Revision a2179ea1
Von Moritz Bunkus vor etwa 4 Jahren hinzugefügt
SL/ClientJS.pm | ||
---|---|---|
123 | 123 |
run_once_for => 3, # kivi.run_once_for(<TARGET>, <ARGS>) |
124 | 124 |
|
125 | 125 |
scroll_into_view => 1, # $(<TARGET>)[0].scrollIntoView() |
126 |
|
|
127 |
set_cursor_position => 2, # kivi.set_cursor_position(<TARGET>, <ARGS>) |
|
126 | 128 |
); |
127 | 129 |
|
128 | 130 |
my %trim_target_for = map { ($_ => 1) } qw(insertAfter insertBefore appendTo prependTo); |
js/client_js.js | ||
---|---|---|
113 | 113 |
|
114 | 114 |
// ## jQuery UI dialog plugin ## |
115 | 115 |
|
116 |
// Opening and closing and closing a popup
|
|
116 |
// Opening and closing a popup |
|
117 | 117 |
else if (action[0] == 'dialog:open') kivi.popup_dialog(action[1]); |
118 | 118 |
else if (action[0] == 'dialog:close') $(action[1]).dialog('close'); |
119 | 119 |
|
... | ... | |
159 | 159 |
else if (action[0] == 'run') kivi.run(action[1], action.slice(2, action.length)); |
160 | 160 |
else if (action[0] == 'run_once_for') kivi.run_once_for(action[1], action[2], action[3]); |
161 | 161 |
else if (action[0] == 'scroll_into_view') $(action[1])[0].scrollIntoView(); |
162 |
else if (action[0] == 'set_cursor_position') kivi.set_cursor_position(action[1], action[2]); |
|
162 | 163 |
|
163 | 164 |
else console.log('Unknown action: ' + action[0]); |
164 | 165 |
|
js/kivi.js | ||
---|---|---|
662 | 662 |
$input.parent().replaceWith($area); |
663 | 663 |
$area.focus(); |
664 | 664 |
}; |
665 |
|
|
666 |
ns.set_cursor_position = function(selector, position) { |
|
667 |
var $input = $(selector); |
|
668 |
if (position === 'end') |
|
669 |
position = $input.val().length; |
|
670 |
|
|
671 |
$input.prop('selectionStart', position); |
|
672 |
$input.prop('selectionEnd', position); |
|
673 |
}; |
|
665 | 674 |
}); |
666 | 675 |
|
667 | 676 |
kivi = namespace('kivi'); |
Auch abrufbar als: Unified diff
ClientJS: Funktion zum Setzen der Cursorposition (z.B. in textareas)