jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Move tagButton code into a template
......................................................................
Hygiene: Move tagButton code into a template
Improves readability of WikiGrokDialogB.
Change-Id: I19e4c4a5d298e8784782eb88a84b40699eb991d3
---
M includes/Resources.php
M javascripts/modules/wikigrok/WikiGrokDialogB.js
A templates/modules/wikigrok/tagButton.hogan
3 files changed, 25 insertions(+), 21 deletions(-)
Approvals:
Phuedx: Looks good to me, approved
jenkins-bot: Verified
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..144868d 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 );
}
} );
@@ -150,10 +147,10 @@
var $this = $( this );
answers.push( {
correct: $this.is(
'.mw-ui-progressive' ) ? true : null,
- prop: $this.data( 'propName' ),
- propid: $this.data( 'propId' ),
+ prop: $this.data( 'propname' ),
+ propid: $this.data( 'propid' ),
value: $this.data( 'readable' ),
- valueid: $this.data( 'itemId' )
+ valueid: $this.data( 'itemid' )
} );
} );
diff --git a/templates/modules/wikigrok/tagButton.hogan
b/templates/modules/wikigrok/tagButton.hogan
new file mode 100644
index 0000000..e2dcb9e
--- /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: merged
Gerrit-Change-Id: I19e4c4a5d298e8784782eb88a84b40699eb991d3
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits