*/
var AnselMobile = {
+ /**
+ * The currently displayed gallery
+ *
+ * @var object
+ */
currentGallery: null,
/**
{
// TODO: error checks, build any subgallery lists etc...
if ($.mobile.currentPage != 'galleryview' &&
- AnselMobile.currentGallery && (r.id == AnselMobile.currentGallery)) {
+ AnselMobile.currentGallery && (r.id == AnselMobile.currentGallery.id)) {
$.mobile.changePage('galleryview', 'slide', false, true);
return;
}
//AnselMobile.imgs = r.imgs;
- AnselMobile.currentGallery = r.id;
+ AnselMobile.currentGallery = r;
if (r.sg.length) {
var l = $('<ul>').addClass('anselgalleries').attr({ 'data-role': 'listview', 'data-inset': 'true' });
$('#thumbs').before(AnselMobile.buildGalleryList(l, r.sg).listview());
var img = $('<li>').addClass('anselthumb').append($('<a>').attr({ 'href': '#' }).append($('<img>').attr({ src: i.url })));
$('#thumbs').append(img);
});
+ if (r.p) {
+ $('#gallerybackbutton .ui-btn-text').text(r.pn);
+ $('#gallerybackbutton').attr({ 'action': 'gallery', 'gallery-id': r.p });
+ } else {
+ $('#gallerybackbutton .ui-btn-text').text($.mobile.page.prototype.options.backBtnText);
+ $('#gallerybackbutton').attr({ 'action': 'home' });
+ }
AnselMobile.centerGrid();
},
if (elt.hasClass('ansel-gallery')) {
AnselMobile.toGallery(elt.attr('ansel-gallery-id'));
}
+ if (elt.attr('id') == 'gallerybackbutton') {
+ switch (elt.attr('action')) {
+ case 'home':
+ $.mobile.changePage('gallerylist', 'slide', true, true);
+ break;
+ case 'gallery':
+ AnselMobile.toGallery(elt.attr('gallery-id'));
+ }
+ }
elt = elt.parent();
}
},
*
* @return mixed False on failure, object representing the gallery with
* the following structure:
- * <pre>
- * 'id' - gallery id
- * 'n' - gallery name
- * 'dc' - date created
- * 'dm' - date modified
- * 'd' - description
- * 'ki' - key image
- * 'sg' - an object with the following properties:
- * 'n' - gallery name
- * 'dc' - date created
- * 'dm' - date modified
- * 'd' - description
- * 'ki' - key image
- *
- * 'imgs' - an array of image objects with the following properties:
- * 'id' - the image id
- * 'url' - the image url
- * </pre>
+ * @see Ansel_Gallery::toJson()
*/
public function getGallery()
{
* @param boolean $full Return all information (subgalleries and images)?
*
* @return StdClass An object describing the gallery
+ * <pre>
+ * 'id' - gallery id
+ * 'p' - gallery's parent's id (null if top level)
+ * 'pn' - gallery's parent's name (null if top level)
+ * 'n' - gallery name
+ * 'dc' - date created
+ * 'dm' - date modified
+ * 'd' - description
+ * 'ki' - key image
+ * 'sg' - an object with the following properties:
+ * 'n' - gallery name
+ * 'dc' - date created
+ * 'dm' - date modified
+ * 'd' - description
+ * 'ki' - key image
+ *
+ * 'imgs' - an array of image objects with the following properties:
+ * 'id' - the image id
+ * 'url' - the image url
+ * </pre>
*/
public function toJson($full = false)
{
$parents = $this->get('parents');
if (empty($parents)) {
$json->p = null;
+ $json->pn - null;
} else {
$parents = explode(':', $parents);
$json->p = array_pop($parents);
+ $json->pn = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($json->p)->get('name');
}
if ($full) {