diff options
author | Armen Kesablyan | 2012-07-02 13:20:43 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-07-02 13:20:43 -0700 |
commit | 5a6b1fcf207817a7aa0ba7d0c1bea90f0ee5e8cb (patch) | |
tree | af71b72b828d942ebf11f565b7c9ccff0798343d /js/tools/TagTool.js | |
parent | 8966fc4903f0eec61816d9b9bdbcac9b7d99c320 (diff) | |
parent | 526b9d76686323f488f1b26175440172b715d808 (diff) | |
download | ninja-5a6b1fcf207817a7aa0ba7d0c1bea90f0ee5e8cb.tar.gz |
Merge branch 'refs/heads/master' into GIO-TextTool
Diffstat (limited to 'js/tools/TagTool.js')
-rwxr-xr-x | js/tools/TagTool.js | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index fac6798f..80e6150d 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js | |||
@@ -81,27 +81,56 @@ exports.TagTool = Montage.create(DrawingTool, { | |||
81 | // TODO: Add position support | 81 | // TODO: Add position support |
82 | insertElement: { | 82 | insertElement: { |
83 | value: function(drawData) { | 83 | value: function(drawData) { |
84 | var element, styles; | 84 | var element, styles, color; |
85 | 85 | ||
86 | // Create the element | 86 | // Create the element |
87 | if(this.options.selectedElement === "custom") { | 87 | if(this.options.selectedElement === "custom") { |
88 | element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument); | 88 | element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument); |
89 | |||
90 | } else { | 89 | } else { |
91 | element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); | 90 | element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); |
92 | } | 91 | } |
93 | 92 | ||
93 | // Adding a canplay event to videos to pause them and prevent autoplay on stage | ||
94 | if(this.options.selectedElement === "video") { | ||
95 | element.addEventListener("canplay", this, false); | ||
96 | } | ||
97 | |||
94 | // Create the styles | 98 | // Create the styles |
95 | styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); | 99 | styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); |
96 | 100 | ||
97 | // Add color | 101 | // Add color |
98 | if(this.options.getProperty("fill.colorMode") !== "nocolor") { | 102 | color = this.options.fill; |
99 | styles['background-color'] = this.options.getProperty("fill.color.css"); | 103 | switch(color.colorMode) { |
104 | case "nocolor": | ||
105 | break; | ||
106 | case "gradient": | ||
107 | styles['background-image'] = color.color.css; | ||
108 | break; | ||
109 | default: | ||
110 | styles['background-color'] = color.color.css; | ||
100 | } | 111 | } |
101 | 112 | ||
102 | // Add the element and styles | 113 | // Add the element and styles |
103 | this.application.ninja.elementMediator.addElements(element, styles); | 114 | this.application.ninja.elementMediator.addElements(element, styles); |
104 | } | 115 | } |
116 | }, | ||
117 | |||
118 | handleCanplay: { | ||
119 | value: function(event) { | ||
120 | //TODO: Figure out why the video must be seeked to the end before pausing | ||
121 | var time = Math.ceil(event.target.duration); | ||
122 | //Trying to display the last frame (doing minus 2 seconds if long video) | ||
123 | if (time > 2) { | ||
124 | event.target.currentTime = time - 2; | ||
125 | } else if (time > 1) { | ||
126 | event.target.currentTime = time - 1; | ||
127 | } else { | ||
128 | event.target.currentTime = time || 0; | ||
129 | } | ||
130 | //Pauing video | ||
131 | event.target.pause(); | ||
132 | } | ||
105 | } | 133 | } |
134 | |||
106 | }); | 135 | }); |
107 | 136 | ||