mediawiki.page.gallery.resize: Remove weird mw.hook call
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 11 Jun 2014 15:31:34 +0000 (17:31 +0200)
committerKrinkle <krinklemail@gmail.com>
Tue, 17 Jun 2014 20:07:45 +0000 (20:07 +0000)
commit88d8dd2bf78af39bcd8c1436bc84426cfc1c2dd4
tree63f69441c3f6a2c11b138250b7891efc1fe19c8f
parent0bb3d2a499a37c348eab1df11a6229a2aa19ecf8
mediawiki.page.gallery.resize: Remove weird mw.hook call

This mw.hook has no place here, there's various things wrong
with it:

* Naming.
  We don't prefix event names with "mediawiki" nor the module
  name. This pattern does not exist and this being here makes
  understanding mw.hook by example harder and only adds to the
  confusion.

* Synchronous behaviour.
  Aside from the naming (details..), mw.hook simply doesn't do
  what the code is asking for here and exhibits behaviour the
  gallery relies on to to happen.
  By design, mw.hook is asynchronous and memorises the last call
  for new event handlers to allow modifying the last version of a
  particular interface. It's like document-ready, if you bind
  after the document is already ready, it's just to declare it
  needs the document to be ready. It's not for exactly when that
  happened, just that it happens after.

* Plurality.
  To make matters worse, aside from naming and asynchonisity,
  the gallery is also calling it in a loop, which is another
  violation of mw.hook's design. When something emits mw.hook,
  it means any previous state is no longer active (e.g. the user
  switched modes, or navigated to another page with AJAX, or
  closed the relevant dialog, or opened another one etc.).

Also removed some mw.log calls that seems to be left from
development. If these are important during regular usage, it should
probably throw an exception or use mw.log.warn instead.

Change-Id: Iefdfab26fcd24e3f9f8f3f2fc7f1fdba9f838a25
resources/src/mediawiki.page/mediawiki.page.gallery.js