Import xinha so we can switch from htmlarea and fix a bunch of in-browser issues that htmlarea has

This commit is contained in:
Chris Morgan
2005-09-30 02:25:07 +00:00
committed by WineHQ
parent 2311d4d572
commit 9242a68c4a
375 changed files with 26623 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
-----------------------------------------
author: Cau guanabara
e-mail: caugb@ibest.com.br
\*---------------------------------------*/
function FindReplace(editor) {
this.editor = editor;
var cfg = editor.config;
var self = this;
cfg.registerButton("FR-findreplace", this._lc("Find and Replace"),
editor.imgURL("ed_find.gif", "FindReplace"), false,
function(editor) { self.buttonPress(editor); });
cfg.addToolbarElement(["FR-findreplace","separator"], ["formatblock","fontsize","fontname"], -1);
};
FindReplace.prototype.buttonPress = function(editor) {
FindReplace.editor = editor;
var sel = editor.getSelectedHTML();
if(/\w/.test(sel)) {
sel = sel.replace(/<[^>]*>/g,"");
sel = sel.replace(/&nbsp;/g,"");
}
var param = /\w/.test(sel) ? {fr_pattern: sel} : null;
editor._popupDialog("plugin://FindReplace/find_replace", null, param);
};
FindReplace._pluginInfo = {
name : "FindReplace",
version : "1.0 - beta",
developer : "Cau Guanabara",
developer_url : "mailto:caugb@ibest.com.br",
c_owner : "Cau Guanabara",
sponsor : "Independent production",
sponsor_url : "http://www.netflash.com.br/gb/HA3-rc1/examples/find-replace.html",
license : "htmlArea"
};
FindReplace.prototype._lc = function(string) {
return HTMLArea._lc(string, 'FindReplace');
}

View File

@@ -0,0 +1,149 @@
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
-----------------------------------------
author: Cau guanabara
e-mail: caugb@ibest.com.br
\*---------------------------------------*/
var FindReplace = window.opener.FindReplace;
var editor = FindReplace.editor;
var is_mo = window.opener.HTMLArea.is_gecko;
var tosearch = '';
var pater = null;
var buffer = null;
var matches = 0;
var replaces = 0;
var fr_spans = new Array();
function _lc(string) {
return(window.opener.HTMLArea._lc(string, 'FindReplace'));
}
function execSearch(params) {
var ihtml = editor._doc.body.innerHTML;
if(buffer == null)
buffer = ihtml;
if(params['fr_pattern'] != tosearch) {
if(tosearch != '')
clearDoc();
tosearch = params['fr_pattern'];
}
if(matches == 0) {
er = params['fr_words'] ? "/(?!<[^>]*)(\\b"+params['fr_pattern']+"\\b)(?![^<]*>)/g" :
"/(?!<[^>]*)("+params['fr_pattern']+")(?![^<]*>)/g";
if(!params['fr_matchcase'])
er += "i";
pater = eval(er);
var tago = '<span id=frmark>';
var tagc = '</span>';
var newHtml = ihtml.replace(pater,tago+"$1"+tagc);
editor.setHTML(newHtml);
var getallspans = editor._doc.body.getElementsByTagName("span");
for (var i = 0; i < getallspans.length; i++)
if(/^frmark/.test(getallspans[i].id))
fr_spans.push(getallspans[i]);
}
spanWalker(params['fr_pattern'],params['fr_replacement'],params['fr_replaceall']);
};
function spanWalker(pattern,replacement,replaceall) {
var foundtrue = false;
clearMarks();
for (var i = matches; i < fr_spans.length; i++) {
var elm = fr_spans[i];
foundtrue = true;
if(!(/[0-9]$/.test(elm.id))) {
matches++;
disab('fr_clear',false);
elm.id = 'frmark_'+matches;
elm.style.color = 'white';
elm.style.backgroundColor = 'highlight';
elm.style.fontWeight = 'bold';
elm.scrollIntoView(false);
if(/\w/.test(replacement)) {
if(replaceall || confirm(_lc("Substitute this occurrence?"))) {
elm.firstChild.replaceData(0,elm.firstChild.data.length,replacement);
replaces++;
disab('fr_undo',false);
}
if(replaceall) {
clearMarks();
continue;
}
}
break;
}
}
var last = (i >= fr_spans.length - 1);
if(last || !foundtrue) { // EOF
var message = _lc("Done")+':\n\n';
if(matches > 0) {
if(matches == 1) message += matches+' '+_lc("found item");
else message += matches+' '+_lc("found items");
if(replaces > 0) {
if(replaces == 1) message += ',\n'+replaces+' '+_lc("replaced item");
else message += ',\n'+replaces+' '+_lc("replaced items");
}
hiliteAll();
disab('fr_hiliteall',false);
} else { message += '"'+pattern+'" '+_lc("not found"); }
alert(message+'.');
}
};
function clearDoc() {
var doc = editor._doc.body.innerHTML;
var er = /(<span\s+[^>]*id=.?frmark[^>]*>)([^<>]*)(<\/span>)/gi;
editor._doc.body.innerHTML = doc.replace(er,"$2");
pater = null;
tosearch = '';
fr_spans = new Array();
matches = 0;
replaces = 0;
disab("fr_hiliteall,fr_clear",true);
};
function clearMarks() {
var getall = editor._doc.body.getElementsByTagName("span");
for (var i = 0; i < getall.length; i++) {
var elm = getall[i];
if(/^frmark/.test(elm.id)) {
var objStyle = editor._doc.getElementById(elm.id).style;
objStyle.backgroundColor = "";
objStyle.color = "";
objStyle.fontWeight = "";
}
}
};
function hiliteAll() {
var getall = editor._doc.body.getElementsByTagName("span");
for (var i = 0; i < getall.length; i++) {
var elm = getall[i];
if(/^frmark/.test(elm.id)) {
var objStyle = editor._doc.getElementById(elm.id).style;
objStyle.backgroundColor = "highlight";
objStyle.color = "white";
objStyle.fontWeight = "bold";
}
}
};
function resetContents() {
if(buffer == null) return;
var transp = editor._doc.body.innerHTML;
editor._doc.body.innerHTML = buffer;
buffer = transp;
};
function disab(elms,toset) {
var names = elms.split(/[,; ]+/);
for(var i = 0; i < names.length; i++)
document.getElementById(names[i]).disabled = toset;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

View File

@@ -0,0 +1,38 @@
// I18N constants
// LANG: "de", ENCODING: UTF-8
// translated: gocher / udo.schmal@t-online.de
// FOR TRANSLATORS:
//
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
// messages
"Substitute this occurrence?": "Treffer ersetzen?",
"Enter the text you want to find": "Geben Sie einen Text ein den Sie finden möchten",
"Inform a replacement word": "Geben sie einen Text zum ersetzen ein",
"found items": "alle Treffer",
"replaced items": "ersetzte Treffer",
"found item": "Treffer",
"replaced item": "ersetzter Treffer",
"not found": "kein Teffer",
// window
"Find and Replace": "Suchen und ersetzen",
"Search for:": "Suchen nach:",
"Replace with:": "Ersetzen durch:",
"Options": "Optionen",
"Whole words only": "Ganze Wörter",
"Case sensitive search": "Groß-/Kleinschreibung",
"Substitute all occurrences": "alle Treffer ersetzen",
"Clear": "Nächstes ersetzen",
"Highlight": "Hervorheben",
"Undo": "Rückgängig",
"Next": "Nächster",
"Done": "Fertig"
}

View File

@@ -0,0 +1,26 @@
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
// messages
"Substitute this occurrence?": "Remplacer cette occurrence ?",
"Enter the text you want to find": "Texte à trouver",
"Inform a replacement word": "Geben sie einen Text zum ersetzen ein",
"found items": "éléments trouvés",
"replaced items": "éléments remplacés",
"found item": "élément trouvé",
"replaced item": "élément remplacé",
"not found": "non trouvé",
// window
"Find and Replace": "Chercher et Remplacer",
"Search for:": "Chercher",
"Replace with:": "Remplacer par",
"Options": "Options",
"Whole words only": "Mots entiers seulement",
"Case sensitive search": "Recherche sensible à la casse",
"Substitute all occurrences": "Remplacer toutes les occurences",
"Clear": "Effacer",
"Highlight": "Surligner",
"Undo": "Annuler",
"Next": "Suivant",
"Done": "Fin"
}

