Skip to content

Commit d81dc22

Browse files
authored
Merge pull request #5 from HangYang/inline-icons
Add explicit options icon
2 parents 53b1124 + 6046e3e commit d81dc22

File tree

3 files changed

+37
-40
lines changed

3 files changed

+37
-40
lines changed

icon-options.svg

Lines changed: 1 addition & 0 deletions
Loading

popup.css

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ input {
4949
list-style: none;
5050
}
5151
.ext {
52-
overflow: hidden;
53-
text-overflow: ellipsis;
52+
display: flex;
5453
white-space: nowrap;
5554
font-size: 1.2em;
5655
line-height: 1.8;
@@ -68,28 +67,28 @@ input {
6867
.ext.disabled + .disabled {
6968
margin-top: 0;
7069
}
71-
.ext:hover {
72-
background-color: #ecf0f1;
73-
cursor: pointer;
74-
}
75-
.extIcon {
76-
margin-right: 0.3em;
77-
}
78-
.extIcon a{
79-
cursor: default;
70+
.extName {
71+
flex-grow: 1;
72+
overflow: hidden;
73+
text-overflow: ellipsis;
8074
}
81-
.extIcon img {
75+
.ext img {
8276
width: 16px;
8377
height: 16px;
84-
cursor: default;
8578
vertical-align: -3px;
8679
}
87-
a .hasOpt {
88-
overflow: hidden;
89-
transition-duration: 0.8s;
90-
transition-property: transform;
80+
.extIcon {
81+
margin-right: 0.3em;
82+
}
83+
.extOptions {
84+
padding: 0 0.3em;
85+
opacity: 0.1;
86+
}
87+
.ext > *:hover {
88+
background-color: #ecf0f1;
9189
cursor: pointer;
9290
}
93-
.hasOpt:hover {
94-
transform: rotate(360deg);
91+
*:hover + .extOptions,
92+
.extOptions:hover {
93+
opacity: 1;
9594
}

popup.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const getI18N = chrome.i18n.getMessage;
44
const searchText = $('#searchext');
55

66
// disable the default context menu
7-
window.oncontextmenu = () => false;
7+
eul.on('contextmenu', () => false);
88

99
searchText.attr('placeholder', getI18N('searchTxt')).focus();
1010

@@ -56,9 +56,8 @@ cme.getAll(ets => {
5656
$('#pbgjpgbpljobkekbhnnmlikbbfhbhmem').remove();
5757
});
5858

59-
$('body').on('click', 'li.ext', function (e) {
60-
const that = $(this);
61-
const extSel = that.find('.extName');
59+
$('body').on('click', '.extName', function (e) {
60+
const extSel = $(this);
6261
const eid = extSel.attr('data-id');
6362
cme.get(eid, e => {
6463
extSel.parent().remove();
@@ -72,17 +71,11 @@ $('body').on('click', 'li.ext', function (e) {
7271
});
7372
}
7473
});
75-
}).on('click', 'li .extIcon a', function (e) {
76-
const that = $(this);
77-
const href = that.attr('href');
78-
if (href !== '#') {
79-
chrome.tabs.create({url: href});
80-
}
81-
}).on('mouseup', 'li.ext', function (e) {
74+
}).on('click', '.extOptions', e => {
75+
chrome.tabs.create({url: e.target.href});
76+
}).on('mouseup', '.extName', e => {
8277
if (e.which == 3) {
83-
const that = $(this);
84-
const eid = that.find('.extName').attr('data-id');
85-
cme.uninstall(eid);
78+
cme.uninstall(e.target.dataset.id);
8679
}
8780
});
8881

@@ -114,21 +107,25 @@ function getIcon(icons, size = 16) {
114107
return false;
115108
}
116109
selectedIcon = icon.url;
117-
})
110+
});
118111
}
119112
return selectedIcon;
120113
}
121114

122115
function createList(e, enabled) {
123116
return `
124117
<li class='ext ${enabled ? '' : 'disabled'}' id='${e.id}' data-name="${e.name.toLowerCase()}">
125-
<span class='extIcon' title='${e.optionsUrl ? getI18N('openOpt') : ''}'>
126-
<a href='${e.optionsUrl ? e.optionsUrl : ''}'><img
127-
src='${getIcon(e.icons, 16)}'
128-
class='${e.optionsUrl ? 'hasOpt' : ''}'
129-
></a>
118+
<span class='extName' data-id='${e.id}' title='${getI18N('toggleEnable')}'>
119+
<img class='extIcon' src='${getIcon(e.icons, 16)}'>
120+
${e.name}
130121
</span>
131-
<span class='extName' data-id='${e.id}' title='${getI18N('toggleEnable')}'>${e.name}</span>
122+
${
123+
e.optionsUrl ? `
124+
<a class='extOptions' href='${e.optionsUrl}' title='${getI18N('openOpt')}'>
125+
<img src="${chrome.extension.getURL('icon-options.svg')}">
126+
</a>
127+
` : ``
128+
}
132129
</li>
133130
`;
134131
}

0 commit comments

Comments
 (0)