1: <?php
2: /**
3: * Description of OnsenPage
4: *
5: * @author SARTAJ
6: */
7:
8: class OnsenPage extends \Sphp\tools\Component{
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/css/onsenui.css',false,"","","onsen:4",[SphpBase::sphp_settings()->res_path . '/jslib/onsen/css']);
22: addFileLink(SphpBase::sphp_settings()->res_path . '/jslib/onsen/css/onsen-css-components.min.css',false,"","","onsen:4",[SphpBase::sphp_settings()->res_path . '/jslib/onsen/css']);
23: addFileLink(SphpBase::sphp_settings()->res_path . '/jslib/onsen/js/onsenui.min.js');
24:
25: addHeaderJSCode('onsen0', ' window["onsen"] = {};');
26: addHeaderJSFunction('comp_'. $this->name .'_init', 'function comp_'. $this->name .'_init(event) {', '}');
27: addHeaderJSFunction('comp_'. $this->name .'_destroy', 'function comp_'. $this->name .'_destroy(event) {', '}');
28: addHeaderJSFunction('comp_'. $this->name .'_show', 'function comp_'. $this->name .'_show(event) {', '}');
29: addHeaderJSFunction('comp_'. $this->name .'_hide', 'function comp_'. $this->name .'_hide(event) {', '}');
30:
31: addHeaderJSFunction('init', 'document.addEventListener("init", function(event) {bindJsVarRefresh();', '});');
32: addHeaderJSFunction('destroy', 'document.addEventListener("destroy", function(event) {', '});');
33: addHeaderJSFunction('show', 'document.addEventListener("show", function(event) {', '});');
34: addHeaderJSFunction('hide', 'document.addEventListener("hide", function(event) {', '});');
35:
36: addHeaderJSFunctionCode('init',$this->name . '1', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('init') .'; } ');
37: addHeaderJSFunctionCode('destroy',$this->name . '2', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('destroy') .'; } ');
38: addHeaderJSFunctionCode('show',$this->name . '3', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('show') .'; } ');
39: addHeaderJSFunctionCode('hide',$this->name . '4', 'if(event.target.id == "'. $this->name.'"){ '. $this->raiseEventJS('hide') .'; } ');
40: }
41:
42: public function onrender() {
43: $str1 = "";
44: if(! OnsenPage::$navigator){
45: addHeaderJSFunctionCode('ready','onsen1', ' const onsennavi = document.querySelector(\'#onsennavi\');');
46: addHeaderJSCode('onsen3', ' window.onsen.loadPage = function(page,data){onsennavi.bringPageTop(page,data);}');
47: $str1 = '<ons-navigator animation="slide" swipeable id="onsennavi" page="'. $this->name .'.html"></ons-navigator>';
48: OnsenPage::$navigator = true;
49: }
50: $str1 .= '<template id="'. $this->name .'.html">';
51: $this->setPreTag($str1);
52: $this->setPostTag('</template>');
53: }
54:
55: }
56: