fixing the problem with adding tabs and the new icon-based drop downs on editing data types
[TFS Changeset #70254]
This commit is contained in:
@@ -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("<div id='" + this.ClientID + "' style='height:" + this.Height.Value + "px;width:" + this.Width.Value + "px;'>");
|
||||
writer.WriteLine(" <div class='header'>");
|
||||
writer.WriteLine(" <ul>");
|
||||
for (int i = 0; i <= Tabs.Count - 1; i++) {
|
||||
string TabPageCaption = (string)Tabs[i];
|
||||
string TabId = this.ClientID + "_tab0" + (i + 1);
|
||||
writer.WriteLine(" <li id='" + TabId + "' class='tabOff'>");
|
||||
writer.WriteLine(" <a id='" + TabId + "a' href='#' onclick=\"setActiveTab('" + this.ClientID + "','" + TabId + "'," + this.ClientID + "_tabs); return false;\">");
|
||||
writer.WriteLine(" <span><nobr>" + TabPageCaption + "</nobr></span>");
|
||||
writer.WriteLine(" </a>");
|
||||
writer.WriteLine(" </li>");
|
||||
}
|
||||
writer.WriteLine(" </ul>");
|
||||
writer.WriteLine(" </div>");
|
||||
writer.WriteLine(" <div id='' class='tabpagecontainer'>");
|
||||
this.RenderChildren(writer);
|
||||
writer.WriteLine("\t</div>");
|
||||
writer.WriteLine("\t<div class='footer'><div class='status'><h2>" + this.status + "</h2></div></div>");
|
||||
writer.WriteLine("</div>");
|
||||
writer.WriteLine("<input type='hidden' name='" + this.ClientID + "_activetab' id='" + this.ClientID + "_activetab' value='" + this.ActiveTabId + "'/>");
|
||||
}
|
||||
}
|
||||
protected override void Render(HtmlTextWriter writer) {
|
||||
writer.WriteLine("<div id='" + this.ClientID + "' style='height:" + this.Height.Value + "px;width:" + this.Width.Value + "px;'>");
|
||||
writer.WriteLine(" <div class='header'>");
|
||||
writer.WriteLine(" <ul>");
|
||||
for (int i = 0; i <= Tabs.Count - 1; i++) {
|
||||
string TabPageCaption = (string)Tabs[i];
|
||||
string TabId = this.ClientID + "_tab0" + (i + 1);
|
||||
writer.WriteLine(" <li id='" + TabId + "' class='tabOff'>");
|
||||
writer.WriteLine(" <a id='" + TabId + "a' href='#' onclick=\"setActiveTab('" + this.ClientID + "','" + TabId + "'," + this.ClientID + "_tabs); return false;\">");
|
||||
writer.WriteLine(" <span><nobr>" + TabPageCaption + "</nobr></span>");
|
||||
writer.WriteLine(" </a>");
|
||||
writer.WriteLine(" </li>");
|
||||
}
|
||||
writer.WriteLine(" </ul>");
|
||||
writer.WriteLine(" </div>");
|
||||
writer.WriteLine(" <div id='' class='tabpagecontainer'>");
|
||||
this.RenderChildren(writer);
|
||||
writer.WriteLine("\t</div>");
|
||||
writer.WriteLine("\t<div class='footer'><div class='status'><h2>" + this.status + "</h2></div></div>");
|
||||
writer.WriteLine("</div>");
|
||||
writer.WriteLine("<input type='hidden' name='" + this.ClientID + "_activetab' id='" + this.ClientID + "_activetab' value='" + this.ActiveTabId + "'/>");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,64 +1,103 @@
|
||||
/// <reference path="../Application/NamespaceManager.js" />
|
||||
|
||||
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<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) );
|
||||
}
|
||||
Umbraco.Controls.TabView.resizeTabViewTo(TabPageArr, TabViewName, tvHeight, tvWidth);
|
||||
}
|
||||
|
||||
function tabSwitch(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 (jQuery("#" + preFix+'_tab' + nextTab) != null) {
|
||||
setActiveTab(preFix,preFix + '_tab' + nextTab,eval(preFix+'_tabs'));
|
||||
}
|
||||
}
|
||||
Umbraco.Controls.TabView.tabSwitch(direction);
|
||||
}
|
||||
@@ -111,7 +111,7 @@
|
||||
<add verb="GET,HEAD,POST" path="GoogleSpellChecker.ashx" type="umbraco.presentation.umbraco_client.tinymce3.plugins.spellchecker.GoogleSpellChecker,umbraco" />
|
||||
</httpHandlers>
|
||||
|
||||
<compilation defaultLanguage="c#" debug="false" batch="false">
|
||||
<compilation defaultLanguage="c#" debug="true" batch="false">
|
||||
<assemblies>
|
||||
<!-- ASPNETAJAX -->
|
||||
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
|
||||
|
||||
Reference in New Issue
Block a user