2011-09-26 00:32:08 +04:00
|
|
|
var actual_cover;
|
2012-03-07 21:58:10 +04:00
|
|
|
var paths = [];
|
2012-03-04 21:28:41 +04:00
|
|
|
var crumbCount = 0;
|
|
|
|
$(document).ready(returnToElement(0));
|
|
|
|
|
|
|
|
function returnToElement(num) {
|
2012-03-07 21:58:10 +04:00
|
|
|
while (crumbCount != num) {
|
|
|
|
$('#g-album-navigation .last').remove();
|
|
|
|
$('#g-album-navigation .crumb :last').parent().addClass('last');
|
|
|
|
crumbCount--;
|
|
|
|
paths.pop();
|
|
|
|
}
|
2012-03-11 19:49:21 +04:00
|
|
|
var p='';
|
|
|
|
for (var i in paths) p += paths[i]+'/';
|
|
|
|
$('#g-album-loading').show();
|
|
|
|
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'get_gallery', path: p }, albumClickHandler);
|
2012-03-04 21:28:41 +04:00
|
|
|
}
|
|
|
|
|
2012-03-11 19:49:21 +04:00
|
|
|
function albumClick(title) {
|
|
|
|
paths.push(title);
|
2012-03-07 21:58:10 +04:00
|
|
|
crumbCount++;
|
2012-03-11 19:49:21 +04:00
|
|
|
var p = '';
|
|
|
|
for (var i in paths) p += paths[i]+'/';
|
|
|
|
$('#g-album-loading').show();
|
|
|
|
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'get_gallery', path: p }, function(r) {
|
|
|
|
albumClickHandler(r);
|
2012-03-07 21:58:10 +04:00
|
|
|
if ($('#g-album-navigation :last-child'))
|
|
|
|
$('#g-album-navigation :last-child').removeClass('last');
|
2012-03-11 19:49:21 +04:00
|
|
|
$('#g-album-navigation').append('<div class="crumb last real" style="background-image:url(\''+OC.imagePath('core','breadcrumb')+'\')"><a href=\"javascript:returnToElement('+crumbCount+');\">'+decodeURIComponent(escape(title))+'</a></div>');
|
|
|
|
});
|
2012-03-04 21:28:41 +04:00
|
|
|
}
|
|
|
|
|
2012-03-24 22:26:53 +04:00
|
|
|
function constructSharingPath() {
|
|
|
|
return document.location.protocol + '//' + document.location.host + OC.linkTo('gallery', 'sharing.php') + '?token=' + Albums.token;
|
|
|
|
}
|
|
|
|
|
2012-03-24 21:35:16 +04:00
|
|
|
function shareGallery() {
|
|
|
|
var existing_token = '';
|
|
|
|
if (Albums.token)
|
2012-03-24 22:26:53 +04:00
|
|
|
existing_token = constructSharingPath();
|
2012-03-24 21:35:16 +04:00
|
|
|
var form_fields = [{text: 'Share', name: 'share', type: 'checkbox', value: Albums.shared},
|
|
|
|
{text: 'Share recursive', name: 'recursive', type: 'checkbox', value: Albums.recursive},
|
|
|
|
{text: 'Shared gallery address', name: 'address', type: 'text', value: existing_token}];
|
|
|
|
OC.dialogs.form(form_fields, t('gallery', 'Share gallery'), function(values){
|
|
|
|
var p = '';
|
2012-03-30 23:14:01 +04:00
|
|
|
for (var i in paths) p += paths[i]+'/';
|
2012-03-24 21:35:16 +04:00
|
|
|
if (p == '') p = '/';
|
2012-03-30 23:14:01 +04:00
|
|
|
alert(p);
|
2012-03-24 21:35:16 +04:00
|
|
|
$.getJSON(OC.filePath('gallery', 'ajax', 'galleryOp.php'), {operation: 'share', path: p, share: values[0].value, recursive: values[1].value}, function(r) {
|
|
|
|
if (r.status == 'success') {
|
|
|
|
Albums.shared = r.sharing;
|
|
|
|
if (Albums.shared) {
|
|
|
|
Albums.token = r.token;
|
|
|
|
Albums.recursive = r.recursive;
|
|
|
|
} else {
|
|
|
|
Albums.token = '';
|
|
|
|
Albums.recursive = false;
|
|
|
|
}
|
|
|
|
var actual_addr = '';
|
|
|
|
if (Albums.token)
|
2012-03-24 22:26:53 +04:00
|
|
|
actual_addr = constructSharingPath();
|
2012-03-24 21:35:16 +04:00
|
|
|
$('input[name="address"]').val(actual_addr);
|
|
|
|
} else {
|
|
|
|
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-03-04 21:28:41 +04:00
|
|
|
function albumClickHandler(r) {
|
2012-03-07 21:58:10 +04:00
|
|
|
Albums.photos = [];
|
|
|
|
Albums.albums = [];
|
|
|
|
if (r.status == 'success') {
|
|
|
|
for (var i in r.albums) {
|
|
|
|
var a = r.albums[i];
|
2012-03-24 21:35:16 +04:00
|
|
|
Albums.add(a.name, a.numOfItems, a.path, a.shared, a.recursive, a.token);
|
2012-03-07 21:58:10 +04:00
|
|
|
}
|
|
|
|
for (var i in r.photos) {
|
2012-03-24 21:35:16 +04:00
|
|
|
Albums.photos.push(r.photos[i]);
|
2012-03-07 21:58:10 +04:00
|
|
|
}
|
2012-03-24 21:35:16 +04:00
|
|
|
Albums.shared = r.shared;
|
|
|
|
if (Albums.shared) {
|
|
|
|
Albums.recursive = r.recursive;
|
|
|
|
Albums.token = r.token;
|
|
|
|
} else {
|
|
|
|
Albums.recursive = false;
|
|
|
|
Albums.token = '';
|
|
|
|
}
|
2012-03-07 21:58:10 +04:00
|
|
|
var targetDiv = document.getElementById('gallery_list');
|
|
|
|
if (targetDiv) {
|
|
|
|
$(targetDiv).html('');
|
|
|
|
Albums.display(targetDiv);
|
|
|
|
//$('#gallery_list').sortable({revert:true});
|
|
|
|
$('.album').each(function(i, el) {
|
2012-03-11 19:49:21 +04:00
|
|
|
$(el).click(albumClick.bind(null,$(el).attr('title')));
|
2012-03-07 21:58:10 +04:00
|
|
|
//$(el).draggable({connectToSortable: '#gallery_list', handle: '.dummy'});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
OC.dialogs.alert(t('gallery', 'Error: no such layer `gallery_list`'), t('gallery', 'Internal error'));
|
|
|
|
}
|
|
|
|
} else {
|
2012-03-24 21:35:16 +04:00
|
|
|
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
2012-03-07 21:58:10 +04:00
|
|
|
}
|
2012-03-11 19:49:21 +04:00
|
|
|
$('#g-album-loading').hide();
|
2011-09-26 00:32:08 +04:00
|
|
|
}
|
|
|
|
|
2012-01-15 18:31:17 +04:00
|
|
|
var albumCounter = 0;
|
|
|
|
var totalAlbums = 0;
|
|
|
|
|
2012-02-04 00:38:44 +04:00
|
|
|
function scanForAlbums(cleanup) {
|
2012-03-11 19:49:21 +04:00
|
|
|
Scanner.scanAlbums();
|
|
|
|
return;
|
2011-12-22 00:55:52 +04:00
|
|
|
}
|
|
|
|
|
2012-02-04 00:38:44 +04:00
|
|
|
function settings() {
|
2012-03-31 00:50:57 +04:00
|
|
|
OC.dialogs.form([{text: t('gallery', 'Scanning root'), name: 'root', type:'text', value:gallery_scanning_root},
|
|
|
|
{text: t('gallery', 'Default order'), name: 'order', type:'select', value:gallery_default_order, options:[
|
|
|
|
{text:t('gallery', 'Ascending'), value:'ASC'}, {text: t('gallery', 'Descending'), value:'DESC'} ]}],
|
|
|
|
t('gallery', 'Settings'),
|
|
|
|
function(values) {
|
|
|
|
var scanning_root = values[0].value;
|
|
|
|
var disp_order = values[1].value;
|
2012-03-07 21:58:10 +04:00
|
|
|
if (scanning_root == '') {
|
2012-03-31 00:50:57 +04:00
|
|
|
OC.dialogs.alert(t('gallery', 'Scanning root cannot be empty'), t('gallery', 'Error'));
|
2012-03-07 21:58:10 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'store_settings', root: scanning_root, order: disp_order}, function(r) {
|
|
|
|
if (r.status == 'success') {
|
2012-03-31 00:50:57 +04:00
|
|
|
if (r.rescan == 'yes') {
|
|
|
|
Albums.clear(document.getElementById('gallery_list'));
|
|
|
|
scanForAlbums(true);
|
|
|
|
}
|
|
|
|
gallery_scanning_root = scanning_root;
|
2012-03-07 21:58:10 +04:00
|
|
|
} else {
|
2012-03-31 00:50:57 +04:00
|
|
|
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Error'));
|
|
|
|
return;
|
2012-03-07 21:58:10 +04:00
|
|
|
}
|
|
|
|
});
|
2012-03-31 00:50:57 +04:00
|
|
|
});
|
2012-02-04 00:38:44 +04:00
|
|
|
}
|