diff options
Diffstat (limited to 'src/jqLite.js')
| -rw-r--r-- | src/jqLite.js | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/src/jqLite.js b/src/jqLite.js index 68172fd8..1ad4d96d 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -2,24 +2,17 @@ //JQLite ////////////////////////////////// -var jqCache = {}; -var jqName = 'ng-' + new Date().getTime(); -var jqId = 1; -function jqNextId() { return (jqId++); } - -var addEventListener = window.document.attachEvent ? - function(element, type, fn) { - element.attachEvent('on' + type, fn); - } : function(element, type, fn) { - element.addEventListener(type, fn, false); - }; +var jqCache = {}, + jqName = 'ng-' + new Date().getTime(), + jqId = 1, + addEventListener = (window.document.attachEvent ? + function(element, type, fn) {element.attachEvent('on' + type, fn);} : + function(element, type, fn) {element.addEventListener(type, fn, false);}), + removeEventListener = (window.document.detachEvent ? + function(element, type, fn) {element.detachEvent('on' + type, fn); } : + function(element, type, fn) { element.removeEventListener(type, fn, false); }); -var removeEventListener = window.document.detachEvent ? - function(element, type, fn) { - element.detachEvent('on' + type, fn); - } : function(element, type, fn) { - element.removeEventListener(type, fn, false); - }; +function jqNextId() { return (jqId++); } function jqClearData(element) { var cacheId = element[jqName], @@ -36,6 +29,23 @@ function jqClearData(element) { } } +function getStyle(element) { + var current = {}, style = element[0].style, value, name, i; + if (typeof style.length == 'number') { + for(i = 0; i < style.length; i++) { + name = style[i]; + current[name] = style[name]; + } + } else { + for (name in style) { + value = style[name]; + if (1*name != name && name != 'cssText' && value && typeof value == 'string' && value !='false') + current[name] = value; + } + } + return current; +} + function JQLite(element) { if (isElement(element)) { this[0] = element; @@ -87,19 +97,14 @@ JQLite.prototype = { eventHandler = bind[type]; if (!eventHandler) { bind[type] = eventHandler = function(event) { - var bubbleEvent = false; - foreach(eventHandler.fns, function(fn){ - bubbleEvent = bubbleEvent || fn.call(self, event); - }); - if (!bubbleEvent) { - if (msie) { + if (!event.preventDefault) { + event.preventDefault = function(){ event.returnValue = false; - event.cancelBubble = true; - } else { - event.preventDefault(); - event.stopPropagation(); - } + }; } + foreach(eventHandler.fns, function(fn){ + fn.call(self, event); + }); }; eventHandler.fns = []; addEventListener(element, type, eventHandler); |
