Search code examples
javascriptjquerylightbox2

Lightbox 2.51 - how to move close button and image number to the top?


I'm using Lightbox 2.51 and I can't find a solution to move lb-dataContainer with close button and current image number etc to the top

enter image description here

I only found solutions for the old versions.

Code can be found here: http://lokeshdhakar.com/projects/lightbox2/releases/lightbox2.51.zip


Solution

  • The solution is to change outer container with data container:

    Lightbox.prototype.build = function() {
      var $lightbox,
        _this = this;
    
      $("<div>", {id: 'lightboxOverlay'}).after
        (
              $('<div/>', {id: 'lightbox'}
              ).append(
    
              $('<div/>', {
                "class": 'lb-dataContainer'
              }).append($('<div/>', {
                "class": 'lb-data'
              }).append($('<div/>', {
                "class": 'lb-details'
              }).append($('<span/>', {
                "class": 'lb-caption'
              }), $('<span/>', {
                "class": 'lb-number'
              })), $('<div/>', {
                "class": 'lb-closeContainer'
              }).append($('<a/>', {
                "class": 'lb-close'
              }).append($('<img/>', {
                src: this.options.fileCloseImage
            })))
     )),
    
              $('<div/>', {"class": 'lb-outerContainer'}).append
              ( $('<div/>', {
                    "class": 'lb-container'
                  }).append($('<img/>', {
                    "class": 'lb-image'
                  }), $('<div/>', {
                    "class": 'lb-nav'
                  }).append($('<a/>', {
                    "class": 'lb-prev'
                  }), $('<a/>', {
                    "class": 'lb-next'
                  })), $('<div/>', {
                    "class": 'lb-loader'
                  }).append($('<a/>', {
                    "class": 'lb-cancel'
                  }).append($('<img/>', {
                    src: this.options.fileLoadingImage
                  }))))
              )
    
    )
        ).appendTo($('body'));
      $('#lightboxOverlay').hide().on('click', function(e) {
        _this.end();
        return false;
      });