@@ -8,9 +8,27 @@ class Window
88 private $ content ;
99 private $ options = ['width ' => '0.8 ' , 'height ' => '0.8 ' ];
1010
11- public function __construct (array $ xhr = ['url ' => '' , 'method ' => 'POST ' ])
11+ /**
12+ * Window constructor.
13+ * @param string|array $content
14+ */
15+ public function __construct ($ content )
1216 {
13- $ this ->xhr = json_encode (array_merge ($ this ->xhr , $ xhr ));
17+ $ this ->content = $ content ;
18+ if (is_string ($ content )){
19+ $ this ->content = <<<EOF
20+ function(){
21+ let window = document.createElement('div');
22+ let fragment = document.createRange().createContextualFragment(" {$ this ->content }");
23+ window.appendChild(fragment);
24+ return window;
25+ }()
26+ EOF ;
27+ return ;
28+ }
29+ $ xhr = array_merge (['url ' =>'' ,'method ' =>'' ,'data ' =>[],'callback ' =>'null ' ],$ content );
30+ $ data = json_encode ($ xhr ['data ' ]);
31+ $ this ->content = "{url:' {$ xhr ['url ' ]}',method:' {$ xhr ['method ' ]}',data: {$ data },callback: {$ xhr ['callback ' ]}} " ;
1432 }
1533
1634 /**
@@ -38,28 +56,6 @@ public function options(array $options)
3856 $ this ->options = array_merge ($ this ->options , $ options );
3957 }
4058
41- /**
42- * @param string|array $data
43- */
44- public function content ($ data )
45- {
46- $ this ->content = $ data ;
47- if (is_string ($ data )){
48- $ this ->content = <<<EOF
49- function(){
50- let window = document.createElement('div');
51- let fragment = document.createRange().createContextualFragment(response);
52- window.appendChild(fragment);
53- return window;
54- }()
55- EOF ;
56- return ;
57- }
58- $ xhr = array_merge (['url ' =>'' ,'method ' =>'' ,'data ' =>[],'callback ' =>'null ' ],$ data );
59- $ data = json_encode ($ xhr ['data ' ]);
60- $ this ->content = "{url:' {$ xhr ['url ' ]}',method:' {$ xhr ['method ' ]}',data: {$ data },callback: {$ xhr ['callback ' ]}} " ;
61- }
62-
6359 public function __toString ()
6460 {
6561 $ this ->options = json_encode ($ this ->options );
0 commit comments