javascript - Extension dialogs: across-session info, "pre-load" event and how to center startup dialog? -
i working on small extension personal consumption , practice. provide information every time firefox starts using modal dialog. know frowned upon, know-how. have few question regarding things---i feel there better ways them. kindly share wisdom:
i have created small dialog xul, , have event listener registered load event of main window. display dialog, use:
window.opendialog("chrome://myext/content/prompt.xul", "dialogname", "chrome,dialog,modal,centerscreen,resizable", params).focus();
problem 1: can never start dialog on center screen (even if have centerscreen
enabled), starts top left---it nice have in middle---something firefox's password-on-startup request. how can achieve that?
- i modal window open once per session, if there multiple instances of firefox. have done accomplish is, once dialog runs, set extension preference, , check before opening dialog on "load" event of new window.
problem 2: make sure somehow don't have preferences set previous session, try check if first window opened, , if so, reset preferences. safe, reset them on unload event of last window closes. discover first/last load , unload, use nsiwindowwatcher
service, , see if can traverse returned enumerator:
var ww = components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getservice(components.interfaces.nsiwindowwatcher); var en = ww.getwindowenumerator(); var win1 = en.getnext(); //if there no more en.getnext(), 1st window
there has better way this, no? event fires once per session (not per window) example?
- if dialog box cancelled, want firefox close down. right now, accomplish through simple
window.close()
associated cancel button of dialog. however, since original load (which triggered modal dialog) called after page finishes loading, can see small glimpse of homepage before closes duewindow.close()
---this not elegant. there event similar "before_page_load"? proper way accomplish goal.
once again, personal use, kindly ignore usability factor of startup modal dialog.
you need observe final-ui-startup
notification, happens before main window opens. registering component observe profile-after-change
notification, during notification, add observe final-ui-startup
notification. when component subsequently receives notification, can open modal dialog , subsequently quit application if necessary.
Comments
Post a Comment