Skip to content

Latest commit

 

History

History
534 lines (441 loc) · 17.6 KB

api.md

File metadata and controls

534 lines (441 loc) · 17.6 KB

Xone API

Uppercase identifiers helps you to determine:

  • static vars (e.g. API namespaces, global configs, constants, flags, switches)
  • read-only values
  • special definitions in object notation to fulfill conventions of Xone automated system
  • special members and classes also used by the automated system

Note: You are free to use or not to use these automated concept, most of those features can also be used directly outside of the automated chain.

Global Constants

  • ENV
  • PLATFORM
  • DEBUG

Note: Globals only available in non-production environments. All globals are removed in production builds.

Global Namespaces

  • APP
  • CORE
  • CONFIG
  • MANIFEST

Note: Globals only available in non-production environments. All globals are removed in production builds.

CONFIG.*

Constants: (read-only)

  • CONFIG.ENV
  • CONFIG.PLATFORM
  • CONFIG.DEBUG

get more details here

APP.*

Static Methods:

  • APP.INIT: function()
  • APP.SETUP: function()
  • APP.MAIN: function()

MVC Methods

  • APP.MODEL
    • Methods:
      • APP.MODEL.new: function(name, data<, persistent>)
      • APP.MODEL.create: function(name, data)
      • APP.MODEL.register: function(name, model)
  • APP.CONTROLLER
    • Methods:
      • APP.CONTROLLER.build: function build(view<, data>)
      • APP.CONTROLLER.render: function render(target<, data>)
      • APP.CONTROLLER.changeLanguage: function(lang) (deprecated)

MVC Definitions

  • APP.MODEL: Array([model]) implements ModelInterface
  • APP.CONTROLLER: Array([controller]) implements ControllerInterface
  • APP.ROUTE: Array([route]) implements RouteInterface
  • APP.PAYLOAD: Array([function])
  • APP.MAPPER: Array([object])
  • APP.LANG: Array([object])

APP Definitions

  • APP.EVENT: Array([event]) implements EventInterface
  • APP.HANDLER: Array([function])
  • APP.HELPER: Array([function])
  • APP.INTERFACE: Array([interface])
  • APP.ADAPTER: Array([class])
  • APP.REQUIRE
  • APP.CHANGELOG: Array([object]) (dropped)
  • APP.MIGRATE (in progress)
  • APP.PLUGIN

APP Base

  • APP.VIEWPORT
    • Constants: (read-only)
      • APP.VIEWPORT.ASPECT_RATIO
      • APP.VIEWPORT.PIXEL_RATIO
      • APP.VIEWPORT.ORIENTATION
      • APP.VIEWPORT.WIDTH
      • APP.VIEWPORT.HEIGHT
      • APP.VIEWPORT.SCALE
      • APP.VIEWPORT.ZOOM
    • Methods:
      • APP.VIEWPORT.lockOrientation: function(orientation)
      • APP.VIEWPORT.update: function()
  • APP.DEVICE (coming soon)
    • Constants: (read-only)
      • APP.DEVICE.ASPECT_RATIO
      • APP.DEVICE.PIXEL_RATIO
      • APP.DEVICE.ORIENTATION
      • APP.DEVICE.WIDTH
      • APP.DEVICE.HEIGHT
      • APP.DEVICE.SCALE
      • APP.DEVICE.ZOOM
  • APP.CONFIG
    • Constants: (read-only)
      • APP.CONFIG.LANG: String
      • APP.CONFIG.PROC (deprecated)
      • APP.CONFIG.GZIP: Boolean
      • APP.CONFIG.PASSIVE_EVENTS (deprecated)
      • APP.CONFIG.EVENT_OPTIONS (deprecated)
      • APP.CONFIG.LAYOUT: Array([string])
    • Switches:
      • APP.CONFIG.SHOW_DEBUG (deprecated)
      • APP.CONFIG.SHOW_GRAPH (deprecated)
      • APP.CONFIG.SHOW_STATS (deprecated)
  • APP.VARS
    • Globals:
      • APP.VARS.CURRENT_USER: Object
      • APP.VARS.HEADER: Object
      • APP.VARS.AUTH: String
  • APP.STATS: Object
  • APP.SETTINGS (implements StorageInterface)
    • Methods:
      • APP.SETTINGS.clear: function()
      • APP.SETTINGS.del: function(index)
      • APP.SETTINGS.get: function(index)
      • APP.SETTINGS.keys: function()
      • APP.SETTINGS.set: function(index, value)
      • APP.SETTINGS.update: function(index, value)
  • APP.LAYOUT (deprecated)
  • APP.STORAGE (extends StorageAdapter)
  • APP.WORKER
    • Methods:
      • APP.WORKER.register: function(name, worker<, callback>)

CORE.*

Math

  • CORE.Math
    • Methods:
      • CORE.Math.min: function(a, b<, c, d, ...>)
      • CORE.Math.max: function(a, b<, c, d, ...>)
      • CORE.Math.med: function(a, b<, c, d, ...>)
      • CORE.Math.rad: function(num)
      • CORE.Math.cos: function(num)
      • CORE.Math.sin: function(num)
      • CORE.Math.abs: function(num)
      • CORE.Math.round: function(num)
      • CORE.Math.rand: function(<seed>)

DOM

  • CORE.query: function(query)
  • CORE.queryOne: function(query)
  • CORE.queryAll: function(query)
  • CORE.getByClass: function(classname, context)
  • CORE.getById: function(id)
  • CORE.getByTag: function(tag, context)
  • CORE.getClosest: function(query)
  • CORE.getHTML: function(node)
  • CORE.getText: function(node)
  • CORE.getNode: function(element) (deprecated)
  • CORE.getValue: function(node)
  • CORE.setHTML: function(node, html, async)
  • CORE.setText: function(node, val)
  • CORE.setValue: function(node, value)

Styles

  • CORE.css: function(obj, style, val)
  • CORE.paint: function(fn, delay)
  • CORE.addByClass: function(name, node<, callback>) (deprecated)
  • CORE.addCssRule: function(selector, rules, value)
  • CORE.addClass: function(node, name<, callback>)
  • CORE.animate: function(obj, params)
  • CORE.getStyle: function(obj, style)
  • CORE.scrollTo: function(node, from, to<, duration>)
  • CORE.scrollToTop: function(node)
  • CORE.removeByClass: function(name, node, callback) (deprecated)
  • CORE.removeClass: function(node, name, callback)
  • CORE.removeNodes: function(element)
  • CORE.hasClass: function(node, name)
  • CORE.toggleByClass: function(name, node, callback) (deprecated)
  • CORE.toggleClass: function(node, name, callback)
  • CORE.toggleStyle: function(obj, css, val)
  • CORE.setStyle: function(obj, css, val)
  • CORE.hasStyle: function(obj, css, val)

Event

  • CORE.on: function(elem, query, event, fn<, preventDefault, stopBubble, key>)
  • CORE.addEvent: function(elem, event, fn<, preventDefault, stopBubble>)
  • CORE.addInputEvent: function(node, fn<, preventDefault>)
  • CORE.addMouseWheelScroll: function(node, fn)
  • CORE.addTouchEvent: function(node, fn<, preventDefault, stopBubble>)
  • CORE.addTouchMoveEvent: function(node, fn<, preventDefault, stopBubble>)
  • CORE.delegateByClass: function(node, classname, event, fn<, preventDefault, stopBubble>)
  • CORE.delegateByTag: function(node, tag, event, fn<, preventDefault, stopBubble>)
  • CORE.delegateByTagClass: function(node, tag, classname, event, fn<, preventDefault, stopBubble>)
  • CORE.handleEvent: function(event, elem, fn, preventDefault, stopBubble)
  • CORE.preventEvent: function(event, prevent, stop)
  • CORE.triggerMouseEvent: function(node, event)
  • CORE.switchKeyCode: function(keycode, payload)

Checks

  • CORE.contains: function(array, item)
  • CORE.isArray: function(value)
  • CORE.isBlank: function(value)
  • CORE.isDefined: function(value)
  • CORE.isEmpty: function(value)
  • CORE.isObject: function(value)
  • CORE.isString: function(value, item)
  • CORE.isNumber: function(value, item)
  • CORE.isBoolean: function(value, item)
  • CORE.isCollection: function(value, item)
  • CORE.isNode: function(value, item)
  • CORE.isType: function(value<, type>)
  • CORE.is: function(item<, type>)
  • CORE.hasValue: function(value)
  • CORE.hasValues: function(array)
  • CORE.hasKeys: function(object)
  • CORE.has: function(item<, type>)

System

  • CORE.Browser
    • Constants: (read-only)
      • CORE.System.isOpera: Boolean
      • CORE.System.isFirefox: Boolean
      • CORE.System.isSafari: Boolean
      • CORE.System.isMSIE: Boolean
      • CORE.System.isChrome: Boolean
      • CORE.System.is: function(type)
  • CORE.System
    • Constants: (read-only)
      • CORE.System.isIphone: Boolean
      • CORE.System.isIpod: Boolean
      • CORE.System.isIpad: Boolean
      • CORE.System.isAndroid: Boolean
      • CORE.System.isIOS: Boolean
      • CORE.System.isWindows: Boolean
      • CORE.System.isCordova: Boolean
      • CORE.System.isWebapp: Boolean
      • CORE.System.is: function(type)
  • CORE.Device
    • Constants: (read-only)
      • CORE.System.isMobile: Boolean
      • CORE.System.isRetina: Boolean
      • CORE.System.isTouch: Boolean
      • CORE.System.isOnline: Boolean
      • CORE.System.isOffline: Boolean
      • CORE.System.is: function(type)

Array

  • CORE.merge: function(a, b<, c, d, ...>)
  • CORE.unique: function(array<, field>)
  • CORE.registerEach: function(fn)
  • CORE.registerFilter: function(fn)
  • CORE.registerMap: function(fn)
  • CORE.reverse: function(array)
  • CORE.shuffle: function(array<, times>)
  • CORE.fill: function(array, content)
  • CORE.sort: function(array<, compare>)
  • CORE.sortAsc: function(array)
  • CORE.sortDesc: function(array)
  • CORE.sortNum: function(array<, compare>)
  • CORE.sortNumAsc: function(array)
  • CORE.sortNumDesc: function(array)
  • CORE.sortBy: function(array, field<, compare>) (in progress)
  • CORE.sortByAsc: function(array, field) (in progress)
  • CORE.sortByDesc: function(array, field) (in progress)
  • CORE.getKeys: function(data)
  • CORE.replace: function(array, find, replace)
  • CORE.count: function(array, find)

String

  • CORE.replace: function(string, find, replace)
  • CORE.count: function(string, find)
  • CORE.randomString: function(pattern)
  • CORE.trim: function(string)

Process

  • CORE.async: function(fn<, delay>)
  • CORE.stack: function(fn<, delay>)
  • CORE.clear: function(id)
  • CORE.time: function()
  • CORE.getStackLength: function() (deprecated)

Ajax

  • CORE.ajax: function(params) (deprecated)
  • CORE.xhr:
    • Methods:
      • CORE.xhr.get: function(host, payload, callback)
      • CORE.xhr.post: function(host, payload<, callback>)
      • CORE.xhr.patch: function(host<, payload, callback>)
      • CORE.xhr.delete: function(host<, payload, callback>)
      • CORE.xhr.download: function(host, destination<, callback>) (in progress)
      • CORE.xhr.upload: function(host, source<, callback>) (in progress)
  • CORE.request: function(type<, payload, callback>)
  • CORE.paramsToString: function(params)

Format

  • CORE.formatDate: function(date)
  • CORE.formatNumber: function(number, places, decimal, seperator)
  • CORE.capitalize: function(text)

Template

  • CORE.buildData: function(pattern, parent<, data>)
  • CORE.buildPattern: function(pattern, parent<, data>)
  • CORE.parseNode: function(pattern, data)

Debug

  • CORE.console
    • Methods:
      • Console.log: function(msg)
      • Console.warn: function(msg)
      • Console.err: function(msg)
      • Console.info: function(msg)
      • Console.show: function()
      • Console.hide: function()

Helpers

  • CORE.Storage: StorageAdapter implements StorageInterface
  • CORE.crc32: function(str)
  • CORE.imageToDataUrl: function(src, callback, format, quality)
  • CORE.initRetina: function(data, context) (deprecated)
  • CORE.loadScript: function(src, callback)
  • CORE.loadStyle: function(src, media)
  • CORE.prefix (deprecated)
  • CORE.preloadImages: function(images) (deprecated)
  • CORE.focusInput: function(input_element)

Adapter, Interfaces & Structs (Type Definitions)

Model Definition implements ModelHelper

