diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/tools/TextTool.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/tools/TextTool.js')
-rw-r--r-- | js/tools/TextTool.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/js/tools/TextTool.js b/js/tools/TextTool.js new file mode 100644 index 00000000..538583ee --- /dev/null +++ b/js/tools/TextTool.js | |||
@@ -0,0 +1,87 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | DrawingTool = require("js/tools/drawing-tool").DrawingTool; | ||
9 | |||
10 | exports.TextTool = Montage.create(DrawingTool, { | ||
11 | drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, | ||
12 | |||
13 | HandleLeftButtonDown: { | ||
14 | value: function(event) { | ||
15 | this.startDraw(event); | ||
16 | } | ||
17 | }, | ||
18 | |||
19 | HandleMouseMove: { | ||
20 | value: function(event) { | ||
21 | if(this._escape) { | ||
22 | this._escape = false; | ||
23 | this.isDrawing = true; | ||
24 | } | ||
25 | |||
26 | if(this.isDrawing) { | ||
27 | this._hasDraw = true; // Flag for position of element | ||
28 | this.doDraw(event); | ||
29 | } else { | ||
30 | this.doSnap(event); | ||
31 | } | ||
32 | |||
33 | this.drawLastSnap(); // Required cleanup for both Draw/Feedbacks | ||
34 | } | ||
35 | }, | ||
36 | |||
37 | |||
38 | HandleLeftButtonUp: { | ||
39 | value: function(event) { | ||
40 | if(this._escape) { | ||
41 | this._escape = false; | ||
42 | return; | ||
43 | } | ||
44 | |||
45 | var drawData, selectedItem; | ||
46 | |||
47 | if(this._hasDraw) { | ||
48 | drawData = this.getDrawingData(); | ||
49 | |||
50 | if(drawData) { | ||
51 | //this.insertElement(drawData); | ||
52 | } | ||
53 | |||
54 | this._hasDraw = false; | ||
55 | this.endDraw(event); | ||
56 | } else { | ||
57 | |||
58 | this.doSelection(event); | ||
59 | |||
60 | this._isDrawing = false; | ||
61 | } | ||
62 | } | ||
63 | }, | ||
64 | |||
65 | HandleDoubleClick: { | ||
66 | value: function(e) { | ||
67 | console.log(this.application.ninja.selectedElements[0]._element); | ||
68 | this.application.ninja.selectedElements[0]._element.setAttribute("contenteditable", true); | ||
69 | this.application.ninja.stage._iframeContainer.style.zIndex = 200; | ||
70 | this.application.ninja.selectedElements[0]._element.focus(); | ||
71 | |||
72 | |||
73 | } | ||
74 | }, | ||
75 | |||
76 | Configure: { | ||
77 | value: function(wasSelected) { | ||
78 | if(wasSelected) { | ||
79 | NJevent("enableStageMove"); | ||
80 | this.application.ninja.stage.stageDeps.snapManager.setupDragPlaneFromPlane( workingPlane ); | ||
81 | } else { | ||
82 | NJevent("disableStageMove"); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | }); \ No newline at end of file | ||