Element height

peppe10

Member
hello

In a module i have elements that contain a lot of cascading text as in the attached file

How can I fix the height and width of the field?
Thank you
 

Attachments

  • 2017-05-28 (7).png
    2017-05-28 (7).png
    65.1 KB · Views: 62
With a custom CSS file, custom_css.php in the template folder.

If you point me at the page, I can tell you the class names to use.

-- hugh
 
OK, so are you talking about the width of the inputs themselves, ie. the way all of them are at 100% width of the container (which is from your theme3167 template CSS, which is adding the input-block-level class to all inputs, and setting that class to 100% width.

Or do you mean the "overflow" in the dropdowns when you select an option?

If so, turns out there isn't a way to do this that works on all browsers. You should be able to simply apply a width style attribute to the options, but that doesn't work in Chrome.

It looks like the only way to do it in Chrome is to brute-force it, by running some Javascript to shorten the option text.

So you'd have to add a ./components/com_fabrik/js/form_X.js file (where X is your numeric form ID), and do something like this:

JavaScript:
jQuery(document).ready(function(){
    jQuery('.fabrikElement option').text(function(i, text) {
        if (text.length > 100) {
            return text.substr(0, 100) + '...';
        }
    });
});

-- hugh
 
By inserting this file, modify only the fields in the OBBLIGHI tab, or the height of all fields in the form?
 
I don't see that code in form_74.js, just some unrelated stuff about doing date handling (addDays).

-- hugh
 
in the file from_74.js

function addDays(el) {
// get initial date from element
var initialDate = el.form.formElements.get('accesso_civico___data_ricevuta_pec').getValue();
// get days to add from element
var days = el.form.formElements.get('accesso_civico___giorni').getValue();
// create new date object from initial date
var result = new Date(initialDate);
// add days to date
result.setDate(result.getDate() + days.toInt());
// set final date element to formatted result
el.form.formElements.get('accesso_civico___data_finale').update(result.format('%d-%m-%Y'));
var initialDate = el.form.formElements.get('accesso_civico___data_finale').getValue();
// get days to add from element
var days = el.form.formElements.get('accesso_civico___giorni_controinteressati').getValue();
// create new date object from initial date
var result = new Date(initialDate);
// add days to date
result.setDate(result.getDate() + days.toInt());
// set final date element to formatted result
el.form.formElements.get('accesso_civico___data_in_cui_la_pa_deve_rispondere_se_ci_sono_controinteressati').update(result.format('%d-%m-%Y'));
}
jQuery(document).ready(function(){
jQuery('.fabrikElement option').text(function(i, text) {
if (text.length > 100) {
return text.substr(0, 100) + '...';
}
});
});



it's correct?

can you see?
 
Ah, OK, forgot those are in CDD's, so the otpions won't exist on page load, we need to look at them when the CDD updates:

JavaScript:
requirejs(['fab/fabrik'], function() {
    Fabrik.addEvent('fabrik.cdd.update', function(el) {
        jQuery('#' + el.element.id + ' option').text(function(i, text) {
            if (text.length > 100) {
                return text.substr(0, 100) + '...';
            }
        });
    });
});

-- hugh
 
Last edited:
You have set your element(s) to input-xxlarge which is 530px in Protostar (static).
Use span12 in element settings or set Protostar template to "fluid" (Advanced)
 
now the file from_74.js

function addDays(el) {
// get initial date from element
var initialDate = el.form.formElements.get('accesso_civico___data_ricevuta_pec').getValue();
// get days to add from element
var days = el.form.formElements.get('accesso_civico___giorni').getValue();
// create new date object from initial date
var result = new Date(initialDate);
// add days to date
result.setDate(result.getDate() + days.toInt());
// set final date element to formatted result
el.form.formElements.get('accesso_civico___data_finale').update(result.format('%d-%m-%Y'));
var initialDate = el.form.formElements.get('accesso_civico___data_finale').getValue();
// get days to add from element
var days = el.form.formElements.get('accesso_civico___giorni_controinteressati').getValue();
// create new date object from initial date
var result = new Date(initialDate);
// add days to date
result.setDate(result.getDate() + days.toInt());
// set final date element to formatted result
el.form.formElements.get('accesso_civico___data_in_cui_la_pa_deve_rispondere_se_ci_sono_controinteressati').update(result.format('%d-%m-%Y'));
}
jQuery(document).ready(function(){
jQuery('.fabrikElement option').text(function(i, text) {
if (text.length > 100) {
return text.substr(0, 100) + '...';
}
});
});

Which code should I enter to display the fields correctly?
 
yes
http://www.codiceconcorsipubblici.org/foia/richieste.html

I added the code as follows:
function addDays(el) {
// get initial date from element
var initialDate = el.form.formElements.get('accesso_civico___data_ricevuta_pec').getValue();
// get days to add from element
var days = el.form.formElements.get('accesso_civico___giorni').getValue();
// create new date object from initial date
var result = new Date(initialDate);
// add days to date
result.setDate(result.getDate() + days.toInt());
// set final date element to formatted result
el.form.formElements.get('accesso_civico___data_finale').update(result.format('%d-%m-%Y'));
var initialDate = el.form.formElements.get('accesso_civico___data_finale').getValue();
// get days to add from element
var days = el.form.formElements.get('accesso_civico___giorni_controinteressati').getValue();
// create new date object from initial date
var result = new Date(initialDate);
// add days to date
result.setDate(result.getDate() + days.toInt());
// set final date element to formatted result
el.form.formElements.get('accesso_civico___data_in_cui_la_pa_deve_rispondere_se_ci_sono_controinteressati').update(result.format('%d-%m-%Y'));
}
jQuery(document).ready(function(){
jQuery('.fabrikElement option').text(function(i, text) {
if (text.length > 100) {
return text.substr(0, 100) + '...';
}
});
});



does not work. Is there a mistake?
 
I've fixed that in my post.

And I now have a new laptop that doesn't have the dodgy keys. On my old one, the k and ] keys only worked about half the time.

-- hugh
 
The code now works. But you see the dots ... Can not go head to head instead of dots ???
 

Attachments

  • 2017-06-16_LI.jpg
    2017-06-16_LI.jpg
    180.2 KB · Views: 44
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top