Each model class provide some built ins.

  • ModelHelper.new: function(data)
  • ModelHelper.create: function(data)
  • ModelHelper.newFromList (deprecated)
  • ModelHelper.createFromList (deprecated)
  • ModelHelper.parse (deprecated)
  • ModelHelper.find
  • ModelHelper.findBy
  • ModelHelper.all
  • ModelHelper.range
  • ModelHelper.count
  • ModelHelper.countBy
  • ModelHelper.countWhere
  • ModelHelper.each
  • ModelHelper.where
  • ModelHelper.like
  • ModelHelper.saveAll
  • ModelHelper.deleteAll
  • ModelHelper.updateAll
    • Constructor:
      • ModelHelper.constructor.beforeUpdate
      • ModelHelper.constructor.beforeCreate
      • ModelHelper.constructor.beforeSave
      • ModelHelper.constructor.onCreate
      • ModelHelper.constructor.onUpdate
      • ModelHelper.constructor.onSave

Model Instance implements ModelClass

All instances of a model provide some built ins.

  • ModelClass.save
  • ModelClass.update
  • ModelClass.restore
  • ModelClass.delete
    • Constructor:
      • ModelClass.constructor.beforeUpdate
      • ModelClass.constructor.beforeCreate
      • ModelClass.constructor.beforeSave
      • ModelClass.constructor.onCreate
      • ModelClass.constructor.onUpdate
      • ModelClass.constructor.onSave

Controller implements ControllerInterface

The controller can be used directly or can be automatically connected to a chain via definitions.

  • Controller.render
  • Controller.build
  • Controller.request
  • Controller.requestBatch
  • Controller.requestSync

Route implements RouteInterface

A route definition connects either: a request controller with its default chain or an event controller chain.

  • Route.to
  • Route.action
  • Route.type
  • Route.field
  • Route.limit
  • Route.last
  • Route.params
  • Route.header
  • Route.cache
  • Route.clear
  • Route.async
  • Route.default
  • Route.sort
  • Route.error
  • Route.filter
  • Route.map
  • Route.arrayfilter
  • Route.arraymap

Mapper implements MapperInterface

A mapper definition maps a model to a different representations (e.g. model > server, model > storage, storage > model)

  • Mapper.mapToView
  • Mapper.mapToPayload (in progress)
  • Mapper.mapToData (in progress)
  • Mapper.mapFromPayload (in progress)
  • Mapper.mapFromData (in progress)

Template implements TemplateStruct (comming soon)

Templates will be auto generated by built-in compilation.

  • Template.if
  • Template.map
  • Template.data
  • Template.loop
  • Template.else
  • Template.include

ViewModel implements ViewModelStruct

A viewmodel payload has to be passed when calling the view controller by Controller.render() directly.

  • ViewModel.data
  • ViewModel.target
  • ViewModel.view
  • ViewModel.default
  • ViewModel.callback

ViewCache implements StorageInterface

The view cache is automatically used by the view controller.

  • ViewCache.set, update: function(key, view)
  • ViewCache.get: function(key)
  • ViewCache.del, delete: function(key)
  • ViewCache.clean, cleanup function()
  • ViewCache.clear: function()
  • ViewCache.has: function(key)

Pattern implements PatternStruct

This pattern scheme is used to render templates from JSON into DOM elements by CORE.build()

  • Pattern.tag
  • Pattern.attr
  • Pattern.text
  • Pattern.child, childs
  • Pattern.length

Event implements EventStruct

An event definition is used to make event delegation more simple.

  • Event.on
  • Event.if
  • Event.at
  • Event.to
  • Event.do
  • Event.go
  • Event.stopBubble
  • Event.preventDefault

Request implements RequestStruct

An request definition is used to setup server calls or when calling the request controller directly by CONTROLLER.request().

  • Request.type
  • Request.url
  • Request.params
  • Request.success
  • Request.error
  • Request.header
  • Request.async
  • Request.clear
  • Request.cache

Storage implements StorageInterface

A storage can be one of both: persistent or temporary (cache).

  • Storage.new, create, register function(name, persistent?) : Storage
  • Storage.get function(key) : value
  • Storage.set function(key, data)
  • Storage.update function(key, data) : hasUpdate?
  • Storage.del, delete function(key)
  • Storage.clean, cleanup function()
  • Storage.clear function()
  • Storage.has function(key) : value

FileSystem implements FileSystemInterface

The filesystem provides access to larger capacity and can also be one of both: persistent or temporary.

  • FileSystem.init
  • FileSystem.load
  • FileSystem.save
  • FileSystem.delete
  • FileSystem.copy
  • FileSystem.move
  • FileSystem.exist