rails_stackview 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -4
  3. data/lib/rails_stackview/version.rb +1 -1
  4. data/vendor/assets/README.md +16 -0
  5. data/vendor/assets/images/stackview/bookEnd-next.png +0 -0
  6. data/vendor/assets/images/stackview/bookEnd-prev.png +0 -0
  7. data/vendor/assets/images/stackview/gloss.png +0 -0
  8. data/vendor/assets/images/stackview/highGloss.png +0 -0
  9. data/vendor/assets/images/stackview/icon-globe.png +0 -0
  10. data/vendor/assets/images/stackview/icon-note.png +0 -0
  11. data/vendor/assets/images/stackview/nav.png +0 -0
  12. data/vendor/assets/images/stackview/placeholder.gif +0 -0
  13. data/vendor/assets/images/stackview/ribbonTab.png +0 -0
  14. data/vendor/assets/images/stackview/serials-edge.png +0 -0
  15. data/vendor/assets/images/stackview/serials.png +0 -0
  16. data/vendor/assets/images/stackview/superGloss.png +0 -0
  17. data/vendor/assets/javascripts/jquery.stackview.js +21 -0
  18. data/vendor/assets/javascripts/stackview/jquery.easing.1.3.js +205 -0
  19. data/vendor/assets/javascripts/stackview/jquery.stackview.base.js +561 -0
  20. data/vendor/assets/javascripts/stackview/jquery.stackview.infinite.js +46 -0
  21. data/vendor/assets/javascripts/stackview/jquery.stackview.ministack.js +33 -0
  22. data/vendor/assets/javascripts/stackview/jquery.stackview.navigation.js +71 -0
  23. data/vendor/assets/javascripts/stackview/jquery.stackview.stackcache.js +74 -0
  24. data/vendor/assets/javascripts/stackview/jquery.stackview.templates.js +31 -0
  25. data/vendor/assets/javascripts/stackview/microtemplating.js +40 -0
  26. data/vendor/assets/javascripts/stackview/types/book.js +184 -0
  27. data/vendor/assets/javascripts/stackview/types/my_plain.js +183 -0
  28. data/vendor/assets/javascripts/stackview/types/serial.js +40 -0
  29. data/vendor/assets/javascripts/stackview/types/soundrecording.js +42 -0
  30. data/vendor/assets/javascripts/stackview/types/videofilm.js +56 -0
  31. data/vendor/assets/javascripts/stackview/types/webpage.js +42 -0
  32. data/vendor/assets/stackview.sha +1 -0
  33. data/vendor/assets/stylesheets/stackview/_book.scss +66 -0
  34. data/vendor/assets/stylesheets/stackview/_heatmap.scss +154 -0
  35. data/vendor/assets/stylesheets/stackview/_ministack.scss +43 -0
  36. data/vendor/assets/stylesheets/stackview/_mixins.scss +100 -0
  37. data/vendor/assets/stylesheets/stackview/_navigation.scss +52 -0
  38. data/vendor/assets/stylesheets/stackview/_plain.scss +71 -0
  39. data/vendor/assets/stylesheets/stackview/_serial.scss +50 -0
  40. data/vendor/assets/stylesheets/stackview/_soundrecording.scss +83 -0
  41. data/vendor/assets/stylesheets/stackview/_videofilm.scss +74 -0
  42. data/vendor/assets/stylesheets/stackview/_webpage.scss +82 -0
  43. data/vendor/assets/stylesheets/stackview/jquery.stackview.scss +171 -0
  44. metadata +41 -1
