MediaWiki:Common.js

From open-support.info

(Difference between revisions)
Jump to: navigation, search
m
m
 
(17 intermediate revisions not shown)
Line 1: Line 1:
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
-
if (!document.getElementsByClassName) {
+
/*
-
  function getElementsByClassName(searchClass) {
+
function getElementsByClass(searchClass) {
-
    if (document.all) {
+
  if (document.getElementsByClassName) {
-
      var classElements = new Array();
+
    return document.getElementsByClassName(searchClass);
-
      var allElements = document.all;
+
  } else if (document.all) {
-
      for (i = 0, j = 0; i < allElements.length; i++) {
+
    var classElements = new Array();
-
        if (allElements[i].className == searchClass) {
+
    var allElements = document.all;
-
          classElements[j] = allElements[i];
+
    for (i = 0, j = 0; i < allElements.length; i++) {
-
          j++;
+
      if (allElements[i].className == searchClass) {
-
        }
+
        classElements[j] = allElements[i];
-
      }     
+
        j++;
-
    } else if (document.getElementsByTagName) {
+
      }
-
      var classElements = new Array();
+
    }     
-
      var allElements = document.getElementsByTagName("*");
+
  } else if (document.getElementsByTagName) {
-
      for (i = 0, j = 0; i < allElements.length; i++) {
+
    var classElements = new Array();
-
        if (allElements[i].className == searchClass) {
+
    var allElements = document.getElementsByTagName("*");
-
          classElements[j] = allElements[i];
+
    for (i = 0, j = 0; i < allElements.length; i++) {
-
          j++;
+
      if (allElements[i].className == searchClass) {
-
        }
+
        classElements[j] = allElements[i];
-
      }         
+
        j++;
-
    } else {
+
      }
-
      return;
+
    }         
-
    }
+
  } else {
-
     return classElements;
+
     return;
   }
   }
 +
  return classElements;
}
}
-
function resizeWidthMax() {
+
function resizeTdWidthMax() {
-
   if(
+
   var elements = getElementsByClass("resizeTdWidthMax");
-
      document.getElementsByClassName &&
+
  for (var i=0; i<elements.length; i++) {
-
      document.getElementsByClassName('resizeWidthMax') &&
+
     var itemTd = elements[i];
-
      document.getElementsByClassName('resizeWidthMax').length > 0
+
    var itemTr = elements[i].parentNode;
-
  ) {
+
    var itemTable = itemTr.parentNode;
-
     var elements = document.getElementsByClassName('resizeWidthMax');
+
     alert (itemTd.clientWidth
-
     alert(elements.length);
+
          + "\n" + itemTr.clientWidth
 +
          + "\n" + itemTable.clientWidth
 +
          + "\n" + itemTable.parentNode.clientWidth
 +
          + "\n" + itemTable.parentNode.parentNode.clientWidth
 +
          + "\n" + itemTable.parentNode.parentNode.parentNode.clientWidth
 +
          );
   }
   }
}
}
-
addOnloadHook( resizeWidthMax );
+
addOnloadHook( resizeTdWidthMax );
-
 
+
*/
function createBookNavLink() {
function createBookNavLink() {
if (
if (
Line 55: Line 61:
document.getElementById('bookHeaderNavSrc') &&
document.getElementById('bookHeaderNavSrc') &&
document.getElementById('bookHeaderNavSrc').innerHTML &&
document.getElementById('bookHeaderNavSrc').innerHTML &&
-
document.getElementById('contentSub') &&
+
document.getElementById('contentSub') /* &&
-
document.getElementById('contentSub').innerHTML
+
document.getElementById('contentSub').innerHTML */
) {
) {

Latest revision as of 18:31, 21 April 2011

/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
/*
function getElementsByClass(searchClass) {
  if (document.getElementsByClassName) {
    return document.getElementsByClassName(searchClass);
  } else if (document.all) {
    var classElements = new Array();
    var allElements = document.all;
    for (i = 0, j = 0; i < allElements.length; i++) {
      if (allElements[i].className == searchClass) {
        classElements[j] = allElements[i];
        j++;
      }
    }    
  } else if (document.getElementsByTagName) {
    var classElements = new Array();
    var allElements = document.getElementsByTagName("*");
    for (i = 0, j = 0; i < allElements.length; i++) {
      if (allElements[i].className == searchClass) {
         classElements[j] = allElements[i];
         j++;
      }
    }        
  } else {
    return;
  }
  return classElements;
}

function resizeTdWidthMax() {
  var elements = getElementsByClass("resizeTdWidthMax");
  for (var i=0; i<elements.length; i++) {
    var itemTd = elements[i];
    var itemTr = elements[i].parentNode;
    var itemTable = itemTr.parentNode;
    alert (itemTd.clientWidth
           + "\n" + itemTr.clientWidth
           + "\n" + itemTable.clientWidth
           + "\n" + itemTable.parentNode.clientWidth
           + "\n" + itemTable.parentNode.parentNode.clientWidth
           + "\n" + itemTable.parentNode.parentNode.parentNode.clientWidth
           );
  }
}
addOnloadHook( resizeTdWidthMax );
*/
function createBookNavLink() {
	if (
		document.getElementById &&
		document.getElementById('bodyContent') &&
		document.getElementById('bookFooterMargin')
	) {
		var bct = document.getElementById('bodyContent');
		var bfm = document.getElementById('bookFooterMargin');
		if ( bct.clientHeight < 350 ) {
			bfm.style.height = ( 350 + bfm.clientHeight - bct.clientHeight ) + "px";
		}
 	}
	if (
		document.getElementById &&
		document.getElementById('bookHeaderNavSrc') &&
		document.getElementById('bookHeaderNavSrc').innerHTML &&
		document.getElementById('contentSub') /* &&
		document.getElementById('contentSub').innerHTML */
	) {

		var curNode = document.getElementById('contentSub');
		var newNode = document.getElementById('bookHeaderNavSrc');
		if( ! curNode.innerHTML ) {
			curNode.innerHTML = '&nbsp;';
		}
		curNode.innerHTML = newNode.innerHTML + curNode.innerHTML;

	}
	if (
		document.getElementById &&
		document.getElementById('bookFooterNavSrc') &&
		document.getElementById('bookFooterNavSrc').innerHTML &&
		document.getElementById('catlinks') &&
		document.getElementById('catlinks').innerHTML &&
		document.createElement &&
		document.insertBefore
	) {
		var curNode = document.getElementById('catlinks');
		var newNode = document.createElement('div');
		newNode.id = 'bookFooter';
		newNode.innerHTML = document.getElementById('bookFooterNavSrc').innerHTML;
		newNode.style.margin        = '0px';
		newNode.style.padding       = '0px';
		newNode.style.verticalAlign = 'bottom';
		curNode.parentNode.insertBefore(newNode,curNode);
	}
}
addOnloadHook( createBookNavLink );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox