By W.M. on
I use JS injector to add JS to my site. I have a particular function which is:
equalheight = function(container){
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function() {
$el = $(this);
$($el).height('auto')
topPostion = $el.position().top;
if (currentRowStart != topPostion) {
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.height();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
}
I want to load it on every page in my site and then call it locally at some nodes using CPN module.
The function can be called like this:
$( "div.some-class" ).each(function() {
var object = $( this ).find("p");
equalheight(object);
});
I don't want to re-declare it on each node. I want to define it globally and then access it everywhere.
Any clue how to do that? Thanks.
Comments
use old fashioned way? create
use old fashioned way? create custom.js , put the code there, load it via theme (drupal_add_js())?
--------------------------------------------------------------------------------------------------------
if you can use drupal why use others?
VicTheme.com
Thanks duckzland. I will try
Thanks duckzland. Worked perfectly :)