مدیاویکی:Common.js: تفاوت میان نسخه‌ها

از ویکی داد
پرش به ناوبری پرش به جستجو
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
برچسب: برگردانده‌شده
خط ۲۳۹: خط ۲۳۹:


} );
} );
/* =========================================================
  ویکی‌داد — منوی موبایل
  ========================================================= */
/* ---------------------------------------------------------
  منوی موبایل در حالت عادی مخفی است
  --------------------------------------------------------- */
.wd-mobile-menu {
    display: none;
}
/* =========================================================
  فقط موبایل
  ========================================================= */
@media screen and (max-width: 767px) {
    /* -----------------------------------------------------
      نوار منوی موبایل
      ----------------------------------------------------- */
    .wd-mobile-menu {
        display: block;
        width: 100%;
        margin: 0 0 18px 0;
        direction: rtl;
        text-align: right;
        font-family:
            "Vazirmatn",
            "IRANSans",
            Tahoma,
            Arial,
            sans-serif;
    }
    /* -----------------------------------------------------
      دکمه منو
      ----------------------------------------------------- */
    .wd-mobile-menu-button {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: 48px;
        padding: 10px 15px;
        background: #ffffff;
        border: 1px solid #dfe7e5;
        border-right: 4px solid #168477;
        border-radius: 9px;
        color: #11695f;
        font-size: 15px;
        font-weight: bold;
        line-height: 1.8;
        cursor: pointer;
        box-shadow:
            0 2px 10px rgba(20,60,55,0.05);
        transition:
            background 0.15s ease,
            border-color 0.15s ease;
    }
    .wd-mobile-menu-button:hover,
    .wd-mobile-menu-button:focus {
        background: #f5faf8;
        border-color: #168477;
        outline: none;
    }
    /* آیکون همبرگری */
    .wd-mobile-menu-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin-left: 8px;
        background: #edf7f4;
        border-radius: 7px;
        color: #168477;
        font-size: 20px;
        line-height: 1;
    }
    /* فلش */
    .wd-mobile-menu-arrow {
        font-size: 15px;
        color: #78909c;
        transition:
            transform 0.2s ease;
    }
    .wd-mobile-menu.is-open
    .wd-mobile-menu-arrow {
        transform: rotate(180deg);
    }
    /* -----------------------------------------------------
      محتوای منو
      ----------------------------------------------------- */
    .wd-mobile-menu-content {
        display: none;
        margin-top: 7px;
        padding: 7px;
        background: #ffffff;
        border: 1px solid #dfe7e5;
        border-radius: 9px;
        box-shadow:
            0 4px 16px rgba(20,60,55,0.07);
    }
    .wd-mobile-menu.is-open
    .wd-mobile-menu-content {
        display: block;
    }
    /* -----------------------------------------------------
      لینک‌های منو
      ----------------------------------------------------- */
    .wd-mobile-menu-content a {
        display: block;
        width: 100%;
        padding: 11px 13px;
        margin: 2px 0;
        border-radius: 7px;
        color: #37474f !important;
        font-size: 15px;
        font-weight: normal;
        line-height: 1.8;
        text-decoration: none !important;
        transition:
            background 0.15s ease,
            color 0.15s ease;
    }
    .wd-mobile-menu-content a:hover,
    .wd-mobile-menu-content a:focus {
        background: #f1f8f6;
        color: #11695f !important;
    }
    /* -----------------------------------------------------
      لینک فعال
      ----------------------------------------------------- */
    .wd-mobile-menu-content a.wd-mobile-active {
        background: #edf7f4;
        color: #11695f !important;
        font-weight: bold;
    }
    /* -----------------------------------------------------
      جداکننده
      ----------------------------------------------------- */
    .wd-mobile-menu-divider {
        height: 1px;
        margin: 7px 10px;
        background: #e7eeec;
    }
    /* -----------------------------------------------------
      گروه اصلی
      ----------------------------------------------------- */
    .wd-mobile-menu-title {
        padding: 7px 13px 5px;
        color: #78909c;
        font-size: 11px;
        font-weight: bold;
        line-height: 1.8;
    }
}

نسخهٔ ۱۰ سپتامبر ۲۰۲۶، ساعت ۱۳:۱۷

$( function () {

    /*
     * =====================================================
     * ویکی‌داد — تست‌های تعاملی
     * =====================================================
     */


    /*
     * -----------------------------------------------------
     * تبدیل گزینه‌های لیست به گزینه‌های قابل کلیک
     * -----------------------------------------------------
     */

    $( '.wd-test-options' ).each( function () {

        var container = $( this );

        container.find( 'li' ).each( function () {

            $( this ).addClass( 'wd-test-option' );

        } );

    });


    /*
     * -----------------------------------------------------
     * انتخاب گزینه
     * -----------------------------------------------------
     */

    $( document ).on( 'click', '.wd-test-option', function () {

        var option = $( this );

        var box = option.closest( '.wd-test' );


        /*
         * اگر پاسخ صحیح قبلاً انتخاب شده،
         * تست تمام شده است.
         */

        if ( box.hasClass( 'wd-test-finished' ) ) {
            return;
        }


        /*
         * دریافت پاسخ صحیح
         */

        var answer = $.trim(
            box.attr( 'data-answer' )
        );


        /*
         * متن گزینه انتخاب‌شده
         */

        var selectedText = $.trim(
            option.text()
        );


        /*
         * عناصر نتیجه
         */

        var result = box.find(
            '.wd-test-result'
        );

        var message = box.find(
            '.wd-test-result-message'
        );

        var answerBox = box.find(
            '.wd-test-answer'
        );


        /*
         * تشخیص حرف گزینه
         */

        var selectedLetter = '';


        if (
            selectedText.indexOf( 'الف' ) === 0
        ) {

            selectedLetter = 'الف';

        } else if (
            selectedText.indexOf( 'ب' ) === 0
        ) {

            selectedLetter = 'ب';

        } else if (
            selectedText.indexOf( 'ج' ) === 0
        ) {

            selectedLetter = 'ج';

        } else if (
            selectedText.indexOf( 'د' ) === 0
        ) {

            selectedLetter = 'د';

        }


        /*
         * تبدیل:
         *
         * گزینه ب
         *
         * به:
         *
         * ب
         */

        var correctLetter = answer
            .replace( 'گزینه', '' )
            .replace( ':', '' )
            .trim();


        /*
         * ثبت انتخاب کاربر
         */

        option.addClass(
            'wd-selected'
        );


        /*
         * نمایش پیام نتیجه
         */

        result.show();


        /*
         * =================================================
         * پاسخ صحیح
         * =================================================
         */

        if (
            selectedLetter === correctLetter
        ) {

            option.addClass(
                'wd-correct'
            );


            message
                .removeClass(
                    'wd-result-wrong'
                )
                .addClass(
                    'wd-result-correct'
                )
                .text(
                    '✓ پاسخ شما صحیح است.'
                );


            /*
             * نمایش پاسخ و تحلیل
             */

            answerBox
                .stop(
                    true,
                    true
                )
                .slideDown(
                    250
                );


            /*
             * پایان تست
             */

            box.addClass(
                'wd-test-finished'
            );

        }


        /*
         * =================================================
         * پاسخ غلط
         * =================================================
         */

        else {

            option.addClass(
                'wd-wrong'
            );


            message
                .removeClass(
                    'wd-result-correct'
                )
                .addClass(
                    'wd-result-wrong'
                )
                .text(
                    '✕ پاسخ شما نادرست است.'
                );


            /*
             * عمداً پاسخ صحیح را نمایش نمی‌دهیم.
             *
             * کاربر می‌تواند گزینه دیگری را انتخاب کند.
             */

        }

    });

} );


/* =========================================================
   ویکی‌داد — منوی موبایل
   ========================================================= */


