Commit graph

114 commits

Author SHA1 Message Date
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
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
Trevor Parscal 4568274949 Template parameter adding
Objective:

* Allow browsing, searching and adding documented parameters

Changes:

ve.ui.MWTransclusionDialog.js
* Replace regular text input with ve.ui.ParameterSearchWidget
* Fix uses of $(), this.frame.$$ is correct

ve.ui.Dialog.css
* Change rules for addParameterFieldset to make search widget auto-size vertically

ve.ui.Widget.css
* Add styles for ve.ui.MWParameterResultWidget

ve.ui.MWParameterSearchWidget.js, ve.ui.MWParameterResultWidget.js
* New classes
* Provides a way to search and select parameter for a template
* Displays parameter label, name, aliases and description

*.php
* Links to new files and messages

Change-Id: Ie5dbe8c44ce5d64c4b49b09517fb66cd30dd7304
2013-07-02 13:40:54 -07:00
jenkins-bot 88247dc93d Merge "doc: Fix incorrect documentation in template data model" 2013-07-02 20:05:23 +00:00
Timo Tijhof 1c0cca5460 doc: Fix incorrect documentation in template data model
Per the TemplateData spec:
* Most message values can be null, though they're never undefined.
* 'deprecated' is actually {boolean|string}.

For us:
* Make #isParameterDeprecated always return a boolean
* Add #getParameterDeprecationDescription to get the explanation
  of why a parameter is deprecated
* getParameterDescription doesn't need to pass 'null' for fallback
  since that's the default fallback.
  And it may return null or string.
* #getParameterSets returns an array of Set objects, not an array
  of strings (see spec for more information).

Change-Id: Iee788bc8fa6f0545085a0f154b77b8176f770dd2
2013-07-02 13:02:01 -07:00
Trevor Parscal 4fb94d9586 Select widget relative item fixes
Changes:

ve.ui.SelectWidget.js
* Make getRelativeSelectableItem properly loop around
* Replace confusing and broken getClosestSelectableItem with getFirstSelectableItem since that's the only use case we had for it anyway

ve.ui.PagedDialog.js, ve.ui.LookupInputWidget.js
* Update calls to getClosestSelectableItem to use new method

Change-Id: I2399d01a45c43d1ad663ed6c6de156e796065306
2013-07-01 16:05:08 -07:00
Trevor Parscal 30b56e7597 Improve async template data loading
Objective:

* Fix issue where async behavior of addTemplate caused templates to be added in the wrong order

Bonus:

* Get rid of special adders for transclusion parts, just construct objects outside and use addPart

Change-Id: Ibe579f033873446376d72d3bd1b9f92d9f361de5
2013-06-29 20:51:09 -07:00
Trevor Parscal de48c88ee3 Use template data for new templates and fix alias bug
Objectives:

* Use template data for templates added to a transclusion using
  the list controls
* Cache template data between different instances of the dialog
* Allow placeholders to be replaced with templates asynchronously
* Save http request and abort pending requests on close

Also:
* Fix breakage of (unused) method getParameterAliases
  (dont delete aliases)
* Remove unused method getTemplateSpec.

Bug: 49778
Change-Id: I391e51cb900ef5560455d6f3d4d2a8b99ed2b034
2013-06-28 23:34:58 +00:00
jenkins-bot 9a8cb712b1 Merge "Reference insertion, new and existing" 2013-06-28 01:13:53 +00:00
Trevor Parscal 0aac4c7e60 Reference insertion, new and existing
Objectives:

* Split reference dialog (at least for now) an edit and an insert dialog
* Add reference search widget for selecting an existing source, or
  choosing to add a new one
* Abstract reference names, don't allow editing them and generate them
  when needed
* When editing groups, move the internal item and update all references
  to it
* Resolve name conflicts when moving a reference to a new group by
  generating a new list key

Bonus:

* Add getNodeGroups method to internal list
* Add getUniqueListKey method to internal list
* Add destroy functionality to ce.node to release events and references

