diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-12 11:22:18 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-12 11:22:40 +0100 |
commit | a75e37f56963bc55faf182811237cee8a4172fb7 (patch) | |
tree | 2c4048d9ffc6188d6886cafa4f4c4c38b089a1a8 /coffee | |
parent | a1e85b1e4cc145e65575c08702f2e72f5ced1235 (diff) |
slide areas with jquery and slide click directive
Diffstat (limited to 'coffee')
-rw-r--r-- | coffee/directives/clickslidetoggle.coffee | 46 | ||||
-rw-r--r-- | coffee/directives/hidesettingswhenfocuslost.coffee | 30 |
2 files changed, 46 insertions, 30 deletions
diff --git a/coffee/directives/clickslidetoggle.coffee b/coffee/directives/clickslidetoggle.coffee new file mode 100644 index 000000000..cea8560c0 --- /dev/null +++ b/coffee/directives/clickslidetoggle.coffee @@ -0,0 +1,46 @@ +### +# ownCloud news app +# +# @author Alessandro Cosentino +# @author Bernhard Posselt +# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> +# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> +# +# This file is licensed under the Affero General Public License version 3 or +# later. +# +# See the COPYING-README file +# +### + +### +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', -> + + return (scope, elm, attr) -> + options = scope.$eval(attr.clickSlideToggle) + + if angular.isDefined(options.selector) + slideArea = $(options.selector) + else + slideArea = elm + + elm.click -> + if slideArea.is(':visible') and not slideArea.is(':animated') + slideArea.slideUp() + else + slideArea.slideDown() + + if angular.isDefined(options.hideOnFocusLost) and options.hideOnFocusLost + $(document.body).click -> + if slideArea.is(':visible') and not slideArea.is(':animated') + slideArea.slideUp() + + slideArea.click (e) -> + e.stopPropagation() + + elm.click (e) -> + e.stopPropagation() diff --git a/coffee/directives/hidesettingswhenfocuslost.coffee b/coffee/directives/hidesettingswhenfocuslost.coffee deleted file mode 100644 index 0a1f92fdf..000000000 --- a/coffee/directives/hidesettingswhenfocuslost.coffee +++ /dev/null @@ -1,30 +0,0 @@ -### -# ownCloud news app -# -# @author Alessandro Cosentino -# @author Bernhard Posselt -# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> -# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> -# -# This file is licensed under the Affero General Public License version 3 or -# later. -# -# See the COPYING-README file -# -### - -### -# 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', -($rootScope) -> - - return (scope, elm, attr) -> - $(document.body).click -> - $rootScope.$broadcast('hidesettings') - scope.$apply attr.hideSettingsWhenFocusLost - - $(elm).click (e) -> - e.stopPropagation() -] |