diff options
author | Kruti Shah | 2012-06-22 10:00:53 -0700 |
---|---|---|
committer | Kruti Shah | 2012-06-22 10:00:53 -0700 |
commit | 4bf8e4cdc179c3b388fc06f26008808aa4b77eb0 (patch) | |
tree | 743ea0d3a3af9cae65d5af531a6dba1951b03b33 | |
parent | cb9fbfeba90b5b76d3f3f2b9303129ca4651e5be (diff) | |
parent | 020ad879a627c4234a8732f05e175ad69cedf180 (diff) | |
download | ninja-4bf8e4cdc179c3b388fc06f26008808aa4b77eb0.tar.gz |
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
35 files changed, 1363 insertions, 2440 deletions
diff --git a/css/ninja.css b/css/ninja.css index 4d2de3ee..d98aa513 100755 --- a/css/ninja.css +++ b/css/ninja.css | |||
@@ -677,7 +677,9 @@ nav.menuBar ul li:hover ul, nav.menuBar ul ul li:hover ul, nav.menuBar ul ul ul | |||
677 | 677 | ||
678 | .toolOptionsSpacer { margin-right: 9px; } | 678 | .toolOptionsSpacer { margin-right: 9px; } |
679 | 679 | ||
680 | .toolColorChipCtrl { width: 18px; height: 18px; margin-top: 1px; margin-left: 3px; margin-right: 8px; border: 1px black solid; } | 680 | .toolColorChipCtrl { width: 16px; height: 16px; border: 1px #000 solid; } |
681 | |||
682 | .toolColorChipContainer { background: url(../../../../../images/colorpanel/transparent.png) repeat; width: 18px; height: 18px; margin-top: 1px; margin-left: 3px; margin-right: 8px; border: 1px #777 solid; } | ||
681 | 683 | ||
682 | .toolColorChipIcon { width: 20px; height: 20px; margin-top: 1px; -webkit-transform: scale(0.8); background-color: #282828; } | 684 | .toolColorChipIcon { width: 20px; height: 20px; margin-top: 1px; -webkit-transform: scale(0.8); background-color: #282828; } |
683 | 685 | ||
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> | ||
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 | |||
10 | var Montage = require("montage/core/core").Montage, | ||
11 | Component = require("montage/ui/component").Component, | ||
12 | ClipboardUtil = require("js/clipboard/util").ClipboardUtil; | ||
13 | |||
14 | var 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); | ||