Mooeypoo has uploaded a new change for review.

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

Change subject: [wip^2] Transform the new topic button to ooui widgets
......................................................................

[wip^2] Transform the new topic button to ooui widgets

* Don't review me yet, I'm ugly *

Change-Id: I73295e1664e0a226100cd65aa570aeec02e5373c
---
M Resources.php
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
M handlebars/flow_newtopic_form.partial.handlebars
M includes/TemplateHelper.php
M includes/View.php
M modules/engine/components/common/flow-component-events.js
A modules/engine/components/common/flow-component-ooui.js
M modules/engine/components/flow-component.js
M modules/styles/board/form-actions.less
10 files changed, 98 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/52/208052/1

diff --git a/Resources.php b/Resources.php
index e103c57..e89de20 100644
--- a/Resources.php
+++ b/Resources.php
@@ -328,6 +328,7 @@
                        // FlowComponent must come before actual components
                        'engine/components/common/flow-component-engines.js',
                        'engine/components/common/flow-component-events.js',
+                       'engine/components/common/flow-component-ooui.js',
 
                        // Component: BoardAndHistoryBase
                        // Base class for both FlowBoardComponent and 
FlowBoardHistoryComponent
@@ -339,6 +340,7 @@
                ),
                'dependencies' => array(
                        'oojs',
+                       'oojs-ui',
                        'ext.flow.templating', // prototype-based for 
progressiveEnhancement
                        'ext.flow.jquery.findWithParent',
                        'ext.flow.vendor.storer',
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php 
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 69b0d2c..0a082f8 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -21,6 +21,7 @@
             'concat' => 'Flow\TemplateHelper::concat',
             'linkWithReturnTo' => 'Flow\TemplateHelper::linkWithReturnTo',
             'escapeContent' => 'Flow\TemplateHelper::escapeContent',
+            'oouify' => 'Flow\TemplateHelper::oouify',
 ),
         'blockhelpers' => array(),
         'hbhelpers' => array(            'eachPost' => 
'Flow\TemplateHelper::eachPost',
@@ -130,10 +131,11 @@
 
                <div class="flow-form-actions flow-form-collapsible"
                        '.((LCRun3::ifvar($cx, ((isset($in['isOnFlowBoard']) && 
is_array($in)) ? $in['isOnFlowBoard'] : null))) ? 'style="display:none;"' : 
'').'>
-                       <button data-role="submit" 
data-flow-api-handler="newTopic"
+                       '.LCRun3::ch($cx, 'oouify', 
array(array(),array('type'=>'buttonWidget','name'=>'flow-newtopic-save','classes'=>'flow-ui-button','l10n'=>'flow-newtopic-save','flags'=>'primary
 constructive','handler'=>'apiRequest','apiHandler'=>'newTopic')), 'raw').'
+                       <!-- button data-role="submit" 
data-flow-api-handler="newTopic"
                                data-flow-interactive-handler="apiRequest"
                                data-flow-eventlog-action="save-attempt"
-                               class="mw-ui-button mw-ui-constructive 
mw-ui-flush-right">'.LCRun3::ch($cx, 'l10n', 
array(array('flow-newtopic-save'),array()), 'encq').'</button>
+                               class="mw-ui-button mw-ui-constructive 
mw-ui-flush-right">'.LCRun3::ch($cx, 'l10n', 
array(array('flow-newtopic-save'),array()), 'encq').'</button -->
 '.LCRun3::p($cx, 'flow_form_buttons', array(array($in),array())).'             
        <small class="flow-terms-of-use plainlinks">'.LCRun3::ch($cx, 
'l10nParse', array(array('flow-terms-of-use-new-topic'),array()), 
'encq').'</small>
                </div>
        </form>
diff --git a/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php 
b/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
index 48db767..123a00a 100644
--- a/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
@@ -16,6 +16,7 @@
             'html' => 'Flow\TemplateHelper::htmlHelper',
             'l10nParse' => 'Flow\TemplateHelper::l10nParse',
             'linkWithReturnTo' => 'Flow\TemplateHelper::linkWithReturnTo',
+            'oouify' => 'Flow\TemplateHelper::oouify',
 ),
         'blockhelpers' => array(),
         'hbhelpers' => array(            'ifAnonymous' => 
'Flow\TemplateHelper::ifAnonymous',
@@ -68,10 +69,11 @@
 
                <div class="flow-form-actions flow-form-collapsible"
                        '.((LCRun3::ifvar($cx, ((isset($in['isOnFlowBoard']) && 
is_array($in)) ? $in['isOnFlowBoard'] : null))) ? 'style="display:none;"' : 
'').'>
-                       <button data-role="submit" 
data-flow-api-handler="newTopic"
+                       '.LCRun3::ch($cx, 'oouify', 
array(array(),array('type'=>'buttonWidget','name'=>'flow-newtopic-save','classes'=>'flow-ui-button','l10n'=>'flow-newtopic-save','flags'=>'primary
 constructive','handler'=>'apiRequest','apiHandler'=>'newTopic')), 'raw').'
+                       <!-- button data-role="submit" 
data-flow-api-handler="newTopic"
                                data-flow-interactive-handler="apiRequest"
                                data-flow-eventlog-action="save-attempt"
-                               class="mw-ui-button mw-ui-constructive 
mw-ui-flush-right">'.LCRun3::ch($cx, 'l10n', 
array(array('flow-newtopic-save'),array()), 'encq').'</button>
+                               class="mw-ui-button mw-ui-constructive 
mw-ui-flush-right">'.LCRun3::ch($cx, 'l10n', 
array(array('flow-newtopic-save'),array()), 'encq').'</button -->
 '.LCRun3::p($cx, 'flow_form_buttons', array(array($in),array())).'             
        <small class="flow-terms-of-use plainlinks">'.LCRun3::ch($cx, 
'l10nParse', array(array('flow-terms-of-use-new-topic'),array()), 
'encq').'</small>
                </div>
        </form>
