Skip to content

Commit

Permalink
Start building gallery tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Jul 6, 2016
1 parent 2253303 commit 040cf24
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
17 changes: 11 additions & 6 deletions ansel/js/ansel.js
Expand Up @@ -202,7 +202,7 @@ AnselCore =
loadNextView: function()
{
var current = this.viewLoading.shift();
$('anselSidebarOtherGalleries').hide();
// $('anselSidebarOtherGalleries').hide();
$('anselSidebarOtherGalleries').up().down('span').update('');
if (this.viewLoading.size()) {
var next = this.viewLoading.pop();
Expand Down Expand Up @@ -464,18 +464,21 @@ AnselCore =
{
HordeCore.doAction(
'listGalleries',
{ user: r.o, all_levels: true },
{ user: r.o, all_levels: true, mini: true },
{ callback: this.updateOtherGalleriesCallback.bind(this, r.on) }
);
},

/**
* [updateOtherGalleriesCallback description]
*
* @param {[type]} on Name of user for other galleries.
* @param {[type]} r Array of galleries.
*/
updateOtherGalleriesCallback: function(on, r)
{
$('anselSidebarOtherGalleries').up().down('span').update(on);
// @todo - need to implement a folder tree manager/objects.
// $H(r).each(function(g) {
// });
$('anselSidebarOtherGalleries').show();
this.tree.create(r);
},

/**
Expand Down Expand Up @@ -622,6 +625,7 @@ AnselCore =
document.observe('click', AnselCore.clickHandler.bindAsEventListener(AnselCore));
document.observe('dblclick', AnselCore.clickHandler.bindAsEventListener(AnselCore, true));
$('anselViewGalleries').observe('AnselLayout:galleryClick', this.onGalleryClick.bindAsEventListener(this));
$('anselSidebarOtherGalleries').observe('AnselLayout:galleryClick', this.onGalleryClick.bindAsEventListener(this));
$('anselViewImage').observe('AnselImageView:close', function() { this.closeImageView(); }.bind(this));
$('anselViewImage').observe('AnselImageView:next', this.navigateNext.bindAsEventListener(this));
$('anselViewImage').observe('AnselImageView:previous', this.navigatePrevious.bindAsEventListener(this));
Expand All @@ -644,6 +648,7 @@ AnselCore =
container: 'anselViewImage'
});

this.tree = new AnselTree($('anselSidebarOtherGalleries'));
this.initialized = true;

/* Initialize the starting page. */
Expand Down
2 changes: 1 addition & 1 deletion ansel/js/layout.js
Expand Up @@ -107,7 +107,7 @@ AnselLayout = Class.create({
return;
}

var elt = e.element(), id;
var elt = e.element();
while (Object.isElement(elt)) {
if (elt.hasClassName('ansel-tile-gallery')) {
this.opts.parent.fire('AnselLayout:galleryClick', { gid: elt.retrieve('gid') });
Expand Down
1 change: 1 addition & 0 deletions ansel/lib/Ajax.php
Expand Up @@ -29,6 +29,7 @@ public function init()
$page_output->addScriptFile('ansel.js');
$page_output->addScriptFile('layout.js');
$page_output->addScriptFile('imageview.js');
$page_output->addScriptFile('anseltree.js');
$page_output->addScriptPackage('Horde_Core_Script_Package_Datejs');

$page_output->addScriptFile('plupload/plupload.js', 'horde');
Expand Down
2 changes: 1 addition & 1 deletion ansel/lib/Ajax/Application/Handler.php
Expand Up @@ -48,7 +48,7 @@ public function listGalleries()
$galleries = $GLOBALS['storage']->listGalleries($params);
$return = new stdClass();
foreach ($galleries as $gallery) {
$return->{$gallery->id} = $gallery->toJson(Ansel_Gallery::TO_JSON_SUBGALLERIES);
$return->{$gallery->id} = $gallery->toJson(Ansel_Gallery::TO_JSON_SUBGALLERIES, !empty($this->vars->mini));
}

return $return;
Expand Down
14 changes: 9 additions & 5 deletions ansel/lib/Gallery.php
Expand Up @@ -1180,6 +1180,7 @@ public function unserialize($data)
* Returns a json representation of this gallery.
*
* @param integer $level Bit mask of what information to include.
* @param string $mini Return mini thumbnails for gallery key images.
*
* @return StdClass An object describing the gallery
* <pre>
Expand Down Expand Up @@ -1207,7 +1208,7 @@ public function unserialize($data)
* 'url' - the image url
* </pre>
*/
public function toJson($level = 0)
public function toJson($level = 0, $mini = false)
{
// @TODO: Support date grouped galleries
$vMode = $this->get('view_mode');
Expand All @@ -1224,7 +1225,11 @@ public function toJson($level = 0)
$json->dc = $this->get('date_created');
$json->dm = $this->get('last_modified');
$json->d = $this->get('desc');
$json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'thumb', false, $style)->toString(true);
if ($mini) {
$json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'Mini', false)->toString(true);
} else {
$json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'Thumb', false, $style)->toString(true);
}
$json->kid = $this->getKeyImage($style);
$json->imgs = array();
$json->ct = $this->countImages(true);
Expand All @@ -1244,7 +1249,6 @@ public function toJson($level = 0)
}

if ($level & self::TO_JSON_SUBGALLERIES) {
Horde::debug('fo');
$json->tiny =
($GLOBALS['conf']['image']['tiny'] &&
($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->_share->hasPermission('', Horde_Perms::READ)));
Expand All @@ -1255,7 +1259,7 @@ public function toJson($level = 0)
Horde_Perms::READ,
false);
foreach ($sgs as $g) {
$json->sg[] = $g->toJson();
$json->sg[] = $g->toJson($level, $mini);
}
}
}
Expand All @@ -1265,10 +1269,10 @@ public function toJson($level = 0)
$json->imgs[] = $img->toJson($style);
}
}

if ($vMode != 'Normal') {
$this->_setModeHelper($vMode);
}

return $json;
}

Expand Down
6 changes: 4 additions & 2 deletions ansel/package.xml
Expand Up @@ -22,7 +22,7 @@
<email>mrubinsk@horde.org</email>
<active>yes</active>
</lead>
<date>2014-06-16</date>
<date>2016-07-04</date>
<version>
<release>3.0.2</release>
<api>3.0.0</api>
Expand Down Expand Up @@ -128,6 +128,7 @@
<file name="tagactions.js" role="horde" />
</dir> <!-- /js/widgets -->
<file name="ansel.js" role="horde" />
<file name="anseltree.js" role="horde" />
<file name="block.js" role="horde" />
<file name="carousel.js" role="horde" />
<file name="cropper.js" role="horde" />
Expand Down Expand Up @@ -898,6 +899,7 @@
<install as="ansel/img/upload.php" name="img/upload.php" />
<install as="ansel/img/upload_preview.php" name="img/upload_preview.php" />
<install as="ansel/js/ansel.js" name="js/ansel.js" />
<install as="ansel/js/anseltree.js" name="js/anseltree.js" />
<install as="ansel/js/block.js" name="js/block.js" />
<install as="ansel/js/carousel.js" name="js/carousel.js" />
<install as="ansel/js/cropper.js" name="js/cropper.js" />
Expand Down Expand Up @@ -1380,7 +1382,7 @@
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2014-06-16</date>
<date>2016-07-04</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [jan] Keep original file names when PUTing images via WebDAV.
Expand Down

0 comments on commit 040cf24

Please sign in to comment.