לדלג לתוכן

מדיה ויקי:Gadget-CustomSideBarLinks.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
תיקונים כדי שיעבוד טוב גם ב VECTOR + מוחק הערות לא רלוונטיות
מ 37 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-CustomSideBarLinks.js יובאו
 
(33 גרסאות ביניים של 5 משתמשים אינן מוצגות)
שורה 1: שורה 1:
// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// created by [[user:Yonidebest]] with some help from [[User:ערן]]
// created by [[user:Yonidebest]] with some help from [[User:ערן]]
$( function() {
function createCustomNav(linkstext) {
var skin = mw.config.get('skin');


var CustomSideBarLinksShowDefualt = false; // he who wishes the side bar to be visibale by default, set this to true.
        if (skin === 'monobook') {
        var aLink1 = $('<a href="#">הקישורים שלי</a>');


function navCustonToggle()
        aLink1.click(function(){
{
            $('#p-customBody1').toggle();
    var divBody = document.getElementById('p-customBody1');
            return false;
    if ( divBody.style.display == 'none' ) divBody.style.display = 'block'; // show content
        });
                                      else divBody.style.display = 'none';   // hide content
}


function createCustomNav(linkstext)
        var h3CustomTitle = $('<h3>').append(aLink1);
{
        var divCustomBody = $('<div>', { id: "p-customBody1"} ).toggle(!! window.customLinksOpen);
    var aLink1 = document.createElement('A');
        divCustomBody.html(linkstext);
    aLink1.appendChild(document.createTextNode('הקישורים שלי'));
        var navCustomMain = $('<div>').append(h3CustomTitle).append(divCustomBody);
    aLink1.href = 'javascript:navCustonToggle();';
        var pCom = $('#p-community');
        navCustomMain.addClass(pCom.attr('class'));
        divCustomBody.addClass(pCom.find('div').attr('class'));
        navCustomMain.insertBefore(pCom);


    var h5CustonTitle = document.createElement('H5');
            return;
    h5CustonTitle.appendChild(aLink1);
        } // else...
        var linksPortalName = 'myLinksPortal';
        var $div;
if (skin === 'vector' || skin === 'vector-2022'){
        $div = $('<nav>', { id: linksPortalName } )
        .addClass('mw-portlet vector-menu vector-menu-portal portal')
            .append($('<h3>').addClass('vector-menu-heading').text('הקישורים שלי'))
            .append($('<div>', {'class': 'vector-menu-content'}).html(linkstext));
} else {
        $div = $('<nav>', { id: linksPortalName } )
        .addClass('portal')
            .append($('<h3>').addClass('vector-menu-heading').text('הקישורים שלי'))
            .append($('<div>', {'class': 'body'}).html(linkstext));
}


    try { // for IE
        var $firstPortal = $('#p-navigation');
      var divCustonBody = document.createElement('<DIV ID="p-customBody1"></DIV>');
       
    } catch (e) { // for FF
        $firstPortal.after($div);
      var divCustonBody = document.createElement('DIV');
      divCustonBody.id = 'p-customBody1';
    };
    divCustonBody.innerHTML = linkstext;


    var navCustonMain = document.createElement('DIV');
        $( document ).trigger( 'new-portlet-link', [linksPortalName] );
    navCustonMain.appendChild(h5CustonTitle);
}
    navCustonMain.appendChild(divCustonBody);
 
     $.ajax({
     var pCom = document.getElementById('p-community');
            url: mw.util.wikiScript('index'),
    navCustonMain.className = pCom.className;
            data: {
    divCustonBody.className = pCom.getElementsByTagName('DIV')[0].className;
                title: new mw.Title(mw.config.get('wgUserName')+'/הקישורים שלי', mw.config.get('wgNamespaceIds').user).getPrefixedText(),
    pCom.parentNode.insertBefore (navCustonMain, pCom);
                action: 'render'
 
            },
    if ( !CustomSideBarLinksShowDefualt ) navCustonToggle();
            success: createCustomNav
}
     });
 
});
function initCustomNav()
{
    var a = sajax_init_object();
    a.open ('GET', wgServer + wgScript + '?title=%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:' + encodeURIComponent(wgUserName) + '/%D7%94%D7%A7%D7%99%D7%A9%D7%95%D7%A8%D7%99%D7%9D_%D7%A9%D7%9C%D7%99&action=render', true);
    a.onreadystatechange = function()
      {
        if ( a.readyState != 4 ) return;
        createCustomNav ( a.responseText );
      };
     a.send (null);
}
 
addOnloadHook ( initCustomNav );

גרסה אחרונה מ־07:26, 5 בדצמבר 2022

// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// created by [[user:Yonidebest]] with some help from [[User:ערן]]
$( function() {
	function createCustomNav(linkstext) {
		var skin = mw.config.get('skin');

        if (skin === 'monobook') {
	        var aLink1 = $('<a href="#">הקישורים שלי</a>');

	        aLink1.click(function(){
	            $('#p-customBody1').toggle();
	            return false;
	        });

	        var h3CustomTitle = $('<h3>').append(aLink1);
	        var divCustomBody = $('<div>', { id: "p-customBody1"} ).toggle(!! window.customLinksOpen);
	        divCustomBody.html(linkstext);
	        var navCustomMain = $('<div>').append(h3CustomTitle).append(divCustomBody);
	        var pCom = $('#p-community');
	        navCustomMain.addClass(pCom.attr('class'));
	        divCustomBody.addClass(pCom.find('div').attr('class'));
	        navCustomMain.insertBefore(pCom);

            return;
        } // else...
        var linksPortalName = 'myLinksPortal';
        var $div;
		if (skin === 'vector' || skin === 'vector-2022'){
	        $div = $('<nav>', { id: linksPortalName } )
	        	.addClass('mw-portlet vector-menu vector-menu-portal portal')
	            .append($('<h3>').addClass('vector-menu-heading').text('הקישורים שלי'))
	            .append($('<div>', {'class': 'vector-menu-content'}).html(linkstext));
		} else {
	        $div = $('<nav>', { id: linksPortalName } )
        	.addClass('portal')
            .append($('<h3>').addClass('vector-menu-heading').text('הקישורים שלי'))
            .append($('<div>', {'class': 'body'}).html(linkstext));
		}

        var $firstPortal = $('#p-navigation');
        
        $firstPortal.after($div);

        $( document ).trigger( 'new-portlet-link', [linksPortalName] );
	}
 
    $.ajax({
            url: mw.util.wikiScript('index'),
            data: {
                title: new mw.Title(mw.config.get('wgUserName')+'/הקישורים שלי', mw.config.get('wgNamespaceIds').user).getPrefixedText(),
                action: 'render'
            },
            success: createCustomNav
    });
});