Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ministack

  • Loading branch information...
commit 05911bdbaecdd4e280a66f52e78c1cfc83eb7aa7 1 parent 2c2adba
@imakewebthings imakewebthings authored
View
1  Makefile
@@ -3,6 +3,7 @@ JS_SOURCES = src/js/microtemplating.js\
src/js/jquery.stackview.base.js \
src/js/jquery.stackview.infinite.js\
src/js/jquery.stackview.navigation.js\
+ src/js/jquery.stackview.ministack.js\
src/js/jquery.stackview.stackcache.js\
src/js/jquery.stackview.templates.js\
src/js/types/book.js\
View
42 lib/jquery.stackview.css
@@ -908,7 +908,7 @@
.stack-webpage > a {
display: inline-block;
position: relative;
- border-radius: 6px 0 2px 0;
+ border-radius: 6px 0 1px 0;
border-width: 1px;
border-style: solid;
color: #555;
@@ -974,7 +974,7 @@
display: block;
position: absolute;
top: -3px;
- bottom: 2px;
+ bottom: 1px;
right: -8px;
width: 6px;
-webkit-transform: skew(0, -20deg);
@@ -985,3 +985,41 @@
border-width: 0 1px 1px 0;
border-style: solid;
}
+
+.stackview-mini .spine-text {
+ left: 5px;
+ margin-top: -5px;
+}
+.stackview-mini .spine-title {
+ font-size: 11px;
+}
+.stackview-mini .spine-author {
+ display: none;
+}
+.stackview-mini .spine-year {
+ font-size: 8px;
+ padding: 0;
+ line-height: 12px;
+ height: 12px;
+ margin-top: -6px;
+ width: 24px;
+ -webkit-transform: rotate(0deg);
+ -moz-transform: rotate(0deg);
+ -o-transform: rotate(0deg);
+ -ms-transform: rotate(0deg);
+ transform: rotate(0deg);
+}
+.stackview-mini .stack-items:before, .stackview-mini .stack-items:after {
+ width: 106px;
+ height: 57px;
+ background-size: contain;
+}
+.stackview-mini .stack-items:after {
+ margin-top: -4px;
+}
+.stackview-mini .ribbon {
+ top: 20px;
+ padding: 4px 5px 4px 14px;
+ min-height: 20px;
+ font-size: 16px;
+}
View
2  lib/jquery.stackview.min.js
@@ -12,4 +12,4 @@
Dual licensed under MIT and GPL.
*/
-(function(e,h,i,c){var l,f="stackView",j,g={};l={init:"stackview.init",item_added:"stackview.itemadded",item_removed:"stackview.itemremoved",page_load:"stackview.pageload"};var b=function(n){var m;e.each(g,function(o,p){if(p.match(n)){m=p;return false}});return m};var d=function(m,q,n){var o=n?"before":"append",p=n?n:m.$element.find(m.options.selectors.item_list);e.each(q,function(s,u){var t=b(u),r;if(t==null){return true}r=e(tmpl(t.template,t.adapter(u,m.options)));r.data("stackviewItem",u);p[o](r)});if(n){n.remove()}};var a=function(m){var n=m.options,o;o={start:m.page*m.options.items_per_page,limit:m.options.items_per_page,search_type:m.options.search_type,query:m.options.query};if(o.search_type==="loc_sort_order"){o.start=0;if(m.page===0){m.loc={low:n.id-Math.floor(n.items_per_page/2),high:n.id+Math.floor(n.items_per_page/2)};o.query=["[",m.loc.low,"%20TO%20",m.loc.high,"]"].join("")}else{if(m.direction==="down"){o.query=["[",m.loc.high+1,"%20TO%20",m.loc.high+n.items_per_page+1,"]"].join("");m.loc.high=m.loc.high+n.items_per_page+1}else{if(m.direction==="up"){o.query=["[",m.loc.low-n.items_per_page-1,"%20TO%20",m.loc.low-1,"]"].join("");m.loc.low=m.loc.low-n.items_per_page-1}}}}return o};var k=function(n,q){var p=a(n),m=e.param(p),o;n.page++;o=h.stackCache.get(n.options.url+m);if(o){q(o)}else{e.ajax({url:n.options.url,data:m,dataType:n.options.jsonp?"jsonp":"json",success:function(r){h.stackCache.set(n.options.url+p,r,n.options.cache_ttl);q(r)}})}};j=function(n,m){this.element=n;this.$element=e(n);this.options=e.extend({},j.defaults,m);this.page=0;this.finished={up:false,down:false};this.loc={low:null,high:null};this.direction="down";this.init()};e.extend(true,j,{defaults:{cache_ttl:60,data:"",id:null,items_per_page:10,jsonp:false,query:"",ribbon:"Stack View",search_type:"keyword",selectors:{item:".stack-item",item_list:".stack-items",ribbon:".ribbon"},url:"basic.json"},utils:{get_heat:function(m){return m===100?10:Math.floor(m/10)+1}},register_type:function(m){g[m.name]=m},get_types:function(){return g}});e.extend(true,j.prototype,{init:function(){var m=this;this.$element.html(tmpl(j.templates.scaffold,{ribbon:this.options.ribbon})).addClass("stackview").bind(l.page_load,function(){m.zIndex()});this.$element.data("stackviewObject",this);this.$element.trigger(l.init);this.next_page()},next_page:function(){var m=e(tmpl(j.templates.placeholder,{})),o=this,n=this.options;if(this.finished.down){return}this.direction="down";if(n.data){d(this,n.data.docs?n.data.docs:n.data);this.finished.down=true;this.$element.trigger(l.page_load,[n.data])}else{if(n.url){this.$element.find(n.selectors.item_list).append(m);k(this,function(p){d(o,p.docs,m);if(parseInt(p.start,10)===-1){o.finished.down=true}o.$element.trigger(l.page_load,[p])})}}},prev_page:function(){var m=e(tmpl(j.templates.placeholder,{})),o=this.options,n=this,p=n.$element.find(o.selectors.item).first();if(o.search_type!=="loc_sort_order"||this.finished.up){return}this.direction="up";this.$element.find(o.selectors.item_list).prepend(m);k(this,function(r){var q=p.position().top;d(n,r.docs,m);if(n.page>1){n.$element.find(o.selectors.item_list).animate({scrollTop:"+="+(p.position().top-q)},0)}if(parseInt(r.start,10)===-1){n.finished.up=true}n.$element.trigger(l.page_load,[r])})},add:function(){var s=this.$element.find(this.options.selectors.item),n,p,o,q,r,m;if(typeof(arguments[0])==="number"){n=arguments[0];p=arguments[1]}else{n=s.length;p=arguments[0]}if(n>s.length||n<0){return}else{if(n===s.length){r=s.last();q="after"}else{r=s.eq(n);q="before"}}o=b(p);if(o==null){return}m=e(tmpl(o.template,o.adapter(p,this.options)));m.data("stackviewItem",p);r[q](m);this.zIndex();this.$element.trigger(l.item_added)},remove:function(m){var q=this.$element.find(this.options.selectors.item),o,p,n;if(typeof(m)==="number"){o=q.eq(m)}else{if(m.nodeType||m.jquery){o=e(m)}else{q.each(function(s,t){var r=e(t);if(r.data("stackviewItem")===m){o=r;return false}})}}if(o==null||!o.length){return}o.detach();p=o.data("stackviewItem");this.$element.trigger(l.item_removed,[p]);return o},getData:function(){var m=[];this.$element.find(this.options.selectors.item).each(function(){m.push(e(this).data("stackviewItem"))});return m},zIndex:function(m){var q=this.$element.find(this.options.selectors.item),o=q.length,n=0,p=m?0:q.length-1;while(n<o){q.eq(n).css("z-index",p);p=p+(m?1:-1);n++}}});e.fn[f]=function(o){var m,n=Array.prototype.slice.call(arguments,1);this.each(function(q,s){var p=e(s),t=p.data("stackviewObject");if(!t){new j(s,o)}else{if(t[o]){var r=t[o].apply(t,n);if(m===c&&r!==c){m=r}}}});return m===c?this:m};h.StackView=j})(jQuery,window,document);(function(c,d){var a=c(document),b;c.extend(StackView.defaults,{infiniteScrollDistance:100});b=function(f){var l=c(f.target),m=l.data("stackviewObject"),e=m.options,g,k,e,h,j,i;g=l.find(e.selectors.item_list);k=l.find(e.selectors.item);h=k.length?k.last().position().top:0;h+=g.scrollTop();j=h-l.height()-e.infiniteScrollDistance;i=function(){if(e.search_type==="loc_sort_order"&&g.scrollTop()<=e.infiniteScrollDistance){g.unbind("scroll.stackview");l.stackView("prev_page")}else{if(g.scrollTop()>=j){g.unbind("scroll.stackview");l.stackView("next_page")}}};g.bind("scroll.stackview",i);i()};a.delegate(".stackview","stackview.pageload",b)})(jQuery);(function(c,d){var b=c(document),a=window.StackView;c.extend(true,a.defaults,{transitionDuration:500,transitionEasing:"easeOutQuad",navigationPercent:80,selectors:{downstream:".downstream",upstream:".upstream",num_items:".num-found span"}});b.delegate(".stackview","stackview.init",function(f){var g=c(f.target),e=g.data("stackviewObject"),i=g.find(e.options.selectors.item_list),h=g.height()*e.options.navigationPercent/100;e.num_found_delta=0;g.prepend(tmpl(a.templates.navigation,{empty:e.options.search_type==="loc_sort_order"}));g.delegate(e.options.selectors.downstream,"click",function(){i.animate({scrollTop:"+="+h},e.options.transitionDuration,e.options.transitionEasing);return false}).delegate(e.options.selectors.upstream,"click",function(){i.animate({scrollTop:"-="+h},e.options.transitionDuration,e.options.transitionEasing);return false})}).delegate(".stackview","stackview.pageload",function(h,i){var j=c(h.target),e=j.data("stackviewObject"),g=i.num_found?parseInt(i.num_found,10):i.length,f;e.num_found=g;f=g+e.num_found_delta;j.find(e.options.selectors.num_items).text(f)}).delegate(".stackview","stackview.itemadded stackview.itemremoved",function(g){var h=c(g.target),e=h.data("stackviewObject"),i=h.find(e.options.selectors.item),f;e.num_found_delta+=(g.namespace==="itemadded"?1:-1);f=e.num_found+e.num_found_delta;h.find(e.options.selectors.num_items).text(f)})})(jQuery);window.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);(function(a){StackView.templates={scaffold:' <div class="ribbon"><%= ribbon %></div> <ul class="stack-items" />',navigation:' <div class="stack-navigation<%= empty ? " empty" : ""%>"> <div class="upstream">Up</div> <div class="num-found"> <span></span><br />items </div> <div class="downstream">Down</div> </div>',book:' <li class="stack-item stack-book heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;"> <a href="<%= link %>" target="_newtab"> <span class="spine-text"> <span class="spine-title"><%= title %></span> <span class="spine-author"><%= author %></span> </span> <span class="spine-year"><%= year %></span> <span class="stack-pages" /> <span class="stack-cover" /> </a> </li>',placeholder:'<li class="stackview-placeholder"></li>'}})();(function(e,d,h){e.extend(true,d.StackView.defaults,{book:{max_height_percentage:100,max_height:39,max_pages:540,min_height_percentage:59,min_height:20,min_pages:200,page_multiple:0.2},selectors:{book:".stack-book"}});var g=function(n,m,j,k,p){var i=j-m,l=p-k,o=(n-m)/(i);return k+o*l};var f=function(l,k){var j=parseInt(k.measurement_height_numeric,10),m=l.book.min_height,i=l.book.max_height;if(isNaN(j)){j=m}j=Math.min(Math.max(j,m),i);j=g(j,l.book.min_height,l.book.max_height,l.book.min_height_percentage,l.book.max_height_percentage);return j+"%"};var b=function(l,k){var n=parseInt(k.measurement_page_numeric,10),m=l.book.min_pages,j=l.book.max_pages,i=l.book.page_multiple;if(isNaN(n)){n=m}n=Math.min(Math.max(n,m),j)*i;return n+"px"};var c=function(i){return i.title_link_friendly?"../shelflife/book/"+i.title_link_friendly+"/"+i.id:i.link};var a=function(j){var i=j.creator&&j.creator.length?j.creator[0]:"";if(/^([^,]*)/.test(i)){i=i.match(/^[^,]*/)}return i};d.StackView.register_type({name:"book",match:function(i){return(i.format&&i.format==="book")||!i.format},adapter:function(j,i){return{heat:d.StackView.utils.get_heat(j.shelfrank),book_height:f(i,j),book_thickness:b(i,j),link:c(j),title:j.title,author:a(j),year:j.pub_date}},template:' <li class="stack-item stack-book heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> <span class="spine-author"><%= author %></span> </span> <span class="spine-year"><%= year %></span> <span class="stack-pages" /> <span class="stack-cover" /> </a> </li>'})})(jQuery,window);(function(b,a,c){b.extend(true,a.StackView.defaults,{selectors:{serial:".stack-serial"}});a.StackView.register_type({name:"serial",match:function(d){return d.format==="Serial"},adapter:function(e,d){return{heat:a.StackView.utils.get_heat(e.shelfrank),title:e.title,link:e.link}},template:' <li class="stack-item stack-serial heat<%= heat %>"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> </span> <span class="serial-edge" /> <span class="serial-cover" /> </a> </li>'})})(jQuery,window);(function(b,a,c){b.extend(true,a.StackView.defaults,{selectors:{soundrecording:".stack-soundrecording"}});a.StackView.register_type({name:"soundrecording",match:function(d){return d.format==="Sound Recording"},adapter:function(e,d){return{heat:a.StackView.utils.get_heat(e.shelfrank),link:"#",title:e.title,year:e.pub_date}},template:' <li class="stack-item stack-soundrecording heat<%= heat %>"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> </span> <span class="spine-year"><%= year %></span> <span class="sound-edge"></span> <span class="sound-cover"></span> </a> </li>'})})(jQuery,window);(function(c,b,d){c.extend(true,b.StackView.defaults,{selectors:{videofilm:".stack-videofilm"}});var a=function(e){return e.title?e.title:"#"};b.StackView.register_type({name:"videofilm",match:function(e){return e.format==="Video/Film"},adapter:function(f,e){return{heat:b.StackView.utils.get_heat(f.shelfrank),height:"65%",title:f.title,year:f.pub_date,link:a(f)}},template:' <li class="stack-item stack-videofilm heat<%= heat %>" style="width:<%= height %>;"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> </span> <span class="spine-year"><%= year %></span> <span class="videofilm-edge" /> <span class="videofilm-cover" /> </a> </li>'})})(jQuery,window);(function(b,a,c){b.extend(true,a.StackView.defaults,{selectors:{webpage:".stack-webpage"}});a.StackView.register_type({name:"webpage",match:function(d){return d.format==="webpage"},adapter:function(e,d){return{heat:a.StackView.utils.get_heat(e.shelfrank),link:e.rsrc_value,publisher:e.publisher,title:e.title}},template:' <li class="stack-item stack-webpage heat<%= heat %>"> <a href="<%= link %>" target="_blank"> <span class="url-bar"> <span class="url-publisher"><%= publisher %>:</span> <span class="url-title"><%= title %></span> </span> <span class="webpage-top"></span> <span class="webpage-edge"></span> </a> </li>'})})(jQuery,window);
+(function(e,h,i,c){var l,f="stackView",j,g={};l={init:"stackview.init",item_added:"stackview.itemadded",item_removed:"stackview.itemremoved",page_load:"stackview.pageload"};var b=function(n){var m;e.each(g,function(o,p){if(p.match(n)){m=p;return false}});return m};var d=function(m,q,n){var o=n?"before":"append",p=n?n:m.$element.find(m.options.selectors.item_list);e.each(q,function(s,u){var t=b(u),r;if(t==null){return true}r=e(tmpl(t.template,t.adapter(u,m.options)));r.data("stackviewItem",u);p[o](r)});if(n){n.remove()}};var a=function(m){var n=m.options,o;o={start:m.page*m.options.items_per_page,limit:m.options.items_per_page,search_type:m.options.search_type,query:m.options.query};if(o.search_type==="loc_sort_order"){o.start=0;if(m.page===0){m.loc={low:n.id-Math.floor(n.items_per_page/2),high:n.id+Math.floor(n.items_per_page/2)};o.query=["[",m.loc.low,"%20TO%20",m.loc.high,"]"].join("")}else{if(m.direction==="down"){o.query=["[",m.loc.high+1,"%20TO%20",m.loc.high+n.items_per_page+1,"]"].join("");m.loc.high=m.loc.high+n.items_per_page+1}else{if(m.direction==="up"){o.query=["[",m.loc.low-n.items_per_page-1,"%20TO%20",m.loc.low-1,"]"].join("");m.loc.low=m.loc.low-n.items_per_page-1}}}}return o};var k=function(n,q){var p=a(n),m=e.param(p),o;n.page++;o=h.stackCache.get(n.options.url+m);if(o){q(o)}else{e.ajax({url:n.options.url,data:m,dataType:n.options.jsonp?"jsonp":"json",success:function(r){h.stackCache.set(n.options.url+p,r,n.options.cache_ttl);q(r)}})}};j=function(n,m){this.element=n;this.$element=e(n);this.options=e.extend({},j.defaults,m);this.page=0;this.finished={up:false,down:false};this.loc={low:null,high:null};this.direction="down";this.init()};e.extend(true,j,{defaults:{cache_ttl:60,data:"",id:null,items_per_page:10,jsonp:false,query:"",ribbon:"Stack View",search_type:"keyword",selectors:{item:".stack-item",item_list:".stack-items",ribbon:".ribbon"},url:"basic.json"},utils:{get_heat:function(m){return m===100?10:Math.floor(m/10)+1}},register_type:function(m){g[m.name]=m},get_types:function(){return g}});e.extend(true,j.prototype,{init:function(){var m=this;this.$element.html(tmpl(j.templates.scaffold,{ribbon:this.options.ribbon})).addClass("stackview").bind(l.page_load,function(){m.zIndex()});this.$element.data("stackviewObject",this);this.$element.trigger(l.init);this.next_page()},next_page:function(){var m=e(tmpl(j.templates.placeholder,{})),o=this,n=this.options;if(this.finished.down){return}this.direction="down";if(n.data){d(this,n.data.docs?n.data.docs:n.data);this.finished.down=true;this.$element.trigger(l.page_load,[n.data])}else{if(n.url){this.$element.find(n.selectors.item_list).append(m);k(this,function(p){d(o,p.docs,m);if(parseInt(p.start,10)===-1){o.finished.down=true}o.$element.trigger(l.page_load,[p])})}}},prev_page:function(){var m=e(tmpl(j.templates.placeholder,{})),o=this.options,n=this,p=n.$element.find(o.selectors.item).first();if(o.search_type!=="loc_sort_order"||this.finished.up){return}this.direction="up";this.$element.find(o.selectors.item_list).prepend(m);k(this,function(r){var q=p.position().top;d(n,r.docs,m);if(n.page>1){n.$element.find(o.selectors.item_list).animate({scrollTop:"+="+(p.position().top-q)},0)}if(parseInt(r.start,10)===-1){n.finished.up=true}n.$element.trigger(l.page_load,[r])})},add:function(){var s=this.$element.find(this.options.selectors.item),n,p,o,q,r,m;if(typeof(arguments[0])==="number"){n=arguments[0];p=arguments[1]}else{n=s.length;p=arguments[0]}if(n>s.length||n<0){return}else{if(n===s.length){r=s.last();q="after"}else{r=s.eq(n);q="before"}}o=b(p);if(o==null){return}m=e(tmpl(o.template,o.adapter(p,this.options)));m.data("stackviewItem",p);r[q](m);this.zIndex();this.$element.trigger(l.item_added)},remove:function(m){var q=this.$element.find(this.options.selectors.item),o,p,n;if(typeof(m)==="number"){o=q.eq(m)}else{if(m.nodeType||m.jquery){o=e(m)}else{q.each(function(s,t){var r=e(t);if(r.data("stackviewItem")===m){o=r;return false}})}}if(o==null||!o.length){return}o.detach();p=o.data("stackviewItem");this.$element.trigger(l.item_removed,[p]);return o},getData:function(){var m=[];this.$element.find(this.options.selectors.item).each(function(){m.push(e(this).data("stackviewItem"))});return m},zIndex:function(m){var q=this.$element.find(this.options.selectors.item),o=q.length,n=0,p=m?0:q.length-1;while(n<o){q.eq(n).css("z-index",p);p=p+(m?1:-1);n++}}});e.fn[f]=function(o){var m,n=Array.prototype.slice.call(arguments,1);this.each(function(q,s){var p=e(s),t=p.data("stackviewObject");if(!t){new j(s,o)}else{if(t[o]){var r=t[o].apply(t,n);if(m===c&&r!==c){m=r}}}});return m===c?this:m};h.StackView=j})(jQuery,window,document);(function(c,d){var a=c(document),b;c.extend(StackView.defaults,{infiniteScrollDistance:100});b=function(f){var l=c(f.target),m=l.data("stackviewObject"),e=m.options,g,k,e,h,j,i;g=l.find(e.selectors.item_list);k=l.find(e.selectors.item);h=k.length?k.last().position().top:0;h+=g.scrollTop();j=h-l.height()-e.infiniteScrollDistance;i=function(){if(e.search_type==="loc_sort_order"&&g.scrollTop()<=e.infiniteScrollDistance){g.unbind("scroll.stackview");l.stackView("prev_page")}else{if(g.scrollTop()>=j){g.unbind("scroll.stackview");l.stackView("next_page")}}};g.bind("scroll.stackview",i);i()};a.delegate(".stackview","stackview.pageload",b)})(jQuery);(function(c,d){var b=c(document),a=window.StackView;c.extend(true,a.defaults,{transitionDuration:500,transitionEasing:"easeOutQuad",navigationPercent:80,selectors:{downstream:".downstream",upstream:".upstream",num_items:".num-found span"}});b.delegate(".stackview","stackview.init",function(f){var g=c(f.target),e=g.data("stackviewObject"),i=g.find(e.options.selectors.item_list),h=g.height()*e.options.navigationPercent/100;e.num_found_delta=0;g.prepend(tmpl(a.templates.navigation,{empty:e.options.search_type==="loc_sort_order"}));g.delegate(e.options.selectors.downstream,"click",function(){i.animate({scrollTop:"+="+h},e.options.transitionDuration,e.options.transitionEasing);return false}).delegate(e.options.selectors.upstream,"click",function(){i.animate({scrollTop:"-="+h},e.options.transitionDuration,e.options.transitionEasing);return false})}).delegate(".stackview","stackview.pageload",function(h,i){var j=c(h.target),e=j.data("stackviewObject"),g=i.num_found?parseInt(i.num_found,10):i.length,f;e.num_found=g;f=g+e.num_found_delta;j.find(e.options.selectors.num_items).text(f)}).delegate(".stackview","stackview.itemadded stackview.itemremoved",function(g){var h=c(g.target),e=h.data("stackviewObject"),i=h.find(e.options.selectors.item),f;e.num_found_delta+=(g.namespace==="itemadded"?1:-1);f=e.num_found+e.num_found_delta;h.find(e.options.selectors.num_items).text(f)})})(jQuery);(function(c,d){var b=c(document),a=window.StackView;c.extend(true,a.defaults,{classes:{ministack:"stackview-mini"},ministack:{breakpoint:220,max_height_percentage:100,min_height_percentage:80,page_multiple:0.08}});b.delegate(".stackview","stackview.init",function(f){var g=c(f.target),e=g.data("stackviewObject");if(g.width()<=e.options.ministack.breakpoint){g.addClass(e.options.classes.ministack);c.each(["max_height_percentage","min_height_percentage","page_multiple"],function(h,j){e.options.book[j]=e.options.ministack[j]})}})})(jQuery);window.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);(function(a){StackView.templates={scaffold:' <div class="ribbon"><%= ribbon %></div> <ul class="stack-items" />',navigation:' <div class="stack-navigation<%= empty ? " empty" : ""%>"> <div class="upstream">Up</div> <div class="num-found"> <span></span><br />items </div> <div class="downstream">Down</div> </div>',book:' <li class="stack-item stack-book heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;"> <a href="<%= link %>" target="_newtab"> <span class="spine-text"> <span class="spine-title"><%= title %></span> <span class="spine-author"><%= author %></span> </span> <span class="spine-year"><%= year %></span> <span class="stack-pages" /> <span class="stack-cover" /> </a> </li>',placeholder:'<li class="stackview-placeholder"></li>'}})();(function(e,d,h){e.extend(true,d.StackView.defaults,{book:{max_height_percentage:100,max_height:39,max_pages:540,min_height_percentage:59,min_height:20,min_pages:200,page_multiple:0.2},selectors:{book:".stack-book"}});var g=function(n,m,j,k,p){var i=j-m,l=p-k,o=(n-m)/(i);return k+o*l};var f=function(l,k){var j=parseInt(k.measurement_height_numeric,10),m=l.book.min_height,i=l.book.max_height;if(isNaN(j)){j=m}j=Math.min(Math.max(j,m),i);j=g(j,l.book.min_height,l.book.max_height,l.book.min_height_percentage,l.book.max_height_percentage);return j+"%"};var b=function(l,k){var n=parseInt(k.measurement_page_numeric,10),m=l.book.min_pages,j=l.book.max_pages,i=l.book.page_multiple;if(isNaN(n)){n=m}n=Math.min(Math.max(n,m),j)*i;return n+"px"};var c=function(i){return i.title_link_friendly?"../shelflife/book/"+i.title_link_friendly+"/"+i.id:i.link};var a=function(j){var i=j.creator&&j.creator.length?j.creator[0]:"";if(/^([^,]*)/.test(i)){i=i.match(/^[^,]*/)}return i};d.StackView.register_type({name:"book",match:function(i){return(i.format&&i.format==="book")||!i.format},adapter:function(j,i){return{heat:d.StackView.utils.get_heat(j.shelfrank),book_height:f(i,j),book_thickness:b(i,j),link:c(j),title:j.title,author:a(j),year:j.pub_date}},template:' <li class="stack-item stack-book heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> <span class="spine-author"><%= author %></span> </span> <span class="spine-year"><%= year %></span> <span class="stack-pages" /> <span class="stack-cover" /> </a> </li>'})})(jQuery,window);(function(b,a,c){b.extend(true,a.StackView.defaults,{selectors:{serial:".stack-serial"}});a.StackView.register_type({name:"serial",match:function(d){return d.format==="Serial"},adapter:function(e,d){return{heat:a.StackView.utils.get_heat(e.shelfrank),title:e.title,link:e.link}},template:' <li class="stack-item stack-serial heat<%= heat %>"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> </span> <span class="serial-edge" /> <span class="serial-cover" /> </a> </li>'})})(jQuery,window);(function(b,a,c){b.extend(true,a.StackView.defaults,{selectors:{soundrecording:".stack-soundrecording"}});a.StackView.register_type({name:"soundrecording",match:function(d){return d.format==="Sound Recording"},adapter:function(e,d){return{heat:a.StackView.utils.get_heat(e.shelfrank),link:"#",title:e.title,year:e.pub_date}},template:' <li class="stack-item stack-soundrecording heat<%= heat %>"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> </span> <span class="spine-year"><%= year %></span> <span class="sound-edge"></span> <span class="sound-cover"></span> </a> </li>'})})(jQuery,window);(function(c,b,d){c.extend(true,b.StackView.defaults,{selectors:{videofilm:".stack-videofilm"}});var a=function(e){return e.title?e.title:"#"};b.StackView.register_type({name:"videofilm",match:function(e){return e.format==="Video/Film"},adapter:function(f,e){return{heat:b.StackView.utils.get_heat(f.shelfrank),height:"65%",title:f.title,year:f.pub_date,link:a(f)}},template:' <li class="stack-item stack-videofilm heat<%= heat %>" style="width:<%= height %>;"> <a href="<%= link %>" target="_blank"> <span class="spine-text"> <span class="spine-title"><%= title %></span> </span> <span class="spine-year"><%= year %></span> <span class="videofilm-edge" /> <span class="videofilm-cover" /> </a> </li>'})})(jQuery,window);(function(b,a,c){b.extend(true,a.StackView.defaults,{selectors:{webpage:".stack-webpage"}});a.StackView.register_type({name:"webpage",match:function(d){return d.format==="webpage"},adapter:function(e,d){return{heat:a.StackView.utils.get_heat(e.shelfrank),link:e.rsrc_value,publisher:e.publisher,title:e.title}},template:' <li class="stack-item stack-webpage heat<%= heat %>"> <a href="<%= link %>" target="_blank"> <span class="url-bar"> <span class="url-publisher"><%= publisher %>:</span> <span class="url-title"><%= title %></span> </span> <span class="webpage-top"></span> <span class="webpage-edge"></span> </a> </li>'})})(jQuery,window);
View
33 src/js/jquery.stackview.ministack.js
@@ -0,0 +1,33 @@
+(function($, undefined) {
+ var $d = $(document),
+ StackView = window.StackView;
+
+ $.extend(true, StackView.defaults, {
+ classes: {
+ ministack: 'stackview-mini'
+ },
+
+ ministack: {
+ breakpoint: 220,
+ max_height_percentage: 100,
+ min_height_percentage: 80,
+ page_multiple: .08
+ }
+ });
+
+ $d.delegate('.stackview', 'stackview.init', function(event) {
+ var $stack = $(event.target),
+ stack = $stack.data('stackviewObject');
+
+ if ($stack.width() <= stack.options.ministack.breakpoint) {
+ $stack.addClass(stack.options.classes.ministack);
+ $.each([
+ 'max_height_percentage',
+ 'min_height_percentage',
+ 'page_multiple'
+ ], function(i, el) {
+ stack.options.book[el] = stack.options.ministack[el];
+ });
+ }
+ });
+})(jQuery);
View
43 src/scss/_ministack.scss
@@ -0,0 +1,43 @@
+.stackview-mini {
+ .spine-text {
+ left:5px;
+ margin-top:-5px;
+ }
+
+ .spine-title {
+ font-size:11px;
+ }
+
+ .spine-author {
+ display:none;
+ }
+
+ .spine-year {
+ font-size:8px;
+ padding:0;
+ line-height:12px;
+ height:12px;
+ margin-top:-6px;
+ width:24px;
+ @include rotate(0deg)
+ }
+
+ .stack-items {
+ &:before, &:after {
+ width:106px;
+ height:57px;
+ background-size:contain;
+ }
+
+ &:after {
+ margin-top:-4px;
+ }
+ }
+
+ .ribbon {
+ top:20px;
+ padding:4px 5px 4px 14px;
+ min-height:20px;
+ font-size:16px;
+ }
+}
View
4 src/scss/_webpage.scss
@@ -5,7 +5,7 @@
> a {
display:inline-block;
position:relative;
- border-radius:6px 0 2px 0;
+ border-radius:6px 0 1px 0;
border-width:1px;
border-style:solid;
color:#555;
@@ -70,7 +70,7 @@
display:block;
position:absolute;
top:-3px;
- bottom:2px;
+ bottom:1px;
right:-8px;
width:6px;
@include skew(0, -20deg);
View
2  src/scss/jquery.stackview.scss
@@ -163,3 +163,5 @@
@import "soundrecording";
@import "videofilm";
@import "webpage";
+
+@import "ministack";
View
3  test/index.html
@@ -13,11 +13,13 @@
<!-- StackView source files -->
<link rel="stylesheet" href="../lib/jquery.stackview.css">
<script src="../src/js/microtemplating.js"></script>
+ <script src="../src/js/jquery.easing.1.3.js"></script>
<script src="../src/js/jquery.stackview.base.js"></script>
<script src="../src/js/jquery.stackview.infinite.js"></script>
<script src="../src/js/jquery.stackview.navigation.js"></script>
<script src="../src/js/jquery.stackview.stackcache.js"></script>
<script src="../src/js/jquery.stackview.templates.js"></script>
+ <script src="../src/js/jquery.stackview.ministack.js"></script>
<script src="../src/js/types/book.js"></script>
<script src="../src/js/types/videofilm.js"></script>
<script src="../src/js/types/serial.js"></script>
@@ -34,6 +36,7 @@
<script src="spec/stackview.infinite.spec.js"></script>
<script src="spec/stackview.navigation.spec.js"></script>
<script src="spec/stackview.types.spec.js"></script>
+ <script src="spec/stackview.ministack.spec.js"></script>
</head>
<body>
View
8 test/preview.html
@@ -10,6 +10,7 @@
<div class="static"></div>
<div class="dynamic"></div>
<div class="types"></div>
+ <div class="mini"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="../lib/jquery.stackview.min.js"></script>
@@ -34,7 +35,12 @@
$('.types').stackView({
data: typeItems,
ribbon: 'Item Types'
- })
+ });
+
+ $('.mini').css('width', StackView.defaults.ministack.breakpoint).stackView({
+ data: inlineData,
+ ribbon: 'Ministack'
+ });
});
</script>
</body>
View
40 test/spec/stackview.ministack.spec.js
@@ -0,0 +1,40 @@
+var opts = StackView.defaults;
+
+describe('Stack View Mini Stack', function() {
+ var $stack;
+
+ beforeEach(function() {
+ loadFixtures('default.html');
+ $('#stack').css('width', opts.ministack.breakpoint);
+ $stack = $('#stack').stackView({
+ data:inlineData
+ });
+ });
+
+ it('should add the ministack class to the stack element', function() {
+ expect($stack).toHaveClass(opts.classes.ministack);
+ });
+
+ it('should not add the ministack class to larger elements', function() {
+ loadFixtures('default.html');
+ $stack = $('#stack').stackView({
+ data:inlineData
+ });
+ expect($stack).not.toHaveClass(opts.classes.ministack);
+ });
+
+ it('should use the ministack page multiplier for books', function() {
+ var stack = $stack.data('stackviewObject');
+ expect(stack.options.book.page_multiple).toEqual(opts.ministack.page_multiple);
+ });
+
+ it('should use the ministack min height percentage for books', function() {
+ var stack = $stack.data('stackviewObject');
+ expect(stack.options.book.min_height_percentage).toEqual(opts.ministack.min_height_percentage);
+ });
+
+ it('should use the ministack max height percentage for books', function() {
+ var stack = $stack.data('stackviewObject');
+ expect(stack.options.book.max_height_percentage).toEqual(opts.ministack.max_height_percentage);
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.