| Zeile 19 | Zeile 19 |
|---|
{ return false; }
|
{ return false; }
|
| |
|
if(!this.options.rtl) { this.options.trl = 0;
| if(!this.options.rtl) { this.options.trl = 0;
|
| Zeile 65 | Zeile 66 |
|---|
// Here we get the ID of the textarea we're replacing and store it. this.textarea = textarea;
|
// Here we get the ID of the textarea we're replacing and store it. this.textarea = textarea;
|
| |
// Only swap it over once the page has loaded (add event) Event.observe(window, "load", this.showEditor.bindAsEventListener(this)); },
| // Only swap it over once the page has loaded (add event) Event.observe(window, "load", this.showEditor.bindAsEventListener(this)); },
|
| Zeile 75 | Zeile 75 |
|---|
// Assign the old textarea to a variable for later use. oldTextarea = $(this.textarea);
|
// Assign the old textarea to a variable for later use. oldTextarea = $(this.textarea);
|
| | // Now this.textarea becomes the new textarea ID this.textarea += "_new";
|
// Begin the creation of our new editor.
editor = document.createElement("div");
| // Begin the creation of our new editor.
editor = document.createElement("div");
|
| Zeile 98 | Zeile 101 |
|---|
{ w = "560px"; }
|
{ w = "560px"; }
|
| |
|
if(this.options && this.options.height) { w = this.options.height;
| if(this.options && this.options.height) { w = this.options.height;
|
| Zeile 126 | Zeile 130 |
|---|
// Create text font/color/size toolbar textFormatting = document.createElement("div"); textFormatting.style.position = "absolute";
|
// Create text font/color/size toolbar textFormatting = document.createElement("div"); textFormatting.style.position = "absolute";
|
| |
|
if(this.options.rtl == 1) { textFormatting.style.right = 0;
| if(this.options.rtl == 1) { textFormatting.style.right = 0;
|
| Zeile 139 | Zeile 144 |
|---|
// Create the font drop down. fontSelect = document.createElement("select"); fontSelect.style.margin = "2px";
|
// Create the font drop down. fontSelect = document.createElement("select"); fontSelect.style.margin = "2px";
|
| | fontSelect.id = "font";
|
fontSelect.options[fontSelect.options.length] = new Option(this.options.lang.font, "-");
|
fontSelect.options[fontSelect.options.length] = new Option(this.options.lang.font, "-");
|
| |
|
for(font in this.fonts) { fontSelect.options[fontSelect.options.length] = new Option(this.fonts[font], font);
| for(font in this.fonts) { fontSelect.options[fontSelect.options.length] = new Option(this.fonts[font], font);
|
| Zeile 150 | Zeile 157 |
|---|
// Create the font size drop down. sizeSelect = document.createElement("select"); sizeSelect.style.margin = "2px";
|
// Create the font size drop down. sizeSelect = document.createElement("select"); sizeSelect.style.margin = "2px";
|
| | sizeSelect.id = "size";
|
sizeSelect.options[sizeSelect.options.length] = new Option(this.options.lang.size, "-");
|
sizeSelect.options[sizeSelect.options.length] = new Option(this.options.lang.size, "-");
|
| |
|
for(size in this.sizes) { sizeSelect.options[sizeSelect.options.length] = new Option(this.sizes[size], size);
| for(size in this.sizes) { sizeSelect.options[sizeSelect.options.length] = new Option(this.sizes[size], size);
|
| Zeile 161 | Zeile 170 |
|---|
// Create the colour drop down. colorSelect = document.createElement("select"); colorSelect.style.margin = "2px";
|
// Create the colour drop down. colorSelect = document.createElement("select"); colorSelect.style.margin = "2px";
|
| | colorSelect.id = "color";
|
colorSelect.options[colorSelect.options.length] = new Option(this.options.lang.color, "-");
|
colorSelect.options[colorSelect.options.length] = new Option(this.options.lang.color, "-");
|
| |
|
for(color in this.colors) { colorSelect.options[colorSelect.options.length] = new Option(this.colors[color], color);
| for(color in this.colors) { colorSelect.options[colorSelect.options.length] = new Option(this.colors[color], color);
|
| Zeile 174 | Zeile 185 |
|---|
// Create close tags button closeBar = document.createElement("div"); closeBar.style.position = "absolute";
|
// Create close tags button closeBar = document.createElement("div"); closeBar.style.position = "absolute";
|
| |
|
if(this.options.rtl == 1) { closeBar.style.left = 0;
| if(this.options.rtl == 1) { closeBar.style.left = 0;
|
| Zeile 182 | Zeile 194 |
|---|
{ closeBar.style.right = 0; }
|
{ closeBar.style.right = 0; }
|
| |
|
var closeButton = document.createElement("img"); closeButton.id = "close_tags"; closeButton.src = "images/codebuttons/close_tags.gif";
| var closeButton = document.createElement("img"); closeButton.id = "close_tags"; closeButton.src = "images/codebuttons/close_tags.gif";
|
| Zeile 208 | Zeile 221 |
|---|
// Create formatting section of second toolbar. formatting = document.createElement("div"); formatting.style.position = "absolute";
|
// Create formatting section of second toolbar. formatting = document.createElement("div"); formatting.style.position = "absolute";
|
| | formatting.style.width = "100%"; formatting.style.whiteSpace = "nowrap";
|
if(this.options.rtl == 1) { formatting.style.right = 0;
| if(this.options.rtl == 1) { formatting.style.right = 0;
|
| Zeile 231 | Zeile 247 |
|---|
// Create insertable elements section of second toolbar. elements = document.createElement("div"); elements.style.position = "absolute";
|
// Create insertable elements section of second toolbar. elements = document.createElement("div"); elements.style.position = "absolute";
|
| |
|
if(this.options.rtl == 1) { elements.style.left = 0;
| if(this.options.rtl == 1) { elements.style.left = 0;
|
| Zeile 257 | Zeile 274 |
|---|
// Create our new text area areaContainer = document.createElement("div");
|
// Create our new text area areaContainer = document.createElement("div");
|
| | areaContainer.style.clear = "both";
|
// Set the width/height of the area
|
// Set the width/height of the area
|
| | subtract = subtract2 = 0;
|
if(MyBB.browser == "mozilla") {
|
if(MyBB.browser == "mozilla") {
|
subtract = subtract2 = parseInt(editor.style.padding)*2; } else { subtract = subtract2 = 0;
| subtract = subtract2 = 8;
|
} areaContainer.style.height = parseInt(editor.style.height)-parseInt(toolBar.style.height)-parseInt(toolbar2.style.height)-subtract+"px";
|
} areaContainer.style.height = parseInt(editor.style.height)-parseInt(toolBar.style.height)-parseInt(toolbar2.style.height)-subtract+"px";
|
areaContainer.style.width = (parseInt(editor.style.width)-subtract2)+"px";
| areaContainer.style.width = parseInt(editor.style.width)-subtract2+"px";
|
// Create text area textInput = document.createElement("textarea"); textInput.id = this.textarea;
|
// Create text area textInput = document.createElement("textarea"); textInput.id = this.textarea;
|
textInput.name = oldTextarea.name; textInput.style.height = areaContainer.style.height; textInput.style.width = areaContainer.style.width;
| textInput.name = oldTextarea.name+"_new"; textInput.style.height = parseInt(areaContainer.style.height)+"px"; textInput.style.width = parseInt(areaContainer.style.width)+"px";
|
if(oldTextarea.value != '') { textInput.value = oldTextarea.value; }
|
if(oldTextarea.value != '') { textInput.value = oldTextarea.value; }
|
| |
|
if(oldTextarea.tabIndex) { textInput.tabIndex = oldTextarea.tabIndex; }
|
if(oldTextarea.tabIndex) { textInput.tabIndex = oldTextarea.tabIndex; }
|
| |
|
areaContainer.appendChild(textInput); editor.appendChild(areaContainer);
|
areaContainer.appendChild(textInput); editor.appendChild(areaContainer);
|
| |
|
if(oldTextarea.form) { Event.observe(oldTextarea.form, "submit", this.closeTags.bindAsEventListener(this));
|
if(oldTextarea.form) { Event.observe(oldTextarea.form, "submit", this.closeTags.bindAsEventListener(this));
|
| | Event.observe(oldTextarea.form, "submit", this.updateOldArea.bindAsEventListener(this));
|
}
|
}
|
// Replace the old with the new oldTextarea.parentNode.replaceChild(editor, oldTextarea);
| // Hide the old editor oldTextarea.style.visibility = "hidden"; oldTextarea.style.position = "absolute"; oldTextarea.style.top = "-1000px"; oldTextarea.id += "_old"; this.oldTextarea = oldTextarea;
// Append the new editor oldTextarea.parentNode.appendChild(editor);
Event.observe(textInput, "keyup", this.updateOldArea.bindAsEventListener(this)); Event.observe(textInput, "blur", this.updateOldArea.bindAsEventListener(this)); }, updateOldArea: function(e) { this.oldTextarea.value = $(this.textarea).value;
|
},
|
},
|
| |
|
insertStandardButton: function(into, id, src, insertText, insertExtra, alt) { var button = document.createElement("img");
| insertStandardButton: function(into, id, src, insertText, insertExtra, alt) { var button = document.createElement("img");
|
| Zeile 325 | Zeile 362 |
|---|
toolbarItemOut: function(e) { element = MyBB.eventElement(e);
|
toolbarItemOut: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element) { return false; }
|
if(!element) { return false; }
|
| |
|
if(element.insertText) { if(element.insertExtra)
| if(element.insertText) { if(element.insertExtra)
|
| Zeile 339 | Zeile 378 |
|---|
{ insertCode = element.insertText; }
|
{ insertCode = element.insertText; }
|
| |
|
if(MyBB.inArray(insertCode, this.openTags)) { DomLib.addClass(element, "toolbar_clicked");
| if(MyBB.inArray(insertCode, this.openTags)) { DomLib.addClass(element, "toolbar_clicked");
|
| Zeile 350 | Zeile 390 |
|---|
toolbarItemHover: function(e) { element = MyBB.eventElement(e);
|
toolbarItemHover: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element) { return false; }
|
if(!element) { return false; }
|
| |
|
DomLib.addClass(element, "toolbar_hover"); },
| DomLib.addClass(element, "toolbar_hover"); },
|
| Zeile 361 | Zeile 403 |
|---|
toolbarItemClick: function(e) { element = MyBB.eventElement(e);
|
toolbarItemClick: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element) { return false; }
|
if(!element) { return false; }
|
| |
|
if(element.id == "close_tags") { this.closeTags();
| if(element.id == "close_tags") { this.closeTags();
|
| Zeile 378 | Zeile 422 |
|---|
changeFont: function(e) { element = MyBB.eventElement(e);
|
changeFont: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element) { return false; }
|
if(!element) { return false; }
|
| |
|
this.insertMyCode("font", element.options[element.selectedIndex].value);
|
this.insertMyCode("font", element.options[element.selectedIndex].value);
|
| |
|
if(this.getSelectedText($(this.textarea))) { element.selectedIndex = 0;
| if(this.getSelectedText($(this.textarea))) { element.selectedIndex = 0;
|
| Zeile 392 | Zeile 439 |
|---|
changeSize: function(e) { element = MyBB.eventElement(e);
|
changeSize: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element) { return false; }
|
if(!element) { return false; }
|
| |
|
this.insertMyCode("size", element.options[element.selectedIndex].value);
|
this.insertMyCode("size", element.options[element.selectedIndex].value);
|
| |
|
if(this.getSelectedText($(this.textarea))) { element.selectedIndex = 0;
| if(this.getSelectedText($(this.textarea))) { element.selectedIndex = 0;
|
| Zeile 406 | Zeile 456 |
|---|
changeColor: function(e) { element = MyBB.eventElement(e);
|
changeColor: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element) { return false; }
|
if(!element) { return false; }
|
| |
|
this.insertMyCode("color", element.options[element.selectedIndex].value);
|
this.insertMyCode("color", element.options[element.selectedIndex].value);
|
| |
|
if(this.getSelectedText($(this.textarea))) { element.selectedIndex = 0;
| if(this.getSelectedText($(this.textarea))) { element.selectedIndex = 0;
|
| Zeile 420 | Zeile 473 |
|---|
insertList: function(type) { list = "";
|
insertList: function(type) { list = "";
|
| |
|
do { listItem = prompt(this.options.lang.enter_list_item, "");
|
do { listItem = prompt(this.options.lang.enter_list_item, "");
|
| |
|
if(listItem != "" && listItem != null) { list = list+"[*]"+listItem+"\n"; } } while(listItem != "" && listItem != null);
|
if(listItem != "" && listItem != null) { list = list+"[*]"+listItem+"\n"; } } while(listItem != "" && listItem != null);
|
| |
|
if(list == "") { return false; }
|
if(list == "") { return false; }
|
| |
|
if(type) { list = "[list="+type+"]\n"+list;
| if(type) { list = "[list="+type+"]\n"+list;
|
| Zeile 441 | Zeile 498 |
|---|
{ list = "[list]\n"+list; }
|
{ list = "[list]\n"+list; }
|
| |
|
list = list+"[/list]\n"; this.performInsert(list, "", true, false); },
| list = list+"[/list]\n"; this.performInsert(list, "", true, false); },
|
| Zeile 449 | Zeile 507 |
|---|
{ selectedText = this.getSelectedText($(this.textarea)); url = prompt(this.options.lang.enter_url, "http://");
|
{ selectedText = this.getSelectedText($(this.textarea)); url = prompt(this.options.lang.enter_url, "http://");
|
| |
|
if(url) { if(!selectedText)
| if(url) { if(!selectedText)
|
| Zeile 459 | Zeile 518 |
|---|
{ title = selectedText; }
|
{ title = selectedText; }
|
| |
|
if(title) { this.performInsert("[url="+url+"]"+title+"[/url]", "", true, false);
| if(title) { this.performInsert("[url="+url+"]"+title+"[/url]", "", true, false);
|
| Zeile 474 | Zeile 534 |
|---|
{ selectedText = this.getSelectedText($(this.textarea)); email = prompt(this.options.lang.enter_email, "");
|
{ selectedText = this.getSelectedText($(this.textarea)); email = prompt(this.options.lang.enter_email, "");
|
| |
|
if(email) { if(!selectedText)
| if(email) { if(!selectedText)
|
| Zeile 484 | Zeile 545 |
|---|
{ title = selectedText; }
|
{ title = selectedText; }
|
| |
|
if(title) { this.performInsert("[email="+email+"]"+title+"[/email]", "", true, false);
| if(title) { this.performInsert("[email="+email+"]"+title+"[/email]", "", true, false);
|
| Zeile 498 | Zeile 560 |
|---|
insertIMG: function() { image = prompt(this.options.lang.enter_image, "http://");
|
insertIMG: function() { image = prompt(this.options.lang.enter_image, "http://");
|
| |
|
if(image) { this.performInsert("[img]"+image+"[/img]", "", true);
| if(image) { this.performInsert("[img]"+image+"[/img]", "", true);
|
| Zeile 531 | Zeile 594 |
|---|
{ var full_tag = code; }
|
{ var full_tag = code; }
|
| |
|
var newTags = new Array();
|
var newTags = new Array();
|
for(var i=0;i<this.openTags.length;i++)
| for(var i=0; i< this.openTags.length; ++i)
|
{ if(this.openTags[i]) { exploded_tag = this.openTags[i].split("_");
|
{ if(this.openTags[i]) { exploded_tag = this.openTags[i].split("_");
|
| |
|
if(exploded_tag[0] == code) { already_open = true; this.performInsert("[/"+exploded_tag[0]+"]", "", false);
|
if(exploded_tag[0] == code) { already_open = true; this.performInsert("[/"+exploded_tag[0]+"]", "", false);
|
| |
|
if($(this.openTags[i])) { $(this.openTags[i]).className = "toolbar_normal"; }
|
if($(this.openTags[i])) { $(this.openTags[i]).className = "toolbar_normal"; }
|
| |
|
if(this.openTags[i] == full_tag) { no_insert = true;
| if(this.openTags[i] == full_tag) { no_insert = true;
|
| Zeile 556 | Zeile 623 |
|---|
} } }
|
} } }
|
| |
|
this.openTags = newTags; var do_insert = false;
|
this.openTags = newTags; var do_insert = false;
|
| |
|
if(extra != "" && extra != "-" && no_insert == false) { start_tag = "["+code+"="+extra+"]";
| if(extra != "" && extra != "-" && no_insert == false) { start_tag = "["+code+"="+extra+"]";
|
| Zeile 620 | Zeile 689 |
|---|
{ var ignore_selection = false; }
|
{ var ignore_selection = false; }
|
| |
|
if(!close_tag) { var close_tag = ""; } var textarea = $(this.textarea); textarea.focus();
|
if(!close_tag) { var close_tag = ""; } var textarea = $(this.textarea); textarea.focus();
|
| |
|
if(document.selection) { var selection = document.selection;
|
if(document.selection) { var selection = document.selection;
|
var range = selection.createRange()
| var range = selection.createRange();
|
if(ignore_selection != false) { selection.collapse; }
|
if(ignore_selection != false) { selection.collapse; }
|
| |
|
if((selection.type == "Text" || selection.type == "None") && range != null && ignore_selection != true) { if(close_tag != "" && range.text.length > 0)
| if((selection.type == "Text" || selection.type == "None") && range != null && ignore_selection != true) { if(close_tag != "" && range.text.length > 0)
|
| Zeile 644 | Zeile 717 |
|---|
else { var keep_selected = false;
|
else { var keep_selected = false;
|
| |
|
if(is_single) { is_closed = false;
| if(is_single) { is_closed = false;
|
| Zeile 662 | Zeile 736 |
|---|
var select_start = textarea.selectionStart; var select_end = textarea.selectionEnd; var scroll_top = textarea.scrollTop;
|
var select_start = textarea.selectionStart; var select_end = textarea.selectionEnd; var scroll_top = textarea.scrollTop;
|
| |
|
if(select_end <= 2) { select_end = textarea.textLength; }
|
if(select_end <= 2) { select_end = textarea.textLength; }
|
| |
|
var start = textarea.value.substring(0, select_start); var middle = textarea.value.substring(select_start, select_end); var end = textarea.value.substring(select_end, textarea.textLength);
|
var start = textarea.value.substring(0, select_start); var middle = textarea.value.substring(select_start, select_end); var end = textarea.value.substring(select_end, textarea.textLength);
|
| |
|
if(select_end - select_start > 0 && ignore_selection != true && close_tag != "") { var keep_selected = true;
| if(select_end - select_start > 0 && ignore_selection != true && close_tag != "") { var keep_selected = true;
|
| Zeile 683 | Zeile 760 |
|---|
} middle = open_tag; }
|
} middle = open_tag; }
|
| |
|
textarea.value = start+middle+end;
|
textarea.value = start+middle+end;
|
| |
|
if(keep_selected == true && ignore_selection != true) { textarea.selectionStart = select_start;
| if(keep_selected == true && ignore_selection != true) { textarea.selectionStart = select_start;
|
| Zeile 699 | Zeile 778 |
|---|
else { textarea.value += open_tag;
|
else { textarea.value += open_tag;
|
| |
|
if(is_single) { is_closed = false; } }
|
if(is_single) { is_closed = false; } }
|
| | this.updateOldArea();
|
textarea.focus(); return is_closed; },
| textarea.focus(); return is_closed; },
|
| Zeile 717 | Zeile 798 |
|---|
tag = MyBB.arrayPop(this.openTags); exploded_tag = tag.split("_"); this.performInsert("[/"+exploded_tag[0]+"]", "", false);
|
tag = MyBB.arrayPop(this.openTags); exploded_tag = tag.split("_"); this.performInsert("[/"+exploded_tag[0]+"]", "", false);
|
if($(tag))
| if($(exploded_tag[0]))
|
{
|
{
|
DomLib.removeClass($(tag), "toolbar_clicked");
| tag = $(exploded_tag[0]); if(tag.type == "select-one") { tag.selectedIndex = 0; } else { DomLib.removeClass($(tag), "toolbar_clicked"); }
|
} } }
| } } }
|
| Zeile 742 | Zeile 832 |
|---|
{ return false; }
|
{ return false; }
|
| |
|
smilies = DomLib.getElementsByClassName($(id), "img", "smilie");
|
smilies = DomLib.getElementsByClassName($(id), "img", "smilie");
|
| |
|
if(smilies.length > 0) {
|
if(smilies.length > 0) {
|
for(var i=0;i<smilies.length;i++)
| for(var i=0; i < smilies.length; ++i)
|
{ var smilie = smilies[i]; smilie.onclick = this.insertSmilie.bindAsEventListener(this);
| { var smilie = smilies[i]; smilie.onclick = this.insertSmilie.bindAsEventListener(this);
|
| Zeile 762 | Zeile 854 |
|---|
insertSmilie: function(e) { element = MyBB.eventElement(e);
|
insertSmilie: function(e) { element = MyBB.eventElement(e);
|
| |
|
if(!element || !element.alt) { return false;
| if(!element || !element.alt) { return false;
|