Element.implement({ sep_nfa_show: function() { this.setStyle('display',''); }, sep_nfa_hide: function() { this.setStyle('display','none'); }, sep_nfa_visible: function() { if(this.getStyle('display') == 'none') { return false; } else { return true; } }, sep_nfa_toggle: function() { if(this.getStyle('display') == 'none') { this.sep_nfa_show(); } else { this.sep_nfa_hide(); } }, sep_nfa_update: function(html) { this.innerHTML = html; } }); function SEP_NewsfeedAdvanced_post(action_id, type) { data_string = ''; if(type == 3) { data_string = $('comment_post_form_'+action_id).toQueryString(); } myreq2 = new Request({ method: 'post', url: './user_newsfeed_advanced_ajax.php', data: '_ajaxReq=1&task=post&type='+type+'&action_id='+action_id+'&' + data_string, onSuccess: function(html){ $('ajax_inject_new_post_'+action_id).clone().injectBefore('ajax_inject_new_post_'+action_id).sep_nfa_update(html.replace(/\\n/g, '
')); $('comment_post_form_'+action_id).reset(); if(type == 1 || type == 2) {$('likes_buttons_'+action_id).sep_nfa_hide();} }, onFailure: function() {alert('Could not save your comment! Please try again!');} }).send(); } function SEP_NewsfeedAdvanced_show_edit_form(id) { if($('SEP_NewsfeedAdvanced_Edit_'+id).sep_nfa_visible()) { SEP_NewsfeedAdvanced_hide_edit_form(id); } else { $('SEP_NewsfeedAdvanced_Text_'+id).sep_nfa_hide(); $('SEP_NewsfeedAdvanced_Edit_'+id).sep_nfa_show(); $('SEP_NewsfeedAdvanced_Textarea_Edit_'+id).focus(); } } function SEP_NewsfeedAdvanced_hide_edit_form(id) { $('SEP_NewsfeedAdvanced_Edit_'+id).sep_nfa_hide(); $('SEP_NewsfeedAdvanced_Text_'+id).sep_nfa_show(); } function SEP_NewsfeedAdvanced_edit(id, type) { data_string = ''; if(type == 3) { data_string = $('comment_edit_form_'+id).toQueryString(); } myreq2 = new Request({ method: 'post', url: './user_newsfeed_advanced_ajax.php', data: '_ajaxReq=1&task=edit&type='+type+'&id='+id+'&' + data_string, onSuccess: function(html){ $('SEP_NewsfeedAdvanced_Text_'+id).sep_nfa_update(html.replace(/\\n/g, '
')); $('SEP_NewsfeedAdvanced_Edit_'+id).sep_nfa_hide(); $('SEP_NewsfeedAdvanced_Text_'+id).sep_nfa_show(); }, onFailure: function() {alert('Could not save your changes! Please try again!');} }).send(); } function SEP_NewsfeedAdvanced_delete(id) { myreq2 = new Request({ method: 'post', url: './user_newsfeed_advanced_ajax.php', data: '_ajaxReq=1&task=delete&id='+id, onSuccess: function(html){ $('SEP_NewsfeedAdvanced_BoxItem_'+id).destroy(); }, onFailure: function() {alert('Could not delete this comment! Please try again!');} }).send(); } function SEP_NewsfeedAdvanced_report(id) { myreq2 = new Request({ method: 'post', url: './user_newsfeed_advanced_ajax.php', data: '_ajaxReq=1&task=report&id='+id, onSuccess: function(){ $('SEP_NewsfeedAdvanced_ReportButton_'+id).destroy(); alert('Thank you for reporting this comment!'); }, onFailure: function() {alert('Could not send your report! Please try again!');} }).send(); } function SEP_NewsfeedAdvanced_toggle_box(action_id, display) { if(display == 'preview') { $('SEP_NewsfeedAdvanced_Box_Final_'+action_id).sep_nfa_hide(); if(SEP_NewsfeedAdvanced_AutoGrow_Instance) { $('SEP_NewsfeedAdvanced_Textarea_'+action_id).setStyle('height', SEP_NewsfeedAdvanced_AutoGrow_Instance.textarea_old_height); } $('SEP_NewsfeedAdvanced_Box_Preview_'+action_id).sep_nfa_show(); } else { $('SEP_NewsfeedAdvanced_Box_Preview_'+action_id).sep_nfa_hide(); $('SEP_NewsfeedAdvanced_Box_Final_'+action_id).sep_nfa_show(); $('SEP_NewsfeedAdvanced_Textarea_'+action_id).focus(); } } function SEP_NewsfeedAdvanced_ScrollTo(action_id) { offset = 300; div_position_y = $('SEP_NewsfeedAdvanced_Box_Final_'+action_id).getPosition().y; window.scrollTo(0, div_position_y-offset); } function SEP_NewsfeedAdvanced_Show_Hidden_Boxes(action_id) { $('SEP_NewsfeedAdvanced_ShowMoreButton_'+action_id).sep_nfa_hide(); $$('div.SEP_NewsfeedAdvanced_Box_Hidden_'+action_id).each(function(elm){ elm.sep_nfa_show();}); } function SEP_NewsfeedAdvanced_Check_MaxLength(field_id, max_length) { if($(field_id).value.length > max_length) { alert('Your comment is too long!'); return false; } return true; } function SEP_NewsfeedAdvanced_ItemOptions(mode, id) { if(mode == 'show') { $('SEP_NewsfeedAdvanced_Box_Header_Right_Inactive_'+id).sep_nfa_hide(); $('SEP_NewsfeedAdvanced_Box_Header_Right_Active_'+id).sep_nfa_show(); } else { // $('SEP_NewsfeedAdvanced_Box_Header_Right_Active_'+id).sep_nfa_hide(); // $('SEP_NewsfeedAdvanced_Box_Header_Right_Inactive_'+id).sep_nfa_show(); } } /* * Copyright (c) 2009 Gary Glass (www.bookballoon.com) * Modified by SEplugins */ var SEP_NewsfeedAdvanced_AutoGrow_Instance = null; var AutoGrow = new Class({ Implements: [Options, Events], options: { interval: 333, // update interval in milliseconds margin: 30, // gap (in px) to maintain between last line of text and bottom of textarea minHeight: 20 // minimum height of textarea }, periodical_timer: null, textarea_old_height: 0, initialize: function(textarea, options) { this.textarea = $(textarea); this.options.minHeight = textarea.clientHeight; this.setOptions(options); this.dummy = new Element("div", { styles: { "overflow-x" : "hidden", "position" : "absolute", "top" : 0, "left" : "-9999px" } }).setStyles(this.textarea.getStyles("font-size", "font-family", "width", "line-height", "padding")).inject(document.body); this.textarea_old_height = this.textarea.getStyle("height"); this.resize(); this.start(); }, resize: function() { var html = this.textarea.get('value').replace(/\n|\r\n/g, '
X'); if (this.dummy.get("html").toLowerCase() != html.toLowerCase()){ this.dummy.set("html", html); var triggerHeight = this.dummy.getSize().y + this.options.margin; if (this.textarea.clientHeight != triggerHeight) { var newHeight = Math.max(this.options.minHeight, triggerHeight); this.textarea.tween("height", newHeight); } } }, start: function() { this.periodical_timer = this.resize.periodical(this.options.interval, this); }, stop: function() { $clear(this.periodical_timer); } });