ResizeHandle.js
1.68 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* ResizeHandle.js
*
* Released under LGPL License.
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
/**
* Renders a resize handle that fires ResizeStart, Resize and ResizeEnd events.
*
* @-x-less ResizeHandle.less
* @class tinymce.ui.ResizeHandle
* @extends tinymce.ui.Widget
*/
define("tinymce/ui/ResizeHandle", [
"tinymce/ui/Widget",
"tinymce/ui/DragHelper"
], function(Widget, DragHelper) {
"use strict";
return Widget.extend({
/**
* Renders the control as a HTML string.
*
* @method renderHtml
* @return {String} HTML representing the control.
*/
renderHtml: function() {
var self = this, prefix = self.classPrefix;
self.classes.add('resizehandle');
if (self.settings.direction == "both") {
self.classes.add('resizehandle-both');
}
self.canFocus = false;
return (
'<div id="' + self._id + '" class="' + self.classes + '">' +
'<i class="' + prefix + 'ico ' + prefix + 'i-resize"></i>' +
'</div>'
);
},
/**
* Called after the control has been rendered.
*
* @method postRender
*/
postRender: function() {
var self = this;
self._super();
self.resizeDragHelper = new DragHelper(this._id, {
start: function() {
self.fire('ResizeStart');
},
drag: function(e) {
if (self.settings.direction != "both") {
e.deltaX = 0;
}
self.fire('Resize', e);
},
stop: function() {
self.fire('ResizeEnd');
}
});
},
remove: function() {
if (this.resizeDragHelper) {
this.resizeDragHelper.destroy();
}
return this._super();
}
});
});