Skip to content

Instantly share code, notes, and snippets.

@bochoven
Created August 6, 2015 08:33
Show Gist options
  • Save bochoven/b61e8fca3064fde7f01b to your computer and use it in GitHub Desktop.
Save bochoven/b61e8fca3064fde7f01b to your computer and use it in GitHub Desktop.
Site info module for Munkireport javascript
/*!
* Custom javascript for munkireport
*
*/
$(document).on('appReady', function(e, lang) {
// Add Site info to listing
var listingDropdown = $('span[data-i18n="nav.main.listings"]').parent().next();
listingDropdown.append(
$('<li>')
.append($('<a>')
.attr('href', appUrl + '/module/site_info/listing')
.text('Site info')));
// Only run on the client_detail page
if($('.client-tabs').length)
{
// Create site-info tab content
var content = $('\
<table class="table table-striped">\
<tbody>\
<tr>\
<td>Site Name</td>\
<td id="site-info-site_name"></td>\
</tr>\
<tr>\
<td>Region Name</td>\
<td id="site-info-region_name"></td>\
</tr>\
<tr>\
<td>Site Code</td>\
<td id="site-info-site_code"></td>\
</tr>\
<tr>\
<td>School Type</td>\
<td id="site-info-school_type"></td>\
</tr>\
</tbody>\
</table>');
// Add site-info to tabs
var conf = {
id: 'site-info',
linkTitle: 'Site Info',
tabTitle: 'Site Info',
tabContent: content
}
addTab(conf);
// Retrieve data for site-info tab
$.getJSON( appUrl + '/module/site_info/get_data/' + serialNumber, function( data ) {
// Set properties based on id
$.each(data, function(prop, val){
$('#site-info-'+prop).html(val);
});
});
// Set correct tab on location hash
loadHash();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment