fomantic-ui 2.9.1-beta.16 → 2.9.1-beta.18

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 (252) hide show
  1. package/.eslintrc.js +109 -0
  2. package/.github/workflows/ci.yml +13 -3
  3. package/dist/components/accordion.css +1 -1
  4. package/dist/components/accordion.js +571 -598
  5. package/dist/components/accordion.min.css +1 -1
  6. package/dist/components/accordion.min.js +1 -1
  7. package/dist/components/ad.css +1 -1
  8. package/dist/components/ad.min.css +1 -1
  9. package/dist/components/api.js +1164 -1186
  10. package/dist/components/api.min.js +1 -1
  11. package/dist/components/breadcrumb.css +1 -1
  12. package/dist/components/breadcrumb.min.css +1 -1
  13. package/dist/components/button.css +1 -1
  14. package/dist/components/button.min.css +1 -1
  15. package/dist/components/calendar.css +1 -1
  16. package/dist/components/calendar.js +1897 -1818
  17. package/dist/components/calendar.min.css +1 -1
  18. package/dist/components/calendar.min.js +1 -1
  19. package/dist/components/card.css +1 -1
  20. package/dist/components/card.min.css +1 -1
  21. package/dist/components/checkbox.css +1 -1
  22. package/dist/components/checkbox.js +844 -841
  23. package/dist/components/checkbox.min.css +1 -1
  24. package/dist/components/checkbox.min.js +1 -1
  25. package/dist/components/comment.css +1 -1
  26. package/dist/components/comment.min.css +1 -1
  27. package/dist/components/container.css +3 -1
  28. package/dist/components/container.min.css +2 -2
  29. package/dist/components/dimmer.css +1 -1
  30. package/dist/components/dimmer.js +710 -737
  31. package/dist/components/dimmer.min.css +1 -1
  32. package/dist/components/dimmer.min.js +1 -1
  33. package/dist/components/divider.css +1 -1
  34. package/dist/components/divider.min.css +1 -1
  35. package/dist/components/dropdown.css +11 -8
  36. package/dist/components/dropdown.js +4163 -4234
  37. package/dist/components/dropdown.min.css +2 -2
  38. package/dist/components/dropdown.min.js +2 -2
  39. package/dist/components/embed.css +1 -1
  40. package/dist/components/embed.js +653 -675
  41. package/dist/components/embed.min.css +1 -1
  42. package/dist/components/embed.min.js +1 -1
  43. package/dist/components/feed.css +1 -1
  44. package/dist/components/feed.min.css +1 -1
  45. package/dist/components/flag.css +1 -1
  46. package/dist/components/flag.min.css +1 -1
  47. package/dist/components/flyout.css +6 -3
  48. package/dist/components/flyout.js +1466 -1467
  49. package/dist/components/flyout.min.css +2 -2
  50. package/dist/components/flyout.min.js +1 -1
  51. package/dist/components/form.css +1 -1
  52. package/dist/components/form.js +1981 -2004
  53. package/dist/components/form.min.css +1 -1
  54. package/dist/components/form.min.js +1 -1
  55. package/dist/components/grid.css +1 -1
  56. package/dist/components/grid.min.css +1 -1
  57. package/dist/components/header.css +1 -1
  58. package/dist/components/header.min.css +1 -1
  59. package/dist/components/icon.css +1 -1
  60. package/dist/components/icon.min.css +1 -1
  61. package/dist/components/image.css +1 -1
  62. package/dist/components/image.min.css +1 -1
  63. package/dist/components/input.css +1 -1
  64. package/dist/components/input.min.css +1 -1
  65. package/dist/components/item.css +1 -1
  66. package/dist/components/item.min.css +1 -1
  67. package/dist/components/label.css +1 -1
  68. package/dist/components/label.min.css +1 -1
  69. package/dist/components/list.css +1 -1
  70. package/dist/components/list.min.css +1 -1
  71. package/dist/components/loader.css +1 -1
  72. package/dist/components/loader.min.css +1 -1
  73. package/dist/components/message.css +1 -1
  74. package/dist/components/message.min.css +1 -1
  75. package/dist/components/modal.css +7 -1
  76. package/dist/components/modal.js +1493 -1487
  77. package/dist/components/modal.min.css +2 -2
  78. package/dist/components/modal.min.js +1 -1
  79. package/dist/components/nag.css +1 -1
  80. package/dist/components/nag.js +520 -529
  81. package/dist/components/nag.min.css +1 -1
  82. package/dist/components/nag.min.js +1 -1
  83. package/dist/components/placeholder.css +1 -1
  84. package/dist/components/placeholder.min.css +1 -1
  85. package/dist/components/popup.css +1 -1
  86. package/dist/components/popup.js +1439 -1456
  87. package/dist/components/popup.min.css +1 -1
  88. package/dist/components/popup.min.js +1 -1
  89. package/dist/components/progress.css +1 -1
  90. package/dist/components/progress.js +971 -997
  91. package/dist/components/progress.min.css +1 -1
  92. package/dist/components/progress.min.js +1 -1
  93. package/dist/components/rail.css +1 -1
  94. package/dist/components/rail.min.css +1 -1
  95. package/dist/components/rating.css +1 -1
  96. package/dist/components/rating.js +508 -524
  97. package/dist/components/rating.min.css +1 -1
  98. package/dist/components/rating.min.js +1 -1
  99. package/dist/components/reset.css +1 -1
  100. package/dist/components/reset.min.css +1 -1
  101. package/dist/components/reveal.css +1 -1
  102. package/dist/components/reveal.min.css +1 -1
  103. package/dist/components/search.css +3 -1
  104. package/dist/components/search.js +1500 -1534
  105. package/dist/components/search.min.css +2 -2
  106. package/dist/components/search.min.js +1 -1
  107. package/dist/components/segment.css +3 -1
  108. package/dist/components/segment.min.css +2 -2
  109. package/dist/components/shape.css +1 -1
  110. package/dist/components/shape.js +794 -809
  111. package/dist/components/shape.min.css +1 -1
  112. package/dist/components/shape.min.js +1 -1
  113. package/dist/components/sidebar.css +3 -1
  114. package/dist/components/sidebar.js +1079 -1104
  115. package/dist/components/sidebar.min.css +2 -2
  116. package/dist/components/sidebar.min.js +1 -1
  117. package/dist/components/site.css +1 -1
  118. package/dist/components/site.js +457 -472
  119. package/dist/components/site.min.css +1 -1
  120. package/dist/components/site.min.js +1 -1
  121. package/dist/components/slider.js +1289 -1311
  122. package/dist/components/slider.min.js +1 -1
  123. package/dist/components/state.js +641 -657
  124. package/dist/components/state.min.js +1 -1
  125. package/dist/components/statistic.css +1 -1
  126. package/dist/components/statistic.min.css +1 -1
  127. package/dist/components/step.css +1 -1
  128. package/dist/components/step.min.css +1 -1
  129. package/dist/components/sticky.css +1 -1
  130. package/dist/components/sticky.js +859 -903
  131. package/dist/components/sticky.min.css +1 -1
  132. package/dist/components/sticky.min.js +1 -1
  133. package/dist/components/tab.css +1 -1
  134. package/dist/components/tab.js +923 -963
  135. package/dist/components/tab.min.css +1 -1
  136. package/dist/components/tab.min.js +1 -1
  137. package/dist/components/table.css +5 -1
  138. package/dist/components/table.min.css +2 -2
  139. package/dist/components/text.css +1 -1
  140. package/dist/components/text.min.css +1 -1
  141. package/dist/components/toast.css +1 -1
  142. package/dist/components/toast.js +889 -891
  143. package/dist/components/toast.min.css +1 -1
  144. package/dist/components/toast.min.js +1 -1
  145. package/dist/components/transition.css +1 -1
  146. package/dist/components/transition.js +1043 -1077
  147. package/dist/components/transition.min.css +1 -1
  148. package/dist/components/transition.min.js +1 -1
  149. package/dist/components/visibility.js +1222 -1244
  150. package/dist/components/visibility.min.js +1 -1
  151. package/dist/semantic.css +84 -60
  152. package/dist/semantic.js +29033 -29475
  153. package/dist/semantic.min.css +2 -2
  154. package/dist/semantic.min.js +2 -2
  155. package/examples/assets/show-examples.js +13 -13
  156. package/gulpfile.js +9 -10
  157. package/package.json +5 -2
  158. package/scripts/nightly-version.js +81 -75
  159. package/src/definitions/behaviors/api.js +1163 -1185
  160. package/src/definitions/behaviors/form.js +1980 -2003
  161. package/src/definitions/behaviors/state.js +647 -663
  162. package/src/definitions/behaviors/visibility.js +1221 -1243
  163. package/src/definitions/collections/table.less +2 -0
  164. package/src/definitions/elements/container.less +1 -0
  165. package/src/definitions/elements/segment.less +1 -0
  166. package/src/definitions/globals/site.js +456 -471
  167. package/src/definitions/modules/accordion.js +570 -597
  168. package/src/definitions/modules/calendar.js +1896 -1817
  169. package/src/definitions/modules/checkbox.js +849 -846
  170. package/src/definitions/modules/dimmer.js +709 -736
  171. package/src/definitions/modules/dropdown.js +4162 -4233
  172. package/src/definitions/modules/dropdown.less +5 -8
  173. package/src/definitions/modules/embed.js +652 -674
  174. package/src/definitions/modules/flyout.js +1465 -1466
  175. package/src/definitions/modules/flyout.less +15 -12
  176. package/src/definitions/modules/modal.js +1492 -1486
  177. package/src/definitions/modules/modal.less +3 -0
  178. package/src/definitions/modules/nag.js +519 -528
  179. package/src/definitions/modules/popup.js +1438 -1455
  180. package/src/definitions/modules/progress.js +970 -996
  181. package/src/definitions/modules/rating.js +507 -523
  182. package/src/definitions/modules/search.js +1499 -1533
  183. package/src/definitions/modules/search.less +1 -0
  184. package/src/definitions/modules/shape.js +801 -816
  185. package/src/definitions/modules/sidebar.js +1078 -1103
  186. package/src/definitions/modules/sidebar.less +1 -0
  187. package/src/definitions/modules/slider.js +1288 -1310
  188. package/src/definitions/modules/sticky.js +875 -919
  189. package/src/definitions/modules/tab.js +922 -962
  190. package/src/definitions/modules/toast.js +888 -890
  191. package/src/definitions/modules/transition.js +1048 -1082
  192. package/src/themes/default/elements/container.variables +0 -7
  193. package/src/themes/default/elements/segment.variables +0 -7
  194. package/src/themes/default/globals/site.variables +7 -0
  195. package/src/themes/default/globals/variation.variables +1 -0
  196. package/tasks/admin/components/create.js +274 -276
  197. package/tasks/admin/components/init.js +123 -130
  198. package/tasks/admin/components/update.js +149 -157
  199. package/tasks/admin/distributions/create.js +184 -187
  200. package/tasks/admin/distributions/init.js +123 -130
  201. package/tasks/admin/distributions/update.js +145 -152
  202. package/tasks/admin/publish.js +5 -7
  203. package/tasks/admin/register.js +36 -38
  204. package/tasks/admin/release.js +8 -10
  205. package/tasks/build/assets.js +42 -39
  206. package/tasks/build/css.js +225 -216
  207. package/tasks/build/javascript.js +118 -113
  208. package/tasks/build.js +10 -10
  209. package/tasks/check-install.js +14 -16
  210. package/tasks/clean.js +5 -5
  211. package/tasks/collections/admin.js +34 -36
  212. package/tasks/collections/build.js +18 -20
  213. package/tasks/collections/docs.js +9 -11
  214. package/tasks/collections/install.js +9 -11
  215. package/tasks/collections/rtl.js +9 -11
  216. package/tasks/collections/various.js +8 -10
  217. package/tasks/config/admin/github.js +17 -17
  218. package/tasks/config/admin/oauth.example.js +4 -4
  219. package/tasks/config/admin/release.js +98 -98
  220. package/tasks/config/admin/templates/component-package.js +9 -10
  221. package/tasks/config/admin/templates/css-package.js +18 -20
  222. package/tasks/config/admin/templates/less-package.js +11 -13
  223. package/tasks/config/defaults.js +116 -116
  224. package/tasks/config/docs.js +23 -23
  225. package/tasks/config/npm/gulpfile.js +8 -9
  226. package/tasks/config/project/config.js +127 -134
  227. package/tasks/config/project/install.js +715 -713
  228. package/tasks/config/project/release.js +32 -38
  229. package/tasks/config/tasks.js +163 -164
  230. package/tasks/config/user.js +23 -29
  231. package/tasks/docs/build.js +97 -95
  232. package/tasks/docs/metadata.js +90 -96
  233. package/tasks/docs/serve.js +80 -81
  234. package/tasks/install.js +370 -378
  235. package/tasks/rtl/build.js +2 -2
  236. package/tasks/rtl/watch.js +2 -2
  237. package/tasks/version.js +4 -4
  238. package/tasks/watch.js +28 -30
  239. package/test/meteor/assets.js +10 -13
  240. package/test/meteor/fonts.js +12 -13
  241. package/test/modules/accordion.spec.js +6 -8
  242. package/test/modules/checkbox.spec.js +5 -7
  243. package/test/modules/dropdown.spec.js +5 -7
  244. package/test/modules/modal.spec.js +6 -8
  245. package/test/modules/module.spec.js +158 -178
  246. package/test/modules/popup.spec.js +5 -7
  247. package/test/modules/search.spec.js +5 -7
  248. package/test/modules/shape.spec.js +5 -7
  249. package/test/modules/sidebar.spec.js +5 -7
  250. package/test/modules/tab.spec.js +6 -8
  251. package/test/modules/transition.spec.js +5 -7
  252. package/test/modules/video.spec.js +5 -7
@@ -8,1126 +8,1101 @@
8
8
  *
9
9
  */
10
10
 
11
- ;(function ($, window, document, undefined) {
12
-
13
- 'use strict';
14
-
15
- function isFunction(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.sidebar = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- $window = $(window),
30
- $document = $(document),
31
- $body = $('body'),
32
- $html = $('html'),
33
- $head = $('head'),
34
-
35
- moduleSelector = $allModules.selector || '',
36
-
37
- time = new Date().getTime(),
38
- performance = [],
39
-
40
- query = arguments[0],
41
- methodInvoked = (typeof query == 'string'),
42
- queryArguments = [].slice.call(arguments, 1),
43
-
44
- requestAnimationFrame = window.requestAnimationFrame
45
- || window.mozRequestAnimationFrame
46
- || window.webkitRequestAnimationFrame
47
- || window.msRequestAnimationFrame
48
- || function(callback) { setTimeout(callback, 0); },
49
-
50
- returnedValue
51
- ;
52
-
53
- $allModules
54
- .each(function() {
55
- var
56
- settings = ( $.isPlainObject(parameters) )
57
- ? $.extend(true, {}, $.fn.sidebar.settings, parameters)
58
- : $.extend({}, $.fn.sidebar.settings),
59
-
60
- selector = settings.selector,
61
- className = settings.className,
62
- namespace = settings.namespace,
63
- regExp = settings.regExp,
64
- error = settings.error,
65
-
66
- eventNamespace = '.' + namespace,
67
- moduleNamespace = 'module-' + namespace,
68
-
69
- $module = $(this),
70
- $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body,
71
- isBody = $context[0] === $body[0],
72
-
73
- $sidebars = $module.children(selector.sidebar),
74
- $fixed = $context.children(selector.fixed),
75
- $pusher = $context.children(selector.pusher),
76
- $style,
77
-
78
- element = this,
79
- instance = $module.data(moduleNamespace),
80
-
81
- elementNamespace,
82
- id,
83
- currentScroll,
84
- transitionEvent,
85
- initialBodyMargin = '',
86
- tempBodyMargin = '',
87
- hadScrollbar = false,
88
-
89
- module
90
- ;
91
-
92
- module = {
93
-
94
- initialize: function() {
95
- module.debug('Initializing sidebar', parameters);
96
-
97
- module.create.id();
98
-
99
- transitionEvent = module.get.transitionEvent();
100
-
101
- // avoids locking rendering if initialized in onReady
102
- if(settings.delaySetup) {
103
- requestAnimationFrame(module.setup.layout);
104
- }
105
- else {
106
- module.setup.layout();
107
- }
108
-
109
- requestAnimationFrame(function() {
110
- module.setup.cache();
111
- });
112
-
113
- module.instantiate();
114
- },
115
-
116
- instantiate: function() {
117
- module.verbose('Storing instance of module', module);
118
- instance = module;
119
- $module
120
- .data(moduleNamespace, module)
121
- ;
122
- },
123
-
124
- create: {
125
- id: function() {
126
- id = (Math.random().toString(16) + '000000000').slice(2, 10);
127
- elementNamespace = '.' + id;
128
- module.verbose('Creating unique id for element', id);
129
- }
130
- },
131
-
132
- destroy: function() {
133
- module.verbose('Destroying previous module for', $module);
134
- $module
135
- .off(eventNamespace)
136
- .removeData(moduleNamespace)
137
- ;
138
- if(module.is.ios()) {
139
- module.remove.ios();
140
- }
141
- // bound by uuid
142
- $context.off(elementNamespace);
143
- $window.off(elementNamespace);
144
- $document.off(elementNamespace);
145
- },
11
+ (function ($, window, document, undefined) {
12
+ 'use strict';
146
13
 
147
- event: {
148
- clickaway: function(event) {
149
- if(settings.closable){
150
- var
151
- clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
152
- clickedContext = ($context.is(event.target))
153
- ;
154
- if(clickedInPusher) {
155
- module.verbose('User clicked on dimmed page');
156
- module.hide();
157
- }
158
- if(clickedContext) {
159
- module.verbose('User clicked on dimmable context (scaled out page)');
160
- module.hide();
161
- }
162
- }
163
- },
164
- touch: function(event) {
165
- //event.stopPropagation();
166
- },
167
- containScroll: function(event) {
168
- if(element.scrollTop <= 0) {
169
- element.scrollTop = 1;
170
- }
171
- if((element.scrollTop + element.offsetHeight) >= element.scrollHeight) {
172
- element.scrollTop = element.scrollHeight - element.offsetHeight - 1;
173
- }
174
- },
175
- scroll: function(event) {
176
- if( $(event.target).closest(selector.sidebar).length === 0 ) {
177
- event.preventDefault();
178
- }
179
- }
180
- },
181
-
182
- bind: {
183
- clickaway: function() {
184
- module.verbose('Adding clickaway events to context', $context);
185
- $context
186
- .on('click' + elementNamespace, module.event.clickaway)
187
- .on('touchend' + elementNamespace, module.event.clickaway)
188
- ;
189
- },
190
- scrollLock: function() {
191
- if(settings.scrollLock) {
192
- module.debug('Disabling page scroll');
193
- hadScrollbar = module.has.scrollbar();
194
- if(hadScrollbar) {
195
- module.save.bodyMargin();
196
- module.set.bodyMargin();
197
- }
198
- $context.addClass(className.locked);
199
- }
200
- module.verbose('Adding events to contain sidebar scroll');
201
- $document
202
- .on('touchmove' + elementNamespace, module.event.touch)
203
- ;
204
- $module
205
- .on('scroll' + eventNamespace, module.event.containScroll)
206
- ;
207
- }
208
- },
209
- unbind: {
210
- clickaway: function() {
211
- module.verbose('Removing clickaway events from context', $context);
212
- $context.off(elementNamespace);
213
- },
214
- scrollLock: function() {
215
- module.verbose('Removing scroll lock from page');
216
- if(hadScrollbar) {
217
- module.restore.bodyMargin();
218
- }
219
- $context.removeClass(className.locked);
220
- $document.off(elementNamespace);
221
- $module.off('scroll' + eventNamespace);
222
- }
223
- },
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
224
17
 
225
- add: {
226
- inlineCSS: function() {
18
+ window = (typeof window != 'undefined' && window.Math == Math)
19
+ ? window
20
+ : (typeof self != 'undefined' && self.Math == Math)
21
+ ? self
22
+ : Function('return this')();
23
+
24
+ $.fn.sidebar = function (parameters) {
25
+ var
26
+ $allModules = $(this),
27
+ $window = $(window),
28
+ $document = $(document),
29
+ $body = $('body'),
30
+ $html = $('html'),
31
+ $head = $('head'),
32
+
33
+ moduleSelector = $allModules.selector || '',
34
+
35
+ time = new Date().getTime(),
36
+ performance = [],
37
+
38
+ query = arguments[0],
39
+ methodInvoked = (typeof query == 'string'),
40
+ queryArguments = [].slice.call(arguments, 1),
41
+
42
+ requestAnimationFrame = window.requestAnimationFrame
43
+ || window.mozRequestAnimationFrame
44
+ || window.webkitRequestAnimationFrame
45
+ || window.msRequestAnimationFrame
46
+ || function (callback) {
47
+ setTimeout(callback, 0);
48
+ },
49
+
50
+ returnedValue;
51
+
52
+ $allModules.each(function () {
227
53
  var
228
- width = module.cache.width || $module.outerWidth(),
229
- height = module.cache.height || $module.outerHeight(),
230
- isRTL = module.is.rtl(),
231
- direction = module.get.direction(),
232
- distance = {
233
- left : width,
234
- right : -width,
235
- top : height,
236
- bottom : -height
237
- },
238
- style
54
+ settings = ($.isPlainObject(parameters))
55
+ ? $.extend(true, {}, $.fn.sidebar.settings, parameters)
56
+ : $.extend({}, $.fn.sidebar.settings),
57
+
58
+ selector = settings.selector,
59
+ className = settings.className,
60
+ namespace = settings.namespace,
61
+ regExp = settings.regExp,
62
+ error = settings.error,
63
+
64
+ eventNamespace = '.' + namespace,
65
+ moduleNamespace = 'module-' + namespace,
66
+
67
+ $module = $(this),
68
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body,
69
+ isBody = $context[0] === $body[0],
70
+
71
+ $sidebars = $module.children(selector.sidebar),
72
+ $fixed = $context.children(selector.fixed),
73
+ $pusher = $context.children(selector.pusher),
74
+ $style,
75
+
76
+ element = this,
77
+ instance = $module.data(moduleNamespace),
78
+
79
+ elementNamespace,
80
+ id,
81
+ currentScroll,
82
+ transitionEvent,
83
+ initialBodyMargin = '',
84
+ tempBodyMargin = '',
85
+ hadScrollbar = false,
86
+
87
+ module
239
88
  ;
240
89
 
241
- if(isRTL){
242
- module.verbose('RTL detected, flipping widths');
243
- distance.left = -width;
244
- distance.right = width;
245
- }
246
-
247
- style = '<style>';
248
-
249
- if(direction === 'left' || direction === 'right') {
250
- module.debug('Adding CSS rules for animation distance', width);
251
- style += ''
252
- + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
253
- + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
254
- + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
255
- + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
256
- + ' }'
257
- ;
258
- }
259
- else if(direction === 'top' || direction == 'bottom') {
260
- style += ''
261
- + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
262
- + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
263
- + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
264
- + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
265
- + ' }'
266
- ;
267
- }
268
-
269
- /* IE is only browser not to create context with transforms */
270
- /* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */
271
- if( module.is.ie() ) {
272
- if(direction === 'left' || direction === 'right') {
273
- module.debug('Adding CSS rules for animation distance', width);
274
- style += ''
275
- + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher::after {'
276
- + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
277
- + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
278
- + ' }'
279
- ;
280
- }
281
- else if(direction === 'top' || direction == 'bottom') {
282
- style += ''
283
- + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher::after {'
284
- + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
285
- + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
286
- + ' }'
287
- ;
288
- }
289
- /* opposite sides visible forces content overlay */
290
- style += ''
291
- + ' body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher::after,'
292
- + ' body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher::after {'
293
- + ' -webkit-transform: translate3d(0, 0, 0);'
294
- + ' transform: translate3d(0, 0, 0);'
295
- + ' }'
296
- ;
297
- }
298
- style += '</style>';
299
- $style = $(style)
300
- .appendTo($head)
301
- ;
302
- module.debug('Adding sizing css to head', $style);
303
- }
304
- },
305
-
306
- refresh: function() {
307
- module.verbose('Refreshing selector cache');
308
- $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body;
309
- module.refreshSidebars();
310
- $pusher = $context.children(selector.pusher);
311
- $fixed = $context.children(selector.fixed);
312
- module.clear.cache();
313
- },
314
-
315
- refreshSidebars: function() {
316
- module.verbose('Refreshing other sidebars');
317
- $sidebars = $context.children(selector.sidebar);
318
- },
319
-
320
- repaint: function() {
321
- module.verbose('Forcing repaint event');
322
- element.style.display = 'none';
323
- var ignored = element.offsetHeight;
324
- element.scrollTop = element.scrollTop;
325
- element.style.display = '';
326
- },
327
-
328
- setup: {
329
- cache: function() {
330
- module.cache = {
331
- width : $module.outerWidth(),
332
- height : $module.outerHeight()
90
+ module = {
91
+
92
+ initialize: function () {
93
+ module.debug('Initializing sidebar', parameters);
94
+
95
+ module.create.id();
96
+
97
+ transitionEvent = module.get.transitionEvent();
98
+
99
+ // avoids locking rendering if initialized in onReady
100
+ if (settings.delaySetup) {
101
+ requestAnimationFrame(module.setup.layout);
102
+ } else {
103
+ module.setup.layout();
104
+ }
105
+
106
+ requestAnimationFrame(function () {
107
+ module.setup.cache();
108
+ });
109
+
110
+ module.instantiate();
111
+ },
112
+
113
+ instantiate: function () {
114
+ module.verbose('Storing instance of module', module);
115
+ instance = module;
116
+ $module
117
+ .data(moduleNamespace, module)
118
+ ;
119
+ },
120
+
121
+ create: {
122
+ id: function () {
123
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
124
+ elementNamespace = '.' + id;
125
+ module.verbose('Creating unique id for element', id);
126
+ },
127
+ },
128
+
129
+ destroy: function () {
130
+ module.verbose('Destroying previous module for', $module);
131
+ $module
132
+ .off(eventNamespace)
133
+ .removeData(moduleNamespace)
134
+ ;
135
+ if (module.is.ios()) {
136
+ module.remove.ios();
137
+ }
138
+ // bound by uuid
139
+ $context.off(elementNamespace);
140
+ $window.off(elementNamespace);
141
+ $document.off(elementNamespace);
142
+ },
143
+
144
+ event: {
145
+ clickaway: function (event) {
146
+ if (settings.closable) {
147
+ var
148
+ clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
149
+ clickedContext = ($context.is(event.target))
150
+ ;
151
+ if (clickedInPusher) {
152
+ module.verbose('User clicked on dimmed page');
153
+ module.hide();
154
+ }
155
+ if (clickedContext) {
156
+ module.verbose('User clicked on dimmable context (scaled out page)');
157
+ module.hide();
158
+ }
159
+ }
160
+ },
161
+ touch: function (event) {
162
+ // event.stopPropagation();
163
+ },
164
+ containScroll: function (event) {
165
+ if (element.scrollTop <= 0) {
166
+ element.scrollTop = 1;
167
+ }
168
+ if ((element.scrollTop + element.offsetHeight) >= element.scrollHeight) {
169
+ element.scrollTop = element.scrollHeight - element.offsetHeight - 1;
170
+ }
171
+ },
172
+ scroll: function (event) {
173
+ if ($(event.target).closest(selector.sidebar).length === 0) {
174
+ event.preventDefault();
175
+ }
176
+ },
177
+ },
178
+
179
+ bind: {
180
+ clickaway: function () {
181
+ module.verbose('Adding clickaway events to context', $context);
182
+ $context
183
+ .on('click' + elementNamespace, module.event.clickaway)
184
+ .on('touchend' + elementNamespace, module.event.clickaway)
185
+ ;
186
+ },
187
+ scrollLock: function () {
188
+ if (settings.scrollLock) {
189
+ module.debug('Disabling page scroll');
190
+ hadScrollbar = module.has.scrollbar();
191
+ if (hadScrollbar) {
192
+ module.save.bodyMargin();
193
+ module.set.bodyMargin();
194
+ }
195
+ $context.addClass(className.locked);
196
+ }
197
+ module.verbose('Adding events to contain sidebar scroll');
198
+ $document
199
+ .on('touchmove' + elementNamespace, module.event.touch)
200
+ ;
201
+ $module
202
+ .on('scroll' + eventNamespace, module.event.containScroll)
203
+ ;
204
+ },
205
+ },
206
+ unbind: {
207
+ clickaway: function () {
208
+ module.verbose('Removing clickaway events from context', $context);
209
+ $context.off(elementNamespace);
210
+ },
211
+ scrollLock: function () {
212
+ module.verbose('Removing scroll lock from page');
213
+ if (hadScrollbar) {
214
+ module.restore.bodyMargin();
215
+ }
216
+ $context.removeClass(className.locked);
217
+ $document.off(elementNamespace);
218
+ $module.off('scroll' + eventNamespace);
219
+ },
220
+ },
221
+
222
+ add: {
223
+ inlineCSS: function () {
224
+ var
225
+ width = module.cache.width || $module.outerWidth(),
226
+ height = module.cache.height || $module.outerHeight(),
227
+ isRTL = module.is.rtl(),
228
+ direction = module.get.direction(),
229
+ distance = {
230
+ left: width,
231
+ right: -width,
232
+ top: height,
233
+ bottom: -height,
234
+ },
235
+ style
236
+ ;
237
+
238
+ if (isRTL) {
239
+ module.verbose('RTL detected, flipping widths');
240
+ distance.left = -width;
241
+ distance.right = width;
242
+ }
243
+
244
+ style = '<style>';
245
+
246
+ if (direction === 'left' || direction === 'right') {
247
+ module.debug('Adding CSS rules for animation distance', width);
248
+ style += ''
249
+ + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
250
+ + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
251
+ + ' -webkit-transform: translate3d(' + distance[direction] + 'px, 0, 0);'
252
+ + ' transform: translate3d(' + distance[direction] + 'px, 0, 0);'
253
+ + ' }';
254
+ } else if (direction === 'top' || direction == 'bottom') {
255
+ style += ''
256
+ + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
257
+ + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
258
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
259
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
260
+ + ' }';
261
+ }
262
+
263
+ /* IE is only browser not to create context with transforms */
264
+ /* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */
265
+ if (module.is.ie()) {
266
+ if (direction === 'left' || direction === 'right') {
267
+ module.debug('Adding CSS rules for animation distance', width);
268
+ style += ''
269
+ + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher::after {'
270
+ + ' -webkit-transform: translate3d(' + distance[direction] + 'px, 0, 0);'
271
+ + ' transform: translate3d(' + distance[direction] + 'px, 0, 0);'
272
+ + ' }';
273
+ } else if (direction === 'top' || direction == 'bottom') {
274
+ style += ''
275
+ + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher::after {'
276
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
277
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
278
+ + ' }';
279
+ }
280
+ /* opposite sides visible forces content overlay */
281
+ style += ''
282
+ + ' body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher::after,'
283
+ + ' body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher::after {'
284
+ + ' -webkit-transform: translate3d(0, 0, 0);'
285
+ + ' transform: translate3d(0, 0, 0);'
286
+ + ' }';
287
+ }
288
+ style += '</style>';
289
+ $style = $(style)
290
+ .appendTo($head)
291
+ ;
292
+ module.debug('Adding sizing css to head', $style);
293
+ },
294
+ },
295
+
296
+ refresh: function () {
297
+ module.verbose('Refreshing selector cache');
298
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body;
299
+ module.refreshSidebars();
300
+ $pusher = $context.children(selector.pusher);
301
+ $fixed = $context.children(selector.fixed);
302
+ module.clear.cache();
303
+ },
304
+
305
+ refreshSidebars: function () {
306
+ module.verbose('Refreshing other sidebars');
307
+ $sidebars = $context.children(selector.sidebar);
308
+ },
309
+
310
+ repaint: function () {
311
+ module.verbose('Forcing repaint event');
312
+ element.style.display = 'none';
313
+ var ignored = element.offsetHeight;
314
+ element.scrollTop = element.scrollTop;
315
+ element.style.display = '';
316
+ },
317
+
318
+ setup: {
319
+ cache: function () {
320
+ module.cache = {
321
+ width: $module.outerWidth(),
322
+ height: $module.outerHeight(),
323
+ };
324
+ },
325
+ layout: function () {
326
+ if ($context.children(selector.pusher).length === 0) {
327
+ module.debug('Adding wrapper element for sidebar');
328
+ module.error(error.pusher);
329
+ $pusher = $('<div class="pusher" />');
330
+ $context
331
+ .children()
332
+ .not(selector.omitted)
333
+ .not($sidebars)
334
+ .wrapAll($pusher)
335
+ ;
336
+ module.refresh();
337
+ }
338
+ if ($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
339
+ module.debug('Moved sidebar to correct parent element');
340
+ module.error(error.movedSidebar, element);
341
+ $module.detach().prependTo($context);
342
+ module.refresh();
343
+ }
344
+ module.clear.cache();
345
+ module.set.pushable();
346
+ module.set.direction();
347
+ },
348
+ },
349
+
350
+ attachEvents: function (selector, event) {
351
+ var
352
+ $toggle = $(selector)
353
+ ;
354
+ event = isFunction(module[event])
355
+ ? module[event]
356
+ : module.toggle;
357
+ if ($toggle.length > 0) {
358
+ module.debug('Attaching sidebar events to element', selector, event);
359
+ $toggle
360
+ .on('click' + eventNamespace, event)
361
+ ;
362
+ } else {
363
+ module.error(error.notFound, selector);
364
+ }
365
+ },
366
+ can: {
367
+ leftBodyScrollbar: function () {
368
+ if (module.cache.leftBodyScrollbar === undefined) {
369
+ module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
370
+ }
371
+
372
+ return module.cache.leftBodyScrollbar;
373
+ },
374
+ },
375
+ save: {
376
+ bodyMargin: function () {
377
+ initialBodyMargin = $context.css((isBody ? 'margin-' : 'padding-') + (module.can.leftBodyScrollbar() ? 'left' : 'right'));
378
+ var
379
+ bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, '')),
380
+ bodyScrollbarWidth = isBody ? window.innerWidth - document.documentElement.clientWidth : $context[0].offsetWidth - $context[0].clientWidth
381
+ ;
382
+ tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
383
+ },
384
+ },
385
+ show: function (callback) {
386
+ callback = isFunction(callback)
387
+ ? callback
388
+ : function () {};
389
+ if (module.is.hidden()) {
390
+ if (settings.onShow.call(element) === false) {
391
+ module.verbose('Show callback returned false cancelling show');
392
+
393
+ return;
394
+ }
395
+ if (settings.overlay) {
396
+ module.error(error.overlay);
397
+ settings.transition = 'overlay';
398
+ }
399
+ module.refresh();
400
+ if (module.othersActive()) {
401
+ module.debug('Other sidebars currently visible');
402
+ if (settings.exclusive) {
403
+ // if not overlay queue animation after hide
404
+ if (settings.transition != 'overlay') {
405
+ module.hideOthers(module.show);
406
+
407
+ return;
408
+ } else {
409
+ module.hideOthers();
410
+ }
411
+ } else {
412
+ settings.transition = 'overlay';
413
+ }
414
+ }
415
+ module.set.dimmerStyles();
416
+ module.pushPage(function () {
417
+ callback.call(element);
418
+ settings.onVisible.call(element);
419
+ });
420
+ settings.onChange.call(element);
421
+ } else {
422
+ module.debug('Sidebar is already visible');
423
+ }
424
+ },
425
+
426
+ hide: function (callback) {
427
+ callback = isFunction(callback)
428
+ ? callback
429
+ : function () {};
430
+ if ((module.is.visible() || module.is.animating()) && settings.onHide.call(element) !== false) {
431
+ module.debug('Hiding sidebar', callback);
432
+ module.refreshSidebars();
433
+ module.pullPage(function () {
434
+ callback.call(element);
435
+ settings.onHidden.call(element);
436
+ });
437
+ settings.onChange.call(element);
438
+ }
439
+ },
440
+
441
+ othersAnimating: function () {
442
+ return ($sidebars.not($module).filter('.' + className.animating).length > 0);
443
+ },
444
+ othersVisible: function () {
445
+ return ($sidebars.not($module).filter('.' + className.visible).length > 0);
446
+ },
447
+ othersActive: function () {
448
+ return (module.othersVisible() || module.othersAnimating());
449
+ },
450
+
451
+ hideOthers: function (callback) {
452
+ var
453
+ $otherSidebars = $sidebars.not($module).filter('.' + className.visible),
454
+ sidebarCount = $otherSidebars.length,
455
+ callbackCount = 0
456
+ ;
457
+ callback = callback || function () {};
458
+ $otherSidebars
459
+ .sidebar('hide', function () {
460
+ callbackCount++;
461
+ if (callbackCount == sidebarCount) {
462
+ callback();
463
+ }
464
+ })
465
+ ;
466
+ },
467
+
468
+ toggle: function () {
469
+ module.verbose('Determining toggled direction');
470
+ if (module.is.hidden()) {
471
+ module.show();
472
+ } else {
473
+ module.hide();
474
+ }
475
+ },
476
+
477
+ pushPage: function (callback) {
478
+ var
479
+ transition = module.get.transition(),
480
+ $transition = (transition === 'overlay' || module.othersActive())
481
+ ? $module
482
+ : $pusher,
483
+ animate,
484
+ dim,
485
+ transitionEnd
486
+ ;
487
+ callback = isFunction(callback)
488
+ ? callback
489
+ : function () {};
490
+ if (settings.returnScroll) {
491
+ currentScroll = (isBody ? $window : $context).scrollTop();
492
+ }
493
+ if (settings.transition === 'scale down') {
494
+ module.scrollToTop();
495
+ }
496
+ module.bind.scrollLock();
497
+ module.set.transition(transition);
498
+ module.repaint();
499
+ animate = function () {
500
+ module.bind.clickaway();
501
+ module.add.inlineCSS();
502
+ module.set.animating();
503
+ module.set.visible();
504
+ };
505
+ dim = function () {
506
+ module.set.dimmed();
507
+ };
508
+ transitionEnd = function (event) {
509
+ if (event.target == $transition[0]) {
510
+ $transition.off(transitionEvent + elementNamespace, transitionEnd);
511
+ module.remove.animating();
512
+ callback.call(element);
513
+ }
514
+ };
515
+ $transition.off(transitionEvent + elementNamespace);
516
+ $transition.on(transitionEvent + elementNamespace, transitionEnd);
517
+ requestAnimationFrame(animate);
518
+ if (settings.dimPage && !module.othersVisible()) {
519
+ requestAnimationFrame(dim);
520
+ }
521
+ },
522
+
523
+ pullPage: function (callback) {
524
+ var
525
+ transition = module.get.transition(),
526
+ $transition = (transition == 'overlay' || module.othersActive())
527
+ ? $module
528
+ : $pusher,
529
+ animate,
530
+ transitionEnd
531
+ ;
532
+ callback = isFunction(callback)
533
+ ? callback
534
+ : function () {};
535
+ module.verbose('Removing context push state', module.get.direction());
536
+
537
+ module.unbind.clickaway();
538
+ module.unbind.scrollLock();
539
+
540
+ animate = function () {
541
+ module.set.transition(transition);
542
+ module.set.animating();
543
+ if (settings.dimPage && !module.othersVisible()) {
544
+ module.set.closing();
545
+ }
546
+ module.remove.visible();
547
+ };
548
+ transitionEnd = function (event) {
549
+ if (event.target == $transition[0]) {
550
+ $transition.off(transitionEvent + elementNamespace, transitionEnd);
551
+ module.remove.animating();
552
+ module.remove.closing();
553
+ module.remove.transition();
554
+ module.remove.inlineCSS();
555
+ if (transition === 'scale down' || settings.returnScroll) {
556
+ module.scrollBack();
557
+ }
558
+ if (settings.dimPage && !module.othersVisible()) {
559
+ $pusher.removeClass(className.dimmed);
560
+ }
561
+ callback.call(element);
562
+ }
563
+ };
564
+ $transition.off(transitionEvent + elementNamespace);
565
+ $transition.on(transitionEvent + elementNamespace, transitionEnd);
566
+ requestAnimationFrame(animate);
567
+ },
568
+
569
+ scrollToTop: function () {
570
+ module.verbose('Scrolling to top of page to avoid animation issues');
571
+ $module.scrollTop(0);
572
+ (isBody ? $window : $context)[0].scrollTo(0, 0);
573
+ },
574
+
575
+ scrollBack: function () {
576
+ module.verbose('Scrolling back to original page position');
577
+ (isBody ? $window : $context)[0].scrollTo(0, currentScroll);
578
+ },
579
+
580
+ clear: {
581
+ cache: function () {
582
+ module.verbose('Clearing cached dimensions');
583
+ module.cache = {};
584
+ },
585
+ },
586
+
587
+ set: {
588
+ bodyMargin: function () {
589
+ var position = module.can.leftBodyScrollbar() ? 'left' : 'right';
590
+ $context.css((isBody ? 'margin-' : 'padding-') + position, tempBodyMargin + 'px');
591
+ $context.find(selector.bodyFixed.replace('right', position)).each(function () {
592
+ var
593
+ el = $(this),
594
+ attribute = el.css('position') === 'fixed' ? 'padding-' + position : position
595
+ ;
596
+ el.css(attribute, 'calc(' + el.css(attribute) + ' + ' + tempBodyMargin + 'px)');
597
+ });
598
+ },
599
+ dimmerStyles: function () {
600
+ if (settings.blurring) {
601
+ $pusher.addClass(className.blurring);
602
+ } else {
603
+ $pusher.removeClass(className.blurring);
604
+ }
605
+ },
606
+ // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios
607
+ // (This is no longer necessary in latest iOS)
608
+ ios: function () {
609
+ $html.addClass(className.ios);
610
+ },
611
+
612
+ // container
613
+ pushed: function () {
614
+ $context.addClass(className.pushed);
615
+ },
616
+ pushable: function () {
617
+ $context.addClass(className.pushable);
618
+ },
619
+
620
+ // pusher
621
+ dimmed: function () {
622
+ $pusher.addClass(className.dimmed);
623
+ },
624
+
625
+ // sidebar
626
+ active: function () {
627
+ $module.addClass(className.active);
628
+ },
629
+ animating: function () {
630
+ $module.addClass(className.animating);
631
+ },
632
+ closing: function () {
633
+ $pusher.addClass(className.closing);
634
+ },
635
+ transition: function (transition) {
636
+ transition = transition || module.get.transition();
637
+ $module.addClass(transition);
638
+ },
639
+ direction: function (direction) {
640
+ direction = direction || module.get.direction();
641
+ $module.addClass(className[direction]);
642
+ },
643
+ visible: function () {
644
+ $module.addClass(className.visible);
645
+ },
646
+ overlay: function () {
647
+ $module.addClass(className.overlay);
648
+ },
649
+ },
650
+ remove: {
651
+
652
+ inlineCSS: function () {
653
+ module.debug('Removing inline css styles', $style);
654
+ if ($style && $style.length > 0) {
655
+ $style.remove();
656
+ }
657
+ },
658
+
659
+ // ios scroll on html not document
660
+ ios: function () {
661
+ $html.removeClass(className.ios);
662
+ },
663
+
664
+ // context
665
+ pushed: function () {
666
+ $context.removeClass(className.pushed);
667
+ },
668
+ pushable: function () {
669
+ $context.removeClass(className.pushable);
670
+ },
671
+
672
+ // sidebar
673
+ active: function () {
674
+ $module.removeClass(className.active);
675
+ },
676
+ animating: function () {
677
+ $module.removeClass(className.animating);
678
+ },
679
+ closing: function () {
680
+ $pusher.removeClass(className.closing);
681
+ },
682
+ transition: function (transition) {
683
+ transition = transition || module.get.transition();
684
+ $module.removeClass(transition);
685
+ },
686
+ direction: function (direction) {
687
+ direction = direction || module.get.direction();
688
+ $module.removeClass(className[direction]);
689
+ },
690
+ visible: function () {
691
+ $module.removeClass(className.visible);
692
+ },
693
+ overlay: function () {
694
+ $module.removeClass(className.overlay);
695
+ },
696
+ },
697
+ restore: {
698
+ bodyMargin: function () {
699
+ var position = module.can.leftBodyScrollbar() ? 'left' : 'right';
700
+ $context.css((isBody ? 'margin-' : 'padding-') + position, initialBodyMargin);
701
+ $context.find(selector.bodyFixed.replace('right', position)).each(function () {
702
+ var
703
+ el = $(this),
704
+ attribute = el.css('position') === 'fixed' ? 'padding-' + position : position
705
+ ;
706
+ el.css(attribute, '');
707
+ });
708
+ },
709
+ },
710
+ get: {
711
+ direction: function () {
712
+ if ($module.hasClass(className.top)) {
713
+ return className.top;
714
+ } else if ($module.hasClass(className.right)) {
715
+ return className.right;
716
+ } else if ($module.hasClass(className.bottom)) {
717
+ return className.bottom;
718
+ }
719
+
720
+ return className.left;
721
+ },
722
+ transition: function () {
723
+ var
724
+ direction = module.get.direction(),
725
+ transition
726
+ ;
727
+ transition = (module.is.mobile())
728
+ ? (settings.mobileTransition == 'auto')
729
+ ? settings.defaultTransition.mobile[direction]
730
+ : settings.mobileTransition
731
+ : (settings.transition == 'auto')
732
+ ? settings.defaultTransition.computer[direction]
733
+ : settings.transition;
734
+ module.verbose('Determined transition', transition);
735
+
736
+ return transition;
737
+ },
738
+ transitionEvent: function () {
739
+ var
740
+ element = document.createElement('element'),
741
+ transitions = {
742
+ transition: 'transitionend',
743
+ OTransition: 'oTransitionEnd',
744
+ MozTransition: 'transitionend',
745
+ WebkitTransition: 'webkitTransitionEnd',
746
+ },
747
+ transition
748
+ ;
749
+ for (transition in transitions) {
750
+ if (element.style[transition] !== undefined) {
751
+ return transitions[transition];
752
+ }
753
+ }
754
+ },
755
+ },
756
+ has: {
757
+ scrollbar: function () {
758
+ return isBody || $context.css('overflow-y') !== 'hidden';
759
+ },
760
+ },
761
+ is: {
762
+ safari: function () {
763
+ if (module.cache.isSafari === undefined) {
764
+ module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
765
+ }
766
+
767
+ return module.cache.isSafari;
768
+ },
769
+ edge: function () {
770
+ if (module.cache.isEdge === undefined) {
771
+ module.cache.isEdge = !!window.setImmediate && !module.is.ie();
772
+ }
773
+
774
+ return module.cache.isEdge;
775
+ },
776
+ firefox: function () {
777
+ if (module.cache.isFirefox === undefined) {
778
+ module.cache.isFirefox = !!window.InstallTrigger;
779
+ }
780
+
781
+ return module.cache.isFirefox;
782
+ },
783
+ iframe: function () {
784
+ return !(self === top);
785
+ },
786
+ ie: function () {
787
+ if (module.cache.isIE === undefined) {
788
+ var
789
+ isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
790
+ isIE = ('ActiveXObject' in window)
791
+ ;
792
+ module.cache.isIE = (isIE11 || isIE);
793
+ }
794
+
795
+ return module.cache.isIE;
796
+ },
797
+
798
+ ios: function () {
799
+ var
800
+ userAgent = navigator.userAgent,
801
+ isIOS = userAgent.match(regExp.ios),
802
+ isMobileChrome = userAgent.match(regExp.mobileChrome)
803
+ ;
804
+ if (isIOS && !isMobileChrome) {
805
+ module.verbose('Browser was found to be iOS', userAgent);
806
+
807
+ return true;
808
+ } else {
809
+ return false;
810
+ }
811
+ },
812
+ mobile: function () {
813
+ var
814
+ userAgent = navigator.userAgent,
815
+ isMobile = userAgent.match(regExp.mobile)
816
+ ;
817
+ if (isMobile) {
818
+ module.verbose('Browser was found to be mobile', userAgent);
819
+
820
+ return true;
821
+ } else {
822
+ module.verbose('Browser is not mobile, using regular transition', userAgent);
823
+
824
+ return false;
825
+ }
826
+ },
827
+ hidden: function () {
828
+ return !module.is.visible();
829
+ },
830
+ visible: function () {
831
+ return $module.hasClass(className.visible);
832
+ },
833
+ // alias
834
+ open: function () {
835
+ return module.is.visible();
836
+ },
837
+ closed: function () {
838
+ return module.is.hidden();
839
+ },
840
+ vertical: function () {
841
+ return $module.hasClass(className.top);
842
+ },
843
+ animating: function () {
844
+ return $context.hasClass(className.animating);
845
+ },
846
+ rtl: function () {
847
+ if (module.cache.isRTL === undefined) {
848
+ module.cache.isRTL = $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
849
+ }
850
+
851
+ return module.cache.isRTL;
852
+ },
853
+ },
854
+
855
+ setting: function (name, value) {
856
+ module.debug('Changing setting', name, value);
857
+ if ($.isPlainObject(name)) {
858
+ $.extend(true, settings, name);
859
+ } else if (value !== undefined) {
860
+ if ($.isPlainObject(settings[name])) {
861
+ $.extend(true, settings[name], value);
862
+ } else {
863
+ settings[name] = value;
864
+ }
865
+ } else {
866
+ return settings[name];
867
+ }
868
+ },
869
+ internal: function (name, value) {
870
+ if ($.isPlainObject(name)) {
871
+ $.extend(true, module, name);
872
+ } else if (value !== undefined) {
873
+ module[name] = value;
874
+ } else {
875
+ return module[name];
876
+ }
877
+ },
878
+ debug: function () {
879
+ if (!settings.silent && settings.debug) {
880
+ if (settings.performance) {
881
+ module.performance.log(arguments);
882
+ } else {
883
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
884
+ module.debug.apply(console, arguments);
885
+ }
886
+ }
887
+ },
888
+ verbose: function () {
889
+ if (!settings.silent && settings.verbose && settings.debug) {
890
+ if (settings.performance) {
891
+ module.performance.log(arguments);
892
+ } else {
893
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
894
+ module.verbose.apply(console, arguments);
895
+ }
896
+ }
897
+ },
898
+ error: function () {
899
+ if (!settings.silent) {
900
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
901
+ module.error.apply(console, arguments);
902
+ }
903
+ },
904
+ performance: {
905
+ log: function (message) {
906
+ var
907
+ currentTime,
908
+ executionTime,
909
+ previousTime
910
+ ;
911
+ if (settings.performance) {
912
+ currentTime = new Date().getTime();
913
+ previousTime = time || currentTime;
914
+ executionTime = currentTime - previousTime;
915
+ time = currentTime;
916
+ performance.push({
917
+ Name: message[0],
918
+ Arguments: [].slice.call(message, 1) || '',
919
+ Element: element,
920
+ 'Execution Time': executionTime,
921
+ });
922
+ }
923
+ clearTimeout(module.performance.timer);
924
+ module.performance.timer = setTimeout(module.performance.display, 500);
925
+ },
926
+ display: function () {
927
+ var
928
+ title = settings.name + ':',
929
+ totalTime = 0
930
+ ;
931
+ time = false;
932
+ clearTimeout(module.performance.timer);
933
+ $.each(performance, function (index, data) {
934
+ totalTime += data['Execution Time'];
935
+ });
936
+ title += ' ' + totalTime + 'ms';
937
+ if (moduleSelector) {
938
+ title += ' \'' + moduleSelector + '\'';
939
+ }
940
+ if ((console.group !== undefined || console.table !== undefined) && performance.length > 0) {
941
+ console.groupCollapsed(title);
942
+ if (console.table) {
943
+ console.table(performance);
944
+ } else {
945
+ $.each(performance, function (index, data) {
946
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
947
+ });
948
+ }
949
+ console.groupEnd();
950
+ }
951
+ performance = [];
952
+ },
953
+ },
954
+ invoke: function (query, passedArguments, context) {
955
+ var
956
+ object = instance,
957
+ maxDepth,
958
+ found,
959
+ response
960
+ ;
961
+ passedArguments = passedArguments || queryArguments;
962
+ context = context || element;
963
+ if (typeof query == 'string' && object !== undefined) {
964
+ query = query.split(/[\. ]/);
965
+ maxDepth = query.length - 1;
966
+ $.each(query, function (depth, value) {
967
+ var camelCaseValue = (depth != maxDepth)
968
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
969
+ : query
970
+ ;
971
+ if ($.isPlainObject(object[camelCaseValue]) && (depth != maxDepth)) {
972
+ object = object[camelCaseValue];
973
+ } else if (object[camelCaseValue] !== undefined) {
974
+ found = object[camelCaseValue];
975
+
976
+ return false;
977
+ } else if ($.isPlainObject(object[value]) && (depth != maxDepth)) {
978
+ object = object[value];
979
+ } else if (object[value] !== undefined) {
980
+ found = object[value];
981
+
982
+ return false;
983
+ } else {
984
+ module.error(error.method, query);
985
+
986
+ return false;
987
+ }
988
+ });
989
+ }
990
+ if (isFunction(found)) {
991
+ response = found.apply(context, passedArguments);
992
+ } else if (found !== undefined) {
993
+ response = found;
994
+ }
995
+ if (Array.isArray(returnedValue)) {
996
+ returnedValue.push(response);
997
+ } else if (returnedValue !== undefined) {
998
+ returnedValue = [returnedValue, response];
999
+ } else if (response !== undefined) {
1000
+ returnedValue = response;
1001
+ }
1002
+
1003
+ return found;
1004
+ },
333
1005
  };
334
- },
335
- layout: function() {
336
- if( $context.children(selector.pusher).length === 0 ) {
337
- module.debug('Adding wrapper element for sidebar');
338
- module.error(error.pusher);
339
- $pusher = $('<div class="pusher" />');
340
- $context
341
- .children()
342
- .not(selector.omitted)
343
- .not($sidebars)
344
- .wrapAll($pusher)
345
- ;
346
- module.refresh();
347
- }
348
- if($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
349
- module.debug('Moved sidebar to correct parent element');
350
- module.error(error.movedSidebar, element);
351
- $module.detach().prependTo($context);
352
- module.refresh();
353
- }
354
- module.clear.cache();
355
- module.set.pushable();
356
- module.set.direction();
357
- }
358
- },
359
1006
 
360
- attachEvents: function(selector, event) {
361
- var
362
- $toggle = $(selector)
363
- ;
364
- event = isFunction(module[event])
365
- ? module[event]
366
- : module.toggle
367
- ;
368
- if($toggle.length > 0) {
369
- module.debug('Attaching sidebar events to element', selector, event);
370
- $toggle
371
- .on('click' + eventNamespace, event)
372
- ;
373
- }
374
- else {
375
- module.error(error.notFound, selector);
376
- }
377
- },
378
- can: {
379
- leftBodyScrollbar: function () {
380
- if (module.cache.leftBodyScrollbar === undefined) {
381
- module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
382
- }
383
- return module.cache.leftBodyScrollbar;
384
- }
385
- },
386
- save: {
387
- bodyMargin: function() {
388
- initialBodyMargin = $context.css((isBody ? 'margin-':'padding-')+(module.can.leftBodyScrollbar() ? 'left':'right'));
389
- var bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, '')),
390
- bodyScrollbarWidth = isBody ? window.innerWidth - document.documentElement.clientWidth : $context[0].offsetWidth - $context[0].clientWidth;
391
- tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
392
- }
393
- },
394
- show: function(callback) {
395
- callback = isFunction(callback)
396
- ? callback
397
- : function(){}
398
- ;
399
- if(module.is.hidden()) {
400
- if(settings.onShow.call(element) === false) {
401
- module.verbose('Show callback returned false cancelling show');
402
- return;
403
- }
404
- if(settings.overlay) {
405
- module.error(error.overlay);
406
- settings.transition = 'overlay';
407
- }
408
- module.refresh();
409
- if(module.othersActive()) {
410
- module.debug('Other sidebars currently visible');
411
- if(settings.exclusive) {
412
- // if not overlay queue animation after hide
413
- if(settings.transition != 'overlay') {
414
- module.hideOthers(module.show);
415
- return;
1007
+ if (methodInvoked) {
1008
+ if (instance === undefined) {
1009
+ module.initialize();
416
1010
  }
417
- else {
418
- module.hideOthers();
1011
+ module.invoke(query);
1012
+ } else {
1013
+ if (instance !== undefined) {
1014
+ module.invoke('destroy');
419
1015
  }
420
- }
421
- else {
422
- settings.transition = 'overlay';
423
- }
1016
+ module.initialize();
424
1017
  }
425
- module.set.dimmerStyles();
426
- module.pushPage(function() {
427
- callback.call(element);
428
- settings.onVisible.call(element);
429
- });
430
- settings.onChange.call(element);
431
- }
432
- else {
433
- module.debug('Sidebar is already visible');
434
- }
435
- },
436
-
437
- hide: function(callback) {
438
- callback = isFunction(callback)
439
- ? callback
440
- : function(){}
441
- ;
442
- if((module.is.visible() || module.is.animating()) && settings.onHide.call(element) !== false) {
443
- module.debug('Hiding sidebar', callback);
444
- module.refreshSidebars();
445
- module.pullPage(function() {
446
- callback.call(element);
447
- settings.onHidden.call(element);
448
- });
449
- settings.onChange.call(element);
450
- }
451
- },
452
-
453
- othersAnimating: function() {
454
- return ($sidebars.not($module).filter('.' + className.animating).length > 0);
455
- },
456
- othersVisible: function() {
457
- return ($sidebars.not($module).filter('.' + className.visible).length > 0);
458
- },
459
- othersActive: function() {
460
- return(module.othersVisible() || module.othersAnimating());
1018
+ });
1019
+
1020
+ return (returnedValue !== undefined)
1021
+ ? returnedValue
1022
+ : this;
1023
+ };
1024
+
1025
+ $.fn.sidebar.settings = {
1026
+
1027
+ name: 'Sidebar',
1028
+ namespace: 'sidebar',
1029
+
1030
+ silent: false,
1031
+ debug: false,
1032
+ verbose: false,
1033
+ performance: true,
1034
+
1035
+ transition: 'auto',
1036
+ mobileTransition: 'auto',
1037
+
1038
+ defaultTransition: {
1039
+ computer: {
1040
+ left: 'uncover',
1041
+ right: 'uncover',
1042
+ top: 'overlay',
1043
+ bottom: 'overlay',
1044
+ },
1045
+ mobile: {
1046
+ left: 'uncover',
1047
+ right: 'uncover',
1048
+ top: 'overlay',
1049
+ bottom: 'overlay',
1050
+ },
461
1051
  },
462
1052
 
463
- hideOthers: function(callback) {
464
- var
465
- $otherSidebars = $sidebars.not($module).filter('.' + className.visible),
466
- sidebarCount = $otherSidebars.length,
467
- callbackCount = 0
468
- ;
469
- callback = callback || function(){};
470
- $otherSidebars
471
- .sidebar('hide', function() {
472
- callbackCount++;
473
- if(callbackCount == sidebarCount) {
474
- callback();
475
- }
476
- })
477
- ;
1053
+ context: 'body',
1054
+ exclusive: false,
1055
+ closable: true,
1056
+ dimPage: true,
1057
+ scrollLock: false,
1058
+ returnScroll: false,
1059
+ delaySetup: false,
1060
+
1061
+ onChange: function () {},
1062
+ onShow: function () {},
1063
+ onHide: function () {},
1064
+
1065
+ onHidden: function () {},
1066
+ onVisible: function () {},
1067
+
1068
+ className: {
1069
+ active: 'active',
1070
+ animating: 'animating',
1071
+ blurring: 'blurring',
1072
+ closing: 'closing',
1073
+ dimmed: 'dimmed',
1074
+ ios: 'ios',
1075
+ locked: 'locked',
1076
+ pushable: 'pushable',
1077
+ pushed: 'pushed',
1078
+ right: 'right',
1079
+ top: 'top',
1080
+ left: 'left',
1081
+ bottom: 'bottom',
1082
+ visible: 'visible',
478
1083
  },
479
1084
 
480
- toggle: function() {
481
- module.verbose('Determining toggled direction');
482
- if(module.is.hidden()) {
483
- module.show();
484
- }
485
- else {
486
- module.hide();
487
- }
488
- },
489
-
490
- pushPage: function(callback) {
491
- var
492
- transition = module.get.transition(),
493
- $transition = (transition === 'overlay' || module.othersActive())
494
- ? $module
495
- : $pusher,
496
- animate,
497
- dim,
498
- transitionEnd
499
- ;
500
- callback = isFunction(callback)
501
- ? callback
502
- : function(){}
503
- ;
504
- if(settings.returnScroll) {
505
- currentScroll = (isBody ? $window : $context).scrollTop();
506
- }
507
- if(settings.transition === 'scale down') {
508
- module.scrollToTop();
509
- }
510
- module.bind.scrollLock();
511
- module.set.transition(transition);
512
- module.repaint();
513
- animate = function() {
514
- module.bind.clickaway();
515
- module.add.inlineCSS();
516
- module.set.animating();
517
- module.set.visible();
518
- };
519
- dim = function() {
520
- module.set.dimmed();
521
- };
522
- transitionEnd = function(event) {
523
- if( event.target == $transition[0] ) {
524
- $transition.off(transitionEvent + elementNamespace, transitionEnd);
525
- module.remove.animating();
526
- callback.call(element);
527
- }
528
- };
529
- $transition.off(transitionEvent + elementNamespace);
530
- $transition.on(transitionEvent + elementNamespace, transitionEnd);
531
- requestAnimationFrame(animate);
532
- if(settings.dimPage && !module.othersVisible()) {
533
- requestAnimationFrame(dim);
534
- }
535
- },
536
-
537
- pullPage: function(callback) {
538
- var
539
- transition = module.get.transition(),
540
- $transition = (transition == 'overlay' || module.othersActive())
541
- ? $module
542
- : $pusher,
543
- animate,
544
- transitionEnd
545
- ;
546
- callback = isFunction(callback)
547
- ? callback
548
- : function(){}
549
- ;
550
- module.verbose('Removing context push state', module.get.direction());
551
-
552
- module.unbind.clickaway();
553
- module.unbind.scrollLock();
554
-
555
- animate = function() {
556
- module.set.transition(transition);
557
- module.set.animating();
558
- if(settings.dimPage && !module.othersVisible()) {
559
- module.set.closing();
560
- }
561
- module.remove.visible();
562
- };
563
- transitionEnd = function(event) {
564
- if( event.target == $transition[0] ) {
565
- $transition.off(transitionEvent + elementNamespace, transitionEnd);
566
- module.remove.animating();
567
- module.remove.closing();
568
- module.remove.transition();
569
- module.remove.inlineCSS();
570
- if(transition === 'scale down' || settings.returnScroll) {
571
- module.scrollBack();
572
- }
573
- if(settings.dimPage && !module.othersVisible()) {
574
- $pusher.removeClass(className.dimmed);
575
- }
576
- callback.call(element);
577
- }
578
- };
579
- $transition.off(transitionEvent + elementNamespace);
580
- $transition.on(transitionEvent + elementNamespace, transitionEnd);
581
- requestAnimationFrame(animate);
1085
+ selector: {
1086
+ bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close',
1087
+ fixed: '.fixed',
1088
+ omitted: 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
1089
+ pusher: '.pusher',
1090
+ sidebar: '.ui.sidebar',
582
1091
  },
583
1092
 
584
- scrollToTop: function() {
585
- module.verbose('Scrolling to top of page to avoid animation issues');
586
- $module.scrollTop(0);
587
- (isBody ? $window : $context)[0].scrollTo(0, 0);
1093
+ regExp: {
1094
+ ios: /(iPad|iPhone|iPod)/g,
1095
+ mobileChrome: /(CriOS)/g,
1096
+ mobile: /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g,
588
1097
  },
589
1098
 
590
- scrollBack: function() {
591
- module.verbose('Scrolling back to original page position');
592
- (isBody ? $window : $context)[0].scrollTo(0, currentScroll);
1099
+ error: {
1100
+ method: 'The method you called is not defined.',
1101
+ pusher: 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
1102
+ movedSidebar: 'Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag',
1103
+ overlay: 'The overlay setting is no longer supported, use animation: overlay',
1104
+ notFound: 'There were no elements that matched the specified selector',
593
1105
  },
594
1106
 
595
- clear: {
596
- cache: function() {
597
- module.verbose('Clearing cached dimensions');
598
- module.cache = {};
599
- }
600
- },
601
-
602
- set: {
603
- bodyMargin: function() {
604
- var position = module.can.leftBodyScrollbar() ? 'left':'right';
605
- $context.css((isBody ? 'margin-':'padding-')+position, tempBodyMargin + 'px');
606
- $context.find(selector.bodyFixed.replace('right',position)).each(function(){
607
- var el = $(this),
608
- attribute = el.css('position') === 'fixed' ? 'padding-'+position : position
609
- ;
610
- el.css(attribute, 'calc(' + el.css(attribute) + ' + ' + tempBodyMargin + 'px)');
611
- });
612
- },
613
- dimmerStyles: function() {
614
- if(settings.blurring) {
615
- $pusher.addClass(className.blurring);
616
- }
617
- else {
618
- $pusher.removeClass(className.blurring);
619
- }
620
- },
621
- // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios
622
- // (This is no longer necessary in latest iOS)
623
- ios: function() {
624
- $html.addClass(className.ios);
625
- },
626
-
627
- // container
628
- pushed: function() {
629
- $context.addClass(className.pushed);
630
- },
631
- pushable: function() {
632
- $context.addClass(className.pushable);
633
- },
634
-
635
- // pusher
636
- dimmed: function() {
637
- $pusher.addClass(className.dimmed);
638
- },
639
-
640
- // sidebar
641
- active: function() {
642
- $module.addClass(className.active);
643
- },
644
- animating: function() {
645
- $module.addClass(className.animating);
646
- },
647
- closing: function() {
648
- $pusher.addClass(className.closing);
649
- },
650
- transition: function(transition) {
651
- transition = transition || module.get.transition();
652
- $module.addClass(transition);
653
- },
654
- direction: function(direction) {
655
- direction = direction || module.get.direction();
656
- $module.addClass(className[direction]);
657
- },
658
- visible: function() {
659
- $module.addClass(className.visible);
660
- },
661
- overlay: function() {
662
- $module.addClass(className.overlay);
663
- }
664
- },
665
- remove: {
666
-
667
- inlineCSS: function() {
668
- module.debug('Removing inline css styles', $style);
669
- if($style && $style.length > 0) {
670
- $style.remove();
671
- }
672
- },
673
-
674
- // ios scroll on html not document
675
- ios: function() {
676
- $html.removeClass(className.ios);
677
- },
678
-
679
- // context
680
- pushed: function() {
681
- $context.removeClass(className.pushed);
682
- },
683
- pushable: function() {
684
- $context.removeClass(className.pushable);
685
- },
686
-
687
- // sidebar
688
- active: function() {
689
- $module.removeClass(className.active);
690
- },
691
- animating: function() {
692
- $module.removeClass(className.animating);
693
- },
694
- closing: function() {
695
- $pusher.removeClass(className.closing);
696
- },
697
- transition: function(transition) {
698
- transition = transition || module.get.transition();
699
- $module.removeClass(transition);
700
- },
701
- direction: function(direction) {
702
- direction = direction || module.get.direction();
703
- $module.removeClass(className[direction]);
704
- },
705
- visible: function() {
706
- $module.removeClass(className.visible);
707
- },
708
- overlay: function() {
709
- $module.removeClass(className.overlay);
710
- }
711
- },
712
- restore: {
713
- bodyMargin: function() {
714
- var position = module.can.leftBodyScrollbar() ? 'left':'right';
715
- $context.css((isBody ? 'margin-':'padding-')+position, initialBodyMargin);
716
- $context.find(selector.bodyFixed.replace('right',position)).each(function(){
717
- var el = $(this),
718
- attribute = el.css('position') === 'fixed' ? 'padding-'+position : position
719
- ;
720
- el.css(attribute, '');
721
- });
722
- }
723
- },
724
- get: {
725
- direction: function() {
726
- if($module.hasClass(className.top)) {
727
- return className.top;
728
- }
729
- else if($module.hasClass(className.right)) {
730
- return className.right;
731
- }
732
- else if($module.hasClass(className.bottom)) {
733
- return className.bottom;
734
- }
735
- return className.left;
736
- },
737
- transition: function() {
738
- var
739
- direction = module.get.direction(),
740
- transition
741
- ;
742
- transition = ( module.is.mobile() )
743
- ? (settings.mobileTransition == 'auto')
744
- ? settings.defaultTransition.mobile[direction]
745
- : settings.mobileTransition
746
- : (settings.transition == 'auto')
747
- ? settings.defaultTransition.computer[direction]
748
- : settings.transition
749
- ;
750
- module.verbose('Determined transition', transition);
751
- return transition;
752
- },
753
- transitionEvent: function() {
754
- var
755
- element = document.createElement('element'),
756
- transitions = {
757
- 'transition' :'transitionend',
758
- 'OTransition' :'oTransitionEnd',
759
- 'MozTransition' :'transitionend',
760
- 'WebkitTransition' :'webkitTransitionEnd'
761
- },
762
- transition
763
- ;
764
- for(transition in transitions){
765
- if( element.style[transition] !== undefined ){
766
- return transitions[transition];
767
- }
768
- }
769
- }
770
- },
771
- has: {
772
- scrollbar: function() {
773
- return isBody || $context.css('overflow-y') !== 'hidden';
774
- }
775
- },
776
- is: {
777
- safari: function() {
778
- if(module.cache.isSafari === undefined) {
779
- module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
780
- }
781
- return module.cache.isSafari;
782
- },
783
- edge: function(){
784
- if(module.cache.isEdge === undefined) {
785
- module.cache.isEdge = !!window.setImmediate && !module.is.ie();
786
- }
787
- return module.cache.isEdge;
788
- },
789
- firefox: function(){
790
- if(module.cache.isFirefox === undefined) {
791
- module.cache.isFirefox = !!window.InstallTrigger;
792
- }
793
- return module.cache.isFirefox;
794
- },
795
- iframe: function() {
796
- return !(self === top);
797
- },
798
- ie: function() {
799
- if(module.cache.isIE === undefined) {
800
- var
801
- isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
802
- isIE = ('ActiveXObject' in window)
803
- ;
804
- module.cache.isIE = (isIE11 || isIE);
805
- }
806
- return module.cache.isIE;
807
- },
808
-
809
- ios: function() {
810
- var
811
- userAgent = navigator.userAgent,
812
- isIOS = userAgent.match(regExp.ios),
813
- isMobileChrome = userAgent.match(regExp.mobileChrome)
814
- ;
815
- if(isIOS && !isMobileChrome) {
816
- module.verbose('Browser was found to be iOS', userAgent);
817
- return true;
818
- }
819
- else {
820
- return false;
821
- }
822
- },
823
- mobile: function() {
824
- var
825
- userAgent = navigator.userAgent,
826
- isMobile = userAgent.match(regExp.mobile)
827
- ;
828
- if(isMobile) {
829
- module.verbose('Browser was found to be mobile', userAgent);
830
- return true;
831
- }
832
- else {
833
- module.verbose('Browser is not mobile, using regular transition', userAgent);
834
- return false;
835
- }
836
- },
837
- hidden: function() {
838
- return !module.is.visible();
839
- },
840
- visible: function() {
841
- return $module.hasClass(className.visible);
842
- },
843
- // alias
844
- open: function() {
845
- return module.is.visible();
846
- },
847
- closed: function() {
848
- return module.is.hidden();
849
- },
850
- vertical: function() {
851
- return $module.hasClass(className.top);
852
- },
853
- animating: function() {
854
- return $context.hasClass(className.animating);
855
- },
856
- rtl: function() {
857
- if(module.cache.isRTL === undefined) {
858
- module.cache.isRTL = $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
859
- }
860
- return module.cache.isRTL;
861
- },
862
- },
863
-
864
- setting: function(name, value) {
865
- module.debug('Changing setting', name, value);
866
- if( $.isPlainObject(name) ) {
867
- $.extend(true, settings, name);
868
- }
869
- else if(value !== undefined) {
870
- if($.isPlainObject(settings[name])) {
871
- $.extend(true, settings[name], value);
872
- }
873
- else {
874
- settings[name] = value;
875
- }
876
- }
877
- else {
878
- return settings[name];
879
- }
880
- },
881
- internal: function(name, value) {
882
- if( $.isPlainObject(name) ) {
883
- $.extend(true, module, name);
884
- }
885
- else if(value !== undefined) {
886
- module[name] = value;
887
- }
888
- else {
889
- return module[name];
890
- }
891
- },
892
- debug: function() {
893
- if(!settings.silent && settings.debug) {
894
- if(settings.performance) {
895
- module.performance.log(arguments);
896
- }
897
- else {
898
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
899
- module.debug.apply(console, arguments);
900
- }
901
- }
902
- },
903
- verbose: function() {
904
- if(!settings.silent && settings.verbose && settings.debug) {
905
- if(settings.performance) {
906
- module.performance.log(arguments);
907
- }
908
- else {
909
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
910
- module.verbose.apply(console, arguments);
911
- }
912
- }
913
- },
914
- error: function() {
915
- if(!settings.silent) {
916
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
917
- module.error.apply(console, arguments);
918
- }
919
- },
920
- performance: {
921
- log: function(message) {
922
- var
923
- currentTime,
924
- executionTime,
925
- previousTime
926
- ;
927
- if(settings.performance) {
928
- currentTime = new Date().getTime();
929
- previousTime = time || currentTime;
930
- executionTime = currentTime - previousTime;
931
- time = currentTime;
932
- performance.push({
933
- 'Name' : message[0],
934
- 'Arguments' : [].slice.call(message, 1) || '',
935
- 'Element' : element,
936
- 'Execution Time' : executionTime
937
- });
938
- }
939
- clearTimeout(module.performance.timer);
940
- module.performance.timer = setTimeout(module.performance.display, 500);
941
- },
942
- display: function() {
943
- var
944
- title = settings.name + ':',
945
- totalTime = 0
946
- ;
947
- time = false;
948
- clearTimeout(module.performance.timer);
949
- $.each(performance, function(index, data) {
950
- totalTime += data['Execution Time'];
951
- });
952
- title += ' ' + totalTime + 'ms';
953
- if(moduleSelector) {
954
- title += ' \'' + moduleSelector + '\'';
955
- }
956
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
957
- console.groupCollapsed(title);
958
- if(console.table) {
959
- console.table(performance);
960
- }
961
- else {
962
- $.each(performance, function(index, data) {
963
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
964
- });
965
- }
966
- console.groupEnd();
967
- }
968
- performance = [];
969
- }
970
- },
971
- invoke: function(query, passedArguments, context) {
972
- var
973
- object = instance,
974
- maxDepth,
975
- found,
976
- response
977
- ;
978
- passedArguments = passedArguments || queryArguments;
979
- context = context || element;
980
- if(typeof query == 'string' && object !== undefined) {
981
- query = query.split(/[\. ]/);
982
- maxDepth = query.length - 1;
983
- $.each(query, function(depth, value) {
984
- var camelCaseValue = (depth != maxDepth)
985
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
986
- : query
987
- ;
988
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
989
- object = object[camelCaseValue];
990
- }
991
- else if( object[camelCaseValue] !== undefined ) {
992
- found = object[camelCaseValue];
993
- return false;
994
- }
995
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
996
- object = object[value];
997
- }
998
- else if( object[value] !== undefined ) {
999
- found = object[value];
1000
- return false;
1001
- }
1002
- else {
1003
- module.error(error.method, query);
1004
- return false;
1005
- }
1006
- });
1007
- }
1008
- if ( isFunction( found ) ) {
1009
- response = found.apply(context, passedArguments);
1010
- }
1011
- else if(found !== undefined) {
1012
- response = found;
1013
- }
1014
- if(Array.isArray(returnedValue)) {
1015
- returnedValue.push(response);
1016
- }
1017
- else if(returnedValue !== undefined) {
1018
- returnedValue = [returnedValue, response];
1019
- }
1020
- else if(response !== undefined) {
1021
- returnedValue = response;
1022
- }
1023
- return found;
1024
- }
1025
- }
1026
- ;
1027
-
1028
- if(methodInvoked) {
1029
- if(instance === undefined) {
1030
- module.initialize();
1031
- }
1032
- module.invoke(query);
1033
- }
1034
- else {
1035
- if(instance !== undefined) {
1036
- module.invoke('destroy');
1037
- }
1038
- module.initialize();
1039
- }
1040
- });
1041
-
1042
- return (returnedValue !== undefined)
1043
- ? returnedValue
1044
- : this
1045
- ;
1046
- };
1047
-
1048
- $.fn.sidebar.settings = {
1049
-
1050
- name : 'Sidebar',
1051
- namespace : 'sidebar',
1052
-
1053
- silent : false,
1054
- debug : false,
1055
- verbose : false,
1056
- performance : true,
1057
-
1058
- transition : 'auto',
1059
- mobileTransition : 'auto',
1060
-
1061
- defaultTransition : {
1062
- computer: {
1063
- left : 'uncover',
1064
- right : 'uncover',
1065
- top : 'overlay',
1066
- bottom : 'overlay'
1067
- },
1068
- mobile: {
1069
- left : 'uncover',
1070
- right : 'uncover',
1071
- top : 'overlay',
1072
- bottom : 'overlay'
1073
- }
1074
- },
1075
-
1076
- context : 'body',
1077
- exclusive : false,
1078
- closable : true,
1079
- dimPage : true,
1080
- scrollLock : false,
1081
- returnScroll : false,
1082
- delaySetup : false,
1083
-
1084
- onChange : function(){},
1085
- onShow : function(){},
1086
- onHide : function(){},
1087
-
1088
- onHidden : function(){},
1089
- onVisible : function(){},
1090
-
1091
- className : {
1092
- active : 'active',
1093
- animating : 'animating',
1094
- blurring : 'blurring',
1095
- closing : 'closing',
1096
- dimmed : 'dimmed',
1097
- ios : 'ios',
1098
- locked : 'locked',
1099
- pushable : 'pushable',
1100
- pushed : 'pushed',
1101
- right : 'right',
1102
- top : 'top',
1103
- left : 'left',
1104
- bottom : 'bottom',
1105
- visible : 'visible'
1106
- },
1107
-
1108
- selector: {
1109
- bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close',
1110
- fixed : '.fixed',
1111
- omitted : 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
1112
- pusher : '.pusher',
1113
- sidebar : '.ui.sidebar'
1114
- },
1115
-
1116
- regExp: {
1117
- ios : /(iPad|iPhone|iPod)/g,
1118
- mobileChrome : /(CriOS)/g,
1119
- mobile : /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g
1120
- },
1121
-
1122
- error : {
1123
- method : 'The method you called is not defined.',
1124
- pusher : 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
1125
- movedSidebar : 'Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag',
1126
- overlay : 'The overlay setting is no longer supported, use animation: overlay',
1127
- notFound : 'There were no elements that matched the specified selector'
1128
- }
1129
-
1130
- };
1131
-
1132
-
1133
- })( jQuery, window, document );
1107
+ };
1108
+ })(jQuery, window, document);