You can pass many options explained at the bottom of this README, the best way to understand what this plugin does is to check the example in the documentation.
https://github.com/benichu/jquery.one-hot-minute
If you find a bug, please raise it the issue here on Github!
download this file jquery.one-hot-minute.min.js, and add it to your project.
Format an element's display value to a duration format: HH:MM
That HTML element should have a data-minute
attribute
(or whatever is defined as an option dataAttr
) with the raw value to be converted.
Example
<span id="my_element" data-minute="130">130</span>
#=> <span id="my_element" data-minute="130">2h10</span>
also,
<input id="my_element" data-minute="130" />
#=> <input id="my_element" data-minute="130" value="2h10" />
Basic Initialization
$("#main").oneHotMinute({
processableElements: ['span', 'input'],
processMethod: "minutesToHours",
onReady: function(el) {
// do whatever you want...
}
});
Format an element's content value into minutes, and saves it
into a pre-defined element's data attribute
(ex: data-minute
or whatever is defined as an option saveAttr
)
Example
<input id="my_element" value="1.5" />
#=> <input id="my_element" data-minute="90" value="1.5" />
also,
<input id="my_element" value="1h30" />
#=> <input id="my_element" data-minute="90" value="1h30" />
Basic Initialization
$("#main").oneHotMinute({
processableElements: ['span', 'input'],
processMethod: "valueToMinutes",
onReady: function(el) {
// do whatever you want...
},
onBlur: function(el) {
// apply some formatting on value change.
this.minutesToHours(el);
}
});
debug: false
processMethod: "minutesToHours" # ["minutesToHours", "valueToMinutes"]
processableElements: ['span', 'input'] # What elements are we trying to process?
dataAttr: "data-minute" # attribute with the raw value to be converted (used with processMethod: `minutesToHours`)
saveAttr: "data-minute" # attribute where the converted value is saved (used with processMethod: `valueToMinutes`)
onReady: -> # Function(), called when oneHotMinute has processed all the elements
onError: -> # Function(), called when oneHotMinute has experienced an error
Developed by Benjamin Thouret, benjamin.thouret.com, Github Profile
Based on the MiniBoilerplate template.
Check MiniBoilerplate's website for instructions about the development workflow to be used for improving this plugin.