Commit graph

469 commits

Author SHA1 Message Date
Ed Sanders ae26eefb05 Fix typos
Add some common ones to typos.json

Change-Id: I3830be4949ab6a5fd998d6937ed83e9f18091c2b
2015-12-09 16:47:13 +00:00
Ed Sanders 63184600d4 Use wgNamespaceIds constants instead of hard-coded numbers
Change-Id: I71b80e59a5e24d63e68637a1ae8422974643bd3a
2015-12-04 19:57:56 +00:00
Bartosz Dziewoński 9be5c85db4 Provide a tool to insert a signature in namespaces that need it
VisualEditor is usually not enabled in talk namespaces... but
sometimes it is. And when users see the button to edit with VE,
they're going to click it and expect to be able to sign their posts.

This tool is only loaded on talk pages and pages in additional
namespaces defined in $wgExtraSignatureNamespaces.

Code adapted with small tweaks from my own gadget
<https://meta.wikimedia.org/wiki/User:Matma_Rex/visualeditor-signature.js?oldid=13461327>,
which is already available under the MIT license.

Changes include:
* The tool is now always visible if the wiki allows signatures in any
  VE namespaces, but disabled when not allowed in the current namespace.
* Register '~~~~' sequence to insert the signature.
* Code style tweaks for stricter lint checks in this repository.
* Documentation corrections.

Swedish translation provided by André Costa (already credited
as a translator as Lokal_Profil).

Depends on changes in VisualEditor core:
* I89fe53890ab59d12260ea6b41de802c38c24e8b9
* I14cd7efac521687ea38580341ae08ddc522edeeb

Bug: T53154
Change-Id: I6be5fb2118cf3eef5098d4c5320228aa81411ccb
2015-11-16 18:06:32 +01:00
Ed Sanders 2c2f8c8a04 MediaSearch: Order search results correctly
Bug: T117036
Change-Id: Ia11f3486214425f203695a6060e304a90eba7734
2015-10-29 12:51:22 +00:00
Ed Sanders 9fb6977e52 Update VE core submodule to master (363adf2)
New changes:
63c5f67 [BREAKING CHANGE] GeneratedContentNode: Introduce new hash for rendering
6dd1cb2 Add ve.dm.Surface#selectLastContentOffset

Local changes:
* Use new getHashForRendering in GeneratedContentNode users

  As we no longer have a model hash, remove the originalIndex check
  and just rely on the deep comparison of mwData (trading a deep copy
  for a hash computation should result in similar performance).

Bug: T114689
Change-Id: Ida0ee0234418408b735232c633d41908a424a9ff
2015-10-07 15:00:32 +00:00
Ed Sanders c5c88482b9 MWExtenionNode: Ensure objects are deep copied when used in the hash
We don't expect users not to alter the hash (subclasses may delete items)
so make a copy of any objects we put in it.

Change-Id: I6274f47e02b9f2d53864d4a2ae80df42e6c89867
2015-10-01 15:57:49 +01:00
Alex Monk 736561f3af Actually get uploader details when querying media info
Used in MWMediaDialog's buildMediaInfoPanel function

Bug: T109563
Change-Id: I398957eb0a4610379b29aac1df4234a58e845f28
2015-09-17 00:31:23 +00:00
Ed Sanders 8e63c9e991 MWInternalLinkAnnotation: Make protocol matching case-insensitive
This was causing a regression in the behaviour that takes you
to the external link tab automatically when 'http://' is typed,
as internally it is normalised to 'Http://'.

Bug: T112158
Change-Id: Id7cff07e89caafe5b350f4fb27b99c6c89498990
2015-09-16 23:49:55 +00:00
Ed Sanders 0fdf3cbb93 Update VE core submodule to master (9dcfbdb)
New changes:
184f952 [BREAKING CHANGE] ve.dm.Converter: Put static things in .static
a4c1e1e Localisation updates from https://translatewiki.net.

Local changes:
* Switch to using Converter's newly-static methods

Change-Id: If30f7b2a0de92c4c7f4d5ca57663251c132eeed2
2015-09-15 17:36:27 -07:00
Ed Sanders 830718ce22 Use ve.resolveAttributes instead of resolveUrl in clipboard conversion
This method does the tree traversal for us, and resolves src as well
as href.

Change-Id: Ic3ea47fb9acde9a1dad5caac3ee9c9b63c86d900
2015-09-15 13:44:52 +01:00
Ed Sanders 036b6c9edf Resolve image paths when writing to clipboard
Bug: T111927
Change-Id: Idf3b761481454197eecbc0f6cd5cf6199419ca6c
2015-09-09 16:19:18 +00:00
Ed Sanders d67d110d26 Use rendered contents when copying to clipboard
Bug: T111923
Bug: T111924
Change-Id: I04b98e317d0c883fc257c46552476041c7f53679
2015-09-09 08:56:22 -07:00
jenkins-bot 8502d3ea05 Merge "Specialized inspector for ISBN magic links" 2015-09-01 18:34:23 +00:00
C. Scott Ananian 7cc23367f6 Specialized inspector for ISBN magic links
Implement a special node type, context item, and inspector for
ISBN/PMID/RFC magic links.  Add buttons to the link inspectors
to convert back and forth between "simple" links, and magic links.

Depends on I5d000d8b63dafdfe0a2753069d3f0ac5b03b8829 in Parsoid
for clean round-tripping of localized ISBN magic links.

Bug: T63558
Change-Id: Id5b7a2ae3c80b0e5eed598f0bd024d3e94f7e9aa
2015-09-01 14:25:59 -04:00
Ed Sanders c6236b7b77 MWReferenceNode: Don't allow cross-VE paste of template-defined ref
The reference body is not available, so it would be useless.

Bug: T110479
Change-Id: I2a40178bc629ca65d7507feb1c5ff062fd591eda
2015-08-31 14:50:19 -07:00
jenkins-bot 64c73a4ac6 Merge "ve.dm.MWReferenceModel: Require parent document" 2015-08-27 15:38:01 +00:00
Roan Kattouw e4d2d4785e ve.dm.MWImageModel: Require parent document
Add a parentDoc parameter to the MWImageModel constructor and use
it to inherit language, direction and HTML document. Remove
getLang(), setLang(), getDir() and setDir() whose only purpose
was to propagate the language and direction from the parent document
in a hacky way.

