diff --git a/dashboard-ui/mysyncjob.html b/dashboard-ui/mysyncjob.html index 94c8c358b3..1c537cfc77 100644 --- a/dashboard-ui/mysyncjob.html +++ b/dashboard-ui/mysyncjob.html @@ -1,4 +1,4 @@ -
+
diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 1f9567e3bc..4828c46143 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -1,4 +1,4 @@ -define(['scrollHelper', 'appSettings', 'appStorage', 'apphost', 'datetime', 'itemHelper', 'mediaInfo', 'scrollStyles'], function (scrollHelper, appSettings, appStorage, appHost, datetime, itemHelper, mediaInfo) { +define(['scrollHelper', 'viewManager', 'appSettings', 'appStorage', 'apphost', 'datetime', 'itemHelper', 'mediaInfo', 'scrollStyles'], function (scrollHelper, viewManager, appSettings, appStorage, appHost, datetime, itemHelper, mediaInfo) { function parentWithClass(elem, className) { @@ -381,9 +381,7 @@ if (window.location.href.toLowerCase().indexOf(url.toLowerCase()) != -1) { - if (window.$) { - afterNavigate.call($.mobile.activePage); - } + afterNavigate.call(viewManager.currentView()); } else { pageClassOn('pagebeforeshow', 'page', afterNavigate); diff --git a/dashboard-ui/scripts/myprofile.js b/dashboard-ui/scripts/myprofile.js index 482cd11082..a59a1a0235 100644 --- a/dashboard-ui/scripts/myprofile.js +++ b/dashboard-ui/scripts/myprofile.js @@ -65,15 +65,6 @@ } - function processImageChangeResult() { - - Dashboard.hideLoadingMsg(); - - var page = $($.mobile.activePage)[0]; - - reloadUser(page); - } - function onFileReaderError(evt) { Dashboard.hideLoadingMsg(); @@ -101,11 +92,6 @@ }; } - function onFileReaderOnloadStart(evt) { - - $('#fldUpload', $.mobile.activePage).hide(); - } - function onFileReaderAbort(evt) { Dashboard.hideLoadingMsg(); @@ -130,7 +116,9 @@ var reader = new FileReader(); reader.onerror = onFileReaderError; - reader.onloadstart = onFileReaderOnloadStart; + reader.onloadstart = function() { + $('#fldUpload', page).hide(); + }; reader.onabort = onFileReaderAbort; // Closure to capture the file information. @@ -147,15 +135,6 @@ reader.readAsDataURL(file); } - function onImageDrop(e) { - - e.preventDefault(); - - setFiles($.mobile.activePage, e.originalEvent.dataTransfer.files); - - return false; - } - function onImageDragOver(e) { e.preventDefault(); @@ -165,41 +144,20 @@ return false; } - function myProfilePage() { - - var self = this; - - self.onImageSubmit = function () { - - var file = currentFile; - - if (!file) { - return false; - } - - if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") { - return false; - } - - Dashboard.showLoadingMsg(); - - var userId = getParameterByName("userId"); - - ApiClient.uploadUserImage(userId, 'Primary', file).then(processImageChangeResult); - - return false; - }; - } - - window.MyProfilePage = new myProfilePage(); - $(document).on('pageinit', "#userImagePage", function () { var page = this; reloadUser(page); - $("#userImageDropZone", page).on('dragover', onImageDragOver).on('drop', onImageDrop); + $("#userImageDropZone", page).on('dragover', onImageDragOver).on('drop', function(e) { + + e.preventDefault(); + + setFiles(page, e.originalEvent.dataTransfer.files); + + return false; + }); $('#btnDeleteImage', page).on('click', function () { @@ -211,12 +169,46 @@ var userId = getParameterByName("userId"); - ApiClient.deleteUserImage(userId, "primary").then(processImageChangeResult); + ApiClient.deleteUserImage(userId, "primary").then(function () { + + Dashboard.hideLoadingMsg(); + + reloadUser(page); + }); }); }); }); - $('.newImageForm').off('submit', MyProfilePage.onImageSubmit).on('submit', MyProfilePage.onImageSubmit); + $('.newImageForm').on('submit', function () { + + var self = this; + + self.onImageSubmit = function () { + + var file = currentFile; + + if (!file) { + return false; + } + + if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") { + return false; + } + + Dashboard.showLoadingMsg(); + + var userId = getParameterByName("userId"); + + ApiClient.uploadUserImage(userId, 'Primary', file).then(function () { + + Dashboard.hideLoadingMsg(); + + reloadUser(page); + }); + + return false; + }; + }); page.querySelector('#uploadUserImage').addEventListener('change', function (e) { setFiles(page, e.target.files); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 0cd9b6c0da..d8c7be2243 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -52,7 +52,7 @@ var Dashboard = { // Bounce to the login screen, but not if a password entry fails, obviously if (url.indexOf('/password') == -1 && url.indexOf('/authenticate') == -1 && - !$($.mobile.activePage).is('.standalonePage')) { + !ViewManager.currentView().classList.contains('.standalonePage')) { if (data.errorCode == "ParentalControl") { @@ -1221,7 +1221,9 @@ var Dashboard = { }, exitOnBack: function () { - return $($.mobile.activePage).is('#indexPage'); + + var currentView = ViewManager.currentView(); + return !currentView || currentView.id == 'indexPage'; }, exit: function () { @@ -1811,6 +1813,7 @@ var AppInfo = {}; define("tvguide", [embyWebComponentsBowerPath + "/guide/guide", 'embyRouter'], returnFirstDependency); define("viewManager", [embyWebComponentsBowerPath + "/viewmanager/viewmanager"], function (viewManager) { + window.ViewManager = viewManager; viewManager.dispatchPageEvents(true); return viewManager; }); @@ -2813,9 +2816,10 @@ var AppInfo = {}; defineRoute({ path: '/mysyncjob.html', - dependencies: [], + dependencies: ['paper-fab', 'paper-item-body', 'paper-icon-item'], autoFocus: false, - transition: 'fade' + transition: 'fade', + controller: 'scripts/syncjob' }); defineRoute({ @@ -2972,8 +2976,10 @@ var AppInfo = {}; defineRoute({ path: '/syncjob.html', - dependencies: [], - autoFocus: false + dependencies: ['paper-fab', 'paper-item-body', 'paper-icon-item'], + autoFocus: false, + transition: 'fade', + controller: 'scripts/syncjob' }); defineRoute({ diff --git a/dashboard-ui/scripts/syncjob.js b/dashboard-ui/scripts/syncjob.js index aca4ad5035..f8ff1612f7 100644 --- a/dashboard-ui/scripts/syncjob.js +++ b/dashboard-ui/scripts/syncjob.js @@ -33,10 +33,7 @@ return function (targetId) { - var deferred = $.Deferred(); - - deferred.resolveWith(null, [dialogOptions]); - return deferred.promise(); + return Promise.resolve(dialogOptions); }; } @@ -367,63 +364,54 @@ } - function onWebSocketMessage(e, msg) { + return function (view, params) { - var page = $.mobile.activePage; + view.querySelector('.syncJobForm').addEventListener('submit', function (e) { - if (msg.MessageType == "SyncJob") { - loadJobInfo(page, msg.Data.Job, msg.Data.JobItems); - } - } + saveJob(view); + e.preventDefault(); + return false; + }); - function startListening(page) { + function onWebSocketMessage(e, msg) { - var startParams = "0,1500"; - - startParams += "," + getParameterByName('id'); - - if (ApiClient.isWebSocketOpen()) { - ApiClient.sendWebSocketMessage("SyncJobStart", startParams); + if (msg.MessageType == "SyncJob") { + loadJobInfo(view, msg.Data.Job, msg.Data.JobItems); + } } - } + function startListening(page) { - function stopListening() { + var startParams = "0,1500"; - if (ApiClient.isWebSocketOpen()) { - ApiClient.sendWebSocketMessage("SyncJobStop", ""); + startParams += "," + getParameterByName('id'); + + if (ApiClient.isWebSocketOpen()) { + ApiClient.sendWebSocketMessage("SyncJobStart", startParams); + } } - } + function stopListening() { - function onSubmit() { - var form = this; + if (ApiClient.isWebSocketOpen()) { + ApiClient.sendWebSocketMessage("SyncJobStop", ""); + } - var page = $(form).parents('.page'); + } - saveJob(page); + view.addEventListener('viewshow', function () { + var page = this; + loadJob(page); - return false; - } + startListening(page); + Events.on(ApiClient, "websocketmessage", onWebSocketMessage); + }); - $(document).on('pageinit', ".syncJobPage", function () { + view.addEventListener('viewbeforehide', function () { - $('.syncJobForm').off('submit', onSubmit).on('submit', onSubmit); - - }).on('pageshow', ".syncJobPage", function () { - - var page = this; - loadJob(page); - - startListening(page); - Events.on(ApiClient, "websocketmessage", onWebSocketMessage); - - }).on('pagebeforehide', ".syncJobPage", function () { - - var page = this; - - stopListening(); - Events.off(ApiClient, "websocketmessage", onWebSocketMessage); - }); + stopListening(); + Events.off(ApiClient, "websocketmessage", onWebSocketMessage); + }); + }; }); \ No newline at end of file diff --git a/dashboard-ui/syncjob.html b/dashboard-ui/syncjob.html index 53c2c2535c..75ae6339ea 100644 --- a/dashboard-ui/syncjob.html +++ b/dashboard-ui/syncjob.html @@ -1,4 +1,4 @@ -
+