/* ---------------------------------------------------------
   منوی موبایل در حالت عادی مخفی است
   --------------------------------------------------------- */

.wd-mobile-menu {
    display: none;
}


/* =========================================================
   فقط موبایل
   ========================================================= */

@media screen and (max-width: 767px) {

    /* -----------------------------------------------------
       نوار منوی موبایل
       ----------------------------------------------------- */

    .wd-mobile-menu {
        display: block;

        width: 100%;

        margin: 0 0 18px 0;

        direction: rtl;
        text-align: right;

        font-family:
            "Vazirmatn",
            "IRANSans",
            Tahoma,
            Arial,
            sans-serif;
    }


    /* -----------------------------------------------------
       دکمه منو
       ----------------------------------------------------- */

    .wd-mobile-menu-button {
        display: flex;

        align-items: center;
        justify-content: space-between;

        width: 100%;

        min-height: 48px;

        padding: 10px 15px;

        background: #ffffff;

        border: 1px solid #dfe7e5;
        border-right: 4px solid #168477;

        border-radius: 9px;

        color: #11695f;

        font-size: 15px;
        font-weight: bold;

        line-height: 1.8;

        cursor: pointer;

        box-shadow:
            0 2px 10px rgba(20,60,55,0.05);

        transition:
            background 0.15s ease,
            border-color 0.15s ease;
    }


    .wd-mobile-menu-button:hover,
    .wd-mobile-menu-button:focus {
        background: #f5faf8;
        border-color: #168477;
        outline: none;
    }


    /* آیکون همبرگری */

    .wd-mobile-menu-icon {
        display: inline-flex;

        align-items: center;
        justify-content: center;

        width: 32px;
        height: 32px;

        margin-left: 8px;

        background: #edf7f4;

        border-radius: 7px;

        color: #168477;

        font-size: 20px;
        line-height: 1;
    }


    /* فلش */

    .wd-mobile-menu-arrow {
        font-size: 15px;

        color: #78909c;

        transition:
            transform 0.2s ease;
    }


    .wd-mobile-menu.is-open
    .wd-mobile-menu-arrow {
        transform: rotate(180deg);
    }


    /* -----------------------------------------------------
       محتوای منو
       ----------------------------------------------------- */

    .wd-mobile-menu-content {
        display: none;

        margin-top: 7px;

        padding: 7px;

        background: #ffffff;

        border: 1px solid #dfe7e5;

        border-radius: 9px;

        box-shadow:
            0 4px 16px rgba(20,60,55,0.07);
    }


    .wd-mobile-menu.is-open
    .wd-mobile-menu-content {
        display: block;
    }


    /* -----------------------------------------------------
       لینک‌های منو
       ----------------------------------------------------- */

    .wd-mobile-menu-content a {
        display: block;

        width: 100%;

        padding: 11px 13px;

        margin: 2px 0;

        border-radius: 7px;

        color: #37474f !important;

        font-size: 15px;

        font-weight: normal;

        line-height: 1.8;

        text-decoration: none !important;

        transition:
            background 0.15s ease,
            color 0.15s ease;
    }


    .wd-mobile-menu-content a:hover,
    .wd-mobile-menu-content a:focus {
        background: #f1f8f6;

        color: #11695f !important;
    }


    /* -----------------------------------------------------
       لینک فعال
       ----------------------------------------------------- */

    .wd-mobile-menu-content a.wd-mobile-active {
        background: #edf7f4;

        color: #11695f !important;

        font-weight: bold;
    }


    /* -----------------------------------------------------
       جداکننده
       ----------------------------------------------------- */

    .wd-mobile-menu-divider {
        height: 1px;

        margin: 7px 10px;

        background: #e7eeec;
    }


    /* -----------------------------------------------------
       گروه اصلی
       ----------------------------------------------------- */

    .wd-mobile-menu-title {
        padding: 7px 13px 5px;

        color: #78909c;

        font-size: 11px;

        font-weight: bold;

        line-height: 1.8;
    }

}