diff --git a/dashboard-ui/bower_components/emby-webcomponents/.bower.json b/dashboard-ui/bower_components/emby-webcomponents/.bower.json index 7cb78650f5..d72c483c28 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/.bower.json +++ b/dashboard-ui/bower_components/emby-webcomponents/.bower.json @@ -15,12 +15,12 @@ }, "devDependencies": {}, "ignore": [], - "version": "1.1.19", - "_release": "1.1.19", + "version": "1.1.22", + "_release": "1.1.22", "_resolution": { "type": "version", - "tag": "1.1.19", - "commit": "703a21b89d8650d4520fb2f5f16d10161721c3e4" + "tag": "1.1.22", + "commit": "e24e9e35b215c2982601535ccb2496c962dfc1a9" }, "_source": "git://github.com/MediaBrowser/emby-webcomponents.git", "_target": "~1.1.5", diff --git a/dashboard-ui/bower_components/emby-webcomponents/globalize.js b/dashboard-ui/bower_components/emby-webcomponents/globalize.js new file mode 100644 index 0000000000..b1a7c03657 --- /dev/null +++ b/dashboard-ui/bower_components/emby-webcomponents/globalize.js @@ -0,0 +1,245 @@ +define(['connectionManager', 'userSettings', 'events'], function (connectionManager, userSettings, events) { + + var allTranslations = {}; + var currentCulture; + + function getCurrentLocale() { + + return currentCulture; + } + + function getDefaultLanguage() { + + var culture = document.documentElement.getAttribute('data-culture'); + + if (culture) { + return culture; + } + + if (navigator.language) { + return navigator.language; + } + if (navigator.userLanguage) { + return navigator.userLanguage; + } + if (navigator.languages && navigator.languages.length) { + return navigator.languages[0]; + } + + return 'en-us'; + } + + function updateCurrentCulture() { + + var culture; + try { + culture = userSettings.get('language'); + } catch (err) { + + } + culture = culture || getDefaultLanguage(); + + currentCulture = normalizeLocaleName(culture); + + ensureTranslations(currentCulture); + } + + function ensureTranslations(culture) { + + for (var i in allTranslations) { + ensureTranslation(allTranslations[i], culture); + } + } + + function ensureTranslation(translationInfo, culture) { + + if (translationInfo.dictionaries[culture]) { + return Promise.resolve(); + } + + return loadTranslation(translationInfo.translations, culture).then(function (dictionary) { + + translationInfo.dictionaries[culture] = dictionary; + }); + } + + function normalizeLocaleName(culture) { + + culture = culture.replace('_', '-'); + + // If it's de-DE, convert to just de + var parts = culture.split('-'); + if (parts.length == 2) { + if (parts[0].toLowerCase() == parts[1].toLowerCase()) { + culture = parts[0].toLowerCase(); + } + } + + return culture.toLowerCase(); + } + + function getDictionary(module) { + + if (!module) { + module = defaultModule(); + } + + var translations = allTranslations[module]; + + if (!translations) { + return {}; + } + + return translations.dictionaries[getCurrentLocale()]; + } + + function loadTranslations(options) { + + allTranslations[options.name] = { + translations: options.translations, + dictionaries: {} + }; + + var locale = getCurrentLocale(); + + return ensureTranslation(allTranslations[options.name], locale); + } + + var cacheParam = new Date().getTime(); + function loadTranslation(translations, lang) { + + lang = normalizeLocaleName(lang); + + var filtered = translations.filter(function (t) { + return normalizeLocaleName(t.lang) == lang; + }); + + if (!filtered.length) { + filtered = translations.filter(function (t) { + return normalizeLocaleName(t.lang) == 'en-us'; + }); + } + + return new Promise(function (resolve, reject) { + + if (!filtered.length) { + resolve(); + return; + } + + var url = filtered[0].path; + + url += url.indexOf('?') == -1 ? '?' : '&'; + url += 'v=' + cacheParam; + + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + + xhr.onload = function (e) { + if (this.status < 400) { + resolve(JSON.parse(this.response)); + } + resolve({}); + }; + + xhr.onerror = function () { + resolve({}); + }; + xhr.send(); + }); + } + + function translateKey(key) { + + var parts = key.split('#'); + var module; + + if (parts.length > 1) { + module = parts[0]; + key = parts[1]; + } + + return translateKeyFromModule(key, module); + } + + function translateKeyFromModule(key, module) { + + return getDictionary(module)[key] || key; + } + + function replaceAll(str, find, replace) { + + return str.split(find).join(replace); + } + + function translate(key) { + + var val = translateKey(key); + + for (var i = 1; i < arguments.length; i++) { + + val = replaceAll(val, '{' + (i - 1) + '}', arguments[i]); + + } + + return val; + } + + function translateHtml(html, module) { + + if (!module) { + module = defaultModule(); + } + + if (!module) { + throw new Error('module cannot be null or empty'); + } + + var startIndex = html.indexOf('${'); + + if (startIndex == -1) { + return html; + } + + startIndex += 2; + var endIndex = html.indexOf('}', startIndex); + + if (endIndex == -1) { + return html; + } + + var key = html.substring(startIndex, endIndex); + var val = translateKeyFromModule(key, module); + + html = html.replace('${' + key + '}', val); + return translateHtml(html, module); + } + + var _defaultModule; + function defaultModule(val) { + + if (val) { + + _defaultModule = val; + } + + return _defaultModule; + } + + updateCurrentCulture(); + + events.on(connectionManager, 'localusersignedin', updateCurrentCulture); + events.on(userSettings, 'change', function (e, name) { + if (name == 'language') { + updateCurrentCulture(); + } + }); + + return { + getString: translate, + translate: translate, + translateHtml: translateHtml, + loadStrings: loadTranslations, + defaultModule: defaultModule + }; +}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-icon/.bower.json b/dashboard-ui/bower_components/iron-icon/.bower.json index 9784e3a3b7..f0167baf13 100644 --- a/dashboard-ui/bower_components/iron-icon/.bower.json +++ b/dashboard-ui/bower_components/iron-icon/.bower.json @@ -32,14 +32,14 @@ "web-component-tester": "^4.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, - "homepage": "https://github.com/PolymerElements/iron-icon", + "homepage": "https://github.com/polymerelements/iron-icon", "_release": "1.0.8", "_resolution": { "type": "version", "tag": "v1.0.8", "commit": "f36b38928849ef3853db727faa8c9ef104d611eb" }, - "_source": "git://github.com/PolymerElements/iron-icon.git", + "_source": "git://github.com/polymerelements/iron-icon.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/iron-icon" + "_originalSource": "polymerelements/iron-icon" } \ 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 e608ee7bb4..b58ab585d9 100644 --- a/dashboard-ui/bower_components/paper-input/.bower.json +++ b/dashboard-ui/bower_components/paper-input/.bower.json @@ -1,6 +1,6 @@ { "name": "paper-input", - "version": "1.1.8", + "version": "1.1.9", "description": "Material design text fields", "authors": [ "The Polymer Authors" @@ -47,11 +47,11 @@ "web-component-tester": "^4.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, - "_release": "1.1.8", + "_release": "1.1.9", "_resolution": { "type": "version", - "tag": "v1.1.8", - "commit": "96efaa0f707870d5a5999120467d67b8da806704" + "tag": "v1.1.9", + "commit": "4cb91098977573135b74121d6f4a2a301f44ce93" }, "_source": "git://github.com/polymerelements/paper-input.git", "_target": "^1.0.9", diff --git a/dashboard-ui/bower_components/paper-input/bower.json b/dashboard-ui/bower_components/paper-input/bower.json index d6d61b8e22..a82eb70701 100644 --- a/dashboard-ui/bower_components/paper-input/bower.json +++ b/dashboard-ui/bower_components/paper-input/bower.json @@ -1,6 +1,6 @@ { "name": "paper-input", - "version": "1.1.8", + "version": "1.1.9", "description": "Material design text fields", "authors": [ "The Polymer Authors" diff --git a/dashboard-ui/bower_components/paper-input/paper-input-addon-behavior.html b/dashboard-ui/bower_components/paper-input/paper-input-addon-behavior.html index 0b021a5dd4..41081c7136 100644 --- a/dashboard-ui/bower_components/paper-input/paper-input-addon-behavior.html +++ b/dashboard-ui/bower_components/paper-input/paper-input-addon-behavior.html @@ -31,10 +31,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN /** * The function called by `` when the input value or validity changes. * @param {{ - * inputElement: (Node|undefined), + * inputElement: (Element|undefined), * value: (string|undefined), - * invalid: (boolean|undefined) - * }} state All properties are optional - + * invalid: boolean + * }} state - * inputElement: The input element. * value: The input value. * invalid: True if the input value is invalid. diff --git a/dashboard-ui/bower_components/paper-input/paper-input-char-counter.html b/dashboard-ui/bower_components/paper-input/paper-input-char-counter.html index ec427e0d9b..aa3ee51f41 100644 --- a/dashboard-ui/bower_components/paper-input/paper-input-char-counter.html +++ b/dashboard-ui/bower_components/paper-input/paper-input-char-counter.html @@ -65,6 +65,17 @@ Custom property | Description | Default } }, + /** + * This overrides the update function in PaperInputAddonBehavior. + * @param {{ + * inputElement: (Element|undefined), + * value: (string|undefined), + * invalid: boolean + * }} state - + * inputElement: The input element. + * value: The input value. + * invalid: True if the input value is invalid. + */ update: function(state) { if (!state.inputElement) { return; @@ -72,7 +83,7 @@ Custom property | Description | Default state.value = state.value || ''; - var counter = state.value.length; + var counter = state.value.length.toString(); if (state.inputElement.hasAttribute('maxlength')) { counter += '/' + state.inputElement.getAttribute('maxlength'); diff --git a/dashboard-ui/bower_components/paper-input/paper-input-error.html b/dashboard-ui/bower_components/paper-input/paper-input-error.html index 4b935ef3b2..645f1e722b 100644 --- a/dashboard-ui/bower_components/paper-input/paper-input-error.html +++ b/dashboard-ui/bower_components/paper-input/paper-input-error.html @@ -76,6 +76,17 @@ Custom property | Description | Default } }, + /** + * This overrides the update function in PaperInputAddonBehavior. + * @param {{ + * inputElement: (Element|undefined), + * value: (string|undefined), + * invalid: boolean + * }} state - + * inputElement: The input element. + * value: The input value. + * invalid: True if the input value is invalid. + */ update: function(state) { this._setInvalid(state.invalid); } diff --git a/dashboard-ui/bower_components/polymer/.bower.json b/dashboard-ui/bower_components/polymer/.bower.json index 4ba14e0db6..954f23319a 100644 --- a/dashboard-ui/bower_components/polymer/.bower.json +++ b/dashboard-ui/bower_components/polymer/.bower.json @@ -34,6 +34,6 @@ "commit": "61fac558012d9ef56ea78ed5435de0c418a4afbb" }, "_source": "git://github.com/Polymer/polymer.git", - "_target": "^1.2.0", + "_target": "^1.0.0", "_originalSource": "Polymer/polymer" } \ No newline at end of file diff --git a/dashboard-ui/components/fileorganizer/fileorganizer.js b/dashboard-ui/components/fileorganizer/fileorganizer.js index f8fc32351e..7667150f31 100644 --- a/dashboard-ui/components/fileorganizer/fileorganizer.js +++ b/dashboard-ui/components/fileorganizer/fileorganizer.js @@ -193,7 +193,7 @@ var html = ''; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); diff --git a/dashboard-ui/components/filterdialog/filterdialog.js b/dashboard-ui/components/filterdialog/filterdialog.js index 0baf5dbc12..3c1d3f33be 100644 --- a/dashboard-ui/components/filterdialog/filterdialog.js +++ b/dashboard-ui/components/filterdialog/filterdialog.js @@ -521,7 +521,7 @@ dlg.classList.add('formDialog'); dlg.classList.add('filterDialog'); - dlg.innerHTML = Globalize.translateDocument(template); + dlg.innerHTML = Globalize.translateHtml(template); setVisibility(dlg, options); document.body.appendChild(dlg); diff --git a/dashboard-ui/components/guestinviter/guestinviter.js b/dashboard-ui/components/guestinviter/guestinviter.js index e3c2014e4b..84bf3c708d 100644 --- a/dashboard-ui/components/guestinviter/guestinviter.js +++ b/dashboard-ui/components/guestinviter/guestinviter.js @@ -106,7 +106,7 @@ var html = ''; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); diff --git a/dashboard-ui/components/imagedownloader/imagedownloader.js b/dashboard-ui/components/imagedownloader/imagedownloader.js index 5b115347cc..d6f5650f69 100644 --- a/dashboard-ui/components/imagedownloader/imagedownloader.js +++ b/dashboard-ui/components/imagedownloader/imagedownloader.js @@ -289,7 +289,7 @@ html += ''; html += '
'; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); html += '
'; dlg.innerHTML = html; diff --git a/dashboard-ui/components/imageeditor/imageeditor.js b/dashboard-ui/components/imageeditor/imageeditor.js index d708e0ba8d..4823e6251d 100644 --- a/dashboard-ui/components/imageeditor/imageeditor.js +++ b/dashboard-ui/components/imageeditor/imageeditor.js @@ -262,7 +262,7 @@ html += ''; html += '
'; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); html += '
'; dlg.innerHTML = html; diff --git a/dashboard-ui/components/imageuploader/imageuploader.js b/dashboard-ui/components/imageuploader/imageuploader.js index 8c1f5b0a53..f45ab2c1e7 100644 --- a/dashboard-ui/components/imageuploader/imageuploader.js +++ b/dashboard-ui/components/imageuploader/imageuploader.js @@ -154,7 +154,7 @@ html += ''; html += '
'; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); html += '
'; dlg.innerHTML = html; diff --git a/dashboard-ui/components/itemidentifier/itemidentifier.js b/dashboard-ui/components/itemidentifier/itemidentifier.js index 28c15d2cde..3c46e12d2e 100644 --- a/dashboard-ui/components/itemidentifier/itemidentifier.js +++ b/dashboard-ui/components/itemidentifier/itemidentifier.js @@ -295,7 +295,7 @@ dlg.classList.add('background-theme-b'); var html = ''; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); @@ -361,7 +361,7 @@ dlg.classList.add('background-theme-a'); var html = ''; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); diff --git a/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js b/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js index 37b396b24b..78c8571616 100644 --- a/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js +++ b/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js @@ -215,7 +215,7 @@ html += ''; html += '
'; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); html += '
'; dlg.innerHTML = html; diff --git a/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js index 237061340e..9b75696eb9 100644 --- a/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js +++ b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js @@ -169,7 +169,7 @@ html += ''; html += '
'; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); html += '
'; dlg.innerHTML = html; diff --git a/dashboard-ui/components/metadataeditor/metadataeditor.js b/dashboard-ui/components/metadataeditor/metadataeditor.js index a6415e8d40..1ed6d4eaff 100644 --- a/dashboard-ui/components/metadataeditor/metadataeditor.js +++ b/dashboard-ui/components/metadataeditor/metadataeditor.js @@ -1232,7 +1232,7 @@ var html = ''; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); @@ -1267,7 +1267,7 @@ var template = this.response; - elem.innerHTML = Globalize.translateDocument(template); + elem.innerHTML = Globalize.translateHtml(template); elem.querySelector('.btnCancel').classList.add('hide'); diff --git a/dashboard-ui/components/metadataeditor/personeditor.js b/dashboard-ui/components/metadataeditor/personeditor.js index 6e20fa4209..bba52e65a5 100644 --- a/dashboard-ui/components/metadataeditor/personeditor.js +++ b/dashboard-ui/components/metadataeditor/personeditor.js @@ -23,7 +23,7 @@ var html = ''; var submitted = false; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); diff --git a/dashboard-ui/components/recordingcreator/recordingcreator.js b/dashboard-ui/components/recordingcreator/recordingcreator.js index f0a2051ba6..dacf4e04df 100644 --- a/dashboard-ui/components/recordingcreator/recordingcreator.js +++ b/dashboard-ui/components/recordingcreator/recordingcreator.js @@ -346,7 +346,7 @@ var html = ''; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); dlg.innerHTML = html; document.body.appendChild(dlg); diff --git a/dashboard-ui/components/subtitleeditor/subtitleeditor.js b/dashboard-ui/components/subtitleeditor/subtitleeditor.js index 6ad914a2a6..1139cf3ab1 100644 --- a/dashboard-ui/components/subtitleeditor/subtitleeditor.js +++ b/dashboard-ui/components/subtitleeditor/subtitleeditor.js @@ -370,7 +370,7 @@ html += ''; html += '
'; - html += Globalize.translateDocument(template); + html += Globalize.translateHtml(template); html += '
'; dlg.innerHTML = html; diff --git a/dashboard-ui/components/tvguide/tvguide.js b/dashboard-ui/components/tvguide/tvguide.js index 0bfd2fe335..644454e1f4 100644 --- a/dashboard-ui/components/tvguide/tvguide.js +++ b/dashboard-ui/components/tvguide/tvguide.js @@ -476,7 +476,7 @@ var template = this.response; var tabContent = options.element; - tabContent.innerHTML = Globalize.translateDocument(template); + tabContent.innerHTML = Globalize.translateHtml(template); tabContent.querySelector('.programGrid').addEventListener('scroll', function (e) { diff --git a/dashboard-ui/legacy/fnchecked.js b/dashboard-ui/legacy/fnchecked.js new file mode 100644 index 0000000000..2a88682a57 --- /dev/null +++ b/dashboard-ui/legacy/fnchecked.js @@ -0,0 +1,12 @@ +// TODO: This needs to be deprecated, but it's used heavily +$.fn.checked = function (value) { + if (value === true || value === false) { + // Set the value of the checkbox + return $(this).each(function () { + this.checked = value; + }); + } else { + // Return check state + return this.length && this[0].checked; + } +}; \ No newline at end of file diff --git a/dashboard-ui/scripts/globalize.js b/dashboard-ui/scripts/globalize.js deleted file mode 100644 index d0657e3724..0000000000 --- a/dashboard-ui/scripts/globalize.js +++ /dev/null @@ -1,181 +0,0 @@ -(function () { - - var dictionaries = {}; - - function getUrl(culture) { - - var parts = culture.split('-'); - if (parts.length == 2) { - parts[1] = parts[1].toUpperCase(); - culture = parts.join('-'); - } - - return 'strings/' + culture + '.json'; - } - function getDictionary(culture) { - - return dictionaries[getUrl(culture)]; - } - - function loadDictionary(culture) { - - return new Promise(function (resolve, reject) { - - if (getDictionary(culture)) { - console.log('Globalize loadDictionary resolved.'); - resolve(); - return; - } - - var url = getUrl(culture); - - var requestUrl = url + "?v=" + AppInfo.appVersion; - - console.log('Requesting ' + requestUrl); - - var xhr = new XMLHttpRequest(); - xhr.open('GET', requestUrl, true); - - var onError = function () { - - console.log('Dictionary not found. Reverting to english'); - - // Grab the english version - var xhr2 = new XMLHttpRequest(); - xhr2.open('GET', getUrl('en-US'), true); - - xhr2.onload = function (e) { - dictionaries[url] = JSON.parse(this.response); - console.log('Globalize loadDictionary resolved.'); - resolve(); - }; - - xhr2.send(); - }; - - xhr.onload = function (e) { - - console.log('Globalize response status: ' + this.status); - - if (this.status < 400) { - - dictionaries[url] = JSON.parse(this.response); - console.log('Globalize loadDictionary resolved.'); - resolve(); - - } else { - onError(); - } - }; - - xhr.onerror = onError; - - xhr.send(); - }); - } - - var currentCulture = 'en-US'; - function setCulture(value) { - - console.log('Setting culture to ' + value); - currentCulture = value; - - return loadDictionary(value); - } - - function normalizeLocaleName(culture) { - - culture = culture.replace('_', '-'); - - // If it's de-DE, convert to just de - var parts = culture.split('-'); - if (parts.length == 2) { - if (parts[0].toLowerCase() == parts[1].toLowerCase()) { - culture = parts[0].toLowerCase(); - } - } - - return culture; - } - - function getDeviceCulture() { - - return new Promise(function (resolve, reject) { - - if (Dashboard.isConnectMode()) { - - resolve(navigator.language || navigator.userLanguage); - - } else { - - console.log('Getting culture from document'); - resolve(document.documentElement.getAttribute('data-culture')); - } - }); - } - - - function ensure() { - - console.log('Entering Globalize.ensure'); - - return getDeviceCulture().then(function (culture) { - - culture = normalizeLocaleName(culture || 'en-US'); - - return setCulture(culture); - }); - } - - function translateDocument(html) { - - var glossary = getDictionary(currentCulture) || {}; - return translateHtml(html, glossary); - } - - function translateHtml(html, dictionary) { - - var startIndex = html.indexOf('${'); - - if (startIndex == -1) { - return html; - } - - startIndex += 2; - var endIndex = html.indexOf('}', startIndex); - - if (endIndex == -1) { - return html; - } - - var key = html.substring(startIndex, endIndex); - var val = dictionary[key] || key; - - html = html.replace('${' + key + '}', val); - - return translateHtml(html, dictionary); - } - - // Mimic Globalize api - // https://github.com/jquery/globalize - // Maybe later switch to it - - window.Globalize = { - translate: function (key) { - - var glossary = getDictionary(currentCulture) || {}; - var val = glossary[key] || key; - - for (var i = 1; i < arguments.length; i++) { - - val = val.replace('{' + (i - 1) + '}', arguments[i]); - - } - - return val; - }, - ensure: ensure, - translateDocument: translateDocument - }; - -})(); \ No newline at end of file diff --git a/dashboard-ui/scripts/livetvguideprovider.js b/dashboard-ui/scripts/livetvguideprovider.js index 26710ab12d..c9ba459a8f 100644 --- a/dashboard-ui/scripts/livetvguideprovider.js +++ b/dashboard-ui/scripts/livetvguideprovider.js @@ -22,7 +22,7 @@ var html = this.response; var elem = page.querySelector('.providerTemplate'); - elem.innerHTML = Globalize.translateDocument(html); + elem.innerHTML = Globalize.translateHtml(html); $(elem).trigger('create'); init(page, type, providerId); diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index c704bad3ee..abfe888eec 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -1729,7 +1729,9 @@ define(['appSettings', 'userSettings'], function (appSettings, userSettings) { window.MediaPlayer = new mediaPlayer(); - window.MediaController.registerPlayer(window.MediaPlayer); - window.MediaController.setActivePlayer(window.MediaPlayer, window.MediaPlayer.getTargetsInternal()[0]); + window.MediaPlayer.init = function() { + window.MediaController.registerPlayer(window.MediaPlayer); + window.MediaController.setActivePlayer(window.MediaPlayer, window.MediaPlayer.getTargetsInternal()[0]); + }; }); \ No newline at end of file diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index c92ceff2df..37bc6c8acf 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -33,7 +33,7 @@ var Dashboard = { html = html.substring(0, lastIndex) + html.substring(lastIndex + 3); } - return Globalize.translateDocument(html, 'html'); + return Globalize.translateHtml(html, 'core'); }, isConnectMode: function () { @@ -1740,6 +1740,7 @@ var AppInfo = {}; hammer: bowerPath + "/hammerjs/hammer.min", layoutManager: embyWebComponentsBowerPath + "/layoutmanager", focusManager: embyWebComponentsBowerPath + "/focusmanager", + globalize: embyWebComponentsBowerPath + "/globalize", imageLoader: embyWebComponentsBowerPath + "/images/imagehelper" }; @@ -1933,10 +1934,6 @@ var AppInfo = {}; return ConnectionManager; }); - define("globalize", [], function () { - return Globalize; - }); - define('apiClientResolver', [], function () { return function () { return window.ApiClient; @@ -2047,7 +2044,6 @@ var AppInfo = {}; } deps.push('scripts/mediacontroller'); - deps.push('scripts/globalize'); deps.push('paper-drawer-panel'); @@ -2103,7 +2099,6 @@ var AppInfo = {}; var promises = []; deps = []; - deps.push('scripts/mediaplayer'); deps.push('emby-icons'); deps.push('paper-icon-button'); deps.push('paper-button'); @@ -2111,7 +2106,6 @@ var AppInfo = {}; promises.push(getRequirePromise(deps)); - promises.push(Globalize.ensure()); promises.push(createConnectionManager(credentialProviderFactory, Dashboard.capabilities())); Promise.all(promises).then(function () { @@ -2119,60 +2113,82 @@ var AppInfo = {}; console.log('initAfterDependencies promises resolved'); MediaController.init(); - document.title = Globalize.translateDocument(document.title, 'html'); + require(['globalize'], function (globalize) { - var mainDrawerPanelContent = document.querySelector('.mainDrawerPanelContent'); + window.Globalize = globalize; - if (mainDrawerPanelContent) { - - var newHtml = mainDrawerPanelContent.innerHTML.substring(4); - newHtml = newHtml.substring(0, newHtml.length - 3); - - var srch = 'data-require='; - var index = newHtml.indexOf(srch); - var depends; - - if (index != -1) { - - var requireAttribute = newHtml.substring(index + srch.length + 1); - - requireAttribute = requireAttribute.substring(0, requireAttribute.indexOf('"')); - depends = requireAttribute.split(','); - } - - depends = depends || []; - - if (newHtml.indexOf('type-interior') != -1) { - addLegacyDependencies(depends, window.location.href); - } - - require(depends, function () { - - // TODO: This needs to be deprecated, but it's used heavily - $.fn.checked = function (value) { - if (value === true || value === false) { - // Set the value of the checkbox - return $(this).each(function () { - this.checked = value; - }); - } else { - // Return check state - return this.length && this[0].checked; - } - }; - - // Don't like having to use jQuery here, but it takes care of making sure that embedded script executes - $(mainDrawerPanelContent).html(Globalize.translateDocument(newHtml, 'html')); - onAppReady(); - }); - return; - } - - onAppReady(); + loadCoreDictionary(globalize).then(onGlobalizeInit); + }); }); }); } + function loadCoreDictionary(globalize) { + + var baseUrl = 'strings/'; + + var languages = ['ar', 'bg-BG', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'en-US', 'en-AR', 'en-MX', 'es', 'fi', 'fr', 'gsw', 'he', 'hr', 'hu', 'id', 'it', 'kk', 'ko', 'ms', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sl-SI', 'sv', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW']; + + var translations = languages.map(function (i) { + return { + lang: i, + path: baseUrl + i + '.json' + }; + }); + + globalize.defaultModule('core'); + + return globalize.loadStrings({ + name: 'core', + translations: translations + }); + } + + function onGlobalizeInit() { + document.title = Globalize.translateHtml(document.title, 'core'); + + var mainDrawerPanelContent = document.querySelector('.mainDrawerPanelContent'); + + if (mainDrawerPanelContent) { + + var newHtml = mainDrawerPanelContent.innerHTML.substring(4); + newHtml = newHtml.substring(0, newHtml.length - 3); + + var srch = 'data-require='; + var index = newHtml.indexOf(srch); + var depends; + + if (index != -1) { + + var requireAttribute = newHtml.substring(index + srch.length + 1); + + requireAttribute = requireAttribute.substring(0, requireAttribute.indexOf('"')); + depends = requireAttribute.split(','); + } + + depends = depends || []; + + depends.push('scripts/mediaplayer'); + depends.push('legacy/fnchecked'); + + if (newHtml.indexOf('type-interior') != -1) { + addLegacyDependencies(depends, window.location.href); + } + + require(depends, function () { + + MediaPlayer.init(); + + // Don't like having to use jQuery here, but it takes care of making sure that embedded script executes + $(mainDrawerPanelContent).html(Globalize.translateHtml(newHtml, 'core')); + onAppReady(); + }); + return; + } + + onAppReady(); + } + function onAppReady() { console.log('Begin onAppReady'); diff --git a/dashboard-ui/scripts/wizardlivetvguide.js b/dashboard-ui/scripts/wizardlivetvguide.js index c9609e0440..9277c9f182 100644 --- a/dashboard-ui/scripts/wizardlivetvguide.js +++ b/dashboard-ui/scripts/wizardlivetvguide.js @@ -49,7 +49,7 @@ }).then(function (html) { var elem = page.querySelector('.providerTemplate'); - elem.innerHTML = Globalize.translateDocument(html); + elem.innerHTML = Globalize.translateHtml(html); init(page, type); });