Fixed xslt editing and syncing.
This commit is contained in:
@@ -832,6 +832,8 @@
|
||||
<Content Include="Umbraco_Client\Dialogs\PublishDialog.css" />
|
||||
<Content Include="Umbraco_Client\Dialogs\PublishDialog.js" />
|
||||
<Content Include="Umbraco_Client\Dialogs\UmbracoField.js" />
|
||||
<Content Include="Umbraco_Client\Editors\EditXslt.css" />
|
||||
<Content Include="Umbraco_Client\Editors\EditXslt.js" />
|
||||
<Content Include="Umbraco_Client\Editors\EditScript.js" />
|
||||
<Content Include="Umbraco_Client\Editors\DirectoryBrowser.css" />
|
||||
<Content Include="Umbraco_Client\Editors\EditMacro.css" />
|
||||
|
||||
@@ -9,54 +9,30 @@
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server" ID="cp2">
|
||||
<style type="text/css">
|
||||
#errorDiv
|
||||
{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#errorDiv a
|
||||
{
|
||||
float: right;
|
||||
}
|
||||
.propertyItemheader
|
||||
{
|
||||
width: 200px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<umb:JsInclude ID="JsInclude2" runat="server" FilePath="Editors/EditXslt.js" PathNameAlias="UmbracoClient" />
|
||||
<umb:CssInclude ID="CssInclude1" runat="server" FilePath="Editors/EditXslt.css" PathNameAlias="UmbracoClient" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var xsltSnippet = "";
|
||||
(function ($) {
|
||||
$(document).ready(function () {
|
||||
var editor = new Umbraco.Editors.EditXslt({
|
||||
nameTxtBox: $('#<%= xsltFileName.ClientID %>'),
|
||||
originalFileName: '<%= xsltFileName.Text %>',
|
||||
saveButton: $("#<%= ((Control)SaveButton).ClientID %>"),
|
||||
editorSourceElement: $('#<%= editorSource.ClientID %>'),
|
||||
skipTestingCheckBox: $("#<%= SkipTesting.ClientID %>"),
|
||||
});
|
||||
editor.init();
|
||||
|
||||
function closeErrorDiv() {
|
||||
jQuery('#errorDiv').hide();
|
||||
}
|
||||
|
||||
function doSubmit() {
|
||||
closeErrorDiv();
|
||||
|
||||
var codeVal = jQuery('#<%= editorSource.ClientID %>').val();
|
||||
//if CodeMirror is not defined, then the code editor is disabled.
|
||||
if (typeof (CodeMirror) != "undefined") {
|
||||
codeVal = UmbEditor.GetCode();
|
||||
}
|
||||
|
||||
umbraco.presentation.webservices.codeEditorSave.SaveXslt(jQuery('#<%= xsltFileName.ClientID %>').val(), '<%= xsltFileName.Text %>', codeVal, document.getElementById('<%= SkipTesting.ClientID %>').checked, submitSucces, submitFailure);
|
||||
}
|
||||
|
||||
function submitSucces(t) {
|
||||
if (t != 'true') {
|
||||
top.UmbSpeechBubble.ShowMessage('error', 'Saving Xslt file failed', '');
|
||||
jQuery('#errorDiv').html('<p><a href="#" onclick=\'closeErrorDiv()\'>Hide Errors</a><strong>Error occured</strong></p><p>' + t + '</p>');
|
||||
jQuery('#errorDiv').slideDown('fast');
|
||||
}
|
||||
else {
|
||||
top.UmbSpeechBubble.ShowMessage('save', 'Xslt file saved', '')
|
||||
}
|
||||
}
|
||||
function submitFailure(t) {
|
||||
top.UmbSpeechBubble.ShowMessage('warning', 'Xslt file could not be saved', '')
|
||||
}
|
||||
//bind save shortcut
|
||||
UmbClientMgr.appActions().bindSaveShortCut();
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
//TODO: Move these to EditXslt.js one day
|
||||
var xsltSnippet = "";
|
||||
function xsltVisualize() {
|
||||
|
||||
xsltSnippet = UmbEditor.IsSimpleEditor
|
||||
@@ -71,7 +47,6 @@
|
||||
}
|
||||
|
||||
UmbClientMgr.openModalWindow('<%= umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/developer/xslt/xsltVisualize.aspx', 'Visualize XSLT', true, 550, 650);
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -92,15 +67,9 @@
|
||||
<div id="errorDiv" style="display: none;" class="error">
|
||||
test</div>
|
||||
</cc1:PropertyPanel>
|
||||
<cc1:CodeArea ID="editorSource" CodeBase="XML" ClientSaveMethod="doSubmit" runat="server"
|
||||
AutoResize="true" OffSetX="47" OffSetY="55" />
|
||||
<cc1:CodeArea ID="editorSource" CodeBase="XML" runat="server" AutoResize="true" OffSetX="47" OffSetY="55" />
|
||||
</cc1:Pane>
|
||||
</cc1:UmbracoPanel>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
UmbClientMgr.appActions().bindSaveShortCut();
|
||||
});
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ContentPlaceHolderID="footer" runat="server">
|
||||
<asp:Literal ID="editorJs" runat="server"></asp:Literal>
|
||||
|
||||
14
src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.css
Normal file
14
src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.css
Normal file
@@ -0,0 +1,14 @@
|
||||
#errorDiv
|
||||
{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#errorDiv a
|
||||
{
|
||||
float: right;
|
||||
}
|
||||
|
||||
.propertyItemheader
|
||||
{
|
||||
width: 200px !important;
|
||||
}
|
||||
69
src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.js
Normal file
69
src/Umbraco.Web.UI/umbraco_client/Editors/EditXslt.js
Normal file
@@ -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('<p><a href="#" onclick=\'closeErrorDiv()\'>Hide Errors</a><strong>Error occured</strong></p><p>' + t + '</p>');
|
||||
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);
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// JsInclude1 control.
|
||||
|
||||
Reference in New Issue
Block a user