Dyskusja MediaWiki:Gadget-sel t.js

Treść strony nie jest dostępna w innych językach.
Z Wikipedii, wolnej encyklopedii

Class(object): sel_t – manipulation of selection in an input field.

attributes[edytuj kod]

public[edytuj kod]

  • .version – version of the script

private[edytuj kod]

DO NOT USE THEM!

  • .isWikEdOn
  • .noSelection
  • .range
  • .sel_e
  • .sel_s

functions[edytuj kod]

public[edytuj kod]

getSelStr(input,nonempty)[edytuj kod]

In short: returns selected string in the given input.

Additionally if nothing is selected and nonempty is true then it returns full contents of the input; otherwise it returns an empty string.

setSelStr(input, str, nonempty)[edytuj kod]

In short: replaces current selection in the given input with str.

Additionally if nothing is selected and nonempty is true then it replaces all of the contents of the input; otherwise it inserts the string at the end.

Note: this method runs ScrollIntoView so you don't have to.

qsetSelStr(input, str, nonempty)[edytuj kod]

In short: replaces selection previously found with getSelStr.

Works the same as setSelStr but is quicker and must be used only after calling getSelStr.

Note: this method runs ScrollIntoView so you don't have to.

getSelBound(input)[edytuj kod]

Returns an object with boundaries of selection in the input. Returned object has following attributes:

  • start – 0 based postion of the start of the selection
  • end – 0 based postion of the end of the selection

This is aimed to work the same in all browsers (well IE) as selectionStart/End attributes of textarea does in other browsers. Should work the same in all of them.

setSelBound(input, sel_boundaries, scroll)[edytuj kod]

In short: set boundaries (sel_boundaries) of a selection in the input.

Optionally it can scroll the selection into view.

The sel_boundaries must have the following attributes:

  • start – 0 based postion of the start of the selection
  • end – 0 based postion of the end of the selection

Note: this is very similar to setSelRange.

setSelRange(input, sel_start, sel_end)[edytuj kod]

Selects the given range of text in the given input.

For backward compatibility only. Use setSelBound instead.

private[edytuj kod]

ScrollIntoView(input, sel_start, sel_end)[edytuj kod]

This method is used internally for Firefox to scroll selection into View.

For IE (if you are sure that selection is in the wanted input) you can use:

document.selection.createRange().scrollIntoView(true)