Skip to content
Snippets Groups Projects
Commit 7a9359cc authored by Mark M. Florida's avatar Mark M. Florida
Browse files

XNAT-4518, XNAT-4520: included missing scripts on Noninteractive.vm template;...

XNAT-4518, XNAT-4520: included missing scripts on Noninteractive.vm template; checkboxes (and switchboxes) can use 1/0 for checked/unchecked as well as true/false.
parent 5e5aec23
No related branches found
No related tags found
No related merge requests found
......@@ -207,7 +207,7 @@ var XNAT = getObject(XNAT);
if (hasValue && opts.value.toString().indexOf(doEval) === 0) {
opts.value = (opts.value.split(doEval)[1]||'').trim();
try {
$element.val(eval(opts.value)).change();
$element.changeVal(eval(opts.value));
}
catch (e) {
$element.val('').change();
......@@ -240,8 +240,8 @@ var XNAT = getObject(XNAT);
// add 'before' content before the core element
if (opts.beforeElement) {
opts.beforeElement = stringable(opts.beforeElement) ? [opts.beforeElement] : '';
inner.push(spawn('span.before', opts.beforeElement));
opts.beforeElement = stringable(opts.beforeElement) ? opts.beforeElement : '';
inner.push(opts.beforeElement);
}
......@@ -261,8 +261,8 @@ var XNAT = getObject(XNAT);
// add 'after' content after the core element
if (opts.afterElement) {
opts.afterElement = stringable(opts.afterElement) ? [opts.afterElement] : '';
inner.push(spawn('span.after', opts.afterElement));
opts.afterElement = stringable(opts.afterElement) ? opts.afterElement : '';
inner.push(opts.afterElement);
}
var $hiddenInput, hiddenInput;
......@@ -270,13 +270,13 @@ var XNAT = getObject(XNAT);
// check buttons if value is true
if (/checkbox/i.test(element.type||'')) {
element.checked = /true|checked/i.test(opts.checked||element.value||'');
element.checked = /^(true|checked|1)$/gi.test((opts.checked||element.value||'').trim());
// add a hidden input to capture the checkbox/radio value
$hiddenInput = $.spawn('input.proxy', {
type: 'hidden',
name: element.name,
value: element.checked ? (element.value || opts.value || element.checked || 'true') : 'false'
value: element.checked ? (element.value || opts.value || element.checked || true) : false
});
hiddenInput = $hiddenInput[0];
......@@ -284,14 +284,32 @@ var XNAT = getObject(XNAT);
// add [data-value] attribute
$hiddenInput.dataAttr('value', hiddenInput.value);
// change the value of the hidden input onclick
element.onclick = function(){
// if the checkbox value is boolean,
// match the value to the 'checked' state
if (/true|false/i.test(this.value)) {
this.value = this.checked;
element.onclick = function(e){
var _val = this.value+'';
// shift-click a checkbox (or switchbox) to
// switch between boolean true/false and 1/0
if (e.shiftKey) {
if (/^(1|0)$/g.test(_val)) {
_val = _val === '1' ? 'true' : 'false';
}
else if (/^(true|false)$/gi.test(_val)) {
_val = _val === 'true' ? '1' : '0';
}
}
hiddenInput.value = this.checked ? (this.value || this.checked || 'true') : 'false';
this.value = _val;
};
// change the value of the hidden input
// when 'controller' input changes
element.onchange = function(){
var _val = this.value+'';
if (/^(1|0)$/g.test(_val)) {
_val = this.checked ? '1' : '0';
}
else if (/^(true|false)$/gi.test(_val)) {
_val = this.checked ? 'true' : 'false';
}
this.value = hiddenInput.value = _val;
$hiddenInput.toggleClass('dirty');
};
......
......@@ -26,6 +26,9 @@
## #end
</script>
<script type="text/javascript" src="$content.getURI("scripts/polyfills.js")"></script>
<script type="text/javascript" src="$content.getURI("scripts/globals.js")"></script>
<script type="text/javascript">
var serverRoot = "$content.getURI('')";
......
......@@ -67,7 +67,7 @@ $page.setBgColor($ui.bgcolor)
</div>
<script type="text/javascript">
(function () {
$(function () {
function validEmailFormat(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
......@@ -142,9 +142,9 @@ $page.setBgColor($ui.bgcolor)
jQuery('#send-activation-email-link').click(function (e) {
e.preventDefault();
var __modal, __emailInput;
var requestModal, __modal, __emailInput;
var requestModal = {};
window.requestModal = requestModal = {};
//requestModal.id = 'request-modal'
requestModal.width = 400;
requestModal.height = 200;
......@@ -200,5 +200,5 @@ $page.setBgColor($ui.bgcolor)
xmodal.open(requestModal);
});
})();
});
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment