VulpesOS/gaia/apps/communications/dialer/js/add_contact_menu.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

60 lines
1.4 KiB
JavaScript
Executable file

'use strict';
/* exported AddContactMenu */
/* globals LazyLoader, MozActivity, OptionMenu */
var AddContactMenu = (function() {
var _createNewContact = function(phoneNumber) {
launchActivity('new', phoneNumber);
};
var _addToExistingContact = function(phoneNumber) {
launchActivity('update', phoneNumber);
};
var launchActivity = function(name, phoneNumber) {
try {
/* jshint nonew: false */
new MozActivity({
name: name,
data: {
type: 'webcontacts/contact',
params: {
'tel': phoneNumber
}
}
});
} catch (e) {
console.error('Error while creating activity');
}
};
return {
show: function(phoneNumber) {
var params = {
items: [{
l10nId: 'createNewContact',
method: _createNewContact,
params: [phoneNumber]
},{
l10nId: 'addToExistingContact',
method: _addToExistingContact,
params: [phoneNumber]
},{ // Last item is the Cancel button
l10nId: 'cancel',
incomplete: true
}],
header: phoneNumber
};
LazyLoader.load(['/shared/js/option_menu.js',
'/shared/style/action_menu.css'], function() {
/* jshint nonew: false */
new OptionMenu(params).show();
});
}
};
}());