Skip to content

Commit

Permalink
bumping version
Browse files Browse the repository at this point in the history
  • Loading branch information
tblobaum committed Nov 4, 2011
1 parent d260448 commit 2b5a4a4
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ can use all of the event types that are available with jquery or zepto to do thi

swipe swipeLeft swipeRight swipeUp swipeDown doubleTap tap longTap focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout change select keydown keypress keyup error

Sample usage of methods you can use on the server:
Sample usage of methods on the server:

```javascript

Expand Down
30 changes: 30 additions & 0 deletions examples/event-binding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var Express = require('express')
, dnode = require('dnode')()
, nQuery = require('../')
, express = Express.createServer();

var app = function ($) {
$.on('ready', function () {
var items = 0;

$('body').append('<a href="#" class="link">Add an Item.</a>');

$('.link').live('click', function () {
items++;
$('body').append('<h5>Item added: total is now <em>' + items + '</em></h5>');
});
});
};

nQuery
.use(app);

express
.use(nQuery.middleware)
.use(Express.static(__dirname + '/public'))
.listen(3000);

dnode
.use(nQuery.middleware)
.listen(express);

40 changes: 20 additions & 20 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ $(document).ready(function() {
};

this.nQget = function (params, callback) {
var r = $(params.context)[params.fn]();
if (typeof r !== 'object') {
callback(r.toString());
} else if (typeof r === 'object') {
callback(r['selector']);
}
};
var r = $(params.context)[params.fn]();
if (typeof r !== 'object') {
callback(r.toString());
} else if (typeof r === 'object') {
callback(r['selector']);
}
};
this.nQlive = function (params, callback) {
var fn = $(params.context)[params.fn];
var r = fn.call($(params.context), params.args, function (e) {
callback({type:e.type});
});
};
var fn = $(params.context)[params.fn];
var r = fn.call($(params.context), params.args, function (e) {
callback({type:e.type});
});
};
this.nQset = function (params) {
$(params.context)[params.fn].apply($(params.context), params.args);
};
Expand All @@ -70,13 +70,13 @@ $(document).ready(function() {
dnode.connect(function (remote, conn) {

conn.on('ready', function () {
remote.nodeQuery(String(window.location), window.nQuery.isReady);
remote.nodeQuery(String(window.location), window.nQuery.isReady);
});

conn.on('end', function(data) {
window.nQuery.isClosed(data);
});

conn.on('end', function(data) {
window.nQuery.isClosed(data);
});

});

});
36 changes: 34 additions & 2 deletions lib/nodeQuery.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
var url = require('url')
, _ = require('underscore')
, emitter = require('events').EventEmitter
, EventEmitter = require('events').EventEmitter
, qs = require('querystring');

function nQuery ($, connection, client) {

var _methods = [
'get',
'size',
'index',
'offset',
'height',
'width',
'serialize',
'live',
'bind',
'unbind',
'html',
'text',
'attr',
'css',
'toggleClass',
'addClass',
'removeClass',
'replaceWith',
'append',
'prepend',
'before',
'after',
'prependTo',
'appendTo',
'show',
'hide',
'remove',
'parseQuerystring',
'stringifyQuerystring'
];

connection.$ = function (context) {

this.context = context;
Expand Down Expand Up @@ -308,7 +340,7 @@ function nQuery ($, connection, client) {
return self;
};

_.extend(connection.$, new emitter);
_.extend(connection.$, new EventEmitter);
// Utility functions (no RPC)

connection.$.parseQuerystring = function (str) {
Expand Down

0 comments on commit 2b5a4a4

Please sign in to comment.