Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle toolbar destruction

  • Loading branch information...
commit f1bffa9ec46e74d38c17d150fc602c78f57bb84c 1 parent ab324fc
Henri Bergius authored
4 examples/hallo-min.js
View
@@ -4,5 +4,5 @@ Hallo 1.0.1dev - a rich text editing jQuery UI widget
(c) 2011 Henri Bergius, IKS Consortium
Hallo may be freely distributed under the MIT license
http://hallojs.org
-*/(function(){(function(e){return e.widget("IKS.hallo",{toolbar:null,bound:!1,originalContent:"",previousContent:"",uuid:"",selection:null,_keepActivated:!1,originalHref:null,options:{editable:!0,plugins:{},toolbar:"halloToolbarContextual",parentElement:"body",buttonCssClass:null,toolbarCssClass:null,placeholder:"",forceStructured:!0,checkTouch:!0,touchScreen:null},_create:function(){var t,n,r,i=this;this.id=this._generateUUID(),this.options.checkTouch&&this.options.touchScreen===null&&this.checkTouch(),r=this.options.plugins;for(n in r)t=r[n],e.isPlainObject(t)||(t={}),e.extend(t,{editable:this,uuid:this.id,buttonCssClass:this.options.buttonCssClass}),e(this.element)[n](t);return this.element.one("halloactivated",function(){return i._prepareToolbar()}),this.originalContent=this.getContents()},_init:function(){return this.options.editable?this.enable():this.disable()},destroy:function(){var t,n,r;this.disable(),this.toolbar&&this.toolbar.remove(),r=this.options.plugins;for(n in r)t=r[n],e(this.element)[n]("destroy");return e.Widget.prototype.destroy.call(this)},disable:function(){var t=this;return this.element.attr("contentEditable",!1),this.element.unbind("focus",this._activated),this.element.unbind("blur",this._deactivated),this.element.unbind("keyup paste change",this._checkModified),this.element.unbind("keyup",this._keys),this.element.unbind("keyup mouseup",this._checkSelection),this.bound=!1,e(this.element).removeClass("isModified"),e(this.element).removeClass("inEditMode"),this.element.parents("a").andSelf().each(function(n,r){var i;i=e(r);if(!i.is("a"))return;if(!t.originalHref)return;return i.attr("href",t.originalHref)}),this._trigger("disabled",null)},enable:function(){var t=this;return this.element.parents("a[href]").andSelf().each(function(n,r){var i;i=e(r);if(!i.is("a[href]"))return;return t.originalHref=i.attr("href"),i.removeAttr("href")}),this.element.attr("contentEditable",!0),this.element.html()||(this.element.html(this.options.placeholder),this.element.css({"min-width":this.element.innerWidth(),"min-height":this.element.innerHeight()})),this.bound||(this.element.bind("focus",this,this._activated),this.element.bind("blur",this,this._deactivated),this.element.bind("keyup paste change",this,this._checkModified),this.element.bind("keyup",this,this._keys),this.element.bind("keyup mouseup",this,this._checkSelection),this.bound=!0),this.options.forceStructured&&this._forceStructured(),this._trigger("enabled",null)},activate:function(){return this.element.focus()},containsSelection:function(){var e;return e=this.getSelection(),this.element.has(e.startContainer).length>0},getSelection:function(){var e,t;return t=rangy.getSelection(),e=null,t.rangeCount>0?e=t.getRangeAt(0):e=rangy.createRange(),e},restoreSelection:function(e){var t;return t=rangy.getSelection(),t.setSingleRange(e)},replaceSelection:function(t){var n,r,i,s,o;return e.browser.msie?(o=document.selection.createRange().text,r=document.selection.createRange(),r.pasteHTML(t(o))):(s=window.getSelection(),i=s.getRangeAt(0),n=document.createTextNode(t(i.extractContents())),i.insertNode(n),i.setStartAfter(n),s.removeAllRanges(),s.addRange(i))},removeAllSelections:function(){return e.browser.msie?range.empty():window.getSelection().removeAllRanges()},getContents:function(){var t,n,r;n=this.element.clone();for(r in this.options.plugins){t=e(this.element).data(r).cleanupContentClone;if(!e.isFunction(t))continue;e(this.element)[r]("cleanupContentClone",n)}return n.html()},setContents:function(e){return this.element.html(e)},isModified:function(){return this.previousContent||(this.previousContent=this.originalContent),this.previousContent!==this.getContents()},setUnmodified:function(){return e(this.element).removeClass("isModified"),this.previousContent=this.getContents()},setModified:function(){return e(this.element).addClass("isModified"),this._trigger("modified",null,{editable:this,content:this.getContents()})},restoreOriginalContent:function(){return this.element.html(this.originalContent)},execute:function(e,t){if(document.execCommand(e,!1,t))return this.element.trigger("change")},protectFocusFrom:function(e){var t=this;return e.bind("mousedown",function(e){return e.preventDefault(),t._protectToolbarFocus=!0,setTimeout(function(){return t._protectToolbarFocus=!1},300)})},keepActivated:function(e){this._keepActivated=e},_generateUUID:function(){var e;return e=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},""+e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},_prepareToolbar:function(){var t,n;this.toolbar=e('<div class="hallotoolbar"></div>').hide(),this.options.toolbarCssClass&&this.toolbar.addClass(this.options.toolbarCssClass),this.element[this.options.toolbar]({editable:this,parentElement:this.options.parentElement,toolbar:this.toolbar});for(t in this.options.plugins){n=e(this.element).data(t).populateToolbar;if(!e.isFunction(n))continue;this.element[t]("populateToolbar",this.toolbar)}return this.element[this.options.toolbar]("setPosition"),this.protectFocusFrom(this.toolbar)},changeToolbar:function(e,t,n){var r;n==null&&(n=!1),r=this.options.toolbar,this.options.parentElement=e,t&&(this.options.toolbar=t);if(!this.toolbar)return;this.element[r]("destroy"),this.toolbar.remove(),this._prepareToolbar();if(n)return this.toolbar.hide()},_checkModified:function(e){var t;t=e.data;if(t.isModified())return t.setModified()},_keys:function(e){var t,n;n=e.data;if(e.keyCode===27)return t=n.getContents(),n.restoreOriginalContent(e),n._trigger("restored",null,{editable:n,content:n.getContents(),thrown:t}),n.turnOff()},_rangesEqual:function(e,t){return e.startContainer!==t.startContainer?!1:e.startOffset!==t.startOffset?!1:e.endContainer!==t.endContainer?!1:e.endOffset!==t.endOffset?!1:!0},_checkSelection:function(e){var t;if(e.keyCode===27)return;return t=e.data,setTimeout(function(){var n;n=t.getSelection();if(t._isEmptySelection(n)||t._isEmptyRange(n))if(t.selection){t.selection=null,t._trigger("unselected",null,{editable:t,originalEvent:e});return}if(!t.selection||!t._rangesEqual(n,t.selection))return t.selection=n.cloneRange(),t._trigger("selected",null,{editable:t,selection:t.selection,ranges:[t.selection],originalEvent:e})},0)},_isEmptySelection:function(e){return e.type==="Caret"?!0:!1},_isEmptyRange:function(e){return e.collapsed?!0:e.isCollapsed?typeof e.isCollapsed=="function"?e.isCollapsed():e.isCollapsed:!1},turnOn:function(){return this.getContents()===this.options.placeholder&&this.setContents(""),e(this.element).addClass("inEditMode"),this._trigger("activated",null,this)},turnOff:function(){e(this.element).removeClass("inEditMode"),this._trigger("deactivated",null,this);if(!this.getContents())return this.setContents(this.options.placeholder)},_activated:function(e){return e.data.turnOn()},_deactivated:function(t){if(t.data._keepActivated)return;return t.data._protectToolbarFocus!==!0?t.data.turnOff():setTimeout(function(){return e(t.data.element).focus()},300)},_forceStructured:function(e){try{return document.execCommand("styleWithCSS",0,!1)}catch(t){try{return document.execCommand("useCSS",0,!0)}catch(t){try{return document.execCommand("styleWithCSS",!1,!1)}catch(t){}}}},checkTouch:function(){return this.options.touchScreen="createTouch"in document}})})(jQuery),function(e){return e.widget("IKS.halloindicator",{options:{editable:null,className:"halloEditIndicator"},_create:function(){var e=this;return this.element.bind("halloenabled",function(){return e.buildIndicator()})},populateToolbar:function(){},buildIndicator:function(){var t;return t=e('<div><i class="icon-edit"></i> Edit</div>'),t.addClass(this.options.className),t.hide(),this.element.before(t),this.bindIndicator(t),this.setIndicatorPosition(t)},bindIndicator:function(t){var n=this;return t.bind("click",function(){return n.options.editable.element.focus()}),this.element.bind("halloactivated",function(){return t.hide()}),this.element.bind("hallodisabled",function(){return t.remove()}),this.options.editable.element.hover(function(){if(e(this).hasClass("inEditMode"))return;return t.show()},function(n){if(e(this).hasClass("inEditMode"))return;if(n.relatedTarget===t.get(0))return;return t.hide()})},setIndicatorPosition:function(e){var t;return e.css("position","absolute"),t=this.element.position(),e.css("top",t.top+2),e.css("left",t.left+2)}})}(jQuery),function(e){return e.widget("IKS.hallolists",{options:{editable:null,toolbar:null,uuid:"",lists:{ordered:!0,unordered:!0},buttonCssClass:null},populateToolbar:function(t){var n,r,i=this;return r=e('<span class="'+this.widgetName+'"></span>'),n=function(t,n){var s;return s=e("<span></span>"),s.hallobutton({uuid:i.options.uuid,editable:i.options.editable,label:n,command:"insert"+t+"List",icon:"icon-list-"+n.toLowerCase(),cssClass:i.options.buttonCssClass}),r.append(s)},this.options.lists.ordered&&n("Ordered","OL"),this.options.lists.unordered&&n("Unordered","UL"),r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.halloheadings",{options:{editable:null,toolbar:null,uuid:"",headers:[1,2,3]},populateToolbar:function(t){var n,r,i,s,o,u,a,f,l,c,h,p=this;f=this,i=e('<span class="'+f.widgetName+'"></span>'),o=""+this.options.uuid+"-paragraph",u="P",a='<input id="'+o+'" type="radio" name="'+f.options.uuid+'-headings"/> <label for="'+o+'" class="p_button">'+u+"</label>",i.append(e(a).button()),n=e("#"+o,i),n.attr("hallo-command","formatBlock"),n.bind("change",function(t){var n;return n=e(this).attr("hallo-command"),f.options.editable.execute(n,"P")}),r=function(t){var r;return u="H"+t,o=""+p.options.uuid+"-"+t,r='<input id="'+o+'" type="radio" name="'+f.options.uuid+'-headings"/> <label for="'+o+'" class="h'+t+'_button">'+u+"</label>",i.append(e(r).button()),n=e("#"+o,i),n.attr("hallo-size","H"+t),n.bind("change",function(t){var n;return n=e(this).attr("hallo-size"),f.options.editable.execute("formatBlock",n)})},h=this.options.headers;for(l=0,c=h.length;l<c;l++)s=h[l],r(s);return i.buttonset(),this.element.bind("keyup paste change mouseup",function(t){var n,r,s,o,u;try{n=document.queryCommandValue("formatBlock").toUpperCase()}catch(a){n=""}if(n==="P")u=e("#"+f.options.uuid+"-paragraph");else if(o=n.match(/\d/))r=o[0],u=e("#"+f.options.uuid+"-"+r);s=e(i),s.children("input").attr("checked",!1),s.children("label").removeClass("ui-state-clicked"),s.children("input").button("widget").button("refresh");if(u)return u.attr("checked",!0),u.next("label").addClass("ui-state-clicked"),u.button("refresh")}),t.append(i)}})}(jQuery),function(e){return e.widget("Liip.hallooverlay",{options:{editable:null,toolbar:null,uuid:"",overlay:null,padding:10,background:null},_create:function(){var t;t=this;if(!this.options.bound)return this.options.bound=!0,this.options.editable.element.bind("halloactivated",function(n,r){t.options.currentEditable=e(n.target);if(!t.options.visible)return t.showOverlay()}),this.options.editable.element.bind("hallomodified",function(n,r){t.options.currentEditable=e(n.target);if(t.options.visible)return t.resizeOverlay()}),this.options.editable.element.bind("hallodeactivated",function(n,r){t.options.currentEditable=e(n.target);if(t.options.visible)return t.hideOverlay()})},showOverlay:function(){return this.options.visible=!0,this.options.overlay===null&&(e("#halloOverlay").length>0?this.options.overlay=e("#halloOverlay"):(this.options.overlay=e('<div id="halloOverlay" class="halloOverlay">'),e(document.body).append(this.options.overlay)),this.options.overlay.bind("click",e.proxy(this.options.editable.turnOff,this.options.editable))),this.options.overlay.show(),this.options.background===null&&(e("#halloBackground").length>0?this.options.background=e("#halloBackground"):(this.options.background=e('<div id="halloBackground" class="halloBackground">'),e(document.body).append(this.options.background))),this.resizeOverlay(),this.options.background.show(),this.options.originalZIndex||(this.options.originalZIndex=this.options.currentEditable.css("z-index")),this.options.currentEditable.css("z-index","350")},resizeOverlay:function(){var e;return e=this.options.currentEditable.offset(),this.options.background.css({top:e.top-this.options.padding,left:e.left-this.options.padding,width:this.options.currentEditable.width()+2*this.options.padding,height:this.options.currentEditable.height()+2*this.options.padding})},hideOverlay:function(){return this.options.visible=!1,this.options.overlay.hide(),this.options.background.hide(),this.options.currentEditable.css("z-index",this.options.originalZIndex)},_findBackgroundColor:function(e){var t;return t=e.css("background-color"),t!=="rgba(0, 0, 0, 0)"&&t!=="transparent"?t:e.is("body")?"white":this._findBackgroundColor(e.parent())}})}(jQuery),function(e){return e.widget("IKS.halloimagecurrent",{options:{imageWidget:null,startPlace:"",draggables:[],maxWidth:400,maxHeight:200},_create:function(){return this.element.html('<div> <div class="activeImageContainer"> <div class="rotationWrapper"> <div class="hintArrow"></div> <img src="" class="activeImage" /> </div> <img src="" class="activeImage activeImageBg" /> </div> <div class="metadata" style="display: none;"> <input type="text" class="caption" name="caption" /> </div> </div>'),this.element.hide(),this._prepareDnD()},_init:function(){var t,n;return t=e(this.options.editable.element),n=this,e("img",t).each(function(e,r){return r.contentEditable=!1,n._initDraggable(r,t)}),e("p",t).each(function(t,r){if(e(r).data("jquery_droppable_initialized"))return;return e(r).droppable({tolerance:"pointer",drop:function(e,t){return n._handleDropEvent(e,t)},over:function(e,t){return n._handleOverEvent(e,t)},out:function(e,t){return n._handleLeaveEvent(e,t)}}),e(r).data("jquery_droppable_initialized",!0)})},_prepareDnD:function(){var t,n,r;return r=this,t=e(this.options.editable.element),this.options.offset=t.offset(),this.options.third=parseFloat(t.width()/3),n={width:this.options.third,height:t.height()},this.overlay={big:e("<div/>").addClass("bigOverlay").css({width:this.options.third*2,height:t.height()}),left:e("<div/>").addClass("smallOverlay smallOverlayLeft"),right:e("<div/>").addClass("smallOverlay smallOverlayRight")},this.overlay.left.css(n),this.overlay.right.css(n).css("left",this.options.third*2),t.bind("halloactivated",function(){return r._enableDragging()}),t.bind("hallodeactivated",function(){return r._disableDragging()})},setImage:function(t){if(!t)return;return this.element.show(),e(".activeImage",this.element).attr("src",t.url),t.label&&(e("input",this.element).val(t.label),e(".metadata",this.element).show()),this._initImage(e(this.options.editable.element))},_delayAction:function(e,t){var n;n=clearTimeout(n);if(!n)return n=setTimeout(e,t)},_calcDropPosition:function(e,t){var n,r;n=e.left+this.options.third,r=e.left+this.options.third*2;if(t.pageX>=n&&t.pageX<=r)return"middle";if(t.pageX<n)return"left";if(t.pageX>r)return"right"},_createInsertElement:function(t,n){var r,i,s,o;return r=e("<img>"),o=new Image,s=this.options.maxWidth,i=this.options.maxHeight,e(o).bind("load",function(){var e,t,n;n=o.width,e=o.height;if(n>s||e>i)n>e?t=(o.width/s).toFixed():t=(o.height/i).toFixed(),n=(o.width/t).toFixed(),e=(o.height/t).toFixed();return r.attr({width:n,height:e})}),o.src=t.src,r.attr({src:o.src,alt:n?void 0:e(t).attr("alt"),"class":n?"halloTmp":""}),r.show(),r},_createLineFeedbackElement:function(){return e("<div/>").addClass("halloTmpLine")},_removeFeedbackElements:function(){return e(".halloTmp, .halloTmpLine",this.options.editable.element).remove()},_removeCustomHelper:function(){return e(".customHelper").remove()},_showOverlay:function(t){var n,r;r=e(this.options.editable.element),n=r.height(),n+=parseFloat(r.css("paddingTop")),n+=parseFloat(r.css("paddingBottom")),this.overlay.big.css({height:n}),this.overlay.left.css({height:n}),this.overlay.right.css({height:n});switch(t){case"left":return this.overlay.big.addClass("bigOverlayLeft"),this.overlay.big.removeClass("bigOverlayRight"),this.overlay.big.css({left:this.options.third}),this.overlay.big.show(),this.overlay.left.hide(),this.overlay.right.hide();case"middle":return this.overlay.big.removeClass("bigOverlayLeft bigOverlayRight"),this.overlay.big.hide(),this.overlay.left.show(),this.overlay.right.show();case"right":return this.overlay.big.addClass("bigOverlayRight"),this.overlay.big.removeClass("bigOverlayLeft"),this.overlay.big.css({left:0}),this.overlay.big.show(),this.overlay.left.hide(),this.overlay.right.hide()}},_checkOrigin:function(t){return e(t.target).parents("[contenteditable]").length!==0?!0:!1},_createFeedback:function(e,t){var n;return t==="middle"?this._createLineFeedbackElement():(n=this._createInsertElement(e,!0),n.addClass("inlineImage-"+t))},_handleOverEvent:function(t,n){var r,i,s;return s=this,r=e(this.options.editable),i=function(){var i,o;return window.waitWithTrash=clearTimeout(window.waitWithTrash),i=s._calcDropPosition(s.options.offset,t),e(".trashcan",n.helper).remove(),r.append(s.overlay.big),r.append(s.overlay.left),r.append(s.overlay.right),s._removeFeedbackElements(),o=e(t.target),o.prepend(s._createFeedback(n.draggable[0],i)),i==="middle"?(o.prepend(s._createFeedback(n.draggable[0],"right")),e(".halloTmp",t.target).hide()):(o.prepend(s._createFeedback(n.draggable[0],"middle")),e(".halloTmpLine",t.target).hide()),s._showOverlay(i)},setTimeout(i,5)},_handleDragEvent:function(t,n){var r,i,s;r=this._calcDropPosition(this.options.offset,t);if(r===this._lastPositionDrag)return;return this._lastPositionDrag=r,i=e(".halloTmp",this.options.editable.element),s=e(".halloTmpLine",this.options.editable.element),r==="middle"?(s.show(),i.hide()):(s.hide(),i.removeClass("inlineImage-left inlineImage-right"),i.addClass("inlineImage-"+r),i.show()),this._showOverlay(r)},_handleLeaveEvent:function(t,n){var r;return r=function(){if(!e("div.trashcan",n.helper).length)return e(n.helper).append(e('<div class="trashcan"></div>')),e(".bigOverlay, .smallOverlay").remove()},window.waitWithTrash=setTimeout(r,200),this._removeFeedbackElements()},_handleStartEvent:function(t,n){var r;return r=this._checkOrigin(t),r&&e(t.target).remove(),e(document).trigger("startPreventSave"),this.options.startPlace=e(t.target)},_handleStopEvent:function(t,n){var r;return r=this._checkOrigin(t),r?e(t.target).remove():e(this.options.editable.element).trigger("change"),this.overlay.big.hide(),this.overlay.left.hide(),this.overlay.right.hide(),e(document).trigger("stopPreventSave")},_handleDropEvent:function(t,n){var r,i,s,o,u,a;return i=e(this.options.editable.element),o=this._checkOrigin(t),a=this._calcDropPosition(this.options.offset,t),this._removeFeedbackElements(),this._removeCustomHelper(),s=this._createInsertElement(n.draggable[0],!1),r="inlineImage-middle inlineImage-left inlineImage-right",a==="middle"?(s.show(),s.removeClass(r),u=i.width(),u+=parseFloat(i.css("paddingLeft")),u+=parseFloat(i.css("paddingRight")),u-=s.attr("width"),s.addClass("inlineImage-"+a).css({position:"relative",left:u/2}),s.insertBefore(e(t.target))):(s.removeClass(r),s.addClass("inlineImage-"+a),s.css("display","block"),e(t.target).prepend(s)),this.overlay.big.hide(),this.overlay.left.hide(),this.overlay.right.hide(),i.trigger("change"),this._initImage(i)},_createHelper:function(t){return e("<div>").css({backgroundImage:"url("+e(t.currentTarget).attr("src")+")"}).addClass("customHelper").appendTo("body")},_initDraggable:function(t,n){var r;return r=this,t.jquery_draggable_initialized||(t.jquery_draggable_initialized=!0,e(t).draggable({cursor:"move",helper:function(e){return r._createHelper(e)},drag:function(e,t){return r._handleDragEvent(e,t)},start:function(e,t){return r._handleStartEvent(e,t)},stop:function(e,t){return r._handleStopEvent(e,t)},disabled:!n.hasClass("inEditMode"),cursorAt:{top:50,left:50}})),r.options.draggables.push(t)},_initImage:function(t){var n;return n=this,e(".rotationWrapper img",this.options.dialog).each(function(e,r){return n._initDraggable(r,t)})},_enableDragging:function(){return e.each(this.options.draggables,function(t,n){return e(n).draggable("option","disabled",!1)})},_disableDragging:function(){return e.each(this.options.draggables,function(t,n){return e(n).draggable("option","disabled",!0)})}})}(jQuery),function(e){return e.widget("IKS.halloimageupload",{options:{uploadCallback:null,uploadUrl:null,imageWidget:null,entity:null},_create:function(){return this.element.html(' <form class="upload"> <input type="file" class="file" name="userfile" accept="image/*" /> <input type="hidden" name="tags" value="" /> <button class="uploadSubmit">Upload</button> </form> ')},_init:function(){var t;return t=this,t.options.uploadUrl&&!t.options.uploadCallback&&(t.options.uploadCallback=t._iframeUpload),e(".uploadSubmit",this.element).bind("click",function(e){return e.preventDefault(),e.stopPropagation(),t.options.uploadCallback({widget:t,success:function(e){return t.options.imageWidget.setCurrent({url:e,label:""})}})})},_prepareIframe:function(t){var n,r;return r=""+t.widgetName+"_postframe_"+t.options.uuid,r=r.replace(/-/g,"_"),n=e("#"+r),n.length?n:(n=e('<iframe name="'+r+'" id="'+r+'" class="hidden" style="display:none" />'),this.element.append(n),n.get(0).name=r,n)},_iframeUpload:function(t){var n,r,i,s;return s=t.widget,n=s._prepareIframe(s),r=e("form.upload",s.element),typeof s.options.uploadUrl=="function"?i=s.options.uploadUrl(s.options.entity):i=s.options.uploadUrl,n.bind("load",function(){var e;return e=n.get(0).contentWindow.location.href,s.element.hide(),t.success(e)}),r.attr("action",i),r.attr("method","post"),r.attr("target",n.get(0).name),r.attr("enctype","multipart/form-data"),r.attr("encoding","multipart/form-data"),r.submit()}})}(jQuery),function(e){return e.widget("IKS.halloimagesearch",{options:{imageWidget:null,searchCallback:null,searchUrl:null,limit:5},_create:function(){return this.element.html('<div> <form method="get"> <input type="text" class="searchInput" /> <input type="submit" class="btn searchButton" value="OK" /> </form> <div class="searchResults imageThumbnailContainer"> <div class="activitySpinner">Loading images...</div> <ul></ul> </div> </div>')},_init:function(){var t=this;return this.options.searchUrl&&!this.options.searchCallback&&(this.options.searchCallback=this._ajaxSearch),e(".activitySpinner",this.element).hide(),e("form",this.element).submit(function(n){var r;return n.preventDefault(),e(".activitySpinner",t.element).show(),r=e(".searchInput",t.element.element).val(),t.options.searchCallback(r,t.options.limit,0,function(e){return t._showResults(e)})})},_showResult:function(t){var n,r=this;return t.label||(t.label=t.alt),n=e('<li> <img src="'+t.url+'" class="imageThumbnail" title="'+t.label+'"></li>'),n.bind("click",function(){return r.options.imageWidget.setCurrent(t)}),e("img",n).bind("mousedown",function(e){return e.preventDefault(),r.options.imageWidget.setCurrent(t)}),e(".imageThumbnailContainer ul",this.element).append(n)},_showNextPrev:function(t){var n,r=this;return n=e("imageThumbnailContainer ul",this.element),n.prepend(e('<div class="pager-prev" style="display:none" />')),n.append(e('<div class="pager-next" style="display:none" />')),t.offset>0&&e(".pager-prev",n).show(),t.offset<t.total&&e(".pager-next",n).show(),e(".pager-prev",n).click(function(e){var n;return n=t.offset-r.options.limit,r.options.searchCallback(query,r.options.limit,n,function(e){return r._showResults(e)})}),e(".pager-next",n).click(function(e){var n;return n=t.offset+r.options.limit,r.options.searchCallback(query,r.options.limit,n,function(e){return r._showResults(e)})})},_showResults:function(t){var n,r,i,s;e(".activitySpinner",this.element).hide(),e(".imageThumbnailContainer ul",this.element).empty(),e(".imageThumbnailContainer ul",this.element).show(),s=t.assets;for(r=0,i=s.length;r<i;r++)n=s[r],this._showResult(n);return this.options.imageWidget.setCurrent(t.assets.shift()),this._showNextPrev(t)},_ajaxSearch:function(t,n,r,i){var s;return s=this.searchUrl+"?"+e.param({q:t,limit:n,offset:r}),e.getJSON(s,i)}})}(jQuery),function(e){return e.widget("IKS.halloimagesuggestions",{loaded:!1,options:{entity:null,vie:null,dbPediaUrl:null,getSuggestions:null,thumbnailUri:"<http://dbpedia.org/ontology/thumbnail>"},_create:function(){return this.element.html(' <div id="'+this.options.uuid+'-tab-suggestions"> <div class="imageThumbnailContainer"> <div class="activitySpinner">Loading images...</div> <ul></ul> </div> </div>')},_init:function(){return e(".activitySpinner",this.element).hide()},_normalizeRelated:function(e){return _.isString(e)?e:_.isArray(e)?e.join(","):e.pluck("@subject").join(",")},_prepareVIE:function(){this.options.vie||(this.options.vie=new VIE);if(this.options.vie.services.dbpedia)return;if(!this.options.dbPediaUrl)return;return this.options.vie.use(new vie.DBPediaService({url:this.options.dbPediaUrl,proxyDisabled:!0}))},_getSuggestions:function(){var t,n,r;if(this.loaded)return;if(!this.options.entity)return;e(".activitySpinner",this.element).show(),r=this.options.entity.get("skos:related");if(r.length===0){e("#activitySpinner").html("No images found.");return}return e(".imageThumbnailContainer ul",this.element).empty(),n=this._normalizeRelated(r),t=this.options.limit,this.options.getSuggestions&&this.options.getSuggestions(n,t,0,this._showSuggestions),this._prepareVIE(),this.options.vie.services.dbpedia&&this._getSuggestionsDbPedia(r),this.loaded=!0},_getSuggestionsDbPedia:function(t){var n,r;return r=this,n=1,_.each(t,function(t){return vie.load({entity:t}).using("dbpedia").execute().done(function(n){return e(".activitySpinner",this.element).hide(),_.each(n,function(e){var n,i;i=e.attributes[r.options.thumbnailUri];if(!i)return;return _.isObject(i)&&(n=i[0].value),_.isString(i)&&(n=r.options.entity.fromReference(i)),r._showSuggestion({url:n,label:t})})})})},_showSuggestion:function(t){var n,r=this;return n=e('<li> <img src="'+t.url+'" class="imageThumbnail" title="'+t.label+'"> </li>'),n.bind("click",function(){return r.options.imageWidget.setCurrent(t)}),e(".imageThumbnailContainer ul",this.element).append(n)},_showSuggestions:function(t){var n=this;return e(".activitySpinner",this.element).hide(),_.each(t,function(e){return n._showSuggestion(e)})}})}(jQuery),function(e){return e.widget("Liip.hallotoolbarlinebreak",{options:{editable:null,uuid:"",breakAfter:[]},populateToolbar:function(t){var n,r,i,s,o,u,a,f,l,c,h;i=e(".ui-buttonset",t),s=e(),u=0,h=this.options.breakAfter;for(a=0,l=h.length;a<l;a++){o=h[a],u++,n='<div class="halloButtonrow halloButtonrow-'+u+'" />';for(f=0,c=i.length;f<c;f++){r=i[f],s=e(s).add(e(r));if(e(r).hasClass(o)){s.wrapAll(n),i=i.not(s),s=e();break}}}if(i.length>0)return u++,n='<div class="halloButtonrow halloButtonrow-'+u+'" />',i.wrapAll(n)}})}(jQuery),function(e){var t;return t=null,this.VIE!==void 0&&(t=new VIE,t.use(new t.StanbolService({proxyDisabled:!0,url:"http://dev.iks-project.eu:8081"}))),e.widget("IKS.halloannotate",{options:{vie:t,editable:null,toolbar:null,uuid:"",select:function(){},decline:function(){},remove:function(){},buttonCssClass:null},_create:function(){var t,n,r;r=this;if(this.options.vie===void 0)throw new Error("The halloannotate plugin requires VIE");if(typeof this.element.annotate!="function")throw new Error("The halloannotate plugin requires annotate.js");return this.state="off",this.instantiate(),n=function(){var t;return t=this,e(t).halloannotate("turnOff")},t=this.options.editable.element,t.bind("hallodisabled",n)},populateToolbar:function(t){var n,r=this;return n=e('<span class="'+this.widgetName+'"></span>'),this.button=n.hallobutton({label:"Annotate",icon:"icon-tags",editable:this.options.editable,command:null,uuid:this.options.uuid,cssClass:this.options.buttonCssClass,queryState:!1}),n.bind("change",function(e){if(r.state==="pending")return;return r.state==="off"?r.turnOn():r.turnOff()}),n.buttonset(),t.append(this.button)},cleanupContentClone:function(t){if(this.state==="on")return t.find(".entity:not([about])").each(function(){return e(this).replaceWith(e(this).html())})},instantiate:function(){var t;return t=this,this.options.editable.element.annotate({vie:this.options.vie,debug:!1,showTooltip:!0,select:this.options.select,remove:this.options.remove,success:this.options.success,error:this.options.error}).bind("annotateselect",function(e,n){return t.options.editable.setModified()}).bind("annotateremove",function(){return e.noop()})},turnPending:function(){return this.state="pending",this.button.hallobutton("checked",!1),this.button.hallobutton("disable")},turnOn:function(){var e,t=this;this.turnPending(),e=this;try{return this.options.editable.element.annotate("enable",function(e){if(!e)return;return t.state="on",t.button.hallobutton("checked",!0),t.button.hallobutton("enable")})}catch(n){return alert(n)}},turnOff:function(){this.options.editable.element.annotate("disable"),this.state="off";if(!this.button)return;return this.button.attr("checked",!1),this.button.find("label").removeClass("ui-state-clicked"),this.button.button("refresh")}})}(jQuery),function(e){return e.widget("IKS.halloblacklist",{options:{tags:[]},_init:function(){if(this.options.tags.indexOf("br")!==-1)return this.element.bind("keydown",function(e){if(e.originalEvent.keyCode===13)return e.preventDefault()})},cleanupContentClone:function(t){var n,r,i,s,o;s=this.options.tags,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],o.push(e(n,t).remove());return o}})}(jQuery),function(e){return e.widget("Liip.halloimage",{options:{editable:null,toolbar:null,uuid:"",limit:8,search:null,searchUrl:null,suggestions:null,loaded:null,upload:null,uploadUrl:null,dialogOpts:{autoOpen:!1,width:270,height:"auto",title:"Insert Images",modal:!1,resizable:!1,draggable:!0,dialogClass:"halloimage-dialog"},dialog:null,buttonCssClass:null,entity:null,vie:null,dbPediaUrl:"http://dev.iks-project.eu/stanbolfull",maxWidth:250,maxHeight:250},populateToolbar:function(t){var n,r,i,s,o,u,a;return this.options.toolbar=t,a=this,i=""+this.options.uuid+"-image-dialog",this.options.dialog=e('<div id="'+i+'"> <div class="nav"> <ul class="tabs"> </ul> <div id="'+this.options.uuid+'-tab-activeIndicator" class="tab-activeIndicator" /> </div> <div class="dialogcontent"> </div>'),u=e(".tabs",this.options.dialog),o=e(".dialogcontent",this.options.dialog),a.options.suggestions&&this._addGuiTabSuggestions(u,o),(a.options.search||a.options.searchUrl)&&this._addGuiTabSearch(u,o),(a.options.upload||a.options.uploadUrl)&&this._addGuiTabUpload(u,o),this.current=e('<div class="currentImage"></div>').halloimagecurrent({uuid:this.options.uuid,imageWidget:this,editable:this.options.editable,dialog:this.options.dialog,maxWidth:this.options.maxWidth,maxHeight:this.options.maxHeight}),e(".dialogcontent",this.options.dialog).append(this.current),r=e('<span class="'+a.widgetName+'"></span>'),s=""+this.options.uuid+"-image",n=e("<span></span>"),n.hallobutton({label:"Images",icon:"icon-picture",editable:this.options.editable,command:null,queryState:!1,uuid:this.options.uuid,cssClass:this.options.buttonCssClass}),r.append(n),this.button=n,this.button.bind("click",function(e){return a.options.dialog.dialog("isOpen")?a._closeDialog():a._openDialog(),!1}),this.options.editable.element.bind("hallodeactivated",function(e){return a._closeDialog()}),e(this.options.editable.element).delegate("img","click",function(e){return a._openDialog()}),r.buttonset(),t.append(r),this.options.dialog.dialog(this.options.dialogOpts),this._handleTabs()},setCurrent:function(e){return this.current.halloimagecurrent("setImage",e)},_handleTabs:function(){var t;return t=this,e(".nav li",this.options.dialog).bind("click",function(){var n,r;return e("."+t.widgetName+"-tab").hide(),n=e(this).attr("id"),e("#"+n+"-content").show(),r=e(this).position().left+e(this).width()/2,e("#"+t.options.uuid+"-tab-activeIndicator").css({"margin-left":r})}),e(".nav li",this.options.dialog).first().click()},_openDialog:function(){var t,n,r,i,s,o,u,a,f=this;return o=this,t=function(){return window.setTimeout(function(){var t;return t=e(".imageThumbnail"),e(t).each(function(){var t;t=e("#"+this.id).width();if(t<=20)return e("#"+
-this.id).parent("li").remove()})},15e3)},i="#"+this.options.uuid+"-tab-suggestions-content",r=function(){return e(".imageThumbnailActive",i).first().attr("src")},e("#"+this.options.uuid+"-sugg-activeImage").attr("src",r()),e("#"+this.options.uuid+"-sugg-activeImageBg").attr("src",r()),this.lastSelection=this.options.editable.getSelection(),n=e(this.options.editable.element),s=e(this.options.toolbar),u=n.offset().left+n.outerWidth()-3,a=s.offset().top-e(document).scrollTop()-29,this.options.dialog.dialog("option","position",[u,a]),t(),o.options.loaded=1,this.options.editable.keepActivated(!0),this.options.dialog.dialog("open"),this.options.dialog.bind("dialogclose",function(){return e("label",f.button).removeClass("ui-state-active"),f.options.editable.element.focus(),f.options.editable.keepActivated(!1)})},_closeDialog:function(){return this.options.dialog.dialog("close")},_addGuiTabSuggestions:function(t,n){var r;return t.append(e('<li id="'+this.options.uuid+'-tab-suggestions" class="'+this.widgetName+"-tabselector "+this.widgetName+'-tab-suggestions"> <span>Suggestions</span> </li>')),r=e('<div id="'+this.options.uuid+'-tab-suggestions-content" class="'+this.widgetName+'-tab tab-suggestions"></div>'),n.append(r),r.halloimagesuggestions({uuid:this.options.uuid,imageWidget:this,entity:this.options.entity})},_addGuiTabSearch:function(t,n){var r,i,s;return s=this,r=""+this.options.uuid+"-image-dialog",t.append(e('<li id="'+this.options.uuid+'-tab-search" class="'+this.widgetName+"-tabselector "+this.widgetName+'-tab-search"> <span>Search</span> </li>')),i=e('<div id="'+this.options.uuid+'-tab-search-content" class="'+s.widgetName+'-tab tab-search"></div>'),n.append(i),i.halloimagesearch({uuid:this.options.uuid,imageWidget:this,searchCallback:this.options.search,searchUrl:this.options.searchUrl,limit:this.options.limit,entity:this.options.entity})},_addGuiTabUpload:function(t,n){var r;return t.append(e('<li id="'+this.options.uuid+'-tab-upload" class="'+this.widgetName+"-tabselector "+this.widgetName+'-tab-upload"> <span>Upload</span> </li>')),r=e('<div id="'+this.options.uuid+'-tab-upload-content" class="'+this.widgetName+'-tab tab-upload"></div>'),n.append(r),r.halloimageupload({uuid:this.options.uuid,uploadCallback:this.options.upload,uploadUrl:this.options.uploadUrl,imageWidget:this,entity:this.options.entity})}})}(jQuery),function(e){return e.widget("IKS.halloformat",{options:{editable:null,uuid:"",formattings:{bold:!0,italic:!0,strikeThrough:!1,underline:!1},buttonCssClass:null},populateToolbar:function(t){var n,r,i,s,o,u,a=this;o=this,r=e('<span class="'+o.widgetName+'"></span>'),n=function(t){var n;return n=e("<span></span>"),n.hallobutton({label:t,editable:a.options.editable,command:t,uuid:a.options.uuid,cssClass:a.options.buttonCssClass}),r.append(n)},u=this.options.formattings;for(s in u){i=u[s];if(!i)continue;n(s)}return r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.halloreundo",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},populateToolbar:function(t){var n,r,i=this;return r=e('<span class="'+this.widgetName+'"></span>'),n=function(t,n){var s;return s=e("<span></span>"),s.hallobutton({uuid:i.options.uuid,editable:i.options.editable,label:n,icon:t==="undo"?"icon-undo":"icon-repeat",command:t,queryState:!1,cssClass:i.options.buttonCssClass}),r.append(s)},n("undo","Undo"),n("redo","Redo"),r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.halloblock",{options:{editable:null,toolbar:null,uuid:"",elements:["h1","h2","h3","p","pre","blockquote"],buttonCssClass:null},populateToolbar:function(t){var n,r,i;return n=e('<span class="'+this.widgetName+'"></span>'),r=""+this.options.uuid+"-"+this.widgetName+"-data",i=this._prepareDropdown(r),t.append(n),n.hallobuttonset(),n.append(i),n.append(this._prepareButton(i))},_prepareDropdown:function(t){var n,r,i,s,o,u,a,f=this;i=e('<div id="'+t+'"></div>'),r=this.options.editable.element.get(0).tagName.toLowerCase(),n=function(t){var n,i,s;return n=e("<button class='blockselector'> <"+t+' class="menu-item">'+t+"</"+t+"> </button>"),r===t&&n.addClass("selected"),r!=="div"&&n.addClass("disabled"),n.bind("click",function(){var r;r=t.toUpperCase();if(n.hasClass("disabled"))return;if(e.browser.msie){f.options.editable.execute("FormatBlock","<"+r+">");return}return f.options.editable.execute("formatBlock",r)}),s=function(e){var r;r=document.queryCommandValue("formatBlock");if(r.toLowerCase()===t){n.addClass("selected");return}return n.removeClass("selected")},i="keyup paste change mouseup",f.options.editable.element.bind(i,s),f.options.editable.element.bind("halloenabled",function(){return f.options.editable.element.bind(i,s)}),f.options.editable.element.bind("hallodisabled",function(){return f.options.editable.element.unbind(i,s)}),n},a=this.options.elements;for(o=0,u=a.length;o<u;o++)s=a[o],i.append(n(s));return i},_prepareButton:function(t){var n;return n=e("<span></span>"),n.hallodropdownbutton({uuid:this.options.uuid,editable:this.options.editable,label:"block",icon:"icon-text-height",target:t,cssClass:this.options.buttonCssClass}),n}})}(jQuery),function(e){return e.widget("IKS.hallolink",{options:{editable:null,uuid:"",link:!0,image:!0,defaultUrl:"http://",dialogOpts:{autoOpen:!1,width:540,height:95,title:"Enter Link",modal:!0,resizable:!1,draggable:!1,dialogClass:"hallolink-dialog"},buttonCssClass:null},populateToolbar:function(t){var n,r,i,s,o,u,a,f,l=this;f=this,s=""+this.options.uuid+"-dialog",i=e('<div id="'+s+'"> <form action="#" method="post" class="linkForm"> <input class="url" type="text" name="url" value="'+this.options.defaultUrl+'" /> <input type="submit" id="addlinkButton" value="Insert" /> </form></div>'),a=e("input[name=url]",i).focus(function(e){return this.select()}),u=function(e){return(new RegExp(/^\s*$/)).test(e)?!0:e===f.options.defaultUrl?!0:!1},o=function(e){var t,n;return e.preventDefault(),t=a.val(),f.options.editable.restoreSelection(f.lastSelection),u(t)?(n=f.lastSelection.startContainer,f.lastSelection.collapsed&&(f.lastSelection.setStartBefore(n),f.lastSelection.setEndAfter(n),window.getSelection().addRange(f.lastSelection)),document.execCommand("unlink",null,"")):((new RegExp(/:\/\//)).test(t)||(t="http://"+t),f.lastSelection.startContainer.parentNode.href===void 0?document.execCommand("createLink",null,t):f.lastSelection.startContainer.parentNode.href=t),f.options.editable.element.trigger("change"),f.options.editable.removeAllSelections(),i.dialog("close"),!1},i.find("form").submit(o),r=e('<span class="'+f.widgetName+'"></span>'),n=function(t){var n,s,o;return o=""+l.options.uuid+"-"+t,s=e("<span></span>"),s.hallobutton({label:"Link",icon:"icon-link",editable:l.options.editable,command:null,queryState:!1,uuid:l.options.uuid,cssClass:l.options.buttonCssClass}),r.append(s),n=s,n.bind("click",function(t){var n;return f.lastSelection=f.options.editable.getSelection(),a=e("input[name=url]",i),n=f.lastSelection.startContainer.parentNode,n.href?(a.val(e(n).attr("href")),e(a[0].form).find("input[type=submit]").val("update")):a.val(f.options.defaultUrl),f.options.editable.keepActivated(!0),i.dialog("open"),i.bind("dialogclose",function(){return e("label",s).removeClass("ui-state-active"),f.options.editable.element.focus(),f.options.editable.keepActivated(!1)}),!1}),l.element.bind("keyup paste change mouseup",function(t){var r,i;i=e(f.options.editable.getSelection().startContainer),i.prop("nodeName")?r=i.prop("nodeName"):r=i.parent().prop("nodeName");if(r&&r.toUpperCase()==="A"){e("label",n).addClass("ui-state-active");return}return e("label",n).removeClass("ui-state-active")})},this.options.link&&n("A");if(this.options.link)return t.append(r),r.hallobuttonset(),i.dialog(this.options.dialogOpts)}})}(jQuery),function(e){return e.widget("IKS.hallojustify",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},populateToolbar:function(t){var n,r,i=this;return r=e('<span class="'+this.widgetName+'"></span>'),n=function(t){var n;return n=e("<span></span>"),n.hallobutton({uuid:i.options.uuid,editable:i.options.editable,label:t,command:"justify"+t,icon:"icon-align-"+t.toLowerCase(),cssClass:i.options.buttonCssClass}),r.append(n)},n("Left"),n("Center"),n("Right"),r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.hallobutton",{button:null,isChecked:!1,options:{uuid:"",label:null,icon:null,editable:null,command:null,queryState:!0,cssClass:null},_create:function(){var e,t,n,r,i,s=this;return(i=(r=this.options).icon)==null&&(r.icon="icon-"+this.options.label.toLowerCase()),t=""+this.options.uuid+"-"+this.options.label,n=this.options,this.button=this._createButton(t,n.command,n.label,n.icon),this.element.append(this.button),this.options.cssClass&&this.button.addClass(this.options.cssClass),this.options.editable.options.touchScreen&&this.button.addClass("btn-large"),this.button.data("hallo-command",this.options.command),e="ui-state-hover",this.button.bind("mouseenter",function(t){if(s.isEnabled())return s.button.addClass(e)}),this.button.bind("mouseleave",function(t){return s.button.removeClass(e)})},_init:function(){var e,t,n,r=this;this.button||(this.button=this._prepareButton()),this.element.append(this.button),n=function(e){if(!r.options.command)return;try{return r.checked(document.queryCommandState(r.options.command))}catch(t){}},this.options.command&&this.button.bind("click",function(e){return r.options.editable.execute(r.options.command),n,!1});if(!this.options.queryState)return;return e=this.options.editable.element,t="keyup paste change mouseup hallomodified",e.bind(t,n),e.bind("halloenabled",function(){return e.bind(t,n)}),e.bind("hallodisabled",function(){return e.unbind(t,n)})},enable:function(){return this.button.removeAttr("disabled")},disable:function(){return this.button.attr("disabled","true")},isEnabled:function(){return this.button.attr("disabled")!=="true"},refresh:function(){return this.isChecked?this.button.addClass("ui-state-active"):this.button.removeClass("ui-state-active")},checked:function(e){return this.isChecked=e,this.refresh()},_createButton:function(t,n,r,i){var s;return s=["ui-button","ui-widget","ui-state-default","ui-corner-all","ui-button-text-only",""+n+"_button"],e('<button id="'+t+'" class="'+s.join(" ")+'" title="'+r+'"> <span class="ui-button-text"> <i class="'+i+'"></i> </span> </button>')}}),e.widget("IKS.hallobuttonset",{buttons:null,_create:function(){return this.element.addClass("ui-buttonset")},_init:function(){return this.refresh()},refresh:function(){var e;return e=this.element.css("direction")==="rtl",this.buttons=this.element.find(".ui-button"),this.buttons.removeClass("ui-corner-all ui-corner-left ui-corner-right"),e?(this.buttons.filter(":first").addClass("ui-corner-right"),this.buttons.filter(":last").addClass("ui-corner-left")):(this.buttons.filter(":first").addClass("ui-corner-left"),this.buttons.filter(":last").addClass("ui-corner-right"))}})}(jQuery),function(e){return e.widget("IKS.hallodropdownbutton",{button:null,options:{uuid:"",label:null,icon:null,editable:null,target:"",cssClass:null},_create:function(){var e,t;return(t=(e=this.options).icon)!=null?t:e.icon="icon-"+this.options.label.toLowerCase()},_init:function(){var t,n=this;return t=e(this.options.target),t.css("position","absolute"),t.addClass("dropdown-menu"),t.hide(),this.button||(this.button=this._prepareButton()),this.button.bind("click",function(){if(t.hasClass("open")){n._hideTarget();return}return n._showTarget()}),t.bind("click",function(){return n._hideTarget()}),this.options.editable.element.bind("hallodeactivated",function(){return n._hideTarget()}),this.element.append(this.button)},_showTarget:function(){var t;return t=e(this.options.target),this._updateTargetPosition(),t.addClass("open"),t.show()},_hideTarget:function(){var t;return t=e(this.options.target),t.removeClass("open"),t.hide()},_updateTargetPosition:function(){var t,n,r,i;return n=e(this.options.target),i=this.button.position(),r=i.top,t=i.left,r+=this.button.outerHeight(),n.css("top",r),n.css("left",t-20)},_prepareButton:function(){var t,n,r;return r=""+this.options.uuid+"-"+this.options.label,n=["ui-button","ui-widget","ui-state-default","ui-corner-all","ui-button-text-only"],t=e('<button id="'+r+'" class="'+n.join(" ")+'" title="'+this.options.label+'"> <i class="'+this.options.icon+'"></i> </button>'),this.options.cssClass&&t.addClass(this.options.cssClass),t.button()}})}(jQuery),function(e){return e.widget("Hallo.halloToolbarContextual",{toolbar:null,options:{parentElement:"body",editable:null,toolbar:null},_create:function(){var t=this;return this.toolbar=this.options.toolbar,e(this.options.parentElement).append(this.toolbar),this._bindEvents(),e(window).resize(function(e){return t._updatePosition(t._getPosition(e))})},_getPosition:function(e,t){var n,r;if(!e)return;n=e.type;switch(n){case"keydown":case"keyup":case"keypress":return this._getCaretPosition(t);case"click":case"mousedown":case"mouseup":return r={top:e.pageY,left:e.pageX}}},_getCaretPosition:function(t){var n,r,i;return i=e("<span/>"),n=rangy.createRange(),n.setStart(t.endContainer,t.endOffset),n.insertNode(i.get(0)),r={top:i.offset().top,left:i.offset().left},i.remove(),r},setPosition:function(){return this.options.parentElement!=="body"&&(this.options.parentElement="body",e(this.options.parentElement).append(this.toolbar)),this.toolbar.css("position","absolute"),this.toolbar.css("top",this.element.offset().top-20),this.toolbar.css("left",this.element.offset().left)},_updatePosition:function(e){if(!e)return;if(!e.top||!e.left)return;return this.toolbar.css("top",e.top),this.toolbar.css("left",e.left)},_bindEvents:function(){var e=this;return this.element.bind("halloselected",function(t,n){var r;r=e._getPosition(n.originalEvent,n.selection);if(!r)return;return e._updatePosition(r),e.toolbar.show()}),this.element.bind("hallounselected",function(t,n){return e.toolbar.hide()}),this.element.bind("hallodeactivated",function(t,n){return e.toolbar.hide()})}})}(jQuery),function(e){return e.widget("Hallo.halloToolbarFixed",{toolbar:null,options:{parentElement:"body",editable:null,toolbar:null},_create:function(){var t,n,r=this;this.toolbar=this.options.toolbar,this.toolbar.show(),e(this.options.parentElement).append(this.toolbar),this._bindEvents(),e(window).resize(function(e){return r._updatePosition(r._getPosition(e))});if(this.options.parentElement==="body"&&!this.options.floating)return t=e(this.element),n=parseFloat(t.css("padding-left")),n+=parseFloat(t.css("padding-right")),n+=parseFloat(t.css("border-left-width")),n+=parseFloat(t.css("border-right-width")),n+=parseFloat(t.css("outline-width"))*2,n+=parseFloat(t.css("outline-offset"))*2,e(this.toolbar).css("width",t.width()+n)},_getPosition:function(e,t){var n,r,i;if(!e)return;return i=parseFloat(this.element.css("outline-width")),n=i+parseFloat(this.element.css("outline-offset")),r={top:this.element.offset().top-this.toolbar.outerHeight()-n,left:this.element.offset().left-n}},_getCaretPosition:function(t){var n,r,i;return i=e("<span/>"),n=rangy.createRange(),n.setStart(t.endContainer,t.endOffset),n.insertNode(i.get(0)),r={top:i.offset().top,left:i.offset().left},i.remove(),r},setPosition:function(){if(this.options.parentElement!=="body")return;return this.toolbar.css("position","absolute"),this.toolbar.css("top",this.element.offset().top-this.toolbar.outerHeight()),this.toolbar.css("left",this.element.offset().left)},_updatePosition:function(e){},_bindEvents:function(){var e=this;return this.element.bind("halloactivated",function(t,n){return e._updatePosition(e._getPosition(t)),e.toolbar.show()}),this.element.bind("hallodeactivated",function(t,n){return e.toolbar.hide()})}})}(jQuery)}).call(this);
+*/(function(){(function(e){return e.widget("IKS.hallo",{toolbar:null,bound:!1,originalContent:"",previousContent:"",uuid:"",selection:null,_keepActivated:!1,originalHref:null,options:{editable:!0,plugins:{},toolbar:"halloToolbarContextual",parentElement:"body",buttonCssClass:null,toolbarCssClass:null,placeholder:"",forceStructured:!0,checkTouch:!0,touchScreen:null},_create:function(){var t,n,r,i=this;this.id=this._generateUUID(),this.options.checkTouch&&this.options.touchScreen===null&&this.checkTouch(),r=this.options.plugins;for(n in r)t=r[n],e.isPlainObject(t)||(t={}),e.extend(t,{editable:this,uuid:this.id,buttonCssClass:this.options.buttonCssClass}),e(this.element)[n](t);return this.element.one("halloactivated",function(){return i._prepareToolbar()}),this.originalContent=this.getContents()},_init:function(){return this.options.editable?this.enable():this.disable()},destroy:function(){var t,n,r;this.disable(),this.toolbar&&(this.toolbar.remove(),this.element[this.options.toolbar]("destroy")),r=this.options.plugins;for(n in r)t=r[n],e(this.element)[n]("destroy");return e.Widget.prototype.destroy.call(this)},disable:function(){var t=this;return this.element.attr("contentEditable",!1),this.element.unbind("focus",this._activated),this.element.unbind("blur",this._deactivated),this.element.unbind("keyup paste change",this._checkModified),this.element.unbind("keyup",this._keys),this.element.unbind("keyup mouseup",this._checkSelection),this.bound=!1,e(this.element).removeClass("isModified"),e(this.element).removeClass("inEditMode"),this.element.parents("a").andSelf().each(function(n,r){var i;i=e(r);if(!i.is("a"))return;if(!t.originalHref)return;return i.attr("href",t.originalHref)}),this._trigger("disabled",null)},enable:function(){var t=this;return this.element.parents("a[href]").andSelf().each(function(n,r){var i;i=e(r);if(!i.is("a[href]"))return;return t.originalHref=i.attr("href"),i.removeAttr("href")}),this.element.attr("contentEditable",!0),this.element.html()||(this.element.html(this.options.placeholder),this.element.css({"min-width":this.element.innerWidth(),"min-height":this.element.innerHeight()})),this.bound||(this.element.bind("focus",this,this._activated),this.element.bind("blur",this,this._deactivated),this.element.bind("keyup paste change",this,this._checkModified),this.element.bind("keyup",this,this._keys),this.element.bind("keyup mouseup",this,this._checkSelection),this.bound=!0),this.options.forceStructured&&this._forceStructured(),this._trigger("enabled",null)},activate:function(){return this.element.focus()},containsSelection:function(){var e;return e=this.getSelection(),this.element.has(e.startContainer).length>0},getSelection:function(){var e,t;return t=rangy.getSelection(),e=null,t.rangeCount>0?e=t.getRangeAt(0):e=rangy.createRange(),e},restoreSelection:function(e){var t;return t=rangy.getSelection(),t.setSingleRange(e)},replaceSelection:function(t){var n,r,i,s,o;return e.browser.msie?(o=document.selection.createRange().text,r=document.selection.createRange(),r.pasteHTML(t(o))):(s=window.getSelection(),i=s.getRangeAt(0),n=document.createTextNode(t(i.extractContents())),i.insertNode(n),i.setStartAfter(n),s.removeAllRanges(),s.addRange(i))},removeAllSelections:function(){return e.browser.msie?range.empty():window.getSelection().removeAllRanges()},getContents:function(){var t,n,r;n=this.element.clone();for(r in this.options.plugins){t=e(this.element).data(r).cleanupContentClone;if(!e.isFunction(t))continue;e(this.element)[r]("cleanupContentClone",n)}return n.html()},setContents:function(e){return this.element.html(e)},isModified:function(){return this.previousContent||(this.previousContent=this.originalContent),this.previousContent!==this.getContents()},setUnmodified:function(){return e(this.element).removeClass("isModified"),this.previousContent=this.getContents()},setModified:function(){return e(this.element).addClass("isModified"),this._trigger("modified",null,{editable:this,content:this.getContents()})},restoreOriginalContent:function(){return this.element.html(this.originalContent)},execute:function(e,t){if(document.execCommand(e,!1,t))return this.element.trigger("change")},protectFocusFrom:function(e){var t=this;return e.bind("mousedown",function(e){return e.preventDefault(),t._protectToolbarFocus=!0,setTimeout(function(){return t._protectToolbarFocus=!1},300)})},keepActivated:function(e){this._keepActivated=e},_generateUUID:function(){var e;return e=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},""+e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},_prepareToolbar:function(){var t,n;this.toolbar=e('<div class="hallotoolbar"></div>').hide(),this.options.toolbarCssClass&&this.toolbar.addClass(this.options.toolbarCssClass),this.element[this.options.toolbar]({editable:this,parentElement:this.options.parentElement,toolbar:this.toolbar});for(t in this.options.plugins){n=e(this.element).data(t).populateToolbar;if(!e.isFunction(n))continue;this.element[t]("populateToolbar",this.toolbar)}return this.element[this.options.toolbar]("setPosition"),this.protectFocusFrom(this.toolbar)},changeToolbar:function(e,t,n){var r;n==null&&(n=!1),r=this.options.toolbar,this.options.parentElement=e,t&&(this.options.toolbar=t);if(!this.toolbar)return;this.element[r]("destroy"),this.toolbar.remove(),this._prepareToolbar();if(n)return this.toolbar.hide()},_checkModified:function(e){var t;t=e.data;if(t.isModified())return t.setModified()},_keys:function(e){var t,n;n=e.data;if(e.keyCode===27)return t=n.getContents(),n.restoreOriginalContent(e),n._trigger("restored",null,{editable:n,content:n.getContents(),thrown:t}),n.turnOff()},_rangesEqual:function(e,t){return e.startContainer!==t.startContainer?!1:e.startOffset!==t.startOffset?!1:e.endContainer!==t.endContainer?!1:e.endOffset!==t.endOffset?!1:!0},_checkSelection:function(e){var t;if(e.keyCode===27)return;return t=e.data,setTimeout(function(){var n;n=t.getSelection();if(t._isEmptySelection(n)||t._isEmptyRange(n))if(t.selection){t.selection=null,t._trigger("unselected",null,{editable:t,originalEvent:e});return}if(!t.selection||!t._rangesEqual(n,t.selection))return t.selection=n.cloneRange(),t._trigger("selected",null,{editable:t,selection:t.selection,ranges:[t.selection],originalEvent:e})},0)},_isEmptySelection:function(e){return e.type==="Caret"?!0:!1},_isEmptyRange:function(e){return e.collapsed?!0:e.isCollapsed?typeof e.isCollapsed=="function"?e.isCollapsed():e.isCollapsed:!1},turnOn:function(){return this.getContents()===this.options.placeholder&&this.setContents(""),e(this.element).addClass("inEditMode"),this._trigger("activated",null,this)},turnOff:function(){e(this.element).removeClass("inEditMode"),this._trigger("deactivated",null,this);if(!this.getContents())return this.setContents(this.options.placeholder)},_activated:function(e){return e.data.turnOn()},_deactivated:function(t){if(t.data._keepActivated)return;return t.data._protectToolbarFocus!==!0?t.data.turnOff():setTimeout(function(){return e(t.data.element).focus()},300)},_forceStructured:function(e){try{return document.execCommand("styleWithCSS",0,!1)}catch(t){try{return document.execCommand("useCSS",0,!0)}catch(t){try{return document.execCommand("styleWithCSS",!1,!1)}catch(t){}}}},checkTouch:function(){return this.options.touchScreen="createTouch"in document}})})(jQuery),function(e){return e.widget("IKS.halloindicator",{options:{editable:null,className:"halloEditIndicator"},_create:function(){var e=this;return this.element.bind("halloenabled",function(){return e.buildIndicator()})},populateToolbar:function(){},buildIndicator:function(){var t;return t=e('<div><i class="icon-edit"></i> Edit</div>'),t.addClass(this.options.className),t.hide(),this.element.before(t),this.bindIndicator(t),this.setIndicatorPosition(t)},bindIndicator:function(t){var n=this;return t.bind("click",function(){return n.options.editable.element.focus()}),this.element.bind("halloactivated",function(){return t.hide()}),this.element.bind("hallodisabled",function(){return t.remove()}),this.options.editable.element.hover(function(){if(e(this).hasClass("inEditMode"))return;return t.show()},function(n){if(e(this).hasClass("inEditMode"))return;if(n.relatedTarget===t.get(0))return;return t.hide()})},setIndicatorPosition:function(e){var t;return e.css("position","absolute"),t=this.element.position(),e.css("top",t.top+2),e.css("left",t.left+2)}})}(jQuery),function(e){return e.widget("IKS.hallolists",{options:{editable:null,toolbar:null,uuid:"",lists:{ordered:!0,unordered:!0},buttonCssClass:null},populateToolbar:function(t){var n,r,i=this;return r=e('<span class="'+this.widgetName+'"></span>'),n=function(t,n){var s;return s=e("<span></span>"),s.hallobutton({uuid:i.options.uuid,editable:i.options.editable,label:n,command:"insert"+t+"List",icon:"icon-list-"+n.toLowerCase(),cssClass:i.options.buttonCssClass}),r.append(s)},this.options.lists.ordered&&n("Ordered","OL"),this.options.lists.unordered&&n("Unordered","UL"),r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.halloheadings",{options:{editable:null,toolbar:null,uuid:"",headers:[1,2,3]},populateToolbar:function(t){var n,r,i,s,o,u,a,f,l,c,h,p=this;f=this,i=e('<span class="'+f.widgetName+'"></span>'),o=""+this.options.uuid+"-paragraph",u="P",a='<input id="'+o+'" type="radio" name="'+f.options.uuid+'-headings"/> <label for="'+o+'" class="p_button">'+u+"</label>",i.append(e(a).button()),n=e("#"+o,i),n.attr("hallo-command","formatBlock"),n.bind("change",function(t){var n;return n=e(this).attr("hallo-command"),f.options.editable.execute(n,"P")}),r=function(t){var r;return u="H"+t,o=""+p.options.uuid+"-"+t,r='<input id="'+o+'" type="radio" name="'+f.options.uuid+'-headings"/> <label for="'+o+'" class="h'+t+'_button">'+u+"</label>",i.append(e(r).button()),n=e("#"+o,i),n.attr("hallo-size","H"+t),n.bind("change",function(t){var n;return n=e(this).attr("hallo-size"),f.options.editable.execute("formatBlock",n)})},h=this.options.headers;for(l=0,c=h.length;l<c;l++)s=h[l],r(s);return i.buttonset(),this.element.bind("keyup paste change mouseup",function(t){var n,r,s,o,u;try{n=document.queryCommandValue("formatBlock").toUpperCase()}catch(a){n=""}if(n==="P")u=e("#"+f.options.uuid+"-paragraph");else if(o=n.match(/\d/))r=o[0],u=e("#"+f.options.uuid+"-"+r);s=e(i),s.children("input").attr("checked",!1),s.children("label").removeClass("ui-state-clicked"),s.children("input").button("widget").button("refresh");if(u)return u.attr("checked",!0),u.next("label").addClass("ui-state-clicked"),u.button("refresh")}),t.append(i)}})}(jQuery),function(e){return e.widget("Liip.hallooverlay",{options:{editable:null,toolbar:null,uuid:"",overlay:null,padding:10,background:null},_create:function(){var t;t=this;if(!this.options.bound)return this.options.bound=!0,this.options.editable.element.bind("halloactivated",function(n,r){t.options.currentEditable=e(n.target);if(!t.options.visible)return t.showOverlay()}),this.options.editable.element.bind("hallomodified",function(n,r){t.options.currentEditable=e(n.target);if(t.options.visible)return t.resizeOverlay()}),this.options.editable.element.bind("hallodeactivated",function(n,r){t.options.currentEditable=e(n.target);if(t.options.visible)return t.hideOverlay()})},showOverlay:function(){return this.options.visible=!0,this.options.overlay===null&&(e("#halloOverlay").length>0?this.options.overlay=e("#halloOverlay"):(this.options.overlay=e('<div id="halloOverlay" class="halloOverlay">'),e(document.body).append(this.options.overlay)),this.options.overlay.bind("click",e.proxy(this.options.editable.turnOff,this.options.editable))),this.options.overlay.show(),this.options.background===null&&(e("#halloBackground").length>0?this.options.background=e("#halloBackground"):(this.options.background=e('<div id="halloBackground" class="halloBackground">'),e(document.body).append(this.options.background))),this.resizeOverlay(),this.options.background.show(),this.options.originalZIndex||(this.options.originalZIndex=this.options.currentEditable.css("z-index")),this.options.currentEditable.css("z-index","350")},resizeOverlay:function(){var e;return e=this.options.currentEditable.offset(),this.options.background.css({top:e.top-this.options.padding,left:e.left-this.options.padding,width:this.options.currentEditable.width()+2*this.options.padding,height:this.options.currentEditable.height()+2*this.options.padding})},hideOverlay:function(){return this.options.visible=!1,this.options.overlay.hide(),this.options.background.hide(),this.options.currentEditable.css("z-index",this.options.originalZIndex)},_findBackgroundColor:function(e){var t;return t=e.css("background-color"),t!=="rgba(0, 0, 0, 0)"&&t!=="transparent"?t:e.is("body")?"white":this._findBackgroundColor(e.parent())}})}(jQuery),function(e){return e.widget("IKS.halloimagecurrent",{options:{imageWidget:null,startPlace:"",draggables:[],maxWidth:400,maxHeight:200},_create:function(){return this.element.html('<div> <div class="activeImageContainer"> <div class="rotationWrapper"> <div class="hintArrow"></div> <img src="" class="activeImage" /> </div> <img src="" class="activeImage activeImageBg" /> </div> <div class="metadata" style="display: none;"> <input type="text" class="caption" name="caption" /> </div> </div>'),this.element.hide(),this._prepareDnD()},_init:function(){var t,n;return t=e(this.options.editable.element),n=this,e("img",t).each(function(e,r){return r.contentEditable=!1,n._initDraggable(r,t)}),e("p",t).each(function(t,r){if(e(r).data("jquery_droppable_initialized"))return;return e(r).droppable({tolerance:"pointer",drop:function(e,t){return n._handleDropEvent(e,t)},over:function(e,t){return n._handleOverEvent(e,t)},out:function(e,t){return n._handleLeaveEvent(e,t)}}),e(r).data("jquery_droppable_initialized",!0)})},_prepareDnD:function(){var t,n,r;return r=this,t=e(this.options.editable.element),this.options.offset=t.offset(),this.options.third=parseFloat(t.width()/3),n={width:this.options.third,height:t.height()},this.overlay={big:e("<div/>").addClass("bigOverlay").css({width:this.options.third*2,height:t.height()}),left:e("<div/>").addClass("smallOverlay smallOverlayLeft"),right:e("<div/>").addClass("smallOverlay smallOverlayRight")},this.overlay.left.css(n),this.overlay.right.css(n).css("left",this.options.third*2),t.bind("halloactivated",function(){return r._enableDragging()}),t.bind("hallodeactivated",function(){return r._disableDragging()})},setImage:function(t){if(!t)return;return this.element.show(),e(".activeImage",this.element).attr("src",t.url),t.label&&(e("input",this.element).val(t.label),e(".metadata",this.element).show()),this._initImage(e(this.options.editable.element))},_delayAction:function(e,t){var n;n=clearTimeout(n);if(!n)return n=setTimeout(e,t)},_calcDropPosition:function(e,t){var n,r;n=e.left+this.options.third,r=e.left+this.options.third*2;if(t.pageX>=n&&t.pageX<=r)return"middle";if(t.pageX<n)return"left";if(t.pageX>r)return"right"},_createInsertElement:function(t,n){var r,i,s,o;return r=e("<img>"),o=new Image,s=this.options.maxWidth,i=this.options.maxHeight,e(o).bind("load",function(){var e,t,n;n=o.width,e=o.height;if(n>s||e>i)n>e?t=(o.width/s).toFixed():t=(o.height/i).toFixed(),n=(o.width/t).toFixed(),e=(o.height/t).toFixed();return r.attr({width:n,height:e})}),o.src=t.src,r.attr({src:o.src,alt:n?void 0:e(t).attr("alt"),"class":n?"halloTmp":""}),r.show(),r},_createLineFeedbackElement:function(){return e("<div/>").addClass("halloTmpLine")},_removeFeedbackElements:function(){return e(".halloTmp, .halloTmpLine",this.options.editable.element).remove()},_removeCustomHelper:function(){return e(".customHelper").remove()},_showOverlay:function(t){var n,r;r=e(this.options.editable.element),n=r.height(),n+=parseFloat(r.css("paddingTop")),n+=parseFloat(r.css("paddingBottom")),this.overlay.big.css({height:n}),this.overlay.left.css({height:n}),this.overlay.right.css({height:n});switch(t){case"left":return this.overlay.big.addClass("bigOverlayLeft"),this.overlay.big.removeClass("bigOverlayRight"),this.overlay.big.css({left:this.options.third}),this.overlay.big.show(),this.overlay.left.hide(),this.overlay.right.hide();case"middle":return this.overlay.big.removeClass("bigOverlayLeft bigOverlayRight"),this.overlay.big.hide(),this.overlay.left.show(),this.overlay.right.show();case"right":return this.overlay.big.addClass("bigOverlayRight"),this.overlay.big.removeClass("bigOverlayLeft"),this.overlay.big.css({left:0}),this.overlay.big.show(),this.overlay.left.hide(),this.overlay.right.hide()}},_checkOrigin:function(t){return e(t.target).parents("[contenteditable]").length!==0?!0:!1},_createFeedback:function(e,t){var n;return t==="middle"?this._createLineFeedbackElement():(n=this._createInsertElement(e,!0),n.addClass("inlineImage-"+t))},_handleOverEvent:function(t,n){var r,i,s;return s=this,r=e(this.options.editable),i=function(){var i,o;return window.waitWithTrash=clearTimeout(window.waitWithTrash),i=s._calcDropPosition(s.options.offset,t),e(".trashcan",n.helper).remove(),r.append(s.overlay.big),r.append(s.overlay.left),r.append(s.overlay.right),s._removeFeedbackElements(),o=e(t.target),o.prepend(s._createFeedback(n.draggable[0],i)),i==="middle"?(o.prepend(s._createFeedback(n.draggable[0],"right")),e(".halloTmp",t.target).hide()):(o.prepend(s._createFeedback(n.draggable[0],"middle")),e(".halloTmpLine",t.target).hide()),s._showOverlay(i)},setTimeout(i,5)},_handleDragEvent:function(t,n){var r,i,s;r=this._calcDropPosition(this.options.offset,t);if(r===this._lastPositionDrag)return;return this._lastPositionDrag=r,i=e(".halloTmp",this.options.editable.element),s=e(".halloTmpLine",this.options.editable.element),r==="middle"?(s.show(),i.hide()):(s.hide(),i.removeClass("inlineImage-left inlineImage-right"),i.addClass("inlineImage-"+r),i.show()),this._showOverlay(r)},_handleLeaveEvent:function(t,n){var r;return r=function(){if(!e("div.trashcan",n.helper).length)return e(n.helper).append(e('<div class="trashcan"></div>')),e(".bigOverlay, .smallOverlay").remove()},window.waitWithTrash=setTimeout(r,200),this._removeFeedbackElements()},_handleStartEvent:function(t,n){var r;return r=this._checkOrigin(t),r&&e(t.target).remove(),e(document).trigger("startPreventSave"),this.options.startPlace=e(t.target)},_handleStopEvent:function(t,n){var r;return r=this._checkOrigin(t),r?e(t.target).remove():e(this.options.editable.element).trigger("change"),this.overlay.big.hide(),this.overlay.left.hide(),this.overlay.right.hide(),e(document).trigger("stopPreventSave")},_handleDropEvent:function(t,n){var r,i,s,o,u,a;return i=e(this.options.editable.element),o=this._checkOrigin(t),a=this._calcDropPosition(this.options.offset,t),this._removeFeedbackElements(),this._removeCustomHelper(),s=this._createInsertElement(n.draggable[0],!1),r="inlineImage-middle inlineImage-left inlineImage-right",a==="middle"?(s.show(),s.removeClass(r),u=i.width(),u+=parseFloat(i.css("paddingLeft")),u+=parseFloat(i.css("paddingRight")),u-=s.attr("width"),s.addClass("inlineImage-"+a).css({position:"relative",left:u/2}),s.insertBefore(e(t.target))):(s.removeClass(r),s.addClass("inlineImage-"+a),s.css("display","block"),e(t.target).prepend(s)),this.overlay.big.hide(),this.overlay.left.hide(),this.overlay.right.hide(),i.trigger("change"),this._initImage(i)},_createHelper:function(t){return e("<div>").css({backgroundImage:"url("+e(t.currentTarget).attr("src")+")"}).addClass("customHelper").appendTo("body")},_initDraggable:function(t,n){var r;return r=this,t.jquery_draggable_initialized||(t.jquery_draggable_initialized=!0,e(t).draggable({cursor:"move",helper:function(e){return r._createHelper(e)},drag:function(e,t){return r._handleDragEvent(e,t)},start:function(e,t){return r._handleStartEvent(e,t)},stop:function(e,t){return r._handleStopEvent(e,t)},disabled:!n.hasClass("inEditMode"),cursorAt:{top:50,left:50}})),r.options.draggables.push(t)},_initImage:function(t){var n;return n=this,e(".rotationWrapper img",this.options.dialog).each(function(e,r){return n._initDraggable(r,t)})},_enableDragging:function(){return e.each(this.options.draggables,function(t,n){return e(n).draggable("option","disabled",!1)})},_disableDragging:function(){return e.each(this.options.draggables,function(t,n){return e(n).draggable("option","disabled",!0)})}})}(jQuery),function(e){return e.widget("IKS.halloimageupload",{options:{uploadCallback:null,uploadUrl:null,imageWidget:null,entity:null},_create:function(){return this.element.html(' <form class="upload"> <input type="file" class="file" name="userfile" accept="image/*" /> <input type="hidden" name="tags" value="" /> <button class="uploadSubmit">Upload</button> </form> ')},_init:function(){var t;return t=this,t.options.uploadUrl&&!t.options.uploadCallback&&(t.options.uploadCallback=t._iframeUpload),e(".uploadSubmit",this.element).bind("click",function(e){return e.preventDefault(),e.stopPropagation(),t.options.uploadCallback({widget:t,success:function(e){return t.options.imageWidget.setCurrent({url:e,label:""})}})})},_prepareIframe:function(t){var n,r;return r=""+t.widgetName+"_postframe_"+t.options.uuid,r=r.replace(/-/g,"_"),n=e("#"+r),n.length?n:(n=e('<iframe name="'+r+'" id="'+r+'" class="hidden" style="display:none" />'),this.element.append(n),n.get(0).name=r,n)},_iframeUpload:function(t){var n,r,i,s;return s=t.widget,n=s._prepareIframe(s),r=e("form.upload",s.element),typeof s.options.uploadUrl=="function"?i=s.options.uploadUrl(s.options.entity):i=s.options.uploadUrl,n.bind("load",function(){var e;return e=n.get(0).contentWindow.location.href,s.element.hide(),t.success(e)}),r.attr("action",i),r.attr("method","post"),r.attr("target",n.get(0).name),r.attr("enctype","multipart/form-data"),r.attr("encoding","multipart/form-data"),r.submit()}})}(jQuery),function(e){return e.widget("IKS.halloimagesearch",{options:{imageWidget:null,searchCallback:null,searchUrl:null,limit:5},_create:function(){return this.element.html('<div> <form method="get"> <input type="text" class="searchInput" /> <input type="submit" class="btn searchButton" value="OK" /> </form> <div class="searchResults imageThumbnailContainer"> <div class="activitySpinner">Loading images...</div> <ul></ul> </div> </div>')},_init:function(){var t=this;return this.options.searchUrl&&!this.options.searchCallback&&(this.options.searchCallback=this._ajaxSearch),e(".activitySpinner",this.element).hide(),e("form",this.element).submit(function(n){var r;return n.preventDefault(),e(".activitySpinner",t.element).show(),r=e(".searchInput",t.element.element).val(),t.options.searchCallback(r,t.options.limit,0,function(e){return t._showResults(e)})})},_showResult:function(t){var n,r=this;return t.label||(t.label=t.alt),n=e('<li> <img src="'+t.url+'" class="imageThumbnail" title="'+t.label+'"></li>'),n.bind("click",function(){return r.options.imageWidget.setCurrent(t)}),e("img",n).bind("mousedown",function(e){return e.preventDefault(),r.options.imageWidget.setCurrent(t)}),e(".imageThumbnailContainer ul",this.element).append(n)},_showNextPrev:function(t){var n,r=this;return n=e("imageThumbnailContainer ul",this.element),n.prepend(e('<div class="pager-prev" style="display:none" />')),n.append(e('<div class="pager-next" style="display:none" />')),t.offset>0&&e(".pager-prev",n).show(),t.offset<t.total&&e(".pager-next",n).show(),e(".pager-prev",n).click(function(e){var n;return n=t.offset-r.options.limit,r.options.searchCallback(query,r.options.limit,n,function(e){return r._showResults(e)})}),e(".pager-next",n).click(function(e){var n;return n=t.offset+r.options.limit,r.options.searchCallback(query,r.options.limit,n,function(e){return r._showResults(e)})})},_showResults:function(t){var n,r,i,s;e(".activitySpinner",this.element).hide(),e(".imageThumbnailContainer ul",this.element).empty(),e(".imageThumbnailContainer ul",this.element).show(),s=t.assets;for(r=0,i=s.length;r<i;r++)n=s[r],this._showResult(n);return this.options.imageWidget.setCurrent(t.assets.shift()),this._showNextPrev(t)},_ajaxSearch:function(t,n,r,i){var s;return s=this.searchUrl+"?"+e.param({q:t,limit:n,offset:r}),e.getJSON(s,i)}})}(jQuery),function(e){return e.widget("IKS.halloimagesuggestions",{loaded:!1,options:{entity:null,vie:null,dbPediaUrl:null,getSuggestions:null,thumbnailUri:"<http://dbpedia.org/ontology/thumbnail>"},_create:function(){return this.element.html(' <div id="'+this.options.uuid+'-tab-suggestions"> <div class="imageThumbnailContainer"> <div class="activitySpinner">Loading images...</div> <ul></ul> </div> </div>')},_init:function(){return e(".activitySpinner",this.element).hide()},_normalizeRelated:function(e){return _.isString(e)?e:_.isArray(e)?e.join(","):e.pluck("@subject").join(",")},_prepareVIE:function(){this.options.vie||(this.options.vie=new VIE);if(this.options.vie.services.dbpedia)return;if(!this.options.dbPediaUrl)return;return this.options.vie.use(new vie.DBPediaService({url:this.options.dbPediaUrl,proxyDisabled:!0}))},_getSuggestions:function(){var t,n,r;if(this.loaded)return;if(!this.options.entity)return;e(".activitySpinner",this.element).show(),r=this.options.entity.get("skos:related");if(r.length===0){e("#activitySpinner").html("No images found.");return}return e(".imageThumbnailContainer ul",this.element).empty(),n=this._normalizeRelated(r),t=this.options.limit,this.options.getSuggestions&&this.options.getSuggestions(n,t,0,this._showSuggestions),this._prepareVIE(),this.options.vie.services.dbpedia&&this._getSuggestionsDbPedia(r),this.loaded=!0},_getSuggestionsDbPedia:function(t){var n,r;return r=this,n=1,_.each(t,function(t){return vie.load({entity:t}).using("dbpedia").execute().done(function(n){return e(".activitySpinner",this.element).hide(),_.each(n,function(e){var n,i;i=e.attributes[r.options.thumbnailUri];if(!i)return;return _.isObject(i)&&(n=i[0].value),_.isString(i)&&(n=r.options.entity.fromReference(i)),r._showSuggestion({url:n,label:t})})})})},_showSuggestion:function(t){var n,r=this;return n=e('<li> <img src="'+t.url+'" class="imageThumbnail" title="'+t.label+'"> </li>'),n.bind("click",function(){return r.options.imageWidget.setCurrent(t)}),e(".imageThumbnailContainer ul",this.element).append(n)},_showSuggestions:function(t){var n=this;return e(".activitySpinner",this.element).hide(),_.each(t,function(e){return n._showSuggestion(e)})}})}(jQuery),function(e){return e.widget("Liip.hallotoolbarlinebreak",{options:{editable:null,uuid:"",breakAfter:[]},populateToolbar:function(t){var n,r,i,s,o,u,a,f,l,c,h;i=e(".ui-buttonset",t),s=e(),u=0,h=this.options.breakAfter;for(a=0,l=h.length;a<l;a++){o=h[a],u++,n='<div class="halloButtonrow halloButtonrow-'+u+'" />';for(f=0,c=i.length;f<c;f++){r=i[f],s=e(s).add(e(r));if(e(r).hasClass(o)){s.wrapAll(n),i=i.not(s),s=e();break}}}if(i.length>0)return u++,n='<div class="halloButtonrow halloButtonrow-'+u+'" />',i.wrapAll(n)}})}(jQuery),function(e){var t;return t=null,this.VIE!==void 0&&(t=new VIE,t.use(new t.StanbolService({proxyDisabled:!0,url:"http://dev.iks-project.eu:8081"}))),e.widget("IKS.halloannotate",{options:{vie:t,editable:null,toolbar:null,uuid:"",select:function(){},decline:function(){},remove:function(){},buttonCssClass:null},_create:function(){var t,n,r;r=this;if(this.options.vie===void 0)throw new Error("The halloannotate plugin requires VIE");if(typeof this.element.annotate!="function")throw new Error("The halloannotate plugin requires annotate.js");return this.state="off",this.instantiate(),n=function(){var t;return t=this,e(t).halloannotate("turnOff")},t=this.options.editable.element,t.bind("hallodisabled",n)},populateToolbar:function(t){var n,r=this;return n=e('<span class="'+this.widgetName+'"></span>'),this.button=n.hallobutton({label:"Annotate",icon:"icon-tags",editable:this.options.editable,command:null,uuid:this.options.uuid,cssClass:this.options.buttonCssClass,queryState:!1}),n.bind("change",function(e){if(r.state==="pending")return;return r.state==="off"?r.turnOn():r.turnOff()}),n.buttonset(),t.append(this.button)},cleanupContentClone:function(t){if(this.state==="on")return t.find(".entity:not([about])").each(function(){return e(this).replaceWith(e(this).html())})},instantiate:function(){var t;return t=this,this.options.editable.element.annotate({vie:this.options.vie,debug:!1,showTooltip:!0,select:this.options.select,remove:this.options.remove,success:this.options.success,error:this.options.error}).bind("annotateselect",function(e,n){return t.options.editable.setModified()}).bind("annotateremove",function(){return e.noop()})},turnPending:function(){return this.state="pending",this.button.hallobutton("checked",!1),this.button.hallobutton("disable")},turnOn:function(){var e,t=this;this.turnPending(),e=this;try{return this.options.editable.element.annotate("enable",function(e){if(!e)return;return t.state="on",t.button.hallobutton("checked",!0),t.button.hallobutton("enable")})}catch(n){return alert(n)}},turnOff:function(){this.options.editable.element.annotate("disable"),this.state="off";if(!this.button)return;return this.button.attr("checked",!1),this.button.find("label").removeClass("ui-state-clicked"),this.button.button("refresh")}})}(jQuery),function(e){return e.widget("IKS.halloblacklist",{options:{tags:[]},_init:function(){if(this.options.tags.indexOf("br")!==-1)return this.element.bind("keydown",function(e){if(e.originalEvent.keyCode===13)return e.preventDefault()})},cleanupContentClone:function(t){var n,r,i,s,o;s=this.options.tags,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],o.push(e(n,t).remove());return o}})}(jQuery),function(e){return e.widget("Liip.halloimage",{options:{editable:null,toolbar:null,uuid:"",limit:8,search:null,searchUrl:null,suggestions:null,loaded:null,upload:null,uploadUrl:null,dialogOpts:{autoOpen:!1,width:270,height:"auto",title:"Insert Images",modal:!1,resizable:!1,draggable:!0,dialogClass:"halloimage-dialog"},dialog:null,buttonCssClass:null,entity:null,vie:null,dbPediaUrl:"http://dev.iks-project.eu/stanbolfull",maxWidth:250,maxHeight:250},populateToolbar:function(t){var n,r,i,s,o,u,a;return this.options.toolbar=t,a=this,i=""+this.options.uuid+"-image-dialog",this.options.dialog=e('<div id="'+i+'"> <div class="nav"> <ul class="tabs"> </ul> <div id="'+this.options.uuid+'-tab-activeIndicator" class="tab-activeIndicator" /> </div> <div class="dialogcontent"> </div>'),u=e(".tabs",this.options.dialog),o=e(".dialogcontent",this.options.dialog),a.options.suggestions&&this._addGuiTabSuggestions(u,o),(a.options.search||a.options.searchUrl)&&this._addGuiTabSearch(u,o),(a.options.upload||a.options.uploadUrl)&&this._addGuiTabUpload(u,o),this.current=e('<div class="currentImage"></div>').halloimagecurrent({uuid:this.options.uuid,imageWidget:this,editable:this.options.editable,dialog:this.options.dialog,maxWidth:this.options.maxWidth,maxHeight:this.options.maxHeight}),e(".dialogcontent",this.options.dialog).append(this.current),r=e('<span class="'+a.widgetName+'"></span>'),s=""+this.options.uuid+"-image",n=e("<span></span>"),n.hallobutton({label:"Images",icon:"icon-picture",editable:this.options.editable,command:null,queryState:!1,uuid:this.options.uuid,cssClass:this.options.buttonCssClass}),r.append(n),this.button=n,this.button.bind("click",function(e){return a.options.dialog.dialog("isOpen")?a._closeDialog():a._openDialog(),!1}),this.options.editable.element.bind("hallodeactivated",function(e){return a._closeDialog()}),e(this.options.editable.element).delegate("img","click",function(e){return a._openDialog()}),r.buttonset(),t.append(r),this.options.dialog.dialog(this.options.dialogOpts),this._handleTabs()},setCurrent:function(e){return this.current.halloimagecurrent("setImage",e)},_handleTabs:function(){var t;return t=this,e(".nav li",this.options.dialog).bind("click",function(){var n,r;return e("."+t.widgetName+"-tab").hide(),n=e(this).attr("id"),e("#"+n+"-content").show(),r=e(this).position().left+e(this).width()/2,e("#"+t.options.uuid+"-tab-activeIndicator").css({"margin-left":r})}),e(".nav li",this.options.dialog).first().click()},_openDialog:function(){var t,n,r,i,s,o,u,a,f=this;return o=this,t=function(){return window.setTimeout(function(){var t;return t=e(".imageThumbnail"),e(t).each(function(){var t
+;t=e("#"+this.id).width();if(t<=20)return e("#"+this.id).parent("li").remove()})},15e3)},i="#"+this.options.uuid+"-tab-suggestions-content",r=function(){return e(".imageThumbnailActive",i).first().attr("src")},e("#"+this.options.uuid+"-sugg-activeImage").attr("src",r()),e("#"+this.options.uuid+"-sugg-activeImageBg").attr("src",r()),this.lastSelection=this.options.editable.getSelection(),n=e(this.options.editable.element),s=e(this.options.toolbar),u=n.offset().left+n.outerWidth()-3,a=s.offset().top-e(document).scrollTop()-29,this.options.dialog.dialog("option","position",[u,a]),t(),o.options.loaded=1,this.options.editable.keepActivated(!0),this.options.dialog.dialog("open"),this.options.dialog.bind("dialogclose",function(){return e("label",f.button).removeClass("ui-state-active"),f.options.editable.element.focus(),f.options.editable.keepActivated(!1)})},_closeDialog:function(){return this.options.dialog.dialog("close")},_addGuiTabSuggestions:function(t,n){var r;return t.append(e('<li id="'+this.options.uuid+'-tab-suggestions" class="'+this.widgetName+"-tabselector "+this.widgetName+'-tab-suggestions"> <span>Suggestions</span> </li>')),r=e('<div id="'+this.options.uuid+'-tab-suggestions-content" class="'+this.widgetName+'-tab tab-suggestions"></div>'),n.append(r),r.halloimagesuggestions({uuid:this.options.uuid,imageWidget:this,entity:this.options.entity})},_addGuiTabSearch:function(t,n){var r,i,s;return s=this,r=""+this.options.uuid+"-image-dialog",t.append(e('<li id="'+this.options.uuid+'-tab-search" class="'+this.widgetName+"-tabselector "+this.widgetName+'-tab-search"> <span>Search</span> </li>')),i=e('<div id="'+this.options.uuid+'-tab-search-content" class="'+s.widgetName+'-tab tab-search"></div>'),n.append(i),i.halloimagesearch({uuid:this.options.uuid,imageWidget:this,searchCallback:this.options.search,searchUrl:this.options.searchUrl,limit:this.options.limit,entity:this.options.entity})},_addGuiTabUpload:function(t,n){var r;return t.append(e('<li id="'+this.options.uuid+'-tab-upload" class="'+this.widgetName+"-tabselector "+this.widgetName+'-tab-upload"> <span>Upload</span> </li>')),r=e('<div id="'+this.options.uuid+'-tab-upload-content" class="'+this.widgetName+'-tab tab-upload"></div>'),n.append(r),r.halloimageupload({uuid:this.options.uuid,uploadCallback:this.options.upload,uploadUrl:this.options.uploadUrl,imageWidget:this,entity:this.options.entity})}})}(jQuery),function(e){return e.widget("IKS.halloformat",{options:{editable:null,uuid:"",formattings:{bold:!0,italic:!0,strikeThrough:!1,underline:!1},buttonCssClass:null},populateToolbar:function(t){var n,r,i,s,o,u,a=this;o=this,r=e('<span class="'+o.widgetName+'"></span>'),n=function(t){var n;return n=e("<span></span>"),n.hallobutton({label:t,editable:a.options.editable,command:t,uuid:a.options.uuid,cssClass:a.options.buttonCssClass}),r.append(n)},u=this.options.formattings;for(s in u){i=u[s];if(!i)continue;n(s)}return r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.halloreundo",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},populateToolbar:function(t){var n,r,i=this;return r=e('<span class="'+this.widgetName+'"></span>'),n=function(t,n){var s;return s=e("<span></span>"),s.hallobutton({uuid:i.options.uuid,editable:i.options.editable,label:n,icon:t==="undo"?"icon-undo":"icon-repeat",command:t,queryState:!1,cssClass:i.options.buttonCssClass}),r.append(s)},n("undo","Undo"),n("redo","Redo"),r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.halloblock",{options:{editable:null,toolbar:null,uuid:"",elements:["h1","h2","h3","p","pre","blockquote"],buttonCssClass:null},populateToolbar:function(t){var n,r,i;return n=e('<span class="'+this.widgetName+'"></span>'),r=""+this.options.uuid+"-"+this.widgetName+"-data",i=this._prepareDropdown(r),t.append(n),n.hallobuttonset(),n.append(i),n.append(this._prepareButton(i))},_prepareDropdown:function(t){var n,r,i,s,o,u,a,f=this;i=e('<div id="'+t+'"></div>'),r=this.options.editable.element.get(0).tagName.toLowerCase(),n=function(t){var n,i,s;return n=e("<button class='blockselector'> <"+t+' class="menu-item">'+t+"</"+t+"> </button>"),r===t&&n.addClass("selected"),r!=="div"&&n.addClass("disabled"),n.bind("click",function(){var r;r=t.toUpperCase();if(n.hasClass("disabled"))return;if(e.browser.msie){f.options.editable.execute("FormatBlock","<"+r+">");return}return f.options.editable.execute("formatBlock",r)}),s=function(e){var r;r=document.queryCommandValue("formatBlock");if(r.toLowerCase()===t){n.addClass("selected");return}return n.removeClass("selected")},i="keyup paste change mouseup",f.options.editable.element.bind(i,s),f.options.editable.element.bind("halloenabled",function(){return f.options.editable.element.bind(i,s)}),f.options.editable.element.bind("hallodisabled",function(){return f.options.editable.element.unbind(i,s)}),n},a=this.options.elements;for(o=0,u=a.length;o<u;o++)s=a[o],i.append(n(s));return i},_prepareButton:function(t){var n;return n=e("<span></span>"),n.hallodropdownbutton({uuid:this.options.uuid,editable:this.options.editable,label:"block",icon:"icon-text-height",target:t,cssClass:this.options.buttonCssClass}),n}})}(jQuery),function(e){return e.widget("IKS.hallolink",{options:{editable:null,uuid:"",link:!0,image:!0,defaultUrl:"http://",dialogOpts:{autoOpen:!1,width:540,height:95,title:"Enter Link",modal:!0,resizable:!1,draggable:!1,dialogClass:"hallolink-dialog"},buttonCssClass:null},populateToolbar:function(t){var n,r,i,s,o,u,a,f,l=this;f=this,s=""+this.options.uuid+"-dialog",i=e('<div id="'+s+'"> <form action="#" method="post" class="linkForm"> <input class="url" type="text" name="url" value="'+this.options.defaultUrl+'" /> <input type="submit" id="addlinkButton" value="Insert" /> </form></div>'),a=e("input[name=url]",i).focus(function(e){return this.select()}),u=function(e){return(new RegExp(/^\s*$/)).test(e)?!0:e===f.options.defaultUrl?!0:!1},o=function(e){var t,n;return e.preventDefault(),t=a.val(),f.options.editable.restoreSelection(f.lastSelection),u(t)?(n=f.lastSelection.startContainer,f.lastSelection.collapsed&&(f.lastSelection.setStartBefore(n),f.lastSelection.setEndAfter(n),window.getSelection().addRange(f.lastSelection)),document.execCommand("unlink",null,"")):((new RegExp(/:\/\//)).test(t)||(t="http://"+t),f.lastSelection.startContainer.parentNode.href===void 0?document.execCommand("createLink",null,t):f.lastSelection.startContainer.parentNode.href=t),f.options.editable.element.trigger("change"),f.options.editable.removeAllSelections(),i.dialog("close"),!1},i.find("form").submit(o),r=e('<span class="'+f.widgetName+'"></span>'),n=function(t){var n,s,o;return o=""+l.options.uuid+"-"+t,s=e("<span></span>"),s.hallobutton({label:"Link",icon:"icon-link",editable:l.options.editable,command:null,queryState:!1,uuid:l.options.uuid,cssClass:l.options.buttonCssClass}),r.append(s),n=s,n.bind("click",function(t){var n;return f.lastSelection=f.options.editable.getSelection(),a=e("input[name=url]",i),n=f.lastSelection.startContainer.parentNode,n.href?(a.val(e(n).attr("href")),e(a[0].form).find("input[type=submit]").val("update")):a.val(f.options.defaultUrl),f.options.editable.keepActivated(!0),i.dialog("open"),i.bind("dialogclose",function(){return e("label",s).removeClass("ui-state-active"),f.options.editable.element.focus(),f.options.editable.keepActivated(!1)}),!1}),l.element.bind("keyup paste change mouseup",function(t){var r,i;i=e(f.options.editable.getSelection().startContainer),i.prop("nodeName")?r=i.prop("nodeName"):r=i.parent().prop("nodeName");if(r&&r.toUpperCase()==="A"){e("label",n).addClass("ui-state-active");return}return e("label",n).removeClass("ui-state-active")})},this.options.link&&n("A");if(this.options.link)return t.append(r),r.hallobuttonset(),i.dialog(this.options.dialogOpts)}})}(jQuery),function(e){return e.widget("IKS.hallojustify",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},populateToolbar:function(t){var n,r,i=this;return r=e('<span class="'+this.widgetName+'"></span>'),n=function(t){var n;return n=e("<span></span>"),n.hallobutton({uuid:i.options.uuid,editable:i.options.editable,label:t,command:"justify"+t,icon:"icon-align-"+t.toLowerCase(),cssClass:i.options.buttonCssClass}),r.append(n)},n("Left"),n("Center"),n("Right"),r.hallobuttonset(),t.append(r)}})}(jQuery),function(e){return e.widget("IKS.hallobutton",{button:null,isChecked:!1,options:{uuid:"",label:null,icon:null,editable:null,command:null,queryState:!0,cssClass:null},_create:function(){var e,t,n,r,i,s=this;return(i=(r=this.options).icon)==null&&(r.icon="icon-"+this.options.label.toLowerCase()),t=""+this.options.uuid+"-"+this.options.label,n=this.options,this.button=this._createButton(t,n.command,n.label,n.icon),this.element.append(this.button),this.options.cssClass&&this.button.addClass(this.options.cssClass),this.options.editable.options.touchScreen&&this.button.addClass("btn-large"),this.button.data("hallo-command",this.options.command),e="ui-state-hover",this.button.bind("mouseenter",function(t){if(s.isEnabled())return s.button.addClass(e)}),this.button.bind("mouseleave",function(t){return s.button.removeClass(e)})},_init:function(){var e,t,n,r=this;this.button||(this.button=this._prepareButton()),this.element.append(this.button),n=function(e){if(!r.options.command)return;try{return r.checked(document.queryCommandState(r.options.command))}catch(t){}},this.options.command&&this.button.bind("click",function(e){return r.options.editable.execute(r.options.command),n,!1});if(!this.options.queryState)return;return e=this.options.editable.element,t="keyup paste change mouseup hallomodified",e.bind(t,n),e.bind("halloenabled",function(){return e.bind(t,n)}),e.bind("hallodisabled",function(){return e.unbind(t,n)})},enable:function(){return this.button.removeAttr("disabled")},disable:function(){return this.button.attr("disabled","true")},isEnabled:function(){return this.button.attr("disabled")!=="true"},refresh:function(){return this.isChecked?this.button.addClass("ui-state-active"):this.button.removeClass("ui-state-active")},checked:function(e){return this.isChecked=e,this.refresh()},_createButton:function(t,n,r,i){var s;return s=["ui-button","ui-widget","ui-state-default","ui-corner-all","ui-button-text-only",""+n+"_button"],e('<button id="'+t+'" class="'+s.join(" ")+'" title="'+r+'"> <span class="ui-button-text"> <i class="'+i+'"></i> </span> </button>')}}),e.widget("IKS.hallobuttonset",{buttons:null,_create:function(){return this.element.addClass("ui-buttonset")},_init:function(){return this.refresh()},refresh:function(){var e;return e=this.element.css("direction")==="rtl",this.buttons=this.element.find(".ui-button"),this.buttons.removeClass("ui-corner-all ui-corner-left ui-corner-right"),e?(this.buttons.filter(":first").addClass("ui-corner-right"),this.buttons.filter(":last").addClass("ui-corner-left")):(this.buttons.filter(":first").addClass("ui-corner-left"),this.buttons.filter(":last").addClass("ui-corner-right"))}})}(jQuery),function(e){return e.widget("IKS.hallodropdownbutton",{button:null,options:{uuid:"",label:null,icon:null,editable:null,target:"",cssClass:null},_create:function(){var e,t;return(t=(e=this.options).icon)!=null?t:e.icon="icon-"+this.options.label.toLowerCase()},_init:function(){var t,n=this;return t=e(this.options.target),t.css("position","absolute"),t.addClass("dropdown-menu"),t.hide(),this.button||(this.button=this._prepareButton()),this.button.bind("click",function(){if(t.hasClass("open")){n._hideTarget();return}return n._showTarget()}),t.bind("click",function(){return n._hideTarget()}),this.options.editable.element.bind("hallodeactivated",function(){return n._hideTarget()}),this.element.append(this.button)},_showTarget:function(){var t;return t=e(this.options.target),this._updateTargetPosition(),t.addClass("open"),t.show()},_hideTarget:function(){var t;return t=e(this.options.target),t.removeClass("open"),t.hide()},_updateTargetPosition:function(){var t,n,r,i;return n=e(this.options.target),i=this.button.position(),r=i.top,t=i.left,r+=this.button.outerHeight(),n.css("top",r),n.css("left",t-20)},_prepareButton:function(){var t,n,r;return r=""+this.options.uuid+"-"+this.options.label,n=["ui-button","ui-widget","ui-state-default","ui-corner-all","ui-button-text-only"],t=e('<button id="'+r+'" class="'+n.join(" ")+'" title="'+this.options.label+'"> <i class="'+this.options.icon+'"></i> </button>'),this.options.cssClass&&t.addClass(this.options.cssClass),t.button()}})}(jQuery),function(e){return e.widget("Hallo.halloToolbarContextual",{toolbar:null,options:{parentElement:"body",editable:null,toolbar:null},_create:function(){var t=this;return this.toolbar=this.options.toolbar,e(this.options.parentElement).append(this.toolbar),this._bindEvents(),e(window).resize(function(e){return t._updatePosition(t._getPosition(e))})},_getPosition:function(e,t){var n,r;if(!e)return;n=e.type;switch(n){case"keydown":case"keyup":case"keypress":return this._getCaretPosition(t);case"click":case"mousedown":case"mouseup":return r={top:e.pageY,left:e.pageX}}},_getCaretPosition:function(t){var n,r,i;return i=e("<span/>"),n=rangy.createRange(),n.setStart(t.endContainer,t.endOffset),n.insertNode(i.get(0)),r={top:i.offset().top,left:i.offset().left},i.remove(),r},setPosition:function(){return this.options.parentElement!=="body"&&(this.options.parentElement="body",e(this.options.parentElement).append(this.toolbar)),this.toolbar.css("position","absolute"),this.toolbar.css("top",this.element.offset().top-20),this.toolbar.css("left",this.element.offset().left)},_updatePosition:function(e){if(!e)return;if(!e.top||!e.left)return;return this.toolbar.css("top",e.top),this.toolbar.css("left",e.left)},_bindEvents:function(){var e=this;return this.element.bind("halloselected",function(t,n){var r;r=e._getPosition(n.originalEvent,n.selection);if(!r)return;return e._updatePosition(r),e.toolbar.show()}),this.element.bind("hallounselected",function(t,n){return e.toolbar.hide()}),this.element.bind("hallodeactivated",function(t,n){return e.toolbar.hide()})}})}(jQuery),function(e){return e.widget("Hallo.halloToolbarFixed",{toolbar:null,options:{parentElement:"body",editable:null,toolbar:null},_create:function(){var t,n,r=this;this.toolbar=this.options.toolbar,this.toolbar.show(),e(this.options.parentElement).append(this.toolbar),this._bindEvents(),e(window).resize(function(e){return r._updatePosition(r._getPosition(e))});if(this.options.parentElement==="body"&&!this.options.floating)return t=e(this.element),n=parseFloat(t.css("padding-left")),n+=parseFloat(t.css("padding-right")),n+=parseFloat(t.css("border-left-width")),n+=parseFloat(t.css("border-right-width")),n+=parseFloat(t.css("outline-width"))*2,n+=parseFloat(t.css("outline-offset"))*2,e(this.toolbar).css("width",t.width()+n)},_getPosition:function(e,t){var n,r,i;if(!e)return;return i=parseFloat(this.element.css("outline-width")),n=i+parseFloat(this.element.css("outline-offset")),r={top:this.element.offset().top-this.toolbar.outerHeight()-n,left:this.element.offset().left-n}},_getCaretPosition:function(t){var n,r,i;return i=e("<span/>"),n=rangy.createRange(),n.setStart(t.endContainer,t.endOffset),n.insertNode(i.get(0)),r={top:i.offset().top,left:i.offset().left},i.remove(),r},setPosition:function(){if(this.options.parentElement!=="body")return;return this.toolbar.css("position","absolute"),this.toolbar.css("top",this.element.offset().top-this.toolbar.outerHeight()),this.toolbar.css("left",this.element.offset().left)},_updatePosition:function(e){},_bindEvents:function(){var e=this;return this.element.bind("halloactivated",function(t,n){return e._updatePosition(e._getPosition(t)),e.toolbar.show()}),this.element.bind("hallodeactivated",function(t,n){return e.toolbar.hide()})}})}(jQuery)}).call(this);
1  examples/hallo.js
View
@@ -69,6 +69,7 @@ http://hallojs.org
this.disable();
if (this.toolbar) {
this.toolbar.remove();
+ this.element[this.options.toolbar]('destroy');
}
_ref = this.options.plugins;
for (plugin in _ref) {
5 src/hallo.coffee
View
@@ -132,7 +132,10 @@ http://hallojs.org
destroy: ->
@disable()
- @toolbar.remove() if @toolbar
+
+ if @toolbar
+ @toolbar.remove()
+ @element[@options.toolbar] 'destroy'
for plugin, options of @options.plugins
jQuery(@element)[plugin] 'destroy'
36 test/hallo.coffee
View
@@ -16,8 +16,11 @@ test 'Hallo instantiation and destruction', ->
# Activate to get toolbar
do fixture.focus
- equal jQuery('.hallotoolbar').length, 1
ok fixture.hasClass 'inEditMode'
+ ok fixture.data('halloToolbarContextual')
+ equal jQuery('.hallotoolbar').length, 1
+ # Contextual toolbar shouldn't be visible without a selection
+ equal jQuery('.hallotoolbar:visible').length, 0
# Check also the instance data
instance = fixture.data 'hallo'
@@ -31,6 +34,7 @@ test 'Hallo instantiation and destruction', ->
do stop
fixture.hallo 'destroy'
equal fixture.data('hallo'), undefined
+ equal fixture.data('halloToolbarContextual'), undefined
equal jQuery('.hallotoolbar').length, 0
equal fixture.hasClass('inEditMode'), false
@@ -89,3 +93,33 @@ test 'Hallo modification events', ->
fixture.html 'h'
do stop
fixture.trigger press
+
+test 'Hallo fixed toolbar', ->
+ fixture = jQuery '.hallo-modified p.editable'
+
+ # Instantiate
+ fixture.hallo
+ toolbar: 'halloToolbarFixed'
+ instance = fixture.data 'hallo'
+
+ # We shouldn't have a toolbar before first focus
+ equal fixture.data('halloToolbarFixed'), undefined
+
+ do fixture.focus
+ ok fixture.data('halloToolbarFixed')
+ equal fixture.data('halloToolbarContextual'), undefined
+ equal jQuery('.hallotoolbar:visible').length, 1
+ equal jQuery('.hallotoolbar:hidden').length, 0
+
+ do fixture.blur
+ equal jQuery('.hallotoolbar:visible').length, 0
+ equal jQuery('.hallotoolbar:hidden').length, 1
+ ok fixture.data('halloToolbarFixed')
+
+ do fixture.focus
+ equal jQuery('.hallotoolbar:visible').length, 1
+ equal jQuery('.hallotoolbar:hidden').length, 0
+
+ do fixture.blur
+ equal jQuery('.hallotoolbar:visible').length, 0
+ equal jQuery('.hallotoolbar:hidden').length, 1
3  test/index.html
View
@@ -36,6 +36,9 @@ <h2 id="qunit-userAgent"></h2>
<div class="hallo-modified">
<p class="editable"></p>
</div>
+ <div class="hallo-toolbar">
+ <p class="editable"></p>
+ </div>
</div>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.