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 @@
1
+ !function(){function a(a,b,c,d,e){function f(a,b){if(b=b||0,!a[0])throw"findAndReplaceDOMText cannot handle zero-length matches";var c=a.index;if(b>0){var d=a[b];if(!d)throw"Invalid capture group";c+=a[0].indexOf(d),a[0]=d}return[c,c+a[0].length,[a[0]]]}function g(a){var b;if(3===a.nodeType)return a.data;if(n[a.nodeName]&&!m[a.nodeName])return"";if(b="",(m[a.nodeName]||o[a.nodeName])&&(b+="\n"),a=a.firstChild)do b+=g(a);while(a=a.nextSibling);return b}function h(a,b,c){var d,e,f,g,h=[],i=0,j=a,k=b.shift(),l=0;a:for(;;){if((m[j.nodeName]||o[j.nodeName])&&i++,3===j.nodeType&&(!e&&j.length+i>=k[1]?(e=j,g=k[1]-i):d&&h.push(j),!d&&j.length+i>k[0]&&(d=j,f=k[0]-i),i+=j.length),d&&e){if(j=c({startNode:d,startNodeIndex:f,endNode:e,endNodeIndex:g,innerNodes:h,match:k[2],matchIndex:l}),i-=e.length-g,d=null,e=null,h=[],k=b.shift(),l++,!k)break}else{if((!n[j.nodeName]||m[j.nodeName])&&j.firstChild){j=j.firstChild;continue}if(j.nextSibling){j=j.nextSibling;continue}}for(;;){if(j.nextSibling){j=j.nextSibling;break}if(j.parentNode===a)break a;j=j.parentNode}}}function i(a){var b;if("function"!=typeof a){var c=a.nodeType?a:l.createElement(a);b=function(a,b){var d=c.cloneNode(!1);return d.setAttribute("data-mce-index",b),a&&d.appendChild(l.createTextNode(a)),d}}else b=a;return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex;if(f===g){var i=f;e=i.parentNode,a.startNodeIndex>0&&(c=l.createTextNode(i.data.substring(0,a.startNodeIndex)),e.insertBefore(c,i));var j=b(a.match[0],h);return e.insertBefore(j,i),a.endNodeIndex<i.length&&(d=l.createTextNode(i.data.substring(a.endNodeIndex)),e.insertBefore(d,i)),i.parentNode.removeChild(i),j}c=l.createTextNode(f.data.substring(0,a.startNodeIndex)),d=l.createTextNode(g.data.substring(a.endNodeIndex));for(var k=b(f.data.substring(a.startNodeIndex),h),m=[],n=0,o=a.innerNodes.length;o>n;++n){var p=a.innerNodes[n],q=b(p.data,h);p.parentNode.replaceChild(q,p),m.push(q)}var r=b(g.data.substring(0,a.endNodeIndex),h);return e=f.parentNode,e.insertBefore(c,f),e.insertBefore(k,f),e.removeChild(f),e=g.parentNode,e.insertBefore(r,g),e.insertBefore(d,g),e.removeChild(g),r}}var j,k,l,m,n,o,p=[],q=0;if(l=b.ownerDocument,m=e.getBlockElements(),n=e.getWhiteSpaceElements(),o=e.getShortEndedElements(),k=g(b)){if(a.global)for(;j=a.exec(k);)p.push(f(j,d));else j=k.match(a),p.push(f(j,d));return p.length&&(q=p.length,h(b,p,i(c))),q}}function b(b){function c(){function a(){e.statusbar.find("#next").disabled(!g(k+1).length),e.statusbar.find("#prev").disabled(!g(k-1).length)}function c(){tinymce.ui.MessageBox.alert("Could not find the specified string.",function(){e.find("#find")[0].focus()})}var d={},e=tinymce.ui.Factory.create({type:"window",layout:"flex",pack:"center",align:"center",onClose:function(){b.focus(),j.done()},onSubmit:function(b){var f,h,i,l;return b.preventDefault(),h=e.find("#case").checked(),l=e.find("#words").checked(),i=e.find("#find").value(),i.length?d.text==i&&d.caseState==h&&d.wholeWord==l?0===g(k+1).length?void c():(j.next(),void a()):(f=j.find(i,h,l),f||c(),e.statusbar.items().slice(1).disabled(0===f),a(),void(d={text:i,caseState:h,wholeWord:l})):(j.done(!1),void e.statusbar.items().slice(1).disabled(!0))},buttons:[{text:"Find",onclick:function(){e.submit()}},{text:"Replace",disabled:!0,onclick:function(){j.replace(e.find("#replace").value())||(e.statusbar.items().slice(1).disabled(!0),k=-1,d={})}},{text:"Replace all",disabled:!0,onclick:function(){j.replace(e.find("#replace").value(),!0,!0),e.statusbar.items().slice(1).disabled(!0),d={}}},{type:"spacer",flex:1},{text:"Prev",name:"prev",disabled:!0,onclick:function(){j.prev(),a()}},{text:"Next",name:"next",disabled:!0,onclick:function(){j.next(),a()}}],title:"Find and replace",items:{type:"form",padding:20,labelGap:30,spacing:10,items:[{type:"textbox",name:"find",size:40,label:"Find",value:b.selection.getNode().src},{type:"textbox",name:"replace",size:40,label:"Replace with"},{type:"checkbox",name:"case",text:"Match case",label:" "},{type:"checkbox",name:"words",text:"Whole words",label:" "}]}}).renderTo().reflow()}function d(a){var b=a.getAttribute("data-mce-index");return"number"==typeof b?""+b:b}function e(c){var d,e;return e=b.dom.create("span",{"data-mce-bogus":1}),e.className="mce-match-marker",d=b.getBody(),j.done(!1),a(c,d,e,!1,b.schema)}function f(a){var b=a.parentNode;a.firstChild&&b.insertBefore(a.firstChild,a),a.parentNode.removeChild(a)}function g(a){var c,e=[];if(c=tinymce.toArray(b.getBody().getElementsByTagName("span")),c.length)for(var f=0;f<c.length;f++){var g=d(c[f]);null!==g&&g.length&&g===a.toString()&&e.push(c[f])}return e}function h(a){var c=k,d=b.dom;a=a!==!1,a?c++:c--,d.removeClass(g(k),"mce-match-marker-selected");var e=g(c);return e.length?(d.addClass(g(c),"mce-match-marker-selected"),b.selection.scrollIntoView(e[0]),c):-1}function i(a){a.parentNode.removeChild(a)}var j=this,k=-1;j.init=function(a){a.addMenuItem("searchreplace",{text:"Find and replace",shortcut:"Ctrl+F",onclick:c,separator:"before",context:"edit"}),a.addButton("searchreplace",{tooltip:"Find and replace",shortcut:"Ctrl+F",onclick:c}),a.addCommand("SearchReplace",c),a.shortcuts.add("Ctrl+F","",c)},j.find=function(a,b,c){a=a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),a=c?"\\b"+a+"\\b":a;var d=e(new RegExp(a,b?"g":"gi"));return d&&(k=-1,k=h(!0)),d},j.next=function(){var a=h(!0);-1!==a&&(k=a)},j.prev=function(){var a=h(!1);-1!==a&&(k=a)},j.replace=function(a,c,e){var h,l,m,n,o,p,q=k;for(c=c!==!1,m=b.getBody(),l=tinymce.toArray(m.getElementsByTagName("span")),h=0;h<l.length;h++){var r=d(l[h]);if(null!==r&&r.length)if(n=o=parseInt(r,10),e||n===k){for(a.length?(l[h].firstChild.nodeValue=a,f(l[h])):i(l[h]);l[++h];)if(n=d(l[h]),null!==r&&r.length){if(n!==o){h--;break}i(l[h])}c&&q--}else o>k&&l[h].setAttribute("data-mce-index",o-1)}return b.undoManager.add(),k=q,c?(p=g(q+1).length>0,j.next()):(p=g(q-1).length>0,j.prev()),!e&&p},j.done=function(a){var c,e,g,h;for(e=tinymce.toArray(b.getBody().getElementsByTagName("span")),c=0;c<e.length;c++){var i=d(e[c]);null!==i&&i.length&&(i===k.toString()&&(g||(g=e[c].firstChild),h=e[c].firstChild),f(e[c]))}if(g&&h){var j=b.dom.createRng();return j.setStart(g,0),j.setEnd(h,h.data.length),a!==!1&&b.selection.setRng(j),j}}}tinymce.PluginManager.add("searchreplace",b)}();
@@ -0,0 +1,470 @@
1
+ /**
2
+ * DomTextMatcher.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
+ /*eslint no-labels:0, no-constant-condition: 0 */
12
+
13
+ /**
14
+ * This class logic for filtering text and matching words.
15
+ *
16
+ * @class tinymce.spellcheckerplugin.TextFilter
17
+ * @private
18
+ */
19
+ define("tinymce/spellcheckerplugin/DomTextMatcher", [], function() {
20
+ // Based on work developed by: James Padolsey http://james.padolsey.com
21
+ // released under UNLICENSE that is compatible with LGPL
22
+ // TODO: Handle contentEditable edgecase:
23
+ // <p>text<span contentEditable="false">text<span contentEditable="true">text</span>text</span>text</p>
24
+ return function(node, editor) {
25
+ var m, matches = [], text, dom = editor.dom;
26
+ var blockElementsMap, hiddenTextElementsMap, shortEndedElementsMap;
27
+
28
+ blockElementsMap = editor.schema.getBlockElements(); // H1-H6, P, TD etc
29
+ hiddenTextElementsMap = editor.schema.getWhiteSpaceElements(); // TEXTAREA, PRE, STYLE, SCRIPT
30
+ shortEndedElementsMap = editor.schema.getShortEndedElements(); // BR, IMG, INPUT
31
+
32
+ function createMatch(m, data) {
33
+ if (!m[0]) {
34
+ throw 'findAndReplaceDOMText cannot handle zero-length matches';
35
+ }
36
+
37
+ return {
38
+ start: m.index,
39
+ end: m.index + m[0].length,
40
+ text: m[0],
41
+ data: data
42
+ };
43
+ }
44
+
45
+ function getText(node) {
46
+ var txt;
47
+
48
+ if (node.nodeType === 3) {
49
+ return node.data;
50
+ }
51
+
52
+ if (hiddenTextElementsMap[node.nodeName] && !blockElementsMap[node.nodeName]) {
53
+ return '';
54
+ }
55
+
56
+ txt = '';
57
+
58
+ if (blockElementsMap[node.nodeName] || shortEndedElementsMap[node.nodeName]) {
59
+ txt += '\n';
60
+ }
61
+
62
+ if ((node = node.firstChild)) {
63
+ do {
64
+ txt += getText(node);
65
+ } while ((node = node.nextSibling));
66
+ }
67
+
68
+ return txt;
69
+ }
70
+
71
+ function stepThroughMatches(node, matches, replaceFn) {
72
+ var startNode, endNode, startNodeIndex,
73
+ endNodeIndex, innerNodes = [], atIndex = 0, curNode = node,
74
+ matchLocation, matchIndex = 0;
75
+
76
+ matches = matches.slice(0);
77
+ matches.sort(function(a, b) {
78
+ return a.start - b.start;
79
+ });
80
+
81
+ matchLocation = matches.shift();
82
+
83
+ out: while (true) {
84
+ if (blockElementsMap[curNode.nodeName] || shortEndedElementsMap[curNode.nodeName]) {
85
+ atIndex++;
86
+ }
87
+
88
+ if (curNode.nodeType === 3) {
89
+ if (!endNode && curNode.length + atIndex >= matchLocation.end) {
90
+ // We've found the ending
91
+ endNode = curNode;
92
+ endNodeIndex = matchLocation.end - atIndex;
93
+ } else if (startNode) {
94
+ // Intersecting node
95
+ innerNodes.push(curNode);
96
+ }
97
+
98
+ if (!startNode && curNode.length + atIndex > matchLocation.start) {
99
+ // We've found the match start
100
+ startNode = curNode;
101
+ startNodeIndex = matchLocation.start - atIndex;
102
+ }
103
+
104
+ atIndex += curNode.length;
105
+ }
106
+
107
+ if (startNode && endNode) {
108
+ curNode = replaceFn({
109
+ startNode: startNode,
110
+ startNodeIndex: startNodeIndex,
111
+ endNode: endNode,
112
+ endNodeIndex: endNodeIndex,
113
+ innerNodes: innerNodes,
114
+ match: matchLocation.text,
115
+ matchIndex: matchIndex
116
+ });
117
+
118
+ // replaceFn has to return the node that replaced the endNode
119
+ // and then we step back so we can continue from the end of the
120
+ // match:
121
+ atIndex -= (endNode.length - endNodeIndex);
122
+ startNode = null;
123
+ endNode = null;
124
+ innerNodes = [];
125
+ matchLocation = matches.shift();
126
+ matchIndex++;
127
+
128
+ if (!matchLocation) {
129
+ break; // no more matches
130
+ }
131
+ } else if ((!hiddenTextElementsMap[curNode.nodeName] || blockElementsMap[curNode.nodeName]) && curNode.firstChild) {
132
+ // Move down
133
+ curNode = curNode.firstChild;
134
+ continue;
135
+ } else if (curNode.nextSibling) {
136
+ // Move forward:
137
+ curNode = curNode.nextSibling;
138
+ continue;
139
+ }
140
+
141
+ // Move forward or up:
142
+ while (true) {
143
+ if (curNode.nextSibling) {
144
+ curNode = curNode.nextSibling;
145
+ break;
146
+ } else if (curNode.parentNode !== node) {
147
+ curNode = curNode.parentNode;
148
+ } else {
149
+ break out;
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Generates the actual replaceFn which splits up text nodes
157
+ * and inserts the replacement element.
158
+ */
159
+ function genReplacer(callback) {
160
+ function makeReplacementNode(fill, matchIndex) {
161
+ var match = matches[matchIndex];
162
+
163
+ if (!match.stencil) {
164
+ match.stencil = callback(match);
165
+ }
166
+
167
+ var clone = match.stencil.cloneNode(false);
168
+ clone.setAttribute('data-mce-index', matchIndex);
169
+
170
+ if (fill) {
171
+ clone.appendChild(dom.doc.createTextNode(fill));
172
+ }
173
+
174
+ return clone;
175
+ }
176
+
177
+ return function(range) {
178
+ var before, after, parentNode, startNode = range.startNode,
179
+ endNode = range.endNode, matchIndex = range.matchIndex,
180
+ doc = dom.doc;
181
+
182
+ if (startNode === endNode) {
183
+ var node = startNode;
184
+
185
+ parentNode = node.parentNode;
186
+ if (range.startNodeIndex > 0) {
187
+ // Add "before" text node (before the match)
188
+ before = doc.createTextNode(node.data.substring(0, range.startNodeIndex));
189
+ parentNode.insertBefore(before, node);
190
+ }
191
+
192
+ // Create the replacement node:
193
+ var el = makeReplacementNode(range.match, matchIndex);
194
+ parentNode.insertBefore(el, node);
195
+ if (range.endNodeIndex < node.length) {
196
+ // Add "after" text node (after the match)
197
+ after = doc.createTextNode(node.data.substring(range.endNodeIndex));
198
+ parentNode.insertBefore(after, node);
199
+ }
200
+
201
+ node.parentNode.removeChild(node);
202
+
203
+ return el;
204
+ } else {
205
+ // Replace startNode -> [innerNodes...] -> endNode (in that order)
206
+ before = doc.createTextNode(startNode.data.substring(0, range.startNodeIndex));
207
+ after = doc.createTextNode(endNode.data.substring(range.endNodeIndex));
208
+ var elA = makeReplacementNode(startNode.data.substring(range.startNodeIndex), matchIndex);
209
+ var innerEls = [];
210
+
211
+ for (var i = 0, l = range.innerNodes.length; i < l; ++i) {
212
+ var innerNode = range.innerNodes[i];
213
+ var innerEl = makeReplacementNode(innerNode.data, matchIndex);
214
+ innerNode.parentNode.replaceChild(innerEl, innerNode);
215
+ innerEls.push(innerEl);
216
+ }
217
+
218
+ var elB = makeReplacementNode(endNode.data.substring(0, range.endNodeIndex), matchIndex);
219
+
220
+ parentNode = startNode.parentNode;
221
+ parentNode.insertBefore(before, startNode);
222
+ parentNode.insertBefore(elA, startNode);
223
+ parentNode.removeChild(startNode);
224
+
225
+ parentNode = endNode.parentNode;
226
+ parentNode.insertBefore(elB, endNode);
227
+ parentNode.insertBefore(after, endNode);
228
+ parentNode.removeChild(endNode);
229
+
230
+ return elB;
231
+ }
232
+ };
233
+ }
234
+
235
+ function unwrapElement(element) {
236
+ var parentNode = element.parentNode;
237
+ parentNode.insertBefore(element.firstChild, element);
238
+ element.parentNode.removeChild(element);
239
+ }
240
+
241
+ function getWrappersByIndex(index) {
242
+ var elements = node.getElementsByTagName('*'), wrappers = [];
243
+
244
+ index = typeof(index) == "number" ? "" + index : null;
245
+
246
+ for (var i = 0; i < elements.length; i++) {
247
+ var element = elements[i], dataIndex = element.getAttribute('data-mce-index');
248
+
249
+ if (dataIndex !== null && dataIndex.length) {
250
+ if (dataIndex === index || index === null) {
251
+ wrappers.push(element);
252
+ }
253
+ }
254
+ }
255
+
256
+ return wrappers;
257
+ }
258
+
259
+ /**
260
+ * Returns the index of a specific match object or -1 if it isn't found.
261
+ *
262
+ * @param {Match} match Text match object.
263
+ * @return {Number} Index of match or -1 if it isn't found.
264
+ */
265
+ function indexOf(match) {
266
+ var i = matches.length;
267
+ while (i--) {
268
+ if (matches[i] === match) {
269
+ return i;
270
+ }
271
+ }
272
+
273
+ return -1;
274
+ }
275
+
276
+ /**
277
+ * Filters the matches. If the callback returns true it stays if not it gets removed.
278
+ *
279
+ * @param {Function} callback Callback to execute for each match.
280
+ * @return {DomTextMatcher} Current DomTextMatcher instance.
281
+ */
282
+ function filter(callback) {
283
+ var filteredMatches = [];
284
+
285
+ each(function(match, i) {
286
+ if (callback(match, i)) {
287
+ filteredMatches.push(match);
288
+ }
289
+ });
290
+
291
+ matches = filteredMatches;
292
+
293
+ /*jshint validthis:true*/
294
+ return this;
295
+ }
296
+
297
+ /**
298
+ * Executes the specified callback for each match.
299
+ *
300
+ * @param {Function} callback Callback to execute for each match.
301
+ * @return {DomTextMatcher} Current DomTextMatcher instance.
302
+ */
303
+ function each(callback) {
304
+ for (var i = 0, l = matches.length; i < l; i++) {
305
+ if (callback(matches[i], i) === false) {
306
+ break;
307
+ }
308
+ }
309
+
310
+ /*jshint validthis:true*/
311
+ return this;
312
+ }
313
+
314
+ /**
315
+ * Wraps the current matches with nodes created by the specified callback.
316
+ * Multiple clones of these matches might occur on matches that are on multiple nodex.
317
+ *
318
+ * @param {Function} callback Callback to execute in order to create elements for matches.
319
+ * @return {DomTextMatcher} Current DomTextMatcher instance.
320
+ */
321
+ function wrap(callback) {
322
+ if (matches.length) {
323
+ stepThroughMatches(node, matches, genReplacer(callback));
324
+ }
325
+
326
+ /*jshint validthis:true*/
327
+ return this;
328
+ }
329
+
330
+ /**
331
+ * Finds the specified regexp and adds them to the matches collection.
332
+ *
333
+ * @param {RegExp} regex Global regexp to search the current node by.
334
+ * @param {Object} [data] Optional custom data element for the match.
335
+ * @return {DomTextMatcher} Current DomTextMatcher instance.
336
+ */
337
+ function find(regex, data) {
338
+ if (text && regex.global) {
339
+ while ((m = regex.exec(text))) {
340
+ matches.push(createMatch(m, data));
341
+ }
342
+ }
343
+
344
+ return this;
345
+ }
346
+
347
+ /**
348
+ * Unwraps the specified match object or all matches if unspecified.
349
+ *
350
+ * @param {Object} [match] Optional match object.
351
+ * @return {DomTextMatcher} Current DomTextMatcher instance.
352
+ */
353
+ function unwrap(match) {
354
+ var i, elements = getWrappersByIndex(match ? indexOf(match) : null);
355
+
356
+ i = elements.length;
357
+ while (i--) {
358
+ unwrapElement(elements[i]);
359
+ }
360
+
361
+ return this;
362
+ }
363
+
364
+ /**
365
+ * Returns a match object by the specified DOM element.
366
+ *
367
+ * @param {DOMElement} element Element to return match object for.
368
+ * @return {Object} Match object for the specified element.
369
+ */
370
+ function matchFromElement(element) {
371
+ return matches[element.getAttribute('data-mce-index')];
372
+ }
373
+
374
+ /**
375
+ * Returns a DOM element from the specified match element. This will be the first element if it's split
376
+ * on multiple nodes.
377
+ *
378
+ * @param {Object} match Match element to get first element of.
379
+ * @return {DOMElement} DOM element for the specified match object.
380
+ */
381
+ function elementFromMatch(match) {
382
+ return getWrappersByIndex(indexOf(match))[0];
383
+ }
384
+
385
+ /**
386
+ * Adds match the specified range for example a grammar line.
387
+ *
388
+ * @param {Number} start Start offset.
389
+ * @param {Number} length Length of the text.
390
+ * @param {Object} data Custom data object for match.
391
+ * @return {DomTextMatcher} Current DomTextMatcher instance.
392
+ */
393
+ function add(start, length, data) {
394
+ matches.push({
395
+ start: start,
396
+ end: start + length,
397
+ text: text.substr(start, length),
398
+ data: data
399
+ });
400
+
401
+ return this;
402
+ }
403
+
404
+ /**
405
+ * Returns a DOM range for the specified match.
406
+ *
407
+ * @param {Object} match Match object to get range for.
408
+ * @return {DOMRange} DOM Range for the specified match.
409
+ */
410
+ function rangeFromMatch(match) {
411
+ var wrappers = getWrappersByIndex(indexOf(match));
412
+
413
+ var rng = editor.dom.createRng();
414
+ rng.setStartBefore(wrappers[0]);
415
+ rng.setEndAfter(wrappers[wrappers.length - 1]);
416
+
417
+ return rng;
418
+ }
419
+
420
+ /**
421
+ * Replaces the specified match with the specified text.
422
+ *
423
+ * @param {Object} match Match object to replace.
424
+ * @param {String} text Text to replace the match with.
425
+ * @return {DOMRange} DOM range produced after the replace.
426
+ */
427
+ function replace(match, text) {
428
+ var rng = rangeFromMatch(match);
429
+
430
+ rng.deleteContents();
431
+
432
+ if (text.length > 0) {
433
+ rng.insertNode(editor.dom.doc.createTextNode(text));
434
+ }
435
+
436
+ return rng;
437
+ }
438
+
439
+ /**
440
+ * Resets the DomTextMatcher instance. This will remove any wrapped nodes and remove any matches.
441
+ *
442
+ * @return {[type]} [description]
443
+ */
444
+ function reset() {
445
+ matches.splice(0, matches.length);
446
+ unwrap();
447
+
448
+ return this;
449
+ }
450
+
451
+ text = getText(node);
452
+
453
+ return {
454
+ text: text,
455
+ matches: matches,
456
+ each: each,
457
+ filter: filter,
458
+ reset: reset,
459
+ matchFromElement: matchFromElement,
460
+ elementFromMatch: elementFromMatch,
461
+ find: find,
462
+ add: add,
463
+ wrap: wrap,
464
+ unwrap: unwrap,
465
+ replace: replace,
466
+ rangeFromMatch: rangeFromMatch,
467
+ indexOf: indexOf
468
+ };
469
+ };
470
+ });