switch off responsive design with one click

How to integrate?

  1. Download and reference responsive-switch.min.js in the <head> of your responsive website’s HTML code.
  2. Add the following link to your website:
    <a href="#" class="rs-link" data-link-desktop="Switch to desktop version" data-link-responsive="Switch to responsive / mobile version"></a>
  3. Done.

Code example

<html>
<head>
...
http://scripts/responsive-switch.min.js
...
</head>
<body>
...
<a href="#"
class="rs-link"
data-link-desktop="Switch to desktop version"
data-link-responsive="Switch to responsive / mobile version"
data-always-visible="false"></a>
...
</body>
</html>
You can control the link behaviour with the following attributes:

data-link-desktop Text for linking to desktop version. There is no default text. You can also leave it blank and style the link with the according CSS classes.
data-link-responsive Text for linking to responsive version. There is no default text. You can also leave it blank and style the link with the according CSS classes.
data-always-visible Whether link should be displayed all the time (“true”) or only if browser window or screen size SMALLER than 1024px (“false”). Defaults to “false”. We recommend to use “false” for production websites and “true” only for development purpose.

CSS classes

Depending on the “Responsive on/off” state, the “Responsive Switch” link has some CSS classes for styling.

rs-link-to-desktop Website is in “Responsive Design” mode (default)
rs-link-to-responsive Website is in “Desktop” mode
rs-link-active “Responsive Switch” link IS visible (browser window or screen size SMALLER than 1024px)
rs-link-inactive “Responsive Switch” link NOT visible (browser window or screen size LARGER than 1024px)

API

Using the default method of adding a link with the “Responsive Switch” CSS class is simple. But you can also trigger the “Responsive Switch” via custom JavaScript code. Just call responsiveSwitch.toggle() like in the following example. It will toggle between the desktop and the responsive view and also update all “Responsive Switch” links on your website.


responsiveSwitch.toggle();

Advertisements
Posted in Css

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s