~openerp-community/openobject-doc/ksa-openobject-doc-6.0

« back to all changes in this revision

Viewing changes to i18n/ru/source/.static/tiny_js_kit_comment_control.js

  • Committer: Don Kirkby
  • Date: 2011-02-21 20:46:11 UTC
  • mfrom: (433.1.53 openobject-doc)
  • Revision ID: donkirkby+launpd@gmail.com-20110221204611-1ykt6dmg4k3gh5dh
[MERGE] revisions 477 to 486 from the 5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// Computes the final permalink attributes for JS Comment DIVs
 
3
function setPermaLinks() {
 
4
    $(".js-kit-comments").attr(
 
5
           "permalink",
 
6
           function(){
 
7
               var anchor = $(this).attr("permalink_anchor");
 
8
               if (anchor) {
 
9
                   //ugly, gotta reconstruct the url without the trailing anchor
 
10
                   var location = document.location.href;
 
11
                   var hashlen = document.location.hash.length;
 
12
                   if (hashlen > 0) {
 
13
                      location = location.slice(0,-hashlen);
 
14
                   }
 
15
                   return location+anchor;
 
16
               }
 
17
               return "";
 
18
           });
 
19
}
 
20
 
 
21
$(window).load(function(){
 
22
  $("#comments_control").change(
 
23
    function () {
 
24
      var selected_value = $(this).val();
 
25
      switch(selected_value) {
 
26
        case 'HIDE': {
 
27
          createJsKitCommentCookie('HIDE');
 
28
          $('.js-kit-comments').hide();
 
29
        };http:
 
30
        break;
 
31
        case 'SHOW': {
 
32
          createJsKitCommentCookie('SHOW');
 
33
          $('.js-kit-comments').show();
 
34
        };
 
35
        break;
 
36
        default: {
 
37
        };
 
38
      }
 
39
    }
 
40
  );
 
41
 
 
42
  // js-kit comments control configuration:
 
43
  function createJsKitCommentCookie(value) {
 
44
    var name = 'default_comments_control_behavior';
 
45
    var date = new Date(2038, 0, 1);
 
46
    date.setTime(date.getTime());
 
47
    var expires = "; expires="+date.toGMTString();
 
48
    document.cookie = name+"="+value+expires+"; path=/";
 
49
  }
 
50
 
 
51
  function readJsKitCommentCookie() {
 
52
    var name = 'default_comments_control_behavior';
 
53
    var nameEQ = name + "=";
 
54
    var ca = document.cookie.split(';');
 
55
    for(var i=0;i < ca.length;i++) {
 
56
      var c = ca[i];
 
57
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
 
58
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 
59
    }
 
60
    return null;
 
61
  }
 
62
  var config_value = readJsKitCommentCookie();
 
63
  switch (config_value) {
 
64
    case 'HIDE': {
 
65
      $("#comments_control").val('HIDE');
 
66
    };
 
67
    break;
 
68
    case 'SHOW': {
 
69
      $("#comments_control").val('SHOW');
 
70
    };
 
71
    break;
 
72
    default: {
 
73
      createJsKitCommentCookie('SHOW');
 
74
    };
 
75
  }
 
76
  // ugly way to create an onload that is called *after* js-kit.com's JS has finished initializing
 
77
  // even in WebKit(Safari/Chrome/...), because they use setTimeout as well!
 
78
  setTimeout(function(){$("#comments_control").change();},100);
 
79
});
 
80