MediaWiki:Common.js

From DominionStrategy Wiki
(Difference between revisions)
Jump to: navigation, search
m
 
Line 36: Line 36:
  
 
// Register adding portlets
 
// Register adding portlets
add('Help:Council_Room','ca-new-section')
+
add('DominionStrategy_Wiki:Council_Room','ca-new-section')
 
}
 
}
 
$(document).ready( add_portlet_links )
 
$(document).ready( add_portlet_links )

Latest revision as of 08:29, 18 November 2012

/* Any JavaScript here will be loaded for all users on every page load. */

// ADDING PORTLET LINKS
function add_portlet_links(){
	var PortletLinks = {
	/*
		PortletLinks[ string linkID ] = Array(
			boolean left,     // true if added on the left-side, false if right
			string label,
			string tooltip,
			string href,
			string accesskey,
			integer position  // insert position, counting from left
		)
	*/
		"ca-new-section":[false,"New Section","Add a new section","?action=edit&section=new","+",3]
	}

	/*
		Add a portlet link to page
		PARAMS
			regexp/string page: RegExp or exact match string of page titles to add portlet link
			string id         : linkID of the added portlet link
	*/

	function add(page,id){
		if(typeof page == "string"){
			if(wgPageName != page) return false
		}else if(!page.test(wgPageName)) return false
		
		var link = PortletLinks[id]
		if(!link) return false
		var vector = link[0] ? 'p-namespaces' : 'p-views'
		return mw.util.addPortletLink( vector , link[3] , link[1] , id , link[2] , link[4] , $('#'+vector+' li')[link[5]-1] )
	}

	// Register adding portlets
	add('DominionStrategy_Wiki:Council_Room','ca-new-section')
}
$(document).ready( add_portlet_links )
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox