Skip to content

Commit

Permalink
The link picker dialog shouldn't close all other dialogs if already i…
Browse files Browse the repository at this point in the history
…nside a dialog (eg. LeBlender)
  • Loading branch information
abjerner committed May 9, 2017
1 parent 2dee641 commit 9b9c5aa
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
restrict: 'E',
replace: true,
templateUrl: '/App_Plugins/Skybrud.LinkPicker/Views/LinkPickerDirective.html',
link: function (scope) {
link: function (scope, element) {

function ancestorHasClass(e, className) {
var p = e.parentNode;
while (p != null) {
if (p.classList && p.classList.contains(className)) return true;
p = p.parentNode;
}
return false;
}

// Determine wether the link picker dialog should close all other dialogs (it shouldn't when already in another dialog/modal)
var closeAllDialogs = !ancestorHasClass(element[0], 'umb-modal');

var v = Umbraco.Sys.ServerVariables.application.version.split('.');
scope.umbVersion = parseFloat(v[0] + '.' + v[1]);
Expand Down Expand Up @@ -64,13 +76,13 @@
scope.addLink = function () {
p.addLink(function (link) {
scope.value.items.push(link);
});
}, closeAllDialogs);
};

scope.editLink = function (link, index) {
p.editLink(link, function (newLink) {
scope.value.items[index] = newLink;
});
}, closeAllDialogs);
};

scope.removeLink = function (index) {
Expand Down

0 comments on commit 9b9c5aa

Please sign in to comment.