zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
/*
@license
 
dhtmlxGantt v.6.2.6 Standard
 
This version of dhtmlxGantt is distributed under GPL 2.0 license and can be legally used in GPL projects.
 
To use dhtmlxGantt in non-GPL projects (and get Pro version of the product), please obtain Commercial/Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxGantt/#licensing or contact us at sales@dhtmlx.com
 
(c) XB Software Ltd.
 
*/
(function webpackUniversalModuleDefinition(root, factory) {
    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if(typeof define === 'function' && define.amd)
        define([], factory);
    else {
        var a = factory();
        for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
    }
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/     // The module cache
/******/     var installedModules = {};
/******/
/******/     // The require function
/******/     function __webpack_require__(moduleId) {
/******/
/******/         // Check if module is in cache
/******/         if(installedModules[moduleId]) {
/******/             return installedModules[moduleId].exports;
/******/         }
/******/         // Create a new module (and put it into the cache)
/******/         var module = installedModules[moduleId] = {
/******/             i: moduleId,
/******/             l: false,
/******/             exports: {}
/******/         };
/******/
/******/         // Execute the module function
/******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/         // Flag the module as loaded
/******/         module.l = true;
/******/
/******/         // Return the exports of the module
/******/         return module.exports;
/******/     }
/******/
/******/
/******/     // expose the modules object (__webpack_modules__)
/******/     __webpack_require__.m = modules;
/******/
/******/     // expose the module cache
/******/     __webpack_require__.c = installedModules;
/******/
/******/     // define getter function for harmony exports
/******/     __webpack_require__.d = function(exports, name, getter) {
/******/         if(!__webpack_require__.o(exports, name)) {
/******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/         }
/******/     };
/******/
/******/     // define __esModule on exports
/******/     __webpack_require__.r = function(exports) {
/******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/         }
/******/         Object.defineProperty(exports, '__esModule', { value: true });
/******/     };
/******/
/******/     // create a fake namespace object
/******/     // mode & 1: value is a module id, require it
/******/     // mode & 2: merge all properties of value into the ns
/******/     // mode & 4: return value when already ns object
/******/     // mode & 8|1: behave like require
/******/     __webpack_require__.t = function(value, mode) {
/******/         if(mode & 1) value = __webpack_require__(value);
/******/         if(mode & 8) return value;
/******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/         var ns = Object.create(null);
/******/         __webpack_require__.r(ns);
/******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/         return ns;
/******/     };
/******/
/******/     // getDefaultExport function for compatibility with non-harmony modules
/******/     __webpack_require__.n = function(module) {
/******/         var getter = module && module.__esModule ?
/******/             function getDefault() { return module['default']; } :
/******/             function getModuleExports() { return module; };
/******/         __webpack_require__.d(getter, 'a', getter);
/******/         return getter;
/******/     };
/******/
/******/     // Object.prototype.hasOwnProperty.call
/******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/     // __webpack_public_path__
/******/     __webpack_require__.p = "/codebase/sources/";
/******/
/******/
/******/     // Load entry module and return exports
/******/     return __webpack_require__(__webpack_require__.s = "./sources/ext/click_drag/index.ts");
/******/ })
/************************************************************************/
/******/ ({
 
/***/ "./sources/ext/click_drag/eventsManager.ts":
/*!*************************************************!*\
  !*** ./sources/ext/click_drag/eventsManager.ts ***!
  \*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
Object.defineProperty(exports, "__esModule", { value: true });
var EventsManager = /** @class */ (function () {
    function EventsManager() {
        this._mouseDown = false;
        this._eventsIds = [];
    }
    EventsManager.prototype.attach = function (selectedRegion, useKey) {
        var _this = this;
        var _target = selectedRegion.getViewPort();
        this._originPosition = window.getComputedStyle(_target).display;
        this._restoreOriginPosition = function () {
            _target.style.position = _this._originPosition;
        };
        if (this._originPosition === "static") {
            _target.style.position = "relative";
        }
        var state = gantt.$services.getService("state");
        state.registerProvider("clickDrag", function () {
            var result = { autoscroll: false };
            return result;
        });
        var scheduledDndCoordinates = null;
        var startDragAndDrop = function () {
            if (!scheduledDndCoordinates) {
                return;
            }
            _this._mouseDown = true;
            selectedRegion.setStart(scheduledDndCoordinates);
            selectedRegion.setPosition(scheduledDndCoordinates);
            selectedRegion.setEnd(scheduledDndCoordinates);
            scheduledDndCoordinates = null;
        };
        this._eventsIds[this._eventsIds.length] = gantt.event(_target, "mousedown", function (event) {
            scheduledDndCoordinates = null;
            if (gantt.utils.dom.closest(event.target, ".gantt_task_line, .gantt_task_link")) {
                return;
            }
            state.registerProvider("clickDrag", function () {
                var result = { autoscroll: _this._mouseDown };
                return result;
            });
            if (useKey && event[useKey] !== true) {
                return;
            }
            scheduledDndCoordinates = _this._getCoordinates(event, selectedRegion);
        });
        this._eventsIds[this._eventsIds.length] = gantt.event(document.body, "mouseup", function (event) {
            scheduledDndCoordinates = null;
            if (useKey && event[useKey] !== true) {
                return;
            }
            if (_this._mouseDown === true) {
                _this._mouseDown = false;
                var coordinates = _this._getCoordinates(event, selectedRegion);
                selectedRegion.dragEnd(coordinates);
            }
        });
        this._eventsIds[this._eventsIds.length] = gantt.event(_target, "mousemove", function (event) {
            if (useKey && event[useKey] !== true) {
                return;
            }
            var coordinates = null;
            if (!_this._mouseDown && scheduledDndCoordinates) {
                coordinates = _this._getCoordinates(event, selectedRegion);
                if (Math.abs(scheduledDndCoordinates.relative.left - coordinates.relative.left) > 5) {
                    // add small threshold not to start dnd on simple click
                    startDragAndDrop();
                }
                return;
            }
            if (_this._mouseDown === true) {
                coordinates = _this._getCoordinates(event, selectedRegion);
                selectedRegion.setEnd(coordinates);
                selectedRegion.render();
            }
        });
    };
    EventsManager.prototype.detach = function () {
        this._restoreOriginPosition();
        this._eventsIds.forEach(function (eventId) {
            gantt.eventRemove(eventId);
        });
        var state = gantt.$services.getService("state");
        state.unregisterProvider("clickDrag");
    };
    EventsManager.prototype.destructor = function () {
        this.detach();
    };
    EventsManager.prototype._getCoordinates = function (event, selectedRegion) {
        var viewPort = selectedRegion.getViewPort();
        var viewPortBounds = viewPort.getBoundingClientRect();
        var clientX = event.clientX, clientY = event.clientY;
        var result = {
            absolute: {
                left: clientX,
                top: clientY,
            },
            relative: {
                left: clientX - viewPortBounds.left + viewPort.scrollLeft,
                top: clientY - viewPortBounds.top + viewPort.scrollTop
            }
        };
        return result;
    };
    return EventsManager;
}());
exports.EventsManager = EventsManager;
 
 
/***/ }),
 
/***/ "./sources/ext/click_drag/index.ts":
/*!*****************************************!*\
  !*** ./sources/ext/click_drag/index.ts ***!
  \*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var eventsManager_1 = __webpack_require__(/*! ./eventsManager */ "./sources/ext/click_drag/eventsManager.ts");
var selectedRegion_1 = __webpack_require__(/*! ./selectedRegion */ "./sources/ext/click_drag/selectedRegion.ts");
if (!gantt.ext) {
    gantt.ext = {};
}
var defaultConfig = {
    className: "gantt_click_drag_rect",
    useRequestAnimationFrame: true,
    callback: undefined,
    singleRow: false
};
var eventsManager = new eventsManager_1.EventsManager();
gantt.ext.clickDrag = eventsManager;
gantt.attachEvent("onGanttReady", function () {
    var config = __assign({ viewPort: gantt.$task_data }, defaultConfig);
    if (gantt.config.click_drag) {
        var clickDrag = gantt.config.click_drag;
        config.render = clickDrag.render || defaultConfig.render;
        config.className = clickDrag.className || defaultConfig.className;
        config.callback = clickDrag.callback || defaultConfig.callback;
        config.viewPort = clickDrag.viewPort || gantt.$task_data;
        config.useRequestAnimationFrame = clickDrag.useRequestAnimationFrame === undefined ?
            defaultConfig.useRequestAnimationFrame : clickDrag.useRequestAnimationFrame;
        config.singleRow = clickDrag.singleRow === undefined ? defaultConfig.singleRow : clickDrag.singleRow;
        var selectedRegion = new selectedRegion_1.SelectedRegion(config);
        gantt.ext.clickDrag.attach(selectedRegion, clickDrag.useKey);
    }
});
gantt.attachEvent("onDestroy", function () {
    eventsManager.destructor();
});
 
 
/***/ }),
 
/***/ "./sources/ext/click_drag/selectedRegion.ts":
/*!**************************************************!*\
  !*** ./sources/ext/click_drag/selectedRegion.ts ***!
  \**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
 
"use strict";
 
Object.defineProperty(exports, "__esModule", { value: true });
var eventable = __webpack_require__(/*! ../../utils/eventable */ "./sources/utils/eventable.js");
var helpers_1 = __webpack_require__(/*! ../../utils/helpers */ "./sources/utils/helpers.js");
function _countSize(start, end) {
    var result = start - end;
    if (result >= 0) {
        return result;
    }
    return -result;
}
var SelectedRegion = /** @class */ (function () {
    function SelectedRegion(config) {
        var _this = this;
        this._el = document.createElement("div");
        this._viewPort = config.viewPort;
        this._el.classList.add(config.className);
        if (typeof config.callback === "function") {
            this._callback = config.callback;
        }
        if (typeof config.render === "function") {
            this.render = function () {
                _this._el = config.render(_this._startPoint, _this._endPoint);
                if (config.className !== "") {
                    _this._el.classList.add(config.className);
                }
                _this.draw();
            };
        }
        if (!helpers_1.isEventable(this._viewPort)) {
            eventable(this._viewPort);
        }
        this._singleRow = config.singleRow;
        this._useRequestAnimationFrame = config.useRequestAnimationFrame;
    }
    SelectedRegion.prototype.setStyles = function () {
        if (this._singleRow) {
            var height = gantt.config.row_height;
            this._el.style.height = height + "px";
            this._el.style.top = (Math.ceil(this._positionPoint.relative.top / height) - 1) * height + "px";
        }
        else {
            this._el.style.height = _countSize(this._endPoint.relative.top, this._startPoint.relative.top) + "px";
            this._el.style.top = this._positionPoint.relative.top + "px";
        }
        this._el.style.width = _countSize(this._endPoint.relative.left, this._startPoint.relative.left) + "px";
        this._el.style.left = this._positionPoint.relative.left + "px";
    };
    SelectedRegion.prototype.render = function () {
        this.setStyles();
        this.draw();
    };
    SelectedRegion.prototype.draw = function () {
        var _this = this;
        if (this._useRequestAnimationFrame) {
            return helpers_1.requestAnimationFrame(function () {
                _this._viewPort.appendChild(_this.getElement());
            });
        }
        else {
            this._viewPort.appendChild(this.getElement());
        }
    };
    SelectedRegion.prototype.clear = function () {
        var _this = this;
        if (this._useRequestAnimationFrame) {
            return helpers_1.requestAnimationFrame(function () {
                if (!_this._el.parentNode) {
                    return;
                }
                _this._viewPort.removeChild(_this._el);
            });
        }
        else {
            if (!this._el.parentNode) {
                return;
            }
            this._viewPort.removeChild(this._el);
        }
    };
    SelectedRegion.prototype.getElement = function () {
        return this._el;
    };
    SelectedRegion.prototype.getViewPort = function () {
        return this._viewPort;
    };
    SelectedRegion.prototype.setStart = function (startPoint) {
        this._startPoint = startPoint;
        this._startDate = gantt.dateFromPos(this._startPoint.relative.left);
        this._viewPort.callEvent("onBeforeDrag", [this._startPoint]);
    };
    SelectedRegion.prototype.setEnd = function (endPoint) {
        this._endPoint = endPoint;
        if (this._singleRow) {
            var height = gantt.config.row_height;
            this._endPoint.relative.top = (Math.ceil(this._startPoint.relative.top / height)) * height;
        }
        this._endDate = gantt.dateFromPos(this._endPoint.relative.left);
        if (this._startPoint.relative.left > this._endPoint.relative.left) {
            this._positionPoint = {
                relative: { left: this._endPoint.relative.left, top: this._positionPoint.relative.top },
                absolute: { left: this._endPoint.absolute.left, top: this._positionPoint.absolute.top }
            };
        }
        if (this._startPoint.relative.top > this._endPoint.relative.top) {
            this._positionPoint = {
                relative: { left: this._positionPoint.relative.left, top: this._endPoint.relative.top },
                absolute: { left: this._positionPoint.absolute.left, top: this._endPoint.absolute.top }
            };
        }
        this._viewPort.callEvent("onDrag", [this._startPoint, this._endPoint]);
    };
    SelectedRegion.prototype.setPosition = function (positionPoint) {
        this._positionPoint = positionPoint;
    };
    SelectedRegion.prototype.dragEnd = function (endPoint) {
        var _a;
        if (endPoint.relative.left < 0) {
            endPoint.relative.left = 0;
        }
        this._viewPort.callEvent("onBeforeDragEnd", [this._startPoint, endPoint]);
        this.setEnd(endPoint);
        if (this._startDate.valueOf() > this._endDate.valueOf()) {
            _a = [this._endDate, this._startDate], this._startDate = _a[0], this._endDate = _a[1];
        }
        this.clear();
        var tasksByTime = gantt.getTaskByTime(this._startDate, this._endDate);
        var tasksByIndex = this._getTasksByTop(this._startPoint.relative.top, this._endPoint.relative.top);
        this._viewPort.callEvent("onDragEnd", [this._startPoint, this._endPoint]);
        if (this._callback) {
            this._callback(this._startPoint, this._endPoint, this._startDate, this._endDate, tasksByTime, tasksByIndex);
        }
    };
    SelectedRegion.prototype.getInBounds = function () {
        return this._singleRow;
    };
    SelectedRegion.prototype._getTasksByTop = function (start, end) {
        var startValue = start;
        var endValue = end;
        if (start > end) {
            startValue = end;
            endValue = start;
        }
        var height = gantt.config.row_height;
        var startIndex = Math.ceil(startValue / height) - 1;
        var endIndex = Math.ceil(endValue / height) - 1;
        var result = [];
        for (var i = startIndex; i <= endIndex; i++) {
            var task = gantt.getTaskByIndex(i);
            if (task) {
                result.push(gantt.getTaskByIndex(i));
            }
        }
        return result;
    };
    return SelectedRegion;
}());
exports.SelectedRegion = SelectedRegion;
 
 
/***/ }),
 
