| 1 |
// $Id: taxonomy_csv.js,v 2.5 2009/10/05 09:43:12 danielkm Exp $
|
| 2 |
|
| 3 |
if (Drupal.jsEnabled) {
|
| 4 |
(function ($) {
|
| 5 |
|
| 6 |
/**
|
| 7 |
* Allows to hide unchosen sub-options and to show chosen sub-options.
|
| 8 |
*
|
| 9 |
* TODO: To factorize.
|
| 10 |
*/
|
| 11 |
$(document).ready(function() {
|
| 12 |
// Import options.
|
| 13 |
$('#edit-import').addClass('filtered');
|
| 14 |
// Source choice.
|
| 15 |
// Add/remove class to show/hide it.
|
| 16 |
$('#edit-source-choice').change(function(){
|
| 17 |
var methods = new Array('text', 'path', 'url');
|
| 18 |
for(var m in methods) {
|
| 19 |
$('#edit-import').removeClass(methods[m]);
|
| 20 |
}
|
| 21 |
$('#edit-import').addClass(this.value)
|
| 22 |
.animate({opacity:.5}, 1)
|
| 23 |
.animate({opacity:1}, 1)
|
| 24 |
});
|
| 25 |
// Update current display.
|
| 26 |
$('#edit-source-choice').trigger('change');
|
| 27 |
|
| 28 |
// Import/Export CSV format options.
|
| 29 |
$('#edit-csv-format').addClass('filtered');
|
| 30 |
// Export delimiter.
|
| 31 |
// Add/remove class to show/hide it.
|
| 32 |
$('#delimiter').change(function(){
|
| 33 |
var methods = new Array('comma', 'semicolon', 'tabulation', 'space', 'currency_sign', 'custom_delimiter');
|
| 34 |
for(var m in methods) {
|
| 35 |
$('#edit-csv-format').removeClass(methods[m]);
|
| 36 |
}
|
| 37 |
$('#edit-csv-format').addClass(this.value)
|
| 38 |
.animate({opacity:.5}, 1)
|
| 39 |
.animate({opacity:1}, 1)
|
| 40 |
});
|
| 41 |
// Update current display.
|
| 42 |
$('#delimiter').trigger('change');
|
| 43 |
|
| 44 |
// Import/Export CSV enclosure.
|
| 45 |
// Add/remove class to show/hide it.
|
| 46 |
$('#enclosure').change(function(){
|
| 47 |
var methods = new Array('none', 'quotation', 'custom_enclosure');
|
| 48 |
for(var m in methods) {
|
| 49 |
$('#edit-csv-format').removeClass(methods[m]);
|
| 50 |
}
|
| 51 |
$('#edit-csv-format').addClass(this.value)
|
| 52 |
.animate({opacity:.5}, 1)
|
| 53 |
.animate({opacity:1}, 1)
|
| 54 |
});
|
| 55 |
// Update current display.
|
| 56 |
$('#enclosure').trigger('change');
|
| 57 |
|
| 58 |
// Destination choice.
|
| 59 |
$('#edit-destination').addClass('filtered');
|
| 60 |
// Add/remove class to show/hide it.
|
| 61 |
$('#edit-vocabulary-target').change(function(){
|
| 62 |
var methods = new Array('autocreate', 'duplicate', 'existing');
|
| 63 |
for(var m in methods) {
|
| 64 |
$('#edit-destination').removeClass(methods[m]);
|
| 65 |
}
|
| 66 |
$('#edit-destination').addClass(this.value)
|
| 67 |
.animate({opacity:.5}, 1)
|
| 68 |
.animate({opacity:1}, 1)
|
| 69 |
});
|
| 70 |
// Update current display.
|
| 71 |
$('#edit-vocabulary-target').trigger('change');
|
| 72 |
|
| 73 |
// Import options (general, description and specific).
|
| 74 |
// Hide all items defined with the css class filtered.
|
| 75 |
var methods_import = new Array('#edit-existing-items-update-wrapper', '#edit-existing-items-update-merge-wrapper', '#edit-existing-items-update-replace-wrapper', '#edit-existing-items-ignore-wrapper', '#edit-existing-items-ignore-create-wrapper', '#edit-existing-items-ignore-all-wrapper', '#description_alone_terms', '#description_fields_links', '#description_flat', '#description_tree_structure', '#description_polyhierarchy', '#description_parents', '#description_children', '#description_relations', '#description_fields', '#description_descriptions', '#description_weights', '#description_synonyms', '#description_taxonomy_manager', '#help_alone_terms', '#help_fields_links', '#help_flat', '#help_tree_structure', '#help_polyhierarchy', '#help_parents', '#help_children', '#help_relations', '#help_fields', '#help_descriptions', '#help_weights', '#help_synonyms', '#help_taxonomy_manager', '#edit-fields-links', '#edit-relations');
|
| 76 |
for(var m in methods_import) {
|
| 77 |
$(methods_import[m]).addClass('filtered');
|
| 78 |
}
|
| 79 |
// Existing terms.
|
| 80 |
// Add/remove class to show/hide it.
|
| 81 |
$('#edit-import-format').change(function(){
|
| 82 |
var methods_import_format = new Array('alone_terms', 'fields_links', 'flat', 'tree_structure', 'polyhierarchy', 'parents', 'children', 'relations', 'fields', 'descriptions', 'weights', 'synonyms', 'taxonomy_manager');
|
| 83 |
// Remove all added classes in order to return to base.
|
| 84 |
for(var m in methods_import) {
|
| 85 |
for(var n in methods_import_format) {
|
| 86 |
$(methods_import[m]).removeClass(methods_import_format[n]);
|
| 87 |
}
|
| 88 |
}
|
| 89 |
// Add current class to show it with css.
|
| 90 |
for(var m in methods_import) {
|
| 91 |
$(methods_import[m]).addClass(this.value)
|
| 92 |
.animate({opacity:.5}, 1)
|
| 93 |
.animate({opacity:1}, 1)
|
| 94 |
}
|
| 95 |
});
|
| 96 |
// Update current display.
|
| 97 |
$('#edit-import-format').trigger('change');
|
| 98 |
|
| 99 |
// Export options (specific)
|
| 100 |
// Hide all items defined with the css class filtered.
|
| 101 |
var methods_export = new Array('#edit-fields-links');
|
| 102 |
for(var m in methods_export) {
|
| 103 |
$(methods_export[m]).addClass('filtered');
|
| 104 |
}
|
| 105 |
// Add/remove class to show/hide it.
|
| 106 |
$('#edit-export-format').change(function(){
|
| 107 |
var methods_export_format = new Array('alone_terms', 'fields_links', 'flat', 'tree_structure', 'polyhierarchy', 'parents', 'children', 'relations', 'fields', 'descriptions', 'weights', 'synonyms', 'taxonomy_manager');
|
| 108 |
// Remove all added classes in order to return to base.
|
| 109 |
for(var m in methods_export) {
|
| 110 |
for(var n in methods_export_format) {
|
| 111 |
$(methods_export[m]).removeClass(methods_export_format[n]);
|
| 112 |
}
|
| 113 |
}
|
| 114 |
// Add current class to show it with css.
|
| 115 |
for(var m in methods_export) {
|
| 116 |
$(methods_export[m]).addClass(this.value)
|
| 117 |
.animate({opacity:.5}, 1)
|
| 118 |
.animate({opacity:1}, 1)
|
| 119 |
}
|
| 120 |
});
|
| 121 |
// Update current display.
|
| 122 |
$('#edit-export-format').trigger('change');
|
| 123 |
|
| 124 |
// Advanced options.
|
| 125 |
// Result display.
|
| 126 |
// Add/remove class to show/hide it.
|
| 127 |
$('#edit-disable-internal-cache').change(function(){
|
| 128 |
if (this.checked) {
|
| 129 |
$('#result_display_options').addClass('filtered');
|
| 130 |
$('#result_display_cache').removeClass('filtered');
|
| 131 |
}
|
| 132 |
else {
|
| 133 |
$('#result_display_options').removeClass('filtered');
|
| 134 |
$('#result_display_cache').addClass('filtered');
|
| 135 |
}
|
| 136 |
});
|
| 137 |
// Update current display.
|
| 138 |
$('#edit-disable-internal-cache').trigger('change');
|
| 139 |
|
| 140 |
// Vocabulary hierarchy.
|
| 141 |
// Add/remove class to show/hide it.
|
| 142 |
$('#edit-disable-hierarchy-check').change(function(){
|
| 143 |
if (this.checked) {
|
| 144 |
$('#hierarchy_level').removeClass('filtered');
|
| 145 |
}
|
| 146 |
else {
|
| 147 |
$('#hierarchy_level').addClass('filtered');
|
| 148 |
}
|
| 149 |
});
|
| 150 |
// Update current display.
|
| 151 |
$('#edit-disable-hierarchy-check').trigger('change');
|
| 152 |
|
| 153 |
// Result level.
|
| 154 |
// Add/remove class to show/hide it.
|
| 155 |
$('#edit-result-level-none').change(function(){
|
| 156 |
if (this.checked) {
|
| 157 |
$('#result_type').addClass('filtered');
|
| 158 |
}
|
| 159 |
});
|
| 160 |
$('#edit-result-level-warnings').change(function(){
|
| 161 |
if (this.checked) {
|
| 162 |
$('#result_type').removeClass('filtered');
|
| 163 |
}
|
| 164 |
});
|
| 165 |
$('#edit-result-level-notices').change(function(){
|
| 166 |
if (this.checked) {
|
| 167 |
$('#result_type').removeClass('filtered');
|
| 168 |
}
|
| 169 |
});
|
| 170 |
$('#edit-result-level-infos').change(function(){
|
| 171 |
if (this.checked) {
|
| 172 |
$('#result_type').removeClass('filtered');
|
| 173 |
}
|
| 174 |
});
|
| 175 |
// Update current display.
|
| 176 |
$('#edit-result-level-none').trigger('change');
|
| 177 |
$('#edit-result-level-warnings').trigger('change');
|
| 178 |
$('#edit-result-level-notices').trigger('change');
|
| 179 |
$('#edit-result-level-infos').trigger('change');
|
| 180 |
});
|
| 181 |
|
| 182 |
})(jQuery);
|
| 183 |
}
|