CC-2301 : showing waveform cue/fade editors inside of a jquery dialog box.
This commit is contained in:
parent
811abc4baf
commit
13c8e5f146
23 changed files with 3090 additions and 1 deletions
57
airtime_mvc/public/js/waveformplaylist/observer/observer.js
Normal file
57
airtime_mvc/public/js/waveformplaylist/observer/observer.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
Code taken from http://www.jspatterns.com/book/7/observer-game.html
|
||||
|
||||
Pub/Sub
|
||||
*/
|
||||
|
||||
var publisher = {
|
||||
subscribers: {
|
||||
any: []
|
||||
},
|
||||
on: function (type, fn, context) {
|
||||
type = type || 'any';
|
||||
fn = typeof fn === "function" ? fn : context[fn];
|
||||
|
||||
if (typeof this.subscribers[type] === "undefined") {
|
||||
this.subscribers[type] = [];
|
||||
}
|
||||
this.subscribers[type].push({fn: fn, context: context || this});
|
||||
},
|
||||
remove: function (type, fn, context) {
|
||||
this.visitSubscribers('unsubscribe', type, fn, context);
|
||||
},
|
||||
fire: function (type, publication) {
|
||||
this.visitSubscribers('publish', type, publication);
|
||||
},
|
||||
reset: function (type) {
|
||||
this.subscribers[type] = undefined;
|
||||
},
|
||||
visitSubscribers: function (action, type, arg, context) {
|
||||
var pubtype = type || 'any',
|
||||
subscribers = this.subscribers[pubtype],
|
||||
i,
|
||||
max = subscribers ? subscribers.length : 0;
|
||||
|
||||
for (i = 0; i < max; i += 1) {
|
||||
if (action === 'publish') {
|
||||
subscribers[i].fn.call(subscribers[i].context, arg);
|
||||
}
|
||||
else {
|
||||
if (subscribers[i].fn === arg && subscribers[i].context === context) {
|
||||
subscribers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function makePublisher(o) {
|
||||
var i;
|
||||
for (i in publisher) {
|
||||
if (publisher.hasOwnProperty(i) && typeof publisher[i] === "function") {
|
||||
o[i] = publisher[i];
|
||||
}
|
||||
}
|
||||
o.subscribers = {any: []};
|
||||
}
|
57
airtime_mvc/public/js/waveformplaylist/observer/observer.js~
Normal file
57
airtime_mvc/public/js/waveformplaylist/observer/observer.js~
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
Code taken from http://www.jspatterns.com/book/7/observer-game.html
|
||||
|
||||
Pub/Sub
|
||||
*/
|
||||
|
||||
var publisher = {
|
||||
subscribers: {
|
||||
any: []
|
||||
},
|
||||
on: function (type, fn, context) {
|
||||
type = type || 'any';
|
||||
fn = typeof fn === "function" ? fn : context[fn];
|
||||
|
||||
if (typeof this.subscribers[type] === "undefined") {
|
||||
this.subscribers[type] = [];
|
||||
}
|
||||
this.subscribers[type].push({fn: fn, context: context || this});
|
||||
},
|
||||
remove: function (type, fn, context) {
|
||||
this.visitSubscribers('unsubscribe', type, fn, context);
|
||||
},
|
||||
fire: function (type, publication) {
|
||||
this.visitSubscribers('publish', type, publication);
|
||||
},
|
||||
reset: function (type) {
|
||||
|
||||
},
|
||||
visitSubscribers: function (action, type, arg, context) {
|
||||
var pubtype = type || 'any',
|
||||
subscribers = this.subscribers[pubtype],
|
||||
i,
|
||||
max = subscribers ? subscribers.length : 0;
|
||||
|
||||
for (i = 0; i < max; i += 1) {
|
||||
if (action === 'publish') {
|
||||
subscribers[i].fn.call(subscribers[i].context, arg);
|
||||
}
|
||||
else {
|
||||
if (subscribers[i].fn === arg && subscribers[i].context === context) {
|
||||
subscribers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function makePublisher(o) {
|
||||
var i;
|
||||
for (i in publisher) {
|
||||
if (publisher.hasOwnProperty(i) && typeof publisher[i] === "function") {
|
||||
o[i] = publisher[i];
|
||||
}
|
||||
}
|
||||
o.subscribers = {any: []};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue