Skip to content

Commit 81ace31

Browse files
committed
Change the CodeArea's CodeBase language based on the file extension (JS with standard/default to XML)
1 parent 505efc9 commit 81ace31

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/Our.Umbraco.Tree.Config/umbraco/developer/Config/editConfigFile.aspx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
</umb:PropertyPanel>
248248

249249
<umb:PropertyPanel runat="server" ID="PropertyPanel3">
250-
<umb:CodeArea runat="server" ID="editorSource" CodeBase="XML" AutoResize="true" OffSetX="47" OffSetY="47" />
250+
<umb:CodeArea runat="server" ID="editorSource" AutoResize="true" OffSetX="47" OffSetY="47" />
251251
</umb:PropertyPanel>
252252

253253
</umb:Pane>

src/Our.Umbraco.Tree.Config/umbraco/developer/Config/editConfigFile.aspx.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ protected override void OnInit(EventArgs e)
8383

8484
if (this.UmbracoPanel1.hasMenu)
8585
{
86-
87-
88-
8986
if (!CompatibilityHelper.IsVersion7OrNewer)
9087
{
9188
// add the save button
@@ -108,7 +105,6 @@ protected override void OnInit(EventArgs e)
108105

109106
if (Request.QueryString["file"] == WEB_CONFIG)
110107
b.OnClientClick = "javascript:return confirm('You have modified the Web.config, are you sure that you still want to save?');";
111-
112108
}
113109
}
114110
}
@@ -170,6 +166,10 @@ protected void Page_Load(object sender, EventArgs e)
170166

171167
if (!string.IsNullOrEmpty(fileContents))
172168
this.editorSource.Text = fileContents;
169+
170+
this.editorSource.CodeBase = configFile.EndsWith(".js")
171+
? CodeArea.EditorType.JavaScript
172+
: CodeArea.EditorType.XML;
173173
}
174174
else
175175
{
@@ -187,12 +187,22 @@ protected void Page_Load(object sender, EventArgs e)
187187
}
188188
}
189189

190-
/// <summary>
191-
/// Handles the Click event of the MenuSave control.
192-
/// </summary>
193-
/// <param name="sender">The source of the event.</param>
194-
/// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
195-
private void MenuSave_Click(object sender, ImageClickEventArgs e)
190+
protected override void OnPreRenderComplete(EventArgs e)
191+
{
192+
base.OnPreRenderComplete(e);
193+
194+
if (this.editorSource.CodeBase == CodeArea.EditorType.JavaScript)
195+
{
196+
197+
}
198+
}
199+
200+
/// <summary>
201+
/// Handles the Click event of the MenuSave control.
202+
/// </summary>
203+
/// <param name="sender">The source of the event.</param>
204+
/// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
205+
private void MenuSave_Click(object sender, ImageClickEventArgs e)
196206
{
197207
Save();
198208
}

0 commit comments

Comments
 (0)