-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAdminBar.js
executable file
·113 lines (80 loc) · 2.23 KB
/
AdminBar.js
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
jQuery(document).ready(function($) {
//prepare all js-enhanced functions
$('body').addClass('adminbar-loaded');
var $adminbar = $('#adminbar');
var $li = $adminbar.find('li');
var $links = $adminbar.find('a').not('admin');
var $modalLinks = $adminbar.find('a.modal');
var $browse = $adminbar.find('.browse a');
var $modal = $('<div id="ab-modal"></div>').data('active', 'browse');
var clicked = false;
$links.click(function(){
setActive($(this));
});
$modalLinks.click(function(){
if(!clicked) {
$modal.prependTo('body');
};
if ($adminbar.data('active') == $(this).attr('class')) {
slideUp(true);
} else {
$modal.addClass('loading').find('iframe').remove();
slideDown($(this));
// We "preload" this so it should be shown pretty fast after animation
$iframe = $('<iframe name="ab_modal_iframe" id="ab_modal_iframe" frameborder="0" src="'+ $(this).attr('href') +'"></iframe>')
.css('width', '100%')
.css('height', 0)
.appendTo($modal);
$adminbar.data('active', $(this).attr('class'));
};
return false;
});
$browse.click(function(){
slideUp(true);
return false;
});
function setActive(link) {
$li.removeClass('active');
link.parent().addClass('active');
}
function slideDown(link) {
modalHeight = $(window).height() - 40;
$modal.animate({
height: modalHeight + 'px'
},
// Animation time
300,
// After slide is done
function(){
$iframe.hide().css('height', $modal.height()).show();
});
document.body.style.overflow='hidden';
};
function slideUp(clean) {
if (clean) {
$adminbar.data('active', 'browse');
$modal.find('iframe').attr('src', '').remove();
setActive($browse);
}
$adminbar.data('active', 'browse');
$modal.removeClass('loading').stop().animate({
height: '0px'
}, 300, function(){
$modal.addClass('loading');
});
document.body.style.overflow='auto';
};
$(window).resize(function() {
if ($modal.height() > 1) {
modalHeight = $(window).height() - 40;
$modal.stop().animate({
height: modalHeight + 'px'
},
// Animation time
100, function(){
$iframe.css('height', $modal.height());
});
}
});
$("#ab-pagesaved").delay(3000).slideUp("normal");
});