diff --git a/UpgradeReadme.txt b/UpgradeReadme.txt index fff889ef2e..189b5184f9 100644 --- a/UpgradeReadme.txt +++ b/UpgradeReadme.txt @@ -49,4 +49,17 @@ FireBeforeAddToIndex, AfterAddToIndex, FireAfterAddToIndex, Document.Index * Removed /umbraco/webservices/Search.asmx as the SearchItem object has been removed * Removed /umbraco/reindex.aspx -* Removed /umbraco/dialogs/editImage.aspx since it didn't do anything at all \ No newline at end of file +* Removed /umbraco/dialogs/editImage.aspx since it didn't do anything at all + +* MediaPicker has been completely overhauled in regards to the JavaScript implementation and should now work in live editing mode + +* /umbraco/plugins/tinymce3/insertImage.aspx has been overhauled to use the tree control, image viewer control and upload media image control + +* /umbraco/treeInit.aspx has been marked obsolete +** All pages that used to use TreeInit now use TreeControl (except for Legacy project) +* /umbraco/dialog/treePicker.aspx has been marked obsolete +* /umbraco/dialog/uploadImage.aspx has been marked obsolete +* /umbraco/dialog/imageViewer.aspx has been marked obsolete + +* subModal library moved to legacy and no longer used +* JavaScript Modal window framework overhauled and replaced \ No newline at end of file diff --git a/components/editorControls/BaseTreePickerEditor.cs b/components/editorControls/BaseTreePickerEditor.cs new file mode 100644 index 0000000000..5be3ac5499 --- /dev/null +++ b/components/editorControls/BaseTreePickerEditor.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using umbraco.uicontrols.TreePicker; +using umbraco.interfaces; + +namespace umbraco.editorControls +{ + /// + /// A base tree picker class that has all of the functionality built in for an IDataEditor + /// + public abstract class BaseTreePickerEditor : BaseTreePicker, IDataEditor + { + + interfaces.IData _data; + protected int StoredItemId = -1; + + public BaseTreePickerEditor() + : base() { } + + public BaseTreePickerEditor(IData Data) + : base() + { + _data = Data; + } + + private void StoreItemId(IData Data) + { + if (_data != null && _data.Value != null && !String.IsNullOrEmpty(_data.Value.ToString())) + { + int.TryParse(_data.Value.ToString(), out StoredItemId); + } + } + + protected override void OnInit(EventArgs e) + { + StoreItemId(_data); + + base.OnInit(e); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + if (!Page.IsPostBack) + { + ItemIdValue.Value = StoredItemId != -1 ? StoredItemId.ToString() : ""; + } + } + + #region IDataField Members + + public System.Web.UI.Control Editor { get { return this; } } + + public virtual bool TreatAsRichTextEditor + { + get { return false; } + } + public bool ShowLabel + { + get + { + return true; + } + } + + public void Save() + { + //_text = helper.Request(this.ClientID); + if (ItemIdValue.Value.Trim() != "") + _data.Value = ItemIdValue.Value.Trim(); + else + _data.Value = null; + } + + #endregion + } +} diff --git a/components/editorControls/macrocontainer/Editor.cs b/components/editorControls/macrocontainer/Editor.cs index f106d1a2c3..72c5108cb1 100644 --- a/components/editorControls/macrocontainer/Editor.cs +++ b/components/editorControls/macrocontainer/Editor.cs @@ -43,18 +43,22 @@ namespace umbraco.editorControls.macrocontainer protected override void OnInit(EventArgs e) { base.OnInit(e); - - - base.Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "subModal", ""); - + + //SD: This is useless as it won't work in live editing anyways whilst using MS Ajax/ScriptManager for ajax calls if (!UmbracoContext.Current.LiveEditingContext.Enabled) + { presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page); + ScriptManager sm = ScriptManager.GetCurrent(base.Page); + ServiceReference webservicePath = new ServiceReference(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/webservices/MacroContainerService.asmx"); + + if (!sm.Services.Contains(webservicePath)) + sm.Services.Add(webservicePath); + } else + { ClientDependencyLoader.Instance.RegisterDependency("webservices/legacyAjaxCalls.asmx/js", "UmbracoRoot", ClientDependencyType.Javascript); - - - - + ClientDependencyLoader.Instance.RegisterDependency("webservices/MacroContainerService.asmx/js", "UmbracoRoot", ClientDependencyType.Javascript); + } _addMacro = new LinkButton(); _addMacro.ID = ID + "_btnaddmacro"; diff --git a/components/editorControls/macrocontainer/MacroControlFactory.cs b/components/editorControls/macrocontainer/MacroControlFactory.cs index e533293793..0915dfa403 100644 --- a/components/editorControls/macrocontainer/MacroControlFactory.cs +++ b/components/editorControls/macrocontainer/MacroControlFactory.cs @@ -27,26 +27,15 @@ namespace umbraco.editorControls.macrocontainer internal static Control GetMacroRenderControlByType(PersistableMacroProperty prop, string uniqueID) { Control macroControl; - //Determine the property type - switch (prop.TypeName.ToLower()) + + Type m = MacroControlTypes.FindLast(delegate(Type macroGuiCcontrol) { return macroGuiCcontrol.ToString() == string.Format("{0}.{1}", prop.AssemblyName, prop.TypeName); }); + IMacroGuiRendering typeInstance; + typeInstance = Activator.CreateInstance(m) as IMacroGuiRendering; + if (!string.IsNullOrEmpty(prop.Value)) { - //Use a pagepicker instead of a IMacroGuiRendering control - case "content": - macroControl = new pagePicker(null); - ((pagePicker)macroControl).Value = prop.Value; - break; - ///Default behaviour - default: - Type m = MacroControlTypes.FindLast(delegate(Type macroGuiCcontrol) { return macroGuiCcontrol.ToString() == string.Format("{0}.{1}", prop.AssemblyName, prop.TypeName); }); - IMacroGuiRendering typeInstance; - typeInstance = Activator.CreateInstance(m) as IMacroGuiRendering; - if (!string.IsNullOrEmpty(prop.Value)) - { - ((IMacroGuiRendering)typeInstance).Value = prop.Value; - } - macroControl = (Control)typeInstance; - break; + ((IMacroGuiRendering)typeInstance).Value = prop.Value; } + macroControl = (Control)typeInstance; macroControl.ID = uniqueID; return macroControl; @@ -59,17 +48,7 @@ namespace umbraco.editorControls.macrocontainer /// internal static string GetValueFromMacroControl(Control macroControl) { - if (macroControl is pagePicker) - { - //pagePicker Control - return ((pagePicker)macroControl).Value; - } - else - { - ///Macro control - return ((IMacroGuiRendering)macroControl).Value; - } - + return ((IMacroGuiRendering)macroControl).Value; } #endregion @@ -85,7 +64,7 @@ namespace umbraco.editorControls.macrocontainer { //Populate the list with all the types of IMacroGuiRendering _macroControlTypes = new List(); - _macroControlTypes = TypeFinder.FindClassesOfType(true); + _macroControlTypes = TypeFinder.FindClassesOfType(); } return _macroControlTypes; diff --git a/components/editorControls/mediapicker/MediaChooserScripts.Designer.cs b/components/editorControls/mediapicker/MediaChooserScripts.Designer.cs new file mode 100644 index 0000000000..dd92d4f662 --- /dev/null +++ b/components/editorControls/mediapicker/MediaChooserScripts.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4200 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.editorControls.mediapicker { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class MediaChooserScripts { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal MediaChooserScripts() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("umbraco.editorControls.mediapicker.MediaChooserScripts", typeof(MediaChooserScripts).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to /// <reference path="/umbraco_client/Application/NamespaceManager.js" /> + /// + ///Umbraco.Sys.registerNamespace("Umbraco.Controls"); + /// + ///(function($) { + /// + /// Umbraco.Controls.MediaChooser = function(label, hasPreview, mediaIdValueClientID, previewContainerClientID, imgViewerClientID, mediaTitleClientID) { + /// return { + /// _mediaPickerUrl: '/umbraco/dialogs/mediaPicker.aspx', + /// _webServiceUrl: "/umbraco/webservices/legacyAjaxCalls.asmx/GetNodeName", + /// _label: label, + /// [rest of string was truncated]";. + /// + internal static string MediaPicker { + get { + return ResourceManager.GetString("MediaPicker", resourceCulture); + } + } + } +} diff --git a/components/editorControls/mediapicker/MediaChooserScripts.resx b/components/editorControls/mediapicker/MediaChooserScripts.resx new file mode 100644 index 0000000000..7f939d3d99 --- /dev/null +++ b/components/editorControls/mediapicker/MediaChooserScripts.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + MediaPicker.js;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file diff --git a/components/editorControls/mediapicker/MediaPicker.js b/components/editorControls/mediapicker/MediaPicker.js new file mode 100644 index 0000000000..2f87565fc3 --- /dev/null +++ b/components/editorControls/mediapicker/MediaPicker.js @@ -0,0 +1,52 @@ +/// + +Umbraco.Sys.registerNamespace("Umbraco.Controls"); + +(function($) { + Umbraco.Controls.MediaChooser = function(label, mediaIdValueClientID, previewContainerClientID, imgViewerClientID, mediaTitleClientID, mediaPickerUrl, width, height, umbracoPath) { + return { + _mediaPickerUrl: mediaPickerUrl, + _webServiceUrl: umbracoPath + "/webservices/legacyAjaxCalls.asmx/GetNodeName", + _label: label, + _width: width, + _height: height, + _mediaIdValueClientID: mediaIdValueClientID, + _previewContainerClientID: previewContainerClientID, + _imgViewerClientID: imgViewerClientID, + _mediaTitleClientID: mediaTitleClientID, + + LaunchPicker: function() { + var _this = this; + UmbClientMgr.openModalWindow(this._mediaPickerUrl, this._label, true, this._width, this._height, 30, 0, ['#cancelbutton'], function(e) { _this.SaveSelection(e); }); + }, + + SaveSelection: function(e) { + if (!e.outVal) { + return; + } + $("#" + this._mediaIdValueClientID).val(e.outVal); + $("#" + this._previewContainerClientID).show(); + $("#" + this._imgViewerClientID).UmbracoImageViewerAPI().updateImage(e.outVal); + var _this = this; + $.ajax({ + type: "POST", + url: _this._webServiceUrl, + data: '{ "nodeId": ' + e.outVal + ' }', + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function(msg) { + $("#" + _this._mediaTitleClientID).html(msg.d); + $("#" + _this._mediaTitleClientID).parent().show(); + } + }); + }, + + ClearSelection: function() { + $("#" + this._mediaTitleClientID).parent().hide(); + $("#" + this._mediaIdValueClientID).val(''); + $("#" + this._previewContainerClientID).hide(); + } + }; + } + +})(jQuery); \ No newline at end of file diff --git a/components/editorControls/mediapicker/mediaChooser.cs b/components/editorControls/mediapicker/mediaChooser.cs index 109385dc70..4ce4a3beb5 100644 --- a/components/editorControls/mediapicker/mediaChooser.cs +++ b/components/editorControls/mediapicker/mediaChooser.cs @@ -7,201 +7,173 @@ using umbraco.presentation; using ClientDependency.Core.Controls; using umbraco.interfaces; using umbraco.IO; +using umbraco.BasePages; +using umbraco.controls.Images; +using System.Web.UI.WebControls; +using System.Web.UI.HtmlControls; +using System.Resources; +using umbraco.editorControls.mediapicker; +using umbraco.uicontrols.TreePicker; namespace umbraco.editorControls { - /// - /// Summary description for mediaChooser. - /// - [ClientDependency(100, ClientDependencyType.Css, "js/submodal/submodal.css", "UmbracoRoot")] - [ClientDependency(101, ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")] - //TODO: Work out how to include this: , InvokeJavascriptMethodOnLoad = "initPopUp" - [ClientDependency(102, ClientDependencyType.Javascript, "js/submodal/submodal.js", "UmbracoRoot")] + /// + /// Summary description for mediaChooser. + /// [ValidationProperty("Value")] - public class mediaChooser : System.Web.UI.WebControls.HiddenField, IDataEditor - { - interfaces.IData _data; - bool _showpreview; - bool _showadvanced; + public class mediaChooser : BaseTreePickerEditor + { + bool _showpreview; + bool _showadvanced; + protected ImageViewer ImgViewer; + protected HtmlGenericControl PreviewContainer; - public mediaChooser(interfaces.IData Data) + public mediaChooser(IData data) + : base(data) { } + + + public mediaChooser(IData data, bool showPreview, bool showAdvanced) + : base(data) { - _data = Data; + _showpreview = showPreview; + _showadvanced = showAdvanced; + } + + public override string ModalWindowTitle + { + get + { + return ui.GetText("general", "choose") + " " + ui.GetText("sections", "media"); + } + } + + public override string TreePickerUrl + { + get + { + return _showadvanced ? umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/mediaPicker.aspx" : TreeService.GetPickerUrl("media", "media"); + } + } + + protected override string GetJSScript() + { + if (!_showpreview) + { + return base.GetJSScript(); + } + else + { + /* 0 = this control's client id + * 1 = label + * 2 = mediaIdValueClientID + * 3 = previewContainerClientID + * 4 = imgViewerClientID + * 5 = mediaTitleClientID + * 6 = mediaPickerUrl + * 7 = popup width + * 8 = popup height + * 9 = umbraco path + */ + return string.Format(@" + var mc_{0} = new Umbraco.Controls.MediaChooser('{1}','{2}','{3}','{4}','{5}','{6}',{7},{8},'{9}');", + new string[] + { + this.ClientID, + ModalWindowTitle, + ItemIdValue.ClientID, + _showpreview ? PreviewContainer.ClientID : "__NOTSET", + _showpreview ? ImgViewer.ClientID : "_NOTSET", + ItemTitle.ClientID, + TreePickerUrl, + ModalWidth.ToString(), + ModalHeight.ToString(), + umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco).TrimEnd('/') + }); + } + } + + /// + /// Renders the required media picker javascript + /// + protected override void RenderJSComponents() + { + + if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) + { + ScriptManager.RegisterStartupScript(this, this.GetType(), "MediaChooser", MediaChooserScripts.MediaPicker, true); + } + else + { + Page.ClientScript.RegisterClientScriptBlock(typeof(mediaChooser), "MediaChooser", MediaChooserScripts.MediaPicker, true); + } + } + + protected override void CreateChildControls() + { + base.CreateChildControls(); + + //if preview is enabled, add it to the wrapper + if (_showpreview) + { + //create the preview wrapper + PreviewContainer = new HtmlGenericControl("div"); + PreviewContainer.ID = "preview"; + this.Controls.Add(PreviewContainer); + + ImgViewer = (ImageViewer)Page.LoadControl(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/controls/Images/ImageViewer.ascx"); + ImgViewer.ID = "ImgViewer"; + ImgViewer.ViewerStyle = ImageViewer.Style.ImageLink; + + PreviewContainer.Style.Add(HtmlTextWriterStyle.MarginTop, "5px"); + PreviewContainer.Controls.Add(ImgViewer); + } + } + + /// + /// sets the modal width/height based on properties + /// + /// + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + + ModalWidth = _showadvanced ? 530 : 320; + ModalHeight = _showadvanced ? 565 : 400; } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); - Page.ClientScript.RegisterStartupScript(typeof(IDataEditor), "initPopUp", "jQuery(document).ready(function() { initPopUp(); } );", true); - } - public mediaChooser(interfaces.IData Data, bool ShowPreview, bool ShowAdvanced) - { - _data = Data; - _showpreview = ShowPreview; - _showadvanced = ShowAdvanced; - } - public System.Web.UI.Control Editor { get { return this; } } - #region IDataField Members - - //private string _text; - - public virtual bool TreatAsRichTextEditor - { - get { return false; } - } - - public bool ShowLabel - { - get - { - return true; - } - } - - public void Save() - { - if (base.Value.Trim() != "") - _data.Value = base.Value; - else - _data.Value = null; - } - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - if (_data != null && _data.Value != null && !String.IsNullOrEmpty(_data.Value.ToString())) - { - base.Value = _data.Value.ToString(); - } - } - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager - if (!UmbracoContext.Current.LiveEditingContext.Enabled) - presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page); - else - ClientDependencyLoader.Instance.RegisterDependency("webservices/legacyAjaxCalls.asmx/js", "UmbracoRoot", ClientDependencyType.Javascript); - - // And a reference to the media picker calls - if (!UmbracoContext.Current.LiveEditingContext.Enabled) - { - ScriptManager sm = ScriptManager.GetCurrent(base.Page); - ServiceReference webservicePath = new ServiceReference(SystemDirectories.Webservices + "/MediaPickerService.asmx"); - - if (!sm.Services.Contains(webservicePath)) - sm.Services.Add(webservicePath); - } - else - { - ClientDependencyLoader.Instance.RegisterDependency("webservices/MediaPickerService.asmx/js", "UmbracoRoot", ClientDependencyType.Javascript); - } - } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - - string tempTitle = ""; - int mediaId = -1; - string deleteLink = "   " + ui.Text("delete") + "   "; - try - { - if (base.Value != "") - { - mediaId = int.Parse(base.Value); - tempTitle = new cms.businesslogic.CMSNode(int.Parse(base.Value)).Text; - } - } - catch { } - - string dialog = "\nshowPopWin('" + TreeService.GetPickerUrl(true, "media", "media") + "', 300, 400, " + ClientID + "_saveId)"; - if (_showadvanced) - dialog = "\nshowPopWin('" + SystemDirectories.Umbraco + "/dialogs/mediaPicker.aspx" + "', 500, 530, " + ClientID + "_saveId)"; - - string preview = string.Empty; if (_showpreview) - preview = "\numbraco.presentation.webservices.MediaPickerService.GetThumbNail(treePicker, " + this.ClientID + "_UpdateThumbNail);" + - "\numbraco.presentation.webservices.MediaPickerService.GetFile(treePicker, " + this.ClientID + "_UpdateLink);"; - - - string strScript = "function " + this.ClientID + "_chooseId() {" + - //"\nshowPopWin('" + TreeService.GetPickerUrl(true, "media", "media") + "', 300, 400, " + ClientID + "_saveId)" + - //"\nshowPopWin('" + umbraco.IO.SystemDirectories.Umbraco + "/dialogs/mediaPicker.aspx" + "', 500, 530, " + ClientID + "_saveId)" + - // "\nvar treePicker = window.showModalDialog(, 'treePicker', 'dialogWidth=350px;dialogHeight=300px;scrollbars=no;center=yes;border=thin;help=no;status=no') " + - dialog + - "\n}" + - "\nfunction " + ClientID + "_saveId(treePicker) {" + - "\nsetTimeout('" + ClientID + "_saveIdDo(' + treePicker + ')', 200);" + - "\n}" + - "\nfunction " + ClientID + "_saveIdDo(treePicker) {" + - "\nif (treePicker != undefined) {" + - "\ndocument.getElementById(\"" + this.ClientID + "\").value = treePicker;" + - "\nif (treePicker > 0) {" + - "\numbraco.presentation.webservices.legacyAjaxCalls.GetNodeName(treePicker, " + this.ClientID + "_updateContentTitle" + ");" + - preview+ - "\n} " + - "\n}" + - "\n} " + - "\nfunction " + this.ClientID + "_updateContentTitle(retVal) {" + - "\ndocument.getElementById(\"" + this.ClientID + "_title\").innerHTML = \"\" + retVal + \"" + deleteLink.Replace("\"", "\\\"") + "\";" + - "\n}" + - "\nfunction " + this.ClientID + "_clear() {" + - "\ndocument.getElementById(\"" + this.ClientID + "_title\").innerHTML = \"\";" + - "\ndocument.getElementById(\"" + this.ClientID + "\").value = \"\";" + - "\ndocument.getElementById(\"" + this.ClientID + "_preview\").style.display = 'none';" + - "\n}" + - "\nfunction " + this.ClientID + "_UpdateThumbNail(retVal){" + - "\nif(retVal != \"\"){" + - "\ndocument.getElementById(\"" + this.ClientID + "_thumbnail\").src = retVal;" + - "\ndocument.getElementById(\"" + this.ClientID + "_preview\").style.display = 'block';}" + - "\nelse{document.getElementById(\"" + this.ClientID + "_preview\").style.display = 'none';}" + - "\n}"+ - "\nfunction " + this.ClientID + "_UpdateLink(retVal){" + - "\ndocument.getElementById(\"" + this.ClientID + "_thumbnaillink\").href = retVal;" + - "\n}"; - - try { - if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) - ScriptManager.RegisterClientScriptBlock(this, this.GetType(), this.ClientID + "_chooseId", strScript, true); + if (string.IsNullOrEmpty(ItemIdValue.Value)) + { + PreviewContainer.Style.Add(HtmlTextWriterStyle.Display, "none"); + ImgViewer.MediaId = -1; + } else - Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID + "_chooseId", strScript, true); - } - catch - { - Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID + "_chooseId", strScript, true); - } - // Clear remove link if text if empty - if (base.Value == "") - deleteLink = ""; - writer.WriteLine("" + tempTitle + "" + deleteLink + "" + ui.Text("choose") + "...   ");//   "); - - - - //Thumbnail preview - if (_showpreview) - { - string thumb = string.Empty; - string link = string.Empty; - string style = "display:none;"; - if (mediaId != -1) { - style = string.Empty; - thumb = string.Format(" src=\"{0}\" ", presentation.webservices.MediaPickerServiceHelpers.GetThumbNail(mediaId)); - link = string.Format(" href=\"{0}\" ", presentation.webservices.MediaPickerServiceHelpers.GetFile(mediaId)); + ImgViewer.MediaId = int.Parse(ItemIdValue.Value); } - - writer.WriteLine("
"); } - - - - - base.Render(writer); + + //if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) + //{ + // //renders the media picker JS class + // ScriptManager.RegisterStartupScript(this, this.GetType(), "MediaChooser", MediaChooserScripts.MediaPicker, true); + // ScriptManager.RegisterStartupScript(this, this.GetType(), this.ClientID + "MediaPicker", strScript, true); + + //} + //else + //{ + // //renders the media picker JS class + // Page.ClientScript.RegisterClientScriptBlock(typeof(mediaChooser), "MediaChooser", MediaChooserScripts.MediaPicker, true); + // Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID + "MediaPicker", strScript, true); + + //} + } - #endregion - } + + } } diff --git a/components/editorControls/pagepicker/pagePicker.cs b/components/editorControls/pagepicker/pagePicker.cs index 26c40dd49a..127575c27f 100644 --- a/components/editorControls/pagepicker/pagePicker.cs +++ b/components/editorControls/pagepicker/pagePicker.cs @@ -6,126 +6,37 @@ using ClientDependency.Core; using umbraco.presentation; using ClientDependency.Core.Controls; using umbraco.interfaces; +using System.Web.UI.WebControls; +using System.Web.UI.HtmlControls; +using umbraco.editorControls.pagepicker; +using umbraco.uicontrols.TreePicker; namespace umbraco.editorControls { /// /// Summary description for pagePicker. /// - [ClientDependency(100, ClientDependencyType.Css, "js/submodal/submodal.css", "UmbracoRoot")] - [ClientDependency(101, ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")] - //TODO: Work out how to include this: , InvokeJavascriptMethodOnLoad = "initPopUp" - [ClientDependency(102, ClientDependencyType.Javascript, "js/submodal/submodal.js", "UmbracoRoot")] [ValidationProperty("Value")] - public class pagePicker : System.Web.UI.WebControls.HiddenField, IDataEditor + public class pagePicker : BaseTreePickerEditor { - interfaces.IData _data; - public pagePicker(interfaces.IData Data) - { - _data = Data; - } - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - Page.ClientScript.RegisterStartupScript(typeof(IDataEditor), "initPopUp", "jQuery(document).ready(function() { initPopUp(); } );", true); - } - #region IDataField Members - - //private string _text; - - - public System.Web.UI.Control Editor { get { return this; } } - - public virtual bool TreatAsRichTextEditor - { - get { return false; } - } - public bool ShowLabel + public pagePicker() : base() { } + public pagePicker(interfaces.IData data) : base(data) { } + + public override string TreePickerUrl { get { - return true; + return TreeService.GetPickerUrl("content", "content"); } } - public void Save() + public override string ModalWindowTitle { - //_text = helper.Request(this.ClientID); - if (base.Value.Trim() != "") - _data.Value = base.Value.Trim(); - else - _data.Value = null; - } - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager - if (!UmbracoContext.Current.LiveEditingContext.Enabled) - presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page); - else - ClientDependencyLoader.Instance.RegisterDependency("webservices/legacyAjaxCalls.asmx/js", "UmbracoRoot", ClientDependencyType.Javascript); - - if (_data != null && _data.Value != null) - base.Value = _data.Value.ToString(); - } - - - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - - string tempTitle = ""; - string deleteLink = "   " + ui.Text("delete") + "   "; - try + get { - if (base.Value.Trim() != "") - { - tempTitle = new cms.businesslogic.CMSNode(int.Parse(base.Value.Trim())).Text; - } + return ui.GetText("general", "choose") + " " + ui.GetText("sections", "content"); } - catch { } - - string strScript = "function " + this.ClientID + "_chooseId() {" + - "\nshowPopWin('" + TreeService.GetPickerUrl(true, "content", "content") + "', 300, 400, " + ClientID + "_saveId);" + - //"\nvar treePicker = window.showModalDialog(, 'treePicker', 'dialogWidth=350px;dialogHeight=300px;scrollbars=no;center=yes;border=thin;help=no;status=no') " + - "\n}" + - "\nfunction " + ClientID + "_saveId(treePicker) {" + - "\nsetTimeout('" + ClientID + "_saveIdDo(' + treePicker + ')', 200);" + - "\n}" + - "\nfunction " + ClientID + "_saveIdDo(treePicker) {" + - "\nif (treePicker != undefined) {" + - "\ndocument.getElementById(\"" + this.ClientID + "\").value = treePicker;" + - "\nif (treePicker > 0) {" + - "\numbraco.presentation.webservices.legacyAjaxCalls.GetNodeName(treePicker, " + this.ClientID + "_updateContentTitle" + ");" + - "\n} " + - "\n}" + - "\n} " + - "\nfunction " + this.ClientID + "_updateContentTitle(retVal) {" + - "\ndocument.getElementById(\"" + this.ClientID + "_title\").innerHTML = \"\" + retVal + \"" + deleteLink.Replace("\"", "\\\"") + "\";" + - "\n}" + - "\nfunction " + this.ClientID + "_clear() {" + - "\ndocument.getElementById(\"" + this.ClientID + "_title\").innerHTML = \"\";" + - "\ndocument.getElementById(\"" + this.ClientID + "\").value = \"\";" + - "\n}"; - - try - { - if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) - ScriptManager.RegisterClientScriptBlock(this, this.GetType(), this.ClientID + "_chooseId", strScript, true); - else - Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID + "_chooseId", strScript, true); - } - catch - { - Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID + "_chooseId", strScript, true); - } - // Clear remove link if text if empty - if (base.Value.Trim() == "") - deleteLink = ""; - writer.WriteLine("" + tempTitle + "" + deleteLink + "" + ui.Text("choose") + "...   ");//"); - base.Render(writer); } - #endregion + } } diff --git a/components/editorControls/umbraco.editorControls.csproj b/components/editorControls/umbraco.editorControls.csproj index 9d8a873412..6b6147d6c2 100644 --- a/components/editorControls/umbraco.editorControls.csproj +++ b/components/editorControls/umbraco.editorControls.csproj @@ -152,9 +152,8 @@ {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - umbraco.presentation {651E1350-91B6-44B7-BD60-7207006D7003} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + umbraco.presentation {6EDD2061-82F2-461B-BB6E-879245A832DE} @@ -168,6 +167,7 @@ Code + Code @@ -256,6 +256,11 @@ Code + + MediaChooserScripts.resx + True + True + Code @@ -350,6 +355,11 @@ Designer + + Designer + ResXFileCodeGenerator + MediaChooserScripts.Designer.cs + textFieldDataEditor.cs Designer @@ -372,6 +382,9 @@ false + + + diff --git a/components/macroRenderings/content.cs b/components/macroRenderings/content.cs index 6131d8353b..6f2833b02f 100644 --- a/components/macroRenderings/content.cs +++ b/components/macroRenderings/content.cs @@ -5,111 +5,35 @@ using System.Data.SqlClient; using System.Web.UI; using ClientDependency.Core; using umbraco.IO; +using umbraco.interfaces; +using umbraco.uicontrols.TreePicker; namespace umbraco.macroRenderings { - /// - /// Summary description for content. - /// - [ClientDependency(103, ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")] - [ClientDependency(104, ClientDependencyType.Javascript, "js/submodal/subModal.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Css, "js/submodal/subModal.css", "UmbracoRoot")] - public class content : System.Web.UI.WebControls.WebControl, interfaces.IMacroGuiRendering + + public class content : SimpleContentPicker, IMacroGuiRendering { - private string m_value = ""; - public bool ShowCaption - { - get {return true;} - } + #region IMacroGuiRendering Members - public string Value - { - get { - if (Page.IsPostBack && !String.IsNullOrEmpty(System.Web.HttpContext.Current.Request[this.ClientID])) { - m_value = System.Web.HttpContext.Current.Request[this.ClientID]; - } - return m_value; + string IMacroGuiRendering.Value + { + get + { + return Value; + } + set + { + Value = value; } - set { m_value = value; } - } - - protected override void OnInit(EventArgs e) { - base.OnInit(e); - - // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager - ScriptManager sm = ScriptManager.GetCurrent(Page); - ServiceReference legacyPath = new ServiceReference(SystemDirectories.Webservices + "/legacyAjaxCalls.asmx"); - if (!sm.Services.Contains(legacyPath)) - sm.Services.Add(legacyPath); } - public content() - { - // - // TODO: Add constructor logic here - // - } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) { - - string tempTitle = ""; - string deleteLink = "   " + ui.Text("delete") + "   "; - try { - if (this.Value != "") { - tempTitle = new cms.businesslogic.CMSNode(int.Parse(this.Value)).Text; - } - } catch { } - - writer.WriteLine(""); - - // Clear remove link if text if empty - if (this.Value == "") - deleteLink = ""; - writer.WriteLine("" + tempTitle + "" + deleteLink + "" + ui.Text("choose") + "...   "); - base.Render(writer); + bool IMacroGuiRendering.ShowCaption + { + get { return true; } } - - /* - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - string label = ""; - if (this.Value != "") - { - SqlDataReader pageName = SqlHelper.ExecuteReader(umbraco.GlobalSettings.DbDSN, - CommandType.Text, "select text as nodeName from umbracoNode where id = " + this.Value); - if (pageName.Read()) - label = pageName.GetString(pageName.GetOrdinal("nodeName")) + "
"; - pageName.Close(); - } - writer.WriteLine("" + label + ""); - - writer.WriteLine("Choose item"); - writer.WriteLine(""); - }*/ + #endregion } } diff --git a/components/macroRenderings/media.cs b/components/macroRenderings/media.cs index 33e2a94b96..71755121ff 100644 --- a/components/macroRenderings/media.cs +++ b/components/macroRenderings/media.cs @@ -6,112 +6,33 @@ using System.Data.SqlClient; using System.Web.UI; using ClientDependency.Core; using umbraco.IO; +using umbraco.interfaces; +using umbraco.uicontrols.TreePicker; namespace umbraco.macroRenderings { - /// - /// Summary description for media. - /// - [ClientDependency(103, ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")] - [ClientDependency(104, ClientDependencyType.Javascript, "js/submodal/subModal.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Css, "js/submodal/subModal.css", "UmbracoRoot")] - public class media : System.Web.UI.WebControls.WebControl, interfaces.IMacroGuiRendering + + public class media : SimpleMediaPicker, IMacroGuiRendering { - private string m_value = ""; + #region IMacroGuiRendering Members - public bool ShowCaption - { - get {return true;} - } - - public string Value { - get { - if (Page.IsPostBack && !String.IsNullOrEmpty(System.Web.HttpContext.Current.Request[this.ClientID])) { - m_value = System.Web.HttpContext.Current.Request[this.ClientID]; - } - return m_value; + string IMacroGuiRendering.Value + { + get + { + return Value; + } + set + { + Value = value; } - set { m_value = value; } } - public media() - { - // - // TODO: Add constructor logic here - // - } - - protected override void OnInit(EventArgs e) { - base.OnInit(e); - - - // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager - ScriptManager sm = ScriptManager.GetCurrent(Page); - ServiceReference legacyPath = new ServiceReference(SystemDirectories.Webservices + "/legacyAjaxCalls.asmx"); - if (!sm.Services.Contains(legacyPath)) - sm.Services.Add(legacyPath); + bool IMacroGuiRendering.ShowCaption + { + get { return true; } } - - protected override void Render(System.Web.UI.HtmlTextWriter writer) { - - string tempTitle = ""; - string deleteLink = "   " + ui.Text("delete") + "   "; - try { - if (this.Value != "") { - tempTitle = new cms.businesslogic.CMSNode(int.Parse(this.Value)).Text; - } - } catch { } - - writer.WriteLine(""); - - // Clear remove link if text if empty - if (this.Value == "") - deleteLink = ""; - writer.WriteLine("" + tempTitle + "" + deleteLink + "" + ui.Text("choose") + "...   "); - base.Render(writer); - } - - /* - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - string label = ""; - if (this.Value != "") - { - SqlDataReader pageName = SqlHelper.ExecuteReader(umbraco.GlobalSettings.DbDSN, - CommandType.Text, "select text as nodeName from umbracoNode where id = " + this.Value); - if (pageName.Read()) - label = pageName.GetString(pageName.GetOrdinal("nodeName")) + "
"; - pageName.Close(); - } - writer.WriteLine("" + label + ""); - - writer.WriteLine("Choose item"); - writer.WriteLine(""); - } - */ - - } + #endregion + } } diff --git a/components/macroRenderings/umbraco.macroRenderings.csproj b/components/macroRenderings/umbraco.macroRenderings.csproj index dfb6c914aa..5000b9e60b 100644 --- a/components/macroRenderings/umbraco.macroRenderings.csproj +++ b/components/macroRenderings/umbraco.macroRenderings.csproj @@ -124,6 +124,10 @@ {511F6D8D-7717-440A-9A57-A507E9A8B27F} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ + {6EDD2061-82F2-461B-BB6E-879245A832DE} + umbraco.controls + diff --git a/components/umbraco.controls/CodeArea.cs b/components/umbraco.controls/CodeArea.cs index e517b6d836..d25121c83f 100644 --- a/components/umbraco.controls/CodeArea.cs +++ b/components/umbraco.controls/CodeArea.cs @@ -36,10 +36,12 @@ namespace umbraco.uicontrols { { get { + EnsureChildControls(); return CodeTextBox.Text; } set { + EnsureChildControls(); CodeTextBox.Text = value; } } diff --git a/components/umbraco.controls/TreePicker/BaseTreePicker.cs b/components/umbraco.controls/TreePicker/BaseTreePicker.cs new file mode 100644 index 0000000000..b1718d952a --- /dev/null +++ b/components/umbraco.controls/TreePicker/BaseTreePicker.cs @@ -0,0 +1,223 @@ +using System; +using System.Web.UI; +using ClientDependency.Core; +using ClientDependency.Core.Controls; +using umbraco.interfaces; +using System.Web.UI.WebControls; +using System.Web.UI.HtmlControls; +using umbraco.cms.businesslogic; +namespace umbraco.uicontrols.TreePicker +{ + + [ClientDependency(0, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Css, "modal/style.css", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Javascript, "modal/modal.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoClientManager.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoUtils.js", "UmbracoClient")] + [ValidationProperty("Value")] + public abstract class BaseTreePicker : Control, INamingContainer + { + + protected HiddenField ItemIdValue; + protected HtmlAnchor DeleteLink; + protected HtmlAnchor ChooseLink; + protected HtmlGenericControl ItemTitle; + protected HtmlGenericControl ButtonContainer; + + public BaseTreePicker() + { + ShowDelete = true; + ModalHeight = 400; + ModalWidth = 300; + ShowHeader = true; + } + + /// + /// Wraps the hidden vield value + /// + public string Value + { + get + { + EnsureChildControls(); + return ItemIdValue.Value; + } + set + { + EnsureChildControls(); + ItemIdValue.Value = value; + } + } + + public int ModalWidth { get; set; } + public int ModalHeight { get; set; } + public bool ShowDelete { get; set; } + public bool ShowHeader { get; set; } + + /// + /// Need to specify the tree picker url (iframe) + /// + public abstract string TreePickerUrl { get; } + + /// + /// The title to specify for the picker window + /// + public abstract string ModalWindowTitle { get; } + + /// + /// If item has been selected or stored, this will query the db for it's title + /// + /// + protected virtual string GetItemTitle() + { + if (!string.IsNullOrEmpty(ItemIdValue.Value)) + { + try + { + return new CMSNode(int.Parse(ItemIdValue.Value)).Text; + } + catch (ArgumentException ex) { /*the node does not exist! we will ignore*/ } + } + return ""; + } + + /// + /// Outputs the JavaScript instances used to make this control work + /// + protected virtual string GetJSScript() + { + /* 0 = this control's client id + * 1 = label + * 2 = itemIdValueClientID + * 3 = itemTitleClientID + * 4 = itemPickerUrl + * 5 = popup width + * 6 = popup height + * 7 = show header + * 8 = umbraco path + */ + return string.Format(@" + var mc_{0} = new Umbraco.Controls.TreePicker('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},'{8}');", + new string[] + { + this.ClientID, + ModalWindowTitle, + ItemIdValue.ClientID, + ItemTitle.ClientID, + TreePickerUrl, + ModalWidth.ToString(), + ModalHeight.ToString(), + ShowHeader.ToString().ToLower(), + umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco).TrimEnd('/') + }); + } + + /// + /// Registers the required JS classes required to make this control work + /// + protected virtual void RenderJSComponents() + { + if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) + { + ScriptManager.RegisterStartupScript(this, this.GetType(), this.GetType().ToString(), BaseTreePickerScripts.BaseTreePicker, true); + } + else + { + Page.ClientScript.RegisterClientScriptBlock(typeof(BaseTreePicker), this.GetType().ToString(), BaseTreePickerScripts.BaseTreePicker, true); + } + } + + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + + EnsureChildControls(); + + //disable view state for this control + this.EnableViewState = false; + } + + /// + /// Create the native .net child controls for this control + /// + protected override void CreateChildControls() + { + base.CreateChildControls(); + + //create the hidden field + ItemIdValue = new HiddenField(); + ItemIdValue.ID = "ContentIdValue"; + this.Controls.Add(ItemIdValue); + + ButtonContainer = new HtmlGenericControl("span"); + ButtonContainer.ID = "btns"; + + //add item title with padding + ItemTitle = new HtmlGenericControl("span"); + ItemTitle.ID = "title"; + ItemTitle.Style.Add(HtmlTextWriterStyle.FontWeight, "bold"); + ButtonContainer.Controls.Add(ItemTitle); + ButtonContainer.Controls.Add(new LiteralControl(" ")); + ButtonContainer.Controls.Add(new LiteralControl(" ")); + + //add the delete link with padding + DeleteLink = new HtmlAnchor(); + DeleteLink.HRef = "#"; //set on pre-render + DeleteLink.Style.Add(HtmlTextWriterStyle.Color, "red"); + DeleteLink.Title = ui.GetText("delete"); + DeleteLink.InnerText = ui.GetText("delete"); + ButtonContainer.Controls.Add(DeleteLink); + ButtonContainer.Controls.Add(new LiteralControl(" ")); + ButtonContainer.Controls.Add(new LiteralControl(" ")); + if (!ShowDelete) + { + DeleteLink.Style.Add(HtmlTextWriterStyle.Display, "none"); + } + + this.Controls.Add(ButtonContainer); + + //add choose link with padding + ChooseLink = new HtmlAnchor(); + ChooseLink.HRef = "#"; //filled in on pre-render + ChooseLink.InnerText = ui.GetText("choose") + "..."; + this.Controls.Add(ChooseLink); + + } + + /// + /// Registers the JavaScript required for the control to function and hides/shows controls depending on it's properties + /// + /// + protected override void OnPreRender(EventArgs e) + { + base.OnPreRender(e); + + //hide the buttons if no item, otherwise get the item title + if (string.IsNullOrEmpty(ItemIdValue.Value)) + { + ButtonContainer.Style.Add(HtmlTextWriterStyle.Display, "none"); + } + else + { + ItemTitle.InnerText = GetItemTitle(); + } + + ChooseLink.HRef = string.Format("javascript:mc_{0}.LaunchPicker();", this.ClientID); + DeleteLink.HRef = string.Format("javascript:mc_{0}.ClearSelection();", this.ClientID); + + RenderJSComponents(); + + if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack) + { + ScriptManager.RegisterStartupScript(this, this.GetType(), this.ClientID + "TreePicker", GetJSScript(), true); + } + else + { + Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID + "TreePicker", GetJSScript(), true); + } + + } + + + } +} diff --git a/components/umbraco.controls/TreePicker/BaseTreePicker.js b/components/umbraco.controls/TreePicker/BaseTreePicker.js new file mode 100644 index 0000000000..2992bfe471 --- /dev/null +++ b/components/umbraco.controls/TreePicker/BaseTreePicker.js @@ -0,0 +1,70 @@ +/// + +Umbraco.Sys.registerNamespace("Umbraco.Controls"); + +(function($) { + Umbraco.Controls.TreePicker = function(clientId, label, itemIdValueClientID, itemTitleClientID, itemPickerUrl, width, height, showHeader, umbracoPath) { + var obj = { + _itemPickerUrl: itemPickerUrl, + _webServiceUrl: umbracoPath + "/webservices/legacyAjaxCalls.asmx/GetNodeName", + _label: label, + _width: width, + _height: height, + _itemIdValueClientID: itemIdValueClientID, + _itemTitleClientID: itemTitleClientID, + _showHeader: showHeader, + _clientId: clientId, + + GetValue: function() { + return $("#" + this._itemIdValueClientID).val(); + }, + + 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); }); + }, + + SaveSelection: function(e) { + if (!e.outVal) { + return; + } + $("#" + this._itemIdValueClientID).val(e.outVal); + var _this = this; + $.ajax({ + type: "POST", + url: _this._webServiceUrl, + data: '{ "nodeId": ' + e.outVal + ' }', + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function(msg) { + $("#" + _this._itemTitleClientID).html(msg.d); + $("#" + _this._itemTitleClientID).parent().show(); + } + }); + }, + + ClearSelection: function() { + $("#" + this._itemTitleClientID).parent().hide(); + $("#" + this._itemIdValueClientID).val(''); + } + }; + + //store this instance (by counter and id) so we can retrieve it later if needed + Umbraco.Controls.TreePicker.inst[++Umbraco.Controls.TreePicker.cntr] = obj; + Umbraco.Controls.TreePicker.inst[clientId] = obj; + + return obj; + } + + // Static methods + + //return the existing picker object based on client id of the control + Umbraco.Controls.TreePicker.GetPickerById = function(id) { + return Umbraco.Controls.TreePicker.inst[id] || null; + }; + + // instance manager + Umbraco.Controls.TreePicker.cntr = 0; + Umbraco.Controls.TreePicker.inst = {}; + +})(jQuery); diff --git a/components/umbraco.controls/TreePicker/BaseTreePickerScripts.Designer.cs b/components/umbraco.controls/TreePicker/BaseTreePickerScripts.Designer.cs new file mode 100644 index 0000000000..75d186dfbc --- /dev/null +++ b/components/umbraco.controls/TreePicker/BaseTreePickerScripts.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.uicontrols.TreePicker { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class BaseTreePickerScripts { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal BaseTreePickerScripts() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("umbraco.uicontrols.TreePicker.BaseTreePickerScripts", typeof(BaseTreePickerScripts).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to /// <reference path="/umbraco_client/Application/NamespaceManager.js" /> + /// + ///Umbraco.Sys.registerNamespace("Umbraco.Controls"); + /// + ///(function($) { + /// Umbraco.Controls.TreePicker = function(label, itemIdValueClientID, itemTitleClientID, itemPickerUrl, width, height, showHeader, umbracoPath) { + /// return { + /// _itemPickerUrl: itemPickerUrl, + /// _webServiceUrl: umbracoPath + "/webservices/legacyAjaxCalls.asmx/GetNodeName", + /// _label: label, + /// _width: width, + /// [rest of string was truncated]";. + /// + internal static string BaseTreePicker { + get { + return ResourceManager.GetString("BaseTreePicker", resourceCulture); + } + } + } +} diff --git a/components/umbraco.controls/TreePicker/BaseTreePickerScripts.resx b/components/umbraco.controls/TreePicker/BaseTreePickerScripts.resx new file mode 100644 index 0000000000..628b40df7b --- /dev/null +++ b/components/umbraco.controls/TreePicker/BaseTreePickerScripts.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + BaseTreePicker.js;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file diff --git a/components/umbraco.controls/TreePicker/SimpleContentPicker.cs b/components/umbraco.controls/TreePicker/SimpleContentPicker.cs new file mode 100644 index 0000000000..9866048294 --- /dev/null +++ b/components/umbraco.controls/TreePicker/SimpleContentPicker.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace umbraco.uicontrols.TreePicker +{ + public class SimpleContentPicker : BaseTreePicker + { + public override string TreePickerUrl + { + get + { + return TreeUrlGenerator.GetPickerUrl("content", "content"); + } + } + + public override string ModalWindowTitle + { + get + { + return ui.GetText("general", "choose") + " " + ui.GetText("sections", "content"); + } + } + } +} diff --git a/components/umbraco.controls/TreePicker/SimpleMediaPicker.cs b/components/umbraco.controls/TreePicker/SimpleMediaPicker.cs new file mode 100644 index 0000000000..d91ca6cbba --- /dev/null +++ b/components/umbraco.controls/TreePicker/SimpleMediaPicker.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace umbraco.uicontrols.TreePicker +{ + public class SimpleMediaPicker : BaseTreePicker + { + public override string TreePickerUrl + { + get + { + return TreeUrlGenerator.GetPickerUrl("media", "media"); + } + } + + public override string ModalWindowTitle + { + get + { + return ui.GetText("general", "choose") + " " + ui.GetText("sections", "media"); + } + } + } +} diff --git a/components/umbraco.controls/TreeUrlGenerator.cs b/components/umbraco.controls/TreeUrlGenerator.cs new file mode 100644 index 0000000000..a136772028 --- /dev/null +++ b/components/umbraco.controls/TreeUrlGenerator.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace umbraco.uicontrols +{ + /// + /// This class will generate the URLs for iframe tree pages. + /// Generally used to get the a tree picker url. + /// + /// + /// This was created in 4.1 so that this helper class can be exposed to other assemblies since + /// it only existed in the presentation assembly in previous versions + /// + public class TreeUrlGenerator + { + + public const string TREE_URL = "tree.aspx"; + public const string INIT_URL = "treeinit.aspx"; + public const string PICKER_URL = "treepicker.aspx"; + + private int? m_startNodeID; + private string m_treeType; + private bool? m_showContextMenu; + private bool? m_isDialog; + private string m_app; + private string m_nodeKey; + private string m_functionToCall; + + #region Public Properties + + public string FunctionToCall + { + get { return m_functionToCall; } + set { m_functionToCall = value; } + } + + public string NodeKey + { + get { return m_nodeKey; } + set { m_nodeKey = value; } + } + + public int StartNodeID + { + get { return m_startNodeID ?? -1; } + set { m_startNodeID = value; } + } + + public string TreeType + { + get { return m_treeType; } + set { m_treeType = value; } + } + + public bool ShowContextMenu + { + get { return m_showContextMenu ?? true; } + set { m_showContextMenu = value; } + } + + public bool IsDialog + { + get { return m_isDialog ?? false; } + set { m_isDialog = value; } + } + + public string App + { + get { return m_app; } + set { m_app = value; } + } + #endregion + + /// + /// Returns the url for servicing the xml tree request based on the parameters specified on this class. + /// + /// Tree service url as a string + public string GetServiceUrl() + { + return umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/" + GetUrl(TREE_URL); + } + + /// + /// Static method to return the tree service url with the specified parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static string GetServiceUrl(int? startNodeID, string treeType, bool? showContextMenu, + bool? isDialog, string app, string nodeKey, string functionToCall) + { + TreeUrlGenerator treeSvc = new TreeUrlGenerator() + { + StartNodeID = startNodeID ?? -1, + TreeType = treeType, + ShowContextMenu = showContextMenu ?? true, + IsDialog = isDialog ?? false, + App = app, + NodeKey = nodeKey, + FunctionToCall = functionToCall + }; + return treeSvc.GetServiceUrl(); + } + + /// + /// Returns the url for initializing the tree based on the parameters specified on this class + /// + /// + public string GetInitUrl() + { + return umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/" + GetUrl(INIT_URL); + } + + /// + /// static method to return the tree init url with the specified parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static string GetInitUrl(int? startNodeID, string treeType, bool? showContextMenu, + bool? isDialog, string app, string nodeKey, string functionToCall) + { + TreeUrlGenerator treeSvc = new TreeUrlGenerator() + { + StartNodeID = startNodeID ?? -1, + TreeType = treeType, + ShowContextMenu = showContextMenu ?? true, + IsDialog = isDialog ?? false, + App = app, + NodeKey = nodeKey, + FunctionToCall = functionToCall + }; + return treeSvc.GetInitUrl(); + } + + /// + /// Returns the url for the tree picker (used on modal windows) based on the parameters specified on this class + /// + public static string GetPickerUrl(string app, string treeType) + { + TreeUrlGenerator treeSvc = new TreeUrlGenerator(); + treeSvc.App = app; + treeSvc.TreeType = treeType; + return treeSvc.GetPickerUrl(); + } + + /// + /// Returns the url for the tree picker (used on modal windows) based on the parameters specified on this class + /// + public string GetPickerUrl() + { + return umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/" + GetUrl(PICKER_URL); + } + + [Obsolete("No longer used as useSubModal no longer has any relavence")] + public static string GetPickerUrl(bool useSubModal, string app, string treeType) + { + return GetPickerUrl(app, treeType); + } + [Obsolete("No longer used as useSubModal no longer has any relavence")] + public string GetPickerUrl(bool useSubModal) + { + return GetPickerUrl(); + } + + /// + /// Generates the URL parameters for the tree service. + /// + /// the base url (i.e. tree.aspx) + /// + protected virtual string GetUrl(string pageUrl) + { + StringBuilder sb = new StringBuilder(); + + sb.Append(pageUrl); + //insert random + sb.Append(string.Format("?rnd={0}", Guid.NewGuid().ToString("N"))); + + sb.Append(string.Format("&id={0}", this.StartNodeID.ToString())); + if (!string.IsNullOrEmpty(this.TreeType)) sb.Append(string.Format("&treeType={0}", this.TreeType)); + if (!string.IsNullOrEmpty(this.NodeKey)) sb.Append(string.Format("&nodeKey={0}", this.NodeKey)); + sb.Append(string.Format("&contextMenu={0}", this.ShowContextMenu.ToString().ToLower())); + sb.Append(string.Format("&isDialog={0}", this.IsDialog.ToString().ToLower())); + if (!string.IsNullOrEmpty(this.App)) sb.Append(string.Format("&app={0}", this.App)); + + return sb.ToString(); + } + + } +} diff --git a/components/umbraco.controls/feedback.cs b/components/umbraco.controls/feedback.cs index eb38cd9914..9e3c1b2c24 100644 --- a/components/umbraco.controls/feedback.cs +++ b/components/umbraco.controls/feedback.cs @@ -45,7 +45,7 @@ namespace umbraco.uicontrols { styleString += key + ":" + this.Style[key] + ";"; } - writer.WriteLine("

"); + writer.WriteLine("

"); writer.WriteLine(_text); writer.WriteLine("

"); } diff --git a/components/umbraco.controls/umbraco.controls.csproj b/components/umbraco.controls/umbraco.controls.csproj index 775f15db1b..6aa427313d 100644 --- a/components/umbraco.controls/umbraco.controls.csproj +++ b/components/umbraco.controls/umbraco.controls.csproj @@ -7,7 +7,7 @@ {6EDD2061-82F2-461B-BB6E-879245A832DE} Library Properties - umbraco.controls + umbraco.uicontrols controls SAK SAK @@ -64,6 +64,15 @@ + + + True + True + BaseTreePickerScripts.resx + + + + @@ -86,6 +95,23 @@ {E469A9CE-1BEC-423F-AC44-713CD72457EA} umbraco.businesslogic + + {CCD75EC3-63DB-4184-B49D-51C1DD337230} + umbraco.cms + + + {511F6D8D-7717-440A-9A57-A507E9A8B27F} + umbraco.interfaces + + + + + + + + ResXFileCodeGenerator + BaseTreePickerScripts.Designer.cs + - \ No newline at end of file + diff --git a/foreign dlls/ClientDependency.Core.dll b/foreign dlls/ClientDependency.Core.dll index eae13120f3..d02843e2cc 100644 Binary files a/foreign dlls/ClientDependency.Core.dll and b/foreign dlls/ClientDependency.Core.dll differ diff --git a/foreign dlls/UmbracoExamine.Core.dll b/foreign dlls/UmbracoExamine.Core.dll index 5daf59a208..a76d093f75 100644 Binary files a/foreign dlls/UmbracoExamine.Core.dll and b/foreign dlls/UmbracoExamine.Core.dll differ diff --git a/foreign dlls/UmbracoExamine.Providers.dll b/foreign dlls/UmbracoExamine.Providers.dll index e48efd8f90..48877c8ab7 100644 Binary files a/foreign dlls/UmbracoExamine.Providers.dll and b/foreign dlls/UmbracoExamine.Providers.dll differ diff --git a/umbraco/businesslogic/Application.cs b/umbraco/businesslogic/Application.cs index c60b75efa8..82817ee774 100644 --- a/umbraco/businesslogic/Application.cs +++ b/umbraco/businesslogic/Application.cs @@ -211,7 +211,7 @@ namespace umbraco.BusinessLogic { if (GlobalSettings.Configured) { - List types = TypeFinder.FindClassesOfType(false); + List types = TypeFinder.FindClassesOfType(); foreach (Type t in types) { try diff --git a/umbraco/businesslogic/BasePages/ClientTools.cs b/umbraco/businesslogic/BasePages/ClientTools.cs index 9ba543ae8c..ca36941b77 100644 --- a/umbraco/businesslogic/BasePages/ClientTools.cs +++ b/umbraco/businesslogic/BasePages/ClientTools.cs @@ -54,11 +54,23 @@ namespace umbraco.BasePages public static string MoveNode { get { return GetMainTree + ".moveNode('{0}', '{1}');"; } } public static string ReloadActionNode { get { return GetMainTree + ".reloadActionNode({0}, {1}, null);"; } } public static string SetActiveTreeType { get { return GetMainTree + ".setActiveTreeType('{0}');"; } } - public static string CloseModalWindow { get { return GetMainWindow + ".closeModal();"; } } - public static string OpenModalWindow(string url, string name, int height, int width) - { - return string.Format(GetMainWindow + ".openModal('{0}','{1}',{2},{3});", url, name, height, width); - } + public static string CloseModalWindow() + { + return string.Format("{0}.closeModalWindow();", ClientMgrScript); + } + public static string CloseModalWindow(string rVal) + { + return string.Format("{0}.closeModalWindow('{1}');", ClientMgrScript, rVal); + } + public static string OpenModalWindow(string url, string name, int width, int height) + { + return OpenModalWindow(url, name, true, width, height, 0, 0, "", ""); + } + public static string OpenModalWindow(string url, string name, bool showHeader, int width, int height, int top, int leftOffset, string closeTriggers, string onCloseCallback) + { + return string.Format("{0}.openModalWindow('{1}', '{2}', {3}, {4}, {5}, {6}, {7}, '{8}', '{9}');", + new object[] { ClientMgrScript, url, name, showHeader.ToString().ToLower(), width, height, top, leftOffset, closeTriggers, onCloseCallback }); + } } private Page m_page; @@ -238,14 +250,25 @@ namespace umbraco.BasePages } /// - /// Closes the Umbraco dialog window if it is open + /// Closes the Umbraco dialog window if it is open /// - public ClientTools CloseModalWindow() + /// specify a value to return to add to the onCloseCallback method if one was specified in the OpenModalWindow method + /// + public ClientTools CloseModalWindow(string returnVal) { - RegisterClientScript(Scripts.CloseModalWindow); + RegisterClientScript(Scripts.CloseModalWindow(returnVal)); return this; } - + /// + /// Closes the umbraco dialog window if it is open + /// + /// + public ClientTools CloseModalWindow() + { + return CloseModalWindow(""); + } + + /// /// Opens a modal window /// @@ -254,13 +277,11 @@ namespace umbraco.BasePages /// /// /// - public ClientTools OpenModalWindow(string url, string name, int height, int width) + public ClientTools OpenModalWindow(string url, string name, bool showHeader, int width, int height, int top, int leftOffset, string closeTriggers, string onCloseCallback) { - RegisterClientScript(Scripts.OpenModalWindow(url, name, height, width)); + RegisterClientScript(Scripts.OpenModalWindow(url, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback)); return this; } - - private Page GetCurrentPage() { diff --git a/umbraco/businesslogic/Utils/TypeFinder.cs b/umbraco/businesslogic/Utils/TypeFinder.cs index 68987c63cf..935ffc9577 100644 --- a/umbraco/businesslogic/Utils/TypeFinder.cs +++ b/umbraco/businesslogic/Utils/TypeFinder.cs @@ -14,13 +14,37 @@ namespace umbraco.BusinessLogic.Utils public static class TypeFinder { - /// + + + /// + /// Searches all loaded assemblies for classes of the type passed in. + /// + /// The type of object to search for + /// A list of found types + public static List FindClassesOfType() + { + return FindClassesOfType(true); + } + + /// + /// Searches all loaded assemblies for classes of the type passed in. + /// + /// The type of object to search for + /// true if a seperate app domain should be used to query the types. This is safer as it is able to clear memory after loading the types. + /// A list of found types + public static List FindClassesOfType(bool useSeperateAppDomain) + { + return FindClassesOfType(useSeperateAppDomain, true); + } + + /// /// Searches all loaded assemblies for classes of the type passed in. /// /// The type of object to search for /// true if a seperate app domain should be used to query the types. This is safer as it is able to clear memory after loading the types. + /// True to only return classes that can be constructed /// A list of found types - public static List FindClassesOfType(bool useSeperateAppDomain) + public static List FindClassesOfType(bool useSeperateAppDomain, bool onlyConcreteClasses) { if (useSeperateAppDomain) { @@ -32,10 +56,10 @@ namespace umbraco.BusinessLogic.Utils foreach (string type in strTypes) types.Add(Type.GetType(type)); - return types; + return types.FindAll(OnlyConcreteClasses(typeof(T), onlyConcreteClasses)); } else - return FindClassesOfType(typeof(T)); + return FindClassesOfType(typeof(T), onlyConcreteClasses); } /// @@ -43,7 +67,7 @@ namespace umbraco.BusinessLogic.Utils /// /// The type. /// A list of found classes - private static List FindClassesOfType(Type type) + private static List FindClassesOfType(Type type, bool onlyConcreteClasses) { bool searchGAC = false; @@ -65,9 +89,7 @@ namespace umbraco.BusinessLogic.Utils List listOfTypes = new List(); listOfTypes.AddRange(publicTypes); - List foundTypes = listOfTypes.FindAll( - delegate(Type t) { return (type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract); } - ); + List foundTypes = listOfTypes.FindAll(OnlyConcreteClasses(type, onlyConcreteClasses)); Type[] outputTypes = new Type[foundTypes.Count]; foundTypes.CopyTo(outputTypes); classesOfType.AddRange(outputTypes); @@ -76,5 +98,10 @@ namespace umbraco.BusinessLogic.Utils return classesOfType; } + private static Predicate OnlyConcreteClasses(Type type, bool onlyConcreteClasses) + { + return t => (type.IsAssignableFrom(t) && (onlyConcreteClasses ? (t.IsClass && !t.IsAbstract) : true)); + } + } } diff --git a/umbraco/cms/Actions/Action.cs b/umbraco/cms/Actions/Action.cs index 55a8e77068..8e558159ca 100644 --- a/umbraco/cms/Actions/Action.cs +++ b/umbraco/cms/Actions/Action.cs @@ -45,7 +45,7 @@ namespace umbraco.BusinessLogic.Actions if (_actionHandlers.Count > 0) return; - List foundIActionHandlers = TypeFinder.FindClassesOfType(true); + List foundIActionHandlers = TypeFinder.FindClassesOfType(); foreach (Type type in foundIActionHandlers) { IActionHandler typeInstance; @@ -63,7 +63,7 @@ namespace umbraco.BusinessLogic.Actions if (_actions.Count > 0) return; - List foundIActions = TypeFinder.FindClassesOfType(true); + List foundIActions = TypeFinder.FindClassesOfType(); foreach (Type type in foundIActions) { IAction typeInstance; diff --git a/umbraco/cms/businesslogic/Packager/PackageInstance/PackageActions.cs b/umbraco/cms/businesslogic/Packager/PackageInstance/PackageActions.cs index 1b93dae4be..3e7963a290 100644 --- a/umbraco/cms/businesslogic/Packager/PackageInstance/PackageActions.cs +++ b/umbraco/cms/businesslogic/Packager/PackageInstance/PackageActions.cs @@ -28,7 +28,7 @@ namespace umbraco.cms.businesslogic.packager { private static void RegisterPackageActions() { - List types = TypeFinder.FindClassesOfType(true); + List types = TypeFinder.FindClassesOfType(); foreach (Type t in types) { IPackageAction typeInstance = Activator.CreateInstance(t) as IPackageAction; diff --git a/umbraco/cms/businesslogic/datatype/factory.cs b/umbraco/cms/businesslogic/datatype/factory.cs index b3e5b3dc0f..9637b2d40a 100644 --- a/umbraco/cms/businesslogic/datatype/factory.cs +++ b/umbraco/cms/businesslogic/datatype/factory.cs @@ -72,7 +72,7 @@ namespace umbraco.cms.businesslogic.datatype.controls private static void Initialize() { // Get all datatypes from interface - List types = TypeFinder.FindClassesOfType(true); + List types = TypeFinder.FindClassesOfType(); getDataTypes(types); } diff --git a/umbraco/cms/umbraco.cms.csproj b/umbraco/cms/umbraco.cms.csproj index 44d6cff307..28957121cd 100644 --- a/umbraco/cms/umbraco.cms.csproj +++ b/umbraco/cms/umbraco.cms.csproj @@ -118,10 +118,6 @@ False ..\..\foreign dlls\TidyNet.dll - - {6EDD2061-82F2-461B-BB6E-879245A832DE} - umbraco.controls - umbraco.businesslogic {E469A9CE-1BEC-423F-AC44-713CD72457EA} diff --git a/umbraco/interfaces/IDataEditor.cs b/umbraco/interfaces/IDataEditor.cs index caa44acbe0..abb4273cf6 100644 --- a/umbraco/interfaces/IDataEditor.cs +++ b/umbraco/interfaces/IDataEditor.cs @@ -31,16 +31,4 @@ namespace umbraco.interfaces /// The editor. System.Web.UI.Control Editor{get;} } - - /// - /// The alternative Data Editor which supports AJAX - /// - public interface IDataEditorAjaxAlternative - { - /// - /// Gets the ajax editor. - /// - /// The ajax editor. - System.Web.UI.Control AjaxEditor { get;} - } } diff --git a/umbraco/interfaces/IDataEditorAjaxAlternative.cs b/umbraco/interfaces/IDataEditorAjaxAlternative.cs new file mode 100644 index 0000000000..c96e5478a2 --- /dev/null +++ b/umbraco/interfaces/IDataEditorAjaxAlternative.cs @@ -0,0 +1,16 @@ +using System; + +namespace umbraco.interfaces +{ + /// + /// The alternative Data Editor which supports AJAX + /// + public interface IDataEditorAjaxAlternative + { + /// + /// Gets the ajax editor. + /// + /// The ajax editor. + System.Web.UI.Control AjaxEditor { get; } + } +} diff --git a/umbraco/interfaces/umbraco.interfaces.csproj b/umbraco/interfaces/umbraco.interfaces.csproj index 4c58994525..71d1192026 100644 --- a/umbraco/interfaces/umbraco.interfaces.csproj +++ b/umbraco/interfaces/umbraco.interfaces.csproj @@ -112,6 +112,7 @@ Code + Code diff --git a/umbraco/presentation/config/ExamineIndex.config b/umbraco/presentation/config/ExamineIndex.config index b29e5f812a..03ae727340 100644 --- a/umbraco/presentation/config/ExamineIndex.config +++ b/umbraco/presentation/config/ExamineIndex.config @@ -23,8 +23,8 @@ More information and documentation can be found on CodePlex: http://umbracoexami - \ No newline at end of file diff --git a/umbraco/presentation/config/ExamineSettings.config b/umbraco/presentation/config/ExamineSettings.config index 5fe6e6756a..5831d191d6 100644 --- a/umbraco/presentation/config/ExamineSettings.config +++ b/umbraco/presentation/config/ExamineSettings.config @@ -5,7 +5,7 @@ This configuration file can be extended to add your own search/index providers. Index sets can be defined in the ExamineIndex.config if you're using the standard provider model. More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com ---> +--> @@ -14,6 +14,12 @@ More information and documentation can be found on CodePlex: http://umbracoexami enabled="true" debug="false" supportUnpublished="true"/> + diff --git a/umbraco/presentation/install/default.aspx b/umbraco/presentation/install/default.aspx index b6fc96430d..0e195d932c 100644 --- a/umbraco/presentation/install/default.aspx +++ b/umbraco/presentation/install/default.aspx @@ -48,7 +48,7 @@ } function openDemoModal(id, name) { - openModal("http://packages.umbraco.org/viewPackageData.aspx?id=" + id, name, 550, 750) + UmbClientMgr.openModalWindow("http://packages.umbraco.org/viewPackageData.aspx?id=" + id, name, true, 750, 550) return false; } @@ -62,8 +62,9 @@ - - + + +
diff --git a/umbraco/presentation/install/default.aspx.designer.cs b/umbraco/presentation/install/default.aspx.designer.cs index 8be2aefc2a..c4422e301f 100644 --- a/umbraco/presentation/install/default.aspx.designer.cs +++ b/umbraco/presentation/install/default.aspx.designer.cs @@ -49,6 +49,15 @@ namespace umbraco.presentation.install { /// protected global::ClientDependency.Core.Controls.JsInclude JsInclude4; + /// + /// JsInclude3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude3; + /// /// JsInclude1 control. /// diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index dd6adbafa9..d22dc84458 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -140,7 +140,7 @@ 3.5 - + System.Web.Services @@ -425,6 +425,24 @@ + + ImageViewer.ascx + ASPXCodeBehind + + + ImageViewer.ascx + + + ImageViewerUpdater.asmx + Component + + + UploadMediaImage.ascx + ASPXCodeBehind + + + UploadMediaImage.ascx + ContentTypeControlNew.ascx ASPXCodeBehind @@ -457,17 +475,19 @@ passwordChanger.ascx - ProgressBar.ascx ASPXCodeBehind + ProgressBar.ascx ProgressBar.ascx - + + + TreeControl.ascx ASPXCodeBehind - + TreeControl.ascx @@ -1187,16 +1207,15 @@ + + Code + + MacroContainerService.asmx Component - - MediaPickerService.asmx - Component - - TreeClientService.asmx Component @@ -1442,24 +1461,35 @@ + + + - - - - + + + + + + + + + + + + @@ -1531,7 +1561,6 @@ - @@ -1933,10 +1962,6 @@ - - - - @@ -2686,7 +2711,6 @@ - @@ -2752,7 +2776,6 @@ umbraco.xsd - diff --git a/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs b/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs index 05764a1069..6a639bc15b 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs @@ -17,14 +17,14 @@ namespace umbraco.presentation.LiveEditing.Controls /// Provides public properties, events and methods for Live Editing controls. /// Add this control to a (master) page to enable Live Editing. ///
- - //[ClientDependency(2, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")] - //[ClientDependency(3, ClientDependencyType.Javascript, "Application/UmbracoClientManager.js", "UmbracoClient")] - //[ClientDependency(3, ClientDependencyType.Javascript, "js/language.aspx", "UmbracoRoot")] - + [ClientDependency(0, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")] [ClientDependency(1, ClientDependencyType.Css, "LiveEditing/CSS/LiveEditing.css", "UmbracoRoot")] - [ClientDependency(1, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient", InvokeJavascriptMethodOnLoad = "jQuery.noConflict")] - [ClientDependency(2, ClientDependencyType.Javascript, "js/UmbracoSpeechBubble.js", "UmbracoRoot", InvokeJavascriptMethodOnLoad = "InitUmbracoSpeechBubble")] + [ClientDependency(1, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient")] + [ClientDependency(2, ClientDependencyType.Javascript, "Application/JQuery/jquery.noconflict-invoke.js", "UmbracoClient")] + [ClientDependency(3, ClientDependencyType.Javascript, "js/UmbracoSpeechBubble.js", "UmbracoRoot")] + [ClientDependency(4, ClientDependencyType.Javascript, "js/UmbracoSpeechBubbleInit.js", "UmbracoRoot")] + [ClientDependency(10, ClientDependencyType.Javascript, "Application/UmbracoUtils.js", "UmbracoClient")] + [ClientDependency(20, ClientDependencyType.Javascript, "Application/UmbracoClientManager.js", "UmbracoClient")] public class LiveEditingManager : Control { diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs index 56335a66a6..9cfa7ee286 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs @@ -1,7 +1,7 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; -using AjaxControlToolkit; +//using AjaxControlToolkit; using umbraco.cms.businesslogic.web; using umbraco.presentation.LiveEditing.Controls; using Content = umbraco.cms.businesslogic.Content; @@ -18,7 +18,7 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule protected ImageButton m_CreateButton = new ImageButton(); protected Panel m_CreateModal = new Panel(); - protected ModalPopupExtender m_CreateModalExtender = new ModalPopupExtender(); + //protected ModalPopupExtender m_CreateModalExtender = new ModalPopupExtender(); protected TextBox m_NameTextBox = new TextBox(); protected DropDownList m_AllowedDocTypesDropdown = new DropDownList(); @@ -75,14 +75,14 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule m_CancelCreateButton.Text = "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()"); + //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("
")); diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs index 9f0d2ab965..3ab539ed5b 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs @@ -21,8 +21,9 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing /// Control that wraps the editor control to edit a field in Live Editing mode. /// [ClientDependency(1, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient")] - [ClientDependency(21, ClientDependencyType.Javascript, "LiveEditing/Modules/ItemEditing/ItemEditing.js", "UmbracoRoot", InvokeJavascriptMethodOnLoad = "initializeGlobalItemEditing")] - [ClientDependency(21, ClientDependencyType.Javascript, "tinymce3/tiny_mce_src.js", "UmbracoClient")] //For TinyMCE to work in LiveEdit, we need to ensure that this script is run before it loads... + [ClientDependency(21, ClientDependencyType.Javascript, "LiveEditing/Modules/ItemEditing/ItemEditing.js", "UmbracoRoot")] + [ClientDependency(22, ClientDependencyType.Javascript, "LiveEditing/Modules/ItemEditing/ItemEditingInvoke.js", "UmbracoRoot")] + [ClientDependency(23, ClientDependencyType.Javascript, "tinymce3/tiny_mce_src.js", "UmbracoClient")] //For TinyMCE to work in LiveEdit, we need to ensure that this script is run before it loads... public class ItemEditor : UpdatePanel { #region Protected Constants diff --git a/umbraco/presentation/umbraco/Trees/BaseContentTree.cs b/umbraco/presentation/umbraco/Trees/BaseContentTree.cs index 43b696eff0..7c31331c32 100644 --- a/umbraco/presentation/umbraco/Trees/BaseContentTree.cs +++ b/umbraco/presentation/umbraco/Trees/BaseContentTree.cs @@ -58,7 +58,7 @@ namespace umbraco.cms.presentation.Trees if (!String.IsNullOrEmpty(this.FunctionToCall)) { Javascript.Append("function openContent(id) {\n"); - Javascript.Append(this.FunctionToCall + "(id)\n"); + Javascript.Append(this.FunctionToCall + "(id);\n"); Javascript.Append("}\n"); } else if (!this.IsDialog) @@ -70,20 +70,20 @@ function openContent(id) { } "); } - else - { - //TODO: SD: Find out how what this does...? - Javascript.Append( - @" -function openContent(id) { - if (parent.opener) - parent.opener.dialogHandler(id); - else - parent.dialogHandler(id); -} - -"); - } + //TODO: SD: UPDATE ALL TREE CODE SO THAT THE FUNCTIONTOCALL IS EXPLICITLY SET WHEN DIALOGHANDLER IS REQUIRED! + // else +// { +// Javascript.Append( +// @" +//function openContent(id) { +// if (parent.opener) +// parent.opener.dialogHandler(id); +// else +// parent.dialogHandler(id); +//} +// +//"); +// } } @@ -214,14 +214,14 @@ function openContent(id) { } protected void SetActionAttribute(ref XmlTreeNode treeElement, Document dd) { - //TODO: Work out why the DialogMode isn't working + // Check for dialog behaviour - if (this.DialogMode == TreeDialogModes.fulllink && !this.IsDialog) + if (this.DialogMode == TreeDialogModes.fulllink ) { string nodeLink = CreateNodeLink(dd); treeElement.Action = String.Format("javascript:openContent('{0}');", nodeLink); } - else if (this.IsDialog) //(this.DialogMode == TreeDialogModes.locallink) + else if (this.DialogMode == TreeDialogModes.locallink) { string nodeLink = string.Format("{{localLink:{0}}}", dd.Id); // try to make a niceurl too diff --git a/umbraco/presentation/umbraco/Trees/BaseMediaTree.cs b/umbraco/presentation/umbraco/Trees/BaseMediaTree.cs index e6f8833384..fac401638d 100644 --- a/umbraco/presentation/umbraco/Trees/BaseMediaTree.cs +++ b/umbraco/presentation/umbraco/Trees/BaseMediaTree.cs @@ -57,7 +57,7 @@ namespace umbraco.cms.presentation.Trees if (!string.IsNullOrEmpty(this.FunctionToCall)) { Javascript.Append("function openMedia(id) {\n"); - Javascript.Append(this.FunctionToCall + "(id)\n"); + Javascript.Append(this.FunctionToCall + "(id);\n"); Javascript.Append("}\n"); } else if (!this.IsDialog) @@ -69,19 +69,19 @@ function openMedia(id) { } "); } - else - { - //TODO: SD: Find out how what this does...? - Javascript.Append( - @" -function openMedia(id) { - if (parent.opener) - parent.opener.dialogHandler(id); - else - parent.dialogHandler(id); -} -"); - } + //TODO: SD: UPDATE ALL TREE CODE SO THAT THE FUNCTIONTOCALL IS EXPLICITLY SET WHEN DIALOGHANDLER IS REQUIRED! + // else +// { +// Javascript.Append( +// @" +//function openMedia(id) { +// if (parent.opener) +// parent.opener.dialogHandler(id); +// else +// parent.dialogHandler(id); +//} +//"); +// } } public override void Render(ref XmlTree tree) diff --git a/umbraco/presentation/umbraco/Trees/BaseTree.cs b/umbraco/presentation/umbraco/Trees/BaseTree.cs index 372b4734e5..a143bd69d2 100644 --- a/umbraco/presentation/umbraco/Trees/BaseTree.cs +++ b/umbraco/presentation/umbraco/Trees/BaseTree.cs @@ -291,6 +291,7 @@ namespace umbraco.cms.presentation.Trees this.IsDialog = treeParams.IsDialog; this.ShowContextMenu = treeParams.ShowContextMenu; this.id = treeParams.StartNodeID; + if (!treeParams.ShowContextMenu) this.RootNode.Menu = null; } diff --git a/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs b/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs index ae7dd12947..a85274d803 100644 --- a/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs +++ b/umbraco/presentation/umbraco/Trees/ContentRecycleBin.cs @@ -97,6 +97,12 @@ namespace umbraco.cms.presentation.Trees } } + /// + /// Override the render js so no duplicate js is rendered. + /// + /// + public override void RenderJS(ref StringBuilder Javascript) { } + ///// ///// Returns the tree service url to render the tree. Ensures that IsRecycleBin is flagged. ///// diff --git a/umbraco/presentation/umbraco/Trees/ITreeService.cs b/umbraco/presentation/umbraco/Trees/ITreeService.cs new file mode 100644 index 0000000000..afc96b25dd --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/ITreeService.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Text; +using System.Web; +using System.Xml; +using System.Configuration; +using umbraco.BasePages; +using umbraco.BusinessLogic; +using umbraco.cms.businesslogic; +using umbraco.cms.businesslogic.cache; +using umbraco.cms.businesslogic.contentitem; +using umbraco.cms.businesslogic.datatype; +using umbraco.cms.businesslogic.language; +using umbraco.cms.businesslogic.media; +using umbraco.cms.businesslogic.member; +using umbraco.cms.businesslogic.property; +using umbraco.cms.businesslogic.web; +using umbraco.interfaces; +using umbraco.DataLayer; +using System.Collections.Specialized; + +namespace umbraco.cms.presentation.Trees +{ + /// + /// All Trees rely on the properties of an ITreeService interface. This has been created to avoid having trees + /// dependant on the HttpContext + /// + public interface ITreeService + { + /// + /// The NodeKey is a string representation of the nodeID. Generally this is used for tree's whos node's unique key value is a string in instead + /// of an integer such as folder names. + /// + string NodeKey { get; } + int StartNodeID { get; } + bool ShowContextMenu { get; } + bool IsDialog { get; } + TreeDialogModes DialogMode { get; } + string FunctionToCall { get; } + } +} diff --git a/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs b/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs index 9fde4231f4..e0be6c9313 100644 --- a/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs +++ b/umbraco/presentation/umbraco/Trees/MediaRecycleBin.cs @@ -81,6 +81,12 @@ namespace umbraco.cms.presentation.Trees } } + /// + /// Override the render js so no duplicate js is rendered. + /// + /// + public override void RenderJS(ref StringBuilder Javascript) { } + protected override void CreateRootNode(ref XmlTreeNode rootNode) { rootNode.Icon = "bin_empty.png"; diff --git a/umbraco/presentation/umbraco/Trees/TreeDefinitionCollection.cs b/umbraco/presentation/umbraco/Trees/TreeDefinitionCollection.cs index d399d8d2c8..093608bf36 100644 --- a/umbraco/presentation/umbraco/Trees/TreeDefinitionCollection.cs +++ b/umbraco/presentation/umbraco/Trees/TreeDefinitionCollection.cs @@ -141,7 +141,7 @@ namespace umbraco.cms.presentation.Trees if (this.Count > 0) return; - List foundITrees = TypeFinder.FindClassesOfType(true); + List foundITrees = TypeFinder.FindClassesOfType(); ApplicationTree[] objTrees = ApplicationTree.getAll(); List appTrees = new List(); diff --git a/umbraco/presentation/umbraco/Trees/TreeRequestParams.cs b/umbraco/presentation/umbraco/Trees/TreeRequestParams.cs new file mode 100644 index 0000000000..8e76651b57 --- /dev/null +++ b/umbraco/presentation/umbraco/Trees/TreeRequestParams.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Text; +using System.Web; +using System.Xml; +using System.Configuration; +using umbraco.BasePages; +using umbraco.BusinessLogic; +using umbraco.cms.businesslogic; +using umbraco.cms.businesslogic.cache; +using umbraco.cms.businesslogic.contentitem; +using umbraco.cms.businesslogic.datatype; +using umbraco.cms.businesslogic.language; +using umbraco.cms.businesslogic.media; +using umbraco.cms.businesslogic.member; +using umbraco.cms.businesslogic.property; +using umbraco.cms.businesslogic.web; +using umbraco.interfaces; +using umbraco.DataLayer; +using System.Collections.Specialized; + +namespace umbraco.cms.presentation.Trees +{ + /// + /// An ITreeService class that returns the values found in the Query String or any dictionary + /// + internal class TreeRequestParams : ITreeService + { + private TreeRequestParams() { } + + private Dictionary m_params; + + public static TreeRequestParams FromQueryStrings() + { + Dictionary p = new Dictionary(); + foreach (string key in HttpContext.Current.Request.QueryString.Keys) + { + p.Add(key, HttpContext.Current.Request.QueryString[key]); + //p.Add(item.Key.ToString(), item.Value.ToString()); + } + return FromDictionary(p); + } + + public static TreeRequestParams FromDictionary(Dictionary items) + { + TreeRequestParams treeParams = new TreeRequestParams(); + treeParams.m_params = items; + return treeParams; + } + + /// + /// Converts the tree parameters to a tree service object + /// + /// + public TreeService CreateTreeService() + { + return new TreeService() + { + ShowContextMenu = this.ShowContextMenu, + IsDialog = this.IsDialog, + DialogMode = this.DialogMode, + App = this.Application, + TreeType = this.TreeType, + NodeKey = this.NodeKey, + StartNodeID = this.StartNodeID, + FunctionToCall = this.FunctionToCall + }; + } + + public string NodeKey + { + get + { + return (m_params.ContainsKey("nodeKey") ? m_params["nodeKey"] : ""); + } + } + public string Application + { + get + { + return (m_params.ContainsKey("app") ? m_params["app"] : m_params.ContainsKey("appAlias") ? m_params["appAlias"] : ""); + } + } + public int StartNodeID + { + get + { + string val = (m_params.ContainsKey("id") ? m_params["id"] : ""); + int sNodeID; + if (int.TryParse(HttpContext.Current.Request.QueryString["id"], out sNodeID)) + return sNodeID; + return -1; + } + } + public string FunctionToCall + { + get + { + return (m_params.ContainsKey("functionToCall") ? m_params["functionToCall"] : ""); + } + } + public bool IsDialog + { + get + { + bool value; + if (m_params.ContainsKey("isDialog")) + if (bool.TryParse(m_params["isDialog"], out value)) + return value; + return false; + } + } + public TreeDialogModes DialogMode + { + get + { + if (m_params.ContainsKey("dialogMode") && IsDialog) + { + try + { + return (TreeDialogModes)Enum.Parse(typeof(TreeDialogModes), m_params["dialogMode"]); + } + catch + { + return TreeDialogModes.none; + } + } + return TreeDialogModes.none; + } + } + public bool ShowContextMenu + { + get + { + bool value; + if (m_params.ContainsKey("contextMenu")) + if (bool.TryParse(m_params["contextMenu"], out value)) + return value; + return true; + } + } + public string TreeType + { + get + { + return (m_params.ContainsKey("treeType") ? m_params["treeType"] : ""); + } + } + } +} diff --git a/umbraco/presentation/umbraco/Trees/TreeService.cs b/umbraco/presentation/umbraco/Trees/TreeService.cs index 2fed4d50a6..458798dd38 100644 --- a/umbraco/presentation/umbraco/Trees/TreeService.cs +++ b/umbraco/presentation/umbraco/Trees/TreeService.cs @@ -22,39 +22,22 @@ using umbraco.interfaces; using umbraco.DataLayer; using System.Collections.Specialized; using umbraco.IO; +using umbraco.uicontrols; namespace umbraco.cms.presentation.Trees { - /// - /// All Trees rely on the properties of an ITreeService interface. This has been created to avoid having trees - /// dependant on the HttpContext - /// - public interface ITreeService - { - /// - /// The NodeKey is a string representation of the nodeID. Generally this is used for tree's whos node's unique key value is a string in instead - /// of an integer such as folder names. - /// - string NodeKey { get; } - int StartNodeID { get; } - bool ShowContextMenu { get; } - bool IsDialog { get; } - TreeDialogModes DialogMode { get; } - string FunctionToCall { get; } - } - /// /// A utility class to aid in creating the URL for returning XML for a tree structure and /// for reading the parameters from the URL when a request is made. /// - public class TreeService : ITreeService + public class TreeService : TreeUrlGenerator, ITreeService { /// /// Default empty constructor /// - public TreeService() { } + public TreeService() : base() { } /// /// Constructor to assign all TreeService properties except nodeKey in one call @@ -68,12 +51,12 @@ namespace umbraco.cms.presentation.Trees public TreeService(int? startNodeID, string treeType, bool? showContextMenu, bool? isDialog, TreeDialogModes dialogMode, string app) { - m_startNodeID = startNodeID; - m_treeType = treeType; - m_showContextMenu = showContextMenu; - m_isDialog = isDialog; + StartNodeID = startNodeID ?? -1; + TreeType = treeType; + ShowContextMenu = showContextMenu ?? true; + IsDialog = isDialog ?? false; m_dialogMode = dialogMode; - m_app = app; + App = app; } /// @@ -89,78 +72,32 @@ namespace umbraco.cms.presentation.Trees public TreeService(int? startNodeID, string treeType, bool? showContextMenu, bool? isDialog, TreeDialogModes dialogMode, string app, string nodeKey) { - m_startNodeID = startNodeID; - m_treeType = treeType; - m_showContextMenu = showContextMenu; - m_isDialog = isDialog; + StartNodeID = startNodeID ?? -1; + TreeType = treeType; + ShowContextMenu = showContextMenu ?? true; + IsDialog = isDialog ?? false; m_dialogMode = dialogMode; - m_app = app; - m_nodeKey = nodeKey; + App = app; + NodeKey = nodeKey; } public TreeService(int? startNodeID, string treeType, bool? showContextMenu, bool? isDialog, TreeDialogModes dialogMode, string app, string nodeKey, string functionToCall) { - m_startNodeID = startNodeID; - m_treeType = treeType; - m_showContextMenu = showContextMenu; - m_isDialog = isDialog; + StartNodeID = startNodeID ?? -1; + TreeType = treeType; + ShowContextMenu = showContextMenu ?? true; + IsDialog = isDialog ?? false; m_dialogMode = dialogMode; - m_app = app; - m_nodeKey = nodeKey; - m_functionToCall = functionToCall; + App = app; + NodeKey = nodeKey; + FunctionToCall = functionToCall; } - public const string TREE_URL = "tree.aspx"; - public const string INIT_URL = "treeinit.aspx"; - public const string PICKER_URL = "treepicker.aspx"; - - private int? m_startNodeID; - private string m_treeType; - private bool? m_showContextMenu; - private bool? m_isDialog; - private TreeDialogModes m_dialogMode; - private string m_app; - private string m_nodeKey; - private string m_functionToCall; + private TreeDialogModes m_dialogMode; #region Public Properties - public string FunctionToCall - { - get { return m_functionToCall; } - set { m_functionToCall = value; } - } - - public string NodeKey - { - get { return m_nodeKey; } - set { m_nodeKey = value; } - } - - public int StartNodeID - { - get { return m_startNodeID ?? -1; } - set { m_startNodeID = value; } - } - - public string TreeType - { - get { return m_treeType; } - set { m_treeType = value; } - } - - public bool ShowContextMenu - { - get { return m_showContextMenu ?? true; } - set { m_showContextMenu = value; } - } - - public bool IsDialog - { - get { return m_isDialog ?? false; } - set { m_isDialog = value; } - } public TreeDialogModes DialogMode { @@ -168,22 +105,8 @@ namespace umbraco.cms.presentation.Trees set { m_dialogMode = value; } } - public string App - { - get { return m_app; } - set { m_app = value; } - } #endregion - /// - /// Returns the url for servicing the xml tree request based on the parameters specified on this class. - /// - /// Tree service url as a string - public string GetServiceUrl() - { - return SystemDirectories.Umbraco + "/" + GetUrl(TREE_URL); - } - /// /// Static method to return the tree service url with the specified parameters /// @@ -203,15 +126,6 @@ namespace umbraco.cms.presentation.Trees return treeSvc.GetServiceUrl(); } - /// - /// Returns the url for initializing the tree based on the parameters specified on this class - /// - /// - public string GetInitUrl() - { - return IOHelper.ResolveUrl( SystemDirectories.Umbraco + "/" + GetUrl(INIT_URL) ); - } - /// /// static method to return the tree init url with the specified parameters /// @@ -231,161 +145,12 @@ namespace umbraco.cms.presentation.Trees return treeSvc.GetInitUrl(); } - /// - /// Returns the url for the tree picker (used on modal windows) based on the parameters specified on this class - /// - /// - /// - public static string GetPickerUrl(bool useSubModal, string app, string treeType) - { - TreeService treeSvc = new TreeService(); - treeSvc.App = app; - treeSvc.TreeType = treeType; - return treeSvc.GetPickerUrl(useSubModal); - } + protected override string GetUrl(string pageUrl) + { + StringBuilder sb = new StringBuilder(base.GetUrl(pageUrl)); + if (this.DialogMode != TreeDialogModes.none) sb.Append(string.Format("&dialogMode={0}", this.DialogMode.ToString())); + return sb.ToString(); + } - /// - /// Returns the url for the tree picker (used on modal windows) based on the parameters specified on this class - /// - /// - /// - public string GetPickerUrl(bool useSubModal) - { - string url = IOHelper.ResolveUrl( SystemDirectories.Umbraco + "/dialogs/" + GetUrl(PICKER_URL) ); - return url + (useSubModal ? "&useSubModal=true" : ""); - } - - /// - /// Generates the URL parameters for the tree service. - /// - /// the base url (i.e. tree.aspx) - /// - private string GetUrl(string pageUrl) - { - StringBuilder sb = new StringBuilder(); - - sb.Append(pageUrl); - //insert random - sb.Append(string.Format("?rnd={0}", Guid.NewGuid())); - - sb.Append(string.Format("&id={0}", this.StartNodeID.ToString())); - if (!string.IsNullOrEmpty(this.TreeType)) sb.Append(string.Format("&treeType={0}", this.TreeType)); - if (!string.IsNullOrEmpty(this.NodeKey)) sb.Append(string.Format("&nodeKey={0}", this.NodeKey)); - sb.Append(string.Format("&contextMenu={0}", this.ShowContextMenu.ToString().ToLower())); - sb.Append(string.Format("&isDialog={0}", this.IsDialog.ToString().ToLower())); - if (this.DialogMode != TreeDialogModes.none) sb.Append(string.Format("&dialogMode={0}", this.DialogMode.ToString())); - if (!string.IsNullOrEmpty(this.App)) sb.Append(string.Format("&app={0}", this.App)); - - return sb.ToString(); - } - - } - - /// - /// An ITreeService class that returns the values found in the Query String or any dictionary - /// - internal class TreeRequestParams : ITreeService - { - private TreeRequestParams() { } - - private Dictionary m_params; - - public static TreeRequestParams FromQueryStrings() - { - Dictionary p = new Dictionary(); - foreach (string key in HttpContext.Current.Request.QueryString.Keys) - { - p.Add(key, HttpContext.Current.Request.QueryString[key]); - //p.Add(item.Key.ToString(), item.Value.ToString()); - } - return FromDictionary(p); - } - - public static TreeRequestParams FromDictionary(Dictionary items) - { - TreeRequestParams treeParams = new TreeRequestParams(); - treeParams.m_params = items; - return treeParams; - } - - public string NodeKey - { - get - { - return (m_params.ContainsKey("nodeKey") ? m_params["nodeKey"] : ""); - } - } - public string Application - { - get - { - return (m_params.ContainsKey("app") ? m_params["app"] : m_params.ContainsKey("appAlias") ? m_params["appAlias"] : ""); - } - } - public int StartNodeID - { - get - { - string val = (m_params.ContainsKey("id") ? m_params["id"] : ""); - int sNodeID; - if (int.TryParse(HttpContext.Current.Request.QueryString["id"], out sNodeID)) - return sNodeID; - return -1; - } - } - public string FunctionToCall - { - get - { - return (m_params.ContainsKey("functionToCall") ? m_params["functionToCall"] : ""); - } - } - public bool IsDialog - { - get - { - bool value; - if (m_params.ContainsKey("isDialog")) - if (bool.TryParse(m_params["isDialog"], out value)) - return value; - return false; - } - } - public TreeDialogModes DialogMode - { - get - { - if (m_params.ContainsKey("dialogMode") && IsDialog) - { - try - { - return (TreeDialogModes)Enum.Parse(typeof(TreeDialogModes), m_params["dialogMode"]); - } - catch - { - return TreeDialogModes.none; - } - } - return TreeDialogModes.none; - } - } - public bool ShowContextMenu - { - get - { - bool value; - if (m_params.ContainsKey("contextMenu")) - if (bool.TryParse(m_params["contextMenu"], out value)) - return value; - return true; - } - } - public string TreeType - { - get - { - return (m_params.ContainsKey("treeType") ? m_params["treeType"] : ""); - } - } } } diff --git a/umbraco/presentation/umbraco/Trees/loadMedia.cs b/umbraco/presentation/umbraco/Trees/loadMedia.cs index b070308066..b85b63fae0 100644 --- a/umbraco/presentation/umbraco/Trees/loadMedia.cs +++ b/umbraco/presentation/umbraco/Trees/loadMedia.cs @@ -54,7 +54,7 @@ namespace umbraco protected override void CreateRootNode(ref XmlTreeNode rootNode) { - //TODO: SD: Find out what openMedia does!? + if (this.IsDialog) rootNode.Action = "javascript:openMedia(-1);"; else diff --git a/umbraco/presentation/umbraco/cache/factory.cs b/umbraco/presentation/umbraco/cache/factory.cs index a29a035a82..9136e446b9 100644 --- a/umbraco/presentation/umbraco/cache/factory.cs +++ b/umbraco/presentation/umbraco/cache/factory.cs @@ -34,7 +34,7 @@ namespace umbraco.presentation.cache private static void Initialize() { - List types = TypeFinder.FindClassesOfType(true); + List types = TypeFinder.FindClassesOfType(); foreach (Type t in types) { ICacheRefresher typeInstance = Activator.CreateInstance(t) as ICacheRefresher; diff --git a/umbraco/presentation/umbraco/controls/ContentPicker.cs b/umbraco/presentation/umbraco/controls/ContentPicker.cs index 95cffaa2d9..6edbe3f3ae 100644 --- a/umbraco/presentation/umbraco/controls/ContentPicker.cs +++ b/umbraco/presentation/umbraco/controls/ContentPicker.cs @@ -8,135 +8,70 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using umbraco.cms.presentation.Trees; -using ClientDependency.Core; using umbraco.presentation; -using ClientDependency.Core.Controls; +using umbraco.uicontrols.TreePicker; namespace umbraco.controls { - [ClientDependency(ClientDependencyType.Javascript, "js/xmlextras.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Javascript, "js/xmlRequest.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Javascript, "webservices/ajax.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Javascript, "js/submodal/subModal.js", "UmbracoRoot")] - [ClientDependency(ClientDependencyType.Css, "js/submodal/subModal.css", "UmbracoRoot")] - public class ContentPicker : System.Web.UI.WebControls.WebControl + + public class ContentPicker : BaseTreePicker { - public System.Web.UI.Control Editor { get { return this; } } + public ContentPicker() + { + AppAlias = "content"; + TreeAlias = "content"; + } - private string _text = ""; + [Obsolete("Use Value property instead, this simply wraps it.")] public string Text { get { - if (Page.IsPostBack && !String.IsNullOrEmpty(helper.Request(this.ClientID))) - { - _text = helper.Request(this.ClientID); - } - return _text; + return this.Value; } - set { _text = value; } + set + { + this.Value = value; + } } - private string _appAlias = "content"; - public string AppAlias - { - get { return _appAlias; } - set { _appAlias = value; } - } + public string AppAlias { get; set; } + public string TreeAlias { get; set; } + public override string TreePickerUrl + { + get + { + return TreeService.GetPickerUrl(AppAlias, TreeAlias); + } + } - private string _treeAlias = "content"; - public string TreeAlias - { - get { return _treeAlias; } - set { _treeAlias = value; } - } + public override string ModalWindowTitle + { + get + { + return ui.GetText("general", "choose") + " " + ui.GetText("sections", TreeAlias.ToLower()); + } + } - private bool _showDelete = true; - public bool ShowDelete - { - get { return _showDelete; } - set { _showDelete = value; } - } - - private int m_modalWidth = 300; - public int ModalWidth - { - get { return m_modalWidth; } - set { m_modalWidth = value; } - } - - private int m_modalHeight = 400; - public int ModalHeight - { - get { return m_modalHeight; } - set { m_modalHeight = value; } - } - - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager - if (!UmbracoContext.Current.LiveEditingContext.Enabled) - presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page); - else - ClientDependencyLoader.Instance.RegisterDependency("webservices/legacyAjaxCalls.asmx/js", "UmbracoRoot", ClientDependencyType.Javascript); - } - - - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - - string tempTitle = ""; - string deleteLink = "   " + ui.Text("delete") + "   "; - try - { - if (this.Text != "" && this.Text != "-1") - { - tempTitle = new cms.businesslogic.CMSNode(int.Parse(this.Text)).Text; - } - else - { - tempTitle = (!string.IsNullOrEmpty(_treeAlias) ? ui.Text(_treeAlias) : ui.Text(_appAlias)); - - } - } - catch { } - - writer.WriteLine(""); - - // Clear remove link if text if empty - if (this.Text == "" || !_showDelete) - deleteLink = ""; - writer.WriteLine("" + tempTitle + "" + deleteLink + " " + ui.Text("choose") + "...   "); - base.Render(writer); - } + protected override string GetItemTitle() + { + string tempTitle = ""; + try + { + if (this.Text != "" && this.Text != "-1") + { + tempTitle = new cms.businesslogic.CMSNode(int.Parse(this.Text)).Text; + } + else + { + tempTitle = (!string.IsNullOrEmpty(TreeAlias) ? ui.Text(TreeAlias) : ui.Text(AppAlias)); + } + } + catch { } + return tempTitle; + } } } diff --git a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index 2d0ac21a7f..a2dc0fed6e 100644 --- a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -15,7 +15,7 @@ namespace umbraco.controls [ClientDependency(ClientDependencyType.Javascript, "ui/jqueryui.js", "UmbracoClient")] [ClientDependency(ClientDependencyType.Css, "Tree/treeIcons.css", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Css, "Tree/Themes/umbraco/styles.css", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Css, "Tree/Themes/umbraco/style.css", "UmbracoClient")] public partial class ContentTypeControlNew : System.Web.UI.UserControl { public uicontrols.TabPage InfoTabPage; diff --git a/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx b/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx index a3042a6876..79b4077607 100644 --- a/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx +++ b/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx @@ -13,10 +13,6 @@ - - diff --git a/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs b/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs index 9e2ec192d3..e9cba9dd4a 100644 --- a/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs +++ b/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.cs @@ -168,7 +168,7 @@ namespace umbraco.controls.GenericProperties DeleteButton2.Visible = false; } validationLink.NavigateUrl = "#"; - validationLink.Attributes["onclick"] = ClientTools.Scripts.OpenModalWindow("dialogs/regexWs.aspx?target=" + tbValidation.ClientID , "Search for regular expression", 500, 600) + ";return false;"; + validationLink.Attributes["onclick"] = ClientTools.Scripts.OpenModalWindow("dialogs/regexWs.aspx?target=" + tbValidation.ClientID, "Search for regular expression", 600, 500) + ";return false;"; // Data type definitions if (_dataTypeDefinitions != null) diff --git a/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs b/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs index db7127ceb9..b953baaa55 100644 --- a/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs +++ b/umbraco/presentation/umbraco/controls/GenericProperties/GenericProperty.ascx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.4927 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx b/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx new file mode 100644 index 0000000000..0ceb3cd09a --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx @@ -0,0 +1,48 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ImageViewer.ascx.cs" Inherits="umbraco.controls.Images.ImageViewer" %> +<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> + +
+ + + + + <%#AltText%> + + + + <%#AltText%> + + +
');"> +
+
+
+ + + <%--Register the javascript callback method if any.--%> + + +
+<%--Ensure that the client API is registered for the image.--%> + + + diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx.cs b/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx.cs new file mode 100644 index 0000000000..0d54d11289 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using umbraco.cms.businesslogic.media; + +namespace umbraco.controls.Images +{ + public partial class ImageViewer : System.Web.UI.UserControl + { + + public ImageViewer() + { + MediaItemPath = "#"; + MediaItemThumbnailPath = umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/images/blank.png"; + AltText = "No Image"; + ImageFound = false; + ViewerStyle = Style.Basic; + LinkTarget = "_blank"; + } + + + /// + /// A JS method to invoke when the image is loaded. The method should accept the media ID. + /// + public string ClientCallbackMethod { get; set; } + + public int MediaId { get; set; } + + /// + /// The style to render the image viewer in + /// + public enum Style + { + Basic = 0, + ImageLink = 1, + ThumbnailPreview = 2 + } + + public Style ViewerStyle { get; set; } + + public string LinkTarget { get; set; } + + public string MediaItemPath { get; private set; } + public string MediaItemThumbnailPath { get; private set; } + public string AltText { get; private set; } + public int FileWidth { get { return m_FileWidth; } } + public int FileHeight { get { return m_FileHeight; } } + + protected bool ImageFound { get; private set; } + + + private int m_FileWidth = 0; + private int m_FileHeight = 0; + private bool m_IsBound = false; + + /// + /// automatically bind if it's not explicitly called. + /// + /// + protected override void OnPreRender(EventArgs e) + { + base.OnPreRender(e); + if (!m_IsBound) + { + DataBind(); + } + } + + public override void DataBind() + { + LookupData(); + base.DataBind(); + this.m_IsBound = true; + } + + private void LookupData() + { + if (MediaId > 0) + { + Media m = new Media(MediaId); + + // TODO: Remove "Magic strings" from code. + var pFile = m.getProperty("fileName"); + if (pFile == null) pFile = m.getProperty("umbracoFile"); + if (pFile == null) pFile = m.getProperty("file"); + if (pFile == null) + { + //the media requested does not correspond with the standard umbraco properties + return; + } + + MediaItemPath = pFile.Value != null && !string.IsNullOrEmpty(pFile.Value.ToString()) + ? umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/.." + pFile.Value.ToString() + : "#"; + AltText = MediaItemPath != "#" ? m.Text : ui.GetText("no") + " " + ui.GetText("media"); + + var pWidth = m.getProperty("umbracoWidth"); + var pHeight = m.getProperty("umbracoHeight"); + + if (pWidth != null && pWidth.Value != null && pHeight != null && pHeight.Value != null) + { + int.TryParse(pHeight.Value.ToString(), out m_FileWidth); + int.TryParse(pHeight.Value.ToString(), out m_FileHeight); + } + + string ext = MediaItemPath.Substring(MediaItemPath.LastIndexOf(".") + 1, MediaItemPath.Length - MediaItemPath.LastIndexOf(".") - 1); + MediaItemThumbnailPath = MediaItemPath.Replace("." + ext, "_thumb.jpg"); + + ImageFound = true; + } + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx.designer.cs b/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx.designer.cs new file mode 100644 index 0000000000..c5e0edd1b1 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/ImageViewer.ascx.designer.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.controls.Images { + + + public partial class ImageViewer { + + /// + /// JsInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; + } +} diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewer.js b/umbraco/presentation/umbraco/controls/Images/ImageViewer.js new file mode 100644 index 0000000000..2924c4f81e --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/ImageViewer.js @@ -0,0 +1,133 @@ +/// +/// + +Umbraco.Sys.registerNamespace("Umbraco.Controls"); + +(function($) { + //jQuery plugin for Umbraco image viewer control + $.fn.UmbracoImageViewer = function(opts) { + //all options must be specified + var conf = $.extend({ + style: false, + linkTarget: "_blank", + umbPath: "" + }, opts); + return this.each(function() { + new Umbraco.Controls.ImageViewer().init($(this), conf); + }); + } + $.fn.UmbracoImageViewerAPI = function() { + /// exposes the Umbraco Image Viewer api for the selected object + //if there's more than item in the selector, throw exception + if ($(this).length != 1) { + throw "UmbracoImageViewerAPI selector requires that there be exactly one control selected"; + }; + return Umbraco.Controls.ImageViewer.inst[$(this).attr("id")] || null; + }; + Umbraco.Controls.ImageViewer = function() { + return { + _cntr: ++Umbraco.Controls.ImageViewer.cntr, + _containerId: null, + _context: null, + _serviceUrl: "", + _umbPath: "", + _style: false, + _linkTarget: "", + + init: function(jItem, opts) { + //this is stored so that we search the current document/iframe for this object + //when calling _getContainer. Before this was not required but for some reason inside the + //TinyMCE popup, when doing an ajax call, the context is lost to the jquery item! + this._context = jItem.get(0).ownerDocument; + + //store a reference to this api by the id and the counter + Umbraco.Controls.ImageViewer.inst[this._cntr] = this; + if (!jItem.attr("id")) jItem.attr("id", "UmbImageViewer_" + this._cntr); + Umbraco.Controls.ImageViewer.inst[jItem.attr("id")] = Umbraco.Controls.ImageViewer.inst[this._cntr]; + + this._containerId = jItem.attr("id"); + + this._umbPath = opts.umbPath; + this._serviceUrl = this._umbPath + "/controls/Images/ImageViewerUpdater.asmx"; + this._style = opts.style; + this._linkTarget = opts.linkTarget; + + }, + + updateImage: function(mediaId, callback) { + /// Updates the image to show the mediaId parameter using AJAX + + this._showThrobber(); + + var _this = this; + $.ajax({ + type: "POST", + url: _this._serviceUrl + "/UpdateImage", + data: '{ "mediaId": ' + parseInt(mediaId) + ', "style": "' + _this._style + '", "linkTarget": "' + _this._linkTarget + '"}', + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function(msg) { + var rHtml = $("
").append(msg.d.html); //get the full html response wrapped in temp div + _this._updateImageFromAjax(rHtml); + if (typeof callback == "function") { + //build the parameters to pass back to the callback method + var params = { + hasImage: _this._getContainer().find("img.noimage").length == 0, + mediaId: msg.d.mediaId, + width: msg.d.width, + height: msg.d.height, + url: msg.d.url, + alt: msg.d.alt + }; + //call the callback method + callback.call(_this, params); + } + } + }); + }, + + showImage: function(path) { + /// This will force the image to show the path passed in + if (this._style != "ThumbnailPreview") { + this._getContainer().find("img").attr("src", path); + } + else { + c = this._getContainer().find(".bgImage"); + c.css("background-image", "url('" + path + "')"); + } + }, + + _getContainer: function() { + return $("#" + this._containerId, this._context); + }, + + _updateImageFromAjax: function(rHtml) { + this._getContainer().html(rHtml.find(".imageViewer").html()); //replace the html with the inner html of the image viewer response + }, + + _showThrobber: function() { + var c = null; + if (this._style != "ThumbnailPreview") { + c = this._getContainer().find("img"); + c.attr("src", this._umbPath + "/images/throbber.gif"); + c.css("margin-top", ((c.height() - 15) / 2) + "px"); + c.css("margin-left", ((c.width() - 15) / 2) + "px"); + } + else { + c = this._getContainer().find(".bgImage"); + c.css("background-image", ""); + c.html(""); + var img = c.find("img"); + img.attr("src", this._umbPath + "/images/throbber.gif"); + img.css("margin-top", "45px"); + img.css("margin-left", "45px"); + } + } + } + } + + // instance manager + Umbraco.Controls.ImageViewer.cntr = 0; + Umbraco.Controls.ImageViewer.inst = {}; + +})(jQuery); \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx new file mode 100644 index 0000000000..e5ab3a9652 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx @@ -0,0 +1 @@ +<%@ WebService Language="C#" CodeBehind="ImageViewerUpdater.asmx.cs" Class="umbraco.controls.Images.ImageViewerUpdater" %> diff --git a/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx.cs b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx.cs new file mode 100644 index 0000000000..b3491211a7 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/ImageViewerUpdater.asmx.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Services; +using System.ComponentModel; +using System.Web.Script.Services; +using System.Web.UI; +using umbraco.controls.Images; +using System.IO; +using System.Web.Script.Serialization; +using umbraco.businesslogic.Utils; + +namespace umbraco.controls.Images +{ + /// + /// An ajax service to return the html for an image based on a media id + /// + [WebService(Namespace = "http://tempuri.org/")] + [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] + [ToolboxItem(false)] + [ScriptService] + public class ImageViewerUpdater : System.Web.Services.WebService + { + + /// + /// return the a json object with the properties + /// html = the html returned for rendering the image viewer + /// mediaId = the media id loaded + /// width = the width of the media (0) if not found + /// height = the height of the media (0) if not found + /// url = the url of the image + /// alt = the alt text for the image + /// + /// + [WebMethod] + public Dictionary UpdateImage(int mediaId, string style, string linkTarget) + { + //load the control with the specified properties and render the output as a string and return it + Page page = new Page(); + string path = umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/controls/Images/ImageViewer.ascx"; + + ImageViewer imageViewer = page.LoadControl(path) as ImageViewer; + imageViewer.MediaId = mediaId; + ImageViewer.Style _style = (ImageViewer.Style)Enum.Parse(typeof(ImageViewer.Style), style); + imageViewer.ViewerStyle = _style; + imageViewer.LinkTarget = linkTarget; + + //this adds only the anchor with image to be rendered, not the whole control! + page.Controls.Add(imageViewer); + + imageViewer.DataBind(); + + StringWriter sw = new StringWriter(); + HttpContext.Current.Server.Execute(page, sw, false); + + Dictionary rVal = new Dictionary(); + rVal.Add("html", sw.ToString()); + rVal.Add("mediaId", imageViewer.MediaId.ToString()); + rVal.Add("width", imageViewer.FileWidth.ToString()); + rVal.Add("height", imageViewer.FileHeight.ToString()); + rVal.Add("url", imageViewer.MediaItemPath); + rVal.Add("alt", imageViewer.AltText); + + return rVal; + } + } +} diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx new file mode 100644 index 0000000000..5c8cfd3257 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx @@ -0,0 +1,28 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UploadMediaImage.ascx.cs" + Inherits="umbraco.controls.Images.UploadMediaImage" %> +<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> +<%@ Register TagPrefix="ctl" Namespace="umbraco.controls" Assembly="umbraco" %> + + + + + + + + + + + + + + + + + + + + diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs new file mode 100644 index 0000000000..767351fa84 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Web; +using System.Web.SessionState; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.HtmlControls; +using System.Linq; +using System.Xml; +using umbraco.BasePages; +using umbraco.uicontrols; +using umbraco.interfaces; +using umbraco.cms.businesslogic.media; + +namespace umbraco.controls.Images +{ + + /// + /// A control to render out the controls to upload a new image to media. + /// Includes ability to select where in the media you would like it to upload and also supports client + /// callback methods once complete. + /// + public partial class UploadMediaImage : System.Web.UI.UserControl + { + + public UploadMediaImage() + { + OnClientUpload = ""; + } + + /// + /// The JavaScript method to be invoked once the image is uploaded, the page is rendered and the document is ready. + /// The method will receive a JSON object with the following parameters: + /// - imagePath + /// - thumbnailPath + /// - width + /// - height + /// - id + /// + public string OnClientUpload { get; set; } + + protected IDataType UploadField = new cms.businesslogic.datatype.controls.Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); + + protected override void OnInit(EventArgs e) + { + + base.OnInit(e); + // Get upload field from datafield factory + UploadControl.Controls.Add((Control)UploadField.DataEditor); + } + + protected void Page_Load(object sender, EventArgs e) + { + + ((HtmlInputFile)UploadField.DataEditor).ID = "uploadFile"; + if (!IsPostBack) + { + DataBind(); + } + + + } + + protected void SubmitButton_Click(object sender, EventArgs e) + { + Media m = Media.MakeNew(TextBoxTitle.Text, cms.businesslogic.media.MediaType.GetByAlias("image"), BasePage.Current.getUser(), int.Parse(MediaPickerControl.Text)); + var props = m.getProperties; + foreach (cms.businesslogic.property.Property p in props) + { + if (p.PropertyType.DataTypeDefinition.DataType.Id == UploadField.Id) + { + UploadField.DataTypeDefinitionId = p.PropertyType.DataTypeDefinition.Id; + UploadField.Data.PropertyId = p.Id; + } + } + UploadField.DataEditor.Save(); + + // Generate xml on image + m.XmlGenerate(new XmlDocument()); + pane_upload.Visible = false; + + //this seems real ugly since we apparently already have the properties above (props)... but this data layer is insane and undecipherable:) + string mainImage = m.getProperty("umbracoFile").Value.ToString(); + string extension = mainImage.Substring(mainImage.LastIndexOf(".") + 1, mainImage.Length - mainImage.LastIndexOf(".") - 1); + var thumbnail = mainImage.Remove(mainImage.Length - extension.Length - 1, extension.Length + 1) + "_thumb.jpg"; + string width = m.getProperty("umbracoWidth").Value.ToString(); + string height = m.getProperty("umbracoHeight").Value.ToString(); + int id = m.Id; + + feedback.Style.Add("margin-top", "8px"); + feedback.type = uicontrols.Feedback.feedbacktype.success; + feedback.Text += ""; + + if (!string.IsNullOrEmpty(OnClientUpload)) + { + feedback.Text += @" + "; + } + + } + + protected override void OnPreRender(EventArgs e) + { + base.OnPreRender(e); + + ((HtmlInputFile)UploadField.DataEditor).Attributes.Add("onChange", "uploader_" + this.ClientID + ".validateImage();"); + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.designer.cs b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.designer.cs new file mode 100644 index 0000000000..0ecc358f57 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.ascx.designer.cs @@ -0,0 +1,109 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4200 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace umbraco.controls.Images +{ + + + public partial class UploadMediaImage { + + /// + /// JsInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; + + /// + /// pane_upload control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane pane_upload; + + /// + /// pp_name control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_name; + + /// + /// TextBoxTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox TextBoxTitle; + + /// + /// pp_file control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_file; + + /// + /// UploadControl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.PlaceHolder UploadControl; + + /// + /// pp_target control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_target; + + /// + /// pp_button control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_button; + + /// + /// SubmitButton control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button SubmitButton; + + /// + /// feedback control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Feedback feedback; + + protected global::umbraco.controls.ContentPicker MediaPickerControl; + } +} diff --git a/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.js b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.js new file mode 100644 index 0000000000..fb9f8bcea2 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Images/UploadMediaImage.js @@ -0,0 +1,33 @@ +/// + +Umbraco.Sys.registerNamespace("Umbraco.Controls"); + +(function($) { + Umbraco.Controls.UploadMediaImage = function(txtBoxTitleID, btnID, uploadFileID) { + return { + _txtBoxTitleID: txtBoxTitleID, + _btnID: btnID, + _uplaodFileID: uploadFileID, + + validateImage: function() { + // Disable save button + var imageTypes = ",jpeg,jpg,gif,bmp,png,tiff,tif,"; + var tb_title = document.getElementById(this._txtBoxTitleID); + var bt_submit = $("#" + this._btnID); + var tb_image = document.getElementById(this._uplaodFileID); + + bt_submit.attr("disabled","disabled").css("color", "gray"); + + var imageName = tb_image.value; + if (imageName.length > 0) { + var extension = imageName.substring(imageName.lastIndexOf(".") + 1, imageName.length); + if (imageTypes.indexOf(',' + extension.toLowerCase() + ',') > -1) { + bt_submit.removeAttr("disabled").css("color", "#000"); + if (tb_title.value == "") + tb_title.value = imageName.substring(imageName.lastIndexOf("\\") + 1, imageName.length).replace("." + extension, ""); + } + } + } + }; + } +})(jQuery); \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenu.cs b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenu.cs new file mode 100644 index 0000000000..d2b362fa8b --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenu.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.Script.Serialization; +using umbraco.interfaces; +using System.Text.RegularExpressions; +using umbraco.BusinessLogic.Actions; +using umbraco.businesslogic.Utils; +using System.Text; +using umbraco.cms.presentation.Trees; +using umbraco.BasePages; +using System.Web.Services; + +namespace umbraco.controls.Tree +{ + internal class JTreeContextMenu + { + public string RenderJSONMenu() + { + + JSONSerializer jSSerializer = new JSONSerializer(); + + jSSerializer.RegisterConverters(new List() + { + new JTreeContextMenuItem() + }); + + List allActions = new List(); + foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll()) + { + if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource))) + { + allActions.Add(a); + } + + } + + + return jSSerializer.Serialize(allActions); + } + } +} diff --git a/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs new file mode 100644 index 0000000000..8b33f22670 --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.Script.Serialization; +using umbraco.interfaces; +using System.Text.RegularExpressions; +using umbraco.BusinessLogic.Actions; +using umbraco.businesslogic.Utils; +using System.Text; +using umbraco.cms.presentation.Trees; +using umbraco.BasePages; +using System.Web.Services; + +namespace umbraco.controls.Tree +{ + internal class JTreeContextMenuItem : JavaScriptConverter + { + + /// + /// Not implemented as we never need to Deserialize + /// + /// + /// + /// + /// + public override object Deserialize(IDictionary dictionary, Type type, JavaScriptSerializer serializer) + { + throw new NotImplementedException(); + } + + public override IDictionary Serialize(object obj, JavaScriptSerializer serializer) + { + //{ + // "id": "L", + // "label": "Create", + // "icon": "create.png", + // "visible": function(NODE, TREE_OBJ) { if (NODE.length != 1) return false; return TREE_OBJ.check("creatable", NODE); }, + // "action": function(NODE, TREE_OBJ) { TREE_OBJ.create(false, NODE); }, + //} + + + IAction a = (IAction)obj; + Dictionary data = new Dictionary(); + + data.Add("id", a.Letter); + data.Add("label", ui.Text(a.Alias)); + + if (a.Icon.StartsWith(".")) + { + StringBuilder sb = new StringBuilder(); + sb.Append(string.Format(""); + sb.Append(""); + data["label"] = sb.ToString(); + } + else + { + data.Add("icon", a.Icon); + } + + //required by jsTree + data.Add("visible", JSONSerializer.ToJSONObject("function() {return true;}")); + //The action handler is what is assigned to the IAction, but for flexibility, we'll call our onContextMenuSelect method which will need to return true if the function is to execute. + //TODO: Check if there is a JSSource + data.Add("action", JSONSerializer.ToJSONObject("function(N,T){" + a.JsFunctionName + ";}")); + + return data; + + } + + /// + /// TODO: Find out why we can't just return IAction as one type (JavaScriptSerializer doesn't seem to pick up on it) + /// + public override IEnumerable SupportedTypes + { + get + { + List types = new List(); + foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll()) + { + types.Add(a.GetType()); + } + return types; + } + + + } + } +} diff --git a/umbraco/presentation/umbraco/controls/TreeControl.ascx b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx similarity index 60% rename from umbraco/presentation/umbraco/controls/TreeControl.ascx rename to umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx index c7e13eba79..ec45eefdb8 100644 --- a/umbraco/presentation/umbraco/controls/TreeControl.ascx +++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx @@ -1,4 +1,4 @@ -<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TreeControl.ascx.cs" Inherits="umbraco.presentation.umbraco.controls.TreeControl" %> +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TreeControl.ascx.cs" Inherits="umbraco.controls.Tree.TreeControl" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> @@ -17,38 +17,49 @@ + -
"> + +
+
+
\ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs new file mode 100644 index 0000000000..ec82fbc5cc --- /dev/null +++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs @@ -0,0 +1,390 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.Script.Serialization; +using umbraco.interfaces; +using System.Text.RegularExpressions; +using umbraco.BusinessLogic.Actions; +using umbraco.businesslogic.Utils; +using System.Text; +using umbraco.cms.presentation.Trees; +using umbraco.BasePages; +using System.Web.Services; +using System.Drawing; + +namespace umbraco.controls.Tree +{ + + /// + /// The Umbraco tree control. + /// If this control doesn't exist on an UmbracoEnsuredPage it will not work. + /// + public partial class TreeControl : System.Web.UI.UserControl, ITreeService + { + + /// + /// Set the defaults + /// + public TreeControl() + { + Width = Unit.Empty; + Height = Unit.Empty; + BackColor = Color.Empty; + CssClass = ""; + } + + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + EnableViewState = false; + } + + public enum TreeMode + { + Standard, Checkbox, InheritedCheckBox + } + + /// + /// If there is not application or tree specified in a query string then this is the application to load. + /// + private const string DEFAULT_APP = "content"; + + private List m_ActiveTrees = new List(); + private List m_AllAppTrees = new List(); + private List m_ActiveTreeDefs = null; + private TreeMode m_TreeType = TreeMode.Standard; + private bool m_IsInit = false; + private TreeService m_TreeService = new TreeService(); + + #region Public Properties + + #region Style Properties + public string CssClass { get; set; } + public Unit Height { get; set; } + public Unit Width { get; set; } + public Color BackColor { get; set; } + #endregion + + #region TreeService parameters. + public string FunctionToCall + { + get { return m_TreeService.FunctionToCall; } + set + { + m_TreeService.FunctionToCall = value; + } + } + + public string NodeKey + { + get { return m_TreeService.NodeKey; } + set + { + m_TreeService.NodeKey = value; + } + } + + public int StartNodeID + { + get { return m_TreeService.StartNodeID; } + set + { + m_TreeService.StartNodeID = value; + } + } + + public string TreeType + { + get { return m_TreeService.TreeType; } + set + { + m_TreeService.TreeType = value; + } + } + + public bool ShowContextMenu + { + get { return m_TreeService.ShowContextMenu; } + set + { + m_TreeService.ShowContextMenu = value; + } + } + + public bool IsDialog + { + get { return m_TreeService.IsDialog; } + set + { + m_TreeService.IsDialog = value; + } + } + + public TreeDialogModes DialogMode + { + get { return m_TreeService.DialogMode; } + set + { + m_TreeService.DialogMode = value; + } + } + + + public string App + { + get + { + return GetCurrentApp(); + } + set + { + m_TreeService.App = value; + } + } + #endregion + + /// + /// Allows for checkboxes to be used with the tree. Default is standard. + /// + public TreeMode Mode + { + get + { + return m_TreeType; + } + set + { + m_TreeType = value; + } + } + + + /// + /// Returns the requires JavaScript as a string for the current application + /// + public string JSCurrApp + { + get + { + StringBuilder javascript = new StringBuilder(); + foreach (BaseTree bTree in m_AllAppTrees) + bTree.RenderJS(ref javascript); + return javascript.ToString(); + } + } + #endregion + + /// + /// Can be set explicitly which will override what is in query strings or what has been set by properties. + /// Useful for rendering out a tree dynamically with an instance of anoterh TreeService. + /// By using this method, it will undo any of the tree service public properties that may be set + /// on this object. + /// + public void SetTreeService(TreeService srv) + { + m_TreeService = srv; + Initialize(); + } + + /// + /// Initializes the control and looks up the tree structures that are required to be rendered. + /// Properties of the control (or SetTreeService) need to be set before pre render or calling + /// GetJSONContextMenu or GetJSONNode + /// + protected void Initialize() + { + //use the query strings if the TreeParams isn't explicitly set + if (m_TreeService == null) + { + m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService(); + } + m_TreeService.App = GetCurrentApp(); + + // Validate permissions + if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID)) + return; + UmbracoEnsuredPage page = new UmbracoEnsuredPage(); + if (!page.ValidateUserApp(GetCurrentApp())) + throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator."); + + //find all tree definitions that have the current application alias that are ACTIVE + m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp()); + //find all tree defs that exists for the current application regardless of if they are active + List appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(GetCurrentApp()); + + //Create the BaseTree's based on the tree definitions found + foreach (TreeDefinition treeDef in appTreeDefs) + { + //create the tree and initialize it + BaseTree bTree = treeDef.CreateInstance(); + bTree.SetTreeParameters(m_TreeService); + + //store the created tree + m_AllAppTrees.Add(bTree); + if (treeDef.Tree.Initialize) + m_ActiveTrees.Add(bTree); + } + + m_IsInit = true; + } + + /// + /// This calls the databind method to bind the data binding syntax on the front-end. + /// + /// Databinding was used instead of inline tags in case the tree properties needed to be set + /// by other classes at runtime + /// + /// + /// + /// + /// This will initialize the control so all TreeService properties need to be set before hand + /// + protected override void OnPreRender(EventArgs e) + { + base.OnPreRender(e); + + if (!m_IsInit) + Initialize(); + + //Render out the JavaScript associated with all of the trees for the application + RenderTreeJS(); + + //apply the styles + if (Width != Unit.Empty) + TreeContainer.Style.Add( HtmlTextWriterStyle.Width, Width.ToString()); + if (Height != Unit.Empty) + TreeContainer.Style.Add(HtmlTextWriterStyle.Height, Height.ToString()); + if (BackColor != Color.Empty) + TreeContainer.Style.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(BackColor)); + if (CssClass != "") + { + TreeContainer.Attributes.Add("class", CssClass); + } + else + { + //add the default class + TreeContainer.Attributes.Add("class", "treeContainer"); + } + + + DataBind(); + } + + /// + /// Returns the JSON markup for the full context menu + /// + public string GetJSONContextMenu() + { + if (ShowContextMenu) + { + JTreeContextMenu menu = new JTreeContextMenu(); + return menu.RenderJSONMenu(); + } + else + { + return "{}"; + } + + } + + /// + /// Returns the JSON markup for one node + /// + /// + /// + /// + /// + /// This will initialize the control so all TreeService properties need to be set before hand + /// + public string GetJSONNode(string nodeId) + { + if (!m_IsInit) + Initialize(); + + if (string.IsNullOrEmpty(m_TreeService.TreeType)) + { + throw new ArgumentException("The TreeType is not set on the tree service"); + } + + BaseTree tree = m_ActiveTrees.Find( + delegate(BaseTree t) + { + return (t.TreeAlias == m_TreeService.TreeType); + } + ); + return tree.GetSerializedNodeData(nodeId); + } + + /// + /// Returns the JSON markup for the first node in the tree + /// + + public string GetJSONInitNode() + { + if (!m_IsInit) + Initialize(); + + //if there is only one tree to render, we don't want to have a node to hold sub trees, we just want the + //stand alone tree, so we'll just add a TreeType to the TreeService and ensure that the right method gets loaded in tree.aspx + if (m_ActiveTrees.Count == 1) + { + m_TreeService.TreeType = m_ActiveTreeDefs[0].Tree.Alias; + + //convert the menu to a string + //string initActions = (TreeSvc.ShowContextMenu ? Action.ToString(m_ActiveTrees[0].RootNodeActions) : ""); + + //Since there's only 1 tree, render out the tree's RootNode properties + XmlTree xTree = new XmlTree(); + xTree.Add(m_ActiveTrees[0].RootNode); + return xTree.ToString(); + } + else + { + + //If there is more than 1 tree for the application than render out a + //container node labelled with the current application. + XmlTree xTree = new XmlTree(); + XmlTreeNode xNode = XmlTreeNode.CreateRoot(new NullTree(GetCurrentApp())); + xNode.Text = ui.Text("sections", GetCurrentApp(), UmbracoEnsuredPage.CurrentUser); + xNode.Source = m_TreeService.GetServiceUrl(); + xNode.Action = ClientTools.Scripts.OpenDashboard(GetCurrentApp()); + xNode.NodeType = m_TreeService.App.ToLower(); + xNode.NodeID = "-1"; + xNode.Icon = ".sprTreeFolder"; + xTree.Add(xNode); + return xTree.ToString(); + } + } + + + + private void RenderTreeJS() + { + Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Trees_" + GetCurrentApp(), JSCurrApp, true); + } + + /// + /// Return the current application alias. If neither the TreeType of Application is specified + /// than return the default application. If the Application is null but there is a TreeType then + /// find the application that the tree type is associated with. + /// + private string GetCurrentApp() + { + //if theres an treetype specified but no application + if (string.IsNullOrEmpty(m_TreeService.App) && + !string.IsNullOrEmpty(m_TreeService.TreeType)) + { + TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(m_TreeService.TreeType); + if (treeDef != null) + return treeDef.App.alias; + } + else if (!string.IsNullOrEmpty(m_TreeService.App)) + return m_TreeService.App; + + //if everything is null then return the default app + return DEFAULT_APP; + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/TreeControl.ascx.designer.cs b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.designer.cs similarity index 89% rename from umbraco/presentation/umbraco/controls/TreeControl.ascx.designer.cs rename to umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.designer.cs index 9c42afc877..c27bd96968 100644 --- a/umbraco/presentation/umbraco/controls/TreeControl.ascx.designer.cs +++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.designer.cs @@ -1,14 +1,14 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3603 +// Runtime Version:2.0.50727.4927 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace umbraco.presentation.umbraco.controls { +namespace umbraco.controls.Tree { public partial class TreeControl { @@ -138,5 +138,14 @@ namespace umbraco.presentation.umbraco.controls { /// To modify move field declaration from designer file to code-behind file. /// protected global::ClientDependency.Core.Controls.JsInclude JsInclude10; + + /// + /// TreeContainer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl TreeContainer; } } diff --git a/umbraco/presentation/umbraco/controls/TreeControl.ascx.cs b/umbraco/presentation/umbraco/controls/TreeControl.ascx.cs deleted file mode 100644 index ce291ac1d5..0000000000 --- a/umbraco/presentation/umbraco/controls/TreeControl.ascx.cs +++ /dev/null @@ -1,383 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.Script.Serialization; -using umbraco.interfaces; -using System.Text.RegularExpressions; -using umbraco.BusinessLogic.Actions; -using umbraco.businesslogic.Utils; -using System.Text; -using umbraco.cms.presentation.Trees; -using umbraco.BasePages; -using System.Web.Services; - -namespace umbraco.presentation.umbraco.controls -{ - - /// - /// The Umbraco tree control. - /// If this control doesn't exist on an UmbracoEnsuredPage it will not work. - /// - public partial class TreeControl : System.Web.UI.UserControl - { - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - EnableViewState = false; - } - - public enum TreeMode - { - Standard, Checkbox, InheritedCheckBox - } - - /// - /// If there is not application or tree specified in a query string then this is the application to load. - /// - private const string DEFAULT_APP = "content"; - - private List m_ActiveTrees = new List(); - private List m_AllAppTrees = new List(); - private List m_ActiveTreeDefs = null; - private TreeMode m_TreeType = TreeMode.Standard; - private bool m_IsInit = false; - private TreeService m_TreeService = null; - - /// - /// returns the current tree service being used to render the tree - /// - public TreeService TreeSvc - { - get - { - return m_TreeService; - } - } - - /// - /// Can be set explicitly which will override what is in query strings. - /// Useful for rendering out a tree dynamically. - /// - public void SetTreeService(TreeService srv) - { - m_TreeService = srv; - Initialize(); - } - - /// - /// Allows for checkboxes to be used with the tree. Default is standard. - /// - public TreeMode TreeType - { - get - { - return m_TreeType; - } - set - { - m_TreeType = value; - } - } - - /// - /// Used to create a different container id for the tree control. This is done so that - /// there is a way to differentiate between multiple trees if required. This is currently used - /// to distinguish which tree is the main umbraco tree as opposed to dialog trees. - /// - public string CustomContainerId { get; set; } - - protected void Initialize() - { - //use the query strings if the TreeParams isn't explicitly set - if (m_TreeService == null) - { - TreeRequestParams treeParams = TreeRequestParams.FromQueryStrings(); - m_TreeService = new TreeService() - { - ShowContextMenu = treeParams.ShowContextMenu, - IsDialog = treeParams.IsDialog, - DialogMode = treeParams.DialogMode, - App = treeParams.Application, - TreeType = treeParams.TreeType - }; - } - - //ensure that the application is setup correctly - m_TreeService.App = CurrentApp; - - // Validate permissions - if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID)) - return; - UmbracoEnsuredPage page = new UmbracoEnsuredPage(); - if (!page.ValidateUserApp(TreeSvc.App)) - throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator."); - - //find all tree definitions that have the current application alias that are ACTIVE - m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(TreeSvc.App); - //find all tree defs that exists for the current application regardless of if they are active - List appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(TreeSvc.App); - - //Create the BaseTree's based on the tree definitions found - foreach (TreeDefinition treeDef in appTreeDefs) - { - //create the tree and initialize it - BaseTree bTree = treeDef.CreateInstance(); - bTree.SetTreeParameters(TreeSvc); - - //store the created tree - m_AllAppTrees.Add(bTree); - if (treeDef.Tree.Initialize) - m_ActiveTrees.Add(bTree); - } - - m_IsInit = true; - } - - /// - /// This calls the databind method to bind the data binding syntax on the front-end. - /// - /// Databinding was used instead of inline tags in case the tree properties needed to be set - /// by other classes at runtime - /// - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); - - if (!m_IsInit) - Initialize(); - - //Render out the JavaScript associated with all of the trees for the application - RenderTreeJS(); - - DataBind(); - } - - /// - /// Returns the JSON markup for the full context menu - /// - public string GetJSONContextMenu() - { - JTreeContextMenu menu = new JTreeContextMenu(); - return menu.RenderJSONMenu(); - } - - /// - /// Returns the JSON markup for one node - /// - /// - /// - /// - public string GetJSONNode(string nodeId) - { - if (!m_IsInit) - Initialize(); - - if (string.IsNullOrEmpty(TreeSvc.TreeType)) - { - throw new ArgumentException("The TreeType is not set on the tree service"); - } - - BaseTree tree = m_ActiveTrees.Find( - delegate(BaseTree t) - { - return (t.TreeAlias == TreeSvc.TreeType); - } - ); - return tree.GetSerializedNodeData(nodeId); - } - - /// - /// Returns the JSON markup for the first node in the tree - /// - public string GetJSONInitNode() - { - if (!m_IsInit) - Initialize(); - - //if there is only one tree to render, we don't want to have a node to hold sub trees, we just want the - //stand alone tree, so we'll just add a TreeType to the TreeService and ensure that the right method gets loaded in tree.aspx - if (m_ActiveTrees.Count == 1) - { - TreeSvc.TreeType = m_ActiveTreeDefs[0].Tree.Alias; - - //convert the menu to a string - //string initActions = (TreeSvc.ShowContextMenu ? Action.ToString(m_ActiveTrees[0].RootNodeActions) : ""); - - //Since there's only 1 tree, render out the tree's RootNode properties - XmlTree xTree = new XmlTree(); - xTree.Add(m_ActiveTrees[0].RootNode); - return xTree.ToString(); - } - else - { - - //If there is more than 1 tree for the application than render out a - //container node labelled with the current application. - XmlTree xTree = new XmlTree(); - XmlTreeNode xNode = XmlTreeNode.CreateRoot(new NullTree(CurrentApp)); - xNode.Text = ui.Text("sections", TreeSvc.App, UmbracoEnsuredPage.CurrentUser); - xNode.Source = TreeSvc.GetServiceUrl(); - xNode.Action = ClientTools.Scripts.OpenDashboard(TreeSvc.App); - xNode.NodeType = TreeSvc.App.ToLower(); - xNode.NodeID = "-1"; - xNode.Icon = ".sprTreeFolder"; - xTree.Add(xNode); - return xTree.ToString(); - } - } - - /// - /// Returns the requires JavaScript as a string for the current application - /// - public string JSCurrApp - { - get - { - StringBuilder javascript = new StringBuilder(); - foreach (BaseTree bTree in m_AllAppTrees) - bTree.RenderJS(ref javascript); - return javascript.ToString(); - } - } - - /// - /// Return the current application alias. If neither the TreeType of Application is specified - /// than return the default application. If the Application is null but there is a TreeType then - /// find the application that the tree type is associated with. - /// - protected string CurrentApp - { - get - { - //if theres an treetype specified but no application - if (string.IsNullOrEmpty(TreeSvc.App) && - !string.IsNullOrEmpty(TreeSvc.TreeType)) - { - TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(TreeSvc.TreeType); - if (treeDef != null) - return treeDef.App.alias; - } - else if (!string.IsNullOrEmpty(TreeSvc.App)) - return TreeSvc.App; - - //if everything is null then return the default app - return DEFAULT_APP; - } - } - - private void RenderTreeJS() - { - Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Trees", JSCurrApp, true); - } - - - } - - internal class JTreeContextMenu - { - public string RenderJSONMenu() - { - - JSONSerializer jSSerializer = new JSONSerializer(); - - jSSerializer.RegisterConverters(new List() - { - new JTreeContextMenuItem() - }); - - List allActions = new List(); - foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll()) - { - if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource))) - { - allActions.Add(a); - } - - } - - - return jSSerializer.Serialize(allActions); - } - } - - internal class JTreeContextMenuItem : JavaScriptConverter - { - - /// - /// Not implemented as we never need to Deserialize - /// - /// - /// - /// - /// - public override object Deserialize(IDictionary dictionary, Type type, JavaScriptSerializer serializer) - { - throw new NotImplementedException(); - } - - public override IDictionary Serialize(object obj, JavaScriptSerializer serializer) - { - //{ - // "id": "L", - // "label": "Create", - // "icon": "create.png", - // "visible": function(NODE, TREE_OBJ) { if (NODE.length != 1) return false; return TREE_OBJ.check("creatable", NODE); }, - // "action": function(NODE, TREE_OBJ) { TREE_OBJ.create(false, NODE); }, - //} - - - IAction a = (IAction)obj; - Dictionary data = new Dictionary(); - - data.Add("id", a.Letter); - data.Add("label", ui.Text(a.Alias)); - - if (a.Icon.StartsWith(".")) - { - StringBuilder sb = new StringBuilder(); - sb.Append(string.Format(""); - sb.Append(""); - data["label"] = sb.ToString(); - } - else - { - data.Add("icon", a.Icon); - } - - //required by jsTree - data.Add("visible", JSONSerializer.ToJSONObject("function() {return true;}")); - //The action handler is what is assigned to the IAction, but for flexibility, we'll call our onContextMenuSelect method which will need to return true if the function is to execute. - //TODO: Check if there is a JSSource - data.Add("action", JSONSerializer.ToJSONObject("function(N,T){" + a.JsFunctionName + ";}")); - - return data; - - } - - /// - /// TODO: Find out why we can't just return IAction as one type (JavaScriptSerializer doesn't seem to pick up on it) - /// - public override IEnumerable SupportedTypes - { - get - { - List types = new List(); - foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll()) - { - types.Add(a.GetType()); - } - return types; - } - - - } - } -} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/create/content.ascx b/umbraco/presentation/umbraco/create/content.ascx index 49ae2745b7..da1a385f02 100644 --- a/umbraco/presentation/umbraco/create/content.ascx +++ b/umbraco/presentation/umbraco/create/content.ascx @@ -19,7 +19,7 @@
or - <%=umbraco.ui.Text("cancel")%> + <%=umbraco.ui.Text("cancel")%> - - - - - - - - - + + - - + + - - -
-
- -
-
-
- - -
- - -
+ <%--when a node is selected, the id will be stored in this field--%> + + + + +
+ + + - + -
-

- or - {#cancel} -

- - - - - - +

+ " style="width: 60px; + color: gray" disabled="disabled" id="submitbutton" /> + + <%# umbraco.ui.Text("or") %> + <%#umbraco.ui.Text("cancel") %> +

+
diff --git a/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.cs b/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.cs index 2e70346438..0b30058780 100644 --- a/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.cs @@ -4,15 +4,16 @@ using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using umbraco.BasePages; namespace umbraco.presentation.umbraco.dialogs { - public partial class mediaPicker : System.Web.UI.Page + public partial class mediaPicker : UmbracoEnsuredPage { protected void Page_Load(object sender, EventArgs e) { - - + if (!IsPostBack) + DataBind(); } diff --git a/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.designer.cs index 411be9c340..82c08429dd 100644 --- a/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/mediaPicker.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3074 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -13,78 +13,6 @@ namespace umbraco.presentation.umbraco.dialogs { public partial class mediaPicker { - /// - /// Head1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlHead Head1; - - /// - /// CssInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; - - /// - /// JsInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; - - /// - /// JsInclude3 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude3; - - /// - /// JsInclude4 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude4; - - /// - /// JsInclude2 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; - - /// - /// ClientLoader control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; - - /// - /// Form1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlForm Form1; - /// /// pane_src control. /// @@ -94,6 +22,15 @@ namespace umbraco.presentation.umbraco.dialogs { /// protected global::umbraco.uicontrols.Pane pane_src; + /// + /// ImageViewer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Images.ImageViewer ImageViewer; + /// /// tv_options control. /// @@ -112,6 +49,15 @@ namespace umbraco.presentation.umbraco.dialogs { /// protected global::umbraco.uicontrols.Pane pane_select; + /// + /// DialogTree control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl DialogTree; + /// /// pane_upload control. /// @@ -120,5 +66,14 @@ namespace umbraco.presentation.umbraco.dialogs { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.Panel pane_upload; + + /// + /// MediaUploader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Images.UploadMediaImage MediaUploader; } } diff --git a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx index 79988c6adc..9fc2e74da6 100644 --- a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx +++ b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx @@ -1,6 +1,8 @@ <%@ Page Language="c#" CodeBehind="moveOrCopy.aspx.cs" MasterPageFile="../masterpages/umbracoDialog.Master" AutoEventWireup="True" Inherits="umbraco.dialogs.moveOrCopy" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register Src="../controls/Tree/TreeControl.ascx" TagName="TreeControl" TagPrefix="umbraco" %> + @@ -51,8 +44,10 @@ function doSubmit() {document.Form1["ok"].click()} - - + + @@ -76,7 +71,7 @@ function doSubmit() {document.Form1["ok"].click()}

  - <%=umbraco.ui.Text("general", "or", this.getUser())%>   + <%=umbraco.ui.Text("general", "or", this.getUser())%>   <%=umbraco.ui.Text("general", "cancel", this.getUser())%>

diff --git a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs index efe7acde80..9658147453 100644 --- a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -24,6 +24,8 @@ namespace umbraco.dialogs protected void Page_Load(object sender, System.EventArgs e) { + JTree.DataBind(); + // Put user code to initialize the page here if (!IsPostBack) { //Document Type copy Hack... @@ -259,7 +261,7 @@ namespace umbraco.dialogs m.Move(int.Parse(UmbracoContext.Current.Request["copyTo"])); } - feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, base.getUser()) + "

" + ui.Text("closeThisWindow") + ""; + feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, base.getUser()) + "

" + ui.Text("closeThisWindow") + ""; feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; // refresh tree @@ -270,7 +272,7 @@ namespace umbraco.dialogs { cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id"))); d.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked); - feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "

" + ui.Text("closeThisWindow") + ""; + feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "

" + ui.Text("closeThisWindow") + ""; feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path); } diff --git a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.designer.cs index c08ac1b7ef..334f79a404 100644 --- a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -40,6 +40,15 @@ namespace umbraco.dialogs { /// protected global::umbraco.uicontrols.Pane pane_form; + ///

+ /// JTree control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl JTree; + /// /// pp_relate control. /// diff --git a/umbraco/presentation/umbraco/dialogs/notifications.aspx b/umbraco/presentation/umbraco/dialogs/notifications.aspx index 26ed4f2c40..34e586dcac 100644 --- a/umbraco/presentation/umbraco/dialogs/notifications.aspx +++ b/umbraco/presentation/umbraco/dialogs/notifications.aspx @@ -18,7 +18,7 @@
<%= umbraco.ui.Text("or") %>  <%=umbraco.ui.Text("cancel")%><%= umbraco.ui.Text("or") %>  <%=umbraco.ui.Text("cancel")%>
\ No newline at end of file diff --git a/umbraco/presentation/umbraco/dialogs/notifications.aspx.cs b/umbraco/presentation/umbraco/dialogs/notifications.aspx.cs index cf14caff27..7e7b18bdc1 100644 --- a/umbraco/presentation/umbraco/dialogs/notifications.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/notifications.aspx.cs @@ -88,7 +88,7 @@ namespace umbraco.dialogs base.getUser().initNotifications(); - feedback.Text = ui.Text("notifications") + " " + ui.Text("ok") + "

" + ui.Text("closeThisWindow") + ""; + feedback.Text = ui.Text("notifications") + " " + ui.Text("ok") + "

" + ui.Text("closeThisWindow") + ""; feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; pane_form.Visible = false; diff --git a/umbraco/presentation/umbraco/dialogs/notifications.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/notifications.aspx.designer.cs index a7e5247068..15ce3d33b1 100644 --- a/umbraco/presentation/umbraco/dialogs/notifications.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/notifications.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/umbraco/presentation/umbraco/dialogs/protectPage.aspx b/umbraco/presentation/umbraco/dialogs/protectPage.aspx index c2fce75921..19edd39dfc 100644 --- a/umbraco/presentation/umbraco/dialogs/protectPage.aspx +++ b/umbraco/presentation/umbraco/dialogs/protectPage.aspx @@ -103,7 +103,7 @@

-   <%= umbraco.ui.Text("or") %>  <%=umbraco.ui.Text("cancel")%> +   <%= umbraco.ui.Text("or") %>  <%=umbraco.ui.Text("cancel")%>

@@ -153,7 +153,7 @@

-   <%= umbraco.ui.Text("or") %>  <%=umbraco.ui.Text("cancel")%> +   <%= umbraco.ui.Text("or") %>  <%=umbraco.ui.Text("cancel")%>

diff --git a/umbraco/presentation/umbraco/dialogs/protectPage.aspx.cs b/umbraco/presentation/umbraco/dialogs/protectPage.aspx.cs index 49ef5bb351..104936d3a7 100644 --- a/umbraco/presentation/umbraco/dialogs/protectPage.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/protectPage.aspx.cs @@ -229,7 +229,7 @@ namespace umbraco.presentation.umbraco.dialogs cms.businesslogic.web.Access.RemoveMembershipRoleFromDocument(pageId, li.Value); } - feedback.Text = ui.Text("publicAccess", "paIsProtected", new cms.businesslogic.CMSNode(pageId).Text, null) + "

" + ui.Text("closeThisWindow") + ""; + feedback.Text = ui.Text("publicAccess", "paIsProtected", new cms.businesslogic.CMSNode(pageId).Text, null) + "

" + ui.Text("closeThisWindow") + ""; ClientTools.ReloadActionNode(true, false); @@ -247,7 +247,7 @@ namespace umbraco.presentation.umbraco.dialogs Access.RemoveProtection(pageId); - feedback.Text = ui.Text("publicAccess", "paIsRemoved", new cms.businesslogic.CMSNode(pageId).Text, null) + "

" + ui.Text("closeThisWindow") + ""; + feedback.Text = ui.Text("publicAccess", "paIsRemoved", new cms.businesslogic.CMSNode(pageId).Text, null) + "

" + ui.Text("closeThisWindow") + ""; ClientTools.ReloadActionNode(true, false); diff --git a/umbraco/presentation/umbraco/dialogs/protectPage.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/protectPage.aspx.designer.cs index 7e04e5fa26..6ed66eea24 100644 --- a/umbraco/presentation/umbraco/dialogs/protectPage.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/protectPage.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/umbraco/presentation/umbraco/dialogs/publish.aspx b/umbraco/presentation/umbraco/dialogs/publish.aspx index 2246da7ace..acd3e6e856 100644 --- a/umbraco/presentation/umbraco/dialogs/publish.aspx +++ b/umbraco/presentation/umbraco/dialogs/publish.aspx @@ -85,7 +85,7 @@

- <%= umbraco.ui.Text("general","or") %> <%=umbraco.ui.Text("general", "cancel", this.getUser())%> + <%= umbraco.ui.Text("general","or") %> <%=umbraco.ui.Text("general", "cancel", this.getUser())%>
diff --git a/umbraco/presentation/umbraco/dialogs/sort.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/sort.aspx.designer.cs index 496c4cbe4e..3287cd1289 100644 --- a/umbraco/presentation/umbraco/dialogs/sort.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/sort.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3603 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/umbraco/presentation/umbraco/dialogs/treePicker.aspx b/umbraco/presentation/umbraco/dialogs/treePicker.aspx index c55dd1a64b..b782dc3412 100644 --- a/umbraco/presentation/umbraco/dialogs/treePicker.aspx +++ b/umbraco/presentation/umbraco/dialogs/treePicker.aspx @@ -1,89 +1,23 @@ -<%@ Page Language="c#" Codebehind="treePicker.aspx.cs" AutoEventWireup="True" Inherits="umbraco.dialogs.treePicker" %> +<%@ Page Language="c#" MasterPageFile="../masterpages/umbracoDialog.Master" CodeBehind="treePicker.aspx.cs" + AutoEventWireup="True" Inherits="umbraco.dialogs.treePicker" %> + <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register TagPrefix="umb2" TagName="Tree" Src="../controls/Tree/TreeControl.ascx" %> + + + + - - - - - umbraco - - - - - + - - - - - -
- -
- -
-
- - + + +
diff --git a/umbraco/presentation/umbraco/dialogs/treePicker.aspx.cs b/umbraco/presentation/umbraco/dialogs/treePicker.aspx.cs index 12bdf6ab47..c1f29d9c0e 100644 --- a/umbraco/presentation/umbraco/dialogs/treePicker.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/treePicker.aspx.cs @@ -12,42 +12,17 @@ using umbraco.cms.presentation.Trees; namespace umbraco.dialogs { - /// - /// Summary description for treePicker. - /// + [Obsolete("Use the TreeControl instead. This does however get used by the TreeService when requesting the tree init url.")] public partial class treePicker : BasePages.UmbracoEnsuredPage { protected override void OnLoad(EventArgs e) { base.OnLoad(e); - ClientLoader.DataBind(); + TreeParams = TreeRequestParams.FromQueryStrings().CreateTreeService(); + DataBind(); } - protected string TreeInitUrl - { - get - { - TreeRequestParams treeParams = TreeRequestParams.FromQueryStrings(); + protected TreeService TreeParams { get; private set; } - return TreeService.GetInitUrl(null, treeParams.TreeType, false, true, TreeDialogModes.id, treeParams.Application, "", ""); - } - } - - - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - InitializeComponent(); - base.OnInit(e); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - } - #endregion } } diff --git a/umbraco/presentation/umbraco/dialogs/treePicker.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/treePicker.aspx.designer.cs index 69875cb8f7..547394a509 100644 --- a/umbraco/presentation/umbraco/dialogs/treePicker.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/treePicker.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3603 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -14,21 +14,12 @@ namespace umbraco.dialogs { public partial class treePicker { /// - /// ClientLoader control. + /// DialogTree control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; - - /// - /// JsInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; + protected global::umbraco.controls.Tree.TreeControl DialogTree; } } diff --git a/umbraco/presentation/umbraco/dialogs/umbracoField.aspx b/umbraco/presentation/umbraco/dialogs/umbracoField.aspx index 53b7fb5e44..0d9f7c529d 100644 --- a/umbraco/presentation/umbraco/dialogs/umbracoField.aspx +++ b/umbraco/presentation/umbraco/dialogs/umbracoField.aspx @@ -67,7 +67,7 @@ UmbClientMgr.contentFrame().UmbEditor.Insert(tagString, '', '<%=umbraco.helper.Request("objectId")%>'); - UmbClientMgr.mainWindow().closeModal(); + UmbClientMgr.closeModalWindow(); } var functionsFrame = this; @@ -169,6 +169,6 @@
" onclick="doSubmit()">   or   - <%=umbraco.ui.Text("general", "cancel", this.getUser())%> + <%=umbraco.ui.Text("general", "cancel", this.getUser())%> \ No newline at end of file diff --git a/umbraco/presentation/umbraco/dialogs/umbracoField.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/umbracoField.aspx.designer.cs index 558b59f883..fc13b548da 100644 --- a/umbraco/presentation/umbraco/dialogs/umbracoField.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/umbracoField.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3074 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/umbraco/presentation/umbraco/dialogs/uploadImage.aspx b/umbraco/presentation/umbraco/dialogs/uploadImage.aspx index 08354e4202..f72dba32d0 100644 --- a/umbraco/presentation/umbraco/dialogs/uploadImage.aspx +++ b/umbraco/presentation/umbraco/dialogs/uploadImage.aspx @@ -1,66 +1,28 @@ -<%@ Page language="c#"MasterPageFile="../masterpages/umbracoDialog.Master" Codebehind="uploadImage.aspx.cs" AutoEventWireup="True" Inherits="umbraco.dialogs.uploadImage" %> +<%@ Page Language="c#" MasterPageFile="../masterpages/umbracoDialog.Master" CodeBehind="uploadImage.aspx.cs" + AutoEventWireup="True" Inherits="umbraco.dialogs.uploadImage" %> + <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> - +<%@ Register TagName="MediaUpload" TagPrefix="umb" Src="../controls/Images/UploadMediaImage.ascx" %> + - - var imageName = tb_image.value; - if (imageName.length > 0) { - var extension = imageName.substring(imageName.lastIndexOf(".") + 1, imageName.length); - if (imageTypes.indexOf(',' + extension.toLowerCase() + ',') > -1) { - bt_submit.disabled = false; - if(tb_title.value == "") - tb_title.value = imageName.substring(imageName.lastIndexOf("\\") + 1, imageName.length).replace("." + extension, ""); - } - } - } - - function chooseId() { - var treePicker = window.showModalDialog('<%=umbraco.cms.presentation.Trees.TreeService.GetPickerUrl(true,"media","media")%>', 'treePicker', 'dialogWidth=350px;dialogHeight=300px;scrollbars=no;center=yes;border=thin;help=no;status=no') - if (treePicker != undefined) { - document.getElementById("ctl00_body_folderid").value = treePicker; - if (treePicker > 0) { - umbraco.presentation.webservices.CMSNode.GetNodeName('<%=umbraco.BasePages.BasePage.umbracoUserContextID%>', treePicker, updateContentTitle); - } - } - } - function updateContentTitle(result) { - document.getElementById("mediaTitle").innerHTML = "" + result + ""; - } - - - - - - - - - - - - - - - - - - - - - + - \ No newline at end of file diff --git a/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.cs b/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.cs index b729ba93d6..8c3defc8a0 100644 --- a/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.cs @@ -14,95 +14,9 @@ using umbraco.IO; namespace umbraco.dialogs { - /// - /// Summary description for uploadImage. - /// + [Obsolete("Use the UploadMediaImage control instead")] public partial class uploadImage : BasePages.UmbracoEnsuredPage { - protected controls.ContentPicker mediaPickerControl = new umbraco.controls.ContentPicker(); - - protected interfaces.IDataType uploadField = new cms.businesslogic.datatype.controls.Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c")); - - protected void Page_Load(object sender, System.EventArgs e) - { - //uploadField.Alias = "umbracoFile"; - ((HtmlInputFile) uploadField.DataEditor).Attributes.Add("onChange", "validateImage()"); - ((HtmlInputFile) uploadField.DataEditor).ID = "uploadFile"; - - mediaPickerControl.ID = "mediaPickerControl"; - mediaPickerControl.AppAlias = "media"; - mediaPickerControl.TreeAlias = "media"; - mediaPickerControl.ModalHeight = 200; - mediaPickerControl.ShowDelete = false; - mediaPickerControl.Text = this.getUser().StartMediaId.ToString(); - mediaPicker.Controls.Add(mediaPickerControl); - - if (!IsPostBack) - { - Button1.Text = ui.Text("save"); - //LiteralTitle.Text = ui.Text("name"); - //LiteralUpload.Text = ui.Text("choose"); - } - else - { - - cms.businesslogic.media.Media m = cms.businesslogic.media.Media.MakeNew(TextBoxTitle.Text, cms.businesslogic.media.MediaType.GetByAlias("image"), this.getUser(), int.Parse(mediaPickerControl.Text)); - var props = m.getProperties; - foreach (cms.businesslogic.property.Property p in props) { - if (p.PropertyType.DataTypeDefinition.DataType.Id == uploadField.Id) - { - uploadField.DataTypeDefinitionId = p.PropertyType.DataTypeDefinition.Id; - uploadField.Data.PropertyId = p.Id; - } - } - uploadField.DataEditor.Save(); - - // Generate xml on image - m.XmlGenerate(new XmlDocument()); - pane_upload.Visible = false; - - string imagename = m.getProperty("umbracoFile").Value.ToString(); - string extension = imagename.Substring(imagename.LastIndexOf(".") + 1, imagename.Length - imagename.LastIndexOf(".") -1); - - imagename = imagename.Remove(imagename.Length-extension.Length-1,extension.Length+1) + "_thumb.jpg"; - - feedback.Style.Add("margin-top", "8px"); - feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; - feedback.Text += ""; - - feedback.Text += ""; - - } - // Put user code to initialize the page here - } - - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - InitializeComponent(); - base.OnInit(e); - - // Get upload field from datafield factory - PlaceHolder1.Controls.Add((Control) uploadField.DataEditor); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - - } - #endregion - - protected void Button1_Click(object sender, System.EventArgs e) - { - - } + } } diff --git a/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.designer.cs index 7075f582af..b34a3851bf 100644 --- a/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.designer.cs +++ b/umbraco/presentation/umbraco/dialogs/uploadImage.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -14,93 +14,12 @@ namespace umbraco.dialogs { public partial class uploadImage { /// - /// pane_upload control. + /// MediaUploader control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::umbraco.uicontrols.Pane pane_upload; - - /// - /// pp_name control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_name; - - /// - /// TextBoxTitle control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox TextBoxTitle; - - /// - /// pp_file control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_file; - - /// - /// PlaceHolder1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder PlaceHolder1; - - /// - /// pp_target control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_target; - - /// - /// mediaPicker control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder mediaPicker; - - /// - /// pp_button control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_button; - - /// - /// Button1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button Button1; - - /// - /// feedback control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Feedback feedback; + protected global::umbraco.controls.Images.UploadMediaImage MediaUploader; } } diff --git a/umbraco/presentation/umbraco/images/throbber.gif b/umbraco/presentation/umbraco/images/throbber.gif new file mode 100644 index 0000000000..95ff649d41 Binary files /dev/null and b/umbraco/presentation/umbraco/images/throbber.gif differ diff --git a/umbraco/presentation/umbraco/masterpages/umbracoPage.Master b/umbraco/presentation/umbraco/masterpages/umbracoPage.Master index 228c94ba3e..d4c5768a77 100644 --- a/umbraco/presentation/umbraco/masterpages/umbracoPage.Master +++ b/umbraco/presentation/umbraco/masterpages/umbracoPage.Master @@ -13,14 +13,15 @@ + - + - +
diff --git a/umbraco/presentation/umbraco/masterpages/umbracoPage.Master.designer.cs b/umbraco/presentation/umbraco/masterpages/umbracoPage.Master.designer.cs index e6fc35e47b..eac20e90a5 100644 --- a/umbraco/presentation/umbraco/masterpages/umbracoPage.Master.designer.cs +++ b/umbraco/presentation/umbraco/masterpages/umbracoPage.Master.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -40,6 +40,15 @@ namespace umbraco.presentation.umbraco.masterpages { /// protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; + /// + /// CssInclude2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.CssInclude CssInclude2; + /// /// JsInclude1 control. /// @@ -58,6 +67,15 @@ namespace umbraco.presentation.umbraco.masterpages { /// protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; + /// + /// JsInclude8 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude8; + /// /// JsInclude4 control. /// @@ -85,6 +103,15 @@ namespace umbraco.presentation.umbraco.masterpages { /// protected global::ClientDependency.Core.Controls.JsInclude JsInclude6; + /// + /// JsInclude7 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude7; + /// /// JsInclude3 control. /// diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx b/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx index 3b95c2afef..70f0808de4 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx @@ -1,37 +1,58 @@ <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="insertImage.aspx.cs" Inherits="umbraco.presentation.plugins.tinymce3.insertImage" %> <%@ Register TagPrefix="ui" Namespace="umbraco.uicontrols" Assembly="controls" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> +<%@ Register TagPrefix="umb2" TagName="Tree" Src="../../controls/Tree/TreeControl.ascx" %> +<%@ Register TagPrefix="umb3" TagName="Image" Src="../../controls/Images/ImageViewer.ascx" %> +<%@ Register TagName="MediaUpload" TagPrefix="umb4" Src="../../controls/Images/UploadMediaImage.ascx" %> {#advimage_dlg.dialog_title} - - + <%----%> + + + + + + - - - - + + @@ -111,14 +136,15 @@ - - + + + + + -
-   -
+ @@ -137,382 +163,24 @@ +
- - + +
- +

- or {#cancel} + or {#cancel}

- - - - - - diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs b/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs index 258a1cbc13..e81484bf3d 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.cs @@ -29,14 +29,10 @@ namespace umbraco.presentation.plugins.tinymce3 uicontrols.TabPage tp = tv_options.NewTabPage(ui.Text("choose")); tp.HasMenu = false; tp.Controls.Add(pane_select); - - //tp.Controls.Add(new LiteralControl("
 
")); - + uicontrols.TabPage tp2 = tv_options.NewTabPage(ui.Text("create") + " " + ui.Text("new")); tp2.HasMenu = false; tp2.Controls.Add(pane_upload); - - //tp2.Controls.Add(new LiteralControl("")); } #region Web Form Designer generated code diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.designer.cs b/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.designer.cs index 4a3e711922..6a882ba0b4 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.designer.cs +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertImage.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -31,6 +31,15 @@ namespace umbraco.presentation.plugins.tinymce3 { /// protected global::ClientDependency.Core.Controls.JsInclude JsInclude3; + /// + /// JsInclude9 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude9; + /// /// JsInclude8 control. /// @@ -94,6 +103,24 @@ namespace umbraco.presentation.plugins.tinymce3 { /// protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; + /// + /// Form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm Form1; + + /// + /// ScriptManager1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.ScriptManager ScriptManager1; + /// /// pane_src control. /// @@ -103,6 +130,15 @@ namespace umbraco.presentation.plugins.tinymce3 { /// protected global::umbraco.uicontrols.Pane pane_src; + /// + /// ImageViewer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Images.ImageViewer ImageViewer; + /// /// pp_src control. /// @@ -175,6 +211,15 @@ namespace umbraco.presentation.plugins.tinymce3 { /// protected global::umbraco.uicontrols.Pane pane_select; + /// + /// DialogTree control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl DialogTree; + /// /// pane_upload control. /// @@ -185,21 +230,12 @@ namespace umbraco.presentation.plugins.tinymce3 { protected global::System.Web.UI.WebControls.Panel pane_upload; /// - /// Table1 control. + /// MediaUploader control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.HtmlControls.HtmlTable Table1; - - /// - /// PlaceHolder1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder PlaceHolder1; + protected global::umbraco.controls.Images.UploadMediaImage MediaUploader; } } diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx b/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx index a75bc97408..dee74da7fa 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx @@ -1,6 +1,8 @@ <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="insertLink.aspx.cs" Inherits="umbraco.presentation.plugins.tinymce3.insertLink" %> <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> <%@ Register TagPrefix="ui" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register Src="../../controls/Tree/TreeControl.ascx" TagName="TreeControl" TagPrefix="umbraco" %> + @@ -108,13 +110,17 @@
- +
- -
+ +

diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs b/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs index a20670b476..8928f02994 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.cs @@ -18,15 +18,14 @@ namespace umbraco.presentation.plugins.tinymce3 tp.HasMenu = false; tp.Controls.Add(pane_content); - //tp.Controls.Add(new LiteralControl("")); + uicontrols.TabPage tp2 = tv_options.NewTabPage(ui.Text("media")); tp2.HasMenu = false; tp2.Controls.Add(pane_media); - //tp2.Controls.Add(new LiteralControl("")); - //umbracoLink.Controls.Add(tbv); + } protected override void Render(HtmlTextWriter writer) diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.designer.cs b/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.designer.cs index f5b6e963e3..4f43e2a47c 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.designer.cs +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertLink.aspx.designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.4200 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -121,6 +121,15 @@ namespace umbraco.presentation.plugins.tinymce3 { /// protected global::umbraco.uicontrols.Pane pane_content; + /// + /// TreeControl2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl TreeControl2; + /// /// pane_media control. /// @@ -130,6 +139,15 @@ namespace umbraco.presentation.plugins.tinymce3 { /// protected global::umbraco.uicontrols.Pane pane_media; + /// + /// TreeControl1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl TreeControl1; + /// /// umbracoLink control. /// diff --git a/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx b/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx index a93e2c6fb4..9f063ef1a2 100644 --- a/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx +++ b/umbraco/presentation/umbraco/plugins/tinymce3/insertMacro.aspx @@ -7,14 +7,13 @@ {#advlink_dlg.title} - - - -
-
-
-
-
- × -
- -
-
+ +
+
+ +
+
× +
+
+ + "); + this._getContainer().after(""); } return eval(msg.json); } @@ -540,8 +635,10 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); }, onBeforeRequest: function(NODE, TREE_OBJ) { + this._ensureContext(); + if (TREE_OBJ.settings.data.opts.method == "POST") { - var parameters = "{'app':'" + this._app + "','showContextMenu':'" + this._showContext + "', 'isDialog':'" + this._isDialog + "'}" + var parameters = "{'app':'" + this._app + "','showContextMenu':'" + this._showContext + "', 'isDialog':'" + this._isDialog + "', 'dialogMode':'" + this._dialogMode + "', 'treeType':'" + this._treeType + "', 'functionToCall':'" + this._functionToCall + "', 'nodeKey':'" + this._nodeKey + "'}" return parameters; } else { @@ -571,11 +668,11 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); this._debug("onLoad"); - this._container.show(); + this._getContainer().show(); //ensure the static data is gone this._tree.settings.data.opts.static = null; var _this = this; - _this._loadChildNodes($(_this._container).find("li"), null); + _this._loadChildNodes($(_this._getContainer()).find("li"), null); }, onBeforeMove: function(NODE, REF_NODE, TYPE, TREE_OBJ) { @@ -622,12 +719,18 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); onParse: function(STR, TREE_OBJ) { this._debug("onParse"); + this._ensureContext(); + var obj = $(STR); this._configureNodes(obj); //this will return the full html of the configured node return $('
').append($(obj).clone()).remove().html(); }, + onError: function(ERR, TREE_OBJ) { + this._debug("ERROR!!!!! " + ERR); + }, + _debug: function(strMsg) { if (this._isDebug) { Sys.Debug.trace("UmbracoTree: " + strMsg); @@ -653,7 +756,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); var rxInput = new RegExp("\\boverlay-\\w+\\b", "gi"); nodes.each(function() { //if it is checkbox tree (not standard), don't worry about overlays and remove the default icon. - if (_this._treeType != "standard") { + if (_this._treeMode != "standard") { $(this).children("a:first").css("background", ""); return; } @@ -709,7 +812,14 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); }); } }, - + _ensureContext: function() { + /// + /// ensure that the tree object always has the correct context. + /// this is a fix for the TinyMCE dialog window, as it tends to lose object context for some wacky reason + /// when ajax calls are made. Works fine in all other instances. + /// + this._tree.container = this._getContainer(); + }, _loadChildNodes: function(liNode, callback) { /// jsTree won't allow you to open a node that doesn't explitly have childen, this will force it to try /// a jquery object for the current li node @@ -785,59 +895,6 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); } }, - _init: function(jFullMenu, jInitNode, treeContainer, appActions, uiKeys, app, showContext, isDialog, treeType, serviceUrl, dataUrl, umbClientFolder, recycleBinId) { - /// initialization method, must be called on page ready. - /// JSON markup for the full context menu in accordance with the jsTree context menu object standard - /// JSON markup for the initial node to show - /// the jQuery element to be tree enabled - /// A reference to a MenuActions object - /// A reference to a uiKeys object - /// boolean indicating whether or not to show a context menu - /// boolean indicating whether or not the tree is in dialog mode - /// determines the type of tree: false/null = normal, 'checkbox' = checkboxes enabled, 'inheritedcheckbox' = parent nodes have checks inherited from children - /// Url path for the tree client service - /// Url path for the tree data service - /// Should be set externally!... the root to the umbraco_client folder - /// the id of the recycle bin for the current tree - - this._debug("_init: creating new tree with class/id: " + treeContainer.attr("class") + " / " + treeContainer.attr("id")); - - this._fullMenu = jFullMenu; - this._initNode = jInitNode; - this._appActions = appActions; - this._uiKeys = uiKeys; - this._app = app; - this._showContext = showContext; - this._isDialog = isDialog; - this._treeType = treeType; - this._serviceUrl = serviceUrl; - this._dataUrl = dataUrl; - this._umb_clientFolderRoot = umbClientFolder; - this._recycleBinId = recycleBinId; - - //wire up event handlers - if (this._appActions != null) { - var _this = this; - //wrapped functions maintain scope - this._appActions.addEventHandler("nodeDeleting", function(E) { _this.onNodeDeleting(E) }); - this._appActions.addEventHandler("nodeDeleted", function(E) { _this.onNodeDeleted(E) }); - this._appActions.addEventHandler("nodeRefresh", function(E) { _this.onNodeRefresh(E) }); - } - - //initializes the jsTree - this._container = treeContainer; - this._tree = $.tree.create(); - this._tree.init(this._container, this._getInitOptions()); - //this._tree.rename = this._umbracoRename; //replaces the jsTree rename method - - //add this app to the loaded apps array - //if ($.inArray(app, this._loadedApps) == -1) { - // this._loadedApps.push(app); - //} - - //load child nodes of the init node - //this._loadChildNodes(this._container.find("li:first"), null); - }, // _umbracoRename : function (obj) { // /// A modified version of the original jsTree rename method. We need to use our own since @@ -912,7 +969,9 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); var params = nodeSource.split("?")[1]; return this._dataUrl + "?" + params + "&rnd2=" + Umbraco.Utils.generateRandom(); }, - + _getContainer: function() { + return $("#" + this._containerId, this._context); + }, _getInitOptions: function(initData) { /// return the initialization objects for the tree @@ -937,7 +996,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); rtl: false, animation: false, hover_mode: true, - theme_path: this._umb_clientFolderRoot + "/Tree/Themes/", + theme_path: this._umbClientFolderRoot + "/Tree/Themes/", theme_name: "umbraco" }, langs: { @@ -954,7 +1013,8 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); onchange: function(N, T) { _this.onChange(N, T); }, ondata: function(D, T) { return _this.onJSONData(D, T); }, onload: function(T) { if (initData == null) _this.onLoad(T); }, - onparse: function(S, T) { return _this.onParse(S, T); } + onparse: function(S, T) { return _this.onParse(S, T); }, + error: function(E, T) { _this.onError(E, T); } }, plugins: { //UmbracoContext comes before context menu so that the events fire first @@ -965,7 +1025,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); contextmenu: {} } }; - if (this._treeType != "standard") { + if (this._treeMode != "standard") { options.plugins.checkbox = { three_state: false } } @@ -980,4 +1040,10 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls"); }; } + + // instance manager + Umbraco.Controls.UmbracoTree.cntr = 0; + Umbraco.Controls.UmbracoTree.inst = {}; + + })(jQuery); diff --git a/umbraco/presentation/umbraco_client/Tree/tree_component.js b/umbraco/presentation/umbraco_client/Tree/tree_component.js deleted file mode 100644 index 0d201cd213..0000000000 --- a/umbraco/presentation/umbraco_client/Tree/tree_component.js +++ /dev/null @@ -1,2315 +0,0 @@ -/* - * jsTree 0.9.8 - * http://jstree.com/ - * - * Copyright (c) 2009 Ivan Bozhanov (vakata.com) - * - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * Date: 2009-05-15 - * - */ - -(function($) { - // jQuery plugin - $.fn.tree = function (opts) { - return this.each(function() { - var conf = $.extend({},opts); - if(tree_component.inst && tree_component.inst[$(this).attr('id')]) tree_component.inst[$(this).attr('id')].destroy(); - if(conf !== false) new tree_component().init(this, conf); - }); - }; - $.tree_create = function() { - return new tree_component(); - }; - $.tree_focused = function() { - return tree_component.inst[tree_component.focused]; - }; - $.tree_reference = function(id) { - return tree_component.inst[id] || null; - }; - - // rollback - $.tree_rollback = function(data) { - for(var i in data) { - if(typeof data[i] == "function") continue; - var tmp = tree_component.inst[i]; - var lock = !tmp.locked; - - // if not locked - lock the tree - if(lock) tmp.lock(true); - // Cancel ongoing rename - if(tmp.inp) tmp.inp.val("").blur(); - tmp.context.append = false; - tmp.container.html(data[i].html).find(".dragged").removeClass("dragged").end().find("div.context").remove(); - - if(data[i].selected) { - tmp.selected = $("#" + data[i].selected); - tmp.selected_arr = []; - tmp.container - .find("a.clicked").each( function () { - tmp.selected_arr.push(tmp.get_node(this)); - }); - } - // if this function set the lock - unlock - if(lock) tmp.lock(false); - - delete lock; - delete tmp; - } - }; - - // core - function tree_component () { - // instance manager - if(typeof tree_component.inst == "undefined") { - tree_component.cntr = 0; - tree_component.inst = {}; - - // DRAG'N'DROP STUFF - tree_component.drag_drop = { - isdown : false, // Is there a drag - drag_node : false, // The actual node - drag_help : false, // The helper - - init_x : false, - init_y : false, - moving : false, - - origin_tree : false, - marker : false, - - move_type : false, // before, after or inside - ref_node : false, // reference node - appended : false, // is helper appended - - foreign : false, // Is the dragged node a foreign one - droppable : [], // Array of classes that can be dropped onto the tree - - open_time : false, // Timeout for opening nodes - scroll_time : false // Timeout for scrolling - }; - // listening for clicks on foreign nodes - tree_component.mousedown = function(event) { - var tmp = $(event.target); - if(tree_component.drag_drop.droppable.length && tmp.is("." + tree_component.drag_drop.droppable.join(", .")) ) { - tree_component.drag_drop.drag_help = $(""); - tree_component.drag_drop.drag_node = tree_component.drag_drop.drag_help.find("li:eq(0)"); - tree_component.drag_drop.isdown = true; - tree_component.drag_drop.foreign = tmp; - tmp.blur(); - event.preventDefault(); - event.stopPropagation(); - return false; - } - event.stopPropagation(); - return true; - }; - tree_component.mouseup = function(event) { - var tmp = tree_component.drag_drop; - if(tmp.open_time) clearTimeout(tmp.open_time); - if(tmp.scroll_time) clearTimeout(tmp.scroll_time); - if(tmp.foreign === false && tmp.drag_node && tmp.drag_node.size()) { - tmp.drag_help.remove(); - if(tmp.move_type) { - var tree1 = tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")]; - if(tree1) tree1.moved(tmp.origin_tree.container.find("li.dragged"), tmp.ref_node, tmp.move_type, false, (tmp.origin_tree.settings.rules.drag_copy == "on" || (tmp.origin_tree.settings.rules.drag_copy == "ctrl" && event.ctrlKey) ) ); - } - tmp.move_type = false; - tmp.ref_node = false; - } - if(tmp.drag_node && tmp.foreign !== false) { - tmp.drag_help.remove(); - if(tmp.move_type) { - var tree1 = tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")]; - if(tree1) tree1.settings.callback.ondrop.call(null, tmp.foreign.get(0), tree1.get_node(tmp.ref_node).get(0), tmp.move_type, tree1); - } - tmp.foreign = false; - tmp.move_type = false; - tmp.ref_node = false; - } - // RESET EVERYTHING - tree_component.drag_drop.marker.hide(); - tmp.drag_help = false; - tmp.drag_node = false; - tmp.isdown = false; - tmp.init_x = false; - tmp.init_y = false; - tmp.moving = false; - tmp.appended = false; - $("li.dragged").removeClass("dragged"); - tmp.origin_tree = false; - event.preventDefault(); - event.stopPropagation(); - return false; - }; - tree_component.mousemove = function(event) { - var tmp = tree_component.drag_drop; - - if(tmp.isdown) { - if(!tmp.moving && Math.abs(tmp.init_x - event.pageX) < 5 && Math.abs(tmp.init_y - event.pageY) < 5) { - event.preventDefault(); - event.stopPropagation(); - return false; - } - else tree_component.drag_drop.moving = true; - - if(tmp.open_time) clearTimeout(tmp.open_time); - if(!tmp.appended) { - if(tmp.foreign !== false) tmp.origin_tree = $.tree_focused(); - $("body").append(tmp.drag_help); - tmp.w = tmp.drag_help.width(); - tmp.appended = true; - } - tmp.drag_help.css({ "left" : (event.pageX - (tmp.origin_tree.settings.ui.rtl ? tmp.w : -5 ) ), "top" : (event.pageY + 15) }); - - if(event.target.tagName == "IMG" && event.target.id == "marker") return false; - - var et = $(event.target); - var cnt = et.is(".tree") ? et : et.parents(".tree:eq(0)"); - - // if not moving over a tree - if(cnt.size() == 0 || !tree_component.inst[cnt.attr("id")]) { - if(tmp.scroll_time) clearTimeout(tmp.scroll_time); - if(tmp.drag_help.find("IMG").size() == 0) { - tmp.drag_help.find("li:eq(0)").append(""); - } - tmp.move_type = false; - tmp.ref_node = false; - tree_component.drag_drop.marker.hide(); - return false; - } - - var tree2 = tree_component.inst[cnt.attr("id")]; - tree2.off_height(); - - // if moving over another tree and multitree is false - if( tmp.foreign === false && tmp.origin_tree.container.get(0) != tree2.container.get(0) && (!tmp.origin_tree.settings.rules.multitree || !tree2.settings.rules.multitree) ) { - if(tmp.drag_help.find("IMG").size() == 0) { - tmp.drag_help.find("li:eq(0)").append(""); - } - tmp.move_type = false; - tmp.ref_node = false; - tree_component.drag_drop.marker.hide(); - return false; - } - - if(tmp.scroll_time) clearTimeout(tmp.scroll_time); - tmp.scroll_time = setTimeout( function() { tree2.scrollCheck(event.pageX,event.pageY); }, 50); - - var mov = false; - var st = cnt.scrollTop(); - - if(event.target.tagName == "A" ) { - // just in case if hover is over the draggable - if(et.is("#jstree-dragged")) return false; - if(tree2.get_node(event.target).hasClass("closed")) { - tmp.open_time = setTimeout( function () { tree2.open_branch(et); }, 500); - } - - var et_off = et.offset(); - var goTo = { - x : (et_off.left - 1), - y : (event.pageY - et_off.top) - }; - - if(cnt.children("ul:eq(0)").hasClass("rtl")) goTo.x += et.width() - 8; - var arr = []; - - if(goTo.y < tree2.li_height/3 + 1 ) arr = ["before","inside","after"]; - else if(goTo.y > tree2.li_height*2/3 - 1 ) arr = ["after","inside","before"]; - else { - if(goTo.y < tree2.li_height/2) arr = ["inside","before","after"]; - else arr = ["inside","after","before"]; - } - var ok = false; - $.each(arr, function(i, val) { - if(tree2.checkMove(tmp.origin_tree.container.find("li.dragged"), et, val)) { - mov = val; - ok = true; - return false; - } - }); - if(ok) { - switch(mov) { - case "before": - goTo.y = et_off.top - 2; - if(cnt.children("ul:eq(0)").hasClass("rtl")) { tree_component.drag_drop.marker.attr("src", tree2.settings.ui.theme_path + "marker_rtl.gif").width(40); } - else { tree_component.drag_drop.marker.attr("src", tree2.settings.ui.theme_path + "marker.gif").width(40); } - break; - case "after": - goTo.y = et_off.top - 2 + tree2.li_height; - if(cnt.children("ul:eq(0)").hasClass("rtl")) { tree_component.drag_drop.marker.attr("src", tree2.settings.ui.theme_path + "marker_rtl.gif").width(40); } - else { tree_component.drag_drop.marker.attr("src", tree2.settings.ui.theme_path + "marker.gif").width(40); } - break; - case "inside": - goTo.x -= 2; - if(cnt.children("ul:eq(0)").hasClass("rtl")) { - goTo.x += 36; - } - goTo.y = et_off.top - 2 + tree2.li_height/2; - tree_component.drag_drop.marker.attr("src", tree2.settings.ui.theme_path + "plus.gif").width(11); - break; - } - tmp.move_type = mov; - tmp.ref_node = $(event.target); - tmp.drag_help.find("IMG").remove(); - tree_component.drag_drop.marker.css({ "left" : goTo.x , "top" : goTo.y }).show(); - } - } - - if( (et.is(".tree") || et.is("ul") ) && et.find("li:eq(0)").size() == 0) { - var et_off = et.offset(); - tmp.move_type = "inside"; - tmp.ref_node = cnt.children("ul:eq(0)"); - tmp.drag_help.find("IMG").remove(); - tree_component.drag_drop.marker.attr("src", tree2.settings.ui.theme_path + "plus.gif").width(11); - tree_component.drag_drop.marker.css({ "left" : et_off.left + ( cnt.children("ul:eq(0)").hasClass("rtl") ? (cnt.width() - 10) : 10 ) , "top" : et_off.top + 15 }).show(); - } - else if(event.target.tagName != "A" || !ok) { - if(tmp.drag_help.find("IMG").size() == 0) { - tmp.drag_help.find("li:eq(0)").append(""); - } - tmp.move_type = false; - tmp.ref_node = false; - tree_component.drag_drop.marker.hide(); - } - event.preventDefault(); - event.stopPropagation(); - return false; - } - return true; - }; - }; - return { - cntr : ++tree_component.cntr, - settings : { - data : { - type : "predefined", // ENUM [json, xml_flat, xml_nested, predefined] - method : "GET", // HOW TO REQUEST FILES - async : false, // BOOL - async loading onopen - async_data : function (NODE, TREE_OBJ) { return { id : $(NODE).attr("id") || 0 } }, // PARAMETERS PASSED TO SERVER - url : false, // FALSE or STRING - url to document to be used (async or not) - json : false, // FALSE or OBJECT if type is JSON and async is false - the tree dump as json - xml : false // FALSE or STRING if type is XML_FLAT or XML_NESTED and async is false - a string to generate the tree from - }, - selected : false, // FALSE or STRING or ARRAY - opened : [], // ARRAY OF INITIALLY OPENED NODES - languages : [], // ARRAY of string values (which will be used as CSS classes - so they must be valid) - path : false, // FALSE or STRING (if false - will be autodetected) - cookies : false, // FALSE or OBJECT (prefix, open, selected, opts - from jqCookie - expires, path, domain, secure) - ui : { - dots : true, // BOOL - dots or no dots - rtl : false, // BOOL - is the tree right-to-left - animation : 0, // INT - duration of open/close animations in miliseconds - hover_mode : true, // SHOULD get_* functions chage focus or change hovered item - scroll_spd : 4, - theme_path : false, // Path to themes - theme_name : "default",// Name of theme - context : [ - { - id : "create", - label : "Create", - icon : "create.png", - visible : function (NODE, TREE_OBJ) { if(NODE.length != 1) return false; return TREE_OBJ.check("creatable", NODE); }, - action : function (NODE, TREE_OBJ) { TREE_OBJ.create(false, TREE_OBJ.get_node(NODE[0])); } - }, - "separator", - { - id : "rename", - label : "Rename", - icon : "rename.png", - visible : function (NODE, TREE_OBJ) { if(NODE.length != 1) return false; return TREE_OBJ.check("renameable", NODE); }, - action : function (NODE, TREE_OBJ) { TREE_OBJ.rename(NODE); } - }, - { - id : "delete", - label : "Delete", - icon : "remove.png", - visible : function (NODE, TREE_OBJ) { var ok = true; $.each(NODE, function () { if(TREE_OBJ.check("deletable", this) == false) ok = false; return false; }); return ok; }, - action : function (NODE, TREE_OBJ) { $.each(NODE, function () { TREE_OBJ.remove(this); }); } - } - ] - }, - rules : { - multiple : false, // FALSE | CTRL | ON - multiple selection off/ with or without holding Ctrl - metadata : false, // FALSE or STRING - attribute name (use metadata plugin) - type_attr : "rel", // STRING attribute name (where is the type stored if no metadata) - multitree : false, // BOOL - is drag n drop between trees allowed - createat : "bottom", // STRING (top or bottom) new nodes get inserted at top or bottom - use_inline : false, // CHECK FOR INLINE RULES - REQUIRES METADATA - clickable : "all", // which node types can the user select | default - all - renameable : "all", // which node types can the user select | default - all - deletable : "all", // which node types can the user delete | default - all - creatable : "all", // which node types can the user create in | default - all - draggable : "none", // which node types can the user move | default - none | "all" - dragrules : "all", // what move operations between nodes are allowed | default - none | "all" - drag_copy : false, // FALSE | CTRL | ON - drag to copy off/ with or without holding Ctrl - droppable : [], - drag_button : "left" // left, right or both - }, - lang : { - new_node : "New folder", - loading : "Loading ..." - }, - callback : { // various callbacks to attach custom logic to - // before focus - should return true | false - beforechange: function(NODE,TREE_OBJ) { return true }, - beforeopen : function(NODE,TREE_OBJ) { return true }, - beforeclose : function(NODE,TREE_OBJ) { return true }, - // before move - should return true | false - beforemove : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true }, - // before create - should return true | false - beforecreate: function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true }, - // before rename - should return true | false - beforerename: function(NODE,LANG,TREE_OBJ) { return true }, - // before delete - should return true | false - beforedelete: function(NODE,TREE_OBJ) { return true }, - - onJSONdata : function(DATA,TREE_OBJ) { return DATA; }, - onselect : function(NODE,TREE_OBJ) { }, // node selected - ondeselect : function(NODE,TREE_OBJ) { }, // node deselected - onchange : function(NODE,TREE_OBJ) { }, // focus changed - onrename : function(NODE,LANG,TREE_OBJ,RB) { }, // node renamed ISNEW - TRUE|FALSE, current language - onmove : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // move completed (TYPE is BELOW|ABOVE|INSIDE) - oncopy : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // copy completed (TYPE is BELOW|ABOVE|INSIDE) - oncreate : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // node created, parent node (TYPE is createat) - ondelete : function(NODE,TREE_OBJ,RB) { }, // node deleted - onopen : function(NODE,TREE_OBJ) { }, // node opened - onopen_all : function(TREE_OBJ) { }, // all nodes opened - onclose : function(NODE,TREE_OBJ) { }, // node closed - error : function(TEXT,TREE_OBJ) { }, // error occured - // double click on node - defaults to open/close & select - ondblclk : function(NODE,TREE_OBJ) { TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); }, - // right click - to prevent use: EV.preventDefault(); EV.stopPropagation(); return false - onrgtclk : function(NODE,TREE_OBJ,EV) { }, - onload : function(TREE_OBJ) { }, - onfocus : function(TREE_OBJ) { }, - ondrop : function(NODE,REF_NODE,TYPE,TREE_OBJ) {} - } - }, - // INITIALIZATION - init : function(elem, conf) { - var _this = this; - this.container = $(elem); - if(this.container.size == 0) { alert("Invalid container node!"); return } - - tree_component.inst[this.cntr] = this; - if(!this.container.attr("id")) this.container.attr("id","jstree_" + this.cntr); - tree_component.inst[this.container.attr("id")] = tree_component.inst[this.cntr]; - tree_component.focused = this.cntr; - - var opts = $.extend({},conf); - - // MERGE OPTIONS WITH DEFAULTS - if(opts && opts.cookies) { - this.settings.cookies = $.extend({},this.settings.cookies,opts.cookies); - delete opts.cookies; - if(!this.settings.cookies.opts) this.settings.cookies.opts = {}; - } - if(opts && opts.callback) { - this.settings.callback = $.extend({},this.settings.callback,opts.callback); - delete opts.callback; - } - if(opts && opts.data) { - this.settings.data = $.extend({},this.settings.data,opts.data); - delete opts.data; - } - if(opts && opts.ui) { - this.settings.ui = $.extend({},this.settings.ui,opts.ui); - delete opts.ui; - } - if(opts && opts.rules) { - this.settings.rules = $.extend({},this.settings.rules,opts.rules); - delete opts.rules; - } - if(opts && opts.lang) { - this.settings.lang = $.extend({},this.settings.lang,opts.lang); - delete opts.lang; - } - this.settings = $.extend({},this.settings,opts); - - // PATH TO IMAGES AND XSL - if(this.settings.path == false) { - this.path = ""; - $("script").each( function () { - if(this.src.toString().match(/tree_component.*?js$/)) { - _this.path = this.src.toString().replace(/tree_component.*?js$/, ""); - } - }); - } - else this.path = this.settings.path; - - // DEAL WITH LANGUAGE VERSIONS - this.current_lang = this.settings.languages && this.settings.languages.length ? this.settings.languages[0] : false; - if(this.settings.languages && this.settings.languages.length) { - this.sn = get_sheet_num("tree_component.css"); - if(this.sn === false && document.styleSheets.length) this.sn = document.styleSheets.length; - var st = false; - var id = this.container.attr("id") ? "#" + this.container.attr("id") : ".tree"; - for(var ln = 0; ln < this.settings.languages.length; ln++) { - st = add_css(id + " ." + this.settings.languages[ln], this.sn); - if(st !== false) { - if(this.settings.languages[ln] == this.current_lang) st.style.display = ""; - else st.style.display = "none"; - } - } - } - - // DROPPABLES - if(this.settings.rules.droppable.length) { - for(var i in this.settings.rules.droppable) { - if(typeof this.settings.rules.droppable[i] == "function") continue; - tree_component.drag_drop.droppable.push(this.settings.rules.droppable[i]); - } - tree_component.drag_drop.droppable = $.unique(tree_component.drag_drop.droppable); - } - - // THEMES - if(this.settings.ui.theme_path === false) this.settings.ui.theme_path = this.path + "themes/"; - this.theme = this.settings.ui.theme_path; - if(_this.settings.ui.theme_name) { - this.theme += _this.settings.ui.theme_name + "/"; - if(_this.settings.ui.theme_name != "themeroller" && !tree_component.def_style) { add_sheet(_this.settings.ui.theme_path + "default/style.css"); tree_component.def_style = true; } - add_sheet(_this.theme + "style.css"); - } - - this.container.addClass("tree"); - if(_this.settings.ui.theme_name != "themeroller") this.container.addClass("tree-default"); - if(this.settings.ui.theme_name && this.settings.ui.theme_name != "default") this.container.addClass("tree-" + _this.settings.ui.theme_name); - if(this.settings.ui.theme_name == "themeroller") this.container.addClass("ui-widget ui-widget-content"); - if(this.settings.rules.multiple) this.selected_arr = []; - this.offset = false; - - // CONTEXT MENU - this.context_menu(); - - this.hovered = false; - this.locked = false; - - // CREATE DUMMY FOR MOVING - if(this.settings.rules.draggable != "none" && tree_component.drag_drop.marker === false) { - var _this = this; - tree_component.drag_drop.marker = $("") - .attr({ - id : "marker", - src : _this.settings.ui.theme_path + "marker.gif" - }) - .css({ - height : "5px", - width : "40px", - display : "block", - position : "absolute", - left : "30px", - top : "30px", - zIndex : "1000" - }).hide().appendTo("body"); - } - this.refresh(); - this.attachEvents(); - this.focus(); - }, - off_height : function () { - if(this.offset === false) { - this.container.css({ position : "relative" }); - this.offset = this.container.offset(); - var tmp = 0; - tmp = parseInt($.curCSS(this.container.get(0), "paddingTop", true),10); - if(tmp) this.offset.top += tmp; - tmp = parseInt($.curCSS(this.container.get(0), "borderTopWidth", true),10); - if(tmp) this.offset.top += tmp; - this.container.css({ position : "" }); - } - if(!this.li_height) { - var tmp = this.container.find("ul li.closed, ul li.leaf").eq(0); - this.li_height = tmp.height(); - if(tmp.children("ul:eq(0)").size()) this.li_height -= tmp.children("ul:eq(0)").height(); - if(!this.li_height) this.li_height = 18; - } - }, - context_menu : function () { - this.context = false; - if(this.settings.ui.context != false) { - var str = '
'; - for(var i in this.settings.ui.context) { - if(typeof this.settings.ui.context[i] == "function") continue; - if(this.settings.ui.context[i] == "separator") { - str += " "; - continue; - } - var icn = ""; - if(this.settings.ui.context[i].icon) icn = 'background-image:url(\'' + ( this.settings.ui.context[i].icon.indexOf("/") == -1 ? this.theme + this.settings.ui.context[i].icon : this.settings.ui.context[i].icon ) + '\');'; - str += '' + this.settings.ui.context[i].label + ''; - } - str += '
'; - this.context = $(str); - this.context.hide(); - this.context.append = false; - } - }, - // REPAINT TREE - refresh : function (obj) { - if(this.locked) return this.error("LOCKED"); - var _this = this; - - this.is_partial_refresh = obj ? true : false; - - // SAVE OPENED - this.opened = Array(); - if(this.settings.cookies && $.cookie(this.settings.cookies.prefix + '_open')) { - var str = $.cookie(this.settings.cookies.prefix + '_open'); - var tmp = str.split(","); - $.each(tmp, function () { - if(this.replace(/^#/,"").length > 0) { _this.opened.push("#" + this.replace(/^#/,"")); } - }); - this.settings.opened = false; - } - else if(this.settings.opened != false) { - $.each(this.settings.opened, function (i, item) { - if(this.replace(/^#/,"").length > 0) { _this.opened.push("#" + this.replace(/^#/,"")); } - }); - this.settings.opened = false; - } - else { - this.container.find("li.open").each(function (i) { if(this.id) { _this.opened.push("#" + this.id); } }); - } - - // SAVE SELECTED - if(this.selected) { - this.settings.selected = Array(); - if(obj) { - $(obj).find("li:has(a.clicked)").each(function () { - $this = $(this); - if($this.attr("id")) _this.settings.selected.push("#" + $this.attr("id")); - }); - } - else { - if(this.selected_arr) { - $.each(this.selected_arr, function () { - if(this.attr("id")) _this.settings.selected.push("#" + this.attr("id")); - }); - } - else { - if(this.selected.attr("id")) this.settings.selected.push("#" + this.selected.attr("id")); - } - } - } - else if(this.settings.cookies && $.cookie(this.settings.cookies.prefix + '_selected')) { - this.settings.selected = Array(); - var str = $.cookie(this.settings.cookies.prefix + '_selected'); - var tmp = str.split(","); - $.each(tmp, function () { - if(this.replace(/^#/,"").length > 0) { _this.settings.selected.push("#" + this.replace(/^#/,"")); } - }); - } - else if(this.settings.selected !== false) { - var tmp = Array(); - if((typeof this.settings.selected).toLowerCase() == "object") { - $.each(this.settings.selected, function () { - if(this.replace(/^#/,"").length > 0) tmp.push("#" + this.replace(/^#/,"")); - }); - } - else { - if(this.settings.selected.replace(/^#/,"").length > 0) tmp.push("#" + this.settings.selected.replace(/^#/,"")); - } - this.settings.selected = tmp; - } - - if(obj && this.settings.data.async) { - this.opened = Array(); - obj = this.get_node(obj); - obj.find("li.open").each(function (i) { _this.opened.push("#" + this.id); }); - if(obj.hasClass("open")) obj.removeClass("open").addClass("closed"); - if(obj.hasClass("leaf")) obj.removeClass("leaf"); - obj.children("ul:eq(0)").html(""); - return this.open_branch(obj, true, function () { _this.reselect.apply(_this); }); - } - - if(this.settings.data.type == "xml_flat" || this.settings.data.type == "xml_nested") { - this.scrtop = this.container.get(0).scrollTop; - var xsl = (this.settings.data.type == "xml_flat") ? "flat.xsl" : "nested.xsl"; - if(this.settings.data.xml) this.container.getTransform(this.path + xsl, this.settings.data.xml, { params : { theme_name : _this.settings.ui.theme_name, theme_path : _this.theme }, meth : _this.settings.data.method, dat : _this.settings.data.async_data.apply(_this,[obj, _this]), callback: function () { _this.context_menu.apply(_this); _this.reselect.apply(_this); } }); - else this.container.getTransform(this.path + xsl, this.settings.data.url, { params : { theme_name : _this.settings.ui.theme_name, theme_path : _this.theme }, meth : _this.settings.data.method, dat : _this.settings.data.async_data.apply(_this,[obj, _this]), callback: function () { _this.context_menu.apply(_this); _this.reselect.apply(_this); } }); - return; - } - else if(this.settings.data.type == "json") { - if(this.settings.data.json) { - var str = ""; - if(this.settings.data.json.length) { - for(var i = 0; i < this.settings.data.json.length; i++) { - str += this.parseJSON(this.settings.data.json[i]); - } - } else str = this.parseJSON(this.settings.data.json); - this.container.html("
    " + str + "
"); - this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed"); - this.container.find("li").not(".open").not(".closed").addClass("leaf"); - this.context_menu(); - this.reselect(); - } - else { - var _this = this; - $.ajax({ - type : this.settings.data.method, - url : this.settings.data.url, - data : this.settings.data.async_data(false, this), - dataType : "json", - success : function (data) { - data = _this.settings.callback.onJSONdata.call(null, data, _this); - var str = ""; - if(data.length) { - for(var i = 0; i < data.length; i++) { - str += _this.parseJSON(data[i]); - } - } else str = _this.parseJSON(data); - _this.container.html("
    " + str + "
"); - _this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed"); - _this.container.find("li").not(".open").not(".closed").addClass("leaf"); - _this.context_menu.apply(_this); - _this.reselect.apply(_this); - }, - error : function (xhttp, textStatus, errorThrown) { _this.error(errorThrown + " " + textStatus); } - }); - } - } - else { - this.container.children("ul:eq(0)"); - this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed"); - this.container.find("li").not(".open").not(".closed").addClass("leaf"); - this.reselect(); - } - }, - // CONVERT JSON TO HTML - parseJSON : function (data) { - if(!data || !data.data) return ""; - var str = ""; - str += "
  •  "; - } - str += ( (typeof data.data[this.settings.languages[i]].title).toLowerCase() != "undefined" ? data.data[this.settings.languages[i]].title : data.data[this.settings.languages[i]] ) + ""; - } - } - else { - var attr = {}; - attr["href"] = "#"; - attr["style"] = ""; - attr["class"] = ""; - if((typeof data.data.attributes).toLowerCase() != "undefined") { - for(var i in data.data.attributes) { - if(typeof data.data.attributes[i] == "function") continue; - if(i == "style" || i == "class") attr[i] += " " + data.data.attributes[i]; - else attr[i] = data.data.attributes[i]; - } - } - if(data.data.icon && this.settings.ui.theme_name != "themeroller") { - var icn = data.data.icon.indexOf("/") == -1 ? this.theme + data.data.icon : data.data.icon; - attr["style"] += " ; background-image:url('" + icn + "');"; - } - str += " "; - } - str += ( (typeof data.data.title).toLowerCase() != "undefined" ? data.data.title : data.data ) + ""; - } - if(data.children && data.children.length) { - str += '
      '; - for(var i = 0; i < data.children.length; i++) { - str += this.parseJSON(data.children[i]); - } - str += '
    '; - } - str += "
  • "; - return str; - }, - // getJSON from HTML - getJSON : function (nod, outer_attrib, inner_attrib, force) { - var _this = this; - if(!nod || $(nod).size() == 0) { - nod = this.container.children("ul").children("li"); - } - else nod = $(nod); - - if(nod.size() > 1) { - var arr = []; - nod.each(function () { - arr.push(_this.getJSON(this, outer_attrib, inner_attrib, force)); - }); - return arr; - } - - if(!outer_attrib) outer_attrib = [ "id", "rel", "class" ]; - if(!inner_attrib) inner_attrib = [ ]; - var obj = { attributes : {}, data : false }; - for(var i in outer_attrib) { - if(typeof outer_attrib[i] == "function") continue; - var val = (outer_attrib[i] == "class") ? nod.attr(outer_attrib[i]).replace("last","").replace("leaf","").replace("closed","").replace("open","") : nod.attr(outer_attrib[i]); - if(typeof val != "undefined" && val.replace(" ","").length > 0) obj.attributes[outer_attrib[i]] = val; - delete val; - } - if(this.settings.languages.length) { - obj.data = {}; - for(var i in this.settings.languages) { - if(typeof this.settings.languages[i] == "function") continue; - var a = nod.children("a." + this.settings.languages[i]); - if(force || inner_attrib.length || a.get(0).style.backgroundImage.toString().length) { - obj.data[this.settings.languages[i]] = {}; - obj.data[this.settings.languages[i]].title = a.text(); - if(a.get(0).style.backgroundImage.length) { - obj.data[this.settings.languages[i]].icon = a.get(0).style.backgroundImage.replace("url(","").replace(")",""); - } - if(this.settings.ui.theme_name == "themeroller" && a.children("ins").size()) { - var tmp = a.children("ins").attr("class"); - var cls = false; - $.each(tmp.split(" "), function (i, val) { - if(val.indexOf("ui-icon-") == 0) { - cls = val; - return false; - } - }); - if(cls) obj.data[this.settings.languages[i]].icon = cls; - } - if(inner_attrib.length) { - obj.data[this.settings.languages[i]].attributes = {}; - for(var j in inner_attrib) { - if(typeof inner_attrib[j] == "function") continue; - var val = a.attr(inner_attrib[j]); - if(typeof val != "undefined" && val.replace(" ","").length > 0) obj.data[this.settings.languages[i]].attributes[inner_attrib[j]] = val; - delete val; - } - } - } - else { - obj.data[this.settings.languages[i]] = a.text(); - } - } - } - else { - var a = nod.children("a"); - if(force || inner_attrib.length || a.get(0).style.backgroundImage.toString().length) { - obj.data = {}; - obj.data.title = a.text(); - if(a.get(0).style.backgroundImage.length) { - obj.data.icon = a.get(0).style.backgroundImage.replace("url(","").replace(")",""); - } - if(this.settings.ui.theme_name == "themeroller" && a.children("ins").size()) { - var tmp = a.children("ins").attr("class"); - var cls = false; - $.each(tmp.split(" "), function (i, val) { - if(val.indexOf("ui-icon-") == 0) { - cls = val; - return false; - } - }); - if(cls) obj.data[this.settings.languages[i]].icon = cls; - } - if(inner_attrib.length) { - obj.data.attributes = {}; - for(var j in inner_attrib) { - if(typeof inner_attrib[j] == "function") continue; - var val = a.attr(inner_attrib[j]); - if(typeof val != "undefined" && val.replace(" ","").length > 0) obj.data.attributes[inner_attrib[j]] = val; - delete val; - } - } - } - else { - obj.data = a.text(); - } - } - - if(nod.children("ul").size() > 0) { - obj.children = []; - nod.children("ul").children("li").each(function () { - obj.children.push(_this.getJSON(this, outer_attrib, inner_attrib, force)); - }); - } - return obj; - }, - // getXML from HTML - getXML : function (tp, nod, outer_attrib, inner_attrib, cb) { - var _this = this; - if(tp != "flat") tp = "nested"; - if(!nod || $(nod).size() == 0) { - nod = this.container.children("ul").children("li"); - } - else nod = $(nod); - - if(nod.size() > 1) { - var obj = ''; - nod.each(function () { - obj += _this.getXML(tp, this, outer_attrib, inner_attrib, true); - }); - obj += ''; - return obj; - } - - if(!outer_attrib) outer_attrib = [ "id", "rel", "class" ]; - if(!inner_attrib) inner_attrib = [ ]; - var obj = ''; - - if(!cb) obj = ''; - - obj += ' 0) obj += ' ' + outer_attrib[i] + '="' + val + '" '; - delete val; - } - obj += '>'; - - obj += ''; - if(this.settings.languages.length) { - for(var i in this.settings.languages) { - if(typeof this.settings.languages[i] == "function") continue; - var a = nod.children("a." + this.settings.languages[i]); - obj += ' 0) obj += ' ' + inner_attrib[j] + '="' + val + '" '; - delete val; - } - } - } - obj += '>'; - } - } - else { - var a = nod.children("a"); - obj += ' 0) obj += ' ' + inner_attrib[j] + '="' + val + '" '; - delete val; - } - } - } - obj += '>'; - } - obj += ''; - - if(tp == "flat") obj += ''; - - if(nod.children("ul").size() > 0) { - nod.children("ul").children("li").each(function () { - obj += _this.getXML(tp, this, outer_attrib, inner_attrib, true); - }); - } - - if(tp == "nested") obj += ''; - - if(!cb) obj += ''; - return obj; - }, - focus : function () { - if(this.locked) return false; - if(tree_component.focused != this.cntr) { - tree_component.focused = this.cntr; - this.settings.callback.onfocus.call(null, this); - } - }, - show_context : function (obj) { - this.context.show(); - var tmp = $(obj).children("a:visible").offset(); - this.context.css({ "left" : (tmp.left), "top" : (tmp.top + parseInt(obj.children("a:visible").height()) + 2) }); - }, - hide_context : function () { - if(this.context.to_remove && this.context.apply_to) this.context.apply_to.children("a").removeClass("clicked"); - this.context.apply_to = false; - this.context.hide(); - }, - // ALL EVENTS - attachEvents : function () { - var _this = this; - - this.container - .bind("mousedown.jstree", function (event) { - if(tree_component.drag_drop.isdown) { - tree_component.drag_drop.move_type = false; - event.preventDefault(); - event.stopPropagation(); - event.stopImmediatePropagation(); - return false; - } - }) - .bind("mouseup.jstree", function (event) { - setTimeout( function() { _this.focus.apply(_this); }, 5); - }) - .bind("click.jstree", function (event) { - //event.stopPropagation(); - return true; - }); - $("#" + this.container.attr("id") + " li") - .live("click", function(event) { // WHEN CLICK IS ON THE ARROW - if(event.target.tagName != "LI") return true; - _this.off_height(); - if(event.pageY - $(event.target).offset().top > _this.li_height) return true; - _this.toggle_branch.apply(_this, [event.target]); - event.stopPropagation(); - return false; - }); - $("#" + this.container.attr("id") + " li a") - .live("click.jstree", function (event) { // WHEN CLICK IS ON THE TEXT OR ICON - if(event.which && event.which == 3) return true; - if(_this.locked) { - event.preventDefault(); - event.target.blur(); - return _this.error("LOCKED"); - } - _this.select_branch.apply(_this, [event.target, event.ctrlKey || _this.settings.rules.multiple == "on"]); - if(_this.inp) { _this.inp.blur(); } - event.preventDefault(); - event.target.blur(); - return false; - }) - .live("dblclick.jstree", function (event) { // WHEN DOUBLECLICK ON TEXT OR ICON - if(_this.locked) { - event.preventDefault(); - event.stopPropagation(); - event.target.blur(); - return _this.error("LOCKED"); - } - _this.settings.callback.ondblclk.call(null, _this.get_node(event.target).get(0), _this); - event.preventDefault(); - event.stopPropagation(); - event.target.blur(); - }) - .live("contextmenu.jstree", function (event) { - if(_this.locked) { - event.target.blur(); - return _this.error("LOCKED"); - } - var val = _this.settings.callback.onrgtclk.call(null, _this.get_node(event.target).get(0), _this, event); - if(_this.context) { - if(_this.context.append == false) { - $("body").append(_this.context); - _this.context.append = true; - for(var i in _this.settings.ui.context) { - if(typeof _this.settings.ui.context[i] == "function") continue; - if(_this.settings.ui.context[i] == "separator") continue; - (function () { - var func = _this.settings.ui.context[i].action; - _this.context.children("[rel=" + _this.settings.ui.context[i].id +"]") - .bind("click", function (event) { - if(!$(this).hasClass("disabled")) { - func.call(null, _this.context.apply_to || null, _this); - _this.hide_context(); - } - event.stopPropagation(); - event.preventDefault(); - return false; - }) - .bind("mouseup", function (event) { - this.blur(); - if($(this).hasClass("disabled")) { - event.stopPropagation(); - event.preventDefault(); - return false; - } - }) - .bind("mousedown", function (event) { - event.stopPropagation(); - event.preventDefault(); - }); - })(); - } - } - var obj = _this.get_node(event.target); - if(_this.inp) { _this.inp.blur(); } - if(obj) { - if(!obj.children("a:eq(0)").hasClass("clicked")) { - // _this.select_branch.apply(_this, [event.target, event.ctrlKey || _this.settings.rules.multiple == "on"]); - _this.context.apply_to = obj; - _this.context.to_remove = true; - _this.context.apply_to.children("a").addClass("clicked"); - event.target.blur(); - } - else { - _this.context.to_remove = false; - _this.context.apply_to = (_this.selected_arr && _this.selected_arr.length > 1) ? _this.selected_arr : _this.selected; - } - - _this.context.children("a").removeClass("disabled").show(); - var go = false; - for(var i in _this.settings.ui.context) { - if(typeof _this.settings.ui.context[i] == "function") continue; - if(_this.settings.ui.context[i] == "separator") continue; - var state = _this.settings.ui.context[i].visible.call(null, _this.context.apply_to, _this); - if(state === false) _this.context.children("[rel=" + _this.settings.ui.context[i].id +"]").addClass("disabled"); - if(state === -1) _this.context.children("[rel=" + _this.settings.ui.context[i].id +"]").hide(); - else go = true; - } - if(go == true) _this.show_context(obj); - event.preventDefault(); - event.stopPropagation(); - return false; - } - } - return val; - }) - .live("mouseover.jstree", function (event) { - if(_this.locked) { - event.preventDefault(); - event.stopPropagation(); - return _this.error("LOCKED"); - } - if( (_this.settings.ui.hover_mode || _this.settings.ui.theme_name == "themeroller" ) && _this.hovered !== false && event.target.tagName == "A") { - _this.hovered.children("a").removeClass("hover ui-state-hover"); - _this.hovered = false; - } - if(_this.settings.ui.theme_name == "themeroller") { - _this.hover_branch.apply(_this, [event.target]); - } - }); - if(_this.settings.ui.theme_name == "themeroller") { - $("#" + this.container.attr("id") + " li a").live("mouseout", function (event) { - if(_this.hovered) _this.hovered.children("a").removeClass("hover ui-state-hover"); - }); - } - - // ATTACH DRAG & DROP ONLY IF NEEDED - if(this.settings.rules.draggable != "none") { - $("#" + this.container.attr("id") + " li a") - .live("mousedown.jstree", function (event) { - if(_this.settings.rules.drag_button == "left" && event.which && event.which != 1) return true; - if(_this.settings.rules.drag_button == "right" && event.which && event.which != 3) return true; - _this.focus.apply(_this); - if(_this.locked) return _this.error("LOCKED"); - // SELECT LIST ITEM NODE - var obj = _this.get_node(event.target); - // IF ITEM IS DRAGGABLE - if(_this.settings.rules.multiple != false && _this.selected_arr.length > 1 && obj.children("a:eq(0)").hasClass("clicked")) { - var counter = 0; - for(var i in _this.selected_arr) { - if(typeof _this.selected_arr[i] == "function") continue; - if(_this.check("draggable", _this.selected_arr[i])) { - _this.selected_arr[i].addClass("dragged"); - tree_component.drag_drop.origin_tree = _this; - counter ++; - } - } - if(counter > 0) { - if(_this.check("draggable", obj)) tree_component.drag_drop.drag_node = obj; - else tree_component.drag_drop.drag_node = _this.container.find("li.dragged:eq(0)"); - tree_component.drag_drop.isdown = true; - tree_component.drag_drop.drag_help = $("
    ").append("
      "); - var tmp = $(tree_component.drag_drop.drag_node.get(0).cloneNode(true)); - if(_this.settings.languages.length > 0) tmp.find("a").not("." + _this.current_lang).hide(); - tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp); - tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last").children("a").html("Multiple selection").end().children("ul").remove(); - } - } - else { - if(_this.check("draggable", obj)) { - tree_component.drag_drop.drag_node = obj; - tree_component.drag_drop.drag_help = $("
      ").append("
        "); - var tmp = $(obj.get(0).cloneNode(true)); - if(_this.settings.languages.length > 0) tmp.find("a").not("." + _this.current_lang).hide(); - tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp); - tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last"); - tree_component.drag_drop.isdown = true; - tree_component.drag_drop.foreign = false; - tree_component.drag_drop.origin_tree = _this; - obj.addClass("dragged"); - } - } - tree_component.drag_drop.init_x = event.pageX; - tree_component.drag_drop.init_y = event.pageY; - obj.blur(); - event.preventDefault(); - event.stopPropagation(); - return false; - }); - $(document) - .bind("mousedown.jstree", tree_component.mousedown) - .bind("mouseup.jstree", tree_component.mouseup) - .bind("mousemove.jstree", tree_component.mousemove); - } - // ENDIF OF DRAG & DROP FUNCTIONS - if(_this.context) $(document).bind("mousedown", function() { _this.hide_context(); }); - }, - checkMove : function (NODES, REF_NODE, TYPE) { - if(this.locked) return this.error("LOCKED"); - var _this = this; - - // OVER SELF OR CHILDREN - if(REF_NODE.parents("li.dragged").size() > 0 || REF_NODE.is(".dragged")) return this.error("MOVE: NODE OVER SELF"); - // CHECK AGAINST DRAG_RULES - if(NODES.size() == 1) { - var NODE = NODES.eq(0); - if(tree_component.drag_drop.foreign) { - if(this.settings.rules.droppable.length == 0) return false; - if(!NODE.is("." + this.settings.rules.droppable.join(", ."))) return false; - var ok = false; - for(var i in this.settings.rules.droppable) { - if(typeof this.settings.rules.droppable[i] == "function") continue; - if(NODE.is("." + this.settings.rules.droppable[i])) { - if(this.settings.rules.metadata) { - $.metadata.setType("attr", this.settings.rules.metadata); - NODE.attr(this.settings.rules.metadata, "type: '" + this.settings.rules.droppable[i] + "'"); - } - else { - NODE.attr(this.settings.rules.type_attr, this.settings.rules.droppable[i]); - } - ok = true; - break; - } - } - if(!ok) return false; - } - if(!this.check("dragrules", [NODE, TYPE, REF_NODE.parents("li:eq(0)")])) return this.error("MOVE: AGAINST DRAG RULES"); - } - else { - var ok = true; - NODES.each(function (i) { - if(ok == false) return false; - //if(i > 0) { - // var ref = NODES.eq( (i - 1) ); - // var mv = "after"; - //} - //else { - var ref = REF_NODE; - var mv = TYPE; - //} - if(!_this.check.apply(_this,["dragrules", [$(this), mv, ref]])) ok = false; - }); - if(ok == false) return this.error("MOVE: AGAINST DRAG RULES"); - } - // CHECK AGAINST METADATA - if(this.settings.rules.use_inline && this.settings.rules.metadata) { - var nd = false; - if(TYPE == "inside") nd = REF_NODE.parents("li:eq(0)"); - else nd = REF_NODE.parents("li:eq(1)"); - if(nd.size()) { - // VALID CHILDREN CHECK - if(typeof nd.metadata()["valid_children"] != "undefined") { - var tmp = nd.metadata()["valid_children"]; - var ok = true; - NODES.each(function (i) { - if(ok == false) return false; - if($.inArray(_this.get_type(this), tmp) == -1) ok = false; - }); - if(ok == false) return this.error("MOVE: NOT A VALID CHILD"); - } - // CHECK IF PARENT HAS FREE SLOTS FOR CHILDREN - if(typeof nd.metadata()["max_children"] != "undefined") { - if((nd.children("ul:eq(0)").children("li").not(".dragged").size() + NODES.size()) > nd.metadata().max_children) return this.error("MOVE: MAX CHILDREN REACHED"); - } - // CHECK FOR MAXDEPTH UP THE CHAIN - var incr = 0; - NODES.each(function (j) { - var i = 1; - var t = $(this); - while(i < 100) { - t = t.children("ul").children("li"); - if(t.size() == 0) break; - i ++ - } - incr = Math.max(i,incr); - }); - var ok = true; - - if((typeof $(nd).metadata().max_depth).toLowerCase() != "undefined" && $(nd).metadata().max_depth < incr) ok = false; - else { - nd.parents("li").each(function(i) { - if(ok == false) return false; - if((typeof $(this).metadata().max_depth).toLowerCase() != "undefined") { - if( (i + incr) >= $(this).metadata().max_depth) ok = false; - } - }); - } - if(ok == false) return this.error("MOVE: MAX_DEPTH REACHED"); - } - } - return true; - }, - // USED AFTER REFRESH - reselect : function (is_callback) { - var _this = this; - - if(!is_callback) this.cl_count = 0; - else this.cl_count --; - // REOPEN BRANCHES - if(this.opened && this.opened.length) { - var opn = false; - for(var j = 0; this.opened && j < this.opened.length; j++) { - if(this.settings.data.async) { - if(this.get_node(this.opened[j]).size() > 0) { - opn = true; - var tmp = this.opened[j]; - delete this.opened[j]; - this.open_branch(tmp, true, function () { _this.reselect.apply(_this, [true]); } ); - this.cl_count ++; - } - } - else this.open_branch(this.opened[j], true); - } - if(this.settings.data.async && opn) return; - delete this.opened; - } - if(this.cl_count > 0) return; - - // DOTS and RIGHT TO LEFT - if(this.settings.ui.rtl) this.container.css("direction","rtl").children("ul:eq(0)").addClass("rtl"); - else this.container.css("direction","ltr").children("ul:eq(0)").addClass("ltr"); - if(this.settings.ui.dots == false) this.container.children("ul:eq(0)").addClass("no_dots"); - - // REPOSITION SCROLL - if(this.scrtop) { - this.container.scrollTop(_this.scrtop); - delete this.scrtop; - } - // RESELECT PREVIOUSLY SELECTED - if(this.settings.selected !== false) { - $.each(this.settings.selected, function (i) { - if(_this.is_partial_refresh) _this.select_branch($(_this.settings.selected[i], _this.container), (_this.settings.rules.multiple !== false) ); - else _this.select_branch($(_this.settings.selected[i], _this.container), (_this.settings.rules.multiple !== false && i > 0) ); - }); - this.settings.selected = false; - } - if(this.settings.ui.theme_name == "themeroller") this.container.find("a").addClass("ui-state-default"); - this.settings.callback.onload.call(null, _this); - }, - // GET THE EXTENDED LI ELEMENT - get_node : function (obj) { - var obj = $(obj); - return obj.is("li") ? obj : obj.parents("li:eq(0)"); - }, - // GET THE TYPE OF THE NODE - get_type : function (obj) { - obj = !obj ? this.selected : this.get_node(obj); - if(!obj) return; - if(this.settings.rules.metadata) { - $.metadata.setType("attr", this.settings.rules.metadata); - var tmp = obj.metadata().type; - if(tmp) return tmp; - } - return obj.attr(this.settings.rules.type_attr); - }, - // SCROLL CONTAINER WHILE DRAGGING - scrollCheck : function (x,y) { - var _this = this; - var cnt = _this.container; - var off = _this.container.offset(); - - var st = cnt.scrollTop(); - var sl = cnt.scrollLeft(); - // DETECT HORIZONTAL SCROLL - var h_cor = (cnt.get(0).scrollWidth > cnt.width()) ? 40 : 20; - - if(y - off.top < 20) cnt.scrollTop(Math.max( (st - _this.settings.ui.scroll_spd) ,0)); // NEAR TOP - if(cnt.height() - (y - off.top) < h_cor) cnt.scrollTop(st + _this.settings.ui.scroll_spd); // NEAR BOTTOM - if(x - off.left < 20) cnt.scrollLeft(Math.max( (sl - _this.settings.ui.scroll_spd),0)); // NEAR LEFT - if(cnt.width() - (x - off.left) < 40) cnt.scrollLeft(sl + _this.settings.ui.scroll_spd); // NEAR RIGHT - - if(cnt.scrollLeft() != sl || cnt.scrollTop() != st) { - _this.moveType = false; - _this.moveRef = false; - tree_component.drag_drop.marker.hide(); - } - tree_component.drag_drop.scroll_time = setTimeout( function() { _this.scrollCheck(x,y); }, 50); - }, - check : function (rule, nodes) { - if(this.locked) return this.error("LOCKED"); - // CHECK LOCAL RULES IF METADATA - if(rule != "dragrules" && this.settings.rules.use_inline && this.settings.rules.metadata) { - $.metadata.setType("attr", this.settings.rules.metadata); - if(typeof this.get_node(nodes).metadata()[rule] != "undefined") return this.get_node(nodes).metadata()[rule]; - } - if(!this.settings.rules[rule]) return false; - if(this.settings.rules[rule] == "none") return false; - if(this.settings.rules[rule] == "all") return true; - - if(rule == "dragrules") { - var nds = new Array(); - nds[0] = this.get_type(nodes[0]); - nds[1] = nodes[1]; - nds[2] = this.get_type(nodes[2]); - for(var i = 0; i < this.settings.rules.dragrules.length; i++) { - var r = this.settings.rules.dragrules[i]; - var n = (r.indexOf("!") === 0) ? false : true; - if(!n) r = r.replace("!",""); - var tmp = r.split(" "); - for(var j = 0; j < 3; j++) { - if(tmp[j] == nds[j] || tmp[j] == "*") tmp[j] = true; - } - if(tmp[0] === true && tmp[1] === true && tmp[2] === true) return n; - } - return false; - } - else - return ($.inArray(this.get_type(nodes),this.settings.rules[rule]) != -1) ? true : false; - }, - hover_branch : function (obj) { - if(this.locked) return this.error("LOCKED"); - if(this.settings.ui.hover_mode == false && this.settings.ui.theme_name != "themeroller") return this.select_branch(obj); - var _this = this; - var obj = _this.get_node(obj); - if(!obj.size()) return this.error("HOVER: NOT A VALID NODE"); - // CHECK AGAINST RULES FOR SELECTABLE NODES - if(!_this.check("clickable", obj)) return this.error("SELECT: NODE NOT SELECTABLE"); - if(this.hovered) this.hovered.children("A").removeClass("hover ui-state-hover"); - - // SAVE NEWLY SELECTED - this.hovered = obj; - - // FOCUS NEW NODE AND OPEN ALL PARENT NODES IF CLOSED - this.hovered.children("a").removeClass("hover ui-state-hover").addClass( this.settings.ui.theme_name == "themeroller" ? "hover ui-state-hover" : "hover"); - - // SCROLL SELECTED NODE INTO VIEW - var off_t = this.hovered.offset().top; - var beg_t = this.container.offset().top; - var end_t = beg_t + this.container.height(); - var h_cor = (this.container.get(0).scrollWidth > this.container.width()) ? 40 : 20; - if(off_t + 5 < beg_t) this.container.scrollTop(this.container.scrollTop() - (beg_t - off_t + 5) ); - if(off_t + h_cor > end_t) this.container.scrollTop(this.container.scrollTop() + (off_t + h_cor - end_t) ); - }, - select_branch : function (obj, multiple) { - if(this.locked) return this.error("LOCKED"); - if(!obj && this.hovered !== false) obj = this.hovered; - var _this = this; - obj = _this.get_node(obj); - if(!obj.size()) return this.error("SELECT: NOT A VALID NODE"); - obj.children("a").removeClass("hover ui-state-hover"); - // CHECK AGAINST RULES FOR SELECTABLE NODES - if(!_this.check("clickable", obj)) return this.error("SELECT: NODE NOT SELECTABLE"); - if(_this.settings.callback.beforechange.call(null,obj.get(0),_this) === false) return this.error("SELECT: STOPPED BY USER"); - // IF multiple AND obj IS ALREADY SELECTED - DESELECT IT - if(this.settings.rules.multiple != false && multiple && obj.children("a.clicked").size() > 0) { - return this.deselect_branch(obj); - } - if(this.settings.rules.multiple != false && multiple) { - this.selected_arr.push(obj); - } - if(this.settings.rules.multiple != false && !multiple) { - for(var i in this.selected_arr) { - if(typeof this.selected_arr[i] == "function") continue; - this.selected_arr[i].children("A").removeClass("clicked ui-state-active"); - this.settings.callback.ondeselect.call(null, this.selected_arr[i].get(0), _this); - } - this.selected_arr = []; - this.selected_arr.push(obj); - if(this.selected && this.selected.children("A").hasClass("clicked")) { - this.selected.children("A").removeClass("clicked ui-state-active"); - this.settings.callback.ondeselect.call(null, this.selected.get(0), _this); - } - } - if(!this.settings.rules.multiple) { - if(this.selected) { - this.selected.children("A").removeClass("clicked ui-state-active"); - this.settings.callback.ondeselect.call(null, this.selected.get(0), _this); - } - } - // SAVE NEWLY SELECTED - this.selected = obj; - if( (this.settings.ui.hover_mode || this.settings.ui.theme_name == "themeroller") && this.hovered !== false) { - this.hovered.children("A").removeClass("hover ui-state-hover"); - this.hovered = obj; - } - - // FOCUS NEW NODE AND OPEN ALL PARENT NODES IF CLOSED - this.selected.children("a").removeClass("clicked ui-state-active").addClass( this.settings.ui.theme_name == "themeroller" ? "clicked ui-state-active" : "clicked").end().parents("li.closed").each( function () { _this.open_branch(this, true); }); - - // SCROLL SELECTED NODE INTO VIEW - var off_t = this.selected.offset().top; - var beg_t = this.container.offset().top; - var end_t = beg_t + this.container.height(); - var h_cor = (this.container.get(0).scrollWidth > this.container.width()) ? 40 : 20; - if(off_t + 5 < beg_t) this.container.scrollTop(this.container.scrollTop() - (beg_t - off_t + 5) ); - if(off_t + h_cor > end_t) this.container.scrollTop(this.container.scrollTop() + (off_t + h_cor - end_t) ); - - this.set_cookie("selected"); - this.settings.callback.onselect.call(null, this.selected.get(0), _this); - this.settings.callback.onchange.call(null, this.selected.get(0), _this); - }, - deselect_branch : function (obj) { - if(this.locked) return this.error("LOCKED"); - var _this = this; - var obj = this.get_node(obj); - obj.children("a").removeClass("clicked ui-state-active"); - this.settings.callback.ondeselect.call(null, obj.get(0), _this); - if(this.settings.rules.multiple != false && this.selected_arr.length > 1) { - this.selected_arr = []; - this.container.find("a.clicked").filter(":first-child").parent().each(function () { - _this.selected_arr.push($(this)); - }); - if(obj.get(0) == this.selected.get(0)) { - this.selected = this.selected_arr[0]; - this.set_cookie("selected"); - } - } - else { - if(this.settings.rules.multiple != false) this.selected_arr = []; - this.selected = false; - this.set_cookie("selected"); - } - if(this.selected) this.settings.callback.onchange.call(null, this.selected.get(0), _this); - else this.settings.callback.onchange.call(null, false, _this); - }, - toggle_branch : function (obj) { - if(this.locked) return this.error("LOCKED"); - var obj = this.get_node(obj); - if(obj.hasClass("closed")) return this.open_branch(obj); - if(obj.hasClass("open")) return this.close_branch(obj); - }, - open_branch : function (obj, disable_animation, callback) { - if(this.locked) return this.error("LOCKED"); - var obj = this.get_node(obj); - if(!obj.size()) return this.error("OPEN: NO SUCH NODE"); - if(obj.hasClass("leaf")) return this.error("OPEN: OPENING LEAF NODE"); - - if(this.settings.data.async && obj.find("li").size() == 0) { - if(this.settings.callback.beforeopen.call(null,obj.get(0),this) === false) return this.error("OPEN: STOPPED BY USER"); - var _this = this; - obj.children("ul:eq(0)").remove().end().append(""); - obj.removeClass("closed").addClass("open"); - if(this.settings.data.type == "xml_flat" || this.settings.data.type == "xml_nested") { - var xsl = (this.settings.data.type == "xml_flat") ? "flat.xsl" : "nested.xsl"; - obj.children("ul:eq(0)").getTransform(this.path + xsl, this.settings.data.url, { params : { theme_path : _this.theme }, meth : this.settings.data.method, dat : this.settings.data.async_data(obj, this), repl : true, - callback: function (str, json) { - if(str.length < 15) { - obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove(); - if(callback) callback.call(); - return; - } - _this.open_branch.apply(_this, [obj]); - if(callback) callback.call(); - }, - error : function () { obj.removeClass("open").addClass("closed").children("ul:eq(0)").remove(); } - }); - } - else { - $.ajax({ - type : this.settings.data.method, - url : this.settings.data.url, - data : this.settings.data.async_data(obj, this), - dataType : "json", - success : function (data, textStatus) { - data = _this.settings.callback.onJSONdata.call(null, data, _this); - if(!data || data.length == 0) { - obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove(); - if(callback) callback.call(); - return; - } - var str = ""; - if(data.length) { - for(var i = 0; i < data.length; i++) { - str += _this.parseJSON(data[i]); - } - } - else str = _this.parseJSON(data); - if(str.length > 0) { - obj.children("ul:eq(0)").replaceWith("
          " + str + "
        "); - obj.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed"); - obj.find("li").not(".open").not(".closed").addClass("leaf"); - _this.open_branch.apply(_this, [obj]); - } - else obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove(); - if(callback) callback.call(); - }, - error : function (xhttp, textStatus, errorThrown) { obj.removeClass("open").addClass("closed").children("ul:eq(0)").remove(); _this.error(errorThrown + " " + textStatus); } - }); - } - return true; - } - else { - if(!this.settings.data.async) { - if(this.settings.callback.beforeopen.call(null,obj.get(0),this) === false) return this.error("OPEN: STOPPED BY USER"); - } - if(this.settings.ui.theme_name == "themeroller") obj.find("a").not(".ui-state-default").addClass("ui-state-default"); - if(parseInt(this.settings.ui.animation) > 0 && !disable_animation ) { - obj.children("ul:eq(0)").css("display","none"); - obj.removeClass("closed").addClass("open"); - obj.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation), function() { - $(this).css("display",""); - if(callback) callback.call(); - }); - } else { - obj.removeClass("closed").addClass("open"); - if(callback) callback.call(); - } - this.set_cookie("open"); - this.settings.callback.onopen.call(null, obj.get(0), this); - return true; - } - }, - close_branch : function (obj, disable_animation) { - if(this.locked) return this.error("LOCKED"); - var _this = this; - var obj = this.get_node(obj); - if(!obj.size()) return this.error("CLOSE: NO SUCH NODE"); - if(_this.settings.callback.beforeclose.call(null,obj.get(0),_this) === false) return this.error("CLOSE: STOPPED BY USER"); - if(parseInt(this.settings.ui.animation) > 0 && !disable_animation && obj.children("ul:eq(0)").size() == 1) { - obj.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation), function() { - if(obj.hasClass("open")) obj.removeClass("open").addClass("closed"); - _this.set_cookie("open"); - $(this).css("display",""); - }); - } - else { - if(obj.hasClass("open")) obj.removeClass("open").addClass("closed"); - this.set_cookie("open"); - } - if(this.selected && obj.children("ul:eq(0)").find("a.clicked").size() > 0) { - obj.find("li:has(a.clicked)").each(function() { - _this.deselect_branch(this); - }); - if(obj.children("a.clicked").size() == 0) this.select_branch(obj, (this.settings.rules.multiple != false && this.selected_arr.length > 0) ); - } - this.settings.callback.onclose.call(null, obj.get(0), this); - }, - open_all : function (obj, callback) { - if(this.locked) return this.error("LOCKED"); - var _this = this; - obj = obj ? this.get_node(obj).parent() : this.container; - - var s = obj.find("li.closed").size(); - if(!callback) this.cl_count = 0; - else this.cl_count --; - if(s > 0) { - this.cl_count += s; - obj.find("li.closed").each( function () { var __this = this; _this.open_branch.apply(_this, [this, true, function() { _this.open_all.apply(_this, [__this, true]); } ]); }); - } - else if(this.cl_count == 0) this.settings.callback.onopen_all.call(null,this); - }, - close_all : function () { - if(this.locked) return this.error("LOCKED"); - var _this = this; - this.container.find("li.open").each( function () { _this.close_branch(this, true); }); - }, - show_lang : function (i) { - if(this.locked) return this.error("LOCKED"); - if(this.settings.languages[i] == this.current_lang) return true; - var st = false; - var id = this.container.attr("id") ? "#" + this.container.attr("id") : ".tree"; - st = get_css(id + " ." + this.current_lang, this.sn); - if(st !== false) st.style.display = "none"; - st = get_css(id + " ." + this.settings.languages[i], this.sn); - if(st !== false) st.style.display = ""; - this.current_lang = this.settings.languages[i]; - return true; - }, - cycle_lang : function() { - if(this.locked) return this.error("LOCKED"); - var i = $.inArray(this.current_lang, this.settings.languages); - i ++; - if(i > this.settings.languages.length - 1) i = 0; - this.show_lang(i); - }, - create : function (obj, ref_node, position) { - if(this.locked) return this.error("LOCKED"); - - var root = false; - if(ref_node == -1) { root = true; ref_node = this.container; } - else ref_node = ref_node ? this.get_node(ref_node) : this.selected; - - if(!root && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED"); - - var pos = position; - - var tmp = ref_node; // for type calculation - if(position == "before") { - position = ref_node.parent().children().index(ref_node); - ref_node = ref_node.parents("li:eq(0)"); - } - if(position == "after") { - position = ref_node.parent().children().index(ref_node) + 1; - ref_node = ref_node.parents("li:eq(0)"); - } - if(!root && ref_node.size() == 0) { root = true; ref_node = this.container; } - - if(!root) { - if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE"); - if(ref_node.hasClass("closed")) { - if(this.settings.data.async && ref_node.children("ul").size() == 0) { - var _this = this; - return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } ); - } - else this.open_branch(ref_node, true); - } - } - - // creating new object to pass to parseJSON - var torename = false; - if(!obj) obj = {}; - else obj = $.extend(true, {}, obj); - if(!obj.attributes) obj.attributes = {}; - if(this.settings.rules.metadata) { - if(!obj.attributes[this.settings.rules.metadata]) obj.attributes[this.settings.rules.metadata] = '{ "type" : "' + (this.get_type(tmp) || "") + '" }'; - } - else { - if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(tmp) || ""; - } - if(this.settings.languages.length) { - if(!obj.data) { obj.data = {}; torename = true; } - for(var i = 0; i < this.settings.languages.length; i++) { - if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node; - } - } - else { - if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; } - } - - var $li = $(this.parseJSON(obj)); - if($li.children("ul").size()) { - if(!$li.is(".open")) $li.addClass("closed"); - } - else $li.addClass("leaf"); - $li.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed"); - $li.find("li").not(".open").not(".closed").addClass("leaf"); - - if(!root && this.settings.rules.use_inline && this.settings.rules.metadata) { - var t = this.get_type($li) || ""; - $.metadata.setType("attr", this.settings.rules.metadata); - if(typeof ref_node.metadata()["valid_children"] != "undefined") { - if($.inArray(t, ref_node.metadata()["valid_children"]) == -1) return this.error("CREATE: NODE NOT A VALID CHILD"); - } - if(typeof ref_node.metadata()["max_children"] != "undefined") { - if( (ref_node.children("ul:eq(0)").children("li").size() + 1) > ref_node.metadata().max_children) return this.error("CREATE: MAX_CHILDREN REACHED"); - } - var ok = true; - if((typeof $(ref_node).metadata().max_depth).toLowerCase() != "undefined" && $(ref_node).metadata().max_depth === 0) ok = false; - else { - ref_node.parents("li").each(function(i) { - if($(this).metadata().max_depth) { - if( (i + 1) >= $(this).metadata().max_depth) { - ok = false; - return false; - } - } - }); - } - if(!ok) return this.error("CREATE: MAX_DEPTH REACHED"); - } - - if((typeof position).toLowerCase() == "undefined" || position == "inside") - position = (this.settings.rules.createat == "top") ? 0 : ref_node.children("ul:eq(0)").children("li").size(); - if(ref_node.children("ul").size() == 0 || (root == true && ref_node.children("ul").children("li").size() == 0) ) { - if(!root) var a = this.moved($li,ref_node.children("a:eq(0)"),"inside", true); - else var a = this.moved($li,this.container.children("ul:eq(0)"),"inside", true); - } - else if(pos == "before" && ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) - var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", true); - else if(pos == "after" && ref_node.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size()) - var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after", true); - else if(ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) - var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", true); - else - var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true); - - if(a === false) return this.error("CREATE: ABORTED"); - - if(torename) { - this.select_branch($li.children("a:eq(0)")); - this.rename(); - } - return $li; - }, - rename : function (obj) { - if(this.locked) return this.error("LOCKED"); - obj = obj ? this.get_node(obj) : this.selected; - var _this = this; - if(!obj || !obj.size()) return this.error("RENAME: NO NODE SELECTED"); - if(!this.check("renameable", obj)) return this.error("RENAME: NODE NOT RENAMABLE"); - if(!this.settings.callback.beforerename.call(null,obj.get(0), _this.current_lang, _this)) return this.error("RENAME: STOPPED BY USER"); - - obj.parents("li.closed").each(function () { _this.open_branch(this) }); - if(this.current_lang) obj = obj.find("a." + this.current_lang).get(0); - else obj = obj.find("a:first").get(0); - last_value = obj.innerHTML; - _this.inp = $(""); - _this.inp - .val(last_value.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")) - .bind("mousedown", function (event) { event.stopPropagation(); }) - .bind("mouseup", function (event) { event.stopPropagation(); }) - .bind("click", function (event) { event.stopPropagation(); }) - .bind("keyup", function (event) { - var key = event.keyCode || event.which; - if(key == 27) { this.value = last_value; this.blur(); return } - if(key == 13) { this.blur(); return } - }); - - // Rollback - var rb = {}; - rb[this.container.attr("id")] = this.get_rollback(); - - _this.inp.blur(function(event) { - if(this.value == "") this.value = last_value; - $(obj).text( $(obj).parent().find("input").eq(0).attr("value") ).get(0).style.display = ""; - $(obj).prevAll("span").remove(); - _this.settings.callback.onrename.call(null, _this.get_node(obj).get(0), _this.current_lang, _this, rb); - _this.inp = false; - }); - var spn = $("").addClass(obj.className).append(_this.inp); - spn.attr("style", $(obj).attr("style")); - obj.style.display = "none"; - $(obj).parent().prepend(spn); - _this.inp.get(0).focus(); - _this.inp.get(0).select(); - }, - // REMOVE NODES - remove : function(obj) { - if(this.locked) return this.error("LOCKED"); - - // Rollback - var rb = {}; - rb[this.container.attr("id")] = this.get_rollback(); - - if(obj && (!this.selected || this.get_node(obj).get(0) != this.selected.get(0) )) { - obj = this.get_node(obj); - if(obj.size()) { - if(!this.check("deletable", obj)) return this.error("DELETE: NODE NOT DELETABLE"); - if(!this.settings.callback.beforedelete.call(null,obj.get(0), _this)) return this.error("DELETE: STOPPED BY USER"); - $parent = obj.parent(); - obj = obj.remove(); - $parent.children("li:last").addClass("last"); - if($parent.children("li").size() == 0) { - $li = $parent.parents("li:eq(0)"); - $li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove(); - this.set_cookie("open"); - } - this.settings.callback.ondelete.call(null, obj.get(0), this, rb); - } - } - else if(this.selected) { - if(!this.check("deletable", this.selected)) return this.error("DELETE: NODE NOT DELETABLE"); - if(!this.settings.callback.beforedelete.call(null,this.selected.get(0), _this)) return this.error("DELETE: STOPPED BY USER"); - $parent = this.selected.parent(); - var obj = this.selected; - if(this.settings.rules.multiple == false || this.selected_arr.length == 1) { - var stop = true; - var tmp = (this.selected.prev("li:eq(0)").size()) ? this.selected.prev("li:eq(0)") : this.selected.parents("li:eq(0)"); - // this.get_prev(true); - } - obj = obj.remove(); - $parent.children("li:last").addClass("last"); - if($parent.children("li").size() == 0) { - $li = $parent.parents("li:eq(0)"); - $li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove(); - this.set_cookie("open"); - } - //this.selected = false; - this.settings.callback.ondelete.call(null, obj.get(0), this, rb); - if(stop && tmp) this.select_branch(tmp); - if(this.settings.rules.multiple != false && !stop) { - var _this = this; - this.selected_arr = []; - this.container.find("a.clicked").filter(":first-child").parent().each(function () { - _this.selected_arr.push($(this)); - }); - if(this.selected_arr.length > 0) { - this.selected = this.selected_arr[0]; - this.remove(); - } - } - } - else return this.error("DELETE: NO NODE SELECTED"); - }, - - next : function (obj, strict) { - obj = this.get_node(obj); - if(!obj.size()) return false; - if(strict) return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false; - - if(obj.hasClass("open")) return obj.find("li:eq(0)"); - else if(obj.nextAll("li").size() > 0) return obj.nextAll("li:eq(0)"); - else return obj.parents("li").next("li").eq(0); - }, - prev : function(obj, strict) { - obj = this.get_node(obj); - if(!obj.size()) return false; - if(strict) return (obj.prevAll("li").size() > 0) ? obj.prevAll("li:eq(0)") : false; - - if(obj.prev("li").size()) { - var obj = obj.prev("li").eq(0); - while(obj.hasClass("open")) obj = obj.children("ul:eq(0)").children("li:last"); - return obj; - } - else return obj.parents("li:eq(0)").size() ? obj.parents("li:eq(0)") : false; - }, - parent : function(obj) { - obj = this.get_node(obj); - if(!obj.size()) return false; - return obj.parents("li:eq(0)").size() ? obj.parents("li:eq(0)") : false; - }, - children : function(obj) { - obj = this.get_node(obj); - if(!obj.size()) return false; - return obj.children("ul:eq(0)").children("li"); - }, - - // FOR EXPLORER-LIKE KEYBOARD SHORTCUTS - get_next : function(force) { - var obj = this.hovered || this.selected; - return force ? this.select_branch(this.next(obj)) : this.hover_branch(this.next(obj)); - }, - get_prev : function(force) { - var obj = this.hovered || this.selected; - return force ? this.select_branch(this.prev(obj)) : this.hover_branch(this.prev(obj)); - }, - get_left : function(force, rtl) { - if(this.settings.ui.rtl && !rtl) return this.get_right(force, true); - var obj = this.hovered || this.selected; - if(obj) { - if(obj.hasClass("open")) this.close_branch(obj); - else { - return force ? this.select_branch(this.parent(obj)) : this.hover_branch(this.parent(obj)); - } - } - }, - get_right : function(force, rtl) { - if(this.settings.ui.rtl && !rtl) return this.get_left(force, true); - var obj = this.hovered || this.selected; - if(obj) { - if(obj.hasClass("closed")) this.open_branch(obj); - else { - return force ? this.select_branch(obj.find("li:eq(0)")) : this.hover_branch(obj.find("li:eq(0)")); - } - } - }, - toggleDots : function () { - if(this.settings.ui.dots) { - this.settings.ui.dots = false; - this.container.children("ul:eq(0)").addClass("no_dots"); - } - else { - this.settings.ui.dots = true; - this.container.children("ul:eq(0)").removeClass("no_dots"); - } - }, - toggleRTL : function () { - if(this.settings.ui.rtl) { - this.settings.ui.rtl = false; - this.container.css("direction","ltr").children("ul:eq(0)").removeClass("rtl").addClass("ltr"); - } - else { - this.settings.ui.rtl = true; - this.container.css("direction","rtl").children("ul:eq(0)").removeClass("ltr").addClass("rtl"); - } - }, - set_cookie : function (type) { - if(this.settings.cookies === false) return false; - if(this.settings.cookies[type] === false) return false; - switch(type) { - case "selected": - if(this.settings.rules.multiple != false && this.selected_arr.length > 1) { - var val = Array(); - $.each(this.selected_arr, function () { - if(this.attr("id")) { val.push(this.attr("id")); } - }); - val = val.join(","); - } - else var val = this.selected ? this.selected.attr("id") : false; - $.cookie(this.settings.cookies.prefix + '_selected',val,this.settings.cookies.opts); - break; - case "open": - var str = ""; - this.container.find("li.open").each(function (i) { if(this.id) { str += this.id + ","; } }); - $.cookie(this.settings.cookies.prefix + '_open',str.replace(/,$/ig,""),this.settings.cookies.opts); - break; - } - }, - get_rollback : function () { - var rb = {}; - if(this.context.to_remove && this.context.apply_to) this.context.apply_to.children("a").removeClass("clicked"); - rb.html = this.container.html(); - if(this.context.to_remove && this.context.apply_to) this.context.apply_to.children("a").addClass("clicked"); - rb.selected = this.selected ? this.selected.attr("id") : false; - return rb; - }, - moved : function (what, where, how, is_new, is_copy, rb) { - var what = $(what); - var $parent = $(what).parents("ul:eq(0)"); - var $where = $(where); - - // Rollback - if(!rb) { - var rb = {}; - rb[this.container.attr("id")] = this.get_rollback(); - if(!is_new) { - var tmp = what.size() > 1 ? what.eq(0).parents(".tree:eq(0)") : what.parents(".tree:eq(0)"); - if(tmp.get(0) != this.container.get(0)) { - tmp = tree_component.inst[tmp.attr("id")]; - rb[tmp.container.attr("id")] = tmp.get_rollback(); - } - delete tmp; - } - } - - if(how == "inside" && this.settings.data.async && this.get_node($where).hasClass("closed")) { - var _this = this; - return this.open_branch(this.get_node($where), true, function () { _this.moved.apply(_this, [what, where, how, is_new, is_copy, rb]); }); - } - - // IF MULTIPLE - if(what.size() > 1) { - var _this = this; - var tmp = this.moved(what.eq(0), where, how, false, is_copy, rb); - what.each(function (i) { - if(i == 0) return; - if(tmp) { // if tmp is false - the previous move was a no-go - tmp = _this.moved(this, tmp.children("a:eq(0)"), "after", false, is_copy, rb); - } - }); - return; - } - - if(is_copy) { - _what = what.clone(); - _what.each(function (i) { - this.id = this.id + "_copy"; - $(this).find("li").each(function () { - this.id = this.id + "_copy"; - }); - $(this).removeClass("dragged").find("a.clicked").removeClass("clicked ui-state-active").end().find("li.dragged").removeClass("dragged"); - }); - } - else _what = what; - if(is_new) { - if(!this.settings.callback.beforecreate.call(null,this.get_node(what).get(0), this.get_node(where).get(0),how,this)) return false; - } - else { - if(!this.settings.callback.beforemove.call(null,this.get_node(what).get(0), this.get_node(where).get(0),how,this)) return false; - } - - if(!is_new) { - var tmp = what.parents(".tree:eq(0)"); - // if different trees - if(tmp.get(0) != this.container.get(0)) { - tmp = tree_component.inst[tmp.attr("id")]; - - // if there are languages - otherwise - no cleanup needed - if(tmp.settings.languages.length) { - var res = []; - // if new tree has no languages - use current visible - if(this.settings.languages.length == 0) res.push("." + tmp.current_lang); - else { - for(var i in this.settings.languages) { - if(typeof this.settings.languages[i] == "function") continue; - for(var j in tmp.settings.languages) { - if(typeof tmp.settings.languages[j] == "function") continue; - if(this.settings.languages[i] == tmp.settings.languages[j]) res.push("." + this.settings.languages[i]); - } - } - } - if(res.length == 0) return this.error("MOVE: NO COMMON LANGUAGES"); - what.find("a").not(res.join(",")).remove(); - } - what.find("a.clicked").removeClass("clicked ui-state-active"); - } - } - what = _what; - - // ADD NODE TO NEW PLACE - switch(how) { - case "before": - $where.parents("ul:eq(0)").children("li.last").removeClass("last"); - $where.parent().before(what.removeClass("last")); - $where.parents("ul:eq(0)").children("li:last").addClass("last"); - break; - case "after": - $where.parents("ul:eq(0)").children("li.last").removeClass("last"); - $where.parent().after(what.removeClass("last")); - $where.parents("ul:eq(0)").children("li:last").addClass("last"); - break; - case "inside": - if($where.parent().children("ul:first").size()) { - if(this.settings.rules.createat == "top") $where.parent().children("ul:first").prepend(what.removeClass("last")).children("li:last").addClass("last"); - else $where.parent().children("ul:first").children(".last").removeClass("last").end().append(what.removeClass("last")).children("li:last").addClass("last"); - } - else { - what.addClass("last"); - $where.parent().append("
          ").removeClass("leaf").addClass("closed"); - $where.parent().children("ul:first").prepend(what); - } - if($where.parent().hasClass("closed")) { this.open_branch($where); } - break; - default: - break; - } - // CLEANUP OLD PARENT - if($parent.find("li").size() == 0) { - var $li = $parent.parent(); - $li.removeClass("open").removeClass("closed").addClass("leaf"); - if(!$li.is(".tree")) $li.children("ul").remove(); - $li.parents("ul:eq(0)").children("li.last").removeClass("last").end().children("li:last").addClass("last"); - this.set_cookie("open"); - } - else { - $parent.children("li.last").removeClass("last"); - $parent.children("li:last").addClass("last"); - } - - // NO LONGER CORRECT WITH position PARAM - if(is_new && how != "inside") where = this.get_node(where).parents("li:eq(0)"); - if(is_copy) this.settings.callback.oncopy.call(null, this.get_node(what).get(0), this.get_node(where).get(0), how, this, rb); - else if(is_new) this.settings.callback.oncreate.call(null, this.get_node(what).get(0), ($where.is("ul") ? -1 : this.get_node(where).get(0) ), how, this, rb); - else this.settings.callback.onmove.call(null, this.get_node(what).get(0), this.get_node(where).get(0), how, this, rb); - return what; - }, - error : function (code) { - this.settings.callback.error.call(null,code,this); - return false; - }, - lock : function (state) { - this.locked = state; - if(this.locked) this.container.children("ul:eq(0)").addClass("locked"); - else this.container.children("ul:eq(0)").removeClass("locked"); - }, - cut : function (obj) { - if(this.locked) return this.error("LOCKED"); - obj = obj ? this.get_node(obj) : this.container.find("a.clicked").filter(":first-child").parent(); - if(!obj || !obj.size()) return this.error("CUT: NO NODE SELECTED"); - this.copy_nodes = false; - this.cut_nodes = obj; - }, - copy : function (obj) { - if(this.locked) return this.error("LOCKED"); - obj = obj ? this.get_node(obj) : this.container.find("a.clicked").filter(":first-child").parent(); - if(!obj || !obj.size()) return this.error("COPY: NO NODE SELECTED"); - this.copy_nodes = obj; - this.cut_nodes = false; - }, - paste : function (obj, position) { - if(this.locked) return this.error("LOCKED"); - - var root = false; - if(obj == -1) { root = true; obj = this.container; } - else obj = obj ? this.get_node(obj) : this.selected; - - if(!root && (!obj || !obj.size())) return this.error("PASTE: NO NODE SELECTED"); - if(!this.copy_nodes && !this.cut_nodes) return this.error("PASTE: NOTHING TO DO"); - - var _this = this; - - var pos = position; - - if(position == "before") { - position = obj.parent().children().index(obj); - obj = obj.parents("li:eq(0)"); - } - else if(position == "after") { - position = obj.parent().children().index(obj) + 1; - obj = obj.parents("li:eq(0)"); - } - else if((typeof position).toLowerCase() == "undefined" || position == "inside") { - position = (this.settings.rules.createat == "top") ? 0 : obj.children("ul:eq(0)").children("li").size(); - } - if(!root && obj.size() == 0) { root = true; obj = this.container; } - - if(this.copy_nodes && this.copy_nodes.size()) { - var ok = true; - // This is copy - why forbid this? - //obj.parents().andSelf().each(function () { - // if(_this.copy_nodes.index(this) != -1) { - // ok = false; - // return false; - // } - //}); - if(!ok) return this.error("Invalid paste"); - if(!root && !this.checkMove(this.copy_nodes, obj.children("a:eq(0)"), "inside")) return false; - - if(obj.children("ul").size() == 0 || (root == true && obj.children("ul").children("li").size() == 0) ) { - if(!root) var a = this.moved(this.copy_nodes,obj.children("a:eq(0)"),"inside", false, true); - else var a = this.moved(this.copy_nodes,this.container.children("ul:eq(0)"),"inside", false, true); - } - else if(pos == "before" && obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) - var a = this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", false, true); - else if(pos == "after" && obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size()) - var a = this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after", false, true); - else if(obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) - var a = this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", false, true); - else - var a = this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after", false, true); - this.copy_nodes = false; - } - if(this.cut_nodes && this.cut_nodes.size()) { - var ok = true; - obj.parents().andSelf().each(function () { - if(_this.cut_nodes.index(this) != -1) { - ok = false; - return false; - } - }); - if(!ok) return this.error("Invalid paste"); - if(!root && !this.checkMove(this.cut_nodes, obj.children("a:eq(0)"), "inside")) return false; - - if(obj.children("ul").size() == 0 || (root == true && obj.children("ul").children("li").size() == 0) ) { - if(!root) var a = this.moved(this.cut_nodes,obj.children("a:eq(0)"),"inside"); - else var a = this.moved(this.cut_nodes,this.container.children("ul:eq(0)"),"inside"); - } - else if(pos == "before" && obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) - var a = this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before"); - else if(pos == "after" && obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size()) - var a = this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after"); - else if(obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size()) - var a = this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before"); - else - var a = this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after"); - this.cut_nodes = false; - } - }, - search : function(str) { - var _this = this; - if(!str || (this.srch && str != this.srch) ) { - this.srch = ""; - this.srch_opn = false; - this.container.find("a.search").removeClass("search ui-state-highlight"); - } - this.srch = str; - if(!str) return; - if(this.settings.data.async) { - if(!this.srch_opn) { - var dd = $.extend( { "search" : str } , this.settings.data.async_data(false, this) ); - $.ajax({ - type : this.settings.data.method, - url : this.settings.data.url, - data : dd, - dataType : "text", - success : function (data) { - _this.srch_opn = $.unique(data.split(",")); - _this.search.apply(_this,[str]); - } - }); - } - else if(this.srch_opn.length) { - if(this.srch_opn && this.srch_opn.length) { - var opn = false; - for(var j = 0; j < this.srch_opn.length; j++) { - if(this.get_node("#" + this.srch_opn[j]).size() > 0) { - opn = true; - var tmp = "#" + this.srch_opn[j]; - delete this.srch_opn[j]; - this.open_branch(tmp, true, function () { _this.search.apply(_this,[str]); } ); - } - } - if(!opn) { - this.srch_opn = []; - _this.search.apply(_this,[str]); - } - } - } - else { - var selector = "a"; - // IF LANGUAGE VERSIONS - if(this.settings.languages.length) selector += "." + this.current_lang; - this.container.find(selector + ":contains('" + str + "')").addClass( this.settings.ui.theme_name == "themeroller" ? "search ui-state-highlight" : "search"); - this.srch_opn = false; - } - } - else { - var selector = "a"; - // IF LANGUAGE VERSIONS - if(this.settings.languages.length) selector += "." + this.current_lang; - this.container.find(selector + ":contains('" + str + "')").addClass( this.settings.ui.theme_name == "themeroller" ? "search ui-state-highlight" : "search").parents("li.closed").each( function () { _this.open_branch(this, true); }); - } - }, - - destroy : function() { - this.hide_context(); - this.container.unbind(".jstree"); - $("#" + this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("contextmenu.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree"); - this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-" + this.settings.ui.theme_name).children("ul").removeClass("no_dots rtl ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search ui-state-active ui-state-hover ui-state-highlight ui-state-default"); - - if(this.cntr == tree_component.focused) { - for(var i in tree_component.inst) { - if(i != this.cntr && i != this.container.attr("id")) { - tree_component.inst[i].focus(); - break; - } - } - } - - tree_component.inst[this.cntr] = false; - tree_component.inst[this.container.attr("id")] = false; - delete tree_component.inst[this.cntr]; - delete tree_component.inst[this.container.attr("id")]; - tree_component.cntr --; - } - } - }; -})(jQuery); \ No newline at end of file diff --git a/umbraco/presentation/umbraco_client/Tree/tree_component.min.js b/umbraco/presentation/umbraco_client/Tree/tree_component.min.js deleted file mode 100644 index 682704401a..0000000000 --- a/umbraco/presentation/umbraco_client/Tree/tree_component.min.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - * jsTree 0.9.8 - * http://jstree.com/ - * - * Copyright (c) 2009 Ivan Bozhanov (vakata.com) - * - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * Date: 2009-05-15 - * - */ -(function($){$.fn.tree=function(opts){return this.each(function(){var conf=$.extend({},opts);if(tree_component.inst&&tree_component.inst[$(this).attr('id')])tree_component.inst[$(this).attr('id')].destroy();if(conf!==false)new tree_component().init(this,conf)})};$.tree_create=function(){return new tree_component()};$.tree_focused=function(){return tree_component.inst[tree_component.focused]};$.tree_reference=function(id){return tree_component.inst[id]||null};$.tree_rollback=function(data){for(var i in data){if(typeof data[i]=="function")continue;var tmp=tree_component.inst[i];var lock=!tmp.locked;if(lock)tmp.lock(true);if(tmp.inp)tmp.inp.val("").blur();tmp.context.append=false;tmp.container.html(data[i].html).find(".dragged").removeClass("dragged").end().find("div.context").remove();if(data[i].selected){tmp.selected=$("#"+data[i].selected);tmp.selected_arr=[];tmp.container.find("a.clicked").each(function(){tmp.selected_arr.push(tmp.get_node(this))})}if(lock)tmp.lock(false);delete lock;delete tmp}};function tree_component(){if(typeof tree_component.inst=="undefined"){tree_component.cntr=0;tree_component.inst={};tree_component.drag_drop={isdown:false,drag_node:false,drag_help:false,init_x:false,init_y:false,moving:false,origin_tree:false,marker:false,move_type:false,ref_node:false,appended:false,foreign:false,droppable:[],open_time:false,scroll_time:false};tree_component.mousedown=function(event){var tmp=$(event.target);if(tree_component.drag_drop.droppable.length&&tmp.is("."+tree_component.drag_drop.droppable.join(", ."))){tree_component.drag_drop.drag_help=$("");tree_component.drag_drop.drag_node=tree_component.drag_drop.drag_help.find("li:eq(0)");tree_component.drag_drop.isdown=true;tree_component.drag_drop.foreign=tmp;tmp.blur();event.preventDefault();event.stopPropagation();return false}event.stopPropagation();return true};tree_component.mouseup=function(event){var tmp=tree_component.drag_drop;if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.foreign===false&&tmp.drag_node&&tmp.drag_node.size()){tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.moved(tmp.origin_tree.container.find("li.dragged"),tmp.ref_node,tmp.move_type,false,(tmp.origin_tree.settings.rules.drag_copy=="on"||(tmp.origin_tree.settings.rules.drag_copy=="ctrl"&&event.ctrlKey)))}tmp.move_type=false;tmp.ref_node=false}if(tmp.drag_node&&tmp.foreign!==false){tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.settings.callback.ondrop.call(null,tmp.foreign.get(0),tree1.get_node(tmp.ref_node).get(0),tmp.move_type,tree1)}tmp.foreign=false;tmp.move_type=false;tmp.ref_node=false}tree_component.drag_drop.marker.hide();tmp.drag_help=false;tmp.drag_node=false;tmp.isdown=false;tmp.init_x=false;tmp.init_y=false;tmp.moving=false;tmp.appended=false;$("li.dragged").removeClass("dragged");tmp.origin_tree=false;event.preventDefault();event.stopPropagation();return false};tree_component.mousemove=function(event){var tmp=tree_component.drag_drop;if(tmp.isdown){if(!tmp.moving&&Math.abs(tmp.init_x-event.pageX)<5&&Math.abs(tmp.init_y-event.pageY)<5){event.preventDefault();event.stopPropagation();return false}else tree_component.drag_drop.moving=true;if(tmp.open_time)clearTimeout(tmp.open_time);if(!tmp.appended){if(tmp.foreign!==false)tmp.origin_tree=$.tree_focused();$("body").append(tmp.drag_help);tmp.w=tmp.drag_help.width();tmp.appended=true}tmp.drag_help.css({"left":(event.pageX-(tmp.origin_tree.settings.ui.rtl?tmp.w:-5)),"top":(event.pageY+15)});if(event.target.tagName=="IMG"&&event.target.id=="marker")return false;var et=$(event.target);var cnt=et.is(".tree")?et:et.parents(".tree:eq(0)");if(cnt.size()==0||!tree_component.inst[cnt.attr("id")]){if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.drag_help.find("IMG").size()==0){tmp.drag_help.find("li:eq(0)").append("")}tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide();return false}var tree2=tree_component.inst[cnt.attr("id")];tree2.off_height();if(tmp.foreign===false&&tmp.origin_tree.container.get(0)!=tree2.container.get(0)&&(!tmp.origin_tree.settings.rules.multitree||!tree2.settings.rules.multitree)){if(tmp.drag_help.find("IMG").size()==0){tmp.drag_help.find("li:eq(0)").append("")}tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide();return false}if(tmp.scroll_time)clearTimeout(tmp.scroll_time);tmp.scroll_time=setTimeout(function(){tree2.scrollCheck(event.pageX,event.pageY)},50);var mov=false;var st=cnt.scrollTop();if(event.target.tagName=="A"){if(et.is("#jstree-dragged"))return false;if(tree2.get_node(event.target).hasClass("closed")){tmp.open_time=setTimeout(function(){tree2.open_branch(et)},500)}var et_off=et.offset();var goTo={x:(et_off.left-1),y:(event.pageY-et_off.top)};if(cnt.children("ul:eq(0)").hasClass("rtl"))goTo.x+=et.width()-8;var arr=[];if(goTo.ytree2.li_height*2/3-1)arr=["after","inside","before"];else{if(goTo.y")}tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide()}event.preventDefault();event.stopPropagation();return false}return true}};return{cntr:++tree_component.cntr,settings:{data:{type:"predefined",method:"GET",async:false,async_data:function(NODE,TREE_OBJ){return{id:$(NODE).attr("id")||0}},url:false,json:false,xml:false},selected:false,opened:[],languages:[],path:false,cookies:false,ui:{dots:true,rtl:false,animation:0,hover_mode:true,scroll_spd:4,theme_path:false,theme_name:"default",context:[{id:"create",label:"Create",icon:"create.png",visible:function(NODE,TREE_OBJ){if(NODE.length!=1)return false;return TREE_OBJ.check("creatable",NODE)},action:function(NODE,TREE_OBJ){TREE_OBJ.create(false,TREE_OBJ.get_node(NODE[0]))}},"separator",{id:"rename",label:"Rename",icon:"rename.png",visible:function(NODE,TREE_OBJ){if(NODE.length!=1)return false;return TREE_OBJ.check("renameable",NODE)},action:function(NODE,TREE_OBJ){TREE_OBJ.rename(NODE)}},{id:"delete",label:"Delete",icon:"remove.png",visible:function(NODE,TREE_OBJ){var ok=true;$.each(NODE,function(){if(TREE_OBJ.check("deletable",this)==false)ok=false;return false});return ok},action:function(NODE,TREE_OBJ){$.each(NODE,function(){TREE_OBJ.remove(this)})}}]},rules:{multiple:false,metadata:false,type_attr:"rel",multitree:false,createat:"bottom",use_inline:false,clickable:"all",renameable:"all",deletable:"all",creatable:"all",draggable:"none",dragrules:"all",drag_copy:false,droppable:[],drag_button:"left"},lang:{new_node:"New folder",loading:"Loading ..."},callback:{beforechange:function(NODE,TREE_OBJ){return true},beforeopen:function(NODE,TREE_OBJ){return true},beforeclose:function(NODE,TREE_OBJ){return true},beforemove:function(NODE,REF_NODE,TYPE,TREE_OBJ){return true},beforecreate:function(NODE,REF_NODE,TYPE,TREE_OBJ){return true},beforerename:function(NODE,LANG,TREE_OBJ){return true},beforedelete:function(NODE,TREE_OBJ){return true},onJSONdata:function(DATA,TREE_OBJ){return DATA},onselect:function(NODE,TREE_OBJ){},ondeselect:function(NODE,TREE_OBJ){},onchange:function(NODE,TREE_OBJ){},onrename:function(NODE,LANG,TREE_OBJ,RB){},onmove:function(NODE,REF_NODE,TYPE,TREE_OBJ,RB){},oncopy:function(NODE,REF_NODE,TYPE,TREE_OBJ,RB){},oncreate:function(NODE,REF_NODE,TYPE,TREE_OBJ,RB){},ondelete:function(NODE,TREE_OBJ,RB){},onopen:function(NODE,TREE_OBJ){},onopen_all:function(TREE_OBJ){},onclose:function(NODE,TREE_OBJ){},error:function(TEXT,TREE_OBJ){},ondblclk:function(NODE,TREE_OBJ){TREE_OBJ.toggle_branch.call(TREE_OBJ,NODE);TREE_OBJ.select_branch.call(TREE_OBJ,NODE)},onrgtclk:function(NODE,TREE_OBJ,EV){},onload:function(TREE_OBJ){},onfocus:function(TREE_OBJ){},ondrop:function(NODE,REF_NODE,TYPE,TREE_OBJ){}}},init:function(elem,conf){var _this=this;this.container=$(elem);if(this.container.size==0){alert("Invalid container node!");return}tree_component.inst[this.cntr]=this;if(!this.container.attr("id"))this.container.attr("id","jstree_"+this.cntr);tree_component.inst[this.container.attr("id")]=tree_component.inst[this.cntr];tree_component.focused=this.cntr;var opts=$.extend({},conf);if(opts&&opts.cookies){this.settings.cookies=$.extend({},this.settings.cookies,opts.cookies);delete opts.cookies;if(!this.settings.cookies.opts)this.settings.cookies.opts={}}if(opts&&opts.callback){this.settings.callback=$.extend({},this.settings.callback,opts.callback);delete opts.callback}if(opts&&opts.data){this.settings.data=$.extend({},this.settings.data,opts.data);delete opts.data}if(opts&&opts.ui){this.settings.ui=$.extend({},this.settings.ui,opts.ui);delete opts.ui}if(opts&&opts.rules){this.settings.rules=$.extend({},this.settings.rules,opts.rules);delete opts.rules}if(opts&&opts.lang){this.settings.lang=$.extend({},this.settings.lang,opts.lang);delete opts.lang}this.settings=$.extend({},this.settings,opts);if(this.settings.path==false){this.path="";$("script").each(function(){if(this.src.toString().match(/tree_component.*?js$/)){_this.path=this.src.toString().replace(/tree_component.*?js$/,"")}})}else this.path=this.settings.path;this.current_lang=this.settings.languages&&this.settings.languages.length?this.settings.languages[0]:false;if(this.settings.languages&&this.settings.languages.length){this.sn=get_sheet_num("tree_component.css");if(this.sn===false&&document.styleSheets.length)this.sn=document.styleSheets.length;var st=false;var id=this.container.attr("id")?"#"+this.container.attr("id"):".tree";for(var ln=0;ln").attr({id:"marker",src:_this.settings.ui.theme_path+"marker.gif"}).css({height:"5px",width:"40px",display:"block",position:"absolute",left:"30px",top:"30px",zIndex:"1000"}).hide().appendTo("body")}this.refresh();this.attachEvents();this.focus()},off_height:function(){if(this.offset===false){this.container.css({position:"relative"});this.offset=this.container.offset();var tmp=0;tmp=parseInt($.curCSS(this.container.get(0),"paddingTop",true),10);if(tmp)this.offset.top+=tmp;tmp=parseInt($.curCSS(this.container.get(0),"borderTopWidth",true),10);if(tmp)this.offset.top+=tmp;this.container.css({position:""})}if(!this.li_height){var tmp=this.container.find("ul li.closed, ul li.leaf").eq(0);this.li_height=tmp.height();if(tmp.children("ul:eq(0)").size())this.li_height-=tmp.children("ul:eq(0)").height();if(!this.li_height)this.li_height=18}},context_menu:function(){this.context=false;if(this.settings.ui.context!=false){var str='
          ';for(var i in this.settings.ui.context){if(typeof this.settings.ui.context[i]=="function")continue;if(this.settings.ui.context[i]=="separator"){str+=" ";continue}var icn="";if(this.settings.ui.context[i].icon)icn='background-image:url(\''+(this.settings.ui.context[i].icon.indexOf("/")==-1?this.theme+this.settings.ui.context[i].icon:this.settings.ui.context[i].icon)+'\');';str+=''+this.settings.ui.context[i].label+''}str+='
          ';this.context=$(str);this.context.hide();this.context.append=false}},refresh:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;this.is_partial_refresh=obj?true:false;this.opened=Array();if(this.settings.cookies&&$.cookie(this.settings.cookies.prefix+'_open')){var str=$.cookie(this.settings.cookies.prefix+'_open');var tmp=str.split(",");$.each(tmp,function(){if(this.replace(/^#/,"").length>0){_this.opened.push("#"+this.replace(/^#/,""))}});this.settings.opened=false}else if(this.settings.opened!=false){$.each(this.settings.opened,function(i,item){if(this.replace(/^#/,"").length>0){_this.opened.push("#"+this.replace(/^#/,""))}});this.settings.opened=false}else{this.container.find("li.open").each(function(i){if(this.id){_this.opened.push("#"+this.id)}})}if(this.selected){this.settings.selected=Array();if(obj){$(obj).find("li:has(a.clicked)").each(function(){$this=$(this);if($this.attr("id"))_this.settings.selected.push("#"+$this.attr("id"))})}else{if(this.selected_arr){$.each(this.selected_arr,function(){if(this.attr("id"))_this.settings.selected.push("#"+this.attr("id"))})}else{if(this.selected.attr("id"))this.settings.selected.push("#"+this.selected.attr("id"))}}}else if(this.settings.cookies&&$.cookie(this.settings.cookies.prefix+'_selected')){this.settings.selected=Array();var str=$.cookie(this.settings.cookies.prefix+'_selected');var tmp=str.split(",");$.each(tmp,function(){if(this.replace(/^#/,"").length>0){_this.settings.selected.push("#"+this.replace(/^#/,""))}})}else if(this.settings.selected!==false){var tmp=Array();if((typeof this.settings.selected).toLowerCase()=="object"){$.each(this.settings.selected,function(){if(this.replace(/^#/,"").length>0)tmp.push("#"+this.replace(/^#/,""))})}else{if(this.settings.selected.replace(/^#/,"").length>0)tmp.push("#"+this.settings.selected.replace(/^#/,""))}this.settings.selected=tmp}if(obj&&this.settings.data.async){this.opened=Array();obj=this.get_node(obj);obj.find("li.open").each(function(i){_this.opened.push("#"+this.id)});if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");if(obj.hasClass("leaf"))obj.removeClass("leaf");obj.children("ul:eq(0)").html("");return this.open_branch(obj,true,function(){_this.reselect.apply(_this)})}if(this.settings.data.type=="xml_flat"||this.settings.data.type=="xml_nested"){this.scrtop=this.container.get(0).scrollTop;var xsl=(this.settings.data.type=="xml_flat")?"flat.xsl":"nested.xsl";if(this.settings.data.xml)this.container.getTransform(this.path+xsl,this.settings.data.xml,{params:{theme_name:_this.settings.ui.theme_name,theme_path:_this.theme},meth:_this.settings.data.method,dat:_this.settings.data.async_data.apply(_this,[obj,_this]),callback:function(){_this.context_menu.apply(_this);_this.reselect.apply(_this)}});else this.container.getTransform(this.path+xsl,this.settings.data.url,{params:{theme_name:_this.settings.ui.theme_name,theme_path:_this.theme},meth:_this.settings.data.method,dat:_this.settings.data.async_data.apply(_this,[obj,_this]),callback:function(){_this.context_menu.apply(_this);_this.reselect.apply(_this)}});return}else if(this.settings.data.type=="json"){if(this.settings.data.json){var str="";if(this.settings.data.json.length){for(var i=0;i"+str+"
        ");this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");this.container.find("li").not(".open").not(".closed").addClass("leaf");this.context_menu();this.reselect()}else{var _this=this;$.ajax({type:this.settings.data.method,url:this.settings.data.url,data:this.settings.data.async_data(false,this),dataType:"json",success:function(data){data=_this.settings.callback.onJSONdata.call(null,data,_this);var str="";if(data.length){for(var i=0;i"+str+"
      ");_this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");_this.container.find("li").not(".open").not(".closed").addClass("leaf");_this.context_menu.apply(_this);_this.reselect.apply(_this)},error:function(xhttp,textStatus,errorThrown){_this.error(errorThrown+" "+textStatus)}})}}else{this.container.children("ul:eq(0)");this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");this.container.find("li").not(".open").not(".closed").addClass("leaf");this.reselect()}},parseJSON:function(data){if(!data||!data.data)return"";var str="";str+="
    •  "}str+=((typeof data.data[this.settings.languages[i]].title).toLowerCase()!="undefined"?data.data[this.settings.languages[i]].title:data.data[this.settings.languages[i]])+""}}else{var attr={};attr["href"]="#";attr["style"]="";attr["class"]="";if((typeof data.data.attributes).toLowerCase()!="undefined"){for(var i in data.data.attributes){if(typeof data.data.attributes[i]=="function")continue;if(i=="style"||i=="class")attr[i]+=" "+data.data.attributes[i];else attr[i]=data.data.attributes[i]}}if(data.data.icon&&this.settings.ui.theme_name!="themeroller"){var icn=data.data.icon.indexOf("/")==-1?this.theme+data.data.icon:data.data.icon;attr["style"]+=" ; background-image:url('"+icn+"');"}str+=" "}str+=((typeof data.data.title).toLowerCase()!="undefined"?data.data.title:data.data)+""}if(data.children&&data.children.length){str+='
        ';for(var i=0;i'}str+="";return str},getJSON:function(nod,outer_attrib,inner_attrib,force){var _this=this;if(!nod||$(nod).size()==0){nod=this.container.children("ul").children("li")}else nod=$(nod);if(nod.size()>1){var arr=[];nod.each(function(){arr.push(_this.getJSON(this,outer_attrib,inner_attrib,force))});return arr}if(!outer_attrib)outer_attrib=["id","rel","class"];if(!inner_attrib)inner_attrib=[];var obj={attributes:{},data:false};for(var i in outer_attrib){if(typeof outer_attrib[i]=="function")continue;var val=(outer_attrib[i]=="class")?nod.attr(outer_attrib[i]).replace("last","").replace("leaf","").replace("closed","").replace("open",""):nod.attr(outer_attrib[i]);if(typeof val!="undefined"&&val.replace(" ","").length>0)obj.attributes[outer_attrib[i]]=val;delete val}if(this.settings.languages.length){obj.data={};for(var i in this.settings.languages){if(typeof this.settings.languages[i]=="function")continue;var a=nod.children("a."+this.settings.languages[i]);if(force||inner_attrib.length||a.get(0).style.backgroundImage.toString().length){obj.data[this.settings.languages[i]]={};obj.data[this.settings.languages[i]].title=a.text();if(a.get(0).style.backgroundImage.length){obj.data[this.settings.languages[i]].icon=a.get(0).style.backgroundImage.replace("url(","").replace(")","")}if(this.settings.ui.theme_name=="themeroller"&&a.children("ins").size()){var tmp=a.children("ins").attr("class");var cls=false;$.each(tmp.split(" "),function(i,val){if(val.indexOf("ui-icon-")==0){cls=val;return false}});if(cls)obj.data[this.settings.languages[i]].icon=cls}if(inner_attrib.length){obj.data[this.settings.languages[i]].attributes={};for(var j in inner_attrib){if(typeof inner_attrib[j]=="function")continue;var val=a.attr(inner_attrib[j]);if(typeof val!="undefined"&&val.replace(" ","").length>0)obj.data[this.settings.languages[i]].attributes[inner_attrib[j]]=val;delete val}}}else{obj.data[this.settings.languages[i]]=a.text()}}}else{var a=nod.children("a");if(force||inner_attrib.length||a.get(0).style.backgroundImage.toString().length){obj.data={};obj.data.title=a.text();if(a.get(0).style.backgroundImage.length){obj.data.icon=a.get(0).style.backgroundImage.replace("url(","").replace(")","")}if(this.settings.ui.theme_name=="themeroller"&&a.children("ins").size()){var tmp=a.children("ins").attr("class");var cls=false;$.each(tmp.split(" "),function(i,val){if(val.indexOf("ui-icon-")==0){cls=val;return false}});if(cls)obj.data[this.settings.languages[i]].icon=cls}if(inner_attrib.length){obj.data.attributes={};for(var j in inner_attrib){if(typeof inner_attrib[j]=="function")continue;var val=a.attr(inner_attrib[j]);if(typeof val!="undefined"&&val.replace(" ","").length>0)obj.data.attributes[inner_attrib[j]]=val;delete val}}}else{obj.data=a.text()}}if(nod.children("ul").size()>0){obj.children=[];nod.children("ul").children("li").each(function(){obj.children.push(_this.getJSON(this,outer_attrib,inner_attrib,force))})}return obj},getXML:function(tp,nod,outer_attrib,inner_attrib,cb){var _this=this;if(tp!="flat")tp="nested";if(!nod||$(nod).size()==0){nod=this.container.children("ul").children("li")}else nod=$(nod);if(nod.size()>1){var obj='';nod.each(function(){obj+=_this.getXML(tp,this,outer_attrib,inner_attrib,true)});obj+='';return obj}if(!outer_attrib)outer_attrib=["id","rel","class"];if(!inner_attrib)inner_attrib=[];var obj='';if(!cb)obj='';obj+='0)obj+=' '+outer_attrib[i]+'="'+val+'" ';delete val}obj+='>';obj+='';if(this.settings.languages.length){for(var i in this.settings.languages){if(typeof this.settings.languages[i]=="function")continue;var a=nod.children("a."+this.settings.languages[i]);obj+='0)obj+=' '+inner_attrib[j]+'="'+val+'" ';delete val}}}obj+='>'}}else{var a=nod.children("a");obj+='0)obj+=' '+inner_attrib[j]+'="'+val+'" ';delete val}}}obj+='>'}obj+='';if(tp=="flat")obj+='';if(nod.children("ul").size()>0){nod.children("ul").children("li").each(function(){obj+=_this.getXML(tp,this,outer_attrib,inner_attrib,true)})}if(tp=="nested")obj+='';if(!cb)obj+='';return obj},focus:function(){if(this.locked)return false;if(tree_component.focused!=this.cntr){tree_component.focused=this.cntr;this.settings.callback.onfocus.call(null,this)}},show_context:function(obj){this.context.show();var tmp=$(obj).children("a:visible").offset();this.context.css({"left":(tmp.left),"top":(tmp.top+parseInt(obj.children("a:visible").height())+2)})},hide_context:function(){if(this.context.to_remove&&this.context.apply_to)this.context.apply_to.children("a").removeClass("clicked");this.context.apply_to=false;this.context.hide()},attachEvents:function(){var _this=this;this.container.bind("mousedown.jstree",function(event){if(tree_component.drag_drop.isdown){tree_component.drag_drop.move_type=false;event.preventDefault();event.stopPropagation();event.stopImmediatePropagation();return false}}).bind("mouseup.jstree",function(event){setTimeout(function(){_this.focus.apply(_this)},5)}).bind("click.jstree",function(event){return true});$("#"+this.container.attr("id")+" li").live("click",function(event){if(event.target.tagName!="LI")return true;_this.off_height();if(event.pageY-$(event.target).offset().top>_this.li_height)return true;_this.toggle_branch.apply(_this,[event.target]);event.stopPropagation();return false});$("#"+this.container.attr("id")+" li a").live("click.jstree",function(event){if(event.which&&event.which==3)return true;if(_this.locked){event.preventDefault();event.target.blur();return _this.error("LOCKED")}_this.select_branch.apply(_this,[event.target,event.ctrlKey||_this.settings.rules.multiple=="on"]);if(_this.inp){_this.inp.blur()}event.preventDefault();event.target.blur();return false}).live("dblclick.jstree",function(event){if(_this.locked){event.preventDefault();event.stopPropagation();event.target.blur();return _this.error("LOCKED")}_this.settings.callback.ondblclk.call(null,_this.get_node(event.target).get(0),_this);event.preventDefault();event.stopPropagation();event.target.blur()}).live("contextmenu.jstree",function(event){if(_this.locked){event.target.blur();return _this.error("LOCKED")}var val=_this.settings.callback.onrgtclk.call(null,_this.get_node(event.target).get(0),_this,event);if(_this.context){if(_this.context.append==false){$("body").append(_this.context);_this.context.append=true;for(var i in _this.settings.ui.context){if(typeof _this.settings.ui.context[i]=="function")continue;if(_this.settings.ui.context[i]=="separator")continue;(function(){var func=_this.settings.ui.context[i].action;_this.context.children("[rel="+_this.settings.ui.context[i].id+"]").bind("click",function(event){if(!$(this).hasClass("disabled")){func.call(null,_this.context.apply_to||null,_this);_this.hide_context()}event.stopPropagation();event.preventDefault();return false}).bind("mouseup",function(event){this.blur();if($(this).hasClass("disabled")){event.stopPropagation();event.preventDefault();return false}}).bind("mousedown",function(event){event.stopPropagation();event.preventDefault()})})()}}var obj=_this.get_node(event.target);if(_this.inp){_this.inp.blur()}if(obj){if(!obj.children("a:eq(0)").hasClass("clicked")){_this.context.apply_to=obj;_this.context.to_remove=true;_this.context.apply_to.children("a").addClass("clicked");event.target.blur()}else{_this.context.to_remove=false;_this.context.apply_to=(_this.selected_arr&&_this.selected_arr.length>1)?_this.selected_arr:_this.selected}_this.context.children("a").removeClass("disabled").show();var go=false;for(var i in _this.settings.ui.context){if(typeof _this.settings.ui.context[i]=="function")continue;if(_this.settings.ui.context[i]=="separator")continue;var state=_this.settings.ui.context[i].visible.call(null,_this.context.apply_to,_this);if(state===false)_this.context.children("[rel="+_this.settings.ui.context[i].id+"]").addClass("disabled");if(state===-1)_this.context.children("[rel="+_this.settings.ui.context[i].id+"]").hide();else go=true}if(go==true)_this.show_context(obj);event.preventDefault();event.stopPropagation();return false}}return val}).live("mouseover.jstree",function(event){if(_this.locked){event.preventDefault();event.stopPropagation();return _this.error("LOCKED")}if((_this.settings.ui.hover_mode||_this.settings.ui.theme_name=="themeroller")&&_this.hovered!==false&&event.target.tagName=="A"){_this.hovered.children("a").removeClass("hover ui-state-hover");_this.hovered=false}if(_this.settings.ui.theme_name=="themeroller"){_this.hover_branch.apply(_this,[event.target])}});if(_this.settings.ui.theme_name=="themeroller"){$("#"+this.container.attr("id")+" li a").live("mouseout",function(event){if(_this.hovered)_this.hovered.children("a").removeClass("hover ui-state-hover")})}if(this.settings.rules.draggable!="none"){$("#"+this.container.attr("id")+" li a").live("mousedown.jstree",function(event){if(_this.settings.rules.drag_button=="left"&&event.which&&event.which!=1)return true;if(_this.settings.rules.drag_button=="right"&&event.which&&event.which!=3)return true;_this.focus.apply(_this);if(_this.locked)return _this.error("LOCKED");var obj=_this.get_node(event.target);if(_this.settings.rules.multiple!=false&&_this.selected_arr.length>1&&obj.children("a:eq(0)").hasClass("clicked")){var counter=0;for(var i in _this.selected_arr){if(typeof _this.selected_arr[i]=="function")continue;if(_this.check("draggable",_this.selected_arr[i])){_this.selected_arr[i].addClass("dragged");tree_component.drag_drop.origin_tree=_this;counter++}}if(counter>0){if(_this.check("draggable",obj))tree_component.drag_drop.drag_node=obj;else tree_component.drag_drop.drag_node=_this.container.find("li.dragged:eq(0)");tree_component.drag_drop.isdown=true;tree_component.drag_drop.drag_help=$("
        ").append("
          ");var tmp=$(tree_component.drag_drop.drag_node.get(0).cloneNode(true));if(_this.settings.languages.length>0)tmp.find("a").not("."+_this.current_lang).hide();tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last").children("a").html("Multiple selection").end().children("ul").remove()}}else{if(_this.check("draggable",obj)){tree_component.drag_drop.drag_node=obj;tree_component.drag_drop.drag_help=$("
          ").append("
            ");var tmp=$(obj.get(0).cloneNode(true));if(_this.settings.languages.length>0)tmp.find("a").not("."+_this.current_lang).hide();tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last");tree_component.drag_drop.isdown=true;tree_component.drag_drop.foreign=false;tree_component.drag_drop.origin_tree=_this;obj.addClass("dragged")}}tree_component.drag_drop.init_x=event.pageX;tree_component.drag_drop.init_y=event.pageY;obj.blur();event.preventDefault();event.stopPropagation();return false});$(document).bind("mousedown.jstree",tree_component.mousedown).bind("mouseup.jstree",tree_component.mouseup).bind("mousemove.jstree",tree_component.mousemove)}if(_this.context)$(document).bind("mousedown",function(){_this.hide_context()})},checkMove:function(NODES,REF_NODE,TYPE){if(this.locked)return this.error("LOCKED");var _this=this;if(REF_NODE.parents("li.dragged").size()>0||REF_NODE.is(".dragged"))return this.error("MOVE: NODE OVER SELF");if(NODES.size()==1){var NODE=NODES.eq(0);if(tree_component.drag_drop.foreign){if(this.settings.rules.droppable.length==0)return false;if(!NODE.is("."+this.settings.rules.droppable.join(", .")))return false;var ok=false;for(var i in this.settings.rules.droppable){if(typeof this.settings.rules.droppable[i]=="function")continue;if(NODE.is("."+this.settings.rules.droppable[i])){if(this.settings.rules.metadata){$.metadata.setType("attr",this.settings.rules.metadata);NODE.attr(this.settings.rules.metadata,"type: '"+this.settings.rules.droppable[i]+"'")}else{NODE.attr(this.settings.rules.type_attr,this.settings.rules.droppable[i])}ok=true;break}}if(!ok)return false}if(!this.check("dragrules",[NODE,TYPE,REF_NODE.parents("li:eq(0)")]))return this.error("MOVE: AGAINST DRAG RULES")}else{var ok=true;NODES.each(function(i){if(ok==false)return false;var ref=REF_NODE;var mv=TYPE;if(!_this.check.apply(_this,["dragrules",[$(this),mv,ref]]))ok=false});if(ok==false)return this.error("MOVE: AGAINST DRAG RULES")}if(this.settings.rules.use_inline&&this.settings.rules.metadata){var nd=false;if(TYPE=="inside")nd=REF_NODE.parents("li:eq(0)");else nd=REF_NODE.parents("li:eq(1)");if(nd.size()){if(typeof nd.metadata()["valid_children"]!="undefined"){var tmp=nd.metadata()["valid_children"];var ok=true;NODES.each(function(i){if(ok==false)return false;if($.inArray(_this.get_type(this),tmp)==-1)ok=false});if(ok==false)return this.error("MOVE: NOT A VALID CHILD")}if(typeof nd.metadata()["max_children"]!="undefined"){if((nd.children("ul:eq(0)").children("li").not(".dragged").size()+NODES.size())>nd.metadata().max_children)return this.error("MOVE: MAX CHILDREN REACHED")}var incr=0;NODES.each(function(j){var i=1;var t=$(this);while(i<100){t=t.children("ul").children("li");if(t.size()==0)break;i++}incr=Math.max(i,incr)});var ok=true;if((typeof $(nd).metadata().max_depth).toLowerCase()!="undefined"&&$(nd).metadata().max_depth=$(this).metadata().max_depth)ok=false}})}if(ok==false)return this.error("MOVE: MAX_DEPTH REACHED")}}return true},reselect:function(is_callback){var _this=this;if(!is_callback)this.cl_count=0;else this.cl_count--;if(this.opened&&this.opened.length){var opn=false;for(var j=0;this.opened&&j0){opn=true;var tmp=this.opened[j];delete this.opened[j];this.open_branch(tmp,true,function(){_this.reselect.apply(_this,[true])});this.cl_count++}}else this.open_branch(this.opened[j],true)}if(this.settings.data.async&&opn)return;delete this.opened}if(this.cl_count>0)return;if(this.settings.ui.rtl)this.container.css("direction","rtl").children("ul:eq(0)").addClass("rtl");else this.container.css("direction","ltr").children("ul:eq(0)").addClass("ltr");if(this.settings.ui.dots==false)this.container.children("ul:eq(0)").addClass("no_dots");if(this.scrtop){this.container.scrollTop(_this.scrtop);delete this.scrtop}if(this.settings.selected!==false){$.each(this.settings.selected,function(i){if(_this.is_partial_refresh)_this.select_branch($(_this.settings.selected[i],_this.container),(_this.settings.rules.multiple!==false));else _this.select_branch($(_this.settings.selected[i],_this.container),(_this.settings.rules.multiple!==false&&i>0))});this.settings.selected=false}if(this.settings.ui.theme_name=="themeroller")this.container.find("a").addClass("ui-state-default");this.settings.callback.onload.call(null,_this)},get_node:function(obj){var obj=$(obj);return obj.is("li")?obj:obj.parents("li:eq(0)")},get_type:function(obj){obj=!obj?this.selected:this.get_node(obj);if(!obj)return;if(this.settings.rules.metadata){$.metadata.setType("attr",this.settings.rules.metadata);var tmp=obj.metadata().type;if(tmp)return tmp}return obj.attr(this.settings.rules.type_attr)},scrollCheck:function(x,y){var _this=this;var cnt=_this.container;var off=_this.container.offset();var st=cnt.scrollTop();var sl=cnt.scrollLeft();var h_cor=(cnt.get(0).scrollWidth>cnt.width())?40:20;if(y-off.top<20)cnt.scrollTop(Math.max((st-_this.settings.ui.scroll_spd),0));if(cnt.height()-(y-off.top)this.container.width())?40:20;if(off_t+5end_t)this.container.scrollTop(this.container.scrollTop()+(off_t+h_cor-end_t))},select_branch:function(obj,multiple){if(this.locked)return this.error("LOCKED");if(!obj&&this.hovered!==false)obj=this.hovered;var _this=this;obj=_this.get_node(obj);if(!obj.size())return this.error("SELECT: NOT A VALID NODE");obj.children("a").removeClass("hover ui-state-hover");if(!_this.check("clickable",obj))return this.error("SELECT: NODE NOT SELECTABLE");if(_this.settings.callback.beforechange.call(null,obj.get(0),_this)===false)return this.error("SELECT: STOPPED BY USER");if(this.settings.rules.multiple!=false&&multiple&&obj.children("a.clicked").size()>0){return this.deselect_branch(obj)}if(this.settings.rules.multiple!=false&&multiple){this.selected_arr.push(obj)}if(this.settings.rules.multiple!=false&&!multiple){for(var i in this.selected_arr){if(typeof this.selected_arr[i]=="function")continue;this.selected_arr[i].children("A").removeClass("clicked ui-state-active");this.settings.callback.ondeselect.call(null,this.selected_arr[i].get(0),_this)}this.selected_arr=[];this.selected_arr.push(obj);if(this.selected&&this.selected.children("A").hasClass("clicked")){this.selected.children("A").removeClass("clicked ui-state-active");this.settings.callback.ondeselect.call(null,this.selected.get(0),_this)}}if(!this.settings.rules.multiple){if(this.selected){this.selected.children("A").removeClass("clicked ui-state-active");this.settings.callback.ondeselect.call(null,this.selected.get(0),_this)}}this.selected=obj;if((this.settings.ui.hover_mode||this.settings.ui.theme_name=="themeroller")&&this.hovered!==false){this.hovered.children("A").removeClass("hover ui-state-hover");this.hovered=obj}this.selected.children("a").removeClass("clicked ui-state-active").addClass(this.settings.ui.theme_name=="themeroller"?"clicked ui-state-active":"clicked").end().parents("li.closed").each(function(){_this.open_branch(this,true)});var off_t=this.selected.offset().top;var beg_t=this.container.offset().top;var end_t=beg_t+this.container.height();var h_cor=(this.container.get(0).scrollWidth>this.container.width())?40:20;if(off_t+5end_t)this.container.scrollTop(this.container.scrollTop()+(off_t+h_cor-end_t));this.set_cookie("selected");this.settings.callback.onselect.call(null,this.selected.get(0),_this);this.settings.callback.onchange.call(null,this.selected.get(0),_this)},deselect_branch:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);obj.children("a").removeClass("clicked ui-state-active");this.settings.callback.ondeselect.call(null,obj.get(0),_this);if(this.settings.rules.multiple!=false&&this.selected_arr.length>1){this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))});if(obj.get(0)==this.selected.get(0)){this.selected=this.selected_arr[0];this.set_cookie("selected")}}else{if(this.settings.rules.multiple!=false)this.selected_arr=[];this.selected=false;this.set_cookie("selected")}if(this.selected)this.settings.callback.onchange.call(null,this.selected.get(0),_this);else this.settings.callback.onchange.call(null,false,_this)},toggle_branch:function(obj){if(this.locked)return this.error("LOCKED");var obj=this.get_node(obj);if(obj.hasClass("closed"))return this.open_branch(obj);if(obj.hasClass("open"))return this.close_branch(obj)},open_branch:function(obj,disable_animation,callback){if(this.locked)return this.error("LOCKED");var obj=this.get_node(obj);if(!obj.size())return this.error("OPEN: NO SUCH NODE");if(obj.hasClass("leaf"))return this.error("OPEN: OPENING LEAF NODE");if(this.settings.data.async&&obj.find("li").size()==0){if(this.settings.callback.beforeopen.call(null,obj.get(0),this)===false)return this.error("OPEN: STOPPED BY USER");var _this=this;obj.children("ul:eq(0)").remove().end().append("");obj.removeClass("closed").addClass("open");if(this.settings.data.type=="xml_flat"||this.settings.data.type=="xml_nested"){var xsl=(this.settings.data.type=="xml_flat")?"flat.xsl":"nested.xsl";obj.children("ul:eq(0)").getTransform(this.path+xsl,this.settings.data.url,{params:{theme_path:_this.theme},meth:this.settings.data.method,dat:this.settings.data.async_data(obj,this),repl:true,callback:function(str,json){if(str.length<15){obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();if(callback)callback.call();return}_this.open_branch.apply(_this,[obj]);if(callback)callback.call()},error:function(){obj.removeClass("open").addClass("closed").children("ul:eq(0)").remove()}})}else{$.ajax({type:this.settings.data.method,url:this.settings.data.url,data:this.settings.data.async_data(obj,this),dataType:"json",success:function(data,textStatus){data=_this.settings.callback.onJSONdata.call(null,data,_this);if(!data||data.length==0){obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();if(callback)callback.call();return}var str="";if(data.length){for(var i=0;i0){obj.children("ul:eq(0)").replaceWith("
              "+str+"
            ");obj.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");obj.find("li").not(".open").not(".closed").addClass("leaf");_this.open_branch.apply(_this,[obj])}else obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();if(callback)callback.call()},error:function(xhttp,textStatus,errorThrown){obj.removeClass("open").addClass("closed").children("ul:eq(0)").remove();_this.error(errorThrown+" "+textStatus)}})}return true}else{if(!this.settings.data.async){if(this.settings.callback.beforeopen.call(null,obj.get(0),this)===false)return this.error("OPEN: STOPPED BY USER")}if(this.settings.ui.theme_name=="themeroller")obj.find("a").not(".ui-state-default").addClass("ui-state-default");if(parseInt(this.settings.ui.animation)>0&&!disable_animation){obj.children("ul:eq(0)").css("display","none");obj.removeClass("closed").addClass("open");obj.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation),function(){$(this).css("display","");if(callback)callback.call()})}else{obj.removeClass("closed").addClass("open");if(callback)callback.call()}this.set_cookie("open");this.settings.callback.onopen.call(null,obj.get(0),this);return true}},close_branch:function(obj,disable_animation){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);if(!obj.size())return this.error("CLOSE: NO SUCH NODE");if(_this.settings.callback.beforeclose.call(null,obj.get(0),_this)===false)return this.error("CLOSE: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!disable_animation&&obj.children("ul:eq(0)").size()==1){obj.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation),function(){if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");_this.set_cookie("open");$(this).css("display","")})}else{if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");this.set_cookie("open")}if(this.selected&&obj.children("ul:eq(0)").find("a.clicked").size()>0){obj.find("li:has(a.clicked)").each(function(){_this.deselect_branch(this)});if(obj.children("a.clicked").size()==0)this.select_branch(obj,(this.settings.rules.multiple!=false&&this.selected_arr.length>0))}this.settings.callback.onclose.call(null,obj.get(0),this)},open_all:function(obj,callback){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj).parent():this.container;var s=obj.find("li.closed").size();if(!callback)this.cl_count=0;else this.cl_count--;if(s>0){this.cl_count+=s;obj.find("li.closed").each(function(){var __this=this;_this.open_branch.apply(_this,[this,true,function(){_this.open_all.apply(_this,[__this,true])}])})}else if(this.cl_count==0)this.settings.callback.onopen_all.call(null,this)},close_all:function(){if(this.locked)return this.error("LOCKED");var _this=this;this.container.find("li.open").each(function(){_this.close_branch(this,true)})},show_lang:function(i){if(this.locked)return this.error("LOCKED");if(this.settings.languages[i]==this.current_lang)return true;var st=false;var id=this.container.attr("id")?"#"+this.container.attr("id"):".tree";st=get_css(id+" ."+this.current_lang,this.sn);if(st!==false)st.style.display="none";st=get_css(id+" ."+this.settings.languages[i],this.sn);if(st!==false)st.style.display="";this.current_lang=this.settings.languages[i];return true},cycle_lang:function(){if(this.locked)return this.error("LOCKED");var i=$.inArray(this.current_lang,this.settings.languages);i++;if(i>this.settings.languages.length-1)i=0;this.show_lang(i)},create:function(obj,ref_node,position){if(this.locked)return this.error("LOCKED");var root=false;if(ref_node==-1){root=true;ref_node=this.container}else ref_node=ref_node?this.get_node(ref_node):this.selected;if(!root&&(!ref_node||!ref_node.size()))return this.error("CREATE: NO NODE SELECTED");var pos=position;var tmp=ref_node;if(position=="before"){position=ref_node.parent().children().index(ref_node);ref_node=ref_node.parents("li:eq(0)")}if(position=="after"){position=ref_node.parent().children().index(ref_node)+1;ref_node=ref_node.parents("li:eq(0)")}if(!root&&ref_node.size()==0){root=true;ref_node=this.container}if(!root){if(!this.check("creatable",ref_node))return this.error("CREATE: CANNOT CREATE IN NODE");if(ref_node.hasClass("closed")){if(this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this.open_branch(ref_node,true,function(){_this.create.apply(_this,[obj,ref_node,position])})}else this.open_branch(ref_node,true)}}var torename=false;if(!obj)obj={};else obj=$.extend(true,{},obj);if(!obj.attributes)obj.attributes={};if(this.settings.rules.metadata){if(!obj.attributes[this.settings.rules.metadata])obj.attributes[this.settings.rules.metadata]='{ "type" : "'+(this.get_type(tmp)||"")+'" }'}else{if(!obj.attributes[this.settings.rules.type_attr])obj.attributes[this.settings.rules.type_attr]=this.get_type(tmp)||""}if(this.settings.languages.length){if(!obj.data){obj.data={};torename=true}for(var i=0;iref_node.metadata().max_children)return this.error("CREATE: MAX_CHILDREN REACHED")}var ok=true;if((typeof $(ref_node).metadata().max_depth).toLowerCase()!="undefined"&&$(ref_node).metadata().max_depth===0)ok=false;else{ref_node.parents("li").each(function(i){if($(this).metadata().max_depth){if((i+1)>=$(this).metadata().max_depth){ok=false;return false}}})}if(!ok)return this.error("CREATE: MAX_DEPTH REACHED")}if((typeof position).toLowerCase()=="undefined"||position=="inside")position=(this.settings.rules.createat=="top")?0:ref_node.children("ul:eq(0)").children("li").size();if(ref_node.children("ul").size()==0||(root==true&&ref_node.children("ul").children("li").size()==0)){if(!root)var a=this.moved($li,ref_node.children("a:eq(0)"),"inside",true);else var a=this.moved($li,this.container.children("ul:eq(0)"),"inside",true)}else if(pos=="before"&&ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else if(pos=="after"&&ref_node.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after",true);else if(ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true);if(a===false)return this.error("CREATE: ABORTED");if(torename){this.select_branch($li.children("a:eq(0)"));this.rename()}return $li},rename:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.selected;var _this=this;if(!obj||!obj.size())return this.error("RENAME: NO NODE SELECTED");if(!this.check("renameable",obj))return this.error("RENAME: NODE NOT RENAMABLE");if(!this.settings.callback.beforerename.call(null,obj.get(0),_this.current_lang,_this))return this.error("RENAME: STOPPED BY USER");obj.parents("li.closed").each(function(){_this.open_branch(this)});if(this.current_lang)obj=obj.find("a."+this.current_lang).get(0);else obj=obj.find("a:first").get(0);last_value=obj.innerHTML;_this.inp=$("");_this.inp.val(last_value.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")).bind("mousedown",function(event){event.stopPropagation()}).bind("mouseup",function(event){event.stopPropagation()}).bind("click",function(event){event.stopPropagation()}).bind("keyup",function(event){var key=event.keyCode||event.which;if(key==27){this.value=last_value;this.blur();return}if(key==13){this.blur();return}});var rb={};rb[this.container.attr("id")]=this.get_rollback();_this.inp.blur(function(event){if(this.value=="")this.value=last_value;$(obj).text($(obj).parent().find("input").eq(0).attr("value")).get(0).style.display="";$(obj).prevAll("span").remove();_this.settings.callback.onrename.call(null,_this.get_node(obj).get(0),_this.current_lang,_this,rb);_this.inp=false});var spn=$("").addClass(obj.className).append(_this.inp);spn.attr("style",$(obj).attr("style"));obj.style.display="none";$(obj).parent().prepend(spn);_this.inp.get(0).focus();_this.inp.get(0).select()},remove:function(obj){if(this.locked)return this.error("LOCKED");var rb={};rb[this.container.attr("id")]=this.get_rollback();if(obj&&(!this.selected||this.get_node(obj).get(0)!=this.selected.get(0))){obj=this.get_node(obj);if(obj.size()){if(!this.check("deletable",obj))return this.error("DELETE: NODE NOT DELETABLE");if(!this.settings.callback.beforedelete.call(null,obj.get(0),_this))return this.error("DELETE: STOPPED BY USER");$parent=obj.parent();obj=obj.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove();this.set_cookie("open")}this.settings.callback.ondelete.call(null,obj.get(0),this,rb)}}else if(this.selected){if(!this.check("deletable",this.selected))return this.error("DELETE: NODE NOT DELETABLE");if(!this.settings.callback.beforedelete.call(null,this.selected.get(0),_this))return this.error("DELETE: STOPPED BY USER");$parent=this.selected.parent();var obj=this.selected;if(this.settings.rules.multiple==false||this.selected_arr.length==1){var stop=true;var tmp=(this.selected.prev("li:eq(0)").size())?this.selected.prev("li:eq(0)"):this.selected.parents("li:eq(0)")}obj=obj.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove();this.set_cookie("open")}this.settings.callback.ondelete.call(null,obj.get(0),this,rb);if(stop&&tmp)this.select_branch(tmp);if(this.settings.rules.multiple!=false&&!stop){var _this=this;this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))});if(this.selected_arr.length>0){this.selected=this.selected_arr[0];this.remove()}}}else return this.error("DELETE: NO NODE SELECTED")},next:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.nextAll("li").size()>0)?obj.nextAll("li:eq(0)"):false;if(obj.hasClass("open"))return obj.find("li:eq(0)");else if(obj.nextAll("li").size()>0)return obj.nextAll("li:eq(0)");else return obj.parents("li").next("li").eq(0)},prev:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.prevAll("li").size()>0)?obj.prevAll("li:eq(0)"):false;if(obj.prev("li").size()){var obj=obj.prev("li").eq(0);while(obj.hasClass("open"))obj=obj.children("ul:eq(0)").children("li:last");return obj}else return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):false},parent:function(obj){obj=this.get_node(obj);if(!obj.size())return false;return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):false},children:function(obj){obj=this.get_node(obj);if(!obj.size())return false;return obj.children("ul:eq(0)").children("li")},get_next:function(force){var obj=this.hovered||this.selected;return force?this.select_branch(this.next(obj)):this.hover_branch(this.next(obj))},get_prev:function(force){var obj=this.hovered||this.selected;return force?this.select_branch(this.prev(obj)):this.hover_branch(this.prev(obj))},get_left:function(force,rtl){if(this.settings.ui.rtl&&!rtl)return this.get_right(force,true);var obj=this.hovered||this.selected;if(obj){if(obj.hasClass("open"))this.close_branch(obj);else{return force?this.select_branch(this.parent(obj)):this.hover_branch(this.parent(obj))}}},get_right:function(force,rtl){if(this.settings.ui.rtl&&!rtl)return this.get_left(force,true);var obj=this.hovered||this.selected;if(obj){if(obj.hasClass("closed"))this.open_branch(obj);else{return force?this.select_branch(obj.find("li:eq(0)")):this.hover_branch(obj.find("li:eq(0)"))}}},toggleDots:function(){if(this.settings.ui.dots){this.settings.ui.dots=false;this.container.children("ul:eq(0)").addClass("no_dots")}else{this.settings.ui.dots=true;this.container.children("ul:eq(0)").removeClass("no_dots")}},toggleRTL:function(){if(this.settings.ui.rtl){this.settings.ui.rtl=false;this.container.css("direction","ltr").children("ul:eq(0)").removeClass("rtl").addClass("ltr")}else{this.settings.ui.rtl=true;this.container.css("direction","rtl").children("ul:eq(0)").removeClass("ltr").addClass("rtl")}},set_cookie:function(type){if(this.settings.cookies===false)return false;if(this.settings.cookies[type]===false)return false;switch(type){case"selected":if(this.settings.rules.multiple!=false&&this.selected_arr.length>1){var val=Array();$.each(this.selected_arr,function(){if(this.attr("id")){val.push(this.attr("id"))}});val=val.join(",")}else var val=this.selected?this.selected.attr("id"):false;$.cookie(this.settings.cookies.prefix+'_selected',val,this.settings.cookies.opts);break;case"open":var str="";this.container.find("li.open").each(function(i){if(this.id){str+=this.id+","}});$.cookie(this.settings.cookies.prefix+'_open',str.replace(/,$/ig,""),this.settings.cookies.opts);break}},get_rollback:function(){var rb={};if(this.context.to_remove&&this.context.apply_to)this.context.apply_to.children("a").removeClass("clicked");rb.html=this.container.html();if(this.context.to_remove&&this.context.apply_to)this.context.apply_to.children("a").addClass("clicked");rb.selected=this.selected?this.selected.attr("id"):false;return rb},moved:function(what,where,how,is_new,is_copy,rb){var what=$(what);var $parent=$(what).parents("ul:eq(0)");var $where=$(where);if(!rb){var rb={};rb[this.container.attr("id")]=this.get_rollback();if(!is_new){var tmp=what.size()>1?what.eq(0).parents(".tree:eq(0)"):what.parents(".tree:eq(0)");if(tmp.get(0)!=this.container.get(0)){tmp=tree_component.inst[tmp.attr("id")];rb[tmp.container.attr("id")]=tmp.get_rollback()}delete tmp}}if(how=="inside"&&this.settings.data.async&&this.get_node($where).hasClass("closed")){var _this=this;return this.open_branch(this.get_node($where),true,function(){_this.moved.apply(_this,[what,where,how,is_new,is_copy,rb])})}if(what.size()>1){var _this=this;var tmp=this.moved(what.eq(0),where,how,false,is_copy,rb);what.each(function(i){if(i==0)return;if(tmp){tmp=_this.moved(this,tmp.children("a:eq(0)"),"after",false,is_copy,rb)}});return}if(is_copy){_what=what.clone();_what.each(function(i){this.id=this.id+"_copy";$(this).find("li").each(function(){this.id=this.id+"_copy"});$(this).removeClass("dragged").find("a.clicked").removeClass("clicked ui-state-active").end().find("li.dragged").removeClass("dragged")})}else _what=what;if(is_new){if(!this.settings.callback.beforecreate.call(null,this.get_node(what).get(0),this.get_node(where).get(0),how,this))return false}else{if(!this.settings.callback.beforemove.call(null,this.get_node(what).get(0),this.get_node(where).get(0),how,this))return false}if(!is_new){var tmp=what.parents(".tree:eq(0)");if(tmp.get(0)!=this.container.get(0)){tmp=tree_component.inst[tmp.attr("id")];if(tmp.settings.languages.length){var res=[];if(this.settings.languages.length==0)res.push("."+tmp.current_lang);else{for(var i in this.settings.languages){if(typeof this.settings.languages[i]=="function")continue;for(var j in tmp.settings.languages){if(typeof tmp.settings.languages[j]=="function")continue;if(this.settings.languages[i]==tmp.settings.languages[j])res.push("."+this.settings.languages[i])}}}if(res.length==0)return this.error("MOVE: NO COMMON LANGUAGES");what.find("a").not(res.join(",")).remove()}what.find("a.clicked").removeClass("clicked ui-state-active")}}what=_what;switch(how){case"before":$where.parents("ul:eq(0)").children("li.last").removeClass("last");$where.parent().before(what.removeClass("last"));$where.parents("ul:eq(0)").children("li:last").addClass("last");break;case"after":$where.parents("ul:eq(0)").children("li.last").removeClass("last");$where.parent().after(what.removeClass("last"));$where.parents("ul:eq(0)").children("li:last").addClass("last");break;case"inside":if($where.parent().children("ul:first").size()){if(this.settings.rules.createat=="top")$where.parent().children("ul:first").prepend(what.removeClass("last")).children("li:last").addClass("last");else $where.parent().children("ul:first").children(".last").removeClass("last").end().append(what.removeClass("last")).children("li:last").addClass("last")}else{what.addClass("last");$where.parent().append("
              ").removeClass("leaf").addClass("closed");$where.parent().children("ul:first").prepend(what)}if($where.parent().hasClass("closed")){this.open_branch($where)}break;default:break}if($parent.find("li").size()==0){var $li=$parent.parent();$li.removeClass("open").removeClass("closed").addClass("leaf");if(!$li.is(".tree"))$li.children("ul").remove();$li.parents("ul:eq(0)").children("li.last").removeClass("last").end().children("li:last").addClass("last");this.set_cookie("open")}else{$parent.children("li.last").removeClass("last");$parent.children("li:last").addClass("last")}if(is_copy)this.settings.callback.oncopy.call(null,this.get_node(what).get(0),this.get_node(where).get(0),how,this,rb);else if(is_new)this.settings.callback.oncreate.call(null,this.get_node(what).get(0),($where.is("ul")?-1:this.get_node(where).get(0)),how,this,rb);else this.settings.callback.onmove.call(null,this.get_node(what).get(0),this.get_node(where).get(0),how,this,rb);return what},error:function(code){this.settings.callback.error.call(null,code,this);return false},lock:function(state){this.locked=state;if(this.locked)this.container.children("ul:eq(0)").addClass("locked");else this.container.children("ul:eq(0)").removeClass("locked")},cut:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("CUT: NO NODE SELECTED");this.copy_nodes=false;this.cut_nodes=obj},copy:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("COPY: NO NODE SELECTED");this.copy_nodes=obj;this.cut_nodes=false},paste:function(obj,position){if(this.locked)return this.error("LOCKED");var root=false;if(obj==-1){root=true;obj=this.container}else obj=obj?this.get_node(obj):this.selected;if(!root&&(!obj||!obj.size()))return this.error("PASTE: NO NODE SELECTED");if(!this.copy_nodes&&!this.cut_nodes)return this.error("PASTE: NOTHING TO DO");var _this=this;var pos=position;if(position=="before"){position=obj.parent().children().index(obj);obj=obj.parents("li:eq(0)")}else if(position=="after"){position=obj.parent().children().index(obj)+1;obj=obj.parents("li:eq(0)")}else if((typeof position).toLowerCase()=="undefined"||position=="inside"){position=(this.settings.rules.createat=="top")?0:obj.children("ul:eq(0)").children("li").size()}if(!root&&obj.size()==0){root=true;obj=this.container}if(this.copy_nodes&&this.copy_nodes.size()){var ok=true;if(!ok)return this.error("Invalid paste");if(!root&&!this.checkMove(this.copy_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(this.copy_nodes,obj.children("a:eq(0)"),"inside",false,true);else var a=this.moved(this.copy_nodes,this.container.children("ul:eq(0)"),"inside",false,true)}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",false,true);else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after",false,true);else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",false,true);else var a=this.moved(this.copy_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",false,true);this.copy_nodes=false}if(this.cut_nodes&&this.cut_nodes.size()){var ok=true;obj.parents().andSelf().each(function(){if(_this.cut_nodes.index(this)!=-1){ok=false;return false}});if(!ok)return this.error("Invalid paste");if(!root&&!this.checkMove(this.cut_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(this.cut_nodes,obj.children("a:eq(0)"),"inside");else var a=this.moved(this.cut_nodes,this.container.children("ul:eq(0)"),"inside")}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after");else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else var a=this.moved(this.cut_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after");this.cut_nodes=false}},search:function(str){var _this=this;if(!str||(this.srch&&str!=this.srch)){this.srch="";this.srch_opn=false;this.container.find("a.search").removeClass("search ui-state-highlight")}this.srch=str;if(!str)return;if(this.settings.data.async){if(!this.srch_opn){var dd=$.extend({"search":str},this.settings.data.async_data(false,this));$.ajax({type:this.settings.data.method,url:this.settings.data.url,data:dd,dataType:"text",success:function(data){_this.srch_opn=$.unique(data.split(","));_this.search.apply(_this,[str])}})}else if(this.srch_opn.length){if(this.srch_opn&&this.srch_opn.length){var opn=false;for(var j=0;j0){opn=true;var tmp="#"+this.srch_opn[j];delete this.srch_opn[j];this.open_branch(tmp,true,function(){_this.search.apply(_this,[str])})}}if(!opn){this.srch_opn=[];_this.search.apply(_this,[str])}}}else{var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;this.container.find(selector+":contains('"+str+"')").addClass(this.settings.ui.theme_name=="themeroller"?"search ui-state-highlight":"search");this.srch_opn=false}}else{var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;this.container.find(selector+":contains('"+str+"')").addClass(this.settings.ui.theme_name=="themeroller"?"search ui-state-highlight":"search").parents("li.closed").each(function(){_this.open_branch(this,true)})}},destroy:function(){this.hide_context();this.container.unbind(".jstree");$("#"+this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("contextmenu.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree");this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-"+this.settings.ui.theme_name).children("ul").removeClass("no_dots rtl ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search ui-state-active ui-state-hover ui-state-highlight ui-state-default");if(this.cntr==tree_component.focused){for(var i in tree_component.inst){if(i!=this.cntr&&i!=this.container.attr("id")){tree_component.inst[i].focus();break}}}tree_component.inst[this.cntr]=false;tree_component.inst[this.container.attr("id")]=false;delete tree_component.inst[this.cntr];delete tree_component.inst[this.container.attr("id")];tree_component.cntr--}}}})(jQuery); diff --git a/umbraco/presentation/umbraco_client/modal/modal.js b/umbraco/presentation/umbraco_client/modal/modal.js index c4f2650b6d..05ce597712 100644 --- a/umbraco/presentation/umbraco_client/modal/modal.js +++ b/umbraco/presentation/umbraco_client/modal/modal.js @@ -1,66 +1,176 @@ -// HELPERS -function openModal(url, name, height, width) { - var dialog = jQuery('#umbModalBox').jqm({ - onShow: function(h) { - var umbModal = jQuery(h.w); - var umbModalContent = jQuery("iframe", umbModal); +/// - umbModalContent.width(width); - umbModalContent.height(height - 30); +Umbraco.Sys.registerNamespace("Umbraco.Controls"); - jQuery("#umbModalBoxHeader").html(name); +(function($) { - if (height > 0) umbModal.height(height); + $.fn.ModalWindowAPI = function() { + /// jQuery plugin exposes the modal window api for the selected object + //if there's more than item in the selector, throw exception + if ($(this).length != 1) { + throw "ModalWindowAPI selector requires that there be exactly one control selected"; + }; + return $(this).data("ModalWindowAPI") == null ? null : $(this).data("ModalWindowAPI"); + }; - if (width > 0) { - umbModal.width(width); - umbModal.css("left", ((jQuery(document).width() - width) / 2) + "px"); - } + 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 + open: function(url, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) { + /// Opens a modal window + /// Optional + /// Optional + /// + /// Optional: An array of jQuery selectors that will trigger the modal window to close + /// + /// + /// A method that is called when the window is closing. the callback method will receive an instance + /// of the jQuery object for the popup window/iframe so that you can query against the contents of the window + /// to extract any information. + /// The callback will receive one parameter with 2 properties: + /// modalContent = the jQuery object for the popup window to query against + /// 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 - umbModalContent.html('').attr('src', createUniqueUrl(url)); - - h.w.show(); - umbModalContent.show(); - - jQuery(document).keyup(function(event) { - if (event.keyCode == 27 && umbModal.css("display") == "block") { - closeModal(); + //check if the modal elems exist + if (!this._modalElemsExist()) { + this._createModalElems(); } - }); - }, - onHide: function(h) { - var umbModal = jQuery(h.w); - var umbModalContent = jQuery("iframe", umbModal); - h.w.hide(); - h.o.remove(); - umbModalContent.hide(); - umbModalContent.html('').attr('src', ''); - } - }).jqmShow(); -} + var _this = this; -function createUniqueUrl(url) { - var z = new Date().getTime(); - var rnd = (z - (parseInt(z / 1000, 10) * 1000)) / 10 + this._obj.jqm({ - if (url.indexOf("?") > -1) - return url += "&rndo=" + rnd; - else - return url += "?rndo=" + rnd; -} + onShow: function(h) { + var umbModal = $(h.w); + var umbModalContent = $("iframe", umbModal); + umbModalContent.width(width); + umbModalContent.height(showHeader ? height - 30 : height); -function closeModal() { - top.focus(); - $('#umbModalBox').jqmHide(); + //remove the header if it shouldn't be shown + if (!showHeader) { + _this._obj.find(".umbModalBoxHeader").remove(); + _this._obj.find(".umbracModalBoxClose").remove(); + } + else { + //set the title + _this._obj.find(".umbModalBoxHeader").html(name); + } - return false; -} + //if the height is set, then set it + if (height > 0) { + umbModal.height(height); + } + //if the width is set, then set it in the center + if (width > 0) { + umbModal.width(width); + umbModal.css("left", (($(document).width() - width) / 2) + "px"); + } + //if the top is set + if (top > 0) { + umbModal.css("top", top + "px"); + } + //if the leftOffset is set + if (leftOffset > 0) { + var newLeft = parseInt(umbModal.css("left").replace("px", "")) + leftOffset; + umbModal.css("left", newLeft); + } -function fitModalToPageSize(modalHeight, width) { + umbModalContent.html('').attr('src', _this._getUniqueUrl(url)); -} + umbModal.show(); + umbModalContent.show(); + + $(document).keyup(function(event) { + if (event.keyCode == 27 && umbModal.css("display") == "block") { + _this.close(); + } + }); + if (closeTriggers) { + for (var x in closeTriggers) { + _this._obj.jqmAddClose(closeTriggers[x]); + } + } + + }, + onHide: function(h) { + var umbModal = $(h.w); + var umbModalContent = $("iframe", umbModal); + 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 }; + onCloseCallback.call(_this, e); + } + h.w.hide(); + h.o.remove(); + umbModalContent.hide(); + umbModalContent.html('').attr('src', ''); + _this.close(); + } + }); + + this._obj.jqmShow(); + //store the api in this objects data store + this._obj.data("ModalWindowAPI", this); + return this._obj; + }, + close: function(rVal) { + /// Closes the modal window, Removes the object from the DOM + /// if specified, will add this parameter to the onCloseCallback method's outVal parameter so it may be used in the closing callback method + this._rVal = rVal; + top.focus(); + this._obj.jqmHide(); + this._obj.remove(); + return false; + }, + _createModalElems: function() { + /// 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 _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); + } + }); + }, + _modalElemsExist: function() { + return ($("#" + this._wId + "_modal").length > 0); + }, + _getUniqueUrl: function(url) { + var r = Umbraco.Utils.generateRandom(); + if (url.indexOf("?") > -1) + return url += "&rndo=" + r; + else + return url += "?rndo=" + r; + } + }; + }; + +})(jQuery); // @@ -105,7 +215,7 @@ function fitModalToPageSize(modalHeight, width) { $.jqm = { hash: {}, open: function(s, t) { - var h = H[s], c = h.c, cc = '.' + c.closeClass, z = (parseInt(h.w.css('z-index'))), z = (z > 0) ? z : 3000, o = $('
              ').css({ height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, 'z-index': z - 1}); if (h.a) return F; h.t = t; h.a = true; h.w.css('z-index', z); + var h = H[s], c = h.c, cc = '.' + c.closeClass, z = (parseInt(h.w.css('z-index'))), z = (z > 0) ? z : 3000, o = $('
              ').css({ height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, 'z-index': z - 1 }); if (h.a) return F; h.t = t; h.a = true; h.w.css('z-index', z); if (c.modal) { if (!A[0]) L('bind'); A.push(s); } else if (c.overlay > 0) h.w.jqmAddClose(o); else o = F; @@ -132,8 +242,8 @@ function fitModalToPageSize(modalHeight, width) { }; var s = 0, H = $.jqm.hash, A = [], ie6 = $.browser.msie && ($.browser.version == "6.0"), F = false, i = $('').css({ opacity: 0 }), -e = function(h) { if (ie6) if (h.o) h.o.html('

              ').prepend(i); else if (!$('iframe.jqm', h.w)[0]) h.w.prepend(i);}, -//f = function(h) { try { $(':input:visible', h.w)[0].focus(); } catch (_) { } }, +e = function(h) { if (ie6) if (h.o) h.o.html('

              ').prepend(i); else if (!$('iframe.jqm', h.w)[0]) h.w.prepend(i); }, + //f = function(h) { try { $(':input:visible', h.w)[0].focus(); } catch (_) { } }, L = function(t) { $()[t]("keypress", m)[t]("keydown", m)[t]("mousedown", m); }, m = function(e) { var h = H[A[A.length - 1]], r = (!$(e.target).parents('.jqmID' + h.s)[0]); if (r) f(h); return !r; }, hs = function(w, t, c) { diff --git a/umbraco/presentation/umbraco_client/modal/style.css b/umbraco/presentation/umbraco_client/modal/style.css index 9c93bbe9c7..465a2556cf 100644 --- a/umbraco/presentation/umbraco_client/modal/style.css +++ b/umbraco/presentation/umbraco_client/modal/style.css @@ -1,8 +1,11 @@ -#umbModalBox { +/* TODO: Change these to classes to support many modal boxes */ + +#umbModalBox, +.umbModalBox { position: absolute; top: 0; border: 5px #a3a3a3 solid; - border-top: none; + /*border-top: none;*/ text-align: left; z-index: 10000; display: none; @@ -10,11 +13,16 @@ font: bold 100% "Lucida Grande", Arial, sans-serif; } -#umbModalBox.loaded{background-image: none;} +#umbModalBox.loaded, +.umbModalBox.loaded +{ + background-image: none; +} .jqmOverlay {background: url(modalBackground.gif)} -#umbModalBoxHeader { +#umbModalBoxHeader, +.umbModalBoxHeader { margin: 0; text-shadow: #FFF 0 1px 0; padding: .5em 2em .5em .75em; @@ -22,13 +30,15 @@ text-align: left; } -#umbModalBoxContent { +#umbModalBoxContent, +.umbModalBoxContent { padding: 0px; overflow: hidden; height: 100%; } -#umbracModalBoxClose { +#umbracModalBoxClose, +.umbracModalBoxClose { display: block; position: absolute; right: 5px; top: 2px; @@ -38,13 +48,19 @@ font-size: 13px; } -#umbModalBoxContent {border-top: 1px solid #F9F9F9; } +#umbModalBoxContent, +.umbModalBoxContent {border-top: 1px solid #F9F9F9; } -#umbModalBoxHeader { +#umbModalBoxHeader, +.umbModalBoxHeader { background: url(modalGradiant.gif) repeat-x bottom #fff; border-bottom: 1px solid #CCC; - color: #378080 + color: #378080; + cursor:move; } -#umbracModalBoxClose { color: #777 } -#umbracModalBoxClose:hover { color: #000 } \ No newline at end of file +#umbracModalBoxClose, +.umbracModalBoxClose { color: #777 } + +#umbracModalBoxClose:hover, +.umbracModalBoxClose:hover { color: #000 } \ No newline at end of file diff --git a/umbraco/presentation/umbraco_client/ui/default.css b/umbraco/presentation/umbraco_client/ui/default.css index 9d29055ea6..3a012ab093 100644 --- a/umbraco/presentation/umbraco_client/ui/default.css +++ b/umbraco/presentation/umbraco_client/ui/default.css @@ -550,10 +550,16 @@ guiEditor { .success a {color:#264409;} -.sprTree { - background-color: #fff; - background-image: url(../../umbraco/images/umbraco/sprites.png); - display: inline; - padding-bottom: 2px; -} -.sprTree img{width: 16px; height: 18px; padding-right: 7px;} \ No newline at end of file +.sprTree { + /*background-color: #fff;*/ + background-image: url(../../umbraco/images/umbraco/sprites.png); + display: inline; + padding-bottom: 2px; +} +.sprTree img{width: 16px; height: 18px; padding-right: 7px;} + +.treeContainer +{ + padding:5px; + background-color:White; +} \ No newline at end of file diff --git a/umbraco/presentation/web.config.BOMBER.xslt b/umbraco/presentation/web.config.BOMBER.xslt deleted file mode 100644 index ac97e696f3..0000000000 --- a/umbraco/presentation/web.config.BOMBER.xslt +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - server=.\sqlexpress;database=umbraco4.1;Integrated Security=true - - - - - - - - - - - - - - diff --git a/umbraco/presentation/web.config.SHANDEMVAIO.xslt b/umbraco/presentation/web.config.SHANDEMVAIO.xslt index 622a45798b..27c5fed580 100644 --- a/umbraco/presentation/web.config.SHANDEMVAIO.xslt +++ b/umbraco/presentation/web.config.SHANDEMVAIO.xslt @@ -4,12 +4,13 @@ - datalayer="VistaDB,VistaDB For Umbraco" + server=.\sqlexpress;database=UmbracoTest;user id=sa;password=test + - 4.1.0.alpha + 4.1.0.beta - + @@ -20,5 +21,5 @@ - + diff --git a/umbraco/presentation/web.config.SHOCKING.xslt b/umbraco/presentation/web.config.SHOCKING.xslt index 5715898ec6..d1a14ecfa7 100644 --- a/umbraco/presentation/web.config.SHOCKING.xslt +++ b/umbraco/presentation/web.config.SHOCKING.xslt @@ -4,11 +4,17 @@ - datalayer="VistaDB,VistaDB For Umbraco" + server=SHOCKING\SQLEXPRESS;database=UmbracoTest2;user id=sa;password=test 4.1.0.beta + + /App_Data/umbraco.config + + + /umbraco + diff --git a/umbraco/umbraco.Legacy/umbraco.Legacy.csproj b/umbraco/umbraco.Legacy/umbraco.Legacy.csproj index 2c58256343..e68b966caf 100644 --- a/umbraco/umbraco.Legacy/umbraco.Legacy.csproj +++ b/umbraco/umbraco.Legacy/umbraco.Legacy.csproj @@ -325,6 +325,10 @@ + + + + diff --git a/umbraco/presentation/umbraco/js/submodal/common.js b/umbraco/umbraco.Legacy/umbraco/js/submodal/common.js similarity index 100% rename from umbraco/presentation/umbraco/js/submodal/common.js rename to umbraco/umbraco.Legacy/umbraco/js/submodal/common.js diff --git a/umbraco/presentation/umbraco/js/submodal/maskBG.png b/umbraco/umbraco.Legacy/umbraco/js/submodal/maskBG.png similarity index 100% rename from umbraco/presentation/umbraco/js/submodal/maskBG.png rename to umbraco/umbraco.Legacy/umbraco/js/submodal/maskBG.png diff --git a/umbraco/presentation/umbraco/js/submodal/subModal.css b/umbraco/umbraco.Legacy/umbraco/js/submodal/subModal.css similarity index 100% rename from umbraco/presentation/umbraco/js/submodal/subModal.css rename to umbraco/umbraco.Legacy/umbraco/js/submodal/subModal.css diff --git a/umbraco/presentation/umbraco/js/submodal/subModal.js b/umbraco/umbraco.Legacy/umbraco/js/submodal/subModal.js similarity index 100% rename from umbraco/presentation/umbraco/js/submodal/subModal.js rename to umbraco/umbraco.Legacy/umbraco/js/submodal/subModal.js