Git Product home page Git Product logo

responsive-comments's Introduction

Responsive Comments

ResponsiveComments was designed to bring simple conditional loading to the client side. Through the use of HTML comments, markup can be introduced to progressively enhance an experience as various media queries or feature detections evaluate to true. For more information and examples check out responsivecomments.com.

Installation

$ bower install --save responsive-comments

Usage

Media Queries

To get started using ResponsiveComments, add a [data-responsive-comment-media] attribute containing a valid media query to any element containing children that you wish to conditionally load. The ResponsiveComments concept will only work in a progressivelty enhanced experience so make sure you use minimum width media queries.

<div data-responsive-comment-media="(min-width: 769px)">...</div>

The [data-responsive-comment-media] containers should contain one commented-out segment of markup as well as any other HTML they require.

<div data-responsive-comment-media="(min-width: 769px)">
	<!-- <div><p>Any content can go in here</p></div> -->
</div>

Feature Detection

ResponsiveComments also supports feature detection using Modernizr. Make sure you include a Modernizr build with all the tests you need before the ResponsiveComments library. A Modernizr test, or a comma separated list of multiple Modernizr tests, can then be specified in [data-responsive-comments-supports].

<div data-responsive-comment-supports="svg">
	<!-- <div><p>Any content can go in here, including images</p></div> -->
</div>

The [data-responsive-comment-supports] containers should also contain one commented out segment of markup as well as any other HTML they require.

DOM Insertion

The commented out markup inside the ResponsiveComments container will be inserted into the DOM when the specified media query or feature detection passes. Any valid insertAdjacentHTML insertion type can be specified in [data-responsive-comment-insert], valid options are beforebegin, afterbegin, beforeend, afterend with a default of beforeend.

<div data-responsive-comment-insert="afterbegin"
     data-responsive-comment-media="(min-width: 769px)">
	<!-- <div><p>Any content can go in here, including images</p></div> -->
</div>

Events

You can also bind to an event, fired on the element containing the [data-responsive-comment-media] attribute, for added functionality. Use jQuery if you wish or good old vanilla JavaScript.

document.getElementById('respcomm').addEventListener('responsiveComment', function(e) {
    // do something crazy
});

Support

ResponsiveComments is supported across all major web browsers. However, we make use of the window.matchMedia function for testing media queries, this function is fully supported in Internet Explorer 10, but version 9 and down require a polyfill. ResponsiveComments also requires Modernizr for feature detection so ensure a Modernizr build is included with all the required tests.

ResponsiveComments was designed and developed with love at Digital Surgeons.

MIT Open Source License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

responsive-comments's People

Contributors

chambaz avatar idisposable avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.