diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoFocus.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoFocus.directive.js new file mode 100644 index 0000000000..bf415ff25d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoFocus.directive.js @@ -0,0 +1,16 @@ +angular.module("umbraco.directives") + .directive('umbAutoFocus', function($timeout) { + + return function(scope, element, attr){ + var update = function() { + //if it uses its default naming + if(element.val() === ""){ + element.focus(); + } + }; + + $timeout(function() { + update(); + }); + }; +}); 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 new file mode 100644 index 0000000000..94bdc3f03d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/directives/editors/umbAutoResize.directive.js @@ -0,0 +1,32 @@ +angular.module("umbraco.directives") + .directive('umbAutoResize', function($timeout) { + + return function(scope, element, attr){ + var domEl = element[0]; + var update = function(force) { + + if(force === true){ + element.height(0); + } + + if(domEl.scrollHeight !== domEl.clientHeight){ + element.height(domEl.scrollHeight); + } + }; + + element.bind('keyup keydown keypress change', update); + element.bind('blur', function(){ update(true); }); + + $timeout(function() { + update(); + }, 100); + + + //I hate bootstrap tabs + $('a[data-toggle="tab"]').on('shown', update); + + scope.$on('$destroy', function() { + $('a[data-toggle="tab"]').unbind("shown", update); + }); + }; +}); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.controller.js index 8c5b6944a3..25b387d6be 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.controller.js @@ -2,17 +2,7 @@ angular.module("umbraco") .controller("Umbraco.PropertyEditors.Grid.TextStringController", function ($scope, $rootScope, $timeout, dialogService) { - $scope.adjustSize = function(ev){ - if(ev.target.scrollHeight > ev.target.clientHeight){ - $(ev.target).height(ev.target.scrollHeight); - } - }; - - if($scope.control.value === null){ - $timeout(function(){ - $("#" + $scope.control.uniqueId +"_text").focus(); - }, 200); - } + }); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.html index 9a63a1c7a5..03cb4f123e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/editors/textstring.html @@ -1,7 +1,9 @@