Bug #19378 ยป rtehtmlarea_feature_9429.patch
typo3/sysext/rtehtmlarea/ext_localconf.php (copie de travail) | ||
---|---|---|
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DefaultInline'] = array();
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DefaultInline']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/DefaultInline/class.tx_rtehtmlarea_defaultinline.php:&tx_rtehtmlarea_defaultinline';
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DefaultInline']['addIconsToSkin'] = 1;
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['InlineCSS'] = array();
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['InlineCSS']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/InlineCSS/class.tx_rtehtmlarea_inlinecss.php:&tx_rtehtmlarea_inlinecss';
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['BlockElements'] = array();
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['BlockElements']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/BlockElements/class.tx_rtehtmlarea_blockelements.php:&tx_rtehtmlarea_blockelements';
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['BlockElements']['addIconsToSkin'] = 0;
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DefinitionList'] = array();
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DefinitionList']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/DefinitionList/class.tx_rtehtmlarea_definitionlist.php:&tx_rtehtmlarea_definitionlist';
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DefinitionList']['addIconsToSkin'] = 0;
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DynamicCSS'] = array();
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['DynamicCSS']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/DynamicCSS/class.tx_rtehtmlarea_dynamiccss.php:&tx_rtehtmlarea_dynamiccss';
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['BlockStyle'] = array();
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['BlockStyle']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/BlockStyle/class.tx_rtehtmlarea_blockstyle.php:&tx_rtehtmlarea_blockstyle';
|
||
$TYPO3_CONF_VARS['EXTCONF']['rtehtmlarea']['plugins']['CharacterMap'] = array();
|
typo3/sysext/rtehtmlarea/extensions/DynamicCSS/class.tx_rtehtmlarea_dynamiccss.php (copie de travail) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2007 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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.
|
||
*
|
||
* 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 copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* DynamicCSS extension for htmlArea RTE
|
||
*
|
||
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
|
||
*
|
||
* TYPO3 SVN ID: $Id$
|
||
*
|
||
*/
|
||
require_once(t3lib_extMgm::extPath('rtehtmlarea').'class.tx_rtehtmlareaapi.php');
|
||
class tx_rtehtmlarea_dynamiccss extends tx_rtehtmlareaapi {
|
||
protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE
|
||
protected $pluginName = 'DynamicCSS'; // The name of the plugin registered by the extension
|
||
protected $relativePathToLocallangFile = 'extensions/DynamicCSS/locallang.xml'; // Path to this main locallang file of the extension relative to the extension dir.
|
||
protected $relativePathToSkin = ''; // Path to the skin (css) file relative to the extension dir.
|
||
protected $htmlAreaRTE; // Reference to the invoking object
|
||
protected $thisConfig; // Reference to RTE PageTSConfig
|
||
protected $toolbar; // Reference to RTE toolbar array
|
||
protected $LOCAL_LANG; // Frontend language array
|
||
|
||
protected $pluginButtons = 'blockstyle'; // The comma-seperated list of button names that the extension id adding to the htmlArea RTE tollbar
|
||
protected $pluginLabels = 'blockstylelabel'; // The comma-seperated list of label names that the extension id adding to the htmlArea RTE tollbar
|
||
// The name-converting array, converting the button names used in the RTE PageTSConfing to the button id's used by the JS scripts
|
||
protected $convertToolbarForHtmlAreaArray = array (
|
||
'blockstylelabel' => 'I[style]',
|
||
'blockstyle' => 'DynamicCSS-class',
|
||
);
|
||
protected $requiresClassesConfiguration = true; // True if the extension requires the PageTSConfig Classes configuration
|
||
} // end of class
|
||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/DynamicCSS/class.tx_rtehtmlarea_dynamiccss.php']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/DynamicCSS/class.tx_rtehtmlarea_dynamiccss.php']);
|
||
}
|
||
?>
|
typo3/sysext/rtehtmlarea/extensions/DynamicCSS/locallang.xml (copie de travail) | ||
---|---|---|
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||
<!-- TYPO3 SVN ID: $Id$ -->
|
||
<T3locallang>
|
||
<meta type="array">
|
||
<description>Labels for the DynamicCSS extension of htmlArea RTE</description>
|
||
<type>module</type>
|
||
</meta>
|
||
<data type="array">
|
||
<languageKey index="default" type="array">
|
||
</languageKey>
|
||
</data>
|
||
<orig_hash type="array">
|
||
<languageKey index="default" type="array">
|
||
</languageKey>
|
||
</orig_hash>
|
||
<orig_text type="array">
|
||
<languageKey index="default" type="array">
|
||
</languageKey>
|
||
</orig_text>
|
||
</T3locallang>
|
typo3/sysext/rtehtmlarea/extensions/InlineCSS/class.tx_rtehtmlarea_inlinecss.php (copie de travail) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2007 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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.
|
||
*
|
||
* 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 copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* InlineCSS extension of htmlArea RTE
|
||
*
|
||
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
|
||
*
|
||
* TYPO3 SVN ID: $Id$
|
||
*
|
||
*/
|
||
require_once(t3lib_extMgm::extPath('rtehtmlarea').'class.tx_rtehtmlareaapi.php');
|
||
class tx_rtehtmlarea_inlinecss extends tx_rtehtmlareaapi {
|
||
protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE
|
||
protected $pluginName = 'InlineCSS'; // The name of the plugin registered by the extension
|
||
protected $relativePathToLocallangFile = 'extensions/InlineCSS/locallang.xml'; // Path to this main locallang file of the extension relative to the extension dir.
|
||
protected $relativePathToSkin = ''; // Path to the skin (css) file relative to the extension dir.
|
||
protected $htmlAreaRTE; // Reference to the invoking object
|
||
protected $thisConfig; // Reference to RTE PageTSConfig
|
||
protected $toolbar; // Reference to RTE toolbar array
|
||
protected $LOCAL_LANG; // Frontend language array
|
||
|
||
protected $pluginButtons = 'textstyle'; // The comma-seperated list of button names that the extension id adding to the htmlArea RTE tollbar
|
||
protected $pluginLabels = 'textstylelabel'; // The comma-seperated list of label names that the extension id adding to the htmlArea RTE tollbar
|
||
// The name-converting array, converting the button names used in the RTE PageTSConfing to the button id's used by the JS scripts
|
||
protected $convertToolbarForHtmlAreaArray = array (
|
||
'textstylelabel' => 'I[text_style]',
|
||
'textstyle' => 'InlineCSS-class',
|
||
);
|
||
protected $requiresClassesConfiguration = true; // True if the extension requires the PageTSConfig Classes configuration
|
||
} // end of class
|
||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/InlineCSS/class.tx_rtehtmlarea_inlinecss.php']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/InlineCSS/class.tx_rtehtmlarea_inlinecss.php']);
|
||
}
|
||
?>
|
typo3/sysext/rtehtmlarea/extensions/InlineCSS/locallang.xml (copie de travail) | ||
---|---|---|
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||
<!-- TYPO3 SVN ID: $Id$ -->
|
||
<T3locallang>
|
||
<meta type="array">
|
||
<description>Labels for the Inline CSS plugin of htmlArea RTE</description>
|
||
<type>module</type>
|
||
</meta>
|
||
<data type="array">
|
||
<languageKey index="default" type="array">
|
||
</languageKey>
|
||
</data>
|
||
<orig_hash type="array">
|
||
<languageKey index="default" type="array">
|
||
</languageKey>
|
||
</orig_hash>
|
||
<orig_text type="array">
|
||
<languageKey index="default" type="array">
|
||
</languageKey>
|
||
</orig_text>
|
||
</T3locallang>
|
typo3/sysext/rtehtmlarea/htmlarea/plugins/DynamicCSS/dynamiccss.js (copie de travail) | ||
---|---|---|
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2004 systemconcept.de. Authored by Holger Hees, sponsored by http://www.systemconcept.de.
|
||
* (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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!
|
||
***************************************************************/
|
||
/*
|
||
* Dynamic CSS Plugin for TYPO3 htmlArea RTE
|
||
*
|
||
* TYPO3 SVN ID: $Id$
|
||
*/
|
||
DynamicCSS = HTMLArea.Plugin.extend({
|
||
constructor : function(editor, pluginName) {
|
||
this.base(editor, pluginName);
|
||
},
|
||
/*
|
||
* This function gets called by the class constructor
|
||
*/
|
||
configurePlugin : function(editor) {
|
||
var editorNumber = editor._editorNumber;
|
||
/* Registering plugin "About" information */
|
||
var pluginInformation = {
|
||
version : "1.9",
|
||
developer : "Holger Hees & Stanislas Rolland",
|
||
developerUrl : "http://www.fructifor.ca/",
|
||
copyrightOwner : "Holger Hees & Stanislas Rolland",
|
||
sponsor : "Fructifor Inc.",
|
||
sponsorUrl : "System Concept GmbH & Fructifor Inc.",
|
||
license : "GPL"
|
||
};
|
||
this.registerPluginInformation(pluginInformation);
|
||
/* Registering the dropdown list */
|
||
var buttonId = "DynamicCSS-class";
|
||
var dropDownConfiguration = {
|
||
id : buttonId,
|
||
tooltip : this.localize("DynamicCSSStyleTooltip"),
|
||
options : {"":""},
|
||
action : "onSelect",
|
||
refresh : "generate",
|
||
context : "*",
|
||
cssArray : new Object(),
|
||
parseCount : 1,
|
||
loaded : false,
|
||
timeout : null,
|
||
lastTag : "",
|
||
lastClass : "",
|
||
showTagFreeClasses : RTEarea[editorNumber]["showTagFreeClasses"],
|
||
classesUrl : RTEarea[editorNumber]["classesUrl"],
|
||
classesTag : RTEarea[editorNumber]["classesTag"]
|
||
};
|
||
this.registerDropDown(dropDownConfiguration);
|
||
return true;
|
||
},
|
||
onSelect : function(editor, buttonId) {
|
||
var obj = this.editorConfiguration.customSelects[buttonId];
|
||
var tbobj = editor._toolbarObjects[buttonId];
|
||
var index = document.getElementById(tbobj.elementId).selectedIndex;
|
||
var className = document.getElementById(tbobj.elementId).value;
|
||
editor.focusEditor();
|
||
var blocks = this.getSelectedBlocks(editor);
|
||
for (var k = 0; k < blocks.length; ++k) {
|
||
var parent = blocks[k];
|
||
while (typeof(parent) != "undefined" && !HTMLArea.isBlockElement(parent) && parent.nodeName.toLowerCase() != "img") parent = parent.parentNode;
|
||
if (!k) var tagName = parent.tagName.toLowerCase();
|
||
if (parent.tagName.toLowerCase() == tagName) {
|
||
var cls = parent.className.trim().split(" ");
|
||
for (var i = cls.length; i > 0;) if(!HTMLArea.reservedClassNames.test(cls[--i])) HTMLArea._removeClass(parent,cls[i]);
|
||
if(className != 'none'){
|
||
HTMLArea._addClass(parent,className);
|
||
obj.lastClass = className;
|
||
}
|
||
}
|
||
}
|
||
},
|
||
getSelectedBlocks : function(editor) {
|
||
var block, range, i = 0, blocks = [];
|
||
if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) {
|
||
var sel = editor._getSelection();
|
||
try {
|
||
while (range = sel.getRangeAt(i++)) {
|
||
block = editor.getParentElement(sel, range);
|
||
blocks.push(block);
|
||
}
|
||
} catch(e) {
|
||
/* finished walking through selection */
|
||
}
|
||
} else {
|
||
blocks.push(editor.getParentElement());
|
||
}
|
||
return blocks;
|
||
},
|
||
onGenerate : function() {
|
||
var editor = this.editor;
|
||
var obj = editor.config.customSelects["DynamicCSS-class"];
|
||
if(HTMLArea.is_gecko) this.generate(editor);
|
||
},
|
||
onUpdateToolbar : function() {
|
||
var editor = this.editor;
|
||
var obj = editor.config.customSelects["DynamicCSS-class"];
|
||
if (HTMLArea.is_gecko && editor.getMode() === "wysiwyg" && editor.isEditable()) {
|
||
if(obj.loaded) {
|
||
this.updateValue(editor,obj);
|
||
} else {
|
||
if(obj.timeout) {
|
||
if(editor._iframe.contentWindow) { editor._iframe.contentWindow.clearTimeout(obj.timeout); } else { window.clearTimeout(obj.timeout); }
|
||
obj.timeout = null;
|
||
}
|
||
this.generate(editor);
|
||
}
|
||
} else if (editor.getMode() === "textmode") {
|
||
var select = document.getElementById(editor._toolbarObjects[obj.id].elementId);
|
||
select.disabled = true;
|
||
select.className = "buttonDisabled";
|
||
}
|
||
},
|
||
generate : function(editor) {
|
||
var obj = editor.config.customSelects["DynamicCSS-class"];
|
||
var classesUrl = obj["classesUrl"];
|
||
if (classesUrl && typeof(HTMLArea.classesLabels) == "undefined") {
|
||
var classesData = HTMLArea._getScript(0, false, classesUrl);
|
||
if (classesData) eval(classesData);
|
||
}
|
||
// Let us load the style sheets
|
||
if(obj.loaded) this.updateValue(editor,obj);
|
||
else this.getCSSArray(editor);
|
||
},
|
||
getCSSArray : function(editor) {
|
||
var obj = editor.config.customSelects["DynamicCSS-class"];
|
||
obj.cssArray = this.parseStyleSheet(editor);
|
||
if( !obj.loaded && obj.parseCount<17 ) {
|
||
var getCSSArrayLaterFunctRef = DynamicCSS.getCSSArrayLater(editor, this);
|
||
obj.timeout = editor._iframe.contentWindow ? editor._iframe.contentWindow.setTimeout(getCSSArrayLaterFunctRef, 200) : window.setTimeout(getCSSArrayLaterFunctRef, 200);
|
||
obj.parseCount++ ;
|
||
} else {
|
||
obj.timeout = null;
|
||
obj.loaded = true;
|
||
this.updateValue(editor,obj);
|
||
}
|
||
},
|
||
onMode : function(mode) {
|
||
var editor = this.editor;
|
||
if (mode == 'wysiwyg' && editor.isEditable()) {
|
||
var obj = editor.config.customSelects["DynamicCSS-class"];
|
||
if (obj.loaded) {
|
||
this.updateValue(editor,obj);
|
||
} else {
|
||
if(obj.timeout) {
|
||
if (editor._iframe.contentWindow) editor._iframe.contentWindow.clearTimeout(obj.timeout);
|
||
else window.clearTimeout(obj.timeout);
|
||
obj.timeout = null;
|
||
}
|
||
this.generate(editor);
|
||
}
|
||
}
|
||
},
|
||
updateValue : function(editor,obj) {
|
||
var cssClass, i;
|
||
if(!obj.loaded) {
|
||
if(obj.timeout) {
|
||
if(editor._iframe.contentWindow) editor._iframe.contentWindow.clearTimeout(obj.timeout);
|
||
else window.clearTimeout(obj.timeout);
|
||
obj.timeout = null;
|
||
}
|
||
this.generate(editor);
|
||
}
|
||
var cssArray = obj.cssArray;
|
||
var tagName = "body";
|
||
var className = "";
|
||
var parent = editor.getParentElement();
|
||
while(parent && typeof(parent) != "undefined" && !HTMLArea.isBlockElement(parent) && parent.nodeName.toLowerCase() != "img") parent = parent.parentNode;
|
||
if(parent) {
|
||
tagName = parent.nodeName.toLowerCase();
|
||
className = parent.className;
|
||
if(HTMLArea.reservedClassNames.test(className)) {
|
||
var cls = className.split(" ");
|
||
for (var i = cls.length; i > 0;) if(!HTMLArea.reservedClassNames.test(cls[--i])) className = cls[i];
|
||
}
|
||
}
|
||
if(obj.lastTag != tagName || obj.lastClass != className){
|
||
obj.lastTag = tagName;
|
||
obj.lastClass = className;
|
||
var select = document.getElementById(editor._toolbarObjects[obj.id].elementId);
|
||
while(select.options.length>0) select.options[select.length-1] = null;
|
||
select.options[0]=new Option(this.localize("Default"),'none');
|
||
if(cssArray){
|
||
// style class only allowed if parent tag is not body or editor is in fullpage mode
|
||
if(tagName != 'body' || editor.config.fullPage){
|
||
if(cssArray[tagName]){
|
||
for (cssClass in cssArray[tagName]){
|
||
if (cssArray[tagName].hasOwnProperty(cssClass)) {
|
||
if (cssClass == 'none') {
|
||
select.options[0] = new Option(cssArray[tagName][cssClass],cssClass);
|
||
} else {
|
||
select.options[select.options.length] = new Option(cssArray[tagName][cssClass],cssClass);
|
||
if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (cssArray['all']){
|
||
for (cssClass in cssArray['all']){
|
||
if (cssArray['all'].hasOwnProperty(cssClass)) {
|
||
select.options[select.options.length] = new Option(cssArray['all'][cssClass],cssClass);
|
||
if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
if(cssArray[tagName] && cssArray[tagName]['none']) select.options[0] = new Option(cssArray[tagName]['none'],'none');
|
||
}
|
||
}
|
||
select.selectedIndex = 0;
|
||
if (typeof(className) != "undefined" && /\S/.test(className) && !HTMLArea.reservedClassNames.test(className) ) {
|
||
for (i = select.options.length; --i >= 0;) {
|
||
var option = select.options[i];
|
||
if (className == option.value) {
|
||
select.selectedIndex = i;
|
||
break;
|
||
}
|
||
}
|
||
if (select.selectedIndex == 0) {
|
||
select.options[select.options.length] = new Option(this.localize("Undefined"),className);
|
||
select.selectedIndex = select.options.length-1;
|
||
}
|
||
}
|
||
if (select.options.length > 1) {
|
||
select.disabled = false;
|
||
} else select.disabled = true;
|
||
if(HTMLArea.is_gecko) select.removeAttribute('class');
|
||
else select.removeAttribute('className');
|
||
if (select.disabled) HTMLArea._addClass(select, "buttonDisabled");
|
||
}
|
||
},
|
||
parseStyleSheet : function(editor) {
|
||
var obj = editor.config.customSelects["DynamicCSS-class"];
|
||
var iframe = editor._iframe.contentWindow ? editor._iframe.contentWindow.document : editor._iframe.contentDocument;
|
||
var newCssArray = new Object();
|
||
obj.loaded = true;
|
||
for (var i = 0; i < iframe.styleSheets.length; i++) {
|
||
// Mozilla
|
||
if(HTMLArea.is_gecko){
|
||
try { newCssArray = this.applyCSSRule(editor,iframe.styleSheets[i].cssRules,newCssArray); }
|
||
catch (e) { obj.loaded = false; }
|
||
} else {
|
||
try{
|
||
// @import StyleSheets (IE)
|
||
if (iframe.styleSheets[i].imports) newCssArray = this.applyCSSIEImport(editor,iframe.styleSheets[i].imports,newCssArray);
|
||
if (iframe.styleSheets[i].rules) newCssArray = this.applyCSSRule(editor,iframe.styleSheets[i].rules,newCssArray);
|
||
} catch (e) { obj.loaded = false; }
|
||
}
|
||
}
|
||
return newCssArray;
|
||
},
|
||
applyCSSRule : function(editor, cssRules, cssArray){
|
||
var cssElements = new Array(),
|
||
cssElement = new Array(),
|
||
newCssArray = new Object(),
|
||
classParts = new Array(),
|
||
tagName, className, rule, k,
|
||
obj = editor.config.customSelects["DynamicCSS-class"];
|
||
newCssArray = cssArray;
|
||
for (rule = 0; rule < cssRules.length; rule++) {
|
||
// StyleRule
|
||
if (cssRules[rule].selectorText) {
|
||
if (cssRules[rule].selectorText.search(/:+/) == -1) {
|
||
// split equal Styles e.g. head, body {border:0px}
|
||
cssElements = cssRules[rule].selectorText.split(",");
|
||
for (k = 0; k < cssElements.length; k++) {
|
||
cssElement = cssElements[k].split(".");
|
||
tagName = cssElement[0].toLowerCase().trim();
|
||
if (!tagName) tagName = "all";
|
||
className = cssElement[1];
|
||
if (className) {
|
||
classParts = className.trim().split(" ");
|
||
className = classParts[0];
|
||
}
|
||
if (!HTMLArea.reservedClassNames.test(className) && ((tagName == "all" && obj["showTagFreeClasses"] == true) || (tagName != "all" && (!obj["classesTag"] || !obj["classesTag"][tagName])) || (tagName != "all" && obj["classesTag"][tagName].indexOf(className) != -1)) ) {
|
||
if (!newCssArray[tagName]) newCssArray[tagName] = new Object();
|
||
if (className) {
|
||
cssName = className;
|
||
if (HTMLArea.classesLabels) cssName = HTMLArea.classesLabels[className] ? HTMLArea.classesLabels[className] : cssName ;
|
||
if (tagName != 'all') cssName = '<'+cssName+'>';
|
||
} else {
|
||
className='none';
|
||
if (tagName=='all') cssName=this.localize("Default");
|
||
else cssName='<'+this.localize("Default")+'>';
|
||
}
|
||
newCssArray[tagName][className]=cssName;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
// ImportRule (Mozilla)
|
||
if (cssRules[rule].styleSheet) {
|
||
newCssArray = this.applyCSSRule(editor, cssRules[rule].styleSheet.cssRules, newCssArray);
|
||
}
|
||
// MediaRule (Mozilla)
|
||
if (cssRules[rule].cssRules) {
|
||
newCssArray = this.applyCSSRule(editor, cssRules[rule].cssRules, newCssArray);
|
||
}
|
||
}
|
||
}
|
||
return newCssArray;
|
||
},
|
||
applyCSSIEImport : function(editor,cssIEImport,cssArray){
|
||
var newCssArray = new Object();
|
||
newCssArray = cssArray;
|
||
for (var i=0;i<cssIEImport.length;i++){
|
||
if(cssIEImport[i].imports){
|
||
newCssArray = this.applyCSSIEImport(editor,cssIEImport[i].imports,newCssArray);
|
||
}
|
||
if(cssIEImport[i].rules){
|
||
newCssArray = this.applyCSSRule(editor,cssIEImport[i].rules,newCssArray);
|
||
}
|
||
}
|
||
return newCssArray;
|
||
}
|
||
});
|
||
DynamicCSS.getCSSArrayLater = function(editor,instance) {
|
||
return (function() {
|
||
instance.getCSSArray(editor);
|
||
});
|
||
};
|
||
typo3/sysext/rtehtmlarea/htmlarea/plugins/InlineCSS/inlinecss.js (copie de travail) | ||
---|---|---|
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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 copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/*
|
||
* Inline CSS Plugin for TYPO3 htmlArea RTE
|
||
*
|
||
* TYPO3 SVN ID: $Id$
|
||
*/
|
||
InlineCSS = HTMLArea.Plugin.extend({
|
||
constructor : function(editor, pluginName) {
|
||
this.base(editor, pluginName);
|
||
},
|
||
/*
|
||
* This function gets called by the class constructor
|
||
*/
|
||
configurePlugin : function (editor) {
|
||
var editorNumber = editor._editorNumber;
|
||
/* Registering plugin "About" information */
|
||
var pluginInformation = {
|
||
version : "1.5",
|
||
developer : "Stanislas Rolland",
|
||
developerUrl : "http://www.fructifor.ca/",
|
||
copyrightOwner : "Stanislas Rolland",
|
||
sponsor : "Fructifor Inc.",
|
||
sponsorUrl : "http://www.fructifor.ca/",
|
||
license : "GPL"
|
||
};
|
||
this.registerPluginInformation(pluginInformation);
|
||
/* Registering the dropdown list */
|
||
var buttonId = "InlineCSS-class";
|
||
var dropDownConfiguration = {
|
||
id : buttonId,
|
||
tooltip : this.localize(buttonId + "-Tooltip"),
|
||
options : {"":""},
|
||
action : "onSelect",
|
||
refresh : "generate",
|
||
context : "*",
|
||
cssArray : new Object(),
|
||
parseCount : 1,
|
||
loaded : false,
|
||
timeout : null,
|
||
lastTag : "",
|
||
lastClass : "",
|
||
showTagFreeClasses : RTEarea[editorNumber]["showTagFreeClasses"],
|
||
classesUrl : RTEarea[editorNumber]["classesUrl"],
|
||
classesCharacter : RTEarea[editorNumber]["classesTag"]["span"]
|
||
};
|
||
this.registerDropDown(dropDownConfiguration);
|
||
return true;
|
||
},
|
||
onSelect : function(editor, buttonId) {
|
||
var obj = this.editorConfiguration.customSelects[buttonId];
|
||
var tbobj = editor._toolbarObjects[buttonId];
|
||
var index = document.getElementById(tbobj.elementId).selectedIndex;
|
||
var className = document.getElementById(tbobj.elementId).value;
|
||
var selTrimmed;
|
||
editor.focusEditor();
|
||
var selectedHTML = editor.getSelectedHTMLContents();
|
||
if (selectedHTML) {
|
||
selTrimmed = selectedHTML.replace(/(<[^>]*>| |\n|\r)/g,"");
|
||
}
|
||
var parent = editor.getParentElement();
|
||
if( (HTMLArea.is_gecko && /\w/.test(selTrimmed) == true) || (HTMLArea.is_ie && /\S/.test(selTrimmed) == true) ) {
|
||
var sel = editor._getSelection();
|
||
var range = editor._createRange(sel);
|
||
if( className != 'none' ) {
|
||
obj.lastClass = className;
|
||
if(parent && !HTMLArea.isBlockElement(parent) && selectedHTML.replace(/^\s*|\s*$/g,"") == parent.innerHTML.replace(/^\s*|\s*$/g,"") ) {
|
||
parent.className = className;
|
||
} else {
|
||
if(HTMLArea.is_gecko) {
|
||
var rangeClone = range.cloneRange();
|
||
var span = editor._doc.createElement("span");
|
||
span.className = className;
|
||
span.appendChild(range.extractContents());
|
||
range.insertNode(span);
|
||
if(HTMLArea.is_safari) {
|
||
sel.empty();
|
||
sel.setBaseAndExtent(rangeClone.startContainer,rangeClone.startOffset,rangeClone.endContainer,rangeClone.endOffset);
|
||
} else {
|
||
sel.removeRange(range);
|
||
sel.addRange(rangeClone);
|
||
}
|
||
range.detach();
|
||
} else {
|
||
var tagopen = '<span class="' + className + '">';
|
||
var tagclose = "</span>";
|
||
editor.surroundHTML(tagopen,tagclose);
|
||
}
|
||
}
|
||
} else {
|
||
if (parent && !HTMLArea.isBlockElement(parent)) {
|
||
if (HTMLArea.is_gecko) {
|
||
parent.removeAttribute('class');
|
||
} else {
|
||
parent.removeAttribute('className');
|
||
}
|
||
if (parent.tagName.toLowerCase() == "span") {
|
||
p = parent.parentNode;
|
||
while (parent.firstChild) {
|
||
p.insertBefore(parent.firstChild, parent);
|
||
}
|
||
p.removeChild(parent);
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
alert(HTMLArea.I18N.InlineCSS['You have to select some text']);
|
||
}
|
||
},
|
||
onGenerate : function() {
|
||
var editor = this.editor;
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
if (HTMLArea.is_gecko) {
|
||
this.generate(editor);
|
||
}
|
||
},
|
||
onUpdateToolbar : function() {
|
||
var editor = this.editor;
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
if (HTMLArea.is_gecko && editor.getMode() === "wysiwyg" && editor.isEditable()) {
|
||
if (obj.loaded) {
|
||
this.updateValue(editor,obj);
|
||
} else {
|
||
if (obj.timeout) {
|
||
if (editor._iframe.contentWindow) {
|
||
editor._iframe.contentWindow.clearTimeout(obj.timeout);
|
||
} else {
|
||
window.clearTimeout(obj.timeout);
|
||
}
|
||
obj.timeout = null;
|
||
}
|
||
this.generate(editor);
|
||
}
|
||
}
|
||
},
|
||
generate : function(editor) {
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
var classesUrl = obj["classesUrl"];
|
||
if (classesUrl && typeof(HTMLArea.classesLabels) === "undefined") {
|
||
this.getJavascriptFile(classesUrl);
|
||
}
|
||
// Let us load the style sheets
|
||
if (obj.loaded) {
|
||
this.updateValue(editor,obj);
|
||
} else {
|
||
this.getCSSArray(editor);
|
||
}
|
||
},
|
||
getCSSArray : function(editor) {
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
obj.cssArray = InlineCSS.parseStyleSheet(editor);
|
||
if ( !obj.loaded && obj.parseCount<17 ) {
|
||
var getCSSArrayLaterFunctRef = InlineCSS.getCSSArrayLater(editor, this);
|
||
obj.timeout = editor._iframe.contentWindow ? editor._iframe.contentWindow.setTimeout(getCSSArrayLaterFunctRef, 200) : window.setTimeout(getCSSArrayLaterFunctRef, 200);
|
||
obj.parseCount++ ;
|
||
} else {
|
||
obj.timeout = null;
|
||
obj.loaded = true;
|
||
this.updateValue(editor, obj);
|
||
}
|
||
},
|
||
onMode : function(mode) {
|
||
var editor = this.editor;
|
||
if (mode === "wysiwyg" && editor.isEditable()) {
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
if (obj.loaded) {
|
||
this.updateValue(editor,obj);
|
||
} else {
|
||
if (obj.timeout) {
|
||
if (editor._iframe.contentWindow) {
|
||
editor._iframe.contentWindow.clearTimeout(obj.timeout);
|
||
} else {
|
||
window.clearTimeout(obj.timeout);
|
||
}
|
||
obj.timeout = null;
|
||
}
|
||
this.generate(editor);
|
||
}
|
||
}
|
||
},
|
||
updateValue : function(editor,obj) {
|
||
var cssClass, i;
|
||
if (!obj.loaded) {
|
||
if (obj.timeout) {
|
||
if (editor._iframe.contentWindow) {
|
||
editor._iframe.contentWindow.clearTimeout(obj.timeout);
|
||
} else {
|
||
window.clearTimeout(obj.timeout);
|
||
}
|
||
obj.timeout = null;
|
||
}
|
||
this.generate(editor);
|
||
}
|
||
var cssArray = obj.cssArray;
|
||
var tagName = "body";
|
||
var className = "";
|
||
var parent = editor.getParentElement();
|
||
if (parent) {
|
||
tagName = parent.nodeName.toLowerCase();
|
||
className = parent.className;
|
||
}
|
||
var selTrimmed = editor.getSelectedHTMLContents();
|
||
if(selTrimmed) {
|
||
selTrimmed = selTrimmed.replace(/(<[^>]*>| |\n|\r)/g,"");
|
||
}
|
||
var endPointsInSameBlock = false;
|
||
if ( (HTMLArea.is_gecko && /\w/.test(selTrimmed) == true) || (HTMLArea.is_ie && /\S/.test(selTrimmed) == true) ) {
|
||
var sel = editor._getSelection();
|
||
var range = editor._createRange(sel);
|
||
if (HTMLArea.is_gecko) {
|
||
if (sel.rangeCount == 1 || HTMLArea.is_safari) {
|
||
var parentStart = range.startContainer;
|
||
var parentEnd = range.endContainer;
|
||
if ( !(parentStart.nodeType == 1 && parentStart.tagName.toLowerCase() == "tr") ) {
|
||
while (parentStart && !HTMLArea.isBlockElement(parentStart)) {
|
||
parentStart = parentStart.parentNode;
|
||
}
|
||
while (parentEnd && !HTMLArea.isBlockElement(parentEnd)) {
|
||
parentEnd = parentEnd.parentNode;
|
||
}
|
||
endPointsInSameBlock = (parentStart == parentEnd) && (parent.tagName.toLowerCase() != "body") && (parent.tagName.toLowerCase() != "table") && (parent.tagName.toLowerCase() != "tbody") && (parent.tagName.toLowerCase() != "tr");
|
||
}
|
||
}
|
||
} else {
|
||
if (sel.type != "Control" ) {
|
||
var rangeStart = range.duplicate();
|
||
rangeStart.collapse(true);
|
||
var rangeEnd = range.duplicate();
|
||
rangeEnd.collapse(false);
|
||
var parentStart = rangeStart.parentElement();
|
||
var parentEnd = rangeEnd.parentElement();
|
||
while (parentStart && !HTMLArea.isBlockElement(parentStart)) {
|
||
parentStart = parentStart.parentNode;
|
||
}
|
||
while (parentEnd && !HTMLArea.isBlockElement(parentEnd)) {
|
||
parentEnd = parentEnd.parentNode;
|
||
}
|
||
endPointsInSameBlock = (parentStart == parentEnd) && (parent.tagName.toLowerCase() != "body") ;
|
||
}
|
||
}
|
||
}
|
||
var select = document.getElementById(editor._toolbarObjects[obj.id].elementId);
|
||
select.disabled = !(/\w/.test(selTrimmed)) || !(endPointsInSameBlock);
|
||
obj.lastTag = tagName;
|
||
obj.lastClass = className;
|
||
while(select.options.length>0) {
|
||
select.options[select.length-1] = null;
|
||
}
|
||
select.options[0]=new Option(HTMLArea.I18N.InlineCSS["Default"],'none');
|
||
if (cssArray){
|
||
// we are in span and 'all' tags only
|
||
if (cssArray['span']) {
|
||
for (cssClass in cssArray['span']) {
|
||
if (cssClass == 'none') {
|
||
select.options[0] = new Option(cssArray['span'][cssClass],cssClass);
|
||
} else {
|
||
select.options[select.options.length] = new Option(cssArray['span'][cssClass],cssClass);
|
||
if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) {
|
||
select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (cssArray['all']){
|
||
for (cssClass in cssArray['all']) {
|
||
select.options[select.options.length] = new Option(cssArray['all'][cssClass],cssClass);
|
||
if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) {
|
||
select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
select.selectedIndex = 0;
|
||
//var selected = false;
|
||
//select.multiple = true;
|
||
//select.size = 2;
|
||
if (typeof className != "undefined" && /\S/.test(className) && !HTMLArea.reservedClassNames.test(className)) {
|
||
for (i = select.options.length; --i >= 0;) {
|
||
var option = select.options[i];
|
||
if (className == option.value) {
|
||
option.selected = true;
|
||
//selected = true;
|
||
select.selectedIndex = i;
|
||
break;
|
||
}
|
||
}
|
||
if (select.selectedIndex == 0) {
|
||
//if(!selected){
|
||
select.options[select.options.length] = new Option(HTMLArea.I18N.InlineCSS["Undefined"],className);
|
||
select.selectedIndex = select.options.length-1;
|
||
//select.options[select.options.length-1].selected = true;
|
||
}
|
||
}
|
||
select.disabled = !(select.options.length>1) || !endPointsInSameBlock || !((HTMLArea.is_gecko && /\w/.test(selTrimmed) == true) || (HTMLArea.is_ie && /\S/.test(selTrimmed) == true)) ;
|
||
select.className = "";
|
||
if (select.disabled) {
|
||
select.className = "buttonDisabled";
|
||
}
|
||
}
|
||
});
|
||
InlineCSS.parseStyleSheet = function(editor) {
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
var iframe = editor._iframe.contentWindow ? editor._iframe.contentWindow.document : editor._iframe.contentDocument;
|
||
var newCssArray = new Object();
|
||
obj.loaded = true;
|
||
for(var i=0;i<iframe.styleSheets.length;i++){
|
||
// Mozilla
|
||
if(HTMLArea.is_gecko){
|
||
try{ newCssArray = InlineCSS.applyCSSRule(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].cssRules,newCssArray); }
|
||
catch(e){ obj.loaded = false; }
|
||
} else {
|
||
try{
|
||
// @import StyleSheets (IE)
|
||
if(iframe.styleSheets[i].imports){
|
||
newCssArray = InlineCSS.applyCSSIEImport(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].imports,newCssArray);
|
||
}
|
||
if(iframe.styleSheets[i].rules){
|
||
newCssArray = InlineCSS.applyCSSRule(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].rules,newCssArray);
|
||
}
|
||
} catch(e) { obj.loaded = false; }
|
||
}
|
||
}
|
||
return newCssArray;
|
||
};
|
||
InlineCSS.applyCSSRule = function(editor,i18n,cssRules,cssArray){
|
||
var cssElements = new Array();
|
||
var cssElement = new Array();
|
||
var newCssArray = new Object();
|
||
var tagName, className, rule, k;
|
||
var obj = editor.config.customSelects["InlineCSS-class"];
|
||
newCssArray = cssArray;
|
||
for(rule=0;rule<cssRules.length;rule++){
|
||
// StyleRule
|
||
if(cssRules[rule].selectorText){
|
||
if(cssRules[rule].selectorText.search(/:+/)==-1){
|
||
// split equal Styles (Mozilla-specific) e.q. head, body {border:0px}
|
||
// for ie not relevant. returns allways one element
|
||
cssElements = cssRules[rule].selectorText.split(",");
|
||
for(k=0;k<cssElements.length;k++){
|
||
cssElement = cssElements[k].split(".");
|
||
tagName = cssElement[0].toLowerCase().trim();
|
||
if(!tagName) tagName = 'all';
|
||
className = cssElement[1];
|
||
if( (!obj["classesCharacter"] && (tagName == 'span')) || ((tagName != "all" || obj["showTagFreeClasses"] == true) && obj["classesCharacter"] && obj["classesCharacter"].indexOf(className) != -1)) {
|
||
if(!newCssArray[tagName]) newCssArray[tagName] = new Object();
|
||
if(className){
|
||
cssName = className;
|
||
if (HTMLArea.classesLabels) cssName = HTMLArea.classesLabels[className] ? HTMLArea.classesLabels[className] : cssName ;
|
||
if (tagName != 'all') cssName = '<'+cssName+'>';
|
||
} else {
|
||
className = 'none';
|
||
if(tagName == 'all') cssName = i18n["Default"];
|
||
else cssName = '<'+i18n["Default"]+'>';
|
||
}
|
||
newCssArray[tagName][className] = cssName;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
// ImportRule (Mozilla)
|
||
if (cssRules[rule].styleSheet) {
|
||
newCssArray = InlineCSS.applyCSSRule(editor, i18n, cssRules[rule].styleSheet.cssRules, newCssArray);
|
||
}
|
||
// MediaRule (Mozilla)
|
||
if (cssRules[rule].cssRules) {
|
||
newCssArray = InlineCSS.applyCSSRule(editor, i18n, cssRules[rule].cssRules, newCssArray);
|
||
}
|
||
}
|
||
}
|
||
return newCssArray;
|
||
};
|
||
InlineCSS.applyCSSIEImport=function(editor,i18n,cssIEImport,cssArray){
|
||
var newCssArray = new Object();
|
||
newCssArray = cssArray;
|
||
for(var i=0;i<cssIEImport.length;i++){
|
||
if(cssIEImport[i].imports){
|
||
newCssArray = InlineCSS.applyCSSIEImport(editor,i18n,cssIEImport[i].imports,newCssArray);
|
||
}
|
||
if(cssIEImport[i].rules){
|
||
newCssArray = InlineCSS.applyCSSRule(editor,i18n,cssIEImport[i].rules,newCssArray);
|
||
}
|
||
}
|
||
return newCssArray;
|
||
};
|
||
InlineCSS.getCSSArrayLater = function(editor,instance) {
|
||
return (function() {
|
||
instance.getCSSArray(editor);
|
||
});
|
||
};
|
||
typo3/sysext/rtehtmlarea/htmlarea/plugins/SelectColor/select-color.js (copie de travail) | ||
---|---|---|
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2004, 2005, 2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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 copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/*
|
||
* Color Select Plugin for TYPO3 htmlArea RTE
|
||
*
|
||
* TYPO3 SVN ID: $Id$
|
||
*/
|
||
SelectColor = function(editor) {
|
||
this.editor = editor;
|
||
var cfg = editor.config;
|
||
var bl = SelectColor.btnList;
|
||
// register the toolbar buttons provided by this plugin
|
||
for (var i = 0; i < bl.length; ++i) {
|
||
var btn = bl[i];
|
||
var id = "CO-" + btn[0];
|
||
this.editor.eventHandlers[id] = SelectColor.actionHandler(this);
|
||
cfg.registerButton(
|
||
id,
|
||
SelectColor_langArray[id],
|
||
editor.imgURL(id + ".gif", "SelectColor"),
|
||
false,
|
||
this.editor.eventHandlers[id],
|
||
btn[1]
|
||
);
|
||
}
|
||
};
|
||
SelectColor.I18N = SelectColor_langArray;
|
||
SelectColor._pluginInfo = {
|
||
name : "SelectColor",
|
||
version : "1.6",
|
||
developer : "Stanislas Rolland",
|
||
developer_url : "http://www.fructifor.ca/",
|
||
c_owner : "Stanislas Rolland",
|
||
sponsor : "Fructifor Inc.",
|
||
sponsor_url : "http://www.fructifor.ca/",
|
||
license : "GPL"
|
||
};
|
||
SelectColor.actionHandler = function(instance) {
|
||
return (function(editor,id) {
|
||
instance.buttonPress(editor, id);
|
||
});
|
||
};
|
||
// the list of buttons added by this plugin
|
||
SelectColor.btnList = [
|
||
["forecolor", null],
|
||
["hilitecolor", null]
|
||
];
|
||
// This function gets called when some button from the SelectColor was pressed
|
||
SelectColor.prototype.buttonPress = function(editor,button_id) {
|
||
this.editor = editor;
|
||
switch (button_id) {
|
||
case "CO-forecolor":
|
||
this.dialogSelectColor(button_id,"","");
|
||
break;
|
||
case "CO-hilitecolor":
|
||
this.dialogSelectColor(button_id,"","");
|
||
break;
|
||
default:
|
||
alert("Button [" + button_id + "] not yet implemented");
|
||
}
|
||
};
|
||
// this function requires the file PopupWin
|
||
SelectColor.prototype.dialogSelectColor = function(button_id,element,field,opener) {
|
||
var editor = this.editor;
|
||
var windowWidth = 470;
|
||
var windowHeight = 245;
|
||
// button_id's "color" and "tag" are not registered but used to interface with the Table Operations and QuickTag plugins
|
||
switch (button_id) {
|
||
case "CO-forecolor":
|
||
case "CO-hilitecolor":
|
||
var selectColorInitFunctRef = SelectColor.selectColorCOInit(this, button_id);
|
||
var setColorFunctRef = SelectColor.setColorCO(this);
|
||
var dialog = new PopupWin(this.editor, SelectColor.I18N[button_id + "_title"], setColorFunctRef, selectColorInitFunctRef, windowWidth, windowHeight, editor._iframe.contentWindow);
|
||
break;
|
||
case "color":
|
||
var selectColorInitFunctRef = SelectColor.selectColorColorInit(this, button_id, field);
|
||
var setColorFunctRef = SelectColor.setColorColor(this, element, field);
|
||
var dialog = new PopupWin(this.editor, SelectColor.I18N[button_id + "_title"], setColorFunctRef, selectColorInitFunctRef, windowWidth, windowHeight, opener);
|
||
break;
|
||
case "tag":
|
||
var selectColorInitFunctRef = SelectColor.selectColorTagInit(this, button_id);
|
||
var setColorFunctRef = SelectColor.setColorTag(this, field);
|
||
var dialog = new PopupWin(this.editor, SelectColor.I18N["color_title"], setColorFunctRef, selectColorInitFunctRef, windowWidth, windowHeight, opener);
|
||
}
|
||
};
|
||
/*
|
||
* Initialize the CO-forecolor and the CO-hilitecolor select color dialogs
|
||
*/
|
||
SelectColor.selectColorCOInit = function(instance,button_id) {
|
||
return (function(dialog) {
|
||
var editor = dialog.editor;
|
||
var doc = editor._doc;
|
||
dialog.content.innerHTML = instance.renderPopupSelectColor(button_id, dialog, SelectColor.I18N[button_id + "_title"]);
|
||
var colorTable = dialog.doc.getElementById("colorTable");
|
||
colorTable.onclick = function(e) {
|
||
if(!e) var e = dialog.dialogWindow.event;
|
||
var targ = e.target ? e.target : e.srcElement;
|
||
if (targ.nodeType == 3) targ = targ.parentNode;
|
||
dialog.doc.getElementById(button_id).value = targ.bgColor ? targ.bgColor : "";
|
||
dialog.callHandler();
|
||
return false;
|
||
};
|
||
var colorUnset = dialog.doc.getElementById("colorUnset");
|
||
colorUnset.onclick = function(e) {
|
||
dialog.doc.getElementById(button_id).value="";
|
||
dialog.callHandler();
|
||
return false;
|
||
};
|
||
try {
|
||
with (dialog.doc.getElementById(button_id+"Current").style) {
|
||
switch (button_id) {
|
||
case "CO-forecolor":
|
||
backgroundColor = HTMLArea._makeColor(doc.queryCommandValue("ForeColor"));
|
||
break;
|
||
case "CO-hilitecolor":
|
||
backgroundColor = HTMLArea._makeColor(doc.queryCommandValue(((HTMLArea.is_ie || HTMLArea.is_safari) ? "BackColor" : "HiliteColor")));
|
||
if (/transparent/i.test(backgroundColor)) {
|
||
// Mozilla
|
||
backgroundColor = HTMLArea._makeColor(doc.queryCommandValue("BackColor"));
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
} catch (e) { }
|
||
dialog.showAtElement();
|
||
});
|
||
};
|
||
/*
|
||
* Set the color and close the CO-forecolor and the CO-hilitecolor select color dialogs
|
||
*/
|
||
SelectColor.setColorCO = function(instance) {
|
||
return (function(dialog,params) {
|
||
var editor = dialog.editor;
|
||
instance.processStyle(dialog, params, "", "");
|
||
dialog.releaseEvents();
|
||
editor.focusEditor();
|
||
editor.updateToolbar();
|
||
dialog.close();
|
||
});
|
||
};
|
||
/*
|
||
* Initialize the case=color select color dialog
|
||
* This case is used by the Table Operations plugin
|
||
*/
|
||
SelectColor.selectColorColorInit = function(instance,button_id,field) {
|
||
return (function(dialog) {
|
||
dialog.content.innerHTML = instance.renderPopupSelectColor(button_id, dialog, SelectColor.I18N[button_id + "_title"]);
|
||
var colorTable = dialog.doc.getElementById("colorTable");
|
||
colorTable.onclick = function(e) {
|
||
if(!e) var e = dialog.dialogWindow.event;
|
||
var targ = e.target ? e.target : e.srcElement;
|
||
if (targ.nodeType == 3) targ = targ.parentNode;
|
||
dialog.doc.getElementById(button_id).value = targ.bgColor;
|
||
dialog.callHandler();
|
||
return false;
|
||
};
|
||
var colorUnset = dialog.doc.getElementById("colorUnset");
|
||
colorUnset.onclick = function(e) {
|
||
dialog.doc.getElementById(button_id).value = "";
|
||
dialog.callHandler();
|
||
return false;
|
||
};
|
||
dialog.doc.getElementById(button_id+"Current").style.backgroundColor = field.value;
|
||
dialog.showAtElement();
|
||
});
|
||
};
|
||
/*
|
||
* Set the color and close the case=color select color dialog
|
||
*/
|
||
SelectColor.setColorColor = function(instance,element,field) {
|
||
return (function(dialog,params) {
|
||
instance.processStyle(dialog, params, element, field);
|
||
dialog.releaseEvents();
|
||
dialog.close();
|
||
});
|
||
};
|
||
/*
|
||
* Initialize the case=tag select color dialog
|
||
* This is used by the QuickTag plugin
|
||
*/
|
||
SelectColor.selectColorTagInit = function(instance, button_id) {
|
||
return (function(dialog) {
|
||
instance.dialog = dialog;
|
||
dialog.content.innerHTML = instance.renderPopupSelectColor(button_id, dialog, SelectColor.I18N["color_title"]);
|
||
var colorTable = dialog.doc.getElementById("colorTable");
|
||
colorTable.onclick = function(e) {
|
||
if(!e) var e = dialog.dialogWindow.event;
|
||
var targ = e.target ? e.target : e.srcElement;
|
||
if (targ.nodeType == 3) targ = targ.parentNode;
|
||
dialog.doc.getElementById(button_id).value = targ.bgColor;
|
||
dialog.callHandler();
|
||
return false;
|
||
};
|
||
var colorUnset = dialog.doc.getElementById("colorUnset");
|
||
colorUnset.onclick = function(e) {
|
||
dialog.doc.getElementById(button_id).value = "";
|
||
dialog.callHandler();
|
||
return false;
|
||
};
|
||
dialog.doc.getElementById(button_id+"Current").style.backgroundColor = "";
|
||
dialog.showAtElement();
|
||
});
|
||
};
|
||
/*
|
||
* Set the color and close the case=color select color dialog
|
||
*/
|
||
SelectColor.setColorTag = function(instance,field) {
|
||
return (function(dialog,params) {
|
||
dialog.releaseEvents();
|
||
field._return(params["tag"]);
|
||
dialog.close();
|
||
field.dialog = null;
|
||
});
|
||
};
|
||
// Applies the style found in "params" to the given element.
|
||
SelectColor.prototype.processStyle = function(dialog, params, element, field) {
|
||
var editor = this.editor;
|
||
for (var i in params) {
|
||
var val = params[i];
|
||
switch (i) {
|
||
case "CO-forecolor":
|
||
if(val) {
|
||
editor._doc.execCommand("ForeColor", false, val);
|
||
} else {
|
||
var parentElement = editor.getParentElement();
|
||
parentElement.style.color = "";
|
||
}
|
||
break;
|
||
case "CO-hilitecolor":
|
||
if(val) {
|
||
if(HTMLArea.is_ie || HTMLArea.is_safari) editor._doc.execCommand("BackColor", false, val);
|
||
else editor._doc.execCommand("HiliteColor", false, val);
|
||
} else {
|
||
var parentElement = editor.getParentElement();
|
||
parentElement.style.backgroundColor = "";
|
||
}
|
||
break;
|
||
case "color":
|
||
element.style.backgroundColor = val;
|
||
field.value = val;
|
||
break;
|
||
}
|
||
}
|
||
};
|
||
/**
|
||
* Making color selector table
|
||
*/
|
||
SelectColor.prototype.renderPopupSelectColor = function(sID,dialog,title) {
|
||
var editor = this.editor;
|
||
var cfg = editor.config;
|
||
var cfgColors = cfg.colors;
|
||
var colorDef;
|
||
var szID = sID + "Current";
|
||
var sz;
|
||
var cPick = new Array("00","33","66","99","CC","FF");
|
||
var iColors = cPick.length;
|
||
var szColor = "";
|
||
var szColorId = "";
|
||
sz = '<div class="title">' + title + '</div>';
|
||
sz += '<table style="width:100%"><tr><td id="HA-layout"><fieldset>';
|
||
sz += '<input type="hidden" name="' + sID + '" id="' + sID + '" value="" />';
|
||
sz += '<table style="width:100%;"><tr><td style="vertical-align: middle;"><span style="margin-left: 5px; height: 1em;" class="dialog buttonColor" ';
|
||
sz += ' onMouseover="className += \' buttonColor-hilite\';" ';
|
||
sz += ' onMouseout="className = \'buttonColor\';"> ';
|
||
sz += ' <span id="' + szID + '" class="chooser"></span> ';
|
||
sz += ' <span id="colorUnset" class="nocolor" title="' + SelectColor.I18N["no_color"] + '" ';
|
||
sz += ' onMouseover="className += \' nocolor-hilite\';" ';
|
||
sz += ' onMouseout="className = \'nocolor\';"';
|
||
sz += ' >×</span></span></td><td>';
|
||
sz += '<table ';
|
||
sz += ' onMouseout="document.getElementById(\'' + szID + '\').style.backgroundColor=\'\';" ';
|
||
sz += ' onMouseover="if(' + HTMLArea.is_ie + '){ if(event.srcElement.bgColor) document.getElementById(\'' + szID + '\').style.backgroundColor=event.srcElement.bgColor; } else { if (event.target.bgColor) document.getElementById(\'' + szID + '\').style.backgroundColor=event.target.bgColor; }" ';
|
||
sz += ' class="colorTable" cellspacing="0" cellpadding="0" id="colorTable">';
|
||
// Making colorPicker
|
||
if (!cfg.disableColorPicker) {
|
||
for ( var r = 0; r < iColors; r++) {
|
||
sz+='<tr>';
|
||
for (var g = iColors-1; g >= 0; g--) {
|
||
for (var b=iColors-1;b>=0;b--) {
|
||
szColor = cPick[r]+cPick[g]+cPick[b];
|
||
sz+='<td bgcolor="#'+szColor+'" title="#'+szColor+'"> </td>';
|
||
}
|
||
}
|
||
sz+='</tr>';
|
||
}
|
||
}
|
||
// Making specific color selector:
|
||
if (cfgColors) {
|
||
var iCfgColors = cfgColors.length;
|
||
if (iCfgColors && !cfg.disableColorPicker) {
|
||
sz += '<tr><td colspan="36"></td></tr>';
|
||
}
|
||
for ( var theColor = 0; theColor < iCfgColors; theColor++) {
|
||
colorDef = cfgColors[theColor];
|
||
szColor = colorDef[1];
|
||
sz += '<tr>';
|
||
sz += '<td style="width:36px;" colspan="6" bgcolor="'+szColor+'" title="'+szColor+'"> </td>';
|
||
sz += '<td colspan=2></td>';
|
||
sz += '<td colspan=28><nobr>'+colorDef[0]+'</nobr></td>';
|
||
sz += '</tr>';
|
||
}
|
||
}
|
||
sz += '</table></td></tr></table>';
|
||
sz += '</fieldset></td></tr><tr><td id="HA-style"></td></tr></table>';
|
||
return sz;
|
||
};
|
typo3/sysext/rtehtmlarea/htmlarea/plugins/TableOperations/popups/insert_table.html (copie de travail) | ||
---|---|---|
<html class="popupwin">
|
||
<!--
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2002-2004, interactivetools.com, inc.
|
||
* (c) 2003-2004 dynarch.com
|
||
* (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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!
|
||
***************************************************************/
|
||
/*
|
||
* Insert Table window for TYPO3 htmlArea RTE
|
||
*
|
||
* TYPO3 SVN ID: $Id$
|
||
*/
|
||
-->
|
||
<head>
|
||
<title>Insert Table</title>
|
||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||
<script type="text/javascript">
|
||
/*<![CDATA[*/
|
||
<!--
|
||
var dialog = window.opener.HTMLArea.Dialog.TableOperations;
|
||
var plugin;
|
||
|
||
function Init() {
|
||
dialog.initialize("noLocalize", "noResize");
|
||
plugin = dialog.plugin;
|
||
var content = document.getElementById("content");
|
||
buildTitle(content, "Insert Table");
|
||
var form = document.createElement("form");
|
||
form.action = "";
|
||
form.method = "get";
|
||
buildDimensionFieldset(form);
|
||
if (!plugin.editorConfiguration.disableBordersFieldsetInTableOperations) buildBordersFieldset(form);
|
||
if (!plugin.editorConfiguration.disableSpacingFieldsetInTableOperations) buildSpacingFieldset(form);
|
||
addButtons(form, ["ok","cancel"], ["OK","Cancel"]);
|
||
content.appendChild(form);
|
||
dialog.localize();
|
||
dialog.resize();
|
||
document.getElementById("f_rows").focus();
|
||
};
|
||
function onOK() {
|
||
var required = { "f_rows": "", "f_cols": "" };
|
||
required["f_rows"] = plugin.localize("You must enter a number of rows");
|
||
required["f_cols"] = plugin.localize("You must enter a number of columns");
|
||
for (var i in required) {
|
||
var el = document.getElementById(i);
|
||
if (!el.value) {
|
||
alert(required[i]);
|
||
el.focus();
|
||
return false;
|
||
}
|
||
}
|
||
var fields = ["f_rows", "f_cols", "f_width", "f_unit", "f_border", "f_spacing", "f_padding", "f_float"];
|
||
var param = new Object();
|
||
for (var i in fields) {
|
||
var id = fields[i];
|
||
var el = document.getElementById(id);
|
||
if(el) param[id] = el.value;
|
||
}
|
||
dialog.performAction(param);
|
||
dialog.close();
|
||
return false;
|
||
};
|
||
function onCancel() {
|
||
dialog.close();
|
||
return false;
|
||
};
|
||
function buildTitle(content,title) {
|
||
var div = document.createElement("div");
|
||
div.className = "title";
|
||
div.innerHTML = dialog.plugin.localize(title);
|
||
content.appendChild(div);
|
||
};
|
||
function buildDimensionFieldset(content) {
|
||
var fieldset = document.createElement("fieldset");
|
||
insertLegend(fieldset, "Dimension");
|
||
buildInput(fieldset, "f_rows", ["Rows:"], ["Number of rows"], "5", "2");
|
||
buildInput(fieldset, "f_cols", ["Cols:"], ["Number of columns"], "5", "4");
|
||
if (!plugin.editorConfiguration.disableLayoutFieldsetInTableOperations) {
|
||
buildInput(fieldset, "f_width", ["Width:"], ["Width of the table"], "5", "100");
|
||
buildUnitField(fieldset);
|
||
}
|
||
content.appendChild(fieldset);
|
||
};
|
||
function buildBordersFieldset(content) {
|
||
var fieldset = document.createElement("fieldset");
|
||
fieldset.className = "floating";
|
||
insertLegend(fieldset, "Border");
|
||
var ul = document.createElement("ul");
|
||
fieldset.appendChild(ul);
|
||
var li = document.createElement("li");
|
||
ul.appendChild(li);
|
||
buildInput(li, "f_border", ["Border thickness:"], ["Leave empty for no border"], "5", "1", "fl", "");
|
||
content.appendChild(fieldset);
|
||
};
|