null - button visible only in fallback mode; optional icon
Ajax submit:
true - standard button; optional icon
- 'process' - displays progress bar during call; optional icon
+
'default' - default form submit on Ctrl-Enter press; dflt ICON_OK icon
'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
+
+ $atype can contain also multiply type selectors separated by space,
+ however make sense only combination of 'process' and one of defualt/selector/cancel
*/
function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=false)
{
global $path_to_root;
$aspect='';
- if (!is_bool($atype)) // necessary: switch uses '=='
- switch($atype) {
- case 'process':
- $aspect = " aspect='process'"; break;
- case 'selector':
- $aspect = " aspect='selector' rel = '$value'";
- $value = _("Select");
- if ($icon===false) $icon=ICON_SUBMIT; break;
- case 'default':
- $aspect = " aspect='default'";
- if ($icon===false) $icon=ICON_SUBMIT; break;
- case 'cancel':
- $aspect = " aspect='cancel'";
- if ($icon===false) $icon=ICON_ESCAPE; break;
- case null:
- $aspect = fallback_mode() ?
- " aspect='fallback'" : " style='display:none;'"; break;
- }
+ if ($atype === null) {
+ $aspect = fallback_mode() ? " aspect='fallback'" : " style='display:none;'";
+
+ } elseif (!is_bool($atype)) { // necessary: switch uses '=='
+
+ $aspect = "aspect='$atype' ";
+ $types = explode(' ', $atype);
+ foreach ($types as $type) {
+ switch($type) {
+ case 'selector':
+ $aspect = " aspect='selector' rel = '$value'";
+ $value = _("Select");
+ if ($icon===false) $icon=ICON_SUBMIT; break;
+
+ case 'default':
+ if ($icon===false) $icon=ICON_SUBMIT; break;
+
+ case 'cancel':
+ if ($icon===false) $icon=ICON_ESCAPE; break;
+ }
+ }
+ }
$submit_str = "<button class=\""
.($atype ? 'ajaxsubmit' : 'inputsubmit')
."\" type=\"submit\""
checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
break;
case '~': // Match one of space seperated words
- checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
+ checkFunction = function(e) { var a=e.getAttribute(attrName); return (a && a.match(new RegExp('\\b'+attrValue+'\\b'))); };
break;
case '|': // Match start with value followed by optional hyphen
- checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
+ checkFunction = function(e) { var a=e.getAttribute(attrName); return (a && a.match(new RegExp('^'+attrValue+'-?'))); };
break;
case '^': // Match starts with value
- checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
+ checkFunction = function(e) { var a=e.getAttribute(attrName); return (a && a.indexOf(attrValue) == 0); };
break;
case '$': // Match ends with value - fails with "Warning" in Opera 7
- checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
+ checkFunction = function(e) { var a=e.getAttribute(attrName); return (a && a.lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
break;
- case '*': // Match ends with value
- checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
+ case '*': // Match contains value
+ checkFunction = function(e) { var a=e.getAttribute(attrName); return (a && a.indexOf(attrValue) > -1); };
break;
default :
// Just test for existence of attribute
function(e) {
e.onclick = function() {
save_focus(e);
- if (e.getAttribute('aspect') == 'process')
- JsHttpRequest.request(this, null, 60000);
- else
- JsHttpRequest.request(this);
+ var asp = e.getAttribute('aspect')
+ if (asp && asp.indexOf('process') !== -1)
+ JsHttpRequest.request(this, null, 60000);
+ else
+ JsHttpRequest.request(this);
return false;
}
},
}
}
},
- 'button[aspect=selector], input[aspect=selector]': function(e) {
+ 'button[aspect*selector], input[aspect*selector]': function(e) {
e.onclick = function() {
passBack(this.getAttribute('rel'));
return false;
'a.printlink': function(l) {
l.onclick = function() {
save_focus(this);
- JsHttpRequest.request(this);
+ JsHttpRequest.request(this, null, 60000);
return false;
}
},
for (var i=0; i<form.elements.length; i++){
var el = form.elements[i];
var asp = el.getAttribute('aspect');
- if (el.className!='editbutton' && asp=='selector' && (key==13 || key==27)) {
+
+
+ if (el.className!='editbutton' && (asp && asp.indexOf('selector') !== -1) && (key==13 || key==27)) {
passBack(key==13 ? el.getAttribute('rel') : false);
ev.returnValue = false;
return false;
}
- if ((asp=='default' && key==13)||(asp=='cancel' && key==27)) {
- JsHttpRequest.request(el);
+ if (((asp && asp.indexOf('default') !== -1) && key==13)||((asp && asp.indexOf('cancel') !== -1) && key==27)) {
+
+ if (asp.indexOf('process') !== -1)
+ JsHttpRequest.request(el, null, 60000);
+ else
+ JsHttpRequest.request(el);
ev.returnValue = false;
return false;
}