Commit graph

700 commits

Author SHA1 Message Date
jenkins-bot e1c49ace99 Merge "Refactor ve.ui.PagedDialog" 2013-10-04 20:25:43 +00:00
Kyle Florence 4efc6cadb7 Refactor ve.ui.PagedDialog
This commit extracts the page and outline handling logic from
ve.ui.PagedDialog (RIP) and moves it into two layouts: ve.ui.PagedLayout
and ve.ui.PagedOutlineLayout, respectively. These layouts are now implemented
inside the dialogs that used to mixin the ve.ui.PagedDialog class. This
brings a much cleaner separation of concerns between Dialogs and Layouts
and allows the use of page handling logic without the accompanying
outline logic.

Change-Id: I5efa2f893f4b7e962438b3aff34b737573bbd5ca
2013-10-04 12:09:15 -07:00
jenkins-bot 1a9f6489d7 Merge "Rename getDocumentSlice to cloneFromRange" 2013-10-03 18:19:13 +00:00
Ed Sanders 1957eb3e28 Rename getDocumentSlice to cloneFromRange
We already getSlice which returns a ve.dm.DocumentSlice, so using
the word slice in this method is very confusing. What we are actually
doing is creating a ve.dm.Document from a range. Also remove argument
overloading as it's not particularly helpful and would make the new
name a lie.

Change-Id: I93da3419510410b170396e6765fbe2a87f9795be
2013-10-03 12:48:01 +01:00
Moriel Schottlender fb4aae8ea8 Add optional i18n parameters to MWDialog titles
This change allows for the Username to be sent in MWBetaWelcomeDialog
title so the i18n message can support {{GENDER:}} parameters.

This change arose from the need to provide GENDER support when translating
the welcome message from Change-Id: I6a3da40b286bb1abd2aff360dab3b386deb13420

Change-Id: Iae70fbaa5be822d571a0d75704cfeca4eabd2fe8
2013-10-02 17:32:49 +00:00
jenkins-bot bea113fee2 Merge "Introduce newFromDocumentReplace() transaction builder" 2013-09-26 20:45:54 +00:00
jenkins-bot 23dd5f9fb9 Merge "'Config' -> 'Configuration' in all comments" 2013-09-26 19:02:30 +00:00
Roan Kattouw cf17789985 Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.

With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );

and that takes care of metadata, internal list items, and things like
references that reference internal list items.

ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
  and the number of items in its InternalList at the time of slicing
  in the created slice. This is used for reconciliation when the
  modified slice is injected back into the parent document with
  newFromDocumentReplace().

ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
  mapping from old to new InternalList indexes so the linear model data
  being injected by newFromDocumentReplace() can have its InternalList
  indexes remapped.

ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()

ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
  newFromDocumentReplace into that
* Add empty internalList to new mini-documents

ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests

ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes

ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests

VisualEditor.hooks.php:
* Add new test file

Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-25 21:46:38 +00:00
Ed Sanders e6f48c5c93 'Config' -> 'Configuration' in all comments
Because the former isn't a real word.

Change-Id: Ie6ed15f9e390b357bbaa768b57f3c3fd7cf21181
2013-09-25 11:23:16 +01:00
jenkins-bot 1546485fed Merge "No more configuration overrides" 2013-09-24 22:11:06 +00:00
Erick Guan 30f1ed4c75 No more configuration overrides
In various places in the UI code, certain properties of config objects
were overridden and in some cases the configurations were documented as
private as a strange hack to prevent them from being advertised in the
docs.

I, Trevor, have been convinced of the error of my ways, and gladly
reverse this situation, allowing all configurations to always be
overridden when desired, while still allowing default values.

Change-Id: I242e3b1902dec8e09eeea38fa64381e69ee04215
2013-09-23 23:59:14 +00:00
Roan Kattouw eb64743436 Prevent naming collisions when generating unique reference names
Simply generating ':3' as the "unique" name for the 4th reference
doesn't work. Even if getUniqueListKey() had been used, that only
checks for conflicts with names that have already been encountered
(i.e. occur in <ref> tags that precede the current one), not for
conflicts with names that first occur further down in the document.

The solution is to generate names at serialization time, when we
have full knowledge of which names are in use. Internally, we use
'literal/<name>' for names that literally appeared in the source,
and 'auto/<number>' for unnamed references. Then at serialization
time, we translate 'auto/<number>' to 'literal/:<number>' if needed
(i.e. if the reference was reused).

ve.dm.MWReferenceNode.js:
* toDataElement()
** Prefix listKey with literal/ or auto/ as appropriate
* toDomElements()
** Map auto/ listKeys to unique names
** Don't try to unset the name if not present (was unsetting a property
   that didn't exist anyway)

ve.dm.InternalList.js:
* Remove now-unused isUniqueListKey()
* Rewrite getUniqueListKey()
** Make prefix configurable
** Take previously generated unique keys into account
** Map the same old key (auto/N) to the same generated key (literal/:M)
* Add getNextUniqueNumber() as a source for auto/N numbers: previously
  used the length of the itemHtmlQueue, but that only works during
  conversion, not from the UI dialog

ve.ui.MWReferenceDialog.js:
* For new references or conflicting names, generate an auto/N key and
  let toDomElements() deal with actually mapping that to name

ve.dm.InternalList.test.js:
* Rename listKeys to new style
* Split the test case into two groups so we can test multi-group cases
* Add tests for getUniqueListKey()

ve.dm.mwExample.js:
* Rename things to new style
* Modify the test case so it attempts to trigger bug 54341

Bug: 54341
Change-Id: I726fb83e6fb66ffec643d996768a854ec9474b3d
2013-09-19 21:03:15 -07:00
Trevor Parscal d5e7a7ef95 Exclude tools from catch-all menu in media and reference edit dialogs
Change-Id: Ic3c94099fa1db5b1a40ac2a2dbf17562cb36c73b
2013-09-04 17:32:50 -07:00
jenkins-bot feff1fbc24 Merge "Improve welcome dialog support for large fonts" 2013-09-04 23:02:05 +00:00
jenkins-bot 9d67f41ca7 Merge "Insert images after selection, not in place of it" 2013-09-04 23:00:03 +00:00
Trevor Parscal 0c42e51c8f Improve welcome dialog support for large fonts
Objective:

* Make the welcome dialog work with smaller fonts by increasing its
  size a bit, and also making its contents scroll vertically if needed

Changes:

ve.ui.MWBetaWelcomeDialog.js
* Move content into a scrollable and padded panel layout element

ve.ui.MWDialog.css
* Remove padding, now provided by panel layout

ve.ui.Dialog.css
* Remove min-height override, inherited value is fine
* Use max width and height instead of setting them directly

Bug: 52667
Change-Id: Ie35b041e13ef18ffcacef6d9e70439e4e1351e0a
2013-09-04 22:58:52 +00:00
Trevor Parscal d377f3e495 Insert images after selection, not in place of it
Bug: 52460
Change-Id: I69ce4c2473d57fd585df0c602359c1d0f60a58f7
2013-09-03 13:37:43 -07:00
Trevor Parscal 8dfbc5baa5 Make tools generic and add fancy tool groups
Objectives:

* Got rid of mw prefixing in tools, inspectors and dialogs
* Simplify tool classes so they can be generically used as items in bars, lists and menus
* Add support for a catch-all toolbar group
* Simplify tool registration, leaning on tool classes' static name property
* Move default commands to command registry
* Move default triggers to trigger registry
* Get language tool working in standalone

Change-Id: Ic97a636f9a193374728629931b6702bee1b3416a
2013-09-03 11:27:39 -07:00
jenkins-bot 3d2a33855c Merge "Re-build reference search index so they can be used mid-edit" 2013-08-30 19:12:23 +00:00
Trevor Parscal ac77d33c9e Re-build reference search index so they can be used mid-edit
The search index was only being built on initialization, rather than at
the time the list was being shown. By moving it to be built on open
the list will always be fresh. Also, just after building the index, we can
enable/disable the select existing button based on the number of
results.

Bug: 51689
Bug: 51848
Bug: 52000
Change-Id: Ib38b1b227edc3d61dc49fa58999358e7adf11b08
2013-08-30 19:09:47 +00:00
jenkins-bot bc9205e0cc Merge "VisualEditor: RTL entries don't receive dir="rtl" in Page settings / Languages" 2013-08-30 18:26:55 +00:00
Pavel Selitskas 1084cdb350 VisualEditor: RTL entries don't receive dir="rtl" in Page settings / Languages
We call isRedirect to get the real language code instead of the site code.
Post-factum, lang attribute is added as well for each entry.

Bug: 53503
Change-Id: Ia6bf63a7cbe3c7b99ed05d0bd0fdd33190550c98
2013-08-30 14:39:45 +03:00
jenkins-bot 0cdcf2d155 Merge "Always give references names. Ignore if used once." 2013-08-29 18:26:04 +00:00
Ed Sanders 52de8b76ec Always give references names. Ignore if used once.
This avoids problems when unnamed references were copy-pasted.

Knowing that key is always non-null simplifies a lot of logic
elsewhere.

Bug: 53365
Change-Id: I3a23123ae732d9583814d38dd880a0cdf691fd5d
2013-08-28 12:47:33 -07:00
Ed Sanders f50102f521 Disable inserting/changing references when surface widget is empty
This listens to change events on the surface and checks to see if
there is more than just an empty paragraph node.

Bug: 53345
Change-Id: Ic8fa84d7cdcbffd154178939d0ec8c2c4f86c415
2013-08-27 17:18:52 -07:00
Trevor Parscal 3886821b9b Use mw specific names for commands
Objective:

* Use the MW link specifically, since the target/command system doesn't
  understand the group/id/extension concept yet

Change-Id: I8b756fa0bb55468312bb30d45ac5b943ff7362b5
2013-08-21 23:53:53 +00:00
Trevor Parscal 332e31fb00 Toolbar API
Objectives:

* Make it possible to add items to toolbars without having to have all
  toolbars know about the items in advance
* Make it possible to specialize an existing tool and have it be used
  instead of the base implementation

Approach:

* Tools are named using a path-style category/id/ext system, making them
  selectable, the latter component being used to differentiate extended
  tools from their base classes, but is ignored during selection
* Toolbars have ToolGroups, which include or exclude tools by category or
  category/id, and order them by promoting and demoting selections of
  tools by category or category/id

Future:

* Add a way to place available but not yet placed tools in an "overflow"
  group
* Add a mode to ToolGroup to make the tools a multi-column drop-down style
  list with labels so tools with less obvious icons are easier to identify
  - and probably use this as the overflow group

Change-Id: I7625f861435a99ce3d7a2b1ece9731aaab1776f8
2013-08-20 16:08:26 -07:00
Ed Sanders b6443b262c Preserve selection when inserting references
Some browsers (e.g. Firefox) change the CE range when the dialog
is opened, so after the first surfaceModel change (to modify the
internal item) the surface's selection is modified, and the reference
is inserted in the wrong place.

Bug: 52159
Change-Id: Ia5da33b95a599ba78f308cf0554279ad44616f50
2013-08-20 18:18:37 +01:00
Ed Sanders f25d34d0a6 Minor syntax error
End of line comma instead of semi-colon.

Change-Id: I6e8d56e378b2a0f8846d18c413b0cccfb9b780d0
2013-08-20 18:06:28 +01:00
Ed Sanders 0fdd124a17 Allow more things to be inserted into captions
Specifically: transclusions, formulae & references.

Captions also allowed to contain other images and reference lists
but we should probably not encourage that.

Change-Id: Ia1c99e51640a3f9ee53281a1e3ebd67dc13c8990
2013-08-02 18:55:53 +00:00
Rob Moen 5231d05bbe Beta welcome dialog
For configured wikis, show a dialog that welcomes the user to the
amazing and fantabulous world of VisualEditing, which is not only full of
wonderment and joy but also may lead to increased popularity and love.

