stackview_acorn_tester 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +291 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/rails_stackview/auto_init.js +15 -0
- data/app/assets/javascripts/rails_stackview/browser.js +161 -0
- data/app/assets/javascripts/rails_stackview/plain.js +128 -0
- data/app/assets/javascripts/rails_stackview.js +11 -0
- data/app/assets/stylesheets/rails_stackview/_plain.scss +119 -0
- data/app/assets/stylesheets/rails_stackview/browser.scss +116 -0
- data/app/assets/stylesheets/rails_stackview.scss +10 -0
- data/app/controllers/stackview_data_controller.rb +91 -0
- data/app/fetch_adapters/rails_stackview/db_window_fetcher.rb +88 -0
- data/app/fetch_adapters/rails_stackview/mock_fetcher.rb +27 -0
- data/app/models/stackview_call_number.rb +2 -0
- data/app/views/rails_stackview/browser.html.erb +42 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20150602210254_create_stackview_call_numbers.rb +34 -0
- data/lib/rails_stackview/engine.rb +7 -0
- data/lib/rails_stackview/version.rb +3 -0
- data/lib/rails_stackview.rb +20 -0
- data/lib/tasks/rails_stackview_tasks.rake +4 -0
- data/test/controllers/stackview_data_controller_test.rb +55 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +17 -0
- data/test/dummy/app/assets/stylesheets/application.css +20 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/demo_controller.rb +14 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/demo/index.html.erb +14 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +67 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test_fixture.yaml +433 -0
- data/test/fetch_adapters/db_window_fetcher_test.rb +106 -0
- data/test/fixtures/stackview_call_numbers.yml +473 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/rails_stackview_test.rb +7 -0
- data/test/test_helper.rb +42 -0
- data/vendor/assets/README.md +16 -0
- data/vendor/assets/images/stackview/bookEnd-next.png +0 -0
- data/vendor/assets/images/stackview/bookEnd-prev.png +0 -0
- data/vendor/assets/images/stackview/gloss.png +0 -0
- data/vendor/assets/images/stackview/highGloss.png +0 -0
- data/vendor/assets/images/stackview/icon-globe.png +0 -0
- data/vendor/assets/images/stackview/icon-note.png +0 -0
- data/vendor/assets/images/stackview/nav.png +0 -0
- data/vendor/assets/images/stackview/placeholder.gif +0 -0
- data/vendor/assets/images/stackview/ribbonTab.png +0 -0
- data/vendor/assets/images/stackview/serials-edge.png +0 -0
- data/vendor/assets/images/stackview/serials.png +0 -0
- data/vendor/assets/images/stackview/superGloss.png +0 -0
- data/vendor/assets/javascripts/jquery.stackview.js +21 -0
- data/vendor/assets/javascripts/stackview/jquery.easing.1.3.js +205 -0
- data/vendor/assets/javascripts/stackview/jquery.stackview.base.js +561 -0
- data/vendor/assets/javascripts/stackview/jquery.stackview.infinite.js +46 -0
- data/vendor/assets/javascripts/stackview/jquery.stackview.ministack.js +33 -0
- data/vendor/assets/javascripts/stackview/jquery.stackview.navigation.js +71 -0
- data/vendor/assets/javascripts/stackview/jquery.stackview.stackcache.js +74 -0
- data/vendor/assets/javascripts/stackview/jquery.stackview.templates.js +31 -0
- data/vendor/assets/javascripts/stackview/microtemplating.js +40 -0
- data/vendor/assets/javascripts/stackview/types/book.js +184 -0
- data/vendor/assets/javascripts/stackview/types/my_plain.js +183 -0
- data/vendor/assets/javascripts/stackview/types/serial.js +40 -0
- data/vendor/assets/javascripts/stackview/types/soundrecording.js +42 -0
- data/vendor/assets/javascripts/stackview/types/videofilm.js +56 -0
- data/vendor/assets/javascripts/stackview/types/webpage.js +42 -0
- data/vendor/assets/stackview.sha +1 -0
- data/vendor/assets/stylesheets/stackview/_book.scss +66 -0
- data/vendor/assets/stylesheets/stackview/_heatmap.scss +154 -0
- data/vendor/assets/stylesheets/stackview/_ministack.scss +43 -0
- data/vendor/assets/stylesheets/stackview/_mixins.scss +100 -0
- data/vendor/assets/stylesheets/stackview/_navigation.scss +52 -0
- data/vendor/assets/stylesheets/stackview/_plain.scss +71 -0
- data/vendor/assets/stylesheets/stackview/_serial.scss +50 -0
- data/vendor/assets/stylesheets/stackview/_soundrecording.scss +83 -0
- data/vendor/assets/stylesheets/stackview/_videofilm.scss +74 -0
- data/vendor/assets/stylesheets/stackview/_webpage.scss +82 -0
- data/vendor/assets/stylesheets/stackview/jquery.stackview.scss +171 -0
- metadata +233 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
window.stackCache = (function(window, undefined){
|
2
|
+
|
3
|
+
var cache = {},
|
4
|
+
|
5
|
+
// "Borrowed" from Modernizr
|
6
|
+
use_localStorage = window.JSON && (function(){
|
7
|
+
try {
|
8
|
+
return ( 'localStorage' in window ) && window.localStorage !== null;
|
9
|
+
} catch(e) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
})();
|
13
|
+
|
14
|
+
// Expose these methods.
|
15
|
+
return {
|
16
|
+
set: set,
|
17
|
+
get: get,
|
18
|
+
remove: remove
|
19
|
+
};
|
20
|
+
|
21
|
+
// Set a key-value pair with optional TTL.
|
22
|
+
function set( key, value, ttl ) {
|
23
|
+
var expires = ttl && new Date( +new Date() + ttl * 1000 ),
|
24
|
+
obj = {
|
25
|
+
expires: +expires,
|
26
|
+
value: value
|
27
|
+
};
|
28
|
+
|
29
|
+
if ( use_localStorage ) {
|
30
|
+
try {
|
31
|
+
localStorage[ key ] = JSON.stringify( obj );
|
32
|
+
} catch(e) {
|
33
|
+
return e;
|
34
|
+
}
|
35
|
+
} else {
|
36
|
+
cache[ key ] = obj;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
// Get a value if it exists and hasn't expired.
|
41
|
+
function get( key ) {
|
42
|
+
var obj,
|
43
|
+
val;
|
44
|
+
|
45
|
+
if ( use_localStorage ) {
|
46
|
+
obj = localStorage[ key ];
|
47
|
+
if ( obj ) {
|
48
|
+
obj = JSON.parse( obj );
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
obj = cache[ key ];
|
52
|
+
}
|
53
|
+
|
54
|
+
if ( obj ) {
|
55
|
+
if ( obj.expires && obj.expires < +new Date() ) {
|
56
|
+
remove( key );
|
57
|
+
} else {
|
58
|
+
val = obj.value;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
return val;
|
63
|
+
};
|
64
|
+
|
65
|
+
// Remove a key-value pair.
|
66
|
+
function remove( key ) {
|
67
|
+
if ( use_localStorage ) {
|
68
|
+
localStorage.removeItem( key );
|
69
|
+
} else {
|
70
|
+
delete cache[ key ];
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
})(window);
|
@@ -0,0 +1,31 @@
|
|
1
|
+
(function(undefined) {
|
2
|
+
StackView.templates = {
|
3
|
+
scaffold: '\
|
4
|
+
<div class="ribbon"><%= ribbon %></div>\
|
5
|
+
<ul class="stack-items" />',
|
6
|
+
|
7
|
+
navigation: '\
|
8
|
+
<div class="stack-navigation<%= empty ? " empty" : ""%>">\
|
9
|
+
<div class="upstream">Up</div>\
|
10
|
+
<div class="num-found">\
|
11
|
+
<span></span><br />items\
|
12
|
+
</div>\
|
13
|
+
<div class="downstream">Down</div>\
|
14
|
+
</div>',
|
15
|
+
|
16
|
+
book: '\
|
17
|
+
<li class="stack-item stack-book heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;">\
|
18
|
+
<a href="<%= link %>" target="_newtab">\
|
19
|
+
<span class="spine-text">\
|
20
|
+
<span class="spine-title"><%= title %></span>\
|
21
|
+
<span class="spine-author"><%= author %></span>\
|
22
|
+
</span>\
|
23
|
+
<span class="spine-year"><%= year %></span>\
|
24
|
+
<span class="stack-pages" />\
|
25
|
+
<span class="stack-cover" />\
|
26
|
+
</a>\
|
27
|
+
</li>',
|
28
|
+
|
29
|
+
placeholder: '<li class="stackview-placeholder"></li>'
|
30
|
+
}
|
31
|
+
})();
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/*!
|
2
|
+
Simple JavaScript Templating originally by John Resig:
|
3
|
+
http://ejohn.org/blog/javascript-micro-templating/
|
4
|
+
Modified by Rick Strahl:
|
5
|
+
http://west-wind.com/weblog/posts/2008/Oct/13/Client-Templating-with-jQuery
|
6
|
+
MIT Licensed
|
7
|
+
*/
|
8
|
+
(function() {
|
9
|
+
var cache = {};
|
10
|
+
|
11
|
+
this.tmpl = function tmpl(str, data) {
|
12
|
+
// Figure out if we're getting a template, or if we need to
|
13
|
+
// load the template - and be sure to cache the result.
|
14
|
+
var fn = !/\W/.test(str) ?
|
15
|
+
cache[str] = cache[str] || tmpl(document.getElementById(str).innerHTML) :
|
16
|
+
|
17
|
+
// Generate a reusable function that will serve as a template
|
18
|
+
// generator (and which will be cached).
|
19
|
+
new Function("obj",
|
20
|
+
"var p=[],print=function(){p.push.apply(p,arguments);};" +
|
21
|
+
|
22
|
+
// Introduce the data as local variables using with(){}
|
23
|
+
"with(obj){p.push('" +
|
24
|
+
|
25
|
+
// Convert the template into pure JavaScript
|
26
|
+
str
|
27
|
+
.replace(/[\r\t\n]/g, " ")
|
28
|
+
.replace(/'(?=[^%]*%>)/g,"\t")
|
29
|
+
.split("'").join("\\'")
|
30
|
+
.split("\t").join("'")
|
31
|
+
.replace(/^[\r\t\n ]+/, '')
|
32
|
+
.replace(/<%=(.+?)%>/g, "',$1,'")
|
33
|
+
.split("<%").join("');")
|
34
|
+
.split("%>").join("p.push('")
|
35
|
+
+ "');}return p.join('');");
|
36
|
+
|
37
|
+
// Provide some basic currying to the user
|
38
|
+
return data ? fn(data) : fn;
|
39
|
+
};
|
40
|
+
})();
|
@@ -0,0 +1,184 @@
|
|
1
|
+
(function($, window, undefined) {
|
2
|
+
/*
|
3
|
+
Extend StackView defaults to include options for this item type.
|
4
|
+
|
5
|
+
max_height_percentage
|
6
|
+
Books with the maximum height will render as this percentage
|
7
|
+
width in the stack.
|
8
|
+
|
9
|
+
max_height
|
10
|
+
The maximum height in centimeters that an item will render as,
|
11
|
+
regardless of the true height of the item.
|
12
|
+
|
13
|
+
max_pages
|
14
|
+
The maximum number of pages that a book will render as,
|
15
|
+
regardless of the true number of pages.
|
16
|
+
|
17
|
+
min_height_percentage
|
18
|
+
Books with the minimum height will render as this percentage
|
19
|
+
width in the stack.
|
20
|
+
|
21
|
+
min_height
|
22
|
+
The minimum height in centimeters that an item will render as,
|
23
|
+
regardless of the true height of the item.
|
24
|
+
|
25
|
+
min_pages
|
26
|
+
The minimum number of pages that a book will render as,
|
27
|
+
regardless of the true number of pages.
|
28
|
+
|
29
|
+
page_multiple
|
30
|
+
A number that when multiplied by the number of pages in a book
|
31
|
+
gives us the total pixel height to be rendered.
|
32
|
+
|
33
|
+
selectors.book
|
34
|
+
Item selector specific to the book type.
|
35
|
+
*/
|
36
|
+
$.extend(true, window.StackView.defaults, {
|
37
|
+
book: {
|
38
|
+
max_height_percentage: 100,
|
39
|
+
max_height: 39,
|
40
|
+
max_pages: 540,
|
41
|
+
min_height_percentage: 59,
|
42
|
+
min_height: 20,
|
43
|
+
min_pages: 200,
|
44
|
+
page_multiple: 0.20
|
45
|
+
},
|
46
|
+
|
47
|
+
selectors: {
|
48
|
+
book: '.stack-book'
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
/*
|
53
|
+
#translate(number, number, number, number, number) - Private
|
54
|
+
|
55
|
+
Takes a value (the first argument) and two ranges of numbers. Translates
|
56
|
+
this value from the first range to the second range. E.g.:
|
57
|
+
|
58
|
+
translate(0, 0, 10, 50, 100) returns 50.
|
59
|
+
translate(10, 0, 10, 50, 100) returns 100.
|
60
|
+
translate(5, 0, 10, 50, 100) returns 75.
|
61
|
+
|
62
|
+
http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another
|
63
|
+
*/
|
64
|
+
var translate = function(value, start_min, start_max, end_min, end_max) {
|
65
|
+
var start_range = start_max - start_min,
|
66
|
+
end_range = end_max - end_min,
|
67
|
+
scale = (value - start_min) / (start_range);
|
68
|
+
|
69
|
+
return end_min + scale * end_range;
|
70
|
+
};
|
71
|
+
|
72
|
+
/*
|
73
|
+
#get_height(StackView, object) - Private
|
74
|
+
|
75
|
+
Takes a StackView options object and a book object. Returns a
|
76
|
+
normalized book height percentage, taking into account the minimum
|
77
|
+
height, maximum height, height multiple, and translating them onto
|
78
|
+
the percentage range specified in the stack options.
|
79
|
+
*/
|
80
|
+
var get_height = function(options, book) {
|
81
|
+
var height = parseInt(book.measurement_height_numeric, 10),
|
82
|
+
min = options.book.min_height,
|
83
|
+
max = options.book.max_height;
|
84
|
+
|
85
|
+
if (isNaN(height)) {
|
86
|
+
height = min;
|
87
|
+
}
|
88
|
+
height = Math.min(Math.max(height, min), max);
|
89
|
+
height = translate(
|
90
|
+
height,
|
91
|
+
options.book.min_height,
|
92
|
+
options.book.max_height,
|
93
|
+
options.book.min_height_percentage,
|
94
|
+
options.book.max_height_percentage
|
95
|
+
);
|
96
|
+
return height + '%';
|
97
|
+
};
|
98
|
+
|
99
|
+
/*
|
100
|
+
#get_thickness(StackView, object) - Private
|
101
|
+
|
102
|
+
Takes a StackView instance and a book object. Returns a normalized
|
103
|
+
book thickness using the number of book pages, taking into account
|
104
|
+
the minimum pages, maximum pages, and pages multiple.
|
105
|
+
*/
|
106
|
+
var get_thickness = function(options, book) {
|
107
|
+
var thickness = parseInt(book.measurement_page_numeric, 10),
|
108
|
+
min = options.book.min_pages,
|
109
|
+
max = options.book.max_pages,
|
110
|
+
multiple = options.book.page_multiple;
|
111
|
+
|
112
|
+
if (isNaN(thickness)) {
|
113
|
+
thickness = min;
|
114
|
+
}
|
115
|
+
thickness = Math.min(Math.max(thickness, min), max) * multiple;
|
116
|
+
return thickness + 'px';
|
117
|
+
};
|
118
|
+
|
119
|
+
/*
|
120
|
+
#normalize_link(object) - Private
|
121
|
+
|
122
|
+
Takes an item and returns the item's link, taking into account
|
123
|
+
workarounds that may come from inconsistent data structure.
|
124
|
+
*/
|
125
|
+
var normalize_link = function(item) {
|
126
|
+
//workaround for link construction from LibraryCloud
|
127
|
+
return item.title_link_friendly ?
|
128
|
+
'../shelflife/book/' + item.title_link_friendly + '/' + item.id :
|
129
|
+
item.link;
|
130
|
+
};
|
131
|
+
|
132
|
+
/*
|
133
|
+
#get_author(object) - Private
|
134
|
+
|
135
|
+
Takes an item and returns the item's author, taking the first
|
136
|
+
author if an array of authors is defined.
|
137
|
+
*/
|
138
|
+
var get_author = function(item) {
|
139
|
+
var author = item.creator && item.creator.length ? item.creator[0] : '';
|
140
|
+
|
141
|
+
if(/^([^,]*)/.test(author)) {
|
142
|
+
author = author.match(/^[^,]*/);
|
143
|
+
}
|
144
|
+
|
145
|
+
return author;
|
146
|
+
};
|
147
|
+
|
148
|
+
|
149
|
+
/*
|
150
|
+
Book type definition.
|
151
|
+
*/
|
152
|
+
window.StackView.register_type({
|
153
|
+
name: 'book',
|
154
|
+
|
155
|
+
match: function(item) {
|
156
|
+
return (item.format && item.format === 'book') || !item.format;
|
157
|
+
},
|
158
|
+
|
159
|
+
adapter: function(item, options) {
|
160
|
+
return {
|
161
|
+
heat: window.StackView.utils.get_heat(item.shelfrank),
|
162
|
+
book_height: get_height(options, item),
|
163
|
+
book_thickness: get_thickness(options, item),
|
164
|
+
link: normalize_link(item),
|
165
|
+
title: item.title,
|
166
|
+
author: get_author(item),
|
167
|
+
year: item.pub_date
|
168
|
+
};
|
169
|
+
},
|
170
|
+
|
171
|
+
template: '\
|
172
|
+
<li class="stack-item stack-book heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;">\
|
173
|
+
<a href="<%= link %>" target="_blank">\
|
174
|
+
<span class="spine-text">\
|
175
|
+
<span class="spine-title"><%= title %></span>\
|
176
|
+
<span class="spine-author"><%= author %></span>\
|
177
|
+
</span>\
|
178
|
+
<span class="spine-year"><%= year %></span>\
|
179
|
+
<span class="stack-pages" />\
|
180
|
+
<span class="stack-cover" />\
|
181
|
+
</a>\
|
182
|
+
</li>'
|
183
|
+
});
|
184
|
+
})(jQuery, window);
|
@@ -0,0 +1,183 @@
|
|
1
|
+
(function($, window, undefined) {
|
2
|
+
/*
|
3
|
+
Extend StackView defaults to include options for this item type.
|
4
|
+
|
5
|
+
max_height_percentage
|
6
|
+
Books with the maximum height will render as this percentage
|
7
|
+
width in the stack.
|
8
|
+
|
9
|
+
max_height
|
10
|
+
The maximum height in centimeters that an item will render as,
|
11
|
+
regardless of the true height of the item.
|
12
|
+
|
13
|
+
max_pages
|
14
|
+
The maximum number of pages that a book will render as,
|
15
|
+
regardless of the true number of pages.
|
16
|
+
|
17
|
+
min_height_percentage
|
18
|
+
Books with the minimum height will render as this percentage
|
19
|
+
width in the stack.
|
20
|
+
|
21
|
+
min_height
|
22
|
+
The minimum height in centimeters that an item will render as,
|
23
|
+
regardless of the true height of the item.
|
24
|
+
|
25
|
+
min_pages
|
26
|
+
The minimum number of pages that a book will render as,
|
27
|
+
regardless of the true number of pages.
|
28
|
+
|
29
|
+
page_multiple
|
30
|
+
A number that when multiplied by the number of pages in a book
|
31
|
+
gives us the total pixel height to be rendered.
|
32
|
+
|
33
|
+
selectors.book
|
34
|
+
Item selector specific to the book type.
|
35
|
+
*/
|
36
|
+
$.extend(true, window.StackView.defaults, {
|
37
|
+
plain: {
|
38
|
+
max_height_percentage: 100,
|
39
|
+
max_height: 39,
|
40
|
+
max_pages: 540,
|
41
|
+
min_height_percentage: 59,
|
42
|
+
min_height: 20,
|
43
|
+
min_pages: 200,
|
44
|
+
page_multiple: 0.20
|
45
|
+
},
|
46
|
+
|
47
|
+
selectors: {
|
48
|
+
plain: '.stack-plain'
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
/*
|
53
|
+
#translate(number, number, number, number, number) - Private
|
54
|
+
|
55
|
+
Takes a value (the first argument) and two ranges of numbers. Translates
|
56
|
+
this value from the first range to the second range. E.g.:
|
57
|
+
|
58
|
+
translate(0, 0, 10, 50, 100) returns 50.
|
59
|
+
translate(10, 0, 10, 50, 100) returns 100.
|
60
|
+
translate(5, 0, 10, 50, 100) returns 75.
|
61
|
+
|
62
|
+
http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another
|
63
|
+
*/
|
64
|
+
var translate = function(value, start_min, start_max, end_min, end_max) {
|
65
|
+
var start_range = start_max - start_min,
|
66
|
+
end_range = end_max - end_min,
|
67
|
+
scale = (value - start_min) / (start_range);
|
68
|
+
|
69
|
+
return end_min + scale * end_range;
|
70
|
+
};
|
71
|
+
|
72
|
+
/*
|
73
|
+
#get_height(StackView, object) - Private
|
74
|
+
|
75
|
+
Takes a StackView options object and a book object. Returns a
|
76
|
+
normalized book height percentage, taking into account the minimum
|
77
|
+
height, maximum height, height multiple, and translating them onto
|
78
|
+
the percentage range specified in the stack options.
|
79
|
+
*/
|
80
|
+
var get_height = function(options, book) {
|
81
|
+
var height = parseInt(book.measurement_height_numeric, 10),
|
82
|
+
min = options.book.min_height,
|
83
|
+
max = options.book.max_height;
|
84
|
+
|
85
|
+
if (isNaN(height)) {
|
86
|
+
height = min;
|
87
|
+
}
|
88
|
+
height = Math.min(Math.max(height, min), max);
|
89
|
+
height = translate(
|
90
|
+
height,
|
91
|
+
options.book.min_height,
|
92
|
+
options.book.max_height,
|
93
|
+
options.book.min_height_percentage,
|
94
|
+
options.book.max_height_percentage
|
95
|
+
);
|
96
|
+
return height + '%';
|
97
|
+
};
|
98
|
+
|
99
|
+
/*
|
100
|
+
#get_thickness(StackView, object) - Private
|
101
|
+
|
102
|
+
Takes a StackView instance and a book object. Returns a normalized
|
103
|
+
book thickness using the number of book pages, taking into account
|
104
|
+
the minimum pages, maximum pages, and pages multiple.
|
105
|
+
*/
|
106
|
+
var get_thickness = function(options, book) {
|
107
|
+
var thickness = parseInt(book.measurement_page_numeric, 10),
|
108
|
+
min = options.book.min_pages,
|
109
|
+
max = options.book.max_pages,
|
110
|
+
multiple = options.book.page_multiple;
|
111
|
+
|
112
|
+
if (isNaN(thickness)) {
|
113
|
+
thickness = min;
|
114
|
+
}
|
115
|
+
thickness = Math.min(Math.max(thickness, min), max) * multiple;
|
116
|
+
return thickness + 'px';
|
117
|
+
};
|
118
|
+
|
119
|
+
/*
|
120
|
+
#normalize_link(object) - Private
|
121
|
+
|
122
|
+
Takes an item and returns the item's link, taking into account
|
123
|
+
workarounds that may come from inconsistent data structure.
|
124
|
+
*/
|
125
|
+
var normalize_link = function(item) {
|
126
|
+
//workaround for link construction from LibraryCloud
|
127
|
+
return item.title_link_friendly ?
|
128
|
+
'../shelflife/book/' + item.title_link_friendly + '/' + item.id :
|
129
|
+
item.link;
|
130
|
+
};
|
131
|
+
|
132
|
+
/*
|
133
|
+
#get_author(object) - Private
|
134
|
+
|
135
|
+
Takes an item and returns the item's author, taking the first
|
136
|
+
author if an array of authors is defined.
|
137
|
+
*/
|
138
|
+
var get_author = function(item) {
|
139
|
+
var author = item.creator && item.creator.length ? item.creator[0] : '';
|
140
|
+
|
141
|
+
if(/^([^,]*)/.test(author)) {
|
142
|
+
author = author.match(/^[^,]*/);
|
143
|
+
}
|
144
|
+
|
145
|
+
return author;
|
146
|
+
};
|
147
|
+
|
148
|
+
|
149
|
+
/*
|
150
|
+
Book type definition.
|
151
|
+
*/
|
152
|
+
window.StackView.register_type({
|
153
|
+
name: 'plain',
|
154
|
+
|
155
|
+
match: function(item) {
|
156
|
+
return (item.format && item.format === 'plain');
|
157
|
+
},
|
158
|
+
|
159
|
+
adapter: function(item, options) {
|
160
|
+
return {
|
161
|
+
heat: window.StackView.utils.get_heat(item.shelfrank),
|
162
|
+
book_height: get_height(options, item),
|
163
|
+
book_thickness: get_thickness(options, item),
|
164
|
+
link: normalize_link(item),
|
165
|
+
title: item.title,
|
166
|
+
author: get_author(item),
|
167
|
+
year: item.pub_date
|
168
|
+
};
|
169
|
+
},
|
170
|
+
|
171
|
+
template: '\
|
172
|
+
<li class="stack-item stack-plain heat<%= heat %>" style="width:<%= book_height %>; height:<%= book_thickness %>;">\
|
173
|
+
<a href="<%= link %>" target="_blank">\
|
174
|
+
<span class="spine-text">\
|
175
|
+
<span class="spine-title"><%= title %></span>\
|
176
|
+
<span class="spine-author"><%= author %></span>\
|
177
|
+
</span>\
|
178
|
+
<span class="spine-year"><%= year %></span>\
|
179
|
+
<span class="plain-top item-colors" />\
|
180
|
+
<span class="plain-edge item-colors" />\
|
181
|
+
</a>\
|
182
|
+
</li>' });
|
183
|
+
})(jQuery, window);
|
@@ -0,0 +1,40 @@
|
|
1
|
+
(function($, window, undefined) {
|
2
|
+
/*
|
3
|
+
Extend StackView defaults to include options for this item type.
|
4
|
+
|
5
|
+
selectors.serial
|
6
|
+
Item selector specific to the serial type.
|
7
|
+
*/
|
8
|
+
$.extend(true, window.StackView.defaults, {
|
9
|
+
selectors: {
|
10
|
+
serial: '.stack-serial'
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
window.StackView.register_type({
|
15
|
+
name: 'serial',
|
16
|
+
|
17
|
+
match: function(item) {
|
18
|
+
return item.format === 'Serial';
|
19
|
+
},
|
20
|
+
|
21
|
+
adapter: function(item, options) {
|
22
|
+
return {
|
23
|
+
heat: window.StackView.utils.get_heat(item.shelfrank),
|
24
|
+
title: item.title,
|
25
|
+
link: item.link
|
26
|
+
};
|
27
|
+
},
|
28
|
+
|
29
|
+
template: '\
|
30
|
+
<li class="stack-item stack-serial heat<%= heat %>">\
|
31
|
+
<a href="<%= link %>" target="_blank">\
|
32
|
+
<span class="spine-text">\
|
33
|
+
<span class="spine-title"><%= title %></span>\
|
34
|
+
</span>\
|
35
|
+
<span class="serial-edge" />\
|
36
|
+
<span class="serial-cover" />\
|
37
|
+
</a>\
|
38
|
+
</li>'
|
39
|
+
});
|
40
|
+
})(jQuery, window);
|
@@ -0,0 +1,42 @@
|
|
1
|
+
(function($, window, undefined) {
|
2
|
+
/*
|
3
|
+
Extend StackView defaults to include options for this item type.
|
4
|
+
|
5
|
+
selectors.soundrecording
|
6
|
+
Item selector specific to the soundrecording type.
|
7
|
+
*/
|
8
|
+
$.extend(true, window.StackView.defaults, {
|
9
|
+
selectors: {
|
10
|
+
soundrecording: '.stack-soundrecording'
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
window.StackView.register_type({
|
15
|
+
name: 'soundrecording',
|
16
|
+
|
17
|
+
match: function(item) {
|
18
|
+
return item.format === 'Sound Recording';
|
19
|
+
},
|
20
|
+
|
21
|
+
adapter: function(item, options) {
|
22
|
+
return {
|
23
|
+
heat: window.StackView.utils.get_heat(item.shelfrank),
|
24
|
+
link: item.link || '#',
|
25
|
+
title: item.title,
|
26
|
+
year: item.pub_date
|
27
|
+
};
|
28
|
+
},
|
29
|
+
|
30
|
+
template: '\
|
31
|
+
<li class="stack-item stack-soundrecording heat<%= heat %>">\
|
32
|
+
<a href="<%= link %>" target="_blank">\
|
33
|
+
<span class="spine-text">\
|
34
|
+
<span class="spine-title"><%= title %></span>\
|
35
|
+
</span>\
|
36
|
+
<span class="spine-year"><%= year %></span>\
|
37
|
+
<span class="sound-edge"></span>\
|
38
|
+
<span class="sound-cover"></span>\
|
39
|
+
</a>\
|
40
|
+
</li>'
|
41
|
+
});
|
42
|
+
})(jQuery, window);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
(function($, window, undefined) {
|
2
|
+
/*
|
3
|
+
Extend StackView defaults to include options for this item type.
|
4
|
+
|
5
|
+
selectors.videofilm
|
6
|
+
Item selector specific to the videofilm type.
|
7
|
+
*/
|
8
|
+
$.extend(true, window.StackView.defaults, {
|
9
|
+
selectors: {
|
10
|
+
videofilm: '.stack-videofilm'
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
/*
|
15
|
+
#normalize_link(object) - Private
|
16
|
+
|
17
|
+
Takes an item and returns the item's link, taking into account
|
18
|
+
workarounds that may come from inconsistent data structure.
|
19
|
+
*/
|
20
|
+
var normalize_link = function(item) {
|
21
|
+
// TODO: How should this be normalized? Can we just drop normalization
|
22
|
+
// in favor of other systems modifying or redefining types?
|
23
|
+
return item.link || item.title || '#'
|
24
|
+
};
|
25
|
+
|
26
|
+
window.StackView.register_type({
|
27
|
+
name: 'videofilm',
|
28
|
+
|
29
|
+
match: function(item) {
|
30
|
+
return item.format === 'Video\/Film';
|
31
|
+
},
|
32
|
+
|
33
|
+
adapter: function(item, options) {
|
34
|
+
return {
|
35
|
+
heat: window.StackView.utils.get_heat(item.shelfrank),
|
36
|
+
/* TODO: How should video widths be calculated? */
|
37
|
+
height: '65%',
|
38
|
+
title: item.title,
|
39
|
+
year: item.pub_date,
|
40
|
+
link: normalize_link(item)
|
41
|
+
};
|
42
|
+
},
|
43
|
+
|
44
|
+
template: '\
|
45
|
+
<li class="stack-item stack-videofilm heat<%= heat %>" style="width:<%= height %>;">\
|
46
|
+
<a href="<%= link %>" target="_blank">\
|
47
|
+
<span class="spine-text">\
|
48
|
+
<span class="spine-title"><%= title %></span>\
|
49
|
+
</span>\
|
50
|
+
<span class="spine-year"><%= year %></span>\
|
51
|
+
<span class="videofilm-edge" />\
|
52
|
+
<span class="videofilm-cover" />\
|
53
|
+
</a>\
|
54
|
+
</li>'
|
55
|
+
});
|
56
|
+
})(jQuery, window);
|
@@ -0,0 +1,42 @@
|
|
1
|
+
(function($, window, undefined) {
|
2
|
+
/*
|
3
|
+
Extend StackView defaults to include options for this item type.
|
4
|
+
|
5
|
+
selectors.webpage
|
6
|
+
Item selector specific to the webpage type.
|
7
|
+
*/
|
8
|
+
$.extend(true, window.StackView.defaults, {
|
9
|
+
selectors: {
|
10
|
+
webpage: '.stack-webpage'
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
window.StackView.register_type({
|
15
|
+
name: 'webpage',
|
16
|
+
|
17
|
+
match: function(item) {
|
18
|
+
return item.format === 'webpage';
|
19
|
+
},
|
20
|
+
|
21
|
+
adapter: function(item, options) {
|
22
|
+
return {
|
23
|
+
heat: window.StackView.utils.get_heat(item.shelfrank),
|
24
|
+
link: item.rsrc_value || item.link,
|
25
|
+
publisher: item.publisher,
|
26
|
+
title: item.title
|
27
|
+
};
|
28
|
+
},
|
29
|
+
|
30
|
+
template: '\
|
31
|
+
<li class="stack-item stack-webpage heat<%= heat %>">\
|
32
|
+
<a href="<%= link %>" target="_blank">\
|
33
|
+
<span class="url-bar">\
|
34
|
+
<span class="url-publisher"><%= publisher %>:</span>\
|
35
|
+
<span class="url-title"><%= title %></span>\
|
36
|
+
</span>\
|
37
|
+
<span class="webpage-top"></span>\
|
38
|
+
<span class="webpage-edge"></span>\
|
39
|
+
</a>\
|
40
|
+
</li>'
|
41
|
+
});
|
42
|
+
})(jQuery, window);
|
@@ -0,0 +1 @@
|
|
1
|
+
5c6d6ea6ca51e7b335f1f8018017292e2c02203c
|