[dw-free] Keep S2 layer editor window cursor in same place when compiling
[commit: http://hg.dwscoalition.org/dw-free/rev/49b1b53b9bea]
http://bugs.dwscoalition.org/show_bug.cgi?id=401
Codemerge.
Patch by
denise.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=401
Codemerge.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- bin/upgrading/en.dat
- cgi-bin/LJ/S2.pm
- htdocs/customize/advanced/layeredit.bml
- htdocs/js/s2edit/s2edit.js
- htdocs/js/s2edit/s2gui.js
- htdocs/js/s2edit/xlib.js
- htdocs/talkread.bml
-------------------------------------------------------------------------------- diff -r 2158dc707267 -r 49b1b53b9bea bin/upgrading/en.dat --- a/bin/upgrading/en.dat Sun Jul 05 14:16:27 2009 +0000 +++ b/bin/upgrading/en.dat Sun Jul 05 14:46:47 2009 +0000 @@ -3493,6 +3493,8 @@ talk.readsimilar=Read similar journal en talk.replytothis=Reply to this +talk.screened=Comment screened + talk.somebodywrote=[[realname]] ([[userlink]]) wrote, talk.somebodywrote_comm=[[realname]] ([[userlink]]) wrote in [[commlink]], diff -r 2158dc707267 -r 49b1b53b9bea cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Sun Jul 05 14:16:27 2009 +0000 +++ b/cgi-bin/LJ/S2.pm Sun Jul 05 14:46:47 2009 +0000 @@ -3127,7 +3127,7 @@ sub _print_quickreply_link } $onclick = "" unless $page->{'_type'} eq 'EntryPage'; - $onclick = "" unless LJ::is_enabled('s2quickreply'); + $onclick = "" if $page->{'_u'}->{'opt_whocanreply'} eq 'friends' and $remote and not LJ::is_friend($page->{'_u'}, $remote); # See if we want to force them to change their password my $bp = LJ::bad_password_redirect({ 'returl' => 1 }); diff -r 2158dc707267 -r 49b1b53b9bea htdocs/customize/advanced/layeredit.bml --- a/htdocs/customize/advanced/layeredit.bml Sun Jul 05 14:16:27 2009 +0000 +++ b/htdocs/customize/advanced/layeredit.bml Sun Jul 05 14:46:47 2009 +0000 @@ -146,18 +146,14 @@ // --> </script> +$includes + <!--[if IE]> <style type="text/css"> html { overflow: hidden; } -</style> -<![endif]--> -$includes - -<!--[if IE]> -<style type="text/css"> div.reference { height: expression(xGetElementById('statusbar').offsetTop - (42 + 9 + 10) + "px"); } @@ -199,9 +195,9 @@ </head> <body onMouseMove="s2processDrag(event)" onMouseUp="s2endDrag(event)"> - <form method="post"> - $formauth - <input type="hidden" name="action" value="compile" /> + <form method="post" name="s2" action="" onsubmit="return s2submit()"> + $formauth + <input type="hidden" name="action" value="compile" /> <div class="header"> <h1>$title</h1> @@ -278,14 +274,9 @@ <div class="gutter"> </div> <div id="status">Ready.</div> </div> + + </form> -<script type="text/javascript"> - if (navigator.userAgent.indexOf('Safari') > -1) { - xGetElementById('main').style.width = '100%'; - } - - s2init(); -</script> </body> </html> diff -r 2158dc707267 -r 49b1b53b9bea htdocs/js/s2edit/s2edit.js --- a/htdocs/js/s2edit/s2edit.js Sun Jul 05 14:16:27 2009 +0000 +++ b/htdocs/js/s2edit/s2edit.js Sun Jul 05 14:46:47 2009 +0000 @@ -28,3 +28,7 @@ function s2initIndex() { s2index = new Object(); } + +LiveJournal.register_hook('page_load', function () { + s2init(); +}); diff -r 2158dc707267 -r 49b1b53b9bea htdocs/js/s2edit/s2gui.js --- a/htdocs/js/s2edit/s2gui.js Sun Jul 05 14:16:27 2009 +0000 +++ b/htdocs/js/s2edit/s2gui.js Sun Jul 05 14:46:47 2009 +0000 @@ -261,6 +261,16 @@ function s2buildReference() s2buildClasses(); s2buildFunctions(); s2buildProperties(); + + if (window.name) + { + setTimeout(function() { + var pos = window.name.split(':'), textarea = s2getCodeArea(); + textarea.scrollTop = +pos[0] || 0; + nxpositionCursor(textarea, pos[1] || 0) + window.name = ''; + }, 1) + } } // --------------------------------------------------------------------------- @@ -449,3 +459,10 @@ function s2initDrag() return true; } + +function s2submit() +{ + // save position textarea, where reload page + var textarea = s2getCodeArea(); + window.name = textarea.scrollTop + ':' + nxgetPositionCursor(textarea); +} diff -r 2158dc707267 -r 49b1b53b9bea htdocs/js/s2edit/xlib.js --- a/htdocs/js/s2edit/xlib.js Sun Jul 05 14:16:27 2009 +0000 +++ b/htdocs/js/s2edit/xlib.js Sun Jul 05 14:46:47 2009 +0000 @@ -85,12 +85,28 @@ function nxpositionCursor(obj, pos) { if (nxIE) { var range = obj.createTextRange(); - range.move('character', from); + range.collapse(true); + range.moveEnd('character', pos); + range.moveStart('character', pos); range.select(); // TODO: test this } else { obj.selectionStart = obj.selectionEnd = pos; obj.focus(); } +} + +function nxgetPositionCursor(obj) +{ + if ('selectionStart' in obj) { + return obj.selectionStart; + } + if (document.selection && document.selection.createRange) { + obj.focus(); + var range = document.selection.createRange(); + return 0 - range.duplicate().moveStart('character', -100000); + } + + return 0; } // Scrolls the object to the given line out of the given total number of lines. diff -r 2158dc707267 -r 49b1b53b9bea htdocs/talkread.bml --- a/htdocs/talkread.bml Sun Jul 05 14:16:27 2009 +0000 +++ b/htdocs/talkread.bml Sun Jul 05 14:46:47 2009 +0000 @@ -51,6 +51,7 @@ body<= expand talk.expandlink replythis talk.replytothis unscreentoreply talk.unscreentoreply + screened talk.screened frozen talk.frozen link talk.commentpermlink deleted .subjectdeleted @@ -685,8 +686,12 @@ body<= $ret .= "(<a href='$bp'>$T{'replythis'}</a>) "; } else { if ($post->{state} eq 'S') { - # show unscreen to reply link id comment screened - $ret .= "(<a href='$LJ::SITEROOT/talkscreen.bml?mode=unscreen&${jargent}talkid=$dtid'>$T{'unscreentoreply'}</a>) "; + if ( LJ::can_manage( $remote, $u ) ) { + # show unscreen to reply link id comment screened + $ret .= "(<a href='$LJ::SITEROOT/talkscreen.bml?mode=unscreen&${jargent}talkid=$dtid'>$T{'unscreentoreply'}</a>) "; + } else { + $ret .= "($T{ 'screened' })"; + } } else { $ret .= "(" . LJ::make_qr_link($dtid, $post->{'subject'}, $T{'replythis'}, $replyurl) . ") "; } --------------------------------------------------------------------------------