fomantic-ui-sass 2.9.0 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/app/assets/fonts/semantic-ui/Lato-Bold.woff +0 -0
  4. data/app/assets/fonts/semantic-ui/Lato-Bold.woff2 +0 -0
  5. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff +0 -0
  6. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff2 +0 -0
  7. data/app/assets/fonts/semantic-ui/Lato-Italic.woff +0 -0
  8. data/app/assets/fonts/semantic-ui/Lato-Italic.woff2 +0 -0
  9. data/app/assets/fonts/semantic-ui/Lato-Regular.woff +0 -0
  10. data/app/assets/fonts/semantic-ui/Lato-Regular.woff2 +0 -0
  11. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff +0 -0
  12. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff2 +0 -0
  13. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff +0 -0
  14. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff2 +0 -0
  15. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff +0 -0
  16. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff2 +0 -0
  17. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff +0 -0
  18. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff2 +0 -0
  19. data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
  20. data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
  21. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  22. data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
  23. data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
  24. data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
  25. data/app/assets/javascripts/semantic-ui/accordion.js +569 -596
  26. data/app/assets/javascripts/semantic-ui/api.js +1158 -1180
  27. data/app/assets/javascripts/semantic-ui/calendar.js +1935 -1810
  28. data/app/assets/javascripts/semantic-ui/checkbox.js +843 -842
  29. data/app/assets/javascripts/semantic-ui/dimmer.js +707 -738
  30. data/app/assets/javascripts/semantic-ui/dropdown.js +4196 -4237
  31. data/app/assets/javascripts/semantic-ui/embed.js +646 -676
  32. data/app/assets/javascripts/semantic-ui/flyout.js +1503 -1466
  33. data/app/assets/javascripts/semantic-ui/form.js +2035 -2007
  34. data/app/assets/javascripts/semantic-ui/modal.js +1552 -1487
  35. data/app/assets/javascripts/semantic-ui/nag.js +521 -527
  36. data/app/assets/javascripts/semantic-ui/popup.js +1469 -1457
  37. data/app/assets/javascripts/semantic-ui/progress.js +944 -998
  38. data/app/assets/javascripts/semantic-ui/rating.js +508 -524
  39. data/app/assets/javascripts/semantic-ui/search.js +1521 -1535
  40. data/app/assets/javascripts/semantic-ui/shape.js +762 -811
  41. data/app/assets/javascripts/semantic-ui/sidebar.js +1042 -1100
  42. data/app/assets/javascripts/semantic-ui/site.js +437 -477
  43. data/app/assets/javascripts/semantic-ui/slider.js +1311 -1312
  44. data/app/assets/javascripts/semantic-ui/state.js +639 -658
  45. data/app/assets/javascripts/semantic-ui/sticky.js +848 -902
  46. data/app/assets/javascripts/semantic-ui/tab.js +903 -967
  47. data/app/assets/javascripts/semantic-ui/toast.js +911 -885
  48. data/app/assets/javascripts/semantic-ui/transition.js +998 -1078
  49. data/app/assets/javascripts/semantic-ui/visibility.js +1214 -1246
  50. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +7 -7
  51. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +311 -377
  52. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +191 -331
  53. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +302 -439
  54. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +127 -199
  55. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +549 -776
  56. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +711 -1123
  57. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +9 -8
  58. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +45 -63
  59. data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +3558 -3558
  60. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +272 -270
  61. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +120 -144
  62. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +667 -747
  63. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +41 -65
  64. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +416 -300
  65. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +361 -412
  66. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +51 -72
  67. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +69 -157
  68. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +24 -44
  69. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +17 -22
  70. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +46 -85
  71. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +173 -227
  72. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +79 -152
  73. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +34 -34
  74. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +10 -15
  75. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +29 -51
  76. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +37 -55
  77. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +26 -29
  78. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +159 -230
  79. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +55 -174
  80. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +261 -393
  81. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +21 -32
  82. data/app/assets/stylesheets/semantic-ui/modules/_flyout.scss +97 -143
  83. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +122 -156
  84. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +55 -65
  85. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +573 -206
  86. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +108 -213
  87. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +83 -124
  88. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +71 -100
  89. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +16 -32
  90. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +105 -208
  91. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +102 -127
  92. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +3 -7
  93. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +12 -16
  94. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +71 -149
  95. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +371 -1282
  96. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +36 -47
  97. data/app/assets/stylesheets/semantic-ui/views/_card.scss +221 -367
  98. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +43 -61
  99. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +37 -59
  100. data/app/assets/stylesheets/semantic-ui/views/_item.scss +87 -134
  101. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +77 -118
  102. data/lib/fomantic/ui/sass/version.rb +2 -2
  103. data/tasks/converter.rb +1 -1
  104. metadata +17 -1
@@ -1,926 +1,952 @@
1
1
  /*!
2
2
  * # Fomantic-UI - Toast
3
- * http://github.com/fomantic/Fomantic-UI/
3
+ * https://github.com/fomantic/Fomantic-UI/
4
4
  *
5
5
  *
6
6
  * Released under the MIT license
7
- * http://opensource.org/licenses/MIT
7
+ * https://opensource.org/licenses/MIT
8
8
  *
9
9
  */
10
10
 
