Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/170008
Change subject: Renamed template function name
......................................................................
Renamed template function name
Resolves conflict with change Ia0c5c8ec960aa6dff12c9626cee41ae9a3286b76.
Change-Id: Ib370c53f8c5d89bf92cc5bf9a81a80c4731472c7
---
M lib/includes/modules/TemplateModule.php
M lib/resources/jquery.ui/jquery.ui.TemplatedWidget.js
M lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js
M lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js
M lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
M lib/resources/jquery.wikibase/jquery.wikibase.labelview.js
M lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js
M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
M lib/resources/templates.js
M lib/tests/qunit/templates.tests.js
12 files changed, 38 insertions(+), 39 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/08/170008/1
diff --git a/lib/includes/modules/TemplateModule.php
b/lib/includes/modules/TemplateModule.php
index 54b1837..d943768 100644
--- a/lib/includes/modules/TemplateModule.php
+++ b/lib/includes/modules/TemplateModule.php
@@ -33,9 +33,9 @@
( function( mw ) {
'use strict';
- mw.templates = mw.templates || {};
- mw.templates.store = new mw.Map();
- mw.templates.store.set( $templatesJson );
+ mw.wbTemplates = mw.wbTemplates || {};
+ mw.wbTemplates.store = new mw.Map();
+ mw.wbTemplates.store.set( $templatesJson );
}( mediaWiki ) );
EOT;
diff --git a/lib/resources/jquery.ui/jquery.ui.TemplatedWidget.js
b/lib/resources/jquery.ui/jquery.ui.TemplatedWidget.js
index 362761c..939994c 100644
--- a/lib/resources/jquery.ui/jquery.ui.TemplatedWidget.js
+++ b/lib/resources/jquery.ui/jquery.ui.TemplatedWidget.js
@@ -8,7 +8,7 @@
var PARENT = $.Widget;
/**
- * Base prototype for all widgets which use the mw.template templating
system to create a basic
+ * Base prototype for all widgets which use the mw.wbTemplate
templating system to create a basic
* DOM structure for internal usage.
*
* @constructor
@@ -23,7 +23,7 @@
* replaced by the Widget's subject node.
*
* @option templateParams {Array} Parameters given to the template on
its initial construction.
- * A parameter can be what is compatible with mw.template but
can also be a function
+ * A parameter can be what is compatible with wm.wbTemplate but
can also be a function
* which will be executed in the widget's context and provide
the parameter's value by
* its return value.
*
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js
index c3433bc..4234bab 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.aliasesview.js
@@ -113,7 +113,7 @@
for( var i = 0; i < this.options.value.aliases.length;
i++ ) {
this.$list.append(
- mw.template(
'wikibase-aliasesview-list-item', this.options.value.aliases[i] )
+ mw.wbTemplate(
'wikibase-aliasesview-list-item', this.options.value.aliases[i] )
);
}
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js
b/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js
index f166de3..8d77e7f 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.badgeselector.js
@@ -303,7 +303,7 @@
.addClass( self.widgetBaseClass + '-menuitem-'
+ itemId )
.data( self.widgetName + '-menuitem-badge',
itemId )
.append( $item
- .prepend( mw.template( 'wb-badge',
+ .prepend( mw.wbTemplate( 'wb-badge',
itemId + ' ' + cssClasses,
( item && item.getLabel(
self.options.languageCode ) ) || itemId,
itemId
@@ -383,7 +383,7 @@
return;
}
this.element.append(
- mw.template( 'wb-badge',
+ mw.wbTemplate( 'wb-badge',
badgeId + ' ' + this.options.badges[badgeId],
badgeId,
badgeId
@@ -398,7 +398,7 @@
var badgeItem = badges[badgeId],
$placeholderBadge = this.element.children(
'[data-wb-badge="' + badgeId + '"]' );
- var $badge = mw.template( 'wb-badge',
+ var $badge = mw.wbTemplate( 'wb-badge',
badgeId + ' ' + this.options.badges[badgeId],
badgeItem && badgeItem.getLabel(
this.options.languageCode ) || badgeId,
badgeId
@@ -415,7 +415,7 @@
* Creates an empty badge to be displayed as menu anchor when no badges
are selected.
*/
_addEmptyBadge: function() {
- this.element.append( mw.template( 'wb-badge',
+ this.element.append( mw.wbTemplate( 'wb-badge',
'empty',
this.options.messages['badge-placeholder-title'],
''
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
index ceef590..b34a207 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
@@ -182,7 +182,7 @@
$title =
wb.utilities.ui.buildMissingEntityInfo( propertyId, wb.datamodel.Property );
}
- self.element.append( mw.template(
'wb-claimgrouplistview-groupname', $title ) );
+ self.element.append( mw.wbTemplate(
'wb-claimgrouplistview-groupname', $title ) );
} );
},
@@ -407,7 +407,7 @@
if( !$container.length ) {
// TODO: Remove layout-specific toolbar wrapper
$container = $( '<div/>' ).appendTo(
- mw.template(
'wikibase-toolbar-wrapper', '' ).appendTo( $claimlistview )
+ mw.wbTemplate(
'wikibase-toolbar-wrapper', '' ).appendTo( $claimlistview )
);
}
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
index 2421a20..43db52d 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
@@ -112,7 +112,7 @@
this.$label = $( '.wb-firstHeading .wikibase-labelview',
this.element ).first();
if( !this.$label.length ) {
this.$label = $( '<div/>' );
- mw.template( 'wikibase-firstHeading',
+ mw.wbTemplate( 'wikibase-firstHeading',
this.options.value.getId(),
this.$label
).appendTo( this.element );
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js
index 2a0ded7..6f8ee4c 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.labelview.js
@@ -368,7 +368,7 @@
// size)
if( !$container.length ) {
$container = $( '<span/>' ).appendTo(
- mw.template(
'wikibase-toolbar-wrapper', '' )
+ mw.wbTemplate(
'wikibase-toolbar-wrapper', '' )
.appendTo( $labelview.find(
'.wikibase-labelview-container' ) )
);
}
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js
index eaff444..80d0ec6 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinklistview.js
@@ -53,7 +53,7 @@
'', // table header
'', // listview
function() {
- return mw.template(
'wikibase-sitelinklistview-tfoot',
+ return mw.wbTemplate(
'wikibase-sitelinklistview-tfoot',
this.isFull() ? mw.msg(
'wikibase-sitelinksedittool-full' ) : '',
'' // toolbar
);
@@ -702,7 +702,7 @@
siteNameMessageKey += '-special';
}
- this.$thead.append( mw.template(
'wikibase-sitelinklistview-thead',
+ this.$thead.append( mw.wbTemplate(
'wikibase-sitelinklistview-thead',
mw.message( siteNameMessageKey ).text(),
mw.message( 'wikibase-sitelinks-siteid-columnheading'
).text(),
mw.message( 'wikibase-sitelinks-link-columnheading'
).text()
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
index 438ddfa..ef9b01c 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
@@ -170,10 +170,10 @@
site = this._getSite();
this.$link.append(
- mw.template( 'wikibase-sitelinkview-pagename',
+ mw.wbTemplate( 'wikibase-sitelinkview-pagename',
siteLink ? site.getUrlTo(
siteLink.getPageName() ) : '',
siteLink ? siteLink.getPageName() : '',
- mw.template( 'wikibase-badgeselector',
'' ),
+ mw.wbTemplate(
'wikibase-badgeselector', '' ),
site ? site.getLanguageCode() : '',
site ? site.getLanguageDirection() :
'auto'
)
diff --git a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
index 9443254..6f2f3fa 100644
--- a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
+++ b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
@@ -131,7 +131,7 @@
} );
if( this.options.renderItemSeparators &&
this.options.$content.length ) {
- $container.append( mw.template(
'wikibase-toolbar-bracketed', $children ) );
+ $container.append( mw.wbTemplate(
'wikibase-toolbar-bracketed', $children ) );
} else {
$container.append( $children );
}
diff --git a/lib/resources/templates.js b/lib/resources/templates.js
index c06d19b..f7b7873 100644
--- a/lib/resources/templates.js
+++ b/lib/resources/templates.js
@@ -2,7 +2,6 @@
* @licence GNU GPL v2+
* @author H. Snater < [email protected] >
*/
-
( function( mw, $ ) {
'use strict';
@@ -17,11 +16,11 @@
*
* @constructor
*/
- mw.Template = function() { mw.Message.apply( this, arguments ); };
- mw.Template.prototype = $.extend(
+ mw.WbTemplate = function() { mw.Message.apply( this, arguments ); };
+ mw.WbTemplate.prototype = $.extend(
{},
mw.Message.prototype,
- { constructor: mw.Template }
+ { constructor: mw.WbTemplate }
);
/**
@@ -31,7 +30,7 @@
*
* @return {string}
*/
- mw.Template.prototype.plain = function() {
+ mw.WbTemplate.prototype.plain = function() {
return this.parser();
};
@@ -40,7 +39,7 @@
*
* @return {string}
*/
- mw.Template.prototype.parser = function () {
+ mw.WbTemplate.prototype.parser = function () {
var parameters = this.parameters;
return this.map.get( this.key ).replace( /\$(\d+)/g, function (
str, match ) {
var index = parseInt( match, 10 ) - 1;
@@ -62,7 +61,7 @@
*
* @throws {Error} if the generated template's HTML is invalid.
*/
- mw.template = function( key, parameter1 /* [, parameter2[, ...]] */ ) {
+ mw.wbTemplate = function( key, parameter1 /* [, parameter2[, ...]] */ )
{
var i,
params = [],
template,
@@ -94,11 +93,11 @@
tempParams.push( '<' + nodeName + '
class="--mwTemplate"></' + nodeName + '>' );
delayedParams.push( params[i] );
} else {
- throw new Error( 'mw.template: Wrong parameter
type. Pass either String or jQuery.' );
+ throw new Error( 'mw.WbTemplate: Wrong
parameter type. Pass either String or jQuery.' );
}
}
- template = new mw.Template( mw.templates.store, key, tempParams
);
+ template = new mw.WbTemplate( mw.wbTemplates.store, key,
tempParams );
// Wrap template inside a html container to be able to easily
access all temporary nodes and
// insert any jQuery objects:
@@ -106,8 +105,8 @@
if( !areCachedParameterTypes( key, params ) ) {
if( !isValidHtml( template, $wrappedTemplate ) ) {
- throw new Error( 'mw.template: Tried to
generate invalid HTML for template "' + key
- + '"' );
+ throw new Error( 'mw.wbTemplate: Tried to
generate invalid HTML for template "'
+ + key + '"' );
}
addToCache( key, params );
}
@@ -137,7 +136,7 @@
* @return {jQuery}
*/
$.fn.applyTemplate = function( template, parameter1 /*[, parameter2[,
...]] */ ) {
- var $template = mw.template.apply( null, arguments );
+ var $template = mw.wbTemplate.apply( null, arguments );
if( $template.length !== 1 ) {
throw new Error( 'Can not apply a template with more or
less than one root node.' );
diff --git a/lib/tests/qunit/templates.tests.js
b/lib/tests/qunit/templates.tests.js
index cb9c7d5..e416e7d 100644
--- a/lib/tests/qunit/templates.tests.js
+++ b/lib/tests/qunit/templates.tests.js
@@ -8,17 +8,17 @@
* @author H. Snater < [email protected] >
*/
-( function( mw, $, QUnit, undefined ) {
+( function( mw, $, QUnit ) {
'use strict';
QUnit.module( 'templates', QUnit.newMwEnvironment() );
- QUnit.test( 'mw.template()', function( assert ) {
+ QUnit.test( 'mw.wbTemplate()', function( assert ) {
assert.equal(
- typeof mw.templates,
+ typeof mw.wbTemplates,
'object',
- 'mw.templates is defined.'
+ 'mw.wbTemplates is defined.'
);
/**
@@ -153,7 +153,7 @@
];
/**
- * Verifies if mw.template() delivers an expected result.
+ * Verifies if mw.wbTemplate() delivers an expected result.
*
* @param {Array} params
* @param {String} template
@@ -181,7 +181,7 @@
params = [ params ];
}
- mw.templates.store.set( key, template );
+ mw.wbTemplates.store.set( key, template );
var paramMessage = '';
$.each( params, function( i, param ) {
@@ -201,12 +201,12 @@
if ( expected === '' ) {
assert.throws(
- function() { $( '<div/>' ).append(
mw.template( key, params ) ).html(); },
+ function() { $( '<div/>' ).append(
mw.wbTemplate( key, params ) ).html(); },
'Triggered error when trying to create
invalid HTML filling single param template "' + template + '" with "' +
paramMessage + '"'
);
} else {
assert.equal(
- replaceChevrons( $( '<div/>' ).append(
mw.template( key, params ) ).html() ),
+ replaceChevrons( $( '<div/>' ).append(
mw.wbTemplate( key, params ) ).html() ),
replaceChevrons( expected ),
'Verified template: "' + template + '"
with "' + paramMessage + '"'
);
--
To view, visit https://gerrit.wikimedia.org/r/170008
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib370c53f8c5d89bf92cc5bf9a81a80c4731472c7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits