diff --git a/Makefile b/Makefile
index af771a5..2f16c9a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ JS_SOURCES = src/js/microtemplating.js\
src/js/jquery.stackview.stackcache.js\
src/js/jquery.stackview.templates.js\
src/js/types/book.js\
+ src/js/types/book-h.js\
src/js/types/serial.js\
src/js/types/soundrecording.js\
src/js/types/videofilm.js\
@@ -14,6 +15,7 @@ JS_SOURCES = src/js/microtemplating.js\
SCSS_SOURCE = src/scss/jquery.stackview.scss
JS_OUTPUT = lib/jquery.stackview.min.js
+JS_DEBUG_OUTPUT = lib/jquery.stackview.debug.js
CSS_OUTPUT = lib/jquery.stackview.css
CSS_OUTPUT_STYLE = expanded
@@ -26,6 +28,9 @@ js:
$(YUI) -o $(JS_OUTPUT) temp.js
rm -f temp.js
+debug-js:
+ cat $(JS_SOURCES) > $(JS_DEBUG_OUTPUT)
+
css:
sass --style $(CSS_OUTPUT_STYLE) $(SCSS_SOURCE):$(CSS_OUTPUT)
diff --git a/README.md b/README.md
index f5b673f..07a5b12 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,9 @@ The jQuery virtual stack plugin
Check out the [Project Page](http://librarylab.law.harvard.edu/stackview/demo) for more information.
+## Getting Started
+Download [jquery.stackview.min.js](./lib/jquery.stackview.min.js)
+
## Development
A single concatenated and minified `jquery.stackview.min.js` file containing Stack View and all its dependencies is located in `/lib`. Developers making changes to the project should do so in `/src/js` and compile the minified file by running `make js`. If any files in `/src` are added or renamed, they should be added to this list of source files in `Makefile`.
diff --git a/demo/horizontal.html b/demo/horizontal.html
new file mode 100644
index 0000000..b08c5ee
--- /dev/null
+++ b/demo/horizontal.html
@@ -0,0 +1,168 @@
+
+
+
+
+
+
+StackView Horizontal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/hoz2.html b/demo/hoz2.html
new file mode 100644
index 0000000..0b65fdd
--- /dev/null
+++ b/demo/hoz2.html
@@ -0,0 +1,169 @@
+
+
+
+
+
+
+StackView Horizontal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/new.html b/demo/new.html
new file mode 100644
index 0000000..0aa7761
--- /dev/null
+++ b/demo/new.html
@@ -0,0 +1,256 @@
+
+
+
+
+
+
+
+StackView Horizontal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+rendered demo
+
+
+Block demo
+
+Javascript-less demo
+
+
+
+
Up
+
+ 2
+
+ items
+
+
Down
+
+
+
Stack View
+
+
+
+
+
+Standard Basic Stack
+
+
+
+
+
diff --git a/src/js/jquery.easing.1.3.js b/src/js/jquery.easing.1.3.js
index ef74321..d6bac68 100644
--- a/src/js/jquery.easing.1.3.js
+++ b/src/js/jquery.easing.1.3.js
@@ -5,33 +5,33 @@
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
- *
- * Open source under the BSD License.
- *
+ *
+ * Open source under the BSD License.
+ *
* Copyright © 2008 George McGinley Smith
* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
+ *
+ * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
- * Neither the name of the author nor the names of contributors may be used to endorse
+ *
+ * Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -40,166 +40,166 @@ jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{
- def: 'easeOutQuad',
- swing: function (x, t, b, c, d) {
- //alert(jQuery.easing.default);
- return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
- },
- easeInQuad: function (x, t, b, c, d) {
- return c*(t/=d)*t + b;
- },
- easeOutQuad: function (x, t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- },
- easeInOutQuad: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t + b;
- return -c/2 * ((--t)*(t-2) - 1) + b;
- },
- easeInCubic: function (x, t, b, c, d) {
- return c*(t/=d)*t*t + b;
- },
- easeOutCubic: function (x, t, b, c, d) {
- return c*((t=t/d-1)*t*t + 1) + b;
- },
- easeInOutCubic: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t + b;
- return c/2*((t-=2)*t*t + 2) + b;
- },
- easeInQuart: function (x, t, b, c, d) {
- return c*(t/=d)*t*t*t + b;
- },
- easeOutQuart: function (x, t, b, c, d) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
- },
- easeInOutQuart: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
- },
- easeInQuint: function (x, t, b, c, d) {
- return c*(t/=d)*t*t*t*t + b;
- },
- easeOutQuint: function (x, t, b, c, d) {
- return c*((t=t/d-1)*t*t*t*t + 1) + b;
- },
- easeInOutQuint: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
- return c/2*((t-=2)*t*t*t*t + 2) + b;
- },
- easeInSine: function (x, t, b, c, d) {
- return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
- },
- easeOutSine: function (x, t, b, c, d) {
- return c * Math.sin(t/d * (Math.PI/2)) + b;
- },
- easeInOutSine: function (x, t, b, c, d) {
- return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
- },
- easeInExpo: function (x, t, b, c, d) {
- return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
- },
- easeOutExpo: function (x, t, b, c, d) {
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
- },
- easeInOutExpo: function (x, t, b, c, d) {
- if (t==0) return b;
- if (t==d) return b+c;
- if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
- return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
- },
- easeInCirc: function (x, t, b, c, d) {
- return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
- },
- easeOutCirc: function (x, t, b, c, d) {
- return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
- },
- easeInOutCirc: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
- return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
- },
- easeInElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- },
- easeOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
- },
- easeInOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
- easeInBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
- easeOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
- easeInOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
- },
- easeInBounce: function (x, t, b, c, d) {
- return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
- },
- easeOutBounce: function (x, t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- } else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- }
- },
- easeInOutBounce: function (x, t, b, c, d) {
- if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
- return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
+ def: 'easeOutQuad',
+ swing: function (x, t, b, c, d) {
+ //alert(jQuery.easing.default);
+ return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
+ },
+ easeInQuad: function (x, t, b, c, d) {
+ return c*(t/=d)*t + b;
+ },
+ easeOutQuad: function (x, t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
+ },
+ easeInOutQuad: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t + b;
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+ },
+ easeInCubic: function (x, t, b, c, d) {
+ return c*(t/=d)*t*t + b;
+ },
+ easeOutCubic: function (x, t, b, c, d) {
+ return c*((t=t/d-1)*t*t + 1) + b;
+ },
+ easeInOutCubic: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t + b;
+ return c/2*((t-=2)*t*t + 2) + b;
+ },
+ easeInQuart: function (x, t, b, c, d) {
+ return c*(t/=d)*t*t*t + b;
+ },
+ easeOutQuart: function (x, t, b, c, d) {
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ },
+ easeInOutQuart: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ },
+ easeInQuint: function (x, t, b, c, d) {
+ return c*(t/=d)*t*t*t*t + b;
+ },
+ easeOutQuint: function (x, t, b, c, d) {
+ return c*((t=t/d-1)*t*t*t*t + 1) + b;
+ },
+ easeInOutQuint: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
+ return c/2*((t-=2)*t*t*t*t + 2) + b;
+ },
+ easeInSine: function (x, t, b, c, d) {
+ return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
+ },
+ easeOutSine: function (x, t, b, c, d) {
+ return c * Math.sin(t/d * (Math.PI/2)) + b;
+ },
+ easeInOutSine: function (x, t, b, c, d) {
+ return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
+ },
+ easeInExpo: function (x, t, b, c, d) {
+ return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
+ },
+ easeOutExpo: function (x, t, b, c, d) {
+ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
+ },
+ easeInOutExpo: function (x, t, b, c, d) {
+ if (t==0) return b;
+ if (t==d) return b+c;
+ if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
+ return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
+ },
+ easeInCirc: function (x, t, b, c, d) {
+ return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
+ },
+ easeOutCirc: function (x, t, b, c, d) {
+ return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
+ },
+ easeInOutCirc: function (x, t, b, c, d) {
+ if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
+ return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
+ },
+ easeInElastic: function (x, t, b, c, d) {
+ var s=1.70158;var p=0;var a=c;
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ },
+ easeOutElastic: function (x, t, b, c, d) {
+ var s=1.70158;var p=0;var a=c;
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ },
+ easeInOutElastic: function (x, t, b, c, d) {
+ var s=1.70158;var p=0;var a=c;
+ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ },
+ easeInBack: function (x, t, b, c, d, s) {
+ if (s == undefined) s = 1.70158;
+ return c*(t/=d)*t*((s+1)*t - s) + b;
+ },
+ easeOutBack: function (x, t, b, c, d, s) {
+ if (s == undefined) s = 1.70158;
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ },
+ easeInOutBack: function (x, t, b, c, d, s) {
+ if (s == undefined) s = 1.70158;
+ if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ },
+ easeInBounce: function (x, t, b, c, d) {
+ return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
+ },
+ easeOutBounce: function (x, t, b, c, d) {
+ if ((t/=d) < (1/2.75)) {
+ return c*(7.5625*t*t) + b;
+ } else if (t < (2/2.75)) {
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
+ } else if (t < (2.5/2.75)) {
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ } else {
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ }
+ },
+ easeInOutBounce: function (x, t, b, c, d) {
+ if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
+ return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
+ }
});
/*
*
* TERMS OF USE - EASING EQUATIONS
- *
- * Open source under the BSD License.
- *
+ *
+ * Open source under the BSD License.
+ *
* Copyright © 2001 Robert Penner
* All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
+ *
+ * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
- * Neither the name of the author nor the names of contributors may be used to endorse
+ *
+ * Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
*
- */
\ No newline at end of file
+ */
diff --git a/src/js/jquery.stackview.base.js b/src/js/jquery.stackview.base.js
index 9d0c3c3..4a4d923 100644
--- a/src/js/jquery.stackview.base.js
+++ b/src/js/jquery.stackview.base.js
@@ -1,561 +1,590 @@
/*!
- Stack View - The jQuery virtual stack plugin
- by The Harvard Library Innovation Lab
-
- Dual licensed under MIT and GPL.
+ Stack View - The jQuery virtual stack plugin
+ by The Harvard Library Innovation Lab
+
+ Dual licensed under MIT and GPL.
*/
(function($, window, document, undefined) {
- var events,
- plugin = 'stackView',
- StackView,
- types = {};
-
- events = {
- init: 'stackview.init',
- item_added: 'stackview.itemadded',
- item_removed: 'stackview.itemremoved',
- page_load: 'stackview.pageload'
- };
-
- /*
- #get_type
- */
- var get_type = function(item) {
- var type;
-
- $.each(types, function(key, val) {
- if (val.match(item)) {
- type = val;
- return false;
- }
- });
-
- return type;
- };
-
- /*
- #render_items(StackView, array [, jQuery]) - Private
-
- Takes a StackView instance, an array of result items, and an optional
- jQuery object. Renders a DOM element for each of the items and
- appends it to the stack's item list. If [placeholder] is passed in the
- items take the its spot in the DOM.
- */
- var render_items = function(stack, docs, $placeholder) {
- var action = $placeholder ? 'before' : 'append',
- $pivot = $placeholder ?
- $placeholder :
- stack.$element.find(stack.options.selectors.item_list);
-
- $.each(docs, function(i, item) {
- var type = get_type(item),
- $item;
-
- if (type == null) {
- return true;
- }
-
- $item = $(tmpl(type.template, type.adapter(item, stack.options)));
- $item.data('stackviewItem', item);
- $pivot[action]($item);
- });
-
- if ($placeholder) {
- $placeholder.remove();
- }
-
- };
-
- /*
- #calculate_params(StackView) - Private
-
- Takes a StackView instance and returns the parameters for the next page.
- If the Stack uses loc_sort_order, this adjusts the query for that case.
- Returns a plain object with key:value params to be used by $.param.
- */
- var calculate_params = function(stack) {
- var opts = stack.options,
- params;
-
- params = {
- start: stack.page * stack.options.items_per_page,
- limit: stack.options.items_per_page,
- search_type: stack.options.search_type,
- query: stack.options.query
- };
-
- if (params.search_type === 'loc_sort_order') {
- params.start = 0;
-
- if (stack.page === 0) {
- stack.loc = {
- low: opts.id - Math.floor(opts.items_per_page / 2),
- high: opts.id + Math.floor(opts.items_per_page / 2)
- };
- params.query = [
- '[',
- stack.loc.low,
- '%20TO%20',
- stack.loc.high,
- ']'
- ].join('');
- }
- else if (stack.direction === 'down') {
- params.query = [
- '[',
- stack.loc.high + 1,
- '%20TO%20',
- stack.loc.high + opts.items_per_page + 1,
- ']'
- ].join('');
- stack.loc.high = stack.loc.high + opts.items_per_page + 1;
- }
- else if (stack.direction === 'up') {
- params.query = [
- '[',
- stack.loc.low - opts.items_per_page - 1,
- '%20TO%20',
- stack.loc.low - 1,
- ']'
- ].join('');
- stack.loc.low = stack.loc.low - opts.items_per_page - 1;
- }
- }
-
- return params;
- };
-
- /*
- #fetch_page(StackView, function) - Private
-
- Takes a StackView instance and a callback function. Retrieves the
- next page according to the URL and other options of the StackView
- instance. When the page is finished fetching, the callback is
- invoked, passing in the array of items.
- */
- var fetch_page = function(stack, callback) {
- var params = calculate_params(stack),
- querystring = $.param(params),
- cachedResult;
-
- stack.page++;
- cachedResult = window.stackCache.get(stack.options.url + querystring);
-
- if (cachedResult) {
- callback(cachedResult);
- }
- else {
- $.ajax({
- url: stack.options.url,
- data: querystring,
- dataType: stack.options.jsonp ? 'jsonp' : 'json',
- success: function(data) {
- window.stackCache.set(
- stack.options.url + params,
- data,
- stack.options.cache_ttl
- );
- callback(data);
- }
- });
- }
- };
-
-
-
-
- /* StackView constructor, set up instance properties and call init. */
- StackView = function(elem, opts) {
- this.element = elem;
- this.$element = $(elem);
- this.options = $.extend({}, StackView.defaults, opts);
- this.page = 0;
- this.finished = {
- up: false,
- down: false
- };
- this.loc = {
- low: null,
- high: null
- };
- this.direction = 'down';
- this.init();
- };
-
- /* Static properties and functions */
- $.extend(true, StackView, {
-
- /*
- The default options for a StackView instance.
-
- cache_ttl
- How long a request will stay in cache.
-
- data
- An alternative to URL, used for static data. Accepts a typical
- URL response object or a simple array of item objects.
-
- id
- When using a search type of loc_sort_order, this is the id of
- the item that the search centers around.
-
- items_per_page
- The number of items to request each page.
-
- jsonp
- If true, the URL will expect a JSONP request. callback=? will be
- added to the request parameters.
-
- query
- The query passed to the script at URL. Passed as the
- query parameter.
-
- ribbon
- The text of the ribbon at the top of the stack.
-
- search_type
- The type of search to be performed by the script at URL. This is
- passed to the script as the search_type parameter.
-
- selectors
- A number of selectors that are frequently used by the code to
- identify key structures.
-
- item
- A single item in the stack.
-
- item_list
- Container around all of the stack items.
-
- ribbon
- The text ribbon at the top of the stack.
-
- url
- The URL to send requests to for item data.
- */
- 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'
- },
-
- /*
- StackView.get_heat(number)
-
- Takes a value between 0 and 100 and returns a number to be used with
- heat classes to indicate popularity.
- */
- utils: {
- get_heat: function(scaled_value) {
- return scaled_value === 100 ? 10 : Math.floor(scaled_value / 10) + 1;
- }
- },
-
- /*
- StackView.register_type(object)
-
- Registers an item type to be used by the stack. A Type object
- has the following properties:
-
- name: string
- A unique, identifying name of the item type.
-
- match: function(obj) -> obj
- A function that takes a stack item and returns true if the
- item matches this type. Example:
-
- match: function(item) { return item.type === 'book' }
-
- adapter: function(obj, obj) -> obj
- This function allows the user to make transformations to the
- item data before rendering it to the template. It takes as
- parameters a raw item that matches the match function and the
- options from the StackView instance. It should return an object
- to render against "template." If no changes to the raw data need
- to be made, the simplest value for this can be:
-
- adapter: function(item) { return item; }
-
- template: string
- A microtemplating template to render for this type in the stack.
- Receives as its data the return value from "adapter."
-
- */
- register_type: function(obj) {
- types[obj.name] = obj;
- },
-
- /*
- StackView.get_types()
-
- Returns the hash of item types.
- */
- get_types: function() {
- return types;
- }
- });
-
- /*
- StackView public methods
- */
- $.extend(true, StackView.prototype, {
-
- /*
- #init()
-
- Sets up the initial states of a stack. Including:
- - Creating the HTML skeleton.
- - Binding zIndex ordering to the pageload event.
- - Loading the first page.
- - Firing the init event.
- */
- init: function() {
- var that = this;
-
- this.$element
- .html(tmpl(StackView.templates.scaffold, {
- ribbon: this.options.ribbon
- }))
- .addClass('stackview')
- .bind(events.page_load, function() {
- that.zIndex();
- });
-
- this.$element.data('stackviewObject', this);
- this.$element.trigger(events.init);
- this.next_page();
- },
-
- /*
- #next_page()
-
- Loads the next page of stack items. If we've already hit the
- last page, this function does nothing.
- */
- next_page: function() {
- var $placeholder = $(tmpl(StackView.templates.placeholder, {})),
- that = this,
- opts = this.options;
-
- if (this.finished.down) {
- return;
- }
-
- this.direction = 'down';
- if (opts.data) {
- render_items(this, opts.data.docs ? opts.data.docs : opts.data);
- this.finished.down = true;
- this.$element.trigger(events.page_load, [opts.data]);
- }
- else if (opts.url) {
- this.$element
- .find(opts.selectors.item_list)
- .append($placeholder);
- fetch_page(this, function(data) {
- render_items(that, data.docs, $placeholder);
- if (parseInt(data.start, 10) === -1) {
- that.finished.down = true;
- }
- that.$element.trigger(events.page_load, [data]);
- });
- }
- },
-
- /*
- #prev_page()
-
- Loads the previous page of stack items. If we've already hit the
- first page this function does nothing. This function only works
- for stacks using the loc_sort_order search type.
- */
- prev_page: function() {
- var $placeholder = $(tmpl(StackView.templates.placeholder, {})),
- opts = this.options,
- that = this,
- $oldMarker = that.$element.find(opts.selectors.item).first();
-
- if (opts.search_type !== 'loc_sort_order' || this.finished.up) {
- return;
- }
-
- this.direction = 'up';
- this.$element.find(opts.selectors.item_list).prepend($placeholder);
- fetch_page(this, function(data) {
- var oldTop = $oldMarker.position().top;
-
- render_items(that, data.docs, $placeholder);
- if (that.page > 1) {
- that.$element.find(opts.selectors.item_list).animate({
- 'scrollTop': '+=' + ($oldMarker.position().top - oldTop)
- }, 0);
- }
- if (parseInt(data.start, 10) === -1) {
- that.finished.up = true;
- }
- that.$element.trigger(events.page_load, [data]);
- });
- },
-
- /*
- #add([number,] object)
-
- Adds the specified item object to the stack, at the given index if
- provided or at the end (bottom) of the stack if index is not given.
- */
- add: function() {
- var $items = this.$element.find(this.options.selectors.item),
- index, item, type, action, $pivot, $item;
-
- if (typeof(arguments[0]) === 'number') {
- index = arguments[0];
- item = arguments[1];
- }
- else {
- index = $items.length;
- item = arguments[0];
- }
-
- if (index > $items.length || index < 0) {
- return;
- }
- else if (index === $items.length) {
- $pivot = $items.last();
- action = 'after';
- }
- else {
- $pivot = $items.eq(index);
- action = 'before';
- }
-
- type = get_type(item);
- if (type == null) {
- return;
- }
- $item = $(tmpl(type.template, type.adapter(item, this.options)));
-
- $item.data('stackviewItem', item);
- $pivot[action]($item);
- this.zIndex();
- this.$element.trigger(events.item_added);
- },
-
- /*
- #remove(number | object)
-
- If a number is given, it removes the item at that index. If an
- object is given, this method finds the element that represents that
- item and removes it.
- */
- remove: function(arg) {
- var $items = this.$element.find(this.options.selectors.item),
- $found, data, index;
-
- if (typeof(arg) === 'number') {
- $found = $items.eq(arg);
- }
- else if (arg.nodeType || arg.jquery){
- $found = $(arg);
- }
- else {
- $items.each(function(i, el) {
- var $el = $(el);
-
- if ($el.data('stackviewItem') === arg) {
- $found = $el;
- return false;
- }
- });
- }
-
- if ($found == null || !$found.length) {
- return;
- }
-
- $found.detach();
- data = $found.data('stackviewItem');
- this.$element.trigger(events.item_removed, [data]);
- return $found;
- },
-
-
- /*
- #getData()
-
- Returns an array of all the item objects currently in the stack.
- */
- getData: function() {
- var data = [];
-
- this.$element.find(this.options.selectors.item).each(function() {
- data.push($(this).data('stackviewItem'));
- });
-
- return data;
- },
-
- /*
- #zIndex(boolean)
-
- Reverses the natural flow order of the stack items by giving those
- earlier in the source (higher on the stack) a higher z-index. If
- passed true, it will instead assign z-indexes in normal flow order.
- */
- zIndex: function(reverse) {
- var $items = this.$element.find(this.options.selectors.item),
- length = $items.length,
- i = 0,
- z = reverse ? 0 : $items.length - 1;
-
- while (i < length) {
- $items.eq(i).css('z-index', z);
- z = z + (reverse ? 1 : -1);
- i++;
- }
- }
- });
-
- /*
- If .stackView has not been called on an element, the first call will
- initialize the plugin. Subsequent calls expect a method from the
- StackView class. Any method that returns undefined is assumed to
- chain. If the method returns a value, only the value from the first
- element in the jQuery set will be returned, the same as other getters
- in jQuery.
- */
- $.fn[plugin] = function(method) {
- var response,
- args = Array.prototype.slice.call(arguments, 1);
-
- this.each(function(i, el) {
- var $el = $(el),
- obj = $el.data('stackviewObject');
-
- if (!obj) {
- new StackView(el, method);
- }
- else if (obj[method]) {
- var methodResponse = obj[method].apply(obj, args);
-
- if (response === undefined && methodResponse !== undefined) {
- response = methodResponse;
- }
- }
- });
-
- return response === undefined ? this : response;
- };
-
- /* Expose the StackView class for extension */
- window.StackView = StackView;
-})(jQuery, window, document);
\ No newline at end of file
+ var events,
+ plugin = 'stackView',
+ StackView,
+ types = {};
+
+ events = {
+ init: 'stackview.init',
+ item_added: 'stackview.itemadded',
+ item_removed: 'stackview.itemremoved',
+ page_load: 'stackview.pageload'
+ };
+
+ /*
+ #get_type
+ */
+ var get_type = function(item) {
+ var type;
+
+ $.each(types, function(key, val) {
+ if (val.match(item)) {
+ type = val;
+ return false;
+ }
+ });
+
+ return type;
+ };
+
+ /*
+ #render_items(StackView, array [, jQuery]) - Private
+
+ Takes a StackView instance, an array of result items, and an optional
+ jQuery object. Renders a DOM element for each of the items and
+ appends it to the stack's item list. If [placeholder] is passed in the
+ items take the its spot in the DOM.
+ */
+ var render_items = function(stack, docs, $placeholder) {
+ var action = $placeholder ? 'before' : 'append',
+ $pivot = $placeholder ?
+ $placeholder :
+ stack.$element.find(stack.options.selectors.item_list);
+
+ $.each(docs, function(i, item) {
+ var type = get_type(item),
+ $item;
+
+ if (type == null) {
+ return true;
+ }
+
+ // When rendering a horizontal stack, use the horizontal templates
+ if (stack.options.horizontal){
+ var horizontalType = StackView.get_types()['book_h'];
+ $item = $(tmpl(horizontalType.template, type.adapter(item, stack.options)));
+ } else {
+ $item = $(tmpl(type.template, type.adapter(item, stack.options)));
+ }
+ $item.data('stackviewItem', item);
+ $pivot[action]($item);
+ });
+
+ if ($placeholder) {
+ $placeholder.remove();
+ }
+
+ };
+
+ /*
+ #calculate_params(StackView) - Private
+
+ Takes a StackView instance and returns the parameters for the next page.
+ If the Stack uses loc_sort_order, this adjusts the query for that case.
+ Returns a plain object with key:value params to be used by $.param.
+ */
+ var calculate_params = function(stack) {
+ var opts = stack.options,
+ params;
+
+ params = {
+ start: stack.page * stack.options.items_per_page,
+ limit: stack.options.items_per_page,
+ search_type: stack.options.search_type,
+ query: stack.options.query
+ };
+
+ if (params.search_type === 'loc_sort_order') {
+ params.start = 0;
+
+ if (stack.page === 0) {
+ stack.loc = {
+ low: opts.id - Math.floor(opts.items_per_page / 2),
+ high: opts.id + Math.floor(opts.items_per_page / 2)
+ };
+ params.query = [
+ '[',
+ stack.loc.low,
+ '%20TO%20',
+ stack.loc.high,
+ ']'
+ ].join('');
+ }
+ else if (stack.direction === 'down') {
+ params.query = [
+ '[',
+ stack.loc.high + 1,
+ '%20TO%20',
+ stack.loc.high + opts.items_per_page + 1,
+ ']'
+ ].join('');
+ stack.loc.high = stack.loc.high + opts.items_per_page + 1;
+ }
+ else if (stack.direction === 'up') {
+ params.query = [
+ '[',
+ stack.loc.low - opts.items_per_page - 1,
+ '%20TO%20',
+ stack.loc.low - 1,
+ ']'
+ ].join('');
+ stack.loc.low = stack.loc.low - opts.items_per_page - 1;
+ }
+ }
+
+ return params;
+ };
+
+ /*
+ #fetch_page(StackView, function) - Private
+
+ Takes a StackView instance and a callback function. Retrieves the
+ next page according to the URL and other options of the StackView
+ instance. When the page is finished fetching, the callback is
+ invoked, passing in the array of items.
+ */
+ var fetch_page = function(stack, callback) {
+ var params = calculate_params(stack),
+ querystring = $.param(params),
+ cachedResult;
+
+ stack.page++;
+ cachedResult = window.stackCache.get(stack.options.url + querystring);
+
+ if (cachedResult) {
+ callback(cachedResult);
+ }
+ else {
+ $.ajax({
+ url: stack.options.url,
+ data: querystring,
+ dataType: stack.options.jsonp ? 'jsonp' : 'json',
+ success: function(data) {
+ window.stackCache.set(
+ stack.options.url + params,
+ data,
+ stack.options.cache_ttl
+ );
+ callback(data);
+ }
+ });
+ }
+ };
+
+
+
+
+ /* StackView constructor, set up instance properties and call init. */
+ StackView = function(elem, opts) {
+ this.element = elem;
+ this.$element = $(elem);
+ this.options = $.extend({}, StackView.defaults, opts);
+ this.page = 0;
+ this.finished = {
+ up: false,
+ down: false
+ };
+ this.loc = {
+ low: null,
+ high: null
+ };
+ this.direction = 'down';
+ this.init();
+ };
+
+ /* Static properties and functions */
+ $.extend(true, StackView, {
+
+ /*
+ The default options for a StackView instance.
+
+ cache_ttl
+ How long a request will stay in cache.
+
+ data
+ An alternative to URL, used for static data. Accepts a typical
+ URL response object or a simple array of item objects.
+
+ id
+ When using a search type of loc_sort_order, this is the id of
+ the item that the search centers around.
+
+ items_per_page
+ The number of items to request each page.
+
+ jsonp
+ If true, the URL will expect a JSONP request. callback=? will be
+ added to the request parameters.
+
+ query
+ The query passed to the script at URL. Passed as the
+ query parameter.
+
+ ribbon
+ The text of the ribbon at the top of the stack.
+
+ search_type
+ The type of search to be performed by the script at URL. This is
+ passed to the script as the search_type parameter.
+
+ selectors
+ A number of selectors that are frequently used by the code to
+ identify key structures.
+
+ item
+ A single item in the stack.
+
+ item_list
+ Container around all of the stack items.
+
+ ribbon
+ The text ribbon at the top of the stack.
+
+ url
+ The URL to send requests to for item data.
+ */
+ 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'
+ },
+ horizontal: false,
+ decorations: true,
+ url: 'basic.json'
+ },
+
+ /*
+ StackView.get_heat(number)
+
+ Takes a value between 0 and 100 and returns a number to be used with
+ heat classes to indicate popularity.
+ */
+ utils: {
+ get_heat: function(scaled_value) {
+ return scaled_value === 100 ? 10 : Math.floor(scaled_value / 10) + 1;
+ }
+ },
+
+ /*
+ StackView.register_type(object)
+
+ Registers an item type to be used by the stack. A Type object
+ has the following properties:
+
+ name: string
+ A unique, identifying name of the item type.
+
+ match: function(obj) -> obj
+ A function that takes a stack item and returns true if the
+ item matches this type. Example:
+
+ match: function(item) { return item.type === 'book' }
+
+ adapter: function(obj, obj) -> obj
+ This function allows the user to make transformations to the
+ item data before rendering it to the template. It takes as
+ parameters a raw item that matches the match function and the
+ options from the StackView instance. It should return an object
+ to render against "template." If no changes to the raw data need
+ to be made, the simplest value for this can be:
+
+ adapter: function(item) { return item; }
+
+ template: string
+ A microtemplating template to render for this type in the stack.
+ Receives as its data the return value from "adapter."
+
+ */
+ register_type: function(obj) {
+ types[obj.name] = obj;
+ },
+
+ /*
+ StackView.get_types()
+
+ Returns the hash of item types.
+ */
+ get_types: function() {
+ return types;
+ }
+ });
+
+ /*
+ StackView public methods
+ */
+ $.extend(true, StackView.prototype, {
+
+ /*
+ #init()
+
+ Sets up the initial states of a stack. Including:
+ - Creating the HTML skeleton.
+ - Binding zIndex ordering to the pageload event.
+ - Loading the first page.
+ - Firing the init event.
+ */
+ init: function() {
+ var that = this;
+
+ /*
+ * When decorations == false, use the decorationless scaffold
+ */
+ if (this.options.decorations) {
+ this.$element
+ .html(tmpl(StackView.templates.scaffold, {
+ ribbon: this.options.ribbon
+ }));
+ } else {
+ this.$element.html(tmpl(StackView.templates.scaffoldnodecorations));
+ }
+ this.$element.addClass('stackview');
+ /* When 'horizontal' : true
+ * add the stackview-horizontal class to enable special css
+ */
+ if (this.options.horizontal) {
+ this.$element.addClass('stackview-horizontal');
+ } else{
+ // only run the zIndex() function if not running a horizontal stack
+ this.$element.bind(events.page_load, function() {
+ that.zIndex();
+ });
+ }
+
+ this.$element.data('stackviewObject', this);
+ this.$element.trigger(events.init);
+ this.next_page();
+ },
+
+ /*
+ #next_page()
+
+ Loads the next page of stack items. If we've already hit the
+ last page, this function does nothing.
+ */
+ next_page: function() {
+ var $placeholder = $(tmpl(StackView.templates.placeholder, {})),
+ that = this,
+ opts = this.options;
+
+ if (this.finished.down) {
+ return;
+ }
+
+ this.direction = 'down';
+ if (opts.data) {
+ render_items(this, opts.data.docs ? opts.data.docs : opts.data);
+ this.finished.down = true;
+ this.$element.trigger(events.page_load, [opts.data]);
+ }
+ else if (opts.url) {
+ this.$element
+ .find(opts.selectors.item_list)
+ .append($placeholder);
+ fetch_page(this, function(data) {
+ render_items(that, data.docs, $placeholder);
+ if (parseInt(data.start, 10) === -1) {
+ that.finished.down = true;
+ }
+ that.$element.trigger(events.page_load, [data]);
+ });
+ }
+ },
+
+ /*
+ #prev_page()
+
+ Loads the previous page of stack items. If we've already hit the
+ first page this function does nothing. This function only works
+ for stacks using the loc_sort_order search type.
+ */
+ prev_page: function() {
+ var $placeholder = $(tmpl(StackView.templates.placeholder, {})),
+ opts = this.options,
+ that = this,
+ $oldMarker = that.$element.find(opts.selectors.item).first();
+
+ if (opts.search_type !== 'loc_sort_order' || this.finished.up) {
+ return;
+ }
+
+ this.direction = 'up';
+ this.$element.find(opts.selectors.item_list).prepend($placeholder);
+ fetch_page(this, function(data) {
+ var oldTop = $oldMarker.position().top;
+
+ render_items(that, data.docs, $placeholder);
+ if (that.page > 1) {
+ that.$element.find(opts.selectors.item_list).animate({
+ 'scrollTop': '+=' + ($oldMarker.position().top - oldTop)
+ }, 0);
+ }
+ if (parseInt(data.start, 10) === -1) {
+ that.finished.up = true;
+ }
+ that.$element.trigger(events.page_load, [data]);
+ });
+ },
+
+ /*
+ #add([number,] object)
+
+ Adds the specified item object to the stack, at the given index if
+ provided or at the end (bottom) of the stack if index is not given.
+ */
+ add: function() {
+ var $items = this.$element.find(this.options.selectors.item),
+ index, item, type, action, $pivot, $item;
+
+ if (typeof(arguments[0]) === 'number') {
+ index = arguments[0];
+ item = arguments[1];
+ }
+ else {
+ index = $items.length;
+ item = arguments[0];
+ }
+
+ if (index > $items.length || index < 0) {
+ return;
+ }
+ else if (index === $items.length) {
+ $pivot = $items.last();
+ action = 'after';
+ }
+ else {
+ $pivot = $items.eq(index);
+ action = 'before';
+ }
+
+ type = get_type(item);
+ if (type == null) {
+ return;
+ }
+ // When rendering a horizontal stack, use the horizontal templates
+ if (stack.options.horizontal){
+ var horizontalType = StackView.get_types()['book_h'];
+ $item = $(tmpl(horizontalType.template, type.adapter(item, stack.options)));
+ } else {
+ $item = $(tmpl(type.template, type.adapter(item, stack.options)));
+ this.zIndex();
+ }
+
+ $item.data('stackviewItem', item);
+ $pivot[action]($item);
+ this.$element.trigger(events.item_added);
+ },
+
+ /*
+ #remove(number | object)
+
+ If a number is given, it removes the item at that index. If an
+ object is given, this method finds the element that represents that
+ item and removes it.
+ */
+ remove: function(arg) {
+ var $items = this.$element.find(this.options.selectors.item),
+ $found, data, index;
+
+ if (typeof(arg) === 'number') {
+ $found = $items.eq(arg);
+ }
+ else if (arg.nodeType || arg.jquery){
+ $found = $(arg);
+ }
+ else {
+ $items.each(function(i, el) {
+ var $el = $(el);
+
+ if ($el.data('stackviewItem') === arg) {
+ $found = $el;
+ return false;
+ }
+ });
+ }
+
+ if ($found == null || !$found.length) {
+ return;
+ }
+
+ $found.detach();
+ data = $found.data('stackviewItem');
+ this.$element.trigger(events.item_removed, [data]);
+ return $found;
+ },
+
+
+ /*
+ #getData()
+
+ Returns an array of all the item objects currently in the stack.
+ */
+ getData: function() {
+ var data = [];
+
+ this.$element.find(this.options.selectors.item).each(function() {
+ data.push($(this).data('stackviewItem'));
+ });
+
+ return data;
+ },
+
+ /*
+ #zIndex(boolean)
+
+ Reverses the natural flow order of the stack items by giving those
+ earlier in the source (higher on the stack) a higher z-index. If
+ passed true, it will instead assign z-indexes in normal flow order.
+ */
+ zIndex: function(reverse) {
+ var $items = this.$element.find(this.options.selectors.item),
+ length = $items.length,
+ i = 0,
+ z = reverse ? 0 : $items.length - 1;
+
+ while (i < length) {
+ $items.eq(i).css('z-index', z);
+ z = z + (reverse ? 1 : -1);
+ i++;
+ }
+ }
+ });
+
+ /*
+ If .stackView has not been called on an element, the first call will
+ initialize the plugin. Subsequent calls expect a method from the
+ StackView class. Any method that returns undefined is assumed to
+ chain. If the method returns a value, only the value from the first
+ element in the jQuery set will be returned, the same as other getters
+ in jQuery.
+ */
+ $.fn[plugin] = function(method) {
+ var response,
+ args = Array.prototype.slice.call(arguments, 1);
+
+ this.each(function(i, el) {
+ var $el = $(el),
+ obj = $el.data('stackviewObject');
+
+ if (!obj) {
+ new StackView(el, method);
+ }
+ else if (obj[method]) {
+ var methodResponse = obj[method].apply(obj, args);
+
+ if (response === undefined && methodResponse !== undefined) {
+ response = methodResponse;
+ }
+ }
+ });
+
+ return response === undefined ? this : response;
+ };
+
+ /* Expose the StackView class for extension */
+ window.StackView = StackView;
+})(jQuery, window, document);
diff --git a/src/js/jquery.stackview.infinite.js b/src/js/jquery.stackview.infinite.js
index d284aba..35d54ad 100644
--- a/src/js/jquery.stackview.infinite.js
+++ b/src/js/jquery.stackview.infinite.js
@@ -5,42 +5,42 @@
to fire the base methods of next_page and prev_page.
*/
(function($, undefined) {
- var $d = $(document),
- infinite;
-
- /* Extend defaults */
- $.extend(StackView.defaults, {
- infiniteScrollDistance: 100
- });
-
- infinite = function(event) {
- var $stack = $(event.target),
- stack = $stack.data('stackviewObject'),
- opts = stack.options,
- $itemList, $items, opts, lastItemTop, triggerPoint, scrollCheck;
-
- $itemList = $stack.find(opts.selectors.item_list);
- $items = $stack.find(opts.selectors.item);
-
- lastItemTop = $items.length ? $items.last().position().top : 0;
- lastItemTop += $itemList.scrollTop();
- triggerPoint = lastItemTop - $stack.height() - opts.infiniteScrollDistance;
-
- scrollCheck = function() {
- if (opts.search_type === 'loc_sort_order' &&
- $itemList.scrollTop() <= opts.infiniteScrollDistance) {
- $itemList.unbind('scroll.stackview');
- $stack.stackView('prev_page');
- }
- else if ($itemList.scrollTop() >= triggerPoint) {
- $itemList.unbind('scroll.stackview');
- $stack.stackView('next_page');
- }
- };
-
- $itemList.bind('scroll.stackview', scrollCheck);
- scrollCheck();
- };
-
- $d.delegate('.stackview', 'stackview.pageload', infinite);
-})(jQuery);
\ No newline at end of file
+ var $d = $(document),
+ infinite;
+
+ /* Extend defaults */
+ $.extend(StackView.defaults, {
+ infiniteScrollDistance: 100
+ });
+
+ infinite = function(event) {
+ var $stack = $(event.target),
+ stack = $stack.data('stackviewObject'),
+ opts = stack.options,
+ $itemList, $items, opts, lastItemTop, triggerPoint, scrollCheck;
+
+ $itemList = $stack.find(opts.selectors.item_list);
+ $items = $stack.find(opts.selectors.item);
+
+ lastItemTop = $items.length ? $items.last().position().top : 0;
+ lastItemTop += $itemList.scrollTop();
+ triggerPoint = lastItemTop - $stack.height() - opts.infiniteScrollDistance;
+
+ scrollCheck = function() {
+ if (opts.search_type === 'loc_sort_order' &&
+ $itemList.scrollTop() <= opts.infiniteScrollDistance) {
+ $itemList.unbind('scroll.stackview');
+ $stack.stackView('prev_page');
+ }
+ else if ($itemList.scrollTop() >= triggerPoint) {
+ $itemList.unbind('scroll.stackview');
+ $stack.stackView('next_page');
+ }
+ };
+
+ $itemList.bind('scroll.stackview', scrollCheck);
+ scrollCheck();
+ };
+
+ $d.delegate('.stackview', 'stackview.pageload', infinite);
+})(jQuery);
diff --git a/src/js/jquery.stackview.ministack.js b/src/js/jquery.stackview.ministack.js
index 6d9cbd0..d7adf53 100644
--- a/src/js/jquery.stackview.ministack.js
+++ b/src/js/jquery.stackview.ministack.js
@@ -1,33 +1,33 @@
(function($, undefined) {
- var $d = $(document),
- StackView = window.StackView;
+ var $d = $(document),
+ StackView = window.StackView;
- $.extend(true, StackView.defaults, {
- classes: {
- ministack: 'stackview-mini'
- },
+ $.extend(true, StackView.defaults, {
+ classes: {
+ ministack: 'stackview-mini'
+ },
- ministack: {
- breakpoint: 220,
- max_height_percentage: 100,
- min_height_percentage: 80,
- page_multiple: .08
- }
- });
+ 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');
+ $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);
\ No newline at end of file
+ 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);
diff --git a/src/js/jquery.stackview.navigation.js b/src/js/jquery.stackview.navigation.js
index c09a82d..15d9d73 100644
--- a/src/js/jquery.stackview.navigation.js
+++ b/src/js/jquery.stackview.navigation.js
@@ -5,67 +5,67 @@
a # of items indicator.
*/
(function($, undefined) {
- var $d = $(document),
- StackView = window.StackView;
-
- $.extend(true, StackView.defaults, {
- transitionDuration: 500,
- transitionEasing: 'easeOutQuad',
- navigationPercent: 80,
- selectors: {
- downstream: '.downstream',
- upstream: '.upstream',
- num_items: '.num-found span'
- }
- });
-
- $d.delegate('.stackview', 'stackview.init', function(event) {
- var $stack = $(event.target),
- stack = $stack.data('stackviewObject'),
- $items = $stack.find(stack.options.selectors.item_list),
- delta = $stack.height() * stack.options.navigationPercent / 100;
-
- stack.num_found_delta = 0;
- $stack.prepend(tmpl(StackView.templates.navigation, {
- empty: stack.options.search_type === 'loc_sort_order'
- }));
-
- $stack
- .delegate(stack.options.selectors.downstream, 'click', function() {
- $items.animate({
- scrollTop: '+=' + delta
- }, stack.options.transitionDuration, stack.options.transitionEasing);
- return false;
- })
- .delegate(stack.options.selectors.upstream, 'click', function() {
- $items.animate({
- scrollTop: '-=' + delta
- }, stack.options.transitionDuration, stack.options.transitionEasing);
- return false;
- });
-
- }).delegate('.stackview', 'stackview.pageload', function(event, data) {
- var $stack = $(event.target),
- stack = $stack.data('stackviewObject'),
- num_found = data.num_found ? parseInt(data.num_found, 10) : data.length,
- num;
+ var $d = $(document),
+ StackView = window.StackView;
- stack.num_found = num_found;
- num = num_found + stack.num_found_delta;
- $stack.find(stack.options.selectors.num_items).text(num);
-
- }).delegate(
- '.stackview',
- 'stackview.itemadded stackview.itemremoved',
- function(event) {
- var $stack = $(event.target),
- stack = $stack.data('stackviewObject'),
- $items = $stack.find(stack.options.selectors.item),
- num;
+ $.extend(true, StackView.defaults, {
+ transitionDuration: 500,
+ transitionEasing: 'easeOutQuad',
+ navigationPercent: 80,
+ selectors: {
+ downstream: '.downstream',
+ upstream: '.upstream',
+ num_items: '.num-found span'
+ }
+ });
- stack.num_found_delta += (event.namespace === 'itemadded' ? 1 : -1);
- num = stack.num_found + stack.num_found_delta;
- $stack.find(stack.options.selectors.num_items).text(num);
- }
- );
-})(jQuery);
\ No newline at end of file
+ $d.delegate('.stackview', 'stackview.init', function(event) {
+ var $stack = $(event.target),
+ stack = $stack.data('stackviewObject'),
+ $items = $stack.find(stack.options.selectors.item_list),
+ delta = $stack.height() * stack.options.navigationPercent / 100;
+
+ stack.num_found_delta = 0;
+ $stack.prepend(tmpl(StackView.templates.navigation, {
+ empty: stack.options.search_type === 'loc_sort_order'
+ }));
+
+ $stack
+ .delegate(stack.options.selectors.downstream, 'click', function() {
+ $items.animate({
+ scrollTop: '+=' + delta
+ }, stack.options.transitionDuration, stack.options.transitionEasing);
+ return false;
+ })
+ .delegate(stack.options.selectors.upstream, 'click', function() {
+ $items.animate({
+ scrollTop: '-=' + delta
+ }, stack.options.transitionDuration, stack.options.transitionEasing);
+ return false;
+ });
+
+ }).delegate('.stackview', 'stackview.pageload', function(event, data) {
+ var $stack = $(event.target),
+ stack = $stack.data('stackviewObject'),
+ num_found = data.num_found ? parseInt(data.num_found, 10) : data.length,
+ num;
+
+ stack.num_found = num_found;
+ num = num_found + stack.num_found_delta;
+ $stack.find(stack.options.selectors.num_items).text(num);
+
+ }).delegate(
+ '.stackview',
+ 'stackview.itemadded stackview.itemremoved',
+ function(event) {
+ var $stack = $(event.target),
+ stack = $stack.data('stackviewObject'),
+ $items = $stack.find(stack.options.selectors.item),
+ num;
+
+ stack.num_found_delta += (event.namespace === 'itemadded' ? 1 : -1);
+ num = stack.num_found + stack.num_found_delta;
+ $stack.find(stack.options.selectors.num_items).text(num);
+ }
+ );
+})(jQuery);
diff --git a/src/js/jquery.stackview.stackcache.js b/src/js/jquery.stackview.stackcache.js
index 5c53f73..360cb83 100644
--- a/src/js/jquery.stackview.stackcache.js
+++ b/src/js/jquery.stackview.stackcache.js
@@ -1,7 +1,7 @@
window.stackCache = (function(window, undefined){
-
+
var cache = {},
-
+
// "Borrowed" from Modernizr
use_localStorage = window.JSON && (function(){
try {
@@ -10,14 +10,14 @@ window.stackCache = (function(window, undefined){
return false;
}
})();
-
+
// Expose these methods.
return {
set: set,
get: get,
remove: remove
};
-
+
// Set a key-value pair with optional TTL.
function set( key, value, ttl ) {
var expires = ttl && new Date( +new Date() + ttl * 1000 ),
@@ -25,7 +25,7 @@ window.stackCache = (function(window, undefined){
expires: +expires,
value: value
};
-
+
if ( use_localStorage ) {
try {
localStorage[ key ] = JSON.stringify( obj );
@@ -36,12 +36,12 @@ window.stackCache = (function(window, undefined){
cache[ key ] = obj;
}
};
-
+
// Get a value if it exists and hasn't expired.
function get( key ) {
var obj,
val;
-
+
if ( use_localStorage ) {
obj = localStorage[ key ];
if ( obj ) {
@@ -50,7 +50,7 @@ window.stackCache = (function(window, undefined){
} else {
obj = cache[ key ];
}
-
+
if ( obj ) {
if ( obj.expires && obj.expires < +new Date() ) {
remove( key );
@@ -58,10 +58,10 @@ window.stackCache = (function(window, undefined){
val = obj.value;
}
}
-
+
return val;
};
-
+
// Remove a key-value pair.
function remove( key ) {
if ( use_localStorage ) {
@@ -70,5 +70,5 @@ window.stackCache = (function(window, undefined){
delete cache[ key ];
}
};
-
-})(window);
\ No newline at end of file
+
+})(window);
diff --git a/src/js/jquery.stackview.templates.js b/src/js/jquery.stackview.templates.js
index 506ceaa..9351dc0 100644
--- a/src/js/jquery.stackview.templates.js
+++ b/src/js/jquery.stackview.templates.js
@@ -1,31 +1,33 @@
(function(undefined) {
- StackView.templates = {
- scaffold: '\
- <%= ribbon %>
\
- ',
-
- navigation: '\
- ">\
-
Up
\
-
\
- items\
-
\
-
Down
\
-
',
-
- book: '\
- \
- \
- \
- <%= title %> \
- <%= author %> \
- \
- <%= year %> \
- \
- \
- \
- ',
-
- placeholder: ' '
- }
-})();
\ No newline at end of file
+ StackView.templates = {
+ scaffold: '\
+ <%= ribbon %>
\
+ ',
+
+ scaffoldnodecorations: '',
+
+ navigation: '\
+ ">\
+
Up
\
+
\
+ items\
+
\
+
Down
\
+
',
+
+ book: '\
+ \
+ \
+ \
+ <%= title %> \
+ <%= author %> \
+ \
+ <%= year %> \
+ \
+ \
+ \
+ ',
+
+ placeholder: ' '
+ }
+})();
diff --git a/src/js/microtemplating.js b/src/js/microtemplating.js
index 538f36b..054ac30 100644
--- a/src/js/microtemplating.js
+++ b/src/js/microtemplating.js
@@ -6,34 +6,34 @@
MIT Licensed
*/
(function() {
- var cache = {};
+ var cache = {};
- this.tmpl = function tmpl(str, data) {
- // Figure out if we're getting a template, or if we need to
- // load the template - and be sure to cache the result.
- var fn = !/\W/.test(str) ?
- cache[str] = cache[str] || tmpl(document.getElementById(str).innerHTML) :
+ this.tmpl = function tmpl(str, data) {
+ // Figure out if we're getting a template, or if we need to
+ // load the template - and be sure to cache the result.
+ var fn = !/\W/.test(str) ?
+ cache[str] = cache[str] || tmpl(document.getElementById(str).innerHTML) :
- // Generate a reusable function that will serve as a template
- // generator (and which will be cached).
- new Function("obj",
- "var p=[],print=function(){p.push.apply(p,arguments);};" +
+ // Generate a reusable function that will serve as a template
+ // generator (and which will be cached).
+ new Function("obj",
+ "var p=[],print=function(){p.push.apply(p,arguments);};" +
- // Introduce the data as local variables using with(){}
- "with(obj){p.push('" +
+ // Introduce the data as local variables using with(){}
+ "with(obj){p.push('" +
- // Convert the template into pure JavaScript
- str
- .replace(/[\r\t\n]/g, " ")
- .replace(/'(?=[^%]*%>)/g,"\t")
- .split("'").join("\\'")
- .split("\t").join("'")
- .replace(/<%=(.+?)%>/g, "',$1,'")
- .split("<%").join("');")
- .split("%>").join("p.push('")
- + "');}return p.join('');");
+ // Convert the template into pure JavaScript
+ str
+ .replace(/[\r\t\n]/g, " ")
+ .replace(/'(?=[^%]*%>)/g,"\t")
+ .split("'").join("\\'")
+ .split("\t").join("'")
+ .replace(/<%=(.+?)%>/g, "',$1,'")
+ .split("<%").join("');")
+ .split("%>").join("p.push('")
+ + "');}return p.join('');");
- // Provide some basic currying to the user
- return data ? fn(data) : fn;
- };
-})();
\ No newline at end of file
+ // Provide some basic currying to the user
+ return data ? fn(data) : fn;
+ };
+})();
diff --git a/src/js/types/book.js b/src/js/types/book.js
index 371c463..7c99433 100644
--- a/src/js/types/book.js
+++ b/src/js/types/book.js
@@ -1,184 +1,184 @@
(function($, window, undefined) {
- /*
- Extend StackView defaults to include options for this item type.
-
- max_height_percentage
- Books with the maximum height will render as this percentage
- width in the stack.
-
- max_height
- The maximum height in centimeters that an item will render as,
- regardless of the true height of the item.
-
- max_pages
- The maximum number of pages that a book will render as,
- regardless of the true number of pages.
-
- min_height_percentage
- Books with the minimum height will render as this percentage
- width in the stack.
-
- min_height
- The minimum height in centimeters that an item will render as,
- regardless of the true height of the item.
-
- min_pages
- The minimum number of pages that a book will render as,
- regardless of the true number of pages.
-
- page_multiple
- A number that when multiplied by the number of pages in a book
- gives us the total pixel height to be rendered.
-
- selectors.book
- Item selector specific to the book type.
- */
- $.extend(true, window.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.20
- },
-
- selectors: {
- book: '.stack-book'
- }
- });
-
- /*
- #translate(number, number, number, number, number) - Private
-
- Takes a value (the first argument) and two ranges of numbers. Translates
- this value from the first range to the second range. E.g.:
-
- translate(0, 0, 10, 50, 100) returns 50.
- translate(10, 0, 10, 50, 100) returns 100.
- translate(5, 0, 10, 50, 100) returns 75.
-
- http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another
- */
- var translate = function(value, start_min, start_max, end_min, end_max) {
- var start_range = start_max - start_min,
- end_range = end_max - end_min,
- scale = (value - start_min) / (start_range);
-
- return end_min + scale * end_range;
- };
-
- /*
- #get_height(StackView, object) - Private
-
- Takes a StackView options object and a book object. Returns a
- normalized book height percentage, taking into account the minimum
- height, maximum height, height multiple, and translating them onto
- the percentage range specified in the stack options.
- */
- var get_height = function(options, book) {
- var height = parseInt(book.measurement_height_numeric, 10),
- min = options.book.min_height,
- max = options.book.max_height;
-
- if (isNaN(height)) {
- height = min;
- }
- height = Math.min(Math.max(height, min), max);
- height = translate(
- height,
- options.book.min_height,
- options.book.max_height,
- options.book.min_height_percentage,
- options.book.max_height_percentage
- );
- return height + '%';
- };
-
- /*
- #get_thickness(StackView, object) - Private
-
- Takes a StackView instance and a book object. Returns a normalized
- book thickness using the number of book pages, taking into account
- the minimum pages, maximum pages, and pages multiple.
- */
- var get_thickness = function(options, book) {
- var thickness = parseInt(book.measurement_page_numeric, 10),
- min = options.book.min_pages,
- max = options.book.max_pages,
- multiple = options.book.page_multiple;
-
- if (isNaN(thickness)) {
- thickness = min;
- }
- thickness = Math.min(Math.max(thickness, min), max) * multiple;
- return thickness + 'px';
- };
-
- /*
- #normalize_link(object) - Private
-
- Takes an item and returns the item's link, taking into account
- workarounds that may come from inconsistent data structure.
- */
- var normalize_link = function(item) {
- //workaround for link construction from LibraryCloud
- return item.title_link_friendly ?
- '../shelflife/book/' + item.title_link_friendly + '/' + item.id :
- item.link;
- };
-
- /*
- #get_author(object) - Private
-
- Takes an item and returns the item's author, taking the first
- author if an array of authors is defined.
- */
- var get_author = function(item) {
- var author = item.creator && item.creator.length ? item.creator[0] : '';
-
- if(/^([^,]*)/.test(author)) {
- author = author.match(/^[^,]*/);
- }
-
- return author;
- };
-
-
- /*
- Book type definition.
- */
- window.StackView.register_type({
- name: 'book',
-
- match: function(item) {
- return (item.format && item.format === 'book') || !item.format;
- },
-
- adapter: function(item, options) {
- return {
- heat: window.StackView.utils.get_heat(item.shelfrank),
- book_height: get_height(options, item),
- book_thickness: get_thickness(options, item),
- link: normalize_link(item),
- title: item.title,
- author: get_author(item),
- year: item.pub_date
- };
- },
-
- template: '\
- \
- \
- \
- <%= title %> \
- <%= author %> \
- \
- <%= year %> \
- \
- \
- \
- '
- });
-})(jQuery, window);
\ No newline at end of file
+ /*
+ Extend StackView defaults to include options for this item type.
+
+ max_height_percentage
+ Books with the maximum height will render as this percentage
+ width in the stack.
+
+ max_height
+ The maximum height in centimeters that an item will render as,
+ regardless of the true height of the item.
+
+ max_pages
+ The maximum number of pages that a book will render as,
+ regardless of the true number of pages.
+
+ min_height_percentage
+ Books with the minimum height will render as this percentage
+ width in the stack.
+
+ min_height
+ The minimum height in centimeters that an item will render as,
+ regardless of the true height of the item.
+
+ min_pages
+ The minimum number of pages that a book will render as,
+ regardless of the true number of pages.
+
+ page_multiple
+ A number that when multiplied by the number of pages in a book
+ gives us the total pixel height to be rendered.
+
+ selectors.book
+ Item selector specific to the book type.
+ */
+ $.extend(true, window.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.20
+ },
+
+ selectors: {
+ book: '.stack-book'
+ }
+ });
+
+ /*
+ #translate(number, number, number, number, number) - Private
+
+ Takes a value (the first argument) and two ranges of numbers. Translates
+ this value from the first range to the second range. E.g.:
+
+ translate(0, 0, 10, 50, 100) returns 50.
+ translate(10, 0, 10, 50, 100) returns 100.
+ translate(5, 0, 10, 50, 100) returns 75.
+
+ http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another
+ */
+ var translate = function(value, start_min, start_max, end_min, end_max) {
+ var start_range = start_max - start_min,
+ end_range = end_max - end_min,
+ scale = (value - start_min) / (start_range);
+
+ return end_min + scale * end_range;
+ };
+
+ /*
+ #get_height(StackView, object) - Private
+
+ Takes a StackView options object and a book object. Returns a
+ normalized book height percentage, taking into account the minimum
+ height, maximum height, height multiple, and translating them onto
+ the percentage range specified in the stack options.
+ */
+ var get_height = function(options, book) {
+ var height = parseInt(book.measurement_height_numeric, 10),
+ min = options.book.min_height,
+ max = options.book.max_height;
+
+ if (isNaN(height)) {
+ height = min;
+ }
+ height = Math.min(Math.max(height, min), max);
+ height = translate(
+ height,
+ options.book.min_height,
+ options.book.max_height,
+ options.book.min_height_percentage,
+ options.book.max_height_percentage
+ );
+ return height + '%';
+ };
+
+ /*
+ #get_thickness(StackView, object) - Private
+
+ Takes a StackView instance and a book object. Returns a normalized
+ book thickness using the number of book pages, taking into account
+ the minimum pages, maximum pages, and pages multiple.
+ */
+ var get_thickness = function(options, book) {
+ var thickness = parseInt(book.measurement_page_numeric, 10),
+ min = options.book.min_pages,
+ max = options.book.max_pages,
+ multiple = options.book.page_multiple;
+
+ if (isNaN(thickness)) {
+ thickness = min;
+ }
+ thickness = Math.min(Math.max(thickness, min), max) * multiple;
+ return thickness + 'px';
+ };
+
+ /*
+ #normalize_link(object) - Private
+
+ Takes an item and returns the item's link, taking into account
+ workarounds that may come from inconsistent data structure.
+ */
+ var normalize_link = function(item) {
+ //workaround for link construction from LibraryCloud
+ return item.title_link_friendly ?
+ '../shelflife/book/' + item.title_link_friendly + '/' + item.id :
+ item.link;
+ };
+
+ /*
+ #get_author(object) - Private
+
+ Takes an item and returns the item's author, taking the first
+ author if an array of authors is defined.
+ */
+ var get_author = function(item) {
+ var author = item.creator && item.creator.length ? item.creator[0] : '';
+
+ if(/^([^,]*)/.test(author)) {
+ author = author.match(/^[^,]*/);
+ }
+
+ return author;
+ };
+
+
+ /*
+ Book type definition.
+ */
+ window.StackView.register_type({
+ name: 'book',
+
+ match: function(item) {
+ return (item.format && item.format === 'book') || !item.format;
+ },
+
+ adapter: function(item, options) {
+ return {
+ heat: window.StackView.utils.get_heat(item.shelfrank),
+ book_height: get_height(options, item),
+ book_thickness: get_thickness(options, item),
+ link: normalize_link(item),
+ title: item.title,
+ author: get_author(item),
+ year: item.pub_date
+ };
+ },
+
+ template: '\
+ \
+ \
+ \
+ <%= title %> \
+ <%= author %> \
+ \
+ <%= year %> \
+ \
+ \
+ \
+ '
+ });
+})(jQuery, window);
diff --git a/src/scss/_book.scss b/src/scss/_book.scss
index 06556f8..ba99f01 100644
--- a/src/scss/_book.scss
+++ b/src/scss/_book.scss
@@ -1,66 +1,66 @@
.stack-book {
- margin:0 0 2px 0;
-
- > a {
- border-width:1px 2px;
- border-style:solid;
- border-radius:3px / 20px;
- }
+ margin:0 0 2px 0;
- .spine-text {
- height:40px;
- line-height:40px;
- top:50%;
- margin-top:-7px;
- left:15px;
- right:24px;
- }
+ > a {
+ border-width:1px 2px;
+ border-style:solid;
+ border-radius:3px / 20px;
+ }
- .spine-year {
- @include rotate(-90deg);
- }
+ .spine-text {
+ height:40px;
+ line-height:40px;
+ top:50%;
+ margin-top:-7px;
+ left:15px;
+ right:24px;
+ }
+
+ .spine-year {
+ @include rotate(-90deg);
+ }
}
.stack-pages {
- position:absolute;
- z-index:4;
- display:block;
- width:10px;
- right:-6px;
- top:0;
- bottom:-4px;
- border-width:3px 0 3px 2px;
- border-style:solid;
- border-radius:4px 0 0 4px / 20px 0 0 20px;
- @include transform-origin(0 100%);
- @include skew(0deg, -20deg);
-
- &:after {
- position:absolute;
- content:"";
- left:0;
- right:2px;
- top:0;
- bottom:0;
- background:#f5f2e8;
- border-radius:3px 0 0 3px / 20px 0 0 20px;
- border-width:2px 1px 2px 0px;
- border-style:solid;
- border-color:#aaa #e5e5e5 #007acc #ddd;
- }
+ position:absolute;
+ z-index:4;
+ display:block;
+ width:10px;
+ right:-6px;
+ top:0;
+ bottom:-4px;
+ border-width:3px 0 3px 2px;
+ border-style:solid;
+ border-radius:4px 0 0 4px / 20px 0 0 20px;
+ @include transform-origin(0 100%);
+ @include skew(0deg, -20deg);
+
+ &:after {
+ position:absolute;
+ content:"";
+ left:0;
+ right:2px;
+ top:0;
+ bottom:0;
+ background:#f5f2e8;
+ border-radius:3px 0 0 3px / 20px 0 0 20px;
+ border-width:2px 1px 2px 0px;
+ border-style:solid;
+ border-color:#aaa #e5e5e5 #007acc #ddd;
+ }
}
.stack-cover {
- position:absolute;
- z-index:4;
- height:2px;
- border-width:1px;
- border-style:solid;
- border-right-width:2px;
- top:-4px;
- left:0;
- right:5px;
- border-radius:4px 0 0 50px;
- @include transform-origin(0 100%);
- @include skew(-70deg, 0deg);
-}
\ No newline at end of file
+ position:absolute;
+ z-index:4;
+ height:2px;
+ border-width:1px;
+ border-style:solid;
+ border-right-width:2px;
+ top:-4px;
+ left:0;
+ right:5px;
+ border-radius:4px 0 0 50px;
+ @include transform-origin(0 100%);
+ @include skew(-70deg, 0deg);
+}
diff --git a/src/scss/_heatmap.scss b/src/scss/_heatmap.scss
index ed7088b..9a4371e 100644
--- a/src/scss/_heatmap.scss
+++ b/src/scss/_heatmap.scss
@@ -6,149 +6,149 @@
*******************/
.heat1 {
- $bg: #ccebff;
- $border: #adf;
-
- a {
- background-color:$bg;
- background-image:url('images/superGloss.png');
- color:#222;
- text-shadow:0 1px 0 #fff;
- border-color:$border;
-
- &:visited, &:hover, &:active {
- color:#222;
- }
- }
-
- @include decorations($bg, $border);
+ $bg: #ccebff;
+ $border: #adf;
+
+ a {
+ background-color:$bg;
+ background-image:url('images/superGloss.png');
+ color:#222;
+ text-shadow:0 1px 0 #fff;
+ border-color:$border;
+
+ &:visited, &:hover, &:active {
+ color:#222;
+ }
+ }
+
+ @include decorations($bg, $border);
}
.heat2 {
- $bg: #adf;
- $border: #88cfff;
-
- a {
- background-color:$bg;
- background-image:url('images/superGloss.png');
- color:#222;
- text-shadow:0 1px 0 #ddf1ff;
- border-color:$border;
-
- &:visited, &:hover, &:active {
- color:#222;
- }
- }
-
- @include decorations($bg, $border);
+ $bg: #adf;
+ $border: #88cfff;
+
+ a {
+ background-color:$bg;
+ background-image:url('images/superGloss.png');
+ color:#222;
+ text-shadow:0 1px 0 #ddf1ff;
+ border-color:$border;
+
+ &:visited, &:hover, &:active {
+ color:#222;
+ }
+ }
+
+ @include decorations($bg, $border);
}
.heat3 {
- $bg: #77c9ff;
- $border: #59b6ef;
-
- a {
- background-color:$bg;
- background-image:url('images/highGloss.png');
- color:#111;
- text-shadow:0 1px 0 #adf;
- border-color:$border;
-
- &:visited, &:hover, &:active {
- color:#111;
- }
- }
-
- @include decorations($bg, $border);
+ $bg: #77c9ff;
+ $border: #59b6ef;
+
+ a {
+ background-color:$bg;
+ background-image:url('images/highGloss.png');
+ color:#111;
+ text-shadow:0 1px 0 #adf;
+ border-color:$border;
+
+ &:visited, &:hover, &:active {
+ color:#111;
+ }
+ }
+
+ @include decorations($bg, $border);
}
.heat4 {
- $bg: #44b4ff;
- $border: #11a0ff;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 $border;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #44b4ff;
+ $border: #11a0ff;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 $border;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
.heat5 {
- $bg: #22a7ff;
- $border: #008fee;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 $border;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #22a7ff;
+ $border: #008fee;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 $border;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
.heat6 {
- $bg: #0099ff;
- $border: #007acc;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 #0085dd;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #0099ff;
+ $border: #007acc;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 #0085dd;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
.heat7 {
- $bg: #0085dd;
- $border: #06a;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 #0070bb;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #0085dd;
+ $border: #06a;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 #0070bb;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
.heat8 {
- $bg: #0070bb;
- $border: #004777;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 #005c99;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #0070bb;
+ $border: #004777;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 #005c99;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
.heat9 {
- $bg: #005c99;
- $border: #002944;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 #004777;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #005c99;
+ $border: #002944;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 #004777;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
.heat10 {
- $bg: #004777;
- $border: #001522;
-
- a {
- background-color:$bg;
- text-shadow:0 -1px 0 #035;
- border-color:$border;
- }
-
- @include decorations($bg, $border);
+ $bg: #004777;
+ $border: #001522;
+
+ a {
+ background-color:$bg;
+ text-shadow:0 -1px 0 #035;
+ border-color:$border;
+ }
+
+ @include decorations($bg, $border);
}
diff --git a/src/scss/_horizontalstack.scss b/src/scss/_horizontalstack.scss
new file mode 100644
index 0000000..fa80be1
--- /dev/null
+++ b/src/scss/_horizontalstack.scss
@@ -0,0 +1,162 @@
+.stackview-horizontal {
+ .stack-horizontal {
+ width: 100%;
+ }
+
+ .stack-items {
+ /* The UL tag that contains books.
+ * This element is also what creates the bookends
+ * as before & after
+ */
+
+ &:before, &:after {
+ content: '';
+ height: 0;
+ width: 0;
+ display: none;
+ }
+ }
+
+ .stack-book {
+ margin: 0 2px 0 0;
+ position: relative;
+ display: inline-block;
+
+ // Temp styles
+ height: 400px;
+ width: 100px;
+ /*background-color: blue;*/
+ /*border: 4px solid black;*/
+ // end temp styles
+
+ > a {
+ border-width:2px 1px;
+ border-radius:20px / 5px; /* non-rotated was 3px / 20px */
+ }
+ }
+
+ .book-horizontal {
+ position: relative;
+ display: inline-block;
+ margin-top: 80px; /* allow for room for the book pages on top */
+
+ /* These are temporary styles that we're going to use to debug parts of the interface*/
+ /*border: 4px solid black;*/
+ height: 400px;
+ width: 100px;
+
+ > a {
+ display:block;
+ text-decoration:none;
+ width: 100%;
+ height: 100%;
+ color:#fff;
+ white-space:nowrap;
+ }
+ }
+
+ .spine-text {
+ // TODO: position this properly?
+ // make correct width, render, then rotate
+ // transform-origin to set pivot point
+ // this must fill the element to
+ width: 100%;
+ height: 100%;
+ top: 10px;
+ left: auto;
+ right: auto;
+ position: relative;
+ }
+
+ .spine-title {
+ position: absolute;
+ font-size:24px;
+ left: 50%;
+ @include rotate(90deg);
+ @include transform-origin(left);
+ }
+
+ .spine-author {
+ position: absolute;
+ bottom: 29%;
+ left: 50%;
+ @include rotate(90deg);
+ @include transform-origin(left);
+ }
+
+ .spine-year {
+ // coppied from ministack
+ font-size:8px;
+ padding:0;
+ line-height:12px;
+ height:12px;
+ margin-top:-6px;
+ width:24px;
+ // my overrides
+ top: auto;
+ left: calc(50% - 12px);
+ right: auto;
+ bottom: 3px;
+ @include rotate(0deg)
+ }
+
+ // TODO make this at the top
+ .stack-pages {
+ width: 100%;
+ height: 30px;
+ top: -26px;
+ left: 12px;
+ border-width:0 3px 2px 3px;
+ border-radius: 0 0 15px 15px / 0 0 4px 4px ;
+
+ /*border-color: lightgray;*/
+ /*background-color: goldenrod;*/
+
+ @include transform-origin(100% 0);
+ @include skew(-24deg, 0deg);
+
+ &:after {
+ position:absolute;
+
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: -1px;
+
+ background:#f5f2e8;
+ border-radius:0 0 15px 15px / 0 0 3px 3px;
+ border-width:1px 2px 0px 2px;
+ border-style:solid;
+ border-color: #e5e5e5 #007acc #ddd #aaa;
+ }
+ }
+
+ .stack-cover {
+ position:absolute;
+ top:0;
+ right:-15px;
+ left: auto; /*override*/
+ z-index:4;
+
+ width:11px;
+ height: 100%;
+
+ //background-color: lightblue;
+ //border-color: gray;
+ border-style:solid;
+ border-width:1px;
+ border-top-width:5px;
+ border-radius: 0 0 4px 50px;
+
+
+ @include transform-origin(left bottom);
+ @include skew(0deg, -65deg);
+ }
+
+ .ribbon {
+ top:20px;
+ padding:4px 5px 4px 14px;
+ min-height:20px;
+ font-size:16px;
+ }
+}
diff --git a/src/scss/_ministack.scss b/src/scss/_ministack.scss
index 449ff2c..bab554e 100644
--- a/src/scss/_ministack.scss
+++ b/src/scss/_ministack.scss
@@ -1,43 +1,43 @@
.stackview-mini {
- .spine-text {
- left:5px;
- margin-top:-5px;
- }
+ .spine-text {
+ left:5px;
+ margin-top:-5px;
+ }
- .spine-title {
- font-size:11px;
- }
+ .spine-title {
+ font-size:11px;
+ }
- .spine-author {
- display:none;
- }
+ .spine-author {
+ display:none;
+ }
- .spine-year {
- font-size:8px;
- padding:0;
- line-height:12px;
- height:12px;
- margin-top:-6px;
- width:24px;
- @include rotate(0deg)
- }
+ .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;
- }
+ .stack-items {
+ &:before, &:after {
+ width:106px;
+ height:57px;
+ background-size:contain;
+ }
- &:after {
- margin-top:-4px;
- }
- }
+ &:after {
+ margin-top:-4px;
+ }
+ }
- .ribbon {
- top:20px;
- padding:4px 5px 4px 14px;
- min-height:20px;
- font-size:16px;
- }
-}
\ No newline at end of file
+ .ribbon {
+ top:20px;
+ padding:4px 5px 4px 14px;
+ min-height:20px;
+ font-size:16px;
+ }
+}
diff --git a/src/scss/_mixins.scss b/src/scss/_mixins.scss
index 49a2f44..7d13aaf 100644
--- a/src/scss/_mixins.scss
+++ b/src/scss/_mixins.scss
@@ -1,92 +1,92 @@
@mixin rotate($deg) {
- -webkit-transform:rotate($deg);
- -moz-transform:rotate($deg);
- -o-transform:rotate($deg);
- -ms-transform:rotate($deg);
- transform:rotate($deg);
+ -webkit-transform:rotate($deg);
+ -moz-transform:rotate($deg);
+ -o-transform:rotate($deg);
+ -ms-transform:rotate($deg);
+ transform:rotate($deg);
}
@mixin transform-origin($val) {
- -o-transform-origin:$val;
- -ms-transform-origin:$val;
- -moz-transform-origin:$val;
- -webkit-transform-origin:$val;
- transform-origin:$val;
+ -o-transform-origin:$val;
+ -ms-transform-origin:$val;
+ -moz-transform-origin:$val;
+ -webkit-transform-origin:$val;
+ transform-origin:$val;
}
@mixin skew($x, $y) {
- -webkit-transform:skew($x, $y);
- -moz-transform:skew($x, $y);
- -o-transform:skew($x, $y);
- -ms-transform:skew($x, $y);
- transform:skew($x, $y);
+ -webkit-transform:skew($x, $y);
+ -moz-transform:skew($x, $y);
+ -o-transform:skew($x, $y);
+ -ms-transform:skew($x, $y);
+ transform:skew($x, $y);
}
@mixin user-select($val) {
- -webkit-user-select:$val;
- -moz-user-select:$val;
- -ms-user-select:$val;
- user-select:$val;
+ -webkit-user-select:$val;
+ -moz-user-select:$val;
+ -ms-user-select:$val;
+ user-select:$val;
}
@mixin tap-highlight-color($val) {
- -webkit-tap-highlight-color:$val;
- -moz-tap-highlight-color:$val;
- tap-highlight-color:$val;
+ -webkit-tap-highlight-color:$val;
+ -moz-tap-highlight-color:$val;
+ tap-highlight-color:$val;
}
@mixin book-decoration($bg, $border) {
- .stack-pages {
- border-color:$border;
- }
-
- .stack-cover {
- border-color:$border;
- background:$bg;
- }
+ .stack-pages {
+ border-color:$border;
+ }
+
+ .stack-cover {
+ border-color:$border;
+ background:$bg;
+ }
}
@mixin videofilm-decoration($bg, $border) {
- .videofilm-cover {
- background:$bg;
- border-color:$border;
- }
+ .videofilm-cover {
+ background:$bg;
+ border-color:$border;
+ }
}
@mixin serial-decoration($bg, $border) {
- .serial-edge {
- background-color:$bg;
- border-color:$border;
- }
+ .serial-edge {
+ background-color:$bg;
+ border-color:$border;
+ }
- .serial-cover {
- background:$bg;
- border-color:$border;
- }
+ .serial-cover {
+ background:$bg;
+ border-color:$border;
+ }
}
@mixin sound-decoration($bg, $border) {
- .sound-edge {
- background-color:$bg;
- }
+ .sound-edge {
+ background-color:$bg;
+ }
- .sound-cover {
- background:$bg;
- border-color:$border;
- }
+ .sound-cover {
+ background:$bg;
+ border-color:$border;
+ }
}
@mixin webpage-decoration($bg, $border) {
- .webpage-top, .webpage-edge {
- background:$bg;
- border-color:$border;
- }
+ .webpage-top, .webpage-edge {
+ background:$bg;
+ border-color:$border;
+ }
}
@mixin decorations($bg, $border) {
- @include book-decoration($bg, $border);
- @include videofilm-decoration($bg, $border);
- @include serial-decoration($bg, $border);
- @include sound-decoration($bg, $border);
- @include webpage-decoration($bg, $border);
-}
\ No newline at end of file
+ @include book-decoration($bg, $border);
+ @include videofilm-decoration($bg, $border);
+ @include serial-decoration($bg, $border);
+ @include sound-decoration($bg, $border);
+ @include webpage-decoration($bg, $border);
+}
diff --git a/src/scss/_navigation.scss b/src/scss/_navigation.scss
index d478623..f117937 100644
--- a/src/scss/_navigation.scss
+++ b/src/scss/_navigation.scss
@@ -2,51 +2,51 @@
NAVIGATION
***************/
.stack-navigation {
- position:absolute;
- left:5px;
- top:5px;
- width:41px;
- text-align:center;
-
- .upstream, .downstream {
- height:43px;
- text-indent:-999em;
- overflow:hidden;
- }
-
- .upstream {
- background:url('images/nav.png') 0 -87px no-repeat;
-
- &:hover, &:focus {
- background-position:0 -44px;
- }
-
- &:active {
- background-position:0 -1px;
- }
- }
-
- .downstream {
- background:url('images/nav.png') 0 -130px no-repeat;
-
- &:hover, &:focus {
- background-position:0 -173px;
- }
-
- &:active {
- background-position:0 -216px;
- }
- }
-
- .num-found {
- font-size:15px;
- line-height:16px;
- margin:10px 0;
- color:#09f;
- text-shadow: 0 1px 0 #ddd;
- }
-
- &.empty .num-found {
- visibility:hidden;
- }
-}
\ No newline at end of file
+ position:absolute;
+ left:5px;
+ top:5px;
+ width:41px;
+ text-align:center;
+
+ .upstream, .downstream {
+ height:43px;
+ text-indent:-999em;
+ overflow:hidden;
+ }
+
+ .upstream {
+ background:url('images/nav.png') 0 -87px no-repeat;
+
+ &:hover, &:focus {
+ background-position:0 -44px;
+ }
+
+ &:active {
+ background-position:0 -1px;
+ }
+ }
+
+ .downstream {
+ background:url('images/nav.png') 0 -130px no-repeat;
+
+ &:hover, &:focus {
+ background-position:0 -173px;
+ }
+
+ &:active {
+ background-position:0 -216px;
+ }
+ }
+
+ .num-found {
+ font-size:15px;
+ line-height:16px;
+ margin:10px 0;
+ color:#09f;
+ text-shadow: 0 1px 0 #ddd;
+ }
+
+ &.empty .num-found {
+ visibility:hidden;
+ }
+}
diff --git a/src/scss/_serial.scss b/src/scss/_serial.scss
index 7318a07..dd2e7bf 100644
--- a/src/scss/_serial.scss
+++ b/src/scss/_serial.scss
@@ -1,50 +1,50 @@
.stack-serial {
- width:343px;
- height:39px;
- margin:0;
+ width:343px;
+ height:39px;
+ margin:0;
- > a {
- border-radius:3px 0 0 3px;
+ > a {
+ border-radius:3px 0 0 3px;
- &, &:hover, &:focus {
- background-image:url(images/serials.png);
- }
- }
+ &, &:hover, &:focus {
+ background-image:url(images/serials.png);
+ }
+ }
- .spine-text {
- left:15px;
- top:0;
- bottom:0;
- width:200px;
- }
+ .spine-text {
+ left:15px;
+ top:0;
+ bottom:0;
+ width:200px;
+ }
- .spine-title {
- height:39px;
- line-height:39px;
- font-size:12px;
- }
+ .spine-title {
+ height:39px;
+ line-height:39px;
+ font-size:12px;
+ }
}
.serial-edge {
- position:absolute;
- right:-17px;
- bottom:0;
- width:17px;
- height:38px;
- background:url(images/serials-edge.png) 0 0 no-repeat;
- border-width:2px 0;
- @include transform-origin(0 100%);
- @include skew(0deg, -20deg);
+ position:absolute;
+ right:-17px;
+ bottom:0;
+ width:17px;
+ height:38px;
+ background:url(images/serials-edge.png) 0 0 no-repeat;
+ border-width:2px 0;
+ @include transform-origin(0 100%);
+ @include skew(0deg, -20deg);
}
.serial-cover {
- position:absolute;
- top:-5px;
- left:0;
- right:-2px;
- height:3px;
- border-width:1px;
- border-style:solid;
- @include transform-origin(0 100%);
- @include skew(-70deg, 0);
-}
\ No newline at end of file
+ position:absolute;
+ top:-5px;
+ left:0;
+ right:-2px;
+ height:3px;
+ border-width:1px;
+ border-style:solid;
+ @include transform-origin(0 100%);
+ @include skew(-70deg, 0);
+}
diff --git a/src/scss/_soundrecording.scss b/src/scss/_soundrecording.scss
index e7dcbc5..592bc3b 100644
--- a/src/scss/_soundrecording.scss
+++ b/src/scss/_soundrecording.scss
@@ -1,82 +1,82 @@
.stack-soundrecording {
- height:25px;
- width:280px;
- margin:0 0 1px 0;
+ height:25px;
+ width:280px;
+ margin:0 0 1px 0;
- &:before {
- content:url('images/icon-note.png');
- position:absolute;
- left:10px;
- top:4px;
- }
+ &:before {
+ content:url('images/icon-note.png');
+ position:absolute;
+ left:10px;
+ top:4px;
+ }
- > a {
- border-width:1px;
- border-style:solid;
- border-left:3px solid rgba(225, 225, 225, 0.6);
- border-right:3px solid rgba(225, 225, 225, 0.6);
- }
+ > a {
+ border-width:1px;
+ border-style:solid;
+ border-left:3px solid rgba(225, 225, 225, 0.6);
+ border-right:3px solid rgba(225, 225, 225, 0.6);
+ }
- .spine-text {
- left:35px;
- }
+ .spine-text {
+ left:35px;
+ }
- .spine-title {
- height:25px;
- line-height:25px;
- font-size:12px;
- }
+ .spine-title {
+ height:25px;
+ line-height:25px;
+ font-size:12px;
+ }
- .spine-year {
- right:7px;
- }
+ .spine-year {
+ right:7px;
+ }
}
.sound-edge {
- position:absolute;
- top:0;
- bottom:-2px;
- left:100%;
- width:5px;
- border:2px solid rgba(225, 225, 225, 0.6);
- border-radius:0 2px 2px 0;
- @include transform-origin(0 100%);
- @include skew(0, -20deg);
+ position:absolute;
+ top:0;
+ bottom:-2px;
+ left:100%;
+ width:5px;
+ border:2px solid rgba(225, 225, 225, 0.6);
+ border-radius:0 2px 2px 0;
+ @include transform-origin(0 100%);
+ @include skew(0, -20deg);
- &:before {
- position:absolute;
- top:0;
- bottom:0;
- left:1px;
- display: block;
- content:"";
- z-index:5;
- width: 1px;
- background:rgba(250, 250, 250, 0.5);
- }
+ &:before {
+ position:absolute;
+ top:0;
+ bottom:0;
+ left:1px;
+ display: block;
+ content:"";
+ z-index:5;
+ width: 1px;
+ background:rgba(250, 250, 250, 0.5);
+ }
- &:after {
- position:absolute;
- top:0;
- bottom:0;
- left:3px;
- display: block;
- content:"";
- z-index:5;
- width: 1px;
- background:rgba(250, 250, 250, 0.5);
- }
+ &:after {
+ position:absolute;
+ top:0;
+ bottom:0;
+ left:3px;
+ display: block;
+ content:"";
+ z-index:5;
+ width: 1px;
+ background:rgba(250, 250, 250, 0.5);
+ }
}
.sound-cover {
- position:absolute;
- top:-3px;
- left:0;
- right:-1px;
- height:1px;
- border-width:1px;
- border-style:solid;
- border-radius:4px;
- @include transform-origin(0 100%);
- @include skew(-70deg, 0);
-}
\ No newline at end of file
+ position:absolute;
+ top:-3px;
+ left:0;
+ right:-1px;
+ height:1px;
+ border-width:1px;
+ border-style:solid;
+ border-radius:4px;
+ @include transform-origin(0 100%);
+ @include skew(-70deg, 0);
+}
diff --git a/src/scss/_videofilm.scss b/src/scss/_videofilm.scss
index 9c547af..f05cced 100644
--- a/src/scss/_videofilm.scss
+++ b/src/scss/_videofilm.scss
@@ -1,74 +1,74 @@
.stack-videofilm {
- height:28px;
- margin:0 0 1px 0;
+ height:28px;
+ margin:0 0 1px 0;
- > a {
- border-left:4px solid #444;
- border-right:4px solid #444;
- border-top-width:1px;
- border-bottom-width:1px;
- border-style:solid;
- }
+ > a {
+ border-left:4px solid #444;
+ border-right:4px solid #444;
+ border-top-width:1px;
+ border-bottom-width:1px;
+ border-style:solid;
+ }
- .spine-text {
- left:15px;
- top:0;
- bottom:0;
- right:24px;
- font-size:12px;
- font-weight:bold;
- }
+ .spine-text {
+ left:15px;
+ top:0;
+ bottom:0;
+ right:24px;
+ font-size:12px;
+ font-weight:bold;
+ }
- .spine-title {
- height:28px;
- line-height:28px;
- }
+ .spine-title {
+ height:28px;
+ line-height:28px;
+ }
- .spine-year {
- @include rotate(-90deg);
- width:24px;
- height:12px;
- line-height:12px;
- font-size:9px;
- text-align:center;
- margin-top:-6px;
- }
+ .spine-year {
+ @include rotate(-90deg);
+ width:24px;
+ height:12px;
+ line-height:12px;
+ font-size:9px;
+ text-align:center;
+ margin-top:-6px;
+ }
}
.videofilm-edge {
- position:absolute;
- display:block;
- z-index:2;
- left:100%;
- top:0;
- bottom:-2px;
- width:7px;
- background:#444;
- @include transform-origin(0 100%);
- @include skew(0deg, -20deg);
- border-radius:0 2px 2px 0;
+ position:absolute;
+ display:block;
+ z-index:2;
+ left:100%;
+ top:0;
+ bottom:-2px;
+ width:7px;
+ background:#444;
+ @include transform-origin(0 100%);
+ @include skew(0deg, -20deg);
+ border-radius:0 2px 2px 0;
- &:after {
- content:'';
- position:absolute;
- top:50%;
- right:0;
- left:0;
- height:1px;
- background:#000;
- border-top:1px solid #ccc;
- }
+ &:after {
+ content:'';
+ position:absolute;
+ top:50%;
+ right:0;
+ left:0;
+ height:1px;
+ background:#000;
+ border-top:1px solid #ccc;
+ }
}
.videofilm-cover {
- position:absolute;
- top:-4px;
- height:2px;
- left:0;
- right:0;
- border-style:solid;
- border-width:1px;
- border-radius:4px 4px 0 0;
- @include transform-origin(0 100%);
- @include skew(-70deg, 0deg);
-}
\ No newline at end of file
+ position:absolute;
+ top:-4px;
+ height:2px;
+ left:0;
+ right:0;
+ border-style:solid;
+ border-width:1px;
+ border-radius:4px 4px 0 0;
+ @include transform-origin(0 100%);
+ @include skew(-70deg, 0deg);
+}
diff --git a/src/scss/_webpage.scss b/src/scss/_webpage.scss
index 2f3c842..8614c47 100644
--- a/src/scss/_webpage.scss
+++ b/src/scss/_webpage.scss
@@ -1,81 +1,81 @@
.stack-webpage {
- height:38px;
- max-width:75%;
+ height:38px;
+ max-width:75%;
- > a {
- display:inline-block;
- position:relative;
- border-radius:6px 0 1px 0;
- border-width:1px;
- border-style:solid;
- color:#555;
- text-shadow:none;
- font-size:11px;
- padding:0 10px;
- max-width:100%;
+ > a {
+ display:inline-block;
+ position:relative;
+ border-radius:6px 0 1px 0;
+ border-width:1px;
+ border-style:solid;
+ color:#555;
+ text-shadow:none;
+ font-size:11px;
+ padding:0 10px;
+ max-width:100%;
- &:visited, &:hover, &:active {
- color:#555;
- }
- }
+ &:visited, &:hover, &:active {
+ color:#555;
+ }
+ }
}
.url-bar {
- display:block;
- margin:7px 0 0 0;
- height:24px;
- line-height:24px;
- background:#fff;
- padding:0 10px 0 10px;
- border-radius:3px;
- border:1px inset #ccc;
- box-shadow:inset 0 0 5px rgba(0, 0, 0, .2);
- overflow:hidden;
- text-overflow:ellipsis;
+ display:block;
+ margin:7px 0 0 0;
+ height:24px;
+ line-height:24px;
+ background:#fff;
+ padding:0 10px 0 10px;
+ border-radius:3px;
+ border:1px inset #ccc;
+ box-shadow:inset 0 0 5px rgba(0, 0, 0, .2);
+ overflow:hidden;
+ text-overflow:ellipsis;
- &:before {
- content:url('images/icon-globe.png');
- vertical-align:middle;
- position:relative;
- top:1px;
- left:-3px;
- }
+ &:before {
+ content:url('images/icon-globe.png');
+ vertical-align:middle;
+ position:relative;
+ top:1px;
+ left:-3px;
+ }
}
.url-publisher {
- font-variant:small-caps;
+ font-variant:small-caps;
}
.url-title {
- white-space:nowrap;
+ white-space:nowrap;
}
.webpage-top {
- content:'';
- display:block;
- position:absolute;
- top:-5px;
- left:4px;
- right:-5px;
- height:3px;
- border-width:1px;
- border-style:solid;
- @include skew(-70deg, 0);
- border-radius:0 5px 0 5px;
- z-index:2;
+ content:'';
+ display:block;
+ position:absolute;
+ top:-5px;
+ left:4px;
+ right:-5px;
+ height:3px;
+ border-width:1px;
+ border-style:solid;
+ @include skew(-70deg, 0);
+ border-radius:0 5px 0 5px;
+ z-index:2;
}
.webpage-edge {
- content:'';
- display:block;
- position:absolute;
- top:-3px;
- bottom:1px;
- right:-8px;
- width:6px;
- @include skew(0, -20deg);
- border-width:0 1px 1px 0;
- border-style:solid;
+ content:'';
+ display:block;
+ position:absolute;
+ top:-3px;
+ bottom:1px;
+ right:-8px;
+ width:6px;
+ @include skew(0, -20deg);
+ border-width:0 1px 1px 0;
+ border-style:solid;
}
diff --git a/src/scss/jquery.stackview.scss b/src/scss/jquery.stackview.scss
index 4855c21..23e6cf7 100644
--- a/src/scss/jquery.stackview.scss
+++ b/src/scss/jquery.stackview.scss
@@ -1,157 +1,157 @@
/*
- Stack View - The jQuery virtual stack plugin
- by The Harvard Library Innovation Lab
-
- Dual licensed under MIT and GPL.
+ Stack View - The jQuery virtual stack plugin
+ by The Harvard Library Innovation Lab
+
+ Dual licensed under MIT and GPL.
*/
@import "mixins";
.stackview {
- font-family:"Helvetica Neue", sans-serif;
- position:relative;
- height:520px;
- padding:0 0 0 65px;
- overflow:hidden;
-
- * {
- margin:0;
- padding:0;
- }
+ font-family:"Helvetica Neue", sans-serif;
+ position:relative;
+ height:520px;
+ padding:0 0 0 65px;
+ overflow:hidden;
+
+ * {
+ margin:0;
+ padding:0;
+ }
}
.stack-items {
- list-style:none;
- height:100%;
- overflow:auto;
- width:100%;
- padding-right:40px;
- position:relative;
- z-index:2;
- -webkit-overflow-scrolling:touch;
-
- &:before {
- background:url('images/bookEnd-prev.png');
- content:"";
- display:block;
- width:212px;
- height:114px;
- position:relative;
- z-index:9999; // Needs to be bigger than # of books.
- }
-
- &:after {
- content:"";
- display:block;
- width:212px;
- height:114px;
- background:url('images/bookEnd-next.png');
- margin:-7px 0 0 0;
- }
+ list-style:none;
+ height:100%;
+ overflow:auto;
+ width:100%;
+ padding-right:40px;
+ position:relative;
+ z-index:2;
+ -webkit-overflow-scrolling:touch;
+
+ &:before {
+ background:url('images/bookEnd-prev.png');
+ content:"";
+ display:block;
+ width:212px;
+ height:114px;
+ position:relative;
+ z-index:9999; // Needs to be bigger than # of books.
+ }
+
+ &:after {
+ content:"";
+ display:block;
+ width:212px;
+ height:114px;
+ background:url('images/bookEnd-next.png');
+ margin:-7px 0 0 0;
+ }
}
.stackview-placeholder {
- width:250px;
- background:url('images/placeholder.gif') no-repeat center center #ccd;
- border:1px solid #bbb;
- border-radius:3px;
- height:40px;
- position:relative;
- z-index:9997;
+ width:250px;
+ background:url('images/placeholder.gif') no-repeat center center #ccd;
+ border:1px solid #bbb;
+ border-radius:3px;
+ height:40px;
+ position:relative;
+ z-index:9997;
}
.stack-item {
- position:relative;
- display:block;
- -webkit-transform:translate3d(0,0,0);
-
- > a {
- display:block;
- text-decoration:none;
- height:100%;
- color:#fff;
- white-space:nowrap;
- background:url('images/gloss.png') repeat-x 0 47%;
-
- &:hover, &:focus {
- background-image:url('images/highGloss.png');
- text-decoration:none;
- }
-
- &:visited, &:hover, &:active {
- color:#fff;
- }
- }
+ position:relative;
+ display:block;
+ -webkit-transform:translate3d(0,0,0);
+
+ > a {
+ display:block;
+ text-decoration:none;
+ height:100%;
+ color:#fff;
+ white-space:nowrap;
+ background:url('images/gloss.png') repeat-x 0 47%;
+
+ &:hover, &:focus {
+ background-image:url('images/highGloss.png');
+ text-decoration:none;
+ }
+
+ &:visited, &:hover, &:active {
+ color:#fff;
+ }
+ }
}
.spine-text {
- position:absolute;
- z-index:2;
- overflow:hidden;
- display:block;
+ position:absolute;
+ z-index:2;
+ overflow:hidden;
+ display:block;
}
.spine-title {
- float:left;
- font-size:13px;
- line-height:13px;
- vertical-align:middle;
+ float:left;
+ font-size:13px;
+ line-height:13px;
+ vertical-align:middle;
}
.spine-author {
- float:right;
- font-size:10px;
- line-height:13px;
- vertical-align:middle;
- margin-right:6px;
+ float:right;
+ font-size:10px;
+ line-height:13px;
+ vertical-align:middle;
+ margin-right:6px;
}
.spine-year {
- position:absolute;
- z-index:3;
- top:50%;
- right:3px;
- width:28px;
- height:18px;
- line-height:18px;
- background:#f9fceb;
- font-size:9.5px;
- font-family:monospace;
- border-radius:2px;
- text-align:center;
- margin-top:-9px;
- border-width:0 1px;
- border-style:dotted;
- border-color:#e6dec4;
- text-shadow:none;
- color:#555;
+ position:absolute;
+ z-index:3;
+ top:50%;
+ right:3px;
+ width:28px;
+ height:18px;
+ line-height:18px;
+ background:#f9fceb;
+ font-size:9.5px;
+ font-family:monospace;
+ border-radius:2px;
+ text-align:center;
+ margin-top:-9px;
+ border-width:0 1px;
+ border-style:dotted;
+ border-color:#e6dec4;
+ text-shadow:none;
+ color:#555;
}
.stackview .ribbon {
- position:absolute;
- z-index:3;
- left:55px;
- right:10px;
- top:52px;
- padding:8px 10px 8px 12px;
- min-height:25px;
- font-size:20px;
- line-height:1.25;
- background:rgba(252,221,94,.85);
- color:#035;
- border:1px solid #fe4;
- border-radius:2px;
- @include user-select(none);
-
- &:after {
- content:"";
- position:absolute;
- bottom:-10px;
- left:0;
- background:url('images/ribbonTab.png') no-repeat 0 0;
- width:10px;
- height:10px;
- }
+ position:absolute;
+ z-index:3;
+ left:55px;
+ right:10px;
+ top:52px;
+ padding:8px 10px 8px 12px;
+ min-height:25px;
+ font-size:20px;
+ line-height:1.25;
+ background:rgba(252,221,94,.85);
+ color:#035;
+ border:1px solid #fe4;
+ border-radius:2px;
+ @include user-select(none);
+
+ &:after {
+ content:"";
+ position:absolute;
+ bottom:-10px;
+ left:0;
+ background:url('images/ribbonTab.png') no-repeat 0 0;
+ width:10px;
+ height:10px;
+ }
}
@import "heatmap";
@@ -165,3 +165,4 @@
@import "webpage";
@import "ministack";
+@import "horizontalstack";