diff --git a/NEWS b/NEWS index 9c0cb7c..5826e01 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ 1.6.0: January ??, 2009 * Switching between notebooks and loading notebooks is now much faster. + * New keyboard shortcuts for switching to next open note and previous open + note: Page down and page up. * Fixed various bugs related to the subscription page. 1.5.12: December 30, 2008 diff --git a/static/js/Editor.js b/static/js/Editor.js index 0cc4055..206fb3f 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -100,6 +100,7 @@ Editor.prototype.create_div = function ( position_after ) { this.holder = getElement( "note_holder_" + this.id ); this.connect_note_controls( true ); this.div = static_note_div; + this.div.editor = this; static_contents = getFirstElementByTagAndClassName( "span", "static_note_contents", this.div ); if ( static_contents && static_contents.innerHTML != this.initial_text ) static_contents.innerHTML = this.initial_text; @@ -615,6 +616,9 @@ Editor.prototype.query_command_value = function ( command ) { // resize the editor's frame to fit the dimensions of its content Editor.prototype.resize = function ( get_height_from_div ) { if ( !this.document ) return; + + this.reposition(); + var height = null; var width = elementDimensions( this.div.parentNode ).w; @@ -642,10 +646,11 @@ Editor.prototype.resize = function ( get_height_from_div ) { setElementDimensions( this.div, size ); var self = this; - this.reposition(); } Editor.prototype.reposition = function ( repeat ) { + if ( !this.iframe ) return; + // give the iframe the exact same position as the div it replaces. subtract the position of the // center_content_area container, which is relatively positioned var position = getElementPosition( this.div ); diff --git a/static/js/Wiki.js b/static/js/Wiki.js index fca24cd..2ccf617 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1140,6 +1140,32 @@ Wiki.prototype.editor_key_pressed = function ( editor, event ) { editor.exec_command( "indent" ); event.stop(); + // page up: previous note + } else if ( code == 33 ) { + event.stop(); + + if ( !this.focused_editor ) return; + var previous_holder = this.focused_editor.holder.previousSibling; + if ( !previous_holder ) return; + if ( !hasElementClass( previous_holder, "note_holder" ) ) + previous_holder = previous_holder.previousSibling; + if ( !previous_holder || !hasElementClass( previous_holder, "note_holder" ) ) return; + var div = getFirstElementByTagAndClassName( "div", "static_note_div", previous_holder ); + if ( !div || !div.editor ) return; + div.editor.highlight(); + // page down: next note + } else if ( code == 34 ) { + event.stop(); + + if ( !this.focused_editor ) return; + var next_holder = this.focused_editor.holder.nextSibling; + if ( !next_holder ) return; + if ( !hasElementClass( next_holder, "note_holder" ) ) + next_holder = next_holder.nextSibling; + if ( !next_holder || !hasElementClass( next_holder, "note_holder" ) ) return; + var div = getFirstElementByTagAndClassName( "div", "static_note_div", next_holder ); + if ( !div || !div.editor ) return; + div.editor.highlight(); // IE: hitting space while making a link shouldn't end the link } else if ( code == 32 && editor.document.selection && editor.state_enabled( "a" ) ) { var range = editor.document.selection.createRange();