diff --git a/server/documents/elements/header.html.eco b/server/documents/elements/header.html.eco index eaed6d047..35282cc81 100755 --- a/server/documents/elements/header.html.eco +++ b/server/documents/elements/header.html.eco @@ -9,7 +9,7 @@ title : 'Header' description : 'A header provides a short summary of content' type : 'UI Element' -themes : ['Default', 'Bookish', 'Chubby'] +themes : ['Default', 'Classic', 'Bookish', 'Chubby'] --- <%- @partial('header') %> @@ -139,24 +139,24 @@ themes : ['Default', 'Bookish', 'Chubby']

Attached

-

A header can be attached to other content, like a segment

-

+

A header can be attached to other content, like a segment

+

Bulldog -
+

Bulldog is the name for a breed of dog commonly referred to as the English Bulldog. Other Bulldog breeds include the American Bulldog, Old English Bulldog (now extinct), Olde English Bulldogge, and the French Bulldog. The Bulldog is a muscular, heavy dog with a wrinkled face and a distinctive pushed-in nose.

The American Kennel Club (AKC), The Kennel Club (UK), and the United Kennel Club (UKC) oversee breeding standards. Bulldogs are the 5th most popular purebreed in the United States in 2013 according to the American Kennel Club.

-

+

Catahoula Cur -
+

The Catahoula Cur is an American dog breed named after Catahoula Parish, in the state of Louisiana, in the United States. After becoming the state dog of Louisiana in 1979, its name was officially changed to Louisiana Catahoula Leopard Dog. The Catahoula is believed to be the first dog breed developed in North America.

The breed is sometimes referred to as the "Catahoula Hound" or "Catahoula Leopard Hound", although it is not a true hound, but a cur. It is also called the "Catahoula Hog Dog", reflecting its traditional use in hunting wild boar.

-

+

Thanks for reading -
+
diff --git a/server/documents/elements/segment.html.eco b/server/documents/elements/segment.html.eco index 44e8edc40..8fb49bd52 100755 --- a/server/documents/elements/segment.html.eco +++ b/server/documents/elements/segment.html.eco @@ -45,7 +45,7 @@ themes : ['default', 'GitHub']

Horizontal Segment

A vertical segment formats content to be aligned as part of a horizontal group

-

When to Use Horizontal Segments

+
When to Use Horizontal Segments

Horizontal segments are most effectively used with grids, to allow for text groups that are aligned across grid rows.

A horizontal segment adds horizontal padding and a horizontal border, while a basic horizontal segment adds only the padding but not the border.

diff --git a/server/documents/modules/checkbox.html.eco b/server/documents/modules/checkbox.html.eco index 4fe02dce7..30641d0ee 100755 --- a/server/documents/modules/checkbox.html.eco +++ b/server/documents/modules/checkbox.html.eco @@ -84,6 +84,34 @@ themes : ['Default']
+

States

+ +
+

Read-only

+

A checkbox can be read-only and unable to change states

+
+ + +
+
+ +
+

Disabled

+

A checkbox can be read-only and unable to change states

+
+ A checkbox can be disabled by either setting disabled on the hidden input, or class disabled on the ui checkbox +
+
+ + +
+
+
+
+ + +
+
@@ -104,7 +132,7 @@ themes : ['Default'] -

Checkbox without Javascript

+

Basic Checkbox

A checkbox can also be used without using javascript by matching the id attribute of the input field to the for attribute of the accompanying label

@@ -135,76 +163,89 @@ themes : ['Default']

Examples

+
+

Disabled / Read Only / Forced

+

To disable a checkbox, add the property disabled to your input.

+

To make a checkbox read-only do not initialize it, or include the read-only class which will not allow events even if initialized.

+

To make a user able to check a box, but unable to uncheck it, use the uncheckable setting.

+
+ $('#demo3') + .checkbox({ + uncheckable: true + }) + ; +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
-

Example of using checkbox states to alter multiple checkboxes

+

Attaching Events to other Elements

+

Checkbox can use the attach events behavior to attach events easily to other activating elements. This defaults to toggling, but other behaviors can be used as well.

- $('.check.button') - .on('click', function() { - $(this) - .nextAll('.checkbox') - .checkbox('check') - ; - }) - ; - $('.uncheck.button') - .on('click', function() { - $(this) - .nextAll('.checkbox') - .checkbox('uncheck') - ; - }) - ; - $('.toggle.button') - .on('click', function() { - $(this) - .nextAll('.checkbox') - .checkbox('toggle') - ; - }) - ; + $('.test.checkbox').checkbox('attach events', '.toggle.button'); + $('.test.checkbox').checkbox('attach events', '.check.button', 'check'); + $('.test.checkbox').checkbox('attach events', '.uncheck.button', 'uncheck');
Toggle
Check
Uncheck


-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/server/files/javascript/checkbox.js b/server/files/javascript/checkbox.js index 781dfe5d9..a22fc51be 100755 --- a/server/files/javascript/checkbox.js +++ b/server/files/javascript/checkbox.js @@ -4,7 +4,7 @@ semantic.dropdown = {}; semantic.dropdown.ready = function() { // selector cache - var + var $checkbox = $('.example').not('.static').find('.ui.checkbox'), // alias handler @@ -12,13 +12,13 @@ semantic.dropdown.ready = function() { // event handlers handler = { - + }; $checkbox .checkbox() ; - + }; diff --git a/server/files/stylesheets/semantic.css b/server/files/stylesheets/semantic.css index 6512f6790..20056643f 100755 --- a/server/files/stylesheets/semantic.css +++ b/server/files/stylesheets/semantic.css @@ -110,7 +110,7 @@ code { background-color: rgba(0, 0, 0, 0.02); border-radius: 0.2em; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1); - color: #333333; + color: rgba(0, 0, 0, 0.75); font-weight: bold; display: inline-block; font-family: "Monaco","Menlo","Ubuntu Mono","Consolas","source-code-pro",monospace; @@ -1290,6 +1290,7 @@ body.progress.animated .ui.progress .bar { box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.05); border-left: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD; + border-bottom: 1px solid #DDDDDD; padding: 2em 3em 2em; z-index: 1; } diff --git a/src/definitions/modules/checkbox.js b/src/definitions/modules/checkbox.js index d7bb78767..bc798455f 100755 --- a/src/definitions/modules/checkbox.js +++ b/src/definitions/modules/checkbox.js @@ -34,18 +34,19 @@ $.fn.checkbox = function(parameters) { className = settings.className, namespace = settings.namespace, + selector = settings.selector, error = settings.error, eventNamespace = '.' + namespace, moduleNamespace = 'module-' + namespace, $module = $(this), - $label = $(this).next(settings.selector.label).first(), - $input = $(this).find(settings.selector.input), + $label = $(this).next(selector.label).first(), + $input = $(this).find(selector.input), - selector = $module.selector || '', instance = $module.data(moduleNamespace), + observer, element = this, module ; @@ -54,24 +55,10 @@ $.fn.checkbox = function(parameters) { initialize: function() { module.verbose('Initializing checkbox', settings); - if(settings.context && selector !== '') { - module.verbose('Adding delegated events'); - $(element, settings.context) - .on(selector, 'click' + eventNamespace, module.toggle) - .on(selector + ' + ' + settings.selector.label, 'click' + eventNamespace, module.toggle) - ; - } - else { - $module - .on('click' + eventNamespace, module.toggle) - ; - $input - .on('keydown' + eventNamespace, module.event.keydown) - ; - $label - .on('click' + eventNamespace, module.toggle) - ; - } + $module + .on('click' + eventNamespace, module.toggle) + .on('keydown' + eventNamespace, selector.input, module.event.keydown) + ; if( module.is.checked() ) { module.set.checked(); if(settings.fireOnInit) { @@ -84,6 +71,8 @@ $.fn.checkbox = function(parameters) { $.proxy(settings.onUnchecked, $input.get())(); } } + module.observeChanges(); + module.instantiate(); }, @@ -109,6 +98,45 @@ $.fn.checkbox = function(parameters) { ; }, + refresh: function() { + $module = $(this); + $label = $(this).next(selector.label).first(); + $input = $(this).find(selector.input); + }, + + observeChanges: function() { + if(MutationObserver !== undefined) { + observer = new MutationObserver(function(mutations) { + module.debug('DOM tree modified, updating selector cache'); + module.refresh(); + }); + observer.observe(element, { + childList : true, + subtree : true + }); + module.debug('Setting up mutation observer', observer); + } + }, + + attachEvents: function(selector, event) { + var + $toggle = $(selector) + ; + event = $.isFunction(module[event]) + ? module[event] + : module.toggle + ; + if($toggle.size() > 0) { + module.debug('Attaching checkbox events to element', selector, event); + $toggle + .on('click' + eventNamespace, event) + ; + } + else { + module.error(error.notFound); + } + }, + event: { keydown: function(event) { var @@ -145,9 +173,12 @@ $.fn.checkbox = function(parameters) { }, can: { + change: function() { + return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') ); + }, uncheck: function() { - return (typeof settings.required === 'boolean') - ? settings.required + return (typeof settings.uncheckable === 'boolean') + ? !settings.uncheckable : !module.is.radio() ; } @@ -165,6 +196,15 @@ $.fn.checkbox = function(parameters) { } }, + disable: function() { + module.debug('Enabling checkbox functionality'); + $module.addClass(className.disabled); + }, + enable: function() { + module.debug('Disabling checkbox functionality'); + $module.removeClass(className.disabled); + }, + check: function() { module.debug('Enabling checkbox', $input); $input @@ -188,6 +228,11 @@ $.fn.checkbox = function(parameters) { }, toggle: function(event) { + if( !module.can.change() ) { + console.log(module.can.change()); + module.debug('Checkbox is read-only or disabled, ignoring toggle'); + return; + } module.verbose('Determining new checkbox state'); if( module.is.unchecked() ) { module.check(); @@ -258,9 +303,9 @@ $.fn.checkbox = function(parameters) { executionTime = currentTime - previousTime; time = currentTime; performance.push({ - 'Element' : element, 'Name' : message[0], 'Arguments' : [].slice.call(message, 1) || '', + 'Element' : element, 'Execution Time' : executionTime }); } @@ -383,13 +428,15 @@ $.fn.checkbox.settings = { // delegated event context context : false, - required : 'auto', + uncheckable : 'auto', fireOnInit : true, - className: { - checked : 'checked', - radio : 'radio' + className : { + checked : 'checked', + radio : 'radio', + disabled : 'disabled', + readOnly : 'read-only' }, onChange : function(){}, @@ -403,7 +450,7 @@ $.fn.checkbox.settings = { selector : { input : 'input[type=checkbox], input[type=radio]', label : 'label' - }, + } }; diff --git a/src/definitions/modules/checkbox.less b/src/definitions/modules/checkbox.less index a575c6ce9..f59661be7 100755 --- a/src/definitions/modules/checkbox.less +++ b/src/definitions/modules/checkbox.less @@ -46,7 +46,7 @@ position: absolute; top: 0px; left: 0px; - opacity: 0; + opacity: 0 !important; outline: none; z-index: -1; } @@ -178,6 +178,16 @@ opacity: 1; } +/*-------------- + Read-Only +---------------*/ + +.ui.read-only.checkbox, +.ui.read-only.checkbox label { + cursor: default; +} + + /*-------------- Disabled ---------------*/ @@ -186,6 +196,7 @@ .ui.disabled.checkbox label, .ui.checkbox input[disabled] ~ .box:after, .ui.checkbox input[disabled] ~ label { + cursor: default; opacity: @disabledCheckboxOpacity; color: @disabledCheckboxLabelColor; }