Skip to content

Commit

Permalink
Now a widget option may be also a function that is passed both the or…
Browse files Browse the repository at this point in the history
…iginal Html5 node, and the replaced node, and that must return an instance specific option object. This way, each widget instance may have a different option object.
  • Loading branch information
frankabbruzzese committed Oct 25, 2016
1 parent 56f0d73 commit e658333
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
22 changes: 12 additions & 10 deletions bootstrap.html5.fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@
$.fn.datetimepicker.dates = $.fn.datetimepicker.dates || {};
$.fn.datetimepicker.dates[culture]=res;
}
function getOptions(options, name){
function getOptions(options, name, fNode, oNode){
var userOptions=options.html5FallbackWidgets ||{};
userOptions=userOptions[name] ||{};
if(typeof userOptions === "function")
userOptions=userOptions(fNode, oNode) || {};
var res= {};
for(var prop in defaults){
res[prop]=userOptions[prop];;
for(var prop in userOptions){
res[prop]=userOptions[prop];
}
return res;
}
Expand Down Expand Up @@ -192,7 +194,7 @@
var enhance=handlers.enhance=handlers.enhance || {};
if (enhance.date !== null)
enhance.date = function (fNode, oNode) {
var o = getOptions(options, "date");
var o = getOptions(options, "date", fNode, oNode);
o.language = culture;
o.startView = 2;
if (typeof o.autoclose == "undefined") o.autoclose = true;
Expand All @@ -213,7 +215,7 @@
};
if (enhance.week !== null)
enhance.week = function(fNode, oNode){
var o = getOptions(options, "week");
var o = getOptions(options, "week", fNode, oNode);
o.language = culture;
o.startView = 2;
if (typeof o.autoclose == "undefined") o.autoclose = true;
Expand All @@ -234,7 +236,7 @@
};
if (enhance.month !== null)
enhance.month = function(fNode, oNode){
var o = getOptions(options, "month");
var o = getOptions(options, "month", fNode, oNode);
o.language = culture;
o.startView = 3;
if (typeof o.autoclose == "undefined") o.autoclose = true;
Expand All @@ -255,7 +257,7 @@
};
if (enhance.time !== null)
enhance.time = function(fNode, oNode){
var o = getOptions(options, "time");
var o = getOptions(options, "time", fNode, oNode);
o.language = culture;
o.startView = o.maxView = 1;
if (typeof o.autoclose == "undefined") o.autoclose = true;
Expand All @@ -276,7 +278,7 @@
};
if (enhance.datetime !== null)
enhance.datetime = function(fNode, oNode){
var o = getOptions(options, "datetime");
var o = getOptions(options, "datetime", fNode, oNode);
o.language = culture;
o.startView = 2;
if (typeof o.autoclose == "undefined") o.autoclose = true;
Expand All @@ -298,7 +300,7 @@
var humanFNFormatter = mvcct.enhancer.Globalize().numberFormatter();
if (enhance.range !== null)
enhance.range = function (fNode, oNode) {
var o = getOptions(options, "range");
var o = getOptions(options, "range", fNode, oNode);
o.min= enhancer.parse("range", oNode.getAttribute("min"), true);
o.max= enhancer.parse("range", oNode.getAttribute("max"), true);
o.step = enhancer.parse("range", oNode.getAttribute("step"), true);
Expand All @@ -322,7 +324,7 @@
};
if (enhance.color !== null)
enhance.color = function(fNode, oNode){
var o = getOptions(options, "range");
var o = getOptions(options, "range", fNode, oNode);
if(typeof o.format == "undefined") o.format = "hex";
var newContent;
if(o.makeComponent){
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.html5.fallback.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-html5-fallback",
"version": "1.0.1",
"version": "1.0.2",
"homepage": "https://github.com/MvcControlsToolkit/bootstrap-html5-fallback",
"description": "bootstrap widgets based html5 inputs fallback",
"main": [
Expand All @@ -21,7 +21,7 @@
"polyfill"
],
"dependencies": {
"mvcct-enhancer": ">=1.0.0",
"mvcct-enhancer": ">=1.0.1",
"bootstrap-colorpicker": ">=2.3.3",
"smalot-bootstrap-datetimepicker": ">=2.3.10",
"seiyria-bootstrap-slider": ">=7.0.3"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-html5-fallback",
"version": "1.0.1",
"version": "1.0.2",
"description": "bootstrap widgets based html5 inputs fallback",
"main": "bootstrap.html5.fallback.js",
"repository": {
Expand Down Expand Up @@ -28,7 +28,7 @@
"bootstrap.html5.fallback.d.ts"
],
"dependencies": {
"mvcct-enhancer": ">=1.0.0",
"mvcct-enhancer": ">=1.0.1",
"bootstrap-colorpicker": ">=2.3.3",
"bootstrap-datetime-picker": ">=2.3.10",
"bootstrap-slider": ">=7.0.2"
Expand Down

0 comments on commit e658333

Please sign in to comment.