Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A collection of OzJS core modules that form a library called "Mo"
JavaScript CSS

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
README.md
browsers.js
cookie.js
domready.js
easing.js
key.js
lang.js
mainloop.js
network.js
package.json
template.js

README.md

Mo

  • A collection of OzJS core modules that form a library called "Mo"

AMD and OzJS

Modules Overview

  • mo/lang:
    • ES5/6 shim and minimum utilities for language enhancement
  • mo/domready:
    • Non-plugin implementation of cross-browser DOM ready event
    • Based on OzJS's built-in module -- 'finish'
  • mo/browsers:
    • Standalone jQuery.browsers supports skin browsers popular in China
  • mo/cookie:
    • Simple wrapping for managing cookie
  • mo/template:
    • A lightweight and enhanced micro-template implementation, and minimum utilities
  • mo/network:
    • Standalone jQuery.ajax API and enhanced getJSON, and so on
  • mo/easing:
    • An easing library supports jquery.js, standalone module and CSS timing functions
  • mo/mainloop:
    • Implement and manage single loop for WebApp life cycle
    • Provide tweening API for both property animation and frame animation(canvas or css)
  • mo/key:
    • Wrapping API for keyboard events
    • Support key sequence, multiple key press, ...

Examples

Get the code

API and usage

mo/lang

var _ = require('mo/lang');
  • _.type(sth) --
  • _.isFunction(sth) --
  • _.isWindow(sth) --
  • _.isEmptyObject(sth) --
  • _.mix(origin, obj1, obj2, ..., depth) --
  • _.merge(origin, obj1, obj2, ..., depth) --
  • _.interset(origin, obj1, obj2, ..., depth) --
  • _.defaults(origin, obj1, obj2, ..., depth) --
  • _.copy(origin, depth) --
  • _.occupy(origin, obj, depth) --
  • _.config(cfg, opt, DEFAULT_CFG) --
  • _.unique(list) --
  • _.ns(string, value) --
  • _.FnQueue() --
// Add ES5 methods in browsers that don't natively support them:
  • Array.prototype.forEach
  • Array.prototype.map
  • Array.prototype.filter
  • Array.prototype.reduce
  • Array.prototype.some
  • Array.prototype.every
  • Array.prototype.indexOf
  • Array.prototype.lastIndexOf
  • Array.isArray
  • String.prototype.trim
  • Object.keys
  • Object.create
  • Object.getPrototypeOf
  • Function.prototype.bind

mo/domready

require(['mo/domready'], function(none){
    // won't execute until the page's entire DOM has loaded
});

mo/browsers

var browsers = require('mo/browsers');
  • browsers.browser --
  • browsers.version --
  • browsers.skin --
  • browsers.rank --
  • browsers['msie'|'webkit'|'mozilla'|...] --

mo/cookie

var cookie = require('mo/cookie');

cookie(name, value, {
    domain: 'ozjs.org', // '' as default
    path: '/', // '' as default
    expires: 365 // day,
    secure: ''
});

mo/template

var tpl = require('mo/template');
  • tpl.escapeHTML(string) --
  • tpl.substr(string, limit, callback) --
  • tpl.strsize(string) --
  • tpl.str2html(string) --
  • tpl.format(string, dict|list) --
  • tpl.convertTpl(tplName|tplString, dictData, namespace) --
  • tpl.reloadTpl(tplName) --

mo/network

var net = require('mo/network');
  • net.ajax(options) --
  • net.params(data) --
  • net.getScript(url, callback) --
  • net.getStyle(url) --
  • net.getJSON(url, params, callback, options) --
  • net.getRequest(url, params) --

mo/easing

var easingLib = require('mo/easing');
  • easingLib.def --
  • easingLib.values --
  • easingLib.functions --
// use it as extension of other library

var $ = require('jquery');
$.easing['jswing'] = $.easing['swing'];
$.extend($.easing, easingLib.functions);

require('mo/mainloop').config({
    easing: easingLib.functions
});

require('choreo').config({
    easing: easingLib
});

mo/mainloop

var loop = require('mo/mainloop');
  • loop.config(options) --
  • loop.run(optional_stageName) --
  • loop.pause(stageName) --
  • loop.complete(stageName) --
  • loop.remove(stageName) --
  • loop.info(stageName) --
  • loop.isRunning(stageName) --
  • loop.addStage(stageName, optional_canvas) --
  • loop.addRender(stageName, render, optional_canvas) --
  • loop.getRender(renderId) --
  • loop.addTween(stageName, current, end, duration, options) --

mo/key

var Key = require('mo/key');
  • Key.KEYS_CODE --
var key = Key(config);
  • key.addHandler(event, keyName, handler) --
  • key.down([keyName, ...], handler) --
  • key.up([keyName, ...], handler) --
  • key.press([keyName, ...], handler) --
  • key.reset() --
  • key.addRule(fn) --
  • key.enable() --
  • key.disable() --
  • key.check() --

Under construction...

More References

See OzJS References

Release History

See OzJS Release History

License

Copyright (c) 2010 - 2013 dexteryy
Licensed under the MIT license.

Something went wrong with that request. Please try again.