
META-INF.resources.bower_components.textAngular.src.textAngularSetup.min.js Maven / Gradle / Ivy
function validElementString(a){try{return angular.element(a).length!==0}catch(b){return false}}var taTools={};function registerTextAngularTool(b,a){if(!b||b===""||taTools.hasOwnProperty(b)){throw ("textAngular Error: A unique name is required for a Tool Definition")}if((a.display&&(a.display===""||!validElementString(a.display)))||(!a.display&&!a.buttontext&&!a.iconclass)){throw ('textAngular Error: Tool Definition for "'+b+'" does not have a valid display/iconclass/buttontext value')}taTools[b]=a}angular.module("textAngularSetup",[]).constant("taRegisterTool",registerTextAngularTool).value("taTools",taTools).value("taOptions",{forceTextAngularSanitize:true,keyMappings:[],toolbar:[["h1","h2","h3","h4","h5","h6","p","pre","quote"],["bold","italics","underline","strikeThrough","ul","ol","redo","undo","clear"],["justifyLeft","justifyCenter","justifyRight","justifyFull","indent","outdent"],["html","insertImage","insertLink","insertVideo","wordcount","charcount"]],classes:{focussed:"focussed",toolbar:"btn-toolbar",toolbarGroup:"btn-group",toolbarButton:"btn btn-default",toolbarButtonActive:"active",disabled:"disabled",textEditor:"form-control",htmlEditor:"form-control"},defaultTagAttributes:{a:{target:""}},setup:{textEditorSetup:function(a){},htmlEditorSetup:function(a){}},defaultFileDropHandler:function(c,b){var a=new FileReader();if(c.type.substring(0,5)==="image"){a.onload=function(){if(a.result!==""){b("insertImage",a.result,true)}};a.readAsDataURL(c);return true}return false}}).value("taSelectableElements",["a","img"]).value("taCustomRenderers",[{selector:"img",customAttribute:"ta-insert-video",renderLogic:function(b){var c=angular.element("");var a=b.prop("attributes");angular.forEach(a,function(d){c.attr(d.name,d.value)});c.attr("src",c.attr("ta-insert-video"));b.replaceWith(c)}}]).value("taTranslations",{html:{tooltip:"Toggle html / Rich Text"},heading:{tooltip:"Heading "},p:{tooltip:"Paragraph"},pre:{tooltip:"Preformatted text"},ul:{tooltip:"Unordered List"},ol:{tooltip:"Ordered List"},quote:{tooltip:"Quote/unquote selection or paragraph"},undo:{tooltip:"Undo"},redo:{tooltip:"Redo"},bold:{tooltip:"Bold"},italic:{tooltip:"Italic"},underline:{tooltip:"Underline"},strikeThrough:{tooltip:"Strikethrough"},justifyLeft:{tooltip:"Align text left"},justifyRight:{tooltip:"Align text right"},justifyFull:{tooltip:"Justify text"},justifyCenter:{tooltip:"Center"},indent:{tooltip:"Increase indent"},outdent:{tooltip:"Decrease indent"},clear:{tooltip:"Clear formatting"},insertImage:{dialogPrompt:"Please enter an image URL to insert",tooltip:"Insert image",hotkey:"the - possibly language dependent hotkey ... for some future implementation"},insertVideo:{tooltip:"Insert video",dialogPrompt:"Please enter a youtube URL to embed"},insertLink:{tooltip:"Insert / edit link",dialogPrompt:"Please enter a URL to insert"},editLink:{reLinkButton:{tooltip:"Relink"},unLinkButton:{tooltip:"Unlink"},targetToggle:{buttontext:"Open in New Window"}},wordcount:{tooltip:"Display words Count"},charcount:{tooltip:"Display characters Count"}}).factory("taToolFunctions",["$window","taTranslations",function(b,a){return{imgOnSelectAction:function(c,o,e){var p=function(){e.updateTaBindtaTextElement();e.hidePopover()};c.preventDefault();e.displayElements.popover.css("width","375px");var d=e.displayElements.popoverContainer;d.empty();var j=angular.element('');var h=angular.element('');h.on("click",function(q){q.preventDefault();o.css({width:"100%",height:""});p()});var f=angular.element('');f.on("click",function(q){q.preventDefault();o.css({width:"50%",height:""});p()});var k=angular.element('');k.on("click",function(q){q.preventDefault();o.css({width:"25%",height:""});p()});var m=angular.element('');m.on("click",function(q){q.preventDefault();o.css({width:"",height:""});p()});j.append(h);j.append(f);j.append(k);j.append(m);d.append(j);j=angular.element('');var g=angular.element('');g.on("click",function(q){q.preventDefault();o.css("float","left");o.css("cssFloat","left");o.css("styleFloat","left");p()});var l=angular.element('');l.on("click",function(q){q.preventDefault();o.css("float","right");o.css("cssFloat","right");o.css("styleFloat","right");p()});var n=angular.element('');n.on("click",function(q){q.preventDefault();o.css("float","");o.css("cssFloat","");o.css("styleFloat","");p()});j.append(g);j.append(n);j.append(l);d.append(j);j=angular.element('');var i=angular.element('');i.on("click",function(q){q.preventDefault();o.remove();p()});j.append(i);d.append(j);e.showPopover(o);e.showResizeOverlay(o)},aOnSelectAction:function(e,k,g){e.preventDefault();g.displayElements.popover.css("width","436px");var f=g.displayElements.popoverContainer;f.empty();f.css("line-height","28px");var j=angular.element(''+k.attr("href")+"");j.css({display:"inline-block","max-width":"200px",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap","vertical-align":"middle"});f.append(j);var i=angular.element('');var c=angular.element('');c.on("click",function(m){m.preventDefault();var l=b.prompt(a.insertLink.dialogPrompt,k.attr("href"));if(l&&l!==""&&l!=="http://"){k.attr("href",l);g.updateTaBindtaTextElement()}g.hidePopover()});i.append(c);var h=angular.element('');h.on("click",function(l){l.preventDefault();k.replaceWith(k.contents());g.updateTaBindtaTextElement();g.hidePopover()});i.append(h);var d=angular.element('");if(k.attr("target")==="_blank"){d.addClass("active")}d.on("click",function(l){l.preventDefault();k.attr("target",(k.attr("target")==="_blank")?"":"_blank");d.toggleClass("active");g.updateTaBindtaTextElement()});i.append(d);f.append(i);g.showPopover(k)},extractYoutubeVideoId:function(d){var e=/(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/i;var c=d.match(e);return(c&&c[1])||null}}}]).run(["taRegisterTool","$window","taTranslations","taSelection","taToolFunctions","$sanitize","taOptions","$log",function(h,c,g,e,i,k,d,l){var a={};k("",a);if((d.forceTextAngularSanitize===true)&&(a.version!=="taSanitize")){throw angular.$$minErr("textAngular")("textAngularSetup","The textAngular-sanitize provider has been replaced by another -- have you included angular-sanitize by mistake?")}h("html",{iconclass:"fa fa-code",tooltiptext:g.html.tooltip,action:function(){this.$editor().switchView()},activeState:function(){return this.$editor().showHtml}});var f=function(m){return function(){return this.$editor().queryFormatBlockState(m)}};var j=function(){return this.$editor().wrapSelection("formatBlock","<"+this.name.toUpperCase()+">")};angular.forEach(["h1","h2","h3","h4","h5","h6"],function(m){h(m.toLowerCase(),{buttontext:m.toUpperCase(),tooltiptext:g.heading.tooltip+m.charAt(1),action:j,activeState:f(m.toLowerCase())})});h("p",{buttontext:"P",tooltiptext:g.p.tooltip,action:function(){return this.$editor().wrapSelection("formatBlock","")},activeState:function(){return this.$editor().queryFormatBlockState("p")}});h("pre",{buttontext:"pre",tooltiptext:g.pre.tooltip,action:function(){return this.$editor().wrapSelection("formatBlock","
")},activeState:function(){return this.$editor().queryFormatBlockState("pre")}});h("ul",{iconclass:"fa fa-list-ul",tooltiptext:g.ul.tooltip,action:function(){return this.$editor().wrapSelection("insertUnorderedList",null)},activeState:function(){return this.$editor().queryCommandState("insertUnorderedList")}});h("ol",{iconclass:"fa fa-list-ol",tooltiptext:g.ol.tooltip,action:function(){return this.$editor().wrapSelection("insertOrderedList",null)},activeState:function(){return this.$editor().queryCommandState("insertOrderedList")}});h("quote",{iconclass:"fa fa-quote-right",tooltiptext:g.quote.tooltip,action:function(){return this.$editor().wrapSelection("formatBlock","")},activeState:function(){return this.$editor().queryFormatBlockState("blockquote")}});h("undo",{iconclass:"fa fa-undo",tooltiptext:g.undo.tooltip,action:function(){return this.$editor().wrapSelection("undo",null)}});h("redo",{iconclass:"fa fa-repeat",tooltiptext:g.redo.tooltip,action:function(){return this.$editor().wrapSelection("redo",null)}});h("bold",{iconclass:"fa fa-bold",tooltiptext:g.bold.tooltip,action:function(){return this.$editor().wrapSelection("bold",null)},activeState:function(){return this.$editor().queryCommandState("bold")},commandKeyCode:98});h("justifyLeft",{iconclass:"fa fa-align-left",tooltiptext:g.justifyLeft.tooltip,action:function(){return this.$editor().wrapSelection("justifyLeft",null)},activeState:function(n){if(n&&n.nodeName==="#document"){return false}var m=false;if(n){try{m=n.css("text-align")==="left"||n.attr("align")==="left"||(n.css("text-align")!=="right"&&n.css("text-align")!=="center"&&n.css("text-align")!=="justify"&&!this.$editor().queryCommandState("justifyRight")&&!this.$editor().queryCommandState("justifyCenter"))&&!this.$editor().queryCommandState("justifyFull")}catch(o){m=false}}m=m||this.$editor().queryCommandState("justifyLeft");return m}});h("justifyRight",{iconclass:"fa fa-align-right",tooltiptext:g.justifyRight.tooltip,action:function(){return this.$editor().wrapSelection("justifyRight",null)},activeState:function(n){if(n&&n.nodeName==="#document"){return false}var m=false;if(n){try{m=n.css("text-align")==="right"}catch(o){m=false}}m=m||this.$editor().queryCommandState("justifyRight");return m}});h("justifyFull",{iconclass:"fa fa-align-justify",tooltiptext:g.justifyFull.tooltip,action:function(){return this.$editor().wrapSelection("justifyFull",null)},activeState:function(n){var m=false;if(n){try{m=n.css("text-align")==="justify"}catch(o){m=false}}m=m||this.$editor().queryCommandState("justifyFull");return m}});h("justifyCenter",{iconclass:"fa fa-align-center",tooltiptext:g.justifyCenter.tooltip,action:function(){return this.$editor().wrapSelection("justifyCenter",null)},activeState:function(n){if(n&&n.nodeName==="#document"){return false}var m=false;if(n){try{m=n.css("text-align")==="center"}catch(o){m=false}}m=m||this.$editor().queryCommandState("justifyCenter");return m}});h("indent",{iconclass:"fa fa-indent",tooltiptext:g.indent.tooltip,action:function(){return this.$editor().wrapSelection("indent",null)},activeState:function(){return this.$editor().queryFormatBlockState("blockquote")},commandKeyCode:"TabKey"});h("outdent",{iconclass:"fa fa-outdent",tooltiptext:g.outdent.tooltip,action:function(){return this.$editor().wrapSelection("outdent",null)},activeState:function(){return false},commandKeyCode:"ShiftTabKey"});h("italics",{iconclass:"fa fa-italic",tooltiptext:g.italic.tooltip,action:function(){return this.$editor().wrapSelection("italic",null)},activeState:function(){return this.$editor().queryCommandState("italic")},commandKeyCode:105});h("underline",{iconclass:"fa fa-underline",tooltiptext:g.underline.tooltip,action:function(){return this.$editor().wrapSelection("underline",null)},activeState:function(){return this.$editor().queryCommandState("underline")},commandKeyCode:117});h("strikeThrough",{iconclass:"fa fa-strikethrough",tooltiptext:g.strikeThrough.tooltip,action:function(){return this.$editor().wrapSelection("strikeThrough",null)},activeState:function(){return document.queryCommandState("strikeThrough")}});h("clear",{iconclass:"fa fa-ban",tooltiptext:g.clear.tooltip,action:function(u,m){var s,r,q;this.$editor().wrapSelection("removeFormat",null);var p=angular.element(e.getSelectionElement());r=e.getAllSelectedElements();var t=function(x,w){x=angular.element(x);var v=w;if(!w){v=x}angular.forEach(x.children(),function(z){if(z.tagName.toLowerCase()==="ul"||z.tagName.toLowerCase()==="ol"){v=t(z,v)}else{var y=angular.element("");y.html(angular.element(z).html());v.after(y);v=y}});x.remove();return v};angular.forEach(r,function(v){if(v.nodeName.toLowerCase()==="ul"||v.nodeName.toLowerCase()==="ol"){t(v)}});angular.forEach(p.find("ul"),t);angular.forEach(p.find("ol"),t);var o=this.$editor();var n=function(v){v=angular.element(v);if(v[0]!==o.displayElements.text[0]){v.removeAttr("class")}angular.forEach(v.children(),n)};angular.forEach(p,n);if(p[0]&&p[0].tagName.toLowerCase()!=="li"&&p[0].tagName.toLowerCase()!=="ol"&&p[0].tagName.toLowerCase()!=="ul"&&p[0].getAttribute("contenteditable")!=="true"){this.$editor().wrapSelection("formatBlock","default")}m()}});var b=function(m){if(m.toLowerCase().indexOf("javascript")!==-1){return true}return false};h("insertImage",{iconclass:"fa fa-picture-o",tooltiptext:g.insertImage.tooltip,action:function(){var m;m=c.prompt(g.insertImage.dialogPrompt,"http://");if(m&&m!==""&&m!=="http://"){if(!b(m)){if(e.getSelectionElement().tagName&&e.getSelectionElement().tagName.toLowerCase()==="a"){e.setSelectionAfterElement(e.getSelectionElement())}var n='
';return this.$editor().wrapSelection("insertHTML",n,true)}}},onElementSelect:{element:"img",action:i.imgOnSelectAction}});h("insertVideo",{iconclass:"fa fa-youtube-play",tooltiptext:g.insertVideo.tooltip,action:function(){var n;n=c.prompt(g.insertVideo.dialogPrompt,"https://");if(!b(n)){if(n&&n!==""&&n!=="https://"){videoId=i.extractYoutubeVideoId(n);if(videoId){var m="https://www.youtube.com/embed/"+videoId;var o='
';if(e.getSelectionElement().tagName&&e.getSelectionElement().tagName.toLowerCase()==="a"){e.setSelectionAfterElement(e.getSelectionElement())}return this.$editor().wrapSelection("insertHTML",o,true)}}}},onElementSelect:{element:"img",onlyWithAttrs:["ta-insert-video"],action:i.imgOnSelectAction}});h("insertLink",{tooltiptext:g.insertLink.tooltip,iconclass:"fa fa-link",action:function(){var m;if(e.getSelectionElement().tagName&&e.getSelectionElement().tagName.toLowerCase()==="a"){m=c.prompt(g.insertLink.dialogPrompt,e.getSelectionElement().href)}else{m=c.prompt(g.insertLink.dialogPrompt,"http://")}if(m&&m!==""&&m!=="http://"){if(!b(m)){return this.$editor().wrapSelection("createLink",m,true)}}},activeState:function(m){if(m){return m[0].tagName==="A"}return false},onElementSelect:{element:"a",action:i.aOnSelectAction}});h("wordcount",{display:'Words: ',disabled:true,wordcount:0,activeState:function(){var m=this.$editor().displayElements.text;var n=m[0].innerHTML||"";var o=0;if(n.replace(/\s*<[^>]*?>\s*/g,"")!==""){if(n.trim()!==""){o=n.replace(/<\/?(b|i|em|strong|span|u|strikethrough|a|img|small|sub|sup|label)( [^>*?])?>/gi,"").replace(/(<[^>]*?>\s*<[^>]*?>)/ig," ").replace(/(<[^>]*?>)/ig,"").replace(/\s+/ig," ").match(/\S+/g).length}}this.wordcount=o;this.$editor().wordcount=o;return false}});h("charcount",{display:'Characters: ',disabled:true,charcount:0,activeState:function(){var m=this.$editor().displayElements.text;var o=m[0].innerText||m[0].textContent;var n=o.replace(/(\r\n|\n|\r)/gm,"").replace(/^\s+/g," ").replace(/\s+$/g," ").length;this.charcount=n;this.$editor().charcount=n;return false}})}]);
© 2015 - 2025 Weber Informatics LLC | Privacy Policy