Skip to content

Commit

Permalink
Events extension created
Browse files Browse the repository at this point in the history
  • Loading branch information
chernikovalexey committed Mar 22, 2012
1 parent 7cd76a9 commit dc4f15f
Show file tree
Hide file tree
Showing 4 changed files with 674 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Extensions/Dom.js
Expand Up @@ -128,8 +128,7 @@
list.push(v);
} else if(pl.type(v, 'obj')) {
var found = pl(this).find(selector).get();
found = pl.type(found, 'arr') ? found : [found];
list = list.concat(found);
list = list.concat(pl.type(found, 'arr') ? found : [found]);
}
});

Expand Down
31 changes: 31 additions & 0 deletions Extensions/Events.js
@@ -0,0 +1,31 @@
/* Prevel Events Extension
* (adds cross-browser triggering)
*
* Requirements: Core.js
**/

(function() {

pl.extend(pl.fn, {
trigger: function(evt) {
var event;
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(evt, true, true);
} else {
event = document.createEventObject();
event.eventType = 'on' + evt;
}

event.eventName = evt;
var element = this.elements[0];

if (document.createEvent) {
element.dispatchEvent(event);
} else {
element.fireEvent(event.eventType, event);
}
}
});

})();

0 comments on commit dc4f15f

Please sign in to comment.