make an App::Netdisco dist using Module::Install

This commit is contained in:
Oliver Gorwits
2012-12-17 18:31:16 +00:00
parent 6a0aa7864e
commit 05086e8b78
125 changed files with 428 additions and 127 deletions

View File

@@ -0,0 +1,11 @@
$(document).ready(function() {
// search hook for each tab
[% FOREACH tab IN vars.tabs %]
$('[% "#${tab.id}_form" %]').submit(function(event){ do_search(event, '[% tab.id %]'); });
[% END %]
// on page load, load the content for the active tab
[% IF params.tab %]
$('#[% params.tab %]_form').trigger("submit");
[% END %]
});

View File

@@ -0,0 +1,145 @@
// used by the tabbing interface to make sure the correct
// ajax content is loaded
var path = 'device';
function inner_view_processing(tab) {
// LT wanted the page title to reflect what's on the page :)
document.title = $('#nd_device_name').text()
+' - '+ $('#'+ tab + '_link').text();
// VLANs column list collapser trigger
// it's a bit of a faff because we can't easily use Bootstrap's collapser
$('.nd_collapse_vlans').toggle(function() {
$(this).siblings('.nd_collapsing').toggle();
$(this).siblings('.cell-arrow-up-down')
.toggleClass('icon-chevron-up icon-chevron-down');
$(this).html('<div class="cell-arrow-up-down icon-chevron-down icon-large"></div>Hide VLANs');
}, function() {
$(this).siblings('.nd_collapsing').toggle();
$(this).siblings('.cell-arrow-up-down')
.toggleClass('icon-chevron-up icon-chevron-down');
$(this).html('<div class="cell-arrow-up-down icon-chevron-up icon-large"></div>Show VLANs');
});
// toggle visibility of port up/down and edit controls
$('.nd_editable_cell').mouseenter(function() {
$(this).children('.nd_hand_icon').show();
if (! $(this).is(':focus')) {
$(this).children('.nd_edit_icon').show(); // ports
$(this).siblings('td').find('.nd_device_details_edit').show(); // details
}
});
$('.nd_editable_cell').mouseleave(function() {
$(this).children('.nd_hand_icon').hide();
if (! $(this).is(':focus')) {
$(this).children('.nd_edit_icon').hide(); // ports
$(this).siblings('td').find('.nd_device_details_edit').hide(); // details
}
});
$('[contenteditable=true]').focus(function() {
$(this).children('.nd_edit_icon').hide(); // ports
$(this).siblings('td').find('.nd_device_details_edit').hide(); // details
});
// activity for port up/down control
$('.icon-hand-up').click(function() {
port_control(this); // save
});
$('.icon-hand-down').click(function() {
port_control(this); // save
});
// activity for power enable/disable control
$('.nd_power_icon').click(function() {
port_control(this); // save
});
var dirty = false;
// activity for contenteditable control
$('[contenteditable=true]').keydown(function() {
var esc = event.which == 27,
nl = event.which == 13;
if (esc) {
if (dirty) { document.execCommand('undo') }
$(this).blur();
dirty = false;
}
else if (nl) {
$(this).blur();
event.preventDefault();
dirty = false;
port_control(this); // save
}
else {
dirty = true;
}
});
// show or hide netmap help button
if (tab == 'netmap') {
$('#netmap_help_img').show();
}
else {
$('#netmap_help_img').hide();
}
// activate tooltips and popovers
$("[rel=tooltip]").tooltip({live: true});
$("[rel=popover]").popover({live: true});
}
$(document).ready(function() {
// sidebar collapser events trigger change of up/down arrow
$('.collapse').on('show', function() {
$(this).siblings().find('.arrow-up-down')
.toggleClass('icon-chevron-up icon-chevron-down');
});
$('.collapse').on('hide', function() {
$(this).siblings().find('.arrow-up-down')
.toggleClass('icon-chevron-up icon-chevron-down');
});
// show or hide sweeping brush icon when field has content
var sweep = $('#ports_form').find("input[name=f]");
if (sweep.val() === "") {
$('.field_clear_icon').hide();
} else {
$('.field_clear_icon').show();
}
sweep.change(function() {
if ($(this).val() === "") {
$('.field_clear_icon').hide();
} else {
$('.field_clear_icon').show();
}
});
// handler for sweeping brush icon in port filter box
$('.field_clear_icon').click(function() {
sweep.val('');
$('.field_clear_icon').hide();
$('#ports_form').trigger('submit');
});
// clickable device port names can simply resubmit AJAX rather than
// fetch the whole page again.
$('body').on('click', '.nd_this_port_only', function() {
event.preventDefault(); // link is real so prevent page submit
var port = $(this).text();
port = $.trim(port);
sweep.val(port);
$('.field_clear_icon').show();
$('#ports_form').trigger('submit');
});
});

View File

@@ -0,0 +1,70 @@
// used by the tabbing interface to make sure the correct
// ajax content is loaded
var path = 'search';
// fields in the Device Search Options form (Device tab)
var d_inputs = $("#device_form .clearfix input").not('[type="checkbox"]')
.add("#device_form .clearfix select");
// if any field in Device Search Options has content, highlight in green
// and strikethrough the navbar search
function device_form_state(e) {
if (e.is('[value!=""]')) {
if (e.attr('type') == 'text') {
$('.field_copy_icon').hide();
}
e.parent(".clearfix").addClass('success');
$('#nq').css('text-decoration', 'line-through');
var id = '#' + e.attr('name') + '_clear_btn';
$(id).show();
}
else {
e.parent(".clearfix").removeClass('success');
var id = '#' + e.attr('name') + '_clear_btn';
$(id).hide();
if (! d_inputs.is('[value!=""]') ) {
$('#nq').css('text-decoration', 'none');
$('.field_copy_icon').show();
}
}
}
// this is called by do_search to support local code
// here, when tab changes need to strike/unstrike the navbar search
function inner_view_processing(tab) {
if (tab == 'device') {
d_inputs.each(function() {device_form_state($(this))});
}
else {
$('#nq').css('text-decoration', 'none');
}
}
// on load, check initial Device Search Options form state,
// and on each change to the form fields
$(document).ready(function() {
$('.field_copy_icon').hide();
$('.field_clear_icon').hide();
d_inputs.each(function() {device_form_state($(this))});
d_inputs.change(function() {device_form_state($(this))});
// handler for copy icon in search option
$('.field_copy_icon').click(function() {
var name = $(this).data('btn-for');
var input = $('#device_form [name=' + name + ']');
input.val( $('#nq').val() );
device_form_state(input); // will hide copy icons
});
// handler for bin icon in search option
$('.field_clear_icon').click(function() {
var name = $(this).data('btn-for');
var input = $('#device_form [name=' + name + ']');
input.val('');
device_form_state(input);
});
});