Merge "build: Add csshint, jshint and jscs to math extension"
This commit is contained in:
commit
f99b77c98e
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"adjoining-classes": false,
|
||||||
|
"box-model": false,
|
||||||
|
"box-sizing": false,
|
||||||
|
"fallback-colors": false,
|
||||||
|
"important": false,
|
||||||
|
"outline-none": false,
|
||||||
|
"qualified-headings": false,
|
||||||
|
"unique-headings": false,
|
||||||
|
"universal-selector": false,
|
||||||
|
"unqualified-attributes": false,
|
||||||
|
"gradients": false
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"preset": "wikimedia",
|
||||||
|
|
||||||
|
"jsDoc": {
|
||||||
|
"checkAnnotations": {
|
||||||
|
"preset": "jsduck5",
|
||||||
|
"extra": {
|
||||||
|
"this": true,
|
||||||
|
"source": true,
|
||||||
|
"see": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"checkTypes": "strictNativeCase",
|
||||||
|
"checkParamNames": true,
|
||||||
|
"checkRedundantAccess": true,
|
||||||
|
"checkRedundantReturns": true,
|
||||||
|
"requireNewlineAfterDescription": true,
|
||||||
|
"requireParamTypes": true,
|
||||||
|
"requireReturnTypes": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
// Enforcing
|
||||||
|
"bitwise": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"freeze": true,
|
||||||
|
"latedef": true,
|
||||||
|
"noarg": true,
|
||||||
|
"nonew": true,
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
"strict": false,
|
||||||
|
|
||||||
|
// Relaxing
|
||||||
|
"es5": false,
|
||||||
|
|
||||||
|
// Environment
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true,
|
||||||
|
|
||||||
|
"globals": {
|
||||||
|
"mediaWiki": false,
|
||||||
|
"OO": false,
|
||||||
|
"ve": false
|
||||||
|
}
|
||||||
|
}
|
40
Gruntfile.js
40
Gruntfile.js
|
@ -2,6 +2,10 @@
|
||||||
module.exports = function ( grunt ) {
|
module.exports = function ( grunt ) {
|
||||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||||
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
||||||
|
grunt.loadNpmTasks( 'grunt-contrib-csslint' );
|
||||||
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
||||||
|
grunt.loadNpmTasks( 'grunt-contrib-watch' );
|
||||||
|
grunt.loadNpmTasks( 'grunt-jscs' );
|
||||||
|
|
||||||
grunt.initConfig( {
|
grunt.initConfig( {
|
||||||
banana: {
|
banana: {
|
||||||
|
@ -12,9 +16,43 @@ module.exports = function ( grunt ) {
|
||||||
'**/*.json',
|
'**/*.json',
|
||||||
'!node_modules/**'
|
'!node_modules/**'
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
csslint: {
|
||||||
|
options: {
|
||||||
|
csslintrc: '.csslintrc'
|
||||||
|
},
|
||||||
|
all: 'modules/VisualEditor/*.css'
|
||||||
|
},
|
||||||
|
jshint: {
|
||||||
|
options: {
|
||||||
|
jshintrc: true
|
||||||
|
},
|
||||||
|
all: [
|
||||||
|
'*.js',
|
||||||
|
'modules/**/*.js'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
files: [
|
||||||
|
'.{csslintrc,jscsrc,jshintignore,jshintrc}',
|
||||||
|
'<%= jshint.all %>',
|
||||||
|
'<%= csslint.all %>'
|
||||||
|
],
|
||||||
|
tasks: 'test'
|
||||||
|
},
|
||||||
|
jscs: {
|
||||||
|
fix: {
|
||||||
|
options: {
|
||||||
|
fix: true
|
||||||
|
},
|
||||||
|
src: '<%= jshint.all %>'
|
||||||
|
},
|
||||||
|
main: {
|
||||||
|
src: '<%= jshint.all %>'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
grunt.registerTask( 'test', [ 'jsonlint', 'banana' ] );
|
grunt.registerTask( 'test', [ 'jshint', 'jscs:main', 'csslint', 'jsonlint', 'banana' ] );
|
||||||
grunt.registerTask( 'default', 'test' );
|
grunt.registerTask( 'default', 'test' );
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
{
|
|
||||||
"predef": [
|
|
||||||
"mediaWiki",
|
|
||||||
"jQuery"
|
|
||||||
],
|
|
||||||
|
|
||||||
"bitwise": true,
|
|
||||||
"camelcase": true,
|
|
||||||
"curly": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"forin": false,
|
|
||||||
"immed": true,
|
|
||||||
"latedef": true,
|
|
||||||
"newcap": true,
|
|
||||||
"noarg": true,
|
|
||||||
"noempty": true,
|
|
||||||
"nonew": true,
|
|
||||||
"quotmark": "single",
|
|
||||||
"regexp": false,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
"strict": false,
|
|
||||||
"trailing": true,
|
|
||||||
|
|
||||||
"smarttabs": true,
|
|
||||||
|
|
||||||
"browser": true,
|
|
||||||
|
|
||||||
"nomen": true,
|
|
||||||
"onevar": true
|
|
||||||
}
|
|
|
@ -55,7 +55,7 @@ ve.ce.MWMathNode.prototype.afterRender = function () {
|
||||||
if ( this.$element.is( 'span.tex' ) ) {
|
if ( this.$element.is( 'span.tex' ) ) {
|
||||||
// MathJax
|
// MathJax
|
||||||
MathJax.Hub.Queue(
|
MathJax.Hub.Queue(
|
||||||
[ 'Typeset', MathJax.Hub, this.$element[0] ],
|
[ 'Typeset', MathJax.Hub, this.$element[ 0 ] ],
|
||||||
[ this, this.emit, 'rerender' ]
|
[ this, this.emit, 'rerender' ]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -45,6 +45,8 @@ ve.ui.MWMathInspector.static.dir = 'ltr';
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ve.ui.MWMathInspector.prototype.initialize = function () {
|
ve.ui.MWMathInspector.prototype.initialize = function () {
|
||||||
|
var inputField, displayField, idField;
|
||||||
|
|
||||||
// Parent method
|
// Parent method
|
||||||
ve.ui.MWMathInspector.super.prototype.initialize.call( this );
|
ve.ui.MWMathInspector.super.prototype.initialize.call( this );
|
||||||
|
|
||||||
|
@ -71,18 +73,18 @@ ve.ui.MWMathInspector.prototype.initialize = function () {
|
||||||
|
|
||||||
this.idInput = new OO.ui.TextInputWidget();
|
this.idInput = new OO.ui.TextInputWidget();
|
||||||
|
|
||||||
var inputField = new OO.ui.FieldLayout( this.input, {
|
inputField = new OO.ui.FieldLayout( this.input, {
|
||||||
align: 'top',
|
align: 'top',
|
||||||
label: ve.msg( 'math-visualeditor-mwmathinspector-title' )
|
label: ve.msg( 'math-visualeditor-mwmathinspector-title' )
|
||||||
} ),
|
} );
|
||||||
displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
||||||
align: 'top',
|
align: 'top',
|
||||||
label: ve.msg( 'math-visualeditor-mwmathinspector-display' )
|
label: ve.msg( 'math-visualeditor-mwmathinspector-display' )
|
||||||
} ),
|
} );
|
||||||
idField = new OO.ui.FieldLayout( this.idInput, {
|
idField = new OO.ui.FieldLayout( this.idInput, {
|
||||||
align: 'top',
|
align: 'top',
|
||||||
label: ve.msg( 'math-visualeditor-mwmathinspector-id' )
|
label: ve.msg( 'math-visualeditor-mwmathinspector-id' )
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
this.$content.addClass( 've-ui-mwMathInspector-content' );
|
this.$content.addClass( 've-ui-mwMathInspector-content' );
|
||||||
|
@ -115,11 +117,13 @@ ve.ui.MWMathInspector.prototype.getTeardownProcess = function ( data ) {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ve.ui.MWMathInspector.prototype.updateMwData = function ( mwData ) {
|
ve.ui.MWMathInspector.prototype.updateMwData = function ( mwData ) {
|
||||||
|
var display, id;
|
||||||
|
|
||||||
// Parent method
|
// Parent method
|
||||||
ve.ui.MWMathInspector.super.prototype.updateMwData.call( this, mwData );
|
ve.ui.MWMathInspector.super.prototype.updateMwData.call( this, mwData );
|
||||||
|
|
||||||
var display = this.displaySelect.getSelectedItem().getData(),
|
display = this.displaySelect.getSelectedItem().getData();
|
||||||
id = this.idInput.getValue();
|
id = this.idInput.getValue();
|
||||||
|
|
||||||
mwData.attrs.display = display !== 'default' ? display : undefined;
|
mwData.attrs.display = display !== 'default' ? display : undefined;
|
||||||
mwData.attrs.id = id || undefined;
|
mwData.attrs.id = id || undefined;
|
||||||
|
|
|
@ -32,6 +32,6 @@ ve.ui.toolFactory.register( ve.ui.MWMathInspectorTool );
|
||||||
ve.ui.commandRegistry.register(
|
ve.ui.commandRegistry.register(
|
||||||
new ve.ui.Command(
|
new ve.ui.Command(
|
||||||
'math', 'window', 'open',
|
'math', 'window', 'open',
|
||||||
{ args: ['math'], supportedSelections: ['linear'] }
|
{ args: [ 'math' ], supportedSelections: [ 'linear' ] }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
( function ( mw ) {
|
( function ( mw ) {
|
||||||
|
var iconPath;
|
||||||
if ( mw.toolbar ) {
|
if ( mw.toolbar ) {
|
||||||
var iconPath = mw.config.get( 'wgExtensionAssetsPath' ) + '/Math/images/';
|
iconPath = mw.config.get( 'wgExtensionAssetsPath' ) + '/Math/images/';
|
||||||
mw.toolbar.addButton( {
|
mw.toolbar.addButton( {
|
||||||
imageFile: iconPath + 'button_math.png',
|
imageFile: iconPath + 'button_math.png',
|
||||||
speedTip: mw.msg( 'math_tip' ),
|
speedTip: mw.msg( 'math_tip' ),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
var img, url;
|
var img, url;
|
||||||
|
|
||||||
// If MathPlayer is installed we show the MathML rendering.
|
// If MathPlayer is installed we show the MathML rendering.
|
||||||
if (navigator.userAgent.indexOf('MathPlayer') > -1) {
|
if ( navigator.userAgent.indexOf( 'MathPlayer' ) > -1 ) {
|
||||||
$( '.mwe-math-mathml-a11y' ).removeClass( 'mwe-math-mathml-a11y' );
|
$( '.mwe-math-mathml-a11y' ).removeClass( 'mwe-math-mathml-a11y' );
|
||||||
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).css( 'display', 'none' );
|
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).css( 'display', 'none' );
|
||||||
return;
|
return;
|
||||||
|
@ -11,18 +11,18 @@
|
||||||
|
|
||||||
// We verify whether SVG as <img> is supported and otherwise use the
|
// We verify whether SVG as <img> is supported and otherwise use the
|
||||||
// PNG fallback. See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js
|
// PNG fallback. See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js
|
||||||
if (!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1')) {
|
if ( !document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
|
||||||
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).each(function() {
|
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).each( function () {
|
||||||
// Create a new PNG image to use as the fallback.
|
// Create a new PNG image to use as the fallback.
|
||||||
img = document.createElement('img');
|
img = document.createElement( 'img' );
|
||||||
url = this.style.backgroundImage.match(/url\('?([^']*)'?\)/)[1];
|
url = this.style.backgroundImage.match( /url\('?([^']*)'?\)/ )[ 1 ];
|
||||||
img.setAttribute( 'src', url.replace('mode=' + 'mathml', 'mode=' + 'png') );
|
img.setAttribute( 'src', url.replace( 'mode=' + 'mathml', 'mode=' + 'png' ) );
|
||||||
img.setAttribute( 'class', 'tex mwe-math-fallback-image-' + ($( this ).hasClass('mwe-math-fallback-image-inline') ? 'inline' : 'display') );
|
img.setAttribute( 'class', 'tex mwe-math-fallback-image-' + ( $( this ).hasClass( 'mwe-math-fallback-image-inline' ) ? 'inline' : 'display' ) );
|
||||||
img.setAttribute( 'aria-hidden', 'true' );
|
img.setAttribute( 'aria-hidden', 'true' );
|
||||||
this.parentNode.insertBefore( img, this );
|
this.parentNode.insertBefore( img, this );
|
||||||
|
|
||||||
// Hide the SVG fallback.
|
// Hide the SVG fallback.
|
||||||
$( this ).css( 'display', 'none' );
|
$( this ).css( 'display', 'none' );
|
||||||
});
|
} );
|
||||||
}
|
}
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
"grunt": "0.4.5",
|
"grunt": "0.4.5",
|
||||||
"grunt-cli": "0.1.13",
|
"grunt-cli": "0.1.13",
|
||||||
"grunt-banana-checker": "0.2.2",
|
"grunt-banana-checker": "0.2.2",
|
||||||
"grunt-jsonlint": "1.0.4"
|
"grunt-jsonlint": "1.0.4",
|
||||||
|
"grunt-contrib-csslint": "0.5.0",
|
||||||
|
"grunt-contrib-jshint": "0.11.3",
|
||||||
|
"grunt-contrib-watch": "0.6.1",
|
||||||
|
"grunt-jscs": "2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue