fomantic-ui-sass 2.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +27 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +370 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +177 -0
  9. data/Rakefile +8 -0
  10. data/app/assets/fonts/semantic-ui/brand-icons.eot +0 -0
  11. data/app/assets/fonts/semantic-ui/brand-icons.svg +1008 -0
  12. data/app/assets/fonts/semantic-ui/brand-icons.ttf +0 -0
  13. data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
  14. data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
  15. data/app/assets/fonts/semantic-ui/icons.eot +0 -0
  16. data/app/assets/fonts/semantic-ui/icons.otf +0 -0
  17. data/app/assets/fonts/semantic-ui/icons.svg +1518 -0
  18. data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
  19. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  20. data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
  21. data/app/assets/fonts/semantic-ui/outline-icons.eot +0 -0
  22. data/app/assets/fonts/semantic-ui/outline-icons.svg +366 -0
  23. data/app/assets/fonts/semantic-ui/outline-icons.ttf +0 -0
  24. data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
  25. data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
  26. data/app/assets/images/semantic-ui/flags.png +0 -0
  27. data/app/assets/javascripts/semantic-ui.js +27 -0
  28. data/app/assets/javascripts/semantic-ui/accordion.js +613 -0
  29. data/app/assets/javascripts/semantic-ui/api.js +1167 -0
  30. data/app/assets/javascripts/semantic-ui/calendar.js +1476 -0
  31. data/app/assets/javascripts/semantic-ui/checkbox.js +828 -0
  32. data/app/assets/javascripts/semantic-ui/colorize.js +280 -0
  33. data/app/assets/javascripts/semantic-ui/dimmer.js +735 -0
  34. data/app/assets/javascripts/semantic-ui/dropdown.js +4030 -0
  35. data/app/assets/javascripts/semantic-ui/embed.js +706 -0
  36. data/app/assets/javascripts/semantic-ui/form.js +1707 -0
  37. data/app/assets/javascripts/semantic-ui/modal.js +1090 -0
  38. data/app/assets/javascripts/semantic-ui/nag.js +507 -0
  39. data/app/assets/javascripts/semantic-ui/popup.js +1532 -0
  40. data/app/assets/javascripts/semantic-ui/progress.js +923 -0
  41. data/app/assets/javascripts/semantic-ui/range.js +278 -0
  42. data/app/assets/javascripts/semantic-ui/rating.js +511 -0
  43. data/app/assets/javascripts/semantic-ui/search.js +1515 -0
  44. data/app/assets/javascripts/semantic-ui/shape.js +921 -0
  45. data/app/assets/javascripts/semantic-ui/sidebar.js +1033 -0
  46. data/app/assets/javascripts/semantic-ui/site.js +490 -0
  47. data/app/assets/javascripts/semantic-ui/state.js +708 -0
  48. data/app/assets/javascripts/semantic-ui/sticky.js +959 -0
  49. data/app/assets/javascripts/semantic-ui/tab.js +952 -0
  50. data/app/assets/javascripts/semantic-ui/toast.js +592 -0
  51. data/app/assets/javascripts/semantic-ui/transition.js +1106 -0
  52. data/app/assets/javascripts/semantic-ui/video.js +532 -0
  53. data/app/assets/javascripts/semantic-ui/visibility.js +1311 -0
  54. data/app/assets/javascripts/semantic-ui/visit.js +525 -0
  55. data/app/assets/stylesheets/semantic-ui.scss +5 -0
  56. data/app/assets/stylesheets/semantic-ui/collections/_all.scss +6 -0
  57. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +124 -0
  58. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +1158 -0
  59. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +2093 -0
  60. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +2193 -0
  61. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +606 -0
  62. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +1117 -0
  63. data/app/assets/stylesheets/semantic-ui/elements/_all.scss +16 -0
  64. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +4530 -0
  65. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +145 -0
  66. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +259 -0
  67. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1036 -0
  68. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +762 -0
  69. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +6330 -0
  70. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +310 -0
  71. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +519 -0
  72. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +1395 -0
  73. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +959 -0
  74. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +458 -0
  75. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +242 -0
  76. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +152 -0
  77. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +295 -0
  78. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +884 -0
  79. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +675 -0
  80. data/app/assets/stylesheets/semantic-ui/globals/_all.scss +3 -0
  81. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +485 -0
  82. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +206 -0
  83. data/app/assets/stylesheets/semantic-ui/globals/_variables.scss +4 -0
  84. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +247 -0
  85. data/app/assets/stylesheets/semantic-ui/modules/_all.scss +20 -0
  86. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +165 -0
  87. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +718 -0
  88. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +464 -0
  89. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +1745 -0
  90. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +165 -0
  91. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +646 -0
  92. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +148 -0
  93. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +789 -0
  94. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +523 -0
  95. data/app/assets/stylesheets/semantic-ui/modules/_range.scss +192 -0
  96. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +263 -0
  97. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +445 -0
  98. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +154 -0
  99. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +626 -0
  100. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +78 -0
  101. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +92 -0
  102. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +291 -0
  103. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +2059 -0
  104. data/app/assets/stylesheets/semantic-ui/modules/_video.scss +125 -0
  105. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +275 -0
  106. data/app/assets/stylesheets/semantic-ui/views/_all.scss +6 -0
  107. data/app/assets/stylesheets/semantic-ui/views/_card.scss +1124 -0
  108. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +296 -0
  109. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +314 -0
  110. data/app/assets/stylesheets/semantic-ui/views/_item.scss +555 -0
  111. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +583 -0
  112. data/app/helpers/semantic_breadcrumbs_helper.rb +10 -0
  113. data/app/helpers/semantic_flash_helper.rb +22 -0
  114. data/app/helpers/semantic_icon_helper.rb +8 -0
  115. data/app/views/semantic/_breadcrumbs.html.erb +12 -0
  116. data/fomantic-ui-sass.gemspec +31 -0
  117. data/lib/fomantic-ui-sass.rb +62 -0
  118. data/lib/fomantic/ui/sass/breadcrumbs.rb +41 -0
  119. data/lib/fomantic/ui/sass/engine.rb +23 -0
  120. data/lib/fomantic/ui/sass/version.rb +8 -0
  121. data/spec/dummy/README.rdoc +28 -0
  122. data/spec/dummy/Rakefile +6 -0
  123. data/spec/dummy/app/assets/images/.keep +0 -0
  124. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  125. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  126. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  127. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  128. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  129. data/spec/dummy/app/mailers/.keep +0 -0
  130. data/spec/dummy/app/models/.keep +0 -0
  131. data/spec/dummy/app/models/concerns/.keep +0 -0
  132. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  133. data/spec/dummy/bin/bundle +3 -0
  134. data/spec/dummy/bin/rails +4 -0
  135. data/spec/dummy/bin/rake +4 -0
  136. data/spec/dummy/config.ru +4 -0
  137. data/spec/dummy/config/application.rb +28 -0
  138. data/spec/dummy/config/boot.rb +5 -0
  139. data/spec/dummy/config/environment.rb +5 -0
  140. data/spec/dummy/config/environments/development.rb +29 -0
  141. data/spec/dummy/config/environments/production.rb +80 -0
  142. data/spec/dummy/config/environments/test.rb +36 -0
  143. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  144. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  145. data/spec/dummy/config/initializers/inflections.rb +16 -0
  146. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  147. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  148. data/spec/dummy/config/initializers/session_store.rb +3 -0
  149. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  150. data/spec/dummy/config/locales/en.yml +23 -0
  151. data/spec/dummy/config/routes.rb +2 -0
  152. data/spec/dummy/lib/assets/.keep +0 -0
  153. data/spec/dummy/log/.keep +0 -0
  154. data/spec/dummy/public/404.html +58 -0
  155. data/spec/dummy/public/422.html +58 -0
  156. data/spec/dummy/public/500.html +57 -0
  157. data/spec/dummy/public/favicon.ico +0 -0
  158. data/spec/helpers/semantic_breadcrumbs_helper_spec.rb +38 -0
  159. data/spec/helpers/semantic_flash_helper_spec.rb +36 -0
  160. data/spec/helpers/semantic_icon_helper_spec.rb +48 -0
  161. data/spec/spec_helper.rb +17 -0
  162. data/tasks/converter.rb +216 -0
  163. data/templates/project/manifest.rb +29 -0
  164. data/templates/project/styles.scss +1 -0
  165. metadata +390 -0
