1 /** |
|
2 * ResizeHandle.js |
|
3 * |
|
4 * Copyright, Moxiecode Systems AB |
|
5 * Released under LGPL License. |
|
6 * |
|
7 * License: http://www.tinymce.com/license |
|
8 * Contributing: http://www.tinymce.com/contributing |
|
9 */ |
|
10 |
|
11 /** |
|
12 * Renders a resize handle that fires ResizeStart, Resize and ResizeEnd events. |
|
13 * |
|
14 * @-x-less ResizeHandle.less |
|
15 * @class tinymce.ui.ResizeHandle |
|
16 * @extends tinymce.ui.Widget |
|
17 */ |
|
18 define("tinymce/ui/ResizeHandle", [ |
|
19 "tinymce/ui/Widget", |
|
20 "tinymce/ui/DragHelper" |
|
21 ], function(Widget, DragHelper) { |
|
22 "use strict"; |
|
23 |
|
24 return Widget.extend({ |
|
25 /** |
|
26 * Renders the control as a HTML string. |
|
27 * |
|
28 * @method renderHtml |
|
29 * @return {String} HTML representing the control. |
|
30 */ |
|
31 renderHtml: function() { |
|
32 var self = this, prefix = self.classPrefix; |
|
33 |
|
34 self.addClass('resizehandle'); |
|
35 |
|
36 if (self.settings.direction == "both") { |
|
37 self.addClass('resizehandle-both'); |
|
38 } |
|
39 |
|
40 self.canFocus = false; |
|
41 |
|
42 return ( |
|
43 '<div id="' + self._id + '" class="' + self.classes() + '">' + |
|
44 '<i class="' + prefix + 'ico ' + prefix + 'i-resize"></i>' + |
|
45 '</div>' |
|
46 ); |
|
47 }, |
|
48 |
|
49 /** |
|
50 * Called after the control has been rendered. |
|
51 * |
|
52 * @method postRender |
|
53 */ |
|
54 postRender: function() { |
|
55 var self = this; |
|
56 |
|
57 self._super(); |
|
58 |
|
59 self.resizeDragHelper = new DragHelper(this._id, { |
|
60 start: function() { |
|
61 self.fire('ResizeStart'); |
|
62 }, |
|
63 |
|
64 drag: function(e) { |
|
65 if (self.settings.direction != "both") { |
|
66 e.deltaX = 0; |
|
67 } |
|
68 |
|
69 self.fire('Resize', e); |
|
70 }, |
|
71 |
|
72 stop: function() { |
|
73 self.fire('ResizeEnd'); |
|
74 } |
|
75 }); |
|
76 }, |
|
77 |
|
78 remove: function() { |
|
79 if (this.resizeDragHelper) { |
|
80 this.resizeDragHelper.destroy(); |
|
81 } |
|
82 |
|
83 return this._super(); |
|
84 } |
|
85 }); |
|
86 }); |
|