- var set_stage = function(key, opt) {
- var stage = $("select[name=stage] option[value!=]").eq(key).val();
- $.post($('input[name=chunk_mass_edit_url]').val(),
- {
- ids: get_ids(),
- stage: stage,
- },
- function(data, status) {
- location.reload(true);
- }
- );
+ var set_field = function(key, ops) {
+ var fds = {}
+ fds.stage = "";
+ fds.user = "";
+ fds.status = "";
+
+ if (key == "publish" || key == "unpublish") {
+ fds["status"] = key;
+ } else {
+ var kp = key.split('_');
+ var field = kp[0];
+ var idx = parseInt(kp[1]);
+
+ var target_field = field;
+ if (field == 'other-user')
+ target_field = 'user';
+
+ fds[target_field] = $("select[name="+field+"] option[value!=]").eq(idx).val();
+ }
+ /* fill in the form */
+ $("#chunk_mass_edit [name=ids]").val(get_ids());
+ for (var fn in fds) {
+ $("#chunk_mass_edit [name="+fn+"]").val(fds[fn]);
+ }
+
+ $.post($("#chunk_mass_edit").attr("action"),
+ $("#chunk_mass_edit").serialize(),
+ function(data, status) {
+ location.reload(true);
+ }
+ );
+ return true;
+
+