From bbfda77868b841ecbbc57bad9b9a8a19da0a8ca5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 8 Jun 2015 00:47:19 -0400 Subject: [PATCH] modularize scripts --- dashboard-ui/channelsettings.html | 6 +- dashboard-ui/devicesupload.html | 5 +- dashboard-ui/edititemsubtitles.html | 7 +-- dashboard-ui/forgotpassword.html | 6 +- dashboard-ui/forgotpasswordpin.html | 6 +- dashboard-ui/notificationsetting.html | 6 +- dashboard-ui/notificationsettings.html | 2 +- dashboard-ui/scripts/channelsettings.js | 66 ++++++++++---------- dashboard-ui/scripts/devicesupload.js | 28 ++++----- dashboard-ui/scripts/edititemsubtitles.js | 30 +++++---- dashboard-ui/scripts/forgotpassword.js | 19 +++--- dashboard-ui/scripts/forgotpasswordpin.js | 19 +++--- dashboard-ui/scripts/notificationsetting.js | 24 ++++--- dashboard-ui/scripts/notificationsettings.js | 2 +- dashboard-ui/scripts/site.js | 2 + 15 files changed, 95 insertions(+), 133 deletions(-) diff --git a/dashboard-ui/channelsettings.html b/dashboard-ui/channelsettings.html index c4291b8d90..8e1afa1193 100644 --- a/dashboard-ui/channelsettings.html +++ b/dashboard-ui/channelsettings.html @@ -4,7 +4,7 @@ ${TitlePlugins} -
+
@@ -73,10 +73,6 @@
- -
diff --git a/dashboard-ui/devicesupload.html b/dashboard-ui/devicesupload.html index e5720d5271..3162deb1a6 100644 --- a/dashboard-ui/devicesupload.html +++ b/dashboard-ui/devicesupload.html @@ -4,7 +4,7 @@ ${TitleDevices} -
+
@@ -60,9 +60,6 @@
-
diff --git a/dashboard-ui/edititemsubtitles.html b/dashboard-ui/edititemsubtitles.html index 60f20f88e8..8b941825d7 100644 --- a/dashboard-ui/edititemsubtitles.html +++ b/dashboard-ui/edititemsubtitles.html @@ -4,7 +4,7 @@ Emby -
+
@@ -49,11 +49,6 @@

             
- - -
diff --git a/dashboard-ui/forgotpassword.html b/dashboard-ui/forgotpassword.html index fda60faf09..3e4cf9ee9c 100644 --- a/dashboard-ui/forgotpassword.html +++ b/dashboard-ui/forgotpassword.html @@ -4,7 +4,7 @@ ${TitleForgotPassword} -
+
@@ -36,10 +36,6 @@
- -
diff --git a/dashboard-ui/forgotpasswordpin.html b/dashboard-ui/forgotpasswordpin.html index e48cef8dd6..c4ce4017de 100644 --- a/dashboard-ui/forgotpasswordpin.html +++ b/dashboard-ui/forgotpasswordpin.html @@ -4,7 +4,7 @@ ${TitlePasswordReset} -
+
@@ -33,10 +33,6 @@
- -
diff --git a/dashboard-ui/notificationsetting.html b/dashboard-ui/notificationsetting.html index 58f191698a..fe209d524c 100644 --- a/dashboard-ui/notificationsetting.html +++ b/dashboard-ui/notificationsetting.html @@ -4,7 +4,7 @@ ${TitleNotifications} -
+
@@ -85,10 +85,6 @@
- -
diff --git a/dashboard-ui/notificationsettings.html b/dashboard-ui/notificationsettings.html index 404d138724..2fa0f91869 100644 --- a/dashboard-ui/notificationsettings.html +++ b/dashboard-ui/notificationsettings.html @@ -4,7 +4,7 @@ ${TitleNotifications} -
+
diff --git a/dashboard-ui/scripts/channelsettings.js b/dashboard-ui/scripts/channelsettings.js index 92ffad87c6..a4d60e5b1e 100644 --- a/dashboard-ui/scripts/channelsettings.js +++ b/dashboard-ui/scripts/channelsettings.js @@ -54,7 +54,35 @@ Dashboard.hideLoadingMsg(); } - $(document).on('pageinit', "#channelSettingsPage", function () { + function onSubmit() { + + Dashboard.showLoadingMsg(); + + var form = this; + + ApiClient.getNamedConfiguration("channels").done(function (config) { + + // This should be null if empty + config.PreferredStreamingWidth = $('#selectChannelResolution', form).val() || null; + config.MaxDownloadAge = $('#txtDownloadAge', form).val() || null; + config.DownloadSizeLimit = $('#txtDownloadSizeLimit', form).val() || null; + + config.DownloadPath = $('#txtCachePath', form).val() || null; + + config.DownloadingChannels = $('.chkChannelDownload:checked', form) + .get() + .map(function (i) { + return i.getAttribute('data-channelid'); + }); + + ApiClient.updateNamedConfiguration("channels", config).done(Dashboard.processServerConfigurationUpdateResult); + }); + + // Disable default form submission + return false; + } + + $(document).on('pageinitdepends', "#channelSettingsPage", function () { var page = this; @@ -78,7 +106,9 @@ }); }); - }).on('pageshow', "#channelSettingsPage", function () { + $('.channelSettingsForm').off('submit', onSubmit).on('submit', onSubmit); + + }).on('pageshowready', "#channelSettingsPage", function () { Dashboard.showLoadingMsg(); @@ -98,36 +128,4 @@ }); - function onSubmit() { - - Dashboard.showLoadingMsg(); - - var form = this; - - ApiClient.getNamedConfiguration("channels").done(function (config) { - - // This should be null if empty - config.PreferredStreamingWidth = $('#selectChannelResolution', form).val() || null; - config.MaxDownloadAge = $('#txtDownloadAge', form).val() || null; - config.DownloadSizeLimit = $('#txtDownloadSizeLimit', form).val() || null; - - config.DownloadPath = $('#txtCachePath', form).val() || null; - - config.DownloadingChannels = $('.chkChannelDownload:checked', form) - .get() - .map(function(i) { - return i.getAttribute('data-channelid'); - }); - - ApiClient.updateNamedConfiguration("channels", config).done(Dashboard.processServerConfigurationUpdateResult); - }); - - // Disable default form submission - return false; - } - - window.ChannelSettingsPage = { - onSubmit: onSubmit - }; - })(jQuery, document, window); diff --git a/dashboard-ui/scripts/devicesupload.js b/dashboard-ui/scripts/devicesupload.js index f79f0d97d5..6db4f697e7 100644 --- a/dashboard-ui/scripts/devicesupload.js +++ b/dashboard-ui/scripts/devicesupload.js @@ -102,7 +102,16 @@ } - $(document).on('pageinit', "#devicesUploadPage", function () { + function onSubmit() { + var form = this; + var page = $(form).parents('.page'); + + save(page); + + return false; + } + + $(document).on('pageinitdepends', "#devicesUploadPage", function () { var page = this; @@ -124,8 +133,10 @@ }); }); + $('.devicesUploadForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshow', "#devicesUploadPage", function () { + + }).on('pageshowready', "#devicesUploadPage", function () { var page = this; @@ -133,17 +144,4 @@ }); - window.DevicesUploadPage = { - - onSubmit: function () { - - var form = this; - var page = $(form).parents('.page'); - - save(page); - - return false; - } - }; - })(); \ No newline at end of file diff --git a/dashboard-ui/scripts/edititemsubtitles.js b/dashboard-ui/scripts/edititemsubtitles.js index fb99bb6cdf..6ecdcd2a06 100644 --- a/dashboard-ui/scripts/edititemsubtitles.js +++ b/dashboard-ui/scripts/edititemsubtitles.js @@ -295,7 +295,17 @@ } } - $(document).on('pageinit', "#editItemSubtitlesPage", function () { + function onSearchSubmit() { + var form = this; + + var lang = $('#selectLanguage', form).val(); + + searchForSubtitles($(form).parents('.page'), lang); + + return false; + } + + $(document).on('pageinitdepends', "#editItemSubtitlesPage", function () { var page = this; @@ -314,7 +324,9 @@ } }); - }).on('pagebeforeshow', "#editItemSubtitlesPage", function () { + $('.subtitleSearchForm').off('submit', onSearchSubmit).on('submit', onSearchSubmit); + + }).on('pagebeforeshowready', "#editItemSubtitlesPage", function () { var page = this; @@ -340,18 +352,4 @@ $(ApiClient).off("websocketmessage", onWebSocketMessageReceived); }); - window.EditItemSubtitlesPage = { - - onSearchSubmit: function () { - - var form = this; - - var lang = $('#selectLanguage', form).val(); - - searchForSubtitles($(form).parents('.page'), lang); - - return false; - } - }; - })(jQuery, window, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/forgotpassword.js b/dashboard-ui/scripts/forgotpassword.js index 989867b7b1..a62115c9d9 100644 --- a/dashboard-ui/scripts/forgotpassword.js +++ b/dashboard-ui/scripts/forgotpassword.js @@ -40,7 +40,9 @@ } } - function onSubmit(page) { + function onSubmit() { + + var page = $(this).parents('.page'); ApiClient.ajax({ @@ -55,18 +57,13 @@ processForgotPasswordResult(page, result); }); + + return false; } - window.ForgotPasswordPage = { - onSubmit: function () { - - var page = $(this).parents('.page'); - - onSubmit(page); - return false; - } - - }; + $(document).on('pageinitdepends', '#forgotPasswordPage', function () { + $('.forgotPasswordForm').off('submit', onSubmit).on('submit', onSubmit); + }); })(window); \ No newline at end of file diff --git a/dashboard-ui/scripts/forgotpasswordpin.js b/dashboard-ui/scripts/forgotpasswordpin.js index 7f8dd113be..03e95b80ee 100644 --- a/dashboard-ui/scripts/forgotpasswordpin.js +++ b/dashboard-ui/scripts/forgotpasswordpin.js @@ -31,7 +31,9 @@ return; } - function onSubmit(page) { + function onSubmit() { + + var page = $(this).parents('.page'); ApiClient.ajax({ @@ -46,18 +48,11 @@ processForgotPasswordResult(page, result); }); + return false; } - window.ForgotPasswordPinPage = { - - onSubmit: function () { - - var page = $(this).parents('.page'); - - onSubmit(page); - return false; - } - - }; + $(document).on('pageinitdepends', '#forgotPasswordPinPage', function () { + $('.forgotPasswordPinForm').off('submit', onSubmit).on('submit', onSubmit); + }); })(window); \ No newline at end of file diff --git a/dashboard-ui/scripts/notificationsetting.js b/dashboard-ui/scripts/notificationsetting.js index 294070246b..f8efeb9a42 100644 --- a/dashboard-ui/scripts/notificationsetting.js +++ b/dashboard-ui/scripts/notificationsetting.js @@ -1,7 +1,7 @@ (function () { var notificationsConfigurationKey = "notifications"; - + function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) { var html = '
'; @@ -155,7 +155,13 @@ }); } - $(document).on('pageinit', "#notificationSettingPage", function () { + function onSubmit() { + var page = $(this).parents('.page'); + save(page); + return false; + } + + $(document).on('pageinitdepends', "#notificationSettingPage", function () { var page = this; @@ -169,21 +175,13 @@ }); - }).on('pageshow', "#notificationSettingPage", function () { + $('.notificationSettingForm').off('submit', onSubmit).on('submit', onSubmit); + + }).on('pageshowready', "#notificationSettingPage", function () { var page = this; reload(page); }); - window.NotificationSettingPage = { - - onSubmit: function () { - - var page = $(this).parents('.page'); - save(page); - return false; - } - }; - })(jQuery, window); \ No newline at end of file diff --git a/dashboard-ui/scripts/notificationsettings.js b/dashboard-ui/scripts/notificationsettings.js index 4087eb29e8..52812ef617 100644 --- a/dashboard-ui/scripts/notificationsettings.js +++ b/dashboard-ui/scripts/notificationsettings.js @@ -46,7 +46,7 @@ }); } - $(document).on('pageshow', "#notificationSettingsPage", function () { + $(document).on('pageshowready', "#notificationSettingsPage", function () { var page = this; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 803540cdd6..0bdb919313 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -35,6 +35,8 @@ var Dashboard = { //$.mobile.popup.prototype.options.theme = "c"; $.mobile.popup.prototype.options.transition = "pop"; + //$.mobile.keepNative = "input[type='text'],input[type='password'],input[type='number']"; + if ($.browser.mobile) { $.mobile.defaultPageTransition = "none"; } else {