Beagle

 view release on metacpan or  search on metacpan

share/public/js/base/jquery.terminal.js  view on Meta::CPAN

	    running: false,
	    timeout: null,
	    
	    checkQueue: function() {
		    if ( $.livequery.running && $.livequery.queue.length ) {
			    var length = $.livequery.queue.length;
			    // Run each Live Query currently in the queue
			    while ( length-- )
				    $.livequery.queries[ $.livequery.queue.shift() ].run();
		    }
	    },
	    
	    pause: function() {
		    // Don't run anymore Live Queries until restarted
		    $.livequery.running = false;
	    },
	    
	    play: function() {
		    // Restart Live Queries
		    $.livequery.running = true;
		    // Request a run of the Live Queries
		    $.livequery.run();
	    },
	    
	    registerPlugin: function() {
		    $.each( arguments, function(i,n) {
			    // Short-circuit if the method doesn't exist
			    if (!$.fn[n]) return;
			    
			    // Save a reference to the original method
			    var old = $.fn[n];
			    
			    // Create a new method
			    $.fn[n] = function() {
				    // Call the original method
				    var r = old.apply(this, arguments);
				    
				    // Request a run of the Live Queries
				    $.livequery.run();
				    
				    // Return the original methods result
				    return r;
			    }
		    });
	    },
	    
	    run: function(id) {
		    if (id != undefined) {
			    // Put the particular Live Query in the queue if it doesn't already exist
			    if ( $.inArray(id, $.livequery.queue) < 0 )
				    $.livequery.queue.push( id );
		    }
		    else
			    // Put each Live Query in the queue if it doesn't already exist
			    $.each( $.livequery.queries, function(id) {
				    if ( $.inArray(id, $.livequery.queue) < 0 )
					    $.livequery.queue.push( id );
			    });
		    
		    // Clear timeout if it already exists
		    if ($.livequery.timeout) clearTimeout($.livequery.timeout);
		    // Create a timeout to check the queue and actually run the Live Queries
		    $.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
	    },
	    
	    stop: function(id) {
		    if (id != undefined)
			    // Stop are particular Live Query
			    $.livequery.queries[ id ].stop();
		    else
			    // Stop all Live Queries
			    $.each( $.livequery.queries, function(id) {
				    $.livequery.queries[ id ].stop();
			    });
	    }
    });

    // Register core DOM manipulation methods
    $.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');

    // Run Live Queries when the Document is ready
    $(function() { $.livequery.play(); });


    // Save a reference to the original init method
    var init = $.prototype.init;

    // Create a new init method that exposes two new properties: selector and context
    $.prototype.init = function(a,c) {
	    // Call the original init and save the result
	    var r = init.apply(this, arguments);
	    
	    // Copy over properties if they exist already
	    if (a && a.selector)
		    r.context = a.context, r.selector = a.selector;
		
	    // Set properties
	    if ( typeof a == 'string' )
		    r.context = c || document, r.selector = a;
	    
	    // Return the result
	    return r;
    };

    // Give the init function the jQuery prototype for later instantiation
    // (needed after Rev 4091)
    $.prototype.init.prototype = $.prototype; 
    // ----------------------------------------
    // START Storage plugin
    // ----------------------------------------
    // Private data
    var isLS = typeof window.localStorage !== 'undefined';
    // Private functions
    function wls(n, v) {
        var c;
        if (typeof n === 'string' && typeof v === 'string') {
            localStorage[n] = v;
            return true;
        } else if (typeof n === 'object' && typeof v === 'undefined') {
            for (c in n) {
                if (n.hasOwnProperty(c)) {
                    localStorage[c] = n[c];
                }



( run in 0.650 second using v1.01-cache-2.11-cpan-5837b0d9d2c )