fomantic-ui 2.10.0-beta.0 → 2.10.0-beta.10

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 (288) hide show
  1. package/.all-contributorsrc +9 -0
  2. package/.eslintrc.js +0 -10
  3. package/.github/workflows/ci.yml +3 -3
  4. package/CONTRIBUTING.md +4 -1
  5. package/CONTRIBUTORS.md +1 -0
  6. package/FAQ.md +7 -2
  7. package/README.md +5 -9
  8. package/ROADMAP.md +4 -4
  9. package/SECURITY.md +8 -7
  10. package/changelog-setup.js +64 -70
  11. package/dist/components/accordion.css +1 -1
  12. package/dist/components/accordion.js +103 -142
  13. package/dist/components/accordion.min.css +1 -1
  14. package/dist/components/accordion.min.js +2 -2
  15. package/dist/components/ad.css +1 -1
  16. package/dist/components/ad.min.css +1 -1
  17. package/dist/components/api.js +157 -210
  18. package/dist/components/api.min.js +2 -2
  19. package/dist/components/breadcrumb.css +1 -1
  20. package/dist/components/breadcrumb.min.css +1 -1
  21. package/dist/components/button.css +1 -2
  22. package/dist/components/button.min.css +2 -2
  23. package/dist/components/calendar.css +1 -2
  24. package/dist/components/calendar.js +314 -352
  25. package/dist/components/calendar.min.css +2 -2
  26. package/dist/components/calendar.min.js +2 -2
  27. package/dist/components/card.css +1 -1
  28. package/dist/components/card.min.css +1 -1
  29. package/dist/components/checkbox.css +1 -2
  30. package/dist/components/checkbox.js +85 -135
  31. package/dist/components/checkbox.min.css +2 -2
  32. package/dist/components/checkbox.min.js +2 -2
  33. package/dist/components/comment.css +1 -1
  34. package/dist/components/comment.min.css +1 -1
  35. package/dist/components/container.css +2 -4
  36. package/dist/components/container.min.css +2 -2
  37. package/dist/components/dimmer.css +1 -11
  38. package/dist/components/dimmer.js +61 -94
  39. package/dist/components/dimmer.min.css +2 -2
  40. package/dist/components/dimmer.min.js +2 -2
  41. package/dist/components/divider.css +1 -2
  42. package/dist/components/divider.min.css +2 -2
  43. package/dist/components/dropdown.css +30 -51
  44. package/dist/components/dropdown.js +736 -1055
  45. package/dist/components/dropdown.min.css +2 -2
  46. package/dist/components/dropdown.min.js +2 -2
  47. package/dist/components/embed.css +1 -1
  48. package/dist/components/embed.js +85 -114
  49. package/dist/components/embed.min.css +1 -1
  50. package/dist/components/embed.min.js +2 -2
  51. package/dist/components/emoji.css +3809 -7617
  52. package/dist/components/emoji.min.css +2 -2
  53. package/dist/components/feed.css +1 -1
  54. package/dist/components/feed.min.css +1 -1
  55. package/dist/components/flag.css +1 -1
  56. package/dist/components/flag.min.css +1 -1
  57. package/dist/components/flyout.css +2 -3
  58. package/dist/components/flyout.js +226 -355
  59. package/dist/components/flyout.min.css +2 -2
  60. package/dist/components/flyout.min.js +2 -2
  61. package/dist/components/form.css +5 -95
  62. package/dist/components/form.js +335 -444
  63. package/dist/components/form.min.css +2 -2
  64. package/dist/components/form.min.js +2 -2
  65. package/dist/components/grid.css +2 -58
  66. package/dist/components/grid.min.css +2 -2
  67. package/dist/components/header.css +1 -1
  68. package/dist/components/header.min.css +1 -1
  69. package/dist/components/icon.css +4 -4
  70. package/dist/components/icon.min.css +2 -2
  71. package/dist/components/image.css +1 -1
  72. package/dist/components/image.min.css +1 -1
  73. package/dist/components/input.css +1 -536
  74. package/dist/components/input.min.css +2 -2
  75. package/dist/components/item.css +1 -1
  76. package/dist/components/item.min.css +1 -1
  77. package/dist/components/label.css +1 -1
  78. package/dist/components/label.min.css +1 -1
  79. package/dist/components/list.css +1 -3
  80. package/dist/components/list.min.css +2 -2
  81. package/dist/components/loader.css +1 -1
  82. package/dist/components/loader.min.css +1 -1
  83. package/dist/components/menu.css +1 -9
  84. package/dist/components/menu.min.css +2 -2
  85. package/dist/components/message.css +1 -1
  86. package/dist/components/message.min.css +1 -1
  87. package/dist/components/modal.css +5 -9
  88. package/dist/components/modal.js +261 -384
  89. package/dist/components/modal.min.css +2 -2
  90. package/dist/components/modal.min.js +2 -2
  91. package/dist/components/nag.css +1 -1
  92. package/dist/components/nag.js +68 -98
  93. package/dist/components/nag.min.css +1 -1
  94. package/dist/components/nag.min.js +2 -2
  95. package/dist/components/placeholder.css +1 -1
  96. package/dist/components/placeholder.min.css +1 -1
  97. package/dist/components/popup.css +1 -2
  98. package/dist/components/popup.js +198 -271
  99. package/dist/components/popup.min.css +2 -2
  100. package/dist/components/popup.min.js +2 -2
  101. package/dist/components/progress.css +1 -1
  102. package/dist/components/progress.js +109 -144
  103. package/dist/components/progress.min.css +1 -1
  104. package/dist/components/progress.min.js +2 -2
  105. package/dist/components/rail.css +1 -1
  106. package/dist/components/rail.min.css +1 -1
  107. package/dist/components/rating.css +1 -1
  108. package/dist/components/rating.js +91 -123
  109. package/dist/components/rating.min.css +1 -1
  110. package/dist/components/rating.min.js +2 -2
  111. package/dist/components/reset.css +1 -1
  112. package/dist/components/reset.min.css +1 -1
  113. package/dist/components/reveal.css +1 -1
  114. package/dist/components/reveal.min.css +1 -1
  115. package/dist/components/search.css +2 -9
  116. package/dist/components/search.js +277 -379
  117. package/dist/components/search.min.css +2 -2
  118. package/dist/components/search.min.js +2 -2
  119. package/dist/components/segment.css +2 -7
  120. package/dist/components/segment.min.css +2 -2
  121. package/dist/components/shape.css +1 -2
  122. package/dist/components/shape.js +158 -224
  123. package/dist/components/shape.min.css +2 -2
  124. package/dist/components/shape.min.js +2 -2
  125. package/dist/components/sidebar.css +2 -3
  126. package/dist/components/sidebar.js +124 -206
  127. package/dist/components/sidebar.min.css +2 -2
  128. package/dist/components/sidebar.min.js +2 -2
  129. package/dist/components/site.css +9 -25
  130. package/dist/components/site.js +38 -57
  131. package/dist/components/site.min.css +2 -2
  132. package/dist/components/site.min.js +2 -2
  133. package/dist/components/slider.css +1 -1
  134. package/dist/components/slider.js +246 -329
  135. package/dist/components/slider.min.css +1 -1
  136. package/dist/components/slider.min.js +2 -2
  137. package/dist/components/state.js +70 -100
  138. package/dist/components/state.min.js +2 -2
  139. package/dist/components/statistic.css +1 -1
  140. package/dist/components/statistic.min.css +1 -1
  141. package/dist/components/step.css +1 -1
  142. package/dist/components/step.min.css +1 -1
  143. package/dist/components/sticky.css +1 -1
  144. package/dist/components/sticky.js +135 -180
  145. package/dist/components/sticky.min.css +1 -1
  146. package/dist/components/sticky.min.js +2 -2
  147. package/dist/components/tab.css +1 -1
  148. package/dist/components/tab.js +176 -244
  149. package/dist/components/tab.min.css +1 -1
  150. package/dist/components/tab.min.js +2 -2
  151. package/dist/components/table.css +3 -37
  152. package/dist/components/table.min.css +2 -2
  153. package/dist/components/text.css +1 -1
  154. package/dist/components/text.min.css +1 -1
  155. package/dist/components/toast.css +1 -3
  156. package/dist/components/toast.js +109 -147
  157. package/dist/components/toast.min.css +1 -1
  158. package/dist/components/toast.min.js +2 -2
  159. package/dist/components/transition.css +1 -1
  160. package/dist/components/transition.js +91 -146
  161. package/dist/components/transition.min.css +1 -1
  162. package/dist/components/transition.min.js +2 -2
  163. package/dist/components/visibility.js +146 -224
  164. package/dist/components/visibility.min.js +2 -2
  165. package/dist/semantic.css +3906 -8720
  166. package/dist/semantic.js +4397 -6155
  167. package/dist/semantic.min.css +2 -2
  168. package/dist/semantic.min.js +2 -2
  169. package/examples/assets/show-examples.js +2 -4
  170. package/gulpfile.js +5 -7
  171. package/package.json +20 -16
  172. package/scripts/nightly-version.js +7 -10
  173. package/src/README.md +3 -3
  174. package/src/definitions/behaviors/api.js +156 -209
  175. package/src/definitions/behaviors/form.js +334 -443
  176. package/src/definitions/behaviors/state.js +69 -99
  177. package/src/definitions/behaviors/visibility.js +145 -223
  178. package/src/definitions/collections/form.less +1 -13
  179. package/src/definitions/collections/grid.less +1 -61
  180. package/src/definitions/collections/menu.less +0 -11
  181. package/src/definitions/collections/table.less +1 -35
  182. package/src/definitions/elements/input.less +1 -61
  183. package/src/definitions/elements/segment.less +0 -6
  184. package/src/definitions/globals/site.js +37 -56
  185. package/src/definitions/globals/site.less +2 -18
  186. package/src/definitions/modules/accordion.js +102 -141
  187. package/src/definitions/modules/calendar.js +313 -351
  188. package/src/definitions/modules/checkbox.js +84 -134
  189. package/src/definitions/modules/dimmer.js +60 -93
  190. package/src/definitions/modules/dimmer.less +0 -9
  191. package/src/definitions/modules/dropdown.js +735 -1054
  192. package/src/definitions/modules/dropdown.less +31 -47
  193. package/src/definitions/modules/embed.js +84 -113
  194. package/src/definitions/modules/flyout.js +225 -354
  195. package/src/definitions/modules/modal.js +260 -383
  196. package/src/definitions/modules/modal.less +1 -1
  197. package/src/definitions/modules/nag.js +67 -97
  198. package/src/definitions/modules/popup.js +197 -270
  199. package/src/definitions/modules/progress.js +108 -143
  200. package/src/definitions/modules/rating.js +90 -122
  201. package/src/definitions/modules/search.js +276 -378
  202. package/src/definitions/modules/search.less +0 -3
  203. package/src/definitions/modules/shape.js +157 -223
  204. package/src/definitions/modules/sidebar.js +123 -205
  205. package/src/definitions/modules/slider.js +245 -328
  206. package/src/definitions/modules/slider.less +1 -1
  207. package/src/definitions/modules/sticky.js +134 -179
  208. package/src/definitions/modules/tab.js +175 -243
  209. package/src/definitions/modules/toast.js +108 -146
  210. package/src/definitions/modules/toast.less +1 -1
  211. package/src/definitions/modules/transition.js +90 -145
  212. package/src/theme.less +0 -13
  213. package/src/themes/basic/elements/icon.variables +1 -1
  214. package/src/themes/default/collections/grid.variables +0 -30
  215. package/src/themes/default/collections/table.variables +1 -5
  216. package/src/themes/default/elements/icon.variables +3 -3
  217. package/src/themes/default/globals/site.variables +8 -15
  218. package/src/themes/default/globals/variation.variables +1 -2
  219. package/src/themes/default/modules/dropdown.variables +1 -0
  220. package/src/themes/default/modules/slider.variables +1 -1
  221. package/src/themes/github/elements/icon.variables +1 -1
  222. package/src/themes/material/elements/icon.variables +1 -1
  223. package/tasks/README.md +1 -1
  224. package/tasks/admin/components/create.js +89 -122
  225. package/tasks/admin/components/init.js +34 -65
  226. package/tasks/admin/components/update.js +50 -61
  227. package/tasks/admin/distributions/create.js +71 -111
  228. package/tasks/admin/distributions/init.js +32 -63
  229. package/tasks/admin/distributions/update.js +49 -57
  230. package/tasks/admin/publish.js +1 -1
  231. package/tasks/admin/register.js +14 -19
  232. package/tasks/admin/release.js +2 -2
  233. package/tasks/build/assets.js +14 -18
  234. package/tasks/build/css.js +59 -68
  235. package/tasks/build/javascript.js +48 -56
  236. package/tasks/build.js +4 -6
  237. package/tasks/check-install.js +5 -8
  238. package/tasks/clean.js +5 -7
  239. package/tasks/collections/admin.js +14 -16
  240. package/tasks/collections/build.js +6 -8
  241. package/tasks/collections/docs.js +4 -6
  242. package/tasks/collections/install.js +2 -4
  243. package/tasks/collections/rtl.js +2 -4
  244. package/tasks/collections/various.js +2 -4
  245. package/tasks/config/admin/github.js +9 -19
  246. package/tasks/config/admin/templates/README.md +2 -2
  247. package/tasks/config/admin/templates/bower.json +2 -4
  248. package/tasks/config/admin/templates/composer.json +1 -1
  249. package/tasks/config/admin/templates/css-package.js +1 -4
  250. package/tasks/config/admin/templates/less-package.js +1 -3
  251. package/tasks/config/defaults.js +0 -1
  252. package/tasks/config/npm/gulpfile.js +4 -6
  253. package/tasks/config/project/config.js +27 -35
  254. package/tasks/config/project/install.js +64 -82
  255. package/tasks/config/project/release.js +7 -9
  256. package/tasks/config/tasks.js +16 -30
  257. package/tasks/config/user.js +14 -20
  258. package/tasks/docs/build.js +26 -31
  259. package/tasks/docs/metadata.js +30 -39
  260. package/tasks/docs/serve.js +23 -27
  261. package/tasks/install.js +94 -128
  262. package/tasks/rtl/build.js +2 -4
  263. package/tasks/rtl/watch.js +3 -5
  264. package/tasks/watch.js +13 -13
  265. package/test/meteor/fonts.js +1 -2
  266. package/test/modules/module.spec.js +16 -18
  267. package/types/fomantic-ui-calendar.d.ts +1 -1
  268. package/types/fomantic-ui-dropdown.d.ts +45 -1
  269. package/types/fomantic-ui-embed.d.ts +1 -1
  270. package/types/fomantic-ui-flyout.d.ts +1 -1
  271. package/types/fomantic-ui-form.d.ts +0 -7
  272. package/types/fomantic-ui-modal.d.ts +1 -1
  273. package/types/fomantic-ui-search.d.ts +12 -6
  274. package/types/fomantic-ui-toast.d.ts +1 -1
  275. package/src/themes/basic/assets/fonts/icons.woff +0 -0
  276. package/src/themes/default/assets/fonts/Lato-Bold.woff +0 -0
  277. package/src/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
  278. package/src/themes/default/assets/fonts/Lato-Italic.woff +0 -0
  279. package/src/themes/default/assets/fonts/Lato-Regular.woff +0 -0
  280. package/src/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  281. package/src/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
  282. package/src/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
  283. package/src/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  284. package/src/themes/default/assets/fonts/brand-icons.woff +0 -0
  285. package/src/themes/default/assets/fonts/icons.woff +0 -0
  286. package/src/themes/default/assets/fonts/outline-icons.woff +0 -0
  287. package/src/themes/github/assets/fonts/octicons.woff +0 -0
  288. package/src/themes/material/assets/fonts/icons.woff +0 -0
