‘);
}
frm.after (comments);
obj.find (“div.pagination ul”). append (pagination);
setComments ();
setReplies ();
setDelete ();
};
loadComments = function (object_id, object_type, page) {
$ (“#object_id”). Val (object_id);
QST var = “mode = ajax & amp; object_id =” + object_id + “& amp; object_type =” + object_type + “& amp; page =” + page;
$ .ajax ({
url: ‘/include/include_comments_ajax.php’,
cache: false,
async: false,
Date: QST,
success: function (response) {
var = NUM_COMMENTS response.split (‘| # |’) [0];
var = response.split comments (‘| # |’) [1];
var = pagination response.split (‘| # |’) [2];
curr_page = response.split (‘| # |’) [3];
writeComments (NUM_COMMENTS, comments, pagination);
}
});
};
var ctrlComments = function () {
err_msg var = “”;
if ($ (“#author_name”). val () == “” || $ (“#author_name”). val () == $ (“#author_name”). attr (“placeholder”)) {
err_msg err_msg + = “Write your name n”;
};
if ($ (“#author_mail”). val () == “” || $ (“#author_mail”). val () == $ (“#author_mail”). attr (“placeholder”)) {
err_msg err_msg + = “Srivi your email n”;
};
if ($ (“#comment”). val () == “” || $ (“#comment”). val () == $ (“#comment”). attr (“placeholder”)) {
err_msg err_msg + = “Write a comment n”;
};
if (err_msg! = “”) {
alert (err_msg);
return false;
} Else {
return true;
};
};
var sendComments = function () {
var QST = $ (“# comments-form”). serialize ();
run.addClass (“disabled”);
$ .ajax ({
url: ‘/include/include_comments_upd_ajax.php’,
cache: false,
async: false,
Date: QST,
success: function (response) {
$ (“#comment”). Val (“”);
$ (“#comment”). Height ($ (“#comment”). Css (“min-height”));
if (response == “0″) {
alert (“We reserve the right to check the content of the comment inserted before its publication.”)
} Else if (response == “1″) {
loadComments (“1043″, “P”, 1);
} Else {
alert (response);
};
}
});
// Run.removeClass (“disabled”); // Comment for not publish a second comment after sending the first
};
var setFields = function () {
inp.each (function () {
if ($ (this) .data (“inputbox”)) {
$ (This) .data (“inputbox”). SetWidth ();
} Else {
$ (This) .inputbox ();
};
});
if (txt.data (“textbox”)) {
txt.data (“textbox”). setWidth ();
} Else {
txt.textbox ();
};
};
var setEmoticons = function () {
emo.click (function () {
txt.data (“textbox”). insertText ($ (this) .attr (‘title’));
});
};
var SetForm = function () {
frm.insertAfter (obj.find (“h4″));
setFields ();
esc.hide ();
rpl.show ();
del.show ();
obj.find (“input # order_by”). val (“”);
};
var setComments = function () {
var = com obj.find (“div.comment div.text”);
com.each (function () {
var obj = $ (this);
obj.css (“position”, “about”);
});
};
var setReplies = function () {
rpl = obj.find (“div.comment a.control.rpl”);
the obj.find = (“div.comment a.control.del”);
rpl.click (function () {
var elm = $ (this);
WRP elm.parent var = ();
var ref = wrp.attr (“date-ref”);
hgt frm.outerHeight var = ();
del.hide ();
rpl.hide ();
frm.insertAfter (wrp.find (“& gt; div.text”));
setFields ();
esc.show ();
frm.find (“input # order_by”). val (ref);
if (wrp.find (‘div.text’). checkscroll () == false) {
$ (‘Html, body’). Animate ({scrollTop: ‘- =’ + (hgt + wrp.find (‘div.comment div.text’). Height ())});
}
});
};
var setDelete = function () {
del.click (function () {
trg var = $ (this);
WRP trg.parent var = ();
var ref = wrp.attr (“date-ref”);
if (confirm (“Do you want to delete this comment?”)) {
QST var = “order_by =” + ref + “& amp; object_id = 1043 & amp; P = object_type”;
$ .ajax ({
url: ‘/include/include_comments_del_ajax.php’,
cache: false,
async: false,
Date: QST,
success: function (response) {
if (response == “1″) {
loadComments (“1043″, “P”, curr_page);
} Else {
alert (response);
};
}
});
};
});
}
$ (Document) .ready (function () {
writeComments (“14″, “”, “
“); inp.inputbox (); txt.textbox (); esc.hide (); setFields (); setEmoticons (); setComments (); run.click (function () {if (! $ (this) .hasClass (“disabled”)) {if (ctrlComments ()) {sendComments (); if (! $ (this) .parent (). parent () .attr (“id”)) {SetForm ();};};};}); esc.click (function () {if (! $ (this) .parent (). parent (). attr (“id”)) {SetForm ();};}); }); });
No comments:
Post a Comment