Merge branch 'MDL-45253-master' of git://github.com/FMCorz/moodle

Conflicts:
	lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
This commit is contained in:
Dan Poltawski 2014-05-06 11:34:17 +08:00
commit 73c2ae4bff
10 changed files with 121 additions and 33 deletions

View File

@ -1103,9 +1103,15 @@ EditorSelection.prototype = {
var editor = this.editor,
stopFn = function(node) {
return editor.contains(node);
// The function getSelectedNodes only returns nodes within the editor, so this test is safe.
return node === editor;
};
// If we do not find at least one match in the editor, no point trying to find them in the selection.
if (!editor.one(selector)) {
return false;
}
selectednodes.each(function(node){
// Check each node, if it doesn't match the tags AND is not within the specified tags then fail this thing.
if (requireall) {
@ -1151,8 +1157,12 @@ EditorSelection.prototype = {
}
if (range.collapsed) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
// We do not want to select all the nodes in the editor if we managed to
// have a collapsed selection directly in the editor.
if (range.commonAncestorContainer !== this.editor.getDOMNode()) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}
}
nodes = range.getNodes();

File diff suppressed because one or more lines are too long

View File

@ -1098,9 +1098,15 @@ EditorSelection.prototype = {
var editor = this.editor,
stopFn = function(node) {
return editor.contains(node);
// The function getSelectedNodes only returns nodes within the editor, so this test is safe.
return node === editor;
};
// If we do not find at least one match in the editor, no point trying to find them in the selection.
if (!editor.one(selector)) {
return false;
}
selectednodes.each(function(node){
// Check each node, if it doesn't match the tags AND is not within the specified tags then fail this thing.
if (requireall) {
@ -1146,8 +1152,12 @@ EditorSelection.prototype = {
}
if (range.collapsed) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
// We do not want to select all the nodes in the editor if we managed to
// have a collapsed selection directly in the editor.
if (range.commonAncestorContainer !== this.editor.getDOMNode()) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}
}
nodes = range.getNodes();

View File

@ -86,6 +86,7 @@ Y.extend(EditorPlugin, Y.Base, {
this._primaryKeyboardShortcut = [];
this._buttonHandlers = [];
this._menuHideHandlers = [];
this._highlightQueue = {};
},
/**
@ -289,6 +290,18 @@ EditorPluginButtons.prototype = {
*/
_primaryKeyboardShortcut: null,
/**
* An list of objects returned by Y.soon().
*
* The keys will be the buttonName of the button, and the value the Y.soon() object.
*
* @property _highlightQueue
* @protected
* @type Object
* @default null
*/
_highlightQueue: null,
/**
* Add a button for this plugin to the toolbar.
*
@ -386,17 +399,23 @@ EditorPluginButtons.prototype = {
// Handle highlighting of the button.
if (config.tags) {
var tagMatchRequiresAll = null;
var tagMatchRequiresAll = false;
if (typeof config.tagMatchRequiresAll === 'boolean') {
tagMatchRequiresAll = config.tagMatchRequiresAll;
}
this._buttonHandlers.push(
host.on('atto:selectionchanged', function(e) {
if (host.selectionFilterMatches(config.tags, e.selectedNodes, tagMatchRequiresAll)) {
this.highlightButtons(config.buttonName);
} else {
this.unHighlightButtons(config.buttonName);
host.on(['atto:selectionchanged', 'change'], function(e) {
if (typeof this._highlightQueue[config.buttonName] !== 'undefined') {
this._highlightQueue[config.buttonName].cancel();
}
// Async the highlighting.
this._highlightQueue[config.buttonName] = Y.soon(Y.bind(function(e) {
if (host.selectionFilterMatches(config.tags, e.selectedNodes, tagMatchRequiresAll)) {
this.highlightButtons(config.buttonName);
} else {
this.unHighlightButtons(config.buttonName);
}
}, this, e));
}, this)
);
}
@ -1101,4 +1120,4 @@ EditorPluginDialogue.prototype = {
Y.Base.mix(Y.M.editor_atto.EditorPlugin, [EditorPluginDialogue]);
}, '@VERSION@', {"requires": ["node", "base", "escape", "event", "event-outside", "handlebars", "event-custom"]});
}, '@VERSION@', {"requires": ["node", "base", "escape", "event", "event-outside", "handlebars", "event-custom", "timers"]});

File diff suppressed because one or more lines are too long

View File

@ -86,6 +86,7 @@ Y.extend(EditorPlugin, Y.Base, {
this._primaryKeyboardShortcut = [];
this._buttonHandlers = [];
this._menuHideHandlers = [];
this._highlightQueue = {};
},
/**
@ -289,6 +290,18 @@ EditorPluginButtons.prototype = {
*/
_primaryKeyboardShortcut: null,
/**
* An list of objects returned by Y.soon().
*
* The keys will be the buttonName of the button, and the value the Y.soon() object.
*
* @property _highlightQueue
* @protected
* @type Object
* @default null
*/
_highlightQueue: null,
/**
* Add a button for this plugin to the toolbar.
*
@ -386,17 +399,23 @@ EditorPluginButtons.prototype = {
// Handle highlighting of the button.
if (config.tags) {
var tagMatchRequiresAll = null;
var tagMatchRequiresAll = false;
if (typeof config.tagMatchRequiresAll === 'boolean') {
tagMatchRequiresAll = config.tagMatchRequiresAll;
}
this._buttonHandlers.push(
host.on('atto:selectionchanged', function(e) {
if (host.selectionFilterMatches(config.tags, e.selectedNodes, tagMatchRequiresAll)) {
this.highlightButtons(config.buttonName);
} else {
this.unHighlightButtons(config.buttonName);
host.on(['atto:selectionchanged', 'change'], function(e) {
if (typeof this._highlightQueue[config.buttonName] !== 'undefined') {
this._highlightQueue[config.buttonName].cancel();
}
// Async the highlighting.
this._highlightQueue[config.buttonName] = Y.soon(Y.bind(function(e) {
if (host.selectionFilterMatches(config.tags, e.selectedNodes, tagMatchRequiresAll)) {
this.highlightButtons(config.buttonName);
} else {
this.unHighlightButtons(config.buttonName);
}
}, this, e));
}, this)
);
}
@ -1097,4 +1116,4 @@ EditorPluginDialogue.prototype = {
Y.Base.mix(Y.M.editor_atto.EditorPlugin, [EditorPluginDialogue]);
}, '@VERSION@', {"requires": ["node", "base", "escape", "event", "event-outside", "handlebars", "event-custom"]});
}, '@VERSION@', {"requires": ["node", "base", "escape", "event", "event-outside", "handlebars", "event-custom", "timers"]});

View File

@ -141,6 +141,18 @@ EditorPluginButtons.prototype = {
*/
_primaryKeyboardShortcut: null,
/**
* An list of objects returned by Y.soon().
*
* The keys will be the buttonName of the button, and the value the Y.soon() object.
*
* @property _highlightQueue
* @protected
* @type Object
* @default null
*/
_highlightQueue: null,
/**
* Add a button for this plugin to the toolbar.
*
@ -238,17 +250,23 @@ EditorPluginButtons.prototype = {
// Handle highlighting of the button.
if (config.tags) {
var tagMatchRequiresAll = null;
var tagMatchRequiresAll = false;
if (typeof config.tagMatchRequiresAll === 'boolean') {
tagMatchRequiresAll = config.tagMatchRequiresAll;
}
this._buttonHandlers.push(
host.on('atto:selectionchanged', function(e) {
if (host.selectionFilterMatches(config.tags, e.selectedNodes, tagMatchRequiresAll)) {
this.highlightButtons(config.buttonName);
} else {
this.unHighlightButtons(config.buttonName);
host.on(['atto:selectionchanged', 'change'], function(e) {
if (typeof this._highlightQueue[config.buttonName] !== 'undefined') {
this._highlightQueue[config.buttonName].cancel();
}
// Async the highlighting.
this._highlightQueue[config.buttonName] = Y.soon(Y.bind(function(e) {
if (host.selectionFilterMatches(config.tags, e.selectedNodes, tagMatchRequiresAll)) {
this.highlightButtons(config.buttonName);
} else {
this.unHighlightButtons(config.buttonName);
}
}, this, e));
}, this)
);
}

View File

@ -84,6 +84,7 @@ Y.extend(EditorPlugin, Y.Base, {
this._primaryKeyboardShortcut = [];
this._buttonHandlers = [];
this._menuHideHandlers = [];
this._highlightQueue = {};
},
/**

View File

@ -212,9 +212,15 @@ EditorSelection.prototype = {
var editor = this.editor,
stopFn = function(node) {
return editor.contains(node);
// The function getSelectedNodes only returns nodes within the editor, so this test is safe.
return node === editor;
};
// If we do not find at least one match in the editor, no point trying to find them in the selection.
if (!editor.one(selector)) {
return false;
}
selectednodes.each(function(node){
// Check each node, if it doesn't match the tags AND is not within the specified tags then fail this thing.
if (requireall) {
@ -260,8 +266,12 @@ EditorSelection.prototype = {
}
if (range.collapsed) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
// We do not want to select all the nodes in the editor if we managed to
// have a collapsed selection directly in the editor.
if (range.commonAncestorContainer !== this.editor.getDOMNode()) {
range = range.cloneRange();
range.selectNode(range.commonAncestorContainer);
}
}
nodes = range.getNodes();

View File

@ -22,7 +22,8 @@
"event",
"event-outside",
"handlebars",
"event-custom"
"event-custom",
"timers"
]
},
"moodle-editor_atto-menu": {