Displaying read-only attributes in Author

Oxygen general issues.
pkong
Posts: 5
Joined: Fri Oct 11, 2013 12:12 am

Displaying read-only attributes in Author

Post by pkong »

I'm experimenting with the CSS extensions for Author mode and have an unusual use-case:
<element attr1="x" attr2="y"/>
I need to display this in author mode as:
element x y

Where element, x, and y are READ-ONLY if y is some value 'a' and READ-WRITE if y is value 'b'.

First of all, I have no idea how to display an attribute without using oxy-editor, but since in most cases the attributes will be read-only, that doesn't work for me. If not read-only, I can use the oxy-editor functions.
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: Displaying read-only attributes in Author

Post by alex_jitianu »

Hi,

You can still use form controls, you just have to mark the element as READ_ONLY (using the -oxy-editable property). As a result the form controls will also be READ-ONLY:

Code: Select all


element:before {
content: oxy_local-name() " " oxy_textfield(edit, '@attr1', columns, 10) " " oxy_textfield(edit, '@attr2', columns, 10);
}

element[attr2='a'] {
-oxy-editable:false;
}

element[attr2='b'] {
-oxy-editable:true;
}
If you don't want to use form controls when the values are READ-ONLY you can use the attr function to just present the attributes:

Code: Select all


element:before {
content: oxy_local-name() " " attr(attr1) " " attr(attr2);
}
Best regards,
Alex
pkong
Posts: 5
Joined: Fri Oct 11, 2013 12:12 am

Re: Displaying read-only attributes in Author

Post by pkong »

Thank you!
pkong
Posts: 5
Joined: Fri Oct 11, 2013 12:12 am

Re: Displaying read-only attributes in Author

Post by pkong »

This does not work at all! Attributes can still be edited when an element's -oxy-editable:false. I'm beginning to think that it is not possible at all to have form controls be set to read-only.

Is it at least possible to have the attributes output as read-only plain text that can be assigned column widths to regularly space them apart?
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: Displaying read-only attributes in Author

Post by alex_jitianu »

Hi,

I've tried this scenario and setting -oxy-editable:false on an element will also make it's attributes read-only.

In the code snapshots I've posted, the attributes are editable but as soon as you set attr2 to value a both attributes become READ-ONLY.

If you want to output the attributes in a columns like layout you can use the oxy_label function, like so:

Code: Select all


element:before {
content: oxy_local-name() ": \A "
oxy_label(text, "Attribute 1", width, 100px) attr(attr1) "\A "
oxy_label(text, "Attr 2", width, 100px) attr(attr2);
}
I'll also send you the sample files on your email address so that you can test them more easily.

Best regards,
Alex
Post Reply