Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename concrete to entwine (and concreteData to entwineData, etc.), a…

…nd add back support for the concrete function names via jquery.entwine.legacy.js
  • Loading branch information...
commit 7bf2d39108e9b24c2892b034ec0b84db746d1d53 1 parent a3da39f
Hamish Friedlander authored
View
96 README.textile
@@ -1,29 +1,29 @@
-h1. Concrete - Support for ConcreteUI programming in jQuery
+h1. Entwine - Support for Concrete UI style programming in jQuery
By Hamish Friedlander, with thanks to "SilverStripe":http://www.silverstripe.com/
-Concrete tries to provide a new model of code organisation - a replacement for Object Oriented programming that is focused on adding functions to groups of DOM elements based on the structure and contents of those DOM elements. It's a merging of the model and view layer that initially seems weird, but can give very powerful results.
+Entwine tries to provide a new model of code organisation - a replacement for Object Oriented programming that is focused on adding functions to groups of DOM elements based on the structure and contents of those DOM elements. It's a merging of the model and view layer that initially seems weird, but can give very powerful results.
We're standing on the shoulders of giants here - combining ideas from Prototype's behaviour & lowpro and jQuery's effen & livequery (who themselves stole ideals from Self's Morphic UI and others), but extending & combining the concepts presented in those tools to provide a complete alternative to traditional OO concepts - self-aware methods, inheritance, polymorphisim and namespacing without a single class definition.
h2. Getting Started
-* Walk through the "Tutorial":http://hafriedlander.github.com/jquery.concrete/tutorial/
+* Walk through the "Tutorial":http://hafriedlander.github.com/jquery.entwine/tutorial/
* Watch the "Screencast":http://www.vimeo.com/6353390 (shot during a introductory developer meeting at SilverStripe)
-* Join the "Google Group":http://groups.google.com/group/jquery-concrete and let us know what you think, or what other features you'd like to see
+* Join the "Google Group":http://groups.google.com/group/jquery-entwine and let us know what you think, or what other features you'd like to see
-h2. Warning: Pending name change
+h2. Name change
-"Concrete5":http://www.concrete5.org/ has asserted their trademark, and requested I change the name of this project to avoid confusion with their CMS product. Since they asked nicely, a name change is pending. The current method names will be retained as aliases, so no code will break. What the new name will be is still under discussion - check the "Google Group Discussion":http://groups.google.com/group/jquery-concrete/browse_thread/thread/c62dd699f3fe2e83 for the latest.
+jQuery Entwine used to be called jQuery Concrete. The name was changed to avoid confusion with another product. The concrete function remains as an alias, but all new code should use entwine
h2. Basic use
h4. First intro
-To attach methods to DOM nodes, call the `concrete` function on a jQuery selector object, passing a hash listing the method names and bodys
+To attach methods to DOM nodes, call the `entwine` function on a jQuery selector object, passing a hash listing the method names and bodys
<pre><code>
- $('div').concrete({
+ $('div').entwine({
foo: function(..){..},
bar: function(..){..}
});
@@ -50,13 +50,13 @@ Given this DOM structure:
</body>
</code></pre>
-And this concrete definition
+And this entwine definition
<pre><code>
- $('.internal_text').concrete({
+ $('.internal_text').entwine({
foo: function(){ console.log(this.text()); }
});
- $('.attribute_text').concrete({
+ $('.attribute_text').entwine({
foo: function(){ console.log(this.attr('rel')); }
});
</code></pre>
@@ -76,12 +76,12 @@ Will log this to the console
h4. Limitations
-When defining methods, the jQuery object that concrete is called on must be a plain selector, without context. These examples will not work
+When defining methods, the jQuery object that entwine is called on must be a plain selector, without context. These examples will not work
<pre><code>
- $('div', el).concrete(...)
- $([ela, elb, elc]).concrete(...)
- $('<div id="a"></div>').concrete(...)
+ $('div', el).entwine(...)
+ $([ela, elb, elc]).entwine(...)
+ $('<div id="a"></div>').entwine(...)
</code></pre>
h2. Live
@@ -104,13 +104,13 @@ Another example. Given this DOM structure
</body>
</code></pre>
-And this concrete definition
+And this entwine definition
<pre><code>
- $('div').concrete({
+ $('div').entwine({
foo: function(){ console.log(this.text()); }
});
- $('.attribute_text').concrete({
+ $('.attribute_text').entwine({
foo: function(){ console.log(this.attr('rel')); }
});
</code></pre>
@@ -138,10 +138,10 @@ name. Just like other functions this binding will be live, and only the most spe
<head>
<script type='text/javascript'>
/* No need for onready wrapper. Events are bound as needed */
- $('div').concrete({
+ $('div').entwine({
onclick: function(){ this.css({backgroundColor: 'blue'}); }
});
- $('.green').concrete({
+ $('.green').entwine({
onclick: function(){ this.css({color: 'green'}); }
});
</script>
@@ -157,7 +157,7 @@ h2. Constructors / Destructors
Declaring a function with the name `onmatch` will create a behavior that is called on each object when it matches. Likewise, `onunmatch` will
be called when an object that did match this selector stops matching it (because it is removed, or because you've changed its properties).
-Note that an onunmatch block must be paired with an onmatch block - an onunmatch without an onmatch _in the same concrete definition block_ is illegal
+Note that an onunmatch block must be paired with an onmatch block - an onunmatch without an onmatch _in the same entwine definition block_ is illegal
Like other functions, only the most specific definition will be used. However, because property changes are not atomic, this may not work as you
expect.
@@ -167,8 +167,8 @@ h2. Namespaces
To avoid name clashes, to allow multiple bindings to the same event, and to generally seperate a set of functions from other code you can use namespaces
<pre><code>
- $.concrete('foo.bar', function($){
- $('div').concrete({
+ $.entwine('foo.bar', function($){
+ $('div').entwine({
baz: function(){}
});
});
@@ -177,19 +177,19 @@ To avoid name clashes, to allow multiple bindings to the same event, and to gene
You can then call these functions like this:
<pre><code>
- $('div').concrete('foo.bar').baz()
+ $('div').entwine('foo.bar').baz()
</code></pre>
Namespaced functions work just like regular functions (`this` is still set to a matching DOM Node). However, specifity is calculated per namespace.
This is particularly useful for events, because given this:
<pre><code>
- $('div').concrete({
+ $('div').entwine({
onclick: function(){ this.css({backgroundColor: 'blue'}); }
});
- $.concrete('foo', function($){
- $('div').concrete({
+ $.entwine('foo', function($){
+ $('div').entwine({
onclick: function(){ this.css({color: 'green'}); }
});
});
@@ -207,14 +207,14 @@ Inside a namespace definition, functions remember the namespace they are in, and
Where they don't exist, they will be looked up in the base namespace
<pre><code>
- $.concrete('foo', function($){
- $('div').concrete({
+ $.entwine('foo', function($){
+ $('div').entwine({
bar: function() { this.baz(); this.qux(); }
baz: function() { console.log('baz'); }
})
})
- $('div').concrete({
+ $('div').entwine({
qux: function() { console.log('qux'); }
})
</code></pre>
@@ -227,20 +227,20 @@ Note that 'exists' means that a function is declared in this namespace for _any_
<div>Internal text</div>
</code></pre>
-And the concrete definitions
+And the entwine definitions
<pre><code>
- $.concrete('foo', function($){
- $('div').concrete({
+ $.entwine('foo', function($){
+ $('div').entwine({
bar: function() { this.baz(); }
});
- $('span').concrete({
+ $('span').entwine({
baz: function() { console.log('a'); }
});
})
- $('div').concrete({
+ $('div').entwine({
baz: function() { console.log('b'); }
})
</code></pre>
@@ -249,15 +249,15 @@ Then doing $('div').bar(); will _not_ display b. Even though the span rule could
h4. Nesting namespace blocks
-You can also nest declarations. In this next example, we're defining the functions $().concrete('zap').bar() and $().concrete('zap.pow').baz()
+You can also nest declarations. In this next example, we're defining the functions $().entwine('zap').bar() and $().entwine('zap.pow').baz()
<pre><code>
- $.concrete('zap', function($){
- $('div').concrete({
+ $.entwine('zap', function($){
+ $('div').entwine({
bar: function() { .. }
})
- $.concrete('pow', function($){
- $('div').concrete({
+ $.entwine('pow', function($){
+ $('div').entwine({
baz: function() { .. }
})
})
@@ -268,12 +268,12 @@ h4. Calling to another namespace (and forcing base)
Inside a namespace, namespace lookups are by default relative to the current namespace.
-In some situations (such as the last example) you may want to force using the base namespace. In this case you can call concrete with the first argument being the base namespace code '.'. For example, if the first definition in the previous example was
+In some situations (such as the last example) you may want to force using the base namespace. In this case you can call entwine with the first argument being the base namespace code '.'. For example, if the first definition in the previous example was
<pre><code>
- $.concrete('foo', function($){
- $('div').concrete({
- bar: function() { this.concrete('.').baz(); }
+ $.entwine('foo', function($){
+ $('div').entwine({
+ bar: function() { this.entwine('.').baz(); }
})
})
</code></pre>
@@ -282,16 +282,16 @@ Then b _would_ be output to the console.
h4. Using
-Sometimes a block outside of a namespace will need to refer to that namespace repeatedly. By passing a function to the concrete function, you can change the looked-up namespace
+Sometimes a block outside of a namespace will need to refer to that namespace repeatedly. By passing a function to the entwine function, you can change the looked-up namespace
<pre><code>
- $.concrete('foo', function($){
- $('div').concrete({
+ $.entwine('foo', function($){
+ $('div').entwine({
bar: function() { console.log('a'); }
})
})
- $('div').concrete('foo', function(){
+ $('div').entwine('foo', function(){
this.bar();
this.bar();
this.bar();
View
15 build.sh
@@ -1,12 +1,12 @@
#!/bin/sh
# Specify the output file's name
-FILE="dist/jquery.concrete-dist.js"
+FILE="dist/jquery.entwine-dist.js"
mkdir -p dist
rm dist/*.js
-echo "/* jQuery.Concrete - Copyright 2009 Hamish Friedlander and SilverStripe. Version $VER. */" > $FILE
+echo "/* jQuery.Entwine - Copyright 2009 Hamish Friedlander and SilverStripe. Version $VER. */" > $FILE
for x in \
vendor/jquery.selector/jquery.class.js \
@@ -14,11 +14,12 @@ for x in \
vendor/jquery.selector/jquery.selector.specifity.js \
vendor/jquery.selector/jquery.selector.matches.js \
src/jquery.focusinout.js \
- src/jquery.concrete.js \
- src/jquery.concrete.dommaybechanged.js \
- src/jquery.concrete.events.js \
- src/jquery.concrete.ctors.js \
- src/jquery.concrete.properties.js
+ src/jquery.entwine.js \
+ src/jquery.entwine.dommaybechanged.js \
+ src/jquery.entwine.events.js \
+ src/jquery.entwine.ctors.js \
+ src/jquery.entwine.properties.js \
+ src/jquery.entwine.legacy.js
do \
echo >> $FILE
echo "/* $x */" >> $FILE
View
186 dist/jquery.entwine-dist.js
@@ -1,4 +1,4 @@
-/* jQuery.Concrete - Copyright 2009 Hamish Friedlander and SilverStripe. Version . */
+/* jQuery.Entwine - Copyright 2009 Hamish Friedlander and SilverStripe. Version . */
/* vendor/jquery.selector/jquery.class.js */
@@ -735,7 +735,7 @@ Sizzle is good for finding elements for a selector, but not so good for telling
})(jQuery);;
-/* src/jquery.concrete.js */
+/* src/jquery.entwine.js */
var console;
@@ -743,30 +743,30 @@ var console;
var namespaces = {};
- $.concrete = function() {
- $.fn.concrete.apply(null, arguments);
+ $.entwine = function() {
+ $.fn.entwine.apply(null, arguments);
}
/**
* A couple of utility functions for accessing the store outside of this closure, and for making things
* operate in a little more easy-to-test manner
*/
- $.extend($.concrete, {
+ $.extend($.entwine, {
/**
* Get all the namespaces. Useful for introspection? Internal interface of Namespace not guaranteed consistant
*/
namespaces: namespaces,
/**
- * Remove all concrete rules
+ * Remove all entwine rules
*/
clear_all_rules: function() {
// Remove proxy functions
- for (var k in $.fn) { if ($.fn[k].concrete) delete $.fn[k] ; }
- // Remove bound events - TODO: Make this pluggable, so this code can be moved to jquery.concrete.events.js
- $(document).unbind('.concrete');
+ for (var k in $.fn) { if ($.fn[k].entwine) delete $.fn[k] ; }
+ // Remove bound events - TODO: Make this pluggable, so this code can be moved to jquery.entwine.events.js
+ $(document).unbind('.entwine');
// Remove namespaces, and start over again
- namespaces = $.concrete.namespaces = {};
+ namespaces = $.entwine.namespaces = {};
},
WARN_LEVEL_NONE: 0,
@@ -780,14 +780,14 @@ var console;
/** Utility to optionally display warning messages depending on level */
warn: function(message, level) {
- if (level <= $.concrete.warningLevel && console && console.warn) {
+ if (level <= $.entwine.warningLevel && console && console.warn) {
console.warn(message);
if (console.trace) console.trace();
}
},
warn_exception: function(where, /* optional: */ on, e) {
- if ($.concrete.WARN_LEVEL_IMPORTANT <= $.concrete.warningLevel && console && console.warn) {
+ if ($.entwine.WARN_LEVEL_IMPORTANT <= $.entwine.warningLevel && console && console.warn) {
if (arguments.length == 2) { e = on; on = null; }
if (on) console.warn('Uncaught exception',e,'in',where,'on',on);
@@ -822,7 +822,7 @@ var console;
(a.rulecount - b.rulecount) ;
}
- $.concrete.RuleList = function() {
+ $.entwine.RuleList = function() {
var list = [];
list.addRule = function(selector, name){
@@ -840,11 +840,11 @@ var console;
var handlers = [];
/**
- * A Namespace holds all the information needed for adding concrete methods to a namespace (including the _null_ namespace)
+ * A Namespace holds all the information needed for adding entwine methods to a namespace (including the _null_ namespace)
*/
- $.concrete.Namespace = Base.extend({
+ $.entwine.Namespace = Base.extend({
init: function(name){
- if (name && !name.match(/^[A-Za-z0-9.]+$/)) $.concrete.warn('Concrete namespace '+name+' is not formatted as period seperated identifiers', $.concrete.WARN_LEVEL_BESTPRACTISE);
+ if (name && !name.match(/^[A-Za-z0-9.]+$/)) $.entwine.warn('Entwine namespace '+name+' is not formatted as period seperated identifiers', $.entwine.WARN_LEVEL_BESTPRACTISE);
name = name || '__base';
this.name = name;
@@ -891,18 +891,18 @@ var console;
// @bug, @cantfix: Any class functions added to $ after this call won't get mirrored through
$.extend(this.$, $);
- // We override concrete to inject the name of this namespace when defining blocks inside this namespace
- var concrete_wrapper = this.injectee.concrete = function(spacename) {
+ // We override entwine to inject the name of this namespace when defining blocks inside this namespace
+ var entwine_wrapper = this.injectee.entwine = function(spacename) {
var args = arguments;
if (!spacename || typeof spacename != 'string') { args = $.makeArray(args); args.unshift(name); }
else if (spacename.charAt(0) != '.') args[0] = name+'.'+spacename;
- return $.fn.concrete.apply(this, args);
+ return $.fn.entwine.apply(this, args);
}
- this.$.concrete = function() {
- concrete_wrapper.apply(null, arguments);
+ this.$.entwine = function() {
+ entwine_wrapper.apply(null, arguments);
}
for (var i = 0; i < handlers.length; i++) {
@@ -914,10 +914,10 @@ var console;
for (var k in overrides) this.injectee[k] = overrides[k];
}
- // Inject $.concrete function overrides
+ // Inject $.entwine function overrides
if (builder = handler.namespaceStaticOverrides) {
var overrides = builder(this);
- for (var k in overrides) this.$.concrete[k] = overrides[k];
+ for (var k in overrides) this.$.entwine[k] = overrides[k];
}
}
}
@@ -928,7 +928,7 @@ var console;
* Used by proxy for all calls, and by ctorProxy to handle _super calls
* @param {String} name - name of the function as passed in the construction object
* @param {String} funcprop - the property on the Rule object that gives the actual function to call
- * @param {function} basefunc - the non-concrete function to use as the catch-all function at the bottom of the stack
+ * @param {function} basefunc - the non-entwine function to use as the catch-all function at the bottom of the stack
*/
one: function(name, funcprop, basefunc) {
var namespace = this;
@@ -945,7 +945,7 @@ var console;
return ret;
}
}
- // If we didn't find a concrete-defined function, but there is a non-concrete function to use as a base, try that
+ // If we didn't find a entwine-defined function, but there is a non-entwine function to use as a base, try that
if (basefunc) return basefunc.apply(namespace.$(el), args);
}
@@ -956,7 +956,7 @@ var console;
* A proxy is a function attached to a callable object (either the base jQuery.fn or a subspace object) which handles
* finding and calling the correct function for each member of the current jQuery context
* @param {String} name - name of the function as passed in the construction object
- * @param {function} basefunc - the non-concrete function to use as the catch-all function at the bottom of the stack
+ * @param {function} basefunc - the non-entwine function to use as the catch-all function at the bottom of the stack
*/
build_proxy: function(name, basefunc) {
var one = this.one(name, 'func', basefunc);
@@ -973,17 +973,17 @@ var console;
},
bind_proxy: function(selector, name, func) {
- var rulelist = this.store[name] || (this.store[name] = $.concrete.RuleList());
+ var rulelist = this.store[name] || (this.store[name] = $.entwine.RuleList());
var rule = rulelist.addRule(selector, name); rule.func = func;
- if (!this.injectee.hasOwnProperty(name) || !this.injectee[name].concrete) {
+ if (!this.injectee.hasOwnProperty(name) || !this.injectee[name].entwine) {
this.injectee[name] = this.build_proxy(name, this.injectee.hasOwnProperty(name) ? this.injectee[name] : null);
- this.injectee[name].concrete = true;
+ this.injectee[name].entwine = true;
}
- if (!this.injectee[name].concrete) {
- $.concrete.warn('Warning: Concrete function '+name+' clashes with regular jQuery function - concrete function will not be callable directly on jQuery object', $.concrete.WARN_LEVEL_IMPORTANT);
+ if (!this.injectee[name].entwine) {
+ $.entwine.warn('Warning: Entwine function '+name+' clashes with regular jQuery function - entwine function will not be callable directly on jQuery object', $.entwine.WARN_LEVEL_IMPORTANT);
}
},
@@ -1015,12 +1015,12 @@ var console;
* A handler is some javascript code that adds support for some time of key / value pair passed in the hash to the Namespace add method.
* The default handlers provided (and included by default) are event, ctor and properties
*/
- $.concrete.Namespace.addHandler = function(handler) {
+ $.entwine.Namespace.addHandler = function(handler) {
for (var i = 0; i < handlers.length && handlers[i].order < handler.order; i++) { /* Pass */ }
handlers.splice(i, 0, handler);
}
- $.concrete.Namespace.addHandler({
+ $.entwine.Namespace.addHandler({
order: 50,
bind: function(selector, k, v){
@@ -1033,22 +1033,22 @@ var console;
$.extend($.fn, {
/**
- * Main concrete function. Used for new definitions, calling into a namespace (or forcing the base namespace) and entering a using block
+ * Main entwine function. Used for new definitions, calling into a namespace (or forcing the base namespace) and entering a using block
*
*/
- concrete: function(spacename) {
+ entwine: function(spacename) {
var i = 0;
/* Don't actually work out selector until we try and define something on it - we might be opening a namespace on an function-traveresed object
which have non-standard selectors like .parents(.foo).slice(0,1) */
var selector = null;
/* By default we operator on the base namespace */
- var namespace = namespaces.__base || $.concrete.Namespace();
+ var namespace = namespaces.__base || $.entwine.Namespace();
/* If the first argument is a string, then it's the name of a namespace. Look it up */
if (typeof spacename == 'string') {
if (spacename.charAt('0') == '.') spacename = spacename.substr(1);
- if (spacename) namespace = namespaces[spacename] || $.concrete.Namespace(spacename);
+ if (spacename) namespace = namespaces[spacename] || $.entwine.Namespace(spacename);
i=1;
}
@@ -1056,18 +1056,18 @@ var console;
while (i < arguments.length) {
var res = arguments[i++];
- // If it's a function, call it - either it's a using block or it's a namespaced concrete definition
+ // If it's a function, call it - either it's a using block or it's a namespaced entwine definition
if ($.isFunction(res)) {
- if (res.length != 1) $.concrete.warn('Function block inside concrete definition does not take $ argument properly', $.concrete.WARN_LEVEL_IMPORTANT);
+ if (res.length != 1) $.entwine.warn('Function block inside entwine definition does not take $ argument properly', $.entwine.WARN_LEVEL_IMPORTANT);
res = res.call(namespace.$(this), namespace.$);
}
- // If we have a concrete definition hash, inject it into namespace
+ // If we have a entwine definition hash, inject it into namespace
if (res) {
if (selector === null) selector = this.selector ? $.selector(this.selector) : false;
if (selector) namespace.add(selector, res);
- else $.concrete.warn('Concrete block given to concrete call without selector. Make sure you call $(selector).concrete when defining blocks', $.concrete.WARN_LEVEL_IMPORTANT);
+ else $.entwine.warn('Entwine block given to entwine call without selector. Make sure you call $(selector).entwine when defining blocks', $.entwine.WARN_LEVEL_IMPORTANT);
}
}
@@ -1076,7 +1076,7 @@ var console;
},
/**
- * Calls the next most specific version of the current concrete method
+ * Calls the next most specific version of the current entwine method
*/
_super: function(){
var rv, i = this.length;
@@ -1092,7 +1092,7 @@ var console;
;
-/* src/jquery.concrete.dommaybechanged.js */
+/* src/jquery.entwine.dommaybechanged.js */
(function($){
@@ -1108,7 +1108,7 @@ var console;
check_id = null;
}
- $.extend($.concrete, {
+ $.extend($.entwine, {
/**
* Make onmatch and onunmatch work in synchronous mode - that is, new elements will be detected immediately after
* the DOM manipulation that made them match. This is only really useful for during testing, since it's pretty slow
@@ -1160,7 +1160,7 @@ var console;
})(jQuery);;
-/* src/jquery.concrete.events.js */
+/* src/jquery.entwine.events.js */
(function($) {
@@ -1181,7 +1181,7 @@ var console;
}
/* Add the methods to handle event binding to the Namespace class */
- $.concrete.Namespace.addMethods({
+ $.entwine.Namespace.addMethods({
build_event_proxy: function(name) {
var one = this.one(name, 'func');
@@ -1272,7 +1272,7 @@ var console;
},
bind_event: function(selector, name, func, event) {
- var funcs = this.store[name] || (this.store[name] = $.concrete.RuleList()) ;
+ var funcs = this.store[name] || (this.store[name] = $.entwine.RuleList()) ;
var proxies = funcs.proxies || (funcs.proxies = {});
var rule = funcs.addRule(selector, name); rule.func = func;
@@ -1298,18 +1298,18 @@ var console;
break;
case 'onfocus':
case 'onblur':
- $.concrete.warn('Event '+event+' not supported - using focusin / focusout instead', $.concrete.WARN_LEVEL_IMPORTANT);
+ $.entwine.warn('Event '+event+' not supported - using focusin / focusout instead', $.entwine.WARN_LEVEL_IMPORTANT);
}
// If none of the special handlers created a proxy, use the generic proxy
if (!proxies[name]) proxies[name] = this.build_event_proxy(name);
- $(document).bind(event+'.concrete', proxies[name]);
+ $(document).bind(event+'.entwine', proxies[name]);
}
}
});
- $.concrete.Namespace.addHandler({
+ $.entwine.Namespace.addHandler({
order: 40,
bind: function(selector, k, v){
@@ -1343,14 +1343,14 @@ var console;
;
-/* src/jquery.concrete.ctors.js */
+/* src/jquery.entwine.ctors.js */
(function($) {
/* Add the methods to handle constructor & destructor binding to the Namespace class */
- $.concrete.Namespace.addMethods({
+ $.entwine.Namespace.addMethods({
bind_condesc: function(selector, name, func) {
- var ctors = this.store.ctors || (this.store.ctors = $.concrete.RuleList()) ;
+ var ctors = this.store.ctors || (this.store.ctors = $.entwine.RuleList()) ;
var rule;
for (var i = 0 ; i < ctors.length; i++) {
@@ -1377,7 +1377,7 @@ var console;
el.i = i; el.f = one;
try { func.call(namespace.$(el)); }
- catch(e) { $.concrete.warn_exception(name, el, e); }
+ catch(e) { $.entwine.warn_exception(name, el, e); }
finally { el.i = tmp_i; el.f = tmp_f; }
}
}
@@ -1387,7 +1387,7 @@ var console;
}
});
- $.concrete.Namespace.addHandler({
+ $.entwine.Namespace.addHandler({
order: 30,
bind: function(selector, k, v) {
@@ -1410,9 +1410,9 @@ var console;
*/
$(document).bind('DOMMaybeChanged', function(){
// For every namespace
- for (var k in $.concrete.namespaces) {
+ for (var k in $.entwine.namespaces) {
// That has constructors or destructors
- var ctors = $.concrete.namespaces[k].store.ctors;
+ var ctors = $.entwine.namespaces[k].store.ctors;
if (ctors) {
// Keep a record of elements that have matched already
@@ -1458,25 +1458,25 @@ var console;
;
-/* src/jquery.concrete.properties.js */
+/* src/jquery.entwine.properties.js */
(function($) {
- var concrete_prepend = '__concrete!';
+ var entwine_prepend = '__entwine!';
- var getConcreteData = function(el, namespace, property) {
- return el.data(concrete_prepend + namespace + '!' + property);
+ var getEntwineData = function(el, namespace, property) {
+ return el.data(entwine_prepend + namespace + '!' + property);
}
- var setConcreteData = function(el, namespace, property, value) {
- return el.data(concrete_prepend + namespace + '!' + property, value);
+ var setEntwineData = function(el, namespace, property, value) {
+ return el.data(entwine_prepend + namespace + '!' + property, value);
}
- var getConcreteDataAsHash = function(el, namespace) {
+ var getEntwineDataAsHash = function(el, namespace) {
var hash = {};
var id = jQuery.data(el[0]);
- var matchstr = concrete_prepend + namespace + '!';
+ var matchstr = entwine_prepend + namespace + '!';
var matchlen = matchstr.length;
var cache = jQuery.cache[id];
@@ -1487,41 +1487,41 @@ var console;
return hash;
}
- var setConcreteDataFromHash = function(el, namespace, hash) {
- for (var k in hash) setConcreteData(namespace, k, hash[k]);
+ var setEntwineDataFromHash = function(el, namespace, hash) {
+ for (var k in hash) setEntwineData(namespace, k, hash[k]);
}
- var concreteData = function(el, namespace, args) {
+ var entwineData = function(el, namespace, args) {
switch (args.length) {
case 0:
- return getConcreteDataAsHash(el, namespace);
+ return getEntwineDataAsHash(el, namespace);
case 1:
- if (typeof args[0] == 'string') return getConcreteData(el, namespace, args[0]);
- else return setConcreteDataFromHash(el, namespace, args[0]);
+ if (typeof args[0] == 'string') return getEntwineData(el, namespace, args[0]);
+ else return setEntwineDataFromHash(el, namespace, args[0]);
default:
- return setConcreteData(el, namespace, args[0], args[1]);
+ return setEntwineData(el, namespace, args[0], args[1]);
}
}
$.extend($.fn, {
- concreteData: function() {
- return concreteData(this, '__base', arguments);
+ entwineData: function() {
+ return entwineData(this, '__base', arguments);
}
});
- $.concrete.Namespace.addHandler({
+ $.entwine.Namespace.addHandler({
order: 60,
bind: function(selector, k, v) {
- if (k.charAt(0) != k.charAt(0).toUpperCase()) $.concrete.warn('Concrete property '+k+' does not start with a capital letter', $.concrete.WARN_LEVEL_BESTPRACTISE);
+ if (k.charAt(0) != k.charAt(0).toUpperCase()) $.entwine.warn('Entwine property '+k+' does not start with a capital letter', $.entwine.WARN_LEVEL_BESTPRACTISE);
// Create the getters and setters
var getterName = 'get'+k;
var setterName = 'set'+k;
- this.bind_proxy(selector, getterName, function() { return this.concreteData(k) || v ; });
- this.bind_proxy(selector, setterName, function(v){ return this.concreteData(k, v); });
+ this.bind_proxy(selector, getterName, function() { return this.entwineData(k) || v ; });
+ this.bind_proxy(selector, setterName, function(v){ return this.entwineData(k, v); });
// Get the get and set proxies we just created
@@ -1537,8 +1537,8 @@ var console;
namespaceMethodOverrides: function(namespace){
return {
- concreteData: function() {
- return concreteData(this, namespace.name, arguments);
+ entwineData: function() {
+ return entwineData(this, namespace.name, arguments);
}
};
}
@@ -1547,3 +1547,29 @@ var console;
})(jQuery);
;
+
+/* src/jquery.entwine.legacy.js */
+
+(function($) {
+
+ // Adds back concrete methods for backwards compatibility
+ $.concrete = $.entwine;
+ $.fn.concrete = $.fn.entwine;
+ $.fn.concreteData = $.fn.entwineData;
+
+ // Use addHandler to hack in the namespace.$.concrete equivilent to the namespace.$.entwine namespace-injection
+ $.entwine.Namespace.addHandler({
+ order: 100,
+ bind: function(selector, k, v) { return false; },
+
+ namespaceMethodOverrides: function(namespace){
+ namespace.$.concrete = namespace.$.entwine;
+ namespace.injectee.concrete = namespace.injectee.entwine;
+ namespace.injectee.concreteData = namespace.injectee.entwineData;
+ return {};
+ }
+ });
+
+})(jQuery);
+;
+
View
10 spec/legacy/spec-dist.html
@@ -1,12 +1,12 @@
<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>
+ <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 src="../../dist/jquery.entwine-dist.js"></script>
<script>
function runSuites() {
View
27 spec/legacy/spec.html
@@ -1,20 +1,21 @@
<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>
+ <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="../../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 src="../../src/jquery.entwine.js"></script>
+ <script src="../../src/jquery.entwine.dommaybechanged.js"></script>
+ <script src="../../src/jquery.entwine.events.js"></script>
+ <script src="../../src/jquery.entwine.ctors.js"></script>
+ <script src="../../src/jquery.entwine.properties.js"></script>
+ <script src="../../src/jquery.entwine.legacy.js"></script>
<script>
function runSuites() {
View
14 spec/spec-dist.html
@@ -6,17 +6,17 @@
<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 src="../dist/jquery.entwine-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')
+ .exec('spec.entwine.basics.js')
+ .exec('spec.entwine.namespaces.js')
+ .exec('spec.entwine.super.js')
+ .exec('spec.entwine.events.js')
+ .exec('spec.entwine.ctors.js')
+ .exec('spec.entwine.properties.js')
.run()
.report()
}
View
36 spec/spec.entwine.basics.js
@@ -1,8 +1,8 @@
-describe 'Concrete'
+describe 'Entwine'
describe 'Basics'
before
- $.concrete.warningLevel = $.concrete.WARN_LEVEL_BESTPRACTISE;
+ $.entwine.warningLevel = $.entwine.WARN_LEVEL_BESTPRACTISE;
$('body').append('<div id="dom_test"></div>');
end
after
@@ -10,26 +10,26 @@ describe 'Concrete'
end
before_each
- $.concrete.clear_all_rules();
+ $.entwine.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({
+ $('#a').entwine({
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({
+ $('[data-fieldtype=foo]').entwine({
foo: function(){return this.attr('id');}
});
$('.a').foo().should.equal 'a'
end
it 'can attach and call several base functions'
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){return 'foo_' + this.attr('id');},
bar: function(){return 'bar_' + this.attr('id');}
});
@@ -38,29 +38,29 @@ describe 'Concrete'
end
it 'can attach and call a namespaced function'
- $.concrete('bar', function($){
- $('#a').concrete({
+ $.entwine('bar', function($){
+ $('#a').entwine({
foo: function(){return this.attr('id');}
});
});
- $('.a').concrete('bar').foo().should.equal 'a'
+ $('.a').entwine('bar').foo().should.equal 'a'
end
it 'can attach and call a nested namespaced function'
- $.concrete('qux.baz.bar', function($){
- $('#a').concrete({
+ $.entwine('qux.baz.bar', function($){
+ $('#a').entwine({
foo: function(){return this.attr('id');}
});
});
- $('.a').concrete('qux.baz.bar').foo().should.equal 'a'
+ $('.a').entwine('qux.baz.bar').foo().should.equal 'a'
end
it 'can call two functions on two elements'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(this.attr('id'));}
});
- $('#b.c').concrete({
+ $('#b.c').entwine({
foo: function(){res.push(this.attr('id'));}
});
$('#dom_test div').foo();
@@ -69,15 +69,15 @@ describe 'Concrete'
it 'can call two namespaced functions on two elements'
var res = []
- $.concrete('bar', function($){
- $('#a').concrete({
+ $.entwine('bar', function($){
+ $('#a').entwine({
foo: function(){res.push(this.attr('id'));}
});
- $('#b.c').concrete({
+ $('#b.c').entwine({
foo: function(){res.push(this.attr('id'));}
});
});
- $('#dom_test div').concrete('bar').foo();
+ $('#dom_test div').entwine('bar').foo();
res.should.eql ['b', 'a']
end
View
28 spec/spec.entwine.ctors.js
@@ -1,4 +1,4 @@
-describe 'Concrete'
+describe 'Entwine'
describe 'Ctors'
before
@@ -10,14 +10,14 @@ describe 'Concrete'
end
before_each
- $.concrete.synchronous_mode();
- $.concrete.clear_all_rules()
+ $.entwine.synchronous_mode();
+ $.entwine.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;} });
+ $('#b').entwine({onmatch: function(){a = true;} });
a.should.be_false
$('#a').after('<div id="b"></div>');
a.should.be_true
@@ -25,7 +25,7 @@ describe 'Concrete'
it 'calls onunmatch when new element deleted'
var a = 0;
- $('#b').concrete({onmatch: function(){a = 1;}, onunmatch: function(){a = 2;} });
+ $('#b').entwine({onmatch: function(){a = 1;}, onunmatch: function(){a = 2;} });
a.should.equal 0
$('#a').after('<div id="b"></div>');
a.should.equal 1
@@ -35,7 +35,7 @@ describe 'Concrete'
it 'calls onmatch when ruleset matches after class added'
var a = 0;
- $('#a.foo').concrete({onmatch: function(){a = 1;} });
+ $('#a.foo').entwine({onmatch: function(){a = 1;} });
a.should.equal 0
$('#a').addClass('foo');
a.should.equal 1
@@ -43,10 +43,10 @@ describe 'Concrete'
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}}})
+ $('.foo').entwine({onmatch: function(){a = 1;}})
+ $('.foo').entwine('bar', function($){return{onmatch: function(){b = 1;}}})
+ $('#a.foo').entwine({onmatch: function(){c = 1;}})
+ $('#a.foo').entwine('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]
@@ -54,10 +54,10 @@ describe 'Concrete'
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();}}})
+ $('.foo').entwine({onmatch: function(){a += 1;}})
+ $('.foo').entwine('bar', function($){return{onmatch: function(){b += 1;}}})
+ $('#a.foo').entwine({onmatch: function(){this._super(); c = 1; this._super();}})
+ $('#a.foo').entwine('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]
View
36 spec/spec.entwine.events.js
@@ -1,4 +1,4 @@
-describe 'Concrete'
+describe 'Entwine'
describe 'Events'
before
@@ -10,14 +10,14 @@ describe 'Concrete'
end
before_each
- $.concrete.synchronous_mode();
- $.concrete.clear_all_rules()
+ $.entwine.synchronous_mode();
+ $.entwine.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').entwine({onfoo: function(){a = 1;} });
a.should.equal 0
$('#a').trigger('foo');
a.should.equal 1
@@ -25,8 +25,8 @@ describe 'Concrete'
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.a').entwine({onfoo: function(){a = 1;} });
+ $('#a').entwine({onfoo: function(){b = 1;} });
a.should.equal 0
b.should.equal 0
$('#a').trigger('foo');
@@ -36,7 +36,7 @@ describe 'Concrete'
it 'calls namespaced onfoo when foo triggered'
var a = 0;
- $('#a').concrete('bar', function($){return{onfoo: function(){a = 1;} }});
+ $('#a').entwine('bar', function($){return{onfoo: function(){a = 1;} }});
a.should.equal 0
$('#a').trigger('foo');
a.should.equal 1
@@ -44,10 +44,10 @@ describe 'Concrete'
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.a').entwine({onfoo: function(){a = 1;} });
+ $('#a').entwine({onfoo: function(){b = 1;} });
+ $('#a.a').entwine('bar', function($){return{onfoo: function(){c = 1;} }});
+ $('#a').entwine('bar', function($){return{onfoo: function(){d = 1;} }});
[a, b, c, d].should.eql [0, 0, 0, 0]
$('#a').trigger('foo');
@@ -56,8 +56,8 @@ describe 'Concrete'
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').entwine({onfoo: function(){a += 1;} });
+ $('#a.a').entwine({onfoo: function(){this._super(); b += 1; this._super();} });
[a, b].should.eql [0, 0]
$('#a').trigger('foo')
@@ -66,7 +66,7 @@ describe 'Concrete'
it 'passes event object'
var event;
- $('#a').concrete({onfoo: function(e){event = e;} });
+ $('#a').entwine({onfoo: function(e){event = e;} });
$('#a').trigger('foo');
event.should.have_prop 'type', 'foo'
$(event.target).should.have_attr 'id', 'a'
@@ -76,7 +76,7 @@ describe 'Concrete'
var a = 0;
$('<form class="foo" action="javascript:undefined">').appendTo('#dom_test');
- $('.foo').concrete({onsubmit: function(e, d){a = 1;} });
+ $('.foo').entwine({onsubmit: function(e, d){a = 1;} });
a.should.eql 0
$('.foo').trigger('submit');
@@ -86,14 +86,14 @@ describe 'Concrete'
describe 'can pass event data'
it 'on custom events'
var data;
- $('#a').concrete({onfoo: function(e, d){data = d;} });
+ $('#a').entwine({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').entwine({onclick: function(e, d){data = d;} });
$('#a').trigger('click', {finger: 'left'});
data.finger.should.eql 'left'
end
@@ -102,7 +102,7 @@ describe 'Concrete'
var data;
$('<form class="foo" action="javascript:undefined">').appendTo('#dom_test');
- $('.foo').concrete({onsubmit: function(e, d){data = d; return false;} })
+ $('.foo').entwine({onsubmit: function(e, d){data = d; return false;} })
$('.foo').trigger('submit', {cheese: 'burger'});
data.cheese.should.eql 'burger'
View
120 spec/spec.entwine.namespaces.js
@@ -1,5 +1,5 @@
-describe 'Concrete'
+describe 'Entwine'
describe 'Namespaces'
before
$('body').append('<div id="dom_test"></div>')
@@ -9,93 +9,93 @@ describe 'Concrete'
end
before_each
- $.concrete.synchronous_mode();
- $.concrete.clear_all_rules()
+ $.entwine.synchronous_mode();
+ $.entwine.clear_all_rules()
$('#dom_test').html('<div id="a" class="a b c"></div><div id="b" class="c d e"></div>')
end
it 'namespaced functions work (single definition mode)'
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
bar: function(){return 'a';}
}})
- $('#a').concrete('bar').bar().should.equal 'a'
+ $('#a').entwine('bar').bar().should.equal 'a'
end
it 'namespaced functions work (block definition mode)'
- $.concrete('zap', function($){
- $('#a').concrete({
+ $.entwine('zap', function($){
+ $('#a').entwine({
bar: function(){return 'a';}
})
});
- $('#a').concrete('zap').bar().should.equal 'a'
+ $('#a').entwine('zap').bar().should.equal 'a'
end
it 'double-namespaced functions work (block definition mode)'
- $.concrete('zap', function($){
- $.concrete('pow', function($){
- $('#a').concrete({
+ $.entwine('zap', function($){
+ $.entwine('pow', function($){
+ $('#a').entwine({
bar: function(){return 'a';}
})
})
})
- $('#a').concrete('zap.pow').bar().should.equal 'a'
+ $('#a').entwine('zap.pow').bar().should.equal 'a'
end
it 'revert to base namespacing work (block definition mode)'
- $.concrete('zap', function($){
- $.concrete('.pow', function($){
- $('#a').concrete({
+ $.entwine('zap', function($){
+ $.entwine('.pow', function($){
+ $('#a').entwine({
bar: function(){return 'a';}
})
})
})
- $('#a').concrete('pow').bar().should.equal 'a'
+ $('#a').entwine('pow').bar().should.equal 'a'
end
it 'internal to namespace, will look up functions in namespace before in base'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(1);},
bar: function(){res.push(2); this.foo();}
})
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
foo: function(){res.push(3);},
bar: function(){res.push(4); $(this).foo();}
}})
$('#dom_test div').bar();
res.should.eql [2, 1]
- $('#dom_test div').concrete('bar').bar();
+ $('#dom_test div').entwine('bar').bar();
res.should.eql [2, 1, 4, 3]
end
it 'internal to namespace, will look up functions in namespace before in base, even in closure'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(1);},
bar: function(){res.push(2); this.foo();}
})
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
foo: function(){res.push(3);},
bar: function(){res.push(4); $('#a').each(function(){ $(this).foo(); })}
}})
$('#dom_test div').bar();
res.should.eql [2, 1]
- $('#dom_test div').concrete('bar').bar();
+ $('#dom_test div').entwine('bar').bar();
res.should.eql [2, 1, 4, 3]
end
it 'internal to namespace, will look up functions in namespace before in base, even in onmatch'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(1);},
bar: function(){res.push(2); this.foo();}
})
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
foo: function(){res.push(3);}
}})
- $('#a.d').concrete('bar', function($){return{
+ $('#a.d').entwine('bar', function($){return{
onmatch: function(){res.push(4); this.foo();}
}})
@@ -108,106 +108,106 @@ describe 'Concrete'
it 'internal to namespace, will look up functions in base when not present in namespace'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(1);}
})
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
bar: function(){res.push(2); this.foo();}
}})
- $('#dom_test div').concrete('bar').bar();
+ $('#dom_test div').entwine('bar').bar();
res.should.eql [2, 1]
end
it 'internal to namespace, will not look up functions in base if present in namespace, even when not applicable to selector'
var res = []
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
foo: function(){this.bar();}
}})
- $('#a').concrete({
+ $('#a').entwine({
bar: function(){res.push(1);}
})
- $('span').concrete('bar', function($){return{
+ $('span').entwine('bar', function($){return{
bar: function(){res.push(2);}
}})
- $('#a').concrete('bar').foo()
+ $('#a').entwine('bar').foo()
res.should.eql []
end
it 'internal to namespace, can be directed to base namespace'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(1);},
bar: function(){res.push(2); this.foo();}
})
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
foo: function(){res.push(3);},
- bar: function(){res.push(4); this.foo(); this.concrete('.').foo();}
+ bar: function(){res.push(4); this.foo(); this.entwine('.').foo();}
}})
$('#dom_test div').bar();
res.should.eql [2, 1]
- $('#dom_test div').concrete('bar').bar();
+ $('#dom_test div').entwine('bar').bar();
res.should.eql [2, 1, 4, 3, 1]
end
it 'internal to namespace, will look up functions in namespace called the same as a regular jQuery base function'
var res = []
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
load: function(){res.push(1);},
bar: function(){res.push(2); this.load();}
}})
- $('#dom_test div').concrete('bar').bar();
+ $('#dom_test div').entwine('bar').bar();
res.should.eql [2, 1]
end
it 'internal to namespace, can be directed to regular jQuery base function'
var res = []
$.fn.testy = function(){ res.push(1); }
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
testy: function(){res.push(3);},
- bar: function(){res.push(2); this.concrete('.').testy();}
+ bar: function(){res.push(2); this.entwine('.').testy();}
}})
- $('#dom_test div').concrete('bar').bar();
+ $('#dom_test div').entwine('bar').bar();
res.should.eql [2, 1]
end
it 'internal to namespace, can be directed to sub namespace'
var res = []
- $.concrete('zap', function($){
- $('#a').concrete({
- foo: function(){ res.push(1); this.concrete('pow').bar(); }
+ $.entwine('zap', function($){
+ $('#a').entwine({
+ foo: function(){ res.push(1); this.entwine('pow').bar(); }
})
- $.concrete('pow', function($){
- $('#a').concrete({
+ $.entwine('pow', function($){
+ $('#a').entwine({
bar: function(){ res.push(2); }
})
})
})
- $('#dom_test div').concrete('zap').foo();
+ $('#dom_test div').entwine('zap').foo();
res.should.eql [1, 2]
end
it 'internal to namespace, can be directed to unrelated namespace'
var res = []
- $.concrete('zap', function($){
- $('#a').concrete({
- foo: function(){ res.push(1); this.concrete('.pow').bar(); }
+ $.entwine('zap', function($){
+ $('#a').entwine({
+ foo: function(){ res.push(1); this.entwine('.pow').bar(); }
})
- $.concrete('pow', function($){
- $('#a').concrete({
+ $.entwine('pow', function($){
+ $('#a').entwine({
bar: function(){ res.push(2); }
})
})
})
- $.concrete('pow', function($){
- $('#a').concrete({
+ $.entwine('pow', function($){
+ $('#a').entwine({
bar: function(){ res.push(3); }
})
})
- $('#dom_test div').concrete('zap').foo();
+ $('#dom_test div').entwine('zap').foo();
res.should.eql [1, 3]
end
@@ -216,27 +216,27 @@ describe 'Concrete'
var func = function(func) {
func.call($('#a, #b'));
}
- $('#a, #b').concrete('bar', function($){return{
+ $('#a, #b').entwine('bar', function($){return{
zap: function(){res.push($(this).attr('id'));},
bar: function(){res.push(2); func(this.zap);}
}})
- $('#dom_test #a').concrete('bar').bar();
+ $('#dom_test #a').entwine('bar').bar();
res.should.eql [2, 'b', 'a']
end
it 'using block functions'
var res = []
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){res.push(1);}
})
- $('#a').concrete('bar', function($){return{
+ $('#a').entwine('bar', function($){return{
foo: function(){res.push(3);}
}})
$('#dom_test div').foo();
res.should.eql [1]
- $('#dom_test div').concrete('bar', function($){
+ $('#dom_test div').entwine('bar', function($){
$(this).foo();
})
res.should.eql [1, 3]
View
42 spec/spec.entwine.properties.js
@@ -1,5 +1,5 @@
-describe 'Concrete'
+describe 'Entwine'
describe 'Properties'
before
$('body').append('<div id="dom_test"></div>')
@@ -9,19 +9,19 @@ describe 'Concrete'
end
before_each
- $.concrete.clear_all_rules()
+ $.entwine.clear_all_rules()
$('#dom_test').html('<div id="a" class="a b c"></div><div id="b" class="b c"></div>')
end
it 'can define and get a basic property'
- $('#a').concrete({
+ $('#a').entwine({
Foo: null
});
$('.a').getFoo().should.be_null
end
it 'can define and set a basic property'
- $('#a').concrete({
+ $('#a').entwine({
Foo: null
});
$('.a').setFoo(1);
@@ -29,61 +29,61 @@ describe 'Concrete'
end
it 'can define a default value'
- $('#a').concrete({
+ $('#a').entwine({
Foo: 1
});
$('.a').getFoo().should.equal 1
end
it 'should manage proprties in namespaces without clashing'
- $('#a').concrete({
+ $('#a').entwine({
Foo: 1
});
- $.concrete('test', function($){
- $('#a').concrete({
+ $.entwine('test', function($){
+ $('#a').entwine({
Foo: 2
});
});
$('.a').getFoo().should.equal 1
- $('.a').concrete('test').getFoo().should.equal 2
+ $('.a').entwine('test').getFoo().should.equal 2
$('.a').setFoo(4);
- $('.a').concrete('test').setFoo(8);
+ $('.a').entwine('test').setFoo(8);
$('.a').getFoo().should.equal 4
- $('.a').concrete('test').getFoo().should.equal 8
+ $('.a').entwine('test').getFoo().should.equal 8
end
it 'should manage directly setting proprties in namespaces without clashing'
- $('#a').concrete({
+ $('#a').entwine({
Foo: null
});
- $.concrete('test', function($){
- $('#a').concrete({
+ $.entwine('test', function($){
+ $('#a').entwine({
Foo: null
});
});
- $('.a').concreteData('Foo', 4);
- $('.a').concrete('test').concreteData('Foo', 8);
+ $('.a').entwineData('Foo', 4);
+ $('.a').entwine('test').entwineData('Foo', 8);
- $('.a').concreteData('Foo').should.equal 4
- $('.a').concrete('test').concreteData('Foo').should.equal 8
+ $('.a').entwineData('Foo').should.equal 4
+ $('.a').entwine('test').entwineData('Foo').should.equal 8
end
describe 'jQuery style accessors'
it 'can define and get a basic property'
- $('#a').concrete({
+ $('#a').entwine({
Foo: null
});
$('.a').Foo().should.be_null
end
it 'can define and set a basic property'
- $('#a').concrete({
+ $('#a').entwine({
Foo: null
});
$('.a').Foo(1);
@@ -91,7 +91,7 @@ describe 'Concrete'
end
it 'can define a default value'
- $('#a').concrete({
+ $('#a').entwine({
Foo: 1
});
$('.a').Foo().should.equal 1
View
20 spec/spec.entwine.super.js
@@ -1,5 +1,5 @@
-describe 'Concrete'
+describe 'Entwine'
describe 'Super'
before
$('body').append('<div id="dom_test"></div>')
@@ -9,16 +9,16 @@ describe 'Concrete'
end
before_each
- $.concrete.clear_all_rules()
+ $.entwine.clear_all_rules()
$('#dom_test').html('<div id="a" class="a b c">Foo</div><div id="b" class="c d e">Bar</div>')
end
it 'can call the super function'
var a = 1;
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){a *= 2;}
});
- $('#a.a').concrete({
+ $('#a.a').entwine({
foo: function(){a += 2; this._super();}
});
$('#a').foo();
@@ -27,10 +27,10 @@ describe 'Concrete'
it 'super to a non-existant class should be ignored'
var a = 1;
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){a *= 2; this._super();}
});
- $('#a.a').concrete({
+ $('#a.a').entwine({
foo: function(){a += 2; this._super();}
});
$('#a').foo();
@@ -39,11 +39,11 @@ describe 'Concrete'
it 'can call super from two different functions without screwing up what super points to'
var list = [];
- $('#a').concrete({
+ $('#a').entwine({
foo: function(){ list.push('foo'); this.bar(); },
bar: function(){ list.push('bar'); }
});
- $('#a.a').concrete({
+ $('#a.a').entwine({
foo: function(){ list.push('foo2'); this._super(); list.push('foo2'); this._super(); },
bar: function(){ list.push('bar2'); this._super(); }
});
@@ -51,9 +51,9 @@ describe 'Concrete'
list.should.eql [ 'foo2', 'foo', 'bar2', 'bar', 'foo2', 'foo', 'bar2', 'bar' ]
end
- it 'can override (and call via super) a non-concrete jquery function'
+ it 'can override (and call via super) a non-entwine jquery function'
var a = 1
- $('#a').concrete({
+ $('#a').entwine({
text: function(){ a = this._super(); }
});
View
22 spec/spec.html
@@ -10,21 +10,21 @@
<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 src="../src/jquery.entwine.js"></script>
+ <script src="../src/jquery.entwine.dommaybechanged.js"></script>
+ <script src="../src/jquery.entwine.events.js"></script>
+ <script src="../src/jquery.entwine.ctors.js"></script>
+ <script src="../src/jquery.entwine.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')
+ .exec('spec.entwine.basics.js')
+ .exec('spec.entwine.namespaces.js')
+ .exec('spec.entwine.super.js')
+ .exec('spec.entwine.events.js')
+ .exec('spec.entwine.ctors.js')
+ .exec('spec.entwine.properties.js')
.run()
.report()
}
View
12 src/jquery.entwine.ctors.js
@@ -1,9 +1,9 @@
(function($) {
/* Add the methods to handle constructor & destructor binding to the Namespace class */
- $.concrete.Namespace.addMethods({
+ $.entwine.Namespace.addMethods({
bind_condesc: function(selector, name, func) {
- var ctors = this.store.ctors || (this.store.ctors = $.concrete.RuleList()) ;
+ var ctors = this.store.ctors || (this.store.ctors = $.entwine.RuleList()) ;
var rule;
for (var i = 0 ; i < ctors.length; i++) {
@@ -30,7 +30,7 @@
el.i = i; el.f = one;
try { func.call(namespace.$(el)); }
- catch(e) { $.concrete.warn_exception(name, el, e); }
+ catch(e) { $.entwine.warn_exception(name, el, e); }
finally { el.i = tmp_i; el.f = tmp_f; }
}
}
@@ -40,7 +40,7 @@
}
});
- $.concrete.Namespace.addHandler({
+ $.entwine.Namespace.addHandler({
order: 30,
bind: function(selector, k, v) {
@@ -63,9 +63,9 @@
*/
$(document).bind('DOMMaybeChanged', function(){
// For every namespace
- for (var k in $.concrete.namespaces) {
+ for (var k in $.entwine.namespaces) {
// That has constructors or destructors
- var ctors = $.concrete.namespaces[k].store.ctors;
+ var ctors = $.entwine.namespaces[k].store.ctors;
if (ctors) {
// Keep a record of elements that have matched already
View
2  src/jquery.entwine.dommaybechanged.js
@@ -12,7 +12,7 @@
check_id = null;
}
- $.extend($.concrete, {
+ $.extend($.entwine, {
/**
* Make onmatch and onunmatch work in synchronous mode - that is, new elements will be detected immediately after
* the DOM manipulation that made them match. This is only really useful for during testing, since it's pretty slow
View
10 src/jquery.entwine.events.js
@@ -17,7 +17,7 @@
}
/* Add the methods to handle event binding to the Namespace class */
- $.concrete.Namespace.addMethods({
+ $.entwine.Namespace.addMethods({
build_event_proxy: function(name) {
var one = this.one(name, 'func');
@@ -108,7 +108,7 @@
},
bind_event: function(selector, name, func, event) {
- var funcs = this.store[name] || (this.store[name] = $.concrete.RuleList()) ;
+ var funcs = this.store[name] || (this.store[name] = $.entwine.RuleList()) ;
var proxies = funcs.proxies || (funcs.proxies = {});
var rule = funcs.addRule(selector, name); rule.func = func;
@@ -134,18 +134,18 @@
break;
case 'onfocus':
case 'onblur':
- $.concrete.warn('Event '+event+' not supported - using focusin / focusout instead', $.concrete.WARN_LEVEL_IMPORTANT);
+ $.entwine.warn('Event '+event+' not supported - using focusin / focusout instead', $.entwine.WARN_LEVEL_IMPORTANT);
}
// If none of the special handlers created a proxy, use the generic proxy
if (!proxies[name]) proxies[name] = this.build_event_proxy(name);
- $(document).bind(event+'.concrete', proxies[name]);
+ $(document).bind(event+'.entwine', proxies[name]);
}
}
});
- $.concrete.Namespace.addHandler({
+ $.entwine.Namespace.addHandler({
order: 40,
bind: function(selector, k, v){
View
80 src/jquery.entwine.js
@@ -4,30 +4,30 @@ var console;
var namespaces = {};
- $.concrete = function() {
- $.fn.concrete.apply(null, arguments);
+ $.entwine = function() {
+ $.fn.entwine.apply(null, arguments);
}
/**
* A couple of utility functions for accessing the store outside of this closure, and for making things
* operate in a little more easy-to-test manner
*/
- $.extend($.concrete, {
+ $.extend($.entwine, {
/**
* Get all the namespaces. Useful for introspection? Internal interface of Namespace not guaranteed consistant
*/
namespaces: namespaces,
/**
- * Remove all concrete rules
+ * Remove all entwine rules
*/
clear_all_rules: function() {
// Remove proxy functions
- for (var k in $.fn) { if ($.fn[k].concrete) delete $.fn[k] ; }
- // Remove bound events - TODO: Make this pluggable, so this code can be moved to jquery.concrete.events.js
- $(document).unbind('.concrete');
+ for (var k in $.fn) { if ($.fn[k].entwine) delete $.fn[k] ; }
+ // Remove bound events - TODO: Make this pluggable, so this code can be moved to jquery.entwine.events.js
+ $(document).unbind('.entwine');
// Remove namespaces, and start over again
- namespaces = $.concrete.namespaces = {};
+ namespaces = $.entwine.namespaces = {};
},
WARN_LEVEL_NONE: 0,
@@ -41,14 +41,14 @@ var console;
/** Utility to optionally display warning messages depending on level */
warn: function(message, level) {
- if (level <= $.concrete.warningLevel && console && console.warn) {
+ if (level <= $.entwine.warningLevel && console && console.warn) {
console.warn(message);
if (console.trace) console.trace();
}
},
warn_exception: function(where, /* optional: */ on, e) {
- if ($.concrete.WARN_LEVEL_IMPORTANT <= $.concrete.warningLevel && console && console.warn) {
+ if ($.entwine.WARN_LEVEL_IMPORTANT <= $.entwine.warningLevel && console && console.warn) {
if (arguments.length == 2) { e = on; on = null; }
if (on) console.warn('Uncaught exception',e,'in',where,'on',on);
@@ -83,7 +83,7 @@ var console;
(a.rulecount - b.rulecount) ;
}
- $.concrete.RuleList = function() {
+ $.entwine.RuleList = function() {
var list = [];
list.addRule = function(selector, name){
@@ -101,11 +101,11 @@ var console;
var handlers = [];
/**
- * A Namespace holds all the information needed for adding concrete methods to a namespace (including the _null_ namespace)
+ * A Namespace holds all the information needed for adding entwine methods to a namespace (including the _null_ namespace)
*/
- $.concrete.Namespace = Base.extend({
+ $.entwine.Namespace = Base.extend({
init: function(name){
- if (name && !name.match(/^[A-Za-z0-9.]+$/)) $.concrete.warn('Concrete namespace '+name+' is not formatted as period seperated identifiers', $.concrete.WARN_LEVEL_BESTPRACTISE);
+ if (name && !name.match(/^[A-Za-z0-9.]+$/)) $.entwine.warn('Entwine namespace '+name+' is not formatted as period seperated identifiers', $.entwine.WARN_LEVEL_BESTPRACTISE);
name = name || '__base';
this.name = name;
@@ -152,18 +152,18 @@ var console;
// @bug, @cantfix: Any class functions added to $ after this call won't get mirrored through
$.extend(this.$, $);
- // We override concrete to inject the name of this namespace when defining blocks inside this namespace
- var concrete_wrapper = this.injectee.concrete = function(spacename) {
+ // We override entwine to inject the name of this namespace when defining blocks inside this namespace
+ var entwine_wrapper = this.injectee.entwine = function(spacename) {
var args = arguments;
if (!spacename || typeof spacename != 'string') { args = $.makeArray(args); args.unshift(name); }
else if (spacename.charAt(0) != '.') args[0] = name+'.'+spacename;
- return $.fn.concrete.apply(this, args);
+ return $.fn.entwine.apply(this, args);
}
- this.$.concrete = function() {
- concrete_wrapper.apply(null, arguments);
+ this.$.entwine = function() {
+ entwine_wrapper.apply(null, arguments);
}
for (var i = 0; i < handlers.length; i++) {
@@ -175,10 +175,10 @@ var console;
for (var k in overrides) this.injectee[k] = overrides[k];
}
- // Inject $.concrete function overrides
+ // Inject $.entwine function overrides
if (builder = handler.namespaceStaticOverrides) {
var overrides = builder(this);
- for (var k in overrides) this.$.concrete[k] = overrides[k];
+ for (var k in overrides) this.$.entwine[k] = overrides[k];
}
}
}
@@ -189,7 +189,7 @@ var console;
* Used by proxy for all calls, and by ctorProxy to handle _super calls
* @param {String} name - name of the function as passed in the construction object
* @param {String} funcprop - the property on the Rule object that gives the actual function to call
- * @param {function} basefunc - the non-concrete function to use as the catch-all function at the bottom of the stack
+ * @param {function} basefunc - the non-entwine function to use as the catch-all function at the bottom of the stack
*/
one: function(name, funcprop, basefunc) {
var namespace = this;
@@ -206,7 +206,7 @@ var console;
return ret;
}
}
- // If we didn't find a concrete-defined function, but there is a non-concrete function to use as a base, try that
+ // If we didn't find a entwine-defined function, but there is a non-entwine function to use as a base, try that
if (basefunc) return basefunc.apply(namespace.$(el), args);