This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.extend($.Autocompleter.prototype, { | |
position: function() { | |
var offset = this.dom.$elem.offset(); | |
this.dom.$results.css({ | |
bottom: Plca.view.partials.$body.height() - offset.top, | |
left: offset.left | |
}); | |
}, | |
cloneFunc: function(func) { | |
var temp = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var suggest = target | |
.autocomplete({ | |
... | |
}) // Инициализируем у инпута автокомплит с набором параметров | |
.data('autocompleter'); // Сохраняем в переменную suggest объект автокомплита сохраненный в data атрибуте autocompleter за счет чейнинга | |
// Изменяем поведение метода position на нужное | |
suggest.position = function() { | |
var offset = this.dom.$elem.offset(); | |
this.dom.$results.css({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Универсальный обработчик события для transition | |
* | |
* @param {DOM Element} el DOM-элемент, к которому применяется css transition | |
* @param {function} callback Функция, вызываемая после выполнения css transition | |
* @param {boolean} isNoFallback По умолчанию в браузерах, не поддерживающих css transition, сразу выполняется | |
* функция callback(). Если isNoFallback равен true, callback() не выполняется для старых браузеров | |
* @param {string} property Название css-свойства, которое подвергается преобразованием (используется, если к DOM-элементу | |
* применяется несколько css transitions, а callback() вызывать несколько раз не нужно) | |
* @param {boolean} autoStartAfterTransition Если равен true, то callback() вызывается сразу, если над DOM-элементом |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Обработчик наведения курсора мыши на аватарку (плавное смещение фона при движении курсора мыши над аватаркой) | |
avatarHoverEvent: function(e) { | |
var $this = $(e.currentTarget), | |
offset = $this.offset(), | |
side = this.avatarsSide, | |
x = e.pageX - Math.floor(offset.left), | |
y = e.pageY - Math.floor(offset.top), | |
percentX = Math.round(x / side * 100), | |
percentY = Math.round(y / side * 100), | |
dataType = $this.attr('data-type'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mediator = (function(){ | |
var subscribe = function(channel, fn){ | |
if (!mediator.channels[channel]) mediator.channels[channel] = []; | |
mediator.channels[channel].push({ context: this, callback: fn }); | |
return this; | |
}, | |
publish = function(channel){ | |
if (!mediator.channels[channel]) return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
for (var j = 0; j < weekDays; j++) { | |
if (data.weekItem[j].Day == data.weekDays[i].Id) { | |
return true; | |
} | |
}; | |
return false; | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p362.tar.gz | |
tar -xvzf ruby-1.9.3-p362.tar.gz | |
cd ruby-1.9.3-p362/ | |
./configure --prefix=/usr/local | |
make | |
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- @posts # we are getting it from controlle | |
- @posts.each do |post| | |
.blog_post | |
.blog_post__title= post.title | |
.blog_post__meta_data | |
.blog_post__date= post.created_at | |
.blog_post__author= post.author.full_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.blog_post | |
font-size: 12px | |
line-height: 18px | |
.blog_post__title | |
font-size: 20px | |
line-height: 24px | |
.blog_post__meta_data | |
text-align: right |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- # in controller | |
- @posts_most_popular = Post.where('likes_count > ?', 100) | |
- @posts_most_commented = Post.where('comments_count > ?', 20) | |
- @posts_draft = Post.where(status: :draft) | |
- # in view | |
- if @posts_most_popular.any? | |
.posts_list.for-most_popular | |
.posts_list__title Most popular | |
- @posts_most_popular.each_with_index do |post, i| |
OlderNewer