r78291 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78290‎ | r78291 | r78292 >
Date:01:41, 13 December 2010
Author:brion
Status:deferred
Tags:
Comment:
SVGEdit extension updates from git workspace:

66e3f59 SVGEdit extension: check for SVG support in the browser before showing edit button on SVG file page
ea93430 Check edit & upload permissions on SVG file page before prepping the editor button.
a0dd1c7 Darken/block svg-edit screen & show a spinner during load/save to/from the wiki
88035e0 add .DS_Store to .gitignore
Modified paths:
  • /trunk/extensions/SVGEdit/.gitignore (modified) (history)
  • /trunk/extensions/SVGEdit/README (modified) (history)
  • /trunk/extensions/SVGEdit/SVGEdit.hooks.php (modified) (history)
  • /trunk/extensions/SVGEdit/modules/ext.svgedit.editButton.js (modified) (history)
  • /trunk/extensions/SVGEdit/svg-edit/extensions/ext-mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SVGEdit/svg-edit/extensions/ext-mediawiki.js
@@ -198,14 +198,6 @@
199199
200200 svgEditor.addExtension("mediawiki", {
201201 callback: function() {
202 - // Load up the original file!
203 - var filename = mwSVG.config('wgTitle');
204 - mwSVG.fetchSVG(filename, function(xmlSource, textStatus, xhr) {
205 - svgCanvas.clear();
206 - svgCanvas.setSvgString(xmlSource);
207 - svgEditor.updateCanvas();
208 - });
209 -
210202 // Add save/close buttons...
211203 $('body').append('<div id="mw-svgedit-buttons">' +
212204 '<button id="mw-svgedit-save"></button>' +
@@ -216,9 +208,11 @@
217209 $('#mw-svgedit-save')
218210 .text(mediaWiki.msg('svgedit-editor-save-close'))
219211 .click(function() {
 212+ $('#mw-svgedit-spinner').show();
220213 var svg = svgCanvas.getSvgString();
221214 var comment = "Modified in svg-edit";
222215 mwSVG.saveSVG(filename, svg, comment, function(data, textStatus, xhr) {
 216+ $('#mw-svgedit-spinner').hide();
223217 if (data.upload && data.upload.result == "Success") {
224218 // refresh parent window
225219 window.parent.location = window.parent.location;
@@ -237,6 +231,29 @@
238232 window.close();
239233 }
240234 });
 235+
 236+ // Loading spinner...
 237+ $('body').append('<div id="mw-svgedit-spinner"></div>')
 238+ $('#mw-svgedit-spinner')
 239+ .attr('style', 'position: absolute;' +
 240+ 'top: 0;' +
 241+ 'left: 0;' +
 242+ 'right: 0;' +
 243+ 'bottom: 0;' +
 244+ 'background: rgba(0,0,0,0.5)' +
 245+ ' url("../images/ajax-loader.gif")' +
 246+ ' 50%' +
 247+ ' no-repeat;' +
 248+ 'z-index: 999999')
 249+
 250+ // Load up the original file!
 251+ var filename = mwSVG.config('wgTitle');
 252+ mwSVG.fetchSVG(filename, function(xmlSource, textStatus, xhr) {
 253+ svgCanvas.clear();
 254+ svgCanvas.setSvgString(xmlSource);
 255+ svgEditor.updateCanvas();
 256+ $('#mw-svgedit-spinner').hide();
 257+ });
 258+
241259 }
242260 });
243 -
Index: trunk/extensions/SVGEdit/.gitignore
@@ -1,2 +1,3 @@
22 *~
33 .svn
 4+.DS_Store
\ No newline at end of file
Index: trunk/extensions/SVGEdit/modules/ext.svgedit.editButton.js
@@ -4,6 +4,15 @@
55 */
66
77 $(document).ready(function() {
 8+ // We probably should check http://www.w3.org/TR/SVG11/feature#SVG-dynamic
 9+ // but Firefox is missing a couple random subfeatures.
 10+ //
 11+ // Chrome, Safari, Opera, and IE 9 preview all return true for it!
 12+ //
 13+ if (!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Shape', '1.1')) {
 14+ return;
 15+ }
 16+
817 var mw = mediaWiki;
918 if (mw.config.get('wgCanonicalNamespace') == 'File'
1019 && mw.config.get('wgAction') == 'view'
Index: trunk/extensions/SVGEdit/README
@@ -22,7 +22,6 @@
2323 * Actual editor issues belong upstream: http://code.google.com/p/svg-edit/
2424 * open seems to have some race conditions (sometimes doesn't load the initial file)
2525 * save-and-close seems to have some race conditions (sometimes shows a 'sure you want to leave?' prompt)
26 -* doesn't check if your browser supports SVG before offering the edit button
2726
2827 Todo:
2928 * add an editor trigger on SVG images visible in regular page views
Index: trunk/extensions/SVGEdit/SVGEdit.hooks.php
@@ -17,7 +17,9 @@
1818 */
1919 public static function beforePageDisplay( $out, $skin ) {
2020 $title = $out->getTitle();
21 - if( $title && $title->getNamespace() == NS_FILE ) {
 21+ if( $title && $title->getNamespace() == NS_FILE &&
 22+ $title->userCan( 'edit' ) && $title->userCan( 'upload' ) ) {
 23+
2224 $out->addModules('ext.svgedit.editButton');
2325 }
2426 return true;

Status & tagging log