Beispiel #1
0
        public static JsDictionary <string, int?> IndexByKey(this TabsObject tabs)
        {
            var indexByKey = tabs.As <jQueryObject>().GetDataValue("indexByKey").As <JsDictionary <string, int?> >();

            if (indexByKey == null)
            {
                indexByKey = new JsDictionary <string, int?>();

                tabs.As <jQueryObject>().Children("ul").Children("li").Children("a")
                .Each((index, el) =>
                {
                    var href      = el.GetAttribute("href").ToString();
                    var prefix    = "_Tab";
                    var lastIndex = href.LastIndexOf(prefix);
                    if (lastIndex >= 0)
                    {
                        href = href.Substr(lastIndex + prefix.Length);
                    }

                    indexByKey[href] = index;
                });

                tabs.As <jQueryObject>().Data("indexByKey", indexByKey);
            }

            return(indexByKey);
        }
Beispiel #2
0
        public static void SetDisabled(this TabsObject tabs, string tabKey, bool isDisabled)
        {
            if (tabs == null)
            {
                return;
            }

            var indexByKey = tabs.IndexByKey();

            if (indexByKey == null)
            {
                return;
            }

            var index = indexByKey[tabKey];

            if (index == null)
            {
                return;
            }

            if (index.Value == (int)tabs.Active)
            {
                tabs.Active = 0;
            }

            if (isDisabled)
            {
                tabs.Disable(index.Value);
            }
            else
            {
                tabs.Enable(index.Value);
            }
        }
Beispiel #3
0
        static ConnectListsTabs()
        {
            jQuery.OnDocumentReady(delegate()
            {
                jQuery.Select("#sortable41, #sortable42")
                .Plugin <SortableObject>()
                .Sortable();

                TabsObject tabs = jQuery.Select("#tabs")
                                  .Plugin <TabsObject>()
                                  .Tabs();

                DroppableObject tabItems
                    = jQuery.Select("ul:first li", tabs)
                      .Plugin <DroppableObject>()
                      .Droppable(new DroppableOptions(
                                     DroppableOption.Accept, ".connectedSortable2 li",
                                     DroppableOption.HoverClass, "ui-state-hover",
                                     DroppableEvents.Drop, new jQueryUIEventHandler <DropEvent>(delegate(jQueryEvent e, DropEvent dropEvent) {
                    jQueryObject list = jQuery.Select(jQuery.This.Find("a").GetAttribute("href"))
                                        .Find(".connectedSortable2");

                    ((jQueryObject)dropEvent.Draggable).Hide(EffectDuration.Slow, delegate() {
                        tabs.Tabs(new TabsOptions(TabsOption.Active, jQuery.This.Index(jQuery.This.Selector)));
                        jQuery.This.AppendTo(list).Show(EffectDuration.Slow);
                    });
                })));
            });
        }
        // actual addTab function: adds new tab using the title input from the form above
        static void addTab(TabsObject tabs)
        {
            string tab_title = tab_title_input.GetValue() ?? ("Tab " + tab_counter);

            tabs.Tabs(TabsMethod.Add, "#tabs-" + tab_counter, tab_title);
            tab_counter++;
        }
Beispiel #5
0
        protected virtual void InitTabs()
        {
            var tabsDiv = this.ById("Tabs");

            if (tabsDiv.Length == 0)
            {
                return;
            }

            tabs = tabsDiv.Tabs(new TabsOptions());
        }
Beispiel #6
0
        public static string ActiveTabKey(this TabsObject tabs)
        {
            var href      = tabs.As <jQueryObject>().Children("ul").Children("li").Eq(tabs.Active.As <int>()).Children("a").GetAttribute("href").ToString();
            var prefix    = "_Tab";
            var lastIndex = href.LastIndexOf(prefix);

            if (lastIndex >= 0)
            {
                href = href.Substr(lastIndex + prefix.Length);
            }
            return(href);
        }
 public static void SelectTab(this TabsObject tabs, string tabKey)
 {
 }
 public static JsDictionary <string, int?> IndexByKey(this TabsObject tabs)
 {
     return(null);
 }
 public static string ActiveTabKey(this TabsObject tabs)
 {
     return(null);
 }
 public static void SetDisabled(this TabsObject tabs, string tabKey, bool isDisabled)
 {
 }
 // actual addTab function: adds new tab using the title input from the form above
 static void addTab(TabsObject tabs)
 {
     string tab_title = tab_title_input.GetValue() ?? ("Tab " + tab_counter);
     tabs.Tabs(TabsMethod.Add, "#tabs-" + tab_counter, tab_title);
     tab_counter++;
 }
        static Manipulation()
        {
            jQuery.OnDocumentReady(delegate() {
                // tabs init with a custom tab template and an "add" callback filling in the content
                TabsObject tabs
                    = jQuery.Select("#tabs6")
                      .Plugin <TabsObject>()
                      .Tabs(new TabsOptions(
                                "tabTemplate", "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
                                "add", new jQueryUIEventHandler <TabsAddEvent>(
                                    delegate(jQueryEvent @event, TabsAddEvent ui) {
                    string tab_content = tab_content_input.GetValue() ?? ("Tab " + tab_counter + " content.");
                    jQuery.Select(ui.Panel).Append("<p>" + tab_content + "</p>");
                })));

                // modal dialog init: custom buttons and a "close" callback reseting the form inside
                DialogObject dialog
                    = jQuery.Select("#dialog11")
                      .Plugin <DialogObject>()
                      .Dialog(new DialogOptions(
                                  DialogOption.AutoOpen, false,
                                  DialogOption.Modal, true,
                                  DialogOption.Buttons,
                                  new DialogOptions(
                                      "Add", new Action(delegate() {
                    addTab(tabs);
                    jQuery.This.Plugin <DialogObject>().Dialog(DialogMethod.Close);
                }),
                                      "Cancel", new Action(delegate() {
                    jQuery.This.Plugin <DialogObject>().Dialog(DialogMethod.Open);
                })),
                                  DialogMethod.Open, new Action(delegate() {
                    tab_title_input.Focus();
                }),
                                  DialogMethod.Close, new Action(delegate() {
                    // addTab form: calls addTab function on submit and closes the dialog
                    jQuery.Select("form", jQuery.This)
                    .Submit(new jQueryEventHandler(delegate(jQueryEvent e) {
                        addTab(tabs);
                        jQuery.This.Plugin <DialogObject>().Dialog(DialogMethod.Close);
                        e.PreventDefault();
                        e.StopPropagation();
                    }));
                })));

                // addTab button: just opens the dialog
                jQuery.Select("#add_tab")
                .Plugin <ButtonObject>()
                .Button()
                .Click(new jQueryEventHandler(delegate(jQueryEvent e) {
                    dialog.Dialog(DialogMethod.Open);
                }));

                // close icon: removing the tab on click
                // note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
                jQuery.Select("#tabs6 span.ui-icon-close")
                .Live("click", new jQueryEventHandler(delegate(jQueryEvent e) {
                    int index = jQuery.Select("li", tabs).Index(jQuery.This.Parent()[0]);
                    tabs.Tabs(TabsMethod.Remove, index);
                }));
            });
        }