mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
floated dialogs working again, improved ajax content, front-end response method for automated json response (parsed by dialog JS)
This commit is contained in:
@@ -15,6 +15,8 @@ e107Base.setPrefs('core-dialog', {
|
||||
minHeight: 100,
|
||||
maxHeight: null,
|
||||
maxWidth: null,
|
||||
maxAdaptWidth: null,
|
||||
maxAdaptHeight: null,
|
||||
gridX: 1,
|
||||
gridY: 1,
|
||||
wired: false,
|
||||
@@ -352,6 +354,16 @@ e107Widgets.Dialog = Class.create(e107WidgetAbstract, {
|
||||
*/
|
||||
adapt: function() {
|
||||
var dimensions = this.content.getScrollDimensions();
|
||||
|
||||
if(this.options.maxAdaptHeight && dimensions.height > this.options.maxAdaptHeight)
|
||||
dimensions.height = this.options.maxAdaptHeight;
|
||||
|
||||
if(this.options.maxAdaptWidth && dimensions.width > this.options.maxAdaptWidth)
|
||||
dimensions.width = this.options.maxAdaptWidth;
|
||||
|
||||
if(this.options.maxHeight && dimensions.height > this.options.maxHeight)
|
||||
dimensions.height = this.options.maxHeight;
|
||||
|
||||
if (this.options.superflousEffects)
|
||||
this.morph(dimensions, true);
|
||||
else
|
||||
@@ -392,11 +404,22 @@ e107Widgets.Dialog = Class.create(e107WidgetAbstract, {
|
||||
options[name] = options[name].bind(this);
|
||||
}, this);
|
||||
|
||||
var onComplete = options.onComplete;
|
||||
var onComplete = options.onComplete, afterComplete = options.onAfterComplete;
|
||||
options.onComplete = (function(response, json) {
|
||||
this.setContent(response.responseText);
|
||||
|
||||
if (Object.isFunction(onComplete))
|
||||
onComplete(response, json);
|
||||
else {
|
||||
if(response.responseJSON) {
|
||||
this.setContent(response.responseJSON['body']);
|
||||
this.setHeader(response.responseJSON['header']);
|
||||
this.setFooter(response.responseJSON['footer']);
|
||||
}
|
||||
else this.setContent(response.responseText);
|
||||
}
|
||||
|
||||
if (Object.isFunction(afterComplete))
|
||||
afterComplete(response, json);
|
||||
}).bind(this);
|
||||
|
||||
new e107Ajax.Request(url, options);
|
||||
@@ -691,7 +714,7 @@ e107Widgets.Dialog = Class.create(e107WidgetAbstract, {
|
||||
computePosition: function(top, left) {
|
||||
if (this.modal && this.centerOptions && this.centerOptions.auto)
|
||||
return this.computeRecenter(this.getSize());
|
||||
|
||||
|
||||
return {
|
||||
top: this.animating ? top : top.snap(this.options.gridY),
|
||||
left: this.animating ? left : left.snap(this.options.gridX)
|
||||
@@ -1556,7 +1579,8 @@ e107Widgets.DialogManager.DefPositionningStrategy = function(win, area, winoffse
|
||||
maxtop = area.height - size.height,
|
||||
maxleft = area.width - size.width,
|
||||
poffset = winoffset === false ? 0 : (winoffset || 20),
|
||||
start = { left: offset[0] + poffset, top: offset[1] + poffset };
|
||||
start = { left: offset[0] + poffset, top: offset[1] + poffset },
|
||||
left, top;
|
||||
|
||||
if(last) {
|
||||
start = last.getPosition();
|
||||
@@ -1566,7 +1590,6 @@ e107Widgets.DialogManager.DefPositionningStrategy = function(win, area, winoffse
|
||||
|
||||
left = start.left < maxleft ? start.left : start.left - (poffset * 2);
|
||||
top = start.top < maxtop ? start.top : start.top - (poffset * 2);
|
||||
|
||||
win.setPosition(top, left);
|
||||
};
|
||||
|
||||
|
@@ -2702,6 +2702,12 @@ class eController
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add document title
|
||||
* @param string $title
|
||||
* @param boolean $meta auto-add it as meta-title
|
||||
* @return eResponse
|
||||
*/
|
||||
public function addTitle($title, $meta = true)
|
||||
{
|
||||
$this->getResponse()->appendTitle($title);
|
||||
@@ -3410,6 +3416,8 @@ class eResponse
|
||||
protected $_params = array(
|
||||
'render' => true,
|
||||
'meta' => false,
|
||||
'jsonNoTitle' => false,
|
||||
'jsonRender' => false,
|
||||
);
|
||||
|
||||
public function setParam($key, $value)
|
||||
@@ -3429,6 +3437,11 @@ class eResponse
|
||||
return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
|
||||
}
|
||||
|
||||
public function isParam($key)
|
||||
{
|
||||
return isset($this->_params[$key]);
|
||||
}
|
||||
|
||||
public function addContentType($typeName, $mediaType)
|
||||
{
|
||||
$this->_content_type_arr[$typeName] = $mediaType;
|
||||
@@ -3797,6 +3810,55 @@ class eResponse
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send AJAX Json Response Output - default method
|
||||
* It's fully compatible with the core dialog.js
|
||||
* @param array $override override output associative array (header, body and footer keys)
|
||||
* @param string $ns namespace/segment
|
||||
* @param bool $render_message append system messages
|
||||
*/
|
||||
function sendJson($override = array(), $ns = null, $render_message = true)
|
||||
{
|
||||
if(!$ns) $ns = 'default';
|
||||
|
||||
$content = $this->getBody($ns, true);
|
||||
// separate render parameter for json response, false by default
|
||||
$render = $this->getParam('jsonRender');
|
||||
if($render_message)
|
||||
{
|
||||
$content = eMessage::getInstance()->render().$content;
|
||||
}
|
||||
|
||||
//render disabled by the controller
|
||||
if(!$this->getRenderMod($ns))
|
||||
{
|
||||
$render = false;
|
||||
}
|
||||
|
||||
|
||||
$title = '';
|
||||
if(!$this->getParam('jsonNoTitle'))
|
||||
{
|
||||
$titleArray = $this->_title;
|
||||
$title = isset($titleArray[$ns]) ? array_pop($titleArray[$ns]) : '';
|
||||
}
|
||||
|
||||
if($render)
|
||||
{
|
||||
$render = e107::getRender();
|
||||
$content = $render->tablerender($this->getTitle($ns, true), $content, $this->getRenderMod($ns), true);
|
||||
}
|
||||
|
||||
$jshelper = e107::getJshelper();
|
||||
$override = array_merge(array(
|
||||
'header' => $title,
|
||||
'body' => $content,
|
||||
'footer' => $statusText,
|
||||
), $override);
|
||||
echo $jshelper->buildJsonResponse($override);
|
||||
$jshelper->sendJsonResponse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* JS manager
|
||||
* @return e_jsmanager
|
||||
|
Reference in New Issue
Block a user