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
|
|
|
/*global mw, confirm, alert */
|
2012-07-19 03:40:49 +00:00
|
|
|
|
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
|
|
|
/*!
|
2012-07-20 23:59:59 +00:00
|
|
|
* VisualEditor MediaWiki initialization ViewPageTarget class.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2012-07-20 23:59:59 +00:00
|
|
|
* MediaWiki Edit 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
|
2012-06-11 06:54:41 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2012-09-06 23:15:55 +00:00
|
|
|
ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
|
2012-08-23 19:01:07 +00:00
|
|
|
var currentUri = new mw.Uri( window.location.toString() );
|
|
|
|
|
2012-09-17 23:53:03 +00:00
|
|
|
// Parent constructor
|
2012-12-04 21:04:19 +00:00
|
|
|
ve.init.mw.Target.call( this, mw.config.get( 'wgRelevantPageName' ), currentUri.query.oldid );
|
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>' );
|
2012-12-11 00:26:09 +00:00
|
|
|
this.$toolbarCancelButton = $( '<div>' ).addClass(
|
|
|
|
've-init-mw-viewPageTarget-button ve-init-mw-viewPageTarget-toolbar-cancelButton'
|
|
|
|
);
|
|
|
|
this.$toolbarSaveButton = $( '<div>' ).addClass(
|
|
|
|
've-init-mw-viewPageTarget-button ve-init-mw-viewPageTarget-button-constructive ' +
|
|
|
|
've-init-mw-viewPageTarget-toolbar-saveButton'
|
|
|
|
);
|
|
|
|
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.$saveDialog = $( '<div>' ).addClass( 've-init-mw-viewPageTarget-saveDialog' );
|
2012-06-19 19:15:41 +00:00
|
|
|
this.$saveDialogSaveButton = null;
|
2012-12-11 23:19:21 +00:00
|
|
|
this.$saveDialogReviewWrongButton = null;
|
|
|
|
this.$saveDialogReviewGoodButton = null;
|
2012-06-21 03:16:10 +00:00
|
|
|
this.onBeforeUnloadFallback = null;
|
|
|
|
this.proxiedOnBeforeUnload = null;
|
2012-06-11 06:54:41 +00:00
|
|
|
this.surface = null;
|
|
|
|
this.active = false;
|
2012-06-12 17:32:10 +00:00
|
|
|
this.edited = false;
|
2012-06-14 01:26:21 +00:00
|
|
|
this.activating = false;
|
2012-06-14 21:31:08 +00:00
|
|
|
this.deactivating = false;
|
2012-06-18 20:12:32 +00:00
|
|
|
this.scrollTop = null;
|
2012-08-11 08:14:56 +00:00
|
|
|
this.proxiedOnSurfaceModelTransact = ve.bind( this.onSurfaceModelTransact, this );
|
2012-08-01 00:49:04 +00:00
|
|
|
this.surfaceOptions = {
|
|
|
|
'toolbars': {
|
|
|
|
'top': {
|
|
|
|
'float': !this.isMobileDevice
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2012-08-23 19:01:07 +00:00
|
|
|
this.currentUri = currentUri;
|
2012-12-04 21:04:19 +00:00
|
|
|
this.restoring = !!this.oldid;
|
2012-08-23 19:01:07 +00:00
|
|
|
this.section = currentUri.query.vesection || null;
|
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
|
|
|
);
|
|
|
|
this.canBeActivated = (
|
2012-11-05 20:46:14 +00:00
|
|
|
$.client.test( ve.init.mw.ViewPageTarget.compatibility ) ||
|
|
|
|
'vewhitelist' in currentUri.query
|
2012-06-18 23:18:48 +00:00
|
|
|
);
|
2012-08-17 19:30:33 +00:00
|
|
|
this.editSummaryByteLimit = 255;
|
2012-11-28 18:11:11 +00:00
|
|
|
// Tab layout.
|
|
|
|
// * add: Adds #ca-ve-edit.
|
|
|
|
// * replace: Re-creates #ca-edit for VisualEditor and adds #ca-editsource.
|
|
|
|
this.tabLayout = 'add';
|
2012-12-11 01:44:44 +00:00
|
|
|
this.feedback = new mw.Feedback( {
|
|
|
|
'title': new mw.Title( 'Project:VisualEditor/Feedback' ),
|
|
|
|
'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-06-18 20:12:32 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.addListenerMethods( this, {
|
|
|
|
'load': 'onLoad',
|
|
|
|
'save': 'onSave',
|
|
|
|
'loadError': 'onLoadError',
|
2012-11-28 23:57:00 +00:00
|
|
|
'saveError': 'onSaveError',
|
2012-12-07 16:23:23 +00:00
|
|
|
'editConflict': 'onEditConflict',
|
|
|
|
'showChanges': 'onShowChanges',
|
|
|
|
'showChangesError': 'onShowChangesError'
|
2012-06-18 20:12:32 +00:00
|
|
|
} );
|
2012-06-11 06:54:41 +00:00
|
|
|
|
|
|
|
// Initialization
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.canBeActivated ) {
|
2012-08-23 19:01:07 +00:00
|
|
|
if ( currentUri.query.venotify ) {
|
2012-08-25 11:20:33 +00:00
|
|
|
// The following messages can be used here:
|
|
|
|
// visualeditor-notification-saved
|
|
|
|
// visualeditor-notification-created
|
2012-12-04 21:04:19 +00:00
|
|
|
// visualeditor-notification-restored
|
2012-12-11 22:13:54 +00:00
|
|
|
mw.notify(
|
2012-12-08 01:38:05 +00:00
|
|
|
ve.msg( 'visualeditor-notification-' + currentUri.query.venotify,
|
|
|
|
new mw.Title( this.pageName ).toText()
|
|
|
|
)
|
2012-08-23 19:01:07 +00:00
|
|
|
);
|
|
|
|
if ( window.history.replaceState ) {
|
|
|
|
delete currentUri.query.venotify;
|
|
|
|
window.history.replaceState( null, document.title, currentUri );
|
|
|
|
}
|
|
|
|
}
|
2012-06-18 23:18:48 +00:00
|
|
|
this.setupSkinTabs();
|
2012-12-12 23:35:33 +00:00
|
|
|
if ( mw.config.get( 'wgVisualEditor' ).enableSectionEditLinks ) {
|
|
|
|
this.setupSectionEditLinks();
|
|
|
|
}
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.isViewPage ) {
|
2012-08-23 19:01:07 +00:00
|
|
|
if ( currentUri.query.veaction === 'edit' ) {
|
2012-06-18 21:13:26 +00:00
|
|
|
this.activate();
|
|
|
|
}
|
|
|
|
}
|
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 );
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/* Static Members */
|
|
|
|
|
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 = {
|
|
|
|
// Left-to-right languages
|
|
|
|
ltr: {
|
2012-12-07 16:23:23 +00:00
|
|
|
msie: false, // FIXME: Bug 42335 (temporarily added IE to blacklist for December release)
|
2012-11-21 20:30:14 +00:00
|
|
|
// msie: [['>=', 9]],
|
2012-08-22 21:24:50 +00:00
|
|
|
firefox: [['>=', 11]],
|
|
|
|
safari: [['>=', 5]],
|
|
|
|
chrome: [['>=', 19]],
|
|
|
|
opera: false,
|
|
|
|
netscape: false,
|
|
|
|
blackberry: false
|
|
|
|
},
|
|
|
|
// Right-to-left languages
|
|
|
|
rtl: {
|
2012-12-07 16:23:23 +00:00
|
|
|
msie: false, // FIXME: Bug 42335 (temporarily added IE to blacklist for December release)
|
2012-11-21 20:30:14 +00:00
|
|
|
// msie: [['>=', 9]],
|
2012-08-22 21:24:50 +00:00
|
|
|
firefox: [['>=', 11]],
|
|
|
|
safari: [['>=', 5]],
|
|
|
|
chrome: [['>=', 19]],
|
|
|
|
opera: false,
|
|
|
|
netscape: false,
|
|
|
|
blackberry: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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 23:19:21 +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-button ve-init-mw-viewPageTarget-button-constructive ve-init-mw-viewPageTarget-saveDialog-reviewGoodButton">\
|
|
|
|
<span class="ve-init-mw-viewPageTarget-button-label"></span>\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-button ve-init-mw-viewPageTarget-button-primary ve-init-mw-viewPageTarget-saveDialog-reviewWrongButton">\
|
|
|
|
<span class="ve-init-mw-viewPageTarget-button-label"></span>\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
|
|
|
</div>\
|
|
|
|
<div style="clear: both;"></div>\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-slide ve-init-mw-viewPageTarget-saveDialog-slide-report">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-report">\
|
|
|
|
<textarea name="problem" class="ve-init-mw-viewPageTarget-saveDialog-problem"\
|
|
|
|
id="ve-init-mw-viewPageTarget-saveDialog-problem" type="text"\
|
|
|
|
rows="4"></textarea>\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-button ve-init-mw-viewPageTarget-button-primary ve-init-mw-viewPageTarget-saveDialog-reportButton">\
|
|
|
|
<span class="ve-init-mw-viewPageTarget-button-label"></span>\
|
|
|
|
</div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
|
|
|
</div>\
|
|
|
|
<div style="clear: both;"></div>\
|
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-foot">\
|
|
|
|
<p class="ve-init-mw-viewPageTarget-saveDialog-report-notice"></p>\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
2012-12-11 22:13:54 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-slide ve-init-mw-viewPageTarget-saveDialog-slide-save">\
|
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">\
|
|
|
|
<input type="checkbox" name="minorEdit" \
|
|
|
|
id="ve-init-mw-viewPageTarget-saveDialog-minorEdit">\
|
2012-12-11 00:26:09 +00:00
|
|
|
<label class="ve-init-mw-viewPageTarget-saveDialog-minorEdit-label"\
|
2012-12-07 16:23:23 +00:00
|
|
|
for="ve-init-mw-viewPageTarget-saveDialog-minorEdit"></label>\
|
2012-12-11 00:26:09 +00:00
|
|
|
<input type="checkbox" name="watchList"\
|
2012-12-07 16:23:23 +00:00
|
|
|
id="ve-init-mw-viewPageTarget-saveDialog-watchList">\
|
2012-12-11 00:26:09 +00:00
|
|
|
<label class="ve-init-mw-viewPageTarget-saveDialog-watchList-label"\
|
2012-12-07 16:23:23 +00:00
|
|
|
for="ve-init-mw-viewPageTarget-saveDialog-watchList"></label>\
|
|
|
|
<label class="ve-init-mw-viewPageTarget-saveDialog-editSummaryCount"></label>\
|
|
|
|
</div>\
|
2012-12-11 00:26:09 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
2012-12-11 23:19:21 +00:00
|
|
|
<div class="ve-init-mw-viewPageTarget-button ve-init-mw-viewPageTarget-button-constructive ve-init-mw-viewPageTarget-saveDialog-saveButton">\
|
|
|
|
<span class="ve-init-mw-viewPageTarget-button-label"></span>\
|
|
|
|
</div>\
|
|
|
|
<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>\
|
2012-06-18 20:12:32 +00:00
|
|
|
</div>';
|
2012-06-11 06:54:41 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Switches 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;
|
2012-06-18 20:12:32 +00:00
|
|
|
// User interface changes
|
|
|
|
this.transformSkinTabs();
|
2012-06-21 19:44:33 +00:00
|
|
|
this.hideSiteNotice();
|
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
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Switches 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 ||
|
2012-06-12 17:32:10 +00:00
|
|
|
!this.surface.getModel().getHistory().length ||
|
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
|
|
|
|
this.restoreSkinTabs();
|
2012-06-21 19:44:33 +00:00
|
|
|
this.restoreSiteNotice();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.hideSpinner();
|
2012-11-30 23:09:34 +00:00
|
|
|
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();
|
2012-06-12 17:32:10 +00:00
|
|
|
this.tearDownSurface();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.showTableOfContents();
|
2012-06-14 21:31:08 +00:00
|
|
|
this.deactivating = false;
|
2012-06-12 17:32:10 +00:00
|
|
|
}
|
2012-06-12 01:21:31 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Handles successful DOM load event.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
2012-06-18 20:12:32 +00:00
|
|
|
* @param {HTMLElement} dom Parsed DOM from server
|
2012-06-11 06:54:41 +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.onLoad = function ( dom ) {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.edited = false;
|
|
|
|
this.setUpSurface( dom );
|
2012-11-30 23:09:34 +00:00
|
|
|
this.setupToolbarEditNotices();
|
|
|
|
this.setupToolbarButtons();
|
|
|
|
this.setupSaveDialog();
|
|
|
|
this.attachToolbarButtons();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.attachSaveDialog();
|
|
|
|
this.restoreScrollPosition();
|
|
|
|
this.restoreEditSection();
|
2012-06-21 03:16:10 +00:00
|
|
|
this.setupBeforeUnloadHandler();
|
2012-06-19 17:50:33 +00:00
|
|
|
this.$document.focus();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.activating = false;
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-12 17:32:10 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Handles failed DOM load event.
|
2012-06-12 17:32:10 +00:00
|
|
|
*
|
|
|
|
* @method
|
2012-06-18 20:12:32 +00:00
|
|
|
* @param {Object} data 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 ) {
|
2012-06-21 02:14:04 +00:00
|
|
|
if ( 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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles successful DOM save event.
|
|
|
|
*
|
|
|
|
* @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.onSave = function ( html ) {
|
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
|
2012-07-20 23:59:59 +00:00
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-watchList')
|
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
|
|
|
);
|
|
|
|
}
|
2012-06-20 19:15:42 +00:00
|
|
|
this.hideSaveDialog();
|
|
|
|
this.resetSaveDialog();
|
|
|
|
this.replacePageContent( html );
|
2012-11-30 23:09:34 +00:00
|
|
|
this.tearDownBeforeUnloadHandler();
|
2012-06-20 19:15:42 +00:00
|
|
|
this.deactivate( true );
|
2012-12-08 01:38:05 +00:00
|
|
|
mw.util.jsMessage(
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles failed DOM save event.
|
|
|
|
*
|
|
|
|
* @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
|
2012-06-18 20:12:32 +00:00
|
|
|
* @param {Mixed} error Thrown exception or HTTP error string
|
|
|
|
*/
|
2012-12-07 16:23:23 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveError = function ( jqXHR, status ) {
|
2012-08-01 00:49:04 +00:00
|
|
|
// TODO: Don't use alert.
|
2012-06-21 02:14:04 +00:00
|
|
|
alert( ve.msg( 'visualeditor-saveerror', status ) );
|
2012-12-11 22:13:54 +00:00
|
|
|
this.enableSaveDialogSaveButton();
|
2012-12-06 22:18:56 +00:00
|
|
|
this.$saveDialogLoadingIcon.hide();
|
2012-06-12 17:32:10 +00:00
|
|
|
};
|
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
/**
|
|
|
|
* Handles Show changes event.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {string} diffHtml
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onShowChanges = function ( diffHtml ) {
|
2012-12-11 23:19:21 +00:00
|
|
|
// Invalidate the diff on next change
|
|
|
|
this.surface.getModel().on( 'transact', this.proxiedOnSurfaceModelTransact );
|
|
|
|
|
2012-12-11 21:19:51 +00:00
|
|
|
// Store the diff for reporting purposes
|
|
|
|
this.diffHtml = diffHtml;
|
2012-12-07 16:23:23 +00:00
|
|
|
|
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();
|
2012-12-11 23:19:21 +00:00
|
|
|
this.enableSaveDialogReviewGoodButton();
|
|
|
|
this.enableSaveDialogReviewWrongButton();
|
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
}, this ), ve.bind( function () {
|
|
|
|
this.onSaveError( null, 'Module load failed' );
|
|
|
|
}, this ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles failed Show changes event.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
* @param {Mixed} error Thrown exception or HTTP error string
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onShowChangesError = function ( jqXHR, status ) {
|
|
|
|
alert( ve.msg( 'visualeditor-differror', status ) );
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
2012-12-11 23:19:21 +00:00
|
|
|
this.enableSaveDialogReviewWrongButton();
|
2012-12-07 16:23:23 +00:00
|
|
|
};
|
|
|
|
|
2012-11-28 23:57:00 +00:00
|
|
|
/**
|
|
|
|
* Handles edit conflict event.
|
|
|
|
*
|
|
|
|
* TODO: Don't use an operating system confirm box. Parsing may take quite some time and we should
|
|
|
|
* be showing the user some sort of progress indicator. Ideally this would be integrated into the
|
|
|
|
* save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onEditConflict = function () {
|
|
|
|
if ( confirm( ve.msg( 'visualeditor-editconflict', status ) ) ) {
|
|
|
|
// Get Wikitext from the DOM, and setup a submit call when it's done
|
|
|
|
this.serialize(
|
|
|
|
ve.dm.converter.getDomFromData( this.surface.getDocumentModel().getFullData() ),
|
|
|
|
ve.bind( function ( wikitext ) {
|
|
|
|
this.submit( wikitext, this.getSaveOptions() );
|
|
|
|
}, this )
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// Return to editing
|
|
|
|
this.hideSaveDialog();
|
|
|
|
this.resetSaveDialog();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-12 17:32:10 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Handles clicks on the edit tab.
|
2012-06-12 17:32: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
|
|
|
* @param {jQuery.Event} e
|
2012-06-12 17:32:10 +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.onEditTabClick = function ( e ) {
|
2012-06-18 20:12:32 +00:00
|
|
|
this.activate();
|
|
|
|
// 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();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicks on a section edit link.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
* @param {jQuery.Event} e
|
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.onEditSectionLinkClick = function ( e ) {
|
2012-08-01 06:40:22 +00:00
|
|
|
this.saveEditSection( $( e.target ).closest( 'h1, h2, h3, h4, h5, h6' ).get( 0 ) );
|
2012-06-18 20:12:32 +00:00
|
|
|
this.activate();
|
|
|
|
// 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();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicks on the view tab.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
* @param {jQuery.Event} e
|
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 ) {
|
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();
|
2012-06-18 21:53:22 +00:00
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicks on the save button in the toolbar.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
* @param {jQuery.Event} e
|
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 () {
|
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
|
|
|
/**
|
|
|
|
* Handles clicks on the save button in the toolbar.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e
|
|
|
|
*/
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2012-11-30 23:09:34 +00:00
|
|
|
/**
|
2012-12-11 01:44:44 +00:00
|
|
|
* Handles clicks on the edit notices tool in the toolbar.
|
2012-11-30 23:09:34 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e
|
|
|
|
*/
|
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' );
|
2012-12-08 00:42:47 +00:00
|
|
|
this.$document.focus();
|
2012-11-30 23:09:34 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 01:44:44 +00:00
|
|
|
/**
|
|
|
|
* Handles clicks on the feedback tool in the toolbar.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onToolbarFeedbackToolClick = function () {
|
|
|
|
this.$toolbarEditNotices.fadeOut( 'fast' );
|
|
|
|
this.feedback.launch();
|
|
|
|
};
|
|
|
|
|
2012-06-12 17:32:10 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Handles the first transaction in the surface model.
|
|
|
|
*
|
|
|
|
* This handler is removed the first time it's used, but added each time the surface is setup.
|
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-06-18 20:12:32 +00:00
|
|
|
this.edited = true;
|
|
|
|
this.enableToolbarSaveButton();
|
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();
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
this.surface.getModel().removeListener( 'transact', this.proxiedOnSurfaceModelTransact );
|
2012-06-12 17:32:10 +00:00
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Handles clicks on the save button in the save dialog.
|
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
|
|
|
* @param {jQuery.Event} e
|
2012-06-11 06:54:41 +00:00
|
|
|
*/
|
2012-12-11 22:13:54 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogSaveButtonClick = function ( e ) {
|
|
|
|
// If button was already disabled, ignore this event.
|
|
|
|
if ( $.data( e.currentTarget, 'disabled' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.disableSaveDialogSaveButton();
|
2012-08-17 23:01:17 +00:00
|
|
|
this.$saveDialogLoadingIcon.show();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.save(
|
2012-10-30 01:42:12 +00:00
|
|
|
ve.dm.converter.getDomFromData( this.surface.getDocumentModel().getFullData() ),
|
2012-12-07 16:23:23 +00:00
|
|
|
this.getSaveOptions()
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Handles clicks on the review "Wrong" button in the save dialog.
|
2012-12-07 16:23:23 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogReviewWrongButtonClick = function ( e ) {
|
2012-12-11 22:13:54 +00:00
|
|
|
// If button was already disabled, ignore this event.
|
|
|
|
if ( $.data( e.currentTarget, 'disabled' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:19:21 +00:00
|
|
|
this.swapSaveDialog( 'report' );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicks on the review "Good" button in the save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogReviewGoodButtonClick = function ( e ) {
|
|
|
|
// If button was already disabled, ignore this event.
|
|
|
|
if ( $.data( e.currentTarget, 'disabled' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.swapSaveDialog( 'save' );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicks on the report a problem button in the save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogReportButtonClick = function () {
|
|
|
|
this.reportProblem( $( '#ve-init-mw-viewPageTarget-saveDialog-problem' ).val() );
|
|
|
|
this.resetSaveDialog();
|
|
|
|
this.hideSaveDialog();
|
|
|
|
mw.notify( ve.msg( 'visualeditor-notification-reported' ) );
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-11-28 23:57:00 +00:00
|
|
|
/**
|
|
|
|
* Gets save options from the save dialog form.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {Object} Save options, including summary, minor and watch properties
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.getSaveOptions = function () {
|
|
|
|
return {
|
|
|
|
'summary': $( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' ).val(),
|
|
|
|
'minor': $( '#ve-init-mw-viewPageTarget-saveDialog-minorEdit' ).prop( 'checked' ),
|
|
|
|
'watch': $( '#ve-init-mw-viewPageTarget-saveDialog-watchList' ).prop( 'checked' )
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Handles clicks on the close button in the save dialog.
|
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
|
|
|
* @param {jQuery.Event} e
|
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
|
|
|
};
|
|
|
|
|
2012-12-07 16:23:23 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogPrevButtonClick = function () {
|
2012-12-11 23:19:21 +00:00
|
|
|
// Hard code "review" for now.
|
|
|
|
// Although we have more than 2 slides, slide "report" and "save" are both
|
|
|
|
// branches of "review". Later this could terminate the path based on an
|
|
|
|
// array or object, or keep a .history array even...
|
|
|
|
this.swapSaveDialog( 'review' );
|
2012-12-07 16:23:23 +00:00
|
|
|
};
|
|
|
|
|
2012-11-30 23:09:34 +00:00
|
|
|
/**
|
|
|
|
* Gets a list of edit notices.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {String[]} HTML strings for each edit notice
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Switches to editing mode.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
2012-06-18 20:12:32 +00:00
|
|
|
* @param {HTMLElement} dom HTML DOM to edit
|
2012-06-11 06:54:41 +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.setUpSurface = function ( dom ) {
|
2012-08-22 21:01:38 +00:00
|
|
|
var $contentText = $( '#mw-content-text' );
|
|
|
|
|
2012-12-12 01:20:18 +00:00
|
|
|
// Store the HTML for reporting purposes
|
|
|
|
this.originalHtml = dom.innerHTML;
|
2012-06-11 06:54:41 +00:00
|
|
|
// Initialize surface
|
2012-08-27 21:34:08 +00:00
|
|
|
this.surface = new ve.Surface( $( '#content' ), dom, this.surfaceOptions );
|
2012-12-03 22:06:24 +00:00
|
|
|
this.surface.getContext().hide();
|
2012-08-27 21:34:08 +00:00
|
|
|
this.$document = this.surface.$.find( '.ve-ce-documentNode' );
|
2012-06-12 17:32:10 +00:00
|
|
|
this.surface.getModel().on( 'transact', this.proxiedOnSurfaceModelTransact );
|
2012-06-11 06:54:41 +00:00
|
|
|
// Transplant the toolbar
|
2012-06-18 20:12:32 +00:00
|
|
|
this.attachToolbar();
|
|
|
|
this.transformPageTitle();
|
2012-06-11 06:54:41 +00:00
|
|
|
// Update UI
|
2012-06-18 20:12:32 +00:00
|
|
|
this.hidePageContent();
|
|
|
|
this.hideSpinner();
|
2012-12-04 21:04:19 +00:00
|
|
|
if ( !this.restoring ) {
|
2012-11-07 21:57:13 +00:00
|
|
|
this.disableToolbarSaveButton();
|
|
|
|
}
|
2012-06-12 01:21:31 +00:00
|
|
|
this.active = true;
|
2012-08-22 21:01:38 +00:00
|
|
|
this.$document.attr( {
|
|
|
|
'lang': $contentText.attr( 'lang' ),
|
|
|
|
'dir': $contentText.attr( 'dir' )
|
|
|
|
} );
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
|
|
|
* Switches to viewing mode.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
// Reset tabs
|
2012-06-18 20:12:32 +00:00
|
|
|
this.restoreSkinTabs();
|
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;
|
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
this.detachToolbar();
|
|
|
|
this.hideSpinner();
|
|
|
|
this.showPageContent();
|
|
|
|
this.restorePageTitle();
|
|
|
|
this.showTableOfContents();
|
2012-06-11 06:54:41 +00:00
|
|
|
// Destroy editor
|
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
|
|
|
/**
|
|
|
|
* Modifies tabs in the skin to support in-place editing.
|
|
|
|
*
|
|
|
|
* @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-12-02 04:33:43 +00:00
|
|
|
var action, pTabsId, $caSource, $caEdit, caVeEdit, caVeEditNextnode, uriClone;
|
2012-11-28 18:11:11 +00:00
|
|
|
$caEdit = $( '#ca-edit' );
|
|
|
|
$caSource = $( '#ca-viewsource' );
|
2012-12-02 01:52:15 +00:00
|
|
|
caVeEditNextnode = $caEdit.next().get( 0 );
|
2012-11-28 18:11:11 +00:00
|
|
|
|
|
|
|
if ( !$caEdit.length || $caSource.length ) {
|
|
|
|
// If there is no edit tab or a view-source tab,
|
|
|
|
// the user doesn't have permission to edit.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-02 05:09:03 +00:00
|
|
|
action = this.pageExists ? 'edit' : 'create';
|
2012-11-28 18:11:11 +00:00
|
|
|
pTabsId = $( '#p-views' ).length ? 'p-views' : 'p-cactions';
|
|
|
|
|
|
|
|
// Add independent ve-edit tab.
|
|
|
|
if ( this.tabLayout === 'add' ) {
|
|
|
|
// Create "Edit" tab.
|
|
|
|
caVeEdit = mw.util.addPortletLink(
|
|
|
|
pTabsId,
|
|
|
|
// Use url instead of '#'.
|
|
|
|
// So that 1) one can always open it in a new tab, even when
|
|
|
|
// onEditTabClick is bound.
|
|
|
|
// 2) when onEditTabClick is not bound (!isViewPage) it will
|
|
|
|
// just work.
|
|
|
|
this.veEditUri,
|
|
|
|
// Message: 'visualeditor-ca-ve-edit' or 'visualeditor-ca-ve-create'
|
|
|
|
ve.msg( 'visualeditor-ca-ve-' + action ),
|
|
|
|
'ca-ve-edit',
|
|
|
|
ve.msg( 'tooltip-ca-ve-edit' ),
|
|
|
|
ve.msg( 'accesskey-ca-ve-edit' ),
|
2012-12-02 01:52:15 +00:00
|
|
|
caVeEditNextnode
|
2012-11-28 18:11:11 +00:00
|
|
|
);
|
2012-08-01 06:40:22 +00:00
|
|
|
|
2012-11-28 18:11:11 +00:00
|
|
|
// Replace edit with ve version, add editsource link.
|
2012-06-11 06:54:41 +00:00
|
|
|
} else {
|
2012-11-28 18:11:11 +00:00
|
|
|
// Create "Edit source" link.
|
|
|
|
// Re-create instead of convert ca-edit since we don't want to copy over accesskey etc.
|
2012-06-11 06:54:41 +00:00
|
|
|
mw.util.addPortletLink(
|
|
|
|
'p-cactions',
|
2012-08-01 06:40:22 +00:00
|
|
|
// Use original href to preserve oldid etc. (bug 38125)
|
2012-11-28 18:11:11 +00:00
|
|
|
$caEdit.find( 'a' ).attr( 'href' ),
|
2012-06-19 20:44:34 +00:00
|
|
|
ve.msg( 'visualeditor-ca-editsource' ),
|
2012-06-11 06:54:41 +00:00
|
|
|
'ca-editsource'
|
|
|
|
);
|
2012-11-28 18:11:11 +00:00
|
|
|
$caEdit.remove();
|
|
|
|
|
|
|
|
// Create "Edit" tab.
|
|
|
|
caVeEdit = mw.util.addPortletLink(
|
|
|
|
pTabsId ,
|
|
|
|
// Use url instead of '#'.
|
|
|
|
// So that 1) one can always open it in a new tab, even when
|
|
|
|
// onEditTabClick is bound.
|
|
|
|
// 2) when onEditTabClick is not bound (!isViewPage) it will
|
|
|
|
// just work.
|
|
|
|
this.veEditUri,
|
|
|
|
// Message: 'edit' or 'create'
|
|
|
|
ve.msg( action ),
|
|
|
|
'ca-edit',
|
|
|
|
ve.msg( 'tooltip-ca-edit' ),
|
|
|
|
ve.msg( 'accesskey-ca-edit' ),
|
2012-12-02 01:52:15 +00:00
|
|
|
caVeEditNextnode
|
2012-11-28 18:11:11 +00:00
|
|
|
);
|
2012-06-11 06:54:41 +00:00
|
|
|
}
|
2012-08-01 06:40:22 +00:00
|
|
|
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.isViewPage ) {
|
2012-08-01 06:40:22 +00:00
|
|
|
// Allow instant switching to edit mode, without refresh
|
2012-11-28 18:11:11 +00:00
|
|
|
$( caVeEdit ).click( ve.bind( this.onEditTabClick, this ) );
|
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
|
|
|
}
|
2012-11-28 18:11:11 +00:00
|
|
|
|
|
|
|
// If there got here via veaction=edit, hide it from the URL.
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.currentUri.query.veaction === 'edit' && window.history.replaceState ) {
|
2012-12-02 04:33:43 +00:00
|
|
|
// Remove the veaction query parameter, but don't affect the original mw.Uri instance
|
|
|
|
uriClone = this.currentUri.clone();
|
|
|
|
delete uriClone.query.veaction;
|
|
|
|
|
|
|
|
// If there are other query parameters, set the url to the current one
|
|
|
|
// (with veaction removed). Otherwise use the canonical style view url (bug 42553).
|
|
|
|
if ( ve.getObjectValues( uriClone.query ).length ) {
|
|
|
|
window.history.replaceState( null, document.title, uriClone );
|
|
|
|
} else {
|
|
|
|
window.history.replaceState( null, document.title, this.viewUri );
|
|
|
|
}
|
2012-06-18 21:53:22 +00:00
|
|
|
}
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Modifies page content to make section edit links activate the editor.
|
|
|
|
*
|
|
|
|
* @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.setupSectionEditLinks = function () {
|
2012-08-02 18:46:13 +00:00
|
|
|
var veEditUri = this.veEditUri,
|
|
|
|
$links = $( '#mw-content-text .editsection a' );
|
2012-06-18 23:18:48 +00:00
|
|
|
if ( this.isViewPage ) {
|
2012-08-11 08:14:56 +00:00
|
|
|
$links.click( ve.bind( this.onEditSectionLinkClick, this ) );
|
2012-06-18 23:18:48 +00:00
|
|
|
} else {
|
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
|
|
|
$links.each( function () {
|
2012-06-19 00:56:26 +00:00
|
|
|
var veSectionEditUri = new mw.Uri( veEditUri.toString() ),
|
2012-06-18 23:18:48 +00:00
|
|
|
sectionEditUri = new mw.Uri( $(this).attr( 'href' ) );
|
|
|
|
veSectionEditUri.extend( { 'vesection': sectionEditUri.query.section } );
|
|
|
|
$(this).attr( 'href', veSectionEditUri );
|
|
|
|
} );
|
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-11-30 23:09:34 +00:00
|
|
|
* Adds 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;
|
2012-12-05 00:33:58 +00:00
|
|
|
this.$toolbarCancelButton
|
|
|
|
.append(
|
2012-12-11 00:26:09 +00:00
|
|
|
$( '<span class="ve-init-mw-viewPageTarget-button-label"></span>' )
|
2012-12-05 00:33:58 +00:00
|
|
|
.text( ve.msg( 'cancel' ) )
|
|
|
|
)
|
2012-12-11 22:13:54 +00:00
|
|
|
.click( ve.bind( this.onToolbarCancelButtonClick, this ) );
|
2012-06-18 20:12:32 +00:00
|
|
|
this.$toolbarSaveButton
|
|
|
|
.append(
|
2012-12-11 00:26:09 +00:00
|
|
|
$( '<span class="ve-init-mw-viewPageTarget-button-label"></span>' )
|
2012-12-11 23:19:21 +00:00
|
|
|
.text( ve.msg( 'visualeditor-toolbar-savedialog' ) )
|
2012-06-18 20:12:32 +00:00
|
|
|
)
|
2012-12-11 22:13:54 +00:00
|
|
|
.click( ve.bind( this.onToolbarSaveButtonClick, 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' );
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes content and event bindings from toolbar buttons.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.tearDownToolbarButtons = function () {
|
2012-12-05 00:33:58 +00:00
|
|
|
this.$toolbarCancelButton.empty().off( 'click' );
|
2012-11-30 23:09:34 +00:00
|
|
|
this.$toolbarSaveButton.empty().off( 'click' );
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarEditNoticesTool.empty().off( 'click' );
|
|
|
|
this.$toolbarFeedbackTool.empty().off( 'click' );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the save button to the user interface.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-11-30 23:09:34 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.attachToolbarButtons = function () {
|
2012-12-11 01:44:44 +00:00
|
|
|
var $target = $( '.ve-ui-toolbar .ve-ui-actions' );
|
|
|
|
$target.append( this.$toolbarFeedbackTool );
|
|
|
|
if ( !ve.isEmptyObject( this.editNotices ) ) {
|
|
|
|
$target.append( this.$toolbarEditNoticesTool );
|
|
|
|
}
|
|
|
|
$target.append( this.$toolbarCancelButton, this.$toolbarSaveButton );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the save button from the user interface.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-11-30 23:09:34 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.detachToolbarButtons = function () {
|
2012-12-05 00:33:58 +00:00
|
|
|
this.$toolbarCancelButton.detach();
|
2012-06-18 20:12:32 +00:00
|
|
|
this.$toolbarSaveButton.detach();
|
2012-12-11 01:44:44 +00:00
|
|
|
this.$toolbarEditNoticesTool.detach();
|
|
|
|
this.$toolbarFeedbackTool.detach();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
2012-12-02 03:44:07 +00:00
|
|
|
/**
|
|
|
|
* Asynchronously provides the template for the save dialog wrapped in a
|
|
|
|
* plain <div> jQuery collection.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.getSaveDialogHtml = function ( callback ) {
|
2012-12-02 05:31:06 +00:00
|
|
|
var viewPage = this,
|
|
|
|
$wrap = $( '<div>' ).html( this.constructor.saveDialogTemplate );
|
2012-12-02 03:44:07 +00:00
|
|
|
|
2012-12-06 05:57:53 +00:00
|
|
|
// Based on EditPage::getCheckboxes and EditPage::initialiseForm
|
|
|
|
|
2012-12-02 03:44:07 +00:00
|
|
|
mw.user.getRights( function ( rights ) {
|
2012-12-02 05:31:06 +00:00
|
|
|
// MediaWiki only allows usage of minor flag when editing an existing page
|
|
|
|
// and the user has the right to use the feature.
|
|
|
|
// If either is not the case, remove it from the form.
|
|
|
|
if ( !viewPage.pageExists || ve.indexOf( 'minoredit', rights ) === -1 ) {
|
2012-12-02 03:44:07 +00:00
|
|
|
$wrap
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-minorEdit-label, #ve-init-mw-viewPageTarget-saveDialog-minorEdit' )
|
|
|
|
.remove();
|
|
|
|
}
|
2012-12-06 05:57:53 +00:00
|
|
|
|
|
|
|
if ( mw.user.isAnon() ) {
|
|
|
|
$wrap
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-watchList-label, #ve-init-mw-viewPageTarget-saveDialog-watchList' )
|
|
|
|
.remove();
|
|
|
|
} else if (
|
|
|
|
mw.user.options.get( 'watchdefault' ) ||
|
|
|
|
( mw.user.options.get( 'watchcreations' ) && !viewPage.pageExists ) ||
|
|
|
|
mw.config.get( 'wgVisualEditor' ).isPageWatched
|
|
|
|
) {
|
|
|
|
$wrap
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-watchList' )
|
|
|
|
.prop( 'checked', true );
|
|
|
|
}
|
2012-12-11 12:59:54 +00:00
|
|
|
|
2012-12-02 03:44:07 +00:00
|
|
|
callback( $wrap );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
|
|
|
* Adds content and event bindings to the save dialog.
|
|
|
|
*
|
|
|
|
* @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 () {
|
2012-07-26 22:11:24 +00:00
|
|
|
var viewPage = this;
|
2012-12-02 03:44:07 +00:00
|
|
|
viewPage.getSaveDialogHtml( function ( $wrap ) {
|
|
|
|
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( $wrap.contents() )
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-closeButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogCloseButtonClick, viewPage ) )
|
|
|
|
.end()
|
2012-12-07 16:23:23 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-prevButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogPrevButtonClick, viewPage ) )
|
|
|
|
.end()
|
2012-12-02 03:44:07 +00:00
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' )
|
|
|
|
.attr( {
|
|
|
|
'placeholder': ve.msg( 'visualeditor-editsummary' )
|
|
|
|
} )
|
|
|
|
.placeholder()
|
|
|
|
.byteLimit( viewPage.editSummaryByteLimit )
|
2012-12-11 00:26:09 +00:00
|
|
|
.on( {
|
|
|
|
'focus': function () {
|
|
|
|
$(this).parent().addClass(
|
|
|
|
've-init-mw-viewPageTarget-saveDialog-summary-focused'
|
2012-12-02 03:44:07 +00:00
|
|
|
);
|
2012-12-11 00:26:09 +00:00
|
|
|
},
|
|
|
|
'blur': function () {
|
|
|
|
$(this).parent().removeClass(
|
|
|
|
've-init-mw-viewPageTarget-saveDialog-summary-focused'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
'keydown mouseup cut paste change focus blur': function () {
|
|
|
|
var $textarea = $(this),
|
|
|
|
$editSummaryCount = $textarea
|
2012-12-11 22:13:54 +00:00
|
|
|
.closest( '.ve-init-mw-viewPageTarget-saveDialog-slide-save' )
|
2012-12-11 00:26:09 +00:00
|
|
|
.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() )
|
|
|
|
);
|
|
|
|
}, 0 );
|
|
|
|
}
|
2012-12-02 03:44:07 +00:00
|
|
|
} )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-editSummaryCount' )
|
|
|
|
.text( viewPage.editSummaryByteLimit )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-minorEdit-label' )
|
2012-12-04 06:56:41 +00:00
|
|
|
.html( ve.init.platform.getParsedMessage( 'minoredit' ) )
|
2012-12-05 23:38:50 +00:00
|
|
|
.find( 'a' )
|
|
|
|
.attr( 'target', '_blank' )
|
|
|
|
.end()
|
2012-12-04 06:56:41 +00:00
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-watchList-label' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'watchthis' ) )
|
2012-12-02 03:44:07 +00:00
|
|
|
.end()
|
2012-12-11 23:19:21 +00:00
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-problem' )
|
|
|
|
.attr( {
|
|
|
|
'placeholder': ve.msg( 'visualeditor-problem' )
|
|
|
|
} )
|
|
|
|
.placeholder()
|
|
|
|
.on( {
|
|
|
|
'focus': function () {
|
|
|
|
$(this).parent().addClass(
|
|
|
|
've-init-mw-viewPageTarget-saveDialog-report-focused'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
'blur': function () {
|
|
|
|
$(this).parent().removeClass(
|
|
|
|
've-init-mw-viewPageTarget-saveDialog-report-focused'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-reviewWrongButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogReviewWrongButtonClick, viewPage ) )
|
|
|
|
.find( '> span' )
|
|
|
|
.text( ve.msg( 'visualeditor-savedialog-label-review-wrong' ) )
|
|
|
|
.end()
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-reviewGoodButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogReviewGoodButtonClick, viewPage ) )
|
|
|
|
.find( '> span' )
|
|
|
|
.text( ve.msg( 'visualeditor-savedialog-label-review-good' ) )
|
|
|
|
.end()
|
|
|
|
.end()
|
2012-12-02 03:44:07 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-saveButton' )
|
2012-12-11 22:13:54 +00:00
|
|
|
.click( ve.bind( viewPage.onSaveDialogSaveButtonClick, viewPage ) )
|
2012-12-02 03:44:07 +00:00
|
|
|
.end()
|
2012-12-11 00:26:09 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-saveButton > span' )
|
2012-12-11 23:19:21 +00:00
|
|
|
.text( ve.msg( viewPage.restoring ? 'visualeditor-savedialog-label-restore' : 'visualeditor-savedialog-label-save' ) )
|
2012-12-02 03:44:07 +00:00
|
|
|
.end()
|
2012-12-11 23:19:21 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-reportButton' )
|
|
|
|
.click( ve.bind( viewPage.onSaveDialogReportButtonClick, viewPage ) )
|
2012-12-07 16:23:23 +00:00
|
|
|
.end()
|
2012-12-11 23:19:21 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-reportButton > span' )
|
|
|
|
.text( ve.msg( 'visualeditor-savedialog-label-report' ) )
|
|
|
|
.end()
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-report-notice' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'visualeditor-report-notice' ) )
|
2012-12-07 16:23:23 +00:00
|
|
|
.end()
|
2012-12-02 03:44:07 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-license' )
|
2012-12-06 05:27:44 +00:00
|
|
|
.html( ve.init.platform.getParsedMessage( 'copyrightwarning' ) );
|
2012-12-02 03:44:07 +00:00
|
|
|
viewPage.$saveDialogLoadingIcon = viewPage.$saveDialog
|
2012-12-11 00:26:09 +00:00
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-working' );
|
2012-12-11 23:19:21 +00:00
|
|
|
viewPage.$saveDialogSaveButton = viewPage.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-saveButton' );
|
|
|
|
viewPage.$saveDialogReviewGoodButton = viewPage.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-reviewGoodButton' );
|
|
|
|
viewPage.$saveDialogReviewWrongButton = viewPage.$saveDialog
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-reviewWrongButton' );
|
2012-12-02 03:44:07 +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
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-watchList' )
|
|
|
|
.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
|
|
|
/**
|
|
|
|
* Shows the save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.showSaveDialog = function () {
|
|
|
|
var viewPage = this;
|
|
|
|
|
|
|
|
viewPage.surface.disable();
|
|
|
|
|
|
|
|
viewPage.$toolbarEditNotices.fadeOut( 'fast' );
|
|
|
|
|
|
|
|
viewPage.swapSaveDialog( 'review' );
|
|
|
|
|
|
|
|
viewPage.$saveDialog.fadeIn( 'fast', function () {
|
|
|
|
// Initial size
|
|
|
|
viewPage.onResizeSaveDialog();
|
|
|
|
});
|
|
|
|
|
|
|
|
$( document ).on( 'keydown.ve-savedialog', function ( e ) {
|
|
|
|
// Escape
|
|
|
|
if ( e.which === 27 ) {
|
|
|
|
viewPage.onSaveDialogCloseButtonClick();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$( 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
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the save dialog
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.hideSaveDialog = function () {
|
|
|
|
this.$saveDialog.fadeOut( 'fast' );
|
|
|
|
if ( this.$document ) {
|
|
|
|
this.$document.focus();
|
|
|
|
}
|
|
|
|
$( document ).off( 'keydown.ve-savedialog' );
|
|
|
|
$( window ).off( 'resize', this.onResizeSaveDialog );
|
|
|
|
|
|
|
|
this.surface.enable();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets 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.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.resetSaveDialog = function () {
|
|
|
|
this.$saveDialog
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-editSummary' )
|
|
|
|
.val( '' )
|
|
|
|
.end()
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-problem' )
|
|
|
|
.val( '' )
|
|
|
|
.end()
|
|
|
|
.find( '#ve-init-mw-viewPageTarget-saveDialog-minorEdit' )
|
|
|
|
.prop( 'checked', false )
|
|
|
|
.end()
|
|
|
|
// Clear the diff
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-viewer' )
|
|
|
|
.empty();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Swap state in the save dialog (forwards or backwards).
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {string} slide One of 'review', 'report' or 'save'.
|
|
|
|
* @return {jQuery} The now active slide.
|
|
|
|
* @throws Error
|
|
|
|
*/
|
|
|
|
ve.init.mw.ViewPageTarget.prototype.swapSaveDialog = function ( slide ) {
|
|
|
|
var $slide, $viewer;
|
|
|
|
if ( ve.indexOf( slide, [ 'review', 'report', 'save'] ) === -1 ) {
|
|
|
|
throw new Error( 'Unknown saveDialog slide: ' + slide );
|
|
|
|
}
|
|
|
|
|
|
|
|
$slide = this.$saveDialog.find( '.ve-init-mw-viewPageTarget-saveDialog-slide-' + slide );
|
|
|
|
|
|
|
|
this.$saveDialog
|
|
|
|
// Hide prev button on the first slide
|
|
|
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-prevButton' )
|
|
|
|
.toggle( slide !== 'review' )
|
|
|
|
.end()
|
|
|
|
// Update title
|
|
|
|
.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();
|
|
|
|
|
|
|
|
if ( slide === 'review' ) {
|
|
|
|
$viewer = $slide.find( '.ve-init-mw-viewPageTarget-saveDialog-viewer' );
|
|
|
|
if ( !$viewer.find( 'table, pre' ).length ) {
|
|
|
|
this.disableSaveDialogReviewGoodButton();
|
|
|
|
this.disableSaveDialogReviewWrongButton();
|
|
|
|
this.$saveDialogLoadingIcon.show();
|
|
|
|
if ( this.pageExists ) {
|
|
|
|
// Has no callback, handled via viewPage.onShowChanges
|
|
|
|
this.showChanges(
|
|
|
|
ve.dm.converter.getDomFromData( this.surface.getDocumentModel().getFullData() )
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.serialize(
|
|
|
|
ve.dm.converter.getDomFromData( this.surface.getDocumentModel().getFullData() ),
|
|
|
|
function ( wikitext ) {
|
|
|
|
$viewer.empty().append( $( '<pre>' ).text( wikitext ) );
|
|
|
|
|
|
|
|
this.enableSaveDialogReviewGoodButton();
|
|
|
|
this.enableSaveDialogReviewWrongButton();
|
|
|
|
this.$saveDialogLoadingIcon.hide();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
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();
|
|
|
|
|
|
|
|
if ( slide === 'save' || slide === 'report' ) {
|
|
|
|
setTimeout( function () {
|
|
|
|
$slide.find( 'textarea' ).eq( 0 ).focus();
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $slide;
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
|
|
|
* Adds the save dialog to the user interface.
|
|
|
|
*
|
|
|
|
* @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 () {
|
2012-09-26 23:16:05 +00:00
|
|
|
this.$toolbarWrapper.find( '.ve-ui-toolbar' ).append( this.$saveDialog );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the save dialog from the user interface.
|
|
|
|
*
|
|
|
|
* @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();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remembers the window's scroll position.
|
|
|
|
*
|
|
|
|
* @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();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restores the window's scroll position.
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows 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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the loading spinner.
|
|
|
|
*
|
|
|
|
* @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();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the page content.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mutes the page content.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the page content.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the table of contents in the view mode.
|
|
|
|
*
|
|
|
|
* @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' ) ) {
|
|
|
|
$wrap.slideDown(function () {
|
|
|
|
$toc.unwrap();
|
|
|
|
});
|
|
|
|
}
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the table of contents in the view mode.
|
|
|
|
*
|
|
|
|
* @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-12-11 23:19:21 +00:00
|
|
|
* Enables the toolbar save button.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.enableToolbarSaveButton = function () {
|
|
|
|
this.$toolbarSaveButton
|
|
|
|
.data( 'disabled', false )
|
|
|
|
.removeClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
2012-06-19 05:42:59 +00:00
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Disables the toolbar save button.
|
2012-06-19 05:42:59 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.disableToolbarSaveButton = function () {
|
|
|
|
this.$toolbarSaveButton
|
|
|
|
.data( 'disabled', true )
|
|
|
|
.addClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-06-19 05:42:59 +00:00
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Enables the save dialog save page button.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.enableSaveDialogSaveButton = function () {
|
|
|
|
this.$saveDialogSaveButton
|
2012-12-11 22:13:54 +00:00
|
|
|
.data( 'disabled', false )
|
2012-12-11 00:26:09 +00:00
|
|
|
.removeClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Disables the save dialog save page button.
|
2012-06-18 20:12:32 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.disableSaveDialogSaveButton = function () {
|
|
|
|
this.$saveDialogSaveButton
|
2012-12-11 22:13:54 +00:00
|
|
|
.data( 'disabled', true )
|
2012-12-11 00:26:09 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-19 19:15:41 +00:00
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Enables the save dialog review "Good" button.
|
2012-06-19 19:15:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.enableSaveDialogReviewGoodButton = function () {
|
|
|
|
this.$saveDialogReviewGoodButton
|
2012-12-11 22:13:54 +00:00
|
|
|
.data( 'disabled', false )
|
2012-12-11 00:26:09 +00:00
|
|
|
.removeClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-06-19 19:15:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Disables the save dialog review "Good" button.
|
2012-06-19 19:15:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.disableSaveDialogReviewGoodButton = function () {
|
|
|
|
this.$saveDialogReviewGoodButton
|
2012-12-11 22:13:54 +00:00
|
|
|
.data( 'disabled', true )
|
2012-12-11 00:26:09 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-12-07 16:23:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Enables the save dialog review "Wrong" button.
|
2012-12-07 16:23:23 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.enableSaveDialogReviewWrongButton = function () {
|
|
|
|
this.$saveDialogReviewWrongButton
|
2012-12-11 22:13:54 +00:00
|
|
|
.data( 'disabled', false )
|
2012-12-11 00:26:09 +00:00
|
|
|
.removeClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-12-07 16:23:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-12-11 23:19:21 +00:00
|
|
|
* Disables the save dialog review "Wrong" button.
|
2012-12-07 16:23:23 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
2012-12-11 23:19:21 +00:00
|
|
|
ve.init.mw.ViewPageTarget.prototype.disableSaveDialogReviewWrongButton = function () {
|
|
|
|
this.$saveDialogReviewWrongButton
|
2012-12-11 22:13:54 +00:00
|
|
|
.data( 'disabled', true )
|
2012-12-11 00:26:09 +00:00
|
|
|
.addClass( 've-init-mw-viewPageTarget-button-disabled' );
|
2012-06-19 19:15:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/**
|
2012-06-18 20:12:32 +00:00
|
|
|
* Shows the toolbar.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
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.attachToolbar = function () {
|
2012-08-27 21:34:08 +00:00
|
|
|
this.$toolbarWrapper = $( '.ve-ui-toolbar-wrapper' )
|
2012-06-18 20:12:32 +00:00
|
|
|
.insertBefore( $( '#firstHeading' ) )
|
2012-08-27 21:34:08 +00:00
|
|
|
.find( '.ve-ui-toolbar' )
|
2012-12-03 22:06:24 +00:00
|
|
|
.slideDown( 'fast', ve.bind( function() {
|
|
|
|
this.surface.getContext().update();
|
|
|
|
}, this ) )
|
2012-08-17 20:11:55 +00:00
|
|
|
.end();
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the toolbar.
|
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.detachToolbar = function () {
|
2012-08-27 21:34:08 +00:00
|
|
|
$( '.ve-ui-toolbar' ).slideUp( 'fast', function () {
|
2012-06-18 20:12:32 +00:00
|
|
|
$(this).parent().remove();
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables the toolbar save button.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables the toolbar save button.
|
|
|
|
*
|
|
|
|
* @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 () {
|
2012-08-23 19:01:07 +00:00
|
|
|
$( '#firstHeading, #siteSub:visible, #contentSub:visible' ).fadeTo( 'fast', 0.6 );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables the toolbar save button.
|
|
|
|
*
|
|
|
|
* @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 );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies page tabs to show that editing is taking place.
|
|
|
|
*
|
|
|
|
* @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.transformSkinTabs = function () {
|
2012-08-23 18:01:20 +00:00
|
|
|
$( $( '#p-views' ).length ? '#p-views' : '#p-cactions' )
|
|
|
|
.find( 'li.selected' ).removeClass( 'selected' );
|
2012-11-28 18:11:11 +00:00
|
|
|
$( this.tabLayout === 'add' ? '#ca-ve-edit' : '#ca-edit' )
|
|
|
|
.addClass( 'selected' );
|
2012-06-18 20:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies page tabs to show that viewing is taking place.
|
|
|
|
*
|
|
|
|
* @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.restoreSkinTabs = function () {
|
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
|
|
|
/**
|
|
|
|
* Hides site notice on page if present.
|
|
|
|
*
|
|
|
|
* @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.hideSiteNotice = function () {
|
2012-06-21 20:01:42 +00:00
|
|
|
$( '#siteNotice:visible' )
|
|
|
|
.addClass( 've-hide' )
|
|
|
|
.slideUp( 'fast' );
|
2012-06-21 19:44:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show site notice on page if present.
|
|
|
|
*
|
|
|
|
* @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.restoreSiteNotice = function () {
|
2012-06-21 20:01:42 +00:00
|
|
|
$(' #siteNotice.ve-hide' )
|
|
|
|
.slideDown( 'fast' );
|
2012-06-21 19:44:33 +00:00
|
|
|
};
|
|
|
|
|
2012-06-18 20:12:32 +00:00
|
|
|
/**
|
|
|
|
* Replaces the page content with new HTML.
|
|
|
|
*
|
|
|
|
* @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 ) {
|
2012-06-18 20:12:32 +00:00
|
|
|
$( '#mw-content-text' ).html( html );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the numeric index of a section in the page.
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the numeric index of a section in the page.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves the cursor in the editor to a given section.
|
|
|
|
*
|
|
|
|
* @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,
|
|
|
|
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 () {
|
2012-06-19 17:50:33 +00:00
|
|
|
var headingNode = $(this).data( 'node' );
|
|
|
|
if ( headingNode ) {
|
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
|
|
|
offset = surfaceModel.getDocument().getNearestContentOffset(
|
2012-06-19 17:50:33 +00:00
|
|
|
headingNode.getModel().getOffset()
|
|
|
|
);
|
|
|
|
surfaceModel.change( null, new ve.Range( offset, offset ) );
|
|
|
|
surfaceView.showSelection( surfaceModel.getSelection() );
|
|
|
|
}
|
|
|
|
} );
|
2012-06-18 20:12:32 +00:00
|
|
|
this.section = null;
|
|
|
|
}
|
2012-06-11 06:54:41 +00:00
|
|
|
};
|
|
|
|
|
2012-06-21 03:16:10 +00:00
|
|
|
/**
|
|
|
|
* Adds onbeforunload handler.
|
|
|
|
*
|
|
|
|
* @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
|
2012-08-11 08:14:56 +00:00
|
|
|
window.onbeforeunload = this.proxiedOnBeforeUnload = 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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes onbeforunload handler.
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Responds to page show event.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
window.onbeforeunload = this.proxiedOnBeforeUnload;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Responds to before unload event.
|
|
|
|
*
|
|
|
|
* @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,
|
|
|
|
proxiedOnBeforeUnload = this.proxiedOnBeforeUnload;
|
|
|
|
// 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
|
2012-08-22 21:44:03 +00:00
|
|
|
if ( this.surface && this.surface.getModel().getHistory().length ) {
|
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 () {
|
2012-06-21 03:16:10 +00:00
|
|
|
window.onbeforeunload = proxiedOnBeforeUnload;
|
2012-08-01 00:49:04 +00:00
|
|
|
}, 1 );
|
2012-06-21 03:16:10 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
/* Initialization */
|
|
|
|
|
2012-07-20 23:59:59 +00:00
|
|
|
ve.init.mw.targets.push( new ve.init.mw.ViewPageTarget() );
|