Commit graph

173 commits

Author SHA1 Message Date
Ed Sanders 706b64e82c Change document title on surface setup/teardown
Now reads "Creating/Editing Title - Sitename".

Bug: 48272
Change-Id: I9dcc8ec2c37a7ff9cff6cedb7bdb1fed1bdc4deb
2013-05-18 12:29:47 +01:00
jenkins-bot 0a8e596ffc Merge "Fix old copy/paste documentation errors" 2013-05-18 10:23:37 +00:00
jenkins-bot 44aac53bbe Merge "Fix various issues with prematurely aborting VE load" 2013-05-18 10:21:54 +00:00
jenkins-bot 9a3d7c288e Merge "Fix bytelimit status update" 2013-05-18 10:20:27 +00:00
jenkins-bot bbfdb30f87 Merge "Change 'Edit source' to 'Create source' for new pages" 2013-05-18 10:19:01 +00:00
Ed Sanders d8658a9fb0 Fix bytelimit status update
We need to listen to the same events as bytelimit. Specifically
we were missing keyup, which meant the counter could get stuck on
-1.

Bug: 47718
Change-Id: I3d4f3f8cd451bfb6acea19ee9baae7be60adcf15
2013-05-18 10:18:59 +00:00
Ed Sanders 356c279046 Always enable save button on oldid pages
Was previously enabled on creation but could be disabled
by state changes.

Bug: 48584
Change-Id: I67c011ac655d4e553f9467cab10a875aaac61d03
2013-05-17 21:00:26 +01:00
Ed Sanders e968fc717f Change 'Edit source' to 'Create source' for new pages
Bug: 47421
Change-Id: Iafba040cb8eb53017f38f2099a473e0e43e2ec46
2013-05-17 18:43:41 +01:00
Ed Sanders 1db0ced8cc Fix various issues with prematurely aborting VE load
Add checks to make sure parts of the target are acutally
active before trying to tear them down or use them.

This fixes a couple of issues which appeared when the VE was
closed before it had a chance to finish loading.

Bug: 48520
Bug: 47813
Change-Id: Ide5def0e983bab49108b40008fc170957c7fc2a2
2013-05-17 17:48:27 +01:00
Ed Sanders 5d41f902ee Fix old copy/paste documentation errors
Three methods in ve.init.mw.ViewPageTarget have incorrect descriptions.

Change-Id: Ie2e7835a7c6fa7387d48936dbe65649a150eec79
2013-05-17 16:38:48 +01:00
Inez Korczyński 9f16ff5150 Keep veaction=edit in the url when VE runs in debug mode so it keeps user just refresh the page in order to get into the edit mode.
Change-Id: I32c7135c3b989348d2d5722977cec2f81f08c162
2013-05-16 15:02:14 -07:00
Trevor Parscal a56e795f58 ve.Editor
Objectives:

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

Some change notes:

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

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

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

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

Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
2013-05-15 10:39:12 -07:00
jenkins-bot 7cc65631bf Merge "Return proper error if parsoid is unavailable on serialize" 2013-05-15 17:26:18 +00:00
jenkins-bot e6004016ca Merge "Use new options format for toolbar in mw init" 2013-05-15 17:20:53 +00:00
Ed Sanders 201a1ac478 Return proper error if parsoid is unavailable on serialize
Previously was just returning an empty result.

Bug: 47581
Change-Id: I6bdd177bc9b5a0af9107cf08d8e46470c6778e12
2013-05-15 16:28:51 +01:00
Ed Sanders cc943418cf Use new options format for toolbar in mw init
Wasn't updated after change 63095 and so wasn't setting options.

Bug: 48509
Change-Id: Icda3305e422bedaf0d490b8fbe51f55b8c8e79e8
2013-05-15 14:52:39 +01:00
Ed Sanders eeb1f3a142 Implement 'minordefault' user preference
Marks all edits as minor by default if the user preference is set.