Also add a parentDoc parameter to newFromImageAttributes(), replacing
the lang and dir parameters. Remove the unused and ill-conceived
caption parameter.

This causes caption documents to always have an HTML document
for URL resolution. Previously, this worked when editing existing
images because a document generated by cloneFromRange() (which
propagates the HTML document) was passed into setCaptionDocument(),
but it didn't work when creating new images.

Bug: T109599
Change-Id: Ida36862092cd779ffc2f04c0ecbc1164f8d71453
2015-08-27 00:09:21 -07:00
Roan Kattouw f11fbee278 ve.dm.MWReferenceModel: Require parent document
Add a parentDoc parameter to the MWReferenceModel constructor and use
it to inherit language, direction and HTML document. Remove
getLang(), setLang(), getDir() and setDir() whose only purpose
was to propagate the language and direction from the parent document
in a hacky way.

This causes ReferenceModel documents to always have an HTML document
for URL resolution. Previously, this worked when editing existing
references because the newFromReferenceNode() code path calls
cloneFromRange() which propagates the HTML document, but it didn't work
when creating new references.

Bug: T109599
Change-Id: I5d9d34d4343be8428318fa0b795fa54c110e34f4
2015-08-26 23:48:45 -07:00
Ed Sanders a67965a888 MWInternalLinkAnnotation: Override new getDisplayTitle method
This allows the URL paste handler to use the normalized title
as the text content. Add a test to cover this behaviour.

Depends on Ica48fea69cc in core.

Bug: T109980
Change-Id: I2784adaf2949a73256049921227dde0917ef9aef
2015-08-24 14:29:49 -07:00
C. Scott Ananian 2852f6368f Builder for ve.dm.MWInternalLinkAnnotation
Add ve.dm.MWInternalLinkAnnotation.static.newFromTitle to build an
appropriate internal link annotation from a mw.Title.  Tweaked some
method signatures to avoid repeated reparsing of the title text.

Also refactor ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref
to explicitly return a boolean indicating whether the result was determined
to be an internal link.

Bug: T64816
Change-Id: I74385d7b3ede1794398dabb749185f4080509b99
2015-08-19 16:57:06 -04:00
James D. Forrester 282ddfa1b6 build: Enable jscs jsDoc rule 'checkTypes' and make pass
Change-Id: Idbf6e698ba7015ee5e4f1cf78234ad3f187f1c06
2015-08-19 11:37:13 -07:00
James D. Forrester 9e7041f925 build: Enable jscs jsDoc rules 'checkRedundant*' and make pass
Change-Id: I36262ee1fe6116749586014fd30df3e00733fa6c
2015-08-19 11:35:43 -07:00
James D. Forrester 00d3226be1 build: Enable jscs jsDoc rule 'checkParamNames' and make pass
Change-Id: Ifcd3f67524c32148ff3591263d6374b31ee57d3b
2015-08-19 11:33:59 -07:00
James D. Forrester 85f91f394e build: Enable jscs jsDoc rule 'requireNewlineAfterDescription' and make pass
Change-Id: I7c0fabc93834d19198caea8f5dd1834e9e473d0a
2015-08-19 11:21:01 -07:00
James D. Forrester 945242a55a build: Enable jscs jsDoc rule 'checkAnnotations' and make pass
Change-Id: I76abb1eb1f3e1a2e8a4c03f577a080f4889b3a6d
2015-08-19 11:09:34 -07:00
James D. Forrester 19df1d4c8a build: Enable jscs rule 'requireVarDeclFirst' and make pass
Change-Id: Ia2f765d12bde001c329c2ff4c080a36b71de9803
2015-08-19 11:05:01 -07:00
James D. Forrester f5c6f61163 build: Enable jscs rule 'requireSpacesInsideBrackets' and make pass
Change-Id: I846d36c15e1b1f810d2ef7fd422f8412790bcb0f
2015-08-19 10:33:02 -07:00
James D. Forrester 06cdfe7acb build: Enable jscs rule 'requireDotNotation' and make pass
Change-Id: I2586e6959c3bbc7e4204242fc65551747c0e25a9
2015-08-19 10:26:19 -07:00
jenkins-bot a150550bea Merge "MWNumberedExternalLinkNode: Provide a context item" 2015-08-17 20:16:27 +00:00
James D. Forrester 31b4466d5f MWNumberedExternalLinkNode: Provide a context item
Bug: T98211
Change-Id: I0ca7811f5be5ce058f2ec22b2ce80e3228af5886
2015-08-17 13:10:58 -07:00
Alex Monk f6195426f0 Fix foreign file repositories (e.g. InstantCommons or equivalent) support
We were checking 'local' in config to determine whether a repo was local or not,
but config.local *will be set* to undefined in cases where it isn't.

Change-Id: Ic203b6e8204b95a644672790a2836d6e4709d218
2015-08-14 20:19:01 +01:00
jenkins-bot f4192a7847 Merge "Make transclusions which are td/th elements behave as table cells" 2015-08-04 20:37:41 +00:00
Ed Sanders de98382a55 Make transclusions which are td/th elements behave as table cells
Depends on Ic94242c0 in core.

Bug: T85648
Change-Id: I0f65fca37fe94486d0a736d763270b3dc5503649
2015-08-04 17:52:13 +00:00
Jforrester dbe11c3b14 Revert "Revert "For empty / whitespace-only headings, output <p> instead of <h#>""
It's seemingly still needed.

This reverts commit 924c58a893.

Change-Id: Ib9428865fbab2669153bd23cf239717080eb8291
2015-08-03 22:49:16 +00:00
Ed Sanders a4b250c790 MWImageModel#insertImageNode: Separate out linmod generation
Change-Id: Idee01e2e59f2a68481476f3d784502d3ebdf015b
2015-08-03 01:11:50 +00:00
Ed Sanders 97e0cd28a5 Make missingref references uneditable, not uninspectable
Depends on I1ba8978dd in core.

Bonus: remove not-allowed-cursor & highlight title (which was
broken) now that we can display this information properly.

Bug: T106810
Change-Id: I1800490ba1b8e10ff54b26372a8a78661c1c7d68
2015-07-24 12:03:05 -07:00
jenkins-bot 31e45cf530 Merge "build: Drop last jscs over-ride and make pass" 2015-07-23 18:48:48 +00:00
James D. Forrester 57f8fc5368 build: Drop last jscs over-ride and make pass
Change-Id: I4ff60af79cfc6e09e284d51f9b7ac2afa900f0f5
2015-07-22 15:13:09 -07:00
jenkins-bot 8d467915f7 Merge "Revert "For empty / whitespace-only headings, output <p> instead of <h#>"" 2015-07-22 22:05:34 +00:00
Ed Sanders aeedd808cd Never use original data optimisation when in clipboard mode
In clipboard mode we need the full body regardless of if the reference
has changed since load or not.

Bug: T104230
Change-Id: Ie59e04d381f2fd2680e8af0cf05a80df71052822
2015-07-10 19:45:56 +00:00
Ed Sanders 924c58a893 Revert "For empty / whitespace-only headings, output <p> instead of <h#>"
Functionality is now provided by Parsoid's scrubWikitext.

This reverts commit 884f301aa0.

Change-Id: I19f340a1c2d9718bfa05c6667042488f3a589719
2015-07-09 11:46:50 +01:00
Marc Ordinas i Llopis 7a33613d23 Use Parsoid's new Cite HTML and CSS
Starting with I21fbbd3247bf7801e5ef9bd5312f95777f4dd6ef, Parsoid
will emit a new HTML for its Cite extension, which enables CSS
styling. In I487095df8a7c4241a14f7b4480360f6774130bec the new
module 'ext.cite.style' is added to the Cite extension to style
this new HTML format.

This patch
* Loads the ext.cite.style module if the Cite extension is
  present.
* Uses the new HTML format for the internal structure of
  reference and reference list nodes, so they are correctly
  styled.

Backwards compatibility: Only new HTML is used internally in VE,
so as long as ext.cite.style can be loaded the new styles will be
used. It does not depend on which format Parsoid returns, so this
patch only depends on the Cite extension patch, not on the Parsoid
one.

Note: The only way I've found of adding a ext.cite.style dependency
only if Cite is present is to register the whole
ext.visualEditor.mwreference module in the
onResourceLoaderRegisterModules hook. Maybe someone can point to
a better way?

Bug: T86782
Change-Id: Ibf333a502d64d2ed6e029221458b7c606554e414
2015-07-06 14:23:18 -07:00
Ed Sanders 6822635158 Use new hasContent method on linear data
Change-Id: I430e628a9db30970ecdf6996bc51e7440a474077
2015-06-30 09:45:24 +01:00
jenkins-bot bbd91b0fb9 Merge "Remove redundant match function from block image" 2015-06-25 00:06:40 +00:00
jenkins-bot 2582f951af Merge "Give TranclusionNodes a matchFunction so they beat LanguageAnnotations" 2015-06-24 23:53:32 +00:00
Ed Sanders 6d8bd6f6e8 Remove redundant match function from block image
Functionality now provided by allowedRdfaTypes.

Bug: T98999
Change-Id: Icd933f4456fdc85fe08bdc9edc61040cb5bacd89
2015-06-24 23:45:14 +00:00
jenkins-bot bb9f9f9fb4 Merge "Converting an error image (red link) from block to inline does not lose its error state" 2015-06-17 17:28:03 +00:00
suchetag f7026d5e5b Converting an error image (red link) from block to inline does not lose its error state
Bug: T101085
Change-Id: I521be8fbcbab27d712ec408ea7048dca2eaab198
2015-06-17 22:41:41 +05:30
Ed Sanders 965a5dde89 Give TranclusionNodes a matchFunction so they beat LanguageAnnotations
This is a hacky fix, we should find a better way of telling the
model registry that language annotation loses to certain RDFa types.

Bug: T101977
Change-Id: I8be3aa55cbbc2832b8a02a15de27289b3041967e
2015-06-16 14:12:37 +01:00
Mark A. Hershberger 7d5e5ec9a9 MWMediaResourceProvider: Use exist instead of bool check on API values
In the MediaWiki API, booleans exist or don't exist (with an empty string),
you can't check "if (bool)..." since that will always be false.  The API has
a newer formatversion=2 that fixes this but we're not using that yet.

Also update the defaultSource placeholder to match the API response. If one
would only update defaultSource without the 'if'-fix, one can reproduce T66822
on a local wiki (JSON-P request instead of JSON).

Bug: T66822
Change-Id: I5a8ab1136325c33c62982c0869fa14ca2fb26034
2015-06-11 17:29:36 +01:00
Ed Sanders 425e581613 Unregister core image types
Once MW images are registered, we should remove core image support so
we don't accidentally match to them (e.g. an MW inline image with an
unsupported extra RDFa type).

Change-Id: I1c8567346c371fe338f95b232c9ac53e009c5a46
2015-06-02 14:36:14 +01:00
Timo Tijhof f2875141d8 ve.dm.MWTemplateSpecModel: Account for data.maps being undefined
This new property is optional and should not be assumed to be present.
Follows-up 2ac7959849.

The constructor defaults 'maps' to an empty object, so there's no need
to add a "|| {}" in extend() or getMaps(). We merely need to make sure
we don't accidentally dereference the default in exchange for undefined.

Change-Id: Id2cb93696d12a20ee14f9d59705877dc174e6564
2015-06-02 01:48:21 +00:00
suchetag dc2247460c Representation for the red-linked inline images in VE
The red-linked inline images in VE are now identifited as red links and image errors.
They can be changed and thereby be modified just as any other inline image on the editor.

Change-Id: Idb6f6f2da14379fd7db6ca19613dad32fe40023d
2015-05-25 15:18:15 +01:00
Ed Sanders 2f087d9ae7 Update VE core submodule to master (3c1f698)
New changes:
a6144f3 [BREAKING CHANGE] Allow models to specify which extra RDFa types they support

Local changes:
* Use new allowedTypes property in model registry
* For reference nodes, allow 'dc:references'.
* For transclusion nodes, allow any other types.
* For image nodes, allow 'mw:Error'.

