tennpipes-init 3.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.rdoc +163 -0
  4. data/Rakefile +1 -0
  5. data/bin/tennpipes-init +16 -0
  6. data/lib/tennpipes-init.rb +73 -0
  7. data/lib/tennpipes-init/command.rb +18 -0
  8. data/lib/tennpipes-init/generators/actions.rb +630 -0
  9. data/lib/tennpipes-init/generators/app.rb +75 -0
  10. data/lib/tennpipes-init/generators/app/app.rb.tt +72 -0
  11. data/lib/tennpipes-init/generators/app/app.rb.tt~ +72 -0
  12. data/lib/tennpipes-init/generators/cli.rb +57 -0
  13. data/lib/tennpipes-init/generators/component.rb +73 -0
  14. data/lib/tennpipes-init/generators/components/actions.rb +208 -0
  15. data/lib/tennpipes-init/generators/components/mocks/mocha.rb +10 -0
  16. data/lib/tennpipes-init/generators/components/mocks/rr.rb +13 -0
  17. data/lib/tennpipes-init/generators/components/orms/activerecord.rb +201 -0
  18. data/lib/tennpipes-init/generators/components/orms/couchrest.rb +55 -0
  19. data/lib/tennpipes-init/generators/components/orms/datamapper.rb +140 -0
  20. data/lib/tennpipes-init/generators/components/orms/dynamoid.rb +67 -0
  21. data/lib/tennpipes-init/generators/components/orms/minirecord.rb +165 -0
  22. data/lib/tennpipes-init/generators/components/orms/mongoid.rb +113 -0
  23. data/lib/tennpipes-init/generators/components/orms/mongomapper.rb +43 -0
  24. data/lib/tennpipes-init/generators/components/orms/mongomatic.rb +84 -0
  25. data/lib/tennpipes-init/generators/components/orms/ohm.rb +65 -0
  26. data/lib/tennpipes-init/generators/components/orms/ripple.rb +75 -0
  27. data/lib/tennpipes-init/generators/components/orms/sequel.rb +99 -0
  28. data/lib/tennpipes-init/generators/components/renderers/erb.rb +3 -0
  29. data/lib/tennpipes-init/generators/components/renderers/haml.rb +3 -0
  30. data/lib/tennpipes-init/generators/components/renderers/liquid.rb +4 -0
  31. data/lib/tennpipes-init/generators/components/renderers/slim.rb +3 -0
  32. data/lib/tennpipes-init/generators/components/scripts/dojo.rb +10 -0
  33. data/lib/tennpipes-init/generators/components/scripts/extcore.rb +10 -0
  34. data/lib/tennpipes-init/generators/components/scripts/jquery.rb +10 -0
  35. data/lib/tennpipes-init/generators/components/scripts/mootools.rb +10 -0
  36. data/lib/tennpipes-init/generators/components/scripts/prototype.rb +12 -0
  37. data/lib/tennpipes-init/generators/components/scripts/rightjs.rb +10 -0
  38. data/lib/tennpipes-init/generators/components/stylesheets/compass.rb +39 -0
  39. data/lib/tennpipes-init/generators/components/stylesheets/compass/application.scss +43 -0
  40. data/lib/tennpipes-init/generators/components/stylesheets/compass/partials/_base.scss +12 -0
  41. data/lib/tennpipes-init/generators/components/stylesheets/less.rb +25 -0
  42. data/lib/tennpipes-init/generators/components/stylesheets/sass.rb +15 -0
  43. data/lib/tennpipes-init/generators/components/stylesheets/scss.rb +16 -0
  44. data/lib/tennpipes-init/generators/components/tests/bacon.rb +103 -0
  45. data/lib/tennpipes-init/generators/components/tests/cucumber.rb +86 -0
  46. data/lib/tennpipes-init/generators/components/tests/minitest.rb +110 -0
  47. data/lib/tennpipes-init/generators/components/tests/riot.rb +117 -0
  48. data/lib/tennpipes-init/generators/components/tests/rspec.rb +111 -0
  49. data/lib/tennpipes-init/generators/components/tests/shoulda.rb +114 -0
  50. data/lib/tennpipes-init/generators/components/tests/steak.rb +114 -0
  51. data/lib/tennpipes-init/generators/controller.rb +77 -0
  52. data/lib/tennpipes-init/generators/helper.rb +50 -0
  53. data/lib/tennpipes-init/generators/mailer.rb +52 -0
  54. data/lib/tennpipes-init/generators/migration.rb +43 -0
  55. data/lib/tennpipes-init/generators/model.rb +113 -0
  56. data/lib/tennpipes-init/generators/plugin.rb +67 -0
  57. data/lib/tennpipes-init/generators/project.rb +160 -0
  58. data/lib/tennpipes-init/generators/project/config.ru +9 -0
  59. data/lib/tennpipes-init/generators/project/config/apps.rb.tt +35 -0
  60. data/lib/tennpipes-init/generators/project/config/boot.rb +49 -0
  61. data/lib/tennpipes-init/generators/project/public/favicon.ico +0 -0
  62. data/lib/tennpipes-init/generators/project/public/images/booking.com.png +0 -0
  63. data/lib/tennpipes-init/generators/project/public/images/causes.png +0 -0
  64. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bg.jpg +0 -0
  65. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.png +0 -0
  66. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.svg +68 -0
  67. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.png +0 -0
  68. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.svg +65 -0
  69. data/lib/tennpipes-init/generators/project/public/images/forever21.png +0 -0
  70. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.eot +0 -0
  71. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.svg +970 -0
  72. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.ttf +0 -0
  73. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.woff +0 -0
  74. data/lib/tennpipes-init/generators/project/public/images/icons/tennpipes-icons.css +598 -0
  75. data/lib/tennpipes-init/generators/project/public/images/image1.jpg +0 -0
  76. data/lib/tennpipes-init/generators/project/public/images/image11.jpg +0 -0
  77. data/lib/tennpipes-init/generators/project/public/images/image2.jpg +0 -0
  78. data/lib/tennpipes-init/generators/project/public/images/image3.jpg +0 -0
  79. data/lib/tennpipes-init/generators/project/public/images/intuit.png +0 -0
  80. data/lib/tennpipes-init/generators/project/public/images/krispykreme.png +0 -0
  81. data/lib/tennpipes-init/generators/project/public/images/placeholders/README.md +302 -0
  82. data/lib/tennpipes-init/generators/project/public/images/placeholders/bower.json +4 -0
  83. data/lib/tennpipes-init/generators/project/public/images/placeholders/composer.json +34 -0
  84. data/lib/tennpipes-init/generators/project/public/images/placeholders/gulpfile.js +92 -0
  85. data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.js +1920 -0
  86. data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.min.js +12 -0
  87. data/lib/tennpipes-init/generators/project/public/images/placeholders/package.json +46 -0
  88. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/holder.js +1411 -0
  89. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/augment.js +27 -0
  90. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/ondomready.js +155 -0
  91. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/polyfills.js +177 -0
  92. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/scenegraph.js +101 -0
  93. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/utils.js +129 -0
  94. data/lib/tennpipes-init/generators/project/public/images/priceline.com.png +0 -0
  95. data/lib/tennpipes-init/generators/project/public/images/stripe.png +0 -0
  96. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes.min.js +6081 -0
  97. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.abide.js +340 -0
  98. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.accordion.js +67 -0
  99. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.alert.js +43 -0
  100. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.clearing.js +556 -0
  101. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.dropdown.js +448 -0
  102. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.equalizer.js +77 -0
  103. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.interchange.js +354 -0
  104. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.joyride.js +932 -0
  105. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.js +703 -0
  106. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.magellan.js +203 -0
  107. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.offcanvas.js +152 -0
  108. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.orbit.js +476 -0
  109. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.reveal.js +471 -0
  110. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.slider.js +263 -0
  111. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tab.js +237 -0
  112. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tooltip.js +307 -0
  113. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.topbar.js +452 -0
  114. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/fastclick.js +8 -0
  115. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.cookie.js +8 -0
  116. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.js +26 -0
  117. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/modernizr.js +8 -0
  118. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/placeholder.js +2 -0
  119. data/lib/tennpipes-init/generators/project/public/stylesheets/app.css~ +178 -0
  120. data/lib/tennpipes-init/generators/project/public/stylesheets/app1.css~ +177 -0
  121. data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css +214 -0
  122. data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css~ +214 -0
  123. data/lib/tennpipes-init/generators/project/public/stylesheets/normalize.css +427 -0
  124. data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css +6201 -0
  125. data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css~ +6201 -0
  126. data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.min.css +1 -0
  127. data/lib/tennpipes-init/generators/runner.rb +139 -0
  128. data/lib/tennpipes-init/generators/task.rb +45 -0
  129. data/lib/tennpipes-init/generators/templates/Gemfile.tt +32 -0
  130. data/lib/tennpipes-init/generators/templates/Rakefile.tt +8 -0
  131. data/lib/tennpipes-init/generators/templates/controller.rb.tt +22 -0
  132. data/lib/tennpipes-init/generators/templates/gem/README.md.tt +29 -0
  133. data/lib/tennpipes-init/generators/templates/gem/gemspec.tt +19 -0
  134. data/lib/tennpipes-init/generators/templates/gem/lib/libname.tt +6 -0
  135. data/lib/tennpipes-init/generators/templates/gem/lib/libname/version.tt +3 -0
  136. data/lib/tennpipes-init/generators/templates/helper.rb.tt +13 -0
  137. data/lib/tennpipes-init/generators/templates/initializer.rb.tt +5 -0
  138. data/lib/tennpipes-init/generators/templates/mailer.rb.tt +54 -0
  139. data/lib/tennpipes-init/generators/templates/project_bin.tt +14 -0
  140. data/lib/tennpipes-init/generators/templates/task.rb.tt +7 -0
  141. data/lib/tennpipes-init/tennpipes-tasks/activerecord.rb +377 -0
  142. data/lib/tennpipes-init/tennpipes-tasks/database.rb +12 -0
  143. data/lib/tennpipes-init/tennpipes-tasks/datamapper.rb +94 -0
  144. data/lib/tennpipes-init/tennpipes-tasks/minirecord.rb +19 -0
  145. data/lib/tennpipes-init/tennpipes-tasks/mongoid.rb +215 -0
  146. data/lib/tennpipes-init/tennpipes-tasks/mongomapper.rb +55 -0
  147. data/lib/tennpipes-init/tennpipes-tasks/sequel.rb +85 -0
  148. data/lib/tennpipes-init/tennpipes-tasks/sql-helpers.rb +72 -0
  149. data/test/fixtures/admin_template.rb +7 -0
  150. data/test/fixtures/example_template.rb +15 -0
  151. data/test/fixtures/git_template.rb +4 -0
  152. data/test/fixtures/plugin_template.rb +13 -0
  153. data/test/fixtures/rake_template.rb +9 -0
  154. data/test/helper.rb +103 -0
  155. data/test/test_app_generator.rb +142 -0
  156. data/test/test_cli.rb +27 -0
  157. data/test/test_component_generator.rb +98 -0
  158. data/test/test_controller_generator.rb +272 -0
  159. data/test/test_generator.rb +13 -0
  160. data/test/test_helper_generator.rb +133 -0
  161. data/test/test_mailer_generator.rb +69 -0
  162. data/test/test_migration_generator.rb +222 -0
  163. data/test/test_model_generator.rb +553 -0
  164. data/test/test_plugin_generator.rb +152 -0
  165. data/test/test_project_generator.rb +757 -0
  166. data/test/test_task_generator.rb +53 -0
  167. metadata +285 -0
