1// ------------------------------------------------------------------------------------------- 2// 3// AVIA Magazine function for magazine sorting 4// 5// ------------------------------------------------------------------------------------------- 6(function($) 7{ 8 "use strict"; 9 10 var animating = false, 11 methods = { 12 13 switchMag: function(clicked, _self) 14 { 15 var current = $(clicked); 16 17 if( current.is('.active_sort') || animating ) 18 { 19 return; 20 } 21 22 var filter = current.data('filter'), 23 oldContainer = _self.container.filter(':visible'), 24 newContainer = _self.container.filter( '.' + filter ); 25 26 //switch Class 27 animating = true; 28 _self.sort_buttons.removeClass('active_sort'); 29 current.addClass('active_sort'); 30 31 //apply fixed heiht for transition 32 _self.magazine.height(_self.magazine.outerHeight()); 33 34 //switch items 35 oldContainer.avia_animate({opacity:0}, 200, function() 36 { 37 oldContainer.css({display:'none'}); 38 newContainer.css({opacity:0, display:'block'}).avia_animate({opacity:1}, 150, function() 39 { 40 _self.magazine.avia_animate({height: (newContainer.outerHeight() + _self.sort_bar.outerHeight())}, 150, function() 41 { 42 _self.magazine.height('auto'); 43 animating = false; 44 }); 45 }); 46 }); 47 } 48 }; 49 50 51 $.fn.aviaMagazine = function( options ) 52 { 53 if( ! this.length ) 54 { 55 return; 56 } 57 58 return this.each(function() 59 { 60 var _self = {}; 61 62 _self.magazine = $(this), 63 _self.sort_buttons = _self.magazine.find('.av-magazine-sort a'); 64 _self.container = _self.magazine.find('.av-magazine-group'); 65 _self.sort_bar = _self.magazine.find('.av-magazine-top-bar'); 66 67 // Hide sort buttons that link to an empty container 68 _self.sort_buttons.each( function (i) 69 { 70 var current = $( this ), 71 filter = current.data('filter'), 72 entry = _self.container.filter( '.' + filter ); 73 74 if( entry.length == 0 || entry.html().trim() == '' ) 75 { 76 current.hide(); 77 current.prev('span.text-sep').hide(); 78 } 79 }); 80 81 _self.sort_buttons.on( 'click', function(e) 82 { 83 e.preventDefault(); 84 methods.switchMag(this, _self); 85 }); 86 }); 87 }; 88 89}(jQuery)); 90
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.