B2G/gecko/browser/components/tabview/ui.js
// Must be called after the object is created.
Must be called after the object is created.
Must be called after the object is created .
function UI_init() {
    try {
      let self = this;
      this._initPageDirection();
      Storage.init();
      if (Storage.readWindowBusyState(gWindow))
        this.storageBusy();
      let data = Storage.readUIData(gWindow);
      this._storageSanity(data);
      this._pageBounds = data.pageBounds;
      Search.init();
      Telemetry.init();
      this._currentTab = gBrowser.selectedTab;
      iQ("#exit-button").click(function() {
        self.exit();
        self.blurAll();
      })
      .attr("title", tabviewString("button.exitTabGroups"));
      iQ(gTabViewFrame.contentDocument).mousedown(function(e) {
        if (iQ(":focus").length > 0) {
          iQ(":focus").each(function(element) {
            if (e.target != element && element.nodeName == "INPUT")
              element.blur();
          });
        }
        if (e.originalTarget.id == "content" &&
            Utils.isLeftClick(e) &&
            e.detail == 1) {
          self._createGroupItemOnDrag(e);
        }
      });
      iQ(gTabViewFrame.contentDocument).dblclick(function(e) {
        if (e.originalTarget.id != "content")
          return;
        let box =
          new Rect(e.clientX - Math.floor(TabItems.tabWidth/2),
                   e.clientY - Math.floor(TabItems.tabHeight/2),
                   TabItems.tabWidth, TabItems.tabHeight);
        box.inset(-30, -30);
        let opts = {immediately: true, bounds: box};
        let groupItem = new GroupItem([], opts);
        groupItem.newTab();
        gTabView.firstUseExperienced = true;
      });
      iQ(window).bind("unload", function() {
        self.uninit();
      });
      let mm = gWindow.messageManager;
      let callback = this._onDOMWillOpenModalDialog.bind(this);
      mm.addMessageListener("Panorama:DOMWillOpenModalDialog", callback);
      this._cleanupFunctions.push(function () {
        mm.removeMessageListener("Panorama:DOMWillOpenModalDialog", callback);
      });
      this._setTabViewFrameKeyHandlers();
      this._addTabActionHandlers();
      GroupItems.init();
      GroupItems.pauseArrange();
      let hasGroupItemsData = GroupItems.load();
      TabItems.init();
      TabItems.pausePainting();
      FavIcons.init();
      if (!hasGroupItemsData)
        this.reset();
      if (this._pageBounds)
        this._resize(true);
      else
        this._pageBounds = Items.getPageBounds();
      iQ(window).resize(function() {
        self._resize();
      });
      gWindow.addEventListener("SSWindowClosing", function onWindowClosing() {
        gWindow.removeEventListener("SSWindowClosing", onWindowClosing, false);
        self.isDOMWindowClosing = true;
        if (self.isTabViewVisible())
          GroupItems.removeHiddenGroups();
        TabItems.saveAll();
        self._save();
      }, false);
      let frameScript = "chrome://browser/content/tabview-content.js";
      gWindow.messageManager.loadFrameScript(frameScript, true);
      this._frameInitialized = true;
      this._save();
      let event = document.createEvent("Events");
      event.initEvent("tabviewframeinitialized", true, false);
      dispatchEvent(event);
    } catch(e) {
      Utils.log(e);
    } finally {
      GroupItems.resumeArrange();
    }
  }
