66 * Set up the form in a modal after being successfully attached to the body.
77 */
88function attachGroupForm ( ) {
9- $ ( "body" ) . on ( 'renderSuccess.ufModal' , function ( data ) {
9+ $ ( "body" ) . on ( 'renderSuccess.ufModal' , function ( data ) {
1010 var modal = $ ( this ) . ufModal ( 'getModal' ) ;
1111 var form = modal . find ( '.js-form' ) ;
1212
@@ -36,11 +36,34 @@ function attachGroupForm() {
3636 }
3737 } ) ;
3838
39+ // Fontawesome-iconpicker
40+ // Starcraft icons
41+ var sc_icons = [ {
42+ title : "sc sc-terran" ,
43+ searchTerms : [ 'starcraft' , 'terran' ]
44+ } ,
45+ {
46+ title : "sc sc-zerg" ,
47+ searchTerms : [ 'starcraft' , 'zerg' ]
48+ } , {
49+ title : "sc sc-protoss" ,
50+ searchTerms : [ 'starcraft' , 'protoss' ]
51+ } ,
52+ ]
53+
54+ $ ( '.icp-auto' ) . iconpicker ( {
55+ // this is a hacky way to add in our custom icons to the default FA5 icons.
56+ // See https://github.com/farbelous/fontawesome-iconpicker/issues/77
57+ icons : typeof sc_icons != 'undefined' ? $ . merge ( sc_icons , $ . iconpicker . defaultOptions . icons ) : null ,
58+ } ) ;
59+
3960 // Set icon when changed
4061 form . find ( 'input[name=icon]' ) . on ( 'input change' , function ( ) {
4162 $ ( this ) . prev ( ".icon-preview" ) . find ( "i" ) . removeClass ( ) . addClass ( $ ( this ) . val ( ) ) ;
4263 } ) ;
4364
65+ $ ( '.icp-auto' ) . iconpicker ( ) ;
66+
4467 // Set up the form for submission
4568 form . ufForm ( {
4669 validator : page . validators
@@ -93,16 +116,16 @@ function bindGroupButtons(el, options) {
93116 msgTarget : $ ( "#alerts-page" )
94117 } ) ;
95118
96- $ ( "body" ) . on ( 'renderSuccess.ufModal' , function ( ) {
119+ $ ( "body" ) . on ( 'renderSuccess.ufModal' , function ( ) {
97120 var modal = $ ( this ) . ufModal ( 'getModal' ) ;
98121 var form = modal . find ( '.js-form' ) ;
99122
100123 form . ufForm ( )
101- . on ( "submitSuccess.ufForm" , function ( ) {
102- // Navigate or reload page on success
103- if ( options . delete_redirect ) window . location . href = options . delete_redirect ;
104- else window . location . reload ( ) ;
105- } ) ;
124+ . on ( "submitSuccess.ufForm" , function ( ) {
125+ // Navigate or reload page on success
126+ if ( options . delete_redirect ) window . location . href = options . delete_redirect ;
127+ else window . location . reload ( ) ;
128+ } ) ;
106129 } ) ;
107130 } ) ;
108131}
@@ -119,4 +142,4 @@ function bindGroupCreationButton(el) {
119142
120143 attachGroupForm ( ) ;
121144 } ) ;
122- } ;
145+ } ;
0 commit comments