summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-02-12 15:24:15 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-02-12 15:25:11 +0100
commita658eac21f9b2131750f9253ca2a608454d355f4 (patch)
tree5738b542e03da4831a3ac50468fc9c2be2d62531 /js
parente904f00e2002d12d7e5b7b9632e964ce2825e498 (diff)
also slide down other elements that have the click slide handler and listeners on focus lost when an element wit this directive is clicked
Diffstat (limited to 'js')
-rw-r--r--js/app.js59
1 files changed, 34 insertions, 25 deletions
diff --git a/js/app.js b/js/app.js
index 7f5108375..d715aa06f 100644
--- a/js/app.js
+++ b/js/app.js
@@ -2249,37 +2249,46 @@
*/
- angular.module('News').directive('clickSlideToggle', function() {
- return function(scope, elm, attr) {
- var options, slideArea;
- options = scope.$eval(attr.clickSlideToggle);
- if (angular.isDefined(options.selector)) {
- slideArea = $(options.selector);
- } else {
- slideArea = elm;
- }
- elm.click(function() {
- if (slideArea.is(':visible') && !slideArea.is(':animated')) {
- return slideArea.slideUp();
+ angular.module('News').directive('clickSlideToggle', [
+ '$rootScope', function($rootScope) {
+ return function(scope, elm, attr) {
+ var options, slideArea;
+ options = scope.$eval(attr.clickSlideToggle);
+ if (angular.isDefined(options.selector)) {
+ slideArea = $(options.selector);
} else {
- return slideArea.slideDown();
+ slideArea = elm;
}
- });
- if (angular.isDefined(options.hideOnFocusLost) && options.hideOnFocusLost) {
- $(document.body).click(function() {
+ elm.click(function() {
if (slideArea.is(':visible') && !slideArea.is(':animated')) {
return slideArea.slideUp();
+ } else {
+ return slideArea.slideDown();
}
});
- slideArea.click(function(e) {
- return e.stopPropagation();
- });
- return elm.click(function(e) {
- return e.stopPropagation();
- });
- }
- };
- });
+ if (angular.isDefined(options.hideOnFocusLost) && options.hideOnFocusLost) {
+ $(document.body).click(function() {
+ return $rootScope.$broadcast('lostFocus');
+ });
+ $rootScope.$on('lostFocus', function(scope, params) {
+ if (params !== slideArea) {
+ if (slideArea.is(':visible') && !slideArea.is(':animated')) {
+ return slideArea.slideUp();
+ }
+ }
+ });
+ slideArea.click(function(e) {
+ $rootScope.$broadcast('lostFocus', slideArea);
+ return e.stopPropagation();
+ });
+ return elm.click(function(e) {
+ $rootScope.$broadcast('lostFocus', slideArea);
+ return e.stopPropagation();
+ });
+ }
+ };
+ }
+ ]);
/*
# ownCloud news app