مدیاویکی:Gadget-sidebarToggle.js: تفاوت میان نسخهها
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
(۲۳ نسخهٔ میانیِ ایجادشده توسط همین کاربر نشان داده نشد) | |||
خط ۱: | خط ۱: | ||
(function( $, undefined ) { | (function( $, undefined ) { | ||
"use strict"; | "use strict"; | ||
/** | /** | ||
خط ۳۸: | خط ۱۱: | ||
* The text direction of the page. | * The text direction of the page. | ||
*/ | */ | ||
var dir = " | var dir = "ltr"; | ||
/** | /** | ||
خط ۴۹: | خط ۲۲: | ||
*/ | */ | ||
var nodes = {}; | var nodes = {}; | ||
/** | |||
* Equivalent CSS property names for RTL pages. | |||
*/ | |||
var cssRTLProps = { | |||
"left": "right", | |||
"margin-left": "margin-right" | |||
}; | |||
/** | |||
* Changes the CSS property name as appropriate for the page's text direction. | |||
* @param prop {string} The CSS property name to be changed. | |||
*/ | |||
function flipCSSProp(prop) { | |||
if ( dir === "rtl" && cssRTLProps[prop] ) { | |||
return cssRTLProps[prop]; | |||
} | |||
return prop; | |||
} | |||
/** | /** | ||
* Loads the current state from sessionStorage (preferred) or localStorage. | * Loads the current state from sessionStorage (preferred) or localStorage. | ||
خط ۹۴: | خط ۸۶: | ||
* @param duration {mixed} Animation duration passed to jQuery. | * @param duration {mixed} Animation duration passed to jQuery. | ||
*/ | */ | ||
/* | |||
function collapse( duration ) { | function collapse( duration ) { | ||
خط ۱۰۰: | خط ۹۳: | ||
mwPanelNonIE: {opacity: 0}, | mwPanelNonIE: {opacity: 0}, | ||
notSidebar: {}, | notSidebar: {}, | ||
leftNavigation: {} | leftNavigation: {} | ||
}; | }; | ||
animations.mwPanelIE[ " | animations.mwPanelIE[ flipCSSProp("left") ] = "-10em"; | ||
animations.mwPanelNonIE[ " | animations.mwPanelNonIE[ flipCSSProp("left") ] = "-10em"; | ||
animations.notSidebar[ "margin- | animations.notSidebar[ flipCSSProp("margin-left") ] = 0; | ||
animations.leftNavigation[ " | animations.leftNavigation[ flipCSSProp("left") ] = "1em"; | ||
if ( isOldIE ) { | if ( isOldIE ) { | ||
nodes.$mwPanel.animate( animations.mwPanelIE, duration, function() { | nodes.$mwPanel.animate( animations.mwPanelIE, duration, function() { | ||
خط ۱۲۶: | خط ۱۱۶: | ||
nodes.$leftNavigation.animate( animations.leftNavigation, duration); | nodes.$leftNavigation.animate( animations.leftNavigation, duration); | ||
$("#collsidebar").css("transform", "rotate(180deg)"); | |||
state = "collapsed"; | state = "collapsed"; | ||
} | } | ||
/** | /** | ||
* Expands the sidebar. | * Expands the sidebar. | ||
* @param duration {mixed} Animation duration passed to jQuery. | * @param duration {mixed} Animation duration passed to jQuery. | ||
function expand( duration ) { | function expand( duration ) { | ||
خط ۱۴۶: | خط ۱۳۸: | ||
}; | }; | ||
animations.mwPanelIE[ " | animations.mwPanelIE[ flipCSSProp("left") ] = "-0.01em"; | ||
animations.mwPanelNonIE[ " | animations.mwPanelNonIE[ flipCSSProp("left") ] = 0; | ||
animations.notSidebar[ "margin- | animations.notSidebar[ flipCSSProp("margin-left") ] = "11em"; | ||
animations.leftNavigation[ " | animations.leftNavigation[ flipCSSProp("left") ] = "10em"; | ||
if ( isOldIE ) { | if ( isOldIE ) { | ||
nodes.$mwPanel.animate( animations.mwPanelIE, duration, function () { | nodes.$mwPanel.animate( animations.mwPanelIE, duration, function () { | ||
nodes.$mwPanel.css( " | nodes.$mwPanel.css( flipCSSProp("left"), "0em" ); | ||
}); | }); | ||
} else { | } else { | ||
خط ۱۵۹: | خط ۱۵۱: | ||
} | } | ||
nodes.$content.css( "background-image", "" ); | |||
nodes.$notSidebar.animate( animations.notSidebar, duration ); | nodes.$notSidebar.animate( animations.notSidebar, duration ); | ||
nodes.$leftNavigation.animate( animations.leftNavigation, duration ); | nodes.$leftNavigation.animate( animations.leftNavigation, duration ); | ||
$("#collsidebar").css("transform", "rotate(0deg)"); | |||
state = "expanded"; | state = "expanded"; | ||
} | } | ||
*/ | |||
function totop() { | |||
$('html, body').animate({ scrollTop: 0 }, 500); | |||
} | |||
function fontsizeup() { | |||
var fontSize = parseInt($('p').css("font-size")); | |||
fontSize = fontSize + 3 + "px"; | |||
$('p').css({'font-size':fontSize}); | |||
} | |||
function fontsizedown() { | |||
var fontSize = parseInt($('p').css("font-size")); | |||
fontSize = fontSize - 3 + "px"; | |||
$('p').css({'font-size':fontSize}); | |||
} | |||
/** | /** | ||
* Called when the DOM is ready for manipulation. | * Called when the DOM is ready for manipulation. | ||
خط ۱۷۸: | خط ۱۸۹: | ||
// Show the toggle tab. | // Show the toggle tab. | ||
$("< | //$("<a class='sidebarbottons' id='collsidebar'></a>") | ||
.prop( "title", | // .prop( "title", "تغییر وضعیت فهرست سمت راست" ) | ||
//. | // .click( toggle ) | ||
.click( | // .insertAfter("#mw-panel"); | ||
$("<a class='sidebarbottons' id='totop'></a>") | |||
.prop( "title", "بازگشت به بالا" ) | |||
.click( totop ) | |||
.insertAfter("#mw-panel"); | |||
$("<a class='sidebarbottons' id='fontsizeup'></a>") | |||
.prop( "title", "افزایش اندازه قلم" ) | |||
.click( fontsizeup ) | |||
.insertAfter("#mw-panel"); | |||
$("<a class='sidebarbottons' id='fontsizedown'></a>") | |||
.prop( "title", "کاهش اندازه قلم" ) | |||
.click( fontsizedown ) | |||
.insertAfter("#mw-panel"); | .insertAfter("#mw-panel"); | ||
/* | |||
// Respect the saved state. | // Respect the saved state. | ||
if ( state === "collapsed" ) { | if ( state === "collapsed" ) { | ||
collapse( 0 ); | collapse( 0 ); | ||
} | } | ||
*/ | |||
} | } | ||
خط ۲۰۲: | خط ۲۲۹: | ||
// Load translations and saved state. | // Load translations and saved state. | ||
dir = document.documentElement.dir; | dir = document.documentElement.dir; | ||
$.extend( msg, translations[document.documentElement.lang] ); | //$.extend( msg, translations[document.documentElement.lang] ); | ||
loadState(); | loadState(); | ||
خط ۲۱۴: | خط ۲۴۱: | ||
mw.loader.using( "jquery.client", main ); | mw.loader.using( "jquery.client", main ); | ||
})( jQuery ); | })( jQuery ); |