Revision 551d4b78
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
js/kivi.js | ||
---|---|---|
27 | 27 |
ns._locale = locale; |
28 | 28 |
}; |
29 | 29 |
|
30 |
ns.set_focus = function(element) { |
|
31 |
var $e = $(element).eq(0); |
|
32 |
if ($e.data('ckeditorInstance')) |
|
33 |
ns.focus_ckeditor_when_ready($e); |
|
34 |
else |
|
35 |
$e.focus(); |
|
36 |
}; |
|
37 |
|
|
38 |
ns.focus_ckeditor_when_ready = function(element) { |
|
39 |
$(element).ckeditor(function() { ns.focus_ckeditor(element); }); |
|
40 |
}; |
|
41 |
|
|
42 |
ns.focus_ckeditor = function(element) { |
|
43 |
var editor = $(element).ckeditorGet(); |
|
44 |
var editable = editor.editable(); |
|
45 |
|
|
46 |
if (editable.is('textarea')) { |
|
47 |
var textarea = editable.$; |
|
48 |
|
|
49 |
if (CKEDITOR.env.ie) |
|
50 |
textarea.createTextRange().execCommand('SelectAll'); |
|
51 |
else { |
|
52 |
textarea.selectionStart = 0; |
|
53 |
textarea.selectionEnd = textarea.value.length; |
|
54 |
} |
|
55 |
|
|
56 |
textarea.focus(); |
|
57 |
|
|
58 |
} else { |
|
59 |
if (editable.is('body')) |
|
60 |
editor.document.$.execCommand('SelectAll', false, null); |
|
61 |
|
|
62 |
else { |
|
63 |
var range = editor.createRange(); |
|
64 |
range.selectNodeContents(editable); |
|
65 |
range.select(); |
|
66 |
} |
|
67 |
|
|
68 |
editor.forceNextSelectionCheck(); |
|
69 |
editor.selectionChange(); |
|
70 |
|
|
71 |
editor.focus(); |
|
72 |
} |
|
73 |
}; |
|
74 |
|
|
30 | 75 |
ns.init_tabwidget = function(element) { |
31 | 76 |
var $element = $(element); |
32 | 77 |
var tabsParams = {}; |
... | ... | |
44 | 89 |
$element.tabs(tabsParams); |
45 | 90 |
}; |
46 | 91 |
|
92 |
ns.init_text_editor = function(element) { |
|
93 |
var layouts = { |
|
94 |
all: [ [ 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript' ], [ 'BulletedList', 'NumberedList' ], [ 'RemoveFormat' ] ], |
|
95 |
default: [ [ 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript' ], [ 'BulletedList', 'NumberedList' ], [ 'RemoveFormat' ] ] |
|
96 |
}; |
|
97 |
|
|
98 |
var $e = $(element); |
|
99 |
var buttons = layouts[ $e.data('texteditor-layout') || 'default' ] || layouts['default']; |
|
100 |
var config = { |
|
101 |
entities: false, |
|
102 |
language: 'de', |
|
103 |
removePlugins: 'resize', |
|
104 |
toolbar: buttons |
|
105 |
} |
|
106 |
|
|
107 |
var style = $e.prop('style'); |
|
108 |
$(['width', 'height']).each(function(idx, prop) { |
|
109 |
var matches = (style[prop] || '').match(/(\d+)px/); |
|
110 |
if (matches && (matches.length > 1)) |
|
111 |
config[prop] = matches[1]; |
|
112 |
}); |
|
113 |
|
|
114 |
$e.ckeditor(config); |
|
115 |
|
|
116 |
if ($e.hasClass('texteditor-autofocus')) |
|
117 |
$e.ckeditor(function() { ns.focus_ckeditor($e); }); |
|
118 |
}; |
|
119 |
|
|
47 | 120 |
ns.reinit_widgets = function() { |
48 | 121 |
ns.run_once_for('.datepicker', 'datepicker', function(elt) { |
49 | 122 |
$(elt).datepicker(); |
... | ... | |
63 | 136 |
}); |
64 | 137 |
|
65 | 138 |
ns.run_once_for('.tabwidget', 'tabwidget', kivi.init_tabwidget); |
139 |
ns.run_once_for('.texteditor', 'texteditor', kivi.init_text_editor); |
|
66 | 140 |
}; |
67 | 141 |
|
68 | 142 |
ns.submit_ajax_form = function(url, form_selector, additional_data) { |
Auch abrufbar als: Unified diff
kivi.js: ckeditor über Klasse »texteditor« nutzen können