Index: trunk/extensions/GPoC/SpecialSelection.php |
— | — | @@ -51,10 +51,12 @@ |
52 | 52 | if( $action == 'setrevision' ) { |
53 | 53 | $revision = $wgRequest->getVal( 'revision' ); |
54 | 54 | $success = Selection::setRevision( $name, $namespace, $article, $revision ); |
55 | | - |
| 55 | + $title = Title::makeTitle( $namespace, $article ); |
| 56 | + $url = $title->getLinkUrl( array( 'oldid' => $revision ) ); |
56 | 57 | $return = array( |
57 | 58 | 'status' => $success, |
58 | | - 'revision' => $revision |
| 59 | + 'revision' => $revision, |
| 60 | + 'revision_url' => $url |
59 | 61 | ); |
60 | 62 | } else if ( $action == 'deletearticle') { |
61 | 63 | $success = Selection::deleteArticle( $name, $namespace, $article ); |
Index: trunk/extensions/GPoC/templates/SelectionTemplate.php |
— | — | @@ -15,21 +15,21 @@ |
16 | 16 | <h3>Articles in Selection <?php echo $name; ?></h3> <small><a href="<?php echo $csv_link; ?>">Export CSV</a></small> |
17 | 17 | <table> |
18 | 18 | <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> |
23 | 23 | </tr> |
24 | 24 | <?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']; ?>"> |
26 | 26 | <td><a href="<?php echo $article['title']->getLinkURL(); ?>"><?php echo $article['s_article']; ?></a></td> |
27 | 27 | <td><?php echo wfTimeStamp( TS_ISO_8601, $article['s_timestamp'] ); ?></td> |
28 | 28 | <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> |
30 | 30 | <?php } ?> |
31 | 31 | </td> |
32 | 32 | <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"> |
34 | 34 | <div class="revision-input" style="display:none"> |
35 | 35 | <input type="text" class="revision-id" placeholder="Enter revision id" value="<?php echo $article['s_revision']; ?>" /> |
36 | 36 | (<a href="#" class="revision-save">Save</a> | <a href="#" class="revision-cancel">Cancel</a>) |
— | — | @@ -47,19 +47,22 @@ |
48 | 48 | </div> |
49 | 49 | |
50 | 50 | <script type="text/javascript"> |
| 51 | + // Should this be a RL module? |
51 | 52 | $(document).ready(function() { |
52 | 53 | $(".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); |
55 | 56 | input_box.fadeToggle(); |
56 | 57 | return false; |
57 | 58 | }); |
58 | 59 | $(".revision-save").click(function() { |
59 | | - var parent = $(this).parents("div.item-actions"); |
| 60 | + var parent = $(this).parents(".article-row"); |
60 | 61 | var ns = parent.attr("data-namespace"), |
61 | 62 | article = parent.attr("data-article"); |
62 | 63 | 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 | + |
64 | 67 | var revid = input.val(); |
65 | 68 | |
66 | 69 | $.post('', { |
— | — | @@ -67,14 +70,18 @@ |
68 | 71 | namespace: ns, |
69 | 72 | article: article, |
70 | 73 | revision: revid |
71 | | - }, function() { |
| 74 | + }, function(raw_data) { |
| 75 | + var data = $.parseJSON(raw_data) |
| 76 | + console.log(data); |
72 | 77 | input_box.fadeOut(); |
| 78 | + revlink.hide(); |
| 79 | + revlink.attr("href", data.revision_url).html(data.revision).fadeIn(); |
73 | 80 | }); |
74 | 81 | |
75 | 82 | return false; |
76 | 83 | }); |
77 | 84 | $(".delete-article").click(function() { |
78 | | - var parent = $(this).parents("div.item-actions"); |
| 85 | + var parent = $(this).parents(".article-row"); |
79 | 86 | var ns = parent.attr("data-namespace"), |
80 | 87 | article = parent.attr("data-article"); |
81 | 88 | |
— | — | @@ -83,6 +90,7 @@ |
84 | 91 | namespace: ns, |
85 | 92 | article: article |
86 | 93 | }, function() { |
| 94 | + parent.fadeOut(); |
87 | 95 | }); |
88 | 96 | |
89 | 97 | return false; |