XUI

Basic Selector

x$(‘a.foo > li’);

Other Selectors

x$(window);                         // The Window
x$(element);                        // An Existing Element  
x$('ul#globalnav li a.selected');   // A CSS3 Selector
x$(['li','div#foo']);               // An Array of Selectors
x$('li','.selected','#some_id');    // A comma list of CSS3 Selectors

Select Extended

Given
<ul>
  <li class="foo">one</li>
  <li>two</li>
  <li class="foo baz">three</li>
  <li>four</li>
  <li>five</li>
</ul>


Yields
x = x$("ul li").not('.foo'); // returns two, four, and five
x = x$("ul li").has('.foo'); // returns one and three

Dom Basics

Dom 1

inner / outer

x$("ul li").inner('Hello World');  // replaces all items with Hello World
x$("p").outer('<b>Hello</b>'); // replaces p with b

Dom 2

top / bottom

<ul>
  <li>one</li>
  <li>two</li>
</ul>

x$("ul").top('zero');
x$("ul").bottom('<li>Three</li>');


<ul>
  <li>zero</li>
  <li>one</li>
  <li>two</li>
  <li>three</li>  
</ul>

Dom 3

before / after

<ul>
  <li>one</li>
  <li>two</li>
</ul>

x$("ul").before('<h1>My List</h1>');
x$("ul").after('<p>Thanks</p>');


<h1>My List</h1>
<ul>
  <li>one</li>
  <li>two</li> 
</ul>
<p>Thanks</p>

Dom 4

remove

<ul>
  <li id="one">one</li>
  <li>two</li>
</ul>

x$("#one").remove();


<ul>
  <li>two</li> 
</ul>

Style Basics

getStyle / addClass / removeClass / css
<p style="padding-left:20px;">Testing getStyle</p>

x$("p").getStyle('padding-left');  // returns 20px

x$("p").addClass('selected');

x$("p").removeClass('selected');

x$("p").css({'color':'red','height':'100px'});

XHR

XMLHttpRequest
  
    x$('node').xhr(url, options);
  
x$("#tweets").xhr('_tweets.html');

XHR 2

call me back!
var doThis = function() {
  console.log(this.responseText);
}

x$(window).xhr('test.html', {callback: doThis });

XHR 3

post
var doThis = function() {
  console.log(this.responseText);
}

x$(window).xhr('http://myserver.com/post.php', {
    method:'post', 
    data:'comment=win&id=12', 
    callback: doThis 
    });

XHR 4

advanced
json.txt results
{'username':'silentrob','age':'29'}


x$(window).xhrjson( 'json.txt', {
  map:{'username':'#name', 'age':'#age'}
});


<span id="name">silentrob</span>
<span id="age">29</span>

Event Basics

on anything
  x$('button').on( 'click', function(e){ alert('hey that tickles!') });


do anything
  x$('button').click(function(e){ alert('hey that tickles!') });

Event 2

Supported Events
* click
* load
* touchstart
* touchmove
* touchend
* touchcancel
* gesturestart
* gesturechange
* gestureend
* orientationchange

Effects

css transformation
x$('#fx').tween({
	background:'red',
	duration:1.5
});

Effects 2

css animation
x$('#fx').tween({
	by:[100,100], // X,Y
	duration:1.5
});

Debugging

Resources

http://www.xuijs.com


http://phonegap-docs.smart.joyent.com/


http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/InteractiveVisualEffects/InteractiveVisualEffects.html

Cleanup Phonegap Manifest – This is because it shows up in store, and you don’t need everything
Remove Android Debug = true in manifest
Right Click on Src and rename com.phonegap.demo use refactor >> rename command
In Strings.xml change the app_name