/* Copyright jQuery4u.com - Script for hooking up 50 function demo buttons and displaying code. */ var JQ4UFUNCS = { init: function() { _this = this; //console.log('running init...'); /* settings */ var fns = ['animate1','animate2','animate3','setinterval1','setinterval2','settimeout','slidetoggle','fadetoggle','delay','css1','css2','addclass','toggleclass','html','append','clone','ajax','getjson','getscript','load','jsonp','bind1','bind2','bind3','live','delegate','preventdefault','stoppropagation','stopimmediatepropagation','each1','each2','data','match1','match2','find','filter','slice','next','extend1','extend2','serializearray1','serializearray2']; /* array of demo functions */ $('.demoarea').hide(); /* demos shown when user clicks run */ /* ------------------------------ Demo Button Events ------------------------ */ $('.demobtn').live('click', function(e) { e.preventDefault(); var _id = _this.getId($(this)); $(_id).show(); /* show demoarea */ $(_id+'-resetbtn').show(); /* show reset button */ }); /* I've coded the function this way ONLY because originally I was using eval() but IE poop'd - IE sucks. */ $.getScript('https://www.jquery4u.com/scripts/htmlentities.js', function() { $('.demobtn, .codebtn, .resetbtn').live('click', function(e) { e.preventDefault(); }); $.each(fns, function(i,fn) { /* check for presence of function */ var parentPresence = $('#maindemoarea').html() == null ? false : true; var fnPresence = parentPresence == true ? ($('#maindemoarea').html().indexOf('id="'+fn+'"') !== -1) : ($('body').html().indexOf('id="'+fn+'"') !== -1); if(fnPresence) { $('#'+fn+'-demobtn').live('click', function(e) { JQFUNCS.runFunc[fn]["run"](fn); }); $('#'+fn+'-codebtn').live('click', function(e) { $('#'+fn+'-sourcecode').fadeToggle('slow'); }); $('#'+fn+'-resetbtn').live('click', function(e) { JQFUNCS.runFunc[fn]["reset"](fn); }); /* --------------------- Attach the source code to demo ------------------------------ */ var functionCodeRun = JQFUNCS.runFunc[fn]["run"].toString(); functionCodeRun = new String(functionCodeRun.substring(functionCodeRun.indexOf('{')+1,functionCodeRun.lastIndexOf('}')).trim()); var functionCodeReset = JQFUNCS.runFunc[fn]["reset"].toString(); functionCodeReset = new String(functionCodeReset.substring(functionCodeReset.indexOf('{')+1,functionCodeReset.lastIndexOf('}')).trim()); $('#'+fn).after('
Code to Run
'+''+functionCodeRun+''+'
Code to Reset
'+''+functionCodeReset+''+'