diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 9eb5b6521f..ccf4de46ce 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -2029,7 +2029,9 @@ - + + Designer + applications.config Designer diff --git a/src/Umbraco.Web.UI/umbraco/settings/scripts/editScript.aspx b/src/Umbraco.Web.UI/umbraco/settings/scripts/editScript.aspx index be52ab61a2..d9ee1f6a9f 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/scripts/editScript.aspx +++ b/src/Umbraco.Web.UI/umbraco/settings/scripts/editScript.aspx @@ -15,30 +15,26 @@ diff --git a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx index dfdccaaa69..b0e0704709 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx +++ b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx @@ -25,10 +25,11 @@ } }); editor.init(); + + //bind save shortcut + UmbClientMgr.appActions().bindSaveShortCut(); }); })(jQuery); - - diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js index 324bf08d37..3761c316a9 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js @@ -3,61 +3,64 @@ (function ($) { Umbraco.Editors.EditScript = base2.Base.extend({ - //private methods/variables - _opts: null, + //private methods/variables + _opts: null, - // Constructor - constructor: function(opts) { - // Merge options with default - this._opts = $.extend({ - - // Default options go here - }, opts); - }, - - save: function() { - var self = this; - - umbraco.presentation.webservices.codeEditorSave.SaveCss( - self._opts.fileName, self._opts.oldName, self._opts.codeVal, self._opts.cssId, - function(t) { self.submitSucces(t); }, - function(t) { self.submitFailure(t); }); - - }, - - submitSucces: function(t) { - if (t != 'true') { - top.UmbSpeechBubble.ShowMessage('error', this._opts.text.cssErrorHeader, this._opts.text.cssErrorText); - } - else { - top.UmbSpeechBubble.ShowMessage('save', this._opts.text.cssSavedHeader, this._opts.text.cssSavedText); - } + // Constructor + constructor: function(opts) { + // Merge options with default + this._opts = $.extend({ - UmbClientMgr.mainTree().setActiveTreeType('stylesheets'); - UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.cssId, true); - }, - submitFailure: function(t) { - top.UmbSpeechBubble.ShowMessage('error', this._opts.text.cssErrorHeader, this._opts.text.cssErrorText); - } + // Default options go here + }, opts); }, - { - saveScript: function(codeVal, fileName, oldName, cssId) { - //Static method to do the saving - var codeVal = $('#' + editorSourceClientId).val(); - //if CodeMirror is not defined, then the code editor is disabled. - if (typeof(CodeMirror) != "undefined") { - codeVal = UmbEditor.GetCode(); - } + init: function () { + //setup UI elements + var self = this; - var processor = new Umbraco.Editors.EditStyleSheet({ - codeVal: codeVal, - fileName: $('#' + nameTxtClientId).val(), - oldname: nameTxtValue, - cssId: cssId - }); - processor.save(); + //bind to the save event + this._opts.saveButton.click(function () { + self.doSubmit(); + }); + }, + + doSubmit: function () { + var self = this; + + var fileName = this._opts.nameTxtBox.val(); + var codeVal = this._opts.editorSourceElement.val(); + //if CodeMirror is not defined, then the code editor is disabled. + if (typeof (CodeMirror) != "undefined") { + codeVal = UmbEditor.GetCode(); } - }); + umbraco.presentation.webservices.codeEditorSave.SaveScript( + fileName, self._opts.originalFileName, codeVal, + function (t) { self.submitSucces(t); }, + function (t) { self.submitFailure(t); }); + + }, + + submitSucces: function(t) { + if (t != 'true') { + top.UmbSpeechBubble.ShowMessage('error', this._opts.text.fileErrorHeader, this._opts.text.fileErrorText); + } + else { + top.UmbSpeechBubble.ShowMessage('save', this._opts.text.fileSavedHeader, this._opts.text.fileSavedText); + } + + + var newFilePath = this._opts.nameTxtBox.val(); + UmbClientMgr.mainTree().setActiveTreeType('scripts'); + //we need to pass in the newId parameter so it knows which node to resync after retreival from the server + UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath); + //set the original file path to the new one + this._opts.originalFileName = newFilePath; + }, + + submitFailure: function(t) { + top.UmbSpeechBubble.ShowMessage('error', this._opts.text.fileErrorHeader, this._opts.text.fileErrorText); + } + }); })(jQuery); \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs index 213e4b6a4f..e0b6f2dfa0 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs @@ -11,10 +11,11 @@ using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; using Umbraco.Core; +using Umbraco.Core.IO; using umbraco.cms.presentation.Trees; -using umbraco.IO; using System.Linq; using umbraco.cms.helpers; +using umbraco.uicontrols; namespace umbraco.cms.presentation.settings.scripts { @@ -36,18 +37,20 @@ namespace umbraco.cms.presentation.settings.scripts protected umbraco.uicontrols.PropertyPanel pp_name; protected umbraco.uicontrols.PropertyPanel pp_path; + protected MenuIconI SaveButton; + private string file; - protected void Page_Load(object sender, System.EventArgs e) + protected override void OnLoad(EventArgs e) { - + base.OnLoad(e); NameTxt.Text = file; string path = ""; if (file.StartsWith("~/")) - path = Umbraco.Core.IO.IOHelper.ResolveUrl(file); + path = Umbraco.Core.IO.IOHelper.ResolveUrl(file); else - path = Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Scripts + "/" + file); + path = Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Scripts + "/" + file); lttPath.Text = "" + path + ""; @@ -60,19 +63,19 @@ namespace umbraco.cms.presentation.settings.scripts } var dirs = Umbraco.Core.IO.SystemDirectories.Scripts; - if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) + if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) dirs += "," + Umbraco.Core.IO.SystemDirectories.MvcViews; // validate file - Umbraco.Core.IO.IOHelper.ValidateEditPath(Umbraco.Core.IO.IOHelper.MapPath(path), dirs.Split(',')); - + Umbraco.Core.IO.IOHelper.ValidateEditPath(Umbraco.Core.IO.IOHelper.MapPath(path), dirs.Split(',')); + // validate extension - Umbraco.Core.IO.IOHelper.ValidateFileExtension(Umbraco.Core.IO.IOHelper.MapPath(path), exts); + Umbraco.Core.IO.IOHelper.ValidateFileExtension(Umbraco.Core.IO.IOHelper.MapPath(path), exts); StreamReader SR; string S; - SR = File.OpenText(Umbraco.Core.IO.IOHelper.MapPath(path)); + SR = File.OpenText(Umbraco.Core.IO.IOHelper.MapPath(path)); S = SR.ReadToEnd(); SR.Close(); @@ -91,25 +94,22 @@ namespace umbraco.cms.presentation.settings.scripts } } - - - #region Web Form Designer generated code override protected void OnInit(EventArgs e) { + base.OnInit(e); file = Request.QueryString["file"].TrimStart('/'); //need to change the editor type if it is XML if (file.EndsWith("xml")) - editorSource.CodeBase = umbraco.uicontrols.CodeArea.EditorType.XML; + editorSource.CodeBase = uicontrols.CodeArea.EditorType.XML; else if (file.EndsWith("master")) - editorSource.CodeBase = umbraco.uicontrols.CodeArea.EditorType.HTML; + editorSource.CodeBase = uicontrols.CodeArea.EditorType.HTML; - uicontrols.MenuIconI save = Panel1.Menu.NewIcon(); - save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; - save.OnClickCommand = "doSubmit()"; - save.AltText = "Save File"; - save.ID = "save"; + SaveButton = Panel1.Menu.NewIcon(); + SaveButton.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; + SaveButton.AltText = "Save File"; + SaveButton.ID = "save"; if (editorSource.CodeBase == uicontrols.CodeArea.EditorType.HTML) { @@ -117,19 +117,19 @@ namespace umbraco.cms.presentation.settings.scripts Panel1.Menu.InsertSplitter(); uicontrols.MenuIconI umbField = Panel1.Menu.NewIcon(); umbField.ImageURL = UmbracoPath + "/images/editor/insField.gif"; - umbField.OnClickCommand = umbraco.BasePages.ClientTools.Scripts.OpenModalWindow(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" + editorSource.ClientID + "&tagName=UMBRACOGETDATA", ui.Text("template", "insertPageField"), 640, 550); + umbField.OnClickCommand = BasePages.ClientTools.Scripts.OpenModalWindow(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" + editorSource.ClientID + "&tagName=UMBRACOGETDATA", ui.Text("template", "insertPageField"), 640, 550); umbField.AltText = ui.Text("template", "insertPageField"); // TODO: Update icon uicontrols.MenuIconI umbDictionary = Panel1.Menu.NewIcon(); umbDictionary.ImageURL = GlobalSettings.Path + "/images/editor/dictionaryItem.gif"; - umbDictionary.OnClickCommand = umbraco.BasePages.ClientTools.Scripts.OpenModalWindow(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" + editorSource.ClientID + "&tagName=UMBRACOGETDICTIONARY", ui.Text("template", "insertDictionaryItem"), 640, 550); + umbDictionary.OnClickCommand = BasePages.ClientTools.Scripts.OpenModalWindow(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" + editorSource.ClientID + "&tagName=UMBRACOGETDICTIONARY", ui.Text("template", "insertDictionaryItem"), 640, 550); umbDictionary.AltText = "Insert umbraco dictionary item"; uicontrols.MenuIconI umbMacro = Panel1.Menu.NewIcon(); umbMacro.ImageURL = UmbracoPath + "/images/editor/insMacro.gif"; umbMacro.AltText = ui.Text("template", "insertMacro"); - umbMacro.OnClickCommand = umbraco.BasePages.ClientTools.Scripts.OpenModalWindow(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/editMacro.aspx?objectId=" + editorSource.ClientID, ui.Text("template", "insertMacro"), 470, 530); + umbMacro.OnClickCommand = BasePages.ClientTools.Scripts.OpenModalWindow(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/editMacro.aspx?objectId=" + editorSource.ClientID, ui.Text("template", "insertMacro"), 470, 530); // Help Panel1.Menu.InsertSplitter(); @@ -141,23 +141,8 @@ namespace umbraco.cms.presentation.settings.scripts } - - this.Load += new System.EventHandler(Page_Load); - InitializeComponent(); - base.OnInit(e); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - - } - - + protected override void OnPreRender(EventArgs e) { @@ -165,7 +150,6 @@ namespace umbraco.cms.presentation.settings.scripts ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/codeEditorSave.asmx")); ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx")); } - #endregion } }