rangy-1.2.3.rangy-cssclassapplier.js Maven / Gradle / Ivy
/*
CSS Class Applier module for Rangy.
Adds, removes and toggles CSS classes on Ranges and Selections
Part of Rangy, a cross-browser JavaScript range and selection library
http://code.google.com/p/rangy/
Depends on Rangy core.
Copyright 2012, Tim Down
Licensed under the MIT license.
Version: 1.2.3
Build date: 26 February 2012
*/
rangy.createModule("CssClassApplier",function(i,v){function r(a,b){return a.className&&RegExp("(?:^|\\s)"+b+"(?:\\s|$)").test(a.className)}function s(a,b){if(a.className)r(a,b)||(a.className+=" "+b);else a.className=b}function o(a){return a.split(/\s+/).sort().join(" ")}function w(a,b){return o(a.className)==o(b.className)}function x(a){for(var b=a.parentNode;a.hasChildNodes();)b.insertBefore(a.firstChild,a);b.removeChild(a)}function y(a,b){var c=a.cloneRange();c.selectNodeContents(b);var d=c.intersection(a);
d=d?d.toString():"";c.detach();return d!=""}function z(a){return a.getNodes([3],function(b){return y(a,b)})}function A(a,b){if(a.attributes.length!=b.attributes.length)return false;for(var c=0,d=a.attributes.length,e,f;c0&&j