diff --git a/Gruntfile.js b/Gruntfile.js
index 139fb018..94fda317 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -55,6 +55,9 @@ module.exports = function(grunt) {
uglify: {
options: {
+ beautify : {
+ ascii_only : true
+ } ,
preserveComments: false,
banner: '//\n' +
'// <%= pkg.name %> - v<%= pkg.version %>\n' +
@@ -64,7 +67,7 @@ module.exports = function(grunt) {
},
ice: {
files: {
- 'dist/ice.min.js': ['lib/rangy/rangy-core.js', 'src/polyfills.js', 'src/ice.js', 'src/dom.js', 'src/bookmark.js', 'src/selection.js', 'src/icePlugin.js', 'src/icePluginManager.js', 'src/plugins/IceAddTitlePlugin/IceAddTitlePlugin.js', 'src/plugins/IceCopyPastePlugin/IceCopyPastePlugin.js', 'src/plugins/IceSmartQuotesPlugin/IceSmartQuotesPlugin.js', 'src/plugins/IceEmdashPlugin/IceEmdashPlugin.js']
+ 'dist/ice.min.js': ['dist/ice.js']
}
},
icemaster: {
@@ -76,17 +79,17 @@ module.exports = function(grunt) {
'//\n'
},
files: {
- 'ice-master.min.js': ['lib/rangy/rangy-core.js', 'src/polyfills.js', 'src/ice.js', 'src/dom.js', 'src/bookmark.js', 'src/selection.js', 'src/icePlugin.js', 'src/icePluginManager.js', 'src/plugins/IceAddTitlePlugin/IceAddTitlePlugin.js', 'src/plugins/IceCopyPastePlugin/IceCopyPastePlugin.js', 'src/plugins/IceSmartQuotesPlugin/IceSmartQuotesPlugin.js', 'src/plugins/IceEmdashPlugin/IceEmdashPlugin.js']
+ 'ice-master.min.js': ['dist/ice.js']
}
},
tinyice: {
files: {
- 'dist/ice_editor_plugin.js': 'lib/tinymce/jscripts/tiny_mce/plugins/ice/editor_plugin.js'
+ 'dist/ice_editor_plugin.js': 'lib/tinymce/js/tinymce/plugins/ice/plugin.min.js'
}
},
tinysr: {
files: {
- 'dist/sr_editor_plugin.js': 'lib/tinymce/jscripts/tiny_mce/plugins/icesearchreplace/editor_plugin.js'
+ 'dist/sr_editor_plugin.js': 'lib/tinymce/js/tinymce/plugins/icesearchreplace/plugin.min.js'
}
}
},
@@ -125,7 +128,7 @@ module.exports = function(grunt) {
grunt.registerTask('test', ['connect', 'qunit']);
- grunt.registerTask('build', ['clean:build', 'uglify:ice', 'uglify:icemaster', 'concat', 'compress:gz', 'cp', 'compress:zip']);
+ grunt.registerTask('build', ['clean:build', 'concat', 'uglify:ice', 'uglify:icemaster', 'compress:gz', 'cp', 'compress:zip']);
grunt.registerTask('cp', function() {
cpTinyDir('ice');
@@ -136,7 +139,7 @@ module.exports = function(grunt) {
});
var cpTinyDir = function(dir) {
- grunt.file.recurse('lib/tinymce/jscripts/tiny_mce/plugins/' + dir + '/', function(abspath, rootdir, subdir, filename) {
+ grunt.file.recurse('lib/tinymce/js/tinymce/plugins/' + dir + '/', function(abspath, rootdir, subdir, filename) {
grunt.file.copy(rootdir + '/' + (subdir ? subdir + '/' : '') + filename,'dist/tinymce/plugins/' + dir + '/' + (subdir ? subdir + '/' : '') + '/' + filename);
});
};
diff --git a/README.md b/README.md
index dd49b350..e60b71ee 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@
# ice.js
-Ice is a track changes implementation, built in javascript, for anything that is `contenteditable` on the web. Conceived by the CMS Group at The New York Times, ice has been piloting successfully for articles written in the newsroom.
+Ice is a track changes implementation, built in javascript, for anything that is `contenteditable` on the web. Conceived by the CMS Group at The New York Times, ice is powering the editor used for writing articles in the newsroom.
## Demo
-[Check it out!](http://NYTimes.github.com/ice/demo/)
+[Try it](http://NYTimes.github.com/ice/demo/)
## Download
-[v0.4.2](http://nytimes.github.com/ice/downloads/ice_0.4.2.zip)
+[v0.5.0](http://nytimes.github.com/ice/downloads/ice_0.5.0.zip)
## Features
@@ -111,17 +111,22 @@ Additional options:
```
***
-**_Wordpress initialization_**
+## Limitations/Dependencies
- In testing - more to come soon.
+- ice needs to be initialized after the DOM ready event fires.
+- Wordpress support is limited. We need contribution from any willing WordPress developers.
+- Browser support is limited to Firefox (5+) and Webkit browsers, and minimal support for IE8+.
-***
+## Changelog
-## Limitations/Dependencies
+### Master
-- ice needs to be initialized after the DOM ready event fires.
-- ice was originally created for the simple markup behind nytimes.com articles (`p`, `a`, `em`, `strong`). As such, it requires that all text editing takes place in a common root block element, and that there are no other blocks found in the editor. Any type of inline elements are ok, inside of the common root blocks.
-- Unfortunately, we haven't been able to test this across all browsers and versions. We know that it tests well in modern Firefox (5+) and Webkit browsers, and "seems to work" in IE7+. We intend to do more testing and get a better idea about what ice can support across browsers.
+- Fixes bug where Webkit browsers were throwing errors when the letter "v" was pressed.
+
+### 0.5.0
+
+- Fixes cut, copy, paste for Firefox and Webkit browsers.
+- Fixes delete tracking in webkit browsers.
## License
diff --git a/demo/index.html b/demo/index.html
index f92e02da..0fbb962d 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -17,7 +17,7 @@
-
+
@@ -182,7 +182,7 @@
Tinymce Plugin
tinymce.init({
mode: "exact",
elements: "tinymce",
- theme: "advanced",
+ theme: "modern",
plugins: 'ice,icesearchreplace',
theme_advanced_buttons1: "bold,italic,underline,|,bullist,numlist,|,undo,redo,code,|,search,replace,|,ice_togglechanges,ice_toggleshowchanges,iceacceptall,icerejectall,iceaccept,icereject",
theme_advanced_buttons2: "",
diff --git a/demo/js/main.js b/demo/js/main.js
new file mode 100644
index 00000000..e69de29b
diff --git a/demo/js/require-config.js b/demo/js/require-config.js
new file mode 100644
index 00000000..4e7be483
--- /dev/null
+++ b/demo/js/require-config.js
@@ -0,0 +1,66 @@
+var require = {
+ "paths": {
+ "jquery": "http://code.jquery.com/jquery-1.9.1.min",
+ 'tinymce': "tinymce/js/tinymce/tinymce",
+ "tinymce.jquery": "tinymce/js/tinymce/jquery.tinymce.min",
+ // "rangy": "rangy/rangy-core",
+ // "ice": "ice/ice",
+ // "icePluginManager": "ice/icePluginManager",
+ // "IceAddTitlePlugin":'ice/plugins/IceAddTitlePlugin/IceAddTitlePlugin',
+ // "IceCopyPastePlugin":'ice/plugins/IceCopyPastePlugin/IceCopyPastePlugin.js',
+ // "IceEmdashPlugin":'ice/plugins/IceEmdashPlugin/IceEmdashPlugin.js',
+ // "IceSmartQuotesPlugin":'ice/plugins/IceSmartQuotesPlugin/IceSmartQuotesPlugin.js',
+
+ "jquery1.9": "http://code.jquery.com/jquery-1.9.1.min",
+ "jquery-migrate" : "http://code.jquery.com/jquery-migrate-1.0.0",
+ "rangy-core": "../../lib/rangy/rangy-core",
+ "polyfills": "../../src/polyfills",
+ "ice":"../../src/ice",
+ "dom":"../../src/dom",
+ "icePlugin":"../../src/icePlugin",
+ "icePluginManager":"../../src/icePluginManager",
+ "bookmark":"../../src/bookmark",
+ "selection":"../../src/selection",
+ "IceAddTitlePlugin":"../../src/plugins/IceAddTitlePlugin/IceAddTitlePlugin",
+ "IceCopyPastePlugin":"../../src/plugins/IceCopyPastePlugin/IceCopyPastePlugin",
+ "IceEmdashPlugin":"../../src/plugins/IceEmdashPlugin/IceEmdashPlugin",
+ "IceSmartQuotesPlugin":"../../src/plugins/IceSmartQuotesPlugin/IceSmartQuotesPlugin",
+ "tinymce":"../../lib/tinymce/jscripts/tinymce4/tinymce",
+ },
+ "shim": {
+ "jquery1.9": {
+ exports: "$"
+ },
+ "rangy-core": {
+ exports: "window.rangy"
+ },
+ "dom": {
+ deps:['ice'],
+ exports: "dom"
+ },
+ "selection" : {
+ exports: "Selection"
+ },
+ "bookmark": {
+ exports: "Bookmark"
+ },
+ "ice" : {
+ exports: "ice"
+ },
+ "icePluginManager": {deps: ['ice'] },
+ "IceAddTitlePlugin":{ deps: ['icePluginManager']},
+ "IceCopyPastePlugin":{ deps: ['icePluginManager']},
+ "IceEmdashPlugin":{ deps: ['icePluginManager']},
+ "IceSmartQuotesPlugin":{ deps: ['icePluginManager']},
+ "tinymce": {
+ exports: "tinymce",
+ init: function() {
+ this.tinymce.DOM.events.domLoaded = true;
+ return this.tinymce;
+ }
+ },
+ "tinymce.jquery" :{
+ deps: ['jquery']
+ }
+ }
+};
\ No newline at end of file
diff --git a/demo/js/require.js b/demo/js/require.js
new file mode 100644
index 00000000..0de1ec89
--- /dev/null
+++ b/demo/js/require.js
@@ -0,0 +1,36 @@
+/*
+ RequireJS 2.1.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ Available via the MIT or new BSD license.
+ see: http://github.com/jrburke/requirejs for details
+*/
+var requirejs,require,define;
+(function(Z){function H(b){return"[object Function]"===L.call(b)}function I(b){return"[object Array]"===L.call(b)}function y(b,c){if(b){var d;for(d=0;dthis.depCount&&!this.defined){if(H(m)){if(this.events.error&&this.map.isDefine||j.onError!==aa)try{e=i.execCb(c,m,b,e)}catch(d){a=d}else e=i.execCb(c,m,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==
+this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",v(this.error=a)}else e=m;this.exports=e;if(this.map.isDefine&&!this.ignore&&(r[c]=e,j.onResourceLoad))j.onResourceLoad(i,this.map,this.depMaps);x(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=
+!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=n(a.prefix);this.depMaps.push(d);t(d,"defined",u(this,function(e){var m,d;d=this.map.name;var g=this.map.parentMap?this.map.parentMap.name:null,h=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,g,!0)})||""),e=n(a.prefix+"!"+d,this.map.parentMap),t(e,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),
+d=l(p,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else m=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),m.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];F(p,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&x(a.map.id)});v(a)}),m.fromText=u(this,function(e,c){var d=a.name,g=n(d),B=O;c&&(e=c);B&&(O=!1);q(g);s(k.config,b)&&(k.config[d]=k.config[b]);try{j.exec(e)}catch(ca){return v(A("fromtexteval",
+"fromText eval for "+b+" failed: "+ca,ca,[b]))}B&&(O=!0);this.depMaps.push(g);i.completeLoad(d);h([d],m)}),e.load(a.name,h,m,k)}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){T[this.map.id]=this;this.enabling=this.enabled=!0;y(this.depMaps,u(this,function(a,b){var c,e;if("string"===typeof a){a=n(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=l(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;t(a,"defined",u(this,function(a){this.defineDep(b,
+a);this.check()}));this.errback&&t(a,"error",u(this,this.errback))}c=a.id;e=p[c];!s(N,c)&&(e&&!e.enabled)&&i.enable(a,this)}));F(this.pluginMaps,u(this,function(a){var b=l(p,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){y(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:k,contextName:b,registry:p,defined:r,urlFetched:S,defQueue:G,Module:X,makeModuleMap:n,
+nextTick:j.nextTick,onError:v,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e={paths:!0,config:!0,map:!0};F(a,function(a,b){e[b]?"map"===b?(k.map||(k.map={}),Q(k[b],a,!0,!0)):Q(k[b],a,!0):k[b]=a});a.shim&&(F(a.shim,function(a,b){I(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);c[b]=a}),k.shim=c);a.packages&&(y(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,
+location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ea,"")}}),k.pkgs=b);F(p,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=n(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Z,arguments));return b||a.exports&&ba(a.exports)}},makeRequire:function(a,f){function d(e,c,h){var g,k;f.enableBuildCallback&&(c&&H(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(H(c))return v(A("requireargs",
+"Invalid require call"),h);if(a&&s(N,e))return N[e](p[a.id]);if(j.get)return j.get(i,e,a,d);g=n(e,a,!1,!0);g=g.id;return!s(r,g)?v(A("notloaded",'Module name "'+g+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[g]}K();i.nextTick(function(){K();k=q(n(null,a));k.skipMap=f.skipMap;k.init(e,c,h,{enabled:!0});C()});return d}f=f||{};Q(d,{isBrowser:z,toUrl:function(b){var d,f=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==f&&(!("."===g||".."===g)||1h.attachEvent.toString().indexOf("[native code"))&&!W?(O=!0,h.attachEvent("onreadystatechange",b.onScriptLoad)):(h.addEventListener("load",b.onScriptLoad,!1),h.addEventListener("error",
+b.onScriptError,!1)),h.src=d,K=h,C?x.insertBefore(h,C):x.appendChild(h),K=null,h;if(da)try{importScripts(d),b.completeLoad(c)}catch(l){b.onError(A("importscripts","importScripts failed for "+c+" at "+d,l,[c]))}};z&&M(document.getElementsByTagName("script"),function(b){x||(x=b.parentNode);if(J=b.getAttribute("data-main"))return q=J,t.baseUrl||(D=q.split("/"),q=D.pop(),fa=D.length?D.join("/")+"/":"./",t.baseUrl=fa),q=q.replace(ea,""),j.jsExtRegExp.test(q)&&(q=J),t.deps=t.deps?t.deps.concat(q):[q],!0});
+define=function(b,c,d){var h,j;"string"!==typeof b&&(d=c,c=b,b=null);I(c)||(d=c,c=null);!c&&H(d)&&(c=[],d.length&&(d.toString().replace(la,"").replace(ma,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(O){if(!(h=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),h=P;h&&(b||(b=h.getAttribute("data-requiremodule")),j=E[h.getAttribute("data-requirecontext")])}(j?j.defQueue:
+R).push([b,c,d])};define.amd={jQuery:!0};j.exec=function(b){return eval(b)};j(t)}})(this);
\ No newline at end of file
diff --git a/ice-master.min.js b/ice-master.min.js
index c07c2417..a091a7b1 100644
--- a/ice-master.min.js
+++ b/ice-master.min.js
@@ -3,7 +3,7 @@
// The MIT License
// Copyright (c) 2012 The New York Times, CMS Group, Matthew DeLambo
//
-window.rangy=function(){function e(e,t){var n=typeof e[t];return n==h||!(n!=d||!e[t])||"unknown"==n}function t(e,t){return!(typeof e[t]!=d||!e[t])}function n(e,t){return typeof e[t]!=u}function i(e){return function(t,n){for(var i=n.length;i--;)if(!e(t,n[i]))return!1;return!0}}function r(e){return e&&C(e,p)&&N(e,m)}function o(e){window.alert("Rangy not supported in your browser. Reason: "+e),E.initialized=!0,E.supported=!1}function s(e){var t="Rangy warning: "+e;E.config.alertOnWarn?window.alert(t):typeof window.console!=u&&typeof window.console.log!=u&&window.console.log(t)}function a(){if(!E.initialized){var n,i=!1,s=!1;e(document,"createRange")&&(n=document.createRange(),C(n,g)&&N(n,f)&&(i=!0),n.detach());var a=t(document,"body")?document.body:document.getElementsByTagName("body")[0];a&&e(a,"createTextRange")&&(n=a.createTextRange(),r(n)&&(s=!0)),i||s||o("Neither Range nor TextRange are implemented"),E.initialized=!0,E.features={implementsDomRange:i,implementsTextRange:s};for(var c=_.concat(y),l=0,d=c.length;d>l;++l)try{c[l](E)}catch(h){t(window,"console")&&e(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",h)}}}function c(e){e=e||window,a();for(var t=0,n=T.length;n>t;++t)T[t](e)}function l(e){this.name=e,this.initialized=!1,this.supported=!1}var d="object",h="function",u="undefined",f=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"],g=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],m=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],p=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint","getBoundingClientRect"],C=i(e),v=i(t),N=i(n),E={version:"1.2.3",initialized:!1,supported:!0,util:{isHostMethod:e,isHostObject:t,isHostProperty:n,areHostMethods:C,areHostObjects:v,areHostProperties:N,isTextRange:r},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}};E.fail=o,E.warn=s,{}.hasOwnProperty?E.util.extend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}:o("hasOwnProperty not supported");var y=[],_=[];E.init=a,E.addInitListener=function(e){E.initialized?e(E):y.push(e)};var T=[];E.addCreateMissingNativeApiListener=function(e){T.push(e)},E.createMissingNativeApi=c,l.prototype.fail=function(e){throw this.initialized=!0,this.supported=!1,Error("Module '"+this.name+"' failed to load: "+e)},l.prototype.warn=function(e){E.warn("Module "+this.name+": "+e)},l.prototype.createError=function(e){return Error("Error in Rangy "+this.name+" module: "+e)},E.createModule=function(e,t){var n=new l(e);E.modules[e]=n,_.push(function(e){t(e,n),n.initialized=!0,n.supported=!0})},E.requireModules=function(e){for(var t,n,i=0,r=e.length;r>i;++i){if(n=e[i],t=E.modules[n],!(t&&t instanceof l))throw Error("Module '"+n+"' not found");if(!t.supported)throw Error("Module '"+n+"' not supported")}};var S=!1,b=function(){S||(S=!0,E.initialized||a())};return typeof window==u?(o("No window found"),void 0):typeof document==u?(o("No document found"),void 0):(e(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",b,!1),e(window,"addEventListener")?window.addEventListener("load",b,!1):e(window,"attachEvent")?window.attachEvent("onload",b):o("Window does not have required addEventListener or attachEvent method"),E)}(),rangy.createModule("DomUtil",function(e,t){function n(e){var t;return typeof e.namespaceURI==b||null===(t=e.namespaceURI)||"http://www.w3.org/1999/xhtml"==t}function i(e){var t=e.parentNode;return 1==t.nodeType?t:null}function r(e){for(var t=0;e=e.previousSibling;)t++;return t}function o(e){var t;return l(e)?e.length:(t=e.childNodes)?t.length:0}function s(e,t){var n,i=[];for(n=e;n;n=n.parentNode)i.push(n);for(n=t;n;n=n.parentNode)if(D(i,n))return n;return null}function a(e,t,n){for(var i=n?t:t.parentNode;i;){if(i===e)return!0;i=i.parentNode}return!1}function c(e,t,n){for(var i,r=n?e:e.parentNode;r;){if(i=r.parentNode,i===t)return r;r=i}return null}function l(e){var t=e.nodeType;return 3==t||4==t||8==t}function d(e,t){var n=t.nextSibling,i=t.parentNode;return n?i.insertBefore(e,n):i.appendChild(e),e}function h(e,t){var n=e.cloneNode(!1);return n.deleteData(0,t),e.deleteData(t,e.length-t),d(n,e),n}function u(e){if(9==e.nodeType)return e;if(typeof e.ownerDocument!=b)return e.ownerDocument;if(typeof e.document!=b)return e.document;if(e.parentNode)return u(e.parentNode);throw Error("getDocument: no document found for node")}function f(e){var t=u(e);if(typeof t.defaultView!=b)return t.defaultView;if(typeof t.parentWindow!=b)return t.parentWindow;throw Error("Cannot get a window object for node")}function g(e){if(typeof e.contentDocument!=b)return e.contentDocument;if(typeof e.contentWindow!=b)return e.contentWindow.document;throw Error("getIframeWindow: No Document object found for iframe element")}function m(e){if(typeof e.contentWindow!=b)return e.contentWindow;if(typeof e.contentDocument!=b)return e.contentDocument.defaultView;throw Error("getIframeWindow: No Window object found for iframe element")}function p(e){return R.isHostObject(e,"body")?e.body:e.getElementsByTagName("body")[0]}function C(e){for(var t;t=e.parentNode;)e=t;return e}function v(e,t,n,i){var o,a,l,d,h;if(e==n)return t===i?0:i>t?-1:1;if(o=c(n,e,!0))return r(o)>=t?-1:1;if(o=c(e,n,!0))return i>r(o)?-1:1;if(a=s(e,n),l=e===a?a:c(e,a,!0),d=n===a?a:c(n,a,!0),l===d)throw Error("comparePoints got to case 4 and childA and childB are the same!");for(h=a.firstChild;h;){if(h===l)return-1;if(h===d)return 1;h=h.nextSibling}throw Error("Should not be here!")}function N(e){for(var t,n=u(e).createDocumentFragment();t=e.firstChild;)n.appendChild(t);return n}function E(e){if(!e)return"[No node]";if(l(e))return'"'+e.data+'"';if(1==e.nodeType){var t=e.id?' id="'+e.id+'"':"";return"<"+e.nodeName+t+">["+e.childNodes.length+"]"}return e.nodeName}function y(e){this.root=e,this._next=e}function _(e){return new y(e)}function T(e,t){this.node=e,this.offset=t}function S(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}var b="undefined",R=e.util;R.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||t.fail("document missing a Node creation method"),R.isHostMethod(document,"getElementsByTagName")||t.fail("document missing getElementsByTagName method");var O=document.createElement("div");R.areHostMethods(O,["insertBefore","appendChild","cloneNode"]||!R.areHostObjects(O,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation"),R.isHostProperty(O,"innerHTML")||t.fail("Element is missing innerHTML property");var w=document.createTextNode("test");R.areHostMethods(w,["splitText","deleteData","insertData","appendData","cloneNode"]||!R.areHostObjects(O,["previousSibling","nextSibling","childNodes","parentNode"])||!R.areHostProperties(w,["data"]))||t.fail("Incomplete Text Node implementation");var D=function(e,t){for(var n=e.length;n--;)if(e[n]===t)return!0;return!1};y.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e,t,n=this._current=this._next;if(this._current)if(e=n.firstChild)this._next=e;else{for(t=null;n!==this.root&&!(t=n.nextSibling);)n=n.parentNode;this._next=t}return this._current},detach:function(){this._current=this._next=this.root=null}},T.prototype={equals:function(e){return this.node===e.node&this.offset==e.offset},inspect:function(){return"[DomPosition("+E(this.node)+":"+this.offset+")]"}},S.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11},S.prototype.toString=function(){return this.message},e.dom={arrayContains:D,isHtmlNamespace:n,parentElement:i,getNodeIndex:r,getNodeLength:o,getCommonAncestor:s,isAncestorOf:a,getClosestAncestorIn:c,isCharacterDataNode:l,insertAfter:d,splitDataNode:h,getDocument:u,getWindow:f,getIframeWindow:m,getIframeDocument:g,getBody:p,getRootContainer:C,comparePoints:v,inspectNode:E,fragmentFromNodeChildren:N,createIterator:_,DomPosition:T},e.DOMException=S}),rangy.createModule("DomRange",function(e){function t(e,t){return 3!=e.nodeType&&(L.isAncestorOf(e,t.startContainer,!0)||L.isAncestorOf(e,t.endContainer,!0))}function n(e){return L.getDocument(e.startContainer)}function i(e,t,n){var i=e._listeners[t];if(i)for(var r=0,o=i.length;o>r;++r)i[r].call(e,{target:e,args:n})}function r(e){return new H(e.parentNode,L.getNodeIndex(e))}function o(e){return new H(e.parentNode,L.getNodeIndex(e)+1)}function s(e,t,n){var i=11==e.nodeType?e.firstChild:e;return L.isCharacterDataNode(t)?n==t.length?L.insertAfter(e,t):t.parentNode.insertBefore(e,0==n?t:L.splitDataNode(t,n)):n>=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[n]),i}function a(e){for(var t,i,r,o=n(e.range).createDocumentFragment();i=e.next();){if(t=e.isPartiallySelectedSubtree(),i=i.cloneNode(!t),t&&(r=e.getSubtreeIterator(),i.appendChild(a(r)),r.detach(!0)),10==i.nodeType)throw new j("HIERARCHY_REQUEST_ERR");o.appendChild(i)}return o}function c(e,t,n){var i,r;n=n||{stop:!1};for(var o,s;o=e.next();)if(e.isPartiallySelectedSubtree()){if(t(o)===!1)return n.stop=!0,void 0;if(s=e.getSubtreeIterator(),c(s,t,n),s.detach(!0),n.stop)return}else for(i=L.createIterator(o);r=i.next();)if(t(r)===!1)return n.stop=!0,void 0}function l(e){for(var t;e.next();)e.isPartiallySelectedSubtree()?(t=e.getSubtreeIterator(),l(t),t.detach(!0)):e.remove()}function d(e){for(var t,i,r=n(e.range).createDocumentFragment();t=e.next();){if(e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),i=e.getSubtreeIterator(),t.appendChild(d(i)),i.detach(!0)):e.remove(),10==t.nodeType)throw new j("HIERARCHY_REQUEST_ERR");r.appendChild(t)}return r}function h(e,t,n){var i,r=!(!t||!t.length),o=!!n;r&&(i=RegExp("^("+t.join("|")+")$"));var s=[];return c(new f(e,!1),function(e){r&&!i.test(e.nodeType)||o&&!n(e)||s.push(e)}),s}function u(e){var t=e.getName===void 0?"Range":e.getName();return"["+t+"("+L.inspectNode(e.startContainer)+":"+e.startOffset+", "+L.inspectNode(e.endContainer)+":"+e.endOffset+")]"}function f(e,t){if(this.range=e,this.clonePartiallySelectedTextNodes=t,!e.collapsed){this.sc=e.startContainer,this.so=e.startOffset,this.ec=e.endContainer,this.eo=e.endOffset;var n=e.commonAncestorContainer;this.sc===this.ec&&L.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==n||L.isCharacterDataNode(this.sc)?L.getClosestAncestorIn(this.sc,n,!0):this.sc.childNodes[this.so],this._last=this.ec!==n||L.isCharacterDataNode(this.ec)?L.getClosestAncestorIn(this.ec,n,!0):this.ec.childNodes[this.eo-1])}}function g(e){this.code=this[e],this.codeName=e,this.message="RangeException: "+this.codeName}function m(e,t,n){this.nodes=h(e,t,n),this._next=this.nodes[0],this._position=0}function p(e){return function(t,n){for(var i,r=n?t:t.parentNode;r;){if(i=r.nodeType,L.arrayContains(e,i))return r;r=r.parentNode}return null}}function C(e,t){if(q(e,t))throw new g("INVALID_NODE_TYPE_ERR")}function v(e){if(!e.startContainer)throw new j("INVALID_STATE_ERR")}function N(e,t){if(!L.arrayContains(t,e.nodeType))throw new g("INVALID_NODE_TYPE_ERR")}function E(e,t){if(0>t||t>(L.isCharacterDataNode(e)?e.length:e.childNodes.length))throw new j("INDEX_SIZE_ERR")}function y(e,t){if(X(e,!0)!==X(t,!0))throw new j("WRONG_DOCUMENT_ERR")}function _(e){if(z(e,!0))throw new j("NO_MODIFICATION_ALLOWED_ERR")}function T(e,t){if(!e)throw new j(t)}function S(e){return!L.arrayContains(Q,e.nodeType)&&!X(e,!0)}function b(e,t){return(L.isCharacterDataNode(e)?e.length:e.childNodes.length)>=t}function R(e){return!!e.startContainer&&!!e.endContainer&&!S(e.startContainer)&&!S(e.endContainer)&&b(e.startContainer,e.startOffset)&&b(e.endContainer,e.endOffset)}function O(e){if(v(e),!R(e))throw Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}function w(){}function D(e){e.START_TO_START=et,e.START_TO_END=tt,e.END_TO_END=nt,e.END_TO_START=it,e.NODE_BEFORE=rt,e.NODE_AFTER=ot,e.NODE_BEFORE_AND_AFTER=st,e.NODE_INSIDE=at}function x(e){D(e),D(e.prototype)}function k(e,t){return function(){O(this);var n,i,r=this.startContainer,s=this.startOffset,a=this.commonAncestorContainer,l=new f(this,!0);r!==a&&(n=L.getClosestAncestorIn(r,a,!0),i=o(n),r=i.node,s=i.offset),c(l,_),l.reset();var d=e(l);return l.detach(),t(this,r,s,r,s),d}}function A(n,i,s){function a(e,t){return function(n){v(this),N(n,U),N(V(n),Q);var i=(e?r:o)(n);(t?c:h)(this,i.node,i.offset)}}function c(e,t,n){var r=e.endContainer,o=e.endOffset;(t!==e.startContainer||n!==e.startOffset)&&((V(t)!=V(r)||1==L.comparePoints(t,n,r,o))&&(r=t,o=n),i(e,t,n,r,o))}function h(e,t,n){var r=e.startContainer,o=e.startOffset;(t!==e.endContainer||n!==e.endOffset)&&((V(t)!=V(r)||-1==L.comparePoints(t,n,r,o))&&(r=t,o=n),i(e,r,o,t,n))}function u(e,t,n){(t!==e.startContainer||n!==e.startOffset||t!==e.endContainer||n!==e.endOffset)&&i(e,t,n,t,n)}n.prototype=new w,e.util.extend(n.prototype,{setStart:function(e,t){v(this),C(e,!0),E(e,t),c(this,e,t)},setEnd:function(e,t){v(this),C(e,!0),E(e,t),h(this,e,t)},setStartBefore:a(!0,!0),setStartAfter:a(!1,!0),setEndBefore:a(!0,!1),setEndAfter:a(!1,!1),collapse:function(e){O(this),e?i(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):i(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){v(this),C(e,!0),i(this,e,0,e,L.getNodeLength(e))},selectNode:function(e){v(this),C(e,!1),N(e,U);var t=r(e),n=o(e);i(this,t.node,t.offset,n.node,n.offset)},extractContents:k(d,i),deleteContents:k(l,i),canSurroundContents:function(){O(this),_(this.startContainer),_(this.endContainer);var e=new f(this,!0),n=e._first&&t(e._first,this)||e._last&&t(e._last,this);return e.detach(),!n},detach:function(){s(this)},splitBoundaries:function(){O(this);var e=this.startContainer,t=this.startOffset,n=this.endContainer,r=this.endOffset,o=e===n;L.isCharacterDataNode(n)&&r>0&&n.length>r&&L.splitDataNode(n,r),L.isCharacterDataNode(e)&&t>0&&e.length>t&&(e=L.splitDataNode(e,t),o?(r-=t,n=e):n==e.parentNode&&r>=L.getNodeIndex(e)&&r++,t=0),i(this,e,t,n,r)},normalizeBoundaries:function(){O(this);var e=this.startContainer,t=this.startOffset,n=this.endContainer,r=this.endOffset,o=function(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(n=e,r=e.length,e.appendData(t.data),t.parentNode.removeChild(t))},s=function(i){var o=i.previousSibling;if(o&&o.nodeType==i.nodeType){e=i;var s=i.length;if(t=o.length,i.insertData(0,o.data),o.parentNode.removeChild(o),e==n)r+=t,n=e;else if(n==i.parentNode){var a=L.getNodeIndex(i);r==a?(n=i,r=s):r>a&&r--}}},a=!0;if(L.isCharacterDataNode(n))n.length==r&&o(n);else{if(r>0){var c=n.childNodes[r-1];c&&L.isCharacterDataNode(c)&&o(c)}a=!this.collapsed}if(a){if(L.isCharacterDataNode(e))0==t&&s(e);else if(e.childNodes.length>t){var l=e.childNodes[t];l&&L.isCharacterDataNode(l)&&s(l)}}else e=n,t=r;i(this,e,t,n,r)},collapseToPoint:function(e,t){v(this),C(e,!0),E(e,t),u(this,e,t)}}),x(n)}function P(e){e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset,e.commonAncestorContainer=e.collapsed?e.startContainer:L.getCommonAncestor(e.startContainer,e.endContainer)}function I(e,t,n,r,o){var s=e.startContainer!==t||e.startOffset!==n,a=e.endContainer!==r||e.endOffset!==o;e.startContainer=t,e.startOffset=n,e.endContainer=r,e.endOffset=o,P(e),i(e,"boundarychange",{startMoved:s,endMoved:a})}function B(e){v(e),e.startContainer=e.startOffset=e.endContainer=e.endOffset=null,e.collapsed=e.commonAncestorContainer=null,i(e,"detach",null),e._listeners=null}function M(e){this.startContainer=e,this.startOffset=0,this.endContainer=e,this.endOffset=0,this._listeners={boundarychange:[],detach:[]},P(this)}e.requireModules(["DomUtil"]);var L=e.dom,H=L.DomPosition,j=e.DOMException;f.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next;return e&&(this._next=e!==this._last?e.nextSibling:null,L.isCharacterDataNode(e)&&this.clonePartiallySelectedTextNodes&&(e===this.ec&&(e=e.cloneNode(!0)).deleteData(this.eo,e.length-this.eo),this._current===this.sc&&(e=e.cloneNode(!0)).deleteData(0,this.so))),e},remove:function(){var e,t,n=this._current;!L.isCharacterDataNode(n)||n!==this.sc&&n!==this.ec?n.parentNode&&n.parentNode.removeChild(n):(e=n===this.sc?this.so:0,t=n===this.ec?this.eo:n.length,e!=t&&n.deleteData(e,t-e))},isPartiallySelectedSubtree:function(){var e=this._current;return t(e,this.range)},getSubtreeIterator:function(){var e;if(this.isSingleCharacterDataNode)e=this.range.cloneRange(),e.collapse();else{e=new M(n(this.range));var t=this._current,i=t,r=0,o=t,s=L.getNodeLength(t);L.isAncestorOf(t,this.sc,!0)&&(i=this.sc,r=this.so),L.isAncestorOf(t,this.ec,!0)&&(o=this.ec,s=this.eo),I(e,i,r,o,s)}return new f(e,this.clonePartiallySelectedTextNodes)},detach:function(e){e&&this.range.detach(),this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}},g.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2},g.prototype.toString=function(){return this.message},m.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){return this._current=this._next,this._next=this.nodes[++this._position],this._current},detach:function(){this._current=this._next=this.nodes=null}};var U=[1,3,4,5,7,8,10],Q=[2,9,11],W=[5,6,10,12],F=[1,3,4,5,7,8,10,11],K=[1,3,4,5,7,8],V=L.getRootContainer,X=p([9,11]),z=p(W),q=p([6,10,12]),Y=document.createElement("style"),$=!1;try{Y.innerHTML="x",$=3==Y.firstChild.nodeType}catch(G){}e.features.htmlParsingConforms=$;var Z=$?function(e){var t=this.startContainer,n=L.getDocument(t);if(!t)throw new j("INVALID_STATE_ERR");var i=null;return 1==t.nodeType?i=t:L.isCharacterDataNode(t)&&(i=L.parentElement(t)),i=null===i||"HTML"==i.nodeName&&L.isHtmlNamespace(L.getDocument(i).documentElement)&&L.isHtmlNamespace(i)?n.createElement("body"):i.cloneNode(!1),i.innerHTML=e,L.fragmentFromNodeChildren(i)}:function(e){v(this);var t=n(this),i=t.createElement("body");return i.innerHTML=e,L.fragmentFromNodeChildren(i)},J=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],et=0,tt=1,nt=2,it=3,rt=0,ot=1,st=2,at=3;w.prototype={attachListener:function(e,t){this._listeners[e].push(t)},compareBoundaryPoints:function(e,t){O(this),y(this.startContainer,t.startContainer);var n,i,r,o,s=e==it||e==et?"start":"end",a=e==tt||e==et?"start":"end";return n=this[s+"Container"],i=this[s+"Offset"],r=t[a+"Container"],o=t[a+"Offset"],L.comparePoints(n,i,r,o)},insertNode:function(e){if(O(this),N(e,F),_(this.startContainer),L.isAncestorOf(e,this.startContainer,!0))throw new j("HIERARCHY_REQUEST_ERR");var t=s(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){O(this);var e,t;if(this.collapsed)return n(this).createDocumentFragment();if(this.startContainer===this.endContainer&&L.isCharacterDataNode(this.startContainer))return e=this.startContainer.cloneNode(!0),e.data=e.data.slice(this.startOffset,this.endOffset),t=n(this).createDocumentFragment(),t.appendChild(e),t;var i=new f(this,!0);return e=a(i),i.detach(),e},canSurroundContents:function(){O(this),_(this.startContainer),_(this.endContainer);var e=new f(this,!0),n=e._first&&t(e._first,this)||e._last&&t(e._last,this);return e.detach(),!n},surroundContents:function(e){if(N(e,K),!this.canSurroundContents())throw new g("BAD_BOUNDARYPOINTS_ERR");var t=this.extractContents();if(e.hasChildNodes())for(;e.lastChild;)e.removeChild(e.lastChild);s(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){O(this);for(var e,t=new M(n(this)),i=J.length;i--;)e=J[i],t[e]=this[e];return t},toString:function(){O(this);var e=this.startContainer;if(e===this.endContainer&&L.isCharacterDataNode(e))return 3==e.nodeType||4==e.nodeType?e.data.slice(this.startOffset,this.endOffset):"";var t=[],n=new f(this,!0);return c(n,function(e){(3==e.nodeType||4==e.nodeType)&&t.push(e.data)}),n.detach(),t.join("")},compareNode:function(e){O(this);var t=e.parentNode,n=L.getNodeIndex(e);if(!t)throw new j("NOT_FOUND_ERR");var i=this.comparePoint(t,n),r=this.comparePoint(t,n+1);return 0>i?r>0?st:rt:r>0?ot:at},comparePoint:function(e,t){return O(this),T(e,"HIERARCHY_REQUEST_ERR"),y(e,this.startContainer),0>L.comparePoints(e,t,this.startContainer,this.startOffset)?-1:L.comparePoints(e,t,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:Z,toHtml:function(){O(this);var e=n(this).createElement("div");return e.appendChild(this.cloneContents()),e.innerHTML},intersectsNode:function(e,t){if(O(this),T(e,"NOT_FOUND_ERR"),L.getDocument(e)!==n(this))return!1;var i=e.parentNode,r=L.getNodeIndex(e);T(i,"NOT_FOUND_ERR");var o=L.comparePoints(i,r,this.endContainer,this.endOffset),s=L.comparePoints(i,r+1,this.startContainer,this.startOffset);return t?0>=o&&s>=0:0>o&&s>0},isPointInRange:function(e,t){return O(this),T(e,"HIERARCHY_REQUEST_ERR"),y(e,this.startContainer),L.comparePoints(e,t,this.startContainer,this.startOffset)>=0&&0>=L.comparePoints(e,t,this.endContainer,this.endOffset)},intersectsRange:function(e,t){if(O(this),n(e)!=n(this))throw new j("WRONG_DOCUMENT_ERR");var i=L.comparePoints(this.startContainer,this.startOffset,e.endContainer,e.endOffset),r=L.comparePoints(this.endContainer,this.endOffset,e.startContainer,e.startOffset);return t?0>=i&&r>=0:0>i&&r>0},intersection:function(e){if(this.intersectsRange(e)){var t=L.comparePoints(this.startContainer,this.startOffset,e.startContainer,e.startOffset),n=L.comparePoints(this.endContainer,this.endOffset,e.endContainer,e.endOffset),i=this.cloneRange();return-1==t&&i.setStart(e.startContainer,e.startOffset),1==n&&i.setEnd(e.endContainer,e.endOffset),i}return null},union:function(e){if(this.intersectsRange(e,!0)){var t=this.cloneRange();return-1==L.comparePoints(e.startContainer,e.startOffset,this.startContainer,this.startOffset)&&t.setStart(e.startContainer,e.startOffset),1==L.comparePoints(e.endContainer,e.endOffset,this.endContainer,this.endOffset)&&t.setEnd(e.endContainer,e.endOffset),t}throw new g("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==at},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&0>=this.comparePoint(e,L.getNodeLength(e))},containsRange:function(e){return this.intersection(e).equals(e)},containsNodeText:function(e){var t=this.cloneRange();t.selectNode(e);var n=t.getNodes([3]);if(n.length>0){t.setStart(n[0],0);var i=n.pop();t.setEnd(i,i.length);var r=this.containsRange(t);return t.detach(),r}return this.containsNodeContents(e)},createNodeIterator:function(e,t){return O(this),new m(this,e,t)},getNodes:function(e,t){return O(this),h(this,e,t)},getDocument:function(){return n(this)},collapseBefore:function(e){v(this),this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){v(this),this.setStartAfter(e),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(e){return M.rangesEqual(this,e)},isValid:function(){return R(this)},inspect:function(){return u(this)}},A(M,I,B),e.rangePrototype=w.prototype,M.rangeProperties=J,M.RangeIterator=f,M.copyComparisonConstants=x,M.createPrototypeRange=A,M.inspect=u,M.getRangeDocument=n,M.rangesEqual=function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset},e.DomRange=M,e.RangeException=g}),rangy.createModule("WrappedRange",function(e){function t(e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var i=n.parentElement();n=e.duplicate(),n.collapse(!1);var r=n.parentElement(),o=i==r?i:s.getCommonAncestor(i,r);return o==t?o:s.getCommonAncestor(t,o)}function n(e){return 0==e.compareEndPoints("StartToEnd",e)}function i(e,t,n,i){var r=e.duplicate();r.collapse(n);var o=r.parentElement();if(s.isAncestorOf(t,o,!0)||(o=t),!o.canHaveHTML)return new a(o.parentNode,s.getNodeIndex(o));var c,l,d,h,u,f=s.getDocument(o).createElement("span"),g=n?"StartToStart":"StartToEnd";do o.insertBefore(f,f.previousSibling),r.moveToElementText(f);while((c=r.compareEndPoints(g,e))>0&&f.previousSibling);if(u=f.nextSibling,-1==c&&u&&s.isCharacterDataNode(u)){r.setEndPoint(n?"EndToStart":"EndToEnd",e);var m;if(/[\r\n]/.test(u.data)){var p=r.duplicate(),C=p.text.replace(/\r\n/g,"\r").length;for(m=p.moveStart("character",C);-1==(c=p.compareEndPoints("StartToEnd",p));)m++,p.moveStart("character",1)}else m=r.text.length;h=new a(u,m)}else l=(i||!n)&&f.previousSibling,d=(i||n)&&f.nextSibling,h=d&&s.isCharacterDataNode(d)?new a(d,0):l&&s.isCharacterDataNode(l)?new a(l,l.length):new a(o,s.getNodeIndex(f));return f.parentNode.removeChild(f),h}function r(e,t){var n,i,r,o,a=e.offset,c=s.getDocument(e.node),l=c.body.createTextRange(),d=s.isCharacterDataNode(e.node);return d?(n=e.node,i=n.parentNode):(o=e.node.childNodes,n=o.length>a?o[a]:null,i=e.node),r=c.createElement("span"),r.innerHTML="feff;",n?i.insertBefore(r,n):i.appendChild(r),l.moveToElementText(r),l.collapse(!t),i.removeChild(r),d&&l[t?"moveStart":"moveEnd"]("character",a),l}e.requireModules(["DomUtil","DomRange"]);var o,s=e.dom,a=s.DomPosition,c=e.DomRange;if(!e.features.implementsDomRange||e.features.implementsTextRange&&e.config.preferTextRange){if(e.features.implementsTextRange){o=function(e){this.textRange=e,this.refresh()},o.prototype=new c(document),o.prototype.refresh=function(){var e,r,o=t(this.textRange);n(this.textRange)?r=e=i(this.textRange,o,!0,!0):(e=i(this.textRange,o,!0,!1),r=i(this.textRange,o,!1,!1)),this.setStart(e.node,e.offset),this.setEnd(r.node,r.offset)},c.copyComparisonConstants(o);var l=function(){return this}();l.Range===void 0&&(l.Range=o),e.createNativeRange=function(e){return e=e||document,e.body.createTextRange()}}}else(function(){function t(e){for(var t,n=d.length;n--;)t=d[n],e[t]=e.nativeRange[t]}function n(e,t,n,i,r){var o=e.startContainer!==t||e.startOffset!=n,s=e.endContainer!==i||e.endOffset!=r;(o||s)&&(e.setEnd(i,r),e.setStart(t,n))}function i(e){e.nativeRange.detach(),e.detached=!0;for(var t,n=d.length;n--;)t=d[n],e[t]=null}var r,a,l,d=c.rangeProperties;o=function(e){if(!e)throw Error("Range must be specified");this.nativeRange=e,t(this)},c.createPrototypeRange(o,n,i),r=o.prototype,r.selectNode=function(e){this.nativeRange.selectNode(e),t(this)},r.deleteContents=function(){this.nativeRange.deleteContents(),t(this)},r.extractContents=function(){var e=this.nativeRange.extractContents();return t(this),e},r.cloneContents=function(){return this.nativeRange.cloneContents()},r.surroundContents=function(e){this.nativeRange.surroundContents(e),t(this)},r.collapse=function(e){this.nativeRange.collapse(e),t(this)},r.cloneRange=function(){return new o(this.nativeRange.cloneRange())},r.refresh=function(){t(this)},r.toString=function(){return""+this.nativeRange};var h=document.createTextNode("test");s.getBody(document).appendChild(h);var u=document.createRange();u.setStart(h,0),u.setEnd(h,0);try{u.setStart(h,1),a=!0,r.setStart=function(e,n){this.nativeRange.setStart(e,n),t(this)},r.setEnd=function(e,n){this.nativeRange.setEnd(e,n),t(this)},l=function(e){return function(n){this.nativeRange[e](n),t(this)}}}catch(f){a=!1,r.setStart=function(e,n){try{this.nativeRange.setStart(e,n)}catch(i){this.nativeRange.setEnd(e,n),this.nativeRange.setStart(e,n)}t(this)},r.setEnd=function(e,n){try{this.nativeRange.setEnd(e,n)}catch(i){this.nativeRange.setStart(e,n),this.nativeRange.setEnd(e,n)}t(this)},l=function(e,n){return function(i){try{this.nativeRange[e](i)}catch(r){this.nativeRange[n](i),this.nativeRange[e](i)}t(this)}}}r.setStartBefore=l("setStartBefore","setEndBefore"),r.setStartAfter=l("setStartAfter","setEndAfter"),r.setEndBefore=l("setEndBefore","setStartBefore"),r.setEndAfter=l("setEndAfter","setStartAfter"),u.selectNodeContents(h),r.selectNodeContents=u.startContainer==h&&u.endContainer==h&&0==u.startOffset&&u.endOffset==h.length?function(e){this.nativeRange.selectNodeContents(e),t(this)}:function(e){this.setStart(e,0),this.setEnd(e,c.getEndOffset(e))},u.selectNodeContents(h),u.setEnd(h,3);var g=document.createRange();g.selectNodeContents(h),g.setEnd(h,4),g.setStart(h,2),r.compareBoundaryPoints=-1==u.compareBoundaryPoints(u.START_TO_END,g)&1==u.compareBoundaryPoints(u.END_TO_START,g)?function(e,t){return t=t.nativeRange||t,e==t.START_TO_END?e=t.END_TO_START:e==t.END_TO_START&&(e=t.START_TO_END),this.nativeRange.compareBoundaryPoints(e,t)}:function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)},e.util.isHostMethod(u,"createContextualFragment")&&(r.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}),s.getBody(document).removeChild(h),u.detach(),g.detach()})(),e.createNativeRange=function(e){return e=e||document,e.createRange()};e.features.implementsTextRange&&(o.rangeToTextRange=function(e){if(e.collapsed){var t=r(new a(e.startContainer,e.startOffset),!0);return t}var n=r(new a(e.startContainer,e.startOffset),!0),i=r(new a(e.endContainer,e.endOffset),!1),o=s.getDocument(e.startContainer).body.createTextRange();return o.setEndPoint("StartToStart",n),o.setEndPoint("EndToEnd",i),o}),o.prototype.getName=function(){return"WrappedRange"},e.WrappedRange=o,e.createRange=function(t){return t=t||document,new o(e.createNativeRange(t))},e.createRangyRange=function(e){return e=e||document,new c(e)},e.createIframeRange=function(t){return e.createRange(s.getIframeDocument(t))},e.createIframeRangyRange=function(t){return e.createRangyRange(s.getIframeDocument(t))},e.addCreateMissingNativeApiListener(function(t){var n=t.document;n.createRange===void 0&&(n.createRange=function(){return e.createRange(this)}),n=t=null})}),rangy.createModule("WrappedSelection",function(e,t){function n(e){return(e||window).getSelection()}function i(e){return(e||window).document.selection}function r(e,t,n){var i=n?"end":"start",r=n?"start":"end";e.anchorNode=t[i+"Container"],e.anchorOffset=t[i+"Offset"],e.focusNode=t[r+"Container"],e.focusOffset=t[r+"Offset"]}function o(e){var t=e.nativeSelection;e.anchorNode=t.anchorNode,e.anchorOffset=t.anchorOffset,e.focusNode=t.focusNode,e.focusOffset=t.focusOffset}function s(e){e.anchorNode=e.focusNode=null,e.anchorOffset=e.focusOffset=0,e.rangeCount=0,e.isCollapsed=!0,e._ranges.length=0}function a(t){var n;return t instanceof S?(n=t._selectionNativeRange,n||(n=e.createNativeRange(_.getDocument(t.startContainer)),n.setEnd(t.endContainer,t.endOffset),n.setStart(t.startContainer,t.startOffset),t._selectionNativeRange=n,t.attachListener("detach",function(){this._selectionNativeRange=null}))):t instanceof b?n=t.nativeRange:e.features.implementsDomRange&&t instanceof _.getWindow(t.startContainer).Range&&(n=t),n}function c(e){if(!e.length||1!=e[0].nodeType)return!1;for(var t=1,n=e.length;n>t;++t)if(!_.isAncestorOf(e[0],e[t]))return!1;return!0}function l(e){var t=e.getNodes();if(!c(t))throw Error("getSingleElementFromRange: range "+e.inspect()+" did not consist of a single element");return t[0]}function d(e){return!!e&&e.text!==void 0}function h(e,t){var n=new b(t);e._ranges=[n],r(e,n,!1),e.rangeCount=1,e.isCollapsed=n.collapsed}function u(t){if(t._ranges.length=0,"None"==t.docSelection.type)s(t);else{var n=t.docSelection.createRange();if(d(n))h(t,n);else{t.rangeCount=n.length;for(var i,o=_.getDocument(n.item(0)),a=0;t.rangeCount>a;++a)i=e.createRange(o),i.selectNode(n.item(a)),t._ranges.push(i);t.isCollapsed=1==t.rangeCount&&t._ranges[0].collapsed,r(t,t._ranges[t.rangeCount-1],!1)
-}}}function f(e,t){for(var n=e.docSelection.createRange(),i=l(t),r=_.getDocument(n.item(0)),o=_.getBody(r).createControlRange(),s=0,a=n.length;a>s;++s)o.add(n.item(s));try{o.add(i)}catch(c){throw Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}o.select(),u(e)}function g(e,t,n){this.nativeSelection=e,this.docSelection=t,this._ranges=[],this.win=n,this.refresh()}function m(e,t){for(var n,i=_.getDocument(t[0].startContainer),r=_.getBody(i).createControlRange(),o=0;rangeCount>o;++o){n=l(t[o]);try{r.add(n)}catch(s){throw Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)")}}r.select(),u(e)}function p(e,t){if(e.anchorNode&&_.getDocument(e.anchorNode)!==_.getDocument(t))throw new R("WRONG_DOCUMENT_ERR")}function C(e){var t=[],n=new O(e.anchorNode,e.anchorOffset),i=new O(e.focusNode,e.focusOffset),r="function"==typeof e.getName?e.getName():"Selection";if(e.rangeCount!==void 0)for(var o=0,s=e.rangeCount;s>o;++o)t[o]=S.inspect(e.getRangeAt(o));return"["+r+"(Ranges: "+t.join(", ")+")(anchor: "+n.inspect()+", focus: "+i.inspect()+"]"}e.requireModules(["DomUtil","DomRange","WrappedRange"]),e.config.checkSelectionRanges=!0;var v,N,E="boolean",y="_rangySelection",_=e.dom,T=e.util,S=e.DomRange,b=e.WrappedRange,R=e.DOMException,O=_.DomPosition,w="Control",D=e.util.isHostMethod(window,"getSelection"),x=e.util.isHostObject(document,"selection"),k=x&&(!D||e.config.preferTextRange);k?(v=i,e.isSelectionValid=function(e){var t=(e||window).document,n=t.selection;return"None"!=n.type||_.getDocument(n.createRange().parentElement())==t}):D?(v=n,e.isSelectionValid=function(){return!0}):t.fail("Neither document.selection or window.getSelection() detected."),e.getNativeSelection=v;var A=v(),P=e.createNativeRange(document),I=_.getBody(document),B=T.areHostObjects(A,["anchorNode","focusNode"]&&T.areHostProperties(A,["anchorOffset","focusOffset"]));e.features.selectionHasAnchorAndFocus=B;var M=T.isHostMethod(A,"extend");e.features.selectionHasExtend=M;var L="number"==typeof A.rangeCount;e.features.selectionHasRangeCount=L;var H=!1,j=!0;T.areHostMethods(A,["addRange","getRangeAt","removeAllRanges"])&&"number"==typeof A.rangeCount&&e.features.implementsDomRange&&function(){var e=document.createElement("iframe");e.frameBorder=0,e.style.position="absolute",e.style.left="-10000px",I.appendChild(e);var t=_.getIframeDocument(e);t.open(),t.write("12"),t.close();var n=_.getIframeWindow(e).getSelection(),i=t.documentElement,r=i.lastChild,o=r.firstChild,s=t.createRange();s.setStart(o,1),s.collapse(!0),n.addRange(s),j=1==n.rangeCount,n.removeAllRanges();var a=s.cloneRange();s.setStart(o,0),a.setEnd(o,2),n.addRange(s),n.addRange(a),H=2==n.rangeCount,s.detach(),a.detach(),I.removeChild(e)}(),e.features.selectionSupportsMultipleRanges=H,e.features.collapsedNonEditableSelectionsSupported=j;var U,Q=!1;I&&T.isHostMethod(I,"createControlRange")&&(U=I.createControlRange(),T.areHostProperties(U,["item","add"])&&(Q=!0)),e.features.implementsControlRange=Q,N=B?function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}:function(e){return e.rangeCount?e.getRangeAt(e.rangeCount-1).collapsed:!1};var W;T.isHostMethod(A,"getRangeAt")?W=function(e,t){try{return e.getRangeAt(t)}catch(n){return null}}:B&&(W=function(t){var n=_.getDocument(t.anchorNode),i=e.createRange(n);return i.setStart(t.anchorNode,t.anchorOffset),i.setEnd(t.focusNode,t.focusOffset),i.collapsed!==this.isCollapsed&&(i.setStart(t.focusNode,t.focusOffset),i.setEnd(t.anchorNode,t.anchorOffset)),i}),e.getSelection=function(e){e=e||window;var t=e[y],n=v(e),r=x?i(e):null;return t?(t.nativeSelection=n,t.docSelection=r,t.refresh(e)):(t=new g(n,r,e),e[y]=t),t},e.getIframeSelection=function(t){return e.getSelection(_.getIframeWindow(t))};var F=g.prototype;if(!k&&B&&T.areHostMethods(A,["removeAllRanges","addRange"])){F.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),s(this)};var K=function(t,n){var i=S.getRangeDocument(n),r=e.createRange(i);r.collapseToPoint(n.endContainer,n.endOffset),t.nativeSelection.addRange(a(r)),t.nativeSelection.extend(n.startContainer,n.startOffset),t.refresh()};F.addRange=L?function(t,n){if(Q&&x&&this.docSelection.type==w)f(this,t);else if(n&&M)K(this,t);else{var i;if(H?i=this.rangeCount:(this.removeAllRanges(),i=0),this.nativeSelection.addRange(a(t)),this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==i+1){if(e.config.checkSelectionRanges){var o=W(this.nativeSelection,this.rangeCount-1);o&&!S.rangesEqual(o,t)&&(t=new b(o))}this._ranges[this.rangeCount-1]=t,r(this,t,z(this.nativeSelection)),this.isCollapsed=N(this)}else this.refresh()}}:function(e,t){t&&M?K(this,e):(this.nativeSelection.addRange(a(e)),this.refresh())},F.setRanges=function(e){if(Q&&e.length>1)m(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;n>t;++t)this.addRange(e[t])}}}else{if(!(T.isHostMethod(A,"empty")&&T.isHostMethod(P,"select")&&Q&&k))return t.fail("No means of selecting a Range or TextRange was found"),!1;F.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var e;if(this.anchorNode)e=_.getDocument(this.anchorNode);else if(this.docSelection.type==w){var t=this.docSelection.createRange();t.length&&(e=_.getDocument(t.item(0)).body.createTextRange())}if(e){var n=e.body.createTextRange();n.select(),this.docSelection.empty()}}}catch(i){}s(this)},F.addRange=function(e){this.docSelection.type==w?f(this,e):(b.rangeToTextRange(e).select(),this._ranges[0]=e,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,r(this,e,!1))},F.setRanges=function(e){this.removeAllRanges();var t=e.length;t>1?m(this,e):t&&this.addRange(e[0])}}F.getRangeAt=function(e){if(0>e||e>=this.rangeCount)throw new R("INDEX_SIZE_ERR");return this._ranges[e]};var V;if(k)V=function(t){var n;e.isSelectionValid(t.win)?n=t.docSelection.createRange():(n=_.getBody(t.win.document).createTextRange(),n.collapse(!0)),t.docSelection.type==w?u(t):d(n)?h(t,n):s(t)};else if(T.isHostMethod(A,"getRangeAt")&&"number"==typeof A.rangeCount)V=function(t){if(Q&&x&&t.docSelection.type==w)u(t);else if(t._ranges.length=t.rangeCount=t.nativeSelection.rangeCount,t.rangeCount){for(var n=0,i=t.rangeCount;i>n;++n)t._ranges[n]=new e.WrappedRange(t.nativeSelection.getRangeAt(n));r(t,t._ranges[t.rangeCount-1],z(t.nativeSelection)),t.isCollapsed=N(t)}else s(t)};else{if(!B||typeof A.isCollapsed!=E||typeof P.collapsed!=E||!e.features.implementsDomRange)return t.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;V=function(e){var t,n=e.nativeSelection;n.anchorNode?(t=W(n,0),e._ranges=[t],e.rangeCount=1,o(e),e.isCollapsed=N(e)):s(e)}}F.refresh=function(e){var t=e?this._ranges.slice(0):null;if(V(this),e){var n=t.length;if(n!=this._ranges.length)return!1;for(;n--;)if(!S.rangesEqual(t[n],this._ranges[n]))return!1;return!0}};var X=function(e,t){var n=e.getAllRanges(),i=!1;e.removeAllRanges();for(var r=0,o=n.length;o>r;++r)i||t!==n[r]?e.addRange(n[r]):i=!0;e.rangeCount||s(e)};F.removeRange=Q?function(e){if(this.docSelection.type==w){for(var t,n=this.docSelection.createRange(),i=l(e),r=_.getDocument(n.item(0)),o=_.getBody(r).createControlRange(),s=!1,a=0,c=n.length;c>a;++a)t=n.item(a),t!==i||s?o.add(n.item(a)):s=!0;o.select(),u(this)}else X(this,e)}:function(e){X(this,e)};var z;!k&&B&&e.features.implementsDomRange?(z=function(e){var t=!1;return e.anchorNode&&(t=1==_.comparePoints(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)),t},F.isBackwards=function(){return z(this)}):z=F.isBackwards=function(){return!1},F.toString=function(){for(var e=[],t=0,n=this.rangeCount;n>t;++t)e[t]=""+this._ranges[t];return e.join("")},F.collapse=function(t,n){p(this,t);var i=e.createRange(_.getDocument(t));i.collapseToPoint(t,n),this.removeAllRanges(),this.addRange(i),this.isCollapsed=!0},F.collapseToStart=function(){if(!this.rangeCount)throw new R("INVALID_STATE_ERR");var e=this._ranges[0];this.collapse(e.startContainer,e.startOffset)},F.collapseToEnd=function(){if(!this.rangeCount)throw new R("INVALID_STATE_ERR");var e=this._ranges[this.rangeCount-1];this.collapse(e.endContainer,e.endOffset)},F.selectAllChildren=function(t){p(this,t);var n=e.createRange(_.getDocument(t));n.selectNodeContents(t),this.removeAllRanges(),this.addRange(n)},F.deleteFromDocument=function(){if(Q&&x&&this.docSelection.type==w){for(var e,t=this.docSelection.createRange();t.length;)e=t.item(0),t.remove(e),e.parentNode.removeChild(e);this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();this.removeAllRanges();for(var i=0,r=n.length;r>i;++i)n[i].deleteContents();this.addRange(n[r-1])}},F.getAllRanges=function(){return this._ranges.slice(0)},F.setSingleRange=function(e){this.setRanges([e])},F.containsNode=function(e,t){for(var n=0,i=this._ranges.length;i>n;++n)if(this._ranges[n].containsNode(e,t))return!0;return!1},F.toHtml=function(){var e="";if(this.rangeCount){for(var t=S.getRangeDocument(this._ranges[0]).createElement("div"),n=0,i=this._ranges.length;i>n;++n)t.appendChild(this._ranges[n].cloneContents());e=t.innerHTML}return e},F.getName=function(){return"WrappedSelection"},F.inspect=function(){return C(this)},F.detach=function(){this.win[y]=null,this.win=this.anchorNode=this.focusNode=null},g.inspect=C,e.Selection=g,e.selectionPrototype=F,e.addCreateMissingNativeApiListener(function(t){t.getSelection===void 0&&(t.getSelection=function(){return e.getSelection(this)}),t=null})}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),"indexOf"in Array.prototype||(Array.prototype.indexOf=function(e,t){void 0===t&&(t=0),0>t&&(t+=this.length),0>t&&(t=0);for(var n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1}),"lastIndexOf"in Array.prototype||(Array.prototype.lastIndexOf=function(e,t){for(void 0===t&&(t=this.length-1),0>t&&(t+=this.length),t>this.length-1&&(t=this.length-1),t++;t-->0;)if(t in this&&this[t]===e)return t;return-1}),"map"in Array.prototype||(Array.prototype.map=function(e,t){for(var n=Array(this.length),i=0,r=this.length;r>i;i++)i in this&&(n[i]=e.call(t,this[i],i,this));return n}),"filter"in Array.prototype||(Array.prototype.filter=function(e,t){for(var n,i=[],r=0,o=this.length;o>r;r++)r in this&&e.call(t,n=this[r],r,this)&&i.push(n);return i}),function(){var e,t,n=this;e={changeIdAttribute:"data-cid",userIdAttribute:"data-userid",userNameAttribute:"data-username",timeAttribute:"data-time",attrValuePrefix:"",blockEl:"p",blockEls:["p","ol","ul","li","h1","h2","h3","h4","h5","h6","blockquote"],stylePrefix:"cts",currentUser:{id:null,name:null},changeTypes:{insertType:{tag:"span",alias:"ins",action:"Inserted"},deleteType:{tag:"span",alias:"del",action:"Deleted"}},handleEvents:!1,contentEditable:!0,isTracking:!0,noTrack:".ice-no-track",avoid:".ice-avoid",mergeBlocks:!0},t=function(t){if(this._changes={},t||(t={}),!t.element)throw Error("`options.element` must be defined for ice construction.");ice.dom.extend(!0,this,e,t),this.pluginsManager=new ice.IcePluginManager(this),t.plugins&&this.pluginsManager.usePlugins("ice-init",t.plugins)},t.prototype={_userStyles:{},_styles:{},_uniqueStyleIndex:0,_browserType:null,_batchChangeid:null,_uniqueIDIndex:1,_delBookmark:"tempdel",isPlaceHoldingDeletes:!1,startTracking:function(){if(this.element.setAttribute("contentEditable",this.contentEditable),this.handleEvents){var e=this;ice.dom.bind(e.element,"keyup.ice keydown.ice keypress.ice mousedown.ice mouseup.ice",function(t){return e.handleEvent(t)})}return this.initializeEnvironment(),this.initializeEditor(),this.initializeRange(),this.pluginsManager.fireEnabled(this.element),this},stopTracking:function(){if(this.element.setAttribute("contentEditable",!this.contentEditable),this.handleEvents){var e=this;ice.dom.unbind(e.element,"keyup.ice keydown.ice keypress.ice mousedown.ice mouseup.ice")}return this.pluginsManager.fireDisabled(this.element),this},initializeEnvironment:function(){this.env||(this.env={}),this.env.element=this.element,this.env.document=this.element.ownerDocument,this.env.window=this.env.document.defaultView||this.env.document.parentWindow||window,this.env.frame=this.env.window.frameElement,this.env.selection=this.selection=new ice.Selection(this.env),this.env.document.createElement(this.changeTypes.insertType.tag),this.env.document.createElement(this.changeTypes.deleteType.tag)},initializeRange:function(){var e=this.selection.createRange();e.setStart(ice.dom.find(this.element,this.blockEls.join(", "))[0],0),e.collapse(!0),this.selection.addRange(e),this.env.frame?this.env.frame.contentWindow.focus():this.element.focus()},initializeEditor:function(){var e=this,t=this.env.document.createElement("div");this.element.childNodes.length?(t.innerHTML=this.element.innerHTML,ice.dom.removeWhitespace(t),""===t.innerHTML&&t.appendChild(ice.dom.create("<"+this.blockEl+" >
"+this.blockEl+">"))):t.appendChild(ice.dom.create("<"+this.blockEl+" >
"+this.blockEl+">")),this.element.innerHTML=t.innerHTML;var n=[];for(var i in this.changeTypes)n.push(this._getIceNodeClass(i));ice.dom.each(ice.dom.find(this.element,"."+n.join(", .")),function(t,i){for(var r=0,o="",s=i.className.split(" "),t=0;s.length>t;t++){var a=RegExp(e.stylePrefix+"-(\\d+)").exec(s[t]);a&&(r=a[1]);var c=RegExp("("+n.join("|")+")").exec(s[t]);c&&(o=e._getChangeTypeFromAlias(c[1]))}var l=ice.dom.attr(i,e.userIdAttribute);e.setUserStyle(l,Number(r));var d=ice.dom.attr(i,e.changeIdAttribute);e._changes[d]={type:o,userid:l,username:ice.dom.attr(i,e.userNameAttribute),time:ice.dom.attr(i,e.timeAttribute)}})},enableChangeTracking:function(){this.isTracking=!0,this.pluginsManager.fireEnabled(this.element)},disableChangeTracking:function(){this.isTracking=!1,this.pluginsManager.fireDisabled(this.element)},setCurrentUser:function(e){this.currentUser=e},handleEvent:function(e){if(this.isTracking)if("mouseup"==e.type){var t=this;setTimeout(function(){t.mouseUp(e)},200)}else{if("mousedown"==e.type)return this.mouseDown(e);if("keypress"==e.type){var n=this.keyPress(e);return n||e.preventDefault(),n}if("keydown"==e.type){var n=this.keyDown(e);return n||e.preventDefault(),n}"keyup"==e.type&&this.pluginsManager.fireCaretUpdated()}},visible:function(e){e.nodeType===ice.dom.TEXT_NODE&&(e=e.parentNode);var t=e.getBoundingClientRect();return t.top>0&&t.left>0},createIceNode:function(e,t){var n=this.env.document.createElement(this.changeTypes[e].tag);return ice.dom.addClass(n,this._getIceNodeClass(e)),n.appendChild(t?t:this.env.document.createTextNode("")),this.addChange(this.changeTypes[e].alias,[n]),this.pluginsManager.fireNodeCreated(n,{action:this.changeTypes[e].action}),n},insert:function(e,t){var n=!e;if(e||(e=""),t?this.selection.addRange(t):t=this.getCurrentRange(),"string"==typeof e&&(e=document.createTextNode(e)),!t.collapsed&&(this.deleteContents(),t=this.getCurrentRange(),t.startContainer===t.endContainer&&this.element===t.startContainer)){ice.dom.empty(this.element);var i=t.getLastSelectableChild(this.element);t.setStartAfter(i),t.collapse(!0)}this._moveRangeToValidTrackingPos(t);var r=this.startBatchChange();return this._insertNode(e,t,n),this.pluginsManager.fireNodeInserted(e,t),this.endBatchChange(r),n},placeholdDeletes:function(){var e=this;this.isPlaceholdingDeletes&&this.revertDeletePlaceholders(),this.isPlaceholdingDeletes=!0,this._deletes=[];var t="."+this._getIceNodeClass("deleteType");return ice.dom.each(ice.dom.find(this.element,t),function(t,n){e._deletes.push(ice.dom.cloneNode(n)),ice.dom.replaceWith(n,"<"+e._delBookmark+' data-allocation="'+(e._deletes.length-1)+'"/>')}),!0},revertDeletePlaceholders:function(){var e=this;return this.isPlaceholdingDeletes?(ice.dom.each(this._deletes,function(t,n){ice.dom.find(e.element,e._delBookmark+"[data-allocation="+t+"]").replaceWith(n)}),this.isPlaceholdingDeletes=!1,!0):!1},deleteContents:function(e,t){var n=!0,i=ice.dom.browser();t?this.selection.addRange(t):t=this.getCurrentRange();var r=this.startBatchChange(this.changeTypes.deleteType.alias);if(t.collapsed===!1)this._currentUserIceNode(t.startContainer.parentNode)?this._deleteSelection(t):(this._deleteSelection(t),"mozilla"===i.type?(t.startContainer.parentNode.previousSibling?(t.setEnd(t.startContainer.parentNode.previousSibling,0),t.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(t.endContainer))):t.setEndAfter(t.startContainer.parentNode),t.collapse(!1)):this.visible(t.endContainer)||(t.setEnd(t.endContainer,t.endOffset-1),t.collapse(!1)));else if(e)if("mozilla"===i.type)n=this._deleteRight(t),this.visible(t.endContainer)||(t.endContainer.parentNode.nextSibling?t.setEndBefore(t.endContainer.parentNode.nextSibling):t.setEndAfter(t.endContainer),t.collapse(!1));else{if(t.endOffset===ice.dom.getNodeCharacterLength(t.endContainer)){var o=t.startContainer.nextSibling;if(ice.dom.is(o,"."+this._getIceNodeClass("deleteType")))for(;o;){if(!ice.dom.is(o,"."+this._getIceNodeClass("deleteType"))){t.setStart(o,0),t.collapse(!0);break}o=o.nextSibling}}n=this._deleteRight(t),this.visible(t.endContainer)||ice.dom.is(t.endContainer.parentNode,"."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType"))&&(t.setStartAfter(t.endContainer.parentNode),t.collapse(!0))}else if("mozilla"===i.type)n=this._deleteLeft(t),this.visible(t.startContainer)||(t.startContainer.parentNode.previousSibling?t.setEnd(t.startContainer.parentNode.previousSibling,0):t.setEnd(t.startContainer.parentNode,0),t.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(t.endContainer)),t.collapse(!1));else{if(!this.visible(t.startContainer)&&t.endOffset===ice.dom.getNodeCharacterLength(t.endContainer)){var s=t.startContainer.previousSibling;if(ice.dom.is(s,"."+this._getIceNodeClass("deleteType")))for(;s;){if(!ice.dom.is(s,"."+this._getIceNodeClass("deleteType"))){t.setEndBefore(s.nextSibling,0),t.collapse(!1);break}s=s.prevSibling}}n=this._deleteLeft(t)}return this.selection.addRange(t),this.endBatchChange(r),n},getChanges:function(){return this._changes},getChangeUserids:function(){var e=[],t=Object.keys(this._changes);for(var n in t)e.push(this._changes[t[n]].userid);return e.sort().filter(function(e,t,n){return t==n.indexOf(e)?1:0})},getElementContent:function(){return this.element.innerHTML},getCleanContent:function(e,t,n){var i="",r=this;ice.dom.each(this.changeTypes,function(e,t){"deleteType"!=e&&(t>0&&(i+=","),i+="."+r._getIceNodeClass(e))}),e=e?"string"==typeof e?ice.dom.create(""+e+"
"):ice.dom.cloneNode(e,!1)[0]:ice.dom.cloneNode(this.element,!1)[0],e=n?n.call(this,e):e;var o=ice.dom.find(e,i);ice.dom.each(o,function(){ice.dom.replaceWith(this,ice.dom.contents(this))});var s=ice.dom.find(e,"."+this._getIceNodeClass("deleteType"));return ice.dom.remove(s),e=t?t.call(this,e):e,e.innerHTML},acceptAll:function(){this.element.innerHTML=this.getCleanContent()},rejectAll:function(){var e="."+this._getIceNodeClass("insertType"),t="."+this._getIceNodeClass("deleteType");ice.dom.remove(ice.dom.find(this.element,e)),ice.dom.each(ice.dom.find(this.element,t),function(e,t){ice.dom.replaceWith(t,ice.dom.contents(t))})},acceptChange:function(e){this.acceptRejectChange(e,!0)},rejectChange:function(e){this.acceptRejectChange(e,!1)},acceptRejectChange:function(e,t){var n,i,r,o,s,a,c,l=ice.dom;if(!e){var d=this.getCurrentRange();if(!d.collapsed)return;e=d.startContainer}n=o="."+this._getIceNodeClass("deleteType"),i=s="."+this._getIceNodeClass("insertType"),r=n+","+i,a=l.getNode(e,r),c=l.find(this.element,"["+this.changeIdAttribute+"="+l.attr(a,this.changeIdAttribute)+"]"),t||(o=i,s=n),ice.dom.is(a,s)?l.each(c,function(e,t){l.replaceWith(t,ice.dom.contents(t))}):l.is(a,o)&&l.remove(c)},isInsideChange:function(e){var t="."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType");if(!e){if(range=this.getCurrentRange(),!range.collapsed)return!1;e=range.startContainer}return!!ice.dom.getNode(e,t)},addChangeType:function(e,t,n,i){var r={tag:t,alias:n};i&&(r.action=i),this.changeTypes[e]=r},getIceNode:function(e,t){var n="."+this._getIceNodeClass(t);return ice.dom.getNode(e,n)},_moveRangeToValidTrackingPos:function(e){for(var t=!1,n=this._getVoidElement(e.endContainer);n;){try{e.moveEnd(ice.dom.CHARACTER_UNIT,1),e.moveEnd(ice.dom.CHARACTER_UNIT,-1)}catch(i){t=!0}if(t||ice.dom.onBlockBoundary(e.endContainer,e.startContainer,this.blockEls)){e.setStartAfter(n),e.collapse(!0);break}n=this._getVoidElement(e.endContainer),n?(e.setEnd(e.endContainer,0),e.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(e.endContainer)),e.collapse()):(e.setStart(e.endContainer,0),e.collapse(!0))}},_getNoTrackElement:function(e){var t=this._getNoTrackSelector(),n=ice.dom.is(e,t)?e:ice.dom.parents(e,t)[0]||null;return n},_getNoTrackSelector:function(){return this.noTrack},_getVoidElement:function(e){var t=this._getVoidElSelector();return ice.dom.is(e,t)?e:ice.dom.parents(e,t)[0]||null},_getVoidElSelector:function(){return"."+this._getIceNodeClass("deleteType")+","+this.avoid},_currentUserIceNode:function(e){return ice.dom.attr(e,this.userIdAttribute)==this.currentUser.id},_getChangeTypeFromAlias:function(e){var t,n=null;for(t in this.changeTypes)this.changeTypes.hasOwnProperty(t)&&this.changeTypes[t].alias==e&&(n=t);return n},_getIceNodeClass:function(e){return this.attrValuePrefix+this.changeTypes[e].alias},getUserStyle:function(e){var t=null;return t=this._userStyles[e]?this._userStyles[e]:this.setUserStyle(e,this.getNewStyleId())},setUserStyle:function(e,t){var n=this.stylePrefix+"-"+t;return this._styles[t]||(this._styles[t]=!0),this._userStyles[e]=n},getNewStyleId:function(){var e=++this._uniqueStyleIndex;return this._styles[e]?this.getNewStyleId():(this._styles[e]=!0,e)},addChange:function(e,t){var n=this._batchChangeid||this.getNewChangeId();this._changes[n]||(this._changes[n]={type:this._getChangeTypeFromAlias(e),time:(new Date).getTime(),userid:this.currentUser.id,username:this.currentUser.name});var i=this;return ice.dom.foreach(t,function(e){i.addNodeToChange(n,t[e])}),n},addNodeToChange:function(e,t){null!==this._batchChangeid&&(e=this._batchChangeid);var n=this.getChange(e);t.getAttribute(this.changeIdAttribute)||t.setAttribute(this.changeIdAttribute,e),t.getAttribute(this.userIdAttribute)||t.setAttribute(this.userIdAttribute,n.userid),t.getAttribute(this.userNameAttribute)||t.setAttribute(this.userNameAttribute,n.username),t.getAttribute(this.timeAttribute)||t.setAttribute(this.timeAttribute,n.time),ice.dom.hasClass(t,this._getIceNodeClass(n.type))||ice.dom.addClass(t,this._getIceNodeClass(n.type));var i=this.getUserStyle(n.userid);ice.dom.hasClass(t,i)||ice.dom.addClass(t,i)},getChange:function(e){var t=null;return this._changes[e]&&(t=this._changes[e]),t},getNewChangeId:function(){var e=++this._uniqueIDIndex;return this._changes[e]&&(e=this.getNewChangeId()),e},startBatchChange:function(){return this._batchChangeid=this.getNewChangeId(),this._batchChangeid},endBatchChange:function(e){e===this._batchChangeid&&(this._batchChangeid=null)},getCurrentRange:function(){return this.selection.getRangeAt(0)},_insertNode:function(e,t,n){ice.dom.isBlockElement(t.startContainer)||ice.dom.canContainTextElement(ice.dom.getBlockParent(t.startContainer,this.element))||!t.startContainer.previousSibling||t.setStart(t.startContainer.previousSibling,0),t.startContainer;var i=ice.dom.isBlockElement(t.startContainer)&&t.startContainer||ice.dom.getBlockParent(t.startContainer,this.element)||null;if(i===this.element){var r=document.createElement(this.blockEl);return i.appendChild(r),t.setStart(r,0),t.collapse(),this._insertNode(e,t,n)}ice.dom.hasNoTextOrStubContent(i)&&(ice.dom.empty(i),ice.dom.append(i,"
"),t.setStart(i,0));var o=this.getIceNode(t.startContainer,"insertType"),s=this._currentUserIceNode(o);n&&s||(s||(e=this.createIceNode("insertType",e)),t.insertNode(e),t.setEnd(e,1),n?t.setStart(e,0):t.collapse(),this.selection.addRange(t))},_handleVoidEl:function(e,t){var n=this._getVoidElement(e);return n&&!this.getIceNode(n,"deleteType")?(t.collapse(!0),!0):!1},_deleteSelection:function(e){for(var t=new ice.Bookmark(this.env,e),n=ice.dom.getElementsBetween(t.start,t.end),i=ice.dom.parents(e.startContainer,this.blockEls.join(", "))[0],r=ice.dom.parents(e.endContainer,this.blockEls.join(", "))[0],o=[],s=0;n.length>s;s++){var a=n[s];if(!ice.dom.isBlockElement(a)||(o.push(a),ice.dom.canContainTextElement(a))){if((a.nodeType!==ice.dom.TEXT_NODE||0!==ice.dom.getNodeTextContent(a).length)&&!this._getVoidElement(a)){if(a.nodeType!==ice.dom.TEXT_NODE){if(ice.dom.BREAK_ELEMENT==ice.dom.getTagName(a))continue;if(ice.dom.isStubElement(a)){this._addNodeTracking(a,!1,!0);continue}for(ice.dom.hasNoTextOrStubContent(a)&&ice.dom.remove(a),j=0;a.childNodes.length>j;j++){var c=a.childNodes[j];n.push(c)}continue}var l=ice.dom.getBlockParent(a);this._addNodeTracking(a,!1,!0,!0),ice.dom.hasNoTextOrStubContent(l)&&ice.dom.remove(l)}}else for(var d=0;a.childNodes.length>d;d++)n.push(a.childNodes[d])}if(this.mergeBlocks&&i!==r){for(;o.length;)ice.dom.mergeContainers(o.shift(),i);ice.dom.removeBRFromChild(r),ice.dom.removeBRFromChild(i),ice.dom.mergeContainers(r,i)}t.selectBookmark(),e.collapse(!0)},_deleteRight:function(e){var t,n,i=ice.dom.isBlockElement(e.startContainer)&&e.startContainer||ice.dom.getBlockParent(e.startContainer,this.element)||null,r=i?ice.dom.hasNoTextOrStubContent(i):!1,o=i&&ice.dom.getNextContentNode(i,this.element),s=o?ice.dom.hasNoTextOrStubContent(o):!1,a=e.endContainer,c=e.endOffset,l=e.commonAncestorContainer;if(r)return!1;if(l.nodeType!==ice.dom.TEXT_NODE){if(0===c&&ice.dom.isBlockElement(l)&&!ice.dom.canContainTextElement(l)){var d=l.firstElementChild;if(d)return e.setStart(d,0),e.collapse(),this._deleteRight(e)}if(l.childNodes.length>c){var h=document.createTextNode(" ");return l.insertBefore(h,l.childNodes[c]),e.setStart(h,1),e.collapse(!0),n=this._deleteRight(e),ice.dom.remove(h),n}return t=ice.dom.getNextContentNode(l,this.element),e.setEnd(t,0),e.collapse(),this._deleteRight(e)}if(e.moveEnd(ice.dom.CHARACTER_UNIT,1),e.moveEnd(ice.dom.CHARACTER_UNIT,-1),c===a.data.length&&!ice.dom.hasNoTextOrStubContent(a)){if(t=ice.dom.getNextNode(a,this.element),!t)return e.selectNodeContents(a),e.collapse(),!1;if(ice.dom.BREAK_ELEMENT==ice.dom.getTagName(t)&&(t=ice.dom.getNextNode(t,this.element)),t.nodeType===ice.dom.TEXT_NODE&&(t=t.parentNode),!t.isContentEditable){n=this._addNodeTracking(t,!1,!1);var u=document.createTextNode("");return t.parentNode.insertBefore(u,t.nextSibling),e.selectNode(u),e.collapse(!0),n}if(this._handleVoidEl(t,e))return!0;if(ice.dom.isChildOf(t,i)&&ice.dom.isStubElement(t))return this._addNodeTracking(t,e,!1)}if(this._handleVoidEl(t,e))return!0;if(this._getNoTrackElement(e.endContainer.parentElement))return e.deleteContents(),!1;if(ice.dom.isOnBlockBoundary(e.startContainer,e.endContainer,this.element)){if(this.mergeBlocks&&ice.dom.is(ice.dom.getBlockParent(t,this.element),this.blockEl)){o!==ice.dom.getBlockParent(e.endContainer,this.element)&&e.setEnd(o,0);for(var f=ice.dom.getElementsBetween(e.startContainer,e.endContainer),g=0;f.length>g;g++)ice.dom.remove(f[g]);var m=e.startContainer,p=e.endContainer;return ice.dom.remove(ice.dom.find(m,"br")),ice.dom.remove(ice.dom.find(p,"br")),ice.dom.mergeBlockWithSibling(e,ice.dom.getBlockParent(e.endContainer,this.element)||i)}return s?(ice.dom.remove(o),e.collapse(!0),!0):(e.setStart(o,0),e.collapse(!0),!0)}var C=e.endContainer,v=C.splitText(e.endOffset);return v.splitText(1),this._addNodeTracking(v,e,!1)},_deleteLeft:function(e){var t,n,i=ice.dom.isBlockElement(e.startContainer)&&e.startContainer||ice.dom.getBlockParent(e.startContainer,this.element)||null,r=i?ice.dom.hasNoTextOrStubContent(i):!1,o=i&&ice.dom.getPrevContentNode(i,this.element),s=o?ice.dom.hasNoTextOrStubContent(o):!1,a=e.startContainer,c=e.startOffset,l=e.commonAncestorContainer;if(r)return!1;if(0===c||l.nodeType!==ice.dom.TEXT_NODE){if(ice.dom.isBlockElement(l)&&!ice.dom.canContainTextElement(l))if(0===c){var d=l.firstElementChild;if(d)return e.setStart(d,0),e.collapse(),this._deleteLeft(e)}else{var h=l.lastElementChild;if(h&&(t=e.getLastSelectableChild(h)))return e.setStart(t,t.data.length),e.collapse(),this._deleteLeft(e)}if(n=0===c?ice.dom.getPrevContentNode(a,this.element):l.childNodes[c-1],!n)return!1;if(ice.dom.is(n,"."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType"))&&n.childNodes.length>0&&n.lastChild&&(n=n.lastChild),n.nodeType===ice.dom.TEXT_NODE&&(n=n.parentNode),!n.isContentEditable){var u=this._addNodeTracking(n,!1,!0),f=document.createTextNode("");return n.parentNode.insertBefore(f,n),e.selectNode(f),e.collapse(!0),u}if(this._handleVoidEl(n,e))return!0;if(ice.dom.isStubElement(n)&&ice.dom.isChildOf(n,i)||!n.isContentEditable)return this._addNodeTracking(n,e,!0);if(ice.dom.isStubElement(n))return ice.dom.remove(n),e.collapse(!0),!1;if(n!==i&&!ice.dom.isChildOf(n,i)){if(ice.dom.canContainTextElement(n)||(n=n.lastElementChild),n.lastChild&&n.lastChild.nodeType!==ice.dom.TEXT_NODE&&ice.dom.isStubElement(n.lastChild)&&"BR"!==n.lastChild.tagName)return e.setStartAfter(n.lastChild),e.collapse(!0),!0;if(t=e.getLastSelectableChild(n),t&&!ice.dom.isOnBlockBoundary(e.startContainer,t,this.element))return e.selectNodeContents(t),e.collapse(),!0}}if(1===c&&!ice.dom.isBlockElement(l)&&e.startContainer.childNodes.length>1&&e.startContainer.childNodes[0].nodeType===ice.dom.TEXT_NODE&&0===e.startContainer.childNodes[0].data.length)return e.setStart(e.startContainer,0),this._deleteLeft(e);if(e.moveStart(ice.dom.CHARACTER_UNIT,-1),e.moveStart(ice.dom.CHARACTER_UNIT,1),this._getNoTrackElement(e.startContainer.parentElement))return e.deleteContents(),!1;if(ice.dom.isOnBlockBoundary(e.startContainer,e.endContainer,this.element)){if(s)return ice.dom.remove(o),e.collapse(),!0;if(this.mergeBlocks&&ice.dom.is(ice.dom.getBlockParent(n,this.element),this.blockEl)){o!==ice.dom.getBlockParent(e.startContainer,this.element)&&e.setStart(o,o.childNodes.length);for(var g=ice.dom.getElementsBetween(e.startContainer,e.endContainer),m=0;g.length>m;m++)ice.dom.remove(g[m]);var p=e.startContainer,C=e.endContainer;return ice.dom.remove(ice.dom.find(p,"br")),ice.dom.remove(ice.dom.find(C,"br")),ice.dom.mergeBlockWithSibling(e,ice.dom.getBlockParent(e.endContainer,this.element)||i)}return o&&o.lastChild&&ice.dom.isStubElement(o.lastChild)?(e.setStartAfter(o.lastChild),e.collapse(!0),!0):(t=e.getLastSelectableChild(o),t?(e.setStart(t,t.data.length),e.collapse(!0)):o&&(e.setStart(o,o.childNodes.length),e.collapse(!0)),!0)}var v=e.startContainer,N=v.splitText(e.startOffset-1);return N.splitText(1),this._addNodeTracking(N,e,!0)},_addNodeTracking:function(e,t,n){var i=this.getIceNode(e,"insertType");if(i&&this._currentUserIceNode(i)){t&&n&&t.selectNode(e),e.parentNode.removeChild(e);var r=ice.dom.cloneNode(i);if(ice.dom.remove(ice.dom.find(r,".iceBookmark")),null!==i&&ice.dom.hasNoTextOrStubContent(r[0])){var o=this.env.document.createTextNode("");ice.dom.insertBefore(i,o),t&&(t.setStart(o,0),t.collapse(!0)),ice.dom.replaceWith(i,ice.dom.contents(i))}return!0}if(t&&this.getIceNode(e,"deleteType")){e.normalize();var s=!1;if(n){for(var a=ice.dom.getPrevContentNode(e,this.element);!s;)d=this.getIceNode(a,"deleteType"),d?a=ice.dom.getPrevContentNode(a,this.element):s=!0;if(a){var c=t.getLastSelectableChild(a);c&&(a=c),t.setStart(a,ice.dom.getNodeCharacterLength(a)),t.collapse(!0)}return!0}for(var l=ice.dom.getNextContentNode(e,this.element);!s;)d=this.getIceNode(l,"deleteType"),d?l=ice.dom.getNextContentNode(l,this.element):s=!0;return l&&(t.selectNodeContents(l),t.collapse(!0)),!0}e.previousSibling&&e.previousSibling.nodeType===ice.dom.TEXT_NODE&&0===e.previousSibling.length&&e.parentNode.removeChild(e.previousSibling),e.nextSibling&&e.nextSibling.nodeType===ice.dom.TEXT_NODE&&0===e.nextSibling.length&&e.parentNode.removeChild(e.nextSibling);
-var d,h=this.getIceNode(e.previousSibling,"deleteType"),u=this.getIceNode(e.nextSibling,"deleteType");if(h&&this._currentUserIceNode(h)){if(d=h,d.appendChild(e),u&&this._currentUserIceNode(u)){var f=ice.dom.extractContent(u);ice.dom.append(d,f),u.parentNode.removeChild(u)}}else u&&this._currentUserIceNode(u)?(d=u,d.insertBefore(e,d.firstChild)):(d=this.createIceNode("deleteType"),e.parentNode.insertBefore(d,e),d.appendChild(e));return t&&(ice.dom.isStubElement(e)?t.selectNode(e):t.selectNodeContents(e),n?t.collapse(!0):t.collapse(),e.normalize()),!0},_handleAncillaryKey:function(e){var t=e.keyCode?e.keyCode:e.which,n=ice.dom.browser(),i=!0;e.shiftKey;var r=this,o=r.getCurrentRange();switch(t){case ice.dom.DOM_VK_DELETE:i=this.deleteContents(),this.pluginsManager.fireKeyPressed(e);break;case 46:i=this.deleteContents(!0),this.pluginsManager.fireKeyPressed(e);break;case ice.dom.DOM_VK_DOWN:case ice.dom.DOM_VK_UP:case ice.dom.DOM_VK_LEFT:this.pluginsManager.fireCaretPositioned(),"mozilla"===n.type&&(this.visible(o.startContainer)||(o.startContainer.parentNode.previousSibling?(o.setEnd(o.startContainer.parentNode.previousSibling,0),o.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(o.endContainer)),o.collapse(!1)):(o.setEnd(o.startContainer.parentNode.nextSibling,0),o.collapse(!1)))),i=!1;break;case ice.dom.DOM_VK_RIGHT:this.pluginsManager.fireCaretPositioned(),"mozilla"===n.type&&(this.visible(o.startContainer)||o.startContainer.parentNode.nextSibling&&(o.setStart(o.startContainer.parentNode.nextSibling,0),o.collapse(!0))),i=!1;break;case 32:i=!0;var o=this.getCurrentRange();this._moveRangeToValidTrackingPos(o,o.startContainer),this.insert("Â ",o);break;default:i=!1}return i===!0?(ice.dom.preventDefault(e),!1):!0},keyDown:function(e){if(!this.pluginsManager.fireKeyDown(e))return ice.dom.preventDefault(e),!1;var t=!1;if(this._handleSpecialKey(e)===!1)return ice.dom.isBrowser("msie")!==!0&&(this._preventKeyPress=!0),!1;if(!(e.ctrlKey!==!0&&e.metaKey!==!0||ice.dom.isBrowser("msie")!==!0&&ice.dom.isBrowser("chrome")!==!0||this.pluginsManager.fireKeyPressed(e)))return!1;switch(e.keyCode){case 27:break;default:/Firefox/.test(navigator.userAgent)!==!0&&(t=!this._handleAncillaryKey(e))}return t?(ice.dom.preventDefault(e),!1):!0},keyPress:function(e){if(this._preventKeyPress===!0)return this._preventKeyPress=!1,void 0;var t=null;if(null==e.which?t=String.fromCharCode(e.keyCode):e.which>0&&(t=String.fromCharCode(e.which)),!this.pluginsManager.fireKeyPress(e))return!1;if(e.ctrlKey||e.metaKey)return!0;var n=this.getCurrentRange(),i=ice.dom.parents(n.startContainer,"br")[0]||null;if(i&&(n.moveToNextEl(i),i.parentNode.removeChild(i)),null!==t&&e.ctrlKey!==!0&&e.metaKey!==!0){var r=e.keyCode?e.keyCode:e.which;switch(r){case ice.dom.DOM_VK_DELETE:return this._handleAncillaryKey(e);case ice.dom.DOM_VK_ENTER:return this._handleEnter();case 32:return this._handleAncillaryKey(e);default:return this._moveRangeToValidTrackingPos(n,n.startContainer),this.insert()}}return this._handleAncillaryKey(e)},_handleEnter:function(){var e=this.getCurrentRange();return e.collapsed||this.deleteContents(),!0},_handleSpecialKey:function(e){var t=e.which;null===t&&(t=e.keyCode);var n=!1;switch(t){case 65:if(e.ctrlKey===!0||e.metaKey===!0){n=!0;var i=this.getCurrentRange();if(ice.dom.isBrowser("msie")===!0){var r=this.env.document.createTextNode(""),o=this.env.document.createTextNode("");this.element.firstChild?ice.dom.insertBefore(this.element.firstChild,r):this.element.appendChild(r),this.element.appendChild(o),i.setStart(r,0),i.setEnd(o,0)}else{i.setStart(i.getFirstSelectableChild(this.element),0);var s=i.getLastSelectableChild(this.element);i.setEnd(s,s.length)}this.selection.addRange(i)}break;default:}return n===!0?(ice.dom.preventDefault(e),!1):!0},mouseUp:function(e){return this.pluginsManager.fireClicked(e)?(this.pluginsManager.fireSelectionChanged(this.getCurrentRange()),void 0):!1},mouseDown:function(e){return this.pluginsManager.fireMouseDown(e)?(this.pluginsManager.fireCaretUpdated(),void 0):!1}},n.ice=this.ice||{},n.ice.InlineChangeEditor=t}.call(this),function(){var e=this,t={};t.DOM_VK_DELETE=8,t.DOM_VK_LEFT=37,t.DOM_VK_UP=38,t.DOM_VK_RIGHT=39,t.DOM_VK_DOWN=40,t.DOM_VK_ENTER=13,t.ELEMENT_NODE=1,t.ATTRIBUTE_NODE=2,t.TEXT_NODE=3,t.CDATA_SECTION_NODE=4,t.ENTITY_REFERENCE_NODE=5,t.ENTITY_NODE=6,t.PROCESSING_INSTRUCTION_NODE=7,t.COMMENT_NODE=8,t.DOCUMENT_NODE=9,t.DOCUMENT_TYPE_NODE=10,t.DOCUMENT_FRAGMENT_NODE=11,t.NOTATION_NODE=12,t.CHARACTER_UNIT="character",t.WORD_UNIT="word",t.BREAK_ELEMENT="br",t.CONTENT_STUB_ELEMENTS=["img","hr","iframe","param","link","meta","input","frame","col","base","area"],t.BLOCK_ELEMENTS=["p","div","pre","ul","ol","li","table","tbody","td","th","fieldset","form","blockquote","dl","dt","dd","dir","center","address","h1","h2","h3","h4","h5","h6"],t.TEXT_CONTAINER_ELEMENTS=["p","div","pre","li","td","th","blockquote","dt","dd","center","address","h1","h2","h3","h4","h5","h6"],t.STUB_ELEMENTS=t.CONTENT_STUB_ELEMENTS.slice(),t.STUB_ELEMENTS.push(t.BREAK_ELEMENT),t.getKeyChar=function(e){return String.fromCharCode(e.which)},t.getClass=function(e,t,n){return t||(t=document.body),e="."+e.split(" ").join("."),n&&(e=n+e),jQuery.makeArray(jQuery(t).find(e))},t.getId=function(e,t){return t||(t=document),element=t.getElementById(e)},t.getTag=function(e,t){return t||(t=document),jQuery.makeArray(jQuery(t).find(e))},t.getElementWidth=function(e){return e.offsetWidth},t.getElementHeight=function(e){return e.offsetHeight},t.getElementDimensions=function(e){var n={width:t.getElementWidth(e),height:t.getElementHeight(e)};return n},t.trim=function(e){return jQuery.trim(e)},t.empty=function(e){return e?jQuery(e).empty():void 0},t.remove=function(e){return e?jQuery(e).remove():void 0},t.prepend=function(e,t){jQuery(e).prepend(t)},t.append=function(e,t){jQuery(e).append(t)},t.insertBefore=function(e,t){jQuery(e).before(t)},t.insertAfter=function(e,t){jQuery(e).after(t)},t.getHtml=function(e){return jQuery(e).html()},t.setHtml=function(e,t){e&&jQuery(e).html(t)},t.removeWhitespace=function(e){jQuery(e).contents().filter(function(){return this.nodeType!=ice.dom.TEXT_NODE&&"UL"==this.nodeName||"OL"==this.nodeName?(t.removeWhitespace(this),!1):this.nodeType!=ice.dom.TEXT_NODE?!1:!/\S/.test(this.nodeValue)}).remove()},t.contents=function(e){return jQuery.makeArray(jQuery(e).contents())},t.extractContent=function(e){for(var t,n=document.createDocumentFragment();t=e.firstChild;)n.appendChild(t);return n},t.getNode=function(e,n){return t.is(e,n)?e:t.parents(e,n)[0]||null},t.getParents=function(e,t,n){for(var i=jQuery(e).parents(t),r=i.length,o=[],s=0;r>s&&i[s]!==n;s++)o.push(i[s]);return o},t.hasBlockChildren=function(e){for(var n=e.childNodes.length,i=0;n>i;i++)if(e.childNodes[i].nodeType===t.ELEMENT_NODE&&t.isBlockElement(e.childNodes[i])===!0)return!0;return!1},t.removeTag=function(e,t){return jQuery(e).find(t).replaceWith(function(){return jQuery(this).contents()}),e},t.stripEnclosingTags=function(e,t){var n=jQuery(e);return n.find("*").not(t).replaceWith(function(){var e,t=jQuery();try{e=jQuery(this),t=e.contents()}catch(n){}return 0===t.length&&e.remove(),t}),n[0]},t.getSiblings=function(e,t,n,i){if(n===!0)return"prev"===t?jQuery(e).prevAll():jQuery(e).nextAll();var r=[];if("prev"===t)for(;e.previousSibling&&(e=e.previousSibling,e!==i);)r.push(e);else for(;e.nextSibling&&(e=e.nextSibling,e!==i);)r.push(e);return r},t.getNodeTextContent=function(e){return jQuery(e).text()},t.getNodeStubContent=function(e){return jQuery(e).find(t.CONTENT_STUB_ELEMENTS.join(", "))},t.hasNoTextOrStubContent=function(e){return t.getNodeTextContent(e).length>0?!1:jQuery(e).find(t.CONTENT_STUB_ELEMENTS.join(", ")).length>0?!1:!0},t.getNodeCharacterLength=function(e){return t.getNodeTextContent(e).length+jQuery(e).find(t.STUB_ELEMENTS.join(", ")).length},t.setNodeTextContent=function(e,t){return jQuery(e).text(t)},t.getTagName=function(e){return e.tagName&&e.tagName.toLowerCase()||null},t.getIframeDocument=function(e){var t=null;return e.contentDocument?t=e.contentDocument:e.contentWindow?t=e.contentWindow.document:e.document&&(t=e.document),t},t.isBlockElement=function(e){return-1!=t.BLOCK_ELEMENTS.lastIndexOf(e.nodeName.toLowerCase())},t.isStubElement=function(e){return-1!=t.STUB_ELEMENTS.lastIndexOf(e.nodeName.toLowerCase())},t.removeBRFromChild=function(e){if(e&&e.hasChildNodes())for(var t=0;e.childNodes.length>t;t++){var n=e.childNodes[t];n&&ice.dom.BREAK_ELEMENT==ice.dom.getTagName(n)&&n.parentNode.removeChild(n)}},t.isChildOf=function(e,t){try{for(;e&&e.parentNode;){if(e.parentNode===t)return!0;e=e.parentNode}}catch(n){}return!1},t.isChildOfTagName=function(e,t){try{for(;e&&e.parentNode;){if(e.parentNode&&e.parentNode.tagName&&e.parentNode.tagName.toLowerCase()===t)return e.parentNode;e=e.parentNode}}catch(n){}return!1},t.isChildOfTagNames=function(e,t){try{for(;e&&e.parentNode;){if(e.parentNode&&e.parentNode.tagName){tagName=e.parentNode.tagName.toLowerCase();for(var n=0;t.length>n;n++)if(tagName===t[n])return e.parentNode}e=e.parentNode}}catch(i){}return null},t.isChildOfClassName=function(e,t){try{for(;e&&e.parentNode;){if(jQuery(e.parentNode).hasClass(t))return e.parentNode;e=e.parentNode}}catch(n){}return null},t.cloneNode=function(e,t){return void 0===t&&(t=!0),jQuery(e).clone(t)},t.bind=function(e,t,n){return jQuery(e).bind(t,n)},t.unbind=function(e,t,n){return jQuery(e).unbind(t,n)},t.attr=function(e,t,n){return n?jQuery(e).attr(t,n):jQuery(e).attr(t)},t.replaceWith=function(e,t){return jQuery(e).replaceWith(t)},t.removeAttr=function(e,t){jQuery(e).removeAttr(t)},t.getElementsBetween=function(e,n){var i=[];if(e===n)return i;if(t.isChildOf(n,e)===!0){for(var r=e.childNodes.length,o=0;r>o&&e.childNodes[o]!==n;o++){if(t.isChildOf(n,e.childNodes[o])===!0)return t.arrayMerge(i,t.getElementsBetween(e.childNodes[o],n));i.push(e.childNodes[o])}return i}for(var s=e.nextSibling;s;){if(t.isChildOf(n,s)===!0)return i=t.arrayMerge(i,t.getElementsBetween(s,n));if(s===n)return i;i.push(s),s=s.nextSibling}for(var a=t.getParents(e),c=t.getParents(n),l=t.arrayDiff(a,c,!0),d=l.length,h=0;d-1>h;h++)i=t.arrayMerge(i,t.getSiblings(l[h],"next"));var u=l[l.length-1];return i=t.arrayMerge(i,t.getElementsBetween(u,n))},t.getCommonAncestor=function(e,n){for(var i=e;i;){if(t.isChildOf(n,i)===!0)return i;i=i.parentNode}return null},t.getNextNode=function(e,n){if(e)for(;e.parentNode;){if(e===n)return null;if(e.nextSibling){if(e.nextSibling.nodeType===t.TEXT_NODE&&0===e.nextSibling.length){e=e.nextSibling;continue}return t.getFirstChild(e.nextSibling)}e=e.parentNode}return null},t.getNextContentNode=function(e,n){if(e)for(;e.parentNode;){if(e===n)return null;if(e.nextSibling&&t.canContainTextElement(t.getBlockParent(e))){if(e.nextSibling.nodeType===t.TEXT_NODE&&0===e.nextSibling.length){e=e.nextSibling;continue}return e.nextSibling}if(e.nextElementSibling)return e.nextElementSibling;e=e.parentNode}return null},t.getPrevNode=function(e,n){if(e)for(;e.parentNode;){if(e===n)return null;if(e.previousSibling){if(e.previousSibling.nodeType===t.TEXT_NODE&&0===e.previousSibling.length){e=e.previousSibling;continue}return t.getLastChild(e.previousSibling)}e=e.parentNode}return null},t.getPrevContentNode=function(e,n){if(e)for(;e.parentNode;){if(e===n)return null;if(e.previousSibling&&t.canContainTextElement(t.getBlockParent(e))){if(e.previousSibling.nodeType===t.TEXT_NODE&&0===e.previousSibling.length){e=e.previousSibling;continue}return e.previousSibling}if(e.previousElementSibling)return e.previousElementSibling;e=e.parentNode}return null},t.canContainTextElement=function(e){return e&&e.nodeName?-1!=t.TEXT_CONTAINER_ELEMENTS.lastIndexOf(e.nodeName.toLowerCase()):!1},t.getFirstChild=function(e){return e.firstChild?e.firstChild.nodeType===t.ELEMENT_NODE?t.getFirstChild(e.firstChild):e.firstChild:e},t.getLastChild=function(e){return e.lastChild?e.lastChild.nodeType===t.ELEMENT_NODE?t.getLastChild(e.lastChild):e.lastChild:e},t.removeEmptyNodes=function(e,n){for(var i=jQuery(e).find(":empty"),r=i.length;r>0;)r--,t.isStubElement(i[r])===!1&&(n&&n.call(this,i[r])===!1||t.remove(i[r]))},t.create=function(e){return jQuery(e)[0]},t.find=function(e,t){return jQuery(e).find(t)},t.children=function(e,t){return jQuery(e).children(t)},t.parent=function(e,t){return jQuery(e).parent(t)[0]},t.parents=function(e,t){return jQuery(e).parents(t)},t.is=function(e,t){return jQuery(e).is(t)},t.extend=function(){return jQuery.extend.apply(this,arguments)},t.walk=function(e,n,i){if(e){i||(i=0);var r=n.call(this,e,i);r!==!1&&(e.childNodes&&e.childNodes.length>0?t.walk(e.firstChild,n,i+1):e.nextSibling?t.walk(e.nextSibling,n,i):e.parentNode&&e.parentNode.nextSibling&&t.walk(e.parentNode.nextSibling,n,i-1))}},t.revWalk=function(e,n){if(e){var i=n.call(this,e);i!==!1&&(e.childNodes&&e.childNodes.length>0?t.walk(e.lastChild,n):e.previousSibling?t.walk(e.previousSibling,n):e.parentNode&&e.parentNode.previousSibling&&t.walk(e.parentNode.previousSibling,n))}},t.setStyle=function(e,t,n){e&&jQuery(e).css(t,n)},t.getStyle=function(e,t){return jQuery(e).css(t)},t.hasClass=function(e,t){return jQuery(e).hasClass(t)},t.addClass=function(e,t){jQuery(e).addClass(t)},t.removeClass=function(e,t){jQuery(e).removeClass(t)},t.preventDefault=function(e){e.preventDefault(),t.stopPropagation(e)},t.stopPropagation=function(e){e.stopPropagation()},t.noInclusionInherits=function(e,n){(n instanceof String||"string"==typeof n)&&(n=window[n]),(e instanceof String||"string"==typeof e)&&(e=window[e]);var i=function(){};if(t.isset(n)===!0)for(value in n.prototype)e.prototype[value]?i.prototype[value]=n.prototype[value]:e.prototype[value]=n.prototype[value];e.prototype&&(i.prototype.constructor=n,e.prototype["super"]=new i)},t.each=function(e,t){jQuery.each(e,function(e,n){t.call(this,e,n)})},t.foreach=function(e,t){if(e instanceof Array||e instanceof NodeList||e.length!==void 0&&e.item!==void 0)for(var n=e.length,i=0;n>i;i++){var r=t.call(this,i,e[i]);if(r===!1)break}else for(var o in e)if(e.hasOwnProperty(o)===!0){var r=t.call(this,o);if(r===!1)break}},t.isBlank=function(e){return!e||/^\s*$/.test(e)?!0:!1},t.isFn=function(e){return"function"==typeof e?!0:!1},t.isObj=function(e){return null!==e&&"object"==typeof e?!0:!1},t.isset=function(e){return e!==void 0&&null!==e?!0:!1},t.isArray=function(e){return jQuery.isArray(e)},t.isNumeric=function(e){var t=e.match(/^\d+$/);return null!==t?!0:!1},t.getUniqueId=function(){var e=(new Date).getTime(),t=Math.ceil(1e6*Math.random()),n=e+""+t;return n.substr(5,18).replace(/,/,"")},t.inArray=function(e,t){for(var n=t.length,i=0;n>i;i++)if(e===t[i])return!0;return!1},t.arrayDiff=function(e,n,i){for(var r=e.length,o=[],s=0;r>s;s++)t.inArray(e[s],n)===!1&&o.push(e[s]);if(i!==!0){r=n.length;for(var s=0;r>s;s++)t.inArray(n[s],e)===!1&&o.push(n[s])}return o},t.arrayMerge=function(e,t){for(var n=t.length,i=0;n>i;i++)e.push(t[i]);return e},t.stripTags=function(e,n){if("string"==typeof n){var i=jQuery(""+e+"
");return i.find("*").not(n).remove(),i.html()}for(var r,o=RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim),s=e;null!=(r=o.exec(e));)(t.isset(n)===!1||t.inArray(r[1],n)!==!0)&&(s=s.replace(r[0],""));return s},t.browser=function(){var e={};return e.version=jQuery.browser.version,jQuery.browser.mozilla===!0?e.type="mozilla":jQuery.browser.msie===!0?e.type="msie":jQuery.browser.opera===!0?e.type="opera":jQuery.browser.webkit===!0&&(e.type="webkit"),e},t.getBrowserType=function(){if(null===this._browserType){for(var e=["msie","firefox","chrome","safari"],t=e.length,n=0;t>n;n++){var i=RegExp(e[n],"i");if(i.test(navigator.userAgent)===!0)return this._browserType=e[n],this._browserType}this._browserType="other"}return this._browserType},t.getWebkitType=function(){if("webkit"!==t.browser().type)return console.log("Not a webkit!"),!1;var e=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0;return e?"safari":"chrome"},t.isBrowser=function(e){return t.browser().type===e},t.getBlockParent=function(e,n){if(t.isBlockElement(e)===!0)return e;if(e)for(;e.parentNode;){if(e=e.parentNode,e===n)return null;if(t.isBlockElement(e)===!0)return e}return null},t.findNodeParent=function(e,n,i){if(e)for(;e.parentNode;){if(e===i)return null;if(t.is(e,n)===!0)return e;e=e.parentNode}return null},t.onBlockBoundary=function(e,n,i){if(!e||!n)return!1;var r=t.isChildOfTagNames(e,i)||t.is(e,i.join(", "))&&e||null,o=t.isChildOfTagNames(n,i)||t.is(n,i.join(", "))&&n||null;return r!==o},t.isOnBlockBoundary=function(e,n,i){if(!e||!n)return!1;var r=t.getBlockParent(e,i)||t.isBlockElement(e,i)&&e||null,o=t.getBlockParent(n,i)||t.isBlockElement(n,i)&&n||null;return r!==o},t.mergeContainers=function(e,n){if(!e||!n)return!1;if(e.nodeType===t.TEXT_NODE||t.isStubElement(e))n.appendChild(e);else if(e.nodeType===t.ELEMENT_NODE){for(;e.firstChild;)n.appendChild(e.firstChild);t.remove(e)}return!0},t.mergeBlockWithSibling=function(e,n,i){var r=i?jQuery(n).next().get(0):jQuery(n).prev().get(0);return i?t.mergeContainers(r,n):t.mergeContainers(n,r),e.collapse(!0),!0},t.date=function(e,n,i){if(null!==n||!i||(n=t.tsIso8601ToTimestamp(i))){for(var r=new Date(n),o=e.split(""),s=o.length,a="",c=0;s>c;c++){var l="",d=o[c];switch(d){case"D":case"l":var h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];l=h[r.getDay()],"D"===d&&(l=l.substring(0,3));break;case"F":case"m":l=r.getMonth()+1,10>l&&(l="0"+l);break;case"M":months=["January","February","March","April","May","June","July","August","September","October","November","December"],l=months[r.getMonth()],"M"===d&&(l=l.substring(0,3));break;case"d":l=r.getDate();break;case"S":l=t.getOrdinalSuffix(r.getDate());break;case"Y":l=r.getFullYear();break;case"y":l=r.getFullYear(),l=(""+l).substring(2);break;case"H":l=r.getHours();break;case"h":l=r.getHours(),0===l?l=12:l>12&&(l-=12);break;case"i":l=t.addNumberPadding(r.getMinutes());break;case"a":l="am",r.getHours()>=12&&(l="pm");break;default:l=d}a+=l}return a}},t.getOrdinalSuffix=function(e){var t="",n=e%100;if(n>=4&&20>=n)t="th";else switch(e%10){case 1:t="st";break;case 2:t="nd";break;case 3:t="rd";break;default:t="th"}return t},t.addNumberPadding=function(e){return 10>e&&(e="0"+e),e},t.tsIso8601ToTimestamp=function(e){var t=/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:Z|(?:([-+])(\d\d)(?::?(\d\d))?)?)?)?)?)?/,n=e.match(RegExp(t));if(n){var i=new Date;i.setDate(n[3]),i.setFullYear(n[1]),i.setMonth(n[2]-1),i.setHours(n[4]),i.setMinutes(n[5]),i.setSeconds(n[6]);var r=60*n[9];"+"===n[8]&&(r*=-1),r-=i.getTimezoneOffset();var o=i.getTime()+1e3*60*r;return o}return null},e.dom=t}.call(this.ice),function(){var e,t=this;e=function(e,t,n){this.env=e,this.element=e.element,this.selection=this.env.selection,n||this.removeBookmarks(this.element);var i=t||this.selection.getRangeAt(0);t=i.cloneRange();var r=t.startContainer;t.endContainer;var o=t.startOffset;t.endOffset;var s;t.collapse(!1);var a=this.env.document.createElement("span");a.style.display="none",ice.dom.setHtml(a," "),ice.dom.addClass(a,"iceBookmark iceBookmark_end"),a.setAttribute("iceBookmark","end"),t.insertNode(a),ice.dom.isChildOf(a,this.element)||this.element.appendChild(a),t.setStart(r,o),t.collapse(!0);var c=this.env.document.createElement("span");c.style.display="none",ice.dom.addClass(c,"iceBookmark iceBookmark_start"),ice.dom.setHtml(c," "),c.setAttribute("iceBookmark","start");try{t.insertNode(c),c.previousSibling===a&&(s=c,c=a,a=s)}catch(l){ice.dom.insertBefore(a,c)}ice.dom.isChildOf(c,this.element)===!1&&(this.element.firstChild?ice.dom.insertBefore(this.element.firstChild,c):this.element.appendChild(c)),a.previousSibling||(s=this.env.document.createTextNode(""),ice.dom.insertBefore(a,s)),c.nextSibling||(s=this.env.document.createTextNode(""),ice.dom.insertAfter(c,s)),i.setStart(c.nextSibling,0),i.setEnd(a.previousSibling,a.previousSibling.length||0),this.start=c,this.end=a},e.prototype={selectBookmark:function(){var e=this.selection.getRangeAt(0),t=null,n=null,i=0,r=null;if(this.start.nextSibling===this.end||0===ice.dom.getElementsBetween(this.start,this.end).length)this.end.nextSibling?t=ice.dom.getFirstChild(this.end.nextSibling):this.start.previousSibling?(t=ice.dom.getFirstChild(this.start.previousSibling),t.nodeType===ice.dom.TEXT_NODE&&(i=t.length)):(this.end.parentNode.appendChild(this.env.document.createTextNode("")),t=ice.dom.getFirstChild(this.end.nextSibling));else{if(this.start.nextSibling)t=ice.dom.getFirstChild(this.start.nextSibling);else{if(!this.start.previousSibling){var o=this.env.document.createTextNode("");ice.dom.insertBefore(this.start,o)}t=ice.dom.getLastChild(this.start.previousSibling),i=t.length}this.end.previousSibling?n=ice.dom.getLastChild(this.end.previousSibling):(n=ice.dom.getFirstChild(this.end.nextSibling||this.end),r=0)}ice.dom.remove([this.start,this.end]),null===n?(e.setEnd(t,i),e.collapse(!1)):(e.setStart(t,i),null===r&&(r=n.length||0),e.setEnd(n,r));try{this.selection.addRange(e)}catch(s){}},getBookmark:function(e,t){var n=ice.dom.getClass("iceBookmark_"+t,e)[0];return n},removeBookmarks:function(e){ice.dom.remove(ice.dom.getClass("iceBookmark",e,"span"))}},t.Bookmark=e}.call(this.ice),function(){var e,t=this;e=function(e){this._selection=null,this.env=e,this._initializeRangeLibrary(),this._getSelection()},e.prototype={_getSelection:function(){return this._selection?this._selection.refresh():this._selection=this.env.frame?rangy.getIframeSelection(this.env.frame):rangy.getSelection(),this._selection},createRange:function(){return rangy.createRange(this.env.document)},getRangeAt:function(e){this._selection.refresh();try{return this._selection.getRangeAt(e)}catch(t){return this._selection=null,this._getSelection().getRangeAt(0)}},addRange:function(e){this._selection||(this._selection=this._getSelection()),this._selection.setSingleRange(e),this._selection.ranges=[e]},_initializeRangeLibrary:function(){var e=this;rangy.init(),rangy.config.checkSelectionRanges=!1;var t=function(e,t,n,i){if(0!==n)switch(t){case ice.dom.CHARACTER_UNIT:n>0?e.moveCharRight(i,n):e.moveCharLeft(i,-1*n);break;case ice.dom.WORD_UNIT:default:}};rangy.rangePrototype.moveStart=function(e,n){t(this,e,n,!0)},rangy.rangePrototype.moveEnd=function(e,n){t(this,e,n,!1)},rangy.rangePrototype.setRange=function(e,t,n){e?this.setStart(t,n):this.setEnd(t,n)},rangy.rangePrototype.moveCharLeft=function(e,t){var n,i;if(e?(n=this.startContainer,i=this.startOffset):(n=this.endContainer,i=this.endOffset),n.nodeType===ice.dom.ELEMENT_NODE)if(n.hasChildNodes()){for(n=n.childNodes[i],n=this.getPreviousTextNode(n);n&&n.nodeType==ice.dom.TEXT_NODE&&""===n.nodeValue;)n=this.getPreviousTextNode(n);i=n.data.length-t}else i=-1*t;else i-=t;if(0>i)for(;0>i;){var r=[];if(n=this.getPreviousTextNode(n,r),!n)return;n.nodeType!==ice.dom.ELEMENT_NODE&&(i+=n.data.length)}this.setRange(e,n,i)},rangy.rangePrototype.moveCharRight=function(e,t){var n,i;e?(n=this.startContainer,i=this.startOffset):(n=this.endContainer,i=this.endOffset),n.nodeType===ice.dom.ELEMENT_NODE?(n=n.childNodes[i],n.nodeType!==ice.dom.TEXT_NODE&&(n=this.getNextTextNode(n)),i=t):i+=t;var r=i-n.data.length;if(r>0){for(var o=[];r>0;)if(n=this.getNextContainer(n,o),n.nodeType!==ice.dom.ELEMENT_NODE){if(n.data.length>=r)break;n.data.length>0&&(r-=n.data.length)}i=r}this.setRange(e,n,i)},rangy.rangePrototype.getNextContainer=function(e,t){if(!e)return null;for(;e.nextSibling;)if(e=e.nextSibling,e.nodeType!==ice.dom.TEXT_NODE){var n=this.getFirstSelectableChild(e);if(null!==n)return n}else if(this.isSelectable(e)===!0)return e;for(;e&&!e.nextSibling;)e=e.parentNode;if(!e)return null;if(e=e.nextSibling,this.isSelectable(e)===!0)return e;t&&ice.dom.isBlockElement(e)===!0&&t.push(e);var i=this.getFirstSelectableChild(e);return null!==i?i:this.getNextContainer(e,t)},rangy.rangePrototype.getPreviousContainer=function(e,t){if(!e)return null;for(;e.previousSibling;)if(e=e.previousSibling,e.nodeType!==ice.dom.TEXT_NODE){if(ice.dom.isStubElement(e)===!0)return e;var n=this.getLastSelectableChild(e);if(null!==n)return n}else if(this.isSelectable(e)===!0)return e;for(;e&&!e.previousSibling;)e=e.parentNode;if(!e)return null;if(e=e.previousSibling,this.isSelectable(e)===!0)return e;t&&ice.dom.isBlockElement(e)===!0&&t.push(e);var i=this.getLastSelectableChild(e);return null!==i?i:this.getPreviousContainer(e,t)},rangy.rangePrototype.getNextTextNode=function(e){return e.nodeType===ice.dom.ELEMENT_NODE&&0!==e.childNodes.length?this.getFirstSelectableChild(e):(e=this.getNextContainer(e),e.nodeType===ice.dom.TEXT_NODE?e:this.getNextTextNode(e))},rangy.rangePrototype.getPreviousTextNode=function(e,t){return e=this.getPreviousContainer(e,t),e.nodeType===ice.dom.TEXT_NODE?e:this.getPreviousTextNode(e,t)},rangy.rangePrototype.getFirstSelectableChild=function(e){if(e){if(e.nodeType===ice.dom.TEXT_NODE)return e;for(var t=e.firstChild;t;){if(this.isSelectable(t)===!0)return t;if(t.firstChild){var n=this.getFirstSelectableChild(t);if(null!==n)return n;t=t.nextSibling}else t=t.nextSibling}}return null},rangy.rangePrototype.getLastSelectableChild=function(e){if(e){if(e.nodeType===ice.dom.TEXT_NODE)return e;for(var t=e.lastChild;t;){if(this.isSelectable(t)===!0)return t;if(t.lastChild){var n=this.getLastSelectableChild(t);if(null!==n)return n;t=t.previousSibling}else t=t.previousSibling}}return null},rangy.rangePrototype.isSelectable=function(e){return e&&e.nodeType===ice.dom.TEXT_NODE&&0!==e.data.length?!0:!1},rangy.rangePrototype.getHTMLContents=function(t){t||(t=this.cloneContents());var n=e.env.document.createElement("div");return n.appendChild(t.cloneNode(!0)),n.innerHTML},rangy.rangePrototype.getHTMLContentsObj=function(){return this.cloneContents()}}},t.Selection=e}.call(this.ice),function(){var e=this,t=function(e){this._ice=e};t.prototype={start:function(){},clicked:function(){return!0},mouseDown:function(){return!0},keyDown:function(){return!0},keyPress:function(){return!0},selectionChanged:function(){},setEnabled:function(){},setDisabled:function(){},caretUpdated:function(){},nodeInserted:function(){},nodeCreated:function(){},caretPositioned:function(){},remove:function(){this._ice.removeKeyPressListener(this)},setSettings:function(){}},e.IcePlugin=t}.call(this.ice),function(){var e=this,t=function(e){this.plugins={},this.pluginConstructors={},this.keyPressListeners={},this.activePlugin=null,this.pluginSets={},this.activePluginSet=null,this._ice=e};t.prototype={getPluginNames:function(){var e=[];for(var t in this.plugins)e.push(t);return e},addPluginObject:function(e,t){this.plugins[e]=t},addPlugin:function(e,t){if("function"!=typeof t)throw Error("IcePluginException: plugin must be a constructor function");ice.dom.isset(this.pluginConstructors[e])===!1&&(this.pluginConstructors[e]=t)},loadPlugins:function(e,t){if(0===e.length)t.call(this);else{var n=e.shift();if("object"==typeof n&&(n=n.name),ice.dom.isset(ice._plugin[n])!==!0)throw Error("plugin was not included in the page: "+n);this.addPlugin(n,ice._plugin[n]),this.loadPlugins(e,t)}},_enableSet:function(e){this.activePluginSet=e;for(var t=this.pluginSets[e].length,n=0;t>n;n++){var i=this.pluginSets[e][n],r="";r="object"==typeof i?i.name:i;var o=this.pluginConstructors[r];if(o){var s=new o(this._ice);this.plugins[r]=s,ice.dom.isset(i.settings)===!0&&s.setSettings(i.settings),s.start()}}},setActivePlugin:function(e){this.activePlugin=e},getActivePlugin:function(){return this.activePlugin},_getPluginName:function(e){var t=""+e,n="function ".length,i=t.substr(n,t.indexOf("(")-n);return i},removePlugin:function(e){this.plugins[e]&&this.plugins[e].remove()},getPlugin:function(e){return this.plugins[e]},usePlugins:function(e,t,n){var i=this;this.pluginSets[e]=ice.dom.isset(t)===!0?t:[];var r=this.pluginSets[e].concat([]);this.loadPlugins(r,function(){i._enableSet(e),n&&n.call(this)})},disablePlugin:function(e){this.plugins[e].disable()},isPluginElement:function(e){for(var t in this.plugins)if(this.plugins[t].isPluginElement&&this.plugins[t].isPluginElement(e)===!0)return!0;return!1},fireKeyPressed:function(e){if(this._fireKeyPressFns(e,"all_keys")===!1)return!1;var t=[];switch((e.ctrlKey===!0||e.metaKey===!0)&&t.push("ctrl"),e.shiftKey===!0&&t.push("shift"),e.altKey===!0&&t.push("alt"),e.keyCode){case 13:t.push("enter");break;case ice.dom.DOM_VK_LEFT:t.push("left");break;case ice.dom.DOM_VK_RIGHT:t.push("right");break;case ice.dom.DOM_VK_UP:t.push("up");break;case ice.dom.DOM_VK_DOWN:t.push("down");break;case 9:t.push("tab");break;case ice.dom.DOM_VK_DELETE:t.push("delete");break;default:var n;e.keyCode?n=e.keyCode:e.which&&(n=e.which),n&&t.push(String.fromCharCode(n).toLowerCase())}var i=t.sort().join("+");return this._fireKeyPressFns(e,i)},_fireKeyPressFns:function(e,t){if(this.keyPressListeners[t])for(var n=this.keyPressListeners[t].length,i=0;n>i;i++){var r=this.keyPressListeners[t][i],o=r.fn,s=r.plugin,a=r.data;if(o)if(ice.dom.isFn(o)===!0){if(o.call(s,e,a)===!0)return ice.dom.preventDefault(e),!1}else if(s[o]&&s[o].call(s,e,a)===!0)return ice.dom.preventDefault(e),!1}return!0},fireSelectionChanged:function(e){for(var t in this.plugins)this.plugins[t].selectionChanged(e)},fireNodeInserted:function(e,t){for(var n in this.plugins)if(this.plugins[n].nodeInserted(e,t)===!1)return!1},fireNodeCreated:function(e,t){for(var n in this.plugins)if(this.plugins[n].nodeCreated(e,t)===!1)return!1},fireCaretPositioned:function(){for(var e in this.plugins)this.plugins[e].caretPositioned()},fireClicked:function(e){var t=!0;for(var n in this.plugins)this.plugins[n].clicked(e)===!1&&(t=!1);return t},fireMouseDown:function(e){var t=!0;for(var n in this.plugins)this.plugins[n].mouseDown(e)===!1&&(t=!1);return t},fireKeyDown:function(e){var t=!0;for(var n in this.plugins)this.plugins[n].keyDown(e)===!1&&(t=!1);return t},fireKeyPress:function(e){var t=!0;for(var n in this.plugins)this.plugins[n].keyPress(e)===!1&&(t=!1);return t},fireEnabled:function(e){for(var t in this.plugins)this.plugins[t].setEnabled(e)},fireDisabled:function(e){for(var t in this.plugins)this.plugins[t].setDisabled(e)},fireCaretUpdated:function(){for(var e in this.plugins)this.plugins[e].caretUpdated&&this.plugins[e].caretUpdated()}},e._plugin={},e.IcePluginManager=t}.call(this.ice),function(){var e,t=this;e=function(e){this._ice=e},e.prototype={nodeCreated:function(e,t){e.setAttribute("title",(t.action||"Modified")+" by "+e.getAttribute(this._ice.userNameAttribute)+" - "+ice.dom.date("m/d/Y h:ia",parseInt(e.getAttribute(this._ice.timeAttribute))))}},ice.dom.noInclusionInherits(e,ice.IcePlugin),t._plugin.IceAddTitlePlugin=e}.call(this.ice),function(){var e,t=this;e=function(e){this._ice=e,this._tmpNode=null,this._tmpNodeTagName="icepaste",this._pasteId="icepastediv";var t=this;this.pasteType="formattedClean",this.preserve="p",this.beforePasteClean=function(e){return e},this.afterPasteClean=function(e){return e},e.element.oncopy=function(){return t.handleCopy.apply(t)}},e.prototype={setSettings:function(e){e=e||{},ice.dom.extend(this,e),this.preserve+=","+this._tmpNodeTagName,this.setupPreserved()},keyDown:function(e){return e.metaKey===!0||e.ctrlKey===!0?(86==e.keyCode?this.handlePaste():88==e.keyCode&&this.handleCut(),!0):void 0},keyPress:function(e){var t=null;null==e.which?t=String.fromCharCode(e.keyCode):e.which>0&&(t=String.fromCharCode(e.which));var n=this;return this.cutElement&&"x"===t?ice.dom.isBrowser("webkit")&&n.cutElement.focus():"v"===t&&ice.dom.isBrowser("webkit")&&this._ice.env.document.getElementById(n._pasteId).focus(),!0},handleCopy:function(){},handlePaste:function(){var e=this._ice.getCurrentRange();if(e.collapsed||(this._ice.isTracking?(this._ice.deleteContents(),e=e.cloneRange()):(e.deleteContents(),e.collapse(!0))),this._ice.isTracking&&this._ice._moveRangeToValidTrackingPos(e),e.startContainer==this._ice.element){var t=ice.dom.find(this._ice.element,this._ice.blockEl)[0];t||(t=ice.dom.create("<"+this._ice.blockEl+" >
"+this._ice.blockEl+">"),this._ice.element.appendChild(t)),e.setStart(t,0),e.collapse(!0),this._ice.env.selection.addRange(e)
-}switch(this._tmpNode=this._ice.env.document.createElement(this._tmpNodeTagName),e.insertNode(this._tmpNode),this.pasteType){case"formatted":this.setupPaste();break;case"formattedClean":this.setupPaste(!0)}return!0},setupPaste:function(e){var t=this.createDiv(this._pasteId),n=this,i=this._ice.getCurrentRange();return i.selectNodeContents(t),this._ice.selection.addRange(i),t.onpaste=function(t){setTimeout(function(){n.handlePasteValue(e)},0),t.stopPropagation()},t.focus(),!0},handlePasteValue:function(e){var t=this._ice.env.document,n=t.getElementById(this._pasteId),i=ice.dom.getHtml(n),r=ice.dom.children(""+i+"
",this._ice.blockEl);1===r.length&&ice.dom.getNodeTextContent(""+i+"
")===ice.dom.getNodeTextContent(r)&&(i=ice.dom.getHtml(i)),i=this.beforePasteClean.call(this,i),e&&(i=this._ice.getCleanContent(i),i=this.stripPaste(i)),i=this.afterPasteClean.call(this,i),i=ice.dom.trim(i);var o=this._ice.getCurrentRange();o.setStartAfter(this._tmpNode),o.collapse(!0);var s=null,a=null,c=null,l=o.createContextualFragment(i),d=this._ice.startBatchChange();if(ice.dom.hasBlockChildren(l)){var h=ice.dom.isChildOfTagName(this._tmpNode,this._ice.blockEl);o.setEndAfter(h.lastChild),this._ice.selection.addRange(o);var u=o.extractContents(),f=t.createElement(this._ice.blockEl);f.appendChild(u),ice.dom.insertAfter(h,f),o.setStart(f,0),o.collapse(!0),this._ice.selection.addRange(o);for(var g=o.startContainer;l.firstChild;)if(3!==l.firstChild.nodeType||jQuery.trim(l.firstChild.nodeValue))if(ice.dom.isBlockElement(l.firstChild)){if(""!==l.firstChild.textContent){s=null;var m=null;this._ice.isTracking?(m=this._ice.createIceNode("insertType"),this._ice.addChange("insertType",[m]),c=t.createElement(l.firstChild.tagName),m.innerHTML=l.firstChild.innerHTML,c.appendChild(m)):(m=c=t.createElement(l.firstChild.tagName),c.innerHTML=l.firstChild.innerHTML),a=m,ice.dom.insertBefore(g,c)}l.removeChild(l.firstChild)}else s||(c=t.createElement(this._ice.blockEl),ice.dom.insertBefore(g,c),this._ice.isTracking?(s=this._ice.createIceNode("insertType"),this._ice.addChange("insertType",[s]),c.appendChild(s)):s=c),a=s,s.appendChild(l.removeChild(l.firstChild));else l.removeChild(l.firstChild);f.textContent||f.parentNode.removeChild(f)}else if(this._ice.isTracking)c=this._ice.createIceNode("insertType",l),this._ice.addChange("insertType",[c]),o.insertNode(c),a=c;else for(var p;p=l.firstChild;)o.insertNode(p),o.setStartAfter(p),o.collapse(!0),a=p;this._ice.endBatchChange(d),n.parentNode.removeChild(n),this._cleanup(a)},createDiv:function(e){var t=this._ice.env.document,n=t.getElementById(e);n&&ice.dom.remove(n);var i=t.createElement("div");return i.id=e,i.setAttribute("contentEditable",!0),ice.dom.setStyle(i,"width","1px"),ice.dom.setStyle(i,"height","1px"),ice.dom.setStyle(i,"overflow","hidden"),ice.dom.setStyle(i,"position","fixed"),ice.dom.setStyle(i,"top","10px"),ice.dom.setStyle(i,"left","10px"),i.appendChild(t.createElement("br")),t.body.appendChild(i),i},handleCut:function(){var e=this,t=this._ice.getCurrentRange();if(!t.collapsed){this.cutElement=this.createDiv("icecut"),this.cutElement.innerHTML=t.getHTMLContents().replace(/ /g,"> "),this._ice.isTracking?this._ice.deleteContents():t.deleteContents();var n=this._ice.env.document.createRange();n.setStart(this.cutElement.firstChild,0),n.setEndAfter(this.cutElement.lastChild),setTimeout(function(){e.cutElement.focus(),setTimeout(function(){ice.dom.remove(e.cutElement),t.setStart(t.startContainer,t.startOffset),t.collapse(!1),e._ice.env.selection.addRange(t)},100)},0),e._ice.env.selection.addRange(n)}},stripPaste:function(e){return e=this._cleanWordPaste(e),e=this.cleanPreserved(e)},setupPreserved:function(){var e=this;this._tags="",this._attributesMap=[],ice.dom.each(this.preserve.split(","),function(t,n){n.match(/(\w+)(\[(.+)\])?/);var i=RegExp.$1,r=RegExp.$3;e._tags&&(e._tags+=","),e._tags+=i.toLowerCase(),e._attributesMap[i]=r.split("|")})},cleanPreserved:function(e){var t=this,n=this._ice.env.document.createElement("div");return n.innerHTML=e,n=ice.dom.stripEnclosingTags(n,this._tags),ice.dom.each(ice.dom.find(n,this._tags),function(e,n){if(ice.dom.hasClass(n,"skip-clean"))return!0;var i=n.tagName.toLowerCase(),r=t._attributesMap[i];if(r[0]&&"*"===r[0])return!0;if(n.hasAttributes())for(var o=n.attributes,e=o.length-1;e>=0;e--)ice.dom.inArray(o[e].name,r)||n.removeAttribute(o[e].name)}),n.innerHTML},_cleanWordPaste:function(e){return e=e.replace(/<(meta|link)[^>]+>/g,""),e=e.replace(//g,""),e=e.replace(/