Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename files in preperation for project rename to jQuery Entwine
- Loading branch information
Hamish Friedlander
authored and
Hamish Friedlander
committed
Nov 30, 2009
1 parent
dc4a924
commit a3da39f
Showing
20 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
<html> | ||
<head> | ||
<!-- spec-dist is the same as spec, but runs on the distribution version of the library, to make sure no problems were introduced during building --> | ||
<link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" /> | ||
<script src="../vendor/jquery-1.3.2.js"></script> | ||
<script src="../vendor/jspec/lib/jspec.js"></script> | ||
<script src="../vendor/jspec/lib/jspec.jquery.js"></script> | ||
|
||
<script src="../dist/jquery.concrete-dist.js"></script> | ||
|
||
<script> | ||
function runSuites() { | ||
JSpec | ||
.exec('spec.concrete.basics.js') | ||
.exec('spec.concrete.namespaces.js') | ||
.exec('spec.concrete.super.js') | ||
.exec('spec.concrete.events.js') | ||
.exec('spec.concrete.ctors.js') | ||
.exec('spec.concrete.properties.js') | ||
.run() | ||
.report() | ||
} | ||
</script> | ||
</head> | ||
<body class="jspec" onLoad="runSuites();"> | ||
<div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div> | ||
<div id="jspec"><div class="loading"></div></div> | ||
<div id="jspec-bottom"></div> | ||
</body> | ||
</html> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,38 @@ | ||
<html> | ||
<head> | ||
<link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" /> | ||
<script src="../vendor/jquery-1.3.2.js"></script> | ||
<script src="../vendor/jspec/lib/jspec.js"></script> | ||
<script src="../vendor/jspec/lib/jspec.jquery.js"></script> | ||
|
||
<script src="../vendor/jquery.selector/jquery.class.js"></script> | ||
<script src="../vendor/jquery.selector/jquery.selector.js"></script> | ||
<script src="../vendor/jquery.selector/jquery.selector.specifity.js"></script> | ||
<script src="../vendor/jquery.selector/jquery.selector.matches.js"></script> | ||
|
||
<script src="../src/jquery.concrete.js"></script> | ||
<script src="../src/jquery.concrete.dommaybechanged.js"></script> | ||
<script src="../src/jquery.concrete.events.js"></script> | ||
<script src="../src/jquery.concrete.ctors.js"></script> | ||
<script src="../src/jquery.concrete.properties.js"></script> | ||
|
||
<script> | ||
function runSuites() { | ||
JSpec | ||
.exec('spec.concrete.basics.js') | ||
.exec('spec.concrete.namespaces.js') | ||
.exec('spec.concrete.super.js') | ||
.exec('spec.concrete.events.js') | ||
.exec('spec.concrete.ctors.js') | ||
.exec('spec.concrete.properties.js') | ||
.run() | ||
.report() | ||
} | ||
</script> | ||
</head> | ||
<body class="jspec" onLoad="runSuites();"> | ||
<div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div> | ||
<div id="jspec"><div class="loading"></div></div> | ||
<div id="jspec-bottom"></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,85 @@ | ||
|
||
describe 'Concrete' | ||
describe 'Basics' | ||
before | ||
$.concrete.warningLevel = $.concrete.WARN_LEVEL_BESTPRACTISE; | ||
$('body').append('<div id="dom_test"></div>'); | ||
end | ||
after | ||
$('#dom_test').remove(); | ||
end | ||
|
||
before_each | ||
$.concrete.clear_all_rules(); | ||
$('#dom_test').html('<div id="a" class="a b c" data-fieldtype="foo"></div><div id="b" class="c d e"></div>'); | ||
end | ||
|
||
it 'can attach and call a base function' | ||
$('#a').concrete({ | ||
foo: function(){return this.attr('id');} | ||
}); | ||
$('.a').foo().should.equal 'a' | ||
end | ||
|
||
it 'can attach and call a base function on a selector using a data attribute selection' | ||
$('[data-fieldtype=foo]').concrete({ | ||
foo: function(){return this.attr('id');} | ||
}); | ||
$('.a').foo().should.equal 'a' | ||
end | ||
|
||
it 'can attach and call several base functions' | ||
$('#a').concrete({ | ||
foo: function(){return 'foo_' + this.attr('id');}, | ||
bar: function(){return 'bar_' + this.attr('id');} | ||
}); | ||
$('.a').foo().should.equal 'foo_a' | ||
$('.a').bar().should.equal 'bar_a' | ||
end | ||
|
||
it 'can attach and call a namespaced function' | ||
$.concrete('bar', function($){ | ||
$('#a').concrete({ | ||
foo: function(){return this.attr('id');} | ||
}); | ||
}); | ||
$('.a').concrete('bar').foo().should.equal 'a' | ||
end | ||
|
||
it 'can attach and call a nested namespaced function' | ||
$.concrete('qux.baz.bar', function($){ | ||
$('#a').concrete({ | ||
foo: function(){return this.attr('id');} | ||
}); | ||
}); | ||
$('.a').concrete('qux.baz.bar').foo().should.equal 'a' | ||
end | ||
|
||
it 'can call two functions on two elements' | ||
var res = [] | ||
$('#a').concrete({ | ||
foo: function(){res.push(this.attr('id'));} | ||
}); | ||
$('#b.c').concrete({ | ||
foo: function(){res.push(this.attr('id'));} | ||
}); | ||
$('#dom_test div').foo(); | ||
res.should.eql ['b', 'a'] | ||
end | ||
|
||
it 'can call two namespaced functions on two elements' | ||
var res = [] | ||
$.concrete('bar', function($){ | ||
$('#a').concrete({ | ||
foo: function(){res.push(this.attr('id'));} | ||
}); | ||
$('#b.c').concrete({ | ||
foo: function(){res.push(this.attr('id'));} | ||
}); | ||
}); | ||
$('#dom_test div').concrete('bar').foo(); | ||
res.should.eql ['b', 'a'] | ||
end | ||
|
||
end | ||
end |
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,68 @@ | ||
describe 'Concrete' | ||
describe 'Ctors' | ||
|
||
before | ||
$('body').append('<div id="dom_test"></div>') | ||
end | ||
|
||
after | ||
$('#dom_test').remove() | ||
end | ||
|
||
before_each | ||
$.concrete.synchronous_mode(); | ||
$.concrete.clear_all_rules() | ||
$('#dom_test').html('<div id="a" class="a b c"></div>') | ||
end | ||
|
||
it 'calls onmatch when new element created' | ||
var a = false; | ||
$('#b').concrete({onmatch: function(){a = true;} }); | ||
a.should.be_false | ||
$('#a').after('<div id="b"></div>'); | ||
a.should.be_true | ||
end | ||
|
||
it 'calls onunmatch when new element deleted' | ||
var a = 0; | ||
$('#b').concrete({onmatch: function(){a = 1;}, onunmatch: function(){a = 2;} }); | ||
a.should.equal 0 | ||
$('#a').after('<div id="b"></div>'); | ||
a.should.equal 1 | ||
$('#b').remove(); | ||
a.should.equal 2 | ||
end | ||
|
||
it 'calls onmatch when ruleset matches after class added' | ||
var a = 0; | ||
$('#a.foo').concrete({onmatch: function(){a = 1;} }); | ||
a.should.equal 0 | ||
$('#a').addClass('foo'); | ||
a.should.equal 1 | ||
end | ||
|
||
it 'calls onmatch in both direct and namespaced onmatch, does not call less specific onmatch' | ||
var a = 0, b=0, c=0, d=0; | ||
$('.foo').concrete({onmatch: function(){a = 1;}}) | ||
$('.foo').concrete('bar', function($){return{onmatch: function(){b = 1;}}}) | ||
$('#a.foo').concrete({onmatch: function(){c = 1;}}) | ||
$('#a.foo').concrete('bar', function($){return{onmatch: function(){d = 1}}}) | ||
[a, b, c, d].should.eql [0, 0, 0, 0] | ||
$('#a').addClass('foo'); | ||
[a, b, c, d].should.eql [0, 0, 1, 1] | ||
end | ||
|
||
it 'calls onmatch in both direct and namespaced onmatch, super works as expected' | ||
var a = 0, b=0, c=0, d=0; | ||
$('.foo').concrete({onmatch: function(){a += 1;}}) | ||
$('.foo').concrete('bar', function($){return{onmatch: function(){b += 1;}}}) | ||
$('#a.foo').concrete({onmatch: function(){this._super(); c = 1; this._super();}}) | ||
$('#a.foo').concrete('bar', function($){return{onmatch: function(){this._super(); d = 1; this._super();}}}) | ||
[a, b, c, d].should.eql [0, 0, 0, 0] | ||
$('#a').addClass('foo'); | ||
[a, b, c, d].should.eql [2, 2, 1, 1] | ||
end | ||
|
||
|
||
end | ||
end |
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,112 @@ | ||
describe 'Concrete' | ||
describe 'Events' | ||
|
||
before | ||
$('body').append('<div id="dom_test"></div>') | ||
end | ||
|
||
after | ||
$('#dom_test').remove() | ||
end | ||
|
||
before_each | ||
$.concrete.synchronous_mode(); | ||
$.concrete.clear_all_rules() | ||
$('#dom_test').html('<div id="a" class="a b c"></div>') | ||
end | ||
|
||
it 'calls onfoo when foo triggered' | ||
var a = 0; | ||
$('#a').concrete({onfoo: function(){a = 1;} }); | ||
a.should.equal 0 | ||
$('#a').trigger('foo'); | ||
a.should.equal 1 | ||
end | ||
|
||
it 'only calls most specific onfoo when foo triggered' | ||
var a = 0, b = 0; | ||
$('#a.a').concrete({onfoo: function(){a = 1;} }); | ||
$('#a').concrete({onfoo: function(){b = 1;} }); | ||
a.should.equal 0 | ||
b.should.equal 0 | ||
$('#a').trigger('foo'); | ||
a.should.equal 1 | ||
b.should.equal 0 | ||
end | ||
|
||
it 'calls namespaced onfoo when foo triggered' | ||
var a = 0; | ||
$('#a').concrete('bar', function($){return{onfoo: function(){a = 1;} }}); | ||
a.should.equal 0 | ||
$('#a').trigger('foo'); | ||
a.should.equal 1 | ||
end | ||
|
||
it 'calls most specific namespaced onfoo and most specific non-namespaced onfoo when foo triggered' | ||
var a = 0, b = 0, c = 0, d = 0; | ||
$('#a.a').concrete({onfoo: function(){a = 1;} }); | ||
$('#a').concrete({onfoo: function(){b = 1;} }); | ||
$('#a.a').concrete('bar', function($){return{onfoo: function(){c = 1;} }}); | ||
$('#a').concrete('bar', function($){return{onfoo: function(){d = 1;} }}); | ||
[a, b, c, d].should.eql [0, 0, 0, 0] | ||
|
||
$('#a').trigger('foo'); | ||
[a, b, c, d].should.eql [1, 0, 1, 0] | ||
end | ||
|
||
it 'calls up correctly on _super' | ||
var a = 0, b = 0; | ||
$('#a').concrete({onfoo: function(){a += 1;} }); | ||
$('#a.a').concrete({onfoo: function(){this._super(); b += 1; this._super();} }); | ||
|
||
[a, b].should.eql [0, 0] | ||
$('#a').trigger('foo') | ||
[a, b].should.eql [2, 1] | ||
end | ||
|
||
it 'passes event object' | ||
var event; | ||
$('#a').concrete({onfoo: function(e){event = e;} }); | ||
$('#a').trigger('foo'); | ||
event.should.have_prop 'type', 'foo' | ||
$(event.target).should.have_attr 'id', 'a' | ||
end | ||
|
||
it 'delegates submit events to forms' | ||
var a = 0; | ||
$('<form class="foo" action="javascript:undefined">').appendTo('#dom_test'); | ||
|
||
$('.foo').concrete({onsubmit: function(e, d){a = 1;} }); | ||
|
||
a.should.eql 0 | ||
$('.foo').trigger('submit'); | ||
a.should.eql 1 | ||
end | ||
|
||
describe 'can pass event data' | ||
it 'on custom events' | ||
var data; | ||
$('#a').concrete({onfoo: function(e, d){data = d;} }); | ||
$('#a').trigger('foo', {cheese: 'burger'}); | ||
data.cheese.should.eql 'burger' | ||
end | ||
|
||
it 'on normal events' | ||
var data; | ||
$('#a').concrete({onclick: function(e, d){data = d;} }); | ||
$('#a').trigger('click', {finger: 'left'}); | ||
data.finger.should.eql 'left' | ||
end | ||
|
||
it 'on submit' | ||
var data; | ||
|
||
$('<form class="foo" action="javascript:undefined">').appendTo('#dom_test'); | ||
$('.foo').concrete({onsubmit: function(e, d){data = d; return false;} }) | ||
|
||
$('.foo').trigger('submit', {cheese: 'burger'}); | ||
data.cheese.should.eql 'burger' | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.