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

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

finish updating guides, fix flow issues, update language file

File size: 4.7 KB
RevLine 
[20620]1{combine_css path=$OAUTH_PATH|cat:'template/oauth_sprites.css'}
2
[20293]3{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
[26556]4{combine_css id='colorbox' path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
[20293]5
[26605]6{if $OAUTH.providers.Persona.enabled}
7  {combine_script id='persona' path='https://login.persona.org/include.js' load='footer'}
8{/if}
9
[26556]10{html_style}
11#openid_form { padding:20px; }
12#openid_form h3, #openid_form .oauth_38px { display:inline-block; vertical-align:middle; margin:0; }
13#openid_label.error { color:red; font-weight:bold; }
14{/html_style}
15
16{footer_script}
[20293]17// redirect, called from the popup
[26604]18function oauth_redirect(type) {
19  var url = '{$OAUTH.u_redirect}';
20  if (type && type != 'default') {
21    url = '{$ABS_ROOT_URL}'+ type +'.php';
[20293]22  }
[26556]23
[20293]24  window.location.href = url;
25}
26
[20301]27// open authentication popup
[20369]28function open_auth(url) {
[20293]29  window.open(
[26608]30    '{$OAUTH.u_login}' + url + '&key={$OAUTH.key}',
[26604]31    'hybridauth_social_sign_on',
32    'location=0,status=0,scrollbars=0,width=800,height=500'
[20293]33  ); 
34}
35
36// click on a button
[26605]37jQuery('a.oauth:not(.persona)').click(function(e) {
[26604]38  e.preventDefault();
39 
[21584]40  var idp = jQuery(this).data('idp');
[20293]41 
[20369]42  switch(idp) {
[23808]43    case 'OpenID': case 'Wordpress': case 'Flickr': case 'Steam':
[20369]44      switch(idp) {
[20301]45        case 'OpenID':
[26604]46          jQuery('#openid_label').html('{'Please enter your OpenID URL'|translate|escape:javascript}'); break;
[26608]47        case 'Wordpress': case 'Steam':
[26604]48          jQuery('#openid_label').html('{'Please enter your username'|translate|escape:javascript}'); break;
[26608]49        case 'Flickr':
50          jQuery('#openid_label').html('{'Please enter your user ID'|translate|escape:javascript}'); break;
[20293]51      }
[20369]52     
[26556]53      var bg_color = $('#the_page #content').css('background-color');
54      if (!bg_color || bg_color=='transparent') {
55        bg_color = $('body').css('background-color');
56      }
[26604]57      jQuery('#openid_form').css('background-color', bg_color);
[26556]58
[26604]59      jQuery('#openid_form .oauth_38px').removeClass().addClass('oauth_38px ' + idp.toLowerCase());
60      jQuery('#openid_form h3').html(idp);
61      jQuery('#openid_form').data('idp', idp);
[26556]62
[21584]63      jQuery.colorbox({
[26604]64        inline: true,
65        href: '#openid_form',
66        initialWidth: 0,
67        initialHeight: 0,
68        mawWidth: '100%',
[26556]69        onComplete: function(){ jQuery.colorbox.resize({ speed:0 }) } // prevent misalignement when icon not loaded
[26604]70      });
[20293]71      break;
72     
73    default:
[26608]74      open_auth(idp);
[20293]75  }
76});
77
[26604]78jQuery('#openid_form').submit(function(e) {
79  e.preventDefault();
80 
[21584]81  var idp = jQuery(this).data('idp');
[26604]82  var oi = jQuery('#openid_form input[name=openid_identifier]').val();
83  jQuery('#openid_form input[name=openid_identifier]').val('');
[20293]84 
[26604]85  jQuery('#openid_label').removeClass('error');
[20369]86  if (!oi) {
[26604]87    jQuery('#openid_label').addClass('error');
88    return;
[20293]89  }
90 
[20369]91  switch(idp) {
[26604]92    case 'Wordpress': oi = 'http://' + oi + '.wordpress.com'; break;
93    case 'Flickr': oi = 'http://www.flickr.com/photos/' + oi + '/'; break;
94    case 'Steam': oi = 'http://steamcommunity.com/openid/' + oi; break;
[20293]95  }
[26556]96
[26608]97  open_auth('OpenID&openid_identifier=' + encodeURI(oi));
[26556]98
[21584]99  jQuery.colorbox.close();
[20293]100});
101
[26604]102jQuery('#openid_cancel').click(function(e) {
103  e.preventDefault();
104 
105  jQuery('#openid_label').removeClass('error');
[21584]106  jQuery.colorbox.close();
[20293]107});
[26605]108
109{if $OAUTH.providers.Persona.enabled}
110jQuery('a.oauth.persona').click(function(e) {
111  e.preventDefault();
112  navigator.id.request();
113});
114
[26608]115{if not empty($OAUTH.persona_email)}
[26605]116jQuery('a[href$="act=logout"]').click(function(e) {
117  e.preventDefault();
118  navigator.id.logout();
119});
[26608]120{/if}
[26605]121
122navigator.id.watch({
123  loggedInUser: {if not empty($OAUTH.persona_email)}'{$OAUTH.persona_email}'{else}null{/if},
124 
125  onlogin: function(assertion) {
126    jQuery.ajax({
127      type: 'POST',
128      url: '{$OAUTH.u_login}Persona',
129      dataType: 'json',
[26608]130      data: {
131        assertion: assertion,
132        key: '{$OAUTH.key}'
133      },
[26605]134      success: function(data) {
135        oauth_redirect(data.redirect_to);
136      },
137      error: function() {
138        alert('Unknown error');
139      }
140    });
141  },
142 
143  onlogout: function() {
144    window.location.href = '{$U_LOGOUT}';
145  }
146});
147{/if}
[26556]148{/footer_script}
[20293]149
150<div style="display:none;">
151  <form id="openid_form" action="">
152    <div>
[20620]153      <span class="oauth_38px"></span>
[20293]154      <h3>OpendID</h3>
155    </div>
156    <div>
[20323]157      <br>
[26604]158      <label id="openid_label" for="openid_identifier"></label>
[20293]159      <br>
160      <input type="text" name="openid_identifier" id="openid_identifier" size="50">
161    </div>
162    <div>
163      <br>
[26556]164      <input type="submit" name="{'Submit'|translate}">
165      <a href="#" id="openid_cancel">{'Cancel'|translate}</a>
[20293]166    </div>
167  </form>
168</div>
Note: See TracBrowser for help on using the repository browser.