MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 1,375: Line 1,375:
     }
     }


     var section = $('.mf-section-0');
     var observer = new MutationObserver(function () {


    if (!section.length) {
        var section = $('.mf-section-0');
        return;
    }


    var authorBlock = section.children('p').filter(function () {
        var authorBlock = section.children('p').filter(function () {
        return $(this).find('span[style*="float:right"]').length;
            return $(this).find('span[style*="float:right"]').length;
    }).first();
        }).first();


    if (!authorBlock.length) {
        var poemBlock = section.children('.Poem2-Ekatra').first();
        return;
    }


    // Hide immediately
        if (authorBlock.length) {
    authorBlock.addClass('author-hidden');
            authorBlock.hide();
        }


    setTimeout(function () {
        if (authorBlock.length && poemBlock.length) {


        var poemBlock = section.children('.Poem2-Ekatra').first();
            poemBlock.after(authorBlock);
 
        if (poemBlock.length) {


             poemBlock.after(authorBlock);
             authorBlock.show();


             // Show after moving
             observer.disconnect();
            authorBlock.removeClass('author-hidden');


             console.log('Author block moved');
             console.log('Author block moved');
        }


        }
    });


     }, 100);
    observer.observe(document.body, {
        childList: true,
        subtree: true
     });


});
});