Responsive Javascript

13
Presented by your friends at Presented by your friends at Responsive Javascript Responsive Javascript in Drupal Sites in Drupal Sites

Transcript of Responsive Javascript

Page 1: Responsive Javascript

Presented by your friends atPresented by your friends at

Responsive JavascriptResponsive Javascriptin Drupal Sitesin Drupal Sites

Page 2: Responsive Javascript

About MeAbout Me

CEO of Trellon

on drupal.org@techsoldaten

Chief Internet Strategistfor Trellon

One of the first Drupal firms in North America

10+ years architecting large scale Drupal

environments

Passionate about scalability, third-party

integration, contributions

Responsive Javascript in Drupal Sites

Page 3: Responsive Javascript

Responsive JavascriptResponsive Javascript

Responsive Javascript in Drupal Sites

Scripts that run:

In specific browser dimensionsOn devices with specific capabilitiesCan be activated / removed in response to changesin device dimensions, including rotation

Page 4: Responsive Javascript

There's No One WayThere's No One Way

Responsive Javascript in Drupal Sites

Popular solutions. Each has benefits and drawbacks:

jQuery MobilejQuery FactoriesConditional javascript with @mediaJust using display: none and duplicating the markupwith a different selector

Page 5: Responsive Javascript

Why is This a DrupalWhy is This a DrupalProblem?Problem?

Responsive Javascript in Drupal Sites

Drupal has a lot of things that don't respond well to mobile.

CKEditor: Try using this on mobileViews Slideshow: No destroy methodBreakpoints: No integration outside theme

Page 6: Responsive Javascript

Recipe for ResponsiveRecipe for ResponsiveJavascriptJavascript

Responsive Javascript in Drupal Sites

jRespondDefine breakpoints in theme

ViewsJust views, no slideshows

Page 7: Responsive Javascript

jRespondjRespond

Allows you to set breakpoints

Responsive Javascript in Drupal Sites

<script> // adds breakpoints used by javascript var jRes = jRespond([ { label: 'handheld', enter: 0, exit: 640 },{ label: 'tablet', enter: 768, exit: 979 },{ label: 'desktop', enter: 1200, exit: 10000 } ]); </script>

Page 8: Responsive Javascript

jRespondjRespond

Allows you to set breakpoints

Responsive Javascript in Drupal Sites

<script> jRes.addFunc({ breakpoint: 'handheld', enter: function() { // turns on slideshows nav = showSlideshow('#slideshow'); }, }); function showSlideshow(item){ item.cycle(); }</script>

Structured around functionsthat fire when dimensionschange (instead of useractivity)

Page 9: Responsive Javascript

jRespondjRespond

Allows you to set breakpoints

Responsive Javascript in Drupal Sites

<script> jRes.addFunc({ breakpoint: 'handheld', enter: function() { // turns on slideshows nav = showSlideshow('#slideshow'); }, // here's my exit function exit: function() { // removes slideshows '#slideshow'.cycle('destroy'); }, }); function showSlideshow(item){ item.cycle(); }</script>

Code executes when usersenter and exit

Structured around functionsthat fire when dimensionschange (instead of useractivity)

Page 10: Responsive Javascript

ViewsViewsInstead of using a Views plug in to generate something,use responsive jQuery

Responsive Javascript in Drupal Sites

Page 11: Responsive Javascript

ExamplesExamplesLet's look at some sitesLet's look at some sites

Page 12: Responsive Javascript

Questions?

Page 13: Responsive Javascript

Thank you!https://github.com/ten1seven/jRespond

[email protected]/trellon