לדלג לתוכן

מדיה ויקי:Gadget-FlowDeluxeLocal.js

מתוך צפונות ויקי

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
// Created by User:FlowDeluxe from frwiki and localized here.
// Documentation complète : https://www.mediawiki.org/wiki/Help:Structured_Discussions/FlowDeluxe
$(function() {
	var flowDeluxeIndentationColors = typeof window.flowDeluxeIndentationColors !== 'undefined' ?
		window.flowDeluxeIndentationColors : true;
	var flowDeluxeButtonsInline = typeof window.flowDeluxeButtonsInline !== 'undefined' ?
		window.flowDeluxeButtonsInline : true;
	
	function switchColor(color) {
		if (color == '#e8f4ff')
		   	return 'white';
		else
			return '#e8f4ff';
	}
	
	function indentPostWithColors() {
		var posts = $('.flow-post-main');
//		var color;
		var colored = false;
		
		for(var i=0, len=posts.length; i<len; i++) {
			if (colored)
				$(posts[[i]]).addClass('flow-color-indent');
			else
				$(posts[[i]]).removeClass('flow-color-indent');
			colored = !colored;
//			color = switchColor(color);
//			posts[[i]].style.backgroundColor = color;
		}
	}
	
	function buttonsInline() {
	   var elements = document.getElementsByClassName('flow-list');
	   
	   for(var i=0, len=elements.length; i<len-1; i++) {
		   	if(elements[i].className.indexOf("moved-flow-list") < 0 &&
		   			elements[i].innerHTML.indexOf("flow-ui-summarize-topic-link") > 0 ) {
		   		var parentItem = elements[i].parentElement;
				var grandParentItem = parentItem.parentElement;
				grandParentItem.insertBefore(elements[i],null);
				elements[i].className = elements[i].className + " moved-flow-list";
				elements[i].style.fontSize= "13px";
				
				var sections = elements[i].getElementsByTagName( "section" );
				for(var j=0; j<sections.length; j++) {
					sections[j].style.display="inline";
				}
				
				var li = elements[i].getElementsByTagName( "li" );
				for(j=0; j<li.length; j++) {
					li[j].style.display="inline";
					li[j].getElementsByTagName("a")[0].style.paddingLeft="10px";
					li[j].getElementsByTagName("a")[0].style.paddingRight="0";
				}
				
				parentItem.remove();
		   }
	   }
	}
	
	function applyChanges() {
	    if(flowDeluxeIndentationColors)
	     indentPostWithColors();
	    if(flowDeluxeButtonsInline)
	     buttonsInline();
	    setTimeout(applyChanges,2000);
	}
	
	if (document.getElementsByClassName('flow-component').length) {
	  applyChanges();
	}
})();