]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/jsolait/missingmixin.js
Release 6.2.1
[Github/sugarcrm.git] / jssource / src_files / include / jsolait / missingmixin.js
1 /*
2
3 Modification information for LGPL compliance
4
5 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
6
7 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
8
9 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
10
11 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3  tags and updated the build system 
12
13 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
14
15 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
16
17 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
18
19 r4085 - 2005-04-13 17:30:42 -0700 (Wed, 13 Apr 2005) - robert - adding meeting scheduler and accept/decline
20
21
22 */
23
24 /*
25   Copyright (c) 2003 Jan-Klaas Kollhof
26   
27   This file is part of the JavaScript o lait library(jsolait).
28   
29   jsolait is free software; you can redistribute it and/or modify
30   it under the terms of the GNU Lesser General Public License as published by
31   the Free Software Foundation; either version 2.1 of the License, or
32   (at your option) any later version.
33  
34   This software is distributed in the hope that it will be useful,
35   but WITHOUT ANY WARRANTY; without even the implied warranty of
36   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37   GNU Lesser General Public License for more details.
38  
39   You should have received a copy of the GNU Lesser General Public License
40   along with this software; if not, write to the Free Software
41   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
42 */
43
44 if(Function.prototype.apply == null){
45     Function.prototype.apply = function(thisObj, args){
46         var a =[];
47         for(var i=0;i<args.length;i++){
48             a[i] = "args[" + i + "]";
49         }
50         thisObj.__apply__ = this;
51         a="thisObj.__apply__(" + a.join(",") +")";
52         var r = eval(a);
53         delete thisObj.__apply__;
54         return r;
55     }
56 }
57 if(Function.prototype.call==null){
58     Function.prototype.call=function(thisObj){
59         var args=[]; //copy all arguments but the first
60         for(var i=1;i<arguments.length;i++){
61             args[i-1] = arguments[i];
62         }
63         return this.apply(thisObj, args);
64     }
65 }
66
67
68 ///----------------------------------Array functions----------------------------------
69 if(Array.prototype.splice == null){
70     Array.prototype.splice = function(index, howMany){
71         var a = this.slice(0, index);
72         var e = this.slice(index + howMany, this.length);
73         var r = this.slice(index, index+howMany);
74         this.length=0;
75         for(var i=0;i<a.length;i++){
76             this[this.length] = a[i];
77         }
78         for(var i=2;i<arguments.length;i++){
79             this[this.length] = arguments[i];
80         }
81         for(var i=0;i<e.length;i++){
82             this[this.length] = e[i];
83         }
84         return r;
85     }
86 }
87
88 if(Array.prototype.pop == null){
89     Array.prototype.pop = function(){
90         var e=this[this.length-1];
91         this.length -= 1;
92         return e;
93     }
94 }
95
96 if(Array.prototype.push == null){
97     Array.prototype.push = function(){
98         for(var i=0;i<arguments.length;i++){
99             this[this.length] = arguments[i];
100         }
101         return this.length;
102     }
103 }
104
105 if(Array.prototype.shift == null){
106     Array.prototype.shift = function(){
107         var e = this[0];
108         for(var i=1;i<this.length;i++){
109             this[i-1] = this[i];
110         }
111         this.length -= 1;
112         return e;
113     }
114 }
115
116 if(Array.prototype.unshift == null){
117     Array.prototype.unshift = function(){
118         var a=[]
119         for(var i=0;i<arguments.length;i++){
120             a[i] = arguments[i];
121         }
122         for(var i=0;i<this.length;i++){
123             a[a.length] = this[i];
124         }
125         this.length=a.length;
126         for(var i=0;i<a.length;i++){
127             this[i] = a[i];
128         }
129         return this.length;
130     }
131 }
132
133
134 /**
135     Number functions.
136     
137     Contributed by Wolfgang Dumhs.
138 */
139 if(Number.prototype.toFixed == null){
140     Number.prototype.toFixed = function(d){
141         var n = this;
142         d = d || 0;
143         var f = Math.pow(10, d);
144         n = Math.round (f * n) / f;
145         n = (n >= 0) ? n+Math.pow(10, -(d+1)) : n-Math.pow(10, -(d+1));
146         n += '';
147         return d == 0 ? n.substring(0, n.indexOf('.')) : n.substring(0, n.indexOf('.') + d + 1);
148     }
149 }
150
151 if(Number.prototype.toExponential == null){
152     Number.prototype.toExponential = function(d){
153         var n = this;
154         var e = 0;
155         if (n != 0){
156             e = Math.floor(Math.log(Math.abs(n)) / Math.LN10);
157         }
158         n /= Math.pow(10, e);
159         if (isFinite(d)){
160             if (Math.abs(n) + 5*Math.pow(10, -(d+1)) >= 10.0){
161                 n /= 10;
162                 e += 1;
163             }
164             n = n.toFixed(d);
165         }
166         n += "e";
167         if (e >= 0){
168             n += "+";
169         }
170         n += e;
171         return n;
172     }
173 }
174