Commit graph

93 commits

Author SHA1 Message Date
Ricordisamoa
fc5fd5c37a Typo fixes and non-code tweaks
Skipped replacements:
* prefered → preferred
* prolly → probably

Skipped files:
* resources/lib/jquery.ui/jquery.ui.mouse.js
* resources/lib/jquery/jquery.form.js

Change-Id: Ib7923f362ddfca1b892bf5d601785d6b5aa5d44c
2014-12-12 18:31:15 +00:00
jdlrobson
aa15d5287d Add blanket support for mediawiki ui via globals
This provides better mobile experiences on various pages
and a more consistent UI across both mobile and desktop.

It does this in two ways.

1) Forces HTMLForms to not use table based layouts so as
not to interfere with responsive nature of mediawiki ui elements

2) Applies MediaWiki.UI classes to most pages
If a page is created via Xml or Html classes it will use mediawiki ui
Where possible I've added classes unconditionally, but for cases of buttons
this is behind the $wgUseMediaWikiUIEverywhere global since button styling is
enabled on pages by default and for checkboxes since it is changes HTML markup.

3) Adds all MediaWiki.UI styles to pages which can use it
When enabled:
* Apply these styles to all pages which use HTMLForms
* Apply to EditPage
* Apply to anything that uses certain elements outputted by the
Xml or HTML helper classes
* Apply to History page
* Apply to protection page
* Apply to move page
* Apply to deletion page

Currently kept behind a global to allow us time to finetune
existing elements. After further testing we will look to kill the
globals and make mediawiki.ui the default

See: I430c0fbb79d2a33bb828b2427bda0ee01115d73f
Change-Id: I47db5eab4569514d039261d11b6dedb0eeae17b5
2014-08-15 14:48:00 -07:00
Tyler Anthony Romeo
5edf25e2e6 Added Html::radio, Html::check, and Html::label.
Migrated some convenience functions from the Xml
class to Html so they can be used. Only added
functions that acted as more than just a wrapper
for another function.

Change-Id: I4cc5876d4be6e04ec554444242cc049a3cff0f58
2014-07-29 19:41:20 +00:00
Thiemo Mättig
4aeb08ef18 Html: Throw exception if array is used for an attribute not supporting it
Previously the behavior was more or less undefined for most attributes
except for the ones in $spaceSeparatedListAttributes (currently 'class',
'accesskey' and 'rel'). If an other attribute is set to an array (no
matter what it contains) the method produces broken HTML like
'key=' and only triggers a warning if error_reporting is enabled. If
error_reporting is not enabled a developer may overlook this.

To clarify: The method always *ALLOWS* array values. This is *NOT*
about unexpected types in the call signature but unexpected
combinations of nested values. These combinations are already
checked in the method but the check was incomplete.

I considered several solutions:
* Simply use the first array element. But we can't know if the first
  element is what the caller expected.
* Silently drop all arrays if the attribute doesn't allow lists. This
  is close to the current behavior of always returning 'key=' but is a
  breaking change for boolean attributes like 'checked' and 'selected'.
  Browsers accept the current 'checked=' as true while omiting the
  attribute means false.

Choosing to always throw an exception. As above, this is a
breaking change in some cases.

