/* * * MODDED: * xhr post method not working .. * http://github.com/brianleroux/xui/issues#issue/6 * * @projectDescription XUI JavaScript library for mobile web applications. * * @author Rob Ellis rob.ellis@nitobi.com * @author Brian LeRoux brian.leroux@westcoastlogic.com * @author Brock Whitten brock@sintaxi.com * * @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']); * */ (function() { var _$ = function(els) { return this.find(els); }; _$.prototype = { elements:[], find: function(q) { this.elements = []; var qlen = q.length; for(var i = 0; i < qlen; i++ ) { if( typeof q[i] == 'string' ) { var list = document.querySelectorAll(q[i]); var size = list.length; for(var j = 0; j < size; j++ ) { this.elements.push(list[j]); } } else { this.elements.push(q[i]); } }; return this; }, /** * Returns the first element in the collection. * * @return {Element} Returns a single DOM element. */ first: function() { return this.elements[0]; }, each: function(fn) { for( var i = 0, len = this.elements.length; irock and roll' ); * x$('#foo').html( 'outer', '

lock and load

' ); * x$('#foo').html( 'top', '
bangers and mash
'); * x$('#foo').html( 'bottom', 'mean and clean'); * x$('#foo').html( 'remove' '

first and last

'); * * or * * x$('#foo').html('

sweet as honey

'); * */ html:function(location, html) { // private method for finding a dom element var getTag = function(el) { if (el.firstChild == null) { switch(el.tagName) { case 'UL': return 'LI'; break; case 'DL': return 'DT'; break; case 'TR': return 'TD'; break; default: return el.tagName; } } return el.firstChild.tagName; }; // private method // Wraps the HTML in a TAG, Tag is optional // If the html starts with a Tag, it will wrap the context in that tag. 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 the node has any attributes, convert to object if (result[2] != "") { var attrList = result[2].split(/([a-zA-Z]*\s*=\s*['|"][a-zA-Z0-9:;#\s]*['|"])/); for(var i=0;i -1 ? e.options[e.selectedIndex].value : null; } if (value == null || value == "") { cb.addClass('input_error'); return true; } else { cb.removeClass('input_error'); return false; } } function iMobile_sendMessage() { var error = false; error = iMobile_isEmptyField('to') || iMobile_isEmptyField('subject') || iMobile_isEmptyField('message'); return !error; } function iMobile_notifyDelete(notifytype_id, notify_grouped) { var x_id = '#notify_' + notifytype_id + '_' + notify_grouped; x$(x_id).xhr('imobile.php', { method: 'post', data: 'task=user_notify_delete¬ifytype_id='+notifytype_id+'¬ify_grouped='+notify_grouped }); x$(x_id).remove(); } function iMobile_loadLastLocation() { if(navigator.standalone) { if(!localStorage.address) { localStorage.address = window.location; localStorage.home = localStorage.address; } else { if(window.location == localStorage.home) { if(localStorage.address != localStorage.home) { window.location = localStorage.address; } } else { localStorage.address = window.location; } } } } function iMobile_init() { if (window.navigator.standalone == true) { x$("#add_homescreen_info").setStyle('display','none'); } } function fullscreen() { var a = document.getElementsByTagName("a"); for (var i = 0; i < a.length;i++) { if (a[i].className.match("noeffect")) { } else { a[i].onclick = function () { window.location = this.getAttribute("href"); return false; }; } } } function hideURLbar() { window.scrollTo(0, 0.9); } window.onload = function () { fullscreen(); hideURLbar(); };