Commit graph

78 commits

Author SHA1 Message Date
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
Trevor Parscal 57599e1c95 Made save dialog float with toolbar
Change-Id: I6c66c3817669adcee6314c16fcf49ef1a8db7b65
2012-09-28 13:44:51 -07: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
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
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
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
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
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 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
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
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
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
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
Catrope 8c0249bb89 Merge "Bug 37821 - Add support for oldid" 2012-08-23 21:18:37 +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
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
Trevor Parscal ceb8ac9918 Floating toolbar fixes
* Added more support for making dynamic skin changes in vector (based on media queries) get applied to the toolbar while it's floating
** Added animation for toolbar wrapper margins
** Added resize handler to update left and right positions on the toolbar when it's floated
 * Changed from using generic "float" and "bottom" class names which are likely going to get re-used elsewhere and cause issues

Change-Id: Ic596b2b8aceb8a2d81539e197ef4d6e17326a87a
2012-08-20 15:43:47 -07:00
Catrope 7c39f65469 Merge "Added saving "spinner" icon to save dialog" 2012-08-17 23:15:48 +00:00
Trevor Parscal 6a3bb91252 Added saving "spinner" icon to save dialog
Change-Id: Ie6ef43378b1a0a18c504efe7bb850d7c9de1bbeb
2012-08-17 16:10:14 -07:00
Trevor Parscal b02055be0f Fixed the text in the edit summary box being the wrong font and size
In Firefox at least...

Change-Id: I236902cde51ac6e25e4edc738fa4a80977d39d29
2012-08-17 15:43:49 -07:00
Catrope 1a4dd7a3db Merge "Design changes for save dialog" 2012-08-17 20:58:24 +00:00
Trevor Parscal f48332d176 Design changes for save dialog
* Summary label is now placeholder text
* Edit summary and options are visually connected
* Added summary length count-down label
* Removed check-mark icons from toolbar and dialog save buttons
* Made toolbar and dialog save buttons the same size
* Reduced line-height and margins of license information
* Changed from X icon for close (which might be confused with cancel) to ^ icon for collapse

Change-Id: Ib1711f49af8929be12796aecdea49467b726856e
2012-08-17 13:48:16 -07:00
Catrope 8c91e3526d Merge "Utilizing RL skinStyles for skin-specific ve.init styles" 2012-08-17 20:24:12 +00:00
Catrope 75c60b3c8e Merge "Fixed scroll and selection issues" 2012-08-17 20:19:32 +00:00
Trevor Parscal a1ba65cc31 Utilizing RL skinStyles for skin-specific ve.init styles
Change-Id: I4b2ed55289be5dceee3e3fbdf305b4ff81d80189
2012-08-17 13:16:25 -07:00
Trevor Parscal dfdc69f994 Fixed scroll and selection issues
* When you visit the page with url# (empty target) it scrolls down - which made setting the URL of the namespace tab to # really bad, plus it was useless since we already handle that click using JS
* Found that this.$toolbarWrapper wasn't pointing to the right place because of a missing .end() call at the end of a chain of jQuery madness

Change-Id: I7dc6953e39d4081f1b91a351bb830e4c18f7b988
2012-08-17 13:11:55 -07:00
Trevor Parscal 8169dbc085 Added notification on save
Change-Id: I362275eb38655401bc48b3209189776e9e37619a
2012-08-17 12:41:33 -07:00
Trevor Parscal d147504f49 Added support for apex skin
* Made vector specific styles only active in the vector skin
* Added apex specific styles
* Removed override of text size for document node
* Added stylesheet for stand-alone to specify text size for document node

Change-Id: I8a57918912499f9453a5692ff45a04a16ed34cde
2012-08-15 16:35:52 -07:00
Timo Tijhof f06952f2f3 Refactor ve.js utilities and improve documentation
Refactor:
* ve.indexOf
  Renamed from ve.inArray.
  This was named after the jQuery method which in turn has a longer
  story about why it is so unfortunately named. It doesn't return
  a boolean, but an index. Hence the native method being called
  indexOf as well.

* ve.bind
  Renamed from ve.proxy.
  I considered making it use Function.prototype.bind if available.
  As it performs better than $.proxy (which doesn't use to the native
  bind if available). However since bind needs to be bound itself in
  order to use it detached, it turns out with the "call()" and
  "bind()"  it is slower than the $.proxy shim:
  http://jsperf.com/function-bind-shim-perf
  It would've been like this:
  ve.bind = Function.prototype.bind ?
      Function.prototype.call.bind( Function.prototype.bind ) :
      $.proxy;
  But instead sticking to ve.bind = $.proxy;

* ve.extendObject
  Documented the parts of jQuery.extend that we use. This makes it
  easier to replace in the future.

