diff --git a/dist/css/ionic.css b/dist/css/ionic.css index 0b18842684..53080085dc 100644 --- a/dist/css/ionic.css +++ b/dist/css/ionic.css @@ -2766,7 +2766,7 @@ a.subdued { left: 0; z-index: 0; overflow: hidden; - margin: 0; + margin: 0 10px; min-width: 30px; text-align: center; text-overflow: ellipsis; @@ -2775,6 +2775,8 @@ a.subdued { line-height: 44px; } .bar .title.title-left { text-align: left; } + .bar .title.title-right { + text-align: right; } .bar .title a { color: inherit; } .bar .button { diff --git a/dist/js/ionic.js b/dist/js/ionic.js index bc2a115336..29cb8f7712 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -2882,17 +2882,8 @@ window.ionic = { var _this = this; window.rAF(ionic.proxy(function() { - var i, c, childSize, childStyle; - var children = this.el.children; + var i, c, childSize; var childNodes = this.el.childNodes; - var styles = window.getComputedStyle(this.el, null); - - // Get the padding of the header for calculations - var paddingLeft = parseFloat(styles['paddingLeft']); - var paddingRight = parseFloat(styles['paddingRight']); - - // Get the full width of the header - var headerWidth = this.el.offsetWidth; // Find the title element var title = this.el.querySelector('.title'); @@ -2902,7 +2893,7 @@ window.ionic = { var leftWidth = 0; var rightWidth = 0; - var titlePos = Array.prototype.indexOf.call(this.el.childNodes, title); + var titlePos = Array.prototype.indexOf.call(childNodes, title); // Compute how wide the left children are for(i = 0; i < titlePos; i++) { @@ -2937,21 +2928,26 @@ window.ionic = { // Size and align the header title based on the sizes of the left and // right children, and the desired alignment mode if(this.alignTitle == 'center') { - title.style.left = margin + 'px'; - title.style.right = margin + 'px'; - + if(margin > 10) { + title.style.left = margin + 'px'; + title.style.right = margin + 'px'; + } if(title.offsetWidth < title.scrollWidth) { - title.style.textAlign = 'left'; - title.style.right = (rightWidth + 5) + 'px'; - } else { - title.style.textAlign = 'center'; + title.classList.add('title-left'); + if(rightWidth > 0) { + title.style.right = (rightWidth + 5) + 'px'; + } } } else if(this.alignTitle == 'left') { - title.style.textAlign = 'left'; - title.style.left = (leftWidth + 15) + 'px'; + title.classList.add('title-left'); + if(leftWidth > 0) { + title.style.left = (leftWidth + 15) + 'px'; + } } else if(this.alignTitle == 'right') { - title.style.textAlign = 'right'; - title.style.right = (rightWidth + 15) + 'px'; + title.classList.add('title-right'); + if(rightWidth > 0) { + title.style.right = (rightWidth + 15) + 'px'; + } } }, this)); } diff --git a/js/views/headerBarView.js b/js/views/headerBarView.js index d63df4d2e0..10ecfb6a37 100644 --- a/js/views/headerBarView.js +++ b/js/views/headerBarView.js @@ -21,17 +21,8 @@ var _this = this; window.rAF(ionic.proxy(function() { - var i, c, childSize, childStyle; - var children = this.el.children; + var i, c, childSize; var childNodes = this.el.childNodes; - var styles = window.getComputedStyle(this.el, null); - - // Get the padding of the header for calculations - var paddingLeft = parseFloat(styles['paddingLeft']); - var paddingRight = parseFloat(styles['paddingRight']); - - // Get the full width of the header - var headerWidth = this.el.offsetWidth; // Find the title element var title = this.el.querySelector('.title'); @@ -41,7 +32,7 @@ var leftWidth = 0; var rightWidth = 0; - var titlePos = Array.prototype.indexOf.call(this.el.childNodes, title); + var titlePos = Array.prototype.indexOf.call(childNodes, title); // Compute how wide the left children are for(i = 0; i < titlePos; i++) { @@ -76,21 +67,26 @@ // Size and align the header title based on the sizes of the left and // right children, and the desired alignment mode if(this.alignTitle == 'center') { - title.style.left = margin + 'px'; - title.style.right = margin + 'px'; - + if(margin > 10) { + title.style.left = margin + 'px'; + title.style.right = margin + 'px'; + } if(title.offsetWidth < title.scrollWidth) { - title.style.textAlign = 'left'; - title.style.right = (rightWidth + 5) + 'px'; - } else { - title.style.textAlign = 'center'; + title.classList.add('title-left'); + if(rightWidth > 0) { + title.style.right = (rightWidth + 5) + 'px'; + } } } else if(this.alignTitle == 'left') { - title.style.textAlign = 'left'; - title.style.left = (leftWidth + 15) + 'px'; + title.classList.add('title-left'); + if(leftWidth > 0) { + title.style.left = (leftWidth + 15) + 'px'; + } } else if(this.alignTitle == 'right') { - title.style.textAlign = 'right'; - title.style.right = (rightWidth + 15) + 'px'; + title.classList.add('title-right'); + if(rightWidth > 0) { + title.style.right = (rightWidth + 15) + 'px'; + } } }, this)); } diff --git a/scss/_bar.scss b/scss/_bar.scss index a16393b91a..5b4f3287fe 100644 --- a/scss/_bar.scss +++ b/scss/_bar.scss @@ -90,7 +90,7 @@ z-index: 0; overflow: hidden; - margin: 0; + margin: 0 10px; min-width: 30px; @@ -107,6 +107,9 @@ &.title-left { text-align: left; } + &.title-right { + text-align: right; + } } .title a {