modified : comments enter press bug fixed

This commit is contained in:
Fahad Abbas 2015-10-19 13:22:41 +00:00
parent a4a61b0b36
commit 42e18bb097
4 changed files with 23 additions and 31 deletions

View file

@ -679,6 +679,7 @@ if(!empty($mode))
case 'add_comment';
{
$type = $_POST['type'];
$comment = mysql_clean($_POST['comment']);
switch($type)
{
case 'v':
@ -686,7 +687,6 @@ if(!empty($mode))
default:
{
$id = mysql_clean($_POST['obj_id']);
$comment = mysql_clean($_POST['comment']);
if($comment=='undefined')
$comment = '';
$reply_to = $_POST['reply_to'];
@ -699,7 +699,6 @@ if(!empty($mode))
{
$id = mysql_clean($_POST['obj_id']);
$comment = $_POST['comment'];
if($comment=='undefined')
$comment = '';
$reply_to = $_POST['reply_to'];
@ -712,7 +711,6 @@ if(!empty($mode))
{
$id = mysql_clean($_POST['obj_id']);
$comment = $_POST['comment'];
if($comment=='undefined')
$comment = '';
$reply_to = $_POST['reply_to'];
@ -725,7 +723,6 @@ if(!empty($mode))
case 'collection':
{
$id = mysql_clean($_POST['obj_id']);
$comment = $_POST['comment'];
if($comment=='undefined')
$comment = '';
$reply_to = $_POST['reply_to'];
@ -738,7 +735,6 @@ if(!empty($mode))
case "photo":
{
$id = mysql_clean($_POST['obj_id']);
$comment = $_POST['comment'];
if($comment=='undefined')
$comment = '';
$reply_to = $_POST['reply_to'];

View file

@ -429,6 +429,7 @@ class myquery {
*/
function add_comment($comment,$obj_id,$reply_to=NULL,$type='v',$obj_owner=NULL,$obj_link=NULL,$force_name_email=false)
{
global $userquery,$eh,$db,$Cbucket;
//Checking maximum comments characters allowed
if(defined("MAX_COMMENT_CHR"))
@ -438,9 +439,9 @@ class myquery {
{
e(sprintf("'%d' characters allowed for comment",MAX_COMMENT_CHR));
}
elseif ( $comment_len < 15 )
elseif ( $comment_len < 5 )
{
e("Comment is too short. It should be atleast 15 characters");
e("Comment is too short. It should be atleast 5 characters");
}
}
if(!verify_captcha())
@ -479,7 +480,7 @@ class myquery {
$name = mysql_clean($_POST['name']);
$email = mysql_clean($_POST['email']);
}
//pr(error_list(),true);
if(empty($eh->error_list))
{
$db->insert(tbl("comments"),array

View file

@ -1729,16 +1729,7 @@ function decode64(input) {
}
function comment_onEnter() {
$('textarea').bind("enterKey",function(e){
});
$('textarea').keyup(function(e){
if(e.keyCode == 13 && !e.shiftKey)
{
add_comment_js('comment_form','{$type}','$vdo.video_id');
}
});
}
function add_comment_js(form_id,type)
{
@ -1747,22 +1738,11 @@ function decode64(input) {
$("#add_comment_button").attr("disabled",true);
$(".add-reply").attr("disabled",true);
$('textarea').bind("enterKey",function(e){
});
$('textarea').keyup(function(e){
if(e.keyCode == 13 && !e.shiftKey)
{
add_comment_js('comment_form','{$type}','$vdo.video_id');
}
});
//var captcha_enabled = $("#" + form_id + " input:#cb_captcha_enabled").val();
//First we will get all values of form_id and then serialize them
//so we can forward details to ajax.php
var formObjectData = $('#' + form_id).serialize() + '&mode=add_comment';
console.log(formObjectData);
$.post(page,formObjectData,
function(data)
{

View file

@ -47,7 +47,7 @@
<textarea name="comment" id="comment_box" class="form-control" placeholder="Please type something in a comment box"></textarea>
</div>
<div class="col-lg-12" style="margin:15px 0 15px 0;">
<input type="button" name="add_comment" id="add_comment_button" class="btn btn-primary btn-block" onclick="add_comment_js('comment_form','{$type}','$vdo.video_id')" value='Add Comment'>
<input type="button" name="add_comment" id="add_comment_button" class="btn btn-primary btn-block" value='Add Comment'>
</div>
<div class="col-lg-10 col-md-9 col-sm-9 col-xs-9" id="msg_container"></div>
</form>
@ -61,5 +61,20 @@
</div>
<script type="text/javascript">
comment_onEnter();
$(document).ready(function(){
var form_selector = 'comment_form';
var type = '{$type}';
var video_id = '{$vdo.video_id}';
$('body').on("click","#add_comment_button",function(){
add_comment_js(form_selector,type,video_id);
});
$('#comment_box').keypress(function(e){
if(e.keyCode == 13 && !e.shiftKey)
{
e.preventDefault();
add_comment_js(form_selector,type,video_id);
}
});
});
</script>