Include to favorites
Log in Logout Register
Start Login Contact Help Photos What's new
Avanced Search
FAQ
RESULTS IN: TEXT IMAGES
 

Hello, Guest
Login  Register
Online: 143 visitors

Blogging (2)
Business (1)
Educational (2)
Gadgets (1)
Games (8)
High Tech News (1)
Internet (1)
PC (2)
PDA (0)
Science (1)
Shopping (6)
Software (1)
Wireless (1)


Browse by date

<< May 2012 >>
MonTueWedThrFriSatSun
123456
78910111213
14151617181920
21222324252627
28293031




Recent searches

Popular searches

Hot this month

Weblogs Archive


GADGETS AND GAMES DIRECTORY :: > Software Register Weblog >  Software Tech Weblogs - WEEKLYBITS.COM GADGETS AND GAMES DIRECTORY
Yahoo User Interface Blog
generated by http://wordpress.org/?v=3.0.4  en Blogger
SEND A FRIEND
Suscribing to  please login first
User: Login

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications.
News and Articles about Designing and Developing with Yahoo! Libraries.Visit Yahoo! User Interface Blog
Address URLhttp://www.yuiblog.com/blog    Registered: 26-Apr-2008
Ads:

Send to email
Visit ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids in Development
By Christian Heilmann
el 25-Jun-2008

I love YUI Grids. I know my CSS and I know how to work around different problems of browsers, but I am also very much bored about having to fix and test and create these workarounds over and over again. While YUI Grids might not be perfect for all cases of web development out there, I am happy to take a pragmatic approach and just create sites that can be done with them (now you also know why I am not a designer).

One problem I keep having when I put some YUI Grids-based sites live is that people complain about me expecting a certain screen resolution or viewport size. YUI grids can either be 100% wide, which can be pretty silly on high resolutions, or optimized for resolutions of either 800×600 or 1024×768. When you optimize for 800 pixels people on higher resolutions will complain about the length of the page and when you go for 1024 people will say they have to scroll to see your side-bar on 800×600. You can’t win.

Or can you? CSS is not dynamic — it has a fixed state and you can only hope that the browser does the right thing with what you give it (well, there are conditional comments for IE, but technically they are HTML, and of course there are media queries in CSS3 and other goodies, but for the sake of the argument let’s say supporting IE6 is a base). JavaScript, on the other hand, is very dynamic and you can read out and check what is happening to the browser currently in use and react to it.

Putting this feature of JavaScript to good use you can create a YUI-Grids-based layout that remains flexible and changes according to needs. All you need to do is use some YUI Dom magic and change IDs and classes accordingly.

YUI Grids come in several flavours of overall width, defined by the ID on the container DIV:

  • #doc - 750px centered (good for 800×600)
  • #doc2 - 950px centered (good for 1024×768)
  • #doc3 - 100% fluid (good for everybody)
  • #doc4 - 974px fluid (good for 1024×768)
  • #doc-custom - custom width

One thing to remember here is that even doc3 has a minimum width of 750 pixels, which is why for a fully flexible grid you need to override that:

#doc3{
  min-width:0;
}

Inside the container DIV you can have two blocks, and their width and the position of the side bar is defined by the class on the container DIV:

  • .yui-t1 - Two columns, narrow on left, 160px
  • .yui-t2 - Two columns, narrow on left, 180px
  • .yui-t3 - Two columns, narrow on left, 300px
  • .yui-t4 - Two columns, narrow on right, 180px
  • .yui-t5 - Two columns, narrow on right, 240px
  • .yui-t6 - Two columns, narrow on right, 300px

Putting these together you can create a plan for your flexible grid:

  • When the available screen space is larger than 950 pixels, use doc2 and the widest sidebar — either left or right
  • If you have less than 950 pixels, use doc and the medium size sidebars
  • If you have less than 760 pixels, use doc3 and the smallest sidebars
  • If you have even less — say 600 pixels — at your disposal, show the side bar below the main content

The script to allow for this is not really rocket science. All it needs to do is read out the grids settings, the width of the available browser window and then change the IDs and classes accordingly.

YAHOO.example.autoGrid = function(){
  var container = YAHOO.util.Dom.get('doc') ||
                  YAHOO.util.Dom.get('doc2') ||
                  YAHOO.util.Dom.get('doc4') ||
                  YAHOO.util.Dom.get('doc3') ||
                  YAHOO.util.Dom.get('doc-custom');
  if(container){
    var sidebar = null;
    var classes = container.className;
    if(classes.match(/yui-t[1-3]|yui-left/)){
       var sidebar = 'left';
    }
    if(classes.match(/yui-t[4-6]|yui-right/)){
       var sidebar = 'right';
    }
    function switchGrid(){
      var currentWidth = YAHOO.util.Dom.getViewportWidth();
      if(currentWidth > 950){
        container.id = 'doc2';
        if(sidebar){
          container.className = sidebar === 'left' ? 'yui-t3' : 'yui-t6';
        }
      }
      if(currentWidth < 950){
        container.id = 'doc';
        if(sidebar){
          container.className = sidebar === 'left' ? 'yui-t2' : 'yui-t5';
        }
      }
      if(currentWidth < 760){
        container.id = 'doc3';
        if(sidebar){
          container.className = sidebar === 'left' ? 'yui-t1' : 'yui-t4';
        }
      }
      if(currentWidth < 600){
        container.id = 'doc3';
        container.className = '';
      }
    };
    switchGrid();
    /*
      Throttle by Nicholas Zakas to work around MSIE's resize nasties.
      http://www.nczonline.net/blog/2007/11/30/the_throttle_function
    */
    function throttle(method, scope) {
      clearTimeout(method._tId);
        method._tId= setTimeout(function(){
        method.call(scope);
      }, 100);
    };
    YAHOO.util.Event.on(window,'resize',function(){
      throttle(YAHOO.example.autoGrid.switch,window);
    });

  };
  return {
    switch:switchGrid
  };
}();

Let’s go through it step by step:

YAHOO.example.autoGrid = function(){
  var container = YAHOO.util.Dom.get('doc') ||
                  YAHOO.util.Dom.get('doc2') ||
                  YAHOO.util.Dom.get('doc4') ||
                  YAHOO.util.Dom.get('doc3') ||
                  YAHOO.util.Dom.get('doc-custom');
  if(container){

First we check if there is actually a YUI Grid in the current document, by testing for the presence of the correct IDs. If there is, we execute the rest of the code.

    var sidebar = null;
    var classes = container.className;
    if(classes.match(/yui-t[1-3]|yui-left/)){
       var sidebar = 'left';
    }
    if(classes.match(/yui-t[4-6]|yui-right/)){
       var sidebar = 'right';
    }

We define sidebar as null, retrieve the class name of the container element and check if there was a column structure defined. In addition to the preset YUI Grids classes we also defined yui-left and yui-right here. These styles allow you to not have a sidebar without the script functionality but to get one once the script determines that there is enough space for one.

    function switchGrid(){
      var currentWidth = YAHOO.util.Dom.getViewportWidth();
      if(currentWidth > 950){
        container.id = 'doc2';
        if(sidebar){
          container.className = sidebar === 'left' ? 'yui-t3' : 'yui-t6';
        }
      }
      if(currentWidth < 950){
        container.id = 'doc';
        if(sidebar){
          container.className = sidebar === 'left' ? 'yui-t2' : 'yui-t5';
        }
      }
      if(currentWidth < 760){
        container.id = 'doc3';
        if(sidebar){
          container.className = sidebar === 'left' ? 'yui-t1' : 'yui-t4';
        }
      }
      if(currentWidth < 600){
        container.id = 'doc3';
        container.className = '';
      }
    };
    switchGrid();

The method switchGrid() does all the work we defined. We set up the different cases for applying IDs and classes and call the method immediately after it’s been defined.

    /*
      Throttle by Nicholas Zakas to work around MSIE's resize nasties.
      http://www.nczonline.net/blog/2007/11/30/the_throttle_function
    */
    function throttle(method, scope) {
      clearTimeout(method._tId);
        method._tId= setTimeout(function(){
        method.call(scope);
      }, 100);
    };
    YAHOO.util.Event.on(window,'resize',function(){
      throttle(YAHOO.example.autoGrid.switch,window);
    });

For full flexibility, we also apply an event listener that re-checks the grid specifications when the user resizes the browser. As Internet Explorer has a nasty habit of firing the resize event while the user resizes the window, we need to throttle the execution of switchGrid(). This is explained in detail on Nicholas Zakas’ blog.

  };
  return {
    switch:switchGrid
  };
}();

