This repository was archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.js
More file actions
75 lines (68 loc) · 1.92 KB
/
helpers.js
File metadata and controls
75 lines (68 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*globals Ext, SWorks, console */
/*jslint glovar: true, undef: true, nomen: true */
SWorks.download = function(url) {
Ext.DomHelper.append(Ext.getBody(), {
src: url,
tag: 'iframe',
id: Ext.id(),
cls: 'x-hidden'
});
};
SWorks.getVtypeRegexFn = function(mask) {
return function(value) {
return mask.test(value);
};
};
Ext.form.VTypes.phoneNumberText = "Phone number is invalid";
Ext.form.VTypes.phoneNumberMask = /[1234567890\-\ ]/;
Ext.form.VTypes.phoneNumber = function(value) {
var ph = value.replace(/\D/g, "");
if(ph.length < 10) {
return "Area code is required.";
} else {
return true;
}
};
Ext.form.VTypes.zipCodeText = "Zip code is invalid";
Ext.form.VTypes.zipCodeMask = /[1234567890\-]/;
Ext.form.VTypes.zipCode = SWorks.getVtypeRegexFn(/^\d{5}(?:-\d{4})?$/);
Ext.util.Format.mysqlDateRenderer = function(fmt){
var raw = Ext.util.Format.dateRenderer(fmt);
return function(value) {
dv = Date.parseDate(value, 'Y-m-d')
return raw(dv);
};
};
Ext.util.Format.yesNo = function(value){
return value ? "Yes" : "No";
};
Ext.util.Format.csvArray = function(value){
return ((value && value.join) ? value.join(", ") : "");
};
Ext.util.Format.dateMjy = function(value) {
return Date.parseDate(value, 'Y/m/d H:i:s').format("M j Y");
};
Ext.util.Format.hourlyRate = function(v){
return Ext.util.Format.usMoney(v) + " / hour";
};
Ext.util.Format.quickTips = function(v,m,r) {
if (r.data.quicktip) {
m.attr = 'ext:qtip=\''+Ext.util.Format.htmlEncode(r.data.quicktip).replace("\n",'<br/>')+'\'';
}
return Ext.util.Format.htmlEncode(v);
};
SWorks.renderers = {
joinFields: function(list) {
list = list.splice(0);
return function(v, meta, record) {
var ret = [];
for(var i=0;i<list.length;i++) {
var value = record.data[list[i]];
if(value && value !== '') {
ret.push(value);
}
}
return ret.join(', ');
};
}
};