Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

setModified method for plugins to use

  • Loading branch information...
commit 3b99f4bdbc74b9c9442ad2956b22a5e511b66b39 1 parent b31c8d6
Henri Bergius bergie authored
Showing with 527 additions and 522 deletions.
  1. +6 −2 examples/hallo-min.js
  2. +512 −514 examples/hallo.js
  3. +9 −6 src/hallo.coffee
8 examples/hallo-min.js
View
@@ -1,2 +1,6 @@
-((function(){(function(a){return a.widget("IKS.hallobutton",{button:null,options:{uuid:"",label:null,icon:null,editable:null,command:null,queryState:!0,cssClass:null},_create:function(){var a,b;return(b=this.options).icon==null&&(b.icon="icon-"+this.options.label.toLowerCase()),a=""+this.options.uuid+"-"+this.options.label,this.element.append(this._createButton(a,this.options.command)),this.element.append(this._createLabel(a,this.options.command,this.options.label,this.options.icon)),this.options.cssClass&&this.element.find("label").addClass(this.options.cssClass),this.button=this.element.find("input"),this.button.button(),this.options.cssClass&&this.button.addClass(this.options.cssClass),this.button.data("hallo-command",this.options.command)},_init:function(){var a,b,c=this;this.button||(this.button=this._prepareButton()),this.element.append(this.button),this.options.command&&this.button.bind("change",function(a){return c.options.editable.execute(c.options.command)});if(!this.options.queryState)return;return a=this.options.editable.element,b=function(a){if(!c.options.command)return;try{return c.checked(document.queryCommandState(c.options.command))}catch(b){}},a.bind("halloenabled",function(){return a.bind("keyup paste change mouseup hallomodified",b)}),a.bind("hallodisabled",function(){return a.unbind("keyup paste change mouseup hallomodified",b)})},enable:function(){return this.button.button("enable")},disable:function(){return this.button.button("disable")},refresh:function(){return this.button.button("refresh")},checked:function(a){return this.button.attr("checked",a),this.refresh()},_createButton:function(b){return a('<input id="'+b+'" type="checkbox" />')},_createLabel:function(b,c,d,e){return a('<label for="'+b+'" class="'+c+'_button" title="'+d+'"><i class="'+e+'"></i></label>')}})})(jQuery),function(a){return a.widget("IKS.hallodropdownbutton",{button:null,options:{uuid:"",label:null,icon:null,editable:null,target:"",cssClass:null},_create:function(){var a,b;return(b=(a=this.options).icon)!=null?b:a.icon="icon-"+this.options.label.toLowerCase()},_init:function(){var b,c=this;return b=a(this.options.target),b.css("position","absolute"),b.addClass("dropdown-menu"),b.hide(),this.button||(this.button=this._prepareButton()),this.button.bind("click",function(){if(b.hasClass("open")){c._hideTarget();return}return c._showTarget()}),b.bind("click",function(){return c._hideTarget()}),this.options.editable.element.bind("hallodeactivated",function(){return c._hideTarget()}),this.element.append(this.button)},_showTarget:function(){var b;return b=a(this.options.target),this._updateTargetPosition(),b.addClass("open"),b.show()},_hideTarget:function(){var b;return b=a(this.options.target),b.removeClass("open"),b.hide()},_updateTargetPosition:function(){var b,c,d,e;return d=a(this.options.target),e=this.element.position(),b=e.bottom,c=e.left,d.css("top",b),d.css("left",c-20)},_prepareButton:function(){var b,c,d;return d=""+this.options.uuid+"-"+this.options.label,c=a('<button id="'+d+'" data-toggle="dropdown" data-target="#'+this.options.target.attr("id")+'" title="'+this.options.label+'">\n <span class="ui-button-text"><i class="'+this.options.icon+'"></i></span>\n</button>'),this.options.cssClass&&c.addClass(this.options.cssClass),b=c.button(),b}})}(jQuery),function(a){return a.widget("IKS.hallo",{toolbar:null,toolbarMoved:!1,bound:!1,originalContent:"",uuid:"",selection:null,options:{editable:!0,plugins:{},floating:!0,offset:{x:0,y:0},fixed:!1,showAlways:!1,activated:function(){},deactivated:function(){},selected:function(){},unselected:function(){},enabled:function(){},disabled:function(){},placeholder:"",parentElement:"body",forceStructured:!0,buttonCssClass:null},_create:function(){var b,c,d,e;this.originalContent=this.getContents(),this.id=this._generateUUID(),this._prepareToolbar(),d=this.options.plugins,e=[];for(c in d)b=d[c],a.isPlainObject(b)||(b={}),b.editable=this,b.toolbar=this.toolbar,b.uuid=this.id,b.buttonCssClass=this.options.buttonCssClass,e.push(a(this.element)[c](b));return e},_init:function(){return this._setToolbarPosition(),this.options.editable?this.enable():this.disable()},disable:function(){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,this._trigger("disabled",null)},enable:function(){var a;return this.element.attr("contentEditable",!0),this.element.html()||this.element.html(this.options.placeholder),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),a=this,this.bound=!0),this.options.forceStructured&&this._forceStructured(),this._trigger("enabled",null)},activate:function(){return this.element.focus()},getSelection:function(){var b,c;if(a.browser.msie)b=document.selection.createRange();else{if(window.getSelection)c=window.getSelection();else{if(!document.selection)throw"Your browser does not support selection handling";c=document.selection.createRange()}c.rangeCount>0?b=c.getRangeAt(0):b=c}return b},restoreSelection:function(b){return a.browser.msie?b.select():(window.getSelection().removeAllRanges(),window.getSelection().addRange(b))},replaceSelection:function(b){var c,d,e,f,g;return a.browser.msie?(g=document.selection.createRange().text,d=document.selection.createRange(),d.pasteHTML(b(g))):(f=window.getSelection(),e=f.getRangeAt(0),c=document.createTextNode(b(e.extractContents())),e.insertNode(c),e.setStartAfter(c),f.removeAllRanges(),f.addRange(e))},removeAllSelections:function(){return a.browser.msie?range.empty():window.getSelection().removeAllRanges()},getContents:function(){var b,c;b=this.element.clone();for(c in this.options.plugins)a(this.element)[c]("cleanupContentClone",b);return b.html()},setContents:function(a){return this.element.html(a)},isModified:function(){return this.originalContent!==this.getContents()},setUnmodified:function(){return this.originalContent=this.getContents()},restoreOriginalContent:function(){return this.element.html(this.originalContent)},execute:function(a,b){if(document.execCommand(a,!1,b))return this.element.trigger("change")},protectFocusFrom:function(a){var b;return b=this,a.bind("mousedown",function(a){return a.preventDefault(),b._protectToolbarFocus=!0,setTimeout(function(){return b._protectToolbarFocus=!1},300)})},_generateUUID:function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},""+a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},_getToolbarPosition:function(a,b){var c;if(!a)return;if(!this.options.floating)return c=parseFloat(this.element.css("outline-width"))+parseFloat(this.element.css("outline-offset")),{top:this.element.offset().top-this.toolbar.outerHeight()-c,left:this.element.offset().left-c};if(a.originalEvent instanceof KeyboardEvent)return this._getCaretPosition(b);if(a.originalEvent instanceof MouseEvent)return{top:a.pageY,left:a.pageX}},_getCaretPosition:function(b){var c,d,e;return e=a("<span/>"),c=document.createRange(),c.setStart(b.endContainer,b.endOffset),c.insertNode(e.get(0)),d={top:e.offset().top,left:e.offset().left},e.remove(),d},_bindToolbarEventsFixed:function(){var a=this;return this.options.floating=!1,this.element.bind("halloactivated",function(b,c){return a._updateToolbarPosition(a._getToolbarPosition(b)),a.toolbar.show()}),this.element.bind("hallodeactivated",function(b,c){return a.toolbar.hide()})},_bindToolbarEventsRegular:function(){var a=this;return this.element.bind("halloselected",function(b,c){var d;d=a._getToolbarPosition(c.originalEvent,c.selection);if(!d)return;return a._updateToolbarPosition(d),a.toolbar.show()}),this.element.bind("hallounselected",function(b,c){return a.toolbar.hide()}),this.element.bind("hallodeactivated",function(b,c){return a.toolbar.hide()})},_setToolbarPosition:function(){if(this.options.fixed){this.toolbar.css("position","static"),this.toolbarMoved&&a(this.options.parentElement).append(this.toolbar),this.toolbarMoved=!1;return}return this.options.parentElement!=="body"&&(a("body").append(this.toolbar),this.toolbarMoved=!0),this.toolbar.css("position","absolute"),this.toolbar.css("top",this.element.offset().top-20),this.toolbar.css("left",this.element.offset().left)},_prepareToolbar:function(){var b,c=this;return this.toolbar=a('<div class="hallotoolbar"></div>').hide(),this._setToolbarPosition(),a(this.options.parentElement).append(this.toolbar),b=this,this.options.showAlways&&this._bindToolbarEventsFixed(),this.options.showAlways||this._bindToolbarEventsRegular(),a(window).resize(function(a){return c._updateToolbarPosition(c._getToolbarPosition(a))}),this.protectFocusFrom(this.toolbar)},_updateToolbarPosition:function(a){if(this.options.fixed)return;if(!a)return;if(!a.top||!a.left)return;return this.toolbar.css("top",a.top),this.toolbar.css("left",a.left)},_checkModified:function(a){var b;b=a.data;if(b.isModified())return b._trigger("modified",null,{editable:b,content:b.getContents()})},_keys:function(a){var b,c;c=a.data;if(a.keyCode===27)return b=c.getContents(),c.restoreOriginalContent(a),c._trigger("restored",null,{editable:c,content:c.getContents(),thrown:b}),c.turnOff()},_rangesEqual:function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset},_checkSelection:function(a){var b;if(a.keyCode===27)return;return b=a.data,setTimeout(function(){var c;c=b.getSelection();if(b._isEmptySelection(c)||b._isEmptyRange(c)){b.selection&&(b.selection=null,b._trigger("unselected",null,{editable:b,originalEvent:a}));return}if(!b.selection||!b._rangesEqual(c,b.selection))return b.selection=c.cloneRange(),b._trigger("selected",null,{editable:b,selection:b.selection,ranges:[b.selection],originalEvent:a})},0)},_isEmptySelection:function(a){return a.type==="Caret"?!0:!1},_isEmptyRange:function(a){return a.collapsed?!0:a.isCollapsed?typeof a.isCollapsed=="function"?a.isCollapsed():a.isCollapsed:!1},turnOn:function(){var b,c;return this.getContents()===this.options.placeholder&&this.setContents(""),a(this.element).addClass("inEditMode"),this.options.floating?this.toolbar.css("width","auto"):(b=a(this.element),c=parseFloat(b.css("padding-left")),c+=parseFloat(b.css("padding-right")),c+=parseFloat(b.css("border-left-width")),c+=parseFloat(b.css("border-right-width")),c+=parseFloat(b.css("outline-width"))*2,c+=parseFloat(b.css("outline-offset"))*2,a(this.toolbar).css("width",b.width()+c)),this._trigger("activated",this)},turnOff:function(){a(this.element).removeClass("inEditMode"),this._trigger("deactivated",this);if(!this.getContents())return this.setContents(this.options.placeholder)},_activated:function(a){return a.data.turnOn()},_deactivated:function(b){return b.data._protectToolbarFocus!==!0?b.data.turnOff():setTimeout(function(){return a(b.data.element).focus()},300)},_forceStructured:function(a){try{return document.execCommand("styleWithCSS",0,!1)}catch(b){try{return document.execCommand("useCSS",0,!0)}catch(b){try{return document.execCommand("styleWithCSS",!1,!1)}catch(b){}}}}})}(jQuery),function(a){var b;return b=null,this.VIE!==void 0&&(b=new VIE,b.use(new b.StanbolService({proxyDisabled:!0,url:"http://dev.iks-project.eu:8081"}))),a.widget("IKS.halloannotate",{options:{vie:b,editable:null,toolbar:null,uuid:"",select:function(){},decline:function(){},remove:function(){},buttonCssClass:null},_create:function(){var b,c,d,e,f=this;e=this;if(this.options.vie===void 0)throw"The halloannotate plugin requires VIE to be loaded";if(typeof this.element.annotate!="function")throw"The halloannotate plugin requires annotate.js to be loaded";return this.state="off",b=a('<span class="'+e.widgetName+'"></span>'),this.button=b.hallobutton({label:"Annotate",icon:"icon-tags",editable:this.options.editable,command:null,uuid:this.options.uuid,cssClass:this.options.buttonCssClass,queryState:!1}),b.bind("change",function(a){if(f.state==="pending")return;return f.state==="off"?f.turnOn():f.turnOff()}),b.buttonset(),this.options.toolbar.append(this.button),this.instantiate(),d=function(){var b;return b=this,a(b).halloannotate("turnOff")},c=this.options.editable.element,c.bind("hallodisabled",d)},cleanupContentClone:function(b){if(this.state==="on")return b.find(".entity:not([about])").each(function(){return a(this).replaceWith(a(this).html())})},instantiate:function(){return 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(){return a.noop()}).bind("annotateremove",function(){return a.noop()})},turnPending:function(){return this.state="pending",this.button.hallobutton("checked",!1),this.button.hallobutton("disable")},turnOn:function(){var a,b=this;this.turnPending(),a=this;try{return this.options.editable.element.annotate("enable",function(a){if(a)return b.state="on",b.button.hallobutton("checked",!0),b.button.hallobutton("enable")})}catch(c){return alert(c)}},turnOff:function(){return this.options.editable.element.annotate("disable"),this.button.attr("checked",!1),this.button.find("label").removeClass("ui-state-clicked"),this.button.button("refresh"),this.state="off"}})}(jQuery),function(a){return a.widget("Liip.hallotoolbarlinebreak",{options:{editable:null,toolbar:null,uuid:"",breakAfter:[]},_create:function(){var b,c,d,e,f,g,h,i,j,k;c=a(".ui-buttonset",this.options.toolbar),d=a(),f=0,k=this.options.breakAfter;for(g=0,i=k.length;g<i;g++){e=k[g],f++;for(h=0,j=c.length;h<j;h++){b=c[h],d=a(d).add(a(b));if(a(b).hasClass(e)){d.wrapAll('<div class="halloButtonrow halloButtonrow-'+f+'" />'),c=c.not(d),d=a();break}}}if(c.length>0)return f++,c.wrapAll('<div class="halloButtonrow halloButtonrow-'+f+'" />')},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.halloblock",{options:{editable:null,toolbar:null,uuid:"",elements:["h1","h2","h3","p","pre","blockquote"],buttonCssClass:null},_create:function(){var b,c,d;return b=a('<span class="'+this.widgetName+'"></span>'),c=""+this.options.uuid+"-"+this.widgetName+"-data",d=this._prepareDropdown(c),b.append(d),b.append(this._prepareButton(d)),this.options.toolbar.append(b)},_prepareDropdown:function(b){var c,d,e,f,g,h,i,j=this;e=a('<div id="'+b+'"></div>'),d=this.options.editable.element.get(0).tagName.toLowerCase(),c=function(b){var c,e;return c=a("<"+b+' class="menu-item">'+b+"</"+b+">"),d===b&&c.addClass("selected"),d!=="div"&&c.addClass("disabled"),c.bind("click",function(){if(c.hasClass("disabled"))return;return j.options.editable.execute("formatBlock",b.toUpperCase())}),e=function(a){var d;d=document.queryCommandValue("formatBlock");if(d.toLowerCase()===b){c.addClass("selected");return}return c.removeClass("selected")},j.options.editable.element.bind("halloenabled",function(){return j.options.editable.element.bind("keyup paste change mouseup",e)}),j.options.editable.element.bind("hallodisabled",function(){return j.options.editable.element.unbind("keyup paste change mouseup",e)}),c},i=this.options.elements;for(g=0,h=i.length;g<h;g++)f=i[g],e.append(c(f));return e},_prepareButton:function(b){var c;return c=a("<span></span>"),c.hallodropdownbutton({uuid:this.options.uuid,editable:this.options.editable,label:"block",icon:"icon-text-height",target:b,cssClass:this.options.buttonCssClass}),c}})}(jQuery),function(a){return a.widget("Liip.halloimage",{options:{editable:null,toolbar:null,uuid:"",limit:8,search: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",close:function(b,c){return a(".image_button").removeClass("ui-state-clicked")}},dialog:null,buttonCssClass:null},_create:function(){var b,c,d,e,f,g;return g=this,e=""+this.options.uuid+"-image-dialog",this.options.dialog=a('<div id="'+e+'"> <div class="nav"> <ul class="tabs"> </ul> <div id="'+this.options.uuid+'-tab-activeIndicator" class="tab-activeIndicator" /> </div> <div class="dialogcontent"> </div>'),g.options.uploadUrl&&!g.options.upload&&(g.options.upload=g._iframeUpload),g.options.suggestions&&this._addGuiTabSuggestions(a(".tabs",this.options.dialog),a(".dialogcontent",this.options.dialog)),g.options.search&&this._addGuiTabSearch(a(".tabs",this.options.dialog),a(".dialogcontent",this.options.dialog)),g.options.upload&&this._addGuiTabUpload(a(".tabs",this.options.dialog),a(".dialogcontent",this.options.dialog)),d=a('<span class="'+g.widgetName+'"></span>'),f=""+this.options.uuid+"-image",c=a("<span></span>"),c.hallobutton({label:"Images",icon:"icon-picture",editable:this.options.editable,command:null,queryState:!1,uuid:this.options.uuid,cssClass:this.options.buttonCssClass}),d.append(c),b=c.button(),b.bind("change",function(a){return g.options.dialog.dialog("isOpen")?g._closeDialog():g._openDialog()}),this.options.editable.element.bind("hallodeactivated",function(a){return g._closeDialog()}),a(this.options.editable.element).delegate("img","click",function(a){return g._openDialog()}),a(this.options.dialog).find(".nav li").click(function(){return a("."+g.widgetName+"-tab").each(function(){return a(this).hide()}),f=a(this).attr("id"),a("#"+f+"-content").show(),a("#"+g.options.uuid+"-tab-activeIndicator").css("margin-left",a(this).position().left+a(this).width()/2)}),a("."+g.widgetName+"-tab .imageThumbnail").live("click",function(b){var c;return c=a(this).closest("."+g.widgetName+"-tab"),a(".imageThumbnail",c).removeClass("imageThumbnailActive"),a(this).addClass("imageThumbnailActive"),a(".activeImage",c).attr("src",a(this).attr("src")),a(".activeImageBg",c).attr("src",a(this).attr("src"))}),d.buttonset(),this.options.toolbar.append(d),this.options.dialog.dialog(this.options.dialogOpts),this._addDragnDrop()},_init:function(){},_openDialog:function(){var b,c,d,e,f,g,h,i,j,k,l,m;k=this,c=function(){return window.setTimeout(function(){var b;return b=a(".imageThumbnail"),a(b).each(function(){var b;b=a("#"+this.id).width();if(b<=20)return a("#"+this.id).parent("li").remove()})},15e3)},e=!1,f=function(b){a.each(b.assets,function(b,c){return a(".imageThumbnailContainer ul").append('<li><img src="'+c.url+'" class="imageThumbnail"></li>'),e=!0});if(b.assets.length>0)return a("#activitySpinner").hide()},a(".image_button").addClass("ui-state-clicked"),a("#"+this.options.uuid+"-sugg-activeImage").attr("src",a("#"+this.options.uuid+"-tab-suggestions-content .imageThumbnailActive").first().attr("src")),a("#"+this.options.uuid+"-sugg-activeImageBg").attr("src",a("#"+this.options.uuid+"-tab-suggestions-content .imageThumbnailActive").first().attr("src")),this.lastSelection=this.options.editable.getSelection(),l=a(this.options.editable.element).offset().left+a(this.options.editable.element).outerWidth()-3,m=a(this.options.toolbar).offset().top-a(document).scrollTop()-29,this.options.dialog.dialog("option","position",[l,m]);if(k.options.loaded===null&&k.options.suggestions){b=[],a("#activitySpinner").show(),i=a(".inEditMode").parent().find(".articleTags input").val(),i=i.split(",");for(d in i)g=typeof i[d],"string"===g&&i[d].indexOf("http")!==-1&&b.push(i[d]);a(".imageThumbnailContainer ul").empty(),k.options.suggestions(a(".inEditMode").parent().find(".articleTags input").val(),k.options.limit,0,f),j=new VIE,j.use(new j.DBPediaService({url:"http://dev.iks-project.eu/stanbolfull",proxyDisabled:!0})),h=1,b.length===0&&a("#activitySpinner").html("No images found."),a(b).each(function(){return j.load({entity:this+""}).using("dbpedia").execute().done(function(b){return a(b).each(function(){var b,c;if(this.attributes["<http://dbpedia.org/ontology/thumbnail>"])return c=typeof this.attributes["<http://dbpedia.org/ontology/thumbnail>"],c==="string"&&(b=this.attributes["<http://dbpedia.org/ontology/thumbnail>"],b=b.substring(1,b.length-1)),c==="object"&&(b="",b=this.attributes["<http://dbpedia.org/ontology/thumbnail>"][0].value),a(".imageThumbnailContainer ul").append('<li><img id="si-'+h+'" src="'+b+'" class="imageThumbnail"></li>'),h++}),a("#activitySpinner").hide()})})}return c(),k.options.loaded=1,this.options.dialog.dialog("open")},_closeDialog:function(){return this.options.dialog.dialog("close")},_addGuiTabSuggestions:function(b,c){var d;return d=this,b.append(a('<li id="'+this.options.uuid+'-tab-suggestions" class="'+d.widgetName+"-tabselector "+d.widgetName+'-tab-suggestions"><span>Suggestions</span></li>')),c.append(a('<div id="'+this.options.uuid+'-tab-suggestions-content" class="'+d.widgetName+'-tab tab-suggestions"> <div class="imageThumbnailContainer fixed"><div id="activitySpinner">Loading Images...</div><ul><li> <img src="http://imagesus.homeaway.com/mda01/badf2e69babf2f6a0e4b680fc373c041c705b891" class="imageThumbnail imageThumbnailActive" /> </li></ul><br style="clear:both"/> </div> <div class="activeImageContainer"> <div class="rotationWrapper"> <div class="hintArrow"></div> <img src="" id="'+this.options.uuid+'-sugg-activeImage" class="activeImage" /> </div> <img src="" id="'+this.options.uuid+'-sugg-activeImageBg" class="activeImage activeImageBg" /> </div> <div class="metadata"> <label for="caption-sugg">Caption</label><input type="text" id="caption-sugg" /> </div> </div>'))},_addGuiTabSearch:function(b,c){var d,e;return e=this,d=""+this.options.uuid+"-image-dialog",b.append(a('<li id="'+this.options.uuid+'-tab-search" class="'+e.widgetName+"-tabselector "+e.widgetName+'-tab-search"><span>Search</span></li>')),c.append(a('<div id="'+this.options.uuid+'-tab-search-content" class="'+e.widgetName+'-tab tab-search"> <form type="get" id="'+this.options.uuid+"-"+e.widgetName+'-searchForm"> <input type="text" class="searchInput" /><input type="submit" id="'+this.options.uuid+"-"+e.widgetName+'-searchButton" class="button searchButton" value="OK"/> </form> <div class="searchResults imageThumbnailContainer"></div> <div id="'+this.options.uuid+'-search-activeImageContainer" class="search-activeImageContainer activeImageContainer"> <div class="rotationWrapper"> <div class="hintArrow"></div> <img src="" id="'+this.options.uuid+'-search-activeImageBg" class="activeImage" /> </div> <img src="" id="'+this.options.uuid+'-search-activeImage" class="activeImage activeImageBg" /> </div> <div class="metadata" id="metadata-search" style="display: none;"> <label for="caption-search">Caption</label><input type="text" id="caption-search" /> <!--<button id="'+this.options.uuid+"-"+e.widgetName+'-addimage">Add Image</button>--> </div> </div>')),a(".tab-search form",c).submit(function(b){var c,f;return b.preventDefault(),f=this,c=function(b){var f,g,h;return h=[],h.push('<div class="pager-prev" style="display:none"></div>'),a.each(b.assets,function(a,b){return h.push('<img src="'+b.url+'" class="imageThumbnail '+e.widgetName+'-search-imageThumbnail" /> ')}),h.push('<div class="pager-next" style="display:none"></div>'),f=a("#"+d+" .tab-search .searchResults"),f.html(h.join("")),b.offset>0&&a(".pager-prev",f).show(),b.offset<b.total&&a(".pager-next",f).show(),a(".pager-prev",f).click(function(a){return e.options.search(null,e.options.limit,b.offset-e.options.limit,c)}),a(".pager-next",f).click(function(a){return e.options.search(null,e.options.limit,b.offset+e.options.limit,c)}),a("#"+e.options.uuid+"-search-activeImageContainer").show(),g=a("."+e.widgetName+"-search-imageThumbnail").first().addClass("imageThumbnailActive"),a("#"+e.options.uuid+"-search-activeImage, #"+e.options.uuid+"-search-activeImageBg").attr("src",g.attr("src")),a("#metadata-search").show()},e.options.search(null,e.options.limit,0,c)})},_prepareIframe:function(b){var c;return b.options.iframeName=""+b.options.uuid+"-"+b.widgetName+"-postframe",c=a('<iframe name="'+b.options.iframeName+'" id="'+b.options.iframeName+'" class="hidden" src="javascript:false;" style="display:none" />'),a("#"+b.options.uuid+"-"+b.widgetName+"-iframe").append(c),c.get(0).name=b.options.iframeName},_iframeUpload:function(b){var c,d;return d=b.widget,d._prepareIframe(d),a("#"+d.options.uuid+"-"+d.widgetName+"-tags").val(a(".inEditMode").parent().find(".articleTags input").val()),c=a("#"+d.options.uuid+"-"+d.widgetName+"-uploadform"),c.attr("action",d.options.uploadUrl),c.attr("method","post"),c.attr("userfile",b.file),c.attr("enctype","multipart/form-data"),c.attr("encoding","multipart/form-data"),c.attr("target",d.options.iframeName),c.submit(),a("#"+d.options.iframeName).load(function(){return b.success(a("#"+d.options.iframeName)[0].contentWindow.location.href)})},_addGuiTabUpload:function(b,c){var d,e,f;return f=this,b.append(a('<li id="'+this.options.uuid+'-tab-upload" class="'+f.widgetName+"-tabselector "+f.widgetName+'-tab-upload"><span>Upload</span></li>')),c.append(a('<div id="'+this.options.uuid+'-tab-upload-content" class="'+f.widgetName+'-tab tab-upload"> <form id="'+this.options.uuid+"-"+f.widgetName+'-uploadform"> <input id="'+this.options.uuid+"-"+f.widgetName+'-file" name="'+this.options.uuid+"-"+f.widgetName+'-file" type="file" class="file"> <input id="'+this.options.uuid+"-"+f.widgetName+'-tags" name="tags" type="hidden" /> <br /> <input type="submit" value="Upload" id="'+this.options.uuid+"-"+f.widgetName+'-upload"> </form> <div id="'+this.options.uuid+"-"+f.widgetName+'-iframe"></div> </div>')),d=a('<iframe name="postframe" id="postframe" class="hidden" src="about:none" style="display:none" />'),a("#"+f.options.uuid+"-"+f.widgetName+"-upload").live("click",function(b){var c;return b.preventDefault(),c=a("#"+f.options.uuid+"-"+f.widgetName+"-file").val(),f.options.upload({widget:f,file:c,success:function(b){var c,d;return c="si"+Math.floor(Math.random()*101+400)+"ab",a(".imageThumbnailContainer ul",f.options.dialog).length===0&&(d=a("<ul></ul>"),a(".imageThumbnailContainer").append(d)),a(".imageThumbnailContainer ul",f.options.dialog).append('<li><img src="'+b+'" id="'+c+'" class="imageThumbnail"></li>'),a("#"+c).trigger("click"),a(f.options.dialog).find(".nav li").first().trigger("click")}}),!1}),e=function(){var b,c;try{if(!f.options.editable.getSelection())throw new Error("SelectionNotSet")}catch(d){f.options.editable.restoreSelection(f.lastSelection)}return document.execCommand("insertImage",null,a(this).attr("src")),b=document.getSelection().anchorNode.firstChild,a(b).attr("alt",a(".caption").value),c=function(){return f.element.trigger("hallomodified")},window.setTimeout(c,100),f._closeDialog()},this.options.dialog.find(".halloimage-activeImage, #"+f.options.uuid+"-"+f.widgetName+"-addimage").click(e)},_addDragnDrop:function(){var b,c,d,e,f,g,h,i,j;return e={delayAction:function(a,b){var c;c=clearTimeout(c);if(!c)return c=setTimeout(a,b)},calcPosition:function(a,b){var c;c=a.left+i;if(b.pageX>=c&&b.pageX<=a.left+i*2)return"middle";if(b.pageX<c)return"left";if(b.pageX>a.left+i*2)return"right"},createInsertElement:function(b,c){var d,e,f,g,h,i,j,k;h=250,g=250,j=new Image,j.src=b.src,c||(this.startPlace.parents(".tab-suggestions").length>0?d=a("#caption-sugg").val():this.startPlace.parents(".tab-search").length>0?d=a("#caption-search").val():d=a(b).attr("alt")),k=j.width,e=j.height;if(k>h||e>g)k>e?i=(j.width/h).toFixed():i=(j.height/g).toFixed(),k=(j.width/i).toFixed(),e=(j.height/i).toFixed();return f=a("<img>").attr({src:j.src,width:k,height:e,alt:d,"class":c?"tmp":""}).show(),f},createLineFeedbackElement:function(){return a("<div/>").addClass("tmpLine")},removeFeedbackElements:function(){return a(".tmp, .tmpLine",d).remove()},removeCustomHelper:function(){return a(".customHelper").remove()},showOverlay:function(a){var b;b=d.height()+parseFloat(d.css("paddingTop"))+parseFloat(d.css("paddingBottom")),g.big.css({height:b}),g.left.css({height:b}),g.right.css({height:b});switch(a){case"left":return g.big.addClass("bigOverlayLeft").removeClass("bigOverlayRight").css({left:i}).show(),g.left.hide(),g.right.hide();case"middle":return g.big.removeClass("bigOverlayLeft bigOverlayRight"),g.big.hide(),g.left.show(),g.right.show();case"right":return g.big.addClass("bigOverlayRight").removeClass("bigOverlayLeft").css({left:0}).show(),g.left.hide(),g.right.hide()}},checkOrigin:function(b){return a(b.target).parents("[contenteditable]").length!==0?!0:!1},startPlace:""},b={createTmpFeedback:function(a,b){var c;return b==="middle"?e.createLineFeedbackElement():(c=e.createInsertElement(a,!0),c.addClass("inlineImage-"+b))},handleOverEvent:function(c,h){var i;return i=function(){var i;return window.waitWithTrash=clearTimeout(window.waitWithTrash),i=e.calcPosition(f,c),a(".trashcan",h.helper).remove(),d.append(g.big),d.append(g.left),d.append(g.right),e.removeFeedbackElements(),a(c.target).prepend(b.createTmpFeedback(h.draggable[0],i)),i==="middle"?(a(c.target).prepend(b.createTmpFeedback(h.draggable[0],"right")),a(".tmp",a(c.target)).hide()):(a(c.target).prepend(b.createTmpFeedback(h.draggable[0],"middle")),a(".tmpLine",a(c.target)).hide()),e.showOverlay(i)},setTimeout(i,5)},handleDragEvent:function(c,g){var h,i,j;h=e.calcPosition(f,c);if(h===b.lastPositionDrag)return;return b.lastPositionDrag=h,i=a(".tmp",d),j=a(".tmpLine",d),h==="middle"?(j.show(),i.hide()):(j.hide(),i.removeClass("inlineImage-left inlineImage-right").addClass("inlineImage-"+h).show()),e.showOverlay(h)},handleLeaveEvent:function(b,c){var d;return d=function(){return a("div.trashcan",c.helper).length||a(c.helper).append(a('<div class="trashcan"></div>')),a(".bigOverlay, .smallOverlay").remove()},window.waitWithTrash=setTimeout(d,200),e.removeFeedbackElements()},handleStartEvent:function(b,c){var d;return d=e.checkOrigin(b),d&&a(b.target).remove(),a(document).trigger("startPreventSave"),e.startPlace=a(b.target)},handleStopEvent:function(b,c){var f;return f=e.checkOrigin(b),f?a(b.target).remove():d.trigger("change"),g.big.hide(),g.left.hide(),g.right.hide(),a(document).trigger("stopPreventSave")},handleDropEvent:function(c,h){var i,j,k;return j=e.checkOrigin(c),k=e.calcPosition(f,c),e.removeFeedbackElements(),e.removeCustomHelper(),i=e.createInsertElement(h.draggable[0],!1),k==="middle"?(i.show(),i.removeClass("inlineImage-middle inlineImage-left inlineImage-right").addClass("inlineImage-"+k).css({position:"relative",left:(d.width()+parseFloat(d.css("paddingLeft"))+parseFloat(d.css("paddingRight"))-i.attr("width"))/2}),i.insertBefore(a(c.target))):(i.removeClass("inlineImage-middle inlineImage-left inlineImage-right").addClass("inlineImage-"+k).css("display","block"),a(c.target).prepend(i)),g.big.hide(),g.left.hide(),g.right.hide(),d.trigger("change"),b.init(d)},createHelper:function(b){return a("<div>").css({backgroundImage:"url("+a(b.currentTarget).attr("src")+")"}).addClass("customHelper").appendTo("body")},init:function(){var e,f;return e=[],f=function(e){return e.jquery_draggable_initialized||(e.jquery_draggable_initialized=!0,a(e).draggable({cursor:"move",helper:b.createHelper,drag:b.handleDragEvent,start:b.handleStartEvent,stop:b.handleStopEvent,disabled:!d.hasClass("inEditMode"),cursorAt:{top:50,left:50}})),c.push(e)},a(".rotationWrapper img",j.dialog).each(function(a,b){if(!b.jquery_draggable_initialized)return f(b)}),a("img",d).each(function(a,b){b.contentEditable=!1;if(!b.jquery_draggable_initialized)return f(b)}),a("p",d).each(function(c,e){if(!e.jquery_droppable_initialized)return e.jquery_droppable_initialized=!0,a("p",d).droppable({tolerance:"pointer",drop:b.handleDropEvent,over:b.handleOverEvent,out:b.handleLeaveEvent})})},enableDragging:function(){return a.each(c,function(b,c){return a(c).draggable("option","disabled",!1)})},disableDragging:function(){return a.each(c,function(b,c){return a(c).draggable("option","disabled",!0)})}},c=[],d=a(
-this.options.editable.element),j=this.options,f=d.offset(),i=parseFloat(d.width()/3),h={width:i,height:d.height()},g={big:a("<div/>").addClass("bigOverlay").css({width:i*2,height:d.height()}),left:a("<div/>").addClass("smallOverlay smallOverlayLeft").css(h),right:a("<div/>").addClass("smallOverlay smallOverlayRight").css(h).css("left",i*2)},b.init(),d.bind("halloactivated",b.enableDragging),d.bind("hallodeactivated",b.disableDragging)}})}(jQuery),function(a){return a.widget("IKS.halloreundo",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},_create:function(){var b,c,d=this;return c=a('<span class="'+this.widgetName+'"></span>'),b=function(b,e){var f;return f=a("<span></span>"),f.hallobutton({uuid:d.options.uuid,editable:d.options.editable,label:e,icon:b==="undo"?"icon-arrow-left":"icon-arrow-right",command:b,queryState:!1,cssClass:d.options.buttonCssClass}),c.append(f)},b("undo","Undo"),b("redo","Redo"),c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("Liip.hallooverlay",{options:{editable:null,toolbar:null,uuid:"",overlay:null,padding:10,background:null},_create:function(){var b;b=this;if(!this.options.bound)return this.options.bound=!0,b.options.editable.element.bind("halloactivated",function(c,d){b.options.currentEditable=a(c.target);if(!b.options.visible)return b.showOverlay()}),b.options.editable.element.bind("hallomodified",function(c,d){b.options.currentEditable=a(c.target);if(b.options.visible)return b.resizeOverlay()}),b.options.editable.element.bind("hallodeactivated",function(c,d){b.options.currentEditable=a(c.target);if(b.options.visible)return b.hideOverlay()})},_init:function(){},showOverlay:function(){return this.options.visible=!0,this.options.overlay===null&&(a("#halloOverlay").length>0?this.options.overlay=a("#halloOverlay"):(this.options.overlay=a('<div id="halloOverlay" class="halloOverlay">'),a(document.body).append(this.options.overlay)),this.options.overlay.bind("click",a.proxy(this.options.editable.turnOff,this.options.editable))),this.options.overlay.show(),this.options.background===null&&(a("#halloBackground").length>0?this.options.background=a("#halloBackground"):(this.options.background=a('<div id="halloBackground" class="halloBackground">'),a(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 a;return a=this.options.currentEditable.offset(),this.options.background.css({top:a.top-this.options.padding,left:a.left-this.options.padding}),this.options.background.width(this.options.currentEditable.width()+2*this.options.padding),this.options.background.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(a){var b;return b=a.css("background-color"),b!=="rgba(0, 0, 0, 0)"&&b!=="transparent"?b:a.is("body")?"white":this._findBackgroundColor(a.parent())}})}(jQuery),function(a){return a.widget("IKS.halloheadings",{options:{editable:null,toolbar:null,uuid:"",headers:[1,2,3]},_create:function(){var b,c,d,e,f,g,h,i,j,k,l=this;h=this,d=a('<span class="'+h.widgetName+'"></span>'),f=""+this.options.uuid+"-paragraph",g="P",d.append(a('<input id="'+f+'" type="radio" name="'+h.options.uuid+'-headings"/><label for="'+f+'" class="p_button">'+g+"</label>").button()),b=a("#"+f,d),b.attr("hallo-command","formatBlock"),b.bind("change",function(b){var c;return c=a(this).attr("hallo-command"),h.options.editable.execute(c,"P")}),c=function(c){return g="H"+c,f=""+l.options.uuid+"-"+c,d.append(a('<input id="'+f+'" type="radio" name="'+h.options.uuid+'-headings"/><label for="'+f+'" class="h'+c+'_button">'+g+"</label>").button()),b=a("#"+f,d),b.attr("hallo-size","H"+c),b.bind("change",function(b){var c;return c=a(this).attr("hallo-size"),h.options.editable.execute("formatBlock",c)})},k=this.options.headers;for(i=0,j=k.length;i<j;i++)e=k[i],c(e);return d.buttonset(),this.element.bind("keyup paste change mouseup",function(b){var c,e,f,g,i;try{c=document.queryCommandValue("formatBlock").toUpperCase()}catch(j){c=""}if(c==="P")i=a("#"+h.options.uuid+"-paragraph");else if(g=c.match(/\d/))e=g[0],i=a("#"+h.options.uuid+"-"+e);f=a(d),f.children("input").attr("checked",!1),f.children("label").removeClass("ui-state-clicked"),f.children("input").button("widget").button("refresh");if(i)return i.attr("checked",!0),i.next("label").addClass("ui-state-clicked"),i.button("refresh")}),this.options.toolbar.append(d)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.hallolink",{options:{editable:null,toolbar: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"}},_create:function(){var b,c,d,e,f,g,h,i=this;h=this,e=""+this.options.uuid+"-dialog",d=a('<div id="'+e+'"><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>'),g=a("input[name=url]",d).focus(function(a){return this.select()}),f=function(){var a;return a=g.val(),h.options.editable.restoreSelection(h.lastSelection),(new RegExp(/^\s*$/)).test(a)||a===h.options.defaultUrl?(h.lastSelection.collapsed&&(h.lastSelection.setStartBefore(h.lastSelection.startContainer),h.lastSelection.setEndAfter(h.lastSelection.startContainer),window.getSelection().addRange(h.lastSelection)),document.execCommand("unlink",null,"")):h.lastSelection.startContainer.parentNode.href===void 0?document.execCommand("createLink",null,a):h.lastSelection.startContainer.parentNode.href=a,h.options.editable.element.trigger("change"),h.options.editable.removeAllSelections(),d.dialog("close"),!1},d.find("form").submit(f),c=a('<span class="'+h.widgetName+'"></span>'),b=function(b){var e,f;return f=""+i.options.uuid+"-"+b,c.append(a('<input id="'+f+'" type="checkbox" /><label for="'+f+'" class="btn anchor_button" ><i class="icon-bookmark"></i></label>').button()),e=a("#"+f,c),e.bind("change",function(b){return h.lastSelection=h.options.editable.getSelection(),g=a("input[name=url]",d),h.lastSelection.startContainer.parentNode.href===void 0?g.val(h.options.defaultUrl):(g.val(a(h.lastSelection.startContainer.parentNode).attr("href")),a(g[0].form).find("input[type=submit]").val("update")),d.dialog("open")}),i.element.bind("keyup paste change mouseup",function(b){var c,d;return d=a(h.options.editable.getSelection().startContainer),c=d.prop("nodeName")?d.prop("nodeName"):d.parent().prop("nodeName"),c&&c.toUpperCase()==="A"?(e.attr("checked",!0),e.next().addClass("ui-state-clicked"),e.button("refresh")):(e.attr("checked",!1),e.next().removeClass("ui-state-clicked"),e.button("refresh"))})},this.options.link&&b("A");if(this.options.link)return c.buttonset(),this.options.toolbar.append(c),d.dialog(this.options.dialogOpts)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.hallojustify",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},_create:function(){var b,c,d=this;return c=a('<span class="'+this.widgetName+'"></span>'),b=function(b){var e;return e=a("<span></span>"),e.hallobutton({uuid:d.options.uuid,editable:d.options.editable,label:b,command:"justify"+b,icon:"icon-align-"+b.toLowerCase(),cssClass:d.options.buttonCssClass}),c.append(e)},b("Left"),b("Center"),b("Right"),c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.halloformat",{options:{editable:null,toolbar:null,uuid:"",formattings:{bold:!0,italic:!0,strikeThrough:!1,underline:!1},buttonCssClass:null},_create:function(){var b,c,d,e,f,g,h=this;f=this,c=a('<span class="'+f.widgetName+'"></span>'),b=function(b){var d;return d=a("<span></span>"),d.hallobutton({label:b,editable:h.options.editable,command:b,uuid:h.options.uuid,cssClass:h.options.buttonCssClass}),c.append(d)},g=this.options.formattings;for(e in g)d=g[e],d&&b(e);return c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.hallolists",{options:{editable:null,toolbar:null,uuid:"",lists:{ordered:!1,unordered:!0},buttonCssClass:null},_create:function(){var b,c,d=this;return c=a('<span class="'+this.widgetName+'"></span>'),b=function(b,e){var f;return f=a("<span></span>"),f.hallobutton({uuid:d.options.uuid,editable:d.options.editable,label:e,command:"insert"+b+"List",icon:"icon-list",cssClass:d.options.buttonCssClass}),c.append(f)},this.options.lists.ordered&&b("Ordered","OL"),this.options.lists.unordered&&b("Unordered","UL"),c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery)})).call(this);
+/*
+ Hallo - a rich text editing jQuery UI widget
+ (c) 2011 Henri Bergius, IKS Consortium
+ Hallo may be freely distributed under the MIT license
+ */(function(a){return a.widget("IKS.hallo",{toolbar:null,toolbarMoved:!1,bound:!1,originalContent:"",uuid:"",selection:null,options:{editable:!0,plugins:{},floating:!0,offset:{x:0,y:0},fixed:!1,showAlways:!1,activated:function(){},deactivated:function(){},selected:function(){},unselected:function(){},enabled:function(){},disabled:function(){},placeholder:"",parentElement:"body",forceStructured:!0,buttonCssClass:null},_create:function(){var b,c,d,e;this.originalContent=this.getContents(),this.id=this._generateUUID(),this._prepareToolbar(),d=this.options.plugins,e=[];for(c in d)b=d[c],a.isPlainObject(b)||(b={}),b.editable=this,b.toolbar=this.toolbar,b.uuid=this.id,b.buttonCssClass=this.options.buttonCssClass,e.push(a(this.element)[c](b));return e},_init:function(){return this._setToolbarPosition(),this.options.editable?this.enable():this.disable()},disable:function(){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,this._trigger("disabled",null)},enable:function(){var a;return this.element.attr("contentEditable",!0),this.element.html()||this.element.html(this.options.placeholder),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),a=this,this.bound=!0),this.options.forceStructured&&this._forceStructured(),this._trigger("enabled",null)},activate:function(){return this.element.focus()},getSelection:function(){var b,c;if(a.browser.msie)b=document.selection.createRange();else{if(window.getSelection)c=window.getSelection();else{if(!document.selection)throw"Your browser does not support selection handling";c=document.selection.createRange()}c.rangeCount>0?b=c.getRangeAt(0):b=c}return b},restoreSelection:function(b){return a.browser.msie?b.select():(window.getSelection().removeAllRanges(),window.getSelection().addRange(b))},replaceSelection:function(b){var c,d,e,f,g;return a.browser.msie?(g=document.selection.createRange().text,d=document.selection.createRange(),d.pasteHTML(b(g))):(f=window.getSelection(),e=f.getRangeAt(0),c=document.createTextNode(b(e.extractContents())),e.insertNode(c),e.setStartAfter(c),f.removeAllRanges(),f.addRange(e))},removeAllSelections:function(){return a.browser.msie?range.empty():window.getSelection().removeAllRanges()},getContents:function(){var b,c;b=this.element.clone();for(c in this.options.plugins)a(this.element)[c]("cleanupContentClone",b);return b.html()},setContents:function(a){return this.element.html(a)},isModified:function(){return this.originalContent!==this.getContents()},setUnmodified:function(){return this.originalContent=this.getContents()},setModified:function(){return this._trigger("modified",null,{editable:this,content:this.getContents()})},restoreOriginalContent:function(){return this.element.html(this.originalContent)},execute:function(a,b){if(document.execCommand(a,!1,b))return this.element.trigger("change")},protectFocusFrom:function(a){var b;return b=this,a.bind("mousedown",function(a){return a.preventDefault(),b._protectToolbarFocus=!0,setTimeout(function(){return b._protectToolbarFocus=!1},300)})},_generateUUID:function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},""+a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},_getToolbarPosition:function(a,b){var c;if(!a)return;if(!this.options.floating)return c=parseFloat(this.element.css("outline-width"))+parseFloat(this.element.css("outline-offset")),{top:this.element.offset().top-this.toolbar.outerHeight()-c,left:this.element.offset().left-c};if(a.originalEvent instanceof KeyboardEvent)return this._getCaretPosition(b);if(a.originalEvent instanceof MouseEvent)return{top:a.pageY,left:a.pageX}},_getCaretPosition:function(b){var c,d,e;return e=a("<span/>"),c=document.createRange(),c.setStart(b.endContainer,b.endOffset),c.insertNode(e.get(0)),d={top:e.offset().top,left:e.offset().left},e.remove(),d},_bindToolbarEventsFixed:function(){var a=this;return this.options.floating=!1,this.element.bind("halloactivated",function(b,c){return a._updateToolbarPosition(a._getToolbarPosition(b)),a.toolbar.show()}),this.element.bind("hallodeactivated",function(b,c){return a.toolbar.hide()})},_bindToolbarEventsRegular:function(){var a=this;return this.element.bind("halloselected",function(b,c){var d;d=a._getToolbarPosition(c.originalEvent,c.selection);if(!d)return;return a._updateToolbarPosition(d),a.toolbar.show()}),this.element.bind("hallounselected",function(b,c){return a.toolbar.hide()}),this.element.bind("hallodeactivated",function(b,c){return a.toolbar.hide()})},_setToolbarPosition:function(){if(this.options.fixed){this.toolbar.css("position","static"),this.toolbarMoved&&a(this.options.parentElement).append(this.toolbar),this.toolbarMoved=!1;return}return this.options.parentElement!=="body"&&(a("body").append(this.toolbar),this.toolbarMoved=!0),this.toolbar.css("position","absolute"),this.toolbar.css("top",this.element.offset().top-20),this.toolbar.css("left",this.element.offset().left)},_prepareToolbar:function(){var b,c=this;return this.toolbar=a('<div class="hallotoolbar"></div>').hide(),this._setToolbarPosition(),a(this.options.parentElement).append(this.toolbar),b=this,this.options.showAlways&&this._bindToolbarEventsFixed(),this.options.showAlways||this._bindToolbarEventsRegular(),a(window).resize(function(a){return c._updateToolbarPosition(c._getToolbarPosition(a))}),this.protectFocusFrom(this.toolbar)},_updateToolbarPosition:function(a){if(this.options.fixed)return;if(!a)return;if(!a.top||!a.left)return;return this.toolbar.css("top",a.top),this.toolbar.css("left",a.left)},_checkModified:function(a){var b;b=a.data;if(b.isModified())return b.setModified()},_keys:function(a){var b,c;c=a.data;if(a.keyCode===27)return b=c.getContents(),c.restoreOriginalContent(a),c._trigger("restored",null,{editable:c,content:c.getContents(),thrown:b}),c.turnOff()},_rangesEqual:function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset},_checkSelection:function(a){var b;if(a.keyCode===27)return;return b=a.data,setTimeout(function(){var c;c=b.getSelection();if(b._isEmptySelection(c)||b._isEmptyRange(c)){b.selection&&(b.selection=null,b._trigger("unselected",null,{editable:b,originalEvent:a}));return}if(!b.selection||!b._rangesEqual(c,b.selection))return b.selection=c.cloneRange(),b._trigger("selected",null,{editable:b,selection:b.selection,ranges:[b.selection],originalEvent:a})},0)},_isEmptySelection:function(a){return a.type==="Caret"?!0:!1},_isEmptyRange:function(a){return a.collapsed?!0:a.isCollapsed?typeof a.isCollapsed=="function"?a.isCollapsed():a.isCollapsed:!1},turnOn:function(){var b,c;return this.getContents()===this.options.placeholder&&this.setContents(""),a(this.element).addClass("inEditMode"),this.options.floating?this.toolbar.css("width","auto"):(b=a(this.element),c=parseFloat(b.css("padding-left")),c+=parseFloat(b.css("padding-right")),c+=parseFloat(b.css("border-left-width")),c+=parseFloat(b.css("border-right-width")),c+=parseFloat(b.css("outline-width"))*2,c+=parseFloat(b.css("outline-offset"))*2,a(this.toolbar).css("width",b.width()+c)),this._trigger("activated",this)},turnOff:function(){a(this.element).removeClass("inEditMode"),this._trigger("deactivated",this);if(!this.getContents())return this.setContents(this.options.placeholder)},_activated:function(a){return a.data.turnOn()},_deactivated:function(b){return b.data._protectToolbarFocus!==!0?b.data.turnOff():setTimeout(function(){return a(b.data.element).focus()},300)},_forceStructured:function(a){try{return document.execCommand("styleWithCSS",0,!1)}catch(b){try{return document.execCommand("useCSS",0,!0)}catch(b){try{return document.execCommand("styleWithCSS",!1,!1)}catch(b){}}}}})})(jQuery),function(a){return a.widget("IKS.hallolists",{options:{editable:null,toolbar:null,uuid:"",lists:{ordered:!1,unordered:!0},buttonCssClass:null},_create:function(){var b,c,d=this;return c=a('<span class="'+this.widgetName+'"></span>'),b=function(b,e){var f;return f=a("<span></span>"),f.hallobutton({uuid:d.options.uuid,editable:d.options.editable,label:e,command:"insert"+b+"List",icon:"icon-list",cssClass:d.options.buttonCssClass}),c.append(f)},this.options.lists.ordered&&b("Ordered","OL"),this.options.lists.unordered&&b("Unordered","UL"),c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.halloheadings",{options:{editable:null,toolbar:null,uuid:"",headers:[1,2,3]},_create:function(){var b,c,d,e,f,g,h,i,j,k,l=this;h=this,d=a('<span class="'+h.widgetName+'"></span>'),f=""+this.options.uuid+"-paragraph",g="P",d.append(a('<input id="'+f+'" type="radio" name="'+h.options.uuid+'-headings"/><label for="'+f+'" class="p_button">'+g+"</label>").button()),b=a("#"+f,d),b.attr("hallo-command","formatBlock"),b.bind("change",function(b){var c;return c=a(this).attr("hallo-command"),h.options.editable.execute(c,"P")}),c=function(c){return g="H"+c,f=""+l.options.uuid+"-"+c,d.append(a('<input id="'+f+'" type="radio" name="'+h.options.uuid+'-headings"/><label for="'+f+'" class="h'+c+'_button">'+g+"</label>").button()),b=a("#"+f,d),b.attr("hallo-size","H"+c),b.bind("change",function(b){var c;return c=a(this).attr("hallo-size"),h.options.editable.execute("formatBlock",c)})},k=this.options.headers;for(i=0,j=k.length;i<j;i++)e=k[i],c(e);return d.buttonset(),this.element.bind("keyup paste change mouseup",function(b){var c,e,f,g,i;try{c=document.queryCommandValue("formatBlock").toUpperCase()}catch(j){c=""}if(c==="P")i=a("#"+h.options.uuid+"-paragraph");else if(g=c.match(/\d/))e=g[0],i=a("#"+h.options.uuid+"-"+e);f=a(d),f.children("input").attr("checked",!1),f.children("label").removeClass("ui-state-clicked"),f.children("input").button("widget").button("refresh");if(i)return i.attr("checked",!0),i.next("label").addClass("ui-state-clicked"),i.button("refresh")}),this.options.toolbar.append(d)},_init:function(){}})}(jQuery),function(a){return a.widget("Liip.hallooverlay",{options:{editable:null,toolbar:null,uuid:"",overlay:null,padding:10,background:null},_create:function(){var b;b=this;if(!this.options.bound)return this.options.bound=!0,b.options.editable.element.bind("halloactivated",function(c,d){b.options.currentEditable=a(c.target);if(!b.options.visible)return b.showOverlay()}),b.options.editable.element.bind("hallomodified",function(c,d){b.options.currentEditable=a(c.target);if(b.options.visible)return b.resizeOverlay()}),b.options.editable.element.bind("hallodeactivated",function(c,d){b.options.currentEditable=a(c.target);if(b.options.visible)return b.hideOverlay()})},_init:function(){},showOverlay:function(){return this.options.visible=!0,this.options.overlay===null&&(a("#halloOverlay").length>0?this.options.overlay=a("#halloOverlay"):(this.options.overlay=a('<div id="halloOverlay" class="halloOverlay">'),a(document.body).append(this.options.overlay)),this.options.overlay.bind("click",a.proxy(this.options.editable.turnOff,this.options.editable))),this.options.overlay.show(),this.options.background===null&&(a("#halloBackground").length>0?this.options.background=a("#halloBackground"):(this.options.background=a('<div id="halloBackground" class="halloBackground">'),a(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 a;return a=this.options.currentEditable.offset(),this.options.background.css({top:a.top-this.options.padding,left:a.left-this.options.padding}),this.options.background.width(this.options.currentEditable.width()+2*this.options.padding),this.options.background.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(a){var b;return b=a.css("background-color"),b!=="rgba(0, 0, 0, 0)"&&b!=="transparent"?b:a.is("body")?"white":this._findBackgroundColor(a.parent())}})}(jQuery),function(a){return a.widget("Liip.hallotoolbarlinebreak",{options:{editable:null,toolbar:null,uuid:"",breakAfter:[]},_create:function(){var b,c,d,e,f,g,h,i,j,k;c=a(".ui-buttonset",this.options.toolbar),d=a(),f=0,k=this.options.breakAfter;for(g=0,i=k.length;g<i;g++){e=k[g],f++;for(h=0,j=c.length;h<j;h++){b=c[h],d=a(d).add(a(b));if(a(b).hasClass(e)){d.wrapAll('<div class="halloButtonrow halloButtonrow-'+f+'" />'),c=c.not(d),d=a();break}}}if(c.length>0)return f++,c.wrapAll('<div class="halloButtonrow halloButtonrow-'+f+'" />')},_init:function(){}})}(jQuery),function(a){var b;return b=null,this.VIE!==void 0&&(b=new VIE,b.use(new b.StanbolService({proxyDisabled:!0,url:"http://dev.iks-project.eu:8081"}))),a.widget("IKS.halloannotate",{options:{vie:b,editable:null,toolbar:null,uuid:"",select:function(){},decline:function(){},remove:function(){},buttonCssClass:null},_create:function(){var b,c,d,e,f=this;e=this;if(this.options.vie===void 0)throw"The halloannotate plugin requires VIE to be loaded";if(typeof this.element.annotate!="function")throw"The halloannotate plugin requires annotate.js to be loaded";return this.state="off",b=a('<span class="'+e.widgetName+'"></span>'),this.button=b.hallobutton({label:"Annotate",icon:"icon-tags",editable:this.options.editable,command:null,uuid:this.options.uuid,cssClass:this.options.buttonCssClass,queryState:!1}),b.bind("change",function(a){if(f.state==="pending")return;return f.state==="off"?f.turnOn():f.turnOff()}),b.buttonset(),this.options.toolbar.append(this.button),this.instantiate(),d=function(){var b;return b=this,a(b).halloannotate("turnOff")},c=this.options.editable.element,c.bind("hallodisabled",d)},cleanupContentClone:function(b){if(this.state==="on")return b.find(".entity:not([about])").each(function(){return a(this).replaceWith(a(this).html())})},instantiate:function(){return 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(){return a.noop()}).bind("annotateremove",function(){return a.noop()})},turnPending:function(){return this.state="pending",this.button.hallobutton("checked",!1),this.button.hallobutton("disable")},turnOn:function(){var a,b=this;this.turnPending(),a=this;try{return this.options.editable.element.annotate("enable",function(a){if(a)return b.state="on",b.button.hallobutton("checked",!0),b.button.hallobutton("enable")})}catch(c){return alert(c)}},turnOff:function(){return this.options.editable.element.annotate("disable"),this.button.attr("checked",!1),this.button.find("label").removeClass("ui-state-clicked"),this.button.button("refresh"),this.state="off"}})}(jQuery),function(a){return a.widget("Liip.halloimage",{options:{editable:null,toolbar:null,uuid:"",limit:8,search: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",close:function(b,c){return a(".image_button").removeClass("ui-state-clicked")}},dialog:null,buttonCssClass:null},_create:function(){var b,c,d,e,f,g;return g=this,e=""+this.options.uuid+"-image-dialog",this.options.dialog=a('<div id="'+e+'"> <div class="nav"> <ul class="tabs"> </ul> <div id="'+this.options.uuid+'-tab-activeIndicator" class="tab-activeIndicator" /> </div> <div class="dialogcontent"> </div>'),g.options.uploadUrl&&!g.options.upload&&(g.options.upload=g._iframeUpload),g.options.suggestions&&this._addGuiTabSuggestions(a(".tabs",this.options.dialog),a(".dialogcontent",this.options.dialog)),g.options.search&&this._addGuiTabSearch(a(".tabs",this.options.dialog),a(".dialogcontent",this.options.dialog)),g.options.upload&&this._addGuiTabUpload(a(".tabs",this.options.dialog),a(".dialogcontent",this.options.dialog)),d=a('<span class="'+g.widgetName+'"></span>'),f=""+this.options.uuid+"-image",c=a("<span></span>"),c.hallobutton({label:"Images",icon:"icon-picture",editable:this.options.editable,command:null,queryState:!1,uuid:this.options.uuid,cssClass:this.options.buttonCssClass}),d.append(c),b=c.button(),b.bind("change",function(a){return g.options.dialog.dialog("isOpen")?g._closeDialog():g._openDialog()}),this.options.editable.element.bind("hallodeactivated",function(a){return g._closeDialog()}),a(this.options.editable.element).delegate("img","click",function(a){return g._openDialog()}),a(this.options.dialog).find(".nav li").click(function(){return a("."+g.widgetName+"-tab").each(function(){return a(this).hide()}),f=a(this).attr("id"),a("#"+f+"-content").show(),a("#"+g.options.uuid+"-tab-activeIndicator").css("margin-left",a(this).position().left+a(this).width()/2)}),a("."+g.widgetName+"-tab .imageThumbnail").live("click",function(b){var c;return c=a(this).closest("."+g.widgetName+"-tab"),a(".imageThumbnail",c).removeClass("imageThumbnailActive"),a(this).addClass("imageThumbnailActive"),a(".activeImage",c).attr("src",a(this).attr("src")),a(".activeImageBg",c).attr("src",a(this).attr("src"))}),d.buttonset(),this.options.toolbar.append(d),this.options.dialog.dialog(this.options.dialogOpts),this._addDragnDrop()},_init:function(){},_openDialog:function(){var b,c,d,e,f,g,h,i,j,k,l,m;k=this,c=function(){return window.setTimeout(function(){var b;return b=a(".imageThumbnail"),a(b).each(function(){var b;b=a("#"+this.id).width();if(b<=20)return a("#"+this.id).parent("li").remove()})},15e3)},e=!1,f=function(b){a.each(b.assets,function(b,c){return a(".imageThumbnailContainer ul").append('<li><img src="'+c.url+'" class="imageThumbnail"></li>'),e=!0});if(b.assets.length>0)return a("#activitySpinner").hide()},a(".image_button").addClass("ui-state-clicked"),a("#"+this.options.uuid+"-sugg-activeImage").attr("src",a("#"+this.options.uuid+"-tab-suggestions-content .imageThumbnailActive").first().attr("src")),a("#"+this.options.uuid+"-sugg-activeImageBg").attr("src",a("#"+this.options.uuid+"-tab-suggestions-content .imageThumbnailActive").first().attr("src")),this.lastSelection=this.options.editable.getSelection(),l=a(this.options.editable.element).offset().left+a(this.options.editable.element).outerWidth()-3,m=a(this.options.toolbar).offset().top-a(document).scrollTop()-29,this.options.dialog.dialog("option","position",[l,m]);if(k.options.loaded===null&&k.options.suggestions){b=[],a("#activitySpinner").show(),i=a(".inEditMode").parent().find(".articleTags input").val(),i=i.split(",");for(d in i)g=typeof i[d],"string"===g&&i[d].indexOf("http")!==-1&&b.push(i[d]);a(".imageThumbnailContainer ul").empty(),k.options.suggestions(a(".inEditMode").parent().find(".articleTags input").val(),k.options.limit,0,f),j=new VIE,j.use(new j.DBPediaService({url:"http://dev.iks-project.eu/stanbolfull",proxyDisabled:!0})),h=1,b.length===0&&a("#activitySpinner").html("No images found."),a(b).each(function(){return j.load({entity:this+""}).using("dbpedia").execute().done(function(b){return a(b).each(function(){var b,c;if(this.attributes["<http://dbpedia.org/ontology/thumbnail>"])return c=typeof this.attributes["<http://dbpedia.org/ontology/thumbnail>"],c==="string"&&(b=this.attributes["<http://dbpedia.org/ontology/thumbnail>"],b=b.substring(1,b.length-1)),c==="object"&&(b="",b=this.attributes["<http://dbpedia.org/ontology/thumbnail>"][0].value),a(".imageThumbnailContainer ul").append('<li><img id="si-'+h+'" src="'+b+'" class="imageThumbnail"></li>'),h++}),a("#activitySpinner").hide()})})}return c(),k.options.loaded=1,this.options.dialog.dialog("open")},_closeDialog:function(){return this.options.dialog.dialog("close")},_addGuiTabSuggestions:function(b,c){var d;return d=this,b.append(a('<li id="'+this.options.uuid+'-tab-suggestions" class="'+d.widgetName+"-tabselector "+d.widgetName+'-tab-suggestions"><span>Suggestions</span></li>')),c.append(a('<div id="'+this.options.uuid+'-tab-suggestions-content" class="'+d.widgetName+'-tab tab-suggestions"> <div class="imageThumbnailContainer fixed"><div id="activitySpinner">Loading Images...</div><ul><li> <img src="http://imagesus.homeaway.com/mda01/badf2e69babf2f6a0e4b680fc373c041c705b891" class="imageThumbnail imageThumbnailActive" /> </li></ul><br style="clear:both"/> </div> <div class="activeImageContainer"> <div class="rotationWrapper"> <div class="hintArrow"></div> <img src="" id="'+this.options.uuid+'-sugg-activeImage" class="activeImage" /> </div> <img src="" id="'+this.options.uuid+'-sugg-activeImageBg" class="activeImage activeImageBg" /> </div> <div class="metadata"> <label for="caption-sugg">Caption</label><input type="text" id="caption-sugg" /> </div> </div>'))},_addGuiTabSearch:function(b,c){var d,e;return e=this,d=""+this.options.uuid+"-image-dialog",b.append(a('<li id="'+this.options.uuid+'-tab-search" class="'+e.widgetName+"-tabselector "+e.widgetName+'-tab-search"><span>Search</span></li>')),c.append(a('<div id="'+this.options.uuid+'-tab-search-content" class="'+e.widgetName+'-tab tab-search"> <form type="get" id="'+this.options.uuid+"-"+e.widgetName+'-searchForm"> <input type="text" class="searchInput" /><input type="submit" id="'+this.options.uuid+"-"+e.widgetName+'-searchButton" class="button searchButton" value="OK"/> </form> <div class="searchResults imageThumbnailContainer"></div> <div id="'+this.options.uuid+'-search-activeImageContainer" class="search-activeImageContainer activeImageContainer"> <div class="rotationWrapper"> <div class="hintArrow"></div> <img src="" id="'+this.options.uuid+'-search-activeImageBg" class="activeImage" /> </div> <img src="" id="'+this.options.uuid+'-search-activeImage" class="activeImage activeImageBg" /> </div> <div class="metadata" id="metadata-search" style="display: none;"> <label for="caption-search">Caption</label><input type="text" id="caption-search" /> <!--<button id="'+this.options.uuid+"-"+e.widgetName+'-addimage">Add Image</button>--> </div> </div>')),a(".tab-search form",c).submit(function(b){var c,f;return b.preventDefault(),f=this,c=function(b){var f,g,h;return h=[],h.push('<div class="pager-prev" style="display:none"></div>'),a.each(b.assets,function(a,b){return h.push('<img src="'+b.url+'" class="imageThumbnail '+e.widgetName+'-search-imageThumbnail" /> ')}),h.push('<div class="pager-next" style="display:none"></div>'),f=a("#"+d+" .tab-search .searchResults"),f.html(h.join("")),b.offset>0&&a(".pager-prev",f).show(),b.offset<b.total&&a(".pager-next",f).show(),a(".pager-prev",f).click(function(a){return e.options.search(null,e.options.limit,b.offset-e.options.limit,c)}),a(".pager-next",f).click(function(a){return e.options.search(null,e.options.limit,b.offset+e.options.limit,c)}),a("#"+e.options.uuid+"-search-activeImageContainer").show(),g=a("."+e.widgetName+"-search-imageThumbnail").first().addClass("imageThumbnailActive"),a("#"+e.options.uuid+"-search-activeImage, #"+e.options.uuid+"-search-activeImageBg").attr("src",g.attr("src")),a("#metadata-search").show()},e.options.search(null,e.options.limit,0,c)})},_prepareIframe:function(b){var c;return b.options.iframeName=""+b.options.uuid+"-"+b.widgetName+"-postframe",c=a('<iframe name="'+b.options.iframeName+'" id="'+b.options.iframeName+'" class="hidden" src="javascript:false;" style="display:none" />'),a("#"+b.options.uuid+"-"+b.widgetName+"-iframe").append(c),c.get(0).name=b.options.iframeName},_iframeUpload:function(b){var c,d;return d=b.widget,d._prepareIframe(d),a("#"+d.options.uuid+"-"+d.widgetName+"-tags").val(a(".inEditMode").parent().find(".articleTags input").val()),c=a("#"+d.options.uuid+"-"+d.widgetName+"-uploadform"),c.attr("action",d.options.uploadUrl),c.attr("method","post"),c.attr("userfile",b.file),c.attr("enctype","multipart/form-data"),c.attr("encoding","multipart/form-data"),c.attr("target",d.options.iframeName),c.submit(),a("#"+d.options.iframeName).load(function(){return b.success(a("#"+d.options.iframeName)[0].contentWindow.location.href)})},_addGuiTabUpload:function(b,c){var d,e,f;return f=this,b.append(a('<li id="'+this.options.uuid+'-tab-upload" class="'+f.widgetName+"-tabselector "+f.widgetName+'-tab-upload"><span>Upload</span></li>')),c.append(a('<div id="'+this.options.uuid+'-tab-upload-content" class="'+f.widgetName+'-tab tab-upload"> <form id="'+this.options.uuid+"-"+f.widgetName+'-uploadform"> <input id="'+this.options.uuid+"-"+f.widgetName+'-file" name="'+this.options.uuid+"-"+f.widgetName+'-file" type="file" class="file"> <input id="'+this.options.uuid+"-"+f.widgetName+'-tags" name="tags" type="hidden" /> <br /> <input type="submit" value="Upload" id="'+this.options.uuid+"-"+f.widgetName+'-upload"> </form> <div id="'+this.options.uuid+"-"+f.widgetName+'-iframe"></div> </div>')),d=a('<iframe name="postframe" id="postframe" class="hidden" src="about:none" style="display:none" />'),a("#"+f.options.uuid+"-"+f.widgetName+"-upload").live("click",function(b){var c;return b.preventDefault(),c=a("#"+f.options.uuid+"-"+f.widgetName+"-file").val(),f.options.upload({widget:f,file:c,success:function(b){var c,d;return c="si"+Math.floor(Math.random()*101+400)+"ab",a(".imageThumbnailContainer ul",f.options.dialog).length===0&&(d=a("<ul></ul>"),a(".imageThumbnailContainer").append(d)),a(".imageThumbnailContainer ul",f.options.dialog).append('<li><img src="'+b+'" id="'+c+'" class="imageThumbnail"></li>'),a("#"+c).trigger("click"),a(f.options.dialog).find(".nav li").first().trigger("click")}}),!1}),e=function(){var b,c;try{if(!f.options.editable.getSelection())throw new Error("SelectionNotSet")}catch(d){f.options.editable.restoreSelection(f.lastSelection)}return document.execCommand("insertImage",null,a(this).attr("src")),b=document.getSelection().anchorNode.firstChild,a(b).attr("alt",a(".caption").value),c=function(){return f.element.trigger("hallomodified")},window.setTimeout(c,100),f._closeDialog()},this.options.dialog.find(".halloimage-activeImage, #"+f.options.uuid+"-"+f.widgetName+"-addimage").click(e)},_addDragnDrop:function(){var b,c,d,e,f,g,h,i,j;return e={delayAction:function(a,b){var c;c=clearTimeout(c);if(!c)return c=setTimeout(a,b)},calcPosition:function(a,b){var c;c=a.left+i;if(b.pageX>=c&&b.pageX<=a.left+i*2)return"middle";if(b.pageX<c)return"left";if(b.pageX>a.left+i*2)return"right"},createInsertElement:function(b,c){var d,e,f,g,h,i,j,k;h=250,g=250,j=new Image,j.src=b.src,c||(this.startPlace.parents(".tab-suggestions").length>0?d=a("#caption-sugg").val():this.startPlace.parents(".tab-search").length>0?d=a("#caption-search").val():d=a(b).attr("alt")),k=j.width,e=j.height;if(k>h||e>g)k>e?i=(j.width/h).toFixed():i=(j.height/g).toFixed(),k=(j.width/i).toFixed(),e=(j.height/i).toFixed();return f=a("<img>").attr({src:j.src,width:k,height:e,alt:d,"class":c?"tmp":""}).show(),f},createLineFeedbackElement:function(){return a("<div/>").addClass("tmpLine")},removeFeedbackElements:function(){return a(".tmp, .tmpLine",d).remove()},removeCustomHelper:function(){return a(".customHelper").remove()},showOverlay:function(a){var b;b=d.height()+parseFloat(d.css("paddingTop"))+parseFloat(d.css("paddingBottom")),g.big.css({height:b}),g.left.css({height:b}),g.right.css({height:b});switch(a){case"left":return g.big.addClass("bigOverlayLeft").removeClass("bigOverlayRight").css({left:i}).show(),g.left.hide(),g.right.hide();case"middle":return g.big.removeClass("bigOverlayLeft bigOverlayRight"),g.big.hide(),g.left.show(),g.right.show();case"right":return g.big.addClass("bigOverlayRight").removeClass("bigOverlayLeft").css({left:0}).show(),g.left.hide(),g.right.hide()}},checkOrigin:function(b){return a(b.target).parents("[contenteditable]").length!==0?!0:!1},startPlace:""},b={createTmpFeedback:function(a,b){var c;return b==="middle"?e.createLineFeedbackElement():(c=e.createInsertElement(a,!0),c.addClass("inlineImage-"+b))},handleOverEvent:function(c,h){var i;return i=function(){var i;return window.waitWithTrash=clearTimeout(window.waitWithTrash),i=e.calcPosition(f,c),a(".trashcan",h.helper).remove(),d.append(g.big),d.append(g.left),d.append(g.right),e.removeFeedbackElements(),a(c.target).prepend(b.createTmpFeedback(h.draggable[0],i)),i==="middle"?(a(c.target).prepend(b.createTmpFeedback(h.draggable[0],"right")),a(".tmp",a(c.target)).hide()):(a(c.target).prepend(b.createTmpFeedback(h.draggable[0],"middle")),a(".tmpLine",a(c.target)).hide()),e.showOverlay(i)},setTimeout(i,5)},handleDragEvent:function(c,g){var h,i,j;h=e.calcPosition(f,c);if(h===b.lastPositionDrag)return;return b.lastPositionDrag=h,i=a(".tmp",d),j=a(".tmpLine",d),h==="middle"?(j.show(),i.hide()):(j.hide(),i.removeClass("inlineImage-left inlineImage-right").addClass("inlineImage-"+h).show()),e.showOverlay(h)},handleLeaveEvent:function(b,c){var d;return d=function(){return a("div.trashcan",c.helper).length||a(c.helper).append(a('<div class="trashcan"></div>')),a(".bigOverlay, .smallOverlay").remove()},window.waitWithTrash=setTimeout(d,200),e.removeFeedbackElements()},handleStartEvent:function(b,c){var d;return d=e.checkOrigin(b),d&&a(b.target).remove(),a(document).trigger("startPreventSave"),e.startPlace=a(b.target)},handleStopEvent:function(b,c){var f;return f=e.checkOrigin(b),f?a(b.target).remove():d.trigger("change"),g.big.hide(),g.left.hide(),g.right.hide(),a(document).trigger("stopPreventSave")},handleDropEvent:function(c,h){var i,j,k;return j=e.checkOrigin(c),k=e.calcPosition(f,c),e.removeFeedbackElements(),e.removeCustomHelper(),i=e.createInsertElement(h.draggable[0],!1),k==="middle"?(i.show(),i.removeClass("inlineImage-middle inlineImage-left inlineImage-right").addClass("inlineImage-"+k).css({position:"relative",left:(d.width()+parseFloat(d.css("paddingLeft"))+parseFloat(d.css("paddingRight"))-i.attr("width"))/2}),i.insertBefore(a(c.target))):(i.removeClass("inlineImage-middle inlineImage-left inlineImage-right").addClass("inlineImage-"+k).css("display","block"),a(c.target).prepend(i)),g.big.hide(),g.left.hide(),g.right.hide(),d.trigger("change"),b.init(d)},createHelper:function(b){return a("<div>").css({backgroundImage:"url("+a(b.currentTarget).attr("src")+")"}).addClass("customHelper").appendTo("body")},init:function(){var e,f;return e=[],f=function(e){return e.jquery_draggable_initialized||(e.jquery_draggable_initialized=!0,a(e).draggable({cursor:"move",helper:b.createHelper,drag:b.handleDragEvent,start:b.handleStartEvent,stop:b.handleStopEvent,disabled:!d.hasClass("inEditMode"),cursorAt:{top:50,left:50}})),c.push(e)},a(".rotationWrapper img",j.dialog).each(function(a,b){if(!b.jquery_draggable_initialized)return f(b)}),a("img",d).each(function(a,b){b.contentEditable=!1;if(!b.jquery_draggable_initialized)return f(b)}),a("p",d).each(function(c,e){if(!e.jquery_droppable_initialized)return e.jquery_droppable_initialized=!0,a("p",d).droppable({tolerance:"pointer",drop:b.handleDropEvent,over:b.handleOverEvent,out:b.handleLeaveEvent})})},enableDragging:function(){return a.each(c,function(b,c){return a(c).draggable("option","disabled",!1)})},disableDragging:function(){return a.each(c,function(b,c){return a(c).draggable("option","disabled",!0)})}},c=[],d=a(this.options.editable.element),j=this.options,f=d.offset(),i=parseFloat(d.width()/3),h={width:i,height:d.height()},g={big:a("<div/>").addClass("bigOverlay").css({width:i*2,height:d.height()}),left:a("<div/>"
+).addClass("smallOverlay smallOverlayLeft").css(h),right:a("<div/>").addClass("smallOverlay smallOverlayRight").css(h).css("left",i*2)},b.init(),d.bind("halloactivated",b.enableDragging),d.bind("hallodeactivated",b.disableDragging)}})}(jQuery),function(a){return a.widget("IKS.halloformat",{options:{editable:null,toolbar:null,uuid:"",formattings:{bold:!0,italic:!0,strikeThrough:!1,underline:!1},buttonCssClass:null},_create:function(){var b,c,d,e,f,g,h=this;f=this,c=a('<span class="'+f.widgetName+'"></span>'),b=function(b){var d;return d=a("<span></span>"),d.hallobutton({label:b,editable:h.options.editable,command:b,uuid:h.options.uuid,cssClass:h.options.buttonCssClass}),c.append(d)},g=this.options.formattings;for(e in g)d=g[e],d&&b(e);return c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.halloreundo",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},_create:function(){var b,c,d=this;return c=a('<span class="'+this.widgetName+'"></span>'),b=function(b,e){var f;return f=a("<span></span>"),f.hallobutton({uuid:d.options.uuid,editable:d.options.editable,label:e,icon:b==="undo"?"icon-arrow-left":"icon-arrow-right",command:b,queryState:!1,cssClass:d.options.buttonCssClass}),c.append(f)},b("undo","Undo"),b("redo","Redo"),c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.halloblock",{options:{editable:null,toolbar:null,uuid:"",elements:["h1","h2","h3","p","pre","blockquote"],buttonCssClass:null},_create:function(){var b,c,d;return b=a('<span class="'+this.widgetName+'"></span>'),c=""+this.options.uuid+"-"+this.widgetName+"-data",d=this._prepareDropdown(c),b.append(d),b.append(this._prepareButton(d)),this.options.toolbar.append(b)},_prepareDropdown:function(b){var c,d,e,f,g,h,i,j=this;e=a('<div id="'+b+'"></div>'),d=this.options.editable.element.get(0).tagName.toLowerCase(),c=function(b){var c,e;return c=a("<"+b+' class="menu-item">'+b+"</"+b+">"),d===b&&c.addClass("selected"),d!=="div"&&c.addClass("disabled"),c.bind("click",function(){if(c.hasClass("disabled"))return;return j.options.editable.execute("formatBlock",b.toUpperCase())}),e=function(a){var d;d=document.queryCommandValue("formatBlock");if(d.toLowerCase()===b){c.addClass("selected");return}return c.removeClass("selected")},j.options.editable.element.bind("halloenabled",function(){return j.options.editable.element.bind("keyup paste change mouseup",e)}),j.options.editable.element.bind("hallodisabled",function(){return j.options.editable.element.unbind("keyup paste change mouseup",e)}),c},i=this.options.elements;for(g=0,h=i.length;g<h;g++)f=i[g],e.append(c(f));return e},_prepareButton:function(b){var c;return c=a("<span></span>"),c.hallodropdownbutton({uuid:this.options.uuid,editable:this.options.editable,label:"block",icon:"icon-text-height",target:b,cssClass:this.options.buttonCssClass}),c}})}(jQuery),function(a){return a.widget("IKS.hallolink",{options:{editable:null,toolbar: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"}},_create:function(){var b,c,d,e,f,g,h,i=this;h=this,e=""+this.options.uuid+"-dialog",d=a('<div id="'+e+'"><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>'),g=a("input[name=url]",d).focus(function(a){return this.select()}),f=function(){var a;return a=g.val(),h.options.editable.restoreSelection(h.lastSelection),(new RegExp(/^\s*$/)).test(a)||a===h.options.defaultUrl?(h.lastSelection.collapsed&&(h.lastSelection.setStartBefore(h.lastSelection.startContainer),h.lastSelection.setEndAfter(h.lastSelection.startContainer),window.getSelection().addRange(h.lastSelection)),document.execCommand("unlink",null,"")):h.lastSelection.startContainer.parentNode.href===void 0?document.execCommand("createLink",null,a):h.lastSelection.startContainer.parentNode.href=a,h.options.editable.element.trigger("change"),h.options.editable.removeAllSelections(),d.dialog("close"),!1},d.find("form").submit(f),c=a('<span class="'+h.widgetName+'"></span>'),b=function(b){var e,f;return f=""+i.options.uuid+"-"+b,c.append(a('<input id="'+f+'" type="checkbox" /><label for="'+f+'" class="btn anchor_button" ><i class="icon-bookmark"></i></label>').button()),e=a("#"+f,c),e.bind("change",function(b){return h.lastSelection=h.options.editable.getSelection(),g=a("input[name=url]",d),h.lastSelection.startContainer.parentNode.href===void 0?g.val(h.options.defaultUrl):(g.val(a(h.lastSelection.startContainer.parentNode).attr("href")),a(g[0].form).find("input[type=submit]").val("update")),d.dialog("open")}),i.element.bind("keyup paste change mouseup",function(b){var c,d;return d=a(h.options.editable.getSelection().startContainer),c=d.prop("nodeName")?d.prop("nodeName"):d.parent().prop("nodeName"),c&&c.toUpperCase()==="A"?(e.attr("checked",!0),e.next().addClass("ui-state-clicked"),e.button("refresh")):(e.attr("checked",!1),e.next().removeClass("ui-state-clicked"),e.button("refresh"))})},this.options.link&&b("A");if(this.options.link)return c.buttonset(),this.options.toolbar.append(c),d.dialog(this.options.dialogOpts)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.hallojustify",{options:{editable:null,toolbar:null,uuid:"",buttonCssClass:null},_create:function(){var b,c,d=this;return c=a('<span class="'+this.widgetName+'"></span>'),b=function(b){var e;return e=a("<span></span>"),e.hallobutton({uuid:d.options.uuid,editable:d.options.editable,label:b,command:"justify"+b,icon:"icon-align-"+b.toLowerCase(),cssClass:d.options.buttonCssClass}),c.append(e)},b("Left"),b("Center"),b("Right"),c.buttonset(),this.options.toolbar.append(c)},_init:function(){}})}(jQuery),function(a){return a.widget("IKS.hallobutton",{button:null,options:{uuid:"",label:null,icon:null,editable:null,command:null,queryState:!0,cssClass:null},_create:function(){var a,b,c;return(c=(b=this.options).icon)==null&&(b.icon="icon-"+this.options.label.toLowerCase()),a=""+this.options.uuid+"-"+this.options.label,this.element.append(this._createButton(a,this.options.command)),this.element.append(this._createLabel(a,this.options.command,this.options.label,this.options.icon)),this.options.cssClass&&this.element.find("label").addClass(this.options.cssClass),this.button=this.element.find("input"),this.button.button(),this.options.cssClass&&this.button.addClass(this.options.cssClass),this.button.data("hallo-command",this.options.command)},_init:function(){var a,b,c=this;this.button||(this.button=this._prepareButton()),this.element.append(this.button),this.options.command&&this.button.bind("change",function(a){return c.options.editable.execute(c.options.command)});if(!this.options.queryState)return;return a=this.options.editable.element,b=function(a){if(!c.options.command)return;try{return c.checked(document.queryCommandState(c.options.command))}catch(b){}},a.bind("halloenabled",function(){return a.bind("keyup paste change mouseup hallomodified",b)}),a.bind("hallodisabled",function(){return a.unbind("keyup paste change mouseup hallomodified",b)})},enable:function(){return this.button.button("enable")},disable:function(){return this.button.button("disable")},refresh:function(){return this.button.button("refresh")},checked:function(a){return this.button.attr("checked",a),this.refresh()},_createButton:function(b){return a('<input id="'+b+'" type="checkbox" />')},_createLabel:function(b,c,d,e){return a('<label for="'+b+'" class="'+c+'_button" title="'+d+'"><i class="'+e+'"></i></label>')}})}(jQuery),function(a){return a.widget("IKS.hallodropdownbutton",{button:null,options:{uuid:"",label:null,icon:null,editable:null,target:"",cssClass:null},_create:function(){var a,b;return(b=(a=this.options).icon)!=null?b:a.icon="icon-"+this.options.label.toLowerCase()},_init:function(){var b,c=this;return b=a(this.options.target),b.css("position","absolute"),b.addClass("dropdown-menu"),b.hide(),this.button||(this.button=this._prepareButton()),this.button.bind("click",function(){if(b.hasClass("open")){c._hideTarget();return}return c._showTarget()}),b.bind("click",function(){return c._hideTarget()}),this.options.editable.element.bind("hallodeactivated",function(){return c._hideTarget()}),this.element.append(this.button)},_showTarget:function(){var b;return b=a(this.options.target),this._updateTargetPosition(),b.addClass("open"),b.show()},_hideTarget:function(){var b;return b=a(this.options.target),b.removeClass("open"),b.hide()},_updateTargetPosition:function(){var b,c,d,e;return d=a(this.options.target),e=this.element.position(),b=e.bottom,c=e.left,d.css("top",b),d.css("left",c-20)},_prepareButton:function(){var b,c,d;return d=""+this.options.uuid+"-"+this.options.label,c=a('<button id="'+d+'" data-toggle="dropdown" data-target="#'+this.options.target.attr("id")+'" title="'+this.options.label+'">\n <span class="ui-button-text"><i class="'+this.options.icon+'"></i></span>\n</button>'),this.options.cssClass&&c.addClass(this.options.cssClass),b=c.button(),b}})}(jQuery);
1,026 examples/hallo.js
View
@@ -1,150 +1,3 @@
-(function() {
-
- (function(jQuery) {
- return jQuery.widget('IKS.hallobutton', {
- button: null,
- options: {
- uuid: '',
- label: null,
- icon: null,
- editable: null,
- command: null,
- queryState: true,
- cssClass: null
- },
- _create: function() {
- var id, _base;
- if ((_base = this.options).icon == null) {
- _base.icon = "icon-" + (this.options.label.toLowerCase());
- }
- id = "" + this.options.uuid + "-" + this.options.label;
- this.element.append(this._createButton(id, this.options.command));
- this.element.append(this._createLabel(id, this.options.command, this.options.label, this.options.icon));
- if (this.options.cssClass) {
- this.element.find('label').addClass(this.options.cssClass);
- }
- this.button = this.element.find('input');
- this.button.button();
- if (this.options.cssClass) this.button.addClass(this.options.cssClass);
- return this.button.data('hallo-command', this.options.command);
- },
- _init: function() {
- var editableElement, queryState,
- _this = this;
- if (!this.button) this.button = this._prepareButton();
- this.element.append(this.button);
- if (this.options.command) {
- this.button.bind('change', function(event) {
- return _this.options.editable.execute(_this.options.command);
- });
- }
- if (!this.options.queryState) return;
- editableElement = this.options.editable.element;
- queryState = function(event) {
- if (!_this.options.command) return;
- try {
- return _this.checked(document.queryCommandState(_this.options.command));
- } catch (e) {
-
- }
- };
- editableElement.bind('halloenabled', function() {
- return editableElement.bind('keyup paste change mouseup hallomodified', queryState);
- });
- return editableElement.bind('hallodisabled', function() {
- return editableElement.unbind('keyup paste change mouseup hallomodified', queryState);
- });
- },
- enable: function() {
- return this.button.button('enable');
- },
- disable: function() {
- return this.button.button('disable');
- },
- refresh: function() {
- return this.button.button('refresh');
- },
- checked: function(checked) {
- this.button.attr('checked', checked);
- return this.refresh();
- },
- _createButton: function(id) {
- return jQuery("<input id=\"" + id + "\" type=\"checkbox\" />");
- },
- _createLabel: function(id, command, label, icon) {
- return jQuery("<label for=\"" + id + "\" class=\"" + command + "_button\" title=\"" + label + "\"><i class=\"" + icon + "\"></i></label>");
- }
- });
- })(jQuery);
-
- (function(jQuery) {
- return jQuery.widget('IKS.hallodropdownbutton', {
- button: null,
- options: {
- uuid: '',
- label: null,
- icon: null,
- editable: null,
- target: '',
- cssClass: null
- },
- _create: function() {
- var _base, _ref;
- return (_ref = (_base = this.options).icon) != null ? _ref : _base.icon = "icon-" + (this.options.label.toLowerCase());
- },
- _init: function() {
- var target,
- _this = this;
- target = jQuery(this.options.target);
- target.css('position', 'absolute');
- target.addClass('dropdown-menu');
- target.hide();
- if (!this.button) this.button = this._prepareButton();
- this.button.bind('click', function() {
- if (target.hasClass('open')) {
- _this._hideTarget();
- return;
- }
- return _this._showTarget();
- });
- target.bind('click', function() {
- return _this._hideTarget();
- });
- this.options.editable.element.bind('hallodeactivated', function() {
- return _this._hideTarget();
- });
- return this.element.append(this.button);
- },
- _showTarget: function() {
- var target;
- target = jQuery(this.options.target);
- this._updateTargetPosition();
- target.addClass('open');
- return target.show();
- },
- _hideTarget: function() {
- var target;
- target = jQuery(this.options.target);
- target.removeClass('open');
- return target.hide();
- },
- _updateTargetPosition: function() {
- var bottom, left, target, _ref;
- target = jQuery(this.options.target);
- _ref = this.element.position(), bottom = _ref.bottom, left = _ref.left;
- target.css('top', bottom);
- return target.css('left', left - 20);
- },
- _prepareButton: function() {
- var button, buttonEl, id;
- id = "" + this.options.uuid + "-" + this.options.label;
- buttonEl = jQuery("<button id=\"" + id + "\" data-toggle=\"dropdown\" data-target=\"#" + (this.options.target.attr('id')) + "\" title=\"" + this.options.label + "\">\n <span class=\"ui-button-text\"><i class=\"" + this.options.icon + "\"></i></span>\n</button>");
- if (this.options.cssClass) buttonEl.addClass(this.options.cssClass);
- button = buttonEl.button();
- return button;
- }
- });
- })(jQuery);
/*
Hallo - a rich text editing jQuery UI widget
@@ -304,6 +157,12 @@
setUnmodified: function() {
return this.originalContent = this.getContents();
},
+ setModified: function() {
+ return this._trigger('modified', null, {
+ editable: this,
+ content: this.getContents()
+ });
+ },
restoreOriginalContent: function() {
return this.element.html(this.originalContent);
},
@@ -408,8 +267,8 @@
return this.toolbar.css('left', this.element.offset().left);
},
_prepareToolbar: function() {
- var widget,
- _this = this;
+ var widget;
+ var _this = this;
this.toolbar = jQuery('<div class="hallotoolbar"></div>').hide();
this._setToolbarPosition();
jQuery(this.options.parentElement).append(this.toolbar);
@@ -431,12 +290,7 @@
_checkModified: function(event) {
var widget;
widget = event.data;
- if (widget.isModified()) {
- return widget._trigger("modified", null, {
- editable: widget,
- content: widget.getContents()
- });
- }
+ if (widget.isModified()) return widget.setModified();
},
_keys: function(event) {
var old, widget;
@@ -549,115 +403,195 @@
})(jQuery);
(function(jQuery) {
- var z;
- z = null;
- if (this.VIE !== void 0) {
- z = new VIE;
- z.use(new z.StanbolService({
- proxyDisabled: true,
- url: 'http://dev.iks-project.eu:8081'
- }));
- }
- return jQuery.widget('IKS.halloannotate', {
+ return jQuery.widget("IKS.hallolists", {
options: {
- vie: z,
editable: null,
toolbar: null,
uuid: '',
- select: function() {},
- decline: function() {},
- remove: function() {},
+ lists: {
+ ordered: false,
+ unordered: true
+ },
buttonCssClass: null
},
_create: function() {
- var buttonHolder, editableElement, turnOffAnnotate, widget,
- _this = this;
- widget = this;
- if (this.options.vie === void 0) {
- throw 'The halloannotate plugin requires VIE to be loaded';
- return;
- }
- if (typeof this.element.annotate !== 'function') {
- throw 'The halloannotate plugin requires annotate.js to be loaded';
- return;
- }
- this.state = 'off';
- buttonHolder = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
- this.button = buttonHolder.hallobutton({
- label: 'Annotate',
- icon: 'icon-tags',
- editable: this.options.editable,
- command: null,
- uuid: this.options.uuid,
- cssClass: this.options.buttonCssClass,
- queryState: false
- });
- buttonHolder.bind('change', function(event) {
- if (_this.state === "pending") return;
- if (_this.state === "off") return _this.turnOn();
- return _this.turnOff();
- });
- buttonHolder.buttonset();
- this.options.toolbar.append(this.button);
- this.instantiate();
- turnOffAnnotate = function() {
- var editable;
- editable = this;
- return jQuery(editable).halloannotate('turnOff');
- };
- editableElement = this.options.editable.element;
- return editableElement.bind('hallodisabled', turnOffAnnotate);
- },
- cleanupContentClone: function(el) {
- if (this.state === 'on') {
- return el.find(".entity:not([about])").each(function() {
- return jQuery(this).replaceWith(jQuery(this).html());
+ var buttonize, buttonset;
+ var _this = this;
+ buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
+ buttonize = function(type, label) {
+ var buttonElement;
+ buttonElement = jQuery('<span></span>');
+ buttonElement.hallobutton({
+ uuid: _this.options.uuid,
+ editable: _this.options.editable,
+ label: label,
+ command: "insert" + type + "List",
+ icon: 'icon-list',
+ cssClass: _this.options.buttonCssClass
});
- }
- },
- instantiate: function() {
- return this.options.editable.element.annotate({
- vie: this.options.vie,
- debug: false,
- showTooltip: true,
- select: this.options.select,
- remove: this.options.remove,
- success: this.options.success,
- error: this.options.error
- }).bind('annotateselect', function() {
- return jQuery.noop();
- }).bind('annotateremove', function() {
- return jQuery.noop();
- });
+ return buttonset.append(buttonElement);
+ };
+ if (this.options.lists.ordered) buttonize("Ordered", "OL");
+ if (this.options.lists.unordered) buttonize("Unordered", "UL");
+ buttonset.buttonset();
+ return this.options.toolbar.append(buttonset);
},
- turnPending: function() {
- this.state = 'pending';
- this.button.hallobutton('checked', false);
- return this.button.hallobutton('disable');
+ _init: function() {}
+ });
+ })(jQuery);
+
+ (function(jQuery) {
+ return jQuery.widget("IKS.halloheadings", {
+ options: {
+ editable: null,
+ toolbar: null,
+ uuid: "",
+ headers: [1, 2, 3]
},
- turnOn: function() {
- var widget,
- _this = this;
- this.turnPending();
+ _create: function() {
+ var button, buttonize, buttonset, header, id, label, widget, _i, _len, _ref;
+ var _this = this;
widget = this;
- try {
- return this.options.editable.element.annotate('enable', function(success) {
- if (success) {
- _this.state = 'on';
- _this.button.hallobutton('checked', true);
- return _this.button.hallobutton('enable');
- }
+ buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
+ id = "" + this.options.uuid + "-paragraph";
+ label = "P";
+ buttonset.append(jQuery("<input id=\"" + id + "\" type=\"radio\" name=\"" + widget.options.uuid + "-headings\"/><label for=\"" + id + "\" class=\"p_button\">" + label + "</label>").button());
+ button = jQuery("#" + id, buttonset);
+ button.attr("hallo-command", "formatBlock");
+ button.bind("change", function(event) {
+ var cmd;
+ cmd = jQuery(this).attr("hallo-command");
+ return widget.options.editable.execute(cmd, "P");
+ });
+ buttonize = function(headerSize) {
+ label = "H" + headerSize;
+ id = "" + _this.options.uuid + "-" + headerSize;
+ buttonset.append(jQuery("<input id=\"" + id + "\" type=\"radio\" name=\"" + widget.options.uuid + "-headings\"/><label for=\"" + id + "\" class=\"h" + headerSize + "_button\">" + label + "</label>").button());
+ button = jQuery("#" + id, buttonset);
+ button.attr("hallo-size", "H" + headerSize);
+ return button.bind("change", function(event) {
+ var size;
+ size = jQuery(this).attr("hallo-size");
+ return widget.options.editable.execute("formatBlock", size);
});
- } catch (e) {
- return alert(e);
+ };
+ _ref = this.options.headers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ header = _ref[_i];
+ buttonize(header);
}
+ buttonset.buttonset();
+ this.element.bind("keyup paste change mouseup", function(event) {
+ var format, formatNumber, labelParent, matches, selectedButton;
+ try {
+ format = document.queryCommandValue("formatBlock").toUpperCase();
+ } catch (e) {
+ format = '';
+ }
+ if (format === "P") {
+ selectedButton = jQuery("#" + widget.options.uuid + "-paragraph");
+ } else if (matches = format.match(/\d/)) {
+ formatNumber = matches[0];
+ selectedButton = jQuery("#" + widget.options.uuid + "-" + formatNumber);
+ }
+ labelParent = jQuery(buttonset);
+ labelParent.children("input").attr("checked", false);
+ labelParent.children("label").removeClass("ui-state-clicked");
+ labelParent.children("input").button("widget").button("refresh");
+ if (selectedButton) {
+ selectedButton.attr("checked", true);
+ selectedButton.next("label").addClass("ui-state-clicked");
+ return selectedButton.button("refresh");
+ }
+ });
+ return this.options.toolbar.append(buttonset);
},
- turnOff: function() {
- this.options.editable.element.annotate('disable');
- this.button.attr('checked', false);
- this.button.find("label").removeClass("ui-state-clicked");
- this.button.button('refresh');
- return this.state = 'off';
+ _init: function() {}
+ });
+ })(jQuery);
+
+ (function(jQuery) {
+ return jQuery.widget("Liip.hallooverlay", {
+ options: {
+ editable: null,
+ toolbar: null,
+ uuid: "",
+ overlay: null,
+ padding: 10,
+ background: null
+ },
+ _create: function() {
+ var widget;
+ widget = this;
+ if (!this.options.bound) {
+ this.options.bound = true;
+ widget.options.editable.element.bind("halloactivated", function(event, data) {
+ widget.options.currentEditable = jQuery(event.target);
+ if (!widget.options.visible) return widget.showOverlay();
+ });
+ widget.options.editable.element.bind("hallomodified", function(event, data) {
+ widget.options.currentEditable = jQuery(event.target);
+ if (widget.options.visible) return widget.resizeOverlay();
+ });
+ return widget.options.editable.element.bind("hallodeactivated", function(event, data) {
+ widget.options.currentEditable = jQuery(event.target);
+ if (widget.options.visible) return widget.hideOverlay();
+ });
+ }
+ },
+ _init: function() {},
+ showOverlay: function() {
+ this.options.visible = true;
+ if (this.options.overlay === null) {
+ if (jQuery("#halloOverlay").length > 0) {
+ this.options.overlay = jQuery("#halloOverlay");
+ } else {
+ this.options.overlay = jQuery('<div id="halloOverlay" class="halloOverlay">');
+ jQuery(document.body).append(this.options.overlay);
+ }
+ this.options.overlay.bind('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable));
+ }
+ this.options.overlay.show();
+ if (this.options.background === null) {
+ if (jQuery("#halloBackground").length > 0) {
+ this.options.background = jQuery("#halloBackground");
+ } else {
+ this.options.background = jQuery('<div id="halloBackground" class="halloBackground">');
+ jQuery(document.body).append(this.options.background);
+ }
+ }
+ this.resizeOverlay();
+ this.options.background.show();
+ if (!this.options.originalZIndex) {
+ this.options.originalZIndex = this.options.currentEditable.css("z-index");
+ }
+ return this.options.currentEditable.css('z-index', '350');
+ },
+ resizeOverlay: function() {
+ var offset;
+ offset = this.options.currentEditable.offset();
+ this.options.background.css({
+ top: offset.top - this.options.padding,
+ left: offset.left - this.options.padding
+ });
+ this.options.background.width(this.options.currentEditable.width() + 2 * this.options.padding);
+ return this.options.background.height(this.options.currentEditable.height() + 2 * this.options.padding);
+ },
+ hideOverlay: function() {
+ this.options.visible = false;
+ this.options.overlay.hide();
+ this.options.background.hide();
+ return this.options.currentEditable.css('z-index', this.options.originalZIndex);
+ },
+ _findBackgroundColor: function(jQueryfield) {
+ var color;
+ color = jQueryfield.css("background-color");
+ if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') return color;
+ if (jQueryfield.is("body")) {
+ return "white";
+ } else {
+ return this._findBackgroundColor(jQueryfield.parent());
+ }
}
});
})(jQuery);
@@ -700,73 +634,115 @@
})(jQuery);
(function(jQuery) {
- return jQuery.widget('IKS.halloblock', {
+ var z;
+ z = null;
+ if (this.VIE !== void 0) {
+ z = new VIE;
+ z.use(new z.StanbolService({
+ proxyDisabled: true,
+ url: 'http://dev.iks-project.eu:8081'
+ }));
+ }
+ return jQuery.widget('IKS.halloannotate', {
options: {
+ vie: z,
editable: null,
toolbar: null,
uuid: '',
- elements: ['h1', 'h2', 'h3', 'p', 'pre', 'blockquote'],
+ select: function() {},
+ decline: function() {},
+ remove: function() {},
buttonCssClass: null
},
_create: function() {
- var buttonset, contentId, target;
- buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
- contentId = "" + this.options.uuid + "-" + this.widgetName + "-data";
- target = this._prepareDropdown(contentId);
- buttonset.append(target);
- buttonset.append(this._prepareButton(target));
- return this.options.toolbar.append(buttonset);
+ var buttonHolder, editableElement, turnOffAnnotate, widget;
+ var _this = this;
+ widget = this;
+ if (this.options.vie === void 0) {
+ throw 'The halloannotate plugin requires VIE to be loaded';
+ return;
+ }
+ if (typeof this.element.annotate !== 'function') {
+ throw 'The halloannotate plugin requires annotate.js to be loaded';
+ return;
+ }
+ this.state = 'off';
+ buttonHolder = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
+ this.button = buttonHolder.hallobutton({
+ label: 'Annotate',
+ icon: 'icon-tags',
+ editable: this.options.editable,
+ command: null,
+ uuid: this.options.uuid,
+ cssClass: this.options.buttonCssClass,
+ queryState: false
+ });
+ buttonHolder.bind('change', function(event) {
+ if (_this.state === "pending") return;
+ if (_this.state === "off") return _this.turnOn();
+ return _this.turnOff();
+ });
+ buttonHolder.buttonset();
+ this.options.toolbar.append(this.button);
+ this.instantiate();
+ turnOffAnnotate = function() {
+ var editable;
+ editable = this;
+ return jQuery(editable).halloannotate('turnOff');
+ };
+ editableElement = this.options.editable.element;
+ return editableElement.bind('hallodisabled', turnOffAnnotate);
},
- _prepareDropdown: function(contentId) {
- var addElement, containingElement, contentArea, element, _i, _len, _ref,
- _this = this;
- contentArea = jQuery("<div id=\"" + contentId + "\"></div>");
- containingElement = this.options.editable.element.get(0).tagName.toLowerCase();
- addElement = function(element) {
- var el, queryState;
- el = jQuery("<" + element + " class=\"menu-item\">" + element + "</" + element + ">");
- if (containingElement === element) el.addClass('selected');
- if (containingElement !== 'div') el.addClass('disabled');
- el.bind('click', function() {
- if (el.hasClass('disabled')) return;
- return _this.options.editable.execute('formatBlock', element.toUpperCase());
+ cleanupContentClone: function(el) {
+ if (this.state === 'on') {
+ return el.find(".entity:not([about])").each(function() {
+ return jQuery(this).replaceWith(jQuery(this).html());
});
- queryState = function(event) {
- var block;
- block = document.queryCommandValue('formatBlock');
- if (block.toLowerCase() === element) {
- el.addClass('selected');
- return;
+ }
+ },
+ instantiate: function() {
+ return this.options.editable.element.annotate({
+ vie: this.options.vie,
+ debug: false,
+ showTooltip: true,
+ select: this.options.select,
+ remove: this.options.remove,
+ success: this.options.success,
+ error: this.options.error
+ }).bind('annotateselect', function() {
+ return jQuery.noop();
+ }).bind('annotateremove', function() {
+ return jQuery.noop();
+ });
+ },
+ turnPending: function() {
+ this.state = 'pending';
+ this.button.hallobutton('checked', false);
+ return this.button.hallobutton('disable');
+ },
+ turnOn: function() {
+ var widget;
+ var _this = this;
+ this.turnPending();
+ widget = this;
+ try {
+ return this.options.editable.element.annotate('enable', function(success) {
+ if (success) {
+ _this.state = 'on';
+ _this.button.hallobutton('checked', true);
+ return _this.button.hallobutton('enable');
}
- return el.removeClass('selected');
- };
- _this.options.editable.element.bind('halloenabled', function() {
- return _this.options.editable.element.bind('keyup paste change mouseup', queryState);
});
- _this.options.editable.element.bind('hallodisabled', function() {
- return _this.options.editable.element.unbind('keyup paste change mouseup', queryState);
- });
- return el;
- };
- _ref = this.options.elements;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- element = _ref[_i];
- contentArea.append(addElement(element));
+ } catch (e) {
+ return alert(e);
}
- return contentArea;
},
- _prepareButton: function(target) {
- var buttonElement;
- buttonElement = jQuery('<span></span>');
- buttonElement.hallodropdownbutton({
- uuid: this.options.uuid,
- editable: this.options.editable,
- label: 'block',
- icon: 'icon-text-height',
- target: target,
- cssClass: this.options.buttonCssClass
- });
- return buttonElement;
+ turnOff: function() {
+ this.options.editable.element.annotate('disable');
+ this.button.attr('checked', false);
+ this.button.find("label").removeClass("ui-state-clicked");
+ this.button.button('refresh');
+ return this.state = 'off';
}
});
})(jQuery);
@@ -1351,6 +1327,49 @@
})(jQuery);
(function(jQuery) {
+ return jQuery.widget("IKS.halloformat", {
+ options: {
+ editable: null,
+ toolbar: null,
+ uuid: "",
+ formattings: {
+ bold: true,
+ italic: true,
+ strikeThrough: false,
+ underline: false
+ },
+ buttonCssClass: null
+ },
+ _create: function() {
+ var buttonize, buttonset, enabled, format, widget, _ref;
+ var _this = this;
+ widget = this;
+ buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
+ buttonize = function(format) {
+ var buttonHolder;
+ buttonHolder = jQuery('<span></span>');
+ buttonHolder.hallobutton({
+ label: format,
+ editable: _this.options.editable,
+ command: format,
+ uuid: _this.options.uuid,
+ cssClass: _this.options.buttonCssClass
+ });
+ return buttonset.append(buttonHolder);
+ };
+ _ref = this.options.formattings;
+ for (format in _ref) {
+ enabled = _ref[format];
+ if (enabled) buttonize(format);
+ }
+ buttonset.buttonset();
+ return this.options.toolbar.append(buttonset);
+ },
+ _init: function() {}
+ });
+ })(jQuery);
+
+ (function(jQuery) {
return jQuery.widget("IKS.halloreundo", {
options: {
editable: null,
@@ -1359,8 +1378,8 @@
buttonCssClass: null
},
_create: function() {
- var buttonize, buttonset,
- _this = this;
+ var buttonize, buttonset;
+ var _this = this;
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
buttonize = function(cmd, label) {
var buttonElement;
@@ -1386,158 +1405,74 @@
})(jQuery);
(function(jQuery) {
- return jQuery.widget("Liip.hallooverlay", {
+ return jQuery.widget('IKS.halloblock', {
options: {
editable: null,
toolbar: null,
- uuid: "",
- overlay: null,
- padding: 10,
- background: null
+ uuid: '',
+ elements: ['h1', 'h2', 'h3', 'p', 'pre', 'blockquote'],
+ buttonCssClass: null
},
_create: function() {
- var widget;
- widget = this;
- if (!this.options.bound) {
- this.options.bound = true;
- widget.options.editable.element.bind("halloactivated", function(event, data) {
- widget.options.currentEditable = jQuery(event.target);
- if (!widget.options.visible) return widget.showOverlay();
- });
- widget.options.editable.element.bind("hallomodified", function(event, data) {
- widget.options.currentEditable = jQuery(event.target);
- if (widget.options.visible) return widget.resizeOverlay();
- });
- return widget.options.editable.element.bind("hallodeactivated", function(event, data) {
- widget.options.currentEditable = jQuery(event.target);
- if (widget.options.visible) return widget.hideOverlay();
- });
- }
- },
- _init: function() {},
- showOverlay: function() {
- this.options.visible = true;
- if (this.options.overlay === null) {
- if (jQuery("#halloOverlay").length > 0) {
- this.options.overlay = jQuery("#halloOverlay");
- } else {
- this.options.overlay = jQuery('<div id="halloOverlay" class="halloOverlay">');
- jQuery(document.body).append(this.options.overlay);
- }
- this.options.overlay.bind('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable));
- }
- this.options.overlay.show();
- if (this.options.background === null) {
- if (jQuery("#halloBackground").length > 0) {
- this.options.background = jQuery("#halloBackground");
- } else {
- this.options.background = jQuery('<div id="halloBackground" class="halloBackground">');
- jQuery(document.body).append(this.options.background);
- }
- }
- this.resizeOverlay();
- this.options.background.show();
- if (!this.options.originalZIndex) {
- this.options.originalZIndex = this.options.currentEditable.css("z-index");
- }
- return this.options.currentEditable.css('z-index', '350');
- },
- resizeOverlay: function() {
- var offset;
- offset = this.options.currentEditable.offset();
- this.options.background.css({
- top: offset.top - this.options.padding,
- left: offset.left - this.options.padding
- });
- this.options.background.width(this.options.currentEditable.width() + 2 * this.options.padding);
- return this.options.background.height(this.options.currentEditable.height() + 2 * this.options.padding);
- },
- hideOverlay: function() {
- this.options.visible = false;
- this.options.overlay.hide();
- this.options.background.hide();
- return this.options.currentEditable.css('z-index', this.options.originalZIndex);
- },
- _findBackgroundColor: function(jQueryfield) {
- var color;
- color = jQueryfield.css("background-color");
- if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') return color;
- if (jQueryfield.is("body")) {
- return "white";
- } else {
- return this._findBackgroundColor(jQueryfield.parent());
- }
- }
- });
- })(jQuery);
-
- (function(jQuery) {
- return jQuery.widget("IKS.halloheadings", {
- options: {
- editable: null,
- toolbar: null,
- uuid: "",
- headers: [1, 2, 3]
+ var buttonset, contentId, target;
+ buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
+ contentId = "" + this.options.uuid + "-" + this.widgetName + "-data";
+ target = this._prepareDropdown(contentId);
+ buttonset.append(target);
+ buttonset.append(this._prepareButton(target));
+ return this.options.toolbar.append(buttonset);
},
- _create: function() {
- var button, buttonize, buttonset, header, id, label, widget, _i, _len, _ref,
- _this = this;
- widget = this;
- buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
- id = "" + this.options.uuid + "-paragraph";
- label = "P";
- buttonset.append(jQuery("<input id=\"" + id + "\" type=\"radio\" name=\"" + widget.options.uuid + "-headings\"/><label for=\"" + id + "\" class=\"p_button\">" + label + "</label>").button());
- button = jQuery("#" + id, buttonset);
- button.attr("hallo-command", "formatBlock");
- button.bind("change", function(event) {
- var cmd;
- cmd = jQuery(this).attr("hallo-command");
- return widget.options.editable.execute(cmd, "P");
- });
- buttonize = function(headerSize) {
- label = "H" + headerSize;
- id = "" + _this.options.uuid + "-" + headerSize;
- buttonset.append(jQuery("<input id=\"" + id + "\" type=\"radio\" name=\"" + widget.options.uuid + "-headings\"/><label for=\"" + id + "\" class=\"h" + headerSize + "_button\">" + label + "</label>").button());
- button = jQuery("#" + id, buttonset);
- button.attr("hallo-size", "H" + headerSize);
- return button.bind("change", function(event) {
- var size;
- size = jQuery(this).attr("hallo-size");
- return widget.options.editable.execute("formatBlock", size);
+ _prepareDropdown: function(contentId) {
+ var addElement, containingElement, contentArea, element, _i, _len, _ref;
+ var _this = this;
+ contentArea = jQuery("<div id=\"" + contentId + "\"></div>");
+ containingElement = this.options.editable.element.get(0).tagName.toLowerCase();
+ addElement = function(element) {
+ var el, queryState;
+ el = jQuery("<" + element + " class=\"menu-item\">" + element + "</" + element + ">");
+ if (containingElement === element) el.addClass('selected');
+ if (containingElement !== 'div') el.addClass('disabled');
+ el.bind('click', function() {
+ if (el.hasClass('disabled')) return;
+ return _this.options.editable.execute('formatBlock', element.toUpperCase());
+ });
+ queryState = function(event) {
+ var block;
+ block = document.queryCommandValue('formatBlock');
+ if (block.toLowerCase() === element) {
+ el.addClass('selected');
+ return;
+ }
+ return el.removeClass('selected');
+ };
+ _this.options.editable.element.bind('halloenabled', function() {
+ return _this.options.editable.element.bind('keyup paste change mouseup', queryState);
+ });
+ _this.options.editable.element.bind('hallodisabled', function() {
+ return _this.options.editable.element.unbind('keyup paste change mouseup', queryState);
});
+ return el;
};
- _ref = this.options.headers;
+ _ref = this.options.elements;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- header = _ref[_i];
- buttonize(header);
+ element = _ref[_i];
+ contentArea.append(addElement(element));
}
- buttonset.buttonset();
- this.element.bind("keyup paste change mouseup", function(event) {
- var format, formatNumber, labelParent, matches, selectedButton;
- try {
- format = document.queryCommandValue("formatBlock").toUpperCase();
- } catch (e) {
- format = '';
- }
- if (format === "P") {
- selectedButton = jQuery("#" + widget.options.uuid + "-paragraph");
- } else if (matches = format.match(/\d/)) {
- formatNumber = matches[0];
- selectedButton = jQuery("#" + widget.options.uuid + "-" + formatNumber);
- }
- labelParent = jQuery(buttonset);
- labelParent.children("input").attr("checked", false);
- labelParent.children("label").removeClass("ui-state-clicked");
- labelParent.children("input").button("widget").button("refresh");
- if (selectedButton) {
- selectedButton.attr("checked", true);
- selectedButton.next("label").addClass("ui-state-clicked");
- return selectedButton.button("refresh");
- }
- });
- return this.options.toolbar.append(buttonset);
+ return contentArea;
},
- _init: function() {}
+ _prepareButton: function(target) {
+ var buttonElement;
+ buttonElement = jQuery('<span></span>');
+ buttonElement.hallodropdownbutton({
+ uuid: this.options.uuid,
+ editable: this.options.editable,
+ label: 'block',
+ icon: 'icon-text-height',
+ target: target,
+ cssClass: this.options.buttonCssClass
+ });
+ return buttonElement;
+ }
});
})(jQuery);
@@ -1562,8 +1497,8 @@
}
},
_create: function() {
- var buttonize, buttonset, dialog, dialogId, dialogSubmitCb, urlInput, widget,
- _this = this;
+ var buttonize, buttonset, dialog, dialogId, dialogSubmitCb, urlInput, widget;
+ var _this = this;
widget = this;
dialogId = "" + this.options.uuid + "-dialog";
dialog = jQuery("<div id=\"" + dialogId + "\"><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>");
@@ -1646,8 +1581,8 @@
buttonCssClass: null
},
_create: function() {
- var buttonize, buttonset,
- _this = this;
+ var buttonize, buttonset;
+ var _this = this;
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
buttonize = function(alignment) {
var buttonElement;
@@ -1673,84 +1608,147 @@
})(jQuery);
(function(jQuery) {
- return jQuery.widget("IKS.halloformat", {
+ return jQuery.widget('IKS.hallobutton', {
+ button: null,
options: {
+ uuid: '',
+ label: null,
+ icon: null,
editable: null,
- toolbar: null,
- uuid: "",
- formattings: {
- bold: true,
- italic: true,
- strikeThrough: false,
- underline: false
- },
- buttonCssClass: null
+ command: null,
+ queryState: true,
+ cssClass: null
},
_create: function() {
- var buttonize, buttonset, enabled, format, widget, _ref,
- _this = this;
- widget = this;
- buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
- buttonize = function(format) {
- var buttonHolder;
- buttonHolder = jQuery('<span></span>');
- buttonHolder.hallobutton({
- label: format,
- editable: _this.options.editable,
- command: format,
- uuid: _this.options.uuid,
- cssClass: _this.options.buttonCssClass
+ var id, _base, _ref;
+ if ((_ref = (_base = this.options).icon) == null) {
+ _base.icon = "icon-" + (this.options.label.toLowerCase());
+ }
+ id = "" + this.options.uuid + "-" + this.options.label;
+ this.element.append(this._createButton(id, this.options.command));
+ this.element.append(this._createLabel(id, this.options.command, this.options.label, this.options.icon));
+ if (this.options.cssClass) {
+ this.element.find('label').addClass(this.options.cssClass);
+ }
+ this.button = this.element.find('input');
+ this.button.button();
+ if (this.options.cssClass) this.button.addClass(this.options.cssClass);
+ return this.button.data('hallo-command', this.options.command);
+ },
+ _init: function() {
+ var editableElement, queryState;
+ var _this = this;
+ if (!this.button) this.button = this._prepareButton();
+ this.element.append(this.button);
+ if (this.options.command) {
+ this.button.bind('change', function(event) {
+ return _this.options.editable.execute(_this.options.command);
});
- return buttonset.append(buttonHolder);
- };
- _ref = this.options.formattings;
- for (format in _ref) {
- enabled = _ref[format];
- if (enabled) buttonize(format);
}
- buttonset.buttonset();
- return this.options.toolbar.append(buttonset);
+ if (!this.options.queryState) return;
+ editableElement = this.options.editable.element;
+ queryState = function(event) {
+ if (!_this.options.command) return;
+ try {
+ return _this.checked(document.queryCommandState(_this.options.command));
+ } catch (e) {
+
+ }
+ };
+ editableElement.bind('halloenabled', function() {
+ return editableElement.bind('keyup paste change mouseup hallomodified', queryState);
+ });
+ return editableElement.bind('hallodisabled', function() {
+ return editableElement.unbind('keyup paste change mouseup hallomodified', queryState);
+ });
},
- _init: function() {}
+ enable: function() {
+ return this.button.button('enable');
+ },
+ disable: function() {
+ return this.button.button('disable');
+ },
+ refresh: function() {
+ return this.button.button('refresh');
+ },
+ checked: function(checked) {
+ this.button.attr('checked', checked);
+ return this.refresh();
+ },
+ _createButton: function(id) {
+ return jQuery("<input id=\"" + id + "\" type=\"checkbox\" />");
+ },
+ _createLabel: function(id, command, label, icon) {
+ return jQuery("<label for=\"" + id + "\" class=\"" + command + "_button\" title=\"" + label + "\"><i class=\"" + icon + "\"></i></label>");
+ }
});
})(jQuery);
(function(jQuery) {
- return jQuery.widget("IKS.hallolists", {
+ return jQuery.widget('IKS.hallodropdownbutton', {
+ button: null,
options: {
- editable: null,
- toolbar: null,
uuid: '',
- lists: {
- ordered: false,
- unordered: true
- },
- buttonCssClass: null
+ label: null,
+ icon: null,
+ editable: null,
+ target: '',
+ cssClass: null
},
_create: function() {
- var buttonize, buttonset,
- _this = this;
- buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
- buttonize = function(type, label) {
- var buttonElement;
- buttonElement = jQuery('<span></span>');
- buttonElement.hallobutton({
- uuid: _this.options.uuid,
- editable: _this.options.editable,
- label: label,
- command: "insert" + type + "List",
- icon: 'icon-list',
- cssClass: _this.options.buttonCssClass
- });
- return buttonset.append(buttonElement);
- };
- if (this.options.lists.ordered) buttonize("Ordered", "OL");
- if (this.options.lists.unordered) buttonize("Unordered", "UL");
- buttonset.buttonset();
- return this.options.toolbar.append(buttonset);
+ var _base, _ref;
+ return (_ref = (_base = this.options).icon) != null ? _ref : _base.icon = "icon-" + (this.options.label.toLowerCase());
},
- _init: function() {}
+ _init: function() {
+ var target;
+ var _this = this;
+ target = jQuery(this.options.target);
+ target.css('position', 'absolute');
+ target.addClass('dropdown-menu');
+ target.hide();
+ if (!this.button) this.button = this._prepareButton();
+ this.button.bind('click', function() {
+ if (target.hasClass('open')) {
+ _this._hideTarget();
+ return;
+ }
+ return _this._showTarget();
+ });
+ target.bind('click', function() {
+ return _this._hideTarget();
+ });
+ this.options.editable.element.bind('hallodeactivated', function() {
+ return _this._hideTarget();
+ });
+ return this.element.append(this.button);
+ },
+ _showTarget: function() {
+ var target;
+ target = jQuery(this.options.target);
+ this._updateTargetPosition();
+ target.addClass('open');
+ return target.show();
+ },
+ _hideTarget: function() {
+ var target;
+ target = jQuery(this.options.target);
+ target.removeClass('open');
+ return target.hide();
+ },
+ _updateTargetPosition: function() {
+ var bottom, left, target, _ref;
+ target = jQuery(this.options.target);
+ _ref = this.element.position(), bottom = _ref.bottom, left = _ref.left;
+ target.css('top', bottom);
+ return target.css('left', left - 20);
+ },
+ _prepareButton: function() {
+ var button, buttonEl, id;
+ id = "" + this.options.uuid + "-" + this.options.label;
+ buttonEl = jQuery("<button id=\"" + id + "\" data-toggle=\"dropdown\" data-target=\"#" + (this.options.target.attr('id')) + "\" title=\"" + this.options.label + "\">\n <span class=\"ui-button-text\"><i class=\"" + this.options.icon + "\"></i></span>\n</button>");
+ if (this.options.cssClass) buttonEl.addClass(this.options.cssClass);
+ button = buttonEl.button();
+ return button;
+ }
});
})(jQuery);
-
-}).call(this);
15 src/hallo.coffee
View
@@ -239,11 +239,17 @@ Hallo may be freely distributed under the MIT license
# Check whether the editable has been modified
isModified: ->
- @originalContent isnt @getContents()
+ @originalContent isnt @getContents()
# Set the editable as unmodified
setUnmodified: ->
- @originalContent = @getContents()
+ @originalContent = @getContents()
+
+ # Set the editable as modified
+ setModified: ->
+ @._trigger 'modified', null,
+ editable: @
+ content: @getContents()
# Restore the content original
restoreOriginalContent: () ->
@@ -358,10 +364,7 @@ Hallo may be freely distributed under the MIT license
_checkModified: (event) ->
widget = event.data
- if widget.isModified()
- widget._trigger "modified", null,
- editable: widget
- content: widget.getContents()
+ widget.setModified() if widget.isModified()
_keys: (event) ->
widget = event.data
Please sign in to comment.
Something went wrong with that request. Please try again.