As the throttle method needs a public method to call from setTimeout() we return a pointer to switchGrid.

That’s all. You can try out the effect on the demonstration page. If you define your sidebar independent of size, you can create some wonderfully dynamic and flexible sites with this little script.



Read 55 times

Suscribing to  please login first
?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids -  Tech Weblogs - WEEKLYBITS.COM  Blogger Is a collection of i

Photologs

Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
I love YUI Grids. I know my CSS and I know how to work around different problems of browsers, but I am also very much bored about having to fix and test and create these workarounds over and over again. While YUI Grids might not be perfect for all cases of web development out there, [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 25-Jun-2008 by Christian Heilmann in Development
Read 55 times. More hits in More articles ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids Images about ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

A YUI Grids-based WordPress Theme ? YUI Autogrid Minimal
As I had to upgrade my personal blog to the newest WordPress version (and my old theme had been hacked to death), I chose to start from scratch with a WordPress theme. [You can download the new theme here.] As I am a lazy person and I think blogging is first and foremost about content and availability, [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 02-Jul-2008 by Christian Heilmann in Development
Read 56 times. More hits in More articles A YUI Grids-based WordPress Theme ? YUI Autogrid Minimal Images about A YUI Grids-based WordPress Theme ? YUI Autogrid Minimal
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

More Accessible YUI Grids Layouts with ARIA Landmark Roles
Click here to read WarioWare: D.I.Y. Review: Homebrewed Improvement - WarioWare: D.I.Y. Review: Homebrewed Improvement [Review] YUI Grids CSS has long been an important tool for developers wishing to create more accessible layouts. Through its support of source-order independent layouts, Grids enables control of the reading order of a page, allowing developers to place the most important content higher in the markup so that it can be quickly discovered by users [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 05-Mar-2009 by Todd Kloots in AccessibilityDevelopment
Read 25 times. More hits in More articles More Accessible YUI Grids Layouts with ARIA Landmark Roles Images about More Accessible YUI Grids Layouts with ARIA Landmark Roles
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

YUI 3.2.0 Preview Release 1: Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More
The YUI contributor’s team is pleased to announce the first developer preview of the upcoming YUI 3.2.0 release. This preview provides an opportunity for developers and implementers to help test the release for potential regressions and to provide feedback on new features and components. If you have an existing YUI implementation, please exercise [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 26-Jul-2010 by Eric Miraglia in DevelopmentyuiYUI 3
Read 33 times. More hits in More articles YUI 3.2.0 Preview Release 1: Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More Images about YUI 3.2.0 Preview Release 1: Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

YUI 3.2.0 Released: SimpleYUI, Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More
Intrinsic touch support in YUI 3.2.0 brings touch support to a wide range of YUI-powered interactions, including Drag and Drop and Slider. - YUI 3.2.0 Released: SimpleYUI, Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More The YUI team is pleased to announce the GA release of YUI 3.2.0, a significant update to YUI’s JavaScript and CSS components. This release features a host of performance improvements and major new support for mobile devices with touch UIs. The Gesture module in YUI 3.2.0 brings touch support to a wide range of YUI-powered [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 07-Sep-2010 by Eric Miraglia in Development
Read 45 times. More hits in More articles YUI 3.2.0 Released: SimpleYUI, Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More Images about YUI 3.2.0 Released: SimpleYUI, Touch Event Support, Gestures, Transitions, CSS Grids, ScrollView, Uploader, and More
Thoughts From Kansas Blogger

Weblog of a University of Kansas ecology and evolutionary biology student, fighting for progressive politics, evolution, and endangered species.
Thoughts from Kansas You will notice that it lacks definiteness; that it lacks purpose; that it lacks coherence; that it lacks a subject to talk about; that it is loose and wabbly; that it wanders around; that

Irrationality is adaptive?
I'm not a cognitive scientist, so I'll be curious to see what the blog commentary on this paper might say, but apparently people get smarter when they think about things that don't make sense. Whether or not irrational beliefs are epistemically compatible with science, this would suggest that they are cognitively helpful for the practice of science. Basically, the researchers had some [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 14-Oct-2009 by Thoughts in Policy and Politics
Read 29 times. More hits in More articles Irrationality is adaptive? Images about Irrationality is adaptive?
Kotaku`s The Gamers Guide Blogger

XBOX 360 Gamers Weblog Gossip, news and leaks for obsessive gamers Kotaku As if you don't waste enough of your time in a gamer's haze, here's Kotaku: a gamer's guide that goes beyond the press release. Gossip, cheats, criticism, design, nostalgia, pred

Be Aggressive, Be Stealthy, Be Adaptive In Deus Ex: Human Revolution [Video]
Click here to read Be Aggressive, Be Stealthy, Be Adaptive In <em>Deus Ex: Human Revolution</em> - Be Aggressive, Be Stealthy, Be Adaptive In Deus Ex: Human Revolution [Video] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 24-Mar-2011 by Michael McWhertor in VideoDeus Exdeus ex human revolutionEidos MontrealPCPS3Square EnixXbox 360
Read 12 times. More hits in More articles Be Aggressive, Be Stealthy, Be Adaptive In Deus Ex: Human Revolution [Video] Images about Be Aggressive, Be Stealthy, Be Adaptive In Deus Ex: Human Revolution [Video]
The Boy Genius Report Blogger

The gadgets and technology weblog
Boy Genius Report

Adaptive Path chimes in on Mozilla Phone concept with Aurora browser
Well folks, we have good news and bad news. The bad news is that Mozilla has clarified what many miscontrued from a post earlier this week. We all knew the Mozilla Phone concept Billy May showed off last week was simply a throw away but what many didn?t catch from the wording of the post, [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 07-Feb-2009 by Zach Epstein in HandsetsSoftwareAdaptive PathauroraBlackBerryMozillaMozilla PhoneOLEDOptimus MaximusphoneSmartphone
Read 38 times. More hits in More articles Adaptive Path chimes in on Mozilla Phone concept with Aurora browser Images about Adaptive Path chimes in on Mozilla Phone concept with Aurora browser
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Non-blocking JavaScript Downloads
Stoyan Stefanov. - Non-blocking JavaScript Downloads About the Author: Stoyan Stefanov is a Yahoo! web developer working for the Exceptional Performance team and leading the development of the YSlow performance tool. He also an open-source contributor, conference speaker and technical writer: his latest book is called Object-Oriented JavaScript. External JavaScript files block downloads and hurt your page performance, but there is an [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 22-Jul-2008 by Stoyan Stefanov in DevelopmentPerformance
Read 39 times. More hits in More articles Non-blocking JavaScript Downloads Images about Non-blocking JavaScript Downloads
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Production JavaScript Debugging
Setting up Firefox You know the scenario. A bug is filed for a JavaScript issue in production. You update your development server to the same files (allegedly) that are in production but you can’t reproduce the issue. Debugging your JavaScript code is horrifically difficult, if not impossible, because you’re following best practices and crunching the file using the YUI Compressor. You start [...] [..] Read complete article
Subscribe to ?AutoGrid? for YUI Grids ? Using JavaScript to Create Adaptive Grids
Published 27-Jun-2008 by Nicholas C. Zakas in Development
Read 31 times. More hits in More articles Production JavaScript Debugging Images about Production JavaScript Debugging

Warning We are not responsible of information posted from external feeds. Use this website at your own risk. Notice: We will not be liable for any direct or indirect loss or damage arising under this disclaimer or in connection with our website, whether arising in tort, contract, or otherwise.


Your Site here Your Site here Your site here Your site here Your site here