Updated EditMacro.js to support inserting different syntax depending on rendering engine. Just need to get it to insert the params for MVC now.

Added HttpRequestExtenions with a method GetItemAsString which obsoletes/supercedes the old 'umbraco.helper.Request' method.
This commit is contained in:
Shannon Deminick
2013-01-03 06:21:55 +03:00
parent e0550a9a57
commit 872c163999
8 changed files with 414 additions and 342 deletions

View File

@@ -2,6 +2,7 @@
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<%@ Import Namespace="Umbraco.Web" %>
<%@ Register TagPrefix="cc2" Namespace="umbraco.uicontrols" Assembly="controls" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
@@ -13,7 +14,8 @@
$(document).ready(function () {
Umbraco.Dialogs.EditMacro.getInstance().init({
useAspNetMasterPages: <%=umbraco.UmbracoSettings.UseAspNetMasterPages.ToString().ToLower() %>,
codeEditorElementId: "<%=umbraco.helper.Request("objectId")%>",
codeEditorElementId: "<%=Request.GetItemAsString("objectId")%>",
renderingEngine: "<%=Request.GetItemAsString("renderingEngine")%>",
macroAlias: '<%= _macroAlias %>'
});
});

View File

@@ -163,7 +163,7 @@
if(alias != null && alias != ""){
t = "&alias="+alias;
}
UmbClientMgr.openModalWindow('<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/dialogs/editMacro.aspx?objectId=<%= editorSource.ClientID %>' + t, 'Insert Macro', true, 470, 530, 0, 0, '', '');
UmbClientMgr.openModalWindow('<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/dialogs/editMacro.aspx?renderingEngine=Webforms&objectId=<%= editorSource.ClientID %>' + t, 'Insert Macro', true, 470, 530, 0, 0, '', '');
}
</script>

View File

@@ -22,36 +22,15 @@
document.getElementById("label" + macroAlias).innerHTML = "</b><i>updated with id: " + treePicker + "</i><b><br/>";
},
// Constructor
constructor: function () {
_getMacroSyntaxMvc: function() {
/// <summary>Return the macro syntax to insert for MVC</summary>
return "@Umbraco.RenderMacro(\"" + this._opts.macroAlias + "\")";
},
//public methods
init: function (opts) {
/// <summary>Initializes the class and any UI bindings</summary>
// Merge options with default
this._opts = $.extend({
// Default options go here
}, opts);
var self = this;
//The knockout js view model for the selected item
var koViewModel = {
cancelModal: function () {
UmbClientMgr.closeModalWindow();
},
updateMacro: function () {
self.updateMacro();
}
};
ko.applyBindings(koViewModel);
},
updateMacro: function () {
_getMacroSyntaxWebForms: function () {
/// <summary>Return the macro syntax to insert for webforms</summary>
var macroElement;
if (this._opts.useAspNetMasterPages) {
macroElement = "umbraco:Macro";
@@ -120,9 +99,51 @@
else {
macroString += "></" + macroElement + ">";
}
return macroString;
},
// Constructor
constructor: function () {
},
//public methods
init: function (opts) {
/// <summary>Initializes the class and any UI bindings</summary>
// Merge options with default
this._opts = $.extend({
// Default options go here
}, opts);
var self = this;
//The knockout js view model for the selected item
var koViewModel = {
cancelModal: function () {
UmbClientMgr.closeModalWindow();
},
updateMacro: function () {
self.updateMacro();
}
};
ko.applyBindings(koViewModel);
},
updateMacro: function () {
var macroSyntax = null;
//if it is Mvc or empty, then use Mvc
if (this._opts.renderingEngine == "Mvc" || this._opts.renderingEngine == "") {
macroSyntax = this._getMacroSyntaxMvc();
}
else {
macroSyntax = this._getMacroSyntaxWebForms();
}
UmbClientMgr.contentFrame().focus();
UmbClientMgr.contentFrame().UmbEditor.Insert(macroString, '', this._opts.codeEditorElementId);
UmbClientMgr.contentFrame().UmbEditor.Insert(macroSyntax, '', this._opts.codeEditorElementId);
UmbClientMgr.closeModalWindow();
},

View File

@@ -42,7 +42,9 @@
if (alias != null && alias != "") {
t = "&alias=" + alias;
}
UmbClientMgr.openModalWindow(this._opts.modalUrl + '?objectId=' + this._opts.codeEditorElementId + t, 'Insert Macro', true, 470, 530, 0, 0, '', '');
UmbClientMgr.openModalWindow(
this._opts.modalUrl + '?renderingEngine=Mvc&objectId=' + this._opts.codeEditorElementId + t,
'Insert Macro', true, 470, 530, 0, 0, '', '');
},
doSubmit: function () {