-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(jsonloader): updated callback parameter behaviour
- Loading branch information
1 parent
687bc79
commit 23cabc1
Showing
5 changed files
with
41 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "apiNG", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"homepage": "https://github.com/JohnnyTheTank/apiNG", | ||
"authors": [ | ||
"Jonathan Hornung <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
@name: aping | ||
@version: 1.0.2 (20-01-2016) | ||
@version: 1.0.3 (21-01-2016) | ||
@author: Jonathan Hornung <[email protected]> | ||
@url: https://github.com/JohnnyTheTank/apiNG | ||
@license: MIT | ||
|
@@ -677,24 +677,26 @@ angular.module("jtt_aping_jsonloader", []) | |
requestObject.format = "jsonp"; | ||
} | ||
|
||
if (request.callback && request.format === "jsonp") { | ||
if (request.callback) { | ||
requestObject.callback = request.callback; | ||
} else { | ||
} | ||
|
||
if (request.format === "jsonp" && !request.callback) { | ||
requestObject.callback = 'JSON_CALLBACK'; | ||
} | ||
|
||
if(angular.isDefined(request.items)) { | ||
if (angular.isDefined(request.items)) { | ||
requestObject.count = request.items; | ||
} else { | ||
requestObject.count = appSettings.items; | ||
} | ||
|
||
if(requestObject.count === 0 || requestObject.count === '0') { | ||
if (requestObject.count === 0 || requestObject.count === '0') { | ||
return false; | ||
} | ||
|
||
// -1 is "no explicit limit". same for NaN value | ||
if(requestObject.count < 0 || isNaN(requestObject.count)) { | ||
if (requestObject.count < 0 || isNaN(requestObject.count)) { | ||
requestObject.count = undefined; | ||
} | ||
|
||
|
@@ -706,14 +708,14 @@ angular.module("jtt_aping_jsonloader", []) | |
|
||
var results = _data.data; | ||
|
||
if(angular.isDefined(request.resultProperty)) { | ||
if (angular.isDefined(request.resultProperty)) { | ||
results = _data.data[request.resultProperty]; | ||
} | ||
|
||
if (_data.data.constructor !== Array) { | ||
resultArray.push(results); | ||
} else { | ||
if (request.items < 0 || angular.isDefined(request.items) ) { | ||
if (request.items < 0 || angular.isDefined(request.items)) { | ||
resultArray = results; | ||
} else { | ||
angular.forEach(results, function (value, key) { | ||
|
@@ -735,20 +737,27 @@ angular.module("jtt_aping_jsonloader", []) | |
var jsonloaderFactory = {}; | ||
|
||
jsonloaderFactory.getJsonData = function (_requestObject) { | ||
var params = {}; | ||
if (angular.isDefined(_requestObject.callback)) { | ||
params[_requestObject.callback] = 'JSON_CALLBACK'; | ||
} | ||
|
||
|
||
if (_requestObject.format === "jsonp") { | ||
|
||
return $http.jsonp( | ||
_requestObject.path, | ||
{ | ||
method: 'GET', | ||
params: {callback: _requestObject.callback}, | ||
params: params, | ||
} | ||
); | ||
|
||
} else { | ||
return $http({ | ||
method: 'GET', | ||
url: _requestObject.path | ||
url: _requestObject.path, | ||
params: params | ||
}); | ||
} | ||
}; | ||
|
Oops, something went wrong.