{"size": 34388, "ext": "js", "max_stars_repo_path": "App/Scripts/ej/web/ej.spellcheck.min.js", "max_stars_repo_name": "dush88c/WEBAPI-MVC", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "App/Scripts/ej/web/ej.spellcheck.min.js", "max_issues_repo_name": "dush88c/WEBAPI-MVC", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "App/Scripts/ej/web/ej.spellcheck.min.js", "max_forks_repo_name": "dush88c/WEBAPI-MVC", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 3126.1818181818, "max_line_length": 34034, "alphanum_fraction": 0.7595091311}
/*!
*  filename: ej.spellcheck.min.js
*  version : 15.1.0.37
*  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.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,controlsToValidate:null,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._localizedLabels=null;this._statusFlag=!0;this._words=[];this._controlIds=[];this._control=[];this._targetStatus=!0;this._changeAllWords=[];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 n=this,t,i;if(ej.isNullOrUndefined(this.model.controlsToValidate))this.element=this.element,this.element.addClass("e-spellcheck"),this.element[0].spellcheck=!1,this.element[0].addEventListener("input",function(){n._statusFlag=!0},!1);else for($(this.element).attr("style","display:none"),this._controlIds=this.model.controlsToValidate.split(","),t=0;t<this._controlIds.length;t++)i=$("#"+this._controlIds[t]),i.addClass("e-spellcheck"),i[0].spellcheck=!1,i[0].addEventListener("input",function(){n._statusFlag=!0;n._controlIds=n.model.controlsToValidate.split(",");n._targetStatus=!0},!1);this.model.isResponsive&&this._on($(window),"resize",$.proxy(this._resizeSpellCheck,this))},i.prototype._resizeSpellCheck=function(){var n=!ej.isNullOrUndefined(this._spellCheckWindow)&&this._spellCheckWindow.parents().find(".e-spellcheckparent"),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.find(".e-spelldialog").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._spellCheckWindow.data("ejDialog")&&(u=!ej.isNullOrUndefined(this._alertWindow)&&this._spellCheckWindow.data("ejDialog"),u._dialogPosition())},i.prototype.showInDialog=function(){if(this._statusFlag){var n=ej.buildTag("div.e-spellcheckparent e-spellcheck");this.element.after(n);this._renderDialogWindow()}else this._alertWindowRender("show")},i.prototype.validate=function(){var n,i,t,r,u;if(this._statusFlag){if(this.model.contextMenuSettings.enable&&!ej.isNullOrUndefined(this.model.dictionarySettings.dictionaryUrl)){if(n="",this._controlIds.length>0)for(i=0;i<this._controlIds.length;i++)t=$("#"+this._controlIds[i]),r=ej.isNullOrUndefined($(t)[0].value)?($(t)[0].innerText||$(t)[0].textContent).trim():$(t)[0].value.trim(),n=n.concat(r);else n=ej.isNullOrUndefined($(this.element)[0].value)?($(this.element)[0].innerText||$(this.element)[0].textContent).trim():$(this.element)[0].value.trim();if(this._splitWords(n,this),u={targetSentence:n,requestType:"validate"},this._trigger("actionBegin",u))return!1}this._ajaxRequest(this,n,"validateOnType")}else this._alertWindowRender("show")},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.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.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,index:i,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,index:r,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"};if(this._trigger("validating",t))return!1;this._customWord=JSON.stringify({customWord:n});this._ajaxRequest(this,null,"addToDictionary")},i.prototype._updateErrorContent=function(n,t,i,r,u){var s,f,o,h,e,c;if(t.indexOf(n)!==-1){if(f=ej.browserInfo().name!=="msie"||!ej.isNullOrUndefined(this._spellCheckWindow)&&this._spellCheckWindow.ejDialog("isOpen")?'<span class="errorspan '+this.model.misspellWordCss+'">'+n+"<\/span>":'<span class="errorspan '+this.model.misspellWordCss+'" style="-ms-touch-action: pinch-zoom; touch-action: pinch-zoom;">'+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:".e-spellcheckparent",title:this._localizedLabels.SpellCheckButtonText+":",close:function(){n._close()},cssClass:"e-spelldialog",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._alertWindow.ejDialog("open")},i.prototype._renderAlertWindow=function(n){var t=this;this._alertWindow=ej.buildTag("div.e-alertdialog#"+this._id+"alertWindow");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-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:"100px",click:function(){t._alertClose()},cssClass:"e-flat"});this._alertWindow.ejDialog({width:250,minHeight:120,showOnInit:!1,enableModal:!0,title:this._localizedLabels.CompletionPopupTitle,enableResize:!1,allowKeyboardNavigation:!1,target:n==="validating"?".e-spellcheckdialog":$("body"),cssClass:"e-spellalert",close:function(){t._alertClose()},isResponsive:this.model.isResponsive})},i.prototype._renderContextMenu=function(){var n=this;this._contextMenu=ej.buildTag("ul#"+this._id+"contextMenu");this._contextMenu.ejMenu({fields:{id:"id",text:"text",parentId:"parentId"},menuType:ej.MenuType.ContextMenu,openOnClick:!1,contextMenuTarget:"."+this.model.misspellWordCss,width:"auto",cssClass:"e-spellmenu",click:function(t){n._onMenuSelect(t)},beforeOpen:function(t){n._beforeOpen(t)}})},i.prototype._showDialog=function(){var f,n,i,r,t,u,e,o,s;if(this._removeSpan(this),f={spellCheckDialog:this._spellCheckWindow,requestType:"dialogBeforeOpen"},this._trigger("dialogBeforeOpen",f))return!1;if(this._spellCheckWindow.ejDialog("open"),n="",this._controlIds.length>0){for(r=0;r<this._controlIds.length;r++)t=$("#"+this._controlIds[r]),n=n===""?ej.isNullOrUndefined($(t)[0].value)?($(t)[0].innerText||$(t)[0].textContent).trim():$(t)[0].value.trim():n+" "+(ej.isNullOrUndefined($(t)[0].value)?($(t)[0].innerText||$(t)[0].textContent).trim():$(t)[0].value.trim());this._proControls=this._controlIds.length>0&&this._controlIds[0];this._currentTargetElement=i=$("#"+this._controlIds[0]);this._controlIds.shift()}else i=this.element,n=ej.isNullOrUndefined($(this.element)[0].value)?($(this.element)[0].innerText||$(this.element)[0].textContent).trim():$(this.element)[0].value.trim();if(u=document.getElementById(i.attr("id")).tagName==="TEXTAREA"||document.getElementById(i.attr("id")).tagName==="INPUT"?$(i)[0].value:$(i)[0].innerHTML,this._splitWords(n,this),e={previousElement:null,currentElement:i,targetHtml:u},this._trigger("targetUpdating",e))return this._close(),!1;if((this._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML=u,o={targetText:n,requestType:"dialogOpen"},this._trigger("dialogOpen",o))||(s={targetSentence:n,requestType:"spellCheck"},this._trigger("actionBegin",s)))return!1;this._ajaxRequest(this,n,"spellCheckDialog")},i.prototype._ajaxRequest=function(n,t,i){var r=i==="addToDictionary"?n._customWord:this._getModelValues(this,t);$.ajax({url:i==="addToDictionary"?this.model.dictionarySettings.customDictionaryUrl:this.model.dictionarySettings.dictionaryUrl,data:{data:r},contentType:"application/json; charset=utf-8",dataType:this.model.ajaxDataType,crossDomain:!0,success:function(r){var u,v,e,o,f,y,p,s,w,b,k,l,c,d,a,h,g;if(i==="addToDictionary"?(u=n._errorWordDetails,n._filterData(r.toString(),n)):u=n._errorWordDetails=ej.isNullOrUndefined(n.model)?r:n.model.ajaxDataType==="json"?r.Data:r,e=t,u.length>0){if(i==="spellCheckDialog"||i==="validateOnType"||i==="validateOnRender")y=n._getFilterData(u,n),f=ej.dataUtil.distinct(y),i==="spellCheckDialog"?n._dialogModeOperations(n,f,e,i):(i==="validateOnType"||i==="validateOnRender")&&n._validateOnTypeOperations(n,f,e,i);else if(i==="spellCheck"){if(u.length>0){for(p=n._getFilterData(u,n),f=ej.dataUtil.distinct(p),s=0;s<f.length;s++)w=(new ej.Query).where("ErrorWord",ej.FilterOperators.equal,f[s]),b=new ej.DataManager(u).executeLocal(w),b[0].SuggestedWords.length>0&&(v='<span class="errorspan '+(!ej.isNullOrUndefined(n._misspelledWordCss)&&n._misspelledWordCss!==""?n._misspelledWordCss:n.model.misspellWordCss)+'">'+f[s]+"<\/span>",k=new RegExp(f[s],"gi"),e=e.replace(k,v));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"&&(l=$("#"+n._currentElement).html().trim(),c=n._updateErrorContent(r,l,null,"addToDictionary",null),!ej.isNullOrUndefined(l))){if(!ej.isNullOrUndefined(n._spellCheckWindow)&&n._spellCheckWindow.find(".e-btnaddtodictionary").hasClass("e-select"))d=n._spellCheckWindow.find(".e-suggesteditems"),a=n._spellCheckWindow.find(".e-sentence .e-sentencecontent"),n._errorWordsData.length>0?(a[0].innerHTML=c.resultHTML,n._replaceErrorText(a,r.toString()),n._listBoxDataUpdate(n)):(d.ejListBox({dataSource:null}),n._statusFlag=!1,n._alertWindowRender("validating"));else if(!ej.isNullOrUndefined(n._contextMenu)){if($("#"+n._currentElement)[0].innerHTML=c.resultHTML,n._controlIds.length>0)for(h=0;h<n._controlIds.length;h++)n._currentElement.toString()!==n._controlIds[h]&&(g=$("#"+n._controlIds[h]),n._replaceErrorText(g,r.toString()));n._renderMenu(n)}o={resultHTML:c.resultHTML,errorWordDetails:r,requestType:"addToDictionary"};n._trigger("actionSuccess",o)}}else i==="spellCheckDialog"&&n._spellCheckWindow.ejDialog("isOpen")&&n._spellCheckWindow.ejDialog("close"),i!=="spellCheck"&&i!=="validateOnType"&&n._alertWindowRender("load"),i==="spellCheck"&&(o={resultHTML:t,errorWordDetails:u,requestType:"spellCheck"},n._trigger("actionSuccess",o)),i==="validateOnType"&&n._removeSpan(n)},error:function(t,r,u){var f={errorMessage:u,requestType:i};n._trigger("actionFailure",f)}})},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 u,e,f,o;if(t.length>0){if(this._controlIds.length>0)for(u=0;u<this._controlIds.length;u++)e=$("#"+this._controlIds[u])[0],n._removeSpan($("#"+this._controlIds[u])),n._processNode(n,e,t,r),f={},f.controlId=this._controlIds[u],f.errorHtml=e.innerHTML,this._control.push(f);else n._removeSpan(n),n._processNode(n,$(n.element)[0],t,r);if(n._statusFlag=!0,o=this._controlIds.length>0?{errorWords:n._errorWordDetails,targetControls:this._control,requestType:r}:{errorWords:n._errorWordDetails,targetText:i,requestType:r},this._trigger("start",o))return!1;n._renderContextMenu()}else n._removeSpan(n),n._statusFlag=!1},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._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){for(var r,u=ej.isNullOrUndefined(this.model.controlsToValidate)?n.element:n,i=$(u[0]).find("span.errorspan"),t=0;t<i.length;t++)r=i[t].innerText||i[t].textContent,$(i[t]).replaceWith(r)},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-suggesteditems"),i=n._spellCheckWindow.find(".e-sentence .e-sentencecontent").find(".errorspan"),f,e,o,s;if($(i[0]).addClass(this.model.misspellWordCss),i.length>0){var h=(new ej.Query).where("ErrorWord",ej.FilterOperators.equal,i[0].innerText||i[0].textContent),c=new ej.DataManager(n._errorWordDetails).executeLocal(h),r=ej.dataUtil.distinct(c),u=$("#"+n._id+"_Suggestions").data("ejListBox");r[0].SuggestedWords.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")),f=n.model.maxSuggestionCount<r[0].SuggestedWords.length?n.model.maxSuggestionCount:r[0].SuggestedWords.length,t.ejListBox({selectedIndex:null}),t.ejListBox({dataSource:n._convertData(r[0].SuggestedWords.slice(0,f),"dictionaryData"),selectedIndex:0}),u.refresh()):(n._spellCheckWindow.find(".e-btnchange").addClass("e-disable"),n._spellCheckWindow.find(".e-btnchangeall").addClass("e-disable"),e=[this._localizedLabels.NoSuggestionMessage],t.ejListBox({selectedIndex:null}),t.ejListBox({dataSource:this._convertData(e,"dictionaryData"),selectedIndex:0}),u.refresh());$(n._spellCheckWindow.find("."+n.model.misspellWordCss)).get(0).scrollIntoView(!1)}else if(!ej.isNullOrUndefined(this.model.controlsToValidate)&&n._targetStatus)n._updateTargetText(n);else{if(o=n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML,n._updateTargetString(n),s={targetElement:n._currentTargetElement,targetText:o,requestType:"changeErrorWord"},this._trigger("complete",s))return!1;n._statusFlag=!1;n._alertWindowRender("validating")}},i.prototype._beforeOpen=function(n){var l,f,e,t,h,a,v,o,r,s,u;this._selectedTarget=n.events.target;var c=this._selectedValue=this._selectedTarget.textContent||this._selectedTarget.innerText,y=(new ej.Query).where("ErrorWord",ej.FilterOperators.equal,c.trim()),i=new ej.DataManager(this.model.ajaxDataType==="json"?this._errorWordDetails.Data:this._errorWordDetails).executeLocal(y);if(this._errorWordsData=i,l={selectedErrorWord:c,requestType:"contextOpen"},this._trigger("contextOpen",l))return!1;if(this._errorWordsData.length>0)if(f=this._contextMenu.data("ejMenu"),e=this.model.contextMenuSettings.menuItems,i[0].SuggestedWords.length>0){for(t=[],h=this.model.maxSuggestionCount<i[0].SuggestedWords.length?this.model.maxSuggestionCount:i[0].SuggestedWords.length,t=this._convertData(i[0].SuggestedWords.slice(0,h),"menuData"),a=t.length,v=t[h-1].id,o=0;o<e.length;o++)t.push(e[o]);for(f.option("fields.dataSource",t),r=f.element.find(".e-list"),s=0;s<a;s++)$(r[s]).addClass("e-errorsuggestions");for(u=0;u<r.length;u++)r[u].attributes.id.value===v&&$(r[u]).addClass("e-separator")}else f.option("fields.dataSource",e);else n.cancel=!0},i.prototype._onMenuSelect=function(n){var e=n.events.ID.split("_"),t=this._selectedTarget.parentElement.attributes.id.value,a=(new ej.Query).where("controlId",ej.FilterOperators.notEqual,t),i="",u,s,h,o,f,r,c,l;if(this._controlIds.length>0?(u=new ej.DataManager(this._control).executeLocal(a),i=u[0].errorHtml=$("#"+t).html().trim()):i=$("#"+this._id).html().trim(),s={selectedOption:e[0],requestType:"menuSelect",targetContent:i,selectedValue:this._selectedValue},this._trigger("contextClick",s))return!1;switch(e[0]){case"AddToDictionary":h=(this._selectedTarget.innerText||this._selectedTarget.textContent).trim();this._currentElement=this._controlIds.length>0?t:this._id;this.addToDictionary(h);break;case"IgnoreAll":if(o=(this._selectedTarget.innerText||this._selectedTarget.textContent).trim(),f=this.ignoreAll(o,i),i=this._controlIds.length>0?u[0].errorHtml=f.resultHTML:f.resultHTML,$("#"+t).html(f.resultHTML),this._controlIds.length>0)for(r=0;r<this._controlIds.length;r++)t!==this._controlIds[r]&&(c=$("#"+this._controlIds[r]),this._replaceErrorText(c,o));this._renderMenu(this);break;default:var v=e[0],y=this._contextMenu.data("ejMenu"),p=$(y._activeElement).hasClass("e-errorsuggestions");p&&(this._selectedTarget.innerHTML=v,l=document.createTextNode(this._selectedTarget.innerText||this._selectedTarget.textContent),this._selectedTarget.parentNode.insertBefore(l,this._selectedTarget),$(this._selectedTarget).remove(),i=this._controlIds.length>0?u[0].errorHtml=$("#"+t).html():$("#"+t).html());this._renderMenu(this)}},i.prototype._renderMenu=function(n){var t,i,r;if(n._controlIds.length>0){for(i=0;i<n._controlIds.length;i++)if(t=$("#"+n._controlIds[i]).find(".errorspan").length,t>0)break}else t=$(n.element[0]).find("span.errorspan").length;if(t===0&&(r={targetElement:n._currentTargetElement,requestType:"validate"},this._trigger("complete",r)))return!1;n._statusFlag=t>0?!0:!1;this._renderContextMenu()},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 t,i,n,u,r,f;if(!ej.isNullOrUndefined(this._spellCheckWindow)&&this._spellCheckWindow.parents().find(".e-spellcheckparent").length>0){for(t=this._spellCheckWindow.find(".e-sentence .e-sentencecontent"),i=$(t[0]).find("span.errorspan"),n=0;n<i.length;n++)u=i[n].innerText||i[n].textContent,$(i[n]).replaceWith(u);if(this._updateTargetString(this),r=t.html(),f=ej.isNullOrUndefined(this.model.controlsToValidate)?{updatedText:t.text(),updatedHtml:r,requestType:"dialogClose"}:{updatedText:t.text(),targetElement:this._currentTargetElement,updatedHtml:r,requestType:"dialogClose"},this._trigger("dialogClose",f))return!1;this._spellCheckWindow.ejDialog("isOpen")&&this._spellCheckWindow.ejDialog("close");this._spellCheckWindow.parents().find(".e-spellcheckparent").remove();this._changeAllWords=[];ej.isNullOrUndefined(this.model.controlsToValidate)||(this._controlIds=this.model.controlsToValidate.split(","))}},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.attr("id"),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,c;if(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);else if(!ej.isNullOrUndefined(this.model.controlsToValidate)&&n._targetStatus)n._updateTargetText(n);else{if(ej.isNullOrUndefined(this.model.controlsToValidate)||$("#"+this._proControls).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._updateTargetString(n),c={targetElement:n._currentTargetElement,targetText:t.resultHTML,requestType:"changeErrorWord"},this._trigger("complete",c))return!1;this._statusFlag=!1;this._alertWindowRender("validating")}},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 u,t,i,f,r,o,s;if(n._updateTargetString(n),u=ej.isNullOrUndefined(n.model.controlsToValidate)?$("#"+n._id):$("#"+n._proControls),n._proControls=n._controlIds[0],!ej.isNullOrUndefined(n._proControls)||n._controlIds.length>0){if(t=$("#"+n._controlIds[0]),n._currentTargetElement=t,i=document.getElementById(t.attr("id")).tagName==="TEXTAREA"?$(t)[0].value:$(t)[0].innerHTML,f={previousElement:u,currentElement:t,targetHTML:i,requestType:"updateText"},n._trigger("targetUpdating",f))return n._close(),!1;n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML=i;n._controlIds.shift();var e=n._spellCheckWindow.find(".e-sentence .e-sentencecontent"),h=n._getFilterData(n._errorWordsData,n),c=ej.dataUtil.distinct(h);n._processNode(n,e[0],c,"validating");n._activeElement=e[0];n._changeAllErrors(n)}if(r=n._spellCheckWindow.find(".e-sentence .e-sentencecontent").find(".errorspan"),r.length===0&&n._controlIds.length>0)n._updateTargetText(n);else if(r.length>0)o=n._spellCheckWindow.find(".e-sentence .e-sentencescroller").data("ejScroller"),o.refresh(),n._listBoxDataUpdate(n);else{if(n._controlIds.shift(),n._controlIds.length===0&&(n._targetStatus=!1),n._updateTargetString(n),s={targetElement:n._currentTargetElement,requestType:"changeErrorWord"},this._trigger("complete",s))return!1;n._statusFlag=!1;n._alertWindowRender("validating")}},i.prototype._updateTargetString=function(n){var t=ej.isNullOrUndefined(n.model.controlsToValidate)?$("#"+n._id):$("#"+n._proControls),i,r;t.length>0&&(i=t.attr("id"),r=n._spellCheckWindow.find(".e-sentence .e-sentencecontent")[0].innerHTML,document.getElementById(i).tagName==="TEXTAREA"||document.getElementById(i).tagName==="INPUT"?t.val(r):t.html(r))},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():(ej.isNullOrUndefined(this._contextMenu)||this._contextMenu.parent().remove(),this._removeSpan(this));break;case"ignoreSettings":$.extend(this.model.ignoreSettings,n[t]);this.model.contextMenuSettings.enable&&this.validate();break;case"dictionarySettings":$.extend(this.model.dictionarySettings,n[t]);this.model.contextMenuSettings.enable&&this.validate();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()}},i.prototype._getModelValues=function(n,t){var i={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({model:i,text:t})},i.prototype._getLocalizedLabels=function(){return ej.getLocalizedConstants(this.sfType,this.model.locale)},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"}});
