npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mt.bootstraplazyloader

v1.4.1

Published

Lazy Loader for Bootstrap Tabs,Pills and Modals,This package adds lazyloading option to bootstrap tabs,pills, and Modals so content will load when the user clicks it.

Downloads

4

Readme

MT.BootstrapLazyloader.js

Lazy Loader For Bootstrap Tabs, Pills and Modals

This package adds lazyloading option to bootstrap tabs, pills and modals so contents will load when the user clicks it.

NOT To use with bootstrap 4 lazyload modal set MTLazyloadBootstrapVersion = 4 in global scope.

How To Use

Install

If you use nuget package manager, write down this command in nuget package manager console

Install-Package MT.BootstrapLazyLoader.js

If yout use Bower package manager, write down this command:

bower install mt-bootstraplazyloader

This packages also depends on: Jquery >=2.0.0 Bootstrap >=3.0.0 FontAwsome >=4.2.0

If you don't use nuget package manager, just download source code, and copy MT.BootstrapTabsLazyLoader.js into your scripts folder.

Using

Add a reference to /Scripts/MT.BootstrapLazyLoader.js to the scripts part of your code, after jquery.js and bootstrap.js

A) Tabs

A1)- For Using MT.BootstrapLazyloader with tabs, add .lazyload class to nav-tabs (bootstrap tabs ul tag)

A2)- add data-url to the anchor tag of every tab you want to lazyload. this attribute will contain the url of partial pages you want to load it into the tab.

B) Pills

B1) For Using MT.BootstrapLazyloader with pills, add .lazyload class to nav-pills (bootstrap pills ul tag)

B2) add data-url to the anchor tag of every tab you want to lazyload. this attribute will contain the url of partial pages you want to load it into the tab.

C) Modal

C1) For Using MT.BoostrapLazyloader with modals, add .lazyload and .showModal classes to the element that will show modal when clicked.

C2) add data-header to define the Modal's Header.

C3) add data-size to define the Modal's size. (Example: data-size="modal-lg", don't set it if you want default size.)

C4) If you are using lazyload modal on an Anchor element, the href attribute will be used as url and you don't need to add extra data-url.

C5) By Default the Id For lazyload modal is "LazyloadModal", but you can add id attribute to the tag that will used to toggle modal, so the id for modal will be Id + "Modal". with adding id to the toggle you can open multiple inner modals.

C6) (New) to prevent modal from closing by clicking the close button, pressing 'Esc' key or by clicking outside of the modal, you just need to add data-closedisabled='false'.

C7) (New) Now you can define a header template target for modal, this is useful if you want to place a customized html in header. for this you should replace data-header with data-header-template attribute and the value should be a css selector like '#idOfDomElementsThatContainsHtml' or any css selector.

Exmaple Result:

sample modal with html template header

Note: Modal's Markup will automatically append to body, and you don't need to add Modal's markup to body manually.

Callback function after Ajax Loaded

The data-callback attribute can be used to specify a javascript function to be called once the load is done (on the .done() event of the $.get)

Example 1

applied for nav-tabs and nav-pills

<!-- Nav tabs -->
<ul class="nav nav-tabs lazyload">
    <li class="active"><a href="#fullDesc" data-toggle="tab">Description</a></li>
    <li><a href="#specificationDetails" data-toggle="tab">Specifications</a></li>
    <li><a href="#relatedProducts" data-toggle="tab" data-url="@Url.Action("relatedproducts", new { Model.Product.Id})">Related Products</a></li>
    <li><a href="#files" data-toggle="tab" data-url="@Url.Action("getproductfiles", new { Model.product.Id })" data-callback="initProducts()">Product Files</a></li>
    <li><a href="#videos" data-toggle="tab" data-url="@Url.Action("getproductvideos", new { Model.product.Id })">Product Videos</a></li>
</ul>

note: If you are lazy loading your initial tab, you can add a trigger('shown.bs.tab') on your initial tab.

MVC Example on the same page as your tabs

@section scripts {
        <script type="text/javascript">
            $(document).ready(function () {                
                $('.nav-tabs a[href="#fullDesc"]').trigger('shown.bs.tab');
            });
        </script>
}

Example 2

<button class="lazyload showModal" data-url="@Url.Action("PreviewProduct", new {id=Model.product.Id})"
     data-header="Preview Product" data-size="modal-lg" data-callback="initProducts()">Preview</button>

The Returned Partial View Content:

<div class="modal-body">
    <!--Contents goes here-->    
</div>
<div class="modal-footer">
        <!--footer buttons goes here-->
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Save changes</button>
</div >