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