angular-stackables
Advanced tools
Comparing version 0.0.27 to 0.0.28
{ | ||
"name": "angular-stackables", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"description": "AngularJS stackable widgets built on HTML5 dialog.", | ||
@@ -11,3 +11,3 @@ "authors": [ | ||
"dependencies": { | ||
"angular": "1.3.0-rc.0", | ||
"angular": "1.3.0-rc.4", | ||
"dialog-polyfill": "0.2.0" | ||
@@ -14,0 +14,0 @@ }, |
{ | ||
"name": "angular-stackables", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"dependencies": {} | ||
} |
@@ -35,3 +35,2 @@ /*! | ||
self.link = function(scope, element) { | ||
self.scope = scope; | ||
scope.stackable = self; | ||
@@ -142,20 +141,20 @@ | ||
}); | ||
}; | ||
// close the stackable unless 'closing' callback aborts | ||
self.close = function(err, result) { | ||
var closing = self.scope.closing || angular.noop; | ||
var shouldClose = closing.call(self.scope.$parent, { | ||
err: err, | ||
result: result | ||
}); | ||
Promise.resolve(shouldClose).then(function() { | ||
if(shouldClose !== false) { | ||
self.error = err; | ||
self.result = result; | ||
self.scope.show = false; | ||
self.scope.$apply(); | ||
} | ||
}); | ||
}; | ||
// close the stackable unless 'closing' callback aborts | ||
self.close = function(err, result) { | ||
var closing = scope.closing || angular.noop; | ||
var shouldClose = closing.call(scope.$parent, { | ||
err: err, | ||
result: result | ||
}); | ||
Promise.resolve(shouldClose).then(function() { | ||
if(shouldClose !== false) { | ||
self.error = err; | ||
self.result = result; | ||
scope.show = false; | ||
scope.$apply(); | ||
} | ||
}); | ||
}; | ||
} | ||
} | ||
@@ -264,4 +263,19 @@ } | ||
// watch state to reposition popover | ||
scope.$watch('state', watchState, true); | ||
// keep scope.state.show in-sync with show | ||
scope.$watch('show', function(value) { | ||
if(value !== undefined && scope.state) { | ||
scope.state.show = value; | ||
} | ||
}); | ||
// clean up any remaining handlers | ||
scope.$on('$destroy', function() { | ||
doc.off('keyup', closeOnEscape).off('click', closeOnClick); | ||
}); | ||
var doc = angular.element(document); | ||
scope.$watch('state', function(state) { | ||
function watchState(state) { | ||
if(state) { | ||
@@ -281,24 +295,5 @@ scope.show = state.show; | ||
// schedule repositioning | ||
setTimeout(function() { | ||
// only reposition if content is shown | ||
var content = element.find('.stackable-popover-content'); | ||
if(!content.length) { | ||
return; | ||
} | ||
reposition(content); | ||
}); | ||
}, true); | ||
setTimeout(repositionIfShown); | ||
} | ||
// keep scope.state.show in-sync with show | ||
scope.$watch('show', function(value) { | ||
if(value !== undefined && scope.state) { | ||
scope.state.show = value; | ||
} | ||
}); | ||
// clean up any remaining handlers | ||
scope.$on('$destroy', function() { | ||
doc.off('keyup', closeOnEscape).off('click', closeOnClick); | ||
}); | ||
function closeOnClick(e) { | ||
@@ -324,2 +319,11 @@ // close if target is not in the popover and trigger was not clicked | ||
function repositionIfShown() { | ||
// only reposition if content is shown | ||
var content = element.find('.stackable-popover-content'); | ||
if(!content.length) { | ||
return; | ||
} | ||
reposition(content); | ||
} | ||
function reposition(content) { | ||
@@ -326,0 +330,0 @@ var width = content.outerWidth(false); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26069
737