Usuario:SRuizR/Botónbienvenida.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.
 * 
 * Versión propia de la versión original de GGenellina Usuario:Ggenellina/addIDEButtons.js adaptada para tener botones para dar bienvenidas
 *
 * (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' }
        }
  } );

  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'IDEno',
        tools: {
                "bienvenida.cuenta": {
                        label: 'Bienvenida a usuario registrado',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Symbol_R_orange.svg/22px-Symbol_R_orange.svg.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{" + "sust:Bienvenida}} ",
                                        post: "~~" + "~~",
                                        ownline: true
                                }
                        }
                },
                "bienvenida.anonimo": {
                        label: 'Bienvenida a usuario anónimo',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Symbol_dot_dot_dot_violet.svg/22px-Symbol_dot_dot_dot_violet.svg.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{" + "sust:Bienvenida|IP}} ~~" + "~~",
                                        ownline: true
                                }
                        }
                }
        }
  } );

};
 
/* sólo si la página es una discusión de usuario, y estamos en modo edit, y los módulos requeridos están disponibles */
if (mw.config.get( 'wgPageName' ) == 'Usuario discusión:Usuario') {
  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 );
                        } );
                }
        } );
  }
}