Permalink
Browse files

Refactored out qwery

  • Loading branch information...
1 parent f16ee79 commit f8727157d626c03f1d573cc6e426812845a7f6fb @DamonOehlman committed Jun 29, 2012
Showing with 538 additions and 358 deletions.
  1. +0 −12 Jakefile
  2. +9 −0 Makefile
  3. +1 −1 README.md
  4. +43 −0 examples/debug.html
  5. +66 −0 examples/dom-move.html
  6. +1 −2 examples/draw.html
  7. +299 −262 fui.js
  8. +0 −1 fui.min.js
  9. +2 −3 package.json
  10. +62 −67 src/fui.js
  11. +20 −2 src/source/eventsource.js
  12. +3 −0 src/source/mouse.js
  13. +32 −8 src/types/chain.js
View
@@ -1,12 +0,0 @@
-var fs = require('fs'),
- path = require('path'),
- interleave = require('interleave');
-
-task('default', function() {
- // build each of the builds
- interleave('src/', {
- data: JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')),
- path: '.',
- after: ['uglify']
- });
-});
View
@@ -0,0 +1,9 @@
+SHELL := /bin/bash
+
+build:
+ @node_modules/interleave/bin/interleave src/fui.js --wrap oldschool --uglify
+
+test:
+ @mocha --reporter spec
+
+.PHONY: test
View
@@ -10,7 +10,7 @@ There are examples available both in this repository, and online at jsfiddle:
- [Simple Draw Example - Using Template](http://jsfiddle.net/DamonOehlman/v5ydb/)
-## Example Code
+### Example Code
Here is some very early example code (which is actually running):
View
@@ -0,0 +1,43 @@
+<html>
+<body>
+ <div id="debug"></div>
+ <style type="text/css">
+ body {
+ margin: 0;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ user-select: none;
+ }
+
+ #debug {
+ font: 0.8em monospace;
+ height: 200px;
+ overflow-y: scroll;
+ padding: 10px;
+ }
+ </style>
+ <script src="https://raw.github.com/ded/qwery/master/qwery.min.js"></script>
+ <script src="../fui.js"></script>
+ <script>
+ var debug = (function() {
+ var container = document.getElementById('debug'),
+ lines = [];
+
+ return function(message) {
+ lines = [message].concat(lines).slice(0, 50);
+ container.innerText = lines.join('\n');
+ };
+ })();
+
+ fui()
+ .down(function(target, x, y) {
+ debug('pointer down @ ' + x + ', ' + y);
+ })
+ .move(function(target, x, y) {
+ debug('pointer move @ ' + x + ', ' + y);
+ })
+ .up(function(target, x, y) {
+ debug('pointer up @ ' + x + ', ' + y);
+ });
+ </script>
+</body>
View
@@ -0,0 +1,66 @@
+<html>
+<body>
+ <style type="text/css">
+ .box {
+ width: 20px;
+ height: 20px;
+ background: red;
+ float: left;
+ }
+
+ .box.draggable {
+ background: black;
+ }
+
+ .box.placeholder {
+ background: none;
+ }
+ </style>
+ <script src="../fui.js"></script>
+ <script>
+ var boxCount = 2000;
+
+ function moveTarget(target, x, y) {
+ target.style.left = (x - 10) + 'px';
+ target.style.top = (y - 10) + 'px';
+ }
+
+ fui()
+ .up(function(target, x, y) {
+ // reset the targets
+ this.target = null;
+ })
+ .move(function(target, x, y) {
+ if (this.target) {
+ moveTarget(this.target, x, y);
+ }
+ })
+ .filter('.draggable')
+ .down(function(target, x, y) {
+ if (target.style.position !== 'absolute') {
+ var div = document.createElement('div');
+
+ // initialize the class and insert the replacement box
+ div.className = 'box placeholder';
+ document.body.insertBefore(div, target);
+
+ // update the style of the target to absolute
+ target.style.position = 'absolute';
+ }
+
+ // insert a placeholder box element
+
+
+ moveTarget(this.target = target, x, y);
+ });
+
+ // create a 100 boxes
+ for (var ii = 0; ii < boxCount; ii++) {
+ var div = document.createElement('div');
+
+ div.className = ii % 2 === 0 ? 'box' : 'box draggable';
+
+ document.body.appendChild(div);
+ }
+ </script>
+</body>
View
@@ -7,9 +7,8 @@
<p><button onclick="newCanvas();">Create a Canvas</button></p>
<div id="usercanvas"></div>
<style type="text/css">
- canvas { background: #eee; }
+ canvas { background: #eee; cursor: pointer; -webkit-user-select: none; }
</style>
- <script src="https://raw.github.com/ded/qwery/master/qwery.min.js"></script>
<script src="../fui.js"></script>
<script>
function newCanvas() {
Oops, something went wrong.

0 comments on commit f872715

Please sign in to comment.