forked from angular-google-chart/angular-google-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ng-google-chart.js
executable file
·819 lines (718 loc) · 30.5 KB
/
ng-google-chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
/*! angular-google-chart 2015-11-29 */
/*
* @description Google Chart Api Directive Module for AngularJS
* @version 0.1.0
* @author GitHub Contributors <https://github.com/angular-google-chart/angular-google-chart/graphs/contributors>
* @license MIT
* @year 2013
*/
/* global angular */
(function(){
angular.module('googlechart', [])
.run(registerResizeEvent);
registerResizeEvent.$inject = ['$rootScope', '$window'];
function registerResizeEvent($rootScope, $window){
angular.element($window).bind('resize', function () {
$rootScope.$emit('resizeMsg');
});
}
})();
/* global angular, google */
(function(){
angular.module('googlechart')
.factory('FormatManager', formatManagerFactory);
function formatManagerFactory(){
// Handles the processing of Google Charts API Formats
function FormatManager($google){
var self = this;
var oldFormatTemplates = {};
self.iFormats = {}; // Holds instances of formats (ie. self.iFormats.date[0] = new $google.visualization.DateFormat(params))
self.applyFormats = applyFormats;
// apply formats of type to datatable
function apply(tFormats, dataTable){
var i, formatType;
for (formatType in tFormats){
if (tFormats.hasOwnProperty(formatType)){
for (i = 0; i < self.iFormats[formatType].length; i++) {
if (tFormats[formatType][i].columnNum < dataTable.getNumberOfColumns()) {
self.iFormats[formatType][i].format(dataTable, tFormats[formatType][i].columnNum);
}
}
}
}
}
function applyFormat(formatType, FormatClass, tFormats){
var i;
if (angular.isArray(tFormats[formatType])) {
// basic change detection; no need to run if no changes
if (!angular.equals(tFormats[formatType], oldFormatTemplates[formatType])) {
oldFormatTemplates[formatType] = tFormats[formatType];
self.iFormats[formatType] = [];
if (formatType === 'color') {
instantiateColorFormatters(tFormats);
} else {
for (i = 0; i < tFormats[formatType].length; i++) {
self.iFormats[formatType].push(new FormatClass(
tFormats[formatType][i])
);
}
}
}
}
}
function applyFormats(dataTable, tFormats, customFormatters) {
var formatType, FormatClass, requiresHtml = false;
if (!angular.isDefined(tFormats) || !angular.isDefined(dataTable)){
return { requiresHtml: false };
}
for (formatType in tFormats){
if (tFormats.hasOwnProperty(formatType)){
FormatClass = getFormatClass(formatType, customFormatters);
if (!angular.isFunction(FormatClass)){
// if no class constructor was returned,
// there's no point in completing cycle
continue;
}
applyFormat(formatType, FormatClass, tFormats);
//Many formatters require HTML tags to display special formatting
if (formatType === 'arrow' || formatType === 'bar' || formatType === 'color') {
requiresHtml = true;
}
}
}
apply(tFormats, dataTable);
return { requiresHtml: requiresHtml };
}
function instantiateColorFormatters(tFormats){
var t, colorFormat, i, data, formatType = 'color';
for (t = 0; t < tFormats[formatType].length; t++) {
colorFormat = new $google.visualization.ColorFormat();
for (i = 0; i < tFormats[formatType][t].formats.length; i++) {
data = tFormats[formatType][t].formats[i];
if (typeof (data.fromBgColor) !== 'undefined' && typeof (data.toBgColor) !== 'undefined') {
colorFormat.addGradientRange(data.from, data.to, data.color, data.fromBgColor, data.toBgColor);
} else {
colorFormat.addRange(data.from, data.to, data.color, data.bgcolor);
}
}
self.iFormats[formatType].push(colorFormat);
}
}
function getFormatClass(formatType, customFormatters){
var className = formatType.charAt(0).toUpperCase() + formatType.slice(1).toLowerCase() + "Format";
if ($google.visualization.hasOwnProperty(className)){
return google.visualization[className];
} else if (angular.isDefined(customFormatters) && customFormatters.hasOwnProperty(formatType)) {
return customFormatters[formatType];
}
return;
}
}
return FormatManager;
}
})();
/* global angular, google */
(function() {
angular.module('googlechart')
.controller('GoogleChartController', GoogleChartController);
GoogleChartController.$inject = ['$scope', '$element', '$attrs', '$injector', '$timeout', '$window', '$rootScope', 'GoogleChartService'];
function GoogleChartController($scope, $element, $attrs, $injector, $timeout, $window, $rootScope, GoogleChartService) {
var self = this;
var resizeHandler;
var googleChartService;
init();
function cleanup() {
resizeHandler();
}
function draw() {
if (!draw.triggered && (self.chart !== undefined)) {
draw.triggered = true;
$timeout(setupAndDraw, 0, true);
}
else if (self.chart !== undefined) {
$timeout.cancel(draw.recallTimeout);
draw.recallTimeout = $timeout(draw, 10);
}
}
// Watch function calls this.
function drawAsync() {
googleChartService.getReadyPromise()
.then(draw);
}
//setupAndDraw() calls this.
function drawChartWrapper() {
googleChartService.draw();
draw.triggered = false;
}
function init() {
// Instantiate service
googleChartService = new GoogleChartService();
self.registerChartListener = googleChartService.registerChartListener;
self.registerWrapperListener = googleChartService.registerWrapperListener;
self.registerServiceListener = googleChartService.registerServiceListener;
/* Watches, to refresh the chart when its data, formatters, options, view,
or type change. All other values intentionally disregarded to avoid double
calls to the draw function. Please avoid making changes to these objects
directly from this directive.*/
$scope.$watch(watchValue, watchHandler, true); // true is for deep object equality checking
// Redraw the chart if the window is resized
resizeHandler = $rootScope.$on('resizeMsg', drawAsync);
//Cleanup resize handler.
$scope.$on('$destroy', cleanup);
}
function setupAndDraw() {
googleChartService.setup($element,
self.chart.type,
self.chart.data,
self.chart.view,
self.chart.options,
self.chart.formatters,
self.chart.customFormatters);
$timeout(drawChartWrapper);
}
function watchHandler() {
self.chart = $scope.$eval($attrs.chart);
drawAsync();
}
function watchValue() {
var chartObject = $scope.$eval($attrs.chart);
if (angular.isDefined(chartObject) && angular.isObject(chartObject)) {
return {
customFormatters: chartObject.customFormatters,
data: chartObject.data,
formatters: chartObject.formatters,
options: chartObject.options,
type: chartObject.type,
view: chartObject.view
};
}
}
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.directive('agcBeforeDraw', onReadyDirective);
function onReadyDirective(){
return {
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject=['chartWrapper'];
function callback(chartWrapper){
scope.$apply(function (){
scope.$eval(attrs.agcBeforeDraw, {chartWrapper: chartWrapper});
});
}
googleChartController.registerServiceListener('beforeDraw', callback, this);
}
};
}
})();
(function(){
angular.module('googlechart')
.directive('agcOnClick', onClickDirective);
function onClickDirective(){
return {
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject = ['args', 'chart', 'chartWrapper'];
function callback(args, chart, chartWrapper){
scope.$apply(function (){
scope.$eval(attrs.agcOnClick, {args: args, chart: chart, chartWrapper: chartWrapper});
});
}
googleChartController.registerChartListener('click', callback, this);
}
};
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.directive('agcOnError', onErrorDirective);
function onErrorDirective(){
return{
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject = ['chartWrapper', 'chart', 'args'];
function callback(chartWrapper, chart, args){
var returnValues = {
chartWrapper: chartWrapper,
chart: chart,
args: args,
error: args[0],
err: args[0],
id: args[0].id,
message: args[0].message
};
scope.$apply(function(){
scope.$eval(attrs.agcOnError, returnValues);
});
}
googleChartController.registerWrapperListener('error', callback, this);
}
};
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.directive('agcOnMouseout', agcOnMouseoutDirective);
function agcOnMouseoutDirective(){
return {
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject = ['args', 'chart', 'chartWrapper'];
function callback(args, chart, chartWrapper){
var returnParams = {
chartWrapper: chartWrapper,
chart: chart,
args: args,
column: args[0].column,
row: args[0].row
};
scope.$apply(function () {
scope.$eval(attrs.agcOnMouseout, returnParams);
});
}
googleChartController.registerChartListener('onmouseout', callback, this);
}
};
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.directive('agcOnMouseover', agcOnMouseoverDirective);
function agcOnMouseoverDirective(){
return {
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject = ['args', 'chart', 'chartWrapper'];
function callback(args, chart, chartWrapper){
var returnParams = {
chartWrapper: chartWrapper,
chart: chart,
args: args,
column: args[0].column,
row: args[0].row
};
scope.$apply(function () {
scope.$eval(attrs.agcOnMouseover, returnParams);
});
}
googleChartController.registerChartListener('onmouseover', callback, this);
}
};
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.directive('agcOnReady', onReadyDirective);
function onReadyDirective(){
return {
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject=['chartWrapper'];
function callback(chartWrapper){
scope.$apply(function (){
scope.$eval(attrs.agcOnReady, {chartWrapper: chartWrapper});
});
}
googleChartController.registerWrapperListener('ready', callback, this);
}
};
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.directive('agcOnSelect', onSelectDirective);
function onSelectDirective(){
return {
restrict: 'A',
scope: false,
require: 'googleChart',
link: function(scope, element, attrs, googleChartController){
callback.$inject = ['chartWrapper', 'chart'];
function callback(chartWrapper, chart){
var selectEventRetParams = { selectedItems: chart.getSelection() };
// This is for backwards compatibility for people using 'selectedItem' that only wanted the first selection.
selectEventRetParams.selectedItem = selectEventRetParams.selectedItems[0];
selectEventRetParams.chartWrapper = chartWrapper;
selectEventRetParams.chart = chart;
scope.$apply(function () {
scope.$eval(attrs.agcOnSelect, selectEventRetParams);
});
}
googleChartController.registerWrapperListener('select', callback, this);
}
};
}
})();
/* global angular, google */
/* jshint -W072 */
(function(){
angular.module('googlechart')
.directive('googleChart', googleChartDirective);
googleChartDirective.$inject = [];
function googleChartDirective() {
return {
restrict: 'A',
scope: false,
controller: 'GoogleChartController'
};
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.value('googleChartApiConfig', {
version: '1',
optionalSettings: {
packages: ['corechart']
}
});
})();
/* global angular */
(function(){
angular.module('googlechart')
.factory('googleChartApiPromise', googleChartApiPromiseFactory);
googleChartApiPromiseFactory.$inject = ['$rootScope', '$q', 'googleChartApiConfig', 'googleJsapiUrl'];
function googleChartApiPromiseFactory($rootScope, $q, apiConfig, googleJsapiUrl) {
apiConfig.optionalSettings = apiConfig.optionalSettings || {};
var apiReady = $q.defer();
var onLoad = function () {
// override callback function
var settings = {
callback: function () {
var oldCb = apiConfig.optionalSettings.callback;
$rootScope.$apply(function () {
apiReady.resolve(google);
});
if (angular.isFunction(oldCb)) {
oldCb.call(this);
}
}
};
settings = angular.extend({}, apiConfig.optionalSettings, settings);
window.google.load('visualization', apiConfig.version, settings);
};
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.src = googleJsapiUrl;
if (script.addEventListener) { // Standard browsers (including IE9+)
script.addEventListener('load', onLoad, false);
} else { // IE8 and below
script.onreadystatechange = function () {
if (script.readyState === 'loaded' || script.readyState === 'complete') {
script.onreadystatechange = null;
onLoad();
}
};
}
head.appendChild(script);
return apiReady.promise;
}
})();
/* global angular */
(function() {
angular.module('googlechart')
.factory('GoogleChartService', GoogleChartServiceFactory);
GoogleChartServiceFactory.$inject = ['googleChartApiPromise', '$injector', '$q', 'FormatManager'];
function GoogleChartServiceFactory(googleChartApiPromise, $injector, $q, FormatManager) {
function GoogleChartService() {
var self = this;
self.draw = draw;
self.getChartWrapper = getChartWrapper;
self.getData = getData;
self.getElement = getElement;
self.getOption = getOption;
self.getOptions = getOptions;
self.getView = getView;
self.getReadyPromise = getReadyPromise;
self.isApiReady = isApiReady;
self.registerChartListener = registerChartListener;
self.registerServiceListener = registerServiceListener;
self.registerWrapperListener = registerWrapperListener;
self.setData = setData;
self.setElement = setElement;
self.setOption = setOption;
self.setOptions = setOptions;
self.setup = setup;
self.setView = setView;
var $google,
_apiPromise,
_apiReady,
_chartWrapper,
_element,
_chartType,
_data,
_view,
_options,
_formatters,
_innerVisualization,
_formatManager,
_needsUpdate = true,
_customFormatters,
_serviceDeferred,
serviceListeners = {},
wrapperListeners = {},
chartListeners = {};
_init();
function _activateServiceEvent(eventName) {
var i;
if (angular.isArray(serviceListeners[eventName])) {
for (i = 0; i < serviceListeners[eventName].length; i++) {
serviceListeners[eventName][i]();
}
}
}
function _apiLoadFail(reason) {
// Not sure what to do if this does happen.
// Post your suggestions in the issues tracker at
// https://github.com/angular-google-chart/angular-google-chart/
return reason;
}
function _apiLoadSuccess(g) {
$google = g;
_apiReady = true;
_serviceDeferred.resolve();
return g;
}
function _continueSetup() {
if (!angular.isDefined(_chartWrapper)) {
_chartWrapper = new $google.visualization.ChartWrapper({
chartType: _chartType,
dataTable: _data,
view: _view,
options: _options,
containerId: _element[0]
});
_registerListenersWithGoogle(_chartWrapper, wrapperListeners);
}
else {
_chartWrapper.setChartType(_chartType);
_chartWrapper.setDataTable(_data);
_chartWrapper.setView(_view);
_chartWrapper.setOptions(_options);
}
if (!_formatManager) {
_formatManager = new FormatManager($google);
}
if (_formatManager.applyFormats(_chartWrapper.getDataTable(),
_formatters, _customFormatters).requiresHtml) {
_chartWrapper.setOption('allowHtml', true);
}
_needsUpdate = false;
}
// Credit for this solution:
// http://stackoverflow.com/a/20125572/3771976
function _getSetDescendantProp(obj, desc, value) {
var arr = desc ? desc.split(".") : [];
while (arr.length && obj) {
var comp = arr.shift();
var match = new RegExp("(.+)\\[([0-9]*)\\]").exec(comp);
if (value) {
if (obj[comp] === undefined) {
obj[comp] = {};
}
if (arr.length === 0) {
obj[comp] = value;
}
}
obj = obj[comp];
}
return obj;
}
function _handleReady() {
// When the chartWrapper is ready, check to see if the inner chart
// has changed. If it has, re-register listeners onto that chart.
if (_innerVisualization !== _chartWrapper.getChart()) {
_innerVisualization = _chartWrapper.getChart();
_registerListenersWithGoogle(_innerVisualization, chartListeners);
}
}
function _init() {
_apiReady = false;
_serviceDeferred = $q.defer();
//keeps the resulting promise to chain on other actions
_apiPromise = googleChartApiPromise
.then(_apiLoadSuccess)
.catch(_apiLoadFail);
registerWrapperListener('ready', _handleReady, self);
}
function _registerListener(listenerCollection, eventName, listenerFn, listenerObject) {
// This is the function that will be invoked by the charts API.
// Passing the wrapper function allows the use of DI for
// for the called function.
var listenerWrapper = function() {
var locals = {
chartWrapper: _chartWrapper,
chart: _chartWrapper.getChart(),
args: arguments
};
$injector.invoke(listenerFn, listenerObject || this, locals);
};
if (angular.isDefined(listenerCollection) && angular.isObject(listenerCollection)) {
if (!angular.isArray(listenerCollection[eventName])) {
listenerCollection[eventName] = [];
}
listenerCollection[eventName].push(listenerWrapper);
return function() {
if (angular.isDefined(listenerWrapper.googleListenerHandle)) {
$google.visualization.events.removeListener(listenerWrapper.googleListenerHandle);
}
var fnIndex = listenerCollection[eventName].indexOf(listenerWrapper);
listenerCollection[eventName].splice(fnIndex, 1);
if (listenerCollection[eventName].length === 0) {
listenerCollection[eventName] = undefined;
}
};
}
}
function _registerListenersWithGoogle(eventSource, listenerCollection) {
for (var eventName in listenerCollection) {
if (listenerCollection.hasOwnProperty(eventName) && angular.isArray(listenerCollection[eventName])) {
for (var fnIterator = 0; fnIterator < listenerCollection[eventName].length; fnIterator++) {
if (angular.isFunction(listenerCollection[eventName][fnIterator])) {
listenerCollection[eventName][fnIterator].googleListenerHandle =
$google.visualization.events.addListener(eventSource, eventName, listenerCollection[eventName][fnIterator]);
}
}
}
}
}
function _runDrawCycle() {
_activateServiceEvent('beforeDraw');
_chartWrapper.draw();
}
/*
This function does this:
- waits for API to load, if not already loaded
- sets up ChartWrapper object (create or update)
- schedules timeout event to draw chart
*/
function draw() {
if (_needsUpdate) {
_apiPromise = _apiPromise.then(_continueSetup);
}
_apiPromise = _apiPromise.then(_runDrawCycle());
}
function getChartWrapper() {
// Most get functions on this interface return copies,
// this one should return reference so as to expose the
//chart api to users
return _chartWrapper;
}
function getData() {
var data = _data || {};
return angular.copy(data);
}
function getElement() {
return _element;
}
function getOption(name) {
var options = _options || {};
return _getSetDescendantProp(options, name);
}
function getOptions() {
var options = _options || {};
return angular.copy(options);
}
function getReadyPromise() {
return _serviceDeferred.promise;
}
function getView() {
var view = _view || {};
return angular.copy(view);
}
function isApiReady() {
return _apiReady;
}
function registerChartListener(eventName, listenerFn, listenerObject) {
return _registerListener(chartListeners, eventName, listenerFn, listenerObject);
}
function registerServiceListener(eventName, listenerFn, listenerObject) {
return _registerListener(serviceListeners, eventName, listenerFn, listenerObject);
}
function registerWrapperListener(eventName, listenerFn, listenerObject) {
return _registerListener(wrapperListeners, eventName, listenerFn, listenerObject);
}
function setData(data) {
if (angular.isDefined(data)) {
_data = angular.copy(data);
_needsUpdate = true;
}
}
function setElement(element) {
if (angular.isElement(element) && _element !== element) {
_element = element;
// clear out the chartWrapper because we're going to need a new one
_chartWrapper = null;
_needsUpdate = true;
}
}
function setOption(name, value) {
_options = _options || {};
_getSetDescendantProp(_options, name, angular.copy(value));
_needsUpdate = true;
}
function setOptions(options) {
if (angular.isDefined(options)) {
_options = angular.copy(options);
_needsUpdate = true;
}
}
function setup(element, chartType, data, view, options, formatters, customFormatters) {
// Keep values if already set,
// can call setup() with nulls to keep
// existing values
_element = element || _element;
_chartType = chartType || _chartType;
_data = data || _data;
_view = view || _view;
_options = options || _options;
_formatters = formatters || _formatters;
_customFormatters = customFormatters || _customFormatters;
_apiPromise = _apiPromise.then(_continueSetup);
}
function setView(view) {
_view = angular.copy(view);
}
}
return GoogleChartService;
}
})();
/* global angular */
(function(){
angular.module('googlechart')
.provider('googleJsapiUrl', googleJsapiUrlProvider);
function googleJsapiUrlProvider() {
var protocol = 'https:';
var url = '//www.google.com/jsapi';
this.setProtocol = function (newProtocol) {
protocol = newProtocol;
};
this.setUrl = function (newUrl) {
url = newUrl;
};
this.$get = function () {
return (protocol ? protocol : '') + url;
};
}
})();