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