Bug: 49733
Change-Id: Ib244ff6ad9b4cee1decfd9b9e1d3d4e9cdcfb78c
2013-06-27 18:11:31 -07:00
jenkins-bot db38bd835f Merge "Automatically focus on the query input on insert media dialog open" 2013-06-28 00:47:05 +00:00
Trevor Parscal fb789c7ff7 Automatically focus on the query input on insert media dialog open
Change-Id: I03d44d09e3abfffb67adeba5ebe3a52451cc5be5
2013-06-28 00:43:34 +00:00
jenkins-bot 80b4a43d7d Merge "Don't compute the end offset to pass to insertMeta()" 2013-06-28 00:12:11 +00:00
Trevor Parscal ed7d42592f Move some of MediaSelectWidget into SearchWidget
Objectives:

* Break apart MediaSelectWidget for re-use
* Rename classes to follow search/result naming scheme

Change-Id: I65aab3dc3d41e31af13e2754e77b7dd185ac90f1
2013-06-27 23:51:09 +00:00
Roan Kattouw 70458e6e78 Don't compute the end offset to pass to insertMeta()
Omitting the offset causes insertMeta() to automatically use the
end offset, so we don't need to compute it in two places. The two
computations were also slightly different.

Change-Id: I55543fdd113a6a986899c093733191df948acb2e
2013-06-27 16:21:02 -07:00
Trevor Parscal 6b5310c562 ve.ui.ViewRegistry annihilation
Objectives:
* Associate models with tools, rather than dialogs and inspectors
* Move tool/model association utilities to ve.ui.ToolFactory
* Obliterate the view registry

Notes:

The only special case for leaving modelClasses definitions in place is
for the linkInspector. It uses these for selection expansion.
Because tools can now override the static canEditModel method, we can
dynamically evaluate a model, rather than be restricted to only
comparing classes. This will be useful for disabling editors for models
that are for some reason incomplete or otherwise broken and cannot be
safely edited.

Change-Id: I7adf254990112d90f1f808593a9111afc7a116b5
2013-06-26 16:52:10 -07:00
Inez Korczyński 537e431466 Set href attribute of newly inserted image to image title
I'm not sure if that's the long term solution, however for now it fixes bug 49844 and bug 49848.

Change-Id: I75dbbfdd248a6f5696252ef3a2d7ca6ede0fa156
2013-06-25 15:09:09 -07:00
Timo Tijhof 8a2c9431e6 Create ref list insertion tool
Fixes (follows-up I1b48ef5240, I6daff5c596):
* Invalid html passed to jQuery constructor.
* Use prop() instead of attr() for boolean values.
* Use append() instead of html() when appending nodes instead
  of parsing html.
* Rename shadowed variable name clash 'mw' to 'mwData'.
* Fix odd construction where we parse '{}' to create an empty
  object.
* Have ve.ce.MWReferenceListNode#update perform changes off-document
  in a detached tree.
* Fix deep property access that can fail. mwData is set to
  either JSON parse of data-mw attr or empty object.
  Accessing mwData.attrs.group needs to be guarded by whether
  mw.attrs is indeed set.
* Have `mw` and `about` attribtue in references list roundtrip
  (especially mw which can data we aren't editing/re-creating).
* Add missing 'refGroup' property to MWReferenceListNode's
  data element (similar to what MWReferenceNode already has).

Change-Id: I67e4f378ccd04e97361d8e58ae57db5353075756
2013-06-22 20:23:22 -07:00
jenkins-bot 3a3270486a Merge "Match data inserted from MWMediaInsertDialog with MWBlockImageNode" 2013-06-21 21:01:09 +00:00
jenkins-bot 014b6ed33a Merge changes I379bc2b3,I99acbd16
* changes:
  Straighten out variances in parent method invocation
  ve.ui.MWReferenceDialog: Clean up
2013-06-21 20:53:25 +00:00
jenkins-bot a344396b47 Merge "Remove format tools from mw reference dialog" 2013-06-21 20:13:33 +00:00
Inez Korczyński 50ec8c507a Match data inserted from MWMediaInsertDialog with MWBlockImageNode
Change-Id: I145beba19a8f69f6fd8c29302350c399b4c51c55
2013-06-21 12:36:14 -07:00
Timo Tijhof 2fb1a11a1a Straighten out variances in parent method invocation
Follows-up I99acbd1699:
* "Parent method" comment
* Remove redundant slice() call to convert arguments to array,
  native JavaScript methods that take array-like arguments such
  as Function#apply and Array#slice are both compatible with
  the Arguments objects, no need to convert it. Most invocations
  already did this right but a few were recently introduced again.
* Removed silly "Document dialog." descriptions.
* Removed a few redundant "@method" tags in the near vicinity
  of code I changed.
* Fixed function invocation to be either on one line or
  one parameter per line. Having all arguments on one line
  but the name + "(" looks confusing as it suggest there
  is only 1 parameter. Same as object literals:
  so:
  { foo: 1, bar }
  or:
  {
    foo: 1,
    bar: 2,
  }
  not:
  {
    foo: 1, bar: 2
  }

Change-Id: I379bc2b32603bcf90aba9b4cd0112e7f027d070e
2013-06-21 19:20:37 +00:00
Timo Tijhof 0c2e35593e ve.ui.MWReferenceDialog: Clean up
* Optimise initialisation by building the tree from the bottom up
  and applying the class last.
* Actually document the dialog. Documenting it as "Document dialog"
  is useless and confusing. If there is no documentation yet, leave it
  empty so it is included in jsduck's optional "no_doc" warning list.
* Remove the redundant "Call" prefix in the parent method description,
  we don't do this else where either.

Change-Id: I99acbd1699b2c99a2c9b58f34dc1e07bea58203d
2013-06-21 11:36:44 -07:00
Ed Sanders 4116742bcb Remove format tools from mw reference dialog
Because you can't put a heading in a reference.

Bug: 49715
Change-Id: Ic823a90398dafca1caf8fa4142d98133ab661d7c
2013-06-21 16:23:29 +01:00
Ed Sanders 7b1df21aeb Delete default sort key if set to empty string
Bug: 49724
Change-Id: Ie3caaf4811f87911444462f83d511c0cc46c0716
2013-06-21 11:48:20 +01:00
Ed Sanders 2c421258f8 Delete/don't insert transclusion if object is empty
The transclusion dialog lets you completely delete all templates
within it. If this happens we should delete the node completely, or
not insert it if it's a new instance.

Bug: 49831
Change-Id: Ic5d4fbf73f3d1be9cf877bc8b98096de9e98991a
2013-06-20 17:23:29 +01:00
Ed Sanders 8d2ba6effe Add resource attribute to newly created images
Bug: 49596
Change-Id: Ifbde0f5a4c8eb01df7b429abbb8ab0d4431c1c6f
2013-06-19 20:47:14 +00:00
Ed Sanders 1469575082 Fix inconsistencies and errors with Dialog onOpen/Close
Removed inherited (and often wrong) documentation, replaced direct
usage of onApplyButtonClick with more standard onClose handling,
and one case of calling the wrong parent method.

Change-Id: I86ed16860e996b42c141a6499eefb9084d759a72
2013-06-19 18:35:45 +00:00
Trevor Parscal ece74379de Transclusion editor template naming goodness
"Template" parts should be labeled with a normalized version of what you would actually write inside a set of curly brackets.

Change-Id: I4b9c541a01da86cb078d38012e5a9fead2fa233c
2013-06-18 18:33:58 -07:00
Inez Korczyński a886952563 Support for editing captions of block images
Bug: 38129
Change-Id: I02207e78f5c28eaccd9bc97a48baa78280192255
2013-06-18 17:57:10 -07:00
Trevor Parscal 4a7503ac10 Add templates from toolbar
Change-Id: I0aa21bed13d1dbc693c1db03eab903af55a1517a
2013-06-19 00:23:23 +00:00
Trevor Parscal 23b2da91fd Template and content adding
Objectives:

* Allow adding content or templates within a transclusion
* Add template placeholder to model and view which resolves to nothing
  when saving (thus disappearing if not resolved)

Changes:

*.php
* Add links to new messages and files

ve.ui.OutlineControlsWidget.js
* Organize controls into "adders" and "movers"

ve.ui.Widget.css
* Add styles for adders/movers sections of outline controls
* Make adders appear on hover to reduce clutter

ve.ui.Icons-*.css
* Add icon for "add item"

ve.ui.Dialog.css
* Add styles for add template fieldsets
* Make placeholder items in the outline italic

ve.ui.PagedDialog.js
* Pass adders config to outline controls

ve.ui.MWTransclusionDialog.js
* Add support for adding content and templates

ve.dm.MWTransclusionModel.js
* Add addPlaceholder method

ve.dm.MWTemplatePlaceholderModel.js
* New class, pretty much an empty part
* Using this makes the UI much easier to work with - no need to special
  case the outline control for new items
* Because it's not supported specifically in
  ve.dm.MWTransclusionModel.getPlainObject, it produces nothing and goes
  away naturally on apply

Change-Id: I3478560fb53ba2ccd3fb26bafb6a61e6415565eb
2013-06-18 23:37:44 +00:00
jenkins-bot 8e4177c960 Merge "Only undo on MWMetaDialog close if small stack is non-empty" 2013-06-18 19:34:15 +00:00
Roan Kattouw d5365d2b5a Correctly distinguish between Deferred and Promise
Deferred is read-write, Promise is read-only. Document and return
the correct types.

Change-Id: Icfd6efb07b222c73d49b97ddbfe6565b8542ad00
2013-06-18 10:56:56 -07:00
Ed Sanders 84fbd1db2c Only undo on MWMetaDialog close if small stack is non-empty
Added return boolean to ve.dm.Surface#breakpoint to indicate if
and transactions were pushed to the big stack. Use this value in
MWMetaDialog to see if we need to undo on close.

Added tests for ve.dm.Surface#breakpoint.

Bug: 49630
Change-Id: Ieb2e9e361afe057af93c4d374acc85df58bfb4c3
2013-06-18 16:55:03 +01:00
jenkins-bot 59bf9966b4 Merge "Fix logical conflicts from the transclusion merge." 2013-06-17 18:14:29 +00:00
Ed Sanders dcbea2328c Code style fix: @return -> @returns
Change-Id: I26daca6313bf09055af8f980ba0065782257fd54
2013-06-17 11:50:24 +01:00
Ed Sanders 642a84483e Fix logical conflicts from the transclusion merge.
Change-Id: Ic9d708cdba74c908d14839def5050c8825134c56
2013-06-17 10:36:47 +01:00
Trevor Parscal fc8c46dd74 Reference name and group editing
Objective:

* Allow editing reference groups and names in the reference dialog

Bonus:

* Modify attribute transaction builder to support multiple attribute
  changes in a single transaction

Changes:

ve.ui.MWReferenceDialog.js
* Load ref name and group from model
* Save ref name and group, if changed, to model

ve.ui.ListAction.js, ve.ui.Transaction.test.js, ve.ce.ResizableNode.js
* Update use of newFromAttributeChange to newFromAttributeChanges

ve.dm.SurfaceFragment.test.js
* Add test for new changeAttributes method

ve.dm.InternalList.js
* Missing new line at end of file

ve.dm.Transaction.js
* Change newFromAttributeChange to accept an list of attribute changes and
  produce a single transaction that applies one or more attribute changes
  at once

ve.dm.SurfaceFragment.js
* Fix bug in getCoveredNodes where the wrong mode name was being used
* Add changeAttributes method, which applies attributes to all covered
  nodes and allows filtering of which types of nodes the attributes are
  applied to

ve.dm.MWReferenceNode.js
* Actually write key and group back to DOM
* Separate onRoot functionality into addToInternalList so it can be called
  separately (similarly onUnroot/removeFromInternalList)

ve.ce.MWReferenceListNode.js
* Clone internal item CE node before appending to avoid rendering bug.

*.php
* Add links to messages and sort them

Change-Id: Ic4121e4fcfc09265d5863af6f078cdeb77926c8e
2013-06-14 15:29:56 -07:00
jenkins-bot 3e1e544e48 Merge "Add group field to reference dialog" 2013-06-14 22:24:38 +00:00
Trevor Parscal ac26f5fc69 Outline controls
Objectives:

* Allow reordering items in outline widgets using an outline control
  widget
* Use an outline control widget to reorder transclusion parts

Changes:

ve.ui.SelectWidget.js
* Emit add and remove events

ve.ui.OutlineItemWidget.js
* Add movable config options
* Add isMovable method

ve.ui.OutlineControlsWidget.js
* New class
* Displays move up/down buttons which are synchronized with an outline
  widget
* Doesn't actually move items (since an outline widget is probably
  data-driven) just emits events

