Index: trunk/extensions/SVGEdit/svg-edit/extensions/ext-mediawiki.js |
— | — | @@ -198,14 +198,6 @@ |
199 | 199 | |
200 | 200 | svgEditor.addExtension("mediawiki", { |
201 | 201 | 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 | | - |
210 | 202 | // Add save/close buttons... |
211 | 203 | $('body').append('<div id="mw-svgedit-buttons">' + |
212 | 204 | '<button id="mw-svgedit-save"></button>' + |
— | — | @@ -216,9 +208,11 @@ |
217 | 209 | $('#mw-svgedit-save') |
218 | 210 | .text(mediaWiki.msg('svgedit-editor-save-close')) |
219 | 211 | .click(function() { |
| 212 | + $('#mw-svgedit-spinner').show(); |
220 | 213 | var svg = svgCanvas.getSvgString(); |
221 | 214 | var comment = "Modified in svg-edit"; |
222 | 215 | mwSVG.saveSVG(filename, svg, comment, function(data, textStatus, xhr) { |
| 216 | + $('#mw-svgedit-spinner').hide(); |
223 | 217 | if (data.upload && data.upload.result == "Success") { |
224 | 218 | // refresh parent window |
225 | 219 | window.parent.location = window.parent.location; |
— | — | @@ -237,6 +231,29 @@ |
238 | 232 | window.close(); |
239 | 233 | } |
240 | 234 | }); |
| 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 | + |
241 | 259 | } |
242 | 260 | }); |
243 | | - |
Index: trunk/extensions/SVGEdit/.gitignore |
— | — | @@ -1,2 +1,3 @@ |
2 | 2 | *~ |
3 | 3 | .svn |
| 4 | +.DS_Store |
\ No newline at end of file |
Index: trunk/extensions/SVGEdit/modules/ext.svgedit.editButton.js |
— | — | @@ -4,6 +4,15 @@ |
5 | 5 | */ |
6 | 6 | |
7 | 7 | $(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 | + |
8 | 17 | var mw = mediaWiki; |
9 | 18 | if (mw.config.get('wgCanonicalNamespace') == 'File' |
10 | 19 | && mw.config.get('wgAction') == 'view' |
Index: trunk/extensions/SVGEdit/README |
— | — | @@ -22,7 +22,6 @@ |
23 | 23 | * Actual editor issues belong upstream: http://code.google.com/p/svg-edit/ |
24 | 24 | * open seems to have some race conditions (sometimes doesn't load the initial file) |
25 | 25 | * 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 |
27 | 26 | |
28 | 27 | Todo: |
29 | 28 | * add an editor trigger on SVG images visible in regular page views |
Index: trunk/extensions/SVGEdit/SVGEdit.hooks.php |
— | — | @@ -17,7 +17,9 @@ |
18 | 18 | */ |
19 | 19 | public static function beforePageDisplay( $out, $skin ) { |
20 | 20 | $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 | + |
22 | 24 | $out->addModules('ext.svgedit.editButton'); |
23 | 25 | } |
24 | 26 | return true; |