Fixed some bugs and added support for the 'Cancel' button when adding a link or image
git-svn-id: https://develop.svn.wordpress.org/trunk@669 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
408c34915e
commit
80dbd7e4aa
|
@ -157,7 +157,6 @@ function edAddTag(button) {
|
||||||
if (edButtons[button].tagEnd != '') {
|
if (edButtons[button].tagEnd != '') {
|
||||||
edOpenTags[edOpenTags.length] = button;
|
edOpenTags[edOpenTags.length] = button;
|
||||||
document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value;
|
document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +248,7 @@ function edToolbar() {
|
||||||
function edInsertTag(myField, i) {
|
function edInsertTag(myField, i) {
|
||||||
//IE support
|
//IE support
|
||||||
if (document.selection) {
|
if (document.selection) {
|
||||||
myField.focus();
|
myField.focus();
|
||||||
sel = document.selection.createRange();
|
sel = document.selection.createRange();
|
||||||
if (sel.text.length > 0) {
|
if (sel.text.length > 0) {
|
||||||
sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd;
|
sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd;
|
||||||
|
@ -270,16 +269,14 @@ function edInsertTag(myField, i) {
|
||||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
else if (myField.selectionStart || myField.selectionStart == '0') {
|
||||||
var startPos = myField.selectionStart;
|
var startPos = myField.selectionStart;
|
||||||
var endPos = myField.selectionEnd;
|
var endPos = myField.selectionEnd;
|
||||||
var cursorPos;
|
var cursorPos = endPos;
|
||||||
if (startPos != endPos) {
|
if (startPos != endPos) {
|
||||||
myField.value = myField.value.substring(0, startPos)
|
myField.value = myField.value.substring(0, startPos)
|
||||||
+ edButtons[i].tagStart
|
+ edButtons[i].tagStart
|
||||||
+ myField.value.substring(startPos, endPos)
|
+ myField.value.substring(startPos, endPos)
|
||||||
+ edButtons[i].tagEnd
|
+ edButtons[i].tagEnd
|
||||||
+ myField.value.substring(endPos, myField.value.length);
|
+ myField.value.substring(endPos, myField.value.length);
|
||||||
cursorPos = endPos
|
cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length;
|
||||||
+ edButtons[i].tagStart.length
|
|
||||||
+ edButtons[i].tagEnd.length;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
|
if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
|
||||||
|
@ -343,20 +340,24 @@ function edInsertLink(myField, i, defaultValue) {
|
||||||
defaultValue = 'http://';
|
defaultValue = 'http://';
|
||||||
}
|
}
|
||||||
if (!edCheckOpenTags(i)) {
|
if (!edCheckOpenTags(i)) {
|
||||||
edButtons[i].tagStart = '<a href="'
|
var URL = prompt('Enter the URL' ,defaultValue);
|
||||||
+ prompt('Enter the URL'
|
if (URL) {
|
||||||
,defaultValue
|
edButtons[i].tagStart = '<a href="' + URL + '">';
|
||||||
)
|
edInsertTag(myField, i);
|
||||||
+ '">';
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
edInsertTag(myField, i);
|
||||||
}
|
}
|
||||||
edInsertTag(myField, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function edInsertImage(myField) {
|
function edInsertImage(myField) {
|
||||||
var myValue = '<img src="'
|
var myValue = prompt('Enter the URL of the image', 'http://');
|
||||||
+ prompt('Enter the URL of the image', 'http://')
|
if (myValue) {
|
||||||
+ '" alt="'
|
myValue = '<img src="'
|
||||||
+ prompt('Enter a description of the image', '')
|
+ myValue
|
||||||
+ '" />';
|
+ '" alt="' + prompt('Enter a description of the image', '')
|
||||||
edInsertContent(myField, myValue);
|
+ '" />';
|
||||||
|
edInsertContent(myField, myValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue