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,1090 @@
1
+ /*!
2
+ * # Semantic UI - Modal
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.modal = function(parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $window = $(window),
26
+ $document = $(document),
27
+ $body = $('body'),
28
+
29
+ moduleSelector = $allModules.selector || '',
30
+
31
+ time = new Date().getTime(),
32
+ performance = [],
33
+
34
+ query = arguments[0],
35
+ methodInvoked = (typeof query == 'string'),
36
+ queryArguments = [].slice.call(arguments, 1),
37
+
38
+ requestAnimationFrame = window.requestAnimationFrame
39
+ || window.mozRequestAnimationFrame
40
+ || window.webkitRequestAnimationFrame
41
+ || window.msRequestAnimationFrame
42
+ || function(callback) { setTimeout(callback, 0); },
43
+
44
+ returnedValue
45
+ ;
46
+
47
+ $allModules
48
+ .each(function() {
49
+ var
50
+ settings = ( $.isPlainObject(parameters) )
51
+ ? $.extend(true, {}, $.fn.modal.settings, parameters)
52
+ : $.extend({}, $.fn.modal.settings),
53
+
54
+ selector = settings.selector,
55
+ className = settings.className,
56
+ namespace = settings.namespace,
57
+ error = settings.error,
58
+
59
+ eventNamespace = '.' + namespace,
60
+ moduleNamespace = 'module-' + namespace,
61
+
62
+ $module = $(this),
63
+ $context = $(settings.context),
64
+ $close = $module.find(selector.close),
65
+
66
+ $allModals,
67
+ $otherModals,
68
+ $focusedElement,
69
+ $dimmable,
70
+ $dimmer,
71
+
72
+ element = this,
73
+ instance = $module.data(moduleNamespace),
74
+
75
+ ignoreRepeatedEvents = false,
76
+
77
+ initialMouseDownInModal,
78
+
79
+ elementEventNamespace,
80
+ id,
81
+ observer,
82
+ module
83
+ ;
84
+ module = {
85
+
86
+ initialize: function() {
87
+ module.verbose('Initializing dimmer', $context);
88
+
89
+ module.create.id();
90
+ module.create.dimmer();
91
+
92
+ if ( settings.allowMultiple ) {
93
+ module.create.innerDimmer();
94
+ }
95
+
96
+ module.refreshModals();
97
+
98
+ module.bind.events();
99
+ if(settings.observeChanges) {
100
+ module.observeChanges();
101
+ }
102
+ module.instantiate();
103
+ },
104
+
105
+ instantiate: function() {
106
+ module.verbose('Storing instance of modal');
107
+ instance = module;
108
+ $module
109
+ .data(moduleNamespace, instance)
110
+ ;
111
+ },
112
+
113
+ create: {
114
+ dimmer: function() {
115
+ var
116
+ defaultSettings = {
117
+ debug : settings.debug,
118
+ variation : settings.centered
119
+ ? false
120
+ : 'top aligned',
121
+ dimmerName : 'modals'
122
+ },
123
+ dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
124
+ ;
125
+ if($.fn.dimmer === undefined) {
126
+ module.error(error.dimmer);
127
+ return;
128
+ }
129
+ module.debug('Creating dimmer');
130
+ $dimmable = $context.dimmer(dimmerSettings);
131
+ if(settings.detachable) {
132
+ module.verbose('Modal is detachable, moving content into dimmer');
133
+ $dimmable.dimmer('add content', $module);
134
+ }
135
+ else {
136
+ module.set.undetached();
137
+ }
138
+ $dimmer = $dimmable.dimmer('get dimmer');
139
+ },
140
+ id: function() {
141
+ id = (Math.random().toString(16) + '000000000').substr(2, 8);
142
+ elementEventNamespace = '.' + id;
143
+ module.verbose('Creating unique id for element', id);
144
+ },
145
+ innerDimmer: function() {
146
+ if ( $module.find(selector.dimmer).length == 0 ) {
147
+ $module.prepend('<div class="ui inverted dimmer"></div>');
148
+ }
149
+ }
150
+ },
151
+
152
+ destroy: function() {
153
+ module.verbose('Destroying previous modal');
154
+ $module
155
+ .removeData(moduleNamespace)
156
+ .off(eventNamespace)
157
+ ;
158
+ $window.off(elementEventNamespace);
159
+ $dimmer.off(elementEventNamespace);
160
+ $close.off(eventNamespace);
161
+ $context.dimmer('destroy');
162
+ },
163
+
164
+ observeChanges: function() {
165
+ if('MutationObserver' in window) {
166
+ observer = new MutationObserver(function(mutations) {
167
+ module.debug('DOM tree modified, refreshing');
168
+ module.refresh();
169
+ });
170
+ observer.observe(element, {
171
+ childList : true,
172
+ subtree : true
173
+ });
174
+ module.debug('Setting up mutation observer', observer);
175
+ }
176
+ },
177
+
178
+ refresh: function() {
179
+ module.remove.scrolling();
180
+ module.cacheSizes();
181
+ if(!module.can.useFlex()) {
182
+ module.set.modalOffset();
183
+ }
184
+ module.set.screenHeight();
185
+ module.set.type();
186
+ },
187
+
188
+ refreshModals: function() {
189
+ $otherModals = $module.siblings(selector.modal);
190
+ $allModals = $otherModals.add($module);
191
+ },
192
+
193
+ attachEvents: function(selector, event) {
194
+ var
195
+ $toggle = $(selector)
196
+ ;
197
+ event = $.isFunction(module[event])
198
+ ? module[event]
199
+ : module.toggle
200
+ ;
201
+ if($toggle.length > 0) {
202
+ module.debug('Attaching modal events to element', selector, event);
203
+ $toggle
204
+ .off(eventNamespace)
205
+ .on('click' + eventNamespace, event)
206
+ ;
207
+ }
208
+ else {
209
+ module.error(error.notFound, selector);
210
+ }
211
+ },
212
+
213
+ bind: {
214
+ events: function() {
215
+ module.verbose('Attaching events');
216
+ $module
217
+ .on('click' + eventNamespace, selector.close, module.event.close)
218
+ .on('click' + eventNamespace, selector.approve, module.event.approve)
219
+ .on('click' + eventNamespace, selector.deny, module.event.deny)
220
+ ;
221
+ $window
222
+ .on('resize' + elementEventNamespace, module.event.resize)
223
+ ;
224
+ },
225
+ scrollLock: function() {
226
+ // touch events default to passive, due to changes in chrome to optimize mobile perf
227
+ $dimmable.get(0).addEventListener('touchmove', module.event.preventScroll, { passive: false });
228
+ }
229
+ },
230
+
231
+ unbind: {
232
+ scrollLock: function() {
233
+ $dimmable.get(0).removeEventListener('touchmove', module.event.preventScroll, { passive: false });
234
+ }
235
+ },
236
+
237
+ get: {
238
+ id: function() {
239
+ return (Math.random().toString(16) + '000000000').substr(2, 8);
240
+ }
241
+ },
242
+
243
+ event: {
244
+ approve: function() {
245
+ if(ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) {
246
+ module.verbose('Approve callback returned false cancelling hide');
247
+ return;
248
+ }
249
+ ignoreRepeatedEvents = true;
250
+ module.hide(function() {
251
+ ignoreRepeatedEvents = false;
252
+ });
253
+ },
254
+ preventScroll: function(event) {
255
+ event.preventDefault();
256
+ },
257
+ deny: function() {
258
+ if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) {
259
+ module.verbose('Deny callback returned false cancelling hide');
260
+ return;
261
+ }
262
+ ignoreRepeatedEvents = true;
263
+ module.hide(function() {
264
+ ignoreRepeatedEvents = false;
265
+ });
266
+ },
267
+ close: function() {
268
+ module.hide();
269
+ },
270
+ mousedown: function(event) {
271
+ var
272
+ $target = $(event.target)
273
+ ;
274
+ initialMouseDownInModal = ($target.closest(selector.modal).length > 0);
275
+ if(initialMouseDownInModal) {
276
+ module.verbose('Mouse down event registered inside the modal');
277
+ }
278
+ },
279
+ mouseup: function(event) {
280
+ if(!settings.closable) {
281
+ module.verbose('Dimmer clicked but closable setting is disabled');
282
+ return;
283
+ }
284
+ if(initialMouseDownInModal) {
285
+ module.debug('Dimmer clicked but mouse down was initially registered inside the modal');
286
+ return;
287
+ }
288
+ var
289
+ $target = $(event.target),
290
+ isInModal = ($target.closest(selector.modal).length > 0),
291
+ isInDOM = $.contains(document.documentElement, event.target)
292
+ ;
293
+ if(!isInModal && isInDOM && module.is.active()) {
294
+ module.debug('Dimmer clicked, hiding all modals');
295
+ module.remove.clickaway();
296
+ if(settings.allowMultiple) {
297
+ module.hideAll();
298
+ }
299
+ else {
300
+ module.hide();
301
+ }
302
+ }
303
+ },
304
+ debounce: function(method, delay) {
305
+ clearTimeout(module.timer);
306
+ module.timer = setTimeout(method, delay);
307
+ },
308
+ keyboard: function(event) {
309
+ var
310
+ keyCode = event.which,
311
+ escapeKey = 27
312
+ ;
313
+ if(keyCode == escapeKey) {
314
+ if(settings.closable) {
315
+ module.debug('Escape key pressed hiding modal');
316
+ if ( $module.hasClass(className.top) ) {
317
+ module.hide();
318
+ }
319
+ }
320
+ else {
321
+ module.debug('Escape key pressed, but closable is set to false');
322
+ }
323
+ event.preventDefault();
324
+ }
325
+ },
326
+ resize: function() {
327
+ if( $dimmable.dimmer('is active') && ( module.is.animating() || module.is.active() ) ) {
328
+ requestAnimationFrame(module.refresh);
329
+ }
330
+ }
331
+ },
332
+
333
+ toggle: function() {
334
+ if( module.is.active() || module.is.animating() ) {
335
+ module.hide();
336
+ }
337
+ else {
338
+ module.show();
339
+ }
340
+ },
341
+
342
+ show: function(callback) {
343
+ callback = $.isFunction(callback)
344
+ ? callback
345
+ : function(){}
346
+ ;
347
+ module.refreshModals();
348
+ module.set.dimmerSettings();
349
+ module.set.dimmerStyles();
350
+
351
+ module.showModal(callback);
352
+ },
353
+
354
+ hide: function(callback) {
355
+ callback = $.isFunction(callback)
356
+ ? callback
357
+ : function(){}
358
+ ;
359
+ module.refreshModals();
360
+ module.hideModal(callback);
361
+ },
362
+
363
+ showModal: function(callback) {
364
+ callback = $.isFunction(callback)
365
+ ? callback
366
+ : function(){}
367
+ ;
368
+ if( module.is.animating() || !module.is.active() ) {
369
+ module.showDimmer();
370
+ module.cacheSizes();
371
+ if(module.can.useFlex()) {
372
+ module.remove.legacy();
373
+ }
374
+ else {
375
+ module.set.legacy();
376
+ module.set.modalOffset();
377
+ module.debug('Using non-flex legacy modal positioning.');
378
+ }
379
+ module.set.screenHeight();
380
+ module.set.type();
381
+ module.set.clickaway();
382
+
383
+ if( !settings.allowMultiple && module.others.active() ) {
384
+ module.hideOthers(module.showModal);
385
+ }
386
+ else {
387
+ if( settings.allowMultiple ) {
388
+ if ( module.others.active() ) {
389
+ $otherModals.filter('.' + className.active).find(selector.dimmer).addClass('active')
390
+ }
391
+
392
+ if ( settings.detachable ) {
393
+ $module.detach().appendTo($dimmer);
394
+ }
395
+ }
396
+ settings.onShow.call(element);
397
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
398
+ module.debug('Showing modal with css animations');
399
+ $module
400
+ .transition({
401
+ debug : settings.debug,
402
+ animation : settings.transition + ' in',
403
+ queue : settings.queue,
404
+ duration : settings.duration,
405
+ useFailSafe : true,
406
+ onComplete : function() {
407
+ settings.onVisible.apply(element);
408
+ if(settings.keyboardShortcuts) {
409
+ module.add.keyboardShortcuts();
410
+ }
411
+ module.save.focus();
412
+ module.set.active();
413
+ if(settings.autofocus) {
414
+ module.set.autofocus();
415
+ }
416
+ callback();
417
+ }
418
+ })
419
+ ;
420
+ }
421
+ else {
422
+ module.error(error.noTransition);
423
+ }
424
+ }
425
+ }
426
+ else {
427
+ module.debug('Modal is already visible');
428
+ }
429
+ },
430
+
431
+ hideModal: function(callback, keepDimmed, hideOthersToo) {
432
+ var
433
+ $previousModal = $otherModals.filter('.' + className.active).last()
434
+ ;
435
+ callback = $.isFunction(callback)
436
+ ? callback
437
+ : function(){}
438
+ ;
439
+ module.debug('Hiding modal');
440
+ if(settings.onHide.call(element, $(this)) === false) {
441
+ module.verbose('Hide callback returned false cancelling hide');
442
+ return;
443
+ }
444
+
445
+ if( module.is.animating() || module.is.active() ) {
446
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
447
+ module.remove.active();
448
+ $module
449
+ .transition({
450
+ debug : settings.debug,
451
+ animation : settings.transition + ' out',
452
+ queue : settings.queue,
453
+ duration : settings.duration,
454
+ useFailSafe : true,
455
+ onStart : function() {
456
+ if(!module.others.active() && !keepDimmed) {
457
+ module.hideDimmer();
458
+ }
459
+ if( settings.keyboardShortcuts && !module.others.active() ) {
460
+ module.remove.keyboardShortcuts();
461
+ }
462
+ },
463
+ onComplete : function() {
464
+ if ( settings.allowMultiple ) {
465
+ $previousModal.addClass(className.top);
466
+ $module.removeClass(className.top);
467
+
468
+ if ( hideOthersToo ) {
469
+ $allModals.find(selector.dimmer).removeClass('active')
470
+ }
471
+ else {
472
+ $previousModal.find(selector.dimmer).removeClass('active')
473
+ }
474
+ }
475
+ settings.onHidden.call(element);
476
+ module.remove.dimmerStyles();
477
+ module.restore.focus();
478
+ callback();
479
+ }
480
+ })
481
+ ;
482
+ }
483
+ else {
484
+ module.error(error.noTransition);
485
+ }
486
+ }
487
+ },
488
+
489
+ showDimmer: function() {
490
+ if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) {
491
+ module.debug('Showing dimmer');
492
+ $dimmable.dimmer('show');
493
+ }
494
+ else {
495
+ module.debug('Dimmer already visible');
496
+ }
497
+ },
498
+
499
+ hideDimmer: function() {
500
+ if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) {
501
+ module.unbind.scrollLock();
502
+ $dimmable.dimmer('hide', function() {
503
+ module.remove.clickaway();
504
+ module.remove.screenHeight();
505
+ });
506
+ }
507
+ else {
508
+ module.debug('Dimmer is not visible cannot hide');
509
+ return;
510
+ }
511
+ },
512
+
513
+ hideAll: function(callback) {
514
+ var
515
+ $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
516
+ ;
517
+ callback = $.isFunction(callback)
518
+ ? callback
519
+ : function(){}
520
+ ;
521
+ if( $visibleModals.length > 0 ) {
522
+ module.debug('Hiding all visible modals');
523
+ module.hideDimmer();
524
+ $visibleModals
525
+ .modal('hide modal', callback, false, true)
526
+ ;
527
+ }
528
+ },
529
+
530
+ hideOthers: function(callback) {
531
+ var
532
+ $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
533
+ ;
534
+ callback = $.isFunction(callback)
535
+ ? callback
536
+ : function(){}
537
+ ;
538
+ if( $visibleModals.length > 0 ) {
539
+ module.debug('Hiding other modals', $otherModals);
540
+ $visibleModals
541
+ .modal('hide modal', callback, true)
542
+ ;
543
+ }
544
+ },
545
+
546
+ others: {
547
+ active: function() {
548
+ return ($otherModals.filter('.' + className.active).length > 0);
549
+ },
550
+ animating: function() {
551
+ return ($otherModals.filter('.' + className.animating).length > 0);
552
+ }
553
+ },
554
+
555
+
556
+ add: {
557
+ keyboardShortcuts: function() {
558
+ module.verbose('Adding keyboard shortcuts');
559
+ $document
560
+ .on('keyup' + eventNamespace, module.event.keyboard)
561
+ ;
562
+ }
563
+ },
564
+
565
+ save: {
566
+ focus: function() {
567
+ var
568
+ $activeElement = $(document.activeElement),
569
+ inCurrentModal = $activeElement.closest($module).length > 0
570
+ ;
571
+ if(!inCurrentModal) {
572
+ $focusedElement = $(document.activeElement).blur();
573
+ }
574
+ }
575
+ },
576
+
577
+ restore: {
578
+ focus: function() {
579
+ if($focusedElement && $focusedElement.length > 0) {
580
+ $focusedElement.focus();
581
+ }
582
+ }
583
+ },
584
+
585
+ remove: {
586
+ active: function() {
587
+ $module.removeClass(className.active);
588
+ },
589
+ legacy: function() {
590
+ $module.removeClass(className.legacy);
591
+ },
592
+ clickaway: function() {
593
+ $dimmer
594
+ .off('mousedown' + elementEventNamespace)
595
+ ;
596
+ $dimmer
597
+ .off('mouseup' + elementEventNamespace)
598
+ ;
599
+ },
600
+ dimmerStyles: function() {
601
+ $dimmer.removeClass(className.inverted);
602
+ $dimmable.removeClass(className.blurring);
603
+ },
604
+ bodyStyle: function() {
605
+ if($body.attr('style') === '') {
606
+ module.verbose('Removing style attribute');
607
+ $body.removeAttr('style');
608
+ }
609
+ },
610
+ screenHeight: function() {
611
+ module.debug('Removing page height');
612
+ $body
613
+ .css('height', '')
614
+ ;
615
+ },
616
+ keyboardShortcuts: function() {
617
+ module.verbose('Removing keyboard shortcuts');
618
+ $document
619
+ .off('keyup' + eventNamespace)
620
+ ;
621
+ },
622
+ scrolling: function() {
623
+ $dimmable.removeClass(className.scrolling);
624
+ $module.removeClass(className.scrolling);
625
+ }
626
+ },
627
+
628
+ cacheSizes: function() {
629
+ $module.addClass(className.loading);
630
+ var
631
+ scrollHeight = $module.prop('scrollHeight'),
632
+ modalWidth = $module.outerWidth(),
633
+ modalHeight = $module.outerHeight()
634
+ ;
635
+ if(module.cache === undefined || modalHeight !== 0) {
636
+ module.cache = {
637
+ pageHeight : $(document).outerHeight(),
638
+ width : modalWidth,
639
+ height : modalHeight + settings.offset,
640
+ scrollHeight : scrollHeight + settings.offset,
641
+ contextHeight : (settings.context == 'body')
642
+ ? $(window).height()
643
+ : $dimmable.height(),
644
+ };
645
+ module.cache.topOffset = -(module.cache.height / 2);
646
+ }
647
+ $module.removeClass(className.loading);
648
+ module.debug('Caching modal and container sizes', module.cache);
649
+ },
650
+
651
+ can: {
652
+ useFlex: function() {
653
+ return (settings.useFlex == 'auto')
654
+ ? settings.detachable && !module.is.ie()
655
+ : settings.useFlex
656
+ ;
657
+ },
658
+ fit: function() {
659
+ var
660
+ contextHeight = module.cache.contextHeight,
661
+ verticalCenter = module.cache.contextHeight / 2,
662
+ topOffset = module.cache.topOffset,
663
+ scrollHeight = module.cache.scrollHeight,
664
+ height = module.cache.height,
665
+ paddingHeight = settings.padding,
666
+ startPosition = (verticalCenter + topOffset)
667
+ ;
668
+ return (scrollHeight > height)
669
+ ? (startPosition + scrollHeight + paddingHeight < contextHeight)
670
+ : (height + (paddingHeight * 2) < contextHeight)
671
+ ;
672
+ }
673
+ },
674
+
675
+ is: {
676
+ active: function() {
677
+ return $module.hasClass(className.active);
678
+ },
679
+ ie: function() {
680
+ var
681
+ isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
682
+ isIE = ('ActiveXObject' in window)
683
+ ;
684
+ return (isIE11 || isIE);
685
+ },
686
+ animating: function() {
687
+ return $module.transition('is supported')
688
+ ? $module.transition('is animating')
689
+ : $module.is(':visible')
690
+ ;
691
+ },
692
+ scrolling: function() {
693
+ return $dimmable.hasClass(className.scrolling);
694
+ },
695
+ modernBrowser: function() {
696
+ // appName for IE11 reports 'Netscape' can no longer use
697
+ return !(window.ActiveXObject || 'ActiveXObject' in window);
698
+ }
699
+ },
700
+
701
+ set: {
702
+ autofocus: function() {
703
+ var
704
+ $inputs = $module.find('[tabindex], :input').filter(':visible'),
705
+ $autofocus = $inputs.filter('[autofocus]'),
706
+ $input = ($autofocus.length > 0)
707
+ ? $autofocus.first()
708
+ : $inputs.first()
709
+ ;
710
+ if($input.length > 0) {
711
+ $input.focus();
712
+ }
713
+ },
714
+ clickaway: function() {
715
+ $dimmer
716
+ .on('mousedown' + elementEventNamespace, module.event.mousedown)
717
+ ;
718
+ $dimmer
719
+ .on('mouseup' + elementEventNamespace, module.event.mouseup)
720
+ ;
721
+ },
722
+ dimmerSettings: function() {
723
+ if($.fn.dimmer === undefined) {
724
+ module.error(error.dimmer);
725
+ return;
726
+ }
727
+ var
728
+ defaultSettings = {
729
+ debug : settings.debug,
730
+ dimmerName : 'modals',
731
+ closable : 'auto',
732
+ useFlex : module.can.useFlex(),
733
+ variation : settings.centered
734
+ ? false
735
+ : 'top aligned',
736
+ duration : {
737
+ show : settings.duration,
738
+ hide : settings.duration
739
+ }
740
+ },
741
+ dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
742
+ ;
743
+ if(settings.inverted) {
744
+ dimmerSettings.variation = (dimmerSettings.variation !== undefined)
745
+ ? dimmerSettings.variation + ' inverted'
746
+ : 'inverted'
747
+ ;
748
+ }
749
+ $context.dimmer('setting', dimmerSettings);
750
+ },
751
+ dimmerStyles: function() {
752
+ if(settings.inverted) {
753
+ $dimmer.addClass(className.inverted);
754
+ }
755
+ else {
756
+ $dimmer.removeClass(className.inverted);
757
+ }
758
+ if(settings.blurring) {
759
+ $dimmable.addClass(className.blurring);
760
+ }
761
+ else {
762
+ $dimmable.removeClass(className.blurring);
763
+ }
764
+ },
765
+ modalOffset: function() {
766
+ var
767
+ width = module.cache.width,
768
+ height = module.cache.height
769
+ ;
770
+ $module
771
+ .css({
772
+ marginTop: (settings.centered && module.can.fit())
773
+ ? -(height / 2)
774
+ : 0,
775
+ marginLeft: -(width / 2)
776
+ })
777
+ ;
778
+ module.verbose('Setting modal offset for legacy mode');
779
+ },
780
+ screenHeight: function() {
781
+ if( module.can.fit() ) {
782
+ $body.css('height', '');
783
+ }
784
+ else {
785
+ module.debug('Modal is taller than page content, resizing page height');
786
+ $body
787
+ .css('height', module.cache.height + (settings.padding * 2) )
788
+ ;
789
+ }
790
+ },
791
+ active: function() {
792
+ $module.addClass(className.active + ' ' + className.top);
793
+ $otherModals.filter('.' + className.active).removeClass(className.top)
794
+ },
795
+ scrolling: function() {
796
+ $dimmable.addClass(className.scrolling);
797
+ $module.addClass(className.scrolling);
798
+ module.unbind.scrollLock();
799
+ },
800
+ legacy: function() {
801
+ $module.addClass(className.legacy);
802
+ },
803
+ type: function() {
804
+ if(module.can.fit()) {
805
+ module.verbose('Modal fits on screen');
806
+ if(!module.others.active() && !module.others.animating()) {
807
+ module.remove.scrolling();
808
+ module.bind.scrollLock();
809
+ }
810
+ }
811
+ else {
812
+ module.verbose('Modal cannot fit on screen setting to scrolling');
813
+ module.set.scrolling();
814
+ }
815
+ },
816
+ undetached: function() {
817
+ $dimmable.addClass(className.undetached);
818
+ }
819
+ },
820
+
821
+ setting: function(name, value) {
822
+ module.debug('Changing setting', name, value);
823
+ if( $.isPlainObject(name) ) {
824
+ $.extend(true, settings, name);
825
+ }
826
+ else if(value !== undefined) {
827
+ if($.isPlainObject(settings[name])) {
828
+ $.extend(true, settings[name], value);
829
+ }
830
+ else {
831
+ settings[name] = value;
832
+ }
833
+ }
834
+ else {
835
+ return settings[name];
836
+ }
837
+ },
838
+ internal: function(name, value) {
839
+ if( $.isPlainObject(name) ) {
840
+ $.extend(true, module, name);
841
+ }
842
+ else if(value !== undefined) {
843
+ module[name] = value;
844
+ }
845
+ else {
846
+ return module[name];
847
+ }
848
+ },
849
+ debug: function() {
850
+ if(!settings.silent && settings.debug) {
851
+ if(settings.performance) {
852
+ module.performance.log(arguments);
853
+ }
854
+ else {
855
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
856
+ module.debug.apply(console, arguments);
857
+ }
858
+ }
859
+ },
860
+ verbose: function() {
861
+ if(!settings.silent && settings.verbose && settings.debug) {
862
+ if(settings.performance) {
863
+ module.performance.log(arguments);
864
+ }
865
+ else {
866
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
867
+ module.verbose.apply(console, arguments);
868
+ }
869
+ }
870
+ },
871
+ error: function() {
872
+ if(!settings.silent) {
873
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
874
+ module.error.apply(console, arguments);
875
+ }
876
+ },
877
+ performance: {
878
+ log: function(message) {
879
+ var
880
+ currentTime,
881
+ executionTime,
882
+ previousTime
883
+ ;
884
+ if(settings.performance) {
885
+ currentTime = new Date().getTime();
886
+ previousTime = time || currentTime;
887
+ executionTime = currentTime - previousTime;
888
+ time = currentTime;
889
+ performance.push({
890
+ 'Name' : message[0],
891
+ 'Arguments' : [].slice.call(message, 1) || '',
892
+ 'Element' : element,
893
+ 'Execution Time' : executionTime
894
+ });
895
+ }
896
+ clearTimeout(module.performance.timer);
897
+ module.performance.timer = setTimeout(module.performance.display, 500);
898
+ },
899
+ display: function() {
900
+ var
901
+ title = settings.name + ':',
902
+ totalTime = 0
903
+ ;
904
+ time = false;
905
+ clearTimeout(module.performance.timer);
906
+ $.each(performance, function(index, data) {
907
+ totalTime += data['Execution Time'];
908
+ });
909
+ title += ' ' + totalTime + 'ms';
910
+ if(moduleSelector) {
911
+ title += ' \'' + moduleSelector + '\'';
912
+ }
913
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
914
+ console.groupCollapsed(title);
915
+ if(console.table) {
916
+ console.table(performance);
917
+ }
918
+ else {
919
+ $.each(performance, function(index, data) {
920
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
921
+ });
922
+ }
923
+ console.groupEnd();
924
+ }
925
+ performance = [];
926
+ }
927
+ },
928
+ invoke: function(query, passedArguments, context) {
929
+ var
930
+ object = instance,
931
+ maxDepth,
932
+ found,
933
+ response
934
+ ;
935
+ passedArguments = passedArguments || queryArguments;
936
+ context = element || context;
937
+ if(typeof query == 'string' && object !== undefined) {
938
+ query = query.split(/[\. ]/);
939
+ maxDepth = query.length - 1;
940
+ $.each(query, function(depth, value) {
941
+ var camelCaseValue = (depth != maxDepth)
942
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
943
+ : query
944
+ ;
945
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
946
+ object = object[camelCaseValue];
947
+ }
948
+ else if( object[camelCaseValue] !== undefined ) {
949
+ found = object[camelCaseValue];
950
+ return false;
951
+ }
952
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
953
+ object = object[value];
954
+ }
955
+ else if( object[value] !== undefined ) {
956
+ found = object[value];
957
+ return false;
958
+ }
959
+ else {
960
+ return false;
961
+ }
962
+ });
963
+ }
964
+ if ( $.isFunction( found ) ) {
965
+ response = found.apply(context, passedArguments);
966
+ }
967
+ else if(found !== undefined) {
968
+ response = found;
969
+ }
970
+ if($.isArray(returnedValue)) {
971
+ returnedValue.push(response);
972
+ }
973
+ else if(returnedValue !== undefined) {
974
+ returnedValue = [returnedValue, response];
975
+ }
976
+ else if(response !== undefined) {
977
+ returnedValue = response;
978
+ }
979
+ return found;
980
+ }
981
+ };
982
+
983
+ if(methodInvoked) {
984
+ if(instance === undefined) {
985
+ module.initialize();
986
+ }
987
+ module.invoke(query);
988
+ }
989
+ else {
990
+ if(instance !== undefined) {
991
+ instance.invoke('destroy');
992
+ }
993
+ module.initialize();
994
+ }
995
+ })
996
+ ;
997
+
998
+ return (returnedValue !== undefined)
999
+ ? returnedValue
1000
+ : this
1001
+ ;
1002
+ };
1003
+
1004
+ $.fn.modal.settings = {
1005
+
1006
+ name : 'Modal',
1007
+ namespace : 'modal',
1008
+
1009
+ useFlex : 'auto',
1010
+ offset : 0,
1011
+
1012
+ silent : false,
1013
+ debug : false,
1014
+ verbose : false,
1015
+ performance : true,
1016
+
1017
+ observeChanges : false,
1018
+
1019
+ allowMultiple : false,
1020
+ detachable : true,
1021
+ closable : true,
1022
+ autofocus : true,
1023
+
1024
+ inverted : false,
1025
+ blurring : false,
1026
+
1027
+ centered : true,
1028
+
1029
+ dimmerSettings : {
1030
+ closable : false,
1031
+ useCSS : true
1032
+ },
1033
+
1034
+ // whether to use keyboard shortcuts
1035
+ keyboardShortcuts: true,
1036
+
1037
+ context : 'body',
1038
+
1039
+ queue : false,
1040
+ duration : 500,
1041
+ transition : 'scale',
1042
+
1043
+ // padding with edge of page
1044
+ padding : 50,
1045
+
1046
+ // called before show animation
1047
+ onShow : function(){},
1048
+
1049
+ // called after show animation
1050
+ onVisible : function(){},
1051
+
1052
+ // called before hide animation
1053
+ onHide : function(){ return true; },
1054
+
1055
+ // called after hide animation
1056
+ onHidden : function(){},
1057
+
1058
+ // called after approve selector match
1059
+ onApprove : function(){ return true; },
1060
+
1061
+ // called after deny selector match
1062
+ onDeny : function(){ return true; },
1063
+
1064
+ selector : {
1065
+ close : '> .close',
1066
+ approve : '.actions .positive, .actions .approve, .actions .ok',
1067
+ deny : '.actions .negative, .actions .deny, .actions .cancel',
1068
+ modal : '.ui.modal',
1069
+ dimmer : '> .ui.dimmer'
1070
+ },
1071
+ error : {
1072
+ dimmer : 'UI Dimmer, a required component is not included in this page',
1073
+ method : 'The method you called is not defined.',
1074
+ notFound : 'The element you specified could not be found'
1075
+ },
1076
+ className : {
1077
+ active : 'active',
1078
+ animating : 'animating',
1079
+ blurring : 'blurring',
1080
+ inverted : 'inverted',
1081
+ legacy : 'legacy',
1082
+ loading : 'loading',
1083
+ scrolling : 'scrolling',
1084
+ undetached : 'undetached',
1085
+ top : 'top'
1086
+ }
1087
+ };
1088
+
1089
+
1090
+ })( jQuery, window, document );