Front-end rewrite #275
This commit is contained in:
parent
edcffdc8eb
commit
b70f65a7d0
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -3,31 +3,31 @@
|
|||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var header = $('header'),
|
var header = $('header'),
|
||||||
headerTitle = $('#title'),
|
headerTitle = $('#title'),
|
||||||
imageview = $('#imageview'),
|
imageview = $('#imageview'),
|
||||||
api_path = 'php/api.php',
|
api_path = 'php/api.php',
|
||||||
infobox = $('#infobox');
|
infobox = $('#infobox');
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
/* Event Name */
|
/* Event Name */
|
||||||
if (mobileBrowser()) event_name = 'touchend';
|
if (mobileBrowser()) event_name = 'touchend';
|
||||||
else event_name = 'click';
|
else event_name = 'click';
|
||||||
|
|
||||||
/* Window */
|
/* Window */
|
||||||
$(window).keydown(key);
|
$(window).keydown(key);
|
||||||
|
|
||||||
/* Infobox */
|
/* Infobox */
|
||||||
$(document).on(event_name, '#infobox .header a', function() { hideInfobox() });
|
$(document) .on(event_name, '#infobox .header a', hideInfobox);
|
||||||
$(document).on(event_name, '#infobox_overlay', function() { hideInfobox() });
|
$(document) .on(event_name, '#infobox_overlay', hideInfobox);
|
||||||
$('#button_info').on(event_name, function() { showInfobox() });
|
$('#button_info') .on(event_name, showInfobox);
|
||||||
|
|
||||||
/* Direct Link */
|
/* Direct Link */
|
||||||
$('#button_direct').on(event_name, function() {
|
$('#button_direct').on(event_name, function() {
|
||||||
|
|
||||||
link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, '');
|
var link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, '');
|
||||||
window.open(link,'_newtab');
|
window.open(link, '_newtab');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,30 +37,34 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
key = function(e) {
|
key = function(e) {
|
||||||
|
|
||||||
code = (e.keyCode ? e.keyCode : e.which);
|
var code = (e.keyCode ? e.keyCode : e.which);
|
||||||
if (code===27&&visibleInfobox()) { hideInfobox(); e.preventDefault(); }
|
|
||||||
|
if (code===27&&visibleInfobox()) {
|
||||||
|
hideInfobox();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visibleInfobox = function() {
|
visibleInfobox = function() {
|
||||||
|
|
||||||
if (parseInt(infobox.css('right').replace('px', ''))<0) return false;
|
if (parseInt(infobox.css('right').replace('px', ''))<0) return false;
|
||||||
else return true;
|
else return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isPhotoSmall = function(photo) {
|
isPhotoSmall = function(photo) {
|
||||||
|
|
||||||
size = {
|
var size = {
|
||||||
width: false,
|
width: false,
|
||||||
height: false
|
height: false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (photo.width<$(window).width()-60) size.width = true;
|
if (photo.width<$(window).width()-60) size.width = true;
|
||||||
if (photo.height<$(window).height()-100) size.height = true;
|
if (photo.height<$(window).height()-100) size.height = true;
|
||||||
|
|
||||||
if (size.width&&size.height) return true;
|
if (size.width&&size.height) return true;
|
||||||
else return false;
|
else return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +85,7 @@ hideInfobox = function() {
|
|||||||
|
|
||||||
loadPhotoInfo = function(photoID) {
|
loadPhotoInfo = function(photoID) {
|
||||||
|
|
||||||
params = 'function=getPhoto&photoID=' + photoID + '&albumID=0&password=""';
|
var params = 'function=getPhoto&photoID=' + photoID + '&albumID=0&password=""';
|
||||||
$.ajax({type: 'POST', url: api_path, data: params, dataType: 'json', success: function(data) {
|
$.ajax({type: 'POST', url: api_path, data: params, dataType: 'json', success: function(data) {
|
||||||
|
|
||||||
if (!data.title) data.title = 'Untitled';
|
if (!data.title) data.title = 'Untitled';
|
||||||
@ -90,10 +94,13 @@ loadPhotoInfo = function(photoID) {
|
|||||||
|
|
||||||
imageview.attr('data-id', photoID);
|
imageview.attr('data-id', photoID);
|
||||||
|
|
||||||
if (isPhotoSmall(data)) imageview.html("<div id='image' class='small' style='background-image: url(" + data.url + "); width: " + data.width + "px; height: " + data.height + "px; margin-top: -" + parseInt((data.height/2)-20) + "px; margin-left: -" + data.width/2 + "px;'></div>");
|
if (isPhotoSmall(data)) imageview.html("<div id='image' class='small' style='background-image: url(" + data.url + "); width: " + data.width + "px; height: " + data.height + "px; margin-top: -" + parseInt((data.height/2)-20) + "px; margin-left: -" + data.width/2 + "px;'></div>");
|
||||||
else imageview.html("<div id='image' style='background-image: url(" + data.url + ");'></div>");
|
else imageview.html("<div id='image' style='background-image: url(" + data.url + ");'></div>");
|
||||||
|
|
||||||
imageview.removeClass('fadeOut').addClass('fadeIn').show();
|
imageview
|
||||||
|
.removeClass('fadeOut')
|
||||||
|
.addClass('fadeIn')
|
||||||
|
.show();
|
||||||
|
|
||||||
infobox.html(build.infoboxPhoto(data, true)).show();
|
infobox.html(build.infoboxPhoto(data, true)).show();
|
||||||
|
|
||||||
@ -101,10 +108,12 @@ loadPhotoInfo = function(photoID) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxError = function(jqXHR, textStatus, errorThrown) {
|
ajaxError = function(errorThrown, params, data) {
|
||||||
|
|
||||||
console.log(jqXHR);
|
console.error({
|
||||||
console.log(textStatus);
|
description: errorThrown,
|
||||||
console.log(errorThrown);
|
params: params,
|
||||||
|
response: data
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user