Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. <!-- TinysMCE shithead script init here -->
  2. <script src="~/scripts/tinymce/tinymce.min.js"></script>
  3. <!-- Script to wire up your TinyMCE editor -->
  4. <script type="text/javascript">
  5. tinyMCE.PluginManager.add('stylebuttons', function (editor, url) {
  6. ['pre', 'p', 'code', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach(function (name) {
  7. editor.addButton("style-" + name, {
  8. title: 'titlu',
  9. tooltip: "Titlu",
  10. image: '../Scripts/tinymce/plugins/emoticons/img/smiley-cool.gif',
  11. text: name.toUpperCase(),
  12. onClick: function () { editor.execCommand('mceToggleFormat', false, name); },
  13. onPostRender: function () {
  14. var self = this, setup = function () {
  15. editor.formatter.formatChanged(name, function (state) {
  16. self.active(state);
  17. });
  18. };
  19. editor.formatter ? setup() : editor.on('init', setup);
  20. }
  21. })
  22. });
  23. });
  24.  
  25. function ValidationTinyMceSetup(editor) {
  26. var $textarea = $('#' + editor.editorId);
  27.  
  28. // method to use to save editor contents to backend input field (TinyMCE hides real input and syncs it up
  29. // with values on form submit) -- we need to sync up the hidden input fields and call the valid()
  30. // method from jQuery unobtrusive validation if it is present
  31. function save(editor) {
  32. if (editor.isDirty) {
  33. editor.save();
  34. var $input = $('#' + editor.editorId);
  35. if (typeof $input.valid === 'function')
  36. $input.valid();
  37. }
  38. }
  39.  
  40. // Save tinyMCE contents to input field on key/up down (efficiently so IE-old friendly)
  41. var typingTimerDown, typingTimerUp;
  42. var triggerDownSaveInterval = 1000; // time in ms
  43. var triggerUpSaveInterval = 500; // time in ms
  44.  
  45. editor.onKeyDown.add(function (editor) {
  46. clearTimeout(typingTimerDown);
  47. typingTimerDown = setTimeout(function () { save(editor) }, triggerDownSaveInterval);
  48. });
  49.  
  50. editor.onKeyUp.add(function () {
  51. clearTimeout(typingTimerUp);
  52. typingTimerUp = setTimeout(function () { save(editor) }, triggerUpSaveInterval);
  53. });
  54.  
  55.  
  56. // Save tinyMCE contents to input field on deactivate (when focus leaves editor)
  57. // this is via TAB
  58. editor.onKeyDown.add(function (editor, event) {
  59. if (event.keyCode === 9)
  60. save(editor);
  61. });
  62.  
  63. // Initialize your tinyMCE Editor with your preferred options
  64. tinymce.init({
  65. menubar: false,
  66. elementpath: false,
  67. setup: ValidationTinyMceSetup,
  68. selector: 'textarea',
  69. content_style: "div, p { font-size: 15px; font-family:arial; }",
  70. forced_root_block: 'div',
  71. height: 300,
  72. width: 600,
  73. theme: 'modern',
  74. plugins: [
  75. 'advlist autolink lists link print preview hr media',
  76. 'template paste textpattern stylebuttons'
  77. ],
  78. toolbar1: 'bold italic | bullist numlist outdent indent | print preview media | style-h4 "',
  79. image_advtab: true,
  80. content_css: [
  81. '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
  82. '//www.tinymce.com/css/codepen.min.css'
  83. ],
  84. init_instance_callback: "insert_contents",
  85. });
  86.  
  87. </script>
  88.  
  89. <script type="text/javascript">
  90. function insert_contents(inst) {
  91. inst.setContent('<h3><strong>Profilul Candidatului</strong></h3><div>Exemplu Text liber</div><div>Exemplu Lista</div><ol><li>exemplu1</li><li>exemplu2</li></ol><h3><strong>Profilul Companiei</strong></h3><div><div>Exemplu Text liber</div><div>Exemplu Lista</div><ul style="list-style-type: disc;"><li>exemplu1</li><li>exemplu2</li></ul></div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div>');
  92. }
  93.  
  94. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement