Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom css class identifier #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/SKUI/control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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.
#
Expand Down
5 changes: 5 additions & 0 deletions src/SKUI/js/ui.control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down