设为首页 加入收藏

TOP

bootstrap选项卡扩展,增加关闭,超出一行显示下拉(三)
2017-10-13 10:49:53 】 浏览:1228
Tags:bootstrap 选项 扩展 增加 关闭 超出 一行 显示 下拉
tting) {//检测选项卡是否存在 123 var divs = _tabcontent.options.selector.children("div"), divdata, hasdata; 124 hasdata = { selector: undefined, has: false }; 125 $.each(divs, function () { 126 divdata = $(this).data("data"); 127 if (!divdata) return true; 128 if (divdata.bindcode === setting.bindcode) { 129 hasdata = { selector: $(this), has: true }; 130 return false; 131 }; 132 }); 133 return hasdata; 134 }; 135 }; 136 137 var droplist = function () { 138 this.options = { 139 selector: undefined, 140 ulpanel: undefined 141 }; 142 143 this.init = function (panel) { 144 var li = $('<li class="dropdown pull-right"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><b class="caret"></b></a><ul class="dropdown-menu"></ul></li>'); 145 this.options.selector = li.css({ "visibility": "hidden" }); 146 this.options.ulpanel = li.children("ul"); 147 this.options.selector.appendTo(panel); 148 }; 149 150 this.addDropItem = function () { 151 additem(this.options.selector, this.options.ulpanel); 152 }; 153 154 function additem(li, ul) { 155 var item = options.selector.children("li").not(li).last(); 156 li.css({ "visibility": "visible" }); 157 if (item.length <= 0) return; 158 item.find("span.close").hide(); 159 ul.append(item); 160 item.one("click", function () { 161 itemtarget(this, li, ul); 162 }); 163 }; 164 165 function itemtarget(target, selector, ulpanel) { 166 var item = options.selector.children("li").not(selector).last(); 167 $(target).find("span.close").show(); 168 $(target).prependTo(options.selector); 169 if (item.length <= 0) return; 170 if (selector.position().top > options.selector.position().top) { 171 item.find("span.close").hide(); 172 ulpanel.append(item); 173 }; 174 item.one("click", function () { 175 itemtarget(this, selector, ulpanel); 176 }); 177 }; 178 }; 179 180 function init(setting) { 181 $.extend(options, setting); 182 if (!options.selector) { 183 return; 184 }; 185 if (options.selector[0].tagName.toLowerCase() != "ul") { 186 var selector = $('<ul class="nav nav-tabs pagetabs"></ul>').appendTo(options.selector); 187 options.selector = selector; 188 }; 189 if (!_drop) { 190 _drop = new droplist(); 191 }; 192 _drop.init(options.selector); 193 194 if (!_tabcontent) { 195 _tabcontent = new tabcontent(); 196 }; 197 _tabcontent.init(); 198 if (!_newtab) { 199 _newtab = new tab(); 200 }; 201 }; 202 203 function addtab(setting) { 204 if (!_newtab) { 205 _newtab = new tab(); 206 }; 207 _newtab.addtab(setting); 208 if (!_tabcontent) { 209 _tabcontent = new tabcontent(); 210 }; 211 _tabcontent.addContent(setting); 212 options.selector.find('li>a').filter('[href=#page' + setting.bindcode + ']').tab("show"); 213 }; 214 215 return { 216 init: function (setting) { 217 init(setting); 218 }, addtab: function (setting) { 219 addtab(setting); 220 } 221 }; 222 })(jQuery); View Code
效果如下:
 
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇nodeJS之crypto加密 下一篇input文字垂直居中和按钮对齐问题..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目