function region_append(region, obj, modname) { var wrp = []; wrp.push('
'); if (obj.children(":visible").length > 0) wrp.push('
'); else wrp.push('
'); wrp.push('' + modname + ''); wrp.push(''); wrp.push('
'); $("#"+REGIONS[region]+"_body").children(".order-machine").append(wrp.join("")) .children(".order-item:last").children(".item-content").append(obj); } function create_new_from_form(form, modvar, last_id) { var new_form = form.html().replace( new RegExp(modvar+'-'+last_id, 'g'), modvar+'-'+(last_id+1)); new_form = '
'+new_form+'
'; $("#"+modvar+"_set").append(new_form); } function get_item_field_value(item,field) { // item: DOM object created by 'region_append' function // field: "order-field" | "delete-field" | "region-field" if (field=="delete-field") return item.find("."+field).attr("checked"); else return item.find("."+field).val(); } function set_item_field_value(item,field, value) { // item: DOM object created by 'region_append' function // field: "order-field" | "delete-field" | "region-field" if (field=="delete-field") item.find("."+field).attr("checked",value); else if (field=="region-choice-field") { var old_region_id = REGION_MAP.indexOf(item.find("."+field).val()); item.find("."+field).val(REGION_MAP[value]); old_region_item = $("#"+REGIONS[old_region_id]+"_body"); old_region_item.children(".empty-machine-msg").hide(); if (old_region_item.children(".order-machine").children().length == 0) old_region_item.children(".empty-machine-msg").show(); new_region_item = $("#"+REGIONS[value]+"_body"); new_region_item.children(".empty-machine-msg").hide(); } else item.find("."+field).val(value); } function move_item (region_id, item) { poorify_rich(item); $("#"+REGIONS[region_id]+"_body").children(".order-machine").append(item); set_item_field_value(item, "region-choice-field", region_id); richify_poor(item); } function poorify_rich(item){ item.children(".item-content").hide(); if (item.find("div[id^=richtext]").length > 0) { var editor_id = item.find(".mceEditor").prev().attr("id"); tinyMCE.execCommand('mceRemoveControl',false,editor_id); } } function richify_poor(item){ item.children(".item-content").show(); if (item.find("div[id^=richtext]").length > 0) { var editor_id = item.find('textarea[name*=richtext]:visible').attr("id"); tinyMCE.execCommand('mceAddControl',false,editor_id); } } function zucht_und_ordnung(move_item) { for (var i=0; i