root / snf-cyclades-app / synnefo / helpdesk / static / js / common.js @ e620ca07
History | View | Annotate | Download (2.2 kB)
1 |
$(document).ready(function(){ $("input").focus(); }) |
---|---|
2 |
|
3 |
$(document).ready(function(){ |
4 |
|
5 |
|
6 |
// fix sub nav on scroll
|
7 |
var $win = $(window) |
8 |
, $nav = $('.subnav') |
9 |
, navTop = $('.subnav').length && $('.subnav').offset().top |
10 |
, isFixed = 0
|
11 |
|
12 |
function processScroll() { |
13 |
var i, scrollTop = $win.scrollTop() |
14 |
if (scrollTop >= navTop && !isFixed) {
|
15 |
isFixed = 1
|
16 |
$nav.addClass('subnav-fixed') |
17 |
} else if (scrollTop <= navTop && isFixed) { |
18 |
isFixed = 0
|
19 |
$nav.removeClass('subnav-fixed') |
20 |
} |
21 |
} |
22 |
|
23 |
processScroll(); |
24 |
|
25 |
// hack sad times - holdover until rewrite for 2.1
|
26 |
$nav.on('click', function () { |
27 |
if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop()) }, 10) |
28 |
}) |
29 |
|
30 |
$win.on('scroll', processScroll) |
31 |
|
32 |
|
33 |
|
34 |
// hide/show expand/collapse
|
35 |
|
36 |
$('.subnav .dropdown-menu a').click(function(){ |
37 |
$('.info-block-content, .show-hide-all').show(); |
38 |
}) |
39 |
|
40 |
|
41 |
|
42 |
var txt_all = ['+ Expand all','- Collapse all']; |
43 |
|
44 |
|
45 |
$('.show-hide-all span').html(txt_all[0]); |
46 |
|
47 |
|
48 |
$('.show-hide-all').click(function(){ |
49 |
var badgeAll = $(this).children('span'); |
50 |
badgeAll.toggleClass('open');
|
51 |
var tabs = $(this).parent('.info-block').find('.object-details-content') |
52 |
|
53 |
console.info(tabs); |
54 |
if (badgeAll.hasClass('open')){ |
55 |
badgeAll.html( txt_all[1]);
|
56 |
tabs.each(function() {
|
57 |
$(this).show(); |
58 |
$(this).siblings('h4').addClass('expanded'); |
59 |
}); |
60 |
|
61 |
|
62 |
} else {
|
63 |
badgeAll.html( txt_all[0]);
|
64 |
tabs.each(function() {
|
65 |
$(this).hide(); |
66 |
$(this).siblings('h4').removeClass('expanded'); |
67 |
|
68 |
}); |
69 |
} |
70 |
|
71 |
|
72 |
}); |
73 |
|
74 |
|
75 |
|
76 |
$('.object-details h4').click(function(){ |
77 |
|
78 |
$(this).siblings('.object-details-content').toggle(); |
79 |
$(this).toggleClass('expanded'); |
80 |
|
81 |
}); |
82 |
|
83 |
|
84 |
$('.info-block h3').click(function(){ |
85 |
$(this).next('.info-block-content').toggle(); |
86 |
$(this).prev('.show-hide-all').toggle(); |
87 |
}); |
88 |
|
89 |
$('.search-query').typeahead() |
90 |
|
91 |
$('.search-query').keyup(function(){ |
92 |
var t = $(".search-query").data("typeahead"); |
93 |
var a = t.lookup().query;
|
94 |
$.ajax({
|
95 |
url:'/helpdesk/api/users/?prefix='+a, |
96 |
dataType:'json', |
97 |
success:function(d){ |
98 |
t.source = d; |
99 |
} |
100 |
}) |
101 |
}) |
102 |
|
103 |
|
104 |
|
105 |
}) |
106 |
|