Added readonly extension for input elements.
This commit is contained in:
		| @@ -913,7 +913,7 @@ class IgniteTemplate { | ||||
|  | ||||
|     /** | ||||
|      * Adds a disabled attribute and class to this template. | ||||
|      * @param {Boolean|IgniteProperty} value A value to determine whether or not the element should be marked as disable dor not.  | ||||
|      * @param {Boolean|IgniteProperty} value A value to determine whether or not the element should be marked as disable or not.  | ||||
|      * @param {*} converter Optional function that can convert the value if needed. | ||||
|      * @returns {IgniteTemplate} This ignite template so function calls can be chained. | ||||
|      */ | ||||
| @@ -944,6 +944,39 @@ class IgniteTemplate { | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds a readonly attribute and class to this template. | ||||
|      * @param {Boolean|IgniteProperty} value A value to determine whether or not the element should be marked as readonly or not.  | ||||
|      * @param {*} converter Optional function that can convert the value if needed. | ||||
|      * @returns {IgniteTemplate} This ignite template so function calls can be chained. | ||||
|      */ | ||||
|     readonly(value, converter = null) { | ||||
|         if (value instanceof IgniteProperty) { | ||||
|             this.attribute("readonly", value, convert => { | ||||
|                 convert = (converter != null ? converter(convert) : convert); | ||||
|                 if (convert) { | ||||
|                     return "readonly"; | ||||
|                 } else { | ||||
|                     return null; | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             this.class(value, convert => { | ||||
|                 convert = (converter != null ? converter(convert) : convert); | ||||
|                 if (convert) { | ||||
|                     return "readonly"; | ||||
|                 } else { | ||||
|                     return null; | ||||
|                 } | ||||
|             }); | ||||
|         } else if (value) { | ||||
|             this.attribute("readonly", "readonly"); | ||||
|             this.class("readonly"); | ||||
|         } | ||||
|  | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the type attribute of the element to be constructed by this template. | ||||
|      * @param {String|IgniteProperty} value The value to set for the type attribute of the element this template will construct. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user