+ Updated WYSIWYG posts editor - Wyzz from version 0.62 to 0.65

+ Added option: displaying no_av.gif file, when avatar in profile not set

git-svn-id: https://svn.pioder.pl/uf-svn/uF@25 72ec579a-5ced-4fa4-82f3-afba5d98df2f
This commit is contained in:
pioder
2009-05-07 16:30:56 +00:00
parent 252bd28722
commit 71b7f52acf
4 changed files with 84 additions and 77 deletions

View File

@@ -1,23 +1,25 @@
/** /**
* @package Dynamic Script Forum * @package uForum
* @file wyzz.js * @file images/wyzz.js
* @version 1.0.x, 19-10-2007, 18:03 * @version $Id$
* @copyright 2008(c) DSF Team * @copyright 2009(c) The Mouse Whisperer
* @author ------------------ * @author The Mouse Whisperer
* @link http://dsf.gim2przemysl.int.pl/ * @modified PioDer <pioder@wp.pl>
* @link http://pioder.gim2przemysl.int.pl/
* @license GNU GPL v3 * @license GNU GPL v3
**/ **/
// Editor Width and Height // Editor Width and Height
wyzzW = 600; wyzzW = 600;
wyzzH = 200; wyzzH = 200;
image_path = skin_path + 'images/'; image_path = skin_path + 'images/';// Number of toolbars - must be either 1 or 2
// Number of toolbars - must be either 1 or 2
// If set to 1, the first tooolbar (defined in array buttonName below) will be ignored // If set to 1, the first tooolbar (defined in array buttonName below) will be ignored
toolbarCount = 2; toolbarCount = 2;
// Edit region stylesheet // Edit region stylesheet
editstyle = skin_path + 'wyzz_editarea.css'; editstyle = skin_path + 'wyzz_editarea.css';
// Do we want to try to clean the code to emulate xhtml? 1=Yes, 0=No // Do we want to try to clean the code to emulate xhtml? 1=Yes, 0=No
xhtml_out = 0; xhtml_out = 0;
@@ -29,11 +31,9 @@ document.write('<link rel="stylesheet" type="text/css" href="'+ skin_path+'wyzz_
// Remove from this any buttons not required in your application // Remove from this any buttons not required in your application
var buttonName = new Array("font","headers","separator","bold","italic","underline","strikethrough","separator","cut","copy","paste","separator","subscript","superscript","separator","justifyleft","justifycenter","justifyright","justifyfull","indent","outdent","separator","insertunorderedlist","insertorderedlist","separator","link","insertimage","separator","undo","redo"); var buttonName = new Array("font","headers","separator","bold","italic","underline","strikethrough","separator","cut","copy","paste","separator","subscript","superscript","separator","justifyleft","justifycenter","justifyright","justifyfull","indent","outdent","separator","insertunorderedlist","insertorderedlist","separator","link","insertimage","separator","undo","redo");
// Order of available commands in toolbar2 // Order of available commands in toolbar2
// Remove from this any buttons not required in your application // Remove from this any buttons not required in your application
var buttonName2 = new Array("specialchar","separator","forecolor","backcolor","separator","inserthorizontalrule","separator","removeformat","separator","upsize","downsize","separator","htmlmode","separator"); var buttonName2 = new Array("specialchar","separator","forecolor","backcolor","separator","inserthorizontalrule","separator","removeformat","separator","upsize","downsize","separator","htmlmode","separator","help");
var myFonts = new Array("Andale Mono","Georgia","Verdana","Arial","Arial Black","impact","Times New Roman","Courier New","Comic Sans MS","Helvetica","Trebuchet MS","Tahoma"); var myFonts = new Array("Andale Mono","Georgia","Verdana","Arial","Arial Black","impact","Times New Roman","Courier New","Comic Sans MS","Helvetica","Trebuchet MS","Tahoma");
@@ -42,7 +42,7 @@ var specialChars = new Array("&copy;","&reg;","&#153;","&agrave;","&aacute;","&c
// DON'T MODIFY BEYOND THIS LINE unless you know what you are doing ////////////// // DON'T MODIFY BEYOND THIS LINE unless you know what you are doing //////////////
/********************************************************************************/ /********************************************************************************/
version = "0.62"; // Please leave this version = "0.65"; // Please leave this
var Headers = new Array("P","PRE","H1","H2","H3","H4","H5","H6"); var Headers = new Array("P","PRE","H1","H2","H3","H4","H5","H6");
@@ -52,6 +52,21 @@ mode = 1;
// Get browser // Get browser
browserName = navigator.appName; browserName = navigator.appName;
// New code for additional browser support
if (navigator.userAgent.indexOf('Safari') !=-1)
{
browserName = "Safari";
}
if (navigator.userAgent.indexOf('Chrome') !=-1)
{
browserName = "Chrome";
}
if (navigator.userAgent.indexOf('Firefox') !=-1)
{
browserName = "Firefox";
}
nlBefore = new Array("div","p","li","h1","h2","h3","h4","h5","h6","hr","ul","ol"); nlBefore = new Array("div","p","li","h1","h2","h3","h4","h5","h6","hr","ul","ol");
function h2x(node,inPre) { // we will pass the node containing the Wyzz-generated html function h2x(node,inPre) { // we will pass the node containing the Wyzz-generated html
@@ -187,7 +202,7 @@ function indexOf(thisarray, value)
// Color picker - here we make an array of all websafe colors // Color picker - here we make an array of all websafe colors
// If you want to limit the colors available to users (e.g. to fit in with // If you want to limit the colors available to users (e.g. to fit in with
// a site design) then use a restricted array of colors // a site design) then use a restricted array of colors
// e.g. var buttonName = new Array("336699","66abff", .... etc // e.g. var buttonColors = new Array("336699","66abff", .... etc
var buttonColors = new Array(216); var buttonColors = new Array(216);
// Colors - replace this function with your own if you have special requirements for colors // Colors - replace this function with your own if you have special requirements for colors
@@ -216,11 +231,12 @@ getColorArray();
/* Emulates insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement() three functions /* Emulates insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement() three functions
so they work with Netscape 6/Mozilla - By Thor Larholm me@jscript.dk */ so they work with Netscape 6/Mozilla - By Thor Larholm me@jscript.dk */
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) { if(typeof HTMLElement!='undefined'){
if(typeof HTMLElement.insertAdjacentHTML=='undefined'){
HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){ HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
switch(where){ switch(where){
case 'beforeBegin': case 'beforeBegin':
this.parentNode.insertBefore(parsedNode,this) this.parentNode.insertBefore(parsedNode,this);
break; break;
case 'afterBegin': case 'afterBegin':
this.insertBefore(parsedNode,this.firstChild); this.insertBefore(parsedNode,this.firstChild);
@@ -233,21 +249,24 @@ if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentEleme
this.parentNode.insertBefore(parsedNode,this.nextSibling); this.parentNode.insertBefore(parsedNode,this.nextSibling);
}else{ }else{
this.parentNode.appendChild(parsedNode); this.parentNode.appendChild(parsedNode);
}
break; break;
} }
};
} }
} if(typeof HTMLElement.insertAdjacentHTML=='undefined'){
HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){ HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){
var r=this.ownerDocument.createRange(); var r=this.ownerDocument.createRange();
r.setStartBefore(this); r.setStartBefore(this);
var parsedHTML=r.createContextualFragment(htmlStr); var parsedHTML=r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML) this.insertAdjacentElement(where,parsedHTML);
};
} }
if(typeof HTMLElement.insertAdjacentText=='undefined'){
HTMLElement.prototype.insertAdjacentText=function(where,txtStr){ HTMLElement.prototype.insertAdjacentText=function(where,txtStr){
var parsedText = document.createTextNode(txtStr) var parsedText=document.createTextNode(txtStr);
this.insertAdjacentElement(where,parsedText) this.insertAdjacentElement(where,parsedText);
};
} }
} }
@@ -273,6 +292,7 @@ function insertLink(n) {
} }
function insertImage(n) { function insertImage(n) {
alert(n);
var imgurl = prompt(editor_lng4); var imgurl = prompt(editor_lng4);
var imgtitle = 'image'; var imgtitle = 'image';
var theImage = '<img src="' + imgurl + '" title="' + imgtitle + '" alt="' + imgtitle + '" />'; var theImage = '<img src="' + imgurl + '" title="' + imgtitle + '" alt="' + imgtitle + '" />';
@@ -384,7 +404,7 @@ function make_wyzz(textareaID) {
// The help/about box // The help/about box
// The copyright and link must remain unaltered // The copyright and link must remain unaltered
toolbar2 += '<div id="helpbox' + n + '" class="helpbox" style="display:none">'; toolbar2 += '<div id="helpbox' + n + '" class="helpbox" style="display:none">';
toolbar2 += '<div class="help"><h4><img src="' + image_path + 'wyzz/wyzzicon.gif" align="middle">Wyzz v' + version + '</h4><br>&copy; 2007 <a href="http://www.wyzz.info" target=_blank>www.wyzz.info</a><br><br></div>'; toolbar2 += '<div class="help"><h4>Wyzz v' + version + '</h4><br>Running on ' + browserName + '<br>&copy; 2009 <a href="http://www.wyzz.info" target=_blank>www.wyzz.info</a><br><br></div>';
toolbar2 += '<img class="closebutton" src="' + image_path + 'wyzz/close.gif" border=0 onclick="closeColorPicker(\'helpbox' + n + '\')"></div></td></tr></table>'; toolbar2 += '<img class="closebutton" src="' + image_path + 'wyzz/close.gif" border=0 onclick="closeColorPicker(\'helpbox' + n + '\')"></div></td></tr></table>';
// Create iframe for editor // Create iframe for editor
@@ -412,8 +432,7 @@ var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:' +
} }
doc.close(); doc.close();
// var browserName = navigator.appName; if (browserName == "Microsoft Internet Explorer") {
if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {
// Make the iframe editable // Make the iframe editable
doc.body.contentEditable = true; doc.body.contentEditable = true;
} else { } else {
@@ -422,13 +441,11 @@ var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:' +
} }
// Update the textarea with content in WYSIWYG when user submits form // Update the textarea with content in WYSIWYG when user submits form
// var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") { if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {
for (var idx=0; idx < document.forms.length; idx++) { for (var idx=0; idx < document.forms.length; idx++) {
document.forms[idx].attachEvent('onsubmit', function() { updateTextArea(n); }); document.forms[idx].attachEvent('onsubmit', function() { updateTextArea(n); });
} }
} } else {
else {
for (var idx=0; idx < document.forms.length; idx++) { for (var idx=0; idx < document.forms.length; idx++) {
document.forms[idx].addEventListener('submit',function OnSumbmit() { updateTextArea(n); }, true); document.forms[idx].addEventListener('submit',function OnSumbmit() { updateTextArea(n); }, true);
} }
@@ -436,11 +453,13 @@ var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:' +
} }
function formatTextColor(color, n, selected) { function formatTextColor(color, n, selected) {
if (browserName == "Microsoft Internet Explorer"||browserName == "Chrome") { color = '#' + color; }
document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('forecolor', false, color); document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('forecolor', false, color);
document.getElementById('colorpicker' + n).style.display = "none"; document.getElementById('colorpicker' + n).style.display = "none";
} }
function formatBackColor(color, n, selected) { function formatBackColor(color, n, selected) {
if (browserName == "Microsoft Internet Explorer"||browserName == "Chrome") { color = '#' + color; }
if (browserName == "Microsoft Internet Explorer") { if (browserName == "Microsoft Internet Explorer") {
document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('backcolor', false, color); document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('backcolor', false, color);
} else { } else {
@@ -558,7 +577,6 @@ function formatText(id, n, selected) {
} }
} }
else if(id=="link"){ else if(id=="link"){
// var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer") { if (browserName == "Microsoft Internet Explorer") {
var target = confirm('Should this link open in a new window?\n\nOK = Open in NEW Window\nCancel = Open in THIS window'); var target = confirm('Should this link open in a new window?\n\nOK = Open in NEW Window\nCancel = Open in THIS window');
document.getElementById("wysiwyg" + n).contentWindow.document.execCommand('createLink',true,' '); document.getElementById("wysiwyg" + n).contentWindow.document.execCommand('createLink',true,' ');
@@ -571,7 +589,6 @@ function formatText(id, n, selected) {
} }
} }
else if(id=="insertimage") { else if(id=="insertimage") {
// var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer") { if (browserName == "Microsoft Internet Explorer") {
document.getElementById("wysiwyg" + n).contentWindow.document.execCommand(id, true, null); document.getElementById("wysiwyg" + n).contentWindow.document.execCommand(id, true, null);
} else { } else {
@@ -585,7 +602,6 @@ function formatText(id, n, selected) {
} }
function insertHTML(html, n) { function insertHTML(html, n) {
// var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer") { if (browserName == "Microsoft Internet Explorer") {
document.getElementById('wysiwyg' + n).contentWindow.document.selection.createRange().pasteHTML(html); document.getElementById('wysiwyg' + n).contentWindow.document.selection.createRange().pasteHTML(html);
} }
@@ -619,18 +635,14 @@ function insertNodeAtSelection(insertNode, n) {
range = document.createRange(); range = document.createRange();
if (container.nodeType==3 && insertNode.nodeType==3) { if (container.nodeType==3 && insertNode.nodeType==3) {
// if we insert text in a textnode, do optimized insertion // if we insert text in a textnode, do optimized insertion
container.insertData(pos, insertNode.nodeValue); container.insertData(pos, insertNode.nodeValue);
// put cursor after inserted text // put cursor after inserted text
range.setEnd(container, pos+insertNode.length); range.setEnd(container, pos+insertNode.length);
range.setStart(container, pos+insertNode.length); range.setStart(container, pos+insertNode.length);
} } else {
else {
var afterNode; var afterNode;
if (container.nodeType==3) { if (container.nodeType==3) {
// when inserting into a textnode we create 2 new textnodes and put the insertNode in between // when inserting into a textnode we create 2 new textnodes and put the insertNode in between
var textNode = container; var textNode = container;
@@ -653,18 +665,14 @@ function insertNodeAtSelection(insertNode, n) {
// remove the old node // remove the old node
container.removeChild(textNode); container.removeChild(textNode);
} } else {
else {
// else simply insert the node // else simply insert the node
afterNode = container.childNodes[pos]; afterNode = container.childNodes[pos];
container.insertBefore(insertNode, afterNode); container.insertBefore(insertNode, afterNode);
} }
range.setEnd(afterNode, 0); range.setEnd(afterNode, 0);
range.setStart(afterNode, 0); range.setStart(afterNode, 0);
} }
sel.addRange(range); sel.addRange(range);
} }
@@ -676,9 +684,8 @@ function updateTextArea(n) {
} }
} }
function grabSelectedText(n){ function grabSelectedText(n){
// var browserName = navigator.appName;
var selectedText = ''; var selectedText = '';
// for IE // for IE
if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") { if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -78,7 +78,7 @@ while($item=DataBase::fetch($query))
alt="edit" onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small_active.gif\'" alt="edit" onMouseOver="this.style.cursor=\'hand\'; this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small_active.gif\'"
onMouseOut="this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small.gif\'"></a><br>' : '' : '', onMouseOut="this.src=\'skins/'.$default_skin.'/images/lng_'.$default_lang.'/edit_small.gif\'"></a><br>' : '' : '',
'userrank' => User::UserRank($item['rank']), 'userrank' => User::UserRank($item['rank']),
'avatar' => ($item['avatar']!='') ? '<img src="'.$item['avatar'].'" alt="av">' : '<br><br><br><br>', 'avatar' => ($item['avatar']!='') ? '<img src="'.$item['avatar'].'" alt="av">' : '<img src="skins/'.$default_skin.'/images/no_av.gif" alt="av">',
'posttext' => Topic::PostText($item['text'], $item['moderated'], $item['p_id']), 'posttext' => Topic::PostText($item['text'], $item['moderated'], $item['p_id']),
'sig'=>($item['sig']!='') ? '<br><br>----------------<br>'.$item['sig'] : '', 'sig'=>($item['sig']!='') ? '<br><br>----------------<br>'.$item['sig'] : '',
'posts'=>$item['posts'], 'posts'=>$item['posts'],