From 1658d43d4cd9079c4f8fb8098efff8dfe5962cbd Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 22 Jan 2009 14:23:07 -0800 Subject: [PATCH] Now when an editor is focused, the toolbar buttons update accordingly. --- static/js/Editor.js | 9 ++++++--- static/js/Wiki.js | 8 ++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/static/js/Editor.js b/static/js/Editor.js index 59143bf..6f029a6 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -260,6 +260,7 @@ Editor.prototype.claim_iframe = function ( position_after, click_position ) { function finish_init() { self.position_cursor( click_position, range ); self.connect_handlers(); + signal( self, "focused", self ); } // this small delay gives the browser enough lag time after set_iframe_contents() to process the HTML @@ -351,7 +352,7 @@ Editor.prototype.position_cursor = function ( click_position, div_range ) { if ( this.init_focus ) { this.init_focus = false; if ( this.iframe ) - this.focus(); + this.focus( true ); } // if requested, move the text cursor to a specific location @@ -970,7 +971,7 @@ Editor.prototype.find_link_at_cursor = function () { return null; } -Editor.prototype.focus = function () { +Editor.prototype.focus = function ( suppress_signal ) { if ( this.div && this.edit_enabled ) this.claim_iframe(); @@ -983,7 +984,8 @@ Editor.prototype.focus = function () { this.iframe.contentWindow.focus(); } - signal( this, "focused", this ); + if ( !suppress_signal ) + signal( this, "focused", this ); } Editor.prototype.blur = function () { @@ -1028,6 +1030,7 @@ Editor.prototype.state_enabled = function ( state_name, node_names ) { Editor.prototype.current_node_names = function () { var node_names = new Array(); + console.log( this.edit_enabled, this.iframe, this.document ); if ( !this.edit_enabled || !this.iframe || !this.document ) return node_names; diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 89fea90..043176b 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1034,12 +1034,8 @@ Wiki.prototype.editor_focused = function ( editor, synchronous ) { } } - if ( !this.focused_editor ) { - this.focused_editor = editor; - this.update_toolbar(); - } else { - this.focused_editor = editor; - } + this.focused_editor = editor; + this.update_toolbar(); } Wiki.prototype.make_byline = function ( username, creation, note_id ) {