Fixes to media picker when creating new folders.
Changed to ngShow to ensure input field hides when blur event is hit. Clearing and switching visibility of input field on successful submit. Fixed up focus directive to use $timeout. The focus event can trigger before the element is rendered by angular so its safer to have a timeout ensure it is done at the end of the digest cycle - using $timeout instead of setTimeout ensures it is handled by angular at the right time.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @description Utillity directives for key and field events
|
||||
* @description Utility directives for key and field events
|
||||
**/
|
||||
angular.module('umbraco.directives')
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ angular.module("umbraco.directives").directive('focusWhen', function ($timeout)
|
||||
link: function (scope, elm, attrs, ctrl) {
|
||||
attrs.$observe("focusWhen", function (newValue) {
|
||||
if (newValue === "true") {
|
||||
elm.focus();
|
||||
$timeout(function() {
|
||||
elm.focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,11 +34,12 @@ angular.module("umbraco")
|
||||
$scope.submitFolder = function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
e.preventDefault();
|
||||
$scope.showFolderInput = false;
|
||||
|
||||
|
||||
mediaResource
|
||||
.addFolder($scope.newFolderName, $scope.options.formData.currentFolder)
|
||||
.then(function(data) {
|
||||
$scope.showFolderInput = false;
|
||||
$scope.newFolderName = "";
|
||||
|
||||
//we've added a new folder so lets clear the tree cache for that specific item
|
||||
treeService.clearCache({
|
||||
@@ -80,7 +81,7 @@ angular.module("umbraco")
|
||||
$scope.options.formData.currentFolder = folder.id;
|
||||
$scope.currentFolder = folder;
|
||||
};
|
||||
|
||||
|
||||
//This executes prior to the whole processing which we can use to get the UI going faster,
|
||||
//this also gives us the start callback to invoke to kick of the whole thing
|
||||
$scope.$on('fileuploadadd', function (e, data) {
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
|
||||
<input type="text"
|
||||
class="input-foldername input-mini inline"
|
||||
ng-if="showFolderInput"
|
||||
ng-show="showFolderInput"
|
||||
ng-model="newFolderName"
|
||||
ng-keydown="submitFolder($event)"
|
||||
on-blur="showFolderInput = false"
|
||||
|
||||
Reference in New Issue
Block a user