@@ -4,7 +4,7 @@ const getI18N = chrome.i18n.getMessage;
44const searchText = $ ( '#searchext' ) ;
55
66// disable the default context menu
7- window . oncontextmenu = ( ) => false ;
7+ eul . on ( 'contextmenu' , ( ) => false ) ;
88
99searchText . 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
122115function 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