forked from mozilla/napkin
/
example.js
52 lines (46 loc) · 1.51 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require.config({
baseUrl: '/javascripts/'
});
require(['jquery', 'lib/bootstrap.min', 'https://browserid.org/include.js'], function($) {
$(function() {
var $body = $('body');
var $loginForm = $('header .login-form');
var $sidebar = $('#sidebar');
// Browser ID login
$loginForm.on('click', 'a', function(event) {
event.preventDefault();
navigator.id.getVerifiedEmail(function(assertion) {
if (assertion) {
$loginForm.find('input[name="bid_assertion"]').val(assertion);
$loginForm.submit();
}
});
});
// add faded overlay on top of sidebar and main content area
$('<div/>').css({
position: 'absolute',
top: 70,
left: 0,
// outerWidth/outerHeight = width/height with padding/border
width: $sidebar.outerWidth(),
height: $sidebar.outerHeight() - 70,
backgroundColor: 'rgba(0, 0, 0, 0.4)'
}).appendTo('body');
$('<div/>').css({
position: 'absolute',
top: 0,
left: $sidebar.outerWidth(),
// outerWidth/outerHeight = width/height with padding/border
width: $body.outerWidth() - $sidebar.outerWidth(),
height: $sidebar.outerHeight(),
backgroundColor: 'rgba(0, 0, 0, 0.4)'
}).appendTo('body');
$loginForm.children('a').popover({
title: 'Ready to prototype?',
content: 'Sign in with Persona to get started.',
trigger: 'manual',
placement: 'bottom'
}).popover('show');
});
});
require(['scripts/core', 'lib/bootstrap.min']);