Skip to content

Instantly share code, notes, and snippets.

View jakearchibald's full-sized avatar
💭
Tired

Jake Archibald jakearchibald

💭
Tired
View GitHub Profile
// out with the old...
glow.events.addListener(innerView, 'mouseover', function(e) {
var item = glow.dom.get(e.source),
itemRelated = glow.dom.get(e.relatedTarget);
while (item[0] != this) {
if ( item.hasClass('timetable-item') ) {
if ( item[0] == itemRelated[0] || itemRelated.isWithin(item) ) {
return;
}
/**
@name glow.ElementList#clone
@function
@description Clones each node in the ElementList, along with data & event listeners
@returns {glow.ElementList}
Returns a new ElementList containing clones of all the nodes in
the ElementList
@example
function(obj) {
if (obj.constructor.name) {
return obj.constructor.name;
} else {
var constructorStr = obj.constructor.toString();
return constructorStr.slice( constructorStr.indexOf('function ') + 9, constructorStr.indexOf('(') );
}
}
function TestClass() {}
(TestClass.prototype.constructor == TestClass); // true
TestClass.prototype = {
myMethod: function() {}
};
(TestClass.prototype.constructor == TestClass); // false
(TestClass.prototype.constructor == Object); // true
// out with the old:
(function(){
// this will hold our instance of glow
var glow;
gloader.load(['glow', '1', 'glow.dom', 'glow.anim', 'glow.widgets.Carousel'], {
async: true,
onLoad: function(g) {
glow = g;
// adding a show listener to an overlay:
myOverlay.on('show', function(event) {
// ...
});
// adding and removing a show listener to an overlay
function showListener() {
// ...
}
/**
@name glow.events
@namespace
@description Listening, creating & firing events
*/
/**
@name glow.events.addListeners
@function
@param {Object[]} attachTo Array of objects to add listeners to
(function() {
var glow = new Glow('2').load().loaded(loaded);
function loaded() {
var thingToClick = glow.dom.create('<a href="#">Thing to click</a>');
glow.events.addListener(thingToClick, 'click', function() {
glow.load('widgets').loaded(widgetsLoaded);
});
}
glow.net.loadScript('http://twitter.com/statuses/user_timeline/15390783.json?callback={callback}', {
onLoad: function(data) {
alert(data[0].user.name + "'s latest tweet:\n\n" + data[0].text);
}
});
<!-- 1. Simple, usual case with callback -->
<script type="text/javascript">
Glow("2").load("core", "widgets").ready(function (glow) {
// core & widgets loaded & dom ready
glow.widgets.doodle();
});
</script>
<!-- 2. 'Application Pattern'. Allows glow instance to be easily used in a wider but not global scope -->
<script type="text/javascript">