flashgrid-ext 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/lib/flashgrid/ext/version.rb +1 -1
- data/vendor/assets/javascripts/hoverdown.js +16 -12
- data/vendor/assets/javascripts/input_mask.js +13 -11
- data/vendor/assets/javascripts/sort.js +184 -169
- data/vendor/assets/stylesheets/aside.css.scss +23 -23
- metadata +2 -4
- data/vendor/assets/javascripts/inline_editor.js +0 -764
- data/vendor/assets/stylesheets/inline_editor.css.scss +0 -353
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 931b3a73e6120bdc07b888fb9e9f6094f274bdd5
|
4
|
+
data.tar.gz: 12bd0d94b4c518f57b25de67c7d14e47824b8e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6fd1d2a41a1c642a2f4b93e37f483ab3273b824f281f8fae9570edb82b61b47dbfdba471ebe551d9ffa7f842ac022a7561c3bbb30c7728281b03d7a2238d9f
|
7
|
+
data.tar.gz: 7f02a7858aeed64ffe4fffb8def1757fb8c78fb9e52acab181a97bc5efb2cc304381f9f28eca7d8633d08d372c564f2ebb6ac455429de05c9c2db2276db2d90c
|
data/README.md
CHANGED
@@ -24,11 +24,10 @@ Add the CSS files you want to include:
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
*= require animate.css
|
27
|
-
*= require aside.css
|
27
|
+
*= require aside.css (place after modal)
|
28
28
|
*= require calendar.css
|
29
29
|
*= require carousel.css
|
30
30
|
*= require editor.css
|
31
|
-
*= require inline_editor.css
|
32
31
|
*= require sort.css
|
33
32
|
*= require typeahead.css
|
34
33
|
```
|
@@ -41,7 +40,6 @@ Add the JS files you want to include:
|
|
41
40
|
//= require carousel.js
|
42
41
|
//= require editor.js
|
43
42
|
//= require hoverdown.js
|
44
|
-
//= require inline_editor.js
|
45
43
|
//= require input_mask.js
|
46
44
|
//= require moment.js
|
47
45
|
//= require scrollspy.js
|
@@ -1,4 +1,6 @@
|
|
1
|
-
;(function($, window, undefined) {
|
1
|
+
;(function ($, window, undefined) {
|
2
|
+
"use strict";
|
3
|
+
|
2
4
|
// don't do anything if touch is supported
|
3
5
|
// (plugin causes some issues on mobile)
|
4
6
|
if('ontouchstart' in document) return;
|
@@ -9,19 +11,21 @@
|
|
9
11
|
|
10
12
|
// if instantlyCloseOthers is true, then it will instantly
|
11
13
|
// shut other nav items when a new one is hovered over
|
12
|
-
$.fn.hoverdown = function(options) {
|
14
|
+
$.fn.hoverdown = function (options) {
|
13
15
|
|
14
16
|
// the element we really care about
|
15
17
|
// is the dropdown-toggle's parent
|
16
18
|
$allDropdowns = $allDropdowns.add(this.parent());
|
17
19
|
|
18
|
-
return this.each(function() {
|
20
|
+
return this.each(function () {
|
19
21
|
var $this = $(this),
|
20
22
|
$parent = $this.parent(),
|
21
23
|
defaults = {
|
22
24
|
delay: 500,
|
23
25
|
instantlyCloseOthers: true
|
24
26
|
},
|
27
|
+
showEvent = 'show.bs.dropdown',
|
28
|
+
hideEvent = 'hide.bs.dropdown',
|
25
29
|
data = {
|
26
30
|
delay: $(this).data('delay'),
|
27
31
|
instantlyCloseOthers: $(this).data('close-others')
|
@@ -29,7 +33,7 @@
|
|
29
33
|
settings = $.extend(true, {}, defaults, options, data),
|
30
34
|
timeout;
|
31
35
|
|
32
|
-
$parent.hover(function(event) {
|
36
|
+
$parent.hover(function (event) {
|
33
37
|
// so a neighbor can't open the dropdown
|
34
38
|
if(!$parent.hasClass('open') && !$this.is(event.target)) {
|
35
39
|
return true;
|
@@ -41,25 +45,25 @@
|
|
41
45
|
window.clearTimeout(timeout);
|
42
46
|
$parent.addClass('open');
|
43
47
|
$parent.trigger($.Event('show.bs.dropdown'));
|
44
|
-
}, function() {
|
48
|
+
}, function () {
|
45
49
|
timeout = window.setTimeout(function() {
|
46
50
|
$parent.removeClass('open');
|
47
|
-
$
|
51
|
+
$this.trigger(hideEvent);
|
48
52
|
}, settings.delay);
|
49
53
|
});
|
50
54
|
|
51
55
|
// this helps with button groups!
|
52
|
-
$this.hover(function() {
|
56
|
+
$this.hover(function () {
|
53
57
|
if(settings.instantlyCloseOthers === true)
|
54
58
|
$allDropdowns.removeClass('open');
|
55
59
|
|
56
60
|
window.clearTimeout(timeout);
|
57
61
|
$parent.addClass('open');
|
58
|
-
$
|
62
|
+
$this.trigger(showEvent);
|
59
63
|
});
|
60
64
|
|
61
65
|
// handle submenus
|
62
|
-
$parent.find('.dropdown-submenu').each(function(){
|
66
|
+
$parent.find('.dropdown-submenu').each(function () {
|
63
67
|
var $this = $(this);
|
64
68
|
var subTimeout;
|
65
69
|
$this.hover(function() {
|
@@ -67,9 +71,9 @@
|
|
67
71
|
$this.children('.dropdown-menu').show();
|
68
72
|
// always close submenu siblings instantly
|
69
73
|
$this.siblings().children('.dropdown-menu').hide();
|
70
|
-
}, function() {
|
74
|
+
}, function () {
|
71
75
|
var $submenu = $this.children('.dropdown-menu');
|
72
|
-
subTimeout = window.setTimeout(function() {
|
76
|
+
subTimeout = window.setTimeout(function () {
|
73
77
|
$submenu.hide();
|
74
78
|
}, settings.delay);
|
75
79
|
});
|
@@ -77,7 +81,7 @@
|
|
77
81
|
});
|
78
82
|
};
|
79
83
|
|
80
|
-
$(document).ready(function() {
|
84
|
+
$(document).ready(function () {
|
81
85
|
// apply hoverdown to all elements with the data-hover="dropdown" attribute
|
82
86
|
$('[data-hover="dropdown"]').hoverdown();
|
83
87
|
});
|
@@ -1,4 +1,6 @@
|
|
1
|
-
+function ($) {
|
1
|
+
+function ($) {
|
2
|
+
|
3
|
+
"use strict";
|
2
4
|
|
3
5
|
var isIphone = (window.orientation !== undefined)
|
4
6
|
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1
|
@@ -45,7 +47,7 @@
|
|
45
47
|
this.partialPosition = i
|
46
48
|
} else if (defs[c]) {
|
47
49
|
this.tests.push(new RegExp(defs[c]))
|
48
|
-
if(this.firstNonMaskPos === null)
|
50
|
+
if (this.firstNonMaskPos === null)
|
49
51
|
this.firstNonMaskPos = this.tests.length - 1
|
50
52
|
} else {
|
51
53
|
this.tests.push(null)
|
@@ -130,9 +132,9 @@
|
|
130
132
|
Inputmask.prototype.shiftL = function(begin,end) {
|
131
133
|
var len = this.mask.length
|
132
134
|
|
133
|
-
if(begin<0) return
|
135
|
+
if (begin < 0) return
|
134
136
|
|
135
|
-
for (var i = begin,j = this.seekNext(end); i < len; i++) {
|
137
|
+
for (var i = begin, j = this.seekNext(end); i < len; i++) {
|
136
138
|
if (this.tests[i]) {
|
137
139
|
if (j < len && this.tests[i].test(this.buffer[j])) {
|
138
140
|
this.buffer[i] = this.buffer[j]
|
@@ -193,7 +195,7 @@
|
|
193
195
|
}
|
194
196
|
|
195
197
|
Inputmask.prototype.keydownEvent = function(e) {
|
196
|
-
var k=e.which
|
198
|
+
var k = e.which
|
197
199
|
|
198
200
|
//backspace, delete, and escape get special treatment
|
199
201
|
if (k == 8 || k == 46 || (isIphone && k == 127)) {
|
@@ -201,12 +203,12 @@
|
|
201
203
|
begin = pos.begin,
|
202
204
|
end = pos.end
|
203
205
|
|
204
|
-
if (end-begin === 0) {
|
205
|
-
begin = k!=46 ? this.seekPrev(begin) : (end=this.seekNext(begin-1))
|
206
|
-
end = k==46 ? this.seekNext(end) : end
|
206
|
+
if (end - begin === 0) {
|
207
|
+
begin = k != 46 ? this.seekPrev(begin) : (end = this.seekNext(begin - 1))
|
208
|
+
end = k == 46 ? this.seekNext(end) : end
|
207
209
|
}
|
208
210
|
this.clearBuffer(begin, end)
|
209
|
-
this.shiftL(begin,end-1)
|
211
|
+
this.shiftL(begin, end - 1)
|
210
212
|
|
211
213
|
return false
|
212
214
|
} else if (k == 27) {//escape
|
@@ -222,12 +224,12 @@
|
|
222
224
|
var k = e.which,
|
223
225
|
pos = this.caret()
|
224
226
|
|
225
|
-
if (e.ctrlKey || e.altKey || e.metaKey || k<32) {//Ignore
|
227
|
+
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
|
226
228
|
return true
|
227
229
|
} else if (k) {
|
228
230
|
if (pos.end - pos.begin !== 0) {
|
229
231
|
this.clearBuffer(pos.begin, pos.end)
|
230
|
-
this.shiftL(pos.begin, pos.end-1)
|
232
|
+
this.shiftL(pos.begin, pos.end - 1)
|
231
233
|
}
|
232
234
|
|
233
235
|
var p = this.seekNext(pos.begin - 1)
|
@@ -315,26 +315,45 @@ ClassList.prototype.removeMatching = function(re){
|
|
315
315
|
};
|
316
316
|
|
317
317
|
/**
|
318
|
-
* Toggle class `name`.
|
318
|
+
* Toggle class `name`, can force state via `force`.
|
319
|
+
*
|
320
|
+
* For browsers that support classList, but do not support `force` yet,
|
321
|
+
* the mistake will be detected and corrected.
|
319
322
|
*
|
320
323
|
* @param {String} name
|
324
|
+
* @param {Boolean} force
|
321
325
|
* @return {ClassList}
|
322
326
|
* @api public
|
323
327
|
*/
|
324
328
|
|
325
|
-
ClassList.prototype.toggle = function(name){
|
329
|
+
ClassList.prototype.toggle = function(name, force){
|
326
330
|
// classList
|
327
331
|
if (this.list) {
|
328
|
-
|
332
|
+
if ("undefined" !== typeof force) {
|
333
|
+
if (force !== this.list.toggle(name, force)) {
|
334
|
+
this.list.toggle(name); // toggle again to correct
|
335
|
+
}
|
336
|
+
} else {
|
337
|
+
this.list.toggle(name);
|
338
|
+
}
|
329
339
|
return this;
|
330
340
|
}
|
331
341
|
|
332
342
|
// fallback
|
333
|
-
if (
|
334
|
-
|
343
|
+
if ("undefined" !== typeof force) {
|
344
|
+
if (!force) {
|
345
|
+
this.remove(name);
|
346
|
+
} else {
|
347
|
+
this.add(name);
|
348
|
+
}
|
335
349
|
} else {
|
336
|
-
this.
|
350
|
+
if (this.has(name)) {
|
351
|
+
this.remove(name);
|
352
|
+
} else {
|
353
|
+
this.add(name);
|
354
|
+
}
|
337
355
|
}
|
356
|
+
|
338
357
|
return this;
|
339
358
|
};
|
340
359
|
|
@@ -431,77 +450,39 @@ exports.unbind = function(el, type, fn, capture){
|
|
431
450
|
return fn;
|
432
451
|
};
|
433
452
|
});
|
434
|
-
require.register("javve-
|
435
|
-
var typeOf = require('type')
|
436
|
-
|
453
|
+
require.register("javve-to-array/index.js", function(exports, require, module){
|
437
454
|
/**
|
438
|
-
*
|
439
|
-
*
|
440
|
-
* collection and `HTMLElement` collections.
|
441
|
-
* Note: This implementation doesn't consider elements that are also
|
442
|
-
*
|
455
|
+
* Convert an array-like object into an `Array`.
|
456
|
+
* If `collection` is already an `Array`, then will return a clone of `collection`.
|
443
457
|
*
|
458
|
+
* @param {Array | Mixed} collection An `Array` or array-like object to convert e.g. `arguments` or `NodeList`
|
459
|
+
* @return {Array} Naive conversion of `collection` to a new `Array`.
|
460
|
+
* @api public
|
461
|
+
*/
|
444
462
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
var type = typeOf(obj)
|
459
|
-
if (type === 'array') return 1
|
460
|
-
switch (type) {
|
461
|
-
case 'arguments': return 2
|
462
|
-
case 'object':
|
463
|
-
if (isNodeList(obj)) return 2
|
464
|
-
try {
|
465
|
-
// indexed, but no tagName (element) or scrollTo/document (window. From DOM.isWindow test which we can't use here),
|
466
|
-
// or functions without apply/call (Safari
|
467
|
-
// HTMLElementCollection bug).
|
468
|
-
if ('length' in obj
|
469
|
-
&& !obj.tagName
|
470
|
-
&& !(obj.scrollTo && obj.document)
|
471
|
-
&& !obj.apply) {
|
472
|
-
return 2
|
473
|
-
}
|
474
|
-
} catch (ex) {}
|
475
|
-
case 'function':
|
476
|
-
if (isNodeList(obj)) return 2
|
477
|
-
try {
|
478
|
-
// indexed, but no tagName (element) or scrollTo/document (window. From DOM.isWindow test which we can't use here),
|
479
|
-
// or functions without apply/call (Safari
|
480
|
-
// HTMLElementCollection bug).
|
481
|
-
if ('length' in obj
|
482
|
-
&& !obj.tagName
|
483
|
-
&& !(obj.scrollTo && obj.document)
|
484
|
-
&& !obj.apply) {
|
485
|
-
return 2
|
486
|
-
}
|
487
|
-
} catch (ex) {}
|
488
|
-
default:
|
489
|
-
return 0
|
463
|
+
module.exports = function toArray(collection) {
|
464
|
+
if (typeof collection === 'undefined') return []
|
465
|
+
if (collection === null) return [null]
|
466
|
+
if (collection === window) return [window]
|
467
|
+
if (typeof collection === 'string') return [collection]
|
468
|
+
if (collection instanceof Array) return collection
|
469
|
+
if (typeof collection.length != 'number') return [collection]
|
470
|
+
if (typeof collection === 'function') return [collection]
|
471
|
+
|
472
|
+
var arr = []
|
473
|
+
for (var i = 0; i < collection.length; i++) {
|
474
|
+
if (Object.prototype.hasOwnProperty.call(collection, i) || i in collection) {
|
475
|
+
arr.push(collection[i])
|
490
476
|
}
|
477
|
+
}
|
478
|
+
if (!arr.length) return []
|
479
|
+
return arr
|
491
480
|
}
|
492
481
|
|
493
|
-
function isNodeList(nodes) {
|
494
|
-
return typeof nodes === 'object'
|
495
|
-
&& /^\[object (NodeList)\]$/.test(Object.prototype.toString.call(nodes))
|
496
|
-
&& nodes.hasOwnProperty('length')
|
497
|
-
&& (nodes.length == 0 || (typeof nodes[0] === "object" && nodes[0].nodeType > 0))
|
498
|
-
}
|
499
|
-
|
500
|
-
|
501
482
|
});
|
502
483
|
require.register("javve-events/index.js", function(exports, require, module){
|
503
484
|
var events = require('event'),
|
504
|
-
|
485
|
+
toArray = require('to-array');
|
505
486
|
|
506
487
|
/**
|
507
488
|
* Bind `el` event `type` to `fn`.
|
@@ -514,12 +495,9 @@ var events = require('event'),
|
|
514
495
|
*/
|
515
496
|
|
516
497
|
exports.bind = function(el, type, fn, capture){
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
for ( var i = 0; i < el.length; i++ ) {
|
521
|
-
events.bind(el[i], type, fn, capture);
|
522
|
-
}
|
498
|
+
el = toArray(el);
|
499
|
+
for ( var i = 0; i < el.length; i++ ) {
|
500
|
+
events.bind(el[i], type, fn, capture);
|
523
501
|
}
|
524
502
|
};
|
525
503
|
|
@@ -534,14 +512,12 @@ exports.bind = function(el, type, fn, capture){
|
|
534
512
|
*/
|
535
513
|
|
536
514
|
exports.unbind = function(el, type, fn, capture){
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
for ( var i = 0; i < el.length; i++ ) {
|
541
|
-
events.unbind(el[i], type, fn, capture);
|
542
|
-
}
|
515
|
+
el = toArray(el);
|
516
|
+
for ( var i = 0; i < el.length; i++ ) {
|
517
|
+
events.unbind(el[i], type, fn, capture);
|
543
518
|
}
|
544
519
|
};
|
520
|
+
|
545
521
|
});
|
546
522
|
require.register("javve-get-by-class/index.js", function(exports, require, module){
|
547
523
|
/**
|
@@ -714,10 +690,12 @@ module.exports = function(val){
|
|
714
690
|
case '[object RegExp]': return 'regexp';
|
715
691
|
case '[object Arguments]': return 'arguments';
|
716
692
|
case '[object Array]': return 'array';
|
693
|
+
case '[object Error]': return 'error';
|
717
694
|
}
|
718
695
|
|
719
696
|
if (val === null) return 'null';
|
720
697
|
if (val === undefined) return 'undefined';
|
698
|
+
if (val !== val) return 'nan';
|
721
699
|
if (val && val.nodeType === 1) return 'element';
|
722
700
|
|
723
701
|
return typeof val.valueOf();
|
@@ -733,7 +711,6 @@ By Jonny Strömberg (www.jonnystromberg.com, www.listjs.com)
|
|
733
711
|
"use strict";
|
734
712
|
|
735
713
|
var document = window.document,
|
736
|
-
events = require('events'),
|
737
714
|
getByClass = require('get-by-class'),
|
738
715
|
extend = require('extend'),
|
739
716
|
indexOf = require('indexof');
|
@@ -741,43 +718,51 @@ var document = window.document,
|
|
741
718
|
var List = function(id, options, values) {
|
742
719
|
|
743
720
|
var self = this,
|
744
|
-
|
721
|
+
init,
|
745
722
|
Item = require('./src/item')(self),
|
746
723
|
addAsync = require('./src/add-async')(self),
|
747
724
|
parse = require('./src/parse')(self);
|
748
725
|
|
749
|
-
this.listClass = "sortable";
|
750
|
-
this.searchClass = "sort-filter";
|
751
|
-
this.sortClass = "sort-trigger";
|
752
|
-
this.page = 200;
|
753
|
-
this.i = 1;
|
754
|
-
this.items = [];
|
755
|
-
this.visibleItems = [];
|
756
|
-
this.matchingItems = [];
|
757
|
-
this.searched = false;
|
758
|
-
this.filtered = false;
|
759
|
-
this.handlers = { 'updated': [] };
|
760
|
-
this.plugins = {};
|
761
|
-
|
762
|
-
extend(this, options);
|
763
|
-
|
764
|
-
this.listContainer = (typeof(id) === 'string') ? document.getElementById(id) : id;
|
765
|
-
if (!this.listContainer) { return; }
|
766
|
-
this.list = getByClass(this.listContainer, this.listClass, true);
|
767
|
-
|
768
|
-
this.templater = require('./src/templater')(self);
|
769
|
-
this.sort = require('./src/sort')(self);
|
770
|
-
this.search = require('./src/search')(self);
|
771
|
-
this.filter = require('./src/filter')(self);
|
772
|
-
|
773
726
|
init = {
|
774
|
-
start: function(
|
727
|
+
start: function() {
|
728
|
+
self.listClass = "sortable";
|
729
|
+
self.searchClass = "sort-filter";
|
730
|
+
self.sortClass = "sort-trigger";
|
731
|
+
self.page = 200;
|
732
|
+
self.i = 1;
|
733
|
+
self.items = [];
|
734
|
+
self.visibleItems = [];
|
735
|
+
self.matchingItems = [];
|
736
|
+
self.searched = false;
|
737
|
+
self.filtered = false;
|
738
|
+
self.handlers = { 'updated': [] };
|
739
|
+
self.plugins = {};
|
740
|
+
self.helpers = {
|
741
|
+
getByClass: getByClass,
|
742
|
+
extend: extend,
|
743
|
+
indexOf: indexOf
|
744
|
+
};
|
745
|
+
|
746
|
+
extend(self, options);
|
747
|
+
|
748
|
+
self.listContainer = (typeof(id) === 'string') ? document.getElementById(id) : id;
|
749
|
+
if (!self.listContainer) { return; }
|
750
|
+
self.list = getByClass(self.listContainer, self.listClass, true);
|
751
|
+
|
752
|
+
self.templater = require('./src/templater')(self);
|
753
|
+
self.search = require('./src/search')(self);
|
754
|
+
self.filter = require('./src/filter')(self);
|
755
|
+
self.sort = require('./src/sort')(self);
|
756
|
+
|
757
|
+
this.items();
|
758
|
+
self.update();
|
759
|
+
this.plugins();
|
760
|
+
},
|
761
|
+
items: function() {
|
775
762
|
parse(self.list);
|
776
763
|
if (values !== undefined) {
|
777
764
|
self.add(values);
|
778
765
|
}
|
779
|
-
self.update();
|
780
|
-
this.plugins();
|
781
766
|
},
|
782
767
|
plugins: function() {
|
783
768
|
for (var i = 0; i < self.plugins.length; i++) {
|
@@ -818,12 +803,12 @@ var List = function(id, options, values) {
|
|
818
803
|
return added;
|
819
804
|
};
|
820
805
|
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
806
|
+
this.show = function(i, page) {
|
807
|
+
this.i = i;
|
808
|
+
this.page = page;
|
809
|
+
self.update();
|
825
810
|
return self;
|
826
|
-
|
811
|
+
};
|
827
812
|
|
828
813
|
/* Removes object from list.
|
829
814
|
* Loops through the list and removes objects where
|
@@ -917,7 +902,7 @@ var List = function(id, options, values) {
|
|
917
902
|
|
918
903
|
this.update = function() {
|
919
904
|
var is = self.items,
|
920
|
-
|
905
|
+
il = is.length;
|
921
906
|
|
922
907
|
self.visibleItems = [];
|
923
908
|
self.matchingItems = [];
|
@@ -927,18 +912,18 @@ var List = function(id, options, values) {
|
|
927
912
|
is[i].show();
|
928
913
|
self.visibleItems.push(is[i]);
|
929
914
|
self.matchingItems.push(is[i]);
|
930
|
-
|
915
|
+
} else if (is[i].matching()) {
|
931
916
|
self.matchingItems.push(is[i]);
|
932
917
|
is[i].hide();
|
933
|
-
|
918
|
+
} else {
|
934
919
|
is[i].hide();
|
935
|
-
|
920
|
+
}
|
936
921
|
}
|
937
922
|
self.trigger('updated');
|
938
923
|
return self;
|
939
924
|
};
|
940
925
|
|
941
|
-
init.start(
|
926
|
+
init.start();
|
942
927
|
};
|
943
928
|
|
944
929
|
module.exports = List;
|
@@ -1052,6 +1037,7 @@ module.exports = function(list) {
|
|
1052
1037
|
searchMethod(target.value);
|
1053
1038
|
});
|
1054
1039
|
|
1040
|
+
list.helpers.toString = toString;
|
1055
1041
|
return searchMethod;
|
1056
1042
|
};
|
1057
1043
|
|
@@ -1061,52 +1047,82 @@ var naturalSort = require('natural-sort'),
|
|
1061
1047
|
classes = require('classes'),
|
1062
1048
|
events = require('events'),
|
1063
1049
|
getByClass = require('get-by-class'),
|
1064
|
-
getAttribute = require('get-attribute')
|
1065
|
-
sortButtons;
|
1066
|
-
|
1067
|
-
var clearPreviousSorting = function() {
|
1068
|
-
for (var i = 0, il = sortButtons.length; i < il; i++) {
|
1069
|
-
classes(sortButtons[i]).remove('asc');
|
1070
|
-
classes(sortButtons[i]).remove('desc');
|
1071
|
-
}
|
1072
|
-
};
|
1050
|
+
getAttribute = require('get-attribute');
|
1073
1051
|
|
1074
1052
|
module.exports = function(list) {
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1053
|
+
list.sortFunction = list.sortFunction || function(itemA, itemB, options) {
|
1054
|
+
options.desc = options.order == "desc" ? true : false; // Natural sort uses this format
|
1055
|
+
return naturalSort(itemA.values()[options.valueName], itemB.values()[options.valueName], options);
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
var buttons = {
|
1059
|
+
els: undefined,
|
1060
|
+
clear: function() {
|
1061
|
+
for (var i = 0, il = buttons.els.length; i < il; i++) {
|
1062
|
+
classes(buttons.els[i]).remove('asc');
|
1063
|
+
classes(buttons.els[i]).remove('desc');
|
1064
|
+
}
|
1065
|
+
},
|
1066
|
+
getOrder: function(btn) {
|
1067
|
+
var predefinedOrder = getAttribute(btn, 'data-order');
|
1068
|
+
if (predefinedOrder == "asc" || predefinedOrder == "desc") {
|
1069
|
+
return predefinedOrder;
|
1070
|
+
} else if (classes(btn).has('desc')) {
|
1071
|
+
return "asc";
|
1072
|
+
} else if (classes(btn).has('asc')) {
|
1073
|
+
return "desc";
|
1074
|
+
} else {
|
1075
|
+
return "asc";
|
1076
|
+
}
|
1077
|
+
},
|
1078
|
+
getInSensitive: function(btn, options) {
|
1079
|
+
var insensitive = getAttribute(btn, 'data-insensitive');
|
1080
|
+
if (insensitive === "true") {
|
1081
|
+
options.insensitive = true;
|
1092
1082
|
} else {
|
1093
|
-
options.
|
1094
|
-
newSortingOrder = 'asc';
|
1083
|
+
options.insensitive = false;
|
1095
1084
|
}
|
1096
|
-
|
1097
|
-
|
1085
|
+
},
|
1086
|
+
setOrder: function(options) {
|
1087
|
+
for (var i = 0, il = buttons.els.length; i < il; i++) {
|
1088
|
+
var btn = buttons.els[i];
|
1089
|
+
if (getAttribute(btn, 'data-sort') !== options.valueName) {
|
1090
|
+
continue;
|
1091
|
+
}
|
1092
|
+
var predefinedOrder = getAttribute(btn, 'data-order');
|
1093
|
+
if (predefinedOrder == "asc" || predefinedOrder == "desc") {
|
1094
|
+
if (predefinedOrder == options.order) {
|
1095
|
+
classes(btn).add(options.order);
|
1096
|
+
}
|
1097
|
+
} else {
|
1098
|
+
classes(btn).add(options.order);
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
};
|
1103
|
+
var sort = function() {
|
1104
|
+
list.trigger('sortStart');
|
1105
|
+
options = {};
|
1106
|
+
|
1107
|
+
var target = arguments[0].currentTarget || arguments[0].srcElement || undefined;
|
1108
|
+
|
1109
|
+
if (target) {
|
1110
|
+
options.valueName = getAttribute(target, 'data-sort');
|
1111
|
+
buttons.getInSensitive(target, options);
|
1112
|
+
options.order = buttons.getOrder(target);
|
1098
1113
|
} else {
|
1099
|
-
valueName = arguments[0];
|
1100
1114
|
options = arguments[1] || options;
|
1115
|
+
options.valueName = arguments[0];
|
1116
|
+
options.order = options.order || "asc";
|
1117
|
+
options.insensitive = (typeof options.insensitive == "undefined") ? true : options.insensitive;
|
1101
1118
|
}
|
1119
|
+
buttons.clear();
|
1120
|
+
buttons.setOrder(options);
|
1102
1121
|
|
1103
|
-
options.
|
1104
|
-
|
1105
|
-
return
|
1106
|
-
};
|
1107
|
-
|
1108
|
-
list.trigger('sortStart');
|
1109
|
-
list.items.sort(options.sortFunction);
|
1122
|
+
options.sortFunction = options.sortFunction || list.sortFunction;
|
1123
|
+
list.items.sort(function(a, b) {
|
1124
|
+
return options.sortFunction(a, b, options);
|
1125
|
+
});
|
1110
1126
|
list.update();
|
1111
1127
|
list.trigger('sortComplete');
|
1112
1128
|
};
|
@@ -1115,8 +1131,16 @@ module.exports = function(list) {
|
|
1115
1131
|
list.handlers.sortStart = list.handlers.sortStart || [];
|
1116
1132
|
list.handlers.sortComplete = list.handlers.sortComplete || [];
|
1117
1133
|
|
1118
|
-
|
1119
|
-
events.bind(
|
1134
|
+
buttons.els = getByClass(list.listContainer, list.sortClass);
|
1135
|
+
events.bind(buttons.els, 'click', sort);
|
1136
|
+
list.on('searchStart', buttons.clear);
|
1137
|
+
list.on('filterStart', buttons.clear);
|
1138
|
+
|
1139
|
+
// Helpers
|
1140
|
+
list.helpers.classes = classes;
|
1141
|
+
list.helpers.naturalSort = naturalSort;
|
1142
|
+
list.helpers.events = events;
|
1143
|
+
list.helpers.getAttribute = getAttribute;
|
1120
1144
|
|
1121
1145
|
return sort;
|
1122
1146
|
};
|
@@ -1379,29 +1403,20 @@ module.exports = function(list) {
|
|
1379
1403
|
require.alias("component-classes/index.js", "list.js/deps/classes/index.js");
|
1380
1404
|
require.alias("component-classes/index.js", "classes/index.js");
|
1381
1405
|
require.alias("component-indexof/index.js", "component-classes/deps/indexof/index.js");
|
1382
|
-
|
1383
1406
|
require.alias("segmentio-extend/index.js", "list.js/deps/extend/index.js");
|
1384
1407
|
require.alias("segmentio-extend/index.js", "extend/index.js");
|
1385
|
-
|
1386
1408
|
require.alias("component-indexof/index.js", "list.js/deps/indexof/index.js");
|
1387
1409
|
require.alias("component-indexof/index.js", "indexof/index.js");
|
1388
|
-
|
1389
1410
|
require.alias("javve-events/index.js", "list.js/deps/events/index.js");
|
1390
1411
|
require.alias("javve-events/index.js", "events/index.js");
|
1391
1412
|
require.alias("component-event/index.js", "javve-events/deps/event/index.js");
|
1392
|
-
|
1393
|
-
require.alias("javve-is-collection/index.js", "javve-events/deps/is-collection/index.js");
|
1394
|
-
require.alias("component-type/index.js", "javve-is-collection/deps/type/index.js");
|
1395
|
-
|
1413
|
+
require.alias("javve-to-array/index.js", "javve-events/deps/to-array/index.js");
|
1396
1414
|
require.alias("javve-get-by-class/index.js", "list.js/deps/get-by-class/index.js");
|
1397
1415
|
require.alias("javve-get-by-class/index.js", "get-by-class/index.js");
|
1398
|
-
|
1399
1416
|
require.alias("javve-get-attribute/index.js", "list.js/deps/get-attribute/index.js");
|
1400
1417
|
require.alias("javve-get-attribute/index.js", "get-attribute/index.js");
|
1401
|
-
|
1402
1418
|
require.alias("javve-natural-sort/index.js", "list.js/deps/natural-sort/index.js");
|
1403
1419
|
require.alias("javve-natural-sort/index.js", "natural-sort/index.js");
|
1404
|
-
|
1405
1420
|
require.alias("javve-to-string/index.js", "list.js/deps/to-string/index.js");
|
1406
1421
|
require.alias("javve-to-string/index.js", "list.js/deps/to-string/index.js");
|
1407
1422
|
require.alias("javve-to-string/index.js", "to-string/index.js");
|