r94323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94322‎ | r94323 | r94324 >
Date:05:09, 12 August 2011
Author:yuvipanda
Status:deferred
Tags:
Comment:
UI fixes in selection operations
Modified paths:
  • /trunk/extensions/GPoC/SpecialSelection.php (modified) (history)
  • /trunk/extensions/GPoC/templates/SelectionTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GPoC/SpecialSelection.php
@@ -51,10 +51,12 @@
5252 if( $action == 'setrevision' ) {
5353 $revision = $wgRequest->getVal( 'revision' );
5454 $success = Selection::setRevision( $name, $namespace, $article, $revision );
55 -
 55+ $title = Title::makeTitle( $namespace, $article );
 56+ $url = $title->getLinkUrl( array( 'oldid' => $revision ) );
5657 $return = array(
5758 'status' => $success,
58 - 'revision' => $revision
 59+ 'revision' => $revision,
 60+ 'revision_url' => $url
5961 );
6062 } else if ( $action == 'deletearticle') {
6163 $success = Selection::deleteArticle( $name, $namespace, $article );
Index: trunk/extensions/GPoC/templates/SelectionTemplate.php
@@ -15,21 +15,21 @@
1616 <h3>Articles in Selection <?php echo $name; ?></h3> <small><a href="<?php echo $csv_link; ?>">Export CSV</a></small>
1717 <table>
1818 <tr>
19 - <th>Article</th>
20 - <th>Added on</th>
21 - <th>Revision</th>
22 - <th>Actions</th>
 19+ <th style="width:150px">Article</th>
 20+ <th style="width:150px">Added on</th>
 21+ <th style="width:75px">Revision</th>
 22+ <th style="width:300px">Actions</th>
2323 </tr>
2424 <?php foreach( $articles as $article ) { ?>
25 - <tr>
 25+ <tr class="article-row" data-namespace="<?php echo $article['s_namespace']; ?>" data-article="<?php echo $article['s_article']; ?>">
2626 <td><a href="<?php echo $article['title']->getLinkURL(); ?>"><?php echo $article['s_article']; ?></a></td>
2727 <td><?php echo wfTimeStamp( TS_ISO_8601, $article['s_timestamp'] ); ?></td>
2828 <td><?php if($article['s_revision'] != null) { ?>
29 - <a href="<?php echo $article['title']->getLinkUrl(array('oldid' => $article['s_revision'])); ?>"><?php echo $article['s_revision']; ?></a>
 29+ <a href="<?php echo $article['title']->getLinkUrl(array('oldid' => $article['s_revision'])); ?>" class="revision-link"><?php echo $article['s_revision']; ?></a>
3030 <?php } ?>
3131 </td>
3232 <td>
33 - <div class="item-actions" data-namespace="<?php echo $article['s_namespace']; ?>" data-article="<?php echo $article['s_article']; ?>">
 33+ <div class="item-actions">
3434 <div class="revision-input" style="display:none">
3535 <input type="text" class="revision-id" placeholder="Enter revision id" value="<?php echo $article['s_revision']; ?>" />
3636 (<a href="#" class="revision-save">Save</a> | <a href="#" class="revision-cancel">Cancel</a>)
@@ -47,19 +47,22 @@
4848 </div>
4949
5050 <script type="text/javascript">
 51+ // Should this be a RL module?
5152 $(document).ready(function() {
5253 $(".change-revision").click(function() {
53 - var parent = $(this).parent("div.item-actions");
54 - var input_box = parent.children(".revision-input");
 54+ var parent = $(this).parents(".article-row");
 55+ var input_box = $(".revision-input", parent);
5556 input_box.fadeToggle();
5657 return false;
5758 });
5859 $(".revision-save").click(function() {
59 - var parent = $(this).parents("div.item-actions");
 60+ var parent = $(this).parents(".article-row");
6061 var ns = parent.attr("data-namespace"),
6162 article = parent.attr("data-article");
6263 var input = $("input.revision-id", parent);
63 - var input_box = parent.children(".revision-input");
 64+ var input_box = $(".revision-input", parent);
 65+ var revlink = $(".revision-link", parent);
 66+
6467 var revid = input.val();
6568
6669 $.post('', {
@@ -67,14 +70,18 @@
6871 namespace: ns,
6972 article: article,
7073 revision: revid
71 - }, function() {
 74+ }, function(raw_data) {
 75+ var data = $.parseJSON(raw_data)
 76+ console.log(data);
7277 input_box.fadeOut();
 78+ revlink.hide();
 79+ revlink.attr("href", data.revision_url).html(data.revision).fadeIn();
7380 });
7481
7582 return false;
7683 });
7784 $(".delete-article").click(function() {
78 - var parent = $(this).parents("div.item-actions");
 85+ var parent = $(this).parents(".article-row");
7986 var ns = parent.attr("data-namespace"),
8087 article = parent.attr("data-article");
8188
@@ -83,6 +90,7 @@
8491 namespace: ns,
8592 article: article
8693 }, function() {
 94+ parent.fadeOut();
8795 });
8896
8997 return false;

Status & tagging log