function showMenu() {
document.getElementById('showMenuItem').style.display = 'none';
document.getElementById('hideMenuItem').style.display = '';
$("#editorMenu").slideDown('medium');
}
function hideMenu() {
$("#editorMenu").slideUp('medium');
document.getElementById('showMenuItem').style.display = '';
document.getElementById('hideMenuItem').style.display = 'none';
}
/*************************************************
* editors/queue *
*************************************************/
//Expand/collapse the filter box
function toggleFilters() {
var div = document.getElementById('filterTable');
if (div.style.display == 'none') {
div.style.display = '';
}
else {
div.style.display = 'none';
}
}
/*************************************************
* editors/review *
*************************************************/
//Array of possible actions
var actions = ['public', 'sandbox', 'superreview'];
//Simulate radio button group for action icons
function selectAction(action) {
var actionField = document.getElementById('actionField');
actionField.value = action;
//Select action and deselect other actions
for (var i = 0; i < actions.length; i++) {
if (actions[i] == action) {
color(actions[i]);
document.getElementById('details-' + actions[i]).style.display = '';
}
else {
bw(actions[i]);
document.getElementById('details-' + actions[i]).style.display = 'none';
}
}
$('#subform').show('medium');
}
//Turn an icon colored
function color(action) {
var icon = document.getElementById(action + 'Icon');
var span = document.getElementById(action);
icon.src = '../../../../img/developers/' + action + '-color.png';
span.className = 'action_color';
}
//Turn an icon bw
function bw(action) {
var icon = document.getElementById(action + 'Icon');
var span = document.getElementById(action);
icon.src = '../../../../img/developers/' + action + '-bw.png';
span.className = 'action_bw';
}
//Get number of selected files
function selectedFileCount() {
var filesSelected = 0;
var elements = document.getElementsByTagName('input');
for (var i = 0; i < elements.length; i++) {
if (elements[i].className == 'fileCheckbox' && elements[i].disabled == false) {
if (elements[i].checked == true) {
filesSelected++;
}
}
}
return filesSelected;
}
//Show notice if more than one file selected
function selectedFile() {
var filesSelected = selectedFileCount();
if (filesSelected > 1) {
document.getElementById('multipleNotice').style.display = '';
}
else {
document.getElementById('multipleNotice').style.display = 'none';
}
}
//Validate review form
function validateReview(type) {
if (type == 'pending') {
//Make sure at least one file is selected
var filesSelected = selectedFileCount();
if (filesSelected == 0) {
alert(localized['files']);
return false;
}
}
var errors = '';
//Make sure an action was selected
if (document.getElementById('actionField').value == '') {
errors += '- ' + localized['action'] + '\n';
}
//Make sure comments were entered
if (document.getElementById('comments').value == '') {
errors += '- ' + localized['comments'] + '\n';
}
if (type == 'pending') {
//Make sure tested operating system was entered
if (document.getElementById('ApprovalOs').value == '') {
errors += '- ' + localized['os'] + '\n';
}
//Make sure tested application was entered
if (document.getElementById('ApprovalApplications').value == '') {
errors += '- ' + localized['applications'] + '\n';
}
}
if (errors != '') {
alert(localized['errors'] + '\n' + errors);
return false;
}
else {
return true;
}
}
/*************************************************
* editors/reviewlog *
*************************************************/
//Show a review entry's comments
function showComments(id) {
document.getElementById('reviewComment_' + id).style.display = '';
document.getElementById('reviewShow_' + id).style.display = 'none';
document.getElementById('reviewHide_' + id).style.display = '';
document.getElementById('reviewEntry_' + id).className = 'reviewEntryActive';
}
//Hide a review entry's comments
function hideComments(id) {
document.getElementById('reviewComment_' + id).style.display = 'none';
document.getElementById('reviewShow_' + id).style.display = '';
document.getElementById('reviewHide_' + id).style.display = 'none';
document.getElementById('reviewEntry_' + id).className = '';
}
function clearInput(input) {
if (input.value == 'YYYY-MM-DD') {
input.value = '';
}
}
/*************************************************
* editors/featured *
*************************************************/
/*
Creates new autocomplete object for whichever input that just recieved focus.
Most likely done on focus to reduce # of objects instantiated on page load
*/
function prepAutocomplete(tagid) {
$('#new-addon-id-' + tagid).autocomplete(autocompleteurl, {minChars:4, formatItem: formatResult, formatValue: formatData });
$('#new-addon-id-' + tagid).focus();
}
//Formatting functions for autocomplete results returned from server
function formatResult(row) {
return '' + row[0] + '
' + row[1] + '';
}
function formatData(row) {
return row[2];
}
/*
Parses input for addon id and name, then sends to server
*/
function addFeatureSubmit(tagid) {
var addonid = document.getElementById('new-addon-id-' + tagid).value;
addonname = addonid.substring(0, addonid.lastIndexOf('['));
addonid = addonid.substring(addonid.lastIndexOf('[')+1, addonid.lastIndexOf(']'));
if (addonid.length == 0) {
editFeatureMessage(tagid, featureaddfailure, false);
return false;
}
$.ajax({
type: 'POST',
url: featuredurl + '/add/ajax',
data: $('#feature-add-form-'+tagid).serialize(),
success : function() {
$('#new-addon-id-' + tagid).attr('value', '');
addNewFeatureRowBeforeElement($('#feature-add-tr-form-' + tagid), tagid, addonid, addonname);
},
error : function() {
editFeatureMessage(tagid, featureaddfailure, false);
}
});
return false;
}
/*
After an addon is added to a featured list, it is added above the search box
*/
function addNewFeatureRowBeforeElement(sibling, tagid, addonid, addonname) {
// Sure would be nice if we had a newer Prototype library :(
var addonrow = document.createElement('tr');
addonrow.setAttribute('id', 'feature-' + tagid + '-' + addonid);
// First