1: <?php
2: /**
3: * Description of Dialog
4: *
5: * @author SARTAJ
6: */
7:
8: class Dialog extends \Sphp\tools\Component{
9: protected function oncreate($element){
10: $this->setHTMLName("");
11: $this->setHTMLID($this->name . '_dlg');
12: }
13:
14: public function sendAJAX($content){
15: SphpBase::JSServer()->addJSONHTMLBlock($this->name . "_body",$content);
16: }
17:
18: protected function onjsrender(){
19: global $jquerypath;
20: //work pending
21: //addFileLink($this->myrespath . '/fq-ui.extendeddialog.css');
22: //addFileLink($this->myrespath . '/fq-ui.extendeddialog.js');
23: SphpJsM::addjQueryUI();
24: $this->setInnerHTML('<div id="'. $this->name .'_body"></div>');
25:
26: if($this->getAttribute('parameter')!=''){
27: $this->parameterA['parameter'] = ", ".$this->parameterA['parameter'];
28: }
29: if($this->getAttribute('opener')==''){
30: $this->parameterA['opener'] = "#opener";
31: }
32:
33: if($this->getAttribute('modal')!=''){
34: $this->parameterA['modal'] = ", modal: ".$this->parameterA['modal'];
35: }
36: if($this->getAttribute('buttons')!=''){
37: $ft = explode(',', $this->parameterA['buttons']);
38: $tu = '';
39: foreach($ft as $key=>$val){
40: if($tu!=''){
41: $tu .= ",";
42: }
43: switch(strtolower($val)){
44: case 'ok':{
45: $tu .= "Ok: function() { $(this).dialog('close'); ".$this->getAttribute('onok')." }";
46: break;
47: }
48: case 'cancel':{
49: $tu .= "Cancel: function() { $(this).dialog('close'); ".$this->getAttribute('oncancel')." }";
50: break;
51: }
52: default:{
53: $tu .= "'$val': function() {".$this->parameterA['on'.strtolower($val)]." }";
54: break;
55: }
56: }
57: }
58: $this->parameterA['buttons'] = ", buttons: {
59: $tu
60: }
61: ";
62: //$this->parameterA['type'] = ", modal: true '".$this->parameterA['axis']. "'";
63: }
64: /*
65: addFileLink($jquerypath.'themes/base/jquery.ui.all.css');
66: addFileLink($jquerypath.'themes/base/jquery.ui.dialog.css');
67: addFileLink($jquerypath.'ui/jquery.ui.core.min.js');
68: addFileLink("{$jquerypath}/ui/jquery.ui.widget.min.js");
69: addFileLink("{$jquerypath}/ui/jquery.ui.mouse.min.js");
70: addFileLink($jquerypath.'ui/jquery.ui.draggable.min.js');
71: addFileLink("{$jquerypath}/ui/jquery.ui.position.min.js");
72: addFileLink($jquerypath.'ui/jquery.ui.resizable.min.js');
73: addFileLink($jquerypath.'ui/jquery.ui.button.min.js');
74: addFileLink($jquerypath.'ui/jquery.ui.dialog.min.js');
75: addFileLink($jquerypath.'ui/jquery.ui.effect.min.js');
76: addFileLink($jquerypath.'ui/jquery.ui.effect-blind.min.js');
77: addFileLink($jquerypath.'ui/jquery.ui.effect-explode.min.js');
78: *
79: */
80: addHeaderJSFunctionCode('ready',$this->HTMLID,'
81: $("#'.$this->HTMLID.'").dialog({
82: autoOpen: false,
83: width: "700",
84: height: "800",
85: show: {
86: effect: "blind",
87: duration: 1000
88: },
89: hide: {
90: effect: "explode",
91: duration: 1000
92: },
93: title: "'.$this->getAttribute('title').'"
94: '.$this->getAttribute('modal').'
95: '.$this->getAttribute('buttons').'
96: '.$this->getAttribute('parameter').'
97: });
98: $( "'.$this->getAttribute('opener').'" ).click(function() {
99: $( "#'.$this->HTMLID.'" ).dialog( "open" );
100: return false;
101: });
102: $(".ui-dialog-titlebar-close").html("X");
103:
104: ');
105: if($this->getAttribute('class') == ''){
106: addHeaderCSS('dragdrop', '
107: .dragdrop
108: {
109: position: relative;
110: cursor: auto;
111: }
112: ');
113: $this->parameterA['class'] = 'dragdrop';
114: }
115:
116: }
117:
118:
119: }
120: