@@ -2,6 +2,139 @@ if (!RedactorPlugins) var RedactorPlugins = {};
22
33if ( ! RedactorPlugins ) var RedactorPlugins = { } ;
44
5+ RedactorPlugins . fontsize = function ( )
6+ {
7+ return {
8+ init : function ( )
9+ {
10+ var fonts = [ 10 , 11 , 12 , 14 , 16 , 18 , 20 , 24 , 28 , 30 ] ;
11+ var that = this ;
12+ var dropdown = { } ;
13+
14+ $ . each ( fonts , function ( i , s )
15+ {
16+ dropdown [ 's' + i ] = { title : s + 'px' , func : function ( ) { that . fontsize . set ( s ) ; } } ;
17+ } ) ;
18+
19+ dropdown . remove = { title : 'Remove Font Size' , func : that . fontsize . reset } ;
20+
21+ var button = this . button . add ( 'fontsize' , 'Change Font Size' ) ;
22+ this . button . addDropdown ( button , dropdown ) ;
23+ } ,
24+ set : function ( size )
25+ {
26+ this . inline . format ( 'span' , 'style' , 'font-size: ' + size + 'px;' ) ;
27+ } ,
28+ reset : function ( )
29+ {
30+ this . inline . removeStyleRule ( 'font-size' ) ;
31+ }
32+ } ;
33+ } ;
34+
35+
36+ RedactorPlugins . fontfamily = function ( )
37+ {
38+ return {
39+ init : function ( )
40+ {
41+ var fonts = [ 'Arial' , 'Helvetica' , 'Georgia' , 'Times New Roman' , 'Monospace' ] ;
42+ var that = this ;
43+ var dropdown = { } ;
44+
45+ $ . each ( fonts , function ( i , s )
46+ {
47+ dropdown [ 's' + i ] = { title : s , func : function ( ) { that . fontfamily . set ( s ) ; } } ;
48+ } ) ;
49+
50+ dropdown . remove = { title : 'Remove Font Family' , func : that . fontfamily . reset } ;
51+
52+ var button = this . button . add ( 'fontfamily' , 'Change Font Family' ) ;
53+ this . button . addDropdown ( button , dropdown ) ;
54+
55+ } ,
56+ set : function ( value )
57+ {
58+ this . inline . format ( 'span' , 'style' , 'font-family:' + value + ';' ) ;
59+ } ,
60+ reset : function ( )
61+ {
62+ this . inline . removeStyleRule ( 'font-family' ) ;
63+ }
64+ } ;
65+ } ;
66+
67+ RedactorPlugins . fontcolor = function ( )
68+ {
69+ return {
70+ init : function ( )
71+ {
72+ var colors = [
73+ '#ffffff' , '#000000' , '#eeece1' , '#1f497d' , '#4f81bd' , '#c0504d' , '#9bbb59' , '#8064a2' , '#4bacc6' , '#f79646' , '#ffff00' ,
74+ '#f2f2f2' , '#7f7f7f' , '#ddd9c3' , '#c6d9f0' , '#dbe5f1' , '#f2dcdb' , '#ebf1dd' , '#e5e0ec' , '#dbeef3' , '#fdeada' , '#fff2ca' ,
75+ '#d8d8d8' , '#595959' , '#c4bd97' , '#8db3e2' , '#b8cce4' , '#e5b9b7' , '#d7e3bc' , '#ccc1d9' , '#b7dde8' , '#fbd5b5' , '#ffe694' ,
76+ '#bfbfbf' , '#3f3f3f' , '#938953' , '#548dd4' , '#95b3d7' , '#d99694' , '#c3d69b' , '#b2a2c7' , '#b7dde8' , '#fac08f' , '#f2c314' ,
77+ '#a5a5a5' , '#262626' , '#494429' , '#17365d' , '#366092' , '#953734' , '#76923c' , '#5f497a' , '#92cddc' , '#e36c09' , '#c09100' ,
78+ '#7f7f7f' , '#0c0c0c' , '#1d1b10' , '#0f243e' , '#244061' , '#632423' , '#4f6128' , '#3f3151' , '#31859b' , '#974806' , '#7f6000'
79+ ] ;
80+
81+ var buttons = [ 'fontcolor' , 'backcolor' ] ;
82+
83+ for ( var i = 0 ; i < 2 ; i ++ )
84+ {
85+ var name = buttons [ i ] ;
86+
87+ var button = this . button . add ( name , this . lang . get ( name ) ) ;
88+ var $dropdown = this . button . addDropdown ( button ) ;
89+
90+ $dropdown . width ( 242 ) ;
91+ this . fontcolor . buildPicker ( $dropdown , name , colors ) ;
92+
93+ }
94+ } ,
95+ buildPicker : function ( $dropdown , name , colors )
96+ {
97+ var rule = ( name == 'backcolor' ) ? 'background-color' : 'color' ;
98+
99+ var len = colors . length ;
100+ var self = this ;
101+ var func = function ( e )
102+ {
103+ e . preventDefault ( ) ;
104+ self . fontcolor . set ( $ ( this ) . data ( 'rule' ) , $ ( this ) . attr ( 'rel' ) ) ;
105+ } ;
106+
107+ for ( var z = 0 ; z < len ; z ++ )
108+ {
109+ var color = colors [ z ] ;
110+
111+ var $swatch = $ ( '<a rel="' + color + '" data-rule="' + rule + '" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 22px; height: 22px;"></a>' ) ;
112+ $swatch . css ( 'background-color' , color ) ;
113+ $swatch . on ( 'click' , func ) ;
114+
115+ $dropdown . append ( $swatch ) ;
116+ }
117+
118+ var $elNone = $ ( '<a href="#" style="display: block; clear: both; padding: 5px; font-size: 12px; line-height: 1;"></a>' ) . html ( this . lang . get ( 'none' ) ) ;
119+ $elNone . on ( 'click' , $ . proxy ( function ( e )
120+ {
121+ e . preventDefault ( ) ;
122+ this . fontcolor . remove ( rule ) ;
123+
124+ } , this ) ) ;
125+
126+ $dropdown . append ( $elNone ) ;
127+ } ,
128+ set : function ( rule , type )
129+ {
130+ this . inline . format ( 'span' , 'style' , rule + ': ' + type + ';' ) ;
131+ } ,
132+ remove : function ( rule )
133+ {
134+ this . inline . removeStyleRule ( rule ) ;
135+ }
136+ } ;
137+ } ;
5138
6139 RedactorPlugins . fullscreen = function ( )
7140 {
@@ -187,8 +320,8 @@ RedactorPlugins.filepicker = function() {
187320 autosaveCallback : updateModel ,
188321 focusCallback : updateModel ,
189322 blurCallback : updateModel ,
190- plugins : [ 'filepicker' , 'fullscreen' ] ,
191- buttons : [ 'html' , 'bold' , 'italic' , 'deleted ' , 'outdent' , 'indent' , 'image' , 'file' , 'link' , 'alignment' , 'horizontalrule' ] ,
323+ plugins : [ 'filepicker' , 'fullscreen' , 'fontcolor' , 'fontsize' , 'fontfamily' ] ,
324+ buttons : [ 'html' , 'formatting' , ' bold', 'italic' , 'underline' , 'orderedlist' , 'unorderedlist ', 'outdent' , 'indent' , 'image' , 'file' , 'link' , 'alignment' , 'horizontalrule' ] ,
192325 deniedTags : [ 'html' , 'head' , 'body' , 'meta' , 'applet' ]
193326 } ,
194327 additionalOptions = attrs . redactor ?
0 commit comments