semantic-ui-sass 0.19.3.1 → 1.7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +5 -6
- data/app/assets/fonts/semantic-ui/icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/icons.otf +0 -0
- data/app/assets/fonts/semantic-ui/icons.svg +472 -367
- data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/icons.woff +0 -0
- data/app/assets/images/semantic-ui/flags.png +0 -0
- data/app/assets/javascripts/semantic-ui.js +9 -5
- data/app/assets/javascripts/semantic-ui/accordion.js +169 -102
- data/app/assets/javascripts/semantic-ui/api.js +840 -0
- data/app/assets/javascripts/semantic-ui/checkbox.js +203 -46
- data/app/assets/javascripts/semantic-ui/{behavior/colorize.js → colorize.js} +4 -2
- data/app/assets/javascripts/semantic-ui/dimmer.js +110 -76
- data/app/assets/javascripts/semantic-ui/dropdown.js +897 -285
- data/app/assets/javascripts/semantic-ui/{behavior/form.js → form.js} +127 -42
- data/app/assets/javascripts/semantic-ui/modal.js +294 -219
- data/app/assets/javascripts/semantic-ui/nag.js +120 -186
- data/app/assets/javascripts/semantic-ui/popup.js +491 -223
- data/app/assets/javascripts/semantic-ui/progress.js +779 -0
- data/app/assets/javascripts/semantic-ui/rating.js +66 -22
- data/app/assets/javascripts/semantic-ui/search.js +219 -99
- data/app/assets/javascripts/semantic-ui/shape.js +72 -29
- data/app/assets/javascripts/semantic-ui/sidebar.js +678 -142
- data/app/assets/javascripts/semantic-ui/site.js +487 -0
- data/app/assets/javascripts/semantic-ui/{behavior/state.js → state.js} +116 -151
- data/app/assets/javascripts/semantic-ui/sticky.js +771 -0
- data/app/assets/javascripts/semantic-ui/tab.js +680 -603
- data/app/assets/javascripts/semantic-ui/transition.js +269 -158
- data/app/assets/javascripts/semantic-ui/video.js +113 -32
- data/app/assets/javascripts/semantic-ui/visibility.js +970 -0
- data/app/assets/javascripts/semantic-ui/visit.js +513 -0
- data/app/assets/stylesheets/semantic-ui.scss +2 -0
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +58 -14
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +464 -372
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +1385 -533
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +482 -655
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +238 -139
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +631 -280
- data/app/assets/stylesheets/semantic-ui/elements/_all.scss +3 -2
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +1614 -657
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +143 -80
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1018 -0
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +302 -145
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +1653 -1365
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +160 -59
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +247 -118
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +501 -470
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +888 -0
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +189 -98
- data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +125 -0
- data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +147 -212
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +328 -190
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +261 -185
- data/app/assets/stylesheets/semantic-ui/globals/_all.scss +2 -0
- data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +430 -0
- data/app/assets/stylesheets/semantic-ui/globals/_site.scss +128 -0
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +190 -106
- data/app/assets/stylesheets/semantic-ui/modules/_all.scss +2 -1
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +303 -201
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +72 -63
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +711 -331
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +262 -140
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +82 -71
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +163 -119
- data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +435 -0
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +163 -68
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +223 -150
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +39 -40
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +413 -147
- data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +80 -0
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +49 -20
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +542 -568
- data/app/assets/stylesheets/semantic-ui/modules/_video.scss +69 -37
- data/app/assets/stylesheets/semantic-ui/views/_ad.scss +265 -0
- data/app/assets/stylesheets/semantic-ui/views/_all.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_card.scss +758 -0
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +133 -92
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +200 -87
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +298 -523
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +390 -12
- data/lib/semantic/ui/sass/version.rb +2 -2
- data/tasks/converter.rb +99 -216
- metadata +22 -27
- data/app/assets/fonts/semantic-ui/basic.icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/basic.icons.svg +0 -450
- data/app/assets/fonts/semantic-ui/basic.icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/basic.icons.woff +0 -0
- data/app/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-large.gif +0 -0
- data/app/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-medium.gif +0 -0
- data/app/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-mini.gif +0 -0
- data/app/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-small.gif +0 -0
- data/app/assets/javascripts/semantic-ui/behavior/api.js +0 -634
- data/app/assets/javascripts/semantic-ui/chatroom.js +0 -772
- data/app/assets/stylesheets/semantic-ui/depends/_basic.icon.scss +0 -4
- data/app/assets/stylesheets/semantic-ui/depends/_icon.scss +0 -4
- data/app/assets/stylesheets/semantic-ui/depends/_loader.scss +0 -8
- data/app/assets/stylesheets/semantic-ui/elements/_basic.icon.scss +0 -1124
- data/app/assets/stylesheets/semantic-ui/elements/_progress.scss +0 -280
- data/app/assets/stylesheets/semantic-ui/modules/_chatroom.scss +0 -299
- data/app/assets/stylesheets/semantic-ui/modules/_reveal.scss +0 -322
- data/app/assets/stylesheets/semantic-ui/views/_list.scss +0 -700
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,634 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* # Semantic - API
|
3
|
-
* http://github.com/jlukic/semantic-ui/
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* Copyright 2014 Contributors
|
7
|
-
* Released under the MIT license
|
8
|
-
* http://opensource.org/licenses/MIT
|
9
|
-
*
|
10
|
-
*/
|
11
|
-
|
12
|
-
;(function ( $, window, document, undefined ) {
|
13
|
-
|
14
|
-
$.api = $.fn.api = function(parameters) {
|
15
|
-
|
16
|
-
var
|
17
|
-
settings = $.extend(true, {}, $.api.settings, parameters),
|
18
|
-
|
19
|
-
// if this keyword isn't a jQuery object, create one
|
20
|
-
context = (typeof this != 'function')
|
21
|
-
? this
|
22
|
-
: $('<div/>'),
|
23
|
-
// context defines the element used for loading/error state
|
24
|
-
$context = (settings.stateContext)
|
25
|
-
? $(settings.stateContext)
|
26
|
-
: $(context),
|
27
|
-
// module is the thing that initiates the api action, can be independent of context
|
28
|
-
$module = typeof this == 'object'
|
29
|
-
? $(context)
|
30
|
-
: $context,
|
31
|
-
|
32
|
-
element = this,
|
33
|
-
time = new Date().getTime(),
|
34
|
-
performance = [],
|
35
|
-
|
36
|
-
moduleSelector = $module.selector || '',
|
37
|
-
moduleNamespace = settings.namespace + '-module',
|
38
|
-
|
39
|
-
className = settings.className,
|
40
|
-
metadata = settings.metadata,
|
41
|
-
error = settings.error,
|
42
|
-
|
43
|
-
instance = $module.data(moduleNamespace),
|
44
|
-
|
45
|
-
query = arguments[0],
|
46
|
-
methodInvoked = (instance !== undefined && typeof query == 'string'),
|
47
|
-
queryArguments = [].slice.call(arguments, 1),
|
48
|
-
|
49
|
-
module,
|
50
|
-
returnedValue
|
51
|
-
;
|
52
|
-
|
53
|
-
module = {
|
54
|
-
initialize: function() {
|
55
|
-
var
|
56
|
-
runSettings,
|
57
|
-
|
58
|
-
loadingTimer = new Date().getTime(),
|
59
|
-
loadingDelay,
|
60
|
-
|
61
|
-
promise,
|
62
|
-
url,
|
63
|
-
|
64
|
-
formData = {},
|
65
|
-
data,
|
66
|
-
|
67
|
-
ajaxSettings = {},
|
68
|
-
xhr
|
69
|
-
;
|
70
|
-
|
71
|
-
// serialize parent form if requested!
|
72
|
-
if(settings.serializeForm && $(this).toJSON() !== undefined) {
|
73
|
-
formData = module.get.formData();
|
74
|
-
module.debug('Adding form data to API Request', formData);
|
75
|
-
$.extend(true, settings.data, formData);
|
76
|
-
}
|
77
|
-
|
78
|
-
// let beforeSend change settings object
|
79
|
-
runSettings = $.proxy(settings.beforeSend, $module)(settings);
|
80
|
-
|
81
|
-
// check for exit conditions
|
82
|
-
if(runSettings !== undefined && !runSettings) {
|
83
|
-
module.error(error.beforeSend);
|
84
|
-
module.reset();
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
|
88
|
-
// get real url from template
|
89
|
-
url = module.get.url( module.get.templateURL() );
|
90
|
-
|
91
|
-
// exit conditions reached from missing url parameters
|
92
|
-
if( !url ) {
|
93
|
-
module.error(error.missingURL);
|
94
|
-
module.reset();
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
|
98
|
-
// promise handles notification on api request, so loading min. delay can occur for all notifications
|
99
|
-
promise =
|
100
|
-
$.Deferred()
|
101
|
-
.always(function() {
|
102
|
-
if(settings.stateContext) {
|
103
|
-
$context
|
104
|
-
.removeClass(className.loading)
|
105
|
-
;
|
106
|
-
}
|
107
|
-
$.proxy(settings.complete, $module)();
|
108
|
-
})
|
109
|
-
.done(function(response) {
|
110
|
-
module.debug('API request successful');
|
111
|
-
// take a stab at finding success state if json
|
112
|
-
if(settings.dataType == 'json') {
|
113
|
-
if (response.error !== undefined) {
|
114
|
-
$.proxy(settings.failure, $context)(response.error, settings, $module);
|
115
|
-
}
|
116
|
-
else if ($.isArray(response.errors)) {
|
117
|
-
$.proxy(settings.failure, $context)(response.errors[0], settings, $module);
|
118
|
-
}
|
119
|
-
else {
|
120
|
-
$.proxy(settings.success, $context)(response, settings, $module);
|
121
|
-
}
|
122
|
-
}
|
123
|
-
// otherwise
|
124
|
-
else {
|
125
|
-
$.proxy(settings.success, $context)(response, settings, $module);
|
126
|
-
}
|
127
|
-
})
|
128
|
-
.fail(function(xhr, status, httpMessage) {
|
129
|
-
var
|
130
|
-
errorMessage = (settings.error[status] !== undefined)
|
131
|
-
? settings.error[status]
|
132
|
-
: httpMessage,
|
133
|
-
response
|
134
|
-
;
|
135
|
-
// let em know unless request aborted
|
136
|
-
if(xhr !== undefined) {
|
137
|
-
// readyState 4 = done, anything less is not really sent
|
138
|
-
if(xhr.readyState !== undefined && xhr.readyState == 4) {
|
139
|
-
|
140
|
-
// if http status code returned and json returned error, look for it
|
141
|
-
if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') {
|
142
|
-
module.error(error.statusMessage + httpMessage);
|
143
|
-
}
|
144
|
-
else {
|
145
|
-
if(status == 'error' && settings.dataType == 'json') {
|
146
|
-
try {
|
147
|
-
response = $.parseJSON(xhr.responseText);
|
148
|
-
if(response && response.error !== undefined) {
|
149
|
-
errorMessage = response.error;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
catch(error) {
|
153
|
-
module.error(error.JSONParse);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
}
|
157
|
-
$context
|
158
|
-
.removeClass(className.loading)
|
159
|
-
.addClass(className.error)
|
160
|
-
;
|
161
|
-
// show error state only for duration specified in settings
|
162
|
-
if(settings.errorLength > 0) {
|
163
|
-
setTimeout(function(){
|
164
|
-
$context
|
165
|
-
.removeClass(className.error)
|
166
|
-
;
|
167
|
-
}, settings.errorLength);
|
168
|
-
}
|
169
|
-
module.debug('API Request error:', errorMessage);
|
170
|
-
$.proxy(settings.failure, $context)(errorMessage, settings, this);
|
171
|
-
}
|
172
|
-
else {
|
173
|
-
module.debug('Request Aborted (Most likely caused by page change)');
|
174
|
-
}
|
175
|
-
}
|
176
|
-
})
|
177
|
-
;
|
178
|
-
|
179
|
-
// look for params in data
|
180
|
-
$.extend(true, ajaxSettings, settings, {
|
181
|
-
success : function(){},
|
182
|
-
failure : function(){},
|
183
|
-
complete : function(){},
|
184
|
-
type : settings.method || settings.type,
|
185
|
-
data : data,
|
186
|
-
url : url,
|
187
|
-
beforeSend : settings.beforeXHR
|
188
|
-
});
|
189
|
-
|
190
|
-
if(settings.stateContext) {
|
191
|
-
$context
|
192
|
-
.addClass(className.loading)
|
193
|
-
;
|
194
|
-
}
|
195
|
-
|
196
|
-
if(settings.progress) {
|
197
|
-
module.verbose('Adding progress events');
|
198
|
-
$.extend(true, ajaxSettings, {
|
199
|
-
xhr: function() {
|
200
|
-
var
|
201
|
-
xhr = new window.XMLHttpRequest()
|
202
|
-
;
|
203
|
-
xhr.upload.addEventListener('progress', function(event) {
|
204
|
-
var
|
205
|
-
percentComplete
|
206
|
-
;
|
207
|
-
if (event.lengthComputable) {
|
208
|
-
percentComplete = Math.round(event.loaded / event.total * 10000) / 100 + '%';
|
209
|
-
$.proxy(settings.progress, $context)(percentComplete, event);
|
210
|
-
}
|
211
|
-
}, false);
|
212
|
-
xhr.addEventListener('progress', function(event) {
|
213
|
-
var
|
214
|
-
percentComplete
|
215
|
-
;
|
216
|
-
if (event.lengthComputable) {
|
217
|
-
percentComplete = Math.round(event.loaded / event.total * 10000) / 100 + '%';
|
218
|
-
$.proxy(settings.progress, $context)(percentComplete, event);
|
219
|
-
}
|
220
|
-
}, false);
|
221
|
-
return xhr;
|
222
|
-
}
|
223
|
-
});
|
224
|
-
}
|
225
|
-
|
226
|
-
module.verbose('Creating AJAX request with settings: ', ajaxSettings);
|
227
|
-
xhr =
|
228
|
-
$.ajax(ajaxSettings)
|
229
|
-
.always(function() {
|
230
|
-
// calculate if loading time was below minimum threshold
|
231
|
-
loadingDelay = ( settings.loadingLength - (new Date().getTime() - loadingTimer) );
|
232
|
-
settings.loadingDelay = loadingDelay < 0
|
233
|
-
? 0
|
234
|
-
: loadingDelay
|
235
|
-
;
|
236
|
-
})
|
237
|
-
.done(function(response) {
|
238
|
-
var
|
239
|
-
context = this
|
240
|
-
;
|
241
|
-
setTimeout(function(){
|
242
|
-
promise.resolveWith(context, [response]);
|
243
|
-
}, settings.loadingDelay);
|
244
|
-
})
|
245
|
-
.fail(function(xhr, status, httpMessage) {
|
246
|
-
var
|
247
|
-
context = this
|
248
|
-
;
|
249
|
-
// page triggers abort on navigation, dont show error
|
250
|
-
if(status != 'abort') {
|
251
|
-
setTimeout(function(){
|
252
|
-
promise.rejectWith(context, [xhr, status, httpMessage]);
|
253
|
-
}, settings.loadingDelay);
|
254
|
-
}
|
255
|
-
else {
|
256
|
-
$context
|
257
|
-
.removeClass(className.error)
|
258
|
-
.removeClass(className.loading)
|
259
|
-
;
|
260
|
-
}
|
261
|
-
})
|
262
|
-
;
|
263
|
-
if(settings.stateContext) {
|
264
|
-
$module
|
265
|
-
.data(metadata.promise, promise)
|
266
|
-
.data(metadata.xhr, xhr)
|
267
|
-
;
|
268
|
-
}
|
269
|
-
},
|
270
|
-
|
271
|
-
get: {
|
272
|
-
formData: function() {
|
273
|
-
return $module
|
274
|
-
.closest('form')
|
275
|
-
.toJSON()
|
276
|
-
;
|
277
|
-
},
|
278
|
-
templateURL: function() {
|
279
|
-
var
|
280
|
-
action = $module.data(settings.metadata.action) || settings.action || false,
|
281
|
-
url
|
282
|
-
;
|
283
|
-
if(action) {
|
284
|
-
module.debug('Creating url for: ', action);
|
285
|
-
if(settings.api[action] !== undefined) {
|
286
|
-
url = settings.api[action];
|
287
|
-
}
|
288
|
-
else {
|
289
|
-
module.error(error.missingAction);
|
290
|
-
}
|
291
|
-
}
|
292
|
-
// override with url if specified
|
293
|
-
if(settings.url) {
|
294
|
-
url = settings.url;
|
295
|
-
module.debug('Getting url', url);
|
296
|
-
}
|
297
|
-
return url;
|
298
|
-
},
|
299
|
-
url: function(url, urlData) {
|
300
|
-
var
|
301
|
-
urlVariables
|
302
|
-
;
|
303
|
-
if(url) {
|
304
|
-
urlVariables = url.match(settings.regExpTemplate);
|
305
|
-
urlData = urlData || settings.urlData;
|
306
|
-
|
307
|
-
if(urlVariables) {
|
308
|
-
module.debug('Looking for URL variables', urlVariables);
|
309
|
-
$.each(urlVariables, function(index, templateValue){
|
310
|
-
var
|
311
|
-
term = templateValue.substr( 2, templateValue.length - 3),
|
312
|
-
termValue = ($.isPlainObject(urlData) && urlData[term] !== undefined)
|
313
|
-
? urlData[term]
|
314
|
-
: ($module.data(term) !== undefined)
|
315
|
-
? $module.data(term)
|
316
|
-
: urlData[term]
|
317
|
-
;
|
318
|
-
module.verbose('Looking for variable', term, $module, $module.data(term), urlData[term]);
|
319
|
-
// remove optional value
|
320
|
-
if(termValue === false) {
|
321
|
-
module.debug('Removing variable from URL', urlVariables);
|
322
|
-
url = url.replace('/' + templateValue, '');
|
323
|
-
}
|
324
|
-
// undefined condition
|
325
|
-
else if(termValue === undefined || !termValue) {
|
326
|
-
module.error(error.missingParameter + term);
|
327
|
-
url = false;
|
328
|
-
return false;
|
329
|
-
}
|
330
|
-
else {
|
331
|
-
url = url.replace(templateValue, termValue);
|
332
|
-
}
|
333
|
-
});
|
334
|
-
}
|
335
|
-
}
|
336
|
-
return url;
|
337
|
-
}
|
338
|
-
},
|
339
|
-
|
340
|
-
// reset api request
|
341
|
-
reset: function() {
|
342
|
-
$module
|
343
|
-
.data(metadata.promise, false)
|
344
|
-
.data(metadata.xhr, false)
|
345
|
-
;
|
346
|
-
$context
|
347
|
-
.removeClass(className.error)
|
348
|
-
.removeClass(className.loading)
|
349
|
-
;
|
350
|
-
},
|
351
|
-
|
352
|
-
setting: function(name, value) {
|
353
|
-
if( $.isPlainObject(name) ) {
|
354
|
-
$.extend(true, settings, name);
|
355
|
-
}
|
356
|
-
else if(value !== undefined) {
|
357
|
-
settings[name] = value;
|
358
|
-
}
|
359
|
-
else {
|
360
|
-
return settings[name];
|
361
|
-
}
|
362
|
-
},
|
363
|
-
internal: function(name, value) {
|
364
|
-
if( $.isPlainObject(name) ) {
|
365
|
-
$.extend(true, module, name);
|
366
|
-
}
|
367
|
-
else if(value !== undefined) {
|
368
|
-
module[name] = value;
|
369
|
-
}
|
370
|
-
else {
|
371
|
-
return module[name];
|
372
|
-
}
|
373
|
-
},
|
374
|
-
debug: function() {
|
375
|
-
if(settings.debug) {
|
376
|
-
if(settings.performance) {
|
377
|
-
module.performance.log(arguments);
|
378
|
-
}
|
379
|
-
else {
|
380
|
-
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
381
|
-
module.debug.apply(console, arguments);
|
382
|
-
}
|
383
|
-
}
|
384
|
-
},
|
385
|
-
verbose: function() {
|
386
|
-
if(settings.verbose && settings.debug) {
|
387
|
-
if(settings.performance) {
|
388
|
-
module.performance.log(arguments);
|
389
|
-
}
|
390
|
-
else {
|
391
|
-
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
392
|
-
module.verbose.apply(console, arguments);
|
393
|
-
}
|
394
|
-
}
|
395
|
-
},
|
396
|
-
error: function() {
|
397
|
-
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
398
|
-
module.error.apply(console, arguments);
|
399
|
-
},
|
400
|
-
performance: {
|
401
|
-
log: function(message) {
|
402
|
-
var
|
403
|
-
currentTime,
|
404
|
-
executionTime,
|
405
|
-
previousTime
|
406
|
-
;
|
407
|
-
if(settings.performance) {
|
408
|
-
currentTime = new Date().getTime();
|
409
|
-
previousTime = time || currentTime;
|
410
|
-
executionTime = currentTime - previousTime;
|
411
|
-
time = currentTime;
|
412
|
-
performance.push({
|
413
|
-
'Element' : element,
|
414
|
-
'Name' : message[0],
|
415
|
-
'Arguments' : [].slice.call(message, 1) || '',
|
416
|
-
'Execution Time' : executionTime
|
417
|
-
});
|
418
|
-
}
|
419
|
-
clearTimeout(module.performance.timer);
|
420
|
-
module.performance.timer = setTimeout(module.performance.display, 100);
|
421
|
-
},
|
422
|
-
display: function() {
|
423
|
-
var
|
424
|
-
title = settings.name + ':',
|
425
|
-
totalTime = 0
|
426
|
-
;
|
427
|
-
time = false;
|
428
|
-
clearTimeout(module.performance.timer);
|
429
|
-
$.each(performance, function(index, data) {
|
430
|
-
totalTime += data['Execution Time'];
|
431
|
-
});
|
432
|
-
title += ' ' + totalTime + 'ms';
|
433
|
-
if(moduleSelector) {
|
434
|
-
title += ' \'' + moduleSelector + '\'';
|
435
|
-
}
|
436
|
-
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
437
|
-
console.groupCollapsed(title);
|
438
|
-
if(console.table) {
|
439
|
-
console.table(performance);
|
440
|
-
}
|
441
|
-
else {
|
442
|
-
$.each(performance, function(index, data) {
|
443
|
-
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
444
|
-
});
|
445
|
-
}
|
446
|
-
console.groupEnd();
|
447
|
-
}
|
448
|
-
performance = [];
|
449
|
-
}
|
450
|
-
},
|
451
|
-
invoke: function(query, passedArguments, context) {
|
452
|
-
var
|
453
|
-
object = instance,
|
454
|
-
maxDepth,
|
455
|
-
found,
|
456
|
-
response
|
457
|
-
;
|
458
|
-
passedArguments = passedArguments || queryArguments;
|
459
|
-
context = element || context;
|
460
|
-
if(typeof query == 'string' && object !== undefined) {
|
461
|
-
query = query.split(/[\. ]/);
|
462
|
-
maxDepth = query.length - 1;
|
463
|
-
$.each(query, function(depth, value) {
|
464
|
-
var camelCaseValue = (depth != maxDepth)
|
465
|
-
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
466
|
-
: query
|
467
|
-
;
|
468
|
-
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
469
|
-
object = object[camelCaseValue];
|
470
|
-
}
|
471
|
-
else if( object[camelCaseValue] !== undefined ) {
|
472
|
-
found = object[camelCaseValue];
|
473
|
-
return false;
|
474
|
-
}
|
475
|
-
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
476
|
-
object = object[value];
|
477
|
-
}
|
478
|
-
else if( object[value] !== undefined ) {
|
479
|
-
found = object[value];
|
480
|
-
return false;
|
481
|
-
}
|
482
|
-
else {
|
483
|
-
return false;
|
484
|
-
}
|
485
|
-
});
|
486
|
-
}
|
487
|
-
if ( $.isFunction( found ) ) {
|
488
|
-
response = found.apply(context, passedArguments);
|
489
|
-
}
|
490
|
-
else if(found !== undefined) {
|
491
|
-
response = found;
|
492
|
-
}
|
493
|
-
if($.isArray(returnedValue)) {
|
494
|
-
returnedValue.push(response);
|
495
|
-
}
|
496
|
-
else if(returnedValue !== undefined) {
|
497
|
-
returnedValue = [returnedValue, response];
|
498
|
-
}
|
499
|
-
else if(response !== undefined) {
|
500
|
-
returnedValue = response;
|
501
|
-
}
|
502
|
-
return found;
|
503
|
-
}
|
504
|
-
};
|
505
|
-
|
506
|
-
if(methodInvoked) {
|
507
|
-
if(instance === undefined) {
|
508
|
-
module.initialize();
|
509
|
-
}
|
510
|
-
module.invoke(query);
|
511
|
-
}
|
512
|
-
else {
|
513
|
-
if(instance !== undefined) {
|
514
|
-
module.destroy();
|
515
|
-
}
|
516
|
-
module.initialize();
|
517
|
-
}
|
518
|
-
|
519
|
-
return (returnedValue !== undefined)
|
520
|
-
? returnedValue
|
521
|
-
: this
|
522
|
-
;
|
523
|
-
};
|
524
|
-
|
525
|
-
// handle DOM attachment to API functionality
|
526
|
-
$.fn.apiButton = function(parameters) {
|
527
|
-
$(this)
|
528
|
-
.each(function(){
|
529
|
-
var
|
530
|
-
// if only function passed it is success callback
|
531
|
-
$module = $(this),
|
532
|
-
selector = $(this).selector || '',
|
533
|
-
|
534
|
-
settings = ( $.isFunction(parameters) )
|
535
|
-
? $.extend(true, {}, $.api.settings, $.fn.apiButton.settings, { stateContext: this, success: parameters })
|
536
|
-
: $.extend(true, {}, $.api.settings, $.fn.apiButton.settings, { stateContext: this}, parameters),
|
537
|
-
module
|
538
|
-
;
|
539
|
-
module = {
|
540
|
-
initialize: function() {
|
541
|
-
if(settings.context && selector !== '') {
|
542
|
-
$(settings.context)
|
543
|
-
.on(selector, 'click.' + settings.namespace, module.click)
|
544
|
-
;
|
545
|
-
}
|
546
|
-
else {
|
547
|
-
$module
|
548
|
-
.on('click.' + settings.namespace, module.click)
|
549
|
-
;
|
550
|
-
}
|
551
|
-
},
|
552
|
-
click: function() {
|
553
|
-
if(!settings.filter || $(this).filter(settings.filter).size() === 0) {
|
554
|
-
$.proxy( $.api, this )(settings);
|
555
|
-
}
|
556
|
-
}
|
557
|
-
};
|
558
|
-
module.initialize();
|
559
|
-
})
|
560
|
-
;
|
561
|
-
return this;
|
562
|
-
};
|
563
|
-
|
564
|
-
$.api.settings = {
|
565
|
-
|
566
|
-
name : 'API',
|
567
|
-
namespace : 'api',
|
568
|
-
|
569
|
-
debug : true,
|
570
|
-
verbose : true,
|
571
|
-
performance : true,
|
572
|
-
|
573
|
-
api : {},
|
574
|
-
|
575
|
-
beforeSend : function(settings) {
|
576
|
-
return settings;
|
577
|
-
},
|
578
|
-
beforeXHR : function(xhr) {},
|
579
|
-
success : function(response) {},
|
580
|
-
complete : function(response) {},
|
581
|
-
failure : function(errorCode) {},
|
582
|
-
progress : false,
|
583
|
-
|
584
|
-
error : {
|
585
|
-
missingAction : 'API action used but no url was defined',
|
586
|
-
missingURL : 'URL not specified for the API action',
|
587
|
-
missingParameter : 'Missing an essential URL parameter: ',
|
588
|
-
|
589
|
-
timeout : 'Your request timed out',
|
590
|
-
error : 'There was an error with your request',
|
591
|
-
parseError : 'There was an error parsing your request',
|
592
|
-
JSONParse : 'JSON could not be parsed during error handling',
|
593
|
-
statusMessage : 'Server gave an error: ',
|
594
|
-
beforeSend : 'The before send function has aborted the request',
|
595
|
-
exitConditions : 'API Request Aborted. Exit conditions met'
|
596
|
-
},
|
597
|
-
|
598
|
-
className: {
|
599
|
-
loading : 'loading',
|
600
|
-
error : 'error'
|
601
|
-
},
|
602
|
-
|
603
|
-
metadata: {
|
604
|
-
action : 'action',
|
605
|
-
promise : 'promise',
|
606
|
-
xhr : 'xhr'
|
607
|
-
},
|
608
|
-
|
609
|
-
regExpTemplate: /\{\$([A-z]+)\}/g,
|
610
|
-
|
611
|
-
action : false,
|
612
|
-
url : false,
|
613
|
-
urlData : false,
|
614
|
-
serializeForm : false,
|
615
|
-
|
616
|
-
stateContext : false,
|
617
|
-
|
618
|
-
method : 'get',
|
619
|
-
data : {},
|
620
|
-
dataType : 'json',
|
621
|
-
cache : true,
|
622
|
-
|
623
|
-
loadingLength : 200,
|
624
|
-
errorLength : 2000
|
625
|
-
|
626
|
-
};
|
627
|
-
|
628
|
-
$.fn.apiButton.settings = {
|
629
|
-
filter : '.disabled, .loading',
|
630
|
-
context : false,
|
631
|
-
stateContext : false
|
632
|
-
};
|
633
|
-
|
634
|
-
})( jQuery, window , document );
|