/***/ "./sources/utils/eventable.js":
/*!************************************!*\
  !*** ./sources/utils/eventable.js ***!
  \************************************/
/*! no static exports found */
/***/ (function(module, exports) {
 
var EventHost = function(){
    this._connected = [];
    this._silent_mode = false;
};
 
EventHost.prototype = {
    _silentStart: function() {
        this._silent_mode = true;
    },
    _silentEnd: function() {
        this._silent_mode = false;
    }
};
 
var    createEventStorage = function(obj) {
    var dhx_catch = [];
    var z = function(){
        var res = true;
        for (var i = 0; i < dhx_catch.length; i++){
            if (dhx_catch[i]){
                var zr = dhx_catch[i].apply(obj, arguments);
                res=res&&zr;
            }
        }
        return res;
    };
    z.addEvent=function(ev){
        if (typeof (ev) == "function")
            return dhx_catch.push(ev)-1;
        return false;
    };
    z.removeEvent=function(id){
        dhx_catch[id]=null;
    };
    return z;
};
 
function makeEventable(obj){
 
    var eventHost = new EventHost();
    obj.attachEvent=function(name, catcher, callObj){
        name='ev_'+name.toLowerCase();
        if (!eventHost[name])
            eventHost[name] = createEventStorage(callObj||this);
 
        return(name+':'+eventHost[name].addEvent(catcher)); //return ID (event name & event ID)
    };
    obj.attachAll = function(callback, callObj){
        this.attachEvent('listen_all', callback, callObj);
    };
 
    obj.callEvent=function(name, arg0, callObj){
        if (eventHost._silent_mode) return true;
 
        var handlerName = 'ev_'+name.toLowerCase();
 
        if (eventHost['ev_listen_all']){
            eventHost['ev_listen_all'].apply(callObj || this, [name].concat(arg0));
        }
 
        if (eventHost[handlerName])
            return eventHost[handlerName].apply(callObj || this, arg0);
        return true;
    };
    obj.checkEvent=function(name){
        return (!!eventHost['ev_'+name.toLowerCase()]);
    };
    obj.detachEvent=function(id){
        if (id){
            var list = id.split(':');//get EventName and ID
            var eventName = list[0];
            var eventId = list[1];
 
            if(eventHost[eventName]){
                eventHost[eventName].removeEvent(eventId); //remove event
            }
        }
    };
    obj.detachAllEvents = function(){
        for (var name in eventHost){
            if (name.indexOf("ev_") === 0)
                delete eventHost[name];
        }
    };
 
}
 
module.exports = makeEventable;
 
/***/ }),
 
