##// END OF EJS Templates
new tooltip implementation...
marcink -
r2971:2bfcec6a beta
parent child Browse files
Show More
@@ -436,6 +436,9 b' def make_map(config):'
436 controller='changeset', action='raw_changeset',
436 controller='changeset', action='raw_changeset',
437 revision='tip', conditions=dict(function=check_repo))
437 revision='tip', conditions=dict(function=check_repo))
438
438
439 rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}',
440 controller='changeset', action='changeset_info')
441
439 rmap.connect('compare_url',
442 rmap.connect('compare_url',
440 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
443 '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}',
441 controller='compare', action='index',
444 controller='compare', action='index',
@@ -26,7 +26,7 b''
26 import logging
26 import logging
27 import traceback
27 import traceback
28 from collections import defaultdict
28 from collections import defaultdict
29 from webob.exc import HTTPForbidden
29 from webob.exc import HTTPForbidden, HTTPBadRequest
30
30
31 from pylons import tmpl_context as c, url, request, response
31 from pylons import tmpl_context as c, url, request, response
32 from pylons.i18n.translation import _
32 from pylons.i18n.translation import _
@@ -445,3 +445,10 b' class ChangesetController(BaseRepoContro'
445 return True
445 return True
446 else:
446 else:
447 raise HTTPForbidden()
447 raise HTTPForbidden()
448
449 @jsonify
450 def changeset_info(self, repo_name, revision):
451 if request.is_xhr or 1:
452 return c.rhodecode_repo.get_changeset(revision)
453 else:
454 raise HTTPBadRequest()
@@ -532,7 +532,8 b' def action_parser(user_log, feed=False, '
532 title = _('Changeset not found')
532 title = _('Changeset not found')
533 if parse_cs:
533 if parse_cs:
534 return link_to(lbl, _url, title=title, class_='tooltip')
534 return link_to(lbl, _url, title=title, class_='tooltip')
535 return link_to(lbl, _url, raw_id=rev.raw_id, class_='journal-cs')
535 return link_to(lbl, _url, raw_id=rev.raw_id, repo_name=repo_name,
536 class_='lazy-cs')
536
537
537 revs = []
538 revs = []
538 if len(filter(lambda v: v != '', revs_ids)) > 0:
539 if len(filter(lambda v: v != '', revs_ids)) > 0:
@@ -372,6 +372,15 b' class BaseChangeset(object):'
372 def __eq__(self, other):
372 def __eq__(self, other):
373 return self.raw_id == other.raw_id
373 return self.raw_id == other.raw_id
374
374
375 def __json__(self):
376 return dict(
377 short_id=self.short_id,
378 raw_id=self.raw_id,
379 message=self.message,
380 date=self.date,
381 author=self.author,
382 )
383
375 @LazyProperty
384 @LazyProperty
376 def last(self):
385 def last(self):
377 if self.repository is None:
386 if self.repository is None:
@@ -3001,22 +3001,24 b' table.code-browser .submodule-dir {'
3001 z-index: 2;
3001 z-index: 2;
3002 }
3002 }
3003
3003
3004 .yui-tt {
3004 #tip-box {
3005 visibility: hidden;
3006 position: absolute;
3005 position: absolute;
3007 color: #666;
3006
3008 background-color: #FFF;
3007 background-color: #FFF;
3009 border: 2px solid #003367;
3008 border: 2px solid #003367;
3010 font: 100% sans-serif;
3009 font: 100% sans-serif;
3011 width: auto;
3010 width: auto;
3012 opacity: 1px;
3011 opacity: 1px;
3013 padding: 8px;
3012 padding: 8px;
3013
3014 white-space: pre-wrap;
3014 white-space: pre-wrap;
3015 -webkit-border-radius: 8px 8px 8px 8px;
3015 -webkit-border-radius: 8px 8px 8px 8px;
3016 -khtml-border-radius: 8px 8px 8px 8px;
3016 -khtml-border-radius: 8px 8px 8px 8px;
3017 -moz-border-radius: 8px 8px 8px 8px;
3017 -moz-border-radius: 8px 8px 8px 8px;
3018 border-radius: 8px 8px 8px 8px;
3018 border-radius: 8px 8px 8px 8px;
3019 box-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
3019 box-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
3020 -moz-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
3021 -webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
3020 }
3022 }
3021
3023
3022 .mentions-container{
3024 .mentions-container{
@@ -250,6 +250,24 b' function ypjax(url,container,s_call,f_ca'
250
250
251 };
251 };
252
252
253 var ajaxGET = function(url,success) {
254 // Set special header for ajax == HTTP_X_PARTIAL_XHR
255 YUC.initHeader('X-PARTIAL-XHR',true);
256
257 var sUrl = url;
258 var callback = {
259 success: success,
260 failure: function (o) {
261 alert("error");
262 },
263 };
264
265 var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
266 return request;
267 };
268
269
270
253 var ajaxPOST = function(url,postData,success) {
271 var ajaxPOST = function(url,postData,success) {
254 // Set special header for ajax == HTTP_X_PARTIAL_XHR
272 // Set special header for ajax == HTTP_X_PARTIAL_XHR
255 YUC.initHeader('X-PARTIAL-XHR',true);
273 YUC.initHeader('X-PARTIAL-XHR',true);
@@ -282,27 +300,8 b' var ajaxPOST = function(url,postData,suc'
282 * tooltip activate
300 * tooltip activate
283 */
301 */
284 var tooltip_activate = function(){
302 var tooltip_activate = function(){
285 function toolTipsId(){
303 yt = YAHOO.yuitip.main;
286 var ids = [];
304 YUE.onDOMReady(yt.init);
287 var tts = YUQ('.tooltip');
288 for (var i = 0; i < tts.length; i++) {
289 // if element doesn't not have and id
290 // autogenerate one for tooltip
291 if (!tts[i].id){
292 tts[i].id='tt'+((i*100)+tts.length);
293 }
294 ids.push(tts[i].id);
295 }
296 return ids
297 };
298 var myToolTips = new YAHOO.widget.Tooltip("tooltip", {
299 context: [[toolTipsId()],"tl","bl",null,[0,5]],
300 monitorresize:false,
301 xyoffset :[0,0],
302 autodismissdelay:300000,
303 hidedelay:5,
304 showdelay:20,
305 });
306 };
305 };
307
306
308 /**
307 /**
@@ -316,6 +315,140 b' var show_more_event = function(){'
316 });
315 });
317 };
316 };
318
317
318 /**
319 * show changeset tooltip
320 */
321 var show_changeset_tooltip = function(){
322 YUE.on(YUD.getElementsByClassName('lazy-cs'), 'mouseover', function(e){
323 var target = e.currentTarget;
324 var rid = YUD.getAttribute(target,'raw_id');
325 var repo_name = YUD.getAttribute(target,'repo_name');
326 var ttid = 'tt-'+rid;
327 var success = function(o){
328 console.log(o.responseText);
329 var json = JSON.parse(o.responseText);
330 YUD.addClass(target,'tooltip')
331 YUD.setAttribute(target, 'title',json['message']);
332 YAHOO.yuitip.main.show_yuitip(e, target);
333 }
334 if(rid && !YUD.hasClass(target, 'tooltip')){
335 YUD.setAttribute(target,'id',ttid);
336 ajaxGET('/changeset_info/{0}/{1}'.format(repo_name,rid), success)
337 }
338 });
339 };
340
341
342 /**
343 * TOOLTIP IMPL.
344 */
345 YAHOO.namespace('yuitip');
346 YAHOO.yuitip.main = {
347
348 YE: YAHOO.util.Event,
349 Dom: YAHOO.util.Dom,
350 $: YAHOO.util.Dom.get,
351
352 bgColor: '#000',
353 speed: 0.3,
354 opacity: 0.9,
355 offset: [15,15],
356 useAnim: false,
357 maxWidth: 200,
358 add_links: true,
359
360 init: function(){
361 yt._tooltip = '';
362 yt.tipBox = yt.$('tip-box');
363 if(!yt.tipBox){
364 yt.tipBox = document.createElement('div');
365 document.body.appendChild(yt.tipBox);
366 yt.tipBox.id = 'tip-box';
367 }
368
369 yt.Dom.setStyle(yt.tipBox, 'display', 'none');
370 yt.Dom.setStyle(yt.tipBox, 'position', 'absolute');
371 if(yt.maxWidth !== null){
372 yt.Dom.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px');
373 }
374
375 var yuitips = yt.Dom.getElementsByClassName('tooltip');
376
377 if(yt.add_links === true){
378 var links = document.getElementsByTagName('a');
379 var linkLen = links.length;
380 for(i=0;i<linkLen;i++){
381 yuitips.push(links[i]);
382 }
383 }
384
385 var yuiLen = yuitips.length;
386
387 for(i=0;i<yuiLen;i++){
388 yt.YE.on(yuitips[i], 'mouseover', yt.show_yuitip, yuitips[i]);
389 yt.YE.on(yuitips[i], 'mousemove', yt.move_yuitip, yuitips[i]);
390 yt.YE.on(yuitips[i], 'mouseout', yt.close_yuitip, yuitips[i]);
391 }
392 },
393
394 show_yuitip: function(e, el){
395 yt.YE.stopEvent(e);
396 if(el.tagName.toLowerCase() === 'img'){
397 yt.tipText = el.alt ? el.alt : '';
398 } else {
399 yt.tipText = el.title ? el.title : '';
400 }
401
402
403 if(yt.tipText !== ''){
404 // save org title
405 yt._tooltip = yt.tipText;
406 // reset title to not show org tooltips
407 YUD.setAttribute(el, 'title', '');
408
409 var newTipText = yt.tipText.split(' - ');
410 var tipLen = newTipText.length;
411 yt.tipText = '';
412 for(var i=0;i<tipLen;i++){
413 yt.tipText+= newTipText[i]+"<br/>";
414 }
415 yt.tipBox.innerHTML = yt.tipText;
416 yt.Dom.setStyle(yt.tipBox, 'display', 'block');
417 if(yt.useAnim === true){
418 yt.Dom.setStyle(yt.tipBox, 'opacity', '0');
419 var newAnim = new YAHOO.util.Anim(yt.tipBox,
420 {
421 opacity: { to: yt.opacity }
422 }, yt.speed, YAHOO.util.Easing.easeOut
423 );
424 newAnim.animate();
425 }
426 }
427 },
428
429 move_yuitip: function(e, el){
430 yt.YE.stopEvent(e);
431 var movePos = yt.YE.getXY(e);
432 yt.Dom.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px');
433 yt.Dom.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px');
434 },
435
436 close_yuitip: function(e, el){
437 yt.YE.stopEvent(e);
438
439 if(yt.useAnim === true){
440 var newAnim = new YAHOO.util.Anim(yt.tipBox,
441 {
442 opacity: { to: 0 }
443 }, yt.speed, YAHOO.util.Easing.easeOut
444 );
445 newAnim.animate();
446 } else {
447 yt.Dom.setStyle(yt.tipBox, 'display', 'none');
448 }
449 YUD.setAttribute(el,'title', yt._tooltip);
450 }
451 }
319
452
320 /**
453 /**
321 * Quick filter widget
454 * Quick filter widget
@@ -130,6 +130,7 b''
130 YUE.onDOMReady(function(){
130 YUE.onDOMReady(function(){
131 tooltip_activate();
131 tooltip_activate();
132 show_more_event();
132 show_more_event();
133 show_changeset_tooltip();
133
134
134 YUE.on('quick_login_link','click',function(e){
135 YUE.on('quick_login_link','click',function(e){
135 // make sure we don't redirect
136 // make sure we don't redirect
@@ -19,7 +19,11 b''
19 <script type="text/javascript">
19 <script type="text/javascript">
20 YUE.onDOMReady(function(){
20 YUE.onDOMReady(function(){
21 YUE.delegate("followers","click",function(e, matchedEl, container){
21 YUE.delegate("followers","click",function(e, matchedEl, container){
22 ypjax(e.target.href,"followers",function(){show_more_event();tooltip_activate();});
22 ypjax(e.target.href,"followers",function(){
23 show_more_event();
24 tooltip_activate();
25 show_changeset_tooltip();
26 });
23 YUE.preventDefault(e);
27 YUE.preventDefault(e);
24 },'.pager_link');
28 },'.pager_link');
25 });
29 });
@@ -27,7 +27,11 b''
27 <script type="text/javascript">
27 <script type="text/javascript">
28 YUE.onDOMReady(function(){
28 YUE.onDOMReady(function(){
29 YUE.delegate("forks","click",function(e, matchedEl, container){
29 YUE.delegate("forks","click",function(e, matchedEl, container){
30 ypjax(e.target.href,"forks",function(){show_more_event();tooltip_activate();});
30 ypjax(e.target.href,"forks",function(){
31 show_more_event();
32 tooltip_activate();
33 show_changeset_tooltip();
34 });
31 YUE.preventDefault(e);
35 YUE.preventDefault(e);
32 },'.pager_link');
36 },'.pager_link');
33 });
37 });
@@ -153,7 +153,11 b''
153 }
153 }
154
154
155 YUE.on('refresh','click',function(e){
155 YUE.on('refresh','click',function(e){
156 ypjax(e.currentTarget.href,"journal",function(){show_more_event();tooltip_activate();});
156 ypjax(e.currentTarget.href,"journal",function(){
157 show_more_event();
158 tooltip_activate();
159 show_changeset_tooltip();
160 });
157 YUE.preventDefault(e);
161 YUE.preventDefault(e);
158 });
162 });
159
163
@@ -35,7 +35,11 b''
35 <script type="text/javascript">
35 <script type="text/javascript">
36 YUE.onDOMReady(function(){
36 YUE.onDOMReady(function(){
37 YUE.delegate("journal","click",function(e, matchedEl, container){
37 YUE.delegate("journal","click",function(e, matchedEl, container){
38 ypjax(e.target.href,"journal",function(){show_more_event();tooltip_activate();});
38 ypjax(e.target.href,"journal",function(){
39 show_more_event();
40 tooltip_activate();
41 show_changeset_tooltip();
42 });
39 YUE.preventDefault(e);
43 YUE.preventDefault(e);
40 },'.pager_link');
44 },'.pager_link');
41 });
45 });
@@ -28,15 +28,7 b''
28 </li>
28 </li>
29 </ul>
29 </ul>
30 </div>
30 </div>
31 <script type="text/javascript">
31
32 function show_more_event(){
33 YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
34 var el = e.target;
35 YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
36 YUD.setStyle(el.parentNode,'display','none');
37 });
38 }
39 </script>
40 <div id="journal">${c.journal_data}</div>
32 <div id="journal">${c.journal_data}</div>
41 </div>
33 </div>
42
34
General Comments 0
You need to be logged in to leave comments. Login now