[MediaWiki-commits] [Gerrit] oojs/ui[master]: Add PHP version of ProgressBarWidget

2016-08-16 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add PHP version of ProgressBarWidget
..


Add PHP version of ProgressBarWidget

Change-Id: Ib434a5c09699c9196be3d477578099267dceec90
---
M build/modules.yaml
M demos/pages/widgets.php
A php/widgets/ProgressBarWidget.php
M src/styles/core.less
M src/styles/widgets.less
5 files changed, 90 insertions(+), 2 deletions(-)

Approvals:
  Bartosz DziewoƄski: Looks good to me, but someone else must approve
  Jforrester: Looks good to me, approved
  Esanders: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/build/modules.yaml b/build/modules.yaml
index 41bf19e..b6fbb54 100644
--- a/build/modules.yaml
+++ b/build/modules.yaml
@@ -64,6 +64,8 @@
# ComboBoxInputWidget
"src/mixins/FloatableElement.js",
"src/widgets/FloatingMenuSelectWidget.js",
+   # ProgressBarWidget
+   "src/widgets/ProgressBarWidget.js",
 
# The basic widgets and layouts, continued.
"src/widgets/InputWidget.js",
@@ -115,7 +117,6 @@
"src/widgets/CapsuleMultiselectWidget.js",
 
"src/widgets/SelectFileWidget.js",
-   "src/widgets/ProgressBarWidget.js",
"src/widgets/SearchWidget.js",
"src/widgets/NumberInputWidget.js"
],
diff --git a/demos/pages/widgets.php b/demos/pages/widgets.php
index 1950cca..cc23ca1 100644
--- a/demos/pages/widgets.php
+++ b/demos/pages/widgets.php
@@ -981,6 +981,24 @@
'align' => 'top'
]
),
+   new OOUI\FieldLayout(
+   new OOUI\ProgressBarWidget( [
+   'progress' => 33
+   ] ),
+   [
+   'label' => 'Progress bar',
+   'align' => 'top'
+   ]
+   ),
+   new OOUI\FieldLayout(
+   new OOUI\ProgressBarWidget( [
+   'progress' => false
+   ] ),
+   [
+   'label' => 'Progress bar (indeterminate)',
+   'align' => 'top'
+   ]
+   ),
]
 ] ) );
 
diff --git a/php/widgets/ProgressBarWidget.php 
b/php/widgets/ProgressBarWidget.php
new file mode 100644
index 000..c31ce45
--- /dev/null
+++ b/php/widgets/ProgressBarWidget.php
@@ -0,0 +1,69 @@
+bar = new Tag( 'div' );
+   $this->bar->addClasses( [ 'oo-ui-progressBarWidget-bar' ] );
+
+   $this->setProgress( array_key_exists( 'progress', $config ) ? 
$config['progress'] : false );
+
+   $this
+   ->setAttributes( [
+   'role' => 'progressbar',
+   'aria-valuemin' => 0,
+   'aria-valuemax' => 100,
+   ] )
+   ->addClasses( [ 'oo-ui-progressBarWidget' ] )
+   ->appendContent( $this->bar );
+   }
+
+   /**
+* @return bool|int
+*/
+   public function getProgress() {
+   return $this->progress;
+   }
+
+   /**
+* @param bool|int $progress
+*/
+   public function setProgress( $progress ) {
+   $this->progress = $progress;
+
+   if ( $progress !== false ) {
+   $this->bar->setAttributes( [ 'style' => 'width: ' . 
$this->progress . '%;' ] );
+   $this->setAttributes( [ 'aria-valuenow' => 
$this->progress ] );
+   } else {
+   $this->removeAttributes( [ 'aria-valuenow' ] );
+   }
+   $this->toggleClasses( [ 'oo-ui-progressBarWidget-indeterminate' 
], $progress === false );
+   }
+
+   public function getConfig( &$config ) {
+   if ( $this->progress !== null ) {
+   $config['progress'] = $this->progress;
+   }
+   return parent::getConfig( $config );
+   }
+}
diff --git a/src/styles/core.less b/src/styles/core.less
index d17c3bd..21f86dd 100644
--- a/src/styles/core.less
+++ b/src/styles/core.less
@@ -57,3 +57,4 @@
 @import 'widgets/MultioptionWidget.less';
 @import 'widgets/CheckboxMultiselectWidget.less';
 @import 'widgets/CheckboxMultioptionWidget.less';
+@import 'widgets/ProgressBarWidget.less';
diff --git a/src/styles/widgets.less b/src/styles/widgets.less
index c640331..9275bd6 100644
--- a/src/styles/widgets.less
+++ b/src/styles/widgets.less
@@ -20,7 +20,6 @@
 @import 'widgets/ToggleWidget.less';
 @import 

[MediaWiki-commits] [Gerrit] oojs/ui[master]: Add PHP version of ProgressBarWidget

2016-08-11 Thread WMDE-leszek (Code Review)
WMDE-leszek has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/304244

Change subject: Add PHP version of ProgressBarWidget
..

Add PHP version of ProgressBarWidget

Change-Id: Ib434a5c09699c9196be3d477578099267dceec90
---
A php/widgets/ProgressBarWidget.php
1 file changed, 64 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/44/304244/1

diff --git a/php/widgets/ProgressBarWidget.php 
b/php/widgets/ProgressBarWidget.php
new file mode 100644
index 000..4a7e4a5
--- /dev/null
+++ b/php/widgets/ProgressBarWidget.php
@@ -0,0 +1,64 @@
+bar = new Tag( 'div' );
+   $this->bar->addClasses( [ 'oo-ui-progressBarWidget-bar' ] );
+
+   $this->setProgress( array_key_exists( 'progress', $config ) ? 
$config['progress'] : false );
+
+   $this
+   ->setAttributes( [
+   'role' => 'progressbar',
+   'aria-valuemin' => 0,
+   'aria-valuemax' => 100,
+   ] )
+   ->addClasses( [ 'oo-ui-progressBarWidget' ] )
+   ->appendContent( $this->bar );
+   }
+
+   /**
+* @return bool|int
+*/
+   public function getProgress() {
+   return $this->progress;
+   }
+
+   /**
+* @param bool|int $progress
+*/
+   public function setProgress( $progress ) {
+   $this->progress = $progress;
+
+   if ( $progress !== false ) {
+   $this->setAttributes( [
+   'aria-valuenow' => $this->progress,
+   'style' => 'width: ' . $this->progress . '%;'
+   ] );
+   } else {
+   $this->removeAttributes( [ 'aria-valuenow' ] );
+   }
+   $this->toggleClasses( [ 'oo-ui-progressBarWidget-indeterminate' 
], !$progress );
+   }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/304244
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib434a5c09699c9196be3d477578099267dceec90
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits