summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-23 18:49:16 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-23 18:49:16 +0200
commitdb1511a11d7fe89dbb8cdbff1fd6c08c894c2f9d (patch)
tree82a720d31107d1e62f305073329a6ba15f098f79 /core
parent71e1d919de274e30aa043dc6cae67d4e993b2f26 (diff)
downloadnextcloud-server-db1511a11d7fe89dbb8cdbff1fd6c08c894c2f9d.tar.gz
nextcloud-server-db1511a11d7fe89dbb8cdbff1fd6c08c894c2f9d.zip
add a slideup mechanism
Diffstat (limited to 'core')
-rw-r--r--core/js/app.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/core/js/app.js b/core/js/app.js
new file mode 100644
index 00000000000..8f3f04187b7
--- /dev/null
+++ b/core/js/app.js
@@ -0,0 +1,65 @@
+/**
+ * ownCloud - core
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+
+(function (document, $) {
+
+ 'use strict';
+
+ /**
+ * Provides a way to slide down a target area through a button and slide it
+ * up if the user clicks somewhere else. Used for the news app settings and
+ * add new field.
+ *
+ * Usage:
+ * <button data-apps-slide-toggle=".slide-area">slide</button>
+ * <div class=".slide-area" class="hidden">I'm sliding up</div>
+ */
+ var registerAppsSlideToggle = function () {
+ // use only buttons that are already in the dom
+ var buttons = $('[data-apps-slide-toggle]');
+
+ $(document).click(function (event) {
+
+ buttons.each(function (index, button) {
+
+ var areaSelector = $(button).data('apps-slide-toggle');
+ var area = $(areaSelector);
+
+ // do nothing if the area is animated
+ if (!area.is(':animated')) {
+
+ // button slides up the area
+ if (button === event.target) {
+ if (area.is(':visible')) {
+ area.slideUp();
+ } else {
+ area.slideDown();
+ }
+
+ // all other areas that have not been clicked but are open
+ // should be slid up
+ } else {
+ var closest = ($(event.target).closest(areaSelector));
+ if (area.is(':visible') && closest[0] !== area[0]) {
+ area.slideUp();
+ }
+ }
+ }
+ });
+
+ });
+ }
+
+
+ $(document).ready(function () {
+ registerAppsSlideToggle();
+ });
+
+}(document, jQuery)); \ No newline at end of file