<script>
$(document).on('click', '#close_vid', function() {
jQuery("iframe").each(function() {
jQuery(this)[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*')
});
});
</script>
<script>
$(document).on('click', '#play_video', function() {
jQuery("iframe").each(function() {
jQuery(this)[0].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*')
});
});
</script>
<script>
function toggleVideo(state) {
// if state == 'hide', hide. Else: show video
var div = document.getElementById("popupVid");
var iframe = div.getElementsByTagName("iframe")[0].contentWindow;
div.style.display = state == 'hide' ? 'none' : '';
func = state == 'hide' ? 'pauseVideo' : 'playVideo';
iframe.postMessage('{"event":"command","func":"' + func + '","args":""}', '*');
}
</script>
<p><a href="javascript:;" onClick="toggleVideo();">Click here</a> to see my presenting showreel, to give you an idea of my style - usually described as authoritative, affable and and engaging.</p>
<!-- popup and contents -->
<div id="popupVid" style="position:absolute;left:0px;top:87px;width:500px;background-color:#D05F27;height:auto;display:none;z-index:200;">
<iframe width="500" height="315" src="http://www.youtube.com/embed/T39hYJAwR40?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
<br /><br />
<a href="javascript:;" onClick="toggleVideo('hide');">close</a>
<img src="path/to/image" alt="" draggable="false" />
.gradient {
background: linear-gradient(to left, rgba(1, 6, 17, 0.7) 10%, transparent 25%, transparent 75%, rgba(1, 6, 17, 0.7) 90%);
}
transform3d
на transform
)// ./services/api.js
import axios from 'axios';
// Проверим в самом начале, есть ли токен в хранилище
const JWTToken = localStorage.getItem('jwt');
// Создать инстанс axios
const api = axios.create({
baseURL: `${BASE_URL}/api`;
});
function apiSetHeader (name, value) {
if (value) {
api.defaults.headers[name] = value;
}
};
// Если токен есть, то добавим заголовок к запросам
if (JWTToken) {
apiSetHeader('Authorization', `Bearer ${JWTToken}`);
}
api.interceptors.request.use(config => {
// Если пользователь делает запрос и у него нет заголовка с токеном, то...
if (!config.defaults.headers['Authorization']) {
// Тут пишем редирект если не авторизован
}
return config;
}, error => {
return Promise.reject(error);
});
export default api;
export apiSetHeader
// ./services/sign-in.js
import api, { apiSetHeader } from './api'
export const authorize = async (username, password) => {
try {
const { data } = await api.post('/clients/token/', {
username,
password
});
localStorage.setItem('jwt', data.access);
apiSetHeader('Authorization', `Bearer ${data.access}`);
} catch (error) {
console.log(error);
}
};
function Popup(props) {
- <img onClick={props.close} />
+ <img onClick={() => props.close('передали')} />
}