"മീഡിയവിക്കി:Common.js" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

അഭിപ്രായവേദി സംരംഭത്തിൽ നിന്ന്
(ചെ.)തിരുത്തിനു സംഗ്രഹമില്ല
റ്റാഗ്: പഴയപടിയാക്കി
(ചെ.)തിരുത്തിനു സംഗ്രഹമില്ല
 
(ഒരേ ചെയ്ത ഇടയ്ക്കുള്ള 6 നാൾപ്പതിപ്പുകൾ പ്രദർശിപ്പിക്കുന്നില്ല)
വരി 20: വരി 20:
     }
     }
});
});
/* ==========================================================================
/* ==========================================================================
   2. Anonymous User Interface
   2. Anonymous User Interface
==========================================================================  
========================================================================== */


(function () {
(function () {
വരി 51: വരി 49:


}());
}());
*/
 
/* ==========================================================================
  EDITORIAL ACCESS GATEWAY
  Show the appropriate view depending on login status.
  ========================================================================== */
 
$(function () {
 
    // Run only on the Editorial Access page
    if (mw.config.get('wgPageName') !== 'Editorial_Access') {
        return;
    }
 
    var username = mw.config.get('wgUserName');
 
    var loginSection = document.getElementById('editorial-login');
    var workspaceSection = document.getElementById('editorial-workspace');
 
    if (!loginSection || !workspaceSection) {
        return;
    }
 
    if (username) {
        loginSection.style.display = 'none';
        workspaceSection.style.display = 'block';
    } else {
        loginSection.style.display = 'block';
        workspaceSection.style.display = 'none';
    }
if (username) {
    workspaceSection.style.display = 'block';
} else {
    loginSection.style.display = 'block';
 
    var loginLink = document.querySelector('#editorial-login-button a');
 
    if (loginLink) {
        loginLink.href =
            mw.util.getUrl('Special:UserLogin') +
            '?returnto=' +
            encodeURIComponent(mw.config.get('wgPageName'));
    }
}
});
 
/* ==========================================================================
  FOOTER LINK - EDITORIAL ACCESS
  ========================================================================== */
 
$(function () {
    mw.util.addPortletLink(
        'footer-places',
        mw.util.getUrl('Editorial_Access'),
        'Editorial Access',
        'footer-editorial-access'
    );
});
/* ==========================================================================
  6. SOCIAL MEDIA SHARING — VERSION 1.1
  Individual platform sharing
  Supports Article Pages and Home Page
========================================================================== */
 
$(document).on(
    'click',
    '.article-share-button, .homepage-share-button',
    function (event) {
 
        var button = $(this);
        var isHomepage = button.hasClass('homepage-share-button');
 
        var articleTitle = document.getElementById('firstHeading');
 
        var title = isHomepage
            ? 'അഭിപ്രായവേദി – സ്വതന്ത്ര സംവാദത്തിന്റെയും ഗവേഷണത്തിന്റെയും വേദി'
            : (articleTitle ? articleTitle.textContent.trim() : document.title);
 
        // Obtain canonical page URL
        var canonicalElement = document.querySelector('link[rel="canonical"]');
 
        var pageURL = canonicalElement
            ? canonicalElement.href
            : mw.config.get('wgServer') + mw.util.getUrl(mw.config.get('wgPageName'));
 
        var shareURL = '';
 
        if (button.hasClass('share-whatsapp')) {
 
            shareURL = 'https://wa.me/?text=' +
                encodeURIComponent(pageURL);
 
        } else if (button.hasClass('share-facebook')) {
 
            shareURL = 'https://www.facebook.com/sharer/sharer.php?u=' +
                encodeURIComponent(pageURL);
 
        } else if (button.hasClass('share-telegram')) {
 
            shareURL = 'https://t.me/share/url?url=' +
                encodeURIComponent(pageURL);
 
        } else if (button.hasClass('share-x')) {
 
            shareURL = 'https://twitter.com/intent/tweet?text=' +
                encodeURIComponent(title) +
                '&url=' + encodeURIComponent(pageURL);
 
        }
 
        if (shareURL) {
            event.preventDefault();
            window.open(shareURL, '_blank', 'noopener,noreferrer');
        }
 
    }
);
 
// Keyboard accessibility
$(document).on(
    'keydown',
    '.article-share-button, .homepage-share-button',
    function (event) {
 
        if (event.which === 13 || event.which === 32) {
            event.preventDefault();
            $(this).trigger('click');
        }
 
    }
);
 
 
/* ==========================================================================
  7. SOCIAL MEDIA SHARING — COPY LINK
  Supports Article Pages and Home Page
========================================================================== */
 
$(document).on(
    'click',
    '.article-share-button.share-copy, .homepage-share-button.share-copy',
    function (event) {
 
        event.preventDefault();
 
        var button = $(this);
        var label = button.find('.share-label');
        var originalText = label.text();
 
        var canonicalElement = document.querySelector('link[rel="canonical"]');
 
        var pageURL = canonicalElement
            ? canonicalElement.href
            : window.location.href;
 
        function showCopyMessage(message) {
 
            label.text(message);
 
            setTimeout(function () {
                label.text(originalText);
            }, 2000);
 
        }
 
        if (navigator.clipboard && window.isSecureContext) {
 
            navigator.clipboard.writeText(pageURL)
                .then(function () {
                    showCopyMessage('Copied!');
                })
                .catch(function () {
                    showCopyMessage('Copy failed');
                });
 
        } else {
 
            var textArea = document.createElement('textarea');
 
            textArea.value = pageURL;
            textArea.style.position = 'fixed';
            textArea.style.opacity = '0';
 
            document.body.appendChild(textArea);
            textArea.select();
 
            var copied = document.execCommand('copy');
 
            document.body.removeChild(textArea);
 
            showCopyMessage(copied ? 'Copied!' : 'Copy failed');
 
        }
 
    }
);
 
 
/* ==========================================================================
  8. SOCIAL MEDIA SHARING — NATIVE DEVICE SHARE
  Supports Article Pages and Home Page
========================================================================== */
 
$(document).on(
    'click',
    '.article-share-button.share-native, .homepage-share-button.share-native',
    function (event) {
 
        event.preventDefault();
 
        var button = $(this);
        var label = button.find('.share-label');
        var originalText = label.text();
 
        var isHomepage = button.hasClass('homepage-share-button');
 
        var titleElement = document.getElementById('firstHeading');
 
        var title = isHomepage
            ? 'അഭിപ്രായവേദി – സ്വതന്ത്ര സംവാദത്തിന്റെയും ഗവേഷണത്തിന്റെയും വേദി'
            : (titleElement ? titleElement.textContent.trim() : document.title);
 
        var canonicalElement = document.querySelector('link[rel="canonical"]');
 
        var pageURL = canonicalElement
            ? canonicalElement.href
            : window.location.href;
 
        if (navigator.share) {
 
            navigator.share({
                title: title,
                text: title,
                url: pageURL
            }).catch(function (error) {
 
                if (error.name !== 'AbortError') {
 
                    label.text('Sharing failed');
 
                    setTimeout(function () {
                        label.text(originalText);
                    }, 2000);
 
                }
 
            });
 
        } else {
 
            label.text('Not supported');
 
            setTimeout(function () {
                label.text(originalText);
            }, 2000);
 
        }
 
    }
);

12:51, 15 നവംബർ 2026-നു നിലവിലുള്ള രൂപം

/* ഇവിടെ നൽകുന്ന ജാവാസ്ക്രിപ്റ്റ് എല്ലാ ഉപയോക്താക്കൾക്കും, എല്ലാ താളുകളിലും പ്രവർത്തിക്കുന്നതായിരിക്കും */
/* ==========================================================================
   COMMON.JS
   Abhiprayavedi
   Version 1.0
========================================================================== */
/* ==========================================================================
   1. Category Page Enhancements
========================================================================== */
$(document).ready(function() {
    if ($('.mw-category').length) {
        $('.mw-category li a').each(function() {
            var pageTitle = $(this).attr('title');
            if (pageTitle) {
                // This will use the page's actual display title
                // MediaWiki automatically uses DISPLAYTITLE in title attribute
                $(this).text(pageTitle);
            }
        });
    }
});
/* ==========================================================================
   2. Anonymous User Interface
========================================================================== */

(function () {

    if (mw.config.get('wgUserId') === null) {

        $(document).ready(function () {

            // Remove page tabs
            $('#mw-page-header-links').remove();

            // Remove "From AbhiprayaVedi"
            $('#siteSub').remove();

            // Hide MediaWiki generated category listing
            $('.mw-category-generated').hide();

           // Hide PullQuote for anonymous desktop users
           if (window.matchMedia("(min-width: 769px)").matches) {
           $('.pullquote').hide();
}

        });

    }

}());

/* ==========================================================================
   EDITORIAL ACCESS GATEWAY
   Show the appropriate view depending on login status.
   ========================================================================== */

$(function () {

    // Run only on the Editorial Access page
    if (mw.config.get('wgPageName') !== 'Editorial_Access') {
        return;
    }

    var username = mw.config.get('wgUserName');

    var loginSection = document.getElementById('editorial-login');
    var workspaceSection = document.getElementById('editorial-workspace');

    if (!loginSection || !workspaceSection) {
        return;
    }

    if (username) {
        loginSection.style.display = 'none';
        workspaceSection.style.display = 'block';
    } else {
        loginSection.style.display = 'block';
        workspaceSection.style.display = 'none';
    }
if (username) {
    workspaceSection.style.display = 'block';
} else {
    loginSection.style.display = 'block';

    var loginLink = document.querySelector('#editorial-login-button a');

    if (loginLink) {
        loginLink.href =
            mw.util.getUrl('Special:UserLogin') +
            '?returnto=' +
            encodeURIComponent(mw.config.get('wgPageName'));
    }
}
});

/* ==========================================================================
   FOOTER LINK - EDITORIAL ACCESS
   ========================================================================== */

