1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

create collections from movies page

This commit is contained in:
Luke Pulverenti 2014-06-03 23:34:36 -04:00
parent d3a7d45969
commit e0996c055a
5 changed files with 270 additions and 71 deletions

View file

@ -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);

View file

@ -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('<span>' + text + '</span>');
}
@ -197,7 +202,7 @@
showLibraryMenu: showLibraryMenu,
getTopParentId: getTopParentId,
setText: setLibraryMenuText
};
@ -349,4 +354,54 @@
});
})(window, document, jQuery);
})(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');
}
});
};

View file

@ -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 += '<option value="">' + Globalize.translate('OptionNewCollection') + '</option>';
html += result.Items.map(function (i) {
return '<option value="' + i.Id + '">' + i.Name + '</option>';
});
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;
}