| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 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: |
|
| 21: |
|
| 22: |
|
| 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: |
|
| 63: | }
|
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 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: | |