How to call a variable or function inside of another JavaScript function -
i using javascript spinner/loader project http://fgnass.github.io/spin.js/
i have code on jsfiddle here http://jsfiddle.net/jasondavis/9pbsr/ shows progress, may overkill functions have have stripped out non-relevent stuff post. if can me, please leave structure same way is.
now problem. library using has code show spinner
var spinner = new spinner(opts).spin(target);
the documentation says kill , hide spinner run stop
function on spinner
way code structured, not sure how access because keep getting errors
typeerror: cannot call method 'stop' of undefined
my end result able call , have stop/kill spinner...
zpanel.loader.hideloader()
here javascript js , html on jsfiddle http://jsfiddle.net/jasondavis/9pbsr/
please me zpanel.loader.hideloader()
function call zpanel.loader.buildspinner()
functions spinner.stop()
var zpanel = { init: function() { $(document).ready(function() { zpanel.loader.init(); }); }, loader: { init: function() { //bind zloader button click $('#button').click(function() { zpanel.loader.showloader(); }); $('#hidebutton').click(function() { zpanel.loader.hideloader(); }); }, showloader: function() { //show spinning loader $('#zloader_overlay').fadein('fast', function() { $("#zloader").show(); zpanel.loader.buildspinner(); }); }, hideloader: function() { //hide spinning loader $('#zloader_overlay').fadein('fast', function() { $("#zloader").hide(); // function not working yet //zpanel.loader.spinner('stop'); zpanel.loader.buildspinner.spinner.stop(); }); }, buildspinner: function() { var opts = { lines: 9, // number of lines draw length: 11, // length of each line width: 13, // line thickness radius: 40, // radius of inner circle corners: 0.4, // corner roundness (0..1) rotate: 0, // rotation offset color: '#000', // #rgb or #rrggbb speed: 1, // rounds per second trail: 60, // afterglow percentage shadow: false, // whether render shadow hwaccel: false, // whether use hardware acceleration classname: 'spinner', // css class assign spinner zindex: 2e9, // z-index (defaults 2000000000) top: 200, // top position relative parent in px left: 'auto' // left position relative parent in px }; var target = document.getelementbyid('zloader_content'); var spinner = new spinner(opts).spin(target); // need call spinner.stop() how function above name hideloader() }, } }; zpanel.init();
make spinner member of zpanel.
var zpanel = { spinner:null, init: function() { $(document).ready(function() { zpanel.loader.init(); }); }, loader: { init: function() { //bind zloader button click $('#button').click(function() { zpanel.loader.showloader(); }); $('#hidebutton').click(function() { zpanel.loader.hideloader(); }); }, showloader: function() { //show spinning loader $('#zloader_overlay').fadein('fast', function() { $("#zloader").show(); zpanel.loader.buildspinner(); }); }, hideloader: function() { //hide spinning loader $('#zloader_overlay').fadein('fast', function() { $("#zloader").hide(); zpanel.spinner.stop(); }); }, buildspinner: function() { var opts = { lines: 9, // number of lines draw length: 11, // length of each line width: 13, // line thickness radius: 40, // radius of inner circle corners: 0.4, // corner roundness (0..1) rotate: 0, // rotation offset color: '#000', // #rgb or #rrggbb speed: 1, // rounds per second trail: 60, // afterglow percentage shadow: false, // whether render shadow hwaccel: false, // whether use hardware acceleration classname: 'spinner', // css class assign spinner zindex: 2e9, // z-index (defaults 2000000000) top: 200, // top position relative parent in px left: 'auto' // left position relative parent in px }; var target = document.getelementbyid('zloader_content'); zpanel.spinner = new spinner(opts).spin(target); // need call spinner.stop() how function above name hideloader() }, } }; zpanel.init();
Comments
Post a Comment