|
|
(No se muestran 10 ediciones intermedias de otro usuario) |
Línea 1: |
Línea 1: |
| /*jshint smarttabs:true, loopfunc:true,forin:false*/
| | [[:en:Wikipedia:RefToolbar|refTools]], añade un botón a la barra de edición para añadir rápidamente las citas más comunes. |
| /*global mw, $, importScript */
| |
| // TODO: make autodate an option in the CiteTemplate object, not a preference
| |
| | |
| // Global object
| |
| // TODO:
| |
| // * Remove this once the page is moved to a module 'ext.gadget.refToolbarDialogs' depending on 'ext.gadget.refToolbarBase'
| |
| if (typeof CiteTB === 'undefined') {
| |
| var CiteTB = {
| |
| "Templates" : {}, // All templates
| |
| "Options" : {}, // Global options
| |
| "UserOptions" : {}, // User options
| |
| "DefaultOptions" : {}, // Script defaults
| |
| "ErrorChecks" : {} // Error check functions
| |
| };
| |
| }
| |
| | |
| // Only execute on edit, unless it is a user JS/CSS page
| |
| // TODO: Remove tests already done by [[MediaWiki:Gadget-refToolbar.js]]
| |
| if (
| |
| ( mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit' ) &&
| |
| ( ( mw.config.get('wgNamespaceNumber') !== 2 && mw.config.get('wgNamespaceNumber') !== 4 ) ||
| |
| ( mw.config.get('wgPageName').indexOf('.js') === -1 && mw.config.get('wgPageName').indexOf('.css') === -1 ) )
| |
| ) {
| |
| | |
| // TODO: Move this to [[MediaWiki:Gadget-refToolbarDialogs.css]] and add it to the definition of module 'ext.gadget.refToolbarDialogs'
| |
| mw.util.addCSS(".cite-form-td {"+
| |
| "height: 0 !important;"+
| |
| "padding: 0.1em !important;"+
| |
| "}");
| |
| | |
| // Default options, these mainly exist so the script won't break if a new option is added
| |
| CiteTB.DefaultOptions = {
| |
| "date format" : "<year>-<zmonth>-<zdate>",
| |
| "autodate fields" : [],
| |
| "months" : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
| |
| "modal" : true,
| |
| "autoparse" : false,
| |
| "expandtemplates": false
| |
| };
| |
| | |
| // Get an option - user settings override global which override defaults
| |
| CiteTB.getOption = function(opt) {
| |
| if (CiteTB.UserOptions[opt] !== undefined) {
| |
| return CiteTB.UserOptions[opt];
| |
| } else if (CiteTB.Options[opt] !== undefined) {
| |
| return CiteTB.Options[opt];
| |
| }
| |
| return CiteTB.DefaultOptions[opt];
| |
| };
| |