From 2732e262f0c0ac96ba3be01d8837d06fa5016efd Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 30 Aug 2007 20:17:10 +0000 Subject: [PATCH] IE now properly shows link pulldown when you end a link. Also, in all browsers, now silently refusing to close a pulldown upon request when it's been open less than a quarter second. --- static/js/Editor.js | 3 ++- static/js/Wiki.js | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/static/js/Editor.js b/static/js/Editor.js index 10cc047..1d09856 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -394,6 +394,7 @@ Editor.prototype.end_link = function () { } signal( this, "resolve_link", link_title( link ), link ); + return link; } Editor.prototype.find_link_at_cursor = function () { @@ -513,7 +514,7 @@ Editor.prototype.shutdown = function( event ) { // convenience function for parsing a link that has an href URL containing a query string function parse_query( link ) { - if ( !link.href ) + if ( !link || !link.href ) return new Array(); return parseQueryString( link.href.split( "?" ).pop() ); diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 75e6135..58113d0 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -420,8 +420,9 @@ Wiki.prototype.editor_title_changed = function ( editor, old_title, new_title ) this.open_editors[ new_title ] = editor; } -Wiki.prototype.display_link_pulldown = function ( editor ) { - var link = editor.find_link_at_cursor(); +Wiki.prototype.display_link_pulldown = function ( editor, link ) { + if ( !link ) + link = editor.find_link_at_cursor(); if ( !link ) { this.clear_pulldowns(); @@ -546,6 +547,7 @@ Wiki.prototype.update_toolbar = function() { Wiki.prototype.toggle_link_button = function ( event ) { this.clear_messages(); this.clear_pulldowns(); + var link = null; if ( this.focused_editor && this.focused_editor.read_write ) { this.focused_editor.focus(); @@ -553,9 +555,9 @@ Wiki.prototype.toggle_link_button = function ( event ) { if ( hasElementClass( "createLink", "button_down" ) ) this.focused_editor.start_link(); else - this.focused_editor.end_link(); + link = this.focused_editor.end_link(); - this.display_link_pulldown( this.focused_editor ); + this.display_link_pulldown( this.focused_editor, link ); } event.stop(); @@ -856,7 +858,10 @@ Wiki.prototype.clear_pulldowns = function () { for ( var i in results ) { var result = results[ i ]; - result.pulldown.shutdown(); + + // close the pulldown if it's been open at least a quarter second + if ( new Date() - result.pulldown.init_time >= 250 ) + result.pulldown.shutdown(); } } @@ -898,6 +903,7 @@ function Pulldown( wiki, notebook_id, pulldown_id, anchor, relative_to ) { this.notebook_id = notebook_id; this.div = createDOM( "div", { "id": pulldown_id, "class": "pulldown" } ); this.div.pulldown = this; + this.init_time = new Date(); this.anchor = anchor; this.relative_to = relative_to;