From a72d80e64603d6af69b88fbbc2bfb810c4e2f072 Mon Sep 17 00:00:00 2001 From: Shandem Date: Wed, 3 Mar 2010 15:19:51 +0000 Subject: [PATCH] Minor fixes with tree pickers and support for Canvas. Removal of AjaxControlToolkit from Canvas and custom non-used extenders. Refactored Canvas with new modal window lib, better jQuery and browser support. Minor CSS fixees. [TFS Changeset #64405] --- .../TreePicker/BaseTreePicker.js | 12 +- .../config/ClientDependency.config | 2 +- .../presentation/umbraco.presentation.csproj | 6 - .../umbraco/LiveEditing/Css/LiveEditing.css | 60 ++-- .../Modules/CreateModule/CreateModule.cs | 75 +++-- .../Modules/DeleteModule/DeleteModule.cs | 70 ++-- .../Modules/ItemEditing/ItemEditing.js | 313 ++++++++---------- .../ItemEditing/LiveEditingItemRenderer.cs | 7 +- .../Modules/MacroModule/MacroModule.cs | 231 ++++++------- .../UnpublishModule/UnpublishModule.cs | 80 ++--- .../Extenders/CustomDragDropBehavior.js | 312 ----------------- .../Extenders/CustomDragDropDesigner.cs | 8 - .../Extenders/CustomDragDropExtender.cs | 78 ----- .../Extenders/CustomFloatingBehavior.js | 171 ---------- .../CustomFloatingBehaviorDesigner.cs | 14 - .../CustomFloatingBehaviorExtender.cs | 31 -- .../presentation/umbraco/dialogs/create.aspx | 2 +- .../umbraco/dialogs/mediaPicker.aspx | 2 +- .../umbraco/dialogs/moveOrCopy.aspx | 2 +- .../umbraco_client/Tree/UmbracoTree.js | 2 +- .../umbraco_client/modal/modal.js | 150 ++++++--- .../umbraco_client/modal/style.css | 47 +-- 22 files changed, 513 insertions(+), 1162 deletions(-) delete mode 100644 umbraco/presentation/umbraco/controls/Extenders/CustomDragDropBehavior.js delete mode 100644 umbraco/presentation/umbraco/controls/Extenders/CustomDragDropDesigner.cs delete mode 100644 umbraco/presentation/umbraco/controls/Extenders/CustomDragDropExtender.cs delete mode 100644 umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehavior.js delete mode 100644 umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorDesigner.cs delete mode 100644 umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorExtender.cs diff --git a/components/umbraco.controls/TreePicker/BaseTreePicker.js b/components/umbraco.controls/TreePicker/BaseTreePicker.js index c4e30ddff0..2992bfe471 100644 --- a/components/umbraco.controls/TreePicker/BaseTreePicker.js +++ b/components/umbraco.controls/TreePicker/BaseTreePicker.js @@ -19,19 +19,9 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); return $("#" + this._itemIdValueClientID).val(); }, - LaunchPicker: function(e) { + LaunchPicker: function() { var _this = this; UmbClientMgr.openModalWindow(this._itemPickerUrl, this._label, this._showHeader, this._width, this._height, 30, 0, ['#cancelbutton'], function(e) { _this.SaveSelection(e); }); - - var aBetterEventObject = jQuery.Event(e); - // Now you can do what you want: (Cross-browser) - aBetterEventObject.preventDefault() - aBetterEventObject.isDefaultPrevented() - aBetterEventObject.stopPropagation() - aBetterEventObject.isPropagationStopped() - aBetterEventObject.stopImmediatePropagation() - aBetterEventObject.isImmediatePropagationStopped() - return false; }, SaveSelection: function(e) { diff --git a/umbraco/presentation/config/ClientDependency.config b/umbraco/presentation/config/ClientDependency.config index f0fd979c11..fb4fb427de 100644 --- a/umbraco/presentation/config/ClientDependency.config +++ b/umbraco/presentation/config/ClientDependency.config @@ -1,4 +1,4 @@ - + diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index 6f37f3c795..0e9546a8df 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -447,10 +447,6 @@ ContentTypeControlNew.ascx - - - - GenericProperty.ascx ASPXCodeBehind @@ -1486,8 +1482,6 @@ - - diff --git a/umbraco/presentation/umbraco/LiveEditing/Css/LiveEditing.css b/umbraco/presentation/umbraco/LiveEditing/Css/LiveEditing.css index d847c6dbcd..63e8878e65 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Css/LiveEditing.css +++ b/umbraco/presentation/umbraco/LiveEditing/Css/LiveEditing.css @@ -184,47 +184,33 @@ html { /****************************************************************/ -.modalBackground { - background-color:Gray !important; - filter:alpha(opacity=70) !important; - opacity:0.7 !important; -} - -.modal { - background-color: #fff !important; - border:5px solid #CAC9C9 !important; - font-family:Arial, Verdana !important; - font-size: medium !important; - padding:0px !important; - width:500px !important; - min-height: 250px !important; - font-size: 11px !Important; -} - -.modaltitle { - padding: 0px !important; - margin: 0px !important; - height: 14px !important; - width: 493px !important; - background-image: url(../../../umbraco_client/modal/modalGradiant.gif) !important; - color: #378080 !important; - border-bottom: 1px solid #CCCCCC !Important; -} - -.modalcontent { - padding: 5px !important; -} - -.modal h1 { +.umbModalBox h1 +{ font-size: larger !important; } -.modal h2 { +.umbModalBox h2 +{ font-size: medium !important; } -.modalcontent label{padding-bottom: 2px !Important; display: block !Important; color: #999 !Important; } - -.modal p { - font-size: small !important; +.umbModalBox label +{ + padding-bottom: 2px !Important; + display: block !Important; + color: #666 !Important; + font-family:Trebuchet MS,Lucida Grande,verdana,arial ! important; } + +.umbModalBox p +{ + font-size: 12px !important; + font-family:Trebuchet MS,Lucida Grande,verdana,arial ! important; + color:Black ! important; + margin-bottom:5px; +} + +.umbModalBox p select +{ + margin-bottom:10px ! important; +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs index 9cfa7ee286..19d34dc7a3 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs @@ -1,7 +1,6 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; -//using AjaxControlToolkit; using umbraco.cms.businesslogic.web; using umbraco.presentation.LiveEditing.Controls; using Content = umbraco.cms.businesslogic.Content; @@ -11,20 +10,19 @@ using umbraco.IO; namespace umbraco.presentation.LiveEditing.Modules.CreateModule { [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/CreateModule/CreateModule.js", "UmbracoRoot")] + [ClientDependency(200, ClientDependencyType.Javascript, "modal/modal.js", "UmbracoClient")] + [ClientDependency(200, ClientDependencyType.Css, "modal/style.css", "UmbracoClient")] public class CreateModule : BaseModule { - //protected const string CreateModuleScriptFile = "{0}/LiveEditing/Modules/CreateModule/CreateModule.js"; - protected ImageButton m_CreateButton = new ImageButton(); - protected Panel m_CreateModal = new Panel(); - //protected ModalPopupExtender m_CreateModalExtender = new ModalPopupExtender(); + protected Panel m_CreateModal; - protected TextBox m_NameTextBox = new TextBox(); - protected DropDownList m_AllowedDocTypesDropdown = new DropDownList(); + protected TextBox m_NameTextBox; + protected DropDownList m_AllowedDocTypesDropdown; - protected Button m_ConfirmCreateButton = new Button(); - protected Button m_CancelCreateButton = new Button(); + protected Button m_ConfirmCreateButton; + protected Button m_CancelCreateButton; public CreateModule(LiveEditingManager manager) : base(manager) @@ -40,25 +38,25 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule { base.CreateChildControls(); - Controls.Add(m_CreateButton); - m_CreateButton.ID = "LeCreateButton"; - m_CreateButton.CssClass = "button"; - m_CreateButton.ToolTip = "Create"; - m_CreateButton.ImageUrl = String.Format("{0}/LiveEditing/Modules/CreateModule/create.png", SystemDirectories.Umbraco); - m_CreateButton.Visible = UmbracoContext.Current.HasPermission(ActionNew.Instance.Letter); + m_NameTextBox = new TextBox(); + m_NameTextBox.ID = "NewContentName"; - Controls.Add(m_CreateModal); + m_AllowedDocTypesDropdown = new DropDownList(); + m_AllowedDocTypesDropdown.ID = "AllowedDocTypes"; + + m_ConfirmCreateButton = new Button(); + m_ConfirmCreateButton.ID = "ConfirmCreateButton"; + + m_CancelCreateButton = new Button(); + m_CancelCreateButton.ID = "CancelCreateButton"; + + m_CreateModal = new Panel(); m_CreateModal.ID = "LeCreateModal"; - m_CreateModal.CssClass = "modal"; - m_CreateModal.Width = 300; - m_CreateModal.Attributes.Add("Style", "display: none"); + m_CreateModal.Attributes.Add("style", "display: none"); - m_CreateModal.Controls.Add(new LiteralControl("
Create Page
")); - m_CreateModal.Controls.Add(new LiteralControl("
")); - - m_CreateModal.Controls.Add(new LiteralControl("

")); + m_CreateModal.Controls.Add(new LiteralControl("

")); m_CreateModal.Controls.Add(m_NameTextBox); - m_CreateModal.Controls.Add(new LiteralControl("

")); + m_CreateModal.Controls.Add(new LiteralControl("

")); m_CreateModal.Controls.Add(m_AllowedDocTypesDropdown); FillAllowedDoctypes(); @@ -68,25 +66,26 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule m_CreateModal.Controls.Add(new LiteralControl(" ")); m_CreateModal.Controls.Add(m_CancelCreateButton); - m_ConfirmCreateButton.Text = "Ok"; + m_ConfirmCreateButton.Text = ui.GetText("ok"); m_ConfirmCreateButton.ID = "LeCreateModalConfirm"; m_ConfirmCreateButton.CssClass = "modalbuton"; + m_ConfirmCreateButton.OnClientClick = "CreateModuleOk();"; - m_CancelCreateButton.Text = "Cancel"; + m_CancelCreateButton.Text = ui.GetText("cancel"); m_CancelCreateButton.CssClass = "modalbuton"; - //Controls.Add(m_CreateModalExtender); - //m_CreateModalExtender.ID = "ModalCreate"; - //m_CreateModalExtender.TargetControlID = m_CreateButton.ID; - //m_CreateModalExtender.PopupControlID = m_CreateModal.ID; - //m_CreateModalExtender.BackgroundCssClass = "modalBackground"; - //m_CreateModalExtender.OkControlID = m_ConfirmCreateButton.ID; - //m_CreateModalExtender.CancelControlID = m_CancelCreateButton.ID; - //m_CreateModalExtender.OnOkScript = string.Format("CreateModuleOk()"); - m_CreateModal.Controls.Add(new LiteralControl("

")); - //ScriptManager.RegisterClientScriptInclude(this, GetType(), CreateModuleScriptFile, String.Format(CreateModuleScriptFile, umbraco.IO.SystemDirectories.Umbraco)); + Controls.Add(m_CreateModal); + + m_CreateButton.ID = "LeCreateButton"; + m_CreateButton.CssClass = "button"; + m_CreateButton.ToolTip = ui.GetText("create"); + m_CreateButton.ImageUrl = String.Format("{0}/LiveEditing/Modules/CreateModule/create.png", SystemDirectories.Umbraco); + m_CreateButton.Visible = UmbracoContext.Current.HasPermission(ActionNew.Instance.Letter); + m_CreateButton.OnClientClick = "jQuery('#" + m_CreateModal.ClientID + @"').ModalWindowShow('" + ui.GetText("create") + "',true,300,200,50,0, ['.modalbuton'], null);return false;"; + + Controls.Add(m_CreateButton); } private void FillAllowedDoctypes() @@ -128,13 +127,13 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule { switch (e.Type) { - case "createcontent": + case "createcontent": int userid = BasePages.UmbracoEnsuredPage.GetUserId(BasePages.UmbracoEnsuredPage.umbracoUserContextID); DocumentType typeToCreate = new DocumentType(Convert.ToInt32(m_AllowedDocTypesDropdown.SelectedValue)); Document newDoc = Document.MakeNew(m_NameTextBox.Text, typeToCreate, new global::umbraco.BusinessLogic.User(userid), (int)UmbracoContext.Current.PageId); newDoc.Publish(new global::umbraco.BusinessLogic.User(userid)); library.PublishSingleNode(newDoc.Id); - Page.Response.Redirect(library.NiceUrl(newDoc.Id)); + Page.Response.Redirect(library.NiceUrl(newDoc.Id), false); break; } } diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs index f00053a636..5ca76c12d7 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs @@ -1,7 +1,6 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; -using AjaxControlToolkit; using umbraco.cms.businesslogic.web; using umbraco.presentation.LiveEditing.Controls; using umbraco.BusinessLogic.Actions; @@ -9,24 +8,21 @@ using ClientDependency.Core; using umbraco.IO; namespace umbraco.presentation.LiveEditing.Modules.DeleteModule { - [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/DeleteModule/DeleteModule.js", "UmbracoRoot")] + [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/DeleteModule/DeleteModule.js", "UmbracoRoot")] public class DeleteModule : BaseModule { - //protected const string DeleteModuleScriptFile = "{0}/LiveEditing/Modules/DeleteModule/DeleteModule.js"; + protected ImageButton m_DeleteButton; - protected ImageButton m_DeleteButton = new ImageButton(); + protected Panel m_DeleteModal; - protected Panel m_DeleteModal = new Panel(); - protected ModalPopupExtender m_DeleteModalExtender = new ModalPopupExtender(); - - protected Button m_ConfirmDeleteButton = new Button(); - protected Button m_CancelDeleteButton = new Button(); + protected Button m_ConfirmDeleteButton; + protected Button m_CancelDeleteButton; public DeleteModule(LiveEditingManager manager) : base(manager) { } - - protected override void OnInit(EventArgs e) + + protected override void OnInit(EventArgs e) { base.OnInit(e); EnsureChildControls(); @@ -36,48 +32,40 @@ namespace umbraco.presentation.LiveEditing.Modules.DeleteModule { base.CreateChildControls(); - Controls.Add(m_DeleteButton); - m_DeleteButton.ID = "LeDeleteButton"; - m_DeleteButton.CssClass = "button"; - m_DeleteButton.ToolTip = "Delete"; - m_DeleteButton.ImageUrl = String.Format("{0}/LiveEditing/Modules/DeleteModule/delete.png", SystemDirectories.Umbraco); - m_DeleteButton.Visible = UmbracoContext.Current.HasPermission(ActionDelete.Instance.Letter); - - Controls.Add(m_DeleteModal); + m_DeleteModal = new Panel(); m_DeleteModal.ID = "LeDeleteModal"; - m_DeleteModal.CssClass = "modal"; - m_DeleteModal.Width = 300; m_DeleteModal.Attributes.Add("Style", "display: none"); - m_DeleteModal.Controls.Add(new LiteralControl("
Delete Page
")); - m_DeleteModal.Controls.Add(new LiteralControl("

Are you sure you want to delete this page?

")); + m_ConfirmDeleteButton = new Button(); + m_ConfirmDeleteButton.Text = ui.GetText("ok"); + m_ConfirmDeleteButton.ID = "LeDeleteModalConfirm"; + m_ConfirmDeleteButton.CssClass = "modalbuton"; + m_ConfirmDeleteButton.OnClientClick = "DeleteModuleOk();"; + m_CancelDeleteButton = new Button(); + m_CancelDeleteButton.ID = "CancelDelete"; + m_CancelDeleteButton.Text = ui.GetText("cancel"); + m_CancelDeleteButton.CssClass = "modalbuton"; + + m_DeleteModal.Controls.Add(new LiteralControl("

" + ui.GetText("confirmdelete") + "

")); m_DeleteModal.Controls.Add(m_ConfirmDeleteButton); m_DeleteModal.Controls.Add(new LiteralControl(" ")); m_DeleteModal.Controls.Add(m_CancelDeleteButton); - m_ConfirmDeleteButton.Text = "Ok"; - m_ConfirmDeleteButton.ID = "LeDeleteModalConfirm"; - m_ConfirmDeleteButton.CssClass = "modalbuton"; - - m_CancelDeleteButton.Text = "Cancel"; - m_CancelDeleteButton.CssClass = "modalbuton"; - - Controls.Add(m_DeleteModalExtender); - m_DeleteModalExtender.ID = "ModalDelete"; - m_DeleteModalExtender.TargetControlID = m_DeleteButton.ID; - m_DeleteModalExtender.PopupControlID = m_DeleteModal.ID; - m_DeleteModalExtender.BackgroundCssClass = "modalBackground"; - m_DeleteModalExtender.OkControlID = m_ConfirmDeleteButton.ID; - m_DeleteModalExtender.CancelControlID = m_CancelDeleteButton.ID; - m_DeleteModalExtender.OnOkScript = string.Format("DeleteModuleOk()"); + Controls.Add(m_DeleteModal); - m_DeleteModal.Controls.Add(new LiteralControl("
")); + m_DeleteButton = new ImageButton(); + m_DeleteButton.ID = "LeDeleteButton"; + m_DeleteButton.CssClass = "button"; + m_DeleteButton.ToolTip = ui.GetText("delete"); ; + m_DeleteButton.ImageUrl = String.Format("{0}/LiveEditing/Modules/DeleteModule/delete.png", SystemDirectories.Umbraco); + m_DeleteButton.Visible = UmbracoContext.Current.HasPermission(ActionDelete.Instance.Letter); + m_DeleteButton.OnClientClick = "jQuery('#" + m_DeleteModal.ClientID + @"').ModalWindowShow('" + ui.GetText("delete") + "',true,300,200,50,0, ['.modalbuton'], null);return false;"; - //ScriptManager.RegisterClientScriptInclude(this, GetType(), DeleteModuleScriptFile, String.Format(DeleteModuleScriptFile, umbraco.IO.SystemDirectories.Umbraco)); + Controls.Add(m_DeleteButton); } - + /// /// Handles the MessageReceived event of the manager. /// diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditing.js b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditing.js index 0a0affbd49..88b9b8501f 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditing.js +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditing.js @@ -14,12 +14,14 @@ umbraco.presentation.LiveEditing.ItemEditing = function() { this._editControl = null; this._submitControl = null; - var itemEditingInternal = this; + var _this = this; Sys.Debug.trace("Constructor, before init load"); - if (jQuery.browser.msie && !this._inited) { - itemEditingInternal.init(); + if (!this._inited) { + _this.init(); } - Sys.Application.add_load(function() { itemEditingInternal.init() }); + Sys.Application.add_load(function() { + _this.init(); + }); Sys.Debug.trace("Constructor, after init load"); } @@ -35,9 +37,9 @@ umbraco.presentation.LiveEditing.ItemEditing.prototype = { this.itemsEnable(); - - LiveEditingToolbar.add_save(function(sender, args) { ItemEditing.delaySaveWhenEditing(args, "save"); }); - LiveEditingToolbar.add_saveAndPublish(function(sender, args) { ItemEditing.delaySaveWhenEditing(args, "saveAndPublish"); }); + var _this = this; + LiveEditingToolbar.add_save(function(sender, args) { _this.delaySaveWhenEditing(args, "save"); }); + LiveEditingToolbar.add_saveAndPublish(function(sender, args) { _this.delaySaveWhenEditing(args, "saveAndPublish"); }); this._inited = true; Sys.Debug.trace("Live Editing - ItemEditing: Ready."); @@ -55,22 +57,22 @@ umbraco.presentation.LiveEditing.ItemEditing.prototype = { this._activeItem = this._items[itemId]; Sys.Debug.assert(this._activeItem != null, "Live Editing - ItemEditing: Could not find item with ID " + itemId + "."); - this._editControl = this.getElementsByTagName("umbraco:control")[0]; - Sys.Debug.assert(this._editControl != null, "Live Editing - ItemEditing: Could not find the editor control."); - this._activeItem.fadeIn(); - this.moveChildControls(this._editControl, this._activeItem); + this._editControl = this.getElementsByTagName("umbraco:control"); + Sys.Debug.assert(this._editControl.length > 0, "Live Editing - ItemEditing: Could not find the editor control."); + //this._activeItem.jItem.fadeIn(); + this.moveChildControls(this._editControl, this._activeItem.jItem); // Only elements that are currently present, can cause item editing to stop. // This enables transparent use of dynamically created elements (such as context/dropdown menus) // as clicks on those elements will not trigger the stop edit signal. - jQuery("*").each(function() { this._canStopEditing = true; }); + jQuery("*").each(function() { $(this).data("canStopEditing", true); }); // raise event var handler = this.get_events().getHandler("startEdit"); if (handler) handler(this, Sys.EventArgs.Empty); - this.ignoreChildClicks(this._activeItem); + this.ignoreChildClicks(this._activeItem.jItem); LiveEditingToolbar.setDirty(true); }, @@ -90,7 +92,7 @@ umbraco.presentation.LiveEditing.ItemEditing.prototype = { this._submitControl.click(); // hide control - this._activeItem.fadeOut(); + //this._activeItem.jItem.fadeOut(); this._activeItem = null; this._submitControl = null; this._editControl = null; @@ -126,12 +128,24 @@ umbraco.presentation.LiveEditing.ItemEditing.prototype = { var f = function() { Sys.Application.remove_load(f); setTimeout(function() { + Sys.Debug.trace("Live Editing - Delayed Saving Changes to server"); UmbracoCommunicator.SendClientMessage(type, ""); }, 100); } Sys.Application.add_load(f); })(); } + else { + Sys.Debug.trace("Live Editing - Saving Changes to server"); + if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) { + UmbracoCommunicator.SendClientMessage(type, ""); + } + else { + Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { + UmbracoCommunicator.SendClientMessage(type, ""); + }); + } + } }, // Enables Live Editing of items. @@ -140,84 +154,60 @@ umbraco.presentation.LiveEditing.ItemEditing.prototype = { Sys.Debug.trace(" Found " + items.length + " editable Umbraco item(s)."); // enhance items with edit functionality - for (var i = 0; i < items.length; i++) { - var item = items[i]; - this._items[item.getAttribute("itemId")] = item; - this.itemsAddFunctionality(item); - Sys.Debug.trace(" " + (i + 1) + ". " + item.toString() + " is Live Editing enabled."); - } + var _this = this; + var i = 0; + items.each(function() { + var item = new umbraco.presentation.LiveEditing.activeItem($(this)); + _this._items[item.itemId] = item; + Sys.Debug.trace(" " + (++i) + ". " + item.toString() + " is Live Editing enabled."); + }); + // disable hyperlinks to make them clickable for Live Editing + this.disableHyperlinks(); // add "stop editing" handler when clicking outside the item - + var _this = this; jQuery(document).mousedown(function(event) { - // the _canStopEditing property is set in startEdit - if (ItemEditing._activeItem != null && event.target._canStopEditing) { - if (!ItemEditing._activeItem.clicked) - ItemEditing.stopEdit(); + Sys.Debug.trace("DOCUMENT CLICKED"); + // the canStopEditing property is set in startEdit + if (_this._activeItem != null && $(event.target).data("canStopEditing")) { + if (!_this._activeItem.clicked) + _this.stopEdit(); else - ItemEditing._activeItem.clicked = false; + _this._activeItem.clicked = false; } }); jQuery("#LiveEditingToolbar").mousedown(function() { - if (ItemEditing._activeItem != null) - ItemEditing._activeItem.clicked = true; + Sys.Debug.trace("TOOLBAR CLICKED"); + if (_this._activeItem != null) + _this._activeItem.clicked = true; }); }, - // Adds Javascript functionality to an item. - itemsAddFunctionality: function(item) { - // add attributes to item - item.itemId = item.getAttribute("itemId"); - item.nodeId = item.getAttribute("nodeId"); - item.fieldName = item.getAttribute("name"); - - Sys.Debug.assert(item.itemId != null && item.nodeId != null && item.fieldName != null, - "Live Editing - ItemEditing: Necessary umbraco:iteminfo attributes not present."); - - // add functions to item - var itemPrototype = umbraco.presentation.LiveEditing.ItemFunctions.prototype; - item.toString = itemPrototype.toString; - item.activate = itemPrototype.activate; - item.fadeIn = itemPrototype.fadeIn; - item.fadeOut = itemPrototype.fadeOut; - - // register events - // note: this doesn't work in IE, there it is set server-side as an attribute - item.onclick = umbraco.presentation.LiveEditing.ItemFunctions.prototype.click; - - // disable hyperlinks to make them clickable for Live Editing - this.disableHyperlinks(item); - }, - // Update items that have changed. updateItems: function() { var itemUpdates = this.getElementsByTagName("umbraco:itemupdate"); Sys.Debug.trace("Live Editing - ItemEditing: " + itemUpdates.length + " item update(s)."); - // find all item updates - for (var i = 0; i < itemUpdates.length; i++) { - var itemUpdate = itemUpdates[i]; - var itemId = itemUpdate.getAttribute("itemId"); - var item = this._items[itemId]; + var _this = this; + itemUpdates.each(function() { + var itemUpdate = $(this); + var itemId = itemUpdate.attr("itemId"); + var item = _this._items[itemId]; if (item != null) { Sys.Debug.trace(" Updating " + item.toString() + "."); // remove old children and add updates ones - while (item.firstChild != null) - item.removeChild(item.firstChild); - while (itemUpdate.firstChild != null) - item.appendChild(itemUpdate.firstChild); - item.fadeIn(); + _this.moveChildControls(itemUpdate, item.jItem); + //item.jItem.fadeIn(); // disable hyperlinks to make them clickable for Live Editing - this.disableHyperlinks(item); + _this.disableHyperlinks(); } else { - while (itemUpdate.firstChild != null) - itemUpdate.removeChild(itemUpdate.firstChild); + itemUpdate.html(""); } - } + }); }, // Update controls that have changed. @@ -227,139 +217,124 @@ umbraco.presentation.LiveEditing.ItemEditing.prototype = { Sys.Debug.trace("Live Editing - ItemEditing: " + controlUpdates.length + " control update(s)."); if (controlUpdates.length == 1) { - if (this._activeItem != null && controlUpdates[0].firstChild != null) { + if (this._activeItem != null && controlUpdates.children().length > 0) { Sys.Debug.trace("Live Editing - ItemEditing: updating edit control."); - this.moveChildControls(controlUpdates[0], this._activeItem); - this.ignoreChildClicks(this._activeItem); + this.moveChildControls(controlUpdates, this._activeItem.jItem); + this.ignoreChildClicks(); } - this._submitControl = controlUpdates[0].nextSibling; - Sys.Debug.assert(this._submitControl != null, "Live Editing - ItemEditing: Submit button not found."); + this._submitControl = controlUpdates.next(); + Sys.Debug.assert(this._submitControl.length > 0, "Live Editing - ItemEditing: Submit button not found."); } }, // ignores clicks on child elements of the control - ignoreChildClicks: function(control) { - // all children set the clicked property to true on mousedown - // to avoid editing being stopped because of the body mousedown trigger - - for (var i = 0; i < this._activeItem.childNodes.length; i++) { - try { - $addHandler(ItemEditing._activeItem.childNodes[i], "mousedown", function() { - if (ItemEditing._activeItem != null) - ItemEditing._activeItem.clicked = true; - }); - } - // some items don't support the onmousedown property - catch (e) { } - } + ignoreChildClicks: function() { + var _this = this; + this._activeItem.jItem.children().mousedown(function(e) { + _this._activeItem.clicked = true; + }); }, // Moves the child controls from source into destination, overwriting existing elements. moveChildControls: function(source, dest) { - // save source childs to temp - while (dest.firstChild != null) - dest.removeChild(dest.firstChild); - // add original source fields to dest - while (source.firstChild != null) - dest.appendChild(source.firstChild); + Sys.Debug.trace("Live Editing - Moving Child Controls"); + + //remove contents in the destination + dest.html(""); + + //add the source to the destination + dest.append(source.html()); + + //remove teh contents from the source + source.html(""); + }, - // Gets a list of elements with the specified tagname. - // Works with custom namespaces in IE as well. + // Gets a list of elements with the specified tagname including namespaced ones getElementsByTagName: function(tagname) { - var elements = document.getElementsByTagName(tagname); - // if no elements are found, retry search without the namespace prefix - if (elements.length == 0 && tagname.indexOf(":") > 0) - elements = document.getElementsByTagName(tagname.substr(tagname.indexOf(":") + 1)); - return elements; + var found = jQuery("body").find("*").filter(function(index) { + if (this.nodeType != 3) { + var nn = this.nodeName.toLowerCase(); + var ftn = tagname.toLowerCase(); + var ln = (ftn.indexOf(":") > 0 ? ftn.substr(ftn.indexOf(":") + 1) : ftn); + return (nn == ftn + || (typeof this.scopeName != "undefined" && nn == ln && this.scopeName.toLowerCase() == ftn.substr(0, ftn.indexOf(":")))); + } + return false; + }); + Sys.Debug.trace("found " + found.length + " elements with selector: " + tagname); + return found; }, // Disables hyperlinks inside the specified element. - disableHyperlinks: function(element) { - var links = element.getElementsByTagName("a"); - for (var i = 0; i < links.length; i++) - links[i].onclick = function() { return false; }; + disableHyperlinks: function() { + jQuery("a").click(function() { + return false; + }); } } umbraco.presentation.LiveEditing.ItemEditing.registerClass("umbraco.presentation.LiveEditing.ItemEditing", Sys.Component); - - -/********************* Live Editing item member functions *********************/ - -// The ItemFunctions class contains a set of functions that will be added to umbraco:item elements. -// This class will not be initialized. -umbraco.presentation.LiveEditing.ItemFunctions = function() { }; - -umbraco.presentation.LiveEditing.ItemFunctions.prototype = { - - // Returns a textual representation of an item. - toString: function() { - return "Item " + this.itemId + " (node " + this.nodeId + ": " + this.fieldName + ")"; - }, - - // Activates an item for editing. - activate: function() { - ItemEditing._items[this.itemId] = this; - if (this != ItemEditing._activeItem) { - Sys.Debug.trace("Live Editing - ItemEditing: " + this.toString() + " was activated."); - if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) { - UmbracoCommunicator.SendClientMessage("edititem", this.itemId); +//an object to store the information for the active item +umbraco.presentation.LiveEditing.activeItem = function(item) { + //error checking + if (item != null && item.length != 1) { + return null; + } + //create the object with values, wire up events and return it + var obj = { + jItem: item, + nodeId: item.attr("nodeId"), + fieldName: item.attr("name"), + itemId: item.attr("itemId"), + clicked: false, + toString: function() { + return "Item " + this.itemId + " (node " + this.nodeId + ": " + this.fieldName + ")"; + }, + // Activates an item for editing. + activate: function() { + ItemEditing._items[this.itemId] = this; + if (this != ItemEditing._activeItem) { + Sys.Debug.trace("Live Editing - ItemEditing: " + this.toString() + " was activated."); + if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) { + UmbracoCommunicator.SendClientMessage("edititem", this.itemId); + } + else { + var itemId = this.itemId; + Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { + if (itemId != 0) { + UmbracoCommunicator.SendClientMessage("edititem", itemId); + itemId = 0; + } + }); + } + //this.jItem.fadeOut(); + } + }, + // Item click handler. + onClick: function(e) { + if (ItemEditing._activeItem != null && ItemEditing._activeItem.itemId == this.itemId) { + Sys.Debug.trace("Live Editing - ItemEditing: " + this.toString() + " click ignored because it is already active."); } else { - var itemId = this.itemId; - Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { - if (itemId != 0) { - UmbracoCommunicator.SendClientMessage("edititem", itemId); - itemId = 0; - } - }); - } - this.fadeOut(); - } - }, - - // Item click handler. - // Note: in IE, this is called through the onclick attribute. - click: function(e) { - if (ItemEditing._activeItem != null && ItemEditing._activeItem.itemId == this.itemId) { - Sys.Debug.trace("Live Editing - ItemEditing: " + this.toString() + " click ignored because it is already active."); - } - else { - Sys.Debug.trace("Live Editing - ItemEditing: " + this.toString() + " was clicked."); - if (e) { + Sys.Debug.trace("Live Editing - ItemEditing: " + this.toString() + " was clicked."); e.stopPropagation(); // disable click event propagation to parent elements this.activate(); } - else { - // Internet Explorer specific code - window.event.cancelBubble = true; // disable click event propagation to parent elements - // find the iteminfo self-or-ancestor, - // and restore the functionality that magically disappeared - var element = window.event.srcElement; - while (element.tagName != 'iteminfo') - element = element.parentElement; - ItemEditing.itemsAddFunctionality(element); - element.activate(); - } } - }, - - // fades in the item - fadeIn: function() { - if (!jQuery.browser.msie) - jQuery(this).stop().fadeTo(1, 0.0).fadeTo(500, 1); - }, - - // fades out the item - fadeOut: function() { - if (!jQuery.browser.msie) - jQuery(this).stop().fadeTo(1, 1.0).fadeTo(500, 1); } + + //keep the scope on the click event method call + obj.jItem.click(function(e) { + obj.onClick.call(obj, e); + }); + + return obj; } + // global instance of the ItemEditing class function initializeGlobalItemEditing() { ItemEditing = new umbraco.presentation.LiveEditing.ItemEditing(); diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/LiveEditingItemRenderer.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/LiveEditingItemRenderer.cs index d31a18fcc9..18df554e97 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/LiveEditingItemRenderer.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/LiveEditingItemRenderer.cs @@ -94,12 +94,7 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing } catch{} - // hook the click event with by attribute in IE, - // as this is the only way to make it work using custom tags - if (item.Page.Request.Browser.IsBrowser("IE")) - { - writer.AddAttribute("onclick", "umbraco.presentation.LiveEditing.ItemFunctions.prototype.click()"); - } + writer.RenderBeginTag(LiveEditingMarkerTag); } diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs index fa8b78c15d..56a4875793 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Web.UI; using System.Web.UI.WebControls; -using AjaxControlToolkit; using umbraco.controls; -using umbraco.presentation.controls.Extenders; using umbraco.presentation.LiveEditing.Controls; using umbraco.presentation.LiveEditing.Updates; using umbraco.presentation.templateControls; @@ -13,28 +11,33 @@ using ClientDependency.Core; using umbraco.IO; namespace umbraco.presentation.LiveEditing.Modules.MacroEditing { - [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/MacroModule/MacroModule.js", "UmbracoRoot")] + + /// + /// + /// THIS MODULE HASN'T YET EVER BEEN INCLUDED IN UMBRACO. + /// + /// SINCE AJAXCONTROLTOOLKIT IS REMOVED, THIS CLASS WILL NEED TO BE REFACTORED LIKE THE + /// OTHER MODULES. + /// + /// WHATEVER FUNCTIONALITY THAT WAS INTENDED FOR THIS MODULE WILL NEED TO BE FIGURED OUT + /// BASED ON THE COMMENTED CODE ALREADY WRITTEN. + /// + /// + [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/MacroModule/MacroModule.js", "UmbracoRoot")] public class MacroModule : BaseModule { - //protected const string MacroModuleScriptFile = "{0}/LiveEditing/Modules/MacroModule/MacroModule.js"; - private ImageButton m_MacroButton = new ImageButton(); - - private DropDownList m_MacroDropDown = new DropDownList(); - private DropDownList m_ContainerDropDown = new DropDownList(); - private List containers = new List(); - private Button m_AddMacroButton = new Button(); - - private Panel m_MacroModal = new Panel(); - - private Panel m_AddMacroStep2 = new Panel(); - - private macroParameterControl m_MacroParameter = new macroParameterControl(); - - private ModalPopupExtender m_MacroModalExtender = new ModalPopupExtender(); + //private ImageButton m_MacroButton = new ImageButton(); + //private DropDownList m_MacroDropDown = new DropDownList(); + //private DropDownList m_ContainerDropDown = new DropDownList(); + //private List containers = new List(); + //private Button m_AddMacroButton = new Button(); + //private Panel m_MacroModal = new Panel(); + //private Panel m_AddMacroStep2 = new Panel(); + //private macroParameterControl m_MacroParameter = new macroParameterControl(); public MacroModule(LiveEditingManager manager) - : base (manager) + : base(manager) { } protected override void OnInit(EventArgs e) @@ -52,144 +55,124 @@ namespace umbraco.presentation.LiveEditing.Modules.MacroEditing protected override void CreateChildControls() { base.CreateChildControls(); - - Controls.Add(m_MacroButton); - m_MacroButton.ID = "LeMacroButton"; - m_MacroButton.CssClass = "button"; - m_MacroButton.ToolTip = "Insert macro"; - m_MacroButton.ImageUrl = String.Format("{0}/images/editor/insMacro.gif", SystemDirectories.Umbraco); - Controls.Add(m_MacroModal); - m_MacroModal.ID = "LeMacroModal"; - m_MacroModal.CssClass = "modal"; - m_MacroModal.Width = 500; - m_MacroModal.Attributes.Add("Style", "display: none"); + //Controls.Add(m_MacroButton); + //m_MacroButton.ID = "LeMacroButton"; + //m_MacroButton.CssClass = "button"; + //m_MacroButton.ToolTip = "Insert macro"; + //m_MacroButton.ImageUrl = String.Format("{0}/images/editor/insMacro.gif", SystemDirectories.Umbraco); - m_MacroModal.Controls.Add(new LiteralControl("
Insert macro
")); - m_MacroModal.Controls.Add(new LiteralControl("
")); + //Controls.Add(m_MacroModal); + //m_MacroModal.ID = "LeMacroModal"; + //m_MacroModal.CssClass = "modal"; + //m_MacroModal.Width = 500; + //m_MacroModal.Attributes.Add("Style", "display: none"); + + //m_MacroModal.Controls.Add(new LiteralControl("
Insert macro
")); + //m_MacroModal.Controls.Add(new LiteralControl("
")); - m_MacroModal.Controls.Add(m_MacroDropDown); - m_MacroDropDown.CssClass = "dropdown"; - m_MacroDropDown.Items.Clear(); - m_MacroDropDown.Items.Add(new ListItem("Choose macro", "0")); - foreach (UM.Macro macro in UM.Macro.GetAll()) - { - m_MacroDropDown.Items.Add(new ListItem(macro.Name, macro.Alias)); - } - m_MacroDropDown.AutoPostBack = true; - m_MacroDropDown.SelectedIndexChanged += new EventHandler(m_MacroDropDown_SelectedIndexChanged); + //m_MacroModal.Controls.Add(m_MacroDropDown); + //m_MacroDropDown.CssClass = "dropdown"; + //m_MacroDropDown.Items.Clear(); + //m_MacroDropDown.Items.Add(new ListItem("Choose macro", "0")); + //foreach (UM.Macro macro in UM.Macro.GetAll()) + //{ + // m_MacroDropDown.Items.Add(new ListItem(macro.Name, macro.Alias)); + //} + //m_MacroDropDown.AutoPostBack = true; + //m_MacroDropDown.SelectedIndexChanged += new EventHandler(m_MacroDropDown_SelectedIndexChanged); - m_MacroModal.Controls.Add(new LiteralControl("
")); + //m_MacroModal.Controls.Add(new LiteralControl("
")); - m_MacroModal.Controls.Add(m_ContainerDropDown); - m_ContainerDropDown.CssClass = "dropdown"; - m_ContainerDropDown.Items.Clear(); - m_ContainerDropDown.Items.Add(new ListItem("Choose container", "0")); - foreach (Control ctrl in Page.Controls) - { - FindMacroHolderPanels(ctrl); + //m_MacroModal.Controls.Add(m_ContainerDropDown); + //m_ContainerDropDown.CssClass = "dropdown"; + //m_ContainerDropDown.Items.Clear(); + //m_ContainerDropDown.Items.Add(new ListItem("Choose container", "0")); + //foreach (Control ctrl in Page.Controls) + //{ + // FindMacroHolderPanels(ctrl); - } + //} - m_MacroModal.Controls.Add(new LiteralControl("
")); - m_MacroModal.Controls.Add(m_AddMacroButton); - m_AddMacroButton.Text = "Add Macro"; - - m_AddMacroButton.Click += new EventHandler(m_AddMacroButton_Click); + //m_MacroModal.Controls.Add(new LiteralControl("
")); + //m_MacroModal.Controls.Add(m_AddMacroButton); + //m_AddMacroButton.Text = "Add Macro"; + + //m_AddMacroButton.Click += new EventHandler(m_AddMacroButton_Click); + //m_MacroModal.Controls.Add(new LiteralControl("
")); - Controls.Add(m_MacroModalExtender); - m_MacroModalExtender.ID = "ModalMacro"; - m_MacroModalExtender.TargetControlID = m_MacroButton.ID; - m_MacroModalExtender.PopupControlID = m_MacroModal.ID; - m_MacroModalExtender.BackgroundCssClass = "modalBackground"; - m_MacroModalExtender.OkControlID = m_AddMacroButton.ID; - m_MacroModalExtender.OnOkScript = "okAddMacro()"; - - m_MacroModal.Controls.Add(new LiteralControl("
")); - - //ScriptManager.RegisterClientScriptInclude(this, GetType(), MacroModuleScriptFile, String.Format(MacroModuleScriptFile, umbraco.IO.SystemDirectories.Umbraco)); - - } void m_MacroDropDown_SelectedIndexChanged(object sender, EventArgs e) { - m_MacroModal.Controls.Add(m_AddMacroStep2); + //m_MacroModal.Controls.Add(m_AddMacroStep2); - m_AddMacroStep2.Controls.Add(new LiteralControl("

Macro Properties

")); + //m_AddMacroStep2.Controls.Add(new LiteralControl("

Macro Properties

")); - m_MacroParameter.MacroAlias = m_MacroDropDown.SelectedValue; + //m_MacroParameter.MacroAlias = m_MacroDropDown.SelectedValue; + + //m_AddMacroStep2.Controls.Add(m_MacroParameter); - m_AddMacroStep2.Controls.Add(m_MacroParameter); - - m_MacroModalExtender.Show(); } void m_AddMacroButton_Click(object sender, EventArgs e) { - containers.ForEach(delegate(Panel p) - { - if (p.ID == m_ContainerDropDown.SelectedItem.Value) - { - Macro macrotoadd = new Macro(); - macrotoadd.Alias = m_MacroDropDown.SelectedItem.Value; + //containers.ForEach(delegate(Panel p) + //{ + // if (p.ID == m_ContainerDropDown.SelectedItem.Value) + // { + // Macro macrotoadd = new Macro(); + // macrotoadd.Alias = m_MacroDropDown.SelectedItem.Value; - p.Controls.Add(new LiteralControl(string.Format( - "
handle
", - macrotoadd.Alias + macrotoadd.ID))); - p.Controls.Add(macrotoadd); - p.Controls.Add(new LiteralControl("
")); - ((UpdatePanel)p.Parent.Parent).Update(); + // p.Controls.Add(new LiteralControl(string.Format( + // "
handle
", + // macrotoadd.Alias + macrotoadd.ID))); + // p.Controls.Add(macrotoadd); + // p.Controls.Add(new LiteralControl("
")); + // ((UpdatePanel)p.Parent.Parent).Update(); - - TemplateUpdate update = new TemplateUpdate(); - LiveEditingContext.Updates.Add(update); - } - }); + + // TemplateUpdate update = new TemplateUpdate(); + // LiveEditingContext.Updates.Add(update); + // } + //}); } private void FindMacroHolderPanels(Control ctrl) { - foreach (Control childControl in ctrl.Controls) - { + //foreach (Control childControl in ctrl.Controls) + //{ - if (childControl is Panel) - { - if (((Panel)childControl).CssClass == "macro_holder") - { - Panel holderPanel = (Panel)childControl; - containers.Add(holderPanel); - m_ContainerDropDown.Items.Add(new ListItem(childControl.ID, childControl.ID)); + // if (childControl is Panel) + // { + // if (((Panel)childControl).CssClass == "macro_holder") + // { + // Panel holderPanel = (Panel)childControl; + // containers.Add(holderPanel); + // m_ContainerDropDown.Items.Add(new ListItem(childControl.ID, childControl.ID)); - ((UpdatePanel)holderPanel.Parent.Parent).Triggers.Clear(); - AsyncPostBackTrigger apt = new AsyncPostBackTrigger(); - apt.ControlID = m_MacroButton.ID; - apt.EventName = "Click"; - ((UpdatePanel)holderPanel.Parent.Parent).Triggers.Add(apt); + // ((UpdatePanel)holderPanel.Parent.Parent).Triggers.Clear(); + // AsyncPostBackTrigger apt = new AsyncPostBackTrigger(); + // apt.ControlID = m_MacroButton.ID; + // apt.EventName = "Click"; + // ((UpdatePanel)holderPanel.Parent.Parent).Triggers.Add(apt); - childControl.Controls.Add(new LiteralControl(string.Format( - "
", - childControl.ID))); + // childControl.Controls.Add(new LiteralControl(string.Format( + // "
", + // childControl.ID))); - CustomDragDropExtender extender = new CustomDragDropExtender(); - extender.TargetControlID = childControl.ID; - extender.DragItemClass = "widget"; - extender.DragItemHandleClass = "widget_header"; - extender.DropCueID = string.Format("DropCue{0}", childControl.ID); - extender.OnClientDrop = "MacroOnDrop"; + + // } + // } - childControl.Controls.Add(extender); - } - } - - if (childControl.HasControls()) - { - FindMacroHolderPanels(childControl); - } - } + // if (childControl.HasControls()) + // { + // FindMacroHolderPanels(childControl); + // } + //} } } diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs index 95da340bbd..b65caadd59 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs @@ -1,7 +1,6 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; -using AjaxControlToolkit; using umbraco.cms.businesslogic.web; using umbraco.presentation.LiveEditing.Controls; using umbraco.BusinessLogic.Actions; @@ -9,18 +8,15 @@ using ClientDependency.Core; using umbraco.IO; namespace umbraco.presentation.LiveEditing.Modules.UnpublishModule { - [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/UnpublishModule/UnpublishModule.js", "UmbracoRoot")] + [ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/UnpublishModule/UnpublishModule.js", "UmbracoRoot")] public class UnpublishModule : BaseModule { - //protected const string UnpublishModuleScriptFile = "{0}/LiveEditing/Modules/UnpublishModule/UnpublishModule.js"; + protected ImageButton m_UnpublishButton; - protected ImageButton m_UnpublishButton = new ImageButton(); + protected Panel m_UnpublishModal; - protected Panel m_UnpublishModal = new Panel(); - protected ModalPopupExtender m_UnpublishModalExtender = new ModalPopupExtender(); - - protected Button m_ConfirmDeleteButton = new Button(); - protected Button m_CancelDeleteButton = new Button(); + protected Button m_ConfirmUnpublishButton; + protected Button m_CancelDeleteButton; /// /// Initializes a new instance of the class. @@ -34,59 +30,51 @@ namespace umbraco.presentation.LiveEditing.Modules.UnpublishModule /// Raises the event. /// /// An object that contains the event data. - protected override void OnInit(EventArgs e) + protected override void OnInit(EventArgs e) { base.OnInit(e); EnsureChildControls(); } - /// - /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. - /// + /// + /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. + /// protected override void CreateChildControls() { base.CreateChildControls(); - Controls.Add(m_UnpublishButton); + m_UnpublishModal = new Panel(); + m_UnpublishModal.ID = "LeUnpublishModal"; + m_UnpublishModal.Attributes.Add("Style", "display: none"); + + m_CancelDeleteButton = new Button(); + m_CancelDeleteButton.ID = "CancelUnpublish"; + m_CancelDeleteButton.Text = ui.GetText("cancel"); + m_CancelDeleteButton.CssClass = "modalbuton"; + + m_ConfirmUnpublishButton = new Button(); + m_ConfirmUnpublishButton.Text = ui.GetText("ok"); + m_ConfirmUnpublishButton.ID = "LeUnpublishModalConfirm"; + m_ConfirmUnpublishButton.CssClass = "modalbuton"; + m_ConfirmUnpublishButton.OnClientClick = "UnpublishModuleOk();"; + + m_UnpublishModal.Controls.Add(new LiteralControl("

" + ui.GetText("areyousure") + "

")); + m_UnpublishModal.Controls.Add(m_ConfirmUnpublishButton); + m_UnpublishModal.Controls.Add(new LiteralControl(" ")); + m_UnpublishModal.Controls.Add(m_CancelDeleteButton); + + Controls.Add(m_UnpublishModal); + + m_UnpublishButton = new ImageButton(); m_UnpublishButton.ID = "LeUnpublishButton"; m_UnpublishButton.CssClass = "button"; m_UnpublishButton.ToolTip = "Unpublish"; m_UnpublishButton.ImageUrl = String.Format("{0}/LiveEditing/Modules/UnpublishModule/unpublish.png", SystemDirectories.Umbraco); m_UnpublishButton.Visible = UmbracoContext.Current.HasPermission(ActionUnPublish.Instance.Letter); + m_UnpublishButton.OnClientClick = "jQuery('#" + m_UnpublishModal.ClientID + @"').ModalWindowShow('" + ui.GetText("unPublish") + "',true,300,200,50,0, ['.modalbuton'], null);return false;"; - Controls.Add(m_UnpublishModal); - m_UnpublishModal.ID = "LeUnpublishModal"; - m_UnpublishModal.CssClass = "modal"; - m_UnpublishModal.Width = 300; - m_UnpublishModal.Attributes.Add("Style", "display: none"); - - m_UnpublishModal.Controls.Add(new LiteralControl("
Unpublish Page
")); - m_UnpublishModal.Controls.Add(new LiteralControl("

Are you sure you want to unpublish this page?

")); - - m_UnpublishModal.Controls.Add(m_ConfirmDeleteButton); - m_UnpublishModal.Controls.Add(new LiteralControl(" ")); - m_UnpublishModal.Controls.Add(m_CancelDeleteButton); - - m_ConfirmDeleteButton.Text = "Ok"; - m_ConfirmDeleteButton.ID = "LeUnpublishModalConfirm"; - m_ConfirmDeleteButton.CssClass = "modalbuton"; - - m_CancelDeleteButton.Text = "Cancel"; - m_CancelDeleteButton.CssClass = "modalbuton"; - - Controls.Add(m_UnpublishModalExtender); - m_UnpublishModalExtender.ID = "ModalUnpublish"; - m_UnpublishModalExtender.TargetControlID = m_UnpublishButton.ID; - m_UnpublishModalExtender.PopupControlID = m_UnpublishModal.ID; - m_UnpublishModalExtender.BackgroundCssClass = "modalBackground"; - m_UnpublishModalExtender.OkControlID = m_ConfirmDeleteButton.ID; - m_UnpublishModalExtender.CancelControlID = m_CancelDeleteButton.ID; - m_UnpublishModalExtender.OnOkScript = string.Format("UnpublishModuleOk()"); - - m_UnpublishModal.Controls.Add(new LiteralControl("
")); - - //ScriptManager.RegisterClientScriptInclude(this, GetType(), UnpublishModuleScriptFile, String.Format(UnpublishModuleScriptFile, umbraco.IO.SystemDirectories.Umbraco)); + Controls.Add(m_UnpublishButton); } diff --git a/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropBehavior.js b/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropBehavior.js deleted file mode 100644 index 4cc0c97d90..0000000000 --- a/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropBehavior.js +++ /dev/null @@ -1,312 +0,0 @@ -Type.registerNamespace('umbraco.presentation.umbraco.controls.Extenders'); - - -umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior = function(element) { - - umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.initializeBase(this, [element]); - - this._DragItemClassValue = null; - this._DragItemHandleClassValue = null; - this._DropCueIDValue = null; - this._dropCue = null; - this._floatingBehaviors = []; -} - -umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.prototype = { - - initialize : function() { - // Register ourselves as a drop target. - AjaxControlToolkit.DragDropManager.registerDropTarget(this); - //Sys.Preview.UI.DragDropManager.registerDropTarget(this); - - // Initialize drag behavior after a while - window.setTimeout( Function.createDelegate( this, this._initializeDraggableItems ), 500 ); - - this._dropCue = $get(this.get_DropCueID()); - }, - - dispose : function() { - AjaxControlToolkit.DragDropManager.unregisterDropTarget(this); - //Sys.Preview.UI.DragDropManager.unregisterDropTarget(this); - - this._clearFloatingBehaviors(); - - umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.callBaseMethod(this, 'dispose'); - }, - - add_onDrop : function(handler) { - this.get_events().addHandler("onDrop", handler); - }, - - remove_onDrop : function(handler) { - this.get_events().removeHandler("onDrop", handler); - }, - - // onDrop property maps to onDrop event - get_onDrop : function() { - return this.get_events().getHandler("onDrop"); - }, - - set_onDrop : function(value) { - if (value && (0 < value.length)) { - var func = CommonToolkitScripts.resolveFunction(value); - if (func) { - this.add_onDrop(func); - } else { - throw Error.argumentType('value', typeof(value), 'Function', 'resize handler not a function, function name, or function text.'); - } - } - }, - - _raiseEvent : function( eventName, eventArgs ) { - var handler = this.get_events().getHandler(eventName); - if( handler ) { - if( !eventArgs ) eventArgs = Sys.EventArgs.Empty; - handler(this, eventArgs); - } - }, - - _clearFloatingBehaviors : function() - { - while( this._floatingBehaviors.length > 0 ) - { - var behavior = this._floatingBehaviors.pop(); - behavior.dispose(); - } - }, - - _findChildByClass : function(item, className) - { - // First check all immediate child items - var child = item.firstChild; - while( child != null ) - { - if( child.className == className ) return child; - child = child.nextSibling; - } - - // Not found, recursively check all child items - child = item.firstChild; - while( child != null ) - { - var found = this._findChildByClass( child, className ); - if( found != null ) return found; - child = child.nextSibling; - } - }, - - // Find all items with the drag item class and make each item - // draggable - _initializeDraggableItems : function() - { - this._clearFloatingBehaviors(); - - var el = this.get_element(); - - var child = el.firstChild; - while( child != null ) - { - if( child.className == this._DragItemClassValue && child != this._dropCue) - { - var handle = this._findChildByClass(child, this._DragItemHandleClassValue); - if( handle ) - { - var handleId = handle.id; - var behaviorId = child.id + "_WidgetFloatingBehavior"; - - // make the item draggable by adding floating behaviour to it - var floatingBehavior = $create(umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior, - {"DragHandleID":handleId, "id":behaviorId, "name": behaviorId}, {}, {}, child); - - Array.add( this._floatingBehaviors, floatingBehavior ); - } - } - child = child.nextSibling; - } - }, - - get_DragItemClass : function() - { - return this._DragItemClassValue; - }, - - set_DragItemClass : function(value) - { - this._DragItemClassValue = value; - }, - - get_DropCueID : function() - { - return this._DropCueIDValue; - }, - - set_DropCueID : function(value) - { - this._DropCueIDValue = value; - }, - - get_DragItemHandleClass : function() - { - return this._DragItemHandleClassValue; - }, - - set_DragItemHandleClass : function(value) - { - this._DragItemHandleClassValue = value; - }, - - getDescriptor : function() { - var td = umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.callBaseMethod(this, 'getDescriptor'); - return td; - }, - - // IDropTarget members. - get_dropTargetElement : function() { - return this.get_element(); - }, - - drop : function(dragMode, type, data) { - this._hideDropCue(data); - this._placeItem(data); - }, - - canDrop : function(dragMode, dataType) { - return true; - }, - - onDragEnterTarget : function(dragMode, type, data) { - this._showDropCue(data); - }, - - onDragLeaveTarget : function(dragMode, type, data) { - this._hideDropCue(data); - }, - - onDragInTarget : function(dragMode, type, data) { - this._repositionDropCue(data); - }, - - _findItemAt : function(x,y, item) - { - var el = this.get_element(); - - var child = el.firstChild; - while( child != null ) - { - if( child.className == this._DragItemClassValue && child != this._dropCue && child != item ) - { - var pos = Sys.UI.DomElement.getLocation(child); - - if( y <= pos.y ) - { - return child; - } - } - child = child.nextSibling; - } - - return null; - }, - - _showDropCue : function(data) - { - this._repositionDropCue(data); - - this._dropCue.style.display = "block"; - this._dropCue.style.visibility = "visible"; - - var bounds = Sys.UI.DomElement.getBounds(data.item); - - if( this._dropCue.style.height == "" ) - this._dropCue.style.height = bounds.height.toString() + "px"; - - }, - - _hideDropCue : function(data) - { - this._dropCue.style.display = "none"; - this._dropCue.style.visibility = "hidden"; - }, - - _repositionDropCue : function(data) - { - var location = Sys.UI.DomElement.getLocation(data.item); - var nearestChild = this._findItemAt(location.x, location.y, data.item); - - var el = this.get_element(); - - if( null == nearestChild ) - { - if( el.lastChild != this._dropCue ) - { - el.removeChild(this._dropCue); - el.appendChild(this._dropCue); - } - } - else - { - if( nearestChild.previousSibling != this._dropCue ) - { - el.removeChild(this._dropCue); - el.insertBefore(this._dropCue, nearestChild); - } - } - }, - - _placeItem : function(data) - { - var el = this.get_element(); - - data.item.parentNode.removeChild( data.item ); - el.insertBefore( data.item, this._dropCue ); - - // Find the position of the dropped item - var position = 0; - var item = el.firstChild; - while( item != data.item ) - { - if( item.className == this._DragItemClassValue ) position++; - item = item.nextSibling; - } - this._raiseDropEvent( /* Container */ el, /* droped item */ data.item, /* position */ position ); - }, - - - _raiseDropEvent : function( container, droppedItem, position ) - { - this._raiseEvent( "onDrop", new umbraco.presentation.umbraco.controls.Extenders.DropEventArgs(container, droppedItem, position) ); - } -} - -umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.registerClass('umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior', -AjaxControlToolkit.BehaviorBase, -AjaxControlToolkit.IDragSource, -AjaxControlToolkit.IDropTarget, -/*Sys.UI.Behavior, -Sys.Preview.UI.IDragSource, -Sys.Preview.UI.IDropTarget,*/ -Sys.IDisposable); - - -umbraco.presentation.umbraco.controls.Extenders.DropEventArgs = function(container, droppedItem, position) { - umbraco.presentation.umbraco.controls.Extenders.DropEventArgs.initializeBase(this); - - this._container = container; - this._droppedItem = droppedItem; - this._position = position; -} - -umbraco.presentation.umbraco.controls.Extenders.DropEventArgs.prototype = { - get_container : function() { - return this._container; - }, - get_droppedItem : function() { - return this._droppedItem; - }, - get_position : function() { - return this._position; - } -} - -umbraco.presentation.umbraco.controls.Extenders.DropEventArgs.registerClass("umbraco.presentation.umbraco.controls.Extenders.DropEventArgs", Sys.EventArgs); - diff --git a/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropDesigner.cs b/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropDesigner.cs deleted file mode 100644 index 57d17c370a..0000000000 --- a/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropDesigner.cs +++ /dev/null @@ -1,8 +0,0 @@ -using AjaxControlToolkit.Design; - -namespace umbraco.presentation.controls.Extenders -{ - class CustomDragDropDesigner : ExtenderControlBaseDesigner - { - } -} diff --git a/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropExtender.cs b/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropExtender.cs deleted file mode 100644 index 72817ab6a5..0000000000 --- a/umbraco/presentation/umbraco/controls/Extenders/CustomDragDropExtender.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.ComponentModel; -using System.Web.UI; -using System.Web.UI.WebControls; -using AjaxControlToolkit; - -[assembly: WebResource("umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.js", "text/javascript")] - -namespace umbraco.presentation.controls.Extenders -{ - [Designer(typeof(CustomDragDropDesigner))] - [ClientScriptResource("umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior", "umbraco.presentation.umbraco.controls.Extenders.CustomDragDropBehavior.js")] - [TargetControlType(typeof(WebControl))] - [RequiredScript(typeof(CommonToolkitScripts))] - [RequiredScript(typeof(TimerScript))] - //[RequiredScript(typeof(FloatingBehaviorScript))] - [RequiredScript(typeof(DragDropScripts))] - [RequiredScript(typeof(DragPanelExtender))] - [RequiredScript(typeof(CustomFloatingBehaviorScript))] - public class CustomDragDropExtender : ExtenderControlBase - { - [ExtenderControlProperty] - public string DragItemClass - { - get - { - return GetPropertyValue("DragItemClass", string.Empty); - } - set - { - SetPropertyValue("DragItemClass", value); - } - } - - [ExtenderControlProperty] - public string DragItemHandleClass - { - get - { - return GetPropertyValue("DragItemHandleClass", string.Empty); - } - set - { - SetPropertyValue("DragItemHandleClass", value); - } - } - - [ExtenderControlProperty] - [IDReferenceProperty(typeof(WebControl))] - public string DropCueID - { - get - { - return GetPropertyValue("DropCueID", string.Empty); - } - set - { - SetPropertyValue("DropCueID", value); - } - } - - [ExtenderControlProperty()] - [DefaultValue("")] - [ClientPropertyName("onDrop")] - public string OnClientDrop - { - get - { - return GetPropertyValue("OnClientDrop", string.Empty); - } - set - { - SetPropertyValue("OnClientDrop", value); - } - } - - } -} diff --git a/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehavior.js b/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehavior.js deleted file mode 100644 index 042a679cb4..0000000000 --- a/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehavior.js +++ /dev/null @@ -1,171 +0,0 @@ -Type.registerNamespace('umbraco.presentation.umbraco.controls.Extenders'); - -umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior = function(element) { - umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.initializeBase(this,[element]); - - var _handle; - var _location; - var _dragStartLocation; - var _DragHandleIDValue; - - var _mouseDownHandler = Function.createDelegate(this, mouseDownHandler); - - this.get_DragHandleID = function() - { - return this._DragHandleIDValue; - } - - this.set_DragHandleID = function(value) - { - this._DragHandleIDValue = value; - } - - this.add_move = function(handler) { - this.get_events().addHandler('move', handler); - } - - this.remove_move = function(handler) { - this.get_events().removeHandler('move', handler); - } - - this.get_handle = function() { - return _handle; - } - this.set_handle = function(value) { - if (_handle != null) { - $removeHandler(_handle, "mousedown", _mouseDownHandler); - } - - _handle = value; - $addHandler(_handle, "mousedown", _mouseDownHandler); - } - - this.get_location = function() { - return _location; - } - this.set_location = function(value) { - if (_location != value) { - _location = value; - if (this.get_isInitialized()) { - - Sys.UI.DomElement.setLocation(this.get_element(), _location.x, _location.y); - } - this.raisePropertyChanged('location'); - } - } - - this.initialize = function() { - umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.callBaseMethod(this, 'initialize'); - - // Set the handle and initialize dragging - this.set_handle( $get( this.get_DragHandleID() ) ); - } - - this.dispose = function() { - if (_handle && _mouseDownHandler) { - $removeHandler(_handle, "mousedown", _mouseDownHandler); - } - _mouseDownHandler = null; - umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.callBaseMethod(this, 'dispose'); - } - - this.checkCanDrag = function(element) { - var undraggableTagNames = ["input", "button", "select", "textarea", "label"]; - var tagName = element.tagName; - - if ((tagName.toLowerCase() == "a") && (element.href != null) && (element.href.length > 0)) { - return false; - } - if (Array.indexOf(undraggableTagNames, tagName.toLowerCase()) > -1) { - return false; - } - return true; - } - - - function mouseDownHandler(ev) { - window._event = ev; - var el = this.get_element(); - - if (!this.checkCanDrag(ev.target)) return; - - // Get the location before making the element absolute - _location = Sys.UI.DomElement.getLocation(el); - - // Make the element absolute - el.style.width = el.offsetWidth + "px"; - el.style.height = el.offsetHeight + "px"; - Sys.UI.DomElement.setLocation(el, _location.x, _location.y); - - _dragStartLocation = Sys.UI.DomElement.getLocation(el); - - ev.preventDefault(); - - this.startDragDrop(el); - - // Hack for restoring position to static - el.originalPosition = "static"; - el.originalZIndex = el.style.zIndex; - el.style.zIndex = "60000"; - } - - // Type get_dataType() - this.get_dragDataType = function() { - return "_CustomFloatingItem"; - } - - // Object get_data(Context) - this.getDragData = function(context) { - return { item : this.get_element(), handle : this.get_handle() } ; - } - - // DragMode get_dragMode() - this.get_dragMode = function() { - //return Sys.Preview.UI.DragMode.Move; - return AjaxControlToolkit.DragMode.Move; - } - - // void onDragStart() - this.onDragStart = function() { } - - // void onDrag() - this.onDrag = function() { } - - // void onDragEnd(Canceled) - this.onDragEnd = function(canceled) { - if (!canceled) { - var handler = this.get_events().getHandler('move'); - if(handler) { - var cancelArgs = new Sys.CancelEventArgs(); - handler(this, cancelArgs); - canceled = cancelArgs.get_cancel(); - } - } - - var el = this.get_element(); - el.style.width = el.style.height = el.style.left = el.style.top = ""; - el.style.zIndex = el.originalZIndex; - } - - this.startDragDrop = function(dragVisual) { - AjaxControlToolkit.DragDropManager.startDragDrop(this, dragVisual, null); - //Sys.Preview.UI.DragDropManager.startDragDrop(this, dragVisual, null); - } - - this.get_dropTargetElement = function() { - return document.body; - } - - this.canDrop = function(dragMode, dataType, data) { - return (dataType == "_CustomFloatingItem"); - } - -} - -umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.registerClass('umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior', -//Sys.UI.Behavior, -//Sys.Preview.UI.IDragSource, -AjaxControlToolkit.BehaviorBase, -AjaxControlToolkit.IDragSource, -Sys.IDisposable); - diff --git a/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorDesigner.cs b/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorDesigner.cs deleted file mode 100644 index b7ef49ed1a..0000000000 --- a/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorDesigner.cs +++ /dev/null @@ -1,14 +0,0 @@ -using AjaxControlToolkit; -using AjaxControlToolkit.Design; - -namespace umbraco.presentation.controls.Extenders -{ - class CustomFloatingBehaviorDesigner : ExtenderControlBaseDesigner - { - } - - [ClientScriptResource(null, "umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.js")] - public static class CustomFloatingBehaviorScript - { - } -} diff --git a/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorExtender.cs b/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorExtender.cs deleted file mode 100644 index f114900547..0000000000 --- a/umbraco/presentation/umbraco/controls/Extenders/CustomFloatingBehaviorExtender.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.ComponentModel; -using System.Web.UI; -using System.Web.UI.WebControls; -using AjaxControlToolkit; - -[assembly: WebResource("umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.js", "text/javascript")] - -namespace umbraco.presentation.controls.Extenders -{ - [Designer(typeof(CustomFloatingBehaviorDesigner))] - [ClientScriptResource("umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior", "umbraco.presentation.umbraco.controls.Extenders.CustomFloatingBehavior.js")] - [TargetControlType(typeof(WebControl))] - [RequiredScript(typeof(DragDropScripts))] - public class CustomFloatingBehaviorExtender : ExtenderControlBase - { - [ExtenderControlProperty] - [IDReferenceProperty(typeof(WebControl))] - public string DragHandleID - { - get - { - return GetPropertyValue("DragHandleID", string.Empty); - } - set - { - SetPropertyValue("DragHandleID", value); - } - } - } -} diff --git a/umbraco/presentation/umbraco/dialogs/create.aspx b/umbraco/presentation/umbraco/dialogs/create.aspx index b69bcdd6d1..92e1b86ed3 100644 --- a/umbraco/presentation/umbraco/dialogs/create.aspx +++ b/umbraco/presentation/umbraco/dialogs/create.aspx @@ -45,7 +45,7 @@ + Height="230"> ").UmbracoTreeAPI(); tree.refreshTree(); } diff --git a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx index 9fc2e74da6..e63ce731d4 100644 --- a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx +++ b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx @@ -44,7 +44,7 @@ - + diff --git a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js index ece84fc38b..ab24075998 100644 --- a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js +++ b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js @@ -64,7 +64,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); $.fn.UmbracoTreeAPI = function() { /// exposes the Umbraco Tree api for the selected object if ($(this).length != 1) { - throw "UmbracoTreeAPI selector requires that there be exactly one control selected"; + throw "UmbracoTreeAPI selector requires that there be exactly one control selected, this selector returns " + $(this).length; }; // check if there's an api stored for the id of the object specified, if there's not // check if the first child is a div and if that has the api specified diff --git a/umbraco/presentation/umbraco_client/modal/modal.js b/umbraco/presentation/umbraco_client/modal/modal.js index 05ce597712..06e4f30831 100644 --- a/umbraco/presentation/umbraco_client/modal/modal.js +++ b/umbraco/presentation/umbraco_client/modal/modal.js @@ -13,13 +13,64 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); return $(this).data("ModalWindowAPI") == null ? null : $(this).data("ModalWindowAPI"); }; + $.fn.ModalWindowShow = function(name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) { + return $(this).each(function() { + //check if the modal exists already + if ($(this).closest(".umbModalBox").length) { + var api = $(this).closest(".umbModalBox").ModalWindowAPI(); + api._obj.jqmShow(); //since it exist, just re-show it + } + else { + var modal = Umbraco.Controls.ModalWindow(); + modal.show(this, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback); + } + }); + }; + Umbraco.Controls.ModalWindow = function() { /// Modal window class, when open is called, it will create a temporary html element to attach the window to return { _wId: Umbraco.Utils.generateRandom().toString().replace(".", ""), //the modal window ID that will be assigned _obj: null, //the jquery element for the modal window _rVal: null, //a return value specified when closing that gets passed to the onCloseCallback method + + show: function(selector, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) { + //check if the modal elems exist + if (!this._modalElemsExist()) { + this._createModalElems(false, selector); + } + + this._open(name, showHeader, + width, height, top, leftOffset, + closeTriggers, onCloseCallback, + function(h) { + //insert the content + var umbModal = $(h.w); + var umbModalContent = $(".umbModalBoxContent", umbModal); + umbModalContent.append($(selector)); + $(selector).show(); + }); + }, open: function(url, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) { + //check if the modal elems exist + if (!this._modalElemsExist()) { + this._createModalElems(true); + } + var _this = this; + this._open(name, showHeader, + width, height, top, leftOffset, + closeTriggers, onCloseCallback, + function(h) { + //get the iframe, and set the url + var umbModal = $(h.w); + var umbModalContent = $("iframe", umbModal); + umbModalContent.html('').attr('src', _this._getUniqueUrl(url)); + umbModalContent.width(width); + umbModalContent.height(showHeader ? height - 30 : height); + umbModalContent.show(); + }); + }, + _open: function(name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback, onCreate) { /// Opens a modal window /// Optional /// Optional @@ -35,21 +86,12 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); /// outVal = the value passed to the close window method that was used to close the window (if it was specified) /// The generated jquery object bound to the modal window - //check if the modal elems exist - if (!this._modalElemsExist()) { - this._createModalElems(); - } - var _this = this; this._obj.jqm({ onShow: function(h) { var umbModal = $(h.w); - var umbModalContent = $("iframe", umbModal); - - umbModalContent.width(width); - umbModalContent.height(showHeader ? height - 30 : height); //remove the header if it shouldn't be shown if (!showHeader) { @@ -80,10 +122,11 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); umbModal.css("left", newLeft); } - umbModalContent.html('').attr('src', _this._getUniqueUrl(url)); - umbModal.show(); - umbModalContent.show(); + + if (typeof onCreate == "function") { + onCreate.call(_this, h) + } $(document).keyup(function(event) { if (event.keyCode == 27 && umbModal.css("display") == "block") { @@ -99,17 +142,22 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); }, onHide: function(h) { var umbModal = $(h.w); - var umbModalContent = $("iframe", umbModal); + var umbModalContent = $(".umbModalBoxContent", umbModal); + var iframe = umbModalContent.find("iframe"); if (typeof onCloseCallback == "function") { //call the callback if specified, pass the jquery content object as a param and the output value array - var e = { modalContent: umbModalContent, outVal: _this._rVal }; + //pass the iframe if there is one + var e = { modalContent: iframe.length > 0 ? iframe : umbModalContent, outVal: _this._rVal }; onCloseCallback.call(_this, e); } h.w.hide(); h.o.remove(); - umbModalContent.hide(); - umbModalContent.html('').attr('src', ''); - _this.close(); + //remove any iframes that might be in there + if (iframe.length > 0) { + umbModalContent.hide(); + umbModalContent.html('').attr('src', ''); + _this.close(); + } } }); @@ -127,35 +175,53 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); this._obj.remove(); return false; }, - _createModalElems: function() { + _createModalElems: function(withIFrame, selector) { /// This will create the html elements required for the modal overlay if they do not already exist in the DOM - var overlayHtml = "
" + - "
×" + - "
" + - "
"; - - this._obj = $(overlayHtml).appendTo("body"); + var overlayHtml = this._getOverlayHtml(withIFrame); + //create the modal dialog in the root if no selector, otherwise create at parent + //of selector + if (!selector) { + this._obj = $(overlayHtml).appendTo("body"); + } + else { + this._obj = $(overlayHtml).appendTo($(selector).parent()); + } var _this = this; - if ($.fn.draggable) this._obj.draggable({ - cursor: 'move', - distance: 5, - iframeFix: true, - helper: function(event) { - var o = $(this).clone(); - o.children().remove(); - o.css("border-width", "1px"); - return o; - }, - start: function(event, ui) { - ui.helper.css("z-index", 20000); - }, - stop: function(event, ui) { - _this._obj.css("top", ui.absolutePosition.top); - _this._obj.css("left", ui.absolutePosition.left); - } - }); + if ($.fn.draggable) { + this._obj.draggable({ + cursor: 'move', + distance: 5, + iframeFix: withIFrame, + helper: function(event) { + var o = $(this).clone(); + o.children().remove(); + o.css("border-width", "1px"); + return o; + }, + start: function(event, ui) { + ui.helper.css("z-index", 20000); + }, + stop: function(event, ui) { + _this._obj.css("top", ui.absolutePosition.top); + _this._obj.css("left", ui.absolutePosition.left); + } + }); + } + else { + this._obj.find(".umbModalBoxHeader").css("cursor", "default"); //remove the move cursor if we can't move + } + }, + _getOverlayHtml: function(withIFrame) { + var overlayHtml = "
" + + "
×" + + "
"; + if (withIFrame) { + overlayHtml += ""; + } + overlayHtml += "
"; + return overlayHtml; }, _modalElemsExist: function() { return ($("#" + this._wId + "_modal").length > 0); diff --git a/umbraco/presentation/umbraco_client/modal/style.css b/umbraco/presentation/umbraco_client/modal/style.css index 465a2556cf..07f3f2117c 100644 --- a/umbraco/presentation/umbraco_client/modal/style.css +++ b/umbraco/presentation/umbraco_client/modal/style.css @@ -1,7 +1,7 @@ /* TODO: Change these to classes to support many modal boxes */ -#umbModalBox, -.umbModalBox { +div#umbModalBox, +div.umbModalBox { position: absolute; top: 0; border: 5px #a3a3a3 solid; @@ -9,36 +9,37 @@ text-align: left; z-index: 10000; display: none; - background: #fff; + background: #fff ! important; font: bold 100% "Lucida Grande", Arial, sans-serif; } -#umbModalBox.loaded, -.umbModalBox.loaded -{ +div#umbModalBox.loaded, +div.umbModalBox.loaded +{ background-image: none; } .jqmOverlay {background: url(modalBackground.gif)} -#umbModalBoxHeader, -.umbModalBoxHeader { +div#umbModalBoxHeader, +div.umbModalBoxHeader { margin: 0; - text-shadow: #FFF 0 1px 0; + text-shadow: #FFF 0 1px 0; padding: .5em 2em .5em .75em; margin: 0; text-align: left; } -#umbModalBoxContent, -.umbModalBoxContent { +div#umbModalBoxContent, +div.umbModalBoxContent { padding: 0px; overflow: hidden; - height: 100%; + /*height: 100%;*/ + background: #fff ! important; } -#umbracModalBoxClose, -.umbracModalBoxClose { +a#umbracModalBoxClose, +a.umbracModalBoxClose { display: block; position: absolute; right: 5px; top: 2px; @@ -48,19 +49,19 @@ font-size: 13px; } -#umbModalBoxContent, -.umbModalBoxContent {border-top: 1px solid #F9F9F9; } +div#umbModalBoxContent, +div.umbModalBoxContent {border-top: 1px solid #F9F9F9; } -#umbModalBoxHeader, -.umbModalBoxHeader { - background: url(modalGradiant.gif) repeat-x bottom #fff; +div#umbModalBoxHeader, +div.umbModalBoxHeader { + background: url(modalGradiant.gif) repeat-x bottom #fff ! important; border-bottom: 1px solid #CCC; color: #378080; cursor:move; } -#umbracModalBoxClose, -.umbracModalBoxClose { color: #777 } +div#umbracModalBoxClose, +div.umbracModalBoxClose { color: #777 } -#umbracModalBoxClose:hover, -.umbracModalBoxClose:hover { color: #000 } \ No newline at end of file +div#umbracModalBoxClose:hover, +div.umbracModalBoxClose:hover { color: #000 } \ No newline at end of file