function L(x) { // shortcut
if (window.console && window.console.log)
window.console.log(x);
}
function saveNote(form, thread_identifier) {
var issue_identifier = $(form.issue_identifier).val();
if (!$(form.comment).val().length) {
cancelSaveNote(form, issue_identifier, thread_identifier);
}
if (!thread_identifier) thread_identifier = '';
$.post(ROOT_URL + '/saveIssueNote', {
issue_identifier:issue_identifier,
thread_identifier:thread_identifier,
comment:$(form.comment).val()},
function(result) {
if (result && result.error) {
alert(result.error);
return;
}
if (result && result.note)
__show_note(issue_identifier, result.note);
cancelSaveNote(form, issue_identifier, thread_identifier);
},
"json");
}
function cancelSaveNote(form, issue_identifier, thread_identifier) {
if (thread_identifier)
$('a.new-note', '.thead').qtip('hide'); // hide all
else
$('a.new-note', '.ihead').qtip('hide');
}
function _basic_qtip_options(note) {
var title = note.date;
//if (note.fromname)
// title += " by " + note.fromname;
var text = note.comment;
return {
content: {
title: {
text: title
},
text:text
},
position: {
corner: {
tooltip: 'rightTop', // Use the corner...
target: 'leftBottom' // ...and opposite corner
}
},
style: {
border: {
width: 2,
radius: 4
},
padding: 3,
textAlign: 'left',
tip: true, // Give it a speech bubble tip with automatic corner detection
name: 'light'
}
};
}
function _qtip_options_by_title(jelement, corner) {
var title = jelement.attr('title');
var point = title.search(/\|/);
var text = title.substr(point+1, title.length);
title = title.substr(0, point);
if (!corner)
corner = {tooltip: 'rightTop',
target: 'leftBottom'};
return {
content: {
title: {
text: title
},
text:text
},
position: {corner: corner
},
style: {
width: { max:400, min:250 },
border: {
width: 2,
radius: 4
},
padding: 3,
textAlign: 'left',
tip: true, // Give it a speech bubble tip with automatic corner detection
name: 'light'
}
};
}
function __show_note(issue_identifier, note) {
var parent = $('#' + issue_identifier);
if (note.threadID) {
// the ID of the div for this followup is going to be the
// end of issue_identifier + '__' + note.threadID
var containerID = issue_identifier.split('__').pop() + '__' + note.threadID;
var container = $('.thead', '#' + containerID);
} else {
var container = $('.ihead', parent);
}
var link = $('').addClass('old-note').click(function() {
return false;
}).append(
$('
').attr('alt',note.title)
).qtip(_basic_qtip_options(note));
$('a.new-note', container).after(link);
//if (PREPEND_OLD_NOTES)
// container.prepend(link);
//else
// container.prepend(link);
}
function onblur_textarea(element) {
if (typeof enableKS != "undefined")
enableKS();
}
function onfocus_textarea(element) {
if (typeof disableKS != "undefined")
disableKS();
}
function _autoexpanding_textarea() {
if (_getNoLines(this) > parseInt(this.rows))
this.rows = '' + Math.min(_getNoLines(this) + 2, 15);
}
function _qtip_options(target, issue_identifier, thread_identifier, corner) {
var text = '';
if (thread_identifier)
text += '