Skip to content

Instantly share code, notes, and snippets.

View jakearchibald's full-sized avatar
💭
Tired

Jake Archibald jakearchibald

💭
Tired
View GitHub Profile
var myOverlay = new glow.widgets.Overlay("#element", {
x: 20,
y: 20
});
var editform = new glow.forms.Form("#editform", {
// make avalidation method
onValidate: function(results) {
// if the form is submitting and there's no errors
if (results.eventName == 'submit' && !results.errorCount) {
if ( /* decide if you want to submit here */ ) {
editform.formNode[0].submit();
}
}
else {
NodeListProto.clone = function() {
// TODO: make this work with events and data
var nodes = [],
i = this.length;
while (i--) {
nodes[i] = this[i].cloneNode(true);
glow.events._copyDomListeners(this[i], nodes[i]);
glow.NodeList._copyData(this[i], nodes[i]);
}
function MyConstructor() {
var instance = function() {
alert('yey');
}
instance.constructor = MyConstructor;
instance.__proto__ = MyConstructor.prototype;
return instance;
}
function getItemIndex(elm) {
var siblings = elm.slice(0,1).parent().children(),
i = siblings.length;
while(i--) {
if (siblings[i] == elm[0]) {
return i;
}
}
return -1;
var myApplication = (function(){
// this will hold our instance of glow
var glow;
gloader.load(['glow', '1', 'glow.dom', 'glow.anim'], {
async: true,
onLoad: function(g) {
glow = g;
glowLoaded();
g.ready(domReady);
function h(str) {
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&#34;')
.replace(/'/g, '&#39;')
}
function preloadImages(imageUrls, callback) {
var images = [],
imagesLen = imageUrls.length,
loaded = 0,
image;
function imageLoaded() {
if (++loaded == imagesLen) {
callback(images);
}
/**
@name glow.NodeList#filter
@function
@description Filter the NodeList
@param {Function|string} test Filter test
If a string is provided, it is used in a call to {@link glow.NodeList#is NodeList#is}.
If a function is provided it will be passed a single argument
representing the index of the current item in the NodeList.
// get images with a width greater than 320
glow('img').filter(function () {
return glow(this).width() > 320;
});
// get a definition term
var term = glow('#myDefs dt:first-child');
// get the next dt
term.next('dt');