From 62b528a41c71034a0a760ef928f1324457332681 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Nov 2015 13:17:58 -0500 Subject: [PATCH] start replacing jquery ajax with fetch --- .../bower_components/fetch/.bower.json | 28 ++ dashboard-ui/bower_components/fetch/LICENSE | 20 + .../bower_components/fetch/bower.json | 16 + dashboard-ui/bower_components/fetch/fetch.js | 381 ++++++++++++++++++ .../get-style-property/.bower.json | 2 +- .../bower_components/iron-meta/.bower.json | 6 +- .../iron-overlay-behavior/.bower.json | 6 +- .../iron-resizable-behavior/.bower.json | 6 +- .../neon-animation/.bower.json | 4 +- .../paper-behaviors/.bower.json | 4 +- .../bower_components/paper-input/.bower.json | 6 +- .../bower_components/paper-ripple/.bower.json | 6 +- dashboard-ui/components/imagestore.js | 2 +- dashboard-ui/css/card.css | 2 +- dashboard-ui/css/librarybrowser.css | 7 + dashboard-ui/devices/android/android.css | 2 +- dashboard-ui/scripts/globalize.js | 77 ++-- dashboard-ui/scripts/registrationservices.js | 8 +- dashboard-ui/scripts/site.js | 6 +- .../jquery.mobile.custom.js | 27 +- 20 files changed, 547 insertions(+), 69 deletions(-) create mode 100644 dashboard-ui/bower_components/fetch/.bower.json create mode 100644 dashboard-ui/bower_components/fetch/LICENSE create mode 100644 dashboard-ui/bower_components/fetch/bower.json create mode 100644 dashboard-ui/bower_components/fetch/fetch.js diff --git a/dashboard-ui/bower_components/fetch/.bower.json b/dashboard-ui/bower_components/fetch/.bower.json new file mode 100644 index 0000000000..96d72ad5cb --- /dev/null +++ b/dashboard-ui/bower_components/fetch/.bower.json @@ -0,0 +1,28 @@ +{ + "name": "fetch", + "main": "fetch.js", + "devDependencies": { + "es6-promise": "1.0.0" + }, + "ignore": [ + ".*", + "*.md", + "examples/", + "Makefile", + "package.json", + "script/", + "test/" + ], + "homepage": "https://github.com/github/fetch", + "version": "0.10.1", + "_release": "0.10.1", + "_resolution": { + "type": "version", + "tag": "v0.10.1", + "commit": "f4f8ca8d0ba6c7d11e5317a84189913cefe55809" + }, + "_source": "git://github.com/github/fetch.git", + "_target": "~0.10.1", + "_originalSource": "fetch", + "_direct": true +} \ No newline at end of file diff --git a/dashboard-ui/bower_components/fetch/LICENSE b/dashboard-ui/bower_components/fetch/LICENSE new file mode 100644 index 0000000000..ef00ba265e --- /dev/null +++ b/dashboard-ui/bower_components/fetch/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2014-2015 GitHub, Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/dashboard-ui/bower_components/fetch/bower.json b/dashboard-ui/bower_components/fetch/bower.json new file mode 100644 index 0000000000..8966a30894 --- /dev/null +++ b/dashboard-ui/bower_components/fetch/bower.json @@ -0,0 +1,16 @@ +{ + "name": "fetch", + "main": "fetch.js", + "devDependencies": { + "es6-promise": "1.0.0" + }, + "ignore": [ + ".*", + "*.md", + "examples/", + "Makefile", + "package.json", + "script/", + "test/" + ] +} diff --git a/dashboard-ui/bower_components/fetch/fetch.js b/dashboard-ui/bower_components/fetch/fetch.js new file mode 100644 index 0000000000..f89f27a663 --- /dev/null +++ b/dashboard-ui/bower_components/fetch/fetch.js @@ -0,0 +1,381 @@ +(function() { + 'use strict'; + + if (self.fetch) { + return + } + + function normalizeName(name) { + if (typeof name !== 'string') { + name = String(name) + } + if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { + throw new TypeError('Invalid character in header field name') + } + return name.toLowerCase() + } + + function normalizeValue(value) { + if (typeof value !== 'string') { + value = String(value) + } + return value + } + + function Headers(headers) { + this.map = {} + + if (headers instanceof Headers) { + headers.forEach(function(value, name) { + this.append(name, value) + }, this) + + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function(name) { + this.append(name, headers[name]) + }, this) + } + } + + Headers.prototype.append = function(name, value) { + name = normalizeName(name) + value = normalizeValue(value) + var list = this.map[name] + if (!list) { + list = [] + this.map[name] = list + } + list.push(value) + } + + Headers.prototype['delete'] = function(name) { + delete this.map[normalizeName(name)] + } + + Headers.prototype.get = function(name) { + var values = this.map[normalizeName(name)] + return values ? values[0] : null + } + + Headers.prototype.getAll = function(name) { + return this.map[normalizeName(name)] || [] + } + + Headers.prototype.has = function(name) { + return this.map.hasOwnProperty(normalizeName(name)) + } + + Headers.prototype.set = function(name, value) { + this.map[normalizeName(name)] = [normalizeValue(value)] + } + + Headers.prototype.forEach = function(callback, thisArg) { + Object.getOwnPropertyNames(this.map).forEach(function(name) { + this.map[name].forEach(function(value) { + callback.call(thisArg, value, name, this) + }, this) + }, this) + } + + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError('Already read')) + } + body.bodyUsed = true + } + + function fileReaderReady(reader) { + return new Promise(function(resolve, reject) { + reader.onload = function() { + resolve(reader.result) + } + reader.onerror = function() { + reject(reader.error) + } + }) + } + + function readBlobAsArrayBuffer(blob) { + var reader = new FileReader() + reader.readAsArrayBuffer(blob) + return fileReaderReady(reader) + } + + function readBlobAsText(blob) { + var reader = new FileReader() + reader.readAsText(blob) + return fileReaderReady(reader) + } + + var support = { + blob: 'FileReader' in self && 'Blob' in self && (function() { + try { + new Blob(); + return true + } catch(e) { + return false + } + })(), + formData: 'FormData' in self, + arrayBuffer: 'ArrayBuffer' in self + } + + function Body() { + this.bodyUsed = false + + + this._initBody = function(body) { + this._bodyInit = body + if (typeof body === 'string') { + this._bodyText = body + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body + } else if (!body) { + this._bodyText = '' + } else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) { + // Only support ArrayBuffers for POST method. + // Receiving ArrayBuffers happens via Blobs, instead. + } else { + throw new Error('unsupported BodyInit type') + } + } + + if (support.blob) { + this.blob = function() { + var rejected = consumed(this) + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as blob') + } else { + return Promise.resolve(new Blob([this._bodyText])) + } + } + + this.arrayBuffer = function() { + return this.blob().then(readBlobAsArrayBuffer) + } + + this.text = function() { + var rejected = consumed(this) + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as text') + } else { + return Promise.resolve(this._bodyText) + } + } + } else { + this.text = function() { + var rejected = consumed(this) + return rejected ? rejected : Promise.resolve(this._bodyText) + } + } + + if (support.formData) { + this.formData = function() { + return this.text().then(decode) + } + } + + this.json = function() { + return this.text().then(JSON.parse) + } + + return this + } + + // HTTP methods whose capitalization should be normalized + var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] + + function normalizeMethod(method) { + var upcased = method.toUpperCase() + return (methods.indexOf(upcased) > -1) ? upcased : method + } + + function Request(input, options) { + options = options || {} + var body = options.body + if (Request.prototype.isPrototypeOf(input)) { + if (input.bodyUsed) { + throw new TypeError('Already read') + } + this.url = input.url + this.credentials = input.credentials + if (!options.headers) { + this.headers = new Headers(input.headers) + } + this.method = input.method + this.mode = input.mode + if (!body) { + body = input._bodyInit + input.bodyUsed = true + } + } else { + this.url = input + } + + this.credentials = options.credentials || this.credentials || 'omit' + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers) + } + this.method = normalizeMethod(options.method || this.method || 'GET') + this.mode = options.mode || this.mode || null + this.referrer = null + + if ((this.method === 'GET' || this.method === 'HEAD') && body) { + throw new TypeError('Body not allowed for GET or HEAD requests') + } + this._initBody(body) + } + + Request.prototype.clone = function() { + return new Request(this) + } + + function decode(body) { + var form = new FormData() + body.trim().split('&').forEach(function(bytes) { + if (bytes) { + var split = bytes.split('=') + var name = split.shift().replace(/\+/g, ' ') + var value = split.join('=').replace(/\+/g, ' ') + form.append(decodeURIComponent(name), decodeURIComponent(value)) + } + }) + return form + } + + function headers(xhr) { + var head = new Headers() + var pairs = xhr.getAllResponseHeaders().trim().split('\n') + pairs.forEach(function(header) { + var split = header.trim().split(':') + var key = split.shift().trim() + var value = split.join(':').trim() + head.append(key, value) + }) + return head + } + + Body.call(Request.prototype) + + function Response(bodyInit, options) { + if (!options) { + options = {} + } + + this._initBody(bodyInit) + this.type = 'default' + this.status = options.status + this.ok = this.status >= 200 && this.status < 300 + this.statusText = options.statusText + this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers) + this.url = options.url || '' + } + + Body.call(Response.prototype) + + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }) + } + + Response.error = function() { + var response = new Response(null, {status: 0, statusText: ''}) + response.type = 'error' + return response + } + + var redirectStatuses = [301, 302, 303, 307, 308] + + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code') + } + + return new Response(null, {status: status, headers: {location: url}}) + } + + self.Headers = Headers; + self.Request = Request; + self.Response = Response; + + self.fetch = function(input, init) { + return new Promise(function(resolve, reject) { + var request + if (Request.prototype.isPrototypeOf(input) && !init) { + request = input + } else { + request = new Request(input, init) + } + + var xhr = new XMLHttpRequest() + + function responseURL() { + if ('responseURL' in xhr) { + return xhr.responseURL + } + + // Avoid security warnings on getResponseHeader when not allowed by CORS + if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) { + return xhr.getResponseHeader('X-Request-URL') + } + + return; + } + + xhr.onload = function() { + var status = (xhr.status === 1223) ? 204 : xhr.status + if (status < 100 || status > 599) { + reject(new TypeError('Network request failed')) + return + } + var options = { + status: status, + statusText: xhr.statusText, + headers: headers(xhr), + url: responseURL() + } + var body = 'response' in xhr ? xhr.response : xhr.responseText; + resolve(new Response(body, options)) + } + + xhr.onerror = function() { + reject(new TypeError('Network request failed')) + } + + xhr.open(request.method, request.url, true) + + if (request.credentials === 'include') { + xhr.withCredentials = true + } + + if ('responseType' in xhr && support.blob) { + xhr.responseType = 'blob' + } + + request.headers.forEach(function(value, name) { + xhr.setRequestHeader(name, value) + }) + + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) + }) + } + self.fetch.polyfill = true +})(); diff --git a/dashboard-ui/bower_components/get-style-property/.bower.json b/dashboard-ui/bower_components/get-style-property/.bower.json index 973f1966c0..d943fa3b04 100644 --- a/dashboard-ui/bower_components/get-style-property/.bower.json +++ b/dashboard-ui/bower_components/get-style-property/.bower.json @@ -31,6 +31,6 @@ "commit": "34fc5e4a0f252964ed2790138b8d7d30d04b55c1" }, "_source": "git://github.com/desandro/get-style-property.git", - "_target": "1.x", + "_target": "~1.0.4", "_originalSource": "get-style-property" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-meta/.bower.json b/dashboard-ui/bower_components/iron-meta/.bower.json index f4bfef4a7c..e1304d174b 100644 --- a/dashboard-ui/bower_components/iron-meta/.bower.json +++ b/dashboard-ui/bower_components/iron-meta/.bower.json @@ -26,14 +26,14 @@ "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, "main": "iron-meta.html", - "homepage": "https://github.com/polymerelements/iron-meta", + "homepage": "https://github.com/PolymerElements/iron-meta", "_release": "1.1.1", "_resolution": { "type": "version", "tag": "v1.1.1", "commit": "e171ee234b482219c9514e6f9551df48ef48bd9f" }, - "_source": "git://github.com/polymerelements/iron-meta.git", + "_source": "git://github.com/PolymerElements/iron-meta.git", "_target": "^1.0.0", - "_originalSource": "polymerelements/iron-meta" + "_originalSource": "PolymerElements/iron-meta" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json b/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json index 3911d5458a..781650cdba 100644 --- a/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json +++ b/dashboard-ui/bower_components/iron-overlay-behavior/.bower.json @@ -33,14 +33,14 @@ "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, "ignore": [], - "homepage": "https://github.com/PolymerElements/iron-overlay-behavior", + "homepage": "https://github.com/polymerelements/iron-overlay-behavior", "_release": "1.1.1", "_resolution": { "type": "version", "tag": "v1.1.1", "commit": "1ed1603ce820456feab3f62ae86f8f3ec801d131" }, - "_source": "git://github.com/PolymerElements/iron-overlay-behavior.git", + "_source": "git://github.com/polymerelements/iron-overlay-behavior.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/iron-overlay-behavior" + "_originalSource": "polymerelements/iron-overlay-behavior" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-resizable-behavior/.bower.json b/dashboard-ui/bower_components/iron-resizable-behavior/.bower.json index 9ae5e84c7e..1f0548f3d7 100644 --- a/dashboard-ui/bower_components/iron-resizable-behavior/.bower.json +++ b/dashboard-ui/bower_components/iron-resizable-behavior/.bower.json @@ -27,14 +27,14 @@ "web-component-tester": "*", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, - "homepage": "https://github.com/PolymerElements/iron-resizable-behavior", + "homepage": "https://github.com/polymerelements/iron-resizable-behavior", "_release": "1.0.2", "_resolution": { "type": "version", "tag": "v1.0.2", "commit": "85de8ba28be2bf17c81d6436ef1119022b003674" }, - "_source": "git://github.com/PolymerElements/iron-resizable-behavior.git", + "_source": "git://github.com/polymerelements/iron-resizable-behavior.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/iron-resizable-behavior" + "_originalSource": "polymerelements/iron-resizable-behavior" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/neon-animation/.bower.json b/dashboard-ui/bower_components/neon-animation/.bower.json index fa31ad184d..67f935cf9f 100644 --- a/dashboard-ui/bower_components/neon-animation/.bower.json +++ b/dashboard-ui/bower_components/neon-animation/.bower.json @@ -54,7 +54,7 @@ "tag": "v1.0.8", "commit": "36656916b75a4715b025a03473620002c2650ee8" }, - "_source": "git://github.com/PolymerElements/neon-animation.git", + "_source": "git://github.com/polymerelements/neon-animation.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/neon-animation" + "_originalSource": "polymerelements/neon-animation" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/paper-behaviors/.bower.json b/dashboard-ui/bower_components/paper-behaviors/.bower.json index a76af97568..713d584e4f 100644 --- a/dashboard-ui/bower_components/paper-behaviors/.bower.json +++ b/dashboard-ui/bower_components/paper-behaviors/.bower.json @@ -45,7 +45,7 @@ "tag": "v1.0.10", "commit": "4b244a542af2c6c271498dfb98b00ed284df1d6a" }, - "_source": "git://github.com/polymerelements/paper-behaviors.git", + "_source": "git://github.com/PolymerElements/paper-behaviors.git", "_target": "^1.0.0", - "_originalSource": "polymerelements/paper-behaviors" + "_originalSource": "PolymerElements/paper-behaviors" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/paper-input/.bower.json b/dashboard-ui/bower_components/paper-input/.bower.json index d0ff753f59..91b2f2300d 100644 --- a/dashboard-ui/bower_components/paper-input/.bower.json +++ b/dashboard-ui/bower_components/paper-input/.bower.json @@ -50,7 +50,7 @@ "tag": "v1.1.1", "commit": "1bbce220b027dc030b294163f7da6f3e9052ab13" }, - "_source": "git://github.com/PolymerElements/paper-input.git", - "_target": "^1.0.0", - "_originalSource": "PolymerElements/paper-input" + "_source": "git://github.com/polymerelements/paper-input.git", + "_target": "^1.0.9", + "_originalSource": "polymerelements/paper-input" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/paper-ripple/.bower.json b/dashboard-ui/bower_components/paper-ripple/.bower.json index 2f654d71c6..157225ee71 100644 --- a/dashboard-ui/bower_components/paper-ripple/.bower.json +++ b/dashboard-ui/bower_components/paper-ripple/.bower.json @@ -32,14 +32,14 @@ "iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0" }, "ignore": [], - "homepage": "https://github.com/polymerelements/paper-ripple", + "homepage": "https://github.com/PolymerElements/paper-ripple", "_release": "1.0.5", "_resolution": { "type": "version", "tag": "v1.0.5", "commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5" }, - "_source": "git://github.com/polymerelements/paper-ripple.git", + "_source": "git://github.com/PolymerElements/paper-ripple.git", "_target": "^1.0.0", - "_originalSource": "polymerelements/paper-ripple" + "_originalSource": "PolymerElements/paper-ripple" } \ No newline at end of file diff --git a/dashboard-ui/components/imagestore.js b/dashboard-ui/components/imagestore.js index 25a9299d8c..31f7debf59 100644 --- a/dashboard-ui/components/imagestore.js +++ b/dashboard-ui/components/imagestore.js @@ -87,7 +87,7 @@ if (this.status == 200) { writeData(dir, filename, this.getResponseHeader('Content-Type'), this.response, callback, errorCallback); } else { - errorCallback(); + errorCallback(''); } } diff --git a/dashboard-ui/css/card.css b/dashboard-ui/css/card.css index 609ffeb55a..a6b8ef6239 100644 --- a/dashboard-ui/css/card.css +++ b/dashboard-ui/css/card.css @@ -522,7 +522,7 @@ } } -@media all and (min-width: 1920px) { +@media all and (min-width: 2100px) { .squareCard { width: 11.111111111111111111111111111111%; diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index 54a18cecb7..7aa6067261 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -144,6 +144,13 @@ } } +@media all and (min-width: 2560px) { + + .ehsContent:not(.fullWidth), .ehsContent .pageTabContent { + width: 96%; + } +} + .detailPageContent, .detailPageContent > table { margin: 0 auto; padding: 0; diff --git a/dashboard-ui/devices/android/android.css b/dashboard-ui/devices/android/android.css index fcfec063a9..b6ee5d1c0d 100644 --- a/dashboard-ui/devices/android/android.css +++ b/dashboard-ui/devices/android/android.css @@ -3,7 +3,7 @@ } .viewMenuBar.semiTransparent { - background-color: rgba(15, 15, 15, .40); + background-color: rgba(15, 15, 15, .35); } .background-theme-b, paper-dialog.background-theme-b { diff --git a/dashboard-ui/scripts/globalize.js b/dashboard-ui/scripts/globalize.js index 7b4846aecd..b929614d30 100644 --- a/dashboard-ui/scripts/globalize.js +++ b/dashboard-ui/scripts/globalize.js @@ -19,33 +19,45 @@ function loadDictionary(name, culture) { - var deferred = DeferredBuilder.Deferred(); + return new Promise(function (resolve, reject) { - if (getDictionary(name, culture)) { - deferred.resolve(); - } else { + if (getDictionary(name, culture)) { + resolve(); + return; + } var url = getUrl(name, culture); var requestUrl = url + "?v=" + window.dashboardVersion; - $.getJSON(requestUrl).done(function (dictionary) { + fetch(requestUrl, { mode: 'no-cors' }).then(function (response) { - dictionaries[url] = dictionary; - deferred.resolve(); + if (response.status < 400) { - }).fail(function () { + return response.json(); - // If there's no dictionary for that language, grab English - $.getJSON(getUrl(name, 'en-US')).done(function (dictionary) { + } else { - dictionaries[url] = dictionary; - deferred.resolve(); + // Grab the english version + fetch(getUrl(name, 'en-US'), { mode: 'no-cors' }).then(function (response) { - }); + return response.json(); + + }).then(function (json) { + + dictionaries[url] = json; + resolve(); + }); + } + + }).then(function (json) { + + if (json) { + dictionaries[url] = json; + resolve(); + } }); - } - return deferred.promise(); + }); } var currentCulture = 'en-US'; @@ -55,7 +67,7 @@ currentCulture = value; - return $.when(loadDictionary('html', value), loadDictionary('javascript', value)); + return Promise.all([loadDictionary('html', value), loadDictionary('javascript', value)]); } function normalizeLocaleName(culture) { @@ -74,25 +86,25 @@ } function getDeviceCulture() { - var deferred = DeferredBuilder.Deferred(); - if (AppInfo.isNativeApp) { + return new Promise(function (resolve, reject) { - deferred.resolveWith(null, [navigator.language || navigator.userLanguage]); + if (AppInfo.isNativeApp) { - } else if (AppInfo.supportsUserDisplayLanguageSetting) { + resolve(navigator.language || navigator.userLanguage); - Logger.log('AppInfo.supportsUserDisplayLanguageSetting is true'); + } else if (AppInfo.supportsUserDisplayLanguageSetting) { - deferred.resolveWith(null, [AppSettings.displayLanguage()]); + Logger.log('AppInfo.supportsUserDisplayLanguageSetting is true'); - } else { + resolve(AppSettings.displayLanguage()); - Logger.log('Getting culture from document'); - deferred.resolveWith(null, [document.documentElement.getAttribute('data-culture')]); - } + } else { - return deferred.promise(); + Logger.log('Getting culture from document'); + resolve(document.documentElement.getAttribute('data-culture')); + } + }); } @@ -100,18 +112,15 @@ Logger.log('Entering Globalize.ensure'); - var deferred = DeferredBuilder.Deferred(); + return new Promise(function (resolve, reject) { - getDeviceCulture().done(function (culture) { + getDeviceCulture().then(function (culture) { - culture = normalizeLocaleName(culture || 'en-US'); + culture = normalizeLocaleName(culture || 'en-US'); - setCulture(culture).done(function () { - deferred.resolve(); + setCulture(culture).then(resolve); }); }); - - return deferred.promise(); } function translateDocument(html, dictionaryName) { diff --git a/dashboard-ui/scripts/registrationservices.js b/dashboard-ui/scripts/registrationservices.js index d7621b15a3..5ab3f16e83 100644 --- a/dashboard-ui/scripts/registrationservices.js +++ b/dashboard-ui/scripts/registrationservices.js @@ -224,7 +224,12 @@ var url = "http://mb3admin.com/admin/service/user/getPayPalEmail?id=" + pkg.owner; - $.getJSON(url).done(function (dev) { + fetch(url, { mode: 'no-cors' }).then(function (response) { + + return response.json(); + + }).then(function (dev) { + if (dev.payPalEmail) { $('#payPalEmail', page).val(dev.payPalEmail); @@ -232,6 +237,7 @@ $('#ppButton', page).hide(); } }); + } else { // Supporter-only feature $('.premiumHasPrice', page).hide(); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 715bfaa592..c07c1ea7e1 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -2265,6 +2265,10 @@ var AppInfo = {}; deps.push('bower_components/native-promise-only/lib/npo.src'); } + if (!window.fetch) { + deps.push('bower_components/fetch/fetch'); + } + require(deps, function () { loadImageCache(); @@ -2330,7 +2334,7 @@ var AppInfo = {}; function onConnectionManagerCreated(deferred) { - Globalize.ensure().done(function () { + Globalize.ensure().then(function () { document.title = Globalize.translateDocument(document.title, 'html'); $(function () { diff --git a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js index fc31c67fa9..725b9ae238 100644 --- a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js +++ b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js @@ -3113,16 +3113,23 @@ return deferred.promise(); } - // Load the new content. - $.ajax({ - url: fileUrl, - type: settings.type, - data: settings.data, - contentType: settings.contentType, - dataType: "html", - success: successFn, - error: this._loadError(absUrl, triggerData, settings, deferred) - }); + //// Load the new content. + //$.ajax({ + // url: fileUrl, + // type: settings.type, + // data: settings.data, + // contentType: settings.contentType, + // dataType: "html", + // success: successFn, + // error: this._loadError(absUrl, triggerData, settings, deferred) + //}); + fetch(fileUrl, { + mode: 'no-cors' + + }).then(function (response) { + + return response.text(); + }).then(successFn); return deferred.promise(); },