From 6046e3e5b068887beeaba9b29deeb26e2f58d15a Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Mon, 13 Feb 2017 02:02:48 +0900 Subject: [PATCH] Add explicit options icon --- icon-options.svg | 1 + popup.css | 37 ++++++++++++++++++------------------- popup.js | 39 ++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 40 deletions(-) create mode 100644 icon-options.svg diff --git a/icon-options.svg b/icon-options.svg new file mode 100644 index 0000000..a421a2c --- /dev/null +++ b/icon-options.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/popup.css b/popup.css index 0db6413..7b474da 100644 --- a/popup.css +++ b/popup.css @@ -49,8 +49,7 @@ input { list-style: none; } .ext { - overflow: hidden; - text-overflow: ellipsis; + display: flex; white-space: nowrap; font-size: 1.2em; line-height: 1.8; @@ -68,28 +67,28 @@ input { .ext.disabled + .disabled { margin-top: 0; } -.ext:hover { - background-color: #ecf0f1; - cursor: pointer; -} -.extIcon { - margin-right: 0.3em; -} -.extIcon a{ - cursor: default; +.extName { + flex-grow: 1; + overflow: hidden; + text-overflow: ellipsis; } -.extIcon img { +.ext img { width: 16px; height: 16px; - cursor: default; vertical-align: -3px; } -a .hasOpt { - overflow: hidden; - transition-duration: 0.8s; - transition-property: transform; +.extIcon { + margin-right: 0.3em; +} +.extOptions { + padding: 0 0.3em; + opacity: 0.1; +} +.ext > *:hover { + background-color: #ecf0f1; cursor: pointer; } -.hasOpt:hover { - transform: rotate(360deg); +*:hover + .extOptions, +.extOptions:hover { + opacity: 1; } diff --git a/popup.js b/popup.js index 340968b..c97308a 100644 --- a/popup.js +++ b/popup.js @@ -4,7 +4,7 @@ const getI18N = chrome.i18n.getMessage; const searchText = $('#searchext'); // disable the default context menu -window.oncontextmenu = () => false; +eul.on('contextmenu', () => false); searchText.attr('placeholder', getI18N('searchTxt')).focus(); @@ -56,9 +56,8 @@ cme.getAll(ets => { $('#pbgjpgbpljobkekbhnnmlikbbfhbhmem').remove(); }); -$('body').on('click', 'li.ext', function (e) { - const that = $(this); - const extSel = that.find('.extName'); +$('body').on('click', '.extName', function (e) { + const extSel = $(this); const eid = extSel.attr('data-id'); cme.get(eid, e => { extSel.parent().remove(); @@ -72,17 +71,11 @@ $('body').on('click', 'li.ext', function (e) { }); } }); -}).on('click', 'li .extIcon a', function (e) { - const that = $(this); - const href = that.attr('href'); - if (href !== '#') { - chrome.tabs.create({url: href}); - } -}).on('mouseup', 'li.ext', function (e) { +}).on('click', '.extOptions', e => { + chrome.tabs.create({url: e.target.href}); +}).on('mouseup', '.extName', e => { if (e.which == 3) { - const that = $(this); - const eid = that.find('.extName').attr('data-id'); - cme.uninstall(eid); + cme.uninstall(e.target.dataset.id); } }); @@ -114,7 +107,7 @@ function getIcon(icons, size = 16) { return false; } selectedIcon = icon.url; - }) + }); } return selectedIcon; } @@ -122,13 +115,17 @@ function getIcon(icons, size = 16) { function createList(e, enabled) { return `
  • - - + + + ${e.name} - ${e.name} + ${ + e.optionsUrl ? ` + + + + ` : `` + }
  • `; }