Skip to content
Browse files

Introduce JS concatenation and minification through YUI compressor + …

…Makefile
  • Loading branch information...
1 parent 49cad1c commit 730896401adc9b73322f609ca68843dcc4253849 @imakewebthings imakewebthings committed Feb 9, 2012
Showing with 46 additions and 1 deletion.
  1. +17 −0 Makefile
  2. BIN bin/yuicompressor-2.4.7.jar
  3. +28 −0 lib/jquery.stackview.min.js
  4. +1 −1 src/js/jquery.stackview.js
View
17 Makefile
@@ -0,0 +1,17 @@
+JS_SOURCES = src/js/jquery.infinitescroller.min.js \
+ src/js/jquery.mousewheel.pack.js \
+ src/js/jquery.stackview.js
+
+JS_OUTPUT = lib/jquery.stackview.min.js
+
+YUI = java -jar bin/yuicompressor-2.4.7.jar
+
+js:
+ cat $(JS_SOURCES) > temp.js
+ $(YUI) -o $(JS_OUTPUT) temp.js
+ rm -f temp.js
+
+clean:
+ rm -f $(JS_OUTPUT)
+
+.PHONY: js clean
View
BIN bin/yuicompressor-2.4.7.jar
Binary file not shown.
View
28 lib/jquery.stackview.min.js
@@ -0,0 +1,28 @@
+/*!
+ * jQuery infiniteScroller - v0.1pre - 9/24/2010
+ * http://benalman.com/
+ *
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+(function(e){var d="infiniteScroller",c;e.fn[d]=c=function(a){a=e.extend({},c.options,a);var b={Width:"Height",Left:"Top"};e.each(b,function(g,h){if(axis==="x"){b[g]=h=g}b[g.toLowerCase()]=h.toLowerCase()});return this.each(function(){var T=e(this),ar=T[0]===document.body?e(window):T,ag=T.children(".scroller-content"),ae,aq,Y=ag.children(".scroller-loading:first-child"),V=ag.children(".scroller-loading:last-child"),W=ah(Y)||0,Q=ah(V)||0,R=0,M=0,U,aa,S,L;ai(false,true);al(ae.eq(0));function O(){var f=L;L=ap();if(a.pagechange&&f!==L){a.pagechange.call(ae.eq(L),ae.eq(f))}if(a.scroll){a.scroll.call(T,ad(T)-R)}if(a.search_type=="loc_sort_order"){am(-1)}am(1)}O();Z();ao();ar.bind("scroll."+d+" resize."+d,O);T.bind("reflow."+d,Z);T.bind("set-zero."+d,ao);T.bind("move-to."+d,function(g,f){X(f)});T.bind("move-by."+d,function(h,g){var f={dir:1,amount:ab("scroll_by")};g=e.extend(f,typeof g==="number"?{amount:g}:g);if(g.amount==="page"){N(g.dir)}else{an(g.dir*g.amount)}});function Z(){ai(true);ac(L,true)}function ai(f,g){ae=ag.children(".scroller-page");aq=[];U=aa=ad(ae.eq(0));ae.each(function(j){var i=e(this);f&&af(i,aa);aq[j]={start:aa,end:aa+ah(i,true)};aa+=ah(i)});W&&af(Y,U-W);Q&&af(V,aa);var h=P();if(h<0){af(ag,W&&Q?(ah(T)-aa)/2:W?ah(T)-aa:Q?U:-h/2)}else{af(ag,W-U);if(g){}}}function al(f){f.addClass("scroller-page").data(d,{})}function N(g,h){var f=L+g;f=Math.min(Math.max(f,0),ae.length);ac(f,h)}function ac(f,g){X(ae.eq(f),g)}function an(g,f,h){X(g,f,h,true)}function X(i,l,t,h){var o=a.scroll_duration,g=ad(T),q,k,s,p,m,r,n;if(i&&typeof i!=="number"){if((q=e(i)).length){m=W-U-R-ab("offset")[0],r=ak(),n=r.start-r.end;k=aq[ae.index(q)];s=k.start;p=k.end;i=(s-p<n?s:(s+p+n)/2)+m}else{return}}S=f(h?g+i:i+R);if(!t){T.stop(true,false);M=0}if(!o||l){j(S)}else{T.scrollTop(g).animate({scrollTop:S},{step:function(v,u){j(v-M)},duration:o})}function f(u){var v=P();return Math.min(Math.max(u,Math.min(0,v)),Math.max(0,v))}function j(u){ar["scroll"+b.Left](f(u))}}function am(k){var l=k!==1,g=ae.eq(l?0:ae.length-1),j=g.data(d),n=a.fetch,m=l?"prev":"next",h=l?W:Q,f=ad(T),i=(l?f:P()-f)-h;if(h&&!j[m]&&e.isFunction(n)&&i<=ab("threshold")){j[m]=true;setTimeout(function(){n.call(g,k,function(p){if(p===false){if(l){M+=W;ao(R-W);an(-W,true,true);Y.hide();W=0}else{V.hide();Q=0}ai()}else{if(p){var o;p=e(p);al(p);if(l){Y.after(p);o=ah(p);af(p,ad(g)-o);ai();ao(R+o);an(o,true,true);M-=o}else{V.before(p);af(p,ad(g)+ah(g));ai()}am(k)}else{delete j[m]}}})},1)}}function ad(f){return f[0]===T[0]?ar["scroll"+b.Left]():f.position()[b.left]}function af(h,g){var f={};if(g!==ad(h)){f[b.left]=g;h.css(f)}}function ah(f,g){return f[0]===ag[0]?W+Q+aa-U:f[(f[0]===T[0]?"inner":"outer")+b.Width](!g)}function aj(g,f){g[b.width](f)}function ab(g){var f=a[g];return e.isFunction(f)?f.call(T,ah(T)):f}function P(){return ah(ag)-ah(T)}function ao(f){R=typeof f==="number"?f:ad(T)}function ak(){var g=ad(T)+U-W,f=ab("offset");return{start:g+f[0],end:g+ah(T)-f[1]}}function ap(){var h=ak(),i=h.start,m=h.end,g,k=[],l=[],f=[],j;e.each(aq,function(p,o){var n=o.start,q=o.end;if(n>=m){return false}if(n>=i){if(q<=m){g=k.push(p)}else{l.push(p)}}else{if(q>i){l.push(p)}}});f=e.map(g?k:l,function(p){var o=aq[p],n=o.start,q=o.end;return{i:p,d:g?Math.abs((i+m-n-q)/2):n<i?i-q:n-m}}).sort(function(n,o){return n.d-o.d});return f.length?f[0].i:0}})};c.options={axis:"x",threshold:function(a){return a},scroll_by:function(a){return a},position:function(a,b){return(a+b)/2},pagechange:function(a){},scroll:function(a){},scroll_duration:400,offset:[0,0],fetch:null}})(jQuery);
+/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
+ * Licensed under the MIT License (LICENSE.txt).
+ *
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
+ *
+ * Version: 3.0.6
+ *
+ * Requires: 1.2.2+
+ */
+(function(f){function b(h){var d=h||window.event,l=[].slice.call(arguments,1),j=0,k=0,i=0,h=f.event.fix(d);h.type="mousewheel";d.wheelDelta&&(j=d.wheelDelta/120);d.detail&&(j=-d.detail/3);i=j;d.axis!==void 0&&d.axis===d.HORIZONTAL_AXIS&&(i=0,k=-1*j);d.wheelDeltaY!==void 0&&(i=d.wheelDeltaY/120);d.wheelDeltaX!==void 0&&(k=-1*d.wheelDeltaX/120);l.unshift(h,j,k,i);return(f.event.dispatch||f.event.handle).apply(this,l)}var g=["DOMMouseScroll","mousewheel"];if(f.event.fixHooks){for(var a=g.length;a;){f.event.fixHooks[g[--a]]=f.event.mouseHooks}}f.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var c=g.length;c;){this.addEventListener(g[--c],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var c=g.length;c;){this.removeEventListener(g[--c],b,false)}}else{this.onmousewheel=null}}};f.fn.extend({mousewheel:function(c){return c?this.bind("mousewheel",c):this.trigger("mousewheel")},unmousewheel:function(c){return this.unbind("mousewheel",c)}})})(jQuery);
+/*!
+ Stack View - The jQuery virutal stack plugin
+ by The Harvard Library Innovation Lab
+
+ Dual licensed under MIT and GPL.
+*/
+(function(b){jQuery.ajaxSettings.traditional=true;var a=+new Date();var c=0;b.fn.stackView=function(d){if(d!==false){d=b.extend({url:"basic.json",data:"",jsonp:false,books_per_page:10,threshold:1000,page_multiple:0.11,height_multiple:12,search_type:"keyword",query:"",ribbon:"Stack View"},d)}return this.each(function(){var e=b(this),i=e.data("scroller"),f;axis="y";e.addClass("scroller");e.html('<div class="scroller-content"><div class="scroller-loading scroller-loading-prev" /><div class="scroller-page" /><div class="scroller-loading scroller-loading-next" /></div>');var h=e.attr("id");var j=h+"-wrapper";e.wrap('<div id="'+j+'" />');b("#"+j).prepend('<div class="navigation"><div class="upstream" /><div class="num-found" /><div class="downstream" /></div><div class="ribbon"><div class="ribbonBody" /><div class="ribbonBehind" /></div>');b("#"+h).bind("mousewheel",function(k,l){b("#"+h).trigger("move-by",-l*75);return false});b("#"+j+" .upstream").live("click",function(){b("#"+h).trigger("move-by",-475);return false});b("#"+j+" .downstream").live("click",function(){b("#"+h).trigger("move-by",475);return false});b(".scroller-page ul li").live("click",function(){window.open(b(this).attr("link"),"_newtab")});b("#"+j+" .ribbonBody").text(d.ribbon);if(d===false){e.unbind(".infiniteScroller");e.replaceWith(i.clone);return}if(!i){e.data("scroller",i={clone:e.clone(),options:d})}function g(m,w,t,o,v,p){var r=d.search_type==="loc_sort_order",l=d.books_per_page*0.5;if(r&&t==="downstream"){d.query="["+w+"%20TO%20"+(w+l)+"]"}if(r&&t==="upstream"){d.query="["+(w-l)+"%20TO%20"+w+"]"}if(r&&t==="center"){d.query="["+(w-6)+"%20TO%20"+(w+l-6)+"]"}var n=b.param({id:d.id,limit:d.books_per_page*(t!=="center"?1:0.5),mode:t,query:d.query,start:o,search_type:d.search_type}),q;if(q=stackCache.get(n)){s(q)}else{var k=d.url.split(".").pop();if(d.data!==""){s(d.data)}else{if(d.jsonp&&k!=="json"){var u=d.url;if(u.indexOf("?")!=-1){u+="&callback=?"}else{u+="?callback=?"}b.getJSON(u,n,s)}else{b.getJSON(d.url,n,function(x){s(x)})}}}function s(y){var C=parseInt(y.start)+parseInt(y.limit);var x=y.num_found-y.start-y.limit;if(x<=0){x=-1}if((!y.docs||!y.docs.length)&&y.start!==0){b("#"+h).find(".scroller-page ul:last").after('<div class="book-end" />');p(false);return}y.start=C;stackCache.set(n,y,60);var B=b.extend([],y.docs);var A=b('<ul class="stack" />');function z(D){if(D>=0&&D<10){return 1}if(D>=10&&D<20){return 2}if(D>=20&&D<30){return 3}if(D>=30&&D<40){return 4}if(D>=40&&D<50){return 5}if(D>=50&&D<60){return 6}if(D>=60&&D<70){return 7}if(D>=70&&D<80){return 8}if(D>=80&&D<90){return 9}if(D>=90&&D<=100){return 10}}if(d.search_type!=="loc_sort_order"){b("#"+j+" .num-found").html(y.num_found+"<br />items").removeClass("empty")}else{b("#"+j+" .num-found").html("").addClass("empty")}b.each(B,function(G,F){if(!F.title){F.title="NULL"}var E="";if(F.measurement_page_numeric){E=F.measurement_page_numeric}if(E===""||E<200||!E){E=200}if(E>540){E=540}var D="";if(F.measurement_height_numeric){D=F.measurement_height_numeric}if(D===""||D<20||!D){D=20}if(D>39){D=39}var I="";if(F.pub_date){I=F.pub_date}var J="";if(parseInt(F.loc_sort_order)===parseInt(d.loc_sort_order)&&t==="center"){J=" anchorbook"}var H="";if(F.creator&&F.creator.length>0){H=F.creator[0];if(/^([^,]*)/.test(H)){H=H.match(/^[^,]*/)}}if(F.title_link_friendly){F.link="../shelflife/book/"+F.title_link_friendly+"/"+F.id}A.append(b('<div class="itemContainer'+J+'" />').html(b('<span class="cover heat'+z(F.shelfrank)+'" />').css("width",D*d.height_multiple+2)).append(b('<span class="pages heat'+z(F.shelfrank)+'" />').css("margin-left",D*d.height_multiple+35).css("margin-bottom",-E*d.page_multiple-11).css("height",E*d.page_multiple+5)).append(b('<li link="'+F.link+'" class="heat'+z(F.shelfrank)+' spine" />').html('<p class="spine-text"><span class="title">'+F.title+'</span><span class="author">'+H+'</span></p><span class="spine-year">'+I+"</span>").css("width",D*d.height_multiple).css("height",E*d.page_multiple)));A.append(b('<div style="clear:both;" />'))});m.empty().attr("id","stackview"+a++).data("scroller",y).append(A);if(parseInt(y.start)<0){b("#"+h).find(".scroller-page ul:last").after('<div class="book-end" />');b("#"+h).find(".scroller-loading-next").remove();e.infiniteScroller();return}else{p(m)}}}if(d.search_type==="loc_sort_order"){g(e.find(".scroller-page"),parseFloat(d.loc_sort_order),"center",0,"",function(){e.infiniteScroller({search_type:d.search_type,axis:d.axis,threshold:d.threshold,fetch:function(m,l){var n=this.data("scroller"),o=m===1?"downstream":"upstream",k=n.docs[m===1?n.docs.length-1:0].loc_sort_order[0]+1;g(b("<div/>").appendTo("body"),k,o,c,d.query,l)},pagechange:function(k){var l=this.data("scroller").docs;i.loc_sort_order=l[parseInt(l.length/2)].loc_sort_order[0]}})})}else{g(e.find(".scroller-page"),d.id,"downstream",0,d.query,function(){e.infiniteScroller({search_type:d.search_type,axis:d.axis,threshold:d.threshold,fetch:function(l,k){var n=this.data("scroller"),p="downstream",q=d.id,m=d.query,o=n.start;g(b("<div/>").appendTo("body"),q,p,o,m,k)}})})}})}})(jQuery);var stackCache=(function(d,f){var b={},e=d.JSON&&(function(){try{return("localStorage" in d)&&d.localStorage!==null}catch(h){return false}})();return{set:g,get:c,remove:a};function g(j,k,h){var i=h&&new Date(+new Date()+h*1000),m={expires:+i,value:k};if(e){try{localStorage[j]=JSON.stringify(m)}catch(l){return l}}else{b[j]=m}}function c(h){var i,j;if(e){i=localStorage[h];if(i){i=JSON.parse(i)}}else{i=b[h]}if(i){if(i.expires&&i.expires<+new Date()){a(h)}else{j=i.value}}return j}function a(h){if(e){localStorage.removeItem(h)}else{delete b[h]}}})(window);
View
2 src/js/jquery.stackview.js
@@ -1,4 +1,4 @@
-/*
+/*!
Stack View - The jQuery virutal stack plugin
by The Harvard Library Innovation Lab

0 comments on commit 7308964

Please sign in to comment.
Something went wrong with that request. Please try again.