Pages

Showing posts with label HTML 5 CSS 3. Show all posts
Showing posts with label HTML 5 CSS 3. Show all posts

HTML Data tables all options example

 

                <table id="basic-datatable-Users" class="table table-striped dt-responsive nowrap w-100">

                            <thead>

                                <tr>

                                    <th>Name</th>

                                    <th>Phone</th>

                                    <th>Email</th>

                                    <th>Role</th>

                                    <th>HRIS No</th>

                                    <th>Bar Code</th>

                                    <th>Supervisor</th>

                                    <th>User Skill</th>

                                    <th>Is Active</th>

                                    <th>Action</th>

                                </tr>

                            </thead>



                            <tbody>

                                @foreach (var user in Model.Users)

                                {

                                    <tr>

                                        <td>

                                            @user.FullName

                                        </td>


                                        <td>@user.PhoneNumber</td>

                                        <td>@user.Email</td>

                                        <td>@user.RoleName</td>

                                        <td>@user.HrisNo</td>

                                        <td>@user.BarCode</td>

                                        <td>@user.Supervisor</td>

                                        <td>@user.UserSkill</td>

                                        <td>

                                            @if (user.IsActive == true)

                                            {

                                                <div class="form-check form-switch">

                                                    <input data-toggle="ajax-modal" type="checkbox" checked disabled class="form-check-input">

                                                </div>

                                            }

                                            else

                                            {

                                                <div class="form-check form-switch">

                                                    <input data-toggle="ajax-modal" type="checkbox" disabled class="form-check-input">

                                                </div>

                                            }

                                        </td>

                                        <td>

                                            <a href="/user/details?id=@user.Id" type="button" title="User Edit" class="btn btn-sm btn-soft-primary rounded-pill">

                                                <i class="mdi mdi-account-edit-outline"></i>

                                            </a>

                                            <button type="button" title="Deactivate" class="btn btn-sm  btn-soft-primary rounded-pill" data-bs-toggle="modal" data-id="@user.Id" onclick="OpenUserDeleteSubmit(this);">

                                                <i class="mdi mdi-delete"></i>

                                            </button>


                                        </td>

                                    </tr>

                                }


                            </tbody>

                            <tfoot>

                                <tr>

                                    <th>Name</th>

                                    <th>Phone</th>

                                    <th>Email</th>

                                    <th>Role</th>

                                    <th>HRIS No</th>

                                    <th>Bar Code</th>

                                    <th>Supervisor</th>

                                    <th>User Skill</th>

                                    <th>Is Active</th>

                                    <th>Action</th>

                                </tr>

                            </tfoot>

                        </table>



<!-- Datatables css -->

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.3.6/css/buttons.dataTables.min.css" />

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.6.2/css/select.dataTables.min.css" />

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap5.min.css" />

<style>

    div.dataTables_wrapper {

        width: 100%;

        margin: 0 auto;

    }


    .dt-button.buttons-excel{

        background: #727cf5;

        color:#fff;

        border:0;

    }

    thead input {

        width: 100%;

        border:1px solid #ededed;

    }

</style>



