forked from 0x2620/oxjs
Ox.Dialog rewrite
This commit is contained in:
parent
6e5b515e5f
commit
e063626bdc
10 changed files with 762 additions and 513 deletions
47
source/Ox.js
47
source/Ox.js
|
|
@ -894,7 +894,7 @@ Ox.some = function(obj, fn) {
|
|||
};
|
||||
|
||||
/*@
|
||||
Ox.substr <f> Returns a substring or sub-array
|
||||
Ox.sub <f> Returns a substring or sub-array
|
||||
Ox.sub behaves like collection[start:stop] in Python
|
||||
(or, for strings, like str.substring() with negative values for stop)
|
||||
> Ox.sub([1, 2, 3], 1, -1)
|
||||
|
|
@ -2740,7 +2740,7 @@ Ox.formatUnit = function(num, str) {
|
|||
|
||||
/*@
|
||||
Ox.getLatLngByXY <f> Returns lat/lng for a given x/y on a 1x1 mercator projection
|
||||
> Ox.values(Ox.getLatLngByXY({x: 0.5, y: 0.5}))
|
||||
> Ox.getLatLngByXY({x: 0.5, y: 0.5})
|
||||
{lat: 0, lng: 0}
|
||||
@*/
|
||||
Ox.getLatLngByXY = function(xy) {
|
||||
|
|
@ -3398,7 +3398,7 @@ Ox.test = function(file, callback) {
|
|||
name: item.name,
|
||||
section: item.section,
|
||||
statement: example.statement,
|
||||
success: Ox.isEqual(eval('Ox.test.result = ' + example.result), actual)
|
||||
passed: Ox.isEqual(eval('Ox.test.result = ' + example.result), actual)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -4273,31 +4273,6 @@ Ox.stripTags = function(str) {
|
|||
return str.replace(/<.*?>/g, '');
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.substr <f> A better <code>substr</code>
|
||||
Ox.substr behaves like str[start:stop] in Python
|
||||
(or like str.substring() with negative values for stop)
|
||||
> Ox.substr('foobar', 1)
|
||||
"oobar"
|
||||
> Ox.substr('foobar', -1)
|
||||
"r"
|
||||
> Ox.substr('foobar', 1, 5)
|
||||
"ooba"
|
||||
> Ox.substr('foobar', 1, -1)
|
||||
"ooba"
|
||||
> Ox.substr('foobar', -5, 5)
|
||||
"ooba"
|
||||
> Ox.substr('foobar', -5, -1)
|
||||
"ooba"
|
||||
@*/
|
||||
// deprecated, use Ox.sub()
|
||||
Ox.substr = function(str, start, stop) {
|
||||
// fixme: needed?
|
||||
stop = Ox.isUndefined(stop) ? str.length : stop;
|
||||
return str.substring(
|
||||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.toCamelCase <f> Takes a string with '-', '/' or '_', returns a camelCase string
|
||||
> Ox.toCamelCase('foo-bar-baz')
|
||||
|
|
@ -4382,29 +4357,27 @@ Ox.truncate <f> Truncate a string to a given length
|
|||
(string, length, position, placeholder) -> <s> Truncated string
|
||||
> Ox.truncate('anticonstitutionellement', 16)
|
||||
'anticonstitut...'
|
||||
> Ox.truncate('anticonstitutionellement', 16, -1)
|
||||
> Ox.truncate('anticonstitutionellement', 16, '...', 'left')
|
||||
'...utionellement'
|
||||
> Ox.truncate('anticonstitutionellement', 16, '>')
|
||||
'anticonstitutio>'
|
||||
> Ox.truncate("anticonstitutionellement", 16, "...", "center")
|
||||
> Ox.truncate('anticonstitutionellement', 16, '...', 'center')
|
||||
'anticon...lement'
|
||||
@*/
|
||||
Ox.truncate = function(str, len, pad, pos) {
|
||||
/*
|
||||
*/
|
||||
var pad = pad || {},
|
||||
pos = pos || "right",
|
||||
var pad = pad || '...',
|
||||
pos = pos || 'right',
|
||||
strlen = str.length,
|
||||
padlen = pad.length,
|
||||
left, right;
|
||||
if (strlen > len) {
|
||||
if (pos == "left") {
|
||||
if (pos == 'left') {
|
||||
str = pad + str.substr(padlen + strlen - len);
|
||||
} else if (pos == "center") {
|
||||
} else if (pos == 'center') {
|
||||
left = Math.ceil((len - padlen) / 2);
|
||||
right = Math.floor((len - padlen) / 2);
|
||||
str = str.substr(0, left) + pad + str.substr(-right);
|
||||
} else if (pos == "right") {
|
||||
} else if (pos == 'right') {
|
||||
str = str.substr(0, len - padlen) + pad;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue