From: Simon Cozens <simon@simon-cozens.org> Date: Tue, 13 Feb 2007 08:57:55 +0000 (+0000) Subject: More Ajaxing. X-Git-Tag: 1.2+svn20070808~36 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=a1a5f8caa6a6d7af6f3b69fe36300a0d07c53d2d;p=memories.git More Ajaxing. git-svn-id: http://svn.simon-cozens.org/memories/trunk@32 041978f6-d955-411f-a9d7-1d8545c9c3c7 --- diff --git a/Memories/Photo.pm b/Memories/Photo.pm index 57a53c4..d14619e 100644 --- a/Memories/Photo.pm +++ b/Memories/Photo.pm @@ -132,6 +132,7 @@ sub exif :Exported {} sub comment :Exported {} sub tagedit :Exported {} sub similar :Exported {} +sub sized :Exported {} use Class::DBI::Plugin::Pager; use Class::DBI::Plugin::AbstractCount; diff --git a/templates/photo/sized b/templates/photo/sized new file mode 100644 index 0000000..c0a0f10 --- /dev/null +++ b/templates/photo/sized @@ -0,0 +1,30 @@ +<div class="photoview" id="photoview"> + [% SET sizes = request.config.sizes %] + [% IF request.params.exists("scale") %] + [% SET size = request.params.scale %] + [% ELSIF request.session.scale %] + [% SET size = request.session.scale %] + [% ELSE; SET size = 1; END; %] + <img src="[% photo.sized_url(size) %]" id="thephoto"> + <p> (Original size [%photo.dimensions %]) </p> + <p> + <script> function change_size(size) { + new Ajax.Updater("photoview", "[%base%]/photo/sized/[%photo.id%]?scale="+size); + } </script> + Size: + [% SET i = 0; WHILE i < sizes.size %] + [% IF photo.is_bigger(sizes.$i); %] + [% IF i == size %] + [% sizes.$i %] + [% ELSIF sizes.$i == "full" %] + <a href="[%photo.path("url")%]">full</a> + [% ELSE %] + <a href="javascript:change_size([%i%])">[% sizes.$i %]</a> + [% END %] + [% END; %] + [% SET i = i + 1 %] + [% END %] + </p> + [%# Now put it back in the session %] + [% SET request.session.scale = size %] +</div> diff --git a/templates/photo/view b/templates/photo/view index 4671484..0fbccbb 100644 --- a/templates/photo/view +++ b/templates/photo/view @@ -61,33 +61,7 @@ photo.uploader %] </a> END %] </div> -<div class="photoview"> - [% SET sizes = request.config.sizes %] - [% IF request.params.exists("scale") %] - [% SET size = request.params.scale %] - [% ELSIF request.session.scale %] - [% SET size = request.session.scale %] - [% ELSE; SET size = 1; END; %] - <img src="[% photo.sized_url(size) %]"> - <p> (Original size [%photo.dimensions %]) </p> - <p> - Size: - [% SET i = 0; WHILE i < sizes.size %] - [% IF photo.is_bigger(sizes.$i); %] - [% IF i == size %] - [% sizes.$i %] - [% ELSIF sizes.$i == "full" %] - <a href="[%photo.path("url")%]">full</a> - [% ELSE %] - <a href="[%url%]?scale=[% i %]&active=[%tab%]">[% sizes.$i %]</a> - [% END %] - [% END; %] - [% SET i = i + 1 %] - [% END %] - </p> - [%# Now put it back in the session %] - [% SET request.session.scale = size %] -</div> +[% PROCESS sized %] [% IF photo.description OR photo.copyright OR photo.license %] <div class="photodesc">