mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-08 18:51:12 +02:00
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92488 467b73ca-7a2a-4603-9d3b-597d59a354a9
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
/**
|
|
* $Id: ControlManager.js 999 2009-02-10 17:42:58Z spocke $
|
|
*
|
|
* @author Moxiecode
|
|
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
|
|
*/
|
|
|
|
(function(tinymce) {
|
|
tinymce.CommandManager = function() {
|
|
var execCommands = {}, queryStateCommands = {}, queryValueCommands = {};
|
|
|
|
function add(collection, cmd, func, scope) {
|
|
if (typeof(cmd) == 'string')
|
|
cmd = [cmd];
|
|
|
|
tinymce.each(cmd, function(cmd) {
|
|
collection[cmd.toLowerCase()] = {func : func, scope : scope};
|
|
});
|
|
};
|
|
|
|
tinymce.extend(this, {
|
|
add : function(cmd, func, scope) {
|
|
add(execCommands, cmd, func, scope);
|
|
},
|
|
|
|
addQueryStateHandler : function(cmd, func, scope) {
|
|
add(queryStateCommands, cmd, func, scope);
|
|
},
|
|
|
|
addQueryValueHandler : function(cmd, func, scope) {
|
|
add(queryValueCommands, cmd, func, scope);
|
|
},
|
|
|
|
execCommand : function(scope, cmd, ui, value, args) {
|
|
if (cmd = execCommands[cmd.toLowerCase()]) {
|
|
if (cmd.func.call(scope || cmd.scope, ui, value, args) !== false)
|
|
return true;
|
|
}
|
|
},
|
|
|
|
queryCommandValue : function() {
|
|
if (cmd = queryValueCommands[cmd.toLowerCase()])
|
|
return cmd.func.call(scope || cmd.scope, ui, value, args);
|
|
},
|
|
|
|
queryCommandState : function() {
|
|
if (cmd = queryStateCommands[cmd.toLowerCase()])
|
|
return cmd.func.call(scope || cmd.scope, ui, value, args);
|
|
}
|
|
});
|
|
};
|
|
|
|
tinymce.GlobalCommands = new tinymce.CommandManager();
|
|
})(tinymce); |