This commit is contained in:
Sebastiaan Janssen
2012-10-10 11:03:27 -02:00
11 changed files with 337 additions and 317 deletions

View File

@@ -272,6 +272,12 @@
<Compile Include="umbraco\masterpages\UmbracoDialog.master.designer.cs">
<DependentUpon>umbracoDialog.Master</DependentUpon>
</Compile>
<Compile Include="umbraco\masterpages\UmbracoPage.master.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco\masterpages\UmbracoPage.master.designer.cs">
<DependentUpon>umbracoPage.Master</DependentUpon>
</Compile>
<Compile Include="umbraco\settings\EditTemplate.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
@@ -579,6 +585,7 @@
<Content Include="umbraco_client\ContextMenu\Css\jquery.contextMenu.css" />
<Content Include="umbraco_client\ContextMenu\Js\jquery.contextMenu.js" />
<Content Include="umbraco_client\Dialogs\UmbracoField.js" />
<Content Include="umbraco_client\Editors\EditView.js" />
<Content Include="umbraco_client\FileUploader\js\jquery.fileUploader.js" />
<Content Include="umbraco_client\FolderBrowser\Css\folderbrowser.css" />
<Content Include="umbraco_client\FolderBrowser\Js\folderbrowser.js" />

View File

@@ -1,5 +1,5 @@
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="umbracoPage.master.cs"
Inherits="umbraco.presentation.masterpages.umbracoPage" %>
<%@ Master Language="C#" AutoEventWireup="True" CodeBehind="UmbracoPage.master.cs"
Inherits="Umbraco.Web.UI.Umbraco.Masterpages.UmbracoPage" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
@@ -18,6 +18,7 @@
Priority="1" />
<umb:JsInclude ID="JsInclude9" runat="server" FilePath="Application/jQuery/jquery.cookie.js"
PathNameAlias="UmbracoClient" Priority="1" />
<umb:JsInclude ID="JsInclude10" runat="server" FilePath="ui/base2.js" PathNameAlias="UmbracoClient" Priority="1" />
<umb:JsInclude ID="JsInclude4" runat="server" FilePath="Application/UmbracoApplicationActions.js"
PathNameAlias="UmbracoClient" Priority="2" />
<umb:JsInclude ID="JsInclude5" runat="server" FilePath="Application/UmbracoUtils.js"

View File

@@ -6,58 +6,34 @@
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
<umb:JsInclude ID="JsInclude1" runat="server" FilePath="Editors/EditView.js" PathNameAlias="UmbracoClient" />
<script language="javascript" type="text/javascript">
function doSubmit() {
var codeVal = UmbEditor.GetCode();
umbraco.presentation.webservices.codeEditorSave.SaveTemplate(jQuery('#<%= NameTxt.ClientID %>').val(), jQuery('#<%= AliasTxt.ClientID %>').val(), codeVal, '<%= Request.QueryString["templateID"] %>', jQuery('#<%= MasterTemplate.ClientID %>').val(), submitSucces, submitFailure);
}
function submitSucces(t)
{
if(t != 'true')
{
top.UmbSpeechBubble.ShowMessage('error', '<%= umbraco.ui.Text("speechBubbles", "templateErrorHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateErrorText") %>');
}
else
{
top.UmbSpeechBubble.ShowMessage('save', '<%= umbraco.ui.Text("speechBubbles", "templateSavedHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateSavedText") %>')
}
}
function submitFailure(t)
{
top.UmbSpeechBubble.ShowMessage('error', '<%= umbraco.ui.Text("speechBubbles", "templateErrorHeader") %>', '<%= umbraco.ui.Text("speechBubbles", "templateErrorText") %>')
}
function changeMasterPageFile(){
var editor = document.getElementById("<%= editorSource.ClientID %>");
var templateDropDown = document.getElementById("<%= MasterTemplate.ClientID %>");
var templateCode = UmbEditor.GetCode();
var newValue = templateDropDown.options[templateDropDown.selectedIndex].id;
var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?)(\"[^\"]*?\"|null)(;[\\s\\S]*?})", "gi");
if(newValue != undefined && newValue != "") {
if (layoutDefRegex.test(templateCode)) {
// Declaration exists, so just update it
templateCode = templateCode.replace(layoutDefRegex, "$1\"" + newValue + "\"$3");
} else {
// Declaration doesn't exist, so prepend to start of doc
//TODO: Maybe insert at the cursor position, rather than just at the top of the doc?
templateCode = "@{\n\tLayout = \"" + newValue + "\";\n}\n" + templateCode;
}
} else {
if (layoutDefRegex.test(templateCode)) {
// Declaration exists, so just update it
templateCode = templateCode.replace(layoutDefRegex, "$1null$3");
}
}
UmbEditor.SetCode(templateCode);
return false;
}
(function ($) {
$(document).ready(function () {
//create a new EditView object
var editView = new Umbraco.Editors.EditView({
masterPageDropDown: $("#<%= MasterTemplate.ClientID %>"),
nameTxtBox: $("#<%= NameTxt.ClientID %>"),
aliasTxtBox: $("#<%= AliasTxt.ClientID %>"),
saveButton: $("#<%= ((Control)SaveButton).ClientID %>"),
templateId: '<%= Request.QueryString["templateID"] %>',
msgs: {
templateErrorHeader: "<%= umbraco.ui.Text("speechBubbles", "templateErrorHeader") %>",
templateErrorText: "<%= umbraco.ui.Text("speechBubbles", "templateErrorText") %>",
templateSavedHeader: "<%= umbraco.ui.Text("speechBubbles", "templateSavedHeader") %>",
templateSavedText: "<%= umbraco.ui.Text("speechBubbles", "templateSavedText") %>"
}
});
//initialize it.
editView.init();
//bind save shortcut
UmbClientMgr.appActions().bindSaveShortCut();
});
})(jQuery);
</script>
</asp:Content>
@@ -86,11 +62,4 @@
</cc1:Pane>
</cc1:UmbracoPanel>
<script type="text/javascript">
jQuery(document).ready(function () {
UmbClientMgr.appActions().bindSaveShortCut();
});
</script>
</asp:Content>

