Created
November 21, 2011 21:28
-
-
Save sash13/1384002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| $(".add2list").hide(); | |
| $('#staff').combobox({ | |
| 'input': true, | |
| 'style': 'ui-combo-light' | |
| // ,'ajax': '/profiler/form/autocomplete.json/'+$(this).attr('field') | |
| }); | |
| // ** show | |
| $("#staff_enabler").bind('click', function(){ | |
| $("#staff").show(); | |
| $(this).hide(); | |
| }); | |
| // ** "To" list | |
| $("#staff, #students").bind('change', function(){ | |
| var v = $(this).val(); | |
| if (!empty(v)) { | |
| // alert(1); | |
| $(".add2list", $(this).parent()).show(); | |
| } | |
| }); | |
| $(".add2list").bind('click', function(){ | |
| var cat = $(this).attr('lang'); | |
| if (empty(cat)) {cat = "staff";}else { | |
| $("input[name="+cat+"_only]").val(1); | |
| } | |
| var sel_el = $("#"+cat+" option:selected"); | |
| if (!empty(sel_el)) v = $(sel_el).val(); | |
| if (!empty(v)) { | |
| // ** init val | |
| var input_html = '<input name="recipient_id[]" type="hidden" value="'+ v + '" />'; | |
| // $(".box4list").after(); | |
| /* $(".input4list input").val(v); | |
| $(".input4list input").appendTo(".box4list"); | |
| // html = $(".input4list").html(); | |
| $(html).val(v); | |
| $(".box4list").after(html).filter('input').attr("value", v); | |
| alert(html);*/ | |
| // ** init title | |
| t = $(sel_el).text(); | |
| if (t.indexOf(",")>0) t = t.substr(0,t.indexOf(",")); | |
| var html = "<span class=rc_item>" + t + input_html + "[<b class=rc_del>x</b>], </span>"; | |
| // alert(v + t); | |
| box_text = ($(".box4list").text() == box4list_def)?"":$(".box4list").html(); | |
| $(".box4list").html(box_text + html); // t | |
| $(".rc_del").attr('title', "Видалити елемент").css('cursor','pointer'); | |
| } | |
| // alert(box4list_def); | |
| $("#box4list").show(); | |
| $("#"+cat+" option:first").attr("selected",true); | |
| $(this).hide(); | |
| // remove recipient btn | |
| $(".rc_del").bind('click', function(){ | |
| var box = $(this).parent(); | |
| // alert($(box).html()); | |
| $(box).remove(); | |
| }); | |
| }); | |
| // ** "To" list | |
| $("#groups").bind('change', function(){ | |
| var v = $(this).val(); | |
| if (!empty(v)) { | |
| $('#students').attr('disabled', 1); | |
| // alert($("#group_ug").val()); | |
| $.ajax({ | |
| type: "POST", | |
| dataType:"json", // html json | |
| url: "ajax/stu_by_group.php", | |
| data: "rec="+v +"&role="+$("#group_ug").val(), | |
| success: function(r){ | |
| $(".stuBoxA").attr("visibility", "hidden"); | |
| if (!empty(r.debug)) alert(r.debug); | |
| if (!empty(r)) { | |
| // alert( r.result + 'body: ' + r.items); | |
| // $("#msgFrom").html(r.items); | |
| var options = '<option value="">-- оберіть --</option>'; | |
| var tmp_str; | |
| // alert(r.items); | |
| if (!empty(r.items) && r.items!=true) { | |
| $(r.items).each(function() { | |
| tmp_str = tmp_str + " " + $(this).attr('id'); | |
| // alert($(this).attr('id')); | |
| options += '<option value="' + $(this).attr('id') + '">' + $(this).attr('name') + '</option>'; | |
| }); | |
| $('#students').html(options); | |
| $('#students').attr('disabled', false); | |
| } | |
| // alert(tmp_str + options); | |
| $(".stuBoxA").css("visibility", "visible").show(); | |
| } | |
| } | |
| }); | |
| // alert(v); | |
| // $(".add2list").show(); | |
| } | |
| }); | |
| // ** "To" list | |
| $("#struct_id").bind('change', function(){ | |
| var v = $(this).val(); | |
| if (!empty(v)) { | |
| location.href = ra+"index.php?mode=msg&create&struct_id="+v; | |
| } | |
| }); | |
| // alert("as"+base_url); | |
| var box4list_def = $(".box4list").text(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment