Merge branch '2.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / 3rdParty / redactor / plugins / wfontfamily.js
1 if (!RedactorPlugins) var RedactorPlugins = {};
2
3 /**
4 * Provides a font family picker, this is actually a heavily modified version of Imperavi's 'fontfamily' plugin.
5 *
6 * @author Alexander Ebert
7 * @copyright 2001-2014 WoltLab GmbH
8 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
9 */
10 RedactorPlugins.wfontfamily = {
11 init: function () {
12 var $fonts = {
13 'Arial': "Arial, Helvetica, sans-serif",
14 'Comic Sans MS': "Comic Sans MS, cursive",
15 'Courier New': "Consolas, Courier New, Courier, monospace",
16 'Georgia': "Georgia, serif",
17 'Lucida Sans Unicode': "Lucida Sans Unicode, Lucida Grande, sans-serif",
18 'Tahoma': "Tahoma, Geneva, sans-serif",
19 'Times New Roman': "Times New Roman, Times, serif",
20 'Trebuchet MS': "Trebuchet MS, Helvetica, sans-serif",
21 'Verdana': "Verdana, Geneva, sans-serif"
22 };
23
24 var $dropdown = { };
25 var $i = 0;
26 var self = this;
27 $.each($fonts, function(title, value) {
28 $dropdown['fontFamily' + $i] = {
29 title: title,
30 className: 'wfontfamily-' + $i,
31 callback: function() {
32 self.inlineSetStyle('font-family', value);
33 }
34 };
35
36 $i++;
37 });
38 $dropdown['separator'] = { name: 'separator' };
39 $dropdown['remove'] = {
40 title: 'remove font',
41 callback: function() {
42 this.inlineRemoveStyle('font-family');
43 }
44 };
45
46 this.buttonReplace('fontfamily', 'wfontfamily', 'Change font family', false, $dropdown);
47 this.buttonGet('wfontfamily').addClass('re-fontfamily');
48
49 // modify dropdown to reflect each font family
50 $dropdown = this.$toolbar.find('.redactor_dropdown_box_wfontfamily');
51 $i = 0;
52 $.each($fonts, function(title, value) {
53 $dropdown.children('.wfontfamily-' + $i).removeClass('wfontfamily-' + $i).css('font-family', value);
54 $i++;
55 });
56 }
57 };