|
1
|
|
|
import { Application as ComponentApplication } from '@boldgrid/components/src/app/js/main.js'; |
|
2
|
|
|
|
|
3
|
|
|
import { |
|
4
|
|
|
ColorPalette, |
|
5
|
|
|
StyleUpdater, |
|
6
|
|
|
ColorPaletteSelection, |
|
7
|
|
|
PaletteConfiguration, |
|
8
|
|
|
Animation, |
|
9
|
|
|
Slider, |
|
10
|
|
|
DeviceVisibility |
|
|
|
|
|
|
11
|
|
|
} from '../controls'; |
|
12
|
|
|
|
|
13
|
|
|
import { Preview } from './preview'; |
|
14
|
|
|
import '@boldgrid/components/src/app/scss/main.scss'; |
|
15
|
|
|
import './main.scss'; |
|
16
|
|
|
import { Control as Save } from './save'; |
|
17
|
|
|
|
|
18
|
|
|
// Import Demo files. |
|
19
|
|
|
import { Demo as MultiSliderDemo } from './multi-slider'; |
|
20
|
|
|
import { Demo as DeviceVisibilityDemo } from './device-visibility/demo'; |
|
21
|
|
|
|
|
22
|
|
|
export class Application { |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Initialize the app used for testing. |
|
26
|
|
|
* |
|
27
|
|
|
* @since 1.0.0 |
|
28
|
|
|
*/ |
|
29
|
|
|
init() { |
|
30
|
|
|
this.paletteConfig = new PaletteConfiguration(); |
|
31
|
|
|
this.preview = new Preview(); |
|
32
|
|
|
|
|
33
|
|
|
new ComponentApplication().init(); |
|
34
|
|
|
|
|
35
|
|
|
this.saveUI = new Save(); |
|
36
|
|
|
this.saveUI.render(); |
|
37
|
|
|
|
|
38
|
|
|
// Instantiate the css loader. |
|
39
|
|
|
this.styleUpdater = new StyleUpdater( document ); |
|
40
|
|
|
this.styleUpdater.setup(); |
|
41
|
|
|
|
|
42
|
|
|
this.renderControls(); |
|
43
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Create the controls. |
|
48
|
|
|
* |
|
49
|
|
|
* @since 1.0.0 |
|
50
|
|
|
*/ |
|
51
|
|
|
renderControls() { |
|
52
|
|
|
this.paletteCustomize(); |
|
53
|
|
|
this.paletteSelection(); |
|
54
|
|
|
this.setupSlider(); |
|
55
|
|
|
new MultiSliderDemo( this.saveUI ).render(); |
|
56
|
|
|
this.animation(); |
|
57
|
|
|
new DeviceVisibilityDemo( this.saveUI, this.preview ).render(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
setupSlider() { |
|
61
|
|
|
let $tab = $( '.slider-tab' ); |
|
62
|
|
|
|
|
63
|
|
|
$tab.find( '.control' ).html( new Slider().render() ); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Set up animation demo control. |
|
68
|
|
|
* |
|
69
|
|
|
* @since 0.10.0 |
|
70
|
|
|
*/ |
|
71
|
|
|
animation() { |
|
72
|
|
|
let $tab = $( '.animations-tab' ), |
|
73
|
|
|
$demoElement = $tab.find( '.demo-element' ); |
|
74
|
|
|
|
|
75
|
|
|
$tab.find( '.control' ).html( new Animation( { |
|
76
|
|
|
target: $demoElement |
|
77
|
|
|
} ).render() ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
paletteSelection() { |
|
81
|
|
|
let $tab = $( '.palette-selection-tab .control' ), |
|
82
|
|
|
$log = $( '.palette-selection-tab .log' ), |
|
83
|
|
|
paletteSelection = new ColorPaletteSelection(), |
|
84
|
|
|
$control = paletteSelection.create(); |
|
85
|
|
|
|
|
86
|
|
|
$tab.html( $control ); |
|
87
|
|
|
|
|
88
|
|
|
$control.on( 'palette-selection', ( e, data ) => { |
|
89
|
|
|
let logData = { |
|
90
|
|
|
colors: data.palette, |
|
91
|
|
|
time: new Date().getTime() |
|
92
|
|
|
}; |
|
93
|
|
|
|
|
94
|
|
|
$log.append( '<div class="log-line">' + JSON.stringify( logData ) + '</div>' ); |
|
95
|
|
|
} ); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
paletteCustomize() { |
|
99
|
|
|
let $control, |
|
100
|
|
|
$tab = $( '.colors-tab' ), |
|
101
|
|
|
colorPalette = new ColorPalette(); |
|
102
|
|
|
|
|
103
|
|
|
colorPalette.init(); |
|
104
|
|
|
|
|
105
|
|
|
$control = colorPalette.render( $tab.find( '.control' ) ); |
|
106
|
|
|
|
|
107
|
|
|
$control.on( 'sass_compiled', ( e, data ) => { |
|
108
|
|
|
this.styleUpdater.update( { |
|
109
|
|
|
id: 'bg-controls-colors', |
|
110
|
|
|
css: data.result.text, |
|
111
|
|
|
scss: data.scss |
|
112
|
|
|
} ); |
|
113
|
|
|
|
|
114
|
|
|
$tab.find( '.css' ).show(); |
|
115
|
|
|
|
|
116
|
|
|
if ( BOLDGRID.COLOR_PALETTE.Modify.state ) { |
|
|
|
|
|
|
117
|
|
|
let savableState = this.paletteConfig.createSavableState( |
|
118
|
|
|
BOLDGRID.COLOR_PALETTE.Modify.state |
|
119
|
|
|
); |
|
120
|
|
|
console.log( 'State', savableState ); |
|
|
|
|
|
|
121
|
|
|
console.log( 'State', JSON.stringify( savableState ) ); |
|
122
|
|
|
} |
|
123
|
|
|
} ); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|