From a75e37f56963bc55faf182811237cee8a4172fb7 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 12 Feb 2013 11:22:18 +0100 Subject: slide areas with jquery and slide click directive --- js/app.js | 91 ++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 36 deletions(-) (limited to 'js') diff --git a/js/app.js b/js/app.js index ce8f161c7..7f5108375 100644 --- a/js/app.js +++ b/js/app.js @@ -2242,6 +2242,61 @@ */ + /* + Used to slide up an area and can be customized by passing an expression. + If selector is defined, a different area is slid up on click + If hideOnFocusLost is defined, the slid up area will hide when the focus is lost + */ + + + 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(); + } else { + return slideArea.slideDown(); + } + }); + if (angular.isDefined(options.hideOnFocusLost) && options.hideOnFocusLost) { + $(document.body).click(function() { + if (slideArea.is(':visible') && !slideArea.is(':animated')) { + return slideArea.slideUp(); + } + }); + slideArea.click(function(e) { + return e.stopPropagation(); + }); + return elm.click(function(e) { + return e.stopPropagation(); + }); + } + }; + }); + + /* + # ownCloud news app + # + # @author Alessandro Cosentino + # @author Bernhard Posselt + # Copyright (c) 2012 - Alessandro Cosentino + # Copyright (c) 2012 - Bernhard Posselt + # + # This file is licensed under the Affero General Public License version 3 or + # later. + # + # See the COPYING-README file + # + */ + + angular.module('News').directive('draggable', function() { return function(scope, elm, attr) { var details; @@ -2425,42 +2480,6 @@ */ - /* - # This is used to signal the settings bar that the app has been focused and that - # it should hide - */ - - - angular.module('News').directive('hideSettingsWhenFocusLost', [ - '$rootScope', function($rootScope) { - return function(scope, elm, attr) { - $(document.body).click(function() { - $rootScope.$broadcast('hidesettings'); - return scope.$apply(attr.hideSettingsWhenFocusLost); - }); - return $(elm).click(function(e) { - return e.stopPropagation(); - }); - }; - } - ]); - - /* - # ownCloud news app - # - # @author Alessandro Cosentino - # @author Bernhard Posselt - # Copyright (c) 2012 - Alessandro Cosentino - # Copyright (c) 2012 - Bernhard Posselt - # - # This file is licensed under the Affero General Public License version 3 or - # later. - # - # See the COPYING-README file - # - */ - - angular.module('News').directive('onEnter', function() { return function(scope, elm, attr) { return elm.bind('keyup', function(e) { -- cgit v1.2.3