From 922ae0543639afd0ce39e424f361d56a334f8f3c Mon Sep 17 00:00:00 2001 From: Barnaby B Date: Mon, 2 Mar 2015 18:37:26 -0800 Subject: [PATCH 1/3] adding a require statement assuming that microevents is not global, and adding to the documentation --- README.md | 14 ++++++++++++++ src/query-builder.js | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd36c50d..e10067ec 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,20 @@ Run `grunt test` to run jsHint and the Mocha test suite. Run `grunt list_modules` to get the list of available plugins and languages. +### AMD importing +To import this into require.js you need to set the microevent and extendext folders and set them as dependencies in your AMD file. Like this: + + paths: { + "microevent": "../bower_components/microevent-mistic100/microevent", + "extendext": "../bower_components/extendext/jQuery.extendext", + }, + shim: { + jquery: { + exports: "jQuery" + }, + jquerybuilder: ["jquery", "microevent", "extendext"] + } + ### Contributing Changes have to be done only in `src` directory. The `dist` directory is updated only once in a while before a release. diff --git a/src/query-builder.js b/src/query-builder.js index 262e851c..02ac2cff 100644 --- a/src/query-builder.js +++ b/src/query-builder.js @@ -43,6 +43,10 @@ this.init(options); }; + //Added this to make it work in AMD + if(!!define && typeof define == "function" && !!define.amd){ + var MicroEvent = require("microevent"); + } MicroEvent.mixin(QueryBuilder); @@ -1709,4 +1713,4 @@ }); } -}(jQuery)); \ No newline at end of file +}(jQuery)); From ef23b8c106f79a38ac2a61ce56178563049c1f0f Mon Sep 17 00:00:00 2001 From: Barnaby B Date: Tue, 3 Mar 2015 11:22:57 -0800 Subject: [PATCH 2/3] Fixed a null pointer exception caused by an empty apply message --- src/query-builder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/query-builder.js b/src/query-builder.js index 02ac2cff..3d0119f6 100644 --- a/src/query-builder.js +++ b/src/query-builder.js @@ -1126,7 +1126,7 @@ $target.addClass('has-error'); var $error = $target.find('.error-container').eq(0); - $error.attr('title', fmt.apply(null, errorLoc)); + $error.attr('title', fmt.call(null, "Error at {0}", errorLoc)); } this.trigger('validationError', $target, error); From 2030f9ef6cc4944f95c754b52d5b852f25bd7147 Mon Sep 17 00:00:00 2001 From: Barnaby B Date: Tue, 3 Mar 2015 11:28:43 -0800 Subject: [PATCH 3/3] clarifying that the example is "like" what you'd need, and correcting the directory name to jquer-extendext in the README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e10067ec..728763fb 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,11 @@ Run `grunt test` to run jsHint and the Mocha test suite. Run `grunt list_modules` to get the list of available plugins and languages. ### AMD importing -To import this into require.js you need to set the microevent and extendext folders and set them as dependencies in your AMD file. Like this: +To import this into require.js you need to set the microevent and extendext folders and set them as dependencies in your AMD file. For example, like this: paths: { "microevent": "../bower_components/microevent-mistic100/microevent", - "extendext": "../bower_components/extendext/jQuery.extendext", + "extendext": "../bower_components/jquery-extendext/jQuery.extendext", }, shim: { jquery: {