Skip to content

Commit

Permalink
getValue fix for inline mode, minus button fix, HTML5 min/max attribu…
Browse files Browse the repository at this point in the history
…tes fix
  • Loading branch information
dioslaska committed May 8, 2012
1 parent 0972da2 commit dfe9f10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
22 changes: 10 additions & 12 deletions js/mobiscroll.core.js
Expand Up @@ -43,7 +43,7 @@

function read() {
that.temp = ((input && that.val !== null && that.val != elm.val()) || that.values === null) ? s.parseValue(elm.val() ? elm.val() : '', that) : that.values.slice(0);
that.setValue(false);
that.setValue(true);
}

function scrollToPos(time) {
Expand Down Expand Up @@ -168,12 +168,11 @@
* If input parameter is true, populates the associated input element.
* @param {Boolean} [fill] - Also set the value of the associated input element. Default is true.
*/
that.setValue = function (fill, time) {
if (fill == undefined) fill = true;
that.setValue = function (sc, fill, time) {
var v = s.formatResult(that.temp);
that.val = v;
that.values = that.temp.slice(0);
if (visible) scrollToPos(time);
if (visible && sc) scrollToPos(time);
if (fill && input) elm.val(v).trigger('change');
}

Expand Down Expand Up @@ -213,8 +212,8 @@
*/
that.change = function (manual) {
var v = s.formatResult(that.temp);
if (s.display == 'inline' && input)
elm.val(v).trigger('change');
if (s.display == 'inline')
that.setValue(false, true);
else
$('.dwv', dw).html(formatHeader(v));
if (manual)
Expand Down Expand Up @@ -281,7 +280,7 @@
if (s.display != 'inline') {
// Init buttons
$('.dwb-s a', dw).click(function () {
that.setValue();
that.setValue(false, true);
that.hide();
s.onSelect.call(e, that.val, that);
return false;
Expand Down Expand Up @@ -330,7 +329,7 @@
setGlobals(t);
clearInterval(timer);
timer = setInterval(function() { func(t); }, s.delay);
plus(t);
func(t);
}
}).delegate('.dwwl', START_EVENT, function (e) {
// Scroll start
Expand All @@ -357,7 +356,7 @@
*/
that.init = function(ss) {
// Get theme defaults
theme = $.extend({ defaults: {}, init: empty }, $.scroller.themes[ss.theme]);
theme = $.extend({ defaults: {}, init: empty }, $.scroller.themes[ss.theme ? ss.theme : s.theme]);

$.extend(s, theme.defaults, ss);

Expand Down Expand Up @@ -572,13 +571,12 @@
}
});
},
setValue: function(d, input, time) {
if (input == undefined) input = false;
setValue: function(d, fill, time) {
return this.each(function () {
var inst = getInst(this);
if (inst) {
inst.temp = d;
inst.setValue(input, time);
inst.setValue(true, fill, time);
}
});
},
Expand Down
20 changes: 11 additions & 9 deletions js/mobiscroll.datetime.js
Expand Up @@ -52,9 +52,9 @@
var min = that.attr('min'),
max = that.attr('max');
if (min)
defaults.minDate = new Date(min);
defaults.minDate = $.scroller.parseDate(format, min);
if (max)
defaults.maxDate = new Date(max);
defaults.maxDate = $.scroller.parseDate(format, max);
}

// Set year-month-day order
Expand Down Expand Up @@ -98,8 +98,8 @@
if (k == o.y) {
offset++;
w[s.yearText] = {};
start = mind ? mind.getFullYear() : s.startYear;
end = maxd ? maxd.getFullYear() : s.endYear;
var start = mind ? mind.getFullYear() : s.startYear,
end = maxd ? maxd.getFullYear() : s.endYear;
for (var i = start; i <= end; i++)
w[s.yearText][i] = dord.match(/yy/i) ? i : (i + '').substr(2, 2);
}
Expand Down Expand Up @@ -303,7 +303,7 @@
// Set wheels
for (var i in o)
inst.temp[o[i]] = d[f[i]] ? d[f[i]]() : f[i](d);
inst.setValue(fill, time);
inst.setValue(true, fill, time);
}
});
}
Expand Down Expand Up @@ -439,7 +439,8 @@
var digits = new RegExp('^\\d{1,' + size + '}');
var num = value.substr(iValue).match(digits);
if (!num)
throw 'Missing number at position ' + iValue;
return 0;
//throw 'Missing number at position ' + iValue;
iValue += num[0].length;
return parseInt(num[0], 10);
},
Expand All @@ -452,12 +453,13 @@
return i + 1;
}
}
throw 'Unknown name at position ' + iValue;
return 0;
//throw 'Unknown name at position ' + iValue;
},
// Confirm that a literal character matches the string value
checkLiteral = function() {
if (value.charAt(iValue) != format.charAt(iFormat))
throw 'Unexpected literal at position ' + iValue;
//if (value.charAt(iValue) != format.charAt(iFormat))
//throw 'Unexpected literal at position ' + iValue;
iValue++;
},
iValue = 0;
Expand Down

0 comments on commit dfe9f10

Please sign in to comment.