Commit graph

832 commits

Author SHA1 Message Date
Catrope 84e598953a Wrap inline elements properly
The HTML "1<br/>2" was being converted to a linmod that looked like
"<p>1</p><br></br><p>2</p>". This commit fixes the wrapping logic such
that the result is "<p>1<br></br>2</p>" instead. In general, inline
nodes (content nodes) should not interrupt the wrapping, but block nodes
should.

This creates a problem for alien nodes: normally, we determine whether an
alien node is a block alien or an inline alien based on context, but if
we're in wrapping mode we're unsure of the context. We can't tell the
difference between "1<tt>Foo</tt>2" (should be wrapped as one, because
tt is inline) and "1<figure></figure>2" (1 and 2 should be wrapped
separately, because figure is block) using context alone, so in these
cases (and ONLY in these cases) we look up whether the HTML tag in
question is an inline tag or a block tag and use that to decide.

Change-Id: I75e7f3da387dd401d9b93e09a21751951eccbb83
2012-10-17 13:50:29 -07:00
Christian Williams 156e56b47b Fixing location of ve.ce.CenterNode.js and adding comma between variable declarations
Change-Id: If54e314f47860ac30060bec6b3f5997ed3709e0b
2012-10-17 13:18:57 -07:00
Inez Korczyński 5c83742313 (Bug 41120) Missing coma. Who knows how it happened...
Change-Id: I4c0a65cc751bf378368df9f8b793f672fb7cca15
2012-10-17 12:48:11 -07:00
Trevor Parscal 5cd4222d9c Whitespace and comment cleanup for dm annotation classes
* Added comments to classes and methods
* Quieted a jshint warning
* Broke some long lines
* Replaced instances of "var\t" with "var "

Change-Id: I1d617ed9e5180f1a3dff42078fb5debb5d718407
2012-10-17 12:35:28 -07:00
Trevor Parscal 1c5ac9d502 Merge "Fix exception when deleting all text (Ctrl+A Backspace)" 2012-10-17 19:33:48 +00:00
Inez Korczyński 874adec1ac (Bug 41120) When getOffset is called for a slug offset there is no need to traverse DOM - we can simply just call getSlugAtOffset and use that information.
Change-Id: I46b21ca0d3ca11d72c77feeb884f7d92a201de36
2012-10-17 12:32:27 -07:00
Trevor Parscal 64442e03d8 Merge "Fix JS error in DocumentSynchronizer when adding to an empty document" 2012-10-17 19:28:58 +00:00
Trevor Parscal 020a04f3dc Merge "Get annotations from first character of a range" 2012-10-17 19:28:05 +00:00
Trevor Parscal a981d98b1e Merge "Fix path issues with missing files, inconsistent subset in demo, test & mediawiki." 2012-10-17 19:27:16 +00:00
Christian Williams 280b0a368e (bug 41092) Fixing cut
Surface was being accidentally locked when we actually want the surface to re-render.

Change-Id: I1d20faec8e55934e1fff7534c7d8cfe94d19031d
2012-10-16 23:33:28 -07:00
Christian Williams 7a2faf7daf Ignore backspace keypress
Firefox triggers a keypress event for backspace. We handle backspace in keydown, so this keypress event should be ignored.

Change-Id: I6a481dbd5df0cf4558a5f1975717ca809250ccda
2012-10-16 12:23:57 -07:00
Timo Tijhof edc5f38d4c Fix path issues with missing files, inconsistent subset in demo, test & mediawiki.
* CenterNode missing in ResourceLoader registry
* UI classes and rangy not in static test/index.html
* Transaction and TransactionProcessor listed twice

Added a maintenance script that generates the <script> and <link> tags for all
files in the same order everywhere.

Change-Id: I5d22d33769b4e356e8065d295505f6f9a8b0bea8
2012-10-16 10:03:26 -04:00
Christian Williams 177557808b (bug 33064) Ignore non-content keypresses
Ignore keypress handling for any keypress with e.which of 0.

Change-Id: Ifa8a562eb882b337bad466183849ba9871605653
2012-10-15 23:05:47 -07:00
Christian Williams 40cc89eb50 Get annotations from first character of a range
If you select some text and start typing, we will now remove the content in the range and new content will be annotated with the annotations from the first character in the deleted range. This is similar to other editors.

Change-Id: I46ced52665ab10f9b724dbb225df5687c18a4c3a
2012-10-15 17:39:28 -07:00
Catrope 0054cd2a57 Fix exception when deleting all text (Ctrl+A Backspace)
Exception was caused by passing -1 to getAnnotationsFromOffset(). So
check for -1 before passing it in; getNearestContentOffset() can
legitimately return -1 if there are no content offsets in the document,
which occurs when the document is empty.

I was originally going to change getNearestContentOffset(start - 1, -1)
to getRelativeContentOffset(start, -1), but Inez correctly pointed out
that that would have unwanted results when near an inline node.

Change-Id: Ife4b497b1c5fd04d411bb25cea99e6ea2abf146f
2012-10-15 15:03:08 -07:00
Catrope 91964a48d0 Fix JS error in DocumentSynchronizer when adding to an empty document
This was reproducible by blanking the entire document (Ctrl+A Delete),
then undoing that (Ctrl+Z). AFAIK that's the only way to trigger an
insertion on a document that is completely empty.

Change-Id: I22252d5972a413dff614880a90c4c6b22e79672d
2012-10-15 15:01:39 -07:00
Rob Moen 7db62daac7 Fix bold and italic key commands in surfaceView.
Change-Id: Iefc436a27285fd811b9d1ac2c684160fe7818a30
2012-10-15 14:47:40 -07:00
Inez Korczyński dac224e110 Added support for Ime in IE. In IE when starting IME sequence 'compositionStart' is called to late, but fortunatelty we can do all necessary job in handler for 'keyDown'.
Change-Id: Id6f15015c45afd81cf8e74d3e03f7fa21611862d
2012-10-14 12:28:06 -07:00
Catrope a64587e44f Merge "Reversed the default value of autoSelect in surface fragments" 2012-10-13 01:10:10 +00:00
Catrope a328a43373 Fix UI for annotation API changes
Change-Id: Ib8341436ba966628c93854a742d8b3a5b45a1d83
2012-10-12 17:53:42 -07:00
Trevor Parscal 6c3878be9e Added multiple name registration to ve.Factory
Also changed from using "type" to "name" to make it less specific and added a test to make sure it's working.

Change-Id: I150a7ab1a57b3df85b459dbc411c2eaefe08b5bb
2012-10-12 17:43:04 -07:00
Trevor Parscal 4fbf7308f7 Reversed the default value of autoSelect in surface fragments
Arguments with default truthy arguments are evil

Change-Id: I3fb972af1b8f52837497950281c537fe09eb7975
2012-10-12 17:34:15 -07:00
Rob Moen ab7c39cf79 Fix context icon in surfaceView
Change-Id: I742b6df25679827fd0e3096a58bb5291c5f4f77d
2012-10-12 17:18:32 -07:00
Catrope 405581f6b8 New annotation API: update tests
Change-Id: I301a1d89c33dd68197d629d187a9a5be8cbf3852
2012-10-12 15:07:28 -07:00
Catrope 8d56cadb82 New annotation API: ve.ce.TextNode integration
Finally getting rid of .annotationRenderers, yay!

Change-Id: I17cb2598de9747d1e3b68ff18ebb02efd56c04c3
2012-10-12 15:07:28 -07:00
Catrope 735ee449e3 New annotation API: ve.dm.Converter integration
The annotation-related code in the converter is greatly simplified
because the API itself takes care of almost everything already.

