Split off styles for PHP DateInputWidget to separate module
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 7 Jun 2017 19:49:42 +0000 (21:49 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 7 Jun 2017 19:49:42 +0000 (21:49 +0200)
This lets us load them with addModuleStyles() (without generating a warning).

Bug: T167343
Change-Id: I88f0716c6a5ac702cc07e8015cfe25d81538a536

includes/specials/SpecialContributions.php
resources/Resources.php
resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.less
resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.styles.less [new file with mode: 0644]

index 4da1c85..e2fa8a3 100644 (file)
@@ -40,7 +40,7 @@ class SpecialContributions extends IncludableSpecialPage {
                $out->addModuleStyles( [
                        'mediawiki.special',
                        'mediawiki.special.changeslist',
-                       'mediawiki.widgets.DateInputWidget',
+                       'mediawiki.widgets.DateInputWidget.styles',
                ] );
                $out->addModules( 'mediawiki.special.contributions' );
                $this->addHelpLink( 'Help:User contributions' );
index 46aafd5..7c0e4af 100644 (file)
@@ -2338,6 +2338,15 @@ return [
                        'oojs-ui-widgets',
                        'oojs-ui.styles.icons-movement',
                        'moment',
+                       'mediawiki.widgets.DateInputWidget.styles',
+               ],
+               'targets' => [ 'desktop', 'mobile' ],
+       ],
+       'mediawiki.widgets.DateInputWidget.styles' => [
+               'skinStyles' => [
+                       'default' => [
+                               'resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.styles.less',
+                       ],
                ],
                'targets' => [ 'desktop', 'mobile' ],
        ],
index 3ecdea8..47f8045 100644 (file)
@@ -1,16 +1,10 @@
 /*!
- * MediaWiki Widgets – DateInputWidget styles.
+ * MediaWiki Widgets – JS DateInputWidget styles.
  *
  * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
  * @license The MIT License (MIT); see LICENSE.txt
  */
 
-.oo-ui-box-sizing( @type: border-box ) {
-       -webkit-box-sizing: @type;
-       -moz-box-sizing: @type;
-       box-sizing: @type;
-}
-
 .oo-ui-unselectable() {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
 }
 
-.oo-ui-inline-spacing( @spacing, @cancelled-spacing: 0 ) {
-       margin-right: @spacing;
-
-       &:last-child {
-               margin-right: @cancelled-spacing;
-       }
-}
-
 @indicator-size: unit( 12 / 16 / 0.8, em );
 
 .mw-widget-dateInputWidget {
-       &.oo-ui-textInputWidget {
-               display: inline-block;
-               position: relative;
-               width: 21em;
-               margin-top: 0.25em;
-               .oo-ui-inline-spacing( 0.5em );
-               margin-bottom: 0.25em;
-               margin-left: 0;
-       }
-
-       &-handle,
-       &.oo-ui-textInputWidget input {
-               background-color: #fff;
-               display: inline-block;
-               position: relative;
-               .oo-ui-box-sizing( border-box );
-               width: 100%;
-               cursor: pointer;
-               padding: 0.5em 1em;
-               border: 1px solid #a2a9b1;
-               border-radius: 2px;
-               outline: 0;
-               line-height: 1.275;
-               /**
-                * Ensures non-infused and infused widget have the same height.
-                * Equal to line height + top padding + bottom padding
-                */
-               height: 2.275em;
-       }
-
        &-handle {
                .oo-ui-unselectable();
 
diff --git a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.styles.less b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.styles.less
new file mode 100644 (file)
index 0000000..18cf723
--- /dev/null
@@ -0,0 +1,53 @@
+/*!
+ * MediaWiki Widgets – PHP DateInputWidget styles.
+ *
+ * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+.oo-ui-box-sizing( @type: border-box ) {
+       -webkit-box-sizing: @type;
+       -moz-box-sizing: @type;
+       box-sizing: @type;
+}
+
+.oo-ui-inline-spacing( @spacing, @cancelled-spacing: 0 ) {
+       margin-right: @spacing;
+
+       &:last-child {
+               margin-right: @cancelled-spacing;
+       }
+}
+
+.mw-widget-dateInputWidget {
+       &.oo-ui-textInputWidget {
+               display: inline-block;
+               position: relative;
+               width: 21em;
+               margin-top: 0.25em;
+               .oo-ui-inline-spacing( 0.5em );
+               margin-bottom: 0.25em;
+               margin-left: 0;
+       }
+
+       // Note that this block applies to both the PHP widget and the JS widget
+       &-handle,
+       &.oo-ui-textInputWidget input {
+               background-color: #fff;
+               display: inline-block;
+               position: relative;
+               .oo-ui-box-sizing( border-box );
+               width: 100%;
+               cursor: pointer;
+               padding: 0.5em 1em;
+               border: 1px solid #a2a9b1;
+               border-radius: 2px;
+               outline: 0;
+               line-height: 1.275;
+               /**
+                * Ensures non-infused and infused widget have the same height.
+                * Equal to line height + top padding + bottom padding
+                */
+               height: 2.275em;
+       }
+}