javascript - Has some problems with convering JS code -
i found interesting article here http://vk.com/away.php?utf=1&to=http%3a%2f%2ftympanus.net%2ftutorials%2fanimatedbordermenus%2findex3.html , tried apply on site.
i found problem in conficting modernize + classie vs jquery decided convert code that: before:
function init() { var menu = document.getelementbyid( 'bt-menu' ), trigger = menu.queryselector( 'a.bt-menu-trigger' ), // triggerplay demo 6 triggerplay = document.queryselector( 'a.bt-menu-trigger-out' ), // event type (if mobile use touch events) eventtype = mobilecheck() ? 'touchstart' : 'click', resetmenu = function() { classie.remove( menu, 'bt-menu-open' ); classie.add( menu, 'bt-menu-close' ); }, closeclickfn = function( ev ) { resetmenu(); overlay.removeeventlistener( eventtype, closeclickfn ); }; var overlay = document.createelement('div'); overlay.classname = 'bt-overlay'; menu.appendchild( overlay ); trigger.addeventlistener( eventtype, function( ev ) { ev.stoppropagation(); ev.preventdefault(); if( classie.has( menu, 'bt-menu-open' ) ) { resetmenu(); } else { classie.remove( menu, 'bt-menu-close' ); classie.add( menu, 'bt-menu-open' ); overlay.addeventlistener( eventtype, closeclickfn ); } }); if( triggerplay ) { triggerplay.addeventlistener( eventtype, function( ev ) { ev.stoppropagation(); ev.preventdefault(); classie.remove( menu, 'bt-menu-close' ); classie.add( menu, 'bt-menu-open' ); overlay.addeventlistener( eventtype, closeclickfn ); }); } } init();
after:
function init() { var $menu = $( 'bt-menu' ), eventtype = mobilecheck() ? 'touchstart' : 'click', resetmenu = function() { $menu.removeclass('bt-menu-open' ); $menu.addclass('bt-menu-close' ); }, closeclickfn = function( ev ) { resetmenu(); $overlay.unbind( eventtype, closeclickfn ); }; var $overlay = $("<div class='bt-overlay'/>"); $menu.append( $overlay ); $('bt-menu a.bt-menu-trigger').bind( eventtype, function( ev ) { alert('hi'); ev.stoppropagation(); ev.preventdefault(); if( $menu.hasclass('bt-menu-open' ) ) { resetmenu(); } else { $menu.removeclass('bt-menu-close' ); $menu.addclass('bt-menu-open' ); $overlay.bind( eventtype, closeclickfn ); } }); } init();
but doesnt work , don't know error. can help?
the var $menu = $( 'bt-menu' )
should var $menu = $( '#bt-menu' )
.
Comments
Post a Comment