diff --git a/src/SKUI/control.rb b/src/SKUI/control.rb index 232db33..9097ec7 100644 --- a/src/SKUI/control.rb +++ b/src/SKUI/control.rb @@ -47,6 +47,10 @@ class Control < Base # @since 1.0.0 prop_writer( :font_name, :font_size ) # (!) Needs more work. + # @return [String] + # @since 1.0.0 + prop( :css_class, &TypeCheck::STRING ) + # @return [Rect] # @since 1.0.0 attr_reader( :rect ) @@ -57,6 +61,14 @@ def initialize @rect = Rect.new( self ) end + # Set a custom css class identifier for this control + # @since 1.0.0 + def css_class( css_class ) + if css_class.is_a? String + @properties[ :css_class ] = css_class + end + end + # Positive `x` value will anchor the control to the left side of the # container, negative will anchor the control to the right side. # diff --git a/src/SKUI/js/ui.control.js b/src/SKUI/js/ui.control.js index 533afe9..4b11224 100644 --- a/src/SKUI/js/ui.control.js +++ b/src/SKUI/js/ui.control.js @@ -12,6 +12,11 @@ function Control( jquery_element ) { Base.call( this, jquery_element ); } +Control.prototype.set_css_class = function( value ) { + this.control.addClass( value ); + return value; +}; + Control.prototype.set_disabled = function( value ) { this.control.toggleClass( 'disabled', value ); this.control.prop( 'disabled', value );