forked from 0x2620/oxjs
rather use ''.slice than ''.substr
This commit is contained in:
parent
f990f3b857
commit
1608664bb6
20 changed files with 69 additions and 71 deletions
|
|
@ -113,7 +113,7 @@ Ox.Button = function(options, self) {
|
|||
that.attr({
|
||||
src: Ox.UI.getImageURL(
|
||||
'symbol' + self.options.title[0].toUpperCase()
|
||||
+ self.options.title.substr(1)
|
||||
+ self.options.title.slice(1)
|
||||
)
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ Ox.Input = function(options, self) {
|
|||
} else if (/\./.test(value) && self.options.decimals) {
|
||||
length = value.split('.')[1].length;
|
||||
if (length > self.options.decimals) {
|
||||
value = value.substr(0, value.indexOf('.') + 1 + self.options.decimals);
|
||||
value = value.slice(0, value.indexOf('.') + 1 + self.options.decimals);
|
||||
cursor = [oldCursor[0] + 1, oldCursor[1] + 1];
|
||||
} else if (length < self.options.decimals) {
|
||||
value += Ox.repeat('0', self.options.decimals - length);
|
||||
|
|
@ -527,7 +527,7 @@ Ox.Input = function(options, self) {
|
|||
}
|
||||
}
|
||||
while (/^0\d/.test(value)) {
|
||||
value = value.substr(1, value.length);
|
||||
value = value.slice(1);
|
||||
}
|
||||
if (!regexp.test(value) || value < self.options.min || value > self.options.max) {
|
||||
value = oldValue;
|
||||
|
|
@ -725,7 +725,7 @@ Ox.Input = function(options, self) {
|
|||
that.triggerEvent('insert', {
|
||||
end: input.selectionEnd,
|
||||
id: that.oxid,
|
||||
selection: input.value.substring(input.selectionStart, input.selectionEnd),
|
||||
selection: input.value.slice(input.selectionStart, input.selectionEnd),
|
||||
start: input.selectionStart,
|
||||
value: input.value
|
||||
});
|
||||
|
|
@ -734,7 +734,7 @@ Ox.Input = function(options, self) {
|
|||
function keydown(event) {
|
||||
var oldCursor = cursor(),
|
||||
oldValue = self.options.value,
|
||||
newValue = oldValue.substr(0, oldCursor[0] - 1),
|
||||
newValue = oldValue.slice(0, oldCursor[0] - 1),
|
||||
hasDeletedSelectedEnd = (event.keyCode == 8 || event.keyCode == 46) &&
|
||||
oldCursor[0] < oldCursor[1] && oldCursor[1] == oldValue.length;
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -190,9 +190,9 @@ Ox.InsertHTMLDialog = function(options, self) {
|
|||
);
|
||||
self.options.callback({
|
||||
position: self.options.start + value.length,
|
||||
value: self.options.value.substr(0, self.options.start)
|
||||
value: self.options.value.slice(0, self.options.start)
|
||||
+ value
|
||||
+ self.options.value.substr(self.options.end)
|
||||
+ self.options.value.slice(self.options.end)
|
||||
});
|
||||
that.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ Ox.TimeInput = function(options, self) {
|
|||
function getDate() {
|
||||
return new Date('1970/01/01 ' + (
|
||||
self.options.milliseconds
|
||||
? self.options.value.substr(0, self.options.value.length - 4)
|
||||
? self.options.value.slice(0, -4)
|
||||
: self.options.value
|
||||
));
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ Ox.TimeInput = function(options, self) {
|
|||
return {
|
||||
ampm: Ox.formatDate(date, '%p'),
|
||||
hours: Ox.formatDate(date, self.options.ampm ? '%I' : '%H'),
|
||||
milliseconds: self.options.milliseconds ? self.options.value.substr(-3) : '000',
|
||||
milliseconds: self.options.milliseconds ? self.options.value.slice(-3) : '000',
|
||||
minutes: Ox.formatDate(date, '%M'),
|
||||
seconds: Ox.formatDate(date, '%S')
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue