jQuery(document).ready(function() {
try {
jQuery('#tag-generator-div').append(tagGenerator());
jQuery('input#wpcf7-title:enabled').css({
cursor: 'pointer'
});
jQuery('input#wpcf7-title').mouseover(function() {
jQuery(this).not('.focus').css({
'background-color': '#ffffdd'
});
});
jQuery('input#wpcf7-title').mouseout(function() {
jQuery(this).css({
'background-color': '#fff'
});
});
jQuery('input#wpcf7-title').focus(function() {
jQuery(this).addClass('focus');
jQuery(this).css({
cursor: 'text',
color: '#333',
border: '1px solid #777',
font: 'normal 13px Verdana, Arial, Helvetica, sans-serif',
'background-color': '#fff'
});
});
jQuery('input#wpcf7-title').blur(function() {
jQuery(this).removeClass('focus');
jQuery(this).css({
cursor: 'pointer',
color: '#555',
border: 'none',
font: 'bold 20px serif',
'background-color': '#fff'
});
});
jQuery('input#wpcf7-title').change(function() {
updateTag();
});
updateTag();
if (! jQuery('#wpcf7-mail-2-active').is(':checked'))
jQuery('#mail-2-fields').hide();
jQuery('#wpcf7-mail-2-active').click(function() {
if (jQuery('#wpcf7-mail-2-active').is(':checked')) {
if (jQuery('#mail-2-fields').is(':hidden'))
jQuery('#mail-2-fields').slideDown('fast');
} else {
if (jQuery('#mail-2-fields').is(':visible'))
jQuery('#mail-2-fields').hide('fast');
}
});
jQuery('#message-fields-toggle-switch').text(_wpcf7L10n.show);
jQuery('#message-fields').hide();
jQuery('#message-fields-toggle-switch').click(function() {
if (jQuery('#message-fields').is(':hidden')) {
jQuery('#message-fields').slideDown('fast');
jQuery('#message-fields-toggle-switch').text(_wpcf7L10n.hide);
} else {
jQuery('#message-fields').hide('fast');
jQuery('#message-fields-toggle-switch').text(_wpcf7L10n.show);
}
});
if ('' == jQuery.trim(jQuery('#wpcf7-additional-settings').text())) {
jQuery('#additional-settings-fields-toggle-switch').text(_wpcf7L10n.show);
jQuery('#additional-settings-fields').hide();
} else {
jQuery('#additional-settings-fields-toggle-switch').text(_wpcf7L10n.hide);
jQuery('#additional-settings-fields').show();
}
jQuery('#additional-settings-fields-toggle-switch').click(function() {
if (jQuery('#additional-settings-fields').is(':hidden')) {
jQuery('#additional-settings-fields').slideDown('fast');
jQuery('#additional-settings-fields-toggle-switch').text(_wpcf7L10n.hide);
} else {
jQuery('#additional-settings-fields').hide('fast');
jQuery('#additional-settings-fields-toggle-switch').text(_wpcf7L10n.show);
}
});
} catch (e) {
}
});
function updateTag() {
var title = jQuery('input#wpcf7-title').val();
if (title)
title = title.replace(/["'\[\]]/g, '');
jQuery('input#wpcf7-title').val(title);
var current = jQuery('input#wpcf7-id').val();
var tag = '[contact-form ' + current + ' "' + title + '"]';
jQuery('input#contact-form-anchor-text').val(tag);
}
function tagGenerator() {
var menu = jQuery('
');
var dropdown_icon = jQuery('');
dropdown_icon.css({ 'vertical-align': 'bottom' });
var selector = jQuery('' + _wpcf7L10n.generateTag + '');
selector.append(dropdown_icon);
selector.css({
border: '1px solid #ddd',
padding: '2px 4px',
background: '#fff url( ../wp-admin/images/fade-butt.png ) repeat-x 0 0',
'-moz-border-radius': '3px',
'-khtml-border-radius': '3px',
'-webkit-border-radius': '3px',
'border-radius': '3px'
});
selector.mouseover(function() {
jQuery(this).css({ 'border-color': '#bbb' });
});
selector.mouseout(function() {
jQuery(this).css({ 'border-color': '#ddd' });
});
selector.mousedown(function() {
jQuery(this).css({ background: '#ddd' });
});
selector.mouseup(function() {
jQuery(this).css({ background: '#fff url( ../wp-admin/images/fade-butt.png ) repeat-x 0 0' });
});
selector.click(function() {
dropdown.slideDown('fast');
return false;
});
jQuery('body').click(function() {
dropdown.hide();
});
menu.append(selector);
var pane = jQuery('');
pane.hide();
menu.append(pane);
var dropdown = jQuery('');
dropdown.hide();
var tag_types = [
'textField', 'emailField', 'textArea', 'menu', 'checkboxes', 'radioButtons',
'acceptance', 'quiz', 'captcha', 'fileUpload', 'submit'];
jQuery.each(tag_types, function(i, n) {
var submenu = jQuery('' + _wpcf7L10n[n] + '
');
submenu.css({
margin: 0,
padding: '0 4px',
'line-height': '180%',
background: '#fff'
});
submenu.mouseover(function() {
jQuery(this).css({ background: '#d4f2f2' });
});
submenu.mouseout(function() {
jQuery(this).css({ background: '#fff' });
});
submenu.click(function() {
dropdown.hide();
pane.hide();
pane.empty();
tgPane(pane, n);
pane.slideDown('fast');
return false;
});
dropdown.append(submenu);
});
menu.append(dropdown);
return menu;
}
function tgPane(pane, tagType) {
var closeButtonDiv = jQuery('');
closeButtonDiv.css({ float: 'right' });
var closeButton = jQuery('×');
closeButton.click(function() {
pane.slideUp('fast').empty();
});
closeButtonDiv.append(closeButton);
pane.append(closeButtonDiv);
var paneTitle = jQuery('' + _wpcf7L10n[tagType] + '
');
pane.append(paneTitle);
var tgInputs = {};
jQuery.each([ 'tagName', 'tagId', 'tagClasses', 'tagId2', 'tagClasses2', 'defaultValue',
'tagSize', 'tagMaxLength', 'tagFileSizeLimit', 'tagAcceptableFileTypes', 'tagCols', 'tagRows', 'label', 'fgColor', 'bgColor' ], function(i, n) {
tgInputs[n] = jQuery('');
tgInputs[n].css({ width: '98%', 'font-size': 'smaller' });
tgInputs[n].change(function() {
tgCreateTag(tagType, tgInputs, n);
});
});
tgInputs.tagName.css({ 'border-color': '#555' });
jQuery.each([ 'isRequiredField', 'allowsMultipleSelections', 'insertFirstBlankOption', 'makeCheckboxesExclusive',
'isAcceptanceDefaultOn', 'isAcceptanceInvert',
'akismetAuthor', 'akismetAuthorEmail', 'akismetAuthorUrl',
'imageSizeSmall', 'imageSizeMedium', 'imageSizeLarge' ], function(i, n) {
tgInputs[n] = jQuery('');
tgInputs[n].change(function() {
tgCreateTag(tagType, tgInputs, n);
});
});
jQuery.each([ 'menuChoices' ], function(i, n) {
tgInputs[n] = jQuery('');
tgInputs[n].css({ width: '98%', height: '100px', 'font-size': 'smaller' });
tgInputs[n].change(function() {
tgCreateTag(tagType, tgInputs, n);
});
});
jQuery.each([ 'tag1st', 'tag2nd' ], function(i, n) {
tgInputs[n] = jQuery('');
tgInputs[n].css({ width: '98%' });
});
switch (tagType) {
case 'textField':
case 'emailField':
var table1 = jQuery('');
pane.append(table1);
table1.append(tgTr(
jQuery(' ' + _wpcf7L10n.isRequiredField + '').prepend(tgInputs.isRequiredField)
));
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append(tgTr(
jQuery('size
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagSize),
jQuery('maxlength
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagMaxLength)
));
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
var akismetOpts = jQuery('' + _wpcf7L10n.akismet + ' (' + _wpcf7L10n.optional + ')
');
if ('textField' == tagType) {
akismetOpts.append(tgInputs.akismetAuthor).append(' ' + _wpcf7L10n.akismetAuthor);
akismetOpts.append('
');
akismetOpts.append(tgInputs.akismetAuthorUrl).append(' ' + _wpcf7L10n.akismetAuthorUrl);
} else if ('emailField' == tagType) {
akismetOpts.append(tgInputs.akismetAuthorEmail).append(' ' + _wpcf7L10n.akismetAuthorEmail);
}
table2.append(tgTr(
akismetOpts,
jQuery('' + _wpcf7L10n.defaultValue + ' (' + _wpcf7L10n.optional + ')
').append(tgInputs.defaultValue)
));
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
case 'textArea':
var table1 = jQuery('');
pane.append(table1);
table1.append(tgTr(
jQuery(' ' + _wpcf7L10n.isRequiredField + '').prepend(tgInputs.isRequiredField)
));
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append(tgTr(
jQuery('cols
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagCols),
jQuery('rows
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagRows)
));
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
table2.append(tgTr(
jQuery('' + _wpcf7L10n.defaultValue + ' (' + _wpcf7L10n.optional + ')
').append(tgInputs.defaultValue)
));
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
case 'menu':
case 'checkboxes':
case 'radioButtons':
var table1 = jQuery('');
pane.append(table1);
if ('radioButtons' != tagType)
table1.append(tgTr(
jQuery(' ' + _wpcf7L10n.isRequiredField + '').prepend(tgInputs.isRequiredField)
));
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
if ('menu' == tagType) {
var menuOpt1 = jQuery(' ' + _wpcf7L10n.allowsMultipleSelections + '').prepend(tgInputs.allowsMultipleSelections).prepend('
');
var menuOpt2 = jQuery(' ' + _wpcf7L10n.insertFirstBlankOption + '').prepend(tgInputs.insertFirstBlankOption).prepend('
');
table2.append(tgTr(
jQuery('' + _wpcf7L10n.menuChoices + '
').append(tgInputs.menuChoices)
.append('
' + _wpcf7L10n.oneChoicePerLine + ''),
menuOpt1.append(menuOpt2)
));
} else if ('checkboxes' == tagType) {
table2.append(tgTr(
jQuery('' + _wpcf7L10n.menuChoices + '
').append(tgInputs.menuChoices)
.append('
' + _wpcf7L10n.oneChoicePerLine + ''),
jQuery(' ' + _wpcf7L10n.makeCheckboxesExclusive + '').prepend(tgInputs.makeCheckboxesExclusive).prepend('
')
));
} else {
table2.append(tgTr(
jQuery('' + _wpcf7L10n.menuChoices + '
').append(tgInputs.menuChoices)
.append('
' + _wpcf7L10n.oneChoicePerLine + '')
));
}
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
case 'acceptance':
var table1 = jQuery('');
pane.append(table1);
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
var menuOpt1 = jQuery(' ' + _wpcf7L10n.isAcceptanceDefaultOn + '').prepend(tgInputs.isAcceptanceDefaultOn).prepend('
');
var menuOpt2 = jQuery(' ' + _wpcf7L10n.isAcceptanceInvert + '').prepend(tgInputs.isAcceptanceInvert).prepend('
');
menuOpt2.append('
' + _wpcf7L10n.isAcceptanceInvertMeans + '');
table2.append(jQuery('
').append(jQuery(' | ').append(menuOpt1).append(menuOpt2)));
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
case 'quiz':
var table1 = jQuery('');
pane.append(table1);
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append(tgTr(
jQuery('size
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagSize),
jQuery('maxlength
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagMaxLength)
));
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
table2.append(tgTr(
jQuery('' + _wpcf7L10n.quizzes + '
').append(tgInputs.menuChoices)
.append('
' + _wpcf7L10n.quizFormatDesc + '')
));
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
case 'captcha':
var table1 = jQuery('');
pane.append(table1);
if (! _wpcf7.captchaMod) {
table1.append('' +
_wpcf7L10n.needReallySimpleCaptcha + ' ' +
'' +
'http://wordpress.org/extend/plugins/really-simple-captcha/ |
');
}
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append('' + _wpcf7L10n.imageSettings + '');
var imageSizeOpts = jQuery('' + _wpcf7L10n.imageSize + ' (' + _wpcf7L10n.optional + ')
');
imageSizeOpts.append(tgInputs.imageSizeSmall).append(' ' + _wpcf7L10n.imageSizeSmall);
imageSizeOpts.append(' ');
imageSizeOpts.append(tgInputs.imageSizeMedium).append(' ' + _wpcf7L10n.imageSizeMedium);
imageSizeOpts.append(' ');
imageSizeOpts.append(tgInputs.imageSizeLarge).append(' ' + _wpcf7L10n.imageSizeLarge);
table2.append(jQuery('
').append(jQuery(' | ').append(imageSizeOpts)));
table2.append(tgTr(
jQuery('' + _wpcf7L10n.fgColor + ' (' + _wpcf7L10n.optional + ')
').append(tgInputs.fgColor),
jQuery('' + _wpcf7L10n.bgColor + ' (' + _wpcf7L10n.optional + ')
').append(tgInputs.bgColor)
));
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
var table3 = jQuery('');
pane.append(table3);
table3.append('' + _wpcf7L10n.inputFieldSettings + '');
table3.append(tgTr(
jQuery('size
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagSize),
jQuery('maxlength
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagMaxLength)
));
table3.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId2),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses2)
));
pane.append(
jQuery('' + _wpcf7L10n.generatedTag + '
')
.append('
').append('1) ' + _wpcf7L10n.tagForImage)
.append(tgInputs.tag1st)
.append('
').append('2) ' + _wpcf7L10n.tagForInputField)
.append(tgInputs.tag2nd)
);
break;
case 'fileUpload':
var table1 = jQuery('');
pane.append(table1);
table1.append(tgTr(
jQuery(' ' + _wpcf7L10n.isRequiredField + '').prepend(tgInputs.isRequiredField)
));
table1.append(tgTr(
jQuery('' + _wpcf7L10n.tagName + '
').append(tgInputs.tagName),
jQuery('')
));
var table2 = jQuery('');
pane.append(table2);
table2.append(tgTr(
jQuery('' + _wpcf7L10n.fileSizeLimit + ' (' + _wpcf7L10n.bytes + ') (' + _wpcf7L10n.optional + ')
').append(tgInputs.tagFileSizeLimit),
jQuery('' + _wpcf7L10n.acceptableFileTypes + ' (' + _wpcf7L10n.optional + ')
').append(tgInputs.tagAcceptableFileTypes)
));
table2.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
case 'submit':
var table = jQuery('');
pane.append(table);
table.append(tgTr(
jQuery('id
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagId),
jQuery('class
(' + _wpcf7L10n.optional + ')
').append(tgInputs.tagClasses)
));
table.append(tgTr(
jQuery('' + _wpcf7L10n.label + '
').append(tgInputs.label),
jQuery('')
));
pane.append(jQuery('' + _wpcf7L10n.generatedTag + '
').append(tgInputs.tag1st));
break;
}
tgCreateTag(tagType, tgInputs);
}
function tgTr() {
var tr = jQuery('
');
jQuery.each(arguments, function(i, n) {
var td = jQuery(' | ').append(n);
tr.append(td);
});
return tr;
}
function tgCreateTag(tagType, tgInputs, trigger) {
tgInputs.tag1st.empty();
tgInputs.tag2nd.empty();
jQuery.each([ 'tagName' ], function(i, n) {
var val = tgInputs[n].val();
val = val.replace(/[^0-9a-zA-Z:._-]/g, '').replace(/^[^a-zA-Z]+/, '');
if ('' == val)
val = tgDefaultName(tagType);
tgInputs[n].val(val);
});
jQuery.each([ 'tagSize', 'tagMaxLength', 'tagCols', 'tagRows' ], function(i, n) {
var val = tgInputs[n].val();
val = val.replace(/[^0-9]/g, '');
tgInputs[n].val(val);
});
jQuery.each([ 'tagId', 'tagId2' ], function(i, n) {
var val = tgInputs[n].val();
val = val.replace(/[^-0-9a-zA-Z_]/g, '');
tgInputs[n].val(val);
});
jQuery.each([ 'tagClasses', 'tagClasses2' ], function(i, n) {
var val = tgInputs[n].val();
val = jQuery.map(val.split(' '), function(n) {
return n.replace(/[^-0-9a-zA-Z_]/g, '');
}).join(' ');
val = jQuery.trim(val.replace(/\s+/g, ' '));
tgInputs[n].val(val);
});
jQuery.each([ 'fgColor', 'bgColor' ], function(i, n) {
var val = tgInputs[n].val();
val = val.replace(/[^0-9a-fA-F]/g, '');
tgInputs[n].val(val);
});
jQuery.each([ 'tagFileSizeLimit' ], function(i, n) {
var val = tgInputs[n].val();
val = val.replace(/[^0-9kKmMbB]/g, '');
tgInputs[n].val(val);
});
jQuery.each([ 'tagAcceptableFileTypes' ], function(i, n) {
var val = tgInputs[n].val();
val = val.replace(/[^0-9a-zA-Z.\s]/g, '');
tgInputs[n].val(val);
});
if ('akismetAuthor' == trigger && tgInputs.akismetAuthor.is(':checked')) {
tgInputs.akismetAuthorUrl.removeAttr('checked');
tgInputs.akismetAuthorEmail.removeAttr('checked');
} else if ('akismetAuthorUrl' == trigger && tgInputs.akismetAuthorUrl.is(':checked')) {
tgInputs.akismetAuthor.removeAttr('checked');
tgInputs.akismetAuthorEmail.removeAttr('checked');
} else if ('akismetAuthorEmail' == trigger && tgInputs.akismetAuthorEmail.is(':checked')) {
tgInputs.akismetAuthor.removeAttr('checked');
tgInputs.akismetAuthorUrl.removeAttr('checked');
}
if ('imageSizeSmall' == trigger && tgInputs.imageSizeSmall.is(':checked')) {
tgInputs.imageSizeMedium.removeAttr('checked');
tgInputs.imageSizeLarge.removeAttr('checked');
} else if ('imageSizeMedium' == trigger && tgInputs.imageSizeMedium.is(':checked')) {
tgInputs.imageSizeSmall.removeAttr('checked');
tgInputs.imageSizeLarge.removeAttr('checked');
} else if ('imageSizeLarge' == trigger && tgInputs.imageSizeLarge.is(':checked')) {
tgInputs.imageSizeSmall.removeAttr('checked');
tgInputs.imageSizeMedium.removeAttr('checked');
}
switch (tagType) {
case 'textField':
case 'emailField':
var type = ('emailField' == tagType) ? 'email' : 'text';
if (tgInputs.isRequiredField.is(':checked'))
type += '*';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.tagSize.val() || tgInputs.tagMaxLength.val())
options.push(tgInputs.tagSize.val() + '/' + tgInputs.tagMaxLength.val());
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
if (tgInputs.akismetAuthor.is(':checked'))
options.push('akismet:author');
if (tgInputs.akismetAuthorUrl.is(':checked'))
options.push('akismet:author_url');
if (tgInputs.akismetAuthorEmail.is(':checked'))
options.push('akismet:author_email');
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var dv = '';
if (tgInputs.defaultValue.val()) {
dv = ' "' + tgInputs.defaultValue.val().replace(/["]/g, '"') + '"';
}
var tag = name ? '[' + type + ' ' + name + options + dv + ']' : '';
tgInputs.tag1st.val(tag);
break;
case 'textArea':
var type = 'textarea';
if (tgInputs.isRequiredField.is(':checked'))
type += '*';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.tagCols.val() || tgInputs.tagRows.val())
options.push(tgInputs.tagCols.val() + 'x' + tgInputs.tagRows.val());
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var dv = '';
if (tgInputs.defaultValue.val()) {
dv = ' "' + tgInputs.defaultValue.val().replace(/["]/g, '"') + '"';
}
var tag = name ? '[' + type + ' ' + name + options + dv + ']' : '';
tgInputs.tag1st.val(tag);
break;
case 'menu':
case 'checkboxes':
case 'radioButtons':
var type = '';
if ('menu' == tagType)
type = 'select';
else if ('checkboxes' == tagType)
type = 'checkbox';
else if ('radioButtons' == tagType)
type = 'radio';
if (tgInputs.isRequiredField.is(':checked'))
type += '*';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.allowsMultipleSelections.is(':checked'))
options.push('multiple');
if (tgInputs.insertFirstBlankOption.is(':checked'))
options.push('include_blank');
if (tgInputs.makeCheckboxesExclusive.is(':checked'))
options.push('exclusive');
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var choices = '';
if (tgInputs.menuChoices.val())
jQuery.each(tgInputs.menuChoices.val().split("\n"), function(i, n) {
choices += ' "' + n.replace(/["]/g, '"') + '"';
});
var tag = name ? '[' + type + ' ' + name + options + choices + ']' : '';
tgInputs.tag1st.val(tag);
break;
case 'acceptance':
var type = 'acceptance';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.isAcceptanceDefaultOn.is(':checked'))
options.push('default:on');
if (tgInputs.isAcceptanceInvert.is(':checked'))
options.push('invert');
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var tag = name ? '[' + type + ' ' + name + options + ']' : '';
tgInputs.tag1st.val(tag);
break;
case 'quiz':
var type = 'quiz';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.tagSize.val() || tgInputs.tagMaxLength.val())
options.push(tgInputs.tagSize.val() + '/' + tgInputs.tagMaxLength.val());
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var choices = '';
if (tgInputs.menuChoices.val())
jQuery.each(tgInputs.menuChoices.val().split("\n"), function(i, n) {
choices += ' "' + n.replace(/["]/g, '"') + '"';
});
var tag = name ? '[' + type + ' ' + name + options + choices + ']' : '';
tgInputs.tag1st.val(tag);
break;
case 'captcha':
// for captchac
var type = 'captchac';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.imageSizeSmall.is(':checked'))
options.push('size:s');
if (tgInputs.imageSizeMedium.is(':checked'))
options.push('size:m');
if (tgInputs.imageSizeLarge.is(':checked'))
options.push('size:l');
if (tgInputs.fgColor.val())
options.push('fg:#' + tgInputs.fgColor.val());
if (tgInputs.bgColor.val())
options.push('bg:#' + tgInputs.bgColor.val());
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var tag = name ? '[' + type + ' ' + name + options + ']' : '';
tgInputs.tag1st.val(tag);
// for captchar
var type = 'captchar';
var options = [];
if (tgInputs.tagSize.val() || tgInputs.tagMaxLength.val())
options.push(tgInputs.tagSize.val() + '/' + tgInputs.tagMaxLength.val());
if (tgInputs.tagId2.val())
options.push('id:' + tgInputs.tagId2.val());
if (tgInputs.tagClasses2.val())
jQuery.each(tgInputs.tagClasses2.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var tag = name ? '[' + type + ' ' + name + options + ']' : '';
tgInputs.tag2nd.val(tag);
break;
case 'fileUpload':
var type = 'file';
if (tgInputs.isRequiredField.is(':checked'))
type += '*';
var name = tgInputs.tagName.val();
var options = [];
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
if (tgInputs.tagFileSizeLimit.val())
options.push('limit:' + tgInputs.tagFileSizeLimit.val());
if (tgInputs.tagAcceptableFileTypes.val())
options.push('filetypes:' + tgInputs.tagAcceptableFileTypes.val().split(' ').join('|'));
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var tag = name ? '[' + type + ' ' + name + options + ']' : '';
tgInputs.tag1st.val(tag);
break;
case 'submit':
var type = 'submit';
var options = [];
if (tgInputs.tagId.val())
options.push('id:' + tgInputs.tagId.val());
if (tgInputs.tagClasses.val())
jQuery.each(tgInputs.tagClasses.val().split(' '), function(i, n) {
options.push('class:' + n);
});
options = (options.length > 0) ? ' ' + options.join(' ') : '';
var label = tgInputs.label.val();
if (label)
label = ' "' + label.replace(/["]/g, '"') + '"';
var tag = '[' + type + options + label + ']';
tgInputs.tag1st.val(tag);
break;
}
}
function tgDefaultName(tagType) {
var rand = Math.floor(Math.random() * 1000);
if ('textField' == tagType) {
return 'text-' + rand;
} else if ('emailField' == tagType) {
return 'email-' + rand;
} else if ('textArea' == tagType) {
return 'textarea-' + rand;
} else if ('menu' == tagType) {
return 'menu-' + rand;
} else if ('checkboxes' == tagType) {
return 'checkbox-' + rand;
} else if ('radioButtons' == tagType) {
return 'radio-' + rand;
} else if ('acceptance' == tagType) {
return 'acceptance-' + rand;
} else if ('quiz' == tagType) {
return 'quiz-' + rand;
} else if ('captcha' == tagType) {
return 'captcha-' + rand;
} else if ('fileUpload' == tagType) {
return 'file-' + rand;
}
}