]> git.mxchange.org Git - friendica.git/blob - view/theme/duepuntozero/theme.php
Update insertFormatting() definition
[friendica.git] / view / theme / duepuntozero / theme.php
1 <?php
2
3 function duepuntozero_init(&$a) {
4
5 set_template_engine($a, 'smarty3');
6
7     $colorset = get_pconfig( local_user(), 'duepuntozero','colorset');
8     if (!$colorset)
9        $colorset = get_config('duepuntozero', 'colorset');          // user setting have priority, then node settings
10     if ($colorset) {
11         if ($colorset == 'greenzero')
12             $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />'."\n";
13         if ($colorset == 'purplezero')
14             $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />'."\n";
15         if ($colorset == 'easterbunny')
16             $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />'."\n";
17         if ($colorset == 'darkzero')
18             $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />'."\n";
19         if ($colorset == 'comix')
20             $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />'."\n";
21         if ($colorset == 'slackr')
22             $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/slackr.css" type="text/css" media="screen" />'."\n";
23     }
24 $a->page['htmlhead'] .= <<< EOT
25 <script>
26 function insertFormatting(BBcode, id) {
27         var tmpStr = $("#comment-edit-text-" + id).val();
28         if (tmpStr == "") {
29                 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
30                 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
31                 openMenu("comment-edit-submit-wrapper-" + id);
32                 $("#comment-edit-text-" + id).val(tmpStr);
33         }
34
35         textarea = document.getElementById("comment-edit-text-" +id);
36         if (document.selection) {
37                 textarea.focus();
38                 selected = document.selection.createRange();
39                 if (BBcode == "url") {
40                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
41                 } else {
42                         selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
43                 }
44         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
45                 var start = textarea.selectionStart;
46                 var end = textarea.selectionEnd;
47                 if (BBcode == "url") {
48                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
49                 } else {
50                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
51                 }
52         }
53
54         return true;
55 }
56
57 function cmtBbOpen(comment, id) {
58         if ($(comment).hasClass('comment-edit-text-full')) {
59                 $(".comment-edit-bb-" + id).show();
60                 return true;
61         }
62         return false;
63 }
64 function cmtBbClose(comment, id) {
65         return false;
66 }
67 $(document).ready(function() {
68
69         $('html').click(function() { $("#nav-notifications-menu" ).hide(); });
70
71         $('.group-edit-icon').hover(
72                 function() {
73                         $(this).addClass('icon'); $(this).removeClass('iconspacer');},
74                 function() {
75                         $(this).removeClass('icon'); $(this).addClass('iconspacer');}
76         );
77
78         $('.sidebar-group-element').hover(
79                 function() {
80                         id = $(this).attr('id');
81                         $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
82
83                 function() {
84                         id = $(this).attr('id');
85                         $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
86         );
87
88
89         $('.savedsearchdrop').hover(
90                 function() {
91                         $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
92                 function() {
93                         $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
94         );
95
96         $('.savedsearchterm').hover(
97                 function() {
98                         id = $(this).attr('id');
99                         $('#drop-' + id).addClass('icon');      $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
100
101                 function() {
102                         id = $(this).attr('id');
103                         $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
104         );
105 });
106 </script>
107 EOT;
108 }