diff --git a/browser/base/content/tabcandy/app/groups.js b/browser/base/content/tabcandy/app/groups.js index 3f45fe80affc..ce794ba4c9ed 100644 --- a/browser/base/content/tabcandy/app/groups.js +++ b/browser/base/content/tabcandy/app/groups.js @@ -311,20 +311,21 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), { var css = {}; var titlebarCSS = {}; var contentCSS = {}; + var force = false; - if(rect.left != this.bounds.left) + if(force || rect.left != this.bounds.left) css.left = rect.left; - if(rect.top != this.bounds.top) + if(force || rect.top != this.bounds.top) css.top = rect.top; - if(rect.width != this.bounds.width) { + if(force || rect.width != this.bounds.width) { css.width = rect.width; titlebarCSS.width = rect.width; contentCSS.width = rect.width; } - if(rect.height != this.bounds.height) { + if(force || rect.height != this.bounds.height) { css.height = rect.height; contentCSS.height = rect.height - titleHeight; } @@ -349,6 +350,10 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), { // ___ Update our representation if(immediately) { + $(this.container).stop(true, true); + this.$titlebar.stop(true, true); + this.$content.stop(true, true); + $(this.container).css(css); this.$titlebar.css(titlebarCSS); this.$content.css(contentCSS); @@ -503,6 +508,9 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), { if(typeof(item.setResizable) == 'function') item.setResizable(false); + + if(item.tab == Utils.activeTab) + Groups.setActiveGroup(this); } if(!options.dontArrange) diff --git a/browser/base/content/tabcandy/app/ui.js b/browser/base/content/tabcandy/app/ui.js index 85bf1ca9cce6..28166e03c86e 100644 --- a/browser/base/content/tabcandy/app/ui.js +++ b/browser/base/content/tabcandy/app/ui.js @@ -53,6 +53,8 @@ Navbar = { } // ########## +// Class: Tabbar +// Singleton for managing the tabbar of the browser. var Tabbar = { // ---------- // Variable: _hidden @@ -99,10 +101,10 @@ var Tabbar = { // tab bar. getVisibleTabs: function(){ var visibleTabs = []; - // UI.tabBar.el.children is not a real array and does contain + // this.el.children is not a real array and does contain // useful functions like filter or forEach. Convert it into a real array. - for( var i=0; i objects. showOnlyTheseTabs: function(tabs){ var visibleTabs = []; - // UI.tabBar.el.children is not a real array and does contain + // this.el.children is not a real array and does contain // useful functions like filter or forEach. Convert it into a real array. var tabBarTabs = []; - for( var i=0; i. window.Page = { startX: 30, startY: 70, @@ -257,49 +262,65 @@ window.Page = { return false; }); - var lastTab = null; Tabs.onFocus(function(){ // If we switched to TabCandy window... - if( this.contentWindow == window && lastTab != null && lastTab.mirror != null){ + if( this.contentWindow == window){ var activeGroup = Groups.getActiveGroup(); if( activeGroup ) activeGroup.reorderBasedOnTabOrder(); - UI.tabBar.hide(false); - // If there was a lastTab we want to animate - // its mirror for the zoom out. - // Zoom out! - var $tab = $(lastTab.mirror.el); - self.setActiveTab($(lastTab.mirror.el).data().tabItem); + if(window.UI) + UI.tabBar.hide(); - var rotation = $tab.css("-moz-transform"); - var [w,h, pos, z] = [$tab.width(), $tab.height(), $tab.position(), $tab.css("zIndex")]; - var scale = window.innerWidth / w; - - var overflow = $("body").css("overflow"); - $("body").css("overflow", "hidden"); - - var mirror = lastTab.mirror; - TabMirror.pausePainting(); - $tab.css({ - top: 0, left: 0, - width: window.innerWidth, - height: h * (window.innerWidth/w), - zIndex: 999999, - '-moz-transform': 'rotate(0deg)' - }).animate({ - top: pos.top, left: pos.left, - width: w, height: h - },350, '', function() { + if(UI.currentTab != null && UI.currentTab.mirror != null) { + // If there was a previous currentTab we want to animate + // its mirror for the zoom out. + // Zoom out! + + var mirror = UI.currentTab.mirror; + var $tab = $(mirror.el); + var item = $tab.data().tabItem; + self.setActiveTab(item); + + var rotation = $tab.css("-moz-transform"); + var [w,h, pos, z] = [$tab.width(), $tab.height(), $tab.position(), $tab.css("zIndex")]; + var scale = window.innerWidth / w; + + var overflow = $("body").css("overflow"); + $("body").css("overflow", "hidden"); + + TabMirror.pausePainting(); $tab.css({ - zIndex: z, - '-moz-transform': rotation + top: 0, left: 0, + width: window.innerWidth, + height: h * (window.innerWidth/w), + zIndex: 999999, + '-moz-transform': 'rotate(0deg)' + }).animate({ + top: pos.top, left: pos.left, + width: w, height: h + },350, '', function() { + $tab.css({ + zIndex: z, + '-moz-transform': rotation + }); + $("body").css("overflow", overflow); + window.Groups.setActiveGroup(null); + TabMirror.resumePainting(); +/* + if(item && item.parent) + item.parent.arrange(); +*/ }); - $("body").css("overflow", overflow); - window.Groups.setActiveGroup(null); - TabMirror.resumePainting(); - }); + } + } else { // switched to another tab + var item = TabItems.getItemByTab(Utils.activeTab); + if(item) + Groups.setActiveGroup(item.parent); + + UI.tabBar.show(); } - lastTab = this; + + UI.currentTab = this; }); }, @@ -421,10 +442,29 @@ ArrangeClass.prototype = { } // ########## +// Class: UIClass +// Singleton top-level UI manager. TODO: Integrate with . function UIClass(){ + // Variable: navBar + // A reference to the , for manipulating the browser's nav bar. this.navBar = Navbar; + + // Variable: tabBar + // A reference to the , for manipulating the browser's tab bar. this.tabBar = Tabbar; + + // Variable: devMode + // If true (set by an url parameter), adds extra features to the screen. + // TODO: Integrate with the dev menu this.devMode = false; + + // Variable: currentTab + // Keeps track of which tab we are currently on. + // Used to facilitate zooming down from a previous tab. + this.currentTab = Utils.activeTab; + + // Variable: focused + // Keeps track of whether Tab Candy is focused. this.focused = (Utils.activeTab == Utils.homeTab); var self = this; @@ -455,6 +495,7 @@ function UIClass(){ if(this.contentWindow.location.host == "tabcandy") { self.focused = true; self.navBar.hide(); + self.tabBar.hide(); } else { self.focused = false; self.navBar.show(); diff --git a/browser/base/content/tabcandy/core/mirror.js b/browser/base/content/tabcandy/core/mirror.js index 3ba1048b1026..b27d357a1bcb 100644 --- a/browser/base/content/tabcandy/core/mirror.js +++ b/browser/base/content/tabcandy/core/mirror.js @@ -188,12 +188,10 @@ TabMirror.prototype = { init: function(){ var self = this; -/* // When a tab is opened, create the mirror Tabs.onOpen(function() { - self.update(this); +/* self.update(this); */ }); -*/ // When a tab is updated, update the mirror Tabs.onReady( function(evt){