|
| 1 | +/** |
| 2 | + * @ngdoc service |
| 3 | + * @name ngCordovaMocks.cordovaProgress |
| 4 | + * |
| 5 | + * @description |
| 6 | + * A service for testing Progress Indicator |
| 7 | + * in an app build with ngCordova. |
| 8 | + */ |
| 9 | + |
| 10 | +ngCordovaMocks.factory('$cordovaProgress', [ |
| 11 | + '$timeout', function($timeout) { |
| 12 | + |
| 13 | + return { |
| 14 | + show: function(_message) { |
| 15 | + var message = _message || 'Please wait...'; |
| 16 | + console.info('$cordovaProgress.message', message); |
| 17 | + }, |
| 18 | + |
| 19 | + showSimple: function(_dim) { |
| 20 | + var dim = _dim || false; |
| 21 | + console.info('$cordovaProgress.dim', dim); |
| 22 | + }, |
| 23 | + |
| 24 | + showSimpleWithLabel: function(_dim, _label) { |
| 25 | + var dim = _dim || false; |
| 26 | + var label = _label || 'Loading...'; |
| 27 | + console.group(); |
| 28 | + console.info('$cordovaProgress.dim', dim); |
| 29 | + console.info('$cordovaProgress.label', label); |
| 30 | + console.groupEnd(); |
| 31 | + }, |
| 32 | + |
| 33 | + showSimpleWithLabelDetail: function(_dim, _label, _detail) { |
| 34 | + var dim = _dim || false; |
| 35 | + var label = _label || 'Loading...'; |
| 36 | + var detail = _detail || 'Please wait'; |
| 37 | + |
| 38 | + console.group(); |
| 39 | + console.info('$cordovaProgress.dim', dim); |
| 40 | + console.info('$cordovaProgress.label', label); |
| 41 | + console.info('$cordovaProgress.detail', detail); |
| 42 | + console.groupEnd(); |
| 43 | + }, |
| 44 | + |
| 45 | + showDeterminate: function(_dim, _timeout) { |
| 46 | + var dim = _dim || false; |
| 47 | + var timeout = _timeout || 50000; |
| 48 | + console.group(); |
| 49 | + console.info('$cordovaProgress.dim show', dim); |
| 50 | + console.info('$cordovaProgress.timeout', timeout); |
| 51 | + console.groupEnd(); |
| 52 | + $timeout(function() { |
| 53 | + console.info('$cordovaProgress.dim timeout', dim); |
| 54 | + }, timeout); |
| 55 | + }, |
| 56 | + |
| 57 | + showDeterminateWithLabel: function(_dim, _timeout, _label) { |
| 58 | + var dim = _dim || false; |
| 59 | + var timeout = _timeout || 50000; |
| 60 | + var label = _label || 'Loading...'; |
| 61 | + |
| 62 | + console.group(); |
| 63 | + console.info('$cordovaProgress.dim', dim); |
| 64 | + console.info('$cordovaProgress.timeout', timeout); |
| 65 | + console.info('$cordovaProgress.label', label); |
| 66 | + console.groupEnd(); |
| 67 | + $timeout(function() { |
| 68 | + console.info('$cordovaProgress[dim, label] timeout', [dim, label]); |
| 69 | + }, timeout); |
| 70 | + }, |
| 71 | + |
| 72 | + showAnnular: function(_dim, _timeout) { |
| 73 | + var dim = _dim || false; |
| 74 | + var timeout = _timeout || 50000; |
| 75 | + |
| 76 | + console.group(); |
| 77 | + console.info('$cordovaProgress.dim', dim); |
| 78 | + console.info('$cordovaProgress.timeout', timeout); |
| 79 | + console.groupEnd(); |
| 80 | + $timeout(function() { |
| 81 | + console.info('$cordovaProgress.dim timeout', dim); |
| 82 | + }, timeout); |
| 83 | + }, |
| 84 | + |
| 85 | + showAnnularWithLabel: function(_dim, _timeout, _label) { |
| 86 | + var dim = _dim || false; |
| 87 | + var timeout = _timeout || 50000; |
| 88 | + var label = _label || 'Loading...'; |
| 89 | + |
| 90 | + console.group(); |
| 91 | + console.info('$cordovaProgress.dim', dim); |
| 92 | + console.info('$cordovaProgress.timeout', timeout); |
| 93 | + console.info('$cordovaProgress.label', label); |
| 94 | + console.groupEnd(); |
| 95 | + $timeout(function() { |
| 96 | + console.info('$cordovaProgress[dim, label] timeout', [dim, label]); |
| 97 | + }, timeout); |
| 98 | + }, |
| 99 | + |
| 100 | + showBar: function(_dim, _timeout) { |
| 101 | + var dim = _dim || false; |
| 102 | + var timeout = _timeout || 50000; |
| 103 | + |
| 104 | + console.group(); |
| 105 | + console.info('$cordovaProgress.dim', dim); |
| 106 | + console.info('$cordovaProgress.timeout', timeout); |
| 107 | + console.groupEnd(); |
| 108 | + $timeout(function() { |
| 109 | + console.info('$cordovaProgress.dim timeout', dim); |
| 110 | + }, timeout); |
| 111 | + }, |
| 112 | + |
| 113 | + showBarWithLabel: function(_dim, _timeout, _label) { |
| 114 | + var dim = _dim || false; |
| 115 | + var timeout = _timeout || 50000; |
| 116 | + var label = _label || 'Loading...'; |
| 117 | + console.group(); |
| 118 | + console.info('$cordovaProgress.dim', dim); |
| 119 | + console.info('$cordovaProgress.label', label); |
| 120 | + console.info('$cordovaProgress.timeout', timeout); |
| 121 | + console.groupEnd(); |
| 122 | + $timeout(function() { |
| 123 | + console.info('$cordovaProgress[dim, label] timeout', [dim, label]); |
| 124 | + }, timeout); |
| 125 | + }, |
| 126 | + |
| 127 | + showSuccess: function(_dim, _label) { |
| 128 | + var dim = _dim || false; |
| 129 | + var label = _label || 'Success'; |
| 130 | + console.group(); |
| 131 | + console.info('$cordovaProgress.dim', dim); |
| 132 | + console.info('$cordovaProgress.label', label); |
| 133 | + console.groupEnd(); |
| 134 | + }, |
| 135 | + |
| 136 | + showText: function(_dim, _text, _position) { |
| 137 | + var dim = _dim || false; |
| 138 | + var text = _text || 'Warning'; |
| 139 | + var position = _position || 'center'; |
| 140 | + console.group(); |
| 141 | + console.info('$cordovaProgress.dim', dim); |
| 142 | + console.info('$cordovaProgress.text', text); |
| 143 | + console.info('$cordovaProgress.position', position); |
| 144 | + console.groupEnd(); |
| 145 | + }, |
| 146 | + |
| 147 | + hide: function() { |
| 148 | + console.info('$cordovaProgress.hide'); |
| 149 | + } |
| 150 | + }; |
| 151 | + } |
| 152 | +]); |
0 commit comments