source: extensions/oAuth/template/identification_common.tpl @ 26604

Last change on this file since 26604 was 26604, checked in by mistic100, 10 years ago

clean templating + allow to use Steam/Wordpress/Flickr without displaying OpenID

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