aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/controllers/clipboard-controller.js103
-rwxr-xr-xjs/data/menu-data.js9
-rwxr-xr-xjs/ninja.reel/ninja.html17
3 files changed, 120 insertions, 9 deletions
diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js
new file mode 100644
index 00000000..d26aaa80
--- /dev/null
+++ b/js/controllers/clipboard-controller.js
@@ -0,0 +1,103 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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////////////////////////////////////////////////////////////////////////
8//
9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component;
11
12var ClipboardController = exports.ClipboardController = Montage.create(Component, {
13 hasTemplate: {
14 value: false
15 },
16
17 deserializedFromTemplate: {
18 value: function() {
19 document.body.addEventListener("copy", this, false);
20 document.body.addEventListener("cut", this, false);
21 document.body.addEventListener("paste", this, false);
22
23 //ninja menu events
24 this.eventManager.addEventListener("executeCut", this, false);
25 this.eventManager.addEventListener("executeCopy", this, false);
26 this.eventManager.addEventListener("executePaste", this, false);
27 }
28 },
29
30 _copyFlag:{
31 value:false
32 },
33
34 copyFlag:{
35 get:function(){return this._copyFlag;},
36 set:function(value){this._copyFlag = value;}
37 },
38
39 _newCopyFlag:{
40 value:true
41 },
42
43 newCopyFlag:{
44 get:function(){return this._newCopyFlag;},
45 set:function(value){this._newCopyFlag = value;}
46 },
47
48 handleExecuteCopy:{
49 value: function(){document.execCommand('copy',false,null);}
50 },
51
52 handleExecuteCut:{
53 value: function(){document.execCommand('cut',false,null);}
54 },
55
56 handleExecutePaste:{
57 value: function(){document.execCommand('paste',false,null);}
58 },
59
60 handleCopy:{
61 value:function(clipboardEvent){
62 //depends on the clipboard event
63 if(this.application.ninja.selectedElements.length > 0){
64 clipboardEvent.clipboardData.setData('text/html', ''+this.application.ninja.selectedElements[0].outerHTML);//copying first selected element for POC
65
66 clipboardEvent.preventDefault();
67 }
68 }
69 },
70
71 handleCut:{
72 value:function(clipboardEvent){
73 var clipboardData = clipboardEvent.clipboardData,
74 htmlData = clipboardData.getData("text/html"),
75 textData = clipboardData.getData("text/plain");
76
77 console.log("$$$ handleCut ", textData);
78
79
80 clipboardEvent.preventDefault();
81 }
82 },
83
84 handlePaste:{
85 value:function(clipboardEvent){
86 var clipboardData = clipboardEvent.clipboardData,
87 htmlData = clipboardData.getData("text/html"),
88 textData = clipboardData.getData("text/plain"),
89 data = null;
90
91 data = htmlData || textData;
92
93 if(data){
94 //hack - to avoid parsing html code now
95
96 this.application.ninja.documentController.activeDocument.documentRoot.innerHTML = data + this.application.ninja.documentController.activeDocument.documentRoot.innerHTML;
97
98 }
99
100 clipboardEvent.preventDefault();
101 }
102 }
103}); \ No newline at end of file
diff --git a/js/data/menu-data.js b/js/data/menu-data.js
index 9e8bf945..e18fb5cf 100755
--- a/js/data/menu-data.js
+++ b/js/data/menu-data.js
@@ -173,17 +173,20 @@ exports.MenuData = Montage.create( Montage, {
173 { 173 {
174 "displayText" : "Cut", 174 "displayText" : "Cut",
175 "hasSubMenu" : false, 175 "hasSubMenu" : false,
176 "enabled": false 176 "enabled": true,
177 "action": "executeCut"
177 }, 178 },
178 { 179 {
179 "displayText" : "Copy", 180 "displayText" : "Copy",
180 "hasSubMenu" : false, 181 "hasSubMenu" : false,
181 "enabled": false 182 "enabled": true,
183 "action": "executeCopy"
182 }, 184 },
183 { 185 {
184 "displayText" : "Paste", 186 "displayText" : "Paste",
185 "hasSubMenu" : false, 187 "hasSubMenu" : false,
186 "enabled": false 188 "enabled": true,
189 "action": "executePaste"
187 } 190 }
188 ] 191 ]
189 }, 192 },
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html
index 52a6daa2..b955a4c9 100755
--- a/js/ninja.reel/ninja.html
+++ b/js/ninja.reel/ninja.html
@@ -1,4 +1,4 @@
1<!DOCTYPE html> 1<!DOCTYPE html>
2 2
3<!-- <copyright> 3<!-- <copyright>
4 This file contains proprietary software owned by Motorola Mobility, Inc. 4 This file contains proprietary software owned by Motorola Mobility, Inc.
@@ -321,12 +321,16 @@
321 "prototype": "js/controllers/code-editor-controller" 321 "prototype": "js/controllers/code-editor-controller"
322 }, 322 },
323 323
324 "clipboardController": {
325 "prototype": "js/controllers/clipboard-controller[ClipboardController]"
326 },
327
324 "owner": { 328 "owner": {
325 "prototype": "js/ninja.reel", 329 "prototype": "js/ninja.reel",
326 "properties": { 330 "properties": {
327 "element": {"#": "main"}, 331 "element": {"#": "main"},
328 "rulerTop": {"#": "rulerTop"}, 332 "rulerTop": {"#": "rulerTop"},
329 "rulerLeft": {"#": "rulerLeft"}, 333 "rulerLeft": {"#": "rulerLeft"},
330 "appModel": {"@": "appModel"}, 334 "appModel": {"@": "appModel"},
331 "toolsData": {"@": "toolsData1"}, 335 "toolsData": {"@": "toolsData1"},
332 "toolsList": {"@": "toolsList1"}, 336 "toolsList": {"@": "toolsList1"},
@@ -340,10 +344,10 @@
340 "popupManager": {"@": "popupManager1"}, 344 "popupManager": {"@": "popupManager1"},
341 "colorController": {"@": "colorController1"}, 345 "colorController": {"@": "colorController1"},
342 "stylesController": {"@": "stylesController"}, 346 "stylesController": {"@": "stylesController"},
343 "presetsController": {"@": "presetsController"}, 347 "presetsController": {"@": "presetsController"},
344 "filePickerController": {"@": "filePickerController"}, 348 "filePickerController": {"@": "filePickerController"},
345 "newFileController": {"@": "newFileController"}, 349 "newFileController": {"@": "newFileController"},
346 "coreIoApi": {"@": "coreIoApi1"}, 350 "coreIoApi": {"@": "coreIoApi1"},
347 "documentBar": {"@": "documentBar"}, 351 "documentBar": {"@": "documentBar"},
348 "editorViewOptions": {"@": "editorViewOptions"}, 352 "editorViewOptions": {"@": "editorViewOptions"},
349 "ioMediator": {"@": "ioMediator"}, 353 "ioMediator": {"@": "ioMediator"},
@@ -354,7 +358,8 @@
354 "panelSplitter": {"@": "splitter3"}, 358 "panelSplitter": {"@": "splitter3"},
355 "timelineSplitter": {"@": "splitter4"}, 359 "timelineSplitter": {"@": "splitter4"},
356 "toolsSplitter": {"@": "splitter2"}, 360 "toolsSplitter": {"@": "splitter2"},
357 "optionsSplitter": {"@": "splitter1"} 361 "optionsSplitter": {"@": "splitter1"},
362 "clipboardController": {"@": "clipboardController"}
358 } 363 }
359 } 364 }
360 } 365 }