trumbowyg.template.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. (function ($) {
  2. 'use strict';
  3. // Adds the language variables
  4. $.extend(true, $.trumbowyg, {
  5. langs: {
  6. // jshint camelcase:false
  7. en: {
  8. template: 'Template'
  9. },
  10. da: {
  11. template: 'Skabelon'
  12. },
  13. de: {
  14. template: 'Vorlage'
  15. },
  16. fr: {
  17. template: 'Patron'
  18. },
  19. hu: {
  20. template: 'Sablon'
  21. },
  22. ja: {
  23. template: 'テンプレート'
  24. },
  25. ko: {
  26. template: '서식'
  27. },
  28. nl: {
  29. template: 'Sjabloon'
  30. },
  31. pt_br: {
  32. template: 'Modelo'
  33. },
  34. ru: {
  35. template: 'Шаблон'
  36. },
  37. tr: {
  38. template: 'Şablon'
  39. },
  40. zh_tw: {
  41. template: '模板',
  42. },
  43. // jshint camelcase:true
  44. }
  45. });
  46. // Adds the extra button definition
  47. $.extend(true, $.trumbowyg, {
  48. plugins: {
  49. template: {
  50. shouldInit: function (trumbowyg) {
  51. return trumbowyg.o.plugins.hasOwnProperty('templates');
  52. },
  53. init: function (trumbowyg) {
  54. trumbowyg.addBtnDef('template', {
  55. dropdown: templateSelector(trumbowyg),
  56. hasIcon: false,
  57. text: trumbowyg.lang.template
  58. });
  59. }
  60. }
  61. }
  62. });
  63. // Creates the template-selector dropdown.
  64. function templateSelector(trumbowyg) {
  65. var available = trumbowyg.o.plugins.templates;
  66. var templates = [];
  67. $.each(available, function (index, template) {
  68. trumbowyg.addBtnDef('template_' + index, {
  69. fn: function () {
  70. trumbowyg.html(template.html);
  71. },
  72. hasIcon: false,
  73. title: template.name
  74. });
  75. templates.push('template_' + index);
  76. });
  77. return templates;
  78. }
  79. })(jQuery);