]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/dtl/filter/logic.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / dtl / filter / logic.js
1 if(!dojo._hasResource["dojox.dtl.filter.logic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.dtl.filter.logic"] = true;
3 dojo.provide("dojox.dtl.filter.logic");
4
5 dojo.mixin(dojox.dtl.filter.logic, {
6         default_: function(value, arg){
7                 // summary: If value is unavailable, use given default
8                 return value || arg || "";
9         },
10         default_if_none: function(value, arg){
11                 // summary: If value is null, use given default
12                 return (value === null) ? arg || "" : value || "";
13         },
14         divisibleby: function(value, arg){
15                 // summary: Returns true if the value is devisible by the argument"
16                 return (parseInt(value) % parseInt(arg)) == 0;
17         },
18         _yesno: /\s*,\s*/g,
19         yesno: function(value, arg){
20                 // summary:
21                 //              arg being a comma-delimited string, value of true/false/none
22                 //              chooses the appropriate item from the string
23                 if(!arg) arg = 'yes,no,maybe';
24                 var parts = arg.split(dojox.dtl.filter.logic._yesno);
25                 if(parts.length < 2){
26                         return value;
27                 }
28                 if(value) return parts[0];
29                 if((!value && value !== null) || parts.length < 3) return parts[1];
30                 return parts[2];
31         }
32 });
33
34 }