|
5 | 5 | */
|
6 | 6 |
|
7 | 7 | 'use strict';
|
8 |
| -/** unify browser specific implementations */ |
9 |
| -var indexedDB = window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB; |
10 |
| -var IDBKeyRange=window.IDBKeyRange||window.mozIDBKeyRange||window.webkitIDBKeyRange||window.msIDBKeyRange; |
11 | 8 |
|
12 | 9 | angular.module('xc.indexedDB', []).provider('$indexedDB', function() {
|
13 | 10 | var module = this,
|
@@ -81,7 +78,14 @@ angular.module('xc.indexedDB', []).provider('$indexedDB', function() {
|
81 | 78 | return this;
|
82 | 79 | };
|
83 | 80 |
|
84 |
| - module.$get = ['$q', '$rootScope', function($q, $rootScope) { |
| 81 | + module.$get = ['$q', '$rootScope', '$window', function($q, $rootScope, $window) { |
| 82 | + |
| 83 | + if(!('indexedDB' in $window)) { |
| 84 | + $window.indexedDB = $window.mozIndexedDB || $window.webkitIndexedDB || $window.msIndexedDB; |
| 85 | + } |
| 86 | + |
| 87 | + var IDBKeyRange = $window.IDBKeyRange || $window.mozIDBKeyRange || $window.webkitIDBKeyRange || $window.msIDBKeyRange; |
| 88 | + |
85 | 89 | /**
|
86 | 90 | * @ngdoc object
|
87 | 91 | * @name defaultQueryOptions
|
@@ -114,7 +118,7 @@ angular.module('xc.indexedDB', []).provider('$indexedDB', function() {
|
114 | 118 | deferred = $q.defer();
|
115 | 119 | module.dbPromise = deferred.promise;
|
116 | 120 |
|
117 |
| - dbReq = indexedDB.open(module.dbName, module.dbVersion || 1); |
| 121 | + dbReq = $window.indexedDB.open(module.dbName, module.dbVersion || 1); |
118 | 122 | dbReq.onsuccess = function(e) {
|
119 | 123 | module.db = dbReq.result;
|
120 | 124 | $rootScope.$apply(function(){
|
|
0 commit comments