Browse Source

Added a bunch of appData events which might be useful to plugins.

pull/51/head
Simon Eisenmann 12 years ago
parent
commit
bf6d017439
  1. 5
      static/js/controllers/mediastreamcontroller.js
  2. 5
      static/js/directives/chat.js
  3. 19
      static/js/services/appdata.js

5
static/js/controllers/mediastreamcontroller.js

@ -431,7 +431,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
}, 0); }, 0);
} }
appData.e.triggerHandler("selfReceived", data); appData.e.triggerHandler("selfReceived", [data]);
}); });
@ -489,6 +489,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
from: from from: from
}); });
}, 30000); }, 30000);
appData.e.triggerHandler("uiNotification", ["incoming", {from: from}]);
}); });
mediaStream.webrtc.e.on("error", function(event, message, msgid) { mediaStream.webrtc.e.on("error", function(event, message, msgid) {
@ -740,6 +741,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
playSound.play("connect"); playSound.play("connect");
} }
}); });
appData.e.triggerHandler("mainStatus", [status]);
}); });
$scope.$on("notification", function(event, type, details) { $scope.$on("notification", function(event, type, details) {
@ -765,6 +767,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
playSound.play("question"); playSound.play("question");
alertify.dialog.alert(message); alertify.dialog.alert(message);
} }
appData.e.triggerHandler("uiNotification", [type, details]);
}); });
$scope.$on("download", function(event, from, token) { $scope.$on("download", function(event, from, token) {

5
static/js/directives/chat.js

@ -346,8 +346,13 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
if (!subscope.isgroupchat && from !== sessionid) { if (!subscope.isgroupchat && from !== sessionid) {
playSound.play("message1"); playSound.play("message1");
desktopNotify.notify(translation._("Message from ") + displayName(from), message); desktopNotify.notify(translation._("Message from ") + displayName(from), message);
appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]);
} }
subscope.firstmessage = false; subscope.firstmessage = false;
} else {
if (!subscope.isgroupchat && from !== sessionid) {
appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]);
}
} }
}); });
chat(subscope, function(clonedElement, $scope) { chat(subscope, function(clonedElement, $scope) {

19
static/js/services/appdata.js

@ -20,9 +20,22 @@
*/ */
define(["jquery"], function($) { define(["jquery"], function($) {
// appData.e events // appData.e events:
// - authenticationChanged(userid) // subscribe these events with appData.e.on(eventname, function() {}).
// - selfReceived(self) //
// - authenticationChanged(event, userid)
// userid (string) : Public user id of the authenitcated user.
//
// - selfReceived(event, self)
// self (object) : Self document as received from API.
//
// - uiNotification(event, type, details)
// type (string) : Notification type (busy, reject, pickuptimeout,
// incomingbusy, incomingpickuptimeout, chatmessage)
// details (object) : Depends on event type.
//
// - mainStatus(event, status)
// status (string) : Status id (connected, waiting, ...)
// appData // appData
return [function() { return [function() {

Loading…
Cancel
Save