Commit graph

91 commits

Author SHA1 Message Date
Roan Kattouw 534f0bdde7 .change( null, foo ) -> .setSelection( foo )
Change-Id: Iaba76ac17888a7825f5a9cd1c383d4f429454278
2013-10-25 18:29:49 +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
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 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
Trevor Parscal efafed3231 Remove ve.{inheritClass,mixinClass} and use OO instead
Change-Id: I8df9226a358a76b661eab6e967ff0d63d361f691
2013-10-18 18:58:08 +02:00
jenkins-bot 47cccb4feb Merge "Cleanup on save dialog cruft & fix updateWatchLink" 2013-10-16 23:17:22 +00:00
Rob Moen 351bf3195f Cleanup on save dialog cruft & fix updateWatchLink
Change-Id: I730003726db0164e1bef8bddcd45e31df1373618
2013-10-16 15:32:39 -07:00
jenkins-bot 1f8d2fd9a7 Merge "Log DOM save timing; update existing ve.track calls" 2013-10-16 14:50:16 +00:00
Ori Livneh b001b2b976 'clearMessage' is a method of MWSaveDialog, not ViewPageTarget
Fixes a small casualty left behind by 972c9a46b7.

Bug: 55726
Change-Id: I8cf8418dede002068fb1090d940b09c3bb91c196
2013-10-15 10:53:44 +00:00
Ori Livneh c27661507b Log DOM save timing; update existing ve.track calls
* For consistency with target.loading, target.saving should be either a boolean
  false or a jqXHR, with the latter type indicating a pending save attempt.
* Rename 'DOM Retrieved' topic to 'performance.parsoid.domLoad' (and thus
  inaugurate a convention of hierarchical, dot-separated topic names).
* Add a 'performance.parsoid.domSave', which is a near-mirror of domLoad, but
  measures the time it takes to save a DOM.
* Remove three old ve.track events, because they are not used and because their
  name and signature are not consistent with current usage.
  - page-save-attempt
  - page-save-success
  - page-edit-impression

Change-Id: I54602394eee5d6d9229c01d868cb366c9f56b2c3
2013-10-11 15:16:05 -07:00
Ed Sanders 972c9a46b7 Make the save dialog an actual dialog
Major changes:
* Create a MW specific save dialog class
* Widgetize save dialog elements
* Simplification of viewPageTarget

Minor changes:
* Added getWindow method to windowSet and setTitle methods to window class
* Add transition css properties to dialog styles

Bug: 48566
Bug: 50722
Bug: 51918
Bug: 52175
Bug: 53313
Change-Id: I8c0db01fb8477a9b3d3dfe2a6073ac67869ce40e
2013-10-07 15:59:00 -07:00
jenkins-bot 00b6de429b Merge "Use FlatLinearData for storing converter results" 2013-10-07 14:47:21 +00:00
jenkins-bot fb18831143 Merge "mw.ViewPageTarget: Fix broken firstHeading transition" 2013-10-07 10:30:17 +00:00
jenkins-bot 0b09b597a1 Merge "mw.ViewPageTarget: Fix incomplete teardown sequence in #deactivate" 2013-10-07 10:28:46 +00:00
Timo Tijhof b169a01907 Follow-up 6ec34a3de: Fix bug and exception in edit notice button
After 6ec34a3de the edit notice button was no longer hidden by
default if there were no notices. The alert icon was always
visible (when clicked it would show "0 notices").

In addition, on any page (except pages with edit notices) it
would throw a fatal exception at load time because method .hide()
doesn't exist.

As a result, current master shows an incomplete toolbar (e.g. not even
a Save button!)

Change-Id: Ib6e91c4756664c25fbb7403ef54b4fffcc0f9938
2013-10-07 00:28:23 +00:00
Timo Tijhof 66ff702561 mw.ViewPageTarget: Fix broken firstHeading transition
Class ve-init-mw-viewPageTarget-pageTitle added various
transition settings that were never used. Meanwhile, we're doing
fadeTo which sets inline opacity css every X ms until the
animation is finished.

* Changed the inline jQuery animation  to use css transitions
  instead.
* Removed the inexistent and obsolete ms-transition declaration.
* Removed ":visible" from selector query. This makes the selector
  more performant (since :visible is a proprietary Sizzle keyword)
  and it was obsolete anyway. The classes don't affect display none/hide,
  this is handled naturally by the browser now.

