alert('ok');\r
},\r
\r
- insert_comment: function(post_id, comment_id, comment, username, profile_url, delete_url, edit_url, convert_url, can_convert) {\r
+ insert_comment: function(post_id, comment_id, comment, username, profile_url, delete_url, edit_url, convert_url, can_convert, show_latest_comments_first) {\r
var $container = $('#comments-container-' + post_id);\r
var skeleton = $('#new-comment-skeleton-' + post_id).html().toString();\r
\r
.replace(new RegExp('%DELETE_URL%', 'g'), delete_url)\r
.replace(new RegExp('%EDIT_URL%', 'g'), edit_url)\r
.replace(new RegExp('%CONVERT_URL%', 'g'), convert_url);\r
-\r
- $container.append(skeleton);\r
+ if (show_latest_comments_first) {\r
+ $container.prepend(skeleton);\r
+ } else {\r
+ $container.append(skeleton);\r
+ }\r
\r
// Show the convert comment to answer tool only if the current comment can be converted\r
if (can_convert == true) {\r
$diag.fadeOut('fast', function() {\r
$diag.remove();\r
});\r
- }\r
+ };\r
\r
var options = {\r
extra_class: '',\r
copy_id = ' id="copy_clip_button"'\r
}\r
\r
- if (options.event != undefined) {\r
+ if (options.event != undefined && options.event.pageX != undefined && options.event.pageY != undefined) {\r
options.pos = {x: options.event.pageX, y: options.event.pageY};\r
+ } else if (options.event.currentTarget != undefined) {\r
+ var el = jQuery("#" + options.event.currentTarget.id);\r
+ var position = el.offset();\r
+ options.pos = {\r
+ x: position.left,\r
+ y: position.top\r
+ }\r
}\r
\r
- var html = '<div class="dialog ' + options.extra_class + '" style="display: none;">'\r
+ var html = '<div class="dialog ' + options.extra_class + '" style="display: none; z-index: 999;">'\r
+ '<div class="dialog-content">' + options.html + '</div><div class="dialog-buttons">';\r
\r
if (options.show_no) {\r
\r
html += '<button class="dialog-yes"' + copy_id + '>' + options.yes_text + '</button>' + '</div></div>';\r
\r
- $dialog = $(html);\r
+ var $dialog = $(html);\r
+\r
$('body').append($dialog);\r
var message = $('.dialog-content')[0];\r
message.style.visibility = "hidden";\r
message.style.visibility = "visible";\r
});\r
\r
- $dialog.find('.dialog-no').click(function() {\r
- default_close_function($dialog);\r
- });\r
-\r
$dialog.find('.dialog-yes').click(function() {\r
options.yes_callback($dialog);\r
});\r
\r
+ if (options.hasOwnProperty("no_callback")) {\r
+ $dialog.find('.dialog-no:first-child').click(function() {\r
+ options.no_callback($dialog);\r
+ });\r
+ } else {\r
+ $dialog.find('.dialog-no:first-child').click(function() {\r
+ default_close_function($dialog);\r
+ });\r
+ }\r
+\r
if (options.close_on_clickoutside) {\r
$dialog.one('clickoutside', function() {\r
default_close_function($dialog);\r
if (!data.success && data['error_message'] != undefined) {\r
show_message(evt, data.error_message, function() {if (callback) callback(true);});\r
end_command(false);\r
- } else if (typeof data['commands'] != undefined){\r
+ }\r
+ if (typeof data['commands'] != undefined){\r
for (var command in data.commands) {\r
response_commands[command].apply(null, data.commands[command])\r
\r
return false;\r
});\r
\r
+ // Submit comment with CTRL + Enter\r
+ $textarea.keydown(function(e) {\r
+ if (e.ctrlKey && e.keyCode == 13 && !$button.attr('disabled')) {\r
+ // console.log('submit');\r
+ $(this).parent().find('input.comment-submit').click();\r
+ }\r
+ });\r
+\r
$cancel.click(function(event) {\r
if (confirm("You will lose all of your changes in this comment. Do you still wish to proceed?")){\r
if (comment_in_form) {\r