Commit 8dd56f2f authored by Fernão Lopes's avatar Fernão Lopes
Browse files

interface: media View image now get configurable parameter and gets size from API - #195

parent 709378e4
Showing with 28 additions and 11 deletions
+28 -11
......@@ -26,6 +26,10 @@ BBX.config = {
"fullSize": {
"width": "0",
"height": window.innerHeight
},
"mediaView": {
"width": "0",
"height": "400"
}
}
}
......
......@@ -347,8 +347,13 @@ define([
var getUrlInterval = setInterval(function() {
if (typeof BBX.tmp.imageThumb[media.uuid] !== 'undefined') {
if (typeof BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height] !== 'undefined') {
var url = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height];
var url = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height].url,
width = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height].width,
height = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height].height;
$(el).attr('href', url);
$(el).attr('width', width);
$(el).attr('height', height);
clearInterval(getUrlInterval);
}
}
......@@ -856,7 +861,10 @@ define([
var thumbInterval = setInterval(function() {
if (typeof BBX.tmp.imageThumb[media.uuid] !== 'undefined') {
if (typeof BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height] !== 'undefined') {
media.url = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height];
media.url = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height].url;
media.width = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height].width;
media.height = BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height].height;
var tmpImage = new Image();
tmpImage.src = media.url;
tmpImage.onload = function() {
......@@ -867,10 +875,9 @@ define([
} else {
$('.media-image-container').prepend('<img id="media-' + media.uuid + '" src="' + media.url + '" />');
}
var width = (params.width !== '00' && params.width < tmpImage.naturalWidth) ? params.width : tmpImage.naturalWidth;
var height = (params.height !== '00' && params.height < tmpImage.naturalHeight) ? params.height : tmpImage.naturalHeight;
$('#media-' + media.uuid).prop('width', width);
$('#media-' + media.uuid).prop('height', height);
$('#media-' + media.uuid).prop('width', media.width);
$('#media-' + media.uuid).prop('height', media.height);
}
clearInterval(thumbInterval);
}
......@@ -900,7 +907,11 @@ define([
if (typeof BBX.tmp.imageThumb[media.uuid] === 'undefined') {
BBX.tmp.imageThumb[media.uuid] = [];
}
BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height] = mediaLoad.attributes.url;
BBX.tmp.imageThumb[media.uuid][params.width + 'x' + params.height] = {
'url': mediaLoad.attributes.url,
'width': mediaLoad.attributes.width,
'height': mediaLoad.attributes.height
}
}
});
}
......
......@@ -20,8 +20,10 @@ define([
media = '',
url = config.apiUrl + '/' + config.repository + '/' + config.mucua + '/media/' + uuid,
urlWhereis = config.apiUrl + '/' + config.repository + '/' + config.mucua + '/media/' + uuid + '/whereis',
userData = localStorage.userData;
userData = localStorage.userData,
mediaWidth = (typeof(BBX.config.images.mediaView) !== 'undefined') ? BBX.config.images.mediaView.width : '0', // default value if size unset at config.js
mediaHeight = (typeof(BBX.config.images.mediaView) !== 'undefined') ? BBX.config.images.mediaView.height : '300'; // default value if size unset at config.js
// pergunta se vai excluir cópia local do arquivo
var askDrop = function() {
var config = BBX.config,
......@@ -61,7 +63,7 @@ define([
clearInterval(focus);
}
}, 500);
media = MediaFunctions.getMedia(url, function(data) {
data.formatDate = BBXFunctions.formatDate;
data.media = data.medias[0];
......@@ -80,7 +82,7 @@ define([
$('.request-copy').addClass('requested-copy').removeClass('request-copy');
});
}, {'width': '00', 'height': '300' });
}, {'width': mediaWidth, 'height': mediaHeight });
// who has the file
var dataWhereis = new MediaModel([], {url: urlWhereis});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment