Lines of Code | 37 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import { |
||
2 | DeviceVisibility |
||
3 | } from '../../controls'; |
||
4 | |||
5 | export class Demo { |
||
6 | |||
7 | constructor( saveUI, preview ) { |
||
8 | this.saveUI = saveUI; |
||
9 | this.preview = preview; |
||
10 | } |
||
11 | |||
12 | render() { |
||
13 | let $tab = $( '.device-visibility' ), |
||
14 | $demoElement = $tab.find( '.demo-element' ), |
||
|
|||
15 | name = 'deviceVisibility', |
||
16 | control = new DeviceVisibility( { |
||
17 | defaults: this.saveUI.getItem( 'deviceVisibility' ), |
||
18 | control: { |
||
19 | selectors: [ '.demo-element' ] |
||
20 | } |
||
21 | } ); |
||
22 | |||
23 | // Render the control. |
||
24 | $tab.find( '.control' ).html( control.render() ); |
||
25 | |||
26 | // On change of the control, update the styles. |
||
27 | control.events.on( 'change', ( settings ) => { |
||
28 | this.preview.appendStyles( name, settings.css ); |
||
29 | } ); |
||
30 | |||
31 | // When the user clicks on save, save the settings. |
||
32 | this.saveUI.setup( name, () => control.getSettings() ); |
||
33 | |||
34 | // On Load, append the current setting styles to the head. |
||
35 | this.preview.appendStyles( name, control.getSettings().css ); |
||
36 | } |
||
37 | } |
||
38 |