Tidy up code - refs #1318

This commit is contained in:
Samuel Georges 2015-08-08 11:39:48 +10:00
parent 56c8053288
commit c139a324d1
2 changed files with 21 additions and 17 deletions

View File

@ -86,18 +86,25 @@
tabIndex = $tabs.index(li),
time = new Date().getTime(),
targetId = this.tabId + '-tab-' + tabIndex + time,
$a = $('a', li)
$anchor = $('a', li)
$a.attr('data-target', '#'+targetId).attr('data-toggle', 'tab')
if (!$a.attr('title'))
$a.attr('title', $a.text())
$anchor
.data('target', '#'+targetId)
.attr('data-target', '#'+targetId)
.attr('data-toggle', 'tab')
var html = $a.html()
if (!$anchor.attr('title'))
$anchor.attr('title', $anchor.text())
$a.html('')
$a.append($('<span class="title"></span>').append($('<span></span>').html(html)))
var html = $anchor.html()
$anchor.html('')
$anchor
.append($('<span class="title"></span>')
.append($('<span></span>').html(html)))
var pane = $('> .tab-pane', this.$pagesContainer).eq(tabIndex).attr('id', targetId)
$(li).append($('<span class="tab-close"><i>&times;</i></span>').click(function(){
$(this).trigger('close.oc.tab')
return false
@ -158,9 +165,6 @@
this.initTab($tab)
$link.data('title', $link.attr('data-title'))
$link.data('target', $link.attr('data-target'))
this.updateClasses()
}

View File

@ -3811,13 +3811,13 @@ if(this.options.slidable){this.$pagesContainer.touchwipe({wipeRight:function(){s
this.$tabsContainer.toolbar({scrollClassContainer:this.$el})
this.updateClasses()}
Tab.prototype.initTab=function(li){var
$tabs=$('>li',this.$tabsContainer),tabIndex=$tabs.index(li),time=new Date().getTime(),targetId=this.tabId+'-tab-'+tabIndex+time,$a=$('a',li)
$a.attr('data-target','#'+targetId).attr('data-toggle','tab')
if(!$a.attr('title'))
$a.attr('title',$a.text())
var html=$a.html()
$a.html('')
$a.append($('<span class="title"></span>').append($('<span></span>').html(html)))
$tabs=$('>li',this.$tabsContainer),tabIndex=$tabs.index(li),time=new Date().getTime(),targetId=this.tabId+'-tab-'+tabIndex+time,$anchor=$('a',li)
$anchor.data('target','#'+targetId).attr('data-target','#'+targetId).attr('data-toggle','tab')
if(!$anchor.attr('title'))
$anchor.attr('title',$anchor.text())
var html=$anchor.html()
$anchor.html('')
$anchor.append($('<span class="title"></span>').append($('<span></span>').html(html)))
var pane=$('> .tab-pane',this.$pagesContainer).eq(tabIndex).attr('id',targetId)
$(li).append($('<span class="tab-close"><i>&times;</i></span>').click(function(){$(this).trigger('close.oc.tab')
return false}))