Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // "True if among editable Text nodes that are effectively contained in
- // the active range, there are two that have distinct effective values.
- // Otherwise false."
- return collectAllEffectivelyContainedNodes(getActiveRange(), function(node) {
- return isEditable(node) && node.nodeType == Node.TEXT_NODE;
- }).map(function(node) {
- return getEffectiveValue(node, "fontname");
- }).filter(function(value, i, arr) {
- return arr.slice(0, i).indexOf(value) == -1;
- }).length >= 2;
- // vs.
- var nodes = collectAllEffectivelyContainedNodes(getActiveRange(), function(node) {
- return isEditable(node) && node.nodeType == Node.TEXT_NODE;
- });
- if (!nodes.length) {
- return false;
- }
- var value = getEffectiveValue(nodes[0], "fontname");
- for (var i = 1; i < nodes.length; i++) {
- if (getEffectiveValue(nodes[i], "fontname") != value) {
- return true;
- }
- }
- return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement