diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbpanel.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbpanel.directive.js index 2d399a063b..a78902e26a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbpanel.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbpanel.directive.js @@ -4,11 +4,59 @@ * @restrict E **/ angular.module("umbraco.directives.html") - .directive('umbPanel', function(){ + .directive('umbPanel', function($timeout){ return { restrict: 'E', replace: true, transclude: 'true', - templateUrl: 'views/directives/html/umb-panel.html' + templateUrl: 'views/directives/html/umb-panel.html', + link: function (scope, el, attrs) { + + function _setClass(resize){ + var bar = $(".tab-content .active .umb-tab-buttons"); + + //incase this runs without any tabs + if(bar.length === 0){ + bar = $(".tab-content .umb-tab-buttons"); + } + + //no need to process + if(resize){ + bar.removeClass("umb-bottom-bar"); + } + + //already positioned + if(bar.hasClass("umb-bottom-bar")){ + return; + } + + var offset = bar.offset(); + + if(offset){ + var bottom = bar.offset().top + bar.height(); + if(bottom > $(window).height()){ + bar.addClass("umb-bottom-bar"); + $(".tab-content .active").addClass("with-buttons"); + }else{ + bar.removeClass("umb-bottom-bar"); + $(".tab-content .active").removeClass("with-buttons"); + } + } + } + + + //initial loading + $timeout(function(){ + $('a[data-toggle="tab"]').on('shown', function (e) { + _setClass(); + }); + _setClass(); + }, 1000, false); + + + $(window).bind("resize", function () { + _setClass(true); + }); + } }; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbtabview.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbtabview.directive.js index 32f384c4d9..505acb3328 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbtabview.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbtabview.directive.js @@ -9,50 +9,6 @@ angular.module("umbraco.directives") restrict: 'E', replace: true, transclude: 'true', - templateUrl: 'views/directives/umb-tab-view.html', - - link: function (scope, el, attrs) { - - function _setClass(resize){ - var bar = $(".tab-content .active .umb-tab-buttons"); - - //no need to process - if(resize){ - bar.removeClass("umb-bottom-bar"); - } - - //already positioned - if(bar.hasClass("umb-bottom-bar")){ - return; - } - - var offset = bar.offset(); - - if(offset){ - var bottom = bar.offset().top + bar.height(); - if(bottom > $(window).height()){ - bar.addClass("umb-bottom-bar"); - $(".tab-content .active").addClass("with-buttons"); - }else{ - bar.removeClass("umb-bottom-bar"); - $(".tab-content .active").removeClass("with-buttons"); - } - } - } - - - //initial loading - $timeout(function(){ - $('a[data-toggle="tab"]').on('shown', function (e) { - _setClass(); - }); - - _setClass(); - }, 500, false); - - $(window).bind("resize", function () { - _setClass(true); - }); - } + templateUrl: 'views/directives/umb-tab-view.html' }; }); \ No newline at end of file