r90504 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90503‎ | r90504 | r90505 >
Date:00:41, 21 June 2011
Author:brion
Status:deferred
Tags:
Comment:
ParserPlayground: save round-tripped source back into the editor so you can save, preview, or diff it.
Modified paths:
  • /trunk/extensions/ParserPlayground/modules/ext.parserPlayground.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserPlayground/modules/ext.parserPlayground.js
@@ -144,9 +144,7 @@
145145 'action': {
146146 'type': 'callback',
147147 'execute': function( context ) {
148 - context.parserPlayground.parser = undefined;
149 - context.parserPlayground.tree = undefined;
150 - context.parserPlayground.fn.hide();
 148+ context.parserPlayground.fn.disable();
151149 }
152150 }
153151 }
@@ -196,16 +194,39 @@
197195 setupInspector($target, $inspector, renderMap, treeMap);
198196 }, renderMap);
199197 });
 198+
 199+ context.$textarea.closest('form').submit( context.parserPlayground.fn.onSubmit );
 200+
200201 },
201202 hide: function() {
202203 $('#pegparser-source').hide(); // it'll reshow; others won't need it
203204 context.$iframe = undefined;
204 - context.$parserContainer.remove();
 205+ if (context.$parserContainer !== undefined) {
 206+ context.$parserContainer.remove();
 207+ }
205208 context.$parserContainer = undefined;
206 - context.$parserInspector.remove();
 209+ if (context.$parserInspector !== undefined) {
 210+ context.$parserInspector.remove();
 211+ }
207212 context.$parserInspector = undefined;
208213 context.$textarea.show();
209214 },
 215+ disable: function() {
 216+ var pp = context.parserPlayground;
 217+ var finish = function() {
 218+ pp.parser = undefined;
 219+ pp.tree = undefined;
 220+ pp.fn.hide();
 221+ };
 222+ if (pp.parser && pp.tree) {
 223+ pp.parser.treeToSource( pp.tree, function( src, err ) {
 224+ context.$textarea.val( src );
 225+ finish();
 226+ });
 227+ } else {
 228+ finish();
 229+ }
 230+ },
210231 toggleInspector: function() {
211232 if (context.parserPlayground.useInspector) {
212233 context.parserPlayground.useInspector = false;
@@ -242,6 +263,11 @@
243264 return false;
244265 }
245266 });
 267+ },
 268+ onSubmit: function() {
 269+ // @fixme if we're really doing async, this might not apply right
 270+ // disable the old thingy and record the updated text before finishing submit
 271+ context.parserPlayground.fn.disable();
246272 }
247273 }
248274 }

Status & tagging log