@section Scripts {

    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/1.13.4/js/dataTables.bootstrap5.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/select/1.6.2/js/dataTables.select.min.js"></script>





    <script>


        $(document).ready(function () {

            $('#basic-datatable-Users thead tr')

                .clone(true)

                .addClass('filters')

                .appendTo('#basic-datatable-Users thead');


                ///


                ///


            $("#basic-datatable-Users").DataTable({

                orderCellsTop: true,

                dom: 'Bfrtip',

                scrollX: true,  

                responsive : true,

                buttons: [{

                    extend: 'excelHtml5',

                    exportOptions: {

                        columns: [1, 2, 3, 4, 5, 6, 7, 8, 9]

                    }

                }

                ],

                select: {

                    style: 'multi'

                },

                keys: !0,

                language: {

                    paginate: {

                        previous: "<i class='mdi mdi-chevron-left'>",

                        next: "<i class='mdi mdi-chevron-right'>"

                    }

                },

                drawCallback: function () {

                    $(".dataTables_paginate > .pagination").addClass("pagination-rounded")

                },

                //clear autocomplete

                initComplete: function () {


                    var api = this.api();


                    // Define the columns that require filters

                    var filterColumns = [1, 2, 3, 4];


                    // For each column

                    api.columns().eq(0).each(function (colIdx) {

                        var cell = $('.filters th').eq($(api.column(colIdx).header()).index());


                        if (filterColumns.includes(colIdx)) {

                            // Set the header cell to contain the input element

                            var title = $(cell).text();

                            $(cell).html('<input type="text" placeholder="' + title + '" />');


                            // On every keypress in this input

                            $('input', cell)

                                .off('keyup change')

                                .on('change', function (e) {

                                    // Get the search value

                                    $(this).attr('title', $(this).val());

                                    var regexr = '({search})';


                                    var cursorPosition = this.selectionStart;

                                    // Search the column for that value

                                    api

                                        .column(colIdx)

                                        .search(

                                            this.value != ''

                                                ? regexr.replace('{search}', '(((' + this.value + ')))')

                                                : '',

                                            this.value != '',

                                            this.value == ''

                                        )

                                        .draw();

                                })

                                .on('keyup', function (e) {

                                    e.stopPropagation();


                                    $(this).trigger('change');

                                    $(this)

                                        .focus()[0]

                                        .setSelectionRange(cursorPosition, cursorPosition);

                                });

                        } else {

                            // Empty the header cell

                            $(cell).empty();

                        }

                    });


                    $(this.api().table().container()).find('input[type="search"]').parent().wrap('<form>').parent().attr('autocomplete', 'off').css('overflow', 'hidden').css('margin', 'auto');


                }

            });

        });


        /////



    </script>




}


Jquery Data Tables Complete essential Example

 <pre>                  

  <table id="basic-datatable" class="display table-bordered nowrap table table-striped table-sm" style="font-size:12px;">

                            <thead>

                                <tr>

                                    <th>Action</th>

                                    <th>Employee ID</th>

                                    <th>Employee Name</th>

                                    <th>Designation</th>

                                    <th>Start Day/Time</th>

                                    <th>Meter Reading</th>

                                    <th>Start Remarks</th>

                                    <th>End Day/Time</th>

                                    <th>Meter Reading</th>

                                    <th>End Remarks</th>

                                    <th>Attachments</th>

                                    

                                </tr>


                            </thead>



                            <tbody>

                                @foreach (var item in Model)

                                {

                                    <tr class="align-middle">


                                        <td class="text-nowrap text-end">


                                            <a class="btn btn-link p-0" href="~/DayInOut/ShowMapRoute?id=@item.Session" data-bs-toggle="tooltip" data-bs-placement="top" title="View Route" onclick="GetRouteById(@item.Session)">

                                                <i class="mdi mdi-archive-edit"></i>

                                            </a>


                                        </td>

                                        <td class="text-nowrap fw-bold">

                                            <span title="@item.Client" class="d-inline-block text-truncate" style="max-width: 100px;"> E10001</span>

                                        </td>

                                        <td class="text-nowrap">

                                            <span title="@item.Client" class="d-inline-block text-truncate" style="max-width: 100px;"> Tharaka Jayampathi </span>

                                        </td>

                                        <td class="text-nowrap">DivisionalCodinator</td>


                                        <td class="text-nowrap fw-bold">


                                            @if (item.DayStart.HasValue)

                                            {

                                                @item.DayStart.Value.ToString("M/d/yyyy")


                                                <br>


                                                @item.DayStart.Value.ToString("h:mm:ss tt")

                                            }

                                            else

                                            {

                                                <p>???</p>

                                            }


                                        

                                        <td class="text-nowrap">@item.StartMileage </td>

                                        <td class="text-nowrap">@item.DayStartRemark </td>


                                        <td class="text-nowrap fw-bold">

                                                @if (item.DayEnd.HasValue)

                                                {

                                                    @item.DayEnd.Value.ToString("M/d/yyyy")


                                                <br>


                                                    @item.DayEnd.Value.ToString("h:mm:ss tt")

                                                }

                                                else

                                                {

                                                <p>???</p>

                                                }

                                        </td>

                                        <td class="text-nowrap">@item.EndMileage </td>

                                        <td class="text-nowrap">@item.DayEndRemark </td>


                                        <td class="text-nowrap">

                                                @if (item.DayStartAttachment != "" && item.DayStartAttachment != null)

                                                {



                                                <a title="Start" style="  border: 1px solid #dedede; margin-right: 5px;" class="btn px-2  btn-success btn btn-sm" target="_blank" href="@item.DayStartAttachment" download>

                                                    <i class="far fa-file-image"></i>

                                                </a>


                                                }


                                                @if (item.DayEndAttachment != "" && item.DayEndAttachment != null)

                                                {


                                                <a title="End" style="    border: 1px solid #dedede; margin-right: 5px;" class="btn px-2 btn-danger btn btn-sm" target="_blank" href="@item.DayEndAttachment" download>

                                                    <i class="far fa-file-image"></i>

                                                </a>


                                                }

                                        </td>


                                    </tr>

                                }

                            </tbody>


                            <tfoot>

                                <tr>

                                    <th>Action</th>

                                    <th>Employee ID</th>

                                    <th>Employee Name</th>

                                    <th>Designation</th>

                                    <th>Start Day/Time</th>

                                    <th>Meter Reading</th>

                                    <th>Start Remarks</th>

                                    <th>End Day/Time</th>

                                    <th>Meter Reading</th>

                                    <th>End Remarks</th>

                                    <th>Attachments</th>


                                </tr>


                            </tfoot>


                        </table>

@section Styles {

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/2.3.6/css/buttons.dataTables.min.css" />

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.6.2/css/select.dataTables.min.css" />

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap5.min.css" />

    <style>

        div.dataTables_wrapper {

            width: 100%;

            margin: 0 auto;

        }


        thead input {

            width: 100%;

        }

    </style>


}






@section Scripts{



    <script type="text/javascript" src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/1.13.4/js/dataTables.bootstrap5.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.3.6/js/dataTables.buttons.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.html5.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/buttons/2.3.6/js/buttons.print.min.js"></script>

    <script type="text/javascript" src="https://cdn.datatables.net/select/1.6.2/js/dataTables.select.min.js"></script>



    <script>

        $(document).ready(function () {

            // Setup - add a text input to specific footer cells

            $('#basic-datatable thead tr')

                .clone(true)

                .addClass('filters')

                .appendTo('#basic-datatable thead');


            $("#basic-datatable").DataTable({

                orderCellsTop: true,

                dom: 'Bfrtip',

                scrollX: true,

                buttons: [{

                    extend: 'excelHtml5',

                    exportOptions: {

                        columns: [1, 2, 3, 4,5,6,7,8,9]

                    }

                }

                ],

                select: {

                    style: 'multi'

                },

                initComplete: function () {

                    var api = this.api();


                    // Define the columns that require filters

                    var filterColumns = [1, 2, 3, 4, 5, 6, 7, 8];


                    // For each column

                    api.columns().eq(0).each(function (colIdx) {

                        var cell = $('.filters th').eq($(api.column(colIdx).header()).index());


                        if (filterColumns.includes(colIdx)) {

                            // Set the header cell to contain the input element

                            var title = $(cell).text();

                            $(cell).html('<input type="text" placeholder="' + title + '" />');


                            // On every keypress in this input

                            $('input', cell)

                                .off('keyup change')

                                .on('change', function (e) {

                                    // Get the search value

                                    $(this).attr('title', $(this).val());

                                    var regexr = '({search})';


                                    var cursorPosition = this.selectionStart;

                                    // Search the column for that value

                                    api

                                        .column(colIdx)

                                        .search(

                                            this.value != ''

                                                ? regexr.replace('{search}', '(((' + this.value + ')))')

                                                : '',

                                            this.value != '',

                                            this.value == ''

                                        )

                                        .draw();

                                })

                                .on('keyup', function (e) {

                                    e.stopPropagation();


                                    $(this).trigger('change');

                                    $(this)

                                        .focus()[0]

                                        .setSelectionRange(cursorPosition, cursorPosition);

                                });

                        } else {

                            // Empty the header cell

                            $(cell).empty();

                        }

                    });

                },

            });

        });

    </script>


</pre>  

defer Javascript in google site audit - lighthouse

Passing the google site audit - defer Javascript in google site audit - lighthouse

<script src="demo_defer.js" defer></script>

This is a script that will not run until after the page has loaded:

Definition and Usage
The defer attribute is a boolean attribute.

When present, it specifies that the script is executed when the page has finished parsing.

Note: The defer attribute is only for external scripts (should only be used if the src attribute is present).

Note: There are several ways an external script can be executed:

If async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
If async is not present and defer is present: The script is executed when the page has finished parsing

If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page

Active class to current page link

To highlight the current page add an active or another class name to the link when the linked page is opened using java script.



  <script>
$(".navbar-nav a").filter(function(){
    return this.href == location.href.replace(/#.*/, "");
}).addClass("active");
  </script>

bootstrap 4 get remaining height of parent div

bootstrap 4 get remaining height of parent div



       <div class="row h-100 flex-column">
        <div class="row">
          <div>
            <div>ROWccccccccccc 1</div>
          </div>
        </div>
        <div class="row justify-content-center align-items-center bg-blue flex-grow-1">
          <div class="text-white">ROWcccccccccccccc 2</div>
        </div>
      </div>


<div class="container-fluid h-100">
  <div class="row justify-content-center h-100">
    <div class="col-4 bg-red">
      <div class="h-100 d-flex flex-column">
        <div class="row justify-content-center bg-purple">
          <div class="text-white">
            <div style="height:200px">ROW 1</div>
          </div>
        </div>
        <div class="row justify-content-center bg-blue flex-grow-1">
          <div class="text-white">ROW 2</div>
        </div>
      </div>
    </div>
    <div class="col-8 bg-gray">grgrgrg</div>
  </div>
</div>

Link - https://codepen.io/anon/pen/RyQvmW?editors=1100

Bootstap 4 hide md and below - Hide in medium screen and below

Reference URL

https://stackoverflow.com/questions/35351353/missing-visible-and-hidden-in-bootstrap-v4

Show/hide for breakpoint and down:
  • hidden-xs-down (hidden-xs) = d-none d-sm-block
  • hidden-sm-down (hidden-sm hidden-xs) = d-none d-md-block
  • hidden-md-down (hidden-md hidden-sm hidden-xs) = d-none d-lg-block
  • hidden-lg-down = d-none d-xl-block
  • hidden-xl-down (n/a 3.x) = d-none (same as hidden)
Show/hide for breakpoint and up:
  • hidden-xs-up = d-none (same as hidden)
  • hidden-sm-up = d-sm-none
  • hidden-md-up = d-md-none
  • hidden-lg-up = d-lg-none
  • hidden-xl-up (n/a 3.x) = d-xl-none
Show/hide only for a single breakpoint:
  • hidden-xs (only) = d-none d-sm-block (same as hidden-xs-down)
  • hidden-sm (only) = d-block d-sm-none d-md-block
  • hidden-md (only) = d-block d-md-none d-lg-block
  • hidden-lg (only) = d-block d-lg-none d-xl-block
  • hidden-xl (n/a 3.x) = d-block d-xl-none
  • visible-xs (only) = d-block d-sm-none
  • visible-sm (only) = d-none d-sm-block d-md-none
  • visible-md (only) = d-none d-md-block d-lg-none
  • visible-lg (only) = d-none d-lg-block d-xl-none
  • visible-xl (n/a 3.x) = d-none d-xl-block

Responsive image link map

This is a Copy and Paste Quick fix solution for HTML Image Map linking for responsive design with Javascript and Jquery. Add this code before closing your body tag.



<img src="images/worldmap-world-map.jpg"   usemap="#image-map">
       
       
<map name="image-map">
    <area target="" alt="North America/Canada" title="North America/Canada" href="#" coords="373,217,393,255,405,272,405,312,391,373,354,368,352,415,371,443,344,473,290,496,213,446,168,395,155,354,137,312,114,293,87,291,45,315,41,276,30,240,18,216,27,185,35,156,59,146,116,153,128,177,155,161,169,152,178,108,260,110,283,70,313,66,344,76,336,143,323,175,376,233,404,277,369,262" shape="poly">
    <area target="" alt="Sri Lanka" title="Sri Lanka" href="#" coords="931,505,892,460" shape="rect">
    <area target="" alt="Europe" title="Europe" href="#" coords="606,362,633,369,654,385,670,371,679,395,707,404,747,364,777,354,776,269,756,270,753,229,732,224,726,205,707,205,706,158,684,158,624,224,617,248,575,225,536,226,534,244,574,255,601,254,584,265,565,279,574,306,564,327,543,335,546,370,575,384,611,379" shape="poly">
    <area target="" alt="Australia" title="Australia" href="#" coords="1011,611,1035,588,1056,575,1079,570,1088,550,1122,551,1134,574,1150,575,1149,532,1168,537,1180,574,1189,582,1197,598,1195,639,1175,650,1176,667,1156,671,1151,691,1111,696,1097,658,1075,650,1067,663,1048,675,1009,660" shape="poly">
    <area target="" alt="East Asia" title="East Asia" href="#" coords="948,405,966,399,975,358,1051,357,1067,335,1089,333,1102,340,1109,362,1125,383,1124,405,1068,407,1067,431,1058,451,1023,470,1034,487,1068,474,1088,493,1073,523,1050,549,1013,558,992,519,971,489,959,451,962,436" shape="poly">
</map>



!function(){"use strict";function a(){function a(){function a(a,d){function e(a){var d=1===(f=1-f)?"width":"height";return c[d]+Math.floor(Number(a)*b[d])}var f=0;j[d].coords=a.split(",").map(e).join(",")}var b={width:l.width/l.naturalWidth,height:l.height/l.naturalHeight},c={width:parseInt(window.getComputedStyle(l,null).getPropertyValue("padding-left"),10),height:parseInt(window.getComputedStyle(l,null).getPropertyValue("padding-top"),10)};k.forEach(a)}function b(a){return a.coords.replace(/ *, */g,",").replace(/ +/g,",")}function c(){clearTimeout(m),m=setTimeout(a,250)}function d(){l.width===l.naturalWidth&&l.height===l.naturalHeight||a()}function e(){l.addEventListener("load",a,!1),window.addEventListener("focus",a,!1),window.addEventListener("resize",c,!1),window.addEventListener("readystatechange",a,!1),document.addEventListener("fullscreenchange",a,!1)}function f(){return"function"==typeof i._resize}function g(a){return document.querySelector('img[usemap="'+a+'"]')}function h(){j=i.getElementsByTagName("area"),k=Array.prototype.map.call(j,b),l=g("#"+i.name)||g(i.name),i._resize=a}var i=this,j=null,k=null,l=null,m=null;f()?i._resize():(h(),e(),d())}function b(){function b(a){if(!a.tagName)throw new TypeError("Object is not a valid DOM element");if("MAP"!==a.tagName.toUpperCase())throw new TypeError("Expected <MAP> tag, found <"+a.tagName+">.")}function c(c){c&&(b(c),a.call(c),d.push(c))}var d;return function(a){switch(d=[],typeof a){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(a||"map"),c);break;case"object":c(a);break;default:throw new TypeError("Unexpected data type ("+typeof a+").")}return d}}"function"==typeof define&&define.amd?define([],b):"object"==typeof module&&"object"==typeof module.exports?module.exports=b():window.imageMapResize=b(),"jQuery"in window&&(jQuery.fn.imageMapResize=function(){return this.filter("map").each(a).end()})}();
//# sourceMappingURL=imageMapResizer.map
jQuery('map').imageMapResize();
//Calling with Jquery

Search This Blog