Bug: T98999
Change-Id: I7eb2b61eb9336792535e9fd6d5a8dd2d57065f04
2015-05-18 19:42:43 +01:00
suchetag de12c761a3 Representation of red-linked images in VE
The red-linked images in VE are now identifited as red links and image errors.
They can be changed and thereby be modified just as any other image on the editor.

Bug: T52788
Change-Id: I9cbb992c34d71b7073157fe276fee04e901845b1
2015-05-16 17:15:51 +01:00
jenkins-bot f1a6e87bc5 Merge "Don't show placeholder references in lists" 2015-05-06 23:17:28 +00:00
James D. Forrester 38239707b0 jshint: Kill file-level globals and add "moment" to the list
Change-Id: I923ba3490f5fc9b2aaf52d10a163f75dd6401c71
2015-05-06 19:01:27 +00:00
Ed Sanders 9811bc4fd9 Don't show placeholder references in lists
Allow references to be created as placeholders and exclude
them from ReferenceListNodes and the ReferenceSearchWidget.

Bonus: Fix reference numbering when items are skipped (in
list nodes and search widget).

Change-Id: I8dc5146c21f309e89ff4ddd939f7c65a0c358378
2015-05-06 19:15:20 +01:00
Alex Monk 6f17fde4cd Convert 'external' links to internal pages pasted into the search field
Bug: T94334
Change-Id: I0ed67e6579b9ed0a0565968fd253fdf5c6151683
2015-04-29 16:11:32 +01:00
Ed Sanders fdcd42f73a Split AlienExtensionNode into inline and block
MWExtensionNode:
* Inherit from LeafNode at the top level. Inline and block only
  differ in CE where inline has isContent set.

MWAlienExtensionNode:
* Inhert from MW(Inline|Block)ExtensionNode respectively. Both
  mixin MWAlienExtensionNode.

Bonus:
* Bring in paragraph unwrapping on inline nodes from MWMathNode

Bug: T93712
Change-Id: Ib04234f740cf1f27c861d8b3cfeea5e323b94678
2015-04-09 16:32:02 +01:00
jenkins-bot 5de7b8a461 Merge "Merge MW internal link annotations if they have the same target" 2015-04-06 19:32:05 +00:00
Ed Sanders dfdf7c3f28 Merge MW internal link annotations if they have the same target
Currently we compare some HTML attributes, but as wikitext doesn't
allow you to set arbitrary attributes on a link they can never
represent a meaningful difference (unlike <b style="color:red;"> vs. <b>)

Bug: T95028
Change-Id: I267604e4b2140d3c4fe4f9ab07961c6f17a1f2fa
2015-04-06 12:07:03 +01:00
Roan Kattouw dd5608598f Use .apply() in MWInternalLinkAnnotation.static.toDomElements
Otherwise other parameters (there are 4 in total) get dropped.

Change-Id: I91cbb8391218cb7e9179b6b655bbfe22d21ade26
2015-04-03 08:54:45 +00:00
Roan Kattouw f3b7ccdefb Use ve.safeDecodeURIComponent()
Depends on Iacc50230a in VE core.

Change-Id: I7fc505c261726f8d83c86a9cc352a0bf9fcb455a
2015-03-31 22:08:46 +00:00
Roan Kattouw 5026e9b4f5 MWInternalLinkAnnotation: Remove useless .toString() call
ve.resolveUrl() always returns a string, so .toString() is not needed.

Change-Id: Ia699821148687ca16ef642bf94740384779ecb5a
2015-03-30 21:14:27 -07:00
Ed Sanders 8f012e76ce Use new createFromElement method from ModelFactory
Depends on Ia23e5d25 in core.

Change-Id: Iac6f0aaacb8404a28a41e33088fc7f519c227317
2015-03-25 18:26:56 +00:00
Roan Kattouw 884f301aa0 For empty / whitespace-only headings, output <p> instead of <h#>
Because sending HTML like <h2>  </h2> or <h2></h2> to Parsoid
produces undesirable output like ==  == or ==<nowiki />==

Bug: T51452
Bug: T52100
Bug: T57769
Bug: T61647
Change-Id: If15a1b4b31d4f08c23ecdf2ecf61a8a14a77259a
2015-03-20 23:05:37 +00:00
Roan Kattouw 8470e2c272 Update VE core submodule to master (f8f9728)
New changes:
68e20d4 Create AlignableContextItem to quickly adjust AlignableNodes
0150df2 Update OOjs UI to v0.9.3
b333fd3 FragmentInspector: Execute action on enter, rather than closing with data
2d14f7a Fix webkit column hack
be780eb Don't drop whitespace when removing empty slug paragraphs
cc19787 Split handlesOwnChildren and ignoreChildren
7f1c9a7 Localisation updates from https://translatewiki.net.

Local changes:
Add ignoreChildren to handlesOwnChildren nodes

Change-Id: Id3dc7efae8d30b6551b2fc3104ed00bc86339176
2015-03-20 16:04:15 -07:00
jenkins-bot 82dc89dc3e Merge "Remove MWTransclusionMetaNode" 2015-03-12 20:16:42 +00:00
Moriel Schottlender bbb5c84149 Remove MWTransclusionMetaNode
Since all transclusion nodes can be interacted with (including the
'hidden' ones,) there is no need for MWTransclusionMetaNodes.

