Ver Mensaje Individual
  #4 (permalink)  
Antiguo 23/08/2005, 14:04
dey
 
Fecha de Ingreso: febrero-2004
Mensajes: 31
Antigüedad: 20 años, 2 meses
Puntos: 0
function mostrarPanel(panel, event) {
var source = getEventSource(event);
var target = document.getElementById(panel);
target.style.left = isIE? event.clientX + document.body.scrollLeft : event.pageX;
target.style.top = isIE? event.clientY + document.body.scrollTop : event.pageY;
target.style.visibility = "visible";
}

function ocultarPanel(panel) {
document.getElementById(panel).style.visibility = 'hidden';
}

function addTimer(source) {
if (!timers[source])
timers[source] = setTimeout("ocultarPanel('"+source+"');", 500)
}

function cancelTimer(source) {
if (timers[source]) {
clearTimeout(timers[source]);
timers[source] = false;
}
}

function getStyle(textarea) {
return isIE? getStyleIE(textarea) : getStyleNoIE(textarea);
}

function getStyleIE(textarea) {
var border = textarea.style.border ? textarea.style.border : null;
var bgcolor = textarea.style.backgroundColor ? textarea.style.backgroundColor : null;
var width = textarea.style.width ? textarea.style.width : null;
var height = textarea.style.height ? textarea.style.height : null;

var rules;
var styles = document.styleSheets;
for (var i=0; i<styles.length; i++) {
rules = styles[i].rules;
for (var j=0; j<rules.length; j++) {
if (rules[j].selectorText == "TEXTAREA") {
if (!border) border = rules[j].style.border;
if (!bgcolor) bgcolor = rules[j].style.backgroundColor;
if (!width) width = rules[j].style.width;
if (!height) height = rules[j].style.height;
}
}
}

if (!border) border = config['border'];
if (!bgcolor) bgcolor = config['bgcolor'];
if (!width) width = textarea.offsetWidth;
if (!height) height = textarea.offsetHeight;

if (bgcolor.length == 4) {
bgcolor = "#"+bgcolor.charAt(1)+bgcolor.charAt(1)+bgcolor.ch arAt(2)+bgcolor.charAt(2)+bgcolor.charAt(3)+bgcolo r.charAt(3);
}

return { border: border, bgcolor: bgcolor, width: width, height: height };
}

function getStyleNoIE(textarea) {
var border = textarea.style.border ? textarea.style.border : null;
var bgcolor = textarea.style.backgroundColor ? textarea.style.backgroundColor : null;
var width = textarea.style.width ? textarea.style.width : null;
var height = textarea.style.height ? textarea.style.height : null;

var rules, text, aux;
var styles = document.styleSheets;
for (var i=0; i<styles.length; i++) {
rules = styles[i].cssRules;
for (var j=0; j<rules.length; j++) {
text = rules[j].cssText.toLowerCase();
if (text.match("[^{]*textarea[^{]\\{")) {
if (!border && (aux = text.match("(\\s|;)border:([^;]*);"))) border = aux[2];
if (!bgcolor && (aux = text.match("(\\s|;)background-color:([^;]*);"))) bgcolor = aux[2];
if (!width && (aux = text.match("(\\s|;)width:([^;]*);"))) width = aux[2];
if (!height && (aux = text.match("(\\s|;)height:([^;]*);"))) height = aux[2];
}
}
}

if (!border) border = config['border'];
if (!bgcolor) bgcolor = config['bgcolor'];
if (!width) width = textarea.offsetWidth;
if (!height) height = textarea.offsetHeight;

return { border: border, bgcolor: bgcolor, width: width, height: height };
}

function getValidId(name) {
var id;
if (!name) name = "text";
if (!document.getElementById(name))
id = name;
else
for (var i=1; document.getElementById(id = name+i); i++);
return id;
}

function getEventSource(event) {
return isIE ? event.srcElement : event.target;
}

function setEventSource(event, src) {
if (isIE)
event.srcElement = src;
else
event.target = src;
}

function resetForm(event) {
var source = getEventSource(event);
var textareas = source.getElementsByTagName('textarea');
var iframe;
for (var i=0; i<textareas.length; i++) {
iframe = document.getElementById(textareas[i].id+"_edit");
if (iframe)
getDocument(iframe).body.innerHTML = textareas[i].startContent;
}
}

function setTextareaContent(event, element) {
var source = document.getElementById(element ? element : getEventSource(event).ownerDocument.editor);
var target = document.getElementById(source.id.substring(0, source.id.indexOf("_")));
target.value = getDocument(source).body.innerHTML;
}

function addImage(src, editor, command, coment) {
return '<img src="http://www.somosciudadanos.org.ve/WYSIWYG/images/actions/'+src+'" onmouseover="seleccionar(this, \'#B6BDD2\');" onmouseout="desseleccionar(this);" onmousedown="seleccionar(this, \'#8592B5\');" onclick="executeCommand(\''+editor+'\', \''+command+'\', event); desseleccionar(this);" style="border: 1px solid #F0F0EE; width; 2px; height: 20px; cursor: pointer;" alt="'+coment+'" title="'+coment+'">';
}

function addEmoticon (src, editor, coment) {
return '<img src="http://www.somosciudadanos.org.ve/WYSIWYG/images/emoticons/'+src+'" onmouseover="this.style.backgroundColor = \'#B6BDD2\';" onmouseout="this.style.backgroundColor = \'#F0F0EE\';" onclick="executeCommand(\''+editor+'\', \'insertimage\', event, this.src);" style="width; 18px; height: 18px; cursor: pointer;" alt="'+coment+'" title="'+coment+'">';
}

function addSeparator() {
return '<img src="http://www.somosciudadanos.org.ve/WYSIWYG/images/spacer.gif" style="width; 2px; height: 20px;" alt="" title="">';
}

function seleccionar(img, fondo) {
img.style.backgroundColor = fondo;
img.style.border = '1px solid #0A246A';
}

function desseleccionar(img) {
img.style.backgroundColor = '#F0F0EE';
img.style.border = '1px solid #F0F0EE';
}

function getDocument(iframe) {
return isIE? document.frames[iframe.id].window.document : iframe.contentDocument;
}

function executeCommand(element, command, event, text) {
var iframe = document.getElementById(element);

if (command.toLowerCase() == "insertimage" && !text) {
text = prompt("Introduce la URL de la imagen", "");
if (text == null || text == "") return;
}

if (command.toLowerCase() == "createlink" && !isIE) {
text = prompt("Introduce la URL del enlace", "");
if (text == null || text.match("^\\s*$")) {
iframe.contentWindow.focus();
return;
}
if ((selection = iframe.contentWindow.getSelection()) == "") {
var link = document.createElement("a");
link.innerHTML = link.href = text;
selection.getRangeAt(0).insertNode(link);
selection.addRange(selection.getRangeAt(0).cloneRa nge());
selection.getRangeAt(1).setEndAfter(link);
selection.getRangeAt(1).setStartAfter(link);
selection.removeRange(selection.getRangeAt(0));
iframe.contentWindow.focus();
return;
}
}

if (command.toLowerCase() == "emoticons") {
mostrarPanel(element.substring(0, element.indexOf("_"))+"_emo", event);
return;
}

iframe.contentWindow.focus();
getDocument(iframe).execCommand(command, false, text);

setTextareaContent(event, element);
}