Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated packages

  • Loading branch information...
commit 7637eeb7b0bca261f55c6bffe358b958ec01434a 1 parent aec5732
Michael Robinson faceleg authored
269 packages/raptor.0deps.js
View
@@ -1,5 +1,5 @@
/*!
-VERSION: 0.0.24
+VERSION: 0.0.25
For license information, see http://www.raptor-editor.com/license
*/
/**
@@ -25650,31 +25650,6 @@ selectionReplace('&lt;p&gt;Replace selection with this&lt;/p&gt;');</pre>
*/
var domTools = {
- /**
- * Removes all ranges from a selection that are not contained within the
- * supplied element.
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element
- * @param {RangySelection} [selection]
- */
- constrainSelection: function(element, selection) {
- element = $(element)[0];
- selection = selection || rangy.getSelection();
-
- var commonAncestor;
- $(selection.getAllRanges()).each(function(i, range){
- if (this.commonAncestorContainer.nodeType === 3) {
- commonAncestor = $(range.commonAncestorContainer).parent()[0];
- } else {
- commonAncestor = range.commonAncestorContainer;
- }
- if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
- selection.removeRange(range);
- }
- });
- },
-
unwrapParentTag: function(tag) {
selectionGetElements().each(function(){
if ($(this).is(tag)) {
@@ -25756,22 +25731,6 @@ var domTools = {
},
/**
- * Wraps the inner content of an element with a tag
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
- * @param {String} tag The wrapper tag name
- */
- wrapInner: function(element, tag) {
- selectionSave();
- $(element).each(function() {
- var wrapper = $('<' + tag + '/>').html($(this).html());
- element.html(wrapper);
- });
- selectionRestore();
- },
-
- /**
*
*/
inverseWrapWithTagClass: function(tag1, class1, tag2, class2) {
@@ -25802,34 +25761,6 @@ var domTools = {
});
selectionRestore();
- },
-
- /**
- * FIXME: this function needs reviewing
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
- */
- toggleStyle: function(element, styles) {
- $.each(styles, function(property, value) {
- if ($(element).css(property) === value) {
- $(element).css(property, '');
- } else {
- $(element).css(property, value);
- }
- });
- },
-
- /**
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element1
- * @param {jQuerySelector|jQuery|Element} element2
- * @param {Object} style
- */
- swapStyles: function(element1, element2, style) {
- for (var name in style) {
- element1.css(name, element2.css(name));
- element2.css(name, style[name]);
- }
}
};
@@ -26075,6 +26006,10 @@ $.widget('ui.editor',
// Stores the previous selection
this.previousSelection = null;
+ // Set the initial locale
+ var locale = this.persist('locale') || this.options.initialLocale;
+ setLocale(locale);
+
// Fire the ready event
this.ready = true;
this.fire('ready');
@@ -26215,7 +26150,7 @@ $.widget('ui.editor',
if (!this[i]) {
this[i] = (function(i) {
return function() {
- this.options.domTools.constrainSelection(this.getElement());
+ selectionConstrain(this.getElement());
var html = this.getHtml();
var result = this.options.domTools[i].apply(this.options.domTools, arguments);
if (html !== this.getHtml()) {
@@ -26398,22 +26333,26 @@ $.widget('ui.editor',
if (node.nodeType === 3) {
// If nodes common parent is a text node, then use its parent
element = $(node).parent();
- // } else if(this.rangeEmptyTag(range)) {
- // element = $(this.domFragmentToHtml(range.cloneContents()));
} else {
// Or else use the node
element = $(node);
}
+ // Ensure the element is the editing element or a child of the editing element
+ if (!editor.isRoot(element) && !$.contains(editor.getElement().get(0), element.get(0))) {
+ element = editor.getElement();
+ }
+
var list = [];
lists.push(list);
- // Loop untill we get to the root element, or the body tag
+ // Loop until we get to the root element, or the body tag
while (element[0] && !editor.isRoot(element) && element[0].tagName.toLowerCase() !== 'body') {
// Add the node to the list
list.push(element);
element = element.parent();
}
list.reverse();
+
if (title) title += ' | ';
title += this.getTemplate('root');
for (var j = 0; j < list.length; j++) {
@@ -27422,6 +27361,9 @@ $.extend($.ui.editor,
elementDefaultDisplay: elementDefaultDisplay,
elementIsValid: elementIsValid,
elementGetStyles: elementGetStyles,
+ elementWrapInner: elementWrapInner,
+ elementToggleStyle: elementToggleStyle,
+ elementSwapStyles: elementSwapStyles,
fragmentToHtml: fragmentToHtml,
fragmentInsertBefore: fragmentInsertBefore,
rangeExpandToParent: rangeExpandToParent,
@@ -27447,99 +27389,102 @@ $.extend($.ui.editor,
stringStripTags: stringStripTags,
// </expose>
- /** @namespace Default options for the jQuery UI Editor */
+ /** @namespace Default options for Raptor Editor */
defaults: {
- /** @type Object Plugins option overrides */
+ /** @type {Object} Plugins option overrides */
plugins: {},
- /** @type Object UI option overrides */
+ /** @type {Object} UI option overrides */
ui: {},
- /** @type Object Default events to bind */
+ /** @type {Object} Default events to bind */
bind: {},
- /** @type Object */
+ /**
+ * @deprecated
+ * @type {Object}
+ */
domTools: domTools,
/**
- * @type String Namespace used to persistence to prevent conflicting
- * stored values
+ * @type {String} Namespace used to persistence to prevent conflicting
+ * stored values.
*/
namespace: null,
/**
- * @type boolean Switch to indicated that some events should be
- * automatically applied to all editors that are 'unified'
+ * @type {Boolean} Switch to indicated that some events should be
+ * automatically applied to all editors that are unified.
*/
unify: true,
- /** @type boolean Switch to indicate weather or not to stored persistent
- values, if set to false the persist function will always return null */
+ /**
+ * @type {Boolean} Switch to indicate weather or not to stored persistent
+ * values, if set to false the persist function will always return null.
+ */
persistence: true,
- /** @type String The name to store persistent values under */
+ /** @type {String} The name to store persistent values under */
persistenceName: 'uiEditor',
/**
- * Switch to indicate weather or not to a warning should pop up when the
- * user navigates aways from the page and there are unsaved changes
- * @type boolean
+ * @type {Boolean} Switch to indicate weather or not to a warning should
+ * pop up when the user navigates away from the page when unsaved changes
+ * exist.
*/
unloadWarning: true,
/**
- * @type boolean Switch to automatically enabled editing on the element
+ * @type {Boolean} Switch to automatically enabled editing on the element.
*/
autoEnable: false,
/**
- * @type {jQuerySelector} Only enable editing on certian parts of the element
+ * @type {Selector} Only enable editing on certain parts of the element.
*/
partialEdit: false,
/**
- * Switch to specify if the editor should automatically enable all
- * plugins, if set to false, only the plugins specified in the 'plugins'
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all plugins, if set to false, only the plugins specified in
+ * the {@link $.ui.editor.defaults.plugins} option object will be enabled.
*/
enablePlugins: true,
/**
- * @type String[] An array of explicitly disabled plugins
+ * @type {String[]} An array of explicitly disabled plugins.
*/
disabledPlugins: [],
/**
- * @type String[] And array of arrays denoting the order and grouping of UI elements in the toolbar
+ * @type {String[]} And array of arrays denoting the order and grouping
+ * of UI elements in the toolbar.
*/
uiOrder: null,
/**
- * Switch to specify if the editor should automatically enable all UI,
- * if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all UI, if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
+ * option object will be enabled.
*/
enableUi: true,
/**
- * An array of explicitly disabled UI elements
- * @type String[]
+ * @type {String[]} An array of explicitly disabled UI elements.
*/
disabledUi: [],
/**
- * Default message options
- * @type Object
+ * @type {Object} Default message options.
*/
message: {
delay: 5000
},
/**
- * @type String[] A list of styles that will be copied from a replaced textarea and applied to the editor replacement element
+ * @type {String[]} A list of styles that will be copied from a replaced
+ * textarea and applied to the editor replacement element.
*/
replaceStyle: [
'display', 'position', 'float', 'width',
@@ -27547,17 +27492,10 @@ $.extend($.ui.editor,
'margin-left', 'margin-right', 'margin-top', 'margin-bottom'
],
- /**
- *
- * @type String
- */
+ /** @type {String} The base class name to use on elements created by the editor. */
baseClass: 'ui-editor',
- /**
- * CSS class prefix that is prepended to inserted elements classes.
- * <pre>"cms-bold"</pre>
- * @type String
- */
+ /** @type {String} CSS class prefix that is prepended to inserted elements classes. */
cssPrefix: 'cms-',
/** @type {Boolean} True if the editor should be draggable. */
@@ -27573,7 +27511,14 @@ $.extend($.ui.editor,
* @type {String} Applied to elements that should not be stripped during
* normal use, but do not belong in the final content.
*/
- supplementaryClass: 'supplementary-element-class'
+ supplementaryClass: 'supplementary-element-class',
+
+ /**
+ * @type {String} Locale to use by default. If
+ * {@link $.ui.editor.options.persistence} is set to true and the user has
+ * changed the locale, then the user's locale choice will be used.
+ */
+ initialLocale: 'en'
},
/** @property {Object} events Events added via $.ui.editor.bind */
@@ -29330,7 +29275,7 @@ $.ui.editor.registerPlugin('emptyElement', /** @lends $.editor.plugin.emptyEleme
* @see $.ui.editor.defaultPlugin#init
*/
init: function(editor, options) {
- this.bind('change', this.change)
+ this.bind('change', this.change);
},
change: function() {
@@ -29656,11 +29601,6 @@ $.ui.editor.registerUi({
*/
init: function(editor, options) {
var ui = this;
- var locale = this.persist('locale');
- if (locale) {
- // @todo Move this to the global scope
- setLocale(locale);
- }
var menu = $('<select autocomplete="off" name="i18n"/>');
@@ -29673,7 +29613,7 @@ $.ui.editor.registerUi({
}
menu.append(option);
- };
+ }
return editor.uiSelectMenu({
title: _('Change Language'),
@@ -31670,7 +31610,7 @@ $.ui.editor.registerPlugin('list', /** @lends $.editor.plugin.list.prototype */
* @param {string} listType One of ul or ol.
*/
wrapList: function(listType) {
- this.editor.constrainSelection(this.editor.getElement());
+ selectionConstrain(this.editor.getElement());
if ($.trim(selectionGetHtml()) === '') {
selectionSelectInner(selectionGetElements());
}
@@ -31902,7 +31842,7 @@ $.ui.editor.registerUi({
}
this.ui.button.find('.ui-button-icon-primary').css({
- 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.24?' + query.join('&') + ')'
+ 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.25?' + query.join('&') + ')'
});
}
});
@@ -33200,8 +33140,8 @@ $.ui.editor.registerUi({
* Replace selection if the selected element parent or the selected element is the editing element,
* instead of splitting the editing element.
*/
- if (selectedElementParent === editingElement
- || selectionGetElements()[0] === editingElement) {
+ if (selectedElementParent === editingElement ||
+ selectionGetElements()[0] === editingElement) {
selectionReplace(replacementHtml);
} else {
selectionReplaceWithinValidTags(replacementHtml, this.validParents);
@@ -33641,6 +33581,48 @@ function elementGetStyles(element) {
}
return result;
}
+
+/**
+ * Wraps the inner content of an element with a tag
+ *
+ * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
+ * @param {String} tag The wrapper tag name
+ */
+function elementWrapInner(element, tag) {
+ selectionSave();
+ $(element).each(function() {
+ var wrapper = $('<' + tag + '/>').html($(this).html());
+ element.html(wrapper);
+ });
+ selectionRestore();
+}
+
+/**
+ * FIXME: this function needs reviewing
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
+ */
+function elementToggleStyle(element, styles) {
+ $.each(styles, function(property, value) {
+ if ($(element).css(property) === value) {
+ $(element).css(property, '');
+ } else {
+ $(element).css(property, value);
+ }
+ });
+}
+
+/**
+ * @param {jQuerySelector|jQuery|Element} element1
+ * @param {jQuerySelector|jQuery|Element} element2
+ * @param {Object} style
+ */
+function elementSwapStyles(element1, element2, style) {
+ for (var name in style) {
+ element1.css(name, element2.css(name));
+ element2.css(name, style[name]);
+ }
+}
/**
* @fileOverview DOM fragment manipulation helper functions
* @author David Neilsen david@panmedia.co.nz
@@ -34152,15 +34134,44 @@ function selectionToggleBlockStyle(styles, limit) {
// Only apply block style if the limit element is a block
if (limit.css('display') !== 'inline') {
// Wrap the HTML inside the limit element
- this.wrapInner(limit, 'div');
+ elementWrapInner(limit, 'div');
// Set the parent to the wrapper
parent = limit.children().first();
}
}
// Apply the style to the parent
- this.toggleStyle(parent, styles);
+ elementToggleStyle(parent, styles);
}, null, this);
}
+
+/**
+ * Removes all ranges from a selection that are not contained within the
+ * supplied element.
+ *
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element
+ * @param {RangySelection} [selection]
+ */
+function selectionConstrain(element, selection) {
+ element = $(element)[0];
+ selection = selection || (rangy) ? rangy.getSelection() : null;
+
+ if (!selection) {
+ return;
+ }
+
+ var commonAncestor;
+ $(selection.getAllRanges()).each(function(i, range){
+ if (this.commonAncestorContainer.nodeType === 3) {
+ commonAncestor = $(range.commonAncestorContainer).parent()[0];
+ } else {
+ commonAncestor = range.commonAncestorContainer;
+ }
+ if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
+ selection.removeRange(range);
+ }
+ });
+}
/**
* @fileOverview String helper functions
* @author David Neilsen - david@panmedia.co.nz
1,175 packages/raptor.0deps.min.js
View
588 additions, 587 deletions not shown
BIN  packages/raptor.0deps.min.js.gz
View
Binary file not shown
269 packages/raptor.0deps.nc.js
View
@@ -1,5 +1,5 @@
/*!
-VERSION: 0.0.24
+VERSION: 0.0.25
For license information, see http://www.raptor-editor.com/license
*/
/**
@@ -25656,31 +25656,6 @@ selectionReplace('&lt;p&gt;Replace selection with this&lt;/p&gt;');</pre>
*/
var domTools = {
- /**
- * Removes all ranges from a selection that are not contained within the
- * supplied element.
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element
- * @param {RangySelection} [selection]
- */
- constrainSelection: function(element, selection) {
- element = $(element)[0];
- selection = selection || rangy.getSelection();
-
- var commonAncestor;
- $(selection.getAllRanges()).each(function(i, range){
- if (this.commonAncestorContainer.nodeType === 3) {
- commonAncestor = $(range.commonAncestorContainer).parent()[0];
- } else {
- commonAncestor = range.commonAncestorContainer;
- }
- if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
- selection.removeRange(range);
- }
- });
- },
-
unwrapParentTag: function(tag) {
selectionGetElements().each(function(){
if ($(this).is(tag)) {
@@ -25762,22 +25737,6 @@ var domTools = {
},
/**
- * Wraps the inner content of an element with a tag
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
- * @param {String} tag The wrapper tag name
- */
- wrapInner: function(element, tag) {
- selectionSave();
- $(element).each(function() {
- var wrapper = $('<' + tag + '/>').html($(this).html());
- element.html(wrapper);
- });
- selectionRestore();
- },
-
- /**
*
*/
inverseWrapWithTagClass: function(tag1, class1, tag2, class2) {
@@ -25808,34 +25767,6 @@ var domTools = {
});
selectionRestore();
- },
-
- /**
- * FIXME: this function needs reviewing
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
- */
- toggleStyle: function(element, styles) {
- $.each(styles, function(property, value) {
- if ($(element).css(property) === value) {
- $(element).css(property, '');
- } else {
- $(element).css(property, value);
- }
- });
- },
-
- /**
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element1
- * @param {jQuerySelector|jQuery|Element} element2
- * @param {Object} style
- */
- swapStyles: function(element1, element2, style) {
- for (var name in style) {
- element1.css(name, element2.css(name));
- element2.css(name, style[name]);
- }
}
};
@@ -26081,6 +26012,10 @@ $.widget('ui.editor',
// Stores the previous selection
this.previousSelection = null;
+ // Set the initial locale
+ var locale = this.persist('locale') || this.options.initialLocale;
+ setLocale(locale);
+
// Fire the ready event
this.ready = true;
this.fire('ready');
@@ -26221,7 +26156,7 @@ $.widget('ui.editor',
if (!this[i]) {
this[i] = (function(i) {
return function() {
- this.options.domTools.constrainSelection(this.getElement());
+ selectionConstrain(this.getElement());
var html = this.getHtml();
var result = this.options.domTools[i].apply(this.options.domTools, arguments);
if (html !== this.getHtml()) {
@@ -26404,22 +26339,26 @@ $.widget('ui.editor',
if (node.nodeType === 3) {
// If nodes common parent is a text node, then use its parent
element = $(node).parent();
- // } else if(this.rangeEmptyTag(range)) {
- // element = $(this.domFragmentToHtml(range.cloneContents()));
} else {
// Or else use the node
element = $(node);
}
+ // Ensure the element is the editing element or a child of the editing element
+ if (!editor.isRoot(element) && !$.contains(editor.getElement().get(0), element.get(0))) {
+ element = editor.getElement();
+ }
+
var list = [];
lists.push(list);
- // Loop untill we get to the root element, or the body tag
+ // Loop until we get to the root element, or the body tag
while (element[0] && !editor.isRoot(element) && element[0].tagName.toLowerCase() !== 'body') {
// Add the node to the list
list.push(element);
element = element.parent();
}
list.reverse();
+
if (title) title += ' | ';
title += this.getTemplate('root');
for (var j = 0; j < list.length; j++) {
@@ -27428,6 +27367,9 @@ $.extend($.ui.editor,
elementDefaultDisplay: elementDefaultDisplay,
elementIsValid: elementIsValid,
elementGetStyles: elementGetStyles,
+ elementWrapInner: elementWrapInner,
+ elementToggleStyle: elementToggleStyle,
+ elementSwapStyles: elementSwapStyles,
fragmentToHtml: fragmentToHtml,
fragmentInsertBefore: fragmentInsertBefore,
rangeExpandToParent: rangeExpandToParent,
@@ -27453,99 +27395,102 @@ $.extend($.ui.editor,
stringStripTags: stringStripTags,
// </expose>
- /** @namespace Default options for the jQuery UI Editor */
+ /** @namespace Default options for Raptor Editor */
defaults: {
- /** @type Object Plugins option overrides */
+ /** @type {Object} Plugins option overrides */
plugins: {},
- /** @type Object UI option overrides */
+ /** @type {Object} UI option overrides */
ui: {},
- /** @type Object Default events to bind */
+ /** @type {Object} Default events to bind */
bind: {},
- /** @type Object */
+ /**
+ * @deprecated
+ * @type {Object}
+ */
domTools: domTools,
/**
- * @type String Namespace used to persistence to prevent conflicting
- * stored values
+ * @type {String} Namespace used to persistence to prevent conflicting
+ * stored values.
*/
namespace: null,
/**
- * @type boolean Switch to indicated that some events should be
- * automatically applied to all editors that are 'unified'
+ * @type {Boolean} Switch to indicated that some events should be
+ * automatically applied to all editors that are unified.
*/
unify: true,
- /** @type boolean Switch to indicate weather or not to stored persistent
- values, if set to false the persist function will always return null */
+ /**
+ * @type {Boolean} Switch to indicate weather or not to stored persistent
+ * values, if set to false the persist function will always return null.
+ */
persistence: true,
- /** @type String The name to store persistent values under */
+ /** @type {String} The name to store persistent values under */
persistenceName: 'uiEditor',
/**
- * Switch to indicate weather or not to a warning should pop up when the
- * user navigates aways from the page and there are unsaved changes
- * @type boolean
+ * @type {Boolean} Switch to indicate weather or not to a warning should
+ * pop up when the user navigates away from the page when unsaved changes
+ * exist.
*/
unloadWarning: true,
/**
- * @type boolean Switch to automatically enabled editing on the element
+ * @type {Boolean} Switch to automatically enabled editing on the element.
*/
autoEnable: false,
/**
- * @type {jQuerySelector} Only enable editing on certian parts of the element
+ * @type {Selector} Only enable editing on certain parts of the element.
*/
partialEdit: false,
/**
- * Switch to specify if the editor should automatically enable all
- * plugins, if set to false, only the plugins specified in the 'plugins'
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all plugins, if set to false, only the plugins specified in
+ * the {@link $.ui.editor.defaults.plugins} option object will be enabled.
*/
enablePlugins: true,
/**
- * @type String[] An array of explicitly disabled plugins
+ * @type {String[]} An array of explicitly disabled plugins.
*/
disabledPlugins: [],
/**
- * @type String[] And array of arrays denoting the order and grouping of UI elements in the toolbar
+ * @type {String[]} And array of arrays denoting the order and grouping
+ * of UI elements in the toolbar.
*/
uiOrder: null,
/**
- * Switch to specify if the editor should automatically enable all UI,
- * if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all UI, if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
+ * option object will be enabled.
*/
enableUi: true,
/**
- * An array of explicitly disabled UI elements
- * @type String[]
+ * @type {String[]} An array of explicitly disabled UI elements.
*/
disabledUi: [],
/**
- * Default message options
- * @type Object
+ * @type {Object} Default message options.
*/
message: {
delay: 5000
},
/**
- * @type String[] A list of styles that will be copied from a replaced textarea and applied to the editor replacement element
+ * @type {String[]} A list of styles that will be copied from a replaced
+ * textarea and applied to the editor replacement element.
*/
replaceStyle: [
'display', 'position', 'float', 'width',
@@ -27553,17 +27498,10 @@ $.extend($.ui.editor,
'margin-left', 'margin-right', 'margin-top', 'margin-bottom'
],
- /**
- *
- * @type String
- */
+ /** @type {String} The base class name to use on elements created by the editor. */
baseClass: 'ui-editor',
- /**
- * CSS class prefix that is prepended to inserted elements classes.
- * <pre>"cms-bold"</pre>
- * @type String
- */
+ /** @type {String} CSS class prefix that is prepended to inserted elements classes. */
cssPrefix: 'cms-',
/** @type {Boolean} True if the editor should be draggable. */
@@ -27579,7 +27517,14 @@ $.extend($.ui.editor,
* @type {String} Applied to elements that should not be stripped during
* normal use, but do not belong in the final content.
*/
- supplementaryClass: 'supplementary-element-class'
+ supplementaryClass: 'supplementary-element-class',
+
+ /**
+ * @type {String} Locale to use by default. If
+ * {@link $.ui.editor.options.persistence} is set to true and the user has
+ * changed the locale, then the user's locale choice will be used.
+ */
+ initialLocale: 'en'
},
/** @property {Object} events Events added via $.ui.editor.bind */
@@ -29336,7 +29281,7 @@ $.ui.editor.registerPlugin('emptyElement', /** @lends $.editor.plugin.emptyEleme
* @see $.ui.editor.defaultPlugin#init
*/
init: function(editor, options) {
- this.bind('change', this.change)
+ this.bind('change', this.change);
},
change: function() {
@@ -29662,11 +29607,6 @@ $.ui.editor.registerUi({
*/
init: function(editor, options) {
var ui = this;
- var locale = this.persist('locale');
- if (locale) {
- // @todo Move this to the global scope
- setLocale(locale);
- }
var menu = $('<select autocomplete="off" name="i18n"/>');
@@ -29679,7 +29619,7 @@ $.ui.editor.registerUi({
}
menu.append(option);
- };
+ }
return editor.uiSelectMenu({
title: _('Change Language'),
@@ -31676,7 +31616,7 @@ $.ui.editor.registerPlugin('list', /** @lends $.editor.plugin.list.prototype */
* @param {string} listType One of ul or ol.
*/
wrapList: function(listType) {
- this.editor.constrainSelection(this.editor.getElement());
+ selectionConstrain(this.editor.getElement());
if ($.trim(selectionGetHtml()) === '') {
selectionSelectInner(selectionGetElements());
}
@@ -31908,7 +31848,7 @@ $.ui.editor.registerUi({
}
this.ui.button.find('.ui-button-icon-primary').css({
- 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.24?' + query.join('&') + ')'
+ 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.25?' + query.join('&') + ')'
});
}
});
@@ -33206,8 +33146,8 @@ $.ui.editor.registerUi({
* Replace selection if the selected element parent or the selected element is the editing element,
* instead of splitting the editing element.
*/
- if (selectedElementParent === editingElement
- || selectionGetElements()[0] === editingElement) {
+ if (selectedElementParent === editingElement ||
+ selectionGetElements()[0] === editingElement) {
selectionReplace(replacementHtml);
} else {
selectionReplaceWithinValidTags(replacementHtml, this.validParents);
@@ -33647,6 +33587,48 @@ function elementGetStyles(element) {
}
return result;
}
+
+/**
+ * Wraps the inner content of an element with a tag
+ *
+ * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
+ * @param {String} tag The wrapper tag name
+ */
+function elementWrapInner(element, tag) {
+ selectionSave();
+ $(element).each(function() {
+ var wrapper = $('<' + tag + '/>').html($(this).html());
+ element.html(wrapper);
+ });
+ selectionRestore();
+}
+
+/**
+ * FIXME: this function needs reviewing
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
+ */
+function elementToggleStyle(element, styles) {
+ $.each(styles, function(property, value) {
+ if ($(element).css(property) === value) {
+ $(element).css(property, '');
+ } else {
+ $(element).css(property, value);
+ }
+ });
+}
+
+/**
+ * @param {jQuerySelector|jQuery|Element} element1
+ * @param {jQuerySelector|jQuery|Element} element2
+ * @param {Object} style
+ */
+function elementSwapStyles(element1, element2, style) {
+ for (var name in style) {
+ element1.css(name, element2.css(name));
+ element2.css(name, style[name]);
+ }
+}
/**
* @fileOverview DOM fragment manipulation helper functions
* @author David Neilsen david@panmedia.co.nz
@@ -34158,15 +34140,44 @@ function selectionToggleBlockStyle(styles, limit) {
// Only apply block style if the limit element is a block
if (limit.css('display') !== 'inline') {
// Wrap the HTML inside the limit element
- this.wrapInner(limit, 'div');
+ elementWrapInner(limit, 'div');
// Set the parent to the wrapper
parent = limit.children().first();
}
}
// Apply the style to the parent
- this.toggleStyle(parent, styles);
+ elementToggleStyle(parent, styles);
}, null, this);
}
+
+/**
+ * Removes all ranges from a selection that are not contained within the
+ * supplied element.
+ *
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element
+ * @param {RangySelection} [selection]
+ */
+function selectionConstrain(element, selection) {
+ element = $(element)[0];
+ selection = selection || (rangy) ? rangy.getSelection() : null;
+
+ if (!selection) {
+ return;
+ }
+
+ var commonAncestor;
+ $(selection.getAllRanges()).each(function(i, range){
+ if (this.commonAncestorContainer.nodeType === 3) {
+ commonAncestor = $(range.commonAncestorContainer).parent()[0];
+ } else {
+ commonAncestor = range.commonAncestorContainer;
+ }
+ if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
+ selection.removeRange(range);
+ }
+ });
+}
/**
* @fileOverview String helper functions
* @author David Neilsen - david@panmedia.co.nz
1,040 packages/raptor.0deps.nc.min.js
View
520 additions, 520 deletions not shown
BIN  packages/raptor.0deps.nc.min.js.gz
View
Binary file not shown
270 packages/raptor.debug.js
View
@@ -1,5 +1,5 @@
/*!
-VERSION: 0.0.24
+VERSION: 0.0.25
For license information, see http://www.raptor-editor.com/license
*/
/**
@@ -25650,31 +25650,6 @@ selectionReplace('&lt;p&gt;Replace selection with this&lt;/p&gt;');</pre>
*/
var domTools = {
- /**
- * Removes all ranges from a selection that are not contained within the
- * supplied element.
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element
- * @param {RangySelection} [selection]
- */
- constrainSelection: function(element, selection) {
- element = $(element)[0];
- selection = selection || rangy.getSelection();
-
- var commonAncestor;
- $(selection.getAllRanges()).each(function(i, range){
- if (this.commonAncestorContainer.nodeType === 3) {
- commonAncestor = $(range.commonAncestorContainer).parent()[0];
- } else {
- commonAncestor = range.commonAncestorContainer;
- }
- if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
- selection.removeRange(range);
- }
- });
- },
-
unwrapParentTag: function(tag) {
selectionGetElements().each(function(){
if ($(this).is(tag)) {
@@ -25756,22 +25731,6 @@ var domTools = {
},
/**
- * Wraps the inner content of an element with a tag
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
- * @param {String} tag The wrapper tag name
- */
- wrapInner: function(element, tag) {
- selectionSave();
- $(element).each(function() {
- var wrapper = $('<' + tag + '/>').html($(this).html());
- element.html(wrapper);
- });
- selectionRestore();
- },
-
- /**
*
*/
inverseWrapWithTagClass: function(tag1, class1, tag2, class2) {
@@ -25802,34 +25761,6 @@ var domTools = {
});
selectionRestore();
- },
-
- /**
- * FIXME: this function needs reviewing
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
- */
- toggleStyle: function(element, styles) {
- $.each(styles, function(property, value) {
- if ($(element).css(property) === value) {
- $(element).css(property, '');
- } else {
- $(element).css(property, value);
- }
- });
- },
-
- /**
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element1
- * @param {jQuerySelector|jQuery|Element} element2
- * @param {Object} style
- */
- swapStyles: function(element1, element2, style) {
- for (var name in style) {
- element1.css(name, element2.css(name));
- element2.css(name, style[name]);
- }
}
};
@@ -26011,7 +25942,6 @@ if (debugLevel >= MID) {
if (debugLevel >= MAX) {
info('TODO: dont fire events when editing is disabled');
info('TODO: make a way to disable all buttons then selectivity enable ones');
- info('TODO: locale switches should affect all instances');
info('FIXME: remove editor instance from instances array on destroy');
info('FIXME: updateTagTree click bindings');
info('FIXME: updateTagTree should filter out duplicates');
@@ -26227,6 +26157,10 @@ $.widget('ui.editor',
// Stores the previous selection
this.previousSelection = null;
+ // Set the initial locale
+ var locale = this.persist('locale') || this.options.initialLocale;
+ setLocale(locale);
+
// Fire the ready event
this.ready = true;
this.fire('ready');
@@ -26369,7 +26303,7 @@ $.widget('ui.editor',
if (!this[i]) {
this[i] = (function(i) {
return function() {
- this.options.domTools.constrainSelection(this.getElement());
+ selectionConstrain(this.getElement());
var html = this.getHtml();
var result = this.options.domTools[i].apply(this.options.domTools, arguments);
if (html !== this.getHtml()) {
@@ -26556,22 +26490,26 @@ $.widget('ui.editor',
if (node.nodeType === 3) {
// If nodes common parent is a text node, then use its parent
element = $(node).parent();
- // } else if(this.rangeEmptyTag(range)) {
- // element = $(this.domFragmentToHtml(range.cloneContents()));
} else {
// Or else use the node
element = $(node);
}
+ // Ensure the element is the editing element or a child of the editing element
+ if (!editor.isRoot(element) && !$.contains(editor.getElement().get(0), element.get(0))) {
+ element = editor.getElement();
+ }
+
var list = [];
lists.push(list);
- // Loop untill we get to the root element, or the body tag
+ // Loop until we get to the root element, or the body tag
while (element[0] && !editor.isRoot(element) && element[0].tagName.toLowerCase() !== 'body') {
// Add the node to the list
list.push(element);
element = element.parent();
}
list.reverse();
+
if (title) title += ' | ';
title += this.getTemplate('root');
for (var j = 0; j < list.length; j++) {
@@ -27623,6 +27561,9 @@ $.extend($.ui.editor,
elementDefaultDisplay: elementDefaultDisplay,
elementIsValid: elementIsValid,
elementGetStyles: elementGetStyles,
+ elementWrapInner: elementWrapInner,
+ elementToggleStyle: elementToggleStyle,
+ elementSwapStyles: elementSwapStyles,
fragmentToHtml: fragmentToHtml,
fragmentInsertBefore: fragmentInsertBefore,
rangeExpandToParent: rangeExpandToParent,
@@ -27648,99 +27589,102 @@ $.extend($.ui.editor,
stringStripTags: stringStripTags,
// </expose>
- /** @namespace Default options for the jQuery UI Editor */
+ /** @namespace Default options for Raptor Editor */
defaults: {
- /** @type Object Plugins option overrides */
+ /** @type {Object} Plugins option overrides */
plugins: {},
- /** @type Object UI option overrides */
+ /** @type {Object} UI option overrides */
ui: {},
- /** @type Object Default events to bind */
+ /** @type {Object} Default events to bind */
bind: {},
- /** @type Object */
+ /**
+ * @deprecated
+ * @type {Object}
+ */
domTools: domTools,
/**
- * @type String Namespace used to persistence to prevent conflicting
- * stored values
+ * @type {String} Namespace used to persistence to prevent conflicting
+ * stored values.
*/
namespace: null,
/**
- * @type boolean Switch to indicated that some events should be
- * automatically applied to all editors that are 'unified'
+ * @type {Boolean} Switch to indicated that some events should be
+ * automatically applied to all editors that are unified.
*/
unify: true,
- /** @type boolean Switch to indicate weather or not to stored persistent
- values, if set to false the persist function will always return null */
+ /**
+ * @type {Boolean} Switch to indicate weather or not to stored persistent
+ * values, if set to false the persist function will always return null.
+ */
persistence: true,
- /** @type String The name to store persistent values under */
+ /** @type {String} The name to store persistent values under */
persistenceName: 'uiEditor',
/**
- * Switch to indicate weather or not to a warning should pop up when the
- * user navigates aways from the page and there are unsaved changes
- * @type boolean
+ * @type {Boolean} Switch to indicate weather or not to a warning should
+ * pop up when the user navigates away from the page when unsaved changes
+ * exist.
*/
unloadWarning: true,
/**
- * @type boolean Switch to automatically enabled editing on the element
+ * @type {Boolean} Switch to automatically enabled editing on the element.
*/
autoEnable: false,
/**
- * @type {jQuerySelector} Only enable editing on certian parts of the element
+ * @type {Selector} Only enable editing on certain parts of the element.
*/
partialEdit: false,
/**
- * Switch to specify if the editor should automatically enable all
- * plugins, if set to false, only the plugins specified in the 'plugins'
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all plugins, if set to false, only the plugins specified in
+ * the {@link $.ui.editor.defaults.plugins} option object will be enabled.
*/
enablePlugins: true,
/**
- * @type String[] An array of explicitly disabled plugins
+ * @type {String[]} An array of explicitly disabled plugins.
*/
disabledPlugins: [],
/**
- * @type String[] And array of arrays denoting the order and grouping of UI elements in the toolbar
+ * @type {String[]} And array of arrays denoting the order and grouping
+ * of UI elements in the toolbar.
*/
uiOrder: null,
/**
- * Switch to specify if the editor should automatically enable all UI,
- * if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all UI, if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
+ * option object will be enabled.
*/
enableUi: true,
/**
- * An array of explicitly disabled UI elements
- * @type String[]
+ * @type {String[]} An array of explicitly disabled UI elements.
*/
disabledUi: [],
/**
- * Default message options
- * @type Object
+ * @type {Object} Default message options.
*/
message: {
delay: 5000
},
/**
- * @type String[] A list of styles that will be copied from a replaced textarea and applied to the editor replacement element
+ * @type {String[]} A list of styles that will be copied from a replaced
+ * textarea and applied to the editor replacement element.
*/
replaceStyle: [
'display', 'position', 'float', 'width',
@@ -27748,17 +27692,10 @@ $.extend($.ui.editor,
'margin-left', 'margin-right', 'margin-top', 'margin-bottom'
],
- /**
- *
- * @type String
- */
+ /** @type {String} The base class name to use on elements created by the editor. */
baseClass: 'ui-editor',
- /**
- * CSS class prefix that is prepended to inserted elements classes.
- * <pre>"cms-bold"</pre>
- * @type String
- */
+ /** @type {String} CSS class prefix that is prepended to inserted elements classes. */
cssPrefix: 'cms-',
/** @type {Boolean} True if the editor should be draggable. */
@@ -27774,7 +27711,14 @@ $.extend($.ui.editor,
* @type {String} Applied to elements that should not be stripped during
* normal use, but do not belong in the final content.
*/
- supplementaryClass: 'supplementary-element-class'
+ supplementaryClass: 'supplementary-element-class',
+
+ /**
+ * @type {String} Locale to use by default. If
+ * {@link $.ui.editor.options.persistence} is set to true and the user has
+ * changed the locale, then the user's locale choice will be used.
+ */
+ initialLocale: 'en'
},
/** @property {Object} events Events added via $.ui.editor.bind */
@@ -29553,7 +29497,7 @@ $.ui.editor.registerPlugin('emptyElement', /** @lends $.editor.plugin.emptyEleme
* @see $.ui.editor.defaultPlugin#init
*/
init: function(editor, options) {
- this.bind('change', this.change)
+ this.bind('change', this.change);
},
change: function() {
@@ -29879,11 +29823,6 @@ $.ui.editor.registerUi({
*/
init: function(editor, options) {
var ui = this;
- var locale = this.persist('locale');
- if (locale) {
- // @todo Move this to the global scope
- setLocale(locale);
- }
var menu = $('<select autocomplete="off" name="i18n"/>');
@@ -29896,7 +29835,7 @@ $.ui.editor.registerUi({
}
menu.append(option);
- };
+ }
return editor.uiSelectMenu({
title: _('Change Language'),
@@ -31893,7 +31832,7 @@ $.ui.editor.registerPlugin('list', /** @lends $.editor.plugin.list.prototype */
* @param {string} listType One of ul or ol.
*/
wrapList: function(listType) {
- this.editor.constrainSelection(this.editor.getElement());
+ selectionConstrain(this.editor.getElement());
if ($.trim(selectionGetHtml()) === '') {
selectionSelectInner(selectionGetElements());
}
@@ -32125,7 +32064,7 @@ $.ui.editor.registerUi({
}
this.ui.button.find('.ui-button-icon-primary').css({
- 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.24?' + query.join('&') + ')'
+ 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.25?' + query.join('&') + ')'
});
}
});
@@ -33427,8 +33366,8 @@ $.ui.editor.registerUi({
* Replace selection if the selected element parent or the selected element is the editing element,
* instead of splitting the editing element.
*/
- if (selectedElementParent === editingElement
- || selectionGetElements()[0] === editingElement) {
+ if (selectedElementParent === editingElement ||
+ selectionGetElements()[0] === editingElement) {
selectionReplace(replacementHtml);
} else {
selectionReplaceWithinValidTags(replacementHtml, this.validParents);
@@ -33868,6 +33807,48 @@ function elementGetStyles(element) {
}
return result;
}
+
+/**
+ * Wraps the inner content of an element with a tag
+ *
+ * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
+ * @param {String} tag The wrapper tag name
+ */
+function elementWrapInner(element, tag) {
+ selectionSave();
+ $(element).each(function() {
+ var wrapper = $('<' + tag + '/>').html($(this).html());
+ element.html(wrapper);
+ });
+ selectionRestore();
+}
+
+/**
+ * FIXME: this function needs reviewing
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
+ */
+function elementToggleStyle(element, styles) {
+ $.each(styles, function(property, value) {
+ if ($(element).css(property) === value) {
+ $(element).css(property, '');
+ } else {
+ $(element).css(property, value);
+ }
+ });
+}
+
+/**
+ * @param {jQuerySelector|jQuery|Element} element1
+ * @param {jQuerySelector|jQuery|Element} element2
+ * @param {Object} style
+ */
+function elementSwapStyles(element1, element2, style) {
+ for (var name in style) {
+ element1.css(name, element2.css(name));
+ element2.css(name, style[name]);
+ }
+}
/**
* @fileOverview DOM fragment manipulation helper functions
* @author David Neilsen david@panmedia.co.nz
@@ -34379,15 +34360,44 @@ function selectionToggleBlockStyle(styles, limit) {
// Only apply block style if the limit element is a block
if (limit.css('display') !== 'inline') {
// Wrap the HTML inside the limit element
- this.wrapInner(limit, 'div');
+ elementWrapInner(limit, 'div');
// Set the parent to the wrapper
parent = limit.children().first();
}
}
// Apply the style to the parent
- this.toggleStyle(parent, styles);
+ elementToggleStyle(parent, styles);
}, null, this);
}
+
+/**
+ * Removes all ranges from a selection that are not contained within the
+ * supplied element.
+ *
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element
+ * @param {RangySelection} [selection]
+ */
+function selectionConstrain(element, selection) {
+ element = $(element)[0];
+ selection = selection || (rangy) ? rangy.getSelection() : null;
+
+ if (!selection) {
+ return;
+ }
+
+ var commonAncestor;
+ $(selection.getAllRanges()).each(function(i, range){
+ if (this.commonAncestorContainer.nodeType === 3) {
+ commonAncestor = $(range.commonAncestorContainer).parent()[0];
+ } else {
+ commonAncestor = range.commonAncestorContainer;
+ }
+ if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
+ selection.removeRange(range);
+ }
+ });
+}
/**
* @fileOverview String helper functions
* @author David Neilsen - david@panmedia.co.nz
270 packages/raptor.debug.min.js
View
@@ -1,5 +1,5 @@
/*!
-VERSION: 0.0.24
+VERSION: 0.0.25
For license information, see http://www.raptor-editor.com/license
*/
/**
@@ -25650,31 +25650,6 @@ selectionReplace('&lt;p&gt;Replace selection with this&lt;/p&gt;');</pre>
*/
var domTools = {
- /**
- * Removes all ranges from a selection that are not contained within the
- * supplied element.
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element
- * @param {RangySelection} [selection]
- */
- constrainSelection: function(element, selection) {
- element = $(element)[0];
- selection = selection || rangy.getSelection();
-
- var commonAncestor;
- $(selection.getAllRanges()).each(function(i, range){
- if (this.commonAncestorContainer.nodeType === 3) {
- commonAncestor = $(range.commonAncestorContainer).parent()[0];
- } else {
- commonAncestor = range.commonAncestorContainer;
- }
- if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
- selection.removeRange(range);
- }
- });
- },
-
unwrapParentTag: function(tag) {
selectionGetElements().each(function(){
if ($(this).is(tag)) {
@@ -25756,22 +25731,6 @@ var domTools = {
},
/**
- * Wraps the inner content of an element with a tag
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
- * @param {String} tag The wrapper tag name
- */
- wrapInner: function(element, tag) {
- selectionSave();
- $(element).each(function() {
- var wrapper = $('<' + tag + '/>').html($(this).html());
- element.html(wrapper);
- });
- selectionRestore();
- },
-
- /**
*
*/
inverseWrapWithTagClass: function(tag1, class1, tag2, class2) {
@@ -25802,34 +25761,6 @@ var domTools = {
});
selectionRestore();
- },
-
- /**
- * FIXME: this function needs reviewing
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
- */
- toggleStyle: function(element, styles) {
- $.each(styles, function(property, value) {
- if ($(element).css(property) === value) {
- $(element).css(property, '');
- } else {
- $(element).css(property, value);
- }
- });
- },
-
- /**
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element1
- * @param {jQuerySelector|jQuery|Element} element2
- * @param {Object} style
- */
- swapStyles: function(element1, element2, style) {
- for (var name in style) {
- element1.css(name, element2.css(name));
- element2.css(name, style[name]);
- }
}
};
@@ -26011,7 +25942,6 @@ if (debugLevel >= MID) {
if (debugLevel >= MAX) {
info('TODO: dont fire events when editing is disabled');
info('TODO: make a way to disable all buttons then selectivity enable ones');
- info('TODO: locale switches should affect all instances');
info('FIXME: remove editor instance from instances array on destroy');
info('FIXME: updateTagTree click bindings');
info('FIXME: updateTagTree should filter out duplicates');
@@ -26227,6 +26157,10 @@ $.widget('ui.editor',
// Stores the previous selection
this.previousSelection = null;
+ // Set the initial locale
+ var locale = this.persist('locale') || this.options.initialLocale;
+ setLocale(locale);
+
// Fire the ready event
this.ready = true;
this.fire('ready');
@@ -26369,7 +26303,7 @@ $.widget('ui.editor',
if (!this[i]) {
this[i] = (function(i) {
return function() {
- this.options.domTools.constrainSelection(this.getElement());
+ selectionConstrain(this.getElement());
var html = this.getHtml();
var result = this.options.domTools[i].apply(this.options.domTools, arguments);
if (html !== this.getHtml()) {
@@ -26556,22 +26490,26 @@ $.widget('ui.editor',
if (node.nodeType === 3) {
// If nodes common parent is a text node, then use its parent
element = $(node).parent();
- // } else if(this.rangeEmptyTag(range)) {
- // element = $(this.domFragmentToHtml(range.cloneContents()));
} else {
// Or else use the node
element = $(node);
}
+ // Ensure the element is the editing element or a child of the editing element
+ if (!editor.isRoot(element) && !$.contains(editor.getElement().get(0), element.get(0))) {
+ element = editor.getElement();
+ }
+
var list = [];
lists.push(list);
- // Loop untill we get to the root element, or the body tag
+ // Loop until we get to the root element, or the body tag
while (element[0] && !editor.isRoot(element) && element[0].tagName.toLowerCase() !== 'body') {
// Add the node to the list
list.push(element);
element = element.parent();
}
list.reverse();
+
if (title) title += ' | ';
title += this.getTemplate('root');
for (var j = 0; j < list.length; j++) {
@@ -27623,6 +27561,9 @@ $.extend($.ui.editor,
elementDefaultDisplay: elementDefaultDisplay,
elementIsValid: elementIsValid,
elementGetStyles: elementGetStyles,
+ elementWrapInner: elementWrapInner,
+ elementToggleStyle: elementToggleStyle,
+ elementSwapStyles: elementSwapStyles,
fragmentToHtml: fragmentToHtml,
fragmentInsertBefore: fragmentInsertBefore,
rangeExpandToParent: rangeExpandToParent,
@@ -27648,99 +27589,102 @@ $.extend($.ui.editor,
stringStripTags: stringStripTags,
// </expose>
- /** @namespace Default options for the jQuery UI Editor */
+ /** @namespace Default options for Raptor Editor */
defaults: {
- /** @type Object Plugins option overrides */
+ /** @type {Object} Plugins option overrides */
plugins: {},
- /** @type Object UI option overrides */
+ /** @type {Object} UI option overrides */
ui: {},
- /** @type Object Default events to bind */
+ /** @type {Object} Default events to bind */
bind: {},
- /** @type Object */
+ /**
+ * @deprecated
+ * @type {Object}
+ */
domTools: domTools,
/**
- * @type String Namespace used to persistence to prevent conflicting
- * stored values
+ * @type {String} Namespace used to persistence to prevent conflicting
+ * stored values.
*/
namespace: null,
/**
- * @type boolean Switch to indicated that some events should be
- * automatically applied to all editors that are 'unified'
+ * @type {Boolean} Switch to indicated that some events should be
+ * automatically applied to all editors that are unified.
*/
unify: true,
- /** @type boolean Switch to indicate weather or not to stored persistent
- values, if set to false the persist function will always return null */
+ /**
+ * @type {Boolean} Switch to indicate weather or not to stored persistent
+ * values, if set to false the persist function will always return null.
+ */
persistence: true,
- /** @type String The name to store persistent values under */
+ /** @type {String} The name to store persistent values under */
persistenceName: 'uiEditor',
/**
- * Switch to indicate weather or not to a warning should pop up when the
- * user navigates aways from the page and there are unsaved changes
- * @type boolean
+ * @type {Boolean} Switch to indicate weather or not to a warning should
+ * pop up when the user navigates away from the page when unsaved changes
+ * exist.
*/
unloadWarning: true,
/**
- * @type boolean Switch to automatically enabled editing on the element
+ * @type {Boolean} Switch to automatically enabled editing on the element.
*/
autoEnable: false,
/**
- * @type {jQuerySelector} Only enable editing on certian parts of the element
+ * @type {Selector} Only enable editing on certain parts of the element.
*/
partialEdit: false,
/**
- * Switch to specify if the editor should automatically enable all
- * plugins, if set to false, only the plugins specified in the 'plugins'
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all plugins, if set to false, only the plugins specified in
+ * the {@link $.ui.editor.defaults.plugins} option object will be enabled.
*/
enablePlugins: true,
/**
- * @type String[] An array of explicitly disabled plugins
+ * @type {String[]} An array of explicitly disabled plugins.
*/
disabledPlugins: [],
/**
- * @type String[] And array of arrays denoting the order and grouping of UI elements in the toolbar
+ * @type {String[]} And array of arrays denoting the order and grouping
+ * of UI elements in the toolbar.
*/
uiOrder: null,
/**
- * Switch to specify if the editor should automatically enable all UI,
- * if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all UI, if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
+ * option object will be enabled.
*/
enableUi: true,
/**
- * An array of explicitly disabled UI elements
- * @type String[]
+ * @type {String[]} An array of explicitly disabled UI elements.
*/
disabledUi: [],
/**
- * Default message options
- * @type Object
+ * @type {Object} Default message options.
*/
message: {
delay: 5000
},
/**
- * @type String[] A list of styles that will be copied from a replaced textarea and applied to the editor replacement element
+ * @type {String[]} A list of styles that will be copied from a replaced
+ * textarea and applied to the editor replacement element.
*/
replaceStyle: [
'display', 'position', 'float', 'width',
@@ -27748,17 +27692,10 @@ $.extend($.ui.editor,
'margin-left', 'margin-right', 'margin-top', 'margin-bottom'
],
- /**
- *
- * @type String
- */
+ /** @type {String} The base class name to use on elements created by the editor. */
baseClass: 'ui-editor',
- /**
- * CSS class prefix that is prepended to inserted elements classes.
- * <pre>"cms-bold"</pre>
- * @type String
- */
+ /** @type {String} CSS class prefix that is prepended to inserted elements classes. */
cssPrefix: 'cms-',
/** @type {Boolean} True if the editor should be draggable. */
@@ -27774,7 +27711,14 @@ $.extend($.ui.editor,
* @type {String} Applied to elements that should not be stripped during
* normal use, but do not belong in the final content.
*/
- supplementaryClass: 'supplementary-element-class'
+ supplementaryClass: 'supplementary-element-class',
+
+ /**
+ * @type {String} Locale to use by default. If
+ * {@link $.ui.editor.options.persistence} is set to true and the user has
+ * changed the locale, then the user's locale choice will be used.
+ */
+ initialLocale: 'en'
},
/** @property {Object} events Events added via $.ui.editor.bind */
@@ -29553,7 +29497,7 @@ $.ui.editor.registerPlugin('emptyElement', /** @lends $.editor.plugin.emptyEleme
* @see $.ui.editor.defaultPlugin#init
*/
init: function(editor, options) {
- this.bind('change', this.change)
+ this.bind('change', this.change);
},
change: function() {
@@ -29879,11 +29823,6 @@ $.ui.editor.registerUi({
*/
init: function(editor, options) {
var ui = this;
- var locale = this.persist('locale');
- if (locale) {
- // @todo Move this to the global scope
- setLocale(locale);
- }
var menu = $('<select autocomplete="off" name="i18n"/>');
@@ -29896,7 +29835,7 @@ $.ui.editor.registerUi({
}
menu.append(option);
- };
+ }
return editor.uiSelectMenu({
title: _('Change Language'),
@@ -31893,7 +31832,7 @@ $.ui.editor.registerPlugin('list', /** @lends $.editor.plugin.list.prototype */
* @param {string} listType One of ul or ol.
*/
wrapList: function(listType) {
- this.editor.constrainSelection(this.editor.getElement());
+ selectionConstrain(this.editor.getElement());
if ($.trim(selectionGetHtml()) === '') {
selectionSelectInner(selectionGetElements());
}
@@ -32125,7 +32064,7 @@ $.ui.editor.registerUi({
}
this.ui.button.find('.ui-button-icon-primary').css({
- 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.24?' + query.join('&') + ')'
+ 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.25?' + query.join('&') + ')'
});
}
});
@@ -33427,8 +33366,8 @@ $.ui.editor.registerUi({
* Replace selection if the selected element parent or the selected element is the editing element,
* instead of splitting the editing element.
*/
- if (selectedElementParent === editingElement
- || selectionGetElements()[0] === editingElement) {
+ if (selectedElementParent === editingElement ||
+ selectionGetElements()[0] === editingElement) {
selectionReplace(replacementHtml);
} else {
selectionReplaceWithinValidTags(replacementHtml, this.validParents);
@@ -33868,6 +33807,48 @@ function elementGetStyles(element) {
}
return result;
}
+
+/**
+ * Wraps the inner content of an element with a tag
+ *
+ * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
+ * @param {String} tag The wrapper tag name
+ */
+function elementWrapInner(element, tag) {
+ selectionSave();
+ $(element).each(function() {
+ var wrapper = $('<' + tag + '/>').html($(this).html());
+ element.html(wrapper);
+ });
+ selectionRestore();
+}
+
+/**
+ * FIXME: this function needs reviewing
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
+ */
+function elementToggleStyle(element, styles) {
+ $.each(styles, function(property, value) {
+ if ($(element).css(property) === value) {
+ $(element).css(property, '');
+ } else {
+ $(element).css(property, value);
+ }
+ });
+}
+
+/**
+ * @param {jQuerySelector|jQuery|Element} element1
+ * @param {jQuerySelector|jQuery|Element} element2
+ * @param {Object} style
+ */
+function elementSwapStyles(element1, element2, style) {
+ for (var name in style) {
+ element1.css(name, element2.css(name));
+ element2.css(name, style[name]);
+ }
+}
/**
* @fileOverview DOM fragment manipulation helper functions
* @author David Neilsen david@panmedia.co.nz
@@ -34379,15 +34360,44 @@ function selectionToggleBlockStyle(styles, limit) {
// Only apply block style if the limit element is a block
if (limit.css('display') !== 'inline') {
// Wrap the HTML inside the limit element
- this.wrapInner(limit, 'div');
+ elementWrapInner(limit, 'div');
// Set the parent to the wrapper
parent = limit.children().first();
}
}
// Apply the style to the parent
- this.toggleStyle(parent, styles);
+ elementToggleStyle(parent, styles);
}, null, this);
}
+
+/**
+ * Removes all ranges from a selection that are not contained within the
+ * supplied element.
+ *
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element
+ * @param {RangySelection} [selection]
+ */
+function selectionConstrain(element, selection) {
+ element = $(element)[0];
+ selection = selection || (rangy) ? rangy.getSelection() : null;
+
+ if (!selection) {
+ return;
+ }
+
+ var commonAncestor;
+ $(selection.getAllRanges()).each(function(i, range){
+ if (this.commonAncestorContainer.nodeType === 3) {
+ commonAncestor = $(range.commonAncestorContainer).parent()[0];
+ } else {
+ commonAncestor = range.commonAncestorContainer;
+ }
+ if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
+ selection.removeRange(range);
+ }
+ });
+}
/**
* @fileOverview String helper functions
* @author David Neilsen - david@panmedia.co.nz
BIN  packages/raptor.debug.min.js.gz
View
Binary file not shown
269 packages/raptor.js
View
@@ -1,5 +1,5 @@
/*!
-VERSION: 0.0.24
+VERSION: 0.0.25
For license information, see http://www.raptor-editor.com/license
*/
(function($, window, rangy, undefined) {/**
@@ -146,31 +146,6 @@ selectionReplace('&lt;p&gt;Replace selection with this&lt;/p&gt;');</pre>
*/
var domTools = {
- /**
- * Removes all ranges from a selection that are not contained within the
- * supplied element.
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element
- * @param {RangySelection} [selection]
- */
- constrainSelection: function(element, selection) {
- element = $(element)[0];
- selection = selection || rangy.getSelection();
-
- var commonAncestor;
- $(selection.getAllRanges()).each(function(i, range){
- if (this.commonAncestorContainer.nodeType === 3) {
- commonAncestor = $(range.commonAncestorContainer).parent()[0];
- } else {
- commonAncestor = range.commonAncestorContainer;
- }
- if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
- selection.removeRange(range);
- }
- });
- },
-
unwrapParentTag: function(tag) {
selectionGetElements().each(function(){
if ($(this).is(tag)) {
@@ -252,22 +227,6 @@ var domTools = {
},
/**
- * Wraps the inner content of an element with a tag
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
- * @param {String} tag The wrapper tag name
- */
- wrapInner: function(element, tag) {
- selectionSave();
- $(element).each(function() {
- var wrapper = $('<' + tag + '/>').html($(this).html());
- element.html(wrapper);
- });
- selectionRestore();
- },
-
- /**
*
*/
inverseWrapWithTagClass: function(tag1, class1, tag2, class2) {
@@ -298,34 +257,6 @@ var domTools = {
});
selectionRestore();
- },
-
- /**
- * FIXME: this function needs reviewing
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
- */
- toggleStyle: function(element, styles) {
- $.each(styles, function(property, value) {
- if ($(element).css(property) === value) {
- $(element).css(property, '');
- } else {
- $(element).css(property, value);
- }
- });
- },
-
- /**
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element1
- * @param {jQuerySelector|jQuery|Element} element2
- * @param {Object} style
- */
- swapStyles: function(element1, element2, style) {
- for (var name in style) {
- element1.css(name, element2.css(name));
- element2.css(name, style[name]);
- }
}
};
@@ -571,6 +502,10 @@ $.widget('ui.editor',
// Stores the previous selection
this.previousSelection = null;
+ // Set the initial locale
+ var locale = this.persist('locale') || this.options.initialLocale;
+ setLocale(locale);
+
// Fire the ready event
this.ready = true;
this.fire('ready');
@@ -711,7 +646,7 @@ $.widget('ui.editor',
if (!this[i]) {
this[i] = (function(i) {
return function() {
- this.options.domTools.constrainSelection(this.getElement());
+ selectionConstrain(this.getElement());
var html = this.getHtml();
var result = this.options.domTools[i].apply(this.options.domTools, arguments);
if (html !== this.getHtml()) {
@@ -894,22 +829,26 @@ $.widget('ui.editor',
if (node.nodeType === 3) {
// If nodes common parent is a text node, then use its parent
element = $(node).parent();
- // } else if(this.rangeEmptyTag(range)) {
- // element = $(this.domFragmentToHtml(range.cloneContents()));
} else {
// Or else use the node
element = $(node);
}
+ // Ensure the element is the editing element or a child of the editing element
+ if (!editor.isRoot(element) && !$.contains(editor.getElement().get(0), element.get(0))) {
+ element = editor.getElement();
+ }
+
var list = [];
lists.push(list);
- // Loop untill we get to the root element, or the body tag
+ // Loop until we get to the root element, or the body tag
while (element[0] && !editor.isRoot(element) && element[0].tagName.toLowerCase() !== 'body') {
// Add the node to the list
list.push(element);
element = element.parent();
}
list.reverse();
+
if (title) title += ' | ';
title += this.getTemplate('root');
for (var j = 0; j < list.length; j++) {
@@ -1918,6 +1857,9 @@ $.extend($.ui.editor,
elementDefaultDisplay: elementDefaultDisplay,
elementIsValid: elementIsValid,
elementGetStyles: elementGetStyles,
+ elementWrapInner: elementWrapInner,
+ elementToggleStyle: elementToggleStyle,
+ elementSwapStyles: elementSwapStyles,
fragmentToHtml: fragmentToHtml,
fragmentInsertBefore: fragmentInsertBefore,
rangeExpandToParent: rangeExpandToParent,
@@ -1943,99 +1885,102 @@ $.extend($.ui.editor,
stringStripTags: stringStripTags,
// </expose>
- /** @namespace Default options for the jQuery UI Editor */
+ /** @namespace Default options for Raptor Editor */
defaults: {
- /** @type Object Plugins option overrides */
+ /** @type {Object} Plugins option overrides */
plugins: {},
- /** @type Object UI option overrides */
+ /** @type {Object} UI option overrides */
ui: {},
- /** @type Object Default events to bind */
+ /** @type {Object} Default events to bind */
bind: {},
- /** @type Object */
+ /**
+ * @deprecated
+ * @type {Object}
+ */
domTools: domTools,
/**
- * @type String Namespace used to persistence to prevent conflicting
- * stored values
+ * @type {String} Namespace used to persistence to prevent conflicting
+ * stored values.
*/
namespace: null,
/**
- * @type boolean Switch to indicated that some events should be
- * automatically applied to all editors that are 'unified'
+ * @type {Boolean} Switch to indicated that some events should be
+ * automatically applied to all editors that are unified.
*/
unify: true,
- /** @type boolean Switch to indicate weather or not to stored persistent
- values, if set to false the persist function will always return null */
+ /**
+ * @type {Boolean} Switch to indicate weather or not to stored persistent
+ * values, if set to false the persist function will always return null.
+ */
persistence: true,
- /** @type String The name to store persistent values under */
+ /** @type {String} The name to store persistent values under */
persistenceName: 'uiEditor',
/**
- * Switch to indicate weather or not to a warning should pop up when the
- * user navigates aways from the page and there are unsaved changes
- * @type boolean
+ * @type {Boolean} Switch to indicate weather or not to a warning should
+ * pop up when the user navigates away from the page when unsaved changes
+ * exist.
*/
unloadWarning: true,
/**
- * @type boolean Switch to automatically enabled editing on the element
+ * @type {Boolean} Switch to automatically enabled editing on the element.
*/
autoEnable: false,
/**
- * @type {jQuerySelector} Only enable editing on certian parts of the element
+ * @type {Selector} Only enable editing on certain parts of the element.
*/
partialEdit: false,
/**
- * Switch to specify if the editor should automatically enable all
- * plugins, if set to false, only the plugins specified in the 'plugins'
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all plugins, if set to false, only the plugins specified in
+ * the {@link $.ui.editor.defaults.plugins} option object will be enabled.
*/
enablePlugins: true,
/**
- * @type String[] An array of explicitly disabled plugins
+ * @type {String[]} An array of explicitly disabled plugins.
*/
disabledPlugins: [],
/**
- * @type String[] And array of arrays denoting the order and grouping of UI elements in the toolbar
+ * @type {String[]} And array of arrays denoting the order and grouping
+ * of UI elements in the toolbar.
*/
uiOrder: null,
/**
- * Switch to specify if the editor should automatically enable all UI,
- * if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
- * option object will be enabled
- * @type boolean
+ * @type {Boolean} Switch to specify if the editor should automatically
+ * enable all UI, if set to false, only the UI specified in the {@link $.ui.editor.defaults.ui}
+ * option object will be enabled.
*/
enableUi: true,
/**
- * An array of explicitly disabled UI elements
- * @type String[]
+ * @type {String[]} An array of explicitly disabled UI elements.
*/
disabledUi: [],
/**
- * Default message options
- * @type Object
+ * @type {Object} Default message options.
*/
message: {
delay: 5000
},
/**
- * @type String[] A list of styles that will be copied from a replaced textarea and applied to the editor replacement element
+ * @type {String[]} A list of styles that will be copied from a replaced
+ * textarea and applied to the editor replacement element.
*/
replaceStyle: [
'display', 'position', 'float', 'width',
@@ -2043,17 +1988,10 @@ $.extend($.ui.editor,
'margin-left', 'margin-right', 'margin-top', 'margin-bottom'
],
- /**
- *
- * @type String
- */
+ /** @type {String} The base class name to use on elements created by the editor. */
baseClass: 'ui-editor',
- /**
- * CSS class prefix that is prepended to inserted elements classes.
- * <pre>"cms-bold"</pre>
- * @type String
- */
+ /** @type {String} CSS class prefix that is prepended to inserted elements classes. */
cssPrefix: 'cms-',
/** @type {Boolean} True if the editor should be draggable. */
@@ -2069,7 +2007,14 @@ $.extend($.ui.editor,
* @type {String} Applied to elements that should not be stripped during
* normal use, but do not belong in the final content.
*/
- supplementaryClass: 'supplementary-element-class'
+ supplementaryClass: 'supplementary-element-class',
+
+ /**
+ * @type {String} Locale to use by default. If
+ * {@link $.ui.editor.options.persistence} is set to true and the user has
+ * changed the locale, then the user's locale choice will be used.
+ */
+ initialLocale: 'en'
},
/** @property {Object} events Events added via $.ui.editor.bind */
@@ -3826,7 +3771,7 @@ $.ui.editor.registerPlugin('emptyElement', /** @lends $.editor.plugin.emptyEleme
* @see $.ui.editor.defaultPlugin#init
*/
init: function(editor, options) {
- this.bind('change', this.change)
+ this.bind('change', this.change);
},
change: function() {
@@ -4152,11 +4097,6 @@ $.ui.editor.registerUi({
*/
init: function(editor, options) {
var ui = this;
- var locale = this.persist('locale');
- if (locale) {
- // @todo Move this to the global scope
- setLocale(locale);
- }
var menu = $('<select autocomplete="off" name="i18n"/>');
@@ -4169,7 +4109,7 @@ $.ui.editor.registerUi({
}
menu.append(option);
- };
+ }
return editor.uiSelectMenu({
title: _('Change Language'),
@@ -6166,7 +6106,7 @@ $.ui.editor.registerPlugin('list', /** @lends $.editor.plugin.list.prototype */
* @param {string} listType One of ul or ol.
*/
wrapList: function(listType) {
- this.editor.constrainSelection(this.editor.getElement());
+ selectionConstrain(this.editor.getElement());
if ($.trim(selectionGetHtml()) === '') {
selectionSelectInner(selectionGetElements());
}
@@ -6398,7 +6338,7 @@ $.ui.editor.registerUi({
}
this.ui.button.find('.ui-button-icon-primary').css({
- 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.24?' + query.join('&') + ')'
+ 'background-image': 'url(http://www.jquery-raptor.com/logo/0.0.25?' + query.join('&') + ')'
});
}
});
@@ -7696,8 +7636,8 @@ $.ui.editor.registerUi({
* Replace selection if the selected element parent or the selected element is the editing element,
* instead of splitting the editing element.
*/
- if (selectedElementParent === editingElement
- || selectionGetElements()[0] === editingElement) {
+ if (selectedElementParent === editingElement ||
+ selectionGetElements()[0] === editingElement) {
selectionReplace(replacementHtml);
} else {
selectionReplaceWithinValidTags(replacementHtml, this.validParents);
@@ -8137,6 +8077,48 @@ function elementGetStyles(element) {
}
return result;
}
+
+/**
+ * Wraps the inner content of an element with a tag
+ *
+ * @param {jQuerySelector|jQuery|Element} element The element(s) to wrap
+ * @param {String} tag The wrapper tag name
+ */
+function elementWrapInner(element, tag) {
+ selectionSave();
+ $(element).each(function() {
+ var wrapper = $('<' + tag + '/>').html($(this).html());
+ element.html(wrapper);
+ });
+ selectionRestore();
+}
+
+/**
+ * FIXME: this function needs reviewing
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element The jQuery element to insert
+ */
+function elementToggleStyle(element, styles) {
+ $.each(styles, function(property, value) {
+ if ($(element).css(property) === value) {
+ $(element).css(property, '');
+ } else {
+ $(element).css(property, value);
+ }
+ });
+}
+
+/**
+ * @param {jQuerySelector|jQuery|Element} element1
+ * @param {jQuerySelector|jQuery|Element} element2
+ * @param {Object} style
+ */
+function elementSwapStyles(element1, element2, style) {
+ for (var name in style) {
+ element1.css(name, element2.css(name));
+ element2.css(name, style[name]);
+ }
+}
/**
* @fileOverview DOM fragment manipulation helper functions
* @author David Neilsen david@panmedia.co.nz
@@ -8648,15 +8630,44 @@ function selectionToggleBlockStyle(styles, limit) {
// Only apply block style if the limit element is a block
if (limit.css('display') !== 'inline') {
// Wrap the HTML inside the limit element
- this.wrapInner(limit, 'div');
+ elementWrapInner(limit, 'div');
// Set the parent to the wrapper
parent = limit.children().first();
}
}
// Apply the style to the parent
- this.toggleStyle(parent, styles);
+ elementToggleStyle(parent, styles);
}, null, this);
}
+
+/**
+ * Removes all ranges from a selection that are not contained within the
+ * supplied element.
+ *
+ * @public @static
+ * @param {jQuerySelector|jQuery|Element} element
+ * @param {RangySelection} [selection]
+ */
+function selectionConstrain(element, selection) {
+ element = $(element)[0];
+ selection = selection || (rangy) ? rangy.getSelection() : null;
+
+ if (!selection) {
+ return;
+ }
+
+ var commonAncestor;
+ $(selection.getAllRanges()).each(function(i, range){
+ if (this.commonAncestorContainer.nodeType === 3) {
+ commonAncestor = $(range.commonAncestorContainer).parent()[0];
+ } else {
+ commonAncestor = range.commonAncestorContainer;
+ }
+ if (element !== commonAncestor && !$.contains(element, commonAncestor)) {
+ selection.removeRange(range);
+ }
+ });
+}
/**
* @fileOverview String helper functions
* @author David Neilsen - david@panmedia.co.nz
269 packages/raptor.light.js
View
@@ -1,5 +1,5 @@
/*!
-VERSION: 0.0.24
+VERSION: 0.0.25
For license information, see http://www.raptor-editor.com/license
*/
/**
@@ -4676,31 +4676,6 @@ selectionReplace('&lt;p&gt;Replace selection with this&lt;/p&gt;');</pre>
*/
var domTools = {
- /**
- * Removes all ranges from a selection that are not contained within the
- * supplied element.
- *
- * @public @static
- * @param {jQuerySelector|jQuery|Element} element
- * @param {RangySelection} [selection]
- */
- constrainSelection: function(element, selection) {
- element = $(element)[0];
- selection = selection || rangy.getSelection();
-
- var commonAncestor;
- $(selection.getAllRanges()).each(function(i, range){
- if (this.commonAncestorContainer.nodeType === 3) {
- commonAncestor = $(range.commonAncestorContainer).parent()[0];
- } else {
- commonAncestor = range.commonAncestorContainer;
- }