Ajax
A Better Mobile Web; What else?
Cedric Dugas feels so passionate about fixed positioning in WebKit that he created A Better Mobile Web to talk about it:
The Problem
It is impossible to have an element fixed in CSS on the page in the mobile Webkit browser. When you are surfing the web on your phone, webkit opens the page completely and acts as a viewport.
“Imagine a book in front of you. Take a piece of paper, cut a 320*416 square in it, and lay it over the book. To read the book, move the paper around and position the hole over the words you want to see.” -Richard Herrera
Why it is important
To create better mobile applications and websites, we need fixed positionning to give the user better tools to browse the web on handled devices. Like a real mobile app, we could have a fixed toolbar when scrolling on a site, it is critical to not take the user in hostage in very long list or on long content pages. This is something we can’t really emulate in javascript as mobile devices are not really powerful.
The solution
The Webkit team could give us a proprietary CSS property that would overwrite the viewport behavior, and this is the proposition here. Give us a CSS property like position: -webkit-viewport-fixed that we can apply on a div so it can be fixed to the viewport.
That is one feature request, but surely there we can add to that? The broad domain of “abettermobileweb.com” deserves more!
What would you like to see for mobile specifically that isn’t covered in the current Web and device API standard work?
Do Your Employees Hate the IT Department?
A deep dive and analysis of the JavaScript Module pattern
Ben Cherry has a really nice detailed analysis of the module pattern.
He starts with the simple pattern that Crock-y documented back in the day..... and then goes on to discuss augmentation (loose and strict) and then deeper into some cool patterns:
Cloning and Inheritance
PLAIN TEXT JAVASCRIPT:- var MODULE_TWO = (function (old) {
- var my = {},
- key;
- for (key in old) {
- if (old.hasOwnProperty(key)) {
- my[key] = old[key];
- }
- }
- var super_moduleMethod = old.moduleMethod;
- my.moduleMethod = function () {
- // override method on the clone, access to super through super_moduleMethod
- };
- return my;
- }(MODULE));
This pattern is perhaps the least flexible option. It does allow some neat compositions, but that comes at the expense of flexibility. As I've written it, properties which are objects or functions will not be duplicated, they will exist as one object with two references. Changing one will change the other. This could be fixed for objects with a recursive cloning process, but probably cannot be fixed for functions, except perhaps with eval. Nevertheless, I've included it for completeness.
Cross-File Private State
One severe limitation of splitting a module across multiple files is that each file maintains its own private state, and does not get access to the private state of the other files. This can be fixed. Here is an example of a loosely augmented module that will maintain private state across all augmentations:
PLAIN TEXT JAVASCRIPT:- var MODULE = (function (my) {
- var _private = my._private = my._private || {},
- _seal = my._seal = my._seal || function () {
- delete my._private;
- delete my._seal;
- delete my._unseal;
- },
- _unseal = my._unseal = my._unseal || function () {
- my._private = _private;
- my._seal = _seal;
- my._unseal = _unseal;
- };
- // permanent access to _private, _seal, and _unseal
- return my;
- }(MODULE || {}));
Any file can set properties on their local variable _private, and it will be immediately available to the others. Once this module has loaded completely, the application should call MODULE._seal(), which will prevent external access to the internal _private. If this module were to be augmented again, further in the application's lifetime, one of the internal methods, in any file, can call _unseal() before loading the new file, and call _seal() again after it has been executed.
This pattern occurred to me today while I was at work, I have not seen this elsewhere. I think this is a very useful pattern, and would have been worth writing about all on its own.
Sub-modules
Our final advanced pattern is actually the simplest. There are many good cases for creating sub-modules. It is just like creating regular modules:
PLAIN TEXT JAVASCRIPT:- MODULE.sub = (function ()) {
- var my = {};
- // ...
- return my;
- }());
While this may have been obvious, I thought it worth including. Sub-modules have all the advanced capabilities of normal modules, including augmentation and private state.
Nice work Ben!
Does Social Media Really Work for Business?
So It’s Gonna Drizzle on Rackspace
CA Buys Nimsoft
Ambilight Sample; video and canvas
Sergey Chikuyonok gets his Philips Ambilight foo on as he created a HTML5 video + canvas sample that mimics the TV effect.
As the video runs, a snapshot is sent over to JavaScript land where colors are worked out:
PLAIN TEXT JAVASCRIPT:- function getMidColors(side) {
- var w = buffer.width,
- h = buffer.height,
- lamps = getOption('lamps'),
- block_width = getOption('block_size'),
- block_height = Math.ceil(h / lamps),
- pxl = block_width * block_height * 4,
- result = [],
- img_data = buffer_ctx.getImageData(side == 'right' ? w - block_width : 0, 0, block_width, h),
- total_pixels = img_data.data.length;
- for (var i = 0; i <lamps; i++) {
- var from = i * w * block_width;
- result.push( calcMidColor(img_data.data, i * pxl, Math.min((i + 1) * pxl, total_pixels - 1)) );
- }
- return result;
- }
Then, two canvas objects are placed, one on each side, of the video itself.
Mainstream IT Buys into Cloud Computing
Microsoft to Present at Cloud Expo East
YQL Geo library – all your geo needs in pure JavaScript
I just finished doing some talks on geo hacking (slides are available here) and how to use some of the Geo technologies Yahoo and Google provide as part of a University gig in Atlanta.
As a lot of the students liked the idea of APIs like GeoPlanet and Placemaker but had a hard time getting their head around them I thought it a good idea to build a small JavaScript library that does the job for them.
I give you the YQL Geo library (and its source on GitHub). Using this library you can do the following:
- Detecting the visitor's location with the W3C geo API and with IP as a fallback
- Find geo location from text
- Find location from lat/lon pair
- Find locations in a certain web document (by URL)
- Get the location for a certain IP number
And all of that in pure JavaScript. For example:
PLAIN TEXT JAVASCRIPT:- yqlgeo.get(
- 'paris,fr',
- function(o){
- console.log(o);
- }
- )
Will get you:
PLAIN TEXT JAVASCRIPT:- "place":{
- "lang":"en-US",
- "uri":"http://where.yahooapis.com/v1/place/615702",
- "woeid":"615702",
- "placeTypeName":{
- "code":"7",
- "content":"Town"
- },
- "name":"Paris",
- "country":{
- "code":"FR",
- "type":"Country",
- "content":"France"
- },
- "admin1":{
- "code":"",
- "type":"Region",
- "content":"Ile-de-France"
- },
- "admin2":{
- "code":"FR-75",
- "type":"Department",
- "content":"Paris"
- },
- "admin3":null,
- "locality1":{
- "type":"Town",
- "content":"Paris"
- },
- "locality2":null,
- "postal":null,
- "centroid":{
- "latitude":"48.856918",
- "longitude":"2.341210"
- },
- "boundingBox":{
- "southWest":{
- "latitude":"48.658291",
- "longitude":"2.086790"
- },
- "northEast":{
- "latitude":"49.046940",
- "longitude":"2.637910"
- }
- }
- }
Other uses:
This gets the name and the country of a lat/lon pair:
PLAIN TEXT JAVASCRIPT:- yqlgeo.get(33.748,-84.393,function(o){
- alert(o.place.name + ',' + o.place.country.content);
- })
This finds the visitor's location (on W3C geo API enabled browsers it asks them to share it - otherwise it detects the IP and locates this one on the planet)
PLAIN TEXT JAVASCRIPT:- yqlgeo.get('visitor',function(o){
- alert(o.place.name + ',' + o.place.country.content +
- ' (' + o.place.centroid.latitude + ',' +
- o.place.centroid.longitude + ')'
- );
- });
Read all about it on my blog and enjoy!
SVG Wow!
Erik Dahlström and Vincent Hardy have put together a cool website, called SVG Wow!, that showcases SVG doing things you didn't expect SVG can do:
There are alot of unique demos on there.
One of my favorites uses SVG, HTML5 Audio, Web Fonts, and YUI to play music accompanied by flying animated lyrics (Chrome and Safari only):
There are lots of other great samples for you to play with and study!
Ext JS 3.2 beta: stores, components, transitions, and themes
The Ext JS team have announced the 3.2 beta which includes new components and goodness.
Take the animated DataView transitions for example:
On top of that, the release includes:
- Multiple sorting and filtering on Ext.data.Store
- Composite Fields
- Slider improvements
- Toolbar plugins: ToolbarReorderer and ToolbarDroppable
- New Accessibility Theme: compliant with Section 508 of the Disabilities Act.
- Quality Assurance: Unit Testing: over 180 bug fixes and enhancements over 3.1
Unisys’s Scott Sanchez to Present at Cloud Expo East
Unisys to Present at Cloud Expo East
Cast Iron Promises Integration with Cloud Computing
Cordys MashApps Now Available Through the Google Apps Marketplace
CSS3 Please! Instant results… Thank You
Paul Irish and Jonathan Neal have created a fun example of various CSS tweaks that you can make, and see the results instantly.
CSS3, Please! lets you play with fancy new rules such as:
- border-radius
- box shadow
- gradients
- rgba support in backgrounds
- transforms
- font-face
Really nice way to make tweaks inline in the page..... nicely done. Hope to see some other examples out there :)
HTML Minification
Good old Kangax has been playing with HTML minification and has shared his new tool in an early stage.
What does it do?
Kangax has forked John Resig's HTML parser which parses the HTML and sends that into the Minifier. This has rules that do things like whitespace optimization, comment removal, and collapsing boolean attributes (e.g. disabled="true" -> disabled).
He also has a linter going:
While working on minifier, I realized that oftentimes the most wasteful part of the markup is not white space, comments or boolean attributes, but inline styles, scripts, presentational or deprecated elements and attributes. None of these can be simply stripped, as that could affect state of the document and is just too obtrusive. What can be done, however, is reporting of these occurences to the user. HTMLLint is even a smaller script, whose job is exactly that—to log any deprecated or presentational elements/attributes encountered during parsing. Additionally, it detects event attributes (e.g. onclick, onmouseover, etc.). The rationale for this is that moving contents of event attributes to external script allows to take advantage of resource caching.
Harmony: Canvas Drawing Tool
Harmony is a new drawing tool, a HTML5/Canvas experiment with great potential. It provides some unique brush styles, and can produce some great-looking charcoal pencil style sketches, among other things. Better to try it out than explain it in words.
Creator Mr. Doob (Richard Cabello) explains how he used Canvas to make it darker the more you draw over it:
The whole thing is quite modular so I can keep adding more brush styles whenever I get inspired. During the process I found out that, for some reason (apparently lack of hardware acceleration), Firefox and Opera do not support context.globalCompositeOperation = 'darker'. This was on the HTML5 spec before but got removed. Just so you know what I'm talking about, this is like the "multiply" blending in Photoshop. Webkit does support it tho. I hope they put it back on the specs and all browsers support it.
You can also save images using data URI encoding.
As it works on webkit, he made sure it worked on the mobile Android and iPhone browsers. No multi-touch as yet, but the touch UI still makes a nice input mechanism.
(Thanks FND)

Recent comments
20 weeks 3 days ago
30 weeks 18 hours ago
1 year 29 weeks ago
1 year 29 weeks ago
1 year 32 weeks ago
1 year 34 weeks ago
1 year 34 weeks ago
1 year 34 weeks ago