aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver/template/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/styles/prosilver/template/editor.js')
-rw-r--r--phpBB/styles/prosilver/template/editor.js92
1 files changed, 48 insertions, 44 deletions
diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js
index c099466005..13e9ca3c66 100644
--- a/phpBB/styles/prosilver/template/editor.js
+++ b/phpBB/styles/prosilver/template/editor.js
@@ -6,15 +6,15 @@
// Startup variables
var imageTag = false;
var theSelection = false;
-
var bbcodeEnabled = true;
+
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion, 10); // Get browser version
-var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
-var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
+var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1));
+var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1));
var baseHeight;
/**
@@ -29,7 +29,7 @@ function helpline(help)
* Fix a bug involving the TextRange object. From
* http://www.frostjedi.com/terra/scripts/demo/caretBug.html
*/
-function initInsertions()
+function initInsertions()
{
var doc;
@@ -37,14 +37,14 @@ function initInsertions()
{
doc = document;
}
- else
+ else
{
doc = opener.document;
}
var textarea = doc.forms[form_name].elements[text_name];
- if (is_ie && typeof(baseHeight) != 'number')
+ if (is_ie && typeof(baseHeight) !== 'number')
{
textarea.focus();
baseHeight = doc.selection.createRange().duplicate().boundingHeight;
@@ -60,12 +60,12 @@ function initInsertions()
* bbstyle
*/
function bbstyle(bbnumber)
-{
- if (bbnumber != -1)
+{
+ if (bbnumber !== -1)
{
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]);
- }
- else
+ }
+ else
{
insert_text('[*]');
document.forms[form_name].elements[text_name].focus();
@@ -104,10 +104,10 @@ function bbfontstyle(bbopen, bbclose)
theSelection = '';
return;
}
-
+
//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition(textarea).start;
- var new_pos = caret_pos + bbopen.length;
+ var new_pos = caret_pos + bbopen.length;
// Open tag
insert_text(bbopen + bbclose);
@@ -118,7 +118,7 @@ function bbfontstyle(bbopen, bbclose)
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
- }
+ }
// IE
else if (document.selection)
{
@@ -138,16 +138,17 @@ function bbfontstyle(bbopen, bbclose)
function insert_text(text, spaces, popup)
{
var textarea;
-
- if (!popup)
+
+ if (!popup)
{
textarea = document.forms[form_name].elements[text_name];
- }
- else
+ }
+ else
{
textarea = opener.document.forms[form_name].elements[text_name];
}
- if (spaces)
+
+ if (spaces)
{
text = ' ' + text + ' ';
}
@@ -165,20 +166,21 @@ function insert_text(text, spaces, popup)
}
else if (textarea.createTextRange && textarea.caretPos)
{
- if (baseHeight != textarea.caretPos.boundingHeight)
+ if (baseHeight !== textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret(textarea);
}
var caret_pos = textarea.caretPos;
- caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
+ caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
textarea.value = textarea.value + text;
}
- if (!popup)
+
+ if (!popup)
{
textarea.focus();
}
@@ -201,6 +203,7 @@ function addquote(post_id, username, l_wrote)
var message_name = 'message_' + post_id;
var theSelection = '';
var divarea = false;
+ var i;
if (l_wrote === undefined)
{
@@ -232,7 +235,7 @@ function addquote(post_id, username, l_wrote)
theSelection = document.selection.createRange().text;
}
- if (theSelection == '' || typeof theSelection == 'undefined' || theSelection == null)
+ if (theSelection === '' || typeof theSelection === 'undefined' || theSelection === null)
{
if (divarea.innerHTML)
{
@@ -282,6 +285,8 @@ function split_lines(text)
var lines = text.split('\n');
var splitLines = new Array();
var j = 0;
+ var i;
+
for(i = 0; i < lines.length; i++)
{
if (lines[i].length <= 80)
@@ -292,11 +297,12 @@ function split_lines(text)
else
{
var line = lines[i];
+ var splitAt;
do
{
- var splitAt = line.indexOf(' ', 80);
-
- if (splitAt == -1)
+ splitAt = line.indexOf(' ', 80);
+
+ if (splitAt === -1)
{
splitLines[j] = line;
j++;
@@ -308,22 +314,23 @@ function split_lines(text)
j++;
}
}
- while(splitAt != -1);
+ while(splitAt !== -1);
}
}
return splitLines;
}
+
/**
* From http://www.massless.org/mozedit/
*/
function mozWrap(txtarea, open, close)
{
- var selLength = (typeof(txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength;
+ var selLength = (typeof(txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;
- if (selEnd == 1 || selEnd == 2)
+ if (selEnd === 1 || selEnd === 2)
{
selEnd = selLength;
}
@@ -372,18 +379,18 @@ function colorPalette(dir, width, height)
for (r = 0; r < 5; r++)
{
- if (dir == 'h')
+ if (dir === 'h')
{
document.writeln('<tr>');
}
for (g = 0; g < 5; g++)
{
- if (dir == 'v')
+ if (dir === 'v')
{
document.writeln('<tr>');
}
-
+
for (b = 0; b < 5; b++)
{
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
@@ -392,13 +399,13 @@ function colorPalette(dir, width, height)
document.writeln('</td>');
}
- if (dir == 'v')
+ if (dir === 'v')
{
document.writeln('</tr>');
}
}
- if (dir == 'h')
+ if (dir === 'h')
{
document.writeln('</tr>');
}
@@ -406,7 +413,6 @@ function colorPalette(dir, width, height)
document.writeln('</table>');
}
-
/**
* Caret Position object
*/
@@ -416,43 +422,41 @@ function caretPosition()
var end = null;
}
-
/**
* Get the caret position in an textarea
*/
function getCaretPosition(txtarea)
{
var caretPos = new caretPosition();
-
+
// simple Gecko/Opera way
- if(txtarea.selectionStart || txtarea.selectionStart == 0)
+ if (txtarea.selectionStart || txtarea.selectionStart === 0)
{
caretPos.start = txtarea.selectionStart;
caretPos.end = txtarea.selectionEnd;
}
// dirty and slow IE way
- else if(document.selection)
+ else if (document.selection)
{
-
// get current selection
var range = document.selection.createRange();
// a new selection of the whole textarea
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea);
-
+
// calculate selection start point by moving beginning of range_all to beginning of range
var sel_start;
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++)
- {
+ {
range_all.moveStart('character', 1);
}
-
+
txtarea.sel_start = sel_start;
-
+
// we ignore the end value for IE, this is already dirty enough and we don't need it
caretPos.start = txtarea.sel_start;
- caretPos.end = txtarea.sel_start;
+ caretPos.end = txtarea.sel_start;
}
return caretPos;