Grammalecte  Check-in [ef8e7e4dcf]

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 on 2018-12-19 12:57:25
Other Links: branch diff | manifest | tags
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: fx, comdic
11:28
[fx] ui: buttons color update check-in: 09ee3a6bc8 user: olr tags: fx, comdic
Changes

Modified gc_lang/fr/webext/background.js from [963b50e25b] to [8000393b2f].

379
380
381
382
383
384
385

386
387
388
389


390
391
392


393
394
395
396
397
398
399
379
380
381
382
383
384
385
386
387
388


389
390



391
392
393
394
395
396
397
398
399







+


-
-
+
+
-
-
-
+
+









/*
    Tabs
*/
let nTabLexiconEditor = null;
let nTabDictionaries = null;
let nTabConjugueur = null;

browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) {
    if (nTabId === nTabLexiconEditor) {
        nTabLexiconEditor = null;
    switch (nTabId) {
        case nTabLexiconEditor: nTabLexiconEditor = null; break;
    }
    else if (nTabId === nTabDictionaries) {
        nTabDictionaries = null;
        case nTabDictionaries:  nTabDictionaries = null; break;
        case nTabConjugueur:    nTabConjugueur = null; break;
    }
});


/*
    Actions
*/
419
420
421
422
423
424
425



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445



446
447
448
449
450
451
452
453

454
455
456



457
458
459
460
461
462
463















464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491


492
419
420
421
422
423
424
425
426
427
428
429
430
431

432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453

454
455
456
457
458



459
460
461







462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494

495
496
497






498
499
500







+
+
+



-
















+
+
+



-




+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


















-



-
-
-
-
-
-
+
+

            return;
        }
        let xLexEditor = browser.tabs.create({
            url: browser.extension.getURL("panel/lex_editor.html")
        });
        xLexEditor.then(onLexiconEditorOpened, onError);
    }
    else {
        browser.tabs.update(nTabLexiconEditor, {active: true});
    }
}

function onLexiconEditorOpened (xTab) {
    //console.log(xTab);
    nTabLexiconEditor = xTab.id;
}

function openDictionaries () {
    if (nTabDictionaries === null) {
        if (bChrome) {
            browser.tabs.create({
                url: browser.extension.getURL("panel/dictionaries.html")
            }, onDictionariesOpened);
            return;
        }
        let xLexEditor = browser.tabs.create({
            url: browser.extension.getURL("panel/dictionaries.html")
        });
        xLexEditor.then(onDictionariesOpened, onError);
    }
    else {
        browser.tabs.update(nTabDictionaries, {active: true});
    }
}

function onDictionariesOpened (xTab) {
    //console.log(xTab);
    nTabDictionaries = xTab.id;
}

function openConjugueurTab () {
    if (nTabDictionaries === null) {
    if (bChrome) {
        browser.tabs.create({
            url: browser.extension.getURL("panel/conjugueur.html")
        if (bChrome) {
            browser.tabs.create({
                url: browser.extension.getURL("panel/conjugueur.html")
        });
        return;
    }
    let xConjTab = browser.tabs.create({
        url: browser.extension.getURL("panel/conjugueur.html")
    });
    xConjTab.then(onCreated, onError);
            }, onConjugueurOpened);
            return;
        }
        let xConjTab = browser.tabs.create({
            url: browser.extension.getURL("panel/conjugueur.html")
        });
        xConjTab.then(onConjugueurOpened, onError);
    }
    else {
        browser.tabs.update(nTabConjugueur, {active: true});
    }
}

function onConjugueurOpened (xTab) {
    nTabConjugueur = xTab.id;
}

function openConjugueurWindow () {
    if (bChrome) {
        browser.windows.create({
            url: browser.extension.getURL("panel/conjugueur.html"),
            type: "popup",
            width: 710,
            height: 980
        });
        return;
    }
    let xConjWindow = browser.windows.create({
        url: browser.extension.getURL("panel/conjugueur.html"),
        type: "popup",
        width: 710,
        height: 980
    });
    xConjWindow.then(onCreated, onError);
}


function onCreated (xWindowInfo) {
    //console.log(`Created window: ${xWindowInfo.id}`);
}

function onError (error) {
    console.log(error);
function onError (e) {
    console.error(e);
}