Skip to content

Commit

Permalink
adds custom attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
marclaval committed Aug 8, 2014
1 parent 4e0fa3b commit 030857d
Show file tree
Hide file tree
Showing 28 changed files with 509 additions and 139 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
/node_modules
/dist
/sauce_connect.log
/npm-debug.log
/sc.log
/test-results
/tmp
Expand Down
5 changes: 4 additions & 1 deletion build/grunt/docs.js
Expand Up @@ -262,7 +262,8 @@ module.exports = function(grunt) {
hspRoot = grunt.config('hspserver.base')+"/hsp",
emptyJsResponse = function(req, res) { res.set('Content-Type', 'application/x-javascript'); return res.send(""); },
compilerPath = '/dist/' + VERSION + '/hashspace-noder-compiler.min.js',
runtimePath = '/dist/' + VERSION + '/hashspace-noder.min.js';
runtimePath = '/dist/' + VERSION + '/hashspace-noder.min.js',
gesturesPath = '/dist/' + VERSION + '/hashspace-noder-gestures.min.js';

grunt.log.subhead('Local website setup');
grunt.log.writeln('Starting local documentation web server...');
Expand All @@ -287,6 +288,8 @@ module.exports = function(grunt) {
grunt.verbose.ok(compilerPath, 'polyfilled to be empty');
app.get(runtimePath, emptyJsResponse);
grunt.verbose.ok(runtimePath, 'polyfilled to be empty');
app.get(gesturesPath, emptyJsResponse);
grunt.verbose.ok(gesturesPath, 'polyfilled to be empty');

// Proxying /test and /node_modules folders
app.use('/test', function(req, res, next) {
Expand Down
1 change: 1 addition & 0 deletions docs/playground/index.md
Expand Up @@ -19,6 +19,7 @@ footerscripts: |
}
</script>
<script src="/dist/<%=version%>/hashspace-noder.min.js" type="text/javascript"></script>
<script src="/dist/<%=version%>/hashspace-noder-gestures.min.js" type="text/javascript"></script>
<script src="/playground/playground-samples-all.js" type="text/javascript"></script>
<script src="/playground/playground-all.js" type="text/javascript"></script>
<script type="noder">
Expand Down
2 changes: 2 additions & 0 deletions docs/samples/gestures/gestures.hsp
@@ -1,3 +1,5 @@
require('hsp/gestures/index');

{template gestures(msgList)}
<div class="touchboard" style="height:200px; background: #27AAFC;text-align:center;"
ontap="{addMsg(event)}" ontapstart="{addMsg(event)}" ontapcancel="{addMsg(event)}"
Expand Down
26 changes: 19 additions & 7 deletions gruntfile.js
Expand Up @@ -248,11 +248,6 @@ module.exports = function (grunt) {
cwd: "hsp/rt",
src: ['*.js'],
dest: 'hsp/rt'
},
{
cwd: "hsp/gestures",
src: ['*.js'],
dest: 'hsp/gestures'
}
]
}
Expand All @@ -268,15 +263,29 @@ module.exports = function (grunt) {
}
]
}
},
gestures: {
files: [{dest: 'dist/hashspace-browserify-gestures.js', src: ['hsp/rt.js']}],
options: {
aliasMappings: [
{
cwd: "hsp/gestures",
src: ['*.js'],
dest: 'hsp/gestures'
}
]
}
}
},
uglify: {
hsp: {
files: [
{dest: 'dist/hashspace-browserify.min.js', src: ['dist/hashspace-browserify.js']},
{dest: 'dist/hashspace-browserify-compiler.min.js', src: ['dist/hashspace-browserify-compiler.js']},
{dest: 'dist/hashspace-browserify-gestures.min.js', src: ['dist/hashspace-browserify-gestures.js']},
{dest: 'dist/hashspace-noder.min.js', src: ['dist/hashspace-noder.js']},
{dest: 'dist/hashspace-noder-compiler.min.js', src: ['dist/hashspace-noder-compiler.js']}
{dest: 'dist/hashspace-noder-compiler.min.js', src: ['dist/hashspace-noder-compiler.js']},
{dest: 'dist/hashspace-noder-gestures.min.js', src: ['dist/hashspace-noder-gestures.js']}
]
}
},
Expand Down Expand Up @@ -342,10 +351,13 @@ module.exports = function (grunt) {
},
packages : [{
name : "hashspace-noder.js",
files : ['hsp/*.js', 'hsp/rt/*.js', 'hsp/gestures/*.js']
files : ['hsp/*.js', 'hsp/rt/*.js']
}, {
name : "hashspace-noder-compiler.js",
files : ['hsp/compiler/compile.js','hsp/transpiler/transpile.js']
}, {
name : "hashspace-noder-gestures.js",
files : ['hsp/gestures/*.js']
}]
}
}
Expand Down
3 changes: 2 additions & 1 deletion hsp/gestures/doubleTap.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -158,4 +159,4 @@ var DoubleTap = klass({

});

