Commit graph

3014 commits

Author SHA1 Message Date
jenkins-bot 4d41a23b61 Merge "Store data in LinearData class with an index-value store for objects" 2013-03-30 10:17:39 +00: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
Ed Sanders 5b168bdbad Fix MWImageNode dimensions and implement toDomElements
Using element.height was returning 0 if the attribute was empty
when in fact what we mean to store is null (i.e. auto height).

This takes care of the writing of attributes in CE as jQuery
ignores an attribute-set command if the value is null.

Also in this commit I've implemented a basic toDomElements
that outputs the original HTML (code copied from AlienNode).
This stops the code from throwing an exception but will
eventually need to be rewritten to rebuild the HTML from
the attributes stored in the DM.

Bug: 56336
Change-Id: I297a1d0a07e9ebf9d0110fb1cdf266f8415f25b7
2013-03-29 12:51:43 +00:00
jenkins-bot 7b9618ebc2 Merge "Typing support after Aliens and Entities for IE" 2013-03-29 02:19:15 +00:00
Inez Korczyński 836fa82155 Make sure that rangy is initialized only once and that it is initialized before it is used.
Change-Id: Ia318908d34e82ae97ae1bf662ad9fc5dc28bf6ba
2013-03-28 14:50:43 -07: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
jenkins-bot f6c50d70a5 Merge "Fix for live preview in jsduck" 2013-03-28 21:11:25 +00:00
Trevor Parscal 3dfbda60d1 Fix for live preview in jsduck
This got out of sync, pretty simple fix.

Change-Id: Ib21e63399f184de1b182f20b9d35307e2c73a0df
2013-03-28 13:26:15 -07:00
Timo Tijhof c53685b865 Doc: Replace "@property @type {Type}" with "@property {Type}".
Also removed a few redundant headings in class documentation
comments. There is already an @class and it looks a bit odd  in
the generated pages:
 <h2>TextString</h2>
 <p>TextString</p>
 <p>This class provides a ...</p>

Change-Id: Ie311c6993ed02e79272dbde71f6a1bc252ef3037
2013-03-28 21:21:56 +01:00
jenkins-bot 9c9675f778 Merge "Fix: focus method should be called on jQuery object not on ve.ui.TextInputWidget object itself." 2013-03-28 20:11:37 +00:00
Inez Korczyński 497b6947e5 Fix: focus method should be called on jQuery object not on ve.ui.TextInputWidget object itself.
Change-Id: I70b6553245b68e6de465eb3434bce4c4228f1764
2013-03-28 13:09:27 -07:00
Inez Korczyński 21e4fdc014 Added support for displaying inline images.
Change-Id: Ieecbca8ed864585e8eaa99598d4bfdb5ac9bfec7
2013-03-28 13:05:57 -07:00
Trevor Parscal a2e59f7c86 Stack panel, element mixins, cleanup
*.php
* Updated links to files

ve.ui.MetaDialog
* Added stack panel that now contains category and language editor panels
* Attached outline widget to stack panel

ve.ui.FlaggableWidget -> ve.ui.FlaggableElement
* Moved to elements

ve.ui.GroupWidget -> ve.ui.GroupElement
* Moved to elements
* Removed invalid event documentation

ve.ui.LabledWidget -> ve.ui.LabledElement
* Moved to elements

ve.ui.StackPanelLayout.js
* New class, mutually exclusive panel container

ve.ui.TitledPanelLayout
* Remvoed, using labeled element instead

ve.ui.Element.css
* Added for elements
* Moved label style here, from widget styles

*.css, ve.ui.ButtonWidget.js, ve.ui.InputLabelWidget, ve.ui.OptionWidget, ve.ui.SelectWidget
* Adjusted class names to reflect widget -> element migration

Change-Id: I32f504c844dba7aae1b286eef06ca046627bdc8d
2013-03-28 12:40:01 -07:00
jenkins-bot 0a8697808e Merge "Removed static "overrides", which were only setting defaults" 2013-03-27 18:34:37 +00:00
jenkins-bot ff38fcd4ef Merge "New popup widget" 2013-03-27 18:30:37 +00:00
Trevor Parscal d25a04b35b New popup widget
This will make the popup with callout functionality easy to reuse elsewhere - in the first case most likely the popup menus for the category widget.

*.php
* Added links to the new widget

ve.ui.Context.css, ve.ui.Widget.css
* Moved styles to the widget stylesheet

ve.ui.Context.js, ve.ui.PopupWidget
* Moved "popup" specific stuff to the new popup widget

Change-Id: I823c6e2c5e1ec11088898e9621d93e983c3b76f3
2013-03-27 11:27:25 -07:00
jenkins-bot 686d4ddc71 Merge "Added layouts and fixed up dialog styling issues" 2013-03-27 18:15:05 +00:00
Inez Korczyński 47691cf586 Initialize rangy once and globally instead of doing it in constructor of every surface.
Change-Id: I06e331021ff8af63e76ceccc005319fc9ce96619
2013-03-27 11:05:29 -07:00
jenkins-bot b20de29fe8 Merge "Small cleanup in CE" 2013-03-27 18:02:06 +00:00
Inez Korczyński fe0fdcd67c Small cleanup in CE
Better comments for:
* ve.ce.Document.getRelativeOffset,
* ve.ce.Document.getSiblingWordBoundary.
Convert ve.ce.Surface.getSelectionRect to a static method.
Moved getNodeAndOffset from ve.ce.Surface to ve.ce.Document.

Change-Id: Ic00221fa463205d04c9b52150c0dd15904493b1e
2013-03-27 10:50:02 -07:00
Ed Sanders 4988efd35e UnicodeJS library to implement Unicode standards
Initially just with a Wordbreak module to implement Unicode standard
on 'Default Word Boundaries'. Due to it's standaloneability this has
been written as a separate library. Non-BMP characters are currently
not supported.

Bug: 44085
Change-Id: Ieafa070076f4c36855684f6bc179667e28af2c25
2013-03-27 17:44:22 +00:00
Trevor Parscal 63567654a2 Link inspector suggestion sections
ve.ui.Widget.css
* Made sections use a default cursor - they aren't clickable so they shouldn't appear to be

Change-Id: Id74288040080c18b8595f2903239bc82e8bc1ab2
2013-03-26 16:57:30 -07:00
Trevor Parscal 482db3763c Removed static "overrides", which were only setting defaults
The default widget element type is already 'div', no need to override that.

Change-Id: Ief6ee9a7a2e2384ea26276483a5d8e33ab70dacf
2013-03-26 16:51:35 -07:00
jenkins-bot a5dcf7cd1b Merge "Prevent adding content to aliens in IE" 2013-03-26 23:04:41 +00: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 168fcec387 Added layouts and fixed up dialog styling issues
ve.ui.Dialog.css
* Fix issue where the use of margin auto on the outer dialog wrapper
  would expose parts of the underlying content - this is resolved by
  making the outer wrapper cover the whole screen and making the
  window frame use margin auto

ve.ui.Icons*.css
* Added missing settings icon rule

ve.ui.Layout.css
* Added styles for editor panel

ve.ui.Window.css
* Removed default height, setting it specifically in inspector now

ve.ui.EditorPanelLayout.js
* New layout, adds a title and icon above the content

ve.ui.TitledEditorLayout.js
* Similar to labeled widget, but for panels

ve.ui.MetaDialog.js
* Using settings icon now
* Switched to using a specific layout - still hard-coded for
  categories

ve.ui.Frame.js
* Modified style loader to guarantee order of style rules, no matter
  what order they load in

*.php
* Moved layouts to be included after widgets so they can use widgets
* Added links to new layouts

Change-Id: I7ff5f5f095460fd4f6cf841f4182bfb92bf034da
2013-03-26 20:52:35 +00:00
Catrope 7e65e3becf Add insert and remove events to MetaList
These events occur when an item is inserted or removed by onTransact(),
so both for insertions/removals done through the MetaList mutators and
insertions/removals done by any other means.

We have to gather these events and batch them up because we have to allow
offset translation and index recomputation to occur first (otherwise
calling .getOffset() and .getIndex() on inserted items doesn't work).

Change-Id: I74a9a21398eca4e9afd7148171af20d439cf7ebd
2013-03-26 15:09:52 +00:00
jenkins-bot 34cc39bf9f Merge changes I4b62a310,I7c9f22a1
* changes:
  Add mutators in MetaList
  Move .commit()/.rollback() from TransactionProcessor to Document
2013-03-26 14:31:44 +00:00
jenkins-bot 8d207b43e7 Merge "Add support for slugs in ve.ce.Document.prototype.getRelativeOffset" 2013-03-25 23:47:03 +00:00
jenkins-bot 14132aeb4e Merge "Docs: Primitive -> primitive." 2013-03-25 23:46:07 +00:00
Inez Korczyński 2108030cfd Add support for slugs in ve.ce.Document.prototype.getRelativeOffset
Also removed ve.ce.Surface.prototype.adjustCursor because it is not being used anymore

Change-Id: Ib7dd8f4f6eaa688995d33247600875a45fc5a602
2013-03-25 16:43:57 -07:00
jenkins-bot e3fd32923f Merge "Cleanup in ve.ce.Surface." 2013-03-25 23:32:32 +00:00
Inez Korczyński 0339a92284 Cleanup in ve.ce.Surface.
Mostly by extracting parts of onDocumentKeyDown method into separated methods: handleLeftOrRightArrowKey and handleUpOrDownArrowKey

Change-Id: If19abf2218bc667c729f7bf388074061cec3031c
2013-03-25 16:23:39 -07:00
jenkins-bot 6178b3bf56 Merge "Fix documentation to place @emits in the correct place" 2013-03-25 22:22:01 +00:00
Catrope 8baf7a1df9 Add mutators in MetaList
Add .insertMeta() and .removeMeta() methods to insert and remove
metadata through the meta list. For convenience, there is also a
.remove() method in MetaItem that wraps around removeMeta().

Also rename insertItem() and removeItem() to addInsertedItem() and
deleteRemovedItem() to avoid confusion, and make the MetaList
constructor take a dm.Surface rather than a document so we can call
change().

Change-Id: I4b62a3109404cfd56f5de68938e1db908b03e678
2013-03-25 21:12:20 +00:00
Ed Sanders 1cec447b59 Fix documentation to place @emits in the correct place
@emits, @returns, @chainable & @throws should always appear
in that order, according to CODING.md.

Change-Id: I9b192e018a028a8b32730c288cc4e3108800fb58
2013-03-25 21:06:05 +00:00
Catrope 1176bf9677 Move .commit()/.rollback() from TransactionProcessor to Document
Previously these were static functions in TransactionProcessor
which instantiated a TP called .process() on it. These are now
methods of ve.dm.Document.

Also moved the emission of the 'transact' event on the document from
TransactionProcessor to Document itself, and moved the tests asserting
double application is protected against from TP to Document (because
the corresponding code moved as well).

Change-Id: I7c9f22a14accaf0ba1f70d5aa4f0573bb7e677d0
2013-03-25 21:03:44 +00:00
jenkins-bot 47dee2a685 Merge "Small cleanup/refactoring to getSiblingWordBoundary" 2013-03-25 20:48:06 +00:00
Inez Korczyński 92ea103153 Small cleanup/refactoring to getSiblingWordBoundary
CPU time + memory optimization + make inexpensive comparison first

Change-Id: I7f504f741b4d90201e40bbc40ae2e88fe0db2e33
2013-03-25 20:38:24 +00:00
Timo Tijhof b19a2010d8 Docs: Primitive -> primitive.
Only one left, thought there were more.

Change-Id: Ifdf490854ea138daf01319ed58cdba4182481c85
2013-03-25 18:55:08 +01:00
jenkins-bot a75b463794 Merge "Add MW-specific meta items for categories and language links" 2013-03-23 21:52:31 +00:00
Inez Korczyński 3b8cdfe2a0 Programmatic handling for selection (arrow up and arrow down only).
This is only for IE and only for backwards selection.

Change-Id: Ifdcd2d404d1018057b5ba16753fc964b07738879
2013-03-22 17:06:41 -07:00
jenkins-bot 59e9c3f65e Merge "Programmatic handling for selection (arrow left and arrow right only)." 2013-03-22 19:34:48 +00:00
jenkins-bot f34407b31a Merge "Introduce helper functions." 2013-03-22 19:28:34 +00:00
Inez Korczyński 8b2d3caebb Programmatic handling for selection (arrow left and arrow right only).
Change-Id: I6ccbecdeafbe189dbe052e4e9ce8f926dad14aea
2013-03-22 12:24:31 -07:00
jenkins-bot e45df0df11 Merge "Introduce method ve.ce.Document.getRelativeOffset." 2013-03-22 19:18:28 +00:00
Inez Korczyński 5b9964878d Introduce helper functions.
* ve.ce.isLeftOrRightArrowKey
* ve.ce.isUpOrDownArrowKey
* ve.ce.isArrowKey

Change-Id: Id9fd7975e98085d01e545d1d0fc6086a06648031
2013-03-22 11:43:18 -07:00
Inez Korczyński c8819742eb Introduce method ve.ce.Document.getRelativeOffset.
Change-Id: If2b8675b4604fc5ec1430497f2d55b2f3584a453
2013-03-22 11:41:26 -07:00
Timo Tijhof 573aea477d ve.init.mw.ViewPageTarget: Fix exception in deactivate().
This caused the page to stay in a dimmed state because it would
throw an exception before tearDownSurface() and showPageContent()
would be called.

Bug: 46456
Change-Id: I91ad2b110c2c523a4bb367407e3f33a953328ab4
2013-03-22 19:32:56 +01:00
Inez Korczyński c636ae138d Cleanup to ve.dm.SurfaceFragment.wordBoundaryPattern
Change-Id: I475fc0c97d5af646f51fe779c4b3136ddd3f83d0
2013-03-21 15:24:23 -07:00
Inez Korczyński 8199f2a1c1 Removed ve.dm.Document.getIEStyleWordBoundary method.
Added ve.ce.Document.getSiblingWordBoundary method.

Change-Id: I44b53273429aede5be10f39c2ee2f70d96cdc6fb
2013-03-21 14:46:13 -07:00
Catrope b39576b433 Add MW-specific meta items for categories and language links
Also rename MWMetaItem to MWAlienMetaItem, because that's what it
really is.

Change-Id: I70695bfa3b8449c936a63f7b2a248b90c49dcea1
2013-03-21 12:18:52 -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
Trevor Parscal fb22e4df50 Group, Select, Option, Outline and MenuSection widgets
Objective: Refactor menu widgets so that the majority of their code can be reused, and then add an outline widget which shares the same base classes.

ve.ui.Dialog.css
* Make dialog a fixed width and have a minimum and maximum height while always being centered in the window.
* Add style for the outline panel
* Add border below the title
* Move font-size adjustment to child elements to preserve layout scale

ve.ui.Inspector.css
* Make inspectors fade in when being opened (will happen after the size transition is complete)
* Add initial size for inspector to prevent the default size of the unfinished contents from making it too large while loading

ve.ui.Tool.css
* Update classes according to changes in labeled widgets

ve.ui.Widget.css
* Add display: block to widget labels to support use of autoEllipsis on them
* Update classes according to changes in labeled widgets
* Add styles for new select, option and outline item widgets
* Remove unused group and items classes for menu widgets (which are now subclasses of the select widget and no longer have grouping built-in)

ve.ui.Window.css.js
* Moved selection disabling rules up to the head to prevent selection drawing around the title

ve.ui.GroupWidget.js
* New widget that manages "items", allowing getting, adding, removing and clearing

ve.ui.MenuSectionItemWidget.js
* New widget that can be used inside a menu to create an unselectable, unhighlightable item that describes a section of the menu

ve.ui.OptionWidget.js
* New widget to be used with select widgets, provides select and highlight functionality

ve.ui.OutlineItemWidget.js
* New widget to be used with outline widgets, extends option and adds support for an icon to be rendered to the left of the label

ve.ui.OutlineWidget.js
* New widget that provides a vertically stacked list of mutually exclusive options, extends select

ve.ui.SelectWidget.js
* New widget that implements most of what menu once did, only now it also handles all the events for it's child elements internally

ve.ui.MetaDialog.js
* Hacked in support for an outline widget in the outline pane
* Added classes for styling purposes

ve.ui.FormatDropDownTool.js
* Modified call to menu item constructor as per changes therein
* Reorganized options config to make construction simpler
* Changed to setLabel after selecting the item to prevent the label from being changed to the wrong value as a side-effect of setting the item

ve.ui.DropDownTool.js
* Added $$ in config for menu widget - just in case later on we use a drop-down inside of a frame
* Using jQuery .text() method to propagate the selected item's text to the label rather than keeping around a plain text copy of the label in a property

ve.ui.Context.js
* Improve context/inspector behavior in regards to initial sizing

ve.ui.js
* Added context property to $$ returned by get$$ so it's easy to get the document object (for event binding) wherever you have a $$

ve.ui.Window.js
* Fixed incorrect case for boolean type in comment
* Added getFrame method

ve.ui.ButtonWidget.js
* Removed extra class being set on label

ve.ui.LabeledWidget.js
* Added class on label
* Added fitLabel method which uses autoEllipsis internally

ve.ui.MenuItemWidget.js
* Moved nearly all of the implementation to option so it could be reused

ve.ui.Menu.js
* Moved most of the implementation to select and group

ve.ui.MWLinkTargetInputWidget
* Prevent aborting and re-querying if the value hasn't actually changed
* Updated populateMenu method as per changes in menu class

*.php
* Added links to new files

Change-Id: I2271b5cc0554973b13cfbff94caf16901c02caa5
2013-03-20 22:55:32 +00:00
Trevor Parscal db6cede4d4 Fix transition animation between context menu/inspector
This removes the "grow from nothing" effect (which may have been a
little overkill) but fixes the situation where the inspector is open
and you click to a new location and it moves to the new location and
then transitions down to the menu (which looks bad).

Change-Id: I19d27da6fea7c36965c83aa73836b1bc870c9bcc
2013-03-20 15:43:32 -07:00
jenkins-bot 0cf80096fe Merge "Document and clean up events in all the things" 2013-03-20 16:59:29 +00:00
Timo Tijhof 4e64187beb Document and clean up events in all the things
* Document them consistently between secetions Inheritance and
  Static Properties under their own (new) section Events.
* Removed any quotes or brackets around the event name in existing
  @emit annotations
  Search: @emit.*['"{}(){}]
* For every call to this.emit() anywhere, added @emits.
* Fixed all warnings for references to undefined events
  (introduced as a result of the previous point).
  Event handler parameter documented based on the emit() call
  and actual handlers using the event. Usually the latter is
  more elaborate.
* Extend coverage of jQuery as needed
  (copied from mwcore/maintenance/jsduck/external.js
  written by me, hereby implicitly and explicitly released under MIT).

Specifics
* ve.ce.Surface#onContentChange: Fixed type of range from Object to ve.Range.
* ve.ce.SurfaceObserver#poll: Fix syntax for code from {} to `backticks`.
* ve.ui.Toolbar#onContextChange: Doesn't actually emit "clearState" event.
  Removed #onClearState in Tool, ButtonTool and DropdownTool.

Bug: 45872
Change-Id: Id879aa769b2c72d86a0322e75dddeb868211ce28
2013-03-20 09:58:27 -07:00
jenkins-bot a559d0d180 Merge "Create basic tests for AnnotationSet." 2013-03-20 16:35:15 +00:00
Inez Korczyński 1c62a63bbf Introducing method ve.dm.Document.getIEStyleWordBoundary
This is just a prototype - if it will be as useful as I expect
then it will get refactored (and probably get a better name +
location).

Change-Id: Ice1a2bd7d498d9d8438c35239216f01bd3db1826
2013-03-20 16:32:38 +00:00
Ed Sanders 62dacf17be Minor comment and licence fixes
Change-Id: I7fb632e56291b136e3e7b83ea6335474f1521d05
2013-03-19 20:54:01 +00:00
Ed Sanders 62318f9c61 Create basic tests for AnnotationSet.
Also covers methods inherited from OrderedHashSet.

Bug: 46320
Change-Id: I632e4cf1b87312179a9ce52df0d590ff42f56325
2013-03-19 15:31:50 +00:00
jenkins-bot 223617ecdf Merge "Add MetaList" 2013-03-15 22:58:10 +00:00
jenkins-bot 0ad90791e0 Merge "Layouts, grids and panels" 2013-03-15 22:41:21 +00:00
Trevor Parscal c535d7c5df Layouts, grids and panels
Layouts
* Makes widget inherit from element
* Adds layout which also inherits from element
* Adds grid and panel layouts
* Uses grid layout in meta dialog

Other changes
* Corrects issues with several of the stand-alone files by fixing and using makeStaticLoader.php

Change-Id: I6b92c0204e176c914c26eff8c03ea417578e080c
2013-03-15 15:12:56 -07:00
Catrope 00a109b4a1 Add MetaList
A MetaList is a collection of MetaItems representing all of the
metadata in a ve.dm.Document, and it updates itself live as the
underlying document changes.

Currently this interface is read-only, I'll add mutators next.

Change-Id: If7bfc9563af37e22dcdca9a682d6decc2f6f1872
2013-03-15 15:03:10 -07:00
jenkins-bot 9acd22330d Merge "Added categories and language icons" 2013-03-15 21:24:04 +00:00
Trevor Parscal b58465dead Added categories and language icons
These are not used yet, but will be for inspectors and dialogs to come.

Change-Id: I503c889d137f8a804f627446af861e6b94442e2b
2013-03-15 14:17:42 -07:00
Trevor Parscal 5e7f538a63 Toolbar style fixes
demo.css
* Removed toolbar floating styles, which were out of sync and essentially a duplication of those in ve.Surface.css

ve.Surface.css
* Reorganized rules
* Fixed some CSS syntax issues

Change-Id: I94eb83fa74312266817f8932f54fc9b89332c524
2013-03-15 12:48:49 -07:00
jenkins-bot d73797d087 Merge "Remove 1px left margin from toolbar in Vector" 2013-03-15 18:25:10 +00:00
jenkins-bot 4a27e78813 Merge changes Ieffb108b,I334f7db2
* changes:
  Remove unused .data()
  Link inspector menu not appearing in the right place
2013-03-15 18:24:40 +00:00
Ed Sanders 0e973815ee Remove 1px left margin from toolbar in Vector
Apparently this is left over code from when Vector drew
the left border as a background.

Change-Id: I3a9829ed7ab1bb1f2ad1a1c88aff82b1a2fc456d
2013-03-15 18:14:18 +00:00
jenkins-bot 4565fa5725 Merge "Move toolbar-shadow.png to correct location" 2013-03-15 18:01:29 +00:00
jenkins-bot e915520310 Merge "Disable the save button when there is no past history" 2013-03-15 17:05:22 +00:00
Ed Sanders 9f2fed76d5 Disable the save button when there is no past history
If the user has undone all their actions they should not be able to
save the document. By updating the 'edited' property we also solve
the issue of the onbeforeunload alert displaying if all edits
have been undone.

Bug: 42939
Change-Id: Ib3bc5b0e2f21781166a17a3fdf4f5286e6713859
2013-03-15 15:56:53 +00:00
jenkins-bot 624171a952 Merge "Emit a transact event on the ve.dm.Document when a transaction occurs" 2013-03-15 13:07:54 +00:00
jenkins-bot 7cd0888b3a Merge "Make metadata reaping handle replacement operations more sanely" 2013-03-15 13:03:23 +00:00
jenkins-bot 9e1f517e9d Merge "Change MetaNodes to MetaItems" 2013-03-15 12:23:25 +00:00
Catrope a835c03bc1 Change MetaNodes to MetaItems
Rather than meta-things being special kinds of nodes, they are now a
separate class of things (MetaItems) along with Nodes and Annotations.

* Created a generic ve.dm.MetaItem that meta items inherit from.
  There will be actual instances of this class as well in the upcoming
  meta group code.
* Renamed MetaNode to AlienMetaItem, MWMetaNode to MWMetaItem,
  'metaBlock'/'metaInline' to 'alienMeta'
* Created a MetaItemFactory, handle meta items in the ModelRegistry
* Kill ve.dm.Node.static.isMeta, now obsolete

ve.dm.Converter:
* Pass in the MetaItemFactory
* Look up data element types in the ModelRegistry rather than the
  NodeFactory, because they can be either nodes or meta items
* Document createDataElement() and make explicit that modelClass can be
  either a node or a meta item
* Handle meta items in getDataFromDom()
* In getDomFromData(), check the MetaItemFactory as well as the NodeFactory

Change-Id: I893709c6f3aa00f85c1b905b70f9f4e597bdeada
2013-03-14 23:35:50 -07:00
Catrope dadf005a67 Emit a transact event on the ve.dm.Document when a transaction occurs
We'll need this to let a MetaList observe a Document and adjust to changes.
We should probably also have SurfaceFragment listen to this event instead.

Change-Id: I9e811e242969eb44afe0b4fa8153d0fb1b0071cd
2013-03-14 23:35:50 -07:00
Catrope 031b96dd2a Make metadata reaping handle replacement operations more sanely
Before, replacement operations that both inserted and removed data at
the same time would be treated as removals followed by insertions,
so we'd reap the metadata from the affected range and move it to the
start of the range. For a pure replacement, this doesn't make any sense.

Instead, preserve the first min(insertLength, removeLength) elements in
the metadata array, then perform a pure insertion splice or a pure
removal splice for the length adjustment. Any metadata reaped in a
removal splice is restored at the offset where we started removing,
after the preserved portion.

These changes make the behavior of metadata reaping saner in general
(the previous behavior had the potential to move metadata around if it
was near a paragraph opening or closing and you converted the paragraph
to a heading), and makes the behavior match up with translateOffset(),
which is desirable for MetaList synchronization.

Change-Id: If9a1c6a7cf43ead7e3e1e8f6e081b139ca65fa53
2013-03-14 23:35:50 -07:00
Trevor Parscal c0dcf647ac Move toolbar-shadow.png to correct location
The style was moved, but the image was left behind.

Change-Id: Ib6c22cf652d0ae787030986f0afd262e62d7f610
2013-03-14 17:10:42 -07:00
Trevor Parscal 531d3a7ac6 Remove unused .data()
Just cleaning up the cruft

Change-Id: Ieffb108b234409a1122a984b45bdda688ce2014b
2013-03-14 16:56:36 -07:00
Trevor Parscal ec912dc2d1 Link inspector menu not appearing in the right place
ve.ui.Widget.css
* Adjust menu up a few pixels to match other uses of ve.ui.MenuWidget (the format drop down)

ve.ui.LinkInspector.js
* Moved the form value initialization to a timeout that fires well after the animation of the inspector - this is only important because the first element has a menu that pops up and the menu was rendering in the wrong location

ve.ui.Frame.js
* Added reference to frame within this.$$ by passing it to get$$

ve.ui.Inspector.js
* Removed auto-focus on open from inspector base class - this will be done in a more specific and controlled way instead

ve.ui.js
* Added optional frame argument to get$$ so that it's easy to get the frame from any $$ that's bound to an iframe document

ve.ui.Window.js
* Removed duplicate static member assignments
* Added auto-focus on the window's frame before calling onOpen
* Added auto-blur of anything focused within the iframe after calling onClose

ve.ui.MWLinkTargetInputWidget.js
* Auto-highlight the selected item when populating a menu so that pressing enter always keeps the currently selected item selected

ve.ui.TextInputMenuWidget.js
* Take the frame's position into account when positioning a menu below an input

Change-Id: I334f7db29af6b821bcfc8dc3c0ccba2636d4d9b1
2013-03-14 16:56:04 -07:00
Trevor Parscal 949722c392 Toolbar actions not floating
Spurious semi-colon caused class to not be parsed, making toolbar actions not float right

Change-Id: I1ef88358908002cd7feb8c02b5da80d4f1ffe46d
2013-03-14 16:47:23 -07:00
jenkins-bot 77d29ec51c Merge "Add support for non-Latin scripts to wordBoundaryPattern" 2013-03-14 18:18:38 +00:00
Ed Sanders 47090bd1fd Add support for non-Latin scripts to wordBoundaryPattern
Replacing [a-zA-Z] with a long unicode expression which encompasses
all the characters in the unicode 'letters' category. Similarly replacing
[0-9] with an expression for 'numbers'.

Bug: 44085
Change-Id: Idd403339caa24769ce08133dda06ab6d4b9d694e
2013-03-14 11:17:28 -07:00
jenkins-bot bf6e7a6361 Merge "Correct name of can(Node)HaveGrandchildren functions" 2013-03-14 18:15:43 +00:00
jenkins-bot f53fe28d11 Merge "Add tests for ve.dm.Document.getNearestWordBoundary" 2013-03-14 18:02:27 +00:00
jenkins-bot 6f1216c3bf Merge "Fix Surface constructor in IndentationAction tests" 2013-03-14 18:01:23 +00:00
jenkins-bot 34a792d7b9 Merge "Context, frame, window, dialog and inspector refactor" 2013-03-14 17:41:09 +00:00
Trevor Parscal 1572ec1569 Context, frame, window, dialog and inspector refactor
This is a major refactor of user interface context, frame, dialog
and inspector classes, including adding several new classes which
generalize managing inspectors/dialogs (which are now subclasses
of window).

New classes:
* ve.ui.Window.js - base class for inspector and dialog classes
* ve.ui.WindowSet.js - manages mutually exclusive windows, used
  by surface and context for dialogs and inspectors respectively
* ve.ui.DialogFactory - generates dialogs
* ve.ui.IconButtonWidget - used in inspector for buttons in the head

Refactored classes:
* ve.ui.Context - moved inspector management to window set
* ve.ui.Frame - made iframes initialize asynchronously
* ve.ui.Dialog and ve.ui.Inspector - moved initialization to async
  initialize method

Other interesting bits:

ve.ui.*Icons*.css, *.svg, *.png, *.ai
* Merged icon stylesheets so all icons are available inside windows
* Renamed inspector icon to window

ve.ui.*.css
* Reorganized styles so that different windows can include only
  what they need
* Moved things to where they belonged (some things were in strange places)

ve.init.Target.js, ve.init.mw.ViewPageTarget.js, ve.init.sa.Target.js
* Removed dialog management - dialogs are managed by the surface now

ve.ui.*Dialog.js
* Renamed title message static property
* Added registration

ve.ui.*Inspector.js
* Switch to accept surface object rather than context, which conforms
  to the more general window class without losing any functionality
  (in fact, most of the time the surface was what we actually wanted)

ve.ui.MenuWidget.js, ve.ui.MWLinkTargetInputWidget.js
* Using surface overly rather than passing an overlay around
  through constructors

Change-Id: Ifd16a1003ff44c48ee7b2c66928cf9cc858b2564
2013-03-14 00:03:31 +00:00
Ed Sanders 387d8d6d39 Fix Surface constructor in IndentationAction tests
The IndentationAction was created against a version of master which
didn't have the new Surface constructor signature. This commit resolves
that conflict.

Change-Id: Ifc17f95acfa6057963d503448405355831b1ff97
2013-03-13 23:55:25 +00:00
Ed Sanders d22c7f7773 Correct name of can(Node)HaveGrandchildren functions
Bug: 43893
Change-Id: I9fd2a1fd6e3ee0a7bdfc357b5d4e4e0fd3efa0a5
2013-03-13 23:25:33 +00:00
Ed Sanders 981bb3ae7c Add tests for ve.dm.Document.getNearestWordBoundary
Also in this commit is a minor fix to the regular expression so it
behaves as documented (the hyphen needed escaping).

Bug: 44085
Change-Id: Idc315e2dce79be8f028b5681c60f74e175b9d869
2013-03-13 17:21:59 +00:00
jenkins-bot acf72c72c4 Merge "Refactor convert to use isolateAndUnwrap" 2013-03-13 16:37:17 +00:00
jenkins-bot 1d6e1828f3 Merge "Emit apply and close dialog when apply changes is clicked." 2013-03-13 06:56:49 +00:00
Rob Moen 002fa5d40b Fix current annotation being nullified
MWLinkTargetInputWidget annotation property was being killed
on populateMenu.

Other changes:
* Removed calls to sanitize on subclasses setValue methods
  as those methods call the parent class method which already
  sanitizes input.

Bug: 46025
Change-Id: I169dd58a06122122f187f9d751076ef56b255558
2013-03-13 01:41:33 +00:00
Timo Tijhof 2a1a25c580 Fix new lint warnings previously uncaught by jshint
The new jshint (0.9.1 > 1.1.0) is smarter about detecting trailing
whitespace (which enabled in our jshintrc file).
Looks like we did indeed let it slip through a few times in ve.Document.

Also cleaning up comment from * to - for consistency and avoiding
block-comment characters.

Change-Id: Ie1621816d608b5c42028ee945346d872a747c6a4
2013-03-13 01:37:00 +00:00
Ed Sanders a03d0d68cb Refactor convert to use isolateAndUnwrap
isolateAndUnwrap now unwraps to a level determined by a target type
i.e. the type you are going to convert to.

Also in this commit wrap/unwrap/rewrap have been refactored to use
getLengthDifference. unwrap now takes an inner/outer unwrap depth.

Change-Id: I3c6249de43232a9ef64f498a0aaf66b1c44973f2
2013-03-13 01:07:52 +00:00
jenkins-bot 9dfa6945b4 Merge "Only unwrap { generated: wrapper } based on context." 2013-03-13 00:55:14 +00:00
Ed Sanders 9a7b8aacf8 Only unwrap { generated: wrapper } based on context.
Wrapper paragraphs should only be unwrapped if they are the first
element in their parent - or if there is a block level element separating
them from the previous unwrapped paragraph.

Empty paragraphs should only be unwrapped if they are empty and the
last element in their parent.

Also in this commit is a simple test for IndentationAction.decrease().

Bug: 45590
Change-Id: I1f47d12db6d57d984fd4607f667a3b62c53f3dd6
2013-03-13 00:42:16 +00:00
jenkins-bot 34e8a9dbac Merge "Create MediaWiki specific nodes to contain MW specific rules." 2013-03-12 23:46:51 +00:00
Ed Sanders 0ce20b6e16 Create MediaWiki specific nodes to contain MW specific rules.
Heading and Preformatted nodes have rules that should only
exist under a document node in MediaWiki.

Two new node types have been created as has a new DropdownTool which
uses these. The MW init options have been changed to use the new
DropdownTool.

Bug: 45295

Change-Id: I3f47e1ae1f5c1415bde58a75385e4bf5f4b8fffc
2013-03-12 16:28:29 -07:00
Timo Tijhof c13dce97ec Fix JSDuck warnings
Change-Id: Ibc3f49c55ded5490fcb071f0ccf9f25a71a06c97
Warning: categories.json Class 've.NodeFactory' not found in categories file
Warning: ve.ui.ContentDialog.js:8: Unknown type ve.ui.Surface
Warning: ve.ui.MetaDialog.js:8: Unknown type ve.ui.Surface
Warning: ve.ui.Dialog.js:8: Unknown type ve.ui.Surface
2013-03-12 22:05:25 +01:00
Ed Sanders 404ddbf7cc Fix broken FormatAction tests.
The ve.Surface constructor was recently changed, but the instantiation
in the FormatAction tests was not updated accordingly.

The constructor now requires a ve.init.Target object.

Bug: 39597
Change-Id: Ia4193fbab5c63007ed057009bf9a39f1f9d18fb7
2013-03-11 16:53:44 +00:00
jenkins-bot 7b47b2ef03 Merge "Do not display phantoms while dragging mouse over alien nodes." 2013-03-08 23:38:25 +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
Rob Moen 004f4cdeb7 Emit apply and close dialog when apply changes is clicked.
* Cleanup cancel button click binding.

Change-Id: I959a1b33e06a344a7946de8709f71f9c265a7604
2013-03-08 13:51:58 -08:00
jenkins-bot 8f7f6aefe6 Merge "Adding comments for grep" 2013-03-08 21:47:55 +00:00
shirayuki 17508a2657 Adding comments for grep
Change-Id: Ib20219ccf4409ac24f896c67e695f4155136daeb
2013-03-09 06:46:24 +09:00
Rob Moen ef9fb83685 In MW integration, dialog was overlapping toolbar shadow.
Setting the top to the outerHeight of the toolbar solves this.

Change-Id: I528ce23c88dfe6a3be7d4f7c4f6c90ef608630c1
2013-03-08 11:15:21 -08:00
jenkins-bot 80067f8633 Merge "Use static.name once for ce and dm nodes" 2013-03-08 01:20:35 +00: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
jenkins-bot 49fea58c76 Merge "Fix for incorrect usage of ve.Range" 2013-03-07 23:51:18 +00:00
Inez Korczyński c021445649 Fix for incorrect usage of ve.Range
Properties "from" and "to" of ve.Range should be used when
direction of the range is important.

Change-Id: I73f27abf5c90f9aad8fdd0622f71b09188af9486
2013-03-07 15:49:00 -08:00
jenkins-bot 007d221b73 Merge "More work on dialog classes and their mw specific handling." 2013-03-07 22:46:43 +00:00
jenkins-bot 41a4cc2327 Merge "Introduce dialogs" 2013-03-07 22:46:36 +00:00
Rob Moen 7044ec820f More work on dialog classes and their mw specific handling.
Changes include:

VisualEditor.i18n.php, VisualEditor.php
* i18n labels for dialogs

ve.init.mw.ViewPageTarget.js
* Initial go at onOpenDialog and onCloseDialog methods

ve.init.Target.js
* Change calls to dialog hide & show to close & open

ve.ui.MetaDialog.js, ve.ui.ContentDialog.js
* Pass surface when constructing
* Add static title message property

ve.ui.Surface.css
* Set high z-index for toolbar for shadow to overlap dialog.

ve.ui.Dialog.js
* Extends EventEmitter class.
* Changed hide/show method names to open/close.
* Create base ui elements.

ve.Surface.js
* Create instance of meta dialog.

Change-Id: I867ca0546606eeb5e2ab7f612bb5af700ab877ec
2013-03-07 12:47:42 -08:00
Inez Korczyński e9b8021bf3 Fix for IE bug where clearTimeout doesn't clear the timeout
Apparently in IE even after you call clearTimeout, the function passed
to setTimeout might still get invoked (not 100% of the time).

It depends on the time difference between calling clearTimeout and
when that function was supposed to be called.

Change-Id: I050c1ecc51c1d891a028fb777243573487357171
2013-03-07 03:49:39 +00:00
Rob Moen 81c9b72db5 Introduce dialogs
Major changes:

demos/ve/index.php
* Renamed ve-demo-content to ve-demo-editor

ve.init.mw.ViewPageTarget, ve.init.sa.Target
* Added handlers for dialog events

ve.ui.*Dialog.js
* Added skeleton classes for dialogs

ve.init.Target.js
* Create abstract class methods for Target.

ve.init.sa.Target.js
* Create Standalone target view methods.

ve.init.mw.Target.js
* Added MW specific target view methods.
* Integration action buttons are now added to the edit
view in the toolbar.

ve.Surface.js
* Simplified constructor, now requiring a target which contains the container

* Other changes include some documentation and code cleanup.

Bug: 39597
Change-Id: Iff39266bdd3052f34bda254ca407030dbbc81f26
2013-03-06 14:19:15 -08:00
Inez Korczyński b98ee5140a DomRange makes more sense as a name for this class (cause it is not rangy specific).
Change-Id: I670523a0ed2216ebe34dc4b759a4aa429b9da53c
2013-03-05 12:18:59 -08:00
Ed Sanders 0195493099 Pass parsoid server errors through to VisualEditor.
Unfortunately the Http::get wapper provides no data if anything but
an OK status is returned, so ApiVisualEditor now uses MWHttpRequest
directly.

If a non-OK status in encountered the error code and message are
passed through to the JSON output, and rendered in the error
alert by VE.

The error code passed through is parsoidserver-http-NNN although
other suggestions are welcome.

Bug: 44354
Change-Id: I166ecf81c40f0f1c62663f2096753269d28f2916
2013-03-05 17:24:51 +00:00
jenkins-bot b3c624f857 Merge "Shift-Enter should add newline in preformatted" 2013-02-28 20:28:57 +00:00
Trevor Parscal d1a397221e Added validation to ve.inheritClass
I encountered a very difficult to track down error while working on
ve.ui.Dialog where a copy-pasted inheritClass call overwrote the
prototype of ve.ui.Widget.

By adding this check, we can ensure that 2 identical calls to
inheritClass won't silently make the system explode. This check is
lightweight and will save someone down the line a bit of time and head
scratching.

Change-Id: I014d53722fc8d941ec415462d258a79985e0e3d7
2013-02-27 18:41:59 +01:00
Christian Williams 0af149824f Shift-Enter should add newline in preformatted
Modified handleEnter to check for the condition that shift-enter
is being pressed inside of a preformatted block. If so, a break
node is inserted.

Bug: 45355
Change-Id: Iae7b3c88b7cd976e519c09821a064078228acc79
2013-02-26 14:01:23 -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
jenkins-bot 86d1f2a35b Merge "Fixing canBeSplit for ListItemNode" 2013-02-26 01:20:15 +00:00
jenkins-bot 9ba823052e Merge "Cleanup: Omit second argument to setTimeout for "nextTick"" 2013-02-26 00:37:44 +00:00
Timo Tijhof 0031725751 Cleanup: Omit second argument to setTimeout for "nextTick"
Not 0 or 1.

Change-Id: Ia6eb985e649c5bd196f87aac98c3919e60be9a86
2013-02-26 00:34:58 +00:00
Christian Williams 3cd0448b33 Fixing canBeSplit for ListItemNode
List items weren't being properly split because of a typo in this file.

Change-Id: Ib275d62156b775bad57624dfdf4b54eb9a925eaa
2013-02-25 16:29:32 -08:00
jenkins-bot db87504269 Merge "Change FormatAction.splitAndUnwrap to use the new SurfaceFrament.isolate method" 2013-02-26 00:23:05 +00:00
Ed Sanders f506e33718 Change FormatAction.splitAndUnwrap to use the new SurfaceFrament.isolate method
Bug: 45246
Change-Id: I6e10ed87b25150cfc9d8e42c0f0bd3733b08fee7
2013-02-26 00:22:19 +00:00
jenkins-bot 8d54ef4135 Merge "Implement SurfaceFragment.rewrapAllNodes" 2013-02-26 00:22:01 +00:00
jenkins-bot e4724553f1 Merge "Modify styles, add disabled and read-only for widgets" 2013-02-26 00:14:08 +00:00
jenkins-bot fbdc0e62ed Merge "Resigning from localStorage" 2013-02-25 23:47:35 +00:00
Trevor Parscal 622180b6fa Fix JSDuck warnings
Follows-up I44bcb79a59 and various other changes.

Please remember to generate documentation and resolve
all warnings before pushing into gerrit.

Change-Id: I8a372443e841308463376d8673ce027a97bbcd30
2013-02-26 00:44:21 +01:00
Christian Williams 6614acc4a0 Resigning from localStorage
Using localStorage for copy and paste between ve instances previously worked, but broke with the introduction of AnnotationSet. After a discussion with James, rich copy and paste from many sources is the real goal, so copy and paste enhancement should work toward that end.

Change-Id: I58c0f4525e486fada997872b40c2317f57034b7a
2013-02-25 15:33:50 -08:00
Ed Sanders b384742103 Implement SurfaceFragment.rewrapAllNodes
rewrapAllNodes is effectively the same as unwrap then wrap
except it operates as one transaction as so avoids a potentially
invalid intermediate state.

Added some more comments for unwrapAllNodes and renamed a varaible
for consistency.

Fixed a typo in Transaction.newFromWrap comment.

Bug: 45242
Change-Id: Ie752a788d087055d97c7c6f75f59c6a2680d26c7
2013-02-25 14:59:39 -08:00
Trevor Parscal 59c67e1e94 Modify styles, add disabled and read-only for widgets
demos/ve/demo.css, demos/ve/index.php
* Style changes for utilities and dump output
* Initially disable the log range button, activate when there's a range to log
* Make range inputs read-only
* Rename some widget variables
* Add extra structure and classes to dump output

ve.ui.Widget.css
* Remove left/right margin for buttons
* Simplify opaque white color
* Modify selector for disabled buttons - see changes in ve.ui.Widget.js
* Added styles for text input widget's readonly and disabled states

ve.ui.Widget.js
* Added disabled state

ve.ui.ButtonWidget.js
* Moved click event handler to method

ve.ui.InputLabelWidget.js
* Moved click event handler to method

ve.ui.InputWidget.js
* Moved input change event handler to method
* Added readOnly state

ve.ui.LinkTargetInputWidget.js
* Corrected documentation

ve.ui.MenuWidget.js
* Blocked interaction while widget is disabled

ve.ui.MWLinkTargetInputWidget.js
* Corrected documentation
* Blocked interaction while widget is disabled

ve.ui.TextInputMenuWidget.js
* Blocked interaction while widget is disabled

Change-Id: I7ea89873b50a98d058d1dd1e309e3e8b7c8e7b2e
2013-02-25 12:10:26 -08:00
jenkins-bot 0d8bc60cc6 Merge "Make translateRange() translate across wrapping transactions correctly" 2013-02-25 19:32:34 +00:00
jenkins-bot c1b25fc8d7 Merge "Add ve.Range.prototype.isBackwards()" 2013-02-25 19:26:18 +00:00
jenkins-bot 86a60faa54 Merge "Combine consecutive remove operations" 2013-02-25 19:26:14 +00:00
jenkins-bot d9fcb114d5 Merge "After creating a ve.Surface in a test, destroy it" 2013-02-25 19:26:09 +00:00
Timo Tijhof a3651cbe0c Use @chainable where appropiate.
Find: @return.*this.*$
Replace: @chainable
Bug: 45264
Change-Id: Ib950422ddb78d7b91545399a6053e82ae2dbd932
2013-02-23 11:11:18 +01:00
Catrope 1a4c60ed17 Make translateRange() translate across wrapping transactions correctly
Previously, we would translate to the right of an insertion, but for
wrapping transactions that means we end up with something like
<ul><li>|<p>...</p></li></ul>|, which doesn't make any sense. This
change changes this to <ul><li>|<p>...</p>|</li></ul>.

* Add parameter to translateOffset() that toggles the behavior for
  the offset before an insertion
* In translateRange(), translate start and end differently
** In some cases this can map them across each other, fix that

Change-Id: Ia2197b08d9f6763be3f2db5a59546ddc3f74a281
2013-02-22 17:33:31 -08:00
Catrope 90114c7a48 Add ve.Range.prototype.isBackwards()
Change-Id: I6f6977cfc9d772239da22ceb779e5e37576c2e0c
2013-02-22 17:33:23 -08:00
Catrope 090e944dd9 Combine consecutive remove operations
We already combine consecutive operations of other types, but didn't do
that for remove. We have to do this, though, because translateOffset()
gets confused otherwise.

Change-Id: I4285a3efd9f2297398f57e2f24adb26adafdf465
2013-02-22 17:33:17 -08:00
jenkins-bot d00486a450 Merge "Cleanup selection displaying related methods in ve.ce.Surface." 2013-02-23 01:18:15 +00:00
jenkins-bot 951b3c78f0 Merge "Introduction of ve.ce.RangyRange class." 2013-02-23 01:16:46 +00:00
Inez Korczyński c3d10e965a Cleanup selection displaying related methods in ve.ce.Surface.
* Deleted blocks of code that are never executed.
* Deleted method (showCursor) that is never used.

Change-Id: I031585b40f384d3e0e5d4cb03f626c9229d97fcf
2013-02-22 17:05:54 -08:00
Inez Korczyński a5e56718cd Introduction of ve.ce.RangyRange class.
Change-Id: I44bcb79a5967c362774603ea27181b9c64d2ea96
2013-02-22 17:02:42 -08:00
Catrope 8b74c70a34 After creating a ve.Surface in a test, destroy it
I was seeing intermittent test failures caused by exceptions in
ce.SurfaceObserver (!!), seems to be caused by the FormatAction test
creating a surface but not destroying it.

Change-Id: I7ab070d3c8db934eb9781ac8a6466475144c214e
2013-02-22 16:22:30 -08:00
Catrope 1463d03f44 Change one last .storeHTMLAttributes to .storeHtmlAttributes
Change-Id: I161b2e8bf22c3784ca660ab0961a528b23601022
2013-02-22 16:13:47 -08:00
jenkins-bot 065e9c8a67 Merge "Make the full document regex hack a bit more robust" 2013-02-22 23:26:38 +00:00
jenkins-bot 60b5c838ad Merge "Make string type matches override regex type matches" 2013-02-22 23:26:27 +00:00
jenkins-bot fa1f760deb Merge "Add MWMetaNode to clean up <meta>/<link> hack in the converter" 2013-02-22 23:26:24 +00:00
jenkins-bot 4e0ebfdba0 Merge "Support RDFa type regexes in ModelRegistry" 2013-02-22 23:26:21 +00:00
jenkins-bot fb11cc8a8c Merge "(bug 45062) Implement the new node API in the converter" 2013-02-22 23:26:18 +00:00
jenkins-bot 482c89a916 Merge "Change context.wrapping to context.inWrapper" 2013-02-22 23:26:15 +00:00
jenkins-bot 950ff37d9b Merge "Add .static.enableAboutGrouping" 2013-02-22 23:26:12 +00:00
jenkins-bot 78232847db Merge "Add .static.storeHtmlAttributes" 2013-02-22 23:26:09 +00:00
Catrope dbd3d2354a Make string type matches override regex type matches
Change-Id: Ic21e27c047d8cb1161a6613bb5232d0d19b37aa6
2013-02-22 15:21:40 -08:00
Catrope 04c72f6871 Add MWMetaNode to clean up <meta>/<link> hack in the converter
Change-Id: I4c69bff4981eef78415b43d31c3fd2ee271450ef
2013-02-22 15:21:40 -08:00
Catrope 314817925a Support RDFa type regexes in ModelRegistry
Change-Id: Id19c3a567140f9e27ba732b6e8d9e25bc7a28a4f
2013-02-22 15:21:40 -08:00
Catrope 2e36f1542b (bug 45062) Implement the new node API in the converter
This changes the node API to work with multiple elements, so we can
support about groups. Instead of passing in and returning single DOM
elements, we use arrays of DOM elements.

ve.dm.Converter:
* Pass modelRegistry into the constructor
* Remove onNodeRegister handler and its data
* Remove getDataElementFromDomElement() and
  getDataAnnotationFromDomElement(). Most logic moved into
  getDataFromDom(), some into createDataElement()
* Remove createAlien(), replaced with
  createDataElement( ve.dm.AlienNode, ... )
* Replace doAboutGrouping() (which wrapped about groups) with
  getAboutGroup() (which returns an array of the nodes in the group)
* Put in a hack so <meta>/<link> elements with an mw: property aren't
  alienated
* Remove about group wrapping behavior in favor of just outputting
  multiple nodes

ve.dm.AlienNode.js:
* For multi-element aliens, only choose inline if all elements are
  inline, not just the first one

ve.dm.example.js:
* Add html/0 stuff for meta nodes
* Fix test case to reflect new alien behavior

Change-Id: I40dcc27430f778bc00a44b91b7d824bfb2718be6
2013-02-22 15:21:40 -08:00
Catrope 5e16141750 Change context.wrapping to context.inWrapper
It's what the docs say it should be, so let's call it that :)

Change-Id: Ia10861ce77872243beb3d3a1886877824103f6c9
2013-02-22 15:21:40 -08:00
Catrope cf9e5dd953 Add .static.enableAboutGrouping
Defaults to false, nodes can opt into about grouping. Not being used
yet, will be used in the converter rewrite.

Change-Id: Ic2a529241e69fb07ac926c826ead0108193b3050
2013-02-22 15:21:40 -08:00
Catrope bbe3783d58 Add .static.storeHtmlAttributes
Defaults to true, but set to false, so we don't do redundant work for
aliens.

Change-Id: If35db3a67afd78124b4b2b46bb78ad60cbac46f5
2013-02-22 15:21:31 -08:00
jenkins-bot 26e623940a Merge "Implement SurfaceFragment.unwrapAllNodes and fix wrapAllNodes." 2013-02-22 22:36:03 +00:00
jenkins-bot 5c78ba9b6a Merge "Fix bug with replacements in translateOffset()" 2013-02-22 22:33:48 +00:00
jenkins-bot 8e0348c803 Merge "Fix ModelRegistry stupidities" 2013-02-22 22:31:03 +00:00
Ed Sanders 4f0ac479ed Implement SurfaceFragment.unwrapAllNodes and fix wrapAllNodes.
wrapAllNodes was calulating the new selection incorrectly. This has
been fixed and a test added.

unwrapAllNodes takes a depth as its argument and unwraps that many
elements from inside the selection.

Tests for wrap/unwrap apply also now check that applying a wrap
and then its inverse as an unwrap result in the document reverting
to its original state.

Change-Id: I7dcacdfb5894be59ffad69b369d7b32933a25b61
2013-02-22 13:37:42 -08:00
Catrope 8f84982e0d Fix bug with replacements in translateOffset()
In our test case, offset 12 was mapped to 16, but that should be 11.
The problem here was that the offset right before the removal was
mapped to right after the removal, but that's only valid if we're
dealing with a removal, not when we're dealing with a replacement
where we're both removing and inserting data.

Change-Id: Ibf3c1463c0de009578cd50736f19bae82669ced8
2013-02-22 13:35:33 -08:00
jenkins-bot eae2529064 Merge "(bug 43461) Hide Phantoms" 2013-02-22 21:19:37 +00:00
jenkins-bot 1ef5c07a93 Merge "(bug 45423) Create SurfaceFragment.isolate method" 2013-02-22 20:40:32 +00:00
Ed Sanders feaa422495 (bug 45423) Create SurfaceFragment.isolate method
This method will take a selection of siblings and ensure they
are the only chlidren in their first parent which can be placed anywhere
(for example the first parent of a tableCell which can be placed anywhere
is a table, and for a listItem is a list).

The method ensures no redundant empty tags are created, so if
the selection encompasses all siblings then no action is taken.

Also in this commit are two test cases run against ve.dm.example.isolationData.

Change-Id: I783bd5ecd9d43d61f9b2685985409b4d746cbe94
2013-02-22 12:38:06 -08:00
jenkins-bot ab718eef32 Merge "Create tests for ve.FormatAction.convert" 2013-02-22 19:55:54 +00:00
Ed Sanders c05b5d13cd Create tests for ve.FormatAction.convert
These 3 tests convert different selections of list items to headings.

Bug: 45216
Change-Id: I6cf042d9d5aa4afb68c0992f444b600ed69f0c04
2013-02-22 11:52:12 -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
Catrope 4b086b94d7 Make the full document regex hack a bit more robust
Anchor the regex and make it look for doctype too

Change-Id: I43abb6f214a28801642bde46b50f4ac12614d1e4
2013-02-21 14:59:19 -08:00
jenkins-bot 502a2a2e53 Merge "Change {Boolean} to {boolean} throughout" 2013-02-21 00:42:44 +00:00
Inez Korczyński 0c73aa012e Introduce ve.Keys based on DOM Level 3 KeyEvent
Change-Id: I6abee2c0c49e355aef39089c7c94e51aaee01929
2013-02-20 16:15:59 -08:00
jenkins-bot ddbc0343b7 Merge "Make ve.copyArray() / copyObject() work with booleans" 2013-02-20 18:24:31 +00:00
Catrope a095c0ab06 Change {Boolean} to {boolean} throughout
Change-Id: Ibbbaed3762efa6a6928ba6e4611b1f1fef91ad8f
2013-02-20 10:03:55 -08:00
jenkins-bot 1d0a383968 Merge "Very small cleanup of onCut method in ve.ce.Surface." 2013-02-20 17:36:48 +00:00
Inez Korczyński 2d9c5d5628 Very small cleanup of onCut method in ve.ce.Surface.
Use ve.bind in order to change context within which
callback is called - reduces a need of introducing
new local variable.

Change-Id: I75ece695548c87073dd22e5e7ec80057d7132d22
2013-02-20 17:35:30 +00:00
Catrope b553cb9f21 Fix ModelRegistry stupidities
* Register mw: as an extension-specific type
* Include 'property' as an RDFa type attribute

Change-Id: Ia70708b76294815eb8eb8132048c33b0636380e9
2013-02-20 09:30:15 -08:00
Catrope 477cec43d6 Make ve.copyArray() / copyObject() work with booleans
This should really be fixed to not enumerate all types but be nicer.
Timo said he'd do that.

Change-Id: I15807696a7324d3fb207ed41b442a83dc83a75ec
2013-02-20 09:30:09 -08: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
jenkins-bot a6fc5ab0ac Merge "Upstream: Update QUnit from v1.10.0 to v1.11.0" 2013-02-19 21:52:30 +00:00
Timo Tijhof 0538841366 Upstream: Update QUnit from v1.10.0 to v1.11.0
* Code:
  http://code.jquery.com/qunit/qunit-1.11.0.js
  http://code.jquery.com/qunit/qunit-1.11.0.css
* Tree:
  https://github.com/jquery/qunit/tree/v1.11.0
* Changes:
  https://github.com/jquery/qunit/compare/v1.10.0...v1.11.0
* Release notes:
  https://github.com/jquery/qunit/blob/v1.11.0/History.md

Change-Id: I3591455f0096471d073c94eaab424d151203b297
2013-02-19 19:50:02 +01:00
Catrope 3035c311ec Make the converter work with full HTML documents rather than fragments
The Parsoid output will also be expected to be a full HTML document. For
backwards compatibility, we allow for the Parsoid output to be a
document fragment as well. We don't send a full document back yet, also
for b/c -- we'll change this later once Parsoid has been updated in
production.

ve.dm.Converter.js:
* Make getDataFromDom() accept a document rather than a node
** Split off the recursion (which does use nodes) into its own function
** For now we just convert the <body>. In the future, we'll want to do
   things with the <head> as well
* Pass the document around so we can use it when creating elements
* Make getDomFromData() return a document rather than a <div>

ve.init.mw.Target.js:
* Store a document (this.doc) rather than a DOM node (this.dom)
* Pass around documents rather than DOM nodes
* Detect whether the Parsoid output is an HTML document or a fragment
  using a hacky regex
* When submitting to Parsoid, submit the innerHTML of the <body>

ve.init.mw.ViewPageTarget.js:
* s/dom/doc/
* Store body.innerHTML in this.originalHtml

ve.Surface.js:
* s/dom/doc/

demos/ve/index.php:
* Don't wrap HTML in <div>
* Pass HTML document rather than DOM node to ve.Surface

ve.dm.Converter.test.js:
* Construct a document from the test HTML, rather than a <div>

ve.dm.example.js:
* Wrap the HTML in the converter test cases in <body> tags to prevent
  misinterpretation (HTML fragments starting with comments, <meta>,
  <link> and whitespace are problematic)

Change-Id: I82fdad0a099febc5e658486cbf8becfcdbc85a2d
2013-02-19 10:38:39 -08:00
Catrope d36e6851d5 Add ve.createDocumentFromHTML()
Converts an HTML string to a brand new document using an iframe hack
(proper ways to do this exist, but don't work cross-browser).

Parsoid will serve us full HTML documents rather than document fragments
soon, so we'll need this functionality (along with some other changes
that I'm working on now) to deal with that change.

This doesn't currently work quite right in IE8 (although we have lots of
other issues in IE8) as well. It's not that hard to fix up though: we
just have to leave the iframe attached to the main document (should
probably provide a destroy function in that case) and the tests have to
deal with the fact that IE normalizes <head></head> to
<head><title></title></head> .

(For backwards compatibility, we'll have to deal with document fragments
as well; this will be implemented as an MW-specific hack in the
integration in the next commit.)

Change-Id: I15f877583c39124ba1c5e8e22585297ff3bac8d6
2013-02-19 10:30:25 -08:00
jenkins-bot a7030a5148 Merge "Abort activation when changing to view mode." 2013-02-16 01:04:52 +00:00
Rob Moen 3070d0c56e Abort activation when changing to view mode.
Resolves (Bug 44838)

Changes:
* onLoad: Setup only if activating.  Prevents ve from loading after aborted
while activating.

* onViewTabClick: add clause for activating mode.  Calls deactivate with an
override, and exits activating mode.

Change-Id: Ia61cd1d576b63098419474ad58bc01362c08541e
2013-02-11 11:38:50 -08:00
Catrope 98a914e9fe Optimize ve.filterArray a bit
Change-Id: I8fc9c8d5f57a4af3b5421c65664351f21e488c53
2013-02-07 17:16:18 -08:00
Catrope 591f2e7396 Change the HTML attribute prefix from html/ to html/0/
This means that <p data-foo="bar"> will now be converted to a paragraph
with attributes {"html/0/data-foo":"bar"} rather than {"html/foo":"bar"}

This paves the way for multi-element node (about group) handling in the
node API: nodes representing multiple DOM elements will have html/i/attr
to represent an attribute of the i'th DOM element.

Change-Id: Iea52bdccd721942ca708c8f9f47e934524809845
2013-02-06 12:00:43 -08:00
Rob Moen 78a99fb0a3 Check for instance of generic LinkAnnotation when querying target.
Resolves (Bug 44686)

Change-Id: I0ff962330e061aea66a25a923f46d6759e5ff6af
2013-02-05 11:55:27 -08:00
jenkins-bot 7ea4b94604 Merge "Fix bug where inline nodes didn't trigger wrapping" 2013-02-02 00:28:07 +00:00
jenkins-bot 6c5d83449d Merge "Remove trailing commas" 2013-02-02 00:26:59 +00:00
jenkins-bot 9a96f894ff Merge "Node cleanup" 2013-02-02 00:23:03 +00:00
Catrope 57ad316988 Fix bug where inline nodes didn't trigger wrapping
When encountering an inline node (i.e. content node that's not a text
node) within a branch node that's not a content branch node, the
converter should start a wrapper. But it doesn't do this, it only opens
wrappers for text nodes and annotations.

Fixed this in the converter, added a test for it, and fixed an existing
test that asserted the broken behavior.

Change-Id: I6e143e21e68b68f0d85b8772e24a2d3a5d465410
2013-02-01 16:06:17 -08:00
Trevor Parscal 363961a9e2 Node cleanup
ve.Node.js
* Removed unused emitUpdate property
* Made traverseUpstream a dynamic method rather than static

ve.ce.Node.js, ve.ce.Surface.js
* Updated calls to traverseUpstream

Change-Id: I28a2dac61aa32668d35854fbdb7712401c42336a
2013-02-01 15:35:48 -08:00
jenkins-bot 7155bcea16 Merge "i18n icons" 2013-02-01 23:34:15 +00:00
Trevor Parscal f49d80d27a i18n icons
Graphics (*.ai, *.png, *.svg)
* Took a pass on all images making them sharper and clearer
* Renamed bold and italic to bold-b and bold-a
* Added bold-f, italic-k, bold-a and italic-a
* Reorganized illustrator file

ve.ui.Icons-raster.css, ve.ui.Icons-vector.css
* Added classes for new icons
* Appended bullet, number, indent and outdent class names with "list"

ve.ui.*ButtonTool.js
* Added definitions for static icon property
* For bold and italic, added i18n style definitions

ve.ui.ButtonTool.js
* Switched from re-using the name property (which is intended to be the symbolic name of the tool used when registering with the tool factory) to using an static icon property for defining the icon

Change-Id: I43e7c35835a1e6dfb06f2a70226fac0d395008e8
2013-02-01 15:29:18 -08:00
Catrope 46957736a4 Remove trailing commas
JSHint doesn't detect this (this is an open bug against jshint), but
Eclipse does

Change-Id: Iebfc0f9c6263f60898739c9d19400357a65da0e9
2013-02-01 14:45:35 -08:00
Catrope a97f777685 Introduce context object in getDataFromDom()
* Introduce context object as specified for
  ve.dm.Node.static.toDataElement()
* Remove wrapping variable in favor of context.wrapping
* Remove wrappingIsOurs in favor of context.canCloseWrapper
* Introduce originallyExpectingContent and use it to repopulate
  context.expectingContent after closing a wrapper
* Replace most uses of branchHasContent with context.expectingContent
** Except for two cases where we need originallyExpectingContent

These changes fix a case where a metaBlock was generated in an inline
position. Updated the tests to reflect this.

Change-Id: I6baf6053f8a3a0b7d91487f812b9235a7b2b3db1
2013-01-31 15:00:00 -08:00
Catrope 1927330352 Use AnnotationSet rather than array in getDataFromDom()
Change-Id: Ie5f1f94bd62739ccf74c027dd0ba418fe2d91fa6
2013-01-31 15:00:00 -08:00
Catrope e083afb029 Hybrid-ify MetaBlock/MetaInline
Change-Id: I7b7a2d50637e2009742b290cb1bd0f4fc0395934
2013-01-31 15:00:00 -08:00
Catrope c0690634ee Hybrid-ify AlienBlock/AlienInline
Change-Id: Ieda8383c0c04df208f4c5f2aa7380427467049b7
2013-01-31 14:59:59 -08:00
Catrope ac6c9b2418 Specify (but do not implement) the context parameter to toDataElement()
This allows the converter to provide the node handlers with context
information, which hybrid nodes (such as alien and meta) need to decide
which shape to take.

Change-Id: I36860bee560a38ee39a149109be3706e39258edc
2013-01-31 14:59:59 -08:00
Trevor Parscal 100e67c128 Fixed documentation warning
Please use backtick (it's to the left of the 1 key) around HTML elements in comments.

Change-Id: I473e88a2cb1f7fb725f21cd0e8b3f659189c15a0
2013-01-30 12:52:03 -08:00
Catrope 36d99ad901 Add Iceweasel to supported browsers list
Depends on https://gerrit.wikimedia.org/r/46666

Change-Id: I1192ce6687ba69504d0c4be484e479ddebedbc87
2013-01-29 17:53:09 -08:00
jenkins-bot 602d01e461 Merge "Added tests and fixed inconsistencies for empty text node handling" 2013-01-29 23:16:30 +00:00
jenkins-bot 9bf5eb5b5b Merge "Added support for passing data into annotation constructors" 2013-01-29 23:15:21 +00:00
Trevor Parscal 16310f7535 Added tests and fixed inconsistencies for empty text node handling
Continues where Ibb682332a6084e357104183641a104e3ae1e253f left off, adding tests and removing inconsistencies between the behavior of the document constructor, which was adding empty text nodes to empty paragraphs, and correcting other tests which expected empty text nodes to be there as well.

Change-Id: I414d061cdd494b8023f14e944eda2910a4dab0d4
2013-01-29 15:13:17 -08:00
jenkins-bot a9b7c5c5e3 Merge "Trigger refactor" 2013-01-29 22:03:53 +00:00
Trevor Parscal ea4b42b2b2 Automatically prune empty text nodes
When there's 2 entities or inline content nodes (like aliens) with text between them, removing that text should remove the node too. If you don't remove the node then CE won't think to make a slug between the two inline nodes.

Change-Id: Ibb682332a6084e357104183641a104e3ae1e253f
2013-01-28 17:09:56 -08:00
Trevor Parscal 294db5e3ef Trigger refactor
Objective: Simplify the registration and use of triggers

Changes:

* Renamed ve.Command to ve.Trigger
* Renamed command demo to trigger demo
* Removed language prefixing of triggers
* Generating trigger tooltips rather than hard-coding them in i18n
* Added documentation to clarify that only 'mac' and 'pc' are supported platforms, and how the default is chosen
* Simplified trigger registry's register command
* Updated trigger registrations

Change-Id: Ibab6ad5b5c86f24707f064967dc2119a81125392
2013-01-28 17:06:13 -08:00
Trevor Parscal 280c85d8e7 Added support for passing data into annotation constructors
This resolves a TODO

* Added logic to support passing an argument into annotation constructor which is used as the data property (reusing the element argument)
* Updated documentation
* Simplified instantiation of annotations

Change-Id: I142b8fa3883bf70c896a2a568088d833814ef2dc
2013-01-28 11:01:52 -08:00
Catrope d73d6e9bf0 Add extension-specific types functionality to ModelRegistry
Extension-specific types are RDFa types (or type regexes) that are
registered with the ModelRegistry separately. If an element has a type
that is extension-specific, then that element can only be matched by a
rule that asserts one of its extension-specific types.

For MediaWiki, we would call
ve.dm.modelRegistry.registerExtensionSpecificType(/^mw:/ ) .
So then an element like <span typeof="mw:foobar"> would either match a
rule specifically for mw:foobar, if one exists, or no rule at all; even
the rule for <span> would not match. The consequence of this is that
elements with unrecognized mw:-prefixed RDFa types are alienated.

Change-Id: Ia8ab1fe5dffb9f813689324372a168e8e4a3e0bc
2013-01-22 18:12:35 -08:00
Catrope 99df776543 Allow matchTagNames = null in ve.dm.Converter
This won't usefully register the node with the converter right now, but
we need to allow this because the ModelFactory tests will need to have
stub nodes with tag-only matches.

Change-Id: I023cc8ff647363ab55c73dff39b17ca47e9e6681
2013-01-22 17:45:43 -08:00
Catrope 47b728bed9 Add wrapper for Array.prototype.filter
Change-Id: Ie7d8dd4193a81bedbb75258494bd78e8236bd0e8
2013-01-22 15:55:11 -08:00
Catrope aa372b6c16 Actually use this.nodeFactory and this.annotationFactory in ve.dm.Converter
Change-Id: I138a437d2e64577ad905ff70ecedf1eb7e6c8360
2013-01-22 15:55:11 -08:00
Catrope 5a5b4b577a Drop name parameter from ModelRegistry.register(), use .static.name
Change-Id: I74eeab1195455072ae48ac0655582f2bf01806d6
2013-01-22 15:55:11 -08:00
Catrope 819b3ded33 Move matching code from AnnotationFactory to ModelRegistry
ModelRegistry registers both annotations and nodes, and performs
matching on both at the same time. It also registers annotations with
the AnnotationFactory, and nodes with the NodeFactory.

Change-Id: I5e68e506a0e573cc0afe6304ccea058ffc20d1c8
2013-01-22 15:51:37 -08:00
Trevor Parscal bf5ba1ea2b Fixed documentation errors
Many of these problems were introduced in I859b5871a9d2f17d970c002067c8ff24f3513e9f

Change-Id: Ifc2dc4934f782c4ce5107e3a356e357aef754083
2013-01-22 23:38:01 +00:00
jenkins-bot 721e69cd9e Merge changes I8ee4796a,I2629c5fd
* changes:
  Make defaultAttributes a static property as well
  Replace nodeFactory invocations with direct static access
2013-01-22 23:23:13 +00:00
jenkins-bot d15b02a374 Merge "Convert node rules to static properties" 2013-01-22 23:22:33 +00:00
jenkins-bot 12b25cc6e8 Merge "Add annotation-like static properties to nodes" 2013-01-22 23:21:17 +00:00
Rob Moen 464471b538 Enable VisualEditor in MediaWiki integration for IE 9 and up.
Change-Id: I987223589c2a6b61dde5e2db8234cca40e237eec
2013-01-22 12:59:03 -08:00
Catrope c1b6e95042 Make defaultAttributes a static property as well
Change-Id: I8ee4796a93d55db9be6e43c78f3ac7bb29a65c6f
2013-01-18 14:51:40 -08:00
Catrope 51f4b4be54 Convert node rules to static properties
Change-Id: If7d0159e984d9ccb4d5c31effb62bb9612260fda
2013-01-18 14:51:40 -08:00
Catrope de6193734d Add annotation-like static properties to nodes
Add static properties for matching, data<->DOM conversion, and name. Use
matchTagNames, toDataElement and toDOMElement. name isn't used yet.

Change-Id: I5e7df3303bbd65e6968e931b568c23d76003a9a4
2013-01-18 14:51:40 -08:00
Catrope 12544c9e82 Replace nodeFactory invocations with direct static access
Change-Id: I2629c5fd659bca166237cef425f7cc3aff13ba0e
2013-01-18 14:51:40 -08:00
jenkins-bot 9cd96cd253 Merge "Fix naming of phantoms" 2013-01-18 21:39:46 +00:00
jenkins-bot 7f22c8b0d1 Merge "Inline ve.dm.Document.offsetContainsAnnotation" 2013-01-18 21:39:22 +00:00
Christian Williams 55b025fb1a Fix naming of phantoms
Change-Id: I60e925ee83fa2670eeabc5b690928f6f029b2eb4
2013-01-18 13:32:15 -08:00
jenkins-bot c6bc26ebe3 Merge "Fixes for typos and some missing documentation" 2013-01-18 21:05:13 +00:00
jenkins-bot 8a8a731a34 Merge "Convert "var\t" to "var "" 2013-01-18 21:03:55 +00:00
Catrope 594222c81d Add TriggerRegistry to tests
Fixes tests broken by 8ba81f4d67

Change-Id: Idd53d5c28941fa738b3a790977c0e7f0e65faaa9
2013-01-18 11:42:36 -08: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 fcf08e4212 Fixes for typos and some missing documentation
Lots of fixes for "it's" being used incorrectly.

ve.ce.Document.js
* Filled in documentation for missing params

ve.FormatAction.js
* Fixed incorrect tag for returns documentation

Change-Id: Ic256cc6952c31f5e6ae8be92919a0799cfe6188b
2013-01-17 15:47:34 -08:00
jenkins-bot 4aeb00dcbc Merge "Slug Todos" 2013-01-17 23:41:34 +00:00
Christian Williams 8ec2276bb5 ImageNode Todos
* Removed mousedown handler (dragging is handled in ve.ce.surface)
* Added attribute change handler to ve.ce.Node to keep attribute changes on the model in sync with the DOM

Change-Id: I1d6a7f3dc3136439ce511a4f3eb5a54797c8f996
2013-01-17 15:40:06 -08:00
jenkins-bot 96b0d8698a Merge "Add interplatform, i18n shortcuts to ui buttons." 2013-01-17 23:30:43 +00:00
Rob Moen 8ba81f4d67 Add interplatform, i18n shortcuts to ui buttons.
Objective:
* Put command shortcuts in button title attributes. (Bug 42919)
* Provide a registry for platform specific command triggers and their
corresponding i18n messages. (Bug 44012)
* Enable loading of triggers after ve.Surface is created. (lazy load)

Changes:

VisualEditor.i18n.php
* Add default trigger i18n messags for mac and pc system platforms

VisusalEditor.php, demos/ve/index.php
* Add links to files

ve.init.mw.Platform.js
* Define getUserLanguage and getSystemPlatform methods.

ve.init.sa.Platform.js
* Define getUserLanguage and getSystemPlatform methods.

ve.init.Platform.js
* Define abstract methods: getUserLangauge, getSystemPlatform

ve.ui.BoldBUttonTool.js, ve.ui.IndentButtonTool.js, ve.ui.ItalicButtonTool.js,
ve.ui.LinkButtonTool.js, ve.ui.OutdentButtonTool.js, ve.ui.RedoButtonTool.js,
ve.ui.UndoButtonTool.js
* Add registration for command triggers.

ve.Surface.js
* Methodize loading of triggers.
* Bind register event to ve.triggerRegistry to allow lazy loading of triggers.

ve.ui.Tool.js
* Init pre-registered tooltip messages.
* Update tool titles when new triggers are loaded.

ve.CommandRegistry.js
* Remove command registration ( moved to buttons themselves )

ve.TriggerRegistry.js
* New class for registering triggers.

ve.init.mw.ViewPageTarget.js
* Changed instance of unindent command to outdent.

Change-Id: Id8580a3f81aac751db0b7482422a73912648dfed
2013-01-17 15:28:32 -08:00
Christian Williams e4ef6163a0 Double spaces optimization
Moved the sequential space check into the whitespaceHtmlChars and htmlChars loop

Change-Id: I835cccf868fed851f25f5ccbba1386697b0ea66b
2013-01-17 15:16:33 -08:00
Christian Williams b80f2ef7dd Reorganization of ve.ce.Surface methods
Logical grouping for Init, Browser Events, Custom Events, Utilities, Helpers, Getters, and Setters. This may be a precursor to a future, larger refactoring.

Change-Id: I059f88a604f0b5bc383eb3ae274bab0fe2dc476b
2013-01-17 15:12:03 -08:00