Bug: 48347
Change-Id: Ib5cdcb9433be5ff7b9179d3833f42e5c3453285a
2013-05-15 13:40:54 +01:00
Ed Sanders f675d73204 Move no changes message to separate save dialog slide
Previously it was just being returned as the diff html, which
looked weird becacuse 1: it was the wrong width and 2: the
save buttons were still there.

Bug: 43754
Change-Id: I537bcae91f51a3f30ca4736c41f7a5619bbf321d
2013-05-14 16:40:14 -07:00
Ed Sanders ea6e1b26ed Move edit conflict notice to a save dialog slide
Previously used a confirm() dialog which is a bit ugly.

Bug: 42522
Change-Id: I709d936d998b130515b62de880c6e7aa7978786b
2013-05-14 16:31:58 -07:00
Trevor Parscal 5012ed101b Floating toolbar cleanup
Objective:

Move toolbar floating functionality to ve.init and clean it up

As a bonus:

demo.css
* Fix CSS path to set width of inputs properly

Changes:

demos/ve/index.php
* Allow ve.init.sa.Target to construct it's own surface object

ve.ce.Surface.js
* Move object resizing and table editing disabling commands from ve.Surface
* Add method for getting the currently focused node

ve.init.mw.ViewPageTarget.js
* Remove initializing surface property (now done in parent class)
* Normalize all uses of "setup" to "setUp"
* Replace uses of getDocumentModel with getModel().getDocument()
* Add calls to set up and tear down for toolbar floating

ve.init.mw.Target.js
* Replace uses of getDocumentModel with getModel().getDocument()

ve.init.sa.Target.js
* Move example from ve.Surface
* Change constructor to accept document model
* Create ve.Surface object in constructor
* Add set up for toolbar floating

ve.ui.init.Target.js
* Initialize surface property
* Move and cleanup toolbar floating functionality from ve.Surface

ve.ui.Surface.js
* Remove example now that init.sa creates it's own surface (moved)
* Document options
* Simplify toolbar options and remove the concept of multiple toolbars
* No longer cache the options object
* Move toolbar initialization to constructor
* Change setupCommands to addCommands, making it useful after construction
* Inline selection initialization
* Move and cleanup toolbar floating functionality to ve.ce.Surface
* Reorganize a few methods
* Move toolbar floating to ve.init.Target.js

Change-Id: I393a426e35567d57c048122bf64a83c1ef45e6e8
2013-05-14 12:43:30 -07:00
Ed Sanders 375a7fceff Access keys for edit and edit source
Set up 'v' for edit, and 'e' for edit source as access keys.

Bug: 48107
Change-Id: I598177bc75ed84dea35952a3b2b1b2111aac89b2
2013-05-10 17:10:26 -07:00
jenkins-bot 89aebd5112 Merge "Edit and Edit source tab were reversed in RTL in the Vector integration" 2013-05-10 23:49:30 +00:00
jenkins-bot 57b05aa433 Merge "Clean up variable initialization in setupSkinTabs()" 2013-05-10 20:31:03 +00:00
Catrope 2efd4f0061 Edit and Edit source tab were reversed in RTL in the Vector integration
If we're in RTL mode and the skin is Vector-based, we need to reverse
the order of the tabs in the DOM, because that's a weird thing that
Vector does to render tabs in RTL.

See https://bugzilla.wikimedia.org/show_bug.cgi?id=46947 for discussion
about the Vector behavior.

Bug: 48017
Change-Id: Ie1214b08450aefed893739a2b862cb1e9b23a2ef
2013-05-10 11:43:05 -07:00
Catrope b295dc8d99 Clean up variable initialization in setupSkinTabs()
Change-Id: Ic596f1c98162557f33f5ca398d2358e91a3d5cb0
2013-05-10 11:43:01 -07:00
Catrope a65ff4fdb9 Use pageLanguage rather than pageViewLanguage for the surface's lang&dir
Bug: 33175
Change-Id: Ica006404227dcd286c387de4f637036341b17eae
2013-05-10 11:04:31 -07:00
Timo Tijhof 6467a5a0e4 ViewPageTarget: Bind callback in onSerialize like in onShowChanges
init.mw.Target#serialize is an odd one because it is the only
target method that has a callback parameter (instead of
emitting the event on Target and having ViewPageTarget get
the event through that).

