public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
Fixed tag cloud AJAX editing. [#190 state:resolved]
vito (author)
Thu Aug 28 16:53:32 -0700 2008
commit  aabc4c3120e84e9b508b8f053f68dfe984f47212
tree    50aaf885b50eb56b79fff236fc6cbbea2b8d0abb
parent  c052e58651a3931fae92a12ae359981932c59f20
...
1
2
3
4
 
5
 
6
7
8
...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
69
70
71
...
502
503
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
...
1
2
3
 
4
5
6
7
8
9
...
28
29
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
32
33
34
...
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
0
@@ -1,8 +1,9 @@
0
 <?php
0
   class Tags extends Modules {
0
     public function __init() {
0
-      $this->addAlias('metaWeblog_newPost_preQuery', 'metaWeblog_editPost_preQuery');
0
+      $this->addAlias("metaWeblog_newPost_preQuery", "metaWeblog_editPost_preQuery");
0
       $this->addAlias("post_grab", "posts_get");
0
+      $this->addAlias("javascript", "cloudSelectorJS");
0
     }
0
 
0
     static function __install() {
0
@@ -27,45 +28,7 @@
0
       $config = Config::current();
0
 ?>
0
     <script type="text/javascript">
0
-      $(function(){
0
-        function scanTags(){
0
-          $(".tags_select a").each(function(){
0
-            regexp = new RegExp("(, ?|^)"+ $(this).text() +"(, ?|$)", "g")
0
-            if ($("#tags").val().match(regexp))
0
-              $(this).addClass("tag_added")
0
-            else
0
-              $(this).removeClass("tag_added")
0
-          })
0
-        }
0
-        scanTags()
0
-        $("#tags").livequery("keyup", scanTags)
0
-        $(".tag_cloud > span").livequery("mouseover", function(){
0
-          $(this).find(".controls").css("opacity", 1)
0
-        }).livequery("mouseout", function(){
0
-          $(this).find(".controls").css("opacity", 0)
0
-        })
0
-      })
0
-
0
-      function add_tag(name, link) {
0
-        if ($("#tags").val().match("(, |^)"+ name +"(, |$)")) {
0
-          regexp = new RegExp("(, |^)"+ name +"(, |$)", "g")
0
-          $("#tags").val($("#tags").val().replace(regexp, function(match, before, after){
0
-            if (before == ", " && after == ", ")
0
-              return ", "
0
-            else
0
-              return ""
0
-          }))
0
-
0
-          $(link).removeClass("tag_added")
0
-        } else {
0
-          if ($("#tags").val() == "")
0
-            $("#tags").val(name)
0
-          else
0
-            $("#tags").val($("#tags").val() + ", "+ name)
0
-
0
-          $(link).addClass("tag_added")
0
-        }
0
-      }
0
+<?php $this->cloudSelectorJS(); ?>
0
     </script>
0
     <link rel="stylesheet" href="<?php echo $config->chyrp_url; ?>/modules/tags/admin.css" type="text/css" media="screen" title="no title" charset="utf-8" />
0
 <?php
0
@@ -502,4 +465,48 @@
0
       $atom.= "    <chyrp:tags>".fix(implode(", ", self::unlinked_tags($tags)))."</chyrp:tags>\r";
0
       return $atom;
0
     }
0
+
0
+    public function cloudSelectorJS() {
0
+?>
0
+      $(function(){
0
+        function scanTags(){
0
+          $(".tags_select a").each(function(){
0
+            regexp = new RegExp("(, ?|^)"+ $(this).text() +"(, ?|$)", "g")
0
+            if ($("#tags").val().match(regexp))
0
+              $(this).addClass("tag_added")
0
+            else
0
+              $(this).removeClass("tag_added")
0
+          })
0
+        }
0
+        scanTags()
0
+        $("#tags").livequery("keyup", scanTags)
0
+        $(".tag_cloud > span").livequery("mouseover", function(){
0
+          $(this).find(".controls").css("opacity", 1)
0
+        }).livequery("mouseout", function(){
0
+          $(this).find(".controls").css("opacity", 0)
0
+        })
0
+      })
0
+
0
+      function add_tag(name, link) {
0
+        if ($("#tags").val().match("(, |^)"+ name +"(, |$)")) {
0
+          regexp = new RegExp("(, |^)"+ name +"(, |$)", "g")
0
+          $("#tags").val($("#tags").val().replace(regexp, function(match, before, after){
0
+            if (before == ", " && after == ", ")
0
+              return ", "
0
+            else
0
+              return ""
0
+          }))
0
+
0
+          $(link).removeClass("tag_added")
0
+        } else {
0
+          if ($("#tags").val() == "")
0
+            $("#tags").val(name)
0
+          else
0
+            $("#tags").val($("#tags").val() + ", "+ name)
0
+
0
+          $(link).addClass("tag_added")
0
+        }
0
+      }
0
+<?php
0
+    }
0
   }
...
651
652
653
654
655
656
657
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
...
651
652
653
 
 
 
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
0
@@ -651,6 +651,30 @@ span.waiting {
0
 }
0
 
0
 /* Miscellaneous */
0
-img.smiley {
0
-  margin: 0 0 -.3em;
0
-}
0
\ No newline at end of file
0
+  /* Emoticons module. */
0
+  img.smiley {
0
+    margin: 0 0 -.3em;
0
+  }
0
+
0
+  /* Tags module (ajax editing). */
0
+  .tags_select {
0
+    display: inline-block;
0
+    margin-top: .5em;
0
+  }
0
+  .tags_select a {
0
+    padding: .1em .4em;
0
+    border: .1em solid #DDDDA8;
0
+    background: #FFFFCA;
0
+    text-decoration: none;
0
+    border-top-width: 0;
0
+    border-left-width: 0;
0
+    color: #555;
0
+  }
0
+  .tags_select a.tag_added {
0
+    background: #111;
0
+    border-top-width: .1em;
0
+    border-bottom: 0;
0
+    border-left-width: .1em;
0
+    border-right: 0;
0
+    border-color: #000;
0
+  }
0
\ No newline at end of file

Comments