.header
height 60px
background #000
&--fixed
position fixed
left 0
top 0
$(window).scroll(function() {
var container = $('.header');
var status = $(this).offsetTop >= container.height() ? true : false;
container.toggleClass('.header--fixed', status);
});
<?php
namespace backend\models;
use Yii;
use backend\models\Model;
use backend\filters\Filter;
class MySuperModel extends Model
{
public $name;
public $other = [];
public function rules()
{
return [
[['name','other'], 'required'],
['other', 'checkOther'],
];
}
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
];
}
public function onUnsafeAttribute($name, $value)
{
if( ! strpos('other_', $name) ) {
list($other, $name) = explode('_', $name);
$this->other[$name] = $value;
}
}
public function checkOther(string $attribute)
{
if( ! is_array($this->$attribute) ) {
return false;
}
$errors = [];
foreach( $this->$attribute as $name => $value ) {
$filter = Filter::run($this->site_id, $name, $value);
$name = 'other_' . $name;
if( ! $filter ) {
$errors[$name] = Yii::t('messages', 'Field does not exist');
continue;
}
}
if( !empty($errors) ) {
return $this->addErrors($errors);
}
return true;
}
}
<div class="example">
<div class="operate"></div>
<div class="line_one"></div>
<div class="line_two"></div>
<div class="result"></div>
</div>
.example {
position: relative;
width: 50px;
height: 200px;
text-align: right;
}
.example .operate {
position: absolute;
left: 0;
top: 10px;
}
.example .line_two {
border-bottom: 1px solid #000;
}
calculator(246, 154, '+');
function calculator(one, two, operate) {
var container = $('.example');
container.find('.operate').text(operate);
container.find('.line_one').text(one);
container.find('.line_two').text(two);
container.find('.result').text(eval(one + operate + two));
}
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
</IfModule>
<form action="#" method="post" class="example">
<div>
<label for="one">Тестовое поле 1</label>
<input type="text" id="one" name="params[name1][value]" value="example 1">
</div>
<div>
<label for="two">Тестовое поле 2</label>
<input type="text" id="two" name="params[name2][value]" value="example 2">
</div>
<input type="submit" value="отправить">
</form>
var form = $('.example');
form.find('input[type="text"]').each(function(i, data) {
var label = $(this).parent().find('label').text();
var name = $(this).attr('name').split('][')[0] + '][label]';
$(this).parent().append('<input type="hidden" name="'+name+'" value="'+label+'">');
});
$_POST['params'][name0..n] {
"label",
"value"
}
https://www.facebook.com/USERNAME/posts/POST_ID
/2.7/POST_ID?fields=from,message,start_time
<section id="content">
<h2 class="section-title">Заголовок</h2>
</section>
@import url(http://allfont.ru/allfont.css?fonts=pragmatica-cyrillic);
section {
.section-title {
font-family: 'Pragmatica Cyrillic', Tahoma;
height 55px;
background #fff;
text-align center;
text-transform uppercase;
line-height 60px;
margin 26px 0;
}
}