Robmoen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/174864
Change subject: Upstream icons from MobileFrontend
......................................................................
Upstream icons from MobileFrontend
Change-Id: I65a85540015ae0fb1dc98fbccd07a83c6f15d2d2
---
M includes/Resources.php
A javascripts/common/Icon.js
A javascripts/common/icons.js
A javascripts/common/templates/icon.hogan
4 files changed, 103 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Mantle
refs/changes/64/174864/1
diff --git a/includes/Resources.php b/includes/Resources.php
index 7eed30f..9dc9ac9 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -75,4 +75,17 @@
'javascripts/common/View.js',
),
),
+ 'ext.mantle.icons' => $wgMantleResourceBoilerplate + array(
+ 'dependencies' => array(
+ 'ext.mantle.views',
+ ),
+ 'templates' => array(
+ 'icon.hogan' =>
'javascripts/common/templates/icon.hogan',
+ ),
+ 'scripts' => array(
+ 'javascripts/common/Icon.js',
+ 'javascripts/common/icons.js',
+ ),
+ ),
+
) );
diff --git a/javascripts/common/Icon.js b/javascripts/common/Icon.js
new file mode 100644
index 0000000..75c57d0
--- /dev/null
+++ b/javascripts/common/Icon.js
@@ -0,0 +1,51 @@
+( function ( M ) {
+
+ var View = M.require( 'View' ),
+ useMediaWikiUI = M.isAlphaGroupMember(),
+ Icon;
+
+ /**
+ * A wrapper for creating an icon.
+ * @class Icon
+ * @extends View
+ */
+ Icon = View.extend( {
+ defaults: {
+ hasText: false,
+ tagName: 'div',
+ base: useMediaWikiUI ? 'mw-ui-icon' : 'icon',
+ name: '',
+ modifier: useMediaWikiUI ? 'mw-ui-icon-element' : '',
+ title: ''
+ },
+ /**
+ * Return the full class name that is required for the icon to
render
+ * @method
+ * @return {string}
+ */
+ getClassName: function () {
+ return this.$el.children( 0 ).attr( 'class' );
+ },
+ /**
+ * Return the class that relates to the icon glyph
+ * @method
+ * @return {string}
+ */
+ getGlyphClassName: function () {
+ return this.options.base + '-' + this.options.name;
+ },
+ initialize: function ( options ) {
+ if ( options.hasText ) {
+ options.modifier = useMediaWikiUI ?
'mw-ui-icon-before' : 'icon-text';
+ }
+ View.prototype.initialize.call( this, options );
+ },
+ toHtmlString: function () {
+ return this.$el.html();
+ },
+ template: mw.template.get( 'ext.mantle.icons', 'icon.hogan' )
+ } );
+
+ M.define( 'Icon', Icon );
+
+}( mw.mobileFrontend ) );
diff --git a/javascripts/common/icons.js b/javascripts/common/icons.js
new file mode 100644
index 0000000..1b38104
--- /dev/null
+++ b/javascripts/common/icons.js
@@ -0,0 +1,36 @@
+( function ( M, $ ) {
+
+ var Icon = M.require( 'Icon' );
+
+ /**
+ * A set of shared icons.
+ *
+ * Factory methods are used to keep separate features that use the same
icons
+ * from accidentally manipulating one another's DOM when calling
methods like
+ * `remove`.
+ *
+ * @class icons
+ * @singleton
+ */
+ M.define( 'icons', {
+
+ /**
+ * Gets a spinner icon.
+ *
+ * The icon should be used to inform the user that the
front-end is
+ * communicating with the back-end.
+ *
+ * @param {Object} options See `Icon` for more details
+ * @return {Icon}
+ */
+ spinner: function ( options ) {
+ options = options || {};
+
+ return new Icon( $.extend( options, {
+ name: 'spinner',
+ additionalClassNames: 'spinner loading'
+ } ) );
+ }
+ } );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/common/templates/icon.hogan
b/javascripts/common/templates/icon.hogan
new file mode 100644
index 0000000..57c6de2
--- /dev/null
+++ b/javascripts/common/templates/icon.hogan
@@ -0,0 +1,3 @@
+<{{tagName}} class="{{base}} {{base}}-{{name}} {{modifier}}
{{additionalClassNames}}"
+ {{#id}}id="{{id}}"{{/id}}
+ {{#title}}title="{{title}}"{{/title}}>{{label}}</{{tagName}}>
--
To view, visit https://gerrit.wikimedia.org/r/174864
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65a85540015ae0fb1dc98fbccd07a83c6f15d2d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Mantle
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits