Project

General

Profile

Feature #22314 ยป rtehtmlarea_feature_13889.patch

Administrator Admin, 2010-03-22 16:55

View differences:

typo3/sysext/rtehtmlarea/htmlarea/plugins/QuickTag/popups/quicktag.html (copie de travail)
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<!--
/***************************************************************
* Copyright notice
*
* (c) 2004 Cau guanabara <caugb@ibest.com.br>
* (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This script is a modified version of a script published under the htmlArea License.
* A copy of the htmlArea License may be found in the textfile HTMLAREA_LICENSE.txt.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/*
* Quick Tag Editor Plugin for TYPO3 htmlArea RTE
*
* TYPO3 SVN ID: $Id$
*/
-->
<head>
<title>Quick Tag Editor</title>
<meta http-equiv="Content-Style-Type" content="text/css" />
<script type="text/javascript" src="../tag-lib.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
<!--
var dialog = window.opener.HTMLArea.Dialog.QuickTag;
var curTag = "none";
var curTagOpt = false;
var CSSEdit = false;
function Init() {
dialog.initialize(false,true);
createDropdown("tags");
var to = document.getElementById('tagopen');
HTMLArea._addEvent(to, "keypress", function(ev) { if (typeof choice_dropdown != "undefined") choice_dropdown(HTMLArea.is_ie ? window.event : ev); });
document.getElementById('bt_colors').style.display = "none";
document.body.onkeypress = onKeyPress;
to.focus();
if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) {
setTimeout( function() { dialog.resize(); }, 200);
} else {
dialog.resize();
}
};
function onCancel() {
dialog.close();
return false;
};
function quoteTest(val) {
var er = /^\w+\s*([a-zA-Z_0-9:;]+=\"[^\"]*\"\s*|[a-zA-Z_0-9:;]+=\'[^\']*\'\s*)*$/;
return er.test(val);
};
function onOK() {
var el = document.getElementById('tagopen');
if(!el.value) {
alert(dialog.plugin.localize("Enter the TAG you want to insert"));
el.focus();
return false;
}
if(!quoteTest(el.value)) {
if(!quoteTest(el.value + '"')) {
alert(dialog.plugin.localize("There are some unclosed quote"));
el.focus();
el.select();
return false;
} else {
el.value += '"';
}
}
var param = {};
var cleanTO = document.getElementById('tagopen').value.replace(/(<|>)/g,"");
param.tagopen = "<"+cleanTO+">";
param.tagclose = param.tagopen.replace(/^<(\w+) ?.*>/,"</$1>");
var subtag = subTagLib[curTag];
if(typeof subtag == 'object') {
param.tagopen = param.tagopen+subtag.op;
param.tagclose = subtag.cl+param.tagclose;
}
dialog.performAction(param);
dialog.close();
return false;
};
function onKeyPress(ev) {
if(!ev) var ev = window.event;
switch(ev.keyCode) {
case 13:
document.getElementById('bt_ok').click();
break;
case 27:
dialog.close();
return false;
}
return true;
};
function selchange() {
var toadd = document.getElementById('selectag').value;
var oldval = document.getElementById('tagopen').value;
var text = (oldval+toadd).replace(/^\s*(.+)\s*$/,"$1");
var atrib = /(\w+)=\"$/.test(toadd) ? toadd.replace(/(\w+)=\"$/, "$1") : null;
var showcolors = (/color\: ?$/.test(toadd)) ? true : false;
var noCSSclasses = false;
var obj = null;
curTag = text.replace(/(^\w+) ?.*$/, "$1");
curTagOpt = (tagLib[curTag] == true);
if (atrib) {
var atrer = eval('/'+atrib+'=/ig');
if(atrer.test(oldval) && !(/[^=]\"$/.test(toadd))) {
alert(dialog.plugin.localize("This attribute already exists in the TAG"));
return false;
}
switch(atrib) {
case 'style':
CSSEdit = true;
break;
case 'class':
if(captureClasses() == 0) noCSSclasses = true;
break;
case 'color':
case 'bgcolor':
case 'bordercolor':
case 'bordercolorlight':
case 'bordercolordark':
showcolors = true;
break;
}
if(curTagOpt == true) {
obj = eval('opAtt_'+curTag.replace(/^h[1-6]$/,"h")+'["'+atrib+'"]');
} else {
obj = opAtt_all[atrib];
}
} else if (!CSSEdit && (/(^\w+$|\"$)/.test(toadd))) {
obj = 'all';
if (curTagOpt == true) obj = curTag;
toadd += ' ';
}
if (CSSEdit && quoteTest(text)) CSSEdit = false;
if (showcolors) document.getElementById('bt_colors').style.display = '';
if(obj) {
createDropdown(obj, curTag);
} else if(!CSSEdit) {
document.getElementById('showselect').style.visibility = 'hidden';
}
if(noCSSclasses) {
document.getElementById('showselect').innerHTML = dialog.plugin.localize("No CSS class avaiable");
document.getElementById('showselect').style.visibility = 'visible';
}
addchanges();
function addchanges() {
document.getElementById('tagopen').focus();
document.getElementById('tagopen').value += toadd;
};
};
function captureClasses() {
var cont = 0;
// If there is no '<HTML>' in the HTMLArea content, when using styleSheets[..].rule, IE generates an error.
// In this case, we lost the classes in external CSS files.
// If FullPage is loaded, there is no problem.
if(!(/<\s*html\s*>/i.test(dialog.plugin.editor.getHTML())) && document.all) {
var styles = dialog.plugin.editor._doc.getElementsByTagName("style");
for(var i in styles) {
var cont = styles[i].innerHTML;
if(typeof cont != 'undefined') {
var cls = cont.match(/\.\w+/ig,"");
for(var j in cls) if(/^\.\w+$/.test(cls[j])) {
var classname = cls[j].replace(/\./,"")+'"';
opAtt_all['class'][cls[j]] = classname;
cont++;
}
}
}
return cont;
}
var styleSheet = null;
var styles = dialog.plugin.editor._doc.styleSheets;
for (var i = 0; i < styles.length; i++) {
styleSheet = styles[i];
if(document.all) {
var _rules = styleSheet.rules;
} else {
var _rules = styleSheet.cssRules;
}
for (var j = 0; j < _rules.length; j++) {
var rule = _rules[j];
if(/^\.\w+$/.test(rule.selectorText)) {
var classname = rule.selectorText.replace(/\./,"")+'"';
opAtt_all['class'][rule.selectorText] = classname;
cont++;
}
}
}
return cont;
};
function choice_dropdown(e) {
if (document.all) var Key = e.keyCode;
else var Key = e.charCode;
if (Key != 32) return;
var text = document.getElementById('tagopen').value.replace(/^\s*([^\s]+)\s*$/,"$1");
if (CSSEdit && quoteTest(text)) CSSEdit = false;
if (CSSEdit) return;
if (curTag == 'none') {
curTag = text.replace(/(^\w+) ?.*$/, "$1");
curTagOpt = tagLib[curTag];
}
if(!/\w/.test(text)) {
document.getElementById('tagopen').value = '';
createDropdown("tags");
return;
}
var att = 'all';
if (curTagOpt == true) att = curTag;
createDropdown(att, curTag);
};
function createDropdown(type,tag) {
var _div = document.getElementById('showselect');
while(_div.hasChildNodes()) _div.removeChild(_div.firstChild);
_div.style.visibility = 'visible';
var _sel = document.createElement("select");
_sel.id = "selectag";
_sel.onchange = function() { selchange(); };
if (typeof(type) == 'object') {
var obj = type;
forObj(dialog.plugin.localize("OPTIONS"),'options');
_div.appendChild(_sel);
return;
}
if (type == 'tags') {
var obj = new Object();
if (dialog.plugin.denyTags) {
var denyTags = dialog.plugin.denyTags.split(",").join("|").replace(/ /g, "");
var expr = new RegExp("^("+denyTags+")$");
for (var i in allTags) {
if (!expr.test(i)) obj[i] = allTags[i];
}
} else {
obj = allTags;
}
forObj(dialog.plugin.localize("TAGs"),'tags');
_div.appendChild(_sel);
return;
}
var topt = eval('opTag_'+type.replace(/^h[1-6]$/,"h"));
if (typeof(topt) == 'object') {
var obj = new Object();
var allowedAttribs = "";
if (typeof(tag) == "string" && (dialog.plugin.allowedAttribs || (dialog.plugin.tags && dialog.plugin.tags[tag] && dialog.plugin.tags[tag]["allowedAttribs"]))) {
if (dialog.plugin.allowedAttribs) {
allowedAttribs = dialog.plugin.allowedAttribs.split(",").join("|").replace(/ /g, "");
}
if (dialog.plugin.tags && dialog.plugin.tags[tag] && dialog.plugin.tags[tag]["allowedAttribs"]) {
if (allowedAttribs) allowedAttribs = allowedAttribs + "|";
allowedAttribs += dialog.plugin.tags[tag]["allowedAttribs"].split(",").join("|").replace(/ /g, "");
}
var expr = new RegExp("^("+allowedAttribs+")$");
for (var i in topt) {
if (expr.test(i)) obj[i] = topt[i];
}
} else {
obj = topt;
}
} else {
return;
}
forObj(dialog.plugin.localize("ATTRIBUTES"),'attributes');
_div.appendChild(_sel);
function forObj(first,type) {
if (first) {
var opt = document.createElement("option");
opt.appendChild(document.createTextNode(first));
_sel.appendChild(opt);
}
for (var i in obj) {
var opt = document.createElement("option");
opt.appendChild(document.createTextNode(i));
opt.value = obj[i];
_sel.appendChild(opt);
}
};
};
// Called from the TYPO3 Color plugin
var SelectColorDialog = new Object();
SelectColorDialog.insertColor = function (val) {
insertColor(val);
};
// Called from the Default Color plugin
function insertColor(val) {
if(val && val != null) {
if(CSSEdit) {
val += "; ";
} else {
val += '" ';
}
document.getElementById('tagopen').value += val;
document.getElementById('bt_colors').style.display = "none";
document.getElementById('tagopen').focus();
var att = 'all';
if (curTagOpt == true) att = curTag;
createDropdown(att, curTag);
}
};
function colors() {
var colorPlugin = dialog.plugin.editor.plugins.TYPO3Color;
if (colorPlugin) {
colorPlugin = colorPlugin.instance;
colorPlugin.dialogSelectColor("tag", "", SelectColorDialog, window);
} else {
colorPlugin = dialog.plugin.editor.plugins.DefaultColor;
if (colorPlugin) {
colorPlugin.instance.onButtonPress(dialog.plugin.editor, "QuickTag");
}
}
};
// -->
/*]]>*/
</script>
</head>
<body class="popupwin htmlarea-quick-tag" onload="Init();">
<div class="title">Quick Tag Editor</div>
<form action="" method="get">
<div id="tag">
<strong>&lt;</strong>
<input id="tagopen" type="text" />
<strong>&gt;</strong>
</div>
<div class="space"></div>
<div id="showselect"></div>
<div class="buttons">
<button type="button" id="bt_colors" onclick="colors();">Colors</button>
<button type="button" id="bt_ok" onclick="return onOK();">Ok</button>
<button type="button" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>
typo3/sysext/rtehtmlarea/htmlarea/plugins/QuickTag/tag-lib.js (copie de travail)
/*
TAG Library for QuickTag Plugin
-------------------------------
allTags = All tags that appears in the first dropdown ('TAGS') {'caption': 'value'}
tagLib = The tags with options (just to check if current TAG have options) {'[TAG]': true}
subTagLib = Complements for some tags that needs it (TABLE)
{'[TAG]': {'op': 'after tag open', 'cl': 'before tag close'}}
opTag_all = Common attributes to all TAGS {'caption': 'value'}
opAtt_all = Options for the common attributes {'attribute': {'caption': 'value'}}
opTag_[TAG] = Attributes for [TAG] {'caption': 'value'}
opAtt_[TAG] = Options for the [TAG] attributes {'attribute': {'caption': 'value'}}
*/
var allTags = {
'a': 'a',
'abbr': 'abbr',
'acronym': 'acronym',
'address': 'address',
'b': 'b',
'big': 'big',
'blockquote': 'blockquote',
'cite': 'cite',
'code': 'code',
'div': 'div',
'em': 'em',
'fieldset': 'fieldset',
'font': 'font',
'h1': 'h1',
'h2': 'h2',
'h3': 'h3',
'h4': 'h4',
'h5': 'h5',
'h6': 'h6',
'i': 'i',
'legend': 'legend',
'li': 'li',
'ol': 'ol',
'ul': 'ul',
'p': 'p',
'pre': 'pre',
'q': 'q',
'small': 'small',
'span': 'span',
'strong': 'strong',
'sub': 'sub',
'sup': 'sup',
'table': 'table',
'tt': 'tt'
};
// tags with options
var tagLib = {
'a': true,
'div': true,
'font': true,
'h1': true,
'h2': true,
'h3': true,
'h4': true,
'h5': true,
'h6': true,
'p': true,
'table': true
};
// tags that needs some complement
var subTagLib = {'table': {'op': '<tbody><tr><td>',
'cl': '</td></tr></tbody>'}
};
var opTag_a = {
'href': 'href="',
'name': 'name="',
'target': 'target="'
};
var opAtt_a = {
'href': {'http://': 'http://',
'https://': 'https://',
'ftp://': 'ftp://',
'mailto:': 'mailto:',
'#': '#"'},
'target': {'_top': '_top"',
'_self': '_self"',
'_parent': '_parent"',
'_blank': '_blank"'}
};
var opTag_font = {
'face': 'face="',
'size': 'size="',
'color': 'color="'
};
var opAtt_font = {
'face': {'Verdana': 'Verdana"',
'Arial': 'Arial"',
'Tahoma': 'Tahoma"',
'Courier New': 'Courier New"',
'Times New Roman': 'Times New Roman"'},
'size': {'1': '1"','2': '2"','3': '3"','4': '4"','5': '5"','6': '6"',
'+1': '+1"','+2': '+2"','+3': '+3"','+4': '+4"','+5': '+5"','+6': '+6"',
'-1': '-1"','-2': '-2"','-3': '-3"','-4': '-4"','-5': '-5"','-6': '-6"'}
};
var opTag_div = {
'align': 'align="'
};
var opAtt_div = {
'align': {'center': 'center"',
'left': 'left"',
'right': 'right"',
'justify': 'justify"'}
};
var opTag_h = {
'align': 'align="'
};
var opAtt_h = {
'align': {'center': 'center"',
'left': 'left"',
'right': 'right"',
'justify': 'justify"'}
};
var opTag_p = {
'align': 'align="'
};
var opAtt_p = {
'align': {'center': 'center"',
'left': 'left"',
'right': 'right"',
'justify': 'justify"'}
};
var opTag_table = {
'align': 'align="',
'width': 'width="',
'height': 'height="',
'cellpadding': 'cellpadding="',
'cellspacing': 'cellspacing="',
'background': 'background="',
'bgcolor': 'bgcolor="',
'border': 'border="',
'bordercolor': 'bordercolor="',
'bordercolorlight': 'bordercolorlight="',
'bordercolordark': 'bordercolordark="'
};
var opAtt_table = {
'align': {'center': 'center"',
'left': 'left"',
'right': 'right"'}
};
// for all tags
var opTag_all = {
'class': 'class="',
'dir': 'dir="',
'id': 'id="',
'lang': 'lang="',
'onFocus': 'onFocus="',
'onBlur': 'onBlur="',
'onClick': 'onClick="',
'onDblClick': 'onDblClick="',
'onMouseDown': 'onMouseDown="',
'onMouseUp': 'onMouseUp="',
'onMouseOver': 'onMouseOver="',
'onMouseMove': 'onMouseMove="',
'onMouseOut': 'onMouseOut="',
'onKeyPress': 'onKeyPress="',
'onKeyDown': 'onKeyDown="',
'onKeyUp': 'onKeyUp="',
'style': 'style="',
'title': 'title="',
'xml:lang' : 'xml:lang="'
};
var opAtt_all = {
'class': {},
'dir': {'rtl': 'rtl"','ltr': 'ltr"'},
'lang': {'Afrikaans ': 'af"',
'Albanian ': 'sq"',
'Arabic ': 'ar"',
'Basque ': 'eu"',
'Breton ': 'br"',
'Bulgarian ': 'bg"',
'Belarusian ': 'be"',
'Catalan ': 'ca"',
'Chinese ': 'zh"',
'Croatian ': 'hr"',
'Czech ': 'cs"',
'Danish ': 'da"',
'Dutch ': 'nl"',
'English ': 'en"',
'Estonian ': 'et"',
'Faeroese ': 'fo"',
'Farsi ': 'fa"',
'Finnish ': 'fi"',
'French ': 'fr"',
'Gaelic ': 'gd"',
'German ': 'de"',
'Greek ': 'el"',
'Hebrew ': 'he"',
'Hindi ': 'hi"',
'Hungarian ': 'hu"',
'Icelandic ': 'is"',
'Indonesian ': 'id"',
'Italian ': 'it"',
'Japanese ': 'ja"',
'Korean ': 'ko"',
'Latvian ': 'lv"',
'Lithuanian ': 'lt"',
'Macedonian ': 'mk"',
'Malaysian ': 'ms"',
'Maltese ': 'mt"',
'Norwegian ': 'no"',
'Polish ': 'pl"',
'Portuguese ': 'pt"',
'Rhaeto-Romanic ': 'rm"',
'Romanian ': 'ro"',
'Russian ': 'ru"',
'Sami ': 'sz"',
'Serbian ': 'sr"',
'Setswana ': 'tn"',
'Slovak ': 'sk"',
'Slovenian ': 'sl"',
'Spanish ': 'es"',
'Sutu ': 'sx"',
'Swedish ': 'sv"',
'Thai ': 'th"',
'Tsonga ': 'ts"',
'Turkish ': 'tr"',
'Ukrainian ': 'uk"',
'Urdu ': 'ur"',
'Vietnamese ': 'vi"',
'Xhosa ': 'xh"',
'Yiddish ': 'yi"',
'Zulu': 'zu"'},
'style': {'azimuth': 'azimuth: ',
'background': 'background: ',
'background-attachment': 'background-attachment: ',
'background-color': 'background-color: ',
'background-image': 'background-image: ',
'background-position': 'background-position: ',
'background-repeat': 'background-repeat: ',
'border': 'border: ',
'border-bottom': 'border-bottom: ',
'border-left': 'border-left: ',
'border-right': 'border-right: ',
'border-top': 'border-top: ',
'border-bottom-color': 'border-bottom-color: ',
'border-left-color': 'border-left-color: ',
'border-right-color': 'border-right-color: ',
'border-top-color': 'border-top-color: ',
'border-bottom-style': 'border-bottom-style: ',
'border-left-style': 'border-left-style: ',
'border-right-style': 'border-right-style: ',
'border-top-style': 'border-top-style: ',
'border-bottom-width': 'border-bottom-width: ',
'border-left-width': 'border-left-width: ',
'border-right-width': 'border-right-width: ',
'border-top-width': 'border-top-width: ',
'border-collapse': 'border-collapse: ',
'border-color': 'border-color: ',
'border-style': 'border-style: ',
'border-width': 'border-width: ',
'bottom': 'bottom: ',
'caption-side': 'caption-side: ',
'cell-spacing': 'cell-spacing: ',
'clear': 'clear: ',
'clip': 'clip: ',
'color': 'color: ',
'column-span': 'column-span: ',
'content': 'content: ',
'cue': 'cue: ',
'cue-after': 'cue-after: ',
'cue-before': 'cue-before: ',
'cursor': 'cursor: ',
'direction': 'direction: ',
'display': 'display: ',
'elevation': 'elevation: ',
'filter': 'filter: ',
'float': 'float: ',
'font-family': 'font-family: ',
'font-size': 'font-size: ',
'font-size-adjust': 'font-size-adjust: ',
'font-style': 'font-style: ',
'font-variant': 'font-variant: ',
'font-weight': 'font-weight: ',
'height': 'height: ',
'!important': '!important: ',
'left': 'left: ',
'letter-spacing': 'letter-spacing: ',
'line-height': 'line-height: ',
'list-style': 'list-style: ',
'list-style-image': 'list-style-image: ',
'list-style-position': 'list-style-position: ',
'list-style-type': 'list-style-type: ',
'margin': 'margin: ',
'margin-bottom': 'margin-bottom: ',
'margin-left': 'margin-left: ',
'margin-right': 'margin-right: ',
'margin-top': 'margin-top: ',
'marks': 'marks: ',
'max-height': 'max-height: ',
'min-height': 'min-height: ',
'max-width': 'max-width: ',
'min-width': 'min-width: ',
'orphans': 'orphans: ',
'overflow': 'overflow: ',
'padding': 'padding: ',
'padding-bottom': 'padding-bottom: ',
'padding-left': 'padding-left: ',
'padding-right': 'padding-right: ',
'padding-top': 'padding-top: ',
'page-break-after': 'page-break-after: ',
'page-break-before': 'page-break-before: ',
'pause': 'pause: ',
'pause-after': 'pause-after: ',
'pause-before': 'pause-before: ',
'pitch': 'pitch: ',
'pitch-range': 'pitch-range: ',
'play-during': 'play-during: ',
'position': 'position: ',
'richness': 'richness: ',
'right': 'right: ',
'row-span': 'row-span: ',
'size': 'size: ',
'speak': 'speak: ',
'speak-date': 'speak-date: ',
'speak-header': 'speak-header: ',
'speak-numeral': 'speak-numeral: ',
'speak-punctuation': 'speak-punctuation: ',
'speak-time': 'speak-time: ',
'speech-rate': 'speech-rate: ',
'stress': 'stress: ',
'table-layout': 'table-layout: ',
'text-align': 'text-align: ',
'text-decoration': 'text-decoration: ',
'text-indent': 'text-indent: ',
'text-shadow': 'text-shadow: ',
'text-transform': 'text-transform: ',
'top': 'top: ',
'vertical-align': 'vertical-align: ',
'visibility': 'visibility: ',
'voice-family': 'voice-family: ',
'volume': 'volume: ',
'white-space': 'white-space: ',
'widows': 'widows: ',
'width': 'width: ',
'word-spacing': 'word-spacing: ',
'z-index': 'z-index: ' }
};
opAtt_all["xml:lang"] = opAtt_all["lang"];
// add the common items to all objects
for(var i in tagLib) {
i = i.replace(/^h[1-6]$/,"h"); // h1 .. h6
for(var j in opTag_all)
eval('opTag_'+i+'["'+j+'"] = opTag_all["'+j+'"];');
for(var j in opAtt_all)
eval('opAtt_'+i+'["'+j+'"] = opAtt_all["'+j+'"];');
}
    (1-1/1)