« Utilisateur:Kghbln/vector.js » : différence entre les versions
De Semantic MediaWiki - Sandbox
(chg) |
(chg) |
||
(19 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
// <nowiki> | // <nowiki> | ||
var customizeToolbar = function () { | var customizeToolbar = function () { | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
/* Add a new group to an existing section */ | |||
' | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
' | 'section': 'advanced', | ||
'groups': { | |||
'templates': { | |||
/* 'label': 'Vorlagen' // or use labelMsg 'groups-templates-label' for a localized label -- no label required since this one is supposed to be a dropdown */ | |||
} | |||
} | } | ||
} ); | |||
} ); | |||
$('#wpTextbox1').wikiEditor('addToToolbar', { | /* Add a button to an existing group */ | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | section: 'advanced', | ||
group: ' | group: 'format', | ||
tools: { | tools: { | ||
"references": { | "references": { | ||
Ligne 26 : | Ligne 29 : | ||
} | } | ||
}, | }, | ||
} | |||
} ); | |||
/* Add a dropdown menu to an existing group */ | |||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | |||
group: 'templates', | |||
tools: { | |||
"templates": { | "templates": { | ||
label: 'Vorlagen', | label: 'Vorlagen', | ||
type: 'select', | type: 'select', | ||
list: { | list: { | ||
'youtube' : { | |||
label: 'YouTube', | |||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Ligne 39 : | Ligne 50 : | ||
} | } | ||
}, | }, | ||
'videor' : { | |||
label: 'Video (fremd)', | |||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Ligne 48 : | Ligne 59 : | ||
} | } | ||
}, | }, | ||
'videol' : { | |||
label: 'Video (eigen)', | |||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Ligne 57 : | Ligne 68 : | ||
} | } | ||
}, | }, | ||
'audior' : { | |||
label: 'Audio (fremd)', | |||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Ligne 67 : | Ligne 78 : | ||
}, | }, | ||
'audiol' : { | 'audiol' : { | ||
label: 'Audio (eigen)', | |||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Ligne 78 : | Ligne 89 : | ||
} | } | ||
} | } | ||
}); | } ); | ||
}; | }; | ||
Ligne 92 : | Ligne 103 : | ||
} ); | } ); | ||
} | } | ||
// </nowiki> | // </nowiki> | ||
Dernière version du 27 juin 2019 à 22:51
// <nowiki>
var customizeToolbar = function () {
/* Add a new group to an existing section */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'groups': {
'templates': {
/* 'label': 'Vorlagen' // or use labelMsg 'groups-templates-label' for a localized label -- no label required since this one is supposed to be a dropdown */
}
}
} );
/* Add a button to an existing group */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"references": {
label: 'Abschnitt Einzelnachweise hinzufügen',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/3/32/OOjs_UI_icon_ref.svg/22px-OOjs_UI_icon_ref.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "==Einzelnachweise==\n<references />",
'ownline': true
}
}
},
}
} );
/* Add a dropdown menu to an existing group */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'templates',
tools: {
"templates": {
label: 'Vorlagen',
type: 'select',
list: {
'youtube' : {
label: 'YouTube',
action: {
type: 'encapsulate',
options: {
pre: '{{YouTube |YouTube-Kennung }}'
}
}
},
'videor' : {
label: 'Video (fremd)',
action: {
type: 'encapsulate',
options: {
pre: '{{Video |url=URL der Datei |width=425 |height=355 }}'
}
}
},
'videol' : {
label: 'Video (eigen)',
action: {
type: 'encapsulate',
options: {
pre: '{{Video |name=Name URL der Datei |width=425 |height=355 }}'
}
}
},
'audior' : {
label: 'Audio (fremd)',
action: {
type: 'encapsulate',
options: {
pre: '{{Audio |url=URL der Datei }}'
}
}
},
'audiol' : {
label: 'Audio (eigen)',
action: {
type: 'encapsulate',
options: {
pre: '{{Audio |name=Name der Datei }}'
}
}
},
}
}
}
} );
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
}
} );
}
// </nowiki>