File: CategoriesView.html

package info (click to toggle)
software-center 2.0.7debian7
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,404 kB
  • ctags: 1,229
  • sloc: python: 7,922; xml: 317; makefile: 17; sh: 14
file content (215 lines) | stat: -rw-r--r-- 6,639 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" $text_direction>
<head>
 <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
 <title></title>
 <script type="text/javascript">
  function changeTitle(title) { 
    document.title = title; 
  }
  function show_header() {
    document.getElementById("header").style.display = 'block';
  }
  function hide_header() {
    document.getElementById("header").style.display = 'none';
  }
  function addCategory(name, untranslated_name, img) {
    // handled featured apps special
    if (untranslated_name == "Featured Applications") {
      addFeaturedCategory(name);
      return;
    }
    oT = document.getElementsByTagName("table")[0];
    Tr = document.getElementsByTagName("tr")[0];
    newTd = document.createElement("td");
    newTd.setAttribute("tabindex", 0)
    newTd.className = "category_td";
    // we need a <p> around the img so that we can align it
    newTextAroundImg = document.createElement("p");
    newImg = document.createElement("img");
    newImg.src = img;
    newImg.setAttribute("width", ${icon_size});
    newImg.setAttribute("height", ${icon_size});
    newImg.className = "no_drag";
    newTextAroundImg.appendChild(newImg);
    newText = document.createElement("p");
    newText.align = "center";
    click_cb = 'changeTitle("call:on_category_clicked:' + name + '");';
    newTd.setAttribute('onclick', click_cb);
    key_cb = 'if (event.which == 13) { changeTitle("call:on_category_clicked:' + name + '"); };'
    newTd.setAttribute('onkeydown', key_cb);
    newTd.id = "Category_"+ parseInt(categoryCount)
    newText.appendChild(document.createTextNode(name))
    newTd.appendChild(newTextAroundImg);
    newTd.appendChild(newText);
    Tr.appendChild(newTd);
    categoryCount += 1;
  }
  function addFeaturedCategory(name){
    var link = document.getElementById("featured_link");
    text = document.createTextNode(name)
    document.getElementById("featured_span").appendChild(text)
    link.setAttribute('onclick', 'changeTitle("call:on_category_clicked:' + name + '");');
  }
  function currently_displayed_rows() {
      var cat_inc_count = 1, current_offset_left = 0, check_offset_left;
      while (true) {
          check_offset_left = document.getElementById("Category_" + cat_inc_count).offsetLeft;
          if (check_offset_left < current_offset_left) {
              break;
          } else {
              current_offset_left = check_offset_left;
              cat_inc_count += 1;
          }
      }
      return cat_inc_count;
  }
  
  function onKey(ev) {
    if (ev) {
      switch (ev.keyCode) {
        // left
        case 37:
          category_delta = -1;
          break;    
        // up
        case 38:
          category_delta = -currently_displayed_rows();
          break;    
        // right
        case 39:
          category_delta = 1;
          break;   
        // down
        case 40:
          category_delta = currently_displayed_rows();
          break;   
        // tab
        case 9:
          category_delta = 1;
          break;   
        default:
          category_delta = 0;
      } 
      // HACK: the very first key-stroke should always focus the first element
      if (currentCategory  == -1)
         category_delta = 1;
      // ensure that we go not over the borders				 
      if ((currentCategory + category_delta) > categoryCount ||
          (currentCategory + category_delta) < 0)
          category_delta = 0;
      var potential_new_category = "Category_" + (parseInt(currentCategory) + category_delta);
      var potential_selected = document.getElementById(potential_new_category);
      if (potential_selected) {
          currentCategory += category_delta;
          potential_selected.focus();
      } 
    }
  }  
  // global variables to keep track of the cursor
  var categoryCount = 0;
  var currentCategory = -1;
  // global key handler for the arrow keys
  document.onkeyup = onKey;
 </script>
  <style type="text/css">
    body {
      padding: 16px;
      margin:0;
      color:#000;
      font-family:${font_family};
      font-size:${font_size};
      font-weight:${font_weight};
      font-style:${font_style};
      background:#fff url('file:${featured_applications_image}') repeat-x;
      border:4px solid white;
    }
    h1{ float:left; font-weight:normal; color:#333;padding:0; margin:0; }
    h2 {
      color: #4a4a4a;
      font-weight:normal;
      font-size:1.2em;      
      padding:0.2em  0.8em;
      margin: .2em 0;
      background-color:#dad7d3;
       -webkit-border-top-left-radius: 5px;
       -webkit-border-top-right-radius: 5px;
    }
    h2 img{
      vertical-align:middle;
    }
    #basket{
        float:right;
        margin-bottom:0.6em;
     }
    #featured_link{
      clear:left;
      margin: 0.3em 0 0 0;
      -khtml-user-drag:none;
    }
    a.button{ 
      font-size:1.2em;
      background:url('file:${button_background_right}') top right no-repeat scroll;
      color:#fff;
      text-decoration:none;
      display:block;
      float:left;
      clear:left;
      height:38px;
      padding-right:26px;

    }
    a.button span{
      background: url('file:${button_background_left}') no-repeat;
      padding:5px 0 5px 15px;
      line-height:28px;
      display:block;
    }
    #departments{
        clear:both;
        border-radius: 5px;
        background-color:#f7f7f7;
        -webkit-box-shadow: rgba(0, 0, 0, 0.2) -1px 1px 4px;
    }
    
 /* debug border */
 /* .category_td {border-width:1px;border-style:solid;} */
 /* fixed width does not work, it does not ellipsis but overflows the box */
 /* .category_td {padding:8px; margin:8px; width:6em; display:inline-block; text-overflow: ellipsis;} */

    .category_td {
      padding: 0 8px;
      display:inline-block;
      text-overflow: ellipsis;
      vertical-align: top;
      width: 8em !important;
    }
    .category_td:hover {cursor: pointer; }
   
    .category_td p { font-size:90%; text-align:center; }
    .no_drag { -khtml-user-drag:none; }
    
    /* make images not draggable in the categories view */
    img { -khtml-user-drag:none; }
    
  
 </style>
 </head>

<body>
  <div id="header">
    <h1>$ubuntu_software_center</h1>
    <img src="${basket_image}" id="basket"/>
    <a href="#" id="featured_link" class="button">
      <span id="featured_span"></span>
    </a>
  </div>
  <div id="departments">
    <h2>$header</h2>
    <table>
      <tr></tr>
    </table>
  </div>
</body>
</html>