-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.js
142 lines (121 loc) · 4.17 KB
/
common.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
// force no cache of POST requests (iOS6)
// http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results
// ------------------------------------------------------------------------------
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
if (!originalOptions.type || originalOptions.type.toUpperCase() !== 'POST') return;
var now = new Date().getTime();
if (typeof originalOptions.data === 'string') {
options.data = originalOptions.data + (originalOptions.data.length ? '&' : '') + '_ts=' + now;
} else {
options.data = jQuery.param($.extend(originalOptions.data || {}, {
_ts: now
}));
}
});
// facebook sdk
// ------------------------------------------------------------------------------
window._fb = (function() {
var init = false;
// init callback
window.fbAsyncInit = function() {
FB.init({
appId : DIY.globals.services.facebook['app-id'],
channelUrl : '//' + window.location.hostname + '/channel.html',
status : !!(DIY.session && DIY.session.parent),
cookie : false,
xfbml : true
});
init = true;
while (callbacks.length) {
callbacks.pop()();
}
};
// include facebook sdk
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// interface
var callbacks = [];
return function(callback) {
if (init) callback();
else callbacks.push(callback);
};
})();
_fb(function() {
FB.Event.subscribe('auth.statusChange', function(response) {
var linked = response.status === 'connected';
$(document.documentElement)
.toggleClass('fbauth', linked)
.toggleClass('no-fbauth', !linked);
});
});
// video player settings
// ------------------------------------------------------------------------------
if (typeof _V_ !== 'undefined') {
_V_.options.flash.swf = DIY.globals['static'] + '/video-js.swf';
}
// other
// ------------------------------------------------------------------------------
/**
* Displays a popup window centered in the browsers.
* @param {object} options - Window options.
*/
var popup = function(options) {
var $window = $(window);
var w = options.width || 400;
var h = options.height || 300;
var top = (window.screenY || window.screenTop) + Math.round(($window.height() - h) / 2);
var left = (window.screenX || window.screenLeft) + Math.round(($window.width() - w) / 2);
window.open(options.url, options.name || '',
'scrollbars=no,menubar=no,resizable=yes,toolbar=no,location=no,status=yes,' +
'left=' + left + ',' +
'top=' + top + ',' +
'width=' + w + ',' +
'height=' + h
).focus();
return false;
};
$(function() {
"use strict";
var $window = $(window);
var $body = $('body');
/**
* Pinned Footer
*/
var footerHeight = 0;
var footerTop = 0;
var $footer = $('.pinned-footer');
if ($footer.length) {
var resetFooter = function() {
footerHeight = $footer.outerHeight();
if ($body.height() > $window.height()) {
$footer.css({
position: 'absolute',
top: $body.height() - footerHeight,
bottom: 'auto'
});
} else {
$footer.css({
position: 'fixed',
top: 'auto',
bottom: '0'
});
}
};
$window.on('load', function() {
resetFooter();
window.setTimeout(function() {
resetFooter();
}, 50);
});
$window.on('scroll resize', resetFooter);
$window.bind('resetfooter', resetFooter);
resetFooter();
}
});