function templatechange() { showhidefrom(); showvariables(); } function hidelinks() { $('.client_id').hide(); $('.user_id').hide(); $('.project_id').hide(); } function hidefrom() { $('.mail_from').hide(); } function showhidefrom() { selectvalue=$('.type_id select').val(); $('.subject').show(); $('.mail_from').show(); if (selectvalue==1 || selectvalue==2 || selectvalue==3 || selectvalue==22) $('.mail_from').hide(); if (selectvalue==3) $('.subject').hide(); } function showvariables() { selectclass=$('.type_id select option:selected').attr('class'); // alert('tr.variables a.'+selectclass); // alert($('tr.variable a.'+selectclass).size()); //alert($('tr.variables a.variable').hasClass(selectclass)); $('tr.variable div').hide(); $('tr.variable div.'+selectclass).show(); } function clientChange(selectClient) { $('#userselect').attr("disabled", true);; $.post('template', { action: 'users', client_id:selectClient.value}, function(data) { var list = eval('(' + data + ')'); userselect=$('#userselect').get(0); for (i = (userselect.options.length - 1); i>=0; i--) userselect.options[i] = null; for (i in list) userselect.options[userselect.options.length] = new Option(list[i], i); $('#userselect').removeAttr("disabled"); }); $('#projectselect').attr("disabled", true);; $.post('template', { action: 'projects', client_id:selectClient.value}, function(data) { var list = eval('(' + data + ')'); projectselect=$('#projectselect').get(0); for (i = (projectselect.options.length - 1); i>=0; i--) projectselect.options[i] = null; for (i in list) projectselect.options[projectselect.options.length] = new Option(list[i], i); $('#projectselect').removeAttr("disabled"); }); } var lastinput=null; var editoractive=false; $(document).ready(function() { $('#filter_form select').change(function(e){e.target.form.submit()}); $('.variable a').click(function(e){ if (lastinput) $(lastinput).insertAtCaret(e.target.rel); else if(editoractive) { var oEditor = FCKeditorAPI.GetInstance('template_text') ; oEditor.InsertHtml(e.target.rel); } return false; }); $('#form_template input').focus(function(e){lastinput=e.target;editoractive=false}); }); function FCKeditor_OnComplete( editorInstance ) { editorInstance.Events.AttachEvent( 'OnFocus', dosave) ; } function dosave(editorInstance) { editoractive=true; lastinput=null; } $.fn.insertAtCaret = function (myValue) { return this.each(function(){ //IE support if (document.selection) { this.focus(); sel = document.selection.createRange(); sel.text = myValue; this.focus(); } //MOZILLA/NETSCAPE support else if (this.selectionStart || this.selectionStart == '0') { var startPos = this.selectionStart; var endPos = this.selectionEnd; var scrollTop = this.scrollTop; this.value = this.value.substring(0, startPos) + myValue + this.value.substring(endPos, this.value.length); this.focus(); this.selectionStart = startPos + myValue.length; this.selectionEnd = startPos + myValue.length; this.scrollTop = scrollTop; } else { this.value += myValue; this.focus(); } }); }; $(document).ready(function() { $('.empty').parent().parent().addClass("highlight").removeClass("odd"); });