aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorKruti Shah2012-06-22 10:00:53 -0700
committerKruti Shah2012-06-22 10:00:53 -0700
commit4bf8e4cdc179c3b388fc06f26008808aa4b77eb0 (patch)
tree743ea0d3a3af9cae65d5af531a6dba1951b03b33 /js
parentcb9fbfeba90b5b76d3f3f2b9303129ca4651e5be (diff)
parent020ad879a627c4234a8732f05e175ad69cedf180 (diff)
downloadninja-4bf8e4cdc179c3b388fc06f26008808aa4b77eb0.tar.gz
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'js')
-rw-r--r--js/clipboard/external-apps-clipboard-agent.js220
-rw-r--r--js/clipboard/internal-ops/component-clipboard-agent.js40
-rw-r--r--js/clipboard/internal-ops/css-clipboard-agent.js40
-rw-r--r--js/clipboard/internal-ops/elements-clipboard-agent.js364
-rw-r--r--js/clipboard/internal-ops/timeline-clipboard-agent.js40
-rw-r--r--js/clipboard/util.js28
-rwxr-xr-xjs/components/gradientpicker.reel/gradientpicker.js67
-rwxr-xr-xjs/components/tools-properties/brush-properties.reel/brush-properties.html2
-rwxr-xr-xjs/components/tools-properties/fill-properties.reel/fill-properties.html2
-rwxr-xr-xjs/components/tools-properties/ink-bottle-properties.reel/ink-bottle-properties.html2
-rwxr-xr-xjs/components/tools-properties/pen-properties.reel/pen-properties.html4
-rwxr-xr-xjs/components/tools-properties/shape-properties.reel/shape-properties.html5
-rwxr-xr-xjs/components/tools-properties/shape-properties.reel/shape-properties.js8
-rwxr-xr-xjs/components/tools-properties/tag-properties.reel/tag-properties.html2
-rwxr-xr-xjs/components/tools-properties/text-properties.reel/text-properties.css4
-rwxr-xr-xjs/components/tools-properties/text-properties.reel/text-properties.html2
-rw-r--r--js/controllers/clipboard-controller.js120
-rwxr-xr-xjs/controllers/styles-controller.js66
-rwxr-xr-xjs/data/menu-data.js9
-rwxr-xr-xjs/helper-classes/3D/StageLine.js309
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js46
-rwxr-xr-xjs/mediators/drag-drop-mediator.js108
-rw-r--r--js/mediators/io-mediator.js59
-rwxr-xr-xjs/mediators/keyboard-mediator.js9
-rwxr-xr-xjs/ninja.reel/ninja.html15
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js6
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js.orig2115
-rw-r--r--js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js60
-rw-r--r--js/panels/css-panel/styles-view-container.reel/styles-view-container.js2
-rwxr-xr-xjs/panels/properties.reel/properties.css10
-rwxr-xr-xjs/stage/stage.reel/stage.js2
-rwxr-xr-xjs/tools/SelectionTool.js17
32 files changed, 1347 insertions, 2436 deletions
diff --git a/js/clipboard/external-apps-clipboard-agent.js b/js/clipboard/external-apps-clipboard-agent.js
new file mode 100644
index 00000000..7e55cf08
--- /dev/null
+++ b/js/clipboard/external-apps-clipboard-agent.js
@@ -0,0 +1,220 @@
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//
9
10var Montage = require("montage/core/core").Montage,
11 Component = require("montage/ui/component").Component,
12 ClipboardUtil = require("js/clipboard/util").ClipboardUtil;
13
14var ExternalAppsClipboardAgent = exports.ExternalAppsClipboardAgent = Montage.create(Component, {
15
16 paste:{
17 value: function(clipboardEvent){
18 var clipboardData = clipboardEvent.clipboardData,
19 htmlData = clipboardData.getData("text/html"),
20 textData = clipboardData.getData("text/plain"),
21 i=0,
22 imageMime, imageData, imageElement;
23
24 //handle image blobs
25 if(clipboardData.items && (clipboardData.items.length > 0)){
26 for(i=0; i < clipboardData.items.length; i++ ){
27 if((clipboardData.items[i].kind === "file") && (clipboardData.items[i].type.indexOf("image") === 0)){//example type -> "image/png"
28 imageMime = clipboardData.items[i].type;
29 imageData = clipboardData.items[i].getAsFile();
30 try{
31 imageElement = this.pasteImageBinary(imageData);
32 }catch(e){
33 console.log(""+e.stack);
34 }
35 this.application.ninja.selectionController.selectElements(imageElement);
36 this.application.ninja.currentDocument.model.needsSave = true;
37
38 }
39 }
40 }
41
42 try{
43 if(!!htmlData || !!textData){
44 this.pasteHtml(htmlData, textData);
45 }
46 }catch(e){
47 console.log(""+e.stack);
48 }
49
50 }
51 },
52
53 //todo: this will be moved to a seperate api
54 pasteImageBinary:{
55 value: function(imageBlob){
56 var element, self = this,
57 fileType = imageBlob.type;
58
59 element = this.application.ninja.ioMediator.createFileFromBinary(imageBlob, {"addFileToStage" : self.addImageElement.bind(self)});
60
61 return element;
62
63 }
64 },
65
66 addImageElement:{
67 value: function(status){
68 var save = status.save,
69 fileName = status.filename,
70 url = status.url,
71 fileType = status.fileType,
72 element, rules, self = this;
73
74 if (save && save.success && save.status === 201) {
75 //
76 if (fileType.indexOf('svg') !== -1) {
77 element = document.application.njUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper
78 element.type = 'image/svg+xml';
79 element.src = url+'/'+fileName;
80 } else {
81 element = document.application.njUtils.make('image', null, this.application.ninja.currentDocument);
82 element.src = url+'/'+fileName;
83 }
84 //Adding element once it is loaded
85 element.onload = function () {
86 element.onload = null;
87 self.application.ninja.elementMediator.addElements(element, rules, true);
88 };
89 //Setting rules of element
90 rules = {
91 'position': 'absolute',
92 'top' : '100px',
93 'left' : '100px'
94 };
95 //
96 self.application.ninja.elementMediator.addElements(element, rules, false);
97 } else {
98 //TODO: HANDLE ERROR ON SAVING FILE TO BE ADDED AS ELEMENT
99 }
100
101 return element;
102 }
103 },
104
105 //paste from external applicaitons
106 pasteHtml:{//todo: change to pasteNinja, pasteHTML, etc
107 value: function(htmlData, textData){
108 var i=0, j=0,
109 pasteDataObject=null,
110 pastedElements = [],
111 node = null, nodeList = null,
112 styles = null,
113 divWrapper = null,
114 spanWrapper = null,
115 metaEl = null,
116 self = this;
117
118 if(htmlData){
119
120 //TODO: cleanse HTML
121
122 htmlData.replace(/[<script]/g," ");
123
124 this.application.ninja.selectedElements.length = 0;
125 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": true} );
126
127 try{
128 nodeList = ClipboardUtil.deserializeHtmlString(htmlData);//this removes html and body tags
129 }
130 catch(e){
131 console.log(""+e.stack);
132 }
133
134 for(i=0; i < nodeList.length; i++){
135 if(nodeList[i].tagName === "META") {
136 nodeList[i] = null;
137 }
138 else if (nodeList[i].tagName === "CANVAS"){
139 //can't paste external canvas for lack of all metadata
140 nodeList[i] = null;
141 }
142 else if((nodeList[i].nodeType === 3) || (nodeList[i].tagName === "A")){
143 node = nodeList[i].cloneNode(true);
144
145 divWrapper = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
146 spanWrapper = document.application.njUtils.make("span", null, this.application.ninja.currentDocument);
147 spanWrapper.appendChild(node);
148 divWrapper.appendChild(spanWrapper);
149 styles = {"position":"absolute", "top":"100px", "left":"100px"};
150
151 this.pastePositioned(divWrapper, styles);
152
153 nodeList[i] = null;
154 pastedElements.push(divWrapper);
155
156 }else if(nodeList[i].tagName === "SPAN"){
157 node = nodeList[i].cloneNode(true);
158
159 divWrapper = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
160 divWrapper.appendChild(node);
161 styles = {"position":"absolute", "top":"100px", "left":"100px"};
162