From 32386e817b4fc8d8c6f6d60ddb5fc93637554a43 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 14 Jan 2014 15:03:35 -0500 Subject: [PATCH] added new item by name filters --- ApiClient.js | 31 +---------- dashboard-ui/scripts/edititemmetadata.js | 13 ++--- dashboard-ui/scripts/librarybrowser.js | 55 ++++++++++++------- dashboard-ui/scripts/librarymenu.js | 24 ++++---- dashboard-ui/scripts/livetvsettings.js | 6 +- dashboard-ui/scripts/livetvtimer.js | 2 +- dashboard-ui/scripts/mediaplayer.js | 26 +-------- .../thirdparty/jquery.hoverIntent.minified.js | 8 --- packages.config | 2 +- 9 files changed, 62 insertions(+), 105 deletions(-) delete mode 100644 dashboard-ui/thirdparty/jquery.hoverIntent.minified.js diff --git a/ApiClient.js b/ApiClient.js index 578f711760..e790a1836c 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -378,20 +378,9 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getAuthorizedFeatures = function (options) { + self.getLiveTvInfo = function (options) { - var url = self.getUrl("Users/AuthorizedFeatures", options || {}); - - return self.ajax({ - type: "GET", - url: url, - dataType: "json" - }); - }; - - self.getLiveTvServices = function (options) { - - var url = self.getUrl("LiveTv/Services", options || {}); + var url = self.getUrl("LiveTv/Info", options || {}); return self.ajax({ type: "GET", @@ -2714,22 +2703,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateLiveTvChannel = function (item) { - - if (!item) { - throw new Error("null item"); - } - - var url = self.getUrl("LiveTv/Channels/" + item.Id); - - return self.ajax({ - type: "POST", - url: url, - data: JSON.stringify(item), - contentType: "application/json" - }); - }; - self.updateArtist = function (item) { if (!item) { diff --git a/dashboard-ui/scripts/edititemmetadata.js b/dashboard-ui/scripts/edititemmetadata.js index f093e315a1..3ed4235828 100644 --- a/dashboard-ui/scripts/edititemmetadata.js +++ b/dashboard-ui/scripts/edititemmetadata.js @@ -91,18 +91,18 @@ var promise1 = ApiClient.getRootFolder(Dashboard.getCurrentUserId()); - var promise2 = ApiClient.getLiveTvServices(); + var promise2 = ApiClient.getLiveTvInfo(); $.when(promise1, promise2).done(function (response1, response2) { var rootFolder = response1[0]; - var liveTvServices = response2[0]; + var liveTvInfo = response2[0]; var nodes = []; nodes.push(getNode(rootFolder, 'open')); - if (liveTvServices.length) { + if (liveTvInfo.Services.length) { nodes.push({ attr: { id: 'livetv', rel: 'folder', itemtype: 'livetv' }, data: 'Live TV', state: 'open' }); } @@ -113,9 +113,9 @@ function loadLiveTvServices(openItems, callback) { - ApiClient.getLiveTvServices().done(function (services) { + ApiClient.getLiveTvInfo().done(function (info) { - var nodes = services.map(function (i) { + var nodes = info.Services.map(function (i) { var state = openItems.indexOf(i.Id) == -1 ? 'closed' : 'open'; @@ -1231,9 +1231,6 @@ else if (currentItem.Type == "Studio") { updatePromise = ApiClient.updateStudio(item); } - else if (currentItem.Type == "Channel") { - updatePromise = ApiClient.updateLiveTvChannel(item); - } else { updatePromise = ApiClient.updateItem(item); } diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 03efb71d6a..2fcb33bd86 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -502,7 +502,7 @@ var isPlaying = MediaPlayer.isPlaying(); if (!isPlaying && !resumePositionTicks && mediaType != "Audio") { - MediaPlayer.playById(itemId, itemType); + MediaPlayer.playById(itemId); return; } @@ -516,7 +516,7 @@ if (itemType == "MusicArtist") { html += '
  • Play
  • '; } else if (itemType != "MusicGenre") { - html += '
  • Play
  • '; + html += '
  • Play
  • '; } if (itemType == "Audio") { @@ -536,7 +536,7 @@ } if (resumePositionTicks) { - html += '
  • Resume
  • '; + html += '
  • Resume
  • '; } if (isPlaying) { @@ -2442,17 +2442,17 @@ html += LibraryBrowser.getMiscInfoHtml(item); html += '

    '; - html += '

    '; + html += '

    '; html += ''; html += LibraryBrowser.getRatingHtml(item); html += ''; html += '

    '; - //html += '

    '; - //html += ''; - //html += LibraryBrowser.getUserDataIconsHtml(item); - //html += ''; - //html += '

    '; + html += '

    '; + html += ''; + html += LibraryBrowser.getUserDataIconsHtml(item); + html += ''; + html += '

    '; html += '

    '; html += (item.OverviewHtml || item.Overview || ''); @@ -2494,14 +2494,26 @@ var popup = $('.itemFlyout').on('mouseenter', onOverlayMouseOver).on('mouseleave', onOverlayMouseOut).popup({ positionTo: elem }).trigger('create').popup("open").on("popupafterclose", function () { - $(elem).off('mouseleave.overlay', onHoverOut); $(this).off("popupafterclose").off("mouseenter").off("mouseleave").remove(); }); popup.parents().prev('.ui-popup-screen').remove(); currentPosterItem = elem; + } - $(elem).on('mouseleave.overlay', onHoverOut).on('click.overlay', hideOverlay); + function onPosterItemClicked() { + + if (showOverlayTimeout) { + clearTimeout(showOverlayTimeout); + showOverlayTimeout = null; + } + + if (hideOverlayTimeout) { + clearTimeout(hideOverlayTimeout); + hideOverlayTimeout = null; + } + + hideOverlay(); } function hideOverlay() { @@ -2510,7 +2522,7 @@ if (currentPosterItem) { - $(currentPosterItem).off('mouseleave.overlay').off('click.overlay'); + $(currentPosterItem).off('click.overlay'); currentPosterItem = null; } } @@ -2535,7 +2547,7 @@ startHideOverlayTimer(); } - $.fn.createPosterItemHoverMenu = function (items) { + $.fn.createPosterItemHoverMenu = function () { function onShowTimerExpired(elem) { @@ -2573,14 +2585,19 @@ }, 600); } - return this.hoverIntent({ - over: onHoverIn, - out: function () { + // https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/ + + if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) { + /* browser with either Touch Events of Pointer Events + running on touch-capable device */ + return this; + } - }, - selector: '.posterItem' + return this; - }); + return this.on('mouseenter', '.posterItem', onHoverIn) + .on('mouseleave', '.posterItem', onHoverOut) + .on('click', '.posterItem', onPosterItemClicked); }; })(jQuery, document, window); diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index e4a87fde78..30560fd50a 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -1,11 +1,11 @@ (function (window, document, $) { var itemCountsPromise; - var liveTvServicesPromise; + var liveTvInfoPromise; function ensurePromises() { itemCountsPromise = itemCountsPromise || ApiClient.getItemCounts(Dashboard.getCurrentUserId()); - liveTvServicesPromise = liveTvServicesPromise || ApiClient.getLiveTvServices(); + liveTvInfoPromise = liveTvInfoPromise || ApiClient.getLiveTvInfo(); } function renderHeader(page, user) { @@ -56,7 +56,7 @@ $('.viewMenuBar', page).trigger('create'); } - function insertViews(page, user, counts, liveTvServices) { + function insertViews(page, user, counts, liveTvInfo) { var html = ''; @@ -74,7 +74,7 @@ html += '' + (view == 'tv' ? selectedHtml : '') + 'TV'; } - if (liveTvServices.length) { + if (liveTvInfo.ActiveServiceName) { html += '' + (view == 'livetv' ? selectedHtml : '') + 'Live TV'; } @@ -93,18 +93,18 @@ ensurePromises(); - $.when(itemCountsPromise, liveTvServicesPromise).done(function (response1, response2) { + $.when(itemCountsPromise, liveTvInfoPromise).done(function (response1, response2) { var counts = response1[0]; - var liveTvServices = response2[0]; + var liveTvInfo = response2[0]; - var panel = getLibraryMenu(page, counts, liveTvServices); + var panel = getLibraryMenu(page, counts, liveTvInfo); $(panel).panel('toggle'); }); } - function getLibraryMenu(page, counts, liveTvServices) { + function getLibraryMenu(page, counts, liveTvInfo) { var panel = $('#libraryPanel', page); @@ -146,7 +146,7 @@ ]); } - if (liveTvServices.length) { + if (liveTvInfo.ActiveServiceName) { html += getCollapsibleHtml('Live TV', [ { text: 'Suggested', href: 'livetvsuggested.html' }, @@ -249,12 +249,12 @@ ensurePromises(); - $.when(itemCountsPromise, liveTvServicesPromise).done(function (response1, response2) { + $.when(itemCountsPromise, liveTvInfoPromise).done(function (response1, response2) { var counts = response1[0]; - var liveTvServices = response2[0]; + var liveTvInfo = response2[0]; - insertViews(page, user, counts, liveTvServices); + insertViews(page, user, counts, liveTvInfo); }); diff --git a/dashboard-ui/scripts/livetvsettings.js b/dashboard-ui/scripts/livetvsettings.js index 48069939ba..1583f16204 100644 --- a/dashboard-ui/scripts/livetvsettings.js +++ b/dashboard-ui/scripts/livetvsettings.js @@ -1,8 +1,8 @@ (function ($, document, window) { - function loadPage(page, config, tvServices) { + function loadPage(page, config, liveTvInfo) { - if (tvServices.length) { + if (liveTvInfo.Services.length) { $('.liveTvSettingsForm', page).show(); $('.noLiveTvServices', page).hide(); @@ -25,7 +25,7 @@ var promise1 = ApiClient.getServerConfiguration(); - var promise2 = ApiClient.getLiveTvServices(); + var promise2 = ApiClient.getLiveTvInfo(); $.when(promise1, promise2).done(function (response1, response2) { diff --git a/dashboard-ui/scripts/livetvtimer.js b/dashboard-ui/scripts/livetvtimer.js index 1d739129b5..89d01a35e9 100644 --- a/dashboard-ui/scripts/livetvtimer.js +++ b/dashboard-ui/scripts/livetvtimer.js @@ -14,7 +14,7 @@ Dashboard.alert('Recording cancelled.'); - reload(page); + Dashboard.navigate('livetvtimers.html'); }); } diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 7254b3be27..9e75a78218 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -363,7 +363,7 @@ if (!$(this).hasClass('selectedMediaFlyoutOption')) { var channelId = this.getAttribute('data-channelid'); - self.playById(channelId, 'Channel'); + self.playById(channelId); } hideFlyout($('#channelsFlyout')); @@ -1229,29 +1229,7 @@ return ApiClient.getItems(userId, query); }; - self.playById = function (id, itemType, startPositionTicks) { - - if (itemType == "Recording") { - - ApiClient.getLiveTvRecording(id, Dashboard.getCurrentUserId()).done(function (item) { - - self.play([item], startPositionTicks); - - }); - - return; - } - - if (itemType == "Channel") { - - ApiClient.getLiveTvChannel(id, Dashboard.getCurrentUserId()).done(function (item) { - - self.play([item], startPositionTicks); - - }); - - return; - } + self.playById = function (id, startPositionTicks) { ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) { diff --git a/dashboard-ui/thirdparty/jquery.hoverIntent.minified.js b/dashboard-ui/thirdparty/jquery.hoverIntent.minified.js deleted file mode 100644 index 3f6bf7372b..0000000000 --- a/dashboard-ui/thirdparty/jquery.hoverIntent.minified.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+ - * http://cherne.net/brian/resources/jquery.hoverIntent.html - * - * You may use hoverIntent under the terms of the MIT license. - * Copyright 2007, 2013 Brian Cherne - */ -(function(e){e.fn.hoverIntent=function(t,n,r){var i={interval:100,sensitivity:7,timeout:0};if(typeof t==="object"){i=e.extend(i,t)}else if(e.isFunction(n)){i=e.extend(i,{over:t,out:n,selector:r})}else{i=e.extend(i,{over:t,out:t,selector:n})}var s,o,u,a;var f=function(e){s=e.pageX;o=e.pageY};var l=function(t,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if(Math.abs(u-s)+Math.abs(a-o) - + \ No newline at end of file