GithubHelp home page GithubHelp logo

web5design / duplicity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomasreimers/duplicity

0.0 3.0 0.0 60 KB

A javascript framework to quick start responsive design.

License: MIT License

duplicity's Introduction

##Duplicity 0.1

Duplicity is a javascript library to kickstart responsive web design

Duplicity is built on top of jquery and requires it to run.

###Devices

Duplicity examines the browser width and makes a guess at which device is being used; if the screen width is:

  • (0, 640): 'phone'
  • [640, 1024]: 'tablet'
  • (1024, โˆž): 'desktop'

Also, if the browser is resized, or the phone is rotated, causing a significant change in screen size (which leads duplicity to classify it as a different device) it will update all the following methods!

###HTML

Once duplicity has determined the device, it provides very simple methods to change your webpage to be responsive. The first being its HTML protocol

<div data-display='phone'>
    This div will only be shown if the device is a phone,
</div>

<div data-display="tablet desktop">
    while this div will appear if the device is a tablet or a desktop!
</div>

<a href="http://example.com?mobile=false" data-display="phone tablet">
    Oh yeah! and you can apply this to any tag (not just divs)!
</a>

###CSS

Additionally duplicity will add an aptly named class ('phone', 'tablet', 'desktop') to the body element; thus allowing you to code device specific styles

#myContent{
    /* What occurs normally */ 
    padding:20px;
}

.phone #myContent{
    /* What occurs on a phone */ 
    padding:5px;
}

###Javascript

Ultimately, duplicity is a JS library and so it provides you with some nice JS features:

The first being three booleans by which you can read the detected device:

duplicity.phone, duplicity.tablet, duplicity.desktop

if (duplicity.phone){

    // do something 
    
}

Additionally, duplicity provides you with the ability to do some additional set up when the device is detected to be changed (i.e. if the user resizes the browser to a size similar to a phone); simply define a function called screenSizeChanged(oldDevice, newDevice), and if you don't define the function that is fine as the error will be caught.

function screenSizeChanged(oldDevice, newDevice){

    // oldDevice and newDevice are strings: 'phone', 'tablet', 'desktop' 

}

###FAQ

Why did you call it duplicity?

Because it is a framework to allow your website to have many faces (one for phones, another for tablets, and yet another for desktops).

duplicity's People

Contributors

tomasreimers avatar

Watchers

JT5D avatar James Cloos avatar  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.