View File

@@ -32,6 +32,7 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
protected global::umbraco.uicontrols.CodeArea editorSource;
protected global::System.Web.UI.WebControls.Repeater rpt_codeTemplates;
protected global::System.Web.UI.WebControls.Repeater rpt_macros;
protected MenuIconI SaveButton;
public EditView()
@@ -43,8 +44,6 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
{
base.OnLoad(e);
MasterTemplate.Attributes.Add("onchange", "changeMasterPageFile()");
if (!IsPostBack)
{
MasterTemplate.Items.Add(new ListItem(ui.Text("none"), "0"));
@@ -91,11 +90,11 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views
base.OnInit(e);
Panel1.hasMenu = true;
MenuIconI save = Panel1.Menu.NewIcon();
save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif";
save.OnClickCommand = "doSubmit()";
save.AltText = ui.Text("save");
save.ID = "save";
SaveButton = Panel1.Menu.NewIcon();
SaveButton.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif";
//SaveButton.OnClickCommand = "doSubmit()";
SaveButton.AltText = ui.Text("save");
SaveButton.ID = "save";
Panel1.Text = ui.Text("edittemplate");
pp_name.Text = ui.Text("name", base.getUser());

View File

@@ -11,5 +11,14 @@ namespace Umbraco.Web.UI.Umbraco.Settings.Views {
public partial class EditView {
/// <summary>
/// JsInclude1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
}
}

View File

@@ -0,0 +1,91 @@
Umbraco.Sys.registerNamespace("Umbraco.Editors");
(function ($) {
Umbraco.Editors.EditView = base2.Base.extend({
//private methods/variables
_opts: null,
// Constructor
constructor: function (opts) {
// Merge options with default
this._opts = $.extend({
// Default options go here
}, opts);
},
//public methods/variables
init: function () {
var self = this;
//bind to the change of the master template drop down
this._opts.masterPageDropDown.change(function () {
self.changeMasterPageFile();
});
//bind to the save event
this._opts.saveButton.click(function() {
self.doSubmit();
});
},
doSubmit: function () {
var codeVal = UmbEditor.GetCode();
var self = this;
umbraco.presentation.webservices.codeEditorSave.SaveTemplate(
this._opts.nameTxtBox.val(),
this._opts.aliasTxtBox.val(),
codeVal,
this._opts.templateId,
this._opts.masterPageDropDown.val(),
function (t) { self.submitSuccess(t); },
function (t) { self.submitFailure(t); });
},
submitSuccess: function (t) {
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', this._opts.msgs.templateErrorHeader, this._opts.msgs.templateErrorText);
}
else {
top.UmbSpeechBubble.ShowMessage('save', this._opts.msgs.templateSavedHeader, this._opts.msgs.templateSavedText);
}
},
submitFailure: function (t) {
top.UmbSpeechBubble.ShowMessage('error', this._opts.msgs.templateErrorHeader, this._opts.msgs.templateErrorText);
},
changeMasterPageFile: function ( ) {
//var editor = document.getElementById(this._opts.sourceEditorId);
var templateDropDown = this._opts.masterPageDropDown.get(0);
var templateCode = UmbEditor.GetCode();
var newValue = templateDropDown.options[templateDropDown.selectedIndex].id;
var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?)(\"[^\"]*?\"|null)(;[\\s\\S]*?})", "gi");
if (newValue != undefined && newValue != "") {
if (layoutDefRegex.test(templateCode)) {
// Declaration exists, so just update it
templateCode = templateCode.replace(layoutDefRegex, "$1\"" + newValue + "\"$3");
} else {
// Declaration doesn't exist, so prepend to start of doc
//TODO: Maybe insert at the cursor position, rather than just at the top of the doc?
templateCode = "@{\n\tLayout = \"" + newValue + "\";\n}\n" + templateCode;
}
} else {
if (layoutDefRegex.test(templateCode)) {
// Declaration exists, so just update it
templateCode = templateCode.replace(layoutDefRegex, "$1null$3");
}
}
UmbEditor.SetCode(templateCode);
return false;
}
});
})(jQuery);