ve.ui.Widget.css
* Add disabled style for icon button widgets
* Add styles for outline controls widget

ve.ui.Icons*.css
* Add missing icon styles

ve.ui.Dialog.css
* Add styles for outline and controls in editable paged dialogs

ve.ui.GroupElement.js
* Fix bug where items are insertions are in the wrong place when "moving"
  them

ve.ui.PagedDialog.js
* Add editable config option which shows outline controls under the
  outline
* Pass through movable config option when creating pages

ve.ui.MWTranclusionDialog.js
* Configure paged dialog outline as editable
* Add initialize method to connect outline controls widget events
* Make addPart method automatically add parameters when templates are
  added
* Add handler for outline controls move event which re-orders parts
* Make parts movable (params are automatically ordered, so they aren't
  movable)

ve.dm.MWTransclusionModel.js
* Add addPart method and use it within the addContent and addTemplate
  methods
* Fix documentation lies
* Add getPartFromId method

*.php
* Add links to new files and messages

Change-Id: I919d4c3e9b85d07a97a99c0b2e8739a859bdf2b1
2013-06-14 11:56:30 -07:00
Trevor Parscal acea97263b Add group field to reference dialog
Change-Id: Icf9ea348cd97bdb09ddf18769f53c01ea5a8b7ef
2013-06-14 10:30:03 -07:00
Trevor Parscal d3a2fab2c4 Transclusion editing
Objectives:

* Rename just about every use of "template" to "transclusion"
* Make a proper data structure for transclusions
* Abstract away template data
* Use more template data in the user interface
* Allow adding parameters
* Allow removing templates, parameters and content

Changes:

ve.ui.Dialog.css
* Add rule to place add param controls on a single line

ve.ui.MWTemplateDialogs.js
* Move template spec loading into transclusion class
* Add remove button for parts and parameters
* Add parameter adding form
* Use template data for labels and descriptions

ve.dm.*
* Add new transclusion data structures

*.php
* Add links to new files

*.*
* Rename all things "template" to "transclusion"

Bug: 39598
Bug: 49403
Change-Id: I3bcf924a3e179cb65f19e833277a39dfd3dad8bd
2013-06-12 16:39:13 -07:00
jenkins-bot 5f30bd9ed6 Merge "References dialog cleanup" 2013-06-12 19:25:59 +00:00
Trevor Parscal 8f9d2a607e Cleanup unused dialogs
Objectives:
* Remove unused dialogs

Changes:

*.js
* Remove unused stuff
*.php
* Cleanup links to files and messages

Change-Id: Ie670afa3aef1757151e385bf922464b85f662a7d
2013-06-12 11:49:44 -07:00
Trevor Parscal 2d044518bd References dialog cleanup
Objectives:

* Remove the whole toolbar subset thing, it's up to the creator of the
  subsurface to know what is and is now allowed, and the commands were
  still passing through unfiltered
* Correctly separate initialization from opening - fix issue where opening
  the reference dialog multiple times will keep adding more and more
  controls

Changes:

ve.init.Target.js
* Remove getToolbarSubset method

ve.ui.MWReferenceDialog.js
* Add toolbar tools and surface commands configs to reference dialog,
  including the things that are safe to use in references
* Move creation of field sets and reused controls to initialize method
  to prevent re-creation each time the dialog is opened
* Move static initialization stuff to the top near the other static stuff

Change-Id: I1c8577d17c506bac76e61b2b036655c59ef5a218
2013-06-12 11:27:49 -07:00
Trevor Parscal 0c935f69af Improve langlinks styling in meta dialog
Change-Id: I88d6d374d34dc08ecf46053cfc639c03ec23f8bf
2013-06-11 14:02:28 -07:00
jenkins-bot f41045c51e Merge "Paged dialog upgrades" 2013-06-11 19:46:24 +00:00
Trevor Parscal 252e9b3d12 Paged dialog upgrades
Objective:

* Add functionality to paged dialogs to work with the pages and select
  them programmatically

Changes:

ve.ui.PagedDialog.js
* Keep track of the current page name
* Add setPage method, which is can be used publicly and is also used
  internally when items in the outline are selected
* Add a page content config option which auto-appends to the inside of
  the page
* Add removePage method for removing pages by name
* Add getPageName method which gets the current page name

Change-Id: I2a2f0c329d274796b8c9e7572ecff8294f472f7f
2013-06-11 19:20:57 +00:00