Front-end rewrite #275

This commit is contained in:
Tobias Reich 2014-11-22 20:43:51 +01:00
parent edcffdc8eb
commit b70f65a7d0
2 changed files with 40 additions and 31 deletions

BIN
dist/view.js vendored

Binary file not shown.

View File

@ -19,15 +19,15 @@ $(document).ready(function(){
$(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,8 +37,12 @@ $(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();
}
} }
@ -51,7 +55,7 @@ visibleInfobox = function() {
isPhotoSmall = function(photo) { isPhotoSmall = function(photo) {
size = { var size = {
width: false, width: false,
height: false height: 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';
@ -93,7 +97,10 @@ loadPhotoInfo = function(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
});
} }