diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js index b79f738f28..c013a2020c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js @@ -23,7 +23,6 @@ angular.module("umbraco.directives") //I hate bootstrap tabs - //TODO: This is legacy since we aren't using bootstrap tabs anymore $('a[data-toggle="tab"]').on('shown', update); scope.$on('$destroy', function() { diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbeditorbuttons.js b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbeditorbuttons.js deleted file mode 100644 index 194f5a1fbf..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbeditorbuttons.js +++ /dev/null @@ -1,21 +0,0 @@ -/** -* @ngdoc directive -* @name umbraco.directives.directive:umbEditorButtons -* @restrict E -* @function -* @description -* The button holder for editors (i.e. save, update, etc...) -**/ -angular.module("umbraco.directives") - .directive('umbEditorButtons', function () { - return { - require: "^umbTabs", - restrict: 'E', - transclude: true, - template: '
', - link: function(scope, element, attrs, ngModel) { - - - } - }; - }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbtabs.js b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbtabs.js deleted file mode 100644 index 1083a80487..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbtabs.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @ngdoc directive -* @name umbraco.directives.directive:umbTabs -* @restrict E -* @function -* @description -* Used to control tab changes in editors, this directive must be placed around any editors' tabs (including header tabs and body tabs) -**/ -angular.module("umbraco.directives") - .directive('umbTabs', function() { - return { - //uses a controller to expose an API - controller: function ($scope, $attrs, $element, $parse) { - - //NOTE: This whole $parse strategy is the same type of thing used by ngModel, we need to use it - // because angular 1.1.5 is stupid. Normally we could just make a scope with =umbTags but that doesn't - // work for attribute type directives, seems to only work for element directives and I don't want this to - // be an element directive.... so we're using this. - var tabsValueGet = $parse($attrs.umbTabs); - - //internal props - - var activeTabId = null; - var tabCollectionChangedCallbacks = []; - var activeTabChangedCallbacks = []; - var firstRun = false; - var tabs = []; - - //public props/methods - - this.getActiveTab = function() { - return activeTabId; - }; - this.setActiveTab = function(tabId) { - activeTabId = tabId; - for (var callback in activeTabChangedCallbacks) { - activeTabChangedCallbacks[callback](activeTabId); - } - }; - this.onTabCollectionChanged = function (callback) { - tabCollectionChangedCallbacks.push(callback); - }; - this.onActiveTabChanged = function (callback) { - activeTabChangedCallbacks.push(callback); - }; - - $scope.$watch(function() { - return tabsValueGet($scope); - }, function (newValue, oldValue) { - if ((angular.isArray(newValue) && angular.isArray(oldValue) && newValue.length !== oldValue.length|| (newValue !== undefined && oldValue === undefined))) { - - tabs = []; //reset first - for (var val in newValue) { - var tab = { id: newValue[val].id, label: newValue[val].label }; - tabs.push(tab); - } - - //set active tab to the first one - one time - if (firstRun === false) { - firstRun = true; - if (tabs.length > 0) { - activeTabId = tabs[0].id; - for (var activeTabCallback in activeTabChangedCallbacks) { - activeTabChangedCallbacks[activeTabCallback](activeTabId); - } - } - } - - for (var callback in tabCollectionChangedCallbacks) { - tabCollectionChangedCallbacks[callback](tabs); - } - } - }); - - $scope.$on('$destroy', function () { - tabCollectionChangedCallbacks = []; - activeTabChangedCallbacks = []; - }); - - } - }; - }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbheader.directive.js index cf45e6b851..439f27e5ee 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbheader.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbheader.directive.js @@ -3,7 +3,6 @@ * @name umbraco.directives.directive:umbHeader * @restrict E * @function -* @deprecated since version 7.3 - use umbTabHeader instead * @description * The header on an editor that contains tabs using bootstrap tabs - THIS IS OBSOLETE, use umbTabHeader instead **/ diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtab.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtab.directive.js index 6d497b148c..f12544646b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtab.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtab.directive.js @@ -6,44 +6,9 @@ angular.module("umbraco.directives") .directive('umbTab', function ($parse, $timeout) { return { - require: "?^umbTabs", restrict: 'E', - replace: true, - scope: { - id : "@", - tabId : "@rel" - }, + replace: true, transclude: 'true', - templateUrl: 'views/directives/umb-tab.html', - link: function(scope, elem, attrs, tabsCtrl) { - - function toggleVisibility(tabId) { - //default if there are no tabs - if (tabId === null) { - elem.addClass("active"); - } - else { - if (scope.tabId === String(tabId)) { - elem.addClass("active"); - } - else { - elem.removeClass("active"); - } - } - } - - //need to make this optional for backwards compat since before we used to - // use bootstrap tabs and now we use our own better implementation which - // gives us far more control but will still support the old way. - if (tabsCtrl) { - - tabsCtrl.onActiveTabChanged(function (tabId) { - toggleVisibility(tabId); - }); - - toggleVisibility(tabsCtrl.getActiveTab()); - - } - } + templateUrl: 'views/directives/umb-tab.html' }; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabheader.directive.js deleted file mode 100644 index 738a8fee18..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabheader.directive.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @ngdoc directive -* @name umbraco.directives.directive:umbTabHeader -* @restrict E -* @function -* @description -* The header on an editor that contains tabs -**/ -angular.module("umbraco.directives").directive('umbTabHeader', function($parse, $timeout) { - return { - require: "?^umbTabs", - restrict: 'E', - replace: true, - transclude: 'true', - templateUrl: 'views/directives/umb-tab-header.html', - link: function(scope, iElement, iAttrs, tabsCtrl) { - - scope.showTabs = false; - scope.activeTabId = null; - scope.tabs = []; - - if (tabsCtrl) { - tabsCtrl.onTabCollectionChanged(function (tabs) { - scope.tabs = tabs; - scope.showTabs = scope.tabs.length > 0; - }); - - tabsCtrl.onActiveTabChanged(function (tabId) { - scope.activeTabId = tabId; - }); - - scope.changeTab = function (tabId) { - tabsCtrl.setActiveTab(tabId); - }; - - //TODO: We'll need to destroy this I'm assuming! - iElement.find('.nav-pills, .nav-tabs').tabdrop(); - } - - } - }; -}); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabview.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabview.directive.js index 035725a9c2..7bb4f1cb18 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabview.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbtabview.directive.js @@ -5,31 +5,10 @@ **/ angular.module("umbraco.directives") .directive('umbTabView', function($timeout, $log){ - return { - require: "?^umbTabs", + return { restrict: 'E', replace: true, transclude: 'true', - templateUrl: 'views/directives/umb-tab-view.html', - compile: function () { - return { - pre: function (scope, iElement, iAttrs, tabsCtrl) { - //if we have our custom tab directive it means we are not using bootstrap - // tabs, however if there isn't a directive we'll continue using bootsrap tabs - // this is done by adding 'tab-content' class for bootstrap or 'umb-tab-content' - // for our custom tabs. - - //We also MUST do this on pre-linking because the tab-content class needs to be there - // before it hits the DOM so that bootstrap can do whatever it is that it does. - - if (tabsCtrl) { - iElement.children("div:first").addClass("umb-tab-content"); - } - else { - iElement.children("div:first").addClass("tab-content"); - } - } - }; - } + templateUrl: 'views/directives/umb-tab-view.html' }; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js index b7f01a1a44..cdd766088c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/util/detectfold.directive.js @@ -7,15 +7,25 @@ angular.module("umbraco.directives.html") .directive('detectFold', function ($timeout, $log, windowResizeListener) { return { - require: "^?umbTabs", restrict: 'A', link: function (scope, el, attrs) { - var state = false; + var firstRun = false; var parent = $(".umb-panel-body"); var winHeight = $(window).height(); - var calculate = function() { + var calculate = function () { + + console.log("calculating..."); + if (el && el.is(":visible") && !el.hasClass("umb-bottom-bar")) { + + //now that the element is visible, set the flag in a couple of seconds, + // this will ensure that loading time of a current tab get's completed and that + // we eventually stop watching to save on CPU time + $timeout(function() { + firstRun = true; + }, 4000); + //var parent = el.parent(); var hasOverflow = parent.innerHeight() < parent[0].scrollHeight; //var belowFold = (el.offset().top + el.height()) > winHeight; @@ -23,21 +33,42 @@ angular.module("umbraco.directives.html") el.addClass("umb-bottom-bar"); } } + return firstRun; }; var resizeCallback = function(size) { winHeight = size.height; el.removeClass("umb-bottom-bar"); - //state = false; calculate(); }; windowResizeListener.register(resizeCallback); + //Only execute the watcher if this tab is the active (first) tab on load, otherwise there's no reason to execute + // the watcher since it will be recalculated when the tab changes! + if (el.closest(".umb-tab-pane").index() === 0) { + //run a watcher to ensure that the calculation occurs until it's firstRun but ensure + // the calculations are throttled to save a bit of CPU + var listener = scope.$watch(_.throttle(calculate, 1000), function (newVal, oldVal) { + if (newVal !== oldVal) { + //cancel the watch + console.log("WATCH CANCEL"); + listener(); + } + }); + } //Required for backwards compat for bootstrap tabs $('a[data-toggle="tab"]').on('shown', calculate); + $('.nav-tabs a').on('shown', function (event) { + console.log("TAB SHOWN 1"); + }); + + $('.nav-tabs a').on('shown.bs.tab', function (event) { + console.log("TAB SHOWN"); + }); + //ensure to unregister scope.$on('$destroy', function() { windowResizeListener.unregister(resizeCallback); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/windowresizelistener.service.js b/src/Umbraco.Web.UI.Client/src/common/services/windowresizelistener.service.js index f7f0a01a8a..3b86510173 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/windowresizelistener.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/windowresizelistener.service.js @@ -36,11 +36,9 @@ function windowResizeListener($rootScope) { } }, unregister: function (fn) { - for (var i = 0, cnt = registered.length; i < cnt; i++) { - if (registered[i] === fn) { - delete registered[i]; - break; - } + var index = registered.indexOf(fn); + if (index > -1) { + registered.splice(index, 1); } } }; diff --git a/src/Umbraco.Web.UI.Client/src/less/navs.less b/src/Umbraco.Web.UI.Client/src/less/navs.less index 004aa1b79b..c79f4b6420 100644 --- a/src/Umbraco.Web.UI.Client/src/less/navs.less +++ b/src/Umbraco.Web.UI.Client/src/less/navs.less @@ -330,8 +330,7 @@ .tabbable { .clearfix(); } -.tab-content, -.umb-tab-content { +.tab-content { overflow: auto; // prevent content from running below tabs } @@ -344,13 +343,11 @@ // Show/hide tabbable areas .tab-content > .tab-pane, -.pill-content > .pill-pane, -.umb-tab-content > .tab-pane { +.pill-content > .pill-pane { display: none; } .tab-content > .active, -.pill-content > .active, -.umb-tab-content > .active { +.pill-content > .active { display: block; } diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html b/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html index d0bafa289c..0ee402a63f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html @@ -1,10 +1,10 @@