View File

@@ -0,0 +1,28 @@
// I18N constants
// LANG: "no", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
// messages
"Substitute this occurrence?": "Vennligst bekreft at du vil erstatte?",
"Enter the text you want to find": "Skriv inn teksten du ønsker å finne",
"Inform a replacement word": "Vennligst skriv inn et erstattningsord / settning",
"found items": "forekomster funnet i søket",
"replaced items": "forekomster erstattet",
"found item": "Treff",
"replaced item": "erstattet treff",
"not found": "ikke funnet",
// window
"Find and Replace": "Søk og erstatt",
"Search for:": "Søk etter:",
"Replace with:": "Erstatt med:",
"Options": "Valg",
"Whole words only": "Bare hele ord",
"Case sensitive search": "Skille mellom store og små bokstaver",
"Substitute all occurrences": "Erstatt alle treff",
"Clear": "Tøm",
"Highlight": "Uthev",
"Undo": "Tilbake",
"Next": "Neste",
"Done": "Ferdig"
}

View File

@@ -0,0 +1,38 @@
/ I18N constants
// LANG: "pl", ENCODING: UTF-8
// translated: Krzysztof Kotowicz, koto1sa@o2.pl, http://www.eskot.krakow.pl/portfolio
// FOR TRANSLATORS:
//
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
// messages
"Substitute this occurrence?": "Zamienić to wystąpienie?",
"Enter the text you want to find": "Podaj tekst, jaki chcesz wyszukać",
"Inform a replacement word": "Podaj tekst do zamiany",
"found items": "znalezionych",
"replaced items": "zamienionych",
"found item": "znaleziony",
"replaced item": "zamieniony",
"not found": "nie znaleziony",
// window
"Find and Replace": "Znajdź i zamień",
"Search for:": "Szukaj:",
"Replace with:": "Zamień na:",
"Options": "Opcje",
"Whole words only": "Całe słowa",
"Case sensitive search": "Wg wielkości liter",
"Substitute all occurrences": "Zamień wszystkie wystąpienia",
"Clear": "Wyczyść",
"Highlight": "Podświetl",
"Undo": "Cofnij",
"Next": "Następny",
"Done": "Gotowe"
}

View File

@@ -0,0 +1,35 @@
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
by Cau guanabara (independent developer)
e-mail: caugb@ibest.com.br
* Feito no Brasil *
\*---------------------------------------*/
// I18N {pt-br) for FindReplace plugin
{
// mensagens
"Substitute this occurrence?": "Substituir?",
"Enter the text you want to find": "Digite um termo para a busca",
"Inform a replacement word": "Informe um termo para a substituição",
"found items": "itens localizados",
"replaced items": "itens substituídos",
"found item": "item localizado",
"replaced item": "item substituído",
"not found": "não encontrado",
// janela
"Find and Replace": "Localizar e Substituir",
"Search for:": "Localizar:",
"Replace with:": "Substituir por:",
"Options": "Opções",
"Whole words only": "Apenas palavras inteiras",
"Case sensitive search": "Diferenciar caixa alta/baixa",
"Substitute all occurrences": "Substituir todas",
"Highlight": "Remarcar",
"Clear": "Limpar",
"Undo": "Desfazer",
"Next": "Próxima",
"Done": "Concluído"
};

View File