@@ -0,0 +1,921 @@
1
+ /*!
2
+ * # Semantic UI - Shape
3
+ * http://github.com/semantic-org/semantic-ui/
4
+ *
5
+ *
6
+ * Released under the MIT license
7
+ * http://opensource.org/licenses/MIT
8
+ *
9
+ */
10
+
11
+ ;(function ($, window, document, undefined) {
12
+
13
+ 'use strict';
14
+
15
+ window = (typeof window != 'undefined' && window.Math == Math)
16
+ ? window
17
+ : (typeof self != 'undefined' && self.Math == Math)
18
+ ? self
19
+ : Function('return this')()
20
+ ;
21
+
22
+ $.fn.shape = function(parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $body = $('body'),
26
+
27
+ time = new Date().getTime(),
28
+ performance = [],
29
+
30
+ query = arguments[0],
31
+ methodInvoked = (typeof query == 'string'),
32
+ queryArguments = [].slice.call(arguments, 1),
33
+
34
+ requestAnimationFrame = window.requestAnimationFrame
35
+ || window.mozRequestAnimationFrame
36
+ || window.webkitRequestAnimationFrame
37
+ || window.msRequestAnimationFrame
38
+ || function(callback) { setTimeout(callback, 0); },
39
+
40
+ returnedValue
41
+ ;
42
+
43
+ $allModules
44
+ .each(function() {
45
+ var
46
+ moduleSelector = $allModules.selector || '',
47
+ settings = ( $.isPlainObject(parameters) )
48
+ ? $.extend(true, {}, $.fn.shape.settings, parameters)
49
+ : $.extend({}, $.fn.shape.settings),
50
+
51
+ // internal aliases
52
+ namespace = settings.namespace,
53
+ selector = settings.selector,
54
+ error = settings.error,
55
+ className = settings.className,
56
+
57
+ // define namespaces for modules
58
+ eventNamespace = '.' + namespace,
59
+ moduleNamespace = 'module-' + namespace,
60
+
61
+ // selector cache
62
+ $module = $(this),
63
+ $sides = $module.find(selector.sides),
64
+ $side = $module.find(selector.side),
65
+
66
+ // private variables
67
+ nextIndex = false,
68
+ $activeSide,
69
+ $nextSide,
70
+
71
+ // standard module
72
+ element = this,
73
+ instance = $module.data(moduleNamespace),
74
+ module
75
+ ;
76
+
77
+ module = {
78
+
79
+ initialize: function() {
80
+ module.verbose('Initializing module for', element);
81
+ module.set.defaultSide();
82
+ module.instantiate();
83
+ },
84
+
85
+ instantiate: function() {
86
+ module.verbose('Storing instance of module', module);
87
+ instance = module;
88
+ $module
89
+ .data(moduleNamespace, instance)
90
+ ;
91
+ },
92
+
93
+ destroy: function() {
94
+ module.verbose('Destroying previous module for', element);
95
+ $module
96
+ .removeData(moduleNamespace)
97
+ .off(eventNamespace)
98
+ ;
99
+ },
100
+
101
+ refresh: function() {
102
+ module.verbose('Refreshing selector cache for', element);
103
+ $module = $(element);
104
+ $sides = $(this).find(selector.shape);
105
+ $side = $(this).find(selector.side);
106
+ },
107
+
108
+ repaint: function() {
109
+ module.verbose('Forcing repaint event');
110
+ var
111
+ shape = $sides[0] || document.createElement('div'),
112
+ fakeAssignment = shape.offsetWidth
113
+ ;
114
+ },
115
+
116
+ animate: function(propertyObject, callback) {
117
+ module.verbose('Animating box with properties', propertyObject);
118
+ callback = callback || function(event) {
119
+ module.verbose('Executing animation callback');
120
+ if(event !== undefined) {
121
+ event.stopPropagation();
122
+ }
123
+ module.reset();
124
+ module.set.active();
125
+ };
126
+ settings.beforeChange.call($nextSide[0]);
127
+ if(module.get.transitionEvent()) {
128
+ module.verbose('Starting CSS animation');
129
+ $module
130
+ .addClass(className.animating)
131
+ ;
132
+ $sides
133
+ .css(propertyObject)
134
+ .one(module.get.transitionEvent(), callback)
135
+ ;
136
+ module.set.duration(settings.duration);
137
+ requestAnimationFrame(function() {
138
+ $module
139
+ .addClass(className.animating)
140
+ ;
141
+ $activeSide
142
+ .addClass(className.hidden)
143
+ ;
144
+ });
145
+ }
146
+ else {
147
+ callback();
148
+ }
149
+ },
150
+
151
+ queue: function(method) {
152
+ module.debug('Queueing animation of', method);
153
+ $sides
154
+ .one(module.get.transitionEvent(), function() {
155
+ module.debug('Executing queued animation');
156
+ setTimeout(function(){
157
+ $module.shape(method);
158
+ }, 0);
159
+ })
160
+ ;
161
+ },
162
+
163
+ reset: function() {
164
+ module.verbose('Animating states reset');
165
+ $module
166
+ .removeClass(className.animating)
167
+ .attr('style', '')
168
+ .removeAttr('style')
169
+ ;
170
+ // removeAttr style does not consistently work in safari
171
+ $sides
172
+ .attr('style', '')
173
+ .removeAttr('style')
174
+ ;
175
+ $side
176
+ .attr('style', '')
177
+ .removeAttr('style')
178
+ .removeClass(className.hidden)
179
+ ;
180
+ $nextSide
181
+ .removeClass(className.animating)
182
+ .attr('style', '')
183
+ .removeAttr('style')
184
+ ;
185
+ },
186
+
187
+ is: {
188
+ complete: function() {
189
+ return ($side.filter('.' + className.active)[0] == $nextSide[0]);
190
+ },
191
+ animating: function() {
192
+ return $module.hasClass(className.animating);
193
+ }
194
+ },
195
+
196
+ set: {
197
+
198
+ defaultSide: function() {
199
+ $activeSide = $module.find('.' + settings.className.active);
200
+ $nextSide = ( $activeSide.next(selector.side).length > 0 )
201
+ ? $activeSide.next(selector.side)
202
+ : $module.find(selector.side).first()
203
+ ;
204
+ nextIndex = false;
205
+ module.verbose('Active side set to', $activeSide);
206
+ module.verbose('Next side set to', $nextSide);
207
+ },
208
+
209
+ duration: function(duration) {
210
+ duration = duration || settings.duration;
211
+ duration = (typeof duration == 'number')
212
+ ? duration + 'ms'
213
+ : duration
214
+ ;
215
+ module.verbose('Setting animation duration', duration);
216
+ if(settings.duration || settings.duration === 0) {
217
+ $sides.add($side)
218
+ .css({
219
+ '-webkit-transition-duration': duration,
220
+ '-moz-transition-duration': duration,
221
+ '-ms-transition-duration': duration,
222
+ '-o-transition-duration': duration,
223
+ 'transition-duration': duration
224
+ })
225
+ ;
226
+ }
227
+ },
228
+
229
+ currentStageSize: function() {
230
+ var
231
+ $activeSide = $module.find('.' + settings.className.active),
232
+ width = $activeSide.outerWidth(true),
233
+ height = $activeSide.outerHeight(true)
234
+ ;
235
+ $module
236
+ .css({
237
+ width: width,
238
+ height: height
239
+ })
240
+ ;
241
+ },
242
+
243
+ stageSize: function() {
244
+ var
245
+ $clone = $module.clone().addClass(className.loading),
246
+ $activeSide = $clone.find('.' + settings.className.active),
247
+ $nextSide = (nextIndex)
248
+ ? $clone.find(selector.side).eq(nextIndex)
249
+ : ( $activeSide.next(selector.side).length > 0 )
250
+ ? $activeSide.next(selector.side)
251
+ : $clone.find(selector.side).first(),
252
+ newWidth = (settings.width == 'next')
253
+ ? $nextSide.outerWidth(true)
254
+ : (settings.width == 'initial')
255
+ ? $module.width()
256
+ : settings.width,
257
+ newHeight = (settings.height == 'next')
258
+ ? $nextSide.outerHeight(true)
259
+ : (settings.height == 'initial')
260
+ ? $module.height()
261
+ : settings.height
262
+ ;
263
+ $activeSide.removeClass(className.active);
264
+ $nextSide.addClass(className.active);
265
+ $clone.insertAfter($module);
266
+ $clone.remove();
267
+ if(settings.width != 'auto') {
268
+ $module.css('width', newWidth + settings.jitter);
269
+ module.verbose('Specifying width during animation', newWidth);
270
+ }
271
+ if(settings.height != 'auto') {
272
+ $module.css('height', newHeight + settings.jitter);
273
+ module.verbose('Specifying height during animation', newHeight);
274
+ }
275
+ },
276
+
277
+ nextSide: function(selector) {
278
+ nextIndex = selector;
279
+ $nextSide = $side.filter(selector);
280
+ nextIndex = $side.index($nextSide);
281
+ if($nextSide.length === 0) {
282
+ module.set.defaultSide();
283
+ module.error(error.side);
284
+ }
285
+ module.verbose('Next side manually set to', $nextSide);
286
+ },
287
+
288
+ active: function() {
289
+ module.verbose('Setting new side to active', $nextSide);
290
+ $side
291
+ .removeClass(className.active)
292
+ ;
293
+ $nextSide
294
+ .addClass(className.active)
295
+ ;
296
+ settings.onChange.call($nextSide[0]);
297
+ module.set.defaultSide();
298
+ }
299
+ },
300
+
301
+ flip: {
302
+
303
+ up: function() {
304
+ if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
305
+ module.debug('Side already visible', $nextSide);
306
+ return;
307
+ }
308
+ if( !module.is.animating()) {
309
+ module.debug('Flipping up', $nextSide);
310
+ var
311
+ transform = module.get.transform.up()
312
+ ;
313
+ module.set.stageSize();
314
+ module.stage.above();
315
+ module.animate(transform);
316
+ }
317
+ else {
318
+ module.queue('flip up');
319
+ }
320
+ },
321
+
322
+ down: function() {
323
+ if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
324
+ module.debug('Side already visible', $nextSide);
325
+ return;
326
+ }
327
+ if( !module.is.animating()) {
328
+ module.debug('Flipping down', $nextSide);
329
+ var
330
+ transform = module.get.transform.down()
331
+ ;
332
+ module.set.stageSize();
333
+ module.stage.below();
334
+ module.animate(transform);
335
+ }
336
+ else {
337
+ module.queue('flip down');
338
+ }
339
+ },
340
+
341
+ left: function() {
342
+ if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
343
+ module.debug('Side already visible', $nextSide);
344
+ return;
345
+ }
346
+ if( !module.is.animating()) {
347
+ module.debug('Flipping left', $nextSide);
348
+ var
349
+ transform = module.get.transform.left()
350
+ ;
351
+ module.set.stageSize();
352
+ module.stage.left();
353
+ module.animate(transform);
354
+ }
355
+ else {
356
+ module.queue('flip left');
357
+ }
358
+ },
359
+
360
+ right: function() {
361
+ if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
362
+ module.debug('Side already visible', $nextSide);
363
+ return;
364
+ }
365
+ if( !module.is.animating()) {
366
+ module.debug('Flipping right', $nextSide);
367
+ var
368
+ transform = module.get.transform.right()
369
+ ;
370
+ module.set.stageSize();
371
+ module.stage.right();
372
+ module.animate(transform);
373
+ }
374
+ else {
375
+ module.queue('flip right');
376
+ }
377
+ },
378
+
379
+ over: function() {
380
+ if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
381
+ module.debug('Side already visible', $nextSide);
382
+ return;
383
+ }
384
+ if( !module.is.animating()) {
385
+ module.debug('Flipping over', $nextSide);
386
+ module.set.stageSize();
387
+ module.stage.behind();
388
+ module.animate(module.get.transform.over() );
389
+ }
390
+ else {
391
+ module.queue('flip over');
392
+ }
393
+ },
394
+
395
+ back: function() {
396
+ if(module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
397
+ module.debug('Side already visible', $nextSide);
398
+ return;
399
+ }
400
+ if( !module.is.animating()) {
401
+ module.debug('Flipping back', $nextSide);
402
+ module.set.stageSize();
403
+ module.stage.behind();
404
+ module.animate(module.get.transform.back() );
405
+ }
406
+ else {
407
+ module.queue('flip back');
408
+ }
409
+ }
410
+
411
+ },
412
+
413
+ get: {
414
+
415
+ transform: {
416
+ up: function() {
417
+ var
418
+ translate = {
419
+ y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
420
+ z: -($activeSide.outerHeight(true) / 2)
421
+ }
422
+ ;
423
+ return {
424
+ transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(-90deg)'
425
+ };
426
+ },
427
+
428
+ down: function() {
429
+ var
430
+ translate = {
431
+ y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
432
+ z: -($activeSide.outerHeight(true) / 2)
433
+ }
434
+ ;
435
+ return {
436
+ transform: 'translateY(' + translate.y + 'px) translateZ('+ translate.z + 'px) rotateX(90deg)'
437
+ };
438
+ },
439
+
440
+ left: function() {
441
+ var
442
+ translate = {
443
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
444
+ z : -($activeSide.outerWidth(true) / 2)
445
+ }
446
+ ;
447
+ return {
448
+ transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(90deg)'
449
+ };
450
+ },
451
+
452
+ right: function() {
453
+ var
454
+ translate = {
455
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
456
+ z : -($activeSide.outerWidth(true) / 2)
457
+ }
458
+ ;
459
+ return {
460
+ transform: 'translateX(' + translate.x + 'px) translateZ(' + translate.z + 'px) rotateY(-90deg)'
461
+ };
462
+ },
463
+
464
+ over: function() {
465
+ var
466
+ translate = {
467
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2)
468
+ }
469
+ ;
470
+ return {
471
+ transform: 'translateX(' + translate.x + 'px) rotateY(180deg)'
472
+ };
473
+ },
474
+
475
+ back: function() {
476
+ var
477
+ translate = {
478
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2)
479
+ }
480
+ ;
481
+ return {
482
+ transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)'
483
+ };
484
+ }
485
+ },
486
+
487
+ transitionEvent: function() {
488
+ var
489
+ element = document.createElement('element'),
490
+ transitions = {
491
+ 'transition' :'transitionend',
492
+ 'OTransition' :'oTransitionEnd',
493
+ 'MozTransition' :'transitionend',
494
+ 'WebkitTransition' :'webkitTransitionEnd'
495
+ },
496
+ transition
497
+ ;
498
+ for(transition in transitions){
499
+ if( element.style[transition] !== undefined ){
500
+ return transitions[transition];
501
+ }
502
+ }
503
+ },
504
+
505
+ nextSide: function() {
506
+ return ( $activeSide.next(selector.side).length > 0 )
507
+ ? $activeSide.next(selector.side)
508
+ : $module.find(selector.side).first()
509
+ ;
510
+ }
511
+
512
+ },
513
+
514
+ stage: {
515
+
516
+ above: function() {
517
+ var
518
+ box = {
519
+ origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
520
+ depth : {
521
+ active : ($nextSide.outerHeight(true) / 2),
522
+ next : ($activeSide.outerHeight(true) / 2)
523
+ }
524
+ }
525
+ ;
526
+ module.verbose('Setting the initial animation position as above', $nextSide, box);
527
+ $sides
528
+ .css({
529
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
530
+ })
531
+ ;
532
+ $activeSide
533
+ .css({
534
+ 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
535
+ })
536
+ ;
537
+ $nextSide
538
+ .addClass(className.animating)
539
+ .css({
540
+ 'top' : box.origin + 'px',
541
+ 'transform' : 'rotateX(90deg) translateZ(' + box.depth.next + 'px)'
542
+ })
543
+ ;
544
+ },
545
+
546
+ below: function() {
547
+ var
548
+ box = {
549
+ origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
550
+ depth : {
551
+ active : ($nextSide.outerHeight(true) / 2),
552
+ next : ($activeSide.outerHeight(true) / 2)
553
+ }
554
+ }
555
+ ;
556
+ module.verbose('Setting the initial animation position as below', $nextSide, box);
557
+ $sides
558
+ .css({
559
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
560
+ })
561
+ ;
562
+ $activeSide
563
+ .css({
564
+ 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
565
+ })
566
+ ;
567
+ $nextSide
568
+ .addClass(className.animating)
569
+ .css({
570
+ 'top' : box.origin + 'px',
571
+ 'transform' : 'rotateX(-90deg) translateZ(' + box.depth.next + 'px)'
572
+ })
573
+ ;
574
+ },
575
+
576
+ left: function() {
577
+ var
578
+ height = {
579
+ active : $activeSide.outerWidth(true),
580
+ next : $nextSide.outerWidth(true)
581
+ },
582
+ box = {
583
+ origin : ( ( height.active - height.next ) / 2),
584
+ depth : {
585
+ active : (height.next / 2),
586
+ next : (height.active / 2)
587
+ }
588
+ }
589
+ ;
590
+ module.verbose('Setting the initial animation position as left', $nextSide, box);
591
+ $sides
592
+ .css({
593
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
594
+ })
595
+ ;
596
+ $activeSide
597
+ .css({
598
+ 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
599
+ })
600
+ ;
601
+ $nextSide
602
+ .addClass(className.animating)
603
+ .css({
604
+ 'left' : box.origin + 'px',
605
+ 'transform' : 'rotateY(-90deg) translateZ(' + box.depth.next + 'px)'
606
+ })
607
+ ;
608
+ },
609
+
610
+ right: function() {
611
+ var
612
+ height = {
613
+ active : $activeSide.outerWidth(true),
614
+ next : $nextSide.outerWidth(true)
615
+ },
616
+ box = {
617
+ origin : ( ( height.active - height.next ) / 2),
618
+ depth : {
619
+ active : (height.next / 2),
620
+ next : (height.active / 2)
621
+ }
622
+ }
623
+ ;
624
+ module.verbose('Setting the initial animation position as left', $nextSide, box);
625
+ $sides
626
+ .css({
627
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
628
+ })
629
+ ;
630
+ $activeSide
631
+ .css({
632
+ 'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
633
+ })
634
+ ;
635
+ $nextSide
636
+ .addClass(className.animating)
637
+ .css({
638
+ 'left' : box.origin + 'px',
639
+ 'transform' : 'rotateY(90deg) translateZ(' + box.depth.next + 'px)'
640
+ })
641
+ ;
642
+ },
643
+
644
+ behind: function() {
645
+ var
646
+ height = {
647
+ active : $activeSide.outerWidth(true),
648
+ next : $nextSide.outerWidth(true)
649
+ },
650
+ box = {
651
+ origin : ( ( height.active - height.next ) / 2),
652
+ depth : {
653
+ active : (height.next / 2),
654
+ next : (height.active / 2)
655
+ }
656
+ }
657
+ ;
658
+ module.verbose('Setting the initial animation position as behind', $nextSide, box);
659
+ $activeSide
660
+ .css({
661
+ 'transform' : 'rotateY(0deg)'
662
+ })
663
+ ;
664
+ $nextSide
665
+ .addClass(className.animating)
666
+ .css({
667
+ 'left' : box.origin + 'px',
668
+ 'transform' : 'rotateY(-180deg)'
669
+ })
670
+ ;
671
+ }
672
+ },
673
+ setting: function(name, value) {
674
+ module.debug('Changing setting', name, value);
675
+ if( $.isPlainObject(name) ) {
676
+ $.extend(true, settings, name);
677
+ }
678
+ else if(value !== undefined) {
679
+ if($.isPlainObject(settings[name])) {
680
+ $.extend(true, settings[name], value);
681
+ }
682
+ else {
683
+ settings[name] = value;
684
+ }
685
+ }
686
+ else {
687
+ return settings[name];
688
+ }
689
+ },
690
+ internal: function(name, value) {
691
+ if( $.isPlainObject(name) ) {
692
+ $.extend(true, module, name);
693
+ }
694
+ else if(value !== undefined) {
695
+ module[name] = value;
696
+ }
697
+ else {
698
+ return module[name];
699
+ }
700
+ },
701
+ debug: function() {
702
+ if(!settings.silent && settings.debug) {
703
+ if(settings.performance) {
704
+ module.performance.log(arguments);
705
+ }
706
+ else {
707
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
708
+ module.debug.apply(console, arguments);
709
+ }
710
+ }
711
+ },
712
+ verbose: function() {
713
+ if(!settings.silent && settings.verbose && settings.debug) {
714
+ if(settings.performance) {
715
+ module.performance.log(arguments);
716
+ }
717
+ else {
718
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
719
+ module.verbose.apply(console, arguments);
720
+ }
721
+ }
722
+ },
723
+ error: function() {
724
+ if(!settings.silent) {
725
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
726
+ module.error.apply(console, arguments);
727
+ }
728
+ },
729
+ performance: {
730
+ log: function(message) {
731
+ var
732
+ currentTime,
733
+ executionTime,
734
+ previousTime
735
+ ;
736
+ if(settings.performance) {
737
+ currentTime = new Date().getTime();
738
+ previousTime = time || currentTime;
739
+ executionTime = currentTime - previousTime;
740
+ time = currentTime;
741
+ performance.push({
742
+ 'Name' : message[0],
743
+ 'Arguments' : [].slice.call(message, 1) || '',
744
+ 'Element' : element,
745
+ 'Execution Time' : executionTime
746
+ });
747
+ }
748
+ clearTimeout(module.performance.timer);
749
+ module.performance.timer = setTimeout(module.performance.display, 500);
750
+ },
751
+ display: function() {
752
+ var
753
+ title = settings.name + ':',
754
+ totalTime = 0
755
+ ;
756
+ time = false;
757
+ clearTimeout(module.performance.timer);
758
+ $.each(performance, function(index, data) {
759
+ totalTime += data['Execution Time'];
760
+ });
761
+ title += ' ' + totalTime + 'ms';
762
+ if(moduleSelector) {
763
+ title += ' \'' + moduleSelector + '\'';
764
+ }
765
+ if($allModules.length > 1) {
766
+ title += ' ' + '(' + $allModules.length + ')';
767
+ }
768
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
769
+ console.groupCollapsed(title);
770
+ if(console.table) {
771
+ console.table(performance);
772
+ }
773
+ else {
774
+ $.each(performance, function(index, data) {
775
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
776
+ });
777
+ }
778
+ console.groupEnd();
779
+ }
780
+ performance = [];
781
+ }
782
+ },
783
+ invoke: function(query, passedArguments, context) {
784
+ var
785
+ object = instance,
786
+ maxDepth,
787
+ found,
788
+ response
789
+ ;
790
+ passedArguments = passedArguments || queryArguments;
791
+ context = element || context;
792
+ if(typeof query == 'string' && object !== undefined) {
793
+ query = query.split(/[\. ]/);
794
+ maxDepth = query.length - 1;
795
+ $.each(query, function(depth, value) {
796
+ var camelCaseValue = (depth != maxDepth)
797
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
798
+ : query
799
+ ;
800
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
801
+ object = object[camelCaseValue];
802
+ }
803
+ else if( object[camelCaseValue] !== undefined ) {
804
+ found = object[camelCaseValue];
805
+ return false;
806
+ }
807
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
808
+ object = object[value];
809
+ }
810
+ else if( object[value] !== undefined ) {
811
+ found = object[value];
812
+ return false;
813
+ }
814
+ else {
815
+ return false;
816
+ }
817
+ });
818
+ }
819
+ if ( $.isFunction( found ) ) {
820
+ response = found.apply(context, passedArguments);
821
+ }
822
+ else if(found !== undefined) {
823
+ response = found;
824
+ }
825
+ if($.isArray(returnedValue)) {
826
+ returnedValue.push(response);
827
+ }
828
+ else if(returnedValue !== undefined) {
829
+ returnedValue = [returnedValue, response];
830
+ }
831
+ else if(response !== undefined) {
832
+ returnedValue = response;
833
+ }
834
+ return found;
835
+ }
836
+ };
837
+
838
+ if(methodInvoked) {
839
+ if(instance === undefined) {
840
+ module.initialize();
841
+ }
842
+ module.invoke(query);
843
+ }
844
+ else {
845
+ if(instance !== undefined) {
846
+ instance.invoke('destroy');
847
+ }
848
+ module.initialize();
849
+ }
850
+ })
851
+ ;
852
+
853
+ return (returnedValue !== undefined)
854
+ ? returnedValue
855
+ : this
856
+ ;
857
+ };
858
+
859
+ $.fn.shape.settings = {
860
+
861
+ // module info
862
+ name : 'Shape',
863
+
864
+ // hide all debug content
865
+ silent : false,
866
+
867
+ // debug content outputted to console
868
+ debug : false,
869
+
870
+ // verbose debug output
871
+ verbose : false,
872
+
873
+ // fudge factor in pixels when swapping from 2d to 3d (can be useful to correct rounding errors)
874
+ jitter : 0,
875
+
876
+ // performance data output
877
+ performance: true,
878
+
879
+ // event namespace
880
+ namespace : 'shape',
881
+
882
+ // width during animation, can be set to 'auto', initial', 'next' or pixel amount
883
+ width: 'initial',
884
+
885
+ // height during animation, can be set to 'auto', 'initial', 'next' or pixel amount
886
+ height: 'initial',
887
+
888
+ // callback occurs on side change
889
+ beforeChange : function() {},
890
+ onChange : function() {},
891
+
892
+ // allow animation to same side
893
+ allowRepeats: false,
894
+
895
+ // animation duration
896
+ duration : false,
897
+
898
+ // possible errors
899
+ error: {
900
+ side : 'You tried to switch to a side that does not exist.',
901
+ method : 'The method you called is not defined'
902
+ },
903
+
904
+ // classnames used
905
+ className : {
906
+ animating : 'animating',
907
+ hidden : 'hidden',
908
+ loading : 'loading',
909
+ active : 'active'
910
+ },
911
+
912
+ // selectors used
913
+ selector : {
914
+ sides : '.sides',
915
+ side : '.side'
916
+ }
917
+
918
+ };
919
+
920
+
921
+ })( jQuery, window, document );