rails-active-ui 0.2.2 → 0.3.1

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