File tree Expand file tree Collapse file tree 4 files changed +51
-40
lines changed Expand file tree Collapse file tree 4 files changed +51
-40
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,14 @@ chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
77 // Setup page for layout changes and show page action
88 if ( match ) {
99 chrome . tabs . executeScript ( null , {
10- file : 'js/setup-css .js'
10+ file : 'js/init .js'
1111 } ) ;
1212 }
1313} ) ;
1414
1515chrome . pageAction . onClicked . addListener ( function ( tab ) {
1616 chrome . tabs . executeScript ( null , {
17- file : 'js/toggle-layout.js '
17+ code : 'toggleLayout() '
1818 } ) ;
1919} ) ;
2020
Original file line number Diff line number Diff line change 1+ function insertCss ( ) {
2+ const cssFile = chrome . extension . getURL ( 'css/layout.css' ) ;
3+ const cssId = 'layoutcss' ;
4+
5+ if ( document . getElementById ( cssId ) === null ) {
6+ let css = document . createElement ( 'link' ) ;
7+ css . id = cssId ;
8+ css . type = 'text/css' ;
9+ css . rel = 'stylesheet' ;
10+ css . href = cssFile ;
11+ document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( css ) ;
12+ }
13+ }
14+
15+ function syncState ( ) {
16+ chrome . storage . sync . get ( 'classList' , function ( result ) {
17+ let board = document . getElementById ( 'board' ) ;
18+
19+ if ( result . classList ) {
20+ board . classList . add ( result . classList ) ;
21+ }
22+ } ) ;
23+ }
24+
25+ function toggleLayout ( ) {
26+ const classVertical = 'layout-trello-vertical' ;
27+ const classMixed = 'layout-trello-mixed' ;
28+
29+ let board = document . getElementById ( 'board' ) ;
30+
31+ if ( board . classList . contains ( classMixed ) ) {
32+ board . classList . remove ( classMixed ) ;
33+ board . classList . add ( classVertical ) ;
34+ chrome . storage . sync . set ( {
35+ 'classList' : classVertical
36+ } ) ;
37+ } else if ( board . classList . contains ( classVertical ) ) {
38+ board . classList . remove ( classVertical ) ;
39+ chrome . storage . sync . remove ( 'classList' ) ;
40+ } else {
41+ board . classList . add ( classMixed ) ;
42+ chrome . storage . sync . set ( {
43+ 'classList' : classMixed
44+ } ) ;
45+ }
46+ }
47+
48+ insertCss ( ) ;
49+ syncState ( ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments