Index: branches/RC/core/admin_templates/js/ajax.js =================================================================== diff -u -N -r9639 -r9643 --- branches/RC/core/admin_templates/js/ajax.js (.../ajax.js) (revision 9639) +++ branches/RC/core/admin_templates/js/ajax.js (.../ajax.js) (revision 9643) @@ -335,6 +335,7 @@ AjaxPopupManager.prototype.errorCallback = function($request, $params, $object) { alert('AJAX Error; class: AjaxPopupManager; ' + Request.getErrorHtml($request)); } + // AJAX DropdownPreloader class function AjaxDropdownPreloader($url, $input_mask, $filter_field, $dependend_field, value) { this.URL = $url; @@ -345,10 +346,12 @@ this.Value = value; this.BusyRequest = false; } + AjaxDropdownPreloader.prototype.prepareURL = function() { return this.URL.replace('#DEPENDEND#', this.Dependend).replace('#FILTER_VALUE#', this.getValue(this.FilterField)); } + AjaxDropdownPreloader.prototype.prepareTitles = function() { var $control = this.getControl(this.DependendField); var $i = 0; @@ -359,22 +362,26 @@ } return $ret; } + AjaxDropdownPreloader.prototype.getValue = function($field_name) { var $control = this.getControl($field_name); if ($control.tagName == 'INPUT') return $control.value; return $control.selectedIndex > 0 ? $control.options[$control.selectedIndex].value : ''; } + AjaxDropdownPreloader.prototype.Query = function () { var $url = this.prepareURL(); var $selected_value = this.Value || this.getValue(this.DependendField); // remove all existing options this.removeOptions(); Request.makeRequest($url, this.BusyRequest, '', this.successCallback, this.errorCallback, $selected_value, this); } + AjaxDropdownPreloader.prototype.getControl = function($field) { var $id = this.InputMask.replace('#FIELD#', $field); return document.getElementById($id); } + AjaxDropdownPreloader.prototype.successCallback = function($request, $params, $object) { if (Request.processRedirect($request) === true) { return ; @@ -384,6 +391,7 @@ runOnChange(control); $object.AfterProcess(); } + AjaxDropdownPreloader.prototype.ProcessXMLNode = function($node, $dst_field, $selected_value) { for (var i = 0; i < $node.childNodes.length; i++) { var $child = $node.childNodes.item(i); @@ -414,9 +422,11 @@ } } } -AjaxDropdownPreloader.prototype.AfterProcess = function() -{ + +AjaxDropdownPreloader.prototype.AfterProcess = function() { + } + AjaxDropdownPreloader.prototype.removeOptions = function($object) { if (!$object) $object = this.getControl(this.DependendField); if ($object.options.length > 0) { @@ -425,6 +435,7 @@ } } } + AjaxDropdownPreloader.prototype.addOption = function($object, $value, $title, attributes) { var $option = document.createElement('OPTION'); $object.options.add($option, $object.options.length); @@ -438,6 +449,7 @@ } } } + AjaxDropdownPreloader.prototype.errorCallback = function($request, $params, $object) { alert('AJAX Error; class: AjaxDropdownPreloader; ' + Request.getErrorHtml($request)); } \ No newline at end of file