/[drupal]/contributions/modules/dblclick/dblclick.js
ViewVC logotype

Contents of /contributions/modules/dblclick/dblclick.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Tue Jan 16 02:13:14 2007 UTC (2 years, 10 months ago) by jjeff
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +10 -6 lines
File MIME type: text/javascript
#104705 fix for DHTML Menu compatibility - by Steve McKenzie
1 // $Id: dblclick.js,v 1.10 2006/12/12 18:25:29 jjeff Exp $
2
3 Drupal.dblClick = new Object();
4
5 Drupal.dblClick.clicker = function(e) {
6 var self = this;
7 if (!e.metaKey && !e.ctrlKey) { // don't do this stuff if meta or control key is pressed
8 var doClick = function() {
9 // allow other scripts to do their stuff
10 $return = typeof(self.oldclick) == 'function' ? self.oldclick() : true;
11 if ($return != false) { // if other scripts don't return false
12 location.href = self.href; // bug: safari doesn't stick this in the history
13 }
14 }
15 if (Drupal.dblClick.clickTimer) {
16 window.clearTimeout(Drupal.dblClick.clickTimer);
17 }
18 Drupal.dblClick.clickTimer = window.setTimeout(doClick, Drupal.settings.dblClick.dblTime);
19 return false;
20 }
21 }
22
23 Drupal.dblClick.dblClicker = function(e) {
24 var self = this;
25 window.clearTimeout(Drupal.dblClick.clickTimer);
26 var arg = (self.href.indexOf('?') == -1) ? '?dbl=true' : '&dbl=true';
27 var parts = self.href.split('#');
28 var path = parts.shift();
29 var frag = parts.shift();
30 if (frag) {
31 arg = arg + '&frag=' + frag;
32 frag = '#' + frag;
33 }
34 else {
35 frag = '';
36 }
37 arg += e.shiftKey ? '&shift=true' : '';
38 arg += e.altKey ? '&alt=true' : '';
39 arg += Drupal.settings.dblClick.dblDest ? Drupal.settings.dblClick.dblDest : '';
40 location.href = path + arg + frag;
41 return false;
42 }
43
44 if (Drupal.jsEnabled) {
45 // jQuery sweetness by the real John Resig.
46 jQuery.expr[":"].exclude = "$(m[3]).index(a)<0";
47
48 $(document).ready(function() {
49 // find all of the internal (relative) links
50 // move their old click behaviors into 'oldclick' so we can execute it later
51 // exclude blocks from dhtml_menu module because of conflicts
52 $('a[@href]:not("[@href*=":"]):not([@onclick]):exclude(div[@id^="block-dhtml_menu"] a)')
53 .each(function(){this.oldclick = this.onclick})
54 .unclick()
55 .click(Drupal.dblClick.clicker)
56 .dblclick(Drupal.dblClick.dblClicker);
57 });
58 }

  ViewVC Help
Powered by ViewVC 1.1.2