$(function () {
    mw.util.addPortletLink(
        'footer-places',
        mw.util.getUrl('Editorial_Access'),
        'Editorial Access',
        'footer-editorial-access'
    );
});
/* ==========================================================================
   6. SOCIAL MEDIA SHARING — VERSION 1.1
   Individual platform sharing
   Supports Article Pages and Home Page
========================================================================== */

$(document).on(
    'click',
    '.article-share-button, .homepage-share-button',
    function (event) {

        var button = $(this);
        var isHomepage = button.hasClass('homepage-share-button');

        var articleTitle = document.getElementById('firstHeading');

        var title = isHomepage
            ? 'അഭിപ്രായവേദി – സ്വതന്ത്ര സംവാദത്തിന്റെയും ഗവേഷണത്തിന്റെയും വേദി'
            : (articleTitle ? articleTitle.textContent.trim() : document.title);

        // Obtain canonical page URL
        var canonicalElement = document.querySelector('link[rel="canonical"]');

        var pageURL = canonicalElement
            ? canonicalElement.href
            : mw.config.get('wgServer') + mw.util.getUrl(mw.config.get('wgPageName'));

        var shareURL = '';

        if (button.hasClass('share-whatsapp')) {

            shareURL = 'https://wa.me/?text=' +
                encodeURIComponent(pageURL);

        } else if (button.hasClass('share-facebook')) {

            shareURL = 'https://www.facebook.com/sharer/sharer.php?u=' +
                encodeURIComponent(pageURL);

        } else if (button.hasClass('share-telegram')) {

            shareURL = 'https://t.me/share/url?url=' +
                encodeURIComponent(pageURL);

        } else if (button.hasClass('share-x')) {

            shareURL = 'https://twitter.com/intent/tweet?text=' +
                encodeURIComponent(title) +
                '&url=' + encodeURIComponent(pageURL);

        }

        if (shareURL) {
            event.preventDefault();
            window.open(shareURL, '_blank', 'noopener,noreferrer');
        }

    }
);

// Keyboard accessibility
$(document).on(
    'keydown',
    '.article-share-button, .homepage-share-button',
    function (event) {

        if (event.which === 13 || event.which === 32) {
            event.preventDefault();
            $(this).trigger('click');
        }

    }
);


/* ==========================================================================
   7. SOCIAL MEDIA SHARING — COPY LINK
   Supports Article Pages and Home Page
========================================================================== */

$(document).on(
    'click',
    '.article-share-button.share-copy, .homepage-share-button.share-copy',
    function (event) {

        event.preventDefault();

        var button = $(this);
        var label = button.find('.share-label');
        var originalText = label.text();

        var canonicalElement = document.querySelector('link[rel="canonical"]');

        var pageURL = canonicalElement
            ? canonicalElement.href
            : window.location.href;

        function showCopyMessage(message) {

            label.text(message);

            setTimeout(function () {
                label.text(originalText);
            }, 2000);

        }

        if (navigator.clipboard && window.isSecureContext) {

            navigator.clipboard.writeText(pageURL)
                .then(function () {
                    showCopyMessage('Copied!');
                })
                .catch(function () {
                    showCopyMessage('Copy failed');
                });

        } else {

            var textArea = document.createElement('textarea');

            textArea.value = pageURL;
            textArea.style.position = 'fixed';
            textArea.style.opacity = '0';

            document.body.appendChild(textArea);
            textArea.select();

            var copied = document.execCommand('copy');

            document.body.removeChild(textArea);

            showCopyMessage(copied ? 'Copied!' : 'Copy failed');

        }

    }
);


/* ==========================================================================
   8. SOCIAL MEDIA SHARING — NATIVE DEVICE SHARE
   Supports Article Pages and Home Page
========================================================================== */

$(document).on(
    'click',
    '.article-share-button.share-native, .homepage-share-button.share-native',
    function (event) {

        event.preventDefault();

        var button = $(this);
        var label = button.find('.share-label');
        var originalText = label.text();

        var isHomepage = button.hasClass('homepage-share-button');

        var titleElement = document.getElementById('firstHeading');

        var title = isHomepage
            ? 'അഭിപ്രായവേദി – സ്വതന്ത്ര സംവാദത്തിന്റെയും ഗവേഷണത്തിന്റെയും വേദി'
            : (titleElement ? titleElement.textContent.trim() : document.title);

        var canonicalElement = document.querySelector('link[rel="canonical"]');

        var pageURL = canonicalElement
            ? canonicalElement.href
            : window.location.href;

        if (navigator.share) {

            navigator.share({
                title: title,
                text: title,
                url: pageURL
            }).catch(function (error) {

                if (error.name !== 'AbortError') {

                    label.text('Sharing failed');

                    setTimeout(function () {
                        label.text(originalText);
                    }, 2000);

                }

            });

        } else {

            label.text('Not supported');

            setTimeout(function () {
                label.text(originalText);
            }, 2000);

        }

    }
);
"https://abhiprayavedi.org/index.php?title=മീഡിയവിക്കി:Common.js&oldid=4538" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്