Permalink
Browse files

wrapped global initialization of 'NW', 'NW.Event' and the 'NW.Dom' ad…

…d-on each inside their own main scope, window does not normally exists in many server side javascript environments also NWEvents itself is of no use without a DOM layer and DOM Events, though Javascript object notifications can be implemented both in SpiderMonkey and V8, changed a semicolon with a comma, bumped release date and removed some extra tabs and spaces
  • Loading branch information...
1 parent d7d5f65 commit 611831e74487d5db2c0a0d05b72a6f3901759717 Diego Perini committed Mar 2, 2010
Showing with 14 additions and 12 deletions.
  1. +14 −12 src/nwevents.js
View
26 src/nwevents.js
@@ -7,17 +7,15 @@
* Author: Diego Perini <diego.perini at gmail com>
* Version: 1.2.4beta
* Created: 20051016
- * Release: 20100210
+ * Release: 20100302
*
* License:
* http://javascript.nwbox.com/NWEvents/MIT-LICENSE
* Download:
* http://javascript.nwbox.com/NWEvents/nwevents.js
*/
-window.NW || (window.NW = {});
-
-NW.Event = (function(global) {
+(function(global, undefined) {
var version = 'nwevents-1.2.4beta',
@@ -156,7 +154,7 @@ NW.Event = (function(global) {
SUPPORT_KEY_EVENTS = 'KeyEvent' in global &&
typeof KeyEvent.prototype.initEvent == 'function',
- KEYBOARD_FIX = SUPPORT_KEYBOARD_EVENTS ? '' : 's';
+ KEYBOARD_FIX = SUPPORT_KEYBOARD_EVENTS ? '' : 's',
KEYBOARD_EVENT = SUPPORT_KEY_EVENTS ? 'KeyEvent' :
SUPPORT_KEYBOARD_EVENTS ? 'KeyboardEvent' :
@@ -188,7 +186,7 @@ NW.Event = (function(global) {
return supportedEvents[type];
} :
- function () { },
+ function () { },
/* =========================== TRIGGER HANDLERS =========================== */
@@ -234,7 +232,7 @@ NW.Event = (function(global) {
triggerTarget.detachEvent(TRIGGER_EVENT, triggerExec);
}
} :
- function(enable) {
+ function(enable) {
triggerSet();
triggerEnabled = !!enable;
},
@@ -1173,7 +1171,9 @@ NW.Event = (function(global) {
// initialize global ready event
contentLoaded(global, complete);
- return {
+ global.NW || (global.NW = { });
+
+ NW.Event || (NW.Event = {
// controls the type of registration
// for event listeners (DOM0 / DOM2)
@@ -1224,13 +1224,13 @@ NW.Event = (function(global) {
enablePropagation: enablePropagation,
disablePropagation: disablePropagation
- };
+ });
})(this);
// embedded NW.Dom.match() so basic event delegation works,
// overwritten if loading the nwmatcher.js selector engine
-NW.Dom = (function(global) {
+(function(global, undefined) {
var Patterns = {
'id': /#([^\.]+)/,
@@ -1239,7 +1239,9 @@ NW.Dom = (function(global) {
'all': /^[\.\-\#\w]+$/
};
- return {
+ global.NW || (global.NW = { });
+
+ NW.Dom = ({
// use a simple selector match or a full
// CSS3 selector engine if it is available
match:
@@ -1306,6 +1308,6 @@ NW.Dom = (function(global) {
return matched;
}
- };
+ });
})(this);

0 comments on commit 611831e

Please sign in to comment.