Advertisement
bkader

Dinakit Framework [JS File]

Jan 20th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.14 KB | None | 0 0
  1. (function($) {
  2.     'use strict';
  3.     $(document).on('click', 'a[href="#"], a[role="button"]', function(e) {
  4.         e.preventDefault();
  5.     });
  6.  
  7.     // close alerts
  8.     $(document).delegate(".alert-close", "click", function (t){
  9.         t.preventDefault();
  10.         var target = $(this).closest('.alert');
  11.         if(target.length == 0) { return false; }
  12.         target.fadeOut(function () {
  13.             $(this).remove();
  14.         });
  15.     });
  16.  
  17.     // disable active breadcrumb item link
  18.     $(document).on('click', '.breadcrumb > .item.active > a', function (e) {
  19.         e.preventDefault();
  20.         return false;
  21.     });
  22.  
  23.     // Button Dropdown
  24.     $(document).delegate('.btn-dropdown>.toggle-dropdown:not(:disabled)', 'click', function (e) {
  25.         e.preventDefault();
  26.         $(this).closest('.btn-dropdown').toggleClass('open');
  27.     });
  28.     $('html').click(function () {
  29.         $('.btn-dropdown:not(:hover)').removeClass('open');
  30.     });
  31.  
  32.     // collapse
  33.     $(document).delegate('.collapse > .title', 'click', function (e) {
  34.         e.preventDefault();
  35.         var that = $(this), parent = that.closest('.collapse'), target = that.next();
  36.         if($(target).hasClass('active')) {;
  37.             $(target).slideUp('fast', function() {
  38.                 that.removeClass('active');
  39.                 target.removeClass('active');
  40.             });
  41.         } else {
  42.             $(parent).children('.content').slideUp('fast', function () {
  43.                 $(this).removeClass('active');
  44.                 $(this).prev('.title').removeClass('active');
  45.             });
  46.             $(target).hide().addClass('active').slideDown('fase', function () {
  47.                 that.addClass('active');
  48.             });
  49.         }
  50.     });
  51.  
  52.     // label close
  53.     $(document).delegate('.label-close', 'click', function (e) {
  54.         e.preventDefault();
  55.         $(this).closest('.label').fadeOut(function () {
  56.             $(this).remove();
  57.         });
  58.     });
  59.  
  60.     // badge close
  61.     $(document).delegate('.badge-close', 'click', function (e) {
  62.         e.preventDefault();
  63.         $(this).closest('.badge').fadeOut(function () {
  64.             $(this).remove();
  65.         });
  66.     });
  67.  
  68.     // disable pagination active item click
  69.     $(document).on('click', '.pagination>.active>a,.pagination>.disabled>a', function (e) {
  70.         e.preventDefault();
  71.         return false;
  72.     });
  73.  
  74.     // close modals
  75.     $(document).delegate('[data-modal]', 'click', function (e) {
  76.         e.preventDefault();
  77.         var modal = $(this).attr('data-modal');
  78.         if(modal.length == 0 || $(modal).hasClass('open')) { return false; }
  79.         $(modal).addClass('open');
  80.     });
  81.  
  82.     $(document).delegate('.modal-close', 'click', function(e){
  83.         e.preventDefault();
  84.         var modal = $(this).closest(".modal");
  85.         if(modal.length == 0) { return false; }
  86.         modal.removeClass('open').remove();
  87.     });
  88.  
  89.     // scroll to
  90.     $(document).delegate(".scroll","click",function (e) {
  91.         e.preventDefault();
  92.         var target = $(this).attr('href');
  93.         if($(target).length == 0) { return false; }
  94.         $("html, body").animate({ scrollTop: $(target).offset().top }, 1000);
  95.     });
  96.  
  97.     // tabs
  98.     $(document).delegate('.tabs > .controls > .item', 'click', function (e) {
  99.         e.preventDefault();
  100.         var that = $(this),
  101.             target = $(that.attr('href')),
  102.             controls = that.parent(),
  103.             tabs = that.parent().parent();
  104.  
  105.         if($(target).length == 0) { return false; }
  106.         controls.children().removeClass('active');
  107.         that.addClass('active');
  108.         tabs.children('.content').children().removeClass('active');
  109.         $(target).addClass('active');
  110.     });
  111.  
  112.     // checkbox
  113.     $(document).on('click', '.checkbox', function (e) {
  114.         e.preventDefault();
  115.         var $that = $(this), $checkbox = $that.children('input[type="checkbox"]');
  116.         if($checkbox.prop("checked")) {
  117.             $that.removeClass('checked');
  118.             $checkbox.prop('checked', false);
  119.         } else {
  120.             $that.addClass('checked');
  121.             $checkbox.prop('checked', true);
  122.         }
  123.     });
  124. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement