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,
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",
createEditTools: function ( placeholder ) {
var sel, id;
var box = document.createElement(
var prevSubset = 0, curSubset = 0;
box.id =
box.title = 'Kliknite na znak ili simbol da biste ga
// append user-defined sets
if ( window.charinsertCustom ) {
for ( id in charinsertCustom ) {
if ( !
}
}
Line 56 ⟶ 71:
// create drop-down select
sel = document.createElement( 'select' );
for ( id in
sel.options[sel.options.length] = new Option( id, id );
}
sel.selectedIndex = 0;
sel.style.marginRight = '.3em';
sel.title = 'Izaberite
sel.onchange = sel.onkeyup = selectSubset;
box.appendChild( sel );
Line 73 ⟶ 88:
selectSubset();
};
cursor = 'pointer';▼
}▼
box.appendChild( recall );
}
if ( getSelectedSection() ) {
sel.selectedIndex = getSelectedSection();
}
var m = cookieRe.exec( document.cookie );▼
sel.selectedIndex = parseInt( m[1] );▼
placeholder.parentNode.replaceChild( box, placeholder );
Line 100 ⟶ 106:
prevSubset = curSubset;
curSubset = sel.selectedIndex;
//save into
} catch ( err ) {▼
//hide other subsets
var pp = box.getElementsByTagName( 'p' ) ;
Line 118 ⟶ 119:
if ( !p ) {
p = document.createElement( 'p' );
p.className =
p.id = id;
if ( id == 'Arabic' || id == 'Hebrew' ) {
Line 124 ⟶ 125:
p.dir = 'rtl';
}
var tokens =
if ( window.charinsertCustom && charinsertCustom[id] ) {
if ( tokens.length > 0 ) {
Line 131 ⟶ 132:
tokens += charinsertCustom[id];
}
box.appendChild( p );
}
Line 150 ⟶ 151:
}
}
if ( token === '' || token === '_' ) {
addText(
} 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' );
if ( dle > 0 ) {
var path = tagOpen.substring( dle + 1 ).split( '.' );
Line 182 ⟶ 185:
handler = handler[path[i]];
}
} else {
tagOpen = tagOpen.replace( /\./g,' ' );
tagClose = tagClose ? tagClose.replace( /_/g,' ' ) : '';
tagOpen:
}
name = name || tagOpen + tagClose;
name = name.replace( /\\n/g,'' );
a.appendChild( document.createTextNode( name ) );
a.href =
paragraph.appendChild( a );
addText( ' ' );
Line 209 ⟶ 213:
paragraph.appendChild( document.createTextNode( txt ) );
}
if ( $currentFocused && $currentFocused.length ) {
$currentFocused.textSelection(
'encapsulateSelection', {
pre: e.data.tagOpen,
peri: e.data.sampleText,
post: e.data.tagClose
}
▲ return;
);
}
}
▲ },
},
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
window.updateEditTools = function () {
};
}
}; // end
} );
|