Created
March 26, 2011 20:29
-
-
Save jeremyckahn/888606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function managerExample () { | |
// Declare private manager vars here | |
var container; | |
function init () { | |
// Select all of the DOM elements the manager uses in `init` | |
container = $('#container'); | |
} | |
// Functions with a leading underscore imply that the function is not to be used publicly | |
function _bindEvents () { | |
} | |
$(document.documentElement).bind('managerExample.init', init); | |
}); | |
$(function articleManager () { | |
var trigger; | |
window._lock = { | |
'articleTransition': false, | |
lock: function (lockName) { | |
this[lockName] = true; | |
}, | |
unlock: function (lockName) { | |
this[lockName] = false; | |
}, | |
isLocked: function (lockName) { | |
return this[lockName]; | |
} | |
}; | |
function init () { | |
trigger = $('#trigger'); | |
_bindEvents(); | |
$(document.documentElement).trigger('article.transitioner.init'); | |
} | |
function _bindEvents () { | |
trigger.click(function (ev) { | |
if (window._lock.isLocked('articleTransition')) { | |
return; | |
} | |
window._lock.lock('articleTransition'); | |
target = $(ev.target); | |
$(document.documentElement).trigger('article.transitioner.transition', [target, function () { | |
window._lock.unlock('articleTransition'); | |
}]); | |
}); | |
} | |
init(); | |
}); | |
$(function articleTransitionerManager () { | |
function init () { | |
// setup logic... | |
_bindEvents(); | |
} | |
function _bindEvents () { | |
// Bind stuff | |
$(document.documentElement).bind('article.transitioner.transition', transition); | |
} | |
function transition (ev, article, callback) { | |
article.animate({ | |
'left': '+=300' | |
}, { | |
'complete': callback | |
}); | |
} | |
$(document.documentElement).bind('article.transitioner.init', init); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment