diff --git a/dashboard-ui/css/librarymenu.css b/dashboard-ui/css/librarymenu.css index 1cb1efd3d5..80d74da6bf 100644 --- a/dashboard-ui/css/librarymenu.css +++ b/dashboard-ui/css/librarymenu.css @@ -62,30 +62,27 @@ border-width: 0 !important; } -.libraryMenuButton { - /*padding-left: 10px; - opacity: .85;*/ +.libraryMenuButton img { + border: 1px solid #444 !important; + padding: .5em; + background-color: #181818; + border-radius: 5px; + height: 14px!important; } -.headerHomeButton { - padding-right: 0!important; +.libraryMenuButton:hover { + opacity: 1!important; } - .libraryMenuButton img, .headerHomeButton img { - border: 1px solid #444 !important; - padding: .5em; - background-color: #181818; - border-radius: 5px; - height: 14px!important; - } +.libraryMenuButton img:hover { + background-color: #38c; +} - .libraryMenuButton:hover { - opacity: 1!important; - } - - .libraryMenuButton img:hover, .headerHomeButton img:hover { - background-color: #38c; +@media all and (min-width: 600px) { + .libraryMenuButton { + opacity: .9; } +} .libraryMenuButtonText { color: #fff !important; @@ -321,14 +318,6 @@ color: #ddd; } -@media all and (max-width: 600px) { - - .headerSettingsButton { - display: none; - } -} - - @media all and (max-width: 500px) { .libraryMenuButtonText { diff --git a/dashboard-ui/movies.html b/dashboard-ui/movies.html index ffaf9c7259..71f8adbad0 100644 --- a/dashboard-ui/movies.html +++ b/dashboard-ui/movies.html @@ -4,7 +4,7 @@ ${TitleMediaBrowser} -
+
${TabLatest} @@ -38,13 +38,45 @@
+
+
+ +

${HeaderAddToCollection}

+ +
+
+ + +
+
+
+
+ + +
${NewCollectionNameExample}
+
+ +
+
+ + +
+
+
+

+ + +

+
+
@@ -210,6 +242,9 @@
+
diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index d2f2b1eaa9..7ac5a59113 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -300,7 +300,7 @@ if (selection.length < 2) { Dashboard.alert({ - message: Globalize.translate('MessagePleaseSelectItemsToGroup'), + message: Globalize.translate('MessagePleaseSelectTwoItems'), title: Globalize.translate('HeaderError') }); @@ -324,6 +324,7 @@ Dashboard.showLoadingMsg(); $.ajax({ + type: "POST", url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') }) @@ -331,13 +332,30 @@ Dashboard.hideLoadingMsg(); - hideSelections(); + hideSelections(page); $('.itemsContainer', page).trigger('needsrefresh'); }); } }); } + + function addToCollection(page) { + + var selection = getSelectedItems(page); + + if (selection.length < 1) { + + Dashboard.alert({ + message: Globalize.translate('MessagePleaseSelectOneItem'), + title: Globalize.translate('HeaderError') + }); + + return; + } + + BoxSetEditor.showPanel(page, selection); + } $(document).on('pageinit', ".libraryPage", function () { @@ -351,6 +369,16 @@ combineVersions(page); }); + $('.btnAddToCollection', page).on('click', function () { + addToCollection(page); + }); + + }).on('pagebeforeshow', ".libraryPage", function () { + + var page = this; + + hideSelections(page); + }); })(jQuery, document, window); \ No newline at end of file diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index f9ca6e0ac3..b0dab5eba3 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -49,7 +49,7 @@ $(document).trigger('headercreated'); - $('.libraryMenuButton').on('click', showLibraryMenu); + $('.libraryMenuButton').createHoverTouch().on('hovertouch', showLibraryMenu); } function getItemHref(item) { @@ -86,10 +86,15 @@ updateLibraryNavLinks($.mobile.activePage); - $(panel).panel('toggle'); + $(panel).panel('toggle').off('mouseleave.librarymenu').on('mouseleave.librarymenu', function () { + + $(this).panel("close"); + + }); } function updateLibraryMenu(panel) { + var userId = Dashboard.getCurrentUserId(); ApiClient.getItems(userId, { @@ -181,9 +186,9 @@ return panel; } - + function setLibraryMenuText(text) { - + $('.libraryMenuButtonText').html('' + text + ''); } @@ -197,7 +202,7 @@ showLibraryMenu: showLibraryMenu, getTopParentId: getTopParentId, - + setText: setLibraryMenuText }; @@ -349,4 +354,54 @@ }); -})(window, document, jQuery); \ No newline at end of file +})(window, document, jQuery); + +$.fn.createHoverTouch = function () { + + var preventHover = false; + var timerId; + + function startTimer(elem) { + + stopTimer(); + + timerId = setTimeout(function () { + + $(elem).trigger('hovertouch'); + }, 200); + } + + function stopTimer(elem) { + + if (timerId) { + clearTimeout(timerId); + timerId = null; + } + } + + return $(this).on('mouseenter', function () { + + if (preventHover === true) { + return; + } + + startTimer(this); + + }).on('mouseleave', function () { + + stopTimer(this); + + }).on('touchstart', function () { + + preventHover = true; + + }).on('click', function () { + + preventHover = true; + + if (preventHover) { + $(this).trigger('hovertouch'); + } + }); + +}; \ No newline at end of file diff --git a/dashboard-ui/scripts/moviecollections.js b/dashboard-ui/scripts/moviecollections.js index c438ef2d06..8f46f20290 100644 --- a/dashboard-ui/scripts/moviecollections.js +++ b/dashboard-ui/scripts/moviecollections.js @@ -104,13 +104,6 @@ $('.alphabetPicker', page).alphaValue(query.NameStartsWithOrGreater); } - function showNewCollectionPanel(page) { - - $('.newCollectionPanel', page).panel('toggle'); - - $('#txtNewCollectionName', page).val('').focus(); - } - $(document).on('pageinit', "#boxsetsPage", function () { var page = this; @@ -199,21 +192,54 @@ }).on('pageshow', "#boxsetsPage", function () { updateFilterControls(this); - - }).on('collectionedit', "#boxsetsPage", function () { - reloadItems(this); }); })(jQuery, document); (function ($, document) { - function showNewCollectionPanel(page) { + function showNewCollectionPanel(page, items) { - $('.newCollectionPanel', page).panel('toggle'); + $('.fldSelectedItemIds', page).val(items.join(',')); - $('#txtNewCollectionName', page).val('').focus(); + var panel = $('.newCollectionPanel', page).panel('toggle'); + + populateCollections(panel); + } + + function populateCollections(panel) { + + var select = $('#selectCollectionToAddTo', panel); + + if (!select.length) { + + $('#txtNewCollectionName', panel).val('').focus(); + return; + } + + $('.newCollectionInfo', panel).hide(); + + var options = { + + Recursive: true, + IncludeItemTypes: "BoxSet" + }; + + ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { + + var html = ''; + + html += ''; + + html += result.Items.map(function (i) { + + return ''; + }); + + select.html(html).val('').selectmenu('refresh').trigger('change'); + + }); } $(document).on('pageinit', ".collectionEditorPage", function () { @@ -222,7 +248,18 @@ $('.btnNewCollection', page).on('click', function () { - showNewCollectionPanel(page); + showNewCollectionPanel(page, []); + }); + + $('#selectCollectionToAddTo', page).on('change', function () { + + if (this.value) { + $('.newCollectionInfo', page).hide(); + $('#txtNewCollectionName', page).removeAttr('required'); + } else { + $('.newCollectionInfo', page).show(); + $('#txtNewCollectionName', page).attr('required', 'required'); + } }); }).on('pagebeforeshow', ".collectionEditorPage", function () { @@ -240,36 +277,91 @@ }); }); + function createCollection(page) { + + var url = ApiClient.getUrl("Collections", { + + Name: $('#txtNewCollectionName', page).val(), + IsLocked: !$('#chkEnableInternetMetadata', page).checked(), + Ids: $('.fldSelectedItemIds', page).val() || '' + + //ParentId: getParameterByName('parentId') || LibraryMenu.getTopParentId() + + }); + + $.ajax({ + type: "POST", + url: url, + dataType: "json" + + }).done(function (result) { + + Dashboard.hideLoadingMsg(); + + var id = result.Id; + var destination = 'itemdetails.html?id=' + id; + + var context = getParameterByName('context'); + + if (context) { + destination += "&context=" + context; + } + + $('.newCollectionPanel', page).panel('toggle'); + Dashboard.navigate(destination); + + }); + } + + function addToCollection(page, id) { + + var url = ApiClient.getUrl("Collections/" + id + "/Items", { + + Ids: $('.fldSelectedItemIds', page).val() || '' + }); + + $.ajax({ + type: "POST", + url: url + + }).done(function () { + + Dashboard.hideLoadingMsg(); + + var destination = 'itemdetails.html?id=' + id; + + var context = getParameterByName('context'); + + if (context) { + destination += "&context=" + context; + } + + $('.newCollectionPanel', page).panel('toggle'); + Dashboard.navigate(destination); + + }); + + } + window.BoxSetEditor = { + showPanel: function (page, items) { + showNewCollectionPanel(page, items); + }, + onNewCollectionSubmit: function () { Dashboard.showLoadingMsg(); var page = $(this).parents('.page'); - var url = ApiClient.getUrl("Collections", { + var collectionId = $('#selectCollectionToAddTo', page).val(); - Name: $('#txtNewCollectionName', page).val(), - IsLocked: !$('#chkEnableInternetMetadata', page).checked(), - - ParentId: getParameterByName('parentId') || LibraryMenu.getTopParentId() - - }); - - $.ajax({ - type: "POST", - url: url - - }).done(function () { - - Dashboard.hideLoadingMsg(); - - $('.newCollectionPanel', page).panel('toggle'); - - $(page).trigger('collectionedit'); - - }); + if (collectionId) { + addToCollection(page, collectionId); + } else { + createCollection(page); + } return false; }