Jdlrobson has uploaded a new change for review.

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

Change subject: Hygiene: Move tagButton code into a template
......................................................................

Hygiene: Move tagButton code into a template

Improve readability
(note I've not tested this so merger please do this and remove this
line before +2ing so I know it happened :-))

Change-Id: I19e4c4a5d298e8784782eb88a84b40699eb991d3
---
M includes/Resources.php
M javascripts/modules/wikigrok/WikiGrokDialogB.js
A templates/modules/wikigrok/tagButton.hogan
3 files changed, 22 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/33/182133/1

diff --git a/includes/Resources.php b/includes/Resources.php
index 05e0cf6..1cd1954 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -956,6 +956,7 @@
                ),
                'templates' => array(
                        'Dialog.hogan' => 
'templates/modules/wikigrok/WikiGrokDialogB.hogan',
+                       'tagButton.hogan' => 
'templates/modules/wikigrok/tagButton.hogan',
                ),
                'scripts' => array(
                        'javascripts/modules/wikigrok/WikiGrokDialogB.js',
diff --git a/javascripts/modules/wikigrok/WikiGrokDialogB.js 
b/javascripts/modules/wikigrok/WikiGrokDialogB.js
index 10988ad..0f44b48 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialogB.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialogB.js
@@ -67,11 +67,23 @@
 
                                        self.$( '.tags' ).show();
                                        $.each( labels, function ( itemId, 
label ) {
-                                               var $tag,
-                                                       id = 'tag-' + itemId;
+                                               var $tag, tagHtml, templateData;
+
+                                               templateData = {
+                                                       id: 'tag-' + itemId,
+                                                       propName: 
campaign.propertyName,
+                                                       propId: 
campaign.propertyId,
+                                                       itemId: itemId,
+                                                       readable: label,
+                                                       campaignText: 
i18n[campaign.name],
+                                                       tagText: label
+                                               };
 
                                                if ( label ) {
-                                                       $tag = $( '<div 
class="ui-tag-button mw-ui-button">' )
+                                                       tagHtml = 
mw.template.get( 'mobile.wikigrok.dialog.b', 'tagButton.hogan' )
+                                                               .render( 
templateData );
+
+                                                       $tag = $( tagHtml )
                                                                .on( 'click', 
function () {
                                                                        // 
Activate the tag
                                                                        $( this 
).toggleClass( 'mw-ui-progressive' );
@@ -85,21 +97,6 @@
                                                                                
$none.show();
                                                                        }
                                                                } ).appendTo( 
self.$( '.tags' ) );
-
-                                                       // FIXME: Use a 
template for this magic.
-                                                       $tag.attr( 'id', id )
-                                                               .data( 
'propName', campaign.propertyName )
-                                                               .data( 
'propId', campaign.propertyId )
-                                                               .data( 
'itemId', itemId )
-                                                               .data( 
'readable', label );
-
-                                                       // Add the property 
label
-                                                       $( '<label>' )
-                                                               .text( 
i18n[campaign.name] ).appendTo( $tag );
-
-                                                       // Add the value label
-                                                       $( '<label>' )
-                                                               .text( label 
).appendTo( $tag );
                                                }
                                        } );
 
diff --git a/templates/modules/wikigrok/tagButton.hogan 
b/templates/modules/wikigrok/tagButton.hogan
new file mode 100644
index 0000000..4701a49
--- /dev/null
+++ b/templates/modules/wikigrok/tagButton.hogan
@@ -0,0 +1,6 @@
+<div class="ui-tag-button mw-ui-button" id="{{id}}"
+       data-itemId="{{itemId}}"
+       data-propName="{{propName}}" data-propId="{{propId}}" 
data-readable="{{readable}}">
+       <label>{{campaignText}}</label>
+       <label>{{tagText}}</label>
+</div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19e4c4a5d298e8784782eb88a84b40699eb991d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to