ManageTable : you can set the style of the dialog box

This commit is contained in:
Dany De Bontridder 2020-09-29 18:04:56 +02:00 committed by Dany De Bontridder
parent 948f62809d
commit fa3ef8a59c
2 changed files with 29 additions and 3 deletions

View file

@ -74,9 +74,12 @@ var ManageTable = function (p_table_name)
{
this.callback = "ajax.php"; //!< File to call
this.control = "dtr"; //<! Prefix Id of dialog box, table, row
this.mt_style={position: "fixed", top: '15%', width: "auto", "margin-left": "20%"};
this.sort_column=0;
this.param = {"table": p_table_name, "ctl_id": this.control}; //<! default value to pass
this.set_style=function(p_json) {
this.mt_style=p_json;
};
/**
* Set the sort ,
* @param {string} p_column column number start from 0
@ -308,7 +311,7 @@ var ManageTable = function (p_table_name)
var obj = {id: control, "cssclass": "inner_box", "html": loading()};
add_div(obj);
var pos = calcy(250);
$(obj.id).setStyle({position: "fixed", top: '15%', width: "auto", "margin-left": "20%"});
$(obj.id).setStyle(here.mt_style);
$(obj.id).update(x['html']);
} catch (e) {
smoke.alert(content[48] + e.message);

View file

@ -86,7 +86,7 @@ class Manage_Table_SQL
private $icon_mod; //!< place of right or left the icon update or mod, default right, accepted value=left,right,first column for mod
private $icon_del; //!< place of right or left the icon update or mod, default right, accepted value=left,right
private $dialogbox_style;
/**
* @brief Constructor : set the label to the column name,
* the order of the column , set the properties and the
@ -123,6 +123,7 @@ class Manage_Table_SQL
// By default no js sort
$this->sort_column="";
$this->dialog_box="dtr";
$this->dialogbox_style=array("position"=> "fixed", "top"=> '15%',"width"=> "auto", "margin-left"=> "20%");
}
/**
* send the XML headers for the ajax call
@ -132,6 +133,26 @@ class Manage_Table_SQL
header('Content-type:text/xml;charset="UTF-8"');
}
/**
* return the db_style
* @return array
*/
public function get_dialogbox_style()
{
return $this->dialogbox_style;
}
/**
* Dialog box style , by default {position: "fixed", top: '15%', width: "auto", "margin-left": "20%"}
*
* @param array $db_style , will be transformed into a json object
*/
public function set_dialogbox_style($db_style)
{
$this->dialogbox_style = $db_style;
return $this;
}
/**
* @return mixed
*/
@ -378,6 +399,7 @@ function check()
*/
function create_js_script()
{
$style=json_encode($this->dialogbox_style);
echo "
<script>
var {$this->object_name}=new ManageTable(\"{$this->table->table}\");
@ -385,6 +407,7 @@ function check()
{$this->object_name}.param_add({$this->json_parameter});
{$this->object_name}.set_sort({$this->get_col_sort()});
{$this->object_name}.set_control(\"{$this->get_dialog_box()}\");
{$this->object_name}.set_style($style);
</script>
";