js-pkg
Version:
Npm package of Syncfusion.JavaScript.
11 lines (10 loc) • 47.9 kB
JavaScript
/*!
* filename: ej.spellcheck.min.js
* version : 15.3.0.33
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
(function(n){typeof define=="function"&&define.amd?define(["./../common/ej.core.min","./../common/ej.data.min","./../common/ej.globalize.min","./../common/ej.scroller.min","./../common/ej.draggable.min","./ej.dialog.min","./ej.button.min","./ej.listbox.min","./ej.menu.min"],n):n()})(function(){"use strict";var n=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},t=function(t){function i(){t.apply(this,arguments);this.rootCSS="e-spellcheck";this.validTags=["div","span","textarea"];this.PluginName="ejSpellCheck";this._id="null";this.defaults={locale:"en-US",misspellWordCss:"e-errorword",ignoreSettings:{ignoreAlphaNumericWords:!0,ignoreHtmlTags:!0,ignoreEmailAddress:!0,ignoreMixedCaseWords:!0,ignoreUpperCase:!0,ignoreUrl:!0,ignoreFileNames:!0},dictionarySettings:{dictionaryUrl:"",customDictionaryUrl:""},maxSuggestionCount:6,ajaxDataType:"jsonp",ignoreWords:[],contextMenuSettings:{enable:!0,menuItems:[{id:"IgnoreAll",text:"Ignore All"},{id:"AddToDictionary",text:"Add to Dictionary"}]},isResponsive:!0,enableValidateOnType:!1,controlsToValidate:null,enableAsync:!0,actionSuccess:null,actionBegin:null,actionFailure:null,start:null,complete:null,contextOpen:null,contextClick:null,dialogBeforeOpen:null,dialogOpen:null,dialogClose:null,validating:null,targetUpdating:null};this.dataTypes={locale:"string",misspellWordCss:"string",ignoreSettings:{ignoreAlphaNumericWords:"boolean",ignoreHtmlTags:"boolean",ignoreEmailAddress:"boolean",ignoreMixedCaseWords:"boolean",ignoreUpperCase:"boolean",ignoreUrl:"boolean",ignoreFileNames:"boolean"},dictionarySettings:{dictionaryUrl:"string",customDictionaryUrl:"string",customDictionaryPath:"string"},maxSuggestionCount:"number",ajaxDataType:"string",ignoreWords:"array",contextMenuSettings:{enable:"boolean",menuItems:"array"}};this._tags=[{tag:"ignoreSettings",attr:[]},{tag:"dictionarySettings",attr:[]},{tag:"contextMenuSettings.menuItems",attr:["id","text"]},];this._localizedLabels=null;this._statusFlag=!0;this._words=[];this._inputWords=[];this._controlIds=[];this._control=[];this._targetStatus=!0;this._statusMultiTarget=!1;this._changeAllWords=[];this._subElements=[];this._iframeStatus=!1;this._elementStatus=!0;this._suggestedWordCollection=[];this._ignoreStatus=!0;this._suggestedWords=[];this.model=this.defaults}return n(i,t),i.prototype._init=function(){ej.isNullOrUndefined(this.element)||this._renderSpellCheck()},i.prototype._renderSpellCheck=function(){this._initLocalize();this._renderControls()},i.prototype._initLocalize=function(){this._localizedLabels=this._getLocalizedLabels()},i.prototype._renderControls=function(){var r,t,n,i,u;if(ej.isNullOrUndefined(this.model.controlsToValidate))this._addAttributes(this,this.element);else{for($(this.element).attr("style","display:none"),this._controlIds=this.model.controlsToValidate.split(","),r=!1,t=0;t<this._controlIds.length;t++)if(n=$(this._controlIds[t]),n.length>0)if(r=!0,n.length>1)for(i=0;i<n.length;i++)u=$(n[i]),this._addAttributes(this,u);else this._addAttributes(this,n);this._elementStatus=this._statusFlag=r}this.model.isResponsive&&this._on($(window),"resize",$.proxy(this._resizeSpellCheck,this))},i.prototype._addAttributes=function(n,t){$(t).addClass("e-spellcheck");t[0].spellcheck=!1;n._addEventListeners(n,t)},i.prototype._addEventListeners=function(n,t){n._isIframe(t)?($(t)[0].contentWindow.document.addEventListener("input",function(){n._changeStatus(n)},!1),n.model.contextMenuSettings.enable&&($(t)[0].contentWindow.document.addEventListener("mousedown",function(){n._elementRightClick(n)},!1),$(document)[0].addEventListener("mousedown",function(){n._elementRightClick(n)},!1),$(t)[0].contentWindow.document.addEventListener("keydown",function(t){n._spellValidateOnType(t)},!1))):(t[0].addEventListener("input",function(){n._changeStatus(n)},!1),n.model.contextMenuSettings.enable&&(n._on($(document),"mousedown",$.proxy(n._elementRightClick,n)),n._on($(t[0]),"keydown","",this._spellValidateOnType)))},i.prototype._changeStatus=function(n){n._statusFlag=!0;ej.isNullOrUndefined(n.model.controlsToValidate)||(n._controlIds=n.model.controlsToValidate.split(","),n._targetStatus=!0)},i.prototype._isIframe=function(n){return $(n)[0].tagName==="IFRAME"},i.prototype._resizeSpellCheck=function(){var n=!ej.isNullOrUndefined(this._spellCheckWindow)&&this._spellCheckWindow.parents().find(".e-spellcheck.e-dialog-wrap"),t=!ej.isNullOrUndefined(this._spellCheckWindow)&&n.length>0&&this._spellCheckWindow.data("ejDialog"),i,r,u;this.model.isResponsive?!ej.isNullOrUndefined(this._spellCheckWindow)&&n.length>0&&this._spellCheckWindow.ejDialog("isOpen")&&(t._dialogPosition(),i=this._spellCheckWindow.find(".e-suggesteditems").data("ejListBox"),i.refresh(!0),r=this._spellCheckWindow.find(".e-sentence .e-sentencescroller").data("ejScroller"),setTimeout(function(){n.find(".e-dialog-scroller").width(n.width()-2);n.find(".e-suggestionlist .e-content").width(n.find(".e-suggestionlist .e-content").width()-2);r.refresh()},4)):t._dialogPosition();!ej.isNullOrUndefined(this._alertWindow)&&this._alertWindow.data("ejDialog")&&(u=!ej.isNullOrUndefined(this._alertWindow)&&this._alertWindow.data("ejDialog"),u._dialogPosition())},i.prototype.showInDialog=function(){this._statusFlag?this._renderDialogWindow():this._alertWindowRender("show")},i.prototype.validate=function(){var t,i,n,r,u,f,o,e,s;if(this._statusFlag){if(t=[],this.model.contextMenuSettings.enable&&!ej.isNullOrUndefined(this.model.dictionarySettings.dictionaryUrl)){if(n="",this._controlIds.length>0&&!this._currentActiveElement&&this.model.enableValidateOnType||this._controlIds.length>0&&(!this.model.enableValidateOnType||!this._statusMultiTarget)){for(r=0;r<this._controlIds.length;r++)if(u=$(this._controlIds[r]),u.length>0)for(f=0;f<u.length;f++)o=$(u[f]),e="",e=this._elementTextProcess(this,o),n=n===""?n.concat(e):n.concat(" "+e)}else this.model.enableValidateOnType&&this._currentActiveElement?n=this._elementTextProcess(this,$(this._currentActiveElement)):(this._isIframe(this.element)&&$(this.element).contents().find("body").addClass("e-spellcheck"),n=this._elementTextProcess(this,this.element));if(t=this._filteringDiffWords(this,n),this._splitWords(n,this),i={targetSentence:n,requestType:"validate",additionalParams:null},this._trigger("actionBegin",i))return!1;t.length>0?this._ajaxRequest(this,t.join(" "),"validateOnType",i):t.length!==0||this._ignoreStatus?ej.isNullOrUndefined(this._errorWordDetails)?this.model.enableValidateOnType||this._alertWindowRender("show"):(s=this._filterErrorData(this,this._errorWordDetails),this._validateOnTypeOperations(this,s,n,"validateOnType")):(this._splitInputWords(n,this),t=ej.dataUtil.distinct(this._inputWords),this._ajaxRequest(this,t.join(" "),"validateOnType",i))}}else this._alertWindowRender("show")},i.prototype._filteringDiffWords=function(n,t){var f=n._inputWords,r=[],i,e,u;for(n._splitInputWords(t,n),i=n._inputWords,u=0;u<i.length;u++)e=f.indexOf(i[u]),e===-1&&r.push(i[u]);return i.length!==f.length&&r.length!==0&&i.length===r.length&&(r=i),r},i.prototype._elementTextProcess=function(n,t){return this.model.contextMenuSettings.enable&&this.model.enableValidateOnType&&(this._controlIds.length>0?t[0].nodeType==9&&t[0].nodeName=="#document"&&(t=$(this._controlIds[0])):t=$(this.element[0])),n._isIframe(t)?$(t).contents().find("body").text():ej.isNullOrUndefined($(t)[0].value)?($(t)[0].innerText||$(t)[0].textContent).trim():$(t)[0].value.trim()},i.prototype._splitWords=function(n,t){var i=n.split(/[^0-9a-zA-Z\'_]/);i=i.filter(function(n){return/\S/.test(n)});t._words=i},i.prototype._splitInputWords=function(n,t){var i=n.split(" ");t._inputWords=i},i.prototype.spellCheck=function(n,t){var i={targetSentence:n,misspelledWordCss:t,requestType:"spellCheck"};if(this._trigger("actionBegin",i))return!1;this._misspelledWordCss=t;this._ajaxRequest(this,n,"spellCheck",i)},i.prototype.ignoreAll=function(n,t){var i;return ej.isNullOrUndefined(n)||n===""||ej.isNullOrUndefined(t)||t===""?!1:(i={ignoreWord:n,targetContent:t,requestType:"ignoreAll"},this._trigger("validating",i))?!1:(this.model.ignoreWords.push(n),this._updateErrorContent(n,t,null,"ignoreAll",null))},i.prototype.ignore=function(n,t,i){var r;return ej.isNullOrUndefined(n)||n===""||ej.isNullOrUndefined(t)||t===""?!1:(r={ignoreWord:n,targetContent:t,requestType:"ignore"},this._trigger("validating",r))?!1:this._updateErrorContent(n,t,null,"ignore",i)},i.prototype.change=function(n,t,i,r){var u;return ej.isNullOrUndefined(n)||n===""||ej.isNullOrUndefined(t)||t===""||ej.isNullOrUndefined(i)||i===""?!1:(u={changableWord:n,targetContent:t,changeWord:i,requestType:"changeWord"},this._trigger("validating",u))?!1:this._updateErrorContent(n,t,i,"changeWord",r)},i.prototype.changeAll=function(n,t,i){var u,r;return ej.isNullOrUndefined(n)||n===""||ej.isNullOrUndefined(t)||t===""||ej.isNullOrUndefined(i)||i===""?!1:(u={changableWord:n,targetContent:t,changeWord:i,requestType:"changeAll"},this._trigger("validating",u))?!1:(r={},r.ErrorWord=n,r.ReplaceWord=i,this._changeAllWords.push(r),this._updateErrorContent(n,t,i,"changeAll",null))},i.prototype.addToDictionary=function(n){if(ej.isNullOrUndefined(n)||n==="")return!1;var t={customWord:n,requestType:"addToDictionary",additionalParams:null};if(this._trigger("validating",t))return!1;this._customWord=n;this._ajaxRequest(this,null,"addToDictionary",t)},i.prototype._updateErrorContent=function(n,t,i,r,u){var s,f,o,h,e,c;if(t.indexOf(n)!==-1){if(f='<span class="errorspan '+this.model.misspellWordCss+'">'+n+"<\/span>",o=r==="ignoreAll"||r==="addToDictionary"||r==="ignore"?n:i,r==="ignoreAll"||r==="addToDictionary"||r==="changeAll")t=t.replace(new RegExp(f,"g"),o);else if(r==="ignore"||r==="changeWord")if(ej.isNullOrUndefined(u))t=t.replace(f,o);else{for(h=[],e=t.indexOf(f);e!==-1;)h.push(e),e=t.indexOf(f,++e);c=h[u];t=t.substr(0,c)+o+t.substr(c+f.length)}s={resultHTML:t}}else s=!1;return s},i.prototype._renderDialogWindow=function(){this._dialogWindowRendering();this._showDialog()},i.prototype._dialogWindowRendering=function(){var n=this,u,t;this._spellCheckWindow=ej.buildTag("div.e-spellcheckdialog#"+this._id+"ErrorCorrectionWindow");var f=ej.buildTag("div.e-dialogdiv"),e=ej.buildTag("div.e-row e-labelrow").append(ej.buildTag("div.e-labelcell").append(ej.buildTag("label.e-dictionarylabel",this._localizedLabels.NotInDictionary))),i=ej.buildTag("div.e-row e-sentencerow"),o=ej.buildTag("div.e-cell e-sentencecell").append(ej.buildTag("div.e-sentence","",{},{id:this._id+"_Sentences",name:"sentences",contenteditable:"false"}));i.append(o);var s=ej.buildTag("div.e-buttoncell"),h=ej.buildTag("button.e-btnignoreonce",this._localizedLabels.IgnoreOnceButtonText,{},{id:this._id+"_IgnoreOnce"}).attr("type","button"),c=ej.buildTag("button.e-btnignoreall",this._localizedLabels.IgnoreAllButtonText,{},{id:this._id+"_IgnoreAll"}).attr("type","button"),l=ej.buildTag("button.e-btnaddtodictionary",this._localizedLabels.AddToDictionary,{},{id:this._id+"_AddToDictionary"}).attr("type","button");i.append(s.append(h).append(c).append(l));var a=ej.buildTag("div.e-row e-labelrow").append(ej.buildTag("div.e-labelcell").append(ej.buildTag("label.e-lablesuggestions",this._localizedLabels.SuggestionLabel))),r=ej.buildTag("div.e-row e-suggestionsrow"),v=ej.buildTag("div.e-cell e-suggestioncell").append(ej.buildTag("ul.e-suggesteditems","",{},{id:this._id+"_Suggestions"}));r.append(v);var y=ej.buildTag("div.e-buttoncell"),p=ej.buildTag("button.e-btnchange",this._localizedLabels.ChangeButtonText,{},{id:this._id+"_Change"}).attr("type","button"),w=ej.buildTag("button.e-btnchangeall",this._localizedLabels.ChangeAllButtonText,{},{id:this._id+"_ChangeAll"}).attr("type","button"),b=ej.buildTag("button.e-btnclose",this._localizedLabels.CloseButtonText,{},{id:this._id+"_Close"}).attr("type","button");for(r.append(y.append(p).append(w).append(b)),f.append(e).append(i).append(a).append(r),this._spellCheckWindow.append(f),this._spellCheckWindow.ejDialog({width:462,minHeight:305,enableModal:!0,enableResize:!1,showOnInit:!1,allowKeyboardNavigation:!1,target:$("body"),title:this._localizedLabels.SpellCheckButtonText,close:function(){n._close()},cssClass:"e-spellcheck",isResponsive:this.model.isResponsive}),u=[".e-btnignoreonce",".e-btnignoreall",".e-btnaddtodictionary",".e-btnchange",".e-btnchangeall",".e-btnclose"],t=0;t<u.length;t++)this._spellCheckWindow.find(u[t]).ejButton({width:this.model.isResponsive?"100%":140,click:function(t){t.model.text===n._localizedLabels.CloseButtonText?n._close():n._changeErrorWord(t)},cssClass:"e-spellbuttons"});this._spellCheckWindow.find(".e-sentence").append(ej.buildTag("div.e-sentencescroller").append(ej.buildTag("div").append(ej.buildTag("div.e-sentencecontent","",{},{id:this._id+"_SentenceContent"}))));this._spellCheckWindow.find(".e-sentence .e-sentencescroller").ejScroller({height:"100%",scrollerSize:20});this._spellCheckWindow.find(".e-suggesteditems").ejListBox({width:"100%",height:"100%",dataSource:null,selectedIndex:0,cssClass:"e-suggestionlist"})},i.prototype._alertWindowRender=function(n){this._renderAlertWindow(n);this._elementStatus||this._alertWindow.find(".e-alerttext").html(this._localizedLabels.NotValidElement);var t={spellCheckDialog:this._renderAlertWindow,requestType:"alertBeforeOpen"};if(this._trigger("dialogBeforeOpen",t))return!ej.isNullOrUndefined(this._spellCheckWindow)&&this._spellCheckWindow.parents().find(".e-spellcheck.e-dialog-wrap").length>0&&this._close(),!1;this._alertWindow.ejDialog("open")},i.prototype._renderAlertWindow=function(n){var t=this;this._alertWindow=ej.buildTag("div.e-alertdialog#"+this._id+"alertWindow");this._elementStatus||this._alertWindow.addClass("e-missingalert");var r=ej.buildTag("div.e-alertbtn","",{"text-align":"center"}).append(ej.buildTag("button.e-alertbutton e-alertspellok",this._localizedLabels.Ok,{},{id:this._id+"alertok"}).attr("type","button")),i=ej.buildTag("div.e-alerttextdiv"),u=ej.buildTag("div.e-alertnotifydiv").append(ej.buildTag("div.e-alertnotification e-icon e-notification")),f=ej.buildTag("div.e-alerttext",this._localizedLabels.CompletionPopupMessage,{"text-align":"left",padding:"5px"});i.append(u).append(f);this._alertWindow.append(i).append(r);this.element.append(this._alertWindow);this._alertWindow.find(".e-alertbutton").ejButton({showRoundedCorner:!0,width:this._elementStatus?"70px":"100px",click:function(){t._alertClose()},cssClass:"e-flat"});this._alertWindow.ejDialog({width:this._elementStatus?240:420,minHeight:140,showOnInit:!1,enableModal:!0,title:this._localizedLabels.CompletionPopupTitle,enableResize:!1,allowKeyboardNavigation:!1,target:n==="validating"?".e-spellcheckdialog":$("body"),cssClass:this._elementStatus?"e-spellalert":"e-spellalert e-elementmissing",close:function(){t._alertClose()},isResponsive:this.model.isResponsive})},i.prototype._renderContextMenu=function(){var n=this,r,i,t,u;if(this._contextMenu=ej.buildTag("ul#"+n._id+"contextMenu"),ej.isNullOrUndefined(n.model.controlsToValidate))r=n._isIframe(this.element)?n.element.contents()[0]:"."+n.model.misspellWordCss;else{for(i=!1,t=0;t<n._controlIds.length;t++)u=n._isIframe($(n._controlIds[t])),u&&(i=!0);r=i?$(n._controlIds[0]).contents()[0]:"."+n.model.misspellWordCss}this._contextMenu.ejMenu({fields:{id:"id",text:"text",parentId:"parentId"},menuType:ej.MenuType.ContextMenu,openOnClick:!1,width:"auto",cssClass:"e-spellmenu",click:function(t){n._onMenuSelect(t)}})},i.prototype._contextMenuPosition=function(n,t){var r,i,f,u,e,o;return!ej.isNullOrUndefined(t._activeElement)&&t._isIframe($(t.element))?(f=ej.isNullOrUndefined(t.model.controlsToValidate)?$(t.element):$(t._control[0].controlId),r=(n.clientX==undefined?0:n.clientX)+f.offset().left,i=(n.clientY==undefined?0:n.clientY)+f.offset().top,u=$(t._contextMenu).attr("style","visibility: visible;display:block;").height(),e=$(t._contextMenu).width(),i=i+u<$(document).scrollTop()+$(window).height()?i:i-u<0?i:i-u,r=r+e<$(document).scrollLeft()+$(window).width()?r:r-e):(r=n.clientX+t._contextMenu.width()<$(window).width()?n.pageX:n.pageX-t._contextMenu.width(),i=n.clientY+t._contextMenu.height()<$(window).height()?n.pageY:n.clientY>t._contextMenu.height()?n.pageY-t._contextMenu.height():$(window).height()-t._contextMenu.outerHeight(),o=$("body").css("position")!=="static"?$("body").offset():{left:0,top:0},r-=o.left,i-=o.top),{X:r,Y:i}},i.prototype._showDialog=function(){var a={spellCheckDialog:this._spellCheckWindow,requestType:"dialogBeforeOpen"},t,n,u,f,e,r,o,i,h,c,s,l;if(this._trigger("dialogBeforeOpen",a))return!1;if(this._spellCheckWindow.ejDialog("open"),t="",this._subElements=[],this._controlIds.length>0){for(u=0;u<this._controlIds.length;u++)if(f=$(this._controlIds[u]),f.length>0)for(e=0;e<f.length;e++)r=$(f[e]),this._activeElement=this._isIframe(r)?$(r).contents().find("body")[0]:$(r)[0],this._removeSpan(this),this._subElements.push(r[0]);t=this._inputTextProcess(this,$(this._subElements[0]),t);this._proElements=this._subElements.length>0&&$(this._subElements[0]);this._currentTargetElement=n=$(this._subElements[0]);this._subElements=this._subElements.slice(1)}else n=this.element,this._activeElement=this._isIframe(n)?this._getIframeElement(n):$(n)[0],this._removeSpan(this),t=this._inputTextProcess(this,n,t);if(o="",this.element=ej.isNullOrUndefined(this.model.controlsToValidate)?this.element:n,this.element.length>0&&(o=this._isIframe(this.element)?$(this.element).contents().find("body").html():$(n)[0].tagName==="TEXTAREA"||$(n)[0].tagName==="INPUT"?$(n)[0].value:$(n)[0].innerHTML),i=this._filteringDiffWords(this,t),this._splitWords(t,this),!ej.isNullOrUndefined(this.model.controlsToValidate)&&(h={previousElement:null,currentElement:n,targetHtml:o},this._trigger("targetUpdating",h)))return this._close(),!1;if((this._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML=o,c={targetText:t,requestType:"dialogOpen"},this._trigger("dialogOpen",c))||(s={targetSentence:t,requestType:"spellCheck",additionalParams:null},this._trigger("actionBegin",s)))return!1;i.length>0?this._ajaxRequest(this,i.join(" "),"spellCheckDialog",s):i.length!==0||this._ignoreStatus?ej.isNullOrUndefined(this._errorWordDetails)?this._alertWindowRender("show"):(l=this._filterErrorData(this,this._errorWordDetails),this._dialogModeOperations(this,l,t,"spellCheckDialog")):(this._splitInputWords(t,this),i=ej.dataUtil.distinct(this._inputWords),this._ajaxRequest(this,i.join(" "),"spellCheckDialog",s))},i.prototype._getIframeElement=function(n){return $(n).contents().find("body")[0]},i.prototype._inputTextProcess=function(n,t,i){var r,u;return n._isIframe(t)?(r=$(t).contents().find("body").text(),i=i===""?r:i+r):(u=ej.isNullOrUndefined($(t)[0].value)?($(t)[0].innerText||$(t)[0].textContent).trim():$(t)[0].value.trim(),i=i===""?u:i+" "+u),i},i.prototype._ajaxRequest=function(n,t,i,r){var u=i==="addToDictionary"?JSON.stringify({customWord:n._customWord,additionalParams:r.additionalParams}):this._getModelValues(this,t,r);$.ajax({async:this.model.enableAsync,url:i==="addToDictionary"?this.model.dictionarySettings.customDictionaryUrl:this.model.dictionarySettings.dictionaryUrl,data:{data:u},contentType:"application/json; charset=utf-8",dataType:this.model.ajaxDataType,crossDomain:!0,success:function(r){var u,h,w,e,o,f,b,s,k,tt,d,y,c,g,p,a,v,l,nt;if(h=typeof r=="string"&&i!=="addToDictionary"?JSON.parse(r):r,i==="addToDictionary"?ej.isNullOrUndefined(n._errorWordDetails)||ej.isNullOrUndefined(n._currentElement)?u=[]:(u=n._errorWordDetails,ej.isNullOrUndefined(h)||(n._filterData(h.toString(),n),n._errorWordDetails=n._errorWordsData)):u=n._updateErrorDetails(n,h),e=t,u.length>0){if(i==="spellCheckDialog"||i==="validateOnType"||i==="validateOnRender")f=n._filterErrorData(n,u),f.length>0?i==="spellCheckDialog"?n._dialogModeOperations(n,f,e,i):(i==="validateOnType"||i==="validateOnRender")&&n._validateOnTypeOperations(n,f,e,i):(i==="spellCheckDialog"&&n._spellCheckWindow.ejDialog("isOpen")&&n._spellCheckWindow.ejDialog("close"),n._alertWindowRender("validating"));else if(i==="spellCheck"){if(u.length>0){for(b=n._getFilterData(u,n),f=ej.dataUtil.distinct(b),s=0;s<f.length;s++)k=(new ej.Query).where("ErrorWord",ej.FilterOperators.equal,f[s]),tt=new ej.DataManager(u).executeLocal(k),f.length>0&&(w='<span class="errorspan '+(!ej.isNullOrUndefined(n._misspelledWordCss)&&n._misspelledWordCss!==""?n._misspelledWordCss:n.model.misspellWordCss)+'">'+f[s]+"<\/span>",d=new RegExp(f[s],"gi"),e=e.replace(d,w));o={resultHTML:e,errorWordDetails:u,requestType:"spellCheck"};n._misspelledWordCss=null}else o={resultHTML:e,errorWordDetails:u,requestType:"spellCheck"};n._trigger("actionSuccess",o)}else if(i==="addToDictionary"&&(ej.isNullOrUndefined(n._currentElement)||(y=$(n._currentElement)[0].tagName==="IFRAME"?$(n._currentElement).contents().find("body").html():$(n._currentElement).html().trim()),c=n._updateErrorContent(n._customWord,y,null,"addToDictionary",null),!ej.isNullOrUndefined(y))){if(!ej.isNullOrUndefined(n._spellCheckWindow)&&n._spellCheckWindow.find(".e-btnaddtodictionary").hasClass("e-select"))g=n._spellCheckWindow.find(".e-suggesteditems"),p=n._spellCheckWindow.find(".e-sentence .e-sentencecontent"),n._errorWordsData.length>0?(p[0].innerHTML=c.resultHTML,n._replaceErrorText(p,n._customWord.toString()),n._listBoxDataUpdate(n)):(g.ejListBox({dataSource:null}),n._statusFlag=!1,n._alertWindowRender("validating"));else if(!ej.isNullOrUndefined(n._contextMenu)){if(n._isIframe(n.element)?$(n.element).contents().find("body").html(c.resultHTML):$(n._currentElement)[0].innerHTML=c.resultHTML,n._controlIds.length>0)for(a=0;a<n._controlIds.length;a++)for(v=$(n._controlIds[a]),l=0;l<v.length;l++)$(n._currentElement)[0]!==$(v[l])[0]&&(nt=$(v[l]),n._replaceErrorText(nt,n._customWord.toString()));n._renderMenu(n)}o={resultHTML:c.resultHTML,errorWordDetails:h,requestType:"addToDictionary"};n._trigger("actionSuccess",o)}}else n._subElements.length>0?n._updateTargetText(n):(i==="spellCheckDialog"&&n._spellCheckWindow.ejDialog("isOpen")&&n._spellCheckWindow.ejDialog("close"),i==="spellCheck"&&(o={resultHTML:t,errorWordDetails:u,requestType:"spellCheck"},n._trigger("actionSuccess",o)),i==="validateOnType"&&n._removeSpan(n),i!=="spellCheck"&&i!=="addToDictionary"&&n._alertWindowRender("load"))},error:function(t,r,u){var f={errorMessage:u,requestType:i};n._trigger("actionFailure",f)}})},i.prototype.getSuggestionWords=function(n){this._selectedValue=n;this._suggestionsRequest(this,null,n,"getSuggestions")},i.prototype._suggestionsRequest=function(n,t,i,r){var u;u=r==="validateByMenu"||r==="suggestionsUpdate"||r==="getSuggestions"?JSON.stringify({requestType:"getSuggestions",errorWord:i}):n._getModelValues(n,i,null);$.ajax({async:n.model.enableAsync,url:n.model.dictionarySettings.dictionaryUrl,data:{data:u},contentType:"application/json; charset=utf-8",dataType:n.model.ajaxDataType,crossDomain:!0,success:function(u){var e={},f,s,o,h,c;f=typeof u=="string"?JSON.parse(u):u;e.ErrorWord=i;e.SuggestedWords=f[i];n._suggestedWordCollection.push(e);r==="getSuggestions"?n._suggestedWords=f[n._selectedValue]:r==="validateByMenu"?(s=f[i],n._contextMenuDisplay(n,s)):r==="validateByDialog"?(o=n._updateErrorDetails(n,f),o.length>0?(h=n._filterErrorData(n,o),n._splitWords(t[0].innerText,n),n._processNode(n,t[0],h,"spellCheckDialog"),n._activeElement=t[0],n._changeAllErrors(n),n._listBoxDataUpdate(n)):n._subElements.length>0?n._updateTargetText(n):n._completionCheck(n)):r==="suggestionsUpdate"&&(c=f[t[0].innerText],n._dialogSuggestionsUpdate(n,c))}})},i.prototype._filterErrorData=function(n,t){var i=n._getFilterData(t,n);return ej.dataUtil.distinct(i)},i.prototype._updateErrorDetails=function(n,t){var i=[],r;if(ej.isNullOrUndefined(n._errorWordDetails))i=n._errorWordDetails=t;else if(t.length>0)if(n._ignoreStatus)for(r=0;r<t.length;r++)n._errorWordDetails.push(t[r]),i=n._errorWordDetails;else i=n._errorWordDetails=t,n._ignoreStatus=!0;else i=n._errorWordDetails;return i},i.prototype._contextMenuDisplay=function(n,t){var i,e,r,h,l,a,o,u,s,f,c;if(ej.isNullOrUndefined(n._contextMenu)&&n._renderContextMenu(),i=n._contextMenu.data("ejMenu"),e=n.model.contextMenuSettings.menuItems,t.length>0){for(r=[],h=n.model.maxSuggestionCount<t.length?n.model.maxSuggestionCount:t.length,r=n._convertData(t.slice(0,h),"menuData"),l=r.length,a=r[h-1].id,o=0;o<e.length;o++)r.push(e[o]);for(i.option("fields.dataSource",r),u=i.element.find(".e-list"),s=0;s<l;s++)$(u[s]).addClass("e-errorsuggestions");for(f=0;f<u.length;f++)u[f].attributes.id.value===a&&$(u[f]).addClass("e-separator")}else i.option("fields.dataSource",e);c=n._contextMenuPosition(n._menuEvents,n);$(i.element).css({left:c.X,top:c.Y});$(i.element).css("display","block")},i.prototype._dialogSuggestionsUpdate=function(n,t){var u=n._spellCheckWindow.find(".e-suggesteditems"),f=$("#"+n._id+"_Suggestions").data("ejListBox"),i,e,r;t.length>0?(n._spellCheckWindow.find(".e-btnchange").hasClass("e-disable")&&n._spellCheckWindow.find(".e-btnchangeall").hasClass("e-disable")&&(n._spellCheckWindow.find(".e-btnchange").removeClass("e-disable"),n._spellCheckWindow.find(".e-btnchangeall").removeClass("e-disable")),e=n.model.maxSuggestionCount<t.length?n.model.maxSuggestionCount:t.length,i=t.slice(0,e)):(n._spellCheckWindow.find(".e-btnchange").addClass("e-disable"),n._spellCheckWindow.find(".e-btnchangeall").addClass("e-disable"),i=[n._localizedLabels.NoSuggestionMessage]);u.ejListBox({selectedIndex:null});u.ejListBox({dataSource:n._convertData(i,"dictionaryData"),selectedIndex:0});ej.isNullOrUndefined(f)||f.refresh();r=n._spellCheckWindow.find(".e-sentence .e-sentencescroller").data("ejScroller");!ej.isNullOrUndefined(r)&&r.isVScroll()&&$(n._spellCheckWindow.find("."+n.model.misspellWordCss)).get(0).scrollIntoView(!1)},i.prototype._replaceErrorText=function(n,t){for(var u,r=$(n).find(".errorspan"),i=0;i<r.length;i++)u=r[i].innerText||r[i].textContent,u===t&&$(r[i]).replaceWith(u)},i.prototype._dialogModeOperations=function(n,t,i,r){var o={errorWords:n._errorWordDetails,targetText:i,requestType:r},u=n._spellCheckWindow.find(".e-sentence .e-sentencecontent"),f,e;if(t.length>0){if(n._removeSpan(n),n._processNode(n,u[0],t,r),this._trigger("start",o))return!1;f=n._spellCheckWindow.find(".e-sentence .e-sentencescroller").data("ejScroller");f.refresh();n._listBoxDataUpdate(n)}else e=n._spellCheckWindow.find(".e-suggesteditems"),r==="spellCheckDialog"&&(u[0].innerHTML=i),e.ejListBox({dataSource:null}),n._statusFlag=!1,this._alertWindowRender("load")},i.prototype._validateOnTypeOperations=function(n,t,i,r){var e,f,o,s,h,c,u;if(t.length>0){if(this._controlIds.length>0&&!this._currentActiveElement&&this.model.enableValidateOnType||this._controlIds.length>0&&(!this.model.enableValidateOnType||!this._statusMultiTarget))for(u=0;u<n._controlIds.length;u++)for(e=$(this._controlIds[u]),f=0;f<e.length;f++)o=n._isIframe($(e[f]))?n._getIframeElement($(e[f])):$(e[f])[0],n._activeElement=o,n._removeSpan(n),n._processNode(n,o,t,r),s={},s.controlId=n._controlIds[u],s.errorHtml=o.innerHTML,n._control.push(s);else this.model.enableValidateOnType&&this._currentActiveElement?(n._removeSpan(n),n._processNode(n,this._currentActiveElement,t,r),this._statusMultiTarget=!1):n._isIframe(n.element)?(h=n._getIframeElement(n.element),n._activeElement=h,n._removeSpan(n),n._processNode(n,h,t,r)):(n._removeSpan(n),n._processNode(n,$(n.element)[0],t,r));if(n._statusFlag=!0,c=this._controlIds.length>0?{errorWords:n._errorWordDetails,targetControls:this._control,requestType:r}:{errorWords:n._errorWordDetails,targetText:$(n.element)[0].innerText,requestType:r},this._trigger("start",c))return!1;if(n._isIframe(this.element))n._bindBeforeOpen(n,$(this.element).contents().find("body"));else if(n._controlIds.length>0)for(u=0;u<n._controlIds.length;u++)n._bindBeforeOpen(n,$(n._controlIds[u]));else n._bindBeforeOpen(n,$(this.element))}else n._removeSpan(n),n._statusFlag=!1,n._alertWindowRender("show");this.model.enableValidateOnType&&n.setCursorPosition(n._currentCursorTarget)},i.prototype._bindBeforeOpen=function(n,t){n._on($(t).find("."+this.model.misspellWordCss),"contextmenu",$.proxy(n._contextOpen,n))},i.prototype._contextOpen=function(n){var r=$(n.target),t,i,f,u;if(r.hasClass("errorspan")){if(n.preventDefault(),t=this,i=t._selectedValue=r[0].innerText,t._selectedTarget=r[0],t._menuEvents=n,f={selectedErrorWord:i,requestType:"contextOpen"},t._trigger("contextOpen",f))return!1;u=t._filterSuggestions(t,i);u.length>0?t._contextMenuDisplay(t,u[0].SuggestedWords):t._suggestionsRequest(t,null,i,"validateByMenu")}else this._elementRightClick(n)},i.prototype._processNode=function(n,t,i,r){for(var b,k,c,u,p,s=n._filterTextNodes(n,t),e=0;e<s.length;e++){var o=s[e],w=[s[e]],h=s[e].data,l=!1,a=!1,v=!1;if(n.model.ignoreSettings.ignoreUrl&&(b=/^((http|ftp|https)?:\/\/)?(www\.)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/,l=b.test(o.wholeText),l&&(v=l)),n.model.ignoreSettings.ignoreEmailAddress&&(k=/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,a=k.test(o.wholeText),a&&(v=a)),!v)for(c=0;c<n._words.length;c++)for(u=0;u<i.length;u++)if(n._words[c]===i[u]&&!ej.isNullOrUndefined(h.match(new RegExp("\\b"+i[u]+"\\b","gi")))&&h.indexOf(i[u])!==-1){var d=h.indexOf(i[u]),g=i[u].length,f=o.splitText(d),y=document.createElement("span");y.className=r==="validateOnType"?"errorspan "+this.model.misspellWordCss:"errorspan";p=document.createTextNode(i[u]);y.appendChild(p);o.parentNode.insertBefore(y,f);f.data=f.data.substr(g);o=f;w.push(p);w.push(f);h=f.data}}},i.prototype._findRepeatWords=function(n,t,i,r){for(var o,f,s,e,h=/([{^}:[\\.,;><?|@!~`#$%&*()_=+'"])/g,u=n;u<=t.length;u++)if(e=!1,f=t.charAt(u),s=f.charCodeAt(f),e=h.test(f),f==" "||s==160||f==""||e)if(o=t.slice(n,u),o===i[r])break;else n=u+1;return n},i.prototype._spellValidateOnType=function(n){var i,t;if(this.model.enableValidateOnType&&this.model.contextMenuSettings.enable&&(i={events:n,requestType:"validate"},this._trigger("validating",i),this._statusMultiTarget=!1,this._currentActiveElement=i.events.currentTarget,i.events.cancelable===!0)){if(t=n.keyCode,t>=16&&t<=31)return;if(t>=37&&t<=40)return;(t===32||t===13)&&(this._statusMultiTarget=!0,this._triggerSpelling())}},i.prototype._triggerSpelling=function(){var n=this;setTimeout(function(){n.getCursorPosition();n.validate()},2)},i.prototype.getCursorPosition=function(){var n,u,i,t,f,e,r,o,s,h,c;if(this.model.enableValidateOnType&&this.model.contextMenuSettings.enable){if(n=this,u=String.fromCharCode(7),this._controlIds.length>0)for(f=0;f<this._controlIds.length;f++)e=$(this._controlIds[f]),this._isIframe(e)?(i=e[0].contentWindow.getSelection(),t=e[0].contentDocument.createRange()):(i=document.getSelection(),t=document.createRange());else this._isIframe(this.element)?(i=this.element[0].contentWindow.getSelection(),t=this.element[0].contentDocument.createRange()):(i=document.getSelection(),t=document.createRange());if(r=i.getRangeAt(0),r.deleteContents(),this._isIframe(this.element)&&ej.browserInfo().name==="msie"){for(o=this.element[0].contentDocument.createElement("div"),o.innerHTML=u,s=$(this.element[0]).contents()[0].createDocumentFragment();h=o.firstChild;)c=s.appendChild(h);r.insertNode(s)}else r.insertNode(document.createTextNode(u));return $(r.startContainer.parentElement).hasClass("errorspan")&&(this.model.controlsToValidate?n._normalizeTextNodes(this._currentActiveElement):n._normalizeTextNodes($(n.element)[0])),n._currentCursorTarget=n._getActiveTarget(n,u),t.collapse(!0),t.setStart(n._currentCursorTarget.node,n._currentCursorTarget.offset),t.setEnd(n._currentCursorTarget.node,n._currentCursorTarget.offset),i.removeAllRanges(),i.addRange(t),n._currentCursorTarget}},i.prototype._getActiveTarget=function(n,t){var r,u,f,i;for(r=this.model.enableValidateOnType?n._filterTextNodes(n,this._currentActiveElement):n._filterTextNodes(n,$(n.element)[0]),u=null,f=null,i=0;i<r.length;i++)if(r[i].data.indexOf(t)>-1)return f=r[i],u=r[i].data.indexOf(t),r[i].data=r[i].data.replace(t,""),{node:f,offset:u}},i.prototype.setCursorPosition=function(n){var o,s,a,i,b,e,c,r,u,v,f,p,t,w;if(this._controlIds.length>0)for(t=0;t<this._controlIds.length;t++)a=$(this._controlIds[t]),this._isIframe(a)?(o=a[0].contentDocument.getSelection(),s=a[0].contentDocument.createRange()):(o=document.getSelection(),s=document.createRange());else this._isIframe(this.element)?(o=this.element[0].contentDocument.getSelection(),s=this.element[0].contentDocument.createRange()):(o=document.getSelection(),s=document.createRange());if(o.getRangeAt&&o.rangeCount&&(b=String.fromCharCode(7),n)){for(i=this.model.controlsToValidate?this._filterTextNodes(this,this._currentActiveElement):this._filterTextNodes(this,$(this.element)[0]),e=n.node,c=n.offset,t=0;t<i.length;t++)i[t]===e&&(r=t);if(u="",r===undefined){var l="",h="",y="",u="",k="",d=!1,g=!1;for(v=0;v<e.length;v++)f=e.data.charAt(v),f.charCodeAt(0)!=160?f.charCodeAt(0)!=32?l===""?u=u+f:f!=b&&(h=h+f):(l=u+f,h=f):(l=u+f,y=" "+y+f);for(u=u+h,k=l.trim(),t=0;t<i.length;t++){if(i[t].data===u&&(r=t),i[t].data===l&&(r=t),i[t].data===h&&h!=""&&(r=t,d=!0),i[t].data===u&&u!=""){r=t;g=!0;break}if(i[t].data===k&&(r=t),i[t].data===u&&i[t+1]!==undefined&&i[t+1].data.charCodeAt(0)===160){r=t;break}if(i[t].data===u&&i[t+1]!==undefined&&i[t+1].data.charCodeAt(1)===160&&y.length>=1){r=t;break}if((i[t].data===l||i[t].data===u)&&i[t+1]==undefined){p=document.createTextNode("");i.push(p);this._currentActiveElement.appendChild(p);r=t+1;c=i[r].data.length;e=i[r];break}}}for(t=r;t<i.length-1;t++){if(c<=i[t].data.length){e=i[t];break}if(d===!1||h===undefined||h==="")c-=i[t].data.length,e=i[t+1];else{c=1;e=i[t];break}}w=e;s.collapse(!0);s.setStart(w,c);s.setEnd(w,c);o.removeAllRanges();o.addRange(s)}},i.prototype._normalizeTextNodes=function(n){n.normalize();return},i.prototype._filterTextNodes=function(n,t){function r(n){for(var t,u=0;u<n.childNodes.length;u++)t=n.childNodes[u],t.nodeType===3?i.push(t):t.childNodes&&r(t)}var i=[];return r(t),i},i.prototype._removeSpan=function(n){var r,i,t,u;for(n.model.enableValidateOnType&&n._statusMultiTarget?n._currentActiveElement&&(r=n._currentActiveElement):r=!ej.isNullOrUndefined(n.model.controlsToValidate)||n._isIframe(n.element)?n._activeElement:n.element[0],i=$(r).find("span.errorspan"),t=0;t<i.length;t++)u=i[t].innerText||i[t].textContent,$(i[t]).replaceWith(u)},i.prototype._getFilterData=function(n,t){var u=[],i,r;for(t._errorWordsData=t._errorWordDetails=n,i=0;i<t.model.ignoreWords.length;i++)t._filterData(t.model.ignoreWords[i],t);for(r=0;r<t._errorWordsData.length;r++)u.push(t._errorWordsData[r].ErrorWord);return u},i.prototype._filterData=function(n,t){var i=(new ej.Query).where("ErrorWord",ej.FilterOperators.notEqual,n);t._errorWordsData=new ej.DataManager(t._errorWordsData).executeLocal(i)},i.prototype._formHtml=function(n,t){for(var r,u,i=0;i<n.length;i++)r='<span class="errorspan">'+n[i]+"<\/span>",u=new RegExp("\\b"+n[i]+"\\b","gi"),t=t.replace(u,r);return t},i.prototype._listBoxDataUpdate=function(n){var t=n._spellCheckWindow.find(".e-sentence .e-sentencecontent").find(".errorspan"),i,r;$(t[0]).addClass(this.model.misspellWordCss);t.length>0?(i=n._filterSuggestions(n,t[0].innerText),i.length>0?n._dialogSuggestionsUpdate(n,i[0].SuggestedWords):n._suggestionsRequest(n,t,t[0].innerText,"suggestionsUpdate")):!ej.isNullOrUndefined(this.model.controlsToValidate)&&n._targetStatus?n._updateTargetText(n):(r=n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML,n._validationComplete(n,r))},i.prototype._filterSuggestions=function(n,t){var i=[],r,u;return n._suggestedWordCollection.length>0&&(r=(new ej.Query).where("ErrorWord",ej.FilterOperators.equal,t),u=new ej.DataManager(n._suggestedWordCollection).executeLocal(r),i=u),i},i.prototype._validationComplete=function(n,t){n._updateTargetString(n);var i=ej.isNullOrUndefined(n._activeElement)?n.element:n._activeElement,r={targetElement:i,targetText:t,requestType:"changeErrorWord"};if(this._trigger("complete",r))return!1;n._statusFlag=!1;n._alertWindowRender("validating")},i.prototype._onMenuSelect=function(n){var o=n.events.ID.split("_"),f=!1,c,t,r,l,a,s,h,i,e,u,v,y,p,w;if(ej.isNullOrUndefined(this.model.controlsToValidate))f=this._isIframe(this.element);else for(i=0;i<this._controlIds.length;i++)c=this._isIframe($(this._controlIds[i])),c&&(f=!0),f&&(this.element=$(this._controlIds[0]));if(t=f?this.element:this._selectedTarget.parentElement,this._activeElement=t,r="",r=this._isIframe($(t))?$(t).contents().find("body").html():$(t).html().trim(),l={selectedOption:o[0],requestType:"menuSelect",targetContent:r,selectedValue:this._selectedValue},this._trigger("contextClick",l))return!1;switch(o[0]){case"AddToDictionary":a=(this._selectedTarget.innerText||this._selectedTarget.textContent).trim();this._currentElement=$(t);this.addToDictionary(a);break;case"IgnoreAll":if(s=(this._selectedTarget.innerText||this._selectedTarget.textContent).trim(),h=this.ignoreAll(s,r),r=h.resultHTML,$(t).html(h.resultHTML),this._controlIds.length>0)for(i=0;i<this._controlIds.length;i++)for(e=$(this._controlIds[i]),u=0;u<e.length;u++)$(t)[0]!==$(e[u])[0]&&(v=$(e[u]),this._replaceErrorText(v,s));this._renderMenu(this);break;default:y=o[0];p=$(n.element).hasClass("e-errorsuggestions");p&&(this._selectedTarget.innerHTML=y,w=document.createTextNode(this._selectedTarget.innerText||this._selectedTarget.textContent),this._selectedTarget.parentNode.insertBefore(w,this._selectedTarget),$(this._selectedTarget).remove(),r=$(t).html());this._renderMenu(this)}},i.prototype._renderMenu=function(n){var t,i=ej.isNullOrUndefined(n._activeElement)?n.element:n._activeElement,r,f,u;if(n._controlIds.length>0){for(r=0;r<n._controlIds.length;r++)if(t=n._getErrorLength(n,$(n._controlIds[r])),t>0)break}else t=n._getErrorLength(n,$(n.element));if(t===0&&(f={targetElement:i,requestType:"validate"},n._trigger("complete",f)))return!1;n._statusFlag=t>0?!0:!1;u=n._contextMenu.data("ejMenu");$(u.element).is(":visible")&&u.hide();n._isIframe($(i))?n._bindBeforeOpen(n,$(i).contents().find("body")):n._bindBeforeOpen(n,$(i))},i.prototype._getErrorLength=function(n,t){var i=n._isIframe(t)?$(t).contents().find("body")[0]:$(t);return $(i).find(".errorspan").length},i.prototype._getElement=function(){for(var t=document.getElementsByTagName("span"),r=this._selectedValue,i=[],n=0;n<t.length;n++)t[n].textContent===r&&i.push(t[n]);return i},i.prototype._alertClose=function(){!ej.isNullOrUndefined(this._alertWindow)&&this._alertWindow.parents().find(".e-alertdialog").length>0&&(this._alertWindow.ejDialog("close"),this._alertWindow.parents().find(".e-alertdialog").remove(),this._close())},i.prototype._close=function(){var i,t,n,u,r,f;if(!ej.isNullOrUndefined(this._spellCheckWindow)&&this._spellCheckWindow.parents().find(".e-spellcheck.e-dialog-wrap").length>0){for(i=this._spellCheckWindow.find(".e-sentence .e-sentencecontent"),t=$(i[0]).find("span.errorspan"),n=0;n<t.length;n++)u=t[n].innerText||t[n].textContent,$(t[n]).replaceWith(u);if(this._updateTargetString(this),r=i.html(),f=ej.isNullOrUndefined(this.model.controlsToValidate)?{updatedText:r,requestType:"dialogClose"}:{updatedText:r,targetElement:this._currentTargetElement,requestType:"dialogClose"},this._trigger("dialogClose",f))return!1;this._spellCheckWindow.ejDialog("isOpen")&&this._spellCheckWindow.ejDialog("close");this._spellCheckWindow.parents().find(".e-spellcheck.e-dialog-wrap").remove();this._changeAllWords=[];ej.isNullOrUndefined(this.model.controlsToValidate)||(this._controlIds=this.model.controlsToValidate.split(","),this._subElements=[])}},i.prototype._changeErrorWord=function(n){var r=$("#"+this._id+"_Suggestions").ejListBox("option","value"),f=this._spellCheckWindow.find(".e-sentence .e-sentencecontent"),u=this._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML,i=$(this._spellCheckWindow.find(".e-sentence .e-sentencecontent").find("."+this.model.misspellWordCss)[0]).text().trim(),t;r=r===this._localizedLabels.NoSuggestionMessage?i:r;n.model.text===this._localizedLabels.AddToDictionary?(this._currentElement=$(f),this.addToDictionary(i)):n.model.text===this._localizedLabels.IgnoreOnceButtonText?(t=this.ignore(i,u,null),t!==!1&&this._updateErrorWord(this,t,n,i,null,"ignore")):n.model.text===this._localizedLabels.IgnoreAllButtonText?(t=this.ignoreAll(i,u),t!==!1&&this._updateErrorWord(this,t,n,i,null,"ignoreAll")):n.model.text===this._localizedLabels.ChangeButtonText?(t=this.change(i,u,r,null),t!==!1&&this._updateErrorWord(this,t,n,i,r,"change")):n.model.text===this._localizedLabels.ChangeAllButtonText&&(t=this.changeAll(i,u,r),t!==!1&&this._updateErrorWord(this,t,n,i,r,"changeAll"))},i.prototype._convertData=function(n,t){for(var r=[],i=0;i<n.length;i++)t==="dictionaryData"?r.push({field:n[i]}):t==="menuData"&&r.push({id:n[i],text:n[i]});return r},i.prototype._updateErrorWord=function(n,t,i,r,u,f){var o=this._spellCheckWindow.find(".e-suggesteditems"),e,s,h;n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML=t.resultHTML;e=this._spellCheckWindow.find(".e-sentence .e-sentencecontent").find(".errorspan");e.length>0?n._targetUpdate(n,e,r,f,u):!ej.isNullOrUndefined(this.model.controlsToValidate)&&n._targetStatus?n._updateTargetText(n):(ej.isNullOrUndefined(this.model.controlsToValidate)||$(this._proElements).html(n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML),h=[this._localizedLabels.NoSuggestionMessage],o.ejListBox({selectedItemIndex:null}),o.ejListBox({dataSource:this._convertData(h,"dictionaryData"),selectedItemIndex:0}),s=$("#"+this._id+"_Suggestions").data("ejListBox"),s.refresh(),n._validationComplete(n,t.resultHTML))},i.prototype._targetUpdate=function(n,t,i,r,u){var f,h,o,e,s;if(r==="changeAll")for(f=0;f<t.length;f++)h=t[f].innerText||t[f].textContent,h===i&&$(t[f]).replaceWith(u);for(o=0;o<this.model.ignoreWords.length;o++)for(e=0;e<t.length;e++)s=t[e].innerText||t[e].textContent,s===n.model.ignoreWords[o]&&$(t[e]).replaceWith(s);n._listBoxDataUpdate(n)},i.prototype._updateTargetText=function(n){var f,t,i,e,r,o,u,s;if(n._updateTargetString(n),f=ej.isNullOrUndefined(n.model.controlsToValidate)?$("#"+n._id):$(n._proElements),n._proElements=$(n._subElements[0]),n._proElements.length>0||n._subElements.length>0){if(t=$(n._subElements[0]),n._currentTargetElement=t,i=$(t)[0].tagName==="TEXTAREA"||$(t)[0].tagName==="INPUT"?$(t)[0].value:$(t)[0].innerHTML,e={previousElement:f,currentElement:t,targetHtml:i,requestType:"updateText"},n._trigger("targetUpdating",e))return n._close(),!1;n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML=i;n._subElements=n._subElements.slice(1);r=n._spellCheckWindow.find(".e-sentence .e-sentencecontent");o=n._filteringDiffWords(n,r[0].innerText);n._suggestionsRequest(n,r,o.toString(),"validateByDialog")}else u=n._spellCheckWindow.find(".e-sentence .e-sentencecontent").find(".errorspan"),u.length===0&&n._subElements.length>0?n._updateTargetText(n):u.length>0?(s=n._spellCheckWindow.find(".e-sentence .e-sentencescroller").data("ejScroller"),s.refresh(),n._listBoxDataUpdate(n)):n._completionCheck(n)},i.prototype._updateTargetString=function(n){var t=ej.isNullOrUndefined(n.model.controlsToValidate)?$("#"+n._id):$(n._proElements),i;t.length>0&&(i=n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML,n._isIframe(t)?t.contents().find("body").html(i):ej.isNullOrUndefined(t[0].value)?t.html(i):t.val(i))},i.prototype._completionCheck=function(n){n._subElements=n._subElements.slice(1);n._subElements.length===0&&(n._targetStatus=!1);n._validationComplete(n,"")},i.prototype._changeAllErrors=function(n){for(var u,t,i=$(n._activeElement).find(".errorspan"),r=0;r<i.length;r++)for(u=i[r].innerText||i[r].textContent,t=0;t<n._changeAllWords.length;t++)u===n._changeAllWords[t].ErrorWord&&$(i[t]).replaceWith(n._changeAllWords[t].ReplaceWord)},i.prototype._setModel=function(n){var f=this,t,u,i,r;for(t in n)if(n.hasOwnProperty(t))switch(t){case"locale":this.model.locale=n[t];this._localizedLabels=ej.getLocalizedConstants("ej.SpellCheck",this.model.locale);break;case"misspellWordCss":this.model.misspellWordCss=n[t];this.model.contextMenuSettings.enable&&(u=$(this.element[0]).find("span.errorspan").attr("class").toString().split(" ")[1],$(this.element[0]).find("span.errorspan").removeClass(u).addClass(this.model.misspellWordCss));break;case"contextMenuSettings":$.extend(this.model.contextMenuSettings,n[t]);this.model.contextMenuSettings.enable?(this.validate(),this._renderControls()):(ej.isNullOrUndefined(this._contextMenu)||this._contextMenu.parent().remove(),this._removeSpan(this));break;case"ignoreSettings":$.extend(this.model.ignoreSettings,n[t]);this._ignoreStatus=!1;this._statusFlag=!0;this.model.contextMenuSettings.enable&&(this.validate(),this._renderControls());break;case"dictionarySettings":$.extend(this.model.dictionarySettings,n[t]);break;case"maxSuggestionCount":this.model.maxSuggestionCount=n[t];break;case"ignoreWords":this.model.ignoreWords=n[t];this.model.contextMenuSettings.enable&&this.validate();break;case"controlsToValidate":if(this.model.controlsToValidate=n[t],ej.isNullOrUndefined(this.model.controlsToValidate))for($(this.element).attr("style","display:block"),i=0;i<this._controlIds.length;i++)r=$(this._controlIds[i]),r.removeClass("e-spellcheck"),r[0].spellcheck=!0,r[0].addEventListener("input",function(){f._statusFlag=!1},!1);this._renderControls();break;case"isResponsive":this.model.isResponsive=n[t];this._renderControls();break;case"enableValidateOnType":this.model.enableValidateOnType=n[t];this._renderControls()}},i.prototype._getModelValues=function(n,t,i){var r={ignoreAlphaNumericWords:n.model.ignoreSettings.ignoreAlphaNumericWords,ignoreEmailAddress:n.model.ignoreSettings.ignoreEmailAddress,ignoreHtmlTags:n.model.ignoreSettings.ignoreHtmlTags,ignoreMixedCaseWords:n.model.ignoreSettings.ignoreMixedCaseWords,ignoreUpperCase:n.model.ignoreSettings.ignoreUpperCase,ignoreUrl:n.model.ignoreSettings.ignoreUrl,ignoreFileNames:n.model.ignoreSettings.ignoreFileNames};return JSON.stringify({requestType:"checkWords",model:r,text:t,additionalParams:ej.isNullOrUndefined(i)?null:i.additionalParams})},i.prototype._getLocalizedLabels=function(){return ej.getLocalizedConstants(this.sfType,this.model.locale)},i.prototype._elementRightClick=function(n){if(!ej.isNullOrUndefined(this._contextMenu)&&!$(n.target).hasClass("e-menulink")){var t=this._contextMenu.data("ejMenu");ej.isNullOrUndefined(t)||$(t.element).is(":visible")&&t.hide()}},i}(ej.WidgetBase);ej.widget("ejSpellCheck","ej.SpellCheck",new t);ej.SpellCheck.Locale=ej.SpellCheck.Locale||{};ej.SpellCheck.Locale["default"]=ej.SpellCheck.Locale["en-US"]={SpellCheckButtonText:"Spelling:",NotInDictionary:"Not in Dictionary:",SuggestionLabel:"Suggestions:",IgnoreOnceButtonText:"Ignore Once",IgnoreAllButtonText:"Ignore All",AddToDictionary:"Add to Dictionary",ChangeButtonText:"Change",ChangeAllButtonText:"Change All",CloseButtonText:"Close",CompletionPopupMessage:"Spell check is complete",CompletionPopupTitle:"Spell check",Ok:"OK",NoSuggestionMessage:"No suggestions available",NotValidElement:"Specify the valid control id or class name to spell check"}});