1// usage: log('inside coolFunc', this, arguments); 2// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ 3//window.log = function f(){ log.history = log.history || []; log.history.push(arguments); if(this.console) { var args = arguments, newarr; args.callee = args.callee.caller; newarr = [].slice.call(args); if (typeof console.log === 'object') log.apply.call(console.log, console, newarr); else console.log.apply(console, newarr);}}; 4 5// make it safe to use console.log always 6//(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}}) 7//(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}()); 8 9(function( $ ) { 10// place any jQuery/helper plugins in here, instead of separate, slower script files. 11 12// ajax gallery 13jQuery.fn.ajaxGallery = function(o) { 14 // default options 15 var o = jQuery.extend({ 16 holder:'div.mask', 17 btnNext:'a.next', 18 btnPrev:'a.prev', 19 scrollSpeed: 500, 20 activeClass:'active', 21 loadingClass: 'loading', 22 disabledClass:'disabled', 23 nextPostLink: 'a.next-post' 24 }, o) 25 26 return this.each(function() { 27 // options 28 var gal = jQuery(this); 29 var holder = gal.find(o.holder); 30 var btnNext = gal.find(o.btnNext); 31 var btnPrev = gal.find(o.btnPrev); 32 var scrollSpeed = o.scrollSpeed; 33 var activeClass = o.activeClass; 34 var loadingClass = o.loadingClass; 35 var disabledClass = o.disabledClass; 36 var nextPostLink = o.nextPostLink; 37 38 var slider = jQuery('<ul />'); 39 holder.append(slider); 40 var len = 0, holderW = holder.width(), anim = false; 41 42 // ajax slide load 43 function loadSlide(path) { 44 anim = true; 45 gal.addClass(loadingClass); 46 jQuery.ajax({ 47 url: path, 48 data: 'ajax=1', 49 dataType: 'html', 50 type: 'GET', 51 success: function(slide){ 52 anim = false; 53 gal.removeClass(loadingClass); 54 var slide = jQuery(slide); 55 var linkToNextPost = slide.find(nextPostLink); 56 btnNext.attr('href', linkToNextPost.attr('href') || '#'); 57 linkToNextPost.remove(); 58 slider.append(jQuery(slide).addClass(activeClass).css({left: len > 0 ? holderW : 0, top: 0}).attr('rel', path)); 59 if(len > 0) switchSlide(true); 60 len++; 61 refresh(); 62 }, 63 error: function(){ 64 gal.removeClass(loadingClass); 65 alert('ERROR!') 66 } 67 }); 68 } 69 // slide animation 70 function switchSlide(dir) { 71 anim = true; 72 var slides = slider.children(); 73 var curSlide = slides.filter('.' + activeClass); 74 var nextSlide = dir ? curSlide.next().length ? curSlide.next() : slides.eq(0) : curSlide.prev().length ? curSlide.prev() : slides.eq(len - 1); 75 curSlide.removeClass(activeClass).stop().animate({left: dir ? -holderW : holderW}, {duration: scrollSpeed, complete: function() {jQuery(this).hide()}}) 76 nextSlide.addClass(activeClass).show().stop().css({left: dir ? holderW : -holderW}).animate({left: 0}, {duration: scrollSpeed, complete: function() {anim = false}}) 77 slider.stop().animate({height: nextSlide.outerHeight(true)}, {duration: scrollSpeed}) 78 } 79 // refresh buttons 80 function refresh() { 81 len >= 2 ? btnPrev.removeClass(disabledClass) : btnPrev.addClass(disabledClass); 82 } 83 // gallery control 84 btnNext.click(function(e) { 85 if(!anim) { 86 if(btnNext.attr('href') != '#' && !slider.children().filter('.' + activeClass).next().length) loadSlide(btnNext.attr('href')); 87 else switchSlide(true); 88 } 89 e.preventDefault(); 90 }) 91 btnPrev.click(function(e) { 92 if(!anim && len > 1) switchSlide(false); 93 e.preventDefault(); 94 }) 95 // load first slide 96 btnNext.trigger('click'); 97 }) 98} 99 100// open-close plugin 101jQuery.fn.OpenClose = function(_options){ 102 // default options 103 var _options = jQuery.extend({ 104 activeClass:'active', 105 opener:'.opener', 106 slider:'.slide', 107 animSpeed: 400, 108 animStart:false, 109 animEnd:false, 110 effect:'fade', 111 event:'click' 112 },_options); 113 114 return this.each(function(){ 115 // options 116 var _holder = jQuery(this); 117 var _slideSpeed = _options.animSpeed; 118 var _activeClass = _options.activeClass; 119 var _opener = jQuery(_options.opener, _holder); 120 var _slider = jQuery(_options.slider, _holder); 121 var _animStart = _options.animStart; 122 var _animEnd = _options.animEnd; 123 var _effect = _options.effect; 124 var _event = _options.event; 125 if(_slider.length) { 126 _opener.bind(_event,function(e){
127 if(!_slider.is(':animated')) { 128 if(typeof _animStart === 'function') _animStart(); 129 if(_holder.hasClass(_activeClass)) { 130 _slider[_effect=='fade' ? 'fadeOut' : 'slideUp'](_slideSpeed,function(){ 131 if(typeof _animEnd === 'function') _animEnd(); 132 }); 133 _holder.removeClass(_activeClass); 134 } else { 135 _holder.addClass(_activeClass); 136 _slider[_effect=='fade' ? 'fadeIn' : 'slideDown'](_slideSpeed,function(){ 137 if(typeof _animEnd === 'function') _animEnd(); 138 }); 139 } 140 } 141 e.preventDefault(); 142 }); 143 if(_holder.hasClass(_activeClass)) _slider.show(); 144 else _slider.hide(); 145 } 146 }); 147} 148 149// fade drop down 150jQuery.fn.fadeDrop = function(o) { 151 // default options 152 var o = jQuery.extend({ 153 drop: '.drop', 154 items:'> li', 155 fadingClass: 'fading', 156 fadeSpeed: 300 157 }, o) 158 159 return this.each(function() { 160 var items = jQuery(this).find(o.items); 161 var fadingClass = o.fadingClass; 162 var fadeSpeed = o.fadeSpeed; 163 164 var body = jQuery('body'); 165 166 // detect device type 167 var isTouchDevice = (function() { 168 try { 169 document.createEvent('TouchEvent'); 170 return true; 171 } catch (e) { 172 return false; 173 } 174 }()); 175 176 items.each(function() { 177 var item = jQuery(this); 178 var drop = item.find(o.drop); 179 if(drop.length) { 180 drop.css({opacity: 0}); 181 item.bind('mouseenter touchstart', function() { 182 if(isTouchDevice) items.removeClass(fadingClass); 183 item.addClass(fadingClass); 184 drop.stop().animate({opacity: 1}, {duration: fadeSpeed}) 185 }) 186 .bind('mouseleave', function() { 187 drop.stop().animate({opacity: 0}, { 188 duration: fadeSpeed, 189 complete: function() { 190 item.removeClass(fadingClass); 191 } 192 }) 193 }) 194 } 195 }) 196 body.bind('touchstart', function(e) { 197 if(!jQuery(e.target).parents('.' + fadingClass).length) items.removeClass(fadingClass).find(o.drop).css({opacity: 0}); 198 }) 199 }) 200} 201}( jQuery ));
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.