r96223 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96222‎ | r96223 | r96224 >
Date:14:04, 4 September 2011
Author:werdna
Status:deferred
Tags:
Comment:
Get LQT JS working with posting and replying
Modified paths:
  • /branches/lqt-updates/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /branches/lqt-updates/extensions/LiquidThreads/api/ApiLqtForm.php (added) (history)
  • /branches/lqt-updates/extensions/LiquidThreads/classes/model/Channel.php (modified) (history)
  • /branches/lqt-updates/extensions/LiquidThreads/classes/model/Post.php (modified) (history)
  • /branches/lqt-updates/extensions/LiquidThreads/classes/model/Topic.php (modified) (history)
  • /branches/lqt-updates/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: branches/lqt-updates/extensions/LiquidThreads/LiquidThreads.php
@@ -235,14 +235,17 @@
236236 // $wgDefaultUserOptions['lqtdisplaycount'] = 25;
237237 // $wgDefaultUserOptions['lqtcustomsignatures'] = true;
238238 //
239 -// // API
 239+// API
240240 // $wgAutoloadClasses['ApiQueryLQTThreads'] = $dir . 'api/ApiQueryLQTThreads.php';
241241 // $wgAPIListModules['threads'] = 'ApiQueryLQTThreads';
242242 // $wgAutoloadClasses['ApiFeedLQTThreads'] = $dir . 'api/ApiFeedLQTThreads.php';
243243 // $wgAPIModules['feedthreads'] = 'ApiFeedLQTThreads';
244244 // $wgAutoloadClasses['ApiThreadAction'] = $dir . '/api/ApiThreadAction.php';
245245 // $wgAPIModules['threadaction'] = 'ApiThreadAction';
246 -//
 246+
 247+$wgAutoloadClasses['ApiLqtForm'] = $dir.'/api/ApiLqtForm.php';
 248+$wgAPIModules['lqtform'] = 'ApiLqtForm';
 249+
