-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.min.js
More file actions
32 lines (29 loc) · 27.4 KB
/
plugin.min.js
File metadata and controls
32 lines (29 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* SCAYT v
* Copyright (c) 2000-2018 WebSpellChecker LLC All rights reserved.
*/
/*!
* jQuip JavaScript Library v0.0.3
* https://github.com/mythz/jquip
*
* Copyright, Demis Bellot
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
*/
/*!
* Rangy, a cross-browser JavaScript range and selection library
* http://code.google.com/p/rangy/
*
* Copyright 2012, Tim Down
* Licensed under the MIT license.
* Version: 1.3alpha.681
* Build date: 20 July 2012
*/
/*! @license
* JS Signals <http://millermedeiros.github.com/js-signals/>
* Released under the MIT license
* Author: Miller Medeiros
* Version: 0.8.1 - Build: 266 (2012/07/31 03:33 PM)
*/
!function(){tinymce.DOM,tinymce.util,tinymce.UndoManager;tinymce.PluginManager.requireLangPack("scayt"),tinymce.createNS("tinymce.plugins.SCAYT"),tinymce.plugins.SCAYT=function(){var t={},e={},n=[],a={loadOrder:[]},o=0,i=new tinymce.dom.ScriptLoader,r={scayt_context_commands:"scayt_contextCommands",scayt_slang:"scayt_sLang",scayt_max_suggestion:"scayt_maxSuggestions",scayt_custom_dic_ids:"scayt_customDictionaryIds",scayt_user_dic_name:"scayt_userDictionaryName",scayt_ui_tabs:"scayt_uiTabs",scayt_service_protocol:"scayt_serviceProtocol",scayt_service_host:"scayt_serviceHost",scayt_service_port:"scayt_servicePort",scayt_service_path:"scayt_servicePath",scayt_context_moresuggestions:"scayt_moreSuggestions",scayt_customer_id:"scayt_customerId",scayt_custom_url:"scayt_srcUrl",scayt_auto_startup:"scayt_autoStartup",scayt_context_menu_items_order:"scayt_contextMenuItemsOrder"},s=function(t){for(var e in t)e in r&&(t[r[e]]=t[e],delete t[e])},c=function(t,e){var n,o=document.location.protocol,r=t.getParam("scayt_srcUrl"),s=(new Date).getTime();o=-1!==o.search(/https?:/)?o:"http:",n=(r=0===r.search(/^\/\//)?o+r:r)+"?"+s,void 0===window.SCAYT||"function"!=typeof window.SCAYT.TINYMCE?(a[t.id]=e,a.loadOrder.push(t.id),i.add(n),i.loadQueue(function(t){for(var e,n=0;n<a.loadOrder.length;n++)e=a.loadOrder[n],tinymce.plugins.SCAYT.fireOnce(tinymce,"onScaytReady"),"function"==typeof a[e]&&a[e](tinymce.editors[e]),delete a[e];a.loadOrder=[]})):window.SCAYT&&"function"==typeof window.SCAYT.TINYMCE&&(tinymce.plugins.SCAYT.fireOnce(tinymce,"onScaytReady"),tinymce.plugins.SCAYT.getScayt(tinymce.editors[t.id])||"function"==typeof e&&e(t))},u=function(t){c(t,function(a){var o={debug:a.getParam("scayt_debug",!1),lang:a.getParam("scayt_sLang"),container:a.getContentAreaContainer()&&a.getContentAreaContainer().children[0]?a.getContentAreaContainer().children[0]:a.getElement(),customDictionary:a.getParam("scayt_customDictionaryIds"),userDictionaryName:a.getParam("scayt_userDictionaryName"),localization:a.langCode,customer_id:a.getParam("scayt_customerId"),data_attribute_name:"data-scayt-word",misspelled_word_class:"scayt-misspell-word",ignoreElementsRegex:a.getParam("scayt_elementsToIgnore"),minWordLength:a.getParam("scayt_minWordLength")};tinymce.focusedEditor===t&&(o.focused=!0),a.getParam("scayt_serviceProtocol")&&(o.service_protocol=a.getParam("scayt_serviceProtocol")),a.getParam("scayt_serviceHost")&&(o.service_host=a.getParam("scayt_serviceHost")),a.getParam("scayt_servicePort")&&(o.service_port=a.getParam("scayt_servicePort")),a.getParam("scayt_servicePath")&&(o.service_path=a.getParam("scayt_servicePath"));var i=new SCAYT.TINYMCE(o,function(){},function(){});i.subscribe("suggestionListSend",function(t){for(var e={},a=[],o=0;o<t.suggestionList.length;o++)e["word_"+t.suggestionList[o]]||(e["word_"+t.suggestionList[o]]=t.suggestionList[o],a.push(t.suggestionList[o]));n=a}),e[a.id]=i})},g=function(t){var n=e[t.id];n&&n.destroy(),delete e[t.id]},l=function(t){t&&(t.reloadMarkup?t.reloadMarkup():(o<5&&(console.warn("Note: You are using latest version of SCAYT plug-in. It is recommended to upgrade WebSpellChecker.net application to version v4.8.3.Contact us by e-mail at support@webspellchecker.net."),o+=1),t.fire("startSpellCheck")))};return{reloadMarkup:function(t){return l(t)},create:function(t){return u(t)},destroy:function(t){return g(t)},getScayt:function(t){return e[t.id]||!1},getSuggestions:function(){return n},getState:function(e){var n="object"==typeof e?e.id:e;return t[n]},setState:function(e,n){var a="object"==typeof e?e.id:e;return n=n||!1,t[a]=n},getOptions:function(t){return this.getScayt(t).getApplicationConfig()},getCurrentLanguage:function(t){return this.getScayt(t).getLang()},getLanguages:function(t){return this.getScayt(t).getLangList()},getUserDictionaryName:function(t){return this.getScayt(t).getUserDictionaryName()},getVersion:function(t){return this.getScayt(t).getVersion()},removeMarkupFromString:function(t,e){var n=this.getScayt(t);return n?n.removeMarkupFromString(e):e},replaceOldOptionsNames:function(t){s(t)},fireOnce:function(t,e){t["uniqueEvtKey_"+e]||(t["uniqueEvtKey_"+e]=!0,t.fire(e))},executeOnce:function(t,e,n){var a=function(){t.off(e,a),"function"==typeof n&&n()};t.on(e,a)},misspelledWordClass:"scayt-misspell-word"}}(),tinymce.PluginManager.add("scayt",function(t,e){"use strict";t.settings.contextmenu=t.settings.contextmenu||"scayt link image inserttable | cell row column deletetable";var n={definitionDefaultOption:{scayt_srcUrl:{type:"string",default:"//svc.webspellchecker.net/spellcheck31/lf/scayt3/tinymce/tinymcescayt.js"},scayt_sLang:{type:"string",default:"en_US"},scayt_customerId:{type:"string",default:"1:wiN6M-YQYOz2-PTPoa2-3yaA92-PmWom-3CEx53-jHqwR3-NYK6b-XR5Uh1-M7YAp4"},scayt_autoStartup:{type:"boolean",default:!1},scayt_maxSuggestions:{type:"number",default:3},scayt_minWordLength:{type:"number",default:3},scayt_moreSuggestions:{type:"string",default:"on",allowable:{on:!0,off:!0}},scayt_contextCommands:{type:"string",default:"ignoreall,add"},scayt_contextMenuItemsOrder:{type:"string",default:"suggest|moresuggest|control"},scayt_uiTabs:{type:"string",default:"1,1,1"},scayt_customDictionaryIds:{type:"string",default:""},scayt_userDictionaryName:{type:"string",default:null},scayt_serviceProtocol:{type:"string",default:null},scayt_serviceHost:{type:"string",default:null},scayt_servicePort:{type:"string",default:null},scayt_servicePath:{type:"string",default:null}},parseOptions:function(t){var e=this.definitionDefaultOption,n=t.settings,a=tinymce.plugins.SCAYT,o=i.getParameter,r=i.isAllowable;n.scayt_autoStartup=o("scayt_autoStartup"),n.scayt_moreSuggestions=r("scayt_moreSuggestions")?o("scayt_moreSuggestions"):"off",n.scayt_maxSuggestions=i.isNegative(o("scayt_maxSuggestions"))?e.scayt_maxSuggestions.default:o("scayt_maxSuggestions"),n.scayt_minWordLength=o("scayt_minWordLength")<1?e.scayt_minWordLength.default:o("scayt_minWordLength"),n.scayt_srcUrl=o("scayt_srcUrl"),n.scayt_sLang=o("scayt_sLang"),n.scayt_customerId=function(t,n){n=i.getLocationInfo(n);var a=i.getLocationInfo(e.scayt_srcUrl.default),o=t&&typeof t===e.scayt_customerId.type&&t.length>=50;return a=n.host===a.host&&n.pathname===a.pathname,o&&!a?t:a?o&&a?t:e.scayt_customerId.default:t}(t.getParam("scayt_customerId"),n.scayt_srcUrl),n.scayt_customDictionaryIds=o("scayt_customDictionaryIds"),n.scayt_userDictionaryName=o("scayt_userDictionaryName"),n.scayt_serviceProtocol=o("scayt_serviceProtocol"),n.scayt_serviceHost=o("scayt_serviceHost"),n.scayt_servicePort=o("scayt_servicePort"),n.scayt_servicePath=o("scayt_servicePath"),n.scayt_contextCommands=o("scayt_contextCommands"),"all"===n.scayt_contextCommands?n.scayt_contextCommands=e.scayt_contextCommands.default:"off"===n.scayt_contextCommands?n.scayt_contextCommands="":n.scayt_contextCommands=n.scayt_contextCommands.replace(/\s?[\|]+/gi," "),n.scayt_contextMenuItemsOrder=o("scayt_contextMenuItemsOrder"),n.scayt_contextMenuItemsOrder=n.scayt_contextMenuItemsOrder.replace(/\s?[\|]+/g," "),n.scayt_uiTabs=o("scayt_uiTabs").split(","),3==n.scayt_uiTabs.length&&i.validateArray(n.scayt_uiTabs,function(t){return 0==t||1==t})||(n.scayt_uiTabs=e.scayt_uiTabs.default.split(",")),a.setState(t,n.scayt_autoStartup)},init:function(t){var e=t;tinymce.plugins.SCAYT.replaceOldOptionsNames(t.settings),this.parseOptions(e),this.bindEvents(e)},bindEvents:function(t){var e=t,n=tinymce.plugins.SCAYT,i=(t.plugins.scayt,function(t){var e=a.scaytButton;t.settings.readonly?e&&e.disabled(!0):!0===n.getState(t)&&(n.create(t),e&&e.active(!0),o.create(t))});t.inline?e.on("focusin",function(t){var e=a.scaytButton;e&&e.disabled(!0)}):e.on("init",function(t){var e=t.target;i(e)}),e.on("remove",function(){return n.destroy(e)}),e.on("SetContent",function(t){var a=n.getScayt(e);a&&n.getState(e)&&(t.content&&(t.content=n.removeMarkupFromString(e,t.content)),n.reloadMarkup(a))}),e.on("GetContent",function(t){n.getScayt(e);t.preventDefault(),n.getState(e)&&t.content&&(t.content=n.removeMarkupFromString(e,t.content))}),e.on("PastePreProcess",function(t){var a=n.getScayt(e);n.getState(e)&&(t.content=n.removeMarkupFromString(e,t.content),setTimeout(function(){a.removeMarkupInSelectionNode(),n.reloadMarkup(a)},0))}),e.on("NodeChange",function(t){var e=[],n=tinymce.plugins.SCAYT.misspelledWordClass;t.element&&"SPAN"==t.element.nodeName&&t.element.className==n&&(tinymce.each(t.parents,function(t){"SPAN"==t.nodeName&&t.className==n||e.push(t)}),t.element=t.element.parentNode,t.parents=e)}),t.on("BeforeAddUndo",function(e){e.lastLevel&&e.lastLevel.content&&(e.lastLevel.content=n.removeMarkupFromString(t,e.lastLevel.content)),e.level.content=n.removeMarkupFromString(t,e.level.content)}),t.on("BeforeExecCommand",function(e){var a=n.getScayt(t),o=!1,i=!0;"Cut"!==e.command&&"Bold"!==e.command&&"Underline"!==e.command&&"Italic"!==e.command&&"Subscript"!==e.command&&"Superscript"!==e.command&&"mceToggleFormat"!==e.command||a&&("Cut"===e.command&&(i=!1,o=!0),a.removeMarkupInSelectionNode({removeInside:i,forceBookmark:o}),setTimeout(function(){n.reloadMarkup(a)},0))})}},a={scaytButton:null,createToolBarButton:function(t){var e=this;t.addButton("scayt",{type:"splitbutton",role:"splitbutton",tooltip:"SpellCheckAsYouType",disabled:!1,menu:e.renderItemMenu(t),icon:"spellchecker",onpostrender:function(){e.scaytButton=this},onshow:function(t){e.findOutStatusMenu(t.control,this)},onclick:function(n){e.toggleStateMenuSelect(t)}})},renderItemMenu:function(t){var e=[],n=tinymce.each,a=t.settings.scayt_uiTabs;return n(r.menu,function(t,n){t.identification&&parseInt(a[n])?(t.menuItemIndex=e.length,e.push(t)):"about"==t.identification&&(t.menuItemIndex=0===e.length?0:e.length,e.push(t))}),e},toggleStateMenuSelect:function(t){var e=tinymce.plugins.SCAYT,n=e.setState(t,!e.getState(t)),a=this.scaytButton,i=this.scaytButton.menu;n?(e.create(t),a.active(!0),o.create(t)):(e.destroy(t),a.active(!1),o.destroy(t)),this.findOutStatusMenu(i,a)},findOutStatusMenu:function(t,e){var n=t?t._items:{},a=!e.active();return tinymce.each(n,function(t){t.disabled(a)}),!a},init:function(t){tinymce.plugins.SCAYT;n.init(t),this.createToolBarButton(t)}},o={originalMenu:void 0,contextmenu:null,menu:null,items:[],pos:null,createScaytMenuItem:function(){t.addMenuItem("scayt",{context:"scayt3t",text:"SCAYT",onPostRender:function(){this.visible(!1),o.originalMenu=this._parent}})},destroy:function(t){var e=this;null!=e.menu&&e.menu.remove(),e.menu=null},create:function(t){var e,n,a,r,s=this,c=tinymce.plugins.SCAYT,u=t,g=u.settings,l=null,m=null,d=null,y=g.scayt_maxSuggestions;u.on("contextmenu",function(f){if(f.preventDefault(),!t.settings.readonly&&(l=c.getScayt(u),m=i.getSelectionWord(l))){l.fire("getSuggestionsList",{lang:c.getCurrentLanguage(u),word:m}),e=c.getSuggestions(),n=e.slice(0,y),a=e.slice(y,15),r="on"===g.scayt_moreSuggestions&&a.length>0&&"no_any_suggestions"!=a[0],i.generateMenuItemsForSuggestion(n),i.generateMoreSuggestionsItem(a),i.registerControlItems();var p=g.scayt_contextCommands+" | aboutscayt |",_=(n.length>0?n.join(" "):r||e.length>0?"":"no_any_suggestions")+" | ",h=r?" moreSuggestions | ":"";s.contextmenu=g.scayt_contextMenuItemsOrder.replace("control",p).replace("moresuggest",h).replace("suggest",_),s.contextmenu=t.settings.contextmenu.replace("scayt",s.contextmenu),s.items=[],tinymce.each(s.contextmenu.split(/[ ,]/),function(t){var e=u.menuItems[t];"|"==t&&(e={text:t}),e&&(e.shortcut="",s.items.push(e))});for(var v=0;v<s.items.length;v++)"|"==s.items[v].text&&(0!==v&&v!=s.items.length-1||s.items.splice(v,1));s.menu=new tinymce.ui.Menu({items:s.items,context:"scayt",onCancel:function(){s.menu&&(s.menu.hide(),s.menu=null)}}),o.originalMenu.hide(),s.menu.renderTo(document.body);var S=s.menu.getEl();return tinymce.isIE?(S.style.height="auto",window.JSON&&(S.style.maxHeight="inherit",S.style.overflow="inherit")):(S.style.maxHeight="inherit",S.style.position="absolute",S.style.overflow="visible"),d="#"+s.menu._id,l.showBanner(d),s.menu.show(),s.pos={x:f.pageX,y:f.pageY},u.inline||(s.pos=tinymce.DOM.getPos(u.getContentAreaContainer()),s.pos.x+=f.clientX,s.pos.y+=f.clientY),s.menu.moveTo(s.pos.x,s.pos.y),s.menu.on("cancel",function(){this.remove(),this.menu=null}),!1}})}},i={getKeys:Object.keys||function(t){var e,n=[];for(e in t)t.hasOwnProperty(e)&&n.push(e);return n},getLocationInfo:function(t){var e=document.createElement("a");return e.href=t,{protocol:e.protocol.replace(/:/,""),host:e.host.split(":")[0],port:"0"==e.port?"80":e.port,pathname:e.pathname.replace(/^\//,"")}},isInteger:function(t){return(0^t)===t},validateArray:function(t,e){for(var n=!0,a=0,o=t.length;a<o&&(n=n&&e(t[a]));a++);return n},isNegative:function(t){return t<0},getParameter:function(e){var a=n.definitionDefaultOption;if(e+="",!a[e])return t.getParam(e);return function(e){return typeof t.getParam(e)===a[e].type}(e)?t.getParam(e):a[e].default},isAllowable:function(t){var e=n.definitionDefaultOption;return i.getParameter(t)in e[t].allowable},getLang:function(e,n){return t.editorManager.i18n.translate(e)!==e?t.editorManager.i18n.translate(e):n||e},getTranslate:function(e){return t.editorManager.i18n.translate(e)},getSelectionWord:function(t){var e,n=!1;return t&&(n=(e=t.getSelectionNode())?e.getAttribute(t.getNodeAttribute()):e),n},registerMenuItem:function(e,n){t.addMenuItem(e,n)},addUndoLevelAfterReplaceCommand:function(t){t.undoManager.add()},generateReplaceCommand:function(e,n){var a=n,o=this;return function(){t.focus(),e.replaceSelectionNode({word:a}),o.addUndoLevelAfterReplaceCommand(t)}},generateMenuItemsForSuggestion:function(e){var n=tinymce.plugins.SCAYT.getScayt(t);if(0===e.length||"no_any_suggestions"===e[0])this.registerMenuItem("no_any_suggestions",{text:i.getLang("no_any_suggestions","No suggestions"),onclick:function(){return!1}});else for(var a=0;a<e.length;a++)this.registerMenuItem(e[a],{text:e[a],onclick:this.generateReplaceCommand(n,e[a])})},generateSubMenuForMoreSuggestions:function(e){for(var n=tinymce.plugins.SCAYT.getScayt(t),a=[],o=0;o<e.length;o++)a.push({text:e[o],onclick:this.generateReplaceCommand(n,e[o])});return a},generateMoreSuggestionsItem:function(e){var n,a;(n=this.generateSubMenuForMoreSuggestions(e))[0]&&n[0].text&&(a="no_any_suggestions"==n[0].text?null:n),null!=a&&t.addMenuItem("moreSuggestions",{text:i.getLang("cm_more_suggestions","More suggestions"),menu:a})},registerControlItems:function(){t.addMenuItem("ignore",{text:i.getLang("cm_ignore_word","Ignore"),onclick:function(){var e=tinymce.plugins.SCAYT.getScayt(t);t.focus(),setTimeout(function(){e.ignoreWord()},0)}}),t.addMenuItem("ignoreall",{text:i.getLang("cm_ignore_all","Ignore all"),onclick:function(){var e=tinymce.plugins.SCAYT.getScayt(t);t.focus(),setTimeout(function(){e.ignoreAllWords()},0)}}),t.addMenuItem("add",{text:i.getLang("cm_add_word","Add word"),onclick:function(){var e=tinymce.plugins.SCAYT.getScayt(t);t.focus(),setTimeout(function(){e.addWordToUserDictionary()},0)}}),t.addMenuItem("aboutscayt",{text:i.getLang("cm_about","About SCAYT"),onclick:function(e){var n=t.settings.scayt_uiTabs,a=n.length;tinymce.each(n,function(t){0==parseInt(t)&&a--}),r.openDialog(t,e,a)}}),t.addMenuItem("no_any_suggestions",{text:i.getLang("no_any_suggestions","No suggestions"),onPostRender:function(t){t.control.disabled(!0)},onclick:function(){}})},registerLanguages:function(){var t,e,n,a={},o={};return t=function(t){var e="string"==typeof t?t:'"'+t+'"';if(o.hasOwnProperty(e))return o[e]},e=function(t){var e="string"==typeof t?t:'"'+t+'"';for(var n in o)if(o[n]==e)return n},n=function(t){a=t;for(var e in a)if(a.hasOwnProperty(e))for(var n in a[e])o[n]=a[e][n];return o},{getToName:t,getToCode:e,makeLanguageList:n}}(),replaceHostNullToNativeNull:function(t){if(document.all&&document.querySelector&&!document.addEventListener)for(var e in t)t[e]=null===t[e]?null:t[e]}},r={dictionaryButtons:[],definitionDataControl:{nodes:{},setInstances:function(t,e){return this.nodes[e]=t},getInstances:function(t){return this.nodes[t]}},langState:{isChanged:function(){return null!==this.selectLang&&this.currentLang!==this.selectLang},currentLang:null,selectLang:null,id:"lang"},getChangedOptions:function(){var t=this,e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return r.langState.isChanged()&&(e[r.langState.id]=r.langState.selectLang),e},menu:[{text:i.getLang("tb_menu_options","SCAYT Options"),identification:"options",menuItemIndex:0,onclick:function(e){i.replaceHostNullToNativeNull(e),r.openDialog(t,e,this.settings.menuItemIndex)}},{text:i.getLang("tb_menu_languages","SCAYT Languages"),identification:"languages",menuItemIndex:1,onclick:function(e){i.replaceHostNullToNativeNull(e),r.openDialog(t,e,this.settings.menuItemIndex)}},{text:i.getLang("tb_menu_dictionaries","SCAYT Dictionaries"),identification:"dictionary",menuItemIndex:2,onclick:function(e){i.replaceHostNullToNativeNull(e),r.openDialog(t,e,this.settings.menuItemIndex)}},{text:i.getLang("tb_menu_about","About SCAYT"),identification:"about",menuItemIndex:3,onclick:function(e){i.replaceHostNullToNativeNull(e),r.openDialog(t,e,this.settings.menuItemIndex)}}],generateOptionsCheckbox:function(t){var e,n=t||{};e=[{checked:!1,name:"ignore-all-caps-words",text:i.getLang("label_allCaps","Ignore All-Caps Words")},{checked:!1,name:"ignore-domain-names",text:i.getLang("label_ignoreDomainNames","Ignore Domain Names")},{checked:!1,name:"ignore-words-with-mixed-cases",text:i.getLang("label_mixedCase","Ignore Mixed-Case Words")},{checked:!1,name:"ignore-words-with-numbers",text:i.getLang("label_mixedWithDigits","Ignore Words with Numbers")}];for(var a=0;a<e.length;a++)e[a].checked=n[e[a].name];return e},generateLanguagesCheckbox:function(t,e){var n=[],a=t||{},o=e||"en_US",r=[],s={},c=i.getKeys;this.langState.currentLang=o,a=i.registerLanguages.makeLanguageList(a);for(var u in a)a.hasOwnProperty(u)&&"string"==typeof a[u]&&""!=a[u]&&(s[a[u]]=u);r=c(s).sort(),a={};for(var g=0;g<r.length;g+=1)a[r[g]]=s[r[g]];for(var l in a)n.push({checked:a[l]===o,name:a[l],role:a[l],text:l});return n},dividedLanguagesCheckbox:function(t){var e=[[],[]],n=(0,i.getKeys)(t).length;for(var a in t)t.hasOwnProperty(a)&&e[parseInt(a)<Math.ceil(n/2)?0:1].push(t[a]);return e},generateDictionaryButtons:function(){return[{disabled:!0,name:"Create",role:"Create",text:i.getLang("dic_create","Create")},{disabled:!0,name:"Restore",role:"Restore",text:i.getLang("dic_restore","Restore")},{disabled:!0,name:"Rename",role:"Rename",text:i.getLang("dic_rename","Rename")},{disabled:!0,name:"Remove",role:"Remove",text:i.getLang("dic_remove","Remove")}]},setDictionaryButtons:function(){var t=this;t.removeDictionaryButtons(),t.definitionDataControl.getInstances("dic_buttons").append(t.getDictionaryButtons())},getDictionaryButtons:function(){return this.dictionaryButtons},removeDictionaryButtons:function(){for(var t=this.definitionDataControl.getInstances("dic_buttons").items(),e=t.length-1;e>=0;e--)t[e].remove()},toggleDictionaryButtons:function(t){for(var e=this,n=e.generateDictionaryButtons(),a=t.split("|")||"",o=0;o<a.length;o++)for(var i=0;i<n.length;i++)n[i].name==a[o]&&(n[i].disabled=!1);e.dictionaryButtons=n},initDictionaryNameAndButtons:function(t){var e=this,n="",a=["Create|Restore","Rename|Remove"];return void 0!==t&&"null"!==t&&""!==t?(n=t,e.toggleDictionaryButtons(a[1])):(n="",e.toggleDictionaryButtons(a[0])),n},handlerDictionaryButtons:function(t){var e=this;if(t&&"BUTTON"===t.target.tagName&&!0!==t.control.disabled()){var n=t.control.aria("role").toLowerCase();e.manageCommandButtons[n]()}},dicEmptyMessage:function(){return!document.getElementById("messageBox").innerHTML},dicSuccessMessage:function(t){return t&&(document.getElementById("messageBox").style.color="green",document.getElementById("messageBox").innerHTML=t),""},dicErrorMessage:function(t){return t&&(document.getElementById("messageBox").style.color="red",document.getElementById("messageBox").innerHTML=t),""},removeMessage:function(){this.dicEmptyMessage()},manageCommandButtons:{create:function(){var e=tinymce.plugins.SCAYT.getScayt(t),n=i.getLang("dic_err_dic_create","The Dictionary %s cannot be created"),a=i.getLang("dic_succ_dic_create","The Dictionary %s has been successfully created");e.createUserDictionary(r.getDictionaryName(),function(t){r.initDictionaryNameAndButtons(t.name),t.error?(r.setDictionaryButtons(),n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicErrorMessage(n)):(r.setDictionaryButtons(),a=a.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicSuccessMessage(a))},function(t){n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicErrorMessage(n)})},restore:function(){var e=tinymce.plugins.SCAYT.getScayt(t),n=i.getLang("dic_err_dic_restore","The Dictionary %s cannot be restored"),a=i.getLang("dic_succ_dic_restore","The Dictionary %s has been successfully restored");e.restoreUserDictionary(r.getDictionaryName(),function(t){r.initDictionaryNameAndButtons(t.name),t.error?(r.setDictionaryButtons(),n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicErrorMessage(n)):(r.setDictionaryButtons(),a=a.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicSuccessMessage(a))},function(t){n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicErrorMessage(n)})},rename:function(){var e=tinymce.plugins.SCAYT.getScayt(t),n=i.getLang("dic_err_dic_rename","The Dictionary %s cannot be renamed"),a=i.getLang("dic_succ_dic_rename","The Dictionary %s has been successfully renamed");e.renameUserDictionary(r.getDictionaryName(),function(t){r.initDictionaryNameAndButtons(t.name),t.error?(n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicErrorMessage(n)):(r.setDictionaryButtons(),a=a.replace("%s",'"'+r.getDictionaryName()+'"'),r.setDictionaryName(r.getDictionaryName()),r.dicSuccessMessage(a))},function(t){n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.setDictionaryName(r.getDictionaryName()),r.dicErrorMessage(n)})},remove:function(){var e=tinymce.plugins.SCAYT.getScayt(t),n=i.getLang("dic_err_dic_remove","The Dictionary %s cannot be removed"),a=i.getLang("dic_succ_dic_remove","The Dictionary %s has been successfully removed");e.removeUserDictionary(r.getDictionaryName(),function(t){r.resetDictionaryName(),r.initDictionaryNameAndButtons(r.getDictionaryName()),t.error?(n=n.replace("%s",'"'+t.name+'"'),r.dicErrorMessage(n)):(r.setDictionaryButtons(),a=a.replace("%s",'"'+t.name+'"'),r.dicSuccessMessage(a))},function(t){n=n.replace("%s",'"'+r.getDictionaryName()+'"'),r.dicErrorMessage(n)})}},getDictionaryName:function(){return this.definitionDataControl.getInstances("dic_textarea").value()},setDictionaryName:function(t){var e=this;return t=t||"",e.initDictionaryNameAndButtons(t)},resetDictionaryName:function(t){var e=this;return t=t||"",e.definitionDataControl.getInstances("dic_textarea").value(t)},definitionWindowDialog:function(t){var e=this,n=[],a=tinymce.each,o=null,s=t,c=tinymce.plugins.SCAYT,u=s.settings.scayt_uiTabs,g=r.generateLanguagesCheckbox(c.getLanguages(s),c.getCurrentLanguage(s)),l=r.dividedLanguagesCheckbox(g);return o=[{title:i.getLang("tab_options","Options"),type:"form",role:"scayt_options",identification:"options",minWidth:450,minHeight:300,defaults:{type:"checkbox",role:"checkbox",style:"overflow: hidden; cursor: pointer;"},items:r.generateOptionsCheckbox(c.getOptions(s))},{title:i.getLang("tab_languages","Languages"),type:"form",pack:"start",role:"scayt_language",identification:"language",items:[{type:"container",role:"container",layout:"grid",id:"langHolder",name:"langHolder",packV:"start",columns:2,spacing:10,alignH:["50%","50%"],items:[{type:"container",id:"leftCol",name:"leftCol",layout:"grid",role:"container",columns:1,spacing:10,defaults:{type:"radio",role:"radio",label:" ",style:"overflow: hidden; cursor: pointer;"},items:l[0]},{type:"container",id:"rightCol",name:"rightCol",layout:"grid",role:"container",columns:1,spacing:10,defaults:{type:"radio",role:"radio",label:" ",style:"overflow: hidden; cursor: pointer;"},items:l[1]}],onClick:function(t){var e,n,a,o,i,s,c=t.control;if(t&&"container"!=c.aria("role")){i=(e=c.parents("#langHolder")[0]).find("#leftCol")[0],s=e.find("#rightCol")[0],n=i.toJSON(),a=s.toJSON(),o=tinymce.extend(n,a);for(var u in o)o[u]=!1;o[c.aria("role")]=!0,r.langState.selectLang=c.aria("role"),i.fromJSON(o),s.fromJSON(o)}}}]},{title:i.getLang("tab_dictionaries","User dictionaries"),type:"form",pack:"start",role:"scayt_dictionary",identification:"dictionary",items:[{label:i.getLang("dic_dictionary_name","Dictionary Name"),type:"textbox",role:"dic_textbox",value:r.setDictionaryName(c.getUserDictionaryName(s)),onPostRender:function(t){r.definitionDataControl.setInstances(t.control,"dic_textarea")}},{type:"container",role:"container",defaults:{type:"button",role:"button",style:"margin-right: 6px; z-index:2;"},items:r.getDictionaryButtons(),onPostRender:function(t){r.definitionDataControl.setInstances(t.control,"dic_buttons")},onClick:function(t){r.handlerDictionaryButtons(t)}},{type:"fieldset",role:"fieldset",style:"border: none;padding-top: 20px;",html:'<div id="infoBlock" style="white-space: normal;text-align: justify;"><div id="messageBox"></div>'+i.getLang("dic_about_info","Initially a User Dictionary is stored in a cookie. However, cookies are limited in size. When a User Dictionary grows to a point where it cannot be stored in a cookie, the dictionary may be stored on our server. To store your personal dictionary on our server, you should specify a name for it. If you already have a stored dictionary, please type its name and click the Restore button.")+"</div>"}]},{title:i.getLang("tab_about","About SCAYT"),type:"form",role:"scayt_about",identification:"about",items:[{type:"container",role:"container",style:"padding: 10px; min-width: 300px;",html:'<div style="white-space: normal;">'+e.aboutTemplate()+"</div>"}]}],a(o,function(t,e){t.identification&&parseInt(u[e])?n.push(t):"about"==t.identification&&n.push(t)}),n},openDialog:function(e,n,a){var o=this,i=a||0,s=tinymce.plugins.SCAYT.getScayt(e);return e.windowManager.open({title:s.getLocal("text_title"),data:n,minWidth:450,minHeight:300,resizable:"true",role:"tabpanel",bodyType:"tabpanel",onPostRender:function(t){for(var e=this,n=this._id+"-head",a=document.getElementById(n).getElementsByTagName("DIV"),o=a.length-1;o>=0;o--)"mce-title"==a[o].className&&(a[o].style.fontSize="15px");e.items()[0].activateTab(i),e.focus()},onSubmit:function(e){var n=tinymce.plugins.SCAYT.getScayt(t),a=r.getChangedOptions.call(e.data);n.commitOption({changedOptions:a})},body:o.definitionWindowDialog(t)})},aboutTemplate:function(){var e=tinymce.plugins.SCAYT,n=e.getScayt(t);return'<div id="scayt_about" style="padding: 15px;"><img title="logo" alt="logo" src="'+n.getLogo(t)+'" style="padding-bottom: 15px;" /><br />'+n.getLocal("version")+e.getVersion(t)+" <br /><br /> "+n.getLocal("text_copyrights")+"</div>"}};a.init(t),o.createScaytMenuItem()}),tinymce.on("onScaytReady",function(t){tinymce.EditorManager.Editor.prototype.isDirty=function(){var t,e,n=tinymce.plugins.SCAYT.getScayt(this);return n?(t=tinymce.trim(n.removeMarkupFromString(this.startContent)),e=tinymce.trim(n.removeMarkupFromString(this.getContent({format:"raw",no_events:1})))):(t=tinymce.trim(this.startContent),e=tinymce.trim(this.getContent({format:"raw",no_events:1}))),e!=t&&!this.isNotDirty}})}();