Change-Id: Ibdfb442ff6c743ef16b514a7696796ee27821887
2013-10-06 22:59:13 +02:00
Timo Tijhof 7f01c9fadc mw.ViewPageTarget: Fix incomplete teardown sequence in #deactivate
When deactivating before the surface became active (e.g.
this.active is still false, as case is the case when Parsoid
isn't running), the teardown sequence was incomplete.

Most notable, the page title (h1.firstHeading) was still dimmed
after cancelling the alert for Parsoid error, eventhough
everything else was shown and restored.

* Moved call to #showTableOfContents in #deactivate up for
  consistency with #activate.
* Added call to #restorePageTitle in #deactivate so that the
  title is restored even if the surface didn't activate yet.
* Removed calls to various methods in #tearDownSurface that
  were already called by #deactivate.

Now activate/deactivate and setUpSurface/tearDownSurface are
in balance.

Change-Id: Ibb2fbf0e5ab9b6a028d4e139c13aa7ff8c82be82
2013-10-06 21:50:06 +02:00
Ed Sanders 44b1fdebe4 Use FlatLinearData for storing converter results
Previously we returned ElementLinearData from the converter, then
stripped out the MetaLinearData. This meant that before processing
the ElementLinearData from the converter actually contained metadata
which is confusing.

The new document constructor stores the converter results in a
FlatLinearData object and simultaneously populates element and meta
data stores.

Also in this commit I have moved various methods from ElementLinearData
to FlatLinearData, from which ElementLinearData inherits.

Change-Id: I64561bde2c31d8f703c13ac7b0a0c5f7ade9f3d4
2013-10-06 20:27:32 +01:00
Trevor Parscal 6ec34a3dee Toolbar action widgetization and UI refactoring
Objectives:

* Use widgets to render toolbar actions
* Remove labels next to help notices and edit notices buttons
* Add a close button to the help notices and edit notices

Overview:

* ve.ui.ButtonWidget is now abstract, use ve.ui.PushButtonWidget instead
* ve.ui.IconButtonWidget now inherits from ve.ui.ButtonWidget
* ve.ui.PopupWidget's display method no longer takes x and y arguments
* Fixup naming issues in MWCategoryPopupWidget
* Fixup naming issues with some ve-init-mw CSS classes
* Rename ve-mw/ui/styles/ve.ui.Widget.css to ve.ui.MWWidget.css
* Change uses of "callout" to "tail"
* Add hyperlink functionality to buttons
* Make buttons accessible through focusing, but make unfocusable by
  clicking
* Add head option to popup for rendering a title and close button

Bug: 52386
Change-Id: Iea2c8df1be64d40f9c039873d89ee540cc56e687
2013-10-04 16:26:13 -07:00
jenkins-bot 48c60153a6 Merge "Extend SurfaceToolbar into TargetToolbar" 2013-09-23 23:48:41 +00:00
Ed Sanders 4d1d632ebd Extend SurfaceToolbar into TargetToolbar
Toolbars may want to control the target as well as the surface (spoiler alert!).
The new TargetToolbar has a pointer to its target as well as its surface.

Change-Id: I928316d9e23ac3f3de3e76c34ef0ac3d27855ab3
2013-09-17 17:05:01 +01:00
Ed Sanders eeb3ac3b19 Hide version info if not available
Sometimes GitInfo returns a version ID of false if it can't
find the right files. In this case we should hide the whole
message as it is meaningless.

Bug: 53050
Change-Id: I71161df7588aa9311bc1fdf6b064cc6d8c155f61
2013-09-16 16:53:20 +01:00
Trevor Parscal 8dfbc5baa5 Make tools generic and add fancy tool groups
Objectives:

* Got rid of mw prefixing in tools, inspectors and dialogs
* Simplify tool classes so they can be generically used as items in bars, lists and menus
* Add support for a catch-all toolbar group
* Simplify tool registration, leaning on tool classes' static name property
* Move default commands to command registry
* Move default triggers to trigger registry
* Get language tool working in standalone

Change-Id: Ic97a636f9a193374728629931b6702bee1b3416a
2013-09-03 11:27:39 -07:00
Ed Sanders a72099af66 Expose version information in the client
By passing in the information via a ResourceLoaderModule this
gets around any concerns with performance (version information
is read from the file system).

The version information is appended to the beta toolbar dialog.

Bug: 53050
Change-Id: I7836e1d4003416cbb7e18e3435aa87d82fd5c2e2
2013-08-29 18:19:40 -07:00
Trevor Parscal 3886821b9b Use mw specific names for commands
Objective:

* Use the MW link specifically, since the target/command system doesn't
  understand the group/id/extension concept yet

Change-Id: I8b756fa0bb55468312bb30d45ac5b943ff7362b5
2013-08-21 23:53:53 +00:00
Trevor Parscal 332e31fb00 Toolbar API
Objectives:

* Make it possible to add items to toolbars without having to have all
  toolbars know about the items in advance
* Make it possible to specialize an existing tool and have it be used
  instead of the base implementation

Approach:

* Tools are named using a path-style category/id/ext system, making them
  selectable, the latter component being used to differentiate extended
  tools from their base classes, but is ignored during selection
* Toolbars have ToolGroups, which include or exclude tools by category or
  category/id, and order them by promoting and demoting selections of
  tools by category or category/id

Future:

* Add a way to place available but not yet placed tools in an "overflow"
  group
* Add a mode to ToolGroup to make the tools a multi-column drop-down style
  list with labels so tools with less obvious icons are easier to identify
  - and probably use this as the overflow group

Change-Id: I7625f861435a99ce3d7a2b1ece9731aaab1776f8
2013-08-20 16:08:26 -07:00
jenkins-bot 916d1c2b69 Merge "Create a subscript tool" 2013-08-16 02:16:25 +00:00
jenkins-bot c01499fb66 Merge "Create a superscript tool" 2013-08-16 02:15:42 +00:00
jenkins-bot ffc513fcf3 Merge "Create an underline tool" 2013-08-16 02:13:02 +00:00
Ori Livneh 825322d4ac Use internal ve.track to log events
This patch rounds off change I29740fa7a by replacing calls to EventLogging's
eventLog.logEvent with calls to VisualEditor's ve.track. ve.track publishes
events by providing an interface, ve.trackRegisterHandler, which event handlers
use to subscribe to VisualEditor events. By making it the responsibility of the
web analytics framework to register itself as a handler, VisualEditor can
remain decoupled from (and indeed ignorant of) any particular event logging
implementation. This allows VisualEditor to be integrated with many different
web analytics platforms with nothing more than a bit of glue code for mapping
ve's event semantics to those of the target platform.

The practical difference that this makes is that it frees VisualEditor from
having to know about EventLogging or from having to load EventLogging
components, which means we can remove quite a lot of gnarly code. My current
plan is to migrate the code for registering and loading the 'Edit'
schema module to Extension:CoreEvents, which is also where I'll commit the
handler for VE events. (CoreEvents exists precisely to provide an organized
place for persistent but WMF-particular instrumentation.)

Once this patch is merged and deployed, the following two configuration
variables may be removed from mediawiki-config:

- $wgVisualEditorEnableSplitTest
- $wgVisualEditorEnableEventLogging

Change-Id: Idfdf692668d2adfbe029e8f0c4ff9e96c60ff741
2013-08-15 19:43:36 +00:00
James D. Forrester 23af88edc3 Create a subscript tool
Bug: 51612
Change-Id: Ia05e09a411213cbc035ad9dd3d3156d57f8e102c
2013-08-15 19:40:15 +00:00
James D. Forrester 34a37471c6 Create a superscript tool
Bug: 51611
Change-Id: I74b6418542927eeeb7e80d664a30fcaf07b93a13
2013-08-15 12:36:35 -07:00
Steven Zhang 3c65d830f2 Create an underline tool
Bug: 51609
Change-Id: I65246d7eeb154950c35a1cb70909a113080c2323
2013-08-15 12:16:01 -07:00
Ed Sanders 0d1617a627 Hieroglyphics support
Mostly as a demonstration of how easy this is with MWExtensionNode.

The icon was chosen with the following criteria:
1. Recognisable (the ankh is quite common in popular culture, right?)
2. Doesn't look idiotic to academics (I've consulted an Egyptology
   PhD and they can confirm it's not the glyph for penis)
3. Renders well at <16x16

That said it does look a little like a stick man...

Bug: 43118

Change-Id: I9f9e8af501401866bfeecf0eec3690a705fbd4db
2013-08-07 09:43:04 +00:00
peter-coti 5014e122e3 Create strikethrough text style button
Experimental to avoid making toolbar too long

Bug: 51610
Change-Id: I1eb5b1361d6058a6e1533ab62c0aa7e21c9fc090
2013-08-07 16:14:19 +08:00
Trevor Parscal 2717ea1645 Add ve.ui.ToolGroup and use within toolbar setup
Objectives:

* Use a class for toolbar groups to add more functionality later
* Rename addTools method to setup

Changes:

*.php
* Add link to new file
* Move ui element classes up for more general use

ve.init.mw.ViewPageTarget.js, ve.init.sa.Target.js, ve.ui.Context.js,
ve.ui.SurfaceWidget.js
* Update use of addTools method

ve.ui.Tool.css, ve.ui.Toolbar.css
* Move styles between sheets

ve.ui.Toolbar.js
* Rename addTools to setup
* Use ve.ui.ToolGroup objects when building tools

ve.ui.ToolGroup.js
* New class, encapsulates tools

Change-Id: Ic3a643634a80a8ac7d6f6f47f031d001c7efaee7
2013-08-07 05:08:20 +00:00
Trevor Parscal a226716d70 Split ve.ui.Toolbar and ve.ui.SurfaceToolbar
Objective:

* Make it possible to make a toolbar without a surface

Changes:

*.php
* Links to new file

ve.ui.Toolbar.js, ve.ui.SurfaceToolbar.js
* Split toolbar into generic and surface specific classes

*.js
* Update symbol names

Change-Id: Ice063a2fb67b5ce5155cdc96a0d47af49eee48cb
2013-08-02 14:33:25 -07:00
James D. Forrester ceb62980ed Make the link to the user guide open in a new window
Bug: 52475
Change-Id: Ia83ec459edb730bbc2adf5712586fdac269b7e00
2013-08-02 12:53:09 -07:00
Rob Moen 5231d05bbe Beta welcome dialog
For configured wikis, show a dialog that welcomes the user to the
amazing and fantabulous world of VisualEditing, which is not only full of
wonderment and joy but also may lead to increased popularity and love.

The dialog only shows up once (uses a cookie).

Change-Id: I8e7c4dc2c63b36594378a543b9d66291395eebcf
2013-08-01 21:08:15 -07:00
Roan Kattouw ced2a8aa59 Move edit tab generation into PHP and make it more configurable
* Generate the edit tabs and the section edit links in PHP, with a
  fallback in JS for cases where we don't have them yet due to
  caching. But only change things if VE is enabled, and have the JS
  correct the state if the wrong cached HTML comes through.
* Make the order of the tabs/links and the messages to use as captions
  configurable
* Make the edit tabs and section edit links always be present in the
  page (regardless of namespace, user prefs, etc.) but be hidden and
  have JS unhide them (using html.ve-available) if appropriate
* Add appendix messages so we can do a superscript "beta" even in places
  where we can't use HTML in the message

VisualEditor.php:
* Add new hook registrations
* Remove edit link caption messages from the init init module because
  they're now added dynamically in VisualEditor.hooks.php
* Add a noscript CSS module so we can hide some things in JS-less
  environments
* Remove $wgVisualEditorTabLayout and replace it with
  $wgVisualEditorPosition
* Add config vars for link captions, with null causing us to use
  the default caption
* Add config vars for link caption appendices. Too many config vars
  but we'll clean that up later

VisualEditor.hooks.php:
* Dynamically add tab messages to the init init module
* Remove unused globals in onBeforePageDisplay()
* Add noscript CSS module
* Add a SkinTemplateNavigation hook that changes and reorders the edit
  tabs as appropriate
* Add a DoEditSectionLink hook that overwrites the edit section links
* Export the new config variables to JS

VisualEditor.i18n.php:
* Add beta appendix message
* Add a message for the default VE edit section link

ve.init.mw.ViewPageTarget.init.css:
* Remove the animation on the edit section links
* Darken the color of the brackets and the pipe from #ccc to #555
* Style the beta message to be superscript-like (but not real <sup> to
  avoid moving the baseline)

ve.init.mw.ViewPageTarget.noscript.css:
* Hide the VE edit tab, the pipe and the VE edit section link initally
  unless and until JS unhides

ve.init.mw.ViewPageTarget.init.js:
* Toggle .ve-not-available / .ve-available
* Edit tabs
** Only generate the the edit tabs if they're not already there from PHP
** Rewrite the edit tab generation to mirror what's being done in PHP
* Section edit links
** Same as for edit tabs
** Also add mw-visualeditor-expanded to pad the brackets

ve.init.mw.ViewPageTarget.js:
* #ca-ve-edit is now always the VE tab (and #ca-edit always the
  edit source tab) so update the .selected behavior accordingly

