MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 122: Line 122:
             event.stopPropagation();
             event.stopPropagation();
         });
         });
 
       
         function setupImageToggle(images) {
         function setupImageToggle(images) {
             var currentIndex = 0;
             var currentIndex = 0;
             var totalImages = images.length;
             var totalImages = images.length;
           
       
             function toggleImage() {
             function toggleImage() {
                 currentIndex = (currentIndex + 1) % totalImages;
                 currentIndex = (currentIndex + 1) % totalImages;
Line 133: Line 133:
                 $('#article-content').find('.article-images').html(getImageHtml(image, currentIndex, totalImages));
                 $('#article-content').find('.article-images').html(getImageHtml(image, currentIndex, totalImages));
             }
             }
           
       
             // Bind click event to a static parent element and delegate to '.article-image img'
             // Updated event binding
             $('#article-content').on('click', '.article-image img', function () {
             $('#article-content').on('click', '.image-container img', function () {
                console.log("Image clicked");
                 toggleImage();
                 toggleImage();
             });
             });
           
         }
         }
         
       
         function getImageHtml(image, currentIndex, totalImages) {
         function getImageHtml(image, currentIndex, totalImages) {
             var imageLabel = (currentIndex + 1) + '/' + totalImages + ' IMAGES';
             var imageLabel = (currentIndex + 1) + '/' + totalImages + ' IMAGES';
Line 148: Line 148:
                       '<div class="' + image.captionClass + '">' + image.caption + '</div>' +
                       '<div class="' + image.captionClass + '">' + image.caption + '</div>' +
                   '</div>';
                   '</div>';
         }      
         }
          
          
         // Attach a mousedown event listener to close the fixed column
         // Attach a mousedown event listener to close the fixed column

Navigation menu