rhammons' posterous.

New Google app shows how much of a website's content is "above the fold" | UX Magazine

Media_httpuxmagcomuploadsbrowsersizepng_ffcqladcwjegqii

Definitely one of the worst info-graphics I've ever come across. Could be useful.

Filed under  //   browsers   google   resolution   statistics   the fold   web development  

Control.Window : Windows, Modals, LightBoxes and Tooltips for Prototype

Class

ReturnNameDescription
Control.Windowopen([Element container [,Hash options]])Creates a window, opens it then returns it.
numberbaseZIndexDefaults to 9999.
arraywindowsReturns all windows, open or closed, in the order they were created.

Instance

ReturnNameDescription
Control.Windowinitialize([Element container [,Hash options]])See the tutorial for the different behaviors based on the lack of, or type of container passed.
nullbringToFront()
boolclose([Event])
nulldestroy()
nullensureInBounds()Redraws the window inside the viewport bounds if it is currently outside.
boolopen([Event])
nullposition([Event])Repositions the window.

Options

TypeNameDefaultDescription
mixedclassNamefalseClass name to apply to the container.
mixedcloseOnClickfalsefalse, string 'container', string 'overlay' or Element.
boolconstrainToViewportfalseIf draggable, the window will stay in bounds of the viewport. May not work with scrollable windows.
mixeddraggablefalseIf true, div.draggable_handle will be inserted into the container, which will become the draggable handle. If Element is passed, the element will become the handle.
boolfadefalse
numberfadeDuration0.75
mixedheightnullCan be null, number (in pixels), or function returning number.
mixedhoverfalseElement object to hover over, or if "true" only available for windows with sourceContainer (an anchor or any element already on the page with an href attribute).
booliframefalseIf the window has an href, this will display the href as an iframe instead of requesting the url as an an Ajax.Request.
booliframeshimtruePositions an iFrameShim underneath the window.
mixedindicatorfalsefalse or Element to show and hide when ajax requests, images and iframes are loading.
mixedinsertRemoteContentAtthis.containerElement to insert Ajax, IFrame or Lightbox content into. Can be string selector for this.container.down(), or an Element that must be a child of this.container.
mixedmaxHeightfalseFor resizable. Can be false or number in pixels.
mixedmaxWidthfalseFor resizable. Can be false or number in pixels.
mixedminHeightfalseFor resizable. Can be false or number in pixels.
mixedminWidthfalseFor resizable. Can be false or number in pixels.
mixedoffsetLeft0number x or function(){return x}
mixedoffsetTop0number y or function(){return y}
Hashparameters{}Will be passed to Ajax.Request if it is an Ajax window.
mixedposition'center'Can be string 'center', string 'relative' (to related element position), string 'mouse' (will follow the mouse), array [number x, number y] or array [function(){return x},function(){return y}]
mixedresizablefalseIf true, div.resizable_handle will be inserted into the container, which will become the resizable handle. If Element is passed, the element will become the handle.
mixedwidthnullCan be null, number (in pixels), or function returning number.

Events

NameDescription
afterClose()
afterDestroy()
afterInitialize()
afterOpen()
beforeClose()Throwing $break inside a callback will prevent the window from opening.
beforeOpen()Throwing $break inside a callback will prevent the window from opening.
bringToFront()
onComplete(object request)Ajax windows only.
onDrag()Draggable windows only.
onException(object request, object exception)Ajax windows only.
onFailure(object request)Ajax windows only.
onRemoteContentLoaded()Iframe, Ajax and LightBox windows will trigger this event.
onResize()Resizable windows only.
onSuccess(object request)Ajax windows only.

Control.Overlay Class

ReturnNameDescription
nullload()
nullhide()
nullshow()

Control.Overlay Events

NameDescription
afterHide()
afterShow()
beforeHide()Throwing $break will prevent the overlay from being hidden.
beforeShow()Throwing $break will prevent the overlay from being shown.

Control.Window Subclasses

All subclasses below inherit all of the methods, options and events from Control.Window.

Control.ToolTip Instance

ReturnNameDescription
Control.ToolTipinitialize(Element container [,mixed tooltip [,Hash options]])Tooltip can be a string, or an Element that is already on the page.

Control.Modal Class

ReturnNameDescription
nullclose()Closes current Modal if one is open.
Control.Modalopen([Element container [,Hash options]])
mixedcurrentFalse, or Control.Modal.

Control.Modal Instance

ReturnNameDescription
Control.Modalinitialize([Element container [,Hash options]])

Control.Modal Options

TypeNameDefaultDescription
numberoverlayOpacity0.5

Control.LightBox Instance

ReturnNameDescription
Control.LightBoxopen([Element container [,Hash options]])

Control.LightBox Options

TypeNameDefaultDescription
boolmodalfalseWill act as a Control.Modal instead of a Control.Window if true.

Interesting, possibly useful prototype based window control.

Filed under  //   javascript   prototype   web   web development   window  

Prototype JS: Change Input Style on Focus

This is some PrototypeJS (www.prototypejs.org) based JavaScript I threw together this morning to get input styles to change upon focus. From my brief stint of testing this works in IE6-8, FF3.5, Safari 4, and Google Chrome 3.  

In this example, you would end up getting input text boxes with an outline of #999 (grey) by default, and a slate blue #dbe2e9 upon focus or click.  Kind of handy, helps make the form a little more usable by adding more visual indication to the box. 

Javascript: 
function inputFocus() {
        var textInputs = $$('input[type="text"]');
        
        textInputs.each(function(textInput){
                textInput.observe('focus', function(event) {
                        textInput.addClassName('focus');
                });
                textInput.observe('blur', function(event){
                        textInput.removeClassName('focus');
                });
        });
}

CSS:
input {
        padding: 2px;
        border: 1px #999 solid;
}

input.focus {
        padding: 1px;
        border: 2px #dbe2e9 solid;
}

Filed under  //   css   form design   forms   javascript   prototype   style switcher   web development  

Simplest jQuery Slideshow - Snook.ca

Simplest jQuery Slideshow

A friend was looking at doing a simple slideshow. The requirements were very straightforward:

  • No animation controls. eg: play, stop.
  • Images should cross-fade.

Her instinct was to find an existing jQuery plug-in and revise it to work to her needs. That would seem simple enough but if you do a search for jQuery slideshows, you'll find that there are plenty of them and they are filled with plenty of functionality.

Using an existing plug-in wasn't very practical and hard to work with. I had even recommended a script that I, myself, had written but she quickly realized it didn't meet the requirements.

I put my thinking cap on and decided to write a script from scratch. "Under 20 lines," I exclaimed! In the end, it turned out much simpler than even I predicted.

(If you're a TL;DR kinda person, check out the demo.)

HTML and CSS

The HTML was very straightforward: a DIV with some IMGs in it.

<div class="fadein">  <img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg">  <img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg">  <img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg"></div>

In thinking about the CSS, I decided to just lock all the images into the same place using absolute positioning.

.fadein { position:relative; width:500px; height:332px; }.fadein img { position:absolute; left:0; top:0; }

jQuery Slideshow

Now to think about the slideshow. First, I knew that I'd want to hide all the images except the first one.

$('.fadein img:gt(0)').hide();

You have to remember that the image index starts at 0. That means that we want all images after the first one to be hidden.

Next, I need a setInterval to iterate through the images every few seconds.

setInterval(function(){ },3000);

From here, I started writing this out piece by piece to get what I wanted. I needed the first image to fade out.

$('.fadein :first-child').fadeOut()

After that, I need the next image to fade in.

.next('img').fadeIn()

Then I needed to take the first image and throw it onto the end of the stack.

.end().appendTo('.fadein')

The end() resets jQuery's internal reference back to the original selection. That way, it's the :first-child that I'm appending to the end of the .fadein element and not the next('img').

That's it?

Well, yes. That's it.

$(function(){
    $('.fadein img:gt(0)').hide();
    setInterval(function(){
      $('.fadein :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('.fadein');}, 
      3000);
});

Check out the demonstration page to this this little script in action.

Is there an even simpler way to do this? (Some ideas that I haven't tried: Is specifying img in next() necessary? Could I have used eq(0) instead of :first-child to save a couple bytes?)

Digging the utter simplicity of this, but it could definitely be enhanced performance and modularity wise.

Filed under  //   development   gallery   javascript   jquery   slideshow   web  

Determining a Path

I really want to like this Posterous thing, I do, but I’m not sure what my best approach at getting the most of it will be.  I already have a lifestream, at Apartment17.com and I have a personal portfolio site at RandyHammons.com so I want this to be different, a bit more obscure or niche, yet useful. So from here on out this is going to work as a technical morgue of ideas, code snippets, and random bits on the web that I find and enjoy.

 

Filed under  //   goals   history   origin  

Kevin Tong's Tranmissions

Media_httpfarm3staticflickrcom24984164977627a0143b8f11ojpg_ihrceyhszqgfviu

Amazing prints up for sale right now by Kevin Tong...

Filed under  //   art   black   gifts   kevin tong   posters   prints   red