Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/incs/blocks.tpl =================================================================== diff -u -r6734 -r6899 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/incs/blocks.tpl (.../blocks.tpl) (revision 6734) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/incs/blocks.tpl (.../blocks.tpl) (revision 6899) @@ -12,6 +12,9 @@ + Index: branches/unlabeled/unlabeled-1.2.2/core/admin_templates/index.tpl =================================================================== diff -u -r6786 -r6899 --- branches/unlabeled/unlabeled-1.2.2/core/admin_templates/index.tpl (.../index.tpl) (revision 6786) +++ branches/unlabeled/unlabeled-1.2.2/core/admin_templates/index.tpl (.../index.tpl) (revision 6899) @@ -24,17 +24,6 @@ } else { document.write(""); } - - function getFrame($name) - { - var $frameset = window.frames; - for ($i = 0; $i < window.length; $i++) { - if ($frameset[$i].name == $name) { - return $frameset[$i]; - } - } - return window; - } Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/ajax.js =================================================================== diff -u -r6734 -r6899 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/ajax.js (.../ajax.js) (revision 6734) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/ajax.js (.../ajax.js) (revision 6899) @@ -254,4 +254,51 @@ document.getElementById('progress_bar[done]').style.width = $display_progress + '%'; document.getElementById('progress_bar[left]').style.width = (100 - $display_progress) + '%'; return $percent < 100 ? true : false; +} + +// AJAX PopupManager class +function AjaxPopupManager($url) { + this.URL = $url; + this.ResponceFunction = null; + this.PopupSizes = new Array(); +} + +AjaxPopupManager.prototype.GetSize = function ($template) { + if (typeof this.ResponceFunction != 'function') { + alert ('Please define responce function first'); + } + + if (!isset(this.PopupSizes[$template])) { +// alert('from ajax'); + var $url = this.URL + '&type=GetPopupSize&template_name=' + $template; + Request.makeRequest($url, this.BusyRequest, '', this.successCallback, this.errorCallback, ['GetSize', $template], this); + } + else { +// alert('from cache'); + this.ResponceFunction(this.PopupSizes[$template]); + } +} + +AjaxPopupManager.prototype.successCallback = function($request, $params, $object) { + var $responce = $request.responseText; + var $match_redirect = new RegExp('^#redirect#(.*)').exec($responce); + if ($match_redirect != null) { + // redirect to external template requested + window.location.href = $match_redirect[1]; + return false; + } + + 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)); } \ No newline at end of file Index: branches/unlabeled/unlabeled-1.2.2/core/admin_templates/tree.tpl =================================================================== diff -u -r6786 -r6899 --- branches/unlabeled/unlabeled-1.2.2/core/admin_templates/tree.tpl (.../tree.tpl) (revision 6786) +++ branches/unlabeled/unlabeled-1.2.2/core/admin_templates/tree.tpl (.../tree.tpl) (revision 6899) @@ -102,10 +102,9 @@ var $kf = document.getElementById($form_name); $kf.target = 'main_frame'; - function checkCatalog($cat_id) { var $ret = checkEditMode(); - var $right_frame = window.parent.getFrame('main'); + var $right_frame = getFrame('main'); if ($ret && $right_frame.$is_catalog) { $right_frame.$Catalog.go_to_cat($cat_id); return 1; // this opens folder, but disables click @@ -116,7 +115,7 @@ function checkEditMode() { var $phrase = ""; - if (window.parent.getFrame('main').$edit_mode) { + if (getFrame('main').$edit_mode) { return confirm($phrase) ? true : false; } Index: branches/unlabeled/unlabeled-1.27.2/core/units/admin/admin_tag_processor.php =================================================================== diff -u -r6889 -r6899 --- branches/unlabeled/unlabeled-1.27.2/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6889) +++ branches/unlabeled/unlabeled-1.27.2/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6899) @@ -537,9 +537,59 @@ */ function SetPopupSize($params) { - + $width = $params['width']; + $height = $params['height']; + + if ($this->Application->GetVar('ajax') == 'yes') { + // during AJAX request just output size + die($width.'x'.$height); + } + + $t = $this->Application->GetVar('t'); + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'PopupSizes + WHERE TemplateName = '.$this->Conn->qstr($t); + $popup_info = $this->Conn->GetRow($sql); + 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'); + } + 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']); + } } + /** + * 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->Parser->ParseTemplate($t); // dies when SetPopupSize tag found & in ajax requrest + return '750x400'; // tag SetPopupSize not found in template -> use default size + } + return $popup_info['PopupWidth'].'x'.$popup_info['PopupHeight']; + } + function UsePopups($params) { return true; Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/tree.js =================================================================== diff -u -r6734 -r6899 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/tree.js (.../tree.js) (revision 6734) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/tree.js (.../tree.js) (revision 6899) @@ -105,7 +105,7 @@ // ensures, that click is made before AJAX request will be sent if (res === true) { // only in case of "true" is returned, used in catalog - window.parent.getFrame(link.target).location.href = this.href; + getFrame(link.target).location.href = this.href; } if (!this.treeItem.Expanded && typeof(this.treeItem.folderClick) == 'function') { Index: branches/unlabeled/unlabeled-1.2.2/core/admin_templates/head.tpl =================================================================== diff -u -r6861 -r6899 --- branches/unlabeled/unlabeled-1.2.2/core/admin_templates/head.tpl (.../head.tpl) (revision 6861) +++ branches/unlabeled/unlabeled-1.2.2/core/admin_templates/head.tpl (.../head.tpl) (revision 6899) @@ -2,6 +2,10 @@ + + Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/incs/header.tpl =================================================================== diff -u -r6867 -r6899 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/incs/header.tpl (.../header.tpl) (revision 6867) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/incs/header.tpl (.../header.tpl) (revision 6899) @@ -17,6 +17,7 @@ + @@ -36,7 +37,6 @@ var $use_popups = truefalse; - Index: branches/unlabeled/unlabeled-1.2.2/core/admin_templates/js/script.js =================================================================== diff -u -r6889 -r6899 --- branches/unlabeled/unlabeled-1.2.2/core/admin_templates/js/script.js (.../script.js) (revision 6889) +++ branches/unlabeled/unlabeled-1.2.2/core/admin_templates/js/script.js (.../script.js) (revision 6899) @@ -411,7 +411,9 @@ function openwin($url,$name,$width,$height) { -// alert('openwin: name = ['+$name+']'); + // prevent window from opening larger, then screen resolution on user's computer (to Kostja) + + // alert('openwin: name = ['+$name+']'); var left = Math.round((screen.width - $width)/2); var top = Math.round((screen.height - $height)/2); @@ -423,18 +425,40 @@ return window.open($url,$name,$window_params); } +function OnResizePopup(e) { + if (!document.all) { + var $winW = window.innerWidth; + var $winH = window.innerHeight; + } + else { + var $winW = window.document.body.offsetWidth; + var $winH = window.document.body.offsetHeight; + } + + window.status = '[width: ' + $winW + '; height: ' + $winH + ']'; +} + function opener_action(new_action) { var $prev_opener = get_hidden_field('m_opener'); set_hidden_field('m_opener', new_action); return $prev_opener; } -function open_popup($prefix_special, $event, $t) { +function open_popup($prefix_special, $event, $t, $window_size) { + if (!$window_size) { + // if no size given, then query it from ajax + var $pm = getFrame('head').$popup_manager; + $pm.ResponceFunction = function ($responce) { + open_popup($prefix_special, $event, $t, $responce); + } + $pm.GetSize($t); + return ; + } + var $kf = document.getElementById($form_name); var $window_name = $t.replace(/(\/|-)/g, '_'); // replace "/" and "-" with "_" - var $window_size = '750x400'; // query with AJAX later $window_size = $window_size.split('x'); openwin('', $window_name, $window_size[0], $window_size[1]); @@ -498,7 +522,6 @@ } } - // set current form base on ajax function set_form($prefix_special, $ajax) { @@ -1129,3 +1152,13 @@ return str.replace(/[ _\']+/g, '.'); } + function getFrame($name) + { + var $frameset = window.parent.frames; + for ($i = 0; $i < $frameset.length; $i++) { + if ($frameset[$i].name == $name) { + return $frameset[$i]; + } + } + return window.parent; + } \ No newline at end of file Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/ajax/popup_manager.tpl =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/ajax/popup_manager.tpl (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/ajax/popup_manager.tpl (revision 6899) @@ -0,0 +1 @@ + \ No newline at end of file