- 2004-11-04 (木) 23:53
- MovableType
前回、デコードボタンを付けましたが、そのやり方が解説してあったブログの次のエントリを見てみるとなんと色つけボタンの解説まで載ってました。
これはやるしか…!
と言うわけで さらに設置。
編集ボタンが充実してきてなかなかいい感じになってきました。
・こんな感じになってます

以下、やったこと
修正するファイル
/mt/tmpl/cms/edit_entry.tmpl
スクリプトタグ内にペースト
function colorSelect (obj) {
var v;
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
with(obj) {
if (options[selectedIndex].value == “——”) return;
v = options[selectedIndex].value;
}
document.all.colcol.style.backgroundColor = v;
document.selection.createRange().text = ‘<font color=”‘ + v + ‘”>’ + str + ‘</font>’;
}
function colorSet() {
var v;
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
if (document.all.colcol.options[document.all.colcol.selectedIndex].value == “——”) return;
v = document.all.colcol.options[document.all.colcol.selectedIndex].value;
document.selection.createRange().text = ‘<font color=”‘ + v + ‘”>’ + str + ‘</font>’;
}
前回と同じところに追加。
最終的にこんな感じにできあがり。
(赤:今回追加、青:これまでに追加、空色:レイアウト調整したところ)
<td width=”242“><font class=”pagetitle”><MT_TRANS phrase=”Entry Body”></font></td>
<td width=”258” align=”right” valign=”top”>
<script language=”javascript”>
if (document.selection) {
document.write(‘<table border=”0″ cellspacing=”0″ cellpadding=”0″ width=”257“>’);
document.write(‘<tr>’);
document.write(‘<td width=”100″><form name=”colform”><select name=”colcol” onchange=”colorSelect(this)” width=”48″><option value=”——” selected>——<option value=”red”>red<option value=”yellow”>yellow<option value=”blue”>blue<option value=”green”>green<option value=”cyan”>cyan</select><input type=”button” onclick=”colorSet()” value=”set”></td>’);
document.write(‘<td width=”24″><a href=”javascript:deCode()”><img src=”<TMPL_VAR NAME=STATIC_URI>images/decode-button.gif” alt=”decode” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’b\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/bold-button.gif” alt=”bold” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’i\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/italic-button.gif” alt=”italic” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’u\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/underline-button.gif” alt=”underline” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’blockquote\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/blockquote.gif” alt=”blockquote” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”26″><a href=”javascript:insertLink()”><img src=”<TMPL_VAR NAME=STATIC_URI>images/url-button.gif” alt=”link” width=”26″ height=”18″ border=”0″></a></td>’);
document.write(‘</tr>’);
document.write(‘</table>’);
} else {
document.write(‘ ’);
}
</script>
- Newer: DebianLinuxをインストールしてみる
- Older: デコードボタンを付けよう
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://blog.eternalmiracle.net/taka/archives/2004/11/04-235323/trackback
- Listed below are links to weblogs that reference
- さらに色つけボタンも付けてみよう from eternal miracle blog mode

