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