Change-Id: Id5fcbdef2696d0a81a91d54338939ee678475ca3
2014-07-10 16:46:35 +00:00
Siebrand Mazeland
e1d58d9071 Pass phpcs-strict on some test files (8/11)
Change-Id: I138c1f9bf2c3c7e9218d5fa29365e78b309fb459
2014-04-24 13:49:48 -07:00
Siebrand Mazeland
ce42915e0d Pass phpcs-strict on some test files (2/x)
Change-Id: Ia39fd107a554206927652b6e168faa0da501b362
2014-04-24 17:05:34 +02:00
addshore
9c540db2df @covers tags for inclues/*Test
Change-Id: Id28acdd8fe0028bf1e46344cfed131076c8f4c95
2013-10-24 11:54:02 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Daniel Friesen
97caae596d Drop support for XHTML 1.0
* $wgHtml5 = false; is now ignored completely.
* $wgDocType and $wgDTD have been removed.
* $wgXhtmlDefaultNamespace is now ignored.
* XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules).
* For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set
  in Setup.php but depending on them is deprecated.

Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0
2013-05-15 23:09:25 -07:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
jenkins-bot
b3d9004342 Merge "Tests: Use more setMwGlobals" 2013-03-22 19:15:03 +00:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
umherirrender
ff3485ec99 Tests: Use more setMwGlobals
Change some tests to use setMwGlobals to have restoring of globals after
the test.
This also removes some save/restore code, which is not needed, due to
the automatically restoring on tearDown with setMwGlobals.

Change-Id: I8d2ac9f6cc14f0bd4ee8eb851c09f2e71babc6e0
2013-03-21 20:35:44 +01:00
Yuri Astrakhan
27d83878c0 Lots of spelling mistakes and phpdoc attributes
@throw->@throws
@returns->@return
@seealso->@see
@cover->@covers
etc

Change-Id: I9ae6bc3034e9790e2d66cd96473b923fe9ee7953
2013-03-10 23:16:28 -04:00
Siebrand Mazeland
ac63001d8e Update formatting
1 of n.

Change-Id: I852729f08bbb0c5e39c2db44362ccdc7f59dcc08
2013-02-14 12:22:13 +01:00
Alex Monk
843ac173b2 Attribtue -> Attribute
Change-Id: I9eca55a96be3ae1cdedf5045db40510b918f3549
2013-02-09 19:10:43 +00:00
Tim Landscheidt
6dc4039270 (bug 40585) Don't drop 'step="any"' in HTML input fields.
The default value for "step" is "1" which effectively bans any decimal
number from being entered into an 'type="number"' field and makes
HTMLFloatField unusable.

Change-Id: I103fd4047814a7fb0dfdc174f36badd5b660b7a4
2012-12-07 19:26:29 +00:00
Stephan Gambke
514bdd184d Set default type attribute for button html elements
According to standard the default type for <button> elements is "submit". Depending on compatibility mode IE might use "button", instead.
To work around the IE bug this patch forces the standard "submit", if nothing is specified explicitly.

See remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx :
-----
The default value of the type attribute depends on the current document compatibility mode. The default value is submit. In other compatibility modes the default value is button.
...
Windows Internet Explorer 8 and later. The default value of the type attribute depends on the current document compatibility mode. In IE8 Standards mode, the default value is submit.
In other compatibility modes and earlier versions of Windows Internet Explorer, the default value is button.
-----

Change-Id: I3b97a8cac74bbfca63699dfcbf1cc5e9a2cef193
2012-10-30 21:45:17 +01:00
Timo Tijhof
d1c8bf85f8 Fix HtmlTest, XmlTest; Add setMwGlobals method to base TestCase.
The HTML and XML test now set the globals they depend on
(instead of relying on the default settings).

Tests for the "other" scenarios still exist, globals are
overridden inline. They are automatically restored after each
test## function by PHPUnit from MediaWikiTestCase::tearDown.

Also fixed 2 other problems with the test suite:

* HtmlTest::testDropDefaults forgot to pass
  $message to the assertion from the provider ($case[3]).

* The data provider for HtmlTest::testDropDefaults was calling
  Html::element directly (instead of calling it within the test)
  which is problematic because data providers are expected to be
  static. PHPUnit calls them outside the setUp/tearDown flow.
  (also fixed the function to be public static, as PHPUnit
  expects).

That last one was crucial to make the test still pass correctly.

Updated the expected strings to what they are with these
fixed non-leakage settings.

Took wgHtml5 without xmlform as default. And added tests
for variations where it made sense.

Change-Id: Iccf6ea81f4bc2639273ab2ad101c58788ee49d45
2012-10-09 00:26:52 +02:00
jeroendedauw
37d9c1a6dc Fix behaviour of namespaceSelector to match the documentation
Change-Id: I3d1bb232905095ae2d5177adc225025178d5f5a3
2012-10-05 16:19:03 +02:00
Platonides
b8f1c3c69c Change case to use the canonical names.
Change-Id: Ib2640e608ac4d33871446b15fca3780eb7715f1d
2012-09-18 22:30:38 +02:00
Antoine Musso
1a7da4f625 test: full coverage of Html::dropDefaults()
This closely match Html::dropDefaults() logic and hopefully test out
all default dropping.

Introduce a test case that match a failure in f34547ab where attribute
default values passed in an array are not cleaned up.

Change-Id: If8d16b066015ed1bcaf38408511ac3713eaa6540
2012-09-14 21:26:56 -07:00
Daniel Friesen
81f1cace4c Fix broken value="" stripping for HTML5
The default value for value="" on <input> elements is not always an
empty string.

In particular the default value for type="radio" is "on" and by
stripping value="" out of the attributes a "" becomes "on" and our
cleanup code ends up breaking forms.

Change-Id: Ibe5a3be3f45a2f93ef95dbe42729b8f8c94a41cb
2012-09-14 21:26:56 -07:00
Antoine Musso
a45e20ff11 HTML5 new types for input element
HTML5 introduced new types for the input element. For some reasons we
never added them to Html::openElement which would thus strip them even
in HTML5 mode.

The issue is:
 $wgHtml5 = true;
 Html::element( 'input', array( 'type' => 'color' );
 # -> "<input />"

With this patch, we returns: <input type="color" />

Change-Id: I7de373635d0eb47f788d1d664c3a913c8801efd6
2012-09-14 21:26:55 -07:00
Antoine Musso
9fd8cf88f0 tests: Wraper to set/disable $wgHTML5 in HtmlTest
Would let us easily set $wgHtml5 in our tests.

Change-Id: Iacf38c2961cbbb9cc58cd45bba34f10ee5688605
2012-08-30 12:20:31 +02:00
Krinkle
1e5689852b [Html::namespaceSelector] Remove default id/name attributes
* Remove default id/name attributes
* Remove now redundant tests introduced in r110274
* Add tests to make sure label has no 'for' attribute when label isn't null but name/id are unset
* Update tests to not include id="" and name="" when calling with no arguments
* Updating calls to add name/id if needed, and while at it remove useless 'null' params


* Context:
-- Introduced in r109990, r111376, r111315
-- No callers exist that assume these defaults. Forcing an ID that should be unique is annoying and redundant. The name used in the query when submitting a form should be mentioned in the same file where it is used from the submission, never assume what name="" is from unrelated code
-- Same for ID, this is often used in CSS or JavaScript, shouldn't be assumed. (It should be simple to but two simple namespace selectors on a page without getting DOM conflicts)
2012-03-07 19:14:20 +00:00
Sam Reed
8e78fbe32b Cleanup a few unused globals 2012-02-16 02:35:48 +00:00
Antoine Musso
51dacc9fbf split ns selector tests for filter / disable options
ping r111376
2012-02-14 09:59:59 +00:00
Krinkle
78c157faf9 [Html] Follow-up r109990: Add support for excluding and disabling options 2012-02-13 15:08:26 +00:00
Krinkle
8a5c2c6026 [Html] Follow-up r109990: Add category to example namespaces
- Category is a special case since it is not moveable  by default, useful to keep in the test
2012-02-13 14:53:40 +00:00
Aaron Schulz
1bebf0c7ea Fixed windows-related test failures (that string format doesn't work with \r\n line endings as the \r chars are left in the PHP string). 2012-02-02 18:42:02 +00:00
Antoine Musso
9755d2e5aa test Html::namespaceSelector() id & name attributes generation
Method was introduced by r109990.
2012-01-30 10:39:51 +00:00
Chad Horohoe
e8da212569 Fixup r109698, add setter for $namespaceNames and use proper accessors in the tests.
Since we're here: nothing uses $namespaceNames, $mNamespaceIds or $namespaceAliases
outside of this class (core or extensions) so lets make it protected.
2012-01-27 13:00:26 +00:00
Krinkle
3065ece7a2 Fix broken unit test
* r109993 broke the test by overwriting namespaces it tried to preserve
* tearDown should always have the opposite order of the overrides in setUp
* Adding wgLanguageCode while at it, no reason not to, just in case.

-- Follows-up r109993
2012-01-25 03:45:01 +00:00
Krinkle
3c9d05055b [Html] Unit test + bugfix Html::namespaceSelector
* Previously it was passing $selectAttribs['name'] to Xml::label, which uses its value for the <label for=""> attribute. This works as long as $selectAttribs['id'] and $selectAttribs['name'] match, but when they don't it fails. <label for=""> always corresponds with <{input,text area,select} id=""> in browsers, never with "name".
* Make name/id match eachother by default to avoid backwards compatibility breakages (they used to match in the Xml class method as well)
* Add HtmlTest.php entries similar to the ones in XmlTest
* Fix E_NOTICE about $params['selected'], default to ''

-- Follows-up r109974, r109698, r109990
-- Bug originally introduced in r41425
-- XmlTest.php still runs successfully
-- HtmlTest.php runs successfully
2012-01-25 03:25:54 +00:00
Platonides
7d626b347b Use canonical case 2011-10-27 15:54:49 +00:00
Antoine Musso
9a2dc2d05a Tests for r96188 features
That revision let us pass an array of values to 'class', 'rel'
and 'accesskey'. The revision requested some tests :)
2011-10-24 17:45:45 +00:00
Krinkle
73db9698a3 Html.php: The "future"[1] is here. Add features for space-separated value attributes of html elements.
* Has been suggested since August 2009 in r54767 (doc-comment from rawElement/element function)
* Implements normalization for these attributes (removal of duplicates and redundant space)
* Adds support for arrays (instead of just string) for these attributes. 
* String are still supported, and are converted to arrays to get the same normalization.
* Wrote unit tests (which pass locally: $ php phpunit.php includes/HtmlTest.php)
* Not trigger for the media-attribute. Reason: Although some people think it's space-separated, it's actually comma-separated. Treating them as space separated might even destroy the value. [2] [3]. Neither the html4 or html5 spec documents media-attribute as space-separated, and as of HTML5/CSS3 the media attribute may contain "media queries".


[1] "In the future, other HTML-specific features might be added, like allowing arrays for the values of attributes like class= and media=" in r54767 by Simetrical.
[2] http://www.w3.org/TR/1999/REC-html401-19991224/types.html#h-6.13
[3] http://dev.w3.org/csswg/css3-mediaqueries/#background

Implementation note: I choose to have a single list of attributes that trigger this feature. Some of these attributes only support multiple values and/or are documented as space-separated as of html5 (such as accesskey), but since those attributes in general have existed in html4 as well (just different w3c spec), they are not stripped if wgHtml5 is not true. So if this feature would (eg. for accesskey) would only be done if wgHtml5=true, then people could get output like <a accesskey=Array /> depending on a configuration variable, which will get messy and make developers' life hard.
2011-09-03 03:55:23 +00:00
Krinkle
16caaa881a Whitespacing in HtmlTest.php 2011-09-03 01:42:43 +00:00
Alexandre Emsenhuber
1455fe4e21 $wgLanguageCode applies to $wgContLang, not $wgLang. This was breaking the test suite by dying with a "nooo!" in when reaching LanguageConverterTest. 2011-08-05 15:10:08 +00:00
Platonides
a326e60e48 Follow-up r92588. Make it work regardless of $wgHtml5 2011-07-19 22:10:05 +00:00
Platonides
a2251d34f9 Follow up r91419. A boolean attribute can be both the empty string and its name [http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#boolean-attributes]
We use the later since that's what xhtml1 required [http://www.w3.org/TR/xhtml1/#h-4.5].
2011-07-19 21:38:28 +00:00
Antoine Musso
2801589462 tests for Html::testExpandAttributes()
FIXME: seems a code duplication of Xml::expandAttributes()

follow up r81571 (skip attributes with null value)
2011-07-04 19:51:35 +00:00