Grammalecte  Check-in [ef8e7e4dcf]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[fx] prevent multi-tabs opening, activate tab if already opened
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | comdic
Files: files | file ages | folders
SHA3-256:ef8e7e4dcf0520c9384d01b28999ecb790bdb643bf462e6da37c2e9c32d39b90
User & Date: olr 2018-12-19 12:57:25
Context
2019-01-09
17:22
merge trunk check-in: 096875de48 user: olr tags: comdic
2018-12-19
12:57
[fx] prevent multi-tabs opening, activate tab if already opened check-in: ef8e7e4dcf user: olr tags: comdic, fx
11:28
[fx] ui: buttons color update check-in: 09ee3a6bc8 user: olr tags: comdic, fx
Changes

Changes to gc_lang/fr/webext/background.js.

   379    379   
   380    380   
   381    381   /*
   382    382       Tabs
   383    383   */
   384    384   let nTabLexiconEditor = null;
   385    385   let nTabDictionaries = null;
          386  +let nTabConjugueur = null;
   386    387   
   387    388   browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) {
   388         -    if (nTabId === nTabLexiconEditor) {
   389         -        nTabLexiconEditor = null;
   390         -    }
   391         -    else if (nTabId === nTabDictionaries) {
   392         -        nTabDictionaries = null;
          389  +    switch (nTabId) {
          390  +        case nTabLexiconEditor: nTabLexiconEditor = null; break;
          391  +        case nTabDictionaries:  nTabDictionaries = null; break;
          392  +        case nTabConjugueur:    nTabConjugueur = null; break;
   393    393       }
   394    394   });
   395    395   
   396    396   
   397    397   /*
   398    398       Actions
   399    399   */
................................................................................
   419    419               return;
   420    420           }
   421    421           let xLexEditor = browser.tabs.create({
   422    422               url: browser.extension.getURL("panel/lex_editor.html")
   423    423           });
   424    424           xLexEditor.then(onLexiconEditorOpened, onError);
   425    425       }
          426  +    else {
          427  +        browser.tabs.update(nTabLexiconEditor, {active: true});
          428  +    }
   426    429   }
   427    430   
   428    431   function onLexiconEditorOpened (xTab) {
   429         -    //console.log(xTab);
   430    432       nTabLexiconEditor = xTab.id;
   431    433   }
   432    434   
   433    435   function openDictionaries () {
   434    436       if (nTabDictionaries === null) {
   435    437           if (bChrome) {
   436    438               browser.tabs.create({
................................................................................
   439    441               return;
   440    442           }
   441    443           let xLexEditor = browser.tabs.create({
   442    444               url: browser.extension.getURL("panel/dictionaries.html")
   443    445           });
   444    446           xLexEditor.then(onDictionariesOpened, onError);
   445    447       }
          448  +    else {
          449  +        browser.tabs.update(nTabDictionaries, {active: true});
          450  +    }
   446    451   }
   447    452   
   448    453   function onDictionariesOpened (xTab) {
   449         -    //console.log(xTab);
   450    454       nTabDictionaries = xTab.id;
   451    455   }
   452    456   
   453    457   function openConjugueurTab () {
   454         -    if (bChrome) {
   455         -        browser.tabs.create({
          458  +    if (nTabDictionaries === null) {
          459  +        if (bChrome) {
          460  +            browser.tabs.create({
          461  +                url: browser.extension.getURL("panel/conjugueur.html")
          462  +            }, onConjugueurOpened);
          463  +            return;
          464  +        }
          465  +        let xConjTab = browser.tabs.create({
   456    466               url: browser.extension.getURL("panel/conjugueur.html")
   457    467           });
   458         -        return;
          468  +        xConjTab.then(onConjugueurOpened, onError);
          469  +    }
          470  +    else {
          471  +        browser.tabs.update(nTabConjugueur, {active: true});
   459    472       }
   460         -    let xConjTab = browser.tabs.create({
   461         -        url: browser.extension.getURL("panel/conjugueur.html")
   462         -    });
   463         -    xConjTab.then(onCreated, onError);
          473  +}
          474  +
          475  +function onConjugueurOpened (xTab) {
          476  +    nTabConjugueur = xTab.id;
   464    477   }
   465    478   
   466    479   function openConjugueurWindow () {
   467    480       if (bChrome) {
   468    481           browser.windows.create({
   469    482               url: browser.extension.getURL("panel/conjugueur.html"),
   470    483               type: "popup",
................................................................................
   475    488       }
   476    489       let xConjWindow = browser.windows.create({
   477    490           url: browser.extension.getURL("panel/conjugueur.html"),
   478    491           type: "popup",
   479    492           width: 710,
   480    493           height: 980
   481    494       });
   482         -    xConjWindow.then(onCreated, onError);
   483    495   }
   484    496   
   485    497   
   486         -function onCreated (xWindowInfo) {
   487         -    //console.log(`Created window: ${xWindowInfo.id}`);
   488         -}
   489         -
   490         -function onError (error) {
   491         -    console.log(error);
          498  +function onError (e) {
          499  +    console.error(e);
   492    500   }