text
stringlengths 0
14.1k
|
---|
}, |
// Update the edit box's position as it gets dragged |
editDrag: function(e) { |
var left = this.editStartX + e.pointerX() - this.cursorStartX |
var top = this.editStartY + e.pointerY() - this.cursorStartY |
this.elements.editBox.style.left = left + 'px' |
this.elements.editBox.style.top = top + 'px' |
e.stop() |
}, |
// Start resizing the note |
resizeStart: function(e) { |
if (Note.debug) { |
console.debug(""Note#resizeStart (id=%d)"", this.id) |
} |
this.cursorStartX = e.pointerX() |
this.cursorStartY = e.pointerY() |
this.boxStartWidth = this.elements.box.clientWidth |
this.boxStartHeight = this.elements.box.clientHeight |
this.boxStartX = this.elements.box.offsetLeft |
this.boxStartY = this.elements.box.offsetTop |
this.boundsX = new ClipRange(10, this.elements.image.clientWidth - this.boxStartX - 5) |
this.boundsY = new ClipRange(10, this.elements.image.clientHeight - this.boxStartY - 5) |
this.dragging = true |
this.clearDocumentObservers() |
this.addDocumentObserver(""mousemove"", this.resize.bindAsEventListener(this)) |
this.addDocumentObserver(""mouseup"", this.resizeStop.bindAsEventListener(this)) |
e.stop() |
this.bodyHide() |
}, |
// Stop resizing teh note |
resizeStop: function(e) { |
if (Note.debug) { |
console.debug(""Note#resizeStop (id=%d)"", this.id) |
} |
this.clearDocumentObservers() |
this.boxCursorStartX = null |
this.boxCursorStartY = null |
this.boxStartWidth = null |
this.boxStartHeight = null |
this.boxStartX = null |
this.boxStartY = null |
this.boundsX = null |
this.boundsY = null |
this.dragging = false |
e.stop() |
}, |
// Update the note's dimensions as it gets resized |
resize: function(e) { |
var width = this.boxStartWidth + e.pointerX() - this.cursorStartX |
var height = this.boxStartHeight + e.pointerY() - this.cursorStartY |
width = this.boundsX.clip(width) |
height = this.boundsY.clip(height) |
this.elements.box.style.width = width + ""px"" |
this.elements.box.style.height = height + ""px"" |
var ratio = this.ratio() |
this.fullsize.width = width / ratio |
this.fullsize.height = height / ratio |
e.stop() |
}, |
// Save the note to the database |
save: function(e) { |
if (Note.debug) { |
console.debug(""Note#save (id=%d)"", this.id) |
} |
var note = this |
for (p in this.fullsize) { |
this.old[p] = this.fullsize[p] |
} |
this.old.raw_body = $('edit-box-text').value |
this.old.formatted_body = this.textValue() |
// FIXME: this is not quite how the note will look (filtered elems, <tn>...). the user won't input a <script> that only damages him, but it might be nice to ""preview"" the <tn> here |
this.elements.body.update(this.textValue()) |
this.hideEditBox(e) |
this.bodyHide() |
this.bodyfit = false |
var params = { |
""id"": this.id, |
""note[x]"": this.old.left, |
""note[y]"": this.old.top, |
""note[width]"": this.old.width, |
""note[height]"": this.old.height, |
""note[body]"": this.old.raw_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.