]> git.decadent.org.uk Git - memories.git/commitdiff
More Ajaxing.
authorSimon Cozens <simon@simon-cozens.org>
Tue, 13 Feb 2007 08:57:55 +0000 (08:57 +0000)
committerSimon Cozens <simon@simon-cozens.org>
Tue, 13 Feb 2007 08:57:55 +0000 (08:57 +0000)
git-svn-id: http://svn.simon-cozens.org/memories/trunk@32 041978f6-d955-411f-a9d7-1d8545c9c3c7

Memories/Photo.pm
templates/photo/sized [new file with mode: 0644]
templates/photo/view

index 57a53c46d93b9c68471195f0ac070e3206444fa3..d14619ee03cd0440ba42d354438658a03d368d5c 100644 (file)
@@ -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 (file)
index 0000000..c0a0f10
--- /dev/null
@@ -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>
index 46714844e8022309c048f8df7537415157aa852c..0fbccbba48aa0c1b6559f8665bb88822b11b194e 100644 (file)
@@ -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">