diff options
46 files changed, 1668 insertions, 461 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 |