In the font pulldown, now showing the current font with a check mark.
This commit is contained in:
parent
ef6b013342
commit
f385ebaa9c
|
@ -285,6 +285,10 @@ Editor.prototype.insert_html = function ( html ) {
|
|||
}
|
||||
}
|
||||
|
||||
Editor.prototype.query_command_value = function ( command ) {
|
||||
return this.document.queryCommandValue( command );
|
||||
}
|
||||
|
||||
// resize the editor's frame to fit the dimensions of its content
|
||||
Editor.prototype.resize = function () {
|
||||
if ( !this.document ) return;
|
||||
|
|
|
@ -4226,6 +4226,7 @@ function Font_pulldown( wiki, notebook_id, invoker, anchor, editor ) {
|
|||
anchor.pulldown = this;
|
||||
this.anchor = anchor;
|
||||
this.editor = editor;
|
||||
this.initial_check_mark = null;
|
||||
|
||||
Pulldown.call( this, wiki, notebook_id, "font_pulldown", anchor );
|
||||
|
||||
|
@ -4252,8 +4253,20 @@ function Font_pulldown( wiki, notebook_id, invoker, anchor, editor ) {
|
|||
var label = createDOM( "label", { "class": "pulldown_label font_label", "style": "font-family: " + font_family + ";" },
|
||||
font_name
|
||||
);
|
||||
|
||||
var check_mark_char = document.createTextNode( "\u2714" );
|
||||
if ( editor.query_command_value( "fontname" ) == font_family ) {
|
||||
var check_mark = createDOM( "span", {}, check_mark_char );
|
||||
this.initial_check_mark = check_mark;
|
||||
} else {
|
||||
var check_mark = createDOM( "span", { "class": "invisible" }, check_mark_char );
|
||||
}
|
||||
|
||||
var div = createDOM( "div", {}, check_mark, " ", label );
|
||||
|
||||
label.font_family = font_family;
|
||||
appendChildNodes( this.div, createDOM( "div", {}, label ) );
|
||||
label.check_mark = check_mark;
|
||||
appendChildNodes( this.div, div );
|
||||
connect( label, "onclick", function ( event ) { self.font_name_clicked( event ); } );
|
||||
}
|
||||
|
||||
|
@ -4265,10 +4278,17 @@ Font_pulldown.prototype.constructor = Font_pulldown;
|
|||
|
||||
Font_pulldown.prototype.font_name_clicked = function ( event ) {
|
||||
var label = event.src();
|
||||
this.editor.focus();
|
||||
if ( this.initial_check_mark )
|
||||
addElementClass( this.initial_check_mark, "invisible" );
|
||||
removeElementClass( label.check_mark, "invisible" );
|
||||
|
||||
var self = this;
|
||||
setTimeout( function () {
|
||||
self.editor.focus();
|
||||
// FIXME: this doesn't work in IE 7 from this click handler, but it works elsewhere (like in the constructor)
|
||||
this.editor.exec_command( "fontname", label.font_family );
|
||||
this.shutdown();
|
||||
self.editor.exec_command( "fontname", label.font_family );
|
||||
self.shutdown();
|
||||
}, 100 );
|
||||
}
|
||||
|
||||
Font_pulldown.prototype.shutdown = function () {
|
||||
|
|
Reference in New Issue