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,551 +8,535 @@
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.rating = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- moduleSelector = $allModules.selector || '',
30
-
31
- time = new Date().getTime(),
32
- performance = [],
33
-
34
- query = arguments[0],
35
- methodInvoked = (typeof query == 'string'),
36
- queryArguments = [].slice.call(arguments, 1),
37
- returnedValue
38
- ;
39
- $allModules
40
- .each(function() {
41
- var
42
- settings = ( $.isPlainObject(parameters) )
43
- ? $.extend(true, {}, $.fn.rating.settings, parameters)
44
- : $.extend({}, $.fn.rating.settings),
45
-
46
- namespace = settings.namespace,
47
- className = settings.className,
48
- metadata = settings.metadata,
49
- selector = settings.selector,
50
- cssVars = settings.cssVars,
51
-
52
- eventNamespace = '.' + namespace,
53
- moduleNamespace = 'module-' + namespace,
54
-
55
- element = this,
56
- instance = $(this).data(moduleNamespace),
57
-
58
- $module = $(this),
59
- $icon = $module.find(selector.icon),
60
-
61
- initialLoad,
62
- module
63
- ;
64
-
65
- module = {
66
-
67
- initialize: function() {
68
- module.verbose('Initializing rating module', settings);
69
-
70
- if($icon.length === 0) {
71
- module.setup.layout();
72
- }
73
-
74
- if(settings.interactive && !module.is.disabled()) {
75
- module.enable();
76
- }
77
- else {
78
- module.disable();
79
- }
80
- module.set.initialLoad();
81
- module.set.rating( module.get.initialRating() );
82
- module.remove.initialLoad();
83
- module.instantiate();
84
- },
11
+ (function ($, window, document, undefined) {
12
+ 'use strict';
85
13
 
86
- instantiate: function() {
87
- module.verbose('Instantiating module', settings);
88
- instance = module;
89
- $module
90
- .data(moduleNamespace, module)
91
- ;
92
- },
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
93
17
 
94
- destroy: function() {
95
- module.verbose('Destroying previous instance', instance);
96
- module.remove.events();
97
- $module
98
- .removeData(moduleNamespace)
99
- ;
100
- },
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.rating = function (parameters) {
25
+ var
26
+ $allModules = $(this),
27
+ moduleSelector = $allModules.selector || '',
28
+
29
+ time = new Date().getTime(),
30
+ performance = [],
31
+
32
+ query = arguments[0],
33
+ methodInvoked = (typeof query == 'string'),
34
+ queryArguments = [].slice.call(arguments, 1),
35
+ returnedValue
36
+ ;
37
+ $allModules.each(function () {
38
+ var
39
+ settings = ($.isPlainObject(parameters))
40
+ ? $.extend(true, {}, $.fn.rating.settings, parameters)
41
+ : $.extend({}, $.fn.rating.settings),
101
42
 
102
- refresh: function() {
103
- $icon = $module.find(selector.icon);
104
- },
43
+ namespace = settings.namespace,
44
+ className = settings.className,
45
+ metadata = settings.metadata,
46
+ selector = settings.selector,
47
+ cssVars = settings.cssVars,
105
48
 
106
- setup: {
107
- layout: function() {
108
- var
109
- maxRating = module.get.maxRating(),
110
- icon = module.get.icon(),
111
- html = $.fn.rating.settings.templates.icon(maxRating, icon)
112
- ;
113
- module.debug('Generating icon html dynamically');
114
- $module
115
- .html(html)
116
- ;
117
- module.refresh();
118
- }
119
- },
49
+ eventNamespace = '.' + namespace,
50
+ moduleNamespace = 'module-' + namespace,
120
51
 
121
- event: {
122
- mouseenter: function() {
123
- var
124
- $activeIcon = $(this)
125
- ;
126
- $activeIcon
127
- .nextAll()
128
- .removeClass(className.selected)
129
- ;
130
- $module
131
- .addClass(className.selected)
132
- ;
133
- $activeIcon
134
- .addClass(className.selected)
135
- .prevAll()
136
- .addClass(className.selected)
137
- ;
138
- },
139
- mouseleave: function() {
140
- $module
141
- .removeClass(className.selected)
142
- ;
143
- $icon
144
- .removeClass(className.selected)
145
- ;
146
- },
147
- click: function() {
148
- var
149
- $activeIcon = $(this),
150
- currentRating = module.get.rating(),
151
- rating = $icon.index($activeIcon) + 1,
152
- canClear = (settings.clearable == 'auto')
153
- ? ($icon.length === 1)
154
- : settings.clearable
52
+ element = this,
53
+ instance = $(this).data(moduleNamespace),
54
+
55
+ $module = $(this),
56
+ $icon = $module.find(selector.icon),
57
+
58
+ initialLoad,
59
+ module
155
60
  ;
156
- if(canClear && currentRating == rating) {
157
- module.clearRating();
158
- }
159
- else {
160
- module.set.rating( rating );
61
+
62
+ module = {
63
+
64
+ initialize: function () {
65
+ module.verbose('Initializing rating module', settings);
66
+
67
+ if ($icon.length === 0) {
68
+ module.setup.layout();
69
+ }
70
+
71
+ if (settings.interactive && !module.is.disabled()) {
72
+ module.enable();
73
+ } else {
74
+ module.disable();
75
+ }
76
+ module.set.initialLoad();
77
+ module.set.rating(module.get.initialRating());
78
+ module.remove.initialLoad();
79
+ module.instantiate();
80
+ },
81
+
82
+ instantiate: function () {
83
+ module.verbose('Instantiating module', settings);
84
+ instance = module;
85
+ $module
86
+ .data(moduleNamespace, module)
87
+ ;
88
+ },
89
+
90
+ destroy: function () {
91
+ module.verbose('Destroying previous instance', instance);
92
+ module.remove.events();
93
+ $module
94
+ .removeData(moduleNamespace)
95
+ ;
96
+ },
97
+
98
+ refresh: function () {
99
+ $icon = $module.find(selector.icon);
100
+ },
101
+
102
+ setup: {
103
+ layout: function () {
104
+ var
105
+ maxRating = module.get.maxRating(),
106
+ icon = module.get.icon(),
107
+ html = $.fn.rating.settings.templates.icon(maxRating, icon)
108
+ ;
109
+ module.debug('Generating icon html dynamically');
110
+ $module
111
+ .html(html)
112
+ ;
113
+ module.refresh();
114
+ },
115
+ },
116
+
117
+ event: {
118
+ mouseenter: function () {
119
+ var
120
+ $activeIcon = $(this)
121
+ ;
122
+ $activeIcon
123
+ .nextAll()
124
+ .removeClass(className.selected)
125
+ ;
126
+ $module
127
+ .addClass(className.selected)
128
+ ;
129
+ $activeIcon
130
+ .addClass(className.selected)
131
+ .prevAll()
132
+ .addClass(className.selected)
133
+ ;
134
+ },
135
+ mouseleave: function () {
136
+ $module
137
+ .removeClass(className.selected)
138
+ ;
139
+ $icon
140
+ .removeClass(className.selected)
141
+ ;
142
+ },
143
+ click: function () {
144
+ var
145
+ $activeIcon = $(this),
146
+ currentRating = module.get.rating(),
147
+ rating = $icon.index($activeIcon) + 1,
148
+ canClear = (settings.clearable == 'auto')
149
+ ? ($icon.length === 1)
150
+ : settings.clearable
151
+ ;
152
+ if (canClear && currentRating == rating) {
153
+ module.clearRating();
154
+ } else {
155
+ module.set.rating(rating);
156
+ }
157
+ },
158
+ },
159
+
160
+ clearRating: function () {
161
+ module.debug('Clearing current rating');
162
+ module.set.rating(0);
163
+ },
164
+
165
+ bind: {
166
+ events: function () {
167
+ module.verbose('Binding events');
168
+ $module
169
+ .on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter)
170
+ .on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave)
171
+ .on('click' + eventNamespace, selector.icon, module.event.click)
172
+ ;
173
+ },
174
+ },
175
+
176
+ remove: {
177
+ events: function () {
178
+ module.verbose('Removing events');
179
+ $module
180
+ .off(eventNamespace)
181
+ ;
182
+ },
183
+ initialLoad: function () {
184
+ initialLoad = false;
185
+ },
186
+ },
187
+
188
+ enable: function () {
189
+ module.debug('Setting rating to interactive mode');
190
+ module.bind.events();
191
+ $module
192
+ .removeClass(className.disabled)
193
+ ;
194
+ },
195
+
196
+ disable: function () {
197
+ module.debug('Setting rating to read-only mode');
198
+ module.remove.events();
199
+ $module
200
+ .addClass(className.disabled)
201
+ ;
202
+ },
203
+
204
+ is: {
205
+ initialLoad: function () {
206
+ return initialLoad;
207
+ },
208
+ disabled: function () {
209
+ return $module.hasClass(className.disabled);
210
+ },
211
+ },
212
+
213
+ get: {
214
+ icon: function () {
215
+ var icon = $module.data(metadata.icon);
216
+ if (icon) {
217
+ $module.removeData(metadata.icon);
218
+ }
219
+
220
+ return icon || settings.icon;
221
+ },
222
+ initialRating: function () {
223
+ if ($module.data(metadata.rating) !== undefined) {
224
+ $module.removeData(metadata.rating);
225
+
226
+ return $module.data(metadata.rating);
227
+ }
228
+
229
+ return settings.initialRating;
230
+ },
231
+ maxRating: function () {
232
+ if ($module.data(metadata.maxRating) !== undefined) {
233
+ $module.removeData(metadata.maxRating);
234
+
235
+ return $module.data(metadata.maxRating);
236
+ }
237
+
238
+ return settings.maxRating;
239
+ },
240
+ rating: function () {
241
+ var
242
+ currentRating = $icon.filter('.' + className.active).length
243
+ ;
244
+ module.verbose('Current rating retrieved', currentRating);
245
+
246
+ return currentRating;
247
+ },
248
+ },
249
+
250
+ set: {
251
+ rating: function (rating) {
252
+ var
253
+ ratingIndex = Math.floor(
254
+ (rating - 1 >= 0)
255
+ ? (rating - 1)
256
+ : 0
257
+ ),
258
+ $activeIcon = $icon.eq(ratingIndex),
259
+ $partialActiveIcon = rating <= 1
260
+ ? $activeIcon
261
+ : $activeIcon.next(),
262
+ filledPercentage = (rating % 1) * 100
263
+ ;
264
+ $module
265
+ .removeClass(className.selected)
266
+ ;
267
+ $icon
268
+ .removeClass(className.selected)
269
+ .removeClass(className.active)
270
+ .removeClass(className.partiallyActive)
271
+ ;
272
+ if (rating > 0) {
273
+ module.verbose('Setting current rating to', rating);
274
+ $activeIcon
275
+ .prevAll()
276
+ .addBack()
277
+ .addClass(className.active)
278
+ ;
279
+ if ($activeIcon.next() && rating % 1 !== 0) {
280
+ $partialActiveIcon
281
+ .addClass(className.partiallyActive)
282
+ .addClass(className.active)
283
+ ;
284
+ $partialActiveIcon
285
+ .css(cssVars.filledCustomPropName, filledPercentage + '%')
286
+ ;
287
+ if ($partialActiveIcon.css('backgroundColor') === 'transparent') {
288
+ $partialActiveIcon
289
+ .removeClass(className.partiallyActive)
290
+ .removeClass(className.active)
291
+ ;
292
+ }
293
+ }
294
+ }
295
+ if (!module.is.initialLoad()) {
296
+ settings.onRate.call(element, rating);
297
+ }
298
+ },
299
+ initialLoad: function () {
300
+ initialLoad = true;
301
+ },
302
+ },
303
+
304
+ setting: function (name, value) {
305
+ module.debug('Changing setting', name, value);
306
+ if ($.isPlainObject(name)) {
307
+ $.extend(true, settings, name);
308
+ } else if (value !== undefined) {
309
+ if ($.isPlainObject(settings[name])) {
310
+ $.extend(true, settings[name], value);
311
+ } else {
312
+ settings[name] = value;
313
+ }
314
+ } else {
315
+ return settings[name];
316
+ }
317
+ },
318
+ internal: function (name, value) {
319
+ if ($.isPlainObject(name)) {
320
+ $.extend(true, module, name);
321
+ } else if (value !== undefined) {
322
+ module[name] = value;
323
+ } else {
324
+ return module[name];
325
+ }
326
+ },
327
+ debug: function () {
328
+ if (!settings.silent && settings.debug) {
329
+ if (settings.performance) {
330
+ module.performance.log(arguments);
331
+ } else {
332
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
333
+ module.debug.apply(console, arguments);
334
+ }
335
+ }
336
+ },
337
+ verbose: function () {
338
+ if (!settings.silent && settings.verbose && settings.debug) {
339
+ if (settings.performance) {
340
+ module.performance.log(arguments);
341
+ } else {
342
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
343
+ module.verbose.apply(console, arguments);
344
+ }
345
+ }
346
+ },
347
+ error: function () {
348
+ if (!settings.silent) {
349
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
350
+ module.error.apply(console, arguments);
351
+ }
352
+ },
353
+ performance: {
354
+ log: function (message) {
355
+ var
356
+ currentTime,
357
+ executionTime,
358
+ previousTime
359
+ ;
360
+ if (settings.performance) {
361
+ currentTime = new Date().getTime();
362
+ previousTime = time || currentTime;
363
+ executionTime = currentTime - previousTime;
364
+ time = currentTime;
365
+ performance.push({
366
+ Name: message[0],
367
+ Arguments: [].slice.call(message, 1) || '',
368
+ Element: element,
369
+ 'Execution Time': executionTime,
370
+ });
371
+ }
372
+ clearTimeout(module.performance.timer);
373
+ module.performance.timer = setTimeout(module.performance.display, 500);
374
+ },
375
+ display: function () {
376
+ var
377
+ title = settings.name + ':',
378
+ totalTime = 0
379
+ ;
380
+ time = false;
381
+ clearTimeout(module.performance.timer);
382
+ $.each(performance, function (index, data) {
383
+ totalTime += data['Execution Time'];
384
+ });
385
+ title += ' ' + totalTime + 'ms';
386
+ if (moduleSelector) {
387
+ title += ' \'' + moduleSelector + '\'';
388
+ }
389
+ if ($allModules.length > 1) {
390
+ title += ' ' + '(' + $allModules.length + ')';
391
+ }
392
+ if ((console.group !== undefined || console.table !== undefined) && performance.length > 0) {
393
+ console.groupCollapsed(title);
394
+ if (console.table) {
395
+ console.table(performance);
396
+ } else {
397
+ $.each(performance, function (index, data) {
398
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
399
+ });
400
+ }
401
+ console.groupEnd();
402
+ }
403
+ performance = [];
404
+ },
405
+ },
406
+ invoke: function (query, passedArguments, context) {
407
+ var
408
+ object = instance,
409
+ maxDepth,
410
+ found,
411
+ response
412
+ ;
413
+ passedArguments = passedArguments || queryArguments;
414
+ context = context || element;
415
+ if (typeof query == 'string' && object !== undefined) {
416
+ query = query.split(/[\. ]/);
417
+ maxDepth = query.length - 1;
418
+ $.each(query, function (depth, value) {
419
+ var camelCaseValue = (depth != maxDepth)
420
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
421
+ : query
422
+ ;
423
+ if ($.isPlainObject(object[camelCaseValue]) && (depth != maxDepth)) {
424
+ object = object[camelCaseValue];
425
+ } else if (object[camelCaseValue] !== undefined) {
426
+ found = object[camelCaseValue];
427
+
428
+ return false;
429
+ } else if ($.isPlainObject(object[value]) && (depth != maxDepth)) {
430
+ object = object[value];
431
+ } else if (object[value] !== undefined) {
432
+ found = object[value];
433
+
434
+ return false;
435
+ } else {
436
+ return false;
437
+ }
438
+ });
439
+ }
440
+ if (isFunction(found)) {
441
+ response = found.apply(context, passedArguments);
442
+ } else if (found !== undefined) {
443
+ response = found;
444
+ }
445
+ if (Array.isArray(returnedValue)) {
446
+ returnedValue.push(response);
447
+ } else if (returnedValue !== undefined) {
448
+ returnedValue = [returnedValue, response];
449
+ } else if (response !== undefined) {
450
+ returnedValue = response;
451
+ }
452
+
453
+ return found;
454
+ },
455
+ };
456
+ if (methodInvoked) {
457
+ if (instance === undefined) {
458
+ module.initialize();
459
+ }
460
+ module.invoke(query);
461
+ } else {
462
+ if (instance !== undefined) {
463
+ instance.invoke('destroy');
464
+ }
465
+ module.initialize();
161
466
  }
162
- }
163
- },
467
+ });
164
468
 
165
- clearRating: function() {
166
- module.debug('Clearing current rating');
167
- module.set.rating(0);
168
- },
469
+ return (returnedValue !== undefined)
470
+ ? returnedValue
471
+ : this;
472
+ };
169
473
 
170
- bind: {
171
- events: function() {
172
- module.verbose('Binding events');
173
- $module
174
- .on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter)
175
- .on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave)
176
- .on('click' + eventNamespace, selector.icon, module.event.click)
177
- ;
178
- }
179
- },
474
+ $.fn.rating.settings = {
180
475
 
181
- remove: {
182
- events: function() {
183
- module.verbose('Removing events');
184
- $module
185
- .off(eventNamespace)
186
- ;
187
- },
188
- initialLoad: function() {
189
- initialLoad = false;
190
- }
476
+ name: 'Rating',
477
+ namespace: 'rating',
478
+
479
+ icon: 'star',
480
+
481
+ silent: false,
482
+ debug: false,
483
+ verbose: false,
484
+ performance: true,
485
+
486
+ initialRating: 0,
487
+ interactive: true,
488
+ maxRating: 4,
489
+ clearable: 'auto',
490
+
491
+ fireOnInit: false,
492
+
493
+ onRate: function (rating) {},
494
+
495
+ error: {
496
+ method: 'The method you called is not defined',
497
+ noMaximum: 'No maximum rating specified. Cannot generate HTML automatically',
191
498
  },
192
499
 
193
- enable: function() {
194
- module.debug('Setting rating to interactive mode');
195
- module.bind.events();
196
- $module
197
- .removeClass(className.disabled)
198
- ;
500
+ metadata: {
501
+ rating: 'rating',
502
+ maxRating: 'maxRating',
503
+ icon: 'icon',
199
504
  },
200
505
 
201
- disable: function() {
202
- module.debug('Setting rating to read-only mode');
203
- module.remove.events();
204
- $module
205
- .addClass(className.disabled)
206
- ;
506
+ className: {
507
+ active: 'active',
508
+ disabled: 'disabled',
509
+ selected: 'selected',
510
+ loading: 'loading',
511
+ partiallyActive: 'partial',
207
512
  },
208
513
 
209
- is: {
210
- initialLoad: function() {
211
- return initialLoad;
212
- },
213
- disabled: function() {
214
- return $module.hasClass(className.disabled);
215
- }
514
+ cssVars: {
515
+ filledCustomPropName: '--full',
216
516
  },
217
517
 
218
- get: {
219
- icon: function(){
220
- var icon = $module.data(metadata.icon);
221
- if (icon) {
222
- $module.removeData(metadata.icon);
223
- }
224
- return icon || settings.icon;
225
- },
226
- initialRating: function() {
227
- if($module.data(metadata.rating) !== undefined) {
228
- $module.removeData(metadata.rating);
229
- return $module.data(metadata.rating);
230
- }
231
- return settings.initialRating;
232
- },
233
- maxRating: function() {
234
- if($module.data(metadata.maxRating) !== undefined) {
235
- $module.removeData(metadata.maxRating);
236
- return $module.data(metadata.maxRating);
237
- }
238
- return settings.maxRating;
239
- },
240
- rating: function() {
241
- var
242
- currentRating = $icon.filter('.' + className.active).length
243
- ;
244
- module.verbose('Current rating retrieved', currentRating);
245
- return currentRating;
246
- }
518
+ selector: {
519
+ icon: '.icon',
247
520
  },
248
521
 
249
- set: {
250
- rating: function(rating) {
251
- var
252
- ratingIndex = Math.floor(
253
- (rating - 1 >= 0)
254
- ? (rating - 1)
255
- : 0
256
- ),
257
- $activeIcon = $icon.eq(ratingIndex),
258
- $partialActiveIcon = rating <= 1
259
- ? $activeIcon
260
- : $activeIcon.next()
261
- ,
262
- filledPercentage = (rating % 1) * 100
263
- ;
264
- $module
265
- .removeClass(className.selected)
266
- ;
267
- $icon
268
- .removeClass(className.selected)
269
- .removeClass(className.active)
270
- .removeClass(className.partiallyActive)
271
- ;
272
- if(rating > 0) {
273
- module.verbose('Setting current rating to', rating);
274
- $activeIcon
275
- .prevAll()
276
- .addBack()
277
- .addClass(className.active)
278
- ;
279
- if($activeIcon.next() && rating % 1 !== 0) {
280
- $partialActiveIcon
281
- .addClass(className.partiallyActive)
282
- .addClass(className.active)
522
+ templates: {
523
+ deQuote: function (string, encode) {
524
+ return String(string).replace(/"/g, encode ? '&quot;' : '');
525
+ },
526
+ icon: function (maxRating, iconClass) {
527
+ var
528
+ icon = 1,
529
+ html = '',
530
+ deQuote = $.fn.rating.settings.templates.deQuote
283
531
  ;
284
- $partialActiveIcon
285
- .css(cssVars.filledCustomPropName, filledPercentage + '%')
286
- ;
287
- if($partialActiveIcon.css('backgroundColor') === 'transparent') {
288
- $partialActiveIcon
289
- .removeClass(className.partiallyActive)
290
- .removeClass(className.active)
291
- ;
532
+ while (icon <= maxRating) {
533
+ html += '<i class="' + deQuote(iconClass) + ' icon"></i>';
534
+ icon++;
292
535
  }
293
- }
294
- }
295
- if(!module.is.initialLoad()) {
296
- settings.onRate.call(element, rating);
297
- }
298
- },
299
- initialLoad: function() {
300
- initialLoad = true;
301
- }
302
- },
303
536
 
304
- setting: function(name, value) {
305
- module.debug('Changing setting', name, value);
306
- if( $.isPlainObject(name) ) {
307
- $.extend(true, settings, name);
308
- }
309
- else if(value !== undefined) {
310
- if($.isPlainObject(settings[name])) {
311
- $.extend(true, settings[name], value);
312
- }
313
- else {
314
- settings[name] = value;
315
- }
316
- }
317
- else {
318
- return settings[name];
319
- }
320
- },
321
- internal: function(name, value) {
322
- if( $.isPlainObject(name) ) {
323
- $.extend(true, module, name);
324
- }
325
- else if(value !== undefined) {
326
- module[name] = value;
327
- }
328
- else {
329
- return module[name];
330
- }
331
- },
332
- debug: function() {
333
- if(!settings.silent && settings.debug) {
334
- if(settings.performance) {
335
- module.performance.log(arguments);
336
- }
337
- else {
338
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
339
- module.debug.apply(console, arguments);
340
- }
341
- }
342
- },
343
- verbose: function() {
344
- if(!settings.silent && settings.verbose && settings.debug) {
345
- if(settings.performance) {
346
- module.performance.log(arguments);
347
- }
348
- else {
349
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
350
- module.verbose.apply(console, arguments);
351
- }
352
- }
537
+ return html;
538
+ },
353
539
  },
354
- error: function() {
355
- if(!settings.silent) {
356
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
357
- module.error.apply(console, arguments);
358
- }
359
- },
360
- performance: {
361
- log: function(message) {
362
- var
363
- currentTime,
364
- executionTime,
365
- previousTime
366
- ;
367
- if(settings.performance) {
368
- currentTime = new Date().getTime();
369
- previousTime = time || currentTime;
370
- executionTime = currentTime - previousTime;
371
- time = currentTime;
372
- performance.push({
373
- 'Name' : message[0],
374
- 'Arguments' : [].slice.call(message, 1) || '',
375
- 'Element' : element,
376
- 'Execution Time' : executionTime
377
- });
378
- }
379
- clearTimeout(module.performance.timer);
380
- module.performance.timer = setTimeout(module.performance.display, 500);
381
- },
382
- display: function() {
383
- var
384
- title = settings.name + ':',
385
- totalTime = 0
386
- ;
387
- time = false;
388
- clearTimeout(module.performance.timer);
389
- $.each(performance, function(index, data) {
390
- totalTime += data['Execution Time'];
391
- });
392
- title += ' ' + totalTime + 'ms';
393
- if(moduleSelector) {
394
- title += ' \'' + moduleSelector + '\'';
395
- }
396
- if($allModules.length > 1) {
397
- title += ' ' + '(' + $allModules.length + ')';
398
- }
399
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
400
- console.groupCollapsed(title);
401
- if(console.table) {
402
- console.table(performance);
403
- }
404
- else {
405
- $.each(performance, function(index, data) {
406
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
407
- });
408
- }
409
- console.groupEnd();
410
- }
411
- performance = [];
412
- }
413
- },
414
- invoke: function(query, passedArguments, context) {
415
- var
416
- object = instance,
417
- maxDepth,
418
- found,
419
- response
420
- ;
421
- passedArguments = passedArguments || queryArguments;
422
- context = context || element;
423
- if(typeof query == 'string' && object !== undefined) {
424
- query = query.split(/[\. ]/);
425
- maxDepth = query.length - 1;
426
- $.each(query, function(depth, value) {
427
- var camelCaseValue = (depth != maxDepth)
428
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
429
- : query
430
- ;
431
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
432
- object = object[camelCaseValue];
433
- }
434
- else if( object[camelCaseValue] !== undefined ) {
435
- found = object[camelCaseValue];
436
- return false;
437
- }
438
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
439
- object = object[value];
440
- }
441
- else if( object[value] !== undefined ) {
442
- found = object[value];
443
- return false;
444
- }
445
- else {
446
- return false;
447
- }
448
- });
449
- }
450
- if ( isFunction( found ) ) {
451
- response = found.apply(context, passedArguments);
452
- }
453
- else if(found !== undefined) {
454
- response = found;
455
- }
456
- if(Array.isArray(returnedValue)) {
457
- returnedValue.push(response);
458
- }
459
- else if(returnedValue !== undefined) {
460
- returnedValue = [returnedValue, response];
461
- }
462
- else if(response !== undefined) {
463
- returnedValue = response;
464
- }
465
- return found;
466
- }
467
- };
468
- if(methodInvoked) {
469
- if(instance === undefined) {
470
- module.initialize();
471
- }
472
- module.invoke(query);
473
- }
474
- else {
475
- if(instance !== undefined) {
476
- instance.invoke('destroy');
477
- }
478
- module.initialize();
479
- }
480
- })
481
- ;
482
-
483
- return (returnedValue !== undefined)
484
- ? returnedValue
485
- : this
486
- ;
487
- };
488
-
489
- $.fn.rating.settings = {
490
-
491
- name : 'Rating',
492
- namespace : 'rating',
493
-
494
- icon : 'star',
495
-
496
- silent : false,
497
- debug : false,
498
- verbose : false,
499
- performance : true,
500
-
501
- initialRating : 0,
502
- interactive : true,
503
- maxRating : 4,
504
- clearable : 'auto',
505
-
506
- fireOnInit : false,
507
-
508
- onRate : function(rating){},
509
-
510
- error : {
511
- method : 'The method you called is not defined',
512
- noMaximum : 'No maximum rating specified. Cannot generate HTML automatically'
513
- },
514
-
515
-
516
- metadata: {
517
- rating : 'rating',
518
- maxRating : 'maxRating',
519
- icon : 'icon'
520
- },
521
-
522
- className : {
523
- active : 'active',
524
- disabled : 'disabled',
525
- selected : 'selected',
526
- loading : 'loading',
527
- partiallyActive : 'partial'
528
- },
529
-
530
- cssVars : {
531
- filledCustomPropName : '--full'
532
- },
533
-
534
- selector : {
535
- icon : '.icon'
536
- },
537
-
538
- templates: {
539
- deQuote: function(string, encode) {
540
- return String(string).replace(/"/g,encode ? "&quot;" : "");
541
- },
542
- icon: function(maxRating, iconClass) {
543
- var
544
- icon = 1,
545
- html = '',
546
- deQuote = $.fn.rating.settings.templates.deQuote
547
- ;
548
- while(icon <= maxRating) {
549
- html += '<i class="'+deQuote(iconClass)+' icon"></i>';
550
- icon++;
551
- }
552
- return html;
553
- }
554
- }
555
-
556
- };
557
540
 
558
- })( jQuery, window, document );
541
+ };
542
+ })(jQuery, window, document);