Support multiple children inside .layout-cell.width-fix

This commit is contained in:
Samuel Georges 2015-07-29 19:15:42 +10:00
parent 2a26aa6889
commit e6a17f8f2b
2 changed files with 22 additions and 11 deletions

View File

@ -13,16 +13,26 @@
} }
OctoberLayout.prototype.updateLayout = function(title) { OctoberLayout.prototype.updateLayout = function(title) {
var $children, $el, fixedWidth, margin
$('.layout-cell.width-fix').each(function(){ $('.layout-cell.width-fix').each(function(){
var $el = $(this).children(); $children = $(this).children()
if ($el.length > 0) {
var margin = $el.data('oc.layoutMargin'); if ($children.length > 0) {
fixedWidth = 0
$children.each(function() {
$el = $(this)
margin = $el.data('oc.layoutMargin')
if (margin === undefined) { if (margin === undefined) {
margin = parseInt($el.css('marginRight')) + parseInt($el.css('marginLeft')) margin = parseInt($el.css('marginRight')) + parseInt($el.css('marginLeft'))
$el.data('oc.layoutMargin', margin) $el.data('oc.layoutMargin', margin)
} }
fixedWidth += $el.get(0).offsetWidth + margin
})
$(this).width($el.get(0).offsetWidth + margin) $(this).width(fixedWidth)
$(this).trigger('oc.widthFixed') $(this).trigger('oc.widthFixed')
} }
}) })

View File

@ -25,8 +25,9 @@
$('.layout-cell.width-fix', navbar).one('oc.widthFixed', function(){ $('.layout-cell.width-fix', navbar).one('oc.widthFixed', function(){
var dragScroll = $('[data-control=toolbar]', navbar).data('oc.dragScroll') var dragScroll = $('[data-control=toolbar]', navbar).data('oc.dragScroll')
if (dragScroll) if (dragScroll) {
dragScroll.goToElement($('ul.nav > li.active', navbar), undefined, {'duration': 0}) dragScroll.goToElement($('ul.nav > li.active', navbar), undefined, {'duration': 0})
}
}) })
}) })
}) })