No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
PurgeButtonText = 'Purge'; |
PurgeButtonText = 'Purge'; |
||
importScriptPage('PurgeButton/code.js', 'dev'); |
importScriptPage('PurgeButton/code.js', 'dev'); |
||
+ | |||
+ | |||
+ | |||
+ | |||
+ | $(document).bind('DOMSubtreeModified',function(){ |
||
+ | //console.log("now there are " + $('a').length + " links on this page."); |
||
+ | var editPageDialog = document.getElementById('EditPageDialog'); |
||
+ | if(editPageDialog){ |
||
+ | editPageDialog.style.width = "850px"; |
||
+ | |||
+ | var editPageDialog_h1 = editPageDialog.getElementsByTagName("h1")[0]; |
||
+ | editPageDialog_h1.style.marginTop = "0px"; |
||
+ | editPageDialog_h1.style.marginBottom = "0px"; |
||
+ | |||
+ | var previewDiv = getElementsByClass2(editPageDialog, 'div', 'ArticlePreview'); |
||
+ | //var currentHeight = previewDiv.css('height').replace("px", ""); |
||
+ | var currentHeight = getStyle(previewDiv, 'height'); |
||
+ | var newHeight = cssPxValueText(currentHeight) + 200; |
||
+ | alert('currentHeight: "' + currentHeight + '" newHeight: "' + newHeight + '"'); |
||
+ | previewDiv.style.height = newHeight + 'px'; |
||
+ | } |
||
+ | }) |
||
+ | |||
+ | function getElementsByClass2(elementName, tagname, tclass){ |
||
+ | var itemsfound = new Array(); |
||
+ | var elements = elementName.getElementsByTagName(tagname); |
||
+ | for(var i=0;i<elements.length;i++){ |
||
+ | if(hasClass(elements[i], tclass)){ |
||
+ | itemsfound.push(elements[i]); |
||
+ | } |
||
+ | } |
||
+ | return itemsfound; |
||
+ | } |
||
+ | |||
+ | function getStyle(el,styleProp) |
||
+ | { |
||
+ | var x = document.getElementById(el); |
||
+ | if (x.currentStyle) |
||
+ | var y = x.currentStyle[styleProp]; |
||
+ | else if (window.getComputedStyle) |
||
+ | var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); |
||
+ | return y; |
||
+ | } |
||
+ | function ConvertCssPxToInt(cssPxValueText) { |
||
+ | |||
+ | // Set valid characters for numeric number. |
||
+ | var validChars = "0123456789."; |
||
+ | |||
+ | // If conversion fails return 0. |
||
+ | var convertedValue = 0; |
||
+ | |||
+ | // Loop all characters of |
||
+ | for (i = 0; i < cssPxValueText.length; i++) { |
||
+ | |||
+ | // Stop search for valid numeric characters, when a none numeric number is found. |
||
+ | if (validChars.indexOf(cssPxValueText.charAt(i)) == -1) { |
||
+ | |||
+ | // Start conversion if at least one character is valid. |
||
+ | if (i > 0) { |
||
+ | // Convert validnumbers to int and return result. |
||
+ | convertedValue = parseInt(cssPxValueText.substring(0, i)); |
||
+ | return convertedValue; |
||
+ | } |
||
+ | } |
||
+ | } |
||
+ | |||
+ | return convertedValue; |
||
+ | } |
Revision as of 10:47, 14 December 2011
PurgeButtonText = 'Purge';
importScriptPage('PurgeButton/code.js', 'dev');
$(document).bind('DOMSubtreeModified',function(){
//console.log("now there are " + $('a').length + " links on this page.");
var editPageDialog = document.getElementById('EditPageDialog');
if(editPageDialog){
editPageDialog.style.width = "850px";
var editPageDialog_h1 = editPageDialog.getElementsByTagName("h1")[0];
editPageDialog_h1.style.marginTop = "0px";
editPageDialog_h1.style.marginBottom = "0px";
var previewDiv = getElementsByClass2(editPageDialog, 'div', 'ArticlePreview');
//var currentHeight = previewDiv.css('height').replace("px", "");
var currentHeight = getStyle(previewDiv, 'height');
var newHeight = cssPxValueText(currentHeight) + 200;
alert('currentHeight: "' + currentHeight + '" newHeight: "' + newHeight + '"');
previewDiv.style.height = newHeight + 'px';
}
})
function getElementsByClass2(elementName, tagname, tclass){
var itemsfound = new Array();
var elements = elementName.getElementsByTagName(tagname);
for(var i=0;i<elements.length;i++){
if(hasClass(elements[i], tclass)){
itemsfound.push(elements[i]);
}
}
return itemsfound;
}
function getStyle(el,styleProp)
{
var x = document.getElementById(el);
if (x.currentStyle)
var y = x.currentStyle[styleProp];
else if (window.getComputedStyle)
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
return y;
}
function ConvertCssPxToInt(cssPxValueText) {
// Set valid characters for numeric number.
var validChars = "0123456789.";
// If conversion fails return 0.
var convertedValue = 0;
// Loop all characters of
for (i = 0; i < cssPxValueText.length; i++) {
// Stop search for valid numeric characters, when a none numeric number is found.
if (validChars.indexOf(cssPxValueText.charAt(i)) == -1) {
// Start conversion if at least one character is valid.
if (i > 0) {
// Convert validnumbers to int and return result.
convertedValue = parseInt(cssPxValueText.substring(0, i));
return convertedValue;
}
}
}
return convertedValue;
}