forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.js
More file actions
192 lines (162 loc) · 5.6 KB
/
base.js
File metadata and controls
192 lines (162 loc) · 5.6 KB
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
// for IE (before 10) we use a jquery plugin called jQuery.XDomainRequest. Explained here,
//http://stackoverflow.com/questions/11487216/cors-with-jquery-and-xdomainrequest-in-ie8-9
//
$(document).ajaxSuccess(function () {
var contents = new Contents(page.client);
contents.on_load();
});
var onLoad = new PjaxExecQueue();
var onUnload = new PjaxExecQueue();
var SessionStore, LocalStore;
if (isStorageSupported(window.localStorage)) {
LocalStore = new Store(window.localStorage);
}
if (isStorageSupported(window.sessionStorage)) {
if (!LocalStore) {
LocalStore = new Store(window.sessionStorage);
}
SessionStore = new Store(window.sessionStorage);
}
if (!SessionStore || !LocalStore) {
if (!LocalStore) {
LocalStore = new InScriptStore();
}
if (!SessionStore) {
SessionStore = new InScriptStore();
}
}
var Settings = new CookieStorage('settings');
var page = new Page(window.page_params);
onLoad.queue(function () {
page.on_load();
});
onUnload.queue(function () {
page.on_unload();
});
var bo_url;
//////////////////////////////////////////////////////////////
//Purpose: To solve cross domain logged out server problem.
//Return: Hostname for this page
//////////////////////////////////////////////////////////////
function changeUrlToSameDomain(url) {
var re = new RegExp('^(http|https):\/\/[.a-zA-Z0-9-]+/');
var server_name = window.location.protocol + '//' + window.location.hostname;
var same_domain_url = url.replace(re, server_name + '/');
return same_domain_url;
}
function formEffects() {
var select_focus_event = function () {
$(this)
.addClass('focus')
.siblings().addClass('focus')
.parents('fieldset').addClass('focus');
};
var select_blur_event = function () {
$(this)
.removeClass('focus')
.siblings().removeClass('focus')
.parents('fieldset').removeClass('focus');
};
var input_focus_event = function () {
$(this)
.parent('div').addClass('focus')
.parents('fieldset').addClass('focus');
};
var input_blur_event = function () {
$(this)
.parent('div').removeClass('focus')
.parents('fieldset').removeClass('focus');
};
this.set = function (jqObject) {
jqObject
.delegate('select', 'focus', select_focus_event)
.delegate('select', 'blur', select_blur_event);
jqObject
.delegate('input[type=text],input[type=password],textarea', 'focus', input_focus_event)
.delegate('input[type=text],input[type=password],textarea', 'blur', input_blur_event);
};
}
function add_click_effect_to_button() {
var prefix = function (class_name) {
var class_names = class_name.split(/\s+/);
var _prefix = 'button';
var cn = class_names.shift();
while (cn) {
if (cn && cn != _prefix && !cn.match(/-focus|-hover/)) {
_prefix = cn;
break;
}
cn = class_names.shift();
}
return _prefix;
};
var remove_button_class = function (button, class_name) {
button.removeClass(class_name).children('.button').removeClass(class_name).end().parent('.button').removeClass(class_name);
};
var add_button_class = function (button, class_name) {
button.addClass(class_name).children('.button').addClass(class_name).end().parent('.button').addClass(class_name);
};
$('#content,#popup')
.delegate('.button', 'mousedown', function () {
var class_name = prefix(this.className) + '-focus';
add_button_class($(this), class_name);
})
.delegate('.button', 'mouseup', function () {
var class_name = prefix(this.className) + '-focus';
remove_button_class($(this), class_name);
})
.delegate('.button', 'mouseover', function () {
var class_name = prefix(this.className) + '-hover';
add_button_class($(this), class_name);
})
.delegate('.button', 'mouseout', function () {
var class_name = prefix(this.className) + '-hover';
remove_button_class($(this), class_name);
});
}
var make_mobile_menu = function () {
if ($('#mobile-menu-container').is(':visible')) {
$('#mobile-menu').mmenu({
position: 'right',
zposition: 'front',
slidingSubmenus: false,
searchfield: true,
onClick: {
close: true
},
}, {
selectedClass: 'active',
});
}
};
onLoad.queue(function () {
$('.tm-ul > li').hover(
function () {
$(this).addClass('hover');
},
function () {
$(this).removeClass('hover');
}
);
MenuContent.init($('.content-tab-container').find('.tm-ul'));
add_click_effect_to_button();
make_mobile_menu();
// attach the class to account form's div/fieldset for CSS visual effects
var objFormEffect = new formEffects();
objFormEffect.set($('form.formObject'));
var i = window.location.href.split('#');
if (i.length != 2) return;
var o = document.getElementsByTagName('a');
for (var t = 0; t < o.length; t++) {
if (o[t].href.substr(o[t].href.length - i[1].length - 1) == '#' + i[1]) {
o[t].click();
break;
}
}
});
onLoad.queue(function () {
attach_date_picker('.has-date-picker');
attach_time_picker('.has-time-picker');
attach_inpage_popup('.has-inpage-popup');
attach_tabs('.has-tabs');
});