@@ -0,0 +1,162 @@
<html>
<head>
<title>Find and Replace</title>
<!--
/*---------------------------------------*\
Find and Replace Plugin for HTMLArea-3.0
-----------------------------------------
author: Cau guanabara
e-mail: caugb@ibest.com.br
\*---------------------------------------*/
-->
<script type="text/javascript" src="../fr_engine.js"></script>
<script type="text/javascript" src="../../../popups/popup.js"></script>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript">
window.resizeTo(335, 250);
var accepted = {
'fr_pattern' : true,
'fr_replacement' : true,
'fr_words' : true,
'fr_matchcase' : true,
'fr_replaceall' : true
};
function Init() {
__dlg_translate('FindReplace');
__dlg_init();
disab("fr_undo,fr_clear,fr_hiliteall",true);
var params = window.dialogArguments;
if(params) {
document.getElementById('fr_pattern').value = params["fr_pattern"];
document.getElementById('fr_replacement').focus();
} else {
document.getElementById('fr_pattern').focus();
}
document.body.onkeypress = __dlg_key_press;
};
function onCancel() {
clearDoc();
__dlg_close(null);
return false;
};
function onOK() {
var required = {'fr_pattern' : _lc("Enter the text you want to find")};
for (var i in required) {
var el = document.getElementById(i);
if (!el.value) {
alert(required[i]);
el.focus();
return false;
}
}
var param = {};
for (var i in accepted) {
var el = document.getElementById(i);
param[i] = el.type == 'checkbox' ? el.checked : el.value;
}
execSearch(param);
return false;
};
function __dlg_key_press(ev) {
ev || (ev = window.event);
switch(ev.keyCode) {
case 13:
document.getElementById('fr_go').click();
document.getElementById('fr_pattern').focus();
break;
case 27:
clearDoc();
window.close();
return false;
}
return true;
};
</script>
<style type="text/css">
table .label { text-align: right; width: 12em; }
.title {
background: #ddf;
color: #000;
font-weight: bold;
font-size: 120%;
padding: 3px 10px;
margin-bottom: 10px;
border-bottom: 1px solid black;
letter-spacing: 2px;
}
.buttons { border-top: 1px solid #999; padding: 2px; text-align: right; }
.hrstyle { border-width: 1px; border-color: #666; width: 95%; padding: 2px; }
</style>
</head>
<body class="dialog" onload="Init()">
<form action="" method="get">
<div class="title" style="width: 310px">Find and Replace</div>
<table border="0" style="width: 100%; padding: 2px;"><!---->
<tbody>
<tr>
<td width="29%" align="right" valign="bottom">Search for:</td>
<td width="71%" colspan="2" valign="bottom">
<input id="fr_pattern" type="text" style="width: 200px" onFocus="this.select();">
</td>
</tr>
<tr>
<td align="right">Replace with:</td>
<td colspan="2">
<input id="fr_replacement" type="text" style="width: 200px" onFocus="this.select();">
</td>
</tr>
<tr>
<td colspan="3"><table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="78%" style="padding: 2px">
<FIELDSET style="width:90%; padding: 5px">
<LEGEND><span>Options</span></LEGEND>
<input id="fr_words" type="checkbox" checked onClick="clearDoc();">
<span onClick="e = document.getElementById('fr_words');
e.click(); e.focus();" style="cursor:default">
<span>Whole words only</span></span><br />
<input id="fr_matchcase" type="checkbox" onClick="clearDoc();">
<span onClick="e = document.getElementById('fr_matchcase');
e.click(); e.focus();" style="cursor:default">
<span>Case sensitive search</span></span><br />
<input id="fr_replaceall" type="checkbox" onClick="
if(document.getElementById('fr_replacement').value == '') {
alert(_lc('Inform a replacement word'));
return false;
}
clearDoc();">
<span onClick="e = document.getElementById('fr_replaceall');
e.click(); e.focus();" style="cursor:default">
<span>Substitute all occurrences</span></span>
</FIELDSET></td>
<td width="22%" align="center" valign="bottom" style="text-align: right; padding: 4px">
<button type="button" id="fr_clear" onClick="clearMarks()">Clear</button>
<div class="space"></div>
<button type="button" id="fr_hiliteall" onClick="hiliteAll()">Highlight</button>
<div class="space"></div>
<button type="button" id="fr_undo" onClick="resetContents();">Undo</button>
</td>
</tr>
</table></td>
</tr>
</tbody>
</table>
<div style="border-top: 1px solid #999; padding: 2px; padding: 5px; text-align: right; height: 20px"><button type="button" id="fr_go" onclick="return onOK();">Next</button>
<button type="button" name="cancel" onclick="return onCancel();">Done</button>
</div>
</form>
</body>
</html>