1 // https://civicrm.org/licensing
3 // This defines an interface which by default only handles plain textareas
4 // A wysiwyg implementation can extend this by overriding as many of these functions as needed
6 supportsFileUploads
: false,
10 getVal: function(item
) {
13 setVal: function(item
, val
) {
14 return $(item
).val(val
);
16 insert: function(item
, text
) {
17 CRM
.wysiwyg
._insertIntoTextarea(item
, text
);
19 focus: function(item
) {
22 // Fallback function to use when a wysiwyg has not been initialized
23 _insertIntoTextarea: function(item
, text
) {
24 var origVal
= $(item
).val();
25 var origPos
= item
[0].selectionStart
;
26 var newVal
= origVal
+ text
;
28 var newPos
= (origPos
+ text
.length
);
29 item
[0].selectionStart
= newPos
;
30 item
[0].selectionEnd
= newPos
;
31 $(item
).triggerHandler('change');
32 CRM
.wysiwyg
.focus(item
);
34 createCollapsed: function(item
) {
37 .after('<div class="replace-plain" tabindex="0"></div>')
38 .on('blur', function () {
39 CRM
.wysiwyg
.destroy(item
);
40 $(item
).hide().next('.replace-plain').show().html($(item
).val());
42 $(item
).next('.replace-plain').attr('title', ts('Click to edit')).on('click keypress', function () {
43 $(item
).show().next('.replace-plain').hide();
44 CRM
.wysiwyg
.create(item
);