1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-23 15:36:12 +00:00

Improvement: Old styles and old grid are removed after redrawing the new

This commit is contained in:
MatMoul 2017-10-15 12:18:10 +02:00
parent 957f468c59
commit dbe7751b77

View File

@ -209,7 +209,7 @@ dial.initMenus = function(){
document.body.appendChild(dial.ItemMenu); document.body.appendChild(dial.ItemMenu);
} }
dial.initStyles = function(){ dial.initStyles = function(){
if(dial.Style) document.head.removeChild(dial.Style); var oldStyle = dial.Style;
dial.Style = document.createElement('style'), StyleSheet; dial.Style = document.createElement('style'), StyleSheet;
document.head.appendChild(dial.Style); document.head.appendChild(dial.Style);
dial.styles = {}; dial.styles = {};
@ -234,9 +234,10 @@ dial.initStyles = function(){
dial.styles.grid.linkFolder = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Folder :first-child { background-image: ' + app.settings.grid.folderIcon + '; background-repeat: no-repeat; background-size: 100% 100%; }')].style; dial.styles.grid.linkFolder = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Folder :first-child { background-image: ' + app.settings.grid.folderIcon + '; background-repeat: no-repeat; background-size: 100% 100%; }')].style;
dial.styles.grid.linkBookmark = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Bookmark :first-child { background-repeat: no-repeat; background-size: 100% 100%; }')].style; dial.styles.grid.linkBookmark = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Bookmark :first-child { background-repeat: no-repeat; background-size: 100% 100%; }')].style;
dial.styles.grid.linkBookmarkLoading = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.BookmarkLoading :first-child { background-image: url("' + app.settings.grid.cells.loadingIcon + '"); background-repeat: no-repeat; background-position: center center; }')].style; dial.styles.grid.linkBookmarkLoading = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.BookmarkLoading :first-child { background-image: url("' + app.settings.grid.cells.loadingIcon + '"); background-repeat: no-repeat; background-position: center center; }')].style;
if(oldStyle) document.head.removeChild(oldStyle);
}; };
dial.initGrid = function(){ dial.initGrid = function(){
if(dial.Grid) document.body.removeChild(dial.Grid); var oldGrid = dial.Grid;
dial.Grid = document.createElement('table'); dial.Grid = document.createElement('table');
var grid = document.createElement('table'); var grid = document.createElement('table');
dial.Grid.className = 'Grid'; dial.Grid.className = 'Grid';
@ -286,6 +287,7 @@ dial.initGrid = function(){
} }
document.body.appendChild(dial.Grid); document.body.appendChild(dial.Grid);
dial.updateGridLayout(); dial.updateGridLayout();
if(oldGrid) document.body.removeChild(oldGrid);
return dial.Grid; return dial.Grid;
}; };
dial.updateGridLayout = function(){ dial.updateGridLayout = function(){