The dialog only shows up once (uses a cookie).

Change-Id: I8e7c4dc2c63b36594378a543b9d66291395eebcf
2013-08-01 21:08:15 -07:00
Timo Tijhof ac6c4da3a7 doc: @return -> @returns
Follows-up 8f05cdbf70.

Change-Id: Id2b68e521ab68862f0f635925708a35d10795342
2013-08-01 02:10:23 +02:00
Timo Tijhof 8f05cdbf70 doc: Add placeholders for unindexed methods
Not having a description yet is fine, but they should at least
be indexed as blocks so that they are searchable and listed
in the jsduck generated pages. jsduck defaults to @method + name
of prototype property. And it even guesses parameters sometimes.

Search: \n\n([a-zA-Z\.]+\.prototype\.[a-zA-Z]+)
Where: modules/ve,modules/ve-mw
Where-Not: modules/ve/test
Replace: \n\n/** */\n$1

Added @return in a few places where it was easy to add.

Change-Id: I830c94cc7dbc261bd7a077391f930cbfff165f9d
2013-07-31 23:00:30 +00:00
jenkins-bot 40e712985c Merge "Add keyboard shortcut for 'clear' button" 2013-07-30 00:51:19 +00:00
James D. Forrester bc3cc9bbdc Add keyboard shortcut for 'clear' button
Now Ctrl+\ (Cmd+\ on Mac) will trigger the 'clear annotations' button
on the current context. Ideally we'd also bond to the 'clear' keyboard
button (ASCII 12) but it does not seem possible to do that yet.

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

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

Change-Id: If560e658dc1fb59bf01f702c97e3e82a50a8a255
2013-07-30 01:44:22 +02:00
Ed Sanders d7bbb1d206 Parse category names correctly
Category names containing colons now parse correctly.

Bug: 51902
Change-Id: If571bb9922399c5a5f77f0b304bec3f2b6f5f7dd
2013-07-25 13:50:49 +01:00
Moriel Schottlender 96fa010f58 Image insertion alignment fix
This removes the initial alignment (either left or right) from new
inserted images, letting the wiki decide the default positioning.
Also, it makes sure that VisualEditor positions the image properly
(according to wiki defaults tright/tleft for ltr/rtl) when editing.

Bug: 51851
Change-Id: I25b966cf6f2736437509ea7e70bfda1bdbc79021
2013-07-23 20:22:43 -04:00
Trevor Parscal dc606823e2 Use ve.ui.SurfaceWidget for image captions
Objectives:

* Make use of the new ve.ui.SurfaceWidget.js for image caption editing

Changes:

ve.ui.MWDialog.css
* Remove styles that are no longer needed
** -body class isn't needed if you contain the content in a layout and
   configure it to be padded
** Toolbar styles are now part of surface widget

