Commit graph

58 commits

Author SHA1 Message Date
Timo Tijhof bdd7aa5e3c mw.ViewPageTarget: Fire 'wikipage.content' hook after saving
Bug: 51565
Change-Id: I5b6dcd3cb425d2763cc3069e3cbc04be7a57af4c
2013-07-30 19:35:31 +02:00
Ed Sanders f5c8af541a Set links in wikitext warning to load in new window
Bug: 52093
Bug: 49820
Change-Id: I20ef246b6382ce801ce7a2cb0c82bc698471b88e
2013-07-30 13:11:53 +00:00
jenkins-bot 40e712985c Merge "Add keyboard shortcut for 'clear' button" 2013-07-30 00:51:19 +00:00
James D. Forrester bc3cc9bbdc Add keyboard shortcut for 'clear' button
Now Ctrl+\ (Cmd+\ on Mac) will trigger the 'clear annotations' button
on the current context. Ideally we'd also bond to the 'clear' keyboard
button (ASCII 12) but it does not seem possible to do that yet.

Bug: 51507
Change-Id: I300ec1ffa237e51418ec429be39001f820f053ae
2013-07-30 00:14:17 +00:00
Timo Tijhof 44623c9b2a ve.copy: Remove obsolete copyArray and copyObject
These have been pointing to the same method for a while now,
we can safely remove these obsolete aliases and just use it
as generic copy.

* Each file touched by my editor had its new line at EOF fixed
  where absent
* Don't copy an otherwise unused empty object
  (ve.dm.Converter)
* Use common ve#copy syntax instead to create a link
  (ve.dm.Document, ve.dm.example)
* Remove redundant conditionals for isArray/copyArray/copyObject
  (ve.dm.example)

Change-Id: If560e658dc1fb59bf01f702c97e3e82a50a8a255
2013-07-30 01:44:22 +02:00
jenkins-bot 529199802c Merge "mw.ViewPageTarget: Clean up nested binds and triple model/connect" 2013-07-29 23:25:02 +00:00
jenkins-bot d0a6e70b1e Merge "Use postEdit mw.hook for save notifications" 2013-07-29 23:23:11 +00:00
Ed Sanders 138270e8ef Use postEdit mw.hook for save notifications
The core changes to postedit in I778b18b that this depends on were
deployed to the cluster as part of 1.22wmf11.

Bug: 39632
Change-Id: Id4a8bc22c09a552ef79670b0d4fc4a70df07ec33
2013-07-29 21:49:46 +00:00
jenkins-bot 9c77d14c29 Merge "Properly clone the document for the sanity check" 2013-07-29 19:45:02 +00:00
MatmaRex 54c5230b01 Unblacklist Opera >= 12
Opera 12 seems to work well enough, but I'm not confident enough to
whitelist it just yet.

Opera 15 is basically Chrome with a different interface, so it should
work perfectly, but it's barely out of beta and untested right now.

Bug: 36000
Change-Id: Ia80a6f53f8c128ef52d0bfde1828fdc132046afb
2013-07-29 12:30:06 -07:00
Timo Tijhof b0e8900a02 mw.ViewPageTarget: Clean up nested binds and triple model/connect
Change-Id: I67cabfdf0247dd0951b7d4f26c99d621aa2f7b0d
2013-07-26 23:54:04 +00:00
Roan Kattouw be9495d31e Properly clone the document for the sanity check
Previously, we'd clone the data but convert it in the context of
the existing dm.Document, whose nodes had pointers to elements in the
old data array, not to the cloned ones. Because dm.MWReferenceNode
has logic like if ( something === dataElement ), this caused the sanity
check conversion to behave slightly differently compared to the real
conversion that happens on save, and so a references corruption
bug went unnoticed.

