From c21e56b0b7d844377f0cf0a09c3b399aeade40f7 Mon Sep 17 00:00:00 2001
From: Fabrizio Balliano
Date: Wed, 5 Jul 2023 09:38:56 +0100
Subject: [PATCH 01/11] Removed unexisting branch alias from composer.json
(#3364)
---
composer.json | 3 ---
composer.lock | 2 +-
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/composer.json b/composer.json
index b366530bbc7..5902f235453 100644
--- a/composer.json
+++ b/composer.json
@@ -84,9 +84,6 @@
}
},
"extra": {
- "branch-alias": {
- "dev-main": "1.9.4.x-dev"
- },
"magento-root-dir": ".",
"magento-deploystrategy": "copy",
"magento-deploystrategy-dev": "symlink",
diff --git a/composer.lock b/composer.lock
index bb3ed52bb62..fc3c029bdd2 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e73fdcac234fc7d39e4487ab1e2d80a3",
+ "content-hash": "bcf4c7beaca0c503bdd487b27bb863b6",
"packages": [
{
"name": "colinmollenhour/cache-backend-redis",
From f96823352e02915427f56233e99ab2c3cf5426a7 Mon Sep 17 00:00:00 2001
From: Hans Mackowiak
Date: Wed, 5 Jul 2023 18:01:17 +0200
Subject: [PATCH 02/11] Clear config cache after maintenance check for DB
Update (#3365)
* clear config cache after maintenance check
* Added .ip and .flag files to htaccess forbidden list
* Update index.php
Co-authored-by: Fabrizio Balliano
---------
Co-authored-by: Fabrizio Balliano
---
.htaccess | 2 +-
index.php | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/.htaccess b/.htaccess
index 7251495a9dc..074758ad18f 100644
--- a/.htaccess
+++ b/.htaccess
@@ -247,7 +247,7 @@
Order allow,deny
Deny from all
-
+
Order allow,deny
Deny from all
diff --git a/index.php b/index.php
index ca190786dca..4432c63b0c4 100644
--- a/index.php
+++ b/index.php
@@ -51,6 +51,10 @@
include_once __DIR__ . '/errors/503.php';
exit;
}
+
+ // remove config cache to make the system check for DB updates
+ $config = Mage::app()->getConfig();
+ $config->getCache()->remove($config->getCacheId());
}
Mage::run($mageRunCode, $mageRunType);
From 2a352a1abb23ca0f8dde9bcc683402e99ee33986 Mon Sep 17 00:00:00 2001
From: Hans Mackowiak
Date: Thu, 6 Jul 2023 09:28:09 +0200
Subject: [PATCH 03/11] Added hidden element before multiselect form elements
in adminhtml (#3352)
Co-authored-by: Ng Kiat Siong
Co-authored-by: Fabrizio Balliano
---
lib/Varien/Data/Form/Element/Multiselect.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/Varien/Data/Form/Element/Multiselect.php b/lib/Varien/Data/Form/Element/Multiselect.php
index 531d687519b..8b4c9c5ab15 100644
--- a/lib/Varien/Data/Form/Element/Multiselect.php
+++ b/lib/Varien/Data/Form/Element/Multiselect.php
@@ -57,8 +57,10 @@ public function getElementHtml()
{
$this->addClass('select multiselect');
$html = '';
- if ($this->getCanBeEmpty() && empty($this->_data['disabled'])) {
- $html .= '';
+ if ($this->getCanBeEmpty()) {
+ $html .= '_data['disabled']) ? '' : ' disabled="disabled"';
+ $html .= '/>';
}
$html .= '
will become
a
b
c
- *
- * @example
- * var parser = new tinymce.html.DomParser({validate: true}, schema);
- * var rootNode = parser.parse('
content
');
- *
- * @class tinymce.html.DomParser
- * @version 3.4
- */
-
- /**
- * Constructs a new DomParser instance.
- *
- * @constructor
- * @method DomParser
- * @param {Object} settings Name/value collection of settings. comment, cdata, text, start and end are callbacks.
- * @param {tinymce.html.Schema} schema HTML Schema class to use when parsing.
- */
- tinymce.html.DomParser = function(settings, schema) {
- var self = this, nodeFilters = {}, attributeFilters = [], matchedNodes = {}, matchedAttributes = {};
-
- settings = settings || {};
- settings.validate = "validate" in settings ? settings.validate : true;
- settings.root_name = settings.root_name || 'body';
- self.schema = schema = schema || new tinymce.html.Schema();
-
- function fixInvalidChildren(nodes) {
- var ni, node, parent, parents, newParent, currentNode, tempNode, childNode, i,
- childClone, nonEmptyElements, nonSplitableElements, textBlockElements, sibling, nextNode;
-
- nonSplitableElements = tinymce.makeMap('tr,td,th,tbody,thead,tfoot,table');
- nonEmptyElements = schema.getNonEmptyElements();
- textBlockElements = schema.getTextBlockElements();
-
- for (ni = 0; ni < nodes.length; ni++) {
- node = nodes[ni];
-
- // Already removed or fixed
- if (!node.parent || node.fixed)
- continue;
-
- // If the invalid element is a text block and the text block is within a parent LI element
- // Then unwrap the first text block and convert other sibling text blocks to LI elements similar to Word/Open Office
- if (textBlockElements[node.name] && node.parent.name == 'li') {
- // Move sibling text blocks after LI element
- sibling = node.next;
- while (sibling) {
- if (textBlockElements[sibling.name]) {
- sibling.name = 'li';
- sibling.fixed = true;
- node.parent.insert(sibling, node.parent);
- } else {
- break;
- }
-
- sibling = sibling.next;
- }
-
- // Unwrap current text block
- node.unwrap(node);
- continue;
- }
-
- // Get list of all parent nodes until we find a valid parent to stick the child into
- parents = [node];
- for (parent = node.parent; parent && !schema.isValidChild(parent.name, node.name) && !nonSplitableElements[parent.name]; parent = parent.parent)
- parents.push(parent);
-
- // Found a suitable parent
- if (parent && parents.length > 1) {
- // Reverse the array since it makes looping easier
- parents.reverse();
-
- // Clone the related parent and insert that after the moved node
- newParent = currentNode = self.filterNode(parents[0].clone());
-
- // Start cloning and moving children on the left side of the target node
- for (i = 0; i < parents.length - 1; i++) {
- if (schema.isValidChild(currentNode.name, parents[i].name)) {
- tempNode = self.filterNode(parents[i].clone());
- currentNode.append(tempNode);
- } else
- tempNode = currentNode;
-
- for (childNode = parents[i].firstChild; childNode && childNode != parents[i + 1]; ) {
- nextNode = childNode.next;
- tempNode.append(childNode);
- childNode = nextNode;
- }
-
- currentNode = tempNode;
- }
-
- if (!newParent.isEmpty(nonEmptyElements)) {
- parent.insert(newParent, parents[0], true);
- parent.insert(node, newParent);
- } else {
- parent.insert(node, parents[0], true);
- }
-
- // Check if the element is empty by looking through it's contents and special treatment for
- parent = parents[0];
- if (parent.isEmpty(nonEmptyElements) || parent.firstChild === parent.lastChild && parent.firstChild.name === 'br') {
- parent.empty().remove();
- }
- } else if (node.parent) {
- // If it's an LI try to find a UL/OL for it or wrap it
- if (node.name === 'li') {
- sibling = node.prev;
- if (sibling && (sibling.name === 'ul' || sibling.name === 'ul')) {
- sibling.append(node);
- continue;
- }
-
- sibling = node.next;
- if (sibling && (sibling.name === 'ul' || sibling.name === 'ul')) {
- sibling.insert(node, sibling.firstChild, true);
- continue;
- }
-
- node.wrap(self.filterNode(new Node('ul', 1)));
- continue;
- }
-
- // Try wrapping the element in a DIV
- if (schema.isValidChild(node.parent.name, 'div') && schema.isValidChild('div', node.name)) {
- node.wrap(self.filterNode(new Node('div', 1)));
- } else {
- // We failed wrapping it, then remove or unwrap it
- if (node.name === 'style' || node.name === 'script')
- node.empty().remove();
- else
- node.unwrap();
- }
- }
- }
- };
-
- /**
- * Runs the specified node though the element and attributes filters.
- *
- * @param {tinymce.html.Node} Node the node to run filters on.
- * @return {tinymce.html.Node} The passed in node.
- */
- self.filterNode = function(node) {
- var i, name, list;
-
- // Run element filters
- if (name in nodeFilters) {
- list = matchedNodes[name];
-
- if (list)
- list.push(node);
- else
- matchedNodes[name] = [node];
- }
-
- // Run attribute filters
- i = attributeFilters.length;
- while (i--) {
- name = attributeFilters[i].name;
-
- if (name in node.attributes.map) {
- list = matchedAttributes[name];
-
- if (list)
- list.push(node);
- else
- matchedAttributes[name] = [node];
- }
- }
-
- return node;
- };
-
- /**
- * Adds a node filter function to the parser, the parser will collect the specified nodes by name
- * and then execute the callback ones it has finished parsing the document.
- *
- * @example
- * parser.addNodeFilter('p,h1', function(nodes, name) {
- * for (var i = 0; i < nodes.length; i++) {
- * console.log(nodes[i].name);
- * }
- * });
- * @method addNodeFilter
- * @method {String} name Comma separated list of nodes to collect.
- * @param {function} callback Callback function to execute once it has collected nodes.
- */
- self.addNodeFilter = function(name, callback) {
- tinymce.each(tinymce.explode(name), function(name) {
- var list = nodeFilters[name];
-
- if (!list)
- nodeFilters[name] = list = [];
-
- list.push(callback);
- });
- };
-
- /**
- * Adds a attribute filter function to the parser, the parser will collect nodes that has the specified attributes
- * and then execute the callback ones it has finished parsing the document.
- *
- * @example
- * parser.addAttributeFilter('src,href', function(nodes, name) {
- * for (var i = 0; i < nodes.length; i++) {
- * console.log(nodes[i].name);
- * }
- * });
- * @method addAttributeFilter
- * @method {String} name Comma separated list of nodes to collect.
- * @param {function} callback Callback function to execute once it has collected nodes.
- */
- self.addAttributeFilter = function(name, callback) {
- tinymce.each(tinymce.explode(name), function(name) {
- var i;
-
- for (i = 0; i < attributeFilters.length; i++) {
- if (attributeFilters[i].name === name) {
- attributeFilters[i].callbacks.push(callback);
- return;
- }
- }
-
- attributeFilters.push({name: name, callbacks: [callback]});
- });
- };
-
- /**
- * Parses the specified HTML string into a DOM like node tree and returns the result.
- *
- * @example
- * var rootNode = new DomParser({...}).parse('text');
- * @method parse
- * @param {String} html Html string to sax parse.
- * @param {Object} args Optional args object that gets passed to all filter functions.
- * @return {tinymce.html.Node} Root node containing the tree.
- */
- self.parse = function(html, args) {
- var parser, rootNode, node, nodes, i, l, fi, fl, list, name, validate,
- blockElements, startWhiteSpaceRegExp, invalidChildren = [], isInWhiteSpacePreservedElement,
- endWhiteSpaceRegExp, allWhiteSpaceRegExp, isAllWhiteSpaceRegExp, whiteSpaceElements, children, nonEmptyElements, rootBlockName;
-
- args = args || {};
- matchedNodes = {};
- matchedAttributes = {};
- blockElements = tinymce.extend(tinymce.makeMap('script,style,head,html,body,title,meta,param'), schema.getBlockElements());
- nonEmptyElements = schema.getNonEmptyElements();
- children = schema.children;
- validate = settings.validate;
- rootBlockName = "forced_root_block" in args ? args.forced_root_block : settings.forced_root_block;
-
- whiteSpaceElements = schema.getWhiteSpaceElements();
- startWhiteSpaceRegExp = /^[ \t\r\n]+/;
- endWhiteSpaceRegExp = /[ \t\r\n]+$/;
- allWhiteSpaceRegExp = /[ \t\r\n]+/g;
- isAllWhiteSpaceRegExp = /^[ \t\r\n]+$/;
-
- function addRootBlocks() {
- var node = rootNode.firstChild, next, rootBlockNode;
-
- while (node) {
- next = node.next;
-
- if (node.type == 3 || (node.type == 1 && node.name !== 'p' && !blockElements[node.name] && !node.attr('data-mce-type'))) {
- if (!rootBlockNode) {
- // Create a new root block element
- rootBlockNode = createNode(rootBlockName, 1);
- rootNode.insert(rootBlockNode, node);
- rootBlockNode.append(node);
- } else
- rootBlockNode.append(node);
- } else {
- rootBlockNode = null;
- }
-
- node = next;
- };
- };
-
- function createNode(name, type) {
- var node = new Node(name, type), list;
-
- if (name in nodeFilters) {
- list = matchedNodes[name];
-
- if (list)
- list.push(node);
- else
- matchedNodes[name] = [node];
- }
-
- return node;
- };
-
- function removeWhitespaceBefore(node) {
- var textNode, textVal, sibling;
-
- for (textNode = node.prev; textNode && textNode.type === 3; ) {
- textVal = textNode.value.replace(endWhiteSpaceRegExp, '');
-
- if (textVal.length > 0) {
- textNode.value = textVal;
- textNode = textNode.prev;
- } else {
- sibling = textNode.prev;
- textNode.remove();
- textNode = sibling;
- }
- }
- };
-
- function cloneAndExcludeBlocks(input) {
- var name, output = {};
-
- for (name in input) {
- if (name !== 'li' && name != 'p') {
- output[name] = input[name];
- }
- }
-
- return output;
- };
-
- parser = new tinymce.html.SaxParser({
- validate : validate,
-
- // Exclude P and LI from DOM parsing since it's treated better by the DOM parser
- self_closing_elements: cloneAndExcludeBlocks(schema.getSelfClosingElements()),
-
- cdata: function(text) {
- node.append(createNode('#cdata', 4)).value = text;
- },
-
- text: function(text, raw) {
- var textNode;
-
- // Trim all redundant whitespace on non white space elements
- if (!isInWhiteSpacePreservedElement) {
- text = text.replace(allWhiteSpaceRegExp, ' ');
-
- if (node.lastChild && blockElements[node.lastChild.name])
- text = text.replace(startWhiteSpaceRegExp, '');
- }
-
- // Do we need to create the node
- if (text.length !== 0) {
- textNode = createNode('#text', 3);
- textNode.raw = !!raw;
- node.append(textNode).value = text;
- }
- },
-
- comment: function(text) {
- node.append(createNode('#comment', 8)).value = text;
- },
-
- pi: function(name, text) {
- node.append(createNode(name, 7)).value = text;
- removeWhitespaceBefore(node);
- },
-
- doctype: function(text) {
- var newNode;
-
- newNode = node.append(createNode('#doctype', 10));
- newNode.value = text;
- removeWhitespaceBefore(node);
- },
-
- start: function(name, attrs, empty) {
- var newNode, attrFiltersLen, elementRule, textNode, attrName, text, sibling, parent;
-
- elementRule = validate ? schema.getElementRule(name) : {};
- if (elementRule) {
- newNode = createNode(elementRule.outputName || name, 1);
- newNode.attributes = attrs;
- newNode.shortEnded = empty;
-
- node.append(newNode);
-
- // Check if node is valid child of the parent node is the child is
- // unknown we don't collect it since it's probably a custom element
- parent = children[node.name];
- if (parent && children[newNode.name] && !parent[newNode.name])
- invalidChildren.push(newNode);
-
- attrFiltersLen = attributeFilters.length;
- while (attrFiltersLen--) {
- attrName = attributeFilters[attrFiltersLen].name;
-
- if (attrName in attrs.map) {
- list = matchedAttributes[attrName];
-
- if (list)
- list.push(newNode);
- else
- matchedAttributes[attrName] = [newNode];
- }
- }
-
- // Trim whitespace before block
- if (blockElements[name])
- removeWhitespaceBefore(newNode);
-
- // Change current node if the element wasn't empty i.e not or
- if (!empty)
- node = newNode;
-
- // Check if we are inside a whitespace preserved element
- if (!isInWhiteSpacePreservedElement && whiteSpaceElements[name]) {
- isInWhiteSpacePreservedElement = true;
- }
- }
- },
-
- end: function(name) {
- var textNode, elementRule, text, sibling, tempNode;
-
- elementRule = validate ? schema.getElementRule(name) : {};
- if (elementRule) {
- if (blockElements[name]) {
- if (!isInWhiteSpacePreservedElement) {
- // Trim whitespace of the first node in a block
- textNode = node.firstChild;
- if (textNode && textNode.type === 3) {
- text = textNode.value.replace(startWhiteSpaceRegExp, '');
-
- // Any characters left after trim or should we remove it
- if (text.length > 0) {
- textNode.value = text;
- textNode = textNode.next;
- } else {
- sibling = textNode.next;
- textNode.remove();
- textNode = sibling;
- }
-
- // Remove any pure whitespace siblings
- while (textNode && textNode.type === 3) {
- text = textNode.value;
- sibling = textNode.next;
-
- if (text.length === 0 || isAllWhiteSpaceRegExp.test(text)) {
- textNode.remove();
- textNode = sibling;
- }
-
- textNode = sibling;
- }
- }
-
- // Trim whitespace of the last node in a block
- textNode = node.lastChild;
- if (textNode && textNode.type === 3) {
- text = textNode.value.replace(endWhiteSpaceRegExp, '');
-
- // Any characters left after trim or should we remove it
- if (text.length > 0) {
- textNode.value = text;
- textNode = textNode.prev;
- } else {
- sibling = textNode.prev;
- textNode.remove();
- textNode = sibling;
- }
-
- // Remove any pure whitespace siblings
- while (textNode && textNode.type === 3) {
- text = textNode.value;
- sibling = textNode.prev;
-
- if (text.length === 0 || isAllWhiteSpaceRegExp.test(text)) {
- textNode.remove();
- textNode = sibling;
- }
-
- textNode = sibling;
- }
- }
- }
-
- // Trim start white space
- // Removed due to: #5424
- /*textNode = node.prev;
- if (textNode && textNode.type === 3) {
- text = textNode.value.replace(startWhiteSpaceRegExp, '');
-
- if (text.length > 0)
- textNode.value = text;
- else
- textNode.remove();
- }*/
- }
-
- // Check if we exited a whitespace preserved element
- if (isInWhiteSpacePreservedElement && whiteSpaceElements[name]) {
- isInWhiteSpacePreservedElement = false;
- }
-
- // Handle empty nodes
- if (elementRule.removeEmpty || elementRule.paddEmpty) {
- if (node.isEmpty(nonEmptyElements)) {
- if (elementRule.paddEmpty)
- node.empty().append(new Node('#text', '3')).value = '\u00a0';
- else {
- // Leave nodes that have a name like
- if (!node.attributes.map.name && !node.attributes.map.id) {
- tempNode = node.parent;
- node.empty().remove();
- node = tempNode;
- return;
- }
- }
- }
- }
-
- node = node.parent;
- }
- }
- }, schema);
-
- rootNode = node = new Node(args.context || settings.root_name, 11);
-
- parser.parse(html);
-
- // Fix invalid children or report invalid children in a contextual parsing
- if (validate && invalidChildren.length) {
- if (!args.context)
- fixInvalidChildren(invalidChildren);
- else
- args.invalid = true;
- }
-
- // Wrap nodes in the root into block elements if the root is body
- if (rootBlockName && rootNode.name == 'body')
- addRootBlocks();
-
- // Run filters only when the contents is valid
- if (!args.invalid) {
- // Run node filters
- for (name in matchedNodes) {
- list = nodeFilters[name];
- nodes = matchedNodes[name];
-
- // Remove already removed children
- fi = nodes.length;
- while (fi--) {
- if (!nodes[fi].parent)
- nodes.splice(fi, 1);
- }
-
- for (i = 0, l = list.length; i < l; i++)
- list[i](nodes, name, args);
- }
-
- // Run attribute filters
- for (i = 0, l = attributeFilters.length; i < l; i++) {
- list = attributeFilters[i];
-
- if (list.name in matchedAttributes) {
- nodes = matchedAttributes[list.name];
-
- // Remove already removed children
- fi = nodes.length;
- while (fi--) {
- if (!nodes[fi].parent)
- nodes.splice(fi, 1);
- }
-
- for (fi = 0, fl = list.callbacks.length; fi < fl; fi++)
- list.callbacks[fi](nodes, list.name, args);
- }
- }
- }
-
- return rootNode;
- };
-
- // Remove at end of block elements Gecko and WebKit injects BR elements to
- // make it possible to place the caret inside empty blocks. This logic tries to remove
- // these elements and keep br elements that where intended to be there intact
- if (settings.remove_trailing_brs) {
- self.addNodeFilter('br', function(nodes, name) {
- var i, l = nodes.length, node, blockElements = tinymce.extend({}, schema.getBlockElements()),
- nonEmptyElements = schema.getNonEmptyElements(), parent, lastParent, prev, prevName;
-
- // Remove brs from body element as well
- blockElements.body = 1;
-
- // Must loop forwards since it will otherwise remove all brs in
- if (fixSelfClosing && selfClosing[value] && stack.length > 0 && stack[stack.length - 1].name === value)
- processEndTag(value);
-
- // Validate element
- if (!validate || (elementRule = schema.getElementRule(value))) {
- isValidElement = true;
-
- // Grab attributes map and patters when validation is enabled
- if (validate) {
- validAttributesMap = elementRule.attributes;
- validAttributePatterns = elementRule.attributePatterns;
- }
-
- // Parse attributes
- if (attribsValue = matches[8]) {
- isInternalElement = attribsValue.indexOf('data-mce-type') !== -1; // Check if the element is an internal element
-
- // If the element has internal attributes then remove it if we are told to do so
- if (isInternalElement && removeInternalElements)
- isValidElement = false;
-
- attrList = [];
- attrList.map = {};
-
- attribsValue.replace(attrRegExp, parseAttribute);
- } else {
- attrList = [];
- attrList.map = {};
- }
-
- // Process attributes if validation is enabled
- if (validate && !isInternalElement) {
- attributesRequired = elementRule.attributesRequired;
- attributesDefault = elementRule.attributesDefault;
- attributesForced = elementRule.attributesForced;
-
- // Handle forced attributes
- if (attributesForced) {
- i = attributesForced.length;
- while (i--) {
- attr = attributesForced[i];
- name = attr.name;
- attrValue = attr.value;
-
- if (attrValue === '{$uid}')
- attrValue = 'mce_' + idCount++;
-
- attrList.map[name] = attrValue;
- attrList.push({name: name, value: attrValue});
- }
- }
-
- // Handle default attributes
- if (attributesDefault) {
- i = attributesDefault.length;
- while (i--) {
- attr = attributesDefault[i];
- name = attr.name;
-
- if (!(name in attrList.map)) {
- attrValue = attr.value;
-
- if (attrValue === '{$uid}')
- attrValue = 'mce_' + idCount++;
-
- attrList.map[name] = attrValue;
- attrList.push({name: name, value: attrValue});
- }
- }
- }
-
- // Handle required attributes
- if (attributesRequired) {
- i = attributesRequired.length;
- while (i--) {
- if (attributesRequired[i] in attrList.map)
- break;
- }
-
- // None of the required attributes where found
- if (i === -1)
- isValidElement = false;
- }
-
- // Invalidate element if it's marked as bogus
- if (attrList.map['data-mce-bogus'])
- isValidElement = false;
- }
-
- if (isValidElement)
- self.start(value, attrList, isShortEnded);
- } else
- isValidElement = false;
-
- // Treat script, noscript and style a bit different since they may include code that looks like elements
- if (endRegExp = specialElements[value]) {
- endRegExp.lastIndex = index = matches.index + matches[0].length;
-
- if (matches = endRegExp.exec(html)) {
- if (isValidElement)
- text = html.substr(index, matches.index - index);
-
- index = matches.index + matches[0].length;
- } else {
- text = html.substr(index);
- index = html.length;
- }
-
- if (isValidElement && text.length > 0)
- self.text(text, true);
-
- if (isValidElement)
- self.end(value);
-
- tokenRegExp.lastIndex = index;
- continue;
- }
-
- // Push value on to stack
- if (!isShortEnded) {
- if (!attribsValue || attribsValue.indexOf('/') != attribsValue.length - 1)
- stack.push({name: value, valid: isValidElement});
- else if (isValidElement)
- self.end(value);
- }
- } else if (value = matches[1]) { // Comment
- self.comment(value);
- } else if (value = matches[2]) { // CDATA
- self.cdata(value);
- } else if (value = matches[3]) { // DOCTYPE
- self.doctype(value);
- } else if (value = matches[4]) { // PI
- self.pi(value, matches[5]);
- }
-
- index = matches.index + matches[0].length;
- }
-
- // Text
- if (index < html.length)
- self.text(decode(html.substr(index)));
-
- // Close any open elements
- for (i = stack.length - 1; i >= 0; i--) {
- value = stack[i];
-
- if (value.valid)
- self.end(value.name);
- }
- };
- }
-})(tinymce);
+/**
+ * SaxParser.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ /**
+ * This class parses HTML code using pure JavaScript and executes various events for each item it finds. It will
+ * always execute the events in the right order for tag soup code like . It will also remove elements
+ * and attributes that doesn't fit the schema if the validate setting is enabled.
+ *
+ * @example
+ * var parser = new tinymce.html.SaxParser({
+ * validate: true,
+ *
+ * comment: function(text) {
+ * console.log('Comment:', text);
+ * },
+ *
+ * cdata: function(text) {
+ * console.log('CDATA:', text);
+ * },
+ *
+ * text: function(text, raw) {
+ * console.log('Text:', text, 'Raw:', raw);
+ * },
+ *
+ * start: function(name, attrs, empty) {
+ * console.log('Start:', name, attrs, empty);
+ * },
+ *
+ * end: function(name) {
+ * console.log('End:', name);
+ * },
+ *
+ * pi: function(name, text) {
+ * console.log('PI:', name, text);
+ * },
+ *
+ * doctype: function(text) {
+ * console.log('DocType:', text);
+ * }
+ * }, schema);
+ * @class tinymce.html.SaxParser
+ * @version 3.4
+ */
+
+ /**
+ * Constructs a new SaxParser instance.
+ *
+ * @constructor
+ * @method SaxParser
+ * @param {Object} settings Name/value collection of settings. comment, cdata, text, start and end are callbacks.
+ * @param {tinymce.html.Schema} schema HTML Schema class to use when parsing.
+ */
+ tinymce.html.SaxParser = function(settings, schema) {
+ var self = this, noop = function() {};
+
+ settings = settings || {};
+ self.schema = schema = schema || new tinymce.html.Schema();
+
+ if (settings.fix_self_closing !== false)
+ settings.fix_self_closing = true;
+
+ // Add handler functions from settings and setup default handlers
+ tinymce.each('comment cdata text start end pi doctype'.split(' '), function(name) {
+ if (name)
+ self[name] = settings[name] || noop;
+ });
+
+ /**
+ * Parses the specified HTML string and executes the callbacks for each item it finds.
+ *
+ * @example
+ * new SaxParser({...}).parse('text');
+ * @method parse
+ * @param {String} html Html string to sax parse.
+ */
+ self.parse = function(html) {
+ var self = this, matches, index = 0, value, endRegExp, stack = [], attrList, i, text, name, isInternalElement, removeInternalElements,
+ shortEndedElements, fillAttrsMap, isShortEnded, validate, elementRule, isValidElement, attr, attribsValue, invalidPrefixRegExp,
+ validAttributesMap, validAttributePatterns, attributesRequired, attributesDefault, attributesForced, selfClosing,
+ tokenRegExp, attrRegExp, specialElements, attrValue, idCount = 0, decode = tinymce.html.Entities.decode, fixSelfClosing, isIE;
+
+ function processEndTag(name) {
+ var pos, i;
+
+ // Find position of parent of the same type
+ pos = stack.length;
+ while (pos--) {
+ if (stack[pos].name === name)
+ break;
+ }
+
+ // Found parent
+ if (pos >= 0) {
+ // Close all the open elements
+ for (i = stack.length - 1; i >= pos; i--) {
+ name = stack[i];
+
+ if (name.valid)
+ self.end(name.name);
+ }
+
+ // Remove the open elements from the stack
+ stack.length = pos;
+ }
+ };
+
+ function parseAttribute(match, name, value, val2, val3) {
+ var attrRule, i;
+
+ name = name.toLowerCase();
+ value = name in fillAttrsMap ? name : decode(value || val2 || val3 || ''); // Handle boolean attribute than value attribute
+
+ // Validate name and value
+ if (validate && !isInternalElement && name.indexOf('data-') !== 0) {
+ attrRule = validAttributesMap[name];
+
+ // Find rule by pattern matching
+ if (!attrRule && validAttributePatterns) {
+ i = validAttributePatterns.length;
+ while (i--) {
+ attrRule = validAttributePatterns[i];
+ if (attrRule.pattern.test(name))
+ break;
+ }
+
+ // No rule matched
+ if (i === -1)
+ attrRule = null;
+ }
+
+ // No attribute rule found
+ if (!attrRule)
+ return;
+
+ // Validate value
+ if (attrRule.validValues && !(value in attrRule.validValues))
+ return;
+ }
+
+ // Add attribute to list and map
+ attrList.map[name] = value;
+ attrList.push({
+ name: name,
+ value: value
+ });
+ };
+
+ // Precompile RegExps and map objects
+ tokenRegExp = new RegExp('<(?:' +
+ '(?:!--([\\w\\W]*?)-->)|' + // Comment
+ '(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|' + // CDATA
+ '(?:!DOCTYPE([\\w\\W]*?)>)|' + // DOCTYPE
+ '(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|' + // PI
+ '(?:\\/([^>]+)>)|' + // End element
+ '(?:([A-Za-z0-9\\-\\:\\.]+)((?:\\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\\/|\\s+)>)' + // Start element
+ ')', 'g');
+
+ attrRegExp = /([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g;
+ specialElements = {
+ 'script' : /<\/script[^>]*>/gi,
+ 'style' : /<\/style[^>]*>/gi,
+ 'noscript' : /<\/noscript[^>]*>/gi
+ };
+
+ // Setup lookup tables for empty elements and boolean attributes
+ shortEndedElements = schema.getShortEndedElements();
+ selfClosing = settings.self_closing_elements || schema.getSelfClosingElements();
+ fillAttrsMap = schema.getBoolAttrs();
+ validate = settings.validate;
+ removeInternalElements = settings.remove_internals;
+ fixSelfClosing = settings.fix_self_closing;
+ isIE = tinymce.isIE;
+ invalidPrefixRegExp = /^:/;
+
+ while (matches = tokenRegExp.exec(html)) {
+ // Text
+ if (index < matches.index)
+ self.text(decode(html.substr(index, matches.index - index)));
+
+ if (value = matches[6]) { // End element
+ value = value.toLowerCase();
+
+ // IE will add a ":" in front of elements it doesn't understand like custom elements or HTML5 elements
+ if (isIE && invalidPrefixRegExp.test(value))
+ value = value.substr(1);
+
+ processEndTag(value);
+ } else if (value = matches[7]) { // Start element
+ value = value.toLowerCase();
+
+ // IE will add a ":" in front of elements it doesn't understand like custom elements or HTML5 elements
+ if (isIE && invalidPrefixRegExp.test(value))
+ value = value.substr(1);
+
+ isShortEnded = value in shortEndedElements;
+
+ // Is self closing tag for example an
after an open
+ if (fixSelfClosing && selfClosing[value] && stack.length > 0 && stack[stack.length - 1].name === value)
+ processEndTag(value);
+
+ // Validate element
+ if (!validate || (elementRule = schema.getElementRule(value))) {
+ isValidElement = true;
+
+ // Grab attributes map and patters when validation is enabled
+ if (validate) {
+ validAttributesMap = elementRule.attributes;
+ validAttributePatterns = elementRule.attributePatterns;
+ }
+
+ // Parse attributes
+ if (attribsValue = matches[8]) {
+ isInternalElement = attribsValue.indexOf('data-mce-type') !== -1; // Check if the element is an internal element
+
+ // If the element has internal attributes then remove it if we are told to do so
+ if (isInternalElement && removeInternalElements)
+ isValidElement = false;
+
+ attrList = [];
+ attrList.map = {};
+
+ attribsValue.replace(attrRegExp, parseAttribute);
+ } else {
+ attrList = [];
+ attrList.map = {};
+ }
+
+ // Process attributes if validation is enabled
+ if (validate && !isInternalElement) {
+ attributesRequired = elementRule.attributesRequired;
+ attributesDefault = elementRule.attributesDefault;
+ attributesForced = elementRule.attributesForced;
+
+ // Handle forced attributes
+ if (attributesForced) {
+ i = attributesForced.length;
+ while (i--) {
+ attr = attributesForced[i];
+ name = attr.name;
+ attrValue = attr.value;
+
+ if (attrValue === '{$uid}')
+ attrValue = 'mce_' + idCount++;
+
+ attrList.map[name] = attrValue;
+ attrList.push({name: name, value: attrValue});
+ }
+ }
+
+ // Handle default attributes
+ if (attributesDefault) {
+ i = attributesDefault.length;
+ while (i--) {
+ attr = attributesDefault[i];
+ name = attr.name;
+
+ if (!(name in attrList.map)) {
+ attrValue = attr.value;
+
+ if (attrValue === '{$uid}')
+ attrValue = 'mce_' + idCount++;
+
+ attrList.map[name] = attrValue;
+ attrList.push({name: name, value: attrValue});
+ }
+ }
+ }
+
+ // Handle required attributes
+ if (attributesRequired) {
+ i = attributesRequired.length;
+ while (i--) {
+ if (attributesRequired[i] in attrList.map)
+ break;
+ }
+
+ // None of the required attributes where found
+ if (i === -1)
+ isValidElement = false;
+ }
+
+ // Invalidate element if it's marked as bogus
+ if (attrList.map['data-mce-bogus'])
+ isValidElement = false;
+ }
+
+ if (isValidElement)
+ self.start(value, attrList, isShortEnded);
+ } else
+ isValidElement = false;
+
+ // Treat script, noscript and style a bit different since they may include code that looks like elements
+ if (endRegExp = specialElements[value]) {
+ endRegExp.lastIndex = index = matches.index + matches[0].length;
+
+ if (matches = endRegExp.exec(html)) {
+ if (isValidElement)
+ text = html.substr(index, matches.index - index);
+
+ index = matches.index + matches[0].length;
+ } else {
+ text = html.substr(index);
+ index = html.length;
+ }
+
+ if (isValidElement && text.length > 0)
+ self.text(text, true);
+
+ if (isValidElement)
+ self.end(value);
+
+ tokenRegExp.lastIndex = index;
+ continue;
+ }
+
+ // Push value on to stack
+ if (!isShortEnded) {
+ if (!attribsValue || attribsValue.indexOf('/') != attribsValue.length - 1)
+ stack.push({name: value, valid: isValidElement});
+ else if (isValidElement)
+ self.end(value);
+ }
+ } else if (value = matches[1]) { // Comment
+ self.comment(value);
+ } else if (value = matches[2]) { // CDATA
+ self.cdata(value);
+ } else if (value = matches[3]) { // DOCTYPE
+ self.doctype(value);
+ } else if (value = matches[4]) { // PI
+ self.pi(value, matches[5]);
+ }
+
+ index = matches.index + matches[0].length;
+ }
+
+ // Text
+ if (index < html.length)
+ self.text(decode(html.substr(index)));
+
+ // Close any open elements
+ for (i = stack.length - 1; i >= 0; i--) {
+ value = stack[i];
+
+ if (value.valid)
+ self.end(value.name);
+ }
+ };
+ }
+})(tinymce);
diff --git a/js/tiny_mce/classes/html/Schema.js b/js/tiny_mce/classes/html/Schema.js
index 77b666eba7f..e25324164c4 100644
--- a/js/tiny_mce/classes/html/Schema.js
+++ b/js/tiny_mce/classes/html/Schema.js
@@ -1,879 +1,879 @@
-/**
- * Schema.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var mapCache = {}, makeMap = tinymce.makeMap, each = tinymce.each;
-
- function split(str, delim) {
- return str.split(delim || ',');
- };
-
- /**
- * Unpacks the specified lookup and string data it will also parse it into an object
- * map with sub object for it's children. This will later also include the attributes.
- */
- function unpack(lookup, data) {
- var key, elements = {};
-
- function replace(value) {
- return value.replace(/[A-Z]+/g, function(key) {
- return replace(lookup[key]);
- });
- };
-
- // Unpack lookup
- for (key in lookup) {
- if (lookup.hasOwnProperty(key))
- lookup[key] = replace(lookup[key]);
- }
-
- // Unpack and parse data into object map
- replace(data).replace(/#/g, '#text').replace(/(\w+)\[([^\]]+)\]\[([^\]]*)\]/g, function(str, name, attributes, children) {
- attributes = split(attributes, '|');
-
- elements[name] = {
- attributes : makeMap(attributes),
- attributesOrder : attributes,
- children : makeMap(children, '|', {'#comment' : {}})
- }
- });
-
- return elements;
- };
-
- /**
- * Returns the HTML5 schema and caches it in the mapCache.
- */
- function getHTML5() {
- var html5 = mapCache.html5;
-
- if (!html5) {
- html5 = mapCache.html5 = unpack({
- A : 'id|accesskey|class|dir|draggable|item|hidden|itemprop|role|spellcheck|style|subject|title|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
- B : '#|a|abbr|area|audio|b|bdo|br|button|canvas|cite|code|command|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|meta|' +
- 'meter|noscript|object|output|progress|q|ruby|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|var|video|wbr',
- C : '#|a|abbr|area|address|article|aside|audio|b|bdo|blockquote|br|button|canvas|cite|code|command|datalist|del|details|dfn|dialog|div|dl|em|embed|fieldset|' +
- 'figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|menu|meta|meter|nav|noscript|ol|object|output|' +
- 'p|pre|progress|q|ruby|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|ul|var|video'
- }, 'html[A|manifest][body|head]' +
- 'head[A][base|command|link|meta|noscript|script|style|title]' +
- 'title[A][#]' +
- 'base[A|href|target][]' +
- 'link[A|href|rel|media|type|sizes][]' +
- 'meta[A|http-equiv|name|content|charset][]' +
- 'style[A|type|media|scoped][#]' +
- 'script[A|charset|type|src|defer|async][#]' +
- 'noscript[A][C]' +
- 'body[A][C]' +
- 'section[A][C]' +
- 'nav[A][C]' +
- 'article[A][C]' +
- 'aside[A][C]' +
- 'h1[A][B]' +
- 'h2[A][B]' +
- 'h3[A][B]' +
- 'h4[A][B]' +
- 'h5[A][B]' +
- 'h6[A][B]' +
- 'hgroup[A][h1|h2|h3|h4|h5|h6]' +
- 'header[A][C]' +
- 'footer[A][C]' +
- 'address[A][C]' +
- 'p[A][B]' +
- 'br[A][]' +
- 'pre[A][B]' +
- 'dialog[A][dd|dt]' +
- 'blockquote[A|cite][C]' +
- 'ol[A|start|reversed][li]' +
- 'ul[A][li]' +
- 'li[A|value][C]' +
- 'dl[A][dd|dt]' +
- 'dt[A][B]' +
- 'dd[A][C]' +
- 'a[A|href|target|ping|rel|media|type][B]' +
- 'em[A][B]' +
- 'strong[A][B]' +
- 'small[A][B]' +
- 'cite[A][B]' +
- 'q[A|cite][B]' +
- 'dfn[A][B]' +
- 'abbr[A][B]' +
- 'code[A][B]' +
- 'var[A][B]' +
- 'samp[A][B]' +
- 'kbd[A][B]' +
- 'sub[A][B]' +
- 'sup[A][B]' +
- 'i[A][B]' +
- 'b[A][B]' +
- 'mark[A][B]' +
- 'progress[A|value|max][B]' +
- 'meter[A|value|min|max|low|high|optimum][B]' +
- 'time[A|datetime][B]' +
- 'ruby[A][B|rt|rp]' +
- 'rt[A][B]' +
- 'rp[A][B]' +
- 'bdo[A][B]' +
- 'span[A][B]' +
- 'ins[A|cite|datetime][B]' +
- 'del[A|cite|datetime][B]' +
- 'figure[A][C|legend|figcaption]' +
- 'figcaption[A][C]' +
- 'img[A|alt|src|height|width|usemap|ismap][]' +
- 'iframe[A|name|src|height|width|sandbox|seamless][]' +
- 'embed[A|src|height|width|type][]' +
- 'object[A|data|type|height|width|usemap|name|form|classid][param]' +
- 'param[A|name|value][]' +
- 'details[A|open][C|legend]' +
- 'command[A|type|label|icon|disabled|checked|radiogroup][]' +
- 'menu[A|type|label][C|li]' +
- 'legend[A][C|B]' +
- 'div[A][C]' +
- 'source[A|src|type|media][]' +
- 'audio[A|src|autobuffer|autoplay|loop|controls][source]' +
- 'video[A|src|autobuffer|autoplay|loop|controls|width|height|poster][source]' +
- 'hr[A][]' +
- 'form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]' +
- 'fieldset[A|disabled|form|name][C|legend]' +
- 'label[A|form|for][B]' +
- 'input[A|type|accept|alt|autocomplete|autofocus|checked|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|list|max|maxlength|min|' +
- 'multiple|pattern|placeholder|readonly|required|size|src|step|width|files|value|name][]' +
- 'button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|value|type][B]' +
- 'select[A|autofocus|disabled|form|multiple|name|size][option|optgroup]' +
- 'datalist[A][B|option]' +
- 'optgroup[A|disabled|label][option]' +
- 'option[A|disabled|selected|label|value][]' +
- 'textarea[A|autofocus|disabled|form|maxlength|name|placeholder|readonly|required|rows|cols|wrap][]' +
- 'keygen[A|autofocus|challenge|disabled|form|keytype|name][]' +
- 'output[A|for|form|name][B]' +
- 'canvas[A|width|height][]' +
- 'map[A|name][B|C]' +
- 'area[A|shape|coords|href|alt|target|media|rel|ping|type][]' +
- 'mathml[A][]' +
- 'svg[A][]' +
- 'table[A|border][caption|colgroup|thead|tfoot|tbody|tr]' +
- 'caption[A][C]' +
- 'colgroup[A|span][col]' +
- 'col[A|span][]' +
- 'thead[A][tr]' +
- 'tfoot[A][tr]' +
- 'tbody[A][tr]' +
- 'tr[A][th|td]' +
- 'th[A|headers|rowspan|colspan|scope][B]' +
- 'td[A|headers|rowspan|colspan][C]' +
- 'wbr[A][]'
- );
- }
-
- return html5;
- };
-
- /**
- * Returns the HTML4 schema and caches it in the mapCache.
- */
- function getHTML4() {
- var html4 = mapCache.html4;
-
- if (!html4) {
- // This is the XHTML 1.0 transitional elements with it's attributes and children packed to reduce it's size
- html4 = mapCache.html4 = unpack({
- Z : 'H|K|N|O|P',
- Y : 'X|form|R|Q',
- ZG : 'E|span|width|align|char|charoff|valign',
- X : 'p|T|div|U|W|isindex|fieldset|table',
- ZF : 'E|align|char|charoff|valign',
- W : 'pre|hr|blockquote|address|center|noframes',
- ZE : 'abbr|axis|headers|scope|rowspan|colspan|align|char|charoff|valign|nowrap|bgcolor|width|height',
- ZD : '[E][S]',
- U : 'ul|ol|dl|menu|dir',
- ZC : 'p|Y|div|U|W|table|br|span|bdo|object|applet|img|map|K|N|Q',
- T : 'h1|h2|h3|h4|h5|h6',
- ZB : 'X|S|Q',
- S : 'R|P',
- ZA : 'a|G|J|M|O|P',
- R : 'a|H|K|N|O',
- Q : 'noscript|P',
- P : 'ins|del|script',
- O : 'input|select|textarea|label|button',
- N : 'M|L',
- M : 'em|strong|dfn|code|q|samp|kbd|var|cite|abbr|acronym',
- L : 'sub|sup',
- K : 'J|I',
- J : 'tt|i|b|u|s|strike',
- I : 'big|small|font|basefont',
- H : 'G|F',
- G : 'br|span|bdo',
- F : 'object|applet|img|map|iframe',
- E : 'A|B|C',
- D : 'accesskey|tabindex|onfocus|onblur',
- C : 'onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
- B : 'lang|xml:lang|dir',
- A : 'id|class|style|title'
- }, 'script[id|charset|type|language|src|defer|xml:space][]' +
- 'style[B|id|type|media|title|xml:space][]' +
- 'object[E|declare|classid|codebase|data|type|codetype|archive|standby|width|height|usemap|name|tabindex|align|border|hspace|vspace][#|param|Y]' +
- 'param[id|name|value|valuetype|type][]' +
- 'p[E|align][#|S]' +
- 'a[E|D|charset|type|name|href|hreflang|rel|rev|shape|coords|target][#|Z]' +
- 'br[A|clear][]' +
- 'span[E][#|S]' +
- 'bdo[A|C|B][#|S]' +
- 'applet[A|codebase|archive|code|object|alt|name|width|height|align|hspace|vspace][#|param|Y]' +
- 'h1[E|align][#|S]' +
- 'img[E|src|alt|name|longdesc|width|height|usemap|ismap|align|border|hspace|vspace][]' +
- 'map[B|C|A|name][X|form|Q|area]' +
- 'h2[E|align][#|S]' +
- 'iframe[A|longdesc|name|src|frameborder|marginwidth|marginheight|scrolling|align|width|height][#|Y]' +
- 'h3[E|align][#|S]' +
- 'tt[E][#|S]' +
- 'i[E][#|S]' +
- 'b[E][#|S]' +
- 'u[E][#|S]' +
- 's[E][#|S]' +
- 'strike[E][#|S]' +
- 'big[E][#|S]' +
- 'small[E][#|S]' +
- 'font[A|B|size|color|face][#|S]' +
- 'basefont[id|size|color|face][]' +
- 'em[E][#|S]' +
- 'strong[E][#|S]' +
- 'dfn[E][#|S]' +
- 'code[E][#|S]' +
- 'q[E|cite][#|S]' +
- 'samp[E][#|S]' +
- 'kbd[E][#|S]' +
- 'var[E][#|S]' +
- 'cite[E][#|S]' +
- 'abbr[E][#|S]' +
- 'acronym[E][#|S]' +
- 'sub[E][#|S]' +
- 'sup[E][#|S]' +
- 'input[E|D|type|name|value|checked|disabled|readonly|size|maxlength|src|alt|usemap|onselect|onchange|accept|align][]' +
- 'select[E|name|size|multiple|disabled|tabindex|onfocus|onblur|onchange][optgroup|option]' +
- 'optgroup[E|disabled|label][option]' +
- 'option[E|selected|disabled|label|value][]' +
- 'textarea[E|D|name|rows|cols|disabled|readonly|onselect|onchange][]' +
- 'label[E|for|accesskey|onfocus|onblur][#|S]' +
- 'button[E|D|name|value|type|disabled][#|p|T|div|U|W|table|G|object|applet|img|map|K|N|Q]' +
- 'h4[E|align][#|S]' +
- 'ins[E|cite|datetime][#|Y]' +
- 'h5[E|align][#|S]' +
- 'del[E|cite|datetime][#|Y]' +
- 'h6[E|align][#|S]' +
- 'div[E|align][#|Y]' +
- 'ul[E|type|compact][li]' +
- 'li[E|type|value][#|Y]' +
- 'ol[E|type|compact|start][li]' +
- 'dl[E|compact][dt|dd]' +
- 'dt[E][#|S]' +
- 'dd[E][#|Y]' +
- 'menu[E|compact][li]' +
- 'dir[E|compact][li]' +
- 'pre[E|width|xml:space][#|ZA]' +
- 'hr[E|align|noshade|size|width][]' +
- 'blockquote[E|cite][#|Y]' +
- 'address[E][#|S|p]' +
- 'center[E][#|Y]' +
- 'noframes[E][#|Y]' +
- 'isindex[A|B|prompt][]' +
- 'fieldset[E][#|legend|Y]' +
- 'legend[E|accesskey|align][#|S]' +
- 'table[E|summary|width|border|frame|rules|cellspacing|cellpadding|align|bgcolor][caption|col|colgroup|thead|tfoot|tbody|tr]' +
- 'caption[E|align][#|S]' +
- 'col[ZG][]' +
- 'colgroup[ZG][col]' +
- 'thead[ZF][tr]' +
- 'tr[ZF|bgcolor][th|td]' +
- 'th[E|ZE][#|Y]' +
- 'form[E|action|method|name|enctype|onsubmit|onreset|accept|accept-charset|target][#|X|R|Q]' +
- 'noscript[E][#|Y]' +
- 'td[E|ZE][#|Y]' +
- 'tfoot[ZF][tr]' +
- 'tbody[ZF][tr]' +
- 'area[E|D|shape|coords|href|nohref|alt|target][]' +
- 'base[id|href|target][]' +
- 'body[E|onload|onunload|background|bgcolor|text|link|vlink|alink][#|Y]'
- );
- }
-
- return html4;
- };
-
- /**
- * Schema validator class.
- *
- * @class tinymce.html.Schema
- * @example
- * if (tinymce.activeEditor.schema.isValidChild('p', 'span'))
- * alert('span is valid child of p.');
- *
- * if (tinymce.activeEditor.schema.getElementRule('p'))
- * alert('P is a valid element.');
- *
- * @class tinymce.html.Schema
- * @version 3.4
- */
-
- /**
- * Constructs a new Schema instance.
- *
- * @constructor
- * @method Schema
- * @param {Object} settings Name/value settings object.
- */
- tinymce.html.Schema = function(settings) {
- var self = this, elements = {}, children = {}, patternElements = [], validStyles, schemaItems;
- var whiteSpaceElementsMap, selfClosingElementsMap, shortEndedElementsMap, boolAttrMap, blockElementsMap, nonEmptyElementsMap, customElementsMap = {};
-
- // Creates an lookup table map object for the specified option or the default value
- function createLookupTable(option, default_value, extend) {
- var value = settings[option];
-
- if (!value) {
- // Get cached default map or make it if needed
- value = mapCache[option];
-
- if (!value) {
- value = makeMap(default_value, ' ', makeMap(default_value.toUpperCase(), ' '));
- value = tinymce.extend(value, extend);
-
- mapCache[option] = value;
- }
- } else {
- // Create custom map
- value = makeMap(value, ',', makeMap(value.toUpperCase(), ' '));
- }
-
- return value;
- };
-
- settings = settings || {};
- schemaItems = settings.schema == "html5" ? getHTML5() : getHTML4();
-
- // Allow all elements and attributes if verify_html is set to false
- if (settings.verify_html === false)
- settings.valid_elements = '*[*]';
-
- // Build styles list
- if (settings.valid_styles) {
- validStyles = {};
-
- // Convert styles into a rule list
- each(settings.valid_styles, function(value, key) {
- validStyles[key] = tinymce.explode(value);
- });
- }
-
- // Setup map objects
- whiteSpaceElementsMap = createLookupTable('whitespace_elements', 'pre script noscript style textarea');
- selfClosingElementsMap = createLookupTable('self_closing_elements', 'colgroup dd dt li option p td tfoot th thead tr');
- shortEndedElementsMap = createLookupTable('short_ended_elements', 'area base basefont br col frame hr img input isindex link meta param embed source wbr');
- boolAttrMap = createLookupTable('boolean_attributes', 'checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls');
- nonEmptyElementsMap = createLookupTable('non_empty_elements', 'td th iframe video audio object script', shortEndedElementsMap);
- textBlockElementsMap = createLookupTable('text_block_elements', 'h1 h2 h3 h4 h5 h6 p div address pre form ' +
- 'blockquote center dir fieldset header footer article section hgroup aside nav figure');
- blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' +
- 'th tr td li ol ul caption dl dt dd noscript menu isindex samp option datalist select optgroup', textBlockElementsMap);
-
- // Converts a wildcard expression string to a regexp for example *a will become /.*a/.
- function patternToRegExp(str) {
- return new RegExp('^' + str.replace(/([?+*])/g, '.$1') + '$');
- };
-
- // Parses the specified valid_elements string and adds to the current rules
- // This function is a bit hard to read since it's heavily optimized for speed
- function addValidElements(valid_elements) {
- var ei, el, ai, al, yl, matches, element, attr, attrData, elementName, attrName, attrType, attributes, attributesOrder,
- prefix, outputName, globalAttributes, globalAttributesOrder, transElement, key, childKey, value,
- elementRuleRegExp = /^([#+\-])?([^\[\/]+)(?:\/([^\[]+))?(?:\[([^\]]+)\])?$/,
- attrRuleRegExp = /^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,
- hasPatternsRegExp = /[*?+]/;
-
- if (valid_elements) {
- // Split valid elements into an array with rules
- valid_elements = split(valid_elements);
-
- if (elements['@']) {
- globalAttributes = elements['@'].attributes;
- globalAttributesOrder = elements['@'].attributesOrder;
- }
-
- // Loop all rules
- for (ei = 0, el = valid_elements.length; ei < el; ei++) {
- // Parse element rule
- matches = elementRuleRegExp.exec(valid_elements[ei]);
- if (matches) {
- // Setup local names for matches
- prefix = matches[1];
- elementName = matches[2];
- outputName = matches[3];
- attrData = matches[4];
-
- // Create new attributes and attributesOrder
- attributes = {};
- attributesOrder = [];
-
- // Create the new element
- element = {
- attributes : attributes,
- attributesOrder : attributesOrder
- };
-
- // Padd empty elements prefix
- if (prefix === '#')
- element.paddEmpty = true;
-
- // Remove empty elements prefix
- if (prefix === '-')
- element.removeEmpty = true;
-
- // Copy attributes from global rule into current rule
- if (globalAttributes) {
- for (key in globalAttributes)
- attributes[key] = globalAttributes[key];
-
- attributesOrder.push.apply(attributesOrder, globalAttributesOrder);
- }
-
- // Attributes defined
- if (attrData) {
- attrData = split(attrData, '|');
- for (ai = 0, al = attrData.length; ai < al; ai++) {
- matches = attrRuleRegExp.exec(attrData[ai]);
- if (matches) {
- attr = {};
- attrType = matches[1];
- attrName = matches[2].replace(/::/g, ':');
- prefix = matches[3];
- value = matches[4];
-
- // Required
- if (attrType === '!') {
- element.attributesRequired = element.attributesRequired || [];
- element.attributesRequired.push(attrName);
- attr.required = true;
- }
-
- // Denied from global
- if (attrType === '-') {
- delete attributes[attrName];
- attributesOrder.splice(tinymce.inArray(attributesOrder, attrName), 1);
- continue;
- }
-
- // Default value
- if (prefix) {
- // Default value
- if (prefix === '=') {
- element.attributesDefault = element.attributesDefault || [];
- element.attributesDefault.push({name: attrName, value: value});
- attr.defaultValue = value;
- }
-
- // Forced value
- if (prefix === ':') {
- element.attributesForced = element.attributesForced || [];
- element.attributesForced.push({name: attrName, value: value});
- attr.forcedValue = value;
- }
-
- // Required values
- if (prefix === '<')
- attr.validValues = makeMap(value, '?');
- }
-
- // Check for attribute patterns
- if (hasPatternsRegExp.test(attrName)) {
- element.attributePatterns = element.attributePatterns || [];
- attr.pattern = patternToRegExp(attrName);
- element.attributePatterns.push(attr);
- } else {
- // Add attribute to order list if it doesn't already exist
- if (!attributes[attrName])
- attributesOrder.push(attrName);
-
- attributes[attrName] = attr;
- }
- }
- }
- }
-
- // Global rule, store away these for later usage
- if (!globalAttributes && elementName == '@') {
- globalAttributes = attributes;
- globalAttributesOrder = attributesOrder;
- }
-
- // Handle substitute elements such as b/strong
- if (outputName) {
- element.outputName = elementName;
- elements[outputName] = element;
- }
-
- // Add pattern or exact element
- if (hasPatternsRegExp.test(elementName)) {
- element.pattern = patternToRegExp(elementName);
- patternElements.push(element);
- } else
- elements[elementName] = element;
- }
- }
- }
- };
-
- function setValidElements(valid_elements) {
- elements = {};
- patternElements = [];
-
- addValidElements(valid_elements);
-
- each(schemaItems, function(element, name) {
- children[name] = element.children;
- });
- };
-
- // Adds custom non HTML elements to the schema
- function addCustomElements(custom_elements) {
- var customElementRegExp = /^(~)?(.+)$/;
-
- if (custom_elements) {
- each(split(custom_elements), function(rule) {
- var matches = customElementRegExp.exec(rule),
- inline = matches[1] === '~',
- cloneName = inline ? 'span' : 'div',
- name = matches[2];
-
- children[name] = children[cloneName];
- customElementsMap[name] = cloneName;
-
- // If it's not marked as inline then add it to valid block elements
- if (!inline) {
- blockElementsMap[name.toUpperCase()] = {};
- blockElementsMap[name] = {};
- }
-
- // Add elements clone if needed
- if (!elements[name]) {
- elements[name] = elements[cloneName];
- }
-
- // Add custom elements at span/div positions
- each(children, function(element, child) {
- if (element[cloneName])
- element[name] = element[cloneName];
- });
- });
- }
- };
-
- // Adds valid children to the schema object
- function addValidChildren(valid_children) {
- var childRuleRegExp = /^([+\-]?)(\w+)\[([^\]]+)\]$/;
-
- if (valid_children) {
- each(split(valid_children), function(rule) {
- var matches = childRuleRegExp.exec(rule), parent, prefix;
-
- if (matches) {
- prefix = matches[1];
-
- // Add/remove items from default
- if (prefix)
- parent = children[matches[2]];
- else
- parent = children[matches[2]] = {'#comment' : {}};
-
- parent = children[matches[2]];
-
- each(split(matches[3], '|'), function(child) {
- if (prefix === '-')
- delete parent[child];
- else
- parent[child] = {};
- });
- }
- });
- }
- };
-
- function getElementRule(name) {
- var element = elements[name], i;
-
- // Exact match found
- if (element)
- return element;
-
- // No exact match then try the patterns
- i = patternElements.length;
- while (i--) {
- element = patternElements[i];
-
- if (element.pattern.test(name))
- return element;
- }
- };
-
- if (!settings.valid_elements) {
- // No valid elements defined then clone the elements from the schema spec
- each(schemaItems, function(element, name) {
- elements[name] = {
- attributes : element.attributes,
- attributesOrder : element.attributesOrder
- };
-
- children[name] = element.children;
- });
-
- // Switch these on HTML4
- if (settings.schema != "html5") {
- each(split('strong/b,em/i'), function(item) {
- item = split(item, '/');
- elements[item[1]].outputName = item[0];
- });
- }
-
- // Add default alt attribute for images
- elements.img.attributesDefault = [{name: 'alt', value: ''}];
-
- // Remove these if they are empty by default
- each(split('ol,ul,sub,sup,blockquote,span,font,a,table,tbody,tr,strong,em,b,i'), function(name) {
- if (elements[name]) {
- elements[name].removeEmpty = true;
- }
- });
-
- // Padd these by default
- each(split('p,h1,h2,h3,h4,h5,h6,th,td,pre,div,address,caption'), function(name) {
- elements[name].paddEmpty = true;
- });
- } else
- setValidElements(settings.valid_elements);
-
- addCustomElements(settings.custom_elements);
- addValidChildren(settings.valid_children);
- addValidElements(settings.extended_valid_elements);
-
- // Todo: Remove this when we fix list handling to be valid
- addValidChildren('+ol[ul|ol],+ul[ul|ol]');
-
- // Delete invalid elements
- if (settings.invalid_elements) {
- tinymce.each(tinymce.explode(settings.invalid_elements), function(item) {
- if (elements[item])
- delete elements[item];
- });
- }
-
- // If the user didn't allow span only allow internal spans
- if (!getElementRule('span'))
- addValidElements('span[!data-mce-type|*]');
-
- /**
- * Name/value map object with valid parents and children to those parents.
- *
- * @example
- * children = {
- * div:{p:{}, h1:{}}
- * };
- * @field children
- * @type {Object}
- */
- self.children = children;
-
- /**
- * Name/value map object with valid styles for each element.
- *
- * @field styles
- * @type {Object}
- */
- self.styles = validStyles;
-
- /**
- * Returns a map with boolean attributes.
- *
- * @method getBoolAttrs
- * @return {Object} Name/value lookup map for boolean attributes.
- */
- self.getBoolAttrs = function() {
- return boolAttrMap;
- };
-
- /**
- * Returns a map with block elements.
- *
- * @method getBlockElements
- * @return {Object} Name/value lookup map for block elements.
- */
- self.getBlockElements = function() {
- return blockElementsMap;
- };
-
- /**
- * Returns a map with text block elements. Such as: p,h1-h6,div,address
- *
- * @method getTextBlockElements
- * @return {Object} Name/value lookup map for block elements.
- */
- self.getTextBlockElements = function() {
- return textBlockElementsMap;
- };
-
- /**
- * Returns a map with short ended elements such as BR or IMG.
- *
- * @method getShortEndedElements
- * @return {Object} Name/value lookup map for short ended elements.
- */
- self.getShortEndedElements = function() {
- return shortEndedElementsMap;
- };
-
- /**
- * Returns a map with self closing tags such as
.
- *
- * @method getSelfClosingElements
- * @return {Object} Name/value lookup map for self closing tags elements.
- */
- self.getSelfClosingElements = function() {
- return selfClosingElementsMap;
- };
-
- /**
- * Returns a map with elements that should be treated as contents regardless if it has text
- * content in them or not such as TD, VIDEO or IMG.
- *
- * @method getNonEmptyElements
- * @return {Object} Name/value lookup map for non empty elements.
- */
- self.getNonEmptyElements = function() {
- return nonEmptyElementsMap;
- };
-
- /**
- * Returns a map with elements where white space is to be preserved like PRE or SCRIPT.
- *
- * @method getWhiteSpaceElements
- * @return {Object} Name/value lookup map for white space elements.
- */
- self.getWhiteSpaceElements = function() {
- return whiteSpaceElementsMap;
- };
-
- /**
- * Returns true/false if the specified element and it's child is valid or not
- * according to the schema.
- *
- * @method isValidChild
- * @param {String} name Element name to check for.
- * @param {String} child Element child to verify.
- * @return {Boolean} True/false if the element is a valid child of the specified parent.
- */
- self.isValidChild = function(name, child) {
- var parent = children[name];
-
- return !!(parent && parent[child]);
- };
-
- /**
- * Returns true/false if the specified element name and optional attribute is
- * valid according to the schema.
- *
- * @method isValid
- * @param {String} name Name of element to check.
- * @param {String} attr Optional attribute name to check for.
- * @return {Boolean} True/false if the element and attribute is valid.
- */
- self.isValid = function(name, attr) {
- var attrPatterns, i, rule = getElementRule(name);
-
- // Check if it's a valid element
- if (rule) {
- if (attr) {
- // Check if attribute name exists
- if (rule.attributes[attr]) {
- return true;
- }
-
- // Check if attribute matches a regexp pattern
- attrPatterns = rule.attributePatterns;
- if (attrPatterns) {
- i = attrPatterns.length;
- while (i--) {
- if (attrPatterns[i].pattern.test(name)) {
- return true;
- }
- }
- }
- } else {
- return true;
- }
- }
-
- // No match
- return false;
- };
-
- /**
- * Returns true/false if the specified element is valid or not
- * according to the schema.
- *
- * @method getElementRule
- * @param {String} name Element name to check for.
- * @return {Object} Element object or undefined if the element isn't valid.
- */
- self.getElementRule = getElementRule;
-
- /**
- * Returns an map object of all custom elements.
- *
- * @method getCustomElements
- * @return {Object} Name/value map object of all custom elements.
- */
- self.getCustomElements = function() {
- return customElementsMap;
- };
-
- /**
- * Parses a valid elements string and adds it to the schema. The valid elements format is for example "element[attr=default|otherattr]".
- * Existing rules will be replaced with the ones specified, so this extends the schema.
- *
- * @method addValidElements
- * @param {String} valid_elements String in the valid elements format to be parsed.
- */
- self.addValidElements = addValidElements;
-
- /**
- * Parses a valid elements string and sets it to the schema. The valid elements format is for example "element[attr=default|otherattr]".
- * Existing rules will be replaced with the ones specified, so this extends the schema.
- *
- * @method setValidElements
- * @param {String} valid_elements String in the valid elements format to be parsed.
- */
- self.setValidElements = setValidElements;
-
- /**
- * Adds custom non HTML elements to the schema.
- *
- * @method addCustomElements
- * @param {String} custom_elements Comma separated list of custom elements to add.
- */
- self.addCustomElements = addCustomElements;
-
- /**
- * Parses a valid children string and adds them to the schema structure. The valid children format is for example: "element[child1|child2]".
- *
- * @method addValidChildren
- * @param {String} valid_children Valid children elements string to parse
- */
- self.addValidChildren = addValidChildren;
-
- self.elements = elements;
- };
-})(tinymce);
+/**
+ * Schema.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var mapCache = {}, makeMap = tinymce.makeMap, each = tinymce.each;
+
+ function split(str, delim) {
+ return str.split(delim || ',');
+ };
+
+ /**
+ * Unpacks the specified lookup and string data it will also parse it into an object
+ * map with sub object for it's children. This will later also include the attributes.
+ */
+ function unpack(lookup, data) {
+ var key, elements = {};
+
+ function replace(value) {
+ return value.replace(/[A-Z]+/g, function(key) {
+ return replace(lookup[key]);
+ });
+ };
+
+ // Unpack lookup
+ for (key in lookup) {
+ if (lookup.hasOwnProperty(key))
+ lookup[key] = replace(lookup[key]);
+ }
+
+ // Unpack and parse data into object map
+ replace(data).replace(/#/g, '#text').replace(/(\w+)\[([^\]]+)\]\[([^\]]*)\]/g, function(str, name, attributes, children) {
+ attributes = split(attributes, '|');
+
+ elements[name] = {
+ attributes : makeMap(attributes),
+ attributesOrder : attributes,
+ children : makeMap(children, '|', {'#comment' : {}})
+ }
+ });
+
+ return elements;
+ };
+
+ /**
+ * Returns the HTML5 schema and caches it in the mapCache.
+ */
+ function getHTML5() {
+ var html5 = mapCache.html5;
+
+ if (!html5) {
+ html5 = mapCache.html5 = unpack({
+ A : 'id|accesskey|class|dir|draggable|item|hidden|itemprop|role|spellcheck|style|subject|title|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
+ B : '#|a|abbr|area|audio|b|bdo|br|button|canvas|cite|code|command|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|meta|' +
+ 'meter|noscript|object|output|progress|q|ruby|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|var|video|wbr',
+ C : '#|a|abbr|area|address|article|aside|audio|b|bdo|blockquote|br|button|canvas|cite|code|command|datalist|del|details|dfn|dialog|div|dl|em|embed|fieldset|' +
+ 'figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|menu|meta|meter|nav|noscript|ol|object|output|' +
+ 'p|pre|progress|q|ruby|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|ul|var|video'
+ }, 'html[A|manifest][body|head]' +
+ 'head[A][base|command|link|meta|noscript|script|style|title]' +
+ 'title[A][#]' +
+ 'base[A|href|target][]' +
+ 'link[A|href|rel|media|type|sizes][]' +
+ 'meta[A|http-equiv|name|content|charset][]' +
+ 'style[A|type|media|scoped][#]' +
+ 'script[A|charset|type|src|defer|async][#]' +
+ 'noscript[A][C]' +
+ 'body[A][C]' +
+ 'section[A][C]' +
+ 'nav[A][C]' +
+ 'article[A][C]' +
+ 'aside[A][C]' +
+ 'h1[A][B]' +
+ 'h2[A][B]' +
+ 'h3[A][B]' +
+ 'h4[A][B]' +
+ 'h5[A][B]' +
+ 'h6[A][B]' +
+ 'hgroup[A][h1|h2|h3|h4|h5|h6]' +
+ 'header[A][C]' +
+ 'footer[A][C]' +
+ 'address[A][C]' +
+ 'p[A][B]' +
+ 'br[A][]' +
+ 'pre[A][B]' +
+ 'dialog[A][dd|dt]' +
+ 'blockquote[A|cite][C]' +
+ 'ol[A|start|reversed][li]' +
+ 'ul[A][li]' +
+ 'li[A|value][C]' +
+ 'dl[A][dd|dt]' +
+ 'dt[A][B]' +
+ 'dd[A][C]' +
+ 'a[A|href|target|ping|rel|media|type][B]' +
+ 'em[A][B]' +
+ 'strong[A][B]' +
+ 'small[A][B]' +
+ 'cite[A][B]' +
+ 'q[A|cite][B]' +
+ 'dfn[A][B]' +
+ 'abbr[A][B]' +
+ 'code[A][B]' +
+ 'var[A][B]' +
+ 'samp[A][B]' +
+ 'kbd[A][B]' +
+ 'sub[A][B]' +
+ 'sup[A][B]' +
+ 'i[A][B]' +
+ 'b[A][B]' +
+ 'mark[A][B]' +
+ 'progress[A|value|max][B]' +
+ 'meter[A|value|min|max|low|high|optimum][B]' +
+ 'time[A|datetime][B]' +
+ 'ruby[A][B|rt|rp]' +
+ 'rt[A][B]' +
+ 'rp[A][B]' +
+ 'bdo[A][B]' +
+ 'span[A][B]' +
+ 'ins[A|cite|datetime][B]' +
+ 'del[A|cite|datetime][B]' +
+ 'figure[A][C|legend|figcaption]' +
+ 'figcaption[A][C]' +
+ 'img[A|alt|src|height|width|usemap|ismap][]' +
+ 'iframe[A|name|src|height|width|sandbox|seamless][]' +
+ 'embed[A|src|height|width|type][]' +
+ 'object[A|data|type|height|width|usemap|name|form|classid][param]' +
+ 'param[A|name|value][]' +
+ 'details[A|open][C|legend]' +
+ 'command[A|type|label|icon|disabled|checked|radiogroup][]' +
+ 'menu[A|type|label][C|li]' +
+ 'legend[A][C|B]' +
+ 'div[A][C]' +
+ 'source[A|src|type|media][]' +
+ 'audio[A|src|autobuffer|autoplay|loop|controls][source]' +
+ 'video[A|src|autobuffer|autoplay|loop|controls|width|height|poster][source]' +
+ 'hr[A][]' +
+ 'form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]' +
+ 'fieldset[A|disabled|form|name][C|legend]' +
+ 'label[A|form|for][B]' +
+ 'input[A|type|accept|alt|autocomplete|autofocus|checked|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|list|max|maxlength|min|' +
+ 'multiple|pattern|placeholder|readonly|required|size|src|step|width|files|value|name][]' +
+ 'button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|value|type][B]' +
+ 'select[A|autofocus|disabled|form|multiple|name|size][option|optgroup]' +
+ 'datalist[A][B|option]' +
+ 'optgroup[A|disabled|label][option]' +
+ 'option[A|disabled|selected|label|value][]' +
+ 'textarea[A|autofocus|disabled|form|maxlength|name|placeholder|readonly|required|rows|cols|wrap][]' +
+ 'keygen[A|autofocus|challenge|disabled|form|keytype|name][]' +
+ 'output[A|for|form|name][B]' +
+ 'canvas[A|width|height][]' +
+ 'map[A|name][B|C]' +
+ 'area[A|shape|coords|href|alt|target|media|rel|ping|type][]' +
+ 'mathml[A][]' +
+ 'svg[A][]' +
+ 'table[A|border][caption|colgroup|thead|tfoot|tbody|tr]' +
+ 'caption[A][C]' +
+ 'colgroup[A|span][col]' +
+ 'col[A|span][]' +
+ 'thead[A][tr]' +
+ 'tfoot[A][tr]' +
+ 'tbody[A][tr]' +
+ 'tr[A][th|td]' +
+ 'th[A|headers|rowspan|colspan|scope][B]' +
+ 'td[A|headers|rowspan|colspan][C]' +
+ 'wbr[A][]'
+ );
+ }
+
+ return html5;
+ };
+
+ /**
+ * Returns the HTML4 schema and caches it in the mapCache.
+ */
+ function getHTML4() {
+ var html4 = mapCache.html4;
+
+ if (!html4) {
+ // This is the XHTML 1.0 transitional elements with it's attributes and children packed to reduce it's size
+ html4 = mapCache.html4 = unpack({
+ Z : 'H|K|N|O|P',
+ Y : 'X|form|R|Q',
+ ZG : 'E|span|width|align|char|charoff|valign',
+ X : 'p|T|div|U|W|isindex|fieldset|table',
+ ZF : 'E|align|char|charoff|valign',
+ W : 'pre|hr|blockquote|address|center|noframes',
+ ZE : 'abbr|axis|headers|scope|rowspan|colspan|align|char|charoff|valign|nowrap|bgcolor|width|height',
+ ZD : '[E][S]',
+ U : 'ul|ol|dl|menu|dir',
+ ZC : 'p|Y|div|U|W|table|br|span|bdo|object|applet|img|map|K|N|Q',
+ T : 'h1|h2|h3|h4|h5|h6',
+ ZB : 'X|S|Q',
+ S : 'R|P',
+ ZA : 'a|G|J|M|O|P',
+ R : 'a|H|K|N|O',
+ Q : 'noscript|P',
+ P : 'ins|del|script',
+ O : 'input|select|textarea|label|button',
+ N : 'M|L',
+ M : 'em|strong|dfn|code|q|samp|kbd|var|cite|abbr|acronym',
+ L : 'sub|sup',
+ K : 'J|I',
+ J : 'tt|i|b|u|s|strike',
+ I : 'big|small|font|basefont',
+ H : 'G|F',
+ G : 'br|span|bdo',
+ F : 'object|applet|img|map|iframe',
+ E : 'A|B|C',
+ D : 'accesskey|tabindex|onfocus|onblur',
+ C : 'onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
+ B : 'lang|xml:lang|dir',
+ A : 'id|class|style|title'
+ }, 'script[id|charset|type|language|src|defer|xml:space][]' +
+ 'style[B|id|type|media|title|xml:space][]' +
+ 'object[E|declare|classid|codebase|data|type|codetype|archive|standby|width|height|usemap|name|tabindex|align|border|hspace|vspace][#|param|Y]' +
+ 'param[id|name|value|valuetype|type][]' +
+ 'p[E|align][#|S]' +
+ 'a[E|D|charset|type|name|href|hreflang|rel|rev|shape|coords|target][#|Z]' +
+ 'br[A|clear][]' +
+ 'span[E][#|S]' +
+ 'bdo[A|C|B][#|S]' +
+ 'applet[A|codebase|archive|code|object|alt|name|width|height|align|hspace|vspace][#|param|Y]' +
+ 'h1[E|align][#|S]' +
+ 'img[E|src|alt|name|longdesc|width|height|usemap|ismap|align|border|hspace|vspace][]' +
+ 'map[B|C|A|name][X|form|Q|area]' +
+ 'h2[E|align][#|S]' +
+ 'iframe[A|longdesc|name|src|frameborder|marginwidth|marginheight|scrolling|align|width|height][#|Y]' +
+ 'h3[E|align][#|S]' +
+ 'tt[E][#|S]' +
+ 'i[E][#|S]' +
+ 'b[E][#|S]' +
+ 'u[E][#|S]' +
+ 's[E][#|S]' +
+ 'strike[E][#|S]' +
+ 'big[E][#|S]' +
+ 'small[E][#|S]' +
+ 'font[A|B|size|color|face][#|S]' +
+ 'basefont[id|size|color|face][]' +
+ 'em[E][#|S]' +
+ 'strong[E][#|S]' +
+ 'dfn[E][#|S]' +
+ 'code[E][#|S]' +
+ 'q[E|cite][#|S]' +
+ 'samp[E][#|S]' +
+ 'kbd[E][#|S]' +
+ 'var[E][#|S]' +
+ 'cite[E][#|S]' +
+ 'abbr[E][#|S]' +
+ 'acronym[E][#|S]' +
+ 'sub[E][#|S]' +
+ 'sup[E][#|S]' +
+ 'input[E|D|type|name|value|checked|disabled|readonly|size|maxlength|src|alt|usemap|onselect|onchange|accept|align][]' +
+ 'select[E|name|size|multiple|disabled|tabindex|onfocus|onblur|onchange][optgroup|option]' +
+ 'optgroup[E|disabled|label][option]' +
+ 'option[E|selected|disabled|label|value][]' +
+ 'textarea[E|D|name|rows|cols|disabled|readonly|onselect|onchange][]' +
+ 'label[E|for|accesskey|onfocus|onblur][#|S]' +
+ 'button[E|D|name|value|type|disabled][#|p|T|div|U|W|table|G|object|applet|img|map|K|N|Q]' +
+ 'h4[E|align][#|S]' +
+ 'ins[E|cite|datetime][#|Y]' +
+ 'h5[E|align][#|S]' +
+ 'del[E|cite|datetime][#|Y]' +
+ 'h6[E|align][#|S]' +
+ 'div[E|align][#|Y]' +
+ 'ul[E|type|compact][li]' +
+ 'li[E|type|value][#|Y]' +
+ 'ol[E|type|compact|start][li]' +
+ 'dl[E|compact][dt|dd]' +
+ 'dt[E][#|S]' +
+ 'dd[E][#|Y]' +
+ 'menu[E|compact][li]' +
+ 'dir[E|compact][li]' +
+ 'pre[E|width|xml:space][#|ZA]' +
+ 'hr[E|align|noshade|size|width][]' +
+ 'blockquote[E|cite][#|Y]' +
+ 'address[E][#|S|p]' +
+ 'center[E][#|Y]' +
+ 'noframes[E][#|Y]' +
+ 'isindex[A|B|prompt][]' +
+ 'fieldset[E][#|legend|Y]' +
+ 'legend[E|accesskey|align][#|S]' +
+ 'table[E|summary|width|border|frame|rules|cellspacing|cellpadding|align|bgcolor][caption|col|colgroup|thead|tfoot|tbody|tr]' +
+ 'caption[E|align][#|S]' +
+ 'col[ZG][]' +
+ 'colgroup[ZG][col]' +
+ 'thead[ZF][tr]' +
+ 'tr[ZF|bgcolor][th|td]' +
+ 'th[E|ZE][#|Y]' +
+ 'form[E|action|method|name|enctype|onsubmit|onreset|accept|accept-charset|target][#|X|R|Q]' +
+ 'noscript[E][#|Y]' +
+ 'td[E|ZE][#|Y]' +
+ 'tfoot[ZF][tr]' +
+ 'tbody[ZF][tr]' +
+ 'area[E|D|shape|coords|href|nohref|alt|target][]' +
+ 'base[id|href|target][]' +
+ 'body[E|onload|onunload|background|bgcolor|text|link|vlink|alink][#|Y]'
+ );
+ }
+
+ return html4;
+ };
+
+ /**
+ * Schema validator class.
+ *
+ * @class tinymce.html.Schema
+ * @example
+ * if (tinymce.activeEditor.schema.isValidChild('p', 'span'))
+ * alert('span is valid child of p.');
+ *
+ * if (tinymce.activeEditor.schema.getElementRule('p'))
+ * alert('P is a valid element.');
+ *
+ * @class tinymce.html.Schema
+ * @version 3.4
+ */
+
+ /**
+ * Constructs a new Schema instance.
+ *
+ * @constructor
+ * @method Schema
+ * @param {Object} settings Name/value settings object.
+ */
+ tinymce.html.Schema = function(settings) {
+ var self = this, elements = {}, children = {}, patternElements = [], validStyles, schemaItems;
+ var whiteSpaceElementsMap, selfClosingElementsMap, shortEndedElementsMap, boolAttrMap, blockElementsMap, nonEmptyElementsMap, customElementsMap = {};
+
+ // Creates an lookup table map object for the specified option or the default value
+ function createLookupTable(option, default_value, extend) {
+ var value = settings[option];
+
+ if (!value) {
+ // Get cached default map or make it if needed
+ value = mapCache[option];
+
+ if (!value) {
+ value = makeMap(default_value, ' ', makeMap(default_value.toUpperCase(), ' '));
+ value = tinymce.extend(value, extend);
+
+ mapCache[option] = value;
+ }
+ } else {
+ // Create custom map
+ value = makeMap(value, ',', makeMap(value.toUpperCase(), ' '));
+ }
+
+ return value;
+ };
+
+ settings = settings || {};
+ schemaItems = settings.schema == "html5" ? getHTML5() : getHTML4();
+
+ // Allow all elements and attributes if verify_html is set to false
+ if (settings.verify_html === false)
+ settings.valid_elements = '*[*]';
+
+ // Build styles list
+ if (settings.valid_styles) {
+ validStyles = {};
+
+ // Convert styles into a rule list
+ each(settings.valid_styles, function(value, key) {
+ validStyles[key] = tinymce.explode(value);
+ });
+ }
+
+ // Setup map objects
+ whiteSpaceElementsMap = createLookupTable('whitespace_elements', 'pre script noscript style textarea');
+ selfClosingElementsMap = createLookupTable('self_closing_elements', 'colgroup dd dt li option p td tfoot th thead tr');
+ shortEndedElementsMap = createLookupTable('short_ended_elements', 'area base basefont br col frame hr img input isindex link meta param embed source wbr');
+ boolAttrMap = createLookupTable('boolean_attributes', 'checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls');
+ nonEmptyElementsMap = createLookupTable('non_empty_elements', 'td th iframe video audio object script', shortEndedElementsMap);
+ textBlockElementsMap = createLookupTable('text_block_elements', 'h1 h2 h3 h4 h5 h6 p div address pre form ' +
+ 'blockquote center dir fieldset header footer article section hgroup aside nav figure');
+ blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' +
+ 'th tr td li ol ul caption dl dt dd noscript menu isindex samp option datalist select optgroup', textBlockElementsMap);
+
+ // Converts a wildcard expression string to a regexp for example *a will become /.*a/.
+ function patternToRegExp(str) {
+ return new RegExp('^' + str.replace(/([?+*])/g, '.$1') + '$');
+ };
+
+ // Parses the specified valid_elements string and adds to the current rules
+ // This function is a bit hard to read since it's heavily optimized for speed
+ function addValidElements(valid_elements) {
+ var ei, el, ai, al, yl, matches, element, attr, attrData, elementName, attrName, attrType, attributes, attributesOrder,
+ prefix, outputName, globalAttributes, globalAttributesOrder, transElement, key, childKey, value,
+ elementRuleRegExp = /^([#+\-])?([^\[\/]+)(?:\/([^\[]+))?(?:\[([^\]]+)\])?$/,
+ attrRuleRegExp = /^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,
+ hasPatternsRegExp = /[*?+]/;
+
+ if (valid_elements) {
+ // Split valid elements into an array with rules
+ valid_elements = split(valid_elements);
+
+ if (elements['@']) {
+ globalAttributes = elements['@'].attributes;
+ globalAttributesOrder = elements['@'].attributesOrder;
+ }
+
+ // Loop all rules
+ for (ei = 0, el = valid_elements.length; ei < el; ei++) {
+ // Parse element rule
+ matches = elementRuleRegExp.exec(valid_elements[ei]);
+ if (matches) {
+ // Setup local names for matches
+ prefix = matches[1];
+ elementName = matches[2];
+ outputName = matches[3];
+ attrData = matches[4];
+
+ // Create new attributes and attributesOrder
+ attributes = {};
+ attributesOrder = [];
+
+ // Create the new element
+ element = {
+ attributes : attributes,
+ attributesOrder : attributesOrder
+ };
+
+ // Padd empty elements prefix
+ if (prefix === '#')
+ element.paddEmpty = true;
+
+ // Remove empty elements prefix
+ if (prefix === '-')
+ element.removeEmpty = true;
+
+ // Copy attributes from global rule into current rule
+ if (globalAttributes) {
+ for (key in globalAttributes)
+ attributes[key] = globalAttributes[key];
+
+ attributesOrder.push.apply(attributesOrder, globalAttributesOrder);
+ }
+
+ // Attributes defined
+ if (attrData) {
+ attrData = split(attrData, '|');
+ for (ai = 0, al = attrData.length; ai < al; ai++) {
+ matches = attrRuleRegExp.exec(attrData[ai]);
+ if (matches) {
+ attr = {};
+ attrType = matches[1];
+ attrName = matches[2].replace(/::/g, ':');
+ prefix = matches[3];
+ value = matches[4];
+
+ // Required
+ if (attrType === '!') {
+ element.attributesRequired = element.attributesRequired || [];
+ element.attributesRequired.push(attrName);
+ attr.required = true;
+ }
+
+ // Denied from global
+ if (attrType === '-') {
+ delete attributes[attrName];
+ attributesOrder.splice(tinymce.inArray(attributesOrder, attrName), 1);
+ continue;
+ }
+
+ // Default value
+ if (prefix) {
+ // Default value
+ if (prefix === '=') {
+ element.attributesDefault = element.attributesDefault || [];
+ element.attributesDefault.push({name: attrName, value: value});
+ attr.defaultValue = value;
+ }
+
+ // Forced value
+ if (prefix === ':') {
+ element.attributesForced = element.attributesForced || [];
+ element.attributesForced.push({name: attrName, value: value});
+ attr.forcedValue = value;
+ }
+
+ // Required values
+ if (prefix === '<')
+ attr.validValues = makeMap(value, '?');
+ }
+
+ // Check for attribute patterns
+ if (hasPatternsRegExp.test(attrName)) {
+ element.attributePatterns = element.attributePatterns || [];
+ attr.pattern = patternToRegExp(attrName);
+ element.attributePatterns.push(attr);
+ } else {
+ // Add attribute to order list if it doesn't already exist
+ if (!attributes[attrName])
+ attributesOrder.push(attrName);
+
+ attributes[attrName] = attr;
+ }
+ }
+ }
+ }
+
+ // Global rule, store away these for later usage
+ if (!globalAttributes && elementName == '@') {
+ globalAttributes = attributes;
+ globalAttributesOrder = attributesOrder;
+ }
+
+ // Handle substitute elements such as b/strong
+ if (outputName) {
+ element.outputName = elementName;
+ elements[outputName] = element;
+ }
+
+ // Add pattern or exact element
+ if (hasPatternsRegExp.test(elementName)) {
+ element.pattern = patternToRegExp(elementName);
+ patternElements.push(element);
+ } else
+ elements[elementName] = element;
+ }
+ }
+ }
+ };
+
+ function setValidElements(valid_elements) {
+ elements = {};
+ patternElements = [];
+
+ addValidElements(valid_elements);
+
+ each(schemaItems, function(element, name) {
+ children[name] = element.children;
+ });
+ };
+
+ // Adds custom non HTML elements to the schema
+ function addCustomElements(custom_elements) {
+ var customElementRegExp = /^(~)?(.+)$/;
+
+ if (custom_elements) {
+ each(split(custom_elements), function(rule) {
+ var matches = customElementRegExp.exec(rule),
+ inline = matches[1] === '~',
+ cloneName = inline ? 'span' : 'div',
+ name = matches[2];
+
+ children[name] = children[cloneName];
+ customElementsMap[name] = cloneName;
+
+ // If it's not marked as inline then add it to valid block elements
+ if (!inline) {
+ blockElementsMap[name.toUpperCase()] = {};
+ blockElementsMap[name] = {};
+ }
+
+ // Add elements clone if needed
+ if (!elements[name]) {
+ elements[name] = elements[cloneName];
+ }
+
+ // Add custom elements at span/div positions
+ each(children, function(element, child) {
+ if (element[cloneName])
+ element[name] = element[cloneName];
+ });
+ });
+ }
+ };
+
+ // Adds valid children to the schema object
+ function addValidChildren(valid_children) {
+ var childRuleRegExp = /^([+\-]?)(\w+)\[([^\]]+)\]$/;
+
+ if (valid_children) {
+ each(split(valid_children), function(rule) {
+ var matches = childRuleRegExp.exec(rule), parent, prefix;
+
+ if (matches) {
+ prefix = matches[1];
+
+ // Add/remove items from default
+ if (prefix)
+ parent = children[matches[2]];
+ else
+ parent = children[matches[2]] = {'#comment' : {}};
+
+ parent = children[matches[2]];
+
+ each(split(matches[3], '|'), function(child) {
+ if (prefix === '-')
+ delete parent[child];
+ else
+ parent[child] = {};
+ });
+ }
+ });
+ }
+ };
+
+ function getElementRule(name) {
+ var element = elements[name], i;
+
+ // Exact match found
+ if (element)
+ return element;
+
+ // No exact match then try the patterns
+ i = patternElements.length;
+ while (i--) {
+ element = patternElements[i];
+
+ if (element.pattern.test(name))
+ return element;
+ }
+ };
+
+ if (!settings.valid_elements) {
+ // No valid elements defined then clone the elements from the schema spec
+ each(schemaItems, function(element, name) {
+ elements[name] = {
+ attributes : element.attributes,
+ attributesOrder : element.attributesOrder
+ };
+
+ children[name] = element.children;
+ });
+
+ // Switch these on HTML4
+ if (settings.schema != "html5") {
+ each(split('strong/b,em/i'), function(item) {
+ item = split(item, '/');
+ elements[item[1]].outputName = item[0];
+ });
+ }
+
+ // Add default alt attribute for images
+ elements.img.attributesDefault = [{name: 'alt', value: ''}];
+
+ // Remove these if they are empty by default
+ each(split('ol,ul,sub,sup,blockquote,span,font,a,table,tbody,tr,strong,em,b,i'), function(name) {
+ if (elements[name]) {
+ elements[name].removeEmpty = true;
+ }
+ });
+
+ // Padd these by default
+ each(split('p,h1,h2,h3,h4,h5,h6,th,td,pre,div,address,caption'), function(name) {
+ elements[name].paddEmpty = true;
+ });
+ } else
+ setValidElements(settings.valid_elements);
+
+ addCustomElements(settings.custom_elements);
+ addValidChildren(settings.valid_children);
+ addValidElements(settings.extended_valid_elements);
+
+ // Todo: Remove this when we fix list handling to be valid
+ addValidChildren('+ol[ul|ol],+ul[ul|ol]');
+
+ // Delete invalid elements
+ if (settings.invalid_elements) {
+ tinymce.each(tinymce.explode(settings.invalid_elements), function(item) {
+ if (elements[item])
+ delete elements[item];
+ });
+ }
+
+ // If the user didn't allow span only allow internal spans
+ if (!getElementRule('span'))
+ addValidElements('span[!data-mce-type|*]');
+
+ /**
+ * Name/value map object with valid parents and children to those parents.
+ *
+ * @example
+ * children = {
+ * div:{p:{}, h1:{}}
+ * };
+ * @field children
+ * @type {Object}
+ */
+ self.children = children;
+
+ /**
+ * Name/value map object with valid styles for each element.
+ *
+ * @field styles
+ * @type {Object}
+ */
+ self.styles = validStyles;
+
+ /**
+ * Returns a map with boolean attributes.
+ *
+ * @method getBoolAttrs
+ * @return {Object} Name/value lookup map for boolean attributes.
+ */
+ self.getBoolAttrs = function() {
+ return boolAttrMap;
+ };
+
+ /**
+ * Returns a map with block elements.
+ *
+ * @method getBlockElements
+ * @return {Object} Name/value lookup map for block elements.
+ */
+ self.getBlockElements = function() {
+ return blockElementsMap;
+ };
+
+ /**
+ * Returns a map with text block elements. Such as: p,h1-h6,div,address
+ *
+ * @method getTextBlockElements
+ * @return {Object} Name/value lookup map for block elements.
+ */
+ self.getTextBlockElements = function() {
+ return textBlockElementsMap;
+ };
+
+ /**
+ * Returns a map with short ended elements such as BR or IMG.
+ *
+ * @method getShortEndedElements
+ * @return {Object} Name/value lookup map for short ended elements.
+ */
+ self.getShortEndedElements = function() {
+ return shortEndedElementsMap;
+ };
+
+ /**
+ * Returns a map with self closing tags such as
.
+ *
+ * @method getSelfClosingElements
+ * @return {Object} Name/value lookup map for self closing tags elements.
+ */
+ self.getSelfClosingElements = function() {
+ return selfClosingElementsMap;
+ };
+
+ /**
+ * Returns a map with elements that should be treated as contents regardless if it has text
+ * content in them or not such as TD, VIDEO or IMG.
+ *
+ * @method getNonEmptyElements
+ * @return {Object} Name/value lookup map for non empty elements.
+ */
+ self.getNonEmptyElements = function() {
+ return nonEmptyElementsMap;
+ };
+
+ /**
+ * Returns a map with elements where white space is to be preserved like PRE or SCRIPT.
+ *
+ * @method getWhiteSpaceElements
+ * @return {Object} Name/value lookup map for white space elements.
+ */
+ self.getWhiteSpaceElements = function() {
+ return whiteSpaceElementsMap;
+ };
+
+ /**
+ * Returns true/false if the specified element and it's child is valid or not
+ * according to the schema.
+ *
+ * @method isValidChild
+ * @param {String} name Element name to check for.
+ * @param {String} child Element child to verify.
+ * @return {Boolean} True/false if the element is a valid child of the specified parent.
+ */
+ self.isValidChild = function(name, child) {
+ var parent = children[name];
+
+ return !!(parent && parent[child]);
+ };
+
+ /**
+ * Returns true/false if the specified element name and optional attribute is
+ * valid according to the schema.
+ *
+ * @method isValid
+ * @param {String} name Name of element to check.
+ * @param {String} attr Optional attribute name to check for.
+ * @return {Boolean} True/false if the element and attribute is valid.
+ */
+ self.isValid = function(name, attr) {
+ var attrPatterns, i, rule = getElementRule(name);
+
+ // Check if it's a valid element
+ if (rule) {
+ if (attr) {
+ // Check if attribute name exists
+ if (rule.attributes[attr]) {
+ return true;
+ }
+
+ // Check if attribute matches a regexp pattern
+ attrPatterns = rule.attributePatterns;
+ if (attrPatterns) {
+ i = attrPatterns.length;
+ while (i--) {
+ if (attrPatterns[i].pattern.test(name)) {
+ return true;
+ }
+ }
+ }
+ } else {
+ return true;
+ }
+ }
+
+ // No match
+ return false;
+ };
+
+ /**
+ * Returns true/false if the specified element is valid or not
+ * according to the schema.
+ *
+ * @method getElementRule
+ * @param {String} name Element name to check for.
+ * @return {Object} Element object or undefined if the element isn't valid.
+ */
+ self.getElementRule = getElementRule;
+
+ /**
+ * Returns an map object of all custom elements.
+ *
+ * @method getCustomElements
+ * @return {Object} Name/value map object of all custom elements.
+ */
+ self.getCustomElements = function() {
+ return customElementsMap;
+ };
+
+ /**
+ * Parses a valid elements string and adds it to the schema. The valid elements format is for example "element[attr=default|otherattr]".
+ * Existing rules will be replaced with the ones specified, so this extends the schema.
+ *
+ * @method addValidElements
+ * @param {String} valid_elements String in the valid elements format to be parsed.
+ */
+ self.addValidElements = addValidElements;
+
+ /**
+ * Parses a valid elements string and sets it to the schema. The valid elements format is for example "element[attr=default|otherattr]".
+ * Existing rules will be replaced with the ones specified, so this extends the schema.
+ *
+ * @method setValidElements
+ * @param {String} valid_elements String in the valid elements format to be parsed.
+ */
+ self.setValidElements = setValidElements;
+
+ /**
+ * Adds custom non HTML elements to the schema.
+ *
+ * @method addCustomElements
+ * @param {String} custom_elements Comma separated list of custom elements to add.
+ */
+ self.addCustomElements = addCustomElements;
+
+ /**
+ * Parses a valid children string and adds them to the schema structure. The valid children format is for example: "element[child1|child2]".
+ *
+ * @method addValidChildren
+ * @param {String} valid_children Valid children elements string to parse
+ */
+ self.addValidChildren = addValidChildren;
+
+ self.elements = elements;
+ };
+})(tinymce);
diff --git a/js/tiny_mce/classes/html/Serializer.js b/js/tiny_mce/classes/html/Serializer.js
index 26937d228b5..7fa15d14a6e 100644
--- a/js/tiny_mce/classes/html/Serializer.js
+++ b/js/tiny_mce/classes/html/Serializer.js
@@ -1,152 +1,152 @@
-/**
- * Serializer.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- /**
- * This class is used to serialize down the DOM tree into a string using a Writer instance.
- *
- *
- * @example
- * new tinymce.html.Serializer().serialize(new tinymce.html.DomParser().parse('
.
+ *
+ * @method start
+ * @param {String} name Name of the element.
+ * @param {Array} attrs Optional attribute array or undefined if it hasn't any.
+ * @param {Boolean} empty Optional empty state if the tag should end like .
+ */
+ start: function(name, attrs, empty) {
+ var i, l, attr, value;
+
+ if (indent && indentBefore[name] && html.length > 0) {
+ value = html[html.length - 1];
+
+ if (value.length > 0 && value !== '\n')
+ html.push('\n');
+ }
+
+ html.push('<', name);
+
+ if (attrs) {
+ for (i = 0, l = attrs.length; i < l; i++) {
+ attr = attrs[i];
+ html.push(' ', attr.name, '="', encode(attr.value, true), '"');
+ }
+ }
+
+ if (!empty || htmlOutput)
+ html[html.length] = '>';
+ else
+ html[html.length] = ' />';
+
+ if (empty && indent && indentAfter[name] && html.length > 0) {
+ value = html[html.length - 1];
+
+ if (value.length > 0 && value !== '\n')
+ html.push('\n');
+ }
+ },
+
+ /**
+ * Writes the a end element such as
.
+ *
+ * @method end
+ * @param {String} name Name of the element.
+ */
+ end: function(name) {
+ var value;
+
+ /*if (indent && indentBefore[name] && html.length > 0) {
+ value = html[html.length - 1];
+
+ if (value.length > 0 && value !== '\n')
+ html.push('\n');
+ }*/
+
+ html.push('', name, '>');
+
+ if (indent && indentAfter[name] && html.length > 0) {
+ value = html[html.length - 1];
+
+ if (value.length > 0 && value !== '\n')
+ html.push('\n');
+ }
+ },
+
+ /**
+ * Writes a text node.
+ *
+ * @method text
+ * @param {String} text String to write out.
+ * @param {Boolean} raw Optional raw state if true the contents wont get encoded.
+ */
+ text: function(text, raw) {
+ if (text.length > 0)
+ html[html.length] = raw ? text : encode(text);
+ },
+
+ /**
+ * Writes a cdata node such as .
+ *
+ * @method cdata
+ * @param {String} text String to write out inside the cdata.
+ */
+ cdata: function(text) {
+ html.push('');
+ },
+
+ /**
+ * Writes a comment node such as .
+ *
+ * @method cdata
+ * @param {String} text String to write out inside the comment.
+ */
+ comment: function(text) {
+ html.push('');
+ },
+
+ /**
+ * Writes a PI node such as .
+ *
+ * @method pi
+ * @param {String} name Name of the pi.
+ * @param {String} text String to write out inside the pi.
+ */
+ pi: function(name, text) {
+ if (text)
+ html.push('', name, ' ', text, '?>');
+ else
+ html.push('', name, '?>');
+
+ if (indent)
+ html.push('\n');
+ },
+
+ /**
+ * Writes a doctype node such as .
+ *
+ * @method doctype
+ * @param {String} text String to write out inside the doctype.
+ */
+ doctype: function(text) {
+ html.push('', indent ? '\n' : '');
+ },
+
+ /**
+ * Resets the internal buffer if one wants to reuse the writer.
+ *
+ * @method reset
+ */
+ reset: function() {
+ html.length = 0;
+ },
+
+ /**
+ * Returns the contents that got serialized.
+ *
+ * @method getContent
+ * @return {String} HTML contents that got written down.
+ */
+ getContent: function() {
+ return html.join('').replace(/\n$/, '');
+ }
+ };
+};
diff --git a/js/tiny_mce/classes/ui/Button.js b/js/tiny_mce/classes/ui/Button.js
index 213a78b4cd2..58b704cc865 100644
--- a/js/tiny_mce/classes/ui/Button.js
+++ b/js/tiny_mce/classes/ui/Button.js
@@ -1,92 +1,92 @@
-/**
- * Button.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var DOM = tinymce.DOM;
-
- /**
- * This class is used to create a UI button. A button is basically a link
- * that is styled to look like a button or icon.
- *
- * @class tinymce.ui.Button
- * @extends tinymce.ui.Control
- */
- tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
- /**
- * Constructs a new button control instance.
- *
- * @constructor
- * @method Button
- * @param {String} id Control id for the button.
- * @param {Object} s Optional name/value settings object.
- * @param {Editor} ed Optional the editor instance this button is for.
- */
- Button : function(id, s, ed) {
- this.parent(id, s, ed);
- this.classPrefix = 'mceButton';
- },
-
- /**
- * Renders the button as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the button control element.
- */
- renderHTML : function() {
- var cp = this.classPrefix, s = this.settings, h, l;
-
- l = DOM.encode(s.label || '');
- h = '';
- if (s.image && !(this.editor &&this.editor.forcedHighContrastMode) )
- h += '' + (l ? '' + l + '' : '');
- else
- h += '' + (l ? '' + l + '' : '');
-
- h += '' + s.title + '';
- h += '';
- return h;
- },
-
- /**
- * Post render handler. This function will be called after the UI has been
- * rendered so that events can be added.
- *
- * @method postRender
- */
- postRender : function() {
- var t = this, s = t.settings, imgBookmark;
-
- // In IE a large image that occupies the entire editor area will be deselected when a button is clicked, so
- // need to keep the selection in case the selection is lost
- if (tinymce.isIE && t.editor) {
- tinymce.dom.Event.add(t.id, 'mousedown', function(e) {
- var nodeName = t.editor.selection.getNode().nodeName;
- imgBookmark = nodeName === 'IMG' ? t.editor.selection.getBookmark() : null;
- });
- }
- tinymce.dom.Event.add(t.id, 'click', function(e) {
- if (!t.isDisabled()) {
- // restore the selection in case the selection is lost in IE
- if (tinymce.isIE && t.editor && imgBookmark !== null) {
- t.editor.selection.moveToBookmark(imgBookmark);
- }
- return s.onclick.call(s.scope, e);
- }
- });
- tinymce.dom.Event.add(t.id, 'keydown', function(e) {
- if (!t.isDisabled() && e.keyCode==tinymce.VK.SPACEBAR) {
- tinymce.dom.Event.cancel(e);
- return s.onclick.call(s.scope, e);
- }
- });
- }
- });
-})(tinymce);
+/**
+ * Button.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var DOM = tinymce.DOM;
+
+ /**
+ * This class is used to create a UI button. A button is basically a link
+ * that is styled to look like a button or icon.
+ *
+ * @class tinymce.ui.Button
+ * @extends tinymce.ui.Control
+ */
+ tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
+ /**
+ * Constructs a new button control instance.
+ *
+ * @constructor
+ * @method Button
+ * @param {String} id Control id for the button.
+ * @param {Object} s Optional name/value settings object.
+ * @param {Editor} ed Optional the editor instance this button is for.
+ */
+ Button : function(id, s, ed) {
+ this.parent(id, s, ed);
+ this.classPrefix = 'mceButton';
+ },
+
+ /**
+ * Renders the button as a HTML string. This method is much faster than using the DOM and when
+ * creating a whole toolbar with buttons it does make a lot of difference.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the button control element.
+ */
+ renderHTML : function() {
+ var cp = this.classPrefix, s = this.settings, h, l;
+
+ l = DOM.encode(s.label || '');
+ h = '';
+ if (s.image && !(this.editor &&this.editor.forcedHighContrastMode) )
+ h += '' + (l ? '' + l + '' : '');
+ else
+ h += '' + (l ? '' + l + '' : '');
+
+ h += '' + s.title + '';
+ h += '';
+ return h;
+ },
+
+ /**
+ * Post render handler. This function will be called after the UI has been
+ * rendered so that events can be added.
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, s = t.settings, imgBookmark;
+
+ // In IE a large image that occupies the entire editor area will be deselected when a button is clicked, so
+ // need to keep the selection in case the selection is lost
+ if (tinymce.isIE && t.editor) {
+ tinymce.dom.Event.add(t.id, 'mousedown', function(e) {
+ var nodeName = t.editor.selection.getNode().nodeName;
+ imgBookmark = nodeName === 'IMG' ? t.editor.selection.getBookmark() : null;
+ });
+ }
+ tinymce.dom.Event.add(t.id, 'click', function(e) {
+ if (!t.isDisabled()) {
+ // restore the selection in case the selection is lost in IE
+ if (tinymce.isIE && t.editor && imgBookmark !== null) {
+ t.editor.selection.moveToBookmark(imgBookmark);
+ }
+ return s.onclick.call(s.scope, e);
+ }
+ });
+ tinymce.dom.Event.add(t.id, 'keydown', function(e) {
+ if (!t.isDisabled() && e.keyCode==tinymce.VK.SPACEBAR) {
+ tinymce.dom.Event.cancel(e);
+ return s.onclick.call(s.scope, e);
+ }
+ });
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/ColorSplitButton.js b/js/tiny_mce/classes/ui/ColorSplitButton.js
index cd0be6a6313..76cf0671270 100644
--- a/js/tiny_mce/classes/ui/ColorSplitButton.js
+++ b/js/tiny_mce/classes/ui/ColorSplitButton.js
@@ -1,299 +1,299 @@
-/**
- * ColorSplitButton.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
-
- /**
- * This class is used to create UI color split button. A color split button will present show a small color picker
- * when you press the open menu.
- *
- * @class tinymce.ui.ColorSplitButton
- * @extends tinymce.ui.SplitButton
- */
- tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
- /**
- * Constructs a new color split button control instance.
- *
- * @constructor
- * @method ColorSplitButton
- * @param {String} id Control id for the color split button.
- * @param {Object} s Optional name/value settings object.
- * @param {Editor} ed The editor instance this button is for.
- */
- ColorSplitButton : function(id, s, ed) {
- var t = this;
-
- t.parent(id, s, ed);
-
- /**
- * Settings object.
- *
- * @property settings
- * @type Object
- */
- t.settings = s = tinymce.extend({
- colors : '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',
- grid_width : 8,
- default_color : '#888888'
- }, t.settings);
-
- /**
- * Fires when the menu is shown.
- *
- * @event onShowMenu
- */
- t.onShowMenu = new tinymce.util.Dispatcher(t);
-
- /**
- * Fires when the menu is hidden.
- *
- * @event onHideMenu
- */
- t.onHideMenu = new tinymce.util.Dispatcher(t);
-
- /**
- * Current color value.
- *
- * @property value
- * @type String
- */
- t.value = s.default_color;
- },
-
- /**
- * Shows the color menu. The color menu is a layer places under the button
- * and displays a table of colors for the user to pick from.
- *
- * @method showMenu
- */
- showMenu : function() {
- var t = this, r, p, e, p2;
-
- if (t.isDisabled())
- return;
-
- if (!t.isMenuRendered) {
- t.renderMenu();
- t.isMenuRendered = true;
- }
-
- if (t.isMenuVisible)
- return t.hideMenu();
-
- e = DOM.get(t.id);
- DOM.show(t.id + '_menu');
- DOM.addClass(e, 'mceSplitButtonSelected');
- p2 = DOM.getPos(e);
- DOM.setStyles(t.id + '_menu', {
- left : p2.x,
- top : p2.y + e.firstChild.clientHeight,
- zIndex : 200000
- });
- e = 0;
-
- Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
- t.onShowMenu.dispatch(t);
-
- if (t._focused) {
- t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
- if (e.keyCode == 27)
- t.hideMenu();
- });
-
- DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
- }
-
- t.keyboardNav = new tinymce.ui.KeyboardNavigation({
- root: t.id + '_menu',
- items: DOM.select('a', t.id + '_menu'),
- onCancel: function() {
- t.hideMenu();
- t.focus();
- }
- });
-
- t.keyboardNav.focus();
- t.isMenuVisible = 1;
- },
-
- /**
- * Hides the color menu. The optional event parameter is used to check where the event occurred so it
- * doesn't close them menu if it was a event inside the menu.
- *
- * @method hideMenu
- * @param {Event} e Optional event object.
- */
- hideMenu : function(e) {
- var t = this;
-
- if (t.isMenuVisible) {
- // Prevent double toogles by canceling the mouse click event to the button
- if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
- return;
-
- if (!e || !DOM.getParent(e.target, '.mceSplitButtonMenu')) {
- DOM.removeClass(t.id, 'mceSplitButtonSelected');
- Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
- Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
- DOM.hide(t.id + '_menu');
- }
-
- t.isMenuVisible = 0;
- t.onHideMenu.dispatch();
- t.keyboardNav.destroy();
- }
- },
-
- /**
- * Renders the menu to the DOM.
- *
- * @method renderMenu
- */
- renderMenu : function() {
- var t = this, m, i = 0, s = t.settings, n, tb, tr, w, context;
-
- w = DOM.add(s.menu_container, 'div', {role: 'listbox', id : t.id + '_menu', 'class' : s.menu_class + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
- m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
- DOM.add(m, 'span', {'class' : 'mceMenuLine'});
-
- n = DOM.add(m, 'table', {role: 'presentation', 'class' : 'mceColorSplitMenu'});
- tb = DOM.add(n, 'tbody');
-
- // Generate color grid
- i = 0;
- each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
- c = c.replace(/^#/, '');
-
- if (!i--) {
- tr = DOM.add(tb, 'tr');
- i = s.grid_width - 1;
- }
-
- n = DOM.add(tr, 'td');
- var settings = {
- href : 'javascript:;',
- style : {
- backgroundColor : '#' + c
- },
- 'title': t.editor.getLang('colors.' + c, c),
- 'data-mce-color' : '#' + c
- };
-
- // adding a proper ARIA role = button causes JAWS to read things incorrectly on IE.
- if (!tinymce.isIE ) {
- settings.role = 'option';
- }
-
- n = DOM.add(n, 'a', settings);
-
- if (t.editor.forcedHighContrastMode) {
- n = DOM.add(n, 'canvas', { width: 16, height: 16, 'aria-hidden': 'true' });
- if (n.getContext && (context = n.getContext("2d"))) {
- context.fillStyle = '#' + c;
- context.fillRect(0, 0, 16, 16);
- } else {
- // No point leaving a canvas element around if it's not supported for drawing on anyway.
- DOM.remove(n);
- }
- }
- });
-
- if (s.more_colors_func) {
- n = DOM.add(tb, 'tr');
- n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
- n = DOM.add(n, 'a', {role: 'option', id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
-
- Event.add(n, 'click', function(e) {
- s.more_colors_func.call(s.more_colors_scope || this);
- return Event.cancel(e); // Cancel to fix onbeforeunload problem
- });
- }
-
- DOM.addClass(m, 'mceColorSplitMenu');
-
- // Prevent IE from scrolling and hindering click to occur #4019
- Event.add(t.id + '_menu', 'mousedown', function(e) {return Event.cancel(e);});
-
- Event.add(t.id + '_menu', 'click', function(e) {
- var c;
-
- e = DOM.getParent(e.target, 'a', tb);
-
- if (e && e.nodeName.toLowerCase() == 'a' && (c = e.getAttribute('data-mce-color')))
- t.setColor(c);
-
- return false; // Prevent IE auto save warning
- });
-
- return w;
- },
-
- /**
- * Sets the current color for the control and hides the menu if it should be visible.
- *
- * @method setColor
- * @param {String} c Color code value in hex for example: #FF00FF
- */
- setColor : function(c) {
- this.displayColor(c);
- this.hideMenu();
- this.settings.onselect(c);
- },
-
- /**
- * Change the currently selected color for the control.
- *
- * @method displayColor
- * @param {String} c Color code value in hex for example: #FF00FF
- */
- displayColor : function(c) {
- var t = this;
-
- DOM.setStyle(t.id + '_preview', 'backgroundColor', c);
-
- t.value = c;
- },
-
- /**
- * Post render event. This will be executed after the control has been rendered and can be used to
- * set states, add events to the control etc. It's recommended for subclasses of the control to call this method by using this.parent().
- *
- * @method postRender
- */
- postRender : function() {
- var t = this, id = t.id;
-
- t.parent();
- DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
- DOM.setStyle(t.id + '_preview', 'backgroundColor', t.value);
- },
-
- /**
- * Destroys the control. This means it will be removed from the DOM and any
- * events tied to it will also be removed.
- *
- * @method destroy
- */
- destroy : function() {
- var self = this;
-
- self.parent();
-
- Event.clear(self.id + '_menu');
- Event.clear(self.id + '_more');
- DOM.remove(self.id + '_menu');
-
- if (self.keyboardNav) {
- self.keyboardNav.destroy();
- }
- }
- });
-})(tinymce);
+/**
+ * ColorSplitButton.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
+
+ /**
+ * This class is used to create UI color split button. A color split button will present show a small color picker
+ * when you press the open menu.
+ *
+ * @class tinymce.ui.ColorSplitButton
+ * @extends tinymce.ui.SplitButton
+ */
+ tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
+ /**
+ * Constructs a new color split button control instance.
+ *
+ * @constructor
+ * @method ColorSplitButton
+ * @param {String} id Control id for the color split button.
+ * @param {Object} s Optional name/value settings object.
+ * @param {Editor} ed The editor instance this button is for.
+ */
+ ColorSplitButton : function(id, s, ed) {
+ var t = this;
+
+ t.parent(id, s, ed);
+
+ /**
+ * Settings object.
+ *
+ * @property settings
+ * @type Object
+ */
+ t.settings = s = tinymce.extend({
+ colors : '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',
+ grid_width : 8,
+ default_color : '#888888'
+ }, t.settings);
+
+ /**
+ * Fires when the menu is shown.
+ *
+ * @event onShowMenu
+ */
+ t.onShowMenu = new tinymce.util.Dispatcher(t);
+
+ /**
+ * Fires when the menu is hidden.
+ *
+ * @event onHideMenu
+ */
+ t.onHideMenu = new tinymce.util.Dispatcher(t);
+
+ /**
+ * Current color value.
+ *
+ * @property value
+ * @type String
+ */
+ t.value = s.default_color;
+ },
+
+ /**
+ * Shows the color menu. The color menu is a layer places under the button
+ * and displays a table of colors for the user to pick from.
+ *
+ * @method showMenu
+ */
+ showMenu : function() {
+ var t = this, r, p, e, p2;
+
+ if (t.isDisabled())
+ return;
+
+ if (!t.isMenuRendered) {
+ t.renderMenu();
+ t.isMenuRendered = true;
+ }
+
+ if (t.isMenuVisible)
+ return t.hideMenu();
+
+ e = DOM.get(t.id);
+ DOM.show(t.id + '_menu');
+ DOM.addClass(e, 'mceSplitButtonSelected');
+ p2 = DOM.getPos(e);
+ DOM.setStyles(t.id + '_menu', {
+ left : p2.x,
+ top : p2.y + e.firstChild.clientHeight,
+ zIndex : 200000
+ });
+ e = 0;
+
+ Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
+ t.onShowMenu.dispatch(t);
+
+ if (t._focused) {
+ t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
+ if (e.keyCode == 27)
+ t.hideMenu();
+ });
+
+ DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
+ }
+
+ t.keyboardNav = new tinymce.ui.KeyboardNavigation({
+ root: t.id + '_menu',
+ items: DOM.select('a', t.id + '_menu'),
+ onCancel: function() {
+ t.hideMenu();
+ t.focus();
+ }
+ });
+
+ t.keyboardNav.focus();
+ t.isMenuVisible = 1;
+ },
+
+ /**
+ * Hides the color menu. The optional event parameter is used to check where the event occurred so it
+ * doesn't close them menu if it was a event inside the menu.
+ *
+ * @method hideMenu
+ * @param {Event} e Optional event object.
+ */
+ hideMenu : function(e) {
+ var t = this;
+
+ if (t.isMenuVisible) {
+ // Prevent double toogles by canceling the mouse click event to the button
+ if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
+ return;
+
+ if (!e || !DOM.getParent(e.target, '.mceSplitButtonMenu')) {
+ DOM.removeClass(t.id, 'mceSplitButtonSelected');
+ Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
+ Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
+ DOM.hide(t.id + '_menu');
+ }
+
+ t.isMenuVisible = 0;
+ t.onHideMenu.dispatch();
+ t.keyboardNav.destroy();
+ }
+ },
+
+ /**
+ * Renders the menu to the DOM.
+ *
+ * @method renderMenu
+ */
+ renderMenu : function() {
+ var t = this, m, i = 0, s = t.settings, n, tb, tr, w, context;
+
+ w = DOM.add(s.menu_container, 'div', {role: 'listbox', id : t.id + '_menu', 'class' : s.menu_class + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
+ m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
+ DOM.add(m, 'span', {'class' : 'mceMenuLine'});
+
+ n = DOM.add(m, 'table', {role: 'presentation', 'class' : 'mceColorSplitMenu'});
+ tb = DOM.add(n, 'tbody');
+
+ // Generate color grid
+ i = 0;
+ each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
+ c = c.replace(/^#/, '');
+
+ if (!i--) {
+ tr = DOM.add(tb, 'tr');
+ i = s.grid_width - 1;
+ }
+
+ n = DOM.add(tr, 'td');
+ var settings = {
+ href : 'javascript:;',
+ style : {
+ backgroundColor : '#' + c
+ },
+ 'title': t.editor.getLang('colors.' + c, c),
+ 'data-mce-color' : '#' + c
+ };
+
+ // adding a proper ARIA role = button causes JAWS to read things incorrectly on IE.
+ if (!tinymce.isIE ) {
+ settings.role = 'option';
+ }
+
+ n = DOM.add(n, 'a', settings);
+
+ if (t.editor.forcedHighContrastMode) {
+ n = DOM.add(n, 'canvas', { width: 16, height: 16, 'aria-hidden': 'true' });
+ if (n.getContext && (context = n.getContext("2d"))) {
+ context.fillStyle = '#' + c;
+ context.fillRect(0, 0, 16, 16);
+ } else {
+ // No point leaving a canvas element around if it's not supported for drawing on anyway.
+ DOM.remove(n);
+ }
+ }
+ });
+
+ if (s.more_colors_func) {
+ n = DOM.add(tb, 'tr');
+ n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
+ n = DOM.add(n, 'a', {role: 'option', id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
+
+ Event.add(n, 'click', function(e) {
+ s.more_colors_func.call(s.more_colors_scope || this);
+ return Event.cancel(e); // Cancel to fix onbeforeunload problem
+ });
+ }
+
+ DOM.addClass(m, 'mceColorSplitMenu');
+
+ // Prevent IE from scrolling and hindering click to occur #4019
+ Event.add(t.id + '_menu', 'mousedown', function(e) {return Event.cancel(e);});
+
+ Event.add(t.id + '_menu', 'click', function(e) {
+ var c;
+
+ e = DOM.getParent(e.target, 'a', tb);
+
+ if (e && e.nodeName.toLowerCase() == 'a' && (c = e.getAttribute('data-mce-color')))
+ t.setColor(c);
+
+ return false; // Prevent IE auto save warning
+ });
+
+ return w;
+ },
+
+ /**
+ * Sets the current color for the control and hides the menu if it should be visible.
+ *
+ * @method setColor
+ * @param {String} c Color code value in hex for example: #FF00FF
+ */
+ setColor : function(c) {
+ this.displayColor(c);
+ this.hideMenu();
+ this.settings.onselect(c);
+ },
+
+ /**
+ * Change the currently selected color for the control.
+ *
+ * @method displayColor
+ * @param {String} c Color code value in hex for example: #FF00FF
+ */
+ displayColor : function(c) {
+ var t = this;
+
+ DOM.setStyle(t.id + '_preview', 'backgroundColor', c);
+
+ t.value = c;
+ },
+
+ /**
+ * Post render event. This will be executed after the control has been rendered and can be used to
+ * set states, add events to the control etc. It's recommended for subclasses of the control to call this method by using this.parent().
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, id = t.id;
+
+ t.parent();
+ DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
+ DOM.setStyle(t.id + '_preview', 'backgroundColor', t.value);
+ },
+
+ /**
+ * Destroys the control. This means it will be removed from the DOM and any
+ * events tied to it will also be removed.
+ *
+ * @method destroy
+ */
+ destroy : function() {
+ var self = this;
+
+ self.parent();
+
+ Event.clear(self.id + '_menu');
+ Event.clear(self.id + '_more');
+ DOM.remove(self.id + '_menu');
+
+ if (self.keyboardNav) {
+ self.keyboardNav.destroy();
+ }
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/Container.js b/js/tiny_mce/classes/ui/Container.js
index e304757452e..28bd93aba5e 100644
--- a/js/tiny_mce/classes/ui/Container.js
+++ b/js/tiny_mce/classes/ui/Container.js
@@ -1,66 +1,66 @@
-/**
- * Container.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-/**
- * This class is the base class for all container controls like toolbars. This class should not
- * be instantiated directly other container controls should inherit from this one.
- *
- * @class tinymce.ui.Container
- * @extends tinymce.ui.Control
- */
-tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
- /**
- * Base contrustor a new container control instance.
- *
- * @constructor
- * @method Container
- * @param {String} id Control id to use for the container.
- * @param {Object} s Optional name/value settings object.
- */
- Container : function(id, s, editor) {
- this.parent(id, s, editor);
-
- /**
- * Array of controls added to the container.
- *
- * @property controls
- * @type Array
- */
- this.controls = [];
-
- this.lookup = {};
- },
-
- /**
- * Adds a control to the collection of controls for the container.
- *
- * @method add
- * @param {tinymce.ui.Control} c Control instance to add to the container.
- * @return {tinymce.ui.Control} Same control instance that got passed in.
- */
- add : function(c) {
- this.lookup[c.id] = c;
- this.controls.push(c);
-
- return c;
- },
-
- /**
- * Returns a control by id from the containers collection.
- *
- * @method get
- * @param {String} n Id for the control to retrieve.
- * @return {tinymce.ui.Control} Control instance by the specified name or undefined if it wasn't found.
- */
- get : function(n) {
- return this.lookup[n];
- }
-});
-
+/**
+ * Container.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/**
+ * This class is the base class for all container controls like toolbars. This class should not
+ * be instantiated directly other container controls should inherit from this one.
+ *
+ * @class tinymce.ui.Container
+ * @extends tinymce.ui.Control
+ */
+tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
+ /**
+ * Base contrustor a new container control instance.
+ *
+ * @constructor
+ * @method Container
+ * @param {String} id Control id to use for the container.
+ * @param {Object} s Optional name/value settings object.
+ */
+ Container : function(id, s, editor) {
+ this.parent(id, s, editor);
+
+ /**
+ * Array of controls added to the container.
+ *
+ * @property controls
+ * @type Array
+ */
+ this.controls = [];
+
+ this.lookup = {};
+ },
+
+ /**
+ * Adds a control to the collection of controls for the container.
+ *
+ * @method add
+ * @param {tinymce.ui.Control} c Control instance to add to the container.
+ * @return {tinymce.ui.Control} Same control instance that got passed in.
+ */
+ add : function(c) {
+ this.lookup[c.id] = c;
+ this.controls.push(c);
+
+ return c;
+ },
+
+ /**
+ * Returns a control by id from the containers collection.
+ *
+ * @method get
+ * @param {String} n Id for the control to retrieve.
+ * @return {tinymce.ui.Control} Control instance by the specified name or undefined if it wasn't found.
+ */
+ get : function(n) {
+ return this.lookup[n];
+ }
+});
+
diff --git a/js/tiny_mce/classes/ui/Control.js b/js/tiny_mce/classes/ui/Control.js
index ba69592d407..e04062aadeb 100644
--- a/js/tiny_mce/classes/ui/Control.js
+++ b/js/tiny_mce/classes/ui/Control.js
@@ -1,198 +1,198 @@
-/**
- * Control.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- // Shorten class names
- var DOM = tinymce.DOM, is = tinymce.is;
-
- /**
- * This class is the base class for all controls like buttons, toolbars, containers. This class should not
- * be instantiated directly other controls should inherit from this one.
- *
- * @class tinymce.ui.Control
- */
- tinymce.create('tinymce.ui.Control', {
- /**
- * Constructs a new control instance.
- *
- * @constructor
- * @method Control
- * @param {String} id Control id.
- * @param {Object} s Optional name/value settings object.
- */
- Control : function(id, s, editor) {
- this.id = id;
- this.settings = s = s || {};
- this.rendered = false;
- this.onRender = new tinymce.util.Dispatcher(this);
- this.classPrefix = '';
- this.scope = s.scope || this;
- this.disabled = 0;
- this.active = 0;
- this.editor = editor;
- },
-
- setAriaProperty : function(property, value) {
- var element = DOM.get(this.id + '_aria') || DOM.get(this.id);
- if (element) {
- DOM.setAttrib(element, 'aria-' + property, !!value);
- }
- },
-
- focus : function() {
- DOM.get(this.id).focus();
- },
-
- /**
- * Sets the disabled state for the control. This will add CSS classes to the
- * element that contains the control. So that it can be disabled visually.
- *
- * @method setDisabled
- * @param {Boolean} s Boolean state if the control should be disabled or not.
- */
- setDisabled : function(s) {
- if (s != this.disabled) {
- this.setAriaProperty('disabled', s);
-
- this.setState('Disabled', s);
- this.setState('Enabled', !s);
- this.disabled = s;
- }
- },
-
- /**
- * Returns true/false if the control is disabled or not. This is a method since you can then
- * choose to check some class or some internal bool state in subclasses.
- *
- * @method isDisabled
- * @return {Boolean} true/false if the control is disabled or not.
- */
- isDisabled : function() {
- return this.disabled;
- },
-
- /**
- * Sets the activated state for the control. This will add CSS classes to the
- * element that contains the control. So that it can be activated visually.
- *
- * @method setActive
- * @param {Boolean} s Boolean state if the control should be activated or not.
- */
- setActive : function(s) {
- if (s != this.active) {
- this.setState('Active', s);
- this.active = s;
- this.setAriaProperty('pressed', s);
- }
- },
-
- /**
- * Returns true/false if the control is disabled or not. This is a method since you can then
- * choose to check some class or some internal bool state in subclasses.
- *
- * @method isActive
- * @return {Boolean} true/false if the control is disabled or not.
- */
- isActive : function() {
- return this.active;
- },
-
- /**
- * Sets the specified class state for the control.
- *
- * @method setState
- * @param {String} c Class name to add/remove depending on state.
- * @param {Boolean} s True/false state if the class should be removed or added.
- */
- setState : function(c, s) {
- var n = DOM.get(this.id);
-
- c = this.classPrefix + c;
-
- if (s)
- DOM.addClass(n, c);
- else
- DOM.removeClass(n, c);
- },
-
- /**
- * Returns true/false if the control has been rendered or not.
- *
- * @method isRendered
- * @return {Boolean} State if the control has been rendered or not.
- */
- isRendered : function() {
- return this.rendered;
- },
-
- /**
- * Renders the control as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the button control element.
- */
- renderHTML : function() {
- },
-
- /**
- * Renders the control to the specified container element.
- *
- * @method renderTo
- * @param {Element} n HTML DOM element to add control to.
- */
- renderTo : function(n) {
- DOM.setHTML(n, this.renderHTML());
- },
-
- /**
- * Post render event. This will be executed after the control has been rendered and can be used to
- * set states, add events to the control etc. It's recommended for subclasses of the control to call this method by using this.parent().
- *
- * @method postRender
- */
- postRender : function() {
- var t = this, b;
-
- // Set pending states
- if (is(t.disabled)) {
- b = t.disabled;
- t.disabled = -1;
- t.setDisabled(b);
- }
-
- if (is(t.active)) {
- b = t.active;
- t.active = -1;
- t.setActive(b);
- }
- },
-
- /**
- * Removes the control. This means it will be removed from the DOM and any
- * events tied to it will also be removed.
- *
- * @method remove
- */
- remove : function() {
- DOM.remove(this.id);
- this.destroy();
- },
-
- /**
- * Destroys the control will free any memory by removing event listeners etc.
- *
- * @method destroy
- */
- destroy : function() {
- tinymce.dom.Event.clear(this.id);
- }
- });
+/**
+ * Control.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ // Shorten class names
+ var DOM = tinymce.DOM, is = tinymce.is;
+
+ /**
+ * This class is the base class for all controls like buttons, toolbars, containers. This class should not
+ * be instantiated directly other controls should inherit from this one.
+ *
+ * @class tinymce.ui.Control
+ */
+ tinymce.create('tinymce.ui.Control', {
+ /**
+ * Constructs a new control instance.
+ *
+ * @constructor
+ * @method Control
+ * @param {String} id Control id.
+ * @param {Object} s Optional name/value settings object.
+ */
+ Control : function(id, s, editor) {
+ this.id = id;
+ this.settings = s = s || {};
+ this.rendered = false;
+ this.onRender = new tinymce.util.Dispatcher(this);
+ this.classPrefix = '';
+ this.scope = s.scope || this;
+ this.disabled = 0;
+ this.active = 0;
+ this.editor = editor;
+ },
+
+ setAriaProperty : function(property, value) {
+ var element = DOM.get(this.id + '_aria') || DOM.get(this.id);
+ if (element) {
+ DOM.setAttrib(element, 'aria-' + property, !!value);
+ }
+ },
+
+ focus : function() {
+ DOM.get(this.id).focus();
+ },
+
+ /**
+ * Sets the disabled state for the control. This will add CSS classes to the
+ * element that contains the control. So that it can be disabled visually.
+ *
+ * @method setDisabled
+ * @param {Boolean} s Boolean state if the control should be disabled or not.
+ */
+ setDisabled : function(s) {
+ if (s != this.disabled) {
+ this.setAriaProperty('disabled', s);
+
+ this.setState('Disabled', s);
+ this.setState('Enabled', !s);
+ this.disabled = s;
+ }
+ },
+
+ /**
+ * Returns true/false if the control is disabled or not. This is a method since you can then
+ * choose to check some class or some internal bool state in subclasses.
+ *
+ * @method isDisabled
+ * @return {Boolean} true/false if the control is disabled or not.
+ */
+ isDisabled : function() {
+ return this.disabled;
+ },
+
+ /**
+ * Sets the activated state for the control. This will add CSS classes to the
+ * element that contains the control. So that it can be activated visually.
+ *
+ * @method setActive
+ * @param {Boolean} s Boolean state if the control should be activated or not.
+ */
+ setActive : function(s) {
+ if (s != this.active) {
+ this.setState('Active', s);
+ this.active = s;
+ this.setAriaProperty('pressed', s);
+ }
+ },
+
+ /**
+ * Returns true/false if the control is disabled or not. This is a method since you can then
+ * choose to check some class or some internal bool state in subclasses.
+ *
+ * @method isActive
+ * @return {Boolean} true/false if the control is disabled or not.
+ */
+ isActive : function() {
+ return this.active;
+ },
+
+ /**
+ * Sets the specified class state for the control.
+ *
+ * @method setState
+ * @param {String} c Class name to add/remove depending on state.
+ * @param {Boolean} s True/false state if the class should be removed or added.
+ */
+ setState : function(c, s) {
+ var n = DOM.get(this.id);
+
+ c = this.classPrefix + c;
+
+ if (s)
+ DOM.addClass(n, c);
+ else
+ DOM.removeClass(n, c);
+ },
+
+ /**
+ * Returns true/false if the control has been rendered or not.
+ *
+ * @method isRendered
+ * @return {Boolean} State if the control has been rendered or not.
+ */
+ isRendered : function() {
+ return this.rendered;
+ },
+
+ /**
+ * Renders the control as a HTML string. This method is much faster than using the DOM and when
+ * creating a whole toolbar with buttons it does make a lot of difference.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the button control element.
+ */
+ renderHTML : function() {
+ },
+
+ /**
+ * Renders the control to the specified container element.
+ *
+ * @method renderTo
+ * @param {Element} n HTML DOM element to add control to.
+ */
+ renderTo : function(n) {
+ DOM.setHTML(n, this.renderHTML());
+ },
+
+ /**
+ * Post render event. This will be executed after the control has been rendered and can be used to
+ * set states, add events to the control etc. It's recommended for subclasses of the control to call this method by using this.parent().
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, b;
+
+ // Set pending states
+ if (is(t.disabled)) {
+ b = t.disabled;
+ t.disabled = -1;
+ t.setDisabled(b);
+ }
+
+ if (is(t.active)) {
+ b = t.active;
+ t.active = -1;
+ t.setActive(b);
+ }
+ },
+
+ /**
+ * Removes the control. This means it will be removed from the DOM and any
+ * events tied to it will also be removed.
+ *
+ * @method remove
+ */
+ remove : function() {
+ DOM.remove(this.id);
+ this.destroy();
+ },
+
+ /**
+ * Destroys the control will free any memory by removing event listeners etc.
+ *
+ * @method destroy
+ */
+ destroy : function() {
+ tinymce.dom.Event.clear(this.id);
+ }
+ });
})(tinymce);
\ No newline at end of file
diff --git a/js/tiny_mce/classes/ui/DropMenu.js b/js/tiny_mce/classes/ui/DropMenu.js
index 81f27a93932..4e218666974 100644
--- a/js/tiny_mce/classes/ui/DropMenu.js
+++ b/js/tiny_mce/classes/ui/DropMenu.js
@@ -1,480 +1,480 @@
-/**
- * DropMenu.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
-
- /**
- * This class is used to create drop menus, a drop menu can be a
- * context menu, or a menu for a list box or a menu bar.
- *
- * @class tinymce.ui.DropMenu
- * @extends tinymce.ui.Menu
- * @example
- * // Adds a menu to the currently active editor instance
- * var dm = tinyMCE.activeEditor.controlManager.createDropMenu('somemenu');
- *
- * // Add some menu items
- * dm.add({title : 'Menu 1', onclick : function() {
- * alert('Item 1 was clicked.');
- * }});
- *
- * dm.add({title : 'Menu 2', onclick : function() {
- * alert('Item 2 was clicked.');
- * }});
- *
- * // Adds a submenu
- * var sub1 = dm.addMenu({title : 'Menu 3'});
- * sub1.add({title : 'Menu 1.1', onclick : function() {
- * alert('Item 1.1 was clicked.');
- * }});
- *
- * // Adds a horizontal separator
- * sub1.addSeparator();
- *
- * sub1.add({title : 'Menu 1.2', onclick : function() {
- * alert('Item 1.2 was clicked.');
- * }});
- *
- * // Adds a submenu to the submenu
- * var sub2 = sub1.addMenu({title : 'Menu 1.3'});
- *
- * // Adds items to the sub sub menu
- * sub2.add({title : 'Menu 1.3.1', onclick : function() {
- * alert('Item 1.3.1 was clicked.');
- * }});
- *
- * sub2.add({title : 'Menu 1.3.2', onclick : function() {
- * alert('Item 1.3.2 was clicked.');
- * }});
- *
- * dm.add({title : 'Menu 4', onclick : function() {
- * alert('Item 3 was clicked.');
- * }});
- *
- * // Display the menu at position 100, 100
- * dm.showMenu(100, 100);
- */
- tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
- /**
- * Constructs a new drop menu control instance.
- *
- * @constructor
- * @method DropMenu
- * @param {String} id Button control id for the button.
- * @param {Object} s Optional name/value settings object.
- */
- DropMenu : function(id, s) {
- s = s || {};
- s.container = s.container || DOM.doc.body;
- s.offset_x = s.offset_x || 0;
- s.offset_y = s.offset_y || 0;
- s.vp_offset_x = s.vp_offset_x || 0;
- s.vp_offset_y = s.vp_offset_y || 0;
-
- if (is(s.icons) && !s.icons)
- s['class'] += ' mceNoIcons';
-
- this.parent(id, s);
- this.onShowMenu = new tinymce.util.Dispatcher(this);
- this.onHideMenu = new tinymce.util.Dispatcher(this);
- this.classPrefix = 'mceMenu';
- },
-
- /**
- * Created a new sub menu for the drop menu control.
- *
- * @method createMenu
- * @param {Object} s Optional name/value settings object.
- * @return {tinymce.ui.DropMenu} New drop menu instance.
- */
- createMenu : function(s) {
- var t = this, cs = t.settings, m;
-
- s.container = s.container || cs.container;
- s.parent = t;
- s.constrain = s.constrain || cs.constrain;
- s['class'] = s['class'] || cs['class'];
- s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x;
- s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y;
- s.keyboard_focus = cs.keyboard_focus;
- m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s);
-
- m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem);
-
- return m;
- },
-
- focus : function() {
- var t = this;
- if (t.keyboardNav) {
- t.keyboardNav.focus();
- }
- },
-
- /**
- * Repaints the menu after new items have been added dynamically.
- *
- * @method update
- */
- update : function() {
- var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
-
- tw = s.max_width ? Math.min(tb.offsetWidth, s.max_width) : tb.offsetWidth;
- th = s.max_height ? Math.min(tb.offsetHeight, s.max_height) : tb.offsetHeight;
-
- if (!DOM.boxModel)
- t.element.setStyles({width : tw + 2, height : th + 2});
- else
- t.element.setStyles({width : tw, height : th});
-
- if (s.max_width)
- DOM.setStyle(co, 'width', tw);
-
- if (s.max_height) {
- DOM.setStyle(co, 'height', th);
-
- if (tb.clientHeight < s.max_height)
- DOM.setStyle(co, 'overflow', 'hidden');
- }
- },
-
- /**
- * Displays the menu at the specified cordinate.
- *
- * @method showMenu
- * @param {Number} x Horizontal position of the menu.
- * @param {Number} y Vertical position of the menu.
- * @param {Numner} px Optional parent X position used when menus are cascading.
- */
- showMenu : function(x, y, px) {
- var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix;
-
- t.collapse(1);
-
- if (t.isMenuVisible)
- return;
-
- if (!t.rendered) {
- co = DOM.add(t.settings.container, t.renderNode());
-
- each(t.items, function(o) {
- o.postRender();
- });
-
- t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
- } else
- co = DOM.get('menu_' + t.id);
-
- // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug
- if (!tinymce.isOpera)
- DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
-
- DOM.show(co);
- t.update();
-
- x += s.offset_x || 0;
- y += s.offset_y || 0;
- vp.w -= 4;
- vp.h -= 4;
-
- // Move inside viewport if not submenu
- if (s.constrain) {
- w = co.clientWidth - ot;
- h = co.clientHeight - ot;
- mx = vp.x + vp.w;
- my = vp.y + vp.h;
-
- if ((x + s.vp_offset_x + w) > mx)
- x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w);
-
- if ((y + s.vp_offset_y + h) > my)
- y = Math.max(0, (my - s.vp_offset_y) - h);
- }
-
- DOM.setStyles(co, {left : x , top : y});
- t.element.update();
-
- t.isMenuVisible = 1;
- t.mouseClickFunc = Event.add(co, 'click', function(e) {
- var m;
-
- e = e.target;
-
- if (e && (e = DOM.getParent(e, 'tr')) && !DOM.hasClass(e, cp + 'ItemSub')) {
- m = t.items[e.id];
-
- if (m.isDisabled())
- return;
-
- dm = t;
-
- while (dm) {
- if (dm.hideMenu)
- dm.hideMenu();
-
- dm = dm.settings.parent;
- }
-
- if (m.settings.onclick)
- m.settings.onclick(e);
-
- return false; // Cancel to fix onbeforeunload problem
- }
- });
-
- if (t.hasMenus()) {
- t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
- var m, r, mi;
-
- e = e.target;
- if (e && (e = DOM.getParent(e, 'tr'))) {
- m = t.items[e.id];
-
- if (t.lastMenu)
- t.lastMenu.collapse(1);
-
- if (m.isDisabled())
- return;
-
- if (e && DOM.hasClass(e, cp + 'ItemSub')) {
- //p = DOM.getPos(s.container);
- r = DOM.getRect(e);
- m.showMenu((r.x + r.w - ot), r.y - ot, r.x);
- t.lastMenu = m;
- DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive');
- }
- }
- });
- }
-
- Event.add(co, 'keydown', t._keyHandler, t);
-
- t.onShowMenu.dispatch(t);
-
- if (s.keyboard_focus) {
- t._setupKeyboardNav();
- }
- },
-
- /**
- * Hides the displayed menu.
- *
- * @method hideMenu
- */
- hideMenu : function(c) {
- var t = this, co = DOM.get('menu_' + t.id), e;
-
- if (!t.isMenuVisible)
- return;
-
- if (t.keyboardNav) t.keyboardNav.destroy();
- Event.remove(co, 'mouseover', t.mouseOverFunc);
- Event.remove(co, 'click', t.mouseClickFunc);
- Event.remove(co, 'keydown', t._keyHandler);
- DOM.hide(co);
- t.isMenuVisible = 0;
-
- if (!c)
- t.collapse(1);
-
- if (t.element)
- t.element.hide();
-
- if (e = DOM.get(t.id))
- DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive');
-
- t.onHideMenu.dispatch(t);
- },
-
- /**
- * Adds a new menu, menu item or sub classes of them to the drop menu.
- *
- * @method add
- * @param {tinymce.ui.Control} o Menu or menu item to add to the drop menu.
- * @return {tinymce.ui.Control} Same as the input control, the menu or menu item.
- */
- add : function(o) {
- var t = this, co;
-
- o = t.parent(o);
-
- if (t.isRendered && (co = DOM.get('menu_' + t.id)))
- t._add(DOM.select('tbody', co)[0], o);
-
- return o;
- },
-
- /**
- * Collapses the menu, this will hide the menu and all menu items.
- *
- * @method collapse
- * @param {Boolean} d Optional deep state. If this is set to true all children will be collapsed as well.
- */
- collapse : function(d) {
- this.parent(d);
- this.hideMenu(1);
- },
-
- /**
- * Removes a specific sub menu or menu item from the drop menu.
- *
- * @method remove
- * @param {tinymce.ui.Control} o Menu item or menu to remove from drop menu.
- * @return {tinymce.ui.Control} Control instance or null if it wasn't found.
- */
- remove : function(o) {
- DOM.remove(o.id);
- this.destroy();
-
- return this.parent(o);
- },
-
- /**
- * Destroys the menu. This will remove the menu from the DOM and any events added to it etc.
- *
- * @method destroy
- */
- destroy : function() {
- var t = this, co = DOM.get('menu_' + t.id);
-
- if (t.keyboardNav) t.keyboardNav.destroy();
- Event.remove(co, 'mouseover', t.mouseOverFunc);
- Event.remove(DOM.select('a', co), 'focus', t.mouseOverFunc);
- Event.remove(co, 'click', t.mouseClickFunc);
- Event.remove(co, 'keydown', t._keyHandler);
-
- if (t.element)
- t.element.remove();
-
- DOM.remove(co);
- },
-
- /**
- * Renders the specified menu node to the dom.
- *
- * @method renderNode
- * @return {Element} Container element for the drop menu.
- */
- renderNode : function() {
- var t = this, s = t.settings, n, tb, co, w;
-
- w = DOM.create('div', {role: 'listbox', id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000;outline:0'});
- if (t.settings.parent) {
- DOM.setAttrib(w, 'aria-parent', 'menu_' + t.settings.parent.id);
- }
- co = DOM.add(w, 'div', {role: 'presentation', id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
- t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
-
- if (s.menu_line)
- DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
-
-// n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
- n = DOM.add(co, 'table', {role: 'presentation', id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
- tb = DOM.add(n, 'tbody');
-
- each(t.items, function(o) {
- t._add(tb, o);
- });
-
- t.rendered = true;
-
- return w;
- },
-
- // Internal functions
- _setupKeyboardNav : function(){
- var contextMenu, menuItems, t=this;
- contextMenu = DOM.get('menu_' + t.id);
- menuItems = DOM.select('a[role=option]', 'menu_' + t.id);
- menuItems.splice(0,0,contextMenu);
- t.keyboardNav = new tinymce.ui.KeyboardNavigation({
- root: 'menu_' + t.id,
- items: menuItems,
- onCancel: function() {
- t.hideMenu();
- },
- enableUpDown: true
- });
- contextMenu.focus();
- },
-
- _keyHandler : function(evt) {
- var t = this, e;
- switch (evt.keyCode) {
- case 37: // Left
- if (t.settings.parent) {
- t.hideMenu();
- t.settings.parent.focus();
- Event.cancel(evt);
- }
- break;
- case 39: // Right
- if (t.mouseOverFunc)
- t.mouseOverFunc(evt);
- break;
- }
- },
-
- _add : function(tb, o) {
- var n, s = o.settings, a, ro, it, cp = this.classPrefix, ic;
-
- if (s.separator) {
- ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
- DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
-
- if (n = ro.previousSibling)
- DOM.addClass(n, 'mceLast');
-
- return;
- }
-
- n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
- n = it = DOM.add(n, s.titleItem ? 'th' : 'td');
- n = a = DOM.add(n, 'a', {id: o.id + '_aria', role: s.titleItem ? 'presentation' : 'option', href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
-
- if (s.parent) {
- DOM.setAttrib(a, 'aria-haspopup', 'true');
- DOM.setAttrib(a, 'aria-owns', 'menu_' + o.id);
- }
-
- DOM.addClass(it, s['class']);
-// n = DOM.add(n, 'span', {'class' : 'item'});
-
- ic = DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
-
- if (s.icon_src)
- DOM.add(ic, 'img', {src : s.icon_src});
-
- n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
-
- if (o.settings.style) {
- if (typeof o.settings.style == "function")
- o.settings.style = o.settings.style();
-
- DOM.setAttrib(n, 'style', o.settings.style);
- }
-
- if (tb.childNodes.length == 1)
- DOM.addClass(ro, 'mceFirst');
-
- if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator'))
- DOM.addClass(ro, 'mceFirst');
-
- if (o.collapse)
- DOM.addClass(ro, cp + 'ItemSub');
-
- if (n = ro.previousSibling)
- DOM.removeClass(n, 'mceLast');
-
- DOM.addClass(ro, 'mceLast');
- }
- });
+/**
+ * DropMenu.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
+
+ /**
+ * This class is used to create drop menus, a drop menu can be a
+ * context menu, or a menu for a list box or a menu bar.
+ *
+ * @class tinymce.ui.DropMenu
+ * @extends tinymce.ui.Menu
+ * @example
+ * // Adds a menu to the currently active editor instance
+ * var dm = tinyMCE.activeEditor.controlManager.createDropMenu('somemenu');
+ *
+ * // Add some menu items
+ * dm.add({title : 'Menu 1', onclick : function() {
+ * alert('Item 1 was clicked.');
+ * }});
+ *
+ * dm.add({title : 'Menu 2', onclick : function() {
+ * alert('Item 2 was clicked.');
+ * }});
+ *
+ * // Adds a submenu
+ * var sub1 = dm.addMenu({title : 'Menu 3'});
+ * sub1.add({title : 'Menu 1.1', onclick : function() {
+ * alert('Item 1.1 was clicked.');
+ * }});
+ *
+ * // Adds a horizontal separator
+ * sub1.addSeparator();
+ *
+ * sub1.add({title : 'Menu 1.2', onclick : function() {
+ * alert('Item 1.2 was clicked.');
+ * }});
+ *
+ * // Adds a submenu to the submenu
+ * var sub2 = sub1.addMenu({title : 'Menu 1.3'});
+ *
+ * // Adds items to the sub sub menu
+ * sub2.add({title : 'Menu 1.3.1', onclick : function() {
+ * alert('Item 1.3.1 was clicked.');
+ * }});
+ *
+ * sub2.add({title : 'Menu 1.3.2', onclick : function() {
+ * alert('Item 1.3.2 was clicked.');
+ * }});
+ *
+ * dm.add({title : 'Menu 4', onclick : function() {
+ * alert('Item 3 was clicked.');
+ * }});
+ *
+ * // Display the menu at position 100, 100
+ * dm.showMenu(100, 100);
+ */
+ tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
+ /**
+ * Constructs a new drop menu control instance.
+ *
+ * @constructor
+ * @method DropMenu
+ * @param {String} id Button control id for the button.
+ * @param {Object} s Optional name/value settings object.
+ */
+ DropMenu : function(id, s) {
+ s = s || {};
+ s.container = s.container || DOM.doc.body;
+ s.offset_x = s.offset_x || 0;
+ s.offset_y = s.offset_y || 0;
+ s.vp_offset_x = s.vp_offset_x || 0;
+ s.vp_offset_y = s.vp_offset_y || 0;
+
+ if (is(s.icons) && !s.icons)
+ s['class'] += ' mceNoIcons';
+
+ this.parent(id, s);
+ this.onShowMenu = new tinymce.util.Dispatcher(this);
+ this.onHideMenu = new tinymce.util.Dispatcher(this);
+ this.classPrefix = 'mceMenu';
+ },
+
+ /**
+ * Created a new sub menu for the drop menu control.
+ *
+ * @method createMenu
+ * @param {Object} s Optional name/value settings object.
+ * @return {tinymce.ui.DropMenu} New drop menu instance.
+ */
+ createMenu : function(s) {
+ var t = this, cs = t.settings, m;
+
+ s.container = s.container || cs.container;
+ s.parent = t;
+ s.constrain = s.constrain || cs.constrain;
+ s['class'] = s['class'] || cs['class'];
+ s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x;
+ s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y;
+ s.keyboard_focus = cs.keyboard_focus;
+ m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s);
+
+ m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem);
+
+ return m;
+ },
+
+ focus : function() {
+ var t = this;
+ if (t.keyboardNav) {
+ t.keyboardNav.focus();
+ }
+ },
+
+ /**
+ * Repaints the menu after new items have been added dynamically.
+ *
+ * @method update
+ */
+ update : function() {
+ var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
+
+ tw = s.max_width ? Math.min(tb.offsetWidth, s.max_width) : tb.offsetWidth;
+ th = s.max_height ? Math.min(tb.offsetHeight, s.max_height) : tb.offsetHeight;
+
+ if (!DOM.boxModel)
+ t.element.setStyles({width : tw + 2, height : th + 2});
+ else
+ t.element.setStyles({width : tw, height : th});
+
+ if (s.max_width)
+ DOM.setStyle(co, 'width', tw);
+
+ if (s.max_height) {
+ DOM.setStyle(co, 'height', th);
+
+ if (tb.clientHeight < s.max_height)
+ DOM.setStyle(co, 'overflow', 'hidden');
+ }
+ },
+
+ /**
+ * Displays the menu at the specified cordinate.
+ *
+ * @method showMenu
+ * @param {Number} x Horizontal position of the menu.
+ * @param {Number} y Vertical position of the menu.
+ * @param {Numner} px Optional parent X position used when menus are cascading.
+ */
+ showMenu : function(x, y, px) {
+ var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix;
+
+ t.collapse(1);
+
+ if (t.isMenuVisible)
+ return;
+
+ if (!t.rendered) {
+ co = DOM.add(t.settings.container, t.renderNode());
+
+ each(t.items, function(o) {
+ o.postRender();
+ });
+
+ t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
+ } else
+ co = DOM.get('menu_' + t.id);
+
+ // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug
+ if (!tinymce.isOpera)
+ DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
+
+ DOM.show(co);
+ t.update();
+
+ x += s.offset_x || 0;
+ y += s.offset_y || 0;
+ vp.w -= 4;
+ vp.h -= 4;
+
+ // Move inside viewport if not submenu
+ if (s.constrain) {
+ w = co.clientWidth - ot;
+ h = co.clientHeight - ot;
+ mx = vp.x + vp.w;
+ my = vp.y + vp.h;
+
+ if ((x + s.vp_offset_x + w) > mx)
+ x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w);
+
+ if ((y + s.vp_offset_y + h) > my)
+ y = Math.max(0, (my - s.vp_offset_y) - h);
+ }
+
+ DOM.setStyles(co, {left : x , top : y});
+ t.element.update();
+
+ t.isMenuVisible = 1;
+ t.mouseClickFunc = Event.add(co, 'click', function(e) {
+ var m;
+
+ e = e.target;
+
+ if (e && (e = DOM.getParent(e, 'tr')) && !DOM.hasClass(e, cp + 'ItemSub')) {
+ m = t.items[e.id];
+
+ if (m.isDisabled())
+ return;
+
+ dm = t;
+
+ while (dm) {
+ if (dm.hideMenu)
+ dm.hideMenu();
+
+ dm = dm.settings.parent;
+ }
+
+ if (m.settings.onclick)
+ m.settings.onclick(e);
+
+ return false; // Cancel to fix onbeforeunload problem
+ }
+ });
+
+ if (t.hasMenus()) {
+ t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
+ var m, r, mi;
+
+ e = e.target;
+ if (e && (e = DOM.getParent(e, 'tr'))) {
+ m = t.items[e.id];
+
+ if (t.lastMenu)
+ t.lastMenu.collapse(1);
+
+ if (m.isDisabled())
+ return;
+
+ if (e && DOM.hasClass(e, cp + 'ItemSub')) {
+ //p = DOM.getPos(s.container);
+ r = DOM.getRect(e);
+ m.showMenu((r.x + r.w - ot), r.y - ot, r.x);
+ t.lastMenu = m;
+ DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive');
+ }
+ }
+ });
+ }
+
+ Event.add(co, 'keydown', t._keyHandler, t);
+
+ t.onShowMenu.dispatch(t);
+
+ if (s.keyboard_focus) {
+ t._setupKeyboardNav();
+ }
+ },
+
+ /**
+ * Hides the displayed menu.
+ *
+ * @method hideMenu
+ */
+ hideMenu : function(c) {
+ var t = this, co = DOM.get('menu_' + t.id), e;
+
+ if (!t.isMenuVisible)
+ return;
+
+ if (t.keyboardNav) t.keyboardNav.destroy();
+ Event.remove(co, 'mouseover', t.mouseOverFunc);
+ Event.remove(co, 'click', t.mouseClickFunc);
+ Event.remove(co, 'keydown', t._keyHandler);
+ DOM.hide(co);
+ t.isMenuVisible = 0;
+
+ if (!c)
+ t.collapse(1);
+
+ if (t.element)
+ t.element.hide();
+
+ if (e = DOM.get(t.id))
+ DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive');
+
+ t.onHideMenu.dispatch(t);
+ },
+
+ /**
+ * Adds a new menu, menu item or sub classes of them to the drop menu.
+ *
+ * @method add
+ * @param {tinymce.ui.Control} o Menu or menu item to add to the drop menu.
+ * @return {tinymce.ui.Control} Same as the input control, the menu or menu item.
+ */
+ add : function(o) {
+ var t = this, co;
+
+ o = t.parent(o);
+
+ if (t.isRendered && (co = DOM.get('menu_' + t.id)))
+ t._add(DOM.select('tbody', co)[0], o);
+
+ return o;
+ },
+
+ /**
+ * Collapses the menu, this will hide the menu and all menu items.
+ *
+ * @method collapse
+ * @param {Boolean} d Optional deep state. If this is set to true all children will be collapsed as well.
+ */
+ collapse : function(d) {
+ this.parent(d);
+ this.hideMenu(1);
+ },
+
+ /**
+ * Removes a specific sub menu or menu item from the drop menu.
+ *
+ * @method remove
+ * @param {tinymce.ui.Control} o Menu item or menu to remove from drop menu.
+ * @return {tinymce.ui.Control} Control instance or null if it wasn't found.
+ */
+ remove : function(o) {
+ DOM.remove(o.id);
+ this.destroy();
+
+ return this.parent(o);
+ },
+
+ /**
+ * Destroys the menu. This will remove the menu from the DOM and any events added to it etc.
+ *
+ * @method destroy
+ */
+ destroy : function() {
+ var t = this, co = DOM.get('menu_' + t.id);
+
+ if (t.keyboardNav) t.keyboardNav.destroy();
+ Event.remove(co, 'mouseover', t.mouseOverFunc);
+ Event.remove(DOM.select('a', co), 'focus', t.mouseOverFunc);
+ Event.remove(co, 'click', t.mouseClickFunc);
+ Event.remove(co, 'keydown', t._keyHandler);
+
+ if (t.element)
+ t.element.remove();
+
+ DOM.remove(co);
+ },
+
+ /**
+ * Renders the specified menu node to the dom.
+ *
+ * @method renderNode
+ * @return {Element} Container element for the drop menu.
+ */
+ renderNode : function() {
+ var t = this, s = t.settings, n, tb, co, w;
+
+ w = DOM.create('div', {role: 'listbox', id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000;outline:0'});
+ if (t.settings.parent) {
+ DOM.setAttrib(w, 'aria-parent', 'menu_' + t.settings.parent.id);
+ }
+ co = DOM.add(w, 'div', {role: 'presentation', id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
+ t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
+
+ if (s.menu_line)
+ DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
+
+// n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
+ n = DOM.add(co, 'table', {role: 'presentation', id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
+ tb = DOM.add(n, 'tbody');
+
+ each(t.items, function(o) {
+ t._add(tb, o);
+ });
+
+ t.rendered = true;
+
+ return w;
+ },
+
+ // Internal functions
+ _setupKeyboardNav : function(){
+ var contextMenu, menuItems, t=this;
+ contextMenu = DOM.get('menu_' + t.id);
+ menuItems = DOM.select('a[role=option]', 'menu_' + t.id);
+ menuItems.splice(0,0,contextMenu);
+ t.keyboardNav = new tinymce.ui.KeyboardNavigation({
+ root: 'menu_' + t.id,
+ items: menuItems,
+ onCancel: function() {
+ t.hideMenu();
+ },
+ enableUpDown: true
+ });
+ contextMenu.focus();
+ },
+
+ _keyHandler : function(evt) {
+ var t = this, e;
+ switch (evt.keyCode) {
+ case 37: // Left
+ if (t.settings.parent) {
+ t.hideMenu();
+ t.settings.parent.focus();
+ Event.cancel(evt);
+ }
+ break;
+ case 39: // Right
+ if (t.mouseOverFunc)
+ t.mouseOverFunc(evt);
+ break;
+ }
+ },
+
+ _add : function(tb, o) {
+ var n, s = o.settings, a, ro, it, cp = this.classPrefix, ic;
+
+ if (s.separator) {
+ ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
+ DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
+
+ if (n = ro.previousSibling)
+ DOM.addClass(n, 'mceLast');
+
+ return;
+ }
+
+ n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
+ n = it = DOM.add(n, s.titleItem ? 'th' : 'td');
+ n = a = DOM.add(n, 'a', {id: o.id + '_aria', role: s.titleItem ? 'presentation' : 'option', href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
+
+ if (s.parent) {
+ DOM.setAttrib(a, 'aria-haspopup', 'true');
+ DOM.setAttrib(a, 'aria-owns', 'menu_' + o.id);
+ }
+
+ DOM.addClass(it, s['class']);
+// n = DOM.add(n, 'span', {'class' : 'item'});
+
+ ic = DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
+
+ if (s.icon_src)
+ DOM.add(ic, 'img', {src : s.icon_src});
+
+ n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
+
+ if (o.settings.style) {
+ if (typeof o.settings.style == "function")
+ o.settings.style = o.settings.style();
+
+ DOM.setAttrib(n, 'style', o.settings.style);
+ }
+
+ if (tb.childNodes.length == 1)
+ DOM.addClass(ro, 'mceFirst');
+
+ if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator'))
+ DOM.addClass(ro, 'mceFirst');
+
+ if (o.collapse)
+ DOM.addClass(ro, cp + 'ItemSub');
+
+ if (n = ro.previousSibling)
+ DOM.removeClass(n, 'mceLast');
+
+ DOM.addClass(ro, 'mceLast');
+ }
+ });
})(tinymce);
\ No newline at end of file
diff --git a/js/tiny_mce/classes/ui/KeyboardNavigation.js b/js/tiny_mce/classes/ui/KeyboardNavigation.js
index 359e8501d02..a9b95229f56 100644
--- a/js/tiny_mce/classes/ui/KeyboardNavigation.js
+++ b/js/tiny_mce/classes/ui/KeyboardNavigation.js
@@ -1,193 +1,193 @@
-/**
- * KeyboardNavigation.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var Event = tinymce.dom.Event, each = tinymce.each;
-
- /**
- * This class provides basic keyboard navigation using the arrow keys to children of a component.
- * For example, this class handles moving between the buttons on the toolbars.
- *
- * @class tinymce.ui.KeyboardNavigation
- */
- tinymce.create('tinymce.ui.KeyboardNavigation', {
- /**
- * Create a new KeyboardNavigation instance to handle the focus for a specific element.
- *
- * @constructor
- * @method KeyboardNavigation
- * @param {Object} settings the settings object to define how keyboard navigation works.
- * @param {DOMUtils} dom the DOMUtils instance to use.
- *
- * @setting {Element/String} root the root element or ID of the root element for the control.
- * @setting {Array} items an array containing the items to move focus between. Every object in this array must have an id attribute which maps to the actual DOM element. If the actual elements are passed without an ID then one is automatically assigned.
- * @setting {Function} onCancel the callback for when the user presses escape or otherwise indicates cancelling.
- * @setting {Function} onAction (optional) the action handler to call when the user activates an item.
- * @setting {Boolean} enableLeftRight (optional, default) when true, the up/down arrows move through items.
- * @setting {Boolean} enableUpDown (optional) when true, the up/down arrows move through items.
- * Note for both up/down and left/right explicitly set both enableLeftRight and enableUpDown to true.
- */
- KeyboardNavigation: function(settings, dom) {
- var t = this, root = settings.root, items = settings.items,
- enableUpDown = settings.enableUpDown, enableLeftRight = settings.enableLeftRight || !settings.enableUpDown,
- excludeFromTabOrder = settings.excludeFromTabOrder,
- itemFocussed, itemBlurred, rootKeydown, rootFocussed, focussedId;
-
- dom = dom || tinymce.DOM;
-
- itemFocussed = function(evt) {
- focussedId = evt.target.id;
- };
-
- itemBlurred = function(evt) {
- dom.setAttrib(evt.target.id, 'tabindex', '-1');
- };
-
- rootFocussed = function(evt) {
- var item = dom.get(focussedId);
- dom.setAttrib(item, 'tabindex', '0');
- item.focus();
- };
-
- t.focus = function() {
- dom.get(focussedId).focus();
- };
-
- /**
- * Destroys the KeyboardNavigation and unbinds any focus/blur event handles it might have added.
- *
- * @method destroy
- */
- t.destroy = function() {
- each(items, function(item) {
- var elm = dom.get(item.id);
-
- dom.unbind(elm, 'focus', itemFocussed);
- dom.unbind(elm, 'blur', itemBlurred);
- });
-
- var rootElm = dom.get(root);
- dom.unbind(rootElm, 'focus', rootFocussed);
- dom.unbind(rootElm, 'keydown', rootKeydown);
-
- items = dom = root = t.focus = itemFocussed = itemBlurred = rootKeydown = rootFocussed = null;
- t.destroy = function() {};
- };
-
- t.moveFocus = function(dir, evt) {
- var idx = -1, controls = t.controls, newFocus;
-
- if (!focussedId)
- return;
-
- each(items, function(item, index) {
- if (item.id === focussedId) {
- idx = index;
- return false;
- }
- });
-
- idx += dir;
- if (idx < 0) {
- idx = items.length - 1;
- } else if (idx >= items.length) {
- idx = 0;
- }
-
- newFocus = items[idx];
- dom.setAttrib(focussedId, 'tabindex', '-1');
- dom.setAttrib(newFocus.id, 'tabindex', '0');
- dom.get(newFocus.id).focus();
-
- if (settings.actOnFocus) {
- settings.onAction(newFocus.id);
- }
-
- if (evt)
- Event.cancel(evt);
- };
-
- rootKeydown = function(evt) {
- var DOM_VK_LEFT = 37, DOM_VK_RIGHT = 39, DOM_VK_UP = 38, DOM_VK_DOWN = 40, DOM_VK_ESCAPE = 27, DOM_VK_ENTER = 14, DOM_VK_RETURN = 13, DOM_VK_SPACE = 32;
-
- switch (evt.keyCode) {
- case DOM_VK_LEFT:
- if (enableLeftRight) t.moveFocus(-1);
- Event.cancel(evt);
- break;
-
- case DOM_VK_RIGHT:
- if (enableLeftRight) t.moveFocus(1);
- Event.cancel(evt);
- break;
-
- case DOM_VK_UP:
- if (enableUpDown) t.moveFocus(-1);
- Event.cancel(evt);
- break;
-
- case DOM_VK_DOWN:
- if (enableUpDown) t.moveFocus(1);
- Event.cancel(evt);
- break;
-
- case DOM_VK_ESCAPE:
- if (settings.onCancel) {
- settings.onCancel();
- Event.cancel(evt);
- }
- break;
-
- case DOM_VK_ENTER:
- case DOM_VK_RETURN:
- case DOM_VK_SPACE:
- if (settings.onAction) {
- settings.onAction(focussedId);
- Event.cancel(evt);
- }
- break;
- }
- };
-
- // Set up state and listeners for each item.
- each(items, function(item, idx) {
- var tabindex, elm;
-
- if (!item.id) {
- item.id = dom.uniqueId('_mce_item_');
- }
-
- elm = dom.get(item.id);
-
- if (excludeFromTabOrder) {
- dom.bind(elm, 'blur', itemBlurred);
- tabindex = '-1';
- } else {
- tabindex = (idx === 0 ? '0' : '-1');
- }
-
- elm.setAttribute('tabindex', tabindex);
- dom.bind(elm, 'focus', itemFocussed);
- });
-
- // Setup initial state for root element.
- if (items[0]){
- focussedId = items[0].id;
- }
-
- dom.setAttrib(root, 'tabindex', '-1');
-
- // Setup listeners for root element.
- var rootElm = dom.get(root);
- dom.bind(rootElm, 'focus', rootFocussed);
- dom.bind(rootElm, 'keydown', rootKeydown);
- }
- });
-})(tinymce);
+/**
+ * KeyboardNavigation.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var Event = tinymce.dom.Event, each = tinymce.each;
+
+ /**
+ * This class provides basic keyboard navigation using the arrow keys to children of a component.
+ * For example, this class handles moving between the buttons on the toolbars.
+ *
+ * @class tinymce.ui.KeyboardNavigation
+ */
+ tinymce.create('tinymce.ui.KeyboardNavigation', {
+ /**
+ * Create a new KeyboardNavigation instance to handle the focus for a specific element.
+ *
+ * @constructor
+ * @method KeyboardNavigation
+ * @param {Object} settings the settings object to define how keyboard navigation works.
+ * @param {DOMUtils} dom the DOMUtils instance to use.
+ *
+ * @setting {Element/String} root the root element or ID of the root element for the control.
+ * @setting {Array} items an array containing the items to move focus between. Every object in this array must have an id attribute which maps to the actual DOM element. If the actual elements are passed without an ID then one is automatically assigned.
+ * @setting {Function} onCancel the callback for when the user presses escape or otherwise indicates cancelling.
+ * @setting {Function} onAction (optional) the action handler to call when the user activates an item.
+ * @setting {Boolean} enableLeftRight (optional, default) when true, the up/down arrows move through items.
+ * @setting {Boolean} enableUpDown (optional) when true, the up/down arrows move through items.
+ * Note for both up/down and left/right explicitly set both enableLeftRight and enableUpDown to true.
+ */
+ KeyboardNavigation: function(settings, dom) {
+ var t = this, root = settings.root, items = settings.items,
+ enableUpDown = settings.enableUpDown, enableLeftRight = settings.enableLeftRight || !settings.enableUpDown,
+ excludeFromTabOrder = settings.excludeFromTabOrder,
+ itemFocussed, itemBlurred, rootKeydown, rootFocussed, focussedId;
+
+ dom = dom || tinymce.DOM;
+
+ itemFocussed = function(evt) {
+ focussedId = evt.target.id;
+ };
+
+ itemBlurred = function(evt) {
+ dom.setAttrib(evt.target.id, 'tabindex', '-1');
+ };
+
+ rootFocussed = function(evt) {
+ var item = dom.get(focussedId);
+ dom.setAttrib(item, 'tabindex', '0');
+ item.focus();
+ };
+
+ t.focus = function() {
+ dom.get(focussedId).focus();
+ };
+
+ /**
+ * Destroys the KeyboardNavigation and unbinds any focus/blur event handles it might have added.
+ *
+ * @method destroy
+ */
+ t.destroy = function() {
+ each(items, function(item) {
+ var elm = dom.get(item.id);
+
+ dom.unbind(elm, 'focus', itemFocussed);
+ dom.unbind(elm, 'blur', itemBlurred);
+ });
+
+ var rootElm = dom.get(root);
+ dom.unbind(rootElm, 'focus', rootFocussed);
+ dom.unbind(rootElm, 'keydown', rootKeydown);
+
+ items = dom = root = t.focus = itemFocussed = itemBlurred = rootKeydown = rootFocussed = null;
+ t.destroy = function() {};
+ };
+
+ t.moveFocus = function(dir, evt) {
+ var idx = -1, controls = t.controls, newFocus;
+
+ if (!focussedId)
+ return;
+
+ each(items, function(item, index) {
+ if (item.id === focussedId) {
+ idx = index;
+ return false;
+ }
+ });
+
+ idx += dir;
+ if (idx < 0) {
+ idx = items.length - 1;
+ } else if (idx >= items.length) {
+ idx = 0;
+ }
+
+ newFocus = items[idx];
+ dom.setAttrib(focussedId, 'tabindex', '-1');
+ dom.setAttrib(newFocus.id, 'tabindex', '0');
+ dom.get(newFocus.id).focus();
+
+ if (settings.actOnFocus) {
+ settings.onAction(newFocus.id);
+ }
+
+ if (evt)
+ Event.cancel(evt);
+ };
+
+ rootKeydown = function(evt) {
+ var DOM_VK_LEFT = 37, DOM_VK_RIGHT = 39, DOM_VK_UP = 38, DOM_VK_DOWN = 40, DOM_VK_ESCAPE = 27, DOM_VK_ENTER = 14, DOM_VK_RETURN = 13, DOM_VK_SPACE = 32;
+
+ switch (evt.keyCode) {
+ case DOM_VK_LEFT:
+ if (enableLeftRight) t.moveFocus(-1);
+ Event.cancel(evt);
+ break;
+
+ case DOM_VK_RIGHT:
+ if (enableLeftRight) t.moveFocus(1);
+ Event.cancel(evt);
+ break;
+
+ case DOM_VK_UP:
+ if (enableUpDown) t.moveFocus(-1);
+ Event.cancel(evt);
+ break;
+
+ case DOM_VK_DOWN:
+ if (enableUpDown) t.moveFocus(1);
+ Event.cancel(evt);
+ break;
+
+ case DOM_VK_ESCAPE:
+ if (settings.onCancel) {
+ settings.onCancel();
+ Event.cancel(evt);
+ }
+ break;
+
+ case DOM_VK_ENTER:
+ case DOM_VK_RETURN:
+ case DOM_VK_SPACE:
+ if (settings.onAction) {
+ settings.onAction(focussedId);
+ Event.cancel(evt);
+ }
+ break;
+ }
+ };
+
+ // Set up state and listeners for each item.
+ each(items, function(item, idx) {
+ var tabindex, elm;
+
+ if (!item.id) {
+ item.id = dom.uniqueId('_mce_item_');
+ }
+
+ elm = dom.get(item.id);
+
+ if (excludeFromTabOrder) {
+ dom.bind(elm, 'blur', itemBlurred);
+ tabindex = '-1';
+ } else {
+ tabindex = (idx === 0 ? '0' : '-1');
+ }
+
+ elm.setAttribute('tabindex', tabindex);
+ dom.bind(elm, 'focus', itemFocussed);
+ });
+
+ // Setup initial state for root element.
+ if (items[0]){
+ focussedId = items[0].id;
+ }
+
+ dom.setAttrib(root, 'tabindex', '-1');
+
+ // Setup listeners for root element.
+ var rootElm = dom.get(root);
+ dom.bind(rootElm, 'focus', rootFocussed);
+ dom.bind(rootElm, 'keydown', rootKeydown);
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/ListBox.js b/js/tiny_mce/classes/ui/ListBox.js
index b5e2f5f8346..c1af63dcfea 100644
--- a/js/tiny_mce/classes/ui/ListBox.js
+++ b/js/tiny_mce/classes/ui/ListBox.js
@@ -1,448 +1,448 @@
-/**
- * ListBox.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, undef;
-
- /**
- * This class is used to create list boxes/select list. This one will generate
- * a non native control. This one has the benefits of having visual items added.
- *
- * @class tinymce.ui.ListBox
- * @extends tinymce.ui.Control
- * @example
- * // Creates a new plugin class and a custom listbox
- * tinymce.create('tinymce.plugins.ExamplePlugin', {
- * createControl: function(n, cm) {
- * switch (n) {
- * case 'mylistbox':
- * var mlb = cm.createListBox('mylistbox', {
- * title : 'My list box',
- * onselect : function(v) {
- * tinyMCE.activeEditor.windowManager.alert('Value selected:' + v);
- * }
- * });
- *
- * // Add some values to the list box
- * mlb.add('Some item 1', 'val1');
- * mlb.add('some item 2', 'val2');
- * mlb.add('some item 3', 'val3');
- *
- * // Return the new listbox instance
- * return mlb;
- * }
- *
- * return null;
- * }
- * });
- *
- * // Register plugin with a short name
- * tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin);
- *
- * // Initialize TinyMCE with the new plugin and button
- * tinyMCE.init({
- * ...
- * plugins : '-example', // - means TinyMCE will not try to load it
- * theme_advanced_buttons1 : 'mylistbox' // Add the new example listbox to the toolbar
- * });
- */
- tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
- /**
- * Constructs a new listbox control instance.
- *
- * @constructor
- * @method ListBox
- * @param {String} id Control id for the list box.
- * @param {Object} s Optional name/value settings object.
- * @param {Editor} ed Optional the editor instance this button is for.
- */
- ListBox : function(id, s, ed) {
- var t = this;
-
- t.parent(id, s, ed);
-
- /**
- * Array of ListBox items.
- *
- * @property items
- * @type Array
- */
- t.items = [];
-
- /**
- * Fires when the selection has been changed.
- *
- * @event onChange
- */
- t.onChange = new Dispatcher(t);
-
- /**
- * Fires after the element has been rendered to DOM.
- *
- * @event onPostRender
- */
- t.onPostRender = new Dispatcher(t);
-
- /**
- * Fires when a new item is added.
- *
- * @event onAdd
- */
- t.onAdd = new Dispatcher(t);
-
- /**
- * Fires when the menu gets rendered.
- *
- * @event onRenderMenu
- */
- t.onRenderMenu = new tinymce.util.Dispatcher(this);
-
- t.classPrefix = 'mceListBox';
- t.marked = {};
- },
-
- /**
- * Selects a item/option by value. This will both add a visual selection to the
- * item and change the title of the control to the title of the option.
- *
- * @method select
- * @param {String/function} va Value to look for inside the list box or a function selector.
- */
- select : function(va) {
- var t = this, fv, f;
-
- t.marked = {};
-
- if (va == undef)
- return t.selectByIndex(-1);
-
- // Is string or number make function selector
- if (va && typeof(va)=="function")
- f = va;
- else {
- f = function(v) {
- return v == va;
- };
- }
-
- // Do we need to do something?
- if (va != t.selectedValue) {
- // Find item
- each(t.items, function(o, i) {
- if (f(o.value)) {
- fv = 1;
- t.selectByIndex(i);
- return false;
- }
- });
-
- if (!fv)
- t.selectByIndex(-1);
- }
- },
-
- /**
- * Selects a item/option by index. This will both add a visual selection to the
- * item and change the title of the control to the title of the option.
- *
- * @method selectByIndex
- * @param {String} idx Index to select, pass -1 to select menu/title of select box.
- */
- selectByIndex : function(idx) {
- var t = this, e, o, label;
-
- t.marked = {};
-
- if (idx != t.selectedIndex) {
- e = DOM.get(t.id + '_text');
- label = DOM.get(t.id + '_voiceDesc');
- o = t.items[idx];
-
- if (o) {
- t.selectedValue = o.value;
- t.selectedIndex = idx;
- DOM.setHTML(e, DOM.encode(o.title));
- DOM.setHTML(label, t.settings.title + " - " + o.title);
- DOM.removeClass(e, 'mceTitle');
- DOM.setAttrib(t.id, 'aria-valuenow', o.title);
- } else {
- DOM.setHTML(e, DOM.encode(t.settings.title));
- DOM.setHTML(label, DOM.encode(t.settings.title));
- DOM.addClass(e, 'mceTitle');
- t.selectedValue = t.selectedIndex = null;
- DOM.setAttrib(t.id, 'aria-valuenow', t.settings.title);
- }
- e = 0;
- }
- },
-
- /**
- * Marks a specific item by name. Marked values are optional items to mark as active.
- *
- * @param {String} value Value item to mark.
- */
- mark : function(value) {
- this.marked[value] = true;
- },
-
- /**
- * Adds a option item to the list box.
- *
- * @method add
- * @param {String} n Title for the new option.
- * @param {String} v Value for the new option.
- * @param {Object} o Optional object with settings like for example class.
- */
- add : function(n, v, o) {
- var t = this;
-
- o = o || {};
- o = tinymce.extend(o, {
- title : n,
- value : v
- });
-
- t.items.push(o);
- t.onAdd.dispatch(t, o);
- },
-
- /**
- * Returns the number of items inside the list box.
- *
- * @method getLength
- * @param {Number} Number of items inside the list box.
- */
- getLength : function() {
- return this.items.length;
- },
-
- /**
- * Renders the list box as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the list box control element.
- */
- renderHTML : function() {
- var h = '', t = this, s = t.settings, cp = t.classPrefix;
-
- h = '
';
-
- return h;
- },
-
- /**
- * Displays the drop menu with all items.
- *
- * @method showMenu
- */
- showMenu : function() {
- var t = this, p2, e = DOM.get(this.id), m;
-
- if (t.isDisabled() || t.items.length === 0)
- return;
-
- if (t.menu && t.menu.isMenuVisible)
- return t.hideMenu();
-
- if (!t.isMenuRendered) {
- t.renderMenu();
- t.isMenuRendered = true;
- }
-
- p2 = DOM.getPos(e);
-
- m = t.menu;
- m.settings.offset_x = p2.x;
- m.settings.offset_y = p2.y;
- m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
-
- // Select in menu
- each(t.items, function(o) {
- if (m.items[o.id]) {
- m.items[o.id].setSelected(0);
- }
- });
-
- each(t.items, function(o) {
- if (m.items[o.id] && t.marked[o.value]) {
- m.items[o.id].setSelected(1);
- }
-
- if (o.value === t.selectedValue) {
- m.items[o.id].setSelected(1);
- }
- });
-
- m.showMenu(0, e.clientHeight);
-
- Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
- DOM.addClass(t.id, t.classPrefix + 'Selected');
-
- //DOM.get(t.id + '_text').focus();
- },
-
- /**
- * Hides the drop menu.
- *
- * @method hideMenu
- */
- hideMenu : function(e) {
- var t = this;
-
- if (t.menu && t.menu.isMenuVisible) {
- DOM.removeClass(t.id, t.classPrefix + 'Selected');
-
- // Prevent double toogles by canceling the mouse click event to the button
- if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
- return;
-
- if (!e || !DOM.getParent(e.target, '.mceMenu')) {
- DOM.removeClass(t.id, t.classPrefix + 'Selected');
- Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
- t.menu.hideMenu();
- }
- }
- },
-
- /**
- * Renders the menu to the DOM.
- *
- * @method renderMenu
- */
- renderMenu : function() {
- var t = this, m;
-
- m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
- menu_line : 1,
- 'class' : t.classPrefix + 'Menu mceNoIcons',
- max_width : 250,
- max_height : 150
- });
-
- m.onHideMenu.add(function() {
- t.hideMenu();
- t.focus();
- });
-
- m.add({
- title : t.settings.title,
- 'class' : 'mceMenuItemTitle',
- onclick : function() {
- if (t.settings.onselect('') !== false)
- t.select(''); // Must be runned after
- }
- });
-
- each(t.items, function(o) {
- // No value then treat it as a title
- if (o.value === undef) {
- m.add({
- title : o.title,
- role : "option",
- 'class' : 'mceMenuItemTitle',
- onclick : function() {
- if (t.settings.onselect('') !== false)
- t.select(''); // Must be runned after
- }
- });
- } else {
- o.id = DOM.uniqueId();
- o.role= "option";
- o.onclick = function() {
- if (t.settings.onselect(o.value) !== false)
- t.select(o.value); // Must be runned after
- };
-
- m.add(o);
- }
- });
-
- t.onRenderMenu.dispatch(t, m);
- t.menu = m;
- },
-
- /**
- * Post render event. This will be executed after the control has been rendered and can be used to
- * set states, add events to the control etc. It's recommended for subclasses of the control to call this method by using this.parent().
- *
- * @method postRender
- */
- postRender : function() {
- var t = this, cp = t.classPrefix;
-
- Event.add(t.id, 'click', t.showMenu, t);
- Event.add(t.id, 'keydown', function(evt) {
- if (evt.keyCode == 32) { // Space
- t.showMenu(evt);
- Event.cancel(evt);
- }
- });
- Event.add(t.id, 'focus', function() {
- if (!t._focused) {
- t.keyDownHandler = Event.add(t.id, 'keydown', function(e) {
- if (e.keyCode == 40) {
- t.showMenu();
- Event.cancel(e);
- }
- });
- t.keyPressHandler = Event.add(t.id, 'keypress', function(e) {
- var v;
- if (e.keyCode == 13) {
- // Fake select on enter
- v = t.selectedValue;
- t.selectedValue = null; // Needs to be null to fake change
- Event.cancel(e);
- t.settings.onselect(v);
- }
- });
- }
-
- t._focused = 1;
- });
- Event.add(t.id, 'blur', function() {
- Event.remove(t.id, 'keydown', t.keyDownHandler);
- Event.remove(t.id, 'keypress', t.keyPressHandler);
- t._focused = 0;
- });
-
- // Old IE doesn't have hover on all elements
- if (tinymce.isIE6 || !DOM.boxModel) {
- Event.add(t.id, 'mouseover', function() {
- if (!DOM.hasClass(t.id, cp + 'Disabled'))
- DOM.addClass(t.id, cp + 'Hover');
- });
-
- Event.add(t.id, 'mouseout', function() {
- if (!DOM.hasClass(t.id, cp + 'Disabled'))
- DOM.removeClass(t.id, cp + 'Hover');
- });
- }
-
- t.onPostRender.dispatch(t, DOM.get(t.id));
- },
-
- /**
- * Destroys the ListBox i.e. clear memory and events.
- *
- * @method destroy
- */
- destroy : function() {
- this.parent();
-
- Event.clear(this.id + '_text');
- Event.clear(this.id + '_open');
- }
- });
-})(tinymce);
+/**
+ * ListBox.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, undef;
+
+ /**
+ * This class is used to create list boxes/select list. This one will generate
+ * a non native control. This one has the benefits of having visual items added.
+ *
+ * @class tinymce.ui.ListBox
+ * @extends tinymce.ui.Control
+ * @example
+ * // Creates a new plugin class and a custom listbox
+ * tinymce.create('tinymce.plugins.ExamplePlugin', {
+ * createControl: function(n, cm) {
+ * switch (n) {
+ * case 'mylistbox':
+ * var mlb = cm.createListBox('mylistbox', {
+ * title : 'My list box',
+ * onselect : function(v) {
+ * tinyMCE.activeEditor.windowManager.alert('Value selected:' + v);
+ * }
+ * });
+ *
+ * // Add some values to the list box
+ * mlb.add('Some item 1', 'val1');
+ * mlb.add('some item 2', 'val2');
+ * mlb.add('some item 3', 'val3');
+ *
+ * // Return the new listbox instance
+ * return mlb;
+ * }
+ *
+ * return null;
+ * }
+ * });
+ *
+ * // Register plugin with a short name
+ * tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin);
+ *
+ * // Initialize TinyMCE with the new plugin and button
+ * tinyMCE.init({
+ * ...
+ * plugins : '-example', // - means TinyMCE will not try to load it
+ * theme_advanced_buttons1 : 'mylistbox' // Add the new example listbox to the toolbar
+ * });
+ */
+ tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
+ /**
+ * Constructs a new listbox control instance.
+ *
+ * @constructor
+ * @method ListBox
+ * @param {String} id Control id for the list box.
+ * @param {Object} s Optional name/value settings object.
+ * @param {Editor} ed Optional the editor instance this button is for.
+ */
+ ListBox : function(id, s, ed) {
+ var t = this;
+
+ t.parent(id, s, ed);
+
+ /**
+ * Array of ListBox items.
+ *
+ * @property items
+ * @type Array
+ */
+ t.items = [];
+
+ /**
+ * Fires when the selection has been changed.
+ *
+ * @event onChange
+ */
+ t.onChange = new Dispatcher(t);
+
+ /**
+ * Fires after the element has been rendered to DOM.
+ *
+ * @event onPostRender
+ */
+ t.onPostRender = new Dispatcher(t);
+
+ /**
+ * Fires when a new item is added.
+ *
+ * @event onAdd
+ */
+ t.onAdd = new Dispatcher(t);
+
+ /**
+ * Fires when the menu gets rendered.
+ *
+ * @event onRenderMenu
+ */
+ t.onRenderMenu = new tinymce.util.Dispatcher(this);
+
+ t.classPrefix = 'mceListBox';
+ t.marked = {};
+ },
+
+ /**
+ * Selects a item/option by value. This will both add a visual selection to the
+ * item and change the title of the control to the title of the option.
+ *
+ * @method select
+ * @param {String/function} va Value to look for inside the list box or a function selector.
+ */
+ select : function(va) {
+ var t = this, fv, f;
+
+ t.marked = {};
+
+ if (va == undef)
+ return t.selectByIndex(-1);
+
+ // Is string or number make function selector
+ if (va && typeof(va)=="function")
+ f = va;
+ else {
+ f = function(v) {
+ return v == va;
+ };
+ }
+
+ // Do we need to do something?
+ if (va != t.selectedValue) {
+ // Find item
+ each(t.items, function(o, i) {
+ if (f(o.value)) {
+ fv = 1;
+ t.selectByIndex(i);
+ return false;
+ }
+ });
+
+ if (!fv)
+ t.selectByIndex(-1);
+ }
+ },
+
+ /**
+ * Selects a item/option by index. This will both add a visual selection to the
+ * item and change the title of the control to the title of the option.
+ *
+ * @method selectByIndex
+ * @param {String} idx Index to select, pass -1 to select menu/title of select box.
+ */
+ selectByIndex : function(idx) {
+ var t = this, e, o, label;
+
+ t.marked = {};
+
+ if (idx != t.selectedIndex) {
+ e = DOM.get(t.id + '_text');
+ label = DOM.get(t.id + '_voiceDesc');
+ o = t.items[idx];
+
+ if (o) {
+ t.selectedValue = o.value;
+ t.selectedIndex = idx;
+ DOM.setHTML(e, DOM.encode(o.title));
+ DOM.setHTML(label, t.settings.title + " - " + o.title);
+ DOM.removeClass(e, 'mceTitle');
+ DOM.setAttrib(t.id, 'aria-valuenow', o.title);
+ } else {
+ DOM.setHTML(e, DOM.encode(t.settings.title));
+ DOM.setHTML(label, DOM.encode(t.settings.title));
+ DOM.addClass(e, 'mceTitle');
+ t.selectedValue = t.selectedIndex = null;
+ DOM.setAttrib(t.id, 'aria-valuenow', t.settings.title);
+ }
+ e = 0;
+ }
+ },
+
+ /**
+ * Marks a specific item by name. Marked values are optional items to mark as active.
+ *
+ * @param {String} value Value item to mark.
+ */
+ mark : function(value) {
+ this.marked[value] = true;
+ },
+
+ /**
+ * Adds a option item to the list box.
+ *
+ * @method add
+ * @param {String} n Title for the new option.
+ * @param {String} v Value for the new option.
+ * @param {Object} o Optional object with settings like for example class.
+ */
+ add : function(n, v, o) {
+ var t = this;
+
+ o = o || {};
+ o = tinymce.extend(o, {
+ title : n,
+ value : v
+ });
+
+ t.items.push(o);
+ t.onAdd.dispatch(t, o);
+ },
+
+ /**
+ * Returns the number of items inside the list box.
+ *
+ * @method getLength
+ * @param {Number} Number of items inside the list box.
+ */
+ getLength : function() {
+ return this.items.length;
+ },
+
+ /**
+ * Renders the list box as a HTML string. This method is much faster than using the DOM and when
+ * creating a whole toolbar with buttons it does make a lot of difference.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the list box control element.
+ */
+ renderHTML : function() {
+ var h = '', t = this, s = t.settings, cp = t.classPrefix;
+
+ h = '
';
+
+ return h;
+ },
+
+ /**
+ * Displays the drop menu with all items.
+ *
+ * @method showMenu
+ */
+ showMenu : function() {
+ var t = this, p2, e = DOM.get(this.id), m;
+
+ if (t.isDisabled() || t.items.length === 0)
+ return;
+
+ if (t.menu && t.menu.isMenuVisible)
+ return t.hideMenu();
+
+ if (!t.isMenuRendered) {
+ t.renderMenu();
+ t.isMenuRendered = true;
+ }
+
+ p2 = DOM.getPos(e);
+
+ m = t.menu;
+ m.settings.offset_x = p2.x;
+ m.settings.offset_y = p2.y;
+ m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
+
+ // Select in menu
+ each(t.items, function(o) {
+ if (m.items[o.id]) {
+ m.items[o.id].setSelected(0);
+ }
+ });
+
+ each(t.items, function(o) {
+ if (m.items[o.id] && t.marked[o.value]) {
+ m.items[o.id].setSelected(1);
+ }
+
+ if (o.value === t.selectedValue) {
+ m.items[o.id].setSelected(1);
+ }
+ });
+
+ m.showMenu(0, e.clientHeight);
+
+ Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
+ DOM.addClass(t.id, t.classPrefix + 'Selected');
+
+ //DOM.get(t.id + '_text').focus();
+ },
+
+ /**
+ * Hides the drop menu.
+ *
+ * @method hideMenu
+ */
+ hideMenu : function(e) {
+ var t = this;
+
+ if (t.menu && t.menu.isMenuVisible) {
+ DOM.removeClass(t.id, t.classPrefix + 'Selected');
+
+ // Prevent double toogles by canceling the mouse click event to the button
+ if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
+ return;
+
+ if (!e || !DOM.getParent(e.target, '.mceMenu')) {
+ DOM.removeClass(t.id, t.classPrefix + 'Selected');
+ Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
+ t.menu.hideMenu();
+ }
+ }
+ },
+
+ /**
+ * Renders the menu to the DOM.
+ *
+ * @method renderMenu
+ */
+ renderMenu : function() {
+ var t = this, m;
+
+ m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
+ menu_line : 1,
+ 'class' : t.classPrefix + 'Menu mceNoIcons',
+ max_width : 250,
+ max_height : 150
+ });
+
+ m.onHideMenu.add(function() {
+ t.hideMenu();
+ t.focus();
+ });
+
+ m.add({
+ title : t.settings.title,
+ 'class' : 'mceMenuItemTitle',
+ onclick : function() {
+ if (t.settings.onselect('') !== false)
+ t.select(''); // Must be runned after
+ }
+ });
+
+ each(t.items, function(o) {
+ // No value then treat it as a title
+ if (o.value === undef) {
+ m.add({
+ title : o.title,
+ role : "option",
+ 'class' : 'mceMenuItemTitle',
+ onclick : function() {
+ if (t.settings.onselect('') !== false)
+ t.select(''); // Must be runned after
+ }
+ });
+ } else {
+ o.id = DOM.uniqueId();
+ o.role= "option";
+ o.onclick = function() {
+ if (t.settings.onselect(o.value) !== false)
+ t.select(o.value); // Must be runned after
+ };
+
+ m.add(o);
+ }
+ });
+
+ t.onRenderMenu.dispatch(t, m);
+ t.menu = m;
+ },
+
+ /**
+ * Post render event. This will be executed after the control has been rendered and can be used to
+ * set states, add events to the control etc. It's recommended for subclasses of the control to call this method by using this.parent().
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, cp = t.classPrefix;
+
+ Event.add(t.id, 'click', t.showMenu, t);
+ Event.add(t.id, 'keydown', function(evt) {
+ if (evt.keyCode == 32) { // Space
+ t.showMenu(evt);
+ Event.cancel(evt);
+ }
+ });
+ Event.add(t.id, 'focus', function() {
+ if (!t._focused) {
+ t.keyDownHandler = Event.add(t.id, 'keydown', function(e) {
+ if (e.keyCode == 40) {
+ t.showMenu();
+ Event.cancel(e);
+ }
+ });
+ t.keyPressHandler = Event.add(t.id, 'keypress', function(e) {
+ var v;
+ if (e.keyCode == 13) {
+ // Fake select on enter
+ v = t.selectedValue;
+ t.selectedValue = null; // Needs to be null to fake change
+ Event.cancel(e);
+ t.settings.onselect(v);
+ }
+ });
+ }
+
+ t._focused = 1;
+ });
+ Event.add(t.id, 'blur', function() {
+ Event.remove(t.id, 'keydown', t.keyDownHandler);
+ Event.remove(t.id, 'keypress', t.keyPressHandler);
+ t._focused = 0;
+ });
+
+ // Old IE doesn't have hover on all elements
+ if (tinymce.isIE6 || !DOM.boxModel) {
+ Event.add(t.id, 'mouseover', function() {
+ if (!DOM.hasClass(t.id, cp + 'Disabled'))
+ DOM.addClass(t.id, cp + 'Hover');
+ });
+
+ Event.add(t.id, 'mouseout', function() {
+ if (!DOM.hasClass(t.id, cp + 'Disabled'))
+ DOM.removeClass(t.id, cp + 'Hover');
+ });
+ }
+
+ t.onPostRender.dispatch(t, DOM.get(t.id));
+ },
+
+ /**
+ * Destroys the ListBox i.e. clear memory and events.
+ *
+ * @method destroy
+ */
+ destroy : function() {
+ this.parent();
+
+ Event.clear(this.id + '_text');
+ Event.clear(this.id + '_open');
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/Menu.js b/js/tiny_mce/classes/ui/Menu.js
index 926370d147b..7e4e16e156a 100644
--- a/js/tiny_mce/classes/ui/Menu.js
+++ b/js/tiny_mce/classes/ui/Menu.js
@@ -1,186 +1,186 @@
-/**
- * Menu.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
-
- /**
- * This class is base class for all menu types like DropMenus etc. This class should not
- * be instantiated directly other menu controls should inherit from this one.
- *
- * @class tinymce.ui.Menu
- * @extends tinymce.ui.MenuItem
- */
- tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
- /**
- * Constructs a new button control instance.
- *
- * @constructor
- * @method Menu
- * @param {String} id Button control id for the button.
- * @param {Object} s Optional name/value settings object.
- */
- Menu : function(id, s) {
- var t = this;
-
- t.parent(id, s);
- t.items = {};
- t.collapsed = false;
- t.menuCount = 0;
- t.onAddItem = new tinymce.util.Dispatcher(this);
- },
-
- /**
- * Expands the menu, this will show them menu and all menu items.
- *
- * @method expand
- * @param {Boolean} d Optional deep state. If this is set to true all children will be expanded as well.
- */
- expand : function(d) {
- var t = this;
-
- if (d) {
- walk(t, function(o) {
- if (o.expand)
- o.expand();
- }, 'items', t);
- }
-
- t.collapsed = false;
- },
-
- /**
- * Collapses the menu, this will hide the menu and all menu items.
- *
- * @method collapse
- * @param {Boolean} d Optional deep state. If this is set to true all children will be collapsed as well.
- */
- collapse : function(d) {
- var t = this;
-
- if (d) {
- walk(t, function(o) {
- if (o.collapse)
- o.collapse();
- }, 'items', t);
- }
-
- t.collapsed = true;
- },
-
- /**
- * Returns true/false if the menu has been collapsed or not.
- *
- * @method isCollapsed
- * @return {Boolean} True/false state if the menu has been collapsed or not.
- */
- isCollapsed : function() {
- return this.collapsed;
- },
-
- /**
- * Adds a new menu, menu item or sub classes of them to the drop menu.
- *
- * @method add
- * @param {tinymce.ui.Control} o Menu or menu item to add to the drop menu.
- * @return {tinymce.ui.Control} Same as the input control, the menu or menu item.
- */
- add : function(o) {
- if (!o.settings)
- o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
-
- this.onAddItem.dispatch(this, o);
-
- return this.items[o.id] = o;
- },
-
- /**
- * Adds a menu separator between the menu items.
- *
- * @method addSeparator
- * @return {tinymce.ui.MenuItem} Menu item instance for the separator.
- */
- addSeparator : function() {
- return this.add({separator : true});
- },
-
- /**
- * Adds a sub menu to the menu.
- *
- * @method addMenu
- * @param {Object} o Menu control or a object with settings to be created into an control.
- * @return {tinymce.ui.Menu} Menu control instance passed in or created.
- */
- addMenu : function(o) {
- if (!o.collapse)
- o = this.createMenu(o);
-
- this.menuCount++;
-
- return this.add(o);
- },
-
- /**
- * Returns true/false if the menu has sub menus or not.
- *
- * @method hasMenus
- * @return {Boolean} True/false state if the menu has sub menues or not.
- */
- hasMenus : function() {
- return this.menuCount !== 0;
- },
-
- /**
- * Removes a specific sub menu or menu item from the menu.
- *
- * @method remove
- * @param {tinymce.ui.Control} o Menu item or menu to remove from menu.
- * @return {tinymce.ui.Control} Control instance or null if it wasn't found.
- */
- remove : function(o) {
- delete this.items[o.id];
- },
-
- /**
- * Removes all menu items and sub menu items from the menu.
- *
- * @method removeAll
- */
- removeAll : function() {
- var t = this;
-
- walk(t, function(o) {
- if (o.removeAll)
- o.removeAll();
- else
- o.remove();
-
- o.destroy();
- }, 'items', t);
-
- t.items = {};
- },
-
- /**
- * Created a new sub menu for the menu control.
- *
- * @method createMenu
- * @param {Object} s Optional name/value settings object.
- * @return {tinymce.ui.Menu} New drop menu instance.
- */
- createMenu : function(o) {
- var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o);
-
- m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem);
-
- return m;
- }
- });
+/**
+ * Menu.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
+
+ /**
+ * This class is base class for all menu types like DropMenus etc. This class should not
+ * be instantiated directly other menu controls should inherit from this one.
+ *
+ * @class tinymce.ui.Menu
+ * @extends tinymce.ui.MenuItem
+ */
+ tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
+ /**
+ * Constructs a new button control instance.
+ *
+ * @constructor
+ * @method Menu
+ * @param {String} id Button control id for the button.
+ * @param {Object} s Optional name/value settings object.
+ */
+ Menu : function(id, s) {
+ var t = this;
+
+ t.parent(id, s);
+ t.items = {};
+ t.collapsed = false;
+ t.menuCount = 0;
+ t.onAddItem = new tinymce.util.Dispatcher(this);
+ },
+
+ /**
+ * Expands the menu, this will show them menu and all menu items.
+ *
+ * @method expand
+ * @param {Boolean} d Optional deep state. If this is set to true all children will be expanded as well.
+ */
+ expand : function(d) {
+ var t = this;
+
+ if (d) {
+ walk(t, function(o) {
+ if (o.expand)
+ o.expand();
+ }, 'items', t);
+ }
+
+ t.collapsed = false;
+ },
+
+ /**
+ * Collapses the menu, this will hide the menu and all menu items.
+ *
+ * @method collapse
+ * @param {Boolean} d Optional deep state. If this is set to true all children will be collapsed as well.
+ */
+ collapse : function(d) {
+ var t = this;
+
+ if (d) {
+ walk(t, function(o) {
+ if (o.collapse)
+ o.collapse();
+ }, 'items', t);
+ }
+
+ t.collapsed = true;
+ },
+
+ /**
+ * Returns true/false if the menu has been collapsed or not.
+ *
+ * @method isCollapsed
+ * @return {Boolean} True/false state if the menu has been collapsed or not.
+ */
+ isCollapsed : function() {
+ return this.collapsed;
+ },
+
+ /**
+ * Adds a new menu, menu item or sub classes of them to the drop menu.
+ *
+ * @method add
+ * @param {tinymce.ui.Control} o Menu or menu item to add to the drop menu.
+ * @return {tinymce.ui.Control} Same as the input control, the menu or menu item.
+ */
+ add : function(o) {
+ if (!o.settings)
+ o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
+
+ this.onAddItem.dispatch(this, o);
+
+ return this.items[o.id] = o;
+ },
+
+ /**
+ * Adds a menu separator between the menu items.
+ *
+ * @method addSeparator
+ * @return {tinymce.ui.MenuItem} Menu item instance for the separator.
+ */
+ addSeparator : function() {
+ return this.add({separator : true});
+ },
+
+ /**
+ * Adds a sub menu to the menu.
+ *
+ * @method addMenu
+ * @param {Object} o Menu control or a object with settings to be created into an control.
+ * @return {tinymce.ui.Menu} Menu control instance passed in or created.
+ */
+ addMenu : function(o) {
+ if (!o.collapse)
+ o = this.createMenu(o);
+
+ this.menuCount++;
+
+ return this.add(o);
+ },
+
+ /**
+ * Returns true/false if the menu has sub menus or not.
+ *
+ * @method hasMenus
+ * @return {Boolean} True/false state if the menu has sub menues or not.
+ */
+ hasMenus : function() {
+ return this.menuCount !== 0;
+ },
+
+ /**
+ * Removes a specific sub menu or menu item from the menu.
+ *
+ * @method remove
+ * @param {tinymce.ui.Control} o Menu item or menu to remove from menu.
+ * @return {tinymce.ui.Control} Control instance or null if it wasn't found.
+ */
+ remove : function(o) {
+ delete this.items[o.id];
+ },
+
+ /**
+ * Removes all menu items and sub menu items from the menu.
+ *
+ * @method removeAll
+ */
+ removeAll : function() {
+ var t = this;
+
+ walk(t, function(o) {
+ if (o.removeAll)
+ o.removeAll();
+ else
+ o.remove();
+
+ o.destroy();
+ }, 'items', t);
+
+ t.items = {};
+ },
+
+ /**
+ * Created a new sub menu for the menu control.
+ *
+ * @method createMenu
+ * @param {Object} s Optional name/value settings object.
+ * @return {tinymce.ui.Menu} New drop menu instance.
+ */
+ createMenu : function(o) {
+ var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o);
+
+ m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem);
+
+ return m;
+ }
+ });
})(tinymce);
\ No newline at end of file
diff --git a/js/tiny_mce/classes/ui/MenuButton.js b/js/tiny_mce/classes/ui/MenuButton.js
index 3eac27e2f46..462bcc9b9c1 100644
--- a/js/tiny_mce/classes/ui/MenuButton.js
+++ b/js/tiny_mce/classes/ui/MenuButton.js
@@ -1,176 +1,176 @@
-/**
- * MenuButton.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
-
- /**
- * This class is used to create a UI button. A button is basically a link
- * that is styled to look like a button or icon.
- *
- * @class tinymce.ui.MenuButton
- * @extends tinymce.ui.Control
- * @example
- * // Creates a new plugin class and a custom menu button
- * tinymce.create('tinymce.plugins.ExamplePlugin', {
- * createControl: function(n, cm) {
- * switch (n) {
- * case 'mymenubutton':
- * var c = cm.createSplitButton('mysplitbutton', {
- * title : 'My menu button',
- * image : 'some.gif'
- * });
- *
- * c.onRenderMenu.add(function(c, m) {
- * m.add({title : 'Some title', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
- *
- * m.add({title : 'Some item 1', onclick : function() {
- * alert('Some item 1 was clicked.');
- * }});
- *
- * m.add({title : 'Some item 2', onclick : function() {
- * alert('Some item 2 was clicked.');
- * }});
- * });
- *
- * // Return the new menubutton instance
- * return c;
- * }
- *
- * return null;
- * }
- * });
- */
- tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
- /**
- * Constructs a new split button control instance.
- *
- * @constructor
- * @method MenuButton
- * @param {String} id Control id for the split button.
- * @param {Object} s Optional name/value settings object.
- * @param {Editor} ed Optional the editor instance this button is for.
- */
- MenuButton : function(id, s, ed) {
- this.parent(id, s, ed);
-
- /**
- * Fires when the menu is rendered.
- *
- * @event onRenderMenu
- */
- this.onRenderMenu = new tinymce.util.Dispatcher(this);
-
- s.menu_container = s.menu_container || DOM.doc.body;
- },
-
- /**
- * Shows the menu.
- *
- * @method showMenu
- */
- showMenu : function() {
- var t = this, p1, p2, e = DOM.get(t.id), m;
-
- if (t.isDisabled())
- return;
-
- if (!t.isMenuRendered) {
- t.renderMenu();
- t.isMenuRendered = true;
- }
-
- if (t.isMenuVisible)
- return t.hideMenu();
-
- p1 = DOM.getPos(t.settings.menu_container);
- p2 = DOM.getPos(e);
-
- m = t.menu;
- m.settings.offset_x = p2.x;
- m.settings.offset_y = p2.y;
- m.settings.vp_offset_x = p2.x;
- m.settings.vp_offset_y = p2.y;
- m.settings.keyboard_focus = t._focused;
- m.showMenu(0, e.firstChild.clientHeight);
-
- Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
- t.setState('Selected', 1);
-
- t.isMenuVisible = 1;
- },
-
- /**
- * Renders the menu to the DOM.
- *
- * @method renderMenu
- */
- renderMenu : function() {
- var t = this, m;
-
- m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
- menu_line : 1,
- 'class' : this.classPrefix + 'Menu',
- icons : t.settings.icons
- });
-
- m.onHideMenu.add(function() {
- t.hideMenu();
- t.focus();
- });
-
- t.onRenderMenu.dispatch(t, m);
- t.menu = m;
- },
-
- /**
- * Hides the menu. The optional event parameter is used to check where the event occurred so it
- * doesn't close them menu if it was a event inside the menu.
- *
- * @method hideMenu
- * @param {Event} e Optional event object.
- */
- hideMenu : function(e) {
- var t = this;
-
- // Prevent double toogles by canceling the mouse click event to the button
- if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
- return;
-
- if (!e || !DOM.getParent(e.target, '.mceMenu')) {
- t.setState('Selected', 0);
- Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
- if (t.menu)
- t.menu.hideMenu();
- }
-
- t.isMenuVisible = 0;
- },
-
- /**
- * Post render handler. This function will be called after the UI has been
- * rendered so that events can be added.
- *
- * @method postRender
- */
- postRender : function() {
- var t = this, s = t.settings;
-
- Event.add(t.id, 'click', function() {
- if (!t.isDisabled()) {
- if (s.onclick)
- s.onclick(t.value);
-
- t.showMenu();
- }
- });
- }
- });
-})(tinymce);
+/**
+ * MenuButton.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
+
+ /**
+ * This class is used to create a UI button. A button is basically a link
+ * that is styled to look like a button or icon.
+ *
+ * @class tinymce.ui.MenuButton
+ * @extends tinymce.ui.Control
+ * @example
+ * // Creates a new plugin class and a custom menu button
+ * tinymce.create('tinymce.plugins.ExamplePlugin', {
+ * createControl: function(n, cm) {
+ * switch (n) {
+ * case 'mymenubutton':
+ * var c = cm.createSplitButton('mysplitbutton', {
+ * title : 'My menu button',
+ * image : 'some.gif'
+ * });
+ *
+ * c.onRenderMenu.add(function(c, m) {
+ * m.add({title : 'Some title', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
+ *
+ * m.add({title : 'Some item 1', onclick : function() {
+ * alert('Some item 1 was clicked.');
+ * }});
+ *
+ * m.add({title : 'Some item 2', onclick : function() {
+ * alert('Some item 2 was clicked.');
+ * }});
+ * });
+ *
+ * // Return the new menubutton instance
+ * return c;
+ * }
+ *
+ * return null;
+ * }
+ * });
+ */
+ tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
+ /**
+ * Constructs a new split button control instance.
+ *
+ * @constructor
+ * @method MenuButton
+ * @param {String} id Control id for the split button.
+ * @param {Object} s Optional name/value settings object.
+ * @param {Editor} ed Optional the editor instance this button is for.
+ */
+ MenuButton : function(id, s, ed) {
+ this.parent(id, s, ed);
+
+ /**
+ * Fires when the menu is rendered.
+ *
+ * @event onRenderMenu
+ */
+ this.onRenderMenu = new tinymce.util.Dispatcher(this);
+
+ s.menu_container = s.menu_container || DOM.doc.body;
+ },
+
+ /**
+ * Shows the menu.
+ *
+ * @method showMenu
+ */
+ showMenu : function() {
+ var t = this, p1, p2, e = DOM.get(t.id), m;
+
+ if (t.isDisabled())
+ return;
+
+ if (!t.isMenuRendered) {
+ t.renderMenu();
+ t.isMenuRendered = true;
+ }
+
+ if (t.isMenuVisible)
+ return t.hideMenu();
+
+ p1 = DOM.getPos(t.settings.menu_container);
+ p2 = DOM.getPos(e);
+
+ m = t.menu;
+ m.settings.offset_x = p2.x;
+ m.settings.offset_y = p2.y;
+ m.settings.vp_offset_x = p2.x;
+ m.settings.vp_offset_y = p2.y;
+ m.settings.keyboard_focus = t._focused;
+ m.showMenu(0, e.firstChild.clientHeight);
+
+ Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
+ t.setState('Selected', 1);
+
+ t.isMenuVisible = 1;
+ },
+
+ /**
+ * Renders the menu to the DOM.
+ *
+ * @method renderMenu
+ */
+ renderMenu : function() {
+ var t = this, m;
+
+ m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
+ menu_line : 1,
+ 'class' : this.classPrefix + 'Menu',
+ icons : t.settings.icons
+ });
+
+ m.onHideMenu.add(function() {
+ t.hideMenu();
+ t.focus();
+ });
+
+ t.onRenderMenu.dispatch(t, m);
+ t.menu = m;
+ },
+
+ /**
+ * Hides the menu. The optional event parameter is used to check where the event occurred so it
+ * doesn't close them menu if it was a event inside the menu.
+ *
+ * @method hideMenu
+ * @param {Event} e Optional event object.
+ */
+ hideMenu : function(e) {
+ var t = this;
+
+ // Prevent double toogles by canceling the mouse click event to the button
+ if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
+ return;
+
+ if (!e || !DOM.getParent(e.target, '.mceMenu')) {
+ t.setState('Selected', 0);
+ Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
+ if (t.menu)
+ t.menu.hideMenu();
+ }
+
+ t.isMenuVisible = 0;
+ },
+
+ /**
+ * Post render handler. This function will be called after the UI has been
+ * rendered so that events can be added.
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, s = t.settings;
+
+ Event.add(t.id, 'click', function() {
+ if (!t.isDisabled()) {
+ if (s.onclick)
+ s.onclick(t.value);
+
+ t.showMenu();
+ }
+ });
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/MenuItem.js b/js/tiny_mce/classes/ui/MenuItem.js
index 5f5b9c8f0be..7c48ebc8a6d 100644
--- a/js/tiny_mce/classes/ui/MenuItem.js
+++ b/js/tiny_mce/classes/ui/MenuItem.js
@@ -1,74 +1,74 @@
-/**
- * MenuItem.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
-
- /**
- * This class is base class for all menu item types like DropMenus items etc. This class should not
- * be instantiated directly other menu items should inherit from this one.
- *
- * @class tinymce.ui.MenuItem
- * @extends tinymce.ui.Control
- */
- tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
- /**
- * Constructs a new button control instance.
- *
- * @constructor
- * @method MenuItem
- * @param {String} id Button control id for the button.
- * @param {Object} s Optional name/value settings object.
- */
- MenuItem : function(id, s) {
- this.parent(id, s);
- this.classPrefix = 'mceMenuItem';
- },
-
- /**
- * Sets the selected state for the control. This will add CSS classes to the
- * element that contains the control. So that it can be selected visually.
- *
- * @method setSelected
- * @param {Boolean} s Boolean state if the control should be selected or not.
- */
- setSelected : function(s) {
- this.setState('Selected', s);
- this.setAriaProperty('checked', !!s);
- this.selected = s;
- },
-
- /**
- * Returns true/false if the control is selected or not.
- *
- * @method isSelected
- * @return {Boolean} true/false if the control is selected or not.
- */
- isSelected : function() {
- return this.selected;
- },
-
- /**
- * Post render handler. This function will be called after the UI has been
- * rendered so that events can be added.
- *
- * @method postRender
- */
- postRender : function() {
- var t = this;
-
- t.parent();
-
- // Set pending state
- if (is(t.selected))
- t.setSelected(t.selected);
- }
- });
-})(tinymce);
+/**
+ * MenuItem.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
+
+ /**
+ * This class is base class for all menu item types like DropMenus items etc. This class should not
+ * be instantiated directly other menu items should inherit from this one.
+ *
+ * @class tinymce.ui.MenuItem
+ * @extends tinymce.ui.Control
+ */
+ tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
+ /**
+ * Constructs a new button control instance.
+ *
+ * @constructor
+ * @method MenuItem
+ * @param {String} id Button control id for the button.
+ * @param {Object} s Optional name/value settings object.
+ */
+ MenuItem : function(id, s) {
+ this.parent(id, s);
+ this.classPrefix = 'mceMenuItem';
+ },
+
+ /**
+ * Sets the selected state for the control. This will add CSS classes to the
+ * element that contains the control. So that it can be selected visually.
+ *
+ * @method setSelected
+ * @param {Boolean} s Boolean state if the control should be selected or not.
+ */
+ setSelected : function(s) {
+ this.setState('Selected', s);
+ this.setAriaProperty('checked', !!s);
+ this.selected = s;
+ },
+
+ /**
+ * Returns true/false if the control is selected or not.
+ *
+ * @method isSelected
+ * @return {Boolean} true/false if the control is selected or not.
+ */
+ isSelected : function() {
+ return this.selected;
+ },
+
+ /**
+ * Post render handler. This function will be called after the UI has been
+ * rendered so that events can be added.
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this;
+
+ t.parent();
+
+ // Set pending state
+ if (is(t.selected))
+ t.setSelected(t.selected);
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/NativeListBox.js b/js/tiny_mce/classes/ui/NativeListBox.js
index 0336d6b7ba2..0fc00e0b9a2 100644
--- a/js/tiny_mce/classes/ui/NativeListBox.js
+++ b/js/tiny_mce/classes/ui/NativeListBox.js
@@ -1,215 +1,215 @@
-/**
- * NativeListBox.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, undef;
-
- /**
- * This class is used to create list boxes/select list. This one will generate
- * a native control the way that the browser produces them by default.
- *
- * @class tinymce.ui.NativeListBox
- * @extends tinymce.ui.ListBox
- */
- tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
- /**
- * Constructs a new button control instance.
- *
- * @constructor
- * @method NativeListBox
- * @param {String} id Button control id for the button.
- * @param {Object} s Optional name/value settings object.
- */
- NativeListBox : function(id, s) {
- this.parent(id, s);
- this.classPrefix = 'mceNativeListBox';
- },
-
- /**
- * Sets the disabled state for the control. This will add CSS classes to the
- * element that contains the control. So that it can be disabled visually.
- *
- * @method setDisabled
- * @param {Boolean} s Boolean state if the control should be disabled or not.
- */
- setDisabled : function(s) {
- DOM.get(this.id).disabled = s;
- this.setAriaProperty('disabled', s);
- },
-
- /**
- * Returns true/false if the control is disabled or not. This is a method since you can then
- * choose to check some class or some internal bool state in subclasses.
- *
- * @method isDisabled
- * @return {Boolean} true/false if the control is disabled or not.
- */
- isDisabled : function() {
- return DOM.get(this.id).disabled;
- },
-
- /**
- * Selects a item/option by value. This will both add a visual selection to the
- * item and change the title of the control to the title of the option.
- *
- * @method select
- * @param {String/function} va Value to look for inside the list box or a function selector.
- */
- select : function(va) {
- var t = this, fv, f;
-
- if (va == undef)
- return t.selectByIndex(-1);
-
- // Is string or number make function selector
- if (va && typeof(va)=="function")
- f = va;
- else {
- f = function(v) {
- return v == va;
- };
- }
-
- // Do we need to do something?
- if (va != t.selectedValue) {
- // Find item
- each(t.items, function(o, i) {
- if (f(o.value)) {
- fv = 1;
- t.selectByIndex(i);
- return false;
- }
- });
-
- if (!fv)
- t.selectByIndex(-1);
- }
- },
-
- /**
- * Selects a item/option by index. This will both add a visual selection to the
- * item and change the title of the control to the title of the option.
- *
- * @method selectByIndex
- * @param {String} idx Index to select, pass -1 to select menu/title of select box.
- */
- selectByIndex : function(idx) {
- DOM.get(this.id).selectedIndex = idx + 1;
- this.selectedValue = this.items[idx] ? this.items[idx].value : null;
- },
-
- /**
- * Adds a option item to the list box.
- *
- * @method add
- * @param {String} n Title for the new option.
- * @param {String} v Value for the new option.
- * @param {Object} o Optional object with settings like for example class.
- */
- add : function(n, v, a) {
- var o, t = this;
-
- a = a || {};
- a.value = v;
-
- if (t.isRendered())
- DOM.add(DOM.get(this.id), 'option', a, n);
-
- o = {
- title : n,
- value : v,
- attribs : a
- };
-
- t.items.push(o);
- t.onAdd.dispatch(t, o);
- },
-
- /**
- * Executes the specified callback function for the menu item. In this case when the user clicks the menu item.
- *
- * @method getLength
- */
- getLength : function() {
- return this.items.length;
- },
-
- /**
- * Renders the list box as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the list box control element.
- */
- renderHTML : function() {
- var h, t = this;
-
- h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
-
- each(t.items, function(it) {
- h += DOM.createHTML('option', {value : it.value}, it.title);
- });
-
- h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox', 'aria-labelledby': t.id + '_aria'}, h);
- h += DOM.createHTML('span', {id : t.id + '_aria', 'style': 'display: none'}, t.settings.title);
- return h;
- },
-
- /**
- * Post render handler. This function will be called after the UI has been
- * rendered so that events can be added.
- *
- * @method postRender
- */
- postRender : function() {
- var t = this, ch, changeListenerAdded = true;
-
- t.rendered = true;
-
- function onChange(e) {
- var v = t.items[e.target.selectedIndex - 1];
-
- if (v && (v = v.value)) {
- t.onChange.dispatch(t, v);
-
- if (t.settings.onselect)
- t.settings.onselect(v);
- }
- };
-
- Event.add(t.id, 'change', onChange);
-
- // Accessibility keyhandler
- Event.add(t.id, 'keydown', function(e) {
- var bf, DOM_VK_LEFT = 37, DOM_VK_RIGHT = 39, DOM_VK_UP = 38, DOM_VK_DOWN = 40, DOM_VK_RETURN = 13, DOM_VK_SPACE = 32;
-
- Event.remove(t.id, 'change', ch);
- changeListenerAdded = false;
-
- bf = Event.add(t.id, 'blur', function() {
- if (changeListenerAdded) return;
- changeListenerAdded = true;
- Event.add(t.id, 'change', onChange);
- Event.remove(t.id, 'blur', bf);
- });
-
- if (e.keyCode == DOM_VK_RETURN || e.keyCode == DOM_VK_SPACE) {
- onChange(e);
- return Event.cancel(e);
- } else if (e.keyCode == DOM_VK_DOWN || e.keyCode == DOM_VK_UP) {
- // allow native implementation (navigate select element options)
- e.stopImmediatePropagation();
- }
- });
-
- t.onPostRender.dispatch(t, DOM.get(t.id));
- }
- });
-})(tinymce);
+/**
+ * NativeListBox.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+ var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, undef;
+
+ /**
+ * This class is used to create list boxes/select list. This one will generate
+ * a native control the way that the browser produces them by default.
+ *
+ * @class tinymce.ui.NativeListBox
+ * @extends tinymce.ui.ListBox
+ */
+ tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
+ /**
+ * Constructs a new button control instance.
+ *
+ * @constructor
+ * @method NativeListBox
+ * @param {String} id Button control id for the button.
+ * @param {Object} s Optional name/value settings object.
+ */
+ NativeListBox : function(id, s) {
+ this.parent(id, s);
+ this.classPrefix = 'mceNativeListBox';
+ },
+
+ /**
+ * Sets the disabled state for the control. This will add CSS classes to the
+ * element that contains the control. So that it can be disabled visually.
+ *
+ * @method setDisabled
+ * @param {Boolean} s Boolean state if the control should be disabled or not.
+ */
+ setDisabled : function(s) {
+ DOM.get(this.id).disabled = s;
+ this.setAriaProperty('disabled', s);
+ },
+
+ /**
+ * Returns true/false if the control is disabled or not. This is a method since you can then
+ * choose to check some class or some internal bool state in subclasses.
+ *
+ * @method isDisabled
+ * @return {Boolean} true/false if the control is disabled or not.
+ */
+ isDisabled : function() {
+ return DOM.get(this.id).disabled;
+ },
+
+ /**
+ * Selects a item/option by value. This will both add a visual selection to the
+ * item and change the title of the control to the title of the option.
+ *
+ * @method select
+ * @param {String/function} va Value to look for inside the list box or a function selector.
+ */
+ select : function(va) {
+ var t = this, fv, f;
+
+ if (va == undef)
+ return t.selectByIndex(-1);
+
+ // Is string or number make function selector
+ if (va && typeof(va)=="function")
+ f = va;
+ else {
+ f = function(v) {
+ return v == va;
+ };
+ }
+
+ // Do we need to do something?
+ if (va != t.selectedValue) {
+ // Find item
+ each(t.items, function(o, i) {
+ if (f(o.value)) {
+ fv = 1;
+ t.selectByIndex(i);
+ return false;
+ }
+ });
+
+ if (!fv)
+ t.selectByIndex(-1);
+ }
+ },
+
+ /**
+ * Selects a item/option by index. This will both add a visual selection to the
+ * item and change the title of the control to the title of the option.
+ *
+ * @method selectByIndex
+ * @param {String} idx Index to select, pass -1 to select menu/title of select box.
+ */
+ selectByIndex : function(idx) {
+ DOM.get(this.id).selectedIndex = idx + 1;
+ this.selectedValue = this.items[idx] ? this.items[idx].value : null;
+ },
+
+ /**
+ * Adds a option item to the list box.
+ *
+ * @method add
+ * @param {String} n Title for the new option.
+ * @param {String} v Value for the new option.
+ * @param {Object} o Optional object with settings like for example class.
+ */
+ add : function(n, v, a) {
+ var o, t = this;
+
+ a = a || {};
+ a.value = v;
+
+ if (t.isRendered())
+ DOM.add(DOM.get(this.id), 'option', a, n);
+
+ o = {
+ title : n,
+ value : v,
+ attribs : a
+ };
+
+ t.items.push(o);
+ t.onAdd.dispatch(t, o);
+ },
+
+ /**
+ * Executes the specified callback function for the menu item. In this case when the user clicks the menu item.
+ *
+ * @method getLength
+ */
+ getLength : function() {
+ return this.items.length;
+ },
+
+ /**
+ * Renders the list box as a HTML string. This method is much faster than using the DOM and when
+ * creating a whole toolbar with buttons it does make a lot of difference.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the list box control element.
+ */
+ renderHTML : function() {
+ var h, t = this;
+
+ h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
+
+ each(t.items, function(it) {
+ h += DOM.createHTML('option', {value : it.value}, it.title);
+ });
+
+ h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox', 'aria-labelledby': t.id + '_aria'}, h);
+ h += DOM.createHTML('span', {id : t.id + '_aria', 'style': 'display: none'}, t.settings.title);
+ return h;
+ },
+
+ /**
+ * Post render handler. This function will be called after the UI has been
+ * rendered so that events can be added.
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, ch, changeListenerAdded = true;
+
+ t.rendered = true;
+
+ function onChange(e) {
+ var v = t.items[e.target.selectedIndex - 1];
+
+ if (v && (v = v.value)) {
+ t.onChange.dispatch(t, v);
+
+ if (t.settings.onselect)
+ t.settings.onselect(v);
+ }
+ };
+
+ Event.add(t.id, 'change', onChange);
+
+ // Accessibility keyhandler
+ Event.add(t.id, 'keydown', function(e) {
+ var bf, DOM_VK_LEFT = 37, DOM_VK_RIGHT = 39, DOM_VK_UP = 38, DOM_VK_DOWN = 40, DOM_VK_RETURN = 13, DOM_VK_SPACE = 32;
+
+ Event.remove(t.id, 'change', ch);
+ changeListenerAdded = false;
+
+ bf = Event.add(t.id, 'blur', function() {
+ if (changeListenerAdded) return;
+ changeListenerAdded = true;
+ Event.add(t.id, 'change', onChange);
+ Event.remove(t.id, 'blur', bf);
+ });
+
+ if (e.keyCode == DOM_VK_RETURN || e.keyCode == DOM_VK_SPACE) {
+ onChange(e);
+ return Event.cancel(e);
+ } else if (e.keyCode == DOM_VK_DOWN || e.keyCode == DOM_VK_UP) {
+ // allow native implementation (navigate select element options)
+ e.stopImmediatePropagation();
+ }
+ });
+
+ t.onPostRender.dispatch(t, DOM.get(t.id));
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/Separator.js b/js/tiny_mce/classes/ui/Separator.js
index 2dcf8c02963..1ac7dec8619 100644
--- a/js/tiny_mce/classes/ui/Separator.js
+++ b/js/tiny_mce/classes/ui/Separator.js
@@ -1,42 +1,42 @@
-/**
- * Separator.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-/**
- * This class is used to create vertical separator between other controls.
- *
- * @class tinymce.ui.Separator
- * @extends tinymce.ui.Control
- */
-tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
- /**
- * Separator constructor.
- *
- * @constructor
- * @method Separator
- * @param {String} id Control id to use for the Separator.
- * @param {Object} s Optional name/value settings object.
- */
- Separator : function(id, s) {
- this.parent(id, s);
- this.classPrefix = 'mceSeparator';
- this.setDisabled(true);
- },
-
- /**
- * Renders the separator as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the separator control element.
- */
- renderHTML : function() {
- return tinymce.DOM.createHTML('span', {'class' : this.classPrefix, role : 'separator', 'aria-orientation' : 'vertical', tabindex : '-1'});
- }
-});
+/**
+ * Separator.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/**
+ * This class is used to create vertical separator between other controls.
+ *
+ * @class tinymce.ui.Separator
+ * @extends tinymce.ui.Control
+ */
+tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
+ /**
+ * Separator constructor.
+ *
+ * @constructor
+ * @method Separator
+ * @param {String} id Control id to use for the Separator.
+ * @param {Object} s Optional name/value settings object.
+ */
+ Separator : function(id, s) {
+ this.parent(id, s);
+ this.classPrefix = 'mceSeparator';
+ this.setDisabled(true);
+ },
+
+ /**
+ * Renders the separator as a HTML string. This method is much faster than using the DOM and when
+ * creating a whole toolbar with buttons it does make a lot of difference.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the separator control element.
+ */
+ renderHTML : function() {
+ return tinymce.DOM.createHTML('span', {'class' : this.classPrefix, role : 'separator', 'aria-orientation' : 'vertical', tabindex : '-1'});
+ }
+});
diff --git a/js/tiny_mce/classes/ui/SplitButton.js b/js/tiny_mce/classes/ui/SplitButton.js
index bfb9f40c62e..3547c6b8d94 100644
--- a/js/tiny_mce/classes/ui/SplitButton.js
+++ b/js/tiny_mce/classes/ui/SplitButton.js
@@ -1,154 +1,154 @@
-/**
- * SplitButton.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
- var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
-
- /**
- * This class is used to create a split button. A button with a menu attached to it.
- *
- * @class tinymce.ui.SplitButton
- * @extends tinymce.ui.Button
- * @example
- * // Creates a new plugin class and a custom split button
- * tinymce.create('tinymce.plugins.ExamplePlugin', {
- * createControl: function(n, cm) {
- * switch (n) {
- * case 'mysplitbutton':
- * var c = cm.createSplitButton('mysplitbutton', {
- * title : 'My split button',
- * image : 'some.gif',
- * onclick : function() {
- * alert('Button was clicked.');
- * }
- * });
- *
- * c.onRenderMenu.add(function(c, m) {
- * m.add({title : 'Some title', 'class' : 'mceMenuItemTitle'}).setDisabled(1);
- *
- * m.add({title : 'Some item 1', onclick : function() {
- * alert('Some item 1 was clicked.');
- * }});
- *
- * m.add({title : 'Some item 2', onclick : function() {
- * alert('Some item 2 was clicked.');
- * }});
- * });
- *
- * // Return the new splitbutton instance
- * return c;
- * }
- *
- * return null;
- * }
- * });
- */
- tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
- /**
- * Constructs a new split button control instance.
- *
- * @constructor
- * @method SplitButton
- * @param {String} id Control id for the split button.
- * @param {Object} s Optional name/value settings object.
- * @param {Editor} ed Optional the editor instance this button is for.
- */
- SplitButton : function(id, s, ed) {
- this.parent(id, s, ed);
- this.classPrefix = 'mceSplitButton';
- },
-
- /**
- * Renders the split button as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the split button control element.
- */
- renderHTML : function() {
- var h, t = this, s = t.settings, h1;
-
- h = '
';
+ h = DOM.createHTML('table', { role: 'presentation', 'class' : 'mceSplitButton mceSplitButtonEnabled ' + s['class'], cellpadding : '0', cellspacing : '0', title : s.title}, h);
+ return DOM.createHTML('div', {id : t.id, role: 'button', tabindex: '0', 'aria-labelledby': t.id + '_voice', 'aria-haspopup': 'true'}, h);
+ },
+
+ /**
+ * Post render handler. This function will be called after the UI has been
+ * rendered so that events can be added.
+ *
+ * @method postRender
+ */
+ postRender : function() {
+ var t = this, s = t.settings, activate;
+
+ if (s.onclick) {
+ activate = function(evt) {
+ if (!t.isDisabled()) {
+ s.onclick(t.value);
+ Event.cancel(evt);
+ }
+ };
+ Event.add(t.id + '_action', 'click', activate);
+ Event.add(t.id, ['click', 'keydown'], function(evt) {
+ var DOM_VK_SPACE = 32, DOM_VK_ENTER = 14, DOM_VK_RETURN = 13, DOM_VK_UP = 38, DOM_VK_DOWN = 40;
+ if ((evt.keyCode === 32 || evt.keyCode === 13 || evt.keyCode === 14) && !evt.altKey && !evt.ctrlKey && !evt.metaKey) {
+ activate();
+ Event.cancel(evt);
+ } else if (evt.type === 'click' || evt.keyCode === DOM_VK_DOWN) {
+ t.showMenu();
+ Event.cancel(evt);
+ }
+ });
+ }
+
+ Event.add(t.id + '_open', 'click', function (evt) {
+ t.showMenu();
+ Event.cancel(evt);
+ });
+ Event.add([t.id, t.id + '_open'], 'focus', function() {t._focused = 1;});
+ Event.add([t.id, t.id + '_open'], 'blur', function() {t._focused = 0;});
+
+ // Old IE doesn't have hover on all elements
+ if (tinymce.isIE6 || !DOM.boxModel) {
+ Event.add(t.id, 'mouseover', function() {
+ if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
+ DOM.addClass(t.id, 'mceSplitButtonHover');
+ });
+
+ Event.add(t.id, 'mouseout', function() {
+ if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
+ DOM.removeClass(t.id, 'mceSplitButtonHover');
+ });
+ }
+ },
+
+ destroy : function() {
+ this.parent();
+
+ Event.clear(this.id + '_action');
+ Event.clear(this.id + '_open');
+ Event.clear(this.id);
+ }
+ });
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/Toolbar.js b/js/tiny_mce/classes/ui/Toolbar.js
index ea7ac47b61c..73ca1c6695f 100644
--- a/js/tiny_mce/classes/ui/Toolbar.js
+++ b/js/tiny_mce/classes/ui/Toolbar.js
@@ -1,89 +1,89 @@
-/**
- * Toolbar.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
-// Shorten class names
-var dom = tinymce.DOM, each = tinymce.each;
-/**
- * This class is used to create toolbars a toolbar is a container for other controls like buttons etc.
- *
- * @class tinymce.ui.Toolbar
- * @extends tinymce.ui.Container
- */
-tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
- /**
- * Renders the toolbar as a HTML string. This method is much faster than using the DOM and when
- * creating a whole toolbar with buttons it does make a lot of difference.
- *
- * @method renderHTML
- * @return {String} HTML for the toolbar control.
- */
- renderHTML : function() {
- var t = this, h = '', c, co, s = t.settings, i, pr, nx, cl;
-
- cl = t.controls;
- for (i=0; i'));
- }
-
- // Add toolbar end before list box and after the previous button
- // This is to fix the o2k7 editor skins
- if (pr && co.ListBox) {
- if (pr.Button || pr.SplitButton)
- h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, ''));
- }
-
- // Render control HTML
-
- // IE 8 quick fix, needed to propertly generate a hit area for anchors
- if (dom.stdMode)
- h += '
' + co.renderHTML() + '
';
- else
- h += '
' + co.renderHTML() + '
';
-
- // Add toolbar start after list box and before the next button
- // This is to fix the o2k7 editor skins
- if (nx && co.ListBox) {
- if (nx.Button || nx.SplitButton)
- h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, ''));
- }
- }
-
- c = 'mceToolbarEnd';
-
- if (co.Button)
- c += ' mceToolbarEndButton';
- else if (co.SplitButton)
- c += ' mceToolbarEndSplitButton';
- else if (co.ListBox)
- c += ' mceToolbarEndListBox';
-
- h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, ''));
-
- return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || '', role: 'presentation', tabindex: '-1'}, '
' + h + '
');
- }
-});
-})(tinymce);
+/**
+ * Toolbar.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+// Shorten class names
+var dom = tinymce.DOM, each = tinymce.each;
+/**
+ * This class is used to create toolbars a toolbar is a container for other controls like buttons etc.
+ *
+ * @class tinymce.ui.Toolbar
+ * @extends tinymce.ui.Container
+ */
+tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
+ /**
+ * Renders the toolbar as a HTML string. This method is much faster than using the DOM and when
+ * creating a whole toolbar with buttons it does make a lot of difference.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the toolbar control.
+ */
+ renderHTML : function() {
+ var t = this, h = '', c, co, s = t.settings, i, pr, nx, cl;
+
+ cl = t.controls;
+ for (i=0; i'));
+ }
+
+ // Add toolbar end before list box and after the previous button
+ // This is to fix the o2k7 editor skins
+ if (pr && co.ListBox) {
+ if (pr.Button || pr.SplitButton)
+ h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, ''));
+ }
+
+ // Render control HTML
+
+ // IE 8 quick fix, needed to propertly generate a hit area for anchors
+ if (dom.stdMode)
+ h += '
' + co.renderHTML() + '
';
+ else
+ h += '
' + co.renderHTML() + '
';
+
+ // Add toolbar start after list box and before the next button
+ // This is to fix the o2k7 editor skins
+ if (nx && co.ListBox) {
+ if (nx.Button || nx.SplitButton)
+ h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, ''));
+ }
+ }
+
+ c = 'mceToolbarEnd';
+
+ if (co.Button)
+ c += ' mceToolbarEndButton';
+ else if (co.SplitButton)
+ c += ' mceToolbarEndSplitButton';
+ else if (co.ListBox)
+ c += ' mceToolbarEndListBox';
+
+ h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, ''));
+
+ return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || '', role: 'presentation', tabindex: '-1'}, '
' + h + '
');
+ }
+});
+})(tinymce);
diff --git a/js/tiny_mce/classes/ui/ToolbarGroup.js b/js/tiny_mce/classes/ui/ToolbarGroup.js
index 35d11e91edf..5f4ca1cb842 100644
--- a/js/tiny_mce/classes/ui/ToolbarGroup.js
+++ b/js/tiny_mce/classes/ui/ToolbarGroup.js
@@ -1,81 +1,81 @@
-/**
- * ToolbarGroup.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function(tinymce) {
-// Shorten class names
-var dom = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event;
-/**
- * This class is used to group a set of toolbars together and control the keyboard navigation and focus.
- *
- * @class tinymce.ui.ToolbarGroup
- * @extends tinymce.ui.Container
- */
-tinymce.create('tinymce.ui.ToolbarGroup:tinymce.ui.Container', {
- /**
- * Renders the toolbar group as a HTML string.
- *
- * @method renderHTML
- * @return {String} HTML for the toolbar control.
- */
- renderHTML : function() {
- var t = this, h = [], controls = t.controls, each = tinymce.each, settings = t.settings;
-
- h.push('
');
- //TODO: ACC test this out - adding a role = application for getting the landmarks working well.
- h.push("");
- h.push('' + dom.encode(settings.name) + '');
- each(controls, function(toolbar) {
- h.push(toolbar.renderHTML());
- });
- h.push("");
- h.push('
');
-
- return h.join('');
- },
-
- focus : function() {
- var t = this;
- dom.get(t.id).focus();
- },
-
- postRender : function() {
- var t = this, items = [];
-
- each(t.controls, function(toolbar) {
- each (toolbar.controls, function(control) {
- if (control.id) {
- items.push(control);
- }
- });
- });
-
- t.keyNav = new tinymce.ui.KeyboardNavigation({
- root: t.id,
- items: items,
- onCancel: function() {
- //Move focus if webkit so that navigation back will read the item.
- if (tinymce.isWebKit) {
- dom.get(t.editor.id+"_ifr").focus();
- }
- t.editor.focus();
- },
- excludeFromTabOrder: !t.settings.tab_focus_toolbar
- });
- },
-
- destroy : function() {
- var self = this;
-
- self.parent();
- self.keyNav.destroy();
- Event.clear(self.id);
- }
-});
-})(tinymce);
+/**
+ * ToolbarGroup.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function(tinymce) {
+// Shorten class names
+var dom = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event;
+/**
+ * This class is used to group a set of toolbars together and control the keyboard navigation and focus.
+ *
+ * @class tinymce.ui.ToolbarGroup
+ * @extends tinymce.ui.Container
+ */
+tinymce.create('tinymce.ui.ToolbarGroup:tinymce.ui.Container', {
+ /**
+ * Renders the toolbar group as a HTML string.
+ *
+ * @method renderHTML
+ * @return {String} HTML for the toolbar control.
+ */
+ renderHTML : function() {
+ var t = this, h = [], controls = t.controls, each = tinymce.each, settings = t.settings;
+
+ h.push('
');
+ //TODO: ACC test this out - adding a role = application for getting the landmarks working well.
+ h.push("");
+ h.push('' + dom.encode(settings.name) + '');
+ each(controls, function(toolbar) {
+ h.push(toolbar.renderHTML());
+ });
+ h.push("");
+ h.push('
');
+
+ return h.join('');
+ },
+
+ focus : function() {
+ var t = this;
+ dom.get(t.id).focus();
+ },
+
+ postRender : function() {
+ var t = this, items = [];
+
+ each(t.controls, function(toolbar) {
+ each (toolbar.controls, function(control) {
+ if (control.id) {
+ items.push(control);
+ }
+ });
+ });
+
+ t.keyNav = new tinymce.ui.KeyboardNavigation({
+ root: t.id,
+ items: items,
+ onCancel: function() {
+ //Move focus if webkit so that navigation back will read the item.
+ if (tinymce.isWebKit) {
+ dom.get(t.editor.id+"_ifr").focus();
+ }
+ t.editor.focus();
+ },
+ excludeFromTabOrder: !t.settings.tab_focus_toolbar
+ });
+ },
+
+ destroy : function() {
+ var self = this;
+
+ self.parent();
+ self.keyNav.destroy();
+ Event.clear(self.id);
+ }
+});
+})(tinymce);
diff --git a/js/tiny_mce/classes/util/Cookie.js b/js/tiny_mce/classes/util/Cookie.js
index b30ca484e1f..0e328b5484a 100644
--- a/js/tiny_mce/classes/util/Cookie.js
+++ b/js/tiny_mce/classes/util/Cookie.js
@@ -1,139 +1,139 @@
-/**
- * Cookie.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function() {
- var each = tinymce.each;
-
- /**
- * This class contains simple cookie manangement functions.
- *
- * @class tinymce.util.Cookie
- * @static
- * @example
- * // Gets a cookie from the browser
- * console.debug(tinymce.util.Cookie.get('mycookie'));
- *
- * // Gets a hash table cookie from the browser and takes out the x parameter from it
- * console.debug(tinymce.util.Cookie.getHash('mycookie').x);
- *
- * // Sets a hash table cookie to the browser
- * tinymce.util.Cookie.setHash({x : '1', y : '2'});
- */
- tinymce.create('static tinymce.util.Cookie', {
- /**
- * Parses the specified query string into an name/value object.
- *
- * @method getHash
- * @param {String} n String to parse into a n Hashtable object.
- * @return {Object} Name/Value object with items parsed from querystring.
- */
- getHash : function(n) {
- var v = this.get(n), h;
-
- if (v) {
- each(v.split('&'), function(v) {
- v = v.split('=');
- h = h || {};
- h[unescape(v[0])] = unescape(v[1]);
- });
- }
-
- return h;
- },
-
- /**
- * Sets a hashtable name/value object to a cookie.
- *
- * @method setHash
- * @param {String} n Name of the cookie.
- * @param {Object} v Hashtable object to set as cookie.
- * @param {Date} e Optional date object for the expiration of the cookie.
- * @param {String} p Optional path to restrict the cookie to.
- * @param {String} d Optional domain to restrict the cookie to.
- * @param {String} s Is the cookie secure or not.
- */
- setHash : function(n, v, e, p, d, s) {
- var o = '';
-
- each(v, function(v, k) {
- o += (!o ? '' : '&') + escape(k) + '=' + escape(v);
- });
-
- this.set(n, o, e, p, d, s);
- },
-
- /**
- * Gets the raw data of a cookie by name.
- *
- * @method get
- * @param {String} n Name of cookie to retrieve.
- * @return {String} Cookie data string.
- */
- get : function(n) {
- var c = document.cookie, e, p = n + "=", b;
-
- // Strict mode
- if (!c)
- return;
-
- b = c.indexOf("; " + p);
-
- if (b == -1) {
- b = c.indexOf(p);
-
- if (b !== 0)
- return null;
- } else
- b += 2;
-
- e = c.indexOf(";", b);
-
- if (e == -1)
- e = c.length;
-
- return unescape(c.substring(b + p.length, e));
- },
-
- /**
- * Sets a raw cookie string.
- *
- * @method set
- * @param {String} n Name of the cookie.
- * @param {String} v Raw cookie data.
- * @param {Date} e Optional date object for the expiration of the cookie.
- * @param {String} p Optional path to restrict the cookie to.
- * @param {String} d Optional domain to restrict the cookie to.
- * @param {String} s Is the cookie secure or not.
- */
- set : function(n, v, e, p, d, s) {
- document.cookie = n + "=" + escape(v) +
- ((e) ? "; expires=" + e.toGMTString() : "") +
- ((p) ? "; path=" + escape(p) : "") +
- ((d) ? "; domain=" + d : "") +
- ((s) ? "; secure" : "");
- },
-
- /**
- * Removes/deletes a cookie by name.
- *
- * @method remove
- * @param {String} name Cookie name to remove/delete.
- * @param {Strong} path Optional path to remove the cookie from.
- * @param {Strong} domain Optional domain to restrict the cookie to.
- */
- remove : function(name, path, domain) {
- var date = new Date();
-
- date.setTime(date.getTime() - 1000);
-
- this.set(name, '', date, path, domain);
- }
- });
-})();
+/**
+ * Cookie.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function() {
+ var each = tinymce.each;
+
+ /**
+ * This class contains simple cookie manangement functions.
+ *
+ * @class tinymce.util.Cookie
+ * @static
+ * @example
+ * // Gets a cookie from the browser
+ * console.debug(tinymce.util.Cookie.get('mycookie'));
+ *
+ * // Gets a hash table cookie from the browser and takes out the x parameter from it
+ * console.debug(tinymce.util.Cookie.getHash('mycookie').x);
+ *
+ * // Sets a hash table cookie to the browser
+ * tinymce.util.Cookie.setHash({x : '1', y : '2'});
+ */
+ tinymce.create('static tinymce.util.Cookie', {
+ /**
+ * Parses the specified query string into an name/value object.
+ *
+ * @method getHash
+ * @param {String} n String to parse into a n Hashtable object.
+ * @return {Object} Name/Value object with items parsed from querystring.
+ */
+ getHash : function(n) {
+ var v = this.get(n), h;
+
+ if (v) {
+ each(v.split('&'), function(v) {
+ v = v.split('=');
+ h = h || {};
+ h[unescape(v[0])] = unescape(v[1]);
+ });
+ }
+
+ return h;
+ },
+
+ /**
+ * Sets a hashtable name/value object to a cookie.
+ *
+ * @method setHash
+ * @param {String} n Name of the cookie.
+ * @param {Object} v Hashtable object to set as cookie.
+ * @param {Date} e Optional date object for the expiration of the cookie.
+ * @param {String} p Optional path to restrict the cookie to.
+ * @param {String} d Optional domain to restrict the cookie to.
+ * @param {String} s Is the cookie secure or not.
+ */
+ setHash : function(n, v, e, p, d, s) {
+ var o = '';
+
+ each(v, function(v, k) {
+ o += (!o ? '' : '&') + escape(k) + '=' + escape(v);
+ });
+
+ this.set(n, o, e, p, d, s);
+ },
+
+ /**
+ * Gets the raw data of a cookie by name.
+ *
+ * @method get
+ * @param {String} n Name of cookie to retrieve.
+ * @return {String} Cookie data string.
+ */
+ get : function(n) {
+ var c = document.cookie, e, p = n + "=", b;
+
+ // Strict mode
+ if (!c)
+ return;
+
+ b = c.indexOf("; " + p);
+
+ if (b == -1) {
+ b = c.indexOf(p);
+
+ if (b !== 0)
+ return null;
+ } else
+ b += 2;
+
+ e = c.indexOf(";", b);
+
+ if (e == -1)
+ e = c.length;
+
+ return unescape(c.substring(b + p.length, e));
+ },
+
+ /**
+ * Sets a raw cookie string.
+ *
+ * @method set
+ * @param {String} n Name of the cookie.
+ * @param {String} v Raw cookie data.
+ * @param {Date} e Optional date object for the expiration of the cookie.
+ * @param {String} p Optional path to restrict the cookie to.
+ * @param {String} d Optional domain to restrict the cookie to.
+ * @param {String} s Is the cookie secure or not.
+ */
+ set : function(n, v, e, p, d, s) {
+ document.cookie = n + "=" + escape(v) +
+ ((e) ? "; expires=" + e.toGMTString() : "") +
+ ((p) ? "; path=" + escape(p) : "") +
+ ((d) ? "; domain=" + d : "") +
+ ((s) ? "; secure" : "");
+ },
+
+ /**
+ * Removes/deletes a cookie by name.
+ *
+ * @method remove
+ * @param {String} name Cookie name to remove/delete.
+ * @param {Strong} path Optional path to remove the cookie from.
+ * @param {Strong} domain Optional domain to restrict the cookie to.
+ */
+ remove : function(name, path, domain) {
+ var date = new Date();
+
+ date.setTime(date.getTime() - 1000);
+
+ this.set(name, '', date, path, domain);
+ }
+ });
+})();
diff --git a/js/tiny_mce/classes/util/Dispatcher.js b/js/tiny_mce/classes/util/Dispatcher.js
index 72d39f9e99c..9f655b22a94 100644
--- a/js/tiny_mce/classes/util/Dispatcher.js
+++ b/js/tiny_mce/classes/util/Dispatcher.js
@@ -1,124 +1,124 @@
-/**
- * Dispatcher.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-/**
- * This class is used to dispatch event to observers/listeners.
- * All internal events inside TinyMCE uses this class.
- *
- * @class tinymce.util.Dispatcher
- * @example
- * // Creates a custom event
- * this.onSomething = new tinymce.util.Dispatcher(this);
- *
- * // Dispatch/fire the event
- * this.onSomething.dispatch('some string');
- */
-tinymce.create('tinymce.util.Dispatcher', {
- scope : null,
- listeners : null,
- inDispatch: false,
-
- /**
- * Constructs a new event dispatcher object.
- *
- * @constructor
- * @method Dispatcher
- * @param {Object} scope Optional default execution scope for all observer functions.
- */
- Dispatcher : function(scope) {
- this.scope = scope || this;
- this.listeners = [];
- },
-
- /**
- * Add an observer function to be executed when a dispatch call is done.
- *
- * @method add
- * @param {function} callback Callback function to execute when a dispatch event occurs.
- * @param {Object} s Optional execution scope, defaults to the one specified in the class constructor.
- * @return {function} Returns the same function as the one passed on.
- */
- add : function(callback, scope) {
- this.listeners.push({cb : callback, scope : scope || this.scope});
-
- return callback;
- },
-
- /**
- * Add an observer function to be executed to the top of the list of observers.
- *
- * @method addToTop
- * @param {function} callback Callback function to execute when a dispatch event occurs.
- * @param {Object} scope Optional execution scope, defaults to the one specified in the class constructor.
- * @return {function} Returns the same function as the one passed on.
- */
- addToTop : function(callback, scope) {
- var self = this, listener = {cb : callback, scope : scope || self.scope};
-
- // Create new listeners if addToTop is executed in a dispatch loop
- if (self.inDispatch) {
- self.listeners = [listener].concat(self.listeners);
- } else {
- self.listeners.unshift(listener);
- }
-
- return callback;
- },
-
- /**
- * Removes an observer function.
- *
- * @method remove
- * @param {function} callback Observer function to remove.
- * @return {function} The same function that got passed in or null if it wasn't found.
- */
- remove : function(callback) {
- var listeners = this.listeners, output = null;
-
- tinymce.each(listeners, function(listener, i) {
- if (callback == listener.cb) {
- output = listener;
- listeners.splice(i, 1);
- return false;
- }
- });
-
- return output;
- },
-
- /**
- * Dispatches an event to all observers/listeners.
- *
- * @method dispatch
- * @param {Object} .. Any number of arguments to dispatch.
- * @return {Object} Last observer functions return value.
- */
- dispatch : function() {
- var self = this, returnValue, args = arguments, i, listeners = self.listeners, listener;
-
- self.inDispatch = true;
-
- // Needs to be a real loop since the listener count might change while looping
- // And this is also more efficient
- for (i = 0; i < listeners.length; i++) {
- listener = listeners[i];
- returnValue = listener.cb.apply(listener.scope, args.length > 0 ? args : [listener.scope]);
-
- if (returnValue === false)
- break;
- }
-
- self.inDispatch = false;
-
- return returnValue;
- }
-
- /**#@-*/
-});
+/**
+ * Dispatcher.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/**
+ * This class is used to dispatch event to observers/listeners.
+ * All internal events inside TinyMCE uses this class.
+ *
+ * @class tinymce.util.Dispatcher
+ * @example
+ * // Creates a custom event
+ * this.onSomething = new tinymce.util.Dispatcher(this);
+ *
+ * // Dispatch/fire the event
+ * this.onSomething.dispatch('some string');
+ */
+tinymce.create('tinymce.util.Dispatcher', {
+ scope : null,
+ listeners : null,
+ inDispatch: false,
+
+ /**
+ * Constructs a new event dispatcher object.
+ *
+ * @constructor
+ * @method Dispatcher
+ * @param {Object} scope Optional default execution scope for all observer functions.
+ */
+ Dispatcher : function(scope) {
+ this.scope = scope || this;
+ this.listeners = [];
+ },
+
+ /**
+ * Add an observer function to be executed when a dispatch call is done.
+ *
+ * @method add
+ * @param {function} callback Callback function to execute when a dispatch event occurs.
+ * @param {Object} s Optional execution scope, defaults to the one specified in the class constructor.
+ * @return {function} Returns the same function as the one passed on.
+ */
+ add : function(callback, scope) {
+ this.listeners.push({cb : callback, scope : scope || this.scope});
+
+ return callback;
+ },
+
+ /**
+ * Add an observer function to be executed to the top of the list of observers.
+ *
+ * @method addToTop
+ * @param {function} callback Callback function to execute when a dispatch event occurs.
+ * @param {Object} scope Optional execution scope, defaults to the one specified in the class constructor.
+ * @return {function} Returns the same function as the one passed on.
+ */
+ addToTop : function(callback, scope) {
+ var self = this, listener = {cb : callback, scope : scope || self.scope};
+
+ // Create new listeners if addToTop is executed in a dispatch loop
+ if (self.inDispatch) {
+ self.listeners = [listener].concat(self.listeners);
+ } else {
+ self.listeners.unshift(listener);
+ }
+
+ return callback;
+ },
+
+ /**
+ * Removes an observer function.
+ *
+ * @method remove
+ * @param {function} callback Observer function to remove.
+ * @return {function} The same function that got passed in or null if it wasn't found.
+ */
+ remove : function(callback) {
+ var listeners = this.listeners, output = null;
+
+ tinymce.each(listeners, function(listener, i) {
+ if (callback == listener.cb) {
+ output = listener;
+ listeners.splice(i, 1);
+ return false;
+ }
+ });
+
+ return output;
+ },
+
+ /**
+ * Dispatches an event to all observers/listeners.
+ *
+ * @method dispatch
+ * @param {Object} .. Any number of arguments to dispatch.
+ * @return {Object} Last observer functions return value.
+ */
+ dispatch : function() {
+ var self = this, returnValue, args = arguments, i, listeners = self.listeners, listener;
+
+ self.inDispatch = true;
+
+ // Needs to be a real loop since the listener count might change while looping
+ // And this is also more efficient
+ for (i = 0; i < listeners.length; i++) {
+ listener = listeners[i];
+ returnValue = listener.cb.apply(listener.scope, args.length > 0 ? args : [listener.scope]);
+
+ if (returnValue === false)
+ break;
+ }
+
+ self.inDispatch = false;
+
+ return returnValue;
+ }
+
+ /**#@-*/
+});
diff --git a/js/tiny_mce/classes/util/JSON.js b/js/tiny_mce/classes/util/JSON.js
index e1fbd3e483e..61a52bf7e85 100644
--- a/js/tiny_mce/classes/util/JSON.js
+++ b/js/tiny_mce/classes/util/JSON.js
@@ -1,103 +1,103 @@
-/**
- * JSON.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function() {
- function serialize(o, quote) {
- var i, v, t, name;
-
- quote = quote || '"';
-
- if (o == null)
- return 'null';
-
- t = typeof o;
-
- if (t == 'string') {
- v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
-
- return quote + o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g, function(a, b) {
- // Make sure single quotes never get encoded inside double quotes for JSON compatibility
- if (quote === '"' && a === "'")
- return a;
-
- i = v.indexOf(b);
-
- if (i + 1)
- return '\\' + v.charAt(i + 1);
-
- a = b.charCodeAt().toString(16);
-
- return '\\u' + '0000'.substring(a.length) + a;
- }) + quote;
- }
-
- if (t == 'object') {
- if (o.hasOwnProperty && Object.prototype.toString.call(o) === '[object Array]') {
- for (i=0, v = '['; i 0 ? ',' : '') + serialize(o[i], quote);
-
- return v + ']';
- }
-
- v = '{';
-
- for (name in o) {
- if (o.hasOwnProperty(name)) {
- v += typeof o[name] != 'function' ? (v.length > 1 ? ',' + quote : quote) + name + quote +':' + serialize(o[name], quote) : '';
- }
- }
-
- return v + '}';
- }
-
- return '' + o;
- };
-
- /**
- * JSON parser and serializer class.
- *
- * @class tinymce.util.JSON
- * @static
- * @example
- * // JSON parse a string into an object
- * var obj = tinymce.util.JSON.parse(somestring);
- *
- * // JSON serialize a object into an string
- * var str = tinymce.util.JSON.serialize(obj);
- */
- tinymce.util.JSON = {
- /**
- * Serializes the specified object as a JSON string.
- *
- * @method serialize
- * @param {Object} obj Object to serialize as a JSON string.
- * @param {String} quote Optional quote string defaults to ".
- * @return {string} JSON string serialized from input.
- */
- serialize: serialize,
-
- /**
- * Unserializes/parses the specified JSON string into a object.
- *
- * @method parse
- * @param {string} s JSON String to parse into a JavaScript object.
- * @return {Object} Object from input JSON string or undefined if it failed.
- */
- parse: function(s) {
- try {
- return eval('(' + s + ')');
- } catch (ex) {
- // Ignore
- }
- }
-
- /**#@-*/
- };
-})();
+/**
+ * JSON.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function() {
+ function serialize(o, quote) {
+ var i, v, t, name;
+
+ quote = quote || '"';
+
+ if (o == null)
+ return 'null';
+
+ t = typeof o;
+
+ if (t == 'string') {
+ v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
+
+ return quote + o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g, function(a, b) {
+ // Make sure single quotes never get encoded inside double quotes for JSON compatibility
+ if (quote === '"' && a === "'")
+ return a;
+
+ i = v.indexOf(b);
+
+ if (i + 1)
+ return '\\' + v.charAt(i + 1);
+
+ a = b.charCodeAt().toString(16);
+
+ return '\\u' + '0000'.substring(a.length) + a;
+ }) + quote;
+ }
+
+ if (t == 'object') {
+ if (o.hasOwnProperty && Object.prototype.toString.call(o) === '[object Array]') {
+ for (i=0, v = '['; i 0 ? ',' : '') + serialize(o[i], quote);
+
+ return v + ']';
+ }
+
+ v = '{';
+
+ for (name in o) {
+ if (o.hasOwnProperty(name)) {
+ v += typeof o[name] != 'function' ? (v.length > 1 ? ',' + quote : quote) + name + quote +':' + serialize(o[name], quote) : '';
+ }
+ }
+
+ return v + '}';
+ }
+
+ return '' + o;
+ };
+
+ /**
+ * JSON parser and serializer class.
+ *
+ * @class tinymce.util.JSON
+ * @static
+ * @example
+ * // JSON parse a string into an object
+ * var obj = tinymce.util.JSON.parse(somestring);
+ *
+ * // JSON serialize a object into an string
+ * var str = tinymce.util.JSON.serialize(obj);
+ */
+ tinymce.util.JSON = {
+ /**
+ * Serializes the specified object as a JSON string.
+ *
+ * @method serialize
+ * @param {Object} obj Object to serialize as a JSON string.
+ * @param {String} quote Optional quote string defaults to ".
+ * @return {string} JSON string serialized from input.
+ */
+ serialize: serialize,
+
+ /**
+ * Unserializes/parses the specified JSON string into a object.
+ *
+ * @method parse
+ * @param {string} s JSON String to parse into a JavaScript object.
+ * @return {Object} Object from input JSON string or undefined if it failed.
+ */
+ parse: function(s) {
+ try {
+ return eval('(' + s + ')');
+ } catch (ex) {
+ // Ignore
+ }
+ }
+
+ /**#@-*/
+ };
+})();
diff --git a/js/tiny_mce/classes/util/JSONP.js b/js/tiny_mce/classes/util/JSONP.js
index 4feccf82bcd..98be199e1c0 100644
--- a/js/tiny_mce/classes/util/JSONP.js
+++ b/js/tiny_mce/classes/util/JSONP.js
@@ -1,28 +1,28 @@
-/**
- * JSONP.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-tinymce.create('static tinymce.util.JSONP', {
- callbacks : {},
- count : 0,
-
- send : function(o) {
- var t = this, dom = tinymce.DOM, count = o.count !== undefined ? o.count : t.count, id = 'tinymce_jsonp_' + count;
-
- t.callbacks[count] = function(json) {
- dom.remove(id);
- delete t.callbacks[count];
-
- o.callback(json);
- };
-
- dom.add(dom.doc.body, 'script', {id : id , src : o.url, type : 'text/javascript'});
- t.count++;
- }
-});
+/**
+ * JSONP.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+tinymce.create('static tinymce.util.JSONP', {
+ callbacks : {},
+ count : 0,
+
+ send : function(o) {
+ var t = this, dom = tinymce.DOM, count = o.count !== undefined ? o.count : t.count, id = 'tinymce_jsonp_' + count;
+
+ t.callbacks[count] = function(json) {
+ dom.remove(id);
+ delete t.callbacks[count];
+
+ o.callback(json);
+ };
+
+ dom.add(dom.doc.body, 'script', {id : id , src : o.url, type : 'text/javascript'});
+ t.count++;
+ }
+});
diff --git a/js/tiny_mce/classes/util/JSONRequest.js b/js/tiny_mce/classes/util/JSONRequest.js
index a5a852a3072..577426ca734 100644
--- a/js/tiny_mce/classes/util/JSONRequest.js
+++ b/js/tiny_mce/classes/util/JSONRequest.js
@@ -1,112 +1,112 @@
-/**
- * JSONRequest.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function() {
- var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
-
- /**
- * This class enables you to use JSON-RPC to call backend methods.
- *
- * @class tinymce.util.JSONRequest
- * @example
- * var json = new tinymce.util.JSONRequest({
- * url : 'somebackend.php'
- * });
- *
- * // Send RPC call 1
- * json.send({
- * method : 'someMethod1',
- * params : ['a', 'b'],
- * success : function(result) {
- * console.dir(result);
- * }
- * });
- *
- * // Send RPC call 2
- * json.send({
- * method : 'someMethod2',
- * params : ['a', 'b'],
- * success : function(result) {
- * console.dir(result);
- * }
- * });
- */
- tinymce.create('tinymce.util.JSONRequest', {
- /**
- * Constructs a new JSONRequest instance.
- *
- * @constructor
- * @method JSONRequest
- * @param {Object} s Optional settings object.
- */
- JSONRequest : function(s) {
- this.settings = extend({
- }, s);
- this.count = 0;
- },
-
- /**
- * Sends a JSON-RPC call. Consult the Wiki API documentation for more details on what you can pass to this function.
- *
- * @method send
- * @param {Object} o Call object where there are three field id, method and params this object should also contain callbacks etc.
- */
- send : function(o) {
- var ecb = o.error, scb = o.success;
-
- o = extend(this.settings, o);
-
- o.success = function(c, x) {
- c = JSON.parse(c);
-
- if (typeof(c) == 'undefined') {
- c = {
- error : 'JSON Parse error.'
- };
- }
-
- if (c.error)
- ecb.call(o.error_scope || o.scope, c.error, x);
- else
- scb.call(o.success_scope || o.scope, c.result);
- };
-
- o.error = function(ty, x) {
- if (ecb)
- ecb.call(o.error_scope || o.scope, ty, x);
- };
-
- o.data = JSON.serialize({
- id : o.id || 'c' + (this.count++),
- method : o.method,
- params : o.params
- });
-
- // JSON content type for Ruby on rails. Bug: #1883287
- o.content_type = 'application/json';
-
- XHR.send(o);
- },
-
- 'static' : {
- /**
- * Simple helper function to send a JSON-RPC request without the need to initialize an object.
- * Consult the Wiki API documentation for more details on what you can pass to this function.
- *
- * @method sendRPC
- * @static
- * @param {Object} o Call object where there are three field id, method and params this object should also contain callbacks etc.
- */
- sendRPC : function(o) {
- return new tinymce.util.JSONRequest().send(o);
- }
- }
- });
+/**
+ * JSONRequest.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function() {
+ var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
+
+ /**
+ * This class enables you to use JSON-RPC to call backend methods.
+ *
+ * @class tinymce.util.JSONRequest
+ * @example
+ * var json = new tinymce.util.JSONRequest({
+ * url : 'somebackend.php'
+ * });
+ *
+ * // Send RPC call 1
+ * json.send({
+ * method : 'someMethod1',
+ * params : ['a', 'b'],
+ * success : function(result) {
+ * console.dir(result);
+ * }
+ * });
+ *
+ * // Send RPC call 2
+ * json.send({
+ * method : 'someMethod2',
+ * params : ['a', 'b'],
+ * success : function(result) {
+ * console.dir(result);
+ * }
+ * });
+ */
+ tinymce.create('tinymce.util.JSONRequest', {
+ /**
+ * Constructs a new JSONRequest instance.
+ *
+ * @constructor
+ * @method JSONRequest
+ * @param {Object} s Optional settings object.
+ */
+ JSONRequest : function(s) {
+ this.settings = extend({
+ }, s);
+ this.count = 0;
+ },
+
+ /**
+ * Sends a JSON-RPC call. Consult the Wiki API documentation for more details on what you can pass to this function.
+ *
+ * @method send
+ * @param {Object} o Call object where there are three field id, method and params this object should also contain callbacks etc.
+ */
+ send : function(o) {
+ var ecb = o.error, scb = o.success;
+
+ o = extend(this.settings, o);
+
+ o.success = function(c, x) {
+ c = JSON.parse(c);
+
+ if (typeof(c) == 'undefined') {
+ c = {
+ error : 'JSON Parse error.'
+ };
+ }
+
+ if (c.error)
+ ecb.call(o.error_scope || o.scope, c.error, x);
+ else
+ scb.call(o.success_scope || o.scope, c.result);
+ };
+
+ o.error = function(ty, x) {
+ if (ecb)
+ ecb.call(o.error_scope || o.scope, ty, x);
+ };
+
+ o.data = JSON.serialize({
+ id : o.id || 'c' + (this.count++),
+ method : o.method,
+ params : o.params
+ });
+
+ // JSON content type for Ruby on rails. Bug: #1883287
+ o.content_type = 'application/json';
+
+ XHR.send(o);
+ },
+
+ 'static' : {
+ /**
+ * Simple helper function to send a JSON-RPC request without the need to initialize an object.
+ * Consult the Wiki API documentation for more details on what you can pass to this function.
+ *
+ * @method sendRPC
+ * @static
+ * @param {Object} o Call object where there are three field id, method and params this object should also contain callbacks etc.
+ */
+ sendRPC : function(o) {
+ return new tinymce.util.JSONRequest().send(o);
+ }
+ }
+ });
}());
\ No newline at end of file
diff --git a/js/tiny_mce/classes/util/URI.js b/js/tiny_mce/classes/util/URI.js
index 3d96c8c491d..54907b628aa 100644
--- a/js/tiny_mce/classes/util/URI.js
+++ b/js/tiny_mce/classes/util/URI.js
@@ -1,319 +1,319 @@
-/**
- * URI.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-(function() {
- var each = tinymce.each;
-
- /**
- * This class handles parsing, modification and serialization of URI/URL strings.
- * @class tinymce.util.URI
- */
- tinymce.create('tinymce.util.URI', {
- /**
- * Constucts a new URI instance.
- *
- * @constructor
- * @method URI
- * @param {String} u URI string to parse.
- * @param {Object} s Optional settings object.
- */
- URI : function(u, s) {
- var t = this, o, a, b, base_url;
-
- // Trim whitespace
- u = tinymce.trim(u);
-
- // Default settings
- s = t.settings = s || {};
-
- // Strange app protocol that isn't http/https or local anchor
- // For example: mailto,skype,tel etc.
- if (/^([\w\-]+):([^\/]{2})/i.test(u) || /^\s*#/.test(u)) {
- t.source = u;
- return;
- }
-
- // Absolute path with no host, fake host and protocol
- if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
- u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
-
- // Relative path http:// or protocol relative //path
- if (!/^[\w\-]*:?\/\//.test(u)) {
- base_url = s.base_uri ? s.base_uri.path : new tinymce.util.URI(location.href).directory;
- u = ((s.base_uri && s.base_uri.protocol) || 'http') + '://mce_host' + t.toAbsPath(base_url, u);
- }
-
- // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
- u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
- u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
- each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
- var s = u[i];
-
- // Zope 3 workaround, they use @@something
- if (s)
- s = s.replace(/\(mce_at\)/g, '@@');
-
- t[v] = s;
- });
-
- b = s.base_uri;
- if (b) {
- if (!t.protocol)
- t.protocol = b.protocol;
-
- if (!t.userInfo)
- t.userInfo = b.userInfo;
-
- if (!t.port && t.host === 'mce_host')
- t.port = b.port;
-
- if (!t.host || t.host === 'mce_host')
- t.host = b.host;
-
- t.source = '';
- }
-
- //t.path = t.path || '/';
- },
-
- /**
- * Sets the internal path part of the URI.
- *
- * @method setPath
- * @param {string} p Path string to set.
- */
- setPath : function(p) {
- var t = this;
-
- p = /^(.*?)\/?(\w+)?$/.exec(p);
-
- // Update path parts
- t.path = p[0];
- t.directory = p[1];
- t.file = p[2];
-
- // Rebuild source
- t.source = '';
- t.getURI();
- },
-
- /**
- * Converts the specified URI into a relative URI based on the current URI instance location.
- *
- * @method toRelative
- * @param {String} u URI to convert into a relative path/URI.
- * @return {String} Relative URI from the point specified in the current URI instance.
- * @example
- * // Converts an absolute URL to an relative URL url will be somedir/somefile.htm
- * var url = new tinymce.util.URI('http://www.site.com/dir/').toRelative('http://www.site.com/dir/somedir/somefile.htm');
- */
- toRelative : function(u) {
- var t = this, o;
-
- if (u === "./")
- return u;
-
- u = new tinymce.util.URI(u, {base_uri : t});
-
- // Not on same domain/port or protocol
- if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol)
- return u.getURI();
-
- var tu = t.getURI(), uu = u.getURI();
-
- // Allow usage of the base_uri when relative_urls = true
- if(tu == uu || (tu.charAt(tu.length - 1) == "/" && tu.substr(0, tu.length - 1) == uu))
- return tu;
-
- o = t.toRelPath(t.path, u.path);
-
- // Add query
- if (u.query)
- o += '?' + u.query;
-
- // Add anchor
- if (u.anchor)
- o += '#' + u.anchor;
-
- return o;
- },
-
- /**
- * Converts the specified URI into a absolute URI based on the current URI instance location.
- *
- * @method toAbsolute
- * @param {String} u URI to convert into a relative path/URI.
- * @param {Boolean} nh No host and protocol prefix.
- * @return {String} Absolute URI from the point specified in the current URI instance.
- * @example
- * // Converts an relative URL to an absolute URL url will be http://www.site.com/dir/somedir/somefile.htm
- * var url = new tinymce.util.URI('http://www.site.com/dir/').toAbsolute('somedir/somefile.htm');
- */
- toAbsolute : function(u, nh) {
- u = new tinymce.util.URI(u, {base_uri : this});
-
- return u.getURI(this.host == u.host && this.protocol == u.protocol ? nh : 0);
- },
-
- /**
- * Converts a absolute path into a relative path.
- *
- * @method toRelPath
- * @param {String} base Base point to convert the path from.
- * @param {String} path Absolute path to convert into a relative path.
- */
- toRelPath : function(base, path) {
- var items, bp = 0, out = '', i, l;
-
- // Split the paths
- base = base.substring(0, base.lastIndexOf('/'));
- base = base.split('/');
- items = path.split('/');
-
- if (base.length >= items.length) {
- for (i = 0, l = base.length; i < l; i++) {
- if (i >= items.length || base[i] != items[i]) {
- bp = i + 1;
- break;
- }
- }
- }
-
- if (base.length < items.length) {
- for (i = 0, l = items.length; i < l; i++) {
- if (i >= base.length || base[i] != items[i]) {
- bp = i + 1;
- break;
- }
- }
- }
-
- if (bp === 1)
- return path;
-
- for (i = 0, l = base.length - (bp - 1); i < l; i++)
- out += "../";
-
- for (i = bp - 1, l = items.length; i < l; i++) {
- if (i != bp - 1)
- out += "/" + items[i];
- else
- out += items[i];
- }
-
- return out;
- },
-
- /**
- * Converts a relative path into a absolute path.
- *
- * @method toAbsPath
- * @param {String} base Base point to convert the path from.
- * @param {String} path Relative path to convert into an absolute path.
- */
- toAbsPath : function(base, path) {
- var i, nb = 0, o = [], tr, outPath;
-
- // Split paths
- tr = /\/$/.test(path) ? '/' : '';
- base = base.split('/');
- path = path.split('/');
-
- // Remove empty chunks
- each(base, function(k) {
- if (k)
- o.push(k);
- });
-
- base = o;
-
- // Merge relURLParts chunks
- for (i = path.length - 1, o = []; i >= 0; i--) {
- // Ignore empty or .
- if (path[i].length === 0 || path[i] === ".")
- continue;
-
- // Is parent
- if (path[i] === '..') {
- nb++;
- continue;
- }
-
- // Move up
- if (nb > 0) {
- nb--;
- continue;
- }
-
- o.push(path[i]);
- }
-
- i = base.length - nb;
-
- // If /a/b/c or /
- if (i <= 0)
- outPath = o.reverse().join('/');
- else
- outPath = base.slice(0, i).join('/') + '/' + o.reverse().join('/');
-
- // Add front / if it's needed
- if (outPath.indexOf('/') !== 0)
- outPath = '/' + outPath;
-
- // Add traling / if it's needed
- if (tr && outPath.lastIndexOf('/') !== outPath.length - 1)
- outPath += tr;
-
- return outPath;
- },
-
- /**
- * Returns the full URI of the internal structure.
- *
- * @method getURI
- * @param {Boolean} nh Optional no host and protocol part. Defaults to false.
- */
- getURI : function(nh) {
- var s, t = this;
-
- // Rebuild source
- if (!t.source || nh) {
- s = '';
-
- if (!nh) {
- if (t.protocol)
- s += t.protocol + '://';
-
- if (t.userInfo)
- s += t.userInfo + '@';
-
- if (t.host)
- s += t.host;
-
- if (t.port)
- s += ':' + t.port;
- }
-
- if (t.path)
- s += t.path;
-
- if (t.query)
- s += '?' + t.query;
-
- if (t.anchor)
- s += '#' + t.anchor;
-
- t.source = s;
- }
-
- return t.source;
- }
- });
-})();
+/**
+ * URI.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+(function() {
+ var each = tinymce.each;
+
+ /**
+ * This class handles parsing, modification and serialization of URI/URL strings.
+ * @class tinymce.util.URI
+ */
+ tinymce.create('tinymce.util.URI', {
+ /**
+ * Constucts a new URI instance.
+ *
+ * @constructor
+ * @method URI
+ * @param {String} u URI string to parse.
+ * @param {Object} s Optional settings object.
+ */
+ URI : function(u, s) {
+ var t = this, o, a, b, base_url;
+
+ // Trim whitespace
+ u = tinymce.trim(u);
+
+ // Default settings
+ s = t.settings = s || {};
+
+ // Strange app protocol that isn't http/https or local anchor
+ // For example: mailto,skype,tel etc.
+ if (/^([\w\-]+):([^\/]{2})/i.test(u) || /^\s*#/.test(u)) {
+ t.source = u;
+ return;
+ }
+
+ // Absolute path with no host, fake host and protocol
+ if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
+ u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
+
+ // Relative path http:// or protocol relative //path
+ if (!/^[\w\-]*:?\/\//.test(u)) {
+ base_url = s.base_uri ? s.base_uri.path : new tinymce.util.URI(location.href).directory;
+ u = ((s.base_uri && s.base_uri.protocol) || 'http') + '://mce_host' + t.toAbsPath(base_url, u);
+ }
+
+ // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
+ u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
+ u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
+ each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
+ var s = u[i];
+
+ // Zope 3 workaround, they use @@something
+ if (s)
+ s = s.replace(/\(mce_at\)/g, '@@');
+
+ t[v] = s;
+ });
+
+ b = s.base_uri;
+ if (b) {
+ if (!t.protocol)
+ t.protocol = b.protocol;
+
+ if (!t.userInfo)
+ t.userInfo = b.userInfo;
+
+ if (!t.port && t.host === 'mce_host')
+ t.port = b.port;
+
+ if (!t.host || t.host === 'mce_host')
+ t.host = b.host;
+
+ t.source = '';
+ }
+
+ //t.path = t.path || '/';
+ },
+
+ /**
+ * Sets the internal path part of the URI.
+ *
+ * @method setPath
+ * @param {string} p Path string to set.
+ */
+ setPath : function(p) {
+ var t = this;
+
+ p = /^(.*?)\/?(\w+)?$/.exec(p);
+
+ // Update path parts
+ t.path = p[0];
+ t.directory = p[1];
+ t.file = p[2];
+
+ // Rebuild source
+ t.source = '';
+ t.getURI();
+ },
+
+ /**
+ * Converts the specified URI into a relative URI based on the current URI instance location.
+ *
+ * @method toRelative
+ * @param {String} u URI to convert into a relative path/URI.
+ * @return {String} Relative URI from the point specified in the current URI instance.
+ * @example
+ * // Converts an absolute URL to an relative URL url will be somedir/somefile.htm
+ * var url = new tinymce.util.URI('http://www.site.com/dir/').toRelative('http://www.site.com/dir/somedir/somefile.htm');
+ */
+ toRelative : function(u) {
+ var t = this, o;
+
+ if (u === "./")
+ return u;
+
+ u = new tinymce.util.URI(u, {base_uri : t});
+
+ // Not on same domain/port or protocol
+ if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol)
+ return u.getURI();
+
+ var tu = t.getURI(), uu = u.getURI();
+
+ // Allow usage of the base_uri when relative_urls = true
+ if(tu == uu || (tu.charAt(tu.length - 1) == "/" && tu.substr(0, tu.length - 1) == uu))
+ return tu;
+
+ o = t.toRelPath(t.path, u.path);
+
+ // Add query
+ if (u.query)
+ o += '?' + u.query;
+
+ // Add anchor
+ if (u.anchor)
+ o += '#' + u.anchor;
+
+ return o;
+ },
+
+ /**
+ * Converts the specified URI into a absolute URI based on the current URI instance location.
+ *
+ * @method toAbsolute
+ * @param {String} u URI to convert into a relative path/URI.
+ * @param {Boolean} nh No host and protocol prefix.
+ * @return {String} Absolute URI from the point specified in the current URI instance.
+ * @example
+ * // Converts an relative URL to an absolute URL url will be http://www.site.com/dir/somedir/somefile.htm
+ * var url = new tinymce.util.URI('http://www.site.com/dir/').toAbsolute('somedir/somefile.htm');
+ */
+ toAbsolute : function(u, nh) {
+ u = new tinymce.util.URI(u, {base_uri : this});
+
+ return u.getURI(this.host == u.host && this.protocol == u.protocol ? nh : 0);
+ },
+
+ /**
+ * Converts a absolute path into a relative path.
+ *
+ * @method toRelPath
+ * @param {String} base Base point to convert the path from.
+ * @param {String} path Absolute path to convert into a relative path.
+ */
+ toRelPath : function(base, path) {
+ var items, bp = 0, out = '', i, l;
+
+ // Split the paths
+ base = base.substring(0, base.lastIndexOf('/'));
+ base = base.split('/');
+ items = path.split('/');
+
+ if (base.length >= items.length) {
+ for (i = 0, l = base.length; i < l; i++) {
+ if (i >= items.length || base[i] != items[i]) {
+ bp = i + 1;
+ break;
+ }
+ }
+ }
+
+ if (base.length < items.length) {
+ for (i = 0, l = items.length; i < l; i++) {
+ if (i >= base.length || base[i] != items[i]) {
+ bp = i + 1;
+ break;
+ }
+ }
+ }
+
+ if (bp === 1)
+ return path;
+
+ for (i = 0, l = base.length - (bp - 1); i < l; i++)
+ out += "../";
+
+ for (i = bp - 1, l = items.length; i < l; i++) {
+ if (i != bp - 1)
+ out += "/" + items[i];
+ else
+ out += items[i];
+ }
+
+ return out;
+ },
+
+ /**
+ * Converts a relative path into a absolute path.
+ *
+ * @method toAbsPath
+ * @param {String} base Base point to convert the path from.
+ * @param {String} path Relative path to convert into an absolute path.
+ */
+ toAbsPath : function(base, path) {
+ var i, nb = 0, o = [], tr, outPath;
+
+ // Split paths
+ tr = /\/$/.test(path) ? '/' : '';
+ base = base.split('/');
+ path = path.split('/');
+
+ // Remove empty chunks
+ each(base, function(k) {
+ if (k)
+ o.push(k);
+ });
+
+ base = o;
+
+ // Merge relURLParts chunks
+ for (i = path.length - 1, o = []; i >= 0; i--) {
+ // Ignore empty or .
+ if (path[i].length === 0 || path[i] === ".")
+ continue;
+
+ // Is parent
+ if (path[i] === '..') {
+ nb++;
+ continue;
+ }
+
+ // Move up
+ if (nb > 0) {
+ nb--;
+ continue;
+ }
+
+ o.push(path[i]);
+ }
+
+ i = base.length - nb;
+
+ // If /a/b/c or /
+ if (i <= 0)
+ outPath = o.reverse().join('/');
+ else
+ outPath = base.slice(0, i).join('/') + '/' + o.reverse().join('/');
+
+ // Add front / if it's needed
+ if (outPath.indexOf('/') !== 0)
+ outPath = '/' + outPath;
+
+ // Add traling / if it's needed
+ if (tr && outPath.lastIndexOf('/') !== outPath.length - 1)
+ outPath += tr;
+
+ return outPath;
+ },
+
+ /**
+ * Returns the full URI of the internal structure.
+ *
+ * @method getURI
+ * @param {Boolean} nh Optional no host and protocol part. Defaults to false.
+ */
+ getURI : function(nh) {
+ var s, t = this;
+
+ // Rebuild source
+ if (!t.source || nh) {
+ s = '';
+
+ if (!nh) {
+ if (t.protocol)
+ s += t.protocol + '://';
+
+ if (t.userInfo)
+ s += t.userInfo + '@';
+
+ if (t.host)
+ s += t.host;
+
+ if (t.port)
+ s += ':' + t.port;
+ }
+
+ if (t.path)
+ s += t.path;
+
+ if (t.query)
+ s += '?' + t.query;
+
+ if (t.anchor)
+ s += '#' + t.anchor;
+
+ t.source = s;
+ }
+
+ return t.source;
+ }
+ });
+})();
diff --git a/js/tiny_mce/classes/util/XHR.js b/js/tiny_mce/classes/util/XHR.js
index 16b64f402dd..c74879e14de 100644
--- a/js/tiny_mce/classes/util/XHR.js
+++ b/js/tiny_mce/classes/util/XHR.js
@@ -1,88 +1,88 @@
-/**
- * XHR.js
- *
- * Copyright, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://www.tinymce.com/license
- * Contributing: http://www.tinymce.com/contributing
- */
-
-/**
- * This class enables you to send XMLHTTPRequests cross browser.
- * @class tinymce.util.XHR
- * @static
- * @example
- * // Sends a low level Ajax request
- * tinymce.util.XHR.send({
- * url : 'someurl',
- * success : function(text) {
- * console.debug(text);
- * }
- * });
- */
-tinymce.create('static tinymce.util.XHR', {
- /**
- * Sends a XMLHTTPRequest.
- * Consult the Wiki for details on what settings this method takes.
- *
- * @method send
- * @param {Object} o Object will target URL, callbacks and other info needed to make the request.
- */
- send : function(o) {
- var x, t, w = window, c = 0;
-
- function ready() {
- if (!o.async || x.readyState == 4 || c++ > 10000) {
- if (o.success && c < 10000 && x.status == 200)
- o.success.call(o.success_scope, '' + x.responseText, x, o);
- else if (o.error)
- o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
-
- x = null;
- } else
- w.setTimeout(ready, 10);
- };
-
- // Default settings
- o.scope = o.scope || this;
- o.success_scope = o.success_scope || o.scope;
- o.error_scope = o.error_scope || o.scope;
- o.async = o.async === false ? false : true;
- o.data = o.data || '';
-
- function get(s) {
- x = 0;
-
- try {
- x = new ActiveXObject(s);
- } catch (ex) {
- }
-
- return x;
- };
-
- x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
-
- if (x) {
- if (x.overrideMimeType)
- x.overrideMimeType(o.content_type);
-
- x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async);
-
- if (o.content_type)
- x.setRequestHeader('Content-Type', o.content_type);
-
- x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
-
- x.send(o.data);
-
- // Syncronous request
- if (!o.async)
- return ready();
-
- // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
- t = w.setTimeout(ready, 10);
- }
- }
-});
+/**
+ * XHR.js
+ *
+ * Copyright, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
+ */
+
+/**
+ * This class enables you to send XMLHTTPRequests cross browser.
+ * @class tinymce.util.XHR
+ * @static
+ * @example
+ * // Sends a low level Ajax request
+ * tinymce.util.XHR.send({
+ * url : 'someurl',
+ * success : function(text) {
+ * console.debug(text);
+ * }
+ * });
+ */
+tinymce.create('static tinymce.util.XHR', {
+ /**
+ * Sends a XMLHTTPRequest.
+ * Consult the Wiki for details on what settings this method takes.
+ *
+ * @method send
+ * @param {Object} o Object will target URL, callbacks and other info needed to make the request.
+ */
+ send : function(o) {
+ var x, t, w = window, c = 0;
+
+ function ready() {
+ if (!o.async || x.readyState == 4 || c++ > 10000) {
+ if (o.success && c < 10000 && x.status == 200)
+ o.success.call(o.success_scope, '' + x.responseText, x, o);
+ else if (o.error)
+ o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
+
+ x = null;
+ } else
+ w.setTimeout(ready, 10);
+ };
+
+ // Default settings
+ o.scope = o.scope || this;
+ o.success_scope = o.success_scope || o.scope;
+ o.error_scope = o.error_scope || o.scope;
+ o.async = o.async === false ? false : true;
+ o.data = o.data || '';
+
+ function get(s) {
+ x = 0;
+
+ try {
+ x = new ActiveXObject(s);
+ } catch (ex) {
+ }
+
+ return x;
+ };
+
+ x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
+
+ if (x) {
+ if (x.overrideMimeType)
+ x.overrideMimeType(o.content_type);
+
+ x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async);
+
+ if (o.content_type)
+ x.setRequestHeader('Content-Type', o.content_type);
+
+ x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+
+ x.send(o.data);
+
+ // Syncronous request
+ if (!o.async)
+ return ready();
+
+ // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
+ t = w.setTimeout(ready, 10);
+ }
+ }
+});
diff --git a/js/tiny_mce/classes/xml/Parser.js b/js/tiny_mce/classes/xml/Parser.js
index 6d21b996ae5..e29965513ae 100644
--- a/js/tiny_mce/classes/xml/Parser.js
+++ b/js/tiny_mce/classes/xml/Parser.js
@@ -1,129 +1,129 @@
-/**
- * Parser.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
-(function() {
- /**
- * XML Parser class. This class is only available for the dev version of TinyMCE.
- */
- tinymce.create('tinymce.xml.Parser', {
- /**
- * Constucts a new XML parser instance.
- *
- * @param {Object} Optional settings object.
- */
- Parser : function(s) {
- this.settings = tinymce.extend({
- async : true
- }, s);
- },
-
- /**
- * Parses the specified document and executed the callback ones it's parsed.
- *
- * @param {String} u URL to XML file to parse.
- * @param {function} cb Optional callback to execute ones the XML file is loaded.
- * @param {Object} s Optional scope for the callback execution.
- */
- load : function(u, cb, s) {
- var doc, t, w = window, c = 0;
-
- s = s || this;
-
- // Explorer, use XMLDOM since it can be used on local fs
- if (window.ActiveXObject) {
- doc = new ActiveXObject("Microsoft.XMLDOM");
- doc.async = this.settings.async;
-
- // Wait for response
- if (doc.async) {
- function check() {
- if (doc.readyState == 4 || c++ > 10000)
- return cb.call(s, doc);
-
- w.setTimeout(check, 10);
- };
-
- t = w.setTimeout(check, 10);
- }
-
- doc.load(u);
-
- if (!doc.async)
- cb.call(s, doc);
-
- return;
- }
-
- // W3C using XMLHttpRequest
- if (window.XMLHttpRequest) {
- try {
- doc = new window.XMLHttpRequest();
- doc.open('GET', u, this.settings.async);
- doc.async = this.settings.async;
-
- doc.onload = function() {
- cb.call(s, doc.responseXML);
- };
-
- doc.send('');
- } catch (ex) {
- cb.call(s, null, ex);
- }
- }
- },
-
- /**
- * Parses the specified XML string.
- *
- * @param {String} xml XML String to parse.
- * @return {Document} XML Document instance.
- */
- loadXML : function(xml) {
- var doc;
-
- // W3C
- if (window.DOMParser)
- return new DOMParser().parseFromString(xml, "text/xml");
-
- // Explorer
- if (window.ActiveXObject) {
- doc = new ActiveXObject("Microsoft.XMLDOM");
- doc.async = "false";
- doc.loadXML(xml);
-
- return doc;
- }
- },
-
- /**
- * Returns all string contents of a element concated together.
- *
- * @param {XMLNode} el XML element to retrieve text from.
- * @return {string} XML element text contents.
- */
- getText : function(el) {
- var o = '';
-
- if (!el)
- return '';
-
- if (el.hasChildNodes()) {
- el = el.firstChild;
-
- do {
- if (el.nodeType == 3 || el.nodeType == 4)
- o += el.nodeValue;
- } while(el = el.nextSibling);
- }
-
- return o;
- }
- });
-})();
+/**
+ * Parser.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function() {
+ /**
+ * XML Parser class. This class is only available for the dev version of TinyMCE.
+ */
+ tinymce.create('tinymce.xml.Parser', {
+ /**
+ * Constucts a new XML parser instance.
+ *
+ * @param {Object} Optional settings object.
+ */
+ Parser : function(s) {
+ this.settings = tinymce.extend({
+ async : true
+ }, s);
+ },
+
+ /**
+ * Parses the specified document and executed the callback ones it's parsed.
+ *
+ * @param {String} u URL to XML file to parse.
+ * @param {function} cb Optional callback to execute ones the XML file is loaded.
+ * @param {Object} s Optional scope for the callback execution.
+ */
+ load : function(u, cb, s) {
+ var doc, t, w = window, c = 0;
+
+ s = s || this;
+
+ // Explorer, use XMLDOM since it can be used on local fs
+ if (window.ActiveXObject) {
+ doc = new ActiveXObject("Microsoft.XMLDOM");
+ doc.async = this.settings.async;
+
+ // Wait for response
+ if (doc.async) {
+ function check() {
+ if (doc.readyState == 4 || c++ > 10000)
+ return cb.call(s, doc);
+
+ w.setTimeout(check, 10);
+ };
+
+ t = w.setTimeout(check, 10);
+ }
+
+ doc.load(u);
+
+ if (!doc.async)
+ cb.call(s, doc);
+
+ return;
+ }
+
+ // W3C using XMLHttpRequest
+ if (window.XMLHttpRequest) {
+ try {
+ doc = new window.XMLHttpRequest();
+ doc.open('GET', u, this.settings.async);
+ doc.async = this.settings.async;
+
+ doc.onload = function() {
+ cb.call(s, doc.responseXML);
+ };
+
+ doc.send('');
+ } catch (ex) {
+ cb.call(s, null, ex);
+ }
+ }
+ },
+
+ /**
+ * Parses the specified XML string.
+ *
+ * @param {String} xml XML String to parse.
+ * @return {Document} XML Document instance.
+ */
+ loadXML : function(xml) {
+ var doc;
+
+ // W3C
+ if (window.DOMParser)
+ return new DOMParser().parseFromString(xml, "text/xml");
+
+ // Explorer
+ if (window.ActiveXObject) {
+ doc = new ActiveXObject("Microsoft.XMLDOM");
+ doc.async = "false";
+ doc.loadXML(xml);
+
+ return doc;
+ }
+ },
+
+ /**
+ * Returns all string contents of a element concated together.
+ *
+ * @param {XMLNode} el XML element to retrieve text from.
+ * @return {string} XML element text contents.
+ */
+ getText : function(el) {
+ var o = '';
+
+ if (!el)
+ return '';
+
+ if (el.hasChildNodes()) {
+ el = el.firstChild;
+
+ do {
+ if (el.nodeType == 3 || el.nodeType == 4)
+ o += el.nodeValue;
+ } while(el = el.nextSibling);
+ }
+
+ return o;
+ }
+ });
+})();
diff --git a/js/tiny_mce/license.txt b/js/tiny_mce/license.txt
index 5a253429948..14ebc6f4b6f 100644
--- a/js/tiny_mce/license.txt
+++ b/js/tiny_mce/license.txt
@@ -1,504 +1,504 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefuly about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefuly about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/js/tiny_mce/plugins/advhr/css/advhr.css b/js/tiny_mce/plugins/advhr/css/advhr.css
index 0e22834985e..3fe369cb0d0 100644
--- a/js/tiny_mce/plugins/advhr/css/advhr.css
+++ b/js/tiny_mce/plugins/advhr/css/advhr.css
@@ -1,5 +1,5 @@
-input.radio {border:1px none #000; background:transparent; vertical-align:middle;}
-.panel_wrapper div.current {height:80px;}
-#width {width:50px; vertical-align:middle;}
-#width2 {width:50px; vertical-align:middle;}
-#size {width:100px;}
+input.radio {border:1px none #000; background:transparent; vertical-align:middle;}
+.panel_wrapper div.current {height:80px;}
+#width {width:50px; vertical-align:middle;}
+#width2 {width:50px; vertical-align:middle;}
+#size {width:100px;}
diff --git a/js/tiny_mce/plugins/advhr/editor_plugin_src.js b/js/tiny_mce/plugins/advhr/editor_plugin_src.js
index 0c652d3303e..5a4b7250bcc 100644
--- a/js/tiny_mce/plugins/advhr/editor_plugin_src.js
+++ b/js/tiny_mce/plugins/advhr/editor_plugin_src.js
@@ -1,57 +1,57 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
-(function() {
- tinymce.create('tinymce.plugins.AdvancedHRPlugin', {
- init : function(ed, url) {
- // Register commands
- ed.addCommand('mceAdvancedHr', function() {
- ed.windowManager.open({
- file : url + '/rule.htm',
- width : 250 + parseInt(ed.getLang('advhr.delta_width', 0)),
- height : 160 + parseInt(ed.getLang('advhr.delta_height', 0)),
- inline : 1
- }, {
- plugin_url : url
- });
- });
-
- // Register buttons
- ed.addButton('advhr', {
- title : 'advhr.advhr_desc',
- cmd : 'mceAdvancedHr'
- });
-
- ed.onNodeChange.add(function(ed, cm, n) {
- cm.setActive('advhr', n.nodeName == 'HR');
- });
-
- ed.onClick.add(function(ed, e) {
- e = e.target;
-
- if (e.nodeName === 'HR')
- ed.selection.select(e);
- });
- },
-
- getInfo : function() {
- return {
- longname : 'Advanced HR',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
- };
- }
- });
-
- // Register plugin
- tinymce.PluginManager.add('advhr', tinymce.plugins.AdvancedHRPlugin);
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function() {
+ tinymce.create('tinymce.plugins.AdvancedHRPlugin', {
+ init : function(ed, url) {
+ // Register commands
+ ed.addCommand('mceAdvancedHr', function() {
+ ed.windowManager.open({
+ file : url + '/rule.htm',
+ width : 250 + parseInt(ed.getLang('advhr.delta_width', 0)),
+ height : 160 + parseInt(ed.getLang('advhr.delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ });
+
+ // Register buttons
+ ed.addButton('advhr', {
+ title : 'advhr.advhr_desc',
+ cmd : 'mceAdvancedHr'
+ });
+
+ ed.onNodeChange.add(function(ed, cm, n) {
+ cm.setActive('advhr', n.nodeName == 'HR');
+ });
+
+ ed.onClick.add(function(ed, e) {
+ e = e.target;
+
+ if (e.nodeName === 'HR')
+ ed.selection.select(e);
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'Advanced HR',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('advhr', tinymce.plugins.AdvancedHRPlugin);
})();
\ No newline at end of file
diff --git a/js/tiny_mce/plugins/advhr/js/rule.js b/js/tiny_mce/plugins/advhr/js/rule.js
index b6cbd66c759..a60c35fc3ce 100644
--- a/js/tiny_mce/plugins/advhr/js/rule.js
+++ b/js/tiny_mce/plugins/advhr/js/rule.js
@@ -1,43 +1,43 @@
-var AdvHRDialog = {
- init : function(ed) {
- var dom = ed.dom, f = document.forms[0], n = ed.selection.getNode(), w;
-
- w = dom.getAttrib(n, 'width');
- f.width.value = w ? parseInt(w) : (dom.getStyle('width') || '');
- f.size.value = dom.getAttrib(n, 'size') || parseInt(dom.getStyle('height')) || '';
- f.noshade.checked = !!dom.getAttrib(n, 'noshade') || !!dom.getStyle('border-width');
- selectByValue(f, 'width2', w.indexOf('%') != -1 ? '%' : 'px');
- },
-
- update : function() {
- var ed = tinyMCEPopup.editor, h, f = document.forms[0], st = '';
-
- h = '';
-
- ed.execCommand("mceInsertContent", false, h);
- tinyMCEPopup.close();
- }
-};
-
-tinyMCEPopup.requireLangPack();
-tinyMCEPopup.onInit.add(AdvHRDialog.init, AdvHRDialog);
+var AdvHRDialog = {
+ init : function(ed) {
+ var dom = ed.dom, f = document.forms[0], n = ed.selection.getNode(), w;
+
+ w = dom.getAttrib(n, 'width');
+ f.width.value = w ? parseInt(w) : (dom.getStyle('width') || '');
+ f.size.value = dom.getAttrib(n, 'size') || parseInt(dom.getStyle('height')) || '';
+ f.noshade.checked = !!dom.getAttrib(n, 'noshade') || !!dom.getStyle('border-width');
+ selectByValue(f, 'width2', w.indexOf('%') != -1 ? '%' : 'px');
+ },
+
+ update : function() {
+ var ed = tinyMCEPopup.editor, h, f = document.forms[0], st = '';
+
+ h = '';
+
+ ed.execCommand("mceInsertContent", false, h);
+ tinyMCEPopup.close();
+ }
+};
+
+tinyMCEPopup.requireLangPack();
+tinyMCEPopup.onInit.add(AdvHRDialog.init, AdvHRDialog);
diff --git a/js/tiny_mce/plugins/advimage/css/advimage.css b/js/tiny_mce/plugins/advimage/css/advimage.css
index 0a6251a6965..228530f9ee8 100644
--- a/js/tiny_mce/plugins/advimage/css/advimage.css
+++ b/js/tiny_mce/plugins/advimage/css/advimage.css
@@ -1,13 +1,13 @@
-#src_list, #over_list, #out_list {width:280px;}
-.mceActionPanel {margin-top:7px;}
-.alignPreview {border:1px solid #000; width:140px; height:140px; overflow:hidden; padding:5px;}
-.checkbox {border:0;}
-.panel_wrapper div.current {height:305px;}
-#prev {margin:0; border:1px solid #000; width:428px; height:150px; overflow:auto;}
-#align, #classlist {width:150px;}
-#width, #height {vertical-align:middle; width:50px; text-align:center;}
-#vspace, #hspace, #border {vertical-align:middle; width:30px; text-align:center;}
-#class_list {width:180px;}
-input {width: 280px;}
-#constrain, #onmousemovecheck {width:auto;}
-#id, #dir, #lang, #usemap, #longdesc {width:200px;}
+#src_list, #over_list, #out_list {width:280px;}
+.mceActionPanel {margin-top:7px;}
+.alignPreview {border:1px solid #000; width:140px; height:140px; overflow:hidden; padding:5px;}
+.checkbox {border:0;}
+.panel_wrapper div.current {height:305px;}
+#prev {margin:0; border:1px solid #000; width:428px; height:150px; overflow:auto;}
+#align, #classlist {width:150px;}
+#width, #height {vertical-align:middle; width:50px; text-align:center;}
+#vspace, #hspace, #border {vertical-align:middle; width:30px; text-align:center;}
+#class_list {width:180px;}
+input {width: 280px;}
+#constrain, #onmousemovecheck {width:auto;}
+#id, #dir, #lang, #usemap, #longdesc {width:200px;}
diff --git a/js/tiny_mce/plugins/advimage/editor_plugin_src.js b/js/tiny_mce/plugins/advimage/editor_plugin_src.js
index d2678cbcf2e..76df89a3a9b 100644
--- a/js/tiny_mce/plugins/advimage/editor_plugin_src.js
+++ b/js/tiny_mce/plugins/advimage/editor_plugin_src.js
@@ -1,50 +1,50 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
-(function() {
- tinymce.create('tinymce.plugins.AdvancedImagePlugin', {
- init : function(ed, url) {
- // Register commands
- ed.addCommand('mceAdvImage', function() {
- // Internal image object like a flash placeholder
- if (ed.dom.getAttrib(ed.selection.getNode(), 'class', '').indexOf('mceItem') != -1)
- return;
-
- ed.windowManager.open({
- file : url + '/image.htm',
- width : 480 + parseInt(ed.getLang('advimage.delta_width', 0)),
- height : 385 + parseInt(ed.getLang('advimage.delta_height', 0)),
- inline : 1
- }, {
- plugin_url : url
- });
- });
-
- // Register buttons
- ed.addButton('image', {
- title : 'advimage.image_desc',
- cmd : 'mceAdvImage'
- });
- },
-
- getInfo : function() {
- return {
- longname : 'Advanced image',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
- };
- }
- });
-
- // Register plugin
- tinymce.PluginManager.add('advimage', tinymce.plugins.AdvancedImagePlugin);
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function() {
+ tinymce.create('tinymce.plugins.AdvancedImagePlugin', {
+ init : function(ed, url) {
+ // Register commands
+ ed.addCommand('mceAdvImage', function() {
+ // Internal image object like a flash placeholder
+ if (ed.dom.getAttrib(ed.selection.getNode(), 'class', '').indexOf('mceItem') != -1)
+ return;
+
+ ed.windowManager.open({
+ file : url + '/image.htm',
+ width : 480 + parseInt(ed.getLang('advimage.delta_width', 0)),
+ height : 385 + parseInt(ed.getLang('advimage.delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ });
+
+ // Register buttons
+ ed.addButton('image', {
+ title : 'advimage.image_desc',
+ cmd : 'mceAdvImage'
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'Advanced image',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('advimage', tinymce.plugins.AdvancedImagePlugin);
})();
\ No newline at end of file
diff --git a/js/tiny_mce/plugins/advimage/js/image.js b/js/tiny_mce/plugins/advimage/js/image.js
index f0b7c6eef58..02495fbf086 100644
--- a/js/tiny_mce/plugins/advimage/js/image.js
+++ b/js/tiny_mce/plugins/advimage/js/image.js
@@ -1,464 +1,464 @@
-var ImageDialog = {
- preInit : function() {
- var url;
-
- tinyMCEPopup.requireLangPack();
-
- if (url = tinyMCEPopup.getParam("external_image_list_url"))
- document.write('');
- },
-
- init : function(ed) {
- var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList');
-
- tinyMCEPopup.resizeToInnerSize();
- this.fillClassList('class_list');
- this.fillFileList('src_list', fl);
- this.fillFileList('over_list', fl);
- this.fillFileList('out_list', fl);
- TinyMCE_EditableSelects.init();
-
- if (n.nodeName == 'IMG') {
- nl.src.value = dom.getAttrib(n, 'src');
- nl.width.value = dom.getAttrib(n, 'width');
- nl.height.value = dom.getAttrib(n, 'height');
- nl.alt.value = dom.getAttrib(n, 'alt');
- nl.title.value = dom.getAttrib(n, 'title');
- nl.vspace.value = this.getAttrib(n, 'vspace');
- nl.hspace.value = this.getAttrib(n, 'hspace');
- nl.border.value = this.getAttrib(n, 'border');
- selectByValue(f, 'align', this.getAttrib(n, 'align'));
- selectByValue(f, 'class_list', dom.getAttrib(n, 'class'), true, true);
- nl.style.value = dom.getAttrib(n, 'style');
- nl.id.value = dom.getAttrib(n, 'id');
- nl.dir.value = dom.getAttrib(n, 'dir');
- nl.lang.value = dom.getAttrib(n, 'lang');
- nl.usemap.value = dom.getAttrib(n, 'usemap');
- nl.longdesc.value = dom.getAttrib(n, 'longdesc');
- nl.insert.value = ed.getLang('update');
-
- if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover')))
- nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
-
- if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout')))
- nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
-
- if (ed.settings.inline_styles) {
- // Move attribs to styles
- if (dom.getAttrib(n, 'align'))
- this.updateStyle('align');
-
- if (dom.getAttrib(n, 'hspace'))
- this.updateStyle('hspace');
-
- if (dom.getAttrib(n, 'border'))
- this.updateStyle('border');
-
- if (dom.getAttrib(n, 'vspace'))
- this.updateStyle('vspace');
- }
- }
-
- // Setup browse button
- document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image');
- if (isVisible('srcbrowser'))
- document.getElementById('src').style.width = '260px';
-
- // Setup browse button
- document.getElementById('onmouseoversrccontainer').innerHTML = getBrowserHTML('overbrowser','onmouseoversrc','image','theme_advanced_image');
- if (isVisible('overbrowser'))
- document.getElementById('onmouseoversrc').style.width = '260px';
-
- // Setup browse button
- document.getElementById('onmouseoutsrccontainer').innerHTML = getBrowserHTML('outbrowser','onmouseoutsrc','image','theme_advanced_image');
- if (isVisible('outbrowser'))
- document.getElementById('onmouseoutsrc').style.width = '260px';
-
- // If option enabled default contrain proportions to checked
- if (ed.getParam("advimage_constrain_proportions", true))
- f.constrain.checked = true;
-
- // Check swap image if valid data
- if (nl.onmouseoversrc.value || nl.onmouseoutsrc.value)
- this.setSwapImage(true);
- else
- this.setSwapImage(false);
-
- this.changeAppearance();
- this.showPreviewImage(nl.src.value, 1);
- },
-
- insert : function(file, title) {
- var ed = tinyMCEPopup.editor, t = this, f = document.forms[0];
-
- if (f.src.value === '') {
- if (ed.selection.getNode().nodeName == 'IMG') {
- ed.dom.remove(ed.selection.getNode());
- ed.execCommand('mceRepaint');
- }
-
- tinyMCEPopup.close();
- return;
- }
-
- if (tinyMCEPopup.getParam("accessibility_warnings", 1)) {
- if (!f.alt.value) {
- tinyMCEPopup.confirm(tinyMCEPopup.getLang('advimage_dlg.missing_alt'), function(s) {
- if (s)
- t.insertAndClose();
- });
-
- return;
- }
- }
-
- t.insertAndClose();
- },
-
- insertAndClose : function() {
- var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
-
- tinyMCEPopup.restoreSelection();
-
- // Fixes crash in Safari
- if (tinymce.isWebKit)
- ed.getWin().focus();
-
- if (!ed.settings.inline_styles) {
- args = {
- vspace : nl.vspace.value,
- hspace : nl.hspace.value,
- border : nl.border.value,
- align : getSelectValue(f, 'align')
- };
- } else {
- // Remove deprecated values
- args = {
- vspace : '',
- hspace : '',
- border : '',
- align : ''
- };
- }
-
- tinymce.extend(args, {
- src : nl.src.value.replace(/ /g, '%20'),
- width : nl.width.value,
- height : nl.height.value,
- alt : nl.alt.value,
- title : nl.title.value,
- 'class' : getSelectValue(f, 'class_list'),
- style : nl.style.value,
- id : nl.id.value,
- dir : nl.dir.value,
- lang : nl.lang.value,
- usemap : nl.usemap.value,
- longdesc : nl.longdesc.value
- });
-
- args.onmouseover = args.onmouseout = '';
-
- if (f.onmousemovecheck.checked) {
- if (nl.onmouseoversrc.value)
- args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';";
-
- if (nl.onmouseoutsrc.value)
- args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';";
- }
-
- el = ed.selection.getNode();
-
- if (el && el.nodeName == 'IMG') {
- ed.dom.setAttribs(el, args);
- } else {
- tinymce.each(args, function(value, name) {
- if (value === "") {
- delete args[name];
- }
- });
-
- ed.execCommand('mceInsertContent', false, tinyMCEPopup.editor.dom.createHTML('img', args), {skip_undo : 1});
- ed.undoManager.add();
- }
-
- tinyMCEPopup.editor.execCommand('mceRepaint');
- tinyMCEPopup.editor.focus();
- tinyMCEPopup.close();
- },
-
- getAttrib : function(e, at) {
- var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
-
- if (ed.settings.inline_styles) {
- switch (at) {
- case 'align':
- if (v = dom.getStyle(e, 'float'))
- return v;
-
- if (v = dom.getStyle(e, 'vertical-align'))
- return v;
-
- break;
-
- case 'hspace':
- v = dom.getStyle(e, 'margin-left')
- v2 = dom.getStyle(e, 'margin-right');
-
- if (v && v == v2)
- return parseInt(v.replace(/[^0-9]/g, ''));
-
- break;
-
- case 'vspace':
- v = dom.getStyle(e, 'margin-top')
- v2 = dom.getStyle(e, 'margin-bottom');
- if (v && v == v2)
- return parseInt(v.replace(/[^0-9]/g, ''));
-
- break;
-
- case 'border':
- v = 0;
-
- tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
- sv = dom.getStyle(e, 'border-' + sv + '-width');
-
- // False or not the same as prev
- if (!sv || (sv != v && v !== 0)) {
- v = 0;
- return false;
- }
-
- if (sv)
- v = sv;
- });
-
- if (v)
- return parseInt(v.replace(/[^0-9]/g, ''));
-
- break;
- }
- }
-
- if (v = dom.getAttrib(e, at))
- return v;
-
- return '';
- },
-
- setSwapImage : function(st) {
- var f = document.forms[0];
-
- f.onmousemovecheck.checked = st;
- setBrowserDisabled('overbrowser', !st);
- setBrowserDisabled('outbrowser', !st);
-
- if (f.over_list)
- f.over_list.disabled = !st;
-
- if (f.out_list)
- f.out_list.disabled = !st;
-
- f.onmouseoversrc.disabled = !st;
- f.onmouseoutsrc.disabled = !st;
- },
-
- fillClassList : function(id) {
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
-
- if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
- cl = [];
-
- tinymce.each(v.split(';'), function(v) {
- var p = v.split('=');
-
- cl.push({'title' : p[0], 'class' : p[1]});
- });
- } else
- cl = tinyMCEPopup.editor.dom.getClasses();
-
- if (cl.length > 0) {
- lst.options.length = 0;
- lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
-
- tinymce.each(cl, function(o) {
- lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
- });
- } else
- dom.remove(dom.getParent(id, 'tr'));
- },
-
- fillFileList : function(id, l) {
- var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
-
- l = typeof(l) === 'function' ? l() : window[l];
- lst.options.length = 0;
-
- if (l && l.length > 0) {
- lst.options[lst.options.length] = new Option('', '');
-
- tinymce.each(l, function(o) {
- lst.options[lst.options.length] = new Option(o[0], o[1]);
- });
- } else
- dom.remove(dom.getParent(id, 'tr'));
- },
-
- resetImageData : function() {
- var f = document.forms[0];
-
- f.elements.width.value = f.elements.height.value = '';
- },
-
- updateImageData : function(img, st) {
- var f = document.forms[0];
-
- if (!st) {
- f.elements.width.value = img.width;
- f.elements.height.value = img.height;
- }
-
- this.preloadImg = img;
- },
-
- changeAppearance : function() {
- var ed = tinyMCEPopup.editor, f = document.forms[0], img = document.getElementById('alignSampleImg');
-
- if (img) {
- if (ed.getParam('inline_styles')) {
- ed.dom.setAttrib(img, 'style', f.style.value);
- } else {
- img.align = f.align.value;
- img.border = f.border.value;
- img.hspace = f.hspace.value;
- img.vspace = f.vspace.value;
- }
- }
- },
-
- changeHeight : function() {
- var f = document.forms[0], tp, t = this;
-
- if (!f.constrain.checked || !t.preloadImg) {
- return;
- }
-
- if (f.width.value == "" || f.height.value == "")
- return;
-
- tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height;
- f.height.value = tp.toFixed(0);
- },
-
- changeWidth : function() {
- var f = document.forms[0], tp, t = this;
-
- if (!f.constrain.checked || !t.preloadImg) {
- return;
- }
-
- if (f.width.value == "" || f.height.value == "")
- return;
-
- tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width;
- f.width.value = tp.toFixed(0);
- },
-
- updateStyle : function(ty) {
- var dom = tinyMCEPopup.dom, b, bStyle, bColor, v, isIE = tinymce.isIE, f = document.forms[0], img = dom.create('img', {style : dom.get('style').value});
-
- if (tinyMCEPopup.editor.settings.inline_styles) {
- // Handle align
- if (ty == 'align') {
- dom.setStyle(img, 'float', '');
- dom.setStyle(img, 'vertical-align', '');
-
- v = getSelectValue(f, 'align');
- if (v) {
- if (v == 'left' || v == 'right')
- dom.setStyle(img, 'float', v);
- else
- img.style.verticalAlign = v;
- }
- }
-
- // Handle border
- if (ty == 'border') {
- b = img.style.border ? img.style.border.split(' ') : [];
- bStyle = dom.getStyle(img, 'border-style');
- bColor = dom.getStyle(img, 'border-color');
-
- dom.setStyle(img, 'border', '');
-
- v = f.border.value;
- if (v || v == '0') {
- if (v == '0')
- img.style.border = isIE ? '0' : '0 none none';
- else {
- var isOldIE = tinymce.isIE && (!document.documentMode || document.documentMode < 9);
-
- if (b.length == 3 && b[isOldIE ? 2 : 1])
- bStyle = b[isOldIE ? 2 : 1];
- else if (!bStyle || bStyle == 'none')
- bStyle = 'solid';
- if (b.length == 3 && b[isIE ? 0 : 2])
- bColor = b[isOldIE ? 0 : 2];
- else if (!bColor || bColor == 'none')
- bColor = 'black';
- img.style.border = v + 'px ' + bStyle + ' ' + bColor;
- }
- }
- }
-
- // Handle hspace
- if (ty == 'hspace') {
- dom.setStyle(img, 'marginLeft', '');
- dom.setStyle(img, 'marginRight', '');
-
- v = f.hspace.value;
- if (v) {
- img.style.marginLeft = v + 'px';
- img.style.marginRight = v + 'px';
- }
- }
-
- // Handle vspace
- if (ty == 'vspace') {
- dom.setStyle(img, 'marginTop', '');
- dom.setStyle(img, 'marginBottom', '');
-
- v = f.vspace.value;
- if (v) {
- img.style.marginTop = v + 'px';
- img.style.marginBottom = v + 'px';
- }
- }
-
- // Merge
- dom.get('style').value = dom.serializeStyle(dom.parseStyle(img.style.cssText), 'img');
- }
- },
-
- changeMouseMove : function() {
- },
-
- showPreviewImage : function(u, st) {
- if (!u) {
- tinyMCEPopup.dom.setHTML('prev', '');
- return;
- }
-
- if (!st && tinyMCEPopup.getParam("advimage_update_dimensions_onchange", true))
- this.resetImageData();
-
- u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(u);
-
- if (!st)
- tinyMCEPopup.dom.setHTML('prev', '');
- else
- tinyMCEPopup.dom.setHTML('prev', '');
- }
-};
-
-ImageDialog.preInit();
-tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
+var ImageDialog = {
+ preInit : function() {
+ var url;
+
+ tinyMCEPopup.requireLangPack();
+
+ if (url = tinyMCEPopup.getParam("external_image_list_url"))
+ document.write('');
+ },
+
+ init : function(ed) {
+ var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList');
+
+ tinyMCEPopup.resizeToInnerSize();
+ this.fillClassList('class_list');
+ this.fillFileList('src_list', fl);
+ this.fillFileList('over_list', fl);
+ this.fillFileList('out_list', fl);
+ TinyMCE_EditableSelects.init();
+
+ if (n.nodeName == 'IMG') {
+ nl.src.value = dom.getAttrib(n, 'src');
+ nl.width.value = dom.getAttrib(n, 'width');
+ nl.height.value = dom.getAttrib(n, 'height');
+ nl.alt.value = dom.getAttrib(n, 'alt');
+ nl.title.value = dom.getAttrib(n, 'title');
+ nl.vspace.value = this.getAttrib(n, 'vspace');
+ nl.hspace.value = this.getAttrib(n, 'hspace');
+ nl.border.value = this.getAttrib(n, 'border');
+ selectByValue(f, 'align', this.getAttrib(n, 'align'));
+ selectByValue(f, 'class_list', dom.getAttrib(n, 'class'), true, true);
+ nl.style.value = dom.getAttrib(n, 'style');
+ nl.id.value = dom.getAttrib(n, 'id');
+ nl.dir.value = dom.getAttrib(n, 'dir');
+ nl.lang.value = dom.getAttrib(n, 'lang');
+ nl.usemap.value = dom.getAttrib(n, 'usemap');
+ nl.longdesc.value = dom.getAttrib(n, 'longdesc');
+ nl.insert.value = ed.getLang('update');
+
+ if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover')))
+ nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
+
+ if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout')))
+ nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
+
+ if (ed.settings.inline_styles) {
+ // Move attribs to styles
+ if (dom.getAttrib(n, 'align'))
+ this.updateStyle('align');
+
+ if (dom.getAttrib(n, 'hspace'))
+ this.updateStyle('hspace');
+
+ if (dom.getAttrib(n, 'border'))
+ this.updateStyle('border');
+
+ if (dom.getAttrib(n, 'vspace'))
+ this.updateStyle('vspace');
+ }
+ }
+
+ // Setup browse button
+ document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image');
+ if (isVisible('srcbrowser'))
+ document.getElementById('src').style.width = '260px';
+
+ // Setup browse button
+ document.getElementById('onmouseoversrccontainer').innerHTML = getBrowserHTML('overbrowser','onmouseoversrc','image','theme_advanced_image');
+ if (isVisible('overbrowser'))
+ document.getElementById('onmouseoversrc').style.width = '260px';
+
+ // Setup browse button
+ document.getElementById('onmouseoutsrccontainer').innerHTML = getBrowserHTML('outbrowser','onmouseoutsrc','image','theme_advanced_image');
+ if (isVisible('outbrowser'))
+ document.getElementById('onmouseoutsrc').style.width = '260px';
+
+ // If option enabled default contrain proportions to checked
+ if (ed.getParam("advimage_constrain_proportions", true))
+ f.constrain.checked = true;
+
+ // Check swap image if valid data
+ if (nl.onmouseoversrc.value || nl.onmouseoutsrc.value)
+ this.setSwapImage(true);
+ else
+ this.setSwapImage(false);
+
+ this.changeAppearance();
+ this.showPreviewImage(nl.src.value, 1);
+ },
+
+ insert : function(file, title) {
+ var ed = tinyMCEPopup.editor, t = this, f = document.forms[0];
+
+ if (f.src.value === '') {
+ if (ed.selection.getNode().nodeName == 'IMG') {
+ ed.dom.remove(ed.selection.getNode());
+ ed.execCommand('mceRepaint');
+ }
+
+ tinyMCEPopup.close();
+ return;
+ }
+
+ if (tinyMCEPopup.getParam("accessibility_warnings", 1)) {
+ if (!f.alt.value) {
+ tinyMCEPopup.confirm(tinyMCEPopup.getLang('advimage_dlg.missing_alt'), function(s) {
+ if (s)
+ t.insertAndClose();
+ });
+
+ return;
+ }
+ }
+
+ t.insertAndClose();
+ },
+
+ insertAndClose : function() {
+ var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
+
+ tinyMCEPopup.restoreSelection();
+
+ // Fixes crash in Safari
+ if (tinymce.isWebKit)
+ ed.getWin().focus();
+
+ if (!ed.settings.inline_styles) {
+ args = {
+ vspace : nl.vspace.value,
+ hspace : nl.hspace.value,
+ border : nl.border.value,
+ align : getSelectValue(f, 'align')
+ };
+ } else {
+ // Remove deprecated values
+ args = {
+ vspace : '',
+ hspace : '',
+ border : '',
+ align : ''
+ };
+ }
+
+ tinymce.extend(args, {
+ src : nl.src.value.replace(/ /g, '%20'),
+ width : nl.width.value,
+ height : nl.height.value,
+ alt : nl.alt.value,
+ title : nl.title.value,
+ 'class' : getSelectValue(f, 'class_list'),
+ style : nl.style.value,
+ id : nl.id.value,
+ dir : nl.dir.value,
+ lang : nl.lang.value,
+ usemap : nl.usemap.value,
+ longdesc : nl.longdesc.value
+ });
+
+ args.onmouseover = args.onmouseout = '';
+
+ if (f.onmousemovecheck.checked) {
+ if (nl.onmouseoversrc.value)
+ args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';";
+
+ if (nl.onmouseoutsrc.value)
+ args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';";
+ }
+
+ el = ed.selection.getNode();
+
+ if (el && el.nodeName == 'IMG') {
+ ed.dom.setAttribs(el, args);
+ } else {
+ tinymce.each(args, function(value, name) {
+ if (value === "") {
+ delete args[name];
+ }
+ });
+
+ ed.execCommand('mceInsertContent', false, tinyMCEPopup.editor.dom.createHTML('img', args), {skip_undo : 1});
+ ed.undoManager.add();
+ }
+
+ tinyMCEPopup.editor.execCommand('mceRepaint');
+ tinyMCEPopup.editor.focus();
+ tinyMCEPopup.close();
+ },
+
+ getAttrib : function(e, at) {
+ var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
+
+ if (ed.settings.inline_styles) {
+ switch (at) {
+ case 'align':
+ if (v = dom.getStyle(e, 'float'))
+ return v;
+
+ if (v = dom.getStyle(e, 'vertical-align'))
+ return v;
+
+ break;
+
+ case 'hspace':
+ v = dom.getStyle(e, 'margin-left')
+ v2 = dom.getStyle(e, 'margin-right');
+
+ if (v && v == v2)
+ return parseInt(v.replace(/[^0-9]/g, ''));
+
+ break;
+
+ case 'vspace':
+ v = dom.getStyle(e, 'margin-top')
+ v2 = dom.getStyle(e, 'margin-bottom');
+ if (v && v == v2)
+ return parseInt(v.replace(/[^0-9]/g, ''));
+
+ break;
+
+ case 'border':
+ v = 0;
+
+ tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
+ sv = dom.getStyle(e, 'border-' + sv + '-width');
+
+ // False or not the same as prev
+ if (!sv || (sv != v && v !== 0)) {
+ v = 0;
+ return false;
+ }
+
+ if (sv)
+ v = sv;
+ });
+
+ if (v)
+ return parseInt(v.replace(/[^0-9]/g, ''));
+
+ break;
+ }
+ }
+
+ if (v = dom.getAttrib(e, at))
+ return v;
+
+ return '';
+ },
+
+ setSwapImage : function(st) {
+ var f = document.forms[0];
+
+ f.onmousemovecheck.checked = st;
+ setBrowserDisabled('overbrowser', !st);
+ setBrowserDisabled('outbrowser', !st);
+
+ if (f.over_list)
+ f.over_list.disabled = !st;
+
+ if (f.out_list)
+ f.out_list.disabled = !st;
+
+ f.onmouseoversrc.disabled = !st;
+ f.onmouseoutsrc.disabled = !st;
+ },
+
+ fillClassList : function(id) {
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
+
+ if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
+ cl = [];
+
+ tinymce.each(v.split(';'), function(v) {
+ var p = v.split('=');
+
+ cl.push({'title' : p[0], 'class' : p[1]});
+ });
+ } else
+ cl = tinyMCEPopup.editor.dom.getClasses();
+
+ if (cl.length > 0) {
+ lst.options.length = 0;
+ lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
+
+ tinymce.each(cl, function(o) {
+ lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
+ });
+ } else
+ dom.remove(dom.getParent(id, 'tr'));
+ },
+
+ fillFileList : function(id, l) {
+ var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
+
+ l = typeof(l) === 'function' ? l() : window[l];
+ lst.options.length = 0;
+
+ if (l && l.length > 0) {
+ lst.options[lst.options.length] = new Option('', '');
+
+ tinymce.each(l, function(o) {
+ lst.options[lst.options.length] = new Option(o[0], o[1]);
+ });
+ } else
+ dom.remove(dom.getParent(id, 'tr'));
+ },
+
+ resetImageData : function() {
+ var f = document.forms[0];
+
+ f.elements.width.value = f.elements.height.value = '';
+ },
+
+ updateImageData : function(img, st) {
+ var f = document.forms[0];
+
+ if (!st) {
+ f.elements.width.value = img.width;
+ f.elements.height.value = img.height;
+ }
+
+ this.preloadImg = img;
+ },
+
+ changeAppearance : function() {
+ var ed = tinyMCEPopup.editor, f = document.forms[0], img = document.getElementById('alignSampleImg');
+
+ if (img) {
+ if (ed.getParam('inline_styles')) {
+ ed.dom.setAttrib(img, 'style', f.style.value);
+ } else {
+ img.align = f.align.value;
+ img.border = f.border.value;
+ img.hspace = f.hspace.value;
+ img.vspace = f.vspace.value;
+ }
+ }
+ },
+
+ changeHeight : function() {
+ var f = document.forms[0], tp, t = this;
+
+ if (!f.constrain.checked || !t.preloadImg) {
+ return;
+ }
+
+ if (f.width.value == "" || f.height.value == "")
+ return;
+
+ tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height;
+ f.height.value = tp.toFixed(0);
+ },
+
+ changeWidth : function() {
+ var f = document.forms[0], tp, t = this;
+
+ if (!f.constrain.checked || !t.preloadImg) {
+ return;
+ }
+
+ if (f.width.value == "" || f.height.value == "")
+ return;
+
+ tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width;
+ f.width.value = tp.toFixed(0);
+ },
+
+ updateStyle : function(ty) {
+ var dom = tinyMCEPopup.dom, b, bStyle, bColor, v, isIE = tinymce.isIE, f = document.forms[0], img = dom.create('img', {style : dom.get('style').value});
+
+ if (tinyMCEPopup.editor.settings.inline_styles) {
+ // Handle align
+ if (ty == 'align') {
+ dom.setStyle(img, 'float', '');
+ dom.setStyle(img, 'vertical-align', '');
+
+ v = getSelectValue(f, 'align');
+ if (v) {
+ if (v == 'left' || v == 'right')
+ dom.setStyle(img, 'float', v);
+ else
+ img.style.verticalAlign = v;
+ }
+ }
+
+ // Handle border
+ if (ty == 'border') {
+ b = img.style.border ? img.style.border.split(' ') : [];
+ bStyle = dom.getStyle(img, 'border-style');
+ bColor = dom.getStyle(img, 'border-color');
+
+ dom.setStyle(img, 'border', '');
+
+ v = f.border.value;
+ if (v || v == '0') {
+ if (v == '0')
+ img.style.border = isIE ? '0' : '0 none none';
+ else {
+ var isOldIE = tinymce.isIE && (!document.documentMode || document.documentMode < 9);
+
+ if (b.length == 3 && b[isOldIE ? 2 : 1])
+ bStyle = b[isOldIE ? 2 : 1];
+ else if (!bStyle || bStyle == 'none')
+ bStyle = 'solid';
+ if (b.length == 3 && b[isIE ? 0 : 2])
+ bColor = b[isOldIE ? 0 : 2];
+ else if (!bColor || bColor == 'none')
+ bColor = 'black';
+ img.style.border = v + 'px ' + bStyle + ' ' + bColor;
+ }
+ }
+ }
+
+ // Handle hspace
+ if (ty == 'hspace') {
+ dom.setStyle(img, 'marginLeft', '');
+ dom.setStyle(img, 'marginRight', '');
+
+ v = f.hspace.value;
+ if (v) {
+ img.style.marginLeft = v + 'px';
+ img.style.marginRight = v + 'px';
+ }
+ }
+
+ // Handle vspace
+ if (ty == 'vspace') {
+ dom.setStyle(img, 'marginTop', '');
+ dom.setStyle(img, 'marginBottom', '');
+
+ v = f.vspace.value;
+ if (v) {
+ img.style.marginTop = v + 'px';
+ img.style.marginBottom = v + 'px';
+ }
+ }
+
+ // Merge
+ dom.get('style').value = dom.serializeStyle(dom.parseStyle(img.style.cssText), 'img');
+ }
+ },
+
+ changeMouseMove : function() {
+ },
+
+ showPreviewImage : function(u, st) {
+ if (!u) {
+ tinyMCEPopup.dom.setHTML('prev', '');
+ return;
+ }
+
+ if (!st && tinyMCEPopup.getParam("advimage_update_dimensions_onchange", true))
+ this.resetImageData();
+
+ u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(u);
+
+ if (!st)
+ tinyMCEPopup.dom.setHTML('prev', '');
+ else
+ tinyMCEPopup.dom.setHTML('prev', '');
+ }
+};
+
+ImageDialog.preInit();
+tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
diff --git a/js/tiny_mce/plugins/advlink/css/advlink.css b/js/tiny_mce/plugins/advlink/css/advlink.css
index 14364316a19..66c65493541 100644
--- a/js/tiny_mce/plugins/advlink/css/advlink.css
+++ b/js/tiny_mce/plugins/advlink/css/advlink.css
@@ -1,8 +1,8 @@
-.mceLinkList, .mceAnchorList, #targetlist {width:280px;}
-.mceActionPanel {margin-top:7px;}
-.panel_wrapper div.current {height:320px;}
-#classlist, #title, #href {width:280px;}
-#popupurl, #popupname {width:200px;}
-#popupwidth, #popupheight, #popupleft, #popuptop {width:30px;vertical-align:middle;text-align:center;}
-#id, #style, #classes, #target, #dir, #hreflang, #lang, #charset, #type, #rel, #rev, #tabindex, #accesskey {width:200px;}
-#events_panel input {width:200px;}
+.mceLinkList, .mceAnchorList, #targetlist {width:280px;}
+.mceActionPanel {margin-top:7px;}
+.panel_wrapper div.current {height:320px;}
+#classlist, #title, #href {width:280px;}
+#popupurl, #popupname {width:200px;}
+#popupwidth, #popupheight, #popupleft, #popuptop {width:30px;vertical-align:middle;text-align:center;}
+#id, #style, #classes, #target, #dir, #hreflang, #lang, #charset, #type, #rel, #rev, #tabindex, #accesskey {width:200px;}
+#events_panel input {width:200px;}
diff --git a/js/tiny_mce/plugins/advlink/editor_plugin_src.js b/js/tiny_mce/plugins/advlink/editor_plugin_src.js
index 14e46a7629c..32ea8f3db92 100644
--- a/js/tiny_mce/plugins/advlink/editor_plugin_src.js
+++ b/js/tiny_mce/plugins/advlink/editor_plugin_src.js
@@ -1,61 +1,61 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
-(function() {
- tinymce.create('tinymce.plugins.AdvancedLinkPlugin', {
- init : function(ed, url) {
- this.editor = ed;
-
- // Register commands
- ed.addCommand('mceAdvLink', function() {
- var se = ed.selection;
-
- // No selection and not in link
- if (se.isCollapsed() && !ed.dom.getParent(se.getNode(), 'A'))
- return;
-
- ed.windowManager.open({
- file : url + '/link.htm',
- width : 480 + parseInt(ed.getLang('advlink.delta_width', 0)),
- height : 400 + parseInt(ed.getLang('advlink.delta_height', 0)),
- inline : 1
- }, {
- plugin_url : url
- });
- });
-
- // Register buttons
- ed.addButton('link', {
- title : 'advlink.link_desc',
- cmd : 'mceAdvLink'
- });
-
- ed.addShortcut('ctrl+k', 'advlink.advlink_desc', 'mceAdvLink');
-
- ed.onNodeChange.add(function(ed, cm, n, co) {
- cm.setDisabled('link', co && n.nodeName != 'A');
- cm.setActive('link', n.nodeName == 'A' && !n.name);
- });
- },
-
- getInfo : function() {
- return {
- longname : 'Advanced link',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
- };
- }
- });
-
- // Register plugin
- tinymce.PluginManager.add('advlink', tinymce.plugins.AdvancedLinkPlugin);
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function() {
+ tinymce.create('tinymce.plugins.AdvancedLinkPlugin', {
+ init : function(ed, url) {
+ this.editor = ed;
+
+ // Register commands
+ ed.addCommand('mceAdvLink', function() {
+ var se = ed.selection;
+
+ // No selection and not in link
+ if (se.isCollapsed() && !ed.dom.getParent(se.getNode(), 'A'))
+ return;
+
+ ed.windowManager.open({
+ file : url + '/link.htm',
+ width : 480 + parseInt(ed.getLang('advlink.delta_width', 0)),
+ height : 400 + parseInt(ed.getLang('advlink.delta_height', 0)),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ });
+
+ // Register buttons
+ ed.addButton('link', {
+ title : 'advlink.link_desc',
+ cmd : 'mceAdvLink'
+ });
+
+ ed.addShortcut('ctrl+k', 'advlink.advlink_desc', 'mceAdvLink');
+
+ ed.onNodeChange.add(function(ed, cm, n, co) {
+ cm.setDisabled('link', co && n.nodeName != 'A');
+ cm.setActive('link', n.nodeName == 'A' && !n.name);
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'Advanced link',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('advlink', tinymce.plugins.AdvancedLinkPlugin);
})();
\ No newline at end of file
diff --git a/js/tiny_mce/plugins/advlink/js/advlink.js b/js/tiny_mce/plugins/advlink/js/advlink.js
index f013aac1e71..5bf80700306 100644
--- a/js/tiny_mce/plugins/advlink/js/advlink.js
+++ b/js/tiny_mce/plugins/advlink/js/advlink.js
@@ -1,543 +1,543 @@
-/* Functions for the advlink plugin popup */
-
-tinyMCEPopup.requireLangPack();
-
-var templates = {
- "window.open" : "window.open('${url}','${target}','${options}')"
-};
-
-function preinit() {
- var url;
-
- if (url = tinyMCEPopup.getParam("external_link_list_url"))
- document.write('');
-}
-
-function changeClass() {
- var f = document.forms[0];
-
- f.classes.value = getSelectValue(f, 'classlist');
-}
-
-function init() {
- tinyMCEPopup.resizeToInnerSize();
-
- var formObj = document.forms[0];
- var inst = tinyMCEPopup.editor;
- var elm = inst.selection.getNode();
- var action = "insert";
- var html;
-
- document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlink');
- document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlink');
- document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist','target');
-
- // Link list
- html = getLinkListHTML('linklisthref','href');
- if (html == "")
- document.getElementById("linklisthrefrow").style.display = 'none';
- else
- document.getElementById("linklisthrefcontainer").innerHTML = html;
-
- // Anchor list
- html = getAnchorListHTML('anchorlist','href');
- if (html == "")
- document.getElementById("anchorlistrow").style.display = 'none';
- else
- document.getElementById("anchorlistcontainer").innerHTML = html;
-
- // Resize some elements
- if (isVisible('hrefbrowser'))
- document.getElementById('href').style.width = '260px';
-
- if (isVisible('popupurlbrowser'))
- document.getElementById('popupurl').style.width = '180px';
-
- elm = inst.dom.getParent(elm, "A");
- if (elm == null) {
- var prospect = inst.dom.create("p", null, inst.selection.getContent());
- if (prospect.childNodes.length === 1) {
- elm = prospect.firstChild;
- }
- }
-
- if (elm != null && elm.nodeName == "A")
- action = "update";
-
- formObj.insert.value = tinyMCEPopup.getLang(action, 'Insert', true);
-
- setPopupControlsDisabled(true);
-
- if (action == "update") {
- var href = inst.dom.getAttrib(elm, 'href');
- var onclick = inst.dom.getAttrib(elm, 'onclick');
- var linkTarget = inst.dom.getAttrib(elm, 'target') ? inst.dom.getAttrib(elm, 'target') : "_self";
-
- // Setup form data
- setFormValue('href', href);
- setFormValue('title', inst.dom.getAttrib(elm, 'title'));
- setFormValue('id', inst.dom.getAttrib(elm, 'id'));
- setFormValue('style', inst.dom.getAttrib(elm, "style"));
- setFormValue('rel', inst.dom.getAttrib(elm, 'rel'));
- setFormValue('rev', inst.dom.getAttrib(elm, 'rev'));
- setFormValue('charset', inst.dom.getAttrib(elm, 'charset'));
- setFormValue('hreflang', inst.dom.getAttrib(elm, 'hreflang'));
- setFormValue('dir', inst.dom.getAttrib(elm, 'dir'));
- setFormValue('lang', inst.dom.getAttrib(elm, 'lang'));
- setFormValue('tabindex', inst.dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
- setFormValue('accesskey', inst.dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
- setFormValue('type', inst.dom.getAttrib(elm, 'type'));
- setFormValue('onfocus', inst.dom.getAttrib(elm, 'onfocus'));
- setFormValue('onblur', inst.dom.getAttrib(elm, 'onblur'));
- setFormValue('onclick', onclick);
- setFormValue('ondblclick', inst.dom.getAttrib(elm, 'ondblclick'));
- setFormValue('onmousedown', inst.dom.getAttrib(elm, 'onmousedown'));
- setFormValue('onmouseup', inst.dom.getAttrib(elm, 'onmouseup'));
- setFormValue('onmouseover', inst.dom.getAttrib(elm, 'onmouseover'));
- setFormValue('onmousemove', inst.dom.getAttrib(elm, 'onmousemove'));
- setFormValue('onmouseout', inst.dom.getAttrib(elm, 'onmouseout'));
- setFormValue('onkeypress', inst.dom.getAttrib(elm, 'onkeypress'));
- setFormValue('onkeydown', inst.dom.getAttrib(elm, 'onkeydown'));
- setFormValue('onkeyup', inst.dom.getAttrib(elm, 'onkeyup'));
- setFormValue('target', linkTarget);
- setFormValue('classes', inst.dom.getAttrib(elm, 'class'));
-
- // Parse onclick data
- if (onclick != null && onclick.indexOf('window.open') != -1)
- parseWindowOpen(onclick);
- else
- parseFunction(onclick);
-
- // Select by the values
- selectByValue(formObj, 'dir', inst.dom.getAttrib(elm, 'dir'));
- selectByValue(formObj, 'rel', inst.dom.getAttrib(elm, 'rel'));
- selectByValue(formObj, 'rev', inst.dom.getAttrib(elm, 'rev'));
- selectByValue(formObj, 'linklisthref', href);
-
- if (href.charAt(0) == '#')
- selectByValue(formObj, 'anchorlist', href);
-
- addClassesToList('classlist', 'advlink_styles');
-
- selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
- selectByValue(formObj, 'targetlist', linkTarget, true);
- } else
- addClassesToList('classlist', 'advlink_styles');
-}
-
-function checkPrefix(n) {
- if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
- n.value = 'mailto:' + n.value;
-
- if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_external')))
- n.value = 'http://' + n.value;
-}
-
-function setFormValue(name, value) {
- document.forms[0].elements[name].value = value;
-}
-
-function parseWindowOpen(onclick) {
- var formObj = document.forms[0];
-
- // Preprocess center code
- if (onclick.indexOf('return false;') != -1) {
- formObj.popupreturn.checked = true;
- onclick = onclick.replace('return false;', '');
- } else
- formObj.popupreturn.checked = false;
-
- var onClickData = parseLink(onclick);
-
- if (onClickData != null) {
- formObj.ispopup.checked = true;
- setPopupControlsDisabled(false);
-
- var onClickWindowOptions = parseOptions(onClickData['options']);
- var url = onClickData['url'];
-
- formObj.popupname.value = onClickData['target'];
- formObj.popupurl.value = url;
- formObj.popupwidth.value = getOption(onClickWindowOptions, 'width');
- formObj.popupheight.value = getOption(onClickWindowOptions, 'height');
-
- formObj.popupleft.value = getOption(onClickWindowOptions, 'left');
- formObj.popuptop.value = getOption(onClickWindowOptions, 'top');
-
- if (formObj.popupleft.value.indexOf('screen') != -1)
- formObj.popupleft.value = "c";
-
- if (formObj.popuptop.value.indexOf('screen') != -1)
- formObj.popuptop.value = "c";
-
- formObj.popuplocation.checked = getOption(onClickWindowOptions, 'location') == "yes";
- formObj.popupscrollbars.checked = getOption(onClickWindowOptions, 'scrollbars') == "yes";
- formObj.popupmenubar.checked = getOption(onClickWindowOptions, 'menubar') == "yes";
- formObj.popupresizable.checked = getOption(onClickWindowOptions, 'resizable') == "yes";
- formObj.popuptoolbar.checked = getOption(onClickWindowOptions, 'toolbar') == "yes";
- formObj.popupstatus.checked = getOption(onClickWindowOptions, 'status') == "yes";
- formObj.popupdependent.checked = getOption(onClickWindowOptions, 'dependent') == "yes";
-
- buildOnClick();
- }
-}
-
-function parseFunction(onclick) {
- var formObj = document.forms[0];
- var onClickData = parseLink(onclick);
-
- // TODO: Add stuff here
-}
-
-function getOption(opts, name) {
- return typeof(opts[name]) == "undefined" ? "" : opts[name];
-}
-
-function setPopupControlsDisabled(state) {
- var formObj = document.forms[0];
-
- formObj.popupname.disabled = state;
- formObj.popupurl.disabled = state;
- formObj.popupwidth.disabled = state;
- formObj.popupheight.disabled = state;
- formObj.popupleft.disabled = state;
- formObj.popuptop.disabled = state;
- formObj.popuplocation.disabled = state;
- formObj.popupscrollbars.disabled = state;
- formObj.popupmenubar.disabled = state;
- formObj.popupresizable.disabled = state;
- formObj.popuptoolbar.disabled = state;
- formObj.popupstatus.disabled = state;
- formObj.popupreturn.disabled = state;
- formObj.popupdependent.disabled = state;
-
- setBrowserDisabled('popupurlbrowser', state);
-}
-
-function parseLink(link) {
- link = link.replace(new RegExp(''', 'g'), "'");
-
- var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
-
- // Is function name a template function
- var template = templates[fnName];
- if (template) {
- // Build regexp
- var variableNames = template.match(new RegExp("'?\\$\\{[A-Za-z0-9\.]*\\}'?", "gi"));
- var regExp = "\\s*[A-Za-z0-9\.]*\\s*\\(";
- var replaceStr = "";
- for (var i=0; i";
- } else
- regExp += ".*";
- }
-
- regExp += "\\);?";
-
- // Build variable array
- var variables = [];
- variables["_function"] = fnName;
- var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('');
- for (var i=0; i' + name + '';
-
- if ((name = nodes[i].id) != "" && !nodes[i].href)
- html += '';
- }
-
- if (html == "")
- return "";
-
- html = '';
-
- return html;
-}
-
-function insertAction() {
- var inst = tinyMCEPopup.editor;
- var elm, elementArray, i;
-
- elm = inst.selection.getNode();
- checkPrefix(document.forms[0].href);
-
- elm = inst.dom.getParent(elm, "A");
-
- // Remove element if there is no href
- if (!document.forms[0].href.value) {
- i = inst.selection.getBookmark();
- inst.dom.remove(elm, 1);
- inst.selection.moveToBookmark(i);
- tinyMCEPopup.execCommand("mceEndUndoLevel");
- tinyMCEPopup.close();
- return;
- }
-
- // Create new anchor elements
- if (elm == null) {
- inst.getDoc().execCommand("unlink", false, null);
- tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
-
- elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
- for (i=0; i';
-
- for (var i=0; i' + tinyMCELinkList[i][0] + '';
-
- html += '';
-
- return html;
-
- // tinyMCE.debug('-- image list start --', html, '-- image list end --');
-}
-
-function getTargetListHTML(elm_id, target_form_element) {
- var targets = tinyMCEPopup.getParam('theme_advanced_link_targets', '').split(';');
- var html = '';
-
- html += '';
-
- return html;
-}
-
-// While loading
-preinit();
-tinyMCEPopup.onInit.add(init);
+/* Functions for the advlink plugin popup */
+
+tinyMCEPopup.requireLangPack();
+
+var templates = {
+ "window.open" : "window.open('${url}','${target}','${options}')"
+};
+
+function preinit() {
+ var url;
+
+ if (url = tinyMCEPopup.getParam("external_link_list_url"))
+ document.write('');
+}
+
+function changeClass() {
+ var f = document.forms[0];
+
+ f.classes.value = getSelectValue(f, 'classlist');
+}
+
+function init() {
+ tinyMCEPopup.resizeToInnerSize();
+
+ var formObj = document.forms[0];
+ var inst = tinyMCEPopup.editor;
+ var elm = inst.selection.getNode();
+ var action = "insert";
+ var html;
+
+ document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlink');
+ document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlink');
+ document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist','target');
+
+ // Link list
+ html = getLinkListHTML('linklisthref','href');
+ if (html == "")
+ document.getElementById("linklisthrefrow").style.display = 'none';
+ else
+ document.getElementById("linklisthrefcontainer").innerHTML = html;
+
+ // Anchor list
+ html = getAnchorListHTML('anchorlist','href');
+ if (html == "")
+ document.getElementById("anchorlistrow").style.display = 'none';
+ else
+ document.getElementById("anchorlistcontainer").innerHTML = html;
+
+ // Resize some elements
+ if (isVisible('hrefbrowser'))
+ document.getElementById('href').style.width = '260px';
+
+ if (isVisible('popupurlbrowser'))
+ document.getElementById('popupurl').style.width = '180px';
+
+ elm = inst.dom.getParent(elm, "A");
+ if (elm == null) {
+ var prospect = inst.dom.create("p", null, inst.selection.getContent());
+ if (prospect.childNodes.length === 1) {
+ elm = prospect.firstChild;
+ }
+ }
+
+ if (elm != null && elm.nodeName == "A")
+ action = "update";
+
+ formObj.insert.value = tinyMCEPopup.getLang(action, 'Insert', true);
+
+ setPopupControlsDisabled(true);
+
+ if (action == "update") {
+ var href = inst.dom.getAttrib(elm, 'href');
+ var onclick = inst.dom.getAttrib(elm, 'onclick');
+ var linkTarget = inst.dom.getAttrib(elm, 'target') ? inst.dom.getAttrib(elm, 'target') : "_self";
+
+ // Setup form data
+ setFormValue('href', href);
+ setFormValue('title', inst.dom.getAttrib(elm, 'title'));
+ setFormValue('id', inst.dom.getAttrib(elm, 'id'));
+ setFormValue('style', inst.dom.getAttrib(elm, "style"));
+ setFormValue('rel', inst.dom.getAttrib(elm, 'rel'));
+ setFormValue('rev', inst.dom.getAttrib(elm, 'rev'));
+ setFormValue('charset', inst.dom.getAttrib(elm, 'charset'));
+ setFormValue('hreflang', inst.dom.getAttrib(elm, 'hreflang'));
+ setFormValue('dir', inst.dom.getAttrib(elm, 'dir'));
+ setFormValue('lang', inst.dom.getAttrib(elm, 'lang'));
+ setFormValue('tabindex', inst.dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
+ setFormValue('accesskey', inst.dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
+ setFormValue('type', inst.dom.getAttrib(elm, 'type'));
+ setFormValue('onfocus', inst.dom.getAttrib(elm, 'onfocus'));
+ setFormValue('onblur', inst.dom.getAttrib(elm, 'onblur'));
+ setFormValue('onclick', onclick);
+ setFormValue('ondblclick', inst.dom.getAttrib(elm, 'ondblclick'));
+ setFormValue('onmousedown', inst.dom.getAttrib(elm, 'onmousedown'));
+ setFormValue('onmouseup', inst.dom.getAttrib(elm, 'onmouseup'));
+ setFormValue('onmouseover', inst.dom.getAttrib(elm, 'onmouseover'));
+ setFormValue('onmousemove', inst.dom.getAttrib(elm, 'onmousemove'));
+ setFormValue('onmouseout', inst.dom.getAttrib(elm, 'onmouseout'));
+ setFormValue('onkeypress', inst.dom.getAttrib(elm, 'onkeypress'));
+ setFormValue('onkeydown', inst.dom.getAttrib(elm, 'onkeydown'));
+ setFormValue('onkeyup', inst.dom.getAttrib(elm, 'onkeyup'));
+ setFormValue('target', linkTarget);
+ setFormValue('classes', inst.dom.getAttrib(elm, 'class'));
+
+ // Parse onclick data
+ if (onclick != null && onclick.indexOf('window.open') != -1)
+ parseWindowOpen(onclick);
+ else
+ parseFunction(onclick);
+
+ // Select by the values
+ selectByValue(formObj, 'dir', inst.dom.getAttrib(elm, 'dir'));
+ selectByValue(formObj, 'rel', inst.dom.getAttrib(elm, 'rel'));
+ selectByValue(formObj, 'rev', inst.dom.getAttrib(elm, 'rev'));
+ selectByValue(formObj, 'linklisthref', href);
+
+ if (href.charAt(0) == '#')
+ selectByValue(formObj, 'anchorlist', href);
+
+ addClassesToList('classlist', 'advlink_styles');
+
+ selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
+ selectByValue(formObj, 'targetlist', linkTarget, true);
+ } else
+ addClassesToList('classlist', 'advlink_styles');
+}
+
+function checkPrefix(n) {
+ if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
+ n.value = 'mailto:' + n.value;
+
+ if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_external')))
+ n.value = 'http://' + n.value;
+}
+
+function setFormValue(name, value) {
+ document.forms[0].elements[name].value = value;
+}
+
+function parseWindowOpen(onclick) {
+ var formObj = document.forms[0];
+
+ // Preprocess center code
+ if (onclick.indexOf('return false;') != -1) {
+ formObj.popupreturn.checked = true;
+ onclick = onclick.replace('return false;', '');
+ } else
+ formObj.popupreturn.checked = false;
+
+ var onClickData = parseLink(onclick);
+
+ if (onClickData != null) {
+ formObj.ispopup.checked = true;
+ setPopupControlsDisabled(false);
+
+ var onClickWindowOptions = parseOptions(onClickData['options']);
+ var url = onClickData['url'];
+
+ formObj.popupname.value = onClickData['target'];
+ formObj.popupurl.value = url;
+ formObj.popupwidth.value = getOption(onClickWindowOptions, 'width');
+ formObj.popupheight.value = getOption(onClickWindowOptions, 'height');
+
+ formObj.popupleft.value = getOption(onClickWindowOptions, 'left');
+ formObj.popuptop.value = getOption(onClickWindowOptions, 'top');
+
+ if (formObj.popupleft.value.indexOf('screen') != -1)
+ formObj.popupleft.value = "c";
+
+ if (formObj.popuptop.value.indexOf('screen') != -1)
+ formObj.popuptop.value = "c";
+
+ formObj.popuplocation.checked = getOption(onClickWindowOptions, 'location') == "yes";
+ formObj.popupscrollbars.checked = getOption(onClickWindowOptions, 'scrollbars') == "yes";
+ formObj.popupmenubar.checked = getOption(onClickWindowOptions, 'menubar') == "yes";
+ formObj.popupresizable.checked = getOption(onClickWindowOptions, 'resizable') == "yes";
+ formObj.popuptoolbar.checked = getOption(onClickWindowOptions, 'toolbar') == "yes";
+ formObj.popupstatus.checked = getOption(onClickWindowOptions, 'status') == "yes";
+ formObj.popupdependent.checked = getOption(onClickWindowOptions, 'dependent') == "yes";
+
+ buildOnClick();
+ }
+}
+
+function parseFunction(onclick) {
+ var formObj = document.forms[0];
+ var onClickData = parseLink(onclick);
+
+ // TODO: Add stuff here
+}
+
+function getOption(opts, name) {
+ return typeof(opts[name]) == "undefined" ? "" : opts[name];
+}
+
+function setPopupControlsDisabled(state) {
+ var formObj = document.forms[0];
+
+ formObj.popupname.disabled = state;
+ formObj.popupurl.disabled = state;
+ formObj.popupwidth.disabled = state;
+ formObj.popupheight.disabled = state;
+ formObj.popupleft.disabled = state;
+ formObj.popuptop.disabled = state;
+ formObj.popuplocation.disabled = state;
+ formObj.popupscrollbars.disabled = state;
+ formObj.popupmenubar.disabled = state;
+ formObj.popupresizable.disabled = state;
+ formObj.popuptoolbar.disabled = state;
+ formObj.popupstatus.disabled = state;
+ formObj.popupreturn.disabled = state;
+ formObj.popupdependent.disabled = state;
+
+ setBrowserDisabled('popupurlbrowser', state);
+}
+
+function parseLink(link) {
+ link = link.replace(new RegExp(''', 'g'), "'");
+
+ var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
+
+ // Is function name a template function
+ var template = templates[fnName];
+ if (template) {
+ // Build regexp
+ var variableNames = template.match(new RegExp("'?\\$\\{[A-Za-z0-9\.]*\\}'?", "gi"));
+ var regExp = "\\s*[A-Za-z0-9\.]*\\s*\\(";
+ var replaceStr = "";
+ for (var i=0; i";
+ } else
+ regExp += ".*";
+ }
+
+ regExp += "\\);?";
+
+ // Build variable array
+ var variables = [];
+ variables["_function"] = fnName;
+ var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('');
+ for (var i=0; i' + name + '';
+
+ if ((name = nodes[i].id) != "" && !nodes[i].href)
+ html += '';
+ }
+
+ if (html == "")
+ return "";
+
+ html = '';
+
+ return html;
+}
+
+function insertAction() {
+ var inst = tinyMCEPopup.editor;
+ var elm, elementArray, i;
+
+ elm = inst.selection.getNode();
+ checkPrefix(document.forms[0].href);
+
+ elm = inst.dom.getParent(elm, "A");
+
+ // Remove element if there is no href
+ if (!document.forms[0].href.value) {
+ i = inst.selection.getBookmark();
+ inst.dom.remove(elm, 1);
+ inst.selection.moveToBookmark(i);
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
+ tinyMCEPopup.close();
+ return;
+ }
+
+ // Create new anchor elements
+ if (elm == null) {
+ inst.getDoc().execCommand("unlink", false, null);
+ tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
+
+ elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
+ for (i=0; i';
+
+ for (var i=0; i' + tinyMCELinkList[i][0] + '';
+
+ html += '';
+
+ return html;
+
+ // tinyMCE.debug('-- image list start --', html, '-- image list end --');
+}
+
+function getTargetListHTML(elm_id, target_form_element) {
+ var targets = tinyMCEPopup.getParam('theme_advanced_link_targets', '').split(';');
+ var html = '';
+
+ html += '';
+
+ return html;
+}
+
+// While loading
+preinit();
+tinyMCEPopup.onInit.add(init);
diff --git a/js/tiny_mce/plugins/advlist/editor_plugin_src.js b/js/tiny_mce/plugins/advlist/editor_plugin_src.js
index a8f046b4188..4ee4d34c879 100644
--- a/js/tiny_mce/plugins/advlist/editor_plugin_src.js
+++ b/js/tiny_mce/plugins/advlist/editor_plugin_src.js
@@ -1,176 +1,176 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
-(function() {
- var each = tinymce.each;
-
- tinymce.create('tinymce.plugins.AdvListPlugin', {
- init : function(ed, url) {
- var t = this;
-
- t.editor = ed;
-
- function buildFormats(str) {
- var formats = [];
-
- each(str.split(/,/), function(type) {
- formats.push({
- title : 'advlist.' + (type == 'default' ? 'def' : type.replace(/-/g, '_')),
- styles : {
- listStyleType : type == 'default' ? '' : type
- }
- });
- });
-
- return formats;
- };
-
- // Setup number formats from config or default
- t.numlist = ed.getParam("advlist_number_styles") || buildFormats("default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman");
- t.bullist = ed.getParam("advlist_bullet_styles") || buildFormats("default,circle,disc,square");
-
- if (tinymce.isIE && /MSIE [2-7]/.test(navigator.userAgent))
- t.isIE7 = true;
- },
-
- createControl: function(name, cm) {
- var t = this, btn, format, editor = t.editor;
-
- if (name == 'numlist' || name == 'bullist') {
- // Default to first item if it's a default item
- if (t[name][0].title == 'advlist.def')
- format = t[name][0];
-
- function hasFormat(node, format) {
- var state = true;
-
- each(format.styles, function(value, name) {
- // Format doesn't match
- if (editor.dom.getStyle(node, name) != value) {
- state = false;
- return false;
- }
- });
-
- return state;
- };
-
- function applyListFormat() {
- var list, dom = editor.dom, sel = editor.selection;
-
- // Check for existing list element
- list = dom.getParent(sel.getNode(), 'ol,ul');
-
- // Switch/add list type if needed
- if (!list || list.nodeName == (name == 'bullist' ? 'OL' : 'UL') || hasFormat(list, format))
- editor.execCommand(name == 'bullist' ? 'InsertUnorderedList' : 'InsertOrderedList');
-
- // Append styles to new list element
- if (format) {
- list = dom.getParent(sel.getNode(), 'ol,ul');
- if (list) {
- dom.setStyles(list, format.styles);
- list.removeAttribute('data-mce-style');
- }
- }
-
- editor.focus();
- };
-
- btn = cm.createSplitButton(name, {
- title : 'advanced.' + name + '_desc',
- 'class' : 'mce_' + name,
- onclick : function() {
- applyListFormat();
- }
- });
-
- btn.onRenderMenu.add(function(btn, menu) {
- menu.onHideMenu.add(function() {
- if (t.bookmark) {
- editor.selection.moveToBookmark(t.bookmark);
- t.bookmark = 0;
- }
- });
-
- menu.onShowMenu.add(function() {
- var dom = editor.dom, list = dom.getParent(editor.selection.getNode(), 'ol,ul'), fmtList;
-
- if (list || format) {
- fmtList = t[name];
-
- // Unselect existing items
- each(menu.items, function(item) {
- var state = true;
-
- item.setSelected(0);
-
- if (list && !item.isDisabled()) {
- each(fmtList, function(fmt) {
- if (fmt.id == item.id) {
- if (!hasFormat(list, fmt)) {
- state = false;
- return false;
- }
- }
- });
-
- if (state)
- item.setSelected(1);
- }
- });
-
- // Select the current format
- if (!list)
- menu.items[format.id].setSelected(1);
- }
-
- editor.focus();
-
- // IE looses it's selection so store it away and restore it later
- if (tinymce.isIE) {
- t.bookmark = editor.selection.getBookmark(1);
- }
- });
-
- menu.add({id : editor.dom.uniqueId(), title : 'advlist.types', 'class' : 'mceMenuItemTitle', titleItem: true}).setDisabled(1);
-
- each(t[name], function(item) {
- // IE<8 doesn't support lower-greek, skip it
- if (t.isIE7 && item.styles.listStyleType == 'lower-greek')
- return;
-
- item.id = editor.dom.uniqueId();
-
- menu.add({id : item.id, title : item.title, onclick : function() {
- format = item;
- applyListFormat();
- }});
- });
- });
-
- return btn;
- }
- },
-
- getInfo : function() {
- return {
- longname : 'Advanced lists',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlist',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
- };
- }
- });
-
- // Register plugin
- tinymce.PluginManager.add('advlist', tinymce.plugins.AdvListPlugin);
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function() {
+ var each = tinymce.each;
+
+ tinymce.create('tinymce.plugins.AdvListPlugin', {
+ init : function(ed, url) {
+ var t = this;
+
+ t.editor = ed;
+
+ function buildFormats(str) {
+ var formats = [];
+
+ each(str.split(/,/), function(type) {
+ formats.push({
+ title : 'advlist.' + (type == 'default' ? 'def' : type.replace(/-/g, '_')),
+ styles : {
+ listStyleType : type == 'default' ? '' : type
+ }
+ });
+ });
+
+ return formats;
+ };
+
+ // Setup number formats from config or default
+ t.numlist = ed.getParam("advlist_number_styles") || buildFormats("default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman");
+ t.bullist = ed.getParam("advlist_bullet_styles") || buildFormats("default,circle,disc,square");
+
+ if (tinymce.isIE && /MSIE [2-7]/.test(navigator.userAgent))
+ t.isIE7 = true;
+ },
+
+ createControl: function(name, cm) {
+ var t = this, btn, format, editor = t.editor;
+
+ if (name == 'numlist' || name == 'bullist') {
+ // Default to first item if it's a default item
+ if (t[name][0].title == 'advlist.def')
+ format = t[name][0];
+
+ function hasFormat(node, format) {
+ var state = true;
+
+ each(format.styles, function(value, name) {
+ // Format doesn't match
+ if (editor.dom.getStyle(node, name) != value) {
+ state = false;
+ return false;
+ }
+ });
+
+ return state;
+ };
+
+ function applyListFormat() {
+ var list, dom = editor.dom, sel = editor.selection;
+
+ // Check for existing list element
+ list = dom.getParent(sel.getNode(), 'ol,ul');
+
+ // Switch/add list type if needed
+ if (!list || list.nodeName == (name == 'bullist' ? 'OL' : 'UL') || hasFormat(list, format))
+ editor.execCommand(name == 'bullist' ? 'InsertUnorderedList' : 'InsertOrderedList');
+
+ // Append styles to new list element
+ if (format) {
+ list = dom.getParent(sel.getNode(), 'ol,ul');
+ if (list) {
+ dom.setStyles(list, format.styles);
+ list.removeAttribute('data-mce-style');
+ }
+ }
+
+ editor.focus();
+ };
+
+ btn = cm.createSplitButton(name, {
+ title : 'advanced.' + name + '_desc',
+ 'class' : 'mce_' + name,
+ onclick : function() {
+ applyListFormat();
+ }
+ });
+
+ btn.onRenderMenu.add(function(btn, menu) {
+ menu.onHideMenu.add(function() {
+ if (t.bookmark) {
+ editor.selection.moveToBookmark(t.bookmark);
+ t.bookmark = 0;
+ }
+ });
+
+ menu.onShowMenu.add(function() {
+ var dom = editor.dom, list = dom.getParent(editor.selection.getNode(), 'ol,ul'), fmtList;
+
+ if (list || format) {
+ fmtList = t[name];
+
+ // Unselect existing items
+ each(menu.items, function(item) {
+ var state = true;
+
+ item.setSelected(0);
+
+ if (list && !item.isDisabled()) {
+ each(fmtList, function(fmt) {
+ if (fmt.id == item.id) {
+ if (!hasFormat(list, fmt)) {
+ state = false;
+ return false;
+ }
+ }
+ });
+
+ if (state)
+ item.setSelected(1);
+ }
+ });
+
+ // Select the current format
+ if (!list)
+ menu.items[format.id].setSelected(1);
+ }
+
+ editor.focus();
+
+ // IE looses it's selection so store it away and restore it later
+ if (tinymce.isIE) {
+ t.bookmark = editor.selection.getBookmark(1);
+ }
+ });
+
+ menu.add({id : editor.dom.uniqueId(), title : 'advlist.types', 'class' : 'mceMenuItemTitle', titleItem: true}).setDisabled(1);
+
+ each(t[name], function(item) {
+ // IE<8 doesn't support lower-greek, skip it
+ if (t.isIE7 && item.styles.listStyleType == 'lower-greek')
+ return;
+
+ item.id = editor.dom.uniqueId();
+
+ menu.add({id : item.id, title : item.title, onclick : function() {
+ format = item;
+ applyListFormat();
+ }});
+ });
+ });
+
+ return btn;
+ }
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'Advanced lists',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlist',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('advlist', tinymce.plugins.AdvListPlugin);
})();
\ No newline at end of file
diff --git a/js/tiny_mce/plugins/autosave/editor_plugin_src.js b/js/tiny_mce/plugins/autosave/editor_plugin_src.js
index 8b308f5aac6..b5c845bcec5 100644
--- a/js/tiny_mce/plugins/autosave/editor_plugin_src.js
+++ b/js/tiny_mce/plugins/autosave/editor_plugin_src.js
@@ -1,433 +1,433 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- *
- * Adds auto-save capability to the TinyMCE text editor to rescue content
- * inadvertently lost. This plugin was originally developed by Speednet
- * and that project can be found here: http://code.google.com/p/tinyautosave/
- *
- * TECHNOLOGY DISCUSSION:
- *
- * The plugin attempts to use the most advanced features available in the current browser to save
- * as much content as possible. There are a total of four different methods used to autosave the
- * content. In order of preference, they are:
- *
- * 1. localStorage - A new feature of HTML 5, localStorage can store megabytes of data per domain
- * on the client computer. Data stored in the localStorage area has no expiration date, so we must
- * manage expiring the data ourselves. localStorage is fully supported by IE8, and it is supposed
- * to be working in Firefox 3 and Safari 3.2, but in reality is is flaky in those browsers. As
- * HTML 5 gets wider support, the AutoSave plugin will use it automatically. In Windows Vista/7,
- * localStorage is stored in the following folder:
- * C:\Users\[username]\AppData\Local\Microsoft\Internet Explorer\DOMStore\[tempFolder]
- *
- * 2. sessionStorage - A new feature of HTML 5, sessionStorage works similarly to localStorage,
- * except it is designed to expire after a certain amount of time. Because the specification
- * around expiration date/time is very loosely-described, it is preferrable to use locaStorage and
- * manage the expiration ourselves. sessionStorage has similar storage characteristics to
- * localStorage, although it seems to have better support by Firefox 3 at the moment. (That will
- * certainly change as Firefox continues getting better at HTML 5 adoption.)
- *
- * 3. UserData - A very under-exploited feature of Microsoft Internet Explorer, UserData is a
- * way to store up to 128K of data per "document", or up to 1MB of data per domain, on the client
- * computer. The feature is available for IE 5+, which makes it available for every version of IE
- * supported by TinyMCE. The content is persistent across browser restarts and expires on the
- * date/time specified, just like a cookie. However, the data is not cleared when the user clears
- * cookies on the browser, which makes it well-suited for rescuing autosaved content. UserData,
- * like other Microsoft IE browser technologies, is implemented as a behavior attached to a
- * specific DOM object, so in this case we attach the behavior to the same DOM element that the
- * TinyMCE editor instance is attached to.
- */
-
-(function(tinymce) {
- // Setup constants to help the compressor to reduce script size
- var PLUGIN_NAME = 'autosave',
- RESTORE_DRAFT = 'restoredraft',
- TRUE = true,
- undefined,
- unloadHandlerAdded,
- Dispatcher = tinymce.util.Dispatcher;
-
- /**
- * This plugin adds auto-save capability to the TinyMCE text editor to rescue content
- * inadvertently lost. By using localStorage.
- *
- * @class tinymce.plugins.AutoSave
- */
- tinymce.create('tinymce.plugins.AutoSave', {
- /**
- * Initializes the plugin, this will be executed after the plugin has been created.
- * This call is done before the editor instance has finished it's initialization so use the onInit event
- * of the editor instance to intercept that event.
- *
- * @method init
- * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
- * @param {string} url Absolute URL to where the plugin is located.
- */
- init : function(ed, url) {
- var self = this, settings = ed.settings;
-
- self.editor = ed;
-
- // Parses the specified time string into a milisecond number 10m, 10s etc.
- function parseTime(time) {
- var multipels = {
- s : 1000,
- m : 60000
- };
-
- time = /^(\d+)([ms]?)$/.exec('' + time);
-
- return (time[2] ? multipels[time[2]] : 1) * parseInt(time);
- };
-
- // Default config
- tinymce.each({
- ask_before_unload : TRUE,
- interval : '30s',
- retention : '20m',
- minlength : 50
- }, function(value, key) {
- key = PLUGIN_NAME + '_' + key;
-
- if (settings[key] === undefined)
- settings[key] = value;
- });
-
- // Parse times
- settings.autosave_interval = parseTime(settings.autosave_interval);
- settings.autosave_retention = parseTime(settings.autosave_retention);
-
- // Register restore button
- ed.addButton(RESTORE_DRAFT, {
- title : PLUGIN_NAME + ".restore_content",
- onclick : function() {
- if (ed.getContent({draft: true}).replace(/\s| |<\/?p[^>]*>| ]*>/gi, "").length > 0) {
- // Show confirm dialog if the editor isn't empty
- ed.windowManager.confirm(
- PLUGIN_NAME + ".warning_message",
- function(ok) {
- if (ok)
- self.restoreDraft();
- }
- );
- } else
- self.restoreDraft();
- }
- });
-
- // Enable/disable restoredraft button depending on if there is a draft stored or not
- ed.onNodeChange.add(function() {
- var controlManager = ed.controlManager;
-
- if (controlManager.get(RESTORE_DRAFT))
- controlManager.setDisabled(RESTORE_DRAFT, !self.hasDraft());
- });
-
- ed.onInit.add(function() {
- // Check if the user added the restore button, then setup auto storage logic
- if (ed.controlManager.get(RESTORE_DRAFT)) {
- // Setup storage engine
- self.setupStorage(ed);
-
- // Auto save contents each interval time
- setInterval(function() {
- if (!ed.removed) {
- self.storeDraft();
- ed.nodeChanged();
- }
- }, settings.autosave_interval);
- }
- });
-
- /**
- * This event gets fired when a draft is stored to local storage.
- *
- * @event onStoreDraft
- * @param {tinymce.plugins.AutoSave} sender Plugin instance sending the event.
- * @param {Object} draft Draft object containing the HTML contents of the editor.
- */
- self.onStoreDraft = new Dispatcher(self);
-
- /**
- * This event gets fired when a draft is restored from local storage.
- *
- * @event onStoreDraft
- * @param {tinymce.plugins.AutoSave} sender Plugin instance sending the event.
- * @param {Object} draft Draft object containing the HTML contents of the editor.
- */
- self.onRestoreDraft = new Dispatcher(self);
-
- /**
- * This event gets fired when a draft removed/expired.
- *
- * @event onRemoveDraft
- * @param {tinymce.plugins.AutoSave} sender Plugin instance sending the event.
- * @param {Object} draft Draft object containing the HTML contents of the editor.
- */
- self.onRemoveDraft = new Dispatcher(self);
-
- // Add ask before unload dialog only add one unload handler
- if (!unloadHandlerAdded) {
- window.onbeforeunload = tinymce.plugins.AutoSave._beforeUnloadHandler;
- unloadHandlerAdded = TRUE;
- }
- },
-
- /**
- * Returns information about the plugin as a name/value array.
- * The current keys are longname, author, authorurl, infourl and version.
- *
- * @method getInfo
- * @return {Object} Name/value array containing information about the plugin.
- */
- getInfo : function() {
- return {
- longname : 'Auto save',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
- };
- },
-
- /**
- * Returns an expiration date UTC string.
- *
- * @method getExpDate
- * @return {String} Expiration date UTC string.
- */
- getExpDate : function() {
- return new Date(
- new Date().getTime() + this.editor.settings.autosave_retention
- ).toUTCString();
- },
-
- /**
- * This method will setup the storage engine. If the browser has support for it.
- *
- * @method setupStorage
- */
- setupStorage : function(ed) {
- var self = this, testKey = PLUGIN_NAME + '_test', testVal = "OK";
-
- self.key = PLUGIN_NAME + ed.id;
-
- // Loop though each storage engine type until we find one that works
- tinymce.each([
- function() {
- // Try HTML5 Local Storage
- if (localStorage) {
- localStorage.setItem(testKey, testVal);
-
- if (localStorage.getItem(testKey) === testVal) {
- localStorage.removeItem(testKey);
-
- return localStorage;
- }
- }
- },
-
- function() {
- // Try HTML5 Session Storage
- if (sessionStorage) {
- sessionStorage.setItem(testKey, testVal);
-
- if (sessionStorage.getItem(testKey) === testVal) {
- sessionStorage.removeItem(testKey);
-
- return sessionStorage;
- }
- }
- },
-
- function() {
- // Try IE userData
- if (tinymce.isIE) {
- ed.getElement().style.behavior = "url('#default#userData')";
-
- // Fake localStorage on old IE
- return {
- autoExpires : TRUE,
-
- setItem : function(key, value) {
- var userDataElement = ed.getElement();
-
- userDataElement.setAttribute(key, value);
- userDataElement.expires = self.getExpDate();
-
- try {
- userDataElement.save("TinyMCE");
- } catch (e) {
- // Ignore, saving might fail if "Userdata Persistence" is disabled in IE
- }
- },
-
- getItem : function(key) {
- var userDataElement = ed.getElement();
-
- try {
- userDataElement.load("TinyMCE");
- return userDataElement.getAttribute(key);
- } catch (e) {
- // Ignore, loading might fail if "Userdata Persistence" is disabled in IE
- return null;
- }
- },
-
- removeItem : function(key) {
- ed.getElement().removeAttribute(key);
- }
- };
- }
- },
- ], function(setup) {
- // Try executing each function to find a suitable storage engine
- try {
- self.storage = setup();
-
- if (self.storage)
- return false;
- } catch (e) {
- // Ignore
- }
- });
- },
-
- /**
- * This method will store the current contents in the the storage engine.
- *
- * @method storeDraft
- */
- storeDraft : function() {
- var self = this, storage = self.storage, editor = self.editor, expires, content;
-
- // Is the contents dirty
- if (storage) {
- // If there is no existing key and the contents hasn't been changed since
- // it's original value then there is no point in saving a draft
- if (!storage.getItem(self.key) && !editor.isDirty())
- return;
-
- // Store contents if the contents if longer than the minlength of characters
- content = editor.getContent({draft: true});
- if (content.length > editor.settings.autosave_minlength) {
- expires = self.getExpDate();
-
- // Store expiration date if needed IE userData has auto expire built in
- if (!self.storage.autoExpires)
- self.storage.setItem(self.key + "_expires", expires);
-
- self.storage.setItem(self.key, content);
- self.onStoreDraft.dispatch(self, {
- expires : expires,
- content : content
- });
- }
- }
- },
-
- /**
- * This method will restore the contents from the storage engine back to the editor.
- *
- * @method restoreDraft
- */
- restoreDraft : function() {
- var self = this, storage = self.storage, content;
-
- if (storage) {
- content = storage.getItem(self.key);
-
- if (content) {
- self.editor.setContent(content);
- self.onRestoreDraft.dispatch(self, {
- content : content
- });
- }
- }
- },
-
- /**
- * This method will return true/false if there is a local storage draft available.
- *
- * @method hasDraft
- * @return {boolean} true/false state if there is a local draft.
- */
- hasDraft : function() {
- var self = this, storage = self.storage, expDate, exists;
-
- if (storage) {
- // Does the item exist at all
- exists = !!storage.getItem(self.key);
- if (exists) {
- // Storage needs autoexpire
- if (!self.storage.autoExpires) {
- expDate = new Date(storage.getItem(self.key + "_expires"));
-
- // Contents hasn't expired
- if (new Date().getTime() < expDate.getTime())
- return TRUE;
-
- // Remove it if it has
- self.removeDraft();
- } else
- return TRUE;
- }
- }
-
- return false;
- },
-
- /**
- * Removes the currently stored draft.
- *
- * @method removeDraft
- */
- removeDraft : function() {
- var self = this, storage = self.storage, key = self.key, content;
-
- if (storage) {
- // Get current contents and remove the existing draft
- content = storage.getItem(key);
- storage.removeItem(key);
- storage.removeItem(key + "_expires");
-
- // Dispatch remove event if we had any contents
- if (content) {
- self.onRemoveDraft.dispatch(self, {
- content : content
- });
- }
- }
- },
-
- "static" : {
- // Internal unload handler will be called before the page is unloaded
- _beforeUnloadHandler : function(e) {
- var msg;
-
- tinymce.each(tinyMCE.editors, function(ed) {
- // Store a draft for each editor instance
- if (ed.plugins.autosave)
- ed.plugins.autosave.storeDraft();
-
- // Never ask in fullscreen mode
- if (ed.getParam("fullscreen_is_enabled"))
- return;
-
- // Setup a return message if the editor is dirty
- if (!msg && ed.isDirty() && ed.getParam("autosave_ask_before_unload"))
- msg = ed.getLang("autosave.unload_msg");
- });
-
- return msg;
- }
- }
- });
-
- tinymce.PluginManager.add('autosave', tinymce.plugins.AutoSave);
-})(tinymce);
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ *
+ * Adds auto-save capability to the TinyMCE text editor to rescue content
+ * inadvertently lost. This plugin was originally developed by Speednet
+ * and that project can be found here: http://code.google.com/p/tinyautosave/
+ *
+ * TECHNOLOGY DISCUSSION:
+ *
+ * The plugin attempts to use the most advanced features available in the current browser to save
+ * as much content as possible. There are a total of four different methods used to autosave the
+ * content. In order of preference, they are:
+ *
+ * 1. localStorage - A new feature of HTML 5, localStorage can store megabytes of data per domain
+ * on the client computer. Data stored in the localStorage area has no expiration date, so we must
+ * manage expiring the data ourselves. localStorage is fully supported by IE8, and it is supposed
+ * to be working in Firefox 3 and Safari 3.2, but in reality is is flaky in those browsers. As
+ * HTML 5 gets wider support, the AutoSave plugin will use it automatically. In Windows Vista/7,
+ * localStorage is stored in the following folder:
+ * C:\Users\[username]\AppData\Local\Microsoft\Internet Explorer\DOMStore\[tempFolder]
+ *
+ * 2. sessionStorage - A new feature of HTML 5, sessionStorage works similarly to localStorage,
+ * except it is designed to expire after a certain amount of time. Because the specification
+ * around expiration date/time is very loosely-described, it is preferrable to use locaStorage and
+ * manage the expiration ourselves. sessionStorage has similar storage characteristics to
+ * localStorage, although it seems to have better support by Firefox 3 at the moment. (That will
+ * certainly change as Firefox continues getting better at HTML 5 adoption.)
+ *
+ * 3. UserData - A very under-exploited feature of Microsoft Internet Explorer, UserData is a
+ * way to store up to 128K of data per "document", or up to 1MB of data per domain, on the client
+ * computer. The feature is available for IE 5+, which makes it available for every version of IE
+ * supported by TinyMCE. The content is persistent across browser restarts and expires on the
+ * date/time specified, just like a cookie. However, the data is not cleared when the user clears
+ * cookies on the browser, which makes it well-suited for rescuing autosaved content. UserData,
+ * like other Microsoft IE browser technologies, is implemented as a behavior attached to a
+ * specific DOM object, so in this case we attach the behavior to the same DOM element that the
+ * TinyMCE editor instance is attached to.
+ */
+
+(function(tinymce) {
+ // Setup constants to help the compressor to reduce script size
+ var PLUGIN_NAME = 'autosave',
+ RESTORE_DRAFT = 'restoredraft',
+ TRUE = true,
+ undefined,
+ unloadHandlerAdded,
+ Dispatcher = tinymce.util.Dispatcher;
+
+ /**
+ * This plugin adds auto-save capability to the TinyMCE text editor to rescue content
+ * inadvertently lost. By using localStorage.
+ *
+ * @class tinymce.plugins.AutoSave
+ */
+ tinymce.create('tinymce.plugins.AutoSave', {
+ /**
+ * Initializes the plugin, this will be executed after the plugin has been created.
+ * This call is done before the editor instance has finished it's initialization so use the onInit event
+ * of the editor instance to intercept that event.
+ *
+ * @method init
+ * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
+ * @param {string} url Absolute URL to where the plugin is located.
+ */
+ init : function(ed, url) {
+ var self = this, settings = ed.settings;
+
+ self.editor = ed;
+
+ // Parses the specified time string into a milisecond number 10m, 10s etc.
+ function parseTime(time) {
+ var multipels = {
+ s : 1000,
+ m : 60000
+ };
+
+ time = /^(\d+)([ms]?)$/.exec('' + time);
+
+ return (time[2] ? multipels[time[2]] : 1) * parseInt(time);
+ };
+
+ // Default config
+ tinymce.each({
+ ask_before_unload : TRUE,
+ interval : '30s',
+ retention : '20m',
+ minlength : 50
+ }, function(value, key) {
+ key = PLUGIN_NAME + '_' + key;
+
+ if (settings[key] === undefined)
+ settings[key] = value;
+ });
+
+ // Parse times
+ settings.autosave_interval = parseTime(settings.autosave_interval);
+ settings.autosave_retention = parseTime(settings.autosave_retention);
+
+ // Register restore button
+ ed.addButton(RESTORE_DRAFT, {
+ title : PLUGIN_NAME + ".restore_content",
+ onclick : function() {
+ if (ed.getContent({draft: true}).replace(/\s| |<\/?p[^>]*>| ]*>/gi, "").length > 0) {
+ // Show confirm dialog if the editor isn't empty
+ ed.windowManager.confirm(
+ PLUGIN_NAME + ".warning_message",
+ function(ok) {
+ if (ok)
+ self.restoreDraft();
+ }
+ );
+ } else
+ self.restoreDraft();
+ }
+ });
+
+ // Enable/disable restoredraft button depending on if there is a draft stored or not
+ ed.onNodeChange.add(function() {
+ var controlManager = ed.controlManager;
+
+ if (controlManager.get(RESTORE_DRAFT))
+ controlManager.setDisabled(RESTORE_DRAFT, !self.hasDraft());
+ });
+
+ ed.onInit.add(function() {
+ // Check if the user added the restore button, then setup auto storage logic
+ if (ed.controlManager.get(RESTORE_DRAFT)) {
+ // Setup storage engine
+ self.setupStorage(ed);
+
+ // Auto save contents each interval time
+ setInterval(function() {
+ if (!ed.removed) {
+ self.storeDraft();
+ ed.nodeChanged();
+ }
+ }, settings.autosave_interval);
+ }
+ });
+
+ /**
+ * This event gets fired when a draft is stored to local storage.
+ *
+ * @event onStoreDraft
+ * @param {tinymce.plugins.AutoSave} sender Plugin instance sending the event.
+ * @param {Object} draft Draft object containing the HTML contents of the editor.
+ */
+ self.onStoreDraft = new Dispatcher(self);
+
+ /**
+ * This event gets fired when a draft is restored from local storage.
+ *
+ * @event onStoreDraft
+ * @param {tinymce.plugins.AutoSave} sender Plugin instance sending the event.
+ * @param {Object} draft Draft object containing the HTML contents of the editor.
+ */
+ self.onRestoreDraft = new Dispatcher(self);
+
+ /**
+ * This event gets fired when a draft removed/expired.
+ *
+ * @event onRemoveDraft
+ * @param {tinymce.plugins.AutoSave} sender Plugin instance sending the event.
+ * @param {Object} draft Draft object containing the HTML contents of the editor.
+ */
+ self.onRemoveDraft = new Dispatcher(self);
+
+ // Add ask before unload dialog only add one unload handler
+ if (!unloadHandlerAdded) {
+ window.onbeforeunload = tinymce.plugins.AutoSave._beforeUnloadHandler;
+ unloadHandlerAdded = TRUE;
+ }
+ },
+
+ /**
+ * Returns information about the plugin as a name/value array.
+ * The current keys are longname, author, authorurl, infourl and version.
+ *
+ * @method getInfo
+ * @return {Object} Name/value array containing information about the plugin.
+ */
+ getInfo : function() {
+ return {
+ longname : 'Auto save',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
+
+ /**
+ * Returns an expiration date UTC string.
+ *
+ * @method getExpDate
+ * @return {String} Expiration date UTC string.
+ */
+ getExpDate : function() {
+ return new Date(
+ new Date().getTime() + this.editor.settings.autosave_retention
+ ).toUTCString();
+ },
+
+ /**
+ * This method will setup the storage engine. If the browser has support for it.
+ *
+ * @method setupStorage
+ */
+ setupStorage : function(ed) {
+ var self = this, testKey = PLUGIN_NAME + '_test', testVal = "OK";
+
+ self.key = PLUGIN_NAME + ed.id;
+
+ // Loop though each storage engine type until we find one that works
+ tinymce.each([
+ function() {
+ // Try HTML5 Local Storage
+ if (localStorage) {
+ localStorage.setItem(testKey, testVal);
+
+ if (localStorage.getItem(testKey) === testVal) {
+ localStorage.removeItem(testKey);
+
+ return localStorage;
+ }
+ }
+ },
+
+ function() {
+ // Try HTML5 Session Storage
+ if (sessionStorage) {
+ sessionStorage.setItem(testKey, testVal);
+
+ if (sessionStorage.getItem(testKey) === testVal) {
+ sessionStorage.removeItem(testKey);
+
+ return sessionStorage;
+ }
+ }
+ },
+
+ function() {
+ // Try IE userData
+ if (tinymce.isIE) {
+ ed.getElement().style.behavior = "url('#default#userData')";
+
+ // Fake localStorage on old IE
+ return {
+ autoExpires : TRUE,
+
+ setItem : function(key, value) {
+ var userDataElement = ed.getElement();
+
+ userDataElement.setAttribute(key, value);
+ userDataElement.expires = self.getExpDate();
+
+ try {
+ userDataElement.save("TinyMCE");
+ } catch (e) {
+ // Ignore, saving might fail if "Userdata Persistence" is disabled in IE
+ }
+ },
+
+ getItem : function(key) {
+ var userDataElement = ed.getElement();
+
+ try {
+ userDataElement.load("TinyMCE");
+ return userDataElement.getAttribute(key);
+ } catch (e) {
+ // Ignore, loading might fail if "Userdata Persistence" is disabled in IE
+ return null;
+ }
+ },
+
+ removeItem : function(key) {
+ ed.getElement().removeAttribute(key);
+ }
+ };
+ }
+ },
+ ], function(setup) {
+ // Try executing each function to find a suitable storage engine
+ try {
+ self.storage = setup();
+
+ if (self.storage)
+ return false;
+ } catch (e) {
+ // Ignore
+ }
+ });
+ },
+
+ /**
+ * This method will store the current contents in the the storage engine.
+ *
+ * @method storeDraft
+ */
+ storeDraft : function() {
+ var self = this, storage = self.storage, editor = self.editor, expires, content;
+
+ // Is the contents dirty
+ if (storage) {
+ // If there is no existing key and the contents hasn't been changed since
+ // it's original value then there is no point in saving a draft
+ if (!storage.getItem(self.key) && !editor.isDirty())
+ return;
+
+ // Store contents if the contents if longer than the minlength of characters
+ content = editor.getContent({draft: true});
+ if (content.length > editor.settings.autosave_minlength) {
+ expires = self.getExpDate();
+
+ // Store expiration date if needed IE userData has auto expire built in
+ if (!self.storage.autoExpires)
+ self.storage.setItem(self.key + "_expires", expires);
+
+ self.storage.setItem(self.key, content);
+ self.onStoreDraft.dispatch(self, {
+ expires : expires,
+ content : content
+ });
+ }
+ }
+ },
+
+ /**
+ * This method will restore the contents from the storage engine back to the editor.
+ *
+ * @method restoreDraft
+ */
+ restoreDraft : function() {
+ var self = this, storage = self.storage, content;
+
+ if (storage) {
+ content = storage.getItem(self.key);
+
+ if (content) {
+ self.editor.setContent(content);
+ self.onRestoreDraft.dispatch(self, {
+ content : content
+ });
+ }
+ }
+ },
+
+ /**
+ * This method will return true/false if there is a local storage draft available.
+ *
+ * @method hasDraft
+ * @return {boolean} true/false state if there is a local draft.
+ */
+ hasDraft : function() {
+ var self = this, storage = self.storage, expDate, exists;
+
+ if (storage) {
+ // Does the item exist at all
+ exists = !!storage.getItem(self.key);
+ if (exists) {
+ // Storage needs autoexpire
+ if (!self.storage.autoExpires) {
+ expDate = new Date(storage.getItem(self.key + "_expires"));
+
+ // Contents hasn't expired
+ if (new Date().getTime() < expDate.getTime())
+ return TRUE;
+
+ // Remove it if it has
+ self.removeDraft();
+ } else
+ return TRUE;
+ }
+ }
+
+ return false;
+ },
+
+ /**
+ * Removes the currently stored draft.
+ *
+ * @method removeDraft
+ */
+ removeDraft : function() {
+ var self = this, storage = self.storage, key = self.key, content;
+
+ if (storage) {
+ // Get current contents and remove the existing draft
+ content = storage.getItem(key);
+ storage.removeItem(key);
+ storage.removeItem(key + "_expires");
+
+ // Dispatch remove event if we had any contents
+ if (content) {
+ self.onRemoveDraft.dispatch(self, {
+ content : content
+ });
+ }
+ }
+ },
+
+ "static" : {
+ // Internal unload handler will be called before the page is unloaded
+ _beforeUnloadHandler : function(e) {
+ var msg;
+
+ tinymce.each(tinyMCE.editors, function(ed) {
+ // Store a draft for each editor instance
+ if (ed.plugins.autosave)
+ ed.plugins.autosave.storeDraft();
+
+ // Never ask in fullscreen mode
+ if (ed.getParam("fullscreen_is_enabled"))
+ return;
+
+ // Setup a return message if the editor is dirty
+ if (!msg && ed.isDirty() && ed.getParam("autosave_ask_before_unload"))
+ msg = ed.getLang("autosave.unload_msg");
+ });
+
+ return msg;
+ }
+ }
+ });
+
+ tinymce.PluginManager.add('autosave', tinymce.plugins.AutoSave);
+})(tinymce);
diff --git a/js/tiny_mce/plugins/autosave/langs/en.js b/js/tiny_mce/plugins/autosave/langs/en.js
index fce6bd3e1fa..219f769ac4a 100644
--- a/js/tiny_mce/plugins/autosave/langs/en.js
+++ b/js/tiny_mce/plugins/autosave/langs/en.js
@@ -1,4 +1,4 @@
-tinyMCE.addI18n('en.autosave',{
-restore_content: "Restore auto-saved content",
-warning_message: "If you restore the saved content, you will lose all the content that is currently in the editor.\n\nAre you sure you want to restore the saved content?"
+tinyMCE.addI18n('en.autosave',{
+restore_content: "Restore auto-saved content",
+warning_message: "If you restore the saved content, you will lose all the content that is currently in the editor.\n\nAre you sure you want to restore the saved content?"
});
\ No newline at end of file
diff --git a/js/tiny_mce/plugins/bbcode/editor_plugin_src.js b/js/tiny_mce/plugins/bbcode/editor_plugin_src.js
index 4e7eb3377ff..12cdacaa582 100644
--- a/js/tiny_mce/plugins/bbcode/editor_plugin_src.js
+++ b/js/tiny_mce/plugins/bbcode/editor_plugin_src.js
@@ -1,120 +1,120 @@
-/**
- * editor_plugin_src.js
- *
- * Copyright 2009, Moxiecode Systems AB
- * Released under LGPL License.
- *
- * License: http://tinymce.moxiecode.com/license
- * Contributing: http://tinymce.moxiecode.com/contributing
- */
-
-(function() {
- tinymce.create('tinymce.plugins.BBCodePlugin', {
- init : function(ed, url) {
- var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase();
-
- ed.onBeforeSetContent.add(function(ed, o) {
- o.content = t['_' + dialect + '_bbcode2html'](o.content);
- });
-
- ed.onPostProcess.add(function(ed, o) {
- if (o.set)
- o.content = t['_' + dialect + '_bbcode2html'](o.content);
-
- if (o.get)
- o.content = t['_' + dialect + '_html2bbcode'](o.content);
- });
- },
-
- getInfo : function() {
- return {
- longname : 'BBCode Plugin',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
- };
- },
-
- // Private methods
-
- // HTML -> BBCode in PunBB dialect
- _punbb_html2bbcode : function(s) {
- s = tinymce.trim(s);
-
- function rep(re, str) {
- s = s.replace(re, str);
- };
-
- // example: to [b]
- rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]");
- rep(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
- rep(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
- rep(/(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
- rep(/(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
- rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]");
- rep(/(.*?)<\/font>/gi,"[color=$1]$2[/color]");
- rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]");
- rep(/(.*?)<\/font>/gi,"$1");
- rep(//gi,"[img]$1[/img]");
- rep(/(.*?)<\/span>/gi,"[code]$1[/code]");
- rep(/(.*?)<\/span>/gi,"[quote]$1[/quote]");
- rep(/(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
- rep(/(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
- rep(/(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
- rep(/(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
- rep(/(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
- rep(/(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");
- rep(/<\/(strong|b)>/gi,"[/b]");
- rep(/<(strong|b)>/gi,"[b]");
- rep(/<\/(em|i)>/gi,"[/i]");
- rep(/<(em|i)>/gi,"[i]");
- rep(/<\/u>/gi,"[/u]");
- rep(/(.*?)<\/span>/gi,"[u]$1[/u]");
- rep(//gi,"[u]");
- rep(/