Show/Hide Dependant Fields - Uploads Fix?

5 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 29, 2012   (RSS)

By Perchpole - May 27, 2012

Hello, All -

I wondered if anyone knew of a workaround for the bug/feature which results in upload fields being rendered very tall?!!

It's a very annoying quirk of an otherwise extremely useful little plugin.

:0/

Perch

Re: [Perchpole] Show/Hide Dependant Fields - Uploads Fix?

By Jason - May 29, 2012

Hi Perch,

I haven't encountered this particular issue before, could you provide some extra information?

Does this happen to any upload field in a section using the show/hide plugin, or only upload fields that are being shown/hidden?

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Show/Hide Dependant Fields - Uploads Fix?

By Perchpole - May 29, 2012

Hi, Jason -

The latter. When an Upload field is "revealed" it's very, very tall!

I have a simple menu in place to switch between two different types of editor set-up: simple and advanced.

My upload field is in the advanced set-up and once revealed it takes up almost half the monitor screen.

It's really annoying and makes the plugin very difficult to deploy in a commercial project (because it just doesn't work right.).

:0/

Perch

Re: [Perchpole] Show/Hide Dependant Fields - Uploads Fix?

By Jason - May 29, 2012

Hi Perch,

This one took some searching. This is a bug that presents when a upload field is hidden when the page loads and is then shown. What we need to do is to add in a function call that automatically resizes the upload field to an appropriate size. In the plugin, you need to make this change:

<script>
var showHideDependantFields_showRules = <?php echo json_encode($showRules); ?>;
var showHideDependantFields_hideRules = <?php echo json_encode($hideRules); ?>;
$(function(){
for (var fieldName in showHideDependantFields_showRules) {
$('SELECT[name="' + fieldName + '"]').change(showHideDependantFields_update);
}
showHideDependantFields_update();
});
function showHideDependantFields_update() {
// hide all

for (i in showHideDependantFields_hideRules) {
$('*[name="' + showHideDependantFields_hideRules + '"]').closest('TR').hide();
$('*[name^="' + showHideDependantFields_hideRules + ':"]').closest('TR').hide();
$('#' + showHideDependantFields_hideRules + '_iframe').closest('TR').hide();


}
// for each list field, show requested fields
for (var listFieldName in showHideDependantFields_showRules) {
var value = $('SELECT[name="' + listFieldName + '"] OPTION:selected').val();
var fieldsToShow = showHideDependantFields_showRules[listFieldName][value];
if (!fieldsToShow) { fieldsToShow = showHideDependantFields_showRules[listFieldName]['_any_value_']; }

if (fieldsToShow) {
for (i in fieldsToShow) {
$('*[name="' + fieldsToShow + '"]').closest('TR').show();
$('*[name^="' + fieldsToShow + ':"]').closest('TR').show();
$('#' + fieldsToShow + '_iframe').closest('TR').show();

//resize element if iframe is being shown
var closestTR = $('#' + fieldsToShow + '_iframe').closest('TR');
if (closestTR.css('display') == "table-row") {
resizeIframe(fieldsToShow + '_iframe');
}

}
}
}
}
</script>


That should take care of the issue.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/