less-rails-semantic_ui 1.12.3.0 → 2.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/assets/javascripts/semantic_ui/definitions/behaviors/api.js +394 -188
  3. data/assets/javascripts/semantic_ui/definitions/behaviors/colorize.js +4 -2
  4. data/assets/javascripts/semantic_ui/definitions/behaviors/form.js +263 -125
  5. data/assets/javascripts/semantic_ui/definitions/behaviors/state.js +3 -3
  6. data/assets/javascripts/semantic_ui/definitions/behaviors/visibility.js +213 -96
  7. data/assets/javascripts/semantic_ui/definitions/behaviors/visit.js +6 -4
  8. data/assets/javascripts/semantic_ui/definitions/globals/site.js +4 -4
  9. data/assets/javascripts/semantic_ui/definitions/modules/accordion.js +66 -52
  10. data/assets/javascripts/semantic_ui/definitions/modules/checkbox.js +309 -112
  11. data/assets/javascripts/semantic_ui/definitions/modules/dimmer.js +24 -26
  12. data/assets/javascripts/semantic_ui/definitions/modules/dropdown.js +2005 -590
  13. data/assets/javascripts/semantic_ui/definitions/modules/embed.js +662 -0
  14. data/assets/javascripts/semantic_ui/definitions/modules/modal.js +106 -79
  15. data/assets/javascripts/semantic_ui/definitions/modules/nag.js +7 -8
  16. data/assets/javascripts/semantic_ui/definitions/modules/popup.js +323 -194
  17. data/assets/javascripts/semantic_ui/definitions/modules/progress.js +111 -103
  18. data/assets/javascripts/semantic_ui/definitions/modules/rating.js +78 -54
  19. data/assets/javascripts/semantic_ui/definitions/modules/search.js +304 -122
  20. data/assets/javascripts/semantic_ui/definitions/modules/shape.js +93 -47
  21. data/assets/javascripts/semantic_ui/definitions/modules/sidebar.js +83 -149
  22. data/assets/javascripts/semantic_ui/definitions/modules/sticky.js +99 -29
  23. data/assets/javascripts/semantic_ui/definitions/modules/tab.js +219 -124
  24. data/assets/javascripts/semantic_ui/definitions/modules/transition.js +202 -171
  25. data/assets/stylesheets/semantic_ui/definitions/collections/breadcrumb.less +2 -1
  26. data/assets/stylesheets/semantic_ui/definitions/collections/form.less +135 -58
  27. data/assets/stylesheets/semantic_ui/definitions/collections/grid.less +366 -383
  28. data/assets/stylesheets/semantic_ui/definitions/collections/menu.less +838 -631
  29. data/assets/stylesheets/semantic_ui/definitions/collections/message.less +89 -71
  30. data/assets/stylesheets/semantic_ui/definitions/collections/table.less +183 -131
  31. data/assets/stylesheets/semantic_ui/definitions/elements/button.less +1097 -300
  32. data/assets/stylesheets/semantic_ui/definitions/elements/container.less +135 -0
  33. data/assets/stylesheets/semantic_ui/definitions/elements/divider.less +31 -30
  34. data/assets/stylesheets/semantic_ui/definitions/elements/flag.less +1 -1
  35. data/assets/stylesheets/semantic_ui/definitions/elements/header.less +209 -121
  36. data/assets/stylesheets/semantic_ui/definitions/elements/icon.less +201 -96
  37. data/assets/stylesheets/semantic_ui/definitions/elements/image.less +26 -11
  38. data/assets/stylesheets/semantic_ui/definitions/elements/input.less +49 -14
  39. data/assets/stylesheets/semantic_ui/definitions/elements/label.less +391 -221
  40. data/assets/stylesheets/semantic_ui/definitions/elements/list.less +107 -68
  41. data/assets/stylesheets/semantic_ui/definitions/elements/loader.less +3 -1
  42. data/assets/stylesheets/semantic_ui/definitions/elements/rail.less +34 -25
  43. data/assets/stylesheets/semantic_ui/definitions/elements/reveal.less +25 -10
  44. data/assets/stylesheets/semantic_ui/definitions/elements/segment.less +261 -173
  45. data/assets/stylesheets/semantic_ui/definitions/elements/step.less +169 -70
  46. data/assets/stylesheets/semantic_ui/definitions/globals/reset.less +1 -1
  47. data/assets/stylesheets/semantic_ui/definitions/globals/site.less +3 -1
  48. data/assets/stylesheets/semantic_ui/definitions/modules/accordion.less +1 -2
  49. data/assets/stylesheets/semantic_ui/definitions/modules/checkbox.less +175 -103
  50. data/assets/stylesheets/semantic_ui/definitions/modules/dimmer.less +26 -15
  51. data/assets/stylesheets/semantic_ui/definitions/modules/dropdown.less +349 -80
  52. data/assets/stylesheets/semantic_ui/definitions/modules/embed.less +174 -0
  53. data/assets/stylesheets/semantic_ui/definitions/modules/modal.less +83 -36
  54. data/assets/stylesheets/semantic_ui/definitions/modules/nag.less +1 -1
  55. data/assets/stylesheets/semantic_ui/definitions/modules/popup.less +48 -7
  56. data/assets/stylesheets/semantic_ui/definitions/modules/progress.less +160 -107
  57. data/assets/stylesheets/semantic_ui/definitions/modules/rating.less +57 -54
  58. data/assets/stylesheets/semantic_ui/definitions/modules/search.less +55 -10
  59. data/assets/stylesheets/semantic_ui/definitions/modules/shape.less +5 -6
  60. data/assets/stylesheets/semantic_ui/definitions/modules/sidebar.less +9 -5
  61. data/assets/stylesheets/semantic_ui/definitions/modules/sticky.less +1 -1
  62. data/assets/stylesheets/semantic_ui/definitions/modules/tab.less +1 -1
  63. data/assets/stylesheets/semantic_ui/definitions/modules/transition.less +3 -4
  64. data/assets/stylesheets/semantic_ui/definitions/views/card.less +240 -130
  65. data/assets/stylesheets/semantic_ui/definitions/views/comment.less +1 -1
  66. data/assets/stylesheets/semantic_ui/definitions/views/feed.less +15 -8
  67. data/assets/stylesheets/semantic_ui/definitions/views/item.less +13 -13
  68. data/assets/stylesheets/semantic_ui/definitions/views/statistic.less +230 -86
  69. data/assets/stylesheets/semantic_ui/theme.less +22 -15
  70. data/assets/stylesheets/semantic_ui/themes/amazon/elements/button.overrides +5 -5
  71. data/assets/stylesheets/semantic_ui/themes/amazon/elements/button.variables +5 -4
  72. data/assets/stylesheets/semantic_ui/themes/basic/collections/table.variables +1 -0
  73. data/assets/stylesheets/semantic_ui/themes/basic/views/card.variables +6 -4
  74. data/assets/stylesheets/semantic_ui/themes/bookish/elements/header.variables +4 -4
  75. data/assets/stylesheets/semantic_ui/themes/bootstrap3/elements/button.variables +1 -1
  76. data/assets/stylesheets/semantic_ui/themes/chubby/collections/form.overrides +8 -0
  77. data/assets/stylesheets/semantic_ui/themes/chubby/collections/menu.overrides +0 -0
  78. data/assets/stylesheets/semantic_ui/themes/chubby/collections/menu.variables +40 -0
  79. data/assets/stylesheets/semantic_ui/themes/classic/modules/progress.variables +1 -0
  80. data/assets/stylesheets/semantic_ui/themes/classic/views/card.overrides +1 -1
  81. data/assets/stylesheets/semantic_ui/themes/colored/modules/checkbox.overrides +0 -0
  82. data/assets/stylesheets/semantic_ui/themes/colored/modules/checkbox.variables +17 -0
  83. data/assets/stylesheets/semantic_ui/themes/default/collections/breadcrumb.overrides +0 -0
  84. data/assets/stylesheets/semantic_ui/themes/default/collections/breadcrumb.variables +5 -15
  85. data/assets/stylesheets/semantic_ui/themes/default/collections/form.overrides +0 -0
  86. data/assets/stylesheets/semantic_ui/themes/default/collections/form.variables +31 -35
  87. data/assets/stylesheets/semantic_ui/themes/default/collections/grid.overrides +0 -0
  88. data/assets/stylesheets/semantic_ui/themes/default/collections/grid.variables +34 -28
  89. data/assets/stylesheets/semantic_ui/themes/default/collections/menu.overrides +0 -0
  90. data/assets/stylesheets/semantic_ui/themes/default/collections/menu.variables +259 -163
  91. data/assets/stylesheets/semantic_ui/themes/default/collections/message.overrides +0 -0
  92. data/assets/stylesheets/semantic_ui/themes/default/collections/message.variables +42 -19
  93. data/assets/stylesheets/semantic_ui/themes/default/collections/table.overrides +0 -3
  94. data/assets/stylesheets/semantic_ui/themes/default/collections/table.variables +63 -59
  95. data/assets/stylesheets/semantic_ui/themes/default/elements/button.overrides +0 -0
  96. data/assets/stylesheets/semantic_ui/themes/default/elements/button.variables +90 -50
  97. data/assets/stylesheets/semantic_ui/themes/default/elements/container.overrides +3 -0
  98. data/assets/stylesheets/semantic_ui/themes/default/elements/container.variables +45 -0
  99. data/assets/stylesheets/semantic_ui/themes/default/elements/divider.overrides +15 -0
  100. data/assets/stylesheets/semantic_ui/themes/default/elements/divider.variables +3 -4
  101. data/assets/stylesheets/semantic_ui/themes/default/elements/flag.overrides +0 -0
  102. data/assets/stylesheets/semantic_ui/themes/default/elements/header.overrides +0 -0
  103. data/assets/stylesheets/semantic_ui/themes/default/elements/header.variables +40 -36
  104. data/assets/stylesheets/semantic_ui/themes/default/elements/icon.overrides +4 -3
  105. data/assets/stylesheets/semantic_ui/themes/default/elements/icon.variables +29 -12
  106. data/assets/stylesheets/semantic_ui/themes/default/elements/image.overrides +0 -0
  107. data/assets/stylesheets/semantic_ui/themes/default/elements/image.variables +5 -3
  108. data/assets/stylesheets/semantic_ui/themes/default/elements/input.overrides +0 -0
  109. data/assets/stylesheets/semantic_ui/themes/default/elements/input.variables +10 -24
  110. data/assets/stylesheets/semantic_ui/themes/default/elements/label.overrides +0 -0
  111. data/assets/stylesheets/semantic_ui/themes/default/elements/label.variables +88 -35
  112. data/assets/stylesheets/semantic_ui/themes/default/elements/list.overrides +0 -0
  113. data/assets/stylesheets/semantic_ui/themes/default/elements/list.variables +53 -34
  114. data/assets/stylesheets/semantic_ui/themes/default/elements/loader.overrides +0 -0
  115. data/assets/stylesheets/semantic_ui/themes/default/elements/loader.variables +9 -10
  116. data/assets/stylesheets/semantic_ui/themes/default/elements/rail.overrides +0 -0
  117. data/assets/stylesheets/semantic_ui/themes/default/elements/rail.variables +13 -5
  118. data/assets/stylesheets/semantic_ui/themes/default/elements/reveal.overrides +0 -0
  119. data/assets/stylesheets/semantic_ui/themes/default/elements/reveal.variables +6 -4
  120. data/assets/stylesheets/semantic_ui/themes/default/elements/segment.overrides +0 -0
  121. data/assets/stylesheets/semantic_ui/themes/default/elements/segment.variables +66 -28
  122. data/assets/stylesheets/semantic_ui/themes/default/elements/step.overrides +0 -0
  123. data/assets/stylesheets/semantic_ui/themes/default/elements/step.variables +60 -31
  124. data/assets/stylesheets/semantic_ui/themes/default/globals/reset.overrides +0 -0
  125. data/assets/stylesheets/semantic_ui/themes/default/globals/site.variables +477 -303
  126. data/assets/stylesheets/semantic_ui/themes/default/modules/accordion.overrides +0 -0
  127. data/assets/stylesheets/semantic_ui/themes/default/modules/accordion.variables +6 -7
  128. data/assets/stylesheets/semantic_ui/themes/default/modules/chatroom.overrides +0 -0
  129. data/assets/stylesheets/semantic_ui/themes/default/modules/checkbox.overrides +19 -16
  130. data/assets/stylesheets/semantic_ui/themes/default/modules/checkbox.variables +71 -43
  131. data/assets/stylesheets/semantic_ui/themes/default/modules/dimmer.overrides +0 -0
  132. data/assets/stylesheets/semantic_ui/themes/default/modules/dimmer.variables +12 -9
  133. data/assets/stylesheets/semantic_ui/themes/default/modules/dropdown.overrides +0 -5
  134. data/assets/stylesheets/semantic_ui/themes/default/modules/dropdown.variables +146 -64
  135. data/assets/stylesheets/semantic_ui/themes/default/modules/{video.overrides → embed.overrides} +0 -0
  136. data/assets/stylesheets/semantic_ui/themes/default/modules/embed.variables +53 -0
  137. data/assets/stylesheets/semantic_ui/themes/default/modules/modal.overrides +0 -0
  138. data/assets/stylesheets/semantic_ui/themes/default/modules/modal.variables +24 -18
  139. data/assets/stylesheets/semantic_ui/themes/default/modules/nag.overrides +0 -0
  140. data/assets/stylesheets/semantic_ui/themes/default/modules/popup.overrides +0 -0
  141. data/assets/stylesheets/semantic_ui/themes/default/modules/popup.variables +3 -9
  142. data/assets/stylesheets/semantic_ui/themes/default/modules/progress.variables +13 -7
  143. data/assets/stylesheets/semantic_ui/themes/default/modules/rating.overrides +0 -0
  144. data/assets/stylesheets/semantic_ui/themes/default/modules/rating.variables +71 -33
  145. data/assets/stylesheets/semantic_ui/themes/default/modules/search.overrides +0 -0
  146. data/assets/stylesheets/semantic_ui/themes/default/modules/search.variables +36 -34
  147. data/assets/stylesheets/semantic_ui/themes/default/modules/shape.overrides +0 -0
  148. data/assets/stylesheets/semantic_ui/themes/default/modules/shape.variables +7 -2
  149. data/assets/stylesheets/semantic_ui/themes/default/modules/sidebar.overrides +0 -0
  150. data/assets/stylesheets/semantic_ui/themes/default/modules/sidebar.variables +2 -5
  151. data/assets/stylesheets/semantic_ui/themes/default/modules/sticky.overrides +0 -0
  152. data/assets/stylesheets/semantic_ui/themes/default/modules/sticky.variables +2 -7
  153. data/assets/stylesheets/semantic_ui/themes/default/modules/tab.variables +1 -3
  154. data/assets/stylesheets/semantic_ui/themes/default/modules/transition.overrides +8 -9
  155. data/assets/stylesheets/semantic_ui/themes/default/views/ad.variables +2 -2
  156. data/assets/stylesheets/semantic_ui/themes/default/views/card.variables +33 -23
  157. data/assets/stylesheets/semantic_ui/themes/default/views/comment.overrides +0 -0
  158. data/assets/stylesheets/semantic_ui/themes/default/views/feed.overrides +0 -0
  159. data/assets/stylesheets/semantic_ui/themes/default/views/feed.variables +15 -23
  160. data/assets/stylesheets/semantic_ui/themes/default/views/item.overrides +0 -0
  161. data/assets/stylesheets/semantic_ui/themes/default/views/item.variables +12 -11
  162. data/assets/stylesheets/semantic_ui/themes/default/views/statistic.overrides +0 -0
  163. data/assets/stylesheets/semantic_ui/themes/default/views/statistic.variables +25 -24
  164. data/assets/stylesheets/semantic_ui/themes/flat/collections/form.overrides +4 -0
  165. data/assets/stylesheets/semantic_ui/themes/flat/collections/form.variables +1 -2
  166. data/assets/stylesheets/semantic_ui/themes/flat/globals/site.variables +1 -0
  167. data/assets/stylesheets/semantic_ui/themes/github/collections/form.variables +1 -1
  168. data/assets/stylesheets/semantic_ui/themes/github/collections/menu.variables +10 -15
  169. data/assets/stylesheets/semantic_ui/themes/github/elements/button.variables +2 -2
  170. data/assets/stylesheets/semantic_ui/themes/github/elements/step.variables +2 -2
  171. data/assets/stylesheets/semantic_ui/themes/instagram/views/card.overrides +12 -0
  172. data/assets/stylesheets/semantic_ui/themes/instagram/views/card.variables +23 -0
  173. data/assets/stylesheets/semantic_ui/themes/material/collections/menu.overrides +1 -0
  174. data/assets/stylesheets/semantic_ui/themes/material/collections/menu.variables +10 -0
  175. data/assets/stylesheets/semantic_ui/themes/material/elements/button.overrides +1 -0
  176. data/assets/stylesheets/semantic_ui/themes/material/elements/button.variables +14 -6
  177. data/assets/stylesheets/semantic_ui/themes/material/globals/site.variables +3 -2
  178. data/assets/stylesheets/semantic_ui/themes/material/modules/dropdown.overrides +5 -0
  179. data/assets/stylesheets/semantic_ui/themes/material/modules/dropdown.variables +20 -0
  180. data/assets/stylesheets/semantic_ui/themes/raised/elements/button.variables +5 -5
  181. data/assets/stylesheets/semantic_ui/themes/round/elements/button.variables +1 -1
  182. data/assets/stylesheets/semantic_ui/themes/timeline/views/feed.overrides +4 -12
  183. data/assets/stylesheets/semantic_ui/themes/timeline/views/feed.variables +3 -7
  184. data/lib/generators/semantic_ui/install/templates/config/elements/container.overrides +3 -0
  185. data/lib/generators/semantic_ui/install/templates/config/elements/container.variables +3 -0
  186. data/lib/generators/semantic_ui/install/templates/config/modules/embed.overrides +3 -0
  187. data/lib/generators/semantic_ui/install/templates/config/modules/embed.variables +0 -0
  188. data/lib/generators/semantic_ui/install/templates/semantic_ui.css +2 -1
  189. data/lib/generators/semantic_ui/install/templates/semantic_ui.js +1 -1
  190. data/lib/generators/semantic_ui/install/templates/theme.config +5 -3
  191. data/lib/less/rails/semantic_ui/version.rb +1 -1
  192. data/tasks/update.rake +21 -6
  193. metadata +23 -7
  194. data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.otf +0 -0
  195. data/assets/javascripts/semantic_ui/definitions/modules/video.js +0 -540
  196. data/assets/stylesheets/semantic_ui/definitions/modules/video.less +0 -135
  197. data/assets/stylesheets/semantic_ui/themes/default/modules/video.variables +0 -16
@@ -3,7 +3,7 @@
3
3
  * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2015 Contributors
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -80,9 +80,10 @@ $.fn.modal = function(parameters) {
80
80
  module.create.dimmer();
81
81
  module.refreshModals();
82
82
 
83
- module.verbose('Attaching close events', $close);
84
83
  module.bind.events();
85
- module.observeChanges();
84
+ if(settings.observeChanges) {
85
+ module.observeChanges();
86
+ }
86
87
  module.instantiate();
87
88
  },
88
89
 
@@ -107,6 +108,12 @@ $.fn.modal = function(parameters) {
107
108
  },
108
109
  dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
109
110
  ;
111
+ if(settings.inverted) {
112
+ dimmerSettings.variation = (dimmerSettings.variation !== undefined)
113
+ ? dimmerSettings.variation + ' inverted'
114
+ : 'inverted'
115
+ ;
116
+ }
110
117
  if($.fn.dimmer === undefined) {
111
118
  module.error(error.dimmer);
112
119
  return;
@@ -117,6 +124,12 @@ $.fn.modal = function(parameters) {
117
124
  module.verbose('Modal is detachable, moving content into dimmer');
118
125
  $dimmable.dimmer('add content', $module);
119
126
  }
127
+ else {
128
+ module.set.undetached();
129
+ }
130
+ if(settings.blurring) {
131
+ $dimmable.addClass(className.blurring);
132
+ }
120
133
  $dimmer = $dimmable.dimmer('get dimmer');
121
134
  },
122
135
  id: function() {
@@ -186,8 +199,15 @@ $.fn.modal = function(parameters) {
186
199
 
187
200
  bind: {
188
201
  events: function() {
189
- $close.on('click' + eventNamespace, module.event.close);
190
- $window.on('resize' + elementNamespace, module.event.resize);
202
+ module.verbose('Attaching events');
203
+ $module
204
+ .on('click' + eventNamespace, selector.close, module.event.close)
205
+ .on('click' + eventNamespace, selector.approve, module.event.approve)
206
+ .on('click' + eventNamespace, selector.deny, module.event.deny)
207
+ ;
208
+ $window
209
+ .on('resize' + elementNamespace, module.event.resize)
210
+ ;
191
211
  }
192
212
  },
193
213
 
@@ -198,30 +218,30 @@ $.fn.modal = function(parameters) {
198
218
  },
199
219
 
200
220
  event: {
201
- close: function() {
202
- module.verbose('Closing element pressed');
203
- if( $(this).is(selector.approve) ) {
204
- if(settings.onApprove.call(element) !== false) {
205
- module.hide();
206
- }
207
- else {
208
- module.verbose('Approve callback returned false cancelling hide');
209
- }
210
- }
211
- else if( $(this).is(selector.deny) ) {
212
- if(settings.onDeny.call(element) !== false) {
213
- module.hide();
214
- }
215
- else {
216
- module.verbose('Deny callback returned false cancelling hide');
217
- }
221
+ approve: function() {
222
+ if(settings.onApprove.call(element, $(this)) === false) {
223
+ module.verbose('Approve callback returned false cancelling hide');
224
+ return;
218
225
  }
219
- else {
220
- module.hide();
226
+ module.hide();
227
+ },
228
+ deny: function() {
229
+ if(settings.onDeny.call(element, $(this)) === false) {
230
+ module.verbose('Deny callback returned false cancelling hide');
231
+ return;
221
232
  }
233
+ module.hide();
234
+ },
235
+ close: function() {
236
+ module.hide();
222
237
  },
223
238
  click: function(event) {
224
- if( $(event.target).closest($module).length === 0 ) {
239
+ var
240
+ $target = $(event.target),
241
+ isInModal = ($target.closest(selector.modal).length > 0),
242
+ isInDOM = $.contains(document.documentElement, event.target)
243
+ ;
244
+ if(!isInModal && isInDOM) {
225
245
  module.debug('Dimmer clicked, hiding all modals');
226
246
  if( module.is.active() ) {
227
247
  module.remove.clickaway();
@@ -302,8 +322,7 @@ $.fn.modal = function(parameters) {
302
322
  module.set.type();
303
323
  module.set.clickaway();
304
324
 
305
- if( !settings.allowMultiple && $otherModals.filter('.' + className.active).length > 0) {
306
- module.debug('Other modals visible, queueing show animation');
325
+ if( !settings.allowMultiple && module.others.active() ) {
307
326
  module.hideOthers(module.showModal);
308
327
  }
309
328
  else {
@@ -329,16 +348,7 @@ $.fn.modal = function(parameters) {
329
348
  ;
330
349
  }
331
350
  else {
332
- module.debug('Showing modal with javascript');
333
- $module
334
- .fadeIn(settings.duration, settings.easing, function() {
335
- settings.onVisible.apply(element);
336
- module.add.keyboardShortcuts();
337
- module.save.focus();
338
- module.set.active();
339
- callback();
340
- })
341
- ;
351
+ module.error(error.noTransition);
342
352
  }
343
353
  }
344
354
  }
@@ -366,7 +376,7 @@ $.fn.modal = function(parameters) {
366
376
  duration : settings.duration,
367
377
  useFailSafe : true,
368
378
  onStart : function() {
369
- if(!module.othersActive() && !keepDimmed) {
379
+ if(!module.others.active() && !keepDimmed) {
370
380
  module.hideDimmer();
371
381
  }
372
382
  module.remove.keyboardShortcuts();
@@ -380,18 +390,7 @@ $.fn.modal = function(parameters) {
380
390
  ;
381
391
  }
382
392
  else {
383
- module.remove.active();
384
- if( !module.othersActive() ) {
385
- module.hideDimmer();
386
- }
387
- module.remove.keyboardShortcuts();
388
- $module
389
- .fadeOut(settings.duration, settings.easing, function() {
390
- settings.onHidden.call(element);
391
- module.restore.focus();
392
- callback();
393
- })
394
- ;
393
+ module.error(error.noTransition);
395
394
  }
396
395
  }
397
396
  },
@@ -423,7 +422,7 @@ $.fn.modal = function(parameters) {
423
422
 
424
423
  hideAll: function(callback) {
425
424
  var
426
- $visibleModals = $allModals.filter(':visible')
425
+ $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
427
426
  ;
428
427
  callback = $.isFunction(callback)
429
428
  ? callback
@@ -440,7 +439,7 @@ $.fn.modal = function(parameters) {
440
439
 
441
440
  hideOthers: function(callback) {
442
441
  var
443
- $visibleModals = $otherModals.filter(':visible')
442
+ $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
444
443
  ;
445
444
  callback = $.isFunction(callback)
446
445
  ? callback
@@ -454,10 +453,16 @@ $.fn.modal = function(parameters) {
454
453
  }
455
454
  },
456
455
 
457
- othersActive: function() {
458
- return ($otherModals.filter('.' + className.active).length > 0);
456
+ others: {
457
+ active: function() {
458
+ return ($otherModals.filter('.' + className.active).length > 0);
459
+ },
460
+ animating: function() {
461
+ return ($otherModals.filter('.' + className.animating).length > 0);
462
+ }
459
463
  },
460
464
 
465
+
461
466
  add: {
462
467
  keyboardShortcuts: function() {
463
468
  module.verbose('Adding keyboard shortcuts');
@@ -557,13 +562,15 @@ $.fn.modal = function(parameters) {
557
562
  autofocus: function() {
558
563
  if(settings.autofocus) {
559
564
  var
560
- $inputs = $module.find(':input:visible'),
565
+ $inputs = $module.filter(':input').filter(':visible'),
561
566
  $autofocus = $inputs.filter('[autofocus]'),
562
567
  $input = ($autofocus.length > 0)
563
- ? $autofocus
564
- : $inputs
568
+ ? $autofocus.first()
569
+ : $inputs.first()
565
570
  ;
566
- $input.first().focus();
571
+ if($input.length > 0) {
572
+ $input.focus();
573
+ }
567
574
  }
568
575
  },
569
576
  clickaway: function() {
@@ -580,7 +587,7 @@ $.fn.modal = function(parameters) {
580
587
  else {
581
588
  module.debug('Modal is taller than page content, resizing page height');
582
589
  $body
583
- .css('height', module.cache.height + (settings.padding / 2) )
590
+ .css('height', module.cache.height + (settings.padding * 2) )
584
591
  ;
585
592
  }
586
593
  },
@@ -594,7 +601,7 @@ $.fn.modal = function(parameters) {
594
601
  type: function() {
595
602
  if(module.can.fit()) {
596
603
  module.verbose('Modal fits on screen');
597
- if(!module.othersActive) {
604
+ if(!module.others.active() && !module.others.animating()) {
598
605
  module.remove.scrolling();
599
606
  }
600
607
  }
@@ -621,6 +628,9 @@ $.fn.modal = function(parameters) {
621
628
  })
622
629
  ;
623
630
  }
631
+ },
632
+ undetached: function() {
633
+ $dimmable.addClass(className.undetached);
624
634
  }
625
635
  },
626
636
 
@@ -693,7 +703,7 @@ $.fn.modal = function(parameters) {
693
703
  });
694
704
  }
695
705
  clearTimeout(module.performance.timer);
696
- module.performance.timer = setTimeout(module.performance.display, 100);
706
+ module.performance.timer = setTimeout(module.performance.display, 500);
697
707
  },
698
708
  display: function() {
699
709
  var
@@ -806,40 +816,55 @@ $.fn.modal.settings = {
806
816
  namespace : 'modal',
807
817
 
808
818
  debug : false,
809
- verbose : true,
819
+ verbose : false,
810
820
  performance : true,
811
821
 
822
+ observeChanges : false,
823
+
812
824
  allowMultiple : false,
813
825
  detachable : true,
814
826
  closable : true,
815
827
  autofocus : true,
816
828
 
829
+ inverted : false,
830
+ blurring : false,
831
+
817
832
  dimmerSettings : {
818
833
  closable : false,
819
834
  useCSS : true
820
835
  },
821
836
 
822
- context : 'body',
823
837
 
824
- queue : false,
825
- duration : 500,
826
- easing : 'easeOutExpo',
827
- offset : 0,
828
- transition : 'scale',
838
+ context : 'body',
839
+
840
+ queue : false,
841
+ duration : 500,
842
+ offset : 0,
843
+ transition : 'scale',
844
+
845
+ // padding with edge of page
846
+ padding : 50,
847
+
848
+ // called before show animation
849
+ onShow : function(){},
850
+
851
+ // called after show animation
852
+ onVisible : function(){},
829
853
 
830
- padding : 50,
854
+ // called before hide animation
855
+ onHide : function(){},
831
856
 
832
- onShow : function(){},
833
- onHide : function(){},
857
+ // called after hide animation
858
+ onHidden : function(){},
834
859
 
835
- onVisible : function(){},
836
- onHidden : function(){},
860
+ // called after approve selector match
861
+ onApprove : function(){ return true; },
837
862
 
838
- onApprove : function(){ return true; },
839
- onDeny : function(){ return true; },
863
+ // called after deny selector match
864
+ onDeny : function(){ return true; },
840
865
 
841
866
  selector : {
842
- close : '.close, .actions .button',
867
+ close : '.close',
843
868
  approve : '.actions .positive, .actions .approve, .actions .ok',
844
869
  deny : '.actions .negative, .actions .deny, .actions .cancel',
845
870
  modal : '.ui.modal'
@@ -850,9 +875,11 @@ $.fn.modal.settings = {
850
875
  notFound : 'The element you specified could not be found'
851
876
  },
852
877
  className : {
853
- active : 'active',
854
- animating : 'animating',
855
- scrolling : 'scrolling'
878
+ active : 'active',
879
+ animating : 'animating',
880
+ blurring : 'blurring',
881
+ scrolling : 'scrolling',
882
+ undetached : 'undetached'
856
883
  }
857
884
  };
858
885
 
@@ -3,7 +3,7 @@
3
3
  * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2015 Contributors
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -76,11 +76,9 @@ $.fn.nag = function(parameters) {
76
76
  module.verbose('Initializing element');
77
77
 
78
78
  $module
79
+ .on('click' + eventNamespace, selector.close, module.dismiss)
79
80
  .data(moduleNamespace, module)
80
81
  ;
81
- $close
82
- .on('click' + eventNamespace, module.dismiss)
83
- ;
84
82
 
85
83
  if(settings.detachable && $module.parent()[0] !== $context[0]) {
86
84
  $module
@@ -310,7 +308,7 @@ $.fn.nag = function(parameters) {
310
308
  });
311
309
  }
312
310
  clearTimeout(module.performance.timer);
313
- module.performance.timer = setTimeout(module.performance.display, 100);
311
+ module.performance.timer = setTimeout(module.performance.display, 500);
314
312
  },
315
313
  display: function() {
316
314
  var
@@ -423,7 +421,7 @@ $.fn.nag.settings = {
423
421
  name : 'Nag',
424
422
 
425
423
  debug : false,
426
- verbose : true,
424
+ verbose : false,
427
425
  performance : true,
428
426
 
429
427
  namespace : 'Nag',
@@ -454,8 +452,9 @@ $.fn.nag.settings = {
454
452
  value : 'dismiss',
455
453
 
456
454
  error: {
457
- noStorage : 'Neither $.cookie or store is defined. A storage solution is required for storing state',
458
- method : 'The method you called is not defined.'
455
+ noCookieStorage : '$.cookie is not included. A storage solution is required.',
456
+ noStorage : 'Neither $.cookie or store is defined. A storage solution is required for storing state',
457
+ method : 'The method you called is not defined.'
459
458
  },
460
459
 
461
460
  className : {
@@ -3,7 +3,7 @@
3
3
  * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2015 Contributors
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -17,6 +17,8 @@ $.fn.popup = function(parameters) {
17
17
  var
18
18
  $allModules = $(this),
19
19
  $document = $(document),
20
+ $window = $(window),
21
+ $body = $('body'),
20
22
 
21
23
  moduleSelector = $allModules.selector || '',
22
24
 
@@ -52,13 +54,12 @@ $.fn.popup = function(parameters) {
52
54
  ? $(settings.target)
53
55
  : $module,
54
56
 
55
- $window = $(window),
56
- $body = $('body'),
57
57
  $popup,
58
58
  $offsetParent,
59
59
 
60
60
  searchDepth = 0,
61
61
  triedPositions = false,
62
+ openedWithTouch = false,
62
63
 
63
64
  element = this,
64
65
  instance = $module.data(moduleNamespace),
@@ -96,6 +97,7 @@ $.fn.popup = function(parameters) {
96
97
  else {
97
98
  if(settings.inline) {
98
99
  $popup = $target.next(selector.popup).eq(0);
100
+ settings.popup = $popup;
99
101
  }
100
102
  }
101
103
  if(settings.popup) {
@@ -154,11 +156,7 @@ $.fn.popup = function(parameters) {
154
156
  : settings.delay
155
157
  ;
156
158
  clearTimeout(module.hideTimer);
157
- module.showTimer = setTimeout(function() {
158
- if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
159
- module.show();
160
- }
161
- }, delay);
159
+ module.showTimer = setTimeout(module.show, delay);
162
160
  },
163
161
  end: function() {
164
162
  var
@@ -167,27 +165,38 @@ $.fn.popup = function(parameters) {
167
165
  : settings.delay
168
166
  ;
169
167
  clearTimeout(module.showTimer);
170
- module.hideTimer = setTimeout(function() {
171
- if(module.is.visible() ) {
172
- module.hide();
173
- }
174
- }, delay);
168
+ module.hideTimer = setTimeout(module.hide, delay);
169
+ },
170
+ touchstart: function(event) {
171
+ openedWithTouch = true;
172
+ module.event.start();
175
173
  },
176
174
  resize: function() {
177
175
  if( module.is.visible() ) {
178
176
  module.set.position();
179
177
  }
178
+ },
179
+ hideGracefully: function(event) {
180
+ // don't close on clicks inside popup
181
+ if(event && $(event.target).closest(selector.popup).length === 0) {
182
+ module.debug('Click occurred outside popup hiding popup');
183
+ module.hide();
184
+ }
185
+ else {
186
+ module.debug('Click was inside popup, keeping popup open');
187
+ }
180
188
  }
181
189
  },
182
190
 
183
191
  // generates popup html from metadata
184
192
  create: function() {
185
193
  var
186
- html = $module.data(metadata.html) || settings.html,
187
- variation = $module.data(metadata.variation) || settings.variation,
188
- title = $module.data(metadata.title) || settings.title,
189
- content = $module.data(metadata.content) || $module.attr('title') || settings.content
194
+ html = module.get.html(),
195
+ variation = module.get.variation(),
196
+ title = module.get.title(),
197
+ content = module.get.content()
190
198
  ;
199
+
191
200
  if(html || content || title) {
192
201
  module.debug('Creating pop-up html');
193
202
  if(!html) {
@@ -228,14 +237,14 @@ $.fn.popup = function(parameters) {
228
237
  else if($target.next(selector.popup).length !== 0) {
229
238
  module.verbose('Pre-existing popup found');
230
239
  settings.inline = true;
231
- settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
240
+ settings.popups = $target.next(selector.popup).data(metadata.activator, $module);
232
241
  module.refresh();
233
242
  if(settings.hoverable) {
234
243
  module.bind.popup();
235
244
  }
236
245
  }
237
246
  else if(settings.popup) {
238
- settings.popup.data(metadata.activator, $module);
247
+ $(settings.popup).data(metadata.activator, $module);
239
248
  module.verbose('Used popup specified in settings');
240
249
  module.refresh();
241
250
  if(settings.hoverable) {
@@ -268,29 +277,40 @@ $.fn.popup = function(parameters) {
268
277
  },
269
278
 
270
279
  show: function(callback) {
271
- callback = $.isFunction(callback) ? callback : function(){};
280
+ callback = callback || function(){};
272
281
  module.debug('Showing pop-up', settings.transition);
273
- if( !module.exists() ) {
274
- module.create();
275
- }
276
- else if(!settings.preserve && !settings.popup) {
277
- module.refresh();
278
- }
279
- if( $popup && module.set.position() ) {
280
- module.save.conditions();
281
- if(settings.exclusive) {
282
- module.hideAll();
282
+
283
+ if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
284
+ if( !module.exists() ) {
285
+ module.create();
286
+ }
287
+ if(settings.onShow.call($popup, element) === false) {
288
+ module.debug('onShow callback returned false, cancelling popup animation');
289
+ return;
290
+ }
291
+ else if(!settings.preserve && !settings.popup) {
292
+ module.refresh();
293
+ }
294
+ if( $popup && module.set.position() ) {
295
+ module.save.conditions();
296
+ if(settings.exclusive) {
297
+ module.hideAll();
298
+ }
299
+ module.animate.show(callback);
283
300
  }
284
- module.animate.show(callback);
285
301
  }
286
302
  },
287
303
 
288
304
 
289
305
  hide: function(callback) {
290
- callback = $.isFunction(callback) ? callback : function(){};
291
- module.remove.visible();
292
- module.unbind.close();
293
- if( module.is.visible() ) {
306
+ callback = callback || function(){};
307
+ if( module.is.visible() || module.is.animating() ) {
308
+ if(settings.onHide.call($popup, element) === false) {
309
+ module.debug('onHide callback returned false, cancelling popup animation');
310
+ return;
311
+ }
312
+ module.remove.visible();
313
+ module.unbind.close();
294
314
  module.restore.conditions();
295
315
  module.animate.hide(callback);
296
316
  }
@@ -307,18 +327,6 @@ $.fn.popup = function(parameters) {
307
327
  })
308
328
  ;
309
329
  },
310
-
311
- hideGracefully: function(event) {
312
- // don't close on clicks inside popup
313
- if(event && $(event.target).closest(selector.popup).length === 0) {
314
- module.debug('Click occurred outside popup hiding popup');
315
- module.hide();
316
- }
317
- else {
318
- module.debug('Click was inside popup, keeping popup open');
319
- }
320
- },
321
-
322
330
  exists: function() {
323
331
  if(!$popup) {
324
332
  return false;
@@ -384,21 +392,16 @@ $.fn.popup = function(parameters) {
384
392
  ;
385
393
  }
386
394
  else {
387
- module.set.visible();
388
- $popup
389
- .stop()
390
- .fadeIn(settings.duration, settings.easing, function() {
391
- module.bind.close();
392
- callback.call($popup, element);
393
- settings.onVisible.call($popup, element);
394
- })
395
- ;
395
+ module.error(error.noTransition);
396
396
  }
397
- settings.onShow.call($popup, element);
398
397
  },
399
398
  hide: function(callback) {
400
399
  callback = $.isFunction(callback) ? callback : function(){};
401
400
  module.debug('Hiding pop-up');
401
+ if(settings.onShow.call($popup, element) === false) {
402
+ module.debug('onShow callback returned false, cancelling popup animation');
403
+ return;
404
+ }
402
405
  if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
403
406
  $popup
404
407
  .transition({
@@ -416,29 +419,95 @@ $.fn.popup = function(parameters) {
416
419
  ;
417
420
  }
418
421
  else {
419
- $popup
420
- .stop()
421
- .fadeOut(settings.duration, settings.easing, function() {
422
- module.reset();
423
- callback.call($popup, element);
424
- settings.onHidden.call($popup, element);
425
- })
426
- ;
422
+ module.error(error.noTransition);
427
423
  }
428
- settings.onHide.call($popup, element);
429
424
  }
430
425
  },
431
426
 
432
427
  get: {
428
+ html: function() {
429
+ $module.removeData(metadata.html);
430
+ return $module.data(metadata.html) || settings.html;
431
+ },
432
+ title: function() {
433
+ $module.removeData(metadata.title);
434
+ return $module.data(metadata.title) || settings.title;
435
+ },
436
+ content: function() {
437
+ $module.removeData(metadata.content);
438
+ return $module.data(metadata.content) || $module.attr('title') || settings.content;
439
+ },
440
+ variation: function() {
441
+ $module.removeData(metadata.variation);
442
+ return $module.data(metadata.variation) || settings.variation;
443
+ },
444
+ calculations: function() {
445
+ var
446
+ targetElement = $target[0],
447
+ targetPosition = (settings.inline || settings.popup)
448
+ ? $target.position()
449
+ : $target.offset(),
450
+ calculations = {},
451
+ screen
452
+ ;
453
+ calculations = {
454
+ // element which is launching popup
455
+ target : {
456
+ element : $target[0],
457
+ width : $target.outerWidth(),
458
+ height : $target.outerHeight(),
459
+ top : targetPosition.top,
460
+ left : targetPosition.left,
461
+ margin : {}
462
+ },
463
+ // popup itself
464
+ popup : {
465
+ width : $popup.outerWidth(),
466
+ height : $popup.outerHeight()
467
+ },
468
+ // offset container (or 3d context)
469
+ parent : {
470
+ width : $offsetParent.outerWidth(),
471
+ height : $offsetParent.outerHeight()
472
+ },
473
+ // screen boundaries
474
+ screen : {
475
+ scroll: {
476
+ top : $window.scrollTop(),
477
+ left : $window.scrollLeft()
478
+ },
479
+ width : $window.width(),
480
+ height : $window.height()
481
+ }
482
+ };
483
+
484
+ // add in margins if inline
485
+ calculations.target.margin.top = (settings.inline)
486
+ ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
487
+ : 0
488
+ ;
489
+ calculations.target.margin.left = (settings.inline)
490
+ ? module.is.rtl()
491
+ ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
492
+ : parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left') , 10)
493
+ : 0
494
+ ;
495
+ // calculate screen boundaries
496
+ screen = calculations.screen;
497
+ calculations.boundary = {
498
+ top : screen.scroll.top,
499
+ bottom : screen.scroll.top + screen.height,
500
+ left : screen.scroll.left,
501
+ right : screen.scroll.left + screen.width
502
+ };
503
+ return calculations;
504
+ },
433
505
  id: function() {
434
506
  return id;
435
507
  },
436
508
  startEvent: function() {
437
509
  if(settings.on == 'hover') {
438
- return (hasTouch)
439
- ? 'touchstart mouseenter'
440
- : 'mouseenter'
441
- ;
510
+ return 'mouseenter';
442
511
  }
443
512
  else if(settings.on == 'focus') {
444
513
  return 'focus';
@@ -446,10 +515,7 @@ $.fn.popup = function(parameters) {
446
515
  return false;
447
516
  },
448
517
  scrollEvent: function() {
449
- return (hasTouch)
450
- ? 'touchmove scroll'
451
- : 'scroll'
452
- ;
518
+ return 'scroll';
453
519
  },
454
520
  endEvent: function() {
455
521
  if(settings.on == 'hover') {
@@ -487,31 +553,28 @@ $.fn.popup = function(parameters) {
487
553
  : $()
488
554
  ;
489
555
  },
490
- offstagePosition: function(position) {
556
+ offstagePosition: function(position, calculations) {
491
557
  var
492
- boundary = {
493
- top : $(window).scrollTop(),
494
- bottom : $(window).scrollTop() + $(window).height(),
495
- left : 0,
496
- right : $(window).width()
497
- },
498
- popup = {
499
- width : $popup.width(),
500
- height : $popup.height(),
501
- offset : $popup.offset()
502
- },
503
- offstage = {},
504
- offstagePositions = []
558
+ offset = $popup.offset(),
559
+ offstage = {},
560
+ offstagePositions = [],
561
+ popup,
562
+ boundary
505
563
  ;
506
- position = position || false;
507
- if(popup.offset && position) {
508
- module.verbose('Checking if outside viewable area', popup.offset);
564
+ position = position || false;
565
+ calculations = calculations || module.get.calculations();
566
+ // shorthand
567
+ popup = calculations.popup;
568
+ boundary = calculations.boundary;
569
+
570
+ if(offset && position) {
509
571
  offstage = {
510
- top : (popup.offset.top < boundary.top),
511
- bottom : (popup.offset.top + popup.height > boundary.bottom),
512
- right : (popup.offset.left + popup.width > boundary.right),
513
- left : (popup.offset.left < boundary.left)
572
+ top : (offset.top < boundary.top),
573
+ bottom : (offset.top + popup.height > boundary.bottom),
574
+ right : (offset.left + popup.width > boundary.right),
575
+ left : (offset.left < boundary.left)
514
576
  };
577
+ module.verbose('Offstage positions determined', offset, offstage);
515
578
  }
516
579
  // return only boundaries that have been surpassed
517
580
  $.each(offstage, function(direction, isOffstage) {
@@ -596,135 +659,133 @@ $.fn.popup = function(parameters) {
596
659
  },
597
660
 
598
661
  set: {
599
- position: function(position, arrowOffset) {
600
- var
601
- windowWidth = $(window).width(),
602
- windowHeight = $(window).height(),
603
-
604
- targetWidth = $target.outerWidth(),
605
- targetHeight = $target.outerHeight(),
606
-
607
- popupWidth = $popup.outerWidth(),
608
- popupHeight = $popup.outerHeight(),
609
-
610
- parentWidth = $offsetParent.outerWidth(),
611
- parentHeight = $offsetParent.outerHeight(),
612
-
613
- distanceAway = settings.distanceAway,
614
-
615
- targetElement = $target[0],
616
-
617
- marginTop = (settings.inline)
618
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
619
- : 0,
620
- marginLeft = (settings.inline)
621
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue(module.is.rtl() ? 'margin-right' : 'margin-left'), 10)
622
- : 0,
623
-
624
- target = (settings.inline || settings.popup)
625
- ? $target.position()
626
- : $target.offset(),
662
+ position: function(position, calculations) {
627
663
 
664
+ // exit conditions
665
+ if($target.length === 0 || $popup.length === 0) {
666
+ module.error(error.notFound);
667
+ return;
668
+ }
669
+ var
670
+ offset,
671
+ distanceAway,
672
+ target,
673
+ popup,
674
+ parent,
628
675
  computedPosition,
629
676
  positioning,
630
677
  offstagePosition
631
678
  ;
632
- position = position || $module.data(metadata.position) || settings.position;
633
- arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset;
679
+ calculations = calculations || module.get.calculations();
680
+ position = position || $module.data(metadata.position) || settings.position;
634
681
 
635
- if(searchDepth == settings.maxSearchDepth && settings.lastResort) {
636
- module.debug('Using last resort position to display', settings.lastResort);
637
- position = settings.lastResort;
682
+ offset = $module.data(metadata.offset) || settings.offset;
683
+ distanceAway = settings.distanceAway;
684
+
685
+ // shorthand
686
+ target = calculations.target;
687
+ popup = calculations.popup;
688
+ parent = calculations.parent;
689
+
690
+ if(target.top === 0 && target.left === 0) {
691
+ module.debug('Popup target is hidden, no action taken');
692
+ return false;
638
693
  }
639
694
 
640
695
  if(settings.inline) {
641
- module.debug('Adding targets margin to calculation');
696
+ module.debug('Adding margin to calculation', target.margin);
642
697
  if(position == 'left center' || position == 'right center') {
643
- arrowOffset += marginTop;
644
- distanceAway += -marginLeft;
698
+ offset += target.margin.top;
699
+ distanceAway += -target.margin.left;
645
700
  }
646
701
  else if (position == 'top left' || position == 'top center' || position == 'top right') {
647
- arrowOffset += marginLeft;
648
- distanceAway -= marginTop;
702
+ offset += target.margin.left;
703
+ distanceAway -= target.margin.top;
649
704
  }
650
705
  else {
651
- arrowOffset += marginLeft;
652
- distanceAway += marginTop;
706
+ offset += target.margin.left;
707
+ distanceAway += target.margin.top;
653
708
  }
654
709
  }
655
- module.debug('Calculating popup positioning', position);
656
710
 
657
- computedPosition = position;
711
+ module.debug('Determining popup position from calculations', position, calculations);
712
+
658
713
  if (module.is.rtl()) {
659
- computedPosition = computedPosition.replace(/left|right/g, function (match) {
714
+ position = position.replace(/left|right/g, function (match) {
660
715
  return (match == 'left')
661
716
  ? 'right'
662
717
  : 'left'
663
718
  ;
664
719
  });
665
- module.debug('RTL: Popup positioning updated', computedPosition);
720
+ module.debug('RTL: Popup position updated', position);
721
+ }
722
+
723
+ if(searchDepth == settings.maxSearchDepth && settings.lastResort) {
724
+ module.debug('Using "last resort" position to display', settings.lastResort);
725
+ position = settings.lastResort;
666
726
  }
667
- switch (computedPosition) {
727
+
728
+ switch (position) {
668
729
  case 'top left':
669
730
  positioning = {
670
731
  top : 'auto',
671
- bottom : parentHeight - target.top + distanceAway,
672
- left : target.left + arrowOffset,
732
+ bottom : parent.height - target.top + distanceAway,
733
+ left : target.left + offset,
673
734
  right : 'auto'
674
735
  };
675
736
  break;
676
737
  case 'top center':
677
738
  positioning = {
678
- bottom : parentHeight - target.top + distanceAway,
679
- left : target.left + (targetWidth / 2) - (popupWidth / 2) + arrowOffset,
739
+ bottom : parent.height - target.top + distanceAway,
740
+ left : target.left + (target.width / 2) - (popup.width / 2) + offset,
680
741
  top : 'auto',
681
742
  right : 'auto'
682
743
  };
683
744
  break;
684
745
  case 'top right':
685
746
  positioning = {
686
- bottom : parentHeight - target.top + distanceAway,
687
- right : parentWidth - target.left - targetWidth - arrowOffset,
747
+ bottom : parent.height - target.top + distanceAway,
748
+ right : parent.width - target.left - target.width - offset,
688
749
  top : 'auto',
689
750
  left : 'auto'
690
751
  };
691
752
  break;
692
753
  case 'left center':
693
754
  positioning = {
694
- top : target.top + (targetHeight / 2) - (popupHeight / 2) + arrowOffset,
695
- right : parentWidth - target.left + distanceAway,
755
+ top : target.top + (target.height / 2) - (popup.height / 2) + offset,
756
+ right : parent.width - target.left + distanceAway,
696
757
  left : 'auto',
697
758
  bottom : 'auto'
698
759
  };
699
760
  break;
700
761
  case 'right center':
701
762
  positioning = {
702
- top : target.top + (targetHeight / 2) - (popupHeight / 2) + arrowOffset,
703
- left : target.left + targetWidth + distanceAway,
763
+ top : target.top + (target.height / 2) - (popup.height / 2) + offset,
764
+ left : target.left + target.width + distanceAway,
704
765
  bottom : 'auto',
705
766
  right : 'auto'
706
767
  };
707
768
  break;
708
769
  case 'bottom left':
709
770
  positioning = {
710
- top : target.top + targetHeight + distanceAway,
711
- left : target.left + arrowOffset,
771
+ top : target.top + target.height + distanceAway,
772
+ left : target.left + offset,
712
773
  bottom : 'auto',
713
774
  right : 'auto'
714
775
  };
715
776
  break;
716
777
  case 'bottom center':
717
778
  positioning = {
718
- top : target.top + targetHeight + distanceAway,
719
- left : target.left + (targetWidth / 2) - (popupWidth / 2) + arrowOffset,
779
+ top : target.top + target.height + distanceAway,
780
+ left : target.left + (target.width / 2) - (popup.width / 2) + offset,
720
781
  bottom : 'auto',
721
782
  right : 'auto'
722
783
  };
723
784
  break;
724
785
  case 'bottom right':
725
786
  positioning = {
726
- top : target.top + targetHeight + distanceAway,
727
- right : parentWidth - target.left - targetWidth - arrowOffset,
787
+ top : target.top + target.height + distanceAway,
788
+ right : parent.width - target.left - target.width - offset,
728
789
  left : 'auto',
729
790
  bottom : 'auto'
730
791
  };
@@ -744,17 +805,17 @@ $.fn.popup = function(parameters) {
744
805
  .addClass(className.loading)
745
806
  ;
746
807
  // check if is offstage
747
- offstagePosition = module.get.offstagePosition(position);
808
+ offstagePosition = module.get.offstagePosition(position, calculations);
748
809
 
749
810
  // recursively find new positioning
750
811
  if(offstagePosition) {
751
- module.debug('Popup cant fit into viewport', offstagePosition);
812
+ module.debug('Popup cant fit into viewport', position, offstagePosition);
752
813
  if(searchDepth < settings.maxSearchDepth) {
753
814
  searchDepth++;
754
815
  position = module.get.nextPosition(position);
755
816
  module.debug('Trying new position', position);
756
817
  return ($popup)
757
- ? module.set.position(position)
818
+ ? module.set.position(position, calculations)
758
819
  : false
759
820
  ;
760
821
  }
@@ -770,14 +831,15 @@ $.fn.popup = function(parameters) {
770
831
 
771
832
  module.debug('Position is on stage', position);
772
833
  module.remove.attempts();
773
- module.set.fluidWidth();
834
+ module.set.fluidWidth(calculations);
774
835
  module.remove.loading();
775
836
  return true;
776
837
  },
777
838
 
778
- fluidWidth: function() {
839
+ fluidWidth: function(calculations) {
840
+ calculations = calculations || module.get.calculations();
779
841
  if( settings.setFluidWidth && $popup.hasClass(className.fluid) ) {
780
- $popup.css('width', $offsetParent.width());
842
+ $popup.css('width', calculations.parent.width);
781
843
  }
782
844
  },
783
845
 
@@ -808,6 +870,11 @@ $.fn.popup = function(parameters) {
808
870
  .on('click' + eventNamespace, module.toggle)
809
871
  ;
810
872
  }
873
+ if(settings.on == 'hover' && hasTouch) {
874
+ $module
875
+ .on('touchstart' + eventNamespace, module.event.touchstart)
876
+ ;
877
+ }
811
878
  else if( module.get.startEvent() ) {
812
879
  $module
813
880
  .on(module.get.startEvent() + eventNamespace, module.event.start)
@@ -828,21 +895,30 @@ $.fn.popup = function(parameters) {
828
895
  ;
829
896
  }
830
897
  },
831
- close:function() {
832
- if(settings.hideOnScroll === true || settings.hideOnScroll == 'auto' && settings.on != 'click') {
898
+ close: function() {
899
+ if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) {
833
900
  $document
834
- .one(module.get.scrollEvent() + elementNamespace, module.hideGracefully)
901
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
835
902
  ;
836
903
  $context
837
- .one(module.get.scrollEvent() + elementNamespace, module.hideGracefully)
904
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
905
+ ;
906
+ }
907
+ if(settings.on == 'hover' && openedWithTouch) {
908
+ module.verbose('Binding popup close event to document');
909
+ $document
910
+ .on('touchstart' + elementNamespace, function(event) {
911
+ module.verbose('Touched away from popup');
912
+ module.event.hideGracefully.call(element, event);
913
+ })
838
914
  ;
839
915
  }
840
916
  if(settings.on == 'click' && settings.closable) {
841
917
  module.verbose('Binding popup close event to document');
842
918
  $document
843
919
  .on('click' + elementNamespace, function(event) {
844
- module.verbose('Pop-up clickaway intent detected');
845
- module.hideGracefully.call(element, event);
920
+ module.verbose('Clicked away from popup');
921
+ module.event.hideGracefully.call(element, event);
846
922
  })
847
923
  ;
848
924
  }
@@ -851,7 +927,7 @@ $.fn.popup = function(parameters) {
851
927
 
852
928
  unbind: {
853
929
  close: function() {
854
- if(settings.hideOnScroll === true || settings.hideOnScroll == 'auto' && settings.on != 'click') {
930
+ if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) {
855
931
  $document
856
932
  .off('scroll' + elementNamespace, module.hide)
857
933
  ;
@@ -859,6 +935,12 @@ $.fn.popup = function(parameters) {
859
935
  .off('scroll' + elementNamespace, module.hide)
860
936
  ;
861
937
  }
938
+ if(settings.on == 'hover' && openedWithTouch) {
939
+ $document
940
+ .off('touchstart' + elementNamespace)
941
+ ;
942
+ openedWithTouch = false;
943
+ }
862
944
  if(settings.on == 'click' && settings.closable) {
863
945
  module.verbose('Removing close event from document');
864
946
  $document
@@ -879,10 +961,10 @@ $.fn.popup = function(parameters) {
879
961
  return $module.hasClass(className.active);
880
962
  },
881
963
  animating: function() {
882
- return ( $popup && $popup.is(':animated') || $popup.hasClass(className.animating) );
964
+ return ( $popup && $popup.hasClass(className.animating) );
883
965
  },
884
966
  visible: function() {
885
- return $popup && $popup.is(':visible');
967
+ return $popup && $popup.hasClass(className.visible);
886
968
  },
887
969
  dropdown: function() {
888
970
  return $module.hasClass(className.dropdown);
@@ -977,7 +1059,7 @@ $.fn.popup = function(parameters) {
977
1059
  });
978
1060
  }
979
1061
  clearTimeout(module.performance.timer);
980
- module.performance.timer = setTimeout(module.performance.display, 100);
1062
+ module.performance.timer = setTimeout(module.performance.display, 500);
981
1063
  },
982
1064
  display: function() {
983
1065
  var
@@ -1088,61 +1170,115 @@ $.fn.popup.settings = {
1088
1170
 
1089
1171
  name : 'Popup',
1090
1172
 
1173
+ // module settings
1091
1174
  debug : false,
1092
- verbose : true,
1175
+ verbose : false,
1093
1176
  performance : true,
1094
1177
  namespace : 'popup',
1095
1178
 
1179
+ // callback only when element added to dom
1096
1180
  onCreate : function(){},
1181
+
1182
+ // callback before element removed from dom
1097
1183
  onRemove : function(){},
1098
1184
 
1185
+ // callback before show animation
1099
1186
  onShow : function(){},
1187
+
1188
+ // callback after show animation
1100
1189
  onVisible : function(){},
1190
+
1191
+ // callback before hide animation
1101
1192
  onHide : function(){},
1193
+
1194
+ // callback after hide animation
1102
1195
  onHidden : function(){},
1103
1196
 
1197
+ // when to show popup
1198
+ on : 'hover',
1199
+
1200
+ // whether to add touchstart events when using hover
1201
+ addTouchEvents : true,
1202
+
1203
+ // default position relative to element
1204
+ position : 'top left',
1205
+
1206
+ // name of variation to use
1104
1207
  variation : '',
1208
+
1209
+ // whether popup should be moved to context
1210
+ movePopup : true,
1211
+
1212
+ // element which popup should be relative to
1213
+ target : false,
1214
+
1215
+ // jq selector or element that should be used as popup
1216
+ popup : false,
1217
+
1218
+ // popup should remain inline next to activator
1219
+ inline : false,
1220
+
1221
+ // popup should be removed from page on hide
1222
+ preserve : true,
1223
+
1224
+ // popup should not close when being hovered on
1225
+ hoverable : false,
1226
+
1227
+ // explicitly set content
1105
1228
  content : false,
1229
+
1230
+ // explicitly set html
1106
1231
  html : false,
1232
+
1233
+ // explicitly set title
1107
1234
  title : false,
1108
1235
 
1109
- on : 'hover',
1236
+ // whether automatically close on clickaway when on click
1110
1237
  closable : true,
1238
+
1239
+ // automatically hide on scroll
1111
1240
  hideOnScroll : 'auto',
1112
- exclusive : true,
1113
1241
 
1242
+ // hide other popups on show
1243
+ exclusive : false,
1244
+
1245
+ // context to attach popups
1114
1246
  context : 'body',
1115
1247
 
1116
- position : 'top left',
1248
+ // position to prefer when calculating new position
1117
1249
  prefer : 'opposite',
1250
+
1251
+ // specify position to appear even if it doesn't fit
1118
1252
  lastResort : false,
1119
1253
 
1254
+ // delay used to prevent accidental refiring of animations due to user error
1120
1255
  delay : {
1121
- show : 30,
1122
- hide : 0
1256
+ show : 50,
1257
+ hide : 70
1123
1258
  },
1124
1259
 
1260
+ // whether fluid variation should assign width explicitly
1125
1261
  setFluidWidth : true,
1126
- movePopup : true,
1127
-
1128
- target : false,
1129
- popup : false,
1130
- inline : false,
1131
- preserve : false,
1132
- hoverable : false,
1133
1262
 
1263
+ // transition settings
1134
1264
  duration : 200,
1135
- easing : 'easeOutQuint',
1136
1265
  transition : 'scale',
1137
1266
 
1267
+ // distance away from activating element in px
1138
1268
  distanceAway : 0,
1269
+
1270
+ // offset on aligning axis from calculated position
1139
1271
  offset : 0,
1272
+
1273
+ // maximum times to look for a position before failing (9 positions total)
1140
1274
  maxSearchDepth : 20,
1141
1275
 
1142
1276
  error: {
1143
1277
  invalidPosition : 'The position you specified is not a valid position',
1144
1278
  cannotPlace : 'No visible position could be found for the popup',
1145
- method : 'The method you called is not defined.'
1279
+ method : 'The method you called is not defined.',
1280
+ noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>',
1281
+ notFound : 'The target or popup you specified does not exist on the page'
1146
1282
  },
1147
1283
 
1148
1284
  metadata: {
@@ -1213,12 +1349,5 @@ $.fn.popup.settings = {
1213
1349
 
1214
1350
  };
1215
1351
 
1216
- // Adds easing
1217
- $.extend( $.easing, {
1218
- easeOutQuad: function (x, t, b, c, d) {
1219
- return -c *(t/=d)*(t-2) + b;
1220
- }
1221
- });
1222
-
1223
1352
 
1224
1353
  })( jQuery, window , document );