@@ -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
@@ -0,0 +1,66 @@
1
+ .stack-book {
2
+ margin:0 0 2px 0;
3
+
4
+ > a {
5
+ border-width:1px 2px;
6
+ border-style:solid;
7
+ border-radius:3px / 20px;
8
+ }
9
+
10
+ .spine-text {
11
+ height:40px;
12
+ line-height:40px;
13
+ top:50%;
14
+ margin-top:-7px;
15
+ left:15px;
16
+ right:24px;
17
+ }
18
+
19
+ .spine-year {
20
+ @include rotate(-90deg);
21
+ }
22
+ }
23
+
24
+ .stack-pages {
25
+ position:absolute;
26
+ z-index:4;
27
+ display:block;
28
+ width:10px;
29
+ right:-6px;
30
+ top:0;
31
+ bottom:-4px;
32
+ border-width:3px 0 3px 2px;
33
+ border-style:solid;
34
+ border-radius:4px 0 0 4px / 20px 0 0 20px;
35
+ @include transform-origin(0 100%);
36
+ @include skew(0deg, -20deg);
37
+
38
+ &:after {
39
+ position:absolute;
40
+ content:"";
41
+ left:0;
42
+ right:2px;
43
+ top:0;
44
+ bottom:0;
45
+ background:#f5f2e8;
46
+ border-radius:3px 0 0 3px / 20px 0 0 20px;
47
+ border-width:3px 1px 2px 0px;
48
+ border-style:solid dotted solid solid;
49
+ border-color:#aaa #e0d7b9 #ccc #ccc;
50
+ }
51
+ }
52
+
53
+ .stack-cover {
54
+ position:absolute;
55
+ z-index:4;
56
+ height:2px;
57
+ border-width:1px;
58
+ border-style:solid;
59
+ border-right-width:2px;
60
+ top:-4px;
61
+ left:0;
62
+ right:5px;
63
+ border-radius:4px 0 0 50px;
64
+ @include transform-origin(0 100%);
65
+ @include skew(-70deg, 0deg);
66
+ }
@@ -0,0 +1,154 @@
1
+ /******************
2
+ HEATMAP
3
+
4
+ hottest = heat10
5
+ coldest = heat1
6
+ *******************/
7
+
8
+ .heat1 {
9
+ $bg: #ccebff;
10
+ $border: #adf;
11
+
12
+ a {
13
+ background-color:$bg;
14
+ background-image:asset-url("stackview/superGloss.png");
15
+ color:#222;
16
+ text-shadow:0 1px 0 #fff;
17
+ border-color:$border;
18
+
19
+ &:visited, &:hover, &:active {
20
+ color:#222;
21
+ }
22
+ }
23
+
24
+ @include decorations($bg, $border);
25
+ }
26
+
27
+ .heat2 {
28
+ $bg: #adf;
29
+ $border: #88cfff;
30
+
31
+ a {
32
+ background-color:$bg;
33
+ background-image:asset-url("stackview/superGloss.png");
34
+ color:#222;
35
+ text-shadow:0 1px 0 #ddf1ff;
36
+ border-color:$border;
37
+
38
+ &:visited, &:hover, &:active {
39
+ color:#222;
40
+ }
41
+ }
42
+
43
+ @include decorations($bg, $border);
44
+ }
45
+
46
+ .heat3 {
47
+ $bg: #77c9ff;
48
+ $border: #59b6ef;
49
+
50
+ a {
51
+ background-color:$bg;
52
+ background-image:asset-url("stackview/highGloss.png");
53
+ color:#111;
54
+ text-shadow:0 1px 0 #adf;
55
+ border-color:$border;
56
+
57
+ &:visited, &:hover, &:active {
58
+ color:#111;
59
+ }
60
+ }
61
+
62
+ @include decorations($bg, $border);
63
+ }
64
+
65
+ .heat4 {
66
+ $bg: #44b4ff;
67
+ $border: #11a0ff;
68
+
69
+ a {
70
+ background-color:$bg;
71
+ text-shadow:0 -1px 0 $border;
72
+ border-color:$border;
73
+ }
74
+
75
+ @include decorations($bg, $border);
76
+ }
77
+
78
+ .heat5 {
79
+ $bg: #22a7ff;
80
+ $border: #008fee;
81
+
82
+ a {
83
+ background-color:$bg;
84
+ text-shadow:0 -1px 0 $border;
85
+ border-color:$border;
86
+ }
87
+
88
+ @include decorations($bg, $border);
89
+ }
90
+
91
+ .heat6 {
92
+ $bg: #0099ff;
93
+ $border: #007acc;
94
+
95
+ a {
96
+ background-color:$bg;
97
+ text-shadow:0 -1px 0 #0085dd;
98
+ border-color:$border;
99
+ }
100
+
101
+ @include decorations($bg, $border);
102
+ }
103
+
104
+ .heat7 {
105
+ $bg: #0085dd;
106
+ $border: #06a;
107
+
108
+ a {
109
+ background-color:$bg;
110
+ text-shadow:0 -1px 0 #0070bb;
111
+ border-color:$border;
112
+ }
113
+
114
+ @include decorations($bg, $border);
115
+ }
116
+
117
+ .heat8 {
118
+ $bg: #0070bb;
119
+ $border: #004777;
120
+
121
+ a {
122
+ background-color:$bg;
123
+ text-shadow:0 -1px 0 #005c99;
124
+ border-color:$border;
125
+ }
126
+
127
+ @include decorations($bg, $border);
128
+ }
129
+
130
+ .heat9 {
131
+ $bg: #005c99;
132
+ $border: #002944;
133
+
134
+ a {
135
+ background-color:$bg;
136
+ text-shadow:0 -1px 0 #004777;
137
+ border-color:$border;
138
+ }
139
+
140
+ @include decorations($bg, $border);
141
+ }
142
+
143
+ .heat10 {
144
+ $bg: #004777;
145
+ $border: #001522;
146
+
147
+ a {
148
+ background-color:$bg;
149
+ text-shadow:0 -1px 0 #035;
150
+ border-color:$border;
151
+ }
152
+
153
+ @include decorations($bg, $border);
154
+ }