Show More
@@ -1,218 +1,221 b'' | |||
|
1 | 1 | /** |
|
2 | 2 | RhodeCode JS Files |
|
3 | 3 | **/ |
|
4 | 4 | |
|
5 | 5 | if (typeof console == "undefined" || typeof console.log == "undefined"){ |
|
6 | 6 | console = { log: function() {} } |
|
7 | 7 | } |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | function str_repeat(i, m) { |
|
11 | 11 | for (var o = []; m > 0; o[--m] = i); |
|
12 | 12 | return o.join(''); |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | 15 | /** |
|
16 | 16 | * INJECT .format function into String |
|
17 | 17 | * Usage: "My name is {0} {1}".format("Johny","Bravo") |
|
18 | 18 | * Return "My name is Johny Bravo" |
|
19 | 19 | * Inspired by https://gist.github.com/1049426 |
|
20 | 20 | */ |
|
21 | 21 | String.prototype.format = function() { |
|
22 | 22 | |
|
23 | 23 | function format() { |
|
24 | 24 | var str = this; |
|
25 | 25 | var len = arguments.length+1; |
|
26 | 26 | var safe = undefined; |
|
27 | 27 | var arg = undefined; |
|
28 | 28 | |
|
29 | 29 | // For each {0} {1} {n...} replace with the argument in that position. If |
|
30 | 30 | // the argument is an object or an array it will be stringified to JSON. |
|
31 | 31 | for (var i=0; i < len; arg = arguments[i++]) { |
|
32 | 32 | safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; |
|
33 | 33 | str = str.replace(RegExp('\\{'+(i-1)+'\\}', 'g'), safe); |
|
34 | 34 | } |
|
35 | 35 | return str; |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | // Save a reference of what may already exist under the property native. |
|
39 | 39 | // Allows for doing something like: if("".format.native) { /* use native */ } |
|
40 | 40 | format.native = String.prototype.format; |
|
41 | 41 | |
|
42 | 42 | // Replace the prototype property |
|
43 | 43 | return format; |
|
44 | 44 | |
|
45 | 45 | }(); |
|
46 | 46 | |
|
47 | 47 | |
|
48 | 48 | /** |
|
49 | 49 | * SmartColorGenerator |
|
50 | 50 | * |
|
51 | 51 | *usage:: |
|
52 | 52 | * var CG = new ColorGenerator(); |
|
53 | 53 | * var col = CG.getColor(key); //returns array of RGB |
|
54 | 54 | * 'rgb({0})'.format(col.join(',') |
|
55 | 55 | * |
|
56 | 56 | * @returns {ColorGenerator} |
|
57 | 57 | */ |
|
58 | 58 | function ColorGenerator(){ |
|
59 | 59 | this.GOLDEN_RATIO = 0.618033988749895; |
|
60 | 60 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random |
|
61 | 61 | this.HSV_1 = 0.75;//saturation |
|
62 | 62 | this.HSV_2 = 0.95; |
|
63 | 63 | this.color; |
|
64 | 64 | this.cacheColorMap = {}; |
|
65 | 65 | }; |
|
66 | 66 | |
|
67 | 67 | ColorGenerator.prototype = { |
|
68 | 68 | getColor:function(key){ |
|
69 | 69 | if(this.cacheColorMap[key] !== undefined){ |
|
70 | 70 | return this.cacheColorMap[key]; |
|
71 | 71 | } |
|
72 | 72 | else{ |
|
73 | 73 | this.cacheColorMap[key] = this.generateColor(); |
|
74 | 74 | return this.cacheColorMap[key]; |
|
75 | 75 | } |
|
76 | 76 | }, |
|
77 | 77 | _hsvToRgb:function(h,s,v){ |
|
78 | 78 | if (s == 0.0) |
|
79 | 79 | return [v, v, v]; |
|
80 | 80 | i = parseInt(h * 6.0) |
|
81 | 81 | f = (h * 6.0) - i |
|
82 | 82 | p = v * (1.0 - s) |
|
83 | 83 | q = v * (1.0 - s * f) |
|
84 | 84 | t = v * (1.0 - s * (1.0 - f)) |
|
85 | 85 | i = i % 6 |
|
86 | 86 | if (i == 0) |
|
87 | 87 | return [v, t, p] |
|
88 | 88 | if (i == 1) |
|
89 | 89 | return [q, v, p] |
|
90 | 90 | if (i == 2) |
|
91 | 91 | return [p, v, t] |
|
92 | 92 | if (i == 3) |
|
93 | 93 | return [p, q, v] |
|
94 | 94 | if (i == 4) |
|
95 | 95 | return [t, p, v] |
|
96 | 96 | if (i == 5) |
|
97 | 97 | return [v, p, q] |
|
98 | 98 | }, |
|
99 | 99 | generateColor:function(){ |
|
100 | 100 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; |
|
101 | 101 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; |
|
102 | 102 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] |
|
103 | 103 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); |
|
104 | 104 | function toRgb(v){ |
|
105 | 105 | return ""+parseInt(v*256) |
|
106 | 106 | } |
|
107 | 107 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; |
|
108 | 108 | |
|
109 | 109 | } |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | |
|
116 | 116 | /** |
|
117 | 117 | * GLOBAL YUI Shortcuts |
|
118 | 118 | */ |
|
119 | 119 | var YUC = YAHOO.util.Connect; |
|
120 | 120 | var YUD = YAHOO.util.Dom; |
|
121 | 121 | var YUE = YAHOO.util.Event; |
|
122 | 122 | var YUQ = YAHOO.util.Selector.query; |
|
123 | 123 | |
|
124 | 124 | // defines if push state is enabled for this browser ? |
|
125 | 125 | var push_state_enabled = Boolean( |
|
126 | 126 | window.history && window.history.pushState && window.history.replaceState |
|
127 | 127 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ |
|
128 | 128 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) |
|
129 | 129 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ |
|
130 | 130 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) |
|
131 | 131 | ) |
|
132 | 132 | ) |
|
133 | 133 | |
|
134 | 134 | /** |
|
135 | 135 | * Partial Ajax Implementation |
|
136 | 136 | * |
|
137 | 137 | * @param url: defines url to make partial request |
|
138 | 138 | * @param container: defines id of container to input partial result |
|
139 | 139 | * @param s_call: success callback function that takes o as arg |
|
140 | 140 | * o.tId |
|
141 | 141 | * o.status |
|
142 | 142 | * o.statusText |
|
143 | 143 | * o.getResponseHeader[ ] |
|
144 | 144 | * o.getAllResponseHeaders |
|
145 | 145 | * o.responseText |
|
146 | 146 | * o.responseXML |
|
147 | 147 | * o.argument |
|
148 | 148 | * @param f_call: failure callback |
|
149 | 149 | * @param args arguments |
|
150 | 150 | */ |
|
151 | 151 | function ypjax(url,container,s_call,f_call,args){ |
|
152 | 152 | var method='GET'; |
|
153 | 153 | if(args===undefined){ |
|
154 | 154 | args=null; |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | // Set special header for partial ajax == HTTP_X_PARTIAL_XHR |
|
158 | 158 | YUC.initHeader('X-PARTIAL-XHR',true); |
|
159 | 159 | |
|
160 | 160 | // wrapper of passed callback |
|
161 | 161 | var s_wrapper = (function(o){ |
|
162 | 162 | return function(o){ |
|
163 | 163 | YUD.get(container).innerHTML=o.responseText; |
|
164 | 164 | YUD.setStyle(container,'opacity','1.0'); |
|
165 | 165 | //execute the given original callback |
|
166 | 166 | if (s_call !== undefined){ |
|
167 | 167 | s_call(o); |
|
168 | 168 | } |
|
169 | 169 | } |
|
170 | 170 | })() |
|
171 | 171 | YUD.setStyle(container,'opacity','0.3'); |
|
172 | 172 | YUC.asyncRequest(method,url,{ |
|
173 | 173 | success:s_wrapper, |
|
174 | 174 | failure:function(o){ |
|
175 | console.log(o) | |
|
175 | console.log(o); | |
|
176 | YUD.get(container).innerHTML='ERROR'; | |
|
177 | YUD.setStyle(container,'opacity','1.0'); | |
|
178 | YUD.setStyle(container,'color','red'); | |
|
176 | 179 | } |
|
177 | 180 | },args); |
|
178 | 181 | |
|
179 | 182 | } |
|
180 | 183 | |
|
181 | 184 | /** |
|
182 | 185 | * tooltip activate |
|
183 | 186 | */ |
|
184 | 187 | var tooltip_activate = function(){ |
|
185 | 188 | function toolTipsId(){ |
|
186 | 189 | var ids = []; |
|
187 | 190 | var tts = YUQ('.tooltip'); |
|
188 | 191 | for (var i = 0; i < tts.length; i++) { |
|
189 | 192 | // if element doesn't not have and id |
|
190 | 193 | // autogenerate one for tooltip |
|
191 | 194 | if (!tts[i].id){ |
|
192 | 195 | tts[i].id='tt'+((i*100)+tts.length); |
|
193 | 196 | } |
|
194 | 197 | ids.push(tts[i].id); |
|
195 | 198 | } |
|
196 | 199 | return ids |
|
197 | 200 | }; |
|
198 | 201 | var myToolTips = new YAHOO.widget.Tooltip("tooltip", { |
|
199 | 202 | context: [[toolTipsId()],"tl","bl",null,[0,5]], |
|
200 | 203 | monitorresize:false, |
|
201 | 204 | xyoffset :[0,0], |
|
202 | 205 | autodismissdelay:300000, |
|
203 | 206 | hidedelay:5, |
|
204 | 207 | showdelay:20, |
|
205 | 208 | }); |
|
206 | 209 | } |
|
207 | 210 | |
|
208 | 211 | /** |
|
209 | 212 | * show more |
|
210 | 213 | */ |
|
211 | 214 | var show_more_event = function(){ |
|
212 | 215 | YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){ |
|
213 | 216 | var el = e.target; |
|
214 | 217 | YUD.setStyle(YUD.get(el.id.substring(1)),'display',''); |
|
215 | 218 | YUD.setStyle(el.parentNode,'display','none'); |
|
216 | 219 | }); |
|
217 | 220 | } |
|
218 | 221 |
@@ -1,23 +1,23 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | <li class="qfilter_rs"> |
|
4 | 4 | <input type="text" |
|
5 | 5 | style="border:0" |
|
6 | 6 | value="quick filter..." |
|
7 | 7 | name="filter" size="15" id="q_filter_rs" /> |
|
8 | 8 | </li> |
|
9 | 9 | |
|
10 | 10 | %for repo in c.repos_list: |
|
11 | 11 | |
|
12 | 12 | %if repo['dbrepo']['private']: |
|
13 | 13 | <li> |
|
14 |
<img src="${h.url( |
|
|
14 | <img src="${h.url('/images/icons/lock.png')}" alt="${_('Private repository')}" class="repo_switcher_type"/> | |
|
15 | 15 | ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="repo_name %s" % repo['dbrepo']['repo_type'])} |
|
16 | 16 | </li> |
|
17 | 17 | %else: |
|
18 | 18 | <li> |
|
19 |
<img src="${h.url( |
|
|
19 | <img src="${h.url('/images/icons/lock_open.png')}" alt="${_('Public repository')}" class="repo_switcher_type" /> | |
|
20 | 20 | ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="repo_name %s" % repo['dbrepo']['repo_type'])} |
|
21 | 21 | </li> |
|
22 | 22 | %endif |
|
23 | 23 | %endfor No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now