Documentation:
* Added function documentation blocks.
* Added annotations to  functions that we will be able to remove
  in the future in favour of the native methods.
  With "@until + when/how".
  In this case "ES5". Meaning, whenever we drop support for browsers
  that don't support ES5. Although in the developer community ES5 is
  still fairly fresh, browsers have been aware for it long enough
  that thee moment we're able to drop it may be sooner than we think.
  The only blocker so far is IE8. The rest of the browsers have had
  it long enough that the traffic we need to support of non-IE
  supports it.

Misc.:
* Removed 'node: true' from .jshintrc since Parsoid is no longer in
  this repo and thus no more nodejs files.
 - This unraveled two lint errors: Usage of 'module' and 'console'.
   (both were considered 'safe globals' due to nodejs, but not in
   browser code).

* Replaced usage (before renaming):
 - $.inArray -> ve.inArray
 - Function.prototype.bind -> ve.proxy
 - Array.isArray -> ve.isArray
 - [].indexOf -> ve.inArray
 - $.fn.bind/live/delegate/unbind/die/delegate -> $.fn.on/off

Change-Id: Idcf1fa6a685b6ed3d7c99ffe17bd57a7bc586a2c
2012-08-12 20:32:45 +02:00
Timo Tijhof 23c5b0d02c 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-10 02:50:30 +02:00
Trevor Parscal d8ee3c2c29 After much research on error objects, native = good, custom = bad
Stack traces, line numbers, etc. All the approaches I've seen are bad hacks. This is the best way to go.

Change-Id: Ib12e9d2ecfe610bcc89d046005e35cc13efa3d99
2012-08-08 10:48:53 -07:00
Krinkle 08b349d7dd Merge "Throw ve.Error instead of string literals" 2012-08-08 04:20:47 +00:00
Trevor Parscal b4de3ead08 Throw ve.Error instead of string literals
Throwing strings is bad because it doesn't include a lot of important
information that an error object does, such as a stack trace or where
the error was actually thrown from.

ve.Error inherits directly from Error. In the future we may create
more specific subclasses and/or do custom stuff.

Some interesting reading on the subject:
* http://www.devthought.com/2011/12/22/a-string-is-not-an-error/

Change-Id: Ib7c568a1dcb98abac44c6c146e84dde5315b2826
2012-08-08 06:19:00 +02:00
Trevor Parscal 1c4f66c49b Merge "(bug 38125) ve.init.mw.ViewPageTarget: Preserve original query" 2012-08-07 16:48:55 +00:00
Timo Tijhof 6b048f4f55 (bug 38125) ve.init.mw.ViewPageTarget: Preserve original query
* Use 'href' of #ca-edit instead of constructing it manually.
  MediaWiki's output of #ca-edit already takes care of all needed
  queries, including "oldid" (bug 38125).

* Misc clean up:
 - Use .get() instead of accessing the array directly.

* Clean up setupSkinTabs and add more inline documentation.

Change-Id: I7d702a3eb1f9ce23a5e3c9e846b00da5cead386e
2012-08-07 11:36:27 +02:00
Timo Tijhof 9b49a7ce81 Clean up: Single quotes
* There were only 3 files with single quotes, fixed them all.

* Added option to .jshintrc (be sure to use the latest version of
  node-jshint since this is a fairly new addition to the library).

Change-Id: I8bf8895ce56bf86e3bed244279a9d32269e44763
2012-08-07 07:02:01 +02:00
Trevor Parscal 255ce870e2 Puttin' em white-spacers where they aught'a be
function() -> function ()
){ -> ) {

Change-Id: I20a85fcf79d7aec64f7f2559e84c0279550d4eea
2012-08-06 18:52:19 -07:00
Timo Tijhof c889292adf Kranitor #004: MediaWiki-specific clean up and minor fixes
* Default value of wgVisualEditorParsoidURL is broken.
  Slash is needed, else Api will request to
  http://hostnamePageName
  Roan says double slashes are okay, and look cleaner than string
  search checks etc.

* Use .clone() for mw.Uri instead of converting to string
  and letting mw.Uri parse it, again. Clone creates a basic
  instance and copies over properties internally (deep copy,
  no references).

* No need for hasOwnProperty (and its potential issues)

* Code clean up
 - Whitespace consistency
 - Variable hosting
 - Remove redundant `return false;` statements in event handlers
   e.preventDefault() is a jQuery.Event method that takes care
   of cross-browser issues.
 - Same for e.keyCode||e.which thing, this is already normalized
   by jQuery.Event
 - Add missing parameter to setTimeout
 - Consistent order in success/error handlers in $.ajax options

Change-Id: I5bc24e0cbdf01b3704d4ccb0b45b3052e3b58694
2012-08-03 23:55:52 -07:00