'selector' - ditto with closing current popup editor window
'cancel' - cancel form entry on Escape press; dflt ICON_CANCEL
'process' - displays progress bar during call; optional icon
-
+ 'nonajax' - ditto, non-ajax submit
$atype can contain also multiply type selectors separated by space,
however make sense only combination of 'process' and one of defualt/selector/cancel
*/
case 'cancel':
if ($icon===false) $icon=ICON_ESCAPE; break;
+
+ case 'nonajax':
+ $atype = false;
}
}
}
}
//-----------------------------------------------------------------------------------
-function radio($label, $name, $value, $selected, $submit_on_change=false) {
+function radio($label, $name, $value, $selected=null, $submit_on_change=false)
+{
+ if (!isset($selected))
+ $selected = get_post($name) == $value;
if ($submit_on_change === true)
$submit_on_change =
function validate(e) {
if (e.name && (typeof _validate[e.name] == 'function'))
return _validate[e.name](e);
+ else {
+ var n = e.name.indexOf('[');
+ if(n!=-1) {
+ var key = e.name.substring(n+1, e.name.length-1);
+ if (key.length>1 && _validate[e.name.substring(0,n)])
+ return _validate[e.name.substring(0,n)][key](e);
+ }
+ }
return true;
}
event = event||window.event;
key = event.keyCode||event.which;
var box = document.getElementsByName(this.getAttribute('rel'))[0];
- if (box && key == 32 && this.className == 'combo2') {
+ if(key == 8 || (key==37 && event.altKey)) {
+ event.returnValue = false;
+ return false;
+ }
+ if (box && (key == 32) && (this.className == 'combo2')) {
this.style.display = 'none';
box.style.display = 'inline';
box.value='';
// this shows divs for js enabled browsers only
e.style.display = 'block';
},
-
'button': function(e) {
- e.onclick = function(){ return validate(e); }
+ e.onclick = function(){
+ if (validate(e)) {
+ setTimeout(function() { var asp = e.getAttribute('aspect');
+ set_mark((asp && (asp.indexOf('process') !== -1)) ? 'progressbar.gif' : 'ajax-loader.gif');
+ }, 100);
+ return true;
+ }
+ },
+ e.onkeydown = function(ev) { // block unintentional page escape with 'history back' key pressed on buttons
+ ev = ev||window.event;
+ key = ev.keyCode||ev.which;
+ if(key == 8 || (key==37 && ev.altKey)) {
+ ev.returnValue = false;
+ return false;
+ }
+ }
+
},
// '.ajaxsubmit,.editbutton,.navibutton': // much slower on IE7
'button.ajaxsubmit,input.ajaxsubmit,input.editbutton,button.editbutton,button.navibutton':
if (validate(e)) {
save_focus(e);
var asp = e.getAttribute('aspect')
- if (asp && asp.indexOf('process') !== -1)
+ if (asp && (asp.indexOf('process') !== -1))
JsHttpRequest.request(this, null, 600000); // ten minutes for backup
else
JsHttpRequest.request(this);
e.onfocus = function() {
save_focus(this);
};
- var c = e.className;
- if (c == 'combo' || c == 'combo2' || c == 'combo3')
+ }
+ var c = e.className;
+ if (c == 'combo' || c == 'combo2' || c == 'combo3')
_set_combo_select(e);
+ else {
+ e.onkeydown = function(ev) { // block unintentional page escape with 'history back' key pressed on buttons
+ ev = ev||window.event;
+ key = ev.keyCode||ev.which;
+ if(key == 8 || (key=37 && ev.altKey)) {
+ ev.returnValue = false;
+ return false;
+ }
+ }
}
},
'a.printlink': function(l) {
}
}
// }
+ },
+ 'textarea': function(e) {
+ if(e.onfocus==undefined) {
+ e.onfocus = function() {
+ save_focus(this);
+ };
+ }
}
-
/* 'tr.editrow': function(e) {
e.onkeydown = function(ev) {
ev = ev||window.event;
for (var i=0; i<form.elements.length; i++){
var el = form.elements[i];
var asp = el.getAttribute('aspect');
-
if (el.className!='editbutton' && (asp && asp.indexOf('selector') !== -1) && (key==13 || key==27)) {
passBack(key==13 ? el.getAttribute('rel') : false);
}
if (((asp && asp.indexOf('default') !== -1) && key==13)||((asp && asp.indexOf('cancel') !== -1) && key==27)) {
if (validate(el)) {
+ if (asp.indexOf('nonajax') !== -1)
+ el.click();
+ else
if (asp.indexOf('process') !== -1)
JsHttpRequest.request(el, null, 600000);
else
//
JsHttpRequest.request= function(trigger, form, tout) {
// if (trigger.type=='submit' && !validate(trigger)) return false;
- tout = tout || 6000; // default timeout value
+ tout = tout || 10000; // default timeout value
document.getElementById('msgbox').innerHTML='';
set_mark(tout>10000 ? 'progressbar.gif' : 'ajax-loader.gif');
JsHttpRequest._request(trigger, form, tout, 0);
window.location = data;
} else if(cmd=='pu') { // pop-up
newwin = 1;
- window.open(data,'REP_WINDOW','toolbar=no,scrollbar=no,resizable=yes,menubar=no');
+ window.open(data,'REP_WINDOW','toolbar=no,scrollbars=yes,resizable=yes,menubar=no');
} else {
errors = errors+'<br>Unknown ajax function: '+cmd;
}
if(upload) { // for form containing file inputs collect all
// form elements and add value of trigger submit button
// (internally form is submitted via form.submit() not button click())
- q[name] = submitObj.type=='submit' && el==submitObj ? el.value : el;
- continue;
+ if (submitObj.type=='submit' && el==submitObj)
+ {
+ q[name] = el.value
+ continue;
+ }
}
if (el.type )
if(
}
}
else
+ if (el.type=='file')
+ q[name] = el
+ else
{
q[name] = el.value;
}