var tag = commandOptions.tagName;
if (tag && (tag === constants.tagName.OL || tag === constants.tagName.UL)) {
return $.Arte.dom.listSurrounded(nodes, {
singleList: true,
tagName: tag
});
}
var nodesWithStyleValue = $.Arte.dom.closestWithCommandValue(nodes, commandOptions);
return nodesWithStyleValue.length === nodes.length;
};
var getState = function(selectedNodes, commandName, options) {
if (!selectedNodes || !selectedNodes.length) {
return null;
}
var commandConfig = $.Arte.configuration.commands[commandName];
var commandOptions = $.extend({
commandName: commandName,
tagName: commandConfig.tagName,
styleName: commandConfig.styleName,
styleValue: commandConfig.defaultValue ? commandConfig.defaultValue.styleName : null,
className: commandConfig.defaultValue ? commandConfig.defaultValue.className : null
}, options);
return commandConfig.acceptsParams ? getValue(selectedNodes, commandOptions) : isApplied(selectedNodes, commandOptions);
};
var getSelectedNodesState = function(selectedNodes, commandName) {
if (commandName) {
return getState(selectedNodes, commandName);
} else {
var result = {};
$.each($.Arte.configuration.commands, function(name, config) {
if ($.isPlainObject(config) && config.commandType && config.commandType != constants.commandType.other) {
result[name] = getState(selectedNodes, name);
}
});
return result;
}
};