Open GoogleCodeExporter opened 8 years ago
Here is recent update of this set of modifiers (used in enterprise ajax
portlet):
this.detailModifiers = {
truncate : function(str, length, truncation) {
length = length || 30;
truncation = (truncation==undefined) ? '...' : truncation;
return str.length > length ?
str.slice(0, length - truncation.length) + truncation : str;
},
ifempty : function(str, substitute) {
return (str==undefined||str==null||str==""||str=="null")?substitute:str;
},
mtai_format_date : function( dateStr, fmt ) {
if (dateStr==undefined||dateStr=='') {
return '';
}
if (fmt==undefined||fmt=='') {
fmt = "M d, Y";
}
return Jel.Date.format(Jel.Date.parse(dateStr, "Y-m-d"), fmt);
}
};
I have attached a modified JEL for this purpose (a stripped down version, lots
of
stuff removed, bloat removed, esp. the stuff that didn't work in IE, nice
little
library, just a bit overreaching, the original author has stopped support and
the
library has gone missing).
Original comment by kucerari...@gmail.com
on 8 Jul 2009 at 2:31
Attachments:
I should mention that in the stripped down version attached above, the JEL
dependency
on prototypejs has also been removed (the portal would not put prototypejs on
production front end).
Original comment by kucerari...@gmail.com
on 8 Jul 2009 at 2:33
Yet another revision... users are picky. They wanted to reorder the name
field of
something to be firstname first instead of lastname, firstname. Well I guess it
makes sense, but don't want to pull over two more database fields in addition
wrestling with the data model and the database guy just for this change.
this.detailModifiers = {
truncate : function(str, length, truncation) {
length = length || 30;
truncation = (truncation==undefined) ? '...' : truncation;
return str.length > length ?
str.slice(0, length - truncation.length) + truncation : str;
},
ifempty : function(str, substitute) {
return (str==undefined||str==null||str==""||str=="null")?substitute:str;
},
splitswap : function(str, splitchar) {
if (str==undefined||str==null||str==""||str=="null") {
return str;
} else {
splitchar = (splitchar==undefined||splitchar==null)?',':splitchar;
var halves = str.split( splitchar );
return Jel.String.trim(halves[1])+" "+Jel.String.trim(halves[0]);
}
},
mtai_format_date : function( dateStr, fmt ) {
if (dateStr==undefined||dateStr=='') {
return '';
}
if (fmt==undefined||fmt=='') {
fmt = "M d, Y";
}
return Jel.Date.format(Jel.Date.parse(dateStr, "Y-m-d"), fmt);
}
};
Once again JEL comes in handy, it is attached to this issue.
Original comment by kucerari...@gmail.com
on 8 Jul 2009 at 4:47
Added prefix, to solve ever-present problem of you don't want a label if you
don't
have a value:
this.detailModifiers = {
truncate : function(str, length, truncation) {
length = length || 30;
truncation = (truncation==undefined) ? '...' : truncation;
return str.length > length ?
str.slice(0, length - truncation.length) + truncation : str;
},
ifempty : function(str, substitute) {
return (str==undefined||str==null||str==""||str=="null")?substitute:str;
},
prefix : function(str, prefix) {
return (str==undefined||str==null||str==""||str=="null")?"":prefix+str;
},
splitswap : function(str, splitchar) {
if (str==undefined||str==null||str==""||str=="null") {
return str;
} else {
splitchar = (splitchar==undefined||splitchar==null)?',':splitchar;
var halves = str.split( splitchar );
return Jel.String.trim(halves[1])+" "+Jel.String.trim(halves[0]);
}
},
format_date : function( dateStr, fmt ) {
if (dateStr==undefined||dateStr=='') {
return '';
}
if (fmt==undefined||fmt=='') {
fmt = "M d, Y";
}
return Jel.Date.format(Jel.Date.parse(dateStr, "Y-m-d"), fmt);
}
};
Original comment by kucerari...@gmail.com
on 5 Oct 2009 at 2:10
Splitswap had a bug, added code to just return the string if the splitchar is
not found:
splitswap : function(str, splitchar) {
if (str==undefined||str==null||str==""||str=="null") {
return str;
} else {
splitchar = (splitchar==undefined||splitchar==null)?',':splitchar;
if ( str.indexOf( splitchar ) != -1 ) {
var halves = str.split( splitchar );
return Jel.String.trim(halves[1])+" "+Jel.String.trim(halves[0]);
} else {
return str;
}
}
},
Original comment by kucerari...@gmail.com
on 23 Oct 2009 at 8:25
Original issue reported on code.google.com by
kucerari...@gmail.com
on 18 Jun 2009 at 4:09