Change-Id: Ib48f52bad6b650a05dc4e7ef82db4158c19b3cf5
2012-10-12 15:07:28 -07:00
Catrope 613dd14332 New annotation API: convert existing annotations
This changes ve.dm.LinkAnnotation to be a generic annotation for <a>
tags, and adds ve.dm.MWInternalLinkAnnotation and
ve.dm.MWExternalLinkAnnotation as MW-specific subclasses. This nicely
splits out the MW-specific parts in LinkAnnotation, and ideally we'd
also move these files somewhere else to reflect their MW-specificity,
but I haven't gotten to that yet.

Similarly, ve.dm.TextStyleAnnotation is now a generic base class for
simple tag-only-no-metadata annotations, and it has 11 subclasses, one
for each tag we support. This is quite a bit more verbose than the
previous code, but I think it's cleaner and more flexible. I considered
writing a function that would generate a TextStyleAnnotation subclass,
then calling that 11 times, but that's not possible if we want to keep
named functions for the constructors.

Change-Id: Ifba10153eef40280e44025dd72d4e9d9f33b0632
2012-10-12 15:07:25 -07:00
Catrope 7fe7182f43 New annotation API: Annotation and AnnotationFactory classes
Fleshes out ve.dm.Annotation to a class. Annotations in the linear model
will be instances of a subclass of ve.dm.Annotation. Annotations are
defined by subclassing ve.dm.Annotation and registering this subclass
with ve.dm.AnnotationFactory.

ve.dm.AnnotationFactory keeps track of which annotation classes are known,
and has code to match an HTML element to an annotation class, for use in
the converter.

Change-Id: I68802bdb8736ced1f9e04ee49c623944b448141c
2012-10-12 15:07:02 -07:00
Catrope 9ca5da44ee Merge "Revert "No longer create zero-length text nodes"" 2012-10-12 18:04:22 +00:00
Catrope 0a6a2c7cd8 Revert "No longer create zero-length text nodes"
Inez asked for this to be merged but now says it's broken

This reverts commit 7702ec10dc
2012-10-12 18:04:15 +00:00
Inez Korczyński 3c69871f4a Refactored method ve.ce.Surface.handleInsertion. Now handling slug and insertion annotations is combined.
Change-Id: I70494c185addcf4d07d385dc1e9745aca2f9d05b
2012-10-11 16:32:32 -07:00
Trevor Parscal 55a31122b5 Merge "Support for pre-unannotating test" 2012-10-11 23:28:18 +00:00
Trevor Parscal e02a253e0e Merge "Native cursor movement" 2012-10-11 23:27:25 +00:00
Christian Williams 011069d17c Native cursor movement
The cursor will move natively when it can, allowing for word jumping with alt/ctrl keys. Special conditions exist for slugs and node boundaries that result in programatic movement.

Change-Id: Ife156bf94d8192ddd322c016ca8359855b17d7fc
2012-10-11 15:51:45 -07:00
Inez Korczyński a78719d7e4 Added missing call to surfaceObserver.clear();
Change-Id: I64eeeef8339d5765d5ce732e660eeba35482d7d3
2012-10-11 13:59:30 -07:00
Christian Williams 9719589e9a Support for pre-unannotating test
Removing check for insertAnnotations length because it's also important to know if we're pre-unannotating text.

Change-Id: I7fab39ca353d7656de3ce2985a821cb54384100e
2012-10-11 13:38:54 -07:00
Trevor Parscal f94063db12 Merge "Introduce new method in ve.ce.Surface called handleInsertion that is responsible for the magic around inserting content with new annotation, or in a slug, or with IME." 2012-10-11 19:43:18 +00:00
Trevor Parscal b3a90966f3 Merge "No longer create zero-length text nodes" 2012-10-11 19:42:52 +00:00
Inez Korczyński 4c08740794 Introduce new method in ve.ce.Surface called handleInsertion that is responsible for the magic around inserting content with new annotation, or in a slug, or with IME.
Change-Id: Ia558376d3e509d15a0746297a9dd29d09beec652
2012-10-11 12:06:17 -07:00
Trevor Parscal 2a1eb1394d Merge "Add ve.getProp()" 2012-10-11 18:26:31 +00:00
Trevor Parscal 5ad9b0c8a9 Merge "Support custom hashes in ve.getHash()" 2012-10-11 18:17:21 +00:00
Trevor Parscal 9b7f9cda42 Merge "Add ve.getOpeningHtmlTag()" 2012-10-11 18:16:55 +00:00
Trevor Parscal f72083f85c Merge "Add setDOMAttributes()" 2012-10-11 18:16:13 +00:00
Catrope a7a64abcf5 Add ve.getProp()
Change-Id: Iad9f53ae252acbeb2842645e6e66c0dfc7618f9f
2012-10-10 17:50:19 -07:00
Catrope b630b8a2a6 Support custom hashes in ve.getHash()
Change-Id: I9193472773b999b45ce850a609ad5fe141421dbf
2012-10-10 17:31:11 -07:00
Catrope 22c7f16b99 Add ve.getOpeningHtmlTag()
Utility function to generate an opening HTML tag. Needed to integrate
the new annotation API with ve.ce.TextNode

Change-Id: I6804bbf6f79346fde1887fa82d29ec5cd0342d60
2012-10-10 17:30:07 -07:00
Catrope 3f4c656275 Add setDOMAttributes()
Change-Id: I1406998400c4f7f3d0983a43e3f86afe4ffd29a6
2012-10-10 15:10:31 -07:00
Christian Williams f2d08f913b Added reversed boolean for translateOffset
Previously, Undo used a transaction's lengthDifference to calculate the selection to display after the transaction was undone. Now, translateOffset with the reversed boolean set to true will properly translate the inverse of a transaction's selection change. Fixes bug #40538

Change-Id: I110bc0cbb5824547842efd391b9f2948b037b758
2012-10-10 14:59:30 -07:00
Catrope 7702ec10dc No longer create zero-length text nodes
We were populating empty content nodes with zero-length text nodes to
make round-trip tests in the test suite work (otherwise blanking a
paragraph leaves behind a zero-length text node whereas creating an
empty paragraph does not), but the empty nodes are causing problems in
CE apparently.

* Do not create empty text nodes when constructing a node tree
* Be more careful with text-only replacements:
** Don't resize a text node to zero, remove it instead
** There may not be a text node to resize at all, build it in that case
** Switch nodeRange to nodeOuterRange, this was probably broken before

Tests:
* Change test case for zero-length text node to assert that there is
  *no* zero-length text node :)
* Remove a test case concerning an empty text node from the
  ve.ce.TextNode suite

Change-Id: Ie677457f2f0a7823a517ba3077b844ef52a20fcc
2012-10-10 14:48:47 -07:00
Timo Tijhof 07c86fc5d3 inheritClass: Implement inherited 'static' property for classes.
Previously tests for inheritClass (and other object management
utilities) were absent (as they were copied from upstream K-js).

I've copied the upstream test suite for this method here and
extended it with tests for this new feature.

Had to add es5:true to .jshintrc due to a bug in JSHint.
Repeated the setting in ve.inheritClass for future reference.

Source: https://github.com/Krinkle/K-js/blob/master/test/K.test.js

