or other dynamically loaded/created element to "activate" it
$canvas.bind("refresh", function (evt) {
var context = evt.target;
//console.log('refresh');
$("section.section1 > div.wrapper", $canvas).autoscrollable();
/* Draggable + resizable Sections {{{ */
$("section.section1", $canvas).bind('mousedown', function(e) {
e.stopPropagation();
}).draggable({
cancel: 'span.edit',
scroll: true,
handle: 'h1',
delay: 200, // NOTE: Prevents unwanted saves
stop: function () {
// Makes sur the annotation doesn't get a negative offset
var position = $(this).position();
if (position.top < 0) {
$(this).css('top', 0);
}
if (position.left < 0) {
$(this).css('left', 0);
}
$(this).trigger('geometrychange');
}
}).resizable({
stop: function () {
$(this).trigger('geometrychange');
}
});
/* }}} */
/* Renumber all sections {{{ */
$('section', $canvas).not('[data-section="-1"]').each(function (i) {
$(this).attr("data-section", (i + 1));
});
/* }}} */
// Section edit {{{ */
// Create & insert edit links in every section's Header that trigger the section's "edit" event
$(context).ffind('section').each(function () {
var $h1 = $("h1", this);
$("✎").addClass("edit").attr('title', 'Edit this annotation in place').click(function () {
$(this).closest("section").trigger("edit");
}).prependTo($(":header:first", this));
var about = $(this).closest("section.section1").attr('about');
$("@").addClass("about").hover(function () {
$('.player[src="' + about + '"], section[about="' + about + '"]', $canvas).addClass('highlight');
}, function() {
$('.player[src="' + about + '"], section[about="' + about + '"]', $canvas).removeClass('highlight');
}).prependTo($h1);
$(this).find("h1, h2").bind('dblclick', function(event) {
event.stopImmediatePropagation();
var section = $(this).closest("section");
if (! section.hasClass('editing')) {
section.toggleClass('collapsed');
section.trigger("geometrychange");
}
})
.filter('h1')
.attr('title', 'Drag to move. Double-click to open/close.')
.end()
.filter('h2')
.attr('title', 'Double-click to open/close.');
var nonhead = $(this).children(":not(:header)");
var wrapped = $('').append(nonhead);
$(this).append(wrapped);
}).bind("geometrychange", function (event) {
event.stopPropagation();
if (! $('body').hasClass('locked')) {
// Prevents anonymous users from recording the changes
// Prevents recording changes on old revisions
commit_attributes(this);
}
}).bind("edit", function (evt) {
function edit (data) {
var position = $(that).css("position");
var section_height = Math.min($(window).height() - 28, $(that).height());
var use_height = (position == "absolute") ? section_height : section_height;
var f = $("").addClass("section_edit").appendTo(that);
var textarea = $("