Permalink
Browse files

Merge branch 'master' of github.com:jupiterjs/canjs

  • Loading branch information...
2 parents be58bb4 + 337ca9f commit 20f07413d8ecfdc97568ebb372ccf79282eab9f1 @amcdnl amcdnl committed Mar 31, 2012
Showing with 139 additions and 178 deletions.
  1. +3 −1 construct/construct.js
  2. +1 −1 control/control_test.js
  3. +8 −7 control/route/route.md
  4. +2 −0 dist/test/can_dojo.html
  5. +2 −0 dist/test/can_yui.html
  6. +122 −168 util/make.js
  7. +1 −1 view/ejs/ejs.js
@@ -293,7 +293,9 @@ steal("can/util/string",function( $ ) {
Constructor.init.apply(Constructor, args || t );
}
- /* @Prototype*/
+ /**
+ * @prototype
+ */
return Constructor;
/**
* @function setup
@@ -32,7 +32,6 @@ if(!(isOpera && isDojo)){
}
}
-
can.append( can.$("#qunit-test-area"), "<div id='things'>div<span>span</span></div>")
var things = new Things("#things",{foo: foo});
@@ -59,6 +58,7 @@ test("data", function(){
var thing1 = new Things("#things",{});
var thing2 = new Things("#things",{});
equals(can.data(can.$('#things'), "controls").length, 2, "there are 2 items in the data array")
+ can.remove( can.$('#things') );
})
if( window.jQuery ){
@@ -6,7 +6,8 @@
The can.Control.route plugin adds a __route__ [can.Control.static.processors processor] to [can.Control].
This allows creating routes and binding to [can.route] in a single step by listening to the _route_ event
-and a route. For example:
+and a route part. Route events will be triggered whenever the route changes to the route part
+the control is listening to. For example:
var Router = can.Control({
init : function(el, options) {
@@ -22,16 +23,16 @@ and a route. For example:
},
"route" : function(data){
- // route is empty
+ // the route is empty
}
});
new Router(window);
-Without a route, the event will be triggered when the route is empty.
-The data passed to the event handler will contain the [can.route.deparam deparamed route] without the
-_route_ attribute. The plugin doesn't affect the way you usually use [can.route]. A control can, for example,
-also set some default values in its _init_ method:
+Just listening to the route event without a route part will trigger when the route is empty.
+The data passed to the event handler is the [can.route.deparam deparamed route] without the
+_route_ attribute. The plugin doesn't affect the way you usually use [can.route].
+A control can, for example, also set some default values in its _init_ method:
init : function(element, options) {
can.route(':type', { type : 'index' });
@@ -42,6 +43,6 @@ also set some default values in its _init_ method:
The following demo shows the above control and default settings in action.
You can edit the hash, follow some example links or directly change the can.route atttributes.
-At the top it shows the event handler, that is being called on the control, and the data passed to it:
+At the top it shows the event handler, that is being triggered on the control, and the data passed to it:
@iframe can/control/route/demo.html 600
@@ -21,6 +21,8 @@
'can/control/control_test.js',
'can/model/model_test.js',
'can/view/ejs/ejs_test.js', function(){
+ QUnit.config.autorun = false;
+ QUnit.config.reorder = false;
QUnit.load();
})
});
@@ -15,6 +15,8 @@
'can/control/control_test.js',
'can/model/model_test.js',
'can/view/ejs/ejs_test.js', function(){
+ QUnit.config.autorun = false;
+ QUnit.config.reorder = false;
QUnit.load();
});
});
View
@@ -7,189 +7,143 @@
* development, building with env.js, using the standalone canjs scripts,
* and using a fully built production.js file.
*
- * 1) development mode - the libaries will be loaded by their corresponding util plugin
- * (the _skip option is ignored in dev mode)
- * 2) while building with env.js - skipCallbacks is set in steal and _skip option causes env.js
- * not load the libary files (because isBuilding is set in open.js). All this is to avoid loading
- * the libraries in env.js, because env throws errors while loading them. skipCallbacks allows no
- * steal callbacks to be called, so the build finishes without error. This is mainly for use in this
- * make.js script. The libs other than jQuery can't be used yet in a full production.js build because
- * of this env weakness.
- * 3) using the standalone canjs scripts - these scripts are build with pluginify, so they don't include any
- * reference to steal. They require the user to load the actual libarary file first, then the corresponding
- * canjs script.
- * 4) using a fully built production.js file - This is only really relevant for jQuery until the env build
- * problem is fixed. The libs are built into the production.js file.
- *
+ * 1) development mode - the libaries will be loaded by their corresponding
+ * util plugin (the _skip option is ignored in dev mode)
+ * 2) while building with env.js - skipCallbacks is set in steal and _skip
+ * option causes env.js not load the libary files (because isBuilding is
+ * set in open.js). All this is to avoid loading the libraries in env.js,
+ * because env throws errors while loading them. skipCallbacks allows no
+ * steal callbacks to be called, so the build finishes without error.
+ * This is mainly for use in this make.js script. The libs other than
+ * jQuery can't be used yet in a full production.js build because of this
+ * env weakness.
+ * 3) using the standalone canjs scripts - these scripts are build with
+ * pluginify, so they don't include any reference to steal. They require
+ * the user to load the actual libarary file first, then the corresponding
+ * canjs script.
+ * 4) using a fully built production.js file - This is only really relevant for
+ * jQuery until the env build problem is fixed. The libs are built into
+ * the production.js file.
*/
+var each = function( obj, fn ) {
+
+ var i, len;
+
+ if ( obj instanceof Array ) {
+ for ( i = 0, len = obj.length; i < len; i++ ) {
+ if ( fn.call( obj, obj[ i ], i, obj ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ if ( fn.call( obj, obj[ i ], i, obj ) === false ) {
+ break;
+ }
+ }
+ }
+
+ },
+ extend = function( d, s ) {
+ for ( var p in s ) {
+ d[p] = s[p];
+ }
+ return d;
+ };
+
load("steal/rhino/rhino.js");
steal('steal/build/pluginify', function() {
+
+ var libs = {
+ "jquery" : {
+ exclude : "can/util/jquery/jquery.1.7.1.js"
+ },
+ "mootools" : {},
+ "zepto" : {},
+ "dojo" : {
+ wrapInner: [
+ '\ndefine("can/dojo", ["dojo/query", "dojo/NodeList-dom", "dojo/NodeList-traverse"], function(){\n',
+ '\nreturn can;\n});\n'
+ ]
+ },
+ "yui" : {
+ wrapInner: [
+ '\nYUI().add("can", function(Y) {\ncan.Y = Y;\n',
+ '}, "0.0.1", {\nrequires: ["node", "io-base", "querystring", "event-focus", "array-extras"],\n optional: ["selector-css2", "selector-css3"]\n});\n'
+ ],
+ }
+
+ },
+ types = {
+ ".min" : true,
+ "" : false
+ },
+ plugins = {
+ "construct/proxy/proxy" : "construct.proxy",
+ "construct/super/super" : "construct.super",
+ "control/plugin/plugin" : "control.plugin",
+ "observe/attributes/attributes" : "observe.attributes",
+ "observe/delegate/delegate" : "observe.delegate",
+ "observe/setter/setter" : "observe.setter",
+ "observe/backup/backup" : "observe.backup",
+ "observe/validations/validations" : "observe.validations"
+ };
+
steal.File("can/dist").mkdirs();
steal.File("can/dist/edge").mkdirs();
- steal.build.pluginify("can/util/make/jquery.js",{
- out : "can/dist/edge/can.jquery.min.js",
- global : "can = {}",
- onefunc : true,
- compress: true,
- skipCallbacks: true,
- exclude : "can/util/jquery/jquery.1.7.1.js"
- });
-
- steal.build.pluginify("can/util/make/mootools.js",{
- out : "can/dist/edge/can.mootools.min.js",
- global : "can = {}",
- onefunc : true,
- compress: true,
- skipCallbacks: true
- });
-
- steal.build.pluginify("can/util/make/zepto.js",{
- out : "can/dist/edge/can.zepto.min.js",
- global : "can = {}",
- onefunc : true,
- compress: true,
- skipCallbacks: true
- });
-
- steal.build.pluginify("can/util/make/dojo.js",{
- out : "can/dist/edge/can.dojo.min.js",
- global : "can = {}",
- onefunc : true,
- compress: true,
- wrapInner: ['\ndefine("can/dojo", ["dojo/query", "dojo/NodeList-dom", "dojo/NodeList-traverse"], function(){\n', '\nreturn can;\n});\n'],
- skipCallbacks: true
- });
-
- steal.build.pluginify("can/util/make/yui.js",{
- out : "can/dist/edge/can.yui.min.js",
- global : "can = {}",
- onefunc : true,
- compress: true,
- wrapInner: ['\nYUI().add("can", function(Y) {\ncan.Y = Y;\n','}, "0.0.1", {\nrequires: ["node", "io-base", "querystring", "event-focus", "array-extras"],\n optional: ["selector-css2", "selector-css3"]\n});\n'],
- skipCallbacks: true
- });
- steal.build.pluginify("can/util/make/jquery.js",{
- out : "can/dist/edge/can.jquery.js",
- global : "can = {}",
- onefunc : true,
- compress: false,
- skipCallbacks: true,
- exclude : "can/util/jquery/jquery.1.7.1.js"
- });
-
- steal.build.pluginify("can/util/make/mootools.js",{
- out : "can/dist/edge/can.mootools.js",
- global : "can = {}",
- onefunc : true,
- compress: false,
- skipCallbacks: true
- });
-
- steal.build.pluginify("can/util/make/zepto.js",{
- out : "can/dist/edge/can.zepto.js",
- global : "can = {}",
- onefunc : true,
- compress: false,
- skipCallbacks: true
- });
-
- steal.build.pluginify("can/util/make/dojo.js",{
- out : "can/dist/edge/can.dojo.js",
- global : "can = {}",
- onefunc : true,
- compress: false,
- wrapInner: ['\ndefine("can/dojo", ["dojo/query", "dojo/NodeList-dom", "dojo/NodeList-traverse"], function(){\n', '\nreturn can;\n});\n'],
- skipCallbacks: true
- });
-
- steal.build.pluginify("can/util/make/yui.js",{
- out : "can/dist/edge/can.yui.js",
- global : "can = {}",
- onefunc : true,
- compress: false,
- wrapInner: ['\nYUI().add("can", function(Y) {\ncan.Y = Y;\n','}, "0.0.1", {\nrequires: ["node", "io-base", "querystring", "event-focus", "array-extras"],\n optional: ["selector-css2", "selector-css3"]\n});\n'],
- skipCallbacks: true
- });
-
- STEALJQUERY = true;
- STEALDOJO = false;
- STEALMOO = false;
- STEALYUI = false;
- STEALZEPTO = false;
-
- steal.build.pluginify("can/construct/proxy/proxy.js", {
- out: "can/dist/edge/can.construct.proxy.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
- });
+ // Build libraries
+ each( libs, function( options, lib ) {
+ each( types, function( compress, type ) {
- steal.build.pluginify("can/construct/super/super.js", {
- out: "can/dist/edge/can.construct.super.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
- });
+ var code;
- steal.build.pluginify("can/control/plugin/plugin.js", {
- out: "can/dist/edge/can.control.plugin.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
- });
+ steal.build.pluginify("can/util/make/" + lib + ".js", extend({
+ out : "can/dist/edge/can." + lib + type + ".js",
+ global : "can = {}",
+ onefunc : true,
+ compress: compress,
+ skipCallbacks: true,
+ }, options ));
+
+ // Strip multiline comments from uncompressed files
+ if ( ! compress ) {
- steal.build.pluginify("can/observe/attributes/attributes.js", {
- out: "can/dist/edge/can.observe.attributes.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
- });
+ // Put new index.html into production mode
+ code = readFile( "can/dist/edge/can." + lib + type + ".js" );
- steal.build.pluginify("can/observe/delegate/delegate.js", {
- out: "can/dist/edge/can.observe.delegate.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
- });
+ // Remove multiline comments
+ code = code.replace( /\/\*(?:.*)(?:\n\s+\*.*)*\n/gim, "");
- steal.build.pluginify("can/observe/setter/setter.js", {
- out: "can/dist/edge/can.observe.setter.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
- });
+ // Remove double semicolons from steal pluginify
+ code = code.replace( /;[\s]*;/gim, ";");
+ code = code.replace( /(\/\/.*)\n[\s]*;/gi, "$1");
- steal.build.pluginify("can/observe/backup/backup.js", {
- out: "can/dist/edge/can.observe.backup.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
+ // Only single new lines
+ code = code.replace( /(\n){3,}/gim, "\n\n");
+
+ // Save the file.
+ steal.File( "can/dist/edge/can." + lib + type + ".js" ).save( code );
+ }
+ });
});
+
+
+ // Build plugins
+ STEALDOJO = STEALMOO = STEALYUI = STEALZEPTO = false;
+ STEALJQUERY = true;
- steal.build.pluginify("can/observe/validations/validations.js", {
- out: "can/dist/edge/can.observe.validations.js",
- global: "can",
- onefunc: true,
- compress: false,
- skipCallbacks: true,
- standAlone: true
+ each( plugins, function( output, input ) {
+ steal.build.pluginify("can/" + input + ".js", {
+ out: "can/dist/edge/can." + output + ".js",
+ global: "can",
+ onefunc: true,
+ compress: false,
+ skipCallbacks: true,
+ standAlone: true
+ });
});
-});
+});
Oops, something went wrong.

0 comments on commit 20f0741

Please sign in to comment.