html - Changing the fontsize with javascript -
the code below adds <font size="x">$text</font>
wysiwyg editor's textarea:
/** * set size context */ this.set_size_context = function(sizestate) { if (this.buttons['fontsize']) { if (typeof sizestate == 'undefined') { sizestate = this.editdoc.querycommandvalue('fontsize'); } switch (sizestate) { case null: case '': { if (is_moz) { sizestate = this.translate_fontsize(this.editdoc.body.style.fontsize); } } break; } if (sizestate != this.sizestate) { this.sizestate = sizestate; var i; if (this.popupmode) { (i in this.sizeoptions) { if (yahoo.lang.hasownproperty(this.sizeoptions, i)) { this.sizeoptions[i].style.display = (i == this.sizestate ? '' : 'none'); } } } else { (i = 0; < this.buttons['fontsize'].options.length; i++) { if (this.buttons['fontsize'].options[i].value == this.sizestate) { this.buttons['fontsize'].selectedindex = i; break; } } } } } };
i replaced <font size
tags <span style="font-size
tags in php side , everthing working except fontsize dropdown menu , editor still adding <font size
when choose font size list. (it's correctly converted <span style="font-size
when message posted or previewed).
the question is, how code above generates <font size
tag , how can replace <span style="font-size
?
below other related sections fontsize in js:
this.build_fontsize_popup = function(obj, menu) { (var n in sizeoptions) { if (yahoo.lang.hasownproperty(sizeoptions, n)) { var option = document.createelement('div'); option.innerhtml = '<span style="font-size:' + sizeoptions[n] + '">' + sizeoptions[n] + '</span>'; option.classname = 'osize'; option.style.textalign = 'center'; option.title = sizeoptions[n]; option.cmd = obj.cmd; option.controlkey = obj.id; option.editorid = this.editorid; option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = vb_text_editor_events.prototype.menuoption_onmouseevent; option.onclick = vb_text_editor_events.prototype.formatting_option_onclick; menu.appendchild(option); } } }
and
this.translate_fontsize = function(csssize) { switch (csssize) { case '15px': case '12px': return 1; case '15px': return 2; case '18px': return 3; case '21px': return 4; case '24px': return 5; case '27px': return 6; case '30px': return 7; default: return ''; } }
here complete js file: https://jsfiddle.net/07ttt9a7/
wading though full code, need fix
case 'fontname': { this.wrap_tags('font', argument); return; }
to use 'span' instead of 'font'
or
modify function beginning
this.wrap_tags = function(tagname, useoption, selection) {
Comments
Post a Comment