JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
/*!
|
2013-01-15 23:38:49 +00:00
|
|
|
* VisualEditor MediaWiki Initialization ViewPageTarget class.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2013-02-19 23:37:34 +00:00
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
2012-07-19 00:11:26 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2013-01-22 22:41:22 +00:00
|
|
|
/*global mw, confirm, alert */
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Initialization MediaWiki view page target.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @class
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @extends ve.init.mw.Target
|
2013-02-20 19:44:44 +00:00
|
|
|
*
|
2012-06-11 06:54:41 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2012-09-06 23:15:55 +00:00
|
|
|
ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
|
2013-05-26 15:23:03 +00:00
|
|
|
var browserWhitelisted,
|
2013-07-03 22:14:52 +00:00
|
|
|
currentUri = new mw.Uri();
|
2012-08-23 19:01:07 +00:00
|
|
|
|
2012-09-17 23:53:03 +00:00
|
|
|
// Parent constructor
|
2013-02-20 19:44:44 +00:00
|
|
|
ve.init.mw.Target.call(
|
2013-06-18 01:38:18 +00:00
|
|
|
this, $( '#content' ),
|
|
|
|
mw.config.get( 'wgRelevantPageName' ),
|
|
|
|
currentUri.query.oldid
|
2013-02-20 19:44:44 +00:00
|
|
|
);
|
2012-06-11 06:54:41 +00:00
|
|
|
|
|
|
|
// Properties
|
2012-06-19 17:50:33 +00:00
|
|
|
this.$document = null;
|
2012-12-11 00:26:09 +00:00
|
|
|
this.$spinner = $( '<div class="ve-init-mw-viewPageTarget-loading"></div>' );
|
2013-06-20 00:28:51 +00:00
|
|
|
this.$toolbarTracker = $( '<div class="ve-init-mw-viewPageTarget-toolbarTracker"></div>' );
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
this.toolbarTrackerFloating = null;
|
|
|
|
this.toolbarOffset = null;
|
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-20 23:25:12 +00:00
|
|
|
this.toolbarCancelButton = null;
|
|
|
|
this.toolbarSaveButton = null;
|
2013-06-07 19:00:38 +00:00
|
|
|
this.saveDialogSlideHistory = [];
|
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-20 23:25:12 +00:00
|
|
|
this.saveDialogSaveButton = null;
|
|
|
|
this.saveDialogReviewGoodButton = null;
|
|
|
|
|
2013-06-12 01:17:10 +00:00
|
|
|
this.$toolbarEditNotices = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-toolbar-editNotices' );
|
|
|
|
this.$toolbarEditNoticesTool = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool' );
|
|
|
|
|
|
|
|
this.$toolbarFeedbackTool = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool' );
|
|
|
|
|
|
|
|
this.$toolbarBetaNotice = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-toolbar-betaNotice' );
|
|
|
|
this.$toolbarBetaNoticeTool = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool' );
|
|
|
|
|
|
|
|
this.$toolbarMwMetaButton = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool' );
|
|
|
|
this.$saveDialog = $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-saveDialog' );
|
|
|
|
|
2012-06-21 03:16:10 +00:00
|
|
|
this.onBeforeUnloadFallback = null;
|
2013-05-01 22:21:32 +00:00
|
|
|
this.onBeforeUnloadHandler = null;
|
2012-06-11 06:54:41 +00:00
|
|
|
this.active = false;
|
2012-06-12 17:32:10 +00:00
|
|
|
this.edited = false;
|
2013-06-23 23:09:47 +00:00
|
|
|
this.sanityCheckFinished = false;
|
|
|
|
this.sanityCheckVerified = false;
|
2012-06-14 01:26:21 +00:00
|
|
|
this.activating = false;
|
2012-06-14 21:31:08 +00:00
|
|
|
this.deactivating = false;
|
2013-06-05 22:39:43 +00:00
|
|
|
// If this is true then #transformPage / #restorePage will not call pushState
|
|
|
|
// This is to avoid adding a new history entry for the url we just got from onpopstate
|
|
|
|
// (which would mess up with the expected order of Back/Forwards browsing)
|
|
|
|
this.actFromPopState = false;
|
2012-06-18 20:12:32 +00:00
|
|
|
this.scrollTop = null;
|
2012-08-23 19:01:07 +00:00
|
|
|
this.currentUri = currentUri;
|
2013-06-30 18:40:57 +00:00
|
|
|
this.messages = {};
|
2012-08-23 19:01:07 +00:00
|
|
|
this.section = currentUri.query.vesection || null;
|
2013-07-18 22:34:16 +00:00
|
|
|
this.sectionPositionRestored = false;
|
|
|
|
this.sectionTitleRestored = false;
|
2012-06-19 04:47:09 +00:00
|
|
|
this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
|
|
|
|
this.viewUri = new mw.Uri( mw.util.wikiGetlink( this.pageName ) );
|
2012-08-01 00:49:04 +00:00
|
|
|
this.veEditUri = this.viewUri.clone().extend( { 'veaction': 'edit' } );
|
2012-06-18 23:18:48 +00:00
|
|
|
this.isViewPage = (
|
|
|
|
mw.config.get( 'wgAction' ) === 'view' &&
|
2012-08-23 19:01:07 +00:00
|
|
|
currentUri.query.diff === undefined
|
2012-06-18 23:18:48 +00:00
|
|
|
);
|
2013-05-17 16:09:20 +00:00
|
|
|
this.originalDocumentTitle = document.title;
|
2012-08-17 19:30:33 +00:00
|
|
|
this.editSummaryByteLimit = 255;
|
2013-06-03 22:23:45 +00:00
|
|
|
this.tabLayout = mw.config.get( 'wgVisualEditorConfig' ).tabLayout;
|
2012-06-18 20:12:32 +00:00
|
|
|
|
2013-06-23 23:09:47 +00:00
|
|
|
/**
|
|
|
|
* @property {jQuery.Promise|null}
|
|
|
|
*/
|
|
|
|
this.sanityCheckPromise = null;
|
|
|
|
|
2013-05-26 15:23:03 +00:00
|
|
|
browserWhitelisted = (
|
2013-06-06 22:39:43 +00:00
|
|
|
'vewhitelist' in currentUri.query ||
|
|
|
|
$.client.test( ve.init.mw.ViewPageTarget.compatibility.whitelist, null, true )
|
2013-05-26 15:23:03 +00:00
|
|
|
);
|
|
|
|
|
2013-06-11 22:14:44 +00:00
|
|
|
if ( mw.config.get( 'wgVisualEditorConfig' ).enableEventLogging ) {
|
|
|
|
this.setUpEventLogging();
|
|
|
|
} else {
|
|
|
|
this.logEvent = $.noop;
|
|
|
|
}
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
// Events
|
2013-05-01 22:21:32 +00:00
|
|
|
this.connect( this, {
|
2012-06-18 20:12:32 +00:00
|
|
|
'load': 'onLoad',
|
|
|
|
'save': 'onSave',
|
|
|
|
'loadError': 'onLoadError',
|
2013-05-18 01:19:20 +00:00
|
|
|
'tokenError': 'onTokenError',
|
2012-11-28 23:57:00 +00:00
|
|
|
'saveError': 'onSaveError',
|
2012-12-07 16:23:23 +00:00
|
|
|
'editConflict': 'onEditConflict',
|
|
|
|
'showChanges': 'onShowChanges',
|
2013-04-24 00:01:44 +00:00
|
|
|
'showChangesError': 'onShowChangesError',
|
2013-05-14 17:40:00 +00:00
|
|
|
'noChanges': 'onNoChanges',
|
2013-04-24 00:01:44 +00:00
|
|
|
'serializeError': 'onSerializeError'
|
2012-06-18 20:12:32 +00:00
|
|
|
} );
|
2012-06-11 06:54:41 +00:00
|
|
|
|
2013-06-05 21:38:39 +00:00
|
|
|
if ( !browserWhitelisted ) {
|
|
|
|
// Show warning in unknown browsers that pass the support test
|
|
|
|
// Continue at own risk.
|
|
|
|
this.localNoticeMessages.push( 'visualeditor-browserwarning' );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( currentUri.query.venotify ) {
|
|
|
|
// The following messages can be used here:
|
|
|
|
// visualeditor-notification-saved
|
|
|
|
// visualeditor-notification-created
|
|
|
|
// visualeditor-notification-restored
|
2013-06-21 12:44:56 +00:00
|
|
|
mw.hook( 'postEdit' ).fire( {
|
|
|
|
'message':
|
|
|
|
ve.msg( 'visualeditor-notification-' + currentUri.query.venotify,
|
|
|
|
new mw.Title( this.pageName ).toText()
|
|
|
|
)
|
|
|
|
} );
|
2013-06-05 21:38:39 +00:00
|
|
|
if ( window.history.replaceState ) {
|
|
|
|
delete currentUri.query.venotify;
|
|
|
|
window.history.replaceState( null, document.title, currentUri );
|
2012-12-12 23:35:33 +00:00
|
|
|
}
|
2013-06-05 21:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setupSkinTabs();
|
2013-06-05 22:39:43 +00:00
|
|
|
|
|
|
|
window.addEventListener( 'popstate', ve.bind( this.onWindowPopState, this ) ) ;
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
Object management: Object create/inherit/clone utilities
* For the most common case:
- replace ve.extendClass with ve.inheritClass (chose slightly
different names to detect usage of the old/new one, and I
like 'inherit' better).
- move it up to below the constructor, see doc block for why.
* Cases where more than 2 arguments were passed to
ve.extendClass are handled differently depending on the case.
In case of a longer inheritance tree, the other arguments
could be omitted (like in "ve.ce.FooBar, ve.FooBar,
ve.Bar". ve.ce.FooBar only needs to inherit from ve.FooBar,
because ve.ce.FooBar inherits from ve.Bar).
In the case of where it previously had two mixins with
ve.extendClass(), either one becomes inheritClass and one
a mixin, both to mixinClass().
No visible changes should come from this commit as the
instances still all have the same visible properties in the
end. No more or less than before.
* Misc.:
- Be consistent in calling parent constructors in the
same order as the inheritance.
- Add missing @extends and @param documentation.
- Replace invalid {Integer} type hint with {Number}.
- Consistent doc comments order:
@class, @abstract, @constructor, @extends, @params.
- Fix indentation errors
A fairly common mistake was a superfluous space before the
identifier on the assignment line directly below the
documentation comment.
$ ack "^ [^*]" --js modules/ve
- Typo "Inhertiance" -> "Inheritance".
- Replacing the other confusing comment "Inheritance" (inside
the constructor) with "Parent constructor".
- Add missing @abstract for ve.ui.Tool.
- Corrected ve.FormatDropdownTool to ve.ui.FormatDropdownTool.js
- Add function names to all @constructor functions. Now that we
have inheritance it is important and useful to have these
functions not be anonymous.
Example of debug shot: http://cl.ly/image/1j3c160w3D45
Makes the difference between
< documentNode;
> ve_dm_DocumentNode
...
: ve_dm_BranchNode
...
: ve_dm_Node
...
: ve_dm_Node
...
: Object
...
without names (current situation):
< documentNode;
> Object
...
: Object
...
: Object
...
: Object
...
: Object
...
though before this commit, it really looks like this
(flattened since ve.extendClass really did a mixin):
< documentNode;
> Object
...
...
...
Pattern in Sublime (case-sensitive) to find nameless
constructor functions:
"^ve\..*\.([A-Z])([^\.]+) = function \("
Change-Id: Iab763954fb8cf375900d7a9a92dec1c755d5407e
2012-09-05 06:07:47 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.inheritClass( ve.init.mw.ViewPageTarget, ve.init.mw.Target );
|
|
|
|
|
2013-01-15 23:38:49 +00:00
|
|
|
/* Static Properties */
|
2012-06-11 06:54:41 +00:00
|
|
|
|
2012-08-22 21:24:50 +00:00
|
|
|
/**
|
|
|
|
* Compatibility map used with jQuery.client to black-list incompatible browsers.
|
|
|
|
*
|
|
|
|
* @static
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @property
|
2012-08-22 21:24:50 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.compatibility = {
|
2013-05-26 15:23:03 +00:00
|
|
|
// The key is the browser name returned by jQuery.client
|
|
|
|
// The value is either null (match all versions) or a list of tuples
|
|
|
|
// containing an inequality (<,>,<=,>=) and a version number
|
2013-06-05 19:50:47 +00:00
|
|
|
'whitelist': {
|
2013-07-09 01:20:42 +00:00
|
|
|
'firefox': [['>=', 15]],
|
2013-05-26 15:23:03 +00:00
|
|
|
'iceweasel': [['>=', 10]],
|
|
|
|
'safari': [['>=', 5]],
|
|
|
|
'chrome': [['>=', 19]]
|
2012-08-22 21:24:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-14 23:45:42 +00:00
|
|
|
ve.init.mw.ViewPageTarget.static.toolbarTools = [
|
2013-06-21 01:57:10 +00:00
|
|
|
{ 'items': [ 'undo', 'redo' ] },
|
|
|
|
{ 'items': [ 'mwFormat' ] },
|
2013-07-08 21:20:31 +00:00
|
|
|
{ 'items': [ 'bold', 'italic', 'mwLink', 'language', 'code', 'clear' ] },
|
2013-06-21 01:57:10 +00:00
|
|
|
{ 'items': [ 'number', 'bullet', 'outdent', 'indent' ] },
|
2013-07-19 22:30:29 +00:00
|
|
|
{ 'items': [ 'mwMediaInsert', 'mwReference', 'mwReferenceList', 'mwTransclusion', 'mwMath' ] }
|
2013-05-14 23:45:42 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
ve.init.mw.ViewPageTarget.static.surfaceCommands = [
|
2013-07-30 00:11:03 +00:00
|
|
|
'bold', 'italic', 'mwLink', 'undo', 'redo', 'indent', 'outdent', 'clear'
|
2013-05-14 23:45:42 +00:00
|
|
|
];
|
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
// TODO: Accessibility tooltips and logical tab order for prevButton and closeButton.
|
2012-07-20 23:59:59 +00:00
|
|
|
ve.init.mw.ViewPageTarget.saveDialogTemplate = '\
|
2012-12-07 16:23:23 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-head">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-prevButton"></div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-closeButton"></div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-title"></div>\
|
|
|
|
</div>\
|
2012-07-20 23:59:59 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-body">\
|
2012-12-11 22:13:54 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-slide ve-init-mw-viewPageTarget-saveDialog-slide-save">\
|
2013-07-18 22:34:16 +00:00
|
|
|
<label class="ve-init-mw-viewPageTarget-saveDialog-editSummary-label"\
|
|
|
|
for="ve-init-mw-viewPageTarget-saveDialog-editSummary"\
|
|
|
|
id="ve-init-mw-viewPageTarget-saveDialog-editSummary-label"></label>\
|
2012-12-07 16:23:23 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-summary">\
|
|
|
|
<textarea name="editSummary" class="ve-init-mw-viewPageTarget-saveDialog-editSummary"\
|
|
|
|
id="ve-init-mw-viewPageTarget-saveDialog-editSummary" type="text"\
|
|
|
|
rows="4"></textarea>\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-options">\
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-checkboxes">\
|
|
|
|
</div>\
|
2012-12-07 16:23:23 +00:00
|
|
|
<label class="ve-init-mw-viewPageTarget-saveDialog-editSummaryCount"></label>\
|
|
|
|
</div>\
|
2013-06-30 18:40:57 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-messages"></div>\
|
2012-12-11 00:26:09 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
2013-06-23 23:09:47 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-dirtymsg"></div>\
|
2012-12-11 23:19:21 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
2012-12-11 00:26:09 +00:00
|
|
|
</div>\
|
2012-12-07 16:23:23 +00:00
|
|
|
<div style="clear: both;"></div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-foot">\
|
|
|
|
<p class="ve-init-mw-viewPageTarget-saveDialog-license"></p>\
|
|
|
|
</div>\
|
2012-06-11 06:54:41 +00:00
|
|
|
</div>\
|
2013-06-07 19:00:38 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-slide ve-init-mw-viewPageTarget-saveDialog-slide-review">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-viewer"></div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
|
|
|
</div>\
|
|
|
|
<div style="clear: both;"></div>\
|
|
|
|
</div>\
|
2013-05-14 16:50:29 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-slide ve-init-mw-viewPageTarget-saveDialog-slide-conflict">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-conflict">\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
|
|
|
</div>\
|
|
|
|
<div style="clear: both;"></div>\
|
|
|
|
</div>\
|
2013-05-14 17:40:00 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-slide ve-init-mw-viewPageTarget-saveDialog-slide-nochanges">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-nochanges">\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
2012-06-18 20:12:32 +00:00
|
|
|
</div>';
|
2012-06-11 06:54:41 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Switch to edit mode.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.activate = function () {
|
2012-06-14 01:26:21 +00:00
|
|
|
if ( !this.active && !this.activating ) {
|
|
|
|
this.activating = true;
|
2013-06-05 21:38:39 +00:00
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
// User interface changes
|
2013-06-05 21:38:39 +00:00
|
|
|
this.transformPage();
|
2012-06-11 06:54:41 +00:00
|
|
|
this.showSpinner();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.hideTableOfContents();
|
|
|
|
this.mutePageContent();
|
|
|
|
this.mutePageTitle();
|
|
|
|
this.saveScrollPosition();
|
|
|
|
this.load();
|
2012-06-11 06:54:41 +00:00
|
|
|
}
|
2012-06-14 21:31:08 +00:00
|
|
|
};
|
|
|
|
|
2012-06-12 01:21:31 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Switch to view mode.
|
2012-06-12 01:21:31 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) {
|
2012-12-06 22:18:56 +00:00
|
|
|
if ( override || ( this.active && !this.deactivating ) ) {
|
2012-06-12 17:32:10 +00:00
|
|
|
if (
|
2012-06-19 00:39:31 +00:00
|
|
|
override ||
|
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-20 23:25:12 +00:00
|
|
|
!this.edited ||
|
2012-06-19 20:44:34 +00:00
|
|
|
confirm( ve.msg( 'visualeditor-viewpage-savewarning' ) )
|
2012-06-12 17:32:10 +00:00
|
|
|
) {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.deactivating = true;
|
|
|
|
// User interface changes
|
2013-06-05 21:38:39 +00:00
|
|
|
this.restorePage();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.hideSpinner();
|
2013-03-22 18:21:16 +00:00
|
|
|
|
|
|
|
if ( this.toolbarCancelButton ) {
|
|
|
|
// If deactivate is called before a successful load, then
|
|
|
|
// setupToolbarButtons has not been called yet and as such tearDownToolbarButtons
|
|
|
|
// would throw an error when trying call methods on the button property (bug 46456)
|
|
|
|
this.tearDownToolbarButtons();
|
|
|
|
this.detachToolbarButtons();
|
|
|
|
}
|
|
|
|
|
2012-12-10 21:47:24 +00:00
|
|
|
this.resetSaveDialog();
|
|
|
|
this.hideSaveDialog();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.detachSaveDialog();
|
2013-05-17 16:44:21 +00:00
|
|
|
// Check we got as far as setting up the surface
|
|
|
|
if ( this.active ) {
|
|
|
|
this.tearDownSurface();
|
|
|
|
} else {
|
|
|
|
this.showPageContent();
|
|
|
|
}
|
|
|
|
// If there is a load in progress, abort it
|
|
|
|
if ( this.loading ) {
|
|
|
|
this.loading.abort();
|
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
this.showTableOfContents();
|
2012-06-14 21:31:08 +00:00
|
|
|
this.deactivating = false;
|
2013-07-09 01:35:35 +00:00
|
|
|
mw.hook( 've.deactivationComplete' ).fire();
|
2012-06-12 17:32:10 +00:00
|
|
|
}
|
2012-06-12 01:21:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle successful DOM load event.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
2013-02-11 19:46:58 +00:00
|
|
|
* @param {HTMLDocument} doc Parsed DOM from server
|
2012-06-11 06:54:41 +00:00
|
|
|
*/
|
2013-02-11 19:46:58 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onLoad = function ( doc ) {
|
2013-02-11 19:38:50 +00:00
|
|
|
if ( this.activating ) {
|
2013-06-11 22:14:44 +00:00
|
|
|
this.logEvent( 'Edit', { action: 'page-edit-impression' } );
|
2013-02-11 19:38:50 +00:00
|
|
|
this.edited = false;
|
2013-02-11 19:46:58 +00:00
|
|
|
this.doc = doc;
|
2013-07-01 20:02:10 +00:00
|
|
|
this.setUpSurface( doc, ve.bind( function() {
|
|
|
|
this.startSanityCheck();
|
|
|
|
this.setupToolbarEditNotices();
|
|
|
|
this.setupToolbarBetaNotice();
|
|
|
|
this.setupToolbarButtons();
|
|
|
|
this.setupSaveDialog();
|
|
|
|
this.attachToolbarButtons();
|
|
|
|
this.attachSaveDialog();
|
|
|
|
this.restoreScrollPosition();
|
|
|
|
this.restoreEditSection();
|
|
|
|
this.setupBeforeUnloadHandler();
|
|
|
|
this.$document[0].focus();
|
|
|
|
this.activating = false;
|
2013-08-01 20:18:33 +00:00
|
|
|
if ( mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome ) {
|
|
|
|
this.showBetaWelcome();
|
|
|
|
}
|
2013-07-09 01:35:35 +00:00
|
|
|
mw.hook( 've.activationComplete' ).fire();
|
2013-07-01 20:02:10 +00:00
|
|
|
}, this ) );
|
2013-02-11 19:38:50 +00:00
|
|
|
}
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-12 17:32:10 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle failed DOM load event.
|
2012-06-12 17:32:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
2013-05-18 01:19:20 +00:00
|
|
|
* @param {Object} response HTTP Response object
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @param {string} status Text status message
|
2012-06-18 20:12:32 +00:00
|
|
|
* @param {Mixed} error Thrown exception or HTTP error string
|
2012-06-12 17:32:10 +00:00
|
|
|
*/
|
Make use of new jshint options
* Restricting "camelcase":
No changes, we were passing all of these already
* Explicitly unrestricting "forin" and "plusplus"
These are off by default in node-jshint, but some distro of jshint
and editors that use their own wrapper around jshint instead of
node-jshint (Eclipse?) may have different defaults. Therefor
setting them to false explicitly. This also serves as a reminder
for the future so we'll always know we don't pass that, in case
we would want to change that.
* Fix order ("quotemark" before "regexp")
* Restricting "unused"
We're not passing all of this, which is why I've set it to false
for now. But I did put it in .jshintrc as placeholder.
I've fixed most of them, there's some left where there is no clean
solution.
* While at it fix a few issues:
- Unused variables ($target, $window)
- Bad practices (using jQuery context for find instead of creation)
- Redundant /*global */ comments
- Parameters that are not used and don't have documentation either
- Lines longer than 100 chars @ 4 spaces/tab
* Note:
- ve.ce.Surface.prototype.onChange takes two arguments but never
uses the former. And even the second one can be null/undefined.
Aside from that, the .change() function emits
another event for the transaction already. Looks like this
should be refactored a bit, two more separated events probably
or one that is actually used better.
- Also cleaned up a lot of comments, some of which were missing,
others were incorrect
- Reworked the contentChange event so we are no longer using the
word new as an object key; expanded a complex object into multiple
arguments being passed through the event to make it easier to work
with and document
Change-Id: I8490815a508c6c379d5f9a743bb4aefd14576aa6
2012-08-07 06:02:18 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onLoadError = function ( response, status ) {
|
2013-05-17 16:44:21 +00:00
|
|
|
// Don't show an error if the load was manually aborted
|
|
|
|
if ( status !== 'abort' && confirm( ve.msg( 'visualeditor-loadwarning', status ) ) ) {
|
2012-06-19 19:26:08 +00:00
|
|
|
this.load();
|
|
|
|
} else {
|
|
|
|
this.activating = false;
|
2012-12-06 22:18:56 +00:00
|
|
|
// User interface changes
|
|
|
|
this.deactivate( true );
|
2012-06-19 19:26:08 +00:00
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
2013-05-18 01:19:20 +00:00
|
|
|
/**
|
|
|
|
* Handle failed token refresh event.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {Object} response Response object
|
|
|
|
* @param {string} status Text status message
|
|
|
|
* @param {Mixed} error Thrown exception or HTTP error string
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onTokenError = function ( response, status ) {
|
|
|
|
if ( confirm( ve.msg( 'visualeditor-loadwarning-token', status ) ) ) {
|
|
|
|
this.load();
|
|
|
|
} else {
|
|
|
|
this.activating = false;
|
2012-12-06 22:18:56 +00:00
|
|
|
// User interface changes
|
|
|
|
this.deactivate( true );
|
2012-06-19 19:26:08 +00:00
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle successful DOM save event.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {HTMLElement} html Rendered HTML from server
|
2013-05-03 12:15:54 +00:00
|
|
|
* @param {number} [newid] New revision id, undefined if unchanged
|
2012-06-18 20:12:32 +00:00
|
|
|
*/
|
2013-05-03 12:15:54 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, newid ) {
|
2013-06-11 22:14:44 +00:00
|
|
|
this.logEvent( 'Edit', {
|
|
|
|
action: 'page-save-success',
|
|
|
|
latency: this.saveStart ? new Date() - this.saveStart : 0
|
|
|
|
} );
|
|
|
|
delete this.saveStart;
|
|
|
|
|
2012-12-04 21:04:19 +00:00
|
|
|
if ( !this.pageExists || this.restoring ) {
|
|
|
|
// This is a page creation or restoration, refresh the page
|
2012-11-30 23:09:34 +00:00
|
|
|
this.tearDownBeforeUnloadHandler();
|
2012-08-23 19:01:07 +00:00
|
|
|
window.location.href = this.viewUri.extend( {
|
2012-12-04 21:04:19 +00:00
|
|
|
'venotify': this.restoring ? 'restored' : 'created'
|
2012-08-23 19:01:07 +00:00
|
|
|
} );
|
2012-06-20 19:15:42 +00:00
|
|
|
} else {
|
2012-06-20 23:20:17 +00:00
|
|
|
// Update watch link to match 'watch checkbox' in save dialog.
|
|
|
|
// User logged in if module loaded.
|
2012-08-01 00:49:04 +00:00
|
|
|
// Just checking for mw.page.watch is not enough because in Firefox
|
|
|
|
// there is Object.prototype.watch...
|
|
|
|
if ( mw.page.watch && mw.page.watch.updateWatchLink ) {
|
|
|
|
var watchChecked = this.$saveDialog
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.find( '#wpWatchthis' )
|
2012-06-20 23:20:17 +00:00
|
|
|
.prop( 'checked' );
|
|
|
|
mw.page.watch.updateWatchLink(
|
2012-08-01 00:49:04 +00:00
|
|
|
$( '#ca-watch a, #ca-unwatch a' ),
|
|
|
|
watchChecked ? 'unwatch': 'watch'
|
2012-06-20 23:20:17 +00:00
|
|
|
);
|
|
|
|
}
|
2013-07-05 07:56:28 +00:00
|
|
|
|
|
|
|
// If we were explicitly editing an older version, make sure we won't
|
|
|
|
// load the same old version again, now that we've saved the next edit
|
|
|
|
// will be against the latest version.
|
|
|
|
// TODO: What about oldid in the url?
|
|
|
|
this.restoring = false;
|
|
|
|
|
2013-05-03 12:15:54 +00:00
|
|
|
if ( newid !== undefined ) {
|
2013-07-05 07:56:28 +00:00
|
|
|
mw.config.set( 'wgCurRevisionId', newid );
|
|
|
|
this.revid = newid;
|
2013-05-03 12:15:54 +00:00
|
|
|
}
|
2013-07-05 07:56:28 +00:00
|
|
|
|
2012-06-20 19:15:42 +00:00
|
|
|
this.hideSaveDialog();
|
|
|
|
this.resetSaveDialog();
|
|
|
|
this.replacePageContent( html );
|
2013-06-24 21:22:54 +00:00
|
|
|
this.setupSectionEditLinks();
|
2012-11-30 23:09:34 +00:00
|
|
|
this.tearDownBeforeUnloadHandler();
|
2012-06-20 19:15:42 +00:00
|
|
|
this.deactivate( true );
|
2013-06-21 12:44:56 +00:00
|
|
|
mw.hook( 'postEdit' ).fire( {
|
|
|
|
'message':
|
|
|
|
ve.msg( 'visualeditor-notification-saved',
|
|
|
|
new mw.Title( this.pageName ).toText()
|
|
|
|
)
|
|
|
|
} );
|
2012-06-20 19:15:42 +00:00
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle failed DOM save event.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
2012-12-07 16:23:23 +00:00
|
|
|
* @param {Object} jqXHR
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @param {string} status Text status message
|
2013-06-29 01:52:29 +00:00
|
|
|
* @param {Object|null} data API response data
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveError = function ( jqXHR, status, data ) {
|
mw.ViewPageTarget: Refetch token if session expired
* Rephrased visualeditor-savedialog-error-badtoken to emphasise
that it is the old session that become invalid, not the one
the user started browsing with since in a different window.
* If the session changed, the user will be asked whether they
agree to save with this new session instead.
* We explictly update mw.config so that future save attempts
in the same window compare against the correct environment.
Without this there are two problems when saving and then
making a second edit in the same window and saving that:
- It will bring up the same question again (user A -> user B),
which is annoying.
- If the user logged back in again (new session, but for
user A again) it would silently try with that new token
without asking, thus saving as user A when the user still
thinks it switched to user B. It switching back automatically
is not obvious since we asked them from A->B, so we should
also ask the other way around.
This can be reproduced by opending ve-edit logged-in, then
logging out in a new window, save, confirm anon, save,
open edit again, log back in in a new window, save open edit
in the old window, confirm new logged-in, save.
Bug: 50424
Change-Id: Id055eca1886f85aeaf615f645de29898afc0373c
2013-07-12 18:27:35 +00:00
|
|
|
var api, editApi,
|
|
|
|
viewPage = this;
|
|
|
|
|
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-20 23:25:12 +00:00
|
|
|
this.saveDialogSaveButton.setDisabled( false );
|
2012-12-06 22:18:56 +00:00
|
|
|
this.$saveDialogLoadingIcon.hide();
|
2013-06-29 01:52:29 +00:00
|
|
|
|
2013-06-30 18:40:57 +00:00
|
|
|
this.clearMessage( 'api-save-error' );
|
2013-06-29 01:52:29 +00:00
|
|
|
|
2013-06-30 18:40:57 +00:00
|
|
|
// Handle empty response
|
|
|
|
if ( !data ) {
|
|
|
|
this.showMessage(
|
|
|
|
'api-save-error',
|
|
|
|
ve.msg( 'visualeditor-saveerror', 'Empty server response' ),
|
|
|
|
{
|
|
|
|
wrap: 'error'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.saveDialogSaveButton.setDisabled( true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-16 14:07:20 +00:00
|
|
|
editApi = data && data.visualeditoredit && data.visualeditoredit.edit;
|
|
|
|
|
|
|
|
// Handle spam blacklist error (either from core or from Extension:SpamBlacklist)
|
|
|
|
if ( editApi && editApi.spamblacklist ) {
|
|
|
|
this.showMessage(
|
|
|
|
'api-save-error',
|
|
|
|
// TODO: Use mediawiki.language equivalant of Language.php::listToText once it exists
|
|
|
|
ve.msg( 'spamprotectiontext' ) + ' ' + ve.msg( 'spamprotectionmatch', editApi.spamblacklist.split( '|' ).join( ', ' ) ),
|
|
|
|
{
|
|
|
|
wrap: 'error'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.saveDialogSaveButton.setDisabled( true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-17 01:11:19 +00:00
|
|
|
// Handle warnings/errors from Extension:AbuseFilter
|
|
|
|
// TODO: Move this to a plugin
|
2013-07-30 23:45:13 +00:00
|
|
|
if ( editApi && editApi.info && editApi.info.indexOf( 'Hit AbuseFilter:' ) === 0 && editApi.warning ) {
|
2013-07-17 01:11:19 +00:00
|
|
|
this.showMessage(
|
|
|
|
'api-save-error',
|
|
|
|
$.parseHTML( editApi.warning ),
|
|
|
|
{ wrap: false }
|
|
|
|
);
|
|
|
|
// Don't disable the save button. If the action is not disallowed the user may save the
|
|
|
|
// edit by pressing Save again. The AbuseFilter API currently has no way to distinguish
|
|
|
|
// between filter triggers that are and aren't disallowing the action.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-11 18:10:59 +00:00
|
|
|
// Handle token errors
|
|
|
|
if ( data.error && data.error.code === 'badtoken' ) {
|
mw.ViewPageTarget: Refetch token if session expired
* Rephrased visualeditor-savedialog-error-badtoken to emphasise
that it is the old session that become invalid, not the one
the user started browsing with since in a different window.
* If the session changed, the user will be asked whether they
agree to save with this new session instead.
* We explictly update mw.config so that future save attempts
in the same window compare against the correct environment.
Without this there are two problems when saving and then
making a second edit in the same window and saving that:
- It will bring up the same question again (user A -> user B),
which is annoying.
- If the user logged back in again (new session, but for
user A again) it would silently try with that new token
without asking, thus saving as user A when the user still
thinks it switched to user B. It switching back automatically
is not obvious since we asked them from A->B, so we should
also ask the other way around.
This can be reproduced by opending ve-edit logged-in, then
logging out in a new window, save, confirm anon, save,
open edit again, log back in in a new window, save open edit
in the old window, confirm new logged-in, save.
Bug: 50424
Change-Id: Id055eca1886f85aeaf615f645de29898afc0373c
2013-07-12 18:27:35 +00:00
|
|
|
api = new mw.Api();
|
|
|
|
viewPage.saveDialogSaveButton.setDisabled( true );
|
|
|
|
viewPage.$saveDialogLoadingIcon.show();
|
|
|
|
api.get( {
|
|
|
|
// action=query&meta=userinfo and action=tokens&type=edit can't be combined
|
|
|
|
// but action=query&meta=userinfo and action=query&prop=info can, however
|
|
|
|
// that means we have to give it titles and deal with page ids.
|
|
|
|
'action': 'query',
|
|
|
|
'meta': 'userinfo',
|
|
|
|
'prop': 'info',
|
|
|
|
// Try to send the normalised form so that it is less likely we get extra data like
|
|
|
|
// data.normalised back that we don't need.
|
|
|
|
'titles': new mw.Title( viewPage.pageName ).toText(),
|
|
|
|
'indexpageids': '',
|
|
|
|
'intoken': 'edit'
|
|
|
|
} )
|
|
|
|
.always( function () {
|
|
|
|
viewPage.$saveDialogLoadingIcon.hide();
|
|
|
|
} )
|
|
|
|
.done( function ( data ) {
|
|
|
|
var badTokenText, userMsg,
|
|
|
|
userInfo = data.query && data.query.userinfo,
|
|
|
|
pageInfo = data.query && data.query.pages && data.query.pageids &&
|
|
|
|
data.query.pageids[0] && data.query.pages[ data.query.pageids[0] ],
|
|
|
|
editToken = pageInfo && pageInfo.edittoken;
|
|
|
|
|
|
|
|
if ( userInfo && editToken ) {
|
|
|
|
viewPage.editToken = editToken;
|
|
|
|
|
|
|
|
if (
|
|
|
|
( mw.user.isAnon() && userInfo.anon !== undefined ) ||
|
|
|
|
// Comparing id instead of name to pretect against possible
|
|
|
|
// normalisation and against case where the user got renamed.
|
|
|
|
mw.config.get( 'wgUserId' ) === userInfo.id
|
|
|
|
) {
|
|
|
|
// New session is the same user still
|
|
|
|
viewPage.saveDocument();
|
|
|
|
} else {
|
|
|
|
// The now current session is a different user
|
|
|
|
viewPage.saveDialogSaveButton.setDisabled( false );
|
|
|
|
|
|
|
|
// Trailing space is to separate from the other message.
|
|
|
|
badTokenText = document.createTextNode( mw.msg( 'visualeditor-savedialog-error-badtoken' ) + ' ' );
|
|
|
|
|
|
|
|
if ( userInfo.anon !== undefined ) {
|
|
|
|
// New session is an anonymous user
|
|
|
|
mw.config.set( {
|
|
|
|
// wgUserId is unset for anonymous users, not set to null
|
|
|
|
'wgUserId': undefined,
|
|
|
|
// wgUserName is explicitly set to null for anonymous users,
|
|
|
|
// functions like mw.user.isAnon rely on this.
|
|
|
|
'wgUserName': null
|
|
|
|
} );
|
|
|
|
|
|
|
|
viewPage.showMessage(
|
|
|
|
'api-save-error',
|
|
|
|
$( badTokenText ).add(
|
|
|
|
$.parseHTML( mw.message( 'visualeditor-savedialog-identify-anon' ).parse() )
|
|
|
|
),
|
|
|
|
{ wrap: 'warning' }
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// New session is a different user
|
|
|
|
mw.config.set( { 'wgUserId': userInfo.id, 'wgUserName': userInfo.name } );
|
|
|
|
|
|
|
|
// mediawiki.jqueryMsg has a bug with [[User:$1|$1]] (bug 51388)
|
|
|
|
userMsg = 'visualeditor-savedialog-identify-user---' + userInfo.name;
|
|
|
|
mw.messages.set(
|
|
|
|
userMsg,
|
|
|
|
mw.messages.get( 'visualeditor-savedialog-identify-user' )
|
|
|
|
.replace( /\$1/g, userInfo.name )
|
|
|
|
);
|
|
|
|
|
|
|
|
viewPage.showMessage(
|
|
|
|
'api-save-error',
|
|
|
|
$( badTokenText ).add(
|
|
|
|
$.parseHTML( mw.message( userMsg ).parse() )
|
|
|
|
),
|
|
|
|
{ wrap: 'warning' }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} );
|
2013-07-11 18:10:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-16 14:02:27 +00:00
|
|
|
// Handle captcha
|
|
|
|
// Captcha "errors" usually aren't errors. We simply don't know about them ahead of time,
|
|
|
|
// so we save once, then (if required) we get an error with a captcha back and try again after
|
|
|
|
// the user solved the captcha.
|
|
|
|
// TODO: ConfirmEdit API is horrible, there is no reliable way to know whether it is a "math",
|
|
|
|
// "question" or "fancy" type of captcha. They all expose differently named properties in the
|
|
|
|
// API for different things in the UI. At this point we only support the FancyCaptha which we
|
|
|
|
// very intuitively detect by the presence of a "url" property.
|
|
|
|
if ( editApi && editApi.captcha && editApi.captcha.url ) {
|
|
|
|
this.captcha = {
|
|
|
|
input: new ve.ui.TextInputWidget(),
|
|
|
|
id: editApi.captcha.id
|
|
|
|
};
|
|
|
|
this.showMessage(
|
|
|
|
'api-save-error',
|
|
|
|
$( '<div>').append(
|
|
|
|
// msg: simplecaptcha-edit, fancycaptcha-edit, ..
|
|
|
|
$( '<p>' ).append(
|
|
|
|
$( '<strong>' ).text( mw.msg( 'captcha-label' ) ),
|
|
|
|
document.createTextNode( mw.msg( 'colon-separator' ) ),
|
|
|
|
$( $.parseHTML( mw.message( 'fancycaptcha-edit' ).parse() ) )
|
|
|
|
.filter( 'a' ).attr( 'target', '_blank ' ).end()
|
|
|
|
),
|
|
|
|
$( '<img>' ).attr( 'src', editApi.captcha.url ),
|
|
|
|
this.captcha.input.$
|
|
|
|
),
|
|
|
|
{
|
|
|
|
wrap: false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2013-07-11 18:10:59 +00:00
|
|
|
|
2013-06-30 18:40:57 +00:00
|
|
|
// Handle (other) unknown and/or unrecoverable errors
|
|
|
|
this.showMessage(
|
|
|
|
'api-save-error',
|
2013-07-15 22:03:19 +00:00
|
|
|
document.createTextNode(
|
2013-07-30 23:45:13 +00:00
|
|
|
( editApi && editApi.info ) ||
|
2013-07-15 22:03:19 +00:00
|
|
|
( data.error && data.error.info ) ||
|
2013-07-30 23:45:13 +00:00
|
|
|
( editApi && editApi.code ) ||
|
2013-07-15 22:03:19 +00:00
|
|
|
( data.error && data.error.code ) ||
|
|
|
|
'Unknown error'
|
|
|
|
),
|
2013-06-30 18:40:57 +00:00
|
|
|
{
|
|
|
|
wrap: 'error'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.saveDialogSaveButton.setDisabled( true );
|
2012-06-12 17:32:10 +00:00
|
|
|
};
|
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle Show changes event.
|
2012-12-07 16:23:23 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {string} diffHtml
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onShowChanges = function ( diffHtml ) {
|
2013-05-08 18:17:50 +00:00
|
|
|
// Invalidate the viewer diff on next change
|
2013-05-01 22:21:32 +00:00
|
|
|
this.surface.getModel().connect( this, { 'transact': 'onSurfaceModelTransact' } );
|
2012-12-11 23:19:21 +00:00
|
|
|
|
|
|
|
mw.loader.using( 'mediawiki.action.history.diff', ve.bind( function () {
|
2012-12-07 16:23:23 +00:00
|
|
|
this.$saveDialog
|
2012-12-11 23:19:21 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-viewer' )
|
|
|
|
.empty().append( diffHtml );
|
2012-12-07 16:23:23 +00:00
|
|
|
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
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-20 23:25:12 +00:00
|
|
|
this.saveDialogReviewGoodButton.setDisabled( false );
|
2012-12-11 23:19:21 +00:00
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
}, this ), ve.bind( function () {
|
|
|
|
this.onSaveError( null, 'Module load failed' );
|
|
|
|
}, this ) );
|
|
|
|
};
|
|
|
|
|
2013-05-08 18:17:50 +00:00
|
|
|
/**
|
|
|
|
* Handle Serialize event.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {string} wikitext
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSerialize = function ( wikitext ) {
|
|
|
|
// Invalidate the viewer wikitext on next change
|
|
|
|
this.surface.getModel().connect( this, { 'transact': 'onSurfaceModelTransact' } );
|
|
|
|
|
|
|
|
this.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-viewer' )
|
|
|
|
.empty().append( $( '<pre>' ).text( wikitext ) );
|
|
|
|
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
|
|
|
this.saveDialogReviewGoodButton.setDisabled( false );
|
|
|
|
};
|
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle failed show changes event.
|
2012-12-07 16:23:23 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {Object} jqXHR
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @param {string} status Text status message
|
2012-12-07 16:23:23 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onShowChangesError = function ( jqXHR, status ) {
|
|
|
|
alert( ve.msg( 'visualeditor-differror', status ) );
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
|
|
|
};
|
|
|
|
|
2013-04-24 00:01:44 +00:00
|
|
|
/**
|
|
|
|
* Called if a call to target.serialize() failed.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jqXHR|null} jqXHR
|
|
|
|
* @param {string} status Text status message
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSerializeError = function ( jqXHR, status ) {
|
|
|
|
alert( ve.msg( 'visualeditor-serializeerror', status ) );
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
|
|
|
};
|
|
|
|
|
2012-11-28 23:57:00 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle edit conflict event.
|
2012-11-28 23:57:00 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onEditConflict = function () {
|
2013-05-14 16:50:29 +00:00
|
|
|
this.$saveDialogLoadingIcon.hide();
|
|
|
|
this.swapSaveDialog( 'conflict' );
|
2012-11-28 23:57:00 +00:00
|
|
|
};
|
|
|
|
|
2013-05-14 17:40:00 +00:00
|
|
|
/**
|
|
|
|
* Handle failed show changes event.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onNoChanges = function () {
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
|
|
|
this.swapSaveDialog( 'nochanges' );
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the view tab.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2012-06-18 20:12:32 +00:00
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onViewTabClick = function ( e ) {
|
2013-06-26 23:35:18 +00:00
|
|
|
if ( ( e.which && e.which !== 1 ) || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) {
|
2013-06-26 19:20:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-06-18 21:53:22 +00:00
|
|
|
if ( this.active ) {
|
|
|
|
this.deactivate();
|
|
|
|
// Prevent the edit tab's normal behavior
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
e.preventDefault();
|
2013-02-11 19:38:50 +00:00
|
|
|
} else if ( this.activating ) {
|
|
|
|
this.deactivate( true );
|
|
|
|
this.activating = false;
|
|
|
|
e.preventDefault();
|
2012-06-18 21:53:22 +00:00
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the save button in the toolbar.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2012-06-18 20:12:32 +00:00
|
|
|
*/
|
Make use of new jshint options
* Restricting "camelcase":
No changes, we were passing all of these already
* Explicitly unrestricting "forin" and "plusplus"
These are off by default in node-jshint, but some distro of jshint
and editors that use their own wrapper around jshint instead of
node-jshint (Eclipse?) may have different defaults. Therefor
setting them to false explicitly. This also serves as a reminder
for the future so we'll always know we don't pass that, in case
we would want to change that.
* Fix order ("quotemark" before "regexp")
* Restricting "unused"
We're not passing all of this, which is why I've set it to false
for now. But I did put it in .jshintrc as placeholder.
I've fixed most of them, there's some left where there is no clean
solution.
* While at it fix a few issues:
- Unused variables ($target, $window)
- Bad practices (using jQuery context for find instead of creation)
- Redundant /*global */ comments
- Parameters that are not used and don't have documentation either
- Lines longer than 100 chars @ 4 spaces/tab
* Note:
- ve.ce.Surface.prototype.onChange takes two arguments but never
uses the former. And even the second one can be null/undefined.
Aside from that, the .change() function emits
another event for the transaction already. Looks like this
should be refactored a bit, two more separated events probably
or one that is actually used better.
- Also cleaned up a lot of comments, some of which were missing,
others were incorrect
- Reworked the contentChange event so we are no longer using the
word new as an object key; expanded a complex object into multiple
arguments being passed through the event to make it easier to work
with and document
Change-Id: I8490815a508c6c379d5f9a743bb4aefd14576aa6
2012-08-07 06:02:18 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarSaveButtonClick = function () {
|
2013-06-11 22:14:44 +00:00
|
|
|
this.logEvent( 'Edit', { action: 'page-save-attempt' } );
|
2012-12-04 21:04:19 +00:00
|
|
|
if ( this.edited || this.restoring ) {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.showSaveDialog();
|
2012-06-12 17:32:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-05 00:33:58 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the save button in the toolbar.
|
2012-12-05 00:33:58 +00:00
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2012-12-05 00:33:58 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarCancelButtonClick = function () {
|
2012-12-10 21:47:24 +00:00
|
|
|
this.deactivate();
|
2012-12-05 00:33:58 +00:00
|
|
|
};
|
|
|
|
|
2013-06-05 19:28:00 +00:00
|
|
|
/**
|
|
|
|
* Handle clicks on the MwMeta button in the toolbar.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e Mouse click event
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarMwMetaButtonClick = function () {
|
|
|
|
this.surface.getDialogs().open( 'mwMeta' );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-30 23:09:34 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the edit notices tool in the toolbar.
|
2012-11-30 23:09:34 +00:00
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2012-11-30 23:09:34 +00:00
|
|
|
*/
|
2012-12-11 01:44:44 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarEditNoticesToolClick = function () {
|
2012-11-30 23:09:34 +00:00
|
|
|
this.$toolbarEditNotices.fadeToggle( 'fast' );
|
2013-06-12 01:17:10 +00:00
|
|
|
this.$toolbarBetaNotice.fadeOut( 'fast' );
|
2013-06-20 04:32:03 +00:00
|
|
|
this.$document[0].focus();
|
2013-06-12 01:17:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle clicks on the beta notices tool in the toolbar.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e Mouse click event
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarBetaNoticeToolClick = function () {
|
|
|
|
this.$toolbarBetaNotice.fadeToggle( 'fast' );
|
|
|
|
this.$toolbarEditNotices.fadeOut( 'fast' );
|
2013-06-20 04:32:03 +00:00
|
|
|
this.$document[0].focus();
|
2012-11-30 23:09:34 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 01:44:44 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the feedback tool in the toolbar.
|
2012-12-11 01:44:44 +00:00
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2012-12-11 01:44:44 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarFeedbackToolClick = function () {
|
|
|
|
this.$toolbarEditNotices.fadeOut( 'fast' );
|
2013-05-18 17:34:25 +00:00
|
|
|
if ( !this.feedback ) {
|
|
|
|
// This can't be constructed until the editor has loaded as it uses special messages
|
|
|
|
this.feedback = new mw.Feedback( {
|
|
|
|
'title': new mw.Title( ve.msg( 'visualeditor-feedback-link' ) ),
|
|
|
|
'bugsLink': new mw.Uri( 'https://bugzilla.wikimedia.org/enter_bug.cgi?product=VisualEditor&component=General' ),
|
|
|
|
'bugsListLink': new mw.Uri( 'https://bugzilla.wikimedia.org/buglist.cgi?query_format=advanced&resolution=---&resolution=LATER&resolution=DUPLICATE&product=VisualEditor&list_id=166234' )
|
|
|
|
} );
|
|
|
|
}
|
2012-12-11 01:44:44 +00:00
|
|
|
this.feedback.launch();
|
|
|
|
};
|
|
|
|
|
2012-06-12 17:32:10 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle the first transaction in the surface model.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
2013-05-10 00:17:51 +00:00
|
|
|
* This handler is removed the first time it's used, but added each time the surface is set up.
|
2012-06-12 17:32:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @param {ve.dm.Transaction} tx Processed transaction
|
2012-06-12 17:32:10 +00:00
|
|
|
*/
|
Make use of new jshint options
* Restricting "camelcase":
No changes, we were passing all of these already
* Explicitly unrestricting "forin" and "plusplus"
These are off by default in node-jshint, but some distro of jshint
and editors that use their own wrapper around jshint instead of
node-jshint (Eclipse?) may have different defaults. Therefor
setting them to false explicitly. This also serves as a reminder
for the future so we'll always know we don't pass that, in case
we would want to change that.
* Fix order ("quotemark" before "regexp")
* Restricting "unused"
We're not passing all of this, which is why I've set it to false
for now. But I did put it in .jshintrc as placeholder.
I've fixed most of them, there's some left where there is no clean
solution.
* While at it fix a few issues:
- Unused variables ($target, $window)
- Bad practices (using jQuery context for find instead of creation)
- Redundant /*global */ comments
- Parameters that are not used and don't have documentation either
- Lines longer than 100 chars @ 4 spaces/tab
* Note:
- ve.ce.Surface.prototype.onChange takes two arguments but never
uses the former. And even the second one can be null/undefined.
Aside from that, the .change() function emits
another event for the transaction already. Looks like this
should be refactored a bit, two more separated events probably
or one that is actually used better.
- Also cleaned up a lot of comments, some of which were missing,
others were incorrect
- Reworked the contentChange event so we are no longer using the
word new as an object key; expanded a complex object into multiple
arguments being passed through the event to make it easier to work
with and document
Change-Id: I8490815a508c6c379d5f9a743bb4aefd14576aa6
2012-08-07 06:02:18 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSurfaceModelTransact = function () {
|
2012-12-11 23:19:21 +00:00
|
|
|
// Clear the diff
|
|
|
|
this.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-slide-review .ve-init-mw-viewPageTarget-saveDialog-viewer' )
|
|
|
|
.empty();
|
|
|
|
|
2013-05-01 22:21:32 +00:00
|
|
|
this.surface.getModel().disconnect( this, { 'transact': 'onSurfaceModelTransact' } );
|
2012-06-12 17:32:10 +00:00
|
|
|
};
|
|
|
|
|
2013-07-13 11:44:25 +00:00
|
|
|
/**
|
|
|
|
* Handle changes to the surface model.
|
|
|
|
*
|
|
|
|
* This is used to trigger notifications when the user starts entering wikitext
|
|
|
|
*
|
|
|
|
* @param {ve.dm.Transaction} tx
|
|
|
|
* @param {ve.Range} range
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSurfaceModelChange = function ( tx, range ) {
|
|
|
|
if ( !range ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var text, doc = this.surface.getView().getDocument(),
|
|
|
|
node = doc.getNodeFromOffset( range.start );
|
|
|
|
if ( !( node instanceof ve.ce.ContentBranchNode ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
text = ve.ce.getDomText( node.$[0] );
|
|
|
|
|
|
|
|
if ( text.match( /\[\[|\{\{|''|<nowiki|~~~|^==|^\*|^\#/ ) ) {
|
|
|
|
mw.notify(
|
2013-07-30 10:27:30 +00:00
|
|
|
$( $.parseHTML( ve.init.platform.getParsedMessage( 'visualeditor-wikitext-warning' ) ) )
|
|
|
|
.filter( 'a' ).attr( 'target', '_blank ' ).end(),
|
2013-07-13 11:44:25 +00:00
|
|
|
{
|
|
|
|
'title': ve.msg( 'visualeditor-wikitext-warning-title' ),
|
|
|
|
'tag': 'visualeditor-wikitext-warning',
|
|
|
|
'autoHide': false
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.surface.getModel().disconnect( this, { 'change': 'onSurfaceModelChange' } );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-03-15 15:51:22 +00:00
|
|
|
/**
|
2013-06-23 23:09:47 +00:00
|
|
|
* Re-evaluate whether the toolbar save button should be disabled or not.
|
2013-03-15 15:51:22 +00:00
|
|
|
*/
|
2013-06-23 23:09:47 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.updateToolbarSaveButtonState = function () {
|
2013-03-15 15:51:22 +00:00
|
|
|
this.edited = this.surface.getModel().hasPastState();
|
2013-06-23 23:09:47 +00:00
|
|
|
// Disable the save button if we have no history or if the sanity check is not finished
|
|
|
|
this.toolbarSaveButton.setDisabled( ( !this.edited && !this.restoring ) || !this.sanityCheckFinished );
|
|
|
|
this.toolbarSaveButton.$.toggleClass( 've-init-mw-viewPageTarget-waiting', !this.sanityCheckFinished );
|
2013-03-15 15:51:22 +00:00
|
|
|
};
|
|
|
|
|
2013-06-07 19:00:38 +00:00
|
|
|
/**
|
|
|
|
* Handle clicks on the review button in the save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogReviewButtonClick = function () {
|
|
|
|
this.swapSaveDialog( 'review' );
|
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the save button in the save dialog.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
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-20 23:25:12 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogSaveButtonClick = function () {
|
mw.ViewPageTarget: Refetch token if session expired
* Rephrased visualeditor-savedialog-error-badtoken to emphasise
that it is the old session that become invalid, not the one
the user started browsing with since in a different window.
* If the session changed, the user will be asked whether they
agree to save with this new session instead.
* We explictly update mw.config so that future save attempts
in the same window compare against the correct environment.
Without this there are two problems when saving and then
making a second edit in the same window and saving that:
- It will bring up the same question again (user A -> user B),
which is annoying.
- If the user logged back in again (new session, but for
user A again) it would silently try with that new token
without asking, thus saving as user A when the user still
thinks it switched to user B. It switching back automatically
is not obvious since we asked them from A->B, so we should
also ask the other way around.
This can be reproduced by opending ve-edit logged-in, then
logging out in a new window, save, confirm anon, save,
open edit again, log back in in a new window, save open edit
in the old window, confirm new logged-in, save.
Bug: 50424
Change-Id: Id055eca1886f85aeaf615f645de29898afc0373c
2013-07-12 18:27:35 +00:00
|
|
|
this.saveDocument();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to save the current document.
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.saveDocument = function () {
|
2013-05-17 14:27:33 +00:00
|
|
|
var doc = this.surface.getModel().getDocument(),
|
|
|
|
saveOptions = this.getSaveOptions();
|
2013-06-29 01:52:29 +00:00
|
|
|
|
|
|
|
// Once we've retrieved the save options,
|
|
|
|
// reset save start and any old captcha data
|
2013-06-11 22:14:44 +00:00
|
|
|
this.saveStart = +new Date();
|
2013-06-29 01:52:29 +00:00
|
|
|
if ( this.captcha ) {
|
2013-06-30 18:40:57 +00:00
|
|
|
this.clearMessage( 'captcha' );
|
2013-06-29 01:52:29 +00:00
|
|
|
delete this.captcha;
|
|
|
|
}
|
|
|
|
|
2013-05-17 14:27:33 +00:00
|
|
|
if (
|
|
|
|
+mw.user.options.get( 'forceeditsummary' ) &&
|
|
|
|
saveOptions.summary === '' &&
|
2013-06-30 18:40:57 +00:00
|
|
|
!this.messages.missingsummary
|
2013-05-17 14:27:33 +00:00
|
|
|
) {
|
2013-06-30 18:40:57 +00:00
|
|
|
this.showMessage(
|
|
|
|
'missingsummary',
|
|
|
|
// Wrap manually since this core message already includes a bold "Warning:" label
|
|
|
|
$( '<p>' ).append( ve.init.platform.getParsedMessage( 'missingsummary' ) ),
|
|
|
|
{ wrap: false }
|
|
|
|
);
|
2013-05-17 14:27:33 +00:00
|
|
|
} else {
|
|
|
|
this.saveDialogSaveButton.setDisabled( true );
|
|
|
|
this.$saveDialogLoadingIcon.show();
|
|
|
|
this.save(
|
|
|
|
ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ),
|
|
|
|
saveOptions
|
|
|
|
);
|
|
|
|
}
|
2012-12-07 16:23:23 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 23:19:21 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the review "Good" button in the save dialog.
|
2012-12-11 23:19:21 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
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-20 23:25:12 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogReviewGoodButtonClick = function () {
|
2012-12-11 23:19:21 +00:00
|
|
|
this.swapSaveDialog( 'save' );
|
|
|
|
};
|
|
|
|
|
2013-05-14 16:50:29 +00:00
|
|
|
/**
|
|
|
|
* Handle clicks on the resolve conflict button in the conflict dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogResolveConflictButtonClick = function () {
|
2013-05-14 17:40:00 +00:00
|
|
|
var doc = this.surface.getModel().getDocument();
|
2013-05-14 16:50:29 +00:00
|
|
|
// Get Wikitext from the DOM, and set up a submit call when it's done
|
|
|
|
this.serialize(
|
|
|
|
ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ),
|
|
|
|
ve.bind( function ( wikitext ) {
|
|
|
|
this.submit( wikitext, this.getSaveOptions() );
|
|
|
|
}, this )
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2012-11-28 23:57:00 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Get save options from the save dialog form.
|
2012-11-28 23:57:00 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {Object} Save options, including summary, minor and watch properties
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.getSaveOptions = function () {
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
var options = {
|
|
|
|
'summary': this.$saveDialog.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' ).val(),
|
2013-06-29 01:52:29 +00:00
|
|
|
'captchaid': this.captcha && this.captcha.id,
|
|
|
|
'captchaword': this.captcha && this.captcha.input.getValue()
|
2012-11-28 23:57:00 +00:00
|
|
|
};
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
if ( this.sanityCheckPromise.state() === 'rejected' ) {
|
|
|
|
options.needcheck = 1;
|
|
|
|
}
|
|
|
|
if ( this.$saveDialog.find( '#wpMinoredit' ).prop( 'checked' ) ) {
|
|
|
|
options.minor = 1;
|
|
|
|
}
|
|
|
|
if ( this.$saveDialog.find( '#wpWatchthis' ).prop( 'checked' ) ) {
|
|
|
|
options.watch = 1;
|
|
|
|
}
|
|
|
|
this.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-checkboxes' )
|
|
|
|
.find( 'input:not(#wpMinoredit, #wpWatchthis)' )
|
|
|
|
.each( function () {
|
|
|
|
var $this = $( this );
|
|
|
|
// We can't just use $this.val() because .val() always returns the value attribute of
|
|
|
|
// a checkbox even when it's unchecked
|
|
|
|
if ( $this.prop( 'type') !== 'checkbox' || $this.prop( 'checked' ) ) {
|
|
|
|
options[$this.prop( 'name' )] = $this.val();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
return options;
|
2012-11-28 23:57:00 +00:00
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle clicks on the close button in the save dialog.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2012-06-11 06:54:41 +00:00
|
|
|
*/
|
Make use of new jshint options
* Restricting "camelcase":
No changes, we were passing all of these already
* Explicitly unrestricting "forin" and "plusplus"
These are off by default in node-jshint, but some distro of jshint
and editors that use their own wrapper around jshint instead of
node-jshint (Eclipse?) may have different defaults. Therefor
setting them to false explicitly. This also serves as a reminder
for the future so we'll always know we don't pass that, in case
we would want to change that.
* Fix order ("quotemark" before "regexp")
* Restricting "unused"
We're not passing all of this, which is why I've set it to false
for now. But I did put it in .jshintrc as placeholder.
I've fixed most of them, there's some left where there is no clean
solution.
* While at it fix a few issues:
- Unused variables ($target, $window)
- Bad practices (using jQuery context for find instead of creation)
- Redundant /*global */ comments
- Parameters that are not used and don't have documentation either
- Lines longer than 100 chars @ 4 spaces/tab
* Note:
- ve.ce.Surface.prototype.onChange takes two arguments but never
uses the former. And even the second one can be null/undefined.
Aside from that, the .change() function emits
another event for the transaction already. Looks like this
should be refactored a bit, two more separated events probably
or one that is actually used better.
- Also cleaned up a lot of comments, some of which were missing,
others were incorrect
- Reworked the contentChange event so we are no longer using the
word new as an object key; expanded a complex object into multiple
arguments being passed through the event to make it easier to work
with and document
Change-Id: I8490815a508c6c379d5f9a743bb4aefd14576aa6
2012-08-07 06:02:18 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogCloseButtonClick = function () {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.hideSaveDialog();
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2013-01-15 23:38:49 +00:00
|
|
|
/**
|
|
|
|
* Handle clicks on the previous view button in the save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
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-20 23:25:12 +00:00
|
|
|
* @param {jQuery.Event} e Mouse click event
|
2013-01-15 23:38:49 +00:00
|
|
|
*/
|
2012-12-07 16:23:23 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogPrevButtonClick = function () {
|
2013-06-07 19:00:38 +00:00
|
|
|
var history = this.saveDialogSlideHistory;
|
|
|
|
if ( history.length < 2 ) {
|
|
|
|
throw new Error( 'PrevButton was triggered without a history' );
|
|
|
|
}
|
|
|
|
// Pop off current slide
|
|
|
|
history.pop();
|
|
|
|
// Navigate to last slide
|
|
|
|
this.swapSaveDialog( history[ history.length -1 ], { fromHistory: true } );
|
2012-12-07 16:23:23 +00:00
|
|
|
};
|
|
|
|
|
2012-11-30 23:09:34 +00:00
|
|
|
/**
|
2013-06-12 01:17:10 +00:00
|
|
|
* Set up the list of edit notices.
|
2012-11-30 23:09:34 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupToolbarEditNotices = function () {
|
|
|
|
var key;
|
|
|
|
this.$toolbarEditNotices.empty();
|
|
|
|
for ( key in this.editNotices ) {
|
2012-12-13 00:22:10 +00:00
|
|
|
this.$toolbarEditNotices.append( this.editNotices[key] );
|
2012-11-30 23:09:34 +00:00
|
|
|
}
|
2013-07-24 01:19:45 +00:00
|
|
|
this.$toolbarEditNotices.find( 'a' ).attr( 'target', '_blank' );
|
2012-11-30 23:09:34 +00:00
|
|
|
};
|
|
|
|
|
2013-06-12 01:17:10 +00:00
|
|
|
/**
|
|
|
|
* Set up the beta notices panel.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {string[]} HTML strings for each edit notice
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupToolbarBetaNotice = function () {
|
|
|
|
this.$toolbarBetaNotice.empty();
|
|
|
|
this.$toolbarBetaNotice
|
2013-07-01 17:28:40 +00:00
|
|
|
.append( $( '<span>' )
|
|
|
|
.text( ve.msg( 'visualeditor-beta-warning' ) )
|
|
|
|
)
|
|
|
|
.append( $( '<div>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool' )
|
|
|
|
.append( $( '<span>' )
|
2013-07-01 18:42:05 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-subtool-label' )
|
2013-07-01 17:28:40 +00:00
|
|
|
.append( $( '<a>' )
|
|
|
|
.attr( 'title', ve.msg( 'visualeditor-help-title' ) )
|
2013-08-02 19:53:09 +00:00
|
|
|
.attr( 'target', '_blank' )
|
2013-07-01 17:28:40 +00:00
|
|
|
.attr( 'href', new mw.Title( ve.msg( 'visualeditor-help-link' ) ).getUrl() )
|
|
|
|
.text( ve.msg( 'visualeditor-help-label' ) )
|
|
|
|
) ) );
|
2013-06-12 01:17:10 +00:00
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Switch to editing mode.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
2013-02-11 19:46:58 +00:00
|
|
|
* @param {HTMLDocument} doc HTML DOM to edit
|
2013-07-01 20:02:10 +00:00
|
|
|
* @param {Function} [callback] Callback to call when done
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.setUpSurface = function ( doc, callback ) {
|
2013-07-26 23:50:35 +00:00
|
|
|
var target = this;
|
|
|
|
setTimeout( function () {
|
2013-07-01 20:02:10 +00:00
|
|
|
// Build linmod
|
|
|
|
var store = new ve.dm.IndexValueStore(),
|
|
|
|
internalList = new ve.dm.InternalList(),
|
|
|
|
data = ve.dm.converter.getDataFromDom( doc, store, internalList );
|
2013-07-26 23:50:35 +00:00
|
|
|
setTimeout( function () {
|
2013-07-01 20:02:10 +00:00
|
|
|
// Build DM tree
|
|
|
|
var dmDoc = new ve.dm.Document( data, undefined, internalList );
|
2013-07-26 23:50:35 +00:00
|
|
|
setTimeout( function () {
|
2013-07-01 20:02:10 +00:00
|
|
|
// Create ui.Surface (also creates ce.Surface and dm.Surface and builds CE tree)
|
2013-07-26 23:50:35 +00:00
|
|
|
target.surface = new ve.ui.Surface( dmDoc, target.surfaceOptions );
|
|
|
|
target.surface.$.addClass( 've-init-mw-viewPageTarget-surface' );
|
|
|
|
setTimeout( function () {
|
2013-07-01 20:02:10 +00:00
|
|
|
// Initialize surface
|
2013-07-26 23:50:35 +00:00
|
|
|
target.surface.getContext().hide();
|
|
|
|
target.$document = target.surface.$.find( '.ve-ce-documentNode' );
|
|
|
|
target.surface.getModel().connect( target, {
|
|
|
|
'transact': 'onSurfaceModelTransact',
|
|
|
|
'change': 'onSurfaceModelChange',
|
|
|
|
'history': 'updateToolbarSaveButtonState'
|
|
|
|
} );
|
|
|
|
target.$.append( target.surface.$ );
|
|
|
|
target.setUpToolbar();
|
|
|
|
target.transformPageTitle();
|
|
|
|
target.changeDocumentTitle();
|
2013-07-01 20:02:10 +00:00
|
|
|
|
|
|
|
// Update UI
|
2013-07-26 23:50:35 +00:00
|
|
|
target.hidePageContent();
|
|
|
|
target.hideSpinner();
|
|
|
|
target.active = true;
|
|
|
|
target.$document.attr( {
|
2013-07-01 20:02:10 +00:00
|
|
|
'lang': mw.config.get( 'wgVisualEditor' ).pageLanguageCode,
|
|
|
|
'dir': mw.config.get( 'wgVisualEditor' ).pageLanguageDir
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Add appropriately mw-content-ltr or mw-content-rtl class
|
2013-07-26 23:50:35 +00:00
|
|
|
target.surface.view.$.addClass(
|
2013-06-27 17:25:28 +00:00
|
|
|
'mw-content-' + mw.config.get( 'wgVisualEditor' ).pageLanguageDir
|
|
|
|
);
|
2013-07-26 23:50:35 +00:00
|
|
|
|
|
|
|
// Now that the surface is attached to the document and ready,
|
|
|
|
// let it initialize itself
|
|
|
|
target.surface.initialize();
|
2013-07-01 20:02:10 +00:00
|
|
|
|
|
|
|
setTimeout( callback );
|
2013-07-26 23:50:35 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2013-06-23 23:09:47 +00:00
|
|
|
/**
|
|
|
|
* Fire off the sanity check. Must be called before the surface is activated.
|
|
|
|
*
|
|
|
|
* To access the result, check whether #sanityCheckPromise has been resolved or rejected
|
|
|
|
* (it's asynchronous, so it may still be pending when you check).
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.startSanityCheck = function () {
|
2013-07-26 22:33:58 +00:00
|
|
|
// We have to get a copy of the data now, before we unlock the surface and let the user edit,
|
|
|
|
// but we can defer the actual conversion and comparison
|
2013-06-23 23:09:47 +00:00
|
|
|
var viewPage = this,
|
|
|
|
doc = viewPage.surface.getModel().getDocument(),
|
2013-07-28 20:51:32 +00:00
|
|
|
data = new ve.dm.ElementLinearData( doc.getStore().clone(), ve.copy( doc.getFullData() ) ),
|
2013-06-23 23:09:47 +00:00
|
|
|
oldDom = viewPage.doc,
|
|
|
|
d = $.Deferred();
|
|
|
|
|
|
|
|
// Reset
|
|
|
|
viewPage.sanityCheckFinished = false;
|
|
|
|
viewPage.sanityCheckVerified = false;
|
|
|
|
|
|
|
|
setTimeout( function () {
|
|
|
|
// We can't compare oldDom.body and newDom.body directly, because the attributes on the
|
|
|
|
// <body> were ignored in the conversion. So compare each child separately.
|
|
|
|
var i,
|
2013-07-09 20:21:48 +00:00
|
|
|
len = oldDom.body.childNodes.length,
|
2013-07-26 22:33:58 +00:00
|
|
|
newDoc = new ve.dm.Document( data, undefined, doc.getInternalList() ),
|
|
|
|
newDom = ve.dm.converter.getDomFromData( newDoc.getFullData(), newDoc.getStore(), newDoc.getInternalList() );
|
2013-07-09 20:21:48 +00:00
|
|
|
|
2013-07-10 00:17:02 +00:00
|
|
|
// Explicitly unlink our full copy of the original version of the document data
|
|
|
|
data = undefined;
|
|
|
|
|
2013-06-23 23:09:47 +00:00
|
|
|
if ( len !== newDom.body.childNodes.length ) {
|
|
|
|
// Different number of children, so they're definitely different
|
|
|
|
d.reject();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
if ( !oldDom.body.childNodes[i].isEqualNode( newDom.body.childNodes[i] ) ) {
|
|
|
|
d.reject();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d.resolve();
|
|
|
|
} );
|
|
|
|
|
|
|
|
viewPage.sanityCheckPromise = d.promise()
|
|
|
|
.done( function () {
|
|
|
|
// If we detect no roundtrip errors,
|
|
|
|
// don't emphasize "review changes" to the user.
|
|
|
|
viewPage.sanityCheckVerified = true;
|
|
|
|
})
|
|
|
|
.always( function () {
|
|
|
|
viewPage.sanityCheckFinished = true;
|
|
|
|
viewPage.updateToolbarSaveButtonState();
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2013-06-20 00:28:51 +00:00
|
|
|
/**
|
2013-08-01 22:01:43 +00:00
|
|
|
* @see ve.ui.SurfaceToolbar#position
|
2013-06-20 00:28:51 +00:00
|
|
|
* @param {jQuery} $bar
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
* @param {Object} update
|
2013-06-20 00:28:51 +00:00
|
|
|
*/
|
2013-07-31 16:13:28 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarPosition = function ( $bar, update ) {
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
// It's important that the toolbar tracker always has 0 height, otherwise it will block events
|
|
|
|
// on the toolbar (e.g. clicking "Save page") as it would overlap that space. The save dialog
|
2013-06-20 00:28:51 +00:00
|
|
|
// will remain visible for the same reason elsewhere: As long as we don't have overflow:hidden,
|
|
|
|
// the save dialog will stick out of the tracker in the right place without the tracker itself
|
|
|
|
// blocking the toolbar.
|
|
|
|
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
if ( !this.toolbarTrackerFloating && update.floating === true ) {
|
|
|
|
// When switching to floating, undo the 'top' position set earlier
|
|
|
|
this.$toolbarTracker.css( 'top', '' );
|
|
|
|
}
|
2013-06-20 00:28:51 +00:00
|
|
|
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
if ( update.offset ) {
|
|
|
|
this.toolbarOffset = update.offset;
|
|
|
|
}
|
2013-06-20 00:28:51 +00:00
|
|
|
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
if ( typeof update.floating === 'boolean' ) {
|
|
|
|
this.$toolbarTracker.toggleClass(
|
|
|
|
've-init-mw-viewPageTarget-toolbarTracker-floating',
|
|
|
|
update.floating
|
|
|
|
);
|
|
|
|
this.toolbarTrackerFloating = update.floating;
|
|
|
|
}
|
2013-06-20 00:28:51 +00:00
|
|
|
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
// Switching to non-floating or offset update when already in non-floating
|
|
|
|
if ( update.floating === false || this.toolbarTrackerFloating === false && update.offset ) {
|
|
|
|
// Don't use update.css in this case since the toolbar is now in its non-floating
|
|
|
|
// position (static, in-flow). So make the tracker absolutely postioned matching the
|
|
|
|
// offset of the toolbar.
|
|
|
|
this.$toolbarTracker.css( {
|
|
|
|
'top': this.toolbarOffset.top,
|
|
|
|
'left': this.toolbarOffset.left,
|
|
|
|
'right': this.toolbarOffset.right
|
|
|
|
} );
|
|
|
|
} else if ( update.css ) {
|
|
|
|
this.$toolbarTracker.css( update.css );
|
2013-06-20 00:28:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-11 22:14:44 +00:00
|
|
|
/**
|
|
|
|
* Set up the logging of analytic edit events using EventLogging.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.setUpEventLogging = function () {
|
|
|
|
mw.loader.using( 'schema.Edit', function () {
|
|
|
|
mw.eventLog.setDefaults( 'Edit', {
|
|
|
|
version: 0,
|
|
|
|
editor: 'visualeditor',
|
2013-06-13 19:59:40 +00:00
|
|
|
pageId: mw.config.get( 'wgArticleId' ),
|
2013-06-11 22:14:44 +00:00
|
|
|
pageNs: mw.config.get( 'wgNamespaceNumber' ),
|
|
|
|
pageName: mw.config.get( 'wgPageName' ),
|
2013-06-14 18:13:59 +00:00
|
|
|
pageViewSessionId: mw.user.generateRandomSessionId(),
|
2013-06-13 19:59:40 +00:00
|
|
|
revId: function () {
|
|
|
|
return mw.config.get( 'wgCurRevisionId' );
|
2013-06-14 18:13:59 +00:00
|
|
|
},
|
|
|
|
userId: +mw.config.get( 'wgUserId' )
|
2013-06-11 22:14:44 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thin wrapper around EventLogging's 'logEvent' method which ensures the
|
|
|
|
* relevant schema module has been loaded.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.logEvent = function ( schemaName, event ) {
|
|
|
|
mw.loader.using( 'schema.' + schemaName, function () {
|
|
|
|
mw.eventLog.logEvent( schemaName, event );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Switch to viewing mode.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.tearDownSurface = function () {
|
2012-06-11 06:54:41 +00:00
|
|
|
// Update UI
|
2012-12-06 22:18:56 +00:00
|
|
|
if ( this.$document ) {
|
|
|
|
this.$document.blur();
|
|
|
|
this.$document = null;
|
|
|
|
}
|
2013-05-14 23:45:42 +00:00
|
|
|
this.tearDownToolbar();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.hideSpinner();
|
|
|
|
this.showPageContent();
|
|
|
|
this.restorePageTitle();
|
2013-05-17 16:09:20 +00:00
|
|
|
this.restoreDocumentTitle();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.showTableOfContents();
|
The Great ve.ui.Surface refactor of 2013
Prologue:
Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.
Note to Roan and/or Ed:
Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.
Objectives:
* Make it possible to have multiple surfaces be instantiated, get along
nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog
Approach:
* Move what's left of ve.Editor to ve.ui.Surface and essentially
obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
the top level one
* Resolve stacking order issues by removing the excessive use of z-index
and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype
Bonus:
* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed
Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
2013-05-20 22:45:50 +00:00
|
|
|
// Destroy surface
|
2012-12-06 22:18:56 +00:00
|
|
|
if ( this.surface ) {
|
|
|
|
this.surface.destroy();
|
|
|
|
this.surface = null;
|
|
|
|
}
|
2012-06-12 01:21:31 +00:00
|
|
|
this.active = false;
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Modify tabs in the skin to support in-place editing.
|
2013-07-03 22:14:52 +00:00
|
|
|
* Edit tab is bound outside the module in mw.ViewPageTarget.init.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupSkinTabs = function () {
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.isViewPage ) {
|
2012-08-01 06:40:22 +00:00
|
|
|
// Allow instant switching back to view mode, without refresh
|
|
|
|
$( '#ca-view a, #ca-nstab-visualeditor a' )
|
2012-08-11 08:14:56 +00:00
|
|
|
.click( ve.bind( this.onViewTabClick, this ) );
|
2012-06-18 21:13:26 +00:00
|
|
|
}
|
2013-07-09 01:35:35 +00:00
|
|
|
|
|
|
|
mw.hook( 've.skinTabSetupComplete' ).fire();
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Modify page content to make section edit links activate the editor.
|
2013-07-05 06:01:31 +00:00
|
|
|
* Dummy replaced by init.js so that we can call it again from #onSave after
|
|
|
|
* replacing the page contents with the new html.
|
2012-06-18 20:12:32 +00:00
|
|
|
*/
|
2013-07-05 06:01:31 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupSectionEditLinks = null;
|
2012-06-18 20:12:32 +00:00
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Add content and event bindings to toolbar buttons.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-11-30 23:09:34 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupToolbarButtons = function () {
|
2012-12-11 01:44:44 +00:00
|
|
|
var editNoticeCount = ve.getObjectKeys( this.editNotices ).length;
|
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-20 23:25:12 +00:00
|
|
|
|
2013-05-17 13:54:54 +00:00
|
|
|
this.toolbarCancelButton = new ve.ui.ButtonWidget( { 'label': ve.msg( 'visualeditor-toolbar-cancel' ) } );
|
2013-07-09 01:35:35 +00:00
|
|
|
this.toolbarCancelButton.$.addClass( 've-ui-toolbar-cancelButton' );
|
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-20 23:25:12 +00:00
|
|
|
this.toolbarSaveButton = new ve.ui.ButtonWidget( {
|
|
|
|
'label': ve.msg( 'visualeditor-toolbar-savedialog' ),
|
|
|
|
'flags': ['constructive'],
|
|
|
|
'disabled': !this.restoring
|
|
|
|
} );
|
2013-07-09 01:35:35 +00:00
|
|
|
// TODO (mattflaschen, 2013-06-27): it would be useful to do this in a more general way, such
|
|
|
|
// as in the ButtonWidget constructor.
|
|
|
|
this.toolbarSaveButton.$.addClass( 've-ui-toolbar-saveButton' );
|
2013-06-23 23:09:47 +00:00
|
|
|
this.updateToolbarSaveButtonState();
|
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-20 23:25:12 +00:00
|
|
|
|
2013-05-01 22:21:32 +00:00
|
|
|
this.toolbarCancelButton.connect( this, { 'click': 'onToolbarCancelButtonClick' } );
|
|
|
|
this.toolbarSaveButton.connect( this, { 'click': 'onToolbarSaveButtonClick' } );
|
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-20 23:25:12 +00:00
|
|
|
|
2013-06-05 19:28:00 +00:00
|
|
|
this.$toolbarMwMetaButton
|
|
|
|
.addClass( 've-ui-icon-settings' )
|
|
|
|
.append(
|
|
|
|
$( '<span>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool-label' )
|
|
|
|
.text( ve.msg( 'visualeditor-meta-tool' ) )
|
|
|
|
)
|
|
|
|
.click( ve.bind( this.onToolbarMwMetaButtonClick, this ) );
|
|
|
|
|
|
|
|
|
2012-11-30 23:09:34 +00:00
|
|
|
if ( editNoticeCount ) {
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarEditNoticesTool
|
2012-11-30 23:09:34 +00:00
|
|
|
.addClass( 've-ui-icon-alert' )
|
|
|
|
.append(
|
|
|
|
$( '<span>' )
|
2012-12-11 01:44:44 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool-label' )
|
|
|
|
.text( ve.msg( 'visualeditor-editnotices-tool', editNoticeCount ) )
|
2012-11-30 23:09:34 +00:00
|
|
|
)
|
|
|
|
.append( this.$toolbarEditNotices )
|
2012-12-11 01:44:44 +00:00
|
|
|
.click( ve.bind( this.onToolbarEditNoticesToolClick, this ) );
|
2012-11-30 23:09:34 +00:00
|
|
|
this.$toolbarEditNotices.fadeIn( 'fast' );
|
|
|
|
}
|
2013-06-12 01:17:10 +00:00
|
|
|
|
|
|
|
this.$toolbarBetaNoticeTool
|
2013-07-01 17:28:40 +00:00
|
|
|
.addClass( 've-ui-icon-help' )
|
2013-06-12 01:17:10 +00:00
|
|
|
.append(
|
|
|
|
$( '<span>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool-label ve-init-mw-viewPageTarget-tool-beta-label' )
|
|
|
|
.text( ve.msg( 'visualeditor-beta-label' ) )
|
|
|
|
)
|
|
|
|
.append( this.$toolbarBetaNotice )
|
|
|
|
.click( ve.bind( this.onToolbarBetaNoticeToolClick, this ) );
|
|
|
|
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarFeedbackTool
|
|
|
|
.addClass( 've-ui-icon-comment' )
|
|
|
|
.append(
|
|
|
|
$( '<span>' )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-tool-label' )
|
|
|
|
.text( ve.msg( 'visualeditor-feedback-tool' ) )
|
|
|
|
)
|
|
|
|
.click( ve.bind( this.onToolbarFeedbackToolClick, this ) );
|
2012-11-30 23:09:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Remove content and event bindings from toolbar buttons.
|
2012-11-30 23:09:34 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.tearDownToolbarButtons = function () {
|
2013-05-01 22:21:32 +00:00
|
|
|
this.toolbarCancelButton.disconnect( this );
|
|
|
|
this.toolbarSaveButton.disconnect( this );
|
2013-06-05 19:28:00 +00:00
|
|
|
this.$toolbarMwMetaButton.empty().off( 'click' );
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarEditNoticesTool.empty().off( 'click' );
|
2013-06-12 01:17:10 +00:00
|
|
|
this.$toolbarBetaNoticeTool.empty().off( 'click' );
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarFeedbackTool.empty().off( 'click' );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Add the save button to the user interface.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-11-30 23:09:34 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.attachToolbarButtons = function () {
|
2013-05-14 23:45:42 +00:00
|
|
|
var $target = this.toolbar.$actions;
|
2013-06-12 01:17:10 +00:00
|
|
|
$target.append( this.$toolbarBetaNoticeTool );
|
|
|
|
this.$toolbarBetaNotice.append( this.$toolbarFeedbackTool );
|
|
|
|
|
2012-12-11 01:44:44 +00:00
|
|
|
if ( !ve.isEmptyObject( this.editNotices ) ) {
|
|
|
|
$target.append( this.$toolbarEditNoticesTool );
|
|
|
|
}
|
2013-06-05 19:28:00 +00:00
|
|
|
$target.append(
|
|
|
|
this.$toolbarMwMetaButton,
|
|
|
|
this.toolbarCancelButton.$,
|
|
|
|
this.toolbarSaveButton.$
|
|
|
|
);
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Remove the save button from the user interface.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-11-30 23:09:34 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.detachToolbarButtons = function () {
|
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-20 23:25:12 +00:00
|
|
|
this.toolbarCancelButton.$.detach();
|
|
|
|
this.toolbarSaveButton.$.detach();
|
2013-06-05 23:53:38 +00:00
|
|
|
this.$toolbarMwMetaButton.detach();
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarEditNoticesTool.detach();
|
|
|
|
this.$toolbarFeedbackTool.detach();
|
2013-06-12 01:17:10 +00:00
|
|
|
this.$toolbarBetaNoticeTool.detach();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Add content and event bindings to the save dialog.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupSaveDialog = function () {
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
var sectionTitle = '', viewPage = this;
|
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-20 23:25:12 +00:00
|
|
|
|
2013-06-07 19:00:38 +00:00
|
|
|
// Save button on "save" slide
|
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-20 23:25:12 +00:00
|
|
|
this.saveDialogSaveButton = new ve.ui.ButtonWidget( {
|
|
|
|
'label': ve.msg(
|
2013-06-07 19:00:38 +00:00
|
|
|
// visualeditor-savedialog-label-restore, visualeditor-savedialog-label-save
|
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-20 23:25:12 +00:00
|
|
|
'visualeditor-savedialog-label-' + ( viewPage.restoring ? 'restore' : 'save' )
|
|
|
|
),
|
|
|
|
'flags': ['constructive']
|
|
|
|
} );
|
2013-05-01 22:21:32 +00:00
|
|
|
this.saveDialogSaveButton.connect( this, { 'click': 'onSaveDialogSaveButtonClick' } );
|
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-20 23:25:12 +00:00
|
|
|
|
2013-06-07 19:00:38 +00:00
|
|
|
// Review button on "save" slide
|
|
|
|
this.saveDialogReviewButton = new ve.ui.ButtonWidget( {
|
|
|
|
'label': ve.msg(
|
|
|
|
'visualeditor-savedialog-label-review'
|
|
|
|
)
|
|
|
|
} );
|
|
|
|
this.saveDialogReviewButton.connect( this, { 'click': 'onSaveDialogReviewButtonClick' } );
|
|
|
|
|
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-20 23:25:12 +00:00
|
|
|
this.saveDialogReviewGoodButton = new ve.ui.ButtonWidget( {
|
|
|
|
'label': ve.msg( 'visualeditor-savedialog-label-review-good' ),
|
|
|
|
'flags': ['constructive']
|
|
|
|
} );
|
2013-05-01 22:21:32 +00:00
|
|
|
this.saveDialogReviewGoodButton.connect(
|
|
|
|
this, { 'click': 'onSaveDialogReviewGoodButtonClick' }
|
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-20 23:25:12 +00:00
|
|
|
);
|
|
|
|
|
2013-05-14 16:50:29 +00:00
|
|
|
this.saveDialogResolveConflictButton = new ve.ui.ButtonWidget( {
|
|
|
|
'label': ve.msg( 'visualeditor-savedialog-label-resolve-conflict' ),
|
|
|
|
'flags': ['constructive']
|
|
|
|
} );
|
|
|
|
this.saveDialogResolveConflictButton.connect( this, { 'click': 'onSaveDialogResolveConflictButtonClick' } );
|
|
|
|
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
|
|
|
|
if ( viewPage.section ) {
|
|
|
|
sectionTitle = viewPage.$document.find( 'h1, h2, h3, h4, h5, h6' ).eq( viewPage.section - 1 ).text();
|
|
|
|
sectionTitle = '/* ' + ve.graphemeSafeSubstring( sectionTitle, 0, 244 ) + ' */ ';
|
|
|
|
viewPage.sectionTitleRestored = true;
|
|
|
|
if ( viewPage.sectionPositionRestored ) {
|
|
|
|
viewPage.onSectionRestored();
|
2013-07-18 22:34:16 +00:00
|
|
|
}
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
}
|
|
|
|
viewPage.$saveDialog
|
|
|
|
// Must not use replaceWith because that can't be used on fragement roots,
|
|
|
|
// plus, we want to preserve the reference and class names of the wrapper.
|
|
|
|
.empty().append( this.constructor.saveDialogTemplate )
|
|
|
|
// Attach buttons
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-slide-save' )
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-actions' )
|
|
|
|
.prepend( viewPage.saveDialogSaveButton.$, viewPage.saveDialogReviewButton.$ )
|
2012-12-02 03:44:07 +00:00
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-slide-review' )
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-actions' )
|
|
|
|
.prepend( viewPage.saveDialogReviewGoodButton.$ )
|
2012-12-07 16:23:23 +00:00
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-slide-conflict' )
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-actions' )
|
|
|
|
.prepend( viewPage.saveDialogResolveConflictButton.$ )
|
2013-07-18 22:34:16 +00:00
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-closeButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogCloseButtonClick, viewPage ) )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-prevButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogPrevButtonClick, viewPage ) )
|
|
|
|
.end()
|
|
|
|
// Attach contents
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary-label' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'summary' ) )
|
|
|
|
.end()
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' )
|
|
|
|
.attr( {
|
|
|
|
'placeholder': ve.msg( 'visualeditor-editsummary' )
|
|
|
|
} )
|
|
|
|
.val( sectionTitle )
|
|
|
|
.placeholder()
|
|
|
|
.byteLimit( viewPage.editSummaryByteLimit )
|
|
|
|
.on( {
|
|
|
|
'focus': function () {
|
|
|
|
$( this ).parent().addClass(
|
|
|
|
've-init-mw-viewPageTarget-saveDialog-summary-focused'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
'blur': function () {
|
|
|
|
$( this ).parent().removeClass(
|
|
|
|
've-init-mw-viewPageTarget-saveDialog-summary-focused'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
'keyup keydown mouseup cut paste change focus blur': function () {
|
|
|
|
var $textarea = $( this ),
|
|
|
|
$editSummaryCount = $textarea
|
|
|
|
.closest( '.ve-init-mw-viewPageTarget-saveDialog-slide-save' )
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-editSummaryCount' );
|
|
|
|
// TODO: This looks a bit weird, there is no unit in the UI, just numbers
|
|
|
|
// Users likely assume characters but then it seems to count down quicker
|
|
|
|
// than expected. Facing users with the word "byte" is bad? (bug 40035)
|
|
|
|
setTimeout( function () {
|
|
|
|
$editSummaryCount.text(
|
|
|
|
viewPage.editSummaryByteLimit - $.byteLength( $textarea.val() )
|
2012-12-11 00:26:09 +00:00
|
|
|
);
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
} )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-editSummaryCount' )
|
|
|
|
.text( viewPage.editSummaryByteLimit )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-checkboxes' )
|
|
|
|
.html( ve.getObjectValues( viewPage.checkboxes ).join( '\n' ) )
|
|
|
|
.find( 'a' )
|
|
|
|
.attr( 'target', '_blank' )
|
2012-12-04 06:56:41 +00:00
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.find( '#wpMinoredit' )
|
2013-05-15 12:33:39 +00:00
|
|
|
.prop( 'checked', +mw.user.options.get( 'minordefault' ) )
|
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.find( '#wpWatchthis' )
|
|
|
|
.prop( 'checked',
|
|
|
|
mw.user.options.get( 'watchdefault' ) ||
|
|
|
|
( mw.user.options.get( 'watchcreations' ) && !viewPage.pageExists ) ||
|
|
|
|
mw.config.get( 'wgVisualEditor' ).isPageWatched
|
|
|
|
)
|
2013-07-24 18:51:35 +00:00
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-license' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'copyrightwarning' ) )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-conflict' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'visualeditor-editconflict' ) )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-nochanges' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'visualeditor-diff-nochanges' ) )
|
|
|
|
;
|
|
|
|
|
|
|
|
// Get reference to loading icon
|
|
|
|
viewPage.$saveDialogLoadingIcon = viewPage.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-working' );
|
2013-06-23 23:09:47 +00:00
|
|
|
|
2012-06-21 03:16:10 +00:00
|
|
|
// Hook onto the 'watch' event on by mediawiki.page.watch.ajax.js
|
|
|
|
// Triggered when mw.page.watch.updateWatchLink(link, action) is called
|
|
|
|
$( '#ca-watch, #ca-unwatch' )
|
|
|
|
.on(
|
2012-06-21 17:46:47 +00:00
|
|
|
'watchpage.mw',
|
2012-09-06 00:54:43 +00:00
|
|
|
function ( e, action ) {
|
|
|
|
viewPage.$saveDialog
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.find( '#wpWatchthis' )
|
2012-09-06 00:54:43 +00:00
|
|
|
.prop( 'checked', ( action === 'watch' ) );
|
|
|
|
}
|
2012-06-21 03:16:10 +00:00
|
|
|
);
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 23:19:21 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Show the save dialog.
|
2012-12-11 23:19:21 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.showSaveDialog = function () {
|
|
|
|
var viewPage = this;
|
|
|
|
|
|
|
|
viewPage.surface.disable();
|
2013-07-10 00:16:25 +00:00
|
|
|
viewPage.$document.css( 'opacity', 0.5 );
|
2012-12-11 23:19:21 +00:00
|
|
|
|
2013-06-12 01:17:10 +00:00
|
|
|
viewPage.$toolbarBetaNotice.fadeOut( 'fast' );
|
2012-12-11 23:19:21 +00:00
|
|
|
viewPage.$toolbarEditNotices.fadeOut( 'fast' );
|
|
|
|
|
2013-06-07 19:00:38 +00:00
|
|
|
viewPage.swapSaveDialog( 'save' );
|
2012-12-11 23:19:21 +00:00
|
|
|
|
|
|
|
viewPage.$saveDialog.fadeIn( 'fast', function () {
|
|
|
|
// Initial size
|
|
|
|
viewPage.onResizeSaveDialog();
|
2013-06-24 17:51:59 +00:00
|
|
|
} );
|
2012-12-11 23:19:21 +00:00
|
|
|
|
|
|
|
$( document ).on( 'keydown.ve-savedialog', function ( e ) {
|
|
|
|
// Escape
|
2013-06-28 00:00:35 +00:00
|
|
|
if ( e.which === ve.Keys.ESCAPE ) {
|
2012-12-11 23:19:21 +00:00
|
|
|
viewPage.onSaveDialogCloseButtonClick();
|
|
|
|
}
|
2013-06-24 17:51:59 +00:00
|
|
|
} );
|
2012-12-11 23:19:21 +00:00
|
|
|
|
|
|
|
$( window ).on( 'resize.ve-savedialog', ve.bind( viewPage.onResizeSaveDialog, viewPage ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update window-size related aspects of the save dialog
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onResizeSaveDialog = function () {
|
|
|
|
var $d = this.$saveDialog, $w = $( window );
|
|
|
|
|
|
|
|
// Available space for css-height is window height,
|
|
|
|
// without the space between the dialog and the window top,
|
|
|
|
// without the space above/below between css-height and outerHeight.
|
|
|
|
$d.css( 'max-height',
|
|
|
|
$w.height() -
|
|
|
|
( $d.offset().top - $w.scrollTop() ) -
|
|
|
|
( $d.outerHeight( true ) - $d.height() ) -
|
|
|
|
20 // shadow
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Hide the save dialog
|
2012-12-11 23:19:21 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.hideSaveDialog = function () {
|
2013-06-24 00:35:04 +00:00
|
|
|
// Reset history on close (bug 49481)
|
|
|
|
this.saveDialogSlideHistory.length = 0;
|
2012-12-11 23:19:21 +00:00
|
|
|
this.$saveDialog.fadeOut( 'fast' );
|
|
|
|
if ( this.$document ) {
|
|
|
|
this.$document.focus();
|
|
|
|
}
|
|
|
|
$( document ).off( 'keydown.ve-savedialog' );
|
|
|
|
$( window ).off( 'resize', this.onResizeSaveDialog );
|
|
|
|
|
2013-01-08 20:27:44 +00:00
|
|
|
if ( this.surface ) {
|
|
|
|
this.surface.enable();
|
2013-07-10 00:16:25 +00:00
|
|
|
this.$document.css( 'opacity', '' );
|
2013-01-08 20:27:44 +00:00
|
|
|
}
|
2012-12-11 23:19:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Reset the fields of the save dialog.
|
|
|
|
*
|
|
|
|
* TODO: Maybe call this more cleverly only when the document changes, so that closing and
|
|
|
|
* re-opening the saveDialog doesn't remove the user input and the diff cache.
|
2012-12-11 23:19:21 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.resetSaveDialog = function () {
|
|
|
|
this.$saveDialog
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' )
|
|
|
|
.val( '' )
|
|
|
|
.end()
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
.find( '#wpMinoredit' )
|
2012-12-11 23:19:21 +00:00
|
|
|
.prop( 'checked', false )
|
|
|
|
.end()
|
|
|
|
// Clear the diff
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-viewer' )
|
|
|
|
.empty();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-06-07 19:00:38 +00:00
|
|
|
* Swap state in the save dialog.
|
2012-12-11 23:19:21 +00:00
|
|
|
*
|
|
|
|
* @method
|
2013-06-07 19:45:43 +00:00
|
|
|
* @param {string} slide One of 'save', 'review', 'conflict' or 'nochanges'
|
2013-06-07 19:00:38 +00:00
|
|
|
* @param {Object} [options]
|
|
|
|
* @param {boolean} [options.fromHistory] Whether this swap was triggered from interaction
|
|
|
|
* with the slide history (e.g. surpresses pushing of target slide in the history again).
|
2013-06-17 10:50:24 +00:00
|
|
|
* @returns {jQuery} The now active slide.
|
2013-01-15 23:38:49 +00:00
|
|
|
* @throws {Error} Unknown saveDialog slide
|
2012-12-11 23:19:21 +00:00
|
|
|
*/
|
2013-06-07 19:00:38 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.swapSaveDialog = function ( slide, options ) {
|
|
|
|
var $slide, $viewer,
|
|
|
|
doc = this.surface.getModel().getDocument();
|
|
|
|
|
2013-06-07 19:45:43 +00:00
|
|
|
if ( ve.indexOf( slide, [ 'save', 'review', 'conflict', 'nochanges' ] ) === -1 ) {
|
2012-12-11 23:19:21 +00:00
|
|
|
throw new Error( 'Unknown saveDialog slide: ' + slide );
|
|
|
|
}
|
|
|
|
|
2013-06-07 19:00:38 +00:00
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
if ( !options.fromHistory ) {
|
|
|
|
this.saveDialogSlideHistory.push( slide );
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:19:21 +00:00
|
|
|
$slide = this.$saveDialog.find( '.ve-init-mw-viewPageTarget-saveDialog-slide-' + slide );
|
|
|
|
|
|
|
|
this.$saveDialog
|
2013-06-07 19:00:38 +00:00
|
|
|
// Hide "prev" button when (back) on the first slide
|
2012-12-11 23:19:21 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-prevButton' )
|
2013-06-07 19:00:38 +00:00
|
|
|
.toggle( this.saveDialogSlideHistory.length >= 2 )
|
2012-12-11 23:19:21 +00:00
|
|
|
.end()
|
2013-06-07 19:00:38 +00:00
|
|
|
// Update title to one of:
|
|
|
|
// - visualeditor-savedialog-title-save
|
|
|
|
// - visualeditor-savedialog-title-review
|
|
|
|
// - visualeditor-savedialog-title-conflict
|
|
|
|
// - visualeditor-savedialog-title-nochanges
|
2012-12-11 23:19:21 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-title' )
|
|
|
|
.text( ve.msg( 'visualeditor-savedialog-title-' + slide ) )
|
|
|
|
.end()
|
|
|
|
// Hide other slides
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-slide' )
|
|
|
|
.not( $slide )
|
|
|
|
.hide();
|
|
|
|
|
2013-06-30 18:40:57 +00:00
|
|
|
// Old messages should not persist after slide changes
|
|
|
|
this.clearAllMessages();
|
|
|
|
// Reset save button if we disabled it for e.g. unrecoverable spam error
|
|
|
|
this.saveDialogSaveButton.setDisabled( false );
|
2013-06-23 23:09:47 +00:00
|
|
|
|
|
|
|
if ( slide === 'save' ) {
|
|
|
|
if ( !this.sanityCheckVerified ) {
|
2013-06-30 18:40:57 +00:00
|
|
|
this.showMessage( 'dirtywarning', mw.msg( 'visualeditor-savedialog-warning-dirty' ) );
|
2013-06-23 23:09:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:19:21 +00:00
|
|
|
if ( slide === 'review' ) {
|
2013-06-23 23:09:47 +00:00
|
|
|
this.sanityCheckVerified = true;
|
2012-12-11 23:19:21 +00:00
|
|
|
$viewer = $slide.find( '.ve-init-mw-viewPageTarget-saveDialog-viewer' );
|
|
|
|
if ( !$viewer.find( 'table, pre' ).length ) {
|
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-20 23:25:12 +00:00
|
|
|
this.saveDialogReviewGoodButton.setDisabled( true );
|
2012-12-11 23:19:21 +00:00
|
|
|
this.$saveDialogLoadingIcon.show();
|
|
|
|
if ( this.pageExists ) {
|
2013-05-08 18:17:50 +00:00
|
|
|
// Has no callback, handled via target.onShowChanges
|
2012-12-11 23:19:21 +00:00
|
|
|
this.showChanges(
|
2013-04-17 17:53:26 +00:00
|
|
|
ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() )
|
2012-12-11 23:19:21 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.serialize(
|
2013-04-17 17:53:26 +00:00
|
|
|
ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ),
|
2013-05-08 18:17:50 +00:00
|
|
|
ve.bind( this.onSerialize, this )
|
2012-12-11 23:19:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2012-12-12 03:32:55 +00:00
|
|
|
this.$saveDialog.css( 'width', '100%' );
|
2012-12-11 23:19:21 +00:00
|
|
|
} else {
|
|
|
|
this.$saveDialog.css( 'width', '' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show the target slide
|
|
|
|
$slide.show();
|
|
|
|
|
2013-07-09 01:35:35 +00:00
|
|
|
mw.hook( 've.saveDialog.stateChanged' ).fire();
|
|
|
|
|
2013-06-07 19:45:43 +00:00
|
|
|
if ( slide === 'save' ) {
|
2012-12-11 23:19:21 +00:00
|
|
|
setTimeout( function () {
|
2013-07-18 22:34:16 +00:00
|
|
|
var $textarea = $slide.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' );
|
|
|
|
$textarea.focus();
|
|
|
|
// If message has be pre-filled (e.g. section edit), move cursor to end
|
|
|
|
if ( $textarea.val() !== '' ) {
|
|
|
|
ve.selectEnd( $textarea[0] );
|
|
|
|
}
|
2012-12-11 23:19:21 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $slide;
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Add the save dialog to the user interface.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.attachSaveDialog = function () {
|
2013-06-20 00:28:51 +00:00
|
|
|
this.surface.$globalOverlay.append(
|
|
|
|
this.$toolbarTracker.append(
|
|
|
|
this.$saveDialog
|
|
|
|
)
|
|
|
|
);
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Remove the save dialog from the user interface.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.detachSaveDialog = function () {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.$saveDialog.detach();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Remember the window's scroll position.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.saveScrollPosition = function () {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.scrollTop = $( window ).scrollTop();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Restore the window's scroll position.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.restoreScrollPosition = function () {
|
2012-06-18 20:12:32 +00:00
|
|
|
if ( this.scrollTop ) {
|
|
|
|
$( window ).scrollTop( this.scrollTop );
|
|
|
|
this.scrollTop = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Show the loading spinner.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.showSpinner = function () {
|
2012-08-28 22:06:34 +00:00
|
|
|
$( '#firstHeading' ).prepend( this.$spinner );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Hide the loading spinner.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.hideSpinner = function () {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.$spinner.detach();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Show the page content.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.showPageContent = function () {
|
2012-08-01 00:49:04 +00:00
|
|
|
$( '#bodyContent > .ve-init-mw-viewPageTarget-content' )
|
2012-07-20 23:59:59 +00:00
|
|
|
.removeClass( 've-init-mw-viewPageTarget-content' )
|
2012-06-19 00:39:31 +00:00
|
|
|
.show()
|
|
|
|
.fadeTo( 0, 1 );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Mute the page content.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.mutePageContent = function () {
|
2012-09-05 07:38:19 +00:00
|
|
|
$( '#bodyContent > :visible:not(#siteSub, #contentSub)' )
|
2012-07-20 23:59:59 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-content' )
|
2012-06-19 04:47:09 +00:00
|
|
|
.fadeTo( 'fast', 0.6 );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Hide the page content.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.hidePageContent = function () {
|
2012-09-05 07:38:19 +00:00
|
|
|
$( '#bodyContent > :visible:not(#siteSub, #contentSub)' )
|
2012-07-20 23:59:59 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-content' )
|
2012-06-19 00:39:31 +00:00
|
|
|
.hide();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Show the table of contents in the view mode.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.showTableOfContents = function () {
|
2012-09-05 07:38:19 +00:00
|
|
|
var $toc = $( '#toc' ),
|
|
|
|
$wrap = $toc.parent();
|
|
|
|
if ( $wrap.data( 've.hideTableOfContents' ) ) {
|
2013-06-24 17:51:59 +00:00
|
|
|
$wrap.slideDown( function () {
|
2012-09-05 07:38:19 +00:00
|
|
|
$toc.unwrap();
|
2013-06-24 17:51:59 +00:00
|
|
|
} );
|
2012-09-05 07:38:19 +00:00
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Hide the table of contents in the view mode.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.hideTableOfContents = function () {
|
2012-09-05 07:38:19 +00:00
|
|
|
$( '#toc' )
|
|
|
|
.wrap( '<div>' )
|
|
|
|
.parent()
|
|
|
|
.data( 've.hideTableOfContents', true )
|
|
|
|
.slideUp();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Show the toolbar.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* This also transplants the toolbar to a new location.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
2012-06-18 20:12:32 +00:00
|
|
|
* @method
|
|
|
|
*/
|
2013-05-14 23:45:42 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.setUpToolbar = function () {
|
2013-08-01 22:01:43 +00:00
|
|
|
this.toolbar = new ve.ui.SurfaceToolbar( this.surface, { 'shadow': true, 'actions': true } );
|
2013-07-31 16:13:28 +00:00
|
|
|
this.toolbar.connect( this, { 'position': 'onToolbarPosition' } );
|
2013-05-14 23:45:42 +00:00
|
|
|
this.toolbar.addTools( this.constructor.static.toolbarTools );
|
The Great ve.ui.Surface refactor of 2013
Prologue:
Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.
Note to Roan and/or Ed:
Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.
Objectives:
* Make it possible to have multiple surfaces be instantiated, get along
nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog
Approach:
* Move what's left of ve.Editor to ve.ui.Surface and essentially
obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
the top level one
* Resolve stacking order issues by removing the excessive use of z-index
and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype
Bonus:
* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed
Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
2013-05-20 22:45:50 +00:00
|
|
|
this.surface.addCommands( this.constructor.static.surfaceCommands );
|
2013-05-14 23:45:42 +00:00
|
|
|
if ( !this.isMobileDevice ) {
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
this.toolbar.enableFloatable();
|
2013-05-14 23:45:42 +00:00
|
|
|
}
|
|
|
|
this.toolbar.$
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-toolbar' )
|
|
|
|
.insertBefore( '#firstHeading' );
|
|
|
|
this.toolbar.$bar.slideDown( 'fast', ve.bind( function () {
|
2013-05-17 16:44:21 +00:00
|
|
|
// Check the surface wasn't torn down while the toolbar was animating
|
|
|
|
if ( this.surface ) {
|
ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==
* enableFloating -> enableFloatable
* disableFloating -> disableFloatable
* setPosition -> float
* resetPosition -> unfloat
== Scroll and resize event ==
Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.
New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer
The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.
Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.
== Changes ==
* New: ve.ui.Toolbar#initialize.
Similar to what surface has. Users of Toolbar should decide
whether to call enableFloatable, append it to the DOM at some
point and then call initialize() once.
* Don't compute offset() every time.
Eliminated by doing it once in #initialize. These 'top' and
'left' offsets do not change.
* Don't compute outerWidth() and $window.width() every time.
Reduced by doing it once in #initialize to compute the 'right'
offset. Updating it only on resize.
* Don't set 'top' every time.
This is already in the stylesheet. It was never set to anything
else so the abstraction for it in #float has been removed.
This also made it obvious that code for "ve-ui-toolbar-bottom"
was unused and left behind. Tha class was only ever being
removed from something (never added).
The one addClass call for it was in a condition that is always
false ("if top > 0").
* Don't set 'left' every time.
Eliminated by doing it once in #float.
* Don't set 'right' every time.
Reduced by no longer doing it on scroll. Done once in #float,
and on resize after computing the new value for it.
* Remove no-op style operations.
Wrapped methods in if-floatable, if-floated etc. to reduce a
fair amount of easily avoided re-paint overhead.
* Avoid double re-paint in mw.ViewPageTarget.
Though we prevent a lot of redundant re-paints now, whenever
we do repaint we want to do it in 1 repaint instead of 2.
ve.ui.Toolbar emits #toolbarPosition, which tells
mw.ViewPageTarget to update toolbarTracker which would read
the new $bar style properties and copy them over to the
$toolbarTracker. However, this read operation forces the browser
to do an immediate re-paint half-way just for $bar.
Browsers only repaint when style properties are changed and
JS has yielded. The exception to this is JS reading style
properties: in that case the browser is forced to do those
deferred repaints directly and reflect the new values.
We can avoid this double repaint by passing the updated values
as data instead of requiring the receiver to read the DOM (and
thus a keep the deferred repaint). Now toolbarTracker can use
them directly whilst the browser hasn't even repainted $bar yet.
== Clean up ==
* Redundant "border-radius: 0". This would reset something, but
it never does. None of the things it inherits from set a
border-radius. There is one subclass where toolbar is used
with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
sets a border-radius) which overrides this on purpose, so the
default of 0 is redundant.
* Pattern "if ( .. ) addClass() else removeClass()" changed to:
"toggleClass( , .. )"
Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-25 02:36:01 +00:00
|
|
|
this.toolbar.initialize();
|
2013-07-31 20:15:33 +00:00
|
|
|
this.surface.emit( 'position' );
|
2013-05-17 16:44:21 +00:00
|
|
|
this.surface.getContext().update();
|
|
|
|
}
|
2013-05-14 23:45:42 +00:00
|
|
|
}, this ) );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Hide the toolbar.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2013-05-14 23:45:42 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.tearDownToolbar = function () {
|
|
|
|
this.toolbar.$bar.slideUp( 'fast', ve.bind( function () {
|
|
|
|
this.toolbar.destroy();
|
|
|
|
this.toolbar = null;
|
|
|
|
}, this ) );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-05-17 15:38:48 +00:00
|
|
|
* Transform the page title into a VE-style title.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.transformPageTitle = function () {
|
2012-07-20 23:59:59 +00:00
|
|
|
$( '#firstHeading' ).addClass( 've-init-mw-viewPageTarget-pageTitle' );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-05-17 15:38:48 +00:00
|
|
|
* Fade the page title to indicate it is not editable.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Remainder JSHint fixes on modules/ve/*
[jshint]
ce/ve.ce.Surface.js: line 670, col 9, Too many var statements.
ce/ve.ce.Surface.js: line 695, col 6, Missing semicolon.
ce/ve.ce.Surface.js: line 726, col 22, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 726, col 41, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 733, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 734, col 24, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 1013, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 1019, col 17, Too many var statements.
ce/ve.ce.Surface.js: line 1023, col 18, Too many ar statements.
ce/ve.ce.Surface.js: line 1027, col 13, Too many var statements.
dm/annotations/ve.dm.LinkAnnotation.js: line 70, col 52, Insecure '.'.
dm/ve.dm.Converter.js: line 383, col 29, Empty block.
dm/ve.dm.Converter.js: line 423, col 33, Empty block.
Commands:
* jshint .
* ack '(if|else|function|switch|for|while)\('
* Sublime Text 2:
Find(*): (if|else|function|switch|for|while)\(
Replace: $1 (
* ack ' ' -Q # double spaces, except in certain comments
Change-Id: I8e34bf2924bc8688fdf8acef08bbc4f6707e93be
2012-09-02 21:45:01 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.mutePageTitle = function () {
|
2013-07-24 03:05:54 +00:00
|
|
|
$( '#firstHeading, #siteSub:visible' ).fadeTo( 'fast', 0.6 );
|
|
|
|
$( '#contentSub:visible' ).fadeTo( 'fast', 0 );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-05-17 15:38:48 +00:00
|
|
|
* Restore the page title to its original style.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.restorePageTitle = function () {
|
2012-08-23 19:01:07 +00:00
|
|
|
$( '#firstHeading, #siteSub:visible, #contentSub:visible' ).fadeTo( 'fast', 1 );
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
setTimeout( function () {
|
2012-07-20 23:59:59 +00:00
|
|
|
$( '#firstHeading' ).removeClass( 've-init-mw-viewPageTarget-pageTitle' );
|
2012-06-18 20:12:32 +00:00
|
|
|
}, 1000 );
|
|
|
|
};
|
|
|
|
|
2013-05-17 16:09:20 +00:00
|
|
|
/**
|
|
|
|
* Change the document title to state that we are now editing.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.changeDocumentTitle = function () {
|
|
|
|
document.title = ve.msg(
|
|
|
|
this.pageExists ? 'editing' : 'creating',
|
|
|
|
mw.config.get( 'wgTitle' )
|
|
|
|
) + ' - ' + mw.config.get( 'wgSiteName' );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore the original document title.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.restoreDocumentTitle = function () {
|
|
|
|
document.title = this.originalDocumentTitle;
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2013-06-05 21:38:39 +00:00
|
|
|
* Page modifications for switching to edit mode.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2013-06-05 21:38:39 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.transformPage = function () {
|
2013-06-05 22:39:43 +00:00
|
|
|
var uri;
|
2013-06-05 21:38:39 +00:00
|
|
|
|
|
|
|
// Put skin tabs in "edit" mode
|
2012-08-23 18:01:20 +00:00
|
|
|
$( $( '#p-views' ).length ? '#p-views' : '#p-cactions' )
|
|
|
|
.find( 'li.selected' ).removeClass( 'selected' );
|
2013-08-01 19:14:41 +00:00
|
|
|
$( '#ca-ve-edit' )
|
2012-11-28 18:11:11 +00:00
|
|
|
.addClass( 'selected' );
|
2013-06-05 21:38:39 +00:00
|
|
|
|
|
|
|
// Hide site notice (if present)
|
|
|
|
$( '#siteNotice:visible' )
|
|
|
|
.addClass( 've-hide' )
|
|
|
|
.slideUp( 'fast' );
|
2013-06-05 22:39:43 +00:00
|
|
|
|
|
|
|
// Push veaction=edit url in history (if not already. If we got here by a veaction=edit
|
|
|
|
// permalink then it will be there already and the constructor called #activate)
|
|
|
|
if ( !this.actFromPopState && window.history.pushState && this.currentUri.query.veaction !== 'edit' ) {
|
|
|
|
// Set the veaction query parameter
|
|
|
|
uri = this.currentUri;
|
|
|
|
uri.query.veaction = 'edit';
|
|
|
|
|
|
|
|
window.history.pushState( null, document.title, uri );
|
|
|
|
}
|
|
|
|
this.actFromPopState = false;
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-06-05 21:38:39 +00:00
|
|
|
* Page modifications for switching back to view mode.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2013-06-05 21:38:39 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.restorePage = function () {
|
2013-06-05 22:39:43 +00:00
|
|
|
var uri;
|
2013-06-05 21:38:39 +00:00
|
|
|
|
|
|
|
// Put skin tabs back in "view" mode
|
2012-08-23 18:01:20 +00:00
|
|
|
$( $( '#p-views' ).length ? '#p-views' : '#p-cactions' )
|
|
|
|
.find( 'li.selected' ).removeClass( 'selected' );
|
2012-06-18 20:12:32 +00:00
|
|
|
$( '#ca-view' ).addClass( 'selected' );
|
|
|
|
|
2012-06-21 19:44:33 +00:00
|
|
|
|
2013-06-05 21:38:39 +00:00
|
|
|
// Make site notice visible again (if present)
|
2013-06-24 17:51:59 +00:00
|
|
|
$( '#siteNotice.ve-hide' )
|
2012-06-21 20:01:42 +00:00
|
|
|
.slideDown( 'fast' );
|
2013-06-05 22:39:43 +00:00
|
|
|
|
|
|
|
// Push non-veaction=edit url in history
|
|
|
|
if ( !this.actFromPopState && window.history.pushState ) {
|
|
|
|
// Remove the veaction query parameter
|
|
|
|
uri = this.currentUri;
|
|
|
|
if ( 'veaction' in uri.query ) {
|
|
|
|
delete uri.query.veaction;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there are other query parameters, set the url to the current url (with veaction removed).
|
|
|
|
// Otherwise use the canonical style view url (bug 42553).
|
|
|
|
if ( ve.getObjectValues( uri.query ).length ) {
|
|
|
|
window.history.pushState( null, document.title, uri );
|
|
|
|
} else {
|
|
|
|
window.history.pushState( null, document.title, this.viewUri );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.actFromPopState = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Event} e Native event object
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onWindowPopState = function () {
|
|
|
|
var newUri = this.currentUri = new mw.Uri( document.location.href );
|
|
|
|
if ( !this.active && newUri.query.veaction === 'edit' ) {
|
|
|
|
this.actFromPopState = true;
|
|
|
|
this.activate();
|
|
|
|
}
|
|
|
|
if ( this.active && newUri.query.veaction !== 'edit' ) {
|
|
|
|
this.actFromPopState = true;
|
|
|
|
this.deactivate();
|
|
|
|
}
|
2012-06-21 19:44:33 +00:00
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Replace the page content with new HTML.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {HTMLElement} html Rendered HTML from server
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html ) {
|
2013-07-30 17:35:23 +00:00
|
|
|
var $content = $( $.parseHTML( html ) );
|
|
|
|
mw.hook( 'wikipage.content' ).fire( $( '#mw-content-text' ).empty().append( $content ) );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Get the numeric index of a section in the page.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {HTMLElement} heading Heading element of section
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.getEditSection = function ( heading ) {
|
2012-06-18 23:18:48 +00:00
|
|
|
var $page = $( '#mw-content-text' ),
|
2012-06-18 20:12:32 +00:00
|
|
|
section = 0;
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
$page.find( 'h1, h2, h3, h4, h5, h6' ).not( '#toc h2' ).each( function () {
|
2012-06-18 23:18:48 +00:00
|
|
|
section++;
|
2012-06-18 20:12:32 +00:00
|
|
|
if ( this === heading ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} );
|
2012-06-18 23:18:48 +00:00
|
|
|
return section;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-07-18 22:34:16 +00:00
|
|
|
* Store the section for which the edit link has been triggered.
|
2012-06-18 23:18:48 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {HTMLElement} heading Heading element of section
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.saveEditSection = function ( heading ) {
|
2012-06-18 23:18:48 +00:00
|
|
|
this.section = this.getEditSection( heading );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Move the cursor in the editor to a given section.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @param {number} section Section to move cursor to
|
2012-06-18 20:12:32 +00:00
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.restoreEditSection = function () {
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.section !== null ) {
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
var offset,
|
2013-06-24 18:52:24 +00:00
|
|
|
target = this,
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
surfaceView = this.surface.getView(),
|
2012-06-18 20:12:32 +00:00
|
|
|
surfaceModel = surfaceView.getModel();
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
this.$document.find( 'h1, h2, h3, h4, h5, h6' ).eq( this.section - 1 ).each( function () {
|
2013-06-24 19:20:12 +00:00
|
|
|
var offsetNode, nextNode,
|
|
|
|
headingNode = $( this ).data( 'view' ),
|
|
|
|
lastHeadingLevel = -1;
|
2013-06-24 18:52:24 +00:00
|
|
|
|
2012-06-19 17:50:33 +00:00
|
|
|
if ( headingNode ) {
|
2013-06-24 19:20:12 +00:00
|
|
|
// Find next sibling which isn't a heading
|
|
|
|
offsetNode = headingNode;
|
|
|
|
while ( offsetNode instanceof ve.ce.HeadingNode && offsetNode.getModel().getAttribute( 'level' ) > lastHeadingLevel ) {
|
|
|
|
lastHeadingLevel = offsetNode.getModel().getAttribute( 'level' );
|
|
|
|
// Next sibling
|
|
|
|
nextNode = offsetNode.parent.children[ve.indexOf( offsetNode, offsetNode.parent.children ) + 1];
|
|
|
|
if ( !nextNode ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
offsetNode = nextNode;
|
|
|
|
}
|
2013-03-20 22:35:05 +00:00
|
|
|
offset = surfaceModel.getDocument().data.getNearestContentOffset(
|
2013-06-24 19:20:12 +00:00
|
|
|
offsetNode.getModel().getOffset(), 1
|
2012-06-19 17:50:33 +00:00
|
|
|
);
|
2013-06-24 19:20:12 +00:00
|
|
|
surfaceModel.change( null, new ve.Range( offset ) );
|
2013-06-24 18:52:24 +00:00
|
|
|
// Scroll to heading:
|
|
|
|
// Wait for toolbar to animate in so we can account for its height
|
|
|
|
setTimeout( function () {
|
2013-06-27 17:25:28 +00:00
|
|
|
var $window = $( ve.Element.getWindow( target.$ ) );
|
2013-06-24 18:52:24 +00:00
|
|
|
$window.scrollTop( headingNode.$.offset().top - target.toolbar.$.height() );
|
|
|
|
}, 200 );
|
2012-06-19 17:50:33 +00:00
|
|
|
}
|
|
|
|
} );
|
2013-07-18 22:34:16 +00:00
|
|
|
this.sectionPositionRestored = true;
|
|
|
|
if ( this.sectionTitleRestored ) {
|
|
|
|
this.onSectionRestored();
|
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
}
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2013-07-18 22:34:16 +00:00
|
|
|
/**
|
|
|
|
* Handle restoration of section editing position and title
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSectionRestored = function () {
|
|
|
|
this.section = null;
|
|
|
|
this.sectionPositionRestored = false;
|
|
|
|
this.sectionTitleRestored = false;
|
|
|
|
};
|
|
|
|
|
2013-05-17 14:27:33 +00:00
|
|
|
/**
|
2013-06-30 18:40:57 +00:00
|
|
|
* Show a message in the save dialog.
|
|
|
|
*
|
|
|
|
* @param {string} name Message's unique name
|
2013-07-17 01:11:19 +00:00
|
|
|
* @param {string|jQuery|Array} message Message content (string of HTML, jQuery object or array of
|
|
|
|
* Node objects)
|
2013-06-29 01:56:58 +00:00
|
|
|
* @param {Object} [options]
|
2013-06-30 18:40:57 +00:00
|
|
|
* @param {boolean} [options.wrap="warning"] Whether to wrap the message in a paragraph and if
|
|
|
|
* so, how. One of "warning", "error" or false.
|
2013-05-17 14:27:33 +00:00
|
|
|
*/
|
2013-06-30 18:40:57 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.showMessage = function ( name, message, options ) {
|
|
|
|
var $message;
|
|
|
|
if ( !this.messages[name] ) {
|
2013-06-29 01:56:58 +00:00
|
|
|
options = options || {};
|
2013-07-01 23:00:43 +00:00
|
|
|
if ( options.wrap === undefined ) {
|
|
|
|
options.wrap = 'warning';
|
|
|
|
}
|
2013-06-30 18:40:57 +00:00
|
|
|
$message = $( '<div class="ve-init-mw-viewPageTarget-saveDialog-message"></div>' );
|
2013-06-29 01:56:58 +00:00
|
|
|
if ( options.wrap !== false ) {
|
2013-06-30 18:40:57 +00:00
|
|
|
$message.append( $( '<p>').append(
|
|
|
|
// visualeditor-savedialog-label-error
|
|
|
|
// visualeditor-savedialog-label-warning
|
|
|
|
$( '<strong>' ).text( mw.msg( 'visualeditor-savedialog-label-' + options.wrap ) ),
|
|
|
|
document.createTextNode( mw.msg( 'colon-separator' ) ),
|
|
|
|
message
|
|
|
|
) );
|
2013-06-29 01:56:58 +00:00
|
|
|
} else {
|
2013-06-30 18:40:57 +00:00
|
|
|
$message.append( message );
|
2013-06-29 01:56:58 +00:00
|
|
|
}
|
2013-06-30 18:40:57 +00:00
|
|
|
this.$saveDialog.find( '.ve-init-mw-viewPageTarget-saveDialog-messages' )
|
|
|
|
.append( $message );
|
2013-06-29 01:56:58 +00:00
|
|
|
|
2013-06-30 18:40:57 +00:00
|
|
|
this.messages[name] = $message;
|
2013-05-17 14:27:33 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-06-30 18:40:57 +00:00
|
|
|
* Remove a message from the save dialog.
|
|
|
|
* @param {string} name Message's unique name
|
2013-05-17 14:27:33 +00:00
|
|
|
*/
|
2013-06-30 18:40:57 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.clearMessage = function ( name ) {
|
|
|
|
if ( this.messages[name] ) {
|
|
|
|
this.messages[name].remove();
|
|
|
|
delete this.messages[name];
|
2013-05-17 14:27:33 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-06-30 18:40:57 +00:00
|
|
|
* Remove all messages from the save dialog.
|
2013-05-17 14:27:33 +00:00
|
|
|
*/
|
2013-06-30 18:40:57 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.clearAllMessages = function () {
|
2013-05-17 14:27:33 +00:00
|
|
|
this.$saveDialog
|
2013-06-30 18:40:57 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-messages' )
|
2013-05-17 14:27:33 +00:00
|
|
|
.empty();
|
2013-06-30 18:40:57 +00:00
|
|
|
this.messages = {};
|
2013-05-17 14:27:33 +00:00
|
|
|
};
|
|
|
|
|
2012-06-21 03:16:10 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Add onbeforunload handler.
|
2012-06-21 03:16:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.setupBeforeUnloadHandler = function () {
|
2012-06-21 03:16:10 +00:00
|
|
|
// Remember any already set on before unload handler
|
|
|
|
this.onBeforeUnloadFallback = window.onbeforeunload;
|
|
|
|
// Attach before unload handler
|
2013-05-01 22:21:32 +00:00
|
|
|
window.onbeforeunload = this.onBeforeUnloadHandler = ve.bind( this.onBeforeUnload, this );
|
2012-06-21 03:16:10 +00:00
|
|
|
// Attach page show handlers
|
|
|
|
if ( window.addEventListener ) {
|
2012-08-11 08:14:56 +00:00
|
|
|
window.addEventListener( 'pageshow', ve.bind( this.onPageShow, this ), false );
|
2012-06-21 03:16:10 +00:00
|
|
|
} else if ( window.attachEvent ) {
|
2012-08-11 08:14:56 +00:00
|
|
|
window.attachEvent( 'pageshow', ve.bind( this.onPageShow, this ) );
|
2012-06-21 03:16:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Remove onbeforunload handler.
|
2012-06-21 03:16:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-11-30 23:09:34 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.tearDownBeforeUnloadHandler = function () {
|
2012-06-21 03:16:10 +00:00
|
|
|
// Restore whatever previous onbeforeload hook existed
|
|
|
|
window.onbeforeunload = this.onBeforeUnloadFallback;
|
|
|
|
};
|
|
|
|
|
2013-08-01 20:18:33 +00:00
|
|
|
/**
|
|
|
|
* Show beta welcome dialog if first load.
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.showBetaWelcome = function () {
|
|
|
|
if ( $.cookie( 've-beta-welcome-dialog' ) === null ) {
|
|
|
|
this.surface.getDialogs().open( 'mwBetaWelcome' );
|
|
|
|
}
|
|
|
|
$.cookie( 've-beta-welcome-dialog', 1, { 'path': '/', 'expires': 30 } );
|
|
|
|
};
|
|
|
|
|
2012-06-21 03:16:10 +00:00
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle page show event.
|
2012-06-21 03:16:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onPageShow = function () {
|
2012-06-21 03:16:10 +00:00
|
|
|
// Re-add onbeforeunload handler
|
2013-05-01 22:21:32 +00:00
|
|
|
window.onbeforeunload = this.onBeforeUnloadHandler;
|
2012-06-21 03:16:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-15 23:38:49 +00:00
|
|
|
* Handle before unload event.
|
2012-06-21 03:16:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onBeforeUnload = function () {
|
2012-06-21 03:16:10 +00:00
|
|
|
var fallbackResult,
|
|
|
|
message,
|
2013-05-01 22:21:32 +00:00
|
|
|
onBeforeUnloadHandler = this.onBeforeUnloadHandler;
|
2012-06-21 03:16:10 +00:00
|
|
|
// Check if someone already set on onbeforeunload hook
|
|
|
|
if ( this.onBeforeUnloadFallback ) {
|
|
|
|
// Get the result of their onbeforeunload hook
|
|
|
|
fallbackResult = this.onBeforeUnloadFallback();
|
|
|
|
}
|
|
|
|
// Check if their onbeforeunload hook returned something
|
|
|
|
if ( fallbackResult !== undefined ) {
|
|
|
|
// Exit here, returning their message
|
|
|
|
message = fallbackResult;
|
|
|
|
} else {
|
2012-11-28 23:57:00 +00:00
|
|
|
// Override if submitting
|
|
|
|
if ( this.submitting ) {
|
|
|
|
return null;
|
|
|
|
}
|
2012-06-21 03:16:10 +00:00
|
|
|
// Check if there's been an edit
|
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-20 23:25:12 +00:00
|
|
|
if ( this.surface && this.edited ) {
|
2012-06-21 03:16:10 +00:00
|
|
|
// Return our message
|
|
|
|
message = ve.msg( 'visualeditor-viewpage-savewarning' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Unset the onbeforeunload handler so we don't break page caching in Firefox
|
|
|
|
window.onbeforeunload = null;
|
|
|
|
if ( message !== undefined ) {
|
|
|
|
// ...but if the user chooses not to leave the page, we need to rebind it
|
Kranitor #1: On-boarding
'''Kranitor commits''' are commits by Krinkle with his janitor hat on.
Must never contain functional changes mixed with miscellaneous changes.
.gitignore:
* Add .DS_Store to the ignore list so that browsing the directories
on Mac OS X, will not add these files to the list of untracked
files.
* Fix missing newline at end of file
.jshintrc
* raises -> throws
* +module (QUnit.module)
* remove 'Node' (as of node-jshint 1.7.2 this is now part of
'browser:true', as it should be)
Authors:
* Adding myself
MWExtension/VisualEditor.php
* Fix default value of wgVisualEditorParsoidURL to not
point to the experimental instance in WMF Labs.
Issues:
* ve.ce.TextNode:
- Fix TODO: Don't perform a useless clone of an already-jQuerified object.
- Use .html() to set html content instead of encapsulating between
two strings. This is slightly faster but more importantly safer,
and prevents situations where the resulting jQuery collection
actually contains 2 elements instead of 1, thus messing up
what .contents() is iterating over.
* ve.ce.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Document.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.Transaction.test.js
- Fix: ReferenceError: assert is not defined
* ve.dm.TransactionProcessor.test.js
- Fix: ReferenceError: assert is not defined
* ext.visualEditor.viewPageTarget
- Missing dependency on 'mediawiki.Title'
Code conventions / Misc cleanup
* Various JSHint warnings.
* Whitespace
* jQuery(): Use '<tag>' for element creation,
use '<valid><xml/></valid>' for parsing
* Use the default operator instead of ternary when the condition and
first value are the same.
x = foo ? foo : bar; -> x = foo || bar;
Because contrary to some programming language (PHP...), in JS the
default operator does not enforce a boolean result but returns the
original value, hence it being called the 'default' operator, as
opposed to the 'or' operator.
* No need to call addClass() twice, it takes a space-separated list
(jQuery splits by space and adds if needed)
* Use .on( event[, selector], fn ) instead of the deprecated
routers to it such as .bind(), .delegate() and .live().
All these three are now built-in and fully compatible with .on()
* Add 'XXX:' comments for suspicious code that I don't want to change
as part of a clean up commit.
* Remove unused variables (several var x = this; where x was not
used anywhere, possibly from boilerplate copy/paste)
* Follows-up Trevor's commit that converts test suites to the new
QUnit format. Also removed the globals since we no longer use those
any more.
Change-Id: I7e37c9bff812e371c7f65a6fd85d9e2af3e0a22f
2012-07-27 08:43:33 +00:00
|
|
|
setTimeout( function () {
|
2013-05-01 22:21:32 +00:00
|
|
|
window.onbeforeunload = onBeforeUnloadHandler;
|
2013-02-26 00:16:57 +00:00
|
|
|
} );
|
2012-06-21 03:16:10 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
};
|