Skip to content

Instantly share code, notes, and snippets.

View igkuz's full-sized avatar

Igor Kuznetsov igkuz

  • Antalya, Turkey
View GitHub Profile
var Comments = Backbone.Collection.extend({
url: function() {
return this.baseUrl + '/comments';
},
initialize: function(bootstrapData, options) {
this.baseUrl = options.baseUrl;
}
}),
Posts = Backbone.Collection.extend({
def category_channels_unfocus(params)
if params[:side]== :down
@current_category += 1 if @current_category < @categories.count - 1
if @categories[@current_category].expanded
@categories[@current_category].activate_current_channel
focus_on @categories[@current_category]
else
@categories[@current_category].activate
app.statechart.send_action(:fill_channels, @category_list[@current_category])
focus_on self
def choose_category
@categories_menu.truncate
@channel_cat_rb_corner.props.top += @categories_menu.layout.dynamic_height
@channel_cat_lb_corner.props.top += @categories_menu.layout.dynamic_height
@categories = []
@category_list.each_with_index do |category, idx|
if idx == @current_category && category.children.count > 0
@categories << @categories_menu.view(Telemarker::Views::Panel::Channels::CategoryItem, category: category, expanded: true, categories_menu_height: @categories_menu_height) if category.channels_count
@categories[@categories.count - 1].activate_current_channel
focus_on @categories[@categories.count - 1]
@igkuz
igkuz / base.rb
Last active December 17, 2015 13:39
@corner_group.props.rotation = [ { "z-axis" => [ 0.0, [ 960, 540 ] ] } ]
add_timer(0.1) do
@logo_start.animate(duration: 800, opacity: 0).on_complete do
@corner_lt.animate(duration: 700, left: 850, top: 427)
@corner_rt.animate(duration: 700, right: 792, top: 427)
@corner_lb.animate(duration: 700, left: 850, bottom: 370)
@corner_rb.animate(duration: 700, right: 792, bottom: 370).on_complete do
@corner_group.animate(duration: 800, rotation_angle_z: -180.0).on_complete do
@corner_lt.animate(duration: 700, left: 25, top: 27)
@corner_rt.animate(duration: 700, right: -33, top: 27)
@igkuz
igkuz / base_spec.rb
Last active December 17, 2015 14:39
describe Telemarker::Aplplication do
include_context :telemarker_app
let(:channels_api_controller) { app.controller('api/controller') }
let(:channels_view) { app.view('channels') }
describe "Channels View Controller" do
it "should get all channels" do
channels_controller = Telemarker::Controllers::View::VideosController.new(channels_view, channels_api_controller)
@igkuz
igkuz / gist:5626137
Last active December 17, 2015 14:39
class View::ChannelsController < CS::Base::Controller
def initialize(view, api_controller)
@view = view
@api_controller = api_controller
end
def show_channels_list
api_controller.all_channels.on_complete do |models|
@view.show_channels(models)
class Api::ChannelsController < CS::Base::Controller
def all_channels
SFK::Http.get(channels_url, options).transform do |data|
parse_data(models)
end
end
def parse_data(data)
models = []
@igkuz
igkuz / 1.rb
Last active December 17, 2015 14:39
describe "Channels Api Controller" do
it "should get all channels from api" do
stub_requested = stub_request(:get, channels_api_url).
with(body: { credentials: credentials }).
to_return(status: 200, body: load_fixture('channels.json'), headers: {})
channels_api_controller = app.controller('api/channels_controller')
channels_api_controller.all_channels.on_complete do |models|
class Channel
include Virtus
atribute :id, Integer
attribute :name, String
end
@igkuz
igkuz / 1.rb
Last active December 17, 2015 14:39
class Channels < Clutter::Group
dsl do |o|
# some markup here
end
def show_channels(channels)
# some actions with dom here
end
end