2013-08-11 08:00:48 +00:00
|
|
|
/**
|
|
|
|
* Check or uncheck checkboxes in formElem
|
|
|
|
* If masterElem is false, toggle each box, otherwise use masterElem's status on all boxes
|
|
|
|
* If elemSelector is false, act on all checkboxes in formElem
|
|
|
|
*/
|
|
|
|
function toggleChecks(formElem, masterElem, elemSelector) {
|
|
|
|
elemSelector = elemSelector || 'input:checkbox';
|
|
|
|
if (masterElem) {
|
|
|
|
$('#'+formElem+' '+elemSelector).prop('checked', masterElem.checked);
|
2013-04-19 08:00:55 +00:00
|
|
|
} else {
|
2013-08-11 08:00:48 +00:00
|
|
|
$('#'+formElem+' '+elemSelector).each(function() {
|
|
|
|
this.checked = !this.checked;
|
|
|
|
})
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Lightbox stuff
|
2012-07-06 08:00:11 +00:00
|
|
|
|
2013-02-22 08:00:24 +00:00
|
|
|
/*
|
2013-04-19 08:00:55 +00:00
|
|
|
* If loading from a thumbnail, the lightbox is shown first with a "loading" screen
|
|
|
|
* while the full size image loads, then the HTML of the lightbox is replaced with the image.
|
2013-02-22 08:00:24 +00:00
|
|
|
*/
|
2012-07-06 08:00:11 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
var lightbox = {
|
|
|
|
init: function (image, size) {
|
2013-04-19 08:00:55 +00:00
|
|
|
if (typeof(image) == 'string') {
|
2013-06-17 08:01:02 +00:00
|
|
|
$('#lightbox').gshow().listen('click',lightbox.unbox).raw().innerHTML =
|
2013-04-19 08:00:55 +00:00
|
|
|
'<p size="7" style="color: gray; font-size: 50px;">Loading...<p>';
|
2013-06-17 08:01:02 +00:00
|
|
|
$('#curtain').gshow().listen('click',lightbox.unbox);
|
2013-04-19 08:00:55 +00:00
|
|
|
var src = image;
|
|
|
|
image = new Image();
|
2012-07-06 08:00:11 +00:00
|
|
|
image.onload = function() {
|
|
|
|
lightbox.box_async(image);
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
image.src = src;
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
if (image.naturalWidth === undefined) {
|
|
|
|
var tmp = document.createElement('img');
|
|
|
|
tmp.style.visibility = 'hidden';
|
|
|
|
tmp.src = image.src;
|
|
|
|
image.naturalWidth = tmp.width;
|
|
|
|
delete tmp;
|
|
|
|
}
|
|
|
|
if (image.naturalWidth > size) {
|
2013-02-22 08:00:24 +00:00
|
|
|
lightbox.box(image);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
box: function (image) {
|
2012-06-18 08:00:14 +00:00
|
|
|
var hasA = false;
|
2013-04-19 08:00:55 +00:00
|
|
|
if (image.parentNode != null && image.parentNode.tagName.toUpperCase() == 'A') {
|
2012-06-18 08:00:14 +00:00
|
|
|
hasA = true;
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!hasA) {
|
2013-06-17 08:01:02 +00:00
|
|
|
$('#lightbox').gshow().listen('click',lightbox.unbox).raw().innerHTML = '<img src="' + image.src + '" alt="" />';
|
|
|
|
$('#curtain').gshow().listen('click',lightbox.unbox);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
},
|
2012-07-06 08:00:11 +00:00
|
|
|
box_async: function (image) {
|
2013-04-19 08:00:55 +00:00
|
|
|
var hasA = false;
|
|
|
|
if (image.parentNode != null && image.parentNode.tagName.toUpperCase() == 'A') {
|
|
|
|
hasA = true;
|
|
|
|
}
|
|
|
|
if (!hasA) {
|
2013-06-17 08:01:02 +00:00
|
|
|
$('#lightbox').raw().innerHTML = '<img src="' + image.src + '" alt="" />';
|
2013-04-19 08:00:55 +00:00
|
|
|
}
|
|
|
|
},
|
2011-03-28 14:21:28 +00:00
|
|
|
unbox: function (data) {
|
2013-06-17 08:01:02 +00:00
|
|
|
$('#curtain').ghide();
|
|
|
|
$('#lightbox').ghide().raw().innerHTML = '';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Still some issues
|
|
|
|
function caps_check(e) {
|
|
|
|
if (e === undefined) {
|
|
|
|
e = window.event;
|
|
|
|
}
|
|
|
|
if (e.which === undefined) {
|
|
|
|
e.which = e.keyCode;
|
|
|
|
}
|
|
|
|
if (e.which > 47 && e.which < 58) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((e.which > 64 && e.which < 91 && !e.shiftKey) || (e.which > 96 && e.which < 123 && e.shiftKey)) {
|
2013-06-17 08:01:02 +00:00
|
|
|
$('#capslock').gshow();
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
function hexify(str) {
|
2013-04-19 08:00:55 +00:00
|
|
|
str = str.replace(/rgb\(|\)/g, "").split(",");
|
|
|
|
str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
|
|
|
|
str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
|
|
|
|
str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
|
|
|
|
str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
|
|
|
|
str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
|
|
|
|
str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
|
|
|
|
return (str.join(""));
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function resize(id) {
|
|
|
|
var textarea = document.getElementById(id);
|
|
|
|
if (textarea.scrollHeight > textarea.clientHeight) {
|
2011-08-09 21:03:28 +00:00
|
|
|
//textarea.style.overflowY = 'hidden';
|
|
|
|
textarea.style.height = Math.min(1000, textarea.scrollHeight + textarea.style.fontSize) + 'px';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//ZIP downloader stuff
|
|
|
|
function add_selection() {
|
|
|
|
var selected = $('#formats').raw().options[$('#formats').raw().selectedIndex];
|
|
|
|
if (selected.disabled === false) {
|
|
|
|
var listitem = document.createElement("li");
|
|
|
|
listitem.id = 'list' + selected.value;
|
|
|
|
listitem.innerHTML = ' <input type="hidden" name="list[]" value="'+selected.value+'" /> ' +
|
2013-04-19 08:00:55 +00:00
|
|
|
' <span style="float: left;">'+selected.innerHTML+'</span>' +
|
|
|
|
' <a href="#" onclick="remove_selection(\''+selected.value+'\');return false;" style="float: right;" class="brackets">X</a>' +
|
|
|
|
' <br style="clear: all;" />';
|
2011-03-28 14:21:28 +00:00
|
|
|
$('#list').raw().appendChild(listitem);
|
|
|
|
$('#opt' + selected.value).raw().disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_selection(index) {
|
|
|
|
$('#list' + index).remove();
|
|
|
|
$('#opt' + index).raw().disabled='';
|
|
|
|
}
|
|
|
|
|
2013-07-14 08:00:49 +00:00
|
|
|
// Thank you http://stackoverflow.com/questions/4578398/selecting-all-text-within-a-div-on-a-single-left-click-with-javascript
|
|
|
|
function select_all(el) {
|
|
|
|
if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {
|
|
|
|
var range = document.createRange();
|
|
|
|
range.selectNodeContents(el);
|
|
|
|
var sel = window.getSelection();
|
|
|
|
sel.removeAllRanges();
|
|
|
|
sel.addRange(range);
|
|
|
|
} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {
|
|
|
|
var textRange = document.body.createTextRange();
|
|
|
|
textRange.moveToElementText(el);
|
|
|
|
textRange.select();
|
|
|
|
}
|
|
|
|
}
|