Razlika između verzija stranice "MediaWiki:Gadget-charinsert-core.js"

Uklonjeni sadržaj Dodani sadržaj
m fix
mNo edit summary
Red 17:
 
jQuery( document ).ready( function ( $ ) {
var $currentFocused,
var EditTools = {
editTools;
 
function getSelectedSection() {
var selectedSection = mw.storage.get( editTools.storageKey )
|| mw.storage.session.get( editTools.storageKey );
return selectedSection;
},
function saveSelectedSection( newIndex ) {
mw.storage.set( editTools.storageKey, newIndex )
|| mw.storage.session.set( editTools.storageKey, newIndex );
}
editTools = {
// Entries prefixed with ␥ (U+2425 SYMBOL FOR DELETE FORM TWO) will not appear in the article namespace (namespace 0).
// Please make any changes to [[MediaWiki:Edittools]] as well, however, instead of using the ␥ symbol, use {{#ifeq:{{NAMESPACE}}|{{ns:0}}| | }}.
Line 36 ⟶ 51:
charinsertDivider: "\240",
 
cookieNamestorageKey: 'edittoolscharsubset',
 
createEditTools: function ( placeholder ) {
var sel, id;
var box = document.createElement( "'div"' );
var prevSubset = 0, curSubset = 0;
box.id = "'editpage-specialchars"';
box.title = 'Kliknite na znak ili simbol da biste ga ubaciteubacili u uređivač';
 
// append user-defined sets
if ( window.charinsertCustom ) {
for ( id in charinsertCustom ) {
if ( !EditToolseditTools.charinsert[id] ) {
EditToolseditTools.charinsert[id] = '';
}
}
Line 56 ⟶ 71:
// create drop-down select
sel = document.createElement( 'select' );
for ( id in EditToolseditTools.charinsert ) {
sel.options[sel.options.length] = new Option( id, id );
}
sel.selectedIndex = 0;
sel.style.marginRight = '.3em';
sel.title = 'Izaberite skuppodskup znakova';
sel.onchange = sel.onkeyup = selectSubset;
box.appendChild( sel );
Line 73 ⟶ 88:
selectSubset();
};
with ( recall.style.cssFloat )= {'left';
cssFloat = styleFloatrecall.style.marginRight = 'left5px';
marginRightrecall.style.cursor = '5pxpointer';
cursor = 'pointer';
}
box.appendChild( recall );
}
 
if ( getSelectedSection() ) {
// load latest selection from cookies
sel.selectedIndex = getSelectedSection();
try {
}
var cookieRe = new RegExp( "(?:^|;)\\s*" + EditTools.cookieName + "=(\\d+)\\s*(?:;|$)" );
var m = cookieRe.exec( document.cookie );
if ( m && m.length > 1 && parseInt( m[1] ) < sel.options.length ) {
sel.selectedIndex = parseInt( m[1] );
}
} catch ( err ) {
// ignore
}
 
placeholder.parentNode.replaceChild( box, placeholder );
Line 100 ⟶ 106:
prevSubset = curSubset;
curSubset = sel.selectedIndex;
//save into cookiesweb storage for persistence
trysaveSelectedSection( {curSubset );
var expires = new Date();
expires.setTime( expires.getTime() + 30 * 24 * 60 * 60 * 1000 ); // + 30 days
document.cookie = EditTools.cookieName + "=" + curSubset + ";path=/;expires=" + expires.toUTCString();
} catch ( err ) {
// ignore
}
//hide other subsets
var pp = box.getElementsByTagName( 'p' ) ;
Line 118 ⟶ 119:
if ( !p ) {
p = document.createElement( 'p' );
p.className = "'nowraplinks"';
p.id = id;
if ( id == 'Arabic' || id == 'Hebrew' ) {
Line 124 ⟶ 125:
p.dir = 'rtl';
}
var tokens = EditToolseditTools.charinsert[id];
if ( window.charinsertCustom && charinsertCustom[id] ) {
if ( tokens.length > 0 ) {
Line 131 ⟶ 132:
tokens += charinsertCustom[id];
}
EditToolseditTools.createTokens( p, tokens );
box.appendChild( p );
}
Line 150 ⟶ 151:
}
}
if ( token === '' || token === '_' ) {
addText( EditToolseditTools.charinsertDivider + ' ' );
} else if ( token === '\n' ) {
paragraph.appendChild( document.createElement( 'br' ) );
} else if ( token === '___' ) {
paragraph.appendChild( document.createElement( 'hr' ) );
} else if ( token.charAt( token.length-1 ) === ':' ) { // : at the end means just text
addBold( token );
} else if ( n === 0 ) { // +<tag> -> <tag>+</tag>
addLink( token.substring( 1 ), '</' + token.substring( 2 ), token.substring( 1 ) );
} else if ( n > 0 ) { // <tag>+</tag>
Line 175 ⟶ 176:
var handler;
var dle = tagOpen.indexOf( '\x10' );
var ma = cookieRedocument.execcreateElement( document.cookie'a' );
}
if ( dle > 0 ) {
var path = tagOpen.substring( dle + 1 ).split( '.' );
Line 182 ⟶ 185:
handler = handler[path[i]];
}
}$( catcha ).on( err'click', )handler {);
} else {
tagOpen = tagOpen.replace( /\./g,' ' );
tagClose = tagClose ? tagClose.replace( /_/g,' ' ) : '';
handler$( =a new Function).on( 'click', {
tagOpen: "evt"tagOpen,
cursor = sampleText: 'pointer';,
"mw.toolbar.insertTags('" + tagOpen + "', '" + tagClose + "', ''); evt.preventDefault(); return false;"
); tagClose: tagClose
sel.selectedIndex}, = parseInt( m[1]insertTags );
}
 
var a = document.createElement( 'a' );
name = name || tagOpen + tagClose;
name = name.replace( /\\n/g,'' );
a.appendChild( document.createTextNode( name ) );
a.href = "#"'';
$( a ).click( handler );
paragraph.appendChild( a );
addText( ' ' );
Line 209 ⟶ 213:
paragraph.appendChild( document.createTextNode( txt ) );
}
}, function insertTags( e ) {
return e.preventDefault();
 
if ( $currentFocused && $currentFocused.length ) {
last_active_textfield: null,
$currentFocused.textSelection(
 
'encapsulateSelection', {
registerTextField: function ( evt ) {
pre: e.data.tagOpen,
var e = evt || window.event;
peri: e.data.sampleText,
var node = e.target || e.srcElement;
post: e.data.tagClose
if ( !node ) {
}
return;
);
}
}
EditTools.last_active_textfield = node.id;
return true;
},
 
getTextArea: function () {
var txtarea = null;
if ( EditTools.last_active_textfield && EditTools.last_active_textfield != "" )
txtarea = document.getElementById( EditTools.last_active_textfield );
if ( !txtarea ) {
// Fallback option: old behaviour
if ( document.editform ) {
txtarea = document.editform.wpTextbox1;
} else {
// Some alternate form? Take the first one we can find
txtarea = document.getElementsByTagName( 'textarea' );
if ( txtarea.length > 0 ) {
txtarea = txtarea[0];
} else {
txtarea = null;
}
}
}
return txtarea;
},
 
Line 257 ⟶ 240:
$( '.editOptions' ).before( placeholder );
}
// Find the element that is focused
EditTools.createEditTools( placeholder );
$currentFocused = $( '#wpTextbox1' );
// Apply to dynamically created textboxes as well as normal ones
$( document ).on( 'focus', 'textarea, input:text', function () {
$currentFocused = $( this );
} );
 
// Used to determine where to insert tags
EditToolseditTools.createEditTools( placeholder );
window.updateEditTools = function () {
EditToolseditTools.createEditTools( $( '#editpage-specialchars' )[0] );
};
}
 
}; // end EditToolseditTools
 
EditToolseditTools.setup();
} );