File modules/editor/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js
Last commit: Tue Aug 28 00:33:27 2018 +0200 Jan Dankert Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.
1 (function ($) { 2 'use strict'; 3 4 $.extend(true, $.trumbowyg, { 5 langs: { 6 // jshint camelcase:false 7 en: { 8 fontsize: 'Font size', 9 fontsizes: { 10 'x-small': 'Extra small', 11 'small': 'Small', 12 'medium': 'Regular', 13 'large': 'Large', 14 'x-large': 'Extra large', 15 'custom': 'Custom' 16 } 17 }, 18 fr: { 19 fontsize: 'Taille de la police', 20 fontsizes: { 21 'x-small': 'Très petit', 22 'small': 'Petit', 23 'medium': 'Normal', 24 'large': 'Grand', 25 'x-large': 'Très grand', 26 'custom': 'Douane' 27 } 28 }, 29 nl: { 30 fontsize: 'Lettergrootte', 31 fontsizes: { 32 'x-small': 'Extra klein', 33 'small': 'Klein', 34 'medium': 'Normaal', 35 'large': 'Groot', 36 'x-large': 'Extra groot', 37 'custom': 'Tilpasset' 38 } 39 }, 40 tr: { 41 fontsize: 'Yazı Boyutu', 42 fontsizes: { 43 'x-small': 'Çok Küçük', 44 'small': 'Küçük', 45 'medium': 'Normal', 46 'large': 'Büyük', 47 'x-large': 'Çok Büyük', 48 'custom': 'Görenek' 49 } 50 } 51 } 52 }); 53 // jshint camelcase:true 54 55 // Add dropdown with font sizes 56 $.extend(true, $.trumbowyg, { 57 plugins: { 58 fontsize: { 59 init: function (trumbowyg) { 60 trumbowyg.addBtnDef('fontsize', { 61 dropdown: buildDropdown(trumbowyg) 62 }); 63 } 64 } 65 } 66 }); 67 68 function buildDropdown(trumbowyg) { 69 var dropdown = []; 70 var sizes = ['x-small', 'small', 'medium', 'large', 'x-large']; 71 72 $.each(sizes, function (index, size) { 73 trumbowyg.addBtnDef('fontsize_' + size, { 74 text: '<span style="font-size: ' + size + ';">' + trumbowyg.lang.fontsizes[size] + '</span>', 75 hasIcon: false, 76 fn: function () { 77 trumbowyg.execCmd('fontSize', index + 1, true); 78 } 79 }); 80 dropdown.push('fontsize_' + size); 81 }); 82 83 var freeSizeButtonName = 'fontsize_custom', 84 freeSizeBtnDef = { 85 fn: function () { 86 trumbowyg.openModalInsert('Custom Font Size', 87 { 88 size: { 89 label: 'Font Size', 90 value: '48px' 91 } 92 }, 93 function (values) { 94 var text = trumbowyg.range.startContainer.parentElement; 95 var selectedText = trumbowyg.getRangeText(); 96 if ($(text).html() === selectedText) { 97 $(text).css('font-size', values.size); 98 } else { 99 trumbowyg.range.deleteContents(); 100 var html = '<span style="font-size: ' + values.size + ';">' + selectedText + '</span>'; 101 var node = $(html)[0]; 102 trumbowyg.range.insertNode(node); 103 } 104 trumbowyg.saveRange(); 105 return true; 106 } 107 ); 108 }, 109 text: '<span style="font-size: medium;">' + trumbowyg.lang.fontsizes.custom + '</span>', 110 hasIcon: false 111 }; 112 trumbowyg.addBtnDef(freeSizeButtonName, freeSizeBtnDef); 113 dropdown.push(freeSizeButtonName); 114 115 return dropdown; 116 } 117 })(jQuery);
Downloadmodules/editor/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js
History Tue, 28 Aug 2018 00:33:27 +0200 Jan Dankert Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.