Browse Source

formatting and build dist #2656

pull/2850/head
Jack Lukic 9 years ago
parent
commit
3552fb5257
5 changed files with 262 additions and 106 deletions
  1. 172
      dist/components/checkbox.js
  2. 2
      dist/components/checkbox.min.js
  3. 172
      dist/semantic.js
  4. 20
      dist/semantic.min.js
  5. 2
      src/definitions/modules/checkbox.js

172
dist/components/checkbox.js

@ -43,9 +43,10 @@ $.fn.checkbox = function(parameters) {
$module = $(this),
$label = $(this).children(selector.label),
$input = $(this).children(selector.input),
input = $input[0],
initialLoad = false,
shortcutPressed = false,
instance = $module.data(moduleNamespace),
observer,
@ -95,35 +96,26 @@ $.fn.checkbox = function(parameters) {
},
setup: function() {
module.set.initialLoad();
if( module.is.indeterminate() ) {
module.debug('Initial value is indeterminate');
module.set.indeterminate();
if(settings.fireOnInit) {
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
}
module.indeterminate();
}
else if( module.is.checked() ) {
module.debug('Initial value is checked');
module.set.checked();
if(settings.fireOnInit) {
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
}
module.check();
}
else {
module.debug('Initial value is unchecked');
module.set.unchecked();
if(settings.fireOnInit) {
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
}
module.uncheck();
}
module.remove.initialLoad();
},
refresh: function() {
$label = $module.children(selector.label);
$input = $module.children(selector.input);
input = $input[0];
},
hide: {
@ -174,10 +166,17 @@ $.fn.checkbox = function(parameters) {
event: {
click: function(event) {
if( $(event.target).is(selector.input) ) {
var
$target = $(event.target)
;
if( $target.is(selector.input) ) {
module.verbose('Using default check action on initialized checkbox');
return;
}
if( $target.is(selector.link) ) {
module.debug('Clicking link inside checkbox, skipping toggle');
return;
}
module.toggle();
$input.focus();
event.preventDefault();
@ -213,47 +212,53 @@ $.fn.checkbox = function(parameters) {
},
check: function() {
if( !module.is.indeterminate() && module.is.checked() ) {
module.debug('Checkbox is already checked');
if( !module.should.allowCheck() ) {
return;
}
module.debug('Checking checkbox', $input);
module.set.checked();
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onChecked.call(input);
settings.onChange.call(input);
}
},
uncheck: function() {
if( !module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Checkbox is already unchecked');
if( !module.should.allowUncheck() ) {
return;
}
module.debug('Unchecking checkbox');
module.set.unchecked();
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onUnchecked.call(input);
settings.onChange.call(input);
}
},
indeterminate: function() {
if( module.is.indeterminate() ) {
if( module.should.allowIndeterminate() ) {
module.debug('Checkbox is already indeterminate');
return;
}
module.debug('Making checkbox indeterminate');
module.set.indeterminate();
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onIndeterminate.call(input);
settings.onChange.call(input);
}
},
determinate: function() {
if( module.is.determinate() ) {
if( module.should.allowDeterminate() ) {
module.debug('Checkbox is already determinate');
return;
}
module.debug('Making checkbox determinate');
module.set.determinate();
settings.onDeterminate.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onDeterminate.call(input);
settings.onChange.call(input);
}
},
enable: function() {
@ -263,7 +268,7 @@ $.fn.checkbox = function(parameters) {
}
module.debug('Enabling checkbox');
module.set.enabled();
settings.onEnable.call($input[0]);
settings.onEnable.call(input);
},
disable: function() {
@ -273,7 +278,7 @@ $.fn.checkbox = function(parameters) {
}
module.debug('Disabling checkbox');
module.set.disabled();
settings.onDisable.call($input[0]);
settings.onDisable.call(input);
},
get: {
@ -292,6 +297,9 @@ $.fn.checkbox = function(parameters) {
},
is: {
initialLoad: function() {
return initialLoad;
},
radio: function() {
return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
},
@ -315,6 +323,59 @@ $.fn.checkbox = function(parameters) {
}
},
should: {
allowCheck: function() {
if(module.is.determinate() && module.is.checked() && !module.should.forceCallbacks() ) {
module.debug('Should not allow check, checkbox is already checked');
return false;
}
if(settings.beforeChecked.apply(input) === false) {
module.debug('Should not allow check, beforeChecked cancelled');
return false;
}
return true;
},
allowUncheck: function() {
if(module.is.determinate() && module.is.unchecked() && !module.should.forceCallbacks() ) {
module.debug('Should not allow uncheck, checkbox is already unchecked');
return false;
}
if(settings.beforeUnchecked.apply(input) === false) {
module.debug('Should not allow uncheck, beforeUnchecked cancelled');
return false;
}
return true;
},
allowIndeterminate: function() {
if(module.is.indeterminate() && !module.should.forceCallbacks() ) {
module.debug('Should not allow indeterminate, checkbox is already indeterminate');
return false;
}
if(settings.beforeIndeterminate.apply(input) === false) {
module.debug('Should not allow indeterminate, beforeIndeterminate cancelled');
return false;
}
return true;
},
allowDeterminate: function() {
if(module.is.determinate() && !module.should.forceCallbacks() ) {
module.debug('Should not allow determinate, checkbox is already determinate');
return false;
}
if(settings.beforeDeterminate.apply(input) === false) {
module.debug('Should not allow determinate, beforeDeterminate cancelled');
return false;
}
return true;
},
forceCallbacks: function() {
return (module.is.initialLoad() && settings.fireOnInit);
},
ignoreCallbacks: function() {
return (initialLoad && !settings.fireOnInit);
}
},
can: {
change: function() {
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
@ -328,6 +389,9 @@ $.fn.checkbox = function(parameters) {
},
set: {
initialLoad: function() {
initialLoad = true;
},
checked: function() {
module.verbose('Setting class to checked');
$module
@ -341,7 +405,7 @@ $.fn.checkbox = function(parameters) {
module.debug('Input is already checked, skipping input property change');
return;
}
module.verbose('Setting state to checked', $input[0]);
module.verbose('Setting state to checked', input);
$input
.prop('indeterminate', false)
.prop('checked', true)
@ -430,6 +494,12 @@ $.fn.checkbox = function(parameters) {
}
},
remove: {
initialLoad: function() {
initialLoad = false;
}
},
trigger: {
change: function() {
module.verbose('Triggering change event from programmatic change');
@ -682,27 +752,32 @@ $.fn.checkbox = function(parameters) {
$.fn.checkbox.settings = {
name : 'Checkbox',
namespace : 'checkbox',
name : 'Checkbox',
namespace : 'checkbox',
debug : false,
verbose : true,
performance : true,
debug : false,
verbose : true,
performance : true,
// delegated event context
uncheckable : 'auto',
fireOnInit : false,
uncheckable : 'auto',
fireOnInit : false,
onChange : function(){},
onChange : function(){},
beforeChecked : function(){},
beforeUnchecked : function(){},
beforeDeterminate : function(){},
beforeIndeterminate : function(){},
onChecked : function(){},
onUnchecked : function(){},
onChecked : function(){},
onUnchecked : function(){},
onDeterminate : function() {},
onIndeterminate : function() {},
onDeterminate : function() {},
onIndeterminate : function() {},
onEnabled : function(){},
onDisabled : function(){},
onEnabled : function(){},
onDisabled : function(){},
className : {
checked : 'checked',
@ -721,6 +796,7 @@ $.fn.checkbox.settings = {
checkbox : '.ui.checkbox',
label : 'label, .box',
input : 'input[type="checkbox"], input[type="radio"]',
link : 'a[href]'
}
};

2
dist/components/checkbox.min.js
File diff suppressed because it is too large
View File

172
dist/semantic.js

@ -2444,9 +2444,10 @@ $.fn.checkbox = function(parameters) {
$module = $(this),
$label = $(this).children(selector.label),
$input = $(this).children(selector.input),
input = $input[0],
initialLoad = false,
shortcutPressed = false,
instance = $module.data(moduleNamespace),
observer,
@ -2496,35 +2497,26 @@ $.fn.checkbox = function(parameters) {
},
setup: function() {
module.set.initialLoad();
if( module.is.indeterminate() ) {
module.debug('Initial value is indeterminate');
module.set.indeterminate();
if(settings.fireOnInit) {
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
}
module.indeterminate();
}
else if( module.is.checked() ) {
module.debug('Initial value is checked');
module.set.checked();
if(settings.fireOnInit) {
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
}
module.check();
}
else {
module.debug('Initial value is unchecked');
module.set.unchecked();
if(settings.fireOnInit) {
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
}
module.uncheck();
}
module.remove.initialLoad();
},
refresh: function() {
$label = $module.children(selector.label);
$input = $module.children(selector.input);
input = $input[0];
},
hide: {
@ -2575,10 +2567,17 @@ $.fn.checkbox = function(parameters) {
event: {
click: function(event) {
if( $(event.target).is(selector.input) ) {
var
$target = $(event.target)
;
if( $target.is(selector.input) ) {
module.verbose('Using default check action on initialized checkbox');
return;
}
if( $target.is(selector.link) ) {
module.debug('Clicking link inside checkbox, skipping toggle');
return;
}
module.toggle();
$input.focus();
event.preventDefault();
@ -2614,47 +2613,53 @@ $.fn.checkbox = function(parameters) {
},
check: function() {
if( !module.is.indeterminate() && module.is.checked() ) {
module.debug('Checkbox is already checked');
if( !module.should.allowCheck() ) {
return;
}
module.debug('Checking checkbox', $input);
module.set.checked();
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onChecked.call(input);
settings.onChange.call(input);
}
},
uncheck: function() {
if( !module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Checkbox is already unchecked');
if( !module.should.allowUncheck() ) {
return;
}
module.debug('Unchecking checkbox');
module.set.unchecked();
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onUnchecked.call(input);
settings.onChange.call(input);
}
},
indeterminate: function() {
if( module.is.indeterminate() ) {
if( module.should.allowIndeterminate() ) {
module.debug('Checkbox is already indeterminate');
return;
}
module.debug('Making checkbox indeterminate');
module.set.indeterminate();
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onIndeterminate.call(input);
settings.onChange.call(input);
}
},
determinate: function() {
if( module.is.determinate() ) {
if( module.should.allowDeterminate() ) {
module.debug('Checkbox is already determinate');
return;
}
module.debug('Making checkbox determinate');
module.set.determinate();
settings.onDeterminate.call($input[0]);
settings.onChange.call($input[0]);
if( !module.should.ignoreCallbacks() ) {
settings.onDeterminate.call(input);
settings.onChange.call(input);
}
},
enable: function() {
@ -2664,7 +2669,7 @@ $.fn.checkbox = function(parameters) {
}
module.debug('Enabling checkbox');
module.set.enabled();
settings.onEnable.call($input[0]);
settings.onEnable.call(input);
},
disable: function() {
@ -2674,7 +2679,7 @@ $.fn.checkbox = function(parameters) {
}
module.debug('Disabling checkbox');
module.set.disabled();
settings.onDisable.call($input[0]);
settings.onDisable.call(input);
},
get: {
@ -2693,6 +2698,9 @@ $.fn.checkbox = function(parameters) {
},
is: {
initialLoad: function() {
return initialLoad;
},
radio: function() {
return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
},
@ -2716,6 +2724,59 @@ $.fn.checkbox = function(parameters) {
}
},
should: {
allowCheck: function() {
if(module.is.determinate() && module.is.checked() && !module.should.forceCallbacks() ) {
module.debug('Should not allow check, checkbox is already checked');
return false;
}
if(settings.beforeChecked.apply(input) === false) {
module.debug('Should not allow check, beforeChecked cancelled');
return false;
}
return true;
},
allowUncheck: function() {
if(module.is.determinate() && module.is.unchecked() && !module.should.forceCallbacks() ) {
module.debug('Should not allow uncheck, checkbox is already unchecked');
return false;
}
if(settings.beforeUnchecked.apply(input) === false) {
module.debug('Should not allow uncheck, beforeUnchecked cancelled');
return false;
}
return true;
},
allowIndeterminate: function() {
if(module.is.indeterminate() && !module.should.forceCallbacks() ) {
module.debug('Should not allow indeterminate, checkbox is already indeterminate');
return false;
}
if(settings.beforeIndeterminate.apply(input) === false) {
module.debug('Should not allow indeterminate, beforeIndeterminate cancelled');
return false;
}
return true;
},
allowDeterminate: function() {
if(module.is.determinate() && !module.should.forceCallbacks() ) {
module.debug('Should not allow determinate, checkbox is already determinate');
return false;
}
if(settings.beforeDeterminate.apply(input) === false) {
module.debug('Should not allow determinate, beforeDeterminate cancelled');
return false;
}
return true;
},
forceCallbacks: function() {
return (module.is.initialLoad() && settings.fireOnInit);
},
ignoreCallbacks: function() {
return (initialLoad && !settings.fireOnInit);
}
},
can: {
change: function() {
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
@ -2729,6 +2790,9 @@ $.fn.checkbox = function(parameters) {
},
set: {
initialLoad: function() {
initialLoad = true;
},
checked: function() {
module.verbose('Setting class to checked');
$module
@ -2742,7 +2806,7 @@ $.fn.checkbox = function(parameters) {
module.debug('Input is already checked, skipping input property change');
return;
}
module.verbose('Setting state to checked', $input[0]);
module.verbose('Setting state to checked', input);
$input
.prop('indeterminate', false)
.prop('checked', true)
@ -2831,6 +2895,12 @@ $.fn.checkbox = function(parameters) {
}
},
remove: {
initialLoad: function() {
initialLoad = false;
}
},
trigger: {
change: function() {
module.verbose('Triggering change event from programmatic change');
@ -3083,27 +3153,32 @@ $.fn.checkbox = function(parameters) {
$.fn.checkbox.settings = {
name : 'Checkbox',
namespace : 'checkbox',
name : 'Checkbox',
namespace : 'checkbox',
debug : false,
verbose : true,
performance : true,
debug : false,
verbose : true,
performance : true,
// delegated event context
uncheckable : 'auto',
fireOnInit : false,
uncheckable : 'auto',
fireOnInit : false,
onChange : function(){},
onChange : function(){},
beforeChecked : function(){},
beforeUnchecked : function(){},
beforeDeterminate : function(){},
beforeIndeterminate : function(){},
onChecked : function(){},
onUnchecked : function(){},
onChecked : function(){},
onUnchecked : function(){},
onDeterminate : function() {},
onIndeterminate : function() {},
onDeterminate : function() {},
onIndeterminate : function() {},
onEnabled : function(){},
onDisabled : function(){},
onEnabled : function(){},
onDisabled : function(){},
className : {
checked : 'checked',
@ -3122,6 +3197,7 @@ $.fn.checkbox.settings = {
checkbox : '.ui.checkbox',
label : 'label, .box',
input : 'input[type="checkbox"], input[type="radio"]',
link : 'a[href]'
}
};

20
dist/semantic.min.js
File diff suppressed because it is too large
View File

2
src/definitions/modules/checkbox.js

@ -369,7 +369,7 @@ $.fn.checkbox = function(parameters) {
return true;
},
forceCallbacks: function() {
return module.is.initialLoad() && settings.fireOnInit;
return (module.is.initialLoad() && settings.fireOnInit);
},
ignoreCallbacks: function() {
return (initialLoad && !settings.fireOnInit);

Loading…
Cancel
Save