Fixes dialog service instant closing modals

This commit is contained in:
Per Ploug
2013-07-05 10:40:28 +02:00
parent d9e79666ca
commit 0030488b61
11 changed files with 120 additions and 49 deletions

View File

@@ -38,42 +38,14 @@ angular.module("umbraco.directives")
* @param n {object} The tree node object associated with the click
*/
scope.select = function(e,n,ev){
//here we need to check for some legacy tree code
if (n.jsClickCallback && n.jsClickCallback !== "") {
//this is a legacy tree node!
var jsPrefix = "javascript:";
var js;
if (n.jsClickCallback.startsWith(jsPrefix)) {
js = n.jsClickCallback.substr(jsPrefix.length);
}
else {
js = n.jsClickCallback;
}
try {
var func = eval(js);
//this is normally not necessary since the eval above should execute the method and will return nothing.
if (func != null && (typeof func === "function")) {
func.call();
}
}
catch(ex) {
$log.error("Error evaluating js callback from legacy tree node: " + ex);
}
}
else {
//not legacy, lets just set the route value
$location.path(n.view);
}
scope.$emit("treeNodeSelect", { element: e, node: n, event: ev });
};
scope.load = function (arrow, node) {
scope.load = function (arrow, node) {
if (node.expanded){
node.expanded = false;
node.children = [];
node.children = [];
}else {
@@ -86,9 +58,9 @@ angular.module("umbraco.directives")
node.children = data;
node.expanded = true;
}, function (reason) {
}, function (reason) {
// $(arrow).parent().remove(loader);
node.loading = false;
node.loading = false;
notificationsService.error(reason);
//alert(reason);

View File

@@ -1,8 +1,20 @@
angular.module('umbraco.services')
.factory('dialogService', ['$rootScope', '$compile', '$http', '$timeout', '$q', '$templateCache',
function($rootScope, $compile, $http, $timeout, $q, $templateCache) {
function($rootScope, $compile, $http, $timeout, $q, $templateCache) {
function _open(options){
var _dialogs = [];
$rootScope.$on("closeDialogs", function () {
for (var i = 0; i < _dialogs.length; i++) {
var dialog = _dialogs[i];
dialog.modal("hide");
dialog.remove();
$("#" + dialog.attr("id")).remove();
_dialogs.splice(i,1);
}
});
function _open(options){
if(!options){
options = {};
}
@@ -21,17 +33,14 @@ angular.module('umbraco.services')
.addClass(animationClass)
.addClass(modalClass);
$rootScope.$on("closeDialogs", function () {
$modal.modal("hide");
$modal.remove();
$("#" + $modal.attr("id")).remove();
});
_dialogs.push($modal);
if(options.iframe) {
var html = $("<iframe auto-scale='0' src='" + templateUrl + "' style='width: 100%; height: 100%;'></iframe>");
$modal.html(html);
$('body').append($modal);
if(width){

View File

@@ -19,8 +19,10 @@
<div ng-view></div>
</div>
</section>
</div>
<umb-notifications></umb-notifications>

View File

@@ -3,11 +3,10 @@
angular.module('umbraco')
.controller("uComponents.Editors.MNTPController",
function($scope, dialogService){
alert("node!");
$scope.openContentPicker =function(value){
var d = dialogService.contentPicker({scope: $scope, callback: populate});
var s = d;
};
function populate(data){

View File

@@ -3,7 +3,9 @@ angular.module("umbraco").controller("Umbraco.Dialogs.ContentPickerController",
function ($scope) {
$scope.$on("treeNodeSelect", function(event, args){
args.event.preventDefault();
args.event.preventDefault();
args.event.stopPropagation();
$(args.event.target.parentElement).find("i.umb-tree-icon").attr("class", "icon umb-tree-icon sprTree icon-check blue");
$scope.select(args.node);
});

View File

@@ -25,7 +25,11 @@ function MainController($scope, $routeParams, $rootScope, $timeout, notification
};
$scope.closeDialogs = function (event) {
$rootScope.$emit("closeDialogs");
//only close dialogs if non-lin and non-buttons are clicked
if(event.target.nodeName != "A" && event.target.nodeName != "BUTTON"){
$rootScope.$emit("closeDialogs");
}
if (navigationService.ui.stickyNavigation && $(event.target).parents(".umb-modalcolumn").size() == 0) {
navigationService.hideNavigation();

View File

@@ -9,7 +9,7 @@
*
* @param navigationService {navigationService} A reference to the navigationService
*/
function NavigationController($scope, navigationService, sectionResource) {
function NavigationController($scope, $location, navigationService, sectionResource) {
//load navigation service handlers
$scope.changeSection = navigationService.changeSection;
$scope.showTree = navigationService.showTree;
@@ -32,12 +32,49 @@ function NavigationController($scope, navigationService, sectionResource) {
});
//events
//this reacts to the options item in the tree
$scope.$on("treeOptionsClick", function (ev, args) {
$scope.currentNode = args.node;
args.scope = $scope;
navigationService.showMenu(ev, args);
});
//this reacts to tree items themselves being clicked
//the tree directive should not contain any handling, simply just bubble events
$scope.$on("treeNodeSelect", function (ev, args) {
var n = args.node;
//here we need to check for some legacy tree code
if (n.jsClickCallback && n.jsClickCallback !== "") {
//this is a legacy tree node!
var jsPrefix = "javascript:";
var js;
if (n.jsClickCallback.startsWith(jsPrefix)) {
js = n.jsClickCallback.substr(jsPrefix.length);
}
else {
js = n.jsClickCallback;
}
try {
var func = eval(js);
//this is normally not necessary since the eval above should execute the method and will return nothing.
if (func != null && (typeof func === "function")) {
func.call();
}
}
catch(ex) {
$log.error("Error evaluating js callback from legacy tree node: " + ex);
}
}
else {
//not legacy, lets just set the route value
$location.path(n.view);
}
});
$scope.openDialog = function (currentNode, action, currentSection) {
navigationService.showDialog({
scope: $scope,