@@ -8,6 +8,7 @@ var fs = require('fs');
8
8
9
9
10
10
var platforms ;
11
+ var templates ;
11
12
12
13
// var platforms = {
13
14
// "osx": "OS X (Xcode)",
@@ -204,9 +205,83 @@ ipc.on('setPlatforms', function(arg) {
204
205
} ) ;
205
206
206
207
208
+ ipc . on ( 'setTemplates' , function ( arg ) {
209
+ console . log ( "----------------" ) ;
210
+ console . log ( "got set templates" ) ;
211
+ console . log ( arg ) ;
212
+
213
+ templates = arg ;
214
+
215
+ var select = document . getElementById ( "templateList" ) ;
216
+ var option , i ;
217
+ for ( var i in templates ) {
218
+ console . log ( i ) ;
219
+ var myClass = 'template' ;
220
+
221
+ $ ( '<div/>' , {
222
+ "class" : 'item' ,
223
+ "data-value" : i
224
+ } ) . html ( templates [ i ] ) . appendTo ( select ) ;
225
+ }
226
+
227
+ console . log ( select ) ;
228
+
229
+ // start the template drop down.
230
+ $ ( '#templatesDropdown' )
231
+ . dropdown ( {
232
+ allowAdditions : false ,
233
+ fullTextSearch : 'exact' ,
234
+ match : "text" ,
235
+ maxSelections : 1
236
+ } ) ;
237
+
238
+ // // set the template to default
239
+ //$('#templatesDropdown').dropdown('set exactly', defaultSettings['defaultTemplate']);
240
+
241
+ // Multi
242
+ var select = document . getElementById ( "templateListMulti" ) ;
243
+ var option , i ;
244
+ for ( var i in templates ) {
245
+ var myClass = 'template' ;
246
+
247
+ $ ( '<div/>' , {
248
+ "class" : 'item' ,
249
+ "data-value" : i
250
+ } ) . html ( templates [ i ] ) . appendTo ( select ) ;
251
+ }
252
+
253
+ // start the platform drop down.
254
+ $ ( '#templatesDropdownMulti' )
255
+ . dropdown ( {
256
+ allowAdditions : false ,
257
+ maxSelections : 1
258
+ } ) ;
259
+
260
+ // // set the template to default
261
+ //$('#templatesDropdownMulti').dropdown('set exactly', defaultSettings['defaultTemplate']);
262
+ } ) ;
263
+
207
264
265
+ ipc . on ( 'enableTemplate' , function ( arg ) {
208
266
267
+ console . log ( 'enableTemplate' ) ;
268
+ let items = arg . bMulti === false ? $ ( '#templatesDropdown .menu .item' ) : $ ( '#templatesDropdownMulti .menu .item' ) ;
209
269
270
+ // enable all first
271
+ for ( let i = 0 ; i < items . length ; i ++ ) {
272
+ let item = $ ( items [ i ] ) ;
273
+ item . removeClass ( "disabled" ) ;
274
+ }
275
+
276
+ for ( let template of arg . invalidTemplateList ) {
277
+ for ( let i = 0 ; i < items . length ; i ++ ) {
278
+ let item = $ ( items [ i ] ) ;
279
+ if ( item . attr ( 'data-value' ) === template ) {
280
+ item . addClass ( "disabled" ) ;
281
+ }
282
+ }
283
+ }
284
+ } ) ;
210
285
211
286
//-------------------------------------------
212
287
// select the list of addons and notify if some aren't installed
@@ -606,6 +681,7 @@ function setup() {
606
681
607
682
// show default platform in GUI
608
683
$ ( "#defaultPlatform" ) . html ( defaultSettings [ 'defaultPlatform' ] ) ;
684
+ //$("#defaultTemplate").html(defaultSettings['defaultTemplate']);
609
685
610
686
// Enable tooltips
611
687
//$("[data-toggle='tooltip']").tooltip();
@@ -654,6 +730,29 @@ function setup() {
654
730
$ ( this ) . removeClass ( "accept deny" ) ;
655
731
} ) ;
656
732
733
+
734
+ // reflesh template dropdown list depends on selected platforms
735
+ $ ( "#platformsDropdown" ) . on ( 'change' , function ( ) {
736
+ let selectedPlatforms = $ ( "#platformsDropdown input" ) . val ( ) ;
737
+ let selectedPlatformArray = selectedPlatforms . trim ( ) . split ( ',' ) ;
738
+ let arg = {
739
+ ofPath : $ ( "#ofPath" ) . val ( ) ,
740
+ selectedPlatforms : selectedPlatformArray ,
741
+ bMulti : false
742
+ }
743
+ ipc . send ( 'refreshTemplateList' , arg ) ;
744
+ } )
745
+ $ ( "#platformsDropdownMulti" ) . on ( 'change' , function ( ) {
746
+ let selectedPlatforms = $ ( "#platformsDropdownMulti input" ) . val ( ) ;
747
+ let selectedPlatformArray = selectedPlatforms . trim ( ) . split ( ',' ) ;
748
+ let arg = {
749
+ ofPath : $ ( "#ofPath" ) . val ( ) ,
750
+ selectedPlatforms : selectedPlatformArray ,
751
+ bMulti : true
752
+ }
753
+ ipc . send ( 'refreshTemplateList' , arg ) ;
754
+ } )
755
+
657
756
} ) ;
658
757
}
659
758
@@ -797,6 +896,12 @@ function generate() {
797
896
// let's get all the info:
798
897
var platformValueArray = getPlatformList ( ) ;
799
898
899
+ var templatePicked = $ ( "#templatesDropdown .active" ) ;
900
+ var templateValueArray = [ ] ;
901
+ for ( var i = 0 ; i < templatePicked . length ; i ++ ) {
902
+ templateValueArray . push ( $ ( templatePicked [ i ] ) . attr ( "data-value" ) ) ;
903
+ }
904
+
800
905
var addonsPicked = $ ( "#addonsDropdown .active" ) ;
801
906
var addonValueArray = [ ] ;
802
907
@@ -816,6 +921,7 @@ function generate() {
816
921
gen [ 'projectName' ] = $ ( "#projectName" ) . val ( ) ;
817
922
gen [ 'projectPath' ] = $ ( "#projectPath" ) . val ( ) ;
818
923
gen [ 'platformList' ] = platformValueArray ;
924
+ gen [ 'templateList' ] = templateValueArray ;
819
925
gen [ 'addonList' ] = addonValueArray ; //$("#addonsDropdown").val();
820
926
gen [ 'ofPath' ] = $ ( "#ofPath" ) . val ( ) ;
821
927
gen [ 'verbose' ] = bVerbose ;
@@ -850,11 +956,16 @@ function updateRecursive() {
850
956
platformValueArray . push ( $ ( platformsPicked [ i ] ) . attr ( "data-value" ) ) ;
851
957
}
852
958
853
-
959
+ var templatePicked = $ ( "#templatesDropdownMulti .active" ) ;
960
+ var templateValueArray = [ ] ;
961
+ for ( var i = 0 ; i < templatePicked . length ; i ++ ) {
962
+ templateValueArray . push ( $ ( templatePicked [ i ] ) . attr ( "data-value" ) ) ;
963
+ }
854
964
855
965
var gen = { } ;
856
966
gen [ 'updatePath' ] = $ ( "#updateMultiplePath" ) . val ( ) ;
857
967
gen [ 'platformList' ] = platformValueArray ;
968
+ gen [ 'templateList' ] = templateValueArray ;
858
969
gen [ 'updateRecursive' ] = true ;
859
970
gen [ 'ofPath' ] = $ ( "#ofPath" ) . val ( ) ;
860
971
gen [ 'verbose' ] = bVerbose ;
@@ -922,10 +1033,18 @@ function enableAdvancedMode(isAdvanced) {
922
1033
$ ( "body" ) . addClass ( 'advanced' ) ;
923
1034
$ ( 'a.updateMultiMenuOption' ) . show ( ) ;
924
1035
1036
+ $ ( '#templateSection' ) . show ( ) ;
1037
+ $ ( '#templateSectionMulti' ) . show ( ) ;
1038
+
925
1039
} else {
926
1040
$ ( '#platformsDropdown' ) . addClass ( "disabled" ) ;
927
1041
$ ( '#platformsDropdown' ) . dropdown ( 'set exactly' , defaultSettings [ 'defaultPlatform' ] ) ;
928
1042
1043
+ $ ( '#templateSection' ) . hide ( ) ;
1044
+ $ ( '#templateSectionMulti' ) . hide ( ) ;
1045
+ $ ( '#templateDropdown' ) . dropdown ( 'set exactly' , '' ) ;
1046
+ $ ( '#templateDropdownMulti' ) . dropdown ( 'set exactly' , '' ) ;
1047
+
929
1048
$ ( "body" ) . removeClass ( 'advanced' ) ;
930
1049
$ ( 'a.updateMultiMenuOption' ) . hide ( ) ;
931
1050
0 commit comments