var XWiki=(function(a){a.Selection=Class.create({container:false,selectionText:false,selectionContext:false,selectionOffset:false,range:false,highlightWrappers:false,selectionParent:false,selectionParentInnerHTML:false,offsetX:false,offsetY:false,step:5,wordStep:1,initialize:function(b){if(!b){return}this.container=b;if(!window.getSelection){this.container.observe("mousedown",function(c){this.offsetX=c.pointerX();this.offsetY=c.pointerY()}.bindAsEventListener(this))}},computeSelection:function(){this.selectionText=false;this.range=false;this.selectionContext=false;this.selectionOffset=false;this.highlightWrappers=false;this.selectionParent=false;this.selectionParentInnerHTML=false;if(!this.container){return}if(window.getSelection){if(window.getSelection().rangeCount==0){return}this.range=window.getSelection().getRangeAt(0);if(!this.isDescendantOrSelf(this.container,this.range.commonAncestorContainer)){return}this.selectionText=this.range.toString()}else{if(document.selection.type=="Text"){this.range=document.selection.createRange();if(!this.isDescendantOrSelf(this.container,this.range.parentElement())){return}this.selectionText=this.range.text}}if(this.selectionText.strip()==""){this.selectionText=false}},isDescendantOrSelf:function(b,c){return b==c||Element.descendantOf(c,b)},computeContext:function(){if(window.getSelection){this.computeContextFF()}else{this.computeContextIE()}},highlightSelection:function(c){if(!this.range){return}if(window.getSelection){var b=new Element("span",{style:"background-color: "+c,"class":"selection-highlight"});var d=this.getRangeTextNodes();window.getSelection().removeAllRanges();this.highlightWrappers=new Array();d.each(function(f){var e=b.clone();e.update(f.textContent.escapeHTML());f.parentNode.replaceChild(e,f);this.highlightWrappers.push(e)}.bind(this))}else{this.selectionParent=this.range.parentElement();this.selectionParentInnerHTML=this.selectionParent.innerHTML;this.range.execCommand("BackColor",false,c)}},getRangeTextNodes:function(){var h=this.range.startContainer;var i=this.range.endContainer;var b=this.range.startOffset;var f=this.range.endOffset;var e=this.getFirstLeafInRange(this.range);var d=this.getLastLeafInRange(this.range);var c=this.getLeafsBetween(e,d);var g=c.findAll(function(j){return j.nodeType==3});if(h==g[0]&&b!=0){g[0]=h.splitText(b);if(h==i){f=f-b;i=g[0]}}if(i==g[g.length-1]&&f!=i.length){i=i.splitText(f)}return g},getLeafsBetween:function(d,b){var c=new Array();var e=d;c.push(d);while(e!=b){e=this.getNextLeaf(e);c.push(e)}return c},getFirstLeafInRange:function(b){if(b.startContainer.hasChildNodes()){if(b.collapsed){return null}else{if(b.startOffset>=b.startContainer.childNodes.length){return this.getNextLeaf(b.startContainer)}else{return this.getFirstLeaf(b.startContainer.childNodes[b.startOffset])}}}else{return b.startContainer}},getLastLeafInRange:function(b){if(b.endContainer.hasChildNodes()){if(b.collapsed){return null}else{if(b.endOffset==0){return this.getPreviousLeaf(b.endContainer)}else{return this.getLastLeaf(b.endContainer.childNodes[b.endOffset-1])}}}else{return b.endContainer}},getNextLeaf:function(c){var b=c;while(b!=null&&b.nextSibling==null){b=b.parentNode}if(b==null){return null}else{return this.getFirstLeaf(b.nextSibling)}},getPreviousLeaf:function(c){var b=c;while(b!=null&&b.previousSibling==null){b=b.parentNode}if(b==null){return null}else{return this.getLastLeaf(b.previousSibling)}},getFirstLeaf:function(c){var b=c;while(b.hasChildNodes()){b=b.firstChild}return b},getLastLeaf:function(c){var b=c;while(b.hasChildNodes()){b=b.lastChild}return b},removeSelectionHighlight:function(){if(window.getSelection){this.highlightWrappers.each(function(b){b.replace(b.innerHTML)})}else{this.selectionParent.update(this.selectionParentInnerHTML)}},getPositionNextToSelection:function(){if(!this.range){return{left:0,top:0}}var d=0;var c=0;if(window.getSelection){if(this.highlightWrappers.length>0){d=this.highlightWrappers[0].cumulativeOffset().left;var b=this.highlightWrappers[this.highlightWrappers.length-1];c=b.cumulativeOffset().top+b.getHeight()}}else{d=this.offsetX;c=this.offsetY}return{left:d,top:c}},getRightDocument:function(b){var d="";if(b==this.container){d=this.getRightDocument(b.parentNode)}for(var c=b.nextSibling;c!=null;c=c.nextSibling){d+=c.textContent}return d},getLeftDocument:function(d){var e="";if(d==this.container){e=this.getLeftDocument(d.parentNode)}var c=d.parentNode;if(c.childNodes){for(var b=0;b<c.childNodes.length&&c.childNodes[b]!=d;++b){e+=c.childNodes[b].textContent}}return e},computeContextFF:function(){var d=this.getLeftDocument(this.range.startContainer)+this.range.startContainer.textContent.substring(0,this.range.startOffset);var h="";var j=this.range.endContainer.textContent.substring(this.range.endOffset,this.range.endContainer.textContent.length)+this.getRightDocument(this.range.endContainer);var i="";var g=0;var c=this.range.toString();var m=0;var b=0;while(i!=j||h!=d){var f=this.container.textContent.indexOf(c);var e=this.container.textContent.indexOf(c,f+1);if(e==-1){break}m=Math.min(d.length,m+this.step);b=Math.min(j.length,b+this.step);i=j.substring(0,b);h=d.substring(d.length-m,d.length)}this.selectionContext=h+this.selectionText+i;this.selectionOffset=Math.max(h.length,0)},computeContextIE:function(){var d=this.container.innerText;var f=this.range.duplicate();var e=0;var c=true;while(!this.isUnique(d,f.text)&&c){var c=false;var b=f.text.length;f.moveStart("word",-1);if(!this.isDescendantOrSelf(this.container,f.parentElement())){f.moveStart("word",1)}else{e+=f.text.length-b;c=true}f.moveEnd("word",1);if(!this.isDescendantOrSelf(this.container,f.parentElement())){f.moveEnd("word",-1)}else{c=true}}this.selectionContext=f.text;this.selectionOffset=e},isUnique:function(b,c){var d=b.indexOf(c);if(d>=0){return b.indexOf(c,d+1)<0}return true}});return a}(XWiki||{}));var XWiki=(function(a){a.Annotation=Class.create({annotatedElement:false,annTabname:"Comments",annTabTemplate:"commentsinline.vm",fetchedAnnotations:false,displayingAnnotations:false,displayAnnotationsCheckbox:false,displayedByDefault:false,displayHighlight:true,addAnnotationShortcuts:["Ctrl+M","Meta+M","Ctrl+I","Meta+I"],toggleAnnotationsShortcuts:["Alt+A"],closeDialogShortcuts:["Esc"],selectionService:false,bubbles:new Array(),currentFilter:{},initialize:function(d,c,b){this.displayHighlight=d;this.annotatedElement=c;this.displayedByDefault=b;if(!this.annotatedElement){if(this.displayedByDefault){new a.widgets.Notification("Impossible de charger les annotations : leur contenu n'est pas disponible.","warning")}return}this.hookMenuButton();document.observe("xwiki:docextra:loaded",this.addDeleteListenersInTab.bindAsEventListener(this));document.observe("xwiki:docextra:loaded",this.addEditListenersInTab.bindAsEventListener(this));document.observe("xwiki:docextra:loaded",this.addValidateListenersInTab.bindAsEventListener(this));document.observe("xwiki:annotation:tab:deleted",this.refreshAnnotationsOnCommentDelete.bindAsEventListener(this));this.registerAddAnnotationShortcut();this.registerToggleAnnotationsShortcut();this.registerCloseDialogShortcut();this.selectionService=new a.Selection(this.annotatedElement);document.observe("xwiki:annotations:filter:changed",this.onFilterChange.bindAsEventListener(this));if(this.displayedByDefault){if(a.docsyntax!="xwiki/1.0"){this.fetchAnnotations(true)}else{new a.widgets.Notification("Les annotations ne sont pas disponibles pour les documents rédigés en syntaxe XWiki 1.0.","warning")}}},hookMenuButton:function(){var b=$("tmAnnotationsTrigger");if(b){b.observe("click",this.toggleSettingsPanel.bind(this))}else{var e=$("contentmenu");if(e){var d=e.down(".rightmenu");if(!d){d=new Element("div",{"class":"rightmenu"});var g=e.down(".leftmenu");if(g){g.insert({before:d})}else{e.insert({bottom:d})}}var f=new Element("div",{"class":"topmenuentry hasIcon",id:"tmAnnotations"});var c=new Element("a",{"class":"tme",href:"#"+this.annTabname});c.update("<strong>Annotations</strong>");f.insert({top:c});d.insert({bottom:f});c.observe("click",this.toggleSettingsPanel.bind(this))}}},setAnnotationVisibility:function(b){this.displayingAnnotations=b;if(this.displayAnnotationsCheckbox){this.displayAnnotationsCheckbox.checked=b}},toggleSettingsPanel:function(b){var c=b.element();b.stop();if(c.disabled){return}if(window.document.body.hasClassName("skin-flamingo")){$("tmMoreActions").removeClassName("open")}if(!this.settingsPanel){new Ajax.Request("/AnnotationCode/Settings?xpage=plain",{parameters:{target:a.currentWiki+":"+a.currentSpace+"."+a.currentPage},onCreate:function(){c.disabled=true;c._x_notification=new a.widgets.Notification("Chargement des paramètres pour les annotations","inprogress")},onSuccess:function(e){if(window.document.body.hasClassName("skin-flamingo")){var d=$$(".xcontent > hr")[0];d.insert({after:e.responseText});this.settingsPanel=d.next()}else{$("contentmenu").insert({after:e.responseText});this.settingsPanel=$("contentmenu").next()}this.settingsPanel.fire("xwiki:annotations:settings:loaded");c._x_notification.hide();this.displayAnnotationsCheckbox=$("annotationsdisplay");if(this.displayedByDefault||this.displayingAnnotations){this.displayAnnotationsCheckbox.checked=true}this.attachSettingsListeners();$("tmAnnotations").toggleClassName("active")}.bind(this),onFailure:function(d){var e=d.statusText;if(d.statusText==""||d.status==12031){e="Server not responding"}c._x_notification.replace(new a.widgets.Notification("Erreur :"+e,"error",{timeout:5}))},on0:function(d){d.request.options.onFailure(d)},onComplete:function(){c.disabled=false}})}else{this.settingsPanel.toggleClassName("hidden");$("tmAnnotations").toggleClassName("active")}},attachSettingsListeners:function(){this.displayAnnotationsCheckbox.observe("click",function(b){var c=this.displayAnnotationsCheckbox.checked;if(this.displayAnnotationsCheckbox.disabled){return}this.displayAnnotationsCheckbox.disabled=true;if(!this.fetchedAnnotations&&c){this.fetchAnnotations(true)}else{this.toggleAnnotations(c);this.displayAnnotationsCheckbox.disabled=false}}.bindAsEventListener(this))},toggleAnnotations:function(b){if(this.displayHighlight){this.annotatedElement.select(".annotation").invoke(b?"addClassName":"removeClassName","annotation-highlight")}this.annotatedElement.select(".annotation-marker").invoke(b?"removeClassName":"addClassName","hidden");this.displayingAnnotations=b;if(!b){this.bubbles.each(function(c){if(c!=this.createPanel){c.remove()}}.bind(this));this.bubbles.clear()}},toggleAnnotationHighlight:function(b,c){this.annotatedElement.select(".annotation.ID"+b).invoke(c?"addClassName":"removeClassName","annotation-highlight")},onFilterChange:function(b){if(b.memo){this.currentFilter=b.memo}var c=this.displayAnnotationsCheckbox?this.displayAnnotationsCheckbox.checked:false;if(c){this.fetchAnnotations(true)}},getExtraFields:function(){return[]},getFilter:function(){return this.currentFilter},prepareRequestParameters:function(d){var g=this.getFilter();for(var c=0;c<g.length;c++){var f=g[c];var e="filter_"+f.name;if(!d.get(e)){d.set(e,[])}d.get(e).push(f.value)}var b=this.getExtraFields();if(b.size()>0){d.set("request_field",[])}for(var c=0;c<b.length;c++){d.get("request_field").push(b[c])}return d},fetchAnnotations:function(b,c){require(["xwiki-meta"],function(e){var d=e.restURL+"/annotations?media=json";new Ajax.Request(d,{method:"GET",parameters:this.prepareRequestParameters(new Hash()),onCreate:function(){this._x_notification=new a.widgets.Notification("Chargement des annotations","inprogress")}.bind(this),onSuccess:function(f){if(this.checkResponseCodeAndFail(f)){return}this._x_notification.hide();this.loadAnnotatedContent(f.responseJSON.annotatedContent,b,false,c);this.fetchedAnnotations=true;if(this.displayAnnotationsCheckbox){this.displayAnnotationsCheckbox.checked=true}}.bind(this),onFailure:function(f){var g=f.statusText;if(f.statusText==""||f.status==12031){g="Server not responding"}this._x_notification.replace(new a.widgets.Notification("Erreur :"+g,"error",{timeout:5}));if(this.displayAnnotationsCheckbox){this.displayAnnotationsCheckbox.checked=false}}.bind(this),on0:function(f){f.request.options.onFailure(f)}.bind(this),onComplete:function(){if(this.displayAnnotationsCheckbox){this.displayAnnotationsCheckbox.disabled=false}}.bind(this)})}.bind(this))},checkResponseCodeAndFail:function(b){if(b.responseJSON&&b.responseJSON.responseCode!=null&&b.responseJSON.responseCode==0){return false}else{if(b.responseJSON){b.statusText=b.responseJSON.responseMessage}else{b.statusText="Réponse serveur mal formatée"}b.request.options.onFailure(b);return true}},loadAnnotatedContent:function(b,c,e,d){if((b.annotations&&b.annotations.size()>0)||d){this.annotatedElement.update(b.content);this.addAnnotationMarkers(b.annotations);document.fire("xwiki:dom:updated",{elements:[this.annotatedElement]});this.reloadTab(e)}if(c){this.toggleAnnotations(true)}},reloadTab:function(c){var b=$(this.annTabname+"pane");if(b){b.update("");b.addClassName("empty");if(!b.hasClassName("hidden")){a.displayDocExtra(this.annTabname,this.annTabTemplate,c)}}},addDeleteListenersInTab:function(){$$("#Annotationspane .annotation a.delete").each(function(b){this.addDeleteListener(b)}.bind(this))},addEditListenersInTab:function(){$$("#Annotationspane .annotation a.edit").each(function(c){var b=c.up(".annotation");var d=b.id.substring(16);this.addEditListener(c,d,b.up())}.bind(this))},addValidateListenersInTab:function(){$$(".annotation a.validate").each(function(c){var b=c.up(".annotation");var d=b.id.substring(16);this.addValidateListener(c,d,b)}.bind(this))},addDeleteListener:function(d,c,b){d.observe("click",function(e){d.blur();e.stop();if(d.disabled){return}else{new a.widgets.ConfirmedAjaxRequest(d.href,{parameters:this.prepareRequestParameters(new Hash()),onCreate:function(){d.disabled=true},onSuccess:function(f){if(this.checkResponseCodeAndFail(f)){return}if(c){this.hideBubble(b)}this.fetchedAnnotations=true;this.loadAnnotatedContent(f.responseJSON.annotatedContent,this.displayAnnotationsCheckbox?this.displayAnnotationsCheckbox.checked:this.displayedByDefault,!c,true)}.bind(this),onComplete:function(){d.disabled=false}},{confirmationText:"Etes-vous certain de vouloir supprimer cette annotation ?",progressMessageText:"Suppression de l'annotation...",successMessageText:"Annotation supprimée",failureMessageText:"Impossible de supprimer l'annotation :"})}}.bindAsEventListener(this))},addValidateListener:function(d,e,b,c){d.observe("click",function(f){d.blur();f.stop();this.updateAnnotationAsync(b,e,c,d.href,"POST",new Hash({state:"SAFE",originalSelection:""}),{successText:"L'annotation a été enregistrée",failureText:"Erreur :"})}.bindAsEventListener(this))},addEditListener:function(d,e,b,c){d.observe("click",function(f){d.blur();f.stop();if(d.disabled){return}else{require(["xwiki-meta"],function(g){new Ajax.Request("/AnnotationCode/EditForm",{parameters:{xpage:"plain",wiki:a.currentWiki,space:a.currentSpace,page:a.currentPage,reference:g.document,id:e},onCreate:function(){b.originalContentHTML=b.innerHTML;d.disabled=true;b.update(new Element("div",{"class":"loading"}))},onSuccess:function(h){this.fillEditForm(b,h.responseText,e,c)}.bind(this),onFailure:function(h){var i=h.statusText;if(h.statusText==""||h.status==12031){i="Server not responding"}this._x_notification=new a.widgets.Notification("annotations.action.edit.form.loaderror"+i,"error",{timeout:5});this.fillViewPanel(b,b.originalContentHTML,e,c)}.bind(this),on0:function(h){h.request.options.onFailure(h)}.bind(this),onComplete:function(){d.disabled=false}})}.bind(this))}}.bindAsEventListener(this))},addAnnotationMarkers:function(b){b.each(function(e){var f=this.annotatedElement.select("[class~=ID"+e.annotationId+"]");if(f.size()==0){return}var d=f[f.size()-1];var c=new Element("span",{id:"ID"+e.annotationId,"class":"hidden annotation-marker "+e.state});d.insert({after:c});c.observe("click",this.onMarkerClick.bindAsEventListener(this,e.annotationId))}.bind(this))},onMarkerClick:function(d,e){var c="annotation-bubble-"+e;var b=$(c);if(!this.displayHighlight){this.toggleAnnotationHighlight(e,!b)}if(b){this.hideBubble(b)}else{var b=this.displayLoadingBubble(d.element().cumulativeOffset().top,d.element().cumulativeOffset().left);b.writeAttribute("id",c);this.fetchAndShowAnnotationDetails(e,b)}},fetchAndShowAnnotationDetails:function(c,b){require(["xwiki-meta"],function(d){new Ajax.Request("/AnnotationCode/DisplayForm",{parameters:{id:c,xpage:"plain",wiki:a.currentWiki,space:a.currentSpace,page:a.currentPage,reference:d.document},onSuccess:function(e){this.fillViewPanel(b,e.responseText,c,true)}.bind(this),onFailure:function(e){var f=e.statusText;if(e.statusText==""||e.status==12031){f="Server not responding"}this.hideBubble(newBubble);this._x_notification=new a.widgets.Notification("Erreur :"+f,"error",{timeout:5})}.bind(this),on0:function(e){e.request.options.onFailure(e)}.bind(this)})}.bind(this))},displayLoadingBubble:function(d,c){var b=new Element("div",{"class":"annotation-bubble"});b.insert({top:new Element("div",{"class":"loading"})});document.body.insert({bottom:b});b.toggleClassName("hidden");b.style.left=c+"px";b.style.top=d+"px";b.toggleClassName("hidden");this.bubbles.push(b);return b},displayAnnotationViewBubble:function(b){},safeUpdate:function(b,c){if(!b.parentNode){return false}b.update(c);return true},fillEditForm:function(c,e,f,d){if(!this.safeUpdate(c,e)){return}c.stopObserving("mouseout");var g=c.down("a.delete");if(g){this.addDeleteListener(g,d,c)}var b=c.down("a.validate");if(b){this.addValidateListener(b,f,c,d)}c.down("form").focusFirstElement();c.down("input[type=submit]").observe("click",this.onAnnotationEdit.bindAsEventListener(this,c,f,d));c.down("input[type=reset]").observe("click",function(h){if(d){this.hideBubble(c)}else{this.fillViewPanel(c,c.originalContentHTML,f,false)}}.bindAsEventListener(this))},onAnnotationEdit:function(e,b,f,d){e.stop();var c=b.down("form");var g=new Hash(c.serialize(true));this.updateAnnotationAsync(b,f,d,c.action,c.method,g,{successText:"L'annotation a été mise à jour",failureText:"Erreur :"})},updateAnnotationAsync:function(b,g,e,f,h,d,c){new Ajax.Request(f,{method:h,parameters:this.prepareRequestParameters(d),onCreate:function(){if(b.parentNode){b.update(new Element("div",{"class":"loading"}))}},onSuccess:function(i){if(this.checkResponseCodeAndFail(i)){return}this._x_notification=new a.widgets.Notification(c.successText,"done");if(e){this.hideBubble(b)}this.fetchedAnnotations=true;this.loadAnnotatedContent(i.responseJSON.annotatedContent,this.displayAnnotationsCheckbox?this.displayAnnotationsCheckbox.checked:this.displayedByDefault,!e)}.bind(this),onFailure:function(i){var j=i.statusText;if(i.statusText==""||i.status==12031){j="Server not responding"}this._x_notification.replace(new a.widgets.Notification(c.failureText+j,"error",{timeout:5}));if(e){this.hideBubble(b)}else{this.fillViewPanel(b,b.originalContentHTML,g,false)}}.bind(this),on0:function(i){i.request.options.onFailure(i)}})},fillViewPanel:function(b,d,i,e){if(!this.safeUpdate(b,d)){return}var f=b.down("a.delete");if(f){this.addDeleteListener(f,e,b)}var g=b.down("a.validate");if(g){this.addValidateListener(g,i,b,e)}var c=b.down("a.edit");if(c){this.addEditListener(c,i,b,e)}var j=b.down("a.reply");if(j){var h=$$("#Commentspane #xwikicomment_"+i+" a.commentreply")[0];if(!h){j.hide()}else{j.observe("click",function(k){k.stop();h.click();b.blur()})}}},hideBubble:function(b){if(!b.parentNode){return}b.remove();var c=this.bubbles.indexOf(b);if(c>=0){this.bubbles.splice(c,1)}},registerShortcuts:function(b,e){var d="keypress";if(Prototype.Browser.IE||Prototype.Browser.WebKit||browser.isIE11up){d="keyup"}for(var c=0;c<b.size();++c){shortcut.add(b[c],e.bindAsEventListener(this),{type:d})}},unregisterShortcuts:function(b){for(var c=0;c<b.size();++c){shortcut.remove(b[c])}},registerAddAnnotationShortcut:function(){this.registerShortcuts(this.addAnnotationShortcuts,this.onAddAnnotationShortcut)},unregisterAddAnnotationShortcut:function(){this.unregisterShortcuts(this.addAnnotationShortcuts)},registerCloseDialogShortcut:function(){this.registerShortcuts(this.closeDialogShortcuts,this.closeOpenBubble)},registerToggleAnnotationsShortcut:function(){this.registerShortcuts(this.toggleAnnotationsShortcuts,this.onToggleAnnotationsShortcut)},onToggleAnnotationsShortcut:function(){if(this.fetchedAnnotations){this.setAnnotationVisibility(!this.displayingAnnotations);this.toggleAnnotations(this.displayingAnnotations)}else{this.fetchAnnotations(true)}},closeOpenBubble:function(){if(this.bubbles.length>0){var b=this.bubbles[this.bubbles.length-1];if(b==this.createPanel){this.hideAnnotationCreationForm()}else{this.hideBubble(b)}}},onAddAnnotationShortcut:function(){if(a.docsyntax=="xwiki/1.0"){new a.widgets.Notification("Les annotations ne sont pas disponibles pour les documents rédigés en syntaxe XWiki 1.0.","warning");return}this.selectionService.computeSelection();var b=this.selectionService.selectionText;if(!b){new a.widgets.Notification("Merci de sélectionner du texte dans le corps du document.","error",{timeout:5})}else{this.selectionService.computeContext();require(["xwiki-meta"],function(c){new Ajax.Request("/AnnotationCode/CreateForm",{parameters:{xpage:"plain",selection:b,selectionContext:this.selectionService.selectionContext,selectionOffset:this.selectionService.selectionOffset,reference:c.document},onCreate:function(){this.displayAnnotationCreationForm()}.bind(this),onSuccess:function(d){this.fillCreateForm(this.createPanel,d.responseText)}.bind(this),onFailure:function(d){var e=d.statusText;if(d.statusText==""||d.status==12031){e="Server not responding"}this._x_notification=new a.widgets.Notification("Erreur :"+e,"error",{timeout:5});this.hideAnnotationCreationForm()}.bind(this),on0:function(d){d.request.options.onFailure(d)}.bind(this)})}.bind(this))}},displayAnnotationCreationForm:function(){this.selectionService.highlightSelection("#FFEE99");var b=this.selectionService.getPositionNextToSelection();this.createPanel=this.displayLoadingBubble(b.top,b.left);this.unregisterAddAnnotationShortcut()},fillCreateForm:function(b,c){if(!this.safeUpdate(this.createPanel,c)){return}this.createPanel.select("form").first().focusFirstElement();this.createPanel.down("input[type=submit]").observe("click",this.onAnnotationAdd.bindAsEventListener(this));this.createPanel.down("input[type=reset]").observe("click",function(){this.hideAnnotationCreationForm()}.bind(this))},hideAnnotationCreationForm:function(b){this.hideBubble(this.createPanel);if(!b){this.selectionService.removeSelectionHighlight()}this.registerAddAnnotationShortcut()},onAnnotationAdd:function(c){c.stop();var b=this.createPanel.down("form");var d=new Hash(b.serialize(true));new Ajax.Request(b.action,{method:b.method,parameters:this.prepareRequestParameters(d),onCreate:function(){this.createPanel.update(new Element("div",{"class":"loading"}))}.bind(this),onSuccess:function(e){if(this.checkResponseCodeAndFail(e)){return}if(this.displayAnnotationsCheckbox){this.displayAnnotationsCheckbox.checked=true}this.loadAnnotatedContent(e.responseJSON.annotatedContent,true);this.fetchedAnnotations=true;b._x_notification=new a.widgets.Notification("L'annotation a été ajoutée avec succès","done");this.hideAnnotationCreationForm(true)}.bind(this),onFailure:function(e){this.hideAnnotationCreationForm();var f=e.statusText;if(e.statusText==""||e.status==12031){f="Server not responding"}this._x_notification=new a.widgets.Notification("Erreur :"+f,"error",{timeout:5})}.bind(this),on0:function(e){e.request.options.onFailure(e)}})},refreshAnnotationsOnCommentDelete:function(b){var c=this.displayAnnotationsCheckbox?this.displayAnnotationsCheckbox.checked:this.displayedByDefault;if(c){this.fetchAnnotations(true,true)}else{this.fetchedAnnotations=false}}});return a}(XWiki||{}));document.observe("xwiki:dom:loaded",function(){if(XWiki.contextaction!="view"||!$("xwikicontent")){return}var e=true;var d=false;var a=true;var c=[];var b=c.indexOf(XWiki.currentSpace);if((a&&b<0)||(!a&&b>=0)){new XWiki.Annotation(e,$("xwikicontent"),d)}});