activeadmin-ckeditor 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/ckeditor/config.js +118 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/assets/stylesheets/activeadmin-ckeditor.css.sass +3 -0
- data/app/assets/stylesheets/ckeditor/.DS_Store +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/.DS_Store +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/autogrow/plugin.js +187 -0
- data/app/assets/stylesheets/ckeditor/plugins/autogrow/samples/autogrow.html +99 -0
- data/app/assets/stylesheets/ckeditor/plugins/floating-tools/README.md +20 -0
- data/app/assets/stylesheets/ckeditor/plugins/floating-tools/plugin.js +582 -0
- data/app/assets/stylesheets/ckeditor/plugins/imagepaste/docs/install.html +64 -0
- data/app/assets/stylesheets/ckeditor/plugins/imagepaste/docs/styles.css +59 -0
- data/app/assets/stylesheets/ckeditor/plugins/imagepaste/plugin.js +82 -0
- data/app/assets/stylesheets/ckeditor/plugins/stylesheetparser/plugin.js +152 -0
- data/app/assets/stylesheets/ckeditor/plugins/stylesheetparser/samples/assets/sample.css +70 -0
- data/app/assets/stylesheets/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +82 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/LICENSE.md +28 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/README.md +55 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/images/transformCapitalize.png +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/images/transformSwitcher.png +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/images/transformToLower.png +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/images/transformToUpper.png +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/lang/en.js +17 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/lang/tr.js +41 -0
- data/app/assets/stylesheets/ckeditor/plugins/texttransform/plugin.js +151 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/images/icon.png +0 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/de.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/en.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/fr.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/hu.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/it.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/ja.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/pt.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/ru.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/lang/tr.js +21 -0
- data/app/assets/stylesheets/ckeditor/plugins/youtube/plugin.js +321 -0
- data/app/assets/stylesheets/ckeditor/skins/.DS_Store +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dev/icons16.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dev/icons16.svg +2106 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dev/icons32.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dev/icons32.svg +2442 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dev/locations.json +139 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dialog.css.scss +7 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dialog_ie.css.scss +7 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dialog_ie7.css.scss +7 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dialog_ie8.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dialog_iequirks.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/dialog_opera.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/editor.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/editor_gecko.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/editor_ie.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/editor_ie7.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/editor_ie8.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/editor_iequirks.css.scss +8 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/arrow.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/close.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/hidpi/close.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/lock-open.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/lock.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/images/refresh.png +0 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/readme.md +51 -0
- data/app/assets/stylesheets/ckeditor/skins/moono/skin.js +10 -0
- data/lib/.DS_Store +0 -0
- data/lib/activeadmin-ckeditor.rb +3 -3
- data/lib/activeadmin-ckeditor/engine.rb +9 -0
- data/lib/activeadmin-ckeditor/version.rb +1 -1
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/activeadmin/.DS_Store +0 -0
- data/lib/generators/activeadmin/ckeditor/install_generator.rb +19 -0
- metadata +74 -1
@@ -0,0 +1,582 @@
|
|
1
|
+
/**
|
2
|
+
* Floating-Tools
|
3
|
+
* Author: Philipp Stracker (2013)
|
4
|
+
* Project page: http://stracker-phil.github.com/Floating-Tools/
|
5
|
+
*/
|
6
|
+
(function() {
|
7
|
+
|
8
|
+
var floatingtools = function() {
|
9
|
+
this.dom = null; // the main toolbar-object
|
10
|
+
this.toolbars = [];
|
11
|
+
this.is_visible = false;
|
12
|
+
|
13
|
+
this.hide_on_blur = true; //!TODO: Make this an configuration option
|
14
|
+
|
15
|
+
this.toolbarsize = false;
|
16
|
+
this.editoroffset = false;
|
17
|
+
this.mousepos = {x:0, y:0};
|
18
|
+
};
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
CKEDITOR.plugins.add( 'floating-tools', {
|
24
|
+
requires: 'toolbar',
|
25
|
+
|
26
|
+
|
27
|
+
init: function( editor ) {
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Create the UI elements required by this plugin
|
32
|
+
* UI is the floating toolbar
|
33
|
+
* Many parts of this function are taken from the toolbar plugin
|
34
|
+
*/
|
35
|
+
editor.on( 'uiSpace', function( event ) {
|
36
|
+
// Create toolbar only once...
|
37
|
+
event.removeListener();
|
38
|
+
|
39
|
+
editor.floatingtools = new floatingtools();
|
40
|
+
|
41
|
+
var labelId = CKEDITOR.tools.getNextId();
|
42
|
+
|
43
|
+
var output = [
|
44
|
+
// Did not find a nicer way to include the CSS required for the toolbar...
|
45
|
+
'<style>',
|
46
|
+
'.pos-relative {position:relative}',
|
47
|
+
'.cke_floatingtools{',
|
48
|
+
'position:absolute;',
|
49
|
+
'left:0;',
|
50
|
+
'top:-500px;',
|
51
|
+
'padding: 5px 0 0 6px;',
|
52
|
+
'border:1px solid #b1b1b1;',
|
53
|
+
'border-radius:3px;',
|
54
|
+
'box-shadow: 0 1px 10px rgba(0,0,0,0.3);',
|
55
|
+
'transition:opacity .1s;-o-transition:opacity .1s;-moz-transition:opacity .1s;-webkit-transition:opacity .1s;',
|
56
|
+
'}',
|
57
|
+
'</style>',
|
58
|
+
'<span id="', labelId, '" class="cke_voice_label">', editor.lang.toolbar.toolbars, '</span>',
|
59
|
+
'<span id="' + editor.ui.spaceId( 'floatingtools' ) + '" class="cke_floatingtools cke_top" role="group" aria-labelledby="', labelId, '" onmousedown="return false;">' ];
|
60
|
+
|
61
|
+
var groupStarted, pendingSeparator;
|
62
|
+
var toolbars = editor.floatingtools.toolbars,
|
63
|
+
toolbar = getFloatingToolbarConfig( editor );
|
64
|
+
|
65
|
+
|
66
|
+
// Build the toolbar
|
67
|
+
for ( var r = 0; r < toolbar.length; r++ ) {
|
68
|
+
var toolbarId,
|
69
|
+
toolbarObj = 0,
|
70
|
+
toolbarName,
|
71
|
+
row = toolbar[ r ],
|
72
|
+
items;
|
73
|
+
|
74
|
+
// It's better to check if the row object is really
|
75
|
+
// available because it's a common mistake to leave
|
76
|
+
// an extra comma in the toolbar definition
|
77
|
+
// settings, which leads on the editor not loading
|
78
|
+
// at all in IE. (#3983)
|
79
|
+
if ( !row )
|
80
|
+
continue;
|
81
|
+
|
82
|
+
if ( groupStarted ) {
|
83
|
+
output.push( '</span>' );
|
84
|
+
groupStarted = 0;
|
85
|
+
pendingSeparator = 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
if ( row === '/' ) {
|
89
|
+
output.push( '<span class="cke_toolbar_break"></span>' );
|
90
|
+
continue;
|
91
|
+
}
|
92
|
+
|
93
|
+
items = row.items || row;
|
94
|
+
|
95
|
+
// Create all items defined for this toolbar.
|
96
|
+
for ( var i = 0; i < items.length; i++ ) {
|
97
|
+
var item = items[ i ],
|
98
|
+
canGroup;
|
99
|
+
|
100
|
+
if ( item ) {
|
101
|
+
if ( item.type == CKEDITOR.UI_SEPARATOR ) {
|
102
|
+
// Do not add the separator immediately. Just save
|
103
|
+
// it be included if we already have something in
|
104
|
+
// the toolbar and if a new item is to be added (later).
|
105
|
+
pendingSeparator = groupStarted && item;
|
106
|
+
continue;
|
107
|
+
}
|
108
|
+
|
109
|
+
canGroup = item.canGroup !== false;
|
110
|
+
|
111
|
+
// Initialize the toolbar first, if needed.
|
112
|
+
if ( !toolbarObj ) {
|
113
|
+
// Create the basic toolbar object.
|
114
|
+
toolbarId = CKEDITOR.tools.getNextId();
|
115
|
+
toolbarObj = { id: toolbarId, items: [] };
|
116
|
+
toolbarName = row.name && ( editor.lang.toolbar.toolbarGroups[ row.name ] || row.name );
|
117
|
+
|
118
|
+
// Output the toolbar opener.
|
119
|
+
output.push( '<span id="', toolbarId, '" class="cke_toolbar"', ( toolbarName ? ' aria-labelledby="' + toolbarId + '_label"' : '' ), ' role="toolbar">' );
|
120
|
+
|
121
|
+
// If a toolbar name is available, send the voice label.
|
122
|
+
toolbarName && output.push( '<span id="', toolbarId, '_label" class="cke_voice_label">', toolbarName, '</span>' );
|
123
|
+
|
124
|
+
output.push( '<span class="cke_toolbar_start"></span>' );
|
125
|
+
|
126
|
+
// Add the toolbar to the "editor.toolbox.toolbars"
|
127
|
+
// array.
|
128
|
+
var index = toolbars.push( toolbarObj ) - 1;
|
129
|
+
|
130
|
+
// Create the next/previous reference.
|
131
|
+
if ( index > 0 ) {
|
132
|
+
toolbarObj.previous = toolbars[ index - 1 ];
|
133
|
+
toolbarObj.previous.next = toolbarObj;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
if ( canGroup ) {
|
138
|
+
if ( !groupStarted ) {
|
139
|
+
output.push( '<span class="cke_toolgroup" role="presentation">' );
|
140
|
+
groupStarted = 1;
|
141
|
+
}
|
142
|
+
} else if ( groupStarted ) {
|
143
|
+
output.push( '</span>' );
|
144
|
+
groupStarted = 0;
|
145
|
+
}
|
146
|
+
|
147
|
+
function addItem( item ) {
|
148
|
+
var itemObj = item.render( editor, output );
|
149
|
+
index = toolbarObj.items.push( itemObj ) - 1;
|
150
|
+
|
151
|
+
if ( index > 0 ) {
|
152
|
+
itemObj.previous = toolbarObj.items[ index - 1 ];
|
153
|
+
itemObj.previous.next = itemObj;
|
154
|
+
}
|
155
|
+
|
156
|
+
itemObj.toolbar = toolbarObj;
|
157
|
+
|
158
|
+
// No need for keyboard handlers, the toolbar is only accessibly by mouse
|
159
|
+
/*
|
160
|
+
itemObj.onkey = itemKeystroke;
|
161
|
+
|
162
|
+
// Fix for #3052:
|
163
|
+
// Prevent JAWS from focusing the toolbar after document load.
|
164
|
+
itemObj.onfocus = function() {
|
165
|
+
if ( !editor.toolbox.focusCommandExecuted )
|
166
|
+
editor.focus();
|
167
|
+
};
|
168
|
+
*/
|
169
|
+
}
|
170
|
+
|
171
|
+
if ( pendingSeparator ) {
|
172
|
+
addItem( pendingSeparator );
|
173
|
+
pendingSeparator = 0;
|
174
|
+
}
|
175
|
+
|
176
|
+
addItem( item );
|
177
|
+
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
if ( groupStarted ) {
|
182
|
+
output.push( '</span>' );
|
183
|
+
groupStarted = 0;
|
184
|
+
pendingSeparator = 0;
|
185
|
+
}
|
186
|
+
|
187
|
+
if ( toolbarObj )
|
188
|
+
output.push( '<span class="cke_toolbar_end"></span></span>' );
|
189
|
+
|
190
|
+
}
|
191
|
+
|
192
|
+
|
193
|
+
output.push( '</span>' );
|
194
|
+
event.data.html += output.join( '' );
|
195
|
+
});
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Do the magic: Attach eventhandlers to see if text is selected
|
201
|
+
* When text is selected then show the floating toolbar, else hide it
|
202
|
+
*/
|
203
|
+
editor.on('contentDom', function( event ) {
|
204
|
+
|
205
|
+
unfocus_toolbar();
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Attach an eventhandler to the mouse-up event
|
209
|
+
*/
|
210
|
+
editor.document.on('mouseup', function( mouse_event ) {
|
211
|
+
// When user right-clicks, ctrl-clicks, etc. then do not show the toolbar
|
212
|
+
data = mouse_event.data.$;
|
213
|
+
if (data.button !== 0 || data.ctrlKey || data.altKey || data.shiftKey) return true;
|
214
|
+
|
215
|
+
// When the user clears the selection by single-clicking in the editor then this event is fired before the selection is removed
|
216
|
+
// So we add a short delay to give the browser a chance to remove the selection before we do anything
|
217
|
+
setTimeout( function() {
|
218
|
+
if (is_text_selected()) {
|
219
|
+
// Save the current mouse-position
|
220
|
+
set_mousepos (mouse_event.data.$);
|
221
|
+
// when there is text selected after mouse-up: show the toolbar
|
222
|
+
editor.execCommand('showFloatingTools');
|
223
|
+
} else {
|
224
|
+
// when no text is selected then hide the toolbar
|
225
|
+
editor.execCommand('hideFloatingTools');
|
226
|
+
}
|
227
|
+
}, 100);
|
228
|
+
});
|
229
|
+
|
230
|
+
|
231
|
+
/**
|
232
|
+
* On keypress we will always hide the toolbar
|
233
|
+
* The toolbar is only accessible via mouse
|
234
|
+
*/
|
235
|
+
editor.document.on('keyup', function( key_event ) {
|
236
|
+
editor.execCommand('hideFloatingTools');
|
237
|
+
});
|
238
|
+
|
239
|
+
|
240
|
+
/**
|
241
|
+
* On blur hide the toolbar (editor looses focus)
|
242
|
+
*/
|
243
|
+
editor.on('blur', function( e ) {
|
244
|
+
if (editor.floatingtools.hide_on_blur) {
|
245
|
+
hide_toolbar();
|
246
|
+
}
|
247
|
+
});
|
248
|
+
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Attach the mouse-over event to the toolbar.
|
252
|
+
* When cursor is above the toolbar then set opacity to 1
|
253
|
+
*/
|
254
|
+
toolbar = get_element();
|
255
|
+
toolbar.on('mouseover', function( mouse_event ) {
|
256
|
+
focus_toolbar();
|
257
|
+
});
|
258
|
+
|
259
|
+
|
260
|
+
/**
|
261
|
+
* When the mouse moves out of the toolbar then make it transparent again
|
262
|
+
*/
|
263
|
+
toolbar.on('mouseout', function( mouse_event ) {
|
264
|
+
unfocus_toolbar();
|
265
|
+
})
|
266
|
+
|
267
|
+
editor.container.addClass('pos-relative');
|
268
|
+
console.log(editor.container);
|
269
|
+
});
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Display the floating toolbar
|
275
|
+
*/
|
276
|
+
editor.addCommand( 'showFloatingTools', {
|
277
|
+
exec : function( editor ) {
|
278
|
+
if (is_text_selected()) {
|
279
|
+
toolbar = get_element();
|
280
|
+
unfocus_toolbar();
|
281
|
+
toolbar.show();
|
282
|
+
|
283
|
+
// Get the size of the toolbar
|
284
|
+
size = get_toolbar_size()
|
285
|
+
// Get the offset of the editor
|
286
|
+
offset = get_editor_offset();
|
287
|
+
// Get the mouse position
|
288
|
+
pos = get_mousepos();
|
289
|
+
|
290
|
+
// Calculate the position for the toolbar
|
291
|
+
toolpos = calculate_position(pos, size, offset);
|
292
|
+
|
293
|
+
toolbar.setStyles({
|
294
|
+
'left' : toolpos.x + 'px',
|
295
|
+
'top' : toolpos.y + 'px'
|
296
|
+
});
|
297
|
+
editor.floatingtools.is_visible = true;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
});
|
301
|
+
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Hide the floating toolbar
|
305
|
+
*/
|
306
|
+
editor.addCommand( 'hideFloatingTools', {
|
307
|
+
exec : function( editor ) {
|
308
|
+
hide_toolbar();
|
309
|
+
}
|
310
|
+
});
|
311
|
+
|
312
|
+
|
313
|
+
/**
|
314
|
+
* ===== Behind the scenes. Getters, setters, calculation, etc.
|
315
|
+
*/
|
316
|
+
|
317
|
+
|
318
|
+
hide_toolbar = function() {
|
319
|
+
if (false != editor.floatingtools.is_visible) {
|
320
|
+
toolbar = get_element();
|
321
|
+
toolbar.hide();
|
322
|
+
editor.floatingtools.is_visible = false;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
|
327
|
+
/**
|
328
|
+
* Store the current mouse-position, so we can position the toolbar near the cursor
|
329
|
+
*/
|
330
|
+
set_mousepos = function(data) {
|
331
|
+
editor.floatingtools.mousepos = {
|
332
|
+
left: data.clientX,
|
333
|
+
top: data.clientY
|
334
|
+
};
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
/**
|
340
|
+
* Store the current mouse-position, so we can position the toolbar near the cursor
|
341
|
+
*/
|
342
|
+
get_mousepos = function() {
|
343
|
+
return editor.floatingtools.mousepos;
|
344
|
+
}
|
345
|
+
|
346
|
+
|
347
|
+
/**
|
348
|
+
* Returns the main toolbar-object (the parent of all items in the floating-toolbar)
|
349
|
+
*/
|
350
|
+
get_element = function() {
|
351
|
+
if (! editor.floatingtools.dom) {
|
352
|
+
var dom_id = editor.ui.spaceId( 'floatingtools' );
|
353
|
+
editor.floatingtools.dom = CKEDITOR.document.getById( dom_id );
|
354
|
+
}
|
355
|
+
return editor.floatingtools.dom;
|
356
|
+
}
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
/**
|
361
|
+
* Returns the offset of the editor area (effectively the height of the top-toolbar)
|
362
|
+
*/
|
363
|
+
get_editor_offset = function() {
|
364
|
+
if (! editor.floatingtools.editoroffset) {
|
365
|
+
var editor_id = editor.ui.spaceId( 'contents' );
|
366
|
+
var obj = CKEDITOR.document.getById( editor_id );
|
367
|
+
editor.floatingtools.editoroffset = {
|
368
|
+
left: obj.$.offsetLeft,
|
369
|
+
top: obj.$.offsetTop,
|
370
|
+
width: obj.$.offsetWidth,
|
371
|
+
height: obj.$.offsetHeight
|
372
|
+
};
|
373
|
+
}
|
374
|
+
return editor.floatingtools.editoroffset;
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
/**
|
379
|
+
* Calculates the position for the toolbar
|
380
|
+
*/
|
381
|
+
calculate_position = function(pos, toolbar_size, offset) {
|
382
|
+
toolpos = {
|
383
|
+
x: pos.left + offset.left - (toolbar_size.width/2),
|
384
|
+
y: pos.top + offset.top - (toolbar_size.height + 20)
|
385
|
+
}
|
386
|
+
|
387
|
+
// make sure toolbar does not extend out of the left CKEditor border
|
388
|
+
if (toolpos.x < offset.left + 2) toolpos.x = offset.left + 2;
|
389
|
+
|
390
|
+
// make sure toolbar does not extend out of the right CKEditor border
|
391
|
+
if (pos.left + (toolbar_size.width/2) >= offset.left + offset.width-2 )
|
392
|
+
toolpos.x = offset.left + offset.width - toolbar_size.width - 2;
|
393
|
+
|
394
|
+
// Make sure toolbar does no go into the top toolbar area
|
395
|
+
if (toolpos.y < offset.top) toolpos.y = offset.top;
|
396
|
+
|
397
|
+
// make sure toolbar does not cover the mouse-cursor when text in the top line is selected
|
398
|
+
if (offset.top+pos.top > toolpos.y
|
399
|
+
&& offset.top+pos.top < toolpos.y+toolbar_size.height)
|
400
|
+
toolpos.y = offset.top + pos.top + 24; // display toolbar below the cursor
|
401
|
+
|
402
|
+
return toolpos;
|
403
|
+
}
|
404
|
+
|
405
|
+
|
406
|
+
/**
|
407
|
+
* Returns the size of the floating toolbar
|
408
|
+
*/
|
409
|
+
get_toolbar_size = function() {
|
410
|
+
if (! editor.floatingtools.toolbarsize) {
|
411
|
+
var obj = get_element();
|
412
|
+
editor.floatingtools.toolbarsize = {
|
413
|
+
width: obj.$.offsetWidth,
|
414
|
+
height: obj.$.offsetHeight
|
415
|
+
};
|
416
|
+
}
|
417
|
+
return editor.floatingtools.toolbarsize;
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Check if text is selected.
|
423
|
+
* Retrns true when there is at least 1 character selected in the editor
|
424
|
+
*/
|
425
|
+
is_text_selected = function () {
|
426
|
+
var text = editor.getSelection().getSelectedText();
|
427
|
+
return text != '';
|
428
|
+
}
|
429
|
+
|
430
|
+
|
431
|
+
/**
|
432
|
+
* Make the toolbar opaque
|
433
|
+
*/
|
434
|
+
focus_toolbar = function() {
|
435
|
+
obj = get_element();
|
436
|
+
obj.setOpacity(1);
|
437
|
+
}
|
438
|
+
|
439
|
+
|
440
|
+
/**
|
441
|
+
* Make the toolbar transparent
|
442
|
+
*/
|
443
|
+
unfocus_toolbar = function() {
|
444
|
+
obj = get_element();
|
445
|
+
obj.setOpacity(0.25);
|
446
|
+
},
|
447
|
+
|
448
|
+
|
449
|
+
/**
|
450
|
+
* Get the plugin configuration.
|
451
|
+
* Kidnapped from the toolbar-plugin...
|
452
|
+
*/
|
453
|
+
getFloatingToolbarConfig = function( editor ) {
|
454
|
+
var removeButtons = editor.config.removeButtons;
|
455
|
+
|
456
|
+
removeButtons = removeButtons && removeButtons.split( ',' );
|
457
|
+
|
458
|
+
function buildToolbarConfig() {
|
459
|
+
// Take the base for the new toolbar, which is basically a toolbar
|
460
|
+
// definition without items.
|
461
|
+
var toolbar = getPrivateFloatingToolbarGroups( editor );
|
462
|
+
return populateToolbarConfig( toolbar );
|
463
|
+
|
464
|
+
}
|
465
|
+
|
466
|
+
// Returns an object containing all toolbar groups used by ui items.
|
467
|
+
function getItemDefinedGroups() {
|
468
|
+
var groups = {},
|
469
|
+
itemName, item, itemToolbar, group, order;
|
470
|
+
|
471
|
+
for ( itemName in editor.ui.items ) {
|
472
|
+
item = editor.ui.items[ itemName ];
|
473
|
+
itemToolbar = item.toolbar || 'others';
|
474
|
+
if ( itemToolbar ) {
|
475
|
+
// Break the toolbar property into its parts: "group_name[,order]".
|
476
|
+
itemToolbar = itemToolbar.split( ',' );
|
477
|
+
group = itemToolbar[ 0 ];
|
478
|
+
order = parseInt( itemToolbar[ 1 ] || -1, 10 );
|
479
|
+
|
480
|
+
// Initialize the group, if necessary.
|
481
|
+
groups[ group ] || ( groups[ group ] = [] );
|
482
|
+
|
483
|
+
// Push the data used to build the toolbar later.
|
484
|
+
groups[ group ].push( { name: itemName, order: order} );
|
485
|
+
}
|
486
|
+
}
|
487
|
+
|
488
|
+
// Put the items in the right order.
|
489
|
+
for ( group in groups ) {
|
490
|
+
groups[ group ] = groups[ group ].sort( function( a, b ) {
|
491
|
+
return a.order == b.order ? 0 :
|
492
|
+
b.order < 0 ? -1 :
|
493
|
+
a.order < 0 ? 1 :
|
494
|
+
a.order < b.order ? -1 :
|
495
|
+
1;
|
496
|
+
});
|
497
|
+
}
|
498
|
+
|
499
|
+
return groups;
|
500
|
+
}
|
501
|
+
|
502
|
+
function fillGroup( toolbarGroup, uiItems ) {
|
503
|
+
if ( uiItems.length ) {
|
504
|
+
if ( toolbarGroup.items )
|
505
|
+
toolbarGroup.items.push( editor.ui.create( '-' ) );
|
506
|
+
else
|
507
|
+
toolbarGroup.items = [];
|
508
|
+
|
509
|
+
var item, name;
|
510
|
+
while ( ( item = uiItems.shift() ) ) {
|
511
|
+
name = typeof item == 'string' ? item : item.name;
|
512
|
+
|
513
|
+
// Ignore items that are configured to be removed.
|
514
|
+
if ( !removeButtons || CKEDITOR.tools.indexOf( removeButtons, name ) == -1 ) {
|
515
|
+
item = editor.ui.create( name );
|
516
|
+
|
517
|
+
if ( !item )
|
518
|
+
continue;
|
519
|
+
|
520
|
+
if ( !editor.addFeature( item ) )
|
521
|
+
continue;
|
522
|
+
|
523
|
+
toolbarGroup.items.push( item );
|
524
|
+
}
|
525
|
+
}
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
function populateToolbarConfig( config ) {
|
530
|
+
var toolbar = [],
|
531
|
+
i, group, newGroup;
|
532
|
+
|
533
|
+
for ( i = 0; i < config.length; ++i ) {
|
534
|
+
group = config[ i ];
|
535
|
+
newGroup = {};
|
536
|
+
|
537
|
+
if ( group == '/' )
|
538
|
+
toolbar.push( group );
|
539
|
+
else if ( CKEDITOR.tools.isArray( group) ) {
|
540
|
+
fillGroup( newGroup, CKEDITOR.tools.clone( group ) );
|
541
|
+
toolbar.push( newGroup );
|
542
|
+
}
|
543
|
+
else if ( group.items ) {
|
544
|
+
fillGroup( newGroup, CKEDITOR.tools.clone( group.items ) );
|
545
|
+
newGroup.name = group.name;
|
546
|
+
toolbar.push( newGroup);
|
547
|
+
}
|
548
|
+
}
|
549
|
+
|
550
|
+
return toolbar;
|
551
|
+
}
|
552
|
+
|
553
|
+
var toolbar = editor.config.floatingtools;
|
554
|
+
|
555
|
+
// If it is a string, return the relative "toolbar_name" config.
|
556
|
+
if ( typeof toolbar == 'string' )
|
557
|
+
toolbar = editor.config[ 'floatingtools_' + toolbar ];
|
558
|
+
|
559
|
+
return ( editor.toolbar = toolbar ? populateToolbarConfig( toolbar ) : buildToolbarConfig() );
|
560
|
+
},
|
561
|
+
|
562
|
+
|
563
|
+
/**
|
564
|
+
* Return the default toolbar configuration.
|
565
|
+
*/
|
566
|
+
getPrivateFloatingToolbarGroups = function( editor ) {
|
567
|
+
return editor._.floatingToolsGroups || ( editor._.floatingToolsGroups = [
|
568
|
+
{ name: 'styles', items: [ 'Font','FontSize' ]},
|
569
|
+
{ name: 'format', items: [ 'Bold','Italic' ]},
|
570
|
+
{ name: 'paragraph', items: [ 'JustifyCenter','Outdent','Indent','NumberedList','BulletedList' ]}
|
571
|
+
]);
|
572
|
+
}
|
573
|
+
|
574
|
+
}
|
575
|
+
|
576
|
+
} );
|
577
|
+
|
578
|
+
|
579
|
+
})();
|
580
|
+
|
581
|
+
|
582
|
+
|