Merge branch '2.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / 3rdParty / redactor / plugins / wfontsize.js
1 if (!RedactorPlugins) var RedactorPlugins = {};
2
3 /**
4 * Provides a font size picker, this is actually a heavily modified version of Imperavi's 'fontsize' 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.wfontsize = {
11 init: function () {
12 var $fontSizes = [ 8, 10, 12, 14, 18, 24, 36 ];
13
14 var $dropdown = { };
15 var self = this;
16 for (var $i = 0, $length = $fontSizes.length; $i < $length; $i++) {
17 var $fontSize = $fontSizes[$i];
18
19 $dropdown['fontSize' + $i] = {
20 title: $fontSize,
21 className: 'wfontsize-' + $fontSize,
22 callback: function() {
23 self.inlineSetStyle('font-size', $fontSize + 'pt');
24 }
25 };
26 }
27
28 $dropdown['separator'] = { name: 'separator' };
29 $dropdown['remove'] = {
30 title: 'remove font size',
31 callback: function() {
32 this.inlineRemoveStyle('font-size');
33 }
34 };
35
36 this.buttonReplace('fontsize', 'wfontsize', 'Change font size', false, $dropdown);
37 this.buttonGet('wfontsize').addClass('re-fontsize');
38
39 // modify dropdown to reflect each font family
40 $dropdown = this.$toolbar.find('.redactor_dropdown_box_wfontsize');
41 for (var $i = 0, $length = $fontSizes.length; $i < $length; $i++) {
42 var $fontSize = $fontSizes[$i];
43
44 var $listItem = $dropdown.children('a.wfontsize-' + $fontSize).removeClass('wfontsize-' + $fontSizes).css('font-size', $fontSize + 'pt');
45 if ($fontSize > 18) {
46 $listItem.css('line-height', '1em');
47 }
48 }
49 }
50 };