kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
15 years ago
|
function initialize_editinplace(cancelButtonAttributes) {
|
||
|
_cancelButtonAttributes = cancelButtonAttributes;
|
||
|
}
|
||
|
|
||
15 years ago
|
function getCurrencyValue(str) {
|
||
15 years ago
|
var result = str.match(/^\s*(([0-9]+[.,])+[0-9]+) (.+)\s*/);
|
||
15 years ago
|
return result ? new Array(result[1], result[3]) : new Array(str, "");
|
||
15 years ago
|
}
|
||
|
|
||
|
function makeEditable(id, name){
|
||
15 years ago
|
var obj = $(id);
|
||
|
obj.addClassName("inline_editable");
|
||
15 years ago
|
Event.observe(id, 'click', function(){edit_and_focus(obj, name)});
|
||
15 years ago
|
|
||
15 years ago
|
}
|
||
|
|
||
|
function edit_and_focus(obj, name) {
|
||
|
edit(obj, name);
|
||
|
|
||
|
Form.Element.focus(obj.id+'_edit');
|
||
|
Form.Element.select(obj.id+'_edit');
|
||
|
}
|
||
|
|
||
|
function edit(obj, name, obj_value) {
|
||
|
Element.hide(obj);
|
||
15 years ago
|
|
||
15 years ago
|
var obj_value = typeof(obj_value) != 'undefined' ? obj_value : obj.innerHTML;
|
||
|
var parsed = getCurrencyValue(obj_value);
|
||
|
var value = parsed[0];
|
||
|
var currency = parsed[1]
|
||
|
|
||
15 years ago
|
var span_in = '<span id="'+obj.id+'_editor">'
|
||
15 years ago
|
var text = '<input id="'+obj.id+'_edit" name="'+name+'" size="7" value="'+value+'" class="currency" /> '+currency;
|
||
15 years ago
|
var button = '<input id="'+obj.id+'_cancel" type="image" '+ _cancelButtonAttributes +' /> ';
|
||
|
var span_end = '</span>';
|
||
15 years ago
|
|
||
15 years ago
|
new Insertion.After(obj, span_in+text+button+span_end);
|
||
15 years ago
|
|
||
15 years ago
|
Event.observe(obj.id+'_cancel', 'click', function(){cleanUp(obj)});
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
function cleanUp(obj){
|
||
15 years ago
|
Element.remove(obj.id+'_editor');
|
||
|
Element.show(obj);
|
||
|
}
|