2011-09-25 20:32:08 +00:00
|
|
|
var actual_cover;
|
2012-03-07 17:58:10 +00:00
|
|
|
var paths = [];
|
2012-03-04 17:28:41 +00:00
|
|
|
var crumbCount = 0;
|
|
|
|
$(document).ready(returnToElement(0));
|
|
|
|
|
|
|
|
function returnToElement(num) {
|
2012-03-07 17:58:10 +00:00
|
|
|
while (crumbCount != num) {
|
|
|
|
$('#g-album-navigation .last').remove();
|
|
|
|
$('#g-album-navigation .crumb :last').parent().addClass('last');
|
|
|
|
crumbCount--;
|
|
|
|
paths.pop();
|
|
|
|
}
|
2012-03-11 15:49:21 +00: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 17:28:41 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 15:49:21 +00:00
|
|
|
function albumClick(title) {
|
|
|
|
paths.push(title);
|
2012-03-07 17:58:10 +00:00
|
|
|
crumbCount++;
|
2012-03-11 15:49:21 +00: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 17:58:10 +00:00
|
|
|
if ($('#g-album-navigation :last-child'))
|
|
|
|
$('#g-album-navigation :last-child').removeClass('last');
|
2012-03-11 15:49:21 +00: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 17:28:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function albumClickHandler(r) {
|
2012-03-07 17:58:10 +00:00
|
|
|
Albums.photos = [];
|
|
|
|
Albums.albums = [];
|
|
|
|
if (r.status == 'success') {
|
|
|
|
for (var i in r.albums) {
|
|
|
|
var a = r.albums[i];
|
|
|
|
Albums.add(a.name, a.numOfItems,a.path);
|
|
|
|
}
|
|
|
|
for (var i in r.photos) {
|
|
|
|
Albums.photos.push(r.photos[i]);
|
|
|
|
}
|
|
|
|
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 15:49:21 +00:00
|
|
|
$(el).click(albumClick.bind(null,$(el).attr('title')));
|
2012-03-07 17:58:10 +00: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 {
|
|
|
|
OC.dialogs.alert(t('gallery', 'Error: ') + r.message, t('gallery', 'Internal error'));
|
|
|
|
}
|
2012-03-11 15:49:21 +00:00
|
|
|
$('#g-album-loading').hide();
|
2011-09-25 20:32:08 +00:00
|
|
|
}
|
|
|
|
|
2012-01-15 14:31:17 +00:00
|
|
|
var albumCounter = 0;
|
|
|
|
var totalAlbums = 0;
|
|
|
|
|
2012-02-03 20:38:44 +00:00
|
|
|
function scanForAlbums(cleanup) {
|
2012-03-11 15:49:21 +00:00
|
|
|
Scanner.scanAlbums();
|
|
|
|
return;
|
2011-12-21 20:55:52 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 20:38:44 +00:00
|
|
|
function settings() {
|
2012-03-07 17:58:10 +00:00
|
|
|
$( '#g-dialog-settings' ).dialog({
|
|
|
|
height: 180,
|
|
|
|
width: 350,
|
|
|
|
modal: false,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
text: t('gallery', 'Apply'),
|
|
|
|
click: function() {
|
|
|
|
var scanning_root = $('#g-scanning-root').val();
|
|
|
|
var disp_order = $('#g-display-order option:selected').val();
|
|
|
|
if (scanning_root == '') {
|
|
|
|
alert('Scanning root cannot be empty');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'store_settings', root: scanning_root, order: disp_order}, function(r) {
|
|
|
|
if (r.status == 'success') {
|
|
|
|
if (r.rescan == 'yes') {
|
|
|
|
$('#g-dialog-settings').dialog('close');
|
|
|
|
Albums.clear(document.getElementById('gallery_list'));
|
|
|
|
scanForAlbums(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
alert('Error: ' + r.cause);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#g-dialog-settings').dialog('close');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: t('gallery', 'Cancel'),
|
|
|
|
click: function() {
|
|
|
|
$(this).dialog('close');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
});
|
2012-02-03 20:38:44 +00:00
|
|
|
}
|