atrium 0.0.1.alpha

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.
Files changed (212) hide show
  1. data/.gitignore +13 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +32 -0
  4. data/GETTING_STARTED.textile +109 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +320 -0
  7. data/Guardfile +10 -0
  8. data/README.mkd +56 -0
  9. data/Rakefile +6 -0
  10. data/app/assets/images/atrium/ajax-loader.gif +0 -0
  11. data/app/assets/images/atrium/lightbox-ico-loading.gif +0 -0
  12. data/app/assets/images/atrium/logo.png +0 -0
  13. data/app/assets/javascripts/atrium/atrium.js +281 -0
  14. data/app/assets/javascripts/chosen.jquery.js +899 -0
  15. data/app/assets/javascripts/ckeditor.warning.js +65 -0
  16. data/app/assets/javascripts/ckeditor/config.js.coffee +6 -0
  17. data/app/assets/javascripts/ckeditor/jquery.generateId.js +13 -0
  18. data/app/assets/javascripts/ckeditor/jquery.jeditable.ckeditor.js +59 -0
  19. data/app/assets/javascripts/ckeditor/plugins/linkItem/application_link.png +0 -0
  20. data/app/assets/javascripts/ckeditor/plugins/linkItem/dialogs/linkItem.js +1470 -0
  21. data/app/assets/javascripts/ckeditor/plugins/linkItem/plugin.js +16 -0
  22. data/app/assets/javascripts/ckeditor/plugins/linkItem/ui_toolbar_pencil.png +0 -0
  23. data/app/assets/javascripts/jquery.colorbox.js +864 -0
  24. data/app/assets/javascripts/jquery.jeditable.js +543 -0
  25. data/app/assets/stylesheets/atrium/atrium.css +216 -0
  26. data/app/assets/stylesheets/atrium/chosen-sprite.png +0 -0
  27. data/app/assets/stylesheets/atrium/chosen.css +367 -0
  28. data/app/assets/stylesheets/colorbox.css +42 -0
  29. data/app/assets/stylesheets/controls.png +0 -0
  30. data/app/assets/stylesheets/loading.gif +0 -0
  31. data/app/controllers/atrium/base_controller.rb +25 -0
  32. data/app/controllers/atrium/collection_exhibit_order_controller.rb +21 -0
  33. data/app/controllers/atrium/collections_controller.rb +165 -0
  34. data/app/controllers/atrium/customization_controller.rb +41 -0
  35. data/app/controllers/atrium/descriptions_controller.rb +177 -0
  36. data/app/controllers/atrium/exhibit_facet_order_controller.rb +19 -0
  37. data/app/controllers/atrium/exhibits_controller.rb +108 -0
  38. data/app/controllers/atrium/showcases_controller.rb +193 -0
  39. data/app/helpers/atrium/base_helper.rb +6 -0
  40. data/app/models/ability.rb +14 -0
  41. data/app/models/atrium/browse_level.rb +41 -0
  42. data/app/models/atrium/collection.rb +121 -0
  43. data/app/models/atrium/description.rb +128 -0
  44. data/app/models/atrium/essay.rb +21 -0
  45. data/app/models/atrium/exhibit.rb +58 -0
  46. data/app/models/atrium/search/facet.rb +29 -0
  47. data/app/models/atrium/search/facet_selection.rb +17 -0
  48. data/app/models/atrium/showcase.rb +173 -0
  49. data/app/models/atrium/showcase/facet_selection.rb +21 -0
  50. data/app/models/atrium/showcase/item.rb +19 -0
  51. data/app/models/role_mapper.rb +23 -0
  52. data/app/views/_user_util_links.html.erb +25 -0
  53. data/app/views/atrium/collections/_bookmark_control.html.erb +25 -0
  54. data/app/views/atrium/collections/_browse_index.html.erb +20 -0
  55. data/app/views/atrium/collections/_collection_items_index.html.erb +10 -0
  56. data/app/views/atrium/collections/_document.html.erb +24 -0
  57. data/app/views/atrium/collections/_document_list.html.erb +6 -0
  58. data/app/views/atrium/collections/_edit_navigation.html.erb +20 -0
  59. data/app/views/atrium/collections/_folder_control.html.erb +12 -0
  60. data/app/views/atrium/collections/_form.html.erb +93 -0
  61. data/app/views/atrium/collections/_listing.html.erb +18 -0
  62. data/app/views/atrium/collections/_navigation.html.erb +45 -0
  63. data/app/views/atrium/collections/_results_pagination.html.erb +9 -0
  64. data/app/views/atrium/collections/_sort_and_per_page.html.erb +23 -0
  65. data/app/views/atrium/collections/edit.html.erb +5 -0
  66. data/app/views/atrium/collections/new.html.erb +6 -0
  67. data/app/views/atrium/collections/show.html.erb +22 -0
  68. data/app/views/atrium/descriptions/_form.html.erb +64 -0
  69. data/app/views/atrium/descriptions/edit.html.erb +4 -0
  70. data/app/views/atrium/descriptions/index.html.erb +4 -0
  71. data/app/views/atrium/descriptions/new.html.erb +2 -0
  72. data/app/views/atrium/descriptions/show.html.erb +20 -0
  73. data/app/views/atrium/exhibits/_bookmark_control.html.erb +25 -0
  74. data/app/views/atrium/exhibits/_folder_control.html.erb +12 -0
  75. data/app/views/atrium/exhibits/_form.html.erb +108 -0
  76. data/app/views/atrium/exhibits/edit.html.erb +9 -0
  77. data/app/views/atrium/exhibits/new.html.erb +6 -0
  78. data/app/views/atrium/exhibits/show.html.erb +26 -0
  79. data/app/views/atrium/showcases/_showcase_navigation.html.erb +23 -0
  80. data/app/views/atrium/showcases/show.html.erb +1 -0
  81. data/app/views/catalog/_collection_home_text.html.erb +6 -0
  82. data/app/views/catalog/_constraints.html.erb +9 -0
  83. data/app/views/catalog/_default_collection_text.html.erb +18 -0
  84. data/app/views/catalog/_default_home_text.html.erb +6 -0
  85. data/app/views/catalog/_home_text.html.erb +6 -0
  86. data/app/views/catalog/_index_partials/_description.html.erb +8 -0
  87. data/app/views/catalog/_search_form.html.erb +66 -0
  88. data/app/views/catalog/_show_partials/_description.html.erb +15 -0
  89. data/app/views/catalog/browse_show.html.erb +18 -0
  90. data/app/views/catalog/index.html.erb +35 -0
  91. data/app/views/catalog/list_description.html.erb +24 -0
  92. data/app/views/catalog/list_item.html.erb +3 -0
  93. data/app/views/layouts/atrium.html.erb +86 -0
  94. data/app/views/layouts/atrium_themes/default.html.erb +4 -0
  95. data/app/views/layouts/item_listing.html.erb +36 -0
  96. data/app/views/listing/_document.html.erb +27 -0
  97. data/app/views/listing/_document_list.html.erb +3 -0
  98. data/app/views/listing/_item_search.html.erb +27 -0
  99. data/app/views/shared/_banner.html.erb +5 -0
  100. data/app/views/shared/_collection_complete_list.html.erb +33 -0
  101. data/app/views/shared/_collection_search_form.html.erb +12 -0
  102. data/app/views/shared/_collection_title_header.html.erb +3 -0
  103. data/app/views/shared/_featured_sources.html.erb +20 -0
  104. data/app/views/shared/_list_descriptions.html.erb +38 -0
  105. data/app/views/shared/_navigation_browse_levels.html.erb +34 -0
  106. data/app/views/shared/_showcase_configure_menu.html.erb +22 -0
  107. data/app/views/shared/_top_navigation.html.erb +9 -0
  108. data/atrium.gemspec +76 -0
  109. data/config/routes.rb +12 -0
  110. data/init.rb +3 -0
  111. data/lib/application_controller.rb +24 -0
  112. data/lib/atrium.rb +42 -0
  113. data/lib/atrium/application_helper.rb +24 -0
  114. data/lib/atrium/atrium_helper_behavior.rb +162 -0
  115. data/lib/atrium/catalog.rb +203 -0
  116. data/lib/atrium/collections_helper.rb +139 -0
  117. data/lib/atrium/controller.rb +10 -0
  118. data/lib/atrium/descriptions_helper.rb +23 -0
  119. data/lib/atrium/engine.rb +12 -0
  120. data/lib/atrium/layout_helper.rb +13 -0
  121. data/lib/atrium/routes.rb +99 -0
  122. data/lib/atrium/solr_helper.rb +440 -0
  123. data/lib/atrium/version.rb +3 -0
  124. data/lib/generators/atrium/assets_generator.rb +44 -0
  125. data/lib/generators/atrium/atrium_generator.rb +149 -0
  126. data/lib/generators/atrium/cucumber_support_generator.rb +29 -0
  127. data/lib/generators/atrium/templates/config/role_map_cucumber.yml +2 -0
  128. data/lib/generators/atrium/templates/config/role_map_development.yml +2 -0
  129. data/lib/generators/atrium/templates/config/role_map_production.yml +2 -0
  130. data/lib/generators/atrium/templates/config/role_map_test.yml +2 -0
  131. data/lib/generators/atrium/templates/config/solr.yml +10 -0
  132. data/lib/generators/atrium/templates/db/seeds.rb +87 -0
  133. data/lib/generators/atrium/templates/migrations/create_atrium_browse_levels.rb +18 -0
  134. data/lib/generators/atrium/templates/migrations/create_atrium_collections.rb +20 -0
  135. data/lib/generators/atrium/templates/migrations/create_atrium_descriptions.rb +16 -0
  136. data/lib/generators/atrium/templates/migrations/create_atrium_essays.rb +15 -0
  137. data/lib/generators/atrium/templates/migrations/create_atrium_exhibits.rb +16 -0
  138. data/lib/generators/atrium/templates/migrations/create_atrium_search_facets.rb +14 -0
  139. data/lib/generators/atrium/templates/migrations/create_atrium_showcase_facet_selections.rb +15 -0
  140. data/lib/generators/atrium/templates/migrations/create_atrium_showcase_items.rb +17 -0
  141. data/lib/generators/atrium/templates/migrations/create_atrium_showcases.rb +16 -0
  142. data/lib/generators/atrium/templates/themes/example.html.erb +21 -0
  143. data/lib/railties/all_tests.rake +23 -0
  144. data/lib/railties/atrium_cucumber.rake +121 -0
  145. data/lib/railties/index.rake +37 -0
  146. data/tasks/atrium.rake +268 -0
  147. data/tasks/atrium_rspec.rake +91 -0
  148. data/test_support/etc/Gemfile +33 -0
  149. data/test_support/etc/bundle_config +3 -0
  150. data/test_support/etc/rvmrc +32 -0
  151. data/test_support/features/atrium_collections.feature +162 -0
  152. data/test_support/features/atrium_exhibits.feature +164 -0
  153. data/test_support/features/step_definitions/atrium_collection_steps.rb +102 -0
  154. data/test_support/features/step_definitions/atrium_exhibit_steps.rb +53 -0
  155. data/test_support/features/step_definitions/bookmarks_steps.rb +6 -0
  156. data/test_support/features/step_definitions/error_steps.rb +5 -0
  157. data/test_support/features/step_definitions/folder_steps.rb +27 -0
  158. data/test_support/features/step_definitions/general_steps.rb +50 -0
  159. data/test_support/features/step_definitions/record_view_steps.rb +12 -0
  160. data/test_support/features/step_definitions/saved_searches_steps.rb +22 -0
  161. data/test_support/features/step_definitions/search_facets_steps.rb +29 -0
  162. data/test_support/features/step_definitions/search_history_steps.rb +9 -0
  163. data/test_support/features/step_definitions/search_result_steps.rb +114 -0
  164. data/test_support/features/step_definitions/search_steps.rb +103 -0
  165. data/test_support/features/step_definitions/user_steps.rb +5 -0
  166. data/test_support/features/step_definitions/web_steps.rb +213 -0
  167. data/test_support/features/support/env.rb +67 -0
  168. data/test_support/features/support/paths.rb +76 -0
  169. data/test_support/features/support/selectors.rb +40 -0
  170. data/test_support/fixtures/atrium_exhibits.yml +3 -0
  171. data/test_support/spec/controllers/atrium/base_controller_spec.rb +13 -0
  172. data/test_support/spec/controllers/atrium/collection_exhibit_order_controller_spec.rb +29 -0
  173. data/test_support/spec/controllers/atrium/collections_controller_spec.rb +185 -0
  174. data/test_support/spec/controllers/atrium/customization_controller_spec.rb +38 -0
  175. data/test_support/spec/controllers/atrium/descriptions_controller_spec.rb +150 -0
  176. data/test_support/spec/controllers/atrium/exhibit_facet_order_controller_spec.rb +36 -0
  177. data/test_support/spec/controllers/atrium/exhibits_controller_spec.rb +192 -0
  178. data/test_support/spec/controllers/atrium/showcases_controller_spec.rb +185 -0
  179. data/test_support/spec/helpers/atrium_collections_helper_spec.rb +147 -0
  180. data/test_support/spec/helpers/atrium_description_helper_spec.rb +47 -0
  181. data/test_support/spec/helpers/atrium_solr_helper_spec.rb +512 -0
  182. data/test_support/spec/models/atrium/browse_level_spec.rb +31 -0
  183. data/test_support/spec/models/atrium/collection_spec.rb +30 -0
  184. data/test_support/spec/models/atrium/description_spec.rb +67 -0
  185. data/test_support/spec/models/atrium/essay_spec.rb +12 -0
  186. data/test_support/spec/models/atrium/exhibit_spec.rb +76 -0
  187. data/test_support/spec/models/atrium/search/facet_selection_spec.rb +24 -0
  188. data/test_support/spec/models/atrium/search/facet_spec.rb +11 -0
  189. data/test_support/spec/models/atrium/search_facet_spec.rb +54 -0
  190. data/test_support/spec/models/atrium/showcase/facet_selection_spec.rb +15 -0
  191. data/test_support/spec/models/atrium/showcase/item_spec.rb +12 -0
  192. data/test_support/spec/models/atrium/showcase_facet_selection_spec.rb +65 -0
  193. data/test_support/spec/models/atrium/showcase_spec.rb +134 -0
  194. data/test_support/spec/rcov.opts +3 -0
  195. data/test_support/spec/routing/atrium/collections_routing_spec.rb +33 -0
  196. data/test_support/spec/spec.opts +4 -0
  197. data/test_support/spec/spec_helper.rb +47 -0
  198. data/test_support/spec/support/be_accessible_matcher.rb +8 -0
  199. data/test_support/spec/support/be_routed_mixin.rb +7 -0
  200. data/test_support/tmp/step_definitions/catalog_index_steps.rb +14 -0
  201. data/test_support/tmp/step_definitions/edit_document_steps.rb +67 -0
  202. data/test_support/tmp/step_definitions/hydra_metadata_steps.rb +3 -0
  203. data/test_support/tmp/step_definitions/hydra_steps.rb +8 -0
  204. data/test_support/tmp/step_definitions/search_steps.rb +86 -0
  205. data/test_support/tmp/step_definitions/searching_steps.rb +22 -0
  206. data/test_support/tmp/step_definitions/select_steps.rb +8 -0
  207. data/test_support/tmp/step_definitions/show_document_steps.rb +73 -0
  208. data/test_support/tmp/step_definitions/user_steps.rb +15 -0
  209. data/test_support/tmp/step_definitions/web_steps.rb +273 -0
  210. data/test_support/tmp/support/env.rb +54 -0
  211. data/test_support/tmp/support/paths.rb +57 -0
  212. metadata +1047 -0
