From e7d9324df828c2897c5fad5e069ad78bb57b7cb7 Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Fri, 11 Jan 2019 23:35:22 +0300 Subject: [PATCH] fix turbolinks & sidebar --- static/js/custom.init.js | 48 ++++++++++++++++++++++++++++++++++++++++ static/js/theme.js | 48 ---------------------------------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/static/js/custom.init.js b/static/js/custom.init.js index aa46fce..12f838a 100644 --- a/static/js/custom.init.js +++ b/static/js/custom.init.js @@ -3,3 +3,51 @@ $('.modal-basic').magnificPopup({ preloader: false, modal: true }); + +// Bootstrap Toggle +(function($) { + + 'use strict'; + + var $window = $( window ); + + var toggleClass = function( $el ) { + if ( !!$el.data('toggleClassBinded') ) { + return false; + } + + var $target, + className, + eventName; + + $target = $( $el.attr('data-target') ); + className = $el.attr('data-toggle-class'); + eventName = $el.attr('data-fire-event'); + + + $el.on('click.toggleClass', function(e) { + e.preventDefault(); + $target.toggleClass( className ); + + var hasClass = $target.hasClass( className ); + + if ( !!eventName ) { + $window.trigger( eventName, { + added: hasClass, + removed: !hasClass + }); + } + }); + + $el.data('toggleClassBinded', true); + + return true; + }; + + $(function() { + $('[data-toggle-class][data-target]').each(function() { + toggleClass( $(this) ); + }); + }); + +}).apply(this, [jQuery]); diff --git a/static/js/theme.js b/static/js/theme.js index f4cb459..b65d835 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -150,54 +150,6 @@ window.theme.fn = { }).apply(this, [window.theme, jQuery]); -// Bootstrap Toggle -(function($) { - - 'use strict'; - - var $window = $( window ); - - var toggleClass = function( $el ) { - if ( !!$el.data('toggleClassBinded') ) { - return false; - } - - var $target, - className, - eventName; - - $target = $( $el.attr('data-target') ); - className = $el.attr('data-toggle-class'); - eventName = $el.attr('data-fire-event'); - - - $el.on('click.toggleClass', function(e) { - e.preventDefault(); - $target.toggleClass( className ); - - var hasClass = $target.hasClass( className ); - - if ( !!eventName ) { - $window.trigger( eventName, { - added: hasClass, - removed: !hasClass - }); - } - }); - - $el.data('toggleClassBinded', true); - - return true; - }; - - $(function() { - $('[data-toggle-class][data-target]').each(function() { - toggleClass( $(this) ); - }); - }); - -}).apply(this, [jQuery]); - // Cards (function($) {