לדלג לתוכן

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

מתוך צפונות ויקי
מאין תקציר עריכה
מ שכתובון
שורה 1: שורה 1:
// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// created by [[user:Yonidebest]] with some help from [[User:ערן]]
// created by [[user:Yonidebest]] with some help from [[User:ערן]]
var CustomSideBarLinksShowDefualt = false; // he who wishes the side bar to be visibale by default, set this to true.
function navCustonToggle()
{
    var divBody = document.getElementById('p-customBody1');
    if ( divBody.style.display == 'none' ) divBody.style.display = 'block';  // show content
                                      else divBody.style.display = 'none';  // hide content
}


$(document).ready(function(){
$(document).ready(function(){
function createCustomNav(linkstext)
function createCustomNav(linkstext)
{
{
     var aLink1 = document.createElement('A');
     var aLink1 = $('<a href="#">הקישורים שלי</a>');
     aLink1.appendChild(document.createTextNode('הקישורים שלי'));
     aLink1.click(function(){
     aLink1.href = 'javascript:navCustonToggle();';
        $('#p-customBody1').toggle();
 
        return false;
     var h5CustonTitle = document.createElement('H5');
     });
    h5CustonTitle.appendChild(aLink1);
     var h5CustonTitle = $('<h5>').append(aLink1);
 
     var divCustonBody = $('<div id="p-customBody1" style="display:none;"></div>');
     try { // for IE
     divCustonBody.html(linkstext);
      var divCustonBody = document.createElement('<DIV ID="p-customBody1"></DIV>');
     var navCustonMain = $('<div></div>').append(h5CustonTitle).append(divCustonBody);
     } catch (e) { // for FF
     var pCom = $('#p-community');
      var divCustonBody = document.createElement('DIV');
     navCustonMain.addClass(pCom.attr('class'));
      divCustonBody.id = 'p-customBody1';
     divCustonBody.addClass(pCom.find('div').attr('class'));
    };
     navCustonMain.insertBefore(pCom);  
    divCustonBody.innerHTML = linkstext;
 
     var navCustonMain = document.createElement('DIV');
    navCustonMain.appendChild(h5CustonTitle);
    navCustonMain.appendChild(divCustonBody);
 
     var pCom = document.getElementById('p-community');
     navCustonMain.className = pCom.className;
     divCustonBody.className = pCom.getElementsByTagName('DIV')[0].className;
     pCom.parentNode.insertBefore (navCustonMain, pCom);
 
    if ( !CustomSideBarLinksShowDefualt ) navCustonToggle();
}
}



גרסה מ־20:43, 4 באוקטובר 2011

// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// created by [[user:Yonidebest]] with some help from [[User:ערן]]

$(document).ready(function(){
function createCustomNav(linkstext)
{
    var aLink1 = $('<a href="#">הקישורים שלי</a>');
    aLink1.click(function(){
        $('#p-customBody1').toggle();
        return false;
    });
    var h5CustonTitle = $('<h5>').append(aLink1);
    var divCustonBody = $('<div id="p-customBody1" style="display:none;"></div>');
    divCustonBody.html(linkstext);
    var navCustonMain = $('<div></div>').append(h5CustonTitle).append(divCustonBody);
    var pCom = $('#p-community');
    navCustonMain.addClass(pCom.attr('class'));
    divCustonBody.addClass(pCom.find('div').attr('class'));
    navCustonMain.insertBefore(pCom); 
}

	$.ajax({ url: mw.util.wikiScript('index'), data: {
		title: 'משתמש:'+mw.user.name()+'/הקישורים שלי',
		action: 'render'
	}, success: createCustomNav
	});
});