// require Ten.js
// 似たようなクラスが既にありそう
FormVerifier = new Ten.Class({
initialize: function(form, button) {
if (!form)
return;
this.form = form;
this.button = button;
this.verifiers = [];
this.clicked = false;
this.button = button;
new Ten.Observer(this.form, 'onsubmit', this, 'onSubmit');
new Ten.Observer(this.button, 'onclick', this, 'onClick');
}
},{
addVerifier: function(verify) {
if (typeof verify != 'function')
return;
this.verifiers.push(verify);
},
onSubmit: function(e) {
if (!this.clicked)
return;
this.clicked = false;
var valid = true;
for (var i=0; i < this.verifiers.length; ++i) {
var v = this.verifiers[i];
if (!v())
valid = false;
}
if (!valid)
e.stop();
},
onClick: function(e) {
this.clicked = true;
}
});
TextInputDescription = new Ten.Class({
initialize: function(textInput, form, text) {
if (!textInput || !form) return;
this.textInput = textInput;
this.form = form;
this.defaultText = text;
new Ten.Observer(this.textInput, 'onfocus', this, 'onFocus');
new Ten.Observer(this.textInput, 'onblur', this, 'onBlur');
if (!this.textInput.value) {
this.showDescription();
}
}
},{
onFocus: function() {
if (this.textInput.value == this.defaultText) {
this.hideDescription();
}
},
onBlur: function() {
if (!this.textInput.value) {
this.showDescription();
}
},
isDefault: function(e) {
return this.textInput.value == this.defaultText;
},
showDescription: function() {
this.textInput.value = this.defaultText;
this.textInput.style.color = '#AAAAAA';
},
hideDescription: function() {
this.textInput.value = '';
this.textInput.style.color = '';
}
});
// 分離したのでこれはいらない、と
// TextInputDescriptionOption = new Ten.Class({
// initialize: function(textInput, form, text) {
// if (!textInput || !form) return;
// this.textInput = textInput;
// this.form = form;
// this.defaultText = text;
// new Ten.Observer(this.textInput, 'onfocus', this, 'onFocus');
// new Ten.Observer(this.textInput, 'onblur', this, 'onBlur');
// if (!this.textInput.value) {
// this.showDescription();
// }
// }
// },{
// onFocus: function() {
// if (this.textInput.value == this.defaultText) {
// this.hideDescription();
// }
// },
// onBlur: function() {
// if (!this.textInput.value) {
// this.showDescription();
// }
// },
// showDescription: function() {
// this.textInput.value = this.defaultText;
// this.textInput.style.color = '#AAAAAA';
// },
// hideDescription: function() {
// this.textInput.value = '';
// this.textInput.style.color = '';
// }
// });
function embedWmvPlayer(container, url) {
var width = 320;
var height = 240;
var showControls = true;
var showStatus = true;
var autoStart = true;
if (container.innerHTML) return;
if (showControls) {
height += 45;
}
if (showStatus) {
height += 24;
}
container.style.background = "";
container.style.backgroundColor = "#000000";
container.style.border = "";
container.innerHTML = [
""
].join('');
}
function embedQuicktimePlayer(container, url) {
var width = 320;
var height = 240;
var showControls = true;
var autoStart = true;
var bgcolor = "#000000";
if (container.innerHTML) return;
if (showControls) {
height += 16;
}
container.style.background = "";
container.style.backgroundColor = "#000000";
container.style.border = "";
container.innerHTML = [
""
].join('');
}