@@ -129,10 +129,10 @@ hello.utils.extend( hello, {
129
129
use : function ( service ) {
130
130
131
131
// Create self, which inherits from its parent
132
- var self = this . utils . objectCreate ( this ) ;
132
+ var self = Object . create ( this ) ;
133
133
134
134
// Inherit the prototype from its parent
135
- self . settings = this . utils . objectCreate ( this . settings ) ;
135
+ self . settings = Object . create ( this . settings ) ;
136
136
137
137
// Define the default service
138
138
if ( service ) {
@@ -962,31 +962,13 @@ hello.utils.extend( hello.utils, {
962
962
diff : function ( a , b ) {
963
963
var r = [ ] ;
964
964
for ( var i = 0 ; i < b . length ; i ++ ) {
965
- if ( this . indexOf ( a , b [ i ] ) === - 1 ) {
965
+ if ( a . indexOf ( b [ i ] ) === - 1 ) {
966
966
r . push ( b [ i ] ) ;
967
967
}
968
968
}
969
969
return r ;
970
970
} ,
971
971
972
- //
973
- // indexOf
974
- // IE hack Array.indexOf doesn't exist prior to IE9
975
- indexOf : function ( a , s ) {
976
- // Do we need the hack?
977
- if ( a . indexOf ) {
978
- return a . indexOf ( s ) ;
979
- }
980
-
981
- for ( var j = 0 ; j < a . length ; j ++ ) {
982
- if ( a [ j ] === s ) {
983
- return j ;
984
- }
985
- }
986
- return - 1 ;
987
- } ,
988
-
989
-
990
972
//
991
973
// unique
992
974
// remove duplicate and null values from an array
@@ -997,7 +979,7 @@ hello.utils.extend( hello.utils, {
997
979
var r = [ ] ;
998
980
for ( var i = 0 ; i < a . length ; i ++ ) {
999
981
1000
- if ( ! a [ i ] || a [ i ] . length === 0 || this . indexOf ( r , a [ i ] ) !== - 1 ) {
982
+ if ( ! a [ i ] || a [ i ] . length === 0 || r . indexOf ( a [ i ] ) !== - 1 ) {
1001
983
continue ;
1002
984
}
1003
985
else {
@@ -1016,8 +998,9 @@ hello.utils.extend( hello.utils, {
1016
998
}
1017
999
1018
1000
// Array?
1019
- if ( obj && obj . length > 0 ) return false ;
1020
- if ( obj && obj . length === 0 ) return true ;
1001
+ if ( Array . isArray ( obj ) ) {
1002
+ return ! obj . length ;
1003
+ }
1021
1004
1022
1005
// object?
1023
1006
for ( var key in obj ) {
@@ -1028,22 +1011,6 @@ hello.utils.extend( hello.utils, {
1028
1011
return true ;
1029
1012
} ,
1030
1013
1031
- // Shim, Object create
1032
- // A shim for Object.create(), it adds a prototype to a new object
1033
- objectCreate : ( function ( ) {
1034
- if ( Object . create ) {
1035
- return Object . create ;
1036
- }
1037
- function F ( ) { }
1038
- return function ( o ) {
1039
- if ( arguments . length != 1 ) {
1040
- throw new Error ( 'Object.create implementation only accepts one parameter.' ) ;
1041
- }
1042
- F . prototype = o ;
1043
- return new F ( ) ;
1044
- } ;
1045
- } ) ( ) ,
1046
-
1047
1014
/*
1048
1015
//
1049
1016
// getProtoTypeOf
@@ -1352,7 +1319,7 @@ hello.utils.extend( hello.utils, {
1352
1319
1353
1320
for ( var name in this . events ) { if ( this . events . hasOwnProperty ( name ) ) {
1354
1321
1355
- if ( hello . utils . indexOf ( a , name ) > - 1 ) {
1322
+ if ( a . indexOf ( name ) > - 1 ) {
1356
1323
1357
1324
for ( var i = 0 ; i < this . events [ name ] . length ; i ++ ) {
1358
1325
@@ -1550,17 +1517,6 @@ hello.utils.extend( hello.utils, {
1550
1517
//
1551
1518
var location = window . location ;
1552
1519
1553
- //
1554
- // Add a helper for relocating, instead of window.location = url;
1555
- //
1556
- var relocate = function ( path ) {
1557
- if ( location . assign ) {
1558
- location . assign ( path ) ;
1559
- }
1560
- else {
1561
- window . location = path ;
1562
- }
1563
- } ;
1564
1520
1565
1521
//
1566
1522
// Is this an auth relay message which needs to call the proxy?
@@ -1577,7 +1533,7 @@ hello.utils.extend( hello.utils, {
1577
1533
// redirect to the host
1578
1534
var path = ( state . oauth_proxy || p . proxy_url ) + "?" + utils . param ( p ) ;
1579
1535
1580
- relocate ( path ) ;
1536
+ location . assign ( path ) ;
1581
1537
return ;
1582
1538
}
1583
1539
@@ -1647,7 +1603,7 @@ hello.utils.extend( hello.utils, {
1647
1603
1648
1604
// If this page is still open
1649
1605
if ( p . page_uri ) {
1650
- window . location = p . page_uri ;
1606
+ location . assign ( p . page_uri ) ;
1651
1607
}
1652
1608
1653
1609
@@ -1658,7 +1614,7 @@ hello.utils.extend( hello.utils, {
1658
1614
// Loading the redirect.html before triggering the OAuth Flow seems to fix it.
1659
1615
else if ( "oauth_redirect" in p ) {
1660
1616
1661
- relocate ( decodeURIComponent ( p . oauth_redirect ) ) ;
1617
+ location . assign ( decodeURIComponent ( p . oauth_redirect ) ) ;
1662
1618
return ;
1663
1619
}
1664
1620
@@ -2419,14 +2375,6 @@ hello.utils.extend( hello.utils, {
2419
2375
2420
2376
2421
2377
2422
-
2423
- //
2424
- // isArray
2425
- isArray : function ( o ) {
2426
- return Object . prototype . toString . call ( o ) === '[object Array]' ;
2427
- } ,
2428
-
2429
-
2430
2378
// _DOM
2431
2379
// return the type of DOM object
2432
2380
domInstance : function ( type , data ) {
@@ -2452,7 +2400,7 @@ hello.utils.extend( hello.utils, {
2452
2400
return obj ;
2453
2401
}
2454
2402
var clone ;
2455
- if ( this . isArray ( obj ) ) {
2403
+ if ( Array . isArray ( obj ) ) {
2456
2404
clone = [ ] ;
2457
2405
for ( var i = 0 ; i < obj . length ; i ++ ) {
2458
2406
clone . push ( this . clone ( obj [ i ] ) ) ;
@@ -3084,29 +3032,3 @@ utils.extend(utils, {
3084
3032
} ;
3085
3033
3086
3034
} ) ( hello ) ;
3087
-
3088
-
3089
-
3090
-
3091
-
3092
-
3093
- // MDN
3094
- // Polyfill IE8, does not support native Function.bind
3095
-
3096
- if ( ! Function . prototype . bind ) {
3097
- Function . prototype . bind = function ( b ) {
3098
- if ( typeof this !== "function" ) {
3099
- throw new TypeError ( "Function.prototype.bind - what is trying to be bound is not callable" ) ;
3100
- }
3101
- function c ( ) { }
3102
- var a = [ ] . slice ,
3103
- f = a . call ( arguments , 1 ) ,
3104
- e = this ,
3105
- d = function ( ) {
3106
- return e . apply ( this instanceof c ?this :b || window , f . concat ( a . call ( arguments ) ) ) ;
3107
- } ;
3108
- c . prototype = this . prototype ;
3109
- d . prototype = new c ( ) ;
3110
- return d ;
3111
- } ;
3112
- }
0 commit comments