Commit graph

4657 commits

Author SHA1 Message Date
Roan Kattouw 1bf58252ce Implement ve.dm.Surface.prototype.undo() and redo() in terms of change()
...or really changeInternal(), so we can avoid adding undo transactions
to the undo stack.

Also get rid of the pattern where undo() and redo() return a selection
which the caller then has to restore, and instead just restore the
selection.

Bug: 53224
Change-Id: If5a3b4d4162e9f0713ee9cd26e79a66efe52770f
2013-10-25 18:29:48 +01:00
Roan Kattouw b7ee30d4e4 Enslave dm.Surface to dm.Document
* Replace surface 'transact' event with 'documentUpdate' event
* Have surface listen for all document transactions and update selection
  as appropriate (as well as emitting 'documentUpdate')
* Implement change() in terms of setSelection()
** Queue 'contextChange' events so contextChange is only emitted once
** Use this.transacting flag to prevent setSelection() (which is called
   because the model emits transact events) from doing too much
** Behavioral change: lock/unlock now emitted separately for
   transaction and selection changes

Change-Id: I44425d260ec70758f99d13f99e41f5c993d260c2
2013-10-25 18:29:48 +01:00
David Chan 04cbbef4ee Remove dm.Surface's 'change' event
ve.dm.Surface.js:
* Stop emitting 'change' and remove its event documentation

ve.ce.Surface.js:
* Listen to 'select' instead of 'change'
* Perform a CE surface update after model-based keydown handling

ve.dm.Surface.test.js:
* Stop asserting that 'change' is emitted

Change-Id: I8f16289493e835d890709c6dfe093d04c18522b6
2013-10-25 18:29:13 +01:00
Roan Kattouw 53e4c370ea Migrate away from using the 'change' event in dm.Surface
Instead, listen to 'select', or to 'transact' on the dm.Document.

This commit only fixes uses outside of the dm/ce.Surface ecosystem.
ce.Surface still listens to 'change'.

ve.init.mw.ViewPageTarget.js:
* Rename onSurfaceModelTransact to clearSaveDialogDiff and bind it to
  the document's transact event instead
* Rename onSurfaceModelChange to checkForWikitextWarning and bind it
  to the surface's transact event. This is needed because the function
  inspects the surface's selection, which isn't yet in a consistent
  state when the document's transact event fires

ve.ui.MWReferenceDialog.js:
* Rename onSurfaceChange to onDocumentTransact and rebind accordingly

ve.ce.ProtectedNode.js:
* Get rid of onSurfaceModelChange
* Instead, bind positionPhantoms to the document's transact event
  directly, and only bind it while phantoms are visible

ve.ui.Context.js:
* Rename onChange to onModelSelect and rebind accordingly
* Rename afterChange to afterModelSelect
* Drop check for undefined selection, no longer needed now that we're
  listening to a finer-grained event

ve.ce.Surface.test.js:
* Listen to 'select' instead of 'change'

Change-Id: Ifeb1a1fc5427696f2aae5441d4b54dde366793e0
2013-10-23 11:54:35 -07:00
Roan Kattouw ede989445e Make dm.Surface's 'select' event more useful
It was previously emitted before the selection was updated and with the
old selection as a parameter. Instead, emit it afterwards, and make sure
it's emitted even if the selection changes because it was translated
for a transaction.

Also correct its event documentation, which seems to have been copied
from a UI class somewhere.

Change-Id: I521eff0095959572587c0ecffd24dbf322e12d82
2013-10-23 11:28:09 -07:00
Zeljko Filipin 904c5a48ad [browser test] Moving shared code to mediawiki-selenium Ruby gem
Bug: 53579
Change-Id: I4ef8b63f485b0274f252cf95e566f0484615e8cf
2013-10-23 16:43:51 +00:00
jenkins-bot 1b13df5155 Merge "Use update rather than show in focusable node re-render" 2013-10-23 15:57:19 +00:00
Roan Kattouw febc0f567f Defer selection-triggered updates in ve.ui.Context
Move selection change handling (closing the popup if open, and updating
the context toolbar) to .afterChange(). Every time .onChange() detects
a selection change, it schedules a call to afterChange(). These calls
are batched so that multiple selection changes in the same tick cause
afterChange() to be called only once.

Deferring these updates causes them to no longer occur while a 'change'
event is being emitted. This means that if an inspectors' close handler
calls .change(), that call is now no longer nested inside another
.change() call and doesn't run afoul of any render locks set by the
caller of the outer .change().

Bug: 54675
Change-Id: Iae2f41a83b5d64251a54e42303100e84a5c25561
2013-10-23 15:12:47 +00:00
Roan Kattouw a12446d795 Ignore change events while opening and closing inspectors
AnnotationInspector changes the selection from both its open and close
handlers, which can cause recursive calls to .hide() and .update()

Change-Id: Ic334f9b8b335fe1aaac2dc98dc6ea9fd9d5707ff
2013-10-23 14:41:24 +00:00
jenkins-bot fad9ae6c50 Merge "Use a sane recursion guard in ve.ui.Context.prototype.hide()" 2013-10-23 13:49:45 +00:00
jenkins-bot 7f7c29cde2 Merge "Fix typo in documentation for ve.ce.View.prototype.getModel" 2013-10-23 13:45:26 +00:00
Ed Sanders ac2a839607 Use update rather than show in focusable node re-render
Update checks if there's actually a context menu to show. We also need
to pass through the parameters for show.

This was causing the last-shown context menu to appears after resizing
an inline image (which has no context menu).

Change-Id: I8f46f71e2fba6896fe10054f0d2a679c6f23eb9c
2013-10-23 14:35:55 +01:00
jenkins-bot f3565f2ed8 Merge "Followup 1878c7c5: fix check for nonexistent property .draggingAndDropping" 2013-10-23 12:49:01 +00:00
Timo Tijhof 6560cfda2b Remove simpleArray utilities from ve.js and use oojs instead
Change-Id: I23710ff50378f4069b8a0dea89f0491884acd377
2013-10-23 03:26:53 +02:00
jenkins-bot 5bd6ea0e93 Merge "Update oojs to v1.0.5" 2013-10-23 01:19:27 +00:00
Timo Tijhof b7a4dcdbdf Update oojs to v1.0.5
Code:
  http://trevorparscal.github.io/oojs/releases/oojs-1.0.5.js

Release notes:
  https://github.com/trevorparscal/oojs/blob/v1.0.5/History.md

Change-Id: I1117bd5bef70783039db18849f85215fcb346ada
2013-10-23 03:16:21 +02:00
Roan Kattouw 20bdb78512 Followup bb03e8f: fix toolbar floating
Small mistake splitting the ooui commit, whoops

Change-Id: I166df38234f432ab2ef00e7d156e49cba16ede99
2013-10-22 23:19:22 +00:00
jenkins-bot f2be711ee0 Merge "Rename ui.Tool.static.canEditModel to isCompatibleWith" 2013-10-22 20:53:46 +00:00
jenkins-bot 30c429bd9d Merge "Rename oo.js to oojs.js per library name" 2013-10-22 20:52:53 +00:00
jenkins-bot a011603ef2 Merge "Remove oo from ve.js closure" 2013-10-22 20:52:01 +00:00
jenkins-bot ad8a95ead5 Merge "Remove ve.Factory and ve.Registry and use oojs instead" 2013-10-22 20:51:09 +00:00
jenkins-bot 6c6fcf1dbd Merge "Cache multiple requests for $resizable's offset" 2013-10-22 20:30:18 +00:00
jenkins-bot a2587ce927 Merge "Recalculate $resizable offset when positioning resize label" 2013-10-22 20:28:27 +00:00
Ed Sanders c543fef85f Cache multiple requests for $resizable's offset
Both the resize handles and the size label position themselves
using $resizable's relative offset, so we can optimise by
caching that result.

Change-Id: Ic225b15cfcece8d5c2e782e1e667d854f805c6fb
2013-10-22 20:27:36 +00:00
Ed Sanders 1efa327121 Recalculate $resizable offset when positioning resize label
Because it can change. Currently the resize label is not
positioned correctly if you use three of four resize handles.

Change-Id: I1a28bc57fda1097c94047fd7690ad8d403cdd478
2013-10-22 20:23:42 +00:00
Trevor Parscal e41d4d470f Rename ui.Tool.static.canEditModel to isCompatibleWith
Change-Id: Ic7583f0966946c870f38a2e7ad06e558238c8794
2013-10-22 21:20:09 +02:00
Roan Kattouw 36fc3b5911 Rename oo.js to oojs.js per library name
Change-Id: I9f02a4438a18243022506b5a2fcc445af03aa945
2013-10-22 19:18:32 +00:00
Trevor Parscal fae7f130e4 Remove oo from ve.js closure
Instead use OO directly. Also remove ve.createObject, which is
unused now that ve.Registry and ve.Factory have been moved to oojs.

Change-Id: I3470b6660107ddd0bdf4a43c50d191a1bb1cc4d8
2013-10-22 19:18:27 +00:00
Trevor Parscal 26a1d8986b Remove ve.Factory and ve.Registry and use oojs instead
Change-Id: I2717300e6cc6102296a2b8d063d344fa5897c825
2013-10-22 19:15:18 +00:00
Trevor Parscal b635541de2 Remove ve.getHash and use getHash from oojs instead
Change-Id: Ib688a3ba0ab07e0d0dc328a3878440756d1103fe
2013-10-22 19:14:23 +00:00
Timo Tijhof 27078af21e Update oojs to v1.0.4
Changes since v1.0.2:
* Added oo.getHash
* Added oo.Registry
* Added oo.Factory
* Bug fixes for oo.EventEmitter

Code:
  http://trevorparscal.github.io/oojs/releases/oojs-1.0.4.js

Release notes:
  https://github.com/trevorparscal/oojs/blob/v1.0.4/History.md

Change-Id: Iafc49bd148a50b19e5e9f0a0add056ad858533de
2013-10-22 19:13:47 +00:00
Timo Tijhof 7db65f386c Rename @emits to @fires so we're forward compatible with JSDuck 5
Instead of using @emits in both, use our custom @fires in
production (JSDuck 4), and in the future it'll just naturally
use the native one.

This way we can also index oojs without issues, which seems to
have started using @fires already.

Change-Id: I7c3b56dd112626d57fa87ab995d205fb782a0149
2013-10-22 19:11:16 +00:00
jenkins-bot b017dcef30 Merge "Fix save dialog crash on load error" 2013-10-22 17:26:21 +00:00
Trevor Parscal 6018e77d70 Use OO.EventEmitter instead of ve.EventEmitter
Change-Id: Ie35e5f51a8d3c0d7f4fa46230b7b37112df610b9
2013-10-22 16:57:33 +00:00
Roan Kattouw 9d915aca2d Fix save dialog crash on load error
If there was an error loading the HTML from Parsoid, ViewPageTarget
would try to tear down the save dialog, which caused a crash because
the save dialog doesn't exist yet at that point.

Change-Id: Ia50756a19cb775be96b90e87b642eb2a38f254ce
2013-10-22 01:15:35 +02:00
Roan Kattouw a34e0fd6e2 Fix typo in documentation for ve.ce.View.prototype.getModel
Change-Id: I176898bc6714bd240ca0776406d11c60f2b2fd96
2013-10-21 17:35:08 +02:00
jenkins-bot 324b04137b Merge "Add requirements to BetaFeatures hook" 2013-10-21 15:18:24 +00:00
Zeljko Filipin 421924bd69 [browser test] cursor feature was not tagged @login
Change-Id: I587ad033c93078d8e626840de3b3eedc73b83516
2013-10-21 13:04:43 +00:00
Roan Kattouw 3f5486a43f Use a sane recursion guard in ve.ui.Context.prototype.hide()
The previous recursion "guard" relied on the recursion to occur for
the function to work correctly, which was very confusing. Additionally,
it didn't actually work: if the inspector's onClose handler changed
the selection (which is common), .hide() would recurse and the recursion
guard didn't catch this (inspector wasn't undefined yet). Fortunately
all that did was call .close() on the inspector again, which was caught
by .close()'s own recursion guard.

Instead, simply use this.hiding as a recursion guard, and refactor the
function so it doesn't do two different things depending on whether it's
expecting recursion or not.

Change-Id: I09eb9229530468ee319ca53b730784a3f632375d
2013-10-21 14:10:23 +02:00
Roan Kattouw 9eac0c8c91 Followup 1878c7c5: fix check for nonexistent property .draggingAndDropping
It's always been named .relocating

Change-Id: I2fcb28cdad037880759420986d8010ee5711d691
2013-10-21 13:40:28 +02:00
Roan Kattouw d3c706ff93 Add a node type for numbered external links
Since I0f0a826c in Parsoid, numbered external links are now empty
<a rel="mw:ExtLink"></a> tags. This means we have to put in a node type
for them to prevent them from being considered empty annotations and
getting converted to alienMeta.

MWNumberedExternalLinkNode is protected and focusable to avoid making
the link text (which isn't editable) clickable. It isn't inspectable
yet, we need to work on that.

Bug: 53505
Change-Id: I83f69695f3974089e51a84e799f31ab6ed879e05
2013-10-18 22:31:45 +02:00
Trevor Parscal efafed3231 Remove ve.{inheritClass,mixinClass} and use OO instead
Change-Id: I8df9226a358a76b661eab6e967ff0d63d361f691
2013-10-18 18:58:08 +02:00
jenkins-bot 40a8e9ef12 Merge "Document constructor params for dm.MWMathNode and dm.MWExtensionNode" 2013-10-18 12:52:19 +00:00
Timo Tijhof 832f8e1e11 Document constructor params for dm.MWMathNode and dm.MWExtensionNode
Follows-up Ib909c5fb02.

Change-Id: Ia3dfbabc8dde9f1e65e8fbb0e4d67f868031247a
2013-10-18 12:44:50 +00:00
cmcmahon 828747f0f0 [Browser tests] identifier for anonymous warning changed for test2
Change-Id: Idfdd6db441205280373f8d24bf0a693b46eed1af
2013-10-18 01:31:47 +00:00
jenkins-bot b76f85c240 Merge "Split out popup functionality from ve.ui.PopupButtonWidget to ve.ui.PopuppableElement" 2013-10-17 22:15:41 +00:00
jenkins-bot 5dd44dab93 Merge "Rename performance.parsoid.domLoad to performance.domLoad" 2013-10-17 19:30:58 +00:00
jenkins-bot 8b3de827cb Merge "Use .done()/.fail() instead of 'success'/'error'" 2013-10-17 17:21:47 +00:00
Trevor Parscal 81bbba4932 Split out popup functionality from ve.ui.PopupButtonWidget to ve.ui.PopuppableElement
Change-Id: I522d852d81d9674723a3262da3f030417f4fc3be
2013-10-17 10:21:03 -07:00
jenkins-bot 107689087a Merge "Followup 8a4058584: use a single media source for rerendering images" 2013-10-17 17:20:13 +00:00