From b2244e144768423241e096bacb9cce134b2962fb Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 3 Feb 2016 21:37:25 +0000 Subject: [PATCH] Update JS for API changes moving to iron-list --- src/gui/html/js/events.js | 12 +++++------- src/gui/html/js/helpers.js | 7 +++---- src/gui/html/js/init.js | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/gui/html/js/events.js b/src/gui/html/js/events.js index a2729688..8d17bf91 100644 --- a/src/gui/html/js/events.js +++ b/src/gui/html/js/events.js @@ -40,8 +40,8 @@ function onChangeGame(evt) { loot.game = new loot.Game(gameInfo, loot.l10n); /* Reset virtual list positions. */ - document.getElementById('cardsNav').scrollToItem(0); - document.getElementById('main').lastElementChild.scrollToItem(0); + document.getElementById('cardsNav').scrollToIndex(0); + document.getElementById('main').lastElementChild.scrollToIndex(0); /* Now update virtual lists. */ filterPluginData(loot.game.plugins, loot.filters); @@ -70,8 +70,6 @@ function updateMasterlistNoProgress() { existingPlugin.tags = resultPlugin.tags; } }); - /* Hack to stop cards overlapping. */ - document.getElementById('main').lastElementChild.updateSize(); loot.Dialog.showNotification(loot.l10n.translate('Masterlist updated to revision %s.', loot.game.masterlist.revision)); } else { @@ -356,7 +354,7 @@ function onSwitchSidebarTab(evt) { } function onSidebarClick(evt) { if (evt.target.hasAttribute('data-index')) { - document.getElementById('main').lastElementChild.scrollToItem(evt.target.getAttribute('data-index')); + document.getElementById('main').lastElementChild.scrollToIndex(evt.target.getAttribute('data-index')); if (evt.type === 'dblclick') { const card = document.getElementById(evt.target.getAttribute('data-id')); @@ -439,7 +437,7 @@ function onEditorOpen(evt) { document.getElementById('sortButton').setAttribute('disabled', ''); } document.body.setAttribute('data-editors', numEditors); - document.getElementById('cardsNav').updateSize(); + document.getElementById('cardsNav').notifyResize(); return loot.query('editorOpened').catch(handlePromiseError); } @@ -500,7 +498,7 @@ function onEditorClose(evt) { } else { document.body.setAttribute('data-editors', numEditors); } - document.getElementById('cardsNav').updateSize(); + document.getElementById('cardsNav').notifyResize(); }).catch(handlePromiseError); } function undoConflictsFilter() { diff --git a/src/gui/html/js/helpers.js b/src/gui/html/js/helpers.js index 08db0c61..a9ca5574 100644 --- a/src/gui/html/js/helpers.js +++ b/src/gui/html/js/helpers.js @@ -44,8 +44,8 @@ function filterPluginData(plugins, filters) { filters.conflictingPluginNames = conflictingPluginNames; return plugins.filter(filters.pluginFilter, filters); }).then((filteredPlugins) => { - document.getElementById('cardsNav').data = filteredPlugins; - document.getElementById('pluginCardList').data = filteredPlugins; + document.getElementById('cardsNav').items = filteredPlugins; + document.getElementById('pluginCardList').items = filteredPlugins; const pluginCards = document.getElementById('pluginCardList').children; for (let i = 0; i < pluginCards.length; ++i) { @@ -53,8 +53,7 @@ function filterPluginData(plugins, filters) { pluginCards[i].updateContent(); } } - document.getElementById('cardsNav').updateSize(); - document.getElementById('pluginCardList').updateSize(); + document.getElementById('cardsNav').notifyResize(); /* Now perform search again. If there is no current search, this won't do anything. */ diff --git a/src/gui/html/js/init.js b/src/gui/html/js/init.js index 785df698..45a7fe1f 100644 --- a/src/gui/html/js/init.js +++ b/src/gui/html/js/init.js @@ -222,8 +222,8 @@ return query('getGameData').then((result) => { const game = JSON.parse(result, Plugin.fromJson); appData.game = new Game(game, appData.l10n); - document.getElementById('cardsNav').data = appData.game.plugins; - document.getElementById('main').lastElementChild.data = appData.game.plugins; + document.getElementById('cardsNav').items = appData.game.plugins; + document.getElementById('main').lastElementChild.items = appData.game.plugins; applyEnabledFilters(appData.filters, appData.settings, appData.game.plugins); Dialog.closeProgress(); });