Change-Id: I63ac620d6ce7832ebfee454ddf7b7c90f6eb6121
2012-10-09 18:29:41 +00:00
Trevor Parscal bbb38c590e Merge "Add missing return in ve.getDOMAttributes()" 2012-10-09 18:21:35 +00:00
Trevor Parscal 87cb7045c1 Merge "Removing onKeyPress return statement" 2012-10-09 17:54:51 +00:00
Christian Williams 4e585eb092 Removing onKeyPress return statement
Also switched to using surfaceObserver and cleaned up some trailing whitespace.

Change-Id: If9a2b390e86f54b4c5ddfd499eefb31f0ab2c96f
2012-10-09 10:54:27 -07:00
Timo Tijhof 73851696f1 ve.Factory: No need for a-b-c workaround, createObject and apply.
This works just fine, as also previously tested/proven by
ve.cloneObject, which uses the same concept of creating an object
identical to what invoking the constructor with "new" would do,
but without invoking the constructor function (which has side-
effects).

Except in this case we do invoke the constructor function, but
we can't use new in ve.Factory because of the arbitrary number of
arguments.

Added a test to assert that 3+ arguments and that instanceof
work as expected.

Change-Id: If0add3da7475886e476900044acda2ba7d01fb11
2012-10-09 19:36:48 +02:00
Timo Tijhof a15b2f77f2 Fix constructor names; remove redundant hasOwnProperty.
Add some missing constructor names and rename the ones with a
lowercase 'v'.

I previously changed Object.create and others to using hasOwn,
but that turned out to be useless. The thought at the time was
to only use the native one if it really is a native one (and not
a polyfill from another script), however in then hasOwn is only
relevant on prototypes and when negated. For static members it
would be an own-property either way.

Follows-up:
* Id6783fcfc35a896db088ff424ff9faaabcaff716 (metanode)
* Iab763954fb8cf375900d7a9a92dec1c755d5407e (object-management)

Change-Id: Ia6ef597e5e5453277472dfc23f25d2878b68b7f6
2012-10-08 06:15:20 +02:00
Catrope ac4c259a19 Add missing return in ve.getDOMAttributes()
Change-Id: I659667a0424bf166cee95b743469e716ff11f3d9
2012-10-05 18:18:51 -07:00
Inez Korczyński 1ed7b3f96e Update ve.ce.Surface to call SurfaceObserver.stop/start/clear instead of stopPolling/startPolling/clearPollData.
Change-Id: I164599dd34304a3eaef285859a66428cf839accb
2012-10-05 14:57:42 -07:00
Catrope f434da5140 Merge "Changed method name to setAutoSelect to avoid collision" 2012-10-05 21:25:51 +00:00
Catrope ffc34ee15a Merge "Got tests working again" 2012-10-05 19:01:38 +00:00
Trevor Parscal 51ac385c98 Merge "Created QUnit tests for ve.Document.selectNodes method (mode "branches")" 2012-10-05 18:57:37 +00:00
Trevor Parscal da2d89ee3a Changed method name to setAutoSelect to avoid collision
Plus, this is more consistent with the rest of the method names

Change-Id: I713f1bfc28d22cc259ce5dba69ea053817fd43f8
2012-10-05 11:07:10 -07:00
Inez Korczyński 2d752fe60c Small clean-up in ve.ce.Surface constructor.
Change-Id: I679511cd0b22192213873ceca5d8410b56d5def9
2012-10-04 17:08:26 -07:00
Inez Korczyński 4ab9d112b7 Created QUnit tests for ve.Document.selectNodes method (mode "branches")
Change-Id: Iee243ffe1a71a23a3ad540421a0cbbb973433f58
2012-10-04 15:24:02 -07:00
Inez Korczyński b2295a2de3 Fix minor bug with incorrect usage of hasSlugAtOffset.
Change-Id: I413fc5850cd7bcae9b1d955eb951394e1ed9df36
2012-10-04 14:31:25 -07:00
Inez Korczyński 72eb2825e5 Start using ve.ce.SurfaceObserver inside ve.ce.Surface. Moved methods getOffsetOfSlug, getOffsetFromElementNode, getOffsetFromTextNode and getOffset to ve.ce.js and made them static.
Change-Id: If6ce0ae10c494392cc384341cc87b61658d4934a
2012-10-04 14:28:54 -07:00
Inez Korczyński c4299fd838 Retire ve.ce.Surface.render variable and instead of it use variable "locked" via methods lock(), unlock() and isLocked().
Change-Id: Ic476a51e9e7766bd2793c2a7d773734cf9bcd0b6
2012-10-04 14:26:06 -07:00
Inez Korczyński 3b8a5ae4d5 Initial import of ve.ce.SufaceObserver
Change-Id: Ifc14a6cc30e46c8ae99c59dcb916795c603329ed
2012-10-04 14:24:12 -07:00
Inez Korczyński 15b151ef58 Setup variable ve.debug to true when ve.debug.js is loaded.
Change-Id: I22309ddfda8271456665eb40c4b698c160061de4
2012-10-03 18:02:31 -07:00
Trevor Parscal 2c3142225f Got tests working again
I think what happened here is I added the skeleton code, Kranitor came through and removed the unused arguments, then I merged in my implementations without pulling, then pushed - git merged cleanly, the arguments I thought were there were not there, and tests broke.

Change-Id: I5aa2968fef164c774a10db83a6df1753c93cd2dc
2012-10-03 16:03:33 -07:00
Inez Korczyński 0b135ede31 Add 'branches' mode to ve.Document.selectNodes method. Tests TBD.
Change-Id: Id466b9452fd0b515831a2536ccc32caa339ee885
2012-10-03 15:55:54 -07:00
Inez Korczyński 714e29d30f Created method getSlugAtOffset in ve.ce.Document and ve.ce.BranchNode, refactored the way how slugs are added.
Change-Id: I8006c7e6e1dd3c640939bf08f39192615b2e5343
2012-10-03 15:40:44 -07:00
Trevor Parscal 58e37e78a9 Merge "Fix transaction bug with Roans help." 2012-10-03 17:56:33 +00:00
James D. Forrester 03c428155e Alter the target of the Feedback link to be the right page.
Specifically, go to [[mw:VisualEditor/Feedback]] rather than [[mw:Visual editor/
Feedback]], as the primary set of pages on MWwiki have been moved some time ago
and right now we're stranding users' feedback messages at the wrong place.

Change-Id: Ia2ba0dad7d1bf0d1633fe2704a2e8354285c66da
2012-10-02 15:41:18 -07:00
Rob Moen 3a48860602 Fix transaction bug with Roans help.
Fixes (Bug 40339)

Change-Id: Ice26bf08071cba5c5500aa9196ade169381a9aea
2012-10-01 16:31:16 -07:00
Trevor Parscal 1ab5fac1aa Merge "Using getRelativeContentOffset for insertAnnotations" 2012-10-01 21:27:54 +00:00
Trevor Parscal 57ec680d76 Merge "Add utility function to get DOM attributes as a plain object" 2012-10-01 21:27:21 +00:00
Krinkle 5ba4c9694d Merge "Added surface model lock and unlock events" 2012-10-01 21:25:08 +00:00
Trevor Parscal 903acdfdf2 Added surface model lock and unlock events
This allowed me to move ve.ce.Surface particulars (such as the starting, stopping and clearing of polling) out of the UI code.

Also cleaned up some switch statements.

Change-Id: I7b85e42a4e01f8d76237d995e25275f2424541ea
2012-10-01 14:23:11 -07:00
Catrope 7cc8096864 Add utility function to get DOM attributes as a plain object
Change-Id: I64abfb7479ae687f95e604f1df48dfe8439176ed
2012-10-01 14:14:52 -07:00
Christian Williams 75c154ef6c Using getRelativeContentOffset for insertAnnotations
Previously, we were looking one offset to the left to load the insertAnnotations. This would fail at the beginning of a document that began with a slug, and probably other cases too. Now using getRelativeContent offset.

Change-Id: I31b24e2ccfa9fda2ce7fb19d1221f8708a96083f
2012-10-01 13:43:27 -07:00
Trevor Parscal 4ae9096632 Merge "Make getDomText() return an empty string for slugs" 2012-10-01 20:06:26 +00:00
Robmoen 8815c3eae4 Merge "Throw an error for bad offsets in getNodeFromOffset()" 2012-10-01 18:46:36 +00:00
Catrope 40b60ebda8 Make getDomText() return an empty string for slugs
Slugs aren't represented in the model at all, but in the DOM they do
contain a single character (&nbsp; or &#xFEFF;), so we have to override
the return value of getDomText() to be empty.

Change-Id: Ic93cb694b0632bc81d8d0749149e4d739232ed48
2012-10-01 11:37:39 -07:00
Catrope 7ec1b8d76d Add exception to getAnnotationsFromOffset() for easier debugging
Change-Id: Ief1209267d2d6f91f8572e4fa15a49e886bc0a30
2012-10-01 11:30:53 -07:00
Catrope 9488a38cca Throw an error for bad offsets in getNodeFromOffset()
Will ease debugging of bug 40463

Change-Id: I3fbacb3e6e2f242c1584f51581d2b4e7c4bdd4dc
2012-10-01 11:25:31 -07:00
Robmoen ff6d0b4a31 Merge "Made save dialog float with toolbar" 2012-09-28 21:04:30 +00:00
Trevor Parscal bfeb0455d9 Added callout icon
Change-Id: I1641c91a2729ada40ccada6b85e9f0e46e1d0c21
2012-09-28 14:00:46 -07:00
Trevor Parscal 57599e1c95 Made save dialog float with toolbar
Change-Id: I6c66c3817669adcee6314c16fcf49ef1a8db7b65
2012-09-28 13:44:51 -07:00
Trevor Parscal 0cbec61b73 Merge "Create method ve.Range.isCollapsed() and added some tests for ve.Range class." 2012-09-28 20:35:16 +00:00
Inez Korczyński 15e0c13fa9 Create method ve.Range.isCollapsed() and added some tests for ve.Range class.
Change-Id: I866b00db196a768460b32766b82fbdf896a48fdd
2012-09-28 13:32:26 -07:00
Christian Williams ffefe63063 Insert Annotations
Change-Id: Ibc927730a668cdcea9c90fe4fc2cb3db4d20480e
2012-09-28 13:28:47 -07:00
Trevor Parscal 50ddba4d12 Really remove all, not just half
Iterating forwards while removing from an array is a good way to get half way there and be confused as hell.

Change-Id: I74db84eee87c73d8e035f6dc8a92be0d0b9b3dad
2012-09-28 12:17:04 -07:00
Trevor Parscal 5f0ccc807a Removed a single space.
Change-Id: Id4f96d980306e00b81a13441c38a3913ae312535
2012-09-27 11:57:50 -07:00
Robmoen 2737b0d0c8 Merge "Icon improvements" 2012-09-26 22:03:53 +00:00
Trevor Parscal 4c9b1d6035 Icon improvements
* Added some new icons (to be used soon in the inspector redesign)
* Added right-to-left icons for lists
* Renamed some icons for future RTL use

Change-Id: I10e3e3fcda82786e3064176e7eefe211b88db95c
2012-09-26 14:53:11 -07:00
Robmoen 6d03a58f21 Merge "Fixed ve.OrderedHashSet.filter" 2012-09-26 21:02:14 +00:00
Trevor Parscal b696e1e84b Fixed ve.OrderedHashSet.filter
Was cloning the original set, then adding to it - resulting in always containing the whole set in any match.

Also using test instead of exec since exec returns a string result, which under strange circumstances could return a falsy result, despite the RegExp finding a match.

Change-Id: I09a7cb264521d58f02d6ff2547edad9a740b23b2
2012-09-26 13:57:19 -07:00
Rob Moen 4613707909 re: AnnotationSet, fix JS error in getFirstLinkAnnotation.
Change-Id: I6a3cb4eb2164bf1c4c8f715e42117ac06cccac04
2012-09-24 17:16:10 -07:00
Catrope 5075d79c4b Merge "Regression fix, clearing only link annotations when creating link." 2012-09-24 22:06:00 +00:00
Rob Moen d5d44df053 Regression fix, clearing only link annotations when creating link.
Clearing only existing selected links when:
1) Creating a link
2) Pressing clear button

Change-Id: I4b1bcd9a3ac177b2f9b4af2d562d4c4fec09d5c5
2012-09-24 15:03:53 -07:00
Catrope 31fc2dc2b4 Merge "re: AnnotationSet, annotationButtonTool properly clears annotation." 2012-09-24 22:00:26 +00:00
Rob Moen 7be9f92de7 re: AnnotationSet, annotationButtonTool properly clears annotation.
Surface model annotate method previously cleared basic tool annotation objects.
Now that bold and other annotations have htmlAttributes from parsoid,
we must gather annotations by type from selection and iterate through
to properly clear.

Change-Id: Id53bf5733078524ae5aac376e01b9679eb8c32df
2012-09-24 14:58:55 -07:00
Krinkle a5a745de69 Merge "ve.dm.SurfaceFragment: Implement wrapNodes and wrapAllNodes" 2012-09-24 19:11:35 +00:00
Trevor Parscal eabe5e6f61 ve.dm.SurfaceFragment: Implement wrapNodes and wrapAllNodes
Change-Id: I378f0aad0286a6c90adeb4602a57d6617154e8b6
2012-09-24 21:11:16 +02:00
Krinkle db2c44ef2d Merge "Added CSS rules back in to put the menu above/below" 2012-09-24 01:56:26 +00:00
Trevor Parscal bee50ae84f Merge "Use inspector specific icon css files vs entire icon set css." 2012-09-21 22:49:01 +00:00
Krinkle 7b15b24496 Merge "Added missing annotation types to domElementTypes array" 2012-09-21 02:02:55 +00:00
Krinkle 717edd5ed4 Merge "Whitespace and comments" 2012-09-21 01:55:53 +00:00
Rob Moen ff1fc7ef08 Use inspector specific icon css files vs entire icon set css.
Change-Id: I9c519abc478ac22976a8d86aac461d90c92c8a57
2012-09-19 17:16:05 -07:00
Trevor Parscal 71f91dd92c Added CSS rules back in to put the menu above/below
Change-Id: I34d9031c04bed4944d2b3cd184fed021fc31d4a9
2012-09-19 12:37:06 -07:00
Trevor Parscal f2454bab68 Merge "Optimize UI tool state updates." 2012-09-19 19:34:29 +00:00
Rob Moen 96d97c2aa8 Optimize UI tool state updates.
Rather than each tool requesting annotations, and nodes pertaining to selection,
Emitted event supplies annotations and nodes to each tool's update method.

Using select vs. of traverseLeafNodes for code optimization.
Better documentation for updateTools()

Removed unneeded code.

Change-Id: I7c0baa1cc0f7fb731d6e28b175a76e931e9e2961
2012-09-19 11:16:10 -07:00
Trevor Parscal daa7e76807 Merge "Add a node type for meta nodes" 2012-09-18 18:15:46 +00:00
Trevor Parscal 944228aec7 Whitespace and comments
* Added documentation for ve.AnnotationSet
* Replaced uses of "// Inheritance" with "// parent Constructor"
* Added "// Mixin constructor" where needed
* Added missing section comments like "/* Static Methods */"
* Cleaned up excessive newlines (matching /\n\n\n/g)
* Put unnecessarily multi-line statements on a single line

