// ---------------------------------------------------------------------------- // adminMenuDatabaseEditor.js // Copyright (C) 2005, All Rights Reserved // ---------------------------------------------------------------------------- // This program is protected by domestic and international copyright laws. Any // use of this program is subject to the the terms of the license agreement // included as part of this distribution archive. Any other uses are stictly // prohibited without the written permission of the Vendor and all other // rights are reserved. // ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Function : // Description : // Usage : // ----------------------------------------------------------------------------- function fieldEditPageInit() { // display appropriate fields for selected fieldtype var fieldTypeElement = document.getElementById('appFieldType'); showOptionsForFieldType( fieldTypeElement ); // create list options table dlist_init("list_options", list_options_createRowHTML); //dlist_debugger('list_options'); // set visibility on customFieldHTML var useCustomFieldHtml = document.getElementById('useCustomFieldHtml').checked; toggleVisibilityOnElementsById(useCustomFieldHtml, ['customFieldHtmlRow']); } // ----------------------------------------------------------------------------- // Function : // Description : // Usage : // ----------------------------------------------------------------------------- function showOptionsForFieldType() { var fieldType = document.getElementById('appFieldType').value; // var displayOnly = document.getElementById('appDisplayOnly').checked; var allElements = [ // database options //'indexed', // not yet support 'databaseNoOptions', 'customFieldTypeRow', // Field Options 'defaultValue_textfield', 'passwordField', 'defaultValue_textbox', 'textbox_height', 'wysiwyg', 'date_options', 'list_choices', 'checkbox_options', 'upload_options', 'customFieldOptions', 'noFieldOptions', // Input Validation 'required','reqUnique','minmax_length','validationRule', 'upload_validation','noValidationOptions', ]; var showlist = []; //if (displayOnly) { showlist = [ 'noValidationOptions', 'noFieldOptions']; } if (fieldType == 'none') { showlist = ['noValidationOptions', 'noFieldOptions']; } else if (fieldType == 'textfield') { showlist = ['defaultValue_textfield', 'passwordField', 'customFieldOptions', 'required','reqUnique','minmax_length','validationRule']; } else if (fieldType == 'textbox') { showlist = ['defaultValue_textbox', 'textbox_height','wysiwyg', 'customFieldOptions','required','reqUnique','minmax_length']; } else if (fieldType == 'date') { showlist = ['date_options', 'customFieldOptions','reqUnique']; } else if (fieldType == 'list') { showlist = ['list_choices', 'customFieldOptions','required','reqUnique']; } else if (fieldType == 'checkbox') { showlist = ['checkbox_options', 'customFieldOptions','noValidationOptions']; } else if (fieldType == 'upload') { showlist = ['required','upload_options', 'customFieldOptions','upload_validation']; } else if (fieldType == 'custom') { showlist = ['customFieldTypeRow', 'noFieldOptions', 'noValidationOptions']; } else if (fieldType == 'all') { showlist = allElements; } else { error("unknown field type '" +fieldType + "'"); } hideAllExcept(showlist, allElements); } // ---------------------------------------------------------------------------- // Function : list_options_defaultValueToLabel // Description : If listItemValue is blank give it the same value as 'list_optionsLabel' // ---------------------------------------------------------------------------- function list_options_defaultValueToLabel() { var labelEl = document.getElementById('list_options:add:list_optionsLabel'); var valueEl = document.getElementById('list_options:add:list_optionsValue'); if (valueEl.value == '') { valueEl.value = labelEl.value; } } // ---------------------------------------------------------------------------- // Function : list_options_addNewRow // Description : // ---------------------------------------------------------------------------- function list_options_addNewRow(listname, createRowHTML) { // add new row dlist_addNewRow(listname, createRowHTML); // reset field states on add row document.getElementById("list_options:add:list_optionsDefault").checked = false; document.getElementById("list_options:add:list_optionsLabel").value = ""; document.getElementById("list_options:add:list_optionsValue").value = ""; document.getElementById("list_options:add:list_optionsLabel").focus(); } // ---------------------------------------------------------------------------- // Function : list_options_createRowHTML // Description : create HTML for a row (used when generating and updating list) // ---------------------------------------------------------------------------- function list_options_createRowHTML(fields) { // short alias fields var fnPrefix = fields._listname +':'+ fields._num +':'; // fieldname:rownum var nameNumArgs = "'" + fields._listname + "','" + fields._num + "'"; // 'listname','rownum' // html encoded values before we insert them into HTML for (var thisname in fields) { fields[thisname] = htmlEncode( fields[thisname] ); } // generate row HTML var list_optionsDefault_1_checked = (fields.list_optionsDefault == '1') ? 'checked="checked"' : ''; var rowHTML = '' + '