@@ -0,0 +1,16 @@
1
+ CKEDITOR.plugins.add('linkItem',
2
+ {
3
+ init: function(editor)
4
+ {
5
+ var pluginName = 'linkItem';
6
+ CKEDITOR.dialog.add(pluginName, this.path + 'dialogs/linkItem.js');
7
+ // Register the command used to open the dialog.
8
+ editor.addCommand( pluginName, new CKEDITOR.dialogCommand(pluginName));
9
+ editor.ui.addButton( 'linkItem',
10
+ {
11
+ label : 'Link Item',
12
+ command : pluginName ,
13
+ icon: CKEDITOR.plugins.getPath('linkItem') + 'application_link.png'
14
+ } );
15
+ }
16
+ });
@@ -0,0 +1,864 @@
1
+ // ColorBox v1.3.17.2 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
2
+ // Copyright (c) 2011 Jack Moore - jack@colorpowered.com
3
+ // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
+
5
+ (function ($, document, window) {
6
+ var
7
+ // ColorBox Default Settings.
8
+ // See http://colorpowered.com/colorbox for details.
9
+ defaults = {
10
+ transition: "elastic",
11
+ speed: 300,
12
+ width: false,
13
+ initialWidth: "600",
14
+ innerWidth: false,
15
+ maxWidth: false,
16
+ height: false,
17
+ initialHeight: "450",
18
+ innerHeight: false,
19
+ maxHeight: false,
20
+ scalePhotos: true,
21
+ scrolling: true,
22
+ inline: false,
23
+ html: false,
24
+ iframe: false,
25
+ fastIframe: true,
26
+ photo: false,
27
+ href: false,
28
+ title: false,
29
+ rel: false,
30
+ opacity: 0.9,
31
+ preloading: true,
32
+ current: "image {current} of {total}",
33
+ previous: "previous",
34
+ next: "next",
35
+ close: "close",
36
+ open: false,
37
+ returnFocus: true,
38
+ loop: true,
39
+ slideshow: false,
40
+ slideshowAuto: true,
41
+ slideshowSpeed: 2500,
42
+ slideshowStart: "start slideshow",
43
+ slideshowStop: "stop slideshow",
44
+ onOpen: false,
45
+ onLoad: false,
46
+ onComplete: false,
47
+ onCleanup: false,
48
+ onClosed: false,
49
+ overlayClose: true,
50
+ escKey: true,
51
+ arrowKey: true,
52
+ top: false,
53
+ bottom: false,
54
+ left: false,
55
+ right: false,
56
+ fixed: false,
57
+ data: false
58
+ },
59
+
60
+ // Abstracting the HTML and event identifiers for easy rebranding
61
+ colorbox = 'colorbox',
62
+ prefix = 'cbox',
63
+ boxElement = prefix + 'Element',
64
+
65
+ // Events
66
+ event_open = prefix + '_open',
67
+ event_load = prefix + '_load',
68
+ event_complete = prefix + '_complete',
69
+ event_cleanup = prefix + '_cleanup',
70
+ event_closed = prefix + '_closed',
71
+ event_purge = prefix + '_purge',
72
+
73
+ // Special Handling for IE
74
+ isIE = $.browser.msie && !$.support.opacity, // Detects IE6,7,8. IE9 supports opacity. Feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome, hence the user-agent test.
75
+ isIE6 = isIE && $.browser.version < 7,
76
+ event_ie6 = prefix + '_IE6',
77
+
78
+ // Cached jQuery Object Variables
79
+ $overlay,
80
+ $box,
81
+ $wrap,
82
+ $content,
83
+ $topBorder,
84
+ $leftBorder,
85
+ $rightBorder,
86
+ $bottomBorder,
87
+ $related,
88
+ $window,
89
+ $loaded,
90
+ $loadingBay,
91
+ $loadingOverlay,
92
+ $title,
93
+ $current,
94
+ $slideshow,
95
+ $next,
96
+ $prev,
97
+ $close,
98
+ $groupControls,
99
+
100
+ // Variables for cached values or use across multiple functions
101
+ settings,
102
+ interfaceHeight,
103
+ interfaceWidth,
104
+ loadedHeight,
105
+ loadedWidth,
106
+ element,
107
+ index,
108
+ photo,
109
+ open,
110
+ active,
111
+ closing,
112
+ handler,
113
+ loadingTimer,
114
+ publicMethod;
115
+
116
+ // ****************
117
+ // HELPER FUNCTIONS
118
+ // ****************
119
+
120
+ // jQuery object generator to reduce code size
121
+ function $div(id, cssText, div) {
122
+ div = document.createElement('div');
123
+ if (id) {
124
+ div.id = prefix + id;
125
+ }
126
+ div.style.cssText = cssText || '';
127
+ return $(div);
128
+ }
129
+
130
+ // Convert '%' and 'px' values to integers
131
+ function setSize(size, dimension) {
132
+ return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : $window.height()) / 100) : 1) * parseInt(size, 10));
133
+ }
134
+
135
+ // Checks an href to see if it is a photo.
136
+ // There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
137
+ function isImage(url) {
138
+ return settings.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(url);
139
+ }
140
+
141
+ // Assigns function results to their respective settings. This allows functions to be used as values.
142
+ function makeSettings(i) {
143
+ settings = $.extend({}, $.data(element, colorbox));
144
+
145
+ for (i in settings) {
146
+ if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
147
+ settings[i] = settings[i].call(element);
148
+ }
149
+ }
150
+
151
+ settings.rel = settings.rel || element.rel || 'nofollow';
152
+ settings.href = settings.href || $(element).attr('href');
153
+ settings.title = settings.title || element.title;
154
+
155
+ if (typeof settings.href === "string") {
156
+ settings.href = $.trim(settings.href);
157
+ }
158
+ }
159
+
160
+ function trigger(event, callback) {
161
+ if (callback) {
162
+ callback.call(element);
163
+ }
164
+ $.event.trigger(event);
165
+ }
166
+
167
+ // Slideshow functionality
168
+ function slideshow() {
169
+ var
170
+ timeOut,
171
+ className = prefix + "Slideshow_",
172
+ click = "click." + prefix,
173
+ start,
174
+ stop,
175
+ clear;
176
+
177
+ if (settings.slideshow && $related[1]) {
178
+ start = function () {
179
+ $slideshow
180
+ .text(settings.slideshowStop)
181
+ .unbind(click)
182
+ .bind(event_complete, function () {
183
+ if (index < $related.length - 1 || settings.loop) {
184
+ timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
185
+ }
186
+ })
187
+ .bind(event_load, function () {
188
+ clearTimeout(timeOut);
189
+ })
190
+ .one(click + ' ' + event_cleanup, stop);
191
+ $box.removeClass(className + "off").addClass(className + "on");
192
+ timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
193
+ };
194
+
195
+ stop = function () {
196
+ clearTimeout(timeOut);
197
+ $slideshow
198
+ .text(settings.slideshowStart)
199
+ .unbind([event_complete, event_load, event_cleanup, click].join(' '))
200
+ .one(click, start);
201
+ $box.removeClass(className + "on").addClass(className + "off");
202
+ };
203
+
204
+ if (settings.slideshowAuto) {
205
+ start();
206
+ } else {
207
+ stop();
208
+ }
209
+ } else {
210
+ $box.removeClass(className + "off " + className + "on");
211
+ }
212
+ }
213
+
214
+ function launch(target) {
215
+ if (!closing) {
216
+
217
+ element = target;
218
+
219
+ makeSettings();
220
+
221
+ $related = $(element);
222
+
223
+ index = 0;
224
+
225
+ if (settings.rel !== 'nofollow') {
226
+ $related = $('.' + boxElement).filter(function () {
227
+ var relRelated = $.data(this, colorbox).rel || this.rel;
228
+ return (relRelated === settings.rel);
229
+ });
230
+ index = $related.index(element);
231
+
232
+ // Check direct calls to ColorBox.
233
+ if (index === -1) {
234
+ $related = $related.add(element);
235
+ index = $related.length - 1;
236
+ }
237
+ }
238
+
239
+ if (!open) {
240
+ open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
241
+
242
+ $box.show();
243
+
244
+ if (settings.returnFocus) {
245
+ try {
246
+ element.blur();
247
+ $(element).one(event_closed, function () {
248
+ try {
249
+ this.focus();
250
+ } catch (e) {
251
+ // do nothing
252
+ }
253
+ });
254
+ } catch (e) {
255
+ // do nothing
256
+ }
257
+ }
258
+
259
+ // +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
260
+ $overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
261
+
262
+ // Opens inital empty ColorBox prior to content being loaded.
263
+ settings.w = setSize(settings.initialWidth, 'x');
264
+ settings.h = setSize(settings.initialHeight, 'y');
265
+ publicMethod.position();
266
+
267
+ if (isIE6) {
268
+ $window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
269
+ $overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
270
+ }).trigger('resize.' + event_ie6);
271
+ }
272
+
273
+ trigger(event_open, settings.onOpen);
274
+
275
+ $groupControls.add($title).hide();
276
+
277
+ $close.html(settings.close).show();
278
+ }
279
+
280
+ publicMethod.load(true);
281
+ }
282
+ }
283
+
284
+ // ****************
285
+ // PUBLIC FUNCTIONS
286
+ // Usage format: $.fn.colorbox.close();
287
+ // Usage from within an iframe: parent.$.fn.colorbox.close();
288
+ // ****************
289
+
290
+ publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
291
+ var $this = this;
292
+
293
+ options = options || {};
294
+
295
+ if (!$this[0]) {
296
+ if ($this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
297
+ return $this;
298
+ }
299
+ // if no selector was given (ie. $.colorbox()), create a temporary element to work with
300
+ $this = $('<a/>');
301
+ options.open = true; // assume an immediate open
302
+ }
303
+
304
+ if (callback) {
305
+ options.onComplete = callback;
306
+ }
307
+
308
+ $this.each(function () {
309
+ $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
310
+ $(this).addClass(boxElement);
311
+ });
312
+
313
+ if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
314
+ launch($this[0]);
315
+ }
316
+
317
+ return $this;
318
+ };
319
+
320
+ // Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
321
+ // This preps ColorBox for a speedy open when clicked, and minimizes the burdon on the browser by only
322
+ // having to run once, instead of each time colorbox is opened.
323
+ publicMethod.init = function () {
324
+ // Create & Append jQuery Objects
325
+ $window = $(window);
326
+ $box = $div().attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''});
327
+ $overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide();
328
+
329
+ $wrap = $div("Wrapper");
330
+ $content = $div("Content").append(
331
+ $loaded = $div("LoadedContent", 'width:0; height:0; overflow:hidden'),
332
+ $loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")),
333
+ $title = $div("Title"),
334
+ $current = $div("Current"),
335
+ $next = $div("Next"),
336
+ $prev = $div("Previous"),
337
+ $slideshow = $div("Slideshow").bind(event_open, slideshow),
338
+ $close = $div("Close")
339
+ );
340
+ $wrap.append( // The 3x3 Grid that makes up ColorBox
341
+ $div().append(
342
+ $div("TopLeft"),
343
+ $topBorder = $div("TopCenter"),
344
+ $div("TopRight")
345
+ ),
346
+ $div(false, 'clear:left').append(
347
+ $leftBorder = $div("MiddleLeft"),
348
+ $content,
349
+ $rightBorder = $div("MiddleRight")
350
+ ),
351
+ $div(false, 'clear:left').append(
352
+ $div("BottomLeft"),
353
+ $bottomBorder = $div("BottomCenter"),
354
+ $div("BottomRight")
355
+ )
356
+ ).children().children().css({'float': 'left'});
357
+
358
+ $loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none');
359
+
360
+ $('body').prepend($overlay, $box.append($wrap, $loadingBay));
361
+
362
+ $content.children()
363
+ .hover(function () {
364
+ $(this).addClass('hover');
365
+ }, function () {
366
+ $(this).removeClass('hover');
367
+ }).addClass('hover');
368
+
369
+ // Cache values needed for size calculations
370
+ interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
371
+ interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
372
+ loadedHeight = $loaded.outerHeight(true);
373
+ loadedWidth = $loaded.outerWidth(true);
374
+
375
+ // Setting padding to remove the need to do size conversions during the animation step.
376
+ $box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
377
+
378
+ // Setup button events.
379
+ // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
380
+ $next.click(function () {
381
+ publicMethod.next();
382
+ });
383
+ $prev.click(function () {
384
+ publicMethod.prev();
385
+ });
386
+ $close.click(function () {
387
+ publicMethod.close();
388
+ });
389
+
390
+ $groupControls = $next.add($prev).add($current).add($slideshow);
391
+
392
+ // Adding the 'hover' class allowed the browser to load the hover-state
393
+ // background graphics in case the images were not part of a sprite. The class can now can be removed.
394
+ $content.children().removeClass('hover');
395
+
396
+ $overlay.click(function () {
397
+ if (settings.overlayClose) {
398
+ publicMethod.close();
399
+ }
400
+ });
401
+
402
+ // Set Navigation Key Bindings
403
+ $(document).bind('keydown.' + prefix, function (e) {
404
+ var key = e.keyCode;
405
+ if (open && settings.escKey && key === 27) {
406
+ e.preventDefault();
407
+ publicMethod.close();
408
+ }
409
+ if (open && settings.arrowKey && $related[1]) {
410
+ if (key === 37) {
411
+ e.preventDefault();
412
+ $prev.click();
413
+ } else if (key === 39) {
414
+ e.preventDefault();
415
+ $next.click();
416
+ }
417
+ }
418
+ });
419
+ };
420
+
421
+ publicMethod.remove = function () {
422
+ $box.add($overlay).remove();
423
+ $('.' + boxElement).removeData(colorbox).removeClass(boxElement);
424
+ };
425
+
426
+ publicMethod.position = function (speed, loadedCallback) {
427
+ var top = 0, left = 0;
428
+
429
+ $window.unbind('resize.' + prefix);
430
+
431
+ // remove the modal so that it doesn't influence the document width/height
432
+ $box.hide();
433
+
434
+ if (settings.fixed && !isIE6) {
435
+ $box.css({position: 'fixed'});
436
+ } else {
437
+ top = $window.scrollTop();
438
+ left = $window.scrollLeft();
439
+ $box.css({position: 'absolute'});
440
+ }
441
+
442
+ // keeps the top and left positions within the browser's viewport.
443
+ if (settings.right !== false) {
444
+ left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
445
+ } else if (settings.left !== false) {
446
+ left += setSize(settings.left, 'x');
447
+ } else {
448
+ left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
449
+ }
450
+
451
+ if (settings.bottom !== false) {
452
+ top += Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
453
+ } else if (settings.top !== false) {
454
+ top += setSize(settings.top, 'y');
455
+ } else {
456
+ top += Math.round(Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2);
457
+ }
458
+
459
+ $box.show();
460
+
461
+ // setting the speed to 0 to reduce the delay between same-sized content.
462
+ speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
463
+
464
+ // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
465
+ // but it has to be shrank down around the size of div#colorbox when it's done. If not,
466
+ // it can invoke an obscure IE bug when using iframes.
467
+ $wrap[0].style.width = $wrap[0].style.height = "9999px";
468
+
469
+ function modalDimensions(that) {
470
+ // loading overlay height has to be explicitly set for IE6.
471
+ $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
472
+ $loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
473
+ }
474
+
475
+ $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, {
476
+ duration: speed,
477
+ complete: function () {
478
+ modalDimensions(this);
479
+
480
+ active = false;
481
+
482
+ // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
483
+ $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
484
+ $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
485
+
486
+ if (loadedCallback) {
487
+ loadedCallback();
488
+ }
489
+
490
+ setTimeout(function(){ // small delay before binding onresize due to an IE8 bug.
491
+ $window.bind('resize.' + prefix, publicMethod.position);
492
+ }, 1);
493
+ },
494
+ step: function () {
495
+ modalDimensions(this);
496
+ }
497
+ });
498
+ };
499
+
500
+ publicMethod.resize = function (options) {
501
+ if (open) {
502
+ options = options || {};
503
+
504
+ if (options.width) {
505
+ settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
506
+ }
507
+ if (options.innerWidth) {
508
+ settings.w = setSize(options.innerWidth, 'x');
509
+ }
510
+ $loaded.css({width: settings.w});
511
+
512
+ if (options.height) {
513
+ settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
514
+ }
515
+ if (options.innerHeight) {
516
+ settings.h = setSize(options.innerHeight, 'y');
517
+ }
518
+ if (!options.innerHeight && !options.height) {
519
+ var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
520
+ settings.h = $child.height();
521
+ $child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
522
+ }
523
+ $loaded.css({height: settings.h});
524
+
525
+ publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
526
+ }
527
+ };
528
+
529
+ publicMethod.prep = function (object) {
530
+ if (!open) {
531
+ return;
532
+ }
533
+
534
+ var callback, speed = settings.transition === "none" ? 0 : settings.speed;
535
+
536
+ $loaded.remove();
537
+ $loaded = $div('LoadedContent').append(object);
538
+
539
+ function getWidth() {
540
+ settings.w = settings.w || $loaded.width();
541
+ settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
542
+ return settings.w;
543
+ }
544
+ function getHeight() {
545
+ settings.h = settings.h || $loaded.height();
546
+ settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
547
+ return settings.h;
548
+ }
549
+
550
+ $loaded.hide()
551
+ .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
552
+ .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
553
+ .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
554
+ .prependTo($content);
555
+
556
+ $loadingBay.hide();
557
+
558
+ // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
559
+ //$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
560
+
561
+ $(photo).css({'float': 'none'});
562
+
563
+ // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
564
+ if (isIE6) {
565
+ $('select').not($box.find('select')).filter(function () {
566
+ return this.style.visibility !== 'hidden';
567
+ }).css({'visibility': 'hidden'}).one(event_cleanup, function () {
568
+ this.style.visibility = 'inherit';
569
+ });
570
+ }
571
+
572
+ callback = function () {
573
+ var prev, prevSrc, next, nextSrc, total = $related.length, iframe, complete;
574
+
575
+ if (!open) {
576
+ return;
577
+ }
578
+
579
+ function removeFilter() {
580
+ if (isIE) {
581
+ $box[0].style.removeAttribute('filter');
582
+ }
583
+ }
584
+
585
+ complete = function () {
586
+ clearTimeout(loadingTimer);
587
+ $loadingOverlay.hide();
588
+ trigger(event_complete, settings.onComplete);
589
+ };
590
+
591
+ if (isIE) {
592
+ //This fadeIn helps the bicubic resampling to kick-in.
593
+ if (photo) {
594
+ $loaded.fadeIn(100);
595
+ }
596
+ }
597
+
598
+ $title.html(settings.title).add($loaded).show();
599
+
600
+ if (total > 1) { // handle grouping
601
+ if (typeof settings.current === "string") {
602
+ $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
603
+ }
604
+
605
+ $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
606
+ $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
607
+
608
+ prev = index ? $related[index - 1] : $related[total - 1];
609
+ next = index < total - 1 ? $related[index + 1] : $related[0];
610
+
611
+ if (settings.slideshow) {
612
+ $slideshow.show();
613
+ }
614
+
615
+ // Preloads images within a rel group
616
+ if (settings.preloading) {
617
+ nextSrc = $.data(next, colorbox).href || next.href;
618
+ prevSrc = $.data(prev, colorbox).href || prev.href;
619
+
620
+ nextSrc = $.isFunction(nextSrc) ? nextSrc.call(next) : nextSrc;
621
+ prevSrc = $.isFunction(prevSrc) ? prevSrc.call(prev) : prevSrc;
622
+
623
+ if (isImage(nextSrc)) {
624
+ $('<img/>')[0].src = nextSrc;
625
+ }
626
+
627
+ if (isImage(prevSrc)) {
628
+ $('<img/>')[0].src = prevSrc;
629
+ }
630
+ }
631
+ } else {
632
+ $groupControls.hide();
633
+ }
634
+
635
+ if (settings.iframe) {
636
+ iframe = $('<iframe/>').addClass(prefix + 'Iframe')[0];
637
+
638
+ if (settings.fastIframe) {
639
+ complete();
640
+ } else {
641
+ $(iframe).one('load', complete);
642
+ }
643
+ iframe.name = prefix + (+new Date());
644
+ iframe.src = settings.href;
645
+
646
+ if (!settings.scrolling) {
647
+ iframe.scrolling = "no";
648
+ }
649
+
650
+ if (isIE) {
651
+ iframe.frameBorder = 0;
652
+ iframe.allowTransparency = "true";
653
+ }
654
+
655
+ $(iframe).appendTo($loaded).one(event_purge, function () {
656
+ iframe.src = "//about:blank";
657
+ });
658
+ } else {
659
+ complete();
660
+ }
661
+
662
+ if (settings.transition === 'fade') {
663
+ $box.fadeTo(speed, 1, removeFilter);
664
+ } else {
665
+ removeFilter();
666
+ }
667
+ };
668
+
669
+ if (settings.transition === 'fade') {
670
+ $box.fadeTo(speed, 0, function () {
671
+ publicMethod.position(0, callback);
672
+ });
673
+ } else {
674
+ publicMethod.position(speed, callback);
675
+ }
676
+ };
677
+
678
+ publicMethod.load = function (launched) {
679
+ var href, setResize, prep = publicMethod.prep;
680
+
681
+ active = true;
682
+
683
+ photo = false;
684
+
685
+ element = $related[index];
686
+
687
+ if (!launched) {
688
+ makeSettings();
689
+ }
690
+
691
+ trigger(event_purge);
692
+
693
+ trigger(event_load, settings.onLoad);
694
+
695
+ settings.h = settings.height ?
696
+ setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
697
+ settings.innerHeight && setSize(settings.innerHeight, 'y');
698
+
699
+ settings.w = settings.width ?
700
+ setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
701
+ settings.innerWidth && setSize(settings.innerWidth, 'x');
702
+
703
+ // Sets the minimum dimensions for use in image scaling
704
+ settings.mw = settings.w;
705
+ settings.mh = settings.h;
706
+
707
+ // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
708
+ // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
709
+ if (settings.maxWidth) {
710
+ settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
711
+ settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
712
+ }
713
+ if (settings.maxHeight) {
714
+ settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
715
+ settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
716
+ }
717
+
718
+ href = settings.href;
719
+
720
+ loadingTimer = setTimeout(function () {
721
+ $loadingOverlay.show();
722
+ }, 100);
723
+
724
+ if (settings.inline) {
725
+ // Inserts an empty placeholder where inline content is being pulled from.
726
+ // An event is bound to put inline content back when ColorBox closes or loads new content.
727
+ $div().hide().insertBefore($(href)[0]).one(event_purge, function () {
728
+ $(this).replaceWith($loaded.children());
729
+ });
730
+ prep($(href));
731
+ } else if (settings.iframe) {
732
+ // IFrame element won't be added to the DOM until it is ready to be displayed,
733
+ // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
734
+ prep(" ");
735
+ } else if (settings.html) {
736
+ prep(settings.html);
737
+ } else if (isImage(href)) {
738
+ $(photo = new Image())
739
+ .addClass(prefix + 'Photo')
740
+ .error(function () {
741
+ settings.title = false;
742
+ prep($div('Error').text('This image could not be loaded'));
743
+ })
744
+ .load(function () {
745
+ var percent;
746
+ photo.onload = null; //stops animated gifs from firing the onload repeatedly.
747
+
748
+ if (settings.scalePhotos) {
749
+ setResize = function () {
750
+ photo.height -= photo.height * percent;
751
+ photo.width -= photo.width * percent;
752
+ };
753
+ if (settings.mw && photo.width > settings.mw) {
754
+ percent = (photo.width - settings.mw) / photo.width;
755
+ setResize();
756
+ }
757
+ if (settings.mh && photo.height > settings.mh) {
758
+ percent = (photo.height - settings.mh) / photo.height;
759
+ setResize();
760
+ }
761
+ }
762
+
763
+ if (settings.h) {
764
+ photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
765
+ }
766
+
767
+ if ($related[1] && (index < $related.length - 1 || settings.loop)) {
768
+ photo.style.cursor = 'pointer';
769
+ photo.onclick = function () {
770
+ publicMethod.next();
771
+ };
772
+ }
773
+
774
+ if (isIE) {
775
+ photo.style.msInterpolationMode = 'bicubic';
776
+ }
777
+
778
+ setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
779
+ prep(photo);
780
+ }, 1);
781
+ });
782
+
783
+ setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
784
+ photo.src = href;
785
+ }, 1);
786
+ } else if (href) {
787
+ $loadingBay.load(href, settings.data, function (data, status, xhr) {
788
+ prep(status === 'error' ? $div('Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents());
789
+ });
790
+ }
791
+ };
792
+
793
+ // Navigates to the next page/image in a set.
794
+ publicMethod.next = function () {
795
+ if (!active && $related[1] && (index < $related.length - 1 || settings.loop)) {
796
+ index = index < $related.length - 1 ? index + 1 : 0;
797
+ publicMethod.load();
798
+ }
799
+ };
800
+
801
+ publicMethod.prev = function () {
802
+ if (!active && $related[1] && (index || settings.loop)) {
803
+ index = index ? index - 1 : $related.length - 1;
804
+ publicMethod.load();
805
+ }
806
+ };
807
+
808
+ // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
809
+ publicMethod.close = function () {
810
+ if (open && !closing) {
811
+
812
+ closing = true;
813
+
814
+ open = false;
815
+
816
+ trigger(event_cleanup, settings.onCleanup);
817
+
818
+ $window.unbind('.' + prefix + ' .' + event_ie6);
819
+
820
+ $overlay.fadeTo(200, 0);
821
+
822
+ $box.stop().fadeTo(300, 0, function () {
823
+
824
+ $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
825
+
826
+ trigger(event_purge);
827
+
828
+ $loaded.remove();
829
+
830
+ setTimeout(function () {
831
+ closing = false;
832
+ trigger(event_closed, settings.onClosed);
833
+ }, 1);
834
+ });
835
+ }
836
+ };
837
+
838
+ // A method for fetching the current element ColorBox is referencing.
839
+ // returns a jQuery object.
840
+ publicMethod.element = function () {
841
+ return $(element);
842
+ };
843
+
844
+ publicMethod.settings = defaults;
845
+
846
+ // Bind the live event before DOM-ready for maximum performance in IE6 & 7.
847
+ handler = function (e) {
848
+ // checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt.
849
+ if (!((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey)) {
850
+ e.preventDefault();
851
+ launch(this);
852
+ }
853
+ };
854
+
855
+ if ($.fn.delegate) {
856
+ $(document).delegate('.' + boxElement, 'click', handler);
857
+ } else {
858
+ $('.' + boxElement).live('click', handler);
859
+ }
860
+
861
+ // Initializes ColorBox when the DOM has loaded
862
+ $(publicMethod.init);
863
+
864
+ }(jQuery, document, this));