sync
This commit is contained in:
@ -58,7 +58,7 @@
|
||||
// items
|
||||
this.data = {};
|
||||
};
|
||||
question.prototype.createContent = function (answer, medias, change) {
|
||||
question.prototype.createContent = function (answer, answerchange, inputchange, medias) {
|
||||
this.answer = answer;
|
||||
var content = $('<div class="question-item" style="line-height: 26px; margin: 0 0 22px 22px"></div>');
|
||||
var q = this.question;
|
||||
@ -72,7 +72,7 @@
|
||||
var div_pic = $('<div></div>');
|
||||
for (var i = 0; i < q.StaticPictures.length; i++) {
|
||||
var pic = q.StaticPictures[i];
|
||||
var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name);
|
||||
var img = $('<img loading="lazy" style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name);
|
||||
img.click(pic.Url, function (e) {
|
||||
window.open(e.data, "_blank")
|
||||
});
|
||||
@ -83,7 +83,7 @@
|
||||
|
||||
var cnt = $('<div style="margin: 6px 0 0 22px"></div>');
|
||||
if (typeof this.createQuestion === 'function') {
|
||||
this.ui.content = this.createQuestion(answer, medias, change);
|
||||
this.ui.content = this.createQuestion(answer, answerchange, inputchange, medias);
|
||||
cnt.append(this.ui.content);
|
||||
} else {
|
||||
cnt.append('<div style="font-style: italic; color: #ccc"><Not implemented yet.></div>');
|
||||
@ -128,7 +128,7 @@
|
||||
};
|
||||
inputQuestion.prototype = Object.create(question.prototype);
|
||||
inputQuestion.prototype.constructor = inputQuestion;
|
||||
inputQuestion.prototype.createQuestion = function (answer, _medias, change) {
|
||||
inputQuestion.prototype.createQuestion = function (answer, answerchange, inputchange, _medias) {
|
||||
var content = $('<div></div>');
|
||||
var input;
|
||||
if (this.question.QuestionType === QTypes.MultipleLineText
|
||||
@ -145,11 +145,19 @@
|
||||
input.prop('readonly', true).css('background', '#eee');
|
||||
} else if (this.question.SubType === FuelRecordTypes.Quantity
|
||||
|| this.question.SubType === FuelRecordTypes.UnitCost) {
|
||||
if (typeof change === 'function') {
|
||||
input.on('input propertychange', this, change);
|
||||
if (typeof inputchange === 'function') {
|
||||
input.on('input propertychange', this, inputchange);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof answerchange === 'function') {
|
||||
if (this.question.QuestionType === QTypes.Number
|
||||
|| this.question.QuestionType === QTypes.Integer
|
||||
|| this.question.QuestionType === QTypes.EngingHours
|
||||
|| this.question.SubType === FuelRecordTypes.UnitCost) {
|
||||
input.on('change', this, answerchange);
|
||||
}
|
||||
}
|
||||
if (answer && answer.Result) {
|
||||
input.val(answer.Result);
|
||||
}
|
||||
@ -169,7 +177,7 @@
|
||||
var div_pic = $('<div></div>');
|
||||
for (var i = 0; i < _medias.length; i++) {
|
||||
var pic = _medias[i];
|
||||
var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name);
|
||||
var img = $('<img loading="lazy" style="width:40px;height:40px;margin-left:5px;"/>').attr('src', pic.Url).attr('title', pic.Name);
|
||||
img.click(pic.Url, function (e) {
|
||||
window.open(e.data, "_blank")
|
||||
});
|
||||
@ -186,6 +194,7 @@
|
||||
//if (this.question.QuestionType !== QTypes.FuelRecords ||
|
||||
// this.question.SubType !== FuelRecordTypes.TotalCost) {
|
||||
answer.Result = this.ui.input.val();
|
||||
answer.AsDouble = Number(answer.Result);
|
||||
//}
|
||||
return answer;
|
||||
};
|
||||
@ -258,7 +267,7 @@
|
||||
};
|
||||
listQuestion.prototype = Object.create(question.prototype);
|
||||
listQuestion.prototype.constructor = listQuestion;
|
||||
listQuestion.prototype.createQuestion = function (answer) {
|
||||
listQuestion.prototype.createQuestion = function (answer, answerchange) {
|
||||
var content = $('<div></div>');
|
||||
var q = this.question;
|
||||
for (var i = 0; i < q.SelectItems.length; i++) {
|
||||
@ -275,6 +284,9 @@
|
||||
check = $('<input type="radio"></input>').attr({ 'id': id, 'name': name }).val(val);
|
||||
}
|
||||
check.data('item', item);
|
||||
if (typeof answerchange === 'function') {
|
||||
check.on('change', this, answerchange);
|
||||
}
|
||||
if (answer && answer.SelectedItems) {
|
||||
var s = answer.SelectedItems.filter(function (a) { return (a.Value || a.Text) === val });
|
||||
if (s.length > 0) {
|
||||
@ -353,6 +365,9 @@
|
||||
//onSelectDate: function (v, inp) {
|
||||
|
||||
//}
|
||||
onChangeDateTime: function (v, inp) {
|
||||
var date = new DateFormatter().formatDate(v, 'm/d/Y');
|
||||
}
|
||||
});
|
||||
if (q.QuestionType === QTypes.DateAndTime
|
||||
|| (q.QuestionType === QTypes.FuelRecords &&
|
||||
@ -406,9 +421,9 @@
|
||||
};
|
||||
dropQuestion.prototype = Object.create(question.prototype);
|
||||
dropQuestion.prototype.constructor = dropQuestion;
|
||||
dropQuestion.prototype.createQuestion = function (answer) {
|
||||
dropQuestion.prototype.createQuestion = function (answer, answerchange) {
|
||||
var _this = this;
|
||||
var content = $('<div></div>').click(function () { _this.openDrop(content.offset()) });
|
||||
var content = $('<div></div>').click(function () { _this.openDrop(content.offset(), answerchange) });
|
||||
var result = $('<div class="drop-result" style="float: left; cursor: pointer"></div>');
|
||||
this.fillResult(result, answer && answer.SelectedItems);
|
||||
content.append(result);
|
||||
@ -469,7 +484,7 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
dropQuestion.prototype.openDrop = function (pos) {
|
||||
dropQuestion.prototype.openDrop = function (pos, answerchange) {
|
||||
var _this = this;
|
||||
var q = this.question;
|
||||
var mask = this.ui.mask;
|
||||
@ -559,6 +574,7 @@
|
||||
refreshList(panelContent, items);
|
||||
}
|
||||
});
|
||||
search.attr("placeholder", GetTextByKey("P_AM_SEARCH", "Search"));
|
||||
var funcs = $('<div style="margin-right: 45px"></div>');
|
||||
funcs.append(search);
|
||||
panel.append($('<div class="sbutton iconcheck"></div>').css({
|
||||
@ -585,6 +601,10 @@
|
||||
answer.SelectedItems = items;
|
||||
_this.fillResult(_this.ui.content.find('.drop-result'), items);
|
||||
_this.closeDrop();
|
||||
|
||||
if (typeof answerchange === 'function') {
|
||||
answerchange(_this);
|
||||
}
|
||||
}));
|
||||
panel.append(funcs);
|
||||
// scroller
|
||||
@ -728,7 +748,7 @@
|
||||
};
|
||||
pictureQuestion.prototype = Object.create(question.prototype);
|
||||
pictureQuestion.prototype.constructor = pictureQuestion;
|
||||
pictureQuestion.prototype.createQuestion = function (_answer, medias) {
|
||||
pictureQuestion.prototype.createQuestion = function (_answer, answerchange, inputchange, medias) {
|
||||
var content = $('<div></div>');
|
||||
if (medias && medias.length > 0) {
|
||||
for (var i = 0; i < medias.length; i++) {
|
||||
@ -750,7 +770,7 @@
|
||||
'color': '#000'
|
||||
}));
|
||||
} else {
|
||||
ele = $('<img></img>').css({
|
||||
ele = $('<img loading="lazy"></img>').css({
|
||||
'float': 'left',
|
||||
'border': '1px solid #ccc',
|
||||
'padding': '4px',
|
||||
@ -774,7 +794,7 @@
|
||||
};
|
||||
assetStatusQuestion.prototype = Object.create(question.prototype);
|
||||
assetStatusQuestion.prototype.constructor = assetStatusQuestion;
|
||||
assetStatusQuestion.prototype.createQuestion = function (answer, medias) {
|
||||
assetStatusQuestion.prototype.createQuestion = function (answer, answerchange, inputchange, medias) {
|
||||
var content = $('<div></div>');
|
||||
var q = this.question;
|
||||
q.SelectItems = [
|
||||
@ -792,6 +812,9 @@
|
||||
var val = item.Value || item.Text;
|
||||
var check = $('<input type="radio"></input>').attr({ 'id': id, 'name': name }).val(val);
|
||||
check.data('item', item);
|
||||
if (typeof answerchange === 'function') {
|
||||
check.on('change', this, answerchange);
|
||||
}
|
||||
if (answer && answer.SelectedItems) {
|
||||
var s = answer.SelectedItems.filter(function (a) { return (a.Value || a.Text) === val });
|
||||
if (s.length > 0) {
|
||||
@ -837,7 +860,7 @@
|
||||
'color': '#000'
|
||||
}));
|
||||
} else {
|
||||
ele = $('<img></img>').css({
|
||||
ele = $('<img loading="lazy"></img>').css({
|
||||
'float': 'left',
|
||||
'border': '1px solid #ccc',
|
||||
'padding': '4px',
|
||||
|
Reference in New Issue
Block a user