2022-06-06 08:53:59 +00:00
|
|
|
require('./style.scss');
|
|
|
|
var Popup = require('../popup');
|
|
|
|
var Spinner = require('../spinner');
|
2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
|
|
|
Extends: Vn.Object
|
2016-05-02 13:05:49 +00:00
|
|
|
,Properties:
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-05-02 13:05:49 +00:00
|
|
|
/**
|
|
|
|
* Subdirectory where full images are allocated.
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2016-05-02 13:05:49 +00:00
|
|
|
fullDir:
|
2015-09-22 07:20:47 +00:00
|
|
|
{
|
2016-05-02 13:05:49 +00:00
|
|
|
type: String
|
2022-05-26 06:08:31 +00:00
|
|
|
,set: function(x) {
|
2016-05-02 13:05:49 +00:00
|
|
|
this._fullDir = x;
|
|
|
|
}
|
2022-05-26 06:08:31 +00:00
|
|
|
,get: function() {
|
2016-05-02 13:05:49 +00:00
|
|
|
return this._fullDir;
|
|
|
|
}
|
2015-09-22 07:20:47 +00:00
|
|
|
}
|
2016-05-02 13:05:49 +00:00
|
|
|
}
|
2015-02-08 15:38:38 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
,show: function(src) {
|
|
|
|
var popup = new Popup({class: 'htk-full-image', modal: true});
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
var img = document.createElement('img');
|
2016-05-02 13:05:49 +00:00
|
|
|
img.className = 'htk-full-image';
|
2022-05-26 06:08:31 +00:00
|
|
|
img.addEventListener('click', this._onImageClick.bind(this, popup));
|
2016-05-02 13:05:49 +00:00
|
|
|
//img.addEventListener ('error', this._onImageError.bind (this, popup));
|
|
|
|
img.src = src;
|
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
if (!img.complete) {
|
|
|
|
img.addEventListener('load', this._onImageLoad.bind(this, popup, img));
|
2016-05-02 13:05:49 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
var spinner = new Spinner();
|
|
|
|
spinner.start();
|
2016-05-02 13:05:49 +00:00
|
|
|
popup.child = spinner;
|
2022-05-26 06:08:31 +00:00
|
|
|
} else
|
|
|
|
this._onImageLoad(popup, img);
|
2016-05-02 13:05:49 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
popup.open();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
,_onImageLoad: function(popup, img) {
|
2016-05-02 13:05:49 +00:00
|
|
|
var scale = null;
|
2015-01-23 13:09:30 +00:00
|
|
|
var width = img.width;
|
|
|
|
var height = img.height;
|
2022-05-26 06:08:31 +00:00
|
|
|
var innerWidth = Vn.Browser.getInnerWidth() - 50;
|
|
|
|
var innerHeight = Vn.Browser.getInnerHeight() - 50;
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
if (width > innerWidth) {
|
2015-01-23 13:09:30 +00:00
|
|
|
scale = width / innerWidth;
|
2022-05-26 06:08:31 +00:00
|
|
|
height = parseInt(height / scale);
|
2015-01-23 13:09:30 +00:00
|
|
|
width = innerWidth;
|
|
|
|
}
|
2022-05-26 06:08:31 +00:00
|
|
|
if (height > innerHeight) {
|
2015-01-23 13:09:30 +00:00
|
|
|
scale = height / innerHeight;
|
2022-05-26 06:08:31 +00:00
|
|
|
width = parseInt(width / scale);
|
2015-01-23 13:09:30 +00:00
|
|
|
height = innerHeight;
|
|
|
|
}
|
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
if (scale !== null) {
|
2015-01-23 13:09:30 +00:00
|
|
|
img.style.width = width +'px';
|
|
|
|
img.style.height = height +'px';
|
|
|
|
}
|
|
|
|
|
2016-05-02 13:05:49 +00:00
|
|
|
popup.childNode = img;
|
2022-05-26 06:08:31 +00:00
|
|
|
popup.reset();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
,_onImageClick: function(popup) {
|
|
|
|
popup.hide();
|
2015-02-01 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
,_onImageError: function(popup) {}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
|
|
|
|