.../alohaeditor/lib/aloha-jquery-noconflict.js | 12 + core/modules/aloha/build/alohaeditor/lib/aloha.js | 20 + .../build/alohaeditor/lib/aloha/ierange-m2.js | 29 + core/modules/aloha/build/alohaeditor/lib/css.js | 455 +++++ .../modules/aloha/build/alohaeditor/lib/require.js | 2053 ++++++++++++++++++++ core/modules/aloha/build/alohaeditor/lib/text.js | 288 +++ .../aloha/build/alohaeditor/lib/vendor/class.js | 8 + .../build/alohaeditor/lib/vendor/ierange-m2.js | 508 +++++ .../alohaeditor/lib/vendor/pubsub/js/pubsub.js | 2 + .../aloha/build/alohaeditor/lib/vendor/sanitize.js | 21 + core/modules/aloha/build/alohaeditor/package.json | 49 + .../build/alohaeditor/plugins/common/align/LICENSE | 166 ++ .../alohaeditor/plugins/common/align/css/align.css | 31 + .../alohaeditor/plugins/common/align/img/align.png | 4 + .../plugins/common/align/nls/ca/i18n.js | 6 + .../plugins/common/align/nls/de/i18n.js | 6 + .../plugins/common/align/nls/mk/i18n.js | 6 + .../plugins/common/align/nls/pt-br/i18n.js | 6 + .../plugins/common/align/nls/ru/i18n.js | 6 + .../plugins/common/align/nls/uk/i18n.js | 6 + .../plugins/common/align/nls/zh-hans/i18n.js | 6 + .../alohaeditor/plugins/common/align/package.json | 2 + .../alohaeditor/plugins/common/block/css/block.css | 110 ++ .../common/block/img/toolbar-draghandle.gif | 1 + .../plugins/common/block/nls/ca/i18n.js | 3 + .../plugins/common/block/nls/de/i18n.js | 3 + .../plugins/common/block/nls/mk/i18n.js | 3 + .../plugins/common/block/nls/pt-br/i18n.js | 3 + .../plugins/common/block/nls/ru/i18n.js | 3 + .../plugins/common/block/nls/uk/i18n.js | 3 + .../plugins/common/block/nls/zh-hans/i18n.js | 3 + .../alohaeditor/plugins/common/block/package.json | 11 + .../plugins/common/commands/package.json | 1 + .../plugins/common/contenthandler/package.json | 1 + .../alohaeditor/plugins/common/format/img/em.png | 5 + .../plugins/common/format/img/strong.png | 5 + .../plugins/common/format/nls/ca/i18n.js | 52 + .../plugins/common/format/nls/de/i18n.js | 52 + .../plugins/common/format/nls/mk/i18n.js | 52 + .../plugins/common/format/nls/pt-br/i18n.js | 52 + .../plugins/common/format/nls/ru/i18n.js | 52 + .../plugins/common/format/nls/uk/i18n.js | 52 + .../plugins/common/format/nls/zh-hans/i18n.js | 52 + .../highlighteditables/css/highlighteditables.css | 14 + .../plugins/common/highlighteditables/package.json | 1 + .../alohaeditor/plugins/common/image/css/image.css | 133 ++ .../alohaeditor/plugins/common/image/img/blank.jpg | 2 + .../plugins/common/image/img/crop-buttons.gif | 5 + .../plugins/common/image/img/cropnresize.png | 13 + .../plugins/common/image/img/handle-sw.png | 4 + .../plugins/common/image/img/image-align-left.png | 28 + .../plugins/common/image/img/image-align-none.png | 28 + .../plugins/common/image/img/image-align-right.png | 26 + .../plugins/common/image/img/image-border.png | 25 + .../plugins/common/image/img/image-title.png | 25 + .../alohaeditor/plugins/common/image/img/image.gif | 4 + .../plugins/common/image/img/padding-decrease.gif | 3 + .../plugins/common/image/img/padding-increase.gif | 3 + .../alohaeditor/plugins/common/image/img/page.png | 4 + .../plugins/common/image/img/size-decrease.gif | 2 + .../plugins/common/image/img/size-increase.gif | 3 + .../plugins/common/image/nls/ca/i18n.js | 32 + .../plugins/common/image/nls/de/i18n.js | 32 + .../plugins/common/image/nls/mk/i18n.js | 32 + .../plugins/common/image/nls/pt-br/i18n.js | 32 + .../plugins/common/image/nls/ru/i18n.js | 32 + .../plugins/common/image/nls/uk/i18n.js | 32 + .../plugins/common/image/nls/zh-hans/i18n.js | 32 + .../alohaeditor/plugins/common/image/package.json | 1 + .../plugins/common/image/vendor/jcrop/jcrop.gif | 9 + .../common/image/vendor/jcrop/jquery.jcrop.css | 46 + .../alohaeditor/plugins/common/link/css/link.css | 53 + .../alohaeditor/plugins/common/link/nls/ca/i18n.js | 14 + .../alohaeditor/plugins/common/link/nls/de/i18n.js | 14 + .../alohaeditor/plugins/common/link/nls/mk/i18n.js | 14 + .../plugins/common/link/nls/pt-br/i18n.js | 14 + .../alohaeditor/plugins/common/link/nls/ru/i18n.js | 14 + .../alohaeditor/plugins/common/link/nls/uk/i18n.js | 14 + .../plugins/common/link/nls/zh-hans/i18n.js | 14 + .../alohaeditor/plugins/common/list/nls/ca/i18n.js | 7 + .../alohaeditor/plugins/common/list/nls/de/i18n.js | 7 + .../alohaeditor/plugins/common/list/nls/mk/i18n.js | 7 + .../plugins/common/list/nls/pt-br/i18n.js | 7 + .../alohaeditor/plugins/common/list/nls/ru/i18n.js | 7 + .../alohaeditor/plugins/common/list/nls/uk/i18n.js | 7 + .../plugins/common/list/nls/zh-hans/i18n.js | 7 + .../alohaeditor/plugins/common/list/package.json | 1 + .../alohaeditor/plugins/common/paste/package.json | 8 + .../alohaeditor/plugins/common/ui/lib/arena.js | 11 + .../plugins/common/ui/lib/autocomplete.js | 70 + .../alohaeditor/plugins/common/ui/lib/dialog.js | 161 ++ .../plugins/common/ui/lib/menuButton.js | 169 ++ .../plugins/common/ui/lib/multiSplit.js | 237 +++ .../build/alohaeditor/plugins/common/ui/lib/tab.js | 281 +++ .../alohaeditor/plugins/common/ui/lib/text.js | 33 + .../alohaeditor/plugins/common/ui/lib/toolbar.js | 244 +++ .../alohaeditor/plugins/common/ui/lib/utils.js | 104 + .../alohaeditor/plugins/common/ui/nls/ca/i18n.js | 44 + .../alohaeditor/plugins/common/ui/nls/de/i18n.js | 44 + .../alohaeditor/plugins/common/ui/nls/mk/i18n.js | 44 + .../plugins/common/ui/nls/pt-br/i18n.js | 44 + .../alohaeditor/plugins/common/ui/nls/ru/i18n.js | 44 + .../alohaeditor/plugins/common/ui/nls/uk/i18n.js | 44 + .../plugins/common/ui/nls/zh-hans/i18n.js | 44 + .../extra/captioned-image/css/captioned-image.css | 15 + .../captioned-image/lib/captioned-image-plugin.js | 555 ++++++ core/modules/aloha/build/build-aloha-for-drupal.sh | 116 ++ core/modules/aloha/build/build-profile-drupal.js | 634 ++++++ 108 files changed, 7959 insertions(+) diff --git a/core/modules/aloha/build/alohaeditor/lib/aloha-jquery-noconflict.js b/core/modules/aloha/build/alohaeditor/lib/aloha-jquery-noconflict.js new file mode 100644 index 0000000..da3b464 --- /dev/null +++ b/core/modules/aloha/build/alohaeditor/lib/aloha-jquery-noconflict.js @@ -0,0 +1,12 @@ +// To be included in the compiled aloha-full.js (which includes +// requirejs and jQuery) immediately after jQuery. This will prevent +// Aloha's jQuery from polluting the global namespace. +// TODO: requirejs shouldn't leak either +// NB: this is only for aloha-full.js to preserve behaviour with the way +// older builds of aloha were done. It is now always preferred to use +// aloha-bare.js (which doesn't include either requirejs or jQuery) and +// let the implementer worry exactly how to set up jQuery and requirejs +// to suit his needs. +Aloha = window.Aloha || {}; +Aloha.settings = Aloha.settings || {}; +Aloha.settings.jQuery = Aloha.settings.jQuery || jQuery.noConflict(true); diff --git a/core/modules/aloha/build/alohaeditor/lib/aloha.js b/core/modules/aloha/build/alohaeditor/lib/aloha.js new file mode 100644 index 0000000..b0136b1 --- /dev/null +++ b/core/modules/aloha/build/alohaeditor/lib/aloha.js @@ -0,0 +1,20 @@ +(function(){var JSON;JSON||(JSON={}),function(){function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a=="object"&&typeof a.toJSON=="function"&&(a=a.toJSON(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;n["+e.childNodes.length+"]"}return e.nodeName}function k(e){this.root=e,this._next=e}function L(e){return new k(e)}function A(e,t){this.node=e,this.offset=t}function O(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}var n="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 i=document.createElement("div");r.areHostMethods(i,["insertBefore","appendChild","cloneNode"]||!r.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"]))||t.fail("Incomplete Element implementation"),r.isHostProperty(i,"innerHTML")||t.fail("Element is missing innerHTML property");var s=document.createTextNode("test");r.areHostMethods(s,["splitText","deleteData","insertData","appendData","cloneNode"]||!r.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"])||!r.areHostProperties(s,["data"]))||t.fail("Incomplete Text Node implementation");var o=function(e,t){var n=e.length;while(n--)if(e[n]===t)return!0;return!1};k.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next,t,n;if(this._current){t=e.firstChild;if(t)this._next=t;else{n=null;while(e!==this.root&&!(n=e.nextSibling))e=e.parentNode;this._next=n}}return this._current},detach:function(){this._current=this._next=this.root=null}},A.prototype={equals:function(e){return this.node===e.node&this.offset==e.offset},inspect:function(){return"[DomPosition("+C(this.node)+":"+this.offset+")]"}},O.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},O.prototype.toString=function(){return this.message},e.dom={arrayContains:o,isHtmlNamespace:u,parentElement:a,getNodeIndex:f,getNodeLength:l,getCommonAncestor:c,isAncestorOf:h,getClosestAncestorIn:p,isCharacterDataNode:d,insertAfter:v,splitDataNode:m,getDocument:g,getWindow:y,getIframeWindow:w,getIframeDocument:b,getBody:E,getRootContainer:S,comparePoints:T,inspectNode:C,fragmentFromNodeChildren:N,createIterator:L,DomPosition:A},e.DOMException=O}),e.createModule("DomRange",function(e,t){function s(e,t){return e.nodeType!=3&&(n.isAncestorOf(e,t.startContainer,!0)||n.isAncestorOf(e,t.endContainer,!0))}function o(e){return n.getDocument(e.startContainer)}function u(e,t,n){var r=e._listeners[t];if(r)for(var i=0,s=r.length;i=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[r]),i}function c(e){var t;for(var n,r=o(e.range).createDocumentFragment(),s;n=e.next();){t=e.isPartiallySelectedSubtree(),n=n.cloneNode(!t),t&&(s=e.getSubtreeIterator(),n.appendChild(c(s)),s.detach(!0));if(n.nodeType==10)throw new i("HIERARCHY_REQUEST_ERR");r.appendChild(n)}return r}function h(e,t,r){var i,s;r=r||{stop:!1};for(var o,u;o=e.next();)if(e.isPartiallySelectedSubtree()){if(t(o)===!1){r.stop=!0;return}u=e.getSubtreeIterator(),h(u,t,r),u.detach(!0);if(r.stop)return}else{i=n.createIterator(o);while(s=i.next())if(t(s)===!1){r.stop=!0;return}}}function p(e){var t;while(e.next())e.isPartiallySelectedSubtree()?(t=e.getSubtreeIterator(),p(t),t.detach(!0)):e.remove()}function d(e){for(var t,n=o(e.range).createDocumentFragment(),r;t=e.next();){e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),r=e.getSubtreeIterator(),t.appendChild(d(r)),r.detach(!0)):e.remove();if(t.nodeType==10)throw new i("HIERARCHY_REQUEST_ERR");n.appendChild(t)}return n}function v(e,t,n){var r=!!t&&!!t.length,i,s=!!n;r&&(i=new RegExp("^("+t.join("|")+")$"));var o=[];return h(new g(e,!1),function(e){(!r||i.test(e.nodeType))&&(!s||n(e))&&o.push(e)}),o}function m(e){var t=typeof e.getName=="undefined"?"Range":e.getName();return"["+t+"("+n.inspectNode(e.startContainer)+":"+e.startOffset+", "+n.inspectNode(e.endContainer)+":"+e.endOffset+")]"}function g(e,t){this.range=e,this.clonePartiallySelectedTextNodes=t;if(!e.collapsed){this.sc=e.startContainer,this.so=e.startOffset,this.ec=e.endContainer,this.eo=e.endOffset;var r=e.commonAncestorContainer;this.sc===this.ec&&n.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===r&&!n.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:n.getClosestAncestorIn(this.sc,r,!0),this._last=this.ec===r&&!n.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:n.getClosestAncestorIn(this.ec,r,!0))}}function y(e){this.code=this[e],this.codeName=e,this.message="RangeException: "+this.codeName}function b(e,t,n){this.nodes=v(e,t,n),this._next=this.nodes[0],this._position=0}function N(e){return function(t,r){var i,s=r?t:t.parentNode;while(s){i=s.nodeType;if(n.arrayContains(e,i))return s;s=s.parentNode}return null}}function O(e,t){if(A(e,t))throw new y("INVALID_NODE_TYPE_ERR")}function M(e){if(!e.startContainer)throw new i("INVALID_STATE_ERR")}function _(e,t){if(!n.arrayContains(t,e.nodeType))throw new y("INVALID_NODE_TYPE_ERR")}function D(e,t){if(t<0||t>(n.isCharacterDataNode(e)?e.length:e.childNodes.length))throw new i("INDEX_SIZE_ERR")}function P(e,t){if(k(e,!0)!==k(t,!0))throw new i("WRONG_DOCUMENT_ERR")}function H(e){if(L(e,!0))throw new i("NO_MODIFICATION_ALLOWED_ERR")}function B(e,t){if(!e)throw new i(t)}function j(e){return!n.arrayContains(E,e.nodeType)&&!k(e,!0)}function F(e,t){return t<=(n.isCharacterDataNode(e)?e.length:e.childNodes.length)}function I(e){M(e);if(j(e.startContainer)||j(e.endContainer)||!F(e.startContainer,e.startOffset)||!F(e.endContainer,e.endOffset))throw new Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}function Z(){}function et(e){e.START_TO_START=X,e.START_TO_END=V,e.END_TO_END=$,e.END_TO_START=J,e.NODE_BEFORE=K,e.NODE_AFTER=Q,e.NODE_BEFORE_AND_AFTER=G,e.NODE_INSIDE=Y}function tt(e){et(e),et(e.prototype)}function nt(e,t){return function(){I(this);var r=this.startContainer,i=this.startOffset,s=this.commonAncestorContainer,o=new g(this,!0),u,a;r!==s&&(u=n.getClosestAncestorIn(r,s,!0),a=f(u),r=a.node,i=a.offset),h(o,H),o.reset();var l=e(o);return o.detach(),t(this,r,i,r,i),l}}function rt(t,r,i){function o(e,t){return function(n){M(this),_(n,w),_(C(n),E);var r=(e?a:f)(n);(t?u:l)(this,r.node,r.offset)}}function u(e,t,i){var s=e.endContainer,o=e.endOffset;if(t!==e.startContainer||i!==this.startOffset){if(C(t)!=C(s)||n.comparePoints(t,i,s,o)==1)s=t,o=i;r(e,t,i,s,o)}}function l(e,t,i){var s=e.startContainer,o=e.startOffset;if(t!==e.endContainer||i!==this.endOffset){if(C(t)!=C(s)||n.comparePoints(t,i,s,o)==-1)s=t,o=i;r(e,s,o,t,i)}}function c(e,t,n){(t!==e.startContainer||n!==this.startOffset||t!==e.endContainer||n!==this.endOffset)&&r(e,t,n,t,n)}t.prototype=new Z,e.util.extend(t.prototype,{setStart:function(e,t){M(this),O(e,!0),D(e,t),u(this,e,t)},setEnd:function(e,t){M(this),O(e,!0),D(e,t),l(this,e,t)},setStartBefore:o(!0,!0),setStartAfter:o(!1,!0),setEndBefore:o(!0,!1),setEndAfter:o(!1,!1),collapse:function(e){I(this),e?r(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):r(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){M(this),O(e,!0),r(this,e,0,e,n.getNodeLength(e))},selectNode:function(e){M(this),O(e,!1),_(e,w);var t=a(e),n=f(e);r(this,t.node,t.offset,n.node,n.offset)},extractContents:nt(d,r),deleteContents:nt(p,r),canSurroundContents:function(){I(this),H(this.startContainer),H(this.endContainer);var e=new g(this,!0),t=e._first&&s(e._first,this)||e._last&&s(e._last,this);return e.detach(),!t},detach:function(){i(this)},splitBoundaries:function(){I(this);var e=this.startContainer,t=this.startOffset,i=this.endContainer,s=this.endOffset,o=e===i;n.isCharacterDataNode(i)&&s>0&&s0&&t=n.getNodeIndex(e)&&s++,t=0),r(this,e,t,i,s)},normalizeBoundaries:function(){I(this);var e=this.startContainer,t=this.startOffset,i=this.endContainer,s=this.endOffset,o=function(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(i=e,s=e.length,e.appendData(t.data),t.parentNode.removeChild(t))},u=function(r){var o=r.previousSibling;if(o&&o.nodeType==r.nodeType){e=r;var u=r.length;t=o.length,r.insertData(0,o.data),o.parentNode.removeChild(o);if(e==i)s+=t,i=e;else if(i==r.parentNode){var a=n.getNodeIndex(r);s==a?(i=r,s=u):s>a&&s--}}},a=!0;if(n.isCharacterDataNode(i))i.length==s&&o(i);else{if(s>0){var f=i.childNodes[s-1];f&&n.isCharacterDataNode(f)&&o(f)}a=!this.collapsed}if(a){if(n.isCharacterDataNode(e))t==0&&u(e);else if(tx",R=q.firstChild.nodeType==3}catch(U){}e.features.htmlParsingConforms=R;var z=R?function(e){var t=this.startContainer,r=n.getDocument(t);if(!t)throw new i("INVALID_STATE_ERR");var s=null;return t.nodeType==1?s=t:n.isCharacterDataNode(t)&&(s=n.parentElement(t)),s===null||s.nodeName=="HTML"&&n.isHtmlNamespace(n.getDocument(s).documentElement)&&n.isHtmlNamespace(s)?s=r.createElement("body"):s=s.cloneNode(!1),s.innerHTML=e,n.fragmentFromNodeChildren(s)}:function(e){M(this);var t=o(this),r=t.createElement("body");return r.innerHTML=e,n.fragmentFromNodeChildren(r)},W=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],X=0,V=1,$=2,J=3,K=0,Q=1,G=2,Y=3;Z.prototype={attachListener:function(e,t){this._listeners[e].push(t)},compareBoundaryPoints:function(e,t){I(this),P(this.startContainer,t.startContainer);var r,i,s,o,u=e==J||e==X?"start":"end",a=e==V||e==X?"start":"end";return r=this[u+"Container"],i=this[u+"Offset"],s=t[a+"Container"],o=t[a+"Offset"],n.comparePoints(r,i,s,o)},insertNode:function(e){I(this),_(e,x),H(this.startContainer);if(n.isAncestorOf(e,this.startContainer,!0))throw new i("HIERARCHY_REQUEST_ERR");var t=l(e,this.startContainer,this.startOffset);this.setStartBefore(t)},cloneContents:function(){I(this);var e,t;if(this.collapsed)return o(this).createDocumentFragment();if(this.startContainer===this.endContainer&&n.isCharacterDataNode(this.startContainer))return e=this.startContainer.cloneNode(!0),e.data=e.data.slice(this.startOffset,this.endOffset),t=o(this).createDocumentFragment(),t.appendChild(e),t;var r=new g(this,!0);return e=c(r),r.detach(),e},canSurroundContents:function(){I(this),H(this.startContainer),H(this.endContainer);var e=new g(this,!0),t=e._first&&s(e._first,this)||e._last&&s(e._last,this);return e.detach(),!t},surroundContents:function(e){_(e,T);if(!this.canSurroundContents())throw new y("BAD_BOUNDARYPOINTS_ERR");var t=this.extractContents();if(e.hasChildNodes())while(e.lastChild)e.removeChild(e.lastChild);l(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){I(this);var e=new ut(o(this)),t=W.length,n;while(t--)n=W[t],e[n]=this[n];return e},toString:function(){I(this);var e=this.startContainer;if(e===this.endContainer&&n.isCharacterDataNode(e))return e.nodeType==3||e.nodeType==4?e.data.slice(this.startOffset,this.endOffset):"";var t=[],r=new g(this,!0);return h(r,function(e){(e.nodeType==3||e.nodeType==4)&&t.push(e.data)}),r.detach(),t.join("")},compareNode:function(e){I(this);var t=e.parentNode,r=n.getNodeIndex(e);if(!t)throw new i("NOT_FOUND_ERR");var s=this.comparePoint(t,r),o=this.comparePoint(t,r+1);return s<0?o>0?G:K:o>0?Q:Y},comparePoint:function(e,t){return I(this),B(e,"HIERARCHY_REQUEST_ERR"),P(e,this.startContainer),n.comparePoints(e,t,this.startContainer,this.startOffset)<0?-1:n.comparePoints(e,t,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:z,toHtml:function(){I(this);var e=o(this).createElement("div");return e.appendChild(this.cloneContents()),e.innerHTML},intersectsNode:function(e,t){I(this),B(e,"NOT_FOUND_ERR");if(n.getDocument(e)!==o(this))return!1;var r=e.parentNode,i=n.getNodeIndex(e);B(r,"NOT_FOUND_ERR");var s=n.comparePoints(r,i,this.endContainer,this.endOffset),u=n.comparePoints(r,i+1,this.startContainer,this.startOffset);return t?s<=0&&u>=0:s<0&&u>0},isPointInRange:function(e,t){return I(this),B(e,"HIERARCHY_REQUEST_ERR"),P(e,this.startContainer),n.comparePoints(e,t,this.startContainer,this.startOffset)>=0&&n.comparePoints(e,t,this.endContainer,this.endOffset)<=0},intersectsRange:function(e,t){I(this);if(o(e)!=o(this))throw new i("WRONG_DOCUMENT_ERR");var r=n.comparePoints(this.startContainer,this.startOffset,e.endContainer,e.endOffset),s=n.comparePoints(this.endContainer,this.endOffset,e.startContainer,e.startOffset);return t?r<=0&&s>=0:r<0&&s>0},intersection:function(e){if(this.intersectsRange(e)){var t=n.comparePoints(this.startContainer,this.startOffset,e.startContainer,e.startOffset),r=n.comparePoints(this.endContainer,this.endOffset,e.endContainer,e.endOffset),i=this.cloneRange();return t==-1&&i.setStart(e.startContainer,e.startOffset),r==1&&i.setEnd(e.endContainer,e.endOffset),i}return null},union:function(e){if(this.intersectsRange(e,!0)){var t=this.cloneRange();return n.comparePoints(e.startContainer,e.startOffset,this.startContainer,this.startOffset)==-1&&t.setStart(e.startContainer,e.startOffset),n.comparePoints(e.endContainer,e.endOffset,this.endContainer,this.endOffset)==1&&t.setEnd(e.endContainer,e.endOffset),t}throw new y("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==Y},containsNodeContents:function(e){return this.comparePoint(e,0)>=0&&this.comparePoint(e,n.getNodeLength(e))<=0},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 r=n.pop();t.setEnd(r,r.length);var i=this.containsRange(t);return t.detach(),i}return this.containsNodeContents(e)},createNodeIterator:function(e,t){return I(this),new b(this,e,t)},getNodes:function(e,t){return I(this),v(this,e,t)},getDocument:function(){return o(this)},collapseBefore:function(e){M(this),this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){M(this),this.setStartAfter(e),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(e){return ut.rangesEqual(this,e)},inspect:function(){return m(this)}},rt(ut,st,ot),e.rangePrototype=Z.prototype,ut.rangeProperties=W,ut.RangeIterator=g,ut.copyComparisonConstants=tt,ut.createPrototypeRange=rt,ut.inspect=m,ut.getRangeDocument=o,ut.rangesEqual=function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset},e.DomRange=ut,e.RangeException=y}),e.createModule("WrappedRange",function(e,t){function o(e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var i=n.parentElement();n=e.duplicate(),n.collapse(!1);var s=n.parentElement(),o=i==s?i:r.getCommonAncestor(i,s);return o==t?o:r.getCommonAncestor(t,o)}function u(e){return e.compareEndPoints("StartToEnd",e)==0}function a(e,t,n,s){var o=e.duplicate();o.collapse(n);var u=o.parentElement();r.isAncestorOf(t,u,!0)||(u=t);if(!u.canHaveHTML)return new i(u.parentNode,r.getNodeIndex(u));var a=r.getDocument(u).createElement("span");a.parentNode&&a.parentNode.removeChild(a);var f,l=n?"StartToStart":"StartToEnd",c,h,p,d;do u.insertBefore(a,a.previousSibling),o.moveToElementText(a);while((f=o.compareEndPoints(l,e))>0&&a.previousSibling);d=a.nextSibling;if(f==-1&&d&&r.isCharacterDataNode(d)){o.setEndPoint(n?"EndToStart":"EndToEnd",e);var v;if(/[\r\n]/.test(d.data)){var m=o.duplicate(),g=m.text.replace(/\r\n/g,"\r").length;v=m.moveStart("character",g);while((f=m.compareEndPoints("StartToEnd",m))==-1)v++,m.moveStart("character",1)}else{var y=o.text.replace(/\u00a0/g," "),b=d.data.replace(/\u00a0/g," ");if(b.indexOf(y)!==0){while(y.length>0&&b.indexOf(y)!==0)y=y.substr(1);v=y.length}else v=o.text.length}p=new i(d,v)}else c=(s||!n)&&a.previousSibling,h=(s||n)&&a.nextSibling,h&&r.isCharacterDataNode(h)?p=new i(h,0):c&&r.isCharacterDataNode(c)?p=new i(c,c.length):p=new i(u,r.getNodeIndex(a));return a.parentNode.removeChild(a),p}function f(e,t){var n,i,s=e.offset,o=r.getDocument(e.node),u,a,f=o.body.createTextRange(),l=r.isCharacterDataNode(e.node);l?(n=e.node,i=n.parentNode):(a=e.node.childNodes,n=s12"),t.close();var n=i.getIframeWindow(e).getSelection(),r=t.documentElement,s=r.lastChild,o=s.firstChild,u=t.createRange();u.setStart(o,1),u.collapse(!0),n.addRange(u),N=n.rangeCount==1,n.removeAllRanges();var a=u.cloneRange();u.setStart(o,0),a.setEnd(o,2),n.addRange(u),n.addRange(a),T=n.rangeCount==2,u.detach(),a.detach(),w.removeChild(e)}(),e.features.selectionSupportsMultipleRanges=T,e.features.collapsedNonEditableSelectionsSupported=N;var C=!1,k;w&&s.isHostMethod(w,"createControlRange")&&(k=w.createControlRange(),s.areHostProperties(k,["item","add"])&&(C=!0)),e.features.implementsControlRange=C,E?c=function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}:c=function(e){return e.rangeCount?e.getRangeAt(e.rangeCount-1).collapsed:!1};var F;s.isHostMethod(y,"getRangeAt")?F=function(e,t){try{return e.getRangeAt(t)}catch(n){return null}}:E&&(F=function(t){var n=i.getDocument(t.anchorNode),r=e.createRange(n);return r.setStart(t.anchorNode,t.anchorOffset),r.setEnd(t.focusNode,t.focusOffset),r.collapsed!==this.isCollapsed&&(r.setStart(t.focusNode,t.focusOffset),r.setEnd(t.anchorNode,t.anchorOffset)),r}),e.getSelection=function(e){e=e||window;var t=e[r],n=l(e),i=m?d(e):null;return t?(t.nativeSelection=n,t.docSelection=i,t.refresh(e)):(t=new I(n,i,e),e[r]=t),t},e.getIframeSelection=function(t){return e.getSelection(i.getIframeWindow(t))};var q=I.prototype;if(!g&&E&&s.areHostMethods(y,["removeAllRanges","addRange"])){q.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),O(this)};var U=function(t,n){var r=o.getRangeDocument(n),i=e.createRange(r);i.collapseToPoint(n.endContainer,n.endOffset),t.nativeSelection.addRange(M(i)),t.nativeSelection.extend(n.startContainer,n.startOffset),t.refresh()};x?q.addRange=function(t,n){if(C&&m&&this.docSelection.type==h)j(this,t);else if(n&&S)U(this,t);else{var r;T?r=this.rangeCount:(this.removeAllRanges(),r=0),this.nativeSelection.addRange(M(t)),this.rangeCount=this.nativeSelection.rangeCount;if(this.rangeCount==r+1){if(e.config.checkSelectionRanges){var i=F(this.nativeSelection,this.rangeCount-1);i&&!o.rangesEqual(i,t)&&(t=new u(i))}this._ranges[this.rangeCount-1]=t,L(this,t,X(this.nativeSelection)),this.isCollapsed=c(this)}else this.refresh()}}:q.addRange=function(e,t){t&&S?U(this,e):(this.nativeSelection.addRange(M(e)),this.refresh())},q.setRanges=function(e){if(C&&e.length>1)R(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;t1?R(this,e):t&&this.addRange(e[0])}}q.getRangeAt=function(e){if(e<0||e>=this.rangeCount)throw new a("INDEX_SIZE_ERR");return this._ranges[e]};var z;if(g)z=function(t){var n;e.isSelectionValid(t.win)?n=t.docSelection.createRange():(n=i.getBody(t.win.document).createTextRange(),n.collapse(!0)),t.docSelection.type==h?B(t):P(n)?H(t,n):O(t)};else if(s.isHostMethod(y,"getRangeAt")&&typeof y.rangeCount=="number")z=function(t){if(C&&m&&t.docSelection.type==h)B(t);else{t._ranges.length=t.rangeCount=t.nativeSelection.rangeCount;if(t.rangeCount){for(var n=0,r=t.rangeCount;n=0&&t.sourceIndex>=0?(e.sourceIndext.sourceIndex&&2):1)}function s(e){return null!=e.sourceIndex?e:e.parentNode.insertBefore(document.createComment(""),e)}var e,t={bind:function(e){var t=this.obj||this,n=Function.prototype.bind,r=Array.prototype.slice.call(arguments,1);return n?n.apply(t,arguments):function(){return t.apply(e,arguments.length===0?r:r.concat(Array.prototype.slice.call(arguments)))}},trim:function(){var e=this.obj||this,t=String.prototype.trim;return t?t.call(e):e.replace(/^\s+/,"").replace(/\s+$/,"")},indexOf:function(e,t){var n=this.obj||this,r=Array.prototype.indexOf;if(r)return r.call(n,e,t);t===undefined&&(t=0),t<0&&(t+=n.length),t<0&&(t=0);var i;for(i=n.length;t0&&(u=a.slice(0,e)),!1});if(!u)return!0;u=u.reverse();for(h=0,p=u.length;h=0?!0:e.isArray(this.tags[this.children[r]])&&e.inArray(i,this.tags[this.children[r]])>=0?!0:!1:!1},addMarkup:function(t,n,r){t.startContainer.nodeType===3&&t.startOffset>0&&t.startOffset0&&t.endOffset0&&this.recursiveAddMarkup(t[o].children,n)},findHighestElement:function(e,t,n){t=t.toLowerCase();var r,i=e,s=n?function(){return n.filter(function(){return i==this}).length}:function(){return!1};while(!s()&&i)i.nodeName.toLowerCase()===t&&(r=i),i=i.parentNode;return r},removeMarkup:function(t,n,r){var i=n.get(0).nodeName,s=this.findHighestElement(t.startContainer,i,r),o=this.findHighestElement(t.endContainer,i,r),u=!1,a,f,l;s&&t.startOffset>0&&(this.split(t,e(s).parent(),!1),u=!0),o&&(t.endContainer.nodeType===3&&t.endOffset0?s.first().unwrap():e(t[r].domobj).remove()),t[r].children&&this.recursiveRemoveMarkup(t[r].children,n)},doCleanup:function(t,n,i){var s=this,o,u,a,f,l;return typeof t=="undefined"&&(t={}),typeof t.merge=="undefined"&&(t.merge=!1),typeof t.removeempty=="undefined"&&(t.removeempty=!1),typeof i=="undefined"&&n&&(i=n.getCommonAncestorContainer()),o=!1,u=!1,a=e(i),f=n.startOffset,l=n.endOffset,a.contents().each(function(){var i,c;try{c=this.nodeType,i=s.getIndexInParent(this)}catch(h){return}switch(c){case 1:if(o&&o.nodeName==this.nodeName)n.startContainer===a&&f>i&&(n.startOffset-=1,u=!0),n.endContainer===a&&l>i&&(n.endOffset-=1 +,u=!0),e(o).append(e(this).contents()),u|=s.doCleanup(t,n,o),e(this).remove();else{u|=s.doCleanup(t,n,this);var p=!1;t.removeempty&&(r.Utils.Dom.isBlockLevelElement(this)&&this.childNodes.length===0&&(p=!0),e.inArray(this.nodeName.toLowerCase(),s.mergeableTags)>=0&&e(this).text().length===0&&this.childNodes.length===0&&(p=!0)),p?(n.startContainer===this.parentNode&&f>i&&(n.startOffset=n.startOffset-1,u=!0),n.endContainer===this.parentNode&&l>i&&(n.endOffset=n.endOffset-1,u=!0),e(this).remove()):e.inArray(this.nodeName.toLowerCase(),s.mergeableTags)>=0?o=this:o=!1}break;case 3:if(o&&o.nodeType===3&&t.merge)n.startContainer===this?(n.startContainer=o,n.startOffset+=o.nodeValue.length,u=!0):n.startContainer===o.parentNode&&n.startOffset===s.getIndexInParent(o)+1&&(n.startContainer=o,n.startOffset=o.nodeValue.length,u=!0),n.endContainer===this?(n.endContainer=o,n.endOffset+=o.nodeValue.length,u=!0):n.endContainer===o.parentNode&&n.endOffset===s.getIndexInParent(o)+1&&(n.endContainer=o,n.endOffset=o.nodeValue.length,u=!0),o.data+=this.data;else if(this.nodeValue!==""||!t.removeempty){o=this;break}n.startContainer===this.parentNode&&n.startOffset>i&&(n.startOffset=n.startOffset-1,u=!0),n.endContainer===this.parentNode&&n.endOffset>i&&(n.endOffset=n.endOffset-1,u=!0),e(this).remove();if(o&&(!o.nextSibling||o.nextSibling.nodeType!==3)){var d;for(d=o.data.length-1;d>=0&&o.data.length>1;d--)o.data.charAt(d)==="​"&&(o.deleteData(d,1),n.startContainer===o&&n.startOffset>d&&(n.startOffset--,u=!0),n.endContainer===o&&n.endOffset>d&&(n.endOffset--,u=!0))}}}),u&&n.clearCaches(),u},getIndexInParent:function(e){if(!e)return!1;var t=0,n=e.previousSibling;while(n)t++,n=n.previousSibling;return t},isBlockLevelElement:function(t){return t?t.nodeType===1&&e.inArray(t.nodeName.toLowerCase(),this.blockLevelElements)>=0?!0:!1:!1},isLineBreakElement:function(e){return e?e.nodeType===1&&e.nodeName.toLowerCase()=="br":!1},isListElement:function(t){return t?t.nodeType===1&&e.inArray(t.nodeName.toLowerCase(),this.listElements)>=0:!1},isSplitObject:function(e){return e.nodeType===1&&s.hasOwnProperty(e.nodeName)},searchAdjacentTextNode:function(t,n,r,i){if(!t||t.nodeType!==1||n<0||n>t.childNodes.length)return!1;typeof i=="undefined"&&(i={blocklevel:!0,list:!0,linebreak:!0}),typeof i.blocklevel=="undefined"&&(i.blocklevel=!0),typeof i.list=="undefined"&&(i.list=!0),typeof i.linebreak=="undefined"&&(i.linebreak=!0),typeof r=="undefined"&&(r=!0);var s,o=t;r&&n>0&&(s=t.childNodes[n-1]),!r&&n0)return s;if(i.blocklevel&&this.isBlockLevelElement(s))return!1;if(i.linebreak&&this.isLineBreakElement(s))return!1;if(i.list&&this.isListElement(s))return!1;s.nodeType===3?s=r?s.previousSibling:s.nextSibling:(o=s,s=r?s.lastChild:s.firstChild)}},insertIntoDOM:function(t,n,r,i,s){var o=n.getContainerParents(r,i),u=this,a,f,l,c,h;r||(r=e(document.body)),o.length===0?a=r.get(0):e.each(o,function(e,n){if(u.allowsNesting(n,t.get(0)))return a=n,!1}),typeof a=="undefined"&&r.length>0&&(a=r.get(0));if(!this.allowsNesting(a,t.get(0))&&!s)return!1;if(typeof a!="undefined")return c=this.split(n,e(a),i),c===!0?(f=n.startContainer,l=n.startOffset,i&&(f=n.endContainer,l=n.endOffset),l===0?(h=e(f).contents(),h.length>0?h.eq(0).before(t):e(f).append(t),!0):(e(f).contents().eq(l-1).after(t),!0)):c?(c.eq(0).after(t),!0):!1;return!1},removeFromDOM:function(t,n,r){if(r){var i=this.getIndexInParent(t),s=e(t).contents().length,o=t.parentNode;n.startContainer==o&&n.startOffset>i?n.startOffset+=s-1:n.startContainer==t&&(n.startContainer=o,n.startOffset=i+n.startOffset),n.endContainer==o&&n.endOffset>i?n.endOffset+=s-1:n.endContainer==t&&(n.endContainer=o,n.endOffset=i+n.endOffset),e(t).contents().unwrap(),this.doCleanup({merge:!0},n,o)}},removeRange:function(t){if(!t)return!1;if(t.isCollapsed())return!1;t.startContainer.nodeType==3&&t.startOffset>0&&t.startOffset0&&t.endOffset0&&(n.startContainer=n.endContainer=t[r].domobj.parentNode,n.startOffset=n.endOffset=this.getIndexInParent(t[r].domobj)),e(t[r].domobj).remove()):t[r].type=="partial"&&t[r].children&&this.recursiveRemoveRange(t[r].children,n)},extendToWord:function(e,t){var n=this.searchWordBoundary(e.startContainer,e.startOffset,!0),r=this.searchWordBoundary(e.endContainer,e.endOffset,!1);if(!t){if(e.startContainer==n.container&&e.startOffset==n.offset)return;if(e.endContainer==r.container&&e.endOffset==r.offset)return}e.startContainer=n.container,e.startOffset=n.offset,e.endContainer=r.container,e.endOffset=r.offset,e.correctRange(),e.clearCaches()},isWordBoundaryElement:function(t){return!t||!t.nodeName?!1:e.inArray(t.nodeName.toLowerCase(),this.nonWordBoundaryTags)==-1},searchWordBoundary:function(e,t,n){typeof n=="undefined"&&(n=!0);var r=!1,i,s,o;while(!r)if(e.nodeType===3)if(!n)i=e.data.substring(t).search(this.nonWordRegex),i!=-1?(t+=i,r=!0):(t=this.getIndexInParent(e)+1,e=e.parentNode);else{i=e.data.substring(0,t).search(this.nonWordRegex),s=i;while(s!=-1)i=s,s=e.data.substring(i+1,t).search(this.nonWordRegex),s!=-1&&(s=s+i+1);i!=-1?(t=i+1,r=!0):(t=this.getIndexInParent(e),e=e.parentNode)}else e.nodeType===1&&(n?t>0?this.isWordBoundaryElement(e.childNodes[t-1])?r=!0:(e=e.childNodes[t-1],t=e.nodeType===3?e.data.length:e.childNodes.length):this.isWordBoundaryElement(e)?r=!0:(t=this.getIndexInParent(e),e=e.parentNode):t=0;--i){var s=this.getLastVisibleChild(t.childNodes[i],!0);if(s!=null)return s}return null}});return r.Utils.Dom=new o,r.Utils.Dom}),define("aloha/pluginmanager",["jquery","util/class"],function(e,t){var n=window.Aloha;return new(t.extend({plugins:{},init:function(e,t){var r=this,i=n&&n.settings?n.settings.plugins||{}:{},s,o,u;for(u in i)i.hasOwnProperty(u)&&(o=this.plugins[u]||!1,o&&(o.settings=i[u]||{}));if(!t.length)for(u in this.plugins)this.plugins.hasOwnProperty(u)&&t.push(u);for(s=0;s=e.settings.logHistory.maxEntries*e.settings.logHistory.highWaterMark/100&&(e.trigger("aloha-log-full"),this.highWaterMarkReached=!0);while(this.logHistory.length>e.settings.logHistory.maxEntries)this.logHistory.shift()},getLogHistory:function(){return this.logHistory},flushLogHistory:function(){this.logHistory=[],this.highWaterMarkReached=!1}});return r=new r,e.Log=e.Console=r,r}),window.GENTICS=window.GENTICS||{},window.GENTICS.Utils=window.GENTICS.Utils||{},define("util/range",["jquery","util/dom","util/class","aloha/console","aloha/rangy-core"],function(e,t,n,r,i){function u(e,t){var n=[],r;1===e.nodeType?r=e:r=e.parentNode;for(;;){if(!r||r===t||9===r.nodeType)break;1===r.nodeType&&n.push(r),r=r.parentNode}return n}var s=window.GENTICS,o=window.Aloha;return s.Utils.RangeObject=n.extend({_constructor:function(e){typeof e=="object"?(typeof e.startContainer!="undefined"&&(this.startContainer=e.startContainer),typeof e.startOffset!="undefined"&&(this.startOffset=e.startOffset),typeof e.endContainer!="undefined"&&(this.endContainer=e.endContainer),typeof e.endOffset!="undefined"&&(this.endOffset=e.endOffset)):e===!0&&this.initializeFromUserSelection()},startContainer:undefined,startOffset:undefined,endContainer:undefined,endOffset:undefined,deleteContents:function(){t.removeRange(this)},log:function(e){r.deprecated("Utils.RangeObject",'log() is deprecated. use console.log() from module "aloha/console" instead: '+e)},isCollapsed:function(){return!this.endContainer||this.startContainer===this.endContainer&&this.startOffset===this.endOffset},getCommonAncestorContainer:function(){return this.commonAncestorContainer?this.commonAncestorContainer:(this.updateCommonAncestorContainer(),this.commonAncestorContainer)},getContainerParents:function(t,n){var r=n?this.endContainer:this.startContainer;return r?e(u(r,t?t[0]:null)):!1},getStartContainerParents:function(e){return this.getContainerParents(e,!1)},getEndContainerParents:function(e){return this.getContainerParents(e,!0)},updateCommonAncestorContainer:function(e){if(!e){var t=this.getStartContainerParents(),n=this.getEndContainerParents(),i;if(!(t.length>0&&n.length>0))return r.warn("aloha/range","could not find commonAncestorContainer"),!1;for(i=0;i0&&(n=e.childNodes[t-1]);while(n&&n.nodeType===3)r+=n.data.length,n=n.previousSibling;return{element:n,characters:r}},searchElementToRight:function(e,t){var n,r=0;e.nodeType===3?(r=e.data.length-t,n=e.nextSibling):t0&&this.startContainer.childNodes[this.startOffset-1].nodeType===3){this.startContainer=this.startContainer.childNodes[this.startOffset-1],this.startOffset=this.startContainer.data.length,this.endContainer=this.startContainer,this.endOffset=this.startOffset;return}if(this.startOffset>0&&this.startContainer.childNodes[this.startOffset-1].nodeType===1){t=s.Utils.Dom.searchAdjacentTextNode(this.startContainer,this.startOffset,!0);if(t){this.startContainer=this.endContainer=t,this.startOffset=this.endOffset=t.data.length;return}t=s.Utils.Dom.searchAdjacentTextNode(this.startContainer,this.startOffset,!1);if(t){this.startContainer=this.endContainer=t,this.startOffset=this.endOffset=0;return}}if(this.startOffset0&&(this.startContainer=this.endContainer=t,this.startOffset=this.endOffset=t.data.length))}else{if(this.startContainer.nodeType===1)if(this.startOffset0)r=r.childNodes[0],r.nodeType===3&&(n=r);n!==!1&&(this.startContainer=n,this.startOffset=0)}this.startContainer.nodeType===3&&this.startOffset===this.startContainer.data.length&&(t=s.Utils.Dom.searchAdjacentTextNode(this.startContainer.parentNode,s.Utils.Dom.getIndexInParent(this.startContainer)+1,!1),t&&(this.startContainer=t,this.startOffset=0));if(this.endContainer.nodeType===3&&this.endOffset===0)if(this.endContainer.previousSibling&&this.endContainer.previousSibling.nodeType===3)this.endContainer=this.endContainer.previousSibling,this.endOffset=this.endContainer.data.length;else if(this.endContainer.previousSibling&&this.endContainer.previousSibling.nodeType===1&&this.endContainer.parentNode){i=this.endContainer.parentNode;for(u=0;u0&&(this.endContainer=this.endContainer.previousSibling,this.endOffset=this.endContainer.childNodes.length));if(this.endContainer.nodeType==1)if(this.endOffset>0&&this.endContainer.childNodes[this.endOffset-1].nodeType===3)this.endContainer=this.endContainer.childNodes[this.endOffset-1],this.endOffset=this.endContainer.data.length;else if(this.endOffset>0&&this.endContainer.childNodes[this.endOffset-1].nodeType===1){n=!1,r=this.endContainer.childNodes[this.endOffset-1];while(n===!1&&r.childNodes&&r.childNodes.length>0)r=r.childNodes[r.childNodes.length-1],r.nodeType===3&&(n=r);n!==!1&&(this.endContainer=n,this.endOffset=this.endContainer.data.length)}}},clearCaches:function(){this.commonAncestorContainer=undefined},getRangeTree:function(e){return typeof e=="undefined"&&(e=this.getCommonAncestorContainer()),this.inselection=!1,this.recursiveGetRangeTree(e)},recursiveGetRangeTree:function(t){var n=e(t),r=0,i=this,o=[];return n.contents().each(function(e){var n="none",u=!1,a=!1,f=!1,l=!1,c=!1,h=!1,p;i.isCollapsed()&&t===i.startContainer&&i.startOffset===e&&(o[r]=new s.Utils.RangeTree,o[r].type="collapsed",o[r].domobj=undefined,i.inselection=!1,f=!0,r++);if(!i.inselection&&!f)switch(this.nodeType){case 3:this===i.startContainer&&(i.inselection=!0,n=i.startOffset>0?"partial":"full",u=i.startOffset,a=this.length);break;case 1:this===i.startContainer&&i.startOffset===0&&(i.inselection=!0,n="full"),t===i.startContainer&&i.startOffset===e&&(i.inselection=!0,n="full")}if(i.inselection&&!f){n=="none"&&(n="full");switch(this.nodeType){case 3:this===i.endContainer&&(i.inselection=!1,i.endOffset0){for(p=0;p>>0;while(n--)t[n]=e[n];return t}function g(e){while(e&&!e.nextSibling)e=e.parentNode;return e?e.nextSibling:null}function y(e){return e.hasChildNodes()?e.firstChild:g(e)}function b(e){if(e.previousSibling){e=e.previousSibling;while(e.hasChildNodes())e=e.lastChild;return e}return e.parentNode&&e.parentNode.nodeType==t.Node.ELEMENT_NODE?e.parentNode:null}function w(e,n){return e&&n&&Boolean(t.compareDocumentPosition(e,n)&t.Node.DOCUMENT_POSITION_CONTAINED_BY)}function E(e,t){return(e||t)&&(e==t||w(e,t))}function S(e,n){return n&&e&&Boolean(t.compareDocumentPosition(n,e)&t.Node.DOCUMENT_POSITION_CONTAINED_BY)}function x(e,n){return Boolean(t.compareDocumentPosition(e,n)&t.Node.DOCUMENT_POSITION_FOLLOWING)}function T(e,n){return Boolean(t.compareDocumentPosition(e,n)&t.Node.DOCUMENT_POSITION_PRECEDING)}function N(e){var t=[];while(e.parentNode)t.unshift(e.parentNode),e=e.parentNode;return t}function C(e){var t=[],n=g(e);while(null!=(e=y(e))&&e!=n)t.push(e);return t}function k(e){var t={fontFamily:"font-family",fontSize:"font-size",fontStyle:"font-style",fontWeight:"font-weight",textDecoration:"text-decoration"};return typeof t[e]!="undefined"?t[e]:e}function L(e){return{"xx-small":1,small:2,medium:3,large:4,"x-large":5,"xx-large":6,"xxx-large":7}[e]}function A(e){return{1:"xx-small",2:"small",3:"medium",4:"large",5:"x-large",6:"xx-large",7:"xxx-large"}[e]}function O(e){return e.dir=="ltr"?"ltr":e.dir=="rtl"?"rtl":l(e.parentNode)?O(e.parentNode):"ltr"}function M(e){var t=0;while(e.previousSibling)t++,e=e.previousSibling;return t}function _(e){switch(e.nodeType){case t.Node.PROCESSING_INSTRUCTION_NODE:case t.Node.DOCUMENT_TYPE_NODE:return 0;case t.Node.TEXT_NODE:case t.Node.COMMENT_NODE:return e.length;default:return e.childNodes.length}}function D(e,n,r,i){if(e==r){if(n==i)return"equal";if(ni)return"after"}var s=t.compareDocumentPosition(r,e);if(s&t.Node.DOCUMENT_POSITION_FOLLOWING){var o=D(r,i,e,n);if(o=="before")return"after";if(o=="after")return"before"}if(s&t.Node.DOCUMENT_POSITION_CONTAINS){var u=r;while(u.parentNode!=e)u=u.parentNode;if(M(u)7&&(r=7),e={1:"xx-small",2:"small",3:"medium",4:"large",5:"x-large",6:"xx-large",7:"xxx-large"}[r]}return e}function J(e){e=$(e);if(n.inArray(e,["xx-small","x-small","small","medium","large","x-large","xx-large","xxx-large"])==-1&&!/^[0-9]+(\.[0-9]+)?(cm|mm|in|pt|pc|px)$/.test(e))return null;var r=document.createElement("font");document.body.appendChild(r),e=="xxx-large"?r.size=7:r.style.fontSize=e;var i=parseInt(t.getComputedStyle(r).fontSize,10);document.body.removeChild(r);var s=1;while(s<7){r=document.createElement("font"),r.size=s,document.body.appendChild(r);var o=parseInt(t.getComputedStyle(r).fontSize,10);r.size=1+s;var u=parseInt(t.getComputedStyle(r).fontSize,10);document.body.removeChild(r);var a=(u+o)/2;if(i=4&&typeof s=="undefined")s=!1;if(arguments.length<=2||arguments.length>=4&&typeof o=="undefined")o="";return K(i,"action",r,function(e,t,n){return function(){return Q(e)?(u[e].action(n,r),G(r),!0):!1}}(i,s,o))}function Z(e,t){return e=e.toLowerCase(),K(e,"indeterm",t,function(e){return function(){return Q(e,t)?u[e].indeterm(t):!1}}(e))}function et(e,t){return e=e.toLowerCase(),K(e,"state",t,function(e){return function(){return Q(e,t)?typeof q(e,t)!="undefined"?q(e,t):u[e].state(t):!1}}(e))}function tt(e){return e=e.toLowerCase(),u.hasOwnProperty(e)}function nt(e,t){return e=e.toLowerCase(),K(e,"value",t,function(){return Q(e,t)?e=="fontsize"&&z("fontsize",t)!==undefined?J(z("fontsize",t)):typeof z(e,t)!="undefined"?z(e,t):u[e].value(t):""})}function it(e){return d(e,rt)}function ot(e){return e&&(e.nodeType==t.Node.ELEMENT_NODE&&!st[t.getComputedStyle(e).display]||e.nodeType==t.Node.DOCUMENT_NODE||e.nodeType==t.Node.DOCUMENT_FRAGMENT_NODE)}function ut(e){return e&&!ot(e)}function at(e){return e&&e.nodeType==t.Node.ELEMENT_NODE&&(e.contentEditable=="true"||e.parentNode&&e.parentNode.nodeType==t.Node.DOCUMENT_NODE&&e.parentNode.designMode=="on")}function ft(e){return e&&!at(e)&&(e.nodeType!=t.Node.ELEMENT_NODE||e.contentEditable!="false"||n(e).hasClass("aloha-table-wrapper"))&&(at(e.parentNode)||ft(e.parentNode))}function lt(e){var t;for(t=0;ti&&e[1]++,e[0]==o&&(e[1]==u||e[1]==u+1)&&(e[0]=r,e[1]+=i-u),e[0]==o&&e[1]>u+1&&e[1]--}),r.childNodes.length==i?r.appendChild(n):r.insertBefore(n,r.childNodes[i]);var c=null;if(l[0][1]>l[0][0].childNodes.length&&l[1][1]>l[1][0].childNodes.length)s.setStart(n,0),s.setEnd(n,0);else{s.setStart(l[0][0],l[0][1]),s.setEnd(l[1][0],l[1][1]),e.getSelection().removeAllRanges();for(a=1;a=7&&typeof e.attributes[n.expando]!="undefined"&&n(e).removeAttr(n.expando);var r=e.attributes,i;for(i=0;i=M(s)&&r.setStart(u,a+1),f==s.parentNode&&l>=M(s)&&r.setEnd(f,l+1),o&&o!==r&&(u=o.startContainer,a=o.startOffset,f=o.endContainer,l=o.endOffset,u==s.parentNode&&a>=M(s)&&o.setStart(u,a+1),f==s.parentNode&&l>=M(s)&&o.setEnd(f,l+1))}var h=e[0].parentNode;if(x(s,e[0])){!ut(s)&&ut(s.lastChild)&&ut(e[0])&&!c(s.lastChild,"BR")&&s.appendChild(s.ownerDocument.createElement("br"));for(i=0;i=0;i--)St(e[i],s,0,r)}ft(h)&&!h.hasChildNodes()&&h.parentNode.removeChild(h);if(ft(s.nextSibling)&&t(s.nextSibling)){!ut(s)&&ut(s.lastChild)&&ut(s.nextSibling.firstChild)&&!c(s.lastChild,"BR")&&s.appendChild(s.ownerDocument.createElement("br"));while(s.nextSibling.hasChildNodes())St(s.nextSibling.firstChild,s,-1,r);s.parentNode.removeChild(s.nextSibling)}return kt(s),s}function Bt(e){return d(e,At)}function jt(e,r){if((Ot[r]||p(r,["colgroup","table","tbody","tfoot","thead","tr"]))&&typeof e=="object"&&e.nodeType==t.Node.TEXT_NODE&&!/^[ \t\n\f\r]*$/.test(e.data))return!1;if(!Mt[r]&&!p(r,["script","style","plaintext","xmp"])||typeof e=="object"&&e.nodeType==t.Node.TEXT_NODE){if(typeof e!="object"||e.nodeType!=t.Node.DOCUMENT_NODE&&e.nodeType!=t.Node.DOCUMENT_FRAGMENT_NODE&&e.nodeType!=t.Node.DOCUMENT_TYPE_NODE){l(e)&&(e=e.tagName.toLowerCase());if(typeof e!="string")return!0;if(l(r)){var i=r;while(i){if(e=="a"&&c(i,"a"))return!1;if(rt[e.toUpperCase()]&&Bt(i))return!1;if(/^h[1-6]$/.test(e)&&l(i)&&/^H[1-6]$/.test(i.tagName))return!1;i=i.parentNode}r=r.tagName.toLowerCase()}if(typeof r!="object"||r.nodeType!=t.Node.ELEMENT_NODE&&r.nodeType!=t.Node.DOCUMENT_FRAGMENT_NODE){if(typeof r!="string")return!1;switch(r){case"colgroup":return e=="col";case"table":return n.inArray(e,["caption","col","colgroup","tbody","td","tfoot","th","thead","tr"])!=-1;case"tbody":case"thead":case"tfoot":return n.inArray(e,["td","th","tr"])!=-1;case"tr":return n.inArray(e,["td","th"])!=-1;case"dl":return n.inArray(e,["dt","dd"])!=-1;case"dir":case"ol":case"ul":return n.inArray(e,["dir","li","ol","ul"])!=-1;case"hgroup":return/^h[1-6]$/.test(e)}if(n.inArray(e,["body","caption","col","colgroup","frame","frameset","head","html","tbody","td","tfoot","th","thead","tr"])!=-1)return!1;if(n.inArray(e,["dd","dt"])!=-1&&r!="dl")return!1;if(e=="li"&&r!="ol"&&r!="ul")return!1;var s=Ht[r.toUpperCase()];if(s){var o=s[e.toUpperCase()];if(o)return!1}return!0}return!0}return!1}return!1}function Ft(e,n){return n.collapsed?!1:H(e,n)?!0:e==n.startContainer&&e.nodeType==t.Node.TEXT_NODE&&_(e)!=n.startOffset?!0:e==n.endContainer&&e.nodeType==t.Node.TEXT_NODE&&n.endOffset!=0?!0:e.hasChildNodes()&&t(e.childNodes).every(function(e){return Ft(e,n)})&&(!S(n.startContainer,e)||n.startContainer.nodeType!=t.Node.TEXT_NODE||n.startOffset==0)&&(!S(n.endContainer,e)||n.endContainer.nodeType!=t.Node.TEXT_NODE||n.endOffset==_(n.endContainer))?!0:!1}function It(e,t){typeof t=="undefined"&&(t=function(){return!0});var n=e.startContainer;while(Ft(n.parentNode,e))n=n.parentNode;var r=g(e.endContainer),i=[];while(x(n,r)){if(Ft(n,e)&&t(n)){i.push(n),n=g(n);continue}n=y(n)}return i}function qt(e,t){typeof t=="undefined"&&(t=function(){return!0});var n=e.startContainer;while(Ft(n.parentNode,e))n=n.parentNode;var r=g(e.endContainer),i=[];while(x(n,r))Ft(n,e)&&t(n)&&i.push(n),n=y(n);return i}function Rt(e){if(!l(e))return!1;if(n.inArray(e.tagName,["B","EM","I","S","SPAN","STRIKE","STRONG","SUB","SUP","U"])!=-1){if(e.attributes.length==0)return!0;if(e.attributes.length==1&&r(e,"style"))return!0}if(e.tagName=="FONT"||e.tagName=="A"){var t=e.attributes.length;r(e,"style")&&t--,e.tagName=="FONT"&&(r(e,"color")&&t--,r(e,"face")&&t--,r(e,"size")&&t--),e.tagName=="A"&&r(e,"href")&&t--;if(t==0)return!0}return!1}function Ut(e){return l(e)?n.inArray(e.tagName,["A","B","EM","FONT","I","S","SPAN","STRIKE","STRONG","SUB","SUP","U"])==-1?!1:e.attributes.length==0?!0:e.attributes.length>1?!1:r(e,"style")&&v(e)==0?!0:e.tagName=="A"&&r(e,"href")?!0:e.tagName=="FONT"&&(r(e,"color")||r(e,"face")||r(e,"size"))?!0:e.tagName!="B"&&e.tagName!="STRONG"||!r(e,"style")||v(e)!=1||e.style.fontWeight==""?e.tagName!="I"&&e.tagName!="EM"||!r(e,"style")||v(e)!=1||e.style.fontStyle==""?e.tagName!="A"&&e.tagName!="FONT"&&e.tagName!="SPAN"||!r(e,"style")||v(e)!=1||e.style.textDecoration!=""?n.inArray(e.tagName,["A","FONT","S","SPAN","STRIKE","U"])==-1||!r(e,"style")||v(e)!=1||e.style.textDecoration!="line-through"&&e.style.textDecoration!="underline"&&e.style.textDecoration!="overline"&&e.style.textDecoration!="none"?!1:!0:!0:!0:!0:!1}function zt(e,t,n){return t===null&&n===null?!0:typeof t=="string"&&typeof n=="string"&&t==n&&!u[e].hasOwnProperty("equivalentValues")?!0:typeof t=="string"&&typeof n=="string"&&u[e].hasOwnProperty("equivalentValues")&&u[e].equivalentValues(t,n)?!0:!1}function Wt(e,n,r){if(zt(e,n,r))return!0;if(e!="fontsize"||typeof n!="string"||typeof r!="string")return!1;var i=Wt;if(i.sizeMap===undefined){i.sizeMap={};var s=document.createElement("font");document.body.appendChild(s),t(["xx-small","small","medium","large","x-large","xx-large","xxx-large"]).forEach(function(e){s.size=L(e),i.sizeMap[e]=t.getComputedStyle(s).fontSize}),document.body.removeChild(s)}return n===i.sizeMap[r]||r===i.sizeMap[n]}function Xt(e,n){if(e.nodeType==t.Node.ELEMENT_NODE||!!e.parentNode&&e.parentNode.nodeType==t.Node.ELEMENT_NODE){if(e.nodeType!=t.Node.ELEMENT_NODE)return Xt(e.parentNode,n);if(n=="createlink"||n=="unlink"){while(e&&(!l(e)||e.tagName!="A"||!r(e,"href")))e=e.parentNode;return e?e.getAttribute("href"):null}if(n=="backcolor"||n=="hilitecolor"){while((t.getComputedStyle(e).backgroundColor=="rgba(0, 0, 0, 0)"||t.getComputedStyle(e).backgroundColor===""||t.getComputedStyle(e).backgroundColor=="transparent")&&e.parentNode&&e.parentNode.nodeType==t.Node.ELEMENT_NODE)e=e.parentNode;return t.getComputedStyle(e).backgroundColor=="rgba(0, 0, 0, 0)"||t.getComputedStyle(e).backgroundColor===""||t.getComputedStyle(e).backgroundColor=="transparent"?"rgb(255, 255, 255)":t.getComputedStyle(e).backgroundColor}if(n=="subscript"||n=="superscript"){var i=!1,s=!1;while(ut(e)){var o=t.getComputedStyle(e).verticalAlign;c(e,"sub")?i=!0:c(e,"sup")&&(s=!0),e=e.parentNode}return i&&s?"mixed":i?"subscript":s?"superscript":null}if(n=="strikethrough"){do{if(t.getComputedStyle(e).textDecoration.indexOf("line-through")!=-1)return"line-through";e=e.parentNode}while(e&&e.nodeType==t.Node.ELEMENT_NODE);return null}if(n=="underline"){do{if(t.getComputedStyle(e).textDecoration.indexOf("underline")!=-1)return"underline";e=e.parentNode}while(e&&e.nodeType==t.Node.ELEMENT_NODE);return null}if(!u[n].hasOwnProperty("relevantCssProperty"))throw"Bug: no relevantCssProperty for "+n+" in getEffectiveCommandValue";return t.getComputedStyle(e)[u[n].relevantCssProperty].toString()}return null}function Vt(e,n){if(n!="backcolor"&&n!="hilitecolor"||t.getComputedStyle(e).display=="inline"){if(n=="createlink"||n=="unlink")return l(e)&&e.tagName=="A"&&r(e,"href")?e.getAttribute("href"):null;if(n=="subscript"||n=="superscript")return c(e,"sup")?"superscript":c(e,"sub")?"subscript":null;if(n=="strikethrough"&&e.style.textDecoration!="")return e.style.textDecoration.indexOf("line-through")!=-1?"line-through":null;if(n=="strikethrough"&&p(e,["S","STRIKE"]))return"line-through";if(n=="underline"&&e.style.textDecoration!="")return e.style.textDecoration.indexOf("underline")!=-1?"underline":null;if(n=="underline"&&c(e,"U"))return"underline";var i=u[n].relevantCssProperty;if(i===null)return null;if(e.style[i]!="")return e.style[i];if(a(e.namespaceURI)&&e.tagName=="FONT"){if(i=="color"&&r(e,"color"))return e.color;if(i=="fontFamily"&&r(e,"face"))return e.face;if(i=="fontSize"&&r(e,"size")){var s=parseInt(e.size,10);return s<1&&(s=1),s>7&&(s=7),{1:"xx-small",2:"small",3:"medium",4:"large",5:"x-large",6:"xx-large",7:"xxx-large"}[s]}}return i!="fontWeight"||e.tagName!="B"&&e.tagName!="STRONG"?i!="fontStyle"||e.tagName!="I"&&e.tagName!="EM"?null:"italic":"bold"}return null}function $t(e,t,n,r){var i=e;while(Rt(i)&&i.childNodes.length==1&&Rt(i.firstChild)&&(!Ut(i)||!zt(t,Vt(i,t),n)))i=i.firstChild;if(i==e||!Ut(i)||!zt(t,Vt(i,t),n)||!Wt(t,Xt(i,t),n))return;while(i.hasChildNodes())St(i.firstChild,i.parentNode,M(i),r);e.parentNode.insertBefore(i,e.nextSibling),St(e,i,-1,r)}function Kt(e){var t=[],r=n.makeArray(e),i,s,o,u,a,f;for(i=0;i=0)return e.nextSibling;if(e.parentNode&&e.parentNode.nextSibling&&e.parentNode.nextSibling.className&&e.parentNode.nextSibling.className.indexOf("aloha-table-wrapper")>=0)return e.parentNode.nextSibling;if(e.parentNode&&e.parentNode.nextSibling&&vt(e.parentNode.nextSibling)&&e.parentNode.nextSibling.nextSibling&&e.parentNode.nextSibling.nextSibling.className&&e.parentNode.nextSibling.nextSibling.className.indexOf("aloha-table-wrapper")>=0)return e.parentNode.nextSibling.nextSibling}function nn(e,n){var r;if(e.nodeType===t.Node.TEXT_NODE&&n>0)for(r=n-1;r>=0;r--)if(e.data.charAt(r)!==" "&&e.data.charAt(r)!=="\r"&&e.data.charAt(r)!=="\n"||e.data.charCodeAt(r)===160)return!1;return e.previousSibling&&e.previousSibling.className&&e.previousSibling.className.indexOf("aloha-table-wrapper")>=0?e.previousSibling:e.parentNode&&e.parentNode.previousSibling&&e.parentNode.previousSibling.className&&e.parentNode.previousSibling.className.indexOf("aloha-table-wrapper")>=0?e.parentNode.previousSibling:e.parentNode&&e.parentNode.previousSibling&&vt(e.parentNode.previousSibling)&&e.parentNode.previousSibling.previousSibling&&e.parentNode.previousSibling.previousSibling.className&&e.parentNode.previousSibling.previousSibling.className.indexOf("aloha-table-wrapper")>=0?e.parentNode.previousSibling.previousSibling:!1}function rn(e,t){return!e.parentNode&&t==0||0<=t-1&&t-1=0;r--)St(e[r],i.parentNode,1+M(i),t);a&&!an(e[e.length-1])&&e[e.length-1].parentNode.insertBefore(document.createElement("br"),e[e.length-1].nextSibling),Ct(i);return}if(!s){var f=i.cloneNode(!1);i.removeAttribute("id"),i.parentNode.insertBefore(f,i);while(e[0].previousSibling)St(i.firstChild,f,f.childNodes.length,t)}for(r=0;r=0;--i)e.parentNode.childNodes[i].nodeType==3&&e.parentNode.childNodes[i].data.length==0&&(e.parentNode.removeChild(e.parentNode.childNodes[i]),r.startContainer==e.parentNode&&r.startOffset>i&&r.startOffset--,r.endContainer==e.parentNode&&r.endOffset>i&&r.endOffset--);if(e.parentNode.childNodes.length==1){u=r.startOffset,a=r.endOffset,r.startContainer===e.parentNode&&r.startOffset>M(e)&&(u=r.startOffset+(n(e).contents().length-1)),r.endContainer===e.parentNode&&r.endOffset>M(e)&&(a=r.endOffset+(n(e).contents().length-1)),n(e).contents().unwrap(),r.startOffset=u,r.endOffset=a;break}var l=e.parentNode;fn([e],r);if(l===e.parentNode){u=r.startOffset,a=r.endOffset,r.startContainer===e.parentNode&&r.startOffset> +M(e)&&(u=r.startOffset+(n(e).contents().length-1)),r.endContainer===e.parentNode&&r.endOffset>M(e)&&(a=r.endOffset+(n(e).contents().length-1)),n(e).contents().unwrap(),r.startOffset=u,r.endOffset=a;break}}Zt(o,r)}function bn(e,n){function i(e){return p(e,["OL","UL"])}if(!c(e,"LI")||!ft(e)||!ft(e.parentNode))return;var r=null;while(t(e.childNodes).some(i)){var s=e.lastChild;p(s,["OL","UL"])||!r&&s.nodeType==t.Node.TEXT_NODE&&/^[ \t\n\f\r]*$/.test(s.data)?(r=null,St(s,e.parentNode,1+M(e),n)):(r||(r=e.ownerDocument.createElement("li"),e.parentNode.insertBefore(r,e.nextSibling)),St(s,r,0,n))}}function wn(e,t){if(!p(e,["OL","UL"])||!ft(e))return;var r=n(e);r.children("ol,ul").each(function(e,n){c(n.previousSibling,"LI")&&St(n,n.previousSibling,n.previousSibling.childNodes.length,t)})}function En(n){var r=n.startContainer,i=n.startOffset,s=n.endContainer,o=n.endOffset,u=t(N(r).concat(r)).filter(function(e){return c(e,"li")}).slice(-1);u.length&&(i=M(u[0]),r=u[0].parentNode);if(!rn(r,i))do i==0?(i=M(r),r=r.parentNode):i--;while(!on(r,i));while(i==0&&r.parentNode)i=M(r),r=r.parentNode;u=t(N(s).concat(s)).filter(function(e){return c(e,"li")}).slice(-1),u.length&&(o=1+M(u[0]),s=u[0].parentNode);if(!sn(s,o))do o==_(s)?(o=1+M(s),s=s.parentNode):o++;while(!on(s,o));while(o==_(s)&&s.parentNode)o=1+M(s),s=s.parentNode;var a=e.createRange();return a.setStart(r,i),a.setEnd(s,o),a}function Sn(){var e=En(Et()),n=B(e,function(e){return ft(e)&&!ln(e)&&(p(e,["ol","ul"])||p(e.parentNode,["ol","ul"])||jt(e,"li"))});if(!n.length)return"none";if(t(n).every(function(e){return c(e,"ol")||c(e.parentNode,"ol")||c(e.parentNode,"li")&&c(e.parentNode.parentNode,"ol")})&&!t(n).some(function(e){return c(e,"ul")||e.querySelector&&e.querySelector("ul")}))return"ol";if(t(n).every(function(e){return c(e,"ul")||c(e.parentNode,"ul")||c(e.parentNode,"li")&&c(e.parentNode.parentNode,"ul")})&&!t(n).some(function(e){return c(e,"ol")||e.querySelector&&e.querySelector("ol")}))return"ul";var r=t(n).some(function(e){return c(e,"ol")||c(e.parentNode,"ol")||e.querySelector&&e.querySelector("ol")||c(e.parentNode,"li")&&c(e.parentNode.parentNode,"ol")}),i=t(n).some(function(e){return c(e,"ul")||c(e.parentNode,"ul")||e.querySelector&&e.querySelector("ul")||c(e.parentNode,"li")&&c(e.parentNode.parentNode,"ul")});return r&&i?"mixed":r?"mixed ol":i?"mixed ul":"none"}function xn(e){while(e&&e.nodeType!=t.Node.ELEMENT_NODE||e.nodeType==t.Node.ELEMENT_NODE&&n.inArray(t.getComputedStyle(e).display,["inline","none"])!=-1)e=e.parentNode;if(!e||e.nodeType!=t.Node.ELEMENT_NODE)return"left";var r=t.getComputedStyle(e).textAlign.replace(/^-(moz|webkit)-/,"").replace(/^auto$/,"start");return r=="start"?O(e)=="ltr"?"left":"right":r=="end"?O(e)=="ltr"?"right":"left":n.inArray(r,["center","justify","left","right"])!=-1?r:"left"}function Tn(e){var n=[];return z("createlink",e)!==undefined&&n.push(["createlink",z("createlink",e)]),t(["bold","italic","strikethrough","subscript","superscript","underline"]).forEach(function(t){q(t,e)!==undefined&&n.push([t,q(t,e)])}),t(["fontname","fontsize","forecolor","hilitecolor"]).forEach(function(t){z(t,e)!==undefined&&n.push([t,z(t,e)])}),n}function Nn(e){var n=[],r=t(qt(e)).filter(function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE})[0];return r?(n.push(["createlink",u.createlink.value(e)]),t(["bold","italic","strikethrough","subscript","superscript","underline"]).forEach(function(e){t(u[e].inlineCommandActivatedValues).indexOf(Xt(r,e))!=-1?n.push([e,!0]):n.push([e,!1])}),t(["fontname","fontsize","forecolor","hilitecolor"]).forEach(function(t){n.push([t,u[t].value(e)])}),n.push(["fontsize",Xt(r,"fontsize")]),n):n}function Cn(e,n){function u(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE}var r,i,s,o=t(qt(n)).filter(function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE})[0];if(o)for(r=0;r3)r+=i,e-=2;return e==3?r+=!t&&!n?"   ":t&&!n?"   ":!t&&n?"   ":t&&n?"   ":"impossible":r+=!t&&!n?"  ":t&&!n?"  ":!t&&n?"  ":t&&n?"  ":"impossible",r}function Ln(e,r){if(!ft(e)&&!at(e))return;var i=e,s=r;for(;;)if(0<=s-1&&ht(i,i.childNodes[s-1]))i=i.childNodes[s-1],s=_(i);else if(s==0&&!un(i)&&ht(i,i.parentNode))s=M(i),i=i.parentNode;else{if(i.nodeType!=t.Node.TEXT_NODE||n.inArray(t.getComputedStyle(i.parentNode).whiteSpace,["pre","pre-wrap"])!=-1||s==0||!/[ \xa0]/.test(i.data[s-1]))break;s--}var o=i,u=s,a=0,f=!1;for(;;)if(u0&&d.data.substr(v-1,1)===" "&&ve?t.startOffset--:t.startContainer===this&&(t.startContainer=this.parentNode,t.startOffset=e),t.endContainer===this.parentNode&&t.endOffset>e?t.endOffset--:t.endContainer===this&&(t.endContainer=this.parentNode,t.endOffset=e),n(this).remove()}})})}function _n(e,t){if(!e.length)return;var n=e[0];if(p(n.parentNode,["OL","UL"])){var r=n.parentNode.tagName;Lt(e,function(e){return f(e,r)},function(){return n.ownerDocument.createElement(r)},t);return}var i=Lt(e,function(e){return cn(e)},function(){return n.ownerDocument.createElement("blockquote")},t);yn(i,t)}function Dn(e,n){if(!ft(e))return;if(cn(e)){On(e,n);return}if(ln(e)){e.removeAttribute("class"),e.removeAttribute("dir"),e.style.margin="",e.style.padding="",e.style.border="",e.getAttribute("style")==""&&e.removeAttribute("style"),Tt(e,"div",n);return}var r=e.parentNode,i=[];while(ft(r)&&r.nodeType==t.Node.ELEMENT_NODE&&!cn(r)&&!p(r,["ol","ul"]))i.push(r),r=r.parentNode;if(!ft(r)||!cn(r)){r=e.parentNode,i=[];while(ft(r)&&r.nodeType==t.Node.ELEMENT_NODE&&!ln(r)&&!p(r,["ol","ul"]))i.push(r),r=r.parentNode}if(p(e,["OL","UL"])&&(!ft(r)||!ln(r))){e.removeAttribute("reversed"),e.removeAttribute("start"),e.removeAttribute("type");var s=[].slice.call(m(e.childNodes));if(e.attributes.length&&!p(e.parentNode,["OL","UL"]))Tt(e,"div",n);else{var o=Kt([].slice.call(m(e.childNodes)));On(e,n),Zt(o,n)}var u;for(u=0;u0&&e.startContainer.data.charAt(r-1)==="​")r--;r!==e.startOffset&&(e.setStart(e.startContainer,r),e.setEnd(e.startContainer,r))}var i="http://www.w3.org/1999/xhtml",s=!1,o=null,u={},q,R,U,z,W,X,V=0,rt={ADDRESS:!0,ARTICLE:!0,ASIDE:!0,BLOCKQUOTE:!0,CAPTION:!0,CENTER:!0,COL:!0,COLGROUP:!0,DD:!0,DETAILS:!0,DIR:!0,DIV:!0,DL:!0,DT:!0,FIELDSET:!0,FIGCAPTION:!0,FIGURE:!0,FOOTER:!0,FORM:!0,H1:!0,H2:!0,H3:!0,H4:!0,H5:!0,H6:!0,HEADER:!0,HGROUP:!0,HR:!0,LI:!0,LISTING:!0,MENU:!0,NAV:!0,OL:!0,P:!0,PLAINTEXT:!0,PRE:!0,SECTION:!0,SUMMARY:!0,TABLE:!0,TBODY:!0,TD:!0,TFOOT:!0,TH:!0,THEAD:!0,TR:!0,UL:!0,XMP:!0},st={inline:!0,"inline-block":!0,"inline-table":!0,none:!0};(function(){function r(r){if(!n||n.startContainer!=r.startContainer||n.endContainer!=r.endContainer||n.startOffset!=r.startOffset||n.endOffset!=r.endOffset)e={},t={},n=r.cloneRange()}var e={},t={},n=null;q=function(t,n){return r(n),e[t]},R=function(t,n,i){r(i),e[t]=n},U=function(t,n){r(n),delete e[t]},z=function(e,n){return r(n),t[e]},W=function(e,n,i){r(i),t[e]=n,e=="backcolor"?t.hilitecolor=n:e=="hilitecolor"&&(t.backcolor=n)},X=function(e,n){r(n),delete t[e],e=="backcolor"?delete t.hilitecolor:e=="hilitecolor"&&delete t.backcolor}})();var At={A:!0,ABBR:!0,B:!0,BDI:!0,BDO:!0,CITE:!0,CODE:!0,DFN:!0,EM:!0,H1:!0,H2:!0,H3:!0,H4:!0,H5:!0,H6:!0,I:!0,KBD:!0,MARK:!0,P:!0,PRE:!0,Q:!0,RP:!0,RT:!0,RUBY:!0,S:!0,SAMP:!0,SMALL:!0,SPAN:!0,STRONG:!0,SUB:!0,SUP:!0,U:!0,VAR:!0,ACRONYM:!0,LISTING:!0,STRIKE:!0,XMP:!0,BIG:!0,BLINK:!0,FONT:!0,MARQUEE:!0,NOBR:!0,TT:!0},Ot={colgroup:!0,table:!0,tbody:!0,tfoot:!0,thead:!0,tr:!0},Mt={script:!0,style:!0,plaintext:!0,xmp:!0},_t=n.extend({H1:!0,H2:!0,H3:!0,H4:!0,H5:!0,H6:!0},rt),Dt={CAPTION:!0,COL:!0,COLGROUP:!0,TBODY:!0,TD:!0,TFOOT:!0,TH:!0,THEAD:!0,TR:!0},Pt={DD:!0,DT:!0},Ht={A:n.extend({A:!0},rt),DD:Pt,DT:Pt,LI:{LI:!0},NOBR:n.extend({NOBR:!0},rt),H1:_t,H2:_t,H3:_t,H4:_t,H5:_t,H6:_t,TD:Dt,TH:Dt,ABBR:rt,B:rt,BDI:rt,BDO:rt,CITE:rt,CODE:rt,DFN:rt,EM:rt,I:rt,KBD:rt,MARK:rt,P:rt,PRE:rt,Q:rt,RP:rt,RT:rt,RUBY:rt,S:rt,SAMP:rt,SMALL:rt,SPAN:rt,STRONG:rt,SUB:rt,SUP:rt,U:rt,VAR:rt,ACRONYM:rt,LISTING:rt,STRIKE:rt,XMP:rt,BIG:rt,BLINK:rt,FONT:rt,MARQUEE:rt,TT:rt},Jt=["subscript","bold","fontname","fontsize","forecolor","hilitecolor","italic","strikethrough","underline"];u.backcolor={action:function(e,t){/^([0-9a-fA-F]{3}){1,2}$/.test(e)&&(e="#"+e);if(!/^(rgba?|hsla?)\(.*\)$/.test(e)&&!I(e)&&e.toLowerCase()!="transparent")return;en("backcolor",e,t)},standardInlineValueCommand:!0,relevantCssProperty:"backgroundColor",equivalentValues:function(e,t){return F(e)===F(t)}},u.bold={action:function(e,t){et("bold",t)?en("bold","normal",t):en("bold","bold",t)},inlineCommandActivatedValues:["bold","600","700","800","900"],relevantCssProperty:"fontWeight",equivalentValues:function(e,t){return e==t||e=="bold"&&t=="700"||e=="700"&&t=="bold"||e=="normal"&&t=="400"||e=="400"&&t=="normal"}},u.createlink={action:function(e,n){if(e==="")return;t(qt(Et())).forEach(function(n){t(N(n)).forEach(function(t){ft(t)&&c(t,"a")&&r(t,"href")&&t.setAttribute("href",e)})}),en("createlink",e,n)},standardInlineValueCommand:!0},u.fontname={action:function(e,t){en("fontname",e,t)},standardInlineValueCommand:!0,relevantCssProperty:"fontFamily"},u.fontsize={action:function(e,t){if(e==="")return;e=$(e);if(n.inArray(e,["xx-small","x-small","small","medium","large","x-large","xx-large","xxx-large"])==-1&&!/^[0-9]+(\.[0-9]+)?(cm|mm|in|pt|pc)$/.test(e))return;en("fontsize",e,t)},indeterm:function(){return t(qt(Et(),function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE})).map(function(e){return Xt(e,"fontsize")},!0).filter(function(e,n,r){return t(r.slice(0,n)).indexOf(e)==-1}).length>=2},value:function(e){var n=qt(e,function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE})[0];n===undefined&&(n=e.startContainer);var r=Xt(n,"fontsize");return J(r)},relevantCssProperty:"fontSize"},u.forecolor={action:function(e,t){/^([0-9a-fA-F]{3}){1,2}$/.test(e)&&(e="#"+e);if(!/^(rgba?|hsla?)\(.*\)$/.test(e)&&!I(e)&&e.toLowerCase()!="transparent")return;en("forecolor",e,t)},standardInlineValueCommand:!0,relevantCssProperty:"color",equivalentValues:function(e,t){return F(e)===F(t)}},u.hilitecolor={action:function(e,t){/^([0-9a-fA-F]{3}){1,2}$/.test(e)&&(e="#"+e);if(!/^(rgba?|hsla?)\(.*\)$/.test(e)&&!I(e)&&e.toLowerCase()!="transparent")return;en("hilitecolor",e,t)},indeterm:function(){return t(qt(Et(),function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE})).map(function(e){return Xt(e,"hilitecolor")},!0).filter(function(e,n,r){return t(r.slice(0,n)).indexOf(e)==-1}).length>=2},standardInlineValueCommand:!0,relevantCssProperty:"backgroundColor",equivalentValues:function(e,t){return F(e)===F(t)}},u.italic={action:function(e,t){et("italic",t)?en("italic","normal",t):en("italic","italic",t)},inlineCommandActivatedValues:["italic","oblique"],relevantCssProperty:"fontStyle"},u.removeformat={action:function(e,n){function o(e){return ft(e)&&p(e,["abbr","acronym","b","bdi","bdo","big","blink","cite","code","dfn","em","font","i","ins","kbd","mark","nobr","q","s","samp","small","span","strike","strong","sub","sup","tt","u","var"])}var r,i,s,u=qt(Et(),o);t(u).forEach(function(e){while(e.hasChildNodes())St(e.firstChild,e.parentNode,M(e),Et());e.parentNode.removeChild(e)}),ft(Et().startContainer)&&Et().startContainer.nodeType==t.Node.TEXT_NODE&&Et().startOffset!=0&&Et().startOffset!=_(Et().startContainer)&&(Et().startContainer==Et().endContainer?(r=Et().endOffset-Et().startOffset,s=Et().startContainer.splitText(Et().startOffset),Et().setStart(s,0),Et().setEnd(s,r)):Et().setStart(Et().startContainer.splitText(Et().startOffset),0)),ft(Et().endContainer)&&Et().endContainer.nodeType==t.Node.TEXT_NODE&&Et().endOffset!=0&&Et().endOffset!=_(Et().endContainer)&&(i=[Et().startContainer,Et().startOffset],r=[Et().endContainer,Et().endOffset],Et().setEnd(document.documentElement,0),r[0].splitText(r[1]),Et().setStart(i[0],i[1]),Et().setEnd(r[0],r[1])),t(qt(Et(),ft)).forEach(function(e){while(o(e.parentNode)&&ht(e.parentNode,e))fn([e],Et())}),t(["subscript","bold","fontname","fontsize","forecolor","hilitecolor","italic","strikethrough","underline"]).forEach(function(e){en(e,null,n)})}},u.strikethrough={action:function(e,t){et("strikethrough",t)?en("strikethrough",null,t):en("strikethrough","line-through",t)},inlineCommandActivatedValues:["line-through"]},u.subscript={action:function(e,t){var n=et("subscript",t);en("subscript",null,t),n||en("subscript","subscript",t)},indeterm:function(){var e=qt(Et(),function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE});return t(e).some(function(e){return Xt(e,"subscript")=="subscript"})&&t(e).some(function(e){return Xt(e,"subscript")!="subscript"})||t(e).some(function(e){return Xt(e,"subscript")=="mixed"})},inlineCommandActivatedValues:["subscript"]},u.superscript={action:function(e,t){var n=et("superscript",t);en("superscript",null,t),n||en("superscript","superscript",t)},indeterm:function(){var e=qt(Et(),function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE});return t(e).some(function(e){return Xt(e,"superscript")=="superscript"})&&t(e).some(function(e){return Xt(e,"superscript")!="superscript"})||t(e).some(function(e){return Xt(e,"superscript")=="mixed"})},inlineCommandActivatedValues:["superscript"]},u.underline={action:function(e,t){et("underline",t)?en("underline",null,t):en("underline","underline",t)},inlineCommandActivatedValues:["underline"]},u.unlink={action:function(){var e=Et(),t=[],n;for(n=e.startContainer;n;n=n.parentNode)c(n,"A")&&r(n,"href")&&t.unshift(n);for(n=e.startContainer;n!=g(e.endContainer);n=y(n))c(n,"A")&&r(n,"href")&&(H(n,e)||w(n,e.endContainer)||n==e.endContainer)&&t.push(n);var i;for(i=0;i0&&(a=c(o.childNodes[u-1],"br")||!1,f=c(o.childNodes[u-1],"hr")||!1);if(u==0&&ft(o.previousSibling)&&bt(o.previousSibling)){o.parentNode.removeChild(o.previousSibling);continue}if(0<=u-1&&u-1$/.test(e)&&(e=e.slice(1,-1)),e=e.toLowerCase();if(t(jn).indexOf(e)==-1)return;var i=En(Et()),s=B(i,function(e){return ft(e)&&(hn(e)||jt(e,"p")||p(e,["dd","dt"]))&&!t(C(e)).some(it)}),o=Kt(s);for(r=0;r=t.startOffset},!0).forEach(function(e){e.parentNode.removeChild(e)}),n.insertNode(r),ot(n.startContainer)&&gn(n.startContainer),n.setStart(i.parentNode,1+M(i)),n.setEnd(i.parentNode,1+M(i));var o;for(o=0;o1){for(s=0;s=1&&r.length-i.length>=1}),null!=u[e].inlineCommandActivatedValues&&(u[e].state=function(n){var r=qt(n,function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE});return r.length==0?t(u[e].inlineCommandActivatedValues).indexOf(Xt(n.startContainer,e))!=-1:t(r).every(function(n){return t(u[e].inlineCommandActivatedValues).indexOf(Xt(n,e))!=-1})}),null!=u[e].standardInlineValueCommand&&(u[e].indeterm=function(){var n=t(qt(Et())).filter(function(e){return ft(e)&&e.nodeType==t.Node.TEXT_NODE},!0).map(function(t){return Xt(t,e)}),r;for(r=1;r0?"partial":"full",a=n.startOffset,f=this.length);break;case 1:this===n.startContainer&&n.startOffset===0&&(o.inselection=!0,i="full"),r===n.startContainer&&n.startOffset===t&&(o.inselection=!0,i="full")}}if(o.inselection&&!l){i=="none"&&(i="full");switch(this.nodeType){case 3:this===n.endContainer&&(o.inselection=!1,n.endOffset0){for(c=0;c0&&f.each(function(){if(this===o)return e.Log.debug(a,"reached limit dom obj"),!1;if(s(this,i))return l===!1&&(l=[]),e.Log.debug(a,"reached object equal to markup"),c++,l[c]=this,!0}),l},standardSectionsAndGroupingContentComparator:function(t,n){if(t.nodeType!==1)return e.Log.debug(this,"only element nodes (nodeType == 1) can be compared"),!1;if(!n[0].nodeName)return!1;var r=e.Selection.replacingElements[t.nodeName.toLowerCase()];return r&&r[n[0].nodeName.toLowerCase()]},standardTagNameComparator:function(t,n){return t.nodeType===1?t.nodeName!=n[0].nodeName?!1:!0:(e.Log.debug(this,"only element nodes (nodeType == 1) can be compared"),!1)},standardTextLevelSemanticsComparator:function(t,n){return t.nodeType===1?t.nodeName!=n[0].nodeName?!1:this.standardAttributesComparator(t,n)?!0:!1:(e.Log.debug(this,"only element nodes (nodeType == 1) can be compared"),!1)},standardAttributesComparator:function(e,t){var n=s.words(e&&e.className||""),r=s.words(t.length&&t[0].className||"");return i.sortUnique(n),i.sortUnique(r),i.equal(n,r)},changeMarkup:function(n,r,i){var s=r[0].tagName.toLowerCase(),o,u,l,p=this.isRangeObjectWithinMarkup(n,!1,r,i,u),d=this.isRangeObjectWithinMarkup(n,!0,r,i,u),v,m,g,y,b,w;if(this.replacingElements[s])l=n,n=new this.SelectionRange(n),e.activeEditable?o=e.activeEditable.obj.get(0):o=t("body"),n.update(o),r.isReplacingElement=!0;else if(n.isCollapsed())return e.Log.debug(this,"early returning from applying markup because nothing is currently selected"),!1;e.activeEditable?u=e.activeEditable.obj[0]:u=t("body"),!r.isReplacingElement&&n.startOffset===0&&null!=(g=this.getTextNodeSibling(false,n.commonAncestorContainer.parentNode,n.startContainer))&&(y=this.isRangeObjectWithinMarkup({startContainer:g,startOffset:0},!1,r,i,u)),!r.isReplacingElement&&n.endOffset===n.endContainer.length&&null!=(v=this.getTextNodeSibling(true,n.commonAncestorContainer.parentNode,n.endContainer))&&(m=this.isRangeObjectWithinMarkup({startContainer:v,startOffset:0},!1,r,i,u));if(!r.isReplacingElement&&p&&!d)e.Log.info(this,"markup 2 non-markup"),this.prepareForRemoval(n.getSelectionTree(),r,i),t(p).addClass("preparedForRemoval"),this.insertCroppedMarkups(p,n,!1,i);else if(!r.isReplacingElement&&p&&d)e.Log.info(this,"markup 2 markup"),this.prepareForRemoval(n.getSelectionTree(),r,i),this.splitRelevantMarkupObject(p,d,n,i);else if(!r.isReplacingElement&&(!p&&d||m||y))e.Log.info(this,"non-markup 2 markup OR with next2markup"),y&&m?(b=new e.Selection.SelectionRange(n),b.startContainer=t(y[y.length-1]).textNodes()[0],b.startOffset=0,b.endContainer=t(m[m.length-1]).textNodes().last()[0],b.endOffset=b.endContainer.length,b.update(),this.applyMarkup(b.getSelectionTree(),n,r,i),e.Log.info(this,"double extending previous markup(previous and after selection), actually wrapping it ...")):y&&!m&&!d?(this.extendExistingMarkupWithSelection(y,n,!1,i),e.Log.info(this,"extending previous markup")):y&&!m&&d?(b=new e.Selection.SelectionRange(n),b.startContainer=t(y[y.length-1]).textNodes()[0],b.startOffset=0,b.endContainer=t(d[d.length-1]).textNodes().last()[0],b.endOffset=b.endContainer.length,b.update(),this.applyMarkup(b.getSelectionTree(),n,r,i),e.Log.info(this,"double extending previous markup(previous and relevant at the end), actually wrapping it ...")):!y&&m?(this.extendExistingMarkupWithSelection(m,n,!0,i),e.Log.info(this,"extending following markup backwards")):this.extendExistingMarkupWithSelection(d,n,!0,i);else if(r.isReplacingElement||!p&&!d&&!y&&!m){e.Log.info(this,"non-markup 2 non-markup");if(c(n)){var E=r.clone();h(n)&&E[0].appendChild(a.createEndBreak()),e.activeEditable&&t.browser.mozilla&&e.activeEditable.obj.focus(),a.isEditable(n.startContainer)?(a.copyAttributes(n.startContainer,E[0]),t(n.startContainer).after(E[0]).remove()):a.isEditingHost(n.startContainer)&&(t(n.startContainer).append(E[0]),a.ensureContainerEditable(E[0])),l.startContainer=E[0],l.endContainer=E[0],l.startOffset=0,l.endOffset=0;return}this.applyMarkup(n.getSelectionTree(),n,r,i,{setRangeObject2NewMarkup:!0}),l.startContainer=n.startContainer,l.endContainer=n.endContainer,l.startOffset=n.startOffset,l.endOffset=n.endOffset}r.isReplacingElement&&(l&&l.startContainer.className&&l.startContainer.className.indexOf("preparedForRemoval")>-1&&(w=t(l.startContainer).parents(r[0].tagName).get(0),l.startContainer=w,n.startContainer=w),l&&l.endContainer.className&&l.endContainer.className.indexOf("preparedForRemoval")>-1&&(w=t(l.endContainer).parents(r[0].tagName).get(0),l.endContainer=w,n.endContainer=w)),t(".preparedForRemoval").zap(),r.isReplacingElement?(f.Node.ELEMENT_NODE===l.startContainer.nodeType&&l.startContainer.childNodes&&l.startContainer.childNodes.length0&&this.prepareForRemoval(u.children,r,i)},wrapMarkupAroundSelectionTree:function(n,r,i,s,o){var u=[],a=-1,f=!0,l="",c="",h,p,d,v,m,g,y;e.Log.debug(this,"The formatting <"+i[0].tagName+"> will be wrapped around the selection");for(m=0;m because this tag is not allowed inside <"+g.domobj.parentNode.tagName.toLowerCase()+">");continue}if(g.domobj&&g.domobj.nodeType===3&&t.trim(g.domobj.nodeValue).length===0)continue;if(g.domobj&&g.selection=="partial"&&!i.isReplacingElement)if(g.startOffset!==undefined&&g.endOffset===undefined)a++,l+=g.domobj.data.substr(0,g.startOffset),g.domobj.data=g.domobj.data.substr(g.startOffset,g.domobj.data.length-g.startOffset),u[a]=g.domobj;else if(g.endOffset!==undefined&&g.startOffset===undefined)a++,c+=g.domobj.data.substr(g.endOffset,g.domobj.data.length-g.endOffset),g.domobj.data=g.domobj.data.substr(0,g.endOffset),u[a]=g.domobj;else if(g.endOffset!==undefined&&g.startOffset!==undefined){if(g.startOffset==g.endOffset){e.Log.debug(this,"skipping empty selection");continue}a++,l+=g.domobj.data.substr(0,g.startOffset),y=g.domobj.data.substr(g.startOffset,g.endOffset-g.startOffset),c+=g.domobj.data.substr(g.endOffset,g.domobj.data.length-g.endOffset),g.domobj.data=y,u[a]=g.domobj}else e.Log.debug(this,"diving into object"),this.applyMarkup(g.children,r,i,s,o);g.domobj&&(g.selection=="full"||g.selection=="partial"&&i.isReplacingElement)&&(a++,u[a]=g.domobj)}u.length>0&&(u=t(u),t.each(u,function(e,n){t.browser.msie&&n.nodeType==3&&!n.nextSibling&&!n.previousSibling&&n.parentNode&&n.parentNode.nodeName.toLowerCase()=="li"&&(n.data=t.trim(n.data))}),v=u.wrapAll(i).parent(),v.before(l).after(c),o.setRangeObject2NewMarkup&&(d=u.textNodes(),d.index(r.startContainer)!=-1&&(r.startOffset=0),d.index(r.endContainer)!=-1&&(r.endOffset=r.endContainer.length),f=!0),o.setRangeObject2NextSibling&&(h=!0,p=v.textNodes(!0).last()[0],u.index(r.startContainer)!=-1&&(r.startContainer=this.getTextNodeSibling(h,v.parent(),p),r.startOffset=0),u.index(r.endContainer)!=-1&&(r.endContainer=this.getTextNodeSibling(h,v.parent(),p),r.endOffset=r.endOffset-p.length)),o.setRangeObject2PreviousSibling&&(h=!1,p=v.textNodes(!0).first()[0],u.index(r.startContainer)!=-1&&(r.startContainer=this.getTextNodeSibling(h,v.parent(),p),r.startOffset=0),u.index(r.endContainer)!=-1&&(r.endContainer=this.getTextNodeSibling(h,v.parent(),p),r.endOffset=r.endContainer.length)))},getTextNodeSibling:function(e,n,r){var i=t(n).textNodes(!0),s,o;return o=i.index(r),o==-1?!1:(s=o+(e?1:-1),i[s]||!1)},optimizeSelectionTree4Markup:function(e,n,r){var i=[],s=0,o=0,u=this,a,f,l,c;typeof r=="undefined"&&(r=function(e,t){return u.standardTextLevelSemanticsComparator(t)});for(a=0;a=0;f--){if(!this.canMarkupBeApplied2ElementAsWhole([e[f]],n)||!this.isMarkupAllowedToStealSelectionTreeElement(e[f],n))break;c=f}l=a;for(f=a+1;f0&&!this.canMarkupBeApplied2ElementAsWhole(i.children,t))return!1}}return s},canTag1WrapTag2:function(e,t){e=e=="#text"?"textNode":e.toLowerCase(),t=t=="#text"?"textNode":t.toLowerCase();var n=this.tagHierarchy[e];return n?this.tagHierarchy[t]?n[t]:!0:!0},mayInsertTag:function(t){var n;if(typeof this.rangeObject.unmodifiableMarkupAtStart=="object"){for(n=0;n0){var n=this.getStartContainerParents(),r=e.editables,i,s,o,u;for(i=0;i ");r?n(t).before(l):n(t).after(l),u.startContainer=u.endContainer=l[0],u.startOffset=u.endOffset=0,E(u),window.$_alohaPlaceholder=l}else{var h=i.startContainer.nodeType===3&&i.startContainer===i.endContainer&&i.startContainer.nodeValue!==""&&(r?i.startOffset===1:i.endOffset+1===i.endContainer.length)||i.startContainer.nodeType===1&&(!i.startOffset||i.startContainer.childNodes[i.startOffset]&&i.startContainer.childNodes[i.startOffset].nodeType===1);if(h){var v=s.insertZeroWidthTextNodeFix(t,r);u.startContainer=u.endContainer=v,u.startOffset=u.endOffset=r?1:0}else u.startContainer=u.endContainer=a,u.startOffset=u.endOffset=r?c(a):0,r||s.insertZeroWidthTextNodeFix(t,!0);E(u)}u.select(),e.trigger("aloha-block-selected",t),e.Selection.preventSelectionChanged()}var o=window.GENTICS,u=!!(n.browser.msie&&9>parseInt(n.browser.version,10));return e.Markup=t.extend({keyHandlers:{},addKeyHandler:function(e,t){this.keyHandlers[e]||(this.keyHandlers[e]=[]),this.keyHandlers[e].push(t)},removeKeyHandler:function(e){this.keyHandlers[e]&&(this.keyHandlers[e]=null)},insertBreak:function(){var t=e.Selection.rangeObject,r,i,s;t.isCollapsed()||this.removeSelectedMarkup(),s=n("
"),o.Utils.Dom.insertIntoDOM(s,t,e.activeEditable.obj),i=o.Utils.Dom.searchAdjacentTextNode(s.parent().get(0),o.Utils.Dom.getIndexInParent(s.get(0))+1,!1),i&&(r=i.data.search(/\S/),r>0&&(i.data=i.data.substring(r))),t.startContainer=t.endContainer=s.get(0).parentNode,t.startOffset=t.endOffset=o.Utils.Dom.getIndexInParent(s.get(0))+1,t.correctRange(),t.clearCaches(),t.select()},preProcessKeyStrokes:function(t){if(t.type!=="keydown")return!1;var n,r,i;if(this.keyHandlers[t.keyCode]){r=this.keyHandlers[t.keyCode];for(i=0;i0&&i.data.charAt(h-1)==="​")h--;h!=t.startOffset&&(t.setStart(t.startContainer,h),t.setEnd(t.startContainer,h),o=e.getSelection(),o.removeAllRanges(),o.addRange(t))}else if(r==39){h=t.startOffset;while(h0;if(b){if(!m(y))return!0;a=y[0]}}var w;if(!a){w=37===r||38===r,h=t.startOffset;if(l(i)){if(w){var E=1===h;if(!E&&!v(i,h))return!0}else if(!g(i,h))return!0}else i=i.childNodes[h===c(i)?h-1:h];a=w?d(i):p(i)}return f(a)?(S(a,w,t),!1):!0},processShiftEnter:function(e){this.insertHTMLBreak(e.getSelectionTree(),e)},processEnter:function(e){e.splitObject?this.splitRangeObject(e):this.insertHTMLBreak(e.getSelectionTree(),e)},insertHTMLCode:function(t){var r=e.Selection.rangeObject;this.insertHTMLBreak(r.getSelectionTree(),r,n(t))},insertHTMLBreak:function(t,r,i){var s,u,a,f,l,c,h,p,d;i=i||n("
");for(s=0,u=t.length;s0?(l=n(t[s-1].domobj),l.after(i)):(c=n(t[1].domobj),c.before(i)),r.startContainer=r.endContainer=i[0].parentNode,r.startOffset=r.endOffset=o.Utils.Dom.getIndexInParent(i[0])+1,r.correctRange();else if(a.domobj&&a.domobj.nodeType===3){a.domobj.nextSibling&&a.domobj.nextSibling.nodeType==1&&e.Selection.replacingElements[a.domobj.nextSibling.nodeName.toLowerCase()]&&f.after("
");if(this.needEndingBreak()){d=a.domobj;while(d)if(d.nextSibling)d=!1;else{d=d.parentNode;if(o.Utils.Dom.isBlockLevelElement(d)||o.Utils.Dom.isListElement(d))break;d===r.limitObject&&(d=!1)}d&&n(d).append('
')}f.between(i,a.startOffset),p=0,h=i[0];while(h)h=h.previousSibling,++p;r.startContainer=i[0].parentNode,r.endContainer=i[0].parentNode,r.startOffset=p,r.endOffset=p,r.correctRange()}else a.domobj&&a.domobj.nodeType===1&&(f.parent().find("br.aloha-ephemera").length===0&&(n(r.limitObject).find("br.aloha-ephemera").remove(),n(r.commonAncestorContainer).append(this.getFillUpElement(r.splitObject))),f.after(i),r.startContainer=r.commonAncestorContainer,r.endContainer=r.startContainer,r.startOffset=s+2,r.endOffset=s+2,r.update())}r.select()},needEndingBreak:function(){return!n.browser.msie},getSelectedText:function(){var t=e.Selection.rangeObject;return t.isCollapsed()?!1:this.getFromSelectionTree(t.getSelectionTree(),!0)},getFromSelectionTree:function(e,t){var r="",i,s,o,u;for(i=0,s=e.length;i0&&(i+=u.domobj.data.substring(0,u.startOffset)),u.endOffset0&&f.get(0).nodeType==1&&f.get(0).nodeName.toLowerCase()==="br"&&(t.startContainer=a.get(0)),t.startContainer||(t.startContainer=a.textNodes(!0,!0).first().get(0)),t.startContainer||(t.startContainer=a.textNodes(!1).first().parent().get(0)),t.startContainer?(t.endContainer=t.startContainer,t.startOffset=0,t.endOffset=0):(t.startContainer=t.endContainer=a.parent().get(0),t.startOffset=t.endOffset=o.Utils.Dom.getIndexInParent(a.get(0))),t.update(),t.select()},getInsertAfterObject:function(t,r){var i,s,o;for(s=0;s')},removeElementContentWhitespaceObj:function(e){var t=0,n=[],r,i,s;for(r=0;r0){d=i.contents(),d.length!==t.length&&this.removeElementContentWhitespaceObj(d);for(c=0,m=t.length;c1||l.domobj.nodeType===1&&l.children.length===0?d.eq(c).remove():o.Utils.Dom.isSplitObject(i[0])?u?i.html(u):i.empty():(i.empty(),i.addClass("preparedForRemoval"));continue}l.selection!=="none"?(l.domobj&&l.domobj.nodeType===3&&l.startOffset!==undefined&&(h=l.domobj.data,l.startOffset>0?l.domobj.data=h.substr(0,l.startOffset):t.length>1?n(l.domobj).remove():(v=n(l.domobj).parent(),o.Utils.Dom.isSplitObject(v[0])?u?v.html(u):v.empty():v.remove()),h.length-l.startOffset>0?d[c].data=h.substr(l.startOffset,h.length):d.length>1?d.eq(c).remove():o.Utils.Dom.isBlockLevelElement(i[0])?u?i.html(u):i.empty():(i.empty(),i.addClass("preparedForRemoval"))),f=!0,l.children.length>0&&this.splitRangeObjectHelper(l.children,r,d.eq(c),s)):l.selection==="none"&&f===!0&&(p=n(l.domobj).remove())}}else e.Log.error(this,"can not split splitObject due to an empty selection tree");a.find("br.aloha-ephemera:gt(0)").remove(),i.find("br.aloha-ephemera:gt(0)").remove(),a.find(".preparedForRemoval").remove(),i.find(".preparedForRemoval").remove(),a.contents().length===0&&o.Utils.Dom.isSplitObject(a[0])&&u&&a.html(u),i.contents().length===0&&o.Utils.Dom.isSplitObject(i[0])&&u&&i.html(u)},getSplitFollowUpContainer:function(e){var t=e.splitObject.nodeName.toLowerCase(),r,i,s;switch(t){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":s=n(e.splitObject).textNodes(":not(.aloha-cleanme)").last()[0];if(s&&e.startContainer===s&&e.startOffset===s.length)return r=n("

"),i=n(e.splitObject.outerHTML).contents(),r.append(i),r;break;case"li":if(e.startContainer.nodeName.toLowerCase()==="br"&&n(e.startContainer).hasClass("aloha-ephemera"))return r=n("

"),i=n(e.splitObject.outerHTML).contents(),r.append(i),r;if(!e.splitObject.nextSibling&&n.trim(n(e.splitObject).text()).length===0)return r=n("

"),r}return n(e.splitObject.outerHTML)},transformDomObject:function(e,t,r){var i=n(e),s=n("<"+t+">"),o,u=i[0].cloneNode(!1).attributes;if(u)for(o=0;o0&&n.push(t)}),t.each(this._eventHandlers[e],function(e,t){t.handler.apply(t.scope,n)})},unbindAll:function(){this._eventHandlers=null}}}),define("aloha/registry",["jquery","aloha/observable","util/class"],function(e,t,n){return n.extend(t,{_entries:null,_ids:null,_constructor:function(){this._entries={},this._ids=[]},register:function(e,t){this._entries[e]=t,this._ids.push(e),this.trigger("register",t,e)},unregister:function(e){var t,n=this._entries[e];delete this._entries[e];for(t in this._ids)if(this._ids.hasOwnProperty(t)&&this._ids[t]===e){this._ids.splice(t,1);break}this.trigger("unregister",n,e)},get:function(e){return this._entries[e]},has:function(e){return this._entries[e]?!0:!1},getEntries:function(){return e.extend({},this._entries)},getIds:function(){return e.extend([],this._ids)}})}),define("aloha/contenthandlermanager",["jquery","aloha/registry","util/class","aloha/console"],function(e,t,n,r){return new(t.extend({createHandler:function(e){if(typeof e.handleContent!="function")throw"ContentHandler has no function handleContent().";var t=n.extend({handleContent:function(e){}},e);return new t},handleContent:function(e,t){var n,i,s=this.getIds();if(typeof t.contenthandler=="undefined"){t.contenthandler=[];for(i in s)s.hasOwnProperty(i)&&t.contenthandler.push(s[i])}for(i in t.contenthandler)if(t.contenthandler.hasOwnProperty(i)){n=this.get(t.contenthandler[i]),n&&(typeof n.handleContent=="function"?e=n.handleContent(e,t):r.error("A valid content handler needs the method handleContent."));if(null===e)break}return e}}))}),define("util/trees",["jquery"],function(e){function t(t,n,r){var i=e.type(t),s,o,u,a,f,l;if("array"===i){o=r?t:[],u=0;for(f=0,a=t.length;f').insertAfter(t),u.height(t.height()).width(t.width()).html(t.val()),t.hide(),t.parents("form:first").submit(function(){t.val(e.getContents())}),this.obj=u,!0;default:}return!1},initPlaceholder:function(){e.settings.placeholder&&this.isEmpty()&&this.addPlaceholder()},isEmpty:function(){var e=n.trim(this.getContents()),t=e==="
"?!0:!1;return e.length===0||t},initEmptyEditable:function(){var e=this.obj;this.empty(this.getContents())&&n(e).prepend('
')},addPlaceholder:function(){var t=n("
"),r=n(""),i,s=this.obj;h.Utils.Dom.allowsNesting(s[0],t[0])?i=t:i=r;if(n("."+this.placeholderClass,s).length!==0)return;n(s).append(i.addClass(this.placeholderClass)),n.each(e.settings.placeholder,function(e,t){s.is(e)&&i.html(t)}),n("br",s).remove()},removePlaceholder:function(e,t){var r=this.placeholderClass,s;if(n("."+this.placeholderClass,e).length===0)return;t===!0?window.setTimeout(function(){s=new i.SelectionRange,s.startContainer=s.endContainer=e.get(0),s.startOffset=s.endOffset=0,n("."+r,e).remove(),s.select()},100):n("."+r,e).remove()},destroy:function(){this===e.getActiveEditable()&&this.blur();switch(this.originalObj.get(0).nodeName.toLowerCase()){case"label":case"button":break;case"textarea":case"input":this.originalObj.val(this.getContents()),this.obj.remove(),this.originalObj.show();break;default:}this.ready=!1,this.removePlaceholder(this.obj),this.obj.removeClass("aloha-editable").contentEditable(!1).unbind("mousedown click dblclick focus keydown keypress keyup"),e.trigger("aloha-editable-destroyed",[this]),e.unregisterEditable(this)},setUnmodified:function(){this.originalContent=this.getContents()},isModified:function(){return this.originalContent!==this.getContents()},toString:function(){return"Aloha.Editable"},isDisabled:function(){return!this.obj.contentEditable()||this.obj.contentEditable()==="false"},disable:function(){return this.isDisabled()||this.obj.contentEditable(!1)},enable:function(){return this.isDisabled()&&this.obj.contentEditable(!0)},activate:function(t){var n=e.getActiveEditable();if(p){p=!1;return}if(t&&t.type==="focus"&&n!==null&&n.obj.parent().get(0)===t.currentTarget)return;if(this.isActive||this.isDisabled())return;this.obj.addClass("aloha-editable-active"),e.activateEditable(this),p=!0,this.removePlaceholder(this.obj,!0),p=!1,this.isActive=!0,e.trigger("aloha-editable-activated",{oldActive:n,editable:this})},blur:function(){this.obj.blur(),this.isActive=!1,this.initPlaceholder(),this.obj.removeClass("aloha-editable-active"),e.trigger("aloha-editable-deactivated",{editable:this}),e.activeEditable.smartContentChange({type:"blur"},null)},empty:function(e){return null===e||n.trim(e)===""||e==="
"},getContents:function(t){var i=this.obj.html(),s=d[this.getId()];if(!s||i!==s.raw){a.removeZeroWidthTextNodeFix();var u=this.obj.clone(!1);this.removePlaceholder(u),u=n(f.prune(u[0])),r.makeClean(u),u=n("
"+o.handleContent(u.html(),{contenthandler:e.settings.contentHandler.getContents,command:"getContents"})+"
"),s=d[this.getId()]={},s.raw=i,s.element=u}return t?s.element.clone().contents():(null==s.serialized&&(s.serialized=m(s.element[0])),s.serialized)},setContents:function(t,n){var r=null;return e.getActiveEditable()===this&&(e.deactivateEditable(),r=this),this.obj.html(t),null!==r&&r.activate(),this.smartContentChange({type:"set-contents"}),n?this.obj.contents():m(this.obj[0])},getId:function(){return this.obj.attr("id")},smartContentChange:function(t){function f(){return null==a&&(a=r.getSnapshotContent()),a}var r=this,i=null,s,o;if(t&&(t.metaKey||t.crtlKey||t.altKey))return!1;t&&t.originalEvent&&(s=new RegExp("U\\+(\\w{4})"),o=s.exec(t.originalEvent.keyIdentifier),i=this.keyCodeMap[this.keyCode]||String.fromCharCode(t.which)||"unknown");var a=null;n.inArray(i,this.sccDelimiters)>=0?(clearTimeout(this.sccTimerIdle),clearTimeout(this.sccTimerDelay),this.sccTimerDelay=window.setTimeout(function(){e.trigger("aloha-smart-content-changed",{editable:r,keyIdentifier:t.originalEvent.keyIdentifier,keyCode:t.keyCode,"char":i,triggerType:"keypress",getSnapshotContent:f}),u.debug("Aloha.Editable","smartContentChanged: event type keypress triggered")},this.sccDelay)):t&&t.type==="paste"?e.trigger("aloha-smart-content-changed",{editable:r,keyIdentifier:null,keyCode:null,"char":null,triggerType:"paste",getSnapshotContent:f}):t&&t.type==="blur"?e.trigger("aloha-smart-content-changed",{editable:r,keyIdentifier:null,keyCode:null,"char":null,triggerType:"blur",getSnapshotContent:f}):t&&t.type==="block-change"?e.trigger("aloha-smart-content-changed",{editable:r,keyIdentifier:null,keyCode:null,"char":null,triggerType:"block-change",getSnapshotContent:f}): +i!==null&&(clearTimeout(this.sccTimerDelay),clearTimeout(this.sccTimerIdle),this.sccTimerIdle=window.setTimeout(function(){e.trigger("aloha-smart-content-changed",{editable:r,keyIdentifier:null,keyCode:null,"char":null,triggerType:"idle",getSnapshotContent:f})},this.sccIdle))},getSnapshotContent:function(){var e=this.snapshotContent;return this.snapshotContent=this.getContents(),e}}),e.Editable.setContentSerializer=function(e){m=e},e.Editable.getContentSerializer=function(){return m}}),define("aloha/plugin",["aloha/core","jquery","util/class","aloha/pluginmanager","aloha/console"],function(e,t,n,r,i){var s=n.extend({name:null,defaults:{},settings:{},dependencies:[],_constructor:function(e){typeof e!="string"?i.error("Cannot initialise unnamed plugin, skipping"):this.name=e},checkDependencies:function(){var n=!0,r=this;return t.each(this.dependencies,function(){e.isPluginLoaded(this)||(n=!1,i.error("plugin."+r.name,'Required plugin "'+this+'" not found.'))}),n},init:function(){},getEditableConfig:function(e){var n=null,r=!1,i=this;return this.settings.editables&&t.each(this.settings.editables,function(s,o){var u;if(e.is(s)){r=!0;if(o instanceof Array)n=[],n=t.merge(n,o);else if(typeof o=="object"){n={},n["aloha-editable-selector"]=s;for(u in o)o.hasOwnProperty(u)&&(o[u]instanceof Array?n[u]=o[u]:typeof o[u]=="object"?(n[u]={},n[u]=t.extend(!0,n[u],i.config[u],o[u])):n[u]=o[u])}else n=o}}),r||(typeof this.settings.config=="undefined"||!this.settings.config?n=this.config:n=this.settings.config),n},makeClean:function(e){},getUID:function(e){return i.deprecated("plugin","getUID() is deprecated. Use plugin.name instead."),this.name},toString:function(){return this.name},log:function(e,t){i.deprecated("plugin","log() is deprecated. Use Aloha.console instead."),i.log(e,this,t)}});return s.create=function(n,i){var o=new(s.extend(i))(n);return o.settings=t.extendObjects(!0,o.defaults,e.settings[n]),r.register(o),o},s}),define("aloha/command",["aloha/core","aloha/registry","aloha/engine","util/dom","aloha/contenthandlermanager"],function(e,t,n,r,i){var s={execCommand:function(t,s,o,u){var a={commandId:t,preventDefault:!1};e.trigger("aloha-command-will-execute",a);if(a.preventDefault===!0)return;if(!u){if(!e.getSelection().getRangeCount())return;u=e.getSelection().getRangeAt(0)}t.toLowerCase()==="inserthtml"&&(o=i.handleContent(o,{contenthandler:e.settings.contentHandler.insertHtml,command:"insertHtml"})),n.execCommand(t,s,o,u);if(e.getSelection().getRangeCount()){u=e.getSelection().getRangeAt(0);var f=u.commonAncestorContainer;f.parentNode&&(f=f.parentNode);var l=new window.GENTICS.Utils.RangeObject;l.startContainer=u.startContainer,l.startOffset=u.startOffset,l.endContainer=u.endContainer,l.endOffset=u.endOffset,r.doCleanup({merge:!0,removeempty:!1},l,f),l.select()}e.trigger("aloha-command-executed",t)},queryCommandEnabled:function(t,r){if(!r){if(!e.getSelection().getRangeCount())return;r=e.getSelection().getRangeAt(0)}return n.queryCommandEnabled(t,r)},queryCommandIndeterm:function(t,r){if(!r){if(!e.getSelection().getRangeCount())return;r=e.getSelection().getRangeAt(0)}return n.queryCommandIndeterm(t,r)},queryCommandState:function(t,r){if(!r){if(!e.getSelection().getRangeCount())return;r=e.getSelection().getRangeAt(0)}return n.queryCommandState(t,r)},queryCommandSupported:function(e){return n.queryCommandSupported(e)},queryCommandValue:function(t,r){if(!r){if(!e.getSelection().getRangeCount())return;r=e.getSelection().getRangeAt(0)}return n.queryCommandValue(t,r)},querySupportedCommands:function(){var e=[],t;for(t in n.commands)n.commands.hasOwnProperty(t)&&e.push(t);return e}};return s=new(t.extend(s)),e.execCommand=s.execCommand,e.queryCommandEnabled=s.queryCommandEnabled,e.queryCommandIndeterm=s.queryCommandIndeterm,e.queryCommandState=s.queryCommandState,e.queryCommandSupported=s.queryCommandSupported,e.queryCommandValue=s.queryCommandValue,e.querySupportedCommands=s.querySupportedCommands,s}),define("aloha/jquery.aloha",["aloha/core","aloha/selection","jquery","aloha/console"],function(e,t,n,r){function s(e,t,n,r){if(t===r.target||!/textarea|input|select/i.test(r.target.nodeName)&&r.target.type!=="text")return e.apply(t,n);return}function o(e){var t,r,i,o;if(typeof e.data!="string")return;t=e.handler,r=e.data.toLowerCase().split(" "),i={};for(o=0;on&&(t=n),t<=0?this.prepend(e):this.children().eq(t-1).after(e)):t<=0?this.before(e):t>=this[0].length?this.after(e):(r=this[0].data,this[0].data=r.substring(0,t),this.after(r.substring(t,r.length)),this.after(e))},n.fn.contentEditable=function(e){var t=n(this),i="contenteditable";return n.browser.msie&&parseInt(n.browser.version,10)==7&&(i="contentEditable"),typeof e=="undefined"?typeof t[0]=="undefined"?(r.warn("The jquery object did not contain any valid elements."),undefined):typeof t[0].isContentEditable=="undefined"?(r.warn("Could not determine whether the is editable or not. I assume it is."),!0):t[0].isContentEditable:(e===""?t.removeAttr(i):(e&&e!=="false"?e="true":e="false",t.attr(i,e)),t)},n.fn.aloha=function(){var t=n(this);return e.bind("aloha-ready",function(){t.each(function(){e.isEditable(this)||(new e.Editable(n(this))).init()})}),t},n.fn.mahalo=function(){return this.each(function(){e.isEditable(this)&&e.getEditableById(n(this).attr("id")).destroy()})},n.fn.contentEditableSelectionChange=function(e){var r=this;return this.keyup(function(n){var r=t.getRangeObject();e(n)}),this.dblclick(function(t){e(t)}),this.mousedown(function(e){r.selectionStarted=!0}),n(document).mouseup(function(n){t.eventOriginalTarget=r,r.selectionStarted&&e(n),t.eventOriginalTarget=!1,r.selectionStarted=!1}),this},n.fn.outerHtml=n.fn.outerHtml||function(){var e=n(this),t=e.get(0);if(typeof t.outerHTML!="undefined")return t.outerHTML;try{return(new i).serializeToString(t)}catch(r){try{return t.xml}catch(s){}}},n.fn.zap=function(){return this.each(function(){n(this.childNodes).insertBefore(this)}).remove()},n.fn.textNodes=function(e,t){var r=[],i=function(s){var o,u;if(s.nodeType===3&&n.trim(s.data)&&!t||s.nodeType===3&&t||s.nodeName=="BR"&&!e)r.push(s);else for(o=0,u=s.childNodes.length;o","/":"?","\\":"|"}},n.each(["keydown","keyup","keypress"],function(){n.event.special[this]={add:o}})}),define("aloha/sidebar",["aloha/core","jquery","aloha/selection","PubSub"],function(e,t,n,r){var i=+(new Date);t.easing.easeOutExpo||t.extend(t.easing,{easeOutExpo:function(e,t,n,r,i){return t==i?n+r:r*(-Math.pow(2,-10*t/i)+1)+n},easeOutElastic:function(e,t,n,r,i){var s=Math,o=1.70158,u=0,a=r;return t?(t/=i)==1?n+r:(u||(u=i*.3),aUntitled
'),this.content=t('
'),this.element=null,this.effectiveElement=null,this.expanded=!1,this.isActive=!0,this.init(n)},o=function(r){var s=this;this.id="aloha-sidebar-"+ ++i,this.panels={},this.container=t('
    '),this.width=300,this.opened=!1,this.isOpen=!1,this.isCompletelyOpen=!1,this.settings={rotateIcons:!t.browser.msie,overlayPage:!0},t(function(){(typeof e.settings.sidebar=="undefined"||!e.settings.sidebar.disabled)&&s.init(r)})},u=null,a=null;t.extend(o.prototype,{init:function(e){var n=this,r;typeof e=="object"&&(r=e.panels,delete e.panels),t.extend(this,e),typeof r=="object"&&t.each(r,function(){n.addPanel(this,!0)});var i=this.container;this.position==="right"&&i.addClass("aloha-sidebar-right"),i.hide().appendTo(t("body")).click(function(){n.barClicked.apply(n,arguments)}).find(".aloha-sidebar-panels").width(this.width),i.width(this.width),this.width=i.width(),this.updateHeight(),this.initToggler(),this.container.css(this.position==="right"?"marginRight":"marginLeft",-this.width),this.opened&&this.open(0),this.toggleHandleIcon(this.isOpen),this.subscribeToEvents(),t(window).resize(function(){n.updateHeight(),n.correctHeight()}),this.correctHeight()},show:function(){return this.container.css("display","block"),this},hide:function(){return this.container.css("display","none"),this},checkActivePanels:function(e){var n=[];if(typeof e!="undefined"&&typeof e.markupEffectiveAtStart!="undefined"){var r=e.markupEffectiveAtStart.length,i;for(i=0;i0&&o>0){o+=d,d=0,p=[];for(m=r.length-1;m>=0;--m)f=r[m],c=f.content.find(".aloha-sidebar-panel-content-inner"),l=v.min(c.height("auto").height(),v.floor(o/(m+1))),c.height(l),o-=l,h=c.find(".aloha-sidebar-panel-content-inner-text"),h.height()>l?(p.push(f),d+=l,c.css({"overflow-x":"hidden","overflow-y":"scroll"})):c.css("overflow-y","hidden"),f.expanded&&f.expand();r=p}},showActivePanel:function(e,n){n.push(null);var r=e.content.parent("li"),i=e.activeOn,s=t(),o=0,u=n.length,a;for(a=0;ali:not(.aloha-sidebar-deactivated)"),n="aloha-sidebar-panel-top",r="aloha-sidebar-panel-bottom";e.find(".aloha-sidebar-panel-top, .aloha-sidebar-panel-bottom").removeClass(n).removeClass(r),t.first().find(".aloha-sidebar-panel-title").addClass(n),t.last().find(".aloha-sidebar-panel-content").addClass(r)},updateHeight:function(){var e=t(window).height();this.container.height(e).find(".aloha-sidebar-inner").height(e)},barClicked:function(e){this.handleBarclick(t(e.target))},handleBarclick:function(e){e.hasClass("aloha-sidebar-panel-title")?this.togglePanel(e):!e.hasClass("aloha-sidebar-panel-content")&&!e.hasClass("aloha-sidebar-handle")&&!e.hasClass("aloha-sidebar-bar")&&this.handleBarclick(e.parent())},getPanelById:function(e){return this.panels[e]},getPanelByElement:function(e){var t=e[0].tagName==="LI"?e:e.parent("li");return this.getPanelById(t[0].id)},togglePanel:function(e){this.getPanelByElement(e).toggle()},rotateHandleIcon:function(e,t){var n=this.container.find(".aloha-sidebar-handle-icon");n.animate({angle:e},{duration:typeof t=="number"||typeof t=="string"?t:500,easing:"easeOutExpo",step:function(e,t){n.css({"-o-transform":"rotate("+e+"deg)","-webkit-transform":"rotate("+e+"deg)","-moz-transform":"rotate("+e+"deg)","-ms-transform":"rotate("+e+"deg)"})}})},toggleHandleIcon:function(e){var t=this.position==="right"^e;if(this.settings.rotateIcons)this.rotateHandleIcon(t?180:0,0);else{var n=this.container.find(".aloha-sidebar-handle-icon");t?n.addClass("aloha-sidebar-handle-icon-left"):n.removeClass("aloha-sidebar-handle-icon-left")}},open:function(e,n){if(this.isOpen)return this;var r=this.position==="right",i=r?{marginRight:0}:{marginLeft:0},s=this;return this.toggleHandleIcon(!0),this.container.animate(i,typeof e=="number"||typeof e=="string"?e:500,"easeOutExpo"),this.settings.overlayPage||t("body").animate(r?{marginRight:"+="+this.width}:{marginLeft:"+="+this.width},500,"easeOutExpo",function(){s.isCompletelyOpen=!0,s.correctHeightWhenCompletelyOpen&&s.correctHeight()}),this.isOpen=!0,this.correctHeight(),this.lastRange&&this.checkActivePanels(this.lastRange),t("body").trigger("aloha-sidebar-opened",this),this},close:function(e,n){if(!this.isOpen)return this;var r=this.position==="right",i=r?{marginRight:-this.width}:{marginLeft:-this.width};return this.toggleHandleIcon(!1),this.container.animate(i,typeof e=="number"||typeof e=="string"?e:500,"easeOutExpo"),this.settings.overlayPage||t("body").animate(r?{marginRight:"-="+this.width}:{marginLeft:"-="+this.width},500,"easeOutExpo"),this.isOpen=!1,this.isCompletelyOpen=!1,this},activatePanel:function(e,t){return typeof e=="string"&&(e=this.getPanelById(e)),e&&e.activate(t),this.roundCorners(),this},expandPanel:function(e,t){return typeof e=="string"&&(e=this.getPanelById(e)),e&&e.expand(t),this},collapsePanel:function(e,t){return typeof e=="string"&&(e=this.getPanelById(e)),e&&e.collapse(t),this},addPanel:function(e,t){return e instanceof s||(e.width||(e.width=this.width),e.sidebar=this,e=new s(e)),this.panels[e.id]=e,this.container.find(".aloha-sidebar-panels").append(e.element),this.checkActivePanels(n.getRangeObject()),e}}),t.extend(s.prototype,{init:function(e){this.setTitle(e.title).setContent(e.content),delete e.title,delete e.content,t.extend(this,e),this.id||(this.id="aloha-sidebar-"+ ++i);var n=this.element=t('
  • ').append(this.title,this.content);this.expanded&&this.content.height("auto"),this.toggleTitleIcon(this.expanded),this.coerceActiveOn(),this.title.attr("unselectable","on").css("-moz-user-select","none").each(function(){this.onselectstart=function(){return!1}}),typeof this.onInit=="function"&&this.onInit.apply(this)},toggleTitleIcon:function(e){if(this.sidebar.settings.rotateIcons)this.rotateTitleIcon(e?90:0);else{var t=this.title.find(".aloha-sidebar-panel-title-arrow");e?t.addClass("aloha-sidebar-panel-title-arrow-down"):t.removeClass("aloha-sidebar-panel-title-arrow-down")}},coerceActiveOn:function(){if(typeof this.activeOn!="function"){var e=this.activeOn;this.activeOn=function(){var t=typeof e,n;return t==="boolean"?n=function(){return e}:t==="undefined"?n=function(){return!0}:t==="string"?n=function(t){return t?t.is(e):!1}:n=function(){return!1},n}()}},activate:function(e){this.isActive=!0,this.content.parent("li").show().removeClass("aloha-sidebar-deactivated"),this.effectiveElement=e,typeof this.onActivate=="function"&&this.onActivate.call(this,e)},deactivate:function(){if(!this.isActive)return;this.isActive=!1,this.content.parent("li").hide().addClass("aloha-sidebar-deactivated"),this.effectiveElement=null},toggle:function(){this.expanded?this.collapse():this.expand()},expand:function(e){var t=this,n=this.content,r=n.height(),i=n.height("auto").height();return n.height(r).stop().animate({height:i},500,"easeOutExpo",function(){typeof e=="function"&&e.call(t)}),this.element.removeClass("collapsed"),this.toggleTitleIcon(!0),this.expanded=!0,this},collapse:function(e,t){var n=this;return this.element.addClass("collapsed"),this.content.stop().animate({height:5},250,"easeOutExpo",function(){typeof t=="function"&&t.call(n)}),this.toggleTitleIcon(!1),this.expanded=!1,this},setTitle:function(e){return this.title.find(".aloha-sidebar-panel-title-text").html(e),this},setContent:function(e){if(!e||e==="")e=" ";return this.content.find(".aloha-sidebar-panel-content-inner-text").html(e),this},rotateTitleIcon:function(e,t){var n=this.title.find(".aloha-sidebar-panel-title-arrow");n.animate({angle:e},{duration:typeof t=="number"?t:500,easing:"easeOutExpo",step:function(e,t){n.css({"-o-transform":"rotate("+e+"deg)","-webkit-transform":"rotate("+e+"deg)","-moz-transform":"rotate("+e+"deg)","-ms-transform":"rotate("+e+"deg)"})}})},renderEffectiveParents:function(e,n){var r=e.first(),i=[],s=[],o=this.activeOn,u,a;while(r.length>0&&!r.is(".aloha-editable")){if(o(r)){s.push(""+r[0].tagName.toLowerCase()+""),u=s.length,a=[];while(u--)a.push(s[u]);i.push('
    '+a.join("")+"
    "+'
    '+(typeof n=="function"?n(r):"----")+"
    "+"
    ")}r=r.parent()}this.setContent(i.join("")),t(".aloha-sidebar-panel-parent-path").click(function(){var e=t(this).parent().find(".aloha-sidebar-panel-parent-content");e.hasClass("aloha-sidebar-opened")?e.hide().removeClass("aloha-sidebar-opened"):e.show().addClass("aloha-sidebar-opened")}),this.content.height("auto").find(".aloha-sidebar-panel-content-inner").height("auto")}});var f=new o({position:"left",width:250}),l=new o({position:"right",width:250});return e.Sidebar={left:f,right:l},e.Sidebar}),window.GENTICS=window.GENTICS||{},window.GENTICS.Utils=window.GENTICS.Utils||{},define("util/position",["jquery"],function(e){var t=e,n=window.GENTICS,r=window.Class,i=window.console;n.Utils.Position={},n.Utils.Position.w=e(window),n.Utils.Position.Scroll={top:0,left:0,isScrolling:!1},n.Utils.Position.ScrollCorrection={top:100,left:50},n.Utils.Position.Mouse={x:0,y:0,oldX:0,oldY:0,isMoving:!1,triggeredMouseStop:!0},n.Utils.Position.mouseStopCallbacks=[],n.Utils.Position.mouseMoveCallbacks=[],n.Utils.Position.update=function(){var e=this.w.scrollTop(),t=this.w.scrollLeft(),n;if(this.Scroll.isScrolling)this.Scroll.top==e&&this.Scroll.left==t&&(this.Scroll.isScrolling=!1);else if(this.Scroll.top!=e||this.Scroll.left!=t)this.Scroll.isScrolling=!0;this.Scroll.top=e,this.Scroll.left=t;if(this.Mouse.x==this.Mouse.oldX&&this.Mouse.y==this.Mouse.oldY){this.Mouse.isMoving=!1;if(!this.Mouse.triggeredMouseStop){this.Mouse.triggeredMouseStop=!0;for(n=0;n0&&r.warn(this,f+" repositories did not return before the configured timeout of "+d+"ms."),f=0,u=u||{},u.timeout=!0,i.queryCallback(t,o,u,l)},d),e.repositoryId?a.push(this.getRepository(e.repositoryId)):a=this.repositories,h=a.length;var v=[];for(c=0;c-1)&&u.push(new e.RepositoryFolder({id:s.repositoryId,name:s.repositoryName,repositoryId:s.repositoryId,type:"repository",hasMoreItems:!0}));i.getChildrenCallback(r,u,null);return}u=this.repositories;var v=parseInt(t.timeout,10)||this.settings.timeout;f=window.setTimeout(function(){a=0,i.getChildrenCallback(r,o,f)},v),c=u.length;for(l=0;l",{"class":"aloha",id:r}),t(function(){s.appendTo("body")}));var o=n.extend({surfaces:[],containers:[]});return t.extend(o,{selector:i,element:s}),o}),define("ui/scopes",["jquery","PubSub"],function(e,t){function o(e,t){if(!n.hasOwnProperty(t))return;var r=n[t];for(var i=0;i").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function u(t,n,r,s){return e.each(i,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),s&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var i=r==="Width"?["Left","Right"]:["Top","Bottom"],s=r.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?o["inner"+r].call(this):this.each(function(){e(this).css(s,u(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return typeof t!="number"?o["outer"+r].call(this,t):this.each(function(){e(this).css(s,u(this,t,!0,n)+"px")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),r=isNaN(n);return(r||n>=0)&&i(t,!r)}}),e(function(){var t=document.body,n=t.appendChild(n=document.createElement("div"));n.offsetHeight,e.extend(n.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),e.support.minHeight=n.offsetHeight===100,e.support.selectstart="onselectstart"in n,t.removeChild(n).style.display="none"}),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n){var r,i=e.plugins[t];if(!i||!e.element[0].parentNode||e.element[0].parentNode.nodeType===11)return;for(r=0;r0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)},isOverAxis:function(e,t,n){return e>t&&e",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetName,this),e.data(r,this.widgetFullName,this),this._on({remove:"destroy"}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i=n,s,o,u;if(arguments.length===0)return e.widget.extend({},this.options);if(typeof n=="string"){i={},s=n.split("."),n=s.shift();if(s.length){o=i[n]=e.widget.extend({},this.options[n]);for(u=0;u=9||!!t.button?this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted):this._mouseUp(t)},_mouseUp:function(t){return e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(e){return this.mouseDelayMet},_mouseStart:function(e){},_mouseDrag:function(e){},_mouseStop:function(e){},_mouseCapture:function(e){return!0}})}(jQuery),function(e,t){function h(e,t,n){return[parseInt(e[0],10)*(l.test(e[0])?t/100:1),parseInt(e[1],10)*(l.test(e[1])?n/100:1)]}function p(t,n){return parseInt(e.css(t,n),10)||0}e.ui=e.ui||{};var n,r=Math.max,i=Math.abs,s=Math.round,o=/left|center|right/,u=/top|center|bottom/,a=/[\+\-]\d+%?/,f=/^\w+/,l=/%$/,c=e.fn.position;e.position={scrollbarWidth:function(){if(n!==t)return n;var r,i,s=e("
    "),o=s.children()[0];return e("body").append(s),r=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,r===i&&(i=s[0].clientWidth),s.remove(),n=r-i},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width0?"right":"center",vertical:u<0?"top":o>0?"bottom":"middle"};lr(i(o),i(u))?h.important="horizontal":h.important="vertical",t.using.call(this,e,h)}),a.offset(e.extend(C,{using:u}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,i=n.isWindow?n.scrollLeft:n.offset.left,s=n.width,o=e.left-t.collisionPosition.marginLeft,u=i-o,a=o+t.collisionWidth-s-i,f;t.collisionWidth>s?u>0&&a<=0?(f=e.left+u+t.collisionWidth-s-i,e.left+=u-f):a>0&&u<=0?e.left=i:u>a?e.left=i+s-t.collisionWidth:e.left=i:u>0?e.left+=u:a>0?e.left-=a:e.left=r(e.left-o,e.left)},top:function(e,t){var n=t.within,i=n.isWindow?n.scrollTop:n.offset.top,s=t.within.height,o=e.top-t.collisionPosition.marginTop,u=i-o,a=o+t.collisionHeight-s-i,f;t.collisionHeight>s?u>0&&a<=0?(f=e.top+u+t.collisionHeight-s-i,e.top+=u-f):a>0&&u<=0?e.top=i:u>a?e.top=i+s-t.collisionHeight:e.top=i:u>0?e.top+=u:a>0?e.top-=a:e.top=r(e.top-o,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,s=n.width,o=n.isWindow?n.scrollLeft:n.offset.left,u=e.left-t.collisionPosition.marginLeft,a=u-o,f=u+t.collisionWidth-s-o,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-s-r;if(p<0||p0){d=e.left-t.collisionPosition.marginLeft+l+c+h-o;if(d>0||i(d)a&&(v<0||v0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-o,e.top+c+h+p>f&&(d>0||i(d)10&&i<11,t.innerHTML="",n.removeChild(t)}(),e.uiBackCompat!==!1&&function(e){var n=e.fn.position;e.fn.position=function(r){if(!r||!r.offset)return n.call(this,r);var i=r.offset.split(" "),s=r.at.split(" ");return i.length===1&&(i[1]=i[0]),/^\d/.test(i[0])&&(i[0]="+"+i[0]),/^\d/.test(i[1])&&(i[1]="+"+i[1]),s.length===1&&(/left|center|right/.test(s[0])?s[1]="center":(s[1]=s[0],s[0]="center")),n.call(this,e.extend(r,{at:s[0]+i[0]+" "+s[1]+i[1],offset:t}))}}(jQuery)}(jQuery),function(e,t){e.widget("ui.draggable",e.ui.mouse,{version:"1.9.0",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var n=this.options;return this.helper||n.disabled||e(t.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(t),this.handle?(e(n.iframeFix===!0?"iframe":n.iframeFix).each(function(){e('
    ').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var n=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,n.cursorAt&&this._adjustOffsetFromHelper(n.cursorAt),n.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,n){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute");if(!n){var r=this._uiHash();if(this._trigger("drag",t,r)===!1)return this._mouseUp({}),!1;this.position=r.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var n=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(n=e.ui.ddmanager.drop(this,t)),this.dropped&&(n=this.dropped,this.dropped=!1);var r=this.element[0],i=!1;while(r&&(r=r.parentNode))r==document&&(i=!0);if(!i&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!n||this.options.revert=="valid"&&n||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,n)){var s=this;e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){s._trigger("stop",t)!==!1&&s._clear()})}else this._trigger("stop",t)!==!1&&this._clear();return!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){var n=!this.options.handle||!e(this.options.handle,this.element).length?!0:!1;return e(this.options.handle,this.element).find("*").andSelf().each(function(){this==t.target&&(n=!0)}),n},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t])):n.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return r.parents("body").length||r.appendTo(n.appendTo=="parent"?this.element[0].parentNode:n.appendTo),r[0]!=this.element[0]&&!/(fixed|absolute)/.test(r.css("position"))&&r.css("position","absolute"),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.browser.msie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[t.containment=="document"?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t.containment=="document"?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(t.containment=="document"?0:e(window).scrollLeft())+e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(t.containment=="document"?0:e(window).scrollTop())+(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)&&t.containment.constructor!=Array){var n=e(t.containment),r=n[0];if(!r)return;var i=n.offset(),s=e(r).css("overflow")!="hidden";this.containment=[(parseInt(e(r).css("borderLeftWidth"),10)||0)+(parseInt(e(r).css("paddingLeft"),10)||0),(parseInt(e(r).css("borderTopWidth"),10)||0)+(parseInt(e(r).css("paddingTop"),10)||0),(s?Math.max(r.scrollWidth,r.offsetWidth):r.offsetWidth)-(parseInt(e(r).css("borderLeftWidth"),10)||0)-(parseInt(e(r).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(s?Math.max(r.scrollHeight,r.offsetHeight):r.offsetHeight)-(parseInt(e(r).css("borderTopWidth"),10)||0)-(parseInt(e(r).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=n}else t.containment.constructor==Array&&(this.containment=t.containment)},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName),s=t.pageX,o=t.pageY;if(this.originalPosition){var u;if(this.containment){if(this.relative_container){var a=this.relative_container.offset();u=[this.containment[0]+a.left,this.containment[1]+a.top,this.containment[2]+a.left,this.containment[3]+a.top]}else u=this.containment;t.pageX-this.offset.click.leftu[2]&&(s=u[2]+this.offset.click.left),t.pageY-this.offset.click.top>u[3]&&(o=u[3]+this.offset.click.top)}if(n.grid){var f=n.grid[1]?this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1]:this.originalPageY;o=u?f-this.offset.click.topu[3]?f-this.offset.click.topu[2]?l-this.offset.click.left=0;l--){var c=r.snapElements[l].left,h=c+r.snapElements[l].width,p=r.snapElements[l].top,d=p+r.snapElements[l].height;if(!(c-s=l&&o<=c||u>=l&&u<=c||oc)&&(i>=a&&i<=f||s>=a&&s<=f||if);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,n){var r=e.ui.ddmanager.droppables[t.options.scope]||[],i=n?n.type:null,s=(t.currentItem||t.element).find(":data(droppable)").andSelf();e:for(var o=0;o').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=n.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var r=this.handles.split(",");this.handles={};for(var i=0;i');u.css({zIndex:n.zIndex}),"se"==s&&u.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(u)}}this._renderAxis=function(t){t=t||this.element;for(var n in this.handles){this.handles[n].constructor==String&&(this.handles[n]=e(this.handles[n],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var r=e(this.handles[n],this.element),i=0;i=/sw|ne|nw|se|n|s/.test(n)?r.outerHeight():r.outerWidth();var s=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");t.css(s,i),this._proportionallyResize()}if(!e(this.handles[n]).length)continue}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!t.resizing){if(this.className)var e=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);t.axis=e&&e[1]?e[1]:"se"}}),n.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){if(n.disabled)return;e(this).removeClass("ui-resizable-autohide"),t._handles.show()}).mouseleave(function(){if(n.disabled)return;t.resizing||(e(this).addClass("ui-resizable-autohide"),t._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){t(this.element);var n=this.element;n.after(this.originalElement.css({position:n.css("position"),width:n.outerWidth(),height:n.outerHeight(),top:n.css("top"),left:n.css("left")})).remove()}return this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_mouseCapture:function(t){var n=!1;for(var r in this.handles)e(this.handles[r])[0]==t.target&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var r=this.options,i=this.element.position(),s=this.element;this.resizing=!0,this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()},(s.is(".ui-draggable")||/absolute/.test(s.css("position")))&&s.css({position:"absolute",top:i.top,left:i.left}),this._renderProxy();var o=n(this.helper.css("left")),u=n(this.helper.css("top"));r.containment&&(o+=e(r.containment).scrollLeft()||0,u+=e(r.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:o,top:u},this.size=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalSize=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalPosition={left:o,top:u},this.sizeDiff={width:s.outerWidth()-s.width(),height:s.outerHeight()-s.height()},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio=typeof r.aspectRatio=="number"?r.aspectRatio:this.originalSize.width/this.originalSize.height||1;var a=e(".ui-resizable-"+this.axis).css("cursor");return e("body").css("cursor",a=="auto"?this.axis+"-resize":a),s.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(e){var t=this.helper,n=this.options,r={},i=this,s=this.originalMousePosition,o=this.axis,u=e.pageX-s.left||0,a=e.pageY-s.top||0,f=this._change[o];if(!f)return!1;var l=f.apply(this,[e,u,a]);this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey)l=this._updateRatio(l,e);return l=this._respectSize(l,e),this._propagate("resize",e),t.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",e,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var n=this.options,r=this;if(this._helper){var i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),o=s&&e.ui.hasScroll(i[0],"left")?0:r.sizeDiff.height,u=s?0:r.sizeDiff.width,a={width:r.helper.width()-u,height:r.helper.height()-o},f=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,l=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;n.animate||this.element.css(e.extend(a,{top:l,left:f})),r.helper.height(r.size.height),r.helper.width(r.size.width),this._helper&&!n.animate&&this._proportionallyResize()}return e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t=this.options,n,i,s,o,u;u={minWidth:r(t.minWidth)?t.minWidth:0,maxWidth:r(t.maxWidth)?t.maxWidth:Infinity,minHeight:r(t.minHeight)?t.minHeight:0,maxHeight:r(t.maxHeight)?t.maxHeight:Infinity};if(this._aspectRatio||e)n=u.minHeight*this.aspectRatio,s=u.minWidth/this.aspectRatio,i=u.maxHeight*this.aspectRatio,o=u.maxWidth/this.aspectRatio,n>u.minWidth&&(u.minWidth=n),s>u.minHeight&&(u.minHeight=s),ie.width,l=r(e.height)&&i.minHeight&&i.minHeight>e.height;f&&(e.width=i.minWidth),l&&(e.height=i.minHeight),u&&(e.width=i.maxWidth),a&&(e.height=i.maxHeight);var c=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,p=/sw|nw|w/.test(o),d=/nw|ne|n/.test(o);f&&p&&(e.left=c-i.minWidth),u&&p&&(e.left=c-i.maxWidth),l&&d&&(e.top=h-i.minHeight),a&&d&&(e.top=h-i.maxHeight);var v=!e.width&&!e.height;return v&&!e.left&&e.top?e.top=null:v&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){var t=this.options;if(!this._proportionallyResizeElements.length)return;var n=this.helper||this.element;for(var r=0;r');var r=e.browser.msie&&e.browser.version<7,i=r?1:0,s=r?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+s,height:this.element.outerHeight()+s,position:"absolute",left:this.elementOffset.left-i+"px",top:this.elementOffset.top-i+"px",zIndex:++n.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(e,t,n){return{width:this.originalSize.width+t}},w:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{top:s.top+n,height:i.height-n}},s:function(e,t,n){return{height:this.originalSize.height+n}},se:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},sw:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,n,r]))},ne:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},nw:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,n,r]))}},_propagate:function(t,n){e.ui.plugin.call(this,t,[n,this.ui()]),t!="resize"&&this._trigger(t,n,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","alsoResize",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=function(t){e(t).each(function(){var t=e(this);t.data("resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};typeof i.alsoResize=="object"&&!i.alsoResize.parentNode?i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)}):s(i.alsoResize)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.originalSize,o=r.originalPosition,u={height:r.size.height-s.height||0,width:r.size.width-s.width||0,top:r.position.top-o.top||0,left:r.position.left-o.left||0},a=function(t,r){e(t).each(function(){var t=e(this),i=e(this).data("resizable-alsoresize"),s={},o=r&&r.length?r:t.parents(n.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var n=(i[t]||0)+(u[t]||0);n&&n>=0&&(s[t]=n||null)}),t.css(s)})};typeof i.alsoResize=="object"&&!i.alsoResize.nodeType?e.each(i.alsoResize,function(e,t){a(e,t)}):a(i.alsoResize)},stop:function(t,n){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","animate",{stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r._proportionallyResizeElements,o=s.length&&/textarea/i.test(s[0].nodeName),u=o&&e.ui.hasScroll(s[0],"left")?0:r.sizeDiff.height,a=o?0:r.sizeDiff.width,f={width:r.size.width-a,height:r.size.height-u},l=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,c=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;r.element.animate(e.extend(f,c&&l?{top:c,left:l}:{}),{duration:i.animateDuration,easing:i.animateEasing,step:function(){var n={width:parseInt(r.element.css("width"),10),height:parseInt(r.element.css("height"),10),top:parseInt(r.element.css("top"),10),left:parseInt(r.element.css("left"),10)};s&&s.length&&e(s[0]).css({width:n.width,height:n.height}),r._updateCache(n),r._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(t,r){var i=e(this).data("resizable"),s=i.options,o=i.element,u=s.containment,a=u instanceof e?u.get(0):/parent/.test(u)?o.parent().get(0):u;if(!a)return;i.containerElement=e(a);if(/document/.test(u)||u==document)i.containerOffset={left:0,top:0},i.containerPosition={left:0,top:0},i.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight};else{var f=e(a),l=[];e(["Top","Right","Left","Bottom"]).each(function(e,t){l[e]=n(f.css("padding"+t))}),i.containerOffset=f.offset(),i.containerPosition=f.position(),i.containerSize={height:f.innerHeight()-l[3],width:f.innerWidth()-l[1]};var c=i.containerOffset,h=i.containerSize.height,p=i.containerSize.width,d=e.ui.hasScroll(a,"left")?a.scrollWidth:p,v=e.ui.hasScroll(a)?a.scrollHeight:h;i.parentData={element:a,left:c.left,top:c.top,width:d,height:v}}},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.containerSize,o=r.containerOffset,u=r.size,a=r.position,f=r._aspectRatio||t.shiftKey,l={top:0,left:0},c=r.containerElement;c[0]!=document&&/static/.test(c.css("position"))&&(l=o),a.left<(r._helper?o.left:0)&&(r.size.width=r.size.width+(r._helper?r.position.left-o.left:r.position.left-l.left),f&&(r.size.height=r.size.width/r.aspectRatio),r.position.left=i.helper?o.left:0),a.top<(r._helper?o.top:0)&&(r.size.height=r.size.height+(r._helper?r.position.top-o.top:r.position.top),f&&(r.size.width=r.size.height*r.aspectRatio),r.position.top=r._helper?o.top:0),r.offset.left=r.parentData.left+r.position.left,r.offset.top=r.parentData.top+r.position.top;var h=Math.abs((r._helper?r.offset.left-l.left:r.offset.left-l.left)+r.sizeDiff.width),p=Math.abs((r._helper?r.offset.top-l.top:r.offset.top-o.top)+r.sizeDiff.height),d=r.containerElement.get(0)==r.element.parent().get(0),v=/relative|absolute/.test(r.containerElement.css("position"));d&&v&&(h-=r.parentData.left),h+r.size.width>=r.parentData.width&&(r.size.width=r.parentData.width-h,f&&(r.size.height=r.size.width/r.aspectRatio)),p+r.size.height>=r.parentData.height&&(r.size.height=r.parentData.height-p,f&&(r.size.width=r.size.height*r.aspectRatio))},stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.position,o=r.containerOffset,u=r.containerPosition,a=r.containerElement,f=e(r.helper),l=f.offset(),c=f.outerWidth()-r.sizeDiff.width,h=f.outerHeight()-r.sizeDiff.height;r._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h}),r._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h})}}),e.ui.plugin.add("resizable","ghost",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size;r.ghost=r.originalElement.clone(),r.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:""),r.ghost.appendTo(r.helper)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.ghost.css({position:"relative",height:r.size.height,width:r.size.width})},stop:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.helper&&r.helper.get(0).removeChild(r.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size,o=r.originalSize,u=r.originalPosition,a=r.axis,f=i._aspectRatio||t.shiftKey;i.grid=typeof i.grid=="number"?[i.grid,i.grid]:i.grid;var l=Math.round((s.width-o.width)/(i.grid[0]||1))*(i.grid[0]||1),c=Math.round((s.height-o.height)/(i.grid[1]||1))*(i.grid[1]||1);/^(se|s|e)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c):/^(ne)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c):/^(sw)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.left=u.left-l):(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c,r.position.left=u.left-l)}});var n=function(e){return parseInt(e,10)||0},r=function(e){return!isNaN(parseInt(e,10))}}(jQuery),function(e,t){e.widget("ui.selectable",e.ui.mouse,{version:"1.9.0",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var t=this;this.element.addClass("ui-selectable"),this.dragged=!1;var n;this.refresh=function(){n=e(t.options.filter,t.element[0]),n.addClass("ui-selectee"),n.each(function(){var t=e(this),n=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:n.left,top:n.top,right:n.left+t.outerWidth(),bottom:n.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=n.addClass("ui-selectee"),this._mouseInit(),this.helper=e("
    ")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var n=this;this.opos=[t.pageX,t.pageY];if(this.options.disabled)return;var r=this.options;this.selectees=e(r.filter,this.element[0]),this._trigger("start",t),e(r.appendTo).append(this.helper),this.helper.css({left:t.clientX,top:t.clientY,width:0,height:0}),r.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var r=e.data(this,"selectable-item");r.startselected=!0,!t.metaKey&&!t.ctrlKey&&(r.$element.removeClass("ui-selected"),r.selected=!1,r.$element.addClass("ui-unselecting"),r.unselecting=!0,n._trigger("unselecting",t,{unselecting:r.element}))}),e(t.target).parents().andSelf().each(function(){var r=e.data(this,"selectable-item");if(r){var i=!t.metaKey&&!t.ctrlKey||!r.$element.hasClass("ui-selected");return r.$element.removeClass(i?"ui-unselecting":"ui-selected").addClass(i?"ui-selecting":"ui-unselecting"),r.unselecting=!i,r.selecting=i,r.selected=i,i?n._trigger("selecting",t,{selecting:r.element}):n._trigger("unselecting",t,{unselecting:r.element}),!1}})},_mouseDrag:function(t){var n= +this;this.dragged=!0;if(this.options.disabled)return;var r=this.options,i=this.opos[0],s=this.opos[1],o=t.pageX,u=t.pageY;if(i>o){var a=o;o=i,i=a}if(s>u){var a=u;u=s,s=a}return this.helper.css({left:i,top:s,width:o-i,height:u-s}),this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!a||a.element==n.element[0])return;var f=!1;r.tolerance=="touch"?f=!(a.left>o||a.rightu||a.bottomi&&a.rights&&a.bottom *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?e.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,n){t==="disabled"?(this.options[t]=n,this.widget().toggleClass("ui-sortable-disabled",!!n)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,n){var r=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(t);var i=null,s=e(t.target).parents().each(function(){if(e.data(this,r.widgetName+"-item")==r)return i=e(this),!1});e.data(t.target,r.widgetName+"-item")==r&&(i=e(t.target));if(!i)return!1;if(this.options.handle&&!n){var o=!1;e(this.options.handle,i).find("*").andSelf().each(function(){this==t.target&&(o=!0)});if(!o)return!1}return this.currentItem=i,this._removeCurrentsFromItems(),!0},_mouseStart:function(t,n,r){var i=this.options;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),i.containment&&this._setContainment(),i.cursor&&(e("body").css("cursor")&&(this._storedCursor=e("body").css("cursor")),e("body").css("cursor",i.cursor)),i.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",i.opacity)),i.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",i.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!r)for(var s=this.containers.length-1;s>=0;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var n=this.options,r=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY=0;i--){var s=this.items[i],o=s.item[0],u=this._intersectsWithPointer(s);if(!u)continue;if(s.instance!==this.currentContainer)continue;if(o!=this.currentItem[0]&&this.placeholder[u==1?"next":"prev"]()[0]!=o&&!e.contains(this.placeholder[0],o)&&(this.options.type=="semi-dynamic"?!e.contains(this.element[0],o):!0)){this.direction=u==1?"down":"up";if(this.options.tolerance!="pointer"&&!this._intersectsWithSides(s))break;this._rearrange(t,s),this._trigger("change",t,this._uiHash());break}}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,n){if(!t)return;e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t);if(this.options.revert){var r=this,i=this.placeholder.offset();this.reverting=!0,e(this.helper).animate({left:i.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:i.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){r._clear(t)})}else this._clear(t,n);return!1},cancel:function(){if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},e(n).each(function(){var n=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[-=_](.+)/);n&&r.push((t.key||n[1]+"[]")+"="+(t.key&&t.expression?n[1]:n[2]))}),!r.length&&t.key&&r.push(t.key+"="),r.join("&")},toArray:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},n.each(function(){r.push(e(t.item||this).attr(t.attribute||"id")||"")}),r},_intersectsWith:function(e){var t=this.positionAbs.left,n=t+this.helperProportions.width,r=this.positionAbs.top,i=r+this.helperProportions.height,s=e.left,o=s+e.width,u=e.top,a=u+e.height,f=this.offset.click.top,l=this.offset.click.left,c=r+f>u&&r+fs&&t+le[this.floating?"width":"height"]?c:s0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return e!=0&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor==String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var n=[],r=[],i=this._connectWith();if(i&&t)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&r.push([e.isFunction(a.options.items)?a.options.items.call(a.element):e(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a])}}r.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var s=r.length-1;s>=0;s--)r[s][0].each(function(){n.push(this)});return e(n)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");for(var t=0;t=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&(r.push([e.isFunction(a.options.items)?a.options.items.call(a.element[0],t,{item:this.currentItem}):e(a.options.items,a.element),a]),this.containers.push(a))}}for(var s=r.length-1;s>=0;s--){var f=r[s][1],l=r[s][0];for(var u=0,c=l.length;u=0;n--){var r=this.items[n];if(r.instance!=this.currentContainer&&this.currentContainer&&r.item[0]!=this.currentItem[0])continue;var i=this.options.toleranceElement?e(this.options.toleranceElement,r.item):r.item;t||(r.width=i.outerWidth(),r.height=i.outerHeight());var s=i.offset();r.left=s.left,r.top=s.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var n=this.containers.length-1;n>=0;n--){var s=this.containers[n].element.offset();this.containers[n].containerCache.left=s.left,this.containers[n].containerCache.top=s.top,this.containers[n].containerCache.width=this.containers[n].element.outerWidth(),this.containers[n].containerCache.height=this.containers[n].element.outerHeight()}return this},_createPlaceholder:function(t){t=t||this;var n=t.options;if(!n.placeholder||n.placeholder.constructor==String){var r=n.placeholder;n.placeholder={element:function(){var n=e(document.createElement(t.currentItem[0].nodeName)).addClass(r||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return r||(n.style.visibility="hidden"),n},update:function(e,i){if(r&&!n.forcePlaceholderSize)return;i.height()||i.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),i.width()||i.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10))}}}t.placeholder=e(n.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),n.placeholder.update(t,t.placeholder)},_contactContainers:function(t){var n=null,r=null;for(var i=this.containers.length-1;i>=0;i--){if(e.contains(this.currentItem[0],this.containers[i].element[0]))continue;if(this._intersectsWith(this.containers[i].containerCache)){if(n&&e.contains(this.containers[i].element[0],n.element[0]))continue;n=this.containers[i],r=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",t,this._uiHash(this)),this.containers[i].containerCache.over=0)}if(!n)return;if(this.containers.length===1)this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1;else if(this.currentContainer!=this.containers[r]){var s=1e4,o=null,u=this.positionAbs[this.containers[r].floating?"left":"top"];for(var a=this.items.length-1;a>=0;a--){if(!e.contains(this.containers[r].element[0],this.items[a].item[0]))continue;var f=this.containers[r].floating?this.items[a].item.offset().left:this.items[a].item.offset().top;Math.abs(f-u)0?"down":"up")}if(!o&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[r],o?this._rearrange(t,o,null,!0):this._rearrange(t,null,this.containers[r].element,!0),this._trigger("change",t,this._uiHash()),this.containers[r]._trigger("change",t,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1}},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t,this.currentItem])):n.helper=="clone"?this.currentItem.clone():this.currentItem;return r.parents("body").length||e(n.appendTo!="parent"?n.appendTo:this.currentItem[0].parentNode)[0].appendChild(r[0]),r[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(r[0].style.width==""||n.forceHelperSize)&&r.width(this.currentItem.width()),(r[0].style.height==""||n.forceHelperSize)&&r.height(this.currentItem.height()),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.browser.msie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)){var n=e(t.containment)[0],r=e(t.containment).offset(),i=e(n).css("overflow")!="hidden";this.containment=[r.left+(parseInt(e(n).css("borderLeftWidth"),10)||0)+(parseInt(e(n).css("paddingLeft"),10)||0)-this.margins.left,r.top+(parseInt(e(n).css("borderTopWidth"),10)||0)+(parseInt(e(n).css("paddingTop"),10)||0)-this.margins.top,r.left+(i?Math.max(n.scrollWidth,n.offsetWidth):n.offsetWidth)-(parseInt(e(n).css("borderLeftWidth"),10)||0)-(parseInt(e(n).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,r.top+(i?Math.max(n.scrollHeight,n.offsetHeight):n.offsetHeight)-(parseInt(e(n).css("borderTopWidth"),10)||0)-(parseInt(e(n).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var s=t.pageX,o=t.pageY;if(this.originalPosition){this.containment&&(t.pageX-this.offset.click.leftthis.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top));if(n.grid){var u=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1];o=this.containment?u-this.offset.click.topthis.containment[3]?u-this.offset.click.topthis.containment[2]?a-this.offset.click.left=0;i--)n||r.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(r.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);this._storedCursor&&e("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!n){this._trigger("beforeStop",t,this._uiHash());for(var i=0;i li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},_create:function(){var t=this.accordionId="ui-accordion-"+(this.element.attr("id")||++n),r=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset"),this.headers=this.element.find(r.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"),this._hoverable(this.headers),this._focusable(this.headers),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide(),!r.collapsible&&r.active===!1&&(r.active=0),r.active<0&&(r.active+=this.headers.length),this.active=this._findActive(r.active).addClass("ui-accordion-header-active ui-state-active").toggleClass("ui-corner-all ui-corner-top"),this.active.next().addClass("ui-accordion-content-active").show(),this._createIcons(),this.originalHeight=this.element[0].style.height,this.refresh(),this.element.attr("role","tablist"),this.headers.attr("role","tab").each(function(n){var r=e(this),i=r.attr("id"),s=r.next(),o=s.attr("id");i||(i=t+"-header-"+n,r.attr("id",i)),o||(o=t+"-panel-"+n,s.attr("id",o)),r.attr("aria-controls",o),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false",tabIndex:-1}).next().attr({"aria-expanded":"false","aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true",tabIndex:0}).next().attr({"aria-expanded":"true","aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._on(this.headers,{keydown:"_keydown"}),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._setupEvents(r.event)},_getCreateEventData:function(){return{header:this.active,content:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this._destroyIcons(),e=this.headers.next().css("display","").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this.options.heightStyle!=="content"&&(this.element.css("height",this.originalHeight),e.css("height",""))},_setOption:function(e,t){if(e==="active"){this._activate(t);return}e==="event"&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),e==="collapsible"&&!t&&this.options.active===!1&&this._activate(0),e==="icons"&&(this._destroyIcons(),t&&this._createIcons()),e==="disabled"&&this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)},_keydown:function(t){if(t.altKey||t.ctrlKey)return;var n=e.ui.keyCode,r=this.headers.length,i=this.headers.index(t.target),s=!1;switch(t.keyCode){case n.RIGHT:case n.DOWN:s=this.headers[(i+1)%r];break;case n.LEFT:case n.UP:s=this.headers[(i-1+r)%r];break;case n.SPACE:case n.ENTER:this._eventHandler(t);break;case n.HOME:s=this.headers[0];break;case n.END:s=this.headers[r-1]}s&&(e(t.target).attr("tabIndex",-1),e(s).attr("tabIndex",0),s.focus(),t.preventDefault())},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t,n,r=this.options.heightStyle,i=this.element.parent();this.element.css("height",this.originalHeight),r==="fill"?(e.support.minHeight||(n=i.css("overflow"),i.css("overflow","hidden")),t=i.height(),this.element.siblings(":visible").each(function(){var n=e(this),r=n.css("position");if(r==="absolute"||r==="fixed")return;t-=n.outerHeight(!0)}),n&&i.css("overflow",n),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):r==="auto"&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).height("").height())}).height(t)),r!=="content"&&this.element.height(this.element.height())},_activate:function(t){var n=this._findActive(t)[0];if(n===this.active[0])return;n=n||this.active[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return typeof t=="number"?this.headers.eq(t):e()},_setupEvents:function(t){var n={};if(!t)return;e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._on(this.headers,n)},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i[0]===r[0],o=s&&n.collapsible,u=o?e():i.next(),a=r.next(),f={oldHeader:r,oldPanel:a,newHeader:o?e():i,newPanel:u};t.preventDefault();if(s&&!n.collapsible||this._trigger("beforeActivate",t,f)===!1)return;n.active=o?!1:this.headers.index(i),this.active=s?e():i,this._toggle(f),r.removeClass("ui-accordion-header-active ui-state-active"),n.icons&&r.children(".ui-accordion-header-icon").removeClass(n.icons.activeHeader).addClass(n.icons.header),s||(i.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),n.icons&&i.children(".ui-accordion-header-icon").removeClass(n.icons.header).addClass(n.icons.activeHeader),i.next().addClass("ui-accordion-content-active"))},_toggle:function(t){var n=t.newPanel,r=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=n,this.prevHide=r,this.options.animate?this._animate(n,r,t):(r.hide(),n.show(),this._toggleComplete(t)),r.attr({"aria-expanded":"false","aria-hidden":"true"}),r.prev().attr("aria-selected","false"),n.length&&r.length?r.prev().attr("tabIndex",-1):n.length&&this.headers.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),n.attr({"aria-expanded":"true","aria-hidden":"false"}).prev().attr({"aria-selected":"true",tabIndex:0})},_animate:function(e,t,n){var s,o,u,a=this,f=0,l=e.length&&(!t.length||e.index()",options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},pending:0,_create:function(){var t,n,r;this.isMultiLine=this._isMultiLine(),this.valueMethod=this.element[this.element.is("input,textarea")?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on({keydown:function(i){if(this.element.prop("readOnly")){t=!0,r=!0,n=!0;return}t=!1,r=!1,n=!1;var s=e.ui.keyCode;switch(i.keyCode){case s.PAGE_UP:t=!0,this._move("previousPage",i);break;case s.PAGE_DOWN:t=!0,this._move("nextPage",i);break;case s.UP:t=!0,this._keyEvent("previous",i);break;case s.DOWN:t=!0,this._keyEvent("next",i);break;case s.ENTER:case s.NUMPAD_ENTER:this.menu.active&&(t=!0,i.preventDefault(),this.menu.select(i));break;case s.TAB:this.menu.active&&this.menu.select(i);break;case s.ESCAPE:this.menu.element.is(":visible")&&(this._value(this.term),this.close(i),i.preventDefault());break;default:n=!0,this._searchTimeout(i)}},keypress:function(r){if(t){t=!1,r.preventDefault();return}if(n)return;var i=e.ui.keyCode;switch(r.keyCode){case i.PAGE_UP:this._move("previousPage",r);break;case i.PAGE_DOWN:this._move("nextPage",r);break;case i.UP:this._keyEvent("previous",r);break;case i.DOWN:this._keyEvent("next",r)}},input:function(e){if(r){r=!1,e.preventDefault();return}this._searchTimeout(e)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}clearTimeout(this.searching),this.close(e),this._change(e)}}),this._initSource(),this.menu=e(""))){n._unorderedListButton.setState(!0),n._outdentListButton.show(!0),n._indentListButton.show(!0);break}if(e.Selection.standardTagNameComparator(s,t("
      "))){n._orderedListButton.setState(!0),n._outdentListButton.show(!0),n._indentListButton.show(!0);break}}e.activeEditable&&n.applyButtonConfig(e.activeEditable.obj)}),e.Markup.addKeyHandler(9,function(e){return n.processTab(e)})},applyButtonConfig:function(n){var r=this.getEditableConfig(n);e.Selection.rangeObject.unmodifiableMarkupAtStart[0]&&(t.inArray("ul",r)!=-1&&e.Selection.canTag1WrapTag2(e.Selection.rangeObject.unmodifiableMarkupAtStart[0].nodeName,"ul")!=-1?this._unorderedListButton.show(!0):this._unorderedListButton.show(!1),t.inArray("ol",r)!=-1&&e.Selection.canTag1WrapTag2(e.Selection.rangeObject.unmodifiableMarkupAtStart[0].nodeName,"ol")!=-1?this._orderedListButton.show(!0):this._orderedListButton.show(!1))},processTab:function(e){return e.keyCode===9?e.shiftKey?this.outdentList():this.indentList():!0},getStartingDomObjectToTransform:function(){var t=e.Selection.rangeObject,n,r;for(n=0;n

      ")),r=this.getStartingDomObjectToTransform();if(!r){if(e.Selection.rangeObject.startContainer.contentEditable){u=n?t("
        "):t("
          "),o=t("
        • "),u.append(o);var m=o.get(0),g=e.getActiveEditable().obj;m.appendChild(document.createTextNode("")),g.append(u),g.focus();var y=e.createRange(),b=e.getSelection();y.setStart(m.firstChild,0),y.setEnd(m.firstChild,0),b.removeAllRanges(),b.addRange(y),e.Selection.updateSelection();return}e.Log.error(this,"Could not transform selection into a list");return}}v=r.nodeName.toLowerCase();if(v=="ul"&&!n)u=t(r),f=u.parent(),f.length>0&&h.Utils.Dom.isListElement(f.get(0))?f.get(0).nodeName.toLowerCase()==="li"?(f.after(u.children()),u.remove()):u.children().unwrap():(d=t(r),t.each(d.children("li"),function(t,n){c=e.Markup.transformDomObject(n,"p",e.Selection.rangeObject),c.after(c.children("ol,ul")),l.ensureContainerEditable(c.get(0))}),d.children().unwrap());else if(v=="ul"&&n)p(r,"ol"),this.mergeAdjacentLists(t(r));else if(v=="ol"&&!n)p(r,"ul"),this.mergeAdjacentLists(t(r));else if(v=="ol"&&n)u=t(r),f=u.parent(),f.length>0&&h.Utils.Dom.isListElement(f.get(0))?f.get(0).nodeName.toLowerCase()==="li"?(f.after(u.children()),u.remove()):u.children().unwrap():(d=t(r),t.each(d.children("li"),function(t,n){c=e.Markup.transformDomObject(n,"p",e.Selection.rangeObject),c.after(c.children("ol,ul")),l.ensureContainerEditable(c.get(0))}),d.children().unwrap());else{a=e.Selection.rangeObject.getSelectedSiblings(r),u=n?t("
            "):t("
              "),o=t("
            • "),u.append(o),t(r).contents().appendTo(o),t(r).replaceWith(u),e.Selection.rangeObject.startContainer==r&&(e.Selection.rangeObject.startContainer=o.get(0)),e.Selection.rangeObject.endContainer==r&&(e.Selection.rangeObject.endContainer=o.get(0));var w=o;if(a){i=!1;for(s=0;s"),u.append(i),w=i),i.append(a[s])}}this.mergeAdjacentLists(u);var m=w.get(0);if(h.Utils.Dom.isEmpty(m)){var y=e.createRange(),b=e.getSelection();m.appendChild(document.createTextNode("")),y.selectNodeContents(m.lastChild),b.removeAllRanges(),b.addRange(y),e.Selection.updateSelection()}}this.refreshSelection()},indentList:function(){var n=this.getNearestSelectedListItem(),r,i,s,o,u;if(n){u=t(n).prev("li");if(u.length===0)return!1;o=t(n).parent(),s=e.Selection.rangeObject.getSelectedSiblings(n),i=t(n).parent().clone(!1).empty(),i.append(n),u.append(i);if(s)for(r=0;r0&&h.Utils.Dom.isListElement(u.get(0))){f=e.Selection.rangeObject.getSelectedSiblings(n),f&&f.length>0?l=t(f[f.length-1]):l=s,l.nextAll("li").length>0&&(i=o.clone(!1).empty(),i.append(l.nextAll()),l.append(i)),a.length>0?a.after(s):o.before(s);if(f&&f.length>0)for(r=f.length-1;r>=0;--r)s.after(t(f[r]));o.contents("li").length===0&&o.remove(),a.length>0&&a.contents().length===0&&a.remove(),this.refreshSelection()}return!1}return!0},refreshSelection:function(){e.Selection.rangeObject.update(),e.Selection.rangeObject.select(),e.Selection.updateSelection()},mergeAdjacentLists:function(e,n){var r=e.get(0),i;while(r.previousSibling&&r.previousSibling.nodeType===1&&this.isMergable(r.previousSibling,r,n))r=r.previousSibling;e=t(r);while(r.nextSibling&&(r.nextSibling.nodeType===1&&this.isMergable(r.nextSibling,r,n)||r.nextSibling.nodeType===3&&t.trim(r.nextSibling.data).length===0))i=t(r.nextSibling),r.nextSibling.nodeType==1&&i.contents().appendTo(e),i.remove()},isMergable:function(e,t,n){return n?e.nodeName.toLowerCase()=="ul"||e.nodeName.toLowerCase()=="ol":e.nodeName==t.nodeName}});return l.commands.insertorderedlist={action:function(t,n){m.transformList(!0),n&&e.Selection.rangeObject&&(n.startContainer=e.Selection.rangeObject.startContainer,n.startOffset=e.Selection.rangeObject.startOffset,n.endContainer=e.Selection.rangeObject.endContainer,n.endOffset=e.Selection.rangeObject.endOffset)},indeterm:function(){},state:function(){for(i=0;i")))return!1;if(e.Selection.standardTagNameComparator(effectiveMarkup,t("
                ")))return!0}return!1}},l.commands.insertunorderedlist={action:function(t,n){m.transformList(!1),n&&e.Selection.rangeObject&&(n.startContainer=e.Selection.rangeObject.startContainer,n.startOffset=e.Selection.rangeObject.startOffset,n.endContainer=e.Selection.rangeObject.endContainer,n.endOffset=e.Selection.rangeObject.endOffset)},indeterm:function(){},state:function(){for(i=0;i")))return!0;if(e.Selection.standardTagNameComparator(effectiveMarkup,t("
                  ")))return!1}return!1}},l.commands.indent={action:function(t,n){m.indentList(),n&&e.Selection.rangeObject&&(n.startContainer=e.Selection.rangeObject.startContainer,n.startOffset=e.Selection.rangeObject.startOffset,n.endContainer=e.Selection.rangeObject.endContainer,n.endOffset=e.Selection.rangeObject.endOffset)},indeterm:function(){},state:function(){return!1}},l.commands.outdent={action:function(t,n){m.outdentList(),n&&e.Selection.rangeObject&&(n.startContainer=e.Selection.rangeObject.startContainer,n.startOffset=e.Selection.rangeObject.startOffset,n.endContainer=e.Selection.rangeObject.endContainer,n.endOffset=e.Selection.rangeObject.endOffset)},indeterm:function(){},state:function(){return!1}},m}),define("image/nls/i18n",{root:{"size.natural":"Original size","button.addimg.tooltip":"add image ref","floatingmenu.tab.img":"Image","floatingmenu.tab.formatting":"Formatting","floatingmenu.tab.resize":"Resize","floatingmenu.tab.crop":"Crop","button.uploadimg.tooltip":"Upload img","button.uploadimg.label":"Upload","button.img.align.left.tooltip":"Left align","button.img.align.right.tooltip":"Right Align","button.img.align.none.tooltip":"No alignment","field.img.title.label":"Title","field.img.title.tooltip":"Title","field.img.label":"URL","field.img.tooltip":"Source","border ":"Add Border to Image","padding.increase ":"Increase Padding","padding.decrease ":"Decrease Padding","size.increase ":"Increase Size","size.decrease ":"Decrease Size",Resize:"Resize",Crop:"Crop",Reset:"Reset",Accept:"Accept",Cancel:"Cancel",height:"Height",width:"Width","button.toggle.tooltip":"Toggle keep aspect ratio","field.img.src.label":"Source","field.img.src.tooltip":"Source"},ca:!0,de:!0,mk:!0,"pt-br":!0,ru:!0,uk:!0,"zh-hans":!0}),define("image/image-floatingMenu",["jquery","util/class","i18n!image/nls/i18n","i18n!aloha/nls/i18n","ui/ui","ui/scopes","ui/button","ui/toggleButton","ui/port-helper-attribute-field"],function(e,t,n,r,i,s,o,u,a){var f=e,l=window.GENTICS,c=window.Aloha;return t.extend({_constructor:function(){},init:function(e){e.floatingMenuControl=this,this.plugin=e,s.createScope(e.name,"Aloha.empty"),this._addUIInsertButton(),this._addUIMetaButtons(),this._addUIResetButton(),this._addUIAlignButtons(),this._addUIMarginButtons(),this._addUICropButtons(),this._addUIResizeButtons(),this._addUIAspectRatioToggleButton()},_addUIAspectRatioToggleButton:function(){var e=this.plugin;this._imageCnrRatioButton=i.adopt("imageCnrRatio",u,{tooltip:n.t("button.toggle.tooltip"),icon:"aloha-icon-cnr-ratio",scope:e.name,click:function(){e.toggleKeepAspectRatio()}}),e.settings.fixedAspectRatio!==!1&&(this._imageCnrRatioButton.setState(!0),e.keepAspectRatio=!0)},_addUIResetButton:function(){var e=this.plugin;this._imageCnrResetButton=i.adopt("imageCnrReset",o,{tooltip:n.t("Reset"),icon:"aloha-icon-cnr-reset",scope:e.name,click:function(){e.reset()}})},_addUIInsertButton:function(){var e=this.plugin;this._insertImageButton=i.adopt("insertImage",o,{tooltip:n.t("button.addimg.tooltip"),icon:"aloha-button aloha-image-insert",scope:"Aloha.continuoustext",click:function(){e.insertImg()}})},_addUIMetaButtons:function(){var e=this.plugin;this.imgSrcField=a({label:n.t("field.img.src.label"),labelClass:"aloha-image-input-label",tooltip:n.t("field.img.src.tooltip"),name:"imageSource",scope:e.name}),this.imgSrcField.setTemplate("{name}
                  {url}
                  "),this.imgSrcField.setObjectTypeFilter(e.objectTypeFilter),this.imgTitleField=a({label:n.t("field.img.title.label"),labelClass:"aloha-image-input-label",tooltip:n.t("field.img.title.tooltip"),name:"imageTitle",scope:e.name}),this.imgTitleField.setObjectTypeFilter()},_addUIAlignButtons:function(){var t=this.plugin;this._imageAlignLeftButton=i.adopt("imageAlignLeft",o,{tooltip:n.t("button.img.align.left.tooltip"),icon:"aloha-img aloha-image-align-left",scope:t.name,click:function(){var n=e(t.getPluginFocus());n.add(n.parent()).css("float","left")}}),this._imageAlignRightButton=i.adopt("imageAlignRight",o,{tooltip:n.t("button.img.align.right.tooltip"),icon:"aloha-img aloha-image-align-right",scope:t.name,click:function(){var n=e(t.getPluginFocus());n.add(n.parent()).css("float","right")}}),this._imageAlignNoneButton=i.adopt("imageAlignNone",o,{tooltip:n.t("button.img.align.none.tooltip"),icon:"aloha-img aloha-image-align-none",scope:t.name,click:function(){var n=e(t.getPluginFocus());n.add(n.parent()).css({"float":"none",display:"inline-block"})}})},_addUIMarginButtons:function(){var t=this.plugin;this._imageIncPaddingButton=i.adopt("imageIncPadding",o,{tooltip:n.t("padding.increase"),icon:"aloha-img aloha-image-padding-increase",scope:t.name,click:function(){e(t.getPluginFocus()).increase("padding")}}),this._imageDecPaddingButton=i.adopt("imageDecPadding",o,{tooltip:n.t("padding.decrease"),icon:"aloha-img aloha-image-padding-decrease",scope:t.name,click:function(){e(t.getPluginFocus()).decrease("padding")}})},_addUICropButtons:function(){var e=this.plugin;s.createScope("Aloha.img",["Aloha.global"]),this._imageCropButton=i.adopt("imageCropButton",u,{tooltip:n.t("Crop"),icon:"aloha-icon-cnr-crop",scope:e.name,click:function(){this.getState()?e.crop():e.endCrop()}})},_addUIResizeButtons:function(){var e=this.plugin;this.imgResizeHeightField=a({label:n.t("height"),labelClass:"aloha-image-input-label",name:"imageResizeHeight",width:50,scope:e.name}),this.imgResizeHeightField.maxValue=e.settings.maxHeight,this.imgResizeHeightField.minValue=e.settings.minHeight,this.imgResizeWidthField=a({label:n.t("width"),labelClass:"aloha-image-input-label",name:"imageResizeWidth",width:50,scope:e.name}),this.imgResizeWidthField.maxValue=e.settings.maxWidth,this.imgResizeWidthField.minValue=e.settings.minWidth},setScope:function(){s.setScope(this.plugin.name)},doLayout:function(){}})}),define("image/vendor/jcrop/jquery.jcrop.min",["jquery"],function(e){(function(e){e.Jcrop=function(t,n){function B(e){return""+parseInt(e)+"px"}function j(e){return""+parseInt(e)+"%"}function F(e){return s.baseClass+"-"+e}function I(t){var n=e(t).offset();return[n.left,n.top]}function q(e){return[e.pageX-C[0],e.pageY-C[1]]}function R(e){e!=L&&(P.setCursor(e),L=e)}function U(e,t){C=I(u),P.setCursor(e=="move"?e:e+"-resize");if(e=="move")return P.activateHandlers(W(t),Q);var n=_.getFixed(),r=X(e),i=_.getCorner(X(r));_.setPressed(_.getCorner(r)),_.setCurrent(i),P.activateHandlers(z(e,n),Q)}function z(e,t){return function(n){if(!s.aspectRatio)switch(e){case"e":n[1]=t.y2;break;case"w":n[1]=t.y2;break;case"n":n[0]=t.x2;break;case"s":n[0]=t.x2}else switch(e){case"e":n[1]=t.y+1;break;case"w":n[1]=t.y+1;break;case"n":n[0]=t.x+1;break;case"s":n[0]=t.x+1}_.setCurrent(n),D.update()}}function W(e){var t=e;return H.watchKeys(),function(e){_.moveOffset([e[0]-t[0],e[1]-t[1]]),t=e,D.update()}}function X(e){switch(e){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function V(e){return function(t){return s.disabled?!1:e=="move"&&!s.allowMove?!1:(k=!0,U(e,q(t)),t.stopPropagation(),t.preventDefault(),!1)}}function J(e,t,n){var r=e.width(),i=e.height();r>t&&t>0&&(r=t,i=t/e.width()*e.height()),i>n&&n>0&&(i=n,r=n/e.height()*e.width()),x=e.width()/r,T=e.height()/i,e.width(r).height(i)}function K(e){return{x:parseInt(e.x*x),y:parseInt(e.y*T),x2:parseInt(e.x2*x),y2:parseInt(e.y2*T),w:parseInt(e.w*x),h:parseInt(e.h*T)}}function Q(e){var t=_.getFixed();t.w>s.minSelect[0]&&t.h>s.minSelect[1]?(D.enableHandles(),D.done()):D.release(),P.setCursor(s.allowSelect?"crosshair":"default")}function G(e){if(s.disabled)return!1;if(!s.allowSelect)return!1;k=!0,C=I(u),D.disableHandles(),R("crosshair");var t=q(e);return _.setPressed(t),P.activateHandlers(Y,Q),H.watchKeys(),D.update(),e.stopPropagation(),e.preventDefault(),!1}function Y(e){_.setCurrent(e),D.update()}function Z(){var t=e("
                  ").addClass(F("tracker"));return e.browser.msie&&t.css({opacity:0,backgroundColor:"white"}),t}function et(e){function b(){window.setTimeout(y,f)}var t=e[0]/x,n=e[1]/T,r=e[2]/x,i=e[3]/T;if(O)return;var o=_.flipCoords(t,n,r,i),u=_.getFixed(),a=initcr=[u.x,u.y,u.x2,u.y2],f=s.animationDelay,l=a[0],c=a[1],r=a[2],i=a[3],h=o[0]-initcr[0],p=o[1]-initcr[1],d=o[2]-initcr[2],v=o[3]-initcr[3],m=0,g=s.swingSpeed;D.animMode(!0);var y=function(){return function(){m+=(100-m)/g,a[0]=l+m/100* +h,a[1]=c+m/100*p,a[2]=r+m/100*d,a[3]=i+m/100*v,m<100?b():D.done(),m>=99.8&&(m=100),nt(a)}}();b()}function tt(e){nt([e[0]/x,e[1]/T,e[2]/x,e[3]/T])}function nt(e){_.setPressed([e[0],e[1]]),_.setCurrent([e[2],e[3]]),D.update()}function rt(t){typeof t!="object"&&(t={}),s=e.extend(s,t),typeof s.onChange!="function"&&(s.onChange=function(){}),typeof s.onSelect!="function"&&(s.onSelect=function(){})}function it(){return K(_.getFixed())}function st(){return _.getFixed()}function ot(e){rt(e),ct()}function ut(){s.disabled=!0,D.disableHandles(),D.setCursor("default"),P.setCursor("default")}function at(){s.disabled=!1,ct()}function ft(){D.done(),P.activateHandlers(null,null)}function lt(){l.remove(),o.show()}function ct(e){s.allowResize?e?D.enableOnly():D.enableHandles():D.disableHandles(),P.setCursor(s.allowSelect?"crosshair":"default"),D.setCursor(s.allowMove?"move":"default"),l.css("backgroundColor",s.bgColor),"setSelect"in s&&(tt(n.setSelect),D.done(),delete s.setSelect),"trueSize"in s&&(x=s.trueSize[0]/a,T=s.trueSize[1]/f),y=s.maxSize[0]||0,b=s.maxSize[1]||0,E=s.minSize[0]||0,S=s.minSize[1]||0,"outerImage"in s&&(u.attr("src",s.outerImage),delete s.outerImage),D.refresh()}var t=t,n=n;typeof t!="object"&&(t=e(t)[0]),typeof n!="object"&&(n={}),"trackDocument"in n||(n.trackDocument=e.browser.msie?!1:!0,e.browser.msie&&e.browser.version.split(".")[0]=="8"&&(n.trackDocument=!0)),"keySupport"in n||(n.keySupport=e.browser.msie?!1:!0);var r={trackDocument:!1,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,borderOpacity:.4,handleOpacity:.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:!0,cornerHandles:!0,sideHandles:!0,drawBorders:!0,dragEdges:!0,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:!0,allowMove:!0,allowResize:!0,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}},s=r;rt(n);var o=e(t),u=o.clone().removeAttr("id").css({position:"absolute"});u.width(o.width()),u.height(o.height()),o.after(u).hide(),J(u,s.boxWidth,s.boxHeight);var a=u.width(),f=u.height(),l=e("
                  ").width(a).height(f).addClass(F("holder")).css({position:"relative",backgroundColor:s.bgColor}).insertAfter(o).append(u);s.addClass&&l.addClass(s.addClass);var c=e("").attr("src",u.attr("src")).css("position","absolute").width(a).height(f),p=e("
                  ").width(j(100)).height(j(100)).css({zIndex:310,position:"absolute",overflow:"hidden"}).append(c),d=e("
                  ").width(j(100)).height(j(100)).css("zIndex",320),v=e("
                  ").css({position:"absolute",zIndex:300}).insertBefore(u).append(p,d),m=s.boundary,g=Z().width(a+m*2).height(f+m*2).css({position:"absolute",top:B(-m),left:B(-m),zIndex:290}).mousedown(G),y,b,E,S,x,T,N=!0,C=I(u),k,L,A,O,M,_=function(){function u(i){var i=m(i);n=e=i[0],r=t=i[1]}function l(e){var e=m(e);i=e[0]-n,o=e[1]-r,n=e[0],r=e[1]}function c(){return[i,o]}function p(i){var s=i[0],o=i[1];0>e+s&&(s-=s+e),0>t+o&&(o-=o+t),fa&&(b=a,h=Math.abs((b-e)/i),E=d<0?t-h:h+t)):(b=n,h=v/i,E=d<0?t-h:t+h,E<0?(E=0,w=Math.abs((E-t)*i),b=p<0?e-w:w+e):E>f&&(E=f,w=Math.abs(E-t)*i,b=p<0?e-w:w+e)),b>e?(b-el&&(b=e+l),E>t?E=t+(b-e)/i:E=t-(b-e)/i):bl&&(b=e-l),E>t?E=t+(e-b)/i:E=t-(e-b)/i),b<0?(e-=b,b=0):b>a&&(e-=b-a,b=a),E<0?(t-=E,E=0):E>f&&(t-=E-f,E=f),last=C(g(e,t,b,E))}function m(e){return e[0]<0&&(e[0]=0),e[1]<0&&(e[1]=0),e[0]>a&&(e[0]=a),e[1]>f&&(e[1]=f),[e[0],e[1]]}function g(e,t,n,r){var i=e,s=n,o=t,u=r;return ny&&(n=i>0?e+y:e-y),b&&Math.abs(s)>b&&(r=s>0?t+b:t-b),S&&Math.abs(s)0?t+S:t-S),E&&Math.abs(i)0?e+E:e-E),e<0&&(n-=e,e-=e),t<0&&(r-=t,t-=t),n<0&&(e-=n,n-=n),r<0&&(t-=r,r-=r);if(n>a){var o=n-a;e-=o,n-=o}if(r>f){var o=r-f;t-=o,r-=o}if(e>a){var o=e-f;r-=o,t-=o}if(t>f){var o=t-f;r-=o,t-=o}return C(g(e,t,n,r))}function C(e){return{x:e[0],y:e[1],x2:e[2],y2:e[3],w:e[2]-e[0],h:e[3]-e[1]}}var e=0,t=0,n=0,r=0,i,o;return{flipCoords:g,setPressed:u,setCurrent:l,getOffset:c,moveOffset:p,getCorner:d,getFixed:v}}(),D=function(){function g(t){var n=e("
                  ").css({position:"absolute",opacity:s.borderOpacity}).addClass(F(t));return p.append(n),n}function y(t,n){var r=e("
                  ").mousedown(V(t)).css({cursor:t+"-resize",position:"absolute",zIndex:n});return d.append(r),r}function b(e){return y(e,a++).css({top:B(-m+1),left:B(-m+1),opacity:s.handleOpacity}).addClass(F("handle"))}function w(e){var t=s.handleSize,n=m,r=t,i=t,o=n,u=n;switch(e){case"n":case"s":i=j(100);break;case"e":case"w":r=j(100)}return y(e,a++).width(i).height(r).css({top:B(-o+1),left:B(-u+1)})}function E(e){for(i in e)l[e[i]]=b(e[i])}function S(e){var t=Math.round(e.h/2-m),n=Math.round(e.w/2-m),r=west=-m+1,i=e.w-m,s=e.h-m,o,u;"e"in l&&l.e.css({top:B(t),left:B(i)})&&l.w.css({top:B(t)})&&l.s.css({top:B(s),left:B(n)})&&l.n.css({left:B(n)}),"ne"in l&&l.ne.css({left:B(i)})&&l.se.css({top:B(s),left:B(i)})&&l.sw.css({top:B(s)}),"b"in l&&l.b.css({top:B(s)})&&l.r.css({left:B(i)})}function x(e,t){c.css({top:B(-t),left:B(-e)}),v.css({top:B(t),left:B(e)})}function T(e,t){v.width(e).height(t)}function N(){var e=_.getFixed();_.setPressed([e.x,e.y]),_.setCurrent([e.x2,e.y2]),C()}function C(){if(o)return k()}function k(){var e=_.getFixed();T(e.w,e.h),x(e.x,e.y),s.drawBorders&&f.right.css({left:B(e.w-1)})&&f.bottom.css({top:B(e.h-1)}),h&&S(e),o||L(),s.onChange(K(e))}function L(){v.show(),u.css("opacity",s.bgOpacity),o=!0}function A(){P(),v.hide(),u.css("opacity",1),o=!1}function M(){h&&(S(_.getFixed()),d.show())}function D(){h=!0;if(s.allowResize)return S(_.getFixed()),d.show(),!0}function P(){h=!1,d.hide()}function H(e){(O=e)?P():D()}function I(){H(!1),N()}var t,n,r,o,a=370,f={},l={},h=!1,m=s.handleOffset;s.drawBorders&&(f={top:g("hline").css("top",e.browser.msie?B(-1):B(0)),bottom:g("hline"),left:g("vline"),right:g("vline")}),s.dragEdges&&(l.t=w("n"),l.b=w("s"),l.r=w("e"),l.l=w("w")),s.sideHandles&&E(["n","s","e","w"]),s.cornerHandles&&E(["sw","nw","ne","se"]);var q=Z().mousedown(V("move")).css({cursor:"move",position:"absolute",zIndex:360});return p.append(q),P(),{updateVisible:C,update:k,release:A,refresh:N,setCursor:function(e){q.css("cursor",e)},enableHandles:D,enableOnly:function(){h=!0},showHandles:M,disableHandles:P,animMode:H,done:I}}(),P=function(){function i(){g.css({zIndex:450}),r&&e(document).mousemove(a).mouseup(f)}function o(){g.css({zIndex:290}),r&&e(document).unbind("mousemove",a).unbind("mouseup",f)}function a(e){t(q(e))}function f(e){return e.preventDefault(),e.stopPropagation(),k&&(k=!1,n(q(e)),s.onSelect(K(_.getFixed())),o(),t=function(){},n=function(){}),!1}function l(e,r){return k=!0,t=e,n=r,i(),!1}function c(e){g.css("cursor",e)}var t=function(){},n=function(){},r=s.trackDocument;return r||g.mousemove(a).mouseup(f).mouseout(f),u.before(g),{activateHandlers:l,setCursor:c}}(),H=function(){function r(){s.keySupport&&(t.show(),t.focus())}function i(e){t.hide()}function o(e,t,n){s.allowMove&&(_.moveOffset([t,n]),D.updateVisible()),e.preventDefault(),e.stopPropagation()}function a(e){if(e.ctrlKey)return!0;M=e.shiftKey?!0:!1;var t=M?10:1;switch(e.keyCode){case 37:o(e,-t,0);break;case 39:o(e,t,0);break;case 38:o(e,0,-t);break;case 40:o(e,0,t);break;case 27:D.release();break;case 9:return!0}return nothing(e)}var t=e('').css({position:"absolute",left:"-30px"}).keypress(a).blur(i),n=e("
                  ").css({position:"absolute",overflow:"hidden"}).append(t);return s.keySupport&&n.insertBefore(u),{watchKeys:r}}();d.hide(),ct(!0);var ht={animateTo:et,setSelect:tt,setOptions:ot,tellSelect:it,tellScaled:st,disable:ut,enable:at,cancel:ft,focus:H.watchKeys,getBounds:function(){return[a*x,f*T]},getWidgetSize:function(){return[a,f]},release:D.release,destroy:lt};return o.data("Jcrop",ht),ht},e.fn.Jcrop=function(t){function n(n){var r=t.useImg||n.src,i=new Image;i.onload=function(){e.Jcrop(n,t)},i.src=r}return typeof t!="object"&&(t={}),this.each(function(){if(e(this).data("Jcrop")){if(t=="api")return e(this).data("Jcrop");e(this).data("Jcrop").setOptions(t)}else n(this)}),this}})(e)}),define("image/vendor/mousewheel/mousewheel",["jquery"],function(e){(function(e){function r(t){var n=t||window.event,r=[].slice.call(arguments,1),i=0,s=!0,o=0,u=0;return t=e.event.fix(n),t.type="mousewheel",n.wheelDelta&&(i=n.wheelDelta/120),n.detail&&(i=-n.detail/3),u=i,n.axis!==undefined&&n.axis===n.HORIZONTAL_AXIS&&(u=0,o=-1*i),n.wheelDeltaY!==undefined&&(u=n.wheelDeltaY/120),n.wheelDeltaX!==undefined&&(o=-1*n.wheelDeltaX/120),r.unshift(t,i,o,u),(e.event.dispatch||e.event.handle).apply(this,r)}var t=["DOMMouseScroll","mousewheel"];if(e.event.fixHooks)for(var n=t.length;n;)e.event.fixHooks[t[--n]]=e.event.mouseHooks;e.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var e=t.length;e;)this.addEventListener(t[--e],r,!1);else this.onmousewheel=r},teardown:function(){if(this.removeEventListener)for(var e=t.length;e;)this.removeEventListener(t[--e],r,!1);else this.onmousewheel=null}},e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})})(e)}),define("image/image-plugin",["jquery","aloha/plugin","image/image-floatingMenu","i18n!aloha/nls/i18n","i18n!image/nls/i18n","jqueryui","image/vendor/jcrop/jquery.jcrop.min","image/vendor/mousewheel/mousewheel"],function(t,n,r,i,s){var o=t,u=t,a=window.GENTICS,f=window.Aloha;return String.prototype.toInteger=String.prototype.toInteger||function(){return parseInt(String(this).replace(/px$/,"")||0,10)},String.prototype.toFloat=String.prototype.toInteger||function(){return parseFloat(String(this).replace(/px$/,"")||0,10)},Number.prototype.toInteger=Number.prototype.toInteger||String.prototype.toInteger,Number.prototype.toFloat=Number.prototype.toFloat||String.prototype.toFloat,o.extend(!0,o.fn,{increase:o.fn.increase||function(e){var t=o(this),n,r;return t.length?(n=t.css(e).toFloat(),r=Math.round((n||1)*1.2),n===r&&r++,t.css(e,r),t):t},decrease:o.fn.decrease||function(e){var t=o(this),n,r;return t.length?(n=t.css(e).toFloat(),r=Math.round((n||0)*.8),n===r&&r>0&&r--,t.css(e,r),t):t}}),n.create("image",{defaultSettings:{maxWidth:1600,minWidth:3,maxHeight:1200,minHeight:3,autoCorrectManualInput:!0,fixedAspectRatio:!1,autoResize:!1,ui:{meta:!0,crop:!0,resizable:!0},handles:"ne, se, sw, nw",onCropped:function(e,t){f.Log.info("Default onCropped invoked",e,t)},onReset:function(e){return f.Log.info("Default onReset invoked",e),!1},onResize:function(e){f.Log.info("Default onResize invoked",e)},onResized:function(e){f.Log.info("Default onResized invoked",e)}},_onCropped:function(e,t){u("#"+this.ui.imgResizeHeightField.getInputId()).val(e.height()),u("#"+this.ui.imgResizeWidthField.getInputId()).val(e.width()),u("body").trigger("aloha-image-cropped",[e,t]),this.onCropped(e,t)},_onReset:function(e){return u("#"+this.ui.imgResizeHeightField.getInputId()).val(e.height()),u("#"+this.ui.imgResizeWidthField.getInputId()).val(e.width()),u("body").trigger("aloha-image-reset",e),this.onReset(e)},_onResize:function(e){u("#"+this.ui.imgResizeHeightField.getInputId()).val(e.height()),u("#"+this.ui.imgResizeWidthField.getInputId()).val(e.width()),u("body").trigger("aloha-image-resize",e),this.onResize(e)},_onResized:function(e){u("#"+this.ui.imgResizeHeightField.getInputId()).val(e.height()),u("#"+this.ui.imgResizeWidthField.getInputId()).val(e.width()),u("body").trigger("aloha-image-resized",e),this.onResized(e)},imageObj:null,jcAPI:null,keepAspectRatio:!1,startAspectRatio:!1,restoreProps:[],objectTypeFilter:[],init:function(){var e=this,t=f.getPluginUrl("image");typeof this.settings.objectTypeFilter!="undefined"&&(this.objectTypeFilter=this.settings.objectTypeFilter),e.startAspectRatio=e.settings.fixedAspectRatio,e.config=e.defaultSettings,e.settings=o.extend(!0,e.defaultSettings,e.settings),e.initializeUI(),e.bindInteractions(),e.subscribeEvents()},initializeUI:function(){var e=this;this.ui=new r,this.ui.init(this)},bindInteractions:function(){var e=this;if(e.settings.ui.resizable)try{document.execCommand("enableObjectResizing",!1,!1)}catch(t){f.Log.info(t,"Could not disable enableObjectResizing")}e.settings.ui.meta&&(e.ui.imgSrcField.addListener("keyup",function(t){e.srcChange()}),e.ui.imgSrcField.addListener("blur",function(t){var n=o(e.ui.imgSrcField.getTargetObject());n.attr("src")===""&&n.remove()})),e.settings.onCropped&&typeof e.settings.onCropped=="function"&&(e.onCropped=e.settings.onCropped),e.settings.onReset&&typeof e.settings.onReset=="function"&&(e.onReset=e.settings.onReset),e.settings.onResized&&typeof e.settings.onResized=="function"&&(e.onResized=e.settings.onResized),e.settings.onResize&&typeof e.settings.onResize=="function"&&(e.onResize=this.settings.onResize)},subscribeEvents:function(){var e=this,t=this.settings,n={};o("img").filter(t.globalselector).unbind(),o("img").filter(t.globalselector).click(function(t){e.clickImage(t)});var r=function(){n[f.activeEditable.getId()]?e.ui._insertImageButton.show():e.ui._insertImageButton.hide()};f.bind("aloha-drop-files-in-editable",function(t,n){var r,i=n.filesObjs.length,s,u;while(--i>=0)s=n.filesObjs[i],s.file.type.match(/image\//)&&(u=e.getEditableConfig(n.editable),r=o(""),r.css({"max-width":that.maxWidth,"max-height":that.maxHeight}),r.attr("id",s.id),typeof s.src=="undefined"?r.attr("src",s.data):r.attr("src",s.src),a.Utils.Dom.insertIntoDOM(r,n.range,o(f.activeEditable.obj)))}),f.bind("aloha-selection-changed",function(t,n,i){var s,u;i&&i.target&&e.settings.ui.resizable&&!o(i.target).hasClass("ui-resizable-handle")&&(e.endResize(),e.imageObj=null,f.trigger("aloha-image-unselected")),f.activeEditable!==null&&(u=e.findImgMarkup(n),r(),u?(e.ui._insertImageButton.show(),e.ui.setScope(),e.settings.ui.meta&&(e.ui.imgSrcField.setTargetObject(u,"src"),e.ui.imgTitleField.setTargetObject(u,"title")),e.ui.imgSrcField.foreground(),e.ui.imgSrcField.focus()):e.settings.ui.meta&&e.ui.imgSrcField.setTargetObject(null),e.ui.doLayout())}),f.bind("aloha-editable-created",function(t,r){var i=e.getEditableConfig(r.obj),s=o.inArray("img",i)!==-1;n[r.getId()]=s;if(!s)return;try{document.execCommand("enableObjectResizing",!1,!1)}catch(u){f.Log.info(u,"Could not disable enableObjectResizing")}r.obj.delegate("img","mouseup",function(t){e.clickImage(t),t.stopPropagation()})}),f.bind("aloha-editable-activated",function(){r()}),e._subscribeToResizeFieldEvents()},autoResize:function(){var e=this,t=e.imageObj.width(),n=e.imageObj.height(),r=!1;if(te.settings.maxWidth||ne.settings.maxHeight)r=!0;return r&&t>=n?(e._setNormalizedFieldValues("width"),e.setSizeByFieldValue(),!0):r&&t=0&&o>r?e.settings.autoCorrectManualInput?(t.val(r),!0):(t.css("background-color","red"),!1):n<=0&&o=r&&(typeof e.jcAPI!="undefined"&&e.jcAPI!==null?e.setCropAreaByFieldValue():(e._setNormalizedFieldValues(s),e.setSizeByFieldValue()));else if(n.keyCode<=57&&n.keyCode>=48||n.keyCode<=105&&n.keyCode>=96)u(this).val()>=r&&(typeof e.jcAPI!="undefined"&&e.jcAPI!==null?e.setCropAreaByFieldValue():(e._setNormalizedFieldValues(s),e.setSizeByFieldValue()));else{var o=0;if(n.keyCode===38||n.keyCode===107)o=1;else if(n.keyCode===40||n.keyCode===109)o=-1;if(n.shiftKey||n.metaKey||n.ctrlKey)o*=10;t(u(this),o,i,r)&&(typeof e.jcAPI!="undefined"&&e.jcAPI!==null?e.setCropAreaByFieldValue():(e._setNormalizedFieldValues(s),e.setSizeByFieldValue()))}return n.preventDefault(),!1}function r(n,r){var i=n.data.minValue,s=n.data.maxValue,o=n.data.fieldName;if(n.shiftKey||n.metaKey||n.ctrlKey)r*=10;return t(u(this),r,s,i)&&(typeof e.jcAPI!="undefined"&&e.jcAPI!==null?e.setCropAreaByFieldValue():(e._setNormalizedFieldValues(o),e.setSizeByFieldValue())),!1}var e=this,i=u("#"+e.ui.imgResizeHeightField.getInputId()),s={fieldName:"height",maxValue:e.ui.imgResizeHeightField.maxValue,minValue:e.ui.imgResizeHeightField.minValue};i.live("keyup",s,n),i.live("mousewheel",s,r);var o=u("#"+e.ui.imgResizeWidthField.getInputId()),a={fieldName:"width",maxValue:e.ui.imgResizeWidthField.maxValue,minValue:e.ui.imgResizeWidthField.minValue};o.live("keyup",a,n),o.live("mousewheel",a,r)},_setNormalizedFieldValues:function(e){var t=this,n=o("#"+t.ui.imgResizeWidthField.getInputId()),r=o("#"+t.ui.imgResizeHeightField.getInputId()),i=n.val(),s=r.val(),u=t._normalizeSize(i,s,e);n.val(u.width),r.val(u.height)},setSize:function(e,t){var n=this;n.imageObj.width(e),n.imageObj.height(t);var r=n.imageObj.closest(".Aloha_Image_Resize");r.height(t),r.width(e),n._onResize(n.imageObj),n._onResized(n.imageObj)},clickImage:function(e){var t=this;t.endResize(),t.imageObj=o(e.target);var n=t.imageObj;if(n.hasClass("aloha-ui"))return;t.ui.setScope();var r=n.closest(".aloha-editable");this.restoreProps.push({obj:e.srcElement,src:t.imageObj.attr("src"),width:t.imageObj.width(),height:t.imageObj.height()}),u("#"+t.ui.imgResizeHeightField.getInputId()).val(t.imageObj.height()),u("#"+t.ui.imgResizeWidthField.getInputId()).val(t.imageObj.width()),t.settings.ui.meta&&(t.ui.imgSrcField.setTargetObject(t.imageObj,"src"),t.ui.imgTitleField.setTargetObject(t.imageObj,"title")),f.Selection.preventSelectionChanged();try{t.ui.imgSrcField.focus()}catch(e){}t.settings.ui.resizable&&t.startResize(),t.settings.autoResize&&t.autoResize(),f.Selection.preventSelectionChangedFlag=!1,f.trigger("aloha-image-selected")},findImgMarkup:function(e){var t=this,n=this.config,r,i;typeof e=="undefined"&&(e=f.Selection.getRangeObject()),i=o(e.startContainer);try{if(f.activeEditable)return typeof e.startContainer!="undefined"&&typeof e.startContainer.childNodes!="undefined"&&typeof e.startOffset!="undefined"&&typeof e.startContainer.childNodes[e.startOffset]!="undefined"&&e.startContainer.childNodes[e.startOffset].nodeName.toLowerCase()==="img"&&e.startOffset+1===e.endOffset||i.hasClass("Aloha_Image_Resize")?(r=i.find("img")[0],r.css||(r.css=""),r.title||(r.title=""),r.src||(r.src=""),r):null}catch(s){f.Log.debug(s,"Error finding img markup.")}return null},getPluginFocus:function(){return this.imageObj},_normalizeSize:function(e,t,n){function i(n){if(t>r.settings.maxHeight){var i={org:t,"new":r.settings.maxHeight};u("body").trigger("aloha-image-resize-outofbounds",["height","max",i]),t=r.settings.maxHeight}else if(tr.settings.maxWidth){var s={org:e,"new":r.settings.maxWidth};u("body").trigger("aloha-image-resize-outofbounds",["width","max",s]),e=r.settings.maxWidth}else if(e',s=o(i),a.Utils.Dom.insertIntoDOM(s,e,o(f.activeEditable.obj))):f.Log.error("img cannot markup a selection")},srcChange:function(){this.imageObj.attr("src",this.ui.imgSrcField.getValue())},positionCropButtons:function(){var e=o(".jcrop-tracker:first"),t=e.offset(),n=t.top,r=t.left,i=e.height(),s=e.width(),u=0,a=0,f=o("#aloha-CropNResize-btns");n===0&&r===0&&f.hide(),n=parseInt(n+i+3,10),r=parseInt(r+s/2-f.width()/2+10,10),(u!=r||a!=n)&&f.offset({top:n,left:r}),u=r,a=n},initCropButtons:function(){var e=this,t;o("body").append('
                  '+''+"
                  "),t=o("#aloha-CropNResize-btns"),t.find(".cnr-crop-apply").click(function(){e.acceptCrop()}),t.find(".cnr-crop-cancel").click(function(){e.endCrop()}),this.interval=setInterval(function(){e.positionCropButtons()},10)},destroyCropButtons:function(){o("#aloha-CropNResize-btns").remove(),clearInterval(this.interval)},_disableSelection:function(e){e.find("*").attr("unselectable","on").css({"-moz-user-select":"none","-webkit-user-select":"none","user-select":"none"})},crop:function(){var e=this,t=this.config;e.initCropButtons(),e.settings.ui.resizable&&e.endResize(),e.jcAPI=o.Jcrop(e.imageObj,{onSelect:function(){e._onCropSelect(),window.setTimeout(function(){e.ui.setScope()},10)}}),e._disableSelection(u(".jcrop-holder")),e._disableSelection(u("#imageContainer")),e._disableSelection(u("#aloha-CropNResize-btns")),u("body").trigger("aloha-image-crop-start",[e.imageObj])},_onCropSelect:function(){var e=this;o("#aloha-CropNResize-btns").fadeIn("slow"),o(".jcrop-handle").mousedown(function(){o("#aloha-CropNResize-btns").hide()}),o(".jcrop-tracker").mousedown(function(){o("#aloha-CropNResize-btns").hide()});if(typeof e.jcAPI!="undefined"&&e.jcAPI!==null){e.positionCropButtons();var t=e.jcAPI.tellSelect(),n=o("#"+e.ui.imgResizeWidthField.getInputId()).val(t.w),r=o("#"+e.ui.imgResizeHeightField.getInputId()).val(t.h)}},endCrop:function(){this.jcAPI&&(this.jcAPI.destroy(),this.jcAPI=null),this.destroyCropButtons(),this.ui._imageCropButton.setState(!1),this.settings.ui.resizable&&this.startResize();if(this.keepAspectRatio){var e=this.imageObj.width()/this.imageObj.height();this.startAspectRatio=e}u("body").trigger("aloha-image-crop-stop",[this.imageObj])},acceptCrop:function(){this._onCropped(this.imageObj,this.jcAPI.tellSelect()),this.endCrop()},startResize:function(){var e=this,t=this.imageObj;t=this.imageObj.css({height:this.imageObj.height(),width:this.imageObj.width(),position:"relative","max-height":"","max-width":""}),t.resizable({maxHeight:e.settings.maxHeight,minHeight:e.settings.minHeight,maxWidth:e.settings.maxWidth,minWidth:e.settings.minWidth,aspectRatio:e.startAspectRatio,handles:e.settings.handles,grid:e.settings.grid,resize:function(t,n){e._onResize(e.imageObj)},stop:function(t,n){e._onResized(e.imageObj),this.enableCrop&&window.setTimeout(function(){e.ui.setScope(),that.done(t)},10)}}),t.css("display","inline-block"),o(".ui-wrapper").attr("contentEditable",!1).addClass("aloha-image-box-active Aloha_Image_Resize aloha").css({position:"relative",display:"inline-block","float":e.imageObj.css("float")}).bind("resizestart",function(e){e.preventDefault()}).bind("mouseup",function(e){e.originalEvent.stopSelectionUpdate=!0})},endResize:function(){if(this.imageObj)var e=this.imageObj.closest(".aloha-editable");this.imageObj&&this.imageObj.is(":ui-resizable")&&this.imageObj.resizable("destroy").css({top:0,left:0})},resetSize:function(){var e=this,t=new Image;t.onload=function(){var n=e.getPluginFocus();e.settings.ui.resizable&&e.endResize(),o(n).add(n.parent()).css({width:t.width+"px",height:t.height+"px","max-width":"","max-height":""}),e.settings.ui.resizable&&e.resize()},t.src=e.getPluginFocus().attr("src")},reset:function(){this.settings.ui.crop&&this.endCrop(),this.settings.ui.resizable&&this.endResize();if(this._onReset(this.imageObj))return;for(var e=0;e"):(i.push("<"+s+c(e,r)+">"),t=p(e,t,n,r,i),i.push("")),t}function v(e,t,n){var r=e.nodeType;1===r?d(e,e.firstChild,h(e),t,n):3===e.nodeType?n.push(f(e.nodeValue)):8===e.nodeType?n.push(""):s.warn("Unknown node type encountered during serialization, ignoring it: type="+e.nodeType+" name="+e.nodeName+" value="+e.nodeValue)}var o={area:!0,base:!0,basefont:!0,br:!0,col:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,link:!0,meta:!0,param:!0,embed:!0},u={checked:!0,compact:!0,declare:!0,defer:!0,disabled:!0,ismap:!0,multiple:!0,nohref:!0,noresize:!0,noshade:!0,nowrap:!0,readonly:!0,selected:!0},a={DIV:!1,SPAN:!1,UL:!1,OL:!1,LI:!1,TABLE:!1,TR:!1,TD:!1,TH:!1,I:!1,B:!1,EM:!1,STRONG:!1,A:!1,P:!1};return{contentsToXhtml:function(e,t){var n=[];return p(e,e.firstChild,!1,t,n),n.join("")},nodeToXhtml:function(e,t){var n=[];return v(e,t,n),n.join("")}}}),define("dom-to-xhtml/dom-to-xhtml-plugin",["aloha","jquery","aloha/plugin","aloha/ephemera","dom-to-xhtml/dom-to-xhtml"],function(e,t,n,r,i){return n.create("dom-to-xhtml",{init:function(){var n=this;e.Editable.setContentSerializer(function(e){return!n.settings.editables&&!n.settings.config?i.contentsToXhtml(e):n.settings.editables&&n.settings.editables["#"+t(e).attr("id")]=="dom-to-xhtml"?i.contentsToXhtml(e,r.ephemera()):n.settings.config&&n.settings.config=="dom-to-xhtml"&&!n.settings.editables["#"+t(e).attr("id")]?i.contentsToXhtml(e,r.ephemera()):t(e).html()})}})}),define("contenthandler/wordcontenthandler",["aloha","jquery","aloha/contenthandlermanager"],function(e,t,n){var r=n.createHandler({handleContent:function(e){return typeof e=="string"?e=t("
                  "+e+"
                  "):e instanceof t&&(e=t("
                  ").append(e)),this.detectWordContent(e)&&this.transformWordContent(e),e.html()},detectWordContent:function(e){var n=!1;return e.find("*").each(function(){var e=t(this).attr("style"),r;if(e&&e.toLowerCase().indexOf("mso")>=0)return n=!0,!1;r=t(this).attr("class");if(r&&r.toLowerCase().indexOf("mso")>=0)return n=!0,!1}),n},isOrderedList:function(e){return e.css("fontFamily")=="Wingdings"||e.css("fontFamily")=="Symbol"?!1:e.text().match(/^([0-9]{1,3}\.)|([0-9]{1,3}\)|([a-zA-Z]{1,5}\.)|([a-zA-Z]{1,5}\)))$/)?!0:!1},transformListsFromWord:function(e){var n=this,r,i,s,o,u,a;a="aloha-list-element",u="aloha-list-bullet",i="p.MsoListParagraphCxSpFirst,p.MsoListParagraphCxSpMiddle,p.MsoListParagraphCxSpLast,p.MsoListParagraph,p span",o=e.find(i),o.each(function(){var e=t(this),n=e.css("font-family")||"",r=e.css("mso-list")||"",i=e.attr("style")||"";e.hasClass("MsoListParagraphCxSpFirst")||e.hasClass("MsoListParagraph")?e.addClass(a):n.indexOf("Symbol")>=0?e.closest("p").addClass(a):n.indexOf("Wingdings")>=0?e.closest("p").addClass(a):r!==""?e.closest("p").addClass(a):i.indexOf("mso-list")>=0&&e.closest("p").addClass(a)}),i="p span span span",s=e.find(i),s.each(function(){var e=t(this),n=t.trim(e.text()).replace(/ /g,""),r;n.length===0&&(r=t.trim(e.parent().parent().text()).replace(/ /g,""),r.match(/^([0-9]{1,3}\.)|([0-9]{1,3}\))|([a-zA-Z]{1,5}\.)|([a-zA-Z]{1,5}\))|(.)$/)&&(e.closest("p").addClass(a),e.parent().parent().addClass(u)))}),i="p."+a,r=":not("+i+", font)",o=e.find(i),o.length>0&&o.each(function(){var e=t(this),i,s,o,f,l,c,h,p;e.removeClass(a),e.find("font").each(function(){t(this).contents().unwrap()}),p=[],h=parseFloat(e.css("marginLeft")),isNaN(h)&&(h=0),c=[],l=e.nextUntil(r),f=t(e.find("span."+u)),f.length===0&&(f=e.find("span").eq(0)),o=n.isOrderedList(f),f.remove(),s=t(o?"
                    ":"
                      "),c.push(s),i=t("
                    • "),s.append(i),e.contents().appendTo(i),e.replaceWith(s),l.each(function(){var e=t(this),r,a;if(e.is("font"))return;e.find("font").each(function(){t(this).contents().unwrap()}),r=parseFloat(e.css("marginLeft")),isNaN(r)&&(r=0),f=t(e.find("span."+u)),f.length===0&&(f=e.find("span").eq(0)),o=n.isOrderedList(f),f.remove();if(r>h)a=t(o?"
                        ":"
                          "),s.children(":last").append(a),s=a,c.push(s),p.push(r),h=r;else if(r0){while(p.length>0&&p[p.length-1]>r)p.pop(),c.pop();s=c[c.length-1],h=r}i=t("
                        • "),s.append(i),e.contents().appendTo(i),e.remove()})})},transformTitles:function(n){n.find("p.MsoTitle").each(function(){e.Markup.transformDomObject(t(this),"h1")}),n.find("p.MsoSubtitle").each(function(){e.Markup.transformDomObject(t(this),"h2")})},cleanHtml:function(e){e.find("*").filter(function(){return t.trim(t(this).text())==""&&!t(this).is("td")}).contents().unwrap(),e.find("span").contents().unwrap(),e.find("a").each(function(){t(this).attr("href")&&t.trim(t(this).attr("href")).match(/^#(.*)$/)&&t(this).contents().unwrap()}),e.find("div").contents().unwrap(),e.find("*").filter(function(){return t.trim(t(this).text())==""&&!t(this).is("td")}).remove()},removeParagraphNumbering:function(e){var n="h1,h2,h3,h4,h5,h6",r=e.find(n);r.length>0&&r.each(function(){var e=t(this),n=e.find("span"),r=e.find("a");n.each(function(){t.trim(t(this).text()).match(/^([\.\(]?[\d\D][\.\(]?){1,4}$/)&&t(this).remove()}),r.each(function(){typeof t(this).attr("href")=="undefined"&&t(this).contents().unwrap()})})},transformToc:function(e){var n="[class*=MsoToc]",r=e.find(n +);r.each(function(){var e=t(this),n=e.find("span"),r=e.find("a");n.each(function(){t(this).attr("style")&&t(this).attr("style").search("mso-hide")>-1&&t(this).remove(),t(this).contents().unwrap()}),r.each(function(){t(this).contents().unwrap()})})},transformWordContent:function(e){this.transformToc(e),this.removeParagraphNumbering(e),this.transformListsFromWord(e),this.transformTitles(e),this.cleanHtml(e)}});return r}),define("contenthandler/genericcontenthandler",["aloha","jquery","aloha/contenthandlermanager"],function(e,t,n){var r=window.GENTICS,i=n.createHandler({handleContent:function(n){if(null==n)return;typeof n=="string"?n=t("
                          "+n+"
                          "):n instanceof t&&(n=t("
                          ").append(n));if(n.find(".aloha-block").length>0)return n.html();this.cleanLists(n),this.transformTables(n),this.removeComments(n),this.unwrapTags(n),this.removeStyles(n),this.removeNamespacedElements(n);var r=!0;return e.settings&&e.settings.contentHandler&&e.settings.contentHandler.handler&&e.settings.contentHandler.handler.generic&&typeof e.settings.contentHandler.handler.generic.transformFormattings!="undefinded"&&!e.settings.contentHandler.handler.generic.transformFormattings&&(r=!1),r===!0&&this.transformFormattings(n),n.html()},cleanLists:function(e){e.find("ul,ol").each(function(){var e=t(this);e.contents(":not(li,ul,ol)").each(function(){t(this).remove()})})},transformTables:function(e){e.find("table").each(function(){t(this).removeAttr("border").removeAttr("cellspacing").removeAttr("cellpadding")}),e.find("td").each(function(){t(this).removeAttr("width").removeAttr("height").removeAttr("valign"),this.innerHTML.replace(/[\s\xA0]+/g,"")==="


                          "&&(this.innerHTML=" "),t(this).find("p").length===1&&t(this).find("p").contents().unwrap()}),e.find("tr").each(function(){t(this).removeAttr("width").removeAttr("height").removeAttr("valign")}),e.find("colgroup").remove()},transformFormattings:function(n){n.find("strong,em,s,u,strike").each(function(){this.nodeName==="STRONG"?e.Markup.transformDomObject(t(this),"b"):this.nodeName==="EM"?e.Markup.transformDomObject(t(this),"i"):this.nodeName==="S"||this.nodeName=="STRIKE"?e.Markup.transformDomObject(t(this),"del"):this.nodeName==="U"&&t(this).contents().unwrap()})},transformLinks:function(e){e.find("a").each(function(){typeof t(this).attr("href")=="undefined"&&t(this).contents().unwrap()})},removeComments:function(e){var n=this;e.contents().each(function(){this.nodeType===8?t(this).remove():n.removeComments(t(this))})},unwrapTags:function(n){var r=this;n.find("span,font,div").not(".aloha-wai-lang").each(function(){this.nodeName=="DIV"?this.innerHTML==="
                          "?t(this).contents().unwrap():t(e.Markup.transformDomObject(t(this),"p").append("
                          ")).contents().unwrap():t(this).contents().unwrap()})},removeStyles:function(e){var n=this;e.children("style").filter(function(){return this.contentEditable!=="false"}).remove(),e.children().filter(function(){return this.contentEditable!=="false"}).each(function(){t(this).removeAttr("style").removeClass(),n.removeStyles(t(this))})},removeNamespacedElements:function(e){e.find("*").each(function(){var e=this.prefix?this.prefix:this.scopeName?this.scopeName:undefined;if(e&&e!=="HTML"||this.nodeName.indexOf(":")>=0){var n=t(this),r=n.contents();r.length?r.unwrap():n.remove()}})}});return i}),define("contenthandler/oembedcontenthandler",["aloha","jquery","aloha/contenthandlermanager"],function(e,t,n){function c(e,t){var n=e.apiendpoint,r="",s=e.callbackparameter||"callback",o;n.indexOf("?")<=0?n+="?":n+="&",e.maxWidth!=null&&e.params["maxwidth"]==null&&(e.params.maxwidth=e.maxWidth),e.maxHeight!=null&&e.params["maxheight"]==null&&(e.params.maxheight=e.maxHeight);for(o in e.params){if(o==e.callbackparameter)continue;e.params[o]!=null&&(r+="&"+i(o)+"="+e.params[o])}return n+="format=json&url="+i(t)+r+"&"+s+"=?",n}function h(e,n,r){var i=c(r,n),s=t.extend({url:i,type:"get",dataType:"json",success:function(r){var i=t.extend({},r);switch(i.type){case"photo":i.code=t.fn.oembed.getPhotoCode(n,i);break;case"video":i.code=t.fn.oembed.getVideoCode(n,i);break;case"rich":i.code=t.fn.oembed.getRichCode(n,i);break;default:i.code=t.fn.oembed.getGenericCode(n,i)}f.beforeEmbed.call(e,i),f.onEmbed.call(e,i),f.afterEmbed.call(e,i)},error:f.onError.call(e,n,r)},f.ajaxOptions||{});t.ajax(s)}function p(){l=[];var e,n=[],r,i;if(!v(f.allowedProviders)){for(r=0;r=0&&l.push(t.fn.oembed.providers[r]);f.greedy=!1}else l=t.fn.oembed.providers;if(!v(f.disallowedProviders)){for(r=0;r
                          ').next(".oembed-container"),r!=null&&r.provider_name!=null&&i.toggleClass("oembed-container-"+r.provider_name);i.html(r.code)}},t.fn.oembed.getInsertCode=function(e,t,n){if(n==null)return;return n.code},t.fn.oembed.getPhotoCode=function(e,t){var n,r=t.title?t.title:"";return r+=t.author_name?" - "+t.author_name:"",r+=t.provider_name?" - "+t.provider_name:"",n='
                          '+r+'
                          ',t.html&&(n+="
                          "+t.html+"
                          "),n},t.fn.oembed.getVideoCode=function(e,t){var n=t.html;return n},t.fn.oembed.getRichCode=function(e,t){var n=t.html;return n},t.fn.oembed.getGenericCode=function(e,t){var n=t.title!=null?t.title:e,r=''+n+"";return t.html&&(r+="
                          "+t.html+"
                          "),r},t.fn.oembed.isProviderAvailable=function(e){var t=o(e);return t!=null},t.fn.oembed.getOEmbedProvider=function(e){for(var t=0;t"+e+"
                          ").get(0):e instanceof t&&(e=t("
                          ").append(e).get(0)),e=t(e).oembed(t(e).text(),{embedMethod:"replace"});var n=setTimeout(function(){return e=t.fn.oembed.embedCode,t("
                          ").append(e).html()},500)},replaceoEmbedContent:function(e){}});return m}),define("contenthandler/sanitizecontenthandler",["aloha/core","jquery","aloha/contenthandlermanager","aloha/plugin","aloha/console","vendor/sanitize"],function(e,t,n,r,i){function o(n){var r=["restricted","basic","relaxed"],i=e.defaults.supports;e.settings.contentHandler.sanitize&&t.inArray(e.settings.contentHandler.sanitize,r)>-1?i=e.defaults.sanitize[e.settings.contentHandler.sanitize]:i=e.defaults.sanitize.relaxed,e.settings.contentHandler.allows&&(i=e.settings.contentHandler.allows),n&&(i=n),i.filters=[function(e){return e.contentEditable!="false"}],s=new Sanitize(i,t)}var s;e.defaults.sanitize||(e.defaults.sanitize={}),e.defaults.sanitize.restricted={elements:["b","em","i","strong","u","del","p","span","div","br"]},e.defaults.sanitize.basic={elements:["a","abbr","b","blockquote","br","cite","code","dd","del","dl","dt","em","i","li","ol","p","pre","q","small","strike","strong","sub","sup","u","ul"],attributes:{a:["href"],blockquote:["cite"],q:["cite"],abbr:["title"]},protocols:{a:{href:["ftp","http","https","mailto","__relative__"]},blockquote:{cite:["http","https","__relative__"]},q:{cite:["http","https","__relative__"]}}},e.defaults.sanitize.relaxed={elements:["a","abbr","b","blockquote","br","caption","cite","code","col","colgroup","dd","del","dl","dt","em","h1","h2","h3","h4","h5","h6","i","img","li","ol","p","pre","q","small","strike","strong","sub","sup","table","tbody","td","tfoot","th","thead","tr","u","ul","span","hr","object","div"],attributes:{a:["href","title","id","class","target","data-gentics-aloha-repository","data-gentics-aloha-object-id"],div:["id","class","style"],abbr:["title"],blockquote:["cite"],br:["class"],col:["span","width"],colgroup:["span","width"],img:["align","alt","height","src","title","width","class","data-caption","data-align","data-width","data-original-image"],ol:["start","type"],p:["class","style","id"],q:["cite"],table:["summary","width"],td:["abbr","axis","colspan","rowspan","width"],th:["abbr","axis","colspan","rowspan","scope","width"],ul:["type"],span:["class","style","lang","xml:lang","role"]},protocols:{a:{href:["ftp","http","https","mailto","__relative__"]},blockquote:{cite:["http","https","__relative__"]},img:{src:["http","https","__relative__"]},q:{cite:["http","https","__relative__"]}}};var u=n.createHandler({handleContent:function(n){var r,i;if(e.activeEditable&&e.settings.contentHandler&&e.settings.contentHandler.handler&&e.settings.contentHandler.handler.sanitize){e.settings.contentHandler.handler.sanitize&&(i=e.settings.contentHandler.handler.sanitize);var u=i["#"+e.activeEditable.getId()];if(typeof u!="undefined")r=i;else{var a=e.activeEditable.obj.attr("class").split(" ");for(var f=0;f"+n+"
                          ").get(0):n instanceof t&&(n=t("
                          ").append(n).get(0)),t("
                          ").append(s.clean_node(n)).html()}});return u}),define("contenthandler/blockelementcontenthandler",["aloha","jquery","aloha/contenthandlermanager"],function(e,t,n){var r={h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,p:!0,pre:!0,blockquote:!0,H1:!0,H2:!0,H3:!0,H4:!0,H5:!0,H6:!0,P:!0,PRE:!0,BLOCKQUOTE:!0},i={br:!0,BR:!0},s=function(e){return r[e.nodeName]&&(!e.lastChild||!i[e.lastChild.nodeName])},o=function(e,n){var r=t(n);r.filter("h1:empty,h2:empty,h3:empty,h4:empty,h5:empty,h6:empty,p:empty,pre:empty,blockquote:empty").remove(),t.browser.msie?r.filter("br.aloha-end-br").remove():r.filter("li").each(function(){s(this)&&t(this).append("
                          ")}),r.children(":not(.aloha-block)").each(o)},u=function(e,n){var r=t(n);r.filter("h1:empty,h2:empty,h3:empty,h4:empty,h5:empty,h6:empty,p:empty,pre:empty,blockquote:empty").append("​"),r.children(":not(.aloha-block)").each(u)},a=function(e,n){var r=t(n);r.filter("p,h1,h2,h3,h4,h5,h6,pre,blockquote").length>0&&s(n)&&t(n).append("
                          "),r.children(":not(.aloha-block)").each(a)},f=n.createHandler({handleContent:function(e,n){return typeof e=="string"?e=t("
                          "+e+"
                          "):e instanceof t&&(e=t("
                          ").append(e)),n=n||{},n.command==="initEditable"?(e.children(":not(.aloha-block)").each(o),t.browser.msie&&t.browser.version<=7&&e.children(":not(.aloha-block)").each(u)):n.command==="getContents"&&(e.children(":not(.aloha-block)").each(a),e.find("li>br:last").remove()),e.html()}});return f}),define("contenthandler/contenthandler-plugin",["aloha","aloha/plugin","jquery","aloha/contenthandlermanager","contenthandler/wordcontenthandler","contenthandler/genericcontenthandler","contenthandler/oembedcontenthandler","contenthandler/sanitizecontenthandler","contenthandler/blockelementcontenthandler"],function(e,t,n,r,i,s,o,u,a){var f=t.create("contenthandler",{settings:{},dependencies:[],init:function(){var e={word:i,generic:s,sanitize:u,blockelement:a},t;for(t in e)e.hasOwnProperty(t)&&r.register(t,e[t])}});return f}),define("commands/inserthtml",["aloha/core","jquery","aloha/command","aloha/selection","util/dom","aloha/contenthandlermanager","aloha/console"],function(e,t,n,r,i,s,o){n.register("inserthtml",{action:function(n,r){function h(e){var n=t(e),s;if(!i.insertIntoDOM(n,r,u,!1)){s=n.contents(),(i.isBlockLevelElement(e)||i.isListElement(e))&&h(t("
                          ").get(0));for(f=s.length-1;f>=0;--f)h(s[f])}}var u=t(i.getEditingHostOf(r.startContainer)),a=r.commonAncestorContainer,f,l,c=[];n=s.handleContent(n,{contenthandler:e.settings.contentHandler.insertHtml});if(typeof n=="string")n=t("
                          "+n+"
                          ");else{if(!(n instanceof t))throw"INVALID_VALUE_ERR";n=t("
                          ").append(n)}c=n.contents(),i.removeRange(r);for(f=c.length-1;f>=0;--f)h(c[f]);c.length>0?r=i.setCursorAfter(c.get(c.length-1)):r.select(),i.doCleanup({merge:!0,removeempty:!0},r,a);try{r.select()}catch(p){o.warn("Error:",p)}}})}),define("commands/commands-plugin",["aloha/command","./inserthtml"],function(e,t){}),define("block/blockmanager",["aloha","jquery","ui/scopes","aloha/observable","aloha/registry","util/class","util/strings","util/maps"],function(e,t,n,r,i,s,o,u){var a=window.GENTICS,f=new(s.extend(r,{defaults:{"aloha-block-type":"DefaultBlock"},blockTypes:null,blocks:null,_highlightedBlocks:null,_activeBlock:null,_dragdropEnabled:!0,_constructor:function(){n.createScope("Aloha.Block"),this.blockTypes=new i,this.blocks=new i,this._highlightedBlocks={}},registerEventHandlers:function(){var n=this;this._registerEventHandlersForDeactivatingAlohaBlock(),this._registerEventHandlersForDeterminingCurrentlyActiveBlock(),this._registerEventHandlersForBlockDeletion(),this._registerEventHandlersForCutCopyPaste(),e.bind("aloha-selection-changed",function(e,r,i){if(r&&t(r.getCommonAncestorContainer()).parents(".aloha-block").length>0)return;n._deactivateHighlightedBlocks()})},_registerEventHandlersForDeactivatingAlohaBlock:function(){var e=this;t(document).bind("click",function(n){if(u.isEmpty(e._highlightedBlocks))return;if(t(n.target).closest(".aloha-ui,.aloha-block-do-not-deactivate,.aloha-block").length>0)return;e._deactivateHighlightedBlocks()})},_registerEventHandlersForDeterminingCurrentlyActiveBlock:function(){var e=this;this.bind("block-selection-change",function(t){t.length>0?e._activeBlock=t[0]:e._activeBlock=null})},_registerEventHandlersForBlockDeletion:function(){var n=this;e.bind("aloha-command-will-execute",function(r,i){var s=i.commandId,o=e.getSelection().getRangeCount()===0||e.getSelection().getRangeCount()===1&&e.getSelection().getRangeAt(0).endContainer===e.getSelection().getRangeAt(0).startContainer&&e.getSelection().getRangeAt(0).endContainer===t("body")[0]||e.getSelection().getRangeCount()===1&&e.getSelection().getRangeAt(0).endContainer===e.getSelection().getRangeAt(0).startContainer&&e.getSelection().getRangeAt(0).startOffset+1===e.getSelection().getRangeAt(0).endOffset;if(n._activeBlock&&(s==="delete"||s==="forwarddelete")&&o)i.preventDefault=!0,n._activeBlock.destroy();else if(!n._activeBlock&&(s==="delete"||s==="forwarddelete")&&e.getSelection().getRangeCount()===1&&e.getSelection().getRangeAt(0).collapsed===!1){var u;u=function(e){var n;for(var r=0,i=e.length;r0)},change:function(e,t){t.item.data("block-sort-allowed",t.placeholder.parents(".aloha-block-dropzone").length>0)},stop:function(e,n){n.item.data("block-sort-allowed")||t(this).sortable("cancel"),n.item.removeData("block-sort-allowed")}}),e.get(0).ondragstart=function(e,t){if(!t||!t.helper||!t.helper.is(".aloha-block"))return!1})},setDragDropState:function(e){this._dragdropEnabled=e},getDragDropState:function(){return this._dragdropEnabled},registerBlockType:function(e,t){n.createScope("Aloha.Block."+e,"Aloha.Block"),this.blockTypes.register(e,t)},_blockify:function(n,r){var i=this,s=t(n),o=e.require("block/block-plugin"),u=s[0].tagName.toLowerCase(),a,f;if(t.inArray(u,o.settings.rootTags)===-1){e.Log.error("block/blockmanager","Blocks can only be created from ["+o.settings.rootTags.join(", ")+"]"+"] element. You passed "+u+".");return}a=this.getConfig(s,r);if(!this.blockTypes.has(a["aloha-block-type"])){e.Log.error("block/blockmanager","Block Type "+a["aloha-block-type"]+" not found!");return}f=new(this.blockTypes.get(a["aloha-block-type"]))(s,a),f.$element.addClass("aloha-block-"+a["aloha-block-type"]),this.blocks.register(f.getId(),f)},_unblockify:function(e){var t=this.getBlock(e);t&&t.unblock()},getConfig:function(e,n){var r=e.clone(!0),i=r.data(),s={};r.removeData();for(var u in i)i.hasOwnProperty(u)&&(s[o.camelCaseToDashes(u)]=i[u]);return t.extend({},this.defaults,n,s)},getBlock:function(e){var n,r;return typeof e=="object"?(r=t(e),r.hasClass("aloha-block-inner")&&(r=r.parent()),n=r.attr("id")):n=e,this.blocks.get(n)},_unregisterBlock:function(e){var t;typeof e=="object"?t=e.getId():t=e,this.blocks.unregister(t)},_deactivateHighlightedBlocks:function(){t.each(t.extend({},this._highlightedBlocks),function(e){var t=f.getBlock(e);t&&t.deactivate()})},_getHighlightedBlocks:function(){var e={};return t.each(this.blocks.getEntries(),function(t,n){n.isActive()&&(e[t]=n)}),e},_setHighlighted:function(e){this._highlightedBlocks[e.id]=!0},_setUnhighlighted:function(e){delete this._highlightedBlocks[e.id]}}));return e.Block=e.Block||{},e.Block.BlockManager=f,f}),define("block/editormanager",["aloha/registry"],function(e){return new(e.extend({createEditor:function(e){if(!this.has(e.type))throw'Editor for type "'+e.type+'" not found.';var t=this.get(e.type);return new t(e)}}))}),define("block/sidebarattributeeditor",["jquery","block/blockmanager","aloha/sidebar","block/editormanager","util/class"],function(e,t,n,r,i){return new(i.extend({_sidebar:null,init:function(){this._sidebar=n.right.show(),t.bind("block-selection-change",this._onBlockSelectionChange,this)},_onBlockSelectionChange:function(t){var n=this;if(!this._sidebar)return;e.each(t,function(){var t=this.getSchema(),i=this,s=[];if(!t)return;n._sidebar.addPanel({title:i.getTitle(),expanded:!0,onInit:function(){var n=e("
                          ");n.submit(function(){return!1}),e.each(t,function(e,t){var o=r.createEditor(t);o.bind("change",function(t){i.attr(e,t)}),i.bind("change",function(){o.setValue(i.attr(e))}),n.append(o.render()),o.setValue(i.attr(e)),s.push(o)}),this.setContent(n)},deactivate:function(){e.each(s,function(e,t){t._deactivate()}),this.isActive=!1,this.effectiveElement=null}})})}}))}),define("block/block",["aloha","jquery","block/blockmanager","aloha/observable","ui/scopes","util/class","PubSub"],function(e,t,n,r,i,s,o){function h(e){var t=e.closest(".aloha-editable");return t.length?!!t.data("block-dragdrop"):!0}var u=window.GENTICS,a=s.extend(r,{title:null,id:null,$element:null,_currentlyRendering:!1,_initialized:!1,_isInsideNestedEditable:!1,_constructor:function(e,n){var r=this;this.$element=e,e.attr("id")?this.id=e.attr("id"):(this.id=u.Utils.guid(),e.attr("id",this.id)),e.contentEditable(!1),e.addClass("aloha-block"),this.isDraggable()&&(e.find("img").attr("draggable","false"),e.find("a").attr("draggable","false")),t.each(n,function(e,t){r._setAttribute(e,t)}),this._onElementClickHandler=function(e){t(e.target).closest(".aloha-block").get(0)===r.$element.get(0)&&(r._fixScrollPositionBugsInIE(),r.activate(e.target,e))},this._connectThisBlockToDomElement(e,function(){o.pub("aloha.block.initialized",{block:r})}),this._initialized=!0},_onElementClickHandler:null,_preventSelectionChangedEventHandler:function(){e.Selection.preventSelectionChanged()},_connectThisBlockToDomElement:function(e,n){var r=this,i=t(e);this._disconnectFromDomElement(),this.$element=i,this.$element.bind("click",this._onElementClickHandler),this.$element.bind("mousedown",this._preventSelectionChangedEventHandler),this.$element.bind("focus",this._preventSelectionChangedEventHandler),this.$element.bind("dblclick",this._preventSelectionChangedEventHandler),this.init(this.$element,function(){window.setTimeout(function(){r._postProcessElementIfNeeded(),n&&n()},5)})},_disconnectFromDomElement:function(){this.$element&&(this.$element.unbind("click",this._onElementClickHandler),this.$element.unbind("mousedown",this._preventSelectionChangedEventHandler),this.$element.unbind("focus",this._preventSelectionChangedEventHandler),this.$element.unbind("dblclick",this._preventSelectionChangedEventHandler))},_fixScrollPositionBugsInIE:function(){var e=t(window).scrollTop();window.setTimeout(function(){t(window).scrollTop()!==e&&t(window).scrollTop(e)},10)},init:function(e,t){t()},shouldDestroy:function(){var e=this.$element.parent().closest(".aloha-block,.aloha-editable,.aloha-block-collection");return e.hasClass("aloha-block-collection")&&this.$element[0].tagName.toLowerCase()==="div"?!0:e.hasClass("aloha-editable")},destroy:function(e){if(!this.shouldDestroy()&&e!==!0)return;var t=this,r=new u.Utils.RangeObject;r.startContainer=r.endContainer=this.$element.parent()[0],r.startOffset=r.endOffset=u.Utils.Dom.getIndexInParent(this.$element[0]),n.trigger("block-delete",this),this.free();var i=this.$element[0].tagName.toLowerCase()==="span";this.$element.fadeOut("fast",function(){t.$element.remove(),n.trigger("block-selection-change",[]),window.setTimeout(function(){i&&r.select()},5)})},unblock:function(){this.deactivate(),this._disconnectFromDomElement(),this.$element.removeClass("aloha-block"),this.$element.children(".aloha-block-handle").remove(),this.free()},free:function(){n._unregisterBlock(this),this.unbindAll()},getId:function(){return this.id},getSchema:function(){return null},getTitle:function(){return this.title},isDraggable:function(){return this.$element[0].tagName.toLowerCase()==="div"&&this.$element.parents(".aloha-editable,.aloha-block,.aloha-block-collection").first().hasClass("aloha-block-collection")?!0:this.$element.parents(".aloha-editable,.aloha-block").first().hasClass("aloha-editable")},activate:function(r,s){var o=[];t.each(n._getHighlightedBlocks(),function(){this.deactivate()}),this.$element.attr("data-block-skip-scope")!=="true"&&i.setScope("Aloha.Block."+this.attr("aloha-block-type")),this.$element.addClass("aloha-block-active"),this._highlight(),o.push(this),this.$element.parents(".aloha-block").each(function(){var e=n.getBlock(this);e&&(e._highlight(),o.push(e))}),t(r).closest(".aloha-editable,.aloha-block,.aloha-table-cell-editable").first().hasClass("aloha-block")?(this._isInsideNestedEditable=!1,e.getSelection().removeAllRanges()):(this._isInsideNestedEditable=!0,s&&e.Selection.updateSelection(s)),n.trigger("block-activate",o),n.trigger("block-selection-change",o)},deactivate:function(){var e=this,t=[this];this._unhighlight(),this.$element.parents(".aloha-block").each(function(){t.push(this),e._unhighlight()}),this.$element.removeClass("aloha-block-active"),n.trigger("block-deactivate",t),n.trigger("block-selection-change",[])},isActive:function(){return this.$element.hasClass("aloha-block-active")},_highlight:function(){this.$element.addClass("aloha-block-highlighted"),n._setHighlighted(this)},_unhighlight:function(){this.$element.removeClass("aloha-block-highlighted"),n._setUnhighlighted(this)},_update:function(){var e=this;if(this._currentlyRendering)return;if(!this._initialized)return;this._currentlyRendering=!0,this.update(this.$element,function(){e._postProcessElementIfNeeded()}),this._currentlyRendering=!1},update:function(e,t){t()},_postProcessElementIfNeeded:function(){this.createEditablesIfNeeded(),this._checkThatNestedBlocksAreStillConsistent(),this._makeNestedBlockCollectionsSortable(),this.renderBlockHandlesIfNeeded(),this.isDraggable()&&this.$element[0].tagName.toLowerCase()==="span"?(this._setupDragDropForInlineElements(),this._disableUglyInternetExplorerDragHandles()):this.isDraggable()&&this.$element[0].tagName.toLowerCase()==="div"&&(this._setupDragDropForBlockElements(),this._disableUglyInternetExplorerDragHandles()),this._hideDragHandlesIfDragDropDisabled(),this._attachDropzoneHighlightEvents()},_checkThatNestedBlocksAreStillConsistent:function(){this.$element.find(".aloha-block").each(function(){var e=n.getBlock(this);e&&e.$element[0]!==this&&e._connectThisBlockToDomElement(this)})},_makeNestedBlockCollectionsSortable:function(){var e=this;this.$element.find(".aloha-block-collection").each(function(){var r=t(this);r.closest(".aloha-block").get(0)===e.$element.get(0)&&n.createBlockLevelSortableForEditableOrBlockCollection(r)})},_disableUglyInternetExplorerDragHandles:function(){t.browser.msie&&(this.$element.get(0).onresizestart=function(e){return!1},this.$element.get(0).oncontrolselect=function(e){return!1},this.$element.get(0).onmovestart=function(e){return!1})},_hideDragHandlesIfDragDropDisabled:function(){this._dd_isDragdropEnabled()||this.$element.find(".aloha-block-draghandle").each(function(){var e=t(this);h(e)||e.removeClass("aloha-block-draghandle")})},_attachDropzoneHighlightEvents:function(){var e=this;this.$element.delegate(".aloha-block-draghandle","mousedown",function(){var n=e.$element.parents(".aloha-editable").first().data("block-dropzones")||[];t.each(n,function(e,n){var r=t(n);t(r).each(function(){t(this).data("block-dragdrop")&&t(this).addClass("aloha-block-dropzone")})}),t(document).one("mouseup.aloha-block-dropzone",function(n){var r=e.$element.parents(".aloha-editable").first().data("block-dropzones")||[];t.each(r,function(e,n){t(n).removeClass("aloha-block-dropzone")})})})},_setupDragDropForInlineElements:function(){var e=this,n=null,r=!1,i=null,s=null,o=function(){if(n){var o=t(n);o.is(".aloha-block-dropInlineElementIntoEmptyBlock")?(o.children().remove(),o.append(i)):o.is(".aloha-block-droppable-right")?(o.html(o.html()+" "),o.after(i)):(o.prev("[data-i]").length>0&&o.prev("[data-i]").html(o.prev("[data-i]").html()+" "),o.html(" "+o.html()),o.before(i)),i.removeClass("ui-draggable").css({left:0,top:0}),e._fixScrollPositionBugsInIE()}t(".aloha-block-dropInlineElementIntoEmptyBlock").removeClass("aloha-block-dropInlineElementIntoEmptyBlock"),s.droppable("destroy"),s=null,r=!0},u=[];this.$element.draggable({handle:".aloha-block-draghandle",scope:"aloha-block-inlinedragdrop",disabled:!this._dd_isDragdropEnabled(),revert:function(){return n===null||!r},revertDuration:250,stop:function(){t.browser.msie&&7===parseInt(t.browser.version,10)&&o(),t.each(u,function(){e._dd_traverseDomTreeAndRemoveSpans(this)}),i=null,u=[]},start:function(){r=!1,u=[],t(".aloha-editable").children("p:empty").html(" ");var a={tolerance:"pointer",addClasses:!1,scope:"aloha-block-inlinedragdrop",over:function(r,s){t.inArray(this,u)===-1&&u.push(this);var o=1===t(this).contents().length&&1===t(this).children("br").length;i=s.draggable;if(t(this).is(":empty")||o||t(this).html()===" "){t(this).addClass("aloha-block-dropInlineElementIntoEmptyBlock"),n=this;return}e._dd_traverseDomTreeAndWrapCharactersWithSpans(this),t("span[data-i]",this).droppable({tolerance:"pointer",addClasses:!1,scope:"aloha-block-inlinedragdrop",over:function(){n&&t(n).removeClass("aloha-block-droppable"),n=this,t(this).addClass("aloha-block-droppable")},out:function(){t(this).removeClass("aloha-block-droppable"),n===this&&(n=null)}}),t.ui.ddmanager.prepareOffsets(s.draggable.data("draggable"),r)},out:function(){t(this).removeClass("aloha-block-dropInlineElementIntoEmptyBlock")},drop:function(){(!t.browser.msie||7!==parseInt(t.browser.version,10))&&o()}};s=t(".aloha-editable.aloha-block-dropzone").children(":not(.aloha-block)"),s.droppable(a),t(".aloha-table-cell-editable").droppable(a)}})},_dd_traverseDomTreeAndWrapCharactersWithSpans:function(e){var t;for(var n=0,r=e.childNodes.length;n0&&(o=document.createElement("span"),o.appendChild(document.createTextNode(u.substr(0,a))),o.setAttribute("data-i",c),r.appendChild(o),l++),o=document.createElement("span"),f=u.substr(a),o.appendChild(document.createTextNode(f)),o.setAttribute("data-i",c),o.setAttribute("class","aloha-block-droppable-right"),r.appendChild(o),l++}return e.parentNode.replaceChild(r,e),l-1},_dd_traverseDomTreeAndRemoveSpans:function(e){var t=[],n;n=function(e){var r=!1,i,s,o;for(var u=0,a=e.childNodes.length;u')},attr:function(n,r,i){var s=this,o=!1;if(arguments.length>=2){if(n.substr(0,12)==="aloha-block-"){e.Log.error("block/block","It is not allowed to set internal block attributes (starting with aloha-block-) through Block.attr() (You tried to set "+n+")");return}this._getAttribute(n)!==r&&(o=!0),this._setAttribute(n,r)}else{if(typeof n!="object")return typeof n=="string"?this._getAttribute(n):this._getAttributes();t.each(n,function(t,n){if(t.substr(0,12)==="aloha-block-"){e.Log.error("block/block","It is not allowed to set internal block attributes (starting with aloha-block-) through Block.attr() (You tried to set "+t+")");return}s._getAttribute(t)!==n&&(o=!0),s._setAttribute(t,n)})}return o&&!i&&(this._update(),this.trigger("change"),e.activeEditable.smartContentChange({type:"block-change"})),null},_setAttribute:function(e,t){this.$element.attr("data-"+e.toLowerCase(),t)},_getAttribute:function(e){return this.$element.attr("data-"+e.toLowerCase())},_getAttributes:function(){var e={};return t.each(this.$element[0].attributes,function(t,n){n.name.substr(0,5)==="data-"&&(e[n.name.substr(5).toLowerCase()]=n.value)}),e}}),f=a.extend({update:function(e,t){t()}}),l=a.extend({title:"Debugging",init:function(e,t){this.update(e,t)},update:function(e,n){e.css({display:"block"});var r='';t.each(this.attr(),function(e,t){r+=""}),r+="
                          "+e+""+t+"
                          ",e.html(r),n()}}),c=a.extend({title:"EmptyBlock",init:function(){},activate:function(){},deactivate:function(){},renderBlockHandlesIfNeeded:function(){}});return{AbstractBlock:a,DefaultBlock:f,DebugBlock:l,EmptyBlock:c}}),define("block/blockcontenthandler",["jquery","aloha/contenthandlermanager","block/blockmanager"],function(e,t,n){var r=t.createHandler({handleContent:function(t){return typeof t=="string"?t=e("
                          "+t+"
                          "):t instanceof e&&(t=e("
                          ").append(t)),t.find('.aloha-block[data-aloha-block-copy-only-block="true"]').length>0&&(t.find(".aloha-block:not([id])").remove(),t.find(".aloha-block + span:empty").remove(),t.find("div:empty").remove(),t.find("br.Apple-interchange-newline").remove(),t.find(".aloha-block").prev("br").remove(),t.find("div > br:only-child").parent().remove()),t.find(".aloha-block").each(function(){var t=e(this),r={},i={};e.each(t[0].attributes,function(e,t){if(t.nodeName==="id")return;t.nodeName.match(/^data-/)?i[t.nodeName.substr(5)]=t.nodeValue:r[t.nodeName]=t.nodeValue});var s=GENTICS.Utils.guid(),o=e("<"+this.tagName+"/>").attr(r).attr("id",s).removeClass("aloha-block-active").removeClass("aloha-block").html(t.html());t.replaceWith(o),window.setTimeout(function(){n._blockify(e("#"+s),i)},50)}),t.html()}});return r}),define("block/editor",["jquery","aloha/observable","util/class"],function(e,t,n){var r=n.extend(t,{schema:null,_constructor:function(e){this.schema=e},render:function(){},getValue:function(){},setValue:function(e){},destroy:function(){},_deactivate:function(){this.trigger("change",this.getValue()),this.destroy()}}),i=r.extend({formInputElementDefinition:null,_$formInputElement:null,render:function(){var t=e('
                          '),n=GENTICS.Utils.guid();return t.append(this.renderLabel().attr("id",n)),t.append(this.renderFormElement().attr("id",n)),t},renderLabel:function(){var t=e("