@ntlab/ntjs-assets 2.0.2 → 2.0.3

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 (235) hide show
  1. package/assets/js/bootstrap-icons/bootstrap-icons.svg +1 -1
  2. package/assets/js/bootstrap-icons/folder-plus.svg +2 -2
  3. package/assets/js/bootstrap-icons/font/bootstrap-icons.css +1981 -0
  4. package/assets/js/bootstrap-icons/font/bootstrap-icons.json +1955 -0
  5. package/assets/js/bootstrap-icons/font/bootstrap-icons.min.css +5 -0
  6. package/assets/js/bootstrap-icons/font/bootstrap-icons.scss +1993 -0
  7. package/assets/js/bootstrap-icons/font/fonts/bootstrap-icons.woff +0 -0
  8. package/assets/js/bootstrap-icons/font/fonts/bootstrap-icons.woff2 +0 -0
  9. package/assets/js/bootstrap-icons/postcard-heart-fill.svg +1 -1
  10. package/assets/js/bootstrap-icons/trash.svg +2 -2
  11. package/assets/js/jquery/jquery.js +840 -1045
  12. package/assets/js/jquery/jquery.min.js +2 -2
  13. package/assets/js/jquery/jquery.min.map +1 -1
  14. package/assets/js/jquery/jquery.slim.js +834 -1039
  15. package/assets/js/jquery/jquery.slim.min.js +2 -2
  16. package/assets/js/jquery/jquery.slim.min.map +1 -1
  17. package/assets/js/popper.js/cjs/enums.js +1 -1
  18. package/assets/js/popper.js/cjs/popper-base.js +12 -170
  19. package/assets/js/popper.js/cjs/popper-base.js.map +1 -1
  20. package/assets/js/popper.js/cjs/popper-lite.js +14 -184
  21. package/assets/js/popper.js/cjs/popper-lite.js.map +1 -1
  22. package/assets/js/popper.js/cjs/popper.js +14 -197
  23. package/assets/js/popper.js/cjs/popper.js.map +1 -1
  24. package/assets/js/popper.js/esm/createPopper.js +6 -66
  25. package/assets/js/popper.js/esm/modifiers/arrow.js +1 -12
  26. package/assets/js/popper.js/esm/modifiers/computeStyles.js +2 -14
  27. package/assets/js/popper.js/esm/utils/computeAutoPlacement.js +0 -4
  28. package/assets/js/popper.js/esm/utils/userAgent.js +1 -1
  29. package/assets/js/popper.js/umd/enums.js +1 -1
  30. package/assets/js/popper.js/umd/enums.min.js +1 -1
  31. package/assets/js/popper.js/umd/popper-base.js +12 -170
  32. package/assets/js/popper.js/umd/popper-base.js.map +1 -1
  33. package/assets/js/popper.js/umd/popper-base.min.js +2 -2
  34. package/assets/js/popper.js/umd/popper-base.min.js.map +1 -1
  35. package/assets/js/popper.js/umd/popper-lite.js +14 -184
  36. package/assets/js/popper.js/umd/popper-lite.js.map +1 -1
  37. package/assets/js/popper.js/umd/popper-lite.min.js +2 -2
  38. package/assets/js/popper.js/umd/popper-lite.min.js.map +1 -1
  39. package/assets/js/popper.js/umd/popper.js +14 -197
  40. package/assets/js/popper.js/umd/popper.js.map +1 -1
  41. package/assets/js/popper.js/umd/popper.min.js +2 -2
  42. package/assets/js/popper.js/umd/popper.min.js.map +1 -1
  43. package/assets/js/semantic-ui/components/accordion.css +196 -74
  44. package/assets/js/semantic-ui/components/accordion.js +570 -591
  45. package/assets/js/semantic-ui/components/accordion.min.css +4 -4
  46. package/assets/js/semantic-ui/components/accordion.min.js +6 -6
  47. package/assets/js/semantic-ui/components/ad.css +40 -51
  48. package/assets/js/semantic-ui/components/ad.min.css +4 -4
  49. package/assets/js/semantic-ui/components/api.js +1154 -1117
  50. package/assets/js/semantic-ui/components/api.min.js +6 -6
  51. package/assets/js/semantic-ui/components/breadcrumb.css +7 -7
  52. package/assets/js/semantic-ui/components/breadcrumb.min.css +4 -4
  53. package/assets/js/semantic-ui/components/button.css +895 -1227
  54. package/assets/js/semantic-ui/components/button.min.css +4 -4
  55. package/assets/js/semantic-ui/components/calendar.css +60 -33
  56. package/assets/js/semantic-ui/components/calendar.js +1952 -1575
  57. package/assets/js/semantic-ui/components/calendar.min.css +4 -4
  58. package/assets/js/semantic-ui/components/calendar.min.js +6 -6
  59. package/assets/js/semantic-ui/components/card.css +1004 -441
  60. package/assets/js/semantic-ui/components/card.min.css +4 -4
  61. package/assets/js/semantic-ui/components/checkbox.css +275 -303
  62. package/assets/js/semantic-ui/components/checkbox.js +863 -855
  63. package/assets/js/semantic-ui/components/checkbox.min.css +4 -4
  64. package/assets/js/semantic-ui/components/checkbox.min.js +6 -6
  65. package/assets/js/semantic-ui/components/comment.css +45 -63
  66. package/assets/js/semantic-ui/components/comment.min.css +4 -4
  67. package/assets/js/semantic-ui/components/container.css +98 -4
  68. package/assets/js/semantic-ui/components/container.min.css +4 -4
  69. package/assets/js/semantic-ui/components/dimmer.css +95 -196
  70. package/assets/js/semantic-ui/components/dimmer.js +698 -717
  71. package/assets/js/semantic-ui/components/dimmer.min.css +4 -4
  72. package/assets/js/semantic-ui/components/dimmer.min.js +6 -6
  73. package/assets/js/semantic-ui/components/divider.css +75 -93
  74. package/assets/js/semantic-ui/components/divider.min.css +4 -4
  75. package/assets/js/semantic-ui/components/dropdown.css +490 -413
  76. package/assets/js/semantic-ui/components/dropdown.js +4203 -4068
  77. package/assets/js/semantic-ui/components/dropdown.min.css +4 -4
  78. package/assets/js/semantic-ui/components/dropdown.min.js +6 -6
  79. package/assets/js/semantic-ui/components/embed.css +27 -38
  80. package/assets/js/semantic-ui/components/embed.js +647 -673
  81. package/assets/js/semantic-ui/components/embed.min.css +4 -4
  82. package/assets/js/semantic-ui/components/embed.min.js +6 -6
  83. package/assets/js/semantic-ui/components/emoji.css +11156 -9192
  84. package/assets/js/semantic-ui/components/emoji.min.css +3 -3
  85. package/assets/js/semantic-ui/components/feed.css +56 -78
  86. package/assets/js/semantic-ui/components/feed.min.css +4 -4
  87. package/assets/js/semantic-ui/components/flag.css +1037 -929
  88. package/assets/js/semantic-ui/components/flag.min.css +4 -4
  89. package/assets/js/semantic-ui/components/flyout.css +552 -0
  90. package/assets/js/semantic-ui/components/flyout.js +1567 -0
  91. package/assets/js/semantic-ui/components/flyout.min.css +9 -0
  92. package/assets/js/semantic-ui/components/flyout.min.js +11 -0
  93. package/assets/js/semantic-ui/components/form.css +536 -530
  94. package/assets/js/semantic-ui/components/form.js +2037 -1945
  95. package/assets/js/semantic-ui/components/form.min.css +4 -4
  96. package/assets/js/semantic-ui/components/form.min.js +6 -6
  97. package/assets/js/semantic-ui/components/grid.css +218 -345
  98. package/assets/js/semantic-ui/components/grid.min.css +4 -4
  99. package/assets/js/semantic-ui/components/header.css +137 -154
  100. package/assets/js/semantic-ui/components/header.min.css +4 -4
  101. package/assets/js/semantic-ui/components/icon.css +3000 -2750
  102. package/assets/js/semantic-ui/components/icon.min.css +4 -4
  103. package/assets/js/semantic-ui/components/image.css +54 -49
  104. package/assets/js/semantic-ui/components/image.min.css +4 -4
  105. package/assets/js/semantic-ui/components/input.css +1081 -227
  106. package/assets/js/semantic-ui/components/input.min.css +4 -4
  107. package/assets/js/semantic-ui/components/item.css +91 -138
  108. package/assets/js/semantic-ui/components/item.min.css +4 -4
  109. package/assets/js/semantic-ui/components/label.css +470 -481
  110. package/assets/js/semantic-ui/components/label.min.css +4 -4
  111. package/assets/js/semantic-ui/components/list.css +93 -114
  112. package/assets/js/semantic-ui/components/list.min.css +4 -4
  113. package/assets/js/semantic-ui/components/loader.css +452 -536
  114. package/assets/js/semantic-ui/components/loader.min.css +4 -4
  115. package/assets/js/semantic-ui/components/menu.css +408 -510
  116. package/assets/js/semantic-ui/components/menu.min.css +9 -1
  117. package/assets/js/semantic-ui/components/message.css +188 -213
  118. package/assets/js/semantic-ui/components/message.min.css +4 -4
  119. package/assets/js/semantic-ui/components/modal.css +174 -166
  120. package/assets/js/semantic-ui/components/modal.js +1558 -1146
  121. package/assets/js/semantic-ui/components/modal.min.css +4 -4
  122. package/assets/js/semantic-ui/components/modal.min.js +6 -6
  123. package/assets/js/semantic-ui/components/nag.css +183 -41
  124. package/assets/js/semantic-ui/components/nag.js +527 -467
  125. package/assets/js/semantic-ui/components/nag.min.css +4 -4
  126. package/assets/js/semantic-ui/components/nag.min.js +6 -6
  127. package/assets/js/semantic-ui/components/placeholder.css +62 -76
  128. package/assets/js/semantic-ui/components/placeholder.min.css +4 -4
  129. package/assets/js/semantic-ui/components/popup.css +681 -312
  130. package/assets/js/semantic-ui/components/popup.js +1470 -1463
  131. package/assets/js/semantic-ui/components/popup.min.css +4 -4
  132. package/assets/js/semantic-ui/components/popup.min.js +6 -6
  133. package/assets/js/semantic-ui/components/progress.css +149 -217
  134. package/assets/js/semantic-ui/components/progress.js +945 -1002
  135. package/assets/js/semantic-ui/components/progress.min.css +4 -4
  136. package/assets/js/semantic-ui/components/progress.min.js +6 -6
  137. package/assets/js/semantic-ui/components/rail.css +17 -22
  138. package/assets/js/semantic-ui/components/rail.min.css +3 -3
  139. package/assets/js/semantic-ui/components/rating.css +89 -184
  140. package/assets/js/semantic-ui/components/rating.js +509 -521
  141. package/assets/js/semantic-ui/components/rating.min.css +4 -4
  142. package/assets/js/semantic-ui/components/rating.min.js +6 -6
  143. package/assets/js/semantic-ui/components/reset.css +12 -17
  144. package/assets/js/semantic-ui/components/reset.min.css +4 -4
  145. package/assets/js/semantic-ui/components/reveal.css +46 -85
  146. package/assets/js/semantic-ui/components/reveal.min.css +4 -4
  147. package/assets/js/semantic-ui/components/search.css +157 -96
  148. package/assets/js/semantic-ui/components/search.js +1522 -1479
  149. package/assets/js/semantic-ui/components/search.min.css +4 -4
  150. package/assets/js/semantic-ui/components/search.min.js +6 -6
  151. package/assets/js/semantic-ui/components/segment.css +317 -249
  152. package/assets/js/semantic-ui/components/segment.min.css +4 -4
  153. package/assets/js/semantic-ui/components/shape.css +16 -32
  154. package/assets/js/semantic-ui/components/shape.js +763 -812
  155. package/assets/js/semantic-ui/components/shape.min.css +4 -4
  156. package/assets/js/semantic-ui/components/shape.min.js +6 -6
  157. package/assets/js/semantic-ui/components/sidebar.css +128 -216
  158. package/assets/js/semantic-ui/components/sidebar.js +1042 -1003
  159. package/assets/js/semantic-ui/components/sidebar.min.css +4 -4
  160. package/assets/js/semantic-ui/components/sidebar.min.js +6 -6
  161. package/assets/js/semantic-ui/components/site.css +123 -48
  162. package/assets/js/semantic-ui/components/site.js +438 -478
  163. package/assets/js/semantic-ui/components/site.min.css +4 -4
  164. package/assets/js/semantic-ui/components/site.min.js +6 -6
  165. package/assets/js/semantic-ui/components/slider.css +133 -141
  166. package/assets/js/semantic-ui/components/slider.js +1312 -1274
  167. package/assets/js/semantic-ui/components/slider.min.css +9 -1
  168. package/assets/js/semantic-ui/components/slider.min.js +6 -6
  169. package/assets/js/semantic-ui/components/state.js +640 -659
  170. package/assets/js/semantic-ui/components/state.min.js +6 -6
  171. package/assets/js/semantic-ui/components/statistic.css +83 -124
  172. package/assets/js/semantic-ui/components/statistic.min.css +4 -4
  173. package/assets/js/semantic-ui/components/step.css +118 -184
  174. package/assets/js/semantic-ui/components/step.min.css +4 -4
  175. package/assets/js/semantic-ui/components/sticky.css +3 -8
  176. package/assets/js/semantic-ui/components/sticky.js +849 -892
  177. package/assets/js/semantic-ui/components/sticky.min.css +4 -4
  178. package/assets/js/semantic-ui/components/sticky.min.js +6 -6
  179. package/assets/js/semantic-ui/components/tab.css +16 -20
  180. package/assets/js/semantic-ui/components/tab.js +896 -941
  181. package/assets/js/semantic-ui/components/tab.min.css +4 -4
  182. package/assets/js/semantic-ui/components/tab.min.js +6 -6
  183. package/assets/js/semantic-ui/components/table.css +2073 -884
  184. package/assets/js/semantic-ui/components/table.min.css +4 -4
  185. package/assets/js/semantic-ui/components/text.css +51 -30
  186. package/assets/js/semantic-ui/components/text.min.css +4 -4
  187. package/assets/js/semantic-ui/components/toast.css +200 -137
  188. package/assets/js/semantic-ui/components/toast.js +912 -832
  189. package/assets/js/semantic-ui/components/toast.min.css +4 -4
  190. package/assets/js/semantic-ui/components/toast.min.js +6 -6
  191. package/assets/js/semantic-ui/components/transition.css +371 -1282
  192. package/assets/js/semantic-ui/components/transition.js +999 -1074
  193. package/assets/js/semantic-ui/components/transition.min.css +4 -4
  194. package/assets/js/semantic-ui/components/transition.min.js +6 -6
  195. package/assets/js/semantic-ui/components/visibility.js +1215 -1247
  196. package/assets/js/semantic-ui/components/visibility.min.js +6 -6
  197. package/assets/js/semantic-ui/semantic.css +43777 -37429
  198. package/assets/js/semantic-ui/semantic.js +29152 -26694
  199. package/assets/js/semantic-ui/semantic.min.css +6 -399
  200. package/assets/js/semantic-ui/semantic.min.js +6 -6
  201. package/assets/js/semantic-ui/themes/basic/assets/fonts/icons.woff2 +0 -0
  202. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Bold.woff +0 -0
  203. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
  204. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
  205. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  206. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Italic.woff +0 -0
  207. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
  208. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Regular.woff +0 -0
  209. package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
  210. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  211. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
  212. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
  213. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
  214. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
  215. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
  216. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  217. package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
  218. package/assets/js/semantic-ui/themes/default/assets/fonts/brand-icons.woff +0 -0
  219. package/assets/js/semantic-ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
  220. package/assets/js/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
  221. package/assets/js/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
  222. package/assets/js/semantic-ui/themes/default/assets/fonts/outline-icons.woff +0 -0
  223. package/assets/js/semantic-ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  224. package/assets/js/semantic-ui/themes/famfamfam/assets/images/flags.png +0 -0
  225. package/assets/js/semantic-ui/themes/github/assets/fonts/octicons.woff2 +0 -0
  226. package/assets/js/socket.io/socket.io.esm.min.js +3 -3
  227. package/assets/js/socket.io/socket.io.esm.min.js.map +1 -1
  228. package/assets/js/socket.io/socket.io.js +841 -333
  229. package/assets/js/socket.io/socket.io.js.map +1 -1
  230. package/assets/js/socket.io/socket.io.min.js +3 -3
  231. package/assets/js/socket.io/socket.io.min.js.map +1 -1
  232. package/assets/js/socket.io/socket.io.msgpack.min.js +3 -3
  233. package/assets/js/socket.io/socket.io.msgpack.min.js.map +1 -1
  234. package/cdn.json +19 -4
  235. package/package.json +1 -1
