Skip to content

Commit 5760f70

Browse files
committed
each plugin is its own folder
1 parent 168ca66 commit 5760f70

File tree

11 files changed

+54
-31
lines changed

11 files changed

+54
-31
lines changed

Gruntfile.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ module.exports = function(grunt) {
1212
loaded_modules = [],
1313
loaded_lang = '';
1414

15-
grunt.file.expandMapping('src/plugins/*.js', '', {
16-
flatten: true, ext: ''
17-
})
15+
grunt.file.expand('src/plugins/*/plugin.js')
1816
.forEach(function(f) {
19-
modules[f.dest] = f.src[0];
17+
modules[f.split('/')[2]] = f;
2018
});
2119

2220
grunt.file.expandMapping('src/i18n/*.js', '', {
@@ -35,7 +33,7 @@ module.exports = function(grunt) {
3533
js_files_to_load.push(modules[m]);
3634
loaded_modules.push(m);
3735
}
38-
else {
36+
else if (m !== 'none') {
3937
grunt.fail.warn('Module '+ m +' unknown');
4038
}
4139
});
@@ -237,7 +235,7 @@ module.exports = function(grunt) {
237235
}
238236
});
239237

240-
grunt.log.writeln('\nTriggers in QueryBuilder ' + grunt.template.process('<%= pkg.version %>') + ' :\n');
238+
grunt.log.writeln('\nTriggers in QueryBuilder:\n');
241239

242240
for (var t in triggers) {
243241
grunt.log.write((triggers[t].name)['cyan']);
@@ -253,6 +251,29 @@ module.exports = function(grunt) {
253251
}
254252
});
255253

254+
// display avilable modules
255+
grunt.registerTask('list_modules', '', function() {
256+
grunt.log.writeln('\nAvailable QueryBuilder plugins:\n');
257+
258+
for (var m in modules) {
259+
grunt.log.write(m['cyan']);
260+
261+
if (grunt.file.exists(modules[m].replace(/js$/, 'css'))) {
262+
grunt.log.write(' + CSS');
263+
}
264+
265+
grunt.log.write('\n');
266+
}
267+
268+
grunt.log.writeln('\nAvailable QueryBuilder languages:\n');
269+
270+
for (var l in langs) {
271+
if (l !== 'en') {
272+
grunt.log.writeln(l['cyan']);
273+
}
274+
}
275+
});
276+
256277
grunt.loadNpmTasks('grunt-contrib-uglify');
257278
grunt.loadNpmTasks('grunt-contrib-copy');
258279
grunt.loadNpmTasks('grunt-contrib-cssmin');

examples/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
88
<link rel="stylesheet" href="../src/query-builder.css">
9-
<link rel="stylesheet" href="../src/plugins/bt-tooltip-errors.css">
10-
<link rel="stylesheet" href="../src/plugins/sortable.css">
9+
<link rel="stylesheet" href="../src/plugins/bt-tooltip-errors/plugin.css">
10+
<link rel="stylesheet" href="../src/plugins/sortable/plugin.css">
1111
<link href="../bower_components/seiyria-bootstrap-slider/dist/css/bootstrap-slider.min.css" rel="stylesheet">
1212
</head>
1313

@@ -42,10 +42,10 @@ <h3>Output</h3>
4242
<script src="../bower_components/jquery-extendext/jQuery.extendext.js"></script>
4343
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
4444
<script src="../src/query-builder.js"></script>
45-
<script src="../src/plugins/sql-support.js"></script>
46-
<script src="../src/plugins/mongodb-support.js"></script>
47-
<script src="../src/plugins/bt-tooltip-errors.js"></script>
48-
<script src="../src/plugins/sortable.js"></script>
45+
<script src="../src/plugins/sql-support/plugin.js"></script>
46+
<script src="../src/plugins/mongodb-support/plugin.js"></script>
47+
<script src="../src/plugins/bt-tooltip-errors/plugin.js"></script>
48+
<script src="../src/plugins/sortable/plugin.js"></script>
4949
<script src="../bower_components/seiyria-bootstrap-slider/dist/bootstrap-slider.min.js"></script>
5050

5151
<script>
@@ -201,7 +201,7 @@ <h3>Output</h3>
201201
},
202202
onAfterSetValue: function($rule, value, filter, operator) {
203203
if (operator.accept_values) {
204-
var val = value.split('.');
204+
var val = value[0].split('.');
205205

206206
$rule.find('[name=coord_1]').val(val[0]).trigger('change');
207207
$rule.find('[name=coord_2]').val(val[1]);
File renamed without changes.
File renamed without changes.

src/plugins/bt-tooltip-errors.js renamed to src/plugins/bt-tooltip-errors/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}, options || {});
1818

1919
// add BT Tooltip data
20-
this.on('ruleTemplate', function(h) {
20+
this.on('getRuleTemplate', function(h) {
2121
return h.replace('class="error-container"', 'class="error-container" data-toggle="tooltip"');
2222
});
2323

File renamed without changes.
File renamed without changes.

src/plugins/sortable.js renamed to src/plugins/sortable/plugin.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
(function($){
88
"use strict";
99

10-
$.fn.queryBuilder.defaults.set({
11-
default_rule_flags: {
12-
no_sortable: false
13-
},
14-
icons: {
15-
sort: 'glyphicon glyphicon-sort'
16-
}
17-
});
18-
1910
$.fn.queryBuilder.define('sortable', function(options) {
11+
options = $.extend({
12+
default_no_sortable: false,
13+
icon: 'glyphicon glyphicon-sort'
14+
}, options || {});
15+
2016
/**
2117
* Init HTML5 drag and drop
2218
*/
@@ -94,6 +90,14 @@
9490
/**
9591
* Remove drag handle from non-sortable rules
9692
*/
93+
this.on('getRuleFlags', function(flags) {
94+
if (flags.no_sortable === undefined) {
95+
flags.no_sortable = options.default_no_sortable;
96+
}
97+
98+
return flags;
99+
});
100+
97101
this.on('afterApplyRuleFlags', function($rule, rule, flags) {
98102
if (flags.no_sortable) {
99103
$rule.find('.drag-handle').remove();
File renamed without changes.

src/query-builder.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
onValidationError: null,
5454
onAfterAddGroup: null,
5555
onAfterAddRule: null,
56-
onAfterCreateRuleInput: null,
57-
onAfterChangeOperator: null,
5856

5957
display_errors: true,
6058
allow_groups: -1,
@@ -463,10 +461,6 @@
463461
}
464462

465463
that.applyRuleFlags($rule, rule);
466-
467-
if (filter.onAfterSetValue) {
468-
filter.onAfterSetValue.call(that, $rule, rule.value, filter, operator);
469-
}
470464
}
471465
});
472466

@@ -1269,6 +1263,10 @@
12691263
}
12701264

12711265
this.trigger('afterSetRuleValue', $rule, value, filter, operator);
1266+
1267+
if (filter.onAfterSetValue) {
1268+
filter.onAfterSetValue.call(this, $rule, value, filter, operator);
1269+
}
12721270
};
12731271

12741272
/**

0 commit comments

Comments
 (0)