Skip to content

Instantly share code, notes, and snippets.

@ngpestelos
Created September 25, 2011 00:21
Show Gist options
  • Save ngpestelos/1240036 to your computer and use it in GitHub Desktop.
Save ngpestelos/1240036 to your computer and use it in GitHub Desktop.
My notes on jquery.evently.js

Utilities

$$

  • a shorthand to jQuery's data(...)
  • using an element to store/fetch data

$.forIn(obj, fun)

  • invoke fun on obj's properties

$.argsToArray(args)

  • convert args (assumed to be array-like) to an array object

$.fn.replace(elem)

  • removes the contents of the currently selected element; replaced by elem

$.evently.fn.render

  • render Mustache templates

evfun(fun, hint)

  • callback function constructor (creates a Function from a string)
  • returns a Function object or fun
  • inside the callback, fun (now a Function) is applied to the current context (this) and returns its result (unless the function is an _init -- hint is checked here)

rfun(me, fun, args)

  • evaluates the function (fun) on the widget (me)

hApply(elem, name, h, args)

  • using name as key, binds a function to an element
  • h is the handler object
  • jQuery can be used to trigger the function
  • inside the callback, there react function is called with the handler object

react(me, h, args, fun)

  • IMPORTANT
  • executes the handler object on the widget (me)
  • uses the before plugin (runs each function inside it)
  • runs the render plugin (mustache as default renderer)
  • runs the after plugin

extractEvents(name, ddoc)

  • how does $.extend.apply work?

applyCommon(events)

  • how does $.extend work?

Evently API

$.fn.evently(events, app, args)

  • binds events (containing names and handlers) to the currently selected element
  • may pass a CouchApp object
  • hApply gets called for each property of events
  • runs the setup plugin

Plugins

$.evently.fn.setup

  • nested Evently (selectors)

$.evently.fn.before

  • before the element gets rendered
  • right after _init

$.evently.fn.render

  • replace element's contents with new HTML from Mustache

$.evently.fn.after

  • after the element has been rendered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment