Skip to content

Commit 22578d6

Browse files
Updated distribution to version 2.0.7
1 parent 1dcc678 commit 22578d6

136 files changed

Lines changed: 516 additions & 398 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/accordion.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.0.5 - Accordion
2+
* # Semantic UI 2.0.7 - Accordion
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*

components/accordion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.0.5 - Accordion
2+
* # Semantic UI 2.0.7 - Accordion
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*

components/accordion.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/accordion.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ad.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.0.5 - Ad
2+
* # Semantic UI 2.0.7 - Ad
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*

components/ad.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/api.js

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.0.5 - API
2+
* # Semantic UI 2.0.7 - API
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
@@ -115,6 +115,20 @@ $.api = $.fn.api = function(parameters) {
115115
}
116116
},
117117

118+
decode: {
119+
json: function(response) {
120+
if(response !== undefined && typeof response == 'string') {
121+
try {
122+
response = JSON.parse(response);
123+
}
124+
catch(e) {
125+
// isnt json string
126+
}
127+
}
128+
return response;
129+
}
130+
},
131+
118132
read: {
119133
cachedResponse: function(url) {
120134
var
@@ -126,15 +140,7 @@ $.api = $.fn.api = function(parameters) {
126140
}
127141
response = sessionStorage.getItem(url);
128142
module.debug('Using cached response', url, response);
129-
if(response !== undefined) {
130-
try {
131-
response = JSON.parse(response);
132-
}
133-
catch(e) {
134-
// didnt store object
135-
}
136-
return response;
137-
}
143+
response = module.decode.json(response);
138144
return false;
139145
}
140146
},
@@ -287,7 +293,7 @@ $.api = $.fn.api = function(parameters) {
287293
}
288294
},
289295
validResponse: function(response) {
290-
if( settings.dataType !== 'json' || !$.isFunction(settings.successTest) ) {
296+
if( (settings.dataType !== 'json' && settings.dataType !== 'jsonp') || !$.isFunction(settings.successTest) ) {
291297
module.verbose('Response is not JSON, skipping validation', settings.successTest, response);
292298
return true;
293299
}
@@ -445,13 +451,13 @@ $.api = $.fn.api = function(parameters) {
445451
},
446452
xhr: {
447453
always: function() {
448-
// calculate if loading time was below minimum threshold
454+
// nothing special
449455
},
450456
done: function(response, textStatus, xhr) {
451457
var
452-
context = this,
453-
elapsedTime = (new Date().getTime() - requestStartTime),
454-
timeLeft = (settings.loadingDuration - elapsedTime),
458+
context = this,
459+
elapsedTime = (new Date().getTime() - requestStartTime),
460+
timeLeft = (settings.loadingDuration - elapsedTime),
455461
translatedResponse = ( $.isFunction(settings.onResponse) )
456462
? settings.onResponse.call(context, $.extend(true, {}, response))
457463
: false
@@ -469,7 +475,7 @@ $.api = $.fn.api = function(parameters) {
469475
}
470476
setTimeout(function() {
471477
if( module.is.validResponse(response) ) {
472-
module.request.resolveWith(context, [response]);
478+
module.request.resolveWith(context, [response, xhr]);
473479
}
474480
else {
475481
module.request.rejectWith(context, [xhr, 'invalid']);
@@ -500,46 +506,52 @@ $.api = $.fn.api = function(parameters) {
500506
}
501507
},
502508
request: {
503-
complete: function(response) {
504-
module.remove.loading();
505-
settings.onComplete.call(context, response, $module);
506-
},
507-
done: function(response) {
509+
done: function(response, xhr) {
508510
module.debug('Successful API Response', response);
509511
if(settings.cache === 'local' && url) {
510512
module.write.cachedResponse(url, response);
511513
module.debug('Saving server response locally', module.cache);
512514
}
513-
settings.onSuccess.call(context, response, $module);
515+
settings.onSuccess.call(context, response, $module, xhr);
516+
},
517+
complete: function(firstParameter, secondParameter) {
518+
var
519+
xhr,
520+
response
521+
;
522+
// have to guess callback parameters based on request success
523+
if( module.was.succesful() ) {
524+
response = firstParameter;
525+
xhr = secondParameter;
526+
}
527+
else {
528+
xhr = firstParameter;
529+
response = module.get.responseFromXHR(xhr);
530+
}
531+
module.remove.loading();
532+
settings.onComplete.call(context, response, $module, xhr);
514533
},
515534
fail: function(xhr, status, httpMessage) {
516535
var
517536
// pull response from xhr if available
518-
response = $.isPlainObject(xhr)
519-
? (xhr.responseText)
520-
: false,
521-
errorMessage = ($.isPlainObject(response) && response.error !== undefined)
522-
? response.error // use json error message
523-
: (settings.error[status] !== undefined) // use server error message
524-
? settings.error[status]
525-
: httpMessage
537+
response = module.get.responseFromXHR(xhr),
538+
errorMessage = module.get.errorFromRequest(response, status, httpMessage)
526539
;
527540
if(status == 'aborted') {
528541
module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage);
529-
settings.onAbort.call(context, status, $module);
542+
settings.onAbort.call(context, status, $module, xhr);
530543
}
531544
else if(status == 'invalid') {
532545
module.debug('JSON did not pass success test. A server-side error has most likely occurred', response);
533546
}
534547
else if(status == 'error') {
535-
536548
if(xhr !== undefined) {
537549
module.debug('XHR produced a server error', status, httpMessage);
538550
// make sure we have an error to display to console
539551
if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') {
540552
module.error(error.statusMessage + httpMessage, ajaxSettings.url);
541553
}
542-
settings.onError.call(context, errorMessage, $module);
554+
settings.onError.call(context, errorMessage, $module, xhr);
543555
}
544556
}
545557

@@ -549,7 +561,7 @@ $.api = $.fn.api = function(parameters) {
549561
setTimeout(module.remove.error, settings.errorDuration);
550562
}
551563
module.debug('API Request failed', errorMessage, xhr);
552-
settings.onFailure.call(context, response, $module);
564+
settings.onFailure.call(context, response, $module, xhr);
553565
}
554566
}
555567
},
@@ -650,6 +662,22 @@ $.api = $.fn.api = function(parameters) {
650662
},
651663

652664
get: {
665+
responseFromXHR: function(xhr) {
666+
return $.isPlainObject(xhr)
667+
? (settings.dataType == 'json' || settings.dataType == 'jsonp')
668+
? module.decode.json(xhr.responseText)
669+
: xhr.responseText
670+
: false
671+
;
672+
},
673+
errorFromRequest: function(response, status, httpMessage) {
674+
return ($.isPlainObject(response) && response.error !== undefined)
675+
? response.error // use json error message
676+
: (settings.error[status] !== undefined) // use server error message
677+
? settings.error[status]
678+
: httpMessage
679+
;
680+
},
653681
request: function() {
654682
return module.request || false;
655683
},

0 commit comments

Comments
 (0)