Code Monkey home page Code Monkey logo

dx-alias's Introduction

DX-Alias is a utility package for helping to make Dojo and AMD more friendly, with shorter names, more versatile methods, and combined modules.

Acknowledgements

Author: Mike Wilcox

Email: [email protected]

Website: http://bettervideo.com

DX-Alias is freely available under the same dual BSD/AFLv2 license as the Dojo Toolkit.

Installation

Download the DX-Alias package, and install it in the same directory as your project.

NOTE

DX-Alias is currently under development, and this should be considered alpha, or pre-release at best. The code is used, and works, but could change. Tests and better documentation are still forth coming.

Description

DX-Alias is designed to make Dojo 1.7+ easier to use. The dom module, for example, loads in a majority of the commonly used dom methods so several modules do not have to be included in your AMD define. dojo/on is reworked so that it is more like the traditional dojo.connect, including the context argument.

More information about each module (in alphabetical order) below.

dom

The dom module returns a simple function for creating nodes:

define(['dx-alias/dom'], function(dom){
	dom('div', {css:'myClass', html:'text here'}, parentNode);
});

The property names are also shorter, so you can use "css" instead of "className", and "html" instead of "innerHTML".

The remaining methods are attached to the dom function, so they can be accessed like:

dom.style(node, prop, value);
dom.byId('myDiv');
dom.css(node, className, conditional);
// etc...

fx

This module is under development. There is one key method, flyout(), which handles something like a volume control slider "popup" (or flyout), by tracking if the mouse is over or clicking on the original button or the flyout.

has

Also under development, this will contain has() tests for some common CSS3 and HTML5 needs.

lang

A small combination of dojo/lang, with a few additional methods.

log

Based on the original consoleFix. It has additional functionality that allows you to add logs to each module than can be turned off with a simple bit:

define(['dx-alias/log'], function(logger){
	var log = logger('MOD', 1);
	log('do stuff'); // outputs: [MOD] do stuff
});

But changing the second argument to something falsey, the log for that module can be turned off:

define(['dx-alias/log'], function(logger){
	var log = logger('MOD', 0);
	log('do stuff'); // no output
});

all

Loads in all modules.

mouse

Functionality not in Dojo. This module can be used to track mouse movements and events, and will return a modified event with information, like the x/y from the corner of a node, or the distance the mouse has moved. Think of it as a GUI-less dojo/dnd, that could be used for canvas or other uses. See the code comments for full details.

on

In Dojo 1.7, dojo.connect was broken into pieces. dojo/on only attaches to dom nodes or objects that are "Evented". To attach to plain old objects, you are supposed to use dojo/aspect. dx-alias/on recombines dojo/aspect and dojo/on, and adds an argument for context (this). It also uses the pause-able ability to the return handle by default.

dx-alias/on adds a simple event for "scroll" to make it easy to attach to dom scroll events. It has a "once" method for attaching to something and allowing for only one event to fire.

It also adds "multi", used like:

var handle = on.multi(node, {
	'mousedown':'onMouseDown',
	'mouseup':this.onMouseUp
}, this);
handle.pause();
handle.resume();
handle.remove();

shim

dx-alias/shim is not a module, and returns nothing. It is a shim for browsers to add missing key functionality. Notably: Function.bind Array.forEach Array.some Array.indexOf Array.isArray TODO: remaining Array methods

string

This module adds dojo.string.trim, but otherwise, the remaining functionality is unique. urlToObj strToObj normalize urlEscape urlEncode trim

topic

dx-alias/topic is a different implementation of dojo/topic, but taps into dojo/topic, so either can be used. It begins by adding the context argument (this), and changes publish and subscribe to the more finger friendly pub and sub. It also adds support for a multi subscribe:

topic.sub.multi({
	'/on/data':'onData',
	'/on/hide':this.oHide
}, this);

dx-alias's People

Stargazers

Mike Wilcox avatar

Watchers

James Cloos avatar  avatar

Forkers

clubajax

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.