From 90521450a069e856183d192e8aff85d158e632b8 Mon Sep 17 00:00:00 2001 From: Max Shinn Date: Tue, 28 Dec 2010 09:38:50 -0600 Subject: [PATCH] Cool js photo resizing effect --- .../GNUsocialPhotos/GNUsocialPhotosPlugin.php | 5 ++++ plugins/GNUsocialPhotos/actions/photos.php | 25 +++++++++++++++++-- .../GNUsocialPhotos/res/gnusocialphotos.js | 15 +++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 plugins/GNUsocialPhotos/res/gnusocialphotos.js diff --git a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php index 7be8b0a962..a3aed95c0c 100644 --- a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php +++ b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php @@ -199,5 +199,10 @@ class GNUsocialPhotosPlugin extends Plugin { $action->cssLink('/plugins/GNUsocialPhotos/res/style.css'); } + + function onEndShowScripts($action) + { + $action->script('plugins/GNUsocialPhotos/res/gnusocialphotos.js'); + } } diff --git a/plugins/GNUsocialPhotos/actions/photos.php b/plugins/GNUsocialPhotos/actions/photos.php index bfa77b9c35..d113600850 100644 --- a/plugins/GNUsocialPhotos/actions/photos.php +++ b/plugins/GNUsocialPhotos/actions/photos.php @@ -83,10 +83,20 @@ class PhotosAction extends Action if (!$album->find()) { GNUsocialPhotoAlbum::newAlbum($cur->id, 'Default'); } + + $this->elementStart('div', array('class' => 'galleryheader')); + $this->element('a', array('href' => '#', + 'onclick' => 'increasePhotoSize()'), '+'); + $this->raw(' | '); + $this->element('a', array('href' => '#', + 'onclick' => 'decreasePhotoSize()'), '-'); + $this->elementEnd('div'); + while ($album->fetch()) { $this->elementStart('div', array('class' => 'photocontainer')); $this->elementStart('a', array('href' => $album->getPageLink())); - $this->element('img', array('src' => $album->getThumbUri())); + $this->element('img', array('src' => $album->getThumbUri(), + 'class' => 'albumingallery')); $this->elementEnd('a'); $this->element('h3', array(), $album->album_name); $this->elementEnd('div'); @@ -107,17 +117,28 @@ class PhotosAction extends Action } $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9); + $this->elementStart('div', array('class' => 'galleryheader')); if ($page > 1) { $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page-1)), 'Previous page'); + $this->raw(' | '); } if (GNUsocialPhoto::getGalleryPage($page+1, $album->album_id, 9)) { $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page+1) ), 'Next page'); + $this->raw(' | '); } + $this->element('a', array('href' => '#', + 'onclick' => 'increasePhotoSize()'), '+'); + $this->raw(' | '); + $this->element('a', array('href' => '#', + 'onclick' => 'decreasePhotoSize()'), '-'); + $this->elementEnd('div'); + foreach ($photos as $photo) { $this->elementStart('a', array('href' => $photo->getPageLink())); $this->elementStart('div', array('class' => 'photocontainer')); - $this->element('img', array('src' => $photo->thumb_uri)); + $this->element('img', array('src' => $photo->thumb_uri, + 'class' => 'photoingallery')); $this->element('div', array('class' => 'phototitle'), $photo->title); $this->elementEnd('div'); $this->elementEnd('a'); diff --git a/plugins/GNUsocialPhotos/res/gnusocialphotos.js b/plugins/GNUsocialPhotos/res/gnusocialphotos.js new file mode 100644 index 0000000000..3a959a5db4 --- /dev/null +++ b/plugins/GNUsocialPhotos/res/gnusocialphotos.js @@ -0,0 +1,15 @@ +function increasePhotoSize() { + $('.photoingallery, .albumingallery').each(function(index) { + this.height *= 1.1; + this.width *= 1.1; + }); + return false; +} + +function decreasePhotoSize() { + $('.photoingallery, .albumingallery').each(function(index) { + this.height /= 1.1; + this.width /= 1.1; + }); + return false; +} -- 2.39.2