Commit 66be24c6 by Xavier Antoviaque

Merge pull request #22 from aboudreault/mrq-tip-width-height

Mrq tip width height
parents fdbfc077 7befbdaa
......@@ -42,6 +42,7 @@
font-family: arial;
font-size: 14px;
height: 100%;
max-height: 100%;
opacity: 0.9;
padding: 10px;
width: 300px;
......
......@@ -2,8 +2,8 @@ function AnswerBlock(runtime, element) {
return {
init: function(options) {
// register the child validator
$(':input', element).on('keyup', options.blockValidator);
// register the child validator
$(':input', element).on('keyup', options.blockValidator);
},
submit: function() {
......@@ -15,7 +15,7 @@ function AnswerBlock(runtime, element) {
$(element).find('.message').text((result || {}).error || '');
checkmark.removeClass(
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
);
if (result.completed) {
checkmark.addClass('checkmark-correct icon-ok fa-check');
......@@ -31,7 +31,7 @@ function AnswerBlock(runtime, element) {
// return true if the answer is read only
var blockquote_ro = $('blockquote.answer.read_only', element);
if (blockquote_ro.length > 0)
return true;
return true;
var input = $(':input', element),
input_value = input.val().replace(/^\s+|\s+$/gm,''),
......
......@@ -55,7 +55,7 @@ function MentoringBlock(runtime, element) {
function getChildren(element) {
if (!_.isUndefined(children))
return children;
return children;
var children_dom = $('.xblock-light-child', element);
children = [];
......@@ -106,7 +106,7 @@ function MentoringBlock(runtime, element) {
blockValidator: validateXBlock
};
_.each(children, function(child) {
callIfExists(child, 'init', options);
callIfExists(child, 'init', options);
});
......@@ -134,7 +134,7 @@ function MentoringBlock(runtime, element) {
var children = getChildren(element);
if ((data.max_attempts > 0) && (data.num_attempts >= data.max_attempts)) {
is_valid = false;
is_valid = false;
}
else {
for (var i = 0; i < children.length; i++) {
......
// TODO: Split in two files
function MessageView(element) {
return {
messageDOM: $('.feedback', element),
allPopupsDOM: $('.choice-tips, .feedback', element),
clearPopupEvents: function() {
this.allPopupsDOM.hide();
$('.close', this.allPopupsDOM).off('click');
},
showPopup: function(popupDOM) {
var self = this;
this.clearPopupEvents();
// Set the width/height
var tip = $('.tip', popupDOM)[0];
var data = $(tip).data();
if (data && data.width) {
popupDOM.css('width', data.width)
} else {
popupDOM.css('width', '')
}
if (data && data.height) {
popupDOM.css('height', data.height);
} else {
popupDOM.css('height', '')
}
popupDOM.show();
popupDOM.on('click', function() {
self.clearPopupEvents();
});
},
showMessage: function(message) {
if (_.isString(message)) {
this.messageDOM.html(message);
this.showPopup(this.messageDOM);
}
else {
this.showPopup(message); // already a DOM
}
return {
messageDOM: $('.feedback', element),
allPopupsDOM: $('.choice-tips, .feedback', element),
clearPopupEvents: function() {
this.allPopupsDOM.hide();
$('.close', this.allPopupsDOM).off('click');
},
showPopup: function(popupDOM) {
var self = this;
this.clearPopupEvents();
// Set the width/height
var tip = $('.tip', popupDOM)[0];
var data = $(tip).data();
if (data && data.width) {
popupDOM.css('width', data.width)
} else {
popupDOM.css('width', '')
}
if (data && data.height) {
popupDOM.css('height', data.height);
} else {
popupDOM.css('height', '')
}
popupDOM.show();
popupDOM.on('click', function() {
self.clearPopupEvents();
});
},
showMessage: function(message) {
if (_.isString(message)) {
this.messageDOM.html(message);
this.showPopup(this.messageDOM);
}
else {
this.showPopup(message); // already a DOM
}
}
}
}
}
function MCQBlock(runtime, element) {
......@@ -66,7 +66,7 @@ function MCQBlock(runtime, element) {
choiceTipsCloseDOM;
choiceResultDOM.removeClass(
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
);
if (result.completed && choiceInputDOM.val() === result.submission) {
choiceResultDOM.addClass('checkmark-correct icon-ok fa-check');
......@@ -75,17 +75,17 @@ function MCQBlock(runtime, element) {
choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
}
var tips = _.find(result.tips, function(obj) {
return obj.choice === choiceInputDOM.val();
});
if (tips) {
choiceTipsDOM.html(tips.tips);
}
var tips = _.find(result.tips, function(obj) {
return obj.choice === choiceInputDOM.val();
});
if (tips) {
choiceTipsDOM.html(tips.tips);
}
choiceTipsCloseDOM = $('.close', choiceTipsDOM);
choiceTipsCloseDOM = $('.close', choiceTipsDOM);
choiceResultDOM.off('click').on('click', function() {
if (choiceTipsDOM.html() != '') {
messageView.showMessage(choiceTipsDOM);
messageView.showMessage(choiceTipsDOM);
}
});
});
......@@ -96,15 +96,15 @@ function MCQBlock(runtime, element) {
}
else if (result.tips) {
var tips = _.find(result.tips, function(obj) {
return obj.choice === result.submission;
});
return obj.choice === result.submission;
});
if (tips) {
messageView.showMessage(tips.tips);
} else {
messageView.clearPopupEvents();
}
}
}
}
};
}
......@@ -140,17 +140,17 @@ function MRQBlock(runtime, element) {
choiceTipsCloseDOM;
choiceResultDOM.removeClass(
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
);
/* show hint if checked or max_attempts is disabled */
if (!hide_results &&
(result.completed || choiceInputDOM.prop('checked') || options.max_attempts <= 0)) {
if (choice.completed) {
choiceResultDOM.addClass('checkmark-correct icon-ok fa-check');
} else if (!choice.completed) {
choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
}
if (choice.completed) {
choiceResultDOM.addClass('checkmark-correct icon-ok fa-check');
} else if (!choice.completed) {
choiceResultDOM.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
}
}
choiceTipsDOM.html(choice.tips);
......
......@@ -10,7 +10,6 @@
<div class="choice-tips"></div>
</div>
{% endfor %}
<div
<div class="feedback"></div>
</div>
</fieldset>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment