/***************************************************************
* Copyright notice
*
-* (c) 2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
+* (c) 2008-2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
* All rights reserved
*
* This script is part of the Typo3 project. The Typo3 project is
'Wingdings' => 'Wingdings',
),
'fontsize' => array(
- 'Extra small' => 'xx-small',
- 'Very small' => 'x-small',
- 'Small' => 'small',
- 'Medium' => 'medium',
- 'Large' => 'large',
- 'Very large' => 'x-large',
- 'Extra large' => 'xx-large',
+ 'Extra small' => '8px',
+ 'Very small' => '9px',
+ 'Small' => '10px',
+ 'Medium' => '12px',
+ 'Large' => '16px',
+ 'Very large' => '24px',
+ 'Extra large' => '32px',
),
);
// Getting removal and addition configuration
$hideItems = $this->htmlAreaRTE->cleanList($this->thisConfig['hideFont' . (($buttonId == 'fontstyle') ? 'Faces' : 'Sizes')]);
- $addItems = $this->htmlAreaRTE->cleanList($this->thisConfig[($buttonId == 'fontstyle') ? 'fontFace' : 'fontSize']);
- if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonId])) {
- if ($this->thisConfig['buttons.'][$buttonId]['removeItems']) {
- $hideItems = $this->thisConfig['buttons.'][$buttonId]['removeItems'];
+ $addItems = t3lib_div::trimExplode(',', $this->htmlAreaRTE->cleanList($this->thisConfig[($buttonId == 'fontstyle') ? 'fontFace' : 'fontSize']), 1);
+ if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonId . '.'])) {
+ if ($this->thisConfig['buttons.'][$buttonId . '.']['removeItems']) {
+ $hideItems = $this->thisConfig['buttons.'][$buttonId . '.']['removeItems'];
}
- if ($this->thisConfig['buttons.'][$buttonId]['addItems']) {
- $addItems = $this->thisConfig['buttons.'][$buttonId]['addItems'];
+ if ($this->thisConfig['buttons.'][$buttonId . '.']['addItems']) {
+ $addItems = t3lib_div::trimExplode(',', $this->htmlAreaRTE->cleanList($this->thisConfig['buttons.'][$buttonId . '.']['addItems']), 1);
}
}
// Initializing the items array
$items = array();
if ($this->htmlAreaRTE->is_FE()) {
$items['none'] = '
- "' . $GLOBALS['TSFE']->getLLL((($buttonId == 'fontstyle') ? 'No font' : 'No size'), $this->LOCAL_LANG) . '" : ""';
+ "' . $GLOBALS['TSFE']->getLLL((($buttonId == 'fontstyle') ? 'Default font' : 'Default size'), $this->LOCAL_LANG) . '" : ""';
} else {
$items['none'] = '
"' . ($this->htmlAreaRTE->TCEform->inline->isAjaxCall
- ? $GLOBALS['LANG']->csConvObj->utf8_encode($GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'No font' : 'No size'), $GLOBALS['LANG']->charSet)
- : $GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'No font' : 'No size')) . '" : ""';
+ ? $GLOBALS['LANG']->csConvObj->utf8_encode($GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'Default font' : 'Default size'), $GLOBALS['LANG']->charSet)
+ : $GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'Default font' : 'Default size')) . '" : ""';
}
- $defaultItems = 'none,';
-
// Inserting and localizing default items
if ($hideItems != '*') {
$index = 0;
foreach ($this->defaultFont[$buttonId] as $name => $value) {
- if (!t3lib_div::inList($hideItems, $index+1)) {
+ if (!t3lib_div::inList($hideItems, strval($index+1))) {
if ($this->htmlAreaRTE->is_FE()) {
$label = $GLOBALS['TSFE']->getLLL($name,$this->LOCAL_LANG);
} else {
$label = $GLOBALS['LANG']->getLL($name);
+ if (!$label) {
+ $label = $name;
+ }
$label = $this->htmlAreaRTE->TCEform->inline->isAjaxCall ? $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet) : $label;
}
$items[$name] = '
"' . $label . '" : "' . $this->htmlAreaRTE->cleanList($value) . '"';
- $defaultItems .= $name . ',';
}
$index++;
}
if (is_array($this->RTEProperties[($buttonId == 'fontstyle') ? 'fonts.' : 'fontSizes.'])) {
foreach ($this->RTEProperties[($buttonId == 'fontstyle') ? 'fonts.' : 'fontSizes.'] as $name => $conf) {
$name = substr($name,0,-1);
- $label = $this->htmlAreaRTE->getPageConfigLabel($conf['name'],0);
- $label = (!$this->htmlAreaRTE->is_FE() && $this->htmlAreaRTE->TCEform->inline->isAjaxCall) ? $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet) : $label;
- $items[$name] = '
+ if (in_array($name, $addItems)) {
+ $label = $this->htmlAreaRTE->getPageConfigLabel($conf['name'],0);
+ $label = (!$this->htmlAreaRTE->is_FE() && $this->htmlAreaRTE->TCEform->inline->isAjaxCall) ? $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet) : $label;
+ $items[$name] = '
"' . $label . '" : "' . $this->htmlAreaRTE->cleanList($conf['value']) . '"';
+ }
}
+ }
+ // Seting default item
+ if ($this->thisConfig['buttons.'][$buttonId . '.']['defaultItem'] && $items[$this->thisConfig['buttons.'][$buttonId . '.']['defaultItem']]) {
+ $items['none'] = $items[$this->thisConfig['buttons.'][$buttonId . '.']['defaultItem']];
+ unset($items[$this->thisConfig['buttons.'][$buttonId . '.']['defaultItem']]);
}
// Setting the JS list of options
$JSOptions = '';
- $configuredItems = t3lib_div::trimExplode(',' , $this->htmlAreaRTE->cleanList($defaultItems . ',' . $addItems));
$index = 0;
- foreach ($configuredItems as $name) {
- $JSOptions .= ($index ? ',' : '') . $items[$name];
+ foreach ($items as $option) {
+ $JSOptions .= ($index ? ',' : '') . $option;
$index++;
}
$JSOptions = '{'
};';
// Adding to button JS configuration
- if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.'][$buttonId.'.'])) {
+ if (!is_array( $this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$buttonId . '.'])) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].buttons.'. $buttonId .' = new Object();';
}
/***************************************************************
* Copyright notice
*
-* (c) 2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
+* (c) 2008-2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* This function gets called by the class constructor
*/
configurePlugin : function (editor) {
-
+
this.options = new Object();
- this.options.FontName = this.editorConfiguration.buttons.fontstyle ? this.editorConfiguration.buttons.fontstyle.options : null;
- this.options.FontSize = this.editorConfiguration.buttons.fontsize ? this.editorConfiguration.buttons.fontsize.options : null;
+ this.defaultValue = new Object();
+ if (this.editorConfiguration.buttons.fontstyle) {
+ this.options.FontName = this.editorConfiguration.buttons.fontstyle.options;
+ if (this.editorConfiguration.buttons.fontstyle.defaultItem) {
+ this.defaultValue.FontName = this.editorConfiguration.buttons.fontstyle.options[this.editorConfiguration.buttons.fontstyle.defaultItem];
+ }
+ }
+ if (this.editorConfiguration.buttons.fontsize) {
+ this.options.FontSize = this.editorConfiguration.buttons.fontsize.options;
+ if (this.editorConfiguration.buttons.fontsize.defaultItem) {
+ this.defaultValue.FontSize = this.editorConfiguration.buttons.fontsize.options[this.editorConfiguration.buttons.fontsize.defaultItem];
+ }
+ }
this.disablePCexamples = this.editorConfiguration.disablePCexamples;
// Font formating will use the style attribute
- if (this.editor.plugins.TextStyle && this.editor.plugins.TextStyle.instance) {
- this.editor.plugins.TextStyle.instance.addAllowedAttribute("style");
- this.allowedAttributes = this.editor.plugins.TextStyle.instance.allowedAttributes;
- }
- if (this.editor.plugins.InlineElements && this.editor.plugins.InlineElements.instance) {
- this.editor.plugins.InlineElements.instance.addAllowedAttribute("style");
+ if (this.editor.getPluginInstance("TextStyle")) {
+ this.editor.getPluginInstance("TextStyle").addAllowedAttribute("style");
+ this.allowedAttributes = this.editor.getPluginInstance("TextStyle").allowedAttributes;
+ }
+ if (this.editor.getPluginInstance("InlineElements")) {
+ this.editor.getPluginInstance("InlineElements").addAllowedAttribute("style");
if (!this.allowedAllowedAttributes) {
- this.allowedAttributes = this.editor.plugins.InlineElements.instance.allowedAttributes;
+ this.allowedAttributes = this.editor.getPluginInstance("InlineElements").allowedAttributes;
}
}
- if (this.editor.plugins.BlockElements && this.editor.plugins.BlockElements.instance) {
- this.editor.plugins.BlockElements.instance.addAllowedAttribute("style");
+ if (this.editor.getPluginInstance("BlockElements")) {
+ this.editor.getPluginInstance("BlockElements").addAllowedAttribute("style");
}
if (!this.allowedAttributes) {
this.allowedAttributes = new Array("id", "title", "lang", "xml:lang", "dir", (HTMLArea.is_gecko?"class":"className"), "style");
FontName : "fontFamily",
FontSize : "fontSize"
},
+
+ /*
+ * Conversion object: button name to corresponding css property name
+ */
+ cssProperty : {
+ FontName : "font-family",
+ FontSize : "font-size"
+ },
/*
* This function gets called when some font style or font size was selected from the dropdown lists
onChange : function (editor, buttonId) {
var select = document.getElementById(this.editor._toolbarObjects[buttonId].elementId),
param = select.value;
- if (param == 'none') {
+ if (!select.selectedIndex) {
param = "";
}
editor.focusEditor();
var selection = editor._getSelection(),
range = editor._createRange(selection),
- statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null;
+ statusBarSelection = editor.getPluginInstance("StatusBar") ? editor.getPluginInstance("StatusBar").getSelection() : null,
element;
if (editor._selectionEmpty(selection)) {
element = editor.getParentElement(selection, range);
if (this.isButtonInToolbar(buttonId)) {
var select = document.getElementById(editor._toolbarObjects[buttonId].elementId);
value = parentElement.style[this.styleProperty[buttonId]];
+ if (!value) {
+ if (HTMLArea.is_gecko) {
+ if (editor._doc.defaultView.getComputedStyle(parentElement, null)) {
+ value = editor._doc.defaultView.getComputedStyle(parentElement, null).getPropertyValue(this.cssProperty[buttonId]);
+ }
+ } else {
+ value = parentElement.currentStyle[this.styleProperty[buttonId]];
+ }
+ }
select.selectedIndex = 0;
if (value) {
var options = this.options[buttonId];