From 13bc8d10dc8f938e7d416c6fc6f0065820177443 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Fri, 15 Aug 2003 15:15:37 +0000 Subject: [PATCH] Renamed quicktag files. git-svn-id: http://svn.automattic.com/wordpress/trunk@315 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/b2edit.form.php | 2 +- wp-admin/wp-quicktags.js | 336 ++++++++++++++++++++++++++++++++++++++ wp-admin/wp-quicktags.php | 2 + 3 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 wp-admin/wp-quicktags.js create mode 100644 wp-admin/wp-quicktags.php diff --git a/wp-admin/b2edit.form.php b/wp-admin/b2edit.form.php index fe4ded0d9b..4398f783e5 100644 --- a/wp-admin/b2edit.form.php +++ b/wp-admin/b2edit.form.php @@ -166,7 +166,7 @@ if ($action != 'editcomment') { Quicktags: '; - include('b2quicktags.php'); + include('wp-quicktags.php'); } ?> diff --git a/wp-admin/wp-quicktags.js b/wp-admin/wp-quicktags.js new file mode 100644 index 0000000000..d811af92f8 --- /dev/null +++ b/wp-admin/wp-quicktags.js @@ -0,0 +1,336 @@ +// new edit toolbar used with permission +// by Alex King +// http://www.alexking.org/ + +function edButton() { + this.id = ''; // used to name the toolbar button + this.display = ''; // label on button + this.tagStart = ''; // open tag + this.tagEnd = ''; // close tag + this.open = 0; // set to -1 if tag does not need to be closed +} + +var edOpenTags = new Array(); + +function edAddTag(button) { + if (eval('ed' + button + '.tagEnd') != '') { + edOpenTags[edOpenTags.length] = button; + document.getElementById(eval('ed' + button + '.id')).value = '/' + document.getElementById(eval('ed' + button + '.id')).value; + + } +} + +function edRemoveTag(button) { + for (i = 0; i < edOpenTags.length; i++) { + if (edOpenTags[i] == button) { + edOpenTags.splice(i, 1); + document.getElementById(eval('ed' + button + '.id')).value = document.getElementById(eval('ed' + button + '.id')).value.replace('/', ''); + } + } +} + +function edCheckOpenTags(button) { + var tag = 0; + for (i = 0; i < edOpenTags.length; i++) { + if (edOpenTags[i] == button) { + tag++; + } + } + if (tag > 0) { + return true; // tag found + } + else { + return false; // tag not found + } +} + +function edCloseAllTags() { + var count = edOpenTags.length; + for (o = 0; o < count; o++) { + edInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]); + } +} + +var ed0 = new edButton(); +ed0.id = 'ed_bold'; +ed0.display = 'B'; +ed0.tagStart = ''; +ed0.tagEnd = ''; + +var ed1 = new edButton(); +ed1.id = 'ed_italic'; +ed1.display = 'I'; +ed1.tagStart = ''; +ed1.tagEnd = ''; + +var ed2 = new edButton(); +ed2.id = 'ed_under'; +ed2.display = 'U'; +ed2.tagStart = ''; +ed2.tagEnd = ''; + +var ed3 = new edButton(); +ed3.id = 'ed_strike'; +ed3.display = 'S'; +ed3.tagStart = ''; +ed3.tagEnd = ''; + +var ed4 = new edButton(); +ed4.id = 'ed_quot'; +ed4.display = '"'; +ed4.tagStart = '"'; +ed4.tagEnd = '"'; +ed4.open = -1; + +var ed5 = new edButton(); +ed5.id = 'ed_amp'; +ed5.display = '&'; +ed5.tagStart = '&'; +ed5.tagEnd = ''; +ed5.open = -1; + +var ed6 = new edButton(); +ed6.id = 'ed_nbsp'; +ed6.display = 'nbsp'; +ed6.tagStart = ' '; +ed6.tagEnd = ''; +ed6.open = -1; + +var ed7 = new edButton(); +ed7.id = 'ed_nobr'; +ed7.display = 'nobr'; +ed7.tagStart = ''; +ed7.tagEnd = ''; + +var ed8 = new edButton(); +ed8.id = 'ed_link'; +ed8.display = 'link'; +ed8.tagStart = ''; // special case +ed8.tagEnd = ''; + +var ed9 = new edButton(); +ed9.id = 'ed_img'; +ed9.display = 'img'; +ed9.tagStart = ''; // special case +ed9.tagEnd = ''; +ed9.open = -1; + +var ed10 = new edButton(); +ed10.id = 'ed_ul'; +ed10.display = 'UL'; +ed10.tagStart = ''; + +var ed11 = new edButton(); +ed11.id = 'ed_ol'; +ed11.display = 'OL'; +ed11.tagStart = '
    '; +ed11.tagEnd = '
