mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
+ We're now storing data in a file named after your candy, in a folder named 'tabcandy' inside your profile folder (e.g. tabcandy/revision-a.json). Currently the only data that's round-tripped is whether you have hidden the tab bar, but we are saving group data out (just not reading it yet).
+ The nav bar wasn't successfully hiding when first starting the browser; fixed.
This commit is contained in:
parent
9854addfd4
commit
b73910fa14
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,55 @@
|
||||
// ##########
|
||||
Storage = {
|
||||
// ----------
|
||||
init: function() {
|
||||
},
|
||||
|
||||
// ----------
|
||||
read: function() {
|
||||
var data = {};
|
||||
var file = this.getFile();
|
||||
if(file.exists()) {
|
||||
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
|
||||
createInstance(Components.interfaces.nsIFileInputStream);
|
||||
var cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
|
||||
createInstance(Components.interfaces.nsIConverterInputStream);
|
||||
fstream.init(file, -1, 0, 0);
|
||||
cstream.init(fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish
|
||||
|
||||
let (str = {}) {
|
||||
cstream.readString(-1, str); // read the whole file and put it in str.value
|
||||
if(str.value)
|
||||
data = JSON.parse(str.value);
|
||||
}
|
||||
cstream.close(); // this closes fstream
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
// ----------
|
||||
write: function(data) {
|
||||
var file = this.getFile();
|
||||
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
|
||||
createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0);
|
||||
var str = JSON.stringify(data);
|
||||
foStream.write(str, str.length);
|
||||
foStream.close();
|
||||
},
|
||||
|
||||
// ----------
|
||||
getFile: function() {
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties).
|
||||
get("ProfD", Components.interfaces.nsIFile);
|
||||
|
||||
/* var dir = Utils.getInstallDirectory('tabcandy@aza.raskin'); */
|
||||
Utils.log(file);
|
||||
|
||||
file.append('tabcandy');
|
||||
if(!file.exists())
|
||||
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
|
||||
|
||||
file.append(Switch.name + '.json');
|
||||
return file;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,40 +1,48 @@
|
||||
(function(){
|
||||
|
||||
window.Switch = {
|
||||
insert: function(selector, style) {
|
||||
var chunks = window.location.toString().split('/');
|
||||
var myName = chunks[chunks.length - 2];
|
||||
var html = '<div style="font-size: 11px; margin: 5px 0px 0px 5px;'
|
||||
+ style
|
||||
+ '">Candy: <select id="visualization-select">';
|
||||
|
||||
var names = Utils.getVisualizationNames();
|
||||
var count = names.length;
|
||||
var a;
|
||||
for(a = 0; a < count; a++) {
|
||||
var name = names[a];
|
||||
html += '<option value="'
|
||||
+ name
|
||||
+ '"'
|
||||
+ (name == myName ? ' selected="true"' : '')
|
||||
+ '>'
|
||||
+ name
|
||||
+ '</option>';
|
||||
}
|
||||
// ##########
|
||||
window.Switch = {
|
||||
// ----------
|
||||
get name() {
|
||||
var chunks = window.location.toString().split('/');
|
||||
var myName = chunks[chunks.length - 2];
|
||||
return myName;
|
||||
},
|
||||
|
||||
html += '<option disabled="disabled">----------</option>';
|
||||
html += '<option value="">Home</option>';
|
||||
|
||||
html += '</select>';
|
||||
$(selector).prepend(html);
|
||||
$('#visualization-select').change(function () {
|
||||
var name = $(this).val();
|
||||
if(name)
|
||||
location.href = '../' + name + '/index.html';
|
||||
else
|
||||
location.href = '../../index.html';
|
||||
});
|
||||
// ----------
|
||||
insert: function(selector, style) {
|
||||
var myName = this.name;
|
||||
var html = '<div style="font-size: 11px; margin: 5px 0px 0px 5px;'
|
||||
+ style
|
||||
+ '">Candy: <select id="visualization-select">';
|
||||
|
||||
var names = Utils.getVisualizationNames();
|
||||
var count = names.length;
|
||||
var a;
|
||||
for(a = 0; a < count; a++) {
|
||||
var name = names[a];
|
||||
html += '<option value="'
|
||||
+ name
|
||||
+ '"'
|
||||
+ (name == myName ? ' selected="true"' : '')
|
||||
+ '>'
|
||||
+ name
|
||||
+ '</option>';
|
||||
}
|
||||
};
|
||||
|
||||
html += '<option disabled="disabled">----------</option>';
|
||||
html += '<option value="">Home</option>';
|
||||
|
||||
html += '</select>';
|
||||
$(selector).prepend(html);
|
||||
$('#visualization-select').change(function () {
|
||||
var name = $(this).val();
|
||||
if(name)
|
||||
location.href = '../' + name + '/index.html';
|
||||
else
|
||||
location.href = '../../index.html';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -2,30 +2,67 @@
|
||||
|
||||
// ##########
|
||||
Navbar = {
|
||||
// ----------
|
||||
get el(){
|
||||
var win = Utils.activeWindow;
|
||||
var navbar = win.gBrowser.ownerDocument.getElementById("navigator-toolbox");
|
||||
return navbar;
|
||||
if(win) {
|
||||
var navbar = win.gBrowser.ownerDocument.getElementById("navigator-toolbox");
|
||||
return navbar;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
// ----------
|
||||
show: function() {
|
||||
var el = this.el;
|
||||
if(el)
|
||||
el.collapsed = false;
|
||||
else { // needs a little longer to get going
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
self.show();
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
// ----------
|
||||
hide: function() {
|
||||
var el = this.el;
|
||||
if(el)
|
||||
el.collapsed = true;
|
||||
else { // needs a little longer to get going
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
self.hide();
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
show: function(){ this.el.collapsed = false; },
|
||||
hide: function(){ this.el.collapsed = true;}
|
||||
}
|
||||
|
||||
// ##########
|
||||
var Tabbar = {
|
||||
// ----------
|
||||
// Variable: _hidden
|
||||
// We keep track of whether the tabs are hidden in this (internal) variable
|
||||
// so we still have access to that information during the window's unload event,
|
||||
// when window.Tabs no longer exists.
|
||||
_hidden: false,
|
||||
get el(){ return window.Tabs[0].raw.parentNode; },
|
||||
height: window.Tabs[0].raw.parentNode.getBoundingClientRect().height,
|
||||
hide: function(){
|
||||
hide: function() {
|
||||
this._hidden = true;
|
||||
var self = this;
|
||||
$(self.el).animate({"marginTop":-self.height}, 150, function(){
|
||||
self.el.collapsed = true;
|
||||
});
|
||||
},
|
||||
show: function(){
|
||||
show: function() {
|
||||
this._hidden = false;
|
||||
this.el.collapsed = false;
|
||||
$(this.el).animate({"marginTop":0}, 150);
|
||||
},
|
||||
get isHidden(){ return this.el.collapsed; }
|
||||
get isHidden(){ return this._hidden; }
|
||||
}
|
||||
|
||||
// ##########
|
||||
@ -83,17 +120,6 @@ window.Page = {
|
||||
}
|
||||
lastTab = this;
|
||||
});
|
||||
|
||||
$("#tabbar-toggle").click(function(){
|
||||
if( Tabbar.isHidden ){
|
||||
Tabbar.show();
|
||||
$(this).removeClass("tabbar-off");
|
||||
}
|
||||
else {
|
||||
Tabbar.hide();
|
||||
$(this).addClass("tabbar-off");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// ----------
|
||||
@ -233,12 +259,49 @@ function UIClass(){
|
||||
self.navBar.show();
|
||||
});
|
||||
|
||||
// ___ tab bar
|
||||
this.$tabBarToggle = $("#tabbar-toggle")
|
||||
.click(function() {
|
||||
if(self.tabBar.isHidden)
|
||||
self.showTabBar();
|
||||
else
|
||||
self.hideTabBar();
|
||||
});
|
||||
|
||||
// ___ Finish up
|
||||
Page.init();
|
||||
|
||||
// ___ Storage
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
// ----------
|
||||
UIClass.prototype = {
|
||||
// ----------
|
||||
showTabBar: function() {
|
||||
this.tabBar.show();
|
||||
this.$tabBarToggle.removeClass("tabbar-off");
|
||||
},
|
||||
|
||||
// ----------
|
||||
hideTabBar: function() {
|
||||
this.tabBar.hide();
|
||||
this.$tabBarToggle.addClass("tabbar-off");
|
||||
},
|
||||
|
||||
// ----------
|
||||
_addArrangements: function() {
|
||||
this.grid = new ArrangeClass("Grid", function(value) {
|
||||
if(typeof(Groups) != 'undefined')
|
||||
|
Loading…
Reference in New Issue
Block a user