@@ -24,66 +24,62 @@
24
24
  : globalThis;
25
25
 
26
26
  $.fn.tab = function (parameters) {
27
- var
28
- // use window context if none specified
29
- $allModules = isFunction(this)
30
- ? $(window)
31
- : $(this),
32
- $document = $(document),
33
- time = Date.now(),
34
- performance = [],
35
-
36
- query = arguments[0],
37
- methodInvoked = typeof query === 'string',
38
- queryArguments = [].slice.call(arguments, 1),
39
- contextCheck = function (context, win) {
40
- var $context;
41
- if ([window, document].indexOf(context) >= 0) {
42
- $context = $(context);
43
- } else {
44
- $context = $(win.document).find(context);
45
- if ($context.length === 0) {
46
- $context = win.frameElement ? contextCheck(context, win.parent) : window;
47
- }
27
+ // use window context if none specified
28
+ let $allModules = isFunction(this)
29
+ ? $(window)
30
+ : $(this);
31
+ let $document = $(document);
32
+ let time = Date.now();
33
+ let performance = [];
34
+
35
+ let query = arguments[0];
36
+ let methodInvoked = typeof query === 'string';
37
+ let queryArguments = [].slice.call(arguments, 1);
38
+ let contextCheck = function (context, win) {
39
+ let $context;
40
+ if ([window, document].indexOf(context) >= 0) {
41
+ $context = $(context);
42
+ } else {
43
+ $context = $(win.document).find(context);
44
+ if ($context.length === 0) {
45
+ $context = win.frameElement ? contextCheck(context, win.parent) : window;
48
46
  }
47
+ }
49
48
 
50
- return $context;
51
- },
52
- initializedHistory = false,
53
- returnedValue
54
- ;
49
+ return $context;
50
+ };
51
+ let initializedHistory = false;
52
+ let returnedValue;
55
53
 
56
54
  $allModules.each(function () {
57
- var
58
- settings = $.isPlainObject(parameters)
59
- ? $.extend(true, {}, $.fn.tab.settings, parameters)
60
- : $.extend({}, $.fn.tab.settings),
55
+ let settings = $.isPlainObject(parameters)
56
+ ? $.extend(true, {}, $.fn.tab.settings, parameters)
57
+ : $.extend({}, $.fn.tab.settings);
61
58
 
62
- className = settings.className,
63
- metadata = settings.metadata,
64
- selector = settings.selector,
65
- error = settings.error,
66
- regExp = settings.regExp,
59
+ let className = settings.className;
60
+ let metadata = settings.metadata;
61
+ let selector = settings.selector;
62
+ let error = settings.error;
63
+ let regExp = settings.regExp;
67
64
 
68
- eventNamespace = '.' + settings.namespace,
69
- moduleNamespace = 'module-' + settings.namespace,
65
+ let eventNamespace = '.' + settings.namespace;
66
+ let moduleNamespace = 'module-' + settings.namespace;
70
67
 
71
- $module = $(this),
72
- $context,
73
- $tabs,
68
+ let $module = $(this);
69
+ let $context;
70
+ let $tabs;
74
71
 
75
- cache = {},
76
- firstLoad = true,
77
- recursionDepth = 0,
78
- element = this,
79
- instance = $module.data(moduleNamespace),
72
+ let cache = {};
73
+ let firstLoad = true;
74
+ let recursionDepth = 0;
75
+ let element = this;
76
+ let instance = $module.data(moduleNamespace);
80
77
 
81
- activeTabPath,
82
- parameterArray,
83
- module,
78
+ let activeTabPath;
79
+ let parameterArray;
80
+ let module;
84
81
 
85
- historyEvent
86
- ;
82
+ let historyEvent;
87
83
 
88
84
  module = {
89
85
 
@@ -103,14 +99,14 @@
103
99
  initializedHistory = true;
104
100
  }
105
101
 
106
- var activeTab = module.determine.activeTab();
102
+ let activeTab = module.determine.activeTab();
107
103
  if (settings.autoTabActivation && instance === undefined && activeTab === null) {
108
104
  activeTab = settings.autoTabActivation === true ? module.get.initialPath() : settings.autoTabActivation;
109
105
  module.debug('No active tab detected, setting tab active', activeTab);
110
106
  module.changeTab(activeTab);
111
107
  }
112
108
  if (activeTab !== null && settings.history && settings.historyType === 'state') {
113
- var autoUpdate = $.address.autoUpdate();
109
+ let autoUpdate = $.address.autoUpdate();
114
110
  $.address.autoUpdate(false);
115
111
  $.address.value(activeTab);
116
112
  $.address.autoUpdate(autoUpdate);
@@ -123,16 +119,14 @@
123
119
  module.verbose('Storing instance of module', module);
124
120
  instance = module;
125
121
  $module
126
- .data(moduleNamespace, module)
127
- ;
122
+ .data(moduleNamespace, module);
128
123
  },
129
124
 
130
125
  destroy: function () {
131
126
  module.debug('Destroying tabs', $module);
132
127
  $module
133
128
  .removeData(moduleNamespace)
134
- .off(eventNamespace)
135
- ;
129
+ .off(eventNamespace);
136
130
  },
137
131
 
138
132
  bind: {
@@ -141,16 +135,13 @@
141
135
  if (!isWindow(element)) {
142
136
  module.debug('Attaching tab activation events to element', $module);
143
137
  $module
144
- .on('click' + eventNamespace, module.event.click)
145
- ;
138
+ .on('click' + eventNamespace, module.event.click);
146
139
  }
147
140
  },
148
141
  },
149
142
 
150
143
  determineTabs: function () {
151
- var
152
- $reference
153
- ;
144
+ let $reference;
154
145
 
155
146
  // determine tab context
156
147
  if (settings.context === 'parent') {
@@ -190,8 +181,7 @@
190
181
  if (settings.path !== false) {
191
182
  $.address
192
183
  .history(true)
193
- .state(settings.path)
194
- ;
184
+ .state(settings.path);
195
185
  $(window).trigger('popstate');
196
186
  } else {
197
187
  module.error(error.path);
@@ -200,17 +190,14 @@
200
190
  }
201
191
  }
202
192
  $.address
203
- .bind('change', module.event.history.change)
204
- ;
193
+ .bind('change', module.event.history.change);
205
194
 
206
195
  return true;
207
196
  },
208
197
 
209
198
  event: {
210
199
  click: function (event) {
211
- var
212
- tabPath = $(this).data(metadata.tab)
213
- ;
200
+ let tabPath = $(this).data(metadata.tab);
214
201
  if (tabPath !== undefined) {
215
202
  if (settings.history) {
216
203
  module.verbose('Updating page state', event);
@@ -226,10 +213,8 @@
226
213
  },
227
214
  history: {
228
215
  change: function (event) {
229
- var
230
- tabPath = event.pathNames.join('/') || module.get.initialPath(),
231
- pageTitle = settings.templates.determineTitle(tabPath) || false
232
- ;
216
+ let tabPath = event.pathNames.join('/') || module.get.initialPath();
217
+ let pageTitle = settings.templates.determineTitle(tabPath) || false;
233
218
  module.performance.display();
234
219
  module.debug('History change event', tabPath, event);
235
220
  historyEvent = event;
@@ -269,21 +254,11 @@
269
254
  },
270
255
  },
271
256
 
272
- escape: {
273
- string: function (text) {
274
- text = String(text);
275
-
276
- return text.replace(regExp.escape, '\\$&');
277
- },
278
- },
279
-
280
257
  set: {
281
258
  auto: function () {
282
- var
283
- url = typeof settings.path === 'string'
284
- ? settings.path.replace(/\/$/, '') + '/{$tab}'
285
- : '/{$tab}'
286
- ;
259
+ let url = typeof settings.path === 'string'
260
+ ? settings.path.replace(/\/$/, '') + '/{$tab}'
261
+ : '/{$tab}';
287
262
  module.verbose('Setting up automatic tab retrieval from server', url);
288
263
  if ($.isPlainObject(settings.apiSettings)) {
289
264
  settings.apiSettings.url = url;
@@ -294,17 +269,14 @@
294
269
  }
295
270
  },
296
271
  loading: function (tabPath) {
297
- var
298
- $tab = module.get.tabElement(tabPath),
299
- isLoading = $tab.hasClass(className.loading)
300
- ;
272
+ let $tab = module.get.tabElement(tabPath);
273
+ let isLoading = $tab.hasClass(className.loading);
301
274
  if (!isLoading) {
302
275
  module.verbose('Setting loading state for', $tab);
303
276
  $tab
304
277
  .addClass(className.loading)
305
278
  .siblings($tabs)
306
- .removeClass(className.active + ' ' + className.loading)
307
- ;
279
+ .removeClass(className.active + ' ' + className.loading);
308
280
  if ($tab.length > 0) {
309
281
  settings.onRequest.call($tab[0], tabPath);
310
282
  }
@@ -316,30 +288,26 @@
316
288
  },
317
289
 
318
290
  changeTab: function (tabPath) {
319
- var
320
- pushStateAvailable = window.history && window.history.pushState,
321
- shouldIgnoreLoad = pushStateAvailable && settings.ignoreFirstLoad && firstLoad,
322
- remoteContent = settings.auto || $.isPlainObject(settings.apiSettings),
323
- // only add default path if not remote content
324
- pathArray = remoteContent && !shouldIgnoreLoad
325
- ? module.utilities.pathToArray(tabPath)
326
- : module.get.defaultPathArray(tabPath)
327
- ;
291
+ let pushStateAvailable = window.history && window.history.pushState;
292
+ let shouldIgnoreLoad = pushStateAvailable && settings.ignoreFirstLoad && firstLoad;
293
+ let remoteContent = settings.auto || $.isPlainObject(settings.apiSettings);
294
+ // only add the default path if not remote content
295
+ let pathArray = remoteContent && !shouldIgnoreLoad
296
+ ? module.utilities.pathToArray(tabPath)
297
+ : module.get.defaultPathArray(tabPath);
328
298
  tabPath = module.utilities.arrayToPath(pathArray);
329
299
  $.each(pathArray, function (index, tab) {
330
- var
331
- currentPathArray = pathArray.slice(0, index + 1),
332
- currentPath = module.utilities.arrayToPath(currentPathArray),
333
-
334
- isTab = module.is.tab(currentPath),
335
- isLastIndex = index + 1 === pathArray.length,
336
-
337
- $tab = module.get.tabElement(currentPath),
338
- $anchor,
339
- nextPathArray,
340
- nextPath,
341
- isLastTab
342
- ;
300
+ let currentPathArray = pathArray.slice(0, index + 1);
301
+ let currentPath = module.utilities.arrayToPath(currentPathArray);
302
+
303
+ let isTab = module.is.tab(currentPath);
304
+ let isLastIndex = index + 1 === pathArray.length;
305
+
306
+ let $tab = module.get.tabElement(currentPath);
307
+ let $anchor;
308
+ let nextPathArray;
309
+ let nextPath;
310
+ let isLastTab;
343
311
  module.verbose('Looking for tab', tab);
344
312
  if (isTab) {
345
313
  module.verbose('Tab was found', tab);
@@ -388,11 +356,10 @@
388
356
  settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
389
357
  } else if (tabPath.search('/') === -1 && tabPath !== '') {
390
358
  // look for in page anchor
391
- tabPath = module.escape.string(tabPath);
392
- $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]');
359
+ $anchor = $('#' + CSS.escape(tabPath) + ', a[name="' + CSS.escape(tabPath) + '"]');
393
360
  currentPath = $anchor.closest('[data-tab]').data(metadata.tab);
394
361
  $tab = module.get.tabElement(currentPath);
395
- // if anchor exists use parent tab
362
+ // if anchor exists, use parent tab
396
363
  if ($anchor && $anchor.length > 0 && currentPath) {
397
364
  module.debug('Anchor link used, opening parent tab', $tab, $anchor);
398
365
  if (settings.onBeforeChange.call(element, currentPath) === false) {
@@ -424,11 +391,9 @@
424
391
  },
425
392
 
426
393
  scrollTo: function ($element) {
427
- var
428
- scrollOffset = $element && $element.length > 0
429
- ? $element.offset().top
430
- : false
431
- ;
394
+ let scrollOffset = $element && $element.length > 0
395
+ ? $element.offset().top
396
+ : false;
432
397
  if (scrollOffset !== false) {
433
398
  module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element);
434
399
  $document.scrollTop(scrollOffset);
@@ -437,18 +402,15 @@
437
402
 
438
403
  update: {
439
404
  content: function (tabPath, html, evaluateScripts) {
440
- var
441
- $tab = module.get.tabElement(tabPath),
442
- tab = $tab[0]
443
- ;
405
+ let $tab = module.get.tabElement(tabPath);
406
+ let tab = $tab[0];
444
407
  evaluateScripts = evaluateScripts !== undefined
445
408
  ? evaluateScripts
446
409
  : settings.evaluateScripts;
447
410
  if (typeof settings.cacheType === 'string' && settings.cacheType.toLowerCase() === 'dom' && typeof html !== 'string') {
448
411
  $tab
449
412
  .empty()
450
- .append($(html).clone(true))
451
- ;
413
+ .append($(html).clone(true));
452
414
  } else {
453
415
  if (evaluateScripts) {
454
416
  module.debug('Updating HTML and evaluating inline scripts', tabPath, html);
@@ -464,53 +426,46 @@
464
426
  fetch: {
465
427
 
466
428
  content: function (tabPath, fullTabPath) {
467
- var
468
- $tab = module.get.tabElement(tabPath),
469
- apiSettings = {
470
- dataType: 'html',
471
- encodeParameters: false,
472
- on: 'now',
473
- cache: settings.alwaysRefresh,
474
- headers: {
475
- 'X-Remote': true,
476
- },
477
- onSuccess: function (response) {
478
- if (settings.cacheType === 'response') {
479
- module.cache.add(fullTabPath, response);
480
- }
481
- module.update.content(tabPath, response);
482
- if (tabPath == activeTabPath) {
483
- module.debug('Content loaded', tabPath);
484
- module.activate.tab(tabPath);
485
- } else {
486
- module.debug('Content loaded in background', tabPath);
487
- }
488
- settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent);
489
- settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
490
-
491
- if (settings.loadOnce) {
492
- module.cache.add(fullTabPath, true);
493
- } else if (typeof settings.cacheType === 'string' && settings.cacheType.toLowerCase() === 'dom' && $tab.children().length > 0) {
494
- setTimeout(function () {
495
- var
496
- $clone = $tab.children().clone(true)
497
- ;
498
- $clone = $clone.not('script');
499
- module.cache.add(fullTabPath, $clone);
500
- }, 0);
501
- } else {
502
- module.cache.add(fullTabPath, $tab.html());
503
- }
504
- },
505
- urlData: {
506
- tab: fullTabPath,
507
- },
429
+ let $tab = module.get.tabElement(tabPath);
430
+ let apiSettings = {
431
+ dataType: 'html',
432
+ encodeParameters: false,
433
+ on: 'now',
434
+ cache: settings.alwaysRefresh,
435
+ onSuccess: function (response) {
436
+ if (settings.cacheType === 'response') {
437
+ module.cache.add(fullTabPath, response);
438
+ }
439
+ module.update.content(tabPath, response);
440
+ if (tabPath == activeTabPath) {
441
+ module.debug('Content loaded', tabPath);
442
+ module.activate.tab(tabPath);
443
+ } else {
444
+ module.debug('Content loaded in background', tabPath);
445
+ }
446
+ settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent);
447
+ settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
448
+
449
+ if (settings.loadOnce) {
450
+ module.cache.add(fullTabPath, true);
451
+ } else if (typeof settings.cacheType === 'string' && settings.cacheType.toLowerCase() === 'dom' && $tab.children().length > 0) {
452
+ setTimeout(function () {
453
+ let $clone = $tab.children().clone(true);
454
+ $clone = $clone.not('script');
455
+ module.cache.add(fullTabPath, $clone);
456
+ }, 0);
457
+ } else {
458
+ module.cache.add(fullTabPath, $tab.html());
459
+ }
460
+ },
461
+ urlData: {
462
+ tab: fullTabPath,
508
463
  },
509
- request = $tab.api('get request') || false,
510
- existingRequest = request && request.state() === 'pending',
511
- requestSettings,
512
- cachedContent
513
- ;
464
+ };
465
+ let request = $tab.api('get request') || false;
466
+ let existingRequest = request && request.state() === 'pending';
467
+ let requestSettings;
468
+ let cachedContent;
514
469
 
515
470
  fullTabPath = fullTabPath || tabPath;
516
471
  cachedContent = module.cache.read(fullTabPath);
@@ -546,42 +501,34 @@
546
501
  module.activate.navigation(tabPath);
547
502
  },
548
503
  tab: function (tabPath) {
549
- var
550
- $tab = module.get.tabElement(tabPath),
551
- $deactiveTabs = settings.deactivate === 'siblings'
552
- ? $tab.siblings($tabs)
553
- : $tabs.not($tab),
554
- isActive = $tab.hasClass(className.active)
555
- ;
504
+ let $tab = module.get.tabElement(tabPath);
505
+ let $deactiveTabs = settings.deactivate === 'siblings'
506
+ ? $tab.siblings($tabs)
507
+ : $tabs.not($tab);
508
+ let isActive = $tab.hasClass(className.active);
556
509
  module.verbose('Showing tab content for', $tab);
557
510
  if (!isActive) {
558
511
  $tab
559
- .addClass(className.active)
560
- ;
512
+ .addClass(className.active);
561
513
  $deactiveTabs
562
- .removeClass(className.active + ' ' + className.loading)
563
- ;
514
+ .removeClass(className.active + ' ' + className.loading);
564
515
  if ($tab.length > 0) {
565
516
  settings.onVisible.call($tab[0], tabPath);
566
517
  }
567
518
  }
568
519
  },
569
520
  navigation: function (tabPath) {
570
- var
571
- $navigation = module.get.navElement(tabPath),
572
- $deactiveNavigation = settings.deactivate === 'siblings'
573
- ? $navigation.siblings($allModules)
574
- : $allModules.not($navigation),
575
- isActive = $navigation.hasClass(className.active)
576
- ;
521
+ let $navigation = module.get.navElement(tabPath);
522
+ let $deactiveNavigation = settings.deactivate === 'siblings'
523
+ ? $navigation.siblings($allModules)
524
+ : $allModules.not($navigation);
525
+ let isActive = $navigation.hasClass(className.active);
577
526
  module.verbose('Activating tab navigation for', $navigation, tabPath);
578
527
  if (!isActive) {
579
528
  $navigation
580
- .addClass(className.active)
581
- ;
529
+ .addClass(className.active);
582
530
  $deactiveNavigation
583
- .removeClass(className.active + ' ' + className.loading)
584
- ;
531
+ .removeClass(className.active + ' ' + className.loading);
585
532
  }
586
533
  },
587
534
  },
@@ -593,13 +540,11 @@
593
540
  },
594
541
  navigation: function () {
595
542
  $allModules
596
- .removeClass(className.active)
597
- ;
543
+ .removeClass(className.active);
598
544
  },
599
545
  tabs: function () {
600
546
  $tabs
601
- .removeClass(className.active + ' ' + className.loading)
602
- ;
547
+ .removeClass(className.active + ' ' + className.loading);
603
548
  },
604
549
  },
605
550
 
@@ -618,15 +563,13 @@
618
563
  path: function () {
619
564
  return $.address.value();
620
565
  },
621
- // adds default tabs to tab path
566
+ // adds default tabs to the tab path
622
567
  defaultPathArray: function (tabPath) {
623
568
  return module.utilities.pathToArray(module.get.defaultPath(tabPath));
624
569
  },
625
570
  defaultPath: function (tabPath) {
626
- var
627
- $defaultNav = $allModules.filter('[data-' + metadata.tab + '^="' + module.escape.string(tabPath) + '/"]').eq(0),
628
- defaultTab = $defaultNav.data(metadata.tab) || false
629
- ;
571
+ let $defaultNav = $allModules.filter('[data-' + metadata.tab + '^="' + CSS.escape(tabPath) + '/"]').eq(0);
572
+ let defaultTab = $defaultNav.data(metadata.tab) || false;
630
573
  if (defaultTab) {
631
574
  module.debug('Found default tab', defaultTab);
632
575
  if (recursionDepth < settings.maxDepth) {
@@ -645,20 +588,18 @@
645
588
  navElement: function (tabPath) {
646
589
  tabPath = tabPath || activeTabPath;
647
590
 
648
- return $allModules.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]');
591
+ return $allModules.filter('[data-' + metadata.tab + '="' + CSS.escape(tabPath) + '"]');
649
592
  },
650
593
  tabElement: function (tabPath) {
651
- var
652
- $fullPathTab,
653
- $simplePathTab,
654
- tabPathArray,
655
- lastTab
656
- ;
594
+ let $fullPathTab;
595
+ let $simplePathTab;
596
+ let tabPathArray;
597
+ let lastTab;
657
598
  tabPath = tabPath || activeTabPath;
658
599
  tabPathArray = module.utilities.pathToArray(tabPath);
659
600
  lastTab = module.utilities.last(tabPathArray);
660
- $fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]');
661
- $simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + module.escape.string(lastTab) + '"]');
601
+ $fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + CSS.escape(tabPath) + '"]');
602
+ $simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + CSS.escape(lastTab) + '"]');
662
603
 
663
604
  return $fullPathTab.length > 0
664
605
  ? $fullPathTab
@@ -671,16 +612,14 @@
671
612
 
672
613
  determine: {
673
614
  activeTab: function () {
674
- var activeTab = null;
615
+ let activeTab = null;
675
616
 
676
617
  $tabs.each(function (_index, tab) {
677
- var $tab = $(tab);
618
+ let $tab = $(tab);
678
619
 
679
620
  if ($tab.hasClass(className.active)) {
680
- var
681
- tabPath = $(this).data(metadata.tab),
682
- $anchor = $allModules.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]')
683
- ;
621
+ let tabPath = $(this).data(metadata.tab);
622
+ let $anchor = $allModules.filter('[data-' + metadata.tab + '="' + CSS.escape(tabPath) + '"]');
684
623
 
685
624
  if ($anchor.hasClass(className.active)) {
686
625
  activeTab = tabPath;
@@ -770,11 +709,9 @@
770
709
  },
771
710
  performance: {
772
711
  log: function (message) {
773
- var
774
- currentTime,
775
- executionTime,
776
- previousTime
777
- ;
712
+ let currentTime;
713
+ let executionTime;
714
+ let previousTime;
778
715
  if (settings.performance) {
779
716
  currentTime = Date.now();
780
717
  previousTime = time || currentTime;
@@ -793,10 +730,8 @@
793
730
  }, 500);
794
731
  },
795
732
  display: function () {
796
- var
797
- title = settings.name + ':',
798
- totalTime = 0
799
- ;
733
+ let title = settings.name + ':';
734
+ let totalTime = 0;
800
735
  time = false;
801
736
  clearTimeout(module.performance.timer);
802
737
  $.each(performance, function (index, data) {
@@ -818,22 +753,19 @@
818
753
  },
819
754
  },
820
755
  invoke: function (query, passedArguments, context) {
821
- var
822
- object = instance,
823
- maxDepth,
824
- found,
825
- response
826
- ;
756
+ let object = instance;
757
+ let maxDepth;
758
+ let found;
759
+ let response;
827
760
  passedArguments = passedArguments || queryArguments;
828
761
  context = context || element;
829
762
  if (typeof query === 'string' && object !== undefined) {
830
763
  query = query.split(/[ .]/);
831
764
  maxDepth = query.length - 1;
832
765
  $.each(query, function (depth, value) {
833
- var camelCaseValue = depth !== maxDepth
766
+ let camelCaseValue = depth !== maxDepth
834
767
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
835
- : query
836
- ;
768
+ : query;
837
769
  if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
838
770
  object = object[camelCaseValue];
839
771
  } else if (object[camelCaseValue] !== undefined) {
@@ -902,7 +834,7 @@
902
834
  verbose: false,
903
835
  performance: true,
904
836
 
905
- auto: false, // uses pjax style endpoints fetching content from same url with remote-content headers
837
+ auto: false, // uses pjax style endpoints fetching content from the same url with remote-content headers
906
838
  history: false, // use browser history
907
839
  historyType: 'hash', // #/ or html5 state
908
840
  path: false, // base path of url
@@ -916,21 +848,21 @@
916
848
  alwaysRefresh: false, // load tab content new every tab click
917
849
  cache: true, // cache the content requests to pull locally
918
850
  loadOnce: false, // Whether tab data should only be loaded once when using remote content
919
- cacheType: 'response', // Whether to cache exact response, or to html cache contents after scripts execute
920
- ignoreFirstLoad: false, // don't load remote content on first load
851
+ cacheType: 'response', // Whether to cache exact response, or to HTML cache contents after scripts execute
852
+ ignoreFirstLoad: false, // don't load remote content on the first load
921
853
 
922
854
  apiSettings: false, // settings for api call
923
855
  evaluateScripts: 'once', // whether inline scripts should be parsed (true/false/once). Once will not re-evaluate on cached content
924
- autoTabActivation: true, // whether a non existing active tab will auto activate the first available tab
856
+ autoTabActivation: true, // whether a non-existing active tab will auto activate the first available tab
925
857
 
926
858
  onFirstLoad: function (tabPath, parameterArray, historyEvent) {}, // called first time loaded
927
859
  onLoad: function (tabPath, parameterArray, historyEvent) {}, // called on every load
928
860
  onVisible: function (tabPath, parameterArray, historyEvent) {}, // called every time tab visible
929
- onRequest: function (tabPath, parameterArray, historyEvent) {}, // called ever time a tab beings loading remote content
861
+ onRequest: function (tabPath, parameterArray, historyEvent) {}, // called every time a tab beings loading remote content
930
862
  onBeforeChange: function (tabPath) {}, // called before a tab is about to be changed. Returning false will cancel the tab change
931
863
 
932
864
  templates: {
933
- determineTitle: function (tabArray) {}, // returns page title for path
865
+ determineTitle: function (tabArray) {}, // returns page title for the path
934
866
  },
935
867
 
936
868
  error: {