Alcuinus

e-shuushuu coments toggle v2

Apr 1st, 2011
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           My e-shuushuu Script
  3. // @description    A brief description of your script
  4. // @author         Your Name
  5. // @include        http://e-shuushuu.net*
  6. // @version        1.0
  7. // ==/UserScript==
  8.  
  9. var anim = {};
  10.  
  11. $(document).ready(function () {
  12.  
  13.  
  14.     dButtonGradientInactive = "-webkit-gradient( " + '\n' +
  15. "      linear,                       " + '\n' +
  16. "      left bottom,                  " + '\n' +
  17. "      left top,                     " + '\n' +
  18. "      color-stop(0.45, #444),    " + '\n' +
  19. "      color-stop(0.95, #666),        " + '\n' +
  20. "      color-stop(1, #999)        " + '\n' +
  21. "    )";
  22.  
  23.     dButtonGradientClick = "-webkit-gradient( " + '\n' +
  24. "      linear,                       " + '\n' +
  25. "      left bottom,                  " + '\n' +
  26. "      left top,                     " + '\n' +
  27. "      color-stop(0, #222),    " + '\n' +
  28. "      color-stop(0.05, #333),    " + '\n' +
  29. "      color-stop(0.45, #333),    " + '\n' +
  30. "      color-stop(0.95, #555),        " + '\n' +
  31. "      color-stop(1, #111)        " + '\n' +
  32. "    )";
  33.  
  34.     dButtonGradientActive = "-webkit-gradient( " + '\n' +
  35. "      linear,                       " + '\n' +
  36. "      left bottom,                  " + '\n' +
  37. "      left top,                     " + '\n' +
  38. "      color-stop(0, #fd0),        " + '\n' +
  39. "      color-stop(0.05, #f90),    " + '\n' +
  40. "      color-stop(0.95, #f70),        " + '\n' +
  41. "      color-stop(1, #a30)        " + '\n' +
  42. "    )";
  43.  
  44.     dButtonGradientHover = "-webkit-gradient( " + '\n' +
  45. "      linear,                       " + '\n' +
  46. "      left bottom,                  " + '\n' +
  47. "      left top,                     " + '\n' +
  48. "      color-stop(0.45, #555),    " + '\n' +
  49. "      color-stop(0.95, #777),        " + '\n' +
  50. "      color-stop(1, #999)        " + '\n' +
  51. "    )";
  52.  
  53.  
  54.     var rad = 4;
  55.     // Style rules. note that everything is prefixed with
  56.     // a "d" for dynamic.  This is to avoid conflicts.
  57.     var dStyleSheet = document.createElement("style");
  58.     dStyleSheet.setAttribute("type", "text/css");
  59.     var dTxt =
  60.     "#dToggle {                       " + '\n' +
  61.     "    position : fixed;            " + '\n' +
  62.     "    right : 2px;                 " + '\n' +
  63.     "    width : 163px;                 " + '\n' +
  64.     "    top : 0px;                   " + '\n' +
  65.     "    font-family : Arial,Helvetica,sans-serif;                   " + '\n' +
  66.     "    font-size: 100%;                   " + '\n' +
  67.     "    line-height: 12px;                   " + '\n' +
  68.     "}                                " + '\n' +
  69.     "#dBackground {                   " + '\n' +
  70.     "    background-color : #000;     " + '\n' +
  71.     "    border : 1px solid black;    " + '\n' +
  72.     "    opacity : 0.8;               " + '\n' +
  73.     "    position : absolute;         " + '\n' +
  74.     "    width : 100%;                " + '\n' +
  75.     "    height : 100%;               " + '\n' +
  76.     "}                                " + '\n' +
  77.     "#dToggle label {                 " + '\n' +
  78.     "    display : inline-block;             " + '\n' +
  79.     "    background-image : " + dButtonGradientInactive + ";" + '\n' +
  80.     "    color : #fff;                " + '\n' +
  81.     "    border : 1px outset  #444;     " + '\n' +
  82.     "    padding : 10px;                " + '\n' +
  83.     "    margin : 0px;                " + '\n' +
  84.     "    width : 80px;                " + '\n' +
  85.     "    border-radius : " + rad + "px 0px 0px " + rad + "px;                " + '\n' +
  86.     "    cursor : pointer;                " + '\n' +
  87.     "}                                " + '\n' +
  88.     "#dToggle .dItem {                " + '\n' +
  89.     "    position : relative;         " + '\n' +
  90.     "    z-index:1;                   " + '\n' +
  91.     "    padding : 0px 10px 0px 10px;         " + '\n' +
  92.     "}                                " + '\n' +
  93.     "#dToggle input {                 " + '\n' +
  94.     "    display : inline-block;             " + '\n' +
  95.     "    background-image : " + dButtonGradientInactive + ";" + '\n' +
  96.     "    color : #fff;                " + '\n' +
  97.     "    border : 1px outset  #444;     " + '\n' +
  98.     "    border-left-color : #333;     " + '\n' +
  99.     "    width : 42px;                " + '\n' +
  100.     "    text-align : left;                " + '\n' +
  101.     "    padding : 8px;                " + '\n' +
  102.     "    margin : 0px 0px 0px -5px;                " + '\n' +
  103.     "    border-radius : 0px " + rad + "px " + rad + "px 0px;                " + '\n' +
  104.     "    float : right;                " + '\n' +
  105.     "}                                " + '\n' +
  106.     "";
  107.     dStyleSheet.appendChild(document.createTextNode(dTxt));
  108.     $("head").append(dStyleSheet);
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.     function ToggleName(id) {
  117.         if (CheckToggle(id)) {
  118.             $(id).attr("value", "Off");
  119.             $(id).css("background-image", dButtonGradientInactive);
  120.             $(id).css("border-style", "outset");
  121.         } else {
  122.             $(id).attr("value", "On");
  123.             $(id).css("background-image", dButtonGradientActive);
  124.             $(id).css("border-style", "inset");
  125.         }
  126.     }
  127.  
  128.     function CheckToggle(id) {
  129.         var text = $(id).attr("value");
  130.         if (text == "On") {
  131.             return true;
  132.         } else {
  133.             return false;
  134.         }
  135.     }
  136.  
  137.     $("body").append(
  138.         '<div id="dToggle">                                                 ' +
  139.         '    <div id="dBackground"></div>                                   ' +
  140.         '    <div class="dItem">  ' +
  141.         '        <label name="#toggleComments"  handles=".post_block">                               ' +
  142.         '            Comments:                                              ' +
  143.         '        </label>                                                   ' +
  144.         '        <input id="toggleComments"  handles=".post_block" type="button" value="Off" />     ' +
  145.         '    </div>                                                         ' +
  146.         '    <div class="dItem">  ' +
  147.         '        <label name="#toggleDescriptions" handles="#banner_image">                               ' +
  148.         '            Descriptions Descriptions Descriptions Descriptions Descriptions Descriptions Descriptions:                                              ' +
  149.         '        </label>                                                   ' +
  150.         '        <input id="toggleDescriptions"  handles="#banner_image" type="button" value="Off" />     ' +
  151.         '    </div>                                                         ' +
  152.         '</div>                                                             '
  153.     )
  154.  
  155.     $("#dToggle label").click(function () {
  156.         handles = $(this).attr("handles").split(",");
  157.         for (i = 0; i < handles.length; i++) {
  158.             $(handles[i]).slideToggle("slow");
  159.         }
  160.         ToggleName($(this).attr("name"))
  161.     }).mousedown(function () {
  162.         $(this).css("background-image", dButtonGradientClick);
  163.         $(this).css("border-style", "inset");
  164.     }).mouseup(function () {
  165.         $(this).css("background-image", dButtonGradientHover);
  166.         $(this).css("border-style", "outset");
  167.     }).mouseenter(function () {
  168.         $(this).css("background-image", dButtonGradientHover);
  169.     }).mouseleave(function () {
  170.         $(this).css("background-image", dButtonGradientInactive);
  171.         $(this).css("border-style", "outset");
  172.     });
  173.  
  174.     $(".dItem:first").css("padding", "10px 10px 0px 10px");
  175.     $(".dItem:last").css("padding", "0px 10px 10px 10px");
  176.     $(".dItem input").each(function(){
  177.       $(this).height($(this).parent().height());
  178.     });
  179. });
Advertisement
Add Comment
Please, Sign In to add comment