function UI_init ( ) { try { let self = this ; this . _initPageDirection ( ) ; Storage . init ( ) ; if ( Storage . readWindowBusyState ( gWindow ) ) this . storageBusy ( ) ; let data = Storage . readUIData ( gWindow ) ; this . _storageSanity ( data ) ; this . _pageBounds = data . pageBounds ; Search . init ( ) ; Telemetry . init ( ) ; this . _currentTab = gBrowser . selectedTab ; iQ ( "#exit-button" ) . click ( function ( ) { self . exit ( ) ; self . blurAll ( ) ; } ) . attr ( "title" , tabviewString ( "button.exitTabGroups" ) ) ; iQ ( gTabViewFrame . contentDocument ) . mousedown ( function ( e ) { if ( iQ ( ":focus" ) . length > 0 ) { iQ ( ":focus" ) . each ( function ( element ) { if ( e . target != element && element . nodeName == "INPUT" ) element . blur ( ) ; } ) ; } if ( e . originalTarget . id == "content" && Utils . isLeftClick ( e ) && e . detail == 1 ) { self . _createGroupItemOnDrag ( e ) ; } } ) ; iQ ( gTabViewFrame . contentDocument ) . dblclick ( function ( e ) { if ( e . originalTarget . id != "content" ) return ; let box = new Rect ( e . clientX - Math . floor ( TabItems . tabWidth / 2 ) , e . clientY - Math . floor ( TabItems . tabHeight / 2 ) , TabItems . tabWidth , TabItems . tabHeight ) ; box . inset ( - 30 , - 30 ) ; let opts = { immediately : true , bounds : box } ; let groupItem = new GroupItem ( [ ] , opts ) ; groupItem . newTab ( ) ; gTabView . firstUseExperienced = true ; } ) ; iQ ( window ) . bind ( "unload" , function ( ) { self . uninit ( ) ; } ) ; let mm = gWindow . messageManager ; let callback = this . _onDOMWillOpenModalDialog . bind ( this ) ; mm . addMessageListener ( "Panorama:DOMWillOpenModalDialog" , callback ) ; this . _cleanupFunctions . push ( function ( ) { mm . removeMessageListener ( "Panorama:DOMWillOpenModalDialog" , callback ) ; } ) ; this . _setTabViewFrameKeyHandlers ( ) ; this . _addTabActionHandlers ( ) ; GroupItems . init ( ) ; GroupItems . pauseArrange ( ) ; let hasGroupItemsData = GroupItems . load ( ) ; TabItems . init ( ) ; TabItems . pausePainting ( ) ; FavIcons . init ( ) ; if ( ! hasGroupItemsData ) this . reset ( ) ; if ( this . _pageBounds ) this . _resize ( true ) ; else this . _pageBounds = Items . getPageBounds ( ) ; iQ ( window ) . resize ( function ( ) { self . _resize ( ) ; } ) ; gWindow . addEventListener ( "SSWindowClosing" , function onWindowClosing ( ) { gWindow . removeEventListener ( "SSWindowClosing" , onWindowClosing , false ) ; self . isDOMWindowClosing = true ; if ( self . isTabViewVisible ( ) ) GroupItems . removeHiddenGroups ( ) ; TabItems . saveAll ( ) ; self . _save ( ) ; } , false ) ; let frameScript = "chrome://browser/content/tabview-content.js" ; gWindow . messageManager . loadFrameScript ( frameScript , true ) ; this . _frameInitialized = true ; this . _save ( ) ; let event = document . createEvent ( "Events" ) ; event . initEvent ( "tabviewframeinitialized" , true , false ) ; dispatchEvent ( event ) ; } catch ( e ) { Utils . log ( e ) ; } finally { GroupItems . resumeArrange ( ) ; } }
Must be called after the object is created.
Must be called after the object is created .
// initialize the direction of the page // ___ storage // ___ search // ___ currentTab // ___ exit button // When you click on the background/empty part of TabView, // we create a new groupItem. // don't fire blur event if the same input element is clicked. // Create a group with one tab on double click // ___ setup DOMWillOpenModalDialog message handler // ___ setup key handlers // ___ add tab action handlers // ___ groups // ___ tabs // ___ favicons // ___ resizing // ___ setup event listener to save canvas images // XXX bug #635975 - don't unlink the tab if the dom window is closing. // ___ load frame script // ___ Done // fire an iframe initialized event so everyone knows tab view is  // initialized.