Project

General

Profile

Feature #19851 » rtehtmlarea_feature_10181.patch

Administrator Admin, 2009-01-19 07:48

View differences:

typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php (copie de travail)
*
* (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
* (c) 2004 Philipp Borgmann <philipp.borgmann@gmx.de>
* (c) 2004-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
* (c) 2004-2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......
RTEarea[editornumber]["useCSS"] = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . ';
RTEarea[editornumber]["keepButtonGroupTogether"] = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . ';
RTEarea[editornumber]["disablePCexamples"] = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . ';
RTEarea[editornumber]["statusBar"] = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
RTEarea[editornumber]["showTagFreeClasses"] = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
RTEarea[editornumber]["useHTTPS"] = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
RTEarea[editornumber]["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';
typo3/sysext/rtehtmlarea/ext_localconf.php (copie de travail)
// Initialize plugin registration array
$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins'] = array();
// Status Bar configuration
$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['StatusBar'] = array();
$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['StatusBar']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/StatusBar/class.tx_rtehtmlarea_statusbar.php:&tx_rtehtmlarea_statusbar';
// Inline Elements configuration
$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['DefaultInline'] = array();
$TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['plugins']['DefaultInline']['objectReference'] = 'EXT:'.$_EXTKEY.'/extensions/DefaultInline/class.tx_rtehtmlarea_defaultinline.php:&tx_rtehtmlarea_defaultinline';
typo3/sysext/rtehtmlarea/extensions/StatusBar/class.tx_rtehtmlarea_statusbar.php (r?vision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009 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.
*
* 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!
***************************************************************/
/**
* EditorMode plugin for htmlArea RTE
*
* @author Stanislas Rolland <typo3(arobas)sjbr.ca>
*
* TYPO3 SVN ID: $Id: class.tx_rtehtmlarea_editormode.php $
*
*/
require_once(t3lib_extMgm::extPath('rtehtmlarea').'class.tx_rtehtmlareaapi.php');
class tx_rtehtmlarea_statusbar extends tx_rtehtmlareaapi {
protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE
protected $pluginName = 'EditorMode'; // The name of the plugin registered by the extension
protected $relativePathToLocallangFile = ''; // Path to this main locallang file of the extension relative to the extension dir.
protected $relativePathToSkin = 'extensions/EditorMode/skin/htmlarea.css'; // 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
public function main($parentObject) {
return parent::main($parentObject) && trim($this->thisConfig['showStatusBar']);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/HTMLEditor/class.tx_rtehtmlarea_statusbar.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/HTMLEditor/class.tx_rtehtmlarea_statusbar.php']);
}
?>
typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js (copie de travail)
};
/*
* Handle statusbar element events
*/
HTMLArea.statusBarHandler = function (ev) {
if(!ev) var ev = window.event;
var target = (ev.target) ? ev.target : ev.srcElement;
var editor = target.editor;
target.blur();
editor.selectNodeContents(target.el);
editor._statusBarTree.selected = target.el;
editor.updateToolbar(true);
switch (ev.type) {
case "click" :
case "mousedown" :
HTMLArea._stopEvent(ev);
return false;
case "contextmenu" :
return editor.plugins["ContextMenu"] ? editor.plugins["ContextMenu"].instance.popupMenu(ev,target.el) : false;
}
};
/*
* Paste exception handler
*/
HTMLArea.prototype._mozillaPasteException = function(cmdID, UI, param) {
typo3/sysext/rtehtmlarea/htmlarea/htmlarea-ie.js (copie de travail)
***************************************************/
/*
* Handle statusbar element events
*/
HTMLArea.statusBarHandler = function (ev) {
if(!ev) var ev = window.event;
var target = (ev.target) ? ev.target : ev.srcElement;
var editor = target.editor;
target.blur();
var tagname = target.el.tagName.toLowerCase();
if(tagname == "table" || tagname == "img") {
var range = editor._doc.body.createControlRange();
range.addElement(target.el);
range.select();
} else {
editor.selectNode(target.el);
}
editor._statusBarTree.selected = target.el;
editor.updateToolbar(true);
switch (ev.type) {
case "click" :
HTMLArea._stopEvent(ev);
return false;
case "contextmenu" :
return editor.plugins["ContextMenu"] ? editor.plugins["ContextMenu"].instance.popupMenu(ev,target.el) : false;
}
};
/*
* Handle the backspace event in IE browsers
*/
HTMLArea.prototype._checkBackspace = function() {
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js (copie de travail)
HTMLArea.Config = function () {
this.width = "auto";
this.height = "auto";
// enable creation of a status bar?
this.statusBar = true;
// whether the toolbar should be included in the size or not.
this.sizeIncludesToolbar = true;
// if true then HTMLArea will retrieve the full HTML, starting with the <HTML> tag.
......
};
/*
* Create the status bar
*/
HTMLArea.prototype._createStatusBar = function() {
var statusBar = document.createElement("div");
this._statusBar = statusBar;
statusBar.className = "statusBar";
if (!this.config.statusBar) statusBar.style.display = "none";
var statusBarTree = document.createElement("span");
this._statusBarTree = statusBarTree;
statusBarTree.className = "statusBarTree";
statusBar.appendChild(statusBarTree);
statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"] + ": "));
this._htmlArea.appendChild(statusBar);
};
/*
* Create the htmlArea iframe and replace the textarea with it.
*/
HTMLArea.prototype.generate = function () {
......
iframe.setAttribute("src", (HTMLArea.is_opera?_typo3_host_url:"") + _editor_url + "popups/blank.html");
}
iframe.className = "editorIframe";
if (!this.config.statusBar) iframe.className += " noStatusBar";
if (!this.getPluginInstance("StatusBar")) {
iframe.className += " noStatusBar";
}
htmlarea.appendChild(iframe);
this._iframe = iframe;
// create & append the status bar
this._createStatusBar();
// size the iframe
this.sizeIframe(2);
HTMLArea._appendToLog("[HTMLArea::generate]: Editor iframe successfully created.");
this.initIframe();
return this;
......
HTMLArea.prototype.sizeIframe = function(diff) {
var height = (this.config.height == "auto" ? (this._textArea.style.height) : this.config.height);
var textareaHeight = height;
// All nested tabs and inline levels in the sorting order they were applied:
this.nested = {};
this.nested.all = RTEarea[this._editorNumber].tceformsNested;
this.nested.sorted = HTMLArea.simplifyNested(this.nested.all);
// Clone the array instead of using a reference (this.accessParentElements will change the array):
// Clone the array of nested tabs and inline levels instead of using a reference (this.accessParentElements will change the array):
var parentElements = (this.nested.sorted && this.nested.sorted.length ? [].concat(this.nested.sorted) : []);
// Walk through all nested tabs and inline levels to make a correct positioning:
var dimensions = this.accessParentElements(parentElements, 'this.getDimensions()');
......
HTMLArea.prototype.getDimensions = function() {
return {
toolbar: {width: this._toolbar.offsetWidth, height: this._toolbar.offsetHeight},
statusbar: {width: this._statusBar.offsetWidth, height: this._statusBar.offsetHeight}
statusbar: {width: (this.getPluginInstance("StatusBar") ? this.getPluginInstance("StatusBar").statusBar.offsetWidth : 0), height: (this.getPluginInstance("StatusBar") ? this.getPluginInstance("StatusBar").statusBar.offsetHeight : 0)}
};
};
......
editor.onGenerate = null;
}
HTMLArea._appendToLog("[HTMLArea::initIframe]: All plugins successfully generated.");
// size the iframe
editor.sizeIframe(2);
editor.focusEditor();
editor.updateToolbar();
};
......
editor._toolbarObjects[txt] = null;
}
}
// cleaning the statusbar elements
if (editor._statusBarTree.hasChildNodes()) {
for (var i = editor._statusBarTree.firstChild; i; i = i.nextSibling) {
if (i.nodeName.toLowerCase() == "a") {
HTMLArea._removeEvents(i, ["click", "contextmenu"], HTMLArea.statusBarHandler);
i.el = null;
i.editor = null;
}
}
}
// final cleanup
editor._toolbar = null;
editor._statusBar = null;
editor._statusBarTree = null;
editor._htmlArea = null;
editor._iframe = null;
};
......
this._textArea.value = this.getHTML();
this._iframe.style.display = "none";
this._textArea.style.display = "block";
if(this.config.statusBar) {
var statusBarTextMode = document.createElement("span");
statusBarTextMode.className = "statusBarTextMode";
statusBarTextMode.appendChild(document.createTextNode(HTMLArea.I18N.msg["TEXT_MODE"]));
this._statusBar.innerHTML = '';
this._statusBar.appendChild(statusBarTextMode);
}
this._editMode = "textmode";
break;
case "wysiwyg":
......
this._textArea.style.display = "none";
this._iframe.style.display = "block";
if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) this._doc.designMode = "on";
if(this.config.statusBar) {
this._statusBar.innerHTML = "";
this._statusBar.appendChild(this._statusBarTree);
}
this._editMode = "wysiwyg";
//set gecko options (if we can... raises exception in Firefox 3)
if (HTMLArea.is_gecko) {
......
};
/*
* Get the instance of the specified plugin, if it exists
*
* @param string pluginName: the name of the plugin
* @return object the plugin instance or null
*/
HTMLArea.prototype.getPluginInstance = function(pluginName) {
return (this.plugins[pluginName] ? this.plugins[pluginName].instance : null);
};
/*
* Load the required plugin script
*/
HTMLArea.loadPlugin = function (pluginName, url, asynchronous) {
......
HTMLArea.prototype.updateToolbar = function(noStatus) {
var doc = this._doc,
text = (this._editMode == "textmode"),
text = (this.getMode() == "textmode"),
selection = false,
ancestors = null, cls = new Array(),
txt, txtClass, i, inContext, match, matchAny, k, j, n, commandState;
if(!text) {
ancestors = null,
inContext, match, matchAny, k, j, n, commandState;
if (!text) {
selection = !this._selectionEmpty(this._getSelection());
ancestors = this.getAllAncestors();
if(this.config.statusBar && !noStatus) {
// Unhook previous events handlers
if(this._statusBarTree.hasChildNodes()) {
for (i = this._statusBarTree.firstChild; i; i = i.nextSibling) {
if(i.nodeName.toLowerCase() == "a") {
HTMLArea._removeEvents(i,["click", "contextmenu, mousedown"], HTMLArea.statusBarHandler);
i.el = null;
i.editor = null;
}
}
}
this._statusBarTree.selected = null;
this._statusBarTree.innerHTML = '';
this._statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"] + ": ")); // clear
for (i = ancestors.length; --i >= 0;) {
var el = ancestors[i];
if(!el) continue;
var a = document.createElement("a");
a.href = "#";
a.el = el;
a.editor = this;
if (!HTMLArea.is_opera) {
HTMLArea._addEvents(a, ["click", "contextmenu"], HTMLArea.statusBarHandler);
} else {
HTMLArea._addEvents(a, ["mousedown", "click"], HTMLArea.statusBarHandler);
}
txt = el.tagName.toLowerCase();
a.title = el.style.cssText;
if (el.id) { txt += "#" + el.id; }
if (el.className) {
txtClass = "";
cls = el.className.trim().split(" ");
for (j = 0; j < cls.length; ++j) {
if (!HTMLArea.reservedClassNames.test(cls[j])) {
txtClass += "." + cls[j];
}
}
txt += txtClass;
}
a.appendChild(document.createTextNode(txt));
this._statusBarTree.appendChild(a);
if (i != 0) this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb)));
}
}
}
for (var cmd in this._toolbarObjects) {
if (this._toolbarObjects.hasOwnProperty(cmd)) {
var btn = this._toolbarObjects[cmd];
// Determine if the button should be enabled
inContext = true;
if (btn.context && !text) {
......
};
/*
* Get the block ancestors of an element within a given block
*/
HTMLArea.prototype.getBlockAncestors = function(element, withinBlock) {
var ancestors = new Array();
var ancestor = element;
while (ancestor && (ancestor.nodeType === 1) && !/^(body)$/i.test(ancestor.nodeName) && ancestor != withinBlock) {
if (HTMLArea.isBlockElement(ancestor)) {
ancestors.unshift(ancestor);
}
ancestor = ancestor.parentNode;
}
ancestors.unshift(ancestor);
return ancestors;
};
/*
* Get the block elements containing the start and the end points of the selection
*/
HTMLArea.prototype.getEndBlocks = function(selection) {
......
editor.config.sizeIncludesToolbar = true;
editor.config.fullPage = false;
// All nested tabs and inline levels in the sorting order they were applied
editor.nested = {};
editor.nested.all = RTEarea[editorNumber].tceformsNested;
editor.nested.sorted = HTMLArea.simplifyNested(editor.nested.all);
// Register the plugins included in the configuration
for (var plugin in editor.config.plugin) {
if (editor.config.plugin.hasOwnProperty(plugin) && editor.config.plugin[plugin]) {
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockElements/block-elements.js (copie de travail)
this.editor.focusEditor();
var selection = editor._getSelection();
var range = editor._createRange(selection);
var parentElement = this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : this.editor.getParentElement(selection, range);
var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
var parentElement = statusBarSelection ? statusBarSelection : this.editor.getParentElement(selection, range);
if (target) {
parentElement = target;
}
......
if (this.editor.getMode() === "textmode" || !this.editor.isEditable()) {
return false;
}
var parentElement = this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : this.editor.getParentElement();
var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
var parentElement = statusBarSelection ? statusBarSelection : this.editor.getParentElement();
if (parentElement.nodeName.toLowerCase() === "body") return false;
while (parentElement && !HTMLArea.isBlockElement(parentElement) || /^li$/i.test(parentElement.nodeName)) {
parentElement = parentElement.parentNode;
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js (copie de travail)
*/
getSelectedBlocks : function() {
var block, range, i = 0, blocks = [];
var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
if (HTMLArea.is_gecko && !HTMLArea.is_safari && !HTMLArea.is_opera) {
var selection = this.editor._getSelection();
try {
while ((range = selection.getRangeAt(i++))) {
block = this.editor.getParentElement(selection, range);
blocks.push(this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : block);
blocks.push(statusBarSelection ? statusBarSelection : block);
}
} catch(e) {
/* finished walking through selection */
}
} else {
blocks.push(this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : this.editor.getParentElement());
blocks.push(statusBarSelection ? statusBarSelection : this.editor.getParentElement());
}
return blocks;
},
......
var classNames = new Array();
var tagName = null;
var parent = this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : this.editor.getParentElement();
var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
var parent = statusBarSelection ? statusBarSelection : this.editor.getParentElement();
while (parent && !HTMLArea.isBlockElement(parent) && parent.nodeName.toLowerCase() != "img") {
parent = parent.parentNode;
}
typo3/sysext/rtehtmlarea/htmlarea/plugins/ContextMenu/context-menu.js (copie de travail)
ContextMenu.mouseOverHandler = function(editor,item) {
return (function() {
item.className += " hover";
editor._statusBarTree.innerHTML = item.__msh.tooltip || '&nbsp;';
if (editor.getPluginInstance("StatusBar")) {
editor.getPluginInstance("StatusBar").setText(item.__msh.tooltip || "&nbsp;");
}
});
};
typo3/sysext/rtehtmlarea/htmlarea/plugins/DefinitionList/definition-list.js (copie de travail)
this.editor.focusEditor();
var selection = editor._getSelection();
var range = editor._createRange(selection);
var parentElement = this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : this.editor.getParentElement(selection, range);
var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
var parentElement = statusBarSelection ? statusBarSelection : this.editor.getParentElement(selection, range);
if (target) {
parentElement = target;
}
......
if (this.editor.getMode() === "textmode" || !this.editor.isEditable()) {
return false;
}
var parentElement = this.editor._statusBarTree.selected ? this.editor._statusBarTree.selected : this.editor.getParentElement();
var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
var parentElement = statusBarSelection ? statusBarSelection : this.editor.getParentElement();
if (parentElement.nodeName.toLowerCase() === "body") return false;
while (parentElement && (!HTMLArea.isBlockElement(parentElement) || /^(li)$/i.test(parentElement.nodeName))) {
parentElement = parentElement.parentNode;
typo3/sysext/rtehtmlarea/htmlarea/plugins/InlineElements/inline-elements.js (copie de travail)
}
}
if (!selectionEmpty) {
var statusBarSelection = (editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null);
// The selection is not empty.
for (var i = 0; i < ancestors.length; ++i) {
fullNodeSelected = (HTMLArea.is_ie && ((selection.type !== "Control" && ancestors[i].innerText === range.text) || (selection.type === "Control" && ancestors[i].innerText === range.item(0).text)))
|| (HTMLArea.is_gecko && ((editor._statusBarTree.selected === ancestors[i] && ancestors[i].textContent === range.toString()) || (!editor._statusBarTree.selected && ancestors[i].textContent === range.toString())));
|| (HTMLArea.is_gecko && ((statusBarSelection === ancestors[i] && ancestors[i].textContent === range.toString()) || (!statusBarSelection && ancestors[i].textContent === range.toString())));
if (fullNodeSelected) {
if (!HTMLArea.isBlockElement(ancestors[i])) {
parent = ancestors[i];
......
}
}
// Working around bug in Safari selectNodeContents
if (!fullNodeSelected && HTMLArea.is_safari && this.editor._statusBarTree.selected && this.isInlineElement(this.editor._statusBarTree.selected) && this.editor._statusBarTree.selected.textContent === range.toString()) {
if (!fullNodeSelected && HTMLArea.is_safari && statusBarSelection && this.isInlineElement(statusBarSelection) && statusBarSelection.textContent === range.toString()) {
fullNodeSelected = true;
parent = this.editor._statusBarTree.selected;
parent = statusBarSelection;
}
var fullNodeTextSelected = (HTMLArea.is_gecko && parent.textContent === range.toString())
......
newElement.setAttribute("dir", "rtl");
}
if (HTMLArea.is_gecko) {
if (fullNodeSelected && editor._statusBarTree.selected) {
if (fullNodeSelected && statusBarSelection) {
if (HTMLArea.is_safari) {
editor.selectNode(parent);
selection = editor._getSelection();
......
}
}
editor.wrapWithInlineElement(newElement, selection, range);
if (fullNodeSelected && editor._statusBarTree.selected && !HTMLArea.is_safari) {
if (fullNodeSelected && statusBarSelection && !HTMLArea.is_safari) {
editor.selectNodeContents(newElement.lastChild, false);
}
range.detach();
......
var tagopen = "<" + element + ">";
var tagclose = "</" + element + ">";
if (fullNodeSelected) {
if (!editor._statusBarTree.selected) {
if (!statusBarSelection) {
parent.innerHTML = tagopen + parent.innerHTML + tagclose;
if (element === "bdo") {
parent.firstChild.setAttribute("dir", "rtl");
......
}
var selectionEmpty = editor._selectionEmpty(sel);
if (!selectionEmpty) {
var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
var ancestors = editor.getAllAncestors();
for (var i = 0; i < ancestors.length; ++i) {
fullNodeSelected = (editor._statusBarTree.selected === ancestors[i])
fullNodeSelected = (statusBarSelection === ancestors[i])
&& ((HTMLArea.is_gecko && ancestors[i].textContent === range.toString()) || (HTMLArea.is_ie && ((sel.type !== "Control" && ancestors[i].innerText === range.text) || (sel.type === "Control" && ancestors[i].innerText === range.item(0).text))));
if (fullNodeSelected) {
if (!HTMLArea.isBlockElement(ancestors[i])) {
......
}
}
// Working around bug in Safari selectNodeContents
if (!fullNodeSelected && HTMLArea.is_safari && this.editor._statusBarTree.selected && this.isInlineElement(this.editor._statusBarTree.selected) && this.editor._statusBarTree.selected.textContent === range.toString()) {
if (!fullNodeSelected && HTMLArea.is_safari && statusBarSelection && this.isInlineElement(statusBarSelection) && statusBarSelection.textContent === range.toString()) {
fullNodeSelected = true;
tagName = this.editor._statusBarTree.selected.nodeName.toLowerCase();
tagName = statusBarSelection.nodeName.toLowerCase();
}
}
var selectionInInlineElement = tagName && this.REInlineElements.test(tagName);
typo3/sysext/rtehtmlarea/htmlarea/plugins/SelectFont/select-font.js (copie de travail)
editor.focusEditor();
var selection = editor._getSelection(),
range = editor._createRange(selection),
statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
element;
if (editor._selectionEmpty(selection)) {
element = editor.getParentElement(selection, range);
......
if ((element.nodeName.toLowerCase() === "span") && !HTMLArea.hasAllowedAttributes(element, this.allowedAttributes)) {
editor.removeMarkup(element);
}
} else if (editor._statusBarTree.selected) {
element = editor._statusBarTree.selected;
} else if (statusBarSelection) {
element = statusBarSelection;
// Set the style attribute
this.setStyle(element, buttonId, param);
// Remove the span tag if it has no more attribute
......
onUpdateToolbar : function () {
var editor = this.editor;
if (editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
var parentElement = editor._statusBarTree.selected ? editor._statusBarTree.selected : editor.getParentElement(),
var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
var parentElement = statusBarSelection ? statusBarSelection : editor.getParentElement(),
enabled = editor.endPointsInSameBlock() && !(editor._selectionEmpty(editor._getSelection()) && parentElement.nodeName.toLowerCase() == "body"),
buttonId, value, k;
for (var i = this.dropDownList.length; --i >= 0;) {
typo3/sysext/rtehtmlarea/htmlarea/plugins/StatusBar/locallang.xml (r?vision 0)
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<description>Labels for StatusBar 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/StatusBar/status-bar.js (r?vision 0)
/***************************************************************
* Copyright notice
*
* (c) 2009 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 copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/*
* StatusBar Plugin for TYPO3 htmlArea RTE
*
* TYPO3 SVN ID: $Id: editor-mode.js $
*/
StatusBar = HTMLArea.Plugin.extend({
constructor : function(editor, pluginName) {
this.base(editor, pluginName);
},
/*
* This function gets called by the class constructor
*/
configurePlugin : function (editor) {
/*
* Registering plugin "About" information
*/
var pluginInformation = {
version : "0.1",
developer : "Stanislas Rolland",
developerUrl : "http://www.sjbr.ca/",
copyrightOwner : "Stanislas Rolland",
sponsor : "SJBR",
sponsorUrl : "http://www.sjbr.ca/",
license : "GPL"
};
this.registerPluginInformation(pluginInformation);
/*
* Making function refernce to status bar handler
*/
this.statusBarHandlerFunctRef = this.makeFunctionReference("statusBarHandler");
return true;
},
/*
* Create the status bar
*/
onGenerate : function () {
var statusBar = document.createElement("div");
this.statusBar = statusBar;
statusBar.className = "statusBar";
var statusBarTree = document.createElement("span");
this.statusBarTree = statusBarTree;
statusBarTree.className = "statusBarTree";
statusBar.appendChild(statusBarTree);
statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"] + ": "));
this.editor._htmlArea.appendChild(this.statusBar);
this.setSelection(null);
this.noUpdate = false;
},
/*
* Adapt status bar to current editor mode
*
* @param string mode: the mode to which the editor got switched to
*/
onMode : function (mode) {
switch (mode) {
case "wysiwyg":
this.statusBar.innerHTML = "";
this.statusBar.appendChild(this.statusBarTree);
break;
case "textmode":
default:
var statusBarTextMode = document.createElement("span");
statusBarTextMode.className = "statusBarTextMode";
statusBarTextMode.appendChild(document.createTextNode(HTMLArea.I18N.msg["TEXT_MODE"]));
this.statusBar.innerHTML = "";
this.statusBar.appendChild(statusBarTextMode);
break;
}
},
/*
* Replace the contents of the staus bar with a text string
*
* @param string text: the text string to be inserted in the status bar
*/
setText : function(text) {
this.statusBarTree.innerHTML = text;
},
/*
* Clear the status bar
*/
clear : function() {
// Unhook events handlers
if (this.statusBarTree.hasChildNodes()) {
for (var element = this.statusBarTree.firstChild; element; element = element.nextSibling) {
if (element.nodeName.toLowerCase() == "a") {
HTMLArea._removeEvents(element, ["click", "contextmenu", "mousedown"], this.statusBarHandlerFunctRef);
element.ancestor = null;
element.editor = null;
}
}
}
this.setSelection(null);
this.statusBarTree.innerHTML = "";
},
/*
* Cleanup the status bar when the editor closes
*/
onClose : function() {
this.clear();
this.statusBarHandlerFunctRef = null;
this.statusBar = null;
this.statusBarTree = null;
},
/*
* Get the status bar selection
*/
getSelection : function() {
return this.selected;
},
/*
* Set the status bar selection
*
* @param object element: set the status bar selection to the given element
*/
setSelection : function(element) {
this.selected = element ? element : null;
},
/*
* Update the status bar
*/
onUpdateToolbar : function() {
if (this.editor.getMode() == "wysiwyg" && !this.noUpdate) {
var text,
language,
languageObject = this.editor.getPluginInstance("Language"),
classes = new Array(),
classText,
ancestors = this.editor.getAllAncestors();
this.clear();
this.statusBarTree.appendChild(document.createTextNode(HTMLArea.I18N.msg["Path"] + ": "));
for (var i = ancestors.length; --i >= 0;) {
var ancestor = ancestors[i];
if (!ancestor) {
continue;
}
var element = document.createElement("a");
element.href = "#";
element.ancestor = ancestor;
element.editor = this.editor;
if (!HTMLArea.is_opera) {
HTMLArea._addEvents(element, ["click", "contextmenu"], this.statusBarHandlerFunctRef);
} else {
HTMLArea._addEvents(element, ["mousedown", "click"], this.statusBarHandlerFunctRef);
}
element.title = ancestor.style.cssText;
text = ancestor.nodeName.toLowerCase();
if (ancestor.id) {
text += "#" + ancestor.id;
}
if (languageObject && languageObject.getLanguageAttribute) {
language = languageObject.getLanguageAttribute(ancestor);
if (language != "none") {
text += "[" + language + "]";
}
}
if (ancestor.className) {
classText = "";
classes = ancestor.className.trim().split(" ");
for (var j = 0, n = classes.length; j < n; ++j) {
if (!HTMLArea.reservedClassNames.test(classes[j])) {
classText += "." + classes[j];
}
}
text += classText;
}
element.appendChild(document.createTextNode(text));
this.statusBarTree.appendChild(element);
if (i) {
this.statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb)));
}
}
}
this.noUpdate = false;
},
/*
* Handle statusbar element events
*/
statusBarHandler : function (ev) {
if (!ev) {
var ev = window.event;
}
var target = (ev.target) ? ev.target : ev.srcElement;
var editor = target.editor;
target.blur();
if (HTMLArea.is_gecko) {
editor.selectNodeContents(target.ancestor);
} else {
var nodeName = target.ancestor.nodeName.toLowerCase();
if (nodeName == "table" || nodeName == "img") {
var range = editor._doc.body.createControlRange();
range.addElement(target.ancestor);
range.select();
} else {
editor.selectNode(target.ancestor);
}
}
this.setSelection(target.ancestor);
this.noUpdate = true;
editor.updateToolbar();
switch (ev.type) {
case "mousedown" :
if (HTMLArea.is_ie) {
return true;
}
case "click" :
HTMLArea._stopEvent(ev);
return false;
case "contextmenu" :
return editor.getPluginInstance("ContextMenu") ? editor.getPluginInstance("ContextMenu").popupMenu(ev, target.ancestor) : false;
}
}
});
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js (copie de travail)
this.editor.focusEditor();
var selection = this.editor._getSelection();
var statusBarSelection = this.editor.getPluginInstance("StatusBar") ? this.editor.getPluginInstance("StatusBar").getSelection() : null;
var range = this.editor._createRange(selection);
var parent = this.editor.getParentElement();
var selectionEmpty = this.editor._selectionEmpty(selection);
......
if (!selectionEmpty) {
// The selection is not empty
for (var i = 0; i < ancestors.length; ++i) {
fullNodeSelected = (HTMLArea.is_ie && ((this.editor._statusBarTree.selected === ancestors[i] && ancestors[i].innerText === range.text) || (!this.editor._statusBarTree.selected && ancestors[i].innerText === range.text)))
|| (HTMLArea.is_gecko && ((this.editor._statusBarTree.selected === ancestors[i] && ancestors[i].textContent === range.toString()) || (!this.editor._statusBarTree.selected && ancestors[i].textContent === range.toString())));
fullNodeSelected = (HTMLArea.is_ie && ((statusBarSelection === ancestors[i] && ancestors[i].innerText === range.text) || (!statusBarSelection && ancestors[i].innerText === range.text)))
|| (HTMLArea.is_gecko && ((statusBarSelection === ancestors[i] && ancestors[i].textContent === range.toString()) || (!statusBarSelection && ancestors[i].textContent === range.toString())));
if (fullNodeSelected) {
if (this.isInlineElement(ancestors[i])) {
parent = ancestors[i];
......
}
}
// Working around bug in Safari selectNodeContents
if (!fullNodeSelected && HTMLArea.is_safari && this.editor._statusBarTree.selected && this.isInlineElement(this.editor._statusBarTree.selected) && this.editor._statusBarTree.selected.textContent === range.toString()) {
if (!fullNodeSelected && HTMLArea.is_safari && statusBarSelection && this.isInlineElement(statusBarSelection) && statusBarSelection.textContent === range.toString()) {
fullNodeSelected = true;
parent = this.editor._statusBarTree.selected;
parent = statusBarSelection;
}
}
if (!selectionEmpty && !fullNodeSelected) {
......
if (this.editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
var tagName = false, classNames = Array(), fullNodeSelected = false;
var selection = editor._getSelection();
var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
var range = editor._createRange(selection);
var parent = editor.getParentElement(selection);
var ancestors = editor.getAllAncestors();
......
var selectionEmpty = editor._selectionEmpty(selection);
if (!selectionEmpty) {
for (var i = 0; i < ancestors.length; ++i) {
fullNodeSelected = (editor._statusBarTree.selected === ancestors[i])
fullNodeSelected = (statusBarSelection === ancestors[i])
&& ((HTMLArea.is_gecko && ancestors[i].textContent === range.toString()) || (HTMLArea.is_ie && ancestors[i].innerText === range.text));
if (fullNodeSelected) {
if (!HTMLArea.isBlockElement(ancestors[i])) {
......
}
}
// Working around bug in Safari selectNodeContents
if (!fullNodeSelected && HTMLArea.is_safari && this.editor._statusBarTree.selected && this.isInlineElement(this.editor._statusBarTree.selected) && this.editor._statusBarTree.selected.textContent === range.toString()) {
if (!fullNodeSelected && HTMLArea.is_safari && statusBarSelection && this.isInlineElement(statusBarSelection) && statusBarSelection.textContent === range.toString()) {
fullNodeSelected = true;
tagName = this.editor._statusBarTree.selected.nodeName.toLowerCase();
if (this.editor._statusBarTree.selected.className && /\S/.test(this.editor._statusBarTree.selected.className)) {
classNames = this.editor._statusBarTree.selected.className.trim().split(" ");
tagName = statusBarSelection.nodeName.toLowerCase();
if (statusBarSelection.className && /\S/.test(statusBarSelection.className)) {
classNames = statusBarSelection.className.trim().split(" ");
}
}
}
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Color/typo3color.js (copie de travail)
case "ForeColor":
case "HiliteColor":
var selection = editor._getSelection();
var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
var range = editor._createRange(selection);
if (editor._selectionEmpty(selection)) {
element = editor.getParentElement(selection, range);
......
if ((element.nodeName.toLowerCase() === "span") && !HTMLArea.hasAllowedAttributes(element, this.allowedAttributes)) {
editor.removeMarkup(element);
}
} else if (editor._statusBarTree.selected) {
element = editor._statusBarTree.selected;
} else if (statusBarSelection) {
element = statusBarSelection;
// Set the color in the style attribute
this.processStyle(dialog, params, element, dialog.arguments.field);
// Remove the span tag if it has no more attribute
......
var editor = this.editor;
if (editor.getMode() === "wysiwyg" && editor.isEditable()) {
var buttonId;
var parentElement = editor._statusBarTree.selected ? editor._statusBarTree.selected : editor.getParentElement();
var statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
var parentElement = statusBarSelection ? statusBarSelection : editor.getParentElement();
var enabled = editor.endPointsInSameBlock() && !(editor._selectionEmpty(editor._getSelection()) && parentElement.nodeName.toLowerCase() == "body");
for (var i = 0, n = this.buttonList.length; i < n; ++i) {
buttonId = this.buttonList[i][0];
(1-1/2)