mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
+ Fixed an unfortunate bug in Rect copying
+ Now reconstituting groups from saved file + Now saving and reconstituting tabs + Fixed start up problem when there's only one tab
This commit is contained in:
parent
b73910fa14
commit
4f29244c0c
@ -41,7 +41,10 @@ window.Group = function(listOfEls, options) {
|
||||
|
||||
var self = this;
|
||||
|
||||
var rectToBe = options.bounds;
|
||||
var rectToBe;
|
||||
if(options.bounds)
|
||||
rectToBe = new Rect(options.bounds);
|
||||
|
||||
if(!rectToBe) {
|
||||
var boundingBox = this._getBoundingBox(listOfEls);
|
||||
var padding = 30;
|
||||
@ -622,17 +625,6 @@ window.Groups = {
|
||||
|
||||
// ----------
|
||||
init: function() {
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
// we do this in a timeout, as window.innerHeight hasn't adjusted for Firebug initially
|
||||
var pad = 5;
|
||||
var sw = window.innerWidth;
|
||||
var sh = window.innerHeight;
|
||||
var w = sw - (pad * 2);
|
||||
var h = TabItems.tabHeight;
|
||||
var box = new Rect(pad, sh - (h + pad), w, h);
|
||||
self.newTabGroup = new Group([], {bounds: box, title: 'New Tabs', locked: true});
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// ----------
|
||||
@ -645,6 +637,23 @@ window.Groups = {
|
||||
return data;
|
||||
},
|
||||
|
||||
// ----------
|
||||
reconstitute: function(data) {
|
||||
if(data && data.groups) {
|
||||
$.each(data.groups, function(index, group) {
|
||||
new Group([], group);
|
||||
});
|
||||
} else {
|
||||
var pad = 5;
|
||||
var sw = window.innerWidth;
|
||||
var sh = window.innerHeight;
|
||||
var w = sw - (pad * 2);
|
||||
var h = TabItems.tabHeight;
|
||||
var box = new Rect(pad, sh - (h + pad), w, h);
|
||||
new Group([], {bounds: box, title: 'New Tabs', locked: true});
|
||||
}
|
||||
},
|
||||
|
||||
// ----------
|
||||
register: function(group) {
|
||||
Utils.assert('only register once per group', $.inArray(group, this.groups) == -1);
|
||||
|
@ -7,6 +7,19 @@ window.TabItem = function(container, tab) {
|
||||
};
|
||||
|
||||
window.TabItem.prototype = $.extend(new Item(), {
|
||||
// ----------
|
||||
getStorageData: function() {
|
||||
return {
|
||||
bounds: this.bounds,
|
||||
url: this.tab.url
|
||||
};
|
||||
},
|
||||
|
||||
// ----------
|
||||
getURL: function() {
|
||||
return this.tab.url;
|
||||
},
|
||||
|
||||
// ----------
|
||||
_getSizeExtra: function() {
|
||||
var $container = $(this.container);
|
||||
@ -153,6 +166,7 @@ window.TabItems = {
|
||||
tabHeight: 120,
|
||||
fontSize: 9,
|
||||
|
||||
// ----------
|
||||
init: function() {
|
||||
var self = this;
|
||||
|
||||
@ -237,14 +251,8 @@ window.TabItems = {
|
||||
items.push(item);
|
||||
});
|
||||
|
||||
if($div.length == 1)
|
||||
if($div.length == 1 && Groups)
|
||||
Groups.newTab($div.data('tabItem'));
|
||||
else {
|
||||
var box = Items.getPageBounds();
|
||||
box.inset(20, 20);
|
||||
|
||||
Items.arrange(items, box, {padding: 10, animate:false});
|
||||
}
|
||||
|
||||
// TODO: Figure out this really weird bug?
|
||||
// Why is that:
|
||||
@ -263,6 +271,47 @@ window.TabItems = {
|
||||
}
|
||||
|
||||
window.TabMirror.customize(mod);
|
||||
},
|
||||
|
||||
// ----------
|
||||
getItems: function() {
|
||||
var items = [];
|
||||
$('.tab').each(function() {
|
||||
items.push($(this).data('tabItem'));
|
||||
});
|
||||
|
||||
return items;
|
||||
},
|
||||
|
||||
// ----------
|
||||
getStorageData: function() {
|
||||
var data = {tabs: []};
|
||||
var items = this.getItems();
|
||||
$.each(items, function(index, item) {
|
||||
data.tabs.push(item.getStorageData());
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
// ----------
|
||||
reconstitute: function(data) {
|
||||
var items = this.getItems();
|
||||
if(data && data.tabs) {
|
||||
$.each(data.tabs, function(index, tab) {
|
||||
$.each(items, function(index, item) {
|
||||
if(item.getURL() == tab.url) {
|
||||
item.setBounds(tab.bounds);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
var box = Items.getPageBounds();
|
||||
box.inset(20, 20);
|
||||
|
||||
Items.arrange(items, box, {padding: 10, animate:false});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -275,16 +275,24 @@ function UIClass(){
|
||||
var data = Storage.read();
|
||||
if(data.hideTabBar)
|
||||
this.hideTabBar();
|
||||
|
||||
$(window).unload(function() {
|
||||
var data = {
|
||||
dataVersion: 1,
|
||||
hideTabBar: self.tabBar._hidden,
|
||||
groups: Groups.getStorageData()
|
||||
};
|
||||
|
||||
Storage.write(data);
|
||||
Groups.reconstitute(data.groups);
|
||||
TabItems.reconstitute(data.tabs);
|
||||
|
||||
$(window).bind('beforeunload', function() {
|
||||
if(self.initialized) {
|
||||
var data = {
|
||||
dataVersion: 1,
|
||||
hideTabBar: self.tabBar._hidden,
|
||||
groups: Groups.getStorageData(),
|
||||
tabs: TabItems.getStorageData()
|
||||
};
|
||||
|
||||
Storage.write(data);
|
||||
}
|
||||
});
|
||||
|
||||
this.initialized = true;
|
||||
};
|
||||
|
||||
// ----------
|
||||
|
@ -41,7 +41,7 @@ window.Point.prototype = {
|
||||
window.Rect = function(a, top, width, height) {
|
||||
// Note: perhaps 'a' should really be called 'rectOrLeft'
|
||||
if(typeof(a.left) != 'undefined' && typeof(a.top) != 'undefined'
|
||||
&& typeof(a.right) != 'undefined' && typeof(a.bottom) != 'undefined') {
|
||||
&& typeof(a.width) != 'undefined' && typeof(a.height) != 'undefined') {
|
||||
this.left = a.left;
|
||||
this.top = a.top;
|
||||
this.width = a.width;
|
||||
|
Loading…
Reference in New Issue
Block a user