2020-05-08 22:11:20 +00:00
|
|
|
function Header(el) {
|
|
|
|
this.el = el;
|
|
|
|
|
2021-01-16 17:06:37 +00:00
|
|
|
var $buttons = this.el.find('#openwebrx-main-buttons').find('[data-toggle-panel]').filter(function(){
|
|
|
|
// ignore buttons when the corresponding panel is not in the DOM
|
|
|
|
return $('#' + $(this).data('toggle-panel'))[0];
|
|
|
|
});
|
|
|
|
|
|
|
|
$buttons.css({display: 'block'}).click(function () {
|
2020-05-08 22:11:20 +00:00
|
|
|
toggle_panel($(this).data('toggle-panel'));
|
|
|
|
});
|
2020-05-08 23:03:43 +00:00
|
|
|
|
|
|
|
this.init_rx_photo();
|
2020-05-10 15:27:46 +00:00
|
|
|
this.download_details();
|
2020-05-08 22:11:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Header.prototype.setDetails = function(details) {
|
|
|
|
this.el.find('#webrx-rx-title').html(details['receiver_name']);
|
2020-12-11 16:53:31 +00:00
|
|
|
this.el.find('#webrx-rx-desc').html(details['receiver_location'] + ' | Loc: ' + details['locator'] + ', ASL: ' + details['receiver_asl'] + ' m');
|
2020-05-08 22:11:20 +00:00
|
|
|
this.el.find('#webrx-rx-photo-title').html(details['photo_title']);
|
|
|
|
this.el.find('#webrx-rx-photo-desc').html(details['photo_desc']);
|
|
|
|
};
|
|
|
|
|
2020-05-08 23:03:43 +00:00
|
|
|
Header.prototype.init_rx_photo = function() {
|
2020-05-10 14:07:14 +00:00
|
|
|
this.rx_photo_state = 0;
|
2020-05-08 23:03:43 +00:00
|
|
|
|
|
|
|
$.extend($.easing, {
|
|
|
|
easeOutCubic:function(x) {
|
|
|
|
return 1 - Math.pow( 1 - x, 3 );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#webrx-top-container').find('.openwebrx-photo-trigger').click(this.toggle_rx_photo.bind(this));
|
|
|
|
};
|
|
|
|
|
|
|
|
Header.prototype.close_rx_photo = function() {
|
|
|
|
this.rx_photo_state = 0;
|
2021-01-15 18:06:00 +00:00
|
|
|
this.el.find('#openwebrx-description-container').removeClass('expanded');
|
2020-05-08 23:03:43 +00:00
|
|
|
this.el.find("#openwebrx-rx-details-arrow-down").show();
|
|
|
|
this.el.find("#openwebrx-rx-details-arrow-up").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
Header.prototype.open_rx_photo = function() {
|
|
|
|
this.rx_photo_state = 1;
|
2021-01-15 18:06:00 +00:00
|
|
|
this.el.find('#openwebrx-description-container').addClass('expanded');
|
2020-05-08 23:03:43 +00:00
|
|
|
this.el.find("#openwebrx-rx-details-arrow-down").hide();
|
|
|
|
this.el.find("#openwebrx-rx-details-arrow-up").show();
|
|
|
|
}
|
|
|
|
|
|
|
|
Header.prototype.toggle_rx_photo = function(ev) {
|
|
|
|
if (ev && ev.target && ev.target.tagName == 'A') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.rx_photo_state) {
|
|
|
|
this.close_rx_photo();
|
|
|
|
} else {
|
|
|
|
this.open_rx_photo();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-10 15:27:46 +00:00
|
|
|
Header.prototype.download_details = function() {
|
|
|
|
var self = this;
|
|
|
|
$.ajax('api/receiverdetails').done(function(data){
|
|
|
|
self.setDetails(data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-05-08 22:11:20 +00:00
|
|
|
$.fn.header = function() {
|
|
|
|
if (!this.data('header')) {
|
|
|
|
this.data('header', new Header(this));
|
|
|
|
}
|
|
|
|
return this.data('header');
|
2020-05-10 14:23:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$(function(){
|
|
|
|
$('#webrx-top-container').header();
|
|
|
|
});
|