Merge pull request #1059 from umbraco/temp-U4-7832-U4-7772

Fixes: U4-7772 Cursor jumps when editing alias in new ContentType edi…
This commit is contained in:
Claus
2016-01-27 15:12:23 +01:00
3 changed files with 34 additions and 27 deletions

View File

@@ -0,0 +1,28 @@
(function() {
'use strict';
function SelectWhen($timeout) {
function link(scope, el, attr, ctrl) {
attr.$observe("umbSelectWhen", function(newValue) {
if (newValue === "true") {
$timeout(function() {
el.select();
});
}
});
}
var directive = {
restrict: 'A',
link: link
};
return directive;
}
angular.module('umbraco.directives').directive('umbSelectWhen', SelectWhen);
})();

View File

@@ -24,12 +24,10 @@
// scope object, but that would mean we'd have to watch that value too in order to set the outer
// ngModelCtrl.$modelValue. It's seems like less overhead to just do this and not have 2x watches.
scope.lockedFieldForm.lockedField.$modelValue = undefined;
scope.lockedFieldForm.lockedField.$setViewValue(newValue);
scope.lockedFieldForm.lockedField.$render();
scope.lockedFieldForm.lockedField.$render();
}
scope.lockedFieldForm.lockedField.$setViewValue(scope.lockedFieldForm.lockedField.$modelValue);
});
var input = el.find('.umb-locked-field__input');
function activate() {
@@ -57,36 +55,14 @@
scope.lock = function() {
scope.locked = true;
input.unbind("blur");
};
scope.unlock = function() {
scope.locked = false;
autoFocusField();
};
function autoFocusField() {
var onBlurHandler = function() {
scope.$apply(function(){
scope.lock();
});
};
$timeout(function() {
input.focus();
input.select();
input.on("blur", onBlurHandler);
});
}
activate();
scope.$on('$destroy', function() {
input.unbind('blur');
});
}
var directive = {

View File

@@ -21,7 +21,10 @@
umb-auto-resize
required
val-server-field="{{serverValidationField}}"
title="{{ngModel}}" />
title="{{ngModel}}"
focus-when="{{!locked}}"
umb-select-when="{{!locked}}"
on-blur="lock()" />
</div>