۸٬۱۶۰
ویرایش
Nazarzadeh (بحث | مشارکتها) بدون خلاصۀ ویرایش |
Nazarzadeh (بحث | مشارکتها) (خنثیسازی نسخهٔ 56823 از Nazarzadeh (بحث)) برچسب: خنثیسازی |
||
(۲۹ نسخهٔ میانیِ ایجادشده توسط همین کاربر نشان داده نشد) | |||
خط ۱۴۷: | خط ۱۴۷: | ||
*/ | */ | ||
var collapseCaption = ' | var collapseCaption = 'بسته'; | ||
var expandCaption = ' | var expandCaption = 'باز'; | ||
// Set up the words in your language | // Set up the words in your language | ||
خط ۴۴۹: | خط ۴۴۹: | ||
/* اضافه کردن تیتر برای یادداشت ها */ | /* اضافه کردن تیتر برای یادداشت ها */ | ||
$( function() { | $( function() { | ||
if($('#reflist-notes . | if($('#reflist-notes .references').text().length>10) { | ||
$('#reflist-notes').before('<h2>یادداشتها</h2>'); | $('#reflist-notes').before('<h2>یادداشتها</h2>'); | ||
} | } | ||
}); | }); | ||
/* sidebar tools */ | |||
(function( $, undefined ) { | |||
"use strict"; | |||
/** | |||
* Whether the web browser is Internet Explorer before version 9. | |||
*/ | |||
var isOldIE = false; | |||
/** | |||
* The text direction of the page. | |||
*/ | |||
var dir = "ltr"; | |||
/** | |||
* The current (or default) state of the sidebar. | |||
*/ | |||
var state = "collapsed"; | |||
/** | |||
* A cache of jQuery objects. | |||
*/ | |||
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. | |||
* If there is no item in storage, this function does nothing. | |||
*/ | |||
function loadState() { | |||
state = ( window.sessionStorage && sessionStorage.getItem("sidebarToggle") ) || | |||
( window.localStorage && localStorage.getItem("sidebarToggle") ) || | |||
state; | |||
} | |||
/** | |||
* Saves the current state in both sessionStorage and localStorage. | |||
*/ | |||
function saveState() { | |||
if ( window.sessionStorage ) { | |||
sessionStorage.setItem( "sidebarToggle", state ); | |||
} | |||
if ( window.localStorage ) { | |||
localStorage.setItem( "sidebarToggle", state ); | |||
} | |||
} | |||
/** | |||
* Reacts to a click on the "Toggle sidebar" button. | |||
*/ | |||
function toggle() { | |||
if ( state === "collapsed" ) { | |||
expand( 400 ); | |||
} else { | |||
collapse( 400 ); | |||
} | |||
//saveState(); | |||
} | |||
/** | |||
* Collapses the sidebar. | |||
* @param duration {mixed} Animation duration passed to jQuery. | |||
*/ | |||
function collapse( duration ) { | |||
var animations = { | |||
mwPanelIE: {}, | |||
mwPanelNonIE: {opacity: 0}, | |||
notSidebar: {}, | |||
leftNavigation: {} | |||
}; | |||
animations.mwPanelIE[ flipCSSProp("left") ] = "-10em"; | |||
animations.mwPanelNonIE[ flipCSSProp("left") ] = "-10em"; | |||
animations.notSidebar[ flipCSSProp("margin-left") ] = 0; | |||
animations.leftNavigation[ flipCSSProp("left") ] = "1em"; | |||
if ( isOldIE ) { | |||
nodes.$mwPanel.animate( animations.mwPanelIE, duration, function() { | |||
nodes.$mwPanel.css( "visibility", "hidden"); | |||
}); | |||
} else { | |||
nodes.$mwPanel.animate( animations.mwPanelNonIE, duration, function() { | |||
nodes.$mwPanel.css( "visibility", "hidden"); | |||
}); | |||
} | |||
nodes.$notSidebar.animate( animations.notSidebar, duration, function() { | |||
nodes.$content.css( "background-image", "none" ); | |||
}); | |||
nodes.$leftNavigation.animate( animations.leftNavigation, duration); | |||
$("#collsidebar").css("transform", "rotate(180deg)"); | |||
state = "collapsed"; | |||
} | |||
/** | |||
* Expands the sidebar. | |||
* @param duration {mixed} Animation duration passed to jQuery. | |||
*/ | |||
function expand( duration ) { | |||
nodes.$mwPanel.css( "visibility", "" ); | |||
var animations = { | |||
mwPanelIE: {}, | |||
mwPanelNonIE: {opacity: 1}, | |||
notSidebar: {}, | |||
leftNavigation: {} | |||
}; | |||
animations.mwPanelIE[ flipCSSProp("left") ] = "-0.01em"; | |||
animations.mwPanelNonIE[ flipCSSProp("left") ] = 0; | |||
animations.notSidebar[ flipCSSProp("margin-left") ] = "11em"; | |||
animations.leftNavigation[ flipCSSProp("left") ] = "10em"; | |||
if ( isOldIE ) { | |||
nodes.$mwPanel.animate( animations.mwPanelIE, duration, function () { | |||
nodes.$mwPanel.css( flipCSSProp("left"), "0em" ); | |||
}); | |||
} else { | |||
nodes.$mwPanel.animate( animations.mwPanelNonIE, duration ); | |||
} | |||
nodes.$content.css( "background-image", "" ); | |||
nodes.$notSidebar.animate( animations.notSidebar, duration ); | |||
nodes.$leftNavigation.animate( animations.leftNavigation, duration ); | |||
$("#collsidebar").css("transform", "rotate(0deg)"); | |||
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. | |||
*/ | |||
function ready() { | |||
// Populate jQuery object cache. | |||
nodes.$mwPanel = $("#mw-panel"); | |||
nodes.$content = $("#content"); | |||
nodes.$notSidebar = $("#content, #mw-head-base, #footer"); | |||
nodes.$leftNavigation = $("#left-navigation"); | |||
// Show the toggle tab. | |||
$("<a class='sidebarbottons' id='totop'></a>") | |||
.prop( "title", "بازگشت به بالا" ) | |||
.click( totop ) | |||
.insertAfter("#mw-panel"); | |||
/*$("<a class='sidebarbottons' id='collsidebar'></a>") | |||
.prop( "title", "تغییر وضعیت فهرست سمت راست" ) | |||
.click( toggle ) | |||
.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"); | |||
/* | |||
// Respect the saved state. | |||
if ( state === "collapsed" ) { | |||
collapse( 0 ); | |||
} | |||
*/ | |||
} | |||
/** | |||
* Initialization code | |||
*/ | |||
function main() { | |||
if ( mw.config.get("skin") !== "vector-2022" ) { | |||
return; | |||
} | |||
// Load translations and saved state. | |||
dir = document.documentElement.dir; | |||
//$.extend( msg, translations[document.documentElement.lang] ); | |||
loadState(); | |||
// Detect Internet Explorer <= 8 | |||
var profile = $.client.profile(); | |||
isOldIE = ( profile.name === "msie" && profile.versionNumber < 9 ); | |||
$(ready); | |||
} | |||
mw.loader.using( "jquery.client", main ); | |||
})( jQuery ); | |||
//mw.loader.load( '/view/مدیاویکی:Stickysidebar.js?action=raw&ctype=text/javascript' ); |