Fixed U4-1414 SplitButtons in template editor aren't working
This commit is contained in:
@@ -8,32 +8,31 @@
|
||||
<!DOCTYPE html>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
|
||||
<umb:CssInclude ID="CssInclude1" runat="server" FilePath="splitbutton/splitbutton.css" PathNameAlias="UmbracoClient" />
|
||||
<umb:JsInclude ID="JsInclude" runat="server" FilePath="splitbutton/jquery.splitbutton.js" PathNameAlias="UmbracoClient" />
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
//macro split button
|
||||
|
||||
jQuery("#splitButtonMacro").appendTo("#splitButtonMacroPlaceHolder");
|
||||
jQuery('#sbMacro').splitbutton({menu:'#macroMenu'});
|
||||
//jQuery(".macro").click(function(){
|
||||
// var alias = jQuery(this).attr("rel");
|
||||
// if(jQuery(this).attr("params") == "1")
|
||||
// {
|
||||
// openMacroModal(alias);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// insertMacro(alias);
|
||||
// }
|
||||
//});
|
||||
//applySplitButtonOverflow('mcontainer','innerc','macroMenu','.macro', 'showMoreMacros');
|
||||
jQuery("#splitButtonMacro").appendTo("#splitButtonMacroPlaceHolder");
|
||||
|
||||
////razor macro split button
|
||||
//jQuery('#sb').splitbutton({menu:'#codeTemplateMenu'});
|
||||
//jQuery("#splitButton").appendTo("#splitButtonPlaceHolder");
|
||||
jQuery('#sb').splitbutton({menu:'#codeTemplateMenu'});
|
||||
jQuery("#splitButton").appendTo("#splitButtonPlaceHolder");
|
||||
|
||||
jQuery(".macro").click(function(){
|
||||
var alias = jQuery(this).attr("rel");
|
||||
if(jQuery(this).attr("params") == "1")
|
||||
{
|
||||
openMacroModal(alias);
|
||||
}
|
||||
else
|
||||
{
|
||||
insertMacro(alias);
|
||||
}
|
||||
});
|
||||
|
||||
jQuery(".codeTemplate").click(function(){
|
||||
insertCodeBlockFromTemplate(jQuery(this).attr("rel"));
|
||||
@@ -63,116 +62,116 @@
|
||||
}
|
||||
|
||||
function umbracoTemplateInsertMasterPageContentContainer() {
|
||||
var master = document.getElementById('<%= MasterTemplate.ClientID %>')[document.getElementById('<%= MasterTemplate.ClientID %>').selectedIndex].value;
|
||||
if (master == "") master = 0;
|
||||
umbraco.presentation.webservices.legacyAjaxCalls.TemplateMasterPageContentContainer(<%=Request["templateID"] %>, master, umbracoTemplateInsertMasterPageContentContainerDo);
|
||||
}
|
||||
var master = document.getElementById('<%= MasterTemplate.ClientID %>')[document.getElementById('<%= MasterTemplate.ClientID %>').selectedIndex].value;
|
||||
if (master == "") master = 0;
|
||||
umbraco.presentation.webservices.legacyAjaxCalls.TemplateMasterPageContentContainer(<%=Request["templateID"] %>, master, umbracoTemplateInsertMasterPageContentContainerDo);
|
||||
}
|
||||
|
||||
function umbracoTemplateInsertMasterPageContentContainerDo(result) {
|
||||
function umbracoTemplateInsertMasterPageContentContainerDo(result) {
|
||||
UmbEditor.Insert(result + '\n', '\n</asp\:Content>\n', '<%= editorSource.ClientID%>');
|
||||
}
|
||||
|
||||
function changeMasterPageFile(){
|
||||
var editor = document.getElementById("<%= editorSource.ClientID %>");
|
||||
var templateDropDown = document.getElementById("<%= MasterTemplate.ClientID %>");
|
||||
var editor = document.getElementById("<%= editorSource.ClientID %>");
|
||||
var templateDropDown = document.getElementById("<%= MasterTemplate.ClientID %>");
|
||||
|
||||
var templateCode = UmbEditor.GetCode();
|
||||
var selectedTemplate = templateDropDown.options[templateDropDown.selectedIndex].id;
|
||||
var masterTemplate = "<%= umbraco.IO.SystemDirectories.Masterpages%>/" + selectedTemplate + ".master";
|
||||
var templateCode = UmbEditor.GetCode();
|
||||
var selectedTemplate = templateDropDown.options[templateDropDown.selectedIndex].id;
|
||||
var masterTemplate = "<%= umbraco.IO.SystemDirectories.Masterpages%>/" + selectedTemplate + ".master";
|
||||
|
||||
if(selectedTemplate == "")
|
||||
masterTemplate = "<%= umbraco.IO.SystemDirectories.Umbraco%>/masterpages/default.master";
|
||||
masterTemplate = "<%= umbraco.IO.SystemDirectories.Umbraco%>/masterpages/default.master";
|
||||
|
||||
var regex = /MasterPageFile=[~a-z0-9/._"-]+/im;
|
||||
|
||||
if (templateCode.match(regex)) {
|
||||
templateCode = templateCode.replace(regex, 'MasterPageFile="' + masterTemplate + '"');
|
||||
if (templateCode.match(regex)) {
|
||||
templateCode = templateCode.replace(regex, 'MasterPageFile="' + masterTemplate + '"');
|
||||
|
||||
UmbEditor.SetCode(templateCode);
|
||||
UmbEditor.SetCode(templateCode);
|
||||
|
||||
} else {
|
||||
//todo, spot if a directive is there, and if not suggest that the user inserts it..
|
||||
alert("Master directive not found...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//todo, spot if a directive is there, and if not suggest that the user inserts it..
|
||||
alert("Master directive not found...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function insertContentElement(id){
|
||||
function insertContentElement(id){
|
||||
|
||||
//nasty hack to avoid asp.net freaking out because of the markup...
|
||||
var cp = 'asp:Content ContentPlaceHolderId="' + id + '"';
|
||||
cp += ' runat="server"';
|
||||
cp += '>\n\t<!-- Insert "' + id + '" markup here -->';
|
||||
//nasty hack to avoid asp.net freaking out because of the markup...
|
||||
var cp = 'asp:Content ContentPlaceHolderId="' + id + '"';
|
||||
cp += ' runat="server"';
|
||||
cp += '>\n\t<!-- Insert "' + id + '" markup here -->';
|
||||
|
||||
UmbEditor.Insert('\n<' + cp, '\n</asp:Content' + '>\n', '<%= editorSource.ClientID %>');
|
||||
}
|
||||
UmbEditor.Insert('\n<' + cp, '\n</asp:Content' + '>\n', '<%= editorSource.ClientID %>');
|
||||
}
|
||||
|
||||
function insertPlaceHolderElement(id){
|
||||
function insertPlaceHolderElement(id){
|
||||
|
||||
var cp = 'asp:ContentPlaceHolder Id="' + id + '"';
|
||||
cp += ' runat="server"';
|
||||
cp += '>\n\t<!-- Insert default "' + id + '" markup here -->';
|
||||
|
||||
UmbEditor.Insert('\n<' + cp, '\n</asp:ContentPlaceHolder' + '>\n', '<%= editorSource.ClientID %>');
|
||||
}
|
||||
}
|
||||
|
||||
function insertCodeBlock()
|
||||
{
|
||||
var snip = umbracoInsertSnippet();
|
||||
UmbEditor.Insert(snip.BeginTag, snip.EndTag, '<%= editorSource.ClientID %>');
|
||||
}
|
||||
function insertCodeBlock()
|
||||
{
|
||||
var snip = umbracoInsertSnippet();
|
||||
UmbEditor.Insert(snip.BeginTag, snip.EndTag, '<%= editorSource.ClientID %>');
|
||||
}
|
||||
|
||||
function umbracoInsertSnippet() {
|
||||
function umbracoInsertSnippet() {
|
||||
var snip = new UmbracoCodeSnippet();
|
||||
var cp = 'umbraco:Macro runat="server" language="cshtml"';
|
||||
snip.BeginTag = '\n<' + cp + '>\n';
|
||||
snip.EndTag = '\n<' + '/umbraco:Macro' + '>\n';
|
||||
snip.TargetId = "<%= editorSource.ClientID %>";
|
||||
return snip;
|
||||
}
|
||||
}
|
||||
|
||||
function insertCodeBlockFromTemplate(templateId)
|
||||
{
|
||||
function insertCodeBlockFromTemplate(templateId)
|
||||
{
|
||||
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: "../webservices/templates.asmx/GetCodeSnippet",
|
||||
data: "{templateId: '" + templateId + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function(msg) {
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: "../webservices/templates.asmx/GetCodeSnippet",
|
||||
data: "{templateId: '" + templateId + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function(msg) {
|
||||
|
||||
var cp = 'umbraco:Macro runat="server" language="cshtml"';
|
||||
UmbEditor.Insert('\n<' + cp +'>\n' + msg.d,'\n</umbraco:Macro' + '>\n', '<%= editorSource.ClientID %>');
|
||||
var cp = 'umbraco:Macro runat="server" language="cshtml"';
|
||||
UmbEditor.Insert('\n<' + cp +'>\n' + msg.d,'\n</umbraco:Macro' + '>\n', '<%= editorSource.ClientID %>');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function insertMacro(alias)
|
||||
{
|
||||
function insertMacro(alias)
|
||||
{
|
||||
<%if (umbraco.UmbracoSettings.UseAspNetMasterPages) { %>
|
||||
var macroElement = "umbraco:Macro";
|
||||
var macroElement = "umbraco:Macro";
|
||||
<%}else{ %>
|
||||
var macroElement = "?UMBRACO_MACRO";
|
||||
var macroElement = "?UMBRACO_MACRO";
|
||||
<%}%>
|
||||
|
||||
var cp = macroElement + ' Alias="'+ alias +'" runat="server"';
|
||||
UmbEditor.Insert('<' + cp +' />','', '<%= editorSource.ClientID %>');
|
||||
}
|
||||
function openMacroModal(alias)
|
||||
{
|
||||
var t = "";
|
||||
if(alias != null && alias != ""){
|
||||
t = "&alias="+alias;
|
||||
}
|
||||
UmbClientMgr.openModalWindow('<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/dialogs/editMacro.aspx?renderingEngine=Webforms&objectId=<%= editorSource.ClientID %>' + t, 'Insert Macro', true, 470, 530, 0, 0, '', '');
|
||||
}
|
||||
var cp = macroElement + ' Alias="'+ alias +'" runat="server"';
|
||||
UmbEditor.Insert('<' + cp +' />','', '<%= editorSource.ClientID %>');
|
||||
}
|
||||
function openMacroModal(alias)
|
||||
{
|
||||
var t = "";
|
||||
if(alias != null && alias != ""){
|
||||
t = "&alias="+alias;
|
||||
}
|
||||
UmbClientMgr.openModalWindow('<%= IOHelper.ResolveUrl(SystemDirectories.Umbraco) %>/dialogs/editMacro.aspx?renderingEngine=Webforms&objectId=<%= editorSource.ClientID %>' + t, 'Insert Macro', true, 470, 530, 0, 0, '', '');
|
||||
}
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
|
||||
<cc1:UmbracoPanel ID="Panel1" runat="server" Width="608px" Height="336px" hasMenu="true">
|
||||
<cc1:Pane ID="Pane7" runat="server" Height="44px" Width="528px">
|
||||
<cc1:PropertyPanel ID="pp_name" runat="server">
|
||||
|
||||
Reference in New Issue
Block a user