projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Insert link to author the user is replying to.
[Sone.git]
/
src
/
main
/
resources
/
static
/
javascript
/
sone.js
diff --git
a/src/main/resources/static/javascript/sone.js
b/src/main/resources/static/javascript/sone.js
index
1341cc0
..
d58f17f
100644
(file)
--- a/
src/main/resources/static/javascript/sone.js
+++ b/
src/main/resources/static/javascript/sone.js
@@
-33,7
+33,7
@@
function registerInputTextareaSwap(inputElement, defaultText, inputFieldName, op
inputField.val(defaultText);
}
}).hide().data("inputField", $(this)).val($(this).val());
inputField.val(defaultText);
}
}).hide().data("inputField", $(this)).val($(this).val());
- $(this).after(textarea);
+ $(this).
data("textarea", textarea).
after(textarea);
(function(inputField, textarea) {
inputField.focus(function() {
$(this).hide().attr("disabled", "disabled");
(function(inputField, textarea) {
inputField.focus(function() {
$(this).hide().attr("disabled", "disabled");
@@
-66,11
+66,11
@@
function registerInputTextareaSwap(inputElement, defaultText, inputFieldName, op
* @param element
* The element to add a “comment” link to
*/
* @param element
* The element to add a “comment” link to
*/
-function addCommentLink(postId, element, insertAfterThisElement) {
+function addCommentLink(postId,
author,
element, insertAfterThisElement) {
if (($(element).find(".show-reply-form").length > 0) || (getPostElement(element).find(".create-reply").length == 0)) {
return;
}
if (($(element).find(".show-reply-form").length > 0) || (getPostElement(element).find(".create-reply").length == 0)) {
return;
}
- commentElement = (function(postId) {
+ commentElement = (function(postId
, author
) {
separator = $("<span> · </span>").addClass("separator");
var commentElement = $("<div><span>Comment</span></div>").addClass("show-reply-form").click(function() {
replyElement = $("#sone .post#" + postId + " .create-reply");
separator = $("<span> · </span>").addClass("separator");
var commentElement = $("<div><span>Comment</span></div>").addClass("show-reply-form").click(function() {
replyElement = $("#sone .post#" + postId + " .create-reply");
@@
-85,10
+85,11
@@
function addCommentLink(postId, element, insertAfterThisElement) {
replyElement.removeClass("light");
});
})(replyElement);
replyElement.removeClass("light");
});
})(replyElement);
- replyElement.find("input.reply-input").focus();
+ textArea = replyElement.find("input.reply-input").focus().data("textarea");
+ textArea.val(textArea.val() + "@sone://" + author + " ");
});
return commentElement;
});
return commentElement;
- })(postId);
+ })(postId
, author
);
$(insertAfterThisElement).after(commentElement.clone(true));
$(insertAfterThisElement).after(separator);
}
$(insertAfterThisElement).after(commentElement.clone(true));
$(insertAfterThisElement).after(separator);
}
@@
-218,7
+219,8
@@
function enhanceDeletePostButton(button, postId, text) {
if (data.success) {
$("#sone .post#" + postId).slideUp();
} else if (data.error == "invalid-post-id") {
if (data.success) {
$("#sone .post#" + postId).slideUp();
} else if (data.error == "invalid-post-id") {
- alert("Invalid post ID given!");
+ /* pretend the post is already gone. */
+ getPost(postId).slideUp();
} else if (data.error == "auth-required") {
alert("You need to be logged in.");
} else if (data.error == "not-authorized") {
} else if (data.error == "auth-required") {
alert("You need to be logged in.");
} else if (data.error == "not-authorized") {
@@
-249,7
+251,8
@@
function enhanceDeleteReplyButton(button, replyId, text) {
if (data.success) {
$("#sone .reply#" + replyId).slideUp();
} else if (data.error == "invalid-reply-id") {
if (data.success) {
$("#sone .reply#" + replyId).slideUp();
} else if (data.error == "invalid-reply-id") {
- alert("Invalid reply ID given!");
+ /* pretend the reply is already gone. */
+ getReply(replyId).slideUp();
} else if (data.error == "auth-required") {
alert("You need to be logged in.");
} else if (data.error == "not-authorized") {
} else if (data.error == "auth-required") {
alert("You need to be logged in.");
} else if (data.error == "not-authorized") {
@@
-664,7
+667,7
@@
function ajaxifySone(soneElement) {
/* mark Sone as known when clicking it. */
$(soneElement).click(function() {
/* mark Sone as known when clicking it. */
$(soneElement).click(function() {
- markSoneAsKnown(
soneElement
);
+ markSoneAsKnown(
this
);
});
}
});
}
@@
-755,7
+758,7
@@
function ajaxifyPost(postElement) {
});
/* add “comment” link. */
});
/* add “comment” link. */
- addCommentLink(getPostId(postElement), postElement, $(postElement).find(".post-status-line .time"));
+ addCommentLink(getPostId(postElement),
getPostAuthor(postElement),
postElement, $(postElement).find(".post-status-line .time"));
/* process all replies. */
replyIds = [];
/* process all replies. */
replyIds = [];
@@
-815,7
+818,7
@@
function ajaxifyReply(replyElement) {
});
});
})(replyElement);
});
});
})(replyElement);
- addCommentLink(getPostId(replyElement), replyElement, $(replyElement).find(".reply-status-line .time"));
+ addCommentLink(getPostId(replyElement),
getReplyAuthor(replyElement),
replyElement, $(replyElement).find(".reply-status-line .time"));
/* convert “show source” link into javascript function. */
$(replyElement).find(".show-reply-source").each(function() {
/* convert “show source” link into javascript function. */
$(replyElement).find(".show-reply-source").each(function() {
@@
-999,6
+1002,10
@@
function getStatus() {
}
$(this).slideUp("normal", function() {
$(this).remove();
}
$(this).slideUp("normal", function() {
$(this).remove();
+ /* remove activity when no notifications are visible. */
+ if ($("#sone #notification-area .notification").length == 0) {
+ resetActivity();
+ }
});
}
});
});
}
});
@@
-1030,10
+1037,6
@@
function getStatus() {
$.each(data.newReplies, function(index, value) {
loadNewReply(value.id, value.sone, value.post, value.postSone);
});
$.each(data.newReplies, function(index, value) {
loadNewReply(value.id, value.sone, value.post, value.postSone);
});
- /* remove activity when no notifications are visible. */
- if ($("#sone #notification-area .notification").length == 0) {
- resetActivity();
- }
/* do it again in 5 seconds. */
setTimeout(getStatus, 5000);
} else {
/* do it again in 5 seconds. */
setTimeout(getStatus, 5000);
} else {
@@
-1333,9
+1336,6
@@
function updatePostTimes(postIds) {
* The tooltip to show
*/
function updateReplyTime(replyId, timeText, refreshTime, tooltip) {
* The tooltip to show
*/
function updateReplyTime(replyId, timeText, refreshTime, tooltip) {
- if (!getReply(replyId).is(":visible")) {
- return;
- }
getReply(replyId).find(".reply-status-line > .time").html(timeText).attr("title", tooltip);
(function(replyId, refreshTime) {
setTimeout(function() {
getReply(replyId).find(".reply-status-line > .time").html(timeText).attr("title", tooltip);
(function(replyId, refreshTime) {
setTimeout(function() {
@@
-1365,6
+1365,7
@@
function resetActivity() {
if (title.indexOf('(') == 0) {
setTitle(title.substr(title.indexOf(' ') + 1));
}
if (title.indexOf('(') == 0) {
setTitle(title.substr(title.indexOf(' ') + 1));
}
+ iconBlinking = false;
}
function setActivity() {
}
function setActivity() {
@@
-1403,7
+1404,7
@@
var iconBlinking = false;
* showing the activity state, it is returned to normal.
*/
function toggleIcon() {
* showing the activity state, it is returned to normal.
*/
function toggleIcon() {
- if (focus) {
+ if (focus
|| !iconBlinking
) {
if (iconActive) {
changeIcon("images/icon.png");
iconActive = false;
if (iconActive) {
changeIcon("images/icon.png");
iconActive = false;