Change-Id: I79a42ae21f91cb8eb410ae26ea638036db19e217
2013-07-26 15:33:58 -07:00
jenkins-bot b8ea6a22ac Merge "Code annotation button" 2013-07-26 19:41:34 +00:00
Ed Sanders fadd7c46a2 Code annotation button
Pretty straightforward, although we should start thinking about
grouping/hiding 'advanced' formatting options in the toolbar.

Making this button experimental for now until we've come up with
a way to deal with this problem.

Bug: 51590
Change-Id: Ieb1935b742aced4b883d8a194e6cb69be68473d0
2013-07-26 12:36:34 -07:00
Roan Kattouw e49df7f9d9 Infrastructure for loading plugins in the MW integration
Server-side, plugins can register themselves by adding to
$wgVisualEditorPluginModules. This is the recommended way for
MW extensions to extend VE. Client-side, plugins can register
themselves through mw.libs.ve.addPlugin(), which takes a string
(RL module name) or a callback.

When VisualEditor loads, we load the registered plugin modules in
parallel with ext.visualEditor.core. Note that they're loaded in
parallel, not after, and so the plugins should explicitly depend
on ext.visualEditor.core if they use or extend classes in VE core.
Once the modules finish loading and user and site scripts have run,
we execute the registered plugin callbacks. These callbacks can
optionally return a promise. We gather these promises and wait for
all of them to be resolved, then initialize the editor.

This allows Gadgets to extend VE by top-loading a small module that
depends on ext.visualEditor.viewPageTarget.init and calls
mw.libs.ve.addPlugin( 'ext.gadget.bottomHalfGadget' ); , the bottom
half being a hidden Gadget that depends on ext.visualEditor.core and
contains the actual code. The addPlugin() call needs to be in a
top-loading module because otherwise there's no guarantee that the
plugin will be registered before the user clicks edit and VE loads.

User and site scripts can extend VE by simply calling addPlugin()
directly, as mw.libs.ve is already present when user scripts run (since
it's top-loaded) and VE waits for 'user' and 'site' to run before
executing plugins.

If user/site scripts need to load additional JS files, they can load
these with $.getScript() and return the corresponding promise:
mw.libs.ve.addPlugin( function() { return $.getScript( 'URL' ); } );

For a diagram of all this, see
https://www.mediawiki.org/wiki/File:VE-plugin-infrastructure.jpg :)

VisualEditor.php:
* Add $wgVisualEditorPluginModules

VisualEditor.hooks.php:
* Expose $wgVisualEditorPluginModules in JS

ve.init.mw.ViewPageTarget.init.js:
* Add mw.libs.ve.addPlugin function that just stores the registered
  values in an array and passes them into the mw.Target when it's
  being initialized

ve.init.mw.Target.js:
* Add $wgVisualEditorPluginModules to the set of modules to load when
  initializing VE
* Add a Deferred (this.modulesReady) to track module loading
* Add addPlugin() and addPlugins() methods that add to either
  this.modules or this.pluginCallbacks
* In load(), instead of mw.loader.load()ing this.modules, use using()
  to load this.modules plus user and site, and fire onModulesReady()
  when they're loaded
* In onModulesReady(), execute the registered callbacks, gather the
  returned promises, wait for all of them to be resolved, then resolve
  this.modulesReady
* Fire onReady based on this.modulesReady being resolved, rather than
  using a second using() call

Bug: 50514
Change-Id: Ib7d87a17eaac6ecdb8b0803b13840d7ee58902df
2013-07-26 19:31:56 +00:00
Ed Sanders 326347b5a9 Fix font size for overlays in Monobook
Bug: 50058
Change-Id: I751682c4bc51299c15e7efef487ae32e70049b16
2013-07-25 00:12:01 +01:00
Roan Kattouw 81d3bde440 Fix copyright warning, which wasn't populated due to a missing .end()
Change-Id: I1a04a40415f3fcf8d11b49e5c90672ee625a85f7
2013-07-24 11:51:35 -07:00
Ed Sanders 7557dd39ed Show error when trying to save in read-only mode
We already correctly show the read only error if the user tries
to load VE which the database is locked, but if the database gets
locked after they've loaded VE, we also need to show the error
when they try to save.

Bug: 51636
Change-Id: I7a56f1b4387e7ea594a2a7f939c81626c9eee834
2013-07-24 14:33:10 +00:00
Roan Kattouw 393807462e Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.

ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them

ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
  through to EditPage thanks to Idab5b524b0e3 in core

ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
  and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
   ve.init.mw.Target.prototype.save(), because here we know which ones
   are checkboxes and we don't know that in save() without
   special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
  rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
   logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout

ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API

Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 00:02:14 -07:00
jenkins-bot fd2fa931cb Merge "Hide contentSub completely" 2013-07-24 05:03:36 +00:00
Roan Kattouw 74e6b716a5 Hide contentSub completely
Previously it was faded out to 60%. contentSub contains FlaggedRevs
stuff we don't want around in the editor, and contains the revision
navigation when editing an oldid, which James decided also shouldn't
be visible when editing.

Change-Id: Icdef98f756ce92a32d276d6eeb22c9de04640d8b
2013-07-23 22:00:48 -07:00
jenkins-bot 71953d7ca6 Merge "Set target=_blank for links in the edit notices" 2013-07-24 04:49:55 +00:00
James D. Forrester 0536d22370 Create temporary preference to disable VisualEditor during beta
This preference will allow users to opt-out of VisualEditor during the beta
if they so choose. We do not re-use the alpha enablement flag because (a) this
would lead to a confusing preference description, and (b) because opting in
and then out of the alpha is not the same user choice as opting out of the
beta period.

Change-Id: I0f0a1b5eb21703ad422d007cab65c75ac1aa6fd8
2013-07-24 01:59:47 +00:00
Roan Kattouw 64442148bf Set target=_blank for links in the edit notices
Change-Id: I63bbf557fa94cda7435614ba7d743e22a148fdce
2013-07-23 18:19:45 -07:00
Ed Sanders 4e17496fa6 Prepend section title to edit summary
When section edit links are used.

Bug: 50872
Change-Id: I44cef7a892b4f2f22f60f8f7f531f4e9dcfe8363
2013-07-23 22:27:33 +00:00
Timo Tijhof a81beef27a mw.ViewPageTarget.init: Move conditionals client-side
Load the module always and have the conditionals on the
client-side so that we can change these without running into
problems with the new conditions not being rolled-out quickly
for anonymous users because the load queue is in the HTML
and cached for 30+ days.

This also allows us to fix above problem retroactively in wmf
production by just adding a mw.loader.load for this module
in something like MediaWiki:Common.js or something else that is
already in the cached load queue (temporarily, until the cache
has rolled over).

Removed unreachable code for loading ext.visualEditor.splitTest.

Change-Id: I21114960a88d224747447f2dc83d17d160f5f066
2013-07-23 20:25:37 +02:00
Timo Tijhof 61a1e8c738 mw.ViewPageTarget.init: Expose support.visualEditor
Refactor a few things to make it easier for scripts to see
not just whether mw.libs.ve is present but also whether it
allows the user to activate VisualEditor.

Change-Id: I50da8d9a260207d4ec1c43254dfe738f91386a9e
2013-07-19 03:56:25 +02:00
Trevor Parscal 61ba07d409 Reference dialog commingling
Objectives:

* Merge reference insert and edit dialogs
* Change workflow to put editing/creating a new reference first
* Add secondary page in dialog for selecting an existing reference

Changes:

*.php
* Cleanup unused files/messages

ve.ui.Dialog.css
* In the footer; make primary, constructive and destructive buttons
  appear on the right; all others on the left

ve.ui.MWReferenceSearchWidget.js
* Fix documentation
* Remove create option and reuse section header items

ve.ui.MWReferenceInsertButtonTool.js,
ve.ui.MWReferenceEditButtonTool.js,
ve.ui.MWReferenceButtonTool.js
* Merge reference button tools

ve.ui.MWDialog.css
* Remove body styles, use padded option of layout instead
* Update selectors as per merging of dialogs

ve.ui.MWReferenceInsertDialog.js
ve.ui.MWReferenceEditDialog.js
ve.ui.MWReferenceDialog.js
* Merge reference dialogs
* Add buttons to switch between edit and select mode

ve.init.mw.ViewPageTarget.js
* Update reference button name as per merging of tools

ve.ui.SurfaceWidget.js
* New widget!
* Encapsulates a "sub-surface"

Bug: 51152
Bug: 50458
Change-Id: I8265febf4fd8f64d2ac40470ff033bac68b24d99
2013-07-18 14:14:14 -07:00
Timo Tijhof 553102644f mw.ViewPageTarget: Show AbuseFilter warning in save dialog
Misc:
* Updated signature of #showMessage to include allowing
  an array of nodes to be passed. We pass this to jQuery#append
  so we're just extending the explicitly documented subset of
  things it could already do due to passing to jQuery#append.

Bug: 50472
Change-Id: I3f56820a4f14b0684bfa265e3eb5e3820f2a3513
2013-07-17 17:20:29 +00:00
Eloquence c5de7696a7 Make beta notice more informative and increase CSS width.
Point out that the software may have issues, and point users to the "Edit source"
link explicitly.

Change-Id: Id84d76887038a3a6a9e11a203f19dc3db7703e6a
2013-07-16 18:49:39 -07:00
Timo Tijhof 16831b16d1 mw.ViewPageTarget: Add support for spam blacklist
Bug: 50826
Change-Id: Icdc2730e5fc644c9030a6648702e071934f5ad62
2013-07-16 23:39:27 +02:00
Timo Tijhof bc7836d1ab mw.ViewPageTarget: Swap captcha and badtoken logic in onSaveError
This way if both are the case, the user (or VE, if possible)
will deal with badtoken first instead of potentially having to
solve the captcha twice (as each handling of the error does - and
should - end with an early return).

Change-Id: I9e4264a7001ffa9654bfab02cc955aa36ff5b6aa
2013-07-16 16:02:27 +02:00
Timo Tijhof 43bce96fae mw.ViewPageTarget: Surface error messages from core edit api
Previously we only looked at error info/code from the root of
the API response, not the ones from the root of the response
that action=visualeditoredit forwards from action=edit.

This changes the message for e.g. AbuseFilter from:

 > Error: Invalid error code

to:

 > Error: Hit AbuseFilter: [name of triggered filter]

Also changed default error for other reasons (e.g. hooks of other
extensions that we don't yet have specific support for) to "Unknown error"
instead of "Invalid error code".

Bug: 50472
Change-Id: I3b32eddafd8fff83f323606f9922ac60b5d3b58e
2013-07-15 22:22:55 +00:00
Timo Tijhof 45c79f8c23 mw.ViewPageTarget: Refetch token if session expired
* Rephrased visualeditor-savedialog-error-badtoken to emphasise
  that it is the old session that become invalid, not the one
  the user started browsing with since in a different window.
* If the session changed, the user will be asked whether they
  agree to save with this new session instead.
* We explictly update mw.config so that future save attempts
  in the same window compare against the correct environment.
  Without this there are two problems when saving and then
  making a second edit in the same window and saving that:
  - It will bring up the same question again (user A -> user B),
    which is annoying.
  - If the user logged back in again (new session, but for
    user A again) it would silently try with that new token
    without asking, thus saving as user A when the user still
    thinks it switched to user B. It switching back automatically
    is not obvious since we asked them from A->B, so we should
    also ask the other way around.
  This can be reproduced by opending ve-edit logged-in, then
  logging out in a new window, save, confirm anon, save,
  open edit again, log back in in a new window, save open edit
  in the old window, confirm new logged-in, save.

Bug: 50424
Change-Id: Id055eca1886f85aeaf615f645de29898afc0373c
2013-07-15 21:40:18 +02:00
Ed Sanders abf3671723 Warn users when they are typing wikitext
Without making the code much more complex (and possibly create
performance issues) the warning will fire on pages which already
contain escaped wikitext (when that text is edited). I think this
should be a small enough minority that it won't be an major annoyance.

Bug: 49820
Change-Id: I0f67ec04b890f4add9247be6126bdc086b6ae72f
2013-07-14 19:27:32 -07:00
Timo Tijhof c292e326e8 mw.ViewPageTarget: Improve error message for badtoken error
Previously all it did was surface api response error.info,
which surfaced underneath the edit summary form as mere:
"Error: Invalid token".

Bug: 50424
Change-Id: I60169b42701ae3b88e54626c4ff7050549e6ef55
2013-07-11 16:20:26 -07:00
jenkins-bot 87f48b1d44 Merge "api: Split save action into separate API module" 2013-07-11 23:11:22 +00:00
Timo Tijhof 46f40dc696 api: Split save action into separate API module
This allows us to make the token no longer a requirement
for non-save actions while still using the built-in system
for token verification.

Update documentation for "oldid" since it is not required even
outside (paction=save). In fact, if we require it VE loading
fails because it doesn't pass oldid unless it has to when
restoring a specific version.

Bug: 50424
Change-Id: I7b1b50a43648b1cc40a984340846efdb0ba2ecc9
2013-07-11 15:37:23 -07:00
Matthew Flaschen 8f63a5e38e Bump gender survey width to 475.
Change-Id: I37336f1d8f962e31d6a241106384c542879f6e67
2013-07-11 18:06:04 -04:00
jenkins-bot 877463e712 Merge "Add hooks and classes, initially to support GuidedTour" 2013-07-10 19:32:32 +00:00
Timo Tijhof a7e8c9d660 mw.ViewPageTarget.init: Document use of mw.libs.ve to test presence
The presence check used to be against the VE global, but we
recently made that impossible without providing an alternative.

Though by accident, mw.libs.ve has become the new way to check
for presence.

Change-Id: If85695525777a71dde467675052d2ede4e52c9b7
2013-07-10 15:55:17 +02:00
Matthew Flaschen 7f094ee607 Add hooks and classes, initially to support GuidedTour
* Hooks for activation, deactivation, save dialog state change,
  and tab setup.
* Class for save button (needed to point to it in a clean way).
  Also done for cancel button to be consistent, though GuidedTour
  doesn't currently use this.

Change-Id: I4a0e0631d513fb09c3408f2f36a0de0bd51e1a37
2013-07-10 00:05:05 -04:00
jenkins-bot f8184ebeb9 Merge "Lock surface while inspectors are animating open" 2013-07-10 01:54:05 +00:00
Timo Tijhof 50b7a9fc93 mw.ViewPageTarget: Explicitly release our copy of linmod data
Follows-up Ic0c6d190c9b78 which introduced a full linmod copy in a
scope that is also accessible by other closures (namely the
callbacks to jQuery.Deferred #done and #always, and setTimeout).

Though in theory engines may be able to garbage collect it,
I doubt it. Though browsers probably destruct the setTimeout
callback I know  at least the closures pass to jQuery.Deferred
are not released by jQuery, so an engine would have to
understand these other functions well enough to know it doesn't
access the `data` variable.

Let's release explicitly to be safe.

Change-Id: I11000edcad4690dcce53b6e9d1a45bf2ab82fbcb
2013-07-10 01:02:10 +00:00
Trevor Parscal 33e2c8f280 Lock surface while inspectors are animating open
Objective:

* Prevent input while the inspector is animating open

Changes:

ve.ui.LinkInspector.js
* Disable and then re-enable the surface while the inspector is opening

ve.ce.DocumentNode.js
* Remove opacity changes on disable/enable

ve.init.mw.ViewPageTarget.js
* Change the opacity of the document when save dialog is open

Bug: 51075
Change-Id: Ic7910a666b33b41b57b035a15cf1f8c9264e7111
2013-07-09 17:16:25 -07:00
jenkins-bot bf930c88c6 Merge "Defer conversion in the sanity check" 2013-07-09 23:33:31 +00:00
Roan Kattouw e9ca44c86c Transplant CSS from the main document to each iframe
We previously manually loaded CSS into these frames, which is flawed
because it completely bypasses ResourceLoader (so CSSJanus didn't flip
them, necessitating a bunch of hacks for RTL), and doesn't pull in
MediaWiki styles (so templates inside references don't render correctly).
Instead, this commit copies all styles from the main document into each
frame's document, inlining what it can.

Loading all styles in dialogs and inspectors caused some problems,
initially. We didn't namespace our styles for dialogs vs. inspectors
at all; the only reason inspector styles weren't being applied to dialogs
and vice versa was because we controlled which files were being loaded
in which context. This commit namespaces the inspector and dialog styles
where needed so they don't conflict and try to override each other.

Tested in Vector and Monobook, but not in Apex and not in RTL.

ve.init.mw.ViewPageTarget*.css:
* Namespace styles that are only intended for the main document
* Undo Monobook's font-size: x-small; in frames

*Dialog.js:
* Remove addLocalStylesheet() calls, we don't need those any more
** ve.ui.MWDialog seems to be unneeded now, we may want to remove it

*.css:
* Remove @noflip-ped RTL rules where they were just flipped versions of
  their LTR counterparts

ve.ui.Dialog.css, ve.ui.Inspector.css:
* Namespace styles with .ve-ui-dialog-content / .ve-ui-inspector-content

ve.ui.Frame.css:
* Move the margin:0 and padding:0 here (were in the frame <body>'s style
  attribute) and add background:none to prevent frames from getting
  the skin's background (grey in Vector, a book in Monobook)

ve.ui.Dialog.js, ve.ui.Inspector.js:
* Add ve-ui-dialog-content / ve-ui-inspector-content class to the
  frame's content <div> so we can restrict styles to only apply in
  dialogs / inspectors

ve.ui.Frame.js:
* Replace infrastructure for @import-ing stylesheets with transplantation
* Remove code polling to see when the stylesheets were loaded
** We can't do this in the new approach AFAIK, since all styles in the
   frame are either inlined or inaccessible due to the same-origin policy
** We also shouldn't need it because the browser should have cached the
   styles when it loaded the main document
* Apply ve-ui-frame-body class to the frame's <body> so we can style it
** Move inline padding:0;margin:0; into ve.ui.Frame.css
** Move the ve-ltr/ve-rtl class up to the <body>

ve.ui.Window.js:
* Remove infrastructure registering stylesheet URLs to load

Change-Id: I4a37115301811ad860f4578344a04873ea8c2b69
2013-07-09 16:13:28 -07:00
Roan Kattouw b77a1b2250 Defer conversion in the sanity check
Conversion is apparently pretty slow on large articles, so put it inside
the setTimeout(). We still need to copy the data array synchronously
though.

Change-Id: Ic0c6d190c9b782f8c643d00d335f0e004d860bcf
2013-07-09 13:21:48 -07:00
Timo Tijhof fdedbb36e2 mw.ViewPageTarget.init: Clarify reason for FF12 / FF14 blacklist
Follows-up I7a9dddb693091f.

Change-Id: I49a952f6b1714808cd4f063c48cf3102997f8746
2013-07-09 13:11:15 +02:00
James D. Forrester d59a3f1202 Blacklist Firefox 13 and 14 too
Firefox 13 and 14 were the cause of links magically turning into [[./Foo]].
Once the immediate rush of deployment is over, we'll want to investigate as
to why and hopefully find a way to unblacklist FF.

Bug: 50720
Change-Id: I7a9dddb693091fa1e44b4325e77b9e4f55e5c193
2013-07-08 18:20:42 -07:00