Changeset 26740


Ignore:
Timestamp:
Jan 15, 2014, 10:10:42 AM (10 years ago)
Author:
mistic100
Message:

revert r26723, not suitable solution

Location:
extensions/oAuth/template
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/template/identification_common.tpl

    r26723 r26740  
    88{/if}
    99
    10 {combine_script id='oauth' load='footer' require='jquery.colorbox' template=true path=$OAUTH_PATH|cat:'template/script.js'}
    11 
    1210{html_style}
    1311#openid_form { padding:20px; }
     
    1614{/html_style}
    1715
     16{footer_script}
     17// redirect, called from the popup
     18function oauth_redirect(type) {
     19  var url = '{$OAUTH.u_redirect}';
     20  if (type && type != 'default') {
     21    url = '{$ABS_ROOT_URL}'+ type +'.php';
     22  }
     23
     24  window.location.href = url;
     25}
     26
     27// open authentication popup
     28function open_auth(url) {
     29  window.open(
     30    '{$OAUTH.u_login}' + url + '&key={$OAUTH.key}',
     31    'hybridauth_social_sign_on',
     32    'location=0,status=0,scrollbars=0,width=800,height=500'
     33  ); 
     34}
     35
     36// click on a button
     37jQuery('a.oauth:not(.persona)').click(function(e) {
     38  e.preventDefault();
     39 
     40  var idp = jQuery(this).data('idp');
     41 
     42  switch(idp) {
     43    case 'OpenID': case 'Wordpress': case 'Flickr': case 'Steam':
     44      switch(idp) {
     45        case 'OpenID':
     46          jQuery('#openid_label').html('{'Please enter your OpenID URL'|translate|escape:javascript}'); break;
     47        case 'Wordpress': case 'Steam':
     48          jQuery('#openid_label').html('{'Please enter your username'|translate|escape:javascript}'); break;
     49        case 'Flickr':
     50          jQuery('#openid_label').html('{'Please enter your user ID'|translate|escape:javascript}'); break;
     51      }
     52     
     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      }
     57      jQuery('#openid_form').css('background-color', bg_color);
     58
     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);
     62
     63      jQuery.colorbox({
     64        inline: true,
     65        href: '#openid_form',
     66        initialWidth: 0,
     67        initialHeight: 0,
     68        mawWidth: '100%',
     69        onComplete: function(){ jQuery.colorbox.resize({ speed:0 }) } // prevent misalignement when icon not loaded
     70      });
     71      break;
     72     
     73    default:
     74      open_auth(idp);
     75  }
     76});
     77
     78jQuery('#openid_form').submit(function(e) {
     79  e.preventDefault();
     80 
     81  var idp = jQuery(this).data('idp');
     82  var oi = jQuery('#openid_form input[name=openid_identifier]').val();
     83  jQuery('#openid_form input[name=openid_identifier]').val('');
     84 
     85  jQuery('#openid_label').removeClass('error');
     86  if (!oi) {
     87    jQuery('#openid_label').addClass('error');
     88    return;
     89  }
     90 
     91  switch(idp) {
     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;
     95  }
     96
     97  open_auth('OpenID&openid_identifier=' + encodeURI(oi));
     98
     99  jQuery.colorbox.close();
     100});
     101
     102jQuery('#openid_cancel').click(function(e) {
     103  e.preventDefault();
     104 
     105  jQuery('#openid_label').removeClass('error');
     106  jQuery.colorbox.close();
     107});
     108
     109{if $OAUTH.providers.Persona.enabled}
     110jQuery('a.oauth.persona').click(function(e) {
     111  e.preventDefault();
     112  navigator.id.request();
     113});
     114
     115{if not empty($OAUTH.persona_email)}
     116jQuery('a[href$="act=logout"]').click(function(e) {
     117  e.preventDefault();
     118  navigator.id.logout();
     119});
     120{/if}
     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',
     130      data: {
     131        assertion: assertion,
     132        key: '{$OAUTH.key}'
     133      },
     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}
     148{/footer_script}
    18149
    19150<div style="display:none;">
Note: See TracChangeset for help on using the changeset viewer.