OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Base class that Ribbon uses to display photos. | 6 * Base class that Ribbon uses to display photos. |
7 */ | 7 */ |
8 | 8 |
9 function RibbonClient() {} | 9 function RibbonClient() {} |
10 | 10 |
11 RibbonClient.prototype.prefetchImage = function(id, url) {}; | 11 RibbonClient.prototype.prefetchImage = function(id, url) {}; |
12 | 12 |
13 RibbonClient.prototype.openImage = function(id, url, metadata, direction) { | 13 RibbonClient.prototype.openImage = function(id, url, metadata, direction) { |
14 }; | 14 }; |
15 | 15 |
16 RibbonClient.prototype.closeImage = function(item) {}; | 16 RibbonClient.prototype.closeImage = function(item) {}; |
17 | 17 |
18 /** | 18 /** |
19 * Image gallery for viewing and editing image files. | 19 * Image gallery for viewing and editing image files. |
20 * | 20 * |
21 * @param {HTMLDivElement} container | 21 * @param {HTMLDivElement} container |
22 * @param {Object} context Object containing the following: | 22 * @param {Object} context Object containing the following: |
23 * {function(string)} onNameChange Called every time a selected | 23 * {function(string)} onNameChange Called every time a selected |
24 * item name changes (on rename and on selection change). | 24 * item name changes (on rename and on selection change). |
25 * {function} onClose | 25 * {function} onClose |
26 * {MetadataProvider} metadataProvider | 26 * {string} rootUrl |
27 * {Array.<Object>} shareActions | 27 * {Array.<Object>} shareActions |
28 * {string} readonlyDirName Directory name for readonly warning or null. | 28 * {string} readonlyDirName Directory name for readonly warning or null. |
29 * {DirEntry} saveDirEntry Directory to save to. | 29 * {DirEntry} saveDirEntry Directory to save to. |
30 * {function(string)} displayStringFunction | 30 * {function(string)} displayStringFunction |
31 */ | 31 */ |
32 function Gallery(container, context) { | 32 function Gallery(container, context) { |
33 this.container_ = container; | 33 this.container_ = container; |
34 this.document_ = container.ownerDocument; | 34 this.document_ = container.ownerDocument; |
35 this.context_ = context; | 35 this.context_ = context; |
| 36 this.context_.metadataProvider = new MetadataProvider(this.context_.rootUrl); |
36 | 37 |
37 var strf = context.displayStringFunction; | 38 var strf = context.displayStringFunction; |
38 this.displayStringFunction_ = function(id, formatArgs) { | 39 this.displayStringFunction_ = function(id, formatArgs) { |
39 var args = Array.prototype.slice.call(arguments); | 40 var args = Array.prototype.slice.call(arguments); |
40 args[0] = 'GALLERY_' + id.toUpperCase(); | 41 args[0] = 'GALLERY_' + id.toUpperCase(); |
41 return strf.apply(null, args); | 42 return strf.apply(null, args); |
42 }; | 43 }; |
43 | 44 |
44 this.onFadeTimeoutBound_ = this.onFadeTimeout_.bind(this); | 45 this.onFadeTimeoutBound_ = this.onFadeTimeout_.bind(this); |
45 this.fadeTimeoutId_ = null; | 46 this.fadeTimeoutId_ = null; |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 Ribbon.Item.prototype.setThumbnail = function(metadata) { | 1301 Ribbon.Item.prototype.setThumbnail = function(metadata) { |
1301 var url; | 1302 var url; |
1302 var transform; | 1303 var transform; |
1303 | 1304 |
1304 var mediaType = FileType.getMediaType(this.url_); | 1305 var mediaType = FileType.getMediaType(this.url_); |
1305 | 1306 |
1306 if (metadata.thumbnailURL) { | 1307 if (metadata.thumbnailURL) { |
1307 url = metadata.thumbnailURL; | 1308 url = metadata.thumbnailURL; |
1308 transform = metadata.thumbnailTransform; | 1309 transform = metadata.thumbnailTransform; |
1309 } else if (mediaType == 'image' && | 1310 } else if (mediaType == 'image' && |
1310 FileType.canUseImageUrlForPreview(metadata)) { | 1311 FileType.canUseImageUrlForPreview(metadata.width, metadata.height, 0)) { |
1311 url = this.url_; | 1312 url = this.url_; |
1312 transform = metadata.imageTransform; | 1313 transform = metadata.imageTransform; |
1313 } else { | 1314 } else { |
1314 url = FileType.getPreviewArt(mediaType); | 1315 url = FileType.getPreviewArt(mediaType); |
1315 } | 1316 } |
1316 | 1317 |
1317 function percent(ratio) { return Math.round(ratio * 100) + '%' } | 1318 function percent(ratio) { return Math.round(ratio * 100) + '%' } |
1318 | 1319 |
1319 function resizeToFill(img, aspect) { | 1320 function resizeToFill(img, aspect) { |
1320 if ((aspect > 1)) { | 1321 if ((aspect > 1)) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 ShareMode.prototype.setUp = function() { | 1403 ShareMode.prototype.setUp = function() { |
1403 ImageEditor.Mode.prototype.setUp.apply(this, arguments); | 1404 ImageEditor.Mode.prototype.setUp.apply(this, arguments); |
1404 ImageUtil.setAttribute(this.menu_, 'hidden', false); | 1405 ImageUtil.setAttribute(this.menu_, 'hidden', false); |
1405 ImageUtil.setAttribute(this.button_, 'pressed', false); | 1406 ImageUtil.setAttribute(this.button_, 'pressed', false); |
1406 }; | 1407 }; |
1407 | 1408 |
1408 ShareMode.prototype.cleanUpUI = function() { | 1409 ShareMode.prototype.cleanUpUI = function() { |
1409 ImageEditor.Mode.prototype.cleanUpUI.apply(this, arguments); | 1410 ImageEditor.Mode.prototype.cleanUpUI.apply(this, arguments); |
1410 ImageUtil.setAttribute(this.menu_, 'hidden', true); | 1411 ImageUtil.setAttribute(this.menu_, 'hidden', true); |
1411 }; | 1412 }; |
OLD | NEW |