mirador_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +13 -0
  7. data/README.md +97 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/mirador_rails.rb +16 -0
  12. data/lib/mirador_rails/version.rb +3 -0
  13. data/lib/mirador_rails/view_helpers.rb +30 -0
  14. data/mirador_rails.gemspec +30 -0
  15. data/vendor/assets/images/border_type_1.png +0 -0
  16. data/vendor/assets/images/border_type_2.png +0 -0
  17. data/vendor/assets/images/border_type_3.png +0 -0
  18. data/vendor/assets/images/debut_dark.png +0 -0
  19. data/vendor/assets/javascripts/mirador.js +1 -0
  20. data/vendor/assets/javascripts/mirador.min.js +88 -0
  21. data/vendor/assets/javascripts/mirador.min.js.map +1 -0
  22. data/vendor/assets/locales/ar/translation.json +42 -0
  23. data/vendor/assets/locales/de/translation.json +77 -0
  24. data/vendor/assets/locales/en/translation.json +82 -0
  25. data/vendor/assets/locales/es/translation.json +35 -0
  26. data/vendor/assets/locales/fr/translation.json +77 -0
  27. data/vendor/assets/locales/ga/translation.json +39 -0
  28. data/vendor/assets/locales/ja/translation.json +82 -0
  29. data/vendor/assets/locales/ko/translation.json +74 -0
  30. data/vendor/assets/locales/nl/translation.json +39 -0
  31. data/vendor/assets/locales/zh-CN/translation.json +74 -0
  32. data/vendor/assets/locales/zh-TW/translation.json +74 -0
  33. data/vendor/assets/locales/zh/translation.json +74 -0
  34. data/vendor/assets/plugins/plugins/advlist/plugin.js +97 -0
  35. data/vendor/assets/plugins/plugins/advlist/plugin.min.js +1 -0
  36. data/vendor/assets/plugins/plugins/anchor/plugin.js +45 -0
  37. data/vendor/assets/plugins/plugins/anchor/plugin.min.js +1 -0
  38. data/vendor/assets/plugins/plugins/autolink/plugin.js +194 -0
  39. data/vendor/assets/plugins/plugins/autolink/plugin.min.js +1 -0
  40. data/vendor/assets/plugins/plugins/autoresize/plugin.js +152 -0
  41. data/vendor/assets/plugins/plugins/autoresize/plugin.min.js +1 -0
  42. data/vendor/assets/plugins/plugins/autosave/plugin.js +165 -0
  43. data/vendor/assets/plugins/plugins/autosave/plugin.min.js +1 -0
  44. data/vendor/assets/plugins/plugins/bbcode/plugin.js +123 -0
  45. data/vendor/assets/plugins/plugins/bbcode/plugin.min.js +1 -0
  46. data/vendor/assets/plugins/plugins/charmap/plugin.js +370 -0
  47. data/vendor/assets/plugins/plugins/charmap/plugin.min.js +1 -0
  48. data/vendor/assets/plugins/plugins/code/plugin.js +60 -0
  49. data/vendor/assets/plugins/plugins/code/plugin.min.js +1 -0
  50. data/vendor/assets/plugins/plugins/colorpicker/plugin.js +112 -0
  51. data/vendor/assets/plugins/plugins/colorpicker/plugin.min.js +1 -0
  52. data/vendor/assets/plugins/plugins/compat3x/css/dialog.css +118 -0
  53. data/vendor/assets/plugins/plugins/compat3x/img/buttons.png +0 -0
  54. data/vendor/assets/plugins/plugins/compat3x/img/icons.gif +0 -0
  55. data/vendor/assets/plugins/plugins/compat3x/img/items.gif +0 -0
  56. data/vendor/assets/plugins/plugins/compat3x/img/menu_arrow.gif +0 -0
  57. data/vendor/assets/plugins/plugins/compat3x/img/menu_check.gif +0 -0
  58. data/vendor/assets/plugins/plugins/compat3x/img/progress.gif +0 -0
  59. data/vendor/assets/plugins/plugins/compat3x/img/tabs.gif +0 -0
  60. data/vendor/assets/plugins/plugins/compat3x/plugin.js +297 -0
  61. data/vendor/assets/plugins/plugins/compat3x/plugin.min.js +1 -0
  62. data/vendor/assets/plugins/plugins/compat3x/tiny_mce_popup.js +542 -0
  63. data/vendor/assets/plugins/plugins/compat3x/utils/editable_selects.js +70 -0
  64. data/vendor/assets/plugins/plugins/compat3x/utils/form_utils.js +210 -0
  65. data/vendor/assets/plugins/plugins/compat3x/utils/mctabs.js +164 -0
  66. data/vendor/assets/plugins/plugins/compat3x/utils/validate.js +252 -0
  67. data/vendor/assets/plugins/plugins/contextmenu/plugin.js +87 -0
  68. data/vendor/assets/plugins/plugins/contextmenu/plugin.min.js +1 -0
  69. data/vendor/assets/plugins/plugins/directionality/plugin.js +64 -0
  70. data/vendor/assets/plugins/plugins/directionality/plugin.min.js +1 -0
  71. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cool.gif +0 -0
  72. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cry.gif +0 -0
  73. data/vendor/assets/plugins/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  74. data/vendor/assets/plugins/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  75. data/vendor/assets/plugins/plugins/emoticons/img/smiley-frown.gif +0 -0
  76. data/vendor/assets/plugins/plugins/emoticons/img/smiley-innocent.gif +0 -0
  77. data/vendor/assets/plugins/plugins/emoticons/img/smiley-kiss.gif +0 -0
  78. data/vendor/assets/plugins/plugins/emoticons/img/smiley-laughing.gif +0 -0
  79. data/vendor/assets/plugins/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  80. data/vendor/assets/plugins/plugins/emoticons/img/smiley-sealed.gif +0 -0
  81. data/vendor/assets/plugins/plugins/emoticons/img/smiley-smile.gif +0 -0
  82. data/vendor/assets/plugins/plugins/emoticons/img/smiley-surprised.gif +0 -0
  83. data/vendor/assets/plugins/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  84. data/vendor/assets/plugins/plugins/emoticons/img/smiley-undecided.gif +0 -0
  85. data/vendor/assets/plugins/plugins/emoticons/img/smiley-wink.gif +0 -0
  86. data/vendor/assets/plugins/plugins/emoticons/img/smiley-yell.gif +0 -0
  87. data/vendor/assets/plugins/plugins/emoticons/plugin.js +65 -0
  88. data/vendor/assets/plugins/plugins/emoticons/plugin.min.js +1 -0
  89. data/vendor/assets/plugins/plugins/example/dialog.html +8 -0
  90. data/vendor/assets/plugins/plugins/example/plugin.js +68 -0
  91. data/vendor/assets/plugins/plugins/example/plugin.min.js +1 -0
  92. data/vendor/assets/plugins/plugins/example_dependency/plugin.js +22 -0
  93. data/vendor/assets/plugins/plugins/example_dependency/plugin.min.js +1 -0
  94. data/vendor/assets/plugins/plugins/fullpage/plugin.js +490 -0
  95. data/vendor/assets/plugins/plugins/fullpage/plugin.min.js +1 -0
  96. data/vendor/assets/plugins/plugins/fullscreen/plugin.js +136 -0
  97. data/vendor/assets/plugins/plugins/fullscreen/plugin.min.js +1 -0
  98. data/vendor/assets/plugins/plugins/hr/plugin.js +30 -0
  99. data/vendor/assets/plugins/plugins/hr/plugin.min.js +1 -0
  100. data/vendor/assets/plugins/plugins/image/plugin.js +439 -0
  101. data/vendor/assets/plugins/plugins/image/plugin.min.js +1 -0
  102. data/vendor/assets/plugins/plugins/importcss/plugin.js +195 -0
  103. data/vendor/assets/plugins/plugins/importcss/plugin.min.js +1 -0
  104. data/vendor/assets/plugins/plugins/insertdatetime/plugin.js +121 -0
  105. data/vendor/assets/plugins/plugins/insertdatetime/plugin.min.js +1 -0
  106. data/vendor/assets/plugins/plugins/layer/plugin.js +225 -0
  107. data/vendor/assets/plugins/plugins/layer/plugin.min.js +1 -0
  108. data/vendor/assets/plugins/plugins/legacyoutput/plugin.js +211 -0
  109. data/vendor/assets/plugins/plugins/legacyoutput/plugin.min.js +1 -0
  110. data/vendor/assets/plugins/plugins/link/plugin.js +400 -0
  111. data/vendor/assets/plugins/plugins/link/plugin.min.js +1 -0
  112. data/vendor/assets/plugins/plugins/lists/plugin.js +791 -0
  113. data/vendor/assets/plugins/plugins/lists/plugin.min.js +1 -0
  114. data/vendor/assets/plugins/plugins/media/moxieplayer.swf +0 -0
  115. data/vendor/assets/plugins/plugins/media/plugin.js +774 -0
  116. data/vendor/assets/plugins/plugins/media/plugin.min.js +1 -0
  117. data/vendor/assets/plugins/plugins/nonbreaking/plugin.js +53 -0
  118. data/vendor/assets/plugins/plugins/nonbreaking/plugin.min.js +1 -0
  119. data/vendor/assets/plugins/plugins/noneditable/plugin.js +540 -0
  120. data/vendor/assets/plugins/plugins/noneditable/plugin.min.js +1 -0
  121. data/vendor/assets/plugins/plugins/pagebreak/plugin.js +88 -0
  122. data/vendor/assets/plugins/plugins/pagebreak/plugin.min.js +1 -0
  123. data/vendor/assets/plugins/plugins/paste/classes/Clipboard.js +634 -0
  124. data/vendor/assets/plugins/plugins/paste/classes/Plugin.js +110 -0
  125. data/vendor/assets/plugins/plugins/paste/classes/Quirks.js +159 -0
  126. data/vendor/assets/plugins/plugins/paste/classes/Utils.js +130 -0
  127. data/vendor/assets/plugins/plugins/paste/classes/WordFilter.js +493 -0
  128. data/vendor/assets/plugins/plugins/paste/plugin.dev.js +120 -0
  129. data/vendor/assets/plugins/plugins/paste/plugin.js +1625 -0
  130. data/vendor/assets/plugins/plugins/paste/plugin.min.js +1 -0
  131. data/vendor/assets/plugins/plugins/preview/plugin.js +88 -0
  132. data/vendor/assets/plugins/plugins/preview/plugin.min.js +1 -0
  133. data/vendor/assets/plugins/plugins/print/plugin.js +32 -0
  134. data/vendor/assets/plugins/plugins/print/plugin.min.js +1 -0
  135. data/vendor/assets/plugins/plugins/save/plugin.js +94 -0
  136. data/vendor/assets/plugins/plugins/save/plugin.min.js +1 -0
  137. data/vendor/assets/plugins/plugins/searchreplace/plugin.js +594 -0
  138. data/vendor/assets/plugins/plugins/searchreplace/plugin.min.js +1 -0
  139. data/vendor/assets/plugins/plugins/spellchecker/classes/DomTextMatcher.js +470 -0
  140. data/vendor/assets/plugins/plugins/spellchecker/classes/Plugin.js +436 -0
  141. data/vendor/assets/plugins/plugins/spellchecker/plugin.dev.js +117 -0
  142. data/vendor/assets/plugins/plugins/spellchecker/plugin.js +996 -0
  143. data/vendor/assets/plugins/plugins/spellchecker/plugin.min.js +1 -0
  144. data/vendor/assets/plugins/plugins/tabfocus/plugin.js +120 -0
  145. data/vendor/assets/plugins/plugins/tabfocus/plugin.min.js +1 -0
  146. data/vendor/assets/plugins/plugins/table/classes/CellSelection.js +176 -0
  147. data/vendor/assets/plugins/plugins/table/classes/Dialogs.js +749 -0
  148. data/vendor/assets/plugins/plugins/table/classes/Plugin.js +422 -0
  149. data/vendor/assets/plugins/plugins/table/classes/Quirks.js +372 -0
  150. data/vendor/assets/plugins/plugins/table/classes/TableGrid.js +864 -0
  151. data/vendor/assets/plugins/plugins/table/plugin.dev.js +118 -0
  152. data/vendor/assets/plugins/plugins/table/plugin.js +2680 -0
  153. data/vendor/assets/plugins/plugins/table/plugin.min.js +1 -0
  154. data/vendor/assets/plugins/plugins/template/plugin.js +262 -0
  155. data/vendor/assets/plugins/plugins/template/plugin.min.js +1 -0
  156. data/vendor/assets/plugins/plugins/textcolor/plugin.js +272 -0
  157. data/vendor/assets/plugins/plugins/textcolor/plugin.min.js +1 -0
  158. data/vendor/assets/plugins/plugins/textpattern/plugin.js +268 -0
  159. data/vendor/assets/plugins/plugins/textpattern/plugin.min.js +1 -0
  160. data/vendor/assets/plugins/plugins/visualblocks/css/visualblocks.css +135 -0
  161. data/vendor/assets/plugins/plugins/visualblocks/img/address.gif +0 -0
  162. data/vendor/assets/plugins/plugins/visualblocks/img/article.gif +0 -0
  163. data/vendor/assets/plugins/plugins/visualblocks/img/aside.gif +0 -0
  164. data/vendor/assets/plugins/plugins/visualblocks/img/blockquote.gif +0 -0
  165. data/vendor/assets/plugins/plugins/visualblocks/img/div.gif +0 -0
  166. data/vendor/assets/plugins/plugins/visualblocks/img/dl.gif +0 -0
  167. data/vendor/assets/plugins/plugins/visualblocks/img/figure.gif +0 -0
  168. data/vendor/assets/plugins/plugins/visualblocks/img/h1.gif +0 -0
  169. data/vendor/assets/plugins/plugins/visualblocks/img/h2.gif +0 -0
  170. data/vendor/assets/plugins/plugins/visualblocks/img/h3.gif +0 -0
  171. data/vendor/assets/plugins/plugins/visualblocks/img/h4.gif +0 -0
  172. data/vendor/assets/plugins/plugins/visualblocks/img/h5.gif +0 -0
  173. data/vendor/assets/plugins/plugins/visualblocks/img/h6.gif +0 -0
  174. data/vendor/assets/plugins/plugins/visualblocks/img/hgroup.gif +0 -0
  175. data/vendor/assets/plugins/plugins/visualblocks/img/ol.gif +0 -0
  176. data/vendor/assets/plugins/plugins/visualblocks/img/p.gif +0 -0
  177. data/vendor/assets/plugins/plugins/visualblocks/img/pre.gif +0 -0
  178. data/vendor/assets/plugins/plugins/visualblocks/img/section.gif +0 -0
  179. data/vendor/assets/plugins/plugins/visualblocks/img/ul.gif +0 -0
  180. data/vendor/assets/plugins/plugins/visualblocks/plugin.js +86 -0
  181. data/vendor/assets/plugins/plugins/visualblocks/plugin.min.js +1 -0
  182. data/vendor/assets/plugins/plugins/visualchars/plugin.js +88 -0
  183. data/vendor/assets/plugins/plugins/visualchars/plugin.min.js +1 -0
  184. data/vendor/assets/plugins/plugins/wordcount/plugin.js +69 -0
  185. data/vendor/assets/plugins/plugins/wordcount/plugin.min.js +1 -0
  186. data/vendor/assets/skins/skins/lightgray/content.inline.min.css +1 -0
  187. data/vendor/assets/skins/skins/lightgray/content.min.css +1 -0
  188. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.eot +0 -0
  189. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.svg +62 -0
  190. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  191. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.woff +0 -0
  192. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.eot +0 -0
  193. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.svg +63 -0
  194. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.ttf +0 -0
  195. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.woff +0 -0
  196. data/vendor/assets/skins/skins/lightgray/img/anchor.gif +0 -0
  197. data/vendor/assets/skins/skins/lightgray/img/loader.gif +0 -0
  198. data/vendor/assets/skins/skins/lightgray/img/object.gif +0 -0
  199. data/vendor/assets/skins/skins/lightgray/img/trans.gif +0 -0
  200. data/vendor/assets/skins/skins/lightgray/skin.ie7.min.css +1 -0
  201. data/vendor/assets/skins/skins/lightgray/skin.min.css +1 -0
  202. data/vendor/assets/stylesheets/mirador-combined.css +3969 -0
  203. data/vendor/assets/stylesheets/mirador.css +11 -0
  204. data/vendor/assets/themes/themes/modern/theme.js +617 -0
  205. data/vendor/assets/themes/themes/modern/theme.min.js +1 -0
  206. metadata +318 -0
@@ -0,0 +1,436 @@
1
+ /**
2
+ * Plugin.js
3
+ *
4
+ * Copyright, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://www.tinymce.com/license
8
+ * Contributing: http://www.tinymce.com/contributing
9
+ */
10
+
11
+ /*jshint camelcase:false */
12
+
13
+ /**
14
+ * This class contains all core logic for the spellchecker plugin.
15
+ *
16
+ * @class tinymce.spellcheckerplugin.Plugin
17
+ * @private
18
+ */
19
+ define("tinymce/spellcheckerplugin/Plugin", [
20
+ "tinymce/spellcheckerplugin/DomTextMatcher",
21
+ "tinymce/PluginManager",
22
+ "tinymce/util/Tools",
23
+ "tinymce/ui/Menu",
24
+ "tinymce/dom/DOMUtils",
25
+ "tinymce/util/XHR",
26
+ "tinymce/util/URI",
27
+ "tinymce/util/JSON"
28
+ ], function(DomTextMatcher, PluginManager, Tools, Menu, DOMUtils, XHR, URI, JSON) {
29
+ PluginManager.add('spellchecker', function(editor, url) {
30
+ var languageMenuItems, self = this, lastSuggestions, started, suggestionsMenu, settings = editor.settings;
31
+ var hasDictionarySupport;
32
+
33
+ function getTextMatcher() {
34
+ if (!self.textMatcher) {
35
+ self.textMatcher = new DomTextMatcher(editor.getBody(), editor);
36
+ }
37
+
38
+ return self.textMatcher;
39
+ }
40
+
41
+ function buildMenuItems(listName, languageValues) {
42
+ var items = [];
43
+
44
+ Tools.each(languageValues, function(languageValue) {
45
+ items.push({
46
+ selectable: true,
47
+ text: languageValue.name,
48
+ data: languageValue.value
49
+ });
50
+ });
51
+
52
+ return items;
53
+ }
54
+
55
+ var languagesString = settings.spellchecker_languages ||
56
+ 'English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,' +
57
+ 'German=de,Italian=it,Polish=pl,Portuguese=pt_BR,' +
58
+ 'Spanish=es,Swedish=sv';
59
+
60
+ languageMenuItems = buildMenuItems('Language',
61
+ Tools.map(languagesString.split(','), function(langPair) {
62
+ langPair = langPair.split('=');
63
+
64
+ return {
65
+ name: langPair[0],
66
+ value: langPair[1]
67
+ };
68
+ })
69
+ );
70
+
71
+ function isEmpty(obj) {
72
+ /*jshint unused:false*/
73
+ /*eslint no-unused-vars:0 */
74
+ for (var name in obj) {
75
+ return false;
76
+ }
77
+
78
+ return true;
79
+ }
80
+
81
+ function showSuggestions(word, spans) {
82
+ var items = [], suggestions = lastSuggestions[word];
83
+
84
+ Tools.each(suggestions, function(suggestion) {
85
+ items.push({
86
+ text: suggestion,
87
+ onclick: function() {
88
+ editor.insertContent(editor.dom.encode(suggestion));
89
+ editor.dom.remove(spans);
90
+ checkIfFinished();
91
+ }
92
+ });
93
+ });
94
+
95
+ items.push({text: '-'});
96
+
97
+ if (hasDictionarySupport) {
98
+ items.push({text: 'Add to Dictionary', onclick: function() {
99
+ addToDictionary(word, spans);
100
+ }});
101
+ }
102
+
103
+ items.push.apply(items, [
104
+ {text: 'Ignore', onclick: function() {
105
+ ignoreWord(word, spans);
106
+ }},
107
+
108
+ {text: 'Ignore all', onclick: function() {
109
+ ignoreWord(word, spans, true);
110
+ }}
111
+ ]);
112
+
113
+ // Render menu
114
+ suggestionsMenu = new Menu({
115
+ items: items,
116
+ context: 'contextmenu',
117
+ onautohide: function(e) {
118
+ if (e.target.className.indexOf('spellchecker') != -1) {
119
+ e.preventDefault();
120
+ }
121
+ },
122
+ onhide: function() {
123
+ suggestionsMenu.remove();
124
+ suggestionsMenu = null;
125
+ }
126
+ });
127
+
128
+ suggestionsMenu.renderTo(document.body);
129
+
130
+ // Position menu
131
+ var pos = DOMUtils.DOM.getPos(editor.getContentAreaContainer());
132
+ var targetPos = editor.dom.getPos(spans[0]);
133
+ var root = editor.dom.getRoot();
134
+
135
+ // Adjust targetPos for scrolling in the editor
136
+ if (root.nodeName == 'BODY') {
137
+ targetPos.x -= root.ownerDocument.documentElement.scrollLeft || root.scrollLeft;
138
+ targetPos.y -= root.ownerDocument.documentElement.scrollTop || root.scrollTop;
139
+ } else {
140
+ targetPos.x -= root.scrollLeft;
141
+ targetPos.y -= root.scrollTop;
142
+ }
143
+
144
+ pos.x += targetPos.x;
145
+ pos.y += targetPos.y;
146
+
147
+ suggestionsMenu.moveTo(pos.x, pos.y + spans[0].offsetHeight);
148
+ }
149
+
150
+ function getWordCharPattern() {
151
+ // Regexp for finding word specific characters this will split words by
152
+ // spaces, quotes, copy right characters etc. It's escaped with unicode characters
153
+ // to make it easier to output scripts on servers using different encodings
154
+ // so if you add any characters outside the 128 byte range make sure to escape it
155
+ return editor.getParam('spellchecker_wordchar_pattern') || new RegExp("[^" +
156
+ "\\s!\"#$%&()*+,-./:;<=>?@[\\]^_{|}`" +
157
+ "\u00a7\u00a9\u00ab\u00ae\u00b1\u00b6\u00b7\u00b8\u00bb" +
158
+ "\u00bc\u00bd\u00be\u00bf\u00d7\u00f7\u00a4\u201d\u201c\u201e\u00a0\u2002\u2003\u2009" +
159
+ "]+", "g");
160
+ }
161
+
162
+ function defaultSpellcheckCallback(method, text, doneCallback, errorCallback) {
163
+ var data = {method: method}, postData = '';
164
+
165
+ if (method == "spellcheck") {
166
+ data.text = text;
167
+ data.lang = settings.spellchecker_language;
168
+ }
169
+
170
+ if (method == "addToDictionary") {
171
+ data.word = text;
172
+ }
173
+
174
+ Tools.each(data, function(value, key) {
175
+ if (postData) {
176
+ postData += '&';
177
+ }
178
+
179
+ postData += key + '=' + encodeURIComponent(value);
180
+ });
181
+
182
+ XHR.send({
183
+ url: new URI(url).toAbsolute(settings.spellchecker_rpc_url),
184
+ type: "post",
185
+ content_type: 'application/x-www-form-urlencoded',
186
+ data: postData,
187
+ success: function(result) {
188
+ result = JSON.parse(result);
189
+
190
+ if (!result) {
191
+ errorCallback("Sever response wasn't proper JSON.");
192
+ } else if (result.error) {
193
+ errorCallback(result.error);
194
+ } else {
195
+ doneCallback(result);
196
+ }
197
+ },
198
+ error: function(type, xhr) {
199
+ errorCallback("Spellchecker request error: " + xhr.status);
200
+ }
201
+ });
202
+ }
203
+
204
+ function sendRpcCall(name, data, successCallback, errorCallback) {
205
+ var spellCheckCallback = settings.spellchecker_callback || defaultSpellcheckCallback;
206
+ spellCheckCallback.call(self, name, data, successCallback, errorCallback);
207
+ }
208
+
209
+ function spellcheck() {
210
+ if (started) {
211
+ finish();
212
+ return;
213
+ } else {
214
+ finish();
215
+ }
216
+
217
+ function errorCallback(message) {
218
+ editor.windowManager.alert(message);
219
+ editor.setProgressState(false);
220
+ finish();
221
+ }
222
+
223
+ editor.setProgressState(true);
224
+ sendRpcCall("spellcheck", getTextMatcher().text, markErrors, errorCallback);
225
+ editor.focus();
226
+ }
227
+
228
+ function checkIfFinished() {
229
+ if (!editor.dom.select('span.mce-spellchecker-word').length) {
230
+ finish();
231
+ }
232
+ }
233
+
234
+ function addToDictionary(word, spans) {
235
+ editor.setProgressState(true);
236
+
237
+ sendRpcCall("addToDictionary", word, function() {
238
+ editor.setProgressState(false);
239
+ editor.dom.remove(spans, true);
240
+ checkIfFinished();
241
+ }, function(message) {
242
+ editor.windowManager.alert(message);
243
+ editor.setProgressState(false);
244
+ });
245
+ }
246
+
247
+ function ignoreWord(word, spans, all) {
248
+ editor.selection.collapse();
249
+
250
+ if (all) {
251
+ Tools.each(editor.dom.select('span.mce-spellchecker-word'), function(span) {
252
+ if (span.getAttribute('data-mce-word') == word) {
253
+ editor.dom.remove(span, true);
254
+ }
255
+ });
256
+ } else {
257
+ editor.dom.remove(spans, true);
258
+ }
259
+
260
+ checkIfFinished();
261
+ }
262
+
263
+ function finish() {
264
+ getTextMatcher().reset();
265
+ self.textMatcher = null;
266
+
267
+ if (started) {
268
+ started = false;
269
+ editor.fire('SpellcheckEnd');
270
+ }
271
+ }
272
+
273
+ function getElmIndex(elm) {
274
+ var value = elm.getAttribute('data-mce-index');
275
+
276
+ if (typeof(value) == "number") {
277
+ return "" + value;
278
+ }
279
+
280
+ return value;
281
+ }
282
+
283
+ function findSpansByIndex(index) {
284
+ var nodes, spans = [];
285
+
286
+ nodes = Tools.toArray(editor.getBody().getElementsByTagName('span'));
287
+ if (nodes.length) {
288
+ for (var i = 0; i < nodes.length; i++) {
289
+ var nodeIndex = getElmIndex(nodes[i]);
290
+
291
+ if (nodeIndex === null || !nodeIndex.length) {
292
+ continue;
293
+ }
294
+
295
+ if (nodeIndex === index.toString()) {
296
+ spans.push(nodes[i]);
297
+ }
298
+ }
299
+ }
300
+
301
+ return spans;
302
+ }
303
+
304
+ editor.on('click', function(e) {
305
+ var target = e.target;
306
+
307
+ if (target.className == "mce-spellchecker-word") {
308
+ e.preventDefault();
309
+
310
+ var spans = findSpansByIndex(getElmIndex(target));
311
+
312
+ if (spans.length > 0) {
313
+ var rng = editor.dom.createRng();
314
+ rng.setStartBefore(spans[0]);
315
+ rng.setEndAfter(spans[spans.length - 1]);
316
+ editor.selection.setRng(rng);
317
+ showSuggestions(target.getAttribute('data-mce-word'), spans);
318
+ }
319
+ }
320
+ });
321
+
322
+ editor.addMenuItem('spellchecker', {
323
+ text: 'Spellcheck',
324
+ context: 'tools',
325
+ onclick: spellcheck,
326
+ selectable: true,
327
+ onPostRender: function() {
328
+ var self = this;
329
+
330
+ self.active(started);
331
+
332
+ editor.on('SpellcheckStart SpellcheckEnd', function() {
333
+ self.active(started);
334
+ });
335
+ }
336
+ });
337
+
338
+ function updateSelection(e) {
339
+ var selectedLanguage = settings.spellchecker_language;
340
+
341
+ e.control.items().each(function(ctrl) {
342
+ ctrl.active(ctrl.settings.data === selectedLanguage);
343
+ });
344
+ }
345
+
346
+ /**
347
+ * Find the specified words and marks them. It will also show suggestions for those words.
348
+ *
349
+ * @example
350
+ * editor.plugins.spellchecker.markErrors({
351
+ * dictionary: true,
352
+ * words: {
353
+ * "word1": ["suggestion 1", "Suggestion 2"]
354
+ * }
355
+ * });
356
+ * @param {Object} data Data object containing the words with suggestions.
357
+ */
358
+ function markErrors(data) {
359
+ var suggestions;
360
+
361
+ if (data.words) {
362
+ hasDictionarySupport = !!data.dictionary;
363
+ suggestions = data.words;
364
+ } else {
365
+ // Fallback to old format
366
+ suggestions = data;
367
+ }
368
+
369
+ editor.setProgressState(false);
370
+
371
+ if (isEmpty(suggestions)) {
372
+ editor.windowManager.alert('No misspellings found');
373
+ started = false;
374
+ return;
375
+ }
376
+
377
+ lastSuggestions = suggestions;
378
+
379
+ getTextMatcher().find(getWordCharPattern()).filter(function(match) {
380
+ return !!suggestions[match.text];
381
+ }).wrap(function(match) {
382
+ return editor.dom.create('span', {
383
+ "class": 'mce-spellchecker-word',
384
+ "data-mce-bogus": 1,
385
+ "data-mce-word": match.text
386
+ });
387
+ });
388
+
389
+ started = true;
390
+ editor.fire('SpellcheckStart');
391
+ }
392
+
393
+ var buttonArgs = {
394
+ tooltip: 'Spellcheck',
395
+ onclick: spellcheck,
396
+ onPostRender: function() {
397
+ var self = this;
398
+
399
+ editor.on('SpellcheckStart SpellcheckEnd', function() {
400
+ self.active(started);
401
+ });
402
+ }
403
+ };
404
+
405
+ if (languageMenuItems.length > 1) {
406
+ buttonArgs.type = 'splitbutton';
407
+ buttonArgs.menu = languageMenuItems;
408
+ buttonArgs.onshow = updateSelection;
409
+ buttonArgs.onselect = function(e) {
410
+ settings.spellchecker_language = e.control.settings.data;
411
+ };
412
+ }
413
+
414
+ editor.addButton('spellchecker', buttonArgs);
415
+ editor.addCommand('mceSpellCheck', spellcheck);
416
+
417
+ editor.on('remove', function() {
418
+ if (suggestionsMenu) {
419
+ suggestionsMenu.remove();
420
+ suggestionsMenu = null;
421
+ }
422
+ });
423
+
424
+ editor.on('change', checkIfFinished);
425
+
426
+ this.getTextMatcher = getTextMatcher;
427
+ this.getWordCharPattern = getWordCharPattern;
428
+ this.markErrors = markErrors;
429
+ this.getLanguage = function() {
430
+ return settings.spellchecker_language;
431
+ };
432
+
433
+ // Set default spellchecker language if it's not specified
434
+ settings.spellchecker_language = settings.spellchecker_language || settings.language || 'en';
435
+ });
436
+ });
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Inline development version. Only to be used while developing since it uses document.write to load scripts.
3
+ */
4
+
5
+ /*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
6
+ /*globals $code */
7
+
8
+ (function(exports) {
9
+ "use strict";
10
+
11
+ var html = "", baseDir;
12
+ var modules = {}, exposedModules = [], moduleCount = 0;
13
+
14
+ var scripts = document.getElementsByTagName('script');
15
+ for (var i = 0; i < scripts.length; i++) {
16
+ var src = scripts[i].src;
17
+
18
+ if (src.indexOf('/plugin.dev.js') != -1) {
19
+ baseDir = src.substring(0, src.lastIndexOf('/'));
20
+ }
21
+ }
22
+
23
+ function require(ids, callback) {
24
+ var module, defs = [];
25
+
26
+ for (var i = 0; i < ids.length; ++i) {
27
+ module = modules[ids[i]] || resolve(ids[i]);
28
+ if (!module) {
29
+ throw 'module definition dependecy not found: ' + ids[i];
30
+ }
31
+
32
+ defs.push(module);
33
+ }
34
+
35
+ callback.apply(null, defs);
36
+ }
37
+
38
+ function resolve(id) {
39
+ var target = exports;
40
+ var fragments = id.split(/[.\/]/);
41
+
42
+ for (var fi = 0; fi < fragments.length; ++fi) {
43
+ if (!target[fragments[fi]]) {
44
+ return;
45
+ }
46
+
47
+ target = target[fragments[fi]];
48
+ }
49
+
50
+ return target;
51
+ }
52
+
53
+ function register(id) {
54
+ var target = exports;
55
+ var fragments = id.split(/[.\/]/);
56
+
57
+ for (var fi = 0; fi < fragments.length - 1; ++fi) {
58
+ if (target[fragments[fi]] === undefined) {
59
+ target[fragments[fi]] = {};
60
+ }
61
+
62
+ target = target[fragments[fi]];
63
+ }
64
+
65
+ target[fragments[fragments.length - 1]] = modules[id];
66
+ }
67
+
68
+ function define(id, dependencies, definition) {
69
+ if (typeof id !== 'string') {
70
+ throw 'invalid module definition, module id must be defined and be a string';
71
+ }
72
+
73
+ if (dependencies === undefined) {
74
+ throw 'invalid module definition, dependencies must be specified';
75
+ }
76
+
77
+ if (definition === undefined) {
78
+ throw 'invalid module definition, definition function must be specified';
79
+ }
80
+
81
+ require(dependencies, function() {
82
+ modules[id] = definition.apply(null, arguments);
83
+ });
84
+
85
+ if (--moduleCount === 0) {
86
+ for (var i = 0; i < exposedModules.length; i++) {
87
+ register(exposedModules[i]);
88
+ }
89
+ }
90
+ }
91
+
92
+ function expose(ids) {
93
+ exposedModules = ids;
94
+ }
95
+
96
+ function writeScripts() {
97
+ document.write(html);
98
+ }
99
+
100
+ function load(path) {
101
+ html += '<script type="text/javascript" src="' + baseDir + '/' + path + '"></script>\n';
102
+ moduleCount++;
103
+ }
104
+
105
+ // Expose globally
106
+ exports.define = define;
107
+ exports.require = require;
108
+
109
+ expose(["tinymce/spellcheckerplugin/DomTextMatcher"]);
110
+
111
+ load('classes/DomTextMatcher.js');
112
+ load('classes/Plugin.js');
113
+
114
+ writeScripts();
115
+ })(this);
116
+
117
+ // $hash: 8869896f1265f5c8b422a19894956678