Usuario:ElGatoSaez/addIDEButtons.js

De Wikipedia, la enciclopedia libre

Nota: Después de guardar, debes refrescar la caché de tu navegador para ver los cambios. Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar. Firefox: mientras presionas Mayús pulsas el botón Actualizar, (o presiona Ctrl-Shift-R). Los usuarios de Google Chrome y Safari pueden simplemente pulsar el botón Recargar. Para más detalles e instrucciones acerca de otros exploradores, véase Ayuda:Cómo limpiar la caché.

/*****************************************************************************
 * addIDEButtons.js
 *
 * Añade botones a la barra de herramientas, en la sección Avanzado, pero sólo
 * si se está editando Wikipedia:Informes_de_error.
 *
 * Los botones son útiles para responder los informes de error. Permiten responder
 * con {{ep|no hay error}}, {{ep|corregido}}, {{ep|trasladar tema}}, etc.
 *
 * (C) 2013 Gabriel A. Genellina
 *
 * Por la presente se concede permiso, sin cargo, a cualquier persona
 * que obtenga una copia de este software y de los archivos de documentación
 * asociados (el "Software"), para utilizar el Software sin restricciones,
 * incluyendo sin limitación los derechos de usar, copiar, modificar, fusionar,
 * publicar, distribuir, sublicenciar, y/o vender copias del Software, y
 * para permitir a las personas a las que se les proporcione el Software a
 * hacer lo mismo, sujeto a las siguientes condiciones:
 *
 * El aviso de copyright anterior y este aviso de permiso deberán ser incluidas
 * en todas las copias o partes sustanciales del Software.
 *
 * EL SOFTWARE SE PROPORCIONA "TAL CUAL", SIN GARANTÍA DE NINGÚN TIPO, EXPRESA
 * O IMPLÍCITA, INCLUYENDO PERO NO LIMITADO A GARANTÍAS DE COMERCIABILIDAD,
 * IDONEIDAD PARA UN PROPÓSITO PARTICULAR Y NO INFRACCIÓN. EN NINGÚN CASO LOS
 * AUTORES O TITULARES DEL COPYRIGHT SERÁN RESPONSABLES DE NINGUNA RECLAMACIÓN,
 * DAÑOS U OTRAS RESPONSABILIDADES, YA SEA EN UN LITIGIO, AGRAVIO O DE OTRO MODO,
 * QUE SURJA DE O EN CONEXIÓN CON EL SOFTWARE O EL USO U OTRO TIPO DE ACCIONES EN
 * EL SOFTWARE.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 *****************************************************************************/

var updateToolBar = function() {

  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'groups': {
                'IDEno': { 'label': 'IDE' },
                'IDEsi': { 'label': '' },
                'IDEvarios': { 'label': '' }
        }
  } );

  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'IDEno',
        tools: {
                "nohayerror": {
                        label: 'No hay error',
                        type: 'button',
                        icon: 'http://upload.wikimedia.org/wikipedia/commons/8/85/Symbol_unrelated.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{no hay error}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "nohayerror.falta": {
                        label: 'No hay error (falta)',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Symbol_dot_dot_dot.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{no hay error|falta}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "nohayerror.crea": {
                        label: 'No hay error (crear artículo)',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/d/df/Symbol_plain_red.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{no hay error|crea}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "nohayerror.categoria": {
                        label: 'No hay error (categoría)',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/d/db/Symbol_list_class.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{no hay error|categoría}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "no": {
                        label: 'No',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/45/Symbol_declined.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{No}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                }
        }
  } );

  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'IDEsi',
        tools: {
                "corregido": {
                        label: 'Corregido',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/41/Symbol_confirmed.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{corregido}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "hecho": {
                        label: 'Hecho',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/d/d0/Symbol_keep_vote.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{Hecho}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "revertido": {
                        label: 'Vandalismo revertido',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/3a/Symbol_redirect_vote_mirror.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        /* pre: ":{{Hecho|Revertido}} el vandalismo no detectado a tiempo. Gracias por avisar. ~~" + "~~", */
                                        pre: ":{{corregido|vandalismo}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "si": {
                        label: 'Sí',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/9/94/Symbol_support_vote.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{Sí}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                }
        }
  } );

  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'IDEvarios',
        tools: {
                "pregunta": {
                        label: 'Pregunta',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/e/e0/Symbol_question.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{pregunta}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "comentario": {
                        label: 'Comentario',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/8c/Symbol_information_vote.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: ":{{comentario}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "trasladar": {
                        label: 'Trasladar tema',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Symbol_deferred.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        post: ":{{trasladar tema}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                }
        }
  } );
};
 
/* sólo si la página es WP:IDE, y estamos en modo edit, y los módulos requeridos están disponibles */
if (mw.config.get( 'wgPageName' ) == 'Wikipedia:Informes_de_error') {
  if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor', function () {
                                $(document).ready( updateToolBar );
                        } );
                }
        } );
  }
}