Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds custom attributes #257

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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').register();

{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/gestures/index.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
20 changes: 19 additions & 1 deletion hsp/gestures/doubleTap.js
@@ -1,3 +1,19 @@
/*
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -158,4 +174,6 @@ var DoubleTap = klass({

});

module.exports.DoubleTap = DoubleTap;
module.exports.register = function() {
hsp.registerCustomAttributes(["ondoubletap", "ondoubletapstart", "ondoubletapcancel"], DoubleTap);
};
20 changes: 19 additions & 1 deletion hsp/gestures/drag.js
@@ -1,3 +1,19 @@
/*
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -112,4 +128,6 @@ var Drag = klass({

});

module.exports.Drag = Drag;
module.exports.register = function() {
hsp.registerCustomAttributes(["ondrag", "ondragstart", "ondragmove", "ondragcancel"], Drag);
};
18 changes: 10 additions & 8 deletions hsp/gestures/gesture.js
@@ -1,5 +1,5 @@
/*
* Copyright 2012 Amadeus s.a.s.
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -25,18 +25,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 +70,9 @@ var Gesture = klass({
},

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

Expand Down Expand Up @@ -331,7 +333,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 +366,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.

32 changes: 32 additions & 0 deletions hsp/gestures/index.js
@@ -0,0 +1,32 @@
/*
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var doubleTap = require("./doubleTap");
var drag = require("./drag");
var longPress = require("./longPress");
var pinch = require("./pinch");
var singleTap = require("./singleTap");
var swipe = require("./swipe");
var tap = require("./tap");

module.exports.register = function() {
doubleTap.register();
drag.register();
longPress.register();
pinch.register();
singleTap.register();
swipe.register();
tap.register();
};
20 changes: 19 additions & 1 deletion hsp/gestures/longPress.js
@@ -1,3 +1,19 @@
/*
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var hsp = require("../rt");
var klass = require("../klass");
var touchEvent = require("./touchEvent");
var Gesture = require("./gesture").Gesture;
Expand Down Expand Up @@ -126,4 +142,6 @@ var LongPress = klass({

});

module.exports.LongPress = LongPress;
module.exports.register = function() {
hsp.registerCustomAttributes(["onlongpress", "onlongpressstart", "onlongpresscancel"], LongPress);
};