]> git.sur5r.net Git - i3/i3.github.io/blobdiff - js/gallery.js
Fix swapping workspaces script colon issue
[i3/i3.github.io] / js / gallery.js
index a1724fbf2bef0482d070dde141b4bbb6f7765ef0..8c3c1a9805679f973de85e882c5361fa2f52e870 100644 (file)
@@ -1,5 +1,30 @@
 // vim:ts=4:sw=4:expandtab
 // © 2011 Michael Stapelberg
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//
+//     * Redistributions in binary form must reproduce the above copyright
+//       notice, this list of conditions and the following disclaimer in the
+//       documentation and/or other materials provided with the distribution.
+//
+//     * Neither the name of Michael Stapelberg nor the
+//       names of contributors may be used to endorse or promote products
+//       derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY Michael Stapelberg ''AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL Michael Stapelberg BE LIABLE FOR ANY
+// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 function initGallery() {
     $('.shot span').css('color', '#888');
@@ -58,11 +83,23 @@ function initGallery() {
         var img = new Image();
         img.src = url;
 
+        // position imgdesc
+        $('#imgdesc').css({ 'width': $('body').width() - (2 * 64) - 4 + 'px' });
+
+        // get description
+        var desc = $(".shot a[href='" + url + "']").parent().children('span').text();
+        $('#imgdesc .description').text(desc);
+
+        // get filename
+        var pos = url.lastIndexOf('/');
+        var filename = (pos !== -1 ? url.substr(pos+1) : url);
+        $('#imgdesc .filename').text(filename);
+
         var loadcomplete = function() {
             var winW = $(window).width();
             var winH = $(window).height();
             var max_w = winW - (2 * 64);
-            var max_h = winH - 64;
+            var max_h = winH - 48;
             var dims = {
                 'top': 0,
                 'left': 0,
@@ -74,7 +111,7 @@ function initGallery() {
                 dims.height = max_h;
                 dims.width = (dims.height / img.height) * img.width;
             }
-            dims.top = (winH - dims.height) / 2;
+            dims.top = (max_h - dims.height) / 2 + 2;
             dims.left = ((max_w - dims.width) / 2) + 64;
             $('#loading').hide();
             var element = $('<img>');
@@ -198,6 +235,11 @@ function initGallery() {
 
     // setup key press handlers for the left/right arrow keys
     var keydown = function(e) {
+        // if we are not in the slideshow mode, process the event as normal
+        if (!$('#mask').is(':visible')) {
+            return true;
+        }
+
         switch (e.keyCode) {
             // left arrow
             case 37: