2011-07-09 01:00:46 +00:00
|
|
|
|
|
|
|
// jquery-colorbox browsable photo gallery
|
|
|
|
|
2013-06-08 17:08:09 +00:00
|
|
|
// TODO(mpl): something about camligroup is broken,
|
|
|
|
// hence why the call to it is commented out.
|
|
|
|
// Not worth fixing for now as I suppose we may replace
|
|
|
|
// all this with some closure eye candy eventually?
|
2011-07-09 01:00:46 +00:00
|
|
|
function addColorboxen() {
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('li > a').each(function() {
|
|
|
|
this.setAttribute('rel', 'camligroup');
|
|
|
|
})
|
|
|
|
$('a[rel="camligroup"]').colorbox({
|
|
|
|
transition:'none',
|
|
|
|
width: '75%',
|
|
|
|
height: '75%',
|
|
|
|
top: '30px',
|
|
|
|
open: false,
|
|
|
|
href: function() {
|
|
|
|
return $(this).parent().find('.camlifile a').attr('href');
|
|
|
|
},
|
|
|
|
title: function() {
|
|
|
|
return $($(this).parent().find('a').get(0)).text();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-07-11 19:10:35 +00:00
|
|
|
var titleInput, editLink;
|
2011-07-09 01:00:46 +00:00
|
|
|
function init() {
|
|
|
|
$(document).ready(function() {
|
2011-07-11 19:10:35 +00:00
|
|
|
// Before the images are loaded, rewrite the urls to include the square
|
|
|
|
// parameter.
|
|
|
|
$('li img').each(function() {
|
|
|
|
this.src = this.src + '&square=1';
|
|
|
|
});
|
|
|
|
|
2011-07-09 01:00:46 +00:00
|
|
|
if (camliViewIsOwner) {
|
|
|
|
$('body').addClass('camliadmin');
|
|
|
|
|
2011-07-11 19:10:35 +00:00
|
|
|
editLink = $(document.createElement('a'));
|
|
|
|
editLink.attr('#');
|
|
|
|
editLink.addClass('pics-edit');
|
|
|
|
editLink.html('edit title');
|
|
|
|
editLink.click(function(e) {
|
|
|
|
editTitle();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
titleInput = $(document.createElement('input'));
|
2011-07-09 01:00:46 +00:00
|
|
|
titleInput.blur(function() {
|
2011-07-11 19:10:35 +00:00
|
|
|
saveImgTitle($(this));
|
|
|
|
});
|
|
|
|
titleInput.bind('keypress', function(e) {
|
|
|
|
if (e.keyCode == 13) {
|
|
|
|
saveImgTitle($(this));
|
2011-07-09 01:00:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-07-11 19:10:35 +00:00
|
|
|
$('li').mouseenter(function(e) {
|
|
|
|
$(this).find('img').after(editLink);
|
|
|
|
editLink.show();
|
|
|
|
});
|
|
|
|
$('li').mouseleave(function(e) {
|
|
|
|
editLink.hide();
|
2011-07-09 01:00:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-07-11 19:10:35 +00:00
|
|
|
function editTitle() {
|
|
|
|
var titleSpan = editLink.next();
|
|
|
|
titleInput.val(titleSpan.text());
|
|
|
|
titleSpan.parent().after(titleInput);
|
|
|
|
titleInput.show();
|
|
|
|
titleInput.focus();
|
|
|
|
titleInput.select();
|
|
|
|
titleSpan.hide();
|
|
|
|
editLink.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveImgTitle(titleInput) {
|
|
|
|
var spanTitle = titleInput.parent().find('a span');
|
|
|
|
var spanText = spanTitle.text();
|
|
|
|
var newVal = titleInput.val();
|
|
|
|
if (spanText != newVal) {
|
|
|
|
spanTitle.text(newVal);
|
|
|
|
var blobRef = titleInput.parent().attr('id').replace(/^camli-/, '');
|
|
|
|
camliNewSetAttributeClaim(
|
|
|
|
blobRef,
|
|
|
|
"title",
|
|
|
|
newVal,
|
|
|
|
{
|
|
|
|
success: function() {
|
|
|
|
titleInput.hide();
|
|
|
|
spanTitle.show();
|
|
|
|
spanTitle.effect('highlight', {}, 300);
|
|
|
|
},
|
|
|
|
fail: function(msg) {
|
|
|
|
alert(msg);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
titleInput.hide();
|
|
|
|
spanTitle.show();
|
|
|
|
}
|
|
|
|
|
2011-07-09 01:00:46 +00:00
|
|
|
// Installs jQuery and the colorbox library along with an onload listener
|
|
|
|
// to fire the init function above.
|
|
|
|
if (typeof window['jQuery'] == 'undefined') {
|
|
|
|
document.write('<link media="screen" rel="stylesheet" href="//colorpowered.com/colorbox/core/example1/colorbox.css">');
|
2011-07-11 19:10:35 +00:00
|
|
|
document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" onload="init()"></sc'+'ript>');
|
|
|
|
document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"></sc'+'ript>');
|
2013-06-08 17:08:09 +00:00
|
|
|
// document.write('<scr'+'ipt src="//colorpowered.com/colorbox/core/colorbox/jquery.colorbox.js" onload="addColorboxen()"></sc'+'ript>');
|
2011-07-09 01:00:46 +00:00
|
|
|
}
|