|
4 | 4 | Polymer({ |
5 | 5 | gistid: null, |
6 | 6 | stylesheet: null, |
| 7 | + defaultStylesheet: null, |
7 | 8 | styleEl: null, |
8 | 9 | gistEl: null, |
9 | 10 | scriptEl: null, |
|
17 | 18 | this.loadJSON(); |
18 | 19 | }, |
19 | 20 |
|
| 21 | + stylesheetChanged: function(){ |
| 22 | + //toggle themes without process response (if external script toggles stylesheet attribute) |
| 23 | + this.stylesheet = this.stylesheet || this.defaultStylesheet |
| 24 | + this.applyStyle(this.stylesheet); |
| 25 | + }, |
| 26 | + |
20 | 27 | loadJSON: function(){ |
21 | 28 | var callbackFunc = callbackFuncName + '_' + callbackId++; |
22 | 29 | window[callbackFunc] = function(object){ |
|
28 | 35 | }, |
29 | 36 |
|
30 | 37 | processResponse: function(object){ |
31 | | - if(this.stylesheet !== null) { |
32 | | - this.applyStyle(this.stylesheet); |
33 | | - this.applyGist(object.div); |
34 | | - } |
35 | | - else if(object && object.div && object.stylesheet){ |
36 | | - if(object.stylesheet.indexOf('http') !== 0){ |
37 | | - if(object.stylesheet.indexOf('/') !== 0){ |
38 | | - object.stylesheet = '/' + object.stylesheet; |
39 | | - } |
40 | | - object.stylesheet = 'https://gist.github.com' + object.stylesheet; |
41 | | - } |
42 | | - this.applyStyle(object.stylesheet); |
43 | | - this.applyGist(object.div); |
| 38 | + if(object && object.div && object.stylesheet){ |
| 39 | + if(object.stylesheet.indexOf('http') !== 0){ |
| 40 | + if(object.stylesheet.indexOf('/') !== 0){ |
| 41 | + object.stylesheet = '/' + object.stylesheet; |
| 42 | + } |
| 43 | + object.stylesheet = 'https://gist.github.com' + object.stylesheet; |
| 44 | + } |
| 45 | + this.defaultStylesheet = object.stylesheet || null; |
44 | 46 | } |
| 47 | + |
| 48 | + this.stylesheet = this.stylesheet || this.defaultStylesheet; |
| 49 | + this.applyStyle(this.stylesheet); |
| 50 | + this.applyGist(object.div); |
45 | 51 | }, |
46 | 52 |
|
47 | 53 | applyGist: function(htmlString){ |
|
0 commit comments