This line from onShowChanges needed to be added to onSerialize

  // Invalidate the viewer wikitext on next change
  this.surface.getModel().connect( this, { 'transact': 'onSurfaceModelTransact' } );

Though onSerialize is currently bound manually from the
serialize callback, it should be refactored to be like the others.

Bug: 44446
Change-Id: I9eddebbdf9294ee3d46286bdf1b157e00252d300
2013-05-08 20:28:28 +02:00
jenkins-bot fdb6b845de Merge "Adjust binding to section edit links after changes in core" 2013-05-06 18:00:40 +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
MatmaRex a90ee007cf Adjust binding to section edit links after changes in core
Match the new .mw-editsection class, after core change I6a6c12a9.

Change-Id: I22daf7f9bc720b2be35695ca78c5603e80999986
2013-05-04 19:37:49 +02:00
jenkins-bot 46dce49462 Merge "Edit source tab should be 'selected' when... selected" 2013-05-03 17:40:50 +00:00
Ed Sanders 33bfeeed41 Update oldid on successful page save (if a new id is generated)
New ID is now passed from the API to the save event, to the onSave
handler. Empty diffs won't generate a newrevid.

Bug: 47420
Change-Id: I12ce27c8dc57f7aa753bcf5840635d5fea6b4e80
2013-05-03 18:10:10 +01:00
Ed Sanders 9dc93451c4 Edit source tab should be 'selected' when... selected
VE recreates the tab from scratch and deletes the old one
so as not to copy over access key settings. This fix
copies over classes from the old tab.

Bug: 47452
Change-Id: Ic2d42bb3034be25f388b587a00c3f523cfcc163c
2013-05-03 13:15:54 +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
James D. Forrester 73cb0c7506 Make the feedback link language-variable for release
This involves setting some i18n messages for the target languages based on the
translations already provided - I hope this doesn't break anything for TWN but
the need for this only just became apparent; apologies!

Longer-term we will need to come up with a better way of doing this, if we are
keeping the in-VisualEditor feedback link around.

Change-Id: Id6ed80cdcd4314e84e75fb718421767162d73ef3
2013-04-25 09:02:28 -07:00
Timo Tijhof c1383b8012 ve.init.mw.ViewPageTarget: Account for serialize error
This is showing a separate need for refactoring. We call
"this.serialize( ..., callback )" but if it failed callback
is never called and an event is emitter for the error.

That makes it rather disconnected from each other.

In this case we're lucky that all calls to serialize are similar
in nature and need the same kind of error callback but other
wise this would be pretty messed up. It obviously needs to be
untangled and get rid of this akward eventemitter dance.

This doesn't fix bug 47581, but it does fix the "Infinite loader
with no error" problem as a result of it by handling the error
in a more intuitive way.

Bug: 47581
Change-Id: Icdf64a792c13a326f494e051be47f2946928d142
2013-04-24 02:06:12 +02:00
jenkins-bot bb34823cbb Merge "ViewPageTarget: Refactor 'replace' tabLayout" 2013-04-23 19:11:14 +00: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
Timo Tijhof cc37ba242b ViewPageTarget: Refactor 'replace' tabLayout
The 'add' tabLayout path is pretty basic and up to date. The
older (now active again) tabLayout 'replace' was fairly outdated
and unmaintained.

Fixes:
* Attributes copied from the original (except for the 'id'
  attribute) were not actually beinged copied over because they
  don't exist on the ca-edit list item, but on the anchor link
  inside that list item.
* Clean up messages from the module registry that were unused.
  Keys 'accesskey-ca-edit' and 'tooltip-ca-edit' were also inexistant.
* Add message keys for tooltip and accesskey of editsource tab.

Depends on I0bde1a228983c58b in mediawiki/core.

Bug: 47396
Change-Id: If598552fac639da645a8b1273c5fc6028695fcc1
2013-04-22 20:09:46 +00:00
Catrope f3b03a64f6 Move config vars that are global in nature to the startup module
If they're in the per-page config, we'll have to deal with caching
nightmares when changing them.

Change-Id: Ic8866500b1f20aee36c436dcc3d132c8fde0a8fc
2013-04-18 20:00:55 -07:00
James D. Forrester fe4dce7890 Fix broken config for this.restoring
Current set up leaves us with restoring when we're not and vice
versa. Not good. :-) (Partial fix of change 59968.)

Change-Id: Ia33a2f3318cf2e46b7469b2c773e91c5ee8fdefa
2013-04-18 17:10:29 -07:00
Catrope 93cb630aed Don't show "Restore page" button when editing most recent version
Change-Id: Iaeb11e0d5323e0276e66fc4c994d705cde68411d
2013-04-18 16:23:08 -07:00
jenkins-bot d03aaa102c Merge changes I7b0e3fa4,I559232f3
* changes:
  ve.init.mw.ViewPageTarget: Put the Edit source link in the visible tab area
  ve.init.mw.ViewPageTarget: Switch tabLayout from 'add' to 'replace'
2013-04-18 21:02:23 +00:00
Catrope cdba5f2800 When we say originalHtml, we'd better mean it
Gabriel noticed whitespace diffs in the problem reports. These were
caused by browsers' .innerHTML being broken on <pre>s. We compensate
for this in the converter, but not when generating originalHtml.

However, a variable called originalHtml really shouldn't be generated,
it should just literally be the original, unprocessed HTML. This
does mean it includes the doctype, <html> and <head> which aren't
included in editedHtml (that one's just the contents of the <body>), but
that's much easier to deal with on Parsoid's end than random newline
diffs all over the place.

Change-Id: I8e66cb79887f49f84114ab6b4d0e0d24aea744b6
2013-04-18 08:09:50 -07:00
Catrope eab968d7f0 ve.init.mw.ViewPageTarget: Put the Edit source link in the visible tab area
Instead of in the collapsed section.

Change-Id: I7b0e3fa4e35ce6135e3a47360da51fd8e0231ca1
2013-04-17 18:15:43 +00:00
Catrope 9a98d8bce4 ve.init.mw.ViewPageTarget: Switch tabLayout from 'add' to 'replace'
This makes the Edit tab point to the VisualEditor, and adds a
"Edit source" link to the p-cactions menu.

Bug: 46872
Change-Id: I559232f3d8e42df0d45311b65df8c30425b1a368
2013-04-17 10:25:36 +00:00
Catrope 2eb77c1298 Add ve.ce.View as a common base class for ce.Node and ce.Annotation
Just like ve.dm.Model is a common base class for dm.Node, dm.Annotation
and dm.MetaItem.

ce.View abstracts the this.model and this.$ behavior, including liveness,
whitelisted HTML attribute rendering and adding a back reference in
.data(). The back reference has been renamed from .data( 'node' ) to
the more generic .data( 'view' ).

At this point this means ce.Annotation is just a shell around ce.View
(except where it defaults to a span rather than a div), but that could
change in the future.

Change-Id: I0eef5b80718e0b0fcd3f8bba096b452f0bb680d0
2013-04-09 12:05:05 -07:00
Timo Tijhof 306680efd5 ve.init.mw.ViewPageTarget: Use original label for replaced tab
To verify
* Save "MediaWiki:Edit" with "Edit page" (anything not "Edit")
* Set this.tabLayout = 'replace';
* Observe that the ve-edit tab is now "Edit" (msg: vector-view-edit)
  instead of "Edit page" (msg: edit)

Bug: 42117
Change-Id: I2e7dd85cd14049101e2d49751d37797d77bc7c9d
2013-04-04 00:16:46 +02: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
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