Change-Id: I2c9b47ba296f7dd3c9cc2985581fbcefd6d76325
2012-09-17 16:53:03 -07:00
Trevor Parscal adda2b85c3 Merge "Documentation & clean up" 2012-09-17 23:21:49 +00:00
Timo Tijhof ab7d6bf082 Documentation & clean up
* Commands for Sublime:

  Find*: "(\* @[a-z]+) ([^{].*) \{(.*)\}"
  Replace: "$1 {$3} $2"

  Save all && Close all

  Find: " function("
  Replace: " function ("

  Save all && Close all

  Find: "Intialization"
  Replace: "Initialization"

  Save all && Close all

* Consistent use of types (documented in CODING.rm):
  - Merged {Integer} into {Number}.
  - Merged {DOM Node} into {DOMElement}.

* Remove work-around /*jshint newcap: false */ from ve.js
  Calling Object() as a function to to use the internal
  toObject no longer throws a newcap warning in JSHint.
  It only does that normal functions now .

  (e.g. var a = Cap(); or var a = new uncap();)

* Add missing annotations (@static, @method, ..).

* Remove unused variables

* Remove null-assignments to variables that should just be
  undefined. There's a few variables explicitly set to null
  whereas they are set a few lines under and not used otherwise
  (e.g. 'tx' in ve.ce.Surface.prototype.onPaste)

Change-Id: I0721a08f8ecd93c25595aedaa1aadb0e08b83799
2012-09-17 16:02:52 +02:00
Rob Moen df4391bc69 (bug 38548) Switch undo / redo buttons for RTL.
Rename the graphic files to more generic names to make them
flippable by CSSJanus.

Change-Id: Ide2540f2f281367909f7f2c7943c9106c0b36699
2012-09-16 08:39:18 -07:00
Krinkle 4edc76ab79 Merge "(Bug 33094) Disallow invalid page titles in LinkInspector." 2012-09-14 12:53:58 +00:00
Rob Moen 442a8358ea (Bug 33094) Disallow invalid page titles in LinkInspector.
Detecting page status in a similar way as WikiEditor inspector.
Disabled accept button now behaves appropriately.
Accept button status is now evaluated on enter or submit.

Change-Id: Ibfef6ffd87cb9a71e37242d6214d0f8e3af2e2c0
2012-09-14 14:51:26 +02:00
Siebrand ed66eb7a05 Merge "Revert "Added 'bytes' remaining to edit summary dialog."" 2012-09-11 20:57:39 +00:00
Siebrand a218baa8c9 Revert "Added 'bytes' remaining to edit summary dialog."
This reverts commit 75c0cdbd38
2012-09-11 20:57:21 +00:00
Reedy 4bff9bb2dc Merge "Added 'bytes' remaining to edit summary dialog." 2012-09-11 20:34:18 +00:00
Rob Moen 75c0cdbd38 Added 'bytes' remaining to edit summary dialog.
Addresses (Bug 40035)

Change-Id: Iad94ea32b62aef2e1875fa2709b6303b88c9c137
2012-09-11 12:34:19 -07:00
Trevor Parscal 80f266d582 Merge "Hiding inspector iframe by additionally setting height and width to 0." 2012-09-11 19:24:10 +00:00
Trevor Parscal c39c788105 Added missing annotation types to domElementTypes array
Change-Id: I595bce18c4a18397fdb7c91b4b033cad40e57008
2012-09-11 11:40:59 -07:00
Rob Moen 2e3821804f Pressing enter key in edit summary no longer submits save form.
Fixes (Bug 40034)

Change-Id: I5b1cca3dc97686982b8dde907c827dc6e031c312
2012-09-11 09:33:07 -07:00
Catrope 7b96fbe3d2 Add a node type for meta nodes
This node type represents <meta> or <link> (transparently, based on the
style attribute). I had to make two node types for this and hack the
toData conversion code directly into ve.dm.Converter, because we don't
have native support for node types that can be both inline and block.
(We should add this in the node API rewrite.)

The CE implementation renders a placeholder (with the same styles as an
alien node) right now. I'm not sure how nice that is, but it's better
than rendering raw <meta>/<link> tags.

This whole thing is a total pile of hacks to make VE deal with
<meta>/<link> tags until we have a proper node types API.

Change-Id: Id6783fcfc35a896db088ff424ff9faaabcaff716
2012-09-10 15:35:30 -07:00
Rob Moen 231f8b6a5d Hiding inspector iframe by additionally setting height and width to 0.
Addresses iframe bug regression

Change-Id: I498b793277fcfaeca15adffc9f33c31734dade93
2012-09-10 12:20:37 -07:00
Trevor Parscal 4cdce88b9a Merge "Fixed multiple bugs with Context Icon appearing when not relevant." 2012-09-07 23:12:31 +00:00
Rob Moen bcaab3332e Fixed multiple bugs with Context Icon appearing when not relevant.
Icon appears when scrolling and resizing window.
	Instead of always setting the context on scroll and resize, bind to the
	updateContextIcon method.
Icon appears when selecting a non content data offset.
	Changed logic to show icon changed to content length vs range difference.

Move Link inspector getSelectionText to ve.dm.document getText.
Rationale, more bits of the code depend on evaluating content.
Added new ve.Range truncate method.
Remove getSelectionText, using truncate range & document.getText instead.

Change-Id: Ibd3e99c923f18d2c96a86d92e74e2e9ebd49c85f
2012-09-07 16:12:14 -07:00
Catrope c6cb537f1a Fix bugs in whitespace preservation for aliens
This was broken in three different ways:
* On the way in, we were applying whitespace to an array of elements
  rather than the actual element, so the whitespace wasn't stored.
* Whitespace processing on the way out was skipped for aliens because
  they had their own code path. Refactored this so alien openings and
  regular openings share much more code, including whitespace output.
* Somewhat unrelatedly, innerPost output was broken for paragraphs
  containing inline elements, because the inline elements' processing
  polluted lastOuterPost. Discovered this because my test with inline
  aliens also happened to be the first test of whitespace preservation
  in paragraphs with inline content elements. Fixed by explicitly
  skipping content nodes when outputting whitespace.

Fixed these issues and added a test case.

Change-Id: I8edb61a008e60ace886b1a841b3417682ec39c32
2012-09-07 15:17:28 -07:00
Trevor Parscal 4659557fef Merge "(bug 39753) UI restores #toc as inline-block instead of table." 2012-09-07 22:01:44 +00:00
Catrope 74ed8e8766 Rename ve_foo_bar back to VeFooBar per discussion
Change-Id: Ibf6d4f08c4761727b2e3952a76e474c8221b38f9
2012-09-06 16:15:55 -07:00
Timo Tijhof 9fb43b6aeb (bug 39753) UI restores #toc as inline-block instead of table.
* Follows-up 656439240d

Change-Id: I57532e556eafe783c8638b25fce502a158597c97
2012-09-07 01:13:04 +02:00
Trevor Parscal e3375e8f23 Merge "Fix global scope leakage in the Transaction tests" 2012-09-06 22:51:55 +00:00
Catrope d43fffc2d2 Fix global scope leakage in the Transaction tests
Change-Id: I9283acb6179d0be84dadca8ad4e58d5cdd6e3bae
2012-09-06 15:47:33 -07:00
Catrope ef27a4b2b1 Fix order-of-annotation tests for hrefPrefix
Change-Id: I9fffad6cd0b186a070fec34fd0f827a5875a5d67
2012-09-06 15:40:41 -07:00
Timo Tijhof b1d9c83b5d 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-06 15:29:31 -07:00
Timo Tijhof 831f2f5cb1 Shared closure around utility functions in ve.js
In preparation of pushing the object-management branch, which
will need more shared variables (for efficiency) creating
a shared closure. To avoid a spegetti of immediately-invoked
functions that return functions (like ve.getObjectValues and
ve.getObjectKeys).

Less duplication of code and faster execution.

First I had the closure around it as-is but then I figured it'd
be faster to have a local reference to ve (instead of having to
go through implied globals for references to other ve.*)

So I made it a local variable and then exposed it. That way
anything inside referring to each other stays within the same
scope.

Review with ignore-whitespace for clarity.

Change-Id: I415d8635db6d82cf239f0364ccc2d63a61bd5a6d
2012-09-06 15:29:26 -07:00
Trevor Parscal 64209467df Merge "Alienate everything with an unrecognized mw: type." 2012-09-06 21:57:00 +00:00
Trevor Parscal c25e237620 Merge "Also add clone functionality, undefined guard and tests to ve.copyObject()" 2012-09-06 21:53:05 +00:00
Catrope debc429a9f Also add clone functionality, undefined guard and tests to ve.copyObject()
Change-Id: I84ca938cbedf93bfd1c73da16bf9d0d96b3bc749
2012-09-06 14:52:41 -07:00
Catrope 742a97b410 Add tests asserting ordering of annotations works
Change-Id: Iada85b95914a8728ca809ebab9a42723c1e7a02c
2012-09-06 14:43:13 -07:00
Catrope 5e7c14c868 Manage annotations in ve.AnnotationSet object
Introduced the ve.AnnotationSet class to manage sets of annotations. This
is a generalization of ve.OrderedHashSet, a class that manages a set
using an array and an object keyed by hash.

Converted everything that stores, tracks or passes around annotations to
use ve.AnnotationSet. In particular, this means the linear model now
contains AnnotationSets instead of hash-keyed objects.

This allows us to maintain the order of annotations in the linear model,
and will help fix bugs with annotation ordering and splitting.

Change-Id: I50975b0a95f4cc33017a0b59fdede9ed1eff0124
2012-09-06 14:39:38 -07:00
Trevor Parscal efa8a33559 Merge "Plug new vector icons / styles into inspector iframe." 2012-09-06 21:13:43 +00:00
Catrope e14d30f3cc Alienate everything with an unrecognized mw: type.
Currently this is done in a hacky way because we don't have a real
registry of RDFa types for node types, so we just hardcode the list of
recognized types (only links currently).

Change-Id: I5afcc55701fc6fa0ee2a360dcf5ca62b065292f5
2012-09-06 13:33:20 -07:00
Timo Tijhof d660d203ea (bug 39558) Implement byteLimit
* Also clean up ve.init.mw.ViewPageTarget...setupSaveDialog
  Consistently use viewPage instead of 'this' inside this
  function. The reason it is locally aliased is because there is
  other 'this'es used here. Using them mixed is even more
  confusing.
- No need for ve.bind, other handlers in this function also
  just use viewPage instead of binding this.

Change-Id: I25e93862a39134961bf80835f46cbf531d8109e0
2012-09-06 02:54:43 +02:00
Rob Moen 3331b16b3f Plug new vector icons / styles into inspector iframe.
Change-Id: Ibd5227de6b74c51f31093e64a4404d5830e84a4e
2012-09-05 17:15:20 -07:00
Trevor Parscal 1df15237fb Merge "Convert the last two uses of $.toJSON to ve.getHash" 2012-09-05 22:52:00 +00:00
Trevor Parscal 3e9eed623c Expanded isSomethingFishy function
No need to declare the function inline and then run the function 2x on the same data

Change-Id: I41c57f2aa6e38316edb54dd0c7ebb5726d83ebcf
2012-09-05 13:46:32 -07:00
Timo Tijhof 71020f7175 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-05 13:45:09 -07:00
Rob Moen 67749504d2 Center Ellpisis for long page titles. Misc positioning fixes.
MultiSuggest:
Added CSS Ellipsis config option which provides CSS to suggestion items.

LinkInspector:
-Configured multiSuggest for page suggestions with CSS ellipsis off and removed CSS definitions.
Instead, using jquery.autoEllpisis plugin for centered position ellipsis. (Bug 39591)
-Temporary tweak to link input padding to prevent text from overlapping down arrow.
Down arrow soon to be implemented differently.

RTL Fixes:
-MultiSuggest overlay positions correctly by setting a width.
-MultiSuggest background image position fix.

Change-Id: I806ead5a2c2621589f76cfb2b03805cbd0b0a18a
2012-09-05 13:21:29 -07:00
Krinkle 5af7cfbd4d Merge "Improved icons" 2012-09-05 18:11:36 +00:00
Krinkle 193b70f36d Merge "Fix error in ve.copyArray() and add tests" 2012-09-04 22:26:24 +00:00
Catrope da1d0d4391 Fix error in ve.copyArray() and add tests
Change-Id: I05e7971d05dfa3118db97d76f51985f64d994d8b
2012-09-05 00:26:10 +02:00
Timo Tijhof 24590a9702 ve.dm.Converter.test: Add hrefPrefix (follows-up I33eab356)
* Tests were failing since I33eab356.

Change-Id: I1fed0e3e21ea379a583ccd4f611212940264d106
2012-09-03 03:07:24 +02:00
Trevor Parscal bc211d34e0 Merge "Preserve the leading ./ and ../ in internal link hrefs" 2012-08-31 22:22:02 +00:00
Catrope 78359c35ac Preserve the leading ./ and ../ in internal link hrefs
Previously we were just discarding them, but that causes round-trip
issues with Parsoid

Change-Id: I33eab356d77acb3c13dc9da94f773915464ef690
2012-08-31 15:07:35 -07:00
Trevor Parscal b370bbd0bc Improved icons
* Moved icons into Illustrator (used to be in Photoshop)
* Added SVG icons too
* Added support for devices with pixel ratio > 1 (they use SVG)
* Cleaned up icons (little rendering errors here and there)
* Organized icons into their own folder
* Increased the horizontal margin of the down arrows in the formatting (in the toolbar) and location (in the link inspector) drop down menus

Change-Id: I29b7084c9b1145051b2a76f514cfca9826d53ddb
2012-08-31 13:23:04 -07:00
Catrope 2d36ce9465 Convert the last two uses of $.toJSON to ve.getHash
Change-Id: Iff033590a6033a8de88dc571481442a819146c90
2012-08-30 17:29:54 -07:00
Catrope 3ece6e825d Also copy cloneable objects in ve.copyArray()
Change-Id: I572afc282557bab059df0b2a4fd0347336531409
2012-08-30 17:09:00 -07:00
Trevor Parscal f26ae1662b Added tests for removeContent and insertContent
Also fixed the arguments given to insertContent and double-translating the range

Change-Id: I7cb7dcfcee1c88f2052c63e31a0ed37eaaf645ab
2012-08-30 16:55:49 -07:00
Catrope 4fbabd16dd Make translateRange() map the offset immediately before an insertion to after the insertion rather than before
This will cause ve.dm.SurfaceFragment.prototype.insertContent() to place
the selection after the insertion as well.

Change-Id: Ifa7e627daceb90408422eb58c110d475f34ba1e2
2012-08-30 15:26:43 -07:00
Trevor Parscal d208ca9002 Cleaned up uses of jQuery to create and appendTo/prependTo
* Separated DOM changes from creation of elements
* Always using parsing for element creation with known attributes
* Always using attr or addClass for variable attributes

Change-Id: Id101f56594014786892d382d06c658f416224a9c
2012-08-29 18:43:48 +02:00
Trevor Parscal a52d7ff65a Finally getting rid of all the es-* stuff and other cruft
* Switched a lot of classes from es-* to ve-ui-*
* Removed all the DOM structure left over from the old sandbox demo
* Got rid of transparent backgrounds
* Added menu font-size rule to stand-alone target
* Moved some rules around that were in the wrong places
* Got rid of some unused/unneeded methods in the mw target (attach and detach surface methods)
* Added active class to context icon with shallower shadow effect so it doesn't break your spacial perception when you click on it
* Renamed the iframe and iframe wrapper elements so it's easier to see where they came from
* Removed unused CSS rules
* Fixed some uses of prop( 'class', … ) to addClass

Change-Id: I54a660ca0baf0baa4463faca7a1edcf648130b6b
2012-08-28 13:59:35 -07:00
Trevor Parscal ab1f849ad5 Fixed position and size of toolbar in Apex skin
Change-Id: I520eb03a6b000c70d3b4892b25eeda7e43f85897
2012-08-28 13:13:37 -07:00
Krinkle 26ddaa2959 Merge "A bit of cleanup in the inspector and suggestion code" 2012-08-27 23:45:33 +00:00
Trevor Parscal a8166fe5a4 A bit of cleanup in the inspector and suggestion code
* function() -> function ()
* ){ -> ) {
* Quoted JSON keys (Look the other way Timo!)
* Using more descriptive group names, which also avoid using "new" as a key
* Line breaks at 100 columns using 4 spaces/tab
* Not setting classes on suggestion items that have no effect (such as 'external' on a div - even on an <a> tag this isn't enough to get the style because it's not inside #content)

Change-Id: I37032fa8ba93adb7b719d9797f9b1b806359cc13
2012-08-27 16:39:08 -07:00
Trevor Parscal 19b95af9dd Merge "Catching transactions that were not being committed." 2012-08-27 20:09:15 +00:00
Trevor Parscal 52859f5e27 Merge "Move caching mechanism out of multiSuggest plugin to linkInspector" 2012-08-27 19:58:04 +00:00
Trevor Parscal 495796a99e Merge "Refactor ve.getHash: Stabilize cross-browser differences; + unit tests" 2012-08-27 18:02:07 +00:00
Timo Tijhof c8ed44fb07 Refactor ve.getHash: Stabilize cross-browser differences; + unit tests
* Replaces c8b4a28936

* Use Object() casting to detect objects instead of .constructor
  (or instanceof). Both .constructor and instanceof compare by reference
  the type "Object" which means if the object comes from another window
  (where there is a different "Object" and "Object.prototype") it will
  drop out of the system and go freewack.

  Theory: If a variable casted to an object returns true when strictly compared
  to the original, the input must be an object.

  Which is true. It doesn't change the inheritance, it doesn't make it inherit
  from this window's Object if the object is from another window's object. All it
  does is cast to an object if not an object already.
  So e.g. "Object(5) !== 5" because 5 is a primitive value as opposed to an instance
  of Number.
  And contrary to "typeof", it doesn't return true for "null".

* .constructor also has the problem that it only works this way if the
  input is a plain object. e.g. a simple construtor function that creates
  an object also get in the wrong side of the if/else case since it is
  an instance of Object, but not directly (rather indirectly via another
  constructor).

* Added unit tests for basic getHash usage, as well as regression tests
  against the above two mentioned problems (these tests fail before this commit).

* While at it, also improved other utilities a bit.
 - Use hasOwnProperty instead of casting to boolean
   when checking for presence of native support.
   Thanks to Douglas Crockford for that tip.
 - Fix documentation for ve.getHash: Parameter is not named "obj".
 - Add Object-check to ve.getObjectKeys per ES5 Object.keys spec (to match native behavior)
 - Add Object-check to ve.getObjectValues to match ve.getObjectKeys
 - Improved performance of ve.getObjectKeys shim. Tried several potential optimizations
   and compared with jsperf. Using a "static" reference to hasOwn improves performance
   (by not having to look it up 4 scopes up and 3 property levels deep).
   Also using [.length] instead of .push() shared off a few ms.
 - Added unit tests for ve.getObjectValues

Change-Id: If24d09405321f201c67f7df75d332bb1171c8a36
2012-08-27 00:14:02 +02:00
Amir E. Aharoni 47d1704b2b Added a comment about possible i18n messages
For easier grepping, according to
https://www.mediawiki.org/wiki/L10n#Using_messages

Change-Id: Ib766fd9c10ddbe9fd16ccec9b9866457117b3e70
2012-08-25 14:20:33 +03:00
Christian Williams ac7376c8d6 Catching transactions that were not being committed.
Change-Id: Ic75b07f279e4db30f6730f10b31c66d506cb94e8
2012-08-24 15:10:29 -07:00
Rob Moen 986d25eea1 Move caching mechanism out of multiSuggest plugin to linkInspector
Fixed issue where overlay would be incorrectly positioned if built
from previous caching method.

Change-Id: Id7c3ba211d5344292da47917a9bd06654823ee87
2012-08-24 14:04:33 -07:00
Catrope 452c759914 Preserve whitespace between elements
This commit fully utilizes all four positions in the internal.whitespace
array. Outer whitespace is now preserved as well, and is duplicated
either in the adjacent sibling (one node's outerPost is the next
sibling's outerPre) or in the parent (a branch node's innerPre is its
first child's outerPre, and its innerPost is its last child's
outerPost). Before restoring saved whitespace, we check that these two
agree with each other, and if they disagree we assume the user has been
moving stuff around and don't restore any whitespace in that spot. The
whitespace at the very beginning and the very end of the document (i.e.
the first node's outerPre and the last node's outerPost) isn't
duplicated anywhere, nor is inner whitespace in content nodes.

The basic outline of the implementation is:
* When we encounter whitespace, strip it and store it in the previous
  node's outerPost. Also store it in nextWhitespace so we can put it in
  the next node's outerPre once we encounter that node.
* When we encounter whitespace in wrapped bare text, we don't know in
  advance if it's gonna be succeeded by more non-whitespace (in which
  case it needs to be output verbatim), or not (in which case it's
  leading whitespace and needs to be stripped and stored). The fact that
  annotations are nodes in HTML makes this trickier. So we write the
  whitespace to the temporary linmod and store it in wrappedWhitespace,
  then if it turns out to be trailing whitespace we take it back out of
  the data array and record it the usual way.
* Because text nodes can contain any combination of leading whitespace
  actual text and trailing whitespace, and because we may or may not
  already have opened a wrapping paragraph, there are a lot of different
  combinations to handle. We handle all of them but the resulting code
  is pretty dense and verbose.

More low-level list of changes:

In getDataFromDom():
* Added helper function addWhitespace() for storing whitespace for an
  element
* Added helper function processNextWhitespace() for processing any
  whitespace passed on from the previous node via the nextWhitespace var
* Rename paragraph to wrappingParagraph. Make wrapping default to
  alreadyWrapped so we can simplify wrapping||alreadyWrapped and
  !wrapping&&!alreadyWrapped. Add wrappingIsOurs to track whether the
  wrapping originated in this recursion level (needed for deciding when
  to close the wrapper).
* Add prevElement to track the previous element so we can propagate
  whitespace to it, and nextWhitespace so we can propagate whitespace to
  the next element.
* Remove previous newline stripping hacks
* Integrate the logic for wrapping bare content with the outer
  whitespace preservation code
* Remove wrapperElement, no longer needed because we have a dedicated
  variable for the wrapping paragraph now and what was previously inner
  whitespace preservation for wrapper paragraphs is now covered by the
  outer whitespace preservation code.

In getDomFromData():
* Reinsert whitespace where appropriate
** outerPre is inserted when opening the element
** This covers outerPost as well except for the last child's outerPost,
   which is handled as the parent's innerPost when closing the parent.
** innerPre and innerPost are inserted when closing the element. Care is
   taken not to insert these if they're duplicates of something else.
* Propagate each node's outerPost to the next node (either the next
  sibling or the parent) using parentDomElement.lastOuterPost. We can't
  get this using .lastChild because we will have destroyed that child's
  .veInternal by then, and we can't tell whether a node will be its
  parent's last child when we process it (all other processing,
  including first child handling is done when processing the node itself,
  but this cannot be).
