1: <?php
2: /**
3: * Description of Counter
4: *
5: * @author SARTAJ
6: * css class counter-box use jquery apear plugin to start counter.
7: * create only one component and then use class counter to run any other counters
8: * <div class="counter-box">
9: <div class="icon">
10: <img src="masters/assets/img/icon/project-done.svg" alt>
11: </div>
12: <div>
13: <span data-count="+" data-to="2500" data-speed="3000" id="ct1" runat="server" path="libpath/comp/bundle/Counter.php">2500</span>
14: <h6 class="title">+ Orders Done </h6>
15: </div>
16: </div>
17:
18: */
19:
20:
21:
22: class Counter extends Sphp\tools\Component{
23: protected function oncreate($element){
24: $this->setHTMLName("");
25: }
26:
27: protected function onjsrender(){
28: addFileLink($this->myrespath . '/res/jquery.appear.min.js');
29: addFileLink($this->myrespath . '/res/counter-up.js');
30: $this->element->appendAttribute('class', 'counter');
31: if(!$this->element->hasAttribute('data-count')) $this->setAttribute('data-count', '+');
32: if(!$this->element->hasAttribute('data-to')) $this->setAttribute('data-to', '500');
33: if(!$this->element->hasAttribute('data-speed')) $this->setAttribute('data-speed', '3000');
34:
35: addHeaderJSFunctionCode('ready','counter1','
36: $(".counter").countTo();
37: $(".counter-box").appear(
38: function () {
39: $(".counter").countTo();
40: },
41: { accY: -100 }
42: );
43:
44: ');
45:
46: }
47:
48:
49: }