PageRenderTime 51ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/taskm/web/ckeditor/plugins/eqneditor/dialogs/eqneditor.js

https://gitlab.com/Roman88/simple-cms
JavaScript | 87 lines | 65 code | 7 blank | 15 comment | 3 complexity | 723be7ea4ab3e5c315a1d78848221b60 MD5 | raw file
  1. /*
  2. Equation Editor Plugin for CKEditor v4
  3. Version 1.4
  4. This plugin allows equations to be created and edited from within CKEditor.
  5. For more information goto: http://www.codecogs.com/latex/integration/ckeditor_v4/install.php
  6. Copyright CodeCogs 2006-2013
  7. Written by Will Bateman.
  8. Special Thanks to:
  9. - Kyle Jones for a fix to allow multiple editor to load on one page
  10. */
  11. window.CCounter=0;
  12. CKEDITOR.dialog.add( 'eqneditorDialog', function(editor)
  13. {
  14. var http = ('https:' == document.location.protocol ? 'https://' : 'http://');
  15. window.CCounter++;
  16. return {
  17. title : editor.lang.eqneditor.title,
  18. minWidth : 550,
  19. minHeight : 380,
  20. resizable: CKEDITOR.DIALOG_RESIZE_NONE,
  21. contents : [
  22. {
  23. id : 'CCEquationEditor',
  24. label : 'EqnEditor',
  25. elements : [
  26. {
  27. type: 'html',
  28. html: '<div id="CCtoolbar'+window.CCounter+'"></div>',
  29. style: 'margin-top:-9px'
  30. },
  31. {
  32. type: 'html',
  33. html: '<label for="CClatex'+window.CCounter+'">Equation (LaTeX):</label>',
  34. },
  35. {
  36. type: 'html',
  37. html: '<textarea id="CClatex'+window.CCounter+'" rows="5"></textarea>',
  38. style:'border:1px solid #8fb6bd; width:540px; font-size:16px; padding:5px; background-color:#ffc',
  39. },
  40. {
  41. type: 'html',
  42. html: '<label for="CCequation'+window.CCounter+'">Preview:</label>'
  43. },
  44. {
  45. type :'html',
  46. html: '<div style="position:absolute; left:5px; bottom:0; z-index:999"><a href="http://www.codecogs.com" target="_blank"><img src="'+http+'latex.codecogs.com/images/poweredbycc.gif" alt="Powered by CodeCogs" style="vertical-align:-4px; border:none"/></a> &nbsp; <a href="http://www.codecogs.com/latex/about.php" target="_blank">About</a> | <a href="http://www.codecogs.com/latex/popup.php" target="_blank">Install</a> | <a href="http://www.codecogs.com/pages/forums/forum_view.php?f=28" target="_blank">Forum</a> | <a href="http://www.codecogs.com" target="_blank">CodeCogs</a> &copy; 2007-2014</div><img id="CCequation'+window.CCounter+'" src="'+http+'www.codecogs.com/images/spacer.gif" />'
  47. }
  48. ]
  49. }
  50. ],
  51. onLoad : function() {
  52. EqEditor.embed('CCtoolbar'+window.CCounter,'','efull');
  53. EqEditor.add(new EqTextArea('CCequation'+window.CCounter, 'CClatex'+window.CCounter),false);
  54. },
  55. onShow : function() {
  56. var dialog = this,
  57. sel = editor.getSelection(),
  58. image = sel.getStartElement().getAscendant('img',true);
  59. // has the users selected an equation. Make sure we have the image element, include itself
  60. if(image)
  61. {
  62. var sName = image.getAttribute('src').match( /(gif|svg)\.latex\?(.*)/ );
  63. if(sName!=null) EqEditor.getTextArea().setText(sName[2]);
  64. dialog.insertMode = true;
  65. }
  66. // set-up the field values based on selected or newly created image
  67. dialog.setupContent( dialog.image );
  68. },
  69. onOk : function() {
  70. var eqn = editor.document.createElement( 'img' );
  71. eqn.setAttribute( 'alt', EqEditor.getTextArea().getLaTeX());
  72. eqn.setAttribute( 'src', EqEditor.getTextArea().exportEquation('urlencoded'));
  73. editor.insertElement(eqn);
  74. Example.add_history(EqEditor.getTextArea().getLaTeX());
  75. }
  76. };
  77. });