Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(window) {
- var
- document = window.document,
- $ = window.jQuery,
- $document = $(document),
- queue = {
- functions: [],
- add: function(fn) {
- if (fn && typeof fn === 'function') {
- queue.functions.push(fn);
- return queue.bindFn(fn, $document);
- }
- },
- bindFn: function(fn, $context) {
- return function() {
- Function.prototype.apply.call(fn, $context, []);
- };
- }
- },
- alterImages = function() {
- $('img', this).each(function() {
- $(this).fadeTo(0, 0.5).after('<span>||||</span>')
- });
- },
- alterPs = function() {
- $('p', this).each(function() {
- $(this).css('background', 'red').after('<hr/>');;
- });
- };
- $(queue.add(alterImages));
- $(queue.add(alterPs));
- /* =/ Later... /= */
- $(function() {
- $('a.load-new-content').click(function() {
- var $target = $($(this).attr('href')),
- queueLength = queue.functions.length;
- $.ajax({
- url: 'new-content.html',
- success: function(data, textStatus, jqXHR) {
- $target.html(data);
- while (queueLength--) {
- queue.bindFn(queue.functions[queueLength], $target)();
- }
- }
- });
- return false;
- });
- });
- })(window);
Add Comment
Please, Sign In to add comment