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