Skip to content

A fast toolkit for attaching events to DOM elements and updating DOM subtrees with snippets of HTML from a webserver.

Notifications You must be signed in to change notification settings

exitnexus/Overlord

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

This code is licensed under the MIT license.

Copyright (c) 2010 Nexopia.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


The purpose of this project is to provide a fast way for attaching javascript
event handlers to a potentially large number of DOM elements, and then allow
the updating of those elements through HTML snippets.

Two features mentioned in the source code, initializing on element available
and initializing on Facebook ready, will not work unless you hook them into
your own code. To use available you will need to call the function 
Overlord.minionAvailable(id) when the node is loaded. To use Facebook call 
Overlord.summonMinions(null, 'facebook') after facebook initialization.

To specify what type of "minion" a DOM node is put the attribute 
minion="my:minion" on it. Multiple minions can be associated with each node
included in a single minion attribute and separated with spaces.

Asides from that basic usage on the javascript side is probably best conveyed
through an example:

Overlord.assign({
  minion: "my:minion",
  click: function(event, element) {
    // what happens when you click on the element goes here.
  },
  load: function(element) {
    // note there is no event passed to load, just the element that has been loaded
  },
  order: 0, // default load order
  scope: Foo // all event handler functions will be executed in the scope of Foo
});

Overlord.assign({
  minion: "progress:bar",
  load: function(element) {
    new ProgressBar({
      element: element,
      percent: parseInt(element.getAttribute('data-percent'), 10)
    });
  }
});

ResponseHandler is a wrapper for the options parameter of Ajax.Request (from 
Prototype). It assumes that your response will be a series of html snippets with
id attributes. It substitutes the snippets for the portion of the page with the
same id, and then reinitializes all of the javascript for just that sub-tree
using Overlord.

About

A fast toolkit for attaching events to DOM elements and updating DOM subtrees with snippets of HTML from a webserver.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%