summaryrefslogtreecommitdiffstats
path: root/projecttemplates/WebFormsRelyingParty/scripts/LoginLink.js
blob: 1e479652935497f5fa925a8f63db01609b9fbebf (plain)
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
53
54
55
56
57
58
59
60
61
$(function() {
	var loginContent = 'LoginFrame.aspx';
	var popupWindowName = 'openidlogin';
	var popupWidth = 365;
	var popupHeight = 273; // use 205 for 1 row of OP buttons, or 273 for 2 rows
	var iframe;

	{
		var div = window.document.createElement('div');
		div.style.padding = 0;
		div.id = 'loginDialog';

		iframe = window.document.createElement('iframe');
		iframe.src = "about:blank"; // don't set the actual page yet, since FireFox & Chrome will refresh it when the iframe is moved in the DOM anyway.
		iframe.frameBorder = 0;
		iframe.width = popupWidth;
		iframe.height = popupHeight;
		div.appendChild(iframe);

		window.document.body.appendChild(div);
	}

	$(document).ready(function() {
		$("#loginDialog").dialog({
			bgiframe: true,
			modal: true,
			title: 'Login or register',
			resizable: false,
			hide: 'clip',
			width: popupWidth,
			height: popupHeight + 50,
			buttons: {},
			closeOnEscape: true,
			autoOpen: false,
			close: function(event, ui) {
				// Clear the URL so Chrome/Firefox don't refresh the iframe when it's hidden.
				iframe.src = "about:blank";
			},
			open: function(event, ui) {
				iframe.src = loginContent;
			},
			focus: function(event, ui) {
				//				var box = $('#openid_identifier')[0];
				//				if (box.style.display != 'none') {
				//					box.focus();
				//				}
			}
		});

		$('.loginPopupLink').click(function() {
			$("#loginDialog").dialog('open');
		});
		$('.loginWindowLink').click(function() {
			if (window.showModalDialog) {
				window.showModalDialog(loginContent, popupWindowName, 'status:0;resizable:1;scroll:1;center:1;dialogHeight:' + popupHeight + 'px;dialogWidth:' + popupWidth + 'px');
			} else {
				window.open(loginContent, popupWindowName, 'modal=yes,status=0,location=1,toolbar=0,menubar=0,resizable=0,scrollbars=0,height=' + popupHeight + 'px,width=' + popupWidth + 'px');
			}
		});
	});
});