comparison annotator_files/lib/class.js @ 4:6979313586cf

new version of annotator.
author casties
date Mon, 27 Aug 2012 19:05:38 +0200
parents 6356e78ccf5c
children
comparison
equal deleted inserted replaced
3:6356e78ccf5c 4:6979313586cf
1 // Generated by CoffeeScript 1.3.3
1 var Delegator, 2 var Delegator,
2 __slice = Array.prototype.slice, 3 __slice = [].slice,
3 __hasProp = Object.prototype.hasOwnProperty; 4 __hasProp = {}.hasOwnProperty;
4 5
5 Delegator = (function() { 6 Delegator = (function() {
6 7
7 Delegator.prototype.events = {}; 8 Delegator.prototype.events = {};
8 9
16 this.on = this.subscribe; 17 this.on = this.subscribe;
17 this.addEvents(); 18 this.addEvents();
18 } 19 }
19 20
20 Delegator.prototype.addEvents = function() { 21 Delegator.prototype.addEvents = function() {
21 var event, functionName, sel, selector, _i, _ref, _ref2, _results; 22 var event, functionName, sel, selector, _i, _ref, _ref1, _results;
22 _ref = this.events; 23 _ref = this.events;
23 _results = []; 24 _results = [];
24 for (sel in _ref) { 25 for (sel in _ref) {
25 functionName = _ref[sel]; 26 functionName = _ref[sel];
26 _ref2 = sel.split(' '), selector = 2 <= _ref2.length ? __slice.call(_ref2, 0, _i = _ref2.length - 1) : (_i = 0, []), event = _ref2[_i++]; 27 _ref1 = sel.split(' '), selector = 2 <= _ref1.length ? __slice.call(_ref1, 0, _i = _ref1.length - 1) : (_i = 0, []), event = _ref1[_i++];
27 _results.push(this.addEvent(selector.join(' '), event, functionName)); 28 _results.push(this.addEvent(selector.join(' '), event, functionName));
28 } 29 }
29 return _results; 30 return _results;
30 }; 31 };
31 32
34 _this = this; 35 _this = this;
35 closure = function() { 36 closure = function() {
36 return _this[functionName].apply(_this, arguments); 37 return _this[functionName].apply(_this, arguments);
37 }; 38 };
38 isBlankSelector = typeof bindTo === 'string' && bindTo.replace(/\s+/g, '') === ''; 39 isBlankSelector = typeof bindTo === 'string' && bindTo.replace(/\s+/g, '') === '';
39 if (isBlankSelector) bindTo = this.element; 40 if (isBlankSelector) {
41 bindTo = this.element;
42 }
40 if (typeof bindTo === 'string') { 43 if (typeof bindTo === 'string') {
41 this.element.delegate(bindTo, event, closure); 44 this.element.delegate(bindTo, event, closure);
42 } else { 45 } else {
43 if (this.isCustomEvent(event)) { 46 if (this.isCustomEvent(event)) {
44 this.subscribe(event, closure); 47 this.subscribe(event, closure);