fomantic-ui 2.9.1-beta.2 → 2.9.1-beta.20
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.
- package/.eslintrc.js +110 -0
- package/.github/workflows/ci.yml +14 -4
- package/.stylelintrc.js +46 -0
- package/dist/components/accordion.css +19 -26
- package/dist/components/accordion.js +568 -595
- package/dist/components/accordion.min.css +1 -1
- package/dist/components/accordion.min.js +2 -2
- package/dist/components/ad.css +31 -41
- package/dist/components/ad.min.css +1 -1
- package/dist/components/api.js +1161 -1179
- package/dist/components/api.min.js +2 -2
- package/dist/components/breadcrumb.css +1 -1
- package/dist/components/breadcrumb.min.css +1 -1
- package/dist/components/button.css +71 -106
- package/dist/components/button.min.css +1 -1
- package/dist/components/calendar.css +18 -16
- package/dist/components/calendar.js +1895 -1809
- package/dist/components/calendar.min.css +2 -2
- package/dist/components/calendar.min.js +2 -2
- package/dist/components/card.css +83 -115
- package/dist/components/card.min.css +1 -1
- package/dist/components/checkbox.css +47 -64
- package/dist/components/checkbox.js +842 -841
- package/dist/components/checkbox.min.css +1 -1
- package/dist/components/checkbox.min.js +2 -2
- package/dist/components/comment.css +37 -51
- package/dist/components/comment.min.css +1 -1
- package/dist/components/container.css +6 -5
- package/dist/components/container.min.css +2 -2
- package/dist/components/dimmer.css +31 -41
- package/dist/components/dimmer.js +708 -737
- package/dist/components/dimmer.min.css +1 -1
- package/dist/components/dimmer.min.js +2 -2
- package/dist/components/divider.css +32 -44
- package/dist/components/divider.min.css +1 -1
- package/dist/components/dropdown.css +129 -166
- package/dist/components/dropdown.js +4161 -4234
- package/dist/components/dropdown.min.css +2 -2
- package/dist/components/dropdown.min.js +2 -2
- package/dist/components/embed.css +13 -19
- package/dist/components/embed.js +651 -675
- package/dist/components/embed.min.css +1 -1
- package/dist/components/embed.min.js +2 -2
- package/dist/components/emoji.css +7 -6
- package/dist/components/feed.css +24 -32
- package/dist/components/feed.min.css +1 -1
- package/dist/components/flag.css +5 -3
- package/dist/components/flag.min.css +1 -1
- package/dist/components/flyout.css +44 -58
- package/dist/components/flyout.js +1464 -1465
- package/dist/components/flyout.min.css +2 -2
- package/dist/components/flyout.min.js +2 -2
- package/dist/components/form.css +85 -111
- package/dist/components/form.js +1979 -2004
- package/dist/components/form.min.css +1 -1
- package/dist/components/form.min.js +2 -2
- package/dist/components/grid.css +70 -96
- package/dist/components/grid.min.css +1 -1
- package/dist/components/header.css +47 -65
- package/dist/components/header.min.css +1 -1
- package/dist/components/icon.css +45 -66
- package/dist/components/icon.min.css +2 -2
- package/dist/components/image.css +32 -42
- package/dist/components/image.min.css +1 -1
- package/dist/components/input.css +182 -65
- package/dist/components/input.min.css +2 -2
- package/dist/components/item.css +55 -77
- package/dist/components/item.min.css +1 -1
- package/dist/components/label.css +68 -91
- package/dist/components/label.min.css +2 -2
- package/dist/components/list.css +44 -59
- package/dist/components/list.min.css +1 -1
- package/dist/components/loader.css +16 -22
- package/dist/components/loader.min.css +1 -1
- package/dist/components/menu.css +126 -186
- package/dist/components/message.css +25 -35
- package/dist/components/message.min.css +1 -1
- package/dist/components/modal.css +39 -40
- package/dist/components/modal.js +1491 -1485
- package/dist/components/modal.min.css +2 -2
- package/dist/components/modal.min.js +2 -2
- package/dist/components/nag.css +21 -28
- package/dist/components/nag.js +518 -526
- package/dist/components/nag.min.css +2 -2
- package/dist/components/nag.min.js +2 -2
- package/dist/components/placeholder.css +10 -12
- package/dist/components/placeholder.min.css +1 -1
- package/dist/components/popup.css +352 -59
- package/dist/components/popup.js +1437 -1456
- package/dist/components/popup.min.css +2 -2
- package/dist/components/popup.min.js +2 -2
- package/dist/components/progress.css +29 -39
- package/dist/components/progress.js +969 -997
- package/dist/components/progress.min.css +1 -1
- package/dist/components/progress.min.js +2 -2
- package/dist/components/rail.css +15 -20
- package/dist/components/rail.min.css +1 -1
- package/dist/components/rating.css +9 -13
- package/dist/components/rating.js +505 -523
- package/dist/components/rating.min.css +1 -1
- package/dist/components/rating.min.js +2 -2
- package/dist/components/reset.css +1 -1
- package/dist/components/reset.min.css +1 -1
- package/dist/components/reveal.css +19 -26
- package/dist/components/reveal.min.css +1 -1
- package/dist/components/search.css +43 -58
- package/dist/components/search.js +1498 -1534
- package/dist/components/search.min.css +2 -2
- package/dist/components/search.min.js +2 -2
- package/dist/components/segment.css +64 -83
- package/dist/components/segment.min.css +2 -2
- package/dist/components/shape.css +10 -14
- package/dist/components/shape.js +792 -809
- package/dist/components/shape.min.css +1 -1
- package/dist/components/shape.min.js +2 -2
- package/dist/components/sidebar.css +43 -58
- package/dist/components/sidebar.js +1071 -1098
- package/dist/components/sidebar.min.css +2 -2
- package/dist/components/sidebar.min.js +2 -2
- package/dist/components/site.css +5 -5
- package/dist/components/site.js +462 -476
- package/dist/components/site.min.css +1 -1
- package/dist/components/site.min.js +2 -2
- package/dist/components/slider.css +27 -37
- package/dist/components/slider.js +1287 -1306
- package/dist/components/slider.min.js +2 -2
- package/dist/components/state.js +639 -657
- package/dist/components/state.min.js +2 -2
- package/dist/components/statistic.css +32 -41
- package/dist/components/statistic.min.css +2 -2
- package/dist/components/step.css +26 -35
- package/dist/components/step.min.css +1 -1
- package/dist/components/sticky.css +1 -1
- package/dist/components/sticky.js +857 -902
- package/dist/components/sticky.min.css +1 -1
- package/dist/components/sticky.min.js +2 -2
- package/dist/components/tab.css +6 -8
- package/dist/components/tab.js +922 -963
- package/dist/components/tab.min.css +1 -1
- package/dist/components/tab.min.js +2 -2
- package/dist/components/table.css +93 -119
- package/dist/components/table.min.css +2 -2
- package/dist/components/text.css +1 -1
- package/dist/components/text.min.css +1 -1
- package/dist/components/toast.css +4 -6
- package/dist/components/toast.js +886 -887
- package/dist/components/toast.min.css +1 -1
- package/dist/components/toast.min.js +2 -2
- package/dist/components/transition.css +150 -3
- package/dist/components/transition.js +1041 -1077
- package/dist/components/transition.min.css +2 -2
- package/dist/components/transition.min.js +2 -2
- package/dist/components/visibility.js +1220 -1244
- package/dist/components/visibility.min.js +2 -2
- package/dist/semantic.css +2529 -1778
- package/dist/semantic.js +28928 -29383
- package/dist/semantic.min.css +2 -2
- package/dist/semantic.min.js +2 -2
- package/dist/themes/default/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/themes/default/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/themes/default/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
- package/dist/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
- package/examples/assets/show-examples.js +13 -13
- package/gulpfile.js +9 -10
- package/package.json +13 -8
- package/scripts/nightly-version.js +81 -75
- package/src/definitions/behaviors/api.js +1162 -1180
- package/src/definitions/behaviors/form.js +1978 -2003
- package/src/definitions/behaviors/state.js +645 -663
- package/src/definitions/behaviors/visibility.js +1219 -1243
- package/src/definitions/collections/breadcrumb.less +41 -44
- package/src/definitions/collections/form.less +869 -879
- package/src/definitions/collections/grid.less +1690 -1695
- package/src/definitions/collections/menu.less +1493 -1503
- package/src/definitions/collections/message.less +292 -295
- package/src/definitions/collections/table.less +1616 -1620
- package/src/definitions/elements/button.less +1721 -1743
- package/src/definitions/elements/container.less +209 -209
- package/src/definitions/elements/divider.less +205 -206
- package/src/definitions/elements/emoji.less +38 -44
- package/src/definitions/elements/flag.less +44 -46
- package/src/definitions/elements/header.less +337 -345
- package/src/definitions/elements/icon.less +516 -443
- package/src/definitions/elements/image.less +221 -225
- package/src/definitions/elements/input.less +663 -659
- package/src/definitions/elements/label.less +803 -793
- package/src/definitions/elements/list.less +809 -809
- package/src/definitions/elements/loader.less +272 -266
- package/src/definitions/elements/placeholder.less +171 -168
- package/src/definitions/elements/rail.less +91 -91
- package/src/definitions/elements/reveal.less +192 -196
- package/src/definitions/elements/segment.less +743 -746
- package/src/definitions/elements/step.less +425 -433
- package/src/definitions/elements/text.less +32 -34
- package/src/definitions/globals/reset.less +9 -6
- package/src/definitions/globals/site.js +461 -475
- package/src/definitions/globals/site.less +106 -108
- package/src/definitions/modules/accordion.js +567 -594
- package/src/definitions/modules/accordion.less +242 -246
- package/src/definitions/modules/calendar.js +1894 -1808
- package/src/definitions/modules/calendar.less +98 -95
- package/src/definitions/modules/checkbox.js +841 -840
- package/src/definitions/modules/checkbox.less +536 -542
- package/src/definitions/modules/dimmer.js +707 -736
- package/src/definitions/modules/dimmer.less +300 -297
- package/src/definitions/modules/dropdown.js +4160 -4233
- package/src/definitions/modules/dropdown.less +1577 -1589
- package/src/definitions/modules/embed.js +650 -674
- package/src/definitions/modules/embed.less +81 -82
- package/src/definitions/modules/flyout.js +1463 -1464
- package/src/definitions/modules/flyout.less +445 -451
- package/src/definitions/modules/modal.js +1490 -1484
- package/src/definitions/modules/modal.less +459 -459
- package/src/definitions/modules/nag.js +517 -525
- package/src/definitions/modules/nag.less +134 -138
- package/src/definitions/modules/popup.js +1436 -1455
- package/src/definitions/modules/popup.less +742 -687
- package/src/definitions/modules/progress.js +968 -996
- package/src/definitions/modules/progress.less +521 -494
- package/src/definitions/modules/rating.js +504 -522
- package/src/definitions/modules/rating.less +94 -101
- package/src/definitions/modules/search.js +1497 -1533
- package/src/definitions/modules/search.less +375 -382
- package/src/definitions/modules/shape.js +791 -808
- package/src/definitions/modules/shape.less +71 -76
- package/src/definitions/modules/sidebar.js +1070 -1097
- package/src/definitions/modules/sidebar.less +463 -472
- package/src/definitions/modules/slider.js +1286 -1305
- package/src/definitions/modules/slider.less +307 -308
- package/src/definitions/modules/sticky.js +873 -918
- package/src/definitions/modules/sticky.less +21 -23
- package/src/definitions/modules/tab.js +921 -962
- package/src/definitions/modules/tab.less +51 -52
- package/src/definitions/modules/toast.js +885 -886
- package/src/definitions/modules/toast.less +584 -586
- package/src/definitions/modules/transition.js +1040 -1076
- package/src/definitions/modules/transition.less +62 -28
- package/src/definitions/views/ad.less +206 -206
- package/src/definitions/views/card.less +968 -970
- package/src/definitions/views/comment.less +190 -198
- package/src/definitions/views/feed.less +220 -224
- package/src/definitions/views/item.less +436 -446
- package/src/definitions/views/statistic.less +271 -277
- package/src/theme.less +29 -32
- package/src/themes/default/assets/fonts/Lato-Bold.woff +0 -0
- package/src/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
- package/src/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/src/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/src/themes/default/assets/fonts/Lato-Italic.woff +0 -0
- package/src/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
- package/src/themes/default/assets/fonts/Lato-Regular.woff +0 -0
- package/src/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
- package/src/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
- package/src/themes/default/elements/container.variables +0 -7
- package/src/themes/default/elements/icon.variables +18 -0
- package/src/themes/default/elements/segment.variables +0 -7
- package/src/themes/default/globals/colors.less +589 -589
- package/src/themes/default/globals/site.variables +8 -0
- package/src/themes/default/globals/variation.variables +13 -1
- package/src/themes/default/modules/calendar.variables +2 -0
- package/src/themes/default/modules/nag.variables +1 -1
- package/src/themes/default/modules/popup.variables +2 -0
- package/src/themes/default/modules/transition.variables +8 -1
- package/tasks/admin/components/create.js +274 -276
- package/tasks/admin/components/init.js +123 -130
- package/tasks/admin/components/update.js +149 -157
- package/tasks/admin/distributions/create.js +184 -187
- package/tasks/admin/distributions/init.js +123 -130
- package/tasks/admin/distributions/update.js +145 -152
- package/tasks/admin/publish.js +5 -7
- package/tasks/admin/register.js +36 -38
- package/tasks/admin/release.js +8 -10
- package/tasks/build/assets.js +42 -39
- package/tasks/build/css.js +225 -216
- package/tasks/build/javascript.js +118 -113
- package/tasks/build.js +10 -10
- package/tasks/check-install.js +14 -16
- package/tasks/clean.js +5 -5
- package/tasks/collections/admin.js +34 -36
- package/tasks/collections/build.js +18 -20
- package/tasks/collections/docs.js +9 -11
- package/tasks/collections/install.js +9 -11
- package/tasks/collections/rtl.js +9 -11
- package/tasks/collections/various.js +8 -10
- package/tasks/config/admin/github.js +17 -17
- package/tasks/config/admin/oauth.example.js +4 -4
- package/tasks/config/admin/release.js +98 -98
- package/tasks/config/admin/templates/component-package.js +9 -10
- package/tasks/config/admin/templates/css-package.js +18 -20
- package/tasks/config/admin/templates/less-package.js +11 -13
- package/tasks/config/defaults.js +116 -114
- package/tasks/config/docs.js +23 -23
- package/tasks/config/npm/gulpfile.js +8 -9
- package/tasks/config/project/config.js +127 -134
- package/tasks/config/project/install.js +715 -713
- package/tasks/config/project/release.js +32 -38
- package/tasks/config/tasks.js +165 -156
- package/tasks/config/user.js +23 -26
- package/tasks/docs/build.js +97 -95
- package/tasks/docs/metadata.js +90 -96
- package/tasks/docs/serve.js +80 -81
- package/tasks/install.js +370 -378
- package/tasks/rtl/build.js +2 -2
- package/tasks/rtl/watch.js +2 -2
- package/tasks/version.js +4 -4
- package/tasks/watch.js +28 -30
- package/test/meteor/assets.js +10 -13
- package/test/meteor/fonts.js +12 -13
- package/test/modules/accordion.spec.js +6 -8
- package/test/modules/checkbox.spec.js +5 -7
- package/test/modules/dropdown.spec.js +5 -7
- package/test/modules/modal.spec.js +6 -8
- package/test/modules/module.spec.js +158 -178
- package/test/modules/popup.spec.js +5 -7
- package/test/modules/search.spec.js +5 -7
- package/test/modules/shape.spec.js +5 -7
- package/test/modules/sidebar.spec.js +5 -7
- package/test/modules/tab.spec.js +6 -8
- package/test/modules/transition.spec.js +5 -7
- package/test/modules/video.spec.js +5 -7
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* # Fomantic-UI 2.9.1-beta.
|
2
|
+
* # Fomantic-UI 2.9.1-beta.20+d4987bf - Rating
|
3
3
|
* https://github.com/fomantic/Fomantic-UI/
|
4
4
|
*
|
5
5
|
*
|
@@ -8,551 +8,533 @@
|
|
8
8
|
*
|
9
9
|
*/
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
'use strict';
|
14
|
-
|
15
|
-
$.isFunction = $.isFunction || function(obj) {
|
16
|
-
return typeof obj === "function" && typeof obj.nodeType !== "number";
|
17
|
-
};
|
18
|
-
|
19
|
-
window = (typeof window != 'undefined' && window.Math == Math)
|
20
|
-
? window
|
21
|
-
: (typeof self != 'undefined' && self.Math == Math)
|
22
|
-
? self
|
23
|
-
: Function('return this')()
|
24
|
-
;
|
25
|
-
|
26
|
-
$.fn.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
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
$module
|
98
|
-
.removeData(moduleNamespace)
|
99
|
-
;
|
100
|
-
},
|
18
|
+
window = (typeof window != 'undefined' && window.Math == Math)
|
19
|
+
? window
|
20
|
+
: globalThis;
|
101
21
|
|
102
|
-
|
103
|
-
|
104
|
-
|
22
|
+
$.fn.rating = function (parameters) {
|
23
|
+
var
|
24
|
+
$allModules = $(this),
|
25
|
+
moduleSelector = $allModules.selector || '',
|
105
26
|
|
106
|
-
|
107
|
-
|
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
|
-
},
|
27
|
+
time = new Date().getTime(),
|
28
|
+
performance = [],
|
120
29
|
|
121
|
-
|
122
|
-
|
30
|
+
query = arguments[0],
|
31
|
+
methodInvoked = (typeof query == 'string'),
|
32
|
+
queryArguments = [].slice.call(arguments, 1),
|
33
|
+
returnedValue
|
34
|
+
;
|
35
|
+
$allModules.each(function () {
|
123
36
|
var
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
.
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
37
|
+
settings = ($.isPlainObject(parameters))
|
38
|
+
? $.extend(true, {}, $.fn.rating.settings, parameters)
|
39
|
+
: $.extend({}, $.fn.rating.settings),
|
40
|
+
|
41
|
+
namespace = settings.namespace,
|
42
|
+
className = settings.className,
|
43
|
+
metadata = settings.metadata,
|
44
|
+
selector = settings.selector,
|
45
|
+
cssVars = settings.cssVars,
|
46
|
+
|
47
|
+
eventNamespace = '.' + namespace,
|
48
|
+
moduleNamespace = 'module-' + namespace,
|
49
|
+
|
50
|
+
element = this,
|
51
|
+
instance = $(this).data(moduleNamespace),
|
52
|
+
|
53
|
+
$module = $(this),
|
54
|
+
$icon = $module.find(selector.icon),
|
55
|
+
|
56
|
+
initialLoad,
|
57
|
+
module
|
155
58
|
;
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
59
|
+
|
60
|
+
module = {
|
61
|
+
|
62
|
+
initialize: function () {
|
63
|
+
module.verbose('Initializing rating module', settings);
|
64
|
+
|
65
|
+
if ($icon.length === 0) {
|
66
|
+
module.setup.layout();
|
67
|
+
}
|
68
|
+
|
69
|
+
if (settings.interactive && !module.is.disabled()) {
|
70
|
+
module.enable();
|
71
|
+
} else {
|
72
|
+
module.disable();
|
73
|
+
}
|
74
|
+
module.set.initialLoad();
|
75
|
+
module.set.rating(module.get.initialRating());
|
76
|
+
module.remove.initialLoad();
|
77
|
+
module.instantiate();
|
78
|
+
},
|
79
|
+
|
80
|
+
instantiate: function () {
|
81
|
+
module.verbose('Instantiating module', settings);
|
82
|
+
instance = module;
|
83
|
+
$module
|
84
|
+
.data(moduleNamespace, module)
|
85
|
+
;
|
86
|
+
},
|
87
|
+
|
88
|
+
destroy: function () {
|
89
|
+
module.verbose('Destroying previous instance', instance);
|
90
|
+
module.remove.events();
|
91
|
+
$module
|
92
|
+
.removeData(moduleNamespace)
|
93
|
+
;
|
94
|
+
},
|
95
|
+
|
96
|
+
refresh: function () {
|
97
|
+
$icon = $module.find(selector.icon);
|
98
|
+
},
|
99
|
+
|
100
|
+
setup: {
|
101
|
+
layout: function () {
|
102
|
+
var
|
103
|
+
maxRating = module.get.maxRating(),
|
104
|
+
icon = module.get.icon(),
|
105
|
+
html = $.fn.rating.settings.templates.icon(maxRating, icon)
|
106
|
+
;
|
107
|
+
module.debug('Generating icon html dynamically');
|
108
|
+
$module
|
109
|
+
.html(html)
|
110
|
+
;
|
111
|
+
module.refresh();
|
112
|
+
},
|
113
|
+
},
|
114
|
+
|
115
|
+
event: {
|
116
|
+
mouseenter: function () {
|
117
|
+
var
|
118
|
+
$activeIcon = $(this)
|
119
|
+
;
|
120
|
+
$activeIcon
|
121
|
+
.nextAll()
|
122
|
+
.removeClass(className.selected)
|
123
|
+
;
|
124
|
+
$module
|
125
|
+
.addClass(className.selected)
|
126
|
+
;
|
127
|
+
$activeIcon
|
128
|
+
.addClass(className.selected)
|
129
|
+
.prevAll()
|
130
|
+
.addClass(className.selected)
|
131
|
+
;
|
132
|
+
},
|
133
|
+
mouseleave: function () {
|
134
|
+
$module
|
135
|
+
.removeClass(className.selected)
|
136
|
+
;
|
137
|
+
$icon
|
138
|
+
.removeClass(className.selected)
|
139
|
+
;
|
140
|
+
},
|
141
|
+
click: function () {
|
142
|
+
var
|
143
|
+
$activeIcon = $(this),
|
144
|
+
currentRating = module.get.rating(),
|
145
|
+
rating = $icon.index($activeIcon) + 1,
|
146
|
+
canClear = (settings.clearable == 'auto')
|
147
|
+
? ($icon.length === 1)
|
148
|
+
: settings.clearable
|
149
|
+
;
|
150
|
+
if (canClear && currentRating == rating) {
|
151
|
+
module.clearRating();
|
152
|
+
} else {
|
153
|
+
module.set.rating(rating);
|
154
|
+
}
|
155
|
+
},
|
156
|
+
},
|
157
|
+
|
158
|
+
clearRating: function () {
|
159
|
+
module.debug('Clearing current rating');
|
160
|
+
module.set.rating(0);
|
161
|
+
},
|
162
|
+
|
163
|
+
bind: {
|
164
|
+
events: function () {
|
165
|
+
module.verbose('Binding events');
|
166
|
+
$module
|
167
|
+
.on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter)
|
168
|
+
.on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave)
|
169
|
+
.on('click' + eventNamespace, selector.icon, module.event.click)
|
170
|
+
;
|
171
|
+
},
|
172
|
+
},
|
173
|
+
|
174
|
+
remove: {
|
175
|
+
events: function () {
|
176
|
+
module.verbose('Removing events');
|
177
|
+
$module
|
178
|
+
.off(eventNamespace)
|
179
|
+
;
|
180
|
+
},
|
181
|
+
initialLoad: function () {
|
182
|
+
initialLoad = false;
|
183
|
+
},
|
184
|
+
},
|
185
|
+
|
186
|
+
enable: function () {
|
187
|
+
module.debug('Setting rating to interactive mode');
|
188
|
+
module.bind.events();
|
189
|
+
$module
|
190
|
+
.removeClass(className.disabled)
|
191
|
+
;
|
192
|
+
},
|
193
|
+
|
194
|
+
disable: function () {
|
195
|
+
module.debug('Setting rating to read-only mode');
|
196
|
+
module.remove.events();
|
197
|
+
$module
|
198
|
+
.addClass(className.disabled)
|
199
|
+
;
|
200
|
+
},
|
201
|
+
|
202
|
+
is: {
|
203
|
+
initialLoad: function () {
|
204
|
+
return initialLoad;
|
205
|
+
},
|
206
|
+
disabled: function () {
|
207
|
+
return $module.hasClass(className.disabled);
|
208
|
+
},
|
209
|
+
},
|
210
|
+
|
211
|
+
get: {
|
212
|
+
icon: function () {
|
213
|
+
var icon = $module.data(metadata.icon);
|
214
|
+
if (icon) {
|
215
|
+
$module.removeData(metadata.icon);
|
216
|
+
}
|
217
|
+
|
218
|
+
return icon || settings.icon;
|
219
|
+
},
|
220
|
+
initialRating: function () {
|
221
|
+
if ($module.data(metadata.rating) !== undefined) {
|
222
|
+
$module.removeData(metadata.rating);
|
223
|
+
|
224
|
+
return $module.data(metadata.rating);
|
225
|
+
}
|
226
|
+
|
227
|
+
return settings.initialRating;
|
228
|
+
},
|
229
|
+
maxRating: function () {
|
230
|
+
if ($module.data(metadata.maxRating) !== undefined) {
|
231
|
+
$module.removeData(metadata.maxRating);
|
232
|
+
|
233
|
+
return $module.data(metadata.maxRating);
|
234
|
+
}
|
235
|
+
|
236
|
+
return settings.maxRating;
|
237
|
+
},
|
238
|
+
rating: function () {
|
239
|
+
var
|
240
|
+
currentRating = $icon.filter('.' + className.active).length
|
241
|
+
;
|
242
|
+
module.verbose('Current rating retrieved', currentRating);
|
243
|
+
|
244
|
+
return currentRating;
|
245
|
+
},
|
246
|
+
},
|
247
|
+
|
248
|
+
set: {
|
249
|
+
rating: function (rating) {
|
250
|
+
var
|
251
|
+
ratingIndex = Math.floor(
|
252
|
+
(rating - 1 >= 0)
|
253
|
+
? (rating - 1)
|
254
|
+
: 0
|
255
|
+
),
|
256
|
+
$activeIcon = $icon.eq(ratingIndex),
|
257
|
+
$partialActiveIcon = rating <= 1
|
258
|
+
? $activeIcon
|
259
|
+
: $activeIcon.next(),
|
260
|
+
filledPercentage = (rating % 1) * 100
|
261
|
+
;
|
262
|
+
$module
|
263
|
+
.removeClass(className.selected)
|
264
|
+
;
|
265
|
+
$icon
|
266
|
+
.removeClass(className.selected)
|
267
|
+
.removeClass(className.active)
|
268
|
+
.removeClass(className.partiallyActive)
|
269
|
+
;
|
270
|
+
if (rating > 0) {
|
271
|
+
module.verbose('Setting current rating to', rating);
|
272
|
+
$activeIcon
|
273
|
+
.prevAll()
|
274
|
+
.addBack()
|
275
|
+
.addClass(className.active)
|
276
|
+
;
|
277
|
+
if ($activeIcon.next() && rating % 1 !== 0) {
|
278
|
+
$partialActiveIcon
|
279
|
+
.addClass(className.partiallyActive)
|
280
|
+
.addClass(className.active)
|
281
|
+
;
|
282
|
+
$partialActiveIcon
|
283
|
+
.css(cssVars.filledCustomPropName, filledPercentage + '%')
|
284
|
+
;
|
285
|
+
if ($partialActiveIcon.css('backgroundColor') === 'transparent') {
|
286
|
+
$partialActiveIcon
|
287
|
+
.removeClass(className.partiallyActive)
|
288
|
+
.removeClass(className.active)
|
289
|
+
;
|
290
|
+
}
|
291
|
+
}
|
292
|
+
}
|
293
|
+
if (!module.is.initialLoad()) {
|
294
|
+
settings.onRate.call(element, rating);
|
295
|
+
}
|
296
|
+
},
|
297
|
+
initialLoad: function () {
|
298
|
+
initialLoad = true;
|
299
|
+
},
|
300
|
+
},
|
301
|
+
|
302
|
+
setting: function (name, value) {
|
303
|
+
module.debug('Changing setting', name, value);
|
304
|
+
if ($.isPlainObject(name)) {
|
305
|
+
$.extend(true, settings, name);
|
306
|
+
} else if (value !== undefined) {
|
307
|
+
if ($.isPlainObject(settings[name])) {
|
308
|
+
$.extend(true, settings[name], value);
|
309
|
+
} else {
|
310
|
+
settings[name] = value;
|
311
|
+
}
|
312
|
+
} else {
|
313
|
+
return settings[name];
|
314
|
+
}
|
315
|
+
},
|
316
|
+
internal: function (name, value) {
|
317
|
+
if ($.isPlainObject(name)) {
|
318
|
+
$.extend(true, module, name);
|
319
|
+
} else if (value !== undefined) {
|
320
|
+
module[name] = value;
|
321
|
+
} else {
|
322
|
+
return module[name];
|
323
|
+
}
|
324
|
+
},
|
325
|
+
debug: function () {
|
326
|
+
if (!settings.silent && settings.debug) {
|
327
|
+
if (settings.performance) {
|
328
|
+
module.performance.log(arguments);
|
329
|
+
} else {
|
330
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
331
|
+
module.debug.apply(console, arguments);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
},
|
335
|
+
verbose: function () {
|
336
|
+
if (!settings.silent && settings.verbose && settings.debug) {
|
337
|
+
if (settings.performance) {
|
338
|
+
module.performance.log(arguments);
|
339
|
+
} else {
|
340
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
341
|
+
module.verbose.apply(console, arguments);
|
342
|
+
}
|
343
|
+
}
|
344
|
+
},
|
345
|
+
error: function () {
|
346
|
+
if (!settings.silent) {
|
347
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
348
|
+
module.error.apply(console, arguments);
|
349
|
+
}
|
350
|
+
},
|
351
|
+
performance: {
|
352
|
+
log: function (message) {
|
353
|
+
var
|
354
|
+
currentTime,
|
355
|
+
executionTime,
|
356
|
+
previousTime
|
357
|
+
;
|
358
|
+
if (settings.performance) {
|
359
|
+
currentTime = new Date().getTime();
|
360
|
+
previousTime = time || currentTime;
|
361
|
+
executionTime = currentTime - previousTime;
|
362
|
+
time = currentTime;
|
363
|
+
performance.push({
|
364
|
+
Name: message[0],
|
365
|
+
Arguments: [].slice.call(message, 1) || '',
|
366
|
+
Element: element,
|
367
|
+
'Execution Time': executionTime,
|
368
|
+
});
|
369
|
+
}
|
370
|
+
clearTimeout(module.performance.timer);
|
371
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
372
|
+
},
|
373
|
+
display: function () {
|
374
|
+
var
|
375
|
+
title = settings.name + ':',
|
376
|
+
totalTime = 0
|
377
|
+
;
|
378
|
+
time = false;
|
379
|
+
clearTimeout(module.performance.timer);
|
380
|
+
$.each(performance, function (index, data) {
|
381
|
+
totalTime += data['Execution Time'];
|
382
|
+
});
|
383
|
+
title += ' ' + totalTime + 'ms';
|
384
|
+
if (moduleSelector) {
|
385
|
+
title += ' \'' + moduleSelector + '\'';
|
386
|
+
}
|
387
|
+
if ($allModules.length > 1) {
|
388
|
+
title += ' ' + '(' + $allModules.length + ')';
|
389
|
+
}
|
390
|
+
if ((console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
391
|
+
console.groupCollapsed(title);
|
392
|
+
if (console.table) {
|
393
|
+
console.table(performance);
|
394
|
+
} else {
|
395
|
+
$.each(performance, function (index, data) {
|
396
|
+
console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
|
397
|
+
});
|
398
|
+
}
|
399
|
+
console.groupEnd();
|
400
|
+
}
|
401
|
+
performance = [];
|
402
|
+
},
|
403
|
+
},
|
404
|
+
invoke: function (query, passedArguments, context) {
|
405
|
+
var
|
406
|
+
object = instance,
|
407
|
+
maxDepth,
|
408
|
+
found,
|
409
|
+
response
|
410
|
+
;
|
411
|
+
passedArguments = passedArguments || queryArguments;
|
412
|
+
context = context || element;
|
413
|
+
if (typeof query == 'string' && object !== undefined) {
|
414
|
+
query = query.split(/[\. ]/);
|
415
|
+
maxDepth = query.length - 1;
|
416
|
+
$.each(query, function (depth, value) {
|
417
|
+
var camelCaseValue = (depth != maxDepth)
|
418
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
419
|
+
: query
|
420
|
+
;
|
421
|
+
if ($.isPlainObject(object[camelCaseValue]) && (depth != maxDepth)) {
|
422
|
+
object = object[camelCaseValue];
|
423
|
+
} else if (object[camelCaseValue] !== undefined) {
|
424
|
+
found = object[camelCaseValue];
|
425
|
+
|
426
|
+
return false;
|
427
|
+
} else if ($.isPlainObject(object[value]) && (depth != maxDepth)) {
|
428
|
+
object = object[value];
|
429
|
+
} else if (object[value] !== undefined) {
|
430
|
+
found = object[value];
|
431
|
+
|
432
|
+
return false;
|
433
|
+
} else {
|
434
|
+
return false;
|
435
|
+
}
|
436
|
+
});
|
437
|
+
}
|
438
|
+
if (isFunction(found)) {
|
439
|
+
response = found.apply(context, passedArguments);
|
440
|
+
} else if (found !== undefined) {
|
441
|
+
response = found;
|
442
|
+
}
|
443
|
+
if (Array.isArray(returnedValue)) {
|
444
|
+
returnedValue.push(response);
|
445
|
+
} else if (returnedValue !== undefined) {
|
446
|
+
returnedValue = [returnedValue, response];
|
447
|
+
} else if (response !== undefined) {
|
448
|
+
returnedValue = response;
|
449
|
+
}
|
450
|
+
|
451
|
+
return found;
|
452
|
+
},
|
453
|
+
};
|
454
|
+
if (methodInvoked) {
|
455
|
+
if (instance === undefined) {
|
456
|
+
module.initialize();
|
457
|
+
}
|
458
|
+
module.invoke(query);
|
459
|
+
} else {
|
460
|
+
if (instance !== undefined) {
|
461
|
+
instance.invoke('destroy');
|
462
|
+
}
|
463
|
+
module.initialize();
|
161
464
|
}
|
162
|
-
|
163
|
-
},
|
465
|
+
});
|
164
466
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
467
|
+
return (returnedValue !== undefined)
|
468
|
+
? returnedValue
|
469
|
+
: this;
|
470
|
+
};
|
169
471
|
|
170
|
-
|
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
|
-
},
|
472
|
+
$.fn.rating.settings = {
|
180
473
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
474
|
+
name: 'Rating',
|
475
|
+
namespace: 'rating',
|
476
|
+
|
477
|
+
icon: 'star',
|
478
|
+
|
479
|
+
silent: false,
|
480
|
+
debug: false,
|
481
|
+
verbose: false,
|
482
|
+
performance: true,
|
483
|
+
|
484
|
+
initialRating: 0,
|
485
|
+
interactive: true,
|
486
|
+
maxRating: 4,
|
487
|
+
clearable: 'auto',
|
488
|
+
|
489
|
+
fireOnInit: false,
|
490
|
+
|
491
|
+
onRate: function (rating) {},
|
492
|
+
|
493
|
+
error: {
|
494
|
+
method: 'The method you called is not defined',
|
495
|
+
noMaximum: 'No maximum rating specified. Cannot generate HTML automatically',
|
191
496
|
},
|
192
497
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
.removeClass(className.disabled)
|
198
|
-
;
|
498
|
+
metadata: {
|
499
|
+
rating: 'rating',
|
500
|
+
maxRating: 'maxRating',
|
501
|
+
icon: 'icon',
|
199
502
|
},
|
200
503
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
504
|
+
className: {
|
505
|
+
active: 'active',
|
506
|
+
disabled: 'disabled',
|
507
|
+
selected: 'selected',
|
508
|
+
loading: 'loading',
|
509
|
+
partiallyActive: 'partial',
|
207
510
|
},
|
208
511
|
|
209
|
-
|
210
|
-
|
211
|
-
return initialLoad;
|
212
|
-
},
|
213
|
-
disabled: function() {
|
214
|
-
return $module.hasClass(className.disabled);
|
215
|
-
}
|
512
|
+
cssVars: {
|
513
|
+
filledCustomPropName: '--full',
|
216
514
|
},
|
217
515
|
|
218
|
-
|
219
|
-
|
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
|
-
}
|
516
|
+
selector: {
|
517
|
+
icon: '.icon',
|
247
518
|
},
|
248
519
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
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)
|
283
|
-
;
|
284
|
-
$partialActiveIcon
|
285
|
-
.css(cssVars.filledCustomPropName, filledPercentage + '%')
|
520
|
+
templates: {
|
521
|
+
deQuote: function (string, encode) {
|
522
|
+
return String(string).replace(/"/g, encode ? '"' : '');
|
523
|
+
},
|
524
|
+
icon: function (maxRating, iconClass) {
|
525
|
+
var
|
526
|
+
icon = 1,
|
527
|
+
html = '',
|
528
|
+
deQuote = $.fn.rating.settings.templates.deQuote
|
286
529
|
;
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
.removeClass(className.active)
|
291
|
-
;
|
530
|
+
while (icon <= maxRating) {
|
531
|
+
html += '<i class="' + deQuote(iconClass) + ' icon"></i>';
|
532
|
+
icon++;
|
292
533
|
}
|
293
|
-
}
|
294
|
-
}
|
295
|
-
if(!module.is.initialLoad()) {
|
296
|
-
settings.onRate.call(element, rating);
|
297
|
-
}
|
298
|
-
},
|
299
|
-
initialLoad: function() {
|
300
|
-
initialLoad = true;
|
301
|
-
}
|
302
|
-
},
|
303
534
|
|
304
|
-
|
305
|
-
|
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
|
-
}
|
535
|
+
return html;
|
536
|
+
},
|
320
537
|
},
|
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
|
-
}
|
353
|
-
},
|
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 ? """ : "");
|
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
538
|
|
558
|
-
}
|
539
|
+
};
|
540
|
+
})(jQuery, window, document);
|