1 <?php
2
3 4 5 6 7 8 9 10
11
12 13 14 15 16 17 18 19 20 21 22 23 24
25 class P3MarkdownWidget extends CMarkdown {
26
27 public $filePath;
28 public $css = ".p3-markdown-widget hr {margin-bottom: 100%} .p3-markdown-widget h3 {margin-top: 1em} blockquote p {margin: 2em 0 2em !important; padding: 0px 0 0 10px; border-left: 5px solid orange}";
29
30 function run() {
31 parent::run();
32 Yii::app()->clientScript->registerCss('p3-markdown-widget', $this->css);
33 echo "<div class='p3-markdown-widget'>";
34 echo $this->transform(file_get_contents($this->filePath));
35 echo "</div>";
36
37 $js = '
38 $.each($(".p3-markdown-widget h2"), function(i){
39 var $this = $(this);
40 h2 = $this.html();
41 $this.html("<a id=item href=#item"+i+">"+h2+"</a>");
42 $this.attr("id","item"+i);
43 $this.attr("href","#item"+(i+1));
44 $this.before("<br/><br/><a class=\"btn btn-mini next\" href=#item"+(i-1)+"><i class=icon-arrow-up></a>")
45 $this.before("<a class=\"btn btn-mini next\" href=#item"+i+">"+h2+" <i class=icon-arrow-right></a><hr/>")
46 $this.after("<a class=\"btn btn-mini\" href=#item"+(i+1)+"><i class=icon-arrow-right></i></a><br/><br/>")
47 $this.after("<a class=\"btn btn-mini\" href=#item"+(i-1)+"><i class=icon-arrow-left></i></a>")
48 })
49 ';
50 Yii::app()->clientScript->registerScript('markdown-widget', $js);
51 }
52
53 }
54
55 ?>
56