ve.ui.MWMediaEditDialog.js
* Wrap caption fieldset in an editPanel (also nice because we may merge
  this dialog with MediaInsert and use a stack panel layout in the future
* Replace surface and toolbar with surface widget which manages both

Change-Id: I1b7e0e2ec1cfa30879360a7ebde2b0f35d26aca5
2013-07-18 21:35:22 +00:00
Trevor Parscal 61ba07d409 Reference dialog commingling
Objectives:

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

Changes:

*.php
* Cleanup unused files/messages

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

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

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

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

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

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

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

Bug: 51152
Bug: 50458
Change-Id: I8265febf4fd8f64d2ac40470ff033bac68b24d99
2013-07-18 14:14:14 -07:00
Trevor Parscal ef262dc241 Add padded option to layouts
Objectives:

* Add option to layouts to control whether it's padded or not
* Rename "scroll" option to "scrollable" to better fit with it's boolean value

Changes:

ve.ui.Layout.css
* Add styles for scrollable and padded options

ve.ui.StackPanelLayout.js, ve.ui.PagedDialog.js, ve.ui.ReferenceListDialog.js
* Update use of scroll option

ve.ui.PanelLayout.js
* Add padded option
* Rename scroll option to scrollable
* Switch to using a class for scrollable option, rather than hardcoding CSS properties

Change-Id: I50e996b9d2fde361238cde75e09baa5872e12223
2013-07-17 19:10:44 +00:00
jenkins-bot c4b05b893d Merge "Use template icon on template placeholder pages" 2013-07-16 00:35:08 +00:00
Trevor Parscal 09f920fcac Remove field set label on reference edit dialog
Objective:

* Allow fieldsets to not have labels
* Remove label from reference edit dialog field set

Changes:

ve.ui.Layout.css
* Only apply negative top margin if fieldset label is being used

ve.ui.FieldsetLayout.js
* Only add label element to DOM if icon or label are used

ve.ui.MWReferenceEditDialog.js
* Remove label from reference edit dialog's first fieldset

*.php
* Remove unused message

Change-Id: I4a36e819ec6ef73aad80d3fb2f06000cb35ec109
2013-07-15 23:44:07 +00:00
Trevor Parscal 130e446e52 Single-click insertion
Objectives:

* Reduce the number of clicks and mouse maneuvers required to insert
  media, references or template parameters
* Make use of highlighting with mouse movement or arrow key presses,
  similar to menus, to suggest action when clicked
* Improve the way media search results look and feel

Changes:

ve.ui.SelectWidget.js
* Add mouseleave handler to un-highlight when the mouse exits the widget
* Document highlight events (already being emitted)

ve.ui.SearchWidget.js
* Propagate both select and highlight events from results widget
* Make arrow keys change highlight instead of selection
* Get rid of enter event, make enter key select highlighted item instead
* Provide direct access to results widget through getResults method

ve.ui.MenuWidget.js
* Use the selected item as a starting point if nothing is currently
  highlighted when adjusting the highlight position

ve.ui.Dialog.js
* Add footless option to hide the foot element and make the body extend
  all the way down to the bottom
* Remove applyButton, which only some dialogs need, and should be creating
  themselves, along with other buttons as needed

ve.ui.Widget.css
* Change highlight and selected colors of option widgets to match other
  selection colors used elsewhere
* Leave selected and highlighted widget looking selected

ve.ui.Frame.css
* Add background color to combat any color that might have been applied to
  the frame body in the imported CSS from the parent frame

ve.ui.Dialog.css
* Add rules for footless mode

ve.ui.MWReferenceResultWidget.js,
ve.ui.MWParameterResultWidget.js,
ve.ui.MWMediaResultWidget.js
* Allow highlighting

ve.ui.MWParamterSearchWidget.js
* Switch from selecting the first item when filtering to highlighting

ve-mw/ve.ui.Widget.js
* Adjust media result widget styling to better match other elements

ve.ui.MWTransclusionDialog.js,
ve.ui.MWReferenceListDialog.js,
ve.ui.MWReferenceEditDialog.js,
ve.ui.MWMetaDialog.js
ve.ui.MWMediaEditDialog.js
* Add apply button, as per it being removed from parent class

ve.ui.MWTransclusionDialog.js,
ve.ui.MWReferenceInsertDialog.js,
ve.ui.MWMediaInsertDialog.js
* Insert parameter/reference/media on select, instead of clicking an
  insert button
* Use 'insert' instead of 'apply' as argument for close method

Bug: 50774
Bug: 51143
Change-Id: Ia18e79f1f8df2540f465468edb01f5ce989bf843
2013-07-15 23:42:56 +00:00
Trevor Parscal c7a5546bb2 Use template icon on template placeholder pages
As opposed to using a parameter icon - which just doesn't make sense.

Change-Id: Idbe42a1b91a0691d1cf83dde4221ce3aac09d0fa
2013-07-15 15:43:39 -07:00
Trevor Parscal d3df2a5a91 Fix uses of addPart to make them async friendly
Problem:

Adding or moving templates or content resulted in the incorrect item
being selected.

Diagnosis:

Although recently we solved a few issues by making addPart async, it
caused some other issues where callers of addPart were assuming
otherwise

Solution:

Return a promise from addPart which is resolved after the part is
actually added and setup callers to use the promise when needed

Changes:

ve.ui.MWTransclusionDialog.js
* Use promises to auto-select new or moved parts

ve.dm.MWTranclusionModel.js
* Make addPart return a promise
* Resolve promise when queue is processed
* Automatically remove existing items before adding them in different
  locations at the time of processing the queue we don't yield between
  removing and adding

Change-Id: Ie43c5b89ca4ed34d5f797714e19c9a7e1824cdec
2013-07-12 01:30:04 +00:00
Trevor Parscal b3b2d3fb91 Preserve unused Parsoid template properties
Problem:

Parsoid has a property called "i" which we don't use, but they need for
round-tripping purposes. Since we were generating a structure from
Parsoid data and then generating data from the structure without
preserving properties we didn't use, it was getting lost.

Solution:

Abstract creating a template from data vs. creating it from name. Make
only templates have an origin argument in their constructors, so and
set it within a set of static constructors that create a template for
either data or a template name. Store the original data in the former
case, and use it as a base when serializing.

Changes:

ve.ui.MWTranslcusionDialog.js
* Remove no-longer-needed mw global declaration
* Move most of the addTemplate function to a static constructor in the
  template model class

ve.dm.MWTransclusionPartModel.js,
ve.dm.MWTransclusionContentModel.js,
ve.dm.MWTemplatePlaceholder
* Remove unused origin argument/property/getter
* Add serialize method (if needed)

ve.dm.MWTranclusionModel.js
* Move template/parameter generation from data into static constructor
  of template model
* Move serialization to part classes

ve.dm.MWTemplateModel.js
* Add mw global declaration
* Stop passing origin to parent constructor, store it locally instead
* Add original data property/setter for preserving unused properties
  when round tripping
* Add static constructors for generating a template from data or by name
* Add serialize method

Bug: 51150
Change-Id: Ide596a0ca0ae8f93ffce6e79b7234a1db7e0586c
2013-07-12 00:47:01 +00:00
Trevor Parscal fc95029b34 Auto-add required params for user added templates
Objectives:

* Automatically add required parameters to templates that users create
  using the GUI, without touching existing templates loaded from data
* Cleanup some confusing terminology and APIs

Changes:

ve.ui.MWParameterSearchWidget.js
* Remove special logic for skipping aliases, which are no longer included
  in the list of names given by getParameterNames

ve.ui.MWTransclusionDialog.js
* Add origin arguments to constructors of transclusion parts
* Re-use onAddParameter method during initial construction of parameter
  pages
* Add required template parameters for user created template parts

ve.dm.MWTransclusionPartModel.js
* Add origin argument/property/getter for tracking where a part came from

ve.dm.MWTransclusionContentModel.js,
ve.dm.MWTransclusionPlaceholderModel.js,
ve.dm.MWTemplateModel.js
* Add origin argument pass through

ve.dm.MWTranclusionModel.js
* Add origin arguments to constructors of transclusion parts

ve.dm.MWTemplateSpecModel.js
* Rename origin to name - was a bad name to start with and will be even
  more confusing with the new part origin property
* Add isParameterAlias method
* Make getParameterNames only return primary names, excluding aliases

ve.dm.MWTemplateModel.js
* Update use of parameter origin, now called name

Bug: 50747
Change-Id: Ib444f0f5a8168cd59ea52a6000ba5e42ccdc2a24
2013-07-11 16:31:51 +00:00
Roan Kattouw e9ca44c86c Transplant CSS from the main document to each iframe
We previously manually loaded CSS into these frames, which is flawed
because it completely bypasses ResourceLoader (so CSSJanus didn't flip
them, necessitating a bunch of hacks for RTL), and doesn't pull in
MediaWiki styles (so templates inside references don't render correctly).
Instead, this commit copies all styles from the main document into each
frame's document, inlining what it can.

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

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

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

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

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

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

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

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

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

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

Change-Id: I4a37115301811ad860f4578344a04873ea8c2b69
2013-07-09 16:13:28 -07:00
Roan Kattouw 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