• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    HTML
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”„ Politely ask your users to view your mobile website in portrait or landscape mode

pleaserotate.js

A simple way to force mobile users to view your site in portrait or landscape mode. Include this js file and it will replace your site with a friendly message until the users' device is in the proper orientation.

Example

View it in action over here (mobile device required to see it).

Basic Usage

Just include the script file anywhere in your doc:

<script src="pleaserotate.js"></script>

Style using CSS. Configure by creating a window.PleaseRotateOptions object before you include the script.

<style>
    /* style the elements with CSS */
    #pleaserotate-graphic{
        fill: #fff;
    }

    #pleaserotate-backdrop {
        color: #fff;
        background-color: #000;
    }
</style>

<script>
    /* you can pass in options here */
    PleaseRotateOptions = {
        forcePortrait: true // if you would prefer to force portrait mode
    };
</script>
<script src="pleaserotate.js"></script>

Using AMD or CommonJS

This supports AMD and CommonJS. Require pleaserotate.js and call PleaseRotate.start(options) to use.

Options

The current default options are:

var PleaseRotateOptions = {
    startOnPageLoad: true,
    onHide: function(){},
    onShow: function(){},
    forcePortrait: false,
    message: "Please Rotate Your Device",
    subMessage: "(or click to continue)",
    allowClickBypass: true,
    onlyMobile: true,
    zIndex: 1000,
    iconNode: null
};

Note Regarding Startup

Depending on where you including the javascript file, other parts of your site could render before pleaserotate.js has a chance to block them out. To help you work around that, pleaserotate.js attaches classes to the <html> element while running. Look for pleaserotate-showing and pleaserotate-hiding classes, which indicate that pleaserotate.js has finished loading and if it is currently showing the "Please Rotate" message or not. You can use CSS to hide parts of your page until those classes show up.

More Repositories

1

encom-boardroom

๐Ÿ“ˆ Web tribute to the Tron: Legacy Boardroom Scene
JavaScript
2,220
star
2

encom-globe

๐ŸŒŽ WebGL globe based on the boardroom scene from Tron: Legacy
JavaScript
1,069
star
3

hexasphere.js

๐ŸŒGenerate a sphere covered (mostly) in hexagons.
JavaScript
243
star
4

streamed

Casual live data stream and visualization server.
JavaScript
90
star
5

lineup

An HTML5 tribute to the lineup scene in Marvel's Guardian of the Galaxy
JavaScript
27
star
6

habitrpg-txt

TXT based UI for HabitRPG
JavaScript
23
star
7

mintkit

Mint.com ruby API
Ruby
14
star
8

encom-screensaver

Generates the Encom boardroom screensaver from Tron Legacy w/custom text as a GIF
JavaScript
9
star
9

arscan.github.com

My personal webpage
JavaScript
6
star
10

ai_ants_js

My javascript entry to the 2011 AI Challenge (aichallenge.org)
JavaScript
5
star
11

github-timeline-stream

Github timeline data exposed as a node.js stream
JavaScript
4
star
12

solar-system

Playground for solar system viz
JavaScript
4
star
13

wikipedia-stream

Wikipedia updates exposed as a node.js stream.
JavaScript
4
star
14

dotfiles

rob's dotfiles
Vim Script
2
star
15

autorepoke

automating immaturity since 2013
Ruby
1
star
16

repulsedelement.js

jQuery plugin that causes specified elements to be repulsed by the user's mouse.
JavaScript
1
star
17

lightplayer

Just a simple python interface to control a set of lights connected via parrallel port
Python
1
star
18

habitrpg-ncurses

1
star
19

github-users-throttled

JavaScript
1
star
20

title-fetch

Grabs the title of a page located at a URL and returns it in a JSON response
JavaScript
1
star
21

robmoonface

Android live wallpaper
Java
1
star
22

mintemailparser-nodejs

Node.js module that recovers account and net worth information from Mint.com's weekly emails
JavaScript
1
star
23

github-api-throttled

JavaScript
1
star
24

robscanlon.com

The root of my web site
JavaScript
1
star
25

world-sketch

playing with some concepts
JavaScript
1
star