Change-Id: Idcb15faea7fabe5fe7578b1508079969b27d2469
2013-08-01 21:08:13 -07:00
Timo Tijhof c9cd496fdc ve.ui.Toolbar: Emit position event on toolbar instead of surface
mw.ViewPageTarget is currently getting events from both the
platform target toolbar and context menu toolbar because the
event is emitted from within the toolbar to the surface.

Instead we're now emitting it on the toolbar itself and it is up
to the binder to access the correct one and listen to its events.

Bug: 52317
Change-Id: Ibd8053768e82b1df91081bd77a172628ea855db7
2013-07-31 21:59:30 +00:00
Timo Tijhof 301eaa4088 mw.ViewPageTarget: Emit position event after toolbar is animated
In target#setUpSurface, both target#setUpToolbar and
target.surface#initialize are called. #setUpToolbar does an
asynchronous animation.

After that animation is completed we call target.toolbar.initialize
and target.surface.context.update.

Right now ce.ProtectedNode needs to update the position of its
shields when the CE Surface changes position (which it does when
the UI Surface changes position because of the UI Toolbar changing
position), and does so by listening to toolbarPosition.

Adding this event to allow it to listen to that instead.

Change-Id: I826986794630c04c34cef6da36ccb15ff7dde49a
2013-07-31 22:15:33 +02:00
jenkins-bot 6828804d27 Merge "Language Inspector UI" 2013-07-31 07:14:56 +00:00
jenkins-bot b3fef14dad Merge "Fix badtoken handling broken by 7557dd39ed3" 2013-07-30 23:51:32 +00:00
Roan Kattouw e23df9f5a7 Fix badtoken handling broken by 7557dd39ed
7557dd39ed make the badtoken handling code unreachable. Revert that
change, and fix the rest of the function to deal with the possibility
that editApi is undefined. Let handling of the read-only mode error
and any other errors fall through to the bottom of the function.

Change-Id: I0673f2bb629e5cc9449675c1074d283e3926e1d5
2013-07-30 16:46:31 -07:00
Ed Sanders 0d30e1e77d MWMath cleanup
VisualEditor.php
* Add CSS file

ve.ce.MWMathNode.js
* Wrap the image in a span, so GenerateContentNode doesn't
  try to nest an image inside an image
* Remove unnecessary attribute setting
* Only pass unwrapped image to deferred.resolve
* Retrigger MathJax rendering

ve.ce.Node.css
* Use inline-block for image wrapper

ve.dm.MWMathNode.js
* Mixin GeneratedContentNode and implement getHash
* Copy over functionality of MWTransclusionNode:
  + Just store data-mw for attributes
  + Store orignal(DomElement|MW|Index) for selser

ve.init.mw.ViewPageTarget.js
* Add mwMath to the toolbar

ve.ui.MWMathInspector.js
* Remove static.InputWidget, not required in this architecture
* Use multiline TextInputWidget
* Only update mw attribute
* Allow creation of new math nodes

ve.ui.MWInspector.css
* Set height of TextInputWidget

Change-Id: I520f8ccc9f89a2ce70aa1d9e02ed0c6cacbecc2f
2013-07-30 23:47:37 +01:00
jenkins-bot e8d9f09ecf Merge "ve.ui.Toolbar: Refactor floating logic for performance" 2013-07-30 22:31:47 +00:00
Timo Tijhof bdd7aa5e3c mw.ViewPageTarget: Fire 'wikipage.content' hook after saving
Bug: 51565
Change-Id: I5b6dcd3cb425d2763cc3069e3cbc04be7a57af4c
2013-07-30 19:35:31 +02:00
Ed Sanders f5c8af541a Set links in wikitext warning to load in new window
Bug: 52093
Bug: 49820
Change-Id: I20ef246b6382ce801ce7a2cb0c82bc698471b88e
2013-07-30 13:11:53 +00:00
jenkins-bot 40e712985c Merge "Add keyboard shortcut for 'clear' button" 2013-07-30 00:51:19 +00:00