265 this.__events[_event] = []; |
265 this.__events[_event] = []; |
266 } |
266 } |
267 this.__events[_event].push(_callback); |
267 this.__events[_event].push(_callback); |
268 } |
268 } |
269 |
269 |
|
270 IriSP.Model.List.prototype.off = function(_event, _callback) { |
|
271 if (typeof this.__events[_event] !== "undefined") { |
|
272 this.__events[_event] = IriSP._(this.__events[_event]).reject(function(_fn) { |
|
273 return _fn === _callback; |
|
274 }); |
|
275 } |
|
276 } |
|
277 |
270 IriSP.Model.List.prototype.trigger = function(_event, _data) { |
278 IriSP.Model.List.prototype.trigger = function(_event, _data) { |
271 var _list = this; |
279 var _list = this; |
272 IriSP._(this.__events[_event]).each(function(_callback) { |
280 IriSP._(this.__events[_event]).each(function(_callback) { |
273 _callback.call(_list, _data); |
281 _callback.call(_list, _data); |
274 }); |
282 }); |
419 IriSP.Model.Element.prototype.getRelated = function(_elementType, _global) { |
427 IriSP.Model.Element.prototype.getRelated = function(_elementType, _global) { |
420 _global = (typeof _global !== "undefined" && _global); |
428 _global = (typeof _global !== "undefined" && _global); |
421 var _this = this; |
429 var _this = this; |
422 return this.source.getList(_elementType, _global).filter(function(_el) { |
430 return this.source.getList(_elementType, _global).filter(function(_el) { |
423 var _ref = _el[_this.elementType]; |
431 var _ref = _el[_this.elementType]; |
424 return _ref.isOrHasId(_this.id); |
432 return _ref && _ref.isOrHasId(_this.id); |
425 }); |
433 }); |
426 } |
434 } |
427 |
435 |
428 IriSP.Model.Element.prototype.on = function(_event, _callback) { |
436 IriSP.Model.Element.prototype.on = function(_event, _callback) { |
429 if (typeof this.__events[_event] === "undefined") { |
437 if (typeof this.__events[_event] === "undefined") { |
430 this.__events[_event] = []; |
438 this.__events[_event] = []; |
431 } |
439 } |
432 this.__events[_event].push(_callback); |
440 this.__events[_event].push(_callback); |
|
441 } |
|
442 |
|
443 IriSP.Model.Element.prototype.off = function(_event, _callback) { |
|
444 if (typeof this.__events[_event] !== "undefined") { |
|
445 this.__events[_event] = IriSP._(this.__events[_event]).reject(function(_fn) { |
|
446 return _fn === _callback; |
|
447 }); |
|
448 } |
433 } |
449 } |
434 |
450 |
435 IriSP.Model.Element.prototype.trigger = function(_event, _data) { |
451 IriSP.Model.Element.prototype.trigger = function(_event, _data) { |
436 var _element = this; |
452 var _element = this; |
437 IriSP._(this.__events[_event]).each(function(_callback) { |
453 IriSP._(this.__events[_event]).each(function(_callback) { |
533 IriSP.Model.Annotation = function(_id, _source) { |
549 IriSP.Model.Annotation = function(_id, _source) { |
534 IriSP.Model.Element.call(this, _id, _source); |
550 IriSP.Model.Element.call(this, _id, _source); |
535 this.elementType = 'annotation'; |
551 this.elementType = 'annotation'; |
536 this.begin = new IriSP.Model.Time(); |
552 this.begin = new IriSP.Model.Time(); |
537 this.end = new IriSP.Model.Time(); |
553 this.end = new IriSP.Model.Time(); |
|
554 this.tag = new IriSP.Model.Reference(_source, []); |
538 this.playing = false; |
555 this.playing = false; |
539 var _this = this; |
556 var _this = this; |
540 this.on("click", function() { |
557 this.on("click", function() { |
541 _this.getMedia().setCurrentTime(_this.begin); |
558 _this.getMedia().setCurrentTime(_this.begin); |
542 }); |
559 }); |
731 |
748 |
732 /* */ |
749 /* */ |
733 |
750 |
734 IriSP.Model.Source = function(_config) { |
751 IriSP.Model.Source = function(_config) { |
735 this.status = IriSP.Model._SOURCE_STATUS_EMPTY; |
752 this.status = IriSP.Model._SOURCE_STATUS_EMPTY; |
|
753 this.elementType = "source"; |
736 if (typeof _config !== "undefined") { |
754 if (typeof _config !== "undefined") { |
737 var _this = this; |
755 var _this = this; |
738 IriSP._(_config).forEach(function(_v, _k) { |
756 IriSP._(_config).forEach(function(_v, _k) { |
739 _this[_k] = _v; |
757 _this[_k] = _v; |
740 }) |
758 }) |
741 this.callbackQueue = []; |
759 this.callbackQueue = []; |
742 this.contents = {}; |
760 this.contents = {}; |
743 this.get(); |
761 this.get(); |
744 } |
762 } |
745 } |
763 } |
|
764 |
|
765 IriSP.Model.Source.prototype = new IriSP.Model.Element(); |
746 |
766 |
747 IriSP.Model.Source.prototype.addList = function(_listId, _contents) { |
767 IriSP.Model.Source.prototype.addList = function(_listId, _contents) { |
748 if (typeof this.contents[_listId] === "undefined") { |
768 if (typeof this.contents[_listId] === "undefined") { |
749 this.contents[_listId] = new IriSP.Model.List(this.directory); |
769 this.contents[_listId] = new IriSP.Model.List(this.directory); |
750 } |
770 } |