diff --git a/handlebars/flow_newtopic_form.partial.handlebars 
b/handlebars/flow_newtopic_form.partial.handlebars
index 8fdb44e..6745427 100644
--- a/handlebars/flow_newtopic_form.partial.handlebars
+++ b/handlebars/flow_newtopic_form.partial.handlebars
@@ -37,10 +37,19 @@
 
                <div class="flow-form-actions flow-form-collapsible"
                        {{#if isOnFlowBoard}}style="display:none;"{{/if}}>
-                       <button data-role="submit" 
data-flow-api-handler="newTopic"
+                       {{{ oouify
+                               type="buttonWidget"
+                               name="flow-newtopic-save"
+                               classes="flow-ui-button"
+                               l10n="flow-newtopic-save"
+                               flags="primary constructive"
+                               handler="apiRequest"
+                               apiHandler="newTopic"
+                       }}}
+                       <!-- button data-role="submit" 
data-flow-api-handler="newTopic"
                                data-flow-interactive-handler="apiRequest"
                                data-flow-eventlog-action="save-attempt"
-                               class="mw-ui-button mw-ui-constructive 
mw-ui-flush-right">{{l10n "flow-newtopic-save"}}</button>
+                               class="mw-ui-button mw-ui-constructive 
mw-ui-flush-right">{{l10n "flow-newtopic-save"}}</button -->
                        {{> flow_form_buttons }}
                        <small class="flow-terms-of-use plainlinks">{{l10nParse 
"flow-terms-of-use-new-topic"}}</small>
                </div>
diff --git a/includes/TemplateHelper.php b/includes/TemplateHelper.php
index 63bfb84..cd86f88 100644
--- a/includes/TemplateHelper.php
+++ b/includes/TemplateHelper.php
@@ -156,6 +156,7 @@
                                        'user' => 'Flow\TemplateHelper::user',
                                        'linkWithReturnTo' => 
'Flow\TemplateHelper::linkWithReturnTo',
                                        'escapeContent' => 
'Flow\TemplateHelper::escapeContent',
+                                       'oouify' => 
'Flow\TemplateHelper::oouify'
                                ),
                                'hbhelpers' => array(
                                        'eachPost' => 
'Flow\TemplateHelper::eachPost',
@@ -493,6 +494,48 @@
         * @param array $args one or more arguments, i18n key and parameters
         * @param array $named unused
         *
+        * @return string Plaintext representation of the ooui widget DOM
+        */
+       static public function oouify( array $args, array $named ) {
+               $widgetType = $named['type'];
+               $widget = "";
+               $acceptableDataArgs = array( 'handler', 'apiHandler' );
+               $data = array();
+
+               // Parse label
+               $label = $named[ 'label' ];
+               if ( empty( $label ) && !empty( $named['l10n'] ) ) {
+                       $label = TemplateHelper::l10n( explode( ' ', 
$named['l10n'] ), array() );
+               }
+
+               // Assemble data
+               for ($i = 0; $i < count( $acceptableDataArgs ); ++$i) {
+                       if ( $named[$acceptableDataArgs[$i]] ) {
+                               $data[$acceptableDataArgs[$i]] = 
$named[$acceptableDataArgs[$i]];
+                       }
+               }
+
+               switch( $widgetType ) {
+                       case "buttonWidget":
+                               $widget = new \OOUI\ButtonInputWidget( array(
+                                       'infusable' => true,
+                                       'id' => $named['name'],
+                                       'type' => 'submit',
+                                       'classes' => explode( ' ', $named[ 
'classes' ] ),
+                                       'label' => $label,
+                                       'flags' => explode( ' ', 
$named['flags'] ),
+                                       'data' => $data
+                               ) );
+                               break;
+               }
+
+               return $widget;
+       }
+
+       /**
+        * @param array $args one or more arguments, i18n key and parameters
+        * @param array $named unused
+        *
         * @return string Plaintext
         */
        static public function l10n( array $args, array $named ) {
diff --git a/includes/View.php b/includes/View.php
index 3f4ac2c..9628cf5 100644
--- a/includes/View.php
+++ b/includes/View.php
@@ -77,6 +77,7 @@
                **/
 
                $output = $this->getOutput();
+               $output->enableOOUI();
                $this->addModules( $output, $action );
                // Please note that all blocks can set page title, which may 
cause them
                // to override one another's titles
diff --git a/modules/engine/components/common/flow-component-events.js 
b/modules/engine/components/common/flow-component-events.js
index a86cb56..f6fd252 100644
--- a/modules/engine/components/common/flow-component-events.js
+++ b/modules/engine/components/common/flow-component-events.js
@@ -514,7 +514,6 @@
                if ( event.type === 'keypress' && ( event.charCode !== 13 || 
event.metaKey || event.shiftKey || event.ctrlKey || event.altKey )) {
                        return;
                }
-
                var args = Array.prototype.slice.call( arguments, 0 ),
                        $context = $( event.currentTarget || 
event.delegateTarget || event.target ),
                        // Have either of these been forced via trigger 
extraParameters?
@@ -534,7 +533,6 @@
                        $context = $( event.currentTarget || 
event.delegateTarget || event.target ),
                        interactiveHandlerName = $context.data( 
'flow-interactive-handler-focus' ),
                        apiHandlerName = $context.data( 
'flow-api-handler-focus' );
-
                return flowExecuteInteractiveHandler.call( this, args, 
$context, interactiveHandlerName, apiHandlerName );
        }
        FlowComponentEventsMixin.eventHandlers.interactiveHandlerFocus = 
flowInteractiveHandlerFocusCallback;
diff --git a/modules/engine/components/common/flow-component-ooui.js 
b/modules/engine/components/common/flow-component-ooui.js
new file mode 100644
index 0000000..755fab1
--- /dev/null
+++ b/modules/engine/components/common/flow-component-ooui.js
@@ -0,0 +1,29 @@
+/*!
+ * Contains flow-menu functionality.
+ */
+
+( function ( $, mw ) {
+       /**
+        * Initializes and handles the ooui components
+        *
+        * @this FlowComponentOoui
+        * @constructor
+        */
+       mw.flow.ooui = function FlowComponentOoui( config ) {
+               config = config || {};
+
+               this.widgets = {};
+
+               // New topic save button
+               this.widgets['flow-newtopic-save'] = OO.ui.infuse( 
'flow-newtopic-save' );
+               this.widgets['flow-newtopic-save'].connect( this, { click: 
this.onNewTopicSaveButtonClick } );
+       };
+       OO.initClass( mw.flow.ooui );
+
+       mw.flow.ooui.prototype.onNewTopicSaveButtonClick = function () {
+               console.log( 'onNewTopicSaveButtonClick' );
+               console.log( this.widgets['flow-newtopic-save'].getData() );
+               return false;
+       };
+
+}( jQuery, mediaWiki ) );
diff --git a/modules/engine/components/flow-component.js 
b/modules/engine/components/flow-component.js
index 563cb8e..a404ac3 100644
--- a/modules/engine/components/flow-component.js
+++ b/modules/engine/components/flow-component.js
@@ -43,6 +43,9 @@
                        parent = parent.parent; // and add it to every instance 
registry
                }
                _totalInstanceCount++;
+
+               // Initialize OOUI
+               this.ooui = new mw.flow.ooui();
        }
        OO.initClass( FlowComponent );
 
diff --git a/modules/styles/board/form-actions.less 
b/modules/styles/board/form-actions.less
index 6b748bb..bfb2a4c 100644
--- a/modules/styles/board/form-actions.less
+++ b/modules/styles/board/form-actions.less
@@ -8,7 +8,7 @@
        position: relative;
        margin-top: 8px;
 
-       button.mw-ui-button, a.mw-ui-button {
+       div.oo-ui-buttonInputWidget, a.mw-ui-button {
                float: right;
                margin-left: .25em;
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73295e1664e0a226100cd65aa570aeec02e5373c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

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

Reply via email to