@@ -1,711 +1,692 @@
1
1
  /*!
2
- * # Fomantic-UI - State
3
- * http://github.com/fomantic/Fomantic-UI/
2
+ * # Fomantic-UI 2.9.2 - State
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) {
11
+ (function ($, window, document) {
12
+ 'use strict';
12
13
 
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.state = function(parameters) {
27
- var
28
- $allModules = $(this),
29
-
30
- moduleSelector = $allModules.selector || '',
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
31
17
 
32
- time = new Date().getTime(),
33
- performance = [],
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
34
21
 
35
- query = arguments[0],
36
- methodInvoked = (typeof query == 'string'),
37
- queryArguments = [].slice.call(arguments, 1),
22
+ $.fn.state = function (parameters) {
23
+ var
24
+ $allModules = $(this),
38
25
 
39
- returnedValue
40
- ;
41
- $allModules
42
- .each(function() {
43
- var
44
- settings = ( $.isPlainObject(parameters) )
45
- ? $.extend(true, {}, $.fn.state.settings, parameters)
46
- : $.extend({}, $.fn.state.settings),
26
+ moduleSelector = $allModules.selector || '',
47
27
 
48
- error = settings.error,
49
- metadata = settings.metadata,
50
- className = settings.className,
51
- namespace = settings.namespace,
52
- states = settings.states,
53
- text = settings.text,
28
+ time = Date.now(),
29
+ performance = [],
54
30
 
55
- eventNamespace = '.' + namespace,
56
- moduleNamespace = namespace + '-module',
31
+ query = arguments[0],
32
+ methodInvoked = typeof query === 'string',
33
+ queryArguments = [].slice.call(arguments, 1),
57
34
 
58
- $module = $(this),
35
+ returnedValue
36
+ ;
37
+ $allModules.each(function () {
38
+ var
39
+ settings = $.isPlainObject(parameters)
40
+ ? $.extend(true, {}, $.fn.state.settings, parameters)
41
+ : $.extend({}, $.fn.state.settings),
59
42
 
60
- element = this,
61
- instance = $module.data(moduleNamespace),
43
+ error = settings.error,
44
+ metadata = settings.metadata,
45
+ className = settings.className,
46
+ namespace = settings.namespace,
47
+ states = settings.states,
48
+ text = settings.text,
62
49
 
63
- module
64
- ;
65
- module = {
50
+ eventNamespace = '.' + namespace,
51
+ moduleNamespace = namespace + '-module',
66
52
 
67
- initialize: function() {
68
- module.verbose('Initializing module');
53
+ $module = $(this),
69
54
 
70
- // allow module to guess desired state based on element
71
- if(settings.automatic) {
72
- module.add.defaults();
73
- }
55
+ element = this,
56
+ instance = $module.data(moduleNamespace),
74
57
 
75
- // bind events with delegated events
76
- if(settings.context && moduleSelector !== '') {
77
- $(settings.context)
78
- .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
79
- .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
80
- .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
58
+ module
81
59
  ;
82
- }
83
- else {
84
- $module
85
- .on('mouseenter' + eventNamespace, module.change.text)
86
- .on('mouseleave' + eventNamespace, module.reset.text)
87
- .on('click' + eventNamespace, module.toggle.state)
88
- ;
89
- }
90
- module.instantiate();
91
- },
92
-
93
- instantiate: function() {
94
- module.verbose('Storing instance of module', module);
95
- instance = module;
96
- $module
97
- .data(moduleNamespace, module)
98
- ;
99
- },
100
-
101
- destroy: function() {
102
- module.verbose('Destroying previous module', instance);
103
- $module
104
- .off(eventNamespace)
105
- .removeData(moduleNamespace)
106
- ;
107
- },
60
+ module = {
61
+
62
+ initialize: function () {
63
+ module.verbose('Initializing module');
64
+
65
+ // allow module to guess desired state based on element
66
+ if (settings.automatic) {
67
+ module.add.defaults();
68
+ }
69
+
70
+ // bind events with delegated events
71
+ if (settings.context && moduleSelector !== '') {
72
+ ([window, document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context))
73
+ .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
74
+ .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
75
+ .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
76
+ ;
77
+ } else {
78
+ $module
79
+ .on('mouseenter' + eventNamespace, module.change.text)
80
+ .on('mouseleave' + eventNamespace, module.reset.text)
81
+ .on('click' + eventNamespace, module.toggle.state)
82
+ ;
83
+ }
84
+ module.instantiate();
85
+ },
86
+
87
+ instantiate: function () {
88
+ module.verbose('Storing instance of module', module);
89
+ instance = module;
90
+ $module
91
+ .data(moduleNamespace, module)
92
+ ;
93
+ },
94
+
95
+ destroy: function () {
96
+ module.verbose('Destroying previous module', instance);
97
+ $module
98
+ .off(eventNamespace)
99
+ .removeData(moduleNamespace)
100
+ ;
101
+ },
102
+
103
+ refresh: function () {
104
+ module.verbose('Refreshing selector cache');
105
+ $module = $(element);
106
+ },
107
+
108
+ add: {
109
+ defaults: function () {
110
+ var
111
+ userStates = parameters && $.isPlainObject(parameters.states)
112
+ ? parameters.states
113
+ : {}
114
+ ;
115
+ $.each(settings.defaults, function (type, typeStates) {
116
+ if (module.is[type] !== undefined && module.is[type]()) {
117
+ module.verbose('Adding default states', type, element);
118
+ $.extend(settings.states, typeStates, userStates);
119
+ }
120
+ });
121
+ },
122
+ },
123
+
124
+ is: {
125
+
126
+ active: function () {
127
+ return $module.hasClass(className.active);
128
+ },
129
+ loading: function () {
130
+ return $module.hasClass(className.loading);
131
+ },
132
+ inactive: function () {
133
+ return !$module.hasClass(className.active);
134
+ },
135
+ state: function (state) {
136
+ if (className[state] === undefined) {
137
+ return false;
138
+ }
139
+
140
+ return $module.hasClass(className[state]);
141
+ },
142
+
143
+ enabled: function () {
144
+ return !$module.is(settings.filter.active);
145
+ },
146
+ disabled: function () {
147
+ return $module.is(settings.filter.active);
148
+ },
149
+ textEnabled: function () {
150
+ return !$module.is(settings.filter.text);
151
+ },
152
+
153
+ // definitions for automatic type detection
154
+ button: function () {
155
+ return $module.is('.button:not(a, .submit)');
156
+ },
157
+ input: function () {
158
+ return $module.is('input');
159
+ },
160
+ progress: function () {
161
+ return $module.is('.ui.progress');
162
+ },
163
+ },
164
+
165
+ allow: function (state) {
166
+ module.debug('Now allowing state', state);
167
+ states[state] = true;
168
+ },
169
+ disallow: function (state) {
170
+ module.debug('No longer allowing', state);
171
+ states[state] = false;
172
+ },
173
+
174
+ allows: function (state) {
175
+ return states[state] || false;
176
+ },
177
+
178
+ enable: function () {
179
+ $module.removeClass(className.disabled);
180
+ },
181
+
182
+ disable: function () {
183
+ $module.addClass(className.disabled);
184
+ },
185
+
186
+ setState: function (state) {
187
+ if (module.allows(state)) {
188
+ $module.addClass(className[state]);
189
+ }
190
+ },
191
+
192
+ removeState: function (state) {
193
+ if (module.allows(state)) {
194
+ $module.removeClass(className[state]);
195
+ }
196
+ },
197
+
198
+ toggle: {
199
+ state: function () {
200
+ var
201
+ apiRequest,
202
+ requestCancelled
203
+ ;
204
+ if (module.allows('active') && module.is.enabled()) {
205
+ module.refresh();
206
+ if ($.fn.api !== undefined) {
207
+ apiRequest = $module.api('get request');
208
+ requestCancelled = $module.api('was cancelled');
209
+ if (requestCancelled) {
210
+ module.debug('API Request cancelled by beforesend');
211
+ settings.activateTest = function () {
212
+ return false;
213
+ };
214
+ settings.deactivateTest = function () {
215
+ return false;
216
+ };
217
+ } else if (apiRequest) {
218
+ module.listenTo(apiRequest);
219
+
220
+ return;
221
+ }
222
+ }
223
+ module.change.state();
224
+ }
225
+ },
226
+ },
227
+
228
+ listenTo: function (apiRequest) {
229
+ module.debug('API request detected, waiting for state signal', apiRequest);
230
+ if (apiRequest) {
231
+ if (text.loading) {
232
+ module.update.text(text.loading);
233
+ }
234
+ $.when(apiRequest)
235
+ .then(function () {
236
+ if (apiRequest.state() === 'resolved') {
237
+ module.debug('API request succeeded');
238
+ settings.activateTest = function () {
239
+ return true;
240
+ };
241
+ settings.deactivateTest = function () {
242
+ return true;
243
+ };
244
+ } else {
245
+ module.debug('API request failed');
246
+ settings.activateTest = function () {
247
+ return false;
248
+ };
249
+ settings.deactivateTest = function () {
250
+ return false;
251
+ };
252
+ }
253
+ module.change.state();
254
+ })
255
+ ;
256
+ }
257
+ },
258
+
259
+ // checks whether active/inactive state can be given
260
+ change: {
261
+
262
+ state: function () {
263
+ module.debug('Determining state change direction');
264
+ // inactive to active change
265
+ if (module.is.inactive()) {
266
+ module.activate();
267
+ } else {
268
+ module.deactivate();
269
+ }
270
+ if (settings.sync) {
271
+ module.sync();
272
+ }
273
+ settings.onChange.call(element);
274
+ },
275
+
276
+ text: function () {
277
+ if (module.is.textEnabled()) {
278
+ if (module.is.disabled()) {
279
+ module.verbose('Changing text to disabled text', text.hover);
280
+ module.update.text(text.disabled);
281
+ } else if (module.is.active()) {
282
+ if (text.hover) {
283
+ module.verbose('Changing text to hover text', text.hover);
284
+ module.update.text(text.hover);
285
+ } else if (text.deactivate) {
286
+ module.verbose('Changing text to deactivating text', text.deactivate);
287
+ module.update.text(text.deactivate);
288
+ }
289
+ } else {
290
+ if (text.hover) {
291
+ module.verbose('Changing text to hover text', text.hover);
292
+ module.update.text(text.hover);
293
+ } else if (text.activate) {
294
+ module.verbose('Changing text to activating text', text.activate);
295
+ module.update.text(text.activate);
296
+ }
297
+ }
298
+ }
299
+ },
300
+
301
+ },
302
+
303
+ activate: function () {
304
+ if (settings.activateTest.call(element)) {
305
+ module.debug('Setting state to active');
306
+ $module
307
+ .addClass(className.active)
308
+ ;
309
+ module.update.text(text.active);
310
+ settings.onActivate.call(element);
311
+ }
312
+ },
313
+
314
+ deactivate: function () {
315
+ if (settings.deactivateTest.call(element)) {
316
+ module.debug('Setting state to inactive');
317
+ $module
318
+ .removeClass(className.active)
319
+ ;
320
+ module.update.text(text.inactive);
321
+ settings.onDeactivate.call(element);
322
+ }
323
+ },
324
+
325
+ sync: function () {
326
+ module.verbose('Syncing other buttons to current state');
327
+ if (module.is.active()) {
328
+ $allModules
329
+ .not($module)
330
+ .state('activate')
331
+ ;
332
+ } else {
333
+ $allModules
334
+ .not($module)
335
+ .state('deactivate')
336
+ ;
337
+ }
338
+ },
339
+
340
+ get: {
341
+ text: function () {
342
+ return settings.selector.text
343
+ ? $module.find(settings.selector.text).text()
344
+ : $module.html();
345
+ },
346
+ textFor: function (state) {
347
+ return text[state] || false;
348
+ },
349
+ },
350
+
351
+ flash: {
352
+ text: function (text, duration, callback) {
353
+ var
354
+ previousText = module.get.text();
355
+ module.debug('Flashing text message', text, duration);
356
+ text = text || settings.text.flash;
357
+ duration = duration || settings.flashDuration;
358
+ callback = callback || function () {};
359
+ module.update.text(text);
360
+ setTimeout(function () {
361
+ module.update.text(previousText);
362
+ callback.call(element);
363
+ }, duration);
364
+ },
365
+ },
366
+
367
+ reset: {
368
+ // on mouseout sets text to previous value
369
+ text: function () {
370
+ var
371
+ activeText = text.active || $module.data(metadata.storedText),
372
+ inactiveText = text.inactive || $module.data(metadata.storedText)
373
+ ;
374
+ if (module.is.textEnabled()) {
375
+ if (module.is.active() && activeText) {
376
+ module.verbose('Resetting active text', activeText);
377
+ module.update.text(activeText);
378
+ } else if (inactiveText) {
379
+ module.verbose('Resetting inactive text', activeText);
380
+ module.update.text(inactiveText);
381
+ }
382
+ }
383
+ },
384
+ },
385
+
386
+ update: {
387
+ text: function (text) {
388
+ var
389
+ currentText = module.get.text();
390
+ if (text && text !== currentText) {
391
+ module.debug('Updating text', text);
392
+ if (settings.selector.text) {
393
+ $module
394
+ .data(metadata.storedText, text)
395
+ .find(settings.selector.text)
396
+ .text(text)
397
+ ;
398
+ } else {
399
+ $module
400
+ .data(metadata.storedText, text)
401
+ .html(text)
402
+ ;
403
+ }
404
+ } else {
405
+ module.debug('Text is already set, ignoring update', text);
406
+ }
407
+ },
408
+ },
409
+
410
+ setting: function (name, value) {
411
+ module.debug('Changing setting', name, value);
412
+ if ($.isPlainObject(name)) {
413
+ $.extend(true, settings, name);
414
+ } else if (value !== undefined) {
415
+ if ($.isPlainObject(settings[name])) {
416
+ $.extend(true, settings[name], value);
417
+ } else {
418
+ settings[name] = value;
419
+ }
420
+ } else {
421
+ return settings[name];
422
+ }
423
+ },
424
+ internal: function (name, value) {
425
+ if ($.isPlainObject(name)) {
426
+ $.extend(true, module, name);
427
+ } else if (value !== undefined) {
428
+ module[name] = value;
429
+ } else {
430
+ return module[name];
431
+ }
432
+ },
433
+ debug: function () {
434
+ if (!settings.silent && settings.debug) {
435
+ if (settings.performance) {
436
+ module.performance.log(arguments);
437
+ } else {
438
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
439
+ module.debug.apply(console, arguments);
440
+ }
441
+ }
442
+ },
443
+ verbose: function () {
444
+ if (!settings.silent && settings.verbose && settings.debug) {
445
+ if (settings.performance) {
446
+ module.performance.log(arguments);
447
+ } else {
448
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
449
+ module.verbose.apply(console, arguments);
450
+ }
451
+ }
452
+ },
453
+ error: function () {
454
+ if (!settings.silent) {
455
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
456
+ module.error.apply(console, arguments);
457
+ }
458
+ },
459
+ performance: {
460
+ log: function (message) {
461
+ var
462
+ currentTime,
463
+ executionTime,
464
+ previousTime
465
+ ;
466
+ if (settings.performance) {
467
+ currentTime = Date.now();
468
+ previousTime = time || currentTime;
469
+ executionTime = currentTime - previousTime;
470
+ time = currentTime;
471
+ performance.push({
472
+ Name: message[0],
473
+ Arguments: [].slice.call(message, 1) || '',
474
+ Element: element,
475
+ 'Execution Time': executionTime,
476
+ });
477
+ }
478
+ clearTimeout(module.performance.timer);
479
+ module.performance.timer = setTimeout(module.performance.display, 500);
480
+ },
481
+ display: function () {
482
+ var
483
+ title = settings.name + ':',
484
+ totalTime = 0
485
+ ;
486
+ time = false;
487
+ clearTimeout(module.performance.timer);
488
+ $.each(performance, function (index, data) {
489
+ totalTime += data['Execution Time'];
490
+ });
491
+ title += ' ' + totalTime + 'ms';
492
+ if (moduleSelector) {
493
+ title += ' \'' + moduleSelector + '\'';
494
+ }
495
+ if (performance.length > 0) {
496
+ console.groupCollapsed(title);
497
+ if (console.table) {
498
+ console.table(performance);
499
+ } else {
500
+ $.each(performance, function (index, data) {
501
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
502
+ });
503
+ }
504
+ console.groupEnd();
505
+ }
506
+ performance = [];
507
+ },
508
+ },
509
+ invoke: function (query, passedArguments, context) {
510
+ var
511
+ object = instance,
512
+ maxDepth,
513
+ found,
514
+ response
515
+ ;
516
+ passedArguments = passedArguments || queryArguments;
517
+ context = context || element;
518
+ if (typeof query === 'string' && object !== undefined) {
519
+ query = query.split(/[ .]/);
520
+ maxDepth = query.length - 1;
521
+ $.each(query, function (depth, value) {
522
+ var camelCaseValue = depth !== maxDepth
523
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
524
+ : query
525
+ ;
526
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
527
+ object = object[camelCaseValue];
528
+ } else if (object[camelCaseValue] !== undefined) {
529
+ found = object[camelCaseValue];
530
+
531
+ return false;
532
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
533
+ object = object[value];
534
+ } else if (object[value] !== undefined) {
535
+ found = object[value];
536
+
537
+ return false;
538
+ } else {
539
+ module.error(error.method, query);
540
+
541
+ return false;
542
+ }
543
+ });
544
+ }
545
+ if (isFunction(found)) {
546
+ response = found.apply(context, passedArguments);
547
+ } else if (found !== undefined) {
548
+ response = found;
549
+ }
550
+ if (Array.isArray(returnedValue)) {
551
+ returnedValue.push(response);
552
+ } else if (returnedValue !== undefined) {
553
+ returnedValue = [returnedValue, response];
554
+ } else if (response !== undefined) {
555
+ returnedValue = response;
556
+ }
557
+
558
+ return found;
559
+ },
560
+ };
561
+
562
+ if (methodInvoked) {
563
+ if (instance === undefined) {
564
+ module.initialize();
565
+ }
566
+ module.invoke(query);
567
+ } else {
568
+ if (instance !== undefined) {
569
+ instance.invoke('destroy');
570
+ }
571
+ module.initialize();
572
+ }
573
+ });
108
574
 
109
- refresh: function() {
110
- module.verbose('Refreshing selector cache');
111
- $module = $(element);
112
- },
575
+ return returnedValue !== undefined
576
+ ? returnedValue
577
+ : this;
578
+ };
113
579
 
114
- add: {
115
- defaults: function() {
116
- var
117
- userStates = parameters && $.isPlainObject(parameters.states)
118
- ? parameters.states
119
- : {}
120
- ;
121
- $.each(settings.defaults, function(type, typeStates) {
122
- if( module.is[type] !== undefined && module.is[type]() ) {
123
- module.verbose('Adding default states', type, element);
124
- $.extend(settings.states, typeStates, userStates);
125
- }
126
- });
127
- }
128
- },
580
+ $.fn.state.settings = {
129
581
 
130
- is: {
131
-
132
- active: function() {
133
- return $module.hasClass(className.active);
134
- },
135
- loading: function() {
136
- return $module.hasClass(className.loading);
137
- },
138
- inactive: function() {
139
- return !( $module.hasClass(className.active) );
140
- },
141
- state: function(state) {
142
- if(className[state] === undefined) {
143
- return false;
144
- }
145
- return $module.hasClass( className[state] );
146
- },
147
-
148
- enabled: function() {
149
- return !( $module.is(settings.filter.active) );
150
- },
151
- disabled: function() {
152
- return ( $module.is(settings.filter.active) );
153
- },
154
- textEnabled: function() {
155
- return !( $module.is(settings.filter.text) );
156
- },
157
-
158
- // definitions for automatic type detection
159
- button: function() {
160
- return $module.is('.button:not(a, .submit)');
161
- },
162
- input: function() {
163
- return $module.is('input');
164
- },
165
- progress: function() {
166
- return $module.is('.ui.progress');
167
- }
168
- },
582
+ // module info
583
+ name: 'State',
169
584
 
170
- allow: function(state) {
171
- module.debug('Now allowing state', state);
172
- states[state] = true;
173
- },
174
- disallow: function(state) {
175
- module.debug('No longer allowing', state);
176
- states[state] = false;
177
- },
585
+ // debug output
586
+ debug: false,
178
587
 
179
- allows: function(state) {
180
- return states[state] || false;
181
- },
588
+ // verbose debug output
589
+ verbose: false,
182
590
 
183
- enable: function() {
184
- $module.removeClass(className.disabled);
185
- },
591
+ // namespace for events
592
+ namespace: 'state',
186
593
 
187
- disable: function() {
188
- $module.addClass(className.disabled);
189
- },
594
+ // debug data includes performance
595
+ performance: true,
190
596
 
191
- setState: function(state) {
192
- if(module.allows(state)) {
193
- $module.addClass( className[state] );
194
- }
195
- },
597
+ // callback occurs on state change
598
+ onActivate: function () {},
599
+ onDeactivate: function () {},
600
+ onChange: function () {},
196
601
 
197
- removeState: function(state) {
198
- if(module.allows(state)) {
199
- $module.removeClass( className[state] );
200
- }
602
+ // state test functions
603
+ activateTest: function () {
604
+ return true;
201
605
  },
202
-
203
- toggle: {
204
- state: function() {
205
- var
206
- apiRequest,
207
- requestCancelled
208
- ;
209
- if( module.allows('active') && module.is.enabled() ) {
210
- module.refresh();
211
- if($.fn.api !== undefined) {
212
- apiRequest = $module.api('get request');
213
- requestCancelled = $module.api('was cancelled');
214
- if( requestCancelled ) {
215
- module.debug('API Request cancelled by beforesend');
216
- settings.activateTest = function(){ return false; };
217
- settings.deactivateTest = function(){ return false; };
218
- }
219
- else if(apiRequest) {
220
- module.listenTo(apiRequest);
221
- return;
222
- }
223
- }
224
- module.change.state();
225
- }
226
- }
606
+ deactivateTest: function () {
607
+ return true;
227
608
  },
228
609
 
229
- listenTo: function(apiRequest) {
230
- module.debug('API request detected, waiting for state signal', apiRequest);
231
- if(apiRequest) {
232
- if(text.loading) {
233
- module.update.text(text.loading);
234
- }
235
- $.when(apiRequest)
236
- .then(function() {
237
- if(apiRequest.state() == 'resolved') {
238
- module.debug('API request succeeded');
239
- settings.activateTest = function(){ return true; };
240
- settings.deactivateTest = function(){ return true; };
241
- }
242
- else {
243
- module.debug('API request failed');
244
- settings.activateTest = function(){ return false; };
245
- settings.deactivateTest = function(){ return false; };
246
- }
247
- module.change.state();
248
- })
249
- ;
250
- }
251
- },
610
+ // whether to automatically map default states
611
+ automatic: true,
252
612
 
253
- // checks whether active/inactive state can be given
254
- change: {
613
+ // activate / deactivate changes all elements instantiated at same time
614
+ sync: false,
255
615
 
256
- state: function() {
257
- module.debug('Determining state change direction');
258
- // inactive to active change
259
- if( module.is.inactive() ) {
260
- module.activate();
261
- }
262
- else {
263
- module.deactivate();
264
- }
265
- if(settings.sync) {
266
- module.sync();
267
- }
268
- settings.onChange.call(element);
269
- },
270
-
271
- text: function() {
272
- if( module.is.textEnabled() ) {
273
- if(module.is.disabled() ) {
274
- module.verbose('Changing text to disabled text', text.hover);
275
- module.update.text(text.disabled);
276
- }
277
- else if( module.is.active() ) {
278
- if(text.hover) {
279
- module.verbose('Changing text to hover text', text.hover);
280
- module.update.text(text.hover);
281
- }
282
- else if(text.deactivate) {
283
- module.verbose('Changing text to deactivating text', text.deactivate);
284
- module.update.text(text.deactivate);
285
- }
286
- }
287
- else {
288
- if(text.hover) {
289
- module.verbose('Changing text to hover text', text.hover);
290
- module.update.text(text.hover);
291
- }
292
- else if(text.activate){
293
- module.verbose('Changing text to activating text', text.activate);
294
- module.update.text(text.activate);
295
- }
296
- }
297
- }
298
- }
616
+ // default flash text duration, used for temporarily changing text of an element
617
+ flashDuration: 1000,
299
618
 
619
+ // selector filter
620
+ filter: {
621
+ text: '.loading, .disabled',
622
+ active: '.disabled',
300
623
  },
301
624
 
302
- activate: function() {
303
- if( settings.activateTest.call(element) ) {
304
- module.debug('Setting state to active');
305
- $module
306
- .addClass(className.active)
307
- ;
308
- module.update.text(text.active);
309
- settings.onActivate.call(element);
310
- }
311
- },
625
+ context: false,
312
626
 
313
- deactivate: function() {
314
- if( settings.deactivateTest.call(element) ) {
315
- module.debug('Setting state to inactive');
316
- $module
317
- .removeClass(className.active)
318
- ;
319
- module.update.text(text.inactive);
320
- settings.onDeactivate.call(element);
321
- }
627
+ // error
628
+ error: {
629
+ method: 'The method you called is not defined.',
322
630
  },
323
631
 
324
- sync: function() {
325
- module.verbose('Syncing other buttons to current state');
326
- if( module.is.active() ) {
327
- $allModules
328
- .not($module)
329
- .state('activate');
330
- }
331
- else {
332
- $allModules
333
- .not($module)
334
- .state('deactivate')
335
- ;
336
- }
632
+ // metadata
633
+ metadata: {
634
+ promise: 'promise',
635
+ storedText: 'stored-text',
337
636
  },
338
637
 
339
- get: {
340
- text: function() {
341
- return (settings.selector.text)
342
- ? $module.find(settings.selector.text).text()
343
- : $module.html()
344
- ;
345
- },
346
- textFor: function(state) {
347
- return text[state] || false;
348
- }
638
+ // change class on state
639
+ className: {
640
+ active: 'active',
641
+ disabled: 'disabled',
642
+ error: 'error',
643
+ loading: 'loading',
644
+ success: 'success',
645
+ warning: 'warning',
349
646
  },
350
647
 
351
- flash: {
352
- text: function(text, duration, callback) {
353
- var
354
- previousText = module.get.text()
355
- ;
356
- module.debug('Flashing text message', text, duration);
357
- text = text || settings.text.flash;
358
- duration = duration || settings.flashDuration;
359
- callback = callback || function() {};
360
- module.update.text(text);
361
- setTimeout(function(){
362
- module.update.text(previousText);
363
- callback.call(element);
364
- }, duration);
365
- }
648
+ selector: {
649
+ // selector for text node
650
+ text: false,
366
651
  },
367
652
 
368
- reset: {
369
- // on mouseout sets text to previous value
370
- text: function() {
371
- var
372
- activeText = text.active || $module.data(metadata.storedText),
373
- inactiveText = text.inactive || $module.data(metadata.storedText)
374
- ;
375
- if( module.is.textEnabled() ) {
376
- if( module.is.active() && activeText) {
377
- module.verbose('Resetting active text', activeText);
378
- module.update.text(activeText);
379
- }
380
- else if(inactiveText) {
381
- module.verbose('Resetting inactive text', activeText);
382
- module.update.text(inactiveText);
383
- }
384
- }
385
- }
653
+ defaults: {
654
+ input: {
655
+ disabled: true,
656
+ loading: true,
657
+ active: true,
658
+ },
659
+ button: {
660
+ disabled: true,
661
+ loading: true,
662
+ active: true,
663
+ },
664
+ progress: {
665
+ active: true,
666
+ success: true,
667
+ warning: true,
668
+ error: true,
669
+ },
386
670
  },
387
671
 
388
- update: {
389
- text: function(text) {
390
- var
391
- currentText = module.get.text()
392
- ;
393
- if(text && text !== currentText) {
394
- module.debug('Updating text', text);
395
- if(settings.selector.text) {
396
- $module
397
- .data(metadata.storedText, text)
398
- .find(settings.selector.text)
399
- .text(text)
400
- ;
401
- }
402
- else {
403
- $module
404
- .data(metadata.storedText, text)
405
- .html(text)
406
- ;
407
- }
408
- }
409
- else {
410
- module.debug('Text is already set, ignoring update', text);
411
- }
412
- }
672
+ states: {
673
+ active: true,
674
+ disabled: true,
675
+ error: true,
676
+ loading: true,
677
+ success: true,
678
+ warning: true,
413
679
  },
414
680
 
415
- setting: function(name, value) {
416
- module.debug('Changing setting', name, value);
417
- if( $.isPlainObject(name) ) {
418
- $.extend(true, settings, name);
419
- }
420
- else if(value !== undefined) {
421
- if($.isPlainObject(settings[name])) {
422
- $.extend(true, settings[name], value);
423
- }
424
- else {
425
- settings[name] = value;
426
- }
427
- }
428
- else {
429
- return settings[name];
430
- }
431
- },
432
- internal: function(name, value) {
433
- if( $.isPlainObject(name) ) {
434
- $.extend(true, module, name);
435
- }
436
- else if(value !== undefined) {
437
- module[name] = value;
438
- }
439
- else {
440
- return module[name];
441
- }
681
+ text: {
682
+ disabled: false,
683
+ flash: false,
684
+ hover: false,
685
+ active: false,
686
+ inactive: false,
687
+ activate: false,
688
+ deactivate: false,
442
689
  },
443
- debug: function() {
444
- if(!settings.silent && settings.debug) {
445
- if(settings.performance) {
446
- module.performance.log(arguments);
447
- }
448
- else {
449
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
450
- module.debug.apply(console, arguments);
451
- }
452
- }
453
- },
454
- verbose: function() {
455
- if(!settings.silent && settings.verbose && settings.debug) {
456
- if(settings.performance) {
457
- module.performance.log(arguments);
458
- }
459
- else {
460
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
461
- module.verbose.apply(console, arguments);
462
- }
463
- }
464
- },
465
- error: function() {
466
- if(!settings.silent) {
467
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
468
- module.error.apply(console, arguments);
469
- }
470
- },
471
- performance: {
472
- log: function(message) {
473
- var
474
- currentTime,
475
- executionTime,
476
- previousTime
477
- ;
478
- if(settings.performance) {
479
- currentTime = new Date().getTime();
480
- previousTime = time || currentTime;
481
- executionTime = currentTime - previousTime;
482
- time = currentTime;
483
- performance.push({
484
- 'Name' : message[0],
485
- 'Arguments' : [].slice.call(message, 1) || '',
486
- 'Element' : element,
487
- 'Execution Time' : executionTime
488
- });
489
- }
490
- clearTimeout(module.performance.timer);
491
- module.performance.timer = setTimeout(module.performance.display, 500);
492
- },
493
- display: function() {
494
- var
495
- title = settings.name + ':',
496
- totalTime = 0
497
- ;
498
- time = false;
499
- clearTimeout(module.performance.timer);
500
- $.each(performance, function(index, data) {
501
- totalTime += data['Execution Time'];
502
- });
503
- title += ' ' + totalTime + 'ms';
504
- if(moduleSelector) {
505
- title += ' \'' + moduleSelector + '\'';
506
- }
507
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
508
- console.groupCollapsed(title);
509
- if(console.table) {
510
- console.table(performance);
511
- }
512
- else {
513
- $.each(performance, function(index, data) {
514
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
515
- });
516
- }
517
- console.groupEnd();
518
- }
519
- performance = [];
520
- }
521
- },
522
- invoke: function(query, passedArguments, context) {
523
- var
524
- object = instance,
525
- maxDepth,
526
- found,
527
- response
528
- ;
529
- passedArguments = passedArguments || queryArguments;
530
- context = element || context;
531
- if(typeof query == 'string' && object !== undefined) {
532
- query = query.split(/[\. ]/);
533
- maxDepth = query.length - 1;
534
- $.each(query, function(depth, value) {
535
- var camelCaseValue = (depth != maxDepth)
536
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
537
- : query
538
- ;
539
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
540
- object = object[camelCaseValue];
541
- }
542
- else if( object[camelCaseValue] !== undefined ) {
543
- found = object[camelCaseValue];
544
- return false;
545
- }
546
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
547
- object = object[value];
548
- }
549
- else if( object[value] !== undefined ) {
550
- found = object[value];
551
- return false;
552
- }
553
- else {
554
- module.error(error.method, query);
555
- return false;
556
- }
557
- });
558
- }
559
- if ( $.isFunction( found ) ) {
560
- response = found.apply(context, passedArguments);
561
- }
562
- else if(found !== undefined) {
563
- response = found;
564
- }
565
- if(Array.isArray(returnedValue)) {
566
- returnedValue.push(response);
567
- }
568
- else if(returnedValue !== undefined) {
569
- returnedValue = [returnedValue, response];
570
- }
571
- else if(response !== undefined) {
572
- returnedValue = response;
573
- }
574
- return found;
575
- }
576
- };
577
-
578
- if(methodInvoked) {
579
- if(instance === undefined) {
580
- module.initialize();
581
- }
582
- module.invoke(query);
583
- }
584
- else {
585
- if(instance !== undefined) {
586
- instance.invoke('destroy');
587
- }
588
- module.initialize();
589
- }
590
- })
591
- ;
592
-
593
- return (returnedValue !== undefined)
594
- ? returnedValue
595
- : this
596
- ;
597
- };
598
-
599
- $.fn.state.settings = {
600
-
601
- // module info
602
- name : 'State',
603
-
604
- // debug output
605
- debug : false,
606
-
607
- // verbose debug output
608
- verbose : false,
609
-
610
- // namespace for events
611
- namespace : 'state',
612
-
613
- // debug data includes performance
614
- performance : true,
615
-
616
- // callback occurs on state change
617
- onActivate : function() {},
618
- onDeactivate : function() {},
619
- onChange : function() {},
620
-
621
- // state test functions
622
- activateTest : function() { return true; },
623
- deactivateTest : function() { return true; },
624
-
625
- // whether to automatically map default states
626
- automatic : true,
627
-
628
- // activate / deactivate changes all elements instantiated at same time
629
- sync : false,
630
-
631
- // default flash text duration, used for temporarily changing text of an element
632
- flashDuration : 1000,
633
-
634
- // selector filter
635
- filter : {
636
- text : '.loading, .disabled',
637
- active : '.disabled'
638
- },
639
-
640
- context : false,
641
-
642
- // error
643
- error: {
644
- beforeSend : 'The before send function has cancelled state change',
645
- method : 'The method you called is not defined.'
646
- },
647
-
648
- // metadata
649
- metadata: {
650
- promise : 'promise',
651
- storedText : 'stored-text'
652
- },
653
-
654
- // change class on state
655
- className: {
656
- active : 'active',
657
- disabled : 'disabled',
658
- error : 'error',
659
- loading : 'loading',
660
- success : 'success',
661
- warning : 'warning'
662
- },
663
-
664
- selector: {
665
- // selector for text node
666
- text: false
667
- },
668
-
669
- defaults : {
670
- input: {
671
- disabled : true,
672
- loading : true,
673
- active : true
674
- },
675
- button: {
676
- disabled : true,
677
- loading : true,
678
- active : true,
679
- },
680
- progress: {
681
- active : true,
682
- success : true,
683
- warning : true,
684
- error : true
685
- }
686
- },
687
-
688
- states : {
689
- active : true,
690
- disabled : true,
691
- error : true,
692
- loading : true,
693
- success : true,
694
- warning : true
695
- },
696
-
697
- text : {
698
- disabled : false,
699
- flash : false,
700
- hover : false,
701
- active : false,
702
- inactive : false,
703
- activate : false,
704
- deactivate : false
705
- }
706
-
707
- };
708
-
709
-
710
690
 
711
- })( jQuery, window, document );
691
+ };
692
+ })(jQuery, window, document);