Add WebCms
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
a
|
||||
{
|
||||
color: #3C6B96;
|
||||
}
|
||||
|
||||
.tdDir a
|
||||
{
|
||||
color: #3C6B96;
|
||||
padding: 3px;
|
||||
padding-left: 25px;
|
||||
background: url(../../umbraco/images/foldericon.png) no-repeat 2px 2px;
|
||||
}
|
||||
|
||||
.tdFile a
|
||||
{
|
||||
color: #3C6B96;
|
||||
padding: 3px;
|
||||
padding-left: 25px;
|
||||
background: url(../../umbraco/images/file.png) no-repeat 2px 2px;
|
||||
}
|
||||
|
||||
small a
|
||||
{
|
||||
color: #999;
|
||||
padding-left: 3px !Important;
|
||||
background-image: none !Important;
|
||||
text-decoration: none;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
table.macro-props {
|
||||
width: 98%;
|
||||
border: 0;
|
||||
}
|
||||
table.macro-props td {
|
||||
padding: 4px;
|
||||
}
|
||||
table.macro-props td.propertyHeader {
|
||||
width: 200px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
table.macro-props td.propertyContent {
|
||||
vertical-align: middle;
|
||||
}
|
||||
table.macro-props td.propertyContent .guiInputText {
|
||||
width: 300px;
|
||||
}
|
||||
table.macro-props td.propertyContent .guiInputText.small
|
||||
{
|
||||
width: 60px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
table.macro-props.params td.propertyHeader
|
||||
{
|
||||
width: 25%;
|
||||
}
|
||||
table.macro-props.params td.propertyContent input,
|
||||
table.macro-props.params td.propertyContent select
|
||||
{
|
||||
width: 90%;
|
||||
}
|
||||
table.macro-props.params td.propertyContent input[type=submit] {
|
||||
width: 100px;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
Umbraco.Sys.registerNamespace("Umbraco.Editors");
|
||||
|
||||
(function ($) {
|
||||
|
||||
Umbraco.Editors.EditMacroScripts = 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 (event) {
|
||||
event.preventDefault();
|
||||
self.doSubmit();
|
||||
});
|
||||
},
|
||||
|
||||
doSubmit: function () {
|
||||
var self = this;
|
||||
|
||||
jQuery('#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.SaveDLRScript(
|
||||
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 scripting file failed', t);
|
||||
}
|
||||
|
||||
var newFilePath = this._opts.nameTxtBox.val();
|
||||
|
||||
//if the filename changes, we need to redirect since the file name is used in the url
|
||||
if (this._opts.originalFileName != newFilePath) {
|
||||
var newLocation = window.location.pathname + "?" + "&file=" + newFilePath;
|
||||
|
||||
UmbClientMgr.contentFrame(newLocation);
|
||||
|
||||
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
|
||||
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '');
|
||||
}
|
||||
else {
|
||||
|
||||
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '');
|
||||
UmbClientMgr.mainTree().setActiveTreeType('python');
|
||||
//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', 'Scripting file could not be saved', '');
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,116 @@
|
||||
Umbraco.Sys.registerNamespace("Umbraco.Editors");
|
||||
|
||||
(function ($) {
|
||||
|
||||
Umbraco.Editors.EditScript = 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 (event) {
|
||||
event.preventDefault();
|
||||
self.doSubmit();
|
||||
});
|
||||
},
|
||||
|
||||
doSubmit: function () {
|
||||
var self = this;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
this.save(
|
||||
filename,
|
||||
self._opts.originalFileName,
|
||||
codeval);
|
||||
},
|
||||
|
||||
save: function (filename, oldName, contents) {
|
||||
var self = this;
|
||||
|
||||
$.post(self._opts.restServiceLocation + "SaveScript",
|
||||
JSON.stringify({
|
||||
filename: filename,
|
||||
oldName: oldName,
|
||||
contents: contents
|
||||
}),
|
||||
function (e) {
|
||||
if (e.success) {
|
||||
self.submitSuccess(e);
|
||||
} else {
|
||||
self.submitFailure(e.message, e.header);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
submitSuccess: function (args) {
|
||||
var msg = args.message;
|
||||
var header = args.header;
|
||||
var path = this._opts.treeSyncPath;
|
||||
var pathChanged = false;
|
||||
if (args.path) {
|
||||
if (path != args.path) {
|
||||
pathChanged = true;
|
||||
}
|
||||
path = args.path;
|
||||
}
|
||||
if (args.contents) {
|
||||
UmbEditor.SetCode(args.contents);
|
||||
}
|
||||
|
||||
UmbClientMgr.mainTree().setActiveTreeType("scripts");
|
||||
if (pathChanged) {
|
||||
// no! file is used in url so we need to redirect
|
||||
//UmbClientMgr.mainTree().moveNode(this._opts.originalFileName, path);
|
||||
//this._opts.treeSyncPath = args.path;
|
||||
//this._opts.lttPathElement.prop("href", args.url).html(args.url);
|
||||
|
||||
var qs = window.location.search;
|
||||
if (qs.startsWith("?")) qs = qs.substring("?".length);
|
||||
var qp1 = qs.split("&");
|
||||
var qp2 = [];
|
||||
for (var i = 0; i < qp1.length; i++)
|
||||
if (!qp1[i].startsWith("file="))
|
||||
qp2.push(qp1[i]);
|
||||
|
||||
var location = window.location.pathname + "?" + qp2.join("&") + "&file=" + args.name;
|
||||
UmbClientMgr.contentFrame(location);
|
||||
|
||||
// need to do it after we navigate otherwise the navigation waits until the message timeout is done
|
||||
top.UmbSpeechBubble.ShowMessage("save", header, msg);
|
||||
}
|
||||
else {
|
||||
top.UmbSpeechBubble.ShowMessage("save", header, msg);
|
||||
this._opts.lttPathElement.prop("href", args.url).html(args.url);
|
||||
this._opts.originalFileName = args.name;
|
||||
this._opts.treeSyncPath = args.path;
|
||||
UmbClientMgr.mainTree().syncTree(path, true);
|
||||
}
|
||||
|
||||
//this._opts.lttPathElement.prop("href", args.url).html(args.url);
|
||||
//this._opts.originalFileName = args.name;
|
||||
},
|
||||
|
||||
submitFailure: function(err, header) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', header, err);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,109 @@
|
||||
Umbraco.Sys.registerNamespace("Umbraco.Editors");
|
||||
|
||||
(function ($) {
|
||||
|
||||
Umbraco.Editors.EditStyleSheet = 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 (event) {
|
||||
event.preventDefault();
|
||||
self.doSubmit();
|
||||
});
|
||||
},
|
||||
|
||||
doSubmit: function() {
|
||||
var self = this;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
this.save(
|
||||
filename,
|
||||
self._opts.originalFileName,
|
||||
codeval);
|
||||
},
|
||||
|
||||
save: function (filename, oldName, contents) {
|
||||
var self = this;
|
||||
|
||||
$.post(self._opts.restServiceLocation + "SaveStylesheet",
|
||||
JSON.stringify({
|
||||
filename: filename,
|
||||
oldName: oldName,
|
||||
contents: contents
|
||||
}),
|
||||
function (e) {
|
||||
if (e.success) {
|
||||
self.submitSuccess(e);
|
||||
} else {
|
||||
self.submitFailure(e.message, e.header);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
submitSuccess: function (args) {
|
||||
var msg = args.message;
|
||||
var header = args.header;
|
||||
var path = this._opts.treeSyncPath;
|
||||
var pathChanged = false;
|
||||
if (args.path) {
|
||||
if (path != args.path) {
|
||||
pathChanged = true;
|
||||
}
|
||||
path = args.path;
|
||||
}
|
||||
if (args.contents) {
|
||||
UmbEditor.SetCode(args.contents);
|
||||
}
|
||||
|
||||
UmbClientMgr.mainTree().setActiveTreeType("stylesheets");
|
||||
if (pathChanged) {
|
||||
// file is used in url so we need to redirect
|
||||
var qs = window.location.search;
|
||||
if (qs.startsWith("?")) qs = qs.substring("?".length);
|
||||
var qp1 = qs.split("&");
|
||||
var qp2 = [];
|
||||
for (var i = 0; i < qp1.length; i++)
|
||||
if (!qp1[i].startsWith("id="))
|
||||
qp2.push(qp1[i]);
|
||||
|
||||
var location = window.location.pathname + "?" + qp2.join("&") + "&id=" + args.name;
|
||||
UmbClientMgr.contentFrame(location);
|
||||
|
||||
// need to do it after we navigate otherwise the navigation waits until the message timeout is done
|
||||
top.UmbSpeechBubble.ShowMessage("save", header, msg);
|
||||
}
|
||||
else {
|
||||
top.UmbSpeechBubble.ShowMessage("save", header, msg);
|
||||
this._opts.lttPathElement.prop("href", args.url).html(args.url);
|
||||
this._opts.originalFileName = args.name;
|
||||
this._opts.treeSyncPath = args.path;
|
||||
UmbClientMgr.mainTree().syncTree(path, true);
|
||||
}
|
||||
},
|
||||
|
||||
submitFailure: function(err, header) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', header, err);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,181 @@
|
||||
Umbraco.Sys.registerNamespace("Umbraco.Editors");
|
||||
|
||||
(function ($) {
|
||||
|
||||
Umbraco.Editors.EditTemplate = base2.Base.extend({
|
||||
//private methods/variables
|
||||
_opts: null,
|
||||
|
||||
_openMacroModal: function(alias) {
|
||||
|
||||
var self = this;
|
||||
|
||||
UmbClientMgr.openAngularModalWindow({
|
||||
template: "views/common/dialogs/insertmacro.html",
|
||||
dialogData: {
|
||||
renderingEngine: "WebForms",
|
||||
macroData: { macroAlias: alias }
|
||||
},
|
||||
callback: function(data) {
|
||||
UmbEditor.Insert(data.syntax, '', self._opts.editorClientId);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_insertMacro: function(alias) {
|
||||
var macroElement = "umbraco:Macro";
|
||||
if (!this._opts.useMasterPages) {
|
||||
macroElement = "?UMBRACO_MACRO";
|
||||
}
|
||||
var cp = macroElement + ' Alias="' + alias + '" runat="server"';
|
||||
UmbEditor.Insert('<' + cp + ' />', '', this._opts.editorClientId);
|
||||
},
|
||||
|
||||
_insertCodeBlockFromTemplate: function(templateId) {
|
||||
var self = this;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: this._opts.umbracoPath + "/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', self._opts.editorClientId);
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_insertCodeBlock: function() {
|
||||
var snip = this._umbracoInsertSnippet();
|
||||
UmbEditor.Insert(snip.BeginTag, snip.EndTag, this._opts.editorClientId);
|
||||
},
|
||||
|
||||
_umbracoInsertSnippet: function() {
|
||||
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 = this._opts.editorClientId;
|
||||
return snip;
|
||||
},
|
||||
|
||||
// Constructor
|
||||
constructor: function(opts) {
|
||||
// Merge options with default
|
||||
this._opts = $.extend({
|
||||
|
||||
|
||||
// Default options go here
|
||||
}, opts);
|
||||
},
|
||||
|
||||
init: function() {
|
||||
//<summary>Sets up the UI and binds events</summary>
|
||||
|
||||
var self = this;
|
||||
|
||||
//bind to the save event
|
||||
this._opts.saveButton.click(function (event) {
|
||||
event.preventDefault();
|
||||
self.doSubmit();
|
||||
});
|
||||
|
||||
$("#sb").click(function() {
|
||||
self._insertCodeBlock();
|
||||
});
|
||||
$("#sbMacro").click(function() {
|
||||
self._openMacroModal();
|
||||
});
|
||||
//macro split button
|
||||
$('#sbMacro').splitbutton({ menu: '#macroMenu' });
|
||||
$("#splitButtonMacro").appendTo("#splitButtonMacroPlaceHolder");
|
||||
|
||||
////razor macro split button
|
||||
$('#sb').splitbutton({ menu: '#codeTemplateMenu' });
|
||||
$("#splitButton").appendTo("#splitButtonPlaceHolder");
|
||||
|
||||
$(".macro").click(function() {
|
||||
var alias = $(this).attr("rel");
|
||||
if ($(this).attr("params") == "1") {
|
||||
self._openMacroModal(alias);
|
||||
}
|
||||
else {
|
||||
self._insertMacro(alias);
|
||||
}
|
||||
});
|
||||
|
||||
$(".codeTemplate").click(function() {
|
||||
self._insertCodeBlockFromTemplate($(this).attr("rel"));
|
||||
});
|
||||
},
|
||||
|
||||
doSubmit: function() {
|
||||
this.save(jQuery('#' + this._opts.templateNameClientId).val(), jQuery('#' + this._opts.templateAliasClientId).val(), UmbEditor.GetCode());
|
||||
},
|
||||
|
||||
save: function(templateName, templateAlias, codeVal) {
|
||||
var self = this;
|
||||
|
||||
$.post(self._opts.restServiceLocation + "SaveTemplate",
|
||||
JSON.stringify({
|
||||
templateName: templateName,
|
||||
templateAlias: templateAlias,
|
||||
templateContents: codeVal,
|
||||
templateId: self._opts.templateId,
|
||||
masterTemplateId: this._opts.masterPageDropDown.val()
|
||||
}),
|
||||
function (e) {
|
||||
if (e.success) {
|
||||
self.submitSuccess(e);
|
||||
} else {
|
||||
self.submitFailure(e.message, e.header);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
submitSuccess: function (args) {
|
||||
var msg = args.message;
|
||||
var header = args.header;
|
||||
var path = this._opts.treeSyncPath;
|
||||
var pathChanged = false;
|
||||
if (args.path) {
|
||||
if (path != args.path) {
|
||||
pathChanged = true;
|
||||
}
|
||||
path = args.path;
|
||||
}
|
||||
if (args.contents) {
|
||||
UmbEditor.SetCode(args.contents);
|
||||
}
|
||||
|
||||
var alias = args.alias;
|
||||
this._opts.aliasTxtBox.val(alias);
|
||||
|
||||
top.UmbSpeechBubble.ShowMessage('save', header, msg);
|
||||
UmbClientMgr.mainTree().setActiveTreeType('templates');
|
||||
if (pathChanged) {
|
||||
UmbClientMgr.mainTree().moveNode(this._opts.templateId, path);
|
||||
}
|
||||
else {
|
||||
UmbClientMgr.mainTree().syncTree(path, true);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
submitFailure: function (err, header) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', header, err);
|
||||
}
|
||||
});
|
||||
|
||||
//Set defaults for jQuery ajax calls.
|
||||
$.ajaxSetup({
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8'
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,288 @@
|
||||
Umbraco.Sys.registerNamespace("Umbraco.Editors");
|
||||
|
||||
(function ($) {
|
||||
|
||||
Umbraco.Editors.EditView = base2.Base.extend({
|
||||
/// <summary>Defines the EditView class to controll the persisting of the view file and UI interaction</summary>
|
||||
|
||||
//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 (event) {
|
||||
event.preventDefault();
|
||||
self.doSubmit();
|
||||
});
|
||||
},
|
||||
|
||||
insertMacroMarkup: function(alias) {
|
||||
/// <summary>callback used to insert the markup for a macro with no parameters</summary>
|
||||
|
||||
UmbEditor.Insert("@Umbraco.RenderMacro(\"" + alias + "\")", "", this._opts.codeEditorElementId);
|
||||
},
|
||||
|
||||
insertRenderBody: function() {
|
||||
UmbEditor.Insert("@RenderBody()", "", this._opts.codeEditorElementId);
|
||||
},
|
||||
|
||||
openMacroModal: function (alias) {
|
||||
/// <summary>callback used to display the modal dialog to insert a macro with parameters</summary>
|
||||
|
||||
var self = this;
|
||||
|
||||
UmbClientMgr.openAngularModalWindow({
|
||||
template: "views/common/dialogs/insertmacro.html",
|
||||
dialogData: {
|
||||
renderingEngine: "Mvc",
|
||||
macroData: {macroAlias: alias}
|
||||
},
|
||||
callback: function (data) {
|
||||
UmbEditor.Insert(data.syntax, '', self._opts.codeEditorElementId);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
openSnippetModal: function (type) {
|
||||
/// <summary>callback used to display the modal dialog to insert a macro with parameters</summary>
|
||||
|
||||
var self = this;
|
||||
|
||||
UmbClientMgr.openAngularModalWindow({
|
||||
template: "views/common/dialogs/template/snippet.html",
|
||||
callback: function (data) {
|
||||
|
||||
var code = "";
|
||||
|
||||
if (type === 'section') {
|
||||
code = "\n@section " + data.name + "{\n";
|
||||
code += "<!-- Content here -->\n" +
|
||||
"}\n";
|
||||
}
|
||||
|
||||
if (type === 'rendersection') {
|
||||
if (data.required) {
|
||||
code = "\n@RenderSection(\"" + data.name + "\", true)\n";
|
||||
} else {
|
||||
code = "\n@RenderSection(\"" + data.name + "\", false)\n";
|
||||
}
|
||||
}
|
||||
|
||||
UmbEditor.Insert(code, '', self._opts.codeEditorElementId);
|
||||
},
|
||||
type: type
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
openQueryModal: function () {
|
||||
/// <summary>callback used to display the modal dialog to insert a macro with parameters</summary>
|
||||
|
||||
var self = this;
|
||||
|
||||
UmbClientMgr.openAngularModalWindow({
|
||||
template: "views/common/dialogs/template/queryBuilder.html",
|
||||
callback: function (data) {
|
||||
|
||||
//var dataFormatted = data.replace(new RegExp('[' + "." + ']', 'g'), "\n\t\t\t\t\t.");
|
||||
|
||||
var code = "\n@{\n" + "\tvar selection = " + data + ";\n}\n";
|
||||
code += "<ul>\n" +
|
||||
"\t@foreach(var item in selection){\n" +
|
||||
"\t\t<li>\n" +
|
||||
"\t\t\t<a href=\"@item.Url\">@item.Name</a>\n" +
|
||||
"\t\t</li>\n" +
|
||||
"\t}\n" +
|
||||
"</ul>\n\n";
|
||||
|
||||
UmbEditor.Insert(code, '', self._opts.codeEditorElementId);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
doSubmit: function () {
|
||||
/// <summary>Submits the data to the server for saving</summary>
|
||||
var codeVal = UmbClientMgr.contentFrame().UmbEditor.GetCode();
|
||||
var self = this;
|
||||
|
||||
if (this._opts.editorType == "Template") {
|
||||
//saving a template view
|
||||
|
||||
$.post(self._opts.restServiceLocation + "SaveTemplate",
|
||||
JSON.stringify({
|
||||
templateName: this._opts.nameTxtBox.val(),
|
||||
templateAlias: this._opts.aliasTxtBox.val(),
|
||||
templateContents: codeVal,
|
||||
templateId: this._opts.templateId,
|
||||
masterTemplateId: this._opts.masterPageDropDown.val()
|
||||
}),
|
||||
function(e) {
|
||||
if (e.success) {
|
||||
self.submitSuccess(e);
|
||||
} else {
|
||||
self.submitFailure(e.message, e.header);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
//saving a partial view
|
||||
var actionName = this._opts.editorType === "PartialViewMacro" ? "SavePartialViewMacro" : "SavePartialView";
|
||||
|
||||
$.post(self._opts.restServiceLocation + actionName,
|
||||
JSON.stringify({
|
||||
filename: this._opts.nameTxtBox.val(),
|
||||
oldName: this._opts.originalFileName,
|
||||
contents: codeVal
|
||||
}),
|
||||
function(e) {
|
||||
if (e.success) {
|
||||
self.submitSuccess(e);
|
||||
} else {
|
||||
self.submitFailure(e.message, e.header);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
submitSuccess: function (args) {
|
||||
|
||||
var msg = args.message;
|
||||
var header = args.header;
|
||||
var path = this._opts.treeSyncPath;
|
||||
var pathChanged = false;
|
||||
if (args.path) {
|
||||
if (path != args.path) {
|
||||
pathChanged = true;
|
||||
}
|
||||
path = args.path;
|
||||
}
|
||||
if (args.contents) {
|
||||
UmbEditor.SetCode(args.contents);
|
||||
} else if (!this.IsSimpleEditor) {
|
||||
// Restore focuse to text region. SetCode also does this.
|
||||
UmbEditor._editor.focus();
|
||||
}
|
||||
|
||||
UmbClientMgr.mainTree().setActiveTreeType(this._opts.currentTreeType);
|
||||
|
||||
if (this._opts.editorType == "Template") {
|
||||
|
||||
var alias = args.alias;
|
||||
this._opts.aliasTxtBox.val(alias);
|
||||
|
||||
top.UmbSpeechBubble.ShowMessage('save', header, msg);
|
||||
|
||||
//templates are different because they are ID based, whereas view files are file based without a static id
|
||||
|
||||
if (pathChanged) {
|
||||
UmbClientMgr.mainTree().moveNode(this._opts.templateId, path);
|
||||
this._opts.treeSyncPath = path;
|
||||
}
|
||||
else {
|
||||
UmbClientMgr.mainTree().syncTree(path, true);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
var newFilePath = this._opts.nameTxtBox.val();
|
||||
|
||||
|
||||
function trimStart(str, trim) {
|
||||
if (str.startsWith(trim)) {
|
||||
return str.substring(trim.length);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
//if the filename changes, we need to redirect since the file name is used in the url
|
||||
if (this._opts.originalFileName != newFilePath) {
|
||||
var queryParts = trimStart(window.location.search, "?").split('&');
|
||||
var notFileParts = [];
|
||||
for (var i = 0; i < queryParts.length; i++) {
|
||||
if (queryParts[i].substr(0, "file=".length) != "file=") {
|
||||
notFileParts.push(queryParts[i]);
|
||||
}
|
||||
}
|
||||
var newLocation = window.location.pathname + "?" + notFileParts.join("&") + "&file=" + newFilePath;
|
||||
|
||||
UmbClientMgr.contentFrame(newLocation);
|
||||
|
||||
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
|
||||
top.UmbSpeechBubble.ShowMessage('save', header, msg);
|
||||
}
|
||||
else {
|
||||
|
||||
top.UmbSpeechBubble.ShowMessage('save', header, msg);
|
||||
|
||||
if (args && args.name) {
|
||||
this._opts.originalFileName = args.name;
|
||||
}
|
||||
if (args && args.path) {
|
||||
this._opts.treeSyncPath = args.path;
|
||||
}
|
||||
|
||||
UmbClientMgr.mainTree().syncTree(path, true, null, newFilePath.split("/")[1]);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
submitFailure: function (err, header) {
|
||||
top.UmbSpeechBubble.ShowMessage('error', header, err);
|
||||
},
|
||||
|
||||
changeMasterPageFile: function ( ) {
|
||||
//var editor = document.getElementById(this._opts.sourceEditorId);
|
||||
var templateDropDown = this._opts.masterPageDropDown.get(0);
|
||||
var templateCode = UmbClientMgr.contentFrame().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");
|
||||
}
|
||||
}
|
||||
|
||||
UmbClientMgr.contentFrame().UmbEditor.SetCode(templateCode);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Set defaults for jQuery ajax calls.
|
||||
$.ajaxSetup({
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8'
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,14 @@
|
||||
#errorDiv
|
||||
{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#errorDiv a
|
||||
{
|
||||
float: right;
|
||||
}
|
||||
|
||||
.propertyItemheader
|
||||
{
|
||||
width: 200px !important;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
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 (event) {
|
||||
event.preventDefault();
|
||||
self.doSubmit();
|
||||
});
|
||||
},
|
||||
|
||||
doSubmit: function () {
|
||||
var self = this;
|
||||
|
||||
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',"<pre>" + t + "</pre>");
|
||||
}
|
||||
|
||||
var newFilePath = this._opts.nameTxtBox.val();
|
||||
|
||||
//if the filename changes, we need to redirect since the file name is used in the url
|
||||
if (this._opts.originalFileName != newFilePath) {
|
||||
var newLocation = window.location.pathname + "?" + "&file=" + newFilePath;
|
||||
|
||||
UmbClientMgr.contentFrame(newLocation);
|
||||
|
||||
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
|
||||
top.UmbSpeechBubble.ShowMessage('save', 'XSLT file saved', '');
|
||||
}
|
||||
else {
|
||||
|
||||
top.UmbSpeechBubble.ShowMessage('save', 'XSLT file saved', '');
|
||||
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) {
|
||||
alert(t);
|
||||
top.UmbSpeechBubble.ShowMessage('warning', 'XSLT file could not be saved', '');
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user