MediaWiki:Common.js: Difference between revisions

From WikiMSK

No edit summary
No edit summary
Line 16: Line 16:
}
}


$('body').on('focus','.ve-ce-surface', function(){
    for( let instance of veInstances){
        //find instance that own this sourface
        if( this == instance.target.getSurface().getView().$element.get(0)){
            //When editor loses focus, update the field input.
            instance.target.focusedWithoutUpdate = true;
}
}
});
/* Toggle advanced search checkboxes;. to use in conjunction with css to hide it if using semantic mediawiki */
/* Toggle advanced search checkboxes;. to use in conjunction with css to hide it if using semantic mediawiki */
/*
/*

Revision as of 19:53, 23 May 2022

/* Any JavaScript here will be loaded for all users on every page load. */
/*Remove the file size information on the gallery image for dynamicpagelist*/
	var galleryText = document.querySelectorAll('.gallerytext');
	var linkList = [];
	
	for (i = 0; i < galleryText.length; i++) {
	var pageLink = galleryText[i].innerHTML;
	var endLinkIndex = pageLink.indexOf("</a>");
	pageLink = pageLink.slice(0,endLinkIndex);
    pageLink += "</a></p>";
    linkList.push(pageLink);
	}
    
    for (i = 0; i < galleryText.length; i++) {
    document.querySelectorAll('.gallerytext')[i].innerHTML = linkList[i];
	}

	$('body').on('focus','.ve-ce-surface', function(){
    	for( let instance of veInstances){
         //find instance that own this sourface
        	if( this == instance.target.getSurface().getView().$element.get(0)){
            //When editor loses focus, update the field input.
            	instance.target.focusedWithoutUpdate = true;
			}
		}
	});
/* Toggle advanced search checkboxes;. to use in conjunction with css to hide it if using semantic mediawiki */
/*
const advancedSearchToggle = document.createElement("li");
advancedSearchToggle.className = "advancedSearchToggle";
const newContent = document.createTextNode("˅");
advancedSearchToggle.appendChild(newContent);

const searchTabs = document.querySelector(".search-types ul");
searchTabs.appendChild(advancedSearchToggle);

advancedSearchToggle.addEventListener("click", function() {
  var advancedSearchBox = document.getElementById("mw-searchoptions");
  if (advancedSearchBox.style.display == "none") {
    advancedSearchBox.style.display = "block";
  } else {
    advancedSearchBox.style.display = "none";
  }
});
*/