-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxui.js
1124 lines (1030 loc) · 28.4 KB
/
xui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* @projectDescription XUI JavaScript library for mobile web applications.
*
* @author Rob Ellis [email protected]
* @author Brian LeRoux [email protected]
* @author Brock Whitten [email protected]
*
* @version 0.1
*
* XUI
* ===
*
* A simple javascript framework for building mobile web applications.
* ---
*
* ### WHY?!
*
* We hear your words. _Why another JavaScript framework?!_ When development of PhoneGap was under way we noticed slow
* load times for modern JavaScript frameworks (such as Prototype, MooTools, YUI, Ext and (yes) even jQuery.
* A big reason why these libraries are so big is because is mostly they contain a great deal of cross browser
* compatability code. The mobile space has less browser implementations (so far) and different needs. Thus XUI.
*
* XUI strives to be a framework for first class mobile device browsers such as WebKit, Fennec and Opera with future
* support under consideration for IE Mobile and BlackBerry.
*
* ### Authors
*
* - Rob Ellis
* - Brock Whitten
* - Brian LeRoux
*
* ### Download
*
* Minified code is less than 6k!
*
* ### Contribute
*
* Clone the source from GitHub:
*
* git clone git://github.com/brianleroux/xui.git
*
* To build xui: run _rake_ in the shell of your choice from the root of the project directory. (This requires Ruby.)
* There are other tasks for code minification, running the specs and generating docs. Run `rake -T` to see them all.
*
* Check out the _example_ directory for a comprehensive example application. Specs are in the _spec_ directory.
*
* API Documentation
* ===
*
* Welcome the XUI documentation. This is generated from inline documentation in the XUI javascript source.
*
*
*
* Basics
* ---
*
* XUI is available to the entire document as x$. It is a function, that accepts a query selector. The syntax is
* mostly chainable and should be familiar to anyone who has worked with jQuery.
*
* x$('a.navigation').css({ background:'blue' });
*
* The query selection engine is based on the browser implementation of querySelectorAll so its fast. Real fast.
* XUI allows for a single expression, an element or an array of elements to be passed
*
* x$(window);
*
* x$('ul#globalnav li a.selected');
*
* x$('li', 'div#foo');
*
* x$(['li', 'div#foo']);
*
*/
var xui;
(function() {
var undefined;
var xui = function(q) {
q = q || document;
return this.find(q);
},
idExpr = /^#([\w-]+)$/;
xui.extend = function(obj) {
var original = this.prototype;
var extended = obj;
for (var key in (extended || {})) original[key] = extended[key];
return original;
};
xui.prototype = {
elements:[],
find: function(q) {
var ele = [];
var qlen = q.length;
var list, size;
var i, j;
if (typeof q == 'string' && idExpr.test(q)) {
this.elements.push(document.getelementsById(q));
return this;
}
for(i = 0; i < qlen; i++ ) {
if (typeof q[i] == 'string' ) { // one selector
list = document.querySelectorAll(q[i]);
size = list.length;
for(j = 0; j < size; j++ ) {
ele.push(list[j]);
}
} else {
if (q[i] instanceof Array) { // an array of selectors
for (var x = 0; x < q[i].length; x++) {
list = document.querySelectorAll(q[i][x]);
size = list.length;
for(j = 0; j < size; j++ ) {
ele.push(list[j]);
}
}
} else {
ele.push(q[i]); // an element
}
}
}
this.elements = this.elements.concat(this.reduce(ele));
return this;
},
/**
* Array Unique
*/
reduce: function( el, b ) {
var a = [], i, l = el.length;
for( i=0; i<l; i++ ) {
if( a.indexOf( el[i], 0, b ) < 0 ) { a.push( el[i] ); }
}
return a;
},
/**
* Array Remove - By John Resig (MIT Licensed)
*/
removex: function(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
},
/**
* Has modifies the elements array and reurns all the elements that match (has) a CSS Query
*/
has: function(q) {
var t = [];
this.each(function(el){
x$(q).each(function(hel) { if (hel == el) { t.push(el); } });
});
this.elements = t;
return this;
},
/**
* Not modifies the elements array and reurns all the elements that DO NOT match a CSS Query
*/
not: function(q) {
var list = this.elements;
for (var i = 0; i<list.length;i++) {
x$(q).each(function(hel){
if (list[i] == hel ) {
this.elements = this.removex(list,list.indexOf(list[i]));
}
});
}
return this;
},
/**
* Adds more DOM nodes to the existing element list.
*/
add: function(q) {
this.find([q]);
this.elements = this.reduce(this.elements);
return this;
},
/**
* Returns the first element in the collection.
*
* @return {Element} Returns a single DOM element.
*/
first: function() {
return this.get(0);
},
/**
* Returns the element in the collection at the
* given index
*
* @return {Element} Returns a single DOM element
* */
get: function(index) {
return this.elements[index];
},
/**
* Returns a collection containing the element
* at the given index
* */
eq: function(idx1,idx2) {
idx2 = idx2 ? idx2 + 1 : idx1 + 1;
this.elements = this.elements.slice(idx1,idx2);
return this;
},
/**
* Returns the size of the collection
*
* @return {Number} Returns an integer size of collection
* */
size: function() {
return this.elements.length;
},
/**
* Element iterator.
*
* @return {XUI} Returns the XUI object.
*/
each: function(fn) {
for (var i = 0, len = this.elements.length; i<len; ++i) {
if (fn.call(this, this.elements[i]) === false) {
break;
}
}
return this;
}
};
var libs = [];
/**
*
* @namespace {Dom}
* @example
*
* Dom
* ---
*
* Manipulating the Document Object Model aka the DOM.
*
*/
var Dom = {
inner: function(html) {
return this.html('inner', html);
},
outer: function(html) {
return this.html('outer', html);
},
top: function(html) {
return this.html('top', html);
},
bottom: function(html) {
return this.html('bottom', html);
},
remove: function() {
return this.html('remove');
},
before: function(html) {
return this.html('before', html);
},
after: function(html) {
return this.html('after', html);
},
/**
* For manipulating HTML markup in the DOM.
*
* @method
* @param {location} [inner|outer|top|bottom|remove|before|after]
* @param {html} A string representation of HTML markup.
* @return {Element Collection}
* @example
*
* ### html
*
* Adds elements or changes the content of an element on a page. This method has shortcut aliases:
*
* - inner
* - outer
* - top
* - bottom
* - remove
* - before
* - after
*
* syntax:
*
* x$(window).html( location, html );
*
* or this method will accept just an html fragment with a default behavior of inner..
*
* x$(window).html( htmlFragment );
*
* arguments:
*
* - location:string can be one of inner, outer, top, bottom
* - html:string any string of html markup or HTMLElement
*
* example:
*
* x$('#foo').html( 'inner', '<strong>rock and roll</strong>' );
* x$('#foo').html( 'outer', '<p>lock and load</p>' );
* x$('#foo').html( 'top', '<div>bangers and mash</div>');
* x$('#foo').html( 'bottom', '<em>mean and clean</em>');
* x$('#foo').html( 'remove');
* x$('#foo').html( 'before', '<p>some warmup html</p>');
* x$('#foo').html( 'after', '<p>more html!</p>');
*
* or
*
* x$('#foo').html('<p>sweet as honey</p>');
*
*/
html: function(location, html) {
var getTag = function(el) {
if (el.firstChild === null) {
switch (el.tagName) {
case 'UL':
return 'LI';
case 'DL':
return 'DT';
case 'TR':
return 'TD';
default:
return el.tagName;
}
}
return el.firstChild.tagName;
};
var wrap = function(xhtml, tag) {
var attributes = {};
var re = /^<([A-Z][A-Z0-9]*)([^>]*)>(.*)<\/\1>/i;
if (re.test(xhtml)) {
result = re.exec(xhtml);
tag = result[1];
if (result[2] !== "") {
var attrList = result[2].split(/([A-Z]*\s*=\s*['|"][A-Z0-9:;#\s]*['|"])/i);
for (var i = 0; i < attrList.length; i++) {
var attr = attrList[i].replace(/^\s*|\s*$/g, "");
if (attr !== "" && attr !== " ") {
var node = attr.split('=');
attributes[node[0]] = node[1].replace(/(["']?)/g, '');
}
}
}
xhtml = result[3];
}
var element = document.createElement(tag);
for (var x in attributes) {
var a = document.createAttribute(x);
a.nodeValue = attributes[x];
element.setAttributeNode(a);
}
element.innerHTML = xhtml;
return element;
};
this.clean();
if (arguments.length == 0) {
return this.elements[0].innerHTML;
}
if (arguments.length == 1 && arguments[0] != 'remove') {
html = location;
location = 'inner';
}
this.each(function(el) {
switch (location) {
case "inner":
if (typeof html == 'string') {
el.innerHTML = html;
var list = el.getElementsByTagName('SCRIPT');
var len = list.length;
for (var i = 0; i < len; i++) {
eval(list[i].text);
}
} else {
el.innerHTML = '';
el.appendChild(html);
}
break;
case "outer":
if (typeof html == 'string') {
html = wrap(html, getTag(el));
}
el.parentNode.replaceChild(html, el);
break;
case "top":
if (typeof html == 'string') {
html = wrap(html, getTag(el));
}
el.insertBefore(html, el.firstChild);
break;
case "bottom":
if (typeof html == 'string') {
html = wrap(html, getTag(el));
}
el.insertBefore(html, null);
break;
case "remove":
var parent = el.parentNode;
parent.removeChild(el);
break;
case "before":
var parent = el.parentNode;
if (typeof html == 'string') {
html = wrap(html, getTag(parent));
}
parent.insertBefore(html, el);
break;
case "after":
var parent = el.parentNode;
if (typeof html == 'string') {
html = wrap(html, getTag(parent));
}
parent.insertBefore(html, el.nextSibling);
break;
}
});
return this;
},
/**
* Removes all erronious nodes from the DOM.
*
* @method
* @return {Element Collection}
* @example
*
* ### clean
*
* Walks the Element Collection removing empty nodes and whitespace.
*
* syntax:
*
* x$(selector).clean();
*
* example:
*
* x$(window).clean();
*/
clean: function() {
var ns = /\S/;
this.each(function(el) {
var d = el,
n = d.firstChild,
ni = -1;
while (n) {
var nx = n.nextSibling;
if (n.nodeType == 3 && !ns.test(n.nodeValue)) {
d.removeChild(n);
} else {
n.nodeIndex = ++ni;
}
n = nx;
}
});
return this;
},
/**
* Attribute getter/setter
*
* @method
* @param {String} attributeName
* @param {String} attributeValue
* @return {Element Collection|String}
* */
attr: function(attribute, val) {
if (arguments.length == 2) {
this.each(function(el) {
el.setAttribute(attribute, val);
});
return this;
} else {
var attrs = [];
this.each(function(el) {
if (el.getAttribute(attribute) != null)
attrs.push(el.getAttribute(attribute));
});
return attrs;
}
}
};
libs.push(Dom);
/**
*
* @namespace {Event}
* @example
*
* Event
* ---
*
* A good old fashioned event handling system.
*
*/
var Event = {
click: function(fn) { return this.on('click', fn); },
load: function(fn) { return this.on('load', fn); },
submit: function(fn) { return this.on('submit', fn); },
touchstart: function(fn) { return this.on('touchstart', fn); },
touchmove: function(fn) { return this.on('touchmove', fn); },
touchend: function(fn) { return this.on('touchend', fn); },
touchcancel: function(fn) { return this.on('touchcancel', fn); },
gesturestart: function(fn) { return this.on('gesturestart', fn); },
gesturechange: function(fn) { return this.on('gesturechange', fn); },
gestureend: function(fn) { return this.on('gestureend', fn); },
orientationchange: function(fn) { return this.on('orientationchange', fn); },
/**
*
* Register callbacks to DOM events.
*
* @method
* @param {Event} The event identifier as a string.
* @param {Function} The callback function to invoke when the event is raised.
* @return {Element Collection}
* @example
*
* ### on
*
* Registers a callback function to a DOM event on the element collection.
*
* This method has shortcut aliases for:
*
* - click
* - load
* - touchstart
* - touchmove
* - touchend
* - touchcancel
* - gesturestart
* - gesturechange
* - gestureend
* - orientationchange
*
* For more information see:
*
* - http://developer.apple.com/webapps/docs/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/chapter_7_section_1.html#//apple_ref/doc/uid/TP40006511-SW1
*
* syntax:
*
* x$('button').on( 'click', function(e){ alert('hey that tickles!') });
*
* or...
*
* x$('a.save').click(function(e){ alert('tee hee!') });
*
* arguments:
*
* - type:string the event to subscribe to click|load|etc
* - fn:function a callback function to execute when the event is fired
*
* example:
*
* x$(window).load(function(e){
* x$('.save').touchstart( function(evt){ alert('tee hee!') }).css(background:'grey');
* });
*
*/
on: function(type, fn) {
var listen = function(el) {
if (window.addEventListener) {
el.addEventListener(type, fn, false);
}
};
this.each(function(el) {
listen(el);
});
return this;
}
};
libs.push(Event);
/**
*
* @namespace {Style}
* @example
*
* Style
* ---
*
* Anything related to how things look. Usually, this is CSS.
*
*/
var Style = {
/**
*
* Sets a single CSS property to a new value.
*
* @method
* @param {String} The property to set.
* @param {String} The value to set the property.
* @return {Element Collection}
* @example
*
* ### setStyle
*
* syntax:
*
* x$(selector).setStyle(property, value);
*
* arguments:
*
* - property:string the property to modify
* - value:string the property value to set
*
* example:
*
* x$('.txt').setStyle('color', '#000');
*
*/
setStyle: function(prop, val) {
this.each(function(el) {
el.style[prop] = val;
});
return this;
},
/**
*
* Retuns a single CSS property. Can also invoke a callback to perform more specific processing tasks related to the property value.
*
* @method
* @param {String} The property to retrieve.
* @param {Function} A callback function to invoke with the property value.
* @return {Element Collection}
* @example
*
* ### getStyle
*
* syntax:
*
* x$(selector).getStyle(property, callback);
*
* arguments:
*
* - property:string a css key (for example, border-color NOT borderColor)
* - callback:function (optional) a method to call on each element in the collection
*
* example:
*
* x$('ul#nav li.trunk').getStyle('font-size');
*
* x$('a.globalnav').getStyle( 'background', function(prop){ prop == 'blue' ? 'green' : 'blue' });
*
*/
getStyle: function(prop, callback) {
var gs = function (el,p) {
return document.defaultView.getComputedStyle(el , "").getPropertyValue(p);
};
if(callback === undefined) {
return gs(this.first(),prop);
}
this.each( function(el) {
callback(gs(el,prop));
});
return this;
},
/**
*
* Adds the classname to all the elements in the collection.
*
* @method
* @param {String} The class name.
* @return {Element Collection}
* @example
*
* ### addClass
*
* syntax:
*
* $(selector).addClass(className);
*
* arguments:
*
* - className:string the name of the CSS class to apply
*
* example:
*
* $('.foo').addClass('awesome');
*
*/
addClass: function(className) {
var that = this;
var hasClass = function(el,className) {
var re = that.getClassRegEx(className);
return re.test(el.className);
};
this.each(function(el) {
if (hasClass(el,className) === false) {
el.className += ' ' + className;
}
});
return this;
},
/**
*
* Checks to see if classname is one the element
*
* @method
* @param {String} The class name.
* @param {Function} A callback function (optional)
* @return {XUI Object - self} Chainable
* @example
*
* ### hasClass
*
* syntax:
*
* $(selector).hasClass('className');
* $(selector).hasClass('className', function(element) {});
*
* arguments:
*
* - className:string the name of the CSS class to apply
*
* example:
*
* $('#foo').hasClass('awesome'); // returns true or false
* $('.foo').hasClass('awesome',function(e){}); // returns XUI object
*
*/
hasClass: function(className, callback) {
var that = this;
if(callback === undefined && this.elements.length == 1) {
var re = this.getClassRegEx(className);
return re.test(that.first().className);
}
this.each( function(el) {
var re = that.getClassRegEx(className);
if (re.test(el.className) == true) {
callback(el);
}
});
return this;
},
/**
*
* Removes the classname from all the elements in the collection.
*
* @method
* @param {String} The class name.
* @return {Element Collection}
* @example
*
* ### removeClass
*
* syntax:
*
* x$(selector).removeClass(className);
*
* arguments:
*
* - className:string the name of the CSS class to remove.
*
* example:
*
* x$('.bar').removeClass('awesome');
*
*/
removeClass:function(className) {
if (className === undefined) {
this.each(function(el) {
el.className = '';
});
} else {
var re = this.getClassRegEx(className);
this.each(function(el) {
el.className = el.className.replace(re, ' ');
});
}
return this;
},
/**
*
* Set a number of CSS properties at once.
*
* @method
* @param {Object} An object literal of CSS properties and corosponding values.
* @return {Element Collection}
* @example
*
* ### css
*
* syntax:
*
* x$(selector).css(object);
*
* arguments:
*
* - an object literal of css key/value pairs to set.
*
* example:
*
* x$('h2.fugly').css({ backgroundColor:'blue', color:'white', border:'2px solid red' });
*
*/
css: function(o) {
var that = this;
this.each(function(el) {
for (var prop in o) {
that.setStyle(prop, o[prop]);
}
});
return this || that;
},
reClassNameCache: {},
getClassRegEx: function(className) {
var re = this.reClassNameCache[className];
if (!re) {
re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
this.reClassNameCache[className] = re;
}
return re;
}
};
libs.push(Style);
/**
*
* @namespace {Fx}
* @example
*
* Fx
* ---
*
* Animations, transforms and transitions for getting the most out of hardware accelerated CSS.
*
*/
var Fx = {
/**
*
* Tween is a method for transforming a css property to a new value.
*
* @method
* @param {Object} [Array|Object]
* @param {Function}
* @return {Element Collection}
* @example
*
* ### tween
*
* syntax:
*
* x$(selector).tween(obj, callback);
*
* arguments:
*
* - properties: object an object literal of element css properties to tween or an array containing object literals of css properties to tween sequentially.
* - callback (optional): function to run when the animation is complete
*
* example:
*
* x$('#box').tween({ left:100px, backgroundColor:'blue' });
* x$('#box').tween({ left:100px, backgroundColor:'blue' }, function() { alert('done!'); });
* x$('#box').tween([{ left:100px, backgroundColor:'green', duration:.2 }, { right:'100px' }]);
* x$('#box').tween({ left:100px}).tween({ left:'100px' });
*
*/
tween: function( options, opts ) {
this.each(function(e){
emile(e, options, opts);
});
return this;
}
};
libs.push(Fx);
/**
*
* @namespace {Xhr}
* @example
*
*
* Xhr
* ---
*
* Remoting methods and utils.
*
*/
var Xhr = {
/**
*
* The classic Xml Http Request sometimes also known as the Greek God: Ajax. Not to be confused with AJAX the cleaning agent.
* This method has a few new tricks. It is always invoked on an element collection and follows the identical behaviour as the
* `html` method. If there no callback is defined the response text will be inserted into the elements in the collection.
*
* @method
* @param {location} [inner|outer|top|bottom|before|after]
* @param {String} The URL to request.
* @param {Object} The method options including a callback function to invoke when the request returns.
* @return {Element Collection}
* @example
*
* ### xhr
* syntax:
*
* xhr(location, url, options)
*
* or this method will accept just a url with a default behavior of inner...
*
* xhr(url, options);
*
* location
*
* options:
*
* - method {String} [get|put|delete|post] Defaults to 'get'.
* - async {Boolen} Asynchronous request. Defaults to false.
* - data {String} A url encoded string of parameters to send.
* - callback {Function} Called on 200 status (success)
*
* response
* - The response available to the callback function as 'this', it is not passed in.
* - this.reponseText will have the resulting data from the file.
*
* example:
*
* x$('#status').xhr('inner', '/status.html');
* x$('#status').xhr('outer', '/status.html');
* x$('#status').xhr('top', '/status.html');
* x$('#status').xhr('bottom','/status.html');
* x$('#status').xhr('before','/status.html');
* x$('#status').xhr('after', '/status.html');
*
* or
*
* x$('#status').xhr('/status.html');
*
* x$('#left-panel').xhr('/panel', {callback:function(){ alert("All Done!") }});
*
* x$('#left-panel').xhr('/panel', function(){ alert(this.responseText) });
*
*/
xhr:function(location, url, options) {
if (!/^inner|outer|top|bottom|before|after$/.test(location)) {
options = url;
url = location;
location = 'inner';
}
var o = options;