3 var PlinnStylesCombo = function(editor
) {
6 this.title
= 'CSS Styles';
7 this.toolbar
= 'styles,10';
9 css
: [CKEDITOR
.skin
.getPath( 'editor' )].concat(editor
.config
.contentsCss
),
11 attributes
: {'aria-label': this.title
}
16 PlinnStylesCombo
.prototype.loadStyle = function(definition
) {
17 this.styles
.push(definition
);
18 this.styles
[definition
.name
] = definition
;
21 PlinnStylesCombo
.prototype.init = function() {
23 for (i
=0 ; i
< this.styles
.length
; i
++) {
24 style
= this.styles
[i
];
26 '<div class="' + style
.className
+ '">' +
34 PlinnStylesCombo
.prototype.onClick = function(value
) {
36 this.editor
.fire( 'saveSnapshot' );
37 var style
= this.styles
[value
]
38 var className
= style
.className
;
39 var element
= this.editor
.elementPath().lastElement
;
40 if (element
.hasClass(className
)) {
41 element
.removeClass(className
);
44 element
.addClass(className
);
46 this.editor
.fire( 'saveSnapshot' );
49 var PlinnStylePlugin = function() {
50 this.requires
= 'richcombo';
51 this.combo
= undefined;
54 PlinnStylePlugin
.prototype.init = function(editor
) {
55 this.combo
= new PlinnStylesCombo(editor
);
56 editor
.ui
.addRichCombo('PlinnStyles', this.combo
);
58 editor
.on('stylesSet', function(evt
){self
.onStylesSet(evt
)});
61 PlinnStylePlugin
.prototype.onStylesSet = function(evt
) {
62 var stylesDefinitions
= evt
.data
.styles
;
63 if (!stylesDefinitions
) { return; }
65 for(i
=0 ; i
< stylesDefinitions
.length
; i
++) {
66 this.combo
.loadStyle(stylesDefinitions
[i
]);
73 CKEDITOR
.plugins
.add( 'plinn_styles', new PlinnStylePlugin());