1
0

trumbowyg.fontfamily.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. (function ($) {
  2. 'use strict';
  3. $.extend(true, $.trumbowyg, {
  4. langs: {
  5. // jshint camelcase:false
  6. en: {
  7. fontFamily: 'Font'
  8. },
  9. es: {
  10. fontFamily: 'Fuente'
  11. },
  12. da: {
  13. fontFamily: 'Skrifttype'
  14. },
  15. de: {
  16. fontFamily: 'Schriftart'
  17. },
  18. fr: {
  19. fontFamily: 'Police'
  20. },
  21. hu: {
  22. fontFamily: 'Betűtípus'
  23. },
  24. ko: {
  25. fontFamily: '글꼴'
  26. },
  27. nl: {
  28. fontFamily: 'Lettertype'
  29. },
  30. pt_br: {
  31. fontFamily: 'Fonte',
  32. },
  33. tr: {
  34. fontFamily: 'Yazı Tipi'
  35. },
  36. zh_tw: {
  37. fontFamily: '字體',
  38. },
  39. }
  40. });
  41. // jshint camelcase:true
  42. var defaultOptions = {
  43. fontList: [
  44. {name: 'Arial', family: 'Arial, Helvetica, sans-serif'},
  45. {name: 'Arial Black', family: 'Arial Black, Gadget, sans-serif'},
  46. {name: 'Comic Sans', family: 'Comic Sans MS, Textile, cursive, sans-serif'},
  47. {name: 'Courier New', family: 'Courier New, Courier, monospace'},
  48. {name: 'Georgia', family: 'Georgia, serif'},
  49. {name: 'Impact', family: 'Impact, Charcoal, sans-serif'},
  50. {name: 'Lucida Console', family: 'Lucida Console, Monaco, monospace'},
  51. {name: 'Lucida Sans', family: 'Lucida Sans Uncide, Lucida Grande, sans-serif'},
  52. {name: 'Palatino', family: 'Palatino Linotype, Book Antiqua, Palatino, serif'},
  53. {name: 'Tahoma', family: 'Tahoma, Geneva, sans-serif'},
  54. {name: 'Times New Roman', family: 'Times New Roman, Times, serif'},
  55. {name: 'Trebuchet', family: 'Trebuchet MS, Helvetica, sans-serif'},
  56. {name: 'Verdana', family: 'Verdana, Geneva, sans-serif'}
  57. ]
  58. };
  59. // Add dropdown with web safe fonts
  60. $.extend(true, $.trumbowyg, {
  61. plugins: {
  62. fontfamily: {
  63. init: function (trumbowyg) {
  64. trumbowyg.o.plugins.fontfamily = $.extend({},
  65. defaultOptions,
  66. trumbowyg.o.plugins.fontfamily || {}
  67. );
  68. trumbowyg.addBtnDef('fontfamily', {
  69. dropdown: buildDropdown(trumbowyg),
  70. hasIcon: false,
  71. text: trumbowyg.lang.fontFamily
  72. });
  73. }
  74. }
  75. }
  76. });
  77. function buildDropdown(trumbowyg) {
  78. var dropdown = [];
  79. $.each(trumbowyg.o.plugins.fontfamily.fontList, function (index, font) {
  80. trumbowyg.addBtnDef('fontfamily_' + index, {
  81. title: '<span style="font-family: ' + font.family + ';">' + font.name + '</span>',
  82. hasIcon: false,
  83. fn: function () {
  84. trumbowyg.execCmd('fontName', font.family, true);
  85. }
  86. });
  87. dropdown.push('fontfamily_' + index);
  88. });
  89. return dropdown;
  90. }
  91. })(jQuery);