-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.inline-attachment.js
66 lines (54 loc) · 1.35 KB
/
jquery.inline-attachment.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*jslint newcap: true */
/*global inlineAttachment: false, jQuery: false */
/**
* jQuery plugin for inline attach
*
* @param {document} document
* @param {window} window
* @param {jQuery} $
*/
(function(document, window, $) {
'use strict';
inlineAttachment.editors.jquery = {};
/**
* Creates a new editor using jQuery
*/
var editor = function(instance) {
var $this = $(instance);
return {
getValue: function() {
return $this.val();
},
insertValue: function(val) {
inlineAttachment.util.insertTextAtCursor($this[0], val);
},
setValue: function(val) {
$this.val(val);
}
};
};
$.fn.inlineattachment = function(options) {
var set = $(this);
set.each(function() {
var $this = $(this),
ed = new editor($this),
inlineattach = new inlineAttachment(options, ed);
$this.bind({
'paste': function(e) {
inlineattach.onPaste(e.originalEvent);
},
'drop': function(e) {
e.stopPropagation();
e.preventDefault();
inlineattach.onDrop(e.originalEvent);
},
'dragenter dragover': function(e) {
e.stopPropagation();
e.preventDefault();
}
});
});
return this;
};
inlineAttachment.editors.jquery.Editor = editor;
})(document, window, jQuery);