/* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ jQuery.fn.between=function(content,offset){if(this[0].nodeType!==3){if(offset>this.children().size()){offset=this.children().size()}if(offset<=0){this.prepend(content)}else{this.children().eq(offset-1).after(content)}}else{if(offset<=0){this.before(content)}else{if(offset>=this[0].length){this.after(content)}else{var fullText=this[0].data;this[0].data=fullText.substring(0,offset);this.after(fullText.substring(offset,fullText.length));this.after(content)}}}}; /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS){GENTICS.Utils={}}GENTICS.Utils.applyProperties=function(target,properties){var name;for(name in properties){if(properties.hasOwnProperty(name)){target[name]=properties[name]}}}; /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS){GENTICS.Utils={}}GENTICS.Utils.RangeObject=function(param){this.startContainer;this.startOffset;this.endContainer;this.endOffset;this.startParents=[];this.endParents=[];this.rangeTree=[];if(typeof param==="object"){if(param.startContainer!==undefined){this.startContainer=param.startContainer}if(param.startOffset!==undefined){this.startOffset=param.startOffset}if(param.endContainer!==undefined){this.endContainer=param.endContainer}if(param.endOffset!==undefined){this.endOffset=param.endOffset}}else{if(param===true){this.initializeFromUserSelection()}}};GENTICS.Utils.RangeObject.prototype.log=function(message,obj){if(GENTICS&&GENTICS.Aloha&&GENTICS.Aloha.Log){GENTICS.Aloha.Log.debug(this,message);return false}if(console){console.log(message);if(obj){console.log(obj)}}};GENTICS.Utils.RangeObject.prototype.isCollapsed=function(){return(!this.endContainer||(this.startContainer===this.endContainer&&this.startOffset===this.endOffset))};GENTICS.Utils.RangeObject.prototype.getCommonAncestorContainer=function(){if(this.commonAncestorContainer){return this.commonAncestorContainer}this.updateCommonAncestorContainer();return this.commonAncestorContainer};GENTICS.Utils.RangeObject.prototype.getContainerParents=function(limit,fromEnd){var container=fromEnd?this.endContainer:this.startContainer;var parentStore=fromEnd?this.endParents:this.startParents;if(!container){return false}if(typeof limit=="undefined"){limit=jQuery("body")}if(!parentStore[limit.get(0)]){var parents;if(container.nodeType==3){parents=jQuery(container).parents()}else{parents=jQuery(container).parents();for(var i=parents.length;i>0;--i){parents[i]=parents[i-1]}parents[0]=container}var limitIndex=parents.index(limit);if(limitIndex>=0){parents=parents.slice(0,limitIndex)}parentStore[limit.get(0)]=parents}return parentStore[limit.get(0)]};GENTICS.Utils.RangeObject.prototype.getStartContainerParents=function(limit){return this.getContainerParents(limit,false)};GENTICS.Utils.RangeObject.prototype.getEndContainerParents=function(limit){return this.getContainerParents(limit,true)};GENTICS.Utils.RangeObject.prototype.updateCommonAncestorContainer=function(commonAncestorContainer){var parentsStartContainer=this.getStartContainerParents();var parentsEndContainer=this.getEndContainerParents();if(!commonAncestorContainer){if(!(parentsStartContainer.length>0&&parentsEndContainer.length>0)){GENTICS.Utils.RangeObject.prototype.log("could not find commonAncestorContainer");return false}for(var i=0;i");if(this.endContainer===this.startContainer.parentNode&&GENTICS.Utils.Dom.getIndexInParent(this.startContainer)0){checkElement=container.childNodes[offset-1]}}while(checkElement&&checkElement.nodeType==3){characters+=checkElement.data.length;checkElement=checkElement.previousSibling}return{element:checkElement,characters:characters}};GENTICS.Utils.RangeObject.prototype.searchElementToRight=function(container,offset){var checkElement=undefined;var characters=0;if(container.nodeType==3){characters=container.data.length-offset;checkElement=container.nextSibling}else{if(offset0&&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){var adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer,this.startOffset,true);if(adjacentTextNode){this.startContainer=this.endContainer=adjacentTextNode;this.startOffset=this.endOffset=adjacentTextNode.data.length;return}adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer,this.startOffset,false);if(adjacentTextNode){this.startContainer=this.endContainer=adjacentTextNode;this.startOffset=this.endOffset=0;return}}if(this.startOffset0){checkedElement=checkedElement.childNodes[0];if(checkedElement.nodeType==3){textNode=checkedElement}}if(textNode!==false){this.startContainer=textNode;this.startOffset=0}}}}if(this.startContainer.nodeType==3&&this.startOffset==this.startContainer.data.length){var adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer.parentNode,GENTICS.Utils.Dom.getIndexInParent(this.startContainer)+1,false);if(adjacentTextNode){this.startContainer=adjacentTextNode;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){var parentNode=this.endContainer.parentNode;for(var offset=0;offset0){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){var textNode=false;var checkedElement=this.endContainer.childNodes[this.endOffset-1];while(textNode===false&&checkedElement.childNodes&&checkedElement.childNodes.length>0){checkedElement=checkedElement.childNodes[checkedElement.childNodes.length-1];if(checkedElement.nodeType==3){textNode=checkedElement}}if(textNode!==false){this.endContainer=textNode;this.endOffset=this.endContainer.data.length}}}}}};GENTICS.Utils.RangeObject.prototype.clearCaches=function(){this.rangeTree=[];this.startParents=[];this.endParents=[];this.commonAncestorContainer=undefined};GENTICS.Utils.RangeObject.prototype.getRangeTree=function(root){if(typeof root=="undefined"){root=this.getCommonAncestorContainer()}if(this.rangeTree[root]){return this.rangeTree[root]}this.inselection=false;this.rangeTree[root]=this.recursiveGetRangeTree(root);return this.rangeTree[root]};GENTICS.Utils.RangeObject.prototype.recursiveGetRangeTree=function(currentObject){var jQueryCurrentObject=jQuery(currentObject);var childCount=0;var that=this;var currentElements=new Array();jQueryCurrentObject.contents().each(function(index){var type="none";var startOffset=false;var endOffset=false;var collapsedFound=false;if(that.isCollapsed()&¤tObject===that.startContainer&&that.startOffset==index){currentElements[childCount]=new GENTICS.Utils.RangeTree();currentElements[childCount].type="collapsed";currentElements[childCount].domobj=undefined;that.inselection=false;collapsedFound=true;childCount++}if(!that.inselection&&!collapsedFound){switch(this.nodeType){case 3:if(this===that.startContainer){that.inselection=true;type=that.startOffset>0?"partial":"full";startOffset=that.startOffset;endOffset=this.length}break;case 1:if(this===that.startContainer&&that.startOffset==0){that.inselection=true;type="full"}if(currentObject===that.startContainer&&that.startOffset==index){that.inselection=true;type="full"}break}}if(that.inselection&&!collapsedFound){if(type=="none"){type="full"}switch(this.nodeType){case 3:if(this===that.endContainer){that.inselection=false;if(that.endOffset0){var noneFound=false;var partialFound=false;var fullFound=false;for(var i=0;i0){path=parents.slice(0,index)}return false}});if(!path){return}path=path.reverse();var newDom;var insertElement;for(var i=0;i=0){return true}if(jQuery.isArray(this.tags[this.children[outerNodeName]])&&jQuery.inArray(innerNodeName,this.tags[this.children[outerNodeName]])>=0){return true}return false};GENTICS.Utils.Dom.prototype.addMarkup=function(rangeObject,markup,nesting){if(rangeObject.startContainer.nodeType==3&&rangeObject.startOffset>0&&rangeObject.startOffset0&&rangeObject.endOffset0){this.recursiveAddMarkup(rangeTree[i].children,markup)}}}}}};GENTICS.Utils.Dom.prototype.findHighestElement=function(start,nodeName,limit){var testObject=start;nodeName=nodeName.toLowerCase();var isLimit=limit?function(){return limit.filter(function(){return testObject==this}).length}:function(){return false};var highestObject=undefined;while(!isLimit()&&testObject){if(testObject.nodeName.toLowerCase()==nodeName){highestObject=testObject}testObject=testObject.parentNode}return highestObject};GENTICS.Utils.Dom.prototype.removeMarkup=function(rangeObject,markup,limit){var nodeName=markup.get(0).nodeName;var startSplitLimit=this.findHighestElement(rangeObject.startContainer,nodeName,limit);var endSplitLimit=this.findHighestElement(rangeObject.endContainer,nodeName,limit);var didSplit=false;if(startSplitLimit){this.split(rangeObject,jQuery(startSplitLimit).parent(),false);didSplit=true}if(endSplitLimit){this.split(rangeObject,jQuery(endSplitLimit).parent(),true);didSplit=true}if(didSplit){rangeObject.correctRange()}var highestObject=this.findHighestElement(rangeObject.getCommonAncestorContainer(),nodeName,limit);var root=highestObject?highestObject.parentNode:undefined;var rangeTree=rangeObject.getRangeTree(root);this.recursiveRemoveMarkup(rangeTree,markup);this.doCleanup({merge:true,removeempty:true},rangeObject,root)};GENTICS.Utils.Dom.prototype.recursiveRemoveMarkup=function(rangeTree,markup){for(var i=0;i0){content.first().unwrap()}else{jQuery(rangeTree[i].domobj).remove()}}if(rangeTree[i].children){this.recursiveRemoveMarkup(rangeTree[i].children,markup)}}};GENTICS.Utils.Dom.prototype.doCleanup=function(cleanup,rangeObject,start){var that=this;if(typeof cleanup=="undefined"){cleanup={merge:true,removeempty:true}}if(typeof start=="undefined"){if(rangeObject){start=rangeObject.getCommonAncestorContainer()}}var prevNode=false;var modifiedRange=false;var startObject=jQuery(start);startObject.contents().each(function(index){switch(this.nodeType){case 1:if(prevNode&&prevNode.nodeName==this.nodeName){if(rangeObject.startContainer===startObject&&rangeObject.startOffset>index){rangeObject.startOffset-=1;modifiedRange=true}if(rangeObject.endContainer===startObject&&rangeObject.endOffset>index){rangeObject.endOffset-=1;modifiedRange=true}jQuery(prevNode).append(jQuery(this).contents());modifiedRange|=that.doCleanup(cleanup,rangeObject,prevNode);jQuery(this).remove()}else{modifiedRange|=that.doCleanup(cleanup,rangeObject,this);var removed=false;if(cleanup.removeempty){if(GENTICS.Utils.Dom.isBlockLevelElement(this)&&this.childNodes.length==0){jQuery(this).remove();removed=true}if(jQuery.inArray(this.nodeName.toLowerCase(),that.mergeableTags)>=0&&jQuery(this).text().length==0){jQuery(this).remove();removed=true}}if(!removed){if(jQuery.inArray(this.nodeName.toLowerCase(),that.mergeableTags)>=0){prevNode=this}else{prevNode=false}}}break;case 3:if(prevNode&&prevNode.nodeType==3&&cleanup.merge){if(rangeObject.startContainer===this){rangeObject.startContainer=prevNode;rangeObject.startOffset+=prevNode.length;modifiedRange=true}if(rangeObject.endContainer===this){rangeObject.endContainer=prevNode;rangeObject.endOffset+=prevNode.length;modifiedRange=true}if(rangeObject.startContainer===startObject&&rangeObject.startOffset>index){rangeObject.startOffset-=1;modifiedRange=true}if(rangeObject.endContainer===startObject&&rangeObject.endOffset>index){rangeObject.endOffset-=1;modifiedRange=true}prevNode.data+=this.data;jQuery(this).remove()}else{prevNode=this}break}});if(cleanup.removeempty&&GENTICS.Utils.Dom.isBlockLevelElement(start)&&(!start.childNodes||start.childNodes.length==0)){if(rangeObject.startContainer==start){rangeObject.startContainer=start.parentNode;rangeObject.startOffset=GENTICS.Utils.Dom.getIndexInParent(start)}if(rangeObject.endContainer==start){rangeObject.endContainer=start.parentNode;rangeObject.endOffset=GENTICS.Utils.Dom.getIndexInParent(start)}startObject.remove();modifiedRange=true}if(modifiedRange){rangeObject.clearCaches()}return modifiedRange};GENTICS.Utils.Dom.prototype.getIndexInParent=function(node){if(!node){return false}var index=0;var check=node.previousSibling;while(check){index++;check=check.previousSibling}return index};GENTICS.Utils.Dom.prototype.isBlockLevelElement=function(node){if(!node){return false}if(node.nodeType==1&&jQuery.inArray(node.nodeName.toLowerCase(),this.blockLevelElements)>=0){return true}else{return false}};GENTICS.Utils.Dom.prototype.isLineBreakElement=function(node){if(!node){return false}return node.nodeType==1&&node.nodeName.toLowerCase()=="br"};GENTICS.Utils.Dom.prototype.isListElement=function(node){if(!node){return false}return node.nodeType==1&&jQuery.inArray(node.nodeName.toLowerCase(),this.listElements)>=0};GENTICS.Utils.Dom.prototype.isSplitObject=function(el){if(el.nodeType===1){switch(el.nodeName.toLowerCase()){case"p":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"li":return true}}return false};GENTICS.Utils.Dom.prototype.searchAdjacentTextNode=function(parent,index,searchleft,stopat){if(!parent||parent.nodeType!=1||index<0||index>parent.childNodes.length){return false}if(typeof stopat=="undefined"){stopat={blocklevel:true,list:true,linebreak:true}}if(stopat.blocklevel=="undefined"){stopal.blocklevel=true}if(stopat.list=="undefined"){stopal.list=true}if(stopat.linebreak=="undefined"){stopal.linebreak=true}if(typeof searchleft=="undefined"){searchleft=true}var nextNode=undefined;var currentParent=parent;if(searchleft&&index>0){nextNode=parent.childNodes[index-1]}if(!searchleft&&index0){return nextNode}else{if(stopat.blocklevel&&this.isBlockLevelElement(nextNode)){return false}else{if(stopat.linebreak&&this.isLineBreakElement(nextNode)){return false}else{if(stopat.list&&this.isListElement(nextNode)){return false}else{if(nextNode.nodeType==3){nextNode=searchleft?nextNode.previousSibling:nextNode.nextSibling}else{currentParent=nextNode;nextNode=searchleft?nextNode.lastChild:nextNode.firstChild}}}}}}}};GENTICS.Utils.Dom.prototype.insertIntoDOM=function(object,range,limit,atEnd){var parentElements=range.getContainerParents(limit,atEnd);var that=this;var newParent;if(!limit){limit=jQuery(document.body)}if(parentElements.length==0){newParent=limit.get(0)}else{jQuery.each(parentElements,function(index,parent){if(that.allowsNesting(parent,object.get(0))){newParent=parent;return false}})}if(typeof newParent=="undefined"&&limit.length>0){newParent=limit.get(0)}if(typeof newParent!="undefined"){var splitParts=this.split(range,jQuery(newParent),atEnd);if(splitParts){splitParts.eq(0).after(object);return true}else{return false}}else{return false}};GENTICS.Utils.Dom.prototype.removeFromDOM=function(object,range,preserveContent){if(preserveContent){var indexInParent=this.getIndexInParent(object);var numChildren=jQuery(object).contents().length;var parent=object.parentNode;if(range.startContainer==parent&&range.startOffset>indexInParent){range.startOffset+=numChildren-1}else{if(range.startContainer==object){range.startContainer=parent;range.startOffset=indexInParent+range.startOffset}}if(range.endContainer==parent&&range.endOffset>indexInParent){range.endOffset+=numChildren-1}else{if(range.endContainer==object){range.endContainer=parent;range.endOffset=indexInParent+range.endOffset}}jQuery(object).contents().unwrap();this.doCleanup({merge:true},range,parent)}else{}};GENTICS.Utils.Dom.prototype.extendToWord=function(range,fromBoundaries){var leftBoundary=this.searchWordBoundary(range.startContainer,range.startOffset,true);var rightBoundary=this.searchWordBoundary(range.endContainer,range.endOffset,false);if(!fromBoundaries){if(range.startContainer==leftBoundary.container&&range.startOffset==leftBoundary.offset){return}if(range.endContainer==rightBoundary.container&&range.endOffset==rightBoundary.offset){return}}range.startContainer=leftBoundary.container;range.startOffset=leftBoundary.offset;range.endContainer=rightBoundary.container;range.endOffset=rightBoundary.offset;range.correctRange();range.clearCaches()};GENTICS.Utils.Dom.prototype.isWordBoundaryElement=function(object){if(!object||!object.nodeName){return false}return jQuery.inArray(object.nodeName.toLowerCase(),this.nonWordBoundaryTags)==-1};GENTICS.Utils.Dom.prototype.searchWordBoundary=function(container,offset,searchleft){if(typeof searchleft=="undefined"){searchleft=true}var boundaryFound=false;while(!boundaryFound){if(container.nodeType==3){if(!searchleft){var wordBoundaryPos=container.data.substring(offset).search(/\W/);if(wordBoundaryPos!=-1){offset=offset+wordBoundaryPos;boundaryFound=true}else{offset=this.getIndexInParent(container)+1;container=container.parentNode}}else{var wordBoundaryPos=container.data.substring(0,offset).search(/\W/);var tempWordBoundaryPos=wordBoundaryPos;while(tempWordBoundaryPos!=-1){wordBoundaryPos=tempWordBoundaryPos;tempWordBoundaryPos=container.data.substring(wordBoundaryPos+1,offset).search(/\W/);if(tempWordBoundaryPos!=-1){tempWordBoundaryPos=tempWordBoundaryPos+wordBoundaryPos+1}}if(wordBoundaryPos!=-1){offset=wordBoundaryPos+1;boundaryFound=true}else{offset=this.getIndexInParent(container);container=container.parentNode}}}else{if(container.nodeType==1){if(!searchleft){if(offset0){if(this.isWordBoundaryElement(container.childNodes[offset-1])){boundaryFound=true}else{container=container.childNodes[offset-1];offset=container.nodeType==3?container.data.length:container.childNodes.length}}else{if(this.isWordBoundaryElement(container)){boundaryFound=true}else{offset=this.getIndexInParent(container);container=container.parentNode}}}}}}if(container.nodeType!=3){var textNode=this.searchAdjacentTextNode(container,offset,!searchleft);if(textNode){container=textNode;offset=searchleft?0:container.data.length}}return{container:container,offset:offset}};GENTICS.Utils.Dom.prototype.isEmpty=function(domObject){if(!domObject){return true}if(jQuery.inArray(domObject.nodeName.toLowerCase(),this.nonEmptyTags)!=-1){return false}if(domObject.nodeType==3){return domObject.data.search(/\S/)==-1}for(var i=0;i=0;i--){if(/\S/.test(str.charAt(i))){str=str.substring(0,i+1);break}}return str};GENTICS.Aloha.prototype.initI18n=function(){if(typeof this.settings.i18n=="undefined"||!this.settings.i18n){this.settings.i18n={}}if(typeof this.settings.i18n.available=="undefined"||!this.settings.i18n.available||!this.settings.i18n.available instanceof Array){this.settings.i18n.available=["en","de","fr","eo","fi","ru","it"]}if((typeof this.settings.i18n.current=="undefined"||!this.settings.i18n.current)&&typeof this.settings.i18n.acceptLanguage=="string"){var acceptLanguage=[];var preferredLanugage=this.settings.i18n.acceptLanguage.split(",");for(i=0;i=0){this.settings.i18n.current=acceptLanguage[i][0];break}}}if(typeof this.settings.i18n.current=="undefined"||!this.settings.i18n.current){this.settings.i18n.current=(navigator.language?navigator.language:navigator.userLanguage)}var actualLanguage=this.getLanguage(this.settings.i18n.current,this.settings.i18n.available);if(!actualLanguage){GENTICS.Aloha.Log.error(this,"Could not determine actual language.")}else{var fileUrl=this.settings.base+"i18n/"+actualLanguage+".dict";this.loadI18nFile(fileUrl,this)}};GENTICS.Aloha.prototype.getLanguage=function(language,availableLanguages){if(!availableLanguages instanceof Array){GENTICS.Aloha.Log.error(this,"Available languages must be an Array");return null}if(typeof language=="undefined"||!language){return availableLanguages[0]}for(var i=0;i0){var key=GENTICS.Aloha.trim(entry.substring(0,equal));var value=GENTICS.Aloha.trim(entry.substring(equal+1,entry.length));value=value.replace(/\\n/g,"\n");value=value.replace(/\\\\/g,"\\");if(dictionary[key]){GENTICS.Aloha.Log.warn(component,"Found duplicate key "+key+" in dictionary file, ignoring")}else{dictionary[key]=value}}}this.dictionaries[component.toString()]=dictionary};GENTICS.Aloha.prototype.i18n=function(component,key,replacements){var value=null;if(this.dictionaries[component.toString()]){if(this.dictionaries[component.toString()][key]){value=this.dictionaries[component.toString()][key]}}if(!value&&component!=GENTICS.Aloha){if(this.dictionaries[GENTICS.Aloha.toString()]){if(this.dictionaries[GENTICS.Aloha.toString()][key]){value=this.dictionaries[GENTICS.Aloha.toString()][key]}}}if(!value){return"??? "+key+" ???"}else{if(typeof replacements!="undefined"&&replacements!=null){for(var i=0;i'}for(var i=0;i"}html+="";var that=this;GENTICS.Aloha.FloatingMenu.extTabPanel.on("move",function(){that.closePanel()});GENTICS.Aloha.FloatingMenu.extTabPanel.on("tabchange",function(){that.closePanel()});this.ulObj=jQuery(this.el.createChild(html).dom);this.ulObj.click(function(event){that.onClick(event)});this.panelButton=jQuery(this.el.createChild('').dom);this.panelButton.click(function(){that.togglePanel()})},onClick:function(event){if(!event.target.attributes.gtxmultisplititem){return}var el=jQuery(event.target);this.closePanel();if(!el.hasClass("GENTICS_multisplit-wide")){this.setActiveDOMElement(el)}this.items[event.target.attributes.gtxmultisplititem.value].click()},setActiveItem:function(name){this.closePanel();if(this.activeItem==name){return}for(var i=0;i")};GENTICS.Aloha.Editable.prototype.getContents=function(){var clonedObj=this.obj.clone(true);GENTICS.Aloha.PluginRegistry.makeClean(clonedObj);return clonedObj.html()};GENTICS.Aloha.Editable.prototype.getId=function(){return this.obj.attr("id")}; /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.Ribbon=function(){var that=this;this.toolbar=new Ext.Toolbar({height:30,cls:"GENTICS_ribbon ext-root"});this.toolbar.add(new Ext.Toolbar.Spacer({width:"5"}));this.icon=new Ext.Toolbar.Spacer();this.toolbar.add(this.icon);this.toolbar.add(new Ext.Toolbar.Fill());this.toolbar.add(new Ext.Toolbar.Separator());var fadeButton=new Ext.Button({iconCls:"GENTICS_fade_out",handler:function(button){var toolbar=jQuery(that.toolbar.getEl().dom);if(button.iconCls=="GENTICS_fade_out"){toolbar.css("marginLeft","34px");toolbar.animate({left:"-100%"});jQuery("body").animate({paddingTop:0});button.setIconClass("GENTICS_fade_in")}else{toolbar.css("marginLeft","0px");toolbar.animate({left:"0%"});jQuery("body").animate({paddingTop:30});button.setIconClass("GENTICS_fade_out")}that.toolbar.doLayout()}});this.toolbar.add(fadeButton);this.toolbar.add(new Ext.Toolbar.Spacer({width:"5"}))};GENTICS.Aloha.Ribbon.prototype.setIcon=function(iconClass){if(typeof this.icon.cls!="undefined"){this.icon.removeClass(this.icon.cls)}this.icon.addClass(iconClass)};GENTICS.Aloha.Ribbon.prototype.addButton=function(button){if(typeof button.menu==="object"){var menu=new Ext.menu.Menu();jQuery.each(button.menu,function(index,entry){menu.addItem(new Ext.menu.Item({text:entry.label,icon:entry.icon,iconCls:entry.iconClass,handler:function(){entry.onclick.apply(entry)}}))})}var buttonConfig={text:button.label,enableToggle:button.toggle,icon:button.icon,pressed:button.pressed,iconCls:button.iconClass,menu:menu,handler:function(){if(typeof button.onclick==="function"){button.onclick.apply(button)}button.pressed=!button.pressed}};var extButton;if(menu&&typeof button.onclick=="function"){extButton=new Ext.SplitButton(buttonConfig)}else{extButton=new Ext.Button(buttonConfig)}this.toolbar.insert(this.toolbar.items.getCount()-3,extButton)};GENTICS.Aloha.Ribbon.prototype.addSeparator=function(){this.toolbar.insert(this.toolbar.items.getCount()-3,new Ext.Toolbar.Separator())};GENTICS.Aloha.Ribbon.prototype.init=function(){this.toolbar.render(document.body,0);if(GENTICS.Aloha.settings.ribbon!==false){jQuery("body").css("paddingTop","30px !important");this.show()}};GENTICS.Aloha.Ribbon.prototype.hide=function(){jQuery(".GENTICS_ribbon").fadeOut()};GENTICS.Aloha.Ribbon.prototype.show=function(){jQuery(".GENTICS_ribbon").fadeIn()};GENTICS.Aloha.Ribbon=new GENTICS.Aloha.Ribbon(); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.Event=function(eventName,eventSource,properties){this.name=eventName;if(eventSource){this.source=eventSource}else{this.source=GENTICS.Aloha}this.properties=properties};GENTICS.Aloha.EventRegistry=function(){};GENTICS.Aloha.EventRegistry.prototype.subscribe=function(eventSource,eventName,handleMethod){jQuery(eventSource).bind(eventName,handleMethod)};GENTICS.Aloha.EventRegistry.prototype.trigger=function(event){jQuery(event.source).trigger(event.name,event.properties)};GENTICS.Aloha.EventRegistry=new GENTICS.Aloha.EventRegistry(); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.FloatingMenu={};GENTICS.Aloha.FloatingMenu.scopes={"GENTICS.Aloha.empty":{name:"GENTICS.Aloha.empty",extendedScopes:[],buttons:[]},"GENTICS.Aloha.global":{name:"GENTICS.Aloha.global",extendedScopes:["GENTICS.Aloha.empty"],buttons:[]},"GENTICS.Aloha.continuoustext":{name:"GENTICS.Aloha.continuoustext",extendedScopes:["GENTICS.Aloha.global"],buttons:[]}};GENTICS.Aloha.FloatingMenu.tabs=new Array();GENTICS.Aloha.FloatingMenu.tabMap={};GENTICS.Aloha.FloatingMenu.initialized=false;GENTICS.Aloha.FloatingMenu.allButtons=new Array();GENTICS.Aloha.FloatingMenu.top=100;GENTICS.Aloha.FloatingMenu.left=100;GENTICS.Aloha.FloatingMenu.pinned=false;GENTICS.Aloha.FloatingMenu.init=function(){this.currentScope="GENTICS.Aloha.global";var that=this;jQuery(window).unload(function(){if(that.pinned){jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned","true");jQuery.cookie("GENTICS.Aloha.FloatingMenu.top",that.obj.offset().top);jQuery.cookie("GENTICS.Aloha.FloatingMenu.left",that.obj.offset().left);if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(this,"stored FloatingMenu pinned position {"+that.obj.offset().left+", "+that.obj.offset().top+"}")}}else{jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned",null);jQuery.cookie("GENTICS.Aloha.FloatingMenu.top",null);jQuery.cookie("GENTICS.Aloha.FloatingMenu.left",null)}if(that.userActivatedTab){jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab",that.userActivatedTab)}}).resize(function(){var target=that.calcFloatTarget(GENTICS.Aloha.Selection.getRangeObject());if(target){that.floatTo(target)}});this.generateComponent();this.initialized=true};GENTICS.Aloha.FloatingMenu.obj=null;GENTICS.Aloha.FloatingMenu.shadow=null;GENTICS.Aloha.FloatingMenu.panelBody=null;GENTICS.Aloha.FloatingMenu.generateComponent=function(){var that=this;Ext.QuickTips.init();Ext.apply(Ext.QuickTips.getQuickTip(),{minWidth:10});if(this.extTabPanel){}this.extTabPanel=new Ext.TabPanel({activeTab:0,width:400,plain:false,draggable:{insertProxy:false,onDrag:function(e){var pel=this.proxy.getEl();this.x=pel.getLeft(true);this.y=pel.getTop(true);GENTICS.Aloha.FloatingMenu.shadow.hide()},endDrag:function(e){if(GENTICS.Aloha.FloatingMenu.pinned){var top=this.y-jQuery(document).scrollTop()}else{var top=this.y}that.left=this.x;that.top=top;this.panel.setPosition(this.x,top);GENTICS.Aloha.FloatingMenu.refreshShadow();GENTICS.Aloha.FloatingMenu.shadow.show()}},floating:true,defaults:{autoScroll:true},layoutOnTabChange:true,shadow:false,cls:"GENTICS_floatingmenu ext-root",listeners:{tabchange:{fn:function(tabPanel,tab){if(tab.title!=that.autoActivatedTab){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"User selected tab "+tab.title)}that.userActivatedTab=tab.title}else{if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"Tab "+tab.title+" was activated automatically")}}that.autoActivatedTab=undefined;jQuery.each(that.allButtons,function(index,buttonInfo){if(typeof buttonInfo.button!="undefined"&&typeof buttonInfo.button.extButton!="undefined"&&typeof buttonInfo.button.extButton.setActiveDOMElement=="function"){if(typeof buttonInfo.button.extButton.activeDOMElement!="undefined"){buttonInfo.button.extButton.setActiveDOMElement(buttonInfo.button.extButton.activeDOMElement)}}});GENTICS.Aloha.FloatingMenu.shadow.show();GENTICS.Aloha.FloatingMenu.refreshShadow()}}},enableTabScroll:true});jQuery.each(this.tabs,function(index,tab){that.extTabPanel.add(tab.getExtComponent())});jQuery("body").append('
 
');this.shadow=jQuery("#GENTICS_floatingmenu_shadow");var pinTab=this.extTabPanel.add({title:" "});this.extTabPanel.render(document.body);jQuery(pinTab.tabEl).addClass("GENTICS_floatingmenu_pin").html(" ").mousedown(function(e){that.togglePin();e.stopPropagation()});this.panelBody=jQuery(".GENTICS_floatingmenu .x-tab-panel-bwrap");this.doLayout();this.obj=jQuery(this.extTabPanel.getEl().dom);if(jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned")=="true"){this.togglePin();this.top=parseInt(jQuery.cookie("GENTICS.Aloha.FloatingMenu.top"));this.left=parseInt(jQuery.cookie("GENTICS.Aloha.FloatingMenu.left"));if(this.top<30){this.top=30}if(this.left<0){this.left=0}if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(this,"restored FloatingMenu pinned position {"+this.left+", "+this.top+"}")}this.refreshShadow()}if(jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab")){this.userActivatedTab=jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab")}this.extTabPanel.setPosition(this.left,this.top);this.obj.mousedown(function(e){e.stopPropagation()});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"selectionChanged",function(event,rangeObject){if(!that.pinned){var pos=that.calcFloatTarget(rangeObject);if(pos){that.floatTo(pos)}}})};GENTICS.Aloha.FloatingMenu.refreshShadow=function(){if(!this.panelBody){return}GENTICS.Aloha.FloatingMenu.shadow.css("top",this.top+24);GENTICS.Aloha.FloatingMenu.shadow.css("left",this.left);GENTICS.Aloha.FloatingMenu.shadow.width(this.panelBody.width());GENTICS.Aloha.FloatingMenu.shadow.height(this.panelBody.height())};GENTICS.Aloha.FloatingMenu.togglePin=function(){var el=jQuery(".GENTICS_floatingmenu_pin");if(this.pinned){el.removeClass("GENTICS_floatingmenu_pinned");this.top=this.obj.offset().top;this.obj.css("top",this.top);this.obj.css("position","absolute");this.shadow.css("position","absolute");this.refreshShadow();this.pinned=false}else{el.addClass("GENTICS_floatingmenu_pinned");this.top=this.obj.offset().top-jQuery(window).scrollTop();this.obj.css("top",this.top);this.obj.css("position","fixed");this.shadow.css("position","fixed");this.refreshShadow();this.pinned=true}};GENTICS.Aloha.FloatingMenu.createScope=function(scope,extendedScopes){if(typeof extendedScopes=="undefined"){extendedScopes=["GENTICS.Aloha.empty"]}else{if(typeof extendedScopes=="string"){extendedScopes=[extendedScopes]}}var scopeObject=this.scopes[scope];if(scopeObject){}else{this.scopes[scope]={name:scope,extendedScopes:extendedScopes,buttons:[]}}};GENTICS.Aloha.FloatingMenu.addButton=function(scope,button,tab,group){var scopeObject=this.scopes[scope];if(typeof scopeObject=="undefined"){}var buttonInfo={button:button,scopeVisible:false};this.allButtons.push(buttonInfo);scopeObject.buttons.push(buttonInfo);var tabObject=this.tabMap[tab];if(typeof tabObject=="undefined"){tabObject=new GENTICS.Aloha.FloatingMenu.Tab(tab);this.tabs.push(tabObject);this.tabMap[tab]=tabObject}var groupObject=tabObject.getGroup(group);groupObject.addButton(buttonInfo);if(this.initialized){this.generateComponent()}};GENTICS.Aloha.FloatingMenu.doLayout=function(){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"doLayout called for FloatingMenu, scope is "+this.currentScope)}var that=this;var firstVisibleTab=false;var activeExtTab=this.extTabPanel.getActiveTab();var activeTab=false;var floatingMenuVisible=false;var showUserActivatedTab=false;jQuery.each(this.tabs,function(index,tab){if(tab.extPanel==activeExtTab){activeTab=tab}var tabVisible=tab.visible;if(tab.doLayout()){floatingMenuVisible=true;if(!tabVisible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"showing tab strip for tab "+tab.label)}that.extTabPanel.unhideTabStripItem(tab.extPanel)}if(firstVisibleTab==false){firstVisibleTab=tab}if(that.userActivatedTab==tab.extPanel.title&&tab.extPanel!=activeExtTab){showUserActivatedTab=tab}}else{if(tabVisible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"hiding tab strip for tab "+tab.label)}that.extTabPanel.hideTabStripItem(tab.extPanel)}}});if(showUserActivatedTab){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Setting active tab to "+showUserActivatedTab.label)}this.extTabPanel.setActiveTab(showUserActivatedTab.extPanel)}else{if(typeof activeTab=="object"&&typeof firstVisibleTab=="object"){if(!activeTab.visible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Setting active tab to "+firstVisibleTab.label)}this.autoActivatedTab=firstVisibleTab.extPanel.title;this.extTabPanel.setActiveTab(firstVisibleTab.extPanel)}}}if(floatingMenuVisible&&this.extTabPanel.hidden){this.extTabPanel.show();this.refreshShadow();this.shadow.show();this.extTabPanel.setPosition(this.left,this.top)}else{if(!floatingMenuVisible&&!this.extTabPanel.hidden){var pos=this.extTabPanel.getPosition(true);this.left=pos[0]<0?100:pos[0];this.top=pos[1]<0?100:pos[1];this.extTabPanel.hide();this.shadow.hide()}}this.extTabPanel.doLayout()};GENTICS.Aloha.FloatingMenu.setScope=function(scope){var scopeObject=this.scopes[scope];if(typeof scopeObject=="undefined"){}else{if(this.currentScope!=scope){this.currentScope=scope;jQuery.each(this.allButtons,function(index,buttonInfo){buttonInfo.scopeVisible=false});this.setButtonScopeVisibility(scopeObject);this.doLayout()}}};GENTICS.Aloha.FloatingMenu.setButtonScopeVisibility=function(scopeObject){var that=this;jQuery.each(scopeObject.buttons,function(index,buttonInfo){buttonInfo.scopeVisible=true});jQuery.each(scopeObject.extendedScopes,function(index,scopeName){var motherScopeObject=that.scopes[scopeName];if(typeof motherScopeObject=="object"){that.setButtonScopeVisibility(motherScopeObject)}})};GENTICS.Aloha.FloatingMenu.nextFloatTargetObj=function(obj,limitObj){if(!obj||obj==limitObj){return obj}switch(obj.nodeName.toLowerCase()){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"p":case"div":case"td":case"pre":case"ul":case"ol":return obj;break;default:return this.nextFloatTargetObj(obj.parentNode,limitObj);break}};GENTICS.Aloha.FloatingMenu.calcFloatTarget=function(range){if(!GENTICS.Aloha.activeEditable){return false}var targetObj=jQuery(this.nextFloatTargetObj(range.getCommonAncestorContainer(),range.limitObject));var scrollTop=GENTICS.Utils.Position.Scroll.top;var y=targetObj.offset().top-this.obj.height()-50;if(y<(scrollTop+30)){y=targetObj.offset().top+targetObj.height()+30}return{x:GENTICS.Aloha.activeEditable.obj.offset().left,y:y}};GENTICS.Aloha.FloatingMenu.floatTo=function(position){if(this.pinned){return}var that=this;if(!this.floatedTo||this.floatedTo.x!=position.x||this.floatedTo.y!=position.y){this.obj.animate({top:position.y,left:position.x},{queue:false,step:function(step,props){if(props.prop=="top"){that.top=props.now}else{if(props.prop=="left"){that.left=props.now}}that.refreshShadow()}});this.floatedTo=position}};GENTICS.Aloha.FloatingMenu.Tab=function(label){this.label=label;this.groups=new Array();this.groupMap={};this.visible=true};GENTICS.Aloha.FloatingMenu.Tab.prototype.getGroup=function(group){var groupObject=this.groupMap[group];if(typeof groupObject=="undefined"){groupObject=new GENTICS.Aloha.FloatingMenu.Group();this.groupMap[group]=groupObject;this.groups.push(groupObject)}return groupObject};GENTICS.Aloha.FloatingMenu.Tab.prototype.getExtComponent=function(){var that=this;if(typeof this.extPanel=="undefined"){this.extPanel=new Ext.Panel({tbar:[],title:this.label,style:"margin-top:0px",bodyStyle:"display:none",autoScroll:true});jQuery.each(this.groups,function(index,group){that.extPanel.getTopToolbar().add(group.getExtComponent())})}return this.extPanel};GENTICS.Aloha.FloatingMenu.Tab.prototype.doLayout=function(){var that=this;if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"doLayout called for tab "+this.label)}this.visible=false;jQuery.each(this.groups,function(index,group){that.visible|=group.doLayout()});if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"tab "+this.label+(this.visible?" is ":" is not ")+"visible now")}return this.visible};GENTICS.Aloha.FloatingMenu.Group=function(){this.buttons=new Array()};GENTICS.Aloha.FloatingMenu.Group.prototype.addButton=function(buttonInfo){this.buttons.push(buttonInfo)};GENTICS.Aloha.FloatingMenu.Group.prototype.getExtComponent=function(){var that=this;if(typeof this.extButtonGroup=="undefined"){var items=new Array();var buttonCount=0;jQuery.each(this.buttons,function(index,button){items.push(button.button.getExtConfigProperties());buttonCount+=button.button.size=="small"?1:2});this.extButtonGroup=new Ext.ButtonGroup({columns:Math.ceil(buttonCount/2),items:items});jQuery.each(this.buttons,function(index,buttonInfo){buttonInfo.button.extButton=that.extButtonGroup.findById(buttonInfo.button.id)})}return this.extButtonGroup};GENTICS.Aloha.FloatingMenu.Group.prototype.doLayout=function(){var groupVisible=false;var that=this;jQuery.each(this.buttons,function(index,button){var extButton=that.extButtonGroup.findById(button.button.id);var buttonVisible=button.button.isVisible()&&button.scopeVisible;if(buttonVisible&&extButton.hidden){extButton.show()}else{if(!buttonVisible&&!extButton.hidden){extButton.hide()}}groupVisible|=buttonVisible});if(groupVisible&&this.extButtonGroup.hidden){this.extButtonGroup.show()}else{if(!groupVisible&&!this.extButtonGroup.hidden){this.extButtonGroup.hide()}}return groupVisible};if(document.attachEvent&&document.selection){(function(){var DOMUtils={findChildPosition:function(node){for(var i=0;node=node.previousSibling;i++){continue}return i},isDataNode:function(node){return node&&node.nodeValue!==null&&node.data!==null},isAncestorOf:function(parent,node){return !DOMUtils.isDataNode(parent)&&(parent.contains(DOMUtils.isDataNode(node)?node.parentNode:node)||node.parentNode==parent)},isAncestorOrSelf:function(root,node){return DOMUtils.isAncestorOf(root,node)||root==node},findClosestAncestor:function(root,node){if(DOMUtils.isAncestorOf(root,node)){while(node&&node.parentNode!=root){node=node.parentNode}}return node},getNodeLength:function(node){return DOMUtils.isDataNode(node)?node.length:node.childNodes.length},splitDataNode:function(node,offset){if(!DOMUtils.isDataNode(node)){return false}var newNode=node.cloneNode(false);node.deleteData(offset,node.length);newNode.deleteData(0,offset);node.parentNode.insertBefore(newNode,node.nextSibling)}};var TextRangeUtils={convertToDOMRange:function(textRange,document){function adoptBoundary(domRange,textRange,bStart){var cursorNode=document.createElement("a"),cursor=textRange.duplicate();cursor.collapse(bStart);var parent=cursor.parentElement();do{parent.insertBefore(cursorNode,cursorNode.previousSibling);cursor.moveToElementText(cursorNode)}while(cursor.compareEndPoints(bStart?"StartToStart":"StartToEnd",textRange)>0&&cursorNode.previousSibling);if(cursor.compareEndPoints(bStart?"StartToStart":"StartToEnd",textRange)==-1&&cursorNode.nextSibling){cursor.setEndPoint(bStart?"EndToStart":"EndToEnd",textRange);domRange[bStart?"setStart":"setEnd"](cursorNode.nextSibling,cursor.text.length)}else{domRange[bStart?"setStartBefore":"setEndBefore"](cursorNode)}cursorNode.parentNode.removeChild(cursorNode)}var domRange=new DOMRange(document);adoptBoundary(domRange,textRange,true);adoptBoundary(domRange,textRange,false);return domRange},convertFromDOMRange:function(domRange){function adoptEndPoint(textRange,domRange,bStart){var container=domRange[bStart?"startContainer":"endContainer"];var offset=domRange[bStart?"startOffset":"endOffset"],textOffset=0;var anchorNode=DOMUtils.isDataNode(container)?container:container.childNodes[offset];var anchorParent=DOMUtils.isDataNode(container)?container.parentNode:container;if(container.nodeType==3||container.nodeType==4){textOffset=offset}var cursorNode=domRange._document.createElement("a");anchorParent.insertBefore(cursorNode,anchorNode);var cursor=domRange._document.body.createTextRange();cursor.moveToElementText(cursorNode);cursorNode.parentNode.removeChild(cursorNode);textRange.setEndPoint(bStart?"StartToStart":"EndToStart",cursor);textRange[bStart?"moveStart":"moveEnd"]("character",textOffset)}var textRange=domRange._document.body.createTextRange();adoptEndPoint(textRange,domRange,true);adoptEndPoint(textRange,domRange,false);return textRange}};function DOMRange(document){this._document=document;this.startContainer=this.endContainer=document.body;this.endOffset=DOMUtils.getNodeLength(document.body)}DOMRange.START_TO_START=0;DOMRange.START_TO_END=1;DOMRange.END_TO_END=2;DOMRange.END_TO_START=3;DOMRange.prototype={startContainer:null,startOffset:0,endContainer:null,endOffset:0,commonAncestorContainer:null,collapsed:false,_document:null,_refreshProperties:function(){this.collapsed=(this.startContainer==this.endContainer&&this.startOffset==this.endOffset);var node=this.startContainer;while(node&&node!=this.endContainer&&!DOMUtils.isAncestorOf(node,this.endContainer)){node=node.parentNode}this.commonAncestorContainer=node},setStart:function(container,offset){this.startContainer=container;this.startOffset=offset;this._refreshProperties()},setEnd:function(container,offset){this.endContainer=container;this.endOffset=offset;this._refreshProperties()},setStartBefore:function(refNode){this.setStart(refNode.parentNode,DOMUtils.findChildPosition(refNode))},setStartAfter:function(refNode){this.setStart(refNode.parentNode,DOMUtils.findChildPosition(refNode)+1)},setEndBefore:function(refNode){this.setEnd(refNode.parentNode,DOMUtils.findChildPosition(refNode))},setEndAfter:function(refNode){this.setEnd(refNode.parentNode,DOMUtils.findChildPosition(refNode)+1)},selectNode:function(refNode){this.setStartBefore(refNode);this.setEndAfter(refNode)},selectNodeContents:function(refNode){this.setStart(refNode,0);this.setEnd(refNode,DOMUtils.getNodeLength(refNode))},collapse:function(toStart){if(toStart){this.setEnd(this.startContainer,this.startOffset)}else{this.setStart(this.endContainer,this.endOffset)}},cloneContents:function(){return(function cloneSubtree(iterator){for(var node,frag=document.createDocumentFragment();node=iterator.next();){node=node.cloneNode(!iterator.hasPartialSubtree());if(iterator.hasPartialSubtree()){node.appendChild(cloneSubtree(iterator.getSubtreeIterator()))}frag.appendChild(node)}return frag})(new RangeIterator(this))},extractContents:function(){var range=this.cloneRange();if(this.startContainer!=this.commonAncestorContainer){this.setStartAfter(DOMUtils.findClosestAncestor(this.commonAncestorContainer,this.startContainer))}this.collapse(true);return(function extractSubtree(iterator){for(var node,frag=document.createDocumentFragment();node=iterator.next();){iterator.hasPartialSubtree()?node=node.cloneNode(false):iterator.remove();if(iterator.hasPartialSubtree()){node.appendChild(extractSubtree(iterator.getSubtreeIterator()))}frag.appendChild(node)}return frag})(new RangeIterator(range))},deleteContents:function(){var range=this.cloneRange();if(this.startContainer!=this.commonAncestorContainer){this.setStartAfter(DOMUtils.findClosestAncestor(this.commonAncestorContainer,this.startContainer))}this.collapse(true);(function deleteSubtree(iterator){while(iterator.next()){iterator.hasPartialSubtree()?deleteSubtree(iterator.getSubtreeIterator()):iterator.remove()}})(new RangeIterator(range))},insertNode:function(newNode){if(DOMUtils.isDataNode(this.startContainer)){DOMUtils.splitDataNode(this.startContainer,this.startOffset);this.startContainer.parentNode.insertBefore(newNode,this.startContainer.nextSibling)}else{this.startContainer.insertBefore(newNode,this.startContainer.childNodes[this.startOffset])}this.setStart(this.startContainer,this.startOffset)},surroundContents:function(newNode){var content=this.extractContents();this.insertNode(newNode);newNode.appendChild(content);this.selectNode(newNode)},compareBoundaryPoints:function(how,sourceRange){var containerA,offsetA,containerB,offsetB;switch(how){case DOMRange.START_TO_START:case DOMRange.START_TO_END:containerA=this.startContainer;offsetA=this.startOffset;break;case DOMRange.END_TO_END:case DOMRange.END_TO_START:containerA=this.endContainer;offsetA=this.endOffset;break}switch(how){case DOMRange.START_TO_START:case DOMRange.END_TO_START:containerB=sourceRange.startContainer;offsetB=sourceRange.startOffset;break;case DOMRange.START_TO_END:case DOMRange.END_TO_END:containerB=sourceRange.endContainer;offsetB=sourceRange.endOffset;break}return containerA.sourceIndex-1&&textRange.compareEndPoints("EndToEnd",selection)==-1){selection.setEndPoint("StartToStart",textRange)}else{if(textRange.compareEndPoints("EndToStart",selection)<1&&textRange.compareEndPoints("EndToEnd",selection)>-1){selection.setEndPoint("EndToEnd",textRange)}}}selection.select()}},removeAllRanges:function(){this._document.selection.empty()},getRangeAt:function(index){var textRange=this._document.selection.createRange();if(this._selectionExists(textRange)){return TextRangeUtils.convertToDOMRange(textRange,this._document)}return null},toString:function(){return this._document.selection.createRange().text}};document.createRange=function(){return new DOMRange(document)};var selection=new DOMSelection(document);window.getSelection=function(){return selection}})(); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ }jQuery.fn.aloha=function(){return this.each(function(){new GENTICS.Aloha.Editable(jQuery(this))})};jQuery.fn.GENTICS_aloha=function(){return this.each(function(){new GENTICS.Aloha.Editable(jQuery(this))})};jQuery.fn.mahalo=function(){return this.each(function(){if(jQuery(this).hasClass("GENTICS_editable")){for(var i=0;i").append(this.eq(0).clone()).html()}}; /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.Log=function(){};GENTICS.Aloha.Log.prototype.logHistory=null;GENTICS.Aloha.Log.prototype.highWaterMarkReached=false;GENTICS.Aloha.Log.prototype.init=function(){if(typeof GENTICS.Aloha.settings.logLevels=="undefined"||!GENTICS.Aloha.settings.logLevels){GENTICS.Aloha.settings.logLevels={error:true,warn:true}}if(typeof GENTICS.Aloha.settings.logHistory=="undefined"||!GENTICS.Aloha.settings.logHistory){GENTICS.Aloha.settings.logHistory={}}if(!GENTICS.Aloha.settings.logHistory.maxEntries){GENTICS.Aloha.settings.logHistory.maxEntries=100}if(!GENTICS.Aloha.settings.logHistory.highWaterMark){GENTICS.Aloha.settings.logHistory.highWaterMark=90}if(!GENTICS.Aloha.settings.logHistory.levels){GENTICS.Aloha.settings.logHistory.levels={error:true,warn:true}}this.flushLogHistory()};GENTICS.Aloha.Log.prototype.log=function(level,component,message){if(typeof level=="undefined"||!level){level="error"}level=level.toLowerCase();if(!GENTICS.Aloha.settings.logLevels[level]){return}this.addToLogHistory({level:level,component:component.toString(),message:message,date:new Date()});switch(level){case"error":if(window.console&&console.error){console.error(component.toString()+": "+message)}break;case"warn":if(window.console&&console.warn){console.warn(component.toString()+": "+message)}break;case"info":if(window.console&&console.info){console.info(component.toString()+": "+message)}break;case"debug":if(window.console&&console.log){console.log(component.toString()+" ["+level+"]: "+message)}break;default:if(window.console&&console.log){console.log(component.toString()+" ["+level+"]: "+message)}break}};GENTICS.Aloha.Log.prototype.error=function(component,message){this.log("error",component,message)};GENTICS.Aloha.Log.prototype.warn=function(component,message){this.log("warn",component,message)};GENTICS.Aloha.Log.prototype.info=function(component,message){this.log("info",component,message)};GENTICS.Aloha.Log.prototype.debug=function(component,message){this.log("debug",component,message)};GENTICS.Aloha.Log.prototype.isLogLevelEnabled=function(level){return GENTICS.Aloha.settings&&GENTICS.Aloha.settings.logLevels&&(GENTICS.Aloha.settings.logLevels[level]==true)};GENTICS.Aloha.Log.prototype.isErrorEnabled=function(){return this.isLogLevelEnabled("error")};GENTICS.Aloha.Log.prototype.isWarnEnabled=function(){return this.isLogLevelEnabled("warn")};GENTICS.Aloha.Log.prototype.isInfoEnabled=function(){return this.isLogLevelEnabled("info")};GENTICS.Aloha.Log.prototype.isDebugEnabled=function(){return this.isLogLevelEnabled("debug")};GENTICS.Aloha.Log.prototype.addToLogHistory=function(entry){if(GENTICS.Aloha.settings.logHistory.maxEntries<=0){return}if(!GENTICS.Aloha.settings.logHistory.levels[entry.level]){return}this.logHistory.push(entry);if(this.highWaterMarkReached==false){if(this.logHistory.length>=GENTICS.Aloha.settings.logHistory.maxEntries*GENTICS.Aloha.settings.logHistory.highWaterMark/100){GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("logFull",GENTICS.Aloha.Log));this.highWaterMarkReached=true}}while(this.logHistory.length>GENTICS.Aloha.settings.logHistory.maxEntries){this.logHistory.shift()}};GENTICS.Aloha.Log.prototype.getLogHistory=function(){return this.logHistory};GENTICS.Aloha.Log.prototype.flushLogHistory=function(){this.logHistory=new Array();this.highWaterMarkReached=false};GENTICS.Aloha.Log=new GENTICS.Aloha.Log(); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.Markup=function(){};GENTICS.Aloha.Markup.prototype.keyHandlers={};GENTICS.Aloha.Markup.prototype.addKeyHandler=function(keyCode,handler){if(!this.keyHandlers[keyCode]){this.keyHandlers[keyCode]=[]}this.keyHandlers[keyCode].push(handler)};GENTICS.Aloha.Markup.prototype.insertBreak=function(){var range=GENTICS.Aloha.Selection.rangeObject;if(!range.isCollapsed()){this.removeSelectedMarkup()}var newBreak=jQuery("
");GENTICS.Utils.Dom.insertIntoDOM(newBreak,range,GENTICS.Aloha.activeEditable.obj);var nextTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(newBreak.parent().get(0),GENTICS.Utils.Dom.getIndexInParent(newBreak.get(0))+1,false);if(nextTextNode){var nonWSIndex=nextTextNode.data.search(/\S/);if(nonWSIndex>0){nextTextNode.data=nextTextNode.data.substring(nonWSIndex)}}range.startContainer=range.endContainer=newBreak.get(0).parentNode;range.startOffset=range.endOffset=GENTICS.Utils.Dom.getIndexInParent(newBreak.get(0))+1;range.correctRange();range.clearCaches();range.select()};GENTICS.Aloha.Markup.prototype.preProcessKeyStrokes=function(event){if(event.type!="keydown"){return false}var rangeObject=GENTICS.Aloha.Selection.rangeObject;if(this.keyHandlers[event.keyCode]){var handlers=this.keyHandlers[event.keyCode];for(var i=0;i");for(var i=0;i0){var jqElBefore=jQuery(selectionTree[i-1].domobj);jqElBefore.after(inBetweenMarkup)}else{var jqElAfter=jQuery(selectionTree[1].domobj);jqElAfter.before(inBetweenMarkup)}rangeObject.startContainer=rangeObject.endContainer=inBetweenMarkup[0].parentNode;rangeObject.startOffset=rangeObject.endOffset=GENTICS.Utils.Dom.getIndexInParent(inBetweenMarkup[0])+1;rangeObject.correctRange()}else{if(el.domobj&&el.domobj.nodeType===3){if(el.domobj.nextSibling&&el.domobj.nextSibling.nodeType==1&&GENTICS.Aloha.Selection.replacingElements[el.domobj.nextSibling.nodeName.toLowerCase()]){jqEl.after("
")}var checkObj=el.domobj;while(checkObj){if(checkObj.nextSibling){checkObj=false}else{checkObj=checkObj.parentNode;if(checkObj===rangeObject.limitObject){checkObj=false}if(GENTICS.Utils.Dom.isBlockLevelElement(checkObj)){break}}}if(checkObj){jQuery(checkObj).append("
")}jqEl.between(inBetweenMarkup,el.startOffset);var offset=0;var tmpObject=inBetweenMarkup[0];while(tmpObject){tmpObject=tmpObject.previousSibling;offset++}rangeObject.startContainer=inBetweenMarkup[0].parentNode;rangeObject.endContainer=inBetweenMarkup[0].parentNode;rangeObject.startOffset=offset;rangeObject.endOffset=offset;rangeObject.correctRange()}else{if(el.domobj&&el.domobj.nodeType===1){if(jqEl.parent().find("br.GENTICS_ephemera").length===0){jQuery(rangeObject.limitObject).find("br.GENTICS_ephemera").remove();jQuery(rangeObject.commonAncestorContainer).append(this.getFillUpElement(rangeObject.splitObject))}jqEl.after(inBetweenMarkup);rangeObject.startContainer=rangeObject.commonAncestorContainer;rangeObject.endContainer=rangeObject.startContainer;rangeObject.startOffset=i+2;rangeObject.endOffset=i+2;rangeObject.update()}}}}}rangeObject.select()};GENTICS.Aloha.Markup.prototype.getSelectedText=function(){var rangeObject=GENTICS.Aloha.Selection.rangeObject;if(rangeObject.isCollapsed()){return false}return this.getFromSelectionTree(rangeObject.getSelectionTree(),true)};GENTICS.Aloha.Markup.prototype.getFromSelectionTree=function(selectionTree,astext){var text="";for(var i=0;i0){newdata+=el.domobj.data.substring(0,el.startOffset)}if(el.endOffset')}};GENTICS.Aloha.Markup.prototype.removeElementContentWhitespaceObj=function(domArray){var correction=0;var removeLater=[];for(var i=0;i0){var mirrorLevel=followUpContainer.contents();if(mirrorLevel.length!==selectionTree.length){this.removeElementContentWhitespaceObj(mirrorLevel)}for(var i=0;i1){mirrorLevel.eq(i).remove()}else{if(GENTICS.Utils.Dom.isSplitObject(followUpContainer[0])){if(fillUpElement){followUpContainer.html(fillUpElement)}else{followUpContainer.empty()}}else{followUpContainer.empty();followUpContainer.addClass("preparedForRemoval")}}continue}else{if(el.selection!=="none"){if(el.domobj&&el.domobj.nodeType===3&&el.startOffset!==undefined){var completeText=el.domobj.data;if(el.startOffset>0){el.domobj.data=completeText.substr(0,el.startOffset)}else{if(selectionTree.length>1){jQuery(el.domobj).remove()}else{var parent=jQuery(el.domobj).parent();if(GENTICS.Utils.Dom.isSplitObject(parent[0])){if(fillUpElement){parent.html(fillUpElement)}else{parent.empty()}}else{parent.remove()}}}if(completeText.length-el.startOffset>0){mirrorLevel[i].data=completeText.substr(el.startOffset,completeText.length)}else{if(mirrorLevel.length>1){mirrorLevel.eq((i)).remove()}else{if(GENTICS.Utils.Dom.isBlockLevelElement(followUpContainer[0])){if(fillUpElement){followUpContainer.html(fillUpElement)}else{followUpContainer.empty()}}else{followUpContainer.empty();followUpContainer.addClass("preparedForRemoval")}}}}startMoving=true;if(el.children.length>0){this.splitRangeObjectHelper(el.children,rangeObject,mirrorLevel.eq(i),inBetweenMarkup)}}else{if(el.selection==="none"&&startMoving===true){jqObj=jQuery(el.domobj).remove()}}}}}else{GENTICS.Aloha.Log.error(this,"can not split splitObject due to an empty selection tree")}splitObject.find("br.GENTICS_ephemera:gt(0)").remove();followUpContainer.find("br.GENTICS_ephemera:gt(0)").remove();splitObject.find(".preparedForRemoval").remove();followUpContainer.find(".preparedForRemoval").remove();if(splitObject.contents().length===0&&GENTICS.Utils.Dom.isSplitObject(splitObject[0])&&fillUpElement){splitObject.html(fillUpElement)}if(followUpContainer.contents().length===0&&GENTICS.Utils.Dom.isSplitObject(followUpContainer[0])&&fillUpElement){followUpContainer.html(fillUpElement)}};GENTICS.Aloha.Markup.prototype.getSplitFollowUpContainer=function(rangeObject){var tagName=rangeObject.splitObject.nodeName.toLowerCase();switch(tagName){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":var lastObj=jQuery(rangeObject.splitObject).textNodes().last()[0];if(lastObj&&rangeObject.startContainer===lastObj&&rangeObject.startOffset===lastObj.length){var returnObj=jQuery("

");var inside=jQuery(rangeObject.splitObject).clone().contents();returnObj.append(inside);return returnObj}break;case"li":if(rangeObject.startContainer.nodeName.toLowerCase()==="br"&&jQuery(rangeObject.startContainer).hasClass("GENTICS_ephemera")){var returnObj=jQuery("

");var inside=jQuery(rangeObject.splitObject).clone().contents();returnObj.append(inside);return returnObj}if(!rangeObject.splitObject.nextSibling&&jQuery.trim(jQuery(rangeObject.splitObject).text()).length==0){var returnObj=jQuery("

");return returnObj}}return jQuery(rangeObject.splitObject).clone()};GENTICS.Aloha.Markup.prototype.transformDomObject=function(domobj,nodeName){var jqOldObj=jQuery(domobj);var jqNewObj=jQuery("<"+nodeName+">");jqOldObj.contents().appendTo(jqNewObj);jqOldObj.replaceWith(jqNewObj);return jqNewObj};GENTICS.Aloha.Markup.prototype.toString=function(){return"GENTICS.Aloha.Markup"};GENTICS.Aloha.Markup=new GENTICS.Aloha.Markup(); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.Message=function(data){this.title=data.title;this.text=data.text;this.type=data.type;this.callback=data.callback};GENTICS.Aloha.Message.Type={CONFIRM:"confirm",ALERT:"alert",WAIT:"wait"};GENTICS.Aloha.Message.prototype.toString=function(){return this.type+": "+this.message};GENTICS.Aloha.MessageLine=function(){this.messages=new Array()};GENTICS.Aloha.MessageLine.prototype.add=function(message){this.messages[this.messages.length]=message;while(this.messages.length>4){this.messages.shift()}jQuery("#gtx_aloha_messageline").html("");for(var i=0;i"))}};GENTICS.Aloha.MessageLine=new GENTICS.Aloha.MessageLine(); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.PluginRegistry=function(){this.plugins=new Array()};GENTICS.Aloha.PluginRegistry.prototype.register=function(plugin){if(plugin instanceof GENTICS.Aloha.Plugin){this.plugins.push(plugin)}};GENTICS.Aloha.PluginRegistry.prototype.init=function(){for(var i=0;i0?"partial":"full";startOffset=rangeObject.startOffset;endOffset=this.length}break;case 1:if(this===rangeObject.startContainer&&rangeObject.startOffset==0){that.inselection=true;selectionType="full"}if(currentObject===rangeObject.startContainer&&rangeObject.startOffset==index){that.inselection=true;selectionType="full"}break}}if(that.inselection&&!collapsedFound){if(selectionType=="none"){selectionType="full"}switch(this.nodeType){case 3:if(this===rangeObject.endContainer){that.inselection=false;if(rangeObject.endOffset0){var noneFound=false;var partialFound=false;var fullFound=false;for(var i=0;i0){parents.each(function(){if(this===limitObject){GENTICS.Aloha.Log.debug(that,"reached limit dom obj");return false}if(tagComparator(this,markupObject)){if(returnVal===false){returnVal=new Array()}GENTICS.Aloha.Log.debug(that,"reached object equal to markup");i++;returnVal[i]=this;return true}})}return returnVal};GENTICS.Aloha.Selection.prototype.standardSectionsAndGroupingContentComparator=function(domobj,markupObject){if(domobj.nodeType===1){if(markupObject[0].tagName&&GENTICS.Aloha.Selection.replacingElements[domobj.tagName.toLowerCase()]&&GENTICS.Aloha.Selection.replacingElements[domobj.tagName.toLowerCase()].indexOf(markupObject[0].tagName.toLowerCase())!=-1){return true}}else{GENTICS.Aloha.Log.debug(this,"only element nodes (nodeType == 1) can be compared")}return false};GENTICS.Aloha.Selection.prototype.standardTextLevelSemanticsComparator=function(domobj,markupObject){if(domobj.nodeType===1){if(domobj.tagName.toLowerCase()!=markupObject[0].tagName.toLowerCase()){return false}if(!this.standardAttributesComparator(domobj,markupObject)){return false}return true}else{GENTICS.Aloha.Log.debug(this,"only element nodes (nodeType == 1) can be compared")}return false};GENTICS.Aloha.Selection.prototype.standardAttributesComparator=function(domobj,markupObject){if(domobj.attributes&&domobj.attributes.length&&domobj.attributes.length>0){for(var i=0;i0){var classString=attr.nodeValue;var classes=classString.split(" ")}}}if(markupObject[0].attributes&&markupObject[0].attributes.length&&markupObject[0].attributes.length>0){for(var i=0;i0){var classString=attr.nodeValue;var classes2=classString.split(" ")}}}if(classes&&!classes2||classes2&&!classes){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because one element has classes and the other has not");return false}if(classes&&classes2&&classes.length!=classes.length){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because of a different amount of classes");return false}if(classes&&classes2&&classes.length==classes2.length&&classes.length!=0){for(var i=0;i failed because of different classes");return false}}}return true};GENTICS.Aloha.Selection.prototype.changeMarkup=function(rangeObject,markupObject,tagComparator){var tagName=markupObject[0].tagName.toLowerCase();if(this.replacingElements[tagName]){var backupRangeObject=rangeObject;rangeObject=new this.SelectionRange(rangeObject);if(GENTICS.Aloha.activeEditable){var newCAC=GENTICS.Aloha.activeEditable.obj.get(0)}else{var newCAC=document.body}rangeObject.update(newCAC);markupObject.isReplacingElement=true}else{if(rangeObject.isCollapsed()){GENTICS.Aloha.Log.debug(this,"early returning from applying markup because nothing is currently selected");return false}}if(GENTICS.Aloha.activeEditable){var limitObject=GENTICS.Aloha.activeEditable.obj[0]}else{var limitObject=document.body}var relevantMarkupObjectsAtSelectionStart=this.isRangeObjectWithinMarkup(rangeObject,false,markupObject,tagComparator,limitObject);var relevantMarkupObjectsAtSelectionEnd=this.isRangeObjectWithinMarkup(rangeObject,true,markupObject,tagComparator,limitObject);if(!markupObject.isReplacingElement&&rangeObject.startOffset==0){var prevSibling;if(prevSibling=this.getTextNodeSibling(false,rangeObject.commonAncestorContainer.parentNode,rangeObject.startContainer)){var relevantMarkupObjectBeforeSelection=this.isRangeObjectWithinMarkup({startContainer:prevSibling,startOffset:0},false,markupObject,tagComparator,limitObject)}}if(!markupObject.isReplacingElement&&(rangeObject.endOffset==rangeObject.endContainer.length)){var nextSibling;if(nextSibling=this.getTextNodeSibling(true,rangeObject.commonAncestorContainer.parentNode,rangeObject.endContainer)){var relevantMarkupObjectAfterSelection=this.isRangeObjectWithinMarkup({startContainer:nextSibling,startOffset:0},false,markupObject,tagComparator,limitObject)}}if(!markupObject.isReplacingElement&&(relevantMarkupObjectsAtSelectionStart&&!relevantMarkupObjectsAtSelectionEnd)){GENTICS.Aloha.Log.info(this,"markup 2 non-markup");this.prepareForRemoval(rangeObject.getSelectionTree(),markupObject,tagComparator);jQuery(relevantMarkupObjectsAtSelectionStart).addClass("preparedForRemoval");this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionStart,rangeObject,false,tagComparator)}else{if(!markupObject.isReplacingElement&&relevantMarkupObjectsAtSelectionStart&&relevantMarkupObjectsAtSelectionEnd){GENTICS.Aloha.Log.info(this,"markup 2 markup");this.prepareForRemoval(rangeObject.getSelectionTree(),markupObject,tagComparator);this.splitRelevantMarkupObject(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject,tagComparator)}else{if(!markupObject.isReplacingElement&&((!relevantMarkupObjectsAtSelectionStart&&relevantMarkupObjectsAtSelectionEnd)||relevantMarkupObjectAfterSelection||relevantMarkupObjectBeforeSelection)){GENTICS.Aloha.Log.info(this,"non-markup 2 markup OR with next2markup");if(relevantMarkupObjectBeforeSelection&&relevantMarkupObjectAfterSelection){var extendedRangeObject=new GENTICS.Aloha.Selection.SelectionRange(rangeObject);extendedRangeObject.startContainer=jQuery(relevantMarkupObjectBeforeSelection[relevantMarkupObjectBeforeSelection.length-1]).textNodes()[0];extendedRangeObject.startOffset=0;extendedRangeObject.endContainer=jQuery(relevantMarkupObjectAfterSelection[relevantMarkupObjectAfterSelection.length-1]).textNodes().last()[0];extendedRangeObject.endOffset=extendedRangeObject.endContainer.length;extendedRangeObject.update();this.applyMarkup(extendedRangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator);GENTICS.Aloha.Log.info(this,"double extending previous markup(previous and after selection), actually wrapping it ...")}else{if(relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection&&!relevantMarkupObjectsAtSelectionEnd){this.extendExistingMarkupWithSelection(relevantMarkupObjectBeforeSelection,rangeObject,false,tagComparator);GENTICS.Aloha.Log.info(this,"extending previous markup")}else{if(relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection&&relevantMarkupObjectsAtSelectionEnd){var extendedRangeObject=new GENTICS.Aloha.Selection.SelectionRange(rangeObject);extendedRangeObject.startContainer=jQuery(relevantMarkupObjectBeforeSelection[relevantMarkupObjectBeforeSelection.length-1]).textNodes()[0];extendedRangeObject.startOffset=0;extendedRangeObject.endContainer=jQuery(relevantMarkupObjectsAtSelectionEnd[relevantMarkupObjectsAtSelectionEnd.length-1]).textNodes().last()[0];extendedRangeObject.endOffset=extendedRangeObject.endContainer.length;extendedRangeObject.update();this.applyMarkup(extendedRangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator);GENTICS.Aloha.Log.info(this,"double extending previous markup(previous and relevant at the end), actually wrapping it ...")}else{if(!relevantMarkupObjectBeforeSelection&&relevantMarkupObjectAfterSelection){this.extendExistingMarkupWithSelection(relevantMarkupObjectAfterSelection,rangeObject,true,tagComparator);GENTICS.Aloha.Log.info(this,"extending following markup backwards")}else{this.extendExistingMarkupWithSelection(relevantMarkupObjectsAtSelectionEnd,rangeObject,true,tagComparator)}}}}}else{if(markupObject.isReplacingElement||(!relevantMarkupObjectsAtSelectionStart&&!relevantMarkupObjectsAtSelectionEnd&&!relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection)){GENTICS.Aloha.Log.info(this,"non-markup 2 non-markup");this.applyMarkup(rangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator,{setRangeObject2NewMarkup:true})}}}}jQuery(".preparedForRemoval").zap();rangeObject.update();if(markupObject.isReplacingElement){backupRangeObject.select()}else{rangeObject.select()}};GENTICS.Aloha.Selection.prototype.areMarkupObjectsAsLongAsRangeObject=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject){if(rangeObject.startOffset!==0){return false}for(var i=0;i0){this.prepareForRemoval(el.children,markupObject,tagComparator)}}};GENTICS.Aloha.Selection.prototype.wrapMarkupAroundSelectionTree=function(selectionTree,rangeObject,markupObject,tagComparator,options){var objects2wrap=new Array;var j=-1;GENTICS.Aloha.Log.debug(this,"The formatting <"+markupObject[0].tagName+"> will be wrapped around the selection");var preText="";var postText="";for(var i=0;i because this tag is not allowed inside <"+el.domobj.parentNode.tagName.toLowerCase()+">");continue}if(el.domobj&&el.domobj.nodeType==3&&jQuery.trim(jQuery(el.domobj).outerHTML()).length==0){continue}if(el.domobj&&el.selection=="partial"&&!markupObject.isReplacingElement){if(el.startOffset!==undefined&&el.endOffset===undefined){j++;preText+=el.domobj.data.substr(0,el.startOffset);el.domobj.data=el.domobj.data.substr(el.startOffset,el.domobj.data.length-el.startOffset);objects2wrap[j]=el.domobj}else{if(el.endOffset!==undefined&&el.startOffset===undefined){j++;postText+=el.domobj.data.substr(el.endOffset,el.domobj.data.length-el.endOffset);el.domobj.data=el.domobj.data.substr(0,el.endOffset);objects2wrap[j]=el.domobj}else{if(el.endOffset!==undefined&&el.startOffset!==undefined){if(el.startOffset==el.endOffset){GENTICS.Aloha.Log.debug(this,"skipping empty selection");continue}j++;preText+=el.domobj.data.substr(0,el.startOffset);var middleText=el.domobj.data.substr(el.startOffset,el.endOffset-el.startOffset);postText+=el.domobj.data.substr(el.endOffset,el.domobj.data.length-el.endOffset);el.domobj.data=middleText;objects2wrap[j]=el.domobj}else{GENTICS.Aloha.Log.debug(this,"diving into object");this.applyMarkup(el.children,rangeObject,markupObject,tagComparator,options)}}}}if(el.domobj&&(el.selection=="full"||(el.selection=="partial"&&markupObject.isReplacingElement))){j++;objects2wrap[j]=el.domobj}}breakpoint=true;if(objects2wrap.length>0){objects2wrap=jQuery(objects2wrap);jQuery.each(objects2wrap,function(index,element){if(jQuery.browser.msie&&element.nodeType==3&&!element.nextSibling&&!element.previousSibling&&element.parentNode&&element.parentNode.nodeName.toLowerCase()=="li"){element.data=jQuery.trim(element.data)}});var newMarkup=objects2wrap.wrapAll(markupObject).parent();newMarkup.before(preText).after(postText);var breakpoint=true;if(options.setRangeObject2NewMarkup){var textnodes=objects2wrap.textNodes();if(textnodes.index(rangeObject.startContainer)!=-1){rangeObject.startOffset=0}if(textnodes.index(rangeObject.endContainer)!=-1){rangeObject.endOffset=rangeObject.endContainer.length}var breakpoint=true}if(options.setRangeObject2NextSibling){var prevOrNext=true;var textNode2Start=newMarkup.textNodes(true).last()[0];if(objects2wrap.index(rangeObject.startContainer)!=-1){rangeObject.startContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.startOffset=0}if(objects2wrap.index(rangeObject.endContainer)!=-1){rangeObject.endContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.endOffset=rangeObject.endOffset-textNode2Start.length}}if(options.setRangeObject2PreviousSibling){var prevOrNext=false;var textNode2Start=newMarkup.textNodes(true).first()[0];if(objects2wrap.index(rangeObject.startContainer)!=-1){rangeObject.startContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.startOffset=0}if(objects2wrap.index(rangeObject.endContainer)!=-1){rangeObject.endContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.endOffset=rangeObject.endContainer.length}}}};GENTICS.Aloha.Selection.prototype.getTextNodeSibling=function(previousOrNext,commonAncestorContainer,currentTextNode){var textNodes=jQuery(commonAncestorContainer).textNodes(true);index=textNodes.index(currentTextNode);if(index==-1){return false}var newIndex=index+(!previousOrNext?-1:1);return textNodes[newIndex]?textNodes[newIndex]:false};GENTICS.Aloha.Selection.prototype.optimizeSelectionTree4Markup=function(selectionTree,markupObject,tagComparator){var groupMap=[];var outerGroupIndex=0;var innerGroupIndex=0;var that=this;if(typeof tagComparator==="undefined"){tagComparator=function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(markupObject)}}for(var i=0;i=0;j--){if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[j]],markupObject)&&this.isMarkupAllowedToStealSelectionTreeElement(selectionTree[j],markupObject)){startPosition=j}else{break}}var endPosition=i;for(var j=i+1;j0&&!this.canMarkupBeApplied2ElementAsWhole(el.children,markupObject)){return false}}}return returnVal};GENTICS.Aloha.Selection.prototype.canTag1WrapTag2=function(t1,t2){t1=(t1=="#text")?"textNode":t1.toLowerCase();t2=(t2=="#text")?"textNode":t2.toLowerCase();if(!this.tagHierarchy[t1]){return true}if(!this.tagHierarchy[t2]){return true}var t1Array=this.tagHierarchy[t1];var returnVal=(t1Array.indexOf(t2)!=-1)?true:false;return returnVal};GENTICS.Aloha.Selection.prototype.mayInsertTag=function(tagName){if(typeof this.rangeObject.unmodifiableMarkupAtStart=="object"){for(var i=0;i0){var parents=jQuery(this.startContainer).parents();var editables=GENTICS.Aloha.editables;for(var i=0;i1&&!select.visible()){onChange(0,true)}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false}progress+=seperator});words[wordAt]=v;v=words.join(options.multipleSeparator)}v+=options.multipleSeparator}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return}var currentValue=$input.val();if(!skipPrevCheck&¤tValue==previousValue){return}previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase){currentValue=currentValue.toLowerCase()}request(currentValue,receiveData,hideResultsNow)}else{stopLoading();select.hide()}}function trimWords(value){if(!value){return[""]}if(!options.multiple){return[$.trim(value)]}return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null})}function lastWord(value){if(!options.multiple){return value}var words=trimWords(value);if(words.length==1){return words[0]}var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""))}return words[words.length-1]}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length)}}function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200)}function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""))}else{$input.val("");$input.trigger("result",null)}}})}}function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show()}else{hideResultsNow()}}function request(term,success,failure){if(!options.matchCase){term=term.toLowerCase()}var data=cache.load(term);if(data&&data.length){success(term,data)}else{if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed)}})}else{select.emptyList();failure(term)}}}function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1")},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase){s=s.toLowerCase()}var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase())}if(i==-1){return false}return i==0||options.matchContains}function add(q,value){if(length>options.cacheLength){flush()}if(!data[q]){length++}data[q]=value}function populate(){if(!options.data){return false}var stMatchSets={},nullData=0;if(!options.url){options.cacheLength=1}stMatchSets[""]=[];for(var i=0,ol=options.data.length;i0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x)}})}}return csub}else{if(data[q]){return data[q]}else{if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x}});return csub}}}}}return null}}};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit){return}element=$("
").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("
    ").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=="LI"){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE)}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false}).mousedown(function(){config.mouseDownOnSelect=true}).mouseup(function(){config.mouseDownOnSelect=false});if(options.width>0){element.css("width",options.width)}needsInit=false}function target(event){var element=event.target;while(element&&element.tagName!="LI"){element=element.parentNode}if(!element){return[]}return element}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight())}else{if(offset=listItems.size()){active=0}}}function limitNumberOfItems(available){return options.max&&options.max").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i])}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0}if($.fn.bgiframe){list.bgiframe()}}return{display:function(d,q){init();data=d;term=q;fillList()},next:function(){moveSelect(1)},prev:function(){moveSelect(-1)},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active)}else{moveSelect(-8)}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active)}else{moveSelect(8)}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1},visible:function(){return element&&element.is(":visible")},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0])},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:"auto"});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight});var scrollbarsVisible=listHeight>options.scrollHeight;list.css("height",scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")))}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data")},emptyList:function(){list&&list.empty()},unbind:function(){element&&element.remove()}}};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select()}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select()}}else{if(this.setSelectionRange){this.setSelectionRange(start,end)}else{if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end}}}})}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else{if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}}}})(jQuery); /* * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ GENTICS.Aloha.RessourceRegistry=function(){this.ressources=new Array()};GENTICS.Aloha.RessourceRegistry.prototype.register=function(ressource){if(ressource instanceof GENTICS.Aloha.Ressource){this.ressources.push(ressource)}};GENTICS.Aloha.RessourceRegistry.prototype.init=function(){for(var i=0;i