Changeset 2363
- Timestamp:
- 05/16/08 16:35:41 (18 months ago)
- Location:
- branches/release-38/default_templates
- Files:
-
- 2 modified
-
javascript.mtml (modified) (11 diffs)
-
signin.mtml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-38/default_templates/javascript.mtml
r2341 r2363 39 39 var el = (typeof id == "string") ? document.getElementById(id) : id; 40 40 if (el) el.style.display = 'block'; 41 } 42 43 <mt:Ignore> 44 /*** 45 * A utility function for assigning/adding handlers to window events. 46 */ 47 </mt:Ignore> 48 function mtAttachEvent(eventName,func) { 49 var onEventName = 'on' + eventName; 50 var old = window[onEventName]; 51 if( typeof old != 'function' ) 52 window[onEventName] = func; 53 else { 54 window[onEventName] = function( evt ) { 55 old( evt ); 56 return func( evt ); 57 }; 58 } 59 } 60 61 <mt:Ignore> 62 /*** 63 * Calls the event named, if there are handlers for it. 64 */ 65 </mt:Ignore> 66 function mtFireEvent(eventName,param) { 67 var fn = window['on' + eventName]; 68 if (typeof fn == 'function') return fn(param); 69 return; 41 70 } 42 71 … … 150 179 mtSaveUser(); 151 180 // sync up user greeting 152 mt UserOnLoad();181 mtFireEvent('usersignin'); 153 182 } 154 183 } … … 318 347 // if the user is authenticated, hide the 'anonymous' fields 319 348 // and any captcha input if already shown 320 if ( u && u.is_authenticated ) { 321 mtShow('comments-form'); 322 mtHide('comments-open-data'); 323 if (mtCaptchaVisible) 324 mtHide('comments-open-captcha'); 325 } else { 349 if ( document.getElementById('comments-form')) { 350 if ( u && u.is_authenticated ) { 351 mtShow('comments-form'); 352 mtHide('comments-open-data'); 353 if (mtCaptchaVisible) 354 mtHide('comments-open-captcha'); 355 } else { 326 356 <mt:IfRegistrationRequired> 327 mtHide('comments-form');357 mtHide('comments-form'); 328 358 </mt:IfRegistrationRequired> 329 }330 if ( u && u.is_banned ) {331 mtHide('comments-form');332 }333 334 // if we're previewing a comment, make sure the captcha335 // field is visible336 if (is_preview) {337 mtShowCaptcha();338 } else {339 // display greeting appropriate to the current user340 mtShowGreeting();341 }342 343 // populate anonymous comment fields if user is cookied as anonymous344 var cf = document['comments_form'];345 if (cf) {346 if (u && u.is_anonymous) {347 if (u.email) cf.email.value = u.email;348 if (u.name) cf.author.value = u.name;349 if (u.url) cf.url.value = u.url;350 if (cf.bakecookie)351 cf.bakecookie.checked = u.name || u.email;352 359 } 353 if (cf.post.disabled) { 354 cf.post.disabled = false; 355 cf.post.value = '<__trans phrase="Submit">'; 356 } 357 if (cf.preview_button.disabled) { 358 cf.preview_button.disabled = false; 359 cf.preview_button.value = '<__trans phrase="Preview">'; 360 if ( u && u.is_banned ) 361 mtHide('comments-form'); 362 363 // if we're previewing a comment, make sure the captcha 364 // field is visible 365 if (is_preview) 366 mtShowCaptcha(); 367 else 368 mtShowGreeting(); 369 370 // populate anonymous comment fields if user is cookied as anonymous 371 var cf = document['comments_form']; 372 if (cf) { 373 if (u && u.is_anonymous) { 374 if (u.email) cf.email.value = u.email; 375 if (u.name) cf.author.value = u.name; 376 if (u.url) cf.url.value = u.url; 377 if (cf.bakecookie) 378 cf.bakecookie.checked = u.name || u.email; 379 } 380 if (cf.post.disabled) { 381 cf.post.disabled = false; 382 cf.post.value = '<__trans phrase="Submit">'; 383 } 384 if (cf.preview_button.disabled) { 385 cf.preview_button.disabled = false; 386 cf.preview_button.value = '<__trans phrase="Preview">'; 387 } 360 388 } 361 389 } … … 370 398 </mt:Ignore> 371 399 function mtEntryOnLoad() { 372 <mt:Unless tag="IfPingsAccepted"> 373 mtHide('trackbacks-info'); 374 </mt:Unless> 375 376 <mt:Unless tag="IfCommentsAccepted"> 377 mtHide('comments-open'); 378 </mt:Unless> 379 380 mtUserOnLoad(); 381 } 400 <mt:Unless tag="IfPingsAccepted">mtHide('trackbacks-info');</mt:Unless> 401 <mt:Unless tag="IfCommentsAccepted">mtHide('comments-open');</mt:Unless> 402 mtFireEvent('usersignin'); 403 } 404 405 mtAttachEvent('usersignin', mtUserOnLoad); 382 406 383 407 <mt:Ignore> … … 396 420 } 397 421 398 function mtSignInOnClick() { 399 // display throbber 400 var el = document.getElementById('comment-greeting'); 401 if (!el) // legacy MT 4.x element id 402 el = document.getElementById('comment-form-external-auth'); 422 function mtSignInOnClick(sign_in_element) { 423 var el; 424 if (sign_in_element) { 425 // display throbber 426 el = document.getElementById(sign_in_element); 427 if (!el) // legacy MT 4.x element id 428 el = document.getElementById('comment-form-external-auth'); 429 } 403 430 if (el) 404 431 el.innerHTML = '<__trans phrase="Signing in..."> <img src="<$mt:StaticWebPath$>images/indicator.white.gif" height="16" width="16" alt="" />'; … … 420 447 <mt:Ignore> 421 448 /*** 422 * Handles the action of the "Sign out" link. First clears any existing 423 * user cookie, then direts to the MT comment script to sign the user out. 449 * Handles sign out from the web site. 450 * First clears any existing user cookie, then direts to the MT comment 451 * script to sign the user out. 424 452 */ 425 453 </mt:Ignore> 426 454 function mtSignOut(entry_id) { 427 var url = '<$mt:SignOutLink$>&entry_id=' + entry_id;428 455 mtClearUser(); 456 var url = '<$mt:SignOutLink$>&return_to=' + encodeURIComponent(location.href); 429 457 location.href = url; 458 } 459 460 <mt:Ignore> 461 /*** 462 * Handles the action of the "Sign out" link. 463 */ 464 </mt:Ignore> 465 function mtSignOutOnClick() { 466 mtSignOut(); 467 return false; 430 468 } 431 469 … … 457 495 if ( u && u.is_authenticated ) { 458 496 if ( u.is_banned ) { 459 phrase = '<__trans phrase="You do not have permission to comment on this blog. ([_1]sign out[_2])" params="<a href="javascript:void(0);" onclick=" mtSignOut(' + entry_id + ');return false;">%%</a>">';497 phrase = '<__trans phrase="You do not have permission to comment on this blog. ([_1]sign out[_2])" params="<a href="javascript:void(0);" onclick="return mtSignOutOnClick();">%%</a>">'; 460 498 } else { 461 499 var user_link; … … 473 511 } 474 512 // TBD: supplement phrase with userpic if one is available. 475 phrase = '<__trans phrase="Thanks for signing in, [_1]. ([_2]sign out[_3])" params="' + user_link + '%%<a href="javascript:void(0)" onclick=" mtSignOut(' + entry_id + ');return false;">%%</a>">';513 phrase = '<__trans phrase="Thanks for signing in, [_1]. ([_2]sign out[_3])" params="' + user_link + '%%<a href="javascript:void(0)" onclick="return mtSignOutOnClick();">%%</a>">'; 476 514 } 477 515 } else { 478 516 if (reg_reqd) { 479 phrase = '<__trans phrase="[_1]Sign in[_2] to comment." params="<a href="javascript:void(0)" onclick="return mtSignInOnClick( )">%%</a>">';517 phrase = '<__trans phrase="[_1]Sign in[_2] to comment." params="<a href="javascript:void(0)" onclick="return mtSignInOnClick(\'comment-greeting\')">%%</a>">'; 480 518 } else { 481 phrase = '<__trans phrase="[_1]Sign in[_2] to comment, or comment anonymously." params="<a href="javascript:void(0)" onclick="return mtSignInOnClick( )">%%</a>">';519 phrase = '<__trans phrase="[_1]Sign in[_2] to comment, or comment anonymously." params="<a href="javascript:void(0)" onclick="return mtSignInOnClick(\'comment-greeting\')">%%</a>">'; 482 520 } 483 521 } … … 587 625 </mt:Ignore> 588 626 function mtSetCookie(name, value, expires, path, domain, secure) { 627 if (domain && domain.match(/^\.?localhost$/)) 628 domain = null; 589 629 var curCookie = name + "=" + escape(value) + 590 630 (expires ? "; expires=" + expires.toGMTString() : "") + … … 618 658 </mt:Ignore> 619 659 function mtDeleteCookie(name, path, domain, secure) { 620 if (mtGetCookie(name)) 660 if (mtGetCookie(name)) { 661 if (domain && domain.match(/^\.?localhost$/)) 662 domain = null; 621 663 document.cookie = name + "=" + 622 664 (path ? "; path=" + path : "") + … … 624 666 (secure ? "; secure" : "") + 625 667 "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 668 } 626 669 } 627 670 -
branches/release-38/default_templates/signin.mtml
r2052 r2363 1 < script type="text/javascript" src="<$mt:Link template="<__trans phrase="JavaScript">"$>"></script>1 <mt:IfRegistrationAllowed> 2 2 <div class="widget-sign-in widget"> 3 3 <h3 class="widget-header"><__trans phrase="Sign In"></h3> 4 <div class="widget-content"> 4 <div class="widget-content" id="signin-widget-content"></div> 5 </div> 5 6 <script type="text/javascript"> 6 7 /* <![CDATA[ */ 7 var name, id, url, blog_ids; 8 if (typeof(commenter_name) != 'undefined') 9 name = commenter_name 10 if (typeof(commenter_id) != 'undefined') 11 id = commenter_id; 12 if (typeof(commenter_url) != 'undefined') 13 url = commenter_url; 14 if (typeof(commenter_blog_ids) != 'undefined') 15 blog_ids = commenter_blog_ids; 16 17 if (!name && !id) { 18 if ('<$mt:CGIHost exclude_port="1"$>' != '<$mt:BlogHost exclude_port="1"$>') { 19 document.write('<scr' + 'ipt src="<$mt:CGIPath$><$mt:CommentScript$>?__mode=cmtr_name_js">'); 20 document.write("</scr" + "ipt>"); 8 function mtUpdateSignInWidget(u) { 9 var el = document.getElementById('signin-widget-content'); 10 if (!el) return; 11 if (u) { 12 if (u && u.is_authenticated) { 13 user = u; 14 mtSaveUser(); 15 } else { 16 // user really isn't logged in; so let's do this! 17 return mtSignIn(); 18 } 21 19 } else { 22 name = getCookie('commenter_name'); 23 ids = getCookie('commenter_id').split(':'); 24 id = ids[0]; 25 blog_ids = ids[1]; 26 url = getCookie('commenter_url'); 20 u = mtGetUser(); 27 21 } 28 } 29 showMessage(name, id, url); 30 31 function showMessage(commenter_name, commenter_id, commenter_url) { 32 static = location.href; 33 if ( commenter_name && 34 ( !commenter_id 35 || commenter_blog_ids.indexOf("'<$mt:BlogID$>'") > -1)) 36 { 22 if (u) { 37 23 var url; 38 if ( commenter_id) {39 url = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=edit_profile& commenter=' + commenter_id + '&blog_id=<$mt:BlogID$>';40 url += '&static=' + static;41 } else if ( commenter_url) {42 url = commenter_url;24 if (u.is_authenticated) { 25 url = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=edit_profile&blog_id=<$mt:BlogID$>'; 26 url += '&static=' + escape( location.href ); 27 } else if (u.url) { 28 url = u.url; 43 29 } else { 44 30 url = null; 45 31 } 46 32 var content = '<__trans phrase="You are signed in as " escape="js">'; 47 if (url) { 48 content += '<a href="' + url + '">' + commenter_name + '</a>'; 49 } else { 50 content += commenter_name; 51 } 52 content += '. (<a href="<$mt:RemoteSignOutLink no_static="1"$>&static=' + static + '"><__trans phrase="sign out" escape="js"></a>)'; 53 document.write(content); 54 } else if (commenter_name) { 55 document.write('<__trans phrase="You do not have permission to sign in to this blog." escape="js"> (<a href="<$mt:RemoteSignOutLink no_static="1"$>&static=' + static + '"><__trans phrase="sign out" escape="js"></a>)'); 33 if (url) 34 content += '<a href="' + url + '">' + u.name + '</a>'; 35 else 36 content += u.name; 37 content += '. (<a href="javascript:void(0)" onclick="return mtSignOutOnClick()"><__trans phrase="sign out" escape="js"></a>)'; 38 } else if (u && u.is_banned) { 39 content = '<__trans phrase="You do not have permission to sign in to this blog." escape="js">'; 56 40 } else { 57 <mt:IfRegistrationAllowed> 58 document.write('<a href="<$mt:CGIPath$><$mt:CommentScript$>?__mode=login&blog_id=<$mt:BlogID$>&static=' + static + '"><__trans phrase="Sign In" escape="js"></a>'); 59 </mt:IfRegistrationAllowed> 41 content = '<a href="javascript:void(0)" onclick="return mtSignInOnClick(\'signin-widget-content\')"><__trans phrase="Sign In" escape="js"></a>'; 60 42 } 43 el.innerHTML = content; 61 44 } 45 mtAttachEvent('usersignin', mtUpdateSignInWidget); 46 mtUpdateSignInWidget(); 62 47 /* ]]> */ 63 48 </script> 64 </div> 65 </div> 49 </mt:IfRegistrationAllowed>
