Vergleich jscripts/editor.js - 1.2.1 - 1.2.3

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 19Zeile 19
			{
return false;
}

			{
return false;
}

 
			

			if(!this.options.rtl)
{

			if(!this.options.rtl)
{

				this.options.trl = 0;

				this.options.rtl = 0;

			}
}


			}
}


Zeile 64Zeile 65
	
// 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 75Zeile 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);


		// Begin the creation of our new editor.





		// Now this.textarea becomes the new textarea ID
this.textarea += "_new";

// Begin the creation of our new editor.


		editor = document.createElement("div");
editor.style.position = "relative";
editor.className = "editor";

// Determine the overall height and width - messy, but works
if(this.options && this.options.width)

		editor = document.createElement("div");
editor.style.position = "relative";
editor.className = "editor";

// Determine the overall height and width - messy, but works
if(this.options && this.options.width)

		{

		{

			w = this.options.width;

			w = this.options.width;

		}

		}

		else if(oldTextarea.style.width)

		else if(oldTextarea.style.width)

		{

		{

			w = oldTextarea.style.width;
}
else if(oldTextarea.clientWidth)
{
w = oldTextarea.clientWidth+"px";

			w = oldTextarea.style.width;
}
else if(oldTextarea.clientWidth)
{
w = oldTextarea.clientWidth+"px";

		}

		}

		else
{
w = "560px";
}

		else
{
w = "560px";
}

 
		

		if(this.options && this.options.height)
{
w = this.options.height;

		if(this.options && this.options.height)
{
w = this.options.height;

Zeile 109Zeile 113
		else if(oldTextarea.clientHeight)
{
h = oldTextarea.clientHeight+"px";

		else if(oldTextarea.clientHeight)
{
h = oldTextarea.clientHeight+"px";

		}
else
{

		}
else
{

			h = "400px";
}
editor.style.width = w;

			h = "400px";
}
editor.style.width = w;

Zeile 126Zeile 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 139Zeile 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 150Zeile 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 161Zeile 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 174Zeile 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)

		if(this.options.rtl == 1)

		{

		{

			closeBar.style.left = 0;

			closeBar.style.left = 0;

		}

		}

		else
{
closeBar.style.right = 0;
}

		else
{
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 204Zeile 217
		toolbar2 = document.createElement("div");
toolbar2.style.height = "28px";
toolbar2.style.position = "relative";

		toolbar2 = document.createElement("div");
toolbar2.style.height = "28px";
toolbar2.style.position = "relative";





		// 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 231Zeile 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;

		}
else

		}
else

		{
elements.style.right = 0;
}

		{
elements.style.right = 0;
}

Zeile 257Zeile 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 != '')

		if(oldTextarea.value != '')

		{

		{

			textInput.value = 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.insertBefore(editor, oldTextarea);

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)
{


insertStandardButton: function(into, id, src, insertText, insertExtra, alt)
{

Zeile 325Zeile 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 339Zeile 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 350Zeile 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 361Zeile 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")

		if(element.id == "close_tags")

		{

		{

			this.closeTags();

			this.closeTags();

		}

		}

		else
{
this.insertMyCode(element.insertText, element.insertExtra);

		else
{
this.insertMyCode(element.insertText, element.insertExtra);

		}
},


		}
},


	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 390Zeile 437
	},

changeSize: function(e)

	},

changeSize: function(e)

	{

	{

		element = MyBB.eventElement(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)))
{


		
if(this.getSelectedText($(this.textarea)))
{

			element.selectedIndex = 0;
}
},

			element.selectedIndex = 0;
}
},

Zeile 406Zeile 456
	changeColor: function(e)
{
element = MyBB.eventElement(e);

	changeColor: function(e)
{
element = MyBB.eventElement(e);

		if(!element)
{


		
if(!element)
{

			return false;
}

			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;

		}

		}

	},

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 441Zeile 498
		{
list = "[list]\n"+list;
}

		{
list = "[list]\n"+list;
}

 
		

		list = list+"[/list]\n";
this.performInsert(list, "", true, false);
},

insertURL: function()

		list = list+"[/list]\n";
this.performInsert(list, "", true, false);
},

insertURL: function()

	{

	{

		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)

			{

			{

				title = prompt(this.options.lang.enter_url_title, "");
}

				title = prompt(this.options.lang.enter_url_title, "");
}

			else
{
title = selectedText;
}


			else
{
title = selectedText;
}


			if(title)

			if(title)

			{

			{

				this.performInsert("[url="+url+"]"+title+"[/url]", "", true, false);
}
else
{
this.performInsert("[url]"+url+"[/url]", "", true, false);

				this.performInsert("[url="+url+"]"+title+"[/url]", "", true, false);
}
else
{
this.performInsert("[url]"+url+"[/url]", "", true, false);

			}

			}

		}
},


		}
},


Zeile 474Zeile 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)

			{

			{

				title = prompt(this.options.lang.enter_email_title, "");

				title = prompt(this.options.lang.enter_email_title, "");

			}

			}

			else

			else

			{

			{

				title = selectedText;
}

				title = selectedText;
}

 
			

			if(title)
{
this.performInsert("[email="+email+"]"+title+"[/email]", "", true, false);

			if(title)
{
this.performInsert("[email="+email+"]"+title+"[/email]", "", true, false);

			}

			}

			else
{
this.performInsert("[email]"+email+"[/email]", "", true, false);

			else
{
this.performInsert("[email]"+email+"[/email]", "", true, false);

Zeile 498Zeile 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 531Zeile 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 556Zeile 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 620Zeile 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)
{
var keep_selected = true;
range.text = open_tag+range.text+close_tag;

			if((selection.type == "Text" || selection.type == "None") && range != null && ignore_selection != true)
{
if(close_tag != "" && range.text.length > 0)
{
var keep_selected = true;
range.text = open_tag+range.text+close_tag;

				}

				}

				else
{
var keep_selected = false;

				else
{
var keep_selected = false;

 
					

					if(is_single)
{
is_closed = false;

					if(is_single)
{
is_closed = false;

Zeile 662Zeile 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;
middle = open_tag+middle+close_tag;

			if(select_end - select_start > 0 && ignore_selection != true && close_tag != "")
{
var keep_selected = true;
middle = open_tag+middle+close_tag;

			}

			}

			else
{
var keep_selected = false;

			else
{
var keep_selected = false;

Zeile 683Zeile 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 695Zeile 774
				textarea.selectionEnd = textarea.selectionStart;
}
textarea.scrollTop = scroll_top;

				textarea.selectionEnd = textarea.selectionStart;
}
textarea.scrollTop = scroll_top;

		}

		}

		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 717Zeile 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 729Zeile 819
	},

setToolbarItemState: function(id, state)

	},

setToolbarItemState: function(id, state)

	{

	{

		element = $(id);
if(element && element != null)
{

		element = $(id);
if(element && element != null)
{

Zeile 739Zeile 829
	bindSmilieInserter: function(id)
{
if(!$(id))

	bindSmilieInserter: function(id)
{
if(!$(id))

		{

		{

			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 762Zeile 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;