diff --git a/apps/communications/dialer/js/add_contact_menu.js b/apps/communications/dialer/js/add_contact_menu.js index 13b4a14a207b..17911556b13c 100644 --- a/apps/communications/dialer/js/add_contact_menu.js +++ b/apps/communications/dialer/js/add_contact_menu.js @@ -37,11 +37,13 @@ var AddContactMenu = (function() { items: [{ l10nId: 'createNewContact', method: _createNewContact, - params: [phoneNumber] + params: [phoneNumber], + hideTimeout: 300 },{ l10nId: 'addToExistingContact', method: _addToExistingContact, - params: [phoneNumber] + params: [phoneNumber], + hideTimeout: 300 },{ // Last item is the Cancel button l10nId: 'cancel', incomplete: true diff --git a/shared/js/option_menu.js b/shared/js/option_menu.js index 5fd383839767..e567be47ec6b 100644 --- a/shared/js/option_menu.js +++ b/shared/js/option_menu.js @@ -169,7 +169,7 @@ var OptionMenu = function(options) { menu.addEventListener('click', function(event) { var action = handlers.get(event.target); - var method; + var method, timeout; // Delegate operation to target method. This allows // for a custom "Cancel" to be provided by calling program. @@ -180,9 +180,10 @@ var OptionMenu = function(options) { method = action.method || function() {}; method.apply(null, action.params || []); + timeout = action.hideTimeout; // Hide action menu when click is received - this.hide(); + timeout ? this.hideTimeout(timeout) : this.hide(); if (typeof options.complete === 'function' && !action.incomplete) { options.complete(); @@ -212,3 +213,7 @@ OptionMenu.prototype.show = function() { OptionMenu.prototype.hide = function() { this.form.classList.remove('visible'); }; + +OptionMenu.prototype.hideTimeout = function(timeout) { + setTimeout(this.hide.bind(this), timeout); +};