fomantic-ui-sass 2.8.8.1 → 2.9.1

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