diff options
-rwxr-xr-x | js/components/menu/menu-entry.reel/menu-entry.js | 4 | ||||
-rwxr-xr-x | js/components/menu/menu-item.reel/menu-item.js | 1 | ||||
-rwxr-xr-x | js/components/menu/menu.reel/menu.js | 9 | ||||
-rw-r--r-- | js/controllers/clipboard-controller.js | 698 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 66 | ||||
-rwxr-xr-x | js/data/menu-data.js | 9 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 8 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 2 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.html | 15 | ||||
-rw-r--r-- | js/panels/css-panel/styles-view-container.reel/styles-view-container.js | 2 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 2 | ||||
-rw-r--r-- | manifest.json | 4 |
12 files changed, 783 insertions, 37 deletions
diff --git a/js/components/menu/menu-entry.reel/menu-entry.js b/js/components/menu/menu-entry.reel/menu-entry.js index b9c546ed..ae3469c6 100755 --- a/js/components/menu/menu-entry.reel/menu-entry.js +++ b/js/components/menu/menu-entry.reel/menu-entry.js | |||
@@ -83,7 +83,7 @@ exports.MenuEntry = Montage.create(Component, { | |||
83 | } | 83 | } |
84 | }, | 84 | }, |
85 | 85 | ||
86 | handleClick: { | 86 | captureMousedown: { |
87 | value: function(event) { | 87 | value: function(event) { |
88 | // TODO: Hack! Rework this! | 88 | // TODO: Hack! Rework this! |
89 | this.parentComponent.ownerComponent.toggleActivation(this); | 89 | this.parentComponent.ownerComponent.toggleActivation(this); |
@@ -105,7 +105,7 @@ exports.MenuEntry = Montage.create(Component, { | |||
105 | 105 | ||
106 | this.topHeaderText.innerHTML = this.data.header; | 106 | this.topHeaderText.innerHTML = this.data.header; |
107 | 107 | ||
108 | this.element.addEventListener("click", this, false); | 108 | this.element.addEventListener("mousedown", this, true); |
109 | 109 | ||
110 | Object.defineBinding(this, "menuIsActive", { | 110 | Object.defineBinding(this, "menuIsActive", { |
111 | boundObject: this._menu, | 111 | boundObject: this._menu, |
diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js index f9a625a3..5ff6b024 100755 --- a/js/components/menu/menu-item.reel/menu-item.js +++ b/js/components/menu/menu-item.reel/menu-item.js | |||
@@ -137,7 +137,6 @@ exports.MenuItem = Montage.create(Component, { | |||
137 | 137 | ||
138 | captureMousedown: { | 138 | captureMousedown: { |
139 | value: function(event) { | 139 | value: function(event) { |
140 | |||
141 | if(this.data.radio && this.checked) return; | 140 | if(this.data.radio && this.checked) return; |
142 | 141 | ||
143 | if( ( this.enabled === true || this.enabled > 0 ) && (this.submenu === false) ) { | 142 | if( ( this.enabled === true || this.enabled > 0 ) && (this.submenu === false) ) { |
diff --git a/js/components/menu/menu.reel/menu.js b/js/components/menu/menu.reel/menu.js index 50d3f0bc..1560100a 100755 --- a/js/components/menu/menu.reel/menu.js +++ b/js/components/menu/menu.reel/menu.js | |||
@@ -83,19 +83,12 @@ exports.Menu = Montage.create(Component, { | |||
83 | 83 | ||
84 | handleMousedown: { | 84 | handleMousedown: { |
85 | value: function(evt) { | 85 | value: function(evt) { |
86 | |||
87 | if(this.active && (this.getZIndex(evt.target) < 9000 || evt.target.id === "topMenu")) { | 86 | if(this.active && (this.getZIndex(evt.target) < 9000 || evt.target.id === "topMenu")) { |
88 | this._activeEntry.deselect(); | 87 | this._activeEntry.deselect(); |
89 | this._activeEntry = null; | 88 | this._activeEntry = null; |
90 | this.active = false; | 89 | this.active = false; |
91 | 90 | this.element.ownerDocument.removeEventListener('mousedown', this, false); | |
92 | //console.log(this.rep.objects[1]); | ||
93 | //this.controller.content[1].header = "BLAH"; | ||
94 | } | 91 | } |
95 | |||
96 | // console.log(evt.target.style['z-index']); | ||
97 | // console.log(this.getZIndex(evt.target)); | ||
98 | |||
99 | } | 92 | } |
100 | }, | 93 | }, |
101 | 94 | ||
diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js new file mode 100644 index 00000000..bc78922c --- /dev/null +++ b/js/controllers/clipboard-controller.js | |||
@@ -0,0 +1,698 @@ | |||
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 | //////////////////////////////////////////////////////////////////////// | ||
8 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | Component = require("montage/ui/component").Component, | ||
11 | NJUtils = require("js/lib/NJUtils").NJUtils, | ||
12 | World = require("js/lib/drawing/world").World; | ||
13 | |||
14 | var ClipboardController = exports.ClipboardController = Montage.create(Component, { | ||
15 | hasTemplate: { | ||
16 | value: false | ||
17 | }, | ||
18 | |||
19 | deserializedFromTemplate: { | ||
20 | value: function() { | ||
21 | document.body.addEventListener("copy", this, false); | ||
22 | document.body.addEventListener("cut", this, false); | ||
23 | document.body.addEventListener("paste", this, false); | ||
24 | |||
25 | //ninja menu events | ||
26 | this.eventManager.addEventListener("executeCut", this, false); | ||
27 | this.eventManager.addEventListener("executeCopy", this, false); | ||
28 | this.eventManager.addEventListener("executePaste", this, false); | ||
29 | |||
30 | } | ||
31 | }, | ||
32 | |||
33 | clipboardOperationsAgent:{//appropriate agent instant required for execution of cut/copy/paste | ||
34 | value: null | ||
35 | }, | ||
36 | |||
37 | //count how many times pasted | ||
38 | //used to move multiple pastes of same copy | ||
39 | pasteCounter:{ | ||
40 | value: 0 | ||
41 | }, | ||
42 | |||
43 | copiedObjects:{ | ||
44 | value: {} | ||
45 | }, | ||
46 | |||
47 | _copyFlag:{ | ||
48 | value:false | ||
49 | }, | ||
50 | |||
51 | copyFlag:{ | ||
52 | get:function(){return this._copyFlag;}, | ||
53 | set:function(value){this._copyFlag = value;} | ||
54 | }, | ||
55 | |||
56 | _newCopyFlag:{ | ||
57 | value:true | ||
58 | }, | ||
59 | |||
60 | newCopyFlag:{ | ||
61 | get:function(){return this._newCopyFlag;}, | ||
62 | set:function(value){this._newCopyFlag = value;} | ||
63 | }, | ||
64 | |||
65 | handleExecuteCopy:{ | ||
66 | value: function(){document.execCommand('copy',false,null);} | ||
67 | }, | ||
68 | |||
69 | handleExecuteCut:{ | ||
70 | value: function(){document.execCommand('cut',false,null);} | ||
71 | }, | ||
72 | |||
73 | handleExecutePaste:{ | ||
74 | value: function(){document.execCommand('paste',false,null);} | ||
75 | }, | ||
76 | |||
77 | handleCopy:{ | ||
78 | value:function(clipboardEvent){ | ||
79 | if(!this.application.ninja.currentDocument | ||
80 | || (this.application.ninja.currentDocument && this.application.ninja.currentDocument.currentView === "code")){ | ||
81 | |||
82 | return; | ||
83 | }//for design view only | ||
84 | |||
85 | // Don't do anything if an input or other control is focused | ||
86 | if(document.activeElement.nodeName !== "BODY") { | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | this.copy(clipboardEvent); | ||
91 | |||
92 | clipboardEvent.preventDefault(); | ||
93 | } | ||
94 | }, | ||
95 | |||
96 | handleCut:{ | ||
97 | value:function(clipboardEvent){ | ||
98 | if(this.application.ninja.currentDocument.currentView === "code") return; | ||
99 | |||
100 | // Don't do anything if an input or other control is focused | ||
101 | if(document.activeElement.nodeName !== "BODY") { | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | this.cut(clipboardEvent); | ||
106 | |||
107 | clipboardEvent.preventDefault(); | ||
108 | } | ||
109 | }, | ||
110 | |||
111 | handlePaste:{ | ||
112 | value:function(clipboardEvent){ | ||
113 | var clipboardData = clipboardEvent.clipboardData, | ||
114 | ninjaData = clipboardData.getData("ninja"), | ||
115 | htmlData = clipboardData.getData("text/html"), | ||
116 | textData = clipboardData.getData("text/plain"), | ||
117 | i=0, | ||
118 | imageMime, imageData, imageElement; | ||
119 | |||
120 | if(!this.application.ninja.currentDocument | ||
121 | || (this.application.ninja.currentDocument && this.application.ninja.currentDocument.currentView === "code")){ | ||
122 | |||
123 | return; | ||
124 | }//for design view only | ||
125 | |||
126 | // Don't do anything if an input or other control is focused | ||
127 | if(document.activeElement.nodeName !== "BODY") { | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | //TODO: return if stage is not focussed | ||
132 | |||
133 | this.pasteCounter++; | ||
134 | |||
135 | if(ninjaData){ | ||
136 | if(this.copiedObjects.copy){this.pasteFromCopy();} | ||
137 | else if(this.copiedObjects.cut){this.pasteFromCut();} | ||
138 | } | ||
139 | else{ | ||
140 | |||
141 | //handle image blobs | ||
142 | if(clipboardData.items && (clipboardData.items.length > 0)){ | ||
143 | for(i=0; i < clipboardData.items.length; i++ ){ | ||
144 | if((clipboardData.items[i].kind === "file") && (clipboardData.items[i].type.indexOf("image") === 0)){//example type -> "image/png" | ||
145 | imageMime = clipboardData.items[i].type; | ||
146 |