Commit graph

32 commits

Author SHA1 Message Date
Roan Kattouw dfbd870e16 Fix copyDomElement issues
* Fix bug in MWTransclusionNode sometimes passing a NodeList rather
  than an array (caused an error because NodeLists can't be .map()ped)
* Use copyDomElements in ce.AlienNode as well

Change-Id: I11c6483d3c062047be80f75a3fac03f13bff9662
2013-06-18 23:37:09 +00:00
Inez Korczyński 394a40f27c Convert GeneratedContentNode into a mixing (instead of an abstract class).
Change-Id: I280d2a59326bd83357c7a09c3a188a70fbc75335
2013-05-29 14:54:57 -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 92f6688162 ve.ce.ProtectedNode
Objective:

Generalize the shield and phantom magic, so we can use it for pretty much
any node we like. Usually this will be used with generated content nodes,
but also with aliens (of course) and possible other stuff in the future.

Bonus:

Also fixes a bug in DM that would crash VE when you selected to the end
and hit backspace.

Changes:

*.php
* Added links to files

aliens.html
* Added attributes to aliens to make them aliens again

ve.ce.AlienNode.js
* Moved shield and phantom functionality to ve.ce.ProtectedNode

ve.ce.AlienNode.js, ve.ce.MWReferenceListNode.js,
ve.ce.MWReferenceNode.js, ve.ce.MWTemplateNode.js
* Mixed in ve.ce.ProtectedNode

ve.ce.Node.css
* Reorganized styles and updated class names
* Added simple light blue hover with outline (using inset box shadow) for
  protected nodes, same style as before for aliens

ve.ce.Surface.css
* Moved phantom styles to ve.ce.Node.css

ve.ce.BranchNode.js
* Moved call to setLive(false) to happen before detach() so that the
  surface object is still available and events can be disconnected

ve.ce.BranchNode.js, ve.ce.Document.js, ve.ce.js, ve.ce.Surface.js, ve.ce.SurfaceObserver.js
* Adjusted CSS class names

ve.ce.Node.js
* Moved shield template to ve.ce.ProtectedNode

ve.ce.ProtectedNode.js
* New class, mix into another class to protect it from editing

ve.ce.RelocatableNode.js
* Renamed temporary surface property to relocatingSurface to avoid
  confusion when debugging

ve.ce.Surface.js
* Moved phantom template to ve.ce.ProtectedNode

ve.dm.Transaction.js
* Fixed bug where most of the internal list was being deleted when the
  end of the document was selected and the user pressed backspace

Change-Id: I2468b16e1ba6785ad298e38190e33493135719c3
2013-05-07 00:08:48 +00: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
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
Christian Williams 4dfb137bc0 Move Phantoms onChange
Aliens now listen for surface model change events in order to
adjust the position of the phantoms.

Change-Id: I1e8bfba331a10678e9ca7e64b7818197237eb0a2
2013-04-30 10:55:59 -07:00
Roan Kattouw fdea620ffe Fix ce.AlienNode
Was completely broken after the dm.AlienNode changes

Change-Id: I3f5116d7dfbaa5889b7c5cac01d7341272749c58
2013-04-29 17:35:08 -07:00
Ed Sanders 6ad61d4ddb Add data model support for MediaWiki references
So far just read-only.

Bug: 39599
Change-Id: I6daff5c5969e5fdc871f8f346cf790b4302ae080
2013-04-23 10:17:42 +01:00
Ed Sanders 6dacc54954 Hybridise MWTemplateNode
* Create MWTemplateBlockNode & MWTemplateInlineNode (in ce and dm)
* Move Alien's 'isInline' code to ve.dm.Node.static.isHybridInline
* Move definition of ce.AlienBlock/InlineNode inside ce.Aline.js file
  to match dm.AlienBlock/InlineNode and MWTemplate
* Duplicate AlienBlock/Inline styles for templates
* Create test case for inline templates
* Count test cases in ve.dm.Converter.test.js automatically

Change-Id: Id9bc7f049ea974dd5e7f8b7a66080939e0948bbd
2013-04-14 02:34:18 +00:00
Ed Sanders 62c06d0253 Create GeneratedContentNode which can store rendered HTML in IV store
AlienNode is now a subclass of GCNode, but doesn't use the IV store yet.

Bug: 46571
Change-Id: If0717afdf557a2aa681d1bae3a6e98299631091a
2013-04-10 19:34:19 +01:00
Ed Sanders fdf30b1ac8 Store data in LinearData class with an index-value store for objects
Created an IndexValueStore class which can store any object and return
an integer index to its hash map.

Linear data is now stored in ve.dm.LinearData instances. Two subclasses
for element and meta data contain methods specific to those data types
(ElementLinearData and MetaLinearData).

The static methods in ve.dm.Document that inspected data at a given
offset are now instance methods of ve.dm.ElementLinearData.

AnnotationSets (which are no longer OrderedHashSets) have been moved
to /dm and also have to be instantiated with a pointer the store.

Bug: 46320
Change-Id: I249a5d48726093d1cb3e36351893f4bff85f52e2
2013-03-30 10:06:34 +00:00
Christian Williams 48f6403504 Typing support after Aliens and Entities for IE
When the cursor is between ce="false" elements and an editable next
sibling, IE often sets the anchorNode to be the ce="false" element
(or text node within). This change returns aliens to ce="false"
(abandoning the former true within true IE trick), and ensures that
the cursor is in the right place on keydown by programmatically
setting the selection.

Change-Id: I952488510f32b096b27e8e55d4afc7df930e0072
2013-03-28 14:49:09 -07:00
Christian Williams a8a5c74d8b Prevent adding content to aliens in IE
The phantoms prevent direct clicking into aliens,
and the recent selection changes prevent keyboard
navigation into aliens, but one issue remained.
Clicking to place the cursor just after an alien
would actually focus within the alien. Typing
modified the alien content. By nesting ce="true"
within ce="true", IE ceases this behavior.

Dragging state is now set to false when blurring
the document. The mouseup event sets dragging to
false, but the event is cancelled because blur
happens between mousedown and mouseup. Phantom
display logic uses on this property.

Change-Id: I162dea89838756fd28d63ff66cc4a5e5bda2873a
2013-03-26 16:01:13 -07:00
Trevor Parscal c2e1350fe0 Remove more periods
Tags don't need periods at the end, these are not complete sentences.

Change-Id: I8efa931862149e892d08b370e70aff8d86a6db7d
2013-03-20 22:55:50 +00:00
Inez Korczyński b99192e110 Do not display phantoms while dragging mouse over alien nodes.
It really does screw up selection in IE and does not look good in other supported browsers.

Change-Id: Ie190e86b25c3b253d4cf809594e74094275d0d57
2013-03-08 15:18:38 -08:00
Ed Sanders edcaaf9edc Use static.name once for ce and dm nodes
Add a static.name property to ce nodes and make sure both ce
and dm nodes always use the static.name property in constructors
and registration calls.

The result of this is that any given node type should now only
appear once in the code as a string.

Bug: 45701
Change-Id: Ibf31de16ab28ad58209c1443cd74f93dda278998
2013-03-07 17:19:39 -08:00
Trevor Parscal a5aeca3ff5 Major UI refactoring and improvements
Objective:

Refactor UI widgets, improve usability and accessibility of menus, general cleanup and style improvements.

Extras:
Fixed documentation in a few other files to make descriptions of jQuery event arguments more consistent, classes inherit correctly, and made use of the @cfg functionality in jsduck.

Changes:

.docs/config.json
* Added window, HTMLDocument, HTMLElement, DocumentFragment and XMLHttpRequest to externals, so jsduck doesn't throw warnings when they are used

demos/ve/index.php, modules/ve/test/index.php, VisualEditor.php
* Moved widgets above tools (since tools use widgets)

demos/ve/index.php
* Refactored widget initialization to use options
* Renamed variables to match widget names

ve.init.mw.ViewPageTarget.css
* Adjusted text sizes to make widgets work normally
* Added margins for buttons in toolbar (since button widgets
don't have any)
* Removed styles for init buttons (button widgets now)

ve.init.mw.ViewPageTarget.js
* Switched to using button widgets (involved moving things around
a bit)

ve.ui.LinkInspector.js, ve.ui.MWLinkInspector.js
* Renamed static property "inputWidget" to
"linkTargetInputWidget" to better reflect the required base class
for the properties value

icons.ai, check.png, check.svg
* Added "check" icon, used in menu right now to show which item
is selected

ve.ui.Icons-raster.css, ve.ui.Icons-vector.css
* Added check icon
* Removed :before pseudo selectors from most of the icon classes (not need by button tool anymore, makes them more reusable now)

ve.ui.Tool.css
* Adjusted drop down tool styles so menu appears below, instead
of on top, of the label
* Adjusted paragraph font size to better match actual content
* Updated class names to still work with menu widget changes
(items are their own widgets now)
* Updated selectors as per changes in the structure of button tools

ve.ui.Widget.css
* Added styles for buttons and menu items
* Adjusted menu styles

ve.ui.*ButtonTool.js
* Added config options argument passthrough

ve.ui.ButtonTool.js
* Moved var statement to the top inside constructor
* Switched to using "a" tag to get cross-browser :active support
* Added icon to inside of button to make icon styles more reusable
* Removed disabled support (now provided by widget parent class)

ve.ui.FormatDropDownTool.js
* Updated options initialization to construct menu item objects
* Modified handling of items to account for changes in menu and
item classes
* Optimized onUpdateState method a bit, adding early exit to
inner loop

ve.ui.ButtonTool.js, ve.ui.DropdownTool.js, ve.ui.Context.js,
ve.ui.Frame, ve.ui.Tool.js, ve.ui.Widget.js
* Added chain ability to non-getter methods

ve.ui.DropdownTool.js
* Removed items argument to constructor
* Updated code as per changes in menu class
* Fixed inconsistent naming of event handler methods
* Removed item event handling (now handled by items directly)
* Made use of this.$$ to ensure tool works in other frames

ve.ui.Tool.js
* Made tools inherit from widget
* Moved trigger registry event handler to a method

ve.ui.Context.js
* Switched from using menu to contain toolbar to a simple wrapper

ve.ui.js
* Added get$$ method, a convenience function for binding jQuery
to a specific document context

ve.ui.*Widget.js
* Switched to using a config options object instead of individual arguments
* Added options
* Factored out flags and labels into their own classes
* Refactored value setting methods for inputs

ve.ui.MenuWidget.js, ve.ui.MenuItemWidget.js
* Broke items out into their own classes
* Redesigned API
* Updated code that uses these classes
* Added support for keyboard interaction
* Made items flash when selected (delaying the hiding of the menu for 200ms)

ve.ui.LinkTargetInputWidget.js, ve.ui.MWLinkTargetInputWidget
* Refactored annotation setting methods

Change-Id: I7769bd5a5b79f1ab36f258ef9f2be583ca503ce6
2013-02-26 12:29:08 -08:00
Christian Williams 7e74f0aa70 (bug 43461) Hide Phantoms
This fixes a problem that phantoms would remain visible if moving the mouse quickly. Now binding to mousemove and also mouseout.

Change-Id: I4f5e3319038828f83b108e9f5a45f54ebfeb7027
2013-02-21 23:02:05 +00:00
James D. Forrester 82114467f1 Bump copyright notice year range to -2013 over -2012
199 files touched. Whee!

Change-Id: Id82ce4a32f833406db4a1cc585674f2bdb39ba0d
2013-02-19 15:37:34 -08:00
Catrope c0690634ee Hybrid-ify AlienBlock/AlienInline
Change-Id: Ieda8383c0c04df208f4c5f2aa7380427467049b7
2013-01-31 14:59:59 -08:00
Catrope 51f4b4be54 Convert node rules to static properties
Change-Id: If7d0159e984d9ccb4d5c31effb62bb9612260fda
2013-01-18 14:51:40 -08:00
jenkins-bot 8a8a731a34 Merge "Convert "var\t" to "var "" 2013-01-18 21:03:55 +00:00
Inez Korczyński 94642c797d Introduced method replacePhantoms in ve.ce.Surface in order to avoid accessing ve.ce.Surface local variable ($phantoms) from ve.ce.AlienNode
Change-Id: I9754d98175c7353f6db5306bc2ce35d6c57fdedb
2013-01-17 17:02:02 -08:00
Trevor Parscal 5cc93b288f Convert "var\t" to "var "
Partially reverts I45ee3fd5b2131131f3d10e05a1cc2f32a3e091cc (I read the diff backwards)

Change-Id: I5a638b8d13ed27a78586ff5507a421d7c49c9679
2013-01-17 16:55:09 -08:00
Trevor Parscal a30e4c325b Cleaned up paste target and surface styles
Resolves a TODO related to the paste target div.

VisualEditor.php
* Added link to ve.Surface.css

ve.Surface.js
* Cleaned up initialization of .ve-surface element
* Removed float clearing div (see ve.Surface.css)
* Removed paste div (moved to ve.ce.Surface)

ve.Surface.css
* Added rule which adds an ":after" element to handle clearing floats

ve.ce.Surface.js
* Cleaned up initialization of DOM elements
* Added paste target div
* Replaced paste element selectors with direct references to this.$pasteTarget

ve.ce.Surface.css
* Changed paste div styles to use a namespaced class instead of a generic ID

demos/ve/index.php
* Added link to ve.Surface.css

Change-Id: Ib93d45ac82ae643fc8e659f5a063c02a8ddacdde
2013-01-17 15:02:47 -08:00
Trevor Parscal 8d33a3de0d Major Documentation Cleanup
* Made method descriptions imperative: "Do this" rather than "Does this"
* Changed use of "this object" to "the object" in method documentation
* Added missing documentation
* Fixed incorrect documentation
* Fixed incorrect debug method names (as in those VeDmClassName tags we add to functions so they make sense when dumped into in the console)
* Normalized use of package names throughout
* Normalized class descriptions
* Removed incorrect @abstract tags
* Added missing @method tags
* Lots of other minor cleanup

Change-Id: I4ea66a2dd107613e2ea3a5f56ff54d675d72957e
2013-01-16 15:37:59 -08:00
jenkins-bot 879a07511a Merge "BugID 43076 - Fixes to alien and phantom corner cases" 2013-01-08 20:39:34 +00:00
Timo Tijhof b11bbed7a6 JSDuck: Generated code documentation!
See CODING.md for how to run it.

Mistakes fixed:
* Warning: Unknown type function
  -> Function
* Warning: Unknown type DOMElement
  -> HTMLElement
* Warning: Unknown type DOM Node
  -> HTMLElement
* Warning: Unknown type Integer
  -> Mixed
* Warning: Unknown type Command
  -> ve.Command
* Warning: Unknown type any
  -> number
* Warning: Unknown type ve.Transaction
  -> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
  -> ve.AnnotationSet
* Warning: Unknown type false
  -> boolean
* Warning: Unknown type ve.dm.AlienNode
  ve.dm doesn't have a generic AlienNode like ve.ce
  -> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
  -> ve.ce.Surface
* ve.example.lookupNode:
  -> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
  -> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
  -> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
  -> (removed)

Differences fixed:
* Variadic arguments are like @param {Type...} [name]
  instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
  to parse all /** blocks and fails to parse with all sorts of
   errors for "Global property", "Unnamed property", and
  "Duplicate property".
  Find: \/\*\*([^@]+)(@copyright)
  Replace: /*!$1$2
* Indented blocks are considered code examples.
  A few methods had documentation with numbered lists that were
  indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
  which requires lists to be separated from paragraphs by an
  empty line.
  And we should use `backticks` instead of {braces} for inline
  code in text paragraphs.
* Doc blocks for classes and their constructor have to be
  in the correct order (@constructor, @param, @return must be
  before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an  inline demo
  iframe, not code block. For that simply indent with spaces.
* @member means something else.
  Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
  is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
  where a hash stands for "instance member", so Foo.bar#quux,
  links to Foo.bar.prototype.quux (the is not supported, as
  "prototype" is considered an implementation detail, it only
  indexes class name and method name).
  If the magic linker doesn't work for some case, the
  verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
  values are supported, only @static @property can't be nested).
  We only have one case of this, which can be worked around by
  moving those in a new virtual class. The code is unaltered
  (only moved down so that it isn't with the scope of the main
  @class block). ve.dm.TransactionProcessor.processors.

New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
  inherited by subclasses. (+ @param, @return and @preventable).
  So ve.Node#event-attach is inherited to ve.dm.BreakNode,
  just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
  documentation causing a tree error. Documented those as a
  JSDuck singleton, which they but just weren't documented yet.
  NB: Members of @singleton don't need @static (if present,
  triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
  "@return {classname}" which is ambiguous (returns the same
  instance or another instance?), @chainable is specifically
  for "@return this". Creates proper labels in the generated
  HTML pages.

Removed:
* @mixin: (not to be confused with @mixins). Not supported by
  JSDuck. Every class is standalone anyway. Where needed marked
  them @class + @abstract instead.

Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-05 01:16:32 +01:00
Christian Williams b740e694b9 BugID 43076 - Fixes to alien and phantom corner cases
The {{coords}} template is correctly rendered as an inlineAlien, which previously did not have shields. However, the template has a deeply nested span that is positioned and floated. The fix is to shift shielding logic up to AlienNode (from AlienBlockNode) and to show phantoms on all shields (both block and inline). I've also updated the aliens demo to exhibit this corner case.

Change-Id: Ifce60c7762c0ead5c6fe29d6eabf601c1565cbfa
2012-12-21 15:20:15 -08:00
Timo Tijhof 1ba75b7ea9 The last ever mw.ext.ve jshint fixup
Change-Id: I262673214dd59e5bcaf4e0855e68728365b041fe
2012-11-26 22:36:07 +01:00
Christian Williams 1932e0907f Phantoms not vanishing on mouseout
If the mouse is moved too quickly, the phantoms have a tendency to stick. This change moves the event from phantom.mouseleave to surface.mousemove.

Change-Id: I2c7e7bdc838427d4355a6c0c13bafe3198636dbe
2012-11-16 11:32:59 -08:00