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 ) {
|
||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||
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( {
|
||||
banana: {
|
||||
|
@ -12,9 +16,43 @@ module.exports = function ( grunt ) {
|
|||
'**/*.json',
|
||||
'!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' );
|
||||
};
|
||||
|
|
|
@ -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' ) ) {
|
||||
// MathJax
|
||||
MathJax.Hub.Queue(
|
||||
[ 'Typeset', MathJax.Hub, this.$element[0] ],
|
||||
[ 'Typeset', MathJax.Hub, this.$element[ 0 ] ],
|
||||
[ this, this.emit, 'rerender' ]
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -45,6 +45,8 @@ ve.ui.MWMathInspector.static.dir = 'ltr';
|
|||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWMathInspector.prototype.initialize = function () {
|
||||
var inputField, displayField, idField;
|
||||
|
||||
// Parent method
|
||||
ve.ui.MWMathInspector.super.prototype.initialize.call( this );
|
||||
|
||||
|
@ -71,14 +73,14 @@ ve.ui.MWMathInspector.prototype.initialize = function () {
|
|||
|
||||
this.idInput = new OO.ui.TextInputWidget();
|
||||
|
||||
var inputField = new OO.ui.FieldLayout( this.input, {
|
||||
inputField = new OO.ui.FieldLayout( this.input, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwmathinspector-title' )
|
||||
} ),
|
||||
} );
|
||||
displayField = new OO.ui.FieldLayout( this.displaySelect, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwmathinspector-display' )
|
||||
} ),
|
||||
} );
|
||||
idField = new OO.ui.FieldLayout( this.idInput, {
|
||||
align: 'top',
|
||||
label: ve.msg( 'math-visualeditor-mwmathinspector-id' )
|
||||
|
@ -115,10 +117,12 @@ ve.ui.MWMathInspector.prototype.getTeardownProcess = function ( data ) {
|
|||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWMathInspector.prototype.updateMwData = function ( mwData ) {
|
||||
var display, id;
|
||||
|
||||
// Parent method
|
||||
ve.ui.MWMathInspector.super.prototype.updateMwData.call( this, mwData );
|
||||
|
||||
var display = this.displaySelect.getSelectedItem().getData(),
|
||||
display = this.displaySelect.getSelectedItem().getData();
|
||||
id = this.idInput.getValue();
|
||||
|
||||
mwData.attrs.display = display !== 'default' ? display : undefined;
|
||||
|
|
|
@ -32,6 +32,6 @@ ve.ui.toolFactory.register( ve.ui.MWMathInspectorTool );
|
|||
ve.ui.commandRegistry.register(
|
||||
new ve.ui.Command(
|
||||
'math', 'window', 'open',
|
||||
{ args: ['math'], supportedSelections: ['linear'] }
|
||||
{ args: [ 'math' ], supportedSelections: [ 'linear' ] }
|
||||
)
|
||||
);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
( function ( mw ) {
|
||||
var iconPath;
|
||||
if ( mw.toolbar ) {
|
||||
var iconPath = mw.config.get( 'wgExtensionAssetsPath' ) + '/Math/images/';
|
||||
iconPath = mw.config.get( 'wgExtensionAssetsPath' ) + '/Math/images/';
|
||||
mw.toolbar.addButton( {
|
||||
imageFile: iconPath + 'button_math.png',
|
||||
speedTip: mw.msg( 'math_tip' ),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var img, url;
|
||||
|
||||
// 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-fallback-image-inline, .mwe-math-fallback-image-display' ).css( 'display', 'none' );
|
||||
return;
|
||||
|
@ -11,18 +11,18 @@
|
|||
|
||||
// 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
|
||||
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() {
|
||||
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 () {
|
||||
// Create a new PNG image to use as the fallback.
|
||||
img = document.createElement('img');
|
||||
url = this.style.backgroundImage.match(/url\('?([^']*)'?\)/)[1];
|
||||
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 = document.createElement( 'img' );
|
||||
url = this.style.backgroundImage.match( /url\('?([^']*)'?\)/ )[ 1 ];
|
||||
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( 'aria-hidden', 'true' );
|
||||
this.parentNode.insertBefore( img, this );
|
||||
|
||||
// Hide the SVG fallback.
|
||||
$( this ).css( 'display', 'none' );
|
||||
});
|
||||
} );
|
||||
}
|
||||
}( jQuery ) );
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
"grunt": "0.4.5",
|
||||
"grunt-cli": "0.1.13",
|
||||
"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