<input :value="user.getAttribute('name')" @input="e => user.setAttribute('name', e.target.value)"/>
// age будет высчитывать возраст по birthday
Object.defineProperty(this, "age", {
get: function() {
var today = new Date();
var yearDelta = today.getFullYear() - this.birthday.getFullYear();
if (today.getMonth() > this.birthday.getMonth() ||
(today.getMonth() === this.birthday.getMonth() && today.getDate() >= this.birthday.getDate())) {
return yearDelta;
}
return yearDelta - 1;
}
});
var Car = (function(){
var speed, color, doors, pub;
function setSpeed(new_speed) {
speed = new_speed;
return pub;
}
function setColor(new_color) {
color = new_color;
return pub;
}
function setDoors(new_doors) {
doors = new_doors;
return pub;
}
pub = {
'setSpeed': setSpeed,
'setColor': setColor,
'setDoors': setDoors,
};
return pub;
})
// Обычная реализация
myCar2 = Car();
myCar2.setSpeed(100);
myCar2.setColor('blue');
myCar2.setDoors(5);
// Текучий интерфейс
myCar = Car();
myCar.setSpeed(100).setColor('blue').setDoors(5);
import qs from 'qs';
const data = { 'bar': 123 };
const options = {
method: 'POST',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
data: qs.stringify(data),
url,
};
axios(options);
$(document).ready(function () {
var $tabs = $('.s-services__tab_item');
$tabs.first().addClass('active');
$tabs.not('.active').hide();
$('.s-services__controls_item').on('click',function (e) {
e.preventDefault();
var tabItem = $(this).closest('.s-services__controls_item'),
tabContentItem = $('.s-services__tab_item'),
tabItemPosition = tabItem.data('services');
tabContentItem.filter('.s-services__tab_item-' + tabItemPosition)
.fadeIn()
.siblings()
.hide();
$(e.currentTarget)
.addClass('active')
.siblings()
.removeClass('active');
});
});
if (Yii::$app->getRequest()->getIsAjax()) {
if (Yii::$app->getRequest()->getHeaders()->get('X-Ie-Redirect-Compatibility') !== null && $statusCode === 302) {
// Ajax 302 redirect in IE does not work. Change status code to 200. See https://github.com/yiisoft/yii2/issues/9670
$statusCode = 200;
}
if (Yii::$app->getRequest()->getIsPjax()) {
$this->getHeaders()->set('X-Pjax-Url', $url);
} else {
$this->getHeaders()->set('X-Redirect', $url);
}
} else {
$this->getHeaders()->set('Location', $url);
}
$(document).ajaxComplete(function (event, xhr) {
var url = xhr && xhr.getResponseHeader('X-Redirect');
if (url) {
window.location.assign(url);
}
});
var loadScriptAsync = function(uri) {
return new Promise((resolve, reject) => {
var tag = document.createElement('script');
tag.src = uri;
tag.async = true;
tag.onload = () => {
resolve();
};
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
}
var scriptLoaded = loadScriptAsync('external-script.js');
scriptLoaded.then(function(){
//код для выполнения после загрузки внешнего скрипта
});
<button class="btn-filter" data-filter="foo1">.foo1</button>
<button class="btn-filter" data-filter="foo2">.foo2</button>
<button class="btn-filter" data-filter="foo3">.foo3</button>
<button class="btn-filter" data-filter="all">All</button>
$('.btn-filter').on('click', function (e) {
var $el = $(e.target);
var className = $el.data('filter');
if (className) { filter(className) }
});
var kids = $('#main-content').children().toArray();
function onSubmit () {
document.getElementById('osForm').style.display = 'none';
document.getElementById('form_one_success').style.display = 'block';
setTimeout(function () {
document.getElementById('form_one_success').style.display = 'none';
document.getElementById('osForm').style.display = 'block';
}, 5000);
}
var getUrlSha = function(url) {
return $.ajax({
type: 'GET',
url: 'sha1.php',
data: {
url: url
}
});
};
var getCommentsCount = function(url, sign) {
return $.ajax({
type: 'POST',
url: 'https://c1api.hypercomments.com/1.0/streams/get',
dataType: 'jsonp',
cache: false,
crossDomain: true,
data: {
body: '{"widget_id":11070,"link":"' + url + '"}',
signature: sign
}
});
};
function getSumComments(url) {
return getUrlSha(url).then(function(sign) {
return getCommentsCount(url, sign);
});
}
getSumComments('https://www.metrtv.ru/articles/second_estate/11617').then(function(count) {
console.log(count);
});