Skip to content

Commit

Permalink
Updated distribution to version 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Semantic-Pusher-Robot committed Jul 23, 2015
1 parent 1dcc678 commit 22578d6
Show file tree
Hide file tree
Showing 136 changed files with 516 additions and 398 deletions.
2 changes: 1 addition & 1 deletion components/accordion.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.0.5 - Accordion
* # Semantic UI 2.0.7 - Accordion
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
2 changes: 1 addition & 1 deletion components/accordion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.0.5 - Accordion
* # Semantic UI 2.0.7 - Accordion
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
2 changes: 1 addition & 1 deletion components/accordion.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/accordion.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/ad.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.0.5 - Ad
* # Semantic UI 2.0.7 - Ad
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
2 changes: 1 addition & 1 deletion components/ad.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 62 additions & 34 deletions components/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.0.5 - API
* # Semantic UI 2.0.7 - API
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down Expand Up @@ -115,6 +115,20 @@ $.api = $.fn.api = function(parameters) {
}
},

decode: {
json: function(response) {
if(response !== undefined && typeof response == 'string') {
try {
response = JSON.parse(response);
}
catch(e) {
// isnt json string
}
}
return response;
}
},

read: {
cachedResponse: function(url) {
var
Expand All @@ -126,15 +140,7 @@ $.api = $.fn.api = function(parameters) {
}
response = sessionStorage.getItem(url);
module.debug('Using cached response', url, response);
if(response !== undefined) {
try {
response = JSON.parse(response);
}
catch(e) {
// didnt store object
}
return response;
}
response = module.decode.json(response);
return false;
}
},
Expand Down Expand Up @@ -287,7 +293,7 @@ $.api = $.fn.api = function(parameters) {
}
},
validResponse: function(response) {
if( settings.dataType !== 'json' || !$.isFunction(settings.successTest) ) {
if( (settings.dataType !== 'json' && settings.dataType !== 'jsonp') || !$.isFunction(settings.successTest) ) {
module.verbose('Response is not JSON, skipping validation', settings.successTest, response);
return true;
}
Expand Down Expand Up @@ -445,13 +451,13 @@ $.api = $.fn.api = function(parameters) {
},
xhr: {
always: function() {
// calculate if loading time was below minimum threshold
// nothing special
},
done: function(response, textStatus, xhr) {
var
context = this,
elapsedTime = (new Date().getTime() - requestStartTime),
timeLeft = (settings.loadingDuration - elapsedTime),
context = this,
elapsedTime = (new Date().getTime() - requestStartTime),
timeLeft = (settings.loadingDuration - elapsedTime),
translatedResponse = ( $.isFunction(settings.onResponse) )
? settings.onResponse.call(context, $.extend(true, {}, response))
: false
Expand All @@ -469,7 +475,7 @@ $.api = $.fn.api = function(parameters) {
}
setTimeout(function() {
if( module.is.validResponse(response) ) {
module.request.resolveWith(context, [response]);
module.request.resolveWith(context, [response, xhr]);
}
else {
module.request.rejectWith(context, [xhr, 'invalid']);
Expand Down Expand Up @@ -500,46 +506,52 @@ $.api = $.fn.api = function(parameters) {
}
},
request: {
complete: function(response) {
module.remove.loading();
settings.onComplete.call(context, response, $module);
},
done: function(response) {
done: function(response, xhr) {
module.debug('Successful API Response', response);
if(settings.cache === 'local' && url) {
module.write.cachedResponse(url, response);
module.debug('Saving server response locally', module.cache);
}
settings.onSuccess.call(context, response, $module);
settings.onSuccess.call(context, response, $module, xhr);
},
complete: function(firstParameter, secondParameter) {
var
xhr,
response
;
// have to guess callback parameters based on request success
if( module.was.succesful() ) {
response = firstParameter;
xhr = secondParameter;
}
else {
xhr = firstParameter;
response = module.get.responseFromXHR(xhr);
}
module.remove.loading();
settings.onComplete.call(context, response, $module, xhr);
},
fail: function(xhr, status, httpMessage) {
var
// pull response from xhr if available
response = $.isPlainObject(xhr)
? (xhr.responseText)
: false,
errorMessage = ($.isPlainObject(response) && response.error !== undefined)
? response.error // use json error message
: (settings.error[status] !== undefined) // use server error message
? settings.error[status]
: httpMessage
response = module.get.responseFromXHR(xhr),
errorMessage = module.get.errorFromRequest(response, status, httpMessage)
;
if(status == 'aborted') {
module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage);
settings.onAbort.call(context, status, $module);
settings.onAbort.call(context, status, $module, xhr);
}
else if(status == 'invalid') {
module.debug('JSON did not pass success test. A server-side error has most likely occurred', response);
}
else if(status == 'error') {

if(xhr !== undefined) {
module.debug('XHR produced a server error', status, httpMessage);
// make sure we have an error to display to console
if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') {
module.error(error.statusMessage + httpMessage, ajaxSettings.url);
}
settings.onError.call(context, errorMessage, $module);
settings.onError.call(context, errorMessage, $module, xhr);
}
}

Expand All @@ -549,7 +561,7 @@ $.api = $.fn.api = function(parameters) {
setTimeout(module.remove.error, settings.errorDuration);
}
module.debug('API Request failed', errorMessage, xhr);
settings.onFailure.call(context, response, $module);
settings.onFailure.call(context, response, $module, xhr);
}
}
},
Expand Down Expand Up @@ -650,6 +662,22 @@ $.api = $.fn.api = function(parameters) {
},

get: {
responseFromXHR: function(xhr) {
return $.isPlainObject(xhr)
? (settings.dataType == 'json' || settings.dataType == 'jsonp')
? module.decode.json(xhr.responseText)
: xhr.responseText
: false
;
},
errorFromRequest: function(response, status, httpMessage) {
return ($.isPlainObject(response) && response.error !== undefined)
? response.error // use json error message
: (settings.error[status] !== undefined) // use server error message
? settings.error[status]
: httpMessage
;
},
request: function() {
return module.request || false;
},
Expand Down
Loading

0 comments on commit 22578d6

Please sign in to comment.