Index: admin_templates/ajax/popup_manager.tpl =================================================================== --- admin_templates/ajax/popup_manager.tpl (revision 15437) +++ admin_templates/ajax/popup_manager.tpl (working copy) @@ -1 +0,0 @@ - \ No newline at end of file Index: admin_templates/categories/images_edit.tpl =================================================================== --- admin_templates/categories/images_edit.tpl (revision 15437) +++ admin_templates/categories/images_edit.tpl (working copy) @@ -1,3 +1,5 @@ + + @@ -26,14 +28,14 @@ go_to_id('c-img', ''); } )); - + a_toolbar.AddButton( new ToolBarButton('next', '', function() { go_to_id('c-img', ''); } )); - + a_toolbar.Render(); - + a_toolbar.HideButton('prev'); a_toolbar.HideButton('next'); Index: admin_templates/categories/related_searches_edit.tpl =================================================================== --- admin_templates/categories/related_searches_edit.tpl (revision 15437) +++ admin_templates/categories/related_searches_edit.tpl (working copy) @@ -1,3 +1,5 @@ + + @@ -23,14 +25,14 @@ go_to_id('c-search', ''); } )); - + a_toolbar.AddButton( new ToolBarButton('next', '', function() { go_to_id('c-search', ''); } )); - + a_toolbar.Render(); - + a_toolbar.HideButton('prev'); a_toolbar.HideButton('next'); Index: admin_templates/categories/relations_edit.tpl =================================================================== --- admin_templates/categories/relations_edit.tpl (revision 15437) +++ admin_templates/categories/relations_edit.tpl (working copy) @@ -1,3 +1,5 @@ + + @@ -34,7 +36,7 @@ a_toolbar.HideButton('prev'); a_toolbar.HideButton('next'); - a_toolbar.HideButton('sep1'); + a_toolbar.HideButton('sep1'); a_toolbar.DisableButton('next'); Index: admin_templates/config/config_search_edit.tpl =================================================================== --- admin_templates/config/config_search_edit.tpl (revision 15437) +++ admin_templates/config/config_search_edit.tpl (working copy) @@ -1,3 +1,5 @@ + + Index: admin_templates/head.tpl =================================================================== --- admin_templates/head.tpl (revision 15437) +++ admin_templates/head.tpl (working copy) @@ -5,7 +5,7 @@ Index: admin_templates/js/ajax.js =================================================================== --- admin_templates/js/ajax.js (revision 15437) +++ admin_templates/js/ajax.js (working copy) @@ -318,44 +318,35 @@ // AJAX PopupManager class function AjaxPopupManager($url) { this.URL = $url; - this.ResponceFunction = null; - this.PopupSizes = new Array(); + this.PopupSizes = []; } -AjaxPopupManager.prototype.GetSize = function ($template) { - if (this.ResponceFunction == null) { - alert ('Please define responce function first (type: '+typeof(this.ResponceFunction)+')'); +AjaxPopupManager.prototype.GetSize = function ($template, $callback) { + if ( $callback === undefined || !$.isFunction($callback) ) { + alert('Please specify callback'); } - if (!isset(this.PopupSizes[$template])) { - var $url = this.URL + '&type=GetPopupSize&template_name=' + $template; -// alert('from ajax: '+$url); - Request.makeRequest($url, this.BusyRequest, '', this.successCallback, this.errorCallback, ['GetSize', $template], this); + if ( !isset(this.PopupSizes[$template]) ) { + var $me = this; + + $.get( + this.URL, + { + 'events[adm]': 'OnGetPopupSize', + 'template_name': $template + }, + function ($popup_size) { + // store response to cache for future use + $me.PopupSizes[$template] = $popup_size; + $callback($popup_size); + } + ); } else { -// alert('from cache'); - this.ResponceFunction(this.PopupSizes[$template]); + $callback(this.PopupSizes[$template]); } -} +}; -AjaxPopupManager.prototype.successCallback = function($request, $params, $object) { - var $responce = $request.responseText; - - switch ($params[0]) { - case 'GetSize': - // store responce to cache for future use - $object.PopupSizes[ $params[1] ] = $responce; - break; - } - - $object.ResponceFunction($responce); - $object.ResponceFunction = null; // reset responce function -} - -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, $has_empty) { this.URL = $url; Index: admin_templates/js/script.js =================================================================== --- admin_templates/js/script.js (revision 15437) +++ admin_templates/js/script.js (working copy) @@ -468,16 +468,15 @@ if ( $pm ) { // popup manager was found in head frame - $pm.ResponceFunction = function ($responce) { - if ( !$responce.match(/([\d]+)x([\d]+)/) ) { - // invalid responce was received, may be php fatal error during AJAX request - $responce = $default_size; + $pm.GetSize($t, function ($response) { + if ( !$response.match(/([\d]+)x([\d]+)/) ) { + // invalid response was received, may be php fatal error during AJAX request + $response = $default_size; } - open_popup($prefix_special, $event, $t, $responce, $onAfterOpenPopup); - } + open_popup($prefix_special, $event, $t, $response, $onAfterOpenPopup); + }); - $pm.GetSize($t); return; } Index: admin_templates/users/admin_edit_group.tpl =================================================================== --- admin_templates/users/admin_edit_group.tpl (revision 15437) +++ admin_templates/users/admin_edit_group.tpl (working copy) @@ -1,5 +1,6 @@ + + - Index: admin_templates/users/image_edit.tpl =================================================================== --- admin_templates/users/image_edit.tpl (revision 15437) +++ admin_templates/users/image_edit.tpl (working copy) @@ -1,3 +1,5 @@ + + @@ -25,14 +27,14 @@ go_to_id('u-img', ''); } )); - + a_toolbar.AddButton( new ToolBarButton('next', '', function() { go_to_id('u-img', ''); } )); - + a_toolbar.Render(); - + a_toolbar.HideButton('prev'); a_toolbar.HideButton('next'); Index: admin_templates/users/user_edit_group.tpl =================================================================== --- admin_templates/users/user_edit_group.tpl (revision 15437) +++ admin_templates/users/user_edit_group.tpl (working copy) @@ -1,3 +1,5 @@ + + Index: units/admin/admin_events_handler.php =================================================================== --- units/admin/admin_events_handler.php (revision 15437) +++ units/admin/admin_events_handler.php (working copy) @@ -1131,6 +1131,43 @@ $this->Conn->Query('OPTIMIZE TABLE ' . $table_name); } } + + /** + * Returns popup size (by template), if not cached, then parse template to get value + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnGetPopupSize(kEvent $event) + { + $event->status = kEvent::erSTOP; + + if ( $this->Application->GetVar('ajax') != 'yes' ) { + return; + } + + $t = $this->Application->GetVar('template_name'); + + $sql = 'SELECT * + FROM ' . TABLE_PREFIX . 'PopupSizes + WHERE TemplateName = ' . $this->Conn->qstr($t); + $popup_info = $this->Conn->GetRow($sql); + + $this->Application->setContentType('text/plain'); + + if ( !$popup_info ) { + // dies when SetPopupSize tag found & in ajax request + $this->Application->InitParser(); + $this->Application->ParseBlock(Array ('name' => $t)); + + // tag SetPopupSize not found in template -> use default size + echo '750x400'; + } + else { + echo $popup_info['PopupWidth'] . 'x' . $popup_info['PopupHeight']; + } + } } Index: units/admin/admin_tag_processor.php =================================================================== --- units/admin/admin_tag_processor.php (revision 15437) +++ units/admin/admin_tag_processor.php (working copy) @@ -654,64 +654,49 @@ * Allows to set popup size (key - current template name) * * @param Array $params + * @return string + * @access protected */ - function SetPopupSize($params) + protected function SetPopupSize($params) { $width = $params['width']; $height = $params['height']; - if ($this->Application->GetVar('ajax') == 'yes') { + if ( $this->Application->GetVar('ajax') == 'yes' ) { // during AJAX request just output size - die($width.'x'.$height); + die($width . 'x' . $height); } - if (!$this->UsePopups($params)) { - return ; + if ( !$this->UsePopups($params) ) { + return; } $t = $this->Application->GetVar('t'); + $sql = 'SELECT * - FROM '.TABLE_PREFIX.'PopupSizes - WHERE TemplateName = '.$this->Conn->qstr($t); + FROM ' . TABLE_PREFIX . 'PopupSizes + WHERE TemplateName = ' . $this->Conn->qstr($t); $popup_info = $this->Conn->GetRow($sql); - if (!$popup_info) { + + if ( !$popup_info ) { // create new popup size record - $fields_hash = Array ( - 'TemplateName' => $t, - 'PopupWidth' => $width, - 'PopupHeight' => $height, - ); - $this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PopupSizes'); + $fields_hash = Array ( + 'TemplateName' => $t, + 'PopupWidth' => $width, + 'PopupHeight' => $height, + ); + + $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'PopupSizes'); } - elseif ($popup_info['PopupWidth'] != $width || $popup_info['PopupHeight'] != $height) { + elseif ( $popup_info['PopupWidth'] != $width || $popup_info['PopupHeight'] != $height ) { // popup found and size in tag differs from one in db -> update in db - $fields_hash = Array ( - 'PopupWidth' => $width, - 'PopupHeight' => $height, - ); - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'PopupSizes', 'PopupId = '.$popup_info['PopupId']); - } - } + $fields_hash = Array ( + 'PopupWidth' => $width, + 'PopupHeight' => $height, + ); - /** - * Returns popup size (by template), if not cached, then parse template to get value - * - * @param Array $params - * @return string - */ - function GetPopupSize($params) - { - $t = $this->Application->GetVar('template_name'); - $sql = 'SELECT * - FROM '.TABLE_PREFIX.'PopupSizes - WHERE TemplateName = '.$this->Conn->qstr($t); - $popup_info = $this->Conn->GetRow($sql); - if (!$popup_info) { - $this->Application->InitParser(); - $this->Application->ParseBlock(array('name' => $t)); // dies when SetPopupSize tag found & in ajax requrest - return '750x400'; // tag SetPopupSize not found in template -> use default size + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'PopupSizes', 'PopupId = ' . $popup_info['PopupId']); } - return $popup_info['PopupWidth'].'x'.$popup_info['PopupHeight']; } /**