This repository was archived by the owner on Aug 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodiqa.ext.js
127 lines (104 loc) · 3.75 KB
/
codiqa.ext.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
window.CodiqaControls = {
types: {},
instances: {},
define: function(type, control) {
control._type = type;
this.types[type] = control;
},
register: function(type, id, opts) {
var instance = new this.types[type]();
instance._type = type;
instance._id = id;
instance._opts = opts;
this.instances[id] = instance;
if(!this.types[type].prototype._isInited) {
this.types[type].prototype.initType();
}
return instance;
},
init: function() {
for(var type in this.types) {
this.types[type].prototype.initType();
}
},
refresh: function() {
for(var x in this.instances) {
this.instances[x].refresh && this.instances[x].refresh();
}
},
callbackInit: function() {
},
getInstances: function(type) {
var x, instance, instances = [];
for(x in this.instances) {
instance = this.instances[x];
if(instance._type === type) {
instances.push(instance);
}
}
return instances;
}
};
CodiqaControls.GoogleMap = function () {};
CodiqaControls.GoogleMap.prototype.initType = function() {
if( window.CodiqaControls.getInstances('googlemaps').length ) {
if(this._isInited) {
if(window.google && window.google.maps) {
CodiqaControls.GoogleMap.prototype.callbackInit();
}
} else {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "https://maps.googleapis.com/maps/api/js?sensor=true&callback=CodiqaControls.types.googlemaps.prototype.callbackInit";
document.getElementsByTagName("head")[0].appendChild(script);
this._isInited = true;
}
}
};
CodiqaControls.GoogleMap.prototype.callbackInit = function() {
var x, instances = window.CodiqaControls.getInstances('googlemaps');
for(x = 0; x < instances.length; x++) {
instances[x]._opts.ready(instances[x]);
}
};
CodiqaControls.GoogleMap.prototype.refresh = function() {
if( this.map && this.el && $(this.el).closest('.ui-page-active').length ) {
google.maps.event.trigger(this.map, 'resize');
this.center && this.map.setCenter(this.center);
}
};
window.CodiqaControls.define('googlemaps', CodiqaControls.GoogleMap);
(function($) {
$.widget('mobile.tabbar', $.mobile.navbar, {
_create: function() {
// Set the theme before we call the prototype, which will
// ensure buttonMarkup() correctly grabs the inheritied theme.
// We default to the "a" swatch if none is found
var theme = this.element.jqmData('theme') || "a";
this.element.addClass('ui-footer ui-footer-fixed ui-bar-' + theme);
// Make sure the page has padding added to it to account for the fixed bar
this.element.closest('[data-role="page"]').addClass('ui-page-footer-fixed');
// Call the NavBar _create prototype
$.mobile.navbar.prototype._create.call(this);
},
// Set the active URL for the Tab Bar, and highlight that button on the bar
setActive: function(url) {
// Sometimes the active state isn't properly cleared, so we reset it ourselves
this.element.find('a').removeClass('ui-btn-active ui-state-persist');
this.element.find('a[href="' + url + '"]').addClass('ui-btn-active ui-state-persist');
}
});
$(document).on('pagecreate create', function(e) {
return $(e.target).find(":jqmData(role='tabbar')").tabbar();
});
$(document).on('pageshow', ":jqmData(role='page')", function(e) {
// Grab the id of the page that's showing, and select it on the Tab Bar on the page
var tabBar, id = $(e.target).attr('id');
tabBar = $.mobile.activePage.find(':jqmData(role="tabbar")');
if(tabBar.length) {
tabBar.tabbar('setActive', '#' + id);
}
window.CodiqaControls.refresh();
});
window.CodiqaControls.init();
})(jQuery);