'; + +var ed12 = new edButton(); +ed12.id = 'ed_li'; +ed12.display = 'LI'; +ed12.tagStart = '
  • '; +ed12.tagEnd = '
  • '; + +var ed13 = new edButton(); +ed13.id = 'ed_block'; +ed13.display = 'b-quote'; +ed13.tagStart = '
    '; +ed13.tagEnd = '
    '; + +var ed14 = new edButton(); +ed14.id = 'ed_pre'; +ed14.display = 'pre'; +ed14.tagStart = '
    ';
    +ed14.tagEnd = '
    '; + +var edButtonCount = 15; + +function edShowButton(button, i) { + if (button.id == 'ed_img') { + document.write(''); + } + else if (button.id == 'ed_link') { + document.write(''); + } + else { + document.write(''); + } +} + +function edLink() { + this.display = ''; + this.URL = ''; + this.newWin = 0; +} + +var edLink0 = new edLink; +edLink0.display = 'WordPress'; +edLink0.URL = 'http://www.wordpress.org/'; + +var edLink1 = new edLink; +edLink1.display = 'alexking.org'; +edLink1.URL = 'http://www.alexking.org/'; + +var edLinkCount = 2; + +function edShowLinks() { + var tempStr = ''; + document.write(tempStr); +} + +function edQuickLink(i, thisSelect) { + if (i > -1) { + var newWin = ''; + if (eval('edLink' + i + '.newWin') == 1) { + newWin = ' target="_blank"'; + } + var tempStr = '' + eval('edLink' + i + '.display') + ''; + edInsertContent(edCanvas, tempStr); + } + thisSelect.selectedIndex = 0; +} + +function edSpell(myField) { + var word = ''; + if (document.selection) { + myField.focus(); + var sel = document.selection.createRange(); + if (sel.text.length > 0) { + word = sel.text; + } + } + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + if (startPos != endPos) { + word = myField.value.substring(startPos, endPos); + } + } + if (word == '') { + word = prompt('Enter a word to look up:', ''); + } + if (word != '') { + window.open('http://dictionary.reference.com/search?q=' + word); + } +} + +function edToolbar() { + document.write('
    '); + for (i = 0; i < edButtonCount; i++) { + edShowButton(eval('ed' + i), i); + } + document.write(''); + document.write(''); +// edShowLinks(); // disabled by default + document.write('
    '); +} + +// insertion code + +function edInsertTag(myField, i) { + //IE support + if (document.selection) { + myField.focus(); + sel = document.selection.createRange(); + if (sel.text.length > 0) { + sel.text = eval('ed' + i + '.tagStart') + sel.text + eval('ed' + i + '.tagEnd'); + } + else { + if (!edCheckOpenTags(i) || eval('ed' + i + '.tagEnd') == '') { + sel.text = eval('ed' + i + '.tagStart'); + edAddTag(i); + } + else { + sel.text = eval('ed' + i + '.tagEnd'); + edRemoveTag(i); + } + } + myField.focus(); + } + //MOZILLA/NETSCAPE support + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + var cursorPos; + if (startPos != endPos) { + myField.value = myField.value.substring(0, startPos) + + eval('ed' + i + '.tagStart') + + myField.value.substring(startPos, endPos) + + eval('ed' + i + '.tagEnd') + + myField.value.substring(endPos, myField.value.length); + cursorPos = endPos + eval('ed' + i + '.tagStart').length + eval('ed' + i + '.tagEnd').length; + } + else { + if (!edCheckOpenTags(i) || eval('ed' + i + '.tagEnd') == '') { + myField.value = myField.value.substring(0, startPos) + + eval('ed' + i + '.tagStart') + + myField.value.substring(endPos, myField.value.length); + edAddTag(i); + cursorPos = startPos + eval('ed' + i + '.tagStart').length; + } + else { + myField.value = myField.value.substring(0, startPos) + + eval('ed' + i + '.tagEnd') + + myField.value.substring(endPos, myField.value.length); + edRemoveTag(i); + cursorPos = startPos + eval('ed' + i + '.tagEnd').length; + } + } + myField.focus(); + myField.selectionStart = cursorPos; + myField.selectionEnd = cursorPos; + } + else { + if (!edCheckOpenTags(i) || eval('ed' + i + '.tagEnd') == '') { + myField.value += eval('ed' + i + '.tagStart'); + edAddTag(i); + } + else { + myField.value += eval('ed' + i + '.tagEnd'); + edRemoveTag(i); + } + myField.focus(); + } +} + +function edInsertContent(myField, myValue) { + //IE support + if (document.selection) { + myField.focus(); + sel = document.selection.createRange(); + sel.text = myValue; + myField.focus(); + } + //MOZILLA/NETSCAPE support + else if (myField.selectionStart || myField.selectionStart == '0') { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + myField.value = myField.value.substring(0, startPos) + + myValue + + myField.value.substring(endPos, myField.value.length); + myField.focus(); + myField.selectionStart = startPos + myValue.length; + myField.selectionEnd = startPos + myValue.length; + } else { + myField.value += myValue; + myField.focus(); + } +} + +function edInsertLink(myField, i) { + if (!edCheckOpenTags(i)) { + eval('ed' + i + '.tagStart = \'\''); + } + edInsertTag(myField, i); +} + +function edInsertImage(myField) { + var myValue = '' + prompt('Enter a description of the image', '') + ''; + edInsertContent(myField, myValue); +} diff --git a/wp-admin/wp-quicktags.php b/wp-admin/wp-quicktags.php new file mode 100644 index 0000000000..274344058f --- /dev/null +++ b/wp-admin/wp-quicktags.php @@ -0,0 +1,2 @@ + + \ No newline at end of file