Change-Id: I23d37e3d82029b7475ec68ebb04883c7e05370cc
2015-03-12 13:12:32 -07:00
Alex Monk 9a0b76ac26 Handle undoing of reference group changes
By removing from and re-inserting into the InternalList when the right
attributes change, rather than trying to hack it into the model's
updateInternalItem (which won't get run on undo).

Bug: T71119
Change-Id: Iaf7a3127576b94666e05691902d2782394d24afb
2015-03-11 19:15:47 +00:00
jenkins-bot 557e0e28ad Remove use of ve.indexOf and ve.getObjectKeys
Change-Id: Icbaa729209605fca8018e4bcbbe29c9ded64e7f2
2015-03-10 17:28:00 +01:00
jenkins-bot ba7db69583 Merge "MWParameterPage: Show the field's example if it exists" 2015-03-09 21:34:27 +00:00
Moriel Schottlender 530f5c05f5 MWParameterPage: Show the field's example if it exists
Also appending both the default value and the example value to the
field description. The input placeholder will show the default
value, the example value, or nothing.

Related to TemplateData change I9e2d66a805e25 but works without.

Bug: T53049
Change-Id: I4e5e57546f6d3c22e778ba061a5344ddee085c17
2015-03-09 14:25:18 -07:00
Timo Tijhof 9fd753e7a7 build: Enforce disallowMixedSpacesAndTabs jscs rule
Also, fix @returns comments (should be @return) and remove unnecessary
@method comments from the documentation.

Change-Id: Icd303626ac745c7ab5bff164f9b8cac276de1523
2015-03-07 16:49:30 +00:00
Roan Kattouw f24dbb3435 Fix transfer of reference contents from removed reference
We unconditionally retrieved originalHtml from itemNode,
even if there was no data-mw.body.id, so as long as
the reference itself wasn't edited, we would never overwrite
data-mw. This meant that if the <ref> with the contents
was deleted, the contents wouldn't be transfered to the
first <ref> tag with that name like they're supposed to be.
The solution is to only look at originalHtml from itemNode
if data-mw.body.id is set.

Change-Id: Ib87491b6fa6a77d62384158f8e8f7dcc2a36c23a
2015-03-02 22:26:05 +01:00
Moriel Schottlender f0f8f52080 Refactor MWMediaResultWidget to resize better
For the masonry view, the result widget resizes itself according to
the rows and other images in the row. Up until now the resize was
a bit buggy, occasionally missing height/width values. This is
mostly due to rounding errors, but also due to a small double
calculation that is now fixed with this code.

Change-Id: If18adc5280e4bdbb9174b7c7e6e4eadf3c1ab26d
2015-02-26 16:42:14 -08:00
Moriel Schottlender b85b81c501 Correctly validate a provider for local api
Make sure that the validation method accounts for local api
vs remote api when checking for valid variables.

Bug: T90795
Change-Id: Ia6877ca6ccc4e65d1db053f107e7702721e2da3c
2015-02-25 15:59:05 -08:00
Alex Monk 8e48f94580 Use mw.Api to run requests rather than our own stuff in ve.init.mw.Target
Bug: T58659
Bug: T89435
Change-Id: I18162f04c50f48606378aed62ee99fccdc3159f6
2015-02-25 01:57:22 +00:00
jenkins-bot bd4289241a Merge "Adjust Queue and Provider to work with generalized parents" 2015-02-24 18:42:40 +00:00
Ed Sanders 65d26891ae Fix transclusion clipboard logic
Run isForClipboard path in MWTransclusion node
even if we have originalDomElements.

Change-Id: Ib5c77888ef41d26e827dbb9a20925e251527a99a
2015-02-22 19:24:41 -08:00
Ori Livneh 4cf393da54 Update VE core submodule to master (032c9a4)
New changes:
dc3b1f8 Replace ve.dm.Model#matchesAttributeSpec

Local changes:
Replace ve.dm.Model#matchesAttributeSpec

Change-Id: I2a107999974309304b59697dad0f7374110b9ab5
2015-02-18 16:32:19 -08:00
Roan Kattouw 3611664663 Update VE core submodule to master (7d2a68e)
New changes:
0ceafd5 Fix V8 deopt for ve.ce.BranchNode#onSplice
01d2d4b [BREAKING CHANGE] Store originalDomElements instead of htmlAttributes
96005a7 Localisation updates from https://translatewiki.net.
42e672e ve.ui.Toolbar: Don't call #updateToolState from #initialize
373562d Localisation updates from https://translatewiki.net.

Local changes:
Update for htmlAttributes going away

Change-Id: I576a1e5d5883b03d1fff6666926f80a5682a280f
2015-02-18 15:35:46 -08:00
Moriel Schottlender 093cf012ea Adjust Queue and Provider to work with generalized parents
Generalize MWResourceQueue and MWResourceProvider so they are
extending the general classes from ve-core. This also allows for
tests in ve-core on the resource queue system.

* Depends on ve-core change I5346081317e *

Change-Id: If34cd99334f4ccb93015c3646f68ae3040b9c5d7
2015-02-17 17:22:21 -08:00
Ed Sanders b9addfc1da ve.dm.MWImageNode: Fix indentation
Change-Id: Ice223d19904f02709a64799cc6b81f8718a92a40
2015-02-17 16:10:33 +00:00
Ed Sanders 7ff516d76c Fix clipboard DM for transclusion nodes starting with invisible tags
<link> and <meta> tags are thrown away by the clipboard so make sure the
data-mw element is converted to a span.

Bug: T86401
Change-Id: Ia2869b9496ea5ce4f474e254bb4125f85152c7cf
2015-02-16 16:52:07 +00:00
Ed Sanders ec4acecf33 Correctly tag clipboard DM from MWTransclusionNodes
Iff in clipboard mode:
* Set data-ve-no-generated-contents on the main element
  regardless of whether we are using orignal DOM elements.
* Set data-ve-ignore on siblings, again, regardless or
  where they came from.

Bug: T89658
Change-Id: I82ad60f0b90e0c6ce88c42737bd36d1a289bcf34
2015-02-16 16:52:04 +00:00
Timo Tijhof 5bf0ac251a Move svgMaxSize and namespacesWithSubpages to site config
These are currently in page-specific mw.config. As these are
not related any page, they should be in the global export.

This is needed to have our tests (and code base) run error-free
without a MediaWiki page.

Bug: T89434
Change-Id: Ic42bcd14028772ff0c06e28c76ffaf156f8b985f
2015-02-13 08:20:26 +00:00
Moriel Schottlender 65d0a9d7e7 Defend against empty file pages in media dialog search
Empty file pages are returned as results in search but have no
useful information, and, more importantly, no 'imageinfo' property.
Make sure these are skipped by the provider.

Bug: T89303
Change-Id: I3374f7373efc1f5751acb16819973594abf56a56
2015-02-11 23:23:38 +00:00
jenkins-bot 0d3bd68431 Merge "Display image uploader and artist correctly in the media dialog" 2015-02-11 21:50:17 +00:00
jenkins-bot 57bffa14c6 Merge "Support specifying reference contents with data-mw.body.id" 2015-02-11 20:18:11 +00:00
Moriel Schottlender a3973145d5 Display image uploader and artist correctly in the media dialog
Add the display for the actual uploader, and change the label
for the artist to "Artist" for differentiating the two roles.

Bug: T88835
Change-Id: Ie939572e7c1240321556f6f81ed9e67d792a339d
2015-02-11 11:14:43 -08:00
jenkins-bot 7ac177c02e Merge "Template dialog: Disable 'Apply changes' until a change is made" 2015-02-10 23:17:01 +00:00
Roan Kattouw 26e5a885bc Support specifying reference contents with data-mw.body.id
If data-mw.body.html is not set, search for the element
whose ID matches data-mw.body.id and use its contents.

.body.html is still used for new content: new references
use .body.html, and if a reference using .body.id is
changed, the changed HTML is output in .body.html.

Bug: T88650
Change-Id: I5d614927256d59a3ab20b0bd6e882b5cb8fcda20
2015-02-09 20:54:50 +00:00
Moriel Schottlender aa9eb95455 Refactor MWMediaSearchWidget to use a queue and providers
Change the media search widget to work with resource queues and
providers. Create providers based on the user's filerepo settings
and aggregate their responses with the media queue. Stop asking
for more results from providers that are depleted.

Also fixes a rather nasty infinite-loop bug where the API returns
only very few images, and the UI keeps asking for more.

Bug: T78161
Bug: T88764
Change-Id: I65aed3446cd1f056476c56e6e04522c70e49e595
2015-02-06 16:45:56 -08:00
James D. Forrester bed038b509 build: Bump devDependencies to latest
Updates:
* grunt-contrib-csslint  0.3.1  ->  0.4.0
* grunt-contrib-jslint   0.10.0 -> 0.11.0
* grunt-jscs             0.8.1  ->  1.2.0

For jscs, leaving requireSpacesInsideArrayBrackets to avoid headaches for now.

Change-Id: I62d34444edbba65c8bd22d2fa5e50e16cabb0042
2015-02-02 14:30:39 -08:00
jenkins-bot d5f7bac940 Merge "Combine imageinfo requests" 2015-02-02 19:32:00 +00:00
Alex Monk dc69b15db1 Template dialog: Disable 'Apply changes' until a change is made
Bug: T76926
Bug: T76927
Change-Id: I5a664f865c11690a19b754fc9877baf37e34edad
2015-01-31 03:19:06 +00:00
Roan Kattouw 2bdb20b3c1 Don't corrupt href="./" in internal links
href="./" was being corrupted to href=""

Change-Id: Ieedd71a991c6b52225f2ac41ebe1a20e7533c19e
2015-01-30 18:44:57 -08:00
Alex Monk 7876cc957a Combine imageinfo requests
By generalising LinkCache into ApiBatchQueue to request them all centrally

Bug: T75822
Change-Id: I097311ec2487bb1ae9f5d927c2c13c274ba716f9
2015-01-30 17:20:04 -08:00
jenkins-bot cc4e8e7ebd Merge "When changing image source, use already-available API info" 2015-01-29 18:34:03 +00:00
jenkins-bot e372b93c4c Merge "Lazy load the media search results" 2015-01-29 18:33:47 +00:00
Moriel Schottlender e454b81f4d When changing image source, use already-available API info
When the user changes an image to another in the media dialog, we
already have API info that includes the original dimensions, media
type and other information that is required for the Scalable object
to compute the new current dimensions. We can use this info if it
exists instead of asking for another API call. Also make sure to
update the filename when we change an image in the dialog.

Bug: T87267
Change-Id: I9d86959b99b3f3dfed92255a9dba9a8fdd352dcb
2015-01-29 01:58:07 +00:00
Moriel Schottlender a44e0d2e5d Lazy load the media search results
* Set the src attribute only when the image is actually
  visible in the search results.
* Display the thumbnail image we have from the search
  results and then update with a larger one from the API.
* Request for more media results on a higher threshhold,
  when the user views 2 rows above the last available
  result.
* Correct the resizeToBoundingBox and simplify it to work
  properly for a non-square bounding box regardless of
  constraints.

Change-Id: If024b0335ce6a5d2d0eafdbfdfe1030dcaac3a75
2015-01-28 17:56:54 -08:00
jenkins-bot a0a6937450 Merge "Use DOM methods instead of jQuery .html() in references DM code" 2015-01-28 23:38:01 +00:00
Roan Kattouw a10fe01f8b Use DOM methods instead of jQuery .html() in references DM code
Bug: T87417
Change-Id: I40df6258cd076911c68351300a488645db1d65d5
2015-01-26 14:06:56 -08:00
Roan Kattouw 711c509f81 dm.MWBlockImageNode: Use DOM methods rather than jQuery
To avoid triggering state thrashing in Sizzle
( https://github.com/jquery/sizzle/issues/311 )

Also account for the fact that missing attributes are returned
as undefined by jQuery but null by .getAttribute().

Bug: T87416
Change-Id: Ib3bc7971920c084568abb6ea0bd822d763b276f2
2015-01-26 09:46:55 -08:00
Moriel Schottlender 061925be87 Add filename to the media dialog
Show the currently used filename at the top of the media dialog so
it can be copied and used in other pages if needed.

Bug: T54459
Change-Id: Ib1844c997189f7ead0656c5a811d3cab70030f89
2015-01-16 17:40:40 +00:00
jenkins-bot 2ebdf34c29 Merge "Transform the search widget to show image details" 2015-01-16 13:26:25 +00:00
Moriel Schottlender 4947420650 Transform the search widget to show image details
Add an info panel to the MediaDialog to show the user information
about the chosen file from the new extmetadata API.

Also, change the way results are viewed:
* Present the search results with their proper ratio.
* Use masonry fit for the search results.
* Change the resizeToBoundingBox method in ve.dm.MWImageNode to accept
  a specific side constraint, either 'width' or 'height'. This is also
  going to be useful for adding and calculating 'scale' considerations
  that affects the image height.
* Add info panel with details from extmetadata including author, license,
  date of upload and creation, etc.
* Get descriptions and data according to wiki language.

Bug: T78161
Bug: T74061
Change-Id: I7b4d019825aa89dd178665bd9492a07af15954ac
2015-01-16 13:22:54 +00:00
James D. Forrester 2f8b3e0d96 build: Bump copyright notices to 2015
Change-Id: Ie92dab7411116d3410195c3fb0a3513c664c0c30
2015-01-12 20:34:19 -08:00
Bartosz Dziewoński 9e5ec5cefb ve.dm.{MWTransclusionModel,MWTemplateModel}: Remove unused parameters
The 'origin' parameter to the constructors has been removed in 51e096d6.

Change-Id: I885f75c381cea013d32d408c7b26de0fa00629c2
2015-01-11 19:25:17 +01:00
Moriel Schottlender e0894b807f Surfaces should have parent document direction
Make sure all surface widgets have documents that are initialized
with the direction of the parent document, so the alignment is set up
correctly.

Bug: T71969
Change-Id: I6e5f003e18a9c5808d9a4b148eddf0d0f7e29e67
2014-12-10 16:46:16 -05:00
Timo Tijhof ee954cbdd5 Use String#slice instead of discouraged String#substr
Aside from the confusion and differences between substr() and
substring() and IE8 bugs with substr(), substr() was removed from
the spec as of ECMAScript 5. It's been standardised in the
optional Annex B section of ES5.

Change-Id: I221ef6ae6956ce20dd9bb74510500f747d04c3b1
2014-12-06 21:26:20 +00:00
jenkins-bot c5ec9cb8d5 Merge "Methods for new "maps" property in TD Root" 2014-11-17 20:56:49 +00:00
jenkins-bot ad92b977d5 Merge "Followup a054a75: don't reintroduce removed template parameters" 2014-11-10 20:44:28 +00:00
Roan Kattouw 5f1e7a651c Followup a054a75: don't reintroduce removed template parameters
Deep-extending originalData is asking for trouble, because there's
no way to delete anything that way.

Bug: 73134
Change-Id: I44d3e582e04942efceae3e0bdbbaa147095b5146
2014-11-10 15:04:42 -05:00
Roan Kattouw 2ba844a372 Followup c232083: use getRelativeTitle for template titles
Otherwise we output stuff like {{Template:Echo|hello}}

Change-Id: Ib6c3996ab40e01a5ddce84b7daffa27a74020ee5
2014-11-10 15:03:10 -05:00
Ed Sanders 5238d06dc7 Support pre's in tables
Bug: 73100
Change-Id: I971420047026c91ed92a19a52d2fd3b6fbeac24a
2014-11-07 15:44:13 +00:00
jenkins-bot 209dbe2449 Merge "Allow headings in table cells" 2014-11-05 23:52:23 +00:00
Ed Sanders 26f567d84f Allow headings in table cells
We possibly want to discourage this somehow but our current
functionality achieves this by doing an isolateAndUnwrap
which for a table is catastrophic.

Bug: 72990
Change-Id: I79f1348da20385dfec014afcac0fb5464580cf2f
2014-11-05 22:34:13 +00:00
Roan Kattouw c23208371a Followup 0165a53: don't store an mw.Title object instead of a string in TemplateModel
0165a53 overlooked the fact that 'name' is also passed to
the MWTemplateModel constructor, and there it really does
always need to be a string, not magically either a string
or an mw.Title object. Oops :(

Bug: 72961
Change-Id: I0b20f0768aae4d9cc9f7af268abd0a704b6adc3a
2014-11-04 10:58:53 -08:00
Roan Kattouw 362d0ebcdf Followup 0165a53: fix typo causing undefined to be passed to mw.Title
Bug: 72948
Change-Id: I1942f153f18c5a182de38a0e067ec5a92abeefd3
2014-11-04 10:53:58 -08:00
jenkins-bot bb96a9083f Merge "Replacing MWTitleInputWidget.getValue() with MWTitleInputWidget.getTitle()" 2014-11-04 01:18:38 +00:00
suchetag 0165a53044 Replacing MWTitleInputWidget.getValue() with MWTitleInputWidget.getTitle()
Now that we have .getTitle() as a method in MWTitleInputWidget, replacing the callers
of MWTitleInputWidget.getValue() with .getTitle(). This fixes a bug in the .getTitle()
method in MWTitleInputWidget which was not taking the namespaces into account before.

Also fixes: the error when entering "Talk:" as a template title. The button to add template
remains disabled when "Talk:" is given as an input to the title here.

Bug: 71998
Change-Id: I1e629a61ec8b035d93a4b7acfecab81934019166
2014-11-03 17:05:51 -08:00
Alex Monk b71bb51171 Remove more references to ve.bind
Seems some of them have crept back in since I1a7fc7f2 (and we missed one somehow)

Bug: 72156
Change-Id: I5631fb7d5963d06aeb238c1daa44344b2060ef1a
2014-10-30 20:55:44 +00:00
jenkins-bot c83961842c Merge "Preserve original data inside parameter objects too" 2014-10-30 20:47:32 +00:00
Roan Kattouw a054a753be Preserve original data inside parameter objects too
Parsoid has added a "key" property to parameter objects,
so now we have to preserve that rather than regenerating
all parameter objects.

Do this by changing the existing use of this.originalData
to a deep extend.

Change-Id: Ib4d31c2e0f7b567da1a148b51c42e688a2590b8e
Bonus: avoid modifying this.originalData
2014-10-30 11:59:42 -07:00
Roan Kattouw 190ba17b74 Also add tableCaption to mwTable parentNodeTypes hack
Change-Id: Ic7e387bdb774699746e6bafb62daf9c843af77b5
2014-10-30 11:38:26 -07:00
jenkins-bot 48e40fe3c2 Merge "MWTransclusionModel: Exclude parts serialising to '' from the plain object" 2014-10-29 23:20:48 +00:00
Roan Kattouw f35d577acb Followup e0981a3: don't pass undefined to getClassAttrFromAttributes()
Change-Id: I987345cd923d1b128573f5669d4d0dd4e82db1c9
2014-10-29 14:50:50 -07:00
Ed Sanders e0981a327f Create mwTables with wikitable attribute by default
Change-Id: I094b1823248e16dd3b9a0a10ba13104f14798621
2014-10-29 12:52:24 -07:00
Ed Sanders cfee8047e4 Use ClassAttributeNode mixin in MWBlockImageNode
This functionality was factored out into core for this purpose.

Depends on I2db6563 in core.

Change-Id: I4fc42e1468a9f0860c7c13e73967204bdf5ad78d
2014-10-29 18:28:33 +00:00
Alex Monk a982d2d3fe MWTransclusionModel: Exclude parts serialising to '' from the plain object
So we get rid of empty content nodes

Bug: 63341
Change-Id: I1d49cc709bf92cc53ba064d148a76650c5143935
2014-10-29 01:08:41 +00:00
jenkins-bot 20b20bc97c Merge "Move autoValue logic from ui.MWParameterPage to dm.MWParameterModel" 2014-10-27 18:15:08 +00:00
Alex Monk 8120dac27b Move autoValue logic from ui.MWParameterPage to dm.MWParameterModel
Also add missing MWParameterModel#getDefaultValue

Bug: 72404
Change-Id: I4bb117d419f3845f44e321f848e95bb246a24e24
2014-10-27 03:31:36 +00:00
Moriel Schottlender b8f96bb512 Make sure initialHash exists before checking its value
(Followup on If17b50cc4a39993)
Make sure initialHash is set before checking and changing its value
in the MWImageModel method. If a user chooses a brand new image to
insert into the document (an insertion rather than update) then the
initial hash is empty, and changing its values will fail with an
error message.

Bug: 72492
Change-Id: I3f9ea74891cc0ab77a07fa5d4e9cbc591f5b93e6
2014-10-24 16:18:06 -04:00
Marielle Volz 2ac7959849 Methods for new "maps" property in TD Root
Methods for new "maps" property in
Template Data JSON root added to
the Template Specification Model

* Added maps property to MWTemplateSpecModel
* Maps filled in extend function
* Added getter function for maps

Depends on I3bf5e002

Change-Id: Ic555093625358d8fc4cb1ca8c68793b5912e8ced
2014-10-24 14:23:46 +01:00
Moriel Schottlender 14e1de1009 Update initialHash after getting defaultDimensions in image model
On initialization, the image model has an initial scalable that has
the given currentDimensions from Parsoid; these are usually correct.
However, in cases where the wiki settings do not fit the user settings
and the images appear smaller or bigger in practice than the values
of the wiki-defaults, the initial hash will store the wrong values.

We will only know what the real values for the comparison will be
after we get them from the API and the calculation; only at that
point we can update the image model initial hash.

This is important so that later the dialog can properly understand
whether to enable the "apply" button if a user changed an image
to custom size and then back to default.

Change-Id: If17b50cc4a39993f98a20a3fec3ddf5d8cb400b3
2014-10-22 00:11:43 +00:00
suchetag e3d185dd90 Replacing push.apply in VE-MW with ve.batchPush from VE core
Bug: 66206
Change-Id: Ifabfd0f28b8133e40ce822ed768442ab6a4d39ad
2014-10-16 23:12:22 +05:30
jenkins-bot 8005868566 Merge "Make MWTransclusionModel and MWTemplateDialog extensible" 2014-10-10 20:40:19 +00:00
Christian Williams 1fc13cce68 Make MWTransclusionModel and MWTemplateDialog extensible
Wikia has done some work on the template user experience, including
automatically showing all available parameters without the use of
TemplateData. In order to make our changes, we had to make some changes
to VE-MW.

ve.dm.MWTransclusionModel.js
* this.specCache is created so subclasses can reference it.
* Promise handlers in the fetch() method have been broken out as class
  methods so they can be overridden in subclasses.

ve.ui.MWTemplateDialog.js
* addPromptedParameters() has been moved to the
  initializeNewTemplateParameters() class method so subclasses can
  overwrite. In Wikia's implementation, we have a method of getting
  all parameters and a dialog that shows all of the parameters, so the
  request to addPromptedParameters is overwritten.
* Added a done() handler to the transclusionModel promise for Wikia
  extensibility.

Change-Id: I073c5850420e7719e82957f879423c2717af674a
2014-10-10 20:38:18 +00:00
jenkins-bot 1d3f875dc4 Merge "Apply link styling logic to transclusion nodes" 2014-10-08 14:30:01 +00:00
Alex Monk 8f7713e796 Apply link styling logic to transclusion nodes
Only template nodes for now. Not sure what we can do about generated content nodes in general...

Bug: 65353
Change-Id: I848f36764b446ed30c74c0e641d0973008f6880b
2014-10-08 15:03:40 +01:00
Ed Sanders 1af18c3c12 Update VE core submodule to master (984b57a)
New changes:
6bbcd6a Localisation updates from https://translatewiki.net.
b8d8a5b [BREAKING CHANGE] The Great Selection Rewrite of 2014

Local changes:
Update to use new selection/range API

Change-Id: I5480d5c77d599c93c2d374fac88bb2fdb68b0024
2014-10-07 21:39:33 +02:00
jenkins-bot 64b2568465 Merge "Use mw.Title#getRelativeText to deal with titles relative to specific namespaces" 2014-09-26 02:50:43 +00:00
Alex Monk ef1cebd111 Use mw.Title#getRelativeText to deal with titles relative to specific namespaces
Added in MW core in Ie554adef, was backported to 1.24.

Change-Id: Iedc0319042529d41d29846d1734b5481850e9552
2014-09-26 02:47:18 +00:00
Ed Sanders 26751dc4a1 Prevent exception throwing in getFilename of MWImageNode
This doesn't happen in real life (as resource is always set) but
it allows us to contruct these nodes from the factory with no data.

Change-Id: Iea146f5dc128ad9d0f36a79b6fe67d622767d46c
2014-09-24 20:43:57 +01:00
Timo Tijhof 66de06b0fa Replace use of ve.isArray with native Array.isArray
Change-Id: Ibc45e0fd80db7da872f6ef934cef915be9366e06
2014-09-23 17:58:09 -07:00
Moriel Schottlender f4dc6fd240 Add 'autovalue' to TemplateData
Allow for an auto-value for parameters in TemplateData, and make sure
this autovalue is inserted as text when parameter is loaded. This is
mostly useful for referencing date or other dynamic templates inside
parameters.

Bug: 52029
Change-Id: I6203530798ffaa62cb26190c70f7ce391bddf123
2014-09-20 00:52:23 +00:00