|
|
@ -1982,6 +1982,12 @@ $.fn.state = function(parameters) { |
|
|
|
inactive: function() { |
|
|
|
return !( $module.hasClass(className.active) ); |
|
|
|
}, |
|
|
|
state: function(state) { |
|
|
|
if(className[state] === undefined) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return $module.hasClass( className[state] ); |
|
|
|
}, |
|
|
|
|
|
|
|
enabled: function() { |
|
|
|
return !( $module.is(settings.filter.active) ); |
|
|
@ -1999,6 +2005,9 @@ $.fn.state = function(parameters) { |
|
|
|
}, |
|
|
|
input: function() { |
|
|
|
return $module.is('input'); |
|
|
|
}, |
|
|
|
progress: function() { |
|
|
|
return $module.is('.ui.progress'); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
@ -2487,7 +2496,10 @@ $.fn.state.settings = { |
|
|
|
className: { |
|
|
|
active : 'active', |
|
|
|
disabled : 'disabled', |
|
|
|
loading : 'loading' |
|
|
|
error : 'error', |
|
|
|
loading : 'loading', |
|
|
|
success : 'success', |
|
|
|
warning : 'warning' |
|
|
|
}, |
|
|
|
|
|
|
|
selector: { |
|
|
@ -2504,14 +2516,23 @@ $.fn.state.settings = { |
|
|
|
button: { |
|
|
|
disabled : true, |
|
|
|
loading : true, |
|
|
|
active : true |
|
|
|
active : true, |
|
|
|
}, |
|
|
|
progress: { |
|
|
|
active : true, |
|
|
|
success : true, |
|
|
|
warning : true, |
|
|
|
error : true |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
states : { |
|
|
|
disabled: true, |
|
|
|
loading : true, |
|
|
|
active : true |
|
|
|
active : true, |
|
|
|
disabled : true, |
|
|
|
error : true, |
|
|
|
loading : true, |
|
|
|
success : true, |
|
|
|
warning : true |
|
|
|
}, |
|
|
|
|
|
|
|
text : { |
|
|
@ -10439,6 +10460,7 @@ $.fn.progress = function(parameters) { |
|
|
|
$module = $(this), |
|
|
|
$bar = $(this).find(selector.bar), |
|
|
|
$progress = $(this).find(selector.progress), |
|
|
|
$label = $(this).find(selector.label), |
|
|
|
|
|
|
|
element = this, |
|
|
|
instance = $module.data(moduleNamespace), |
|
|
@ -10462,6 +10484,20 @@ $.fn.progress = function(parameters) { |
|
|
|
; |
|
|
|
}, |
|
|
|
|
|
|
|
destroy: function() { |
|
|
|
module.verbose('Destroying previous dropdown for', $module); |
|
|
|
$module |
|
|
|
.removeData(moduleNamespace) |
|
|
|
; |
|
|
|
instance = undefined; |
|
|
|
}, |
|
|
|
|
|
|
|
complete: function() { |
|
|
|
if(module.percent === undefined || module.percent < 100) { |
|
|
|
module.set.percent(100); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
read: { |
|
|
|
metadata: function() { |
|
|
|
if( $module.data(metadata.percent) ) { |
|
|
@ -10497,7 +10533,7 @@ $.fn.progress = function(parameters) { |
|
|
|
incrementValue = incrementValue || 1; |
|
|
|
newValue = startValue + incrementValue; |
|
|
|
edgeValue = module.total; |
|
|
|
module.debug('Incrementing completed by value', incrementValue, startValue, edgeValue); |
|
|
|
module.debug('Incrementing value by', incrementValue, startValue, edgeValue); |
|
|
|
if(newValue > edgeValue ) { |
|
|
|
module.debug('Value cannot decrement above total', edgeValue); |
|
|
|
newValue = edgeValue; |
|
|
@ -10527,7 +10563,7 @@ $.fn.progress = function(parameters) { |
|
|
|
startValue = module.value || 0; |
|
|
|
decrementValue = -decrementValue || -1; |
|
|
|
newValue = startValue + decrementValue; |
|
|
|
module.debug('Decrementing completed by value', decrementValue, startValue); |
|
|
|
module.debug('Decrementing value by', decrementValue, startValue); |
|
|
|
if(newValue > module.total ) { |
|
|
|
newValue = module.total; |
|
|
|
} |
|
|
@ -10543,6 +10579,21 @@ $.fn.progress = function(parameters) { |
|
|
|
}, |
|
|
|
|
|
|
|
get: { |
|
|
|
text: function(templateText) { |
|
|
|
var |
|
|
|
value = module.value || 0, |
|
|
|
total = module.total || 0, |
|
|
|
percent = module.percent || 0 |
|
|
|
; |
|
|
|
templateText = templateText || ''; |
|
|
|
templateText = templateText |
|
|
|
.replace('{value}', value) |
|
|
|
.replace('{total}', total) |
|
|
|
.replace('{percent}', percent) |
|
|
|
; |
|
|
|
module.debug('Adding variables to progress bar text', templateText); |
|
|
|
return templateText; |
|
|
|
}, |
|
|
|
randomValue: function() { |
|
|
|
module.debug('Generating random increment percentage'); |
|
|
|
return Math.floor((Math.random() * settings.random.max) + settings.random.min); |
|
|
@ -10559,8 +10610,10 @@ $.fn.progress = function(parameters) { |
|
|
|
}, |
|
|
|
|
|
|
|
set: { |
|
|
|
complete: function() { |
|
|
|
module.set.percent(100); |
|
|
|
barWidth: function(value) { |
|
|
|
$bar |
|
|
|
.css('width', value + '%') |
|
|
|
; |
|
|
|
}, |
|
|
|
initials: function() { |
|
|
|
if(settings.value) { |
|
|
@ -10575,21 +10628,91 @@ $.fn.progress = function(parameters) { |
|
|
|
module.verbose('Current percent set in settings', settings.percent); |
|
|
|
module.percent = settings.percent; |
|
|
|
} |
|
|
|
if(module.percent) { |
|
|
|
module.set.percent(module.percent); |
|
|
|
} |
|
|
|
else if(module.value) { |
|
|
|
module.set.progress(module.value); |
|
|
|
} |
|
|
|
}, |
|
|
|
percent: function(value) { |
|
|
|
value = (typeof value == 'string') |
|
|
|
? +(value.replace('%', '')) |
|
|
|
: value |
|
|
|
percent: function(percent) { |
|
|
|
percent = (typeof percent == 'string') |
|
|
|
? +(percent.replace('%', '')) |
|
|
|
: percent |
|
|
|
; |
|
|
|
console.log(value); |
|
|
|
if(value > 0 && value < 1) { |
|
|
|
if(percent > 0 && percent < 1) { |
|
|
|
module.verbose('Module percentage passed as decimal, converting'); |
|
|
|
value = value * 100; |
|
|
|
percent = percent * 100; |
|
|
|
} |
|
|
|
// round percentage
|
|
|
|
if(settings.precision === 0) { |
|
|
|
percent = Math.round(percent); |
|
|
|
} |
|
|
|
else { |
|
|
|
percent = Math.round(percent * (10 * settings.precision) / (10 * settings.precision) ); |
|
|
|
} |
|
|
|
module.percent = percent; |
|
|
|
if(module.total) { |
|
|
|
module.value = Math.round( (percent / 100) * module.total); |
|
|
|
} |
|
|
|
module.set.barWidth(percent); |
|
|
|
module.set.barLabel(); |
|
|
|
if(percent === 100 && settings.autoSuccess) { |
|
|
|
module.debug('Automatically triggering success at 100%'); |
|
|
|
module.set.success(); |
|
|
|
} |
|
|
|
else if(settings.text.active) { |
|
|
|
module.set.label(settings.text.active); |
|
|
|
} |
|
|
|
$.proxy(settings.onChange, element)(percent, module.value, module.total); |
|
|
|
}, |
|
|
|
label: function(text) { |
|
|
|
text = text || ''; |
|
|
|
if(text) { |
|
|
|
text = module.get.text(text); |
|
|
|
module.debug('Setting label to text', text); |
|
|
|
$label.text(text); |
|
|
|
} |
|
|
|
}, |
|
|
|
barLabel: function(text) { |
|
|
|
if(text !== undefined) { |
|
|
|
$progress.text( module.get.text(text) ); |
|
|
|
} |
|
|
|
else if(settings.label == 'ratio' && module.total) { |
|
|
|
module.debug('Adding ratio to bar label'); |
|
|
|
$progress.text( module.get.text(settings.text.ratio) ); |
|
|
|
} |
|
|
|
else if(settings.label == 'percent') { |
|
|
|
module.debug('Adding percentage to bar label'); |
|
|
|
$progress.text( module.get.text(settings.text.percent) ); |
|
|
|
} |
|
|
|
}, |
|
|
|
success : function(text) { |
|
|
|
text = text || settings.text.success; |
|
|
|
module.debug('Setting success state'); |
|
|
|
$module.addClass(className.success); |
|
|
|
module.complete(); |
|
|
|
if(text) { |
|
|
|
module.set.label(text); |
|
|
|
} |
|
|
|
}, |
|
|
|
warning : function(text) { |
|
|
|
text = text || settings.text.warning; |
|
|
|
module.debug('Setting warning state'); |
|
|
|
$module.addClass(className.warning); |
|
|
|
module.complete(); |
|
|
|
if(text) { |
|
|
|
module.set.label(text); |
|
|
|
} |
|
|
|
}, |
|
|
|
error : function(text) { |
|
|
|
text = text || settings.text.error; |
|
|
|
module.debug('Setting error state'); |
|
|
|
$module.addClass(className.error); |
|
|
|
module.complete(); |
|
|
|
if(text) { |
|
|
|
module.set.label(text); |
|
|
|
} |
|
|
|
module.percent = value; |
|
|
|
$bar |
|
|
|
.css('width', value + '%') |
|
|
|
; |
|
|
|
}, |
|
|
|
total: function(totalValue) { |
|
|
|
module.total = totalValue; |
|
|
@ -10608,7 +10731,7 @@ $.fn.progress = function(parameters) { |
|
|
|
} |
|
|
|
if(module.total) { |
|
|
|
module.value = numericValue; |
|
|
|
percentComplete = (numericValue / module.total); |
|
|
|
percentComplete = (numericValue / module.total) * 100; |
|
|
|
module.debug('Calculating percent complete from total', percentComplete); |
|
|
|
module.set.percent( percentComplete ); |
|
|
|
} |
|
|
@ -10802,26 +10925,32 @@ $.fn.progress.settings = { |
|
|
|
name : 'Progress', |
|
|
|
namespace : 'progress', |
|
|
|
|
|
|
|
debug : true, |
|
|
|
debug : false, |
|
|
|
verbose : true, |
|
|
|
performance : true, |
|
|
|
|
|
|
|
random : { |
|
|
|
min: 1, |
|
|
|
max: 3 |
|
|
|
random : { |
|
|
|
min : 1, |
|
|
|
max : 3 |
|
|
|
}, |
|
|
|
|
|
|
|
label : 'percent', |
|
|
|
autoSuccess : true, |
|
|
|
precision : 1, |
|
|
|
|
|
|
|
percent : false, |
|
|
|
total : false, |
|
|
|
value : false, |
|
|
|
|
|
|
|
onChange : function(value){}, |
|
|
|
onChange : function(percent, value, total){}, |
|
|
|
|
|
|
|
error : { |
|
|
|
method : 'The method you called is not defined.', |
|
|
|
nonNumeric : 'Progress value is non numeric' |
|
|
|
error : { |
|
|
|
method : 'The method you called is not defined.', |
|
|
|
nonNumeric : 'Progress value is non numeric' |
|
|
|
}, |
|
|
|
|
|
|
|
regExp: { |
|
|
|
variable: /\{\$*[A-z0-9]+\}/g |
|
|
|
}, |
|
|
|
|
|
|
|
metadata: { |
|
|
@ -10830,12 +10959,26 @@ $.fn.progress.settings = { |
|
|
|
value : 'value' |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
selector : { |
|
|
|
bar : '> .bar', |
|
|
|
label : '> .label', |
|
|
|
progress : '.bar > .progress' |
|
|
|
}, |
|
|
|
|
|
|
|
text : { |
|
|
|
active : false, |
|
|
|
error : false, |
|
|
|
success : false, |
|
|
|
warning : false, |
|
|
|
percent : '{percent}%', |
|
|
|
ratio : '{value} of {total}' |
|
|
|
}, |
|
|
|
|
|
|
|
className : { |
|
|
|
error : 'error', |
|
|
|
success : 'success', |
|
|
|
warning : 'warning' |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|