@@ -0,0 +1,556 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Tennpipes.libs.clearing = {
5
+ name : 'clearing',
6
+
7
+ version : '5.5.1',
8
+
9
+ settings : {
10
+ templates : {
11
+ viewing : '<a href="#" class="clearing-close">&times;</a>' +
12
+ '<div class="visible-img" style="display: none"><div class="clearing-touch-label"></div><img src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" alt="" />' +
13
+ '<p class="clearing-caption"></p><a href="#" class="clearing-main-prev"><span></span></a>' +
14
+ '<a href="#" class="clearing-main-next"><span></span></a></div>'
15
+ },
16
+
17
+ // comma delimited list of selectors that, on click, will close clearing,
18
+ // add 'div.clearing-blackout, div.visible-img' to close on background click
19
+ close_selectors : '.clearing-close, div.clearing-blackout',
20
+
21
+ // Default to the entire li element.
22
+ open_selectors : '',
23
+
24
+ // Image will be skipped in carousel.
25
+ skip_selector : '',
26
+
27
+ touch_label : '',
28
+
29
+ // event initializers and locks
30
+ init : false,
31
+ locked : false
32
+ },
33
+
34
+ init : function (scope, method, options) {
35
+ var self = this;
36
+ Tennpipes.inherit(this, 'throttle image_loaded');
37
+
38
+ this.bindings(method, options);
39
+
40
+ if (self.S(this.scope).is('[' + this.attr_name() + ']')) {
41
+ this.assemble(self.S('li', this.scope));
42
+ } else {
43
+ self.S('[' + this.attr_name() + ']', this.scope).each(function () {
44
+ self.assemble(self.S('li', this));
45
+ });
46
+ }
47
+ },
48
+
49
+ events : function (scope) {
50
+ var self = this,
51
+ S = self.S,
52
+ $scroll_container = $('.scroll-container');
53
+
54
+ if ($scroll_container.length > 0) {
55
+ this.scope = $scroll_container;
56
+ }
57
+
58
+ S(this.scope)
59
+ .off('.clearing')
60
+ .on('click.fndtn.clearing', 'ul[' + this.attr_name() + '] li ' + this.settings.open_selectors,
61
+ function (e, current, target) {
62
+ var current = current || S(this),
63
+ target = target || current,
64
+ next = current.next('li'),
65
+ settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init'),
66
+ image = S(e.target);
67
+
68
+ e.preventDefault();
69
+
70
+ if (!settings) {
71
+ self.init();
72
+ settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
73
+ }
74
+
75
+ // if clearing is open and the current image is
76
+ // clicked, go to the next image in sequence
77
+ if (target.hasClass('visible') &&
78
+ current[0] === target[0] &&
79
+ next.length > 0 && self.is_open(current)) {
80
+ target = next;
81
+ image = S('img', target);
82
+ }
83
+
84
+ // set current and target to the clicked li if not otherwise defined.
85
+ self.open(image, current, target);
86
+ self.update_paddles(target);
87
+ })
88
+
89
+ .on('click.fndtn.clearing', '.clearing-main-next',
90
+ function (e) { self.nav(e, 'next') })
91
+ .on('click.fndtn.clearing', '.clearing-main-prev',
92
+ function (e) { self.nav(e, 'prev') })
93
+ .on('click.fndtn.clearing', this.settings.close_selectors,
94
+ function (e) { Tennpipes.libs.clearing.close(e, this) });
95
+
96
+ $(document).on('keydown.fndtn.clearing',
97
+ function (e) { self.keydown(e) });
98
+
99
+ S(window).off('.clearing').on('resize.fndtn.clearing',
100
+ function () { self.resize() });
101
+
102
+ this.swipe_events(scope);
103
+ },
104
+
105
+ swipe_events : function (scope) {
106
+ var self = this,
107
+ S = self.S;
108
+
109
+ S(this.scope)
110
+ .on('touchstart.fndtn.clearing', '.visible-img', function (e) {
111
+ if (!e.touches) { e = e.originalEvent; }
112
+ var data = {
113
+ start_page_x : e.touches[0].pageX,
114
+ start_page_y : e.touches[0].pageY,
115
+ start_time : (new Date()).getTime(),
116
+ delta_x : 0,
117
+ is_scrolling : undefined
118
+ };
119
+
120
+ S(this).data('swipe-transition', data);
121
+ e.stopPropagation();
122
+ })
123
+ .on('touchmove.fndtn.clearing', '.visible-img', function (e) {
124
+ if (!e.touches) {
125
+ e = e.originalEvent;
126
+ }
127
+ // Ignore pinch/zoom events
128
+ if (e.touches.length > 1 || e.scale && e.scale !== 1) {
129
+ return;
130
+ }
131
+
132
+ var data = S(this).data('swipe-transition');
133
+
134
+ if (typeof data === 'undefined') {
135
+ data = {};
136
+ }
137
+
138
+ data.delta_x = e.touches[0].pageX - data.start_page_x;
139
+
140
+ if (Tennpipes.rtl) {
141
+ data.delta_x = -data.delta_x;
142
+ }
143
+
144
+ if (typeof data.is_scrolling === 'undefined') {
145
+ data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
146
+ }
147
+
148
+ if (!data.is_scrolling && !data.active) {
149
+ e.preventDefault();
150
+ var direction = (data.delta_x < 0) ? 'next' : 'prev';
151
+ data.active = true;
152
+ self.nav(e, direction);
153
+ }
154
+ })
155
+ .on('touchend.fndtn.clearing', '.visible-img', function (e) {
156
+ S(this).data('swipe-transition', {});
157
+ e.stopPropagation();
158
+ });
159
+ },
160
+
161
+ assemble : function ($li) {
162
+ var $el = $li.parent();
163
+
164
+ if ($el.parent().hasClass('carousel')) {
165
+ return;
166
+ }
167
+
168
+ $el.after('<div id="tennpipesClearingHolder"></div>');
169
+
170
+ var grid = $el.detach(),
171
+ grid_outerHTML = '';
172
+
173
+ if (grid[0] == null) {
174
+ return;
175
+ } else {
176
+ grid_outerHTML = grid[0].outerHTML;
177
+ }
178
+
179
+ var holder = this.S('#tennpipesClearingHolder'),
180
+ settings = $el.data(this.attr_name(true) + '-init'),
181
+ data = {
182
+ grid : '<div class="carousel">' + grid_outerHTML + '</div>',
183
+ viewing : settings.templates.viewing
184
+ },
185
+ wrapper = '<div class="clearing-assembled"><div>' + data.viewing +
186
+ data.grid + '</div></div>',
187
+ touch_label = this.settings.touch_label;
188
+
189
+ if (Modernizr.touch) {
190
+ wrapper = $(wrapper).find('.clearing-touch-label').html(touch_label).end();
191
+ }
192
+
193
+ holder.after(wrapper).remove();
194
+ },
195
+
196
+ open : function ($image, current, target) {
197
+ var self = this,
198
+ body = $(document.body),
199
+ root = target.closest('.clearing-assembled'),
200
+ container = self.S('div', root).first(),
201
+ visible_image = self.S('.visible-img', container),
202
+ image = self.S('img', visible_image).not($image),
203
+ label = self.S('.clearing-touch-label', container),
204
+ error = false;
205
+
206
+ // Event to disable scrolling on touch devices when Clearing is activated
207
+ $('body').on('touchmove', function (e) {
208
+ e.preventDefault();
209
+ });
210
+
211
+ image.error(function () {
212
+ error = true;
213
+ });
214
+
215
+ function startLoad() {
216
+ setTimeout(function () {
217
+ this.image_loaded(image, function () {
218
+ if (image.outerWidth() === 1 && !error) {
219
+ startLoad.call(this);
220
+ } else {
221
+ cb.call(this, image);
222
+ }
223
+ }.bind(this));
224
+ }.bind(this), 100);
225
+ }
226
+
227
+ function cb (image) {
228
+ var $image = $(image);
229
+ $image.css('visibility', 'visible');
230
+ // toggle the gallery
231
+ body.css('overflow', 'hidden');
232
+ root.addClass('clearing-blackout');
233
+ container.addClass('clearing-container');
234
+ visible_image.show();
235
+ this.fix_height(target)
236
+ .caption(self.S('.clearing-caption', visible_image), self.S('img', target))
237
+ .center_and_label(image, label)
238
+ .shift(current, target, function () {
239
+ target.closest('li').siblings().removeClass('visible');
240
+ target.closest('li').addClass('visible');
241
+ });
242
+ visible_image.trigger('opened.fndtn.clearing')
243
+ }
244
+
245
+ if (!this.locked()) {
246
+ visible_image.trigger('open.fndtn.clearing');
247
+ // set the image to the selected thumbnail
248
+ image
249
+ .attr('src', this.load($image))
250
+ .css('visibility', 'hidden');
251
+
252
+ startLoad.call(this);
253
+ }
254
+ },
255
+
256
+ close : function (e, el) {
257
+ e.preventDefault();
258
+
259
+ var root = (function (target) {
260
+ if (/blackout/.test(target.selector)) {
261
+ return target;
262
+ } else {
263
+ return target.closest('.clearing-blackout');
264
+ }
265
+ }($(el))),
266
+ body = $(document.body), container, visible_image;
267
+
268
+ if (el === e.target && root) {
269
+ body.css('overflow', '');
270
+ container = $('div', root).first();
271
+ visible_image = $('.visible-img', container);
272
+ visible_image.trigger('close.fndtn.clearing');
273
+ this.settings.prev_index = 0;
274
+ $('ul[' + this.attr_name() + ']', root)
275
+ .attr('style', '').closest('.clearing-blackout')
276
+ .removeClass('clearing-blackout');
277
+ container.removeClass('clearing-container');
278
+ visible_image.hide();
279
+ visible_image.trigger('closed.fndtn.clearing');
280
+ }
281
+
282
+ // Event to re-enable scrolling on touch devices
283
+ $('body').off('touchmove');
284
+
285
+ return false;
286
+ },
287
+
288
+ is_open : function (current) {
289
+ return current.parent().prop('style').length > 0;
290
+ },
291
+
292
+ keydown : function (e) {
293
+ var clearing = $('.clearing-blackout ul[' + this.attr_name() + ']'),
294
+ NEXT_KEY = this.rtl ? 37 : 39,
295
+ PREV_KEY = this.rtl ? 39 : 37,
296
+ ESC_KEY = 27;
297
+
298
+ if (e.which === NEXT_KEY) {
299
+ this.go(clearing, 'next');
300
+ }
301
+ if (e.which === PREV_KEY) {
302
+ this.go(clearing, 'prev');
303
+ }
304
+ if (e.which === ESC_KEY) {
305
+ this.S('a.clearing-close').trigger('click').trigger('click.fndtn.clearing');
306
+ }
307
+ },
308
+
309
+ nav : function (e, direction) {
310
+ var clearing = $('ul[' + this.attr_name() + ']', '.clearing-blackout');
311
+
312
+ e.preventDefault();
313
+ this.go(clearing, direction);
314
+ },
315
+
316
+ resize : function () {
317
+ var image = $('img', '.clearing-blackout .visible-img'),
318
+ label = $('.clearing-touch-label', '.clearing-blackout');
319
+
320
+ if (image.length) {
321
+ this.center_and_label(image, label);
322
+ image.trigger('resized.fndtn.clearing')
323
+ }
324
+ },
325
+
326
+ // visual adjustments
327
+ fix_height : function (target) {
328
+ var lis = target.parent().children(),
329
+ self = this;
330
+
331
+ lis.each(function () {
332
+ var li = self.S(this),
333
+ image = li.find('img');
334
+
335
+ if (li.height() > image.outerHeight()) {
336
+ li.addClass('fix-height');
337
+ }
338
+ })
339
+ .closest('ul')
340
+ .width(lis.length * 100 + '%');
341
+
342
+ return this;
343
+ },
344
+
345
+ update_paddles : function (target) {
346
+ target = target.closest('li');
347
+ var visible_image = target
348
+ .closest('.carousel')
349
+ .siblings('.visible-img');
350
+
351
+ if (target.next().length > 0) {
352
+ this.S('.clearing-main-next', visible_image).removeClass('disabled');
353
+ } else {
354
+ this.S('.clearing-main-next', visible_image).addClass('disabled');
355
+ }
356
+
357
+ if (target.prev().length > 0) {
358
+ this.S('.clearing-main-prev', visible_image).removeClass('disabled');
359
+ } else {
360
+ this.S('.clearing-main-prev', visible_image).addClass('disabled');
361
+ }
362
+ },
363
+
364
+ center_and_label : function (target, label) {
365
+ if (!this.rtl && label.length > 0) {
366
+ label.css({
367
+ marginLeft : -(label.outerWidth() / 2),
368
+ marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10
369
+ });
370
+ } else {
371
+ label.css({
372
+ marginRight : -(label.outerWidth() / 2),
373
+ marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10,
374
+ left: 'auto',
375
+ right: '50%'
376
+ });
377
+ }
378
+ return this;
379
+ },
380
+
381
+ // image loading and preloading
382
+
383
+ load : function ($image) {
384
+ var href;
385
+
386
+ if ($image[0].nodeName === 'A') {
387
+ href = $image.attr('href');
388
+ } else {
389
+ href = $image.closest('a').attr('href');
390
+ }
391
+
392
+ this.preload($image);
393
+
394
+ if (href) {
395
+ return href;
396
+ }
397
+ return $image.attr('src');
398
+ },
399
+
400
+ preload : function ($image) {
401
+ this
402
+ .img($image.closest('li').next())
403
+ .img($image.closest('li').prev());
404
+ },
405
+
406
+ img : function (img) {
407
+ if (img.length) {
408
+ var new_img = new Image(),
409
+ new_a = this.S('a', img);
410
+
411
+ if (new_a.length) {
412
+ new_img.src = new_a.attr('href');
413
+ } else {
414
+ new_img.src = this.S('img', img).attr('src');
415
+ }
416
+ }
417
+ return this;
418
+ },
419
+
420
+ // image caption
421
+
422
+ caption : function (container, $image) {
423
+ var caption = $image.attr('data-caption');
424
+
425
+ if (caption) {
426
+ container
427
+ .html(caption)
428
+ .show();
429
+ } else {
430
+ container
431
+ .text('')
432
+ .hide();
433
+ }
434
+ return this;
435
+ },
436
+
437
+ // directional methods
438
+
439
+ go : function ($ul, direction) {
440
+ var current = this.S('.visible', $ul),
441
+ target = current[direction]();
442
+
443
+ // Check for skip selector.
444
+ if (this.settings.skip_selector && target.find(this.settings.skip_selector).length != 0) {
445
+ target = target[direction]();
446
+ }
447
+
448
+ if (target.length) {
449
+ this.S('img', target)
450
+ .trigger('click', [current, target]).trigger('click.fndtn.clearing', [current, target])
451
+ .trigger('change.fndtn.clearing');
452
+ }
453
+ },
454
+
455
+ shift : function (current, target, callback) {
456
+ var clearing = target.parent(),
457
+ old_index = this.settings.prev_index || target.index(),
458
+ direction = this.direction(clearing, current, target),
459
+ dir = this.rtl ? 'right' : 'left',
460
+ left = parseInt(clearing.css('left'), 10),
461
+ width = target.outerWidth(),
462
+ skip_shift;
463
+
464
+ var dir_obj = {};
465
+
466
+ // we use jQuery animate instead of CSS transitions because we
467
+ // need a callback to unlock the next animation
468
+ // needs support for RTL **
469
+ if (target.index() !== old_index && !/skip/.test(direction)) {
470
+ if (/left/.test(direction)) {
471
+ this.lock();
472
+ dir_obj[dir] = left + width;
473
+ clearing.animate(dir_obj, 300, this.unlock());
474
+ } else if (/right/.test(direction)) {
475
+ this.lock();
476
+ dir_obj[dir] = left - width;
477
+ clearing.animate(dir_obj, 300, this.unlock());
478
+ }
479
+ } else if (/skip/.test(direction)) {
480
+ // the target image is not adjacent to the current image, so
481
+ // do we scroll right or not
482
+ skip_shift = target.index() - this.settings.up_count;
483
+ this.lock();
484
+
485
+ if (skip_shift > 0) {
486
+ dir_obj[dir] = -(skip_shift * width);
487
+ clearing.animate(dir_obj, 300, this.unlock());
488
+ } else {
489
+ dir_obj[dir] = 0;
490
+ clearing.animate(dir_obj, 300, this.unlock());
491
+ }
492
+ }
493
+
494
+ callback();
495
+ },
496
+
497
+ direction : function ($el, current, target) {
498
+ var lis = this.S('li', $el),
499
+ li_width = lis.outerWidth() + (lis.outerWidth() / 4),
500
+ up_count = Math.floor(this.S('.clearing-container').outerWidth() / li_width) - 1,
501
+ target_index = lis.index(target),
502
+ response;
503
+
504
+ this.settings.up_count = up_count;
505
+
506
+ if (this.adjacent(this.settings.prev_index, target_index)) {
507
+ if ((target_index > up_count) && target_index > this.settings.prev_index) {
508
+ response = 'right';
509
+ } else if ((target_index > up_count - 1) && target_index <= this.settings.prev_index) {
510
+ response = 'left';
511
+ } else {
512
+ response = false;
513
+ }
514
+ } else {
515
+ response = 'skip';
516
+ }
517
+
518
+ this.settings.prev_index = target_index;
519
+
520
+ return response;
521
+ },
522
+
523
+ adjacent : function (current_index, target_index) {
524
+ for (var i = target_index + 1; i >= target_index - 1; i--) {
525
+ if (i === current_index) {
526
+ return true;
527
+ }
528
+ }
529
+ return false;
530
+ },
531
+
532
+ // lock management
533
+
534
+ lock : function () {
535
+ this.settings.locked = true;
536
+ },
537
+
538
+ unlock : function () {
539
+ this.settings.locked = false;
540
+ },
541
+
542
+ locked : function () {
543
+ return this.settings.locked;
544
+ },
545
+
546
+ off : function () {
547
+ this.S(this.scope).off('.fndtn.clearing');
548
+ this.S(window).off('.fndtn.clearing');
549
+ },
550
+
551
+ reflow : function () {
552
+ this.init();
553
+ }
554
+ };
555
+
556
+ }(jQuery, window, window.document));