module.exports.DoubleTap = DoubleTap;
hsp.registerCustomAttributes(["ondoubletap", "ondoubletapstart", "ondoubletapcancel"], DoubleTap);
3 changes: 2 additions & 1 deletion hsp/gestures/drag.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -112,4 +113,4 @@ var Drag = klass({

});

module.exports.Drag = Drag;
hsp.registerCustomAttributes(["ondrag", "ondragstart", "ondragmove", "ondragcancel"], Drag);
17 changes: 9 additions & 8 deletions hsp/gestures/gesture.js
Expand Up @@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var klass = require("../klass");
var touchEvent = require("./touchEvent");

Expand All @@ -25,18 +24,18 @@ var Gesture = klass({
/**
* Constructor.
*/
$constructor : function (target, evthandler) {
$constructor : function (nodeInstance, callback) {
/**
* Reference to the target
* @type HTMLElement
*/
this.target = target;
this.target = nodeInstance.node;

/**
* Reference to the event handler
* @type HTMLElement
* @type Function
*/
this.evthandler = evthandler;
this.callback = callback;

/**
* Event map uses ./touchEvent for touch event detection.
Expand Down Expand Up @@ -70,7 +69,9 @@ var Gesture = klass({
},

$dispose: function() {
this._disconnectTouchEvents();
if (this.callbackMap) {
this._disconnectTouchEvents();
}
this.callbackMap = null;
},

Expand Down Expand Up @@ -331,7 +332,7 @@ var Gesture = klass({
extraData.currentX = position[0].x;
extraData.currentY = position[0].y;
fakeEvent.detail = extraData;
this.evthandler.handleEvent(fakeEvent);
this.callback(fakeEvent);
event.cancelBubble = fakeEvent.hasStopPropagation;
event.returnValue = !fakeEvent.hasPreventDefault;
return event.returnValue;
Expand Down Expand Up @@ -364,4 +365,4 @@ var Gesture = klass({
}
});

module.exports.Gesture = Gesture;
module.exports.Gesture = Gesture;
105 changes: 0 additions & 105 deletions hsp/gestures/gestures.js

This file was deleted.

7 changes: 7 additions & 0 deletions hsp/gestures/index.js
@@ -0,0 +1,7 @@
require("./doubleTap");
require("./drag");
require("./longPress");
require("./pinch");
require("./singleTap");
require("./swipe");
require("./tap");
3 changes: 2 additions & 1 deletion hsp/gestures/longPress.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -126,4 +127,4 @@ var LongPress = klass({

});

module.exports.LongPress = LongPress;
hsp.registerCustomAttributes(["onlongpress", "onlongpressstart", "onlongpresscancel"], LongPress);
3 changes: 2 additions & 1 deletion hsp/gestures/pinch.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -179,4 +180,4 @@ var Pinch = klass({

});

module.exports.Pinch = Pinch;
hsp.registerCustomAttributes(["onpinch", "onpinchstart", "onpinchmove", "onpinchcancel"], Pinch);
3 changes: 2 additions & 1 deletion hsp/gestures/singleTap.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -155,4 +156,4 @@ var SingleTap = klass({

});

module.exports.SingleTap = SingleTap;
hsp.registerCustomAttributes(["onsingletap", "onsingletapstart", "onsingletapcancel"], SingleTap);
3 changes: 2 additions & 1 deletion hsp/gestures/swipe.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -155,4 +156,4 @@ var Swipe = klass({

});

module.exports.Swipe = Swipe;
hsp.registerCustomAttributes(["onswipe", "onswipestart", "onswipemove", "onswipecancel"], Swipe);
3 changes: 2 additions & 1 deletion hsp/gestures/tap.js
@@ -1,3 +1,4 @@
var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -92,4 +93,4 @@ var Tap = klass({

});

module.exports.Tap = Tap;
hsp.registerCustomAttributes(["ontap", "ontapstart", "ontapcancel"], Tap);

0 comments on commit 030857d

Please sign in to comment.