mirror of
https://github.com/MatMoul/quickdial-webext.git
synced 2024-12-23 15:36:12 +00:00
Large change
This commit is contained in:
parent
0f776a6d9f
commit
41c7f0d29a
@ -47,6 +47,11 @@
|
|||||||
"deleteItemConfimation": {
|
"deleteItemConfimation": {
|
||||||
"message": "Delete $1 ?",
|
"message": "Delete $1 ?",
|
||||||
"description": "Text of delete confirmation."
|
"description": "Text of delete confirmation."
|
||||||
|
},
|
||||||
|
|
||||||
|
"menuSettings": {
|
||||||
|
"message": "Quick Dial Settings",
|
||||||
|
"description": "Text of settings menu item."
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,11 @@
|
|||||||
"deleteItemConfimation": {
|
"deleteItemConfimation": {
|
||||||
"message": "Supprimer $1 ?",
|
"message": "Supprimer $1 ?",
|
||||||
"description": "Text of delete confirmation."
|
"description": "Text of delete confirmation."
|
||||||
|
},
|
||||||
|
|
||||||
|
"menuSettings": {
|
||||||
|
"message": "Paramètres Quick Dial",
|
||||||
|
"description": "Text of settings menu item."
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ core.init = function(){ // Init module
|
|||||||
core.Settings = {}; // Settings helper object
|
core.Settings = {}; // Settings helper object
|
||||||
core.Settings.load = function(callback){ // Load settings
|
core.Settings.load = function(callback){ // Load settings
|
||||||
browser.storage.local.get({
|
browser.storage.local.get({
|
||||||
background: '#3c4048',
|
backgroundColor: '#3c4048',
|
||||||
|
backgroundImage: null,
|
||||||
grid: {
|
grid: {
|
||||||
margin: 10,
|
margin: 10,
|
||||||
rows: 4,
|
rows: 4,
|
||||||
@ -26,8 +27,8 @@ core.Settings.load = function(callback){ // Load settings
|
|||||||
borderColorHover: '#a9a9a9',
|
borderColorHover: '#a9a9a9',
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
title: true,
|
title: true,
|
||||||
titleHeight: 18,
|
titleHeight: 16,
|
||||||
titleFontSize: 11,
|
titleFontSize: 10,
|
||||||
titleFont: 'Arial, Verdana, Sans-serif',
|
titleFont: 'Arial, Verdana, Sans-serif',
|
||||||
titleColor: '#ffffff',
|
titleColor: '#ffffff',
|
||||||
titleColorHover: '#33ccff',
|
titleColorHover: '#33ccff',
|
||||||
@ -439,4 +440,5 @@ app.createFolder = core.GridNodes.createFolder;
|
|||||||
app.createBookmark = core.GridNodes.createBookmark;
|
app.createBookmark = core.GridNodes.createBookmark;
|
||||||
app.deleteNode = core.GridNodes.deleteNode;
|
app.deleteNode = core.GridNodes.deleteNode;
|
||||||
app.setNodeIndex = core.GridNodes.setNodeIndex;
|
app.setNodeIndex = core.GridNodes.setNodeIndex;
|
||||||
app.capturePage = core.GridNodes.capturePage;
|
app.capturePage = core.GridNodes.capturePage;
|
||||||
|
app.saveSettings = core.Settings.save;
|
@ -14,7 +14,21 @@ window.onload = function(){
|
|||||||
browser.runtime.onMessage.addListener(function(request, sender, sendResponse){
|
browser.runtime.onMessage.addListener(function(request, sender, sendResponse){
|
||||||
switch(request.command){
|
switch(request.command){
|
||||||
case 'SettingsChanged':
|
case 'SettingsChanged':
|
||||||
//if(app.settings) dial.updateGridLayout(dial.Grid, app.settings.grid, dial.styles.grid);
|
if(app.settings){
|
||||||
|
dial.styles.body.backgroundColor = app.settings.backgroundColor;
|
||||||
|
dial.styles.body.backgroundImage = app.settings.backgroundImage;
|
||||||
|
dial.Body.removeChild(dial.Grid);
|
||||||
|
dial.Grid = dial.initGrid('Grid', app.settings.grid, dial.Body);
|
||||||
|
var url = new URL(window.location);
|
||||||
|
dial.path = url.searchParams.get('path');
|
||||||
|
if(url.searchParams.get('path')) {
|
||||||
|
dial.Node = app.getNode(app.settings.grid.node, dial.path + '/');
|
||||||
|
} else {
|
||||||
|
dial.Node = app.getNode(app.settings.grid.node, '/');
|
||||||
|
}
|
||||||
|
dial.Title.innerText = dial.Node.title;
|
||||||
|
dial.populateGrid(dial.Grid, app.settings.grid, dial.Node);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'GridNodesSaved':
|
case 'GridNodesSaved':
|
||||||
if(app.settings) dial.populateGrid(dial.Grid, app.settings.grid, dial.Node);
|
if(app.settings) dial.populateGrid(dial.Grid, app.settings.grid, dial.Node);
|
||||||
@ -76,7 +90,7 @@ dial.initStyles = function(){
|
|||||||
dial.Style = document.createElement('style'), StyleSheet;
|
dial.Style = document.createElement('style'), StyleSheet;
|
||||||
document.head.appendChild(dial.Style);
|
document.head.appendChild(dial.Style);
|
||||||
dial.styles.html = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('html { height: 100%; }')].style;
|
dial.styles.html = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('html { height: 100%; }')].style;
|
||||||
dial.styles.body = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('body { user-select: none; -moz-user-select: none; display: flex; width: 100%; height: 100%; margin: 0px; padding: 0px; background: ' + app.settings.background + '; }')].style;
|
dial.styles.body = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('body { user-select: none; -moz-user-select: none; display: flex; width: 100%; height: 100%; margin: 0px; padding: 0px; background-color: ' + app.settings.backgroundColor + '; background-image: ' + app.settings.backgroundImage + '; background-repeat: no-repeat; background-size: 100% 100%; }')].style;
|
||||||
dial.styles.grid = {};
|
dial.styles.grid = {};
|
||||||
dial.styles.grid.grid = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid { border-collapse: collapse; margin: auto auto; }')].style;
|
dial.styles.grid.grid = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid { border-collapse: collapse; margin: auto auto; }')].style;
|
||||||
dial.styles.grid.cell = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td { margin: 0px; padding: 0px; }')].style;
|
dial.styles.grid.cell = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td { margin: 0px; padding: 0px; }')].style;
|
||||||
@ -102,8 +116,14 @@ dial.initMenus = function(){
|
|||||||
dial.PageMenuCreateFolder = document.createElement('menuitem');
|
dial.PageMenuCreateFolder = document.createElement('menuitem');
|
||||||
dial.PageMenuCreateFolder.label = 'Add folder';
|
dial.PageMenuCreateFolder.label = 'Add folder';
|
||||||
dial.PageMenuCreateFolder.onclick = dial.createFolder;
|
dial.PageMenuCreateFolder.onclick = dial.createFolder;
|
||||||
|
dial.PageMenuSettings = document.createElement('menuitem');
|
||||||
|
dial.PageMenuSettings.label = browser.i18n.getMessage("menuSettings");
|
||||||
|
dial.PageMenuSettings.onclick = dial.editSettings;
|
||||||
|
|
||||||
dial.PageMenu.appendChild(dial.PageMenuCreateBookmark);
|
dial.PageMenu.appendChild(dial.PageMenuCreateBookmark);
|
||||||
dial.PageMenu.appendChild(dial.PageMenuCreateFolder);
|
dial.PageMenu.appendChild(dial.PageMenuCreateFolder);
|
||||||
|
dial.PageMenu.appendChild(document.createElement('hr'));
|
||||||
|
dial.PageMenu.appendChild(dial.PageMenuSettings);
|
||||||
dial.Body.appendChild(dial.PageMenu);
|
dial.Body.appendChild(dial.PageMenu);
|
||||||
|
|
||||||
dial.ItemMenu = document.createElement('menu');
|
dial.ItemMenu = document.createElement('menu');
|
||||||
@ -131,6 +151,11 @@ dial.initMenus = function(){
|
|||||||
dial.ItemMenuDelete = document.createElement('menuitem');
|
dial.ItemMenuDelete = document.createElement('menuitem');
|
||||||
dial.ItemMenuDelete.label = browser.i18n.getMessage("menuDeleteItem");
|
dial.ItemMenuDelete.label = browser.i18n.getMessage("menuDeleteItem");
|
||||||
dial.ItemMenuDelete.onclick = dial.deleteNode;
|
dial.ItemMenuDelete.onclick = dial.deleteNode;
|
||||||
|
|
||||||
|
dial.ItemMenuSettings = document.createElement('menuitem');
|
||||||
|
dial.ItemMenuSettings.label = browser.i18n.getMessage("menuSettings");
|
||||||
|
dial.ItemMenuSettings.onclick = dial.editSettings;
|
||||||
|
|
||||||
dial.ItemMenu.appendChild(dial.ItemMenuCreateBookmark);
|
dial.ItemMenu.appendChild(dial.ItemMenuCreateBookmark);
|
||||||
dial.ItemMenu.appendChild(dial.ItemMenuCreateFolder);
|
dial.ItemMenu.appendChild(dial.ItemMenuCreateFolder);
|
||||||
dial.ItemMenu.appendChild(document.createElement('hr'));
|
dial.ItemMenu.appendChild(document.createElement('hr'));
|
||||||
@ -138,6 +163,8 @@ dial.initMenus = function(){
|
|||||||
dial.ItemMenu.appendChild(dial.ItemMenuRefresh);
|
dial.ItemMenu.appendChild(dial.ItemMenuRefresh);
|
||||||
dial.ItemMenu.appendChild(dial.ItemMenuCapture);
|
dial.ItemMenu.appendChild(dial.ItemMenuCapture);
|
||||||
dial.ItemMenu.appendChild(dial.ItemMenuDelete);
|
dial.ItemMenu.appendChild(dial.ItemMenuDelete);
|
||||||
|
dial.ItemMenu.appendChild(document.createElement('hr'));
|
||||||
|
dial.ItemMenu.appendChild(dial.ItemMenuSettings);
|
||||||
dial.Body.appendChild(dial.ItemMenu);
|
dial.Body.appendChild(dial.ItemMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,4 +350,64 @@ dial.deleteNode = function(){
|
|||||||
dial.capturePage = function(){
|
dial.capturePage = function(){
|
||||||
if(dial._selectedItem.Node.type == app.GridNodeType.bookmark)
|
if(dial._selectedItem.Node.type == app.GridNodeType.bookmark)
|
||||||
app.capturePage(dial._selectedItem.Node);
|
app.capturePage(dial._selectedItem.Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dial.PopupPanel = function(width, height, modal){ // PopupPanel Object
|
||||||
|
this.panelContainer = document.createElement('div');
|
||||||
|
this.panelContainer.style.position = 'fixed';
|
||||||
|
this.panelContainer.style.left = '0pt';
|
||||||
|
this.panelContainer.style.top = '0pt';
|
||||||
|
this.panelContainer.style.width = '100%';
|
||||||
|
this.panelContainer.style.height = '100%';
|
||||||
|
|
||||||
|
this.panel = document.createElement('div');
|
||||||
|
this.panel.style.margin = 'auto';
|
||||||
|
this.panel.style.marginTop = '30pt';
|
||||||
|
this.panel.style.width = width + 'px';
|
||||||
|
this.panel.style.height = height + 'px';
|
||||||
|
this.panel.style.backgroundColor = '#FFFFFF';
|
||||||
|
this.panelContainer.appendChild(this.panel);
|
||||||
|
this.frame = this.panel;
|
||||||
|
if(modal == true){
|
||||||
|
this.modal = document.createElement('div');
|
||||||
|
this.modal.style.position = 'fixed';
|
||||||
|
this.modal.style.left = '0px';
|
||||||
|
this.modal.style.top = '0px';
|
||||||
|
this.modal.style.width = '100%';
|
||||||
|
this.modal.style.height = '100%';
|
||||||
|
this.modal.style.backgroundColor = '#404040';
|
||||||
|
this.modal.style.opacity = 0.5;
|
||||||
|
this.popup = function(){
|
||||||
|
dial.Body.appendChild(this.modal);
|
||||||
|
dial.Body.appendChild(this.panelContainer);
|
||||||
|
}
|
||||||
|
this.close = function(){
|
||||||
|
dial.Body.removeChild(this.modal);
|
||||||
|
dial.Body.removeChild(this.panelContainer);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.popup = function(){
|
||||||
|
dial.Body.appendChild(this.panelContainer);
|
||||||
|
}
|
||||||
|
this.close = function(){
|
||||||
|
dialBody.removeChild(this.panelContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dial.editSettings = function(){
|
||||||
|
var popup = new dial.PopupPanel(500, 420, true);
|
||||||
|
var iframe = document.createElement('iframe');
|
||||||
|
iframe.style.width = '100%';
|
||||||
|
iframe.style.height = '100%';
|
||||||
|
iframe.style.backgroundColor = 'transparent';
|
||||||
|
iframe.style.border = '0px none transparent';
|
||||||
|
iframe.style.padding = '0px';
|
||||||
|
iframe.style.overflow = 'hidden';
|
||||||
|
popup.frame.appendChild(iframe);
|
||||||
|
iframe.src = '/html/settings.html';
|
||||||
|
iframe.popup = popup;
|
||||||
|
popup.popup();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user