2 // Armadillo File Manager
3 // Copyright (c) 2011, Robert Sesek <http://www.bluestatic.org>
5 // This program is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free Software
7 // Foundation, either version 3 of the License, or any later version.
12 * Defines a namespace.
15 namespace: function(ns
) {
17 this.each(ns
.split('.'), function (i
, space
) {
18 parent
[space] = parent
[space] || {};
19 parent
= parent
[space];
24 * Shortcut for creating a DOM element.
27 createDom
: function(elm
) {
28 return this(document
.createElement(elm
));
32 // Not all browsers (notably Safari) support ES5 Function.bind(). This is a
33 // rough approximation from:
34 // <https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind>.
35 if (!Function
.prototype.bind
) {
36 Function
.prototype.bind
= function (oThis
) {
37 if (typeof this !== "function") {
38 // closest thing possible to the ECMAScript 5 internal IsCallable function
39 throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
42 var aArgs
= Array
.prototype.slice
.call(arguments
, 1);
44 var fNOP
= function () {};
45 var fBound
= function () {
46 return fToBind
.apply(this instanceof fNOP
? this : oThis
|| window
,
47 aArgs
.concat(Array
.prototype.slice
.call(arguments
)));
50 fNOP
.prototype = this.prototype;
51 fBound
.prototype = new fNOP();