diff --git a/dist/view.js b/dist/view.js index 024a2fb..b475e0b 100644 Binary files a/dist/view.js and b/dist/view.js differ diff --git a/src/scripts/view/main.js b/src/scripts/view/main.js index 55d4706..644d6d1 100644 --- a/src/scripts/view/main.js +++ b/src/scripts/view/main.js @@ -3,31 +3,31 @@ * @copyright 2014 by Tobias Reich */ -var header = $('header'), - headerTitle = $('#title'), - imageview = $('#imageview'), - api_path = 'php/api.php', - infobox = $('#infobox'); +var header = $('header'), + headerTitle = $('#title'), + imageview = $('#imageview'), + api_path = 'php/api.php', + infobox = $('#infobox'); $(document).ready(function(){ /* Event Name */ - if (mobileBrowser()) event_name = 'touchend'; - else event_name = 'click'; + if (mobileBrowser()) event_name = 'touchend'; + else event_name = 'click'; /* Window */ $(window).keydown(key); /* Infobox */ - $(document).on(event_name, '#infobox .header a', function() { hideInfobox() }); - $(document).on(event_name, '#infobox_overlay', function() { hideInfobox() }); - $('#button_info').on(event_name, function() { showInfobox() }); + $(document) .on(event_name, '#infobox .header a', hideInfobox); + $(document) .on(event_name, '#infobox_overlay', hideInfobox); + $('#button_info') .on(event_name, showInfobox); /* Direct Link */ $('#button_direct').on(event_name, function() { - link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, ''); - window.open(link,'_newtab'); + var link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, ''); + window.open(link, '_newtab'); }); @@ -37,30 +37,34 @@ $(document).ready(function(){ key = function(e) { - code = (e.keyCode ? e.keyCode : e.which); - if (code===27&&visibleInfobox()) { hideInfobox(); e.preventDefault(); } + var code = (e.keyCode ? e.keyCode : e.which); + + if (code===27&&visibleInfobox()) { + hideInfobox(); + e.preventDefault(); + } } visibleInfobox = function() { - if (parseInt(infobox.css('right').replace('px', ''))<0) return false; - else return true; + if (parseInt(infobox.css('right').replace('px', ''))<0) return false; + else return true; } isPhotoSmall = function(photo) { - size = { - width: false, - height: false + var size = { + width: false, + height: false }; - if (photo.width<$(window).width()-60) size.width = true; - if (photo.height<$(window).height()-100) size.height = true; + if (photo.width<$(window).width()-60) size.width = true; + if (photo.height<$(window).height()-100) size.height = true; - if (size.width&&size.height) return true; - else return false; + if (size.width&&size.height) return true; + else return false; } @@ -81,7 +85,7 @@ hideInfobox = function() { 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) { if (!data.title) data.title = 'Untitled'; @@ -90,10 +94,13 @@ loadPhotoInfo = function(photoID) { imageview.attr('data-id', photoID); - if (isPhotoSmall(data)) imageview.html("
"); - else imageview.html(""); + if (isPhotoSmall(data)) imageview.html(""); + else imageview.html(""); - imageview.removeClass('fadeOut').addClass('fadeIn').show(); + imageview + .removeClass('fadeOut') + .addClass('fadeIn') + .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.log(textStatus); - console.log(errorThrown); + console.error({ + description: errorThrown, + params: params, + response: data + }); } \ No newline at end of file