var mainSlideWordWrap = function() {
// Переберём все блоки контента и обернём слова в span
$('.mainSlideContent').each(function() {
var result = $(this).html().replace(/[\wа-яё]+/gim, function(s) {
return s === "br" ? s : "<span>" + s + "</span>"
});
console.log('<span class="mainSlideWordWrap">'+ result + '</span>');
});
};
mainSlideWordWrap();
<Button onClick = {openModal.bind(null, p.id)}>Drop</Button>
// actions/pageChoice.js
export function openModal(dropId){
return {type:'OPEN_DROP_MODAL', dropId}
}
// reducers/pageChoice.js
case 'OPEN_DROP_MODAL':
return {
...state,
dropId: action.dropId,
modalOpen:true
}
break;
<form onSubmit={this.handleSubmitTest}>
//Мы задаем один и тот же стейт на открытие фрагмента формы и на required,
//соответственно если форма открыта, то и поле необходимо
<Input type="checkbox" onChange={()=>this.setState({check: !this.state.check})}/>
<Input type="text" placeholder="Enter UR Number" required={this.state.check}/>
<ButtonInput type="submit" value="Submit Button"/>
</form>
<img id="bannerImg" class="image" crossOrigin="*" src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Proton-K-Zarya.jpg/800px-Proton-K-Zarya.jpg" />
<img id="tableBanner" class="image" crossOrigin="*" src="https://upload.wikimedia.org/wikipedia/commons/e/e8/Richard_of_Shrewsbury%2C_1._Duke_of_York.jpg?download" />
var images = document.querySelectorAll('.image');
if (images.length > 0) {
// в Storage
var dataArray = [];
for (var i = 0, itemsLength = images.length; i < itemsLength; i++) {
dataArray.push({
img: getBase64Image(images[i]),
id: images[i].id || ''
});
}
localStorage.setItem("imagesData", JSON.stringify(dataArray));
//из Storage
var storageArray = JSON.parse(localStorage.getItem('imagesData'));
if (Array.isArray(storageArray)) {
storageArray.map(function (dataImage) {
var element = document.getElementById(dataImage.id);
if (element) {
element.src = "data:image/png;base64," + dataImage.img;
}
});
}
}
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
onClick(data) {
rest.post("url to backend", {data})
.then((response) = > {
setTimeout(() = > {
AppDispatcher.dispatch({
actionType: AppConstants.INTERESTED_1,
data: response.data
});
}, 0);
setTimeout(() = > {
AppDispatcher.dispatch({
actionType: AppConstants.INTERESTED_2,
data: response.data
});
}, 0);
setTimeout(() = > {
AppDispatcher.dispatch({
actionType: AppConstants.INTERESTED_3,
data: response.data
});
}, 0);
})
.catch(() => {
AppDispatcher.dispatch({
actionType: AppConstants.SERVER_ERROR
});
});
}
<p>Дата изготовления: {{product.data | dateMark : product.termin}} </p>
productApp.filter('dateMark', function(){
return function(srok, TERMIN){
var nowDate = new Date;
if (nowDate < ( Date.parse(srok)* (86400 * TERMIN) ){
return 'Круто';
} else if (nowDate > Date.parse(srok))
return 'НЕ круто';
else return 'Ошибка';
}
});