Improve block toggling.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 22 Sep 2011 18:56:08 +0000 (20:56 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 22 Sep 2011 18:56:08 +0000 (20:56 +0200)
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/templates/imageBrowser.html

index 229f76e..229d3dd 100644 (file)
@@ -191,6 +191,7 @@ Page.ImageBrowser.Header.Albums=Albums
 Page.ImageBrowser.Header.Images=Images
 Page.ImageBrowser.CreateAlbum.Button.CreateAlbum=Create Album
 Page.ImageBrowser.Album.Edit.Title=Edit Album
+Page.ImageBrowser.Album.Delete.Title=Delete Album
 Page.ImageBrowser.Album.Label.Title=Title:
 Page.ImageBrowser.Album.Label.Description=Description:
 Page.ImageBrowser.Album.Button.Save=Save Album
index 81c9f83..1e400fb 100644 (file)
@@ -51,6 +51,10 @@ textarea {
        display: none;
 }
 
+#sone .toggle-link {
+       margin-top: 1em;
+}
+
 #sone #formPassword {
        display: none;
 }
index a037e12..9c0ef90 100644 (file)
@@ -2,6 +2,28 @@
 
        <div class="page-id hidden">image-browser</div>
 
+       <script language="javascript">
+               $(function() {
+
+                       /* hide all those forms. */
+                       hideAndShowBlock = function(blockElement, clickToShowElement, clickToHideElement) {
+                               $(blockElement).hide();
+                               $(clickToShowElement).removeClass("hidden");
+                               $(clickToShowElement).click(function() {
+                                       $(blockElement).slideDown();
+                                       $(clickToShowElement).addClass("hidden");
+                                       $(clickToHideElement).removeClass("hidden");
+                               });
+                               $(clickToHideElement).click(function() {
+                                       $(blockElement).slideUp();
+                                       $(clickToHideElement).addClass("hidden");
+                                       $(clickToShowElement).removeClass("hidden");
+                               });
+                       };
+
+               });
+       </script>
+
        <%if albumRequested>
 
                <%ifnull album>
                                                });
                                                $("#edit-album label").hide();
 
-                                               /* hide all those forms. */
-                                               hideBlock = function(blockElement, clickElement) {
-                                                       $(blockElement).hide();
-                                                       $(clickElement).removeClass("hidden").click(function() {
-                                                               $(blockElement).slideDown();
-                                                               $(this).slideUp();
-                                                               return false;
-                                                       });
-                                               };
-
-                                               hideBlock(".edit-album", ".show-edit-album");
-                                               hideBlock(".create-album", ".show-create-album");
-                                               hideBlock(".upload-image", ".show-upload-image");
+                                               hideAndShowBlock(".edit-album", ".show-edit-album", ".hide-edit-album");
+                                               hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album");
+                                               hideAndShowBlock(".upload-image", ".show-upload-image", ".hide-upload-image");
+                                               hideAndShowBlock(".delete-album", ".show-delete-album", ".hide-delete-album");
                                        });
                                </script>
                        <%/if>
@@ -84,7 +97,8 @@
                        <p id="description"><% album.description|html></p>
 
                        <%if album.sone.local>
-                               <p><a class="show-edit-album hidden small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></p>
+                               <div class="show-edit-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
+                               <div class="hide-edit-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
                                <div class="edit-album">
                                        <h2><%= Page.ImageBrowser.Album.Edit.Title|l10n|html></h2>
 
                        <%/foreach>
 
                        <%if album.sone.local>
-                               <p><a class="show-create-album hidden small-link">» <%= View.CreateAlbum.Title|l10n|html></a></p>
+                               <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
+                               <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
                                <div class="create-album">
                                        <%include include/createAlbum.html>
                                </div>
                        <%/foreach>
 
                        <%if album.sone.local>
-                               <p><a class="show-upload-image hidden small-link">» <%= View.UploadImage.Title|l10n|html></a></p>
+                               <div class="show-upload-image hidden toggle-link"><a class="small-link">» <%= View.UploadImage.Title|l10n|html></a></div>
+                               <div class="hide-upload-image hidden toggle-link"><a class="small-link">« <%= View.UploadImage.Title|l10n|html></a></div>
                                <div class="upload-image">
                                        <%include include/uploadImage.html>
                                </div>
 
                                <%if album.empty>
-                                       <form id="delete-album" action="deleteAlbum.html" method="get">
-                                               <input type="hidden" name="album" value="<%album.id|html>" />
-                                               <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
-                                       </form>
+                                       <div class="show-delete-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
+                                       <div class="hide-delete-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
+                                       <div class="delete-album">
+                                               <form id="delete-album" action="deleteAlbum.html" method="get">
+                                                       <input type="hidden" name="album" value="<%album.id|html>" />
+                                                       <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
+                                               </form>
+                                       </div>
                                <%/if>
 
                        <%/if>
                                                });
                                                $("#edit-image label").hide();
 
-                                               /* hide all those forms. */
-                                               hideBlock = function(blockElement, clickElement) {
-                                                       $(blockElement).hide();
-                                                       $(clickElement).removeClass("hidden").click(function() {
-                                                               $(blockElement).slideDown();
-                                                               $(this).slideUp();
-                                                               return false;
-                                                       });
-                                               };
-
-                                               hideBlock(".edit-image", ".show-edit-image");
-                                               hideBlock(".delete-image", ".show-delete-image");
+                                               hideAndShowBlock(".edit-image", ".show-edit-image", ".hide-edit-image");
+                                               hideAndShowBlock(".delete-image", ".show-delete-image", ".hide-delete-image");
                                        });
                                </script>
                        <%/if>
 
                        <%if image.sone.local>
 
-                               <p><a class="show-edit-image hidden small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></p>
+                               <div class="show-edit-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
+                               <div class="hide-edit-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
                                <div class="edit-image">
                                        <h2><%= Page.ImageBrowser.Image.Edit.Title|l10n|html></h2>
 
                                        </form>
                                </div>
 
-                               <p><a class="show-delete-image hidden small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></p>
+                               <div class="show-delete-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
+                               <div class="hide-delete-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
                                <div class="delete-image">
                                        <h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
 
                                        });
                                        $("#create-album label").hide();
 
-                                       /* hide all those forms. */
-                                       hideBlock = function(blockElement, clickElement) {
-                                               $(blockElement).hide();
-                                               $(clickElement).removeClass("hidden").click(function() {
-                                                       $(blockElement).slideDown();
-                                                       $(this).slideUp();
-                                                       return false;
-                                               });
-                                       };
-
-                                       hideBlock(".create-album", ".show-create-album");
+                                       hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album");
                                });
                        </script>
                <%/if>
                        <%/foreach>
 
                        <%if sone.local>
-                               <p><a class="show-create-album hidden small-link">» <%= View.CreateAlbum.Title|l10n|html></a></p>
+                               <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
+                               <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
                                <div class="create-album">
                                        <%include include/createAlbum.html>
                                </div>