Skip to content

Commit

Permalink
Release 1.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
qathom committed Jan 14, 2018
1 parent 7ff1a84 commit 7d96710
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### 1.4.9 (2018-01-14)

### Features

* Added `getCurrentLocale()` to retrieve the language used with the [i18n](http://phonon.quarkdev.com/docs/i18n) module.

### Bug Fixes

* GET requests with parameters [#100](https://github.com/quark-dev/Phonon-Framework/issues/100)

### 1.4.8 (2017-12-15)

### Features
Expand Down
24 changes: 16 additions & 8 deletions dist/js/phonon-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ phonon.ajax = (function () {
* @param {Object} data
*/
var objToString = function(data) {
var strData = '';
var strData = '?';
var key;

for(key in data) {
Expand All @@ -1352,7 +1352,7 @@ phonon.ajax = (function () {

var last = strData.lastIndexOf('&');
if(last !== -1) {
data = strData.substring(0, last);
strData = strData.substring(0, last);
}
return strData;
};
Expand All @@ -1378,13 +1378,18 @@ phonon.ajax = (function () {
if(typeof url !== 'string') throw new TypeError('url must be a string');
// https://github.com/quark-dev/Phonon-Framework/issues/195#issuecomment-274266194
if(typeof opts.contentType === 'undefined') opts.contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
if(typeof data === 'object') data = contentType === 'application/json' ? JSON.stringify(data) : objToString(data);

var xhr = createXhr(crossDomain);
var flagError = 'NO_INTERNET_ACCESS';

if(xhr) {
if(typeof method === 'string' && method.toLowerCase().trim() === 'get'
&& data !== null && typeof data === 'object') {
url += objToString(data)
}

if(typeof data === 'object' && data !== null) data = JSON.stringify(data);

if(xhr) {
xhr.open(method, url, true);

if(typeof contentType === 'string') {
Expand Down Expand Up @@ -1849,7 +1854,7 @@ phonon.tagManager = (function () {
;(function (window, document) {

var jsonCache = null;
var localeUsed = null;
var currentLocale = null;

var opts = {
localeFallback: null,
Expand Down Expand Up @@ -1975,6 +1980,8 @@ phonon.tagManager = (function () {
opts[prop] = options[prop];
}

currentLocale = opts.localeFallback

if(typeof options.use !== 'undefined') {
opts.loadJson = false
}
Expand All @@ -1997,6 +2004,8 @@ phonon.tagManager = (function () {

var locale = opts.localePreferred ? opts.localePreferred : opts.localeFallback;

currentLocale = locale

if(opts.loadJson) {
// JSON
if(jsonCache !== null) {
Expand All @@ -2023,7 +2032,6 @@ phonon.tagManager = (function () {
try {
var json = JSON.parse(xhr.responseText);
jsonCache = json;
localeUsed = locale;
callback(jsonCache);
} catch (e) {
fallback();
Expand Down Expand Up @@ -2189,8 +2197,8 @@ phonon.tagManager = (function () {
getLocale: function () {
return getLocale();
},
getLoadedLocale: function () {
return localeUsed;
getCurrentLocale: function () {
return currentLocale;
}
};
};
Expand Down
3 changes: 1 addition & 2 deletions dist/js/phonon-core.min.js

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions dist/js/phonon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ phonon.ajax = (function () {
* @param {Object} data
*/
var objToString = function(data) {
var strData = '';
var strData = '?';
var key;

for(key in data) {
Expand All @@ -1352,7 +1352,7 @@ phonon.ajax = (function () {

var last = strData.lastIndexOf('&');
if(last !== -1) {
data = strData.substring(0, last);
strData = strData.substring(0, last);
}
return strData;
};
Expand All @@ -1378,13 +1378,18 @@ phonon.ajax = (function () {
if(typeof url !== 'string') throw new TypeError('url must be a string');
// https://github.com/quark-dev/Phonon-Framework/issues/195#issuecomment-274266194
if(typeof opts.contentType === 'undefined') opts.contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
if(typeof data === 'object') data = contentType === 'application/json' ? JSON.stringify(data) : objToString(data);

var xhr = createXhr(crossDomain);
var flagError = 'NO_INTERNET_ACCESS';

if(xhr) {
if(typeof method === 'string' && method.toLowerCase().trim() === 'get'
&& data !== null && typeof data === 'object') {
url += objToString(data)
}

if(typeof data === 'object' && data !== null) data = JSON.stringify(data);

if(xhr) {
xhr.open(method, url, true);

if(typeof contentType === 'string') {
Expand Down Expand Up @@ -1849,7 +1854,7 @@ phonon.tagManager = (function () {
;(function (window, document) {

var jsonCache = null;
var localeUsed = null;
var currentLocale = null;

var opts = {
localeFallback: null,
Expand Down Expand Up @@ -1975,6 +1980,8 @@ phonon.tagManager = (function () {
opts[prop] = options[prop];
}

currentLocale = opts.localeFallback

if(typeof options.use !== 'undefined') {
opts.loadJson = false
}
Expand All @@ -1997,6 +2004,8 @@ phonon.tagManager = (function () {

var locale = opts.localePreferred ? opts.localePreferred : opts.localeFallback;

currentLocale = locale

if(opts.loadJson) {
// JSON
if(jsonCache !== null) {
Expand All @@ -2023,7 +2032,6 @@ phonon.tagManager = (function () {
try {
var json = JSON.parse(xhr.responseText);
jsonCache = json;
localeUsed = locale;
callback(jsonCache);
} catch (e) {
fallback();
Expand Down Expand Up @@ -2189,8 +2197,8 @@ phonon.tagManager = (function () {
getLocale: function () {
return getLocale();
},
getLoadedLocale: function () {
return localeUsed;
getCurrentLocale: function () {
return currentLocale;
}
};
};
Expand Down
4 changes: 1 addition & 3 deletions dist/js/phonon.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phonon",
"version": "1.4.8",
"version": "1.4.9",
"description": "Phonon is a lightweight & scalable Javascript/CSS3/HTML5 mobile framework to develop a single page application based on Phonegap / Apache Cordova.",
"repository": {
"type": "git",
Expand Down

0 comments on commit 7d96710

Please sign in to comment.