Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="../../../funcunit/qunit/qunit.css" /> | ||
<title>QUnit Test</title> | ||
<style> | ||
body { | ||
margin: 0px; padding: 0px; | ||
} | ||
</style> | ||
<!--[if IE]> | ||
<script type='text/javascript' | ||
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> | ||
<![endif]--> | ||
<script type='text/javascript'> | ||
steal = {ignoreControllers: true} | ||
</script> | ||
<script type='text/javascript' src='../../../steal/steal.js?steal[app]=ss/router/controller/test/qunit'></script> | ||
</head> | ||
<body> | ||
|
||
<h1 id="qunit-header">router Test Suite</h1> | ||
<h2 id="qunit-banner"></h2> | ||
<div id="qunit-testrunner-toolbar"></div> | ||
<h2 id="qunit-userAgent"></h2> | ||
<div id="test-content"></div> | ||
<ol id="qunit-tests"></ol> | ||
<div id="qunit-test-area"></div> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
steal | ||
.plugins("jquery/controller") //load your app | ||
.plugins("ss/router/controller") //load your app | ||
.plugins("funcunit/qunit") //load qunit | ||
.then("controller_test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
steal | ||
.plugins("jquery/controller") //load your app | ||
.plugins("ss/router") //load your app | ||
.plugins("ss/router/sherpa") //load your app | ||
.plugins("funcunit/qunit") //load qunit | ||
.then("sherpa_test") | ||
.then("router_test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="../../../funcunit/qunit/qunit.css" /> | ||
<title>QUnit Test</title> | ||
<style> | ||
body { | ||
margin: 0px; padding: 0px; | ||
} | ||
</style> | ||
<script type='text/javascript'> | ||
steal = {ignoreControllers: true} | ||
</script> | ||
<script type='text/javascript' src='../../../steal/steal.js?steal[app]=ss/router/subscribe/test/qunit'></script> | ||
</head> | ||
<body> | ||
|
||
<h1 id="qunit-header">router subscribe Test Suite</h1> | ||
<h2 id="qunit-banner"></h2> | ||
<div id="qunit-testrunner-toolbar"></div> | ||
<h2 id="qunit-userAgent"></h2> | ||
<div id="test-content"></div> | ||
<ol id="qunit-tests"></ol> | ||
<div id="qunit-test-area"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
steal.plugins("jquery/controller", | ||
"jquery/controller/history", | ||
"jquery/lang/openajax", | ||
"ss/router/sherpa") | ||
.then(function($) { | ||
|
||
var SubscriberRouter = new Sherpa.Router(); | ||
var RouteToCallback = {}; | ||
|
||
OpenAjax.hub.subscribe("history.**", function(event_name) { | ||
var key = event_name.replace(/^history(\.*)/, '/'), | ||
foundRoute = SubscriberRouter.recognize(key) | ||
if (!foundRoute) { | ||
return; | ||
} | ||
|
||
var callbacks = RouteToCallback[foundRoute.destination]; | ||
if (callbacks) { | ||
for (var i = 0; i < callbacks.length; i++) { | ||
callbacks[i](); | ||
} | ||
} | ||
}); | ||
|
||
$.Controller.processors.route = function( el, event, selector, cb, controller ) { | ||
// Add the selector to be watched | ||
SubscriberRouter.add(selector).to(selector); | ||
|
||
// Create an array of callbacks for this selector | ||
if (typeof RouteToCallback[selector] === "undefined") { | ||
RouteToCallback[selector] = []; | ||
} | ||
|
||
// Add callback to this array | ||
RouteToCallback[selector].push(cb); | ||
|
||
return function() { | ||
//console.debug("route unsubscribe", arguments); | ||
} | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module("Router Processor Controller"); | ||
|
||
var didRun = false; | ||
|
||
$.Controller.extend("TestProcessorsController", | ||
{ | ||
onDocument: true | ||
}, | ||
{ | ||
"/test/url route": function() { | ||
didRun = true; | ||
} | ||
}); | ||
|
||
asyncTest("Works", function() { | ||
expect(1) | ||
stop(); | ||
location.hash = "/test/url"; | ||
setTimeout(function() { | ||
start(); | ||
ok(didRun, "Route worked"); | ||
location.hash = "/"; | ||
}, 50); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
steal | ||
.plugins("jquery/controller") //load your app | ||
.plugins("ss/router/subscribe") //load your app | ||
.plugins("funcunit/qunit") //load qunit | ||
.then("processor_test") |