1 | {combine_css path=$OAUTH_PATH|cat:'template/oauth_sprites.css'} |
---|
2 | |
---|
3 | {html_style}{literal} |
---|
4 | #openid_form { |
---|
5 | padding:20px; |
---|
6 | } |
---|
7 | #openid_form h3, #openid_form .oauth_38px { |
---|
8 | display:inline-block; |
---|
9 | vertical-align:middle; |
---|
10 | margin:0; |
---|
11 | } |
---|
12 | #openid_label.error { |
---|
13 | color:red; |
---|
14 | font-weight:bold; |
---|
15 | } |
---|
16 | {/literal}{/html_style} |
---|
17 | |
---|
18 | {combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'} |
---|
19 | {combine_css path="themes/default/js/plugins/colorbox/style2/colorbox.css"} |
---|
20 | |
---|
21 | {footer_script}{literal} |
---|
22 | // redirect, called from the popup |
---|
23 | function redirect(type) { |
---|
24 | {/literal} |
---|
25 | url = "{$REDIRECT_TO}"; |
---|
26 | if (typeof type != 'undefined' && type != 'default') {ldelim} |
---|
27 | url = "{$ABS_ROOT_URL}"+ type +".php"; |
---|
28 | } |
---|
29 | {literal} |
---|
30 | window.location.href = url; |
---|
31 | } |
---|
32 | |
---|
33 | // open authentication popup |
---|
34 | function open_auth(url) { |
---|
35 | window.open( |
---|
36 | url+ "&t=" + (new Date()).getTime(), |
---|
37 | "hybridauth_social_sing_on", |
---|
38 | "location=0,status=0,scrollbars=0,width=800,height=500" |
---|
39 | ); |
---|
40 | } |
---|
41 | |
---|
42 | // click on a button |
---|
43 | jQuery("a.oauth").click(function() { |
---|
44 | var idp = jQuery(this).data('idp'); |
---|
45 | |
---|
46 | switch(idp) { |
---|
47 | case 'OpenID': case 'Wordpress': case 'Flickr': |
---|
48 | switch(idp) { |
---|
49 | {/literal} |
---|
50 | case 'OpenID': |
---|
51 | jQuery("#openid_label").html('{'Please enter your OpenID URL'|@translate|escape:javascript}'); break; |
---|
52 | case 'Wordpress': case 'Flickr': |
---|
53 | jQuery("#openid_label").html('{'Please enter your username'|@translate|escape:javascript}'); break; |
---|
54 | } |
---|
55 | |
---|
56 | jQuery("#openid_form").css('background-color', $("#the_page #content").css('background-color')); |
---|
57 | jQuery("#openid_form .oauth_38px").removeClass().addClass("oauth_38px " + idp.toLowerCase()); |
---|
58 | jQuery("#openid_form h3").html(idp); |
---|
59 | jQuery("#openid_form").data('idp', idp); |
---|
60 | {literal} |
---|
61 | jQuery.colorbox({ |
---|
62 | inline:true, |
---|
63 | href:"#openid_form", |
---|
64 | initialWidth:0, |
---|
65 | initialHeight:0, |
---|
66 | onComplete:function(){ jQuery.colorbox.resize({speed:0}) } // prevent misalignement when icon not loaded |
---|
67 | }) |
---|
68 | break; |
---|
69 | |
---|
70 | default: |
---|
71 | {/literal} |
---|
72 | open_auth("{$OAUTH_URL}"+ idp); |
---|
73 | {literal} |
---|
74 | } |
---|
75 | |
---|
76 | return false; |
---|
77 | }); |
---|
78 | |
---|
79 | jQuery("#openid_form").submit(function() { |
---|
80 | var idp = jQuery(this).data('idp'); |
---|
81 | var oi = jQuery("#openid_form input[name='openid_identifier']").val(); |
---|
82 | jQuery("#openid_form input[name='openid_identifier']").val(''); |
---|
83 | |
---|
84 | jQuery("#openid_label").removeClass('error'); |
---|
85 | if (!oi) { |
---|
86 | jQuery("#openid_label").addClass('error'); |
---|
87 | return false; |
---|
88 | } |
---|
89 | |
---|
90 | switch(idp) { |
---|
91 | case 'Wordpress': oi = "http://" + oi + ".wordpress.com"; break; |
---|
92 | case 'Flickr': oi = "http://www.flickr.com/photos/" + oi + "/"; break; |
---|
93 | } |
---|
94 | {/literal} |
---|
95 | open_auth("{$OAUTH_URL}OpenID&openid_identifier="+ encodeURI(oi)); |
---|
96 | {literal} |
---|
97 | jQuery.colorbox.close(); |
---|
98 | return false; |
---|
99 | }); |
---|
100 | |
---|
101 | jQuery("#openid_cancel").click(function() { |
---|
102 | jQuery("#openid_label").removeClass('error'); |
---|
103 | jQuery.colorbox.close(); |
---|
104 | return false; |
---|
105 | }); |
---|
106 | {/literal}{/footer_script} |
---|
107 | |
---|
108 | <div style="display:none;"> |
---|
109 | <form id="openid_form" action=""> |
---|
110 | <div> |
---|
111 | <span class="oauth_38px"></span> |
---|
112 | <h3>OpendID</h3> |
---|
113 | </div> |
---|
114 | <div> |
---|
115 | <br> |
---|
116 | <label id="openid_label" for="openid_identifier">Open ID URL</label> |
---|
117 | <br> |
---|
118 | <input type="text" name="openid_identifier" id="openid_identifier" size="50"> |
---|
119 | </div> |
---|
120 | <div> |
---|
121 | <br> |
---|
122 | <input type="submit" name="{'Submit'|@translate}"> |
---|
123 | <a href="#" id="openid_cancel">{'Cancel'|@translate}</a> |
---|
124 | </div> |
---|
125 | </form> |
---|
126 | </div> |
---|