All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.textAngular.src.main.min.js Maven / Gradle / Ivy

var dropFired=false;var textAngular=angular.module("textAngular",["ngSanitize","textAngularSetup","textAngular.factories","textAngular.DOM","textAngular.validators","textAngular.taBind"]);textAngular.config([function(){angular.forEach(taTools,function(value,key){delete taTools[key]})}]);textAngular.directive("textAngular",["$compile","$timeout","taOptions","taSelection","taExecCommand","textAngularManager","$document","$animate","$log","$q","$parse",function($compile,$timeout,taOptions,taSelection,taExecCommand,textAngularManager,$document,$animate,$log,$q,$parse){return{require:"?ngModel",scope:{},restrict:"EA",priority:2,link:function(scope,element,attrs,ngModel){var _keydown,_keyup,_keypress,_mouseup,_focusin,_focusout,_originalContents,_editorFunctions,_serial=attrs.serial?attrs.serial:Math.floor(Math.random()*1e16),_taExecCommand,_resizeMouseDown,_updateSelectedStylesTimeout;var _resizeTimeout;scope._name=attrs.name?attrs.name:"textAngularEditor"+_serial;var oneEvent=function(_element,event,action){$timeout(function(){_element.one(event,action)},100)};_taExecCommand=taExecCommand(attrs.taDefaultWrap);angular.extend(scope,angular.copy(taOptions),{wrapSelection:function(command,opt,isSelectableElementTool){if(command.toLowerCase()==="undo"){scope["$undoTaBindtaTextElement"+_serial]()}else if(command.toLowerCase()==="redo"){scope["$redoTaBindtaTextElement"+_serial]()}else{_taExecCommand(command,false,opt,scope.defaultTagAttributes);if(isSelectableElementTool){scope["reApplyOnSelectorHandlerstaTextElement"+_serial]()}scope.displayElements.text[0].focus()}},showHtml:scope.$eval(attrs.taShowHtml)||false});if(attrs.taFocussedClass)scope.classes.focussed=attrs.taFocussedClass;if(attrs.taTextEditorClass)scope.classes.textEditor=attrs.taTextEditorClass;if(attrs.taHtmlEditorClass)scope.classes.htmlEditor=attrs.taHtmlEditorClass;if(attrs.taDefaultTagAttributes){try{angular.extend(scope.defaultTagAttributes,angular.fromJson(attrs.taDefaultTagAttributes))}catch(error){$log.error(error)}}if(attrs.taTextEditorSetup)scope.setup.textEditorSetup=scope.$parent.$eval(attrs.taTextEditorSetup);if(attrs.taHtmlEditorSetup)scope.setup.htmlEditorSetup=scope.$parent.$eval(attrs.taHtmlEditorSetup);if(attrs.taFileDrop)scope.fileDropHandler=scope.$parent.$eval(attrs.taFileDrop);else scope.fileDropHandler=scope.defaultFileDropHandler;_originalContents=element[0].innerHTML;element[0].innerHTML="";scope.displayElements={forminput:angular.element(""),html:angular.element(""),text:angular.element("
"),scrollWindow:angular.element("
"),popover:angular.element('
'),popoverArrow:angular.element('
'),popoverContainer:angular.element('
'),resize:{overlay:angular.element('
'),background:angular.element('
'),anchors:[angular.element('
'),angular.element('
'),angular.element('
'),angular.element('
')],info:angular.element('
')}};scope.displayElements.popover.append(scope.displayElements.popoverArrow);scope.displayElements.popover.append(scope.displayElements.popoverContainer);scope.displayElements.scrollWindow.append(scope.displayElements.popover);scope.displayElements.popover.on("mousedown",function(e,eventData){if(eventData)angular.extend(e,eventData);e.preventDefault();return false});scope.handlePopoverEvents=function(){if(scope.displayElements.popover.css("display")==="block"){if(_resizeTimeout)$timeout.cancel(_resizeTimeout);_resizeTimeout=$timeout(function(){scope.reflowPopover(scope.resizeElement);scope.reflowResizeOverlay(scope.resizeElement)},100)}};angular.element(window).on("resize",scope.handlePopoverEvents);angular.element(window).on("scroll",scope.handlePopoverEvents);var isScrollable=function(node){var cs;var _notScrollable={vertical:false,horizontal:false};try{cs=window.getComputedStyle(node);if(cs===null){return _notScrollable}}catch(e){return _notScrollable}var overflowY=cs["overflow-y"];var overflowX=cs["overflow-x"];return{vertical:(overflowY==="scroll"||overflowY==="auto")&&node.scrollHeight>node.clientHeight,horizontal:(overflowX==="scroll"||overflowX==="auto")&&node.scrollWidth>node.clientWidth}};scope.getScrollTop=function(_el,bAddListener){var scrollTop=_el.scrollTop;if(typeof scrollTop==="undefined"){scrollTop=0}if(bAddListener&&isScrollable(_el).vertical){_el.removeEventListener("scroll",scope._scrollListener,false);_el.addEventListener("scroll",scope._scrollListener,false)}if(scrollTop!==0){return{node:_el.nodeName,top:scrollTop}}if(_el.parentNode){return scope.getScrollTop(_el.parentNode,bAddListener)}else{return{node:"",top:0}}};scope.showPopover=function(_el){scope.getScrollTop(scope.displayElements.scrollWindow[0],true);scope.displayElements.popover.css("display","block");$timeout(function(){scope.displayElements.resize.overlay.css("display","block")});scope.resizeElement=_el;scope.reflowPopover(_el);$animate.addClass(scope.displayElements.popover,"in");oneEvent($document.find("body"),"click keyup",function(){scope.hidePopover()})};scope._scrollListener=function(e,eventData){scope.handlePopoverEvents()};scope.reflowPopover=function(_el){var scrollTop=scope.getScrollTop(scope.displayElements.scrollWindow[0],false);var spaceAboveImage=_el[0].offsetTop-scrollTop.top;if(spaceAboveImage<51){scope.displayElements.popover.css("top",_el[0].offsetTop+_el[0].offsetHeight+scope.displayElements.scrollWindow[0].scrollTop+"px");scope.displayElements.popover.removeClass("top").addClass("bottom")}else{scope.displayElements.popover.css("top",_el[0].offsetTop-54+scope.displayElements.scrollWindow[0].scrollTop+"px");scope.displayElements.popover.removeClass("bottom").addClass("top")}var _maxLeft=scope.displayElements.text[0].offsetWidth-scope.displayElements.popover[0].offsetWidth;var _targetLeft=_el[0].offsetLeft+_el[0].offsetWidth/2-scope.displayElements.popover[0].offsetWidth/2;var _rleft=Math.max(0,Math.min(_maxLeft,_targetLeft));var _marginLeft=Math.min(_targetLeft,Math.max(0,_targetLeft-_maxLeft))-11;_rleft+=window.scrollX;_marginLeft-=window.scrollX;scope.displayElements.popover.css("left",_rleft+"px");scope.displayElements.popoverArrow.css("margin-left",_marginLeft+"px")};scope.hidePopover=function(){scope.displayElements.popover.css("display","none");scope.displayElements.popoverContainer.attr("style","");scope.displayElements.popoverContainer.attr("class","popover-content");scope.displayElements.popover.removeClass("in");scope.displayElements.resize.overlay.css("display","none")};scope.displayElements.resize.overlay.append(scope.displayElements.resize.background);angular.forEach(scope.displayElements.resize.anchors,function(anchor){scope.displayElements.resize.overlay.append(anchor)});scope.displayElements.resize.overlay.append(scope.displayElements.resize.info);scope.displayElements.scrollWindow.append(scope.displayElements.resize.overlay);scope.displayElements.resize.background.on("click",function(e){scope.displayElements.text[0].focus()});scope.reflowResizeOverlay=function(_el){_el=angular.element(_el)[0];scope.displayElements.resize.overlay.css({display:"block",left:_el.offsetLeft-5+"px",top:_el.offsetTop-5+"px",width:_el.offsetWidth+10+"px",height:_el.offsetHeight+10+"px"});scope.displayElements.resize.info.text(_el.offsetWidth+" x "+_el.offsetHeight)};scope.showResizeOverlay=function(_el){var _body=$document.find("body");_resizeMouseDown=function(event){var startPosition={width:parseInt(_el.attr("width")),height:parseInt(_el.attr("height")),x:event.clientX,y:event.clientY};if(startPosition.width===undefined||isNaN(startPosition.width))startPosition.width=_el[0].offsetWidth;if(startPosition.height===undefined||isNaN(startPosition.height))startPosition.height=_el[0].offsetHeight;scope.hidePopover();var ratio=startPosition.height/startPosition.width;var mousemove=function(event){var pos={x:Math.max(0,startPosition.width+(event.clientX-startPosition.x)),y:Math.max(0,startPosition.height+(event.clientY-startPosition.y))};var bForceAspectRatio=attrs.taResizeForceAspectRatio!==undefined;var bFlipKeyBinding=attrs.taResizeMaintainAspectRatio;var bKeepRatio=bForceAspectRatio||bFlipKeyBinding&&!event.shiftKey;if(bKeepRatio){var newRatio=pos.y/pos.x;pos.x=ratio>newRatio?pos.x:pos.y/ratio;pos.y=ratio>newRatio?pos.x*ratio:pos.y}var el=angular.element(_el);function roundedMaxVal(val){return Math.round(Math.max(0,val))}el.css("height",roundedMaxVal(pos.y)+"px");el.css("width",roundedMaxVal(pos.x)+"px");scope.reflowResizeOverlay(_el)};_body.on("mousemove",mousemove);oneEvent(_body,"mouseup",function(event){event.preventDefault();event.stopPropagation();_body.off("mousemove",mousemove);scope.$apply(function(){scope.hidePopover();scope.updateTaBindtaTextElement()},100)});event.stopPropagation();event.preventDefault()};scope.displayElements.resize.anchors[3].off("mousedown");scope.displayElements.resize.anchors[3].on("mousedown",_resizeMouseDown);scope.reflowResizeOverlay(_el);oneEvent(_body,"click",function(){scope.hideResizeOverlay()})};scope.hideResizeOverlay=function(){scope.displayElements.resize.anchors[3].off("mousedown",_resizeMouseDown);scope.displayElements.resize.overlay.css("display","none")};scope.setup.htmlEditorSetup(scope.displayElements.html);scope.setup.textEditorSetup(scope.displayElements.text);scope.displayElements.html.attr({id:"taHtmlElement"+_serial,"ng-show":"showHtml","ta-bind":"ta-bind","ng-model":"html","ng-model-options":element.attr("ng-model-options")});scope.displayElements.text.attr({id:"taTextElement"+_serial,contentEditable:"true","ta-bind":"ta-bind","ng-model":"html","ng-model-options":element.attr("ng-model-options")});scope.displayElements.scrollWindow.attr({"ng-hide":"showHtml"});if(attrs.taDefaultWrap){scope.displayElements.text.attr("ta-default-wrap",attrs.taDefaultWrap)}if(attrs.taUnsafeSanitizer){scope.displayElements.text.attr("ta-unsafe-sanitizer",attrs.taUnsafeSanitizer);scope.displayElements.html.attr("ta-unsafe-sanitizer",attrs.taUnsafeSanitizer)}if(attrs.taKeepStyles){scope.displayElements.text.attr("ta-keep-styles",attrs.taKeepStyles);scope.displayElements.html.attr("ta-keep-styles",attrs.taKeepStyles)}scope.displayElements.scrollWindow.append(scope.displayElements.text);element.append(scope.displayElements.scrollWindow);element.append(scope.displayElements.html);scope.displayElements.forminput.attr("name",scope._name);element.append(scope.displayElements.forminput);if(attrs.tabindex){element.removeAttr("tabindex");scope.displayElements.text.attr("tabindex",attrs.tabindex);scope.displayElements.html.attr("tabindex",attrs.tabindex)}if(attrs.placeholder){scope.displayElements.text.attr("placeholder",attrs.placeholder);scope.displayElements.html.attr("placeholder",attrs.placeholder)}if(attrs.taDisabled){scope.displayElements.text.attr("ta-readonly","disabled");scope.displayElements.html.attr("ta-readonly","disabled");scope.disabled=scope.$parent.$eval(attrs.taDisabled);scope.$parent.$watch(attrs.taDisabled,function(newVal){scope.disabled=newVal;if(scope.disabled){element.addClass(scope.classes.disabled)}else{element.removeClass(scope.classes.disabled)}})}if(attrs.taPaste){scope._pasteHandler=function(_html){return $parse(attrs.taPaste)(scope.$parent,{$html:_html})};scope.displayElements.text.attr("ta-paste","_pasteHandler($html)")}$compile(scope.displayElements.scrollWindow)(scope);$compile(scope.displayElements.html)(scope);scope.updateTaBindtaTextElement=scope["updateTaBindtaTextElement"+_serial];scope.updateTaBindtaHtmlElement=scope["updateTaBindtaHtmlElement"+_serial];element.addClass("ta-root");scope.displayElements.scrollWindow.addClass("ta-text ta-editor "+scope.classes.textEditor);scope.displayElements.html.addClass("ta-html ta-editor "+scope.classes.htmlEditor);var testAndSet=function(choice,beforeState){if(beforeState!==$document[0].queryCommandState(choice)){$document[0].execCommand(choice,false,null)}};scope._actionRunning=false;var _savedSelection=false;scope.startAction=function(){var _beforeStateBold=false;var _beforeStateItalic=false;var _beforeStateUnderline=false;var _beforeStateStrikethough=false;scope._actionRunning=true;_beforeStateBold=$document[0].queryCommandState("bold");_beforeStateItalic=$document[0].queryCommandState("italic");_beforeStateUnderline=$document[0].queryCommandState("underline");_beforeStateStrikethough=$document[0].queryCommandState("strikeThrough");_savedSelection=rangy.saveSelection();testAndSet("bold",_beforeStateBold);testAndSet("italic",_beforeStateItalic);testAndSet("underline",_beforeStateUnderline);testAndSet("strikeThrough",_beforeStateStrikethough);return function(){if(_savedSelection)rangy.restoreSelection(_savedSelection)}};scope.endAction=function(){scope._actionRunning=false;if(_savedSelection){if(scope.showHtml){scope.displayElements.html[0].focus()}else{scope.displayElements.text[0].focus()}rangy.removeMarkers(_savedSelection)}_savedSelection=false;scope.updateSelectedStyles();if(!scope.showHtml)scope["updateTaBindtaTextElement"+_serial]()};_focusin=function(e){scope.focussed=true;element.addClass(scope.classes.focussed);_editorFunctions.focus();element.triggerHandler("focus");if(scope.updateSelectedStyles&&!scope._bUpdateSelectedStyles){$timeout(function(){scope.updateSelectedStyles()},0)}};scope.displayElements.html.on("focus",_focusin);scope.displayElements.text.on("focus",_focusin);_focusout=function(e){if(!scope._actionRunning&&$document[0].activeElement!==scope.displayElements.html[0]&&$document[0].activeElement!==scope.displayElements.text[0]){element.removeClass(scope.classes.focussed);_editorFunctions.unfocus();$timeout(function(){scope._bUpdateSelectedStyles=false;element.triggerHandler("blur");scope.focussed=false},0)}e.preventDefault();return false};scope.displayElements.html.on("blur",_focusout);scope.displayElements.text.on("blur",_focusout);scope.displayElements.text.on("paste",function(event){element.triggerHandler("paste",event)});scope.queryFormatBlockState=function(command){return!scope.showHtml&&command.toLowerCase()===$document[0].queryCommandValue("formatBlock").toLowerCase()};scope.queryCommandState=function(command){return!scope.showHtml?$document[0].queryCommandState(command):""};scope.switchView=function(){scope.showHtml=!scope.showHtml;$animate.enabled(false,scope.displayElements.html);$animate.enabled(false,scope.displayElements.text);if(scope.showHtml){$timeout(function(){$animate.enabled(true,scope.displayElements.html);$animate.enabled(true,scope.displayElements.text);return scope.displayElements.html[0].focus()},100)}else{$timeout(function(){$animate.enabled(true,scope.displayElements.html);$animate.enabled(true,scope.displayElements.text);return scope.displayElements.text[0].focus()},100)}};if(attrs.ngModel){var _firstRun=true;ngModel.$render=function(){if(_firstRun){_firstRun=false;var _initialValue=scope.$parent.$eval(attrs.ngModel);if((_initialValue===undefined||_initialValue===null)&&(_originalContents&&_originalContents!=="")){ngModel.$setViewValue(_originalContents)}}scope.displayElements.forminput.val(ngModel.$viewValue);scope.html=ngModel.$viewValue||""};if(element.attr("required"))ngModel.$validators.required=function(modelValue,viewValue){var value=modelValue||viewValue;return!(!value||value.trim()==="")}}else{scope.displayElements.forminput.val(_originalContents);scope.html=_originalContents}scope.$watch("html",function(newValue,oldValue){if(newValue!==oldValue){if(attrs.ngModel&&ngModel.$viewValue!==newValue){ngModel.$setViewValue(newValue)}scope.displayElements.forminput.val(newValue)}});if(attrs.taTargetToolbars){_editorFunctions=textAngularManager.registerEditor(scope._name,scope,attrs.taTargetToolbars.split(","))}else{var _toolbar=angular.element('
');if(attrs.taToolbar)_toolbar.attr("ta-toolbar",attrs.taToolbar);if(attrs.taToolbarClass)_toolbar.attr("ta-toolbar-class",attrs.taToolbarClass);if(attrs.taToolbarGroupClass)_toolbar.attr("ta-toolbar-group-class",attrs.taToolbarGroupClass);if(attrs.taToolbarButtonClass)_toolbar.attr("ta-toolbar-button-class",attrs.taToolbarButtonClass);if(attrs.taToolbarActiveButtonClass)_toolbar.attr("ta-toolbar-active-button-class",attrs.taToolbarActiveButtonClass);if(attrs.taFocussedClass)_toolbar.attr("ta-focussed-class",attrs.taFocussedClass);element.prepend(_toolbar);$compile(_toolbar)(scope.$parent);_editorFunctions=textAngularManager.registerEditor(scope._name,scope,["textAngularToolbar"+_serial])}scope.$on("$destroy",function(){textAngularManager.unregisterEditor(scope._name);angular.element(window).off("blur");angular.element(window).off("resize",scope.handlePopoverEvents);angular.element(window).off("scroll",scope.handlePopoverEvents)});scope.$on("ta-element-select",function(event,element){if(_editorFunctions.triggerElementSelect(event,element)){scope["reApplyOnSelectorHandlerstaTextElement"+_serial]()}});scope.$on("ta-drop-event",function(event,element,dropEvent,dataTransfer){if(dataTransfer&&dataTransfer.files&&dataTransfer.files.length>0){scope.displayElements.text[0].focus();taSelection.setSelectionToElementEnd(dropEvent.target);angular.forEach(dataTransfer.files,function(file){try{$q.when(scope.fileDropHandler(file,scope.wrapSelection)||scope.fileDropHandler!==scope.defaultFileDropHandler&&$q.when(scope.defaultFileDropHandler(file,scope.wrapSelection))).then(function(){scope["updateTaBindtaTextElement"+_serial]()})}catch(error){$log.error(error)}});dropEvent.preventDefault();dropEvent.stopPropagation()}else{$timeout(function(){scope["updateTaBindtaTextElement"+_serial]()},0)}});scope._bUpdateSelectedStyles=false;angular.element(window).on("blur",function(){scope._bUpdateSelectedStyles=false;scope.focussed=false});scope.updateSelectedStyles=function(){var _selection;if(_updateSelectedStylesTimeout)$timeout.cancel(_updateSelectedStylesTimeout);if((_selection=taSelection.getSelectionElement())!==undefined&&_selection.parentNode!==scope.displayElements.text[0]){_editorFunctions.updateSelectedStyles(angular.element(_selection))}else _editorFunctions.updateSelectedStyles();if(scope._bUpdateSelectedStyles)_updateSelectedStylesTimeout=$timeout(scope.updateSelectedStyles,200)};_keydown=function(){if(!scope.focussed){scope._bUpdateSelectedStyles=false;return}if(!scope._bUpdateSelectedStyles){scope._bUpdateSelectedStyles=true;scope.$apply(function(){scope.updateSelectedStyles()})}};scope.displayElements.html.on("keydown",_keydown);scope.displayElements.text.on("keydown",_keydown);_keyup=function(){scope._bUpdateSelectedStyles=false};scope.displayElements.html.on("keyup",_keyup);scope.displayElements.text.on("keyup",_keyup);_keypress=function(event,eventData){if(taSelection.getSelection){var _selection=taSelection.getSelection();if(taSelection.getSelectionElement()&&taSelection.getSelectionElement().nodeName.toLowerCase()==="a"){if(_selection.start.element.nodeType===3&&_selection.start.element.textContent.length===_selection.end.offset){taSelection.setSelectionAfterElement(taSelection.getSelectionElement())}if(_selection.start.element.nodeType===3&&_selection.start.offset===0){taSelection.setSelectionBeforeElement(taSelection.getSelectionElement())}}}if(eventData)angular.extend(event,eventData);scope.$apply(function(){if(_editorFunctions.sendKeyCommand(event)){if(!scope._bUpdateSelectedStyles){scope.updateSelectedStyles()}event.preventDefault();return false}})};scope.displayElements.html.on("keypress",_keypress);scope.displayElements.text.on("keypress",_keypress);_mouseup=function(){scope._bUpdateSelectedStyles=false;$timeout(function(){scope.updateSelectedStyles()},0)};scope.displayElements.html.on("mouseup",_mouseup);scope.displayElements.text.on("mouseup",_mouseup)}}}]);textAngular.service("textAngularManager",["taToolExecuteAction","taTools","taRegisterTool","$interval","$rootScope","$log",function(taToolExecuteAction,taTools,taRegisterTool,$interval,$rootScope,$log){var toolbars={},editors={};var timeRecentModification=0;var updateStyles=function(selectedElement){angular.forEach(editors,function(editor){editor.editorFunctions.updateSelectedStyles(selectedElement)})};var triggerInterval=50;var triggerIntervalTimer;var setupTriggerUpdateStyles=function(){timeRecentModification=Date.now();triggerIntervalTimer=$interval(function(){updateStyles();triggerIntervalTimer=undefined},triggerInterval,1)};$rootScope.$on("destroy",function(){if(triggerIntervalTimer){$interval.cancel(triggerIntervalTimer);triggerIntervalTimer=undefined}});var touchModification=function(){if(Math.abs(Date.now()-timeRecentModification)>triggerInterval){setupTriggerUpdateStyles()}};return{registerEditor:function(editorName,editorScope,targetToolbars){if(!editorName||editorName==="")throw"textAngular Error: An editor requires a name";if(!editorScope)throw"textAngular Error: An editor requires a scope";if(editors[editorName])throw'textAngular Error: An Editor with name "'+editorName+'" already exists';editors[editorName]={scope:editorScope,toolbars:targetToolbars,toolbarScopes:[],_registerToolbarScope:function(toolbarScope){if(this.toolbars.indexOf(toolbarScope.name)>=0){this.toolbarScopes.push(toolbarScope)}},editorFunctions:{disable:function(){angular.forEach(editors[editorName].toolbarScopes,function(toolbarScope){toolbarScope.disabled=true})},enable:function(){angular.forEach(editors[editorName].toolbarScopes,function(toolbarScope){toolbarScope.disabled=false})},focus:function(){angular.forEach(editors[editorName].toolbarScopes,function(toolbarScope){toolbarScope._parent=editorScope;toolbarScope.disabled=false;toolbarScope.focussed=true});editorScope.focussed=true},unfocus:function(){angular.forEach(editors[editorName].toolbarScopes,function(toolbarScope){toolbarScope.disabled=true;toolbarScope.focussed=false});editorScope.focussed=false},updateSelectedStyles:function(selectedElement){angular.forEach(editors[editorName].toolbarScopes,function(toolbarScope){angular.forEach(toolbarScope.tools,function(toolScope){if(toolScope.activeState){toolbarScope._parent=editorScope;toolScope.active=toolScope.activeState(selectedElement)}})})},sendKeyCommand:function(event){var result=false;if(event.ctrlKey||event.metaKey||event.specialKey)angular.forEach(taTools,function(tool,name){if(tool.commandKeyCode&&(tool.commandKeyCode===event.which||tool.commandKeyCode===event.specialKey)){for(var _t=0;_t0){for(var _i=0;_i");if(toolDefinition&&toolDefinition["class"])toolElement.addClass(toolDefinition["class"]);else toolElement.addClass(scope.classes.toolbarButton);toolElement.attr("name",toolScope.name);toolElement.attr("ta-button","ta-button");toolElement.attr("ng-disabled","isDisabled()");toolElement.attr("tabindex","-1");toolElement.attr("ng-click","executeAction()");toolElement.attr("ng-class","displayActiveToolClass(active)");if(toolDefinition&&toolDefinition.tooltiptext){toolElement.attr("title",toolDefinition.tooltiptext)}if(toolDefinition&&!toolDefinition.display&&!toolScope._display){toolElement[0].innerHTML="";if(toolDefinition.buttontext)toolElement[0].innerHTML=toolDefinition.buttontext;if(toolDefinition.iconclass){var icon=angular.element(""),content=toolElement[0].innerHTML;icon.addClass(toolDefinition.iconclass);toolElement[0].innerHTML="";toolElement.append(icon);if(content&&content!=="")toolElement.append(" "+content)}}toolScope._lastToolDefinition=angular.copy(toolDefinition);return $compile(toolElement)(toolScope)};scope.tools={};scope._parent={disabled:true,showHtml:false,queryFormatBlockState:function(){return false},queryCommandState:function(){return false}};var defaultChildScope={$window:$window,$editor:function(){return scope._parent},isDisabled:function(){if(this.name==="html"&&scope._parent.startAction){return false}return typeof this.$eval("disabled")!=="function"&&this.$eval("disabled")||this.$eval("disabled()")||this.name!=="html"&&this.$editor().showHtml||this.$parent.disabled||this.$editor().disabled},displayActiveToolClass:function(active){return active?scope.classes.toolbarButtonActive:""},executeAction:taToolExecuteAction};angular.forEach(scope.toolbar,function(group){var groupElement=angular.element("
");groupElement.addClass(scope.classes.toolbarGroup);angular.forEach(group,function(tool){scope.tools[tool]=angular.extend(scope.$new(true),taTools[tool],defaultChildScope,{name:tool});scope.tools[tool].$element=setupToolElement(taTools[tool],scope.tools[tool]);groupElement.append(scope.tools[tool].$element)});element.append(groupElement)});scope.updateToolDisplay=function(key,_newTool,forceNew){var toolInstance=scope.tools[key];if(toolInstance){if(toolInstance._lastToolDefinition&&!forceNew)_newTool=angular.extend({},toolInstance._lastToolDefinition,_newTool);if(_newTool.buttontext===null&&_newTool.iconclass===null&&_newTool.display===null)throw'textAngular Error: Tool Definition for updating "'+key+'" does not have a valid display/iconclass/buttontext value';if(_newTool.buttontext===null){delete _newTool.buttontext}if(_newTool.iconclass===null){delete _newTool.iconclass}if(_newTool.display===null){delete _newTool.display}var toolElement=setupToolElement(_newTool,toolInstance);toolInstance.$element.replaceWith(toolElement);toolInstance.$element=toolElement}};scope.addTool=function(key,_newTool,groupIndex,index){scope.tools[key]=angular.extend(scope.$new(true),taTools[key],defaultChildScope,{name:key});scope.tools[key].$element=setupToolElement(taTools[key],scope.tools[key]);var group;if(groupIndex===undefined)groupIndex=scope.toolbar.length-1;group=angular.element(element.children()[groupIndex]);if(index===undefined){group.append(scope.tools[key].$element);scope.toolbar[groupIndex][scope.toolbar[groupIndex].length-1]=key}else{group.children().eq(index).after(scope.tools[key].$element);scope.toolbar[groupIndex][index]=key}};textAngularManager.registerToolbar(scope);scope.$on("$destroy",function(){textAngularManager.unregisterToolbar(scope.name)})}}}]);textAngular.directive("textAngularVersion",["textAngularManager",function(textAngularManager){var version=textAngularManager.getVersion();return{restrict:"EA",link:function(scope,element,attrs){element.html(version)}}}]);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy