Browse Source

Create contactsmanager service for contact dialogs and data.

pull/88/head
Evan Theurer 12 years ago
parent
commit
367b9d67e8
  1. 1
      static/js/directives/settings.js
  2. 8
      static/js/services/contacts.js
  3. 81
      static/js/services/contactsmanager.js
  4. 3
      static/js/services/services.js
  5. 2
      static/partials/settings.html

1
static/js/directives/settings.js

@ -36,6 +36,7 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t @@ -36,6 +36,7 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
$scope.withUsers = mediaStream.config.UsersEnabled;
$scope.withUsersRegistration = mediaStream.config.UsersAllowRegistration;
$scope.withUsersMode = mediaStream.config.UsersMode;
$scope.contactsManager = contactsManager;
_.each(availableLanguages, function(name, code) {
$scope.availableLanguages.push({

8
static/js/services/contacts.js

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmanager.html', 'text!partials/contactsmanageredit.html'], function(_, $, Modernizr, sjcl, templateContactsManager, templateContactsManagerEdit) {
define(['underscore', 'jquery', 'modernizr', 'sjcl'], function(_, $, Modernizr, sjcl) {
var Database = function(name) {
this.version = 3;
@ -121,11 +121,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana @@ -121,11 +121,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
};
// contacts
return ["appData", "contactData", "mediaStream", "$templateCache", function(appData, contactData, mediaStream, $templateCache) {
// Inject our templates.
$templateCache.put('/contactsmanager/main.html', templateContactsManager);
$templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit);
return ["appData", "contactData", "mediaStream", function(appData, contactData, mediaStream) {
var Contacts = function() {

81
static/js/services/contactsmanager.js

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
/*
* Spreed WebRTC.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed WebRTC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
define(['underscore', 'jquery', 'modernizr', 'text!partials/contactsmanager.html', 'text!partials/contactsmanageredit.html'], function(_, $, Modernizr, templateContactsManager, templateContactsManagerEdit) {
return ["dialogs", "translation", "$templateCache", function(dialogs, translation, $templateCache) {
// Inject our templates.
$templateCache.put('/contactsmanager/main.html', templateContactsManager);
$templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit);
var ContactsManager = {};
ContactsManager._mainDialog = function() {
return dialogs.create(
"/contactsmanager/main.html",
"ContactsmanagerController",
{
header: translation._("Contacts Manager")
}, {
wc: "contactsmanager"
}
);
};
ContactsManager._editDialog = function(contact) {
return dialogs.create(
"/contactsmanager/edit.html",
"ContactsmanagerController",
{
header: translation._("Edit Contact"),
contact: contact,
}, {
wc: "contactsmanager"
}
);
};
ContactsManager.setupContactsManager = function() {
var dlgMain = null;
var that = this;
dlgMain = that._mainDialog();
dlgMain.result.then(function(contact) {
if(contact && contact.Id) {
that.setupContactsManagerEdit(contact);
}
});
};
ContactsManager.setupContactsManagerEdit = function(contact) {
var dlgEdit = null;
var that = this;
dlgEdit = that._editDialog(contact);
dlgEdit.result.finally(function(final) {
that.setupContactsManager();
});
};
ContactsManager.open = function() {
this.setupContactsManager();
};
return ContactsManager;
}];
});

3
static/js/services/services.js

@ -47,6 +47,7 @@ define([ @@ -47,6 +47,7 @@ define([
'services/videolayout',
'services/contactdata',
'services/contacts',
'services/contactsmanager',
'services/buddysession',
'services/localstorage',
'services/animationframe',
@ -83,6 +84,7 @@ videoWaiter, @@ -83,6 +84,7 @@ videoWaiter,
videoLayout,
contactData,
contacts,
contactsManager,
buddySession,
localStorage,
animationFrame,
@ -121,6 +123,7 @@ localStatus) { @@ -121,6 +123,7 @@ localStatus) {
videoLayout: videoLayout,
contactData: contactData,
contacts: contacts,
contactsManager: contactsManager,
buddySession: buddySession,
localStorage: localStorage,
animationFrame: animationFrame,

2
static/partials/settings.html

@ -70,7 +70,7 @@ @@ -70,7 +70,7 @@
<div class="form-group" ng-if="userid">
<label class="col-xs-4 control-label">{{_('Contacts')}}</label>
<div class="col-xs-8">
<p class="form-control-static"><a ng-click="openContactsManager()">{{_('Manage contacts')}}</a></p>
<p class="form-control-static"><a ng-click="contactsManager.open()">{{_('Manage contacts')}}</a></p>
</div>
</div>
</div>

Loading…
Cancel
Save