11
- ;(function ($, window, document, undefined) {
12
-
13
- 'use strict';
14
-
15
- $.isFunction = $.isFunction || function(obj) {
16
- return typeof obj === "function" && typeof obj.nodeType !== "number";
17
- };
18
-
19
- window = (typeof window != 'undefined' && window.Math == Math)
20
- ? window
21
- : (typeof self != 'undefined' && self.Math == Math)
22
- ? self
23
- : Function('return this')()
24
- ;
25
-
26
- $.toast = $.fn.toast = function(parameters) {
27
- var
28
- $allModules = $(this),
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
- returnedValue
38
- ;
39
- $allModules
40
- .each(function() {
41
- var
42
- settings = ( $.isPlainObject(parameters) )
43
- ? $.extend(true, {}, $.fn.toast.settings, parameters)
44
- : $.extend({}, $.fn.toast.settings),
45
-
46
- className = settings.className,
47
- selector = settings.selector,
48
- error = settings.error,
49
- namespace = settings.namespace,
50
- fields = settings.fields,
51
-
52
- eventNamespace = '.' + namespace,
53
- moduleNamespace = namespace + '-module',
54
-
55
- $module = $(this),
56
- $toastBox,
57
- $toast,
58
- $actions,
59
- $progress,
60
- $progressBar,
61
- $animationObject,
62
- $close,
63
- $context = (settings.context)
64
- ? ([window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context))
65
- : $('body'),
66
-
67
- isToastComponent = $module.hasClass('toast') || $module.hasClass('message') || $module.hasClass('card'),
68
-
69
- element = this,
70
- instance = isToastComponent ? $module.data(moduleNamespace) : undefined,
71
-
72
- id,
73
- module
74
- ;
75
- module = {
76
-
77
- initialize: function() {
78
- module.verbose('Initializing element');
79
- module.create.id();
80
- if (!module.has.container()) {
81
- module.create.container();
82
- }
83
- if(isToastComponent || settings.message !== '' || settings.title !== '' || module.get.iconClass() !== '' || settings.showImage || module.has.configActions()) {
84
- if(typeof settings.showProgress !== 'string' || [className.top,className.bottom].indexOf(settings.showProgress) === -1 ) {
85
- settings.showProgress = false;
86
- }
87
- module.create.toast();
88
- if(settings.closeOnClick && (settings.closeIcon || $($toast).find(selector.input).length > 0 || module.has.configActions())){
89
- settings.closeOnClick = false;
90
- }
91
- if(!settings.closeOnClick) {
92
- $toastBox.addClass(className.unclickable);
93
- }
94
- module.bind.events();
95
- }
96
- module.instantiate();
97
- if($toastBox) {
98
- module.show();
99
- }
100
- },
11
+ (function ($, window, document) {
12
+ 'use strict';
101
13
 
102
- instantiate: function() {
103
- module.verbose('Storing instance of toast');
104
- instance = module;
105
- $module
106
- .data(moduleNamespace, instance)
107
- ;
108
- },
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
109
17
 
110
- destroy: function() {
111
- if($toastBox) {
112
- module.debug('Removing toast', $toastBox);
113
- module.unbind.events();
114
- $toastBox.remove();
115
- $toastBox = undefined;
116
- $toast = undefined;
117
- $animationObject = undefined;
118
- settings.onRemove.call($toastBox, element);
119
- $progress = undefined;
120
- $progressBar = undefined;
121
- $close = undefined;
122
- }
123
- $module
124
- .removeData(moduleNamespace)
125
- ;
126
- },
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
127
21
 
128
- show: function(callback) {
129
- if(settings.onShow.call($toastBox, element) === false) {
130
- module.debug('onShow callback returned false, cancelling toast animation');
131
- return;
132
- }
133
- callback = callback || function(){};
134
- module.debug('Showing toast');
135
- module.animate.show(callback);
136
- },
22
+ $.fn.toast = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ moduleSelector = $allModules.selector || '',
137
26
 
138
- close: function(callback) {
139
- if(settings.onHide.call($toastBox, element) === false) {
140
- module.debug('onHide callback returned false, cancelling toast animation');
141
- return;
142
- }
143
- callback = callback || function(){};
144
- module.debug('Closing toast');
145
- module.remove.visible();
146
- module.unbind.events();
147
- module.animate.close(callback);
27
+ time = Date.now(),
28
+ performance = [],
148
29
 
149
- },
30
+ query = arguments[0],
31
+ methodInvoked = typeof query === 'string',
32
+ queryArguments = [].slice.call(arguments, 1),
33
+ returnedValue
34
+ ;
35
+ $allModules.each(function () {
36
+ var
37
+ settings = $.isPlainObject(parameters)
38
+ ? $.extend(true, {}, $.fn.toast.settings, parameters)
39
+ : $.extend({}, $.fn.toast.settings),
40
+
41
+ className = settings.className,
42
+ selector = settings.selector,
43
+ error = settings.error,
44
+ namespace = settings.namespace,
45
+ fields = settings.fields,
46
+
47
+ eventNamespace = '.' + namespace,
48
+ moduleNamespace = namespace + '-module',
49
+
50
+ $module = $(this),
51
+ $toastBox,
52
+ $toast,
53
+ $actions,
54
+ $progress,
55
+ $progressBar,
56
+ $animationObject,
57
+ $close,
58
+ $context = settings.context
59
+ ? ([window, document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context))
60
+ : $('body'),
61
+
62
+ isToastComponent = $module.hasClass('toast') || $module.hasClass('message') || $module.hasClass('card'),
63
+
64
+ element = this,
65
+ instance = isToastComponent ? $module.data(moduleNamespace) : undefined,
66
+
67
+ id,
68
+ module
69
+ ;
70
+ module = {
150
71
 
151
- create: {
152
- container: function() {
153
- module.verbose('Creating container');
154
- $context.append($('<div/>',{class: settings.position + ' ' + className.container + ' ' +(settings.horizontal ? className.horizontal : '') + ' ' + (settings.context && settings.context !== 'body' ? className.absolute : '')}));
155
- },
156
- id: function() {
157
- id = (Math.random().toString(16) + '000000000').slice(2, 10);
158
- module.verbose('Creating unique id for element', id);
159
- },
160
- toast: function() {
161
- $toastBox = $('<div/>', {class: className.box});
162
- var iconClass = module.get.iconClass();
163
- if (!isToastComponent) {
164
- module.verbose('Creating toast');
165
- $toast = $('<div/>', {role: 'alert'});
166
- var $content = $('<div/>', {class: className.content});
167
- if (iconClass !== '') {
168
- $toast.append($('<i/>', {class: iconClass + ' ' + className.icon}));
169
- }
170
-
171
- if (settings.showImage) {
172
- $toast.append($('<img>', {
173
- class: className.image + ' ' + settings.classImage,
174
- src: settings.showImage
175
- }));
176
- }
177
- if (settings.title !== '') {
178
- var titleId = '_' + module.get.id() + 'title';
179
- $toast.attr('aria-labelledby', titleId);
180
- $content.append($('<div/>', {
181
- class: className.title,
182
- id: titleId,
183
- html: module.helpers.escape(settings.title, settings.preserveHTML)
184
- }));
185
- }
186
- var descId = '_' + module.get.id() + 'desc';
187
- $toast.attr('aria-describedby', descId);
188
- $content.append($('<div/>', {
189
- class: className.message,
190
- id: descId,
191
- html: module.helpers.escape(settings.message, settings.preserveHTML)
192
- }));
193
-
194
- $toast
195
- .addClass(settings.class + ' ' + className.toast)
196
- .append($content)
197
- ;
198
- $toast.css('opacity', settings.opacity);
199
- if (settings.closeIcon) {
200
- $close = $('<i/>', {class: className.close + ' ' + (typeof settings.closeIcon === 'string' ? settings.closeIcon : ''), role: 'button', tabindex: 0, 'aria-label': settings.text.close});
201
- if($close.hasClass(className.left)) {
202
- $toast.prepend($close);
203
- } else {
204
- $toast.append($close);
205
- }
206
- }
207
- } else {
208
- $toast = settings.cloneModule ? $module.clone().removeAttr('id') : $module;
209
- $close = $toast.find('> i'+module.helpers.toClass(className.close));
210
- settings.closeIcon = ($close.length > 0);
211
- if (iconClass !== '') {
212
- $toast.find(selector.icon).attr('class',iconClass + ' ' + className.icon);
213
- }
214
- if (settings.showImage) {
215
- $toast.find(selector.image).attr('src',settings.showImage);
216
- }
217
- if (settings.title !== '') {
218
- $toast.find(selector.title).html(module.helpers.escape(settings.title, settings.preserveHTML));
219
- }
220
- if (settings.message !== '') {
221
- $toast.find(selector.message).html(module.helpers.escape(settings.message, settings.preserveHTML));
222
- }
223
- }
224
- if ($toast.hasClass(className.compact)) {
225
- settings.compact = true;
226
- }
227
- if ($toast.hasClass('card')) {
228
- settings.compact = false;
229
- }
230
- $actions = $toast.find('.actions');
231
- if (module.has.configActions()) {
232
- if ($actions.length === 0) {
233
- $actions = $('<div/>', {class: className.actions + ' ' + (settings.classActions || '')}).appendTo($toast);
234
- }
235
- if($toast.hasClass('card') && !$actions.hasClass(className.attached)) {
236
- $actions.addClass(className.extraContent);
237
- if($actions.hasClass(className.vertical)) {
238
- $actions.removeClass(className.vertical);
239
- module.error(error.verticalCard);
240
- }
241
- }
242
- settings.actions.forEach(function (el) {
243
- var icon = el[fields.icon] ? '<i '+(el[fields.text] ? 'aria-hidden="true"' : '')+' class="' + module.helpers.deQuote(el[fields.icon]) + ' icon"></i>' : '',
244
- text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML),
245
- cls = module.helpers.deQuote(el[fields.class] || ''),
246
- click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {};
247
- $actions.append($('<button/>', {
248
- html: icon + text,
249
- 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''),
250
- class: className.button + ' ' + cls,
251
- click: function () {
252
- var button = $(this);
253
- if (button.is(selector.approve) || button.is(selector.deny) || click.call(element, $module) === false) {
254
- return;
72
+ initialize: function () {
73
+ module.verbose('Initializing element');
74
+ module.create.id();
75
+ if (!module.has.container()) {
76
+ module.create.container();
255
77
  }
256
- module.close();
257
- }
258
- }));
259
- });
260
- }
261
- if ($actions && $actions.hasClass(className.vertical)) {
262
- $toast.addClass(className.vertical);
263
- }
264
- if($actions.length > 0 && !$actions.hasClass(className.attached)) {
265
- if ($actions && (!$actions.hasClass(className.basic) || $actions.hasClass(className.left))) {
266
- $toast.addClass(className.actions);
267
- }
268
- }
269
- if(settings.displayTime === 'auto'){
270
- settings.displayTime = Math.max(settings.minDisplayTime, $toast.text().split(" ").length / settings.wordsPerMinute * 60000);
271
- }
272
- $toastBox.append($toast);
273
-
274
- if($actions.length > 0 && $actions.hasClass(className.attached)) {
275
- $actions.addClass(className.buttons);
276
- $actions.detach();
277
- $toast.addClass(className.attached);
278
- if (!$actions.hasClass(className.vertical)) {
279
- if ($actions.hasClass(className.top)) {
280
- $toastBox.prepend($actions);
281
- $toast.addClass(className.bottom);
282
- } else {
283
- $toastBox.append($actions);
284
- $toast.addClass(className.top);
285
- }
286
- } else {
287
- $toast.wrap(
288
- $('<div/>',{
289
- class:className.vertical + ' ' +
290
- className.attached + ' ' +
291
- (settings.compact ? className.compact : '')
292
- })
293
- );
294
- if($actions.hasClass(className.left)) {
295
- $toast.addClass(className.left).parent().addClass(className.left).prepend($actions);
296
- } else {
297
- $toast.parent().append($actions);
298
- }
299
- }
300
- }
301
- if($module !== $toast) {
302
- $module = $toast;
303
- element = $toast[0];
304
- }
305
- if(settings.displayTime > 0) {
306
- var progressingClass = className.progressing+' '+(settings.pauseOnHover ? className.pausable:'');
307
- if (!!settings.showProgress) {
308
- $progress = $('<div/>', {
309
- class: className.progress + ' ' + (settings.classProgress || settings.class),
310
- 'data-percent': ''
311
- });
312
- if(!settings.classProgress) {
313
- if ($toast.hasClass('toast') && !$toast.hasClass(className.inverted)) {
314
- $progress.addClass(className.inverted);
315
- } else {
316
- $progress.removeClass(className.inverted);
317
- }
318
- }
319
- $progressBar = $('<div/>', {class: 'bar '+(settings.progressUp ? 'up ' : 'down ')+progressingClass});
320
- $progress
321
- .addClass(settings.showProgress)
322
- .append($progressBar);
323
- if ($progress.hasClass(className.top)) {
324
- $toastBox.prepend($progress);
325
- } else {
326
- $toastBox.append($progress);
327
- }
328
- $progressBar.css('animation-duration', settings.displayTime / 1000 + 's');
329
- }
330
- $animationObject = $('<span/>',{class:'wait '+progressingClass});
331
- $animationObject.css('animation-duration', settings.displayTime / 1000 + 's');
332
- $animationObject.appendTo($toast);
333
- }
334
- if (settings.compact) {
335
- $toastBox.addClass(className.compact);
336
- $toast.addClass(className.compact);
337
- if($progress) {
338
- $progress.addClass(className.compact);
339
- }
340
- }
341
- if (settings.newestOnTop) {
342
- $toastBox.prependTo(module.get.container());
343
- }
344
- else {
345
- $toastBox.appendTo(module.get.container());
346
- }
347
- }
348
- },
78
+ if (isToastComponent || settings.message !== '' || settings.title !== '' || module.get.iconClass() !== '' || settings.showImage || module.has.configActions()) {
79
+ if (typeof settings.showProgress !== 'string' || [className.top, className.bottom].indexOf(settings.showProgress) === -1) {
80
+ settings.showProgress = false;
81
+ }
82
+ module.create.toast();
83
+ if (settings.closeOnClick && (settings.closeIcon || $($toast).find(selector.input).length > 0 || module.has.configActions())) {
84
+ settings.closeOnClick = false;
85
+ }
86
+ if (!settings.closeOnClick) {
87
+ $toastBox.addClass(className.unclickable);
88
+ }
89
+ module.bind.events();
90
+ }
91
+ module.instantiate();
92
+ if ($toastBox) {
93
+ module.show();
94
+ }
95
+ },
96
+
97
+ instantiate: function () {
98
+ module.verbose('Storing instance of toast');
99
+ instance = module;
100
+ $module
101
+ .data(moduleNamespace, instance)
102
+ ;
103
+ },
104
+
105
+ destroy: function () {
106
+ if ($toastBox) {
107
+ module.debug('Removing toast', $toastBox);
108
+ module.unbind.events();
109
+ $toastBox.remove();
110
+ $toastBox = undefined;
111
+ $toast = undefined;
112
+ $animationObject = undefined;
113
+ settings.onRemove.call($toastBox, element);
114
+ $progress = undefined;
115
+ $progressBar = undefined;
116
+ $close = undefined;
117
+ }
118
+ $module
119
+ .removeData(moduleNamespace)
120
+ ;
121
+ },
349
122
 
350
- bind: {
351
- events: function() {
352
- module.debug('Binding events to toast');
353
- if(settings.closeIcon) {
354
- $close.on('click' + eventNamespace, module.event.close);
355
- }
356
- $toast.on('click' + eventNamespace, module.event.click);
357
- if($animationObject) {
358
- $animationObject.on('animationend' + eventNamespace, module.event.close);
359
- }
360
- $toastBox
361
- .on('click' + eventNamespace, selector.approve, module.event.approve)
362
- .on('click' + eventNamespace, selector.deny, module.event.deny)
363
- ;
364
- }
365
- },
123
+ show: function (callback) {
124
+ if (settings.onShow.call($toastBox, element) === false) {
125
+ module.debug('onShow callback returned false, cancelling toast animation');
366
126
 
367
- unbind: {
368
- events: function() {
369
- module.debug('Unbinding events to toast');
370
- if(settings.closeIcon) {
371
- $close.off('click' + eventNamespace);
372
- }
373
- $toast.off('click' + eventNamespace);
374
- if($animationObject) {
375
- $animationObject.off('animationend' + eventNamespace);
376
- }
377
- $toastBox
378
- .off('click' + eventNamespace)
379
- ;
380
- }
381
- },
127
+ return;
128
+ }
129
+ callback = callback || function () {};
130
+ module.debug('Showing toast');
131
+ module.animate.show(callback);
132
+ },
382
133
 
383
- animate: {
384
- show: function(callback) {
385
- callback = $.isFunction(callback) ? callback : function(){};
386
- if(settings.transition && module.can.useElement('transition') && $module.transition('is supported')) {
387
- module.set.visible();
388
- $toastBox
389
- .transition({
390
- animation : settings.transition.showMethod + ' in',
391
- queue : false,
392
- debug : settings.debug,
393
- verbose : settings.verbose,
394
- silent : settings.silent,
395
- duration : settings.transition.showDuration,
396
- onComplete : function() {
397
- callback.call($toastBox, element);
398
- settings.onVisible.call($toastBox, element);
399
- }
400
- })
401
- ;
402
- }
403
- },
404
- close: function(callback) {
405
- callback = $.isFunction(callback) ? callback : function(){};
406
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
407
- $toastBox
408
- .transition({
409
- animation : settings.transition.hideMethod + ' out',
410
- queue : false,
411
- duration : settings.transition.hideDuration,
412
- debug : settings.debug,
413
- verbose : settings.verbose,
414
- silent : settings.silent,
415
- interval : 50,
416
-
417
- onBeforeHide: function(callback){
418
- callback = $.isFunction(callback)?callback : function(){};
419
- if(settings.transition.closeEasing !== ''){
420
- if($toastBox) {
421
- $toastBox.css('opacity', 0);
422
- $toastBox.wrap('<div/>').parent().hide(settings.transition.closeDuration, settings.transition.closeEasing, function () {
423
- if ($toastBox) {
424
- $toastBox.parent().remove();
425
- callback.call($toastBox);
426
- }
134
+ close: function (callback) {
135
+ if (settings.onHide.call($toastBox, element) === false) {
136
+ module.debug('onHide callback returned false, cancelling toast animation');
137
+
138
+ return;
139
+ }
140
+ callback = callback || function () {};
141
+ module.debug('Closing toast');
142
+ module.remove.visible();
143
+ module.unbind.events();
144
+ module.animate.close(callback);
145
+ },
146
+
147
+ create: {
148
+ container: function () {
149
+ module.verbose('Creating container');
150
+ $context.append($('<div/>', {
151
+ class: settings.position + ' ' + className.container + ' '
152
+ + (settings.horizontal ? className.horizontal : '') + ' '
153
+ + (settings.context && settings.context !== 'body' ? className.absolute : ''),
154
+ }));
155
+ },
156
+ id: function () {
157
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
158
+ module.verbose('Creating unique id for element', id);
159
+ },
160
+ toast: function () {
161
+ $toastBox = $('<div/>', { class: className.box });
162
+ var iconClass = module.get.iconClass();
163
+ if (!isToastComponent) {
164
+ module.verbose('Creating toast');
165
+ $toast = $('<div/>', { role: 'alert' });
166
+ var $content = $('<div/>', { class: className.content });
167
+ if (iconClass !== '') {
168
+ $toast.append($('<i/>', { class: iconClass + ' ' + className.icon }));
169
+ }
170
+
171
+ if (settings.showImage) {
172
+ $toast.append($('<img>', {
173
+ class: className.image + ' ' + settings.classImage,
174
+ src: settings.showImage,
175
+ }));
176
+ }
177
+ if (settings.title !== '') {
178
+ var titleId = '_' + module.get.id() + 'title';
179
+ $toast.attr('aria-labelledby', titleId);
180
+ $content.append($('<div/>', {
181
+ class: className.title,
182
+ id: titleId,
183
+ html: module.helpers.escape(settings.title, settings.preserveHTML),
184
+ }));
185
+ }
186
+ var descId = '_' + module.get.id() + 'desc';
187
+ $toast.attr('aria-describedby', descId);
188
+ $content.append($('<div/>', {
189
+ class: className.message,
190
+ id: descId,
191
+ html: module.helpers.escape(settings.message, settings.preserveHTML),
192
+ }));
193
+
194
+ $toast
195
+ .addClass(settings.class + ' ' + className.toast)
196
+ .append($content)
197
+ ;
198
+ $toast.css('opacity', String(settings.opacity));
199
+ if (settings.closeIcon) {
200
+ $close = $('<i/>', {
201
+ class: className.close + ' ' + (typeof settings.closeIcon === 'string' ? settings.closeIcon : ''),
202
+ role: 'button',
203
+ tabindex: 0,
204
+ 'aria-label': settings.text.close,
205
+ });
206
+ if ($close.hasClass(className.left)) {
207
+ $toast.prepend($close);
208
+ } else {
209
+ $toast.append($close);
210
+ }
211
+ }
212
+ } else {
213
+ $toast = settings.cloneModule ? $module.clone().removeAttr('id') : $module;
214
+ $close = $toast.find('> i' + module.helpers.toClass(className.close));
215
+ settings.closeIcon = $close.length > 0;
216
+ if (iconClass !== '') {
217
+ $toast.find(selector.icon).attr('class', iconClass + ' ' + className.icon);
218
+ }
219
+ if (settings.showImage) {
220
+ $toast.find(selector.image).attr('src', settings.showImage);
221
+ }
222
+ if (settings.title !== '') {
223
+ $toast.find(selector.title).html(module.helpers.escape(settings.title, settings.preserveHTML));
224
+ }
225
+ if (settings.message !== '') {
226
+ $toast.find(selector.message).html(module.helpers.escape(settings.message, settings.preserveHTML));
227
+ }
228
+ }
229
+ if ($toast.hasClass(className.compact)) {
230
+ settings.compact = true;
231
+ }
232
+ if ($toast.hasClass('card')) {
233
+ settings.compact = false;
234
+ }
235
+ $actions = $toast.find('.actions');
236
+ if (module.has.configActions()) {
237
+ if ($actions.length === 0) {
238
+ $actions = $('<div/>', { class: className.actions + ' ' + (settings.classActions || '') }).appendTo($toast);
239
+ }
240
+ if ($toast.hasClass('card') && !$actions.hasClass(className.attached)) {
241
+ $actions.addClass(className.extraContent);
242
+ if ($actions.hasClass(className.vertical)) {
243
+ $actions.removeClass(className.vertical);
244
+ module.error(error.verticalCard);
245
+ }
246
+ }
247
+ settings.actions.forEach(function (el) {
248
+ var
249
+ icon = el[fields.icon]
250
+ ? '<i ' + (el[fields.text] ? 'aria-hidden="true"' : '')
251
+ + ' class="' + module.helpers.deQuote(el[fields.icon]) + ' icon"></i>'
252
+ : '',
253
+ text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML),
254
+ cls = module.helpers.deQuote(el[fields.class] || ''),
255
+ click = el[fields.click] && isFunction(el[fields.click])
256
+ ? el[fields.click]
257
+ : function () {}
258
+ ;
259
+ $actions.append($('<button/>', {
260
+ html: icon + text,
261
+ 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g, ''),
262
+ class: className.button + ' ' + cls,
263
+ on: {
264
+ click: function () {
265
+ var $button = $(this);
266
+ if ($button.is(selector.approve) || $button.is(selector.deny) || click.call(element, $module) === false) {
267
+ return;
268
+ }
269
+ module.close();
270
+ },
271
+ },
272
+ }));
427
273
  });
428
- }
429
- } else {
430
- callback.call($toastBox);
431
- }
432
- },
433
- onComplete : function() {
434
- callback.call($toastBox, element);
435
- settings.onHidden.call($toastBox, element);
436
- module.destroy();
437
- }
438
- })
439
- ;
440
- }
441
- else {
442
- module.error(error.noTransition);
443
- }
444
- },
445
- pause: function() {
446
- $animationObject.css('animationPlayState','paused');
447
- if($progressBar) {
448
- $progressBar.css('animationPlayState', 'paused');
449
- }
450
- },
451
- continue: function() {
452
- $animationObject.css('animationPlayState','running');
453
- if($progressBar) {
454
- $progressBar.css('animationPlayState', 'running');
455
- }
456
- }
274
+ }
275
+ if ($actions && $actions.hasClass(className.vertical)) {
276
+ $toast.addClass(className.vertical);
277
+ }
278
+ if ($actions.length > 0 && !$actions.hasClass(className.attached)) {
279
+ if ($actions && (!$actions.hasClass(className.basic) || $actions.hasClass(className.left))) {
280
+ $toast.addClass(className.actions);
281
+ }
282
+ }
283
+ if (settings.displayTime === 'auto') {
284
+ settings.displayTime = Math.max(settings.minDisplayTime, ($toast.text().split(' ').length / settings.wordsPerMinute) * 60000);
285
+ }
286
+ $toastBox.append($toast);
287
+
288
+ if ($actions.length > 0 && $actions.hasClass(className.attached)) {
289
+ $actions.addClass(className.buttons);
290
+ $actions.detach();
291
+ $toast.addClass(className.attached);
292
+ if (!$actions.hasClass(className.vertical)) {
293
+ if ($actions.hasClass(className.top)) {
294
+ $toastBox.prepend($actions);
295
+ $toast.addClass(className.bottom);
296
+ } else {
297
+ $toastBox.append($actions);
298
+ $toast.addClass(className.top);
299
+ }
300
+ } else {
301
+ $toast.wrap(
302
+ $('<div/>', {
303
+ class: className.vertical + ' '
304
+ + className.attached + ' '
305
+ + (settings.compact ? className.compact : ''),
306
+ })
307
+ );
308
+ if ($actions.hasClass(className.left)) {
309
+ $toast.addClass(className.left).parent().addClass(className.left).prepend($actions);
310
+ } else {
311
+ $toast.parent().append($actions);
312
+ }
313
+ }
314
+ }
315
+ if ($module !== $toast) {
316
+ $module = $toast;
317
+ element = $toast[0];
318
+ }
319
+ if (settings.displayTime > 0) {
320
+ var progressingClass = className.progressing + ' ' + (settings.pauseOnHover ? className.pausable : '');
321
+ if (settings.showProgress) {
322
+ $progress = $('<div/>', {
323
+ class: className.progress + ' ' + (settings.classProgress || settings.class),
324
+ 'data-percent': '',
325
+ });
326
+ if (!settings.classProgress) {
327
+ if ($toast.hasClass('toast') && !$toast.hasClass(className.inverted)) {
328
+ $progress.addClass(className.inverted);
329
+ } else {
330
+ $progress.removeClass(className.inverted);
331
+ }
332
+ }
333
+ $progressBar = $('<div/>', { class: 'bar ' + (settings.progressUp ? 'up ' : 'down ') + progressingClass });
334
+ $progress
335
+ .addClass(settings.showProgress)
336
+ .append($progressBar)
337
+ ;
338
+ if ($progress.hasClass(className.top)) {
339
+ $toastBox.prepend($progress);
340
+ } else {
341
+ $toastBox.append($progress);
342
+ }
343
+ $progressBar.css('animation-duration', settings.displayTime / 1000 + 's');
344
+ }
345
+ $animationObject = $('<span/>', { class: 'wait ' + progressingClass });
346
+ $animationObject.css('animation-duration', settings.displayTime / 1000 + 's');
347
+ $animationObject.appendTo($toast);
348
+ }
349
+ if (settings.compact) {
350
+ $toastBox.addClass(className.compact);
351
+ $toast.addClass(className.compact);
352
+ if ($progress) {
353
+ $progress.addClass(className.compact);
354
+ }
355
+ }
356
+ if (settings.newestOnTop) {
357
+ $toastBox.prependTo(module.get.container());
358
+ } else {
359
+ $toastBox.appendTo(module.get.container());
360
+ }
361
+ },
362
+ },
363
+
364
+ bind: {
365
+ events: function () {
366
+ module.debug('Binding events to toast');
367
+ if (settings.closeIcon) {
368
+ $close.on('click' + eventNamespace, module.event.close);
369
+ }
370
+ $toast.on('click' + eventNamespace, module.event.click);
371
+ if ($animationObject) {
372
+ $animationObject.on('animationend' + eventNamespace, module.event.close);
373
+ }
374
+ $toastBox
375
+ .on('click' + eventNamespace, selector.approve, module.event.approve)
376
+ .on('click' + eventNamespace, selector.deny, module.event.deny)
377
+ ;
378
+ },
379
+ },
380
+
381
+ unbind: {
382
+ events: function () {
383
+ module.debug('Unbinding events to toast');
384
+ if (settings.closeIcon) {
385
+ $close.off('click' + eventNamespace);
386
+ }
387
+ $toast.off('click' + eventNamespace);
388
+ if ($animationObject) {
389
+ $animationObject.off('animationend' + eventNamespace);
390
+ }
391
+ $toastBox
392
+ .off('click' + eventNamespace)
393
+ ;
394
+ },
395
+ },
396
+
397
+ animate: {
398
+ show: function (callback) {
399
+ callback = isFunction(callback) ? callback : function () {};
400
+ if (settings.transition && module.can.useElement('transition')) {
401
+ module.set.visible();
402
+ $toastBox
403
+ .transition({
404
+ animation: settings.transition.showMethod + ' in',
405
+ queue: false,
406
+ debug: settings.debug,
407
+ verbose: settings.verbose,
408
+ silent: settings.silent,
409
+ duration: settings.transition.showDuration,
410
+ onComplete: function () {
411
+ callback.call($toastBox, element);
412
+ settings.onVisible.call($toastBox, element);
413
+ },
414
+ })
415
+ ;
416
+ }
417
+ },
418
+ close: function (callback) {
419
+ callback = isFunction(callback) ? callback : function () {};
420
+ if (settings.transition && $.fn.transition !== undefined) {
421
+ $toastBox
422
+ .transition({
423
+ animation: settings.transition.hideMethod + ' out',
424
+ queue: false,
425
+ duration: settings.transition.hideDuration,
426
+ debug: settings.debug,
427
+ verbose: settings.verbose,
428
+ silent: settings.silent,
429
+ interval: 50,
430
+
431
+ onBeforeHide: function (callback) {
432
+ callback = isFunction(callback) ? callback : function () {};
433
+ if (settings.transition.closeEasing !== '') {
434
+ if ($toastBox) {
435
+ $toastBox.css('opacity', '0');
436
+ $toastBox.wrap('<div/>').parent().hide(settings.transition.closeDuration, settings.transition.closeEasing, function () {
437
+ if ($toastBox) {
438
+ $toastBox.parent().remove();
439
+ callback.call($toastBox);
440
+ }
441
+ });
442
+ }
443
+ } else {
444
+ callback.call($toastBox);
445
+ }
446
+ },
447
+ onComplete: function () {
448
+ callback.call($toastBox, element);
449
+ settings.onHidden.call($toastBox, element);
450
+ module.destroy();
451
+ },
452
+ })
453
+ ;
454
+ } else {
455
+ module.error(error.noTransition);
456
+ }
457
+ },
458
+ pause: function () {
459
+ $animationObject.css('animationPlayState', 'paused');
460
+ if ($progressBar) {
461
+ $progressBar.css('animationPlayState', 'paused');
462
+ }
463
+ },
464
+ continue: function () {
465
+ $animationObject.css('animationPlayState', 'running');
466
+ if ($progressBar) {
467
+ $progressBar.css('animationPlayState', 'running');
468
+ }
469
+ },
470
+ },
471
+
472
+ has: {
473
+ container: function () {
474
+ module.verbose('Determining if there is already a container');
475
+
476
+ return module.get.containers().length > 0;
477
+ },
478
+ toast: function () {
479
+ return !!module.get.toast();
480
+ },
481
+ toasts: function () {
482
+ return module.get.toasts().length > 0;
483
+ },
484
+ configActions: function () {
485
+ return Array.isArray(settings.actions) && settings.actions.length > 0;
486
+ },
487
+ },
488
+
489
+ get: {
490
+ id: function () {
491
+ return id;
492
+ },
493
+ containers: function () {
494
+ return $context.children(module.helpers.toClass(settings.position) + selector.container
495
+ + (settings.horizontal
496
+ ? module.helpers.toClass(className.horizontal)
497
+ : ':not(' + module.helpers.toClass(className.horizontal) + ')')
498
+ + (settings.context && settings.context !== 'body'
499
+ ? module.helpers.toClass(className.absolute)
500
+ : ':not(' + module.helpers.toClass(className.absolute) + ')'));
501
+ },
502
+ container: function () {
503
+ return module.get.containers()[0];
504
+ },
505
+ toastBox: function () {
506
+ return $toastBox || null;
507
+ },
508
+ toast: function () {
509
+ return $toast || null;
510
+ },
511
+ toasts: function () {
512
+ return $(module.get.container()).find(selector.box);
513
+ },
514
+ iconClass: function () {
515
+ return typeof settings.showIcon === 'string'
516
+ ? settings.showIcon
517
+ : (settings.showIcon && settings.icons[settings.class]
518
+ ? settings.icons[settings.class]
519
+ : '');
520
+ },
521
+ remainingTime: function () {
522
+ return $animationObject ? $animationObject.css('opacity') * settings.displayTime : 0;
523
+ },
524
+ },
525
+
526
+ set: {
527
+ visible: function () {
528
+ $toast.addClass(className.visible);
529
+ },
530
+ },
531
+
532
+ remove: {
533
+ visible: function () {
534
+ $toast.removeClass(className.visible);
535
+ },
536
+ },
537
+
538
+ event: {
539
+ close: function () {
540
+ module.close();
541
+ },
542
+ click: function (event) {
543
+ if ($(event.target).closest(selector.clickable).length === 0) {
544
+ if (settings.onClick.call($toastBox, element) === false || !settings.closeOnClick) {
545
+ module.verbose('Click callback returned false or close denied by setting cancelling close');
546
+
547
+ return;
548
+ }
549
+ module.close();
550
+ }
551
+ },
552
+ approve: function () {
553
+ if (settings.onApprove.call(element, $module) === false) {
554
+ module.verbose('Approve callback returned false cancelling close');
555
+
556
+ return;
557
+ }
558
+ module.close();
559
+ },
560
+ deny: function () {
561
+ if (settings.onDeny.call(element, $module) === false) {
562
+ module.verbose('Deny callback returned false cancelling close');
563
+
564
+ return;
565
+ }
566
+ module.close();
567
+ },
568
+ },
569
+
570
+ helpers: {
571
+ toClass: function (selector) {
572
+ var
573
+ classes = selector.trim().split(/\s+/),
574
+ result = ''
575
+ ;
576
+
577
+ classes.forEach(function (element) {
578
+ result += '.' + element;
579
+ });
580
+
581
+ return result;
582
+ },
583
+ deQuote: function (string) {
584
+ return String(string).replace(/"/g, '');
585
+ },
586
+ escape: function (string, preserveHTML) {
587
+ if (preserveHTML) {
588
+ return string;
589
+ }
590
+ var
591
+ badChars = /["'<>`]/g,
592
+ shouldEscape = /["&'<>`]/,
593
+ escape = {
594
+ '<': '&lt;',
595
+ '>': '&gt;',
596
+ '"': '&quot;',
597
+ "'": '&#x27;',
598
+ '`': '&#x60;',
599
+ },
600
+ escapedChar = function (chr) {
601
+ return escape[chr];
602
+ }
603
+ ;
604
+ if (shouldEscape.test(string)) {
605
+ string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
606
+
607
+ return string.replace(badChars, escapedChar);
608
+ }
609
+
610
+ return string;
611
+ },
612
+ },
613
+
614
+ can: {
615
+ useElement: function (element) {
616
+ if ($.fn[element] !== undefined) {
617
+ return true;
618
+ }
619
+ module.error(error.noElement.replace('{element}', element));
620
+
621
+ return false;
622
+ },
623
+ },
624
+
625
+ setting: function (name, value) {
626
+ module.debug('Changing setting', name, value);
627
+ if ($.isPlainObject(name)) {
628
+ $.extend(true, settings, name);
629
+ } else if (value !== undefined) {
630
+ if ($.isPlainObject(settings[name])) {
631
+ $.extend(true, settings[name], value);
632
+ } else {
633
+ settings[name] = value;
634
+ }
635
+ } else {
636
+ return settings[name];
637
+ }
638
+ },
639
+ internal: function (name, value) {
640
+ if ($.isPlainObject(name)) {
641
+ $.extend(true, module, name);
642
+ } else if (value !== undefined) {
643
+ module[name] = value;
644
+ } else {
645
+ return module[name];
646
+ }
647
+ },
648
+ debug: function () {
649
+ if (!settings.silent && settings.debug) {
650
+ if (settings.performance) {
651
+ module.performance.log(arguments);
652
+ } else {
653
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
654
+ module.debug.apply(console, arguments);
655
+ }
656
+ }
657
+ },
658
+ verbose: function () {
659
+ if (!settings.silent && settings.verbose && settings.debug) {
660
+ if (settings.performance) {
661
+ module.performance.log(arguments);
662
+ } else {
663
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
664
+ module.verbose.apply(console, arguments);
665
+ }
666
+ }
667
+ },
668
+ error: function () {
669
+ if (!settings.silent) {
670
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
671
+ module.error.apply(console, arguments);
672
+ }
673
+ },
674
+ performance: {
675
+ log: function (message) {
676
+ var
677
+ currentTime,
678
+ executionTime,
679
+ previousTime
680
+ ;
681
+ if (settings.performance) {
682
+ currentTime = Date.now();
683
+ previousTime = time || currentTime;
684
+ executionTime = currentTime - previousTime;
685
+ time = currentTime;
686
+ performance.push({
687
+ Name: message[0],
688
+ Arguments: [].slice.call(message, 1) || '',
689
+ Element: element,
690
+ 'Execution Time': executionTime,
691
+ });
692
+ }
693
+ clearTimeout(module.performance.timer);
694
+ module.performance.timer = setTimeout(module.performance.display, 500);
695
+ },
696
+ display: function () {
697
+ var
698
+ title = settings.name + ':',
699
+ totalTime = 0
700
+ ;
701
+ time = false;
702
+ clearTimeout(module.performance.timer);
703
+ $.each(performance, function (index, data) {
704
+ totalTime += data['Execution Time'];
705
+ });
706
+ title += ' ' + totalTime + 'ms';
707
+ if (moduleSelector) {
708
+ title += ' \'' + moduleSelector + '\'';
709
+ }
710
+ if (performance.length > 0) {
711
+ console.groupCollapsed(title);
712
+ if (console.table) {
713
+ console.table(performance);
714
+ } else {
715
+ $.each(performance, function (index, data) {
716
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
717
+ });
718
+ }
719
+ console.groupEnd();
720
+ }
721
+ performance = [];
722
+ },
723
+ },
724
+ invoke: function (query, passedArguments, context) {
725
+ var
726
+ object = instance,
727
+ maxDepth,
728
+ found,
729
+ response
730
+ ;
731
+ passedArguments = passedArguments || queryArguments;
732
+ context = context || element;
733
+ if (typeof query === 'string' && object !== undefined) {
734
+ query = query.split(/[ .]/);
735
+ maxDepth = query.length - 1;
736
+ $.each(query, function (depth, value) {
737
+ var camelCaseValue = depth !== maxDepth
738
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
739
+ : query
740
+ ;
741
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
742
+ object = object[camelCaseValue];
743
+ } else if (object[camelCaseValue] !== undefined) {
744
+ found = object[camelCaseValue];
745
+
746
+ return false;
747
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
748
+ object = object[value];
749
+ } else if (object[value] !== undefined) {
750
+ found = object[value];
751
+
752
+ return false;
753
+ } else {
754
+ module.error(error.method, query);
755
+
756
+ return false;
757
+ }
758
+ });
759
+ }
760
+ if (isFunction(found)) {
761
+ response = found.apply(context, passedArguments);
762
+ } else if (found !== undefined) {
763
+ response = found;
764
+ }
765
+ if (Array.isArray(returnedValue)) {
766
+ returnedValue.push(response);
767
+ } else if (returnedValue !== undefined) {
768
+ returnedValue = [returnedValue, response];
769
+ } else if (response !== undefined) {
770
+ returnedValue = response;
771
+ }
772
+
773
+ return found;
774
+ },
775
+ };
776
+
777
+ if (methodInvoked) {
778
+ if (instance === undefined) {
779
+ module.initialize();
780
+ }
781
+ module.invoke(query);
782
+ } else {
783
+ if (instance !== undefined) {
784
+ instance.invoke('destroy');
785
+ }
786
+ module.initialize();
787
+ returnedValue = $module;
788
+ }
789
+ });
790
+
791
+ return returnedValue !== undefined
792
+ ? returnedValue
793
+ : this;
794
+ };
795
+ $.toast = $.fn.toast;
796
+
797
+ $.fn.toast.settings = {
798
+
799
+ name: 'Toast',
800
+ namespace: 'toast',
801
+
802
+ silent: false,
803
+ debug: false,
804
+ verbose: false,
805
+ performance: true,
806
+
807
+ context: 'body',
808
+
809
+ position: 'top right',
810
+ horizontal: false,
811
+ class: 'neutral',
812
+ classProgress: false,
813
+ classActions: false,
814
+ classImage: 'mini',
815
+
816
+ title: '',
817
+ message: '',
818
+ displayTime: 3000, // set to zero to require manually dismissal, otherwise hides on its own
819
+ minDisplayTime: 1000, // minimum displaytime in case displayTime is set to 'auto'
820
+ wordsPerMinute: 120,
821
+ showIcon: false,
822
+ newestOnTop: false,
823
+ showProgress: false,
824
+ pauseOnHover: true,
825
+ progressUp: false, // if true, the bar will start at 0% and increase to 100%
826
+ opacity: 1,
827
+ compact: true,
828
+ closeIcon: false,
829
+ closeOnClick: true,
830
+ cloneModule: true,
831
+ actions: false,
832
+ preserveHTML: true,
833
+ showImage: false,
834
+
835
+ // transition settings
836
+ transition: {
837
+ showMethod: 'scale',
838
+ showDuration: 500,
839
+ hideMethod: 'scale',
840
+ hideDuration: 500,
841
+ closeEasing: 'easeOutCubic', // Set to empty string to stack the closed toast area immediately (old behaviour)
842
+ closeDuration: 500,
457
843
  },
458
844
 
459
- has: {
460
- container: function() {
461
- module.verbose('Determining if there is already a container');
462
- return module.get.containers().length > 0;
463
- },
464
- toast: function(){
465
- return !!module.get.toast();
466
- },
467
- toasts: function(){
468
- return module.get.toasts().length > 0;
469
- },
470
- configActions: function () {
471
- return Array.isArray(settings.actions) && settings.actions.length > 0;
472
- }
845
+ error: {
846
+ method: 'The method you called is not defined.',
847
+ noElement: 'This module requires ui {element}',
848
+ verticalCard: 'Vertical but not attached actions are not supported for card layout',
473
849
  },
474
850
 
475
- get: {
476
- id: function() {
477
- return id;
478
- },
479
- containers: function() {
480
- return $context.children(module.helpers.toClass(settings.position) + selector.container + (settings.horizontal ? module.helpers.toClass(className.horizontal) : ':not('+module.helpers.toClass(className.horizontal)+')') + (settings.context && settings.context !== 'body' ? module.helpers.toClass(className.absolute) : ':not('+module.helpers.toClass(className.absolute)+')'));
481
- },
482
- container: function() {
483
- return module.get.containers()[0];
484
- },
485
- toastBox: function() {
486
- return $toastBox || null;
487
- },
488
- toast: function() {
489
- return $toast || null;
490
- },
491
- toasts: function() {
492
- return $(module.get.container()).find(selector.box);
493
- },
494
- iconClass: function() {
495
- return typeof settings.showIcon === 'string' ? settings.showIcon : settings.showIcon && settings.icons[settings.class] ? settings.icons[settings.class] : '';
496
- },
497
- remainingTime: function() {
498
- return $animationObject ? $animationObject.css('opacity') * settings.displayTime : 0;
499
- }
851
+ className: {
852
+ container: 'ui toast-container',
853
+ absolute: 'absolute',
854
+ box: 'floating toast-box',
855
+ progress: 'ui attached active progress',
856
+ toast: 'ui toast',
857
+ icon: 'centered icon',
858
+ visible: 'visible',
859
+ content: 'content',
860
+ title: 'ui header',
861
+ message: 'message',
862
+ actions: 'actions',
863
+ extraContent: 'extra content',
864
+ button: 'ui button',
865
+ buttons: 'ui buttons',
866
+ close: 'close icon',
867
+ image: 'ui image',
868
+ vertical: 'vertical',
869
+ horizontal: 'horizontal',
870
+ attached: 'attached',
871
+ inverted: 'inverted',
872
+ compact: 'compact',
873
+ pausable: 'pausable',
874
+ progressing: 'progressing',
875
+ top: 'top',
876
+ bottom: 'bottom',
877
+ left: 'left',
878
+ basic: 'basic',
879
+ unclickable: 'unclickable',
500
880
  },
501
881
 
502
- set: {
503
- visible: function() {
504
- $toast.addClass(className.visible);
505
- }
882
+ text: {
883
+ close: 'Close',
506
884
  },
507
885
 
508
- remove: {
509
- visible: function() {
510
- $toast.removeClass(className.visible);
511
- }
886
+ icons: {
887
+ info: 'info',
888
+ success: 'checkmark',
889
+ warning: 'warning',
890
+ error: 'times',
512
891
  },
513
892
 
514
- event: {
515
- close: function(){
516
- module.close();
517
- },
518
- click: function(event) {
519
- if($(event.target).closest(selector.clickable).length === 0) {
520
- if(settings.onClick.call($toastBox, element) === false || !settings.closeOnClick) {
521
- module.verbose('Click callback returned false or close denied by setting cancelling close');
522
- return;
523
- }
524
- module.close();
525
- }
526
- },
527
- approve: function() {
528
- if(settings.onApprove.call(element, $module) === false) {
529
- module.verbose('Approve callback returned false cancelling close');
530
- return;
531
- }
532
- module.close();
533
- },
534
- deny: function() {
535
- if(settings.onDeny.call(element, $module) === false) {
536
- module.verbose('Deny callback returned false cancelling close');
537
- return;
538
- }
539
- module.close();
540
- }
893
+ selector: {
894
+ container: '.ui.toast-container',
895
+ box: '.toast-box',
896
+ toast: '.ui.toast',
897
+ title: '.header',
898
+ message: '.message:not(.ui)',
899
+ image: '> img.image, > .image > img',
900
+ icon: '> i.icon',
901
+ input: 'input:not([type="hidden"]), textarea, select, button, .ui.button, ui.dropdown',
902
+ clickable: 'a, details, .ui.accordion',
903
+ approve: '.actions .positive, .actions .approve, .actions .ok',
904
+ deny: '.actions .negative, .actions .deny, .actions .cancel',
541
905
  },
542
906
 
543
- helpers: {
544
- toClass: function(selector) {
545
- var
546
- classes = selector.trim().split(/\s+/),
547
- result = ''
548
- ;
907
+ fields: {
908
+ class: 'class',
909
+ text: 'text',
910
+ icon: 'icon',
911
+ click: 'click',
912
+ },
549
913
 
550
- classes.forEach(function (element) {
551
- result += '.' + element;
552
- });
553
-
554
- return result;
555
- },
556
- deQuote: function(string) {
557
- return String(string).replace(/"/g,"");
558
- },
559
- escape: function(string, preserveHTML) {
560
- if (preserveHTML){
561
- return string;
562
- }
914
+ // callbacks
915
+ onShow: function () {},
916
+ onVisible: function () {},
917
+ onClick: function () {},
918
+ onHide: function () {},
919
+ onHidden: function () {},
920
+ onRemove: function () {},
921
+ onApprove: function () {},
922
+ onDeny: function () {},
923
+ };
924
+
925
+ $.extend($.easing, {
926
+ easeOutBounce: function (x) {
563
927
  var
564
- badChars = /[<>"'`]/g,
565
- shouldEscape = /[&<>"'`]/,
566
- escape = {
567
- "<": "&lt;",
568
- ">": "&gt;",
569
- '"': "&quot;",
570
- "'": "&#x27;",
571
- "`": "&#x60;"
572
- },
573
- escapedChar = function(chr) {
574
- return escape[chr];
575
- }
928
+ n1 = 7.5625,
929
+ d1 = 2.75
576
930
  ;
577
- if(shouldEscape.test(string)) {
578
- string = string.replace(/&(?![a-z0-9#]{1,12};)/gi, "&amp;");
579
- return string.replace(badChars, escapedChar);
931
+ if (x < 1 / d1) {
932
+ return n1 * x * x;
580
933
  }
581
- return string;
582
- }
583
- },
934
+ if (x < 2 / d1) {
935
+ x -= 1.5 / d1;
584
936
 
585
- can: {
586
- useElement: function(element){
587
- if ($.fn[element] !== undefined) {
588
- return true;
937
+ return n1 * x * x + 0.75;
589
938
  }
590
- module.error(error.noElement.replace('{element}',element));
591
- return false;
592
- }
593
- },
939
+ if (x < 2.5 / d1) {
940
+ x -= 2.25 / d1;
594
941
 
595
- setting: function(name, value) {
596
- module.debug('Changing setting', name, value);
597
- if( $.isPlainObject(name) ) {
598
- $.extend(true, settings, name);
599
- }
600
- else if(value !== undefined) {
601
- if($.isPlainObject(settings[name])) {
602
- $.extend(true, settings[name], value);
603
- }
604
- else {
605
- settings[name] = value;
606
- }
607
- }
608
- else {
609
- return settings[name];
610
- }
611
- },
612
- internal: function(name, value) {
613
- if( $.isPlainObject(name) ) {
614
- $.extend(true, module, name);
615
- }
616
- else if(value !== undefined) {
617
- module[name] = value;
618
- }
619
- else {
620
- return module[name];
621
- }
622
- },
623
- debug: function() {
624
- if(!settings.silent && settings.debug) {
625
- if(settings.performance) {
626
- module.performance.log(arguments);
627
- }
628
- else {
629
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
630
- module.debug.apply(console, arguments);
631
- }
632
- }
633
- },
634
- verbose: function() {
635
- if(!settings.silent && settings.verbose && settings.debug) {
636
- if(settings.performance) {
637
- module.performance.log(arguments);
638
- }
639
- else {
640
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
641
- module.verbose.apply(console, arguments);
942
+ return n1 * x * x + 0.9375;
642
943
  }
643
- }
644
- },
645
- error: function() {
646
- if(!settings.silent) {
647
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
648
- module.error.apply(console, arguments);
649
- }
944
+ x -= 2.625 / d1;
945
+
946
+ return n1 * x * x + 0.984375;
650
947
  },
651
- performance: {
652
- log: function(message) {
653
- var
654
- currentTime,
655
- executionTime,
656
- previousTime
657
- ;
658
- if(settings.performance) {
659
- currentTime = new Date().getTime();
660
- previousTime = time || currentTime;
661
- executionTime = currentTime - previousTime;
662
- time = currentTime;
663
- performance.push({
664
- 'Name' : message[0],
665
- 'Arguments' : [].slice.call(message, 1) || '',
666
- 'Element' : element,
667
- 'Execution Time' : executionTime
668
- });
669
- }
670
- clearTimeout(module.performance.timer);
671
- module.performance.timer = setTimeout(module.performance.display, 500);
672
- },
673
- display: function() {
674
- var
675
- title = settings.name + ':',
676
- totalTime = 0
677
- ;
678
- time = false;
679
- clearTimeout(module.performance.timer);
680
- $.each(performance, function(index, data) {
681
- totalTime += data['Execution Time'];
682
- });
683
- title += ' ' + totalTime + 'ms';
684
- if(moduleSelector) {
685
- title += ' \'' + moduleSelector + '\'';
686
- }
687
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
688
- console.groupCollapsed(title);
689
- if(console.table) {
690
- console.table(performance);
691
- }
692
- else {
693
- $.each(performance, function(index, data) {
694
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
695
- });
696
- }
697
- console.groupEnd();
698
- }
699
- performance = [];
700
- }
948
+ easeOutCubic: function (t) {
949
+ return --t * t * t + 1;
701
950
  },
702
- invoke: function(query, passedArguments, context) {
703
- var
704
- object = instance,
705
- maxDepth,
706
- found,
707
- response
708
- ;
709
- passedArguments = passedArguments || queryArguments;
710
- context = context || element;
711
- if(typeof query == 'string' && object !== undefined) {
712
- query = query.split(/[\. ]/);
713
- maxDepth = query.length - 1;
714
- $.each(query, function(depth, value) {
715
- var camelCaseValue = (depth != maxDepth)
716
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
717
- : query
718
- ;
719
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
720
- object = object[camelCaseValue];
721
- }
722
- else if( object[camelCaseValue] !== undefined ) {
723
- found = object[camelCaseValue];
724
- return false;
725
- }
726
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
727
- object = object[value];
728
- }
729
- else if( object[value] !== undefined ) {
730
- found = object[value];
731
- return false;
732
- }
733
- else {
734
- module.error(error.method, query);
735
- return false;
736
- }
737
- });
738
- }
739
- if ( $.isFunction( found ) ) {
740
- response = found.apply(context, passedArguments);
741
- }
742
- else if(found !== undefined) {
743
- response = found;
744
- }
745
- if(Array.isArray(returnedValue)) {
746
- returnedValue.push(response);
747
- }
748
- else if(returnedValue !== undefined) {
749
- returnedValue = [returnedValue, response];
750
- }
751
- else if(response !== undefined) {
752
- returnedValue = response;
753
- }
754
- return found;
755
- }
756
- };
757
-
758
- if(methodInvoked) {
759
- if(instance === undefined) {
760
- module.initialize();
761
- }
762
- module.invoke(query);
763
- }
764
- else {
765
- if(instance !== undefined) {
766
- instance.invoke('destroy');
767
- }
768
- module.initialize();
769
- returnedValue = $module;
770
- }
771
- })
772
- ;
773
-
774
- return (returnedValue !== undefined)
775
- ? returnedValue
776
- : this
777
- ;
778
- };
779
-
780
- $.fn.toast.settings = {
781
-
782
- name : 'Toast',
783
- namespace : 'toast',
784
-
785
- silent : false,
786
- debug : false,
787
- verbose : false,
788
- performance : true,
789
-
790
- context : 'body',
791
-
792
- position : 'top right',
793
- horizontal : false,
794
- class : 'neutral',
795
- classProgress : false,
796
- classActions : false,
797
- classImage : 'mini',
798
-
799
- title : '',
800
- message : '',
801
- displayTime : 3000, // set to zero to require manually dismissal, otherwise hides on its own
802
- minDisplayTime : 1000, // minimum displaytime in case displayTime is set to 'auto'
803
- wordsPerMinute : 120,
804
- showIcon : false,
805
- newestOnTop : false,
806
- showProgress : false,
807
- pauseOnHover : true,
808
- progressUp : false, //if true, the bar will start at 0% and increase to 100%
809
- opacity : 1,
810
- compact : true,
811
- closeIcon : false,
812
- closeOnClick : true,
813
- cloneModule : true,
814
- actions : false,
815
- preserveHTML : true,
816
- showImage : false,
817
-
818
- // transition settings
819
- transition : {
820
- showMethod : 'scale',
821
- showDuration : 500,
822
- hideMethod : 'scale',
823
- hideDuration : 500,
824
- closeEasing : 'easeOutCubic', //Set to empty string to stack the closed toast area immediately (old behaviour)
825
- closeDuration: 500
826
- },
827
-
828
- error: {
829
- method : 'The method you called is not defined.',
830
- noElement : 'This module requires ui {element}',
831
- verticalCard : 'Vertical but not attached actions are not supported for card layout'
832
- },
833
-
834
- className : {
835
- container : 'ui toast-container',
836
- absolute : 'absolute',
837
- box : 'floating toast-box',
838
- progress : 'ui attached active progress',
839
- toast : 'ui toast',
840
- icon : 'centered icon',
841
- visible : 'visible',
842
- content : 'content',
843
- title : 'ui header',
844
- message : 'message',
845
- actions : 'actions',
846
- extraContent : 'extra content',
847
- button : 'ui button',
848
- buttons : 'ui buttons',
849
- close : 'close icon',
850
- image : 'ui image',
851
- vertical : 'vertical',
852
- horizontal : 'horizontal',
853
- attached : 'attached',
854
- inverted : 'inverted',
855
- compact : 'compact',
856
- pausable : 'pausable',
857
- progressing : 'progressing',
858
- top : 'top',
859
- bottom : 'bottom',
860
- left : 'left',
861
- basic : 'basic',
862
- unclickable : 'unclickable'
863
- },
864
-
865
- text: {
866
- close : 'Close'
867
- },
868
-
869
- icons : {
870
- info : 'info',
871
- success : 'checkmark',
872
- warning : 'warning',
873
- error : 'times'
874
- },
875
-
876
- selector : {
877
- container : '.ui.toast-container',
878
- box : '.toast-box',
879
- toast : '.ui.toast',
880
- title : '.header',
881
- message : '.message:not(.ui)',
882
- image : '> img.image, > .image > img',
883
- icon : '> i.icon',
884
- input : 'input:not([type="hidden"]), textarea, select, button, .ui.button, ui.dropdown',
885
- clickable : 'a, details, .ui.accordion',
886
- approve : '.actions .positive, .actions .approve, .actions .ok',
887
- deny : '.actions .negative, .actions .deny, .actions .cancel'
888
- },
889
-
890
- fields : {
891
- class : 'class',
892
- text : 'text',
893
- icon : 'icon',
894
- click : 'click'
895
- },
896
-
897
- // callbacks
898
- onShow : function(){},
899
- onVisible : function(){},
900
- onClick : function(){},
901
- onHide : function(){},
902
- onHidden : function(){},
903
- onRemove : function(){},
904
- onApprove : function(){},
905
- onDeny : function(){}
906
- };
907
-
908
- $.extend( $.easing, {
909
- easeOutBounce: function (x, t, b, c, d) {
910
- if ((t/=d) < (1/2.75)) {
911
- return c*(7.5625*t*t) + b;
912
- } else if (t < (2/2.75)) {
913
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
914
- } else if (t < (2.5/2.75)) {
915
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
916
- } else {
917
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
918
- }
919
- },
920
- easeOutCubic: function (t) {
921
- return (--t)*t*t+1;
922
- }
923
- });
924
-
925
-
926
- })( jQuery, window, document );
951
+ });
952
+ })(jQuery, window, document);