示例#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);
        }
示例#2
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);
        }