-
Notifications
You must be signed in to change notification settings - Fork 0
/
SayOrPlaySelector.js
83 lines (70 loc) · 2.52 KB
/
SayOrPlaySelector.js
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
76
77
78
79
80
81
82
83
/* This is intended to be a composite control to allow saying some text or playing a sound */
dojo.provide("unc.SayOrPlaySelector");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require('dijit.form.TextBox');
dojo.require('dijit.form.RadioButton');
dojo.require('unc.AudioSelector');
dojo.declare("unc.SayOrPlaySelector", [ dijit._Widget, dijit._Templated ], {
templatePath: dojo.moduleUrl('unc', 'SayOrPlaySelector.html'),
widgetsInTemplate: true,
name: '', // name of this control
value: '', //this is the text to say or the URL
disabled: false,
tags: '',
duration: '',
postCreate: function() {
this.connect(this.SPsaybutton, 'onChange', function(v) {
this.radioChange('say', v); });
this.connect(this.SPplaybutton, 'onChange', function(v) {
this.radioChange('play', v); });
var say = this.checkType(this.value) == 'say';
this.SPsaybutton.set('value', say);
this.SPplaybutton.set('value', !say);
//console.log('postCreate', say, this.value);
if (say) {
this.SPsay.set('value', this.value);
this.SPplay.set('value', '');
} else {
this.SPsay.set('value', '');
this.SPplay.set('value', this.value);
}
this.connect(this.SPsay, 'onChange', 'onChange');
this.connect(this.SPplay, 'onChange', 'onChange');
},
checkType: function(str) {
if (/^\/Media\/Audio.*$/.test(str)) { // URL
return 'play';
} else {
return 'say';
}
},
radioChange: function(which, v) {
//console.log('radioChange', which, v);
var ctrl = { say: this.SPsay, play: this.SPplay }[which];
//console.log('ctrl', ctrl);
if (v) {
dojo.style(ctrl.domNode, 'display', '');
} else {
dojo.style(ctrl.domNode, 'display', 'none');
}
this.onChange(this._getValueAttr());
},
_getValueAttr: function() {
if (this.SPsaybutton.get('value')) {
return this.SPsay.get('value');
} else {
return this.SPplay.get('value');
}
},
_setDisabledAttr: function(value) {
//console.log('SP disable', value);
dojo.query("[widgetId]", this.domNode).forEach(function(childNode) {
var child = dijit.byNode(childNode);
//console.log('child', child, childNode);
child.set('disabled', value);
});
},
onChange: function() {
}
});