1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* The current selection object.
*
* @param {FileManager} fileManager FileManager instance.
* @param {Array.<number>} indexes Selected indexes.
* @constructor
*/
function FileSelection(fileManager, indexes) {
this.fileManager_ = fileManager;
this.computeBytesSequence_ = 0;
this.indexes = indexes;
this.entries = [];
this.urls = [];
this.totalCount = 0;
this.fileCount = 0;
this.directoryCount = 0;
this.bytes = 0;
this.showBytes = false;
this.allDriveFilesPresent = false,
this.iconType = null;
this.bytesKnown = false;
// Synchronously compute what we can.
for (var i = 0; i < this.indexes.length; i++) {
var entry = fileManager.getFileList().item(this.indexes[i]);
if (!entry)
continue;
this.entries.push(entry);
this.urls.push(entry.toURL());
if (this.iconType == null) {
this.iconType = FileType.getIcon(entry);
} else if (this.iconType != 'unknown') {
var iconType = FileType.getIcon(entry);
if (this.iconType != iconType)
this.iconType = 'unknown';
}
if (entry.isFile) {
this.fileCount += 1;
} else {
this.directoryCount += 1;
}
this.totalCount++;
}
this.tasks = new FileTasks(this.fileManager_);
}
/**
* Computes data required to get file tasks and requests the tasks.
*
* @param {function} callback The callback.
*/
FileSelection.prototype.createTasks = function(callback) {
if (!this.fileManager_.isOnDrive()) {
this.tasks.init(this.urls);
callback();
return;
}
this.fileManager_.metadataCache_.get(this.urls, 'drive', function(props) {
var present = props.filter(function(p) { return p && p.availableOffline });
this.allDriveFilesPresent = present.length == props.length;
// Collect all of the mime types and push that info into the selection.
this.mimeTypes = props.map(function(value) {
return (value && value.contentMimeType) || '';
});
this.tasks.init(this.urls, this.mimeTypes);
callback();
}.bind(this));
};
/**
* Computes the total size of selected files.
*
* @param {function} callback Completion callback. Not called when cancelled,
* or a new call has been invoked in the meantime.
*/
FileSelection.prototype.computeBytes = function(callback) {
if (this.entries.length == 0) {
this.bytesKnown = true;
this.showBytes = false;
this.bytes = 0;
return;
}
var computeBytesSequence = ++this.computeBytesSequence_;
var pendingMetadataCount = 0;
var maybeDone = function() {
if (pendingMetadataCount == 0) {
this.bytesKnown = true;
callback();
}
}.bind(this);
var onProps = function(properties) {
// Ignore if the call got cancelled, or there is another new one fired.
if (computeBytesSequence != this.computeBytesSequence_)
return;
// It may happen that the metadata is not available because a file has been
// deleted in the meantime.
if (properties)
this.bytes += properties.size;
pendingMetadataCount--;
maybeDone();
}.bind(this);
for (var index = 0; index < this.entries.length; index++) {
var entry = this.entries[index];
if (entry.isFile) {
this.showBytes |= !FileType.isHosted(entry);
pendingMetadataCount++;
this.fileManager_.metadataCache_.get(entry, 'filesystem', onProps);
} else if (entry.isDirectory) {
// Don't compute the directory size as it's expensive.
// crbug.com/179073.
this.showBytes = false;
break;
}
}
maybeDone();
};
/**
* Cancels any async computation by increasing the sequence number. Results
* of any previous call to computeBytes() will be discarded.
*
* @private
*/
FileSelection.prototype.cancelComputing_ = function() {
this.computeBytesSequence_++;
};
/**
* This object encapsulates everything related to current selection.
*
* @param {FileManager} fileManager File manager instance.
* @constructor
*/
function FileSelectionHandler(fileManager) {
this.fileManager_ = fileManager;
// TODO(dgozman): create a shared object with most of UI elements.
this.okButton_ = fileManager.okButton_;
this.filenameInput_ = fileManager.filenameInput_;
this.previewPanel_ = fileManager.dialogDom_.querySelector('.preview-panel');
this.previewThumbnails_ = this.previewPanel_.
querySelector('.preview-thumbnails');
this.previewSummary_ = this.previewPanel_.querySelector('.preview-summary');
this.previewText_ = this.previewSummary_.querySelector('.preview-text');
this.calculatingSize_ = this.previewSummary_.
querySelector('.calculating-size');
this.calculatingSize_.textContent = str('CALCULATING_SIZE');
this.searchBreadcrumbs_ = fileManager.searchBreadcrumbs_;
this.taskItems_ = fileManager.taskItems_;
this.animationTimeout_ = null;
}
/**
* Maximum amount of thumbnails in the preview pane.
*
* @const
* @type {number}
*/
FileSelectionHandler.MAX_PREVIEW_THUMBNAIL_COUNT = 4;
/**
* Maximum width or height of an image what pops up when the mouse hovers
* thumbnail in the bottom panel (in pixels).
*
* @const
* @type {number}
*/
FileSelectionHandler.IMAGE_HOVER_PREVIEW_SIZE = 200;
/**
* Update the UI when the selection model changes.
*
* @param {cr.Event} event The change event.
*/
FileSelectionHandler.prototype.onFileSelectionChanged = function(event) {
var indexes =
this.fileManager_.getCurrentList().selectionModel.selectedIndexes;
if (this.selection) this.selection.cancelComputing_();
var selection = new FileSelection(this.fileManager_, indexes);
this.selection = selection;
if (this.fileManager_.dialogType == DialogType.SELECT_SAVEAS_FILE) {
// If this is a save-as dialog, copy the selected file into the filename
// input text box.
if (this.selection.totalCount == 1 &&
this.selection.entries[0].isFile &&
this.filenameInput_.value != this.selection.entries[0].name) {
this.filenameInput_.value = this.selection.entries[0].name;
}
}
this.updateOkButton();
if (this.selectionUpdateTimer_) {
clearTimeout(this.selectionUpdateTimer_);
this.selectionUpdateTimer_ = null;
}
if (!util.platform.newUI() && !indexes.length) {
this.updatePreviewPanelVisibility_();
this.updatePreviewPanelText_();
this.fileManager_.updateContextMenuActionItems(null, false);
return;
}
this.hideCalculating_();
// The rest of the selection properties are computed via (sometimes lengthy)
// asynchronous calls. We initiate these calls after a timeout. If the
// selection is changing quickly we only do this once when it slows down.
var updateDelay = 200;
var now = Date.now();
if (now > (this.lastFileSelectionTime_ || 0) + updateDelay) {
// The previous selection change happened a while ago. Update the UI soon.
updateDelay = 0;
}
this.lastFileSelectionTime_ = now;
this.selectionUpdateTimer_ = setTimeout(function() {
this.selectionUpdateTimer_ = null;
if (this.selection == selection)
this.updateFileSelectionAsync(selection);
}.bind(this), updateDelay);
};
/**
* Clears the primary UI selection elements.
*/
FileSelectionHandler.prototype.clearUI = function() {
this.previewThumbnails_.textContent = '';
this.previewText_.textContent = '';
this.hideCalculating_();
this.taskItems_.hidden = true;
this.okButton_.disabled = true;
};
/**
* Updates the Ok button enabled state.
*
* @return {boolean} Whether button is enabled.
*/
FileSelectionHandler.prototype.updateOkButton = function() {
var selectable;
var dialogType = this.fileManager_.dialogType;
if (dialogType == DialogType.SELECT_FOLDER) {
// In SELECT_FOLDER mode, we allow to select current directory
// when nothing is selected.
selectable = this.selection.directoryCount <= 1 &&
this.selection.fileCount == 0;
} else if (dialogType == DialogType.SELECT_OPEN_FILE) {
selectable = (this.isFileSelectionAvailable() &&
this.selection.directoryCount == 0 &&
this.selection.fileCount == 1);
} else if (dialogType == DialogType.SELECT_OPEN_MULTI_FILE) {
selectable = (this.isFileSelectionAvailable() &&
this.selection.directoryCount == 0 &&
this.selection.fileCount >= 1);
} else if (dialogType == DialogType.SELECT_SAVEAS_FILE) {
if (this.fileManager_.isOnReadonlyDirectory()) {
selectable = false;
} else {
selectable = !!this.filenameInput_.value;
}
} else if (dialogType == DialogType.FULL_PAGE) {
// No "select" buttons on the full page UI.
selectable = true;
} else {
throw new Error('Unknown dialog type');
}
this.okButton_.disabled = !selectable;
return selectable;
};
/**
* Check if all the files in the current selection are available. The only
* case when files might be not available is when the selection contains
* uncached Drive files and the browser is offline.
*
* @return {boolean} True if all files in the current selection are
* available.
*/
FileSelectionHandler.prototype.isFileSelectionAvailable = function() {
return !this.fileManager_.isOnDrive() ||
!this.fileManager_.isDriveOffline() ||
this.selection.allDriveFilesPresent;
};
/**
* Animates preview panel show/hide transitions.
*
* @private
*/
FileSelectionHandler.prototype.updatePreviewPanelVisibility_ = function() {
var panel = this.previewPanel_;
var state = panel.getAttribute('visibility');
var mustBeVisible = (this.selection.totalCount > 0);
if (util.platform.newUI()) {
mustBeVisible = (this.selection.totalCount > 0 ||
!PathUtil.isRootPath(this.fileManager_.getCurrentDirectory()));
}
var self = this;
var stopHidingAndShow = function() {
clearTimeout(self.hidingTimeout_);
self.hidingTimeout_ = 0;
setVisibility('visible');
};
var startHiding = function() {
setVisibility('hiding');
self.hidingTimeout_ = setTimeout(function() {
self.hidingTimeout_ = 0;
setVisibility('hidden');
}, 250);
};
var show = function() {
setVisibility('visible');
self.previewThumbnails_.textContent = '';
};
var setVisibility = function(visibility) {
panel.setAttribute('visibility', visibility);
};
switch (state) {
case 'visible':
if (!mustBeVisible)
startHiding();
break;
case 'hiding':
if (mustBeVisible)
stopHidingAndShow();
break;
case 'hidden':
if (mustBeVisible)
show();
}
};
/**
* @return {boolean} True if space reserverd for the preview panel.
* @private
*/
FileSelectionHandler.prototype.isPreviewPanelVisibile_ = function() {
return this.previewPanel_.getAttribute('visibility') != 'hidden';
};
/**
* Update the selection summary in preview panel.
*
* @private
*/
FileSelectionHandler.prototype.updatePreviewPanelText_ = function() {
var selection = this.selection;
if (!util.platform.newUI()) {
if (selection.totalCount == 0) {
// We dont want to change the string during preview panel animating
return;
}
} else {
if (selection.totalCount <= 1) {
// Hides the preview text if zero or one file is selected. We shows a
// breadcrumb list instead on the preview panel.
this.hideCalculating_();
this.previewText_.textContent = '';
return;
}
}
var text = '';
if (selection.totalCount == 1) {
text = selection.entries[0].name;
} else if (selection.directoryCount == 0) {
text = strf('MANY_FILES_SELECTED', selection.fileCount);
} else if (selection.fileCount == 0) {
text = strf('MANY_DIRECTORIES_SELECTED', selection.directoryCount);
} else {
text = strf('MANY_ENTRIES_SELECTED', selection.totalCount);
}
if (selection.bytesKnown) {
this.hideCalculating_();
if (selection.showBytes) {
var bytes = util.bytesToString(selection.bytes);
text += ', ' + bytes;
}
} else {
this.showCalculating_();
}
this.previewText_.textContent = text;
};
/**
* Displays the 'calculating size' label.
*
* @private
*/
FileSelectionHandler.prototype.showCalculating_ = function() {
if (this.animationTimeout_) {
clearTimeout(this.animationTimeout_);
this.animationTimeout_ = null;
}
var dotCount = 0;
var advance = function() {
this.animationTimeout_ = setTimeout(advance, 1000);
var s = this.calculatingSize_.textContent;
s = s.replace(/(\.)+$/, '');
for (var i = 0; i < dotCount; i++) {
s += '.';
}
this.calculatingSize_.textContent = s;
dotCount = (dotCount + 1) % 3;
}.bind(this);
var start = function() {
this.calculatingSize_.hidden = false;
advance();
}.bind(this);
this.animationTimeout_ = setTimeout(start, 500);
};
/**
* Hides the 'calculating size' label.
*
* @private
*/
FileSelectionHandler.prototype.hideCalculating_ = function() {
if (this.animationTimeout_) {
clearTimeout(this.animationTimeout_);
this.animationTimeout_ = null;
}
this.calculatingSize_.hidden = true;
};
/**
* Calculates async selection stats and updates secondary UI elements.
*
* @param {FileSelection} selection The selection object.
*/
FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) {
if (this.selection != selection) return;
// Update the file tasks.
if (this.fileManager_.dialogType == DialogType.FULL_PAGE &&
selection.directoryCount == 0 && selection.fileCount > 0) {
selection.createTasks(function() {
if (this.selection != selection)
return;
selection.tasks.display(this.taskItems_);
selection.tasks.updateMenuItem();
}.bind(this));
} else {
this.taskItems_.hidden = true;
}
// Update preview panels.
var wasVisible = this.isPreviewPanelVisibile_();
var thumbnailEntries;
if (util.platform.newUI() && selection.totalCount == 0) {
thumbnailEntries = [
this.fileManager_.getCurrentDirectoryEntry()
];
} else {
thumbnailEntries = selection.entries;
if (selection.totalCount != 1) {
selection.computeBytes(function() {
if (this.selection != selection)
return;
this.updatePreviewPanelText_();
}.bind(this));
}
}
this.updatePreviewPanelVisibility_();
this.updatePreviewPanelText_();
this.showPreviewThumbnails_(thumbnailEntries);
// Update breadcrums.
var updateTarget = null;
if (util.platform.newUI()) {
var path = this.fileManager_.getCurrentDirectory();
if (selection.totalCount == 1) {
// Shows the breadcrumb list when a file is selected.
updateTarget = selection.entries[0].fullPath;
} else if (selection.totalCount == 0 && !PathUtil.isRootPath(path)) {
// Shows the breadcrumb list when no file is selected and the current
// directory is non-root path.
updateTarget = path;
}
}
this.updatePreviewPanelBreadcrumbs_(updateTarget);
// Scroll to item
if (!wasVisible && this.selection.totalCount == 1) {
var list = this.fileManager_.getCurrentList();
list.scrollIndexIntoView(list.selectionModel.selectedIndex);
}
// Sync the commands availability.
if (selection.totalCount != 0) {
var commands = this.fileManager_.dialogDom_.querySelectorAll('command');
for (var i = 0; i < commands.length; i++)
commands[i].canExecuteChange();
}
// Update context menu.
this.fileManager_.updateContextMenuActionItems(null, false);
// Inform tests it's OK to click buttons now.
if (selection.totalCount > 0) {
chrome.test.sendMessage('selection-change-complete');
}
};
/**
* Renders preview thumbnails in preview panel.
*
* @param {Array.<FileEntry>} entries The entries of selected object.
* @private
*/
FileSelectionHandler.prototype.showPreviewThumbnails_ = function(entries) {
var selection = this.selection;
var thumbnails = [];
var thumbnailCount = 0;
var thumbnailLoaded = -1;
var forcedShowTimeout = null;
var thumbnailsHaveZoom = false;
var self = this;
var showThumbnails = function() {
// have-zoom class may be updated twice: then timeout exceeds and then
// then all images loaded.
if (self.selection == selection) {
if (thumbnailsHaveZoom) {
self.previewThumbnails_.classList.add('has-zoom');
} else {
self.previewThumbnails_.classList.remove('has-zoom');
}
}
if (forcedShowTimeout === null)
return;
clearTimeout(forcedShowTimeout);
forcedShowTimeout = null;
// FileSelection could change while images are loading.
if (self.selection == selection) {
self.previewThumbnails_.textContent = '';
for (var i = 0; i < thumbnails.length; i++)
self.previewThumbnails_.appendChild(thumbnails[i]);
}
};
var onThumbnailLoaded = function() {
thumbnailLoaded++;
if (thumbnailLoaded == thumbnailCount)
showThumbnails();
};
var thumbnailClickHandler = function() {
if (selection.tasks)
selection.tasks.executeDefault();
};
var doc = this.fileManager_.document_;
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
if (thumbnailCount < FileSelectionHandler.MAX_PREVIEW_THUMBNAIL_COUNT) {
var box = doc.createElement('div');
box.className = 'thumbnail';
if (thumbnailCount == 0) {
var zoomed = doc.createElement('div');
zoomed.hidden = true;
thumbnails.push(zoomed);
var onFirstThumbnailLoaded = function(img, transform) {
if (img && self.decorateThumbnailZoom_(zoomed, img, transform)) {
zoomed.hidden = false;
thumbnailsHaveZoom = true;
}
onThumbnailLoaded();
};
var thumbnail = this.renderThumbnail_(entry, onFirstThumbnailLoaded);
zoomed.addEventListener('click', thumbnailClickHandler);
} else {
var thumbnail = this.renderThumbnail_(entry, onThumbnailLoaded);
}
thumbnailCount++;
box.appendChild(thumbnail);
box.style.zIndex =
FileSelectionHandler.MAX_PREVIEW_THUMBNAIL_COUNT + 1 - i;
box.addEventListener('click', thumbnailClickHandler);
thumbnails.push(box);
}
}
forcedShowTimeout = setTimeout(showThumbnails,
FileManager.THUMBNAIL_SHOW_DELAY);
onThumbnailLoaded();
};
/**
* Renders a thumbnail for the buttom panel.
*
* @param {Entry} entry Entry to render for.
* @param {function} callback Called when image loaded.
* @return {HTMLDivElement} Created element.
* @private
*/
FileSelectionHandler.prototype.renderThumbnail_ = function(entry, callback) {
var thumbnail = this.fileManager_.document_.createElement('div');
FileGrid.decorateThumbnailBox(thumbnail,
entry,
this.fileManager_.metadataCache_,
ThumbnailLoader.FillMode.FILL,
ThumbnailLoader.OptimizationMode.NEVER_DISCARD,
callback);
return thumbnail;
};
/**
* Updates the breadcrumbs in the preview panel.
*
* @param {?string} path Path to be shown in the breadcrumbs list
* @private
*/
FileSelectionHandler.prototype.updatePreviewPanelBreadcrumbs_ = function(path) {
if (!path)
this.searchBreadcrumbs_.hide();
else
this.searchBreadcrumbs_.show(PathUtil.getRootPath(path), path);
};
/**
* Updates the search breadcrumbs. This method should not be used in the new ui.
*
* @private
*/
FileSelectionHandler.prototype.updateSearchBreadcrumbs_ = function() {
var selectedIndexes =
this.fileManager_.getCurrentList().selectionModel.selectedIndexes;
if (selectedIndexes.length !== 1 ||
!this.fileManager_.directoryModel_.isSearching()) {
this.searchBreadcrumbs_.hide();
return;
}
var entry = this.fileManager_.getFileList().item(
selectedIndexes[0]);
this.searchBreadcrumbs_.show(
PathUtil.getRootPath(entry.fullPath),
entry.fullPath);
};
/**
* Creates enlarged image for a bottom pannel thumbnail.
* Image's assumed to be just loaded and not inserted into the DOM.
*
* @param {HTMLElement} largeImageBox DIV element to decorate.
* @param {HTMLElement} img Loaded image.
* @param {Object} transform Image transformation description.
* @return {boolean} True if zoomed image is present.
* @private
*/
FileSelectionHandler.prototype.decorateThumbnailZoom_ = function(
largeImageBox, img, transform) {
var width = img.width;
var height = img.height;
var THUMBNAIL_SIZE = 45;
if (width < THUMBNAIL_SIZE * 2 && height < THUMBNAIL_SIZE * 2)
return false;
var scale = Math.min(1,
FileSelectionHandler.IMAGE_HOVER_PREVIEW_SIZE / Math.max(width, height));
var imageWidth = Math.round(width * scale);
var imageHeight = Math.round(height * scale);
var largeImage = this.fileManager_.document_.createElement('img');
if (scale < 0.3) {
// Scaling large images kills animation. Downscale it in advance.
// Canvas scales images with liner interpolation. Make a larger
// image (but small enough to not kill animation) and let IMG
// scale it smoothly.
var INTERMEDIATE_SCALE = 3;
var canvas = this.fileManager_.document_.createElement('canvas');
canvas.width = imageWidth * INTERMEDIATE_SCALE;
canvas.height = imageHeight * INTERMEDIATE_SCALE;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
// Using bigger than default compression reduces image size by
// several times. Quality degradation compensated by greater resolution.
largeImage.src = canvas.toDataURL('image/jpeg', 0.6);
} else {
largeImage.src = img.src;
}
largeImageBox.className = 'popup';
var boxWidth = Math.max(THUMBNAIL_SIZE, imageWidth);
var boxHeight = Math.max(THUMBNAIL_SIZE, imageHeight);
if (transform && transform.rotate90 % 2 == 1) {
var t = boxWidth;
boxWidth = boxHeight;
boxHeight = t;
}
var style = largeImageBox.style;
style.width = boxWidth + 'px';
style.height = boxHeight + 'px';
style.top = (-boxHeight + THUMBNAIL_SIZE) + 'px';
var style = largeImage.style;
style.width = imageWidth + 'px';
style.height = imageHeight + 'px';
style.left = (boxWidth - imageWidth) / 2 + 'px';
style.top = (boxHeight - imageHeight) / 2 + 'px';
style.position = 'relative';
util.applyTransform(largeImage, transform);
largeImageBox.appendChild(largeImage);
largeImageBox.style.zIndex = 1000;
return true;
};
|