Commit graph

411 commits

Author SHA1 Message Date
jenkins-bot e2258af635 Merge "Make menus render on the very top of everything" 2013-05-28 13:01:21 +00:00
Trevor Parscal f16eb56a95 Make menus render on the very top of everything
Menus dismiss automatically on blur, so it's safe to make them on the very top of everything

Change-Id: I08bed7f7fbf108f1197c4b6c52ab5b5159e3c982
2013-05-28 13:59:05 +01:00
Trevor Parscal 3be13a7cbc Consistent use of mw in HTML classes, and data element and annotation types
MWfooBar or MWfoobar should be mwFooBar

Change-Id: I30f0ef05960c9df218ef6f1cb161ff6ccd529bc7
2013-05-28 13:49:56 +01:00
Trevor Parscal dd0b331a93 Re-fix pixel grid snapping on new text style icons
Trevor tweaked the pixel grid snapping on my previous commit
but it appears that introduced some errors as well. The horizontal
lines in underline-a and strikethrough-s no longer have integer
x-coordinates, and on underline-u the whole object is offset
by (0.166, 0.166).

Bug: 47780
Change-Id: I51f2605e7d8e2bab1d641f02244d5cd24f505676
2013-05-26 14:30:53 +02:00
jenkins-bot 23595970fe Merge "Remove duplicated code breaking the template dialog" 2013-05-26 12:09:55 +00:00
jenkins-bot cd637c6c35 Merge "Fix misspelled event handler" 2013-05-26 11:19:35 +00:00
jenkins-bot 6ddf7f3695 Merge "Rename 'langlinks' to 'languages'" 2013-05-26 09:19:45 +00:00
Catrope 2fd9454c67 Convert from DOS line endings (CRLF) to Unix ones (LF)
Change-Id: I66c2d6662c7512d5c55daf7a8a1876f00f8a7705
2013-05-25 23:51:21 +02:00
Ed Sanders dd0086468e Rename 'langlinks' to 'languages'
For internal naming consistency (e.g. with MWLanguageMetaItem).

Change-Id: Ifb53fa10da52e1ea87389b024b7c581b8dd730e6
2013-05-25 18:07:46 +02:00
jenkins-bot e51c896d29 Merge "Remove trailing whitespace everywhere" 2013-05-25 15:05:35 +00:00
Catrope dc961f6773 Remove trailing whitespace everywhere
Change-Id: I14f812bd31bd33d9fbd1148a474cbe7a3375d954
2013-05-25 15:04:11 +00:00
Trevor Parscal fb768ddcaf Restore window overlays
And use them for the category widget for it's popup.

Change-Id: I43db14c749400efa6a770343afbdfa16dd6bff30
2013-05-25 15:44:36 +02:00
jenkins-bot cddab2bafc Merge "Fix undefined i18n message in category popout" 2013-05-25 13:03:15 +00:00
Catrope 4f1ed682ed Fix misspelled event handler
Change-Id: I3f3091aad24d4bfdea08fbce1c331e8767866bbc
2013-05-25 14:53:33 +02:00
Catrope d13e09ea6d Fix undefined i18n message in category popout
Message was renamed earlier but this caller wasn't updated

Change-Id: I7ec37c6e0fd6fbbe766166704ea797c9ffd6684b
2013-05-25 14:49:27 +02:00
Catrope b70d6e1b45 Remove duplicated code breaking the template dialog
Change-Id: Ied5dc71106601ab354441c2d81507b616553c0d9
2013-05-25 14:23:29 +02:00
James D. Forrester c85e9ad161 Fix documentation for GridLayout to add a return type
Change-Id: I461160b01ae9fc4448904eeaf150570989d09d45
2013-05-25 12:48:17 +02:00
James D. Forrester 5819375022 Internationalisation for the metadata dialog
Change-Id: Iefb6d5c90583f0684cb9548d38b83048b43d3c81
2013-05-25 10:11:35 +00:00
Ed Sanders 6ca45aa2c8 Remove language page tab from MW meta dialog
MW meta is close to being moved out of experimental, but language
editing is not in line for the beta release.

Bug: 48561
Change-Id: Ie87a3c7dde2f29c3898c08d4cade5c0ba2f937dd
2013-05-24 20:26:14 +02:00
Ed Sanders ce86aa77c8 Add MW meta button to toolbar
Bug: 48561
Change-Id: Ibf63329a53bcd8043d46315239c19be4e681a18a
2013-05-24 15:54:50 +00:00
Ed Sanders 626a8c60f2 Make MW meta dialog experimental
Also remove the exception thrown when we try to add an non-existent
toolbar button, as it may just be experimental and not loaded.

Change-Id: I0a60421f45d7a3941c510defc60d1fbf9469e784
2013-05-24 17:53:06 +02:00
Ed Sanders 026af0d6c0 Remove unused toolbar group name.
Can't see why we'd need to style toolbar groups differently.

Change-Id: I0646b8cf37ab19e34a8ed2eb8558773365403610
2013-05-24 15:36:00 +00:00
Trevor Parscal 2e76271b4e The Great ve.ui.Surface refactor of 2013
Prologue:

Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.

Note to Roan and/or Ed:

Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.

Objectives:

* Make it possible to have multiple surfaces be instantiated, get along
  nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog

Approach:

* Move what's left of ve.Editor to ve.ui.Surface and essentially
  obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
  the top level one
* Resolve stacking order issues by removing the excessive use of z-index
  and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
  and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype

Bonus:

* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
  was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed

Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
2013-05-24 14:01:02 +02:00
Timo Tijhof 917fbc6f30 ve.ui.Toolbar: Clear the float before the toolbar
On wikis where certain "topicons" exist the toolbar showed a
weird blank space pushing the entire toolbar down and
ve-ui-toolbar-actions to the left.

Bug: 48734
Change-Id: Ic5f73ac1eb8c41b891dd1c67b71795cb6c456141
2013-05-23 01:07:51 +02:00
jenkins-bot f8e36324c0 Merge "Clicking link button while link inspector is already open throws error" 2013-05-22 19:57:14 +00:00
jenkins-bot df1e82bcf9 Merge "ve.ui.MWTemplateDialog: Implement templatedata API fetch" 2013-05-22 18:03:35 +00:00
Timo Tijhof 70694b2bbf MWLinkTargetInputWidget: Normalise value before matching
Don't suggest a "new page" (redlink) for values that are
strictly different but the same as a suggestion according
to mw.Title (e.g. input "foo" with an existing "Foo" page
should not suggest a redlink to inexistant page "foo").

Bug: 48476
Change-Id: I66f5fc56554984af58d6223dc6cd76b3ab9940bd
2013-05-22 00:20:41 +02:00
Ed Sanders 38f199d505 Clicking link button while link inspector is already open throws error
Bug: 48549
Change-Id: Ia97b6e3d862e02f5c55cac3f490fd8f26052027a
2013-05-21 16:26:45 +01:00
Timo Tijhof e7af635e88 ve.ui.MWTemplateDialog: Implement templatedata API fetch
Fetch
* Added basic name expansion logic since bug 48663 is not yet
  resolved in Parsoid.
* Fetch info from template data API.

Clean up (follows-up 97157a1c, de203cb8, 718db58)
* Remove redundant initialize method.
* Pass the entire target object to #getTemplateData
  because `target.wt` is *not* the template name.
* Reorganise #createPage to be more logical and rename
  to #createParamPage.
* Add todo comments for things currently missing.
* Implement error handling of promise to prevent UI from
  going stale if the promise is not resolved.
* Fix documentation in ve.ui.MWCategoryInputWidget.

Change-Id: Ie0114a81eead86d7a3b3e3a7a5b10d25c457b524
2013-05-20 23:50:19 -07:00
jenkins-bot 3b85e30f6a Merge "Icons for underline, strike & super/subscript buttons" 2013-05-20 23:58:23 +00:00
Ed Sanders 40e45d176a Icons for underline, strike & super/subscript buttons
Bug: 47780
Change-Id: I2f317e1dda2c2e2fceac401768c732dae02e83ce
2013-05-20 16:53:04 -07:00
Catrope 9ff6737f4c Refactor HTML attribute preservation
Rather than using namespaced linmod attributes, store the preserved
HTML attributes in the .htmlAttributes property of the linear model
element, in a nested structure to allow for easier treatment of child
nodes. Also added attribute order preservation by storing attributes
as an object plus an array of keys.

ve.ce.Node.js:
* Remove html/* attribute synchronization. Doesn't make sense any more
  because these things aren't in the attributes object any more. I don't
  think it ever made sense because these attributes were never supposed
  to be changed anyway.

ve.ce.View.js:
* Replace renderAttributes() with a simple wrapper around
  renderHtmlAttributeList()

ve.dm.Converter.js:
* Add buildHtmlAttributeList() and renderHtmlAttributes() for building
  and rendering HTML attribute lists

ve.dm.Model.js:
* Add getter for .htmlAttributes

ve.dm.Node.js:
* Drop .htmlAttributes on clone, and remove logic dropping html/*

ve.ui.MWCategoryWidget.js:
* Remove html/0/about hack, was already unnecessary and now doesn't
  work any more

tests/:
* UPDATE ALL THE TESTS

Change-Id: I620573afd70d36ade6b80413075b6e1f4a435abe
2013-05-17 20:57:33 -07:00
jenkins-bot 4f14fddd2b Merge "ve.ui.PopupWidget visibility fixes" 2013-05-17 05:52:35 +00:00
Trevor Parscal 3a99b99876 ve.ui.PopupWidget visibility fixes
Objective:

* Context popup would stop opening sometimes "mysteriously" which ended
  up having to do with the automatic closing on blur functionality
  added to popups for use in the category popup widget
* Mousedown event canceling was being applied a little too widely, and
  was causing popup widgets to not allow child elements to be focused
  (unless they contained an iframe, like an inspector)

Changes:

ve.ui.Context.js
* Make use of the popup's show and hide methods within the inspector

ve.ui.MWCategoryPopupWidget.js
* Override autoClose option for category popup widgets

ve.ui.PopupWidget.js
* Add autoClose option to popup widgets
* Move event handler to the top of the methods (convention)
* Only bind blur event if autoClose is enabled
* Inline the getFocusedChild method

Change-Id: I22aedb5fbd51b327ea7ce2ecdd6123e79cbebb9c
2013-05-17 05:49:16 +00:00
Inez Korczyński 97157a1c1c Use promise pattern inside MWTemplateDialog in order to download TemplateData (currently just mocked) asynchronously.
Change-Id: Ib23521cf40a80cc82872de82d3935414ef385d21
2013-05-16 20:37:15 -07:00
jenkins-bot 0eb2581b64 Merge "ve.ui.Context: Add embedding feature" 2013-05-16 18:26:39 +00:00
Trevor Parscal 55b5f30edb ve.ui.Context: Add embedding feature
Objectives:

* Make the context menu display in the top right corner of the currently
  focused inspectable node (if there is one)
* Prevent clicking on anything to do with the toolbar or popup from doing
  anything at all, ever

Bonus:

* While we are using the clever feature in jQuery's on method which allows
  passing boolean false to cancel the event - may as well do that in
  ve.ui.Dialog as well

Changes:

ve.ui.FocusableNode
* Add ability to specify the focusable element so that dimensions can be
  derived from it

ve.ce.Surface
* Add quotes to object keys

ve.ui.MediaDialog
* Change association from being MW specific to handling images in general

ve.ui.Context
* Add embedded styles for context
* Add embedded mode, which is triggered when the context is a single
  focusable node, and the node is large enough to fit the context
  reasonably

ve.ui.Dialog
* Inline mousedown handler

ve.ui.Toolbar, ve.ui.PopupWidget
* Cancel stray mousedown events

Change-Id: I4b25d33f64b4bcb8a3ecfd7e9728f54a2d4886f3
2013-05-16 11:23:59 -07:00
Inez Korczyński a191073d72 Create and commit transaction after attributes of the template are changed and applied.
Change-Id: I4a1acdadcd1486ddd5dafcfc794c9b3b93e92592
2013-05-15 17:49:27 -07:00
Inez Korczyński 1b4b6663c3 Introduce createPage method in ve.ui.MWTemplateDialog and even use it!
Change-Id: I7b063a9380742e157a4c7128c1654abcf3ad8c6f
2013-05-15 16:22:12 -07:00
Inez Korczyński ba5c4f104d Build TemplateDialog based on parameters that are passed to template
(instead of TemplateData as before).

Change-Id: I50b0e6ef1936c4b56f40fa73bd42b03587bdf979
2013-05-15 22:47:59 +00:00
Christian Williams f238683341 Content for Template Dialog
Initial commit of page content.

Change-Id: Iffdf4f4179c6f3b04611d4bd9548e7cf23188856
2013-05-15 15:13:38 -07:00
jenkins-bot 943301f2c9 Merge "Multiline option for ve.ui.TextInputWidget.js" 2013-05-15 21:47:25 +00:00
jenkins-bot e21f8edb60 Merge "Process example template data and add pages to PagedDialog based on it." 2013-05-15 21:44:07 +00:00
jenkins-bot e75f63f279 Merge "Added clearPages method to ve.ui.PagedDialog." 2013-05-15 21:41:34 +00:00
Trevor Parscal 96e49858fa Multiline option for ve.ui.TextInputWidget.js
Objective:

* Add multiline option to text input widget which uses a text area instead of a text input

Changes:

ve.ui.Widget.css
* Add text area support for styles otherwise only targeting input elements

ve.ui.InputWidget.js
* Initialize input element using a method, so it can be fully customized (like making a text area or select input
* Use val() to set the initial value, using jQuery's abstraction around inputs of various types

ve.ui.TextInputWidget.js
* Add multiline option which uses a text area instead of an input

Change-Id: I1bf17c8c76b7f1708c57ee5e95160c071ddd00e9
2013-05-15 14:41:22 -07:00
Inez Korczyński de203cb871 Process example template data and add pages to PagedDialog based on it.
Change-Id: I34ee42e66df26000842f9b1540a577b2621f8839
2013-05-15 14:36:44 -07:00
Inez Korczyński 3895a3ea11 Added clearPages method to ve.ui.PagedDialog.
Change-Id: Ie55f727f649b2dcd4189489c7baa9f524aa5d1c7
2013-05-15 14:31:20 -07:00
jenkins-bot bd0d61c143 Merge "Fix for default sort key crash" 2013-05-15 21:10:57 +00:00
Trevor Parscal 79df2232a5 Fix for default sort key crash
The existing default sort key was being cached when the dialog was
constructed, but on the 2nd time launching it the reference was broken.
This change gets rid of the caching and always grabs a fresh copy when
we need one.

Also, the flag indicating the default sort key has changed wasn't being
reset properly.

Change-Id: I8fb3b088f25212b8c542df65bb5a248550ff6f27
2013-05-15 21:04:10 +00:00
Christian Williams 3f6e127423 Pages in template dialog
Just a starting point for Inez to loop.

Change-Id: I6d418ba955f0904d34b474c984eef7f97be257e9
2013-05-15 13:39:34 -07:00
jenkins-bot f888b79056 Merge "Add level option to ve.ui.OutlineItemWidget" 2013-05-15 20:35:06 +00:00
Trevor Parscal 55f28eecce Add level option to ve.ui.OutlineItemWidget
Objective:

* Add indentation feature to outline items

Changes:

ve.ui.PagedDialog.js
* Pass level argument through addPage method

ve.ui.Widget.css
* Add styles for non-zero levels of outline items

ve.ui.OutlineItemWidget.js
* Add missing config documentation for icon option
* Add level option, with getLevel/setLevel methods
* Add statically configurable number of levels and level class

Change-Id: Ie24761c64918fdc6cd28070b3cf56743c6288970
2013-05-15 12:54:19 -07:00
Trevor Parscal 231a50f2b6 Implement ve.ui.MWTemplateDialog
Objective:

* Add button to launch template dialog
* Add template dialog

Changes;

*.php
* Add messages and links to files

ve.ce.Node.css
* Make inline templates display as inline-block to contain their
  contents (allowing shields to work properly)

ve.ui.MWTemplateDialog.js
* New empty dialog for templates

ve.ui.MWTemplateButtonTool.js
* New template button, appears in context and launches dialog

Change-Id: I9174ed7c9012522246a6defc859276bf36763f5b
2013-05-15 19:36:18 +00:00
Trevor Parscal a56e795f58 ve.Editor
Objectives:

* Split ve.Surface into ve.Editor and ve.ui.Surface
* Move actions, triggers and commands to ve.ui
* Move toolbar wrapping, floating, shadow and actions functionality to configurable options of ve.ui.Toolbar
* Make ve.ce.Surface and ve.ui.Surface inherit ve.Element and use this.$$ for iframe friendliness
* Make the toolbar separately initialized so it's possible to have a surface without one, as well as control where the toolbar is

Some change notes:

VisualEditor.php
* Added standalone module for mediawiki integrated unit testing

ve.ce.Surface.js
* Remove requirement to pass in an attached container to construct object
* Inherit ve.Element and use this.$$ instead of $
* Make getSelectionRect iframe friendly
* Move most of the initialize stuff to a new initialize method to be called after the surface is attached to the DOM

ve.init.mw.ViewPageTarget.js
* Merge toolbar functions into setup/teardown methods
* Add toolbar manually (since it's not added by the surface anymore)

ve.init.sa.Target.js
* Update new init procedure for editor, surface and toolbar separately
* Move toolbar floating stuff to ve.Toolbar

Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
2013-05-15 10:39:12 -07:00
Trevor Parscal c2defc9783 ve.Element refactor
Objectives:

* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element

Changes:

ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors

*.php
* Updated file link

ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName

ve.ce.Surface.js
* Removed static initialization (not needed)

ve.dm.Model.js, ve.ui.Window.js
* Added missing docs

ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements

ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$

ve.ui.js
* Move get$$ to ve.Element

ve.js
* Add auto-init of static properties to mixinClass

Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
2013-05-14 19:47:32 +00:00
Trevor Parscal 67a2613a12 Reference dialog
Objective:

Add a basic (empty) dialog for mediawiki references. Editor to follow.

Changes:

*.php
* Added file links and messages

ve.ui.MWMetaDialog.js
* Moved initialize method to the top (for consistent ordering)

ve.ui.MWReferenceDialog.js
* New class, basic empty dialog for references

ve.ui.LinkInspector.js, ve.ui.MWLinkInspector.js, ve.ui.MediaButtonTool.js
* Cleanup documentation
* Whitespace

icons.ai, reference.png, reference.svg
* Switch to reference icon being 3 books on a shelf

ve.ui.MWReferenceButtonTool.js
* New class, basic dialog button for references

Change-Id: Ia4e30e9239fa1e3b28c0a1ef1ca0a6515a8103ef
2013-05-13 13:10:59 -07:00
Trevor Parscal 8409d16f0f Fieldsets and default sort keys
Objective:
* Add default sort key field to meta dialog
* Replace PagePanelLayout with a generic panel containing one or more FieldsetLayout elements

Changes:

*.php
* Added/removed file links

ve.dm.MWDefaultSortMetaItem.js
* Added getContent method

ve.dm.MetaItem.js
* Added replaceWith method

ve.dm.MetaList.js
* Allow insertion at the end by omitting offset and index

ve.dm.MWMetaDialog.js
* Added default sort key field
* Put category and default sort fields inside fieldsets
* Added loading/saving default sort key

ve.ui.PagedLayout.js
* Changed class used for pages to generic panel layout

ve.ui.PagePanelLayout
* Moved title/icon stuff to field set

ve.ui.FieldsetLayout.js
* New class, adds fieldset with legend

ve.ui.StackPanelLayout.js
* Moved up to the layouts directory

ve.ui.Dialog.css
* Moved style for paged panel from layout stylesheet

ve.ui.Layout.css
* Added styles for fieldsets

ve.ui.Widget.css
* Adjusted margins of input label widgets

ve.ui.MWCategoryWidget.js, ve.ui.MWCategoryPopupWidget.js
* Added setDefaultSortKey method

Change-Id: I979f5e3f08a688790c9f54086206ed1999af13ea
2013-05-10 16:46:08 -07:00
Trevor Parscal e888d7b985 Category UI improvements
Objectives:
* Ensure items don't get moved to the end when their sort-key is edited
* Add placeholder text and pending styling to input
* Auto-expand input to the end of the line
* Make the minimum input width smaller

Changes:

ve.ui.MWMetaDialog.js
* Added calls to fitInput on initialize
* Fixed sort key update and insert handlers to maintain item position when updating

ve.ui.GroupElement.js
* Added index argument to addItems, allowing items to be inserted at a specific location

ve.ui.PagePanelLayout.js
* Fixed CSS class name

ve.ui.StackPanelLayout.js, ve.ui.MenuWidget.js, ve.ui.SelectWidget.js
* Passed index argument through to group element

ve.ui.PanelLayout.js
* Fixed overflow direction for scrolling option

ve.ui.Inspector.css
* Moved border-box properties to text input widget class
* Set input widget within inspectors to be 100% by default

ve.ui.Layout.css
* Updated CSS class name
* Whitespace fixes

ve.ui.Widget.css
* Made text input widgets's wrapper default to 20em wide and the input inside it be 100%, using border-box to ensure proper sizing
* Adjusted category list item and input styles to make input appear more like a category item
* Whitespace fixes

ve.ui.MWCategoryInputWidget.js
* Made category input widget inherit text input widget, rather than just input widget

ve.ui.MWCategoryWidget.js
* Replaced group functionality by mixing in group element
* Added fitInput, which automatically make the input fill the rest of the line or take up the entire next line depending on how much space is left

VisualEditor.i18n.php
* Adjusted placeholder text for category input

Change-Id: I79a18a7b849804027473084a42c36133fdacad57
2013-05-10 00:19:46 +00:00
Ed Sanders cced110c3e Mo' vectors (mo' problems)
Serve vectors to any browser which supports them, instead
of just high dpi devices.

Bug: 48148
Change-Id: Iafe8cd290fb195369776f51a96b6de4a51577b89
2013-05-09 11:22:32 +01:00
Ed Sanders 830de420e1 Code style fixes
* "function(" -> "function ("
* "{String}" -> "{string}"
* collapse unintentional double spaces

Change-Id: I3ce3f02d1e31d4797b44e04d28457dec363be296
2013-05-06 12:36:52 +01:00
jenkins-bot d4d8e9075d Merge "EventEmitter API cleanup" 2013-05-02 23:48:30 +00:00
Trevor Parscal 7233ea8f1b EventEmitter API cleanup
The EventEmitter API we inherited from Node.js and then bastardized was
getting awkward and cumbersome. The number of uses of ve.bind was getting
out of control, and removing events meant caching the bound method in a
property. Many of the "features" of EventEmitter wasn't even being used,
some causing overhead, others just causing bloat. This change cleans up
how EventEmitter is used throughout the codebase.

The new event emitter API includes:
* emit - identical to the previous API, no longer throws an error if you
  emit error without a handler
* once - identical to the previous API, still introduces a wrapper* on -
  compatible with the previous API but has some new features
* off - identical to removeListener in the previous API
* connect - very similar to addListenerMethods but doesn't wrap callbacks
  in closures anymore
* disconnect - new, basically the opposite of addListenerMethods

Another change that is made in this commit is mixing in rather than
inheriting from EventEmitter.

Finally, there are changes throughout the codebase anywhere
connect/disconnect could be used.

Change-Id: Ic3085d39172a8a719ce7f036690f673e59848d3a
2013-05-02 15:05:59 -07:00
Moriel Schottlender 29f5630957 RTL fix for VE's link widget
The purpose is to flip the direction of the input inside
the link widget for RTL wikis, but flip it again to LTR
if the user inserts an external URL. This is my first VE
fix, I tried to follow conventions and avoid touching the
parent objects that are unrelated to URLs.

Bug: 47717
Change-Id: Ic13b9c3b155ce2979298cac9518c7419b9d45bac
2013-05-02 20:43:46 +00:00
jenkins-bot 713fa24d10 Merge changes I5eafaa48,Ia8f23a37,I17534d67,If5ed1b64
* changes:
  Category editing
  Remove singular adding for ve.ui.GroupElement
  Implement ve.dm.Surface#truncateUndoStack
  ve.ui.LookupWidget
2013-04-30 18:34:26 +00:00
jenkins-bot d8d61126ea Merge "Fix range translation for surface fragments" 2013-04-30 17:58:39 +00:00
Trevor Parscal 718db58fd5 Category editing
Modifications:

VisualEditor.php
* Added links to new widgets

VisualEditor.i18n.php
* Added placeholder text for category input

ve.ui.Widget.css
* Added styles for new widgets

New:

ve.ui.MWMetaDialog.js
* Create category widget with categories from dm.
* Listen to metaList for insert and remove events
** insert / remove bound methods to be improved upon additional meta groups
* Add listeners to mwCategoryWidget for new categories and updates

ve.ui.MWCategoryWidget.js
* Top-level category editing widget

ve.ui.MWCategoryItemWidget.js
* Items within a category widget

ve.ui.MWCategoryInputWidget.js
* Input for new categories, handles menu and API requests

ve.ui.MWCategoryPopupWidget.js
* Mini-inspector for a category item

Bug: 39597
Change-Id: I5eafaa484a1924a566d3a1ee1d869293089d0ecf
2013-04-30 17:50:31 +00:00
Trevor Parscal 52529d790b Remove singular adding for ve.ui.GroupElement
By making the API for adding/removing/clearing always plural, it greatly
simplifies the interfaces and reduces function call overhead in most
situations.

Change-Id: Ia8f23a373a01a8f6d5081587a591563e4f25ea42
2013-04-30 17:50:22 +00:00
Trevor Parscal cd6b54a4e8 ve.ui.LookupWidget
Refactoring of externally sourced suggestions for text inputs.

*.php
* Added links to new file

ve.ui.InputLabelWidget.js
* Changed to focus input element, not wrapper div

ve.ui.InputWidget.js
* Fixed incorrect documentation

ve.ui.LookupInputWidget.js
* New mixing that abstracts placing a menu of options below a text input
  and filling it with data from an external source

ve.ui.MenuWidget.js
* Fixed to get reference to input element, no wrapper div

ve.ui.MWLinkTargetInputWidget.js
* Moved pending and lookup functionality to mixing
* Implemented menu population using only matching pages, rather than a
  combination of that and page existence checks (fewer API calls)

ve.ui.TextInputMenuWidget.js
* Added configurable container to render underneath, rather than assuming
  this.input.$
* Added auto-position-on-window-resize functionality
* Fixed frame position correction to ensure that it only is used when the
  overlay is in a different frame from the container to position
  underneath

ve.ui.TextInputWidget.js
* Added placeholder text feature

Change-Id: If5ed1b64fd15982807691ce8bb0362970633108a
2013-04-30 10:47:32 -07:00
Ed Sanders d4eef1b879 Fix range translation for surface fragments
Remove all manual changes to SF ranges as these are not
undoable. Instead change translate range to default to
outer expand and build functionality around that behaviour
never changing.

As translate range is always outer I don't think we need to
check for start and end crossing over?

Added more undo tests to assert these selections are maintained
properly, and added the test case to 'update' for when and undo
point is overwritten.

Insert content now results in a selection over the inserted
content. Most usages were expecting this anyway and were
followed up with an adjustRange(-length,0) which is no longer
necessary.

Noticed that the link inspector case was never being triggered
as word boundary was always expanding to at least one char (mainly
for Hanzi selection). This doesn't make much sense as single
spaces get auto selected so removed this functionality.

Split collapseRange out into collapseRangeToStart and
collapseRangeToEnd as this may be required to get the old
behaviour (range moves to end after insert).

Change-Id: I3dc0b4d00d37bad1ca3076a69b41c5f0b3fa0570
2013-04-30 17:08:15 +01:00
jenkins-bot 6cd91d6c34 Merge "Get back to where you once belonged" 2013-04-30 04:32:59 +00:00
jenkins-bot 00b1458099 Merge "ve.ce.Surface.getSelectionRect() might return null" 2013-04-30 02:11:55 +00:00
jenkins-bot 11056cf07b Merge "Fixed a comment" 2013-04-30 02:11:29 +00:00
Trevor Parscal 4ee9e1f28d Get back to where you once belonged
The toolbar has a high z-index when being floated, it doesn't need one
otherwise. This was causing an issue where the Vector actions drop-down
menu was being obscured.

Change-Id: I3c0ff7c4cf3b4a6c3d94f00ef56d7f299aeb6020
2013-04-29 22:59:46 +00:00
Trevor Parscal 27287188ac Fixed docs
Wrong param type.
<pre> tags quoted to avoid jsduck warning.

Change-Id: Ieb9b5527ea69c8f02a175d29c1534290f85ba032
2013-04-29 21:58:51 +00:00
MatmaRex ee241223ae ve.ce.Surface.getSelectionRect() might return null
Protect against this. Also fix misnesting of updateDimensions()
function's body.

Change-Id: I5040d46d51bd59bf4d2fd7d4d8853c8675420ad0
2013-04-29 15:27:31 +02:00
MatmaRex 6e4f86bf47 Fixed a comment
Change-Id: I97917f70d42820105f6cdbaa3a1724cee3d6731b
2013-04-29 14:29:50 +02:00
Trevor Parscal 6a068e7d83 UI Refactor
Changed:

VisualEditor.i18n.php
* Updated Link inspector i18n messages

ve.ui.MetaDialog.js -> ve.ui.PagedDialog
* Moved paging functionality into Paged dialog

ve.ui.EditorPanelLayout -> ve.ui.PagePanelLayout.js
* Renamed from EditorPanelLayout to work nicely with the concept of
  stacks and pages

ve.ui.GroupElement.js
* Added addItem method and change addItems to use it

ve.ui.Dialog.css
* Updated classname as per refactor of meta dialog

ve.ui.StackPanelLayout.js
* Set currentItem property on showItem
* In addItems method, show currentItem with class method
** rather display block on element

ve.ui.Layout.css
* Make editorPanel layout 100% in width.

ve.ui.Widget.css
* Added CategoryWidget and CategoryPopup styles
* Other adjustments

ve.ui.PopupWidget.js
* Added auto-close on loss of focus
* Made friendly with being initialized inside a frame

ve.ui.MWLinkTargetInputWidget.js
* Mixin ve.ui.PendingInputWidget and remove pending methods
* Prevent querying on spaces
* Reintroduce i18n messages for menu sections

ve.ui.MenuWidget.js
* Update cases of $input config property to input

New:

ve.ui.PagedDialog.js
* Refactored base-class for mwMeta dialog (and probably other dialogs
  too)
* Abstracts adding and accessing pages

ve.ui.PendingInputWidget.js
* Moved pushPending and popPending methods into pending class

Change-Id: I29bcd92b7b5641941a4e98e65b2a56424a5263ff
2013-04-26 21:18:13 +00:00
Trevor Parscal a64ceb74e0 Fix link inspector undefined madness
Reuse the existing internal link annotation builder instead of using a
constructor directly, and incorrectly (it's meant to be passed an
element, not an attributes object)

Change-Id: I4cda6a9c3442cb10ebbc0844630fedba403adc91
2013-04-25 19:43:39 +00:00
Trevor Parscal 3f3c87ce24 Link inspector fixes
ve.ce.Node.css
* Added prefixes for use of box-sizing

ve.ui.MWLinkInspector.js
* Whitespace

ve.ui.Inspector.css
* Corrected input width, always 100% wide now by using box-sizing

ve.ui.DialogButtonTool.js, ve.ui.Context.js
* Updated use of getViewsForNode

ve.ui.ViewRegistry.js
* Added inheritance-based prioritization for matching views with annotations and nodes

Bug: 47413

Change-Id: I286a28002c1691e58bbd7de04ed08cceb8b3bb07
2013-04-24 18:29:55 -07:00
Inez Korczyński 6b7d62e4a4 Rename MWImageNode to MWInlineImageNode (get ready for adding MWBlockImageNode soon)
Change-Id: I617e2a17cb6fbd11e486c2981e361ae931ac1870
2013-04-24 16:49:07 -07:00
jenkins-bot c762dced66 Merge "Add menu icon" 2013-04-23 19:32:40 +00:00
Trevor Parscal 3bcac07aab Fix ve.ui.get$$'s handling of jQuery selection
Turns out, the context property of a jQuery selection isn't always
there.

For example:

$( 'body' ).context === document
$( '<div>' ).context === undefined

Even if you later attach that div, so long as you have the old
selection around, the cached `context` property won't magically be
updated. This makes sense (although it's poorly documented in the
jQuery API) but causes issues for us, and pretty much makes the
context property useless.

Instead, we can just use the standard `ownerDocument` property,
available on all DOM elements.

This change also add support for passing in a DOM element directly, in
addition to the existing support of passing jQuery or Document objects
in.

Change-Id: Ib8a31b74f2a4f455b1318be9f5c7805a2a193c79
2013-04-22 20:36:42 +00:00
Trevor Parscal 66afffa685 Add menu icon
Also fix reference icon class name

Change-Id: I3ace9644c74687047995f8c896d4133bbb59ede2
2013-04-22 10:51:10 -07:00
Ed Sanders 8b09dd7650 The resurrection
By removing the transaction listeners from surface fragments we
no longer have to make sure they are always manually destroyed.

In order to retain the functionality of having fragments update
with transactions elsewhere we keep a pointer to a place in the
new complete history stack in the surface. The complete history
stack records all transactions, even undone ones.

Whenever getRange is called we replay all transactions in the
complete history (in the correct order) since the fragment was
last updated.

Also in this commit:
* Updated Format/IndentationAction to test undo(). This increases
  coverage of surface fragment behaviour.
* .range is always accessed by .getRange now, although as an
  optimisation we can use the noCopy mode when we a sure the
  returned range will not be modified.
* Added undo test to .update (previously .onTransact)

Bug: 47343
Change-Id: I9e9818da1baa8319a3002f6d74fd1aad6732a8f5
2013-04-22 12:50:23 +01:00
Trevor Parscal 1878c7c5a8 Allow node relocation
*.php
* Added links to new file

ve.ce.ImageNode.js
* Added relocatable node mixin
* Added $image reference to the actual img element, so if it's wrapped
  in a sub class the functionality in the parent class  doesn't break.
* Moved drag start event handling to relocatable node
* Removed drag end binding, not needed.

ve.ce.MWImageNode.js
* Moved addClass to initialization section of constructor.
* Copied 'view' data prop from image element to keep stuff working after
  the wrapping.

ve.ce.Node.css
* Switched to default (arrow) cursor for images.

ve.ce.RelocatableNode.js
* New mixing for nodes that should be relocatable
* Added implementation for drag start, which tells the surface to allow
  dragging this node.

ve.ce.Surface.js
* Added relocation support, which is used by relocatable nodes
* Split onDocumentDragDrop into onDocumentDragOver and onDocumentDrop
  which now have implementations that support relocation of nodes

ve.ui.Context.js
* Added relocation tracking to prevent context being shown while
  relocating

Change-Id: I8703adfb707af2c3224431afc3418356ac2c686c
2013-04-19 12:07:18 -07:00
jenkins-bot 832137de50 Merge "Initialize iframe for dialog with correct doctype" 2013-04-19 18:53:12 +00:00
Inez Korczyński c5218b9fef Initialize iframe for dialog with correct doctype
Change-Id: I93bf12754b5c4d99e117c822d287015765651eb3
2013-04-18 19:49:09 -07:00
Trevor Parscal bb232a0ee7 Frame initialization exceptions
Don't call initialize inside the try-catch, it ends up sending exceptions thrown inside that method to /dev/null.

Change-Id: I8e0945f35c639ec156ee9a163b86fddfaed0ea7b
2013-04-18 16:52:03 -07:00
Trevor Parscal bf254f44da UI "Views" refactor
Objective:

Make it possible for inspectors to inspect nodes or annotations, rather
than only annotations. Meanwhile, also make it possible for dialogs to
edit an annotation.

Strategy:

Switch from using type patterns to associate inspectors with annotations
to using arrays of classes, similar to how dialogs already work.
Introduce a view registry which provides lookups for relationships
between models and views. This is more centralized and less repetitive
than implement matching functions for both annotations and nodes in both
the dialog and inspector factories.

Changes:

*.php
* Added links to new file

ve.AnnotationAction.js
* Removed unused parameter to filter annotations using a string or regexp

ve.dm.AnnotationSet.js
* Switched from property/value arguments to callbacks

ve.ui.*(Dialog|Inspector).js
* Replaced type patterns with class lists
* Added class to view registry

ve.ui.*Tool.js, ve.ui.Context.js
* Updated model/view relationship lookup

ve.ui.*Factory.js
* Removed overly-specific lookup functions

ve.ui.Inspector.js
* Removed typePattern property
* Updated model/view relationship lookup

ve.ui.ViewRegistry.js
* New class!
* Migrated node and annotation lookup functions from factories

Change-Id: Ic2bbcf072fdd87e5ce8a03fe1ae3e6d8d50e2593
2013-04-18 15:53:50 -07:00
jenkins-bot f2276214cd Merge "ve.ui.SelectWidget: Keep track of mouse down" 2013-04-18 22:43:29 +00:00
jenkins-bot bed8e8a17a Merge "Simplified iframe initialization" 2013-04-18 22:41:40 +00:00
Trevor Parscal 2419f7638c Death and/or destruction
So. It turns out that the design of SurfaceFragment is a little -
shall we say - wonky.

One of the best things about ve.dm.SurfaceFragment is its magical
ability to retain the intention of its range, even as transactions
are being processed. This ability is granted by each fragment
listening to the surface's change event, and responding by using
translateRange for each transaction that gets processed. Surface
fragments also have these clever methods that allow you to get a
fragment based on another, which makes adjusting the range easy to do
inline without having to manually store multiple fragments or
modifying the original.

This sounded good, and we seemed to all be convinced it was well
designed. But if you add a console.log( 'hello' ); to the first line
of ve.dm.SurfaceFragment.prototype.onTransact, and then start using
the bold tool on various selections of text, you will find that there
may indeed be a flaw. What you will probably realize is that the
number of times that particular line of code is being called is
disturbingly large, and increases each time you do just about anything
in the editor. What's going on? How did we get here? Read on…

It turns out that fragments are immortal. We create them, they listen
to the surface's transact event, we are done with them, but the
surface keeps on emitting events to the now long forgotten about
fragments. They continue to build up over time, never go out of scope,
and bloat the hell out of our program.

The same ended up being true of toolbars - and each time the context
menu fired up a new one the old one was left in limbo, still
responding to events, still taking up memory, but not being visible to
the user.

All of this immortality was causing strange and difficult to track
down problems. This patch fixes this by introducing a destroy method.
This method unbinds events, allowing the object to finally fall out of
scope and die - and more importantly stop receiving notifications of
changes.

This is a hack, but Ed will no doubt get this situation sorted out
properly by making fragments lazy-evaluate their selections by only
storing an identifier of the most recent transaction they were based
on, see bug 47343.

Change-Id: I18bb986001a44732a7871b9d79dc3015eedfb168
2013-04-18 13:56:20 -07:00
Trevor Parscal 8f6b042eaf ve.ui.SelectWidget: Keep track of mouse down
This helps with some differences between browsers, specifically Firefox,
where e.which would be "1" even if the mouse button was not pressed.

Change-Id: Ia88449c2bc84073d903dc702bb586127618d86f2
2013-04-17 11:40:16 +00:00
Trevor Parscal 17c9aadf8f Simplified iframe initialization
Rather than attach a function to the window and trigger it from a script
tag in the document body, it's much simpler to just use the references
we already have to execute the code immediately and directly.

This also fixes issues in Firefox where reaching in and adding functions
to the window wasn't allowed.

Change-Id: If7a84edf6ae4549b19ce36a3477311c46dbadea7
2013-04-16 12:59:11 -07:00
Trevor Parscal 504a1bafd0 Filter our zero-coverage updateState nodes
Added filter for nodes being passed to update state event - this
ensures that nodes are not being included with zero-length coverage, a
side effect of how selectNodes handles the virtual boundaries of text
nodes.

Change-Id: I6362114b57469b1108da11f94dc345a2bcdfc7cd
2013-04-14 02:50:01 +00:00
Trevor Parscal 8f3e6f152f Dialog button changes
ve.ui.MetaDialog.js
* Added scrolling to outline panel

ve.ui.css
* Added reusable animation keyframes

ve.ui.Dialog.css
* Changed dialog head style
* Changed dialog cancel button to close icon button
* Added animation of dialog opening
* Increased min-height of dialog to always show a little content

ve.ui.Icons-*.css
* Added close icon (not sure why it was missing)

ve.ui.Window.css
* Moved head padding out of window and into implementations of window

ve.ui.Dialog.js
* Moved apply button to footer
* Renamed cancel button to close button
* Overrode close method with triggers a closing animation and then calls the parent close method after an animation is complete
* Added classes to close and apply buttons to make styling less ambiguous
* Converted cancel button (now the close button) to an icon button

ve.ui.Window.js
* Added footer to dialog

VisualEditor*.php
* Added close message

Change-Id: Iededbc54b287328b3047b05efad6ca3cc152caa5
2013-04-10 12:34:52 -07:00
Trevor Parscal 7ac32bc0f6 No more confusing boolean argument for closing windows
window.close( true ) thing sucked, and was being named and used
inconsistently throughout the code.

The new approach uses an action string, so it looks more like
window.close( 'accept' ) or window.close( 'back' ). This makes it easy
to steer the behavior at any point in the window close code path.

Most importantly for the link inspector, this allows us to now restore
the previous selection when the user presses escape or clicks the back
button, while still moving the cursor to the end and collapsing the
selection upon pressing enter and allowing removal by clicking the
trash can.

This commit also cleans some things up, like the various ways we have
to close an inspector which all seem useless because we wouldn't want
to just randomly close an inspector on someone. An inspector should
be closed only when the user has dealt with it.

ve.InspectorAction.js
* Removed close method

ve.ui.LinkInspector.js
* Updated documentation
* Passing action to parent method
* Updated logic to deal with change from "remove" to "action" argument
* Added selection restauration on "back" action

ve.ui.Context.js
* Added action to call to close
* Removed closeInspector method

ve.ui.Dialog.js
* Moved event handlers to the top
* Added actions to calls to close
* Added click block event handler to prevent focus changes

ve.ui.Inspector.js
* Added actions to calls to close
* Added storing of previous selection - this is different from
  initialSelection because it's captured before the selection is
  modified by setup

ve.ui.Window.js
* Updated documentation
* Updated argument name from "remove" to "action"

ve.ui.WindowSet.js
* Updated documentation
* Removed auto-close, replaced it with error if trying to open a window
  when another is already open
* Removed close method

Change-Id: Ie8f72504177dd6ba169fdddbb776fd5397b831c4
2013-04-10 12:31:49 -07:00
jenkins-bot 3160e8c838 Merge "Fix 404 on iframe styles by standardizing get and set modules methods." 2013-04-10 17:25:58 +00:00
Rob Moen 1db76c392f Fix 404 on iframe styles by standardizing get and set modules methods.
Change-Id: Iebc2a9fc7db00d661f685c28dbc345fb561bb15e
2013-04-10 10:18:39 -07:00
jenkins-bot 46c079f281 Merge "Added icon for reference, switched from category to tag icons" 2013-04-10 00:10:40 +00:00