Commit graph

222 commits

Author SHA1 Message Date
jenkins-bot 01348dc05f Merge "Update displaytitle on save (try #3)" 2014-07-01 21:18:54 +00:00
James D. Forrester f9e74d3c62 Move reference tool into Cite menu, and language into styling
This puts reference insertion and editing tools into the same menu (yay) and
applying-annotations-to-text tools into the same menu, too.

As part of this, I'm re-labelling the generic reference tool to "Basic" (now
that it has some context for users).

Change-Id: I8b8196d3c2e40237d61c8491ab30e737b82597d6
2014-06-30 19:24:15 -07:00
jenkins-bot caa2298198 Merge "Compress HTML data with deflate before POSTing" 2014-06-30 23:43:16 +00:00
Ed Sanders 4c8da39618 Remove isMobileDevice property
1. It's a bad check, it tells you if the device supports mobile
events, not if it's mobile (e.g. a touch screen laptop has such events)
2. It's no longer used

Change-Id: Ic46bc5b8fdc33b7c2b2bd67e75d65a5e564dbeca
2014-06-28 22:56:24 +01:00
Timo Tijhof 19afd65a08 build: Update jscs and use new "wikimedia" preset
Our coding style has been upstreamed and first released
in node-jscs v1.5.0 (grunt-jscs-checker v0.6.0).

Change-Id: Ifc0cfc7177946b9d11407f60e38b0177883724c5
2014-06-26 17:00:15 +00:00
Ed Sanders e4e9405452 Don't try to change offset for vesection=0
Bug: 66674
Change-Id: I33db33af38b554c9bf3c13b14ce67bcac2e70573
2014-06-25 16:38:56 +01:00
Ed Sanders 288da5b704 Compress HTML data with deflate before POSTing
Bug: 66914
Change-Id: I7b0a9cfd4d4c10986769a868884688ffca833cb6
2014-06-24 17:39:03 +01:00
Alex Monk dc6840c3a0 Update displaytitle on save (try #3)
Parse the wikitext we already have.

This is mostly a revert of commit f84b880a54.

Bug: 50341
Change-Id: I312bafb0e7d61b0abd42d6ca7ea2e4b5dcdc61be
2014-06-23 15:32:15 +00:00
jenkins-bot 9e7c60a4e4 Merge "Revert "Update displaytitle on save (try #2)"" 2014-06-19 00:36:19 +00:00
Alex Monk f84b880a54 Revert "Update displaytitle on save (try #2)"
This reverts commit b7401f838b.

Didn't break everything, but we should probably avoid this getting deployed until I can work out wtf is going wrong with it.

Change-Id: I048143239e998b30aba79fa395a0af1cb06c6a9b
2014-06-19 00:34:26 +00:00
jenkins-bot 29d5bf6e51 Merge "Update displaytitle on save (try #2)" 2014-06-18 23:41:29 +00:00
Alex Monk b7401f838b Update displaytitle on save (try #2)
This reverts commit 5565ccca54.

I have no idea what is going wrong on deployment-prep to cause
the error in bug 66792. Let's try to find out.

Bug: 50341
Change-Id: I5041de838128bb55c57baddae01cdcb263626537
2014-06-19 00:04:51 +01:00
Krenair 143c21999e Port MWSaveDialog to use ActionDialog
Relies on Id17d150d

Change-Id: I80dd89fa7ad55daa3ae7e9c01c4a78f6e54105ca
2014-06-18 20:43:45 +00:00
jenkins-bot c92285e75f Merge "Revert "Update displaytitle on save"" 2014-06-18 20:23:35 +00:00
Catrope 5565ccca54 Revert "Update displaytitle on save"
Causing HTTP 500 errors in ApiVisualEditorEdit.php (calling
getDisplayTitle() on a non-object).

This reverts commit dedc89b5ff.

Bug: 66792
Change-Id: Iaf438660f0623dc05f76294ad847b2fc5e25bed6
2014-06-18 20:21:10 +00:00
jenkins-bot dc81adeb36 Merge "Update displaytitle on save" 2014-06-18 02:23:28 +00:00
Ed Sanders 00af43495b Update VE core submodule to master (155f4ab)
Use new setupToolbar and setupDebugbar methods in base target.

New changes:
7ff523d Localisation updates from https://translatewiki.net.
3815224 [BREAKING CHANGE] Debug bar refactor
155f4ab Edit HTML mode in demo

Change-Id: I554ce51eae872ab0f741a913bf10394c2a8c3e52
2014-06-16 14:52:48 -07:00
Ed Sanders 71395e1fa4 Wait for onDocumentFocus to happen before setting section range
Bug: 65928
Change-Id: If76408b6b89541f0ecb065d4860e0652b6bdebb5
2014-06-15 13:07:32 +01:00
Krenair dedc89b5ff Update displaytitle on save
Also fix a couple of missing param docs

Bug: 50341
Change-Id: I1e73153dca5eb9343bbcda1fc2f9799e72f6f03c
2014-06-12 22:21:35 +01:00
Roan Kattouw 1455c72a35 Update VE core submodule to master (ba8872e)
Replace instances of target.$document, which was removed
in VE core.

New changes:
8083623 [BREAKING CHANGE] Remove $document cache from target
9256158 Cleanup target properties
cc0d71f Multi-surface fixes
ba8872e Localisation updates from https://translatewiki.net.

Change-Id: Ibff83cae770c056ed64bcf438ed74b44d929cdc0
2014-06-10 13:52:34 -07:00
Krenair c18fb662aa mw.ViewPageTarget: When saving a page as a redirect, update contentSub text
Or vice versa. Per my comment on bug 65621.

Change-Id: Ic51745103446dda8ea8ff901c4f211c30c39e45c
2014-06-10 17:34:52 +00:00
Krenair bf42b1a742 Send language when making API requests
The API moans about it in a warning, but it works.

Along with edit page checkboxes, this also fixes edit notices.

Bug: 65455
Change-Id: I7c319d43fd06ab04ab4e4cc099ae49b11c31fabd
2014-06-09 20:49:28 +01:00
Ed Sanders 2122ccb654 Cleanup createSurface methods
No need to set in mw.Target as it now exists in core Target.

Add config param to MobileViewTarget override.

Depends on I555935d2 in core.

Change-Id: I72be9098bd9d59272ca3d7a9a64dca4271ef3ee5
2014-05-30 20:36:26 +00:00
jenkins-bot a7bf8b6a7f Merge "Convert toolbar structure group from bar to list" 2014-05-28 23:06:36 +00:00
James D. Forrester e2fab2f1eb Dump raster support (unuseful) and assert SVG works before loading
Depends on Idb26804576 in core.

Change-Id: I17481b2d52ab2c33c26ff935b0fd58deb4aa207b
2014-05-27 15:22:26 -07:00
James D. Forrester 47e19a9873 Convert toolbar structure group from bar to list
Aligns with I84a4d948ae in stand-alone.

Change-Id: I533355a20bb329b91d6550bde4afa18180b38f59
2014-05-22 17:47:29 -07:00
Timo Tijhof 25d00cc777 build: Update jscs and jshint
jshint:
* Update to grunt-contrib-jshint v0.10.0 (jshint v2.5.0).
* Remove coding style options covered by jscs.
* Enable new option "freeze" (prohibits changing native prototypes).
  http://www.jshint.com/blog/new-in-jshint-oct-2013/#option-freeze
* Re-order to match http://www.jshint.com/docs/options/

jscs:
* Update to grunt-jscs-checker v0.4.4 (jscs v1.4.5).
* Format .jscsrc file in a more spacious way and order the
  properties less arbitrarily (using the jscs's readme order).
* Enforce more details of our coding style
* Get rid of the unsable "sticky" operator rules which have been
  deprecated in favour of using other rules instead that are able
  to enforce this more accurately.
  - disallowLeftStickedOperators: Remove deprecated rule.
    * Ternary covered by requireSpacesInConditionalExpression.
    * Rest covered by requireSpace{Before,After}BinaryOperators.

  - requireLeftStickedOperators: Remove deprecated rule.
     * Comma covered by disallowSpaceBeforeBinaryOperators.

  - requireRightStickedOperators: Remove deprecated rule.
    * Logical not (!) covered by disallowSpaceAfterPrefixUnaryOperators.

See also If46b94ce1, Ib731f11b1 and I0b0cadbc5 in oojs/core.

Also:
* Update grunt-contrib-watch to latest upstream version.
  Change log at https://github.com/gruntjs/grunt-contrib-watch/blob/v0.6.1/CHANGELOG#L1-L17

Change-Id: I6c5a34afea8b05a3dca617897c192594df06ca90
2014-05-15 16:52:34 +00:00
Krenair 81801edb50 Only send useful oldid while switching to wikitext editor if it's specifically requested
Usually we can just send 0. Sending anything else makes PostEdit think we're restoring an old revision.

Bug: 65269
Change-Id: I60454a7a4ea3f6c7cef4c707da3016dd0ec29b88
2014-05-14 22:24:47 +01:00
Bartosz Dziewoński 5e253306d1 Follow-up Id401d973: mw.Target: Make the "Cite" label in the toolbar translatable
Also, re-alpha-sort the ve-mw i18n files.

Change-Id: Id3fc7894b3774042c5eda877c9edf55ef4941ebf
2014-05-11 09:09:09 +02:00
Timo Tijhof ad2fdfb66b ve.init.mw.ViewPageTarget: Actually animate the toolbar during setup
There was a slideDown() call, but this didn't do anything since
toolbars are visible and in the DOM by default.

As a temporary hack, hide it synchronously after creation and
then do the slideDown still.

This could ever so briefly cause a flash, though that didn't
happen in my testing.

This makes the experience smoother when we initialise the surface.
In particular the moment where we swap #bodyContent for our Surface
(which should look visually almost identical), before this change
it was still a bit of a flash since the Surface version has a
toolbar on top, and thus instead of swapping smoothly, we hide
content and show a similar piece of content that has an incompatible
offset from the top.

Bug: 64751
Change-Id: Id94974ba71fd887ce494d7b2b16ec62d43b18575
2014-05-06 02:43:37 +00:00
Juliusz Gonera 72fdab7a0d Enable references on mobile
Further styling and UI improvements in upcoming patches.

Change-Id: I8f93f2a2a6a6eb0c3a9953c7c479f92872d5b621
2014-05-02 14:49:19 -07:00
jenkins-bot 48d025aead Merge "Support QuestyCaptcha and (kind of) MathCaptcha" 2014-04-30 21:34:04 +00:00
Timo Tijhof b272845791 mw.ViewPageTarget: Move .mw-body-content down to .ve-ce-surface
Update VE core submodule to master (109a3cf):

* 109a3cf ve.ce.Surface: Remove font-size: 1em;

Follows-up I5818dce6265.

* When applied to ve-ui-surface, it applies to both of its children,
  namely ve-ce-surface and ve-ui-surface-overlay. The latter
  (containing things like context menu and inspectors) should not
  inherit styles intended for rendering of wikipage content by
  the skin.

* Move mw-content-{ltr,rtl} from an outer parent to a slightly
  deeper parent of the actual content. It's now on documentNode.
  Still high enough to apply to all content. This was to ensure
  it remains a child of mw-body-content, like in MediaWiki core.

* Updated padding/margin hack again. Since now the font-size
  applies on the surface, this once again means that now 1em
  on the surface != 1em on the documentNode, so we need the
  calculation again. Brought it back and this time documented
  what it is based on.

Bug: 64599
Change-Id: I9ee4582a6a0ec9e128f5c36a6dbf2adbd0b216a1
2014-04-30 21:09:54 +00:00
Krenair f8d609a8c7 Add class name to protected pages, to allow for specific CSS styling of edit area
Also get rid of checking for NS_MEDIAWIKI explictly and use
MWNamespace::getRestrictionLevels instead

Bug: 50783
Change-Id: I5986ddb9b6f17e4a2aca12dbb551cce4a6cfd663
2014-04-30 13:59:30 -07:00
Trevor Parscal e0e08388ce mw.ViewPageTarget: Use .mw-body-content for content styling
* font-size and line-height differed between read mode and
  edit mode. This makes them match by using the same css class
  as MediaWiki core uses for the body content.
  Depends on I66c56c57 in MediaWiki core.

* Document padding / margin hack on surface, and sync the values.
  In edit mode, the text was being nudged to the right by a few
  pixels.

* Bump the wfUseMw call as this is a symptom of how VisualEditor
  now depends on MediaWiki 1.23.

Bug: 64599
Change-Id: I5818dce626545c4cbc8bd84fd551dc08baedbe32
2014-04-29 21:04:05 +00:00
Krenair 94b5c8dfa5 Support QuestyCaptcha and (kind of) MathCaptcha
MathCaptcha just extends SimpleCaptcha, so its output is fine to show as
text. Doing that because I'm not sure how to render TeX and this is a
reasonable fallback

Also tidy up the order of some message entries in my last commit.

Bug: 64328
Change-Id: I98312f61471667e7c4dcf715295f85642c31a688
2014-04-24 21:45:20 +01:00
jenkins-bot 2a675d0ce8 Merge "Add support for SimpleCaptcha" 2014-04-24 01:09:29 +00:00
Krenair 62e07f8008 Add support for SimpleCaptcha
Bug: 64328
Change-Id: I04dd82e72184dcef6a660c0886b16a1086ed0b26
2014-04-23 23:30:52 +01:00
Roan Kattouw 54d06b2a3d Unbreak badtoken recovery on mobile
When recovering from a badtoken error, mw.Target called saveDocument(),
but that method only exists in ViewPageTarget. Instead, call .save()
again.

Also pass the HTMLDocument and the save options around to the success
and error handlers, because we need them in order to be able to
call .save().

Bug: 64267
Change-Id: I4743f855dc77f4a9ac427d67d15fb96b7ad770f2
2014-04-23 12:30:48 -07:00
Roan Kattouw ba455643fc [BREAKING CHANGE] Update VE core to master (cb2e61b)
Update dialogs and inspectors for breaking change in VE core

New changes:
a553012 [BREAKING CHANGE] Merge dialog and inspector actions into window actions
f9a0419 Localisation updates from https://translatewiki.net.
cbe81a0 Fix path to spinner in ve.ui.SpecialCharacterInspector.css

Change-Id: Icf90ace6442364283b66b234e3c78fc65212f070
2014-04-21 15:32:59 -07:00
Trevor Parscal afb182c23c Limit the number of citation tools to 5
Don't let too much toothpaste get out of that tube aye!?

Change-Id: I5cd92b7826d55ddde505f1bb883c6f8ed3223ec0
2014-04-10 11:47:34 -07:00
Ed Sanders 0e51180709 Update VE core submodule to master (55a5cdc): use new ve.ui.Dialogs and ve.ui.Inspectors
Move various bits of code from initialize to setup as required.

MWDialog is now useless so use ve.ui.Dialog directly.

New changes:
0b2d03f [BREAKING CHANGE] Pass fragments, not surfaces, to windows (reprise)
0101ac4 Update OOjs UI to v0.1.0-pre (ac6848398c)

Change-Id: I0fae3e5ff2bd0da5b74c244af226b07b1f5883bd
2014-04-09 20:28:30 -07:00
Ed Sanders 164cf27299 Use new model directionality in MW
Depends on I2065e17020dc89 in core.

Change-Id: I6e99db601af58a9c4200f885887de451f9f70daa
2014-04-09 18:21:25 +00:00
jenkins-bot aeb4fabd2d Merge "Fix order of start and base timestamps when switching to the wikitext editor" 2014-04-04 19:31:58 +00:00
Krenair 9dac9f2c04 Fix order of start and base timestamps when switching to the wikitext editor
These were backwards which was triggering edit conflict detection for all users.

Fortunately for logged in users, if Revision::userWasLastToEdit was given a bad
timestamp (e.g. when we submitted here), it would just return true, suppressing
the conflict. It always showed a conflict for anonymous users however.

Bug: 56835
Change-Id: Ib07f965238ca96e17bf59b34da8a8e789954da61
2014-04-03 23:06:41 +01:00
Roan Kattouw 03c5822b6b Update VE core submodule to master (c5f4f78)
Also update tools for changes in VE core.

New changes:
e4de14b Make tools use commands
e029817 Make getToolsForNode place primary commands first

Change-Id: I66575ee6d49e6b2f5a5f789978da98bb55e6dc5e
2014-04-02 16:30:12 -07:00
Roan Kattouw c06a86587c Deal with Parsoid's protocol-relative <base> tags in a DOMParser world
Protocol-relative <base> tags are fine when the iframe trick is used
because the iframe inherits a default base URL from the parent document,
so if the <base> is relative it can be resolved against that. However,
a document created with DOMParser (or document.implementation, oops!)
won't inherit anything, so anything other than a fully absolute <base>
will just break.

To make Parsoid's relative <base> work anyway, resolve it in the
context of the main document, then write the resolved version
back into the <base> tag.

Change-Id: I7261bd5dbe9ec1f4077a4e5a00bd2a03ac237ca0
2014-03-26 21:56:23 -07:00
jenkins-bot cf56fbd0c4 Merge "Make generateCitationFeatures() not explode when citation code isn't loaded" 2014-03-25 18:46:22 +00:00
Roan Kattouw 9d7551ae75 Make generateCitationFeatures() not explode when citation code isn't loaded
Bug: 63074
Change-Id: Ic3973d06707e89993bb551daba0fe13bd3cffc71
2014-03-25 11:26:14 -07:00
Trevor Parscal 1363d15c53 Move cite to be after link, instead of after structure
Change-Id: I69170b68997b8df595cc12e10b3467444e3ae952
2014-03-24 17:13:59 -07:00
Trevor Parscal be199c0bf2 Ultra-mega-hyper-citation editing on crack
Objectives:
* Allow users on-wiki to create tools and dialogs for citation templates
of their choosing
* Allow editing of citation templates directly, without having to go
through the reference dialog
* Provide citation template tools within reference editing that use the
same titles and icons as the citation tools do, but don't wrap the
inserted content in a ref tag

Changes:

* Reference list was cloning the DOM element it was inserting into its
view before the generated content node could finish rendering, so it
never ended up showing the finished rendering in the reference list
* Documenting hack about use of reference list node's destroy method,
and how we are depending on destroy not canceling generated content
rendering
* Introduced reference model
* Added saving/updating method to transclusion model
* Added getPartsList method to dm transclusion node, which caches the
result and invalidates the cache on update
* Added citation dialog, which extends transclusion dialog
* Added cite group to toolbars, cite-template in reference dialog toolbar
* Factored out getting the node to edit and saving changes procedures in
transclusion dialog so they could be extended in citation dialog
* Updated uses of autoAdd as per changes in oojs-ui (Ic353f91)
* Renamed MWDialogTool file since there was only one tool in it
* Expanded TransclusionDialogTool file out since there is now more logic
to it
* Switched to using ve.dm.MWReferenceModel instead of plain objects in
reference search widget

Configuration:

If you add to MediaWiki:Visualeditor-cite-tool-definition.json the
following code you will magically be presented with a delightful array
of citation options:

[
    { "name": "web", "icon": "ref-cite-web", "template": "Cite web" },
    { "name": "book", "icon": "ref-cite-book", "template": "Cite book" },
    { "name": "news", "icon": "ref-cite-news", "template": "Cite news" },
    { "name": "journal", "icon": "ref-cite-journal", "template": "Cite journal" }
]

...or...

[
    {
         "name": "any-name",
         "icon": "any-ooui-icon",
         "template": "Any template",
         "title": "Any title text"
     }
]

The title text is derived either from the title property or from the name
property by pre-pending the string 'visualeditor-cite-tool-name-' to
generate a message key. Titles for 'web', 'book', 'news' and 'journal' are
provided. The icon is a normal oo-ui-icon name, and more icons can be
added, as usual, by adding a class called .oo-ui-icon-{icon name} to
MediaWiki:Common.css. 'ref-cite-web', 'ref-cite-book', 'ref-cite-news'
and 'ref-cite-journal' are provided. The template name is simply the name
of the template without its namespace prefix.

Depends on Ic353f91 in oojs-ui

Bug: 50110
Bug: 50768
Change-Id: Id401d973b8d5fe2faec481cc777c17a24fd19dd4
2014-03-24 19:24:38 +00:00
Roan Kattouw 78a52f1f80 Display links to nonexistent pages as red
* Add ve.init.mw.LinkCache to track page existence and
  transparently query it
* Populate it with initial data from the parser cache
  if available, obtained in the VE API module
* Use linkCache data in link annotation rendering

This doesn't yet integrate the LinkCache with other
components like the link inspector. That should be
done so we can deduplicate the existence checks.

Additionally, we should generalize LinkCache and use
it for the category existence/status checks as well.

Bug: 37901
Change-Id: I9fd43e8c3864dd375cf6dadfdeedd05e4fe9cf3b
2014-03-20 02:42:33 +00:00
James D. Forrester b68c8d3819 Re-sync toolbarGroups for MWMediaEdit and MWReference dialogs
Change-Id: Ic42a57e0e7a1639242092dbe41e13c1b8586f841
2014-03-14 17:01:44 -07:00
Trevor Parscal 42ba981e27 Update VE core submodule to master (520299e)
New changes:
dd15f23 Split ve.ui.Surface into DesktopSurface and MobileSurface
16283f4 Add OOjs UI's sco.json i18n file
ef94038 Split ve.ui.Context into DesktopContext and MobileContext

Minor adjustments to point to desktop and mobile Surface or Context.

Change-Id: I7cf6f99a5a1216a28a7146afcd4deb68c7eac38e
2014-03-14 13:13:02 -07:00
jenkins-bot 3316a0ac62 Merge "Add createSurface() to Target" 2014-03-13 00:57:58 +00:00
Timo Tijhof 5f64ed64d8 mw.Target: Add class "mw-ve-editNotice" to edit notices
Follows-up I260059802379 which removed got rid of
the "ve-init-mw-viewPageTarget-toolbar-editNotices-notice" class
from notices and didn't add something generic in its place.

(There is "ve-ui-mwNoticesPopupTool-item" but that's more an
internal class we don't want gadgets and wiki stylesheets to
rely on.)

Bug: 43013
Change-Id: I8e1e383c2cb3199fe78f45f4feaa24a44126cf0b
2014-03-12 23:07:39 +01:00
Juliusz Gonera ec6c76d619 Add createSurface() to Target
This can be overriden in subclasses (such as MobileViewTarget) so that
we can customize the way the surface is created.

Change-Id: Id17695c8c75c7ae6c549f915625667389aad5f2f
2014-03-10 14:52:06 -07:00
Rob Moen 4bd80b625e Abstract tracking and specify which target it came from
Split tracking out of the base target and from viewPageTarget

Primary reasons for this change:
 * Makes it possible to resolve an issue with tracking in mobile
 * Lets us reuse the viewPage save workflow tracking
 * Support existing and new targets with tracking
 * Simplification of target classes

Change-Id: I036e4f2129d929db0a3b9a4baa87c946a4b194a9
2014-03-06 09:50:11 -08:00
James D. Forrester 0f45399082 Split up ext.visualEditor.mwcore into smaller parts
Core retains core functionality, including text styling and architectural
items like dialogs.

The new modules are:
* mwformatting
* mwimage
* mwlink
* mwmeta
* mwreference
* mwtransclusion

The new modules are loaded in ViewPageTarget (for desktop), except for
mwlinks which is included from MWTarget (for desktop and mobile), per the
needs of the Mobile team.

Also, mwgallery was moved to desktop-only loading status.

Some styles which were loaded in mwcore but only used in modules is now
loaded in said modules.

This does not split up ext.visualEditor.core yet, which is left as an
exercise for the fool-hardy.

Bug: 61075
Change-Id: I6374854eaa13af824c11078d2f7004dc8a211a30
2014-02-26 16:31:15 -08:00
Timo Tijhof 58c647e3ac Ensure we use our references to certain native or upstream methods
Checked:
 ve.cloneObject       (oo|OO).cloneObject
 ve.getObjectValues   (oo|OO).getObjectValues
 ve.getObjectKeys     Object.keys
 ve.compare           (oo|OO).compare
 ve.copy              (oo|OO).copy
 ve.isPlainObject     ($|jQuery).isPlainObject
 ve.isEmptyObject     ($|jQuery).isEmptyObject
 ve.isArray           Array.isArray
 ve.bind              ($|jQuery).proxy
 ve.indexOf           ($|jQuery).inArray
 ve.extendObject      ($|jQuery).extend

Fixed:
* ve.dm.MWBlockImageNode.js (added in Iebb2081de)
* ve.dm.MWInlineImageNode.js (aded in I62ec12a6b)
* ve.dm.MWConverter.test.js (added in I90273786a)
* ve.ui.MWMediaInsertDialog.js (added in Ia5ad9a8c0)
* ve.dm.MWTemplateSpecModel.js (added in Ic3eb66538)
* ve.init.mw.MobileViewTarget.js
* ve.init.mw.ViewPageTarget.js
* ve.init.mw.Target.js

Skipped:
* ve.init.mw.ViewPageTarget.init.js
  - Feature test (which is for the very references from ve.js
    being ensured in this commit).
  - Misc code using $.inArray (can't use ve.js yet since that
    isn't loaded yet there).

Change-Id: I73ae005d3692e871fdcaea938641558c0b98ec69
2014-02-20 22:30:29 +01:00
Juliusz Gonera a6b149decc Move restoreEditSection() to mw.Target
It can be reused in mw.ViewPageTarget and mw.MobileViewTarget.

Also, check if this.section is undefined instead of not null and update
docs. restoreEditSection() does not accept any arguments.

Change-Id: Ibbcf4cb936a89d3ae77bb61ee97b8ad00a8d8a53
2014-02-13 00:22:33 +00:00
James D. Forrester e4f983356b Add tooltips to the drop-down menus explaining what they do
Needs Ic967b88d55daf48d365487e17f76488b3f02c60f to work properly.

Bug: 59719
Change-Id: I449be926e830de241a870d96bf30c835f60ca77d
2014-02-12 22:07:24 +00:00
Trevor Parscal eca0a08ad9 (Stand back again) Even moar label manias! (label refactoring) + VE core update
Update VE core submodule to master (84ced37) and update calling code
for changes in OOUI.

Depends on Ic967b88d55daf48d365487e17f76488b3f02c60f and Ib599b9bd5028e2df084fcc3da657aeb7f1569d2a

New changes:
94f03c3 Undefined variables first in selectNodes
62b5648 Localisation updates from https://translatewiki.net.
10c5a18 Don't descend into handlesOwnChildren nodes in selectNodes
4ed2432 Update jquery.client to MW's master (45192156d7)
d7e24b8 Localisation updates from https://translatewiki.net.
babb9da Localisation updates from https://translatewiki.net.
4639d18 Localisation updates from https://translatewiki.net.
a561537 Localisation updates from https://translatewiki.net.
8f7053a Localisation updates from https://translatewiki.net.
7112cc2 Update OOjs UI to v0.1.0-pre (a290673bbd)

Change-Id: Ie7d58472619509782f23a7dedc1ec27c3dcc7543
2014-02-12 14:05:23 -08:00
jenkins-bot 604d52244d Merge "Make this.loading abortable" 2014-02-08 00:25:40 +00:00
Roan Kattouw 2cf871415b Make this.loading abortable
.then() removes the .abort() method from the promise, even though
we had return jqxhr; in the then() callback. So store xhr in
a variable and put the abort method back.

This fixes a JS error upon calling this.loading.abort();

Change-Id: I50460782e58399198bacc02d028984682ddbed56
2014-02-07 15:56:55 -08:00
Roan Kattouw bb465b22a5 Fixes for 239bae7512 (mobile toolbar)
* Use correct class name for setUpToolbar() in MobileViewTarget
* Move shared setUpToolbar() code into ve.init.mw.Target
* Fix iconModuleStyles documentation, remove leading space

Change-Id: Icf5ed36fd817837c0434db8202bef8a78e6cb898
2014-02-07 14:15:17 -08:00
jrobson 239bae7512 Allow better toolbar customisation for VisualEditor
The toolbar in very desktop vector skin specific
In mobile we want to have more control over the toolbar,
and its placement.
* Thus make setUpToolbar abstract
And move the function to ViewPageTarget

* Introduce ve.init.mw.Target.static.iconModuleStyles to
allow the use of different icons
* Update the mobile toolbar to only have B and I tools

Change-Id: I4c72b4b9128b3a74de8b8b5bce7664fbb315216b
2014-02-06 15:45:08 -08:00
Ed Sanders cf62801694 Move paste rules to Target
Because ViewPageTarget isn't always loaded.

Bug: 60912
Change-Id: I16bd6a329120b3dd7dcb0de3e76e69e84c18553f
2014-02-06 22:41:51 +00:00
jenkins-bot adf8249688 Merge "Ultra-basic gallery editing" 2014-01-15 23:27:06 +00:00
James D. Forrester 842688c51b Ultra-basic gallery editing
'Cos Erik doesn't like things he can't edit.

Change-Id: I1d9fb1215bb16b1245eddd87c977fb5bfdee4da9
2014-01-15 15:13:12 -08:00
jenkins-bot 96f638d2ce Merge "Add multipart/form-data emulation to ve.init.mw.Target#apiRequest" 2014-01-15 22:28:29 +00:00
Trevor Parscal 4f0b988fbc Rejigger-ify the insert tool order
Change-Id: I9e37561eaac17689378af2c6a14dbf24b9326e9e
2014-01-15 20:08:10 +00:00
Roan Kattouw edd2bcd34e Add multipart/form-data emulation to ve.init.mw.Target#apiRequest
On my example main page, this reduces the size of the POST body by 45%

Bug: 59660
Change-Id: I7f04f403e0081188b8b4024c4431ae43b127434c
2014-01-15 17:17:29 +00:00
jenkins-bot 2284cb9aae Merge "Factor out AJAX defaults into ve.init.mw.Target.static.apiRequest()" 2014-01-15 10:37:43 +00:00
Trevor Parscal 278bcd9a20 Added indicators to toolbars
The down arrow is no longer default, so it needs to be specified
explicitly.

Updates submodule to include indicator changes
(see I0a1faef11a1e7e6ea3e44275c85f2efafae4dc9a)

Change-Id: I32aef3ea2e66fd823aeb07dac06cfefba9954270
2014-01-13 18:32:01 -08:00
Roan Kattouw 97c4c6c71b Factor out AJAX defaults into ve.init.mw.Target.static.apiRequest()
Change-Id: I90b0858ccd657b7183ae5327903449d17d9f0bef
2014-01-13 11:45:30 -08:00
Ed Sanders c74d7f1a21 Update categories HTML on page save
Because there's an API for that.

Bug: 48560
Change-Id: I410647d2b1aa740f606ddca64052b8d2b54671bf
2014-01-12 14:55:39 +00:00
James D. Forrester 0ffd654bed Bump copyright like it's 2014
Change-Id: Ic469ebda2c061dc7da0b4c1625f43a7be55da4fa
2014-01-05 20:06:50 +08:00
Timo Tijhof ca40077866 Clean up Target properties
Move target.surface from mw.Target to Target
* All targets use this, let's standardise it.

Move target.$document from mw.ViewPageTarget to Target
* It was initialised with null in mw.ViewPageTarget, but the
  assignment happened in mw.Target. So it should be moved up
  at least to mw.Target.
* Since it is useful to have in sa.Target as well, moved it up
  to the abstract Target, and implemented in sa.Target and
  immediately used in the standalone demo where we were already
  duplicating the find( '.ve-ce-documentNode' ).

Add missing target.setupDone = false; in sa.Target

Add missing target.toolbar to Target
* Was used in all subclasses, but never initialised in any of
  the constructors. Let's standardise this property name as well
  (instead of initialising it in three places).

Move target#event-surfaceReady from mw.Target to Target
* sa.Target uses it as well, and considering Platform#initialize
  is already standardised in the abstract class, Target#setup
  being deferred is most likely to happen in each target as well
  so let's avoid different events being invented for the same
  thing and consistently use 'surfaceReady'.

Change-Id: Ia8bde188a4cde7e1615c2ae9c5b758eefc5d9cb7
2013-12-19 02:16:20 +00:00
Rob Moen 790d2c1307 Move additional module loading from mw.Target to mw.ViewPageTarget
This resolves some experimental mode dependencies on Mobile integration.

Bug: 58551
Change-Id: Id6c498ae19a5d5b1e5d1698f5e149a9b5d6f3b26
2013-12-18 07:11:36 +00:00
Roan Kattouw fb3a75b85d Split ext.visualEditor.mwcore out of ext.visualEditor.core
* Split files according to ve / ve-mw paths
* Split messages according to msgs-ve / msgs-ve-mw
* Update dependencies accordingly
* Remove ve-mw/ hack in makeStaticLoader.php, no longer needed

Bug: 45342
Change-Id: I6cb89606c307e27e237a1e9b56b94dfdcd310f41
2013-12-17 20:56:03 +00:00
Roan Kattouw fc119e3d60 Allow ve.init.Platforms to asynchronously initialize themselves
We'll need this for the standalone platform to load jquery.i18n messages

Change-Id: Iacb9fcb2d5750711187f7d72d53d8c7d54c6f30b
2013-12-16 22:46:19 +01:00
Roan Kattouw af4b7bd067 Fix the standalone toolbar to not demote heading1
The duplication of the toolbar definition is ugly but we don't
have a better system to say "give me the same except demote this
one thing" right now.

Change-Id: Id74ed1a18aee4a947992bdd626702f578bbace14
2013-12-13 12:24:54 -08:00
Timo Tijhof c6b997d0ba mw.Target: Fix document focus scroll bug
Follows-up I55ef2622c9eacc which activated code introduced in
mw.Target in commits before that one that caused a change in the
execution order.

Hiding of page content (regular wiki page content provided by
original view request) must happen before the surface document is
focussed.

We used to hide the content from mw.ViewPageTarget#setUpSurface,
which is called from #onReady, which focusses the document after
setUpSurface is done.

Most of this code was moved to mw.ViewPageTarget#onSurfaceReady
which is the listener for the surfaceReady event emitted from

If our surface document gets focus while the original wikipage
content container is still there, the view port is forced to
scroll down because our surface is the next element sibling after
the wikipage container in the DOM.

And browsers (apparently Chrome is not affected) naturally retain
scroll position even if the elements above the one you "scrolled to"
disappear.

We can't (and shouldn't) move the hidePageContent call because
that's the responsibility of the Target subclass, so instead
moved the document focus to below the hidePageContent which is
now also part of the responsibility of the Target subclass.

Also:
* Removed target.surfaceOptions reference because that property
  does not exist. We never passed a second argument here, and
  whatever this was intended for, doesn't exist.

Bug: 58089
Change-Id: I230fbd5401cbd6e3b9450c7f156650409be8ef16
2013-12-06 22:32:51 +01:00
Timo Tijhof cf7f2b141d Set up node-jscs, pass it, and configure in local Gruntfile
Let's experiment with this via our local Gruntfile. If it works
fine we can install it in Jenkins (similar to node-csslint).

Verify through $ npm install && npm test;

Fixed all outstanding violations.

Also:
* Added syntaxhighight to ignore.
* Added imetests (which contain unformatted JSON) to ignore.
* In ve.dm.ModelRegistry#matchTypeRegExps, removed redundant
  !! cast from the [+!!withFunc] statement which was hitting
  a bug in node-jscs. All callers to this local private function
  pass a literal boolean true/false so no need to cast it.
* Removed "/* key .. , value */" from ve.setProp, though this
  wasn't caught by node-jscs, found it when searching for " , ".
* Made npm.devDependencies fixed instead of using tilde-ranges.
  This too often leads to strange bugs or sudden changes. Fixed
  them at the version they were currently ranging to.

Bug: 54218
Change-Id: Ib2630806f3946874c8b01e58cf171df83a28da29
2013-12-06 10:37:27 -08:00
Ed Sanders 6d34e344ee getDataFromDom -> getModelFromDom
Following on from getDomFromModel, this returns a document model
instead of element linear data. The only instance that hasn't been
replaced is in rich paste, where we need to sanitize the converted
data before constructing the document model.

This should be cleaned up in a later commit.

Change-Id: I37a2b641632af2cb515e3409deed5cd1fa358af5
2013-12-04 14:46:34 -08:00
Ed Sanders 86922f8ca8 Change signature of getDomFromData and rename
Currently it takes 4 arguments which are all properties
of the document model, so just pass the model instead and
access the properties later. Rename to getDomFromModel.

Change-Id: I0c378a04dc08b9b90bdc3984f8fa8c4acfe0b667
2013-12-04 16:30:40 +00:00
Roan Kattouw 75449ea597 Clear cache key when deactivating target
And other state too, while we're at it.

Bug: 57905
Change-Id: Ifd2744c841f302764cf57c13f4a760cbe80fa2e0
2013-12-02 18:52:47 -08:00
Roan Kattouw 9dc891f4cb Move activating/deactivating to ViewPageTarget
That's where they belong IMO, since ViewPageTarget is the one that
has .activate() and .deactivate(), and mw.Target doesn't retain any
state (apart from some caching things).

Change-Id: Ia6cf5bac9054163d54ab492d691d8ce9d6a3bb90
2013-12-02 18:21:31 -08:00
Rob Moen db970a61fc Split apart onSaveError logic for other mw targets
Change-Id: I8c8b2d4900b511a65cff4c554cf7ef89d6d39ea9
2013-12-02 18:04:29 -08:00
Rob Moen f1fa56165d Create base MobileView config and target refactor
Changes include:
* Target mobile for ve dependencies
* Create mobile view constructor
** Some tools like dialogs are excluded for now
* Refactor mw.target to permit code reuse
** Split out pageTarget view functionality from core init methods

Change-Id: I786b63ab57518fc6af7761501259ed66592f70e3
2013-12-02 17:59:27 -08:00
Roan Kattouw 35e20d954f Share code between conflict resolution and the edit source switch
Each used their own implementation of building a form and submitting it.
The edit source one wasn't passing in the oldid, which caused edit
conflicts.

Also introduced a separation between form fields (for the action=edit UI)
and API options, building one from the other.

Bug: 56835
Change-Id: I38547b4ba1827f4028a2255109cba2a57cd59e8a
2013-11-25 17:23:20 +00:00
Roan Kattouw 72b0d2a19c Move setting of minor/watch defaults from MWSaveDialog to Target
It looks like it also came from there originally, because it uses
this.pageExists which doesn't even exist in MWSaveDialog. This caused
all pages, even existing pages, to be watched when 'watchcreations'
was set.

This logic really belongs server-side, though.

Bug: 56206
Change-Id: Idf500383b27a93136dc0cfdd60a2e7b2607af95c
2013-11-25 17:20:29 +00:00
Roan Kattouw 1919fffc74 Use serialization cache in MW integration
Add prepareCacheKey() which submits HTML for serialization and saves
the resulting cache key, and tryWithPreparedCacheKey() which uses that
cache key (if available; if pending, it waits for it) for API requests.
Implemented save(), serialize() and showChanges() in terms of
tryWithPreparedCacheKey().

When opening the save dialog, run the conversion, cache it, and fire
off a prepareCacheKey(). Then use the cached conversion for save/diff/
serialize. This means we don't convert multiple times, and it causes
the prepared wikitext to be used.

Bug: 55979
Bug: 56011
Change-Id: I1d56fe88d312e9810a57d56a285ccdf4f1facf42
2013-11-22 16:50:16 +00:00
Timo Tijhof de979ff293 Replace raw oojs-ui files with v0.1.0-pre (0267100ab3)
Change-Id: I792bc0335269976ff29433227b6fa562a1026aeb
2013-11-20 10:27:48 +05:30
Timo Tijhof 98bc6adf1f Use mw.util.getUrl instead of mw.util.wikiGetlink (deprecated)
Change-Id: I72afbbd909ce2394d54f78d465bd8ad245c1694f
2013-11-12 18:34:05 +01:00
Roan Kattouw d6a00d689e Add a whole bunch of new ve.track() events for instrumenting loading and saving
Renamed events:
* performance.domLoad --> performance.system.domLoad
* performance.domSave --> performance.system.domSave

New events:
* performance.system.activation: total load time
* performance.system.domDiff: timing of paction=diff; like .domSave
* performance.system.domSerialize: timing of paction=serialize; like .domSave
* behavior.lastTransactionTillSaveDialogOpen: time from last transaction
  until user opened save dialog
* behavior.saveDialogOpenTillSave: time from save dialog opening to user
  clicking save
* behavior.saveDialogOpenTillReview: time from save dialog opening to user
  clicking review (skipped when a cached diff is shown)
* behavior.saveDialogClose: when user closes save dialog; duration is time
* performance.user.saveComplete: time from user clicking save to successful
  save completion; 'retries' indicates # of badtoken retries
* performance.user.saveError.*: time from user clicking save to failure;
  'retries' indicates # of badtoken retries
** performance.user.saveError.abusefilter
** performance.user.saveError.badtoken: token was bad and we prompted the user
** performance.user.saveError.captcha
** performance.user.saveError.editconflict
** performance.user.saveError.empty
** performance.user.saveError.spamblacklist
** performance.user.saveError.unknown
* performance.user.reviewComplete: time from user clicking review to diff showing
* performance.user.reviewError: time from user clicking review to diff failure
  since dialog was opened

Change-Id: I9815fa637d34c766c163e181d2f9527d3f32a7c3
2013-11-07 15:42:52 -08:00
jenkins-bot 564605711c Merge "Convert the mass Beta Feature into feature-level ones, enabling formulæ" 2013-10-30 00:08:31 +00:00
Trevor Parscal e83dc3f8fc Use a toolbar for the actions buttons in ve.init.mw.ViewPageTarget
Change-Id: I260059802379d8cab8ca175b7d7d32813e3ff10a
2013-10-29 05:57:52 +00:00
Trevor Parscal d2dfb9ac4f Split oojs-ui from ve.ui
* Move and rename generic parts of ve.ui to OO.ui
* We now have a UI test suite because ve.Element (outside ve.ui)
  is now part of oojs-ui, so it needs a test suite.
* Added to the MW test run (just like we do for unicodejs).
* Updated csslint config (also added ve-mw and syntaxhighlight
  which were missing).

oojs-ui still depends on the TriggerRegistry in VE, this is addressed
in a follow-up commit.

Change-Id: Iec147155c1ddf20b73a4d15d87b8742207032312
2013-10-28 22:40:08 -07:00
Roan Kattouw 829967951e Convert the mass Beta Feature into feature-level ones, enabling formulæ
Make every module that was formerly part of the experimental module its own
Beta Feature. For now, all of them are commented out except for formulæ editing
(mwmath). The "experimental" Beta Feature bucket is no more, but the preference
remains so that it can be set to both true and hidden on MediaWiki.org to let
all the different experimental flags.

The feature icons, previous mis-named "logo" and mis-identified as "screenshots"
are now renamed. One for the mwmath Beta Feature has been added (the rest need
creating before those can be enabled). The i18n descriptions now each identify
that the feature is an experimental one, and that caution is needed.

Change-Id: I28862f3e62f5c78aca33f11265aced1db67f4725
2013-10-29 01:20:48 +00:00
Ori Livneh 56a9484149 Filter DOM load/save deferreds through ve.track callback
Binding ve.init.mw.Target#onLoad and the anonymous function which calls ve#track
with timing data to the resolution of the same deferred makes the timing
measurement sensitive to how long it takes ve.init.mw.Target#onLoad to yield,
which in turns depends on whether the requisite ResourceLoader modules for
setting up the editing surface are ready. This muddles the definition of what
we're actually measuring, making it dependent on a race condition.

This patch moves the tracking call to a filter function through which the jqXHR
deferred is threaded. This ensures that the 'duration' datapoint on the domSave
and domLoad events captures just the time spent talking with the API.

Change-Id: I6e162014a4043d4ff9422131ae87fb25d0ab4c29
2013-10-23 22:44:27 -07:00
Timo Tijhof 7db65f386c Rename @emits to @fires so we're forward compatible with JSDuck 5
Instead of using @emits in both, use our custom @fires in
production (JSDuck 4), and in the future it'll just naturally
use the native one.

This way we can also index oojs without issues, which seems to
have started using @fires already.

Change-Id: I7c3b56dd112626d57fa87ab995d205fb782a0149
2013-10-22 19:11:16 +00:00
Trevor Parscal efafed3231 Remove ve.{inheritClass,mixinClass} and use OO instead
Change-Id: I8df9226a358a76b661eab6e967ff0d63d361f691
2013-10-18 18:58:08 +02:00
jenkins-bot 5dd44dab93 Merge "Rename performance.parsoid.domLoad to performance.domLoad" 2013-10-17 19:30:58 +00:00
Roan Kattouw d3cd404877 Use .done()/.fail() instead of 'success'/'error'
'success' and 'error' are deprecated.

Also make all generateContents() promises abortable.

Change-Id: I8f95e9386f7749e635ce3715389896a0ccdb7523
2013-10-17 14:03:37 +02:00
Gabriel Wicke 266603c3a1 Rename performance.parsoid.domLoad to performance.domLoad
See
https://gerrit.wikimedia.org/r/#/c/89347/2/modules/ve-mw/init/ve.init.mw.Target.js
for the reasoning. Ori offered to adjust the consumers for this.

Change-Id: I835f0752ab3a4c8ad56eec437668423ba8b81c24
2013-10-16 15:02:26 -07:00
jenkins-bot 1f8d2fd9a7 Merge "Log DOM save timing; update existing ve.track calls" 2013-10-16 14:50:16 +00:00
Rob Moen 87629a99e1 Use existing ve config for pluginModules
Change-Id: I16a50f342e0794a98e648afc7251e8341270e9c9
2013-10-15 11:36:06 -07:00
Ori Livneh c27661507b Log DOM save timing; update existing ve.track calls
* For consistency with target.loading, target.saving should be either a boolean
  false or a jqXHR, with the latter type indicating a pending save attempt.
* Rename 'DOM Retrieved' topic to 'performance.parsoid.domLoad' (and thus
  inaugurate a convention of hierarchical, dot-separated topic names).
* Add a 'performance.parsoid.domSave', which is a near-mirror of domLoad, but
  measures the time it takes to save a DOM.
* Remove three old ve.track events, because they are not used and because their
  name and signature are not consistent with current usage.
  - page-save-attempt
  - page-save-success
  - page-edit-impression

Change-Id: I54602394eee5d6d9229c01d868cb366c9f56b2c3
2013-10-11 15:16:05 -07:00
Roan Kattouw 0901c0328a Generalise the way extra modules are loaded
Change-Id: Icd453421b022a6450d1358edbe2132e49ca0b3bf
2013-10-11 14:07:00 +01:00
jenkins-bot bcbefc63cc Merge "Track DOM retrieved events" 2013-10-07 22:15:07 +00:00
Ori Livneh e8aad4d4a7 Track DOM retrieved events
When the editor finishes retrieving the target DOM, fire a 'DOM retrieved'
analytic event with the following properties:

* Response time in millisecond.
* Response size in bytes.
* Whether request was a cache hit.
* Value of X-Parsoid-Performance header (or null if unset).

jQuery.byteLength is now a dependency for ext.visualEditor.mediawiki.

Change-Id: I74d3964238927645e847b6e215991bd6b1ebad59
2013-10-05 23:24:06 -07:00
Trevor Parscal 6ec34a3dee Toolbar action widgetization and UI refactoring
Objectives:

* Use widgets to render toolbar actions
* Remove labels next to help notices and edit notices buttons
* Add a close button to the help notices and edit notices

Overview:

* ve.ui.ButtonWidget is now abstract, use ve.ui.PushButtonWidget instead
* ve.ui.IconButtonWidget now inherits from ve.ui.ButtonWidget
* ve.ui.PopupWidget's display method no longer takes x and y arguments
* Fixup naming issues in MWCategoryPopupWidget
* Fixup naming issues with some ve-init-mw CSS classes
* Rename ve-mw/ui/styles/ve.ui.Widget.css to ve.ui.MWWidget.css
* Change uses of "callout" to "tail"
* Add hyperlink functionality to buttons
* Make buttons accessible through focusing, but make unfocusable by
  clicking
* Add head option to popup for rendering a title and close button

Bug: 52386
Change-Id: Iea2c8df1be64d40f9c039873d89ee540cc56e687
2013-10-04 16:26:13 -07:00
Ed Sanders 4f768f3734 Integrate with BetaPreferences
Look at logo Michael.

Bug: 52686
Change-Id: I3cfada2ea264184698de5f322c1fe5041b37b8c8
2013-09-10 10:20:14 -07:00
Timo Tijhof bdd1a73eaa data: Rename MessagesModule to DataModule
Also..
* removed an incorrrect comment referring to the old module
  name (standalone didn't use the VisualEditorMessagesModule).
* made it use debug mode to determine whether to minify or
  prettify the js code.

Change-Id: I493007649fba27e7faab0cf743eded5f68714c50
2013-08-29 18:07:35 -07:00
Roan Kattouw ceb81353fc mw.Target: Removed unreachable badtoken recovery code
This code caught badtoken errors on load, but we can't get those
any more since the API module was split and we no longer send a token
on load. badtoken handling on save is done in mw.ViewPageTarget.

Bug: 51253
Change-Id: Idb172ee46b7142681d41e593eacd9600b8f11a9a
2013-07-31 00:45:28 +00: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
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
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
Timo Tijhof d16fef546a mw.ViewPageTarget: Fix incorrect retention of the wrong oldid
* Only pass the oldid to the API from #load if we restoring from
  oldid in the url. Otherwise load the latest version.
* Setting 'restoring' from mw.Target instead of mw.ViewPageTarget
  so that we don't rely on mw.ViewPageTarget in mw.Target#load.
* Fix the API to not require 'oldid' to be passed.
* Fix the API to actually return the 'newrevid' property. It
  was doing a no-op on a $result that is never used due to the
  same variable being overwritten with the result of parseWikitext.
* Moved updating of wgCurRevisionId to mw.ViewPageTarget as it
  belongs there (possible future inline editors probably act
  on a different page than the main one). Also made it only
  update if it isn't undefined, so that a null edit doesn't
  result in wgCurRevisionId being unset.

Bug: 49943
Bug: 50441
Change-Id: I221e5038f95eadf6d87013e80f12394f0376a293
2013-07-08 16:11:23 -07:00
Roan Kattouw 92c38eab85 The great directory split of 2013
Move all MW-specific files into the ve-mw directory, in preparation
for moving them out into a separate repo.

All MW-specific files were moved into a parallel directory structure
in modules/ve-mw . Files with both generic and MW-specific things were
split up. Files in ve/init/mw/ were moved to ve-mw/init/ rather than
ve-mw/init/mw ; they're still named ve.init.mw.* but we should change
that. Some of the test files for core classes had MW-specific test cases,
so those were split up and the test runner was duplicated; we should
refactor our tests to use data providers so we can add cases more easily.

Split files:
* ve.ce.Node.css
* ve.ce.ContentBranchNode.test.js (MWEntityNode)
* ve.ce.Document.test.js (some core test cases genericized)
* ve.dm.InternalList.test.js (uses mwReference test document)
* ve.dm.SurfaceFragment.test.js, ve.ui.FormatAction.test.js
** Made core tests use heading instead of mwHeading
** Updated core tests because normal headings don't break out of lists
** Moved test runners into ve.test.utils.js
* ve.ui.Icons-*.css
* ve.ui.Dialog.css (MW parts into ve.ui.MWDialog.css)
* ve.ui.Tool.css
* ve.ui.Widget.css (move ve-ui-rtl and ve-ui-ltr to ve.ui.css)

ve.dm.Converter.test.js: Moved runner functions into ve.test.utils.js

ve.dm.example.js:
* Refactored createExampleDocument so mwExample can use it
* Removed wgExtensionAssetsPath detection, moved into mw-preload.js
* Genericized withMeta example document (original version copied to mwExample)
* Moved references example document to mwExample

ve.dm.mwExample.js:
* Move withMeta and references example documents from ve.dm.example.js
* Add createExampleDocument function

ve-mw/test/index.php: Runner for MW-specific tests only

ve-mw/test/mw-preload.js: Sets VE_TESTDIR for Special:JavaScriptTest only

ve.ui.Window.js:
* Remove magic path interpolation in addLocalStyleSheets()
* Pass full(er) paths to addLocalStyleSheets(), here and in subclasses

ve.ui.MWDialog.js: Subclass of Dialog that adds MW versions of stylesheets

ve.ui.MW*Dialog.js:
* Subclass MWDialog rather than Dialog
* Load both core and MW versions of stylesheets that have both

ve.ui.PagedDialog.js: Converted to a mixin rather than an abstract base class
* Don't inherit ve.ui.Dialog
* Rather than overriding initialize(), provide initializePages() which the
  host class is supposed to call from its initialize()
* Rename onOutlineSelect to onPageOutlineSelect

ve.ui.MWMetaDialog.js, ve.ui.MWTransclusionDialog.js:
* Use PagedDialog as a mixin rather than a base class, inherit MWDialog

bullet-icon.png: Unused, deleted

Stuff we should do later:
* Refactor tests to use data providers
* Write utility function for SVG compat check
* Separate omnibus CSS files such as ve.ui.Widget.css
* Separate omnibus RL modules
* Use icon classes in ViewPageTarget

Change-Id: I1b28f8ba7f2d2513e5c634927a854686fb9dd5a5
2013-07-02 20:51:38 -07:00
Renamed from modules/ve/init/mw/ve.init.mw.Target.js (Browse further)