247250 // // Path to the LQT directory
248251 // $wgLiquidThreadsExtensionPath = "{$wgScriptPath}/extensions/LiquidThreads";
249252
Index: branches/lqt-updates/extensions/LiquidThreads/classes/model/Topic.php
@@ -458,7 +458,7 @@
459459 * @return String
460460 */
461461 public function getUniqueIdentifier() {
462 - return 'lqt-topic:'.$this->getID();
 462+ return 'lqt-topic_'.$this->getID();
463463 }
464464
465465 /**
Index: branches/lqt-updates/extensions/LiquidThreads/classes/model/Post.php
@@ -468,7 +468,7 @@
469469 * @return String
470470 */
471471 public function getUniqueIdentifier() {
472 - return 'lqt-post:'.$this->getID();
 472+ return 'lqt-post_'.$this->getID();
473473 }
474474 }
475475
Index: branches/lqt-updates/extensions/LiquidThreads/classes/model/Channel.php
@@ -196,6 +196,6 @@
197197 * @return String
198198 */
199199 public function getUniqueIdentifier() {
200 - return 'lqt-channel:'.$this->getID();
 200+ return 'lqt-channel_'.$this->getID();
201201 }
202202 }
Index: branches/lqt-updates/extensions/LiquidThreads/api/ApiLqtForm.php
@@ -0,0 +1,135 @@
 2+<?php
 3+
 4+class ApiLqtForm extends ApiBase {
 5+
 6+ public function execute() {
 7+ $params = $this->extractRequestParams();
 8+ $result = $this->getResult();
 9+
 10+ $form = $this->getForm( $params );
 11+
 12+ global $wgUser;
 13+ if ( $params['submit'] ) {
 14+ if ( ! $wgUser->matchEditToken( $params['token'] ) ) {
 15+ $this->dieUsage( "Invalid edit token", 'invalid-token' );
 16+ }
 17+
 18+ $requestParams = array();
 19+
 20+ $requestParams['edittoken'] = $params['token'];
 21+ $requestParams['lqt-subject'] = $params['subject'];
 22+ $requestParams['lqt-edit-content'] = $params['content'];
 23+ $requestParams['lqt-signature'] = $params['signature'];
 24+
 25+ $request = new FauxRequest( $requestParams );
 26+
 27+ if ( ! $form->validate( $request ) ) {
 28+ $this->dieUsage( "Invalid parameters", 'invalid-param' );
 29+ }
 30+
 31+ $formResult = $form->submit( $request );
 32+
 33+ if ( $formResult ) {
 34+ $formOutput = array( 'submit' => 'success' );
 35+
 36+ $result->addValue( null, 'form', $formOutput );
 37+ }
 38+ } else {
 39+ $formOutput = array(
 40+ 'html' => $form->getFormHTML(),
 41+ 'token' => $wgUser->editToken(),
 42+ );
 43+
 44+ $result->addValue( null, 'form', $formOutput );
 45+ }
 46+ }
 47+
 48+ /**
 49+ * Get an array of valid forms and their corresponding classes.
 50+ */
 51+ public function getForms() {
 52+ return array(
 53+ 'new' => 'LiquidThreadsNewTopicForm',
 54+ 'reply' => 'LiquidThreadsReplyForm',
 55+ );
 56+ }
 57+
 58+ /**
 59+ * Creates the appropriate LiquidThreadsEditForm object
 60+ * @param $params Array: The parameters passed to the API module.
 61+ */
 62+ public function getForm( $params ) {
 63+ global $wgUser;
 64+
 65+ $formName = $params['form'];
 66+
 67+ if ( $formName == 'new' ) {
 68+ if ( ! $params['channel'] ) {
 69+ $this->dieUsage( 'You must specify a channel for the new form', 'missing-param' );
 70+ }
 71+
 72+ try {
 73+ $channel = LiquidThreadsChannel::newFromID( $params['channel'] );
 74+ } catch ( MWException $excep ) {
 75+ $this->dieUsage( "You must specify a valid channel", 'invalid-param' );
 76+ }
 77+
 78+ return new LiquidThreadsNewTopicForm( $wgUser, $channel );
 79+ } elseif ( $formName == 'reply' ) {
 80+ if ( ! $params['topic'] ) {
 81+ $this->dieUsage( 'You must specify a topic to reply to', 'missing-param' );
 82+ }
 83+
 84+ $replyPost = null;
 85+
 86+ try {
 87+ $topic = LiquidThreadsTopic::newFromID( $params['topic'] );
 88+ } catch ( MWException $e ) {
 89+ $this->dieUsage( "You must specify a valid topic", 'invalid-param' );
 90+ }
 91+
 92+ if ( $params['reply-post'] ) {
 93+ try {
 94+ $replyPost = LiquidThreadsPost::newFromID( $params['reply-post'] );
 95+ } catch ( MWException $e ) {
 96+ $this->dieUsage( "Invalid reply-post", 'invalid-param' );
 97+ }
 98+ }
 99+
 100+ return new LiquidThreadsReplyForm( $wgUser, $topic, $replyPost );
 101+ } else {
 102+ $this->dieUsage( "Not yet implemented", 'not-implemented' );
 103+ }
 104+ }
 105+
 106+ public function getAllowedParams() {
 107+ return array(
 108+ 'form' => array(
 109+ ApiBase::PARAM_REQUIRED => true,
 110+ ApiBase::PARAM_TYPE => array_keys( $this->getForms() ),
 111+ ),
 112+
 113+ // Parameters for new form
 114+ 'channel' => NULL,
 115+
 116+ // Parameters for reply form
 117+ 'topic' => NULL,
 118+ 'reply-post' => NULL,
 119+
 120+ // Submission parameters
 121+ 'submit' => array(
 122+ ApiBase::PARAM_TYPE => 'boolean',
 123+ ),
 124+
 125+ 'subject' => NULL,
 126+ 'content' => NULL,
 127+ 'signature' => NULL,
 128+
 129+ 'token' => NULL,
 130+ );
 131+ }
 132+
 133+ public function getVersion() {
 134+ return __CLASS__ . ': $Id: ApiLqtForm.php 79941 2011-01-10 17:18:57Z hartman $';
 135+ }
 136+}
Index: branches/lqt-updates/extensions/LiquidThreads/lqt.js
@@ -16,6 +16,14 @@
1717 var liquidThreads = {
1818 currentReplyThread : null,
1919 currentToolbar : null,
 20+
 21+ 'removePrefix' : function(string, prefix) {
 22+ if ( string.substr(0,prefix.length) != prefix ) {
 23+ throw "Invalid prefix for this string";
 24+ }
 25+
 26+ return string.substr(prefix.length);
 27+ },
2028
2129 'handleReplyLink' : function(e) {
2230 if (e.preventDefault)
@@ -27,27 +35,33 @@
2836 target = $j(e.target);
2937 }
3038
31 - var container = $j(target).closest('.lqt-post-tree-wrapper')[0];
32 - var thread_id = $j(this).data('thread-id');
 39+ var postContainer = $j(target).closest('.lqt-post-tree-wrapper')[0];
 40+ var topicContainer = $j(target).closest('.lqt-topic')[0];
3341
34 - // hide the form for this thread if it's currently being shown
35 - if ( thread_id == liquidThreads.currentReplyThread && $j( '#wpTextbox1' ).is( ':visible' ) ) {
36 - liquidThreads.cancelEdit({});
37 - return;
 42+// // hide the form for this thread if it's currently being shown
 43+// if ( thread_id == liquidThreads.currentReplyThread && $j( '#wpTextbox1' ).is( ':visible' ) ) {
 44+// liquidThreads.cancelEdit({});
 45+// return;
 46+// }
 47+
 48+ var topicID = liquidThreads.removePrefix( topicContainer.id, 'lqt-topic_' );
 49+ var params = { 'form' : 'reply', 'topic' : topicID };
 50+
 51+ if ( $j(postContainer).parent()[0] != topicContainer ) {
 52+ var postID = liquidThreads.removePrefix( postContainer.id, 'lqt-post_' );
 53+ params['reply-post'] = postID;
3854 }
3955
40 - var params = { 'method' : 'reply', 'thread' : thread_id };
41 -
42 - var repliesElement = $j(container).contents().filter('.lqt-replies');
 56+ var repliesElement = $j(postContainer).contents().filter('.lqt-replies');
4357 var replyDiv = repliesElement.contents().filter('.lqt-reply-form');
44 - replyDiv = replyDiv.add( $j(container).contents().filter('.lqt-reply-form') );
 58+ replyDiv = replyDiv.add( $j(postContainer).contents().filter('.lqt-reply-form') );
4559 if (!replyDiv.length) {
4660 // Create a div for it
4761 replyDiv = $j('<div class="lqt-reply-form lqt-edit-form"/>');
4862
4963 // Try to find a place for it
5064 if ( !repliesElement.length ) {
51 - repliesElement = liquidThreads.getRepliesElement( $j(container) );
 65+ repliesElement = liquidThreads.getRepliesElement( $j(postContainer) );
5266 }
5367
5468 repliesElement.find('.lqt-replies-finish').before( replyDiv );
@@ -57,7 +71,6 @@
5872 replyDiv = replyDiv[0];
5973
6074 liquidThreads.injectEditForm( params, replyDiv, e.preload );
61 - liquidThreads.currentReplyThread = thread_id;
6275 },
6376
6477 'getRepliesElement' : function(thread /* a .lqt-post-tree-wrapper */ ) {
@@ -99,10 +112,16 @@
100113 'handleNewLink' : function(e) {
101114 e.preventDefault();
102115
103 - var talkpage = $j(this).attr('lqt_talkpage');
104 - var params = {'talkpage' : talkpage, 'method' : 'talkpage_new_thread' };
 116+ var talkpage = $j(this).attr('lqt_channel');
 117+ var params = {'form' : 'new', 'channel' : talkpage };
105118
106119 var container = $j('.lqt-new-thread' );
 120+
 121+ if ( container.length == 0 ) {
 122+ container = $j('<div class="lqt-new-thread" />')
 123+ .prependTo('#lqt-channel_'+talkpage);
 124+ }
 125+
107126 container.data('lqt-talkpage', talkpage);
108127
109128 liquidThreads.injectEditForm( params, container );
@@ -157,7 +176,7 @@
158177 $j(container).find('#lqt_subject_field').focus();
159178
160179 // Update signature editor
161 - $j(container).find('input[name=wpLqtSignature]').hide();
 180+ $j(container).find('input[name=lqt-signature]').hide();
162181 $j(container).find('.lqt-signature-preview').show();
163182 var editLink = $j('<a class="lqt-signature-edit-button"/>' );
164183 editLink.text( mediaWiki.msg('lqt-edit-signature') );
@@ -241,13 +260,14 @@
242261 },
243262
244263 'loadInlineEditForm' : function( params, container, callback ) {
245 - params['action'] = 'threadaction';
246 - params['threadaction'] = 'inlineeditform';
 264+ params['action'] = 'lqtform';
247265
248266 liquidThreads.apiRequest( params,
249267 function(result) {
250 - var content = $j(result.threadaction.inlineeditform.html);
 268+ var content = $j(result.form.html);
251269 $j(container).empty().append(content);
 270+ content.data('token', result.form.token);
 271+ content.data('params', params );
252272
253273 callback();
254274 } );
@@ -885,25 +905,117 @@
886906 callback(token);
887907 }, 'json' );
888908 },
 909+
 910+ // Old AJAX save code
 911+// var replyCallback = function( data ) {
 912+// $parent = $j( '#lqt-post-tree-wrapper_id_' + data.threadaction.thread['parent-id'] );
 913+// $html = $j( data.threadaction.thread['html'] );
 914+// $newThread = $html.find( '#lqt-post-tree-wrapper_id_' + data.threadaction.thread['thread-id'] );
 915+// $parent.find( '.lqt-replies:first' ).append( $newThread );
 916+// $parent.closest( '.lqt-thread-topmost' )
 917+// .find( 'input.lqt-thread-modified' )
 918+// .val( data.threadaction.thread['modified'] );
 919+// liquidThreads.setupThread( $newThread.find( '.lqt-post-wrapper' ) );
 920+// $j( 'html,body' ).animate({scrollTop: $newThread.offset().top}, 'slow');
 921+// };
 922+//
 923+// var newCallback = function( data ) {
 924+// var $newThread = $j( data.threadaction.thread['html'] );
 925+// $j( '.lqt-threads' ).prepend( $newThread );
 926+// // remove the no threads message if it's on the page
 927+// $j('.lqt-no-threads').remove();
 928+// liquidThreads.setupThread( $newThread.find( '.lqt-post-wrapper' ) );
 929+// $j( 'html,body' ).animate( { scrollTop: $newThread.offset().top }, 'slow' );
 930+// };
 931+//
 932+// var editCallback = function( data ) {
 933+// var thread = editform.closest('.lqt-thread-topmost');
 934+//
 935+// liquidThreads.doReloadThread( thread );
 936+// }
 937+//
 938+// var doneCallback = function(data) {
 939+// try {
 940+// var result = data.threadaction.thread.result;
 941+// } catch ( err ) {
 942+// result = 'error';
 943+// }
 944+//
 945+// if ( result != 'Success' ) {
 946+// // Create a hidden field to mimic the save button, and
 947+// // submit it normally, so they'll get a real error message.
 948+//
 949+// var saveHidden = $j('<input/>');
 950+// saveHidden.attr( 'type', 'hidden' );
 951+// saveHidden.attr( 'name', 'wpSave' );
 952+// saveHidden.attr( 'value', 'Save' );
 953+//
 954+// var form = editform.find('#editform');
 955+// form.append(saveHidden);
 956+// form.submit();
 957+// return;
 958+// }
 959+//
 960+// var callback;
 961+//
 962+// if ( type == 'reply' ) {
 963+// callback = replyCallback;
 964+// }
 965+//
 966+// if ( type == 'talkpage_new_thread' ) {
 967+// callback = newCallback;
 968+// }
 969+//
 970+// if ( type == 'edit' ) {
 971+// callback = editCallback;
 972+// }
 973+//
 974+// editform.empty().hide();
 975+//
 976+// callback(data);
 977+//
 978+// // Load the new TOC
 979+// liquidThreads.reloadTOC();
 980+// };
 981+//
 982+// if ( type == 'reply' ) {
 983+// liquidThreads.doReply( replyThread, text, summary,
 984+// doneCallback, bump, signature );
 985+//
 986+// e.preventDefault();
 987+// } else if ( type == 'new' ) {
 988+// var container = editform.closest('.lqt-new-thread');
 989+// var page = container.data('lqt-talkpage');
 990+// liquidThreads.doNewThread( page, subject, text, summary,
 991+// doneCallback, bump, signature );
 992+//
 993+// e.preventDefault();
 994+// } else if ( type == 'edit' ) {
 995+// liquidThreads.doEditThread( replyThread, subject, text, summary,
 996+// doneCallback, bump, signature );
 997+// e.preventDefault();
 998+// }
889999
8901000 'handleAJAXSave' : function( e ) {
 1001+ e.preventDefault();
8911002 var editform = $j(this).closest('.lqt-edit-form');
892 - var type = editform.find('input[name=lqt_method]').val();
893 - var wikiEditorContext = editform.find('#wpTextbox1').data( 'wikiEditor-context' );
 1003+ var params = $.extend( {}, editform.data('params') );
 1004+ var type = params.form;
 1005+ var wikiEditorContext = editform.find('.lqt-editform-textbox').data( 'wikiEditor-context' );
8941006 var text;
8951007
8961008 if ( !wikiEditorContext || typeof(wikiEditorContext) == 'undefined' ||
8971009 ! wikiEditorContext.$iframe) {
898 - text = editform.find('#wpTextbox1').val();
 1010+ text = editform.find('.lqt-editform-textbox').val();
8991011 } else {
9001012 text = wikiEditorContext.$textarea.textSelection( 'getContents' );
9011013 }
9021014
903 - var summary = editform.find('#wpSummary').val();
 1015+ var summary = editform.find('#lqt-summary').val();
9041016
9051017 var signature;
906 - if ( editform.find('input[name=wpLqtSignature]').length ) {
907 - signature = editform.find('input[name=wpLqtSignature]').val();
 1018+ if ( editform.find('input[name=lqt-signature]').length ) {
 1019+ signature = editform.find('input[name=lqt-signature]').val();
9081020 } else {
9091021 signature = undefined
9101022 }
@@ -913,101 +1025,29 @@
9141026 summary = '';
9151027 }
9161028
917 - var subject = editform.find( '#lqt_subject_field' ).val();
918 - var replyThread = editform.find('input[name=lqt_operand]').val();
919 - var bump = editform.find('#wpBumpThread').is(':checked') ? 1 : 0;
 1029+ var subject = editform.find( '#lqt-subject' ).val();
9201030
9211031 var spinner = $j('<div class="mw-ajax-loader"/>');
9221032 editform.prepend(spinner);
923 -
924 - var replyCallback = function( data ) {
925 - $parent = $j( '#lqt-post-tree-wrapper_id_' + data.threadaction.thread['parent-id'] );
926 - $html = $j( data.threadaction.thread['html'] );
927 - $newThread = $html.find( '#lqt-post-tree-wrapper_id_' + data.threadaction.thread['thread-id'] );
928 - $parent.find( '.lqt-replies:first' ).append( $newThread );
929 - $parent.closest( '.lqt-thread-topmost' )
930 - .find( 'input.lqt-thread-modified' )
931 - .val( data.threadaction.thread['modified'] );
932 - liquidThreads.setupThread( $newThread.find( '.lqt-post-wrapper' ) );
933 - $j( 'html,body' ).animate({scrollTop: $newThread.offset().top}, 'slow');
934 - };
935 -
936 - var newCallback = function( data ) {
937 - var $newThread = $j( data.threadaction.thread['html'] );
938 - $j( '.lqt-threads' ).prepend( $newThread );
939 - // remove the no threads message if it's on the page
940 - $j('.lqt-no-threads').remove();
941 - liquidThreads.setupThread( $newThread.find( '.lqt-post-wrapper' ) );
942 - $j( 'html,body' ).animate( { scrollTop: $newThread.offset().top }, 'slow' );
943 - };
944 -
945 - var editCallback = function( data ) {
946 - var thread = editform.closest('.lqt-thread-topmost');
947 -
948 - liquidThreads.doReloadThread( thread );
 1033+
 1034+ params.token = editform.data('token');
 1035+ params.submit = 1;
 1036+ if ( type == 'new' ) {
 1037+ params.subject = subject;
 1038+ params.content = text;
 1039+ params.signature = signature;
 1040+
 1041+ liquidThreads.apiRequest( params, function() {
 1042+ window.location.reload(true);
 1043+ } );
 1044+ } else if ( type == 'reply' ) {
 1045+ params.content = text;
 1046+ params.signature = signature;
 1047+
 1048+ liquidThreads.apiRequest( params, function() {
 1049+ window.location.reload(true);
 1050+ } );
9491051 }
950 -
951 - var doneCallback = function(data) {
952 - try {
953 - var result = data.threadaction.thread.result;
954 - } catch ( err ) {
955 - result = 'error';
956 - }
957 -
958 - if ( result != 'Success' ) {
959 - // Create a hidden field to mimic the save button, and
960 - // submit it normally, so they'll get a real error message.
961 -
962 - var saveHidden = $j('<input/>');
963 - saveHidden.attr( 'type', 'hidden' );
964 - saveHidden.attr( 'name', 'wpSave' );
965 - saveHidden.attr( 'value', 'Save' );
966 -
967 - var form = editform.find('#editform');
968 - form.append(saveHidden);
969 - form.submit();
970 - return;
971 - }
972 -
973 - var callback;
974 -
975 - if ( type == 'reply' ) {
976 - callback = replyCallback;
977 - }
978 -
979 - if ( type == 'talkpage_new_thread' ) {
980 - callback = newCallback;
981 - }
982 -
983 - if ( type == 'edit' ) {
984 - callback = editCallback;
985 - }
986 -
987 - editform.empty().hide();
988 -
989 - callback(data);
990 -
991 - // Load the new TOC
992 - liquidThreads.reloadTOC();
993 - };
994 -
995 - if ( type == 'reply' ) {
996 - liquidThreads.doReply( replyThread, text, summary,
997 - doneCallback, bump, signature );
998 -
999 - e.preventDefault();
1000 - } else if ( type == 'talkpage_new_thread' ) {
1001 - var container = editform.closest('.lqt-new-thread');
1002 - var page = container.data('lqt-talkpage');
1003 - liquidThreads.doNewThread( page, subject, text, summary,
1004 - doneCallback, bump, signature );
1005 -
1006 - e.preventDefault();
1007 - } else if ( type == 'edit' ) {
1008 - liquidThreads.doEditThread( replyThread, subject, text, summary,
1009 - doneCallback, bump, signature );
1010 - e.preventDefault();
1011 - }
10121052 },
10131053
10141054 'reloadTOC' : function() {
@@ -1031,87 +1071,6 @@
10321072 } );
10331073 },
10341074
1035 - 'doNewThread' : function( talkpage, subject, text, summary, callback, bump, signature ) {
1036 - liquidThreads.getToken(
1037 - function(token) {
1038 - var newTopicParams =
1039 - {
1040 - 'action' : 'threadaction',
1041 - 'threadaction' : 'newthread',
1042 - 'talkpage' : talkpage,
1043 - 'subject' : subject,
1044 - 'text' : text,
1045 - 'token' : token,
1046 - 'format' : 'json',
1047 - 'render' : '1',
1048 - 'reason' : summary,
1049 - 'bump' : bump
1050 - };
1051 -
1052 - if ( typeof signature != 'undefined' ) {
1053 - newTopicParams.signature = signature;
1054 - }
1055 -
1056 - $j.post( wgScriptPath+'/api'+wgScriptExtension, newTopicParams,
1057 - function(data) {
1058 - if (callback) {
1059 - callback(data);
1060 - }
1061 - }, 'json' );
1062 - } );
1063 - },
1064 -
1065 - 'doReply' : function( thread, text, summary, callback, bump, signature ) {
1066 - liquidThreads.getToken(
1067 - function(token) {
1068 - var replyParams =
1069 - {
1070 - 'action' : 'threadaction',
1071 - 'threadaction' : 'reply',
1072 - 'thread' : thread,
1073 - 'text' : text,
1074 - 'token' : token,
1075 - 'format' : 'json',
1076 - 'render' : '1',
1077 - 'reason' : summary,
1078 - 'bump' : bump
1079 - };
1080 -
1081 - if ( typeof signature != 'undefined' ) {
1082 - replyParams.signature = signature;
1083 - }
1084 -
1085 - $j.post( wgScriptPath+'/api'+wgScriptExtension, replyParams,
1086 - function(data) {
1087 - if (callback) {
1088 - callback(data);
1089 - }
1090 - }, 'json' );
1091 - } );
1092 - },
1093 -
1094 - 'doEditThread' : function( thread, subject, text, summary,
1095 - callback, bump, signature ) {
1096 - var request =
1097 - {
1098 - 'action' : 'threadaction',
1099 - 'threadaction' : 'edit',
1100 - 'thread' : thread,
1101 - 'text' : text,
1102 - 'format' : 'json',
1103 - 'render' : 1,
1104 - 'reason' : summary,
1105 - 'bump' : bump,
1106 - 'subject':subject
1107 - };
1108 -
1109 - if ( typeof signature != 'undefined' ) {
1110 - request.signature = signature;
1111 - }
1112 -
1113 - liquidThreads.apiRequest( request, callback );
1114 - },
1115 -
11161075 'onTextboxKeyUp' : function(e) {
11171076 // Check if a user has signed their post, and if so, tell them they don't have to.
11181077 var text = $j(this).val().trim();
@@ -1133,25 +1092,15 @@
11341093 },
11351094
11361095 'apiRequest' : function( request, callback ) {
1137 - // Set new subject through API.
1138 - liquidThreads.getToken( function(token) {
 1096+ request.format = 'json';
11391097
1140 - if ( typeof request == 'function' ) {
1141 - request = request(token);
1142 - } else {
1143 - request.token = token;
1144 - }
1145 -
1146 - request.format = 'json';
1147 -
1148 - var path = wgScriptPath+'/api'+wgScriptExtension;
1149 - $j.post( path, request,
1150 - function(data) {
1151 - if (callback) {
1152 - callback(data);
1153 - }
1154 - }, 'json' );
1155 - } );
 1098+ var path = wgScriptPath+'/api'+wgScriptExtension;
 1099+ $j.post( path, request,
 1100+ function(data) {
 1101+ if (callback) {
 1102+ callback(data);
 1103+ }
 1104+ }, 'json' );
11561105 },
11571106
11581107 'activateDragDrop' : function(e) {
@@ -1537,7 +1486,7 @@
15381487 var container = $j(this).parent();
15391488
15401489 container.find('.lqt-signature-preview').hide();
1541 - container.find('input[name=wpLqtSignature]').show();
 1490+ container.find('input[name=lqt-signature]').show();
15421491 $j(this).hide();
15431492
15441493 // Add a save button
@@ -1545,7 +1494,7 @@
15461495 saveButton.text( mediaWiki.msg('lqt-preview-signature') );
15471496 saveButton.click( liquidThreads.handlePreviewSignature );
15481497
1549 - container.find('input[name=wpLqtSignature]').after(saveButton);
 1498+ container.find('input[name=lqt-signature]').after(saveButton);
15501499 },
15511500
15521501 'handlePreviewSignature' : function(e) {
@@ -1556,7 +1505,7 @@
15571506 var spinner = $j('<span class="mw-small-spinner"/>');
15581507 $j(this).replaceWith(spinner);
15591508
1560 - var textbox = container.find('input[name=wpLqtSignature]');
 1509+ var textbox = container.find('input[name=lqt-signature]');
15611510 var preview = container.find('.lqt-signature-preview');
15621511
15631512 textbox.hide();
@@ -1570,11 +1519,11 @@
15711520 'prop' : 'text'
15721521 };
15731522
1574 - liquidThreads.apiRequest( function() { return apiReq; },
 1523+ liquidThreads.apiRequest( apiReq,
15751524 function(data) {
15761525 var html = $j(data.parse.text['*'].trim());
15771526
1578 - if (html.length == 2) { // Not 1, because of the NewPP report
 1527+ if (html.length == 3) { // Not 1, because of the NewPP report and space
15791528 html = html.contents();
15801529 }
15811530
@@ -1628,8 +1577,8 @@
16291578 $j('.lqt-command-edit > a').live( 'click', liquidThreads.handleEditLink );
16301579
16311580 // Save handlers
1632 - $j('#wpSave').live( 'click', liquidThreads.handleAJAXSave );
1633 - $j('#wpTextbox1').live( 'keyup', liquidThreads.onTextboxKeyUp );
 1581+ $j('.lqt-save').live( 'click', liquidThreads.handleAJAXSave );
 1582+ $j('.lqt-edit-content').live( 'keyup', liquidThreads.onTextboxKeyUp );
16341583 $j('#wpPreview').die('click');
16351584 $j('#wpPreview').live('click', liquidThreads.doLivePreview );
16361585

Status & tagging log