1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-25 00:16:12 +00:00
quickdial-webext/src/js/settings.js

53 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-10-03 17:43:09 +00:00
var BackgroundImage = null;
window.onload = function(){
browser.runtime.getBackgroundPage().then(function(page){
app = page.app;
BackgroundColor.value = app.settings.backgroundColor;
BackgroundImage = app.settings.backgroundImage;
GridRows.value = app.settings.grid.rows;
GridMargins.value = app.settings.grid.margin;
GridColumns.value = app.settings.grid.columns;
GridCellsMargins.value = app.settings.grid.cells.margin;
GridCellsBorderRadius.value = app.settings.grid.cells.borderRadius;
GridCellsBorderColor.value = app.settings.grid.cells.borderColor;
GridCellsBorderColorHover.value = app.settings.grid.cells.borderColorHover;
GridCellsTitleColor.value = app.settings.grid.cells.titleColor;
GridCellsTitleColorHover.value = app.settings.grid.cells.titleColorHover;
});
BackgroundImageClear.onclick = function(){
BackgroundImage = null;
}
BackgroundImageFile.onclick = function(){
this.value = null;
}
BackgroundImageFile.onchange = function(){
var fileReader = new FileReader();
fileReader.onload = function(e){
BackgroundImage = 'url(' + e.target.result + ')';
}
fileReader.readAsDataURL(BackgroundImageFile.files[0]);
}
BtnOk.onclick = function(){
BtnApply.onclick();
window.frameElement.popup.close();
}
BtnApply.onclick = function(){
app.settings.backgroundColor = BackgroundColor.value;
app.settings.backgroundImage = BackgroundImage;
app.settings.grid.rows = GridRows.value;
app.settings.grid.margin = GridMargins.value;
app.settings.grid.columns = GridColumns.value;
app.settings.grid.cells.borderRadius = GridCellsBorderRadius.value;
app.settings.grid.cells.borderColor = GridCellsBorderColor.value;
app.settings.grid.cells.borderColorHover = GridCellsBorderColorHover.value;
app.settings.grid.cells.titleColor = GridCellsTitleColor.value;
app.settings.grid.cells.titleColorHover = GridCellsTitleColorHover.value;
app.saveSettings();
}
BtnCancel.onclick = function(){
window.frameElement.popup.close();
}
}