@@ -80,13 +80,27 @@ define(function (require, exports, module) {
8080 * of the clicked button when the dialog is dismissed. Never rejected.
8181 */
8282 function showProjectPreferencesDialog ( baseUrl , errorMessage ) {
83- var $dlg ,
84- $title ,
85- $baseUrlControl ,
83+ var $baseUrlControl ,
8684 dialog ;
87-
88- dialog = Dialogs . showModalDialogUsingTemplate ( Mustache . render ( SettingsDialogTemplate , Strings ) ) ;
89-
85+
86+ // Title
87+ var projectName = "" ,
88+ projectRoot = ProjectManager . getProjectRoot ( ) ,
89+ title ;
90+ if ( projectRoot ) {
91+ projectName = projectRoot . name ;
92+ }
93+ title = StringUtils . format ( Strings . PROJECT_SETTINGS_TITLE , projectName ) ;
94+
95+ var templateVars = {
96+ title : title ,
97+ baseUrl : baseUrl ,
98+ errorMessage : errorMessage ,
99+ Strings : Strings
100+ } ;
101+
102+ dialog = Dialogs . showModalDialogUsingTemplate ( Mustache . render ( SettingsDialogTemplate , templateVars ) ) ;
103+
90104 dialog . done ( function ( id ) {
91105 if ( id === Dialogs . DIALOG_BTN_OK ) {
92106 var baseUrlValue = $baseUrlControl . val ( ) ;
@@ -100,32 +114,8 @@ define(function (require, exports, module) {
100114 }
101115 } ) ;
102116
103- // Populate project settings
104- $dlg = dialog . getElement ( ) ;
105-
106- // Title
107- $title = $dlg . find ( ".dialog-title" ) ;
108- var projectName = "" ,
109- projectRoot = ProjectManager . getProjectRoot ( ) ,
110- title ;
111- if ( projectRoot ) {
112- projectName = projectRoot . name ;
113- }
114- title = StringUtils . format ( Strings . PROJECT_SETTINGS_TITLE , projectName ) ;
115- $title . text ( title ) ;
116-
117- // Base URL
118- $baseUrlControl = $dlg . find ( ".url" ) ;
119- if ( baseUrl ) {
120- $baseUrlControl . val ( baseUrl ) ;
121- }
122-
123- // Error message
124- if ( errorMessage ) {
125- $dlg . find ( ".field-container" ) . append ( "<div class='alert' style='margin-bottom: 0'>" + errorMessage + "</div>" ) ;
126- }
127-
128117 // Give focus to first control
118+ $baseUrlControl = dialog . getElement ( ) . find ( ".url" ) ;
129119 $baseUrlControl . focus ( ) ;
130120
131121 return dialog ;
0 commit comments