Skip to content

Instantly share code, notes, and snippets.

View kfranqueiro's full-sized avatar

Kenneth G. Franqueiro kfranqueiro

View GitHub Profile
@kfranqueiro
kfranqueiro / MoreMixin.html
Created March 15, 2013 04:22
Example of extending dgrid's `_StoreMixin` to present a list or grid progressively, one page at a time.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../dojo/resources/dojo.css">
<link rel="stylesheet" href="../../dgrid/css/skins/claro.css">
<style>
#list {
border: none;
height: auto;
@kfranqueiro
kfranqueiro / enterUp.js
Created February 22, 2013 21:02
Example of a dojo/on extension event that fires when the enter key is released
function enterUp(node, listener) {
return on(node, "keyup", function(evt) {
if (evt.keyCode === 13) {
listener.call(this, evt);
}
});
}
// Usage with dojo/on: on(element, enterUp, ...)
// Usage with dgrid editor: editor({ editOn: enterUp, ... })
@kfranqueiro
kfranqueiro / findDep.js
Last active March 1, 2016 22:47
Functions to find what's depending on a loaded Dojo module or what a module depends on (uses ES5 methods)
function findDep(depid) {
return Object.keys(require.modules).map(function(mid) {
return require.modules[mid];
}).filter(function(m) {
return m.deps && m.deps.map(function(dep) {
return dep.mid;
}).indexOf(depid) > -1;
}).map(function(m) {
return m.mid;
});
@kfranqueiro
kfranqueiro / test.html
Created September 13, 2012 01:01
Test for dgrid #277
<!DOCTYPE html>
<html>
<head>
<style>
#hierarchyTree {
height: 200px;
}
#hierarchyTree .dgrid-cell {
width: 100px;
@kfranqueiro
kfranqueiro / test59.html
Created January 5, 2012 04:59
Test page attempting to reproduce dgrid issue #59
<!DOCTYPE html>
<html>
<head>
<title>Test Issue #59</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=570"/>
<style type="text/css">
@import "../../dijit/themes/claro/document.css";
@import "../../dijit/themes/claro/claro.css";
@import "../css/dgrid.css";
@kfranqueiro
kfranqueiro / ParentHierarchical.js
Created March 29, 2011 12:39
Possibly-naive attempt at a generic dojo.store wrapper supporting getChildren, via parent relationships.
/*
NOTE: This wrapper "works", but is sorta incomplete...
* It does not explicitly support deterministic ordering/rearrangement of children.
* For that matter, the way Tree currently achieves this seems sort of obtuse.
Tree makes a blatant assumption on the existence of a children attribute
(since there is no dedicated method to set them), and reconstructs the array
every time children are reordered...
@kfranqueiro
kfranqueiro / DeferredDeclarativeMenu.js
Created March 13, 2011 21:37
Extension of dijit.Menu which fetches its items from a server endpoint outputting widgets in declarative HTML.
dojo.provide('kgf.widget.DeferredDeclarativeMenu');
dojo.require('dojo.parser');
dojo.require('dojo.string');
dojo.require('dijit.Menu');
dojo.requireLocalization('dijit', 'loading');
dojo.declare('kgf.widget._DeferredDeclarativeMenuMixin', null, {
// src: String
// URL to be loaded when this menu is opened.
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// 1A:
bar[foo ? 'doSomething' : 'doSomethingElse'](el);