diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index ccf4de46ce..d2bd7706e3 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -832,6 +832,8 @@ + + diff --git a/src/Umbraco.Web.UI/umbraco/developer/Xslt/editXslt.aspx b/src/Umbraco.Web.UI/umbraco/developer/Xslt/editXslt.aspx index 5dfbc53f01..a4368ada4c 100644 --- a/src/Umbraco.Web.UI/umbraco/developer/Xslt/editXslt.aspx +++ b/src/Umbraco.Web.UI/umbraco/developer/Xslt/editXslt.aspx @@ -9,54 +9,30 @@ - + + + + @@ -92,15 +67,9 @@ - + - diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.css b/src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.css new file mode 100644 index 0000000000..975c68b0c2 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.css @@ -0,0 +1,14 @@ +#errorDiv +{ + margin-bottom: 10px; +} + + #errorDiv a + { + float: right; + } + +.propertyItemheader +{ + width: 200px !important; +} diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.js new file mode 100644 index 0000000000..07cd265c6d --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.js @@ -0,0 +1,69 @@ +Umbraco.Sys.registerNamespace("Umbraco.Editors"); + +(function ($) { + + Umbraco.Editors.EditXslt = base2.Base.extend({ + //private methods/variables + _opts: null, + + // Constructor + constructor: function(opts) { + // Merge options with default + this._opts = $.extend({ + + + // Default options go here + }, opts); + }, + + init: function () { + //setup UI elements + var self = this; + + //bind to the save event + this._opts.saveButton.click(function () { + self.doSubmit(); + }); + }, + + doSubmit: function () { + var self = this; + + $('#errorDiv').hide(); + + 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.SaveXslt( + fileName, self._opts.originalFileName, codeVal, self._opts.skipTestingCheckBox.is(':checked'), + function (t) { self.submitSucces(t); }, + function (t) { self.submitFailure(t); }); + + }, + + submitSucces: function (t) { + if (t != 'true') { + top.UmbSpeechBubble.ShowMessage('error', 'Saving Xslt file failed', ''); + jQuery('#errorDiv').html('

Hide ErrorsError occured

' + t + '

'); + jQuery('#errorDiv').slideDown('fast'); + } + else { + top.UmbSpeechBubble.ShowMessage('save', 'Xslt file saved', ''); + } + + var newFilePath = this._opts.nameTxtBox.val(); + UmbClientMgr.mainTree().setActiveTreeType('xslt'); + //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('warning', 'Xslt file could not be saved', ''); + } + }); +})(jQuery); \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Xslt/editXslt.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Xslt/editXslt.aspx.cs index 0715b1457b..1f926b4cca 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Xslt/editXslt.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Xslt/editXslt.aspx.cs @@ -7,11 +7,11 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Xml; using System.Xml.Xsl; +using Umbraco.Core.IO; using umbraco.BasePages; using umbraco.uicontrols; using System.Net; using umbraco.cms.presentation.Trees; -using umbraco.IO; using umbraco.cms.helpers; namespace umbraco.cms.presentation.developer @@ -25,9 +25,10 @@ namespace umbraco.cms.presentation.developer { CurrentApp = BusinessLogic.DefaultApps.developer.ToString(); } + protected PlaceHolder buttons; - + protected MenuIconI SaveButton; protected void Page_Load(object sender, EventArgs e) { @@ -44,28 +45,20 @@ namespace umbraco.cms.presentation.developer } - #region Web Form Designer generated code - protected override void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - InitializeComponent(); + { base.OnInit(e); - - - uicontrols.MenuIconI save = UmbracoPanel1.Menu.NewIcon(); - save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; - save.OnClickCommand = "doSubmit()"; - save.AltText = "Save Xslt File"; - save.ID = "save"; + + SaveButton = UmbracoPanel1.Menu.NewIcon(); + SaveButton.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; + SaveButton.AltText = "Save Xslt File"; + SaveButton.ID = "save"; UmbracoPanel1.Menu.InsertSplitter(); - uicontrols.MenuIconI tmp = UmbracoPanel1.Menu.NewIcon(); - tmp.ImageURL = umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/images/editor/insField.GIF"; - tmp.OnClickCommand = ClientTools.Scripts.OpenModalWindow(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/developer/xslt/xsltinsertvalueof.aspx?objectId=" + editorSource.ClientID, "Insert value", 750, 250); + var tmp = UmbracoPanel1.Menu.NewIcon(); + tmp.ImageURL = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/images/editor/insField.GIF"; + tmp.OnClickCommand = ClientTools.Scripts.OpenModalWindow(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/developer/xslt/xsltinsertvalueof.aspx?objectId=" + editorSource.ClientID, "Insert value", 750, 250); //"umbracoInsertField(document.getElementById('editorSource'), 'xsltInsertValueOf', '','felt', 750, 230, '');"; tmp.AltText = "Insert xslt:value-of"; @@ -104,7 +97,7 @@ namespace umbraco.cms.presentation.developer // Add source and filename - String file = IOHelper.MapPath(SystemDirectories.Xslt + "/" + Request.QueryString["file"]); + var file = IOHelper.MapPath(SystemDirectories.Xslt + "/" + Request.QueryString["file"]); // validate file IOHelper.ValidateEditPath(file, SystemDirectories.Xslt); @@ -129,19 +122,10 @@ namespace umbraco.cms.presentation.developer { base.OnPreRender(e); - ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.Webservices) + "/codeEditorSave.asmx")); - ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.Webservices) + "/legacyAjaxCalls.asmx")); + ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/codeEditorSave.asmx")); + ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference(IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/legacyAjaxCalls.asmx")); } - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - } - - #endregion /// /// JsInclude1 control.