text
stringlengths 0
14.1k
|
---|
} |
if (this.is_new) { |
params[""note[post_id]""] = Note.post_id |
} |
notice(""Saving note..."") |
new Ajax.Request('/note/update.json', { |
parameters: params, |
onComplete: function(resp) { |
var resp = resp.responseJSON |
if (resp.success) { |
notice(""Note saved"") |
var note = Note.find(resp.old_id) |
if (resp.old_id < 0) { |
note.is_new = false |
note.id = resp.new_id |
note.elements.box.id = 'note-box-' + note.id |
note.elements.body.id = 'note-body-' + note.id |
note.elements.corner.id = 'note-corner-' + note.id |
} |
note.elements.body.innerHTML = resp.formatted_body |
note.elements.box.setOpacity(0.5) |
note.elements.box.removeClassName('unsaved') |
} else { |
notice(""Error: "" + resp.reason) |
note.elements.box.addClassName('unsaved') |
} |
} |
}) |
e.stop() |
}, |
// Revert the note to the last saved state |
cancel: function(e) { |
if (Note.debug) { |
console.debug(""Note#cancel (id=%d)"", this.id) |
} |
this.hideEditBox(e) |
this.bodyHide() |
var ratio = this.ratio() |
for (p in this.fullsize) { |
this.fullsize[p] = this.old[p] |
this.elements.box.style[p] = this.fullsize[p] * ratio + 'px' |
} |
this.elements.body.innerHTML = this.old.formatted_body |
e.stop() |
}, |
// Remove all references to the note from the page |
removeCleanup: function() { |
if (Note.debug) { |
console.debug(""Note#removeCleanup (id=%d)"", this.id) |
} |
this.elements.box.remove() |
this.elements.body.remove() |
var allTemp = [] |
for (i=0; i<Note.all.length; ++i) { |
if (Note.all[i].id != this.id) { |
allTemp.push(Note.all[i]) |
} |
} |
Note.all = allTemp |
Note.updateNoteCount() |
}, |
// Removes a note from the database |
remove: function(e) { |
if (Note.debug) { |
console.debug(""Note#remove (id=%d)"", this.id) |
} |
this.hideEditBox(e) |
this.bodyHide() |
this_note = this |
if (this.is_new) { |
this.removeCleanup() |
notice(""Note removed"") |
} else { |
notice(""Removing note..."") |
new Ajax.Request('/note/update.json', { |
parameters: { |
""id"": this.id, |
""note[is_active]"": ""0"" |
}, |
onComplete: function(resp) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.