/***/ "./sources/utils/helpers.js":
/*!**********************************!*\
  !*** ./sources/utils/helpers.js ***!
  \**********************************/
/*! no static exports found */
/***/ (function(module, exports) {
 
var units = {
    "second": 1,
    "minute": 60,
    "hour": 60 * 60,
    "day": 60 * 60 * 24,
    "week": 60 * 60 * 24 * 7,
    "month": 60 * 60 * 24 * 30,
    "quarter": 60 * 60 * 24 * 30 * 3,
    "year": 60 * 60 * 24 * 365
};
function getSecondsInUnit(unit){
    return units[unit] || units.hour;
}
 
function forEach(arr, callback) {
    if (arr.forEach) {
        arr.forEach(callback);
    } else {
        var workArray = arr.slice();
        for (var i = 0; i < workArray.length; i++) {
            callback(workArray[i], i);
        }
    }
}
 
function arrayMap(arr, callback) {
    if (arr.map) {
        return arr.map(callback);
    } else {
        var workArray = arr.slice();
        var resArray = [];
 
        for (var i = 0; i < workArray.length; i++) {
            resArray.push(callback(workArray[i], i));
        }
        return resArray;
    }
}
 
 
function arrayFind(arr, callback) {
    if (arr.find) {
        return arr.find(callback);
    } else {
        for (var i = 0; i < arr.length; i++) {
            if (callback(arr[i], i)) {
                return arr[i];
            }
        }
    }
}
 
// iframe-safe array type check instead of using instanceof
function isArray(obj){
    if(Array.isArray){
        return Array.isArray(obj);
    }else{
        // close enough
        return (obj && obj.length !== undefined && obj.pop && obj.push);
    }
}
 
// non-primitive string object, e.g. new String("abc")
function isStringObject(obj){
    return obj && typeof obj === "object"
        && Function.prototype.toString.call(obj.constructor) === "function String() { [native code] }";
}
 
// non-primitive number object, e.g. new Number(5)
function isNumberObject(obj){
    return obj && typeof obj === "object"
        && Function.prototype.toString.call(obj.constructor) === "function Number() { [native code] }";
}
 
// non-primitive number object, e.g. new Boolean(true)
function isBooleanObject(obj){
    return obj && typeof obj === "object"
        && Function.prototype.toString.call(obj.constructor) === "function Boolean() { [native code] }";
}
 
function isDate(obj) {
    if (obj && typeof obj === "object") {
        return !!(obj.getFullYear && obj.getMonth && obj.getDate);
    } else {
        return false;
    }
}
 
function arrayFilter(arr, callback) {
    var result = [];
 
    if (arr.filter) {
        return arr.filter(callback);
    } else {
        for (var i = 0; i < arr.length; i++) {
            if (callback(arr[i], i)) {
                result[result.length] = arr[i];
            }
        }
        return result;
    }
}
 
function hashToArray(hash) {
    var result = [];
 
    for (var key in hash) {
        if (hash.hasOwnProperty(key)) {
            result.push(hash[key]);
        }
    }
 
    return result;
}
 
function arraySome(arr, callback) {
    if (arr.length === 0) return false;
 
    for (var i = 0; i < arr.length; i++) {
        if (callback(arr[i], i, arr)) {
            return true;
        }
    }
    return false;
}
 
function arrayDifference(arr, callback) {
    return arrayFilter(arr, function(item, i) {
        return !callback(item, i);
    });
}
 
function throttle (callback, timeout) {
    var wait = false;
 
    return function () {
        if (!wait) {
            callback.apply(null, arguments);
            wait = true;
            setTimeout(function () {
                wait = false;
            }, timeout);
        }
    };
}
 
function delay (callback, timeout){
    var timer;
 
    var result = function() {
        result.$cancelTimeout();
        callback.$pending = true;
        var args = Array.prototype.slice.call(arguments);
        timer = setTimeout(function(){
            callback.apply(this, args);
            result.$pending = false;
        }, timeout);
    };
    
    result.$pending = false;
    result.$cancelTimeout = function(){
        clearTimeout(timer);
        callback.$pending = false;
    };
    result.$execute = function(){
        callback();
        callback.$cancelTimeout();
    };
 
    return result;
}
 
function sortArrayOfHash(arr, field, desc) {
    var compare = function(a, b) {
        return a < b;
    };
 
    arr.sort(function(a, b) {
        if (a[field] === b[field]) return 0;
 
        return desc ? compare(a[field], b[field]) : compare(b[field], a[field]);
    });
}
 
function objectKeys(obj) {
    if (Object.keys) {
        return Object.keys(obj);
    }
    var result = [];
    var key;
    for (key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
            result.push(key);
        }
    }
    return result;
}
 
function requestAnimationFrame(callback) {
    var w = window;
    var foundRequestAnimationFrame = w.requestAnimationFrame
        || w.webkitRequestAnimationFrame
        || w.msRequestAnimationFrame
        || w.mozRequestAnimationFrame
        || w.oRequestAnimationFrame
        || function(cb) { setTimeout(cb, 1000/60); };
    return foundRequestAnimationFrame(callback);
}
 
function isEventable(obj) {
    return obj.attachEvent && obj.detachEvent;
}
 
module.exports = {
    getSecondsInUnit: getSecondsInUnit,
    forEach: forEach,
    arrayMap: arrayMap,
    arrayFind: arrayFind,
    arrayFilter: arrayFilter,
    arrayDifference: arrayDifference,
    arraySome: arraySome,
    hashToArray: hashToArray,
    sortArrayOfHash: sortArrayOfHash,
    throttle: throttle,
    isArray: isArray,
    isDate: isDate,
    isStringObject: isStringObject,
    isNumberObject: isNumberObject,
    isBooleanObject: isBooleanObject,
    delay: delay,
    objectKeys: objectKeys,
    requestAnimationFrame: requestAnimationFrame,
    isEventable: isEventable
};
 
/***/ })
 
/******/ });
});