diff --git a/apps/communications/dialer/index.html b/apps/communications/dialer/index.html index a91a7e3edb34..deb6d5c9fa9e 100644 --- a/apps/communications/dialer/index.html +++ b/apps/communications/dialer/index.html @@ -111,7 +111,6 @@ - @@ -246,8 +245,9 @@

- + diff --git a/apps/communications/dialer/js/dialer.js b/apps/communications/dialer/js/dialer.js index e5b4dbdec812..8d20dc84e927 100644 --- a/apps/communications/dialer/js/dialer.js +++ b/apps/communications/dialer/js/dialer.js @@ -349,7 +349,7 @@ var CallHandler = (function callHandler() { }; var oncall = function() { - SuggestionBar.hideOverlay(); + SuggestionBar.overlay && SuggestionBar.overlay.hide(); SuggestionBar.clear(); }; diff --git a/apps/communications/dialer/js/suggestion_bar.js b/apps/communications/dialer/js/suggestion_bar.js index 5beca78b6343..cb55fabd2081 100644 --- a/apps/communications/dialer/js/suggestion_bar.js +++ b/apps/communications/dialer/js/suggestion_bar.js @@ -25,7 +25,6 @@ var SuggestionBar = { countTag: null, list: null, overlay: null, - overlayCancel: null, template: null, init: function sb_init() { @@ -67,7 +66,7 @@ var SuggestionBar = { }); }); } else { - this.hideOverlay(); + this.overlay.hide(); } }, @@ -249,7 +248,7 @@ var SuggestionBar = { itemElm.removeAttribute('id'); itemElm.hidden = false; itemElm.classList.add('ci--action-menu'); - this.list.insertBefore(itemElm, this.overlayCancel); + this.overlay.appendChild(itemElm); return itemElm; }, @@ -346,26 +345,19 @@ var SuggestionBar = { return fragment; }, - _initOverlay: function() { - if (this.list) { - return; - } - - this.list = document.getElementById('contact-list'); - this.overlayCancel = document.getElementById('contact-list-overlay-cancel'); - this.overlayCancel.addEventListener('click', this.hideOverlay.bind(this)); - }, - _clearOverlay: function() { - while (this.list.firstElementChild != this.overlayCancel) { - this.list.firstElementChild.remove(); - } + Array.slice(this.overlay.querySelectorAll('button')).forEach(button => { + this.overlay.removeChild(button); + }); }, showOverlay: function sb_showOverlay() { var self = this; - LazyLoader.load(this.overlay, function() { - self._initOverlay(); + var overlayResources = [ + '/shared/js/component_utils.js', + '/shared/elements/gaia_menu/script.js' + ]; + LazyLoader.load(overlayResources, function() { self._clearOverlay(); var title = self.overlay.querySelector('header'); navigator.mozL10n.setAttributes( @@ -383,7 +375,7 @@ var SuggestionBar = { self._allMatched.allMatches[i][j], node); } } - self.overlay.setAttribute('aria-hidden', false); + self.overlay.show(); self.overlay.classList.add('display'); }); }, @@ -398,11 +390,6 @@ var SuggestionBar = { }); return SimplePhoneMatcher.bestMatch(variants, contactTels); - }, - - hideOverlay: function sb_hideOverlay() { - this.overlay.setAttribute('aria-hidden', true); - this.overlay.classList.remove('display'); } }; diff --git a/apps/communications/dialer/test/unit/suggestion_bar_test.js b/apps/communications/dialer/test/unit/suggestion_bar_test.js index 578fdf8ec7f4..922a31d3c2a4 100644 --- a/apps/communications/dialer/test/unit/suggestion_bar_test.js +++ b/apps/communications/dialer/test/unit/suggestion_bar_test.js @@ -4,6 +4,9 @@ 'use strict'; +require('/shared/js/component_utils.js'); +require('/shared/elements/gaia_menu/script.js'); + require('/shared/test/unit/mocks/mock_navigator_moz_icc_manager.js'); require('/shared/test/unit/mocks/mock_lazy_loader.js'); require('/dialer/test/unit/mock_call_handler.js'); @@ -120,9 +123,6 @@ suite('suggestion Bar', function() { loadBodyHTML('/shared/elements/contacts/contact_in_overlay.html'); var suggestionItemTemplate = document.body.querySelector('template'); - loadBodyHTML('/shared/elements/contacts/contact_list_overlay.html'); - var suggestionOverlayTemplate = document.body.querySelector('template'); - domSuggestionBar = document.createElement('section'); domSuggestionBar.id = 'suggestion-bar'; domSuggestionBar.classList.add('hide'); @@ -147,15 +147,11 @@ suite('suggestion Bar', function() { domSuggestionItem.appendChild( suggestionItemTemplate.content.cloneNode(true)); - domOverlay = document.createElement('form'); + domOverlay = document.createElement('gaia-menu'); domOverlay.id = 'contact-list-overlay'; - domOverlay.setAttribute('is', 'contact-list-overlay'); - domOverlay.setAttribute('role', 'dialog'); - domOverlay.dataset.type = 'action'; domOverlay.classList.add('overlay'); - domOverlay.setAttribute('aria-hidden', 'true'); - domOverlay.innerHTML = ''; - domOverlay.appendChild(suggestionOverlayTemplate.content.cloneNode(true)); + domOverlay.setAttribute('hidden', 'true'); + domOverlay.innerHTML = '
'; document.body.appendChild(domOverlay); domSuggestionCount = domSuggestionBar.querySelector('#suggestion-count'); @@ -163,9 +159,7 @@ suite('suggestion Bar', function() { subject.overlay = domOverlay; subject.bar = domSuggestionBar; subject.countTag = document.getElementById('suggestion-count'); - subject.list = document.getElementById('contact-list'); - subject.overlayCancel = - document.getElementById('contact-list-overlay-cancel'); + subject.list = document.querySelector('gaia-menu'); subject.init(); this.sinon.spy(MockL10n, 'setAttributes'); @@ -405,20 +399,14 @@ suite('suggestion Bar', function() { }); test('should load the overlay', function() { - sinon.assert.calledWith(LazyLoader.load, domOverlay); + sinon.assert.called(LazyLoader.load); }); test('overlay is displayed', function() { - assert.equal(subject.overlay.getAttribute('aria-hidden'), 'false'); + assert.equal(subject.overlay.hasAttribute('hidden'), false); assert.isTrue(subject.overlay.classList.contains('display')); }); - test('should have a cancel button as the last button', function() { - var buttons = subject.list.children; - var cancel = buttons[buttons.length - 1]; - assert.equal(cancel.id, 'contact-list-overlay-cancel'); - }); - test('should have 2 suggestions', function() { assert.equal(suggestions.length, 2); }); @@ -480,12 +468,8 @@ suite('suggestion Bar', function() { }); suite('hide overlay', function() { - setup(function() { - subject.hideOverlay(); - }); - test('should hide the overlay', function() { - assert.equal(subject.overlay.getAttribute('aria-hidden'), 'true'); + assert.equal(subject.overlay.getAttribute('hidden'), 'true'); assert.isFalse(subject.overlay.classList.contains('display')); }); }); @@ -497,7 +481,7 @@ suite('suggestion Bar', function() { subject.showOverlay(); assert.equal( - subject.overlay.querySelector('#contact-list').childElementCount, + subject.overlay.childElementCount, 4, 'should have 3 items + cancel button into overlay list'); assert.isFalse(subject.overlay.hidden, 'should show suggestion list'); }); @@ -505,7 +489,6 @@ suite('suggestion Bar', function() { suite('#tap on suggestions list', function() { setup(function() { this.sinon.spy(MockCallHandler, 'call'); - this.sinon.spy(subject, 'hideOverlay'); MockContacts.mResult = mockResult1; subject.update('1234'); @@ -524,7 +507,6 @@ suite('suggestion Bar', function() { document.body.querySelector('.js-suggestion-item').click(); sinon.assert.notCalled(MockCallHandler.call); - sinon.assert.calledOnce(subject.hideOverlay); }); }); diff --git a/apps/emergency-call/index.html b/apps/emergency-call/index.html index ceab4c57f8ea..a2802bf75473 100644 --- a/apps/emergency-call/index.html +++ b/apps/emergency-call/index.html @@ -21,7 +21,6 @@ - @@ -58,7 +57,6 @@ -
@@ -142,8 +140,9 @@
- + diff --git a/apps/emergency-call/js/ice_contacts.js b/apps/emergency-call/js/ice_contacts.js index a4535d08a5bc..6c4e77071cb6 100644 --- a/apps/emergency-call/js/ice_contacts.js +++ b/apps/emergency-call/js/ice_contacts.js @@ -6,9 +6,7 @@ var iceContactsDetails = [], iceContactsBar, contactListOverlay, - contactInOverlay, - contactList, - contactListCancel; + contactInOverlay; function init() { if (ICEContacts._initialized) { @@ -19,16 +17,16 @@ contactListOverlay = document.getElementById('contact-list-overlay'); contactInOverlay = document.getElementById('contact-in-overlay'); - LazyLoader.load([contactListOverlay], function() { + var contactsListOverlayResources = [ + '/shared/js/component_utils.js', + '/shared/elements/gaia_menu/script.js' + ]; + + LazyLoader.load(contactsListOverlayResources, function() { var contactListOverlayHeader = contactListOverlay.querySelector('header'); contactListOverlayHeader.dataset.l10nId = 'ice-contacts-overlay-title'; - contactList = document.getElementById('contact-list'); - contactListCancel = - document.getElementById('contact-list-overlay-cancel'); - iceContactsBar.addEventListener('click', showICEContactOverlay); - contactListCancel.addEventListener('click', hideICEContactOverlay); ICEContacts._initialized = true; }); @@ -39,15 +37,11 @@ } function showICEContactOverlay() { - contactListOverlay.classList.add('display'); - } - - function hideICEContactOverlay() { - contactListOverlay.classList.remove('display'); + contactListOverlay.show(); } function callICEContact(number) { - hideICEContactOverlay(); + contactListOverlay.hide(); CallHandler.call(number); } @@ -86,7 +80,7 @@ tel.type[0]; iceContactOverlayEntry.querySelector('.js-tel').textContent = tel.value; - contactList.insertBefore(iceContactOverlayEntry, contactListCancel); + contactListOverlay.appendChild(iceContactOverlayEntry); iceContactOverlayEntry.addEventListener('click', callICEContact.bind(null, tel.value)); // Set the ICE contacts bar visible as soon as there is some diff --git a/apps/emergency-call/test/unit/ice_contacts_test.js b/apps/emergency-call/test/unit/ice_contacts_test.js index 33f3994410bf..64caedc273bb 100644 --- a/apps/emergency-call/test/unit/ice_contacts_test.js +++ b/apps/emergency-call/test/unit/ice_contacts_test.js @@ -37,15 +37,10 @@ suite('ICE contacts bar', function() { iceContactBar.textContent = 'ICE Contacts - In Case of Emergency'; container.appendChild(iceContactBar); - loadBodyHTML('/shared/elements/contacts/contact_list_overlay.html'); - var iceContactsOverlayTemplate = document.body.querySelector('template'); - iceContactsOverlay = document.createElement('form'); + iceContactsOverlay = document.createElement('gaia-menu'); + iceContactsOverlay.innerHTML = '
'; iceContactsOverlay.id = 'contact-list-overlay'; - iceContactsOverlay.setAttribute('role', 'dialog'); - iceContactsOverlay.setAttribute('data-type', 'action'); iceContactsOverlay.classList.add('overlay'); - iceContactsOverlay.appendChild( - iceContactsOverlayTemplate.content.cloneNode(true)); container.appendChild(iceContactsOverlay); loadBodyHTML('/shared/elements/contacts/contact_in_overlay.html'); @@ -60,7 +55,7 @@ suite('ICE contacts bar', function() { document.body.appendChild(container); - iceContactList = document.getElementById('contact-list'); + iceContactList = document.querySelector('gaia-menu'); } function shouldNotShowICEContactsBar(done) { @@ -103,7 +98,7 @@ suite('ICE contacts bar', function() { test('Lazyloads contact list overlay', function(done) { this.sinon.spy(MockLazyLoader, 'load'); ICEContacts.updateICEContacts().then(function() { - sinon.assert.calledWith(MockLazyLoader.load, [iceContactsOverlay]); + sinon.assert.called(MockLazyLoader.load); done(); }); }); @@ -443,11 +438,6 @@ suite('ICE contacts bar', function() { contact1.tel[0].value); }); - test('Should include cancel button', function() { - assert.ok( - iceContactsOverlay.querySelector('#contact-list-overlay-cancel')); - }); - test('Tapping a contact dials them', function() { this.sinon.spy(CallHandler, 'call'); iceContactsOverlay.querySelector('button').click(); diff --git a/build/csslint/xfail.list b/build/csslint/xfail.list index e9e8bf001230..283effd1ed3f 100644 --- a/build/csslint/xfail.list +++ b/build/csslint/xfail.list @@ -144,6 +144,7 @@ shared/style/action_menu.css 3 1 shared/style/buttons.css 7 0 shared/style/confirm.css 7 0 shared/style/contacts/contacts_buttons.css 0 7 +shared/style/contacts/contact_in_overlay.css 0 3 shared/style/date_selector.css 1 0 shared/style/dialer/dialer.css 0 1 shared/style/dialer/keypad.css 1 0 diff --git a/shared/elements/contacts/contact_list_overlay.html b/shared/elements/contacts/contact_list_overlay.html deleted file mode 100644 index 80f94eea3d2f..000000000000 --- a/shared/elements/contacts/contact_list_overlay.html +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/shared/style/contacts/contact_in_overlay.css b/shared/style/contacts/contact_in_overlay.css index e767759b024b..d8cd614832eb 100644 --- a/shared/style/contacts/contact_in_overlay.css +++ b/shared/style/contacts/contact_in_overlay.css @@ -1,8 +1,9 @@ /* Overrides building blocks */ -#contact-list .contact-item { - height: auto; - padding-top: 1rem; - padding-bottom: 1rem; +/* TODO, move into web component styles. Bug 1225857 */ +#contact-list-overlay .contact-item { + height: auto !important; + padding-top: 1rem !important; + padding-bottom: 1rem !important; } /* End overrides building blocks */