summaryrefslogtreecommitdiff
path: root/modules/contextual/contextual.js
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-06 01:00:27 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-06 01:00:27 +0000
commit66f740c58475b84b907326a0e50e4d91c2fc03ee (patch)
tree9e43dac217331cf78042de4edfefe7b56308086a /modules/contextual/contextual.js
parent882fa0ab33cec0aaa9ebe942cbfe759fcf8f4a4e (diff)
downloadbrdo-66f740c58475b84b907326a0e50e4d91c2fc03ee.tar.gz
brdo-66f740c58475b84b907326a0e50e4d91c2fc03ee.tar.bz2
- Patch #626286 by sun, David_Rothstein, Rob Loach: make contextual links a module.
Diffstat (limited to 'modules/contextual/contextual.js')
-rw-r--r--modules/contextual/contextual.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/modules/contextual/contextual.js b/modules/contextual/contextual.js
new file mode 100644
index 000000000..0dfc9ddfa
--- /dev/null
+++ b/modules/contextual/contextual.js
@@ -0,0 +1,42 @@
+// $Id$
+(function ($) {
+
+Drupal.contextualLinks = Drupal.contextualLinks || {};
+
+/**
+ * Attach outline behavior for regions associated with contextual links.
+ */
+Drupal.behaviors.contextualLinks = {
+ attach: function (context) {
+ $('div.contextual-links-wrapper', context).once('contextual-links', function () {
+ var $wrapper = $(this);
+ var $trigger = $('<a class="contextual-links-trigger" href="#" />').text(Drupal.t('Configure')).click(
+ function () {
+ $wrapper.find('ul.contextual-links').slideToggle(100);
+ $wrapper.toggleClass('contextual-links-active');
+ return false;
+ }
+ );
+ $wrapper.prepend($trigger)
+ .closest('.contextual-links-region').hover(Drupal.contextualLinks.hover, Drupal.contextualLinks.hoverOut);
+ });
+ }
+};
+
+/**
+ * Enables outline for the region contextual links are associated with.
+ */
+Drupal.contextualLinks.hover = function () {
+ $(this).closest('.contextual-links-region').addClass('contextual-links-region-active');
+};
+
+/**
+ * Disables outline for the region contextual links are associated with.
+ */
+Drupal.contextualLinks.hoverOut = function () {
+ $(this).closest('.contextual-links-region').removeClass('contextual-links-region-active')
+ .find('.contextual-links-active').removeClass('contextual-links-active')
+ .find('ul.contextual-links').hide();
+};
+
+})(jQuery);