text
stringlengths 0
14.1k
|
---|
w = this.elements.body.offsetWidth |
h = this.elements.body.offsetHeight |
if (w/h < 1.6180339887) { |
/* for tall notes (lots of text), find more pleasant proportions */ |
lo = 140, hi = 400 |
do { |
last = w |
x = (lo+hi)/2 |
this.elements.body.style.minWidth = x + ""px"" |
w = this.elements.body.offsetWidth |
h = this.elements.body.offsetHeight |
if (w/h < 1.6180339887) lo = x |
else hi = x |
} while ((lo < hi) && (w > last)) |
} else if (this.elements.body.scrollWidth <= this.elements.body.clientWidth) { |
/* for short notes (often a single line), make the box no wider than necessary */ |
// scroll test necessary for Firefox |
lo = 20, hi = w |
do { |
x = (lo+hi)/2 |
this.elements.body.style.minWidth = x + ""px"" |
if (this.elements.body.offsetHeight > h) lo = x |
else hi = x |
} while ((hi - lo) > 4) |
if (this.elements.body.offsetHeight > h) |
this.elements.body.style.minWidth = hi + ""px"" |
} |
if (Prototype.Browser.IE) { |
// IE7 adds scrollbars if the box is too small, obscuring the text |
if (this.elements.body.offsetHeight < 35) { |
this.elements.body.style.minHeight = ""35px"" |
} |
if (this.elements.body.offsetWidth < 47) { |
this.elements.body.style.minWidth = ""47px"" |
} |
} |
this.bodyfit = true |
} |
this.elements.body.style.top = (this.elements.box.offsetTop + this.elements.box.clientHeight + 5) + ""px"" |
// keep the box within the document's width |
var l = 0, e = this.elements.box |
do { l += e.offsetLeft } while (e = e.offsetParent) |
l += this.elements.body.offsetWidth + 10 - dw |
if (l > 0) |
this.elements.body.style.left = this.elements.box.offsetLeft - l + ""px"" |
else |
this.elements.body.style.left = this.elements.box.offsetLeft + ""px"" |
this.elements.body.style.visibility = ""visible"" |
}, |
// Creates a timer that will hide the body text for the note |
bodyHideTimer: function(e) { |
if (Note.debug) { |
console.debug(""Note#bodyHideTimer (id=%d)"", this.id) |
} |
this.hideTimer = setTimeout(this.bodyHide.bindAsEventListener(this), 250) |
}, |
// Hides the body text for the note |
bodyHide: function(e) { |
if (Note.debug) { |
console.debug(""Note#bodyHide (id=%d)"", this.id) |
} |
this.elements.body.hide() |
if (Note.noteShowingBody == this) { |
Note.noteShowingBody = null |
} |
}, |
addDocumentObserver: function(name, func) |
{ |
document.observe(name, func); |
this.document_observers.push([name, func]); |
}, |
clearDocumentObservers: function(name, handler) |
{ |
for(var i = 0; i < this.document_observers.length; ++i) |
{ |
var observer = this.document_observers[i]; |
document.stopObserving(observer[0], observer[1]); |
} |
this.document_observers = []; |
}, |
// Start dragging the note |
dragStart: function(e) { |
if (Note.debug) { |
console.debug(""Note#dragStart (id=%d)"", this.id) |
} |
this.addDocumentObserver(""mousemove"", this.drag.bindAsEventListener(this)) |
this.addDocumentObserver(""mouseup"", this.dragStop.bindAsEventListener(this)) |
this.addDocumentObserver(""selectstart"", function() {return false}) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.