35 updateMessage(msg); |
35 updateMessage(msg); |
36 } |
36 } |
37 }); |
37 }); |
38 } |
38 } |
39 |
39 |
|
40 /** |
|
41 * .. function:: ajaxBoxShowSelector(boxid, eid, unrelfname, |
|
42 * addfname, msg, |
|
43 * oklabel, cancellabel, |
|
44 * separator=None) |
|
45 * |
|
46 * Display an ajax selector within a box of regid `boxid`, for entity with eid |
|
47 * `eid`. |
|
48 * |
|
49 * Other parameters are: |
|
50 * |
|
51 * * `addfname`, name of the json controller method to call to add a relation |
|
52 * |
|
53 * * `msg`, message to display to the user when a relation has been added |
|
54 * |
|
55 * * `oklabel`/`cancellabel`, OK/cancel buttons label |
|
56 * |
|
57 * * `separator`, items separator if the field is multi-valued (will be |
|
58 * considered mono-valued when not specified) |
|
59 */ |
40 function ajaxBoxShowSelector(boxid, eid, |
60 function ajaxBoxShowSelector(boxid, eid, |
41 unrelfname, |
61 unrelfname, |
42 addfname, msg, |
62 addfname, msg, |
43 oklabel, cancellabel, |
63 oklabel, cancellabel, |
44 separator) { |
64 separator) { |
57 $input.keypress(function (evt) { |
77 $input.keypress(function (evt) { |
58 if (evt.keyCode == $.ui.keyCode.ENTER) { |
78 if (evt.keyCode == $.ui.keyCode.ENTER) { |
59 ajaxBoxValidateSelectorInput(boxid, eid, separator, addfname, msg); |
79 ajaxBoxValidateSelectorInput(boxid, eid, separator, addfname, msg); |
60 } |
80 } |
61 }); |
81 }); |
62 $input.cwautocomplete(unrelated, {multiple: true}); |
82 $input.cwautocomplete(unrelated, {multiple: Boolean(separator)}); |
63 var buttons = DIV({'class' : "sgformbuttons"}, |
83 var buttons = DIV({'class' : "sgformbuttons"}, |
64 A({href : "javascript: noop();", |
84 A({href : "javascript: noop();", |
65 onclick : cw.utils.strFuncCall('ajaxBoxValidateSelectorInput', |
85 onclick : cw.utils.strFuncCall('ajaxBoxValidateSelectorInput', |
66 boxid, eid, separator, addfname, msg)}, |
86 boxid, eid, separator, addfname, msg)}, |
67 oklabel), |
87 oklabel), |
68 ' / ', |
88 ' / ', |
69 A({'href' : "javascript: noop();", |
89 A({'href' : "javascript: noop();", |
70 'onclick' : '$("#' + holderid + '").empty()'}, |
90 'onclick' : '$("#' + holderid + '").empty()'}, |
71 cancellabel)); |
91 cancellabel)); |