diff --git a/components/umbraco.controls/TabView.cs b/components/umbraco.controls/TabView.cs index a64101111c..20f8b17a04 100644 --- a/components/umbraco.controls/TabView.cs +++ b/components/umbraco.controls/TabView.cs @@ -14,91 +14,93 @@ namespace umbraco.uicontrols { [ClientDependency(ClientDependencyType.Javascript, "tabview/javascript.js", "UmbracoClient")] [ClientDependency(ClientDependencyType.Css, "tabview/style.css", "UmbracoClient")] - public class TabView : System.Web.UI.WebControls.WebControl { - private HtmlInputHidden tb = new HtmlInputHidden(); - private ArrayList Tabs = new ArrayList(); - protected ArrayList Panels = new ArrayList(); - private string status = ""; + [ClientDependency(0, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")] + public class TabView : System.Web.UI.WebControls.WebControl + { + private HtmlInputHidden tb = new HtmlInputHidden(); + private ArrayList Tabs = new ArrayList(); + protected ArrayList Panels = new ArrayList(); + private string status = ""; - public ArrayList GetPanels() { - return Panels; - } + public ArrayList GetPanels() { + return Panels; + } - public TabPage NewTabPage(string text) { - Tabs.Add(text); - TabPage tp = new TabPage(); - tp.Width = this.Width; - tp.ID = this.ID + "_tab0" + (Panels.Count + 1) + "layer"; - Panels.Add(tp); - this.Controls.Add(tp); - return tp; - } + public TabPage NewTabPage(string text) { + Tabs.Add(text); + TabPage tp = new TabPage(); + tp.Width = this.Width; + tp.ID = this.ID + "_tab0" + (Panels.Count + 1) + "layer"; + Panels.Add(tp); + this.Controls.Add(tp); + return tp; + } - - public string Status { - get { return status; } - set { status = value; } - } + + public string Status { + get { return status; } + set { status = value; } + } - private bool _autoResize = true; - public bool AutoResize { - get { return _autoResize; } - set { _autoResize = value; } - } + private bool _autoResize = true; + public bool AutoResize { + get { return _autoResize; } + set { _autoResize = value; } + } - private string ActiveTabId { - get { - if (this.Parent.Page.IsPostBack) { - return this.Parent.Page.Request.Form[this.ClientID + "_activetab"]; - } - return this.ClientID + "_tab01"; - } - } + private string ActiveTabId { + get { + if (this.Parent.Page.IsPostBack) { + return this.Parent.Page.Request.Form[this.ClientID + "_activetab"]; + } + return this.ClientID + "_tab01"; + } + } - protected override void OnPreRender(EventArgs e) { - base.OnPreRender(e); - SetupClientScript(); - } + protected override void OnPreRender(EventArgs e) { + base.OnPreRender(e); + SetupClientScript(); + } - private void SetupClientScript() { - + private void SetupClientScript() { + - string strTmp = ""; - for (int i = 1; i <= Tabs.Count; i++) { - if (i > 1) - strTmp += ","; - strTmp += "\"" + this.ClientID + "_tab0" + i + "\""; - } - this.Page.ClientScript.RegisterStartupScript( - this.GetType(), - this.ClientID + "TabCollection", ";var " + this.ClientID + "_tabs = new Array(" + strTmp + ");setActiveTab('" + this.ClientID + "','" + this.ActiveTabId + "'," + this.ClientID + "_tabs);", - true); + string strTmp = ""; + for (int i = 1; i <= Tabs.Count; i++) { + if (i > 1) + strTmp += ","; + strTmp += "\"" + this.ClientID + "_tab0" + i + "\""; + } + this.Page.ClientScript.RegisterStartupScript( + this.GetType(), + this.ClientID + "TabCollection", ";var " + this.ClientID + "_tabs = new Array(" + strTmp + ");setActiveTab('" + this.ClientID + "','" + this.ActiveTabId + "'," + this.ClientID + "_tabs);", + true); - if (_autoResize) - this.Page.ClientScript.RegisterStartupScript(this.GetType(), "TabviewEvents", "jQuery(document).ready(function(){resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); }); jQuery(window).resize(function(){ resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); });", true); - } + if (_autoResize) + this.Page.ClientScript.RegisterStartupScript(this.GetType(), "TabviewEvents", "jQuery(document).ready(function(){resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); }); jQuery(window).resize(function(){ resizeTabView(" + this.ClientID + "_tabs, '" + this.ClientID + "'); });", true); + } - protected override void Render(HtmlTextWriter writer) { - writer.WriteLine("
"); - writer.WriteLine("
"); - writer.WriteLine(" "); - writer.WriteLine("
"); - writer.WriteLine("
"); - this.RenderChildren(writer); - writer.WriteLine("\t
"); - writer.WriteLine("\t"); - writer.WriteLine("
"); - writer.WriteLine(""); - } - } + protected override void Render(HtmlTextWriter writer) { + writer.WriteLine("
"); + writer.WriteLine("
"); + writer.WriteLine(" "); + writer.WriteLine("
"); + writer.WriteLine("
"); + this.RenderChildren(writer); + writer.WriteLine("\t
"); + writer.WriteLine("\t"); + writer.WriteLine("
"); + writer.WriteLine(""); + } + } } \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs index c0365f6926..9d715c9037 100644 --- a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs +++ b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.cs @@ -153,15 +153,14 @@ namespace umbraco.controls ListItem li = new ListItem(fileInfo[i].Name + " (deprecated)", fileInfo[i].Name); li.Attributes.Add("title", this.ResolveClientUrl(SystemDirectories.Umbraco + "/images/umbraco/" + fileInfo[i].Name)); - if (!this.Page.IsPostBack && li.Value == cType.IconUrl) li.Selected = true; + if (li.Value == cType.IconUrl) + li.Selected = true; listOfIcons.Add(li); } } ddlIcons.Items.AddRange(listOfIcons.OrderBy(o => o.Text).ToArray()); - Page.ClientScript.RegisterStartupScript(this.GetType(), "iconsDropDown", "jQuery(function() { jQuery('#" + ddlIcons.ClientID + "').msDropDown({ showIcon: true, style: 'width:250px;' }); });", true); - // Get thumbnails dirInfo = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Umbraco + "/images/thumbnails")); fileInfo = dirInfo.GetFiles(); @@ -173,7 +172,13 @@ namespace umbraco.controls ddlThumbnails.Items.Add(li); } - Page.ClientScript.RegisterStartupScript(this.GetType(), "thumbnailsDropDown", "jQuery(function() { jQuery('#" + ddlThumbnails.ClientID + "').msDropDown({ showIcon: false, rowHeight: '130', visibleRows: '2', style: 'width:250px;' }); });", true); + Page.ClientScript.RegisterStartupScript(this.GetType(), "thumbnailsDropDown", @" +function refreshDropDowns() { + jQuery('#" + ddlIcons.ClientID + @"').msDropDown({ showIcon: true, style: 'width:250px;' }); + jQuery('#" + ddlThumbnails.ClientID + @"').msDropDown({ showIcon: false, rowHeight: '130', visibleRows: '2', style: 'width:250px;' }); +} +jQuery(function() { refreshDropDowns(); }); +", true); txtName.Text = cType.GetRawText(); txtAlias.Text = cType.Alias; @@ -770,6 +775,12 @@ namespace umbraco.controls bindTabs(); bindDataGenericProperties(true); } + + Page.ClientScript.RegisterStartupScript(this.GetType(), "dropDowns", @" +Umbraco.Controls.TabView.onActiveTabChange(function(tabviewid, tabid, tabs) { + refreshDropDowns(); +}); +", true); } protected void dgTabs_ItemCommand(object source, DataGridCommandEventArgs e) diff --git a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs index 450005c932..cc59e11640 100644 --- a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs +++ b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // 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. +// the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/umbraco/presentation/umbraco_client/tabview/javascript.js b/umbraco/presentation/umbraco_client/tabview/javascript.js index 1df85cfcb5..dc69c6857c 100644 --- a/umbraco/presentation/umbraco_client/tabview/javascript.js +++ b/umbraco/presentation/umbraco_client/tabview/javascript.js @@ -1,64 +1,103 @@ +/// -function setActiveTab(tabviewid,tabid,tabs) { - for (var i = 0; i < tabs.length; i++) { - jQuery("#" + tabs[i]).attr("class", "tabOff"); - jQuery("#" + tabs[i] + "layer").hide(); - } +Umbraco.Sys.registerNamespace('Umbraco.Controls'); - jQuery("#" + tabid).attr("class", "tabOn"); - jQuery("#" + tabid + "layer").show(); - jQuery("#" + tabviewid + '_activetab').val(tabid); +Umbraco.Controls.TabView = (function () { + var onChangeEvents = []; - // show first tinymce toolbar - jQuery(".tinymceMenuBar").hide(); - jQuery(document).ready(function() { - jQuery("#" + tabid + "layer .tinymceMenuBar:first").show(); - }); + var obj = { + setActiveTab: function (tabviewid, tabid, tabs) { + for (var i = 0; i < tabs.length; i++) { + $("#" + tabs[i]).attr("class", "tabOff"); + $("#" + tabs[i] + "layer").hide(); + } + + var activeTab = $("#" + tabid).attr("class", "tabOn"); + $("#" + tabid + "layer").show(); + $("#" + tabviewid + '_activetab').val(tabid); + + // show first tinymce toolbar + $(".tinymceMenuBar").hide(); + $(document).ready(function () { + $("#" + tabid + "layer .tinymceMenuBar:first").show(); + }); + for (var i = 0; i < onChangeEvents.length; i++) { + var fn = onChangeEvents[i]; + fn.apply(activeTab, [tabviewid, tabid, tabid]); + } + }, + + onActiveTabChange: function (fn) { + console.log('adding function'); + onChangeEvents.push(fn); + }, + + resizeTabViewTo: function (TabPageArr, TabViewName, tvHeight, tvWidth) { + if (!tvHeight) { + tvHeight = jQuery(window).height(); //getViewportHeight(); + if (document.location) { + tvHeight = tvHeight - 10; + } + } + if (!tvWidth) { + tvWidth = jQuery(window).width(); // getViewportWidth(); + if (document.location) { + tvWidth = tvWidth - 10; + } + } + + var tabviewHeight = tvHeight - 12; + + jQuery("#" + TabViewName).width(tvWidth); + jQuery("#" + TabViewName).height(tabviewHeight); + + + for (i = 0; i < TabPageArr.length; i++) { + scrollwidth = tvWidth - 30; + jQuery("#" + TabPageArr[i] + "layer_contentlayer").height((tabviewHeight - 67)); + + //document.getElementById(TabPageArr[i] +"layer_contentlayer").style.border = "2px solid #fff"; + + jQuery("#" + TabPageArr[i] + "layer_contentlayer").width((tvWidth - 2)); + jQuery("#" + TabPageArr[i] + "layer_menu").width((scrollwidth)); + jQuery("#" + TabPageArr[i] + "layer_menu_slh").width((scrollwidth)); + } + }, + + tabSwitch: function (direction) { + var preFix = "TabView1"; + var currentTab = jQuery("#" + preFix + "_activetab").val(); + + currentTab = currentTab.substr(preFix.length + 4, currentTab.length - preFix.length - 4); + var nextTab = Math.round(currentTab) + direction; + + if (nextTab < 10) + nextTab = "0" + nextTab; + + // Try to grab the next one! + if (nextTab != "00") { + if ($("#" + preFix + '_tab' + nextTab) != null) { + setActiveTab(preFix, preFix + '_tab' + nextTab, eval(preFix + '_tabs')); + } + } + } + }; + + return obj; +})(jQuery); + +function setActiveTab(tabviewid, tabid, tabs) { + Umbraco.Controls.TabView.setActiveTab(tabviewid, tabid, tabs); } function resizeTabView(TabPageArr, TabViewName) { - var clientHeight = jQuery(window).height(); //getViewportHeight(); - var clientWidth = jQuery(window).width(); // getViewportWidth(); - - if(top.document.location == document.location) - resizeTabViewTo(TabPageArr, TabViewName, clientHeight - 10, clientWidth - 15) - else - resizeTabViewTo(TabPageArr, TabViewName, clientHeight, clientWidth) + Umbraco.Controls.TabView.resizeTabViewTo(TabPageArr, TabViewName); } function resizeTabViewTo(TabPageArr, TabViewName, tvHeight, tvWidth) { - var tabviewHeight = tvHeight - 12; - - jQuery("#" + TabViewName).width(tvWidth); - jQuery("#" + TabViewName).height(tabviewHeight); - - - for (i=0;i - +