1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: |
|
7: |
|
8: | class OnsenPage extends Control{
|
9: | public static $navigator = false;
|
10: |
|
11: | public function oncreate($element){
|
12: | $this->setHTMLName("");
|
13: | $this->registerEventJS('init');
|
14: | $this->registerEventJS('destroy');
|
15: | $this->registerEventJS('show');
|
16: | $this->registerEventJS('hide');
|
17: | }
|
18: |
|
19: |
|
20: | public function onjsrender(){
|
21: | addFileLink(SphpBase::sphp_settings()->res_path . '/jslib/onsen/onsen.css');
|
22: | addFileLink(SphpBase::sphp_settings()->res_path . '/jslib/onsen/onsen.js');
|
23: |
|
24: | addHeaderJSCode('onsen0', ' window["onsen"] = {};');
|
25: | addHeaderJSFunction('comp_'. $this->name .'_init', 'function comp_'. $this->name .'_init(event) {', '}');
|
26: | addHeaderJSFunction('comp_'. $this->name .'_destroy', 'function comp_'. $this->name .'_destroy(event) {', '}');
|
27: | addHeaderJSFunction('comp_'. $this->name .'_show', 'function comp_'. $this->name .'_show(event) {', '}');
|
28: | addHeaderJSFunction('comp_'. $this->name .'_hide', 'function comp_'. $this->name .'_hide(event) {', '}');
|
29: |
|
30: | addHeaderJSFunction('init', 'document.addEventListener("init", function(event) {bindJsVarRefresh();', '});');
|
31: | addHeaderJSFunction('destroy', 'document.addEventListener("destroy", function(event) {', '});');
|
32: | addHeaderJSFunction('show', 'document.addEventListener("show", function(event) {', '});');
|
33: | addHeaderJSFunction('hide', 'document.addEventListener("hide", function(event) {', '});');
|
34: |
|
35: | addHeaderJSFunctionCode('init',$this->name . '1', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('init') .'; } ');
|
36: | addHeaderJSFunctionCode('destroy',$this->name . '2', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('destroy') .'; } ');
|
37: | addHeaderJSFunctionCode('show',$this->name . '3', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('show') .'; } ');
|
38: | addHeaderJSFunctionCode('hide',$this->name . '4', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('hide') .'; } ');
|
39: | }
|
40: |
|
41: | public function onrender() {
|
42: | $str1 = "";
|
43: | if(! OnsenPage::$navigator){
|
44: | addHeaderJSFunctionCode('ready','onsen1', ' const onsennavi = document.querySelector(\'#onsennavi\');');
|
45: | addHeaderJSCode('onsen3', ' window.onsen.loadPage = function(page,data){onsennavi.bringPageTop(page,data);}');
|
46: | $str1 = '<ons-navigator animation="slide" swipeable id="onsennavi" page="'. $this->name .'.html"></ons-navigator>';
|
47: | OnsenPage::$navigator = true;
|
48: | }
|
49: | $str1 .= '<template id="'. $this->name .'.html">';
|
50: | $this->setPreTag($str1);
|
51: | $this->setPostTag('</template>');
|
52: | }
|
53: |
|
54: | }
|
55: | |