// PatternFly Namespace var PatternFly = PatternFly || {}; $(document).ready(function() { // Call sidebar() on ready if .sidebar-pf exists and .datatable does not exist if ($('.sidebar-pf').length > 0 && $('.datatable').length == 0) { //if ($('.sidebar-pf').length > 0) { sidebar(); } }); $(window).resize(function() { // Call sidebar() on resize if .sidebar-pf exists if ($('.sidebar-pf').length > 0) { sidebar(); } }); // PatternFly Sidebar // Set height of sidebar-pf to height of document minus height of navbar-pf if not mobile function sidebar() { var documentHeight = 0; var navbarpfHeight = 0; var colHeight = 0; if ( $('.navbar-pf .navbar-toggle').is(':hidden') ) { documentHeight = $(document).height(); navbarpfHeight = $('.navbar-pf').outerHeight(); colHeight = documentHeight - navbarpfHeight; } $('.sidebar-pf').parent('.row').children('[class*="col-"]').css({ "min-height":colHeight}); } // Util: PatternFly Popovers // Add data-close="true" to insert close X icon (function($) { PatternFly.popovers = function( selector ) { var allpopovers = $(selector); // Initialize allpopovers.popover(); // Add close icons allpopovers.filter('[data-close=true]').each(function(index, element) { var $this = $(element), title = $this.attr('data-original-title') + ''; $this.attr('data-original-title', title); }); // Bind Close Icon to Toggle Display allpopovers.on('click', function(e) { var $this = $(this); $title = $this.next('.popover').find('.popover-title'); // Only if data-close is true add class "x" to title for right padding $title.find('.close').parent('.popover-title').addClass('closable'); // Bind x icon to close popover $title.find('.close').on('click', function() { $this.popover('toggle'); }); // Prevent href="#" page scroll to top e.preventDefault(); }); }; })(jQuery); // Util: DataTables Settings (function($) { if ($.fn.dataTableExt) { /* Set the defaults for DataTables initialisation */ $.extend( true, $.fn.dataTable.defaults, { "bDestroy": true, "bAutoWidth": false, "iDisplayLength": 20, "sDom": "<'dataTables_header' f i r >" + "<'table-responsive' t >" + "<'dataTables_footer' p >", "oLanguage": { "sInfo": "Showing _START_ to _END_ of _TOTAL_ Items", "sInfoFiltered" : "(of _MAX_)", "sInfoEmpty" : "Showing 0 Results", "sZeroRecords": "

Suggestions

" + "", "sSearch": "" }, "sPaginationType": "bootstrap_input" }); /* Default class modification */ $.extend( $.fn.dataTableExt.oStdClasses, { "sWrapper": "dataTables_wrapper" }); /* API method to get paging information */ $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) { return { "iStart": oSettings._iDisplayStart, "iEnd": oSettings.fnDisplayEnd(), "iLength": oSettings._iDisplayLength, "iTotal": oSettings.fnRecordsTotal(), "iFilteredTotal": oSettings.fnRecordsDisplay(), "iPage": oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), "iTotalPages": oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) }; }; /* Combination of Bootstrap + Input Text style pagination control */ $.extend( $.fn.dataTableExt.oPagination, { "bootstrap_input": { "fnInit": function( oSettings, nPaging, fnDraw ) { var oLang = oSettings.oLanguage.oPaginate; var fnClickHandler = function ( e ) { e.preventDefault(); if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { fnDraw( oSettings ); } }; $(nPaging).append( '' + '
' + '' + 'of 3' + '
' + '' ); var els = $('li', nPaging); $(els[0]).bind( 'click.DT', { action: "first" }, fnClickHandler ); $(els[1]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); $(els[2]).bind( 'click.DT', { action: "next" }, fnClickHandler ); $(els[3]).bind( 'click.DT', { action: "last" }, fnClickHandler ); var nInput = $('input', nPaging); $(nInput).keyup( function (e) { if ( e.which == 38 || e.which == 39 ) { this.value++; } else if ( (e.which == 37 || e.which == 40) && this.value > 1 ) { this.value--; } if ( this.value == "" || this.value.match(/[^0-9]/) ) { /* Nothing entered or non-numeric character */ return; } var iNewStart = oSettings._iDisplayLength * (this.value - 1); if ( iNewStart > oSettings.fnRecordsDisplay() ) { /* Display overrun */ oSettings._iDisplayStart = (Math.ceil((oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength)-1) * oSettings._iDisplayLength; fnDraw( oSettings ); return; } oSettings._iDisplayStart = iNewStart; fnDraw( oSettings ); }); }, "fnUpdate": function ( oSettings, fnDraw ) { var oPaging = oSettings.oInstance.fnPagingInfo(), an = oSettings.aanFeatures.p, i, ien, iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength), iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1; for ( i=0, ien=an.length ; i