From 5d7f6fb03b5a15cea32e74a3a2b4cf3d2fb34b81 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 7 Apr 2013 16:15:04 -0700 Subject: [PATCH] Removed some UI info from views. Added UI Config --- NzbDrone.ncrunchsolution | 1 - UI/AddSeries/Existing/ImportSeriesView.js | 5 +- .../RootFolderCompositeViewTemplate.html | 11 ++- .../UnmappedFolderCompositeViewTemplate.html | 24 ++--- UI/AddSeries/New/SearchResultView.js | 5 +- UI/AddSeries/SearchResultTemplate.html | 54 ++++++----- UI/Calendar/CalendarCollectionTemplate.html | 12 ++- UI/Calendar/CalendarCollectionView.js | 1 - UI/Calendar/CalendarItemTemplate.html | 14 +-- UI/Calendar/CalendarItemView.js | 1 - UI/Config.js | 41 ++++++++ UI/Index.html | 1 + UI/JsLibraries/jquery.cookie.js | 95 +++++++++++++++++++ .../Profile/EditQualityProfileTemplate.html | 7 +- .../Quality/Profile/EditQualityProfileView.js | 11 +-- UI/app.js | 1 + 16 files changed, 211 insertions(+), 73 deletions(-) create mode 100644 UI/Config.js create mode 100644 UI/JsLibraries/jquery.cookie.js diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution index 444b34b1d..6cb47a29a 100644 --- a/NzbDrone.ncrunchsolution +++ b/NzbDrone.ncrunchsolution @@ -2,7 +2,6 @@ 1 False true - true UseDynamicAnalysis Disabled Disabled diff --git a/UI/AddSeries/Existing/ImportSeriesView.js b/UI/AddSeries/Existing/ImportSeriesView.js index 675ec8510..7cb4f5b27 100644 --- a/UI/AddSeries/Existing/ImportSeriesView.js +++ b/UI/AddSeries/Existing/ImportSeriesView.js @@ -4,10 +4,9 @@ define([ NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({ template: 'AddSeries/SearchResultTemplate', - className: 'search-item', events: { - 'click .x-btn-add': 'addSeries' + 'click .x-add': 'addSeries' }, addSeries: function () { @@ -49,7 +48,6 @@ define([ template : 'AddSeries/Existing/UnmappedFolderCompositeViewTemplate', itemViewContainer: '.x-folder-name-match-results', - className : 'unmapped-folder-view', itemView : NzbDrone.AddSeries.Existing.FolderMatchResultView, events: { @@ -116,7 +114,6 @@ define([ template : "AddSeries/Existing/RootFolderCompositeViewTemplate", itemViewContainer: ".x-existing-folder-container", - className : 'row', itemView : NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView, initialize: function () { diff --git a/UI/AddSeries/Existing/RootFolderCompositeViewTemplate.html b/UI/AddSeries/Existing/RootFolderCompositeViewTemplate.html index 1f7e069f2..cd89a1501 100644 --- a/UI/AddSeries/Existing/RootFolderCompositeViewTemplate.html +++ b/UI/AddSeries/Existing/RootFolderCompositeViewTemplate.html @@ -1,6 +1,7 @@ - -
-

{{path}}

+
+
+

{{path}}

-
-
+
+
+
\ No newline at end of file diff --git a/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html b/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html index 07e338fa6..914dfc476 100644 --- a/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html +++ b/UI/AddSeries/Existing/UnmappedFolderCompositeViewTemplate.html @@ -1,15 +1,17 @@ -
-
-
- - -
+
+
+
+
+ + +
-
-
-
-
+
+
+
\ No newline at end of file diff --git a/UI/AddSeries/New/SearchResultView.js b/UI/AddSeries/New/SearchResultView.js index 379333a38..16b0011fc 100644 --- a/UI/AddSeries/New/SearchResultView.js +++ b/UI/AddSeries/New/SearchResultView.js @@ -4,7 +4,6 @@ define(['app', 'Shared/NotificationCollection', 'AddSeries/SearchResultCollectio NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({ template : "AddSeries/SearchResultTemplate", - className: 'search-item', ui: { qualityProfile: '.x-quality-profile', @@ -13,14 +12,14 @@ define(['app', 'Shared/NotificationCollection', 'AddSeries/SearchResultCollectio }, events: { - 'click .x-add': 'add' + 'click .x-add': 'addSeries' }, onRender: function () { this.listenTo(this.model, 'change', this.render); }, - add: function () { + addSeries: function () { var quality = this.ui.qualityProfile.val(); diff --git a/UI/AddSeries/SearchResultTemplate.html b/UI/AddSeries/SearchResultTemplate.html index 5e3687e8a..06ee6bd96 100644 --- a/UI/AddSeries/SearchResultTemplate.html +++ b/UI/AddSeries/SearchResultTemplate.html @@ -1,32 +1,34 @@ -
-
- - - -
-
+
+
+
+ + + +
+
-
- {{#unless isExisting}} - + {{#each rootFolders.models}} + + {{/each}} + + {{/unless}} + - {{/unless}} - -
-
-
-

{{title}}

-
-
- {{overview}} +
+
+
+

{{title}}

+
+
+ {{overview}} +
-
+
\ No newline at end of file diff --git a/UI/Calendar/CalendarCollectionTemplate.html b/UI/Calendar/CalendarCollectionTemplate.html index b34deeca2..a333dd69a 100644 --- a/UI/Calendar/CalendarCollectionTemplate.html +++ b/UI/Calendar/CalendarCollectionTemplate.html @@ -1,6 +1,8 @@ -
-

Upcoming

-
-
-
+
+
+

Upcoming

+
+
+
+
\ No newline at end of file diff --git a/UI/Calendar/CalendarCollectionView.js b/UI/Calendar/CalendarCollectionView.js index a970f1552..7855e2048 100644 --- a/UI/Calendar/CalendarCollectionView.js +++ b/UI/Calendar/CalendarCollectionView.js @@ -5,7 +5,6 @@ define(['app', 'Calendar/CalendarItemView'], function () { itemView : NzbDrone.Calendar.CalendarItemView, itemViewContainer: '#events', template : 'Calendar/CalendarCollectionTemplate', - className : 'row', ui: { calendar: '#calendar' diff --git a/UI/Calendar/CalendarItemTemplate.html b/UI/Calendar/CalendarItemTemplate.html index 4182e5047..1f1278054 100644 --- a/UI/Calendar/CalendarItemTemplate.html +++ b/UI/Calendar/CalendarItemTemplate.html @@ -1,6 +1,8 @@ -
-

{{day}}

-

{{month}}

-
-

{{seriesTitle}}

-

{{startTime}} {{bestDateString}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

+
+
+

{{day}}

+

{{month}}

+
+

{{seriesTitle}}

+

{{startTime}} {{bestDateString}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

+
\ No newline at end of file diff --git a/UI/Calendar/CalendarItemView.js b/UI/Calendar/CalendarItemView.js index 1ef9208f5..bba054684 100644 --- a/UI/Calendar/CalendarItemView.js +++ b/UI/Calendar/CalendarItemView.js @@ -8,7 +8,6 @@ define([ NzbDrone.Calendar.CalendarItemView = Backbone.Marionette.ItemView.extend({ template : 'Calendar/CalendarItemTemplate', tagName : 'div', - className: 'event', onRender: function () { NzbDrone.ModelBinder.bind(this.model, this.el); diff --git a/UI/Config.js b/UI/Config.js new file mode 100644 index 000000000..49fa6b045 --- /dev/null +++ b/UI/Config.js @@ -0,0 +1,41 @@ +"use strict"; +define(['app'], function () { + + $.cookie.json = true; + + NzbDrone.Config.SeriesView = function (value) { + if (value) { + NzbDrone.Config.SetValue('seriesView', value); + } + + else{ + return NzbDrone.Config.GetValue('seriesView', 0); + } + }; + + NzbDrone.Config.GetValue = function (key, defaultValue) { + var cookie = NzbDrone.Config.GetCookie(); + var value = cookie[key]; + + if (!value) { + return defaultValue; + } + + else { + return value; + } + }; + + NzbDrone.Config.SetValue = function (key, value) { + var cookie = NzbDrone.Config.GetCookie(); + cookie[key] = value; + }; + + NzbDrone.Config.GetCookie = function () { + return $.cookie('NzbDroneConfig'); + }; + + NzbDrone.Config.SetCookie = function (cookie) { + $.cookie('NzbDroneConfig', cookie, { expires: 7, path: '/' }); + }; +}); diff --git a/UI/Index.html b/UI/Index.html index 6fca5c062..cb8fc7a2e 100644 --- a/UI/Index.html +++ b/UI/Index.html @@ -103,6 +103,7 @@ + diff --git a/UI/JsLibraries/jquery.cookie.js b/UI/JsLibraries/jquery.cookie.js new file mode 100644 index 000000000..c4f99af00 --- /dev/null +++ b/UI/JsLibraries/jquery.cookie.js @@ -0,0 +1,95 @@ +/*! + * jQuery Cookie Plugin v1.3.1 + * https://github.com/carhartl/jquery-cookie + * + * Copyright 2013 Klaus Hartl + * Released under the MIT license + */ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as anonymous module. + define(['jquery'], factory); + } else { + // Browser globals. + factory(jQuery); + } +}(function ($) { + + var pluses = /\+/g; + + function raw(s) { + return s; + } + + function decoded(s) { + return decodeURIComponent(s.replace(pluses, ' ')); + } + + function converted(s) { + if (s.indexOf('"') === 0) { + // This is a quoted cookie as according to RFC2068, unescape + s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); + } + try { + return config.json ? JSON.parse(s) : s; + } catch(er) {} + } + + var config = $.cookie = function (key, value, options) { + + // write + if (value !== undefined) { + options = $.extend({}, config.defaults, options); + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = config.json ? JSON.stringify(value) : String(value); + + return (document.cookie = [ + config.raw ? key : encodeURIComponent(key), + '=', + config.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // read + var decode = config.raw ? raw : decoded; + var cookies = document.cookie.split('; '); + var result = key ? undefined : {}; + for (var i = 0, l = cookies.length; i < l; i++) { + var parts = cookies[i].split('='); + var name = decode(parts.shift()); + var cookie = decode(parts.join('=')); + + if (key && key === name) { + result = converted(cookie); + break; + } + + if (!key) { + result[name] = converted(cookie); + } + } + + return result; + }; + + config.defaults = {}; + + $.removeCookie = function (key, options) { + if ($.cookie(key) !== undefined) { + // Must not alter options, thus extending a fresh object... + $.cookie(key, '', $.extend({}, options, { expires: -1 })); + return true; + } + return false; + }; + +})); diff --git a/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html b/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html index 3e0c4ec5d..40c284060 100644 --- a/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html +++ b/UI/Settings/Quality/Profile/EditQualityProfileTemplate.html @@ -40,7 +40,12 @@
- + {{#if allowed}} + + {{else}} + + {{/if}} +
diff --git a/UI/Settings/Quality/Profile/EditQualityProfileView.js b/UI/Settings/Quality/Profile/EditQualityProfileView.js index 0d417d19c..eaed084f5 100644 --- a/UI/Settings/Quality/Profile/EditQualityProfileView.js +++ b/UI/Settings/Quality/Profile/EditQualityProfileView.js @@ -11,8 +11,7 @@ define(['app', 'Quality/QualityProfileModel'], function () { }, events: { - 'click .x-save': 'saveQualityProfile', - //'click .x-remove': 'removeSeries' + 'click .x-save': 'saveQualityProfile' }, onRender: function () { @@ -20,19 +19,13 @@ define(['app', 'Quality/QualityProfileModel'], function () { this.ui.switch.bootstrapSwitch(); }, - saveQualityProfile: function () { //Todo: Make sure model is updated with Allowed, Cutoff, Name this.model.save(); this.trigger('saved'); this.$el.parent().modal('hide'); - }, - - // removeSeries: function () { - // var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); - // NzbDrone.modalRegion.show(view); - // } + } }); }); \ No newline at end of file diff --git a/UI/app.js b/UI/app.js index b27f8219d..c359ca36d 100644 --- a/UI/app.js +++ b/UI/app.js @@ -30,6 +30,7 @@ require.config({ define('app', function () { window.NzbDrone = new Backbone.Marionette.Application(); + window.NzbDrone.Config = {}; window.NzbDrone.Series = {}; window.NzbDrone.Series.Index = {}; window.NzbDrone.Series.Edit = {};