/** * Sitewide Javascript */ jQuery(function($) { /* * Fallback for HTML5 placeholder attribute */ $('textarea[placeholder]').simplePlaceholder(); $('input:text[placeholder]').simplePlaceholder(); /* * filter dropdowns */ $(document).on('click','.dropdownwrap',function(){ var listbox = $(this); var droplist = listbox.find('ul'); if (droplist.hasClass('open')){ droplist.removeClass('open').slideUp('fast'); } else { $('.dropdownwrap ul.open').slideUp('fast').removeClass('open'); listbox.find('ul').stop(true, true).slideToggle('fast').addClass('open'); } }); /* * Info popups - e.g. for user, brand info * * Add .info-popup class to any item and the link will be loaded by ajax and displayed in a popup * The element must specify the page to load for content either in href or data-url attribute * * NOTE - other classes bound (e.g. a.item-info-button) are for compatibility with old code only and should not be used */ $(document).on('click', '.info-popup, a.item-info-button', function(e){ e.preventDefault(); //use data-url attribute, or href if data-url is not specified var loc = $(this).attr('data-url'); if( !loc ){loc = $(this).attr('href');} //insert popup containers $('
').addClass('popup-overlay').prependTo('body'); $('').prependTo('body'); //function to close popup var closePopup = function(){ $('#profile-popup').fadeOut('fast'); $('.popup-overlay').remove(); $(window).unbind('keydown', onKeyPressed); } //for binding escape key to close var onKeyPressed = function(e) { if (e.which == 27) { closePopup(); } } //get popup content $.ajax({ url:loc, //dataType:'json', //data:{'JSON':1}, success:function(d) { $('#profile-popup-inner').html(d); $('#profile-popup').fadeIn(); $(window).bind('keydown', onKeyPressed); $(document).on('click', '#profile-popup-close', closePopup); $(".popup-overlay").click(function(){ closePopup(); }); $('#profile-popup').fadeIn(); }, error:function(d){ console.log("error"); } }); }); /* * Not implemented alert. * * Add not-implemented class to any item where action is not yet implemented and user will get an alert */ $(document).on('click', '.not-implemented', function(e){ e.preventDefault(); alert('This feature has not yet been implemented.'); }); });