Link to home
Start Free TrialLog in
Avatar of jeremyBass26
jeremyBass26Flag for United States of America

asked on

call a 'nested' function from outside

Hello, I'm sure this is easier then I'm thinking but ... what I need to do is fire the doSomething();  and or the "$(window).bind('resize', ...etc" functions out side of the "$('[class^=Round_gen]').filter(function() {... etc"

... right now they are inside so I could get them working... but they loop every time.... I want to do them all at once... just not sure how to call them for out side....

thanks for the help...
jeremyBass
$(document).ready(function() {
    var SORUCE = '/rounded_rectangle_r.swf';
    $('.Round_gen53').attr('rel', '' + SORUCE + ':::transparent:45:0');
 
    $('[class^=Round_gen]').filter(function() {
        return /Round_gen[0-9]+/.test($(this).attr('class'));
    }).each(function() {
        $(this).each(function() {
            var $this = $(this);
            var params = $(this).attr('rel').split(':');
            $(this).flash({
                flashvars: {
                    rounded: ['' + params[4] + ''],
                    stroke_w: ['' + params[5] + ''].join(' ')
                }
            },
            {
                version: 8
            },
            function(htmlOptions) {
                var self = this;
                $this.css("padding-right", "" + params[11] + "px");
                $this.css("position", "relative");
                htmlOptions.width = self.offsetWidth;
                htmlOptions.src = params[0];
                htmlOptions.wmode = params[3];
                this.innerHTML = '<div class="" style="">' + this.innerHTML + '</div>';
                htmlOptions.height = this.firstChild.offsetHeight;
                $this.addClass('').prepend($.fn.flash.transform(htmlOptions));
                $(this).contents("embed").not(".readME").addClass("sizeME");
                function doSomething() {  //// move this out????
                    var NEWheight = self.childNodes[1].offsetHeight;
                    var NEWwidth = self.childNodes[1].offsetWidth;
                    $this.contents(".sizeME").css("height", NEWheight + 'px');
                    $this.contents(".sizeME").css("width", (NEWwidth + 20) + 'px');
                    $this.css("height", NEWheight + 'px');
                    var SAheight = $('.thrColLiqHdr').innerHeight();
                    //alert (SAheight);
                    $('.traction').css("height", SAheight + 'px');
                };
                var resizeTimer = null; //// move this out????
                $(window).bind('resize', //// move this out????
                function() {
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(doSomething, 3);
                });
		doSomething(); //// move this out????
            });
        });
    });
var SAheight = $('.thrColLiqHdr').innerHeight();
	//alert (SAheight);
		$('.SA').prepend('<img class="traction" src="images/blank.gif" style="position:absolute; left:0px; top:0px; width:100%; height:'+ SAheight +';">');
 
});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Tomarse111
Tomarse111
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jeremyBass26

ASKER

Well, yes it and no... I was pretty sure that was how it worked... but never read it... I guess I meant to say it was how could it be reworked to have the doSomething() function be out side so I may run the core of the whole function by it's self but also run the doSomething() function which alters what the core function did... hope that made sense...

I guess I'm just looking for a way refactor this function so it uses as little cpu cycles as possible...
thanks for the help...
jeremyBass
Thanks for responding