* Special handling is needed for the last node's outerPost, which ends
  up in the container's .lastOuterPost property.

Tests:
* Allow .html to be null in data<->DOM converter tests. This indicates
  that the test is a one-way data->DOM test, not a DOM->data->DOM
  round-trip test. The data will be converted to HTML and checked
  against .normalizedHtml
* Update existing tests as needed
* Add tests for outer whitespace preservation and storage
* Add test for squashing of whitespace in case of disagreement (this
  requires .html=null)

Change-Id: I4db4fe372a421182e80a2535657af7784ff15f95
2012-08-23 19:08:00 -07:00
Catrope 53b8bcbd61 Merge "Bug 37904 - Show info in title of link tags" 2012-08-23 22:49:46 +00:00
Trevor Parscal ccc2248aa8 Bug 37904 - Show info in title of link tags
Internal links use the title, other links use the href

Change-Id: I1a1cfd70c222dd1d686b46cd702edf2e9d0e5bae
2012-08-23 15:21:20 -07:00
Trevor Parscal a06d8fdf21 Merge "Also strip ./ in addition to ../" 2012-08-23 22:02:22 +00:00
Christian Williams c011a5c08f Fixing enter to leave list
Pressing enter in an empty last list item should remove the list item and add a paragraph. Transaction was not being committed.

Change-Id: I0b173125d48f629eab923e051648d2036bb8956c
2012-08-23 14:34:36 -07:00
Catrope 3ed257a5d6 Also strip ./ in addition to ../
This is necessary because Parsoid is now prefixing all hrefs with ./

Change-Id: I18c4b7470cfa1dd174e25cc921bf7d4daf5ffc55
2012-08-23 14:29:43 -07:00
Catrope 8c0249bb89 Merge "Bug 37821 - Add support for oldid" 2012-08-23 21:18:37 +00:00
Inez Korczynski 06a5e30c72 Fix for method of retrieving anchor node in ve.ce.BranchNode.onSplice method.
In current implementation ve.ce.TextNode can be represented by more then one DOM node (TEXT_NODE and or ELEMENT_NODE) - for instance "Lorem <b>Ipsum</b> est" (TEXT, ELEMENT, TEXT).

Change-Id: I6530cbf1273ad1b1de3599c3eb929eb7abc2d59e
2012-08-23 13:34:09 -07:00
Trevor Parscal 5ee75fbbfd Merge "Set inspector container height and width to 0 on close." 2012-08-23 19:04:33 +00:00
Trevor Parscal fb09872781 Bug 37821 - Add support for oldid
* Added oldid param to the API
* Added oldId argument to ve.init.mw.ViewPageTarget
* Added redirect when saving an oldid page (which adds a new revision)
* Added venotify param to allow notifications even when redirected
* Added creation notification
* Added page title to saved/created notification

Change-Id: I9e957e6f5bc7920093481ffe3c33e299f87ce50a
2012-08-23 12:03:40 -07:00
Rob Moen f8a43c8776 Set inspector container height and width to 0 on close.
Addresses (Bug 38655)

Change-Id: I93076314bab521fdbc16c5441de4496c4d0b04de
2012-08-23 11:41:42 -07:00
Catrope 337b059e84 Merge "Cleaned up some CSS in ve.ui.Surface.css" 2012-08-23 18:05:19 +00:00
Trevor Parscal c6b1011931 Cleaned up some CSS in ve.ui.Surface.css
Got rid of some commented out code we aren't going to use and fixed the order of arguments to background position to x, y

Change-Id: I4e638c33b053dd916681dc91c8c0d7cff224375d
2012-08-23 11:02:31 -07:00
Trevor Parscal 9c782b29b3 Added monobook support
* Added style for monobook
* Added monobook to whitelisted skins
* Made ve.init.mw.ViewPageTarget resilliant to vector and monobook-like skins

Change-Id: Ia39e034229204ae5f1f70dce5d74c6c4db42277b
2012-08-23 11:01:20 -07:00
Catrope f948c359eb Merge "Bug 38902 - Error on onbeforunload" 2012-08-23 17:39:44 +00:00
Catrope 85d8d1cfa6 Merge "Bug 38857 - UserAgent blacklisting" 2012-08-23 17:31:06 +00:00
Trevor Parscal 9cbc2b0fb2 Bug 38902 - Error on onbeforunload
Just had to make sure the surface was still around before using it.

Change-Id: I13a2f02d256937b7da3aca3ad3c3404bd8f31244
2012-08-22 14:44:03 -07:00
Trevor Parscal b360437243 Bug 38857 - UserAgent blacklisting
Add ?vewhitelist to the URL to override this - useful when testing in a blacklisted browser.

Blacklist:
- msie < 9
- firefox < 11
- safari < 5
- chrome < 19
- opera *
- netscape *
- blackberry *

Change-Id: I6ebb3f7a7d56d395e5fe5c7c9129b606f97aeaab
2012-08-22 14:31:45 -07:00
Trevor Parscal 37b0b9a2f2 Bug 33175 - Copy dir and lang from #mw-content-text div to document
This resolves the content direction issues identified in bug 33175

Change-Id: Iaf61fb9e8ad0ba3ab70ffa00c75da4c6f01aad61
2012-08-22 14:01:38 -07:00
Catrope aae793537c Merge "Support for <center> tag" 2012-08-22 19:54:39 +00:00
Inez Korczynski 844df5c8e6 Support for <center> tag
Change-Id: I0d64561dd82b8377ee7491103e81569eaca22fee
2012-08-22 12:51:33 -07:00
Trevor Parscal d1a0d2f946 Merge "Fixing ve.log and ve.dir for IE" 2012-08-22 18:20:01 +00:00
Catrope 31fdb1044b Fix syntax error in 9d7f4e94b5
Change-Id: Ia063de19bf54cb32d4a72304f3289c6c7fa669ca
2012-08-22 11:14:23 -07:00
Catrope 31bf0ea1f8 Merge "Fix ve.ce.getDomText to work with <br/> tags by making it skip not contenteditable=false but all leaf nodes." 2012-08-22 18:09:30 +00:00
Inez Korczynski 9920fb0725 Fix ve.ce.getDomText to work with <br/> tags by making it skip not contenteditable=false but all leaf nodes.
Change-Id: I9e728e091a3021840dac07e9601fc764e7750c49
2012-08-22 11:08:11 -07:00