Fixed view.php
This commit is contained in:
parent
b21141aa8a
commit
8edaba5136
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -123,8 +123,7 @@
|
|||||||
<div class='header'>
|
<div class='header'>
|
||||||
<h1>About</h1>
|
<h1>About</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class='wrapper'>
|
<div class='wrapper'></div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Upload -->
|
<!-- Upload -->
|
||||||
|
@ -14,14 +14,25 @@ var catchError = function(err) {
|
|||||||
/* View ----------------------------------------- */
|
/* View ----------------------------------------- */
|
||||||
|
|
||||||
paths.view = {
|
paths.view = {
|
||||||
|
php: [
|
||||||
|
'../view.php'
|
||||||
|
],
|
||||||
js: [
|
js: [
|
||||||
'../src/scripts/_gup.js',
|
'./scripts/_gup.js',
|
||||||
'../src/scripts/build.js',
|
'./scripts/build.js',
|
||||||
'../src/scripts/view/main.js'
|
'./scripts/api.js',
|
||||||
|
'./scripts/header.js',
|
||||||
|
'./scripts/visible.js',
|
||||||
|
'./scripts/sidebar.js',
|
||||||
|
'./scripts/view/main.js'
|
||||||
],
|
],
|
||||||
scripts: [
|
scripts: [
|
||||||
'bower_components/jQuery/dist/jquery.min.js',
|
'bower_components/jQuery/dist/jquery.min.js',
|
||||||
'../dist/_view--javascript.js'
|
'../dist/_view--javascript.js'
|
||||||
|
],
|
||||||
|
svg: [
|
||||||
|
'./images/iconic.svg',
|
||||||
|
'./images/ionicons.svg'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +62,18 @@ gulp.task('view--scripts', ['view--js'], function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('view--svg', function() {
|
||||||
|
|
||||||
|
var stream =
|
||||||
|
gulp.src(paths.view.php)
|
||||||
|
.pipe(plugins.inject(gulp.src(paths.view.svg), {
|
||||||
|
starttag: '<!-- inject:svg -->',
|
||||||
|
transform: function(filePath, file) { return file.contents.toString('utf8') }
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest('../'));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
/* Main ----------------------------------------- */
|
/* Main ----------------------------------------- */
|
||||||
|
|
||||||
paths.main = {
|
paths.main = {
|
||||||
@ -58,7 +81,7 @@ paths.main = {
|
|||||||
'../index.html'
|
'../index.html'
|
||||||
],
|
],
|
||||||
js: [
|
js: [
|
||||||
'../src/scripts/*.js'
|
'./scripts/*.js'
|
||||||
],
|
],
|
||||||
scripts: [
|
scripts: [
|
||||||
'bower_components/jQuery/dist/jquery.min.js',
|
'bower_components/jQuery/dist/jquery.min.js',
|
||||||
@ -69,12 +92,12 @@ paths.main = {
|
|||||||
'../dist/_main--javascript.js'
|
'../dist/_main--javascript.js'
|
||||||
],
|
],
|
||||||
scss: [
|
scss: [
|
||||||
'../src/styles/*.scss'
|
'./styles/*.scss'
|
||||||
],
|
],
|
||||||
styles: [
|
styles: [
|
||||||
'bower_components/basicContext/src/styles/main.scss',
|
'bower_components/basicContext/src/styles/main.scss',
|
||||||
'bower_components/basicModal/src/styles/main.scss',
|
'bower_components/basicModal/src/styles/main.scss',
|
||||||
'../src/styles/main.scss'
|
'./styles/main.scss'
|
||||||
],
|
],
|
||||||
svg: [
|
svg: [
|
||||||
'./images/iconic.svg',
|
'./images/iconic.svg',
|
||||||
@ -150,7 +173,7 @@ gulp.task('clean', function() {
|
|||||||
|
|
||||||
/* Tasks ----------------------------------------- */
|
/* Tasks ----------------------------------------- */
|
||||||
|
|
||||||
gulp.task('default', ['view--scripts', 'main--svg', 'main--scripts', 'main--styles'], function() {
|
gulp.task('default', ['view--svg', 'view--scripts', 'main--svg', 'main--scripts', 'main--styles'], function() {
|
||||||
|
|
||||||
gulp.start('clean');
|
gulp.start('clean');
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
api = {
|
api = {
|
||||||
|
|
||||||
path: 'php/api.php'
|
path: 'php/api.php',
|
||||||
|
onError: null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ api.post = function(fn, params, callback) {
|
|||||||
// Catch errors
|
// Catch errors
|
||||||
if (typeof data==='string'&&
|
if (typeof data==='string'&&
|
||||||
data.substring(0, 7)==='Error: ') {
|
data.substring(0, 7)==='Error: ') {
|
||||||
lychee.error(data.substring(7, data.length), params, data);
|
api.onError(data.substring(7, data.length), params, data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ api.post = function(fn, params, callback) {
|
|||||||
|
|
||||||
error = function(jqXHR, textStatus, errorThrown) {
|
error = function(jqXHR, textStatus, errorThrown) {
|
||||||
|
|
||||||
lychee.error('Server error or API not found.', params, errorThrown);
|
api.onError('Server error or API not found.', params, errorThrown);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@ $(document).ready(function() {
|
|||||||
/* Event Name */
|
/* Event Name */
|
||||||
var eventName = ('ontouchend' in document.documentElement) ? 'touchend' : 'click';
|
var eventName = ('ontouchend' in document.documentElement) ? 'touchend' : 'click';
|
||||||
|
|
||||||
|
/* Set API error handler */
|
||||||
|
api.onError = lychee.error;
|
||||||
|
|
||||||
/* Multiselect */
|
/* Multiselect */
|
||||||
multiselect.bind();
|
multiselect.bind();
|
||||||
|
|
||||||
|
@ -3,28 +3,24 @@
|
|||||||
* @copyright 2015 by Tobias Reich
|
* @copyright 2015 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var header = $('header'),
|
var lychee = { content: $('#content') },
|
||||||
headerTitle = $('#title'),
|
loadingBar = { show() {}, hide() {} }
|
||||||
imageview = $('#imageview'),
|
imageview = $('#imageview');
|
||||||
api_path = 'php/api.php',
|
|
||||||
infobox = $('#infobox');
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function() {
|
||||||
|
|
||||||
/* Event Name */
|
/* Event Name */
|
||||||
if ('ontouchend' in document.documentElement) eventName = 'touchend';
|
if ('ontouchend' in document.documentElement) eventName = 'touchend';
|
||||||
else eventName = 'click';
|
else eventName = 'click';
|
||||||
|
|
||||||
/* Window */
|
/* Set API error handler */
|
||||||
$(window).keydown(key);
|
api.onError = error;
|
||||||
|
|
||||||
/* Infobox */
|
/* Infobox */
|
||||||
infobox.find('.header .close').on(eventName, hideInfobox);
|
header.dom('#button_info').on(eventName, sidebar.toggle);
|
||||||
$(document) .on(eventName, '#infobox_overlay', hideInfobox);
|
|
||||||
$('#button_info') .on(eventName, showInfobox);
|
|
||||||
|
|
||||||
/* Direct Link */
|
/* Direct Link */
|
||||||
$('#button_direct').on(eventName, function() {
|
header.dom('#button_direct').on(eventName, function() {
|
||||||
|
|
||||||
var 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');
|
||||||
@ -35,17 +31,6 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
key = function(e) {
|
|
||||||
|
|
||||||
var code = (e.keyCode ? e.keyCode : e.which);
|
|
||||||
|
|
||||||
if (code===27) {
|
|
||||||
hideInfobox();
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
getPhotoSize = function(photo) {
|
getPhotoSize = function(photo) {
|
||||||
|
|
||||||
// Size can be 'big', 'medium' or 'small'
|
// Size can be 'big', 'medium' or 'small'
|
||||||
@ -86,50 +71,42 @@ getPhotoSize = function(photo) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showInfobox = function() {
|
|
||||||
|
|
||||||
$('body').append("<div id='infobox_overlay' class='fadeIn'></div>");
|
|
||||||
infobox.addClass('active');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
hideInfobox = function() {
|
|
||||||
|
|
||||||
$('#infobox_overlay').removeClass('fadeIn').addClass('fadeOut');
|
|
||||||
setTimeout(function() { $('#infobox_overlay').remove() }, 300);
|
|
||||||
infobox.removeClass('active');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
loadPhotoInfo = function(photoID) {
|
loadPhotoInfo = function(photoID) {
|
||||||
|
|
||||||
var params = 'function=getPhoto&photoID=' + photoID + '&albumID=0&password=""';
|
var params = {
|
||||||
$.ajax({type: 'POST', url: api_path, data: params, dataType: 'json', success: function(data) {
|
photoID,
|
||||||
|
albumID: 0,
|
||||||
|
password: ''
|
||||||
|
}
|
||||||
|
|
||||||
var size = getPhotoSize(data);
|
api.post('Photo::get', params, function(data) {
|
||||||
|
|
||||||
|
/* Set title */
|
||||||
|
|
||||||
if (!data.title) data.title = 'Untitled';
|
if (!data.title) data.title = 'Untitled';
|
||||||
document.title = 'Lychee - ' + data.title;
|
document.title = 'Lychee - ' + data.title;
|
||||||
headerTitle.html(data.title);
|
header.dom('#title').html(data.title);
|
||||||
|
|
||||||
imageview.attr('data-id', photoID);
|
/* Render HTML */
|
||||||
|
|
||||||
if (size==='big') imageview.html("<div id='image' style='background-image: url(" + data.url + ");'></div>");
|
var size = getPhotoSize(data);
|
||||||
else if (size==='medium') imageview.html("<div id='image' style='background-image: url(" + data.medium + ");'></div>");
|
|
||||||
else 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>");
|
|
||||||
|
|
||||||
imageview
|
imageview.html(build.imageview(data, size, true));
|
||||||
.removeClass('fadeOut')
|
imageview.addClass('fadeIn').show();
|
||||||
.addClass('fadeIn')
|
|
||||||
.show();
|
|
||||||
|
|
||||||
infobox.find('.wrapper').html(build.infoboxPhoto(data, true));
|
/* Render Sidebar */
|
||||||
|
|
||||||
}, error: ajaxError });
|
var structure = sidebar.createStructure.photo(data),
|
||||||
|
html = sidebar.render(structure);
|
||||||
|
|
||||||
|
sidebar.dom('.wrapper').html(html);
|
||||||
|
sidebar.bind();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxError = function(errorThrown, params, data) {
|
error = function(errorThrown, params, data) {
|
||||||
|
|
||||||
console.error({
|
console.error({
|
||||||
description: errorThrown,
|
description: errorThrown,
|
||||||
@ -137,4 +114,6 @@ ajaxError = function(errorThrown, params, data) {
|
|||||||
response: data
|
response: data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
loadingBar.show('error', errorThrown);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user