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
class App.Newsfeed.Layout | |
constructor: (@container, @views = [], @columnWidth = 393, @columnMargin = 16) -> | |
@columns = [] | |
render: -> | |
count = Math.max 1, Math.floor(@container.parent().width()/(@columnWidth + @columnMargin)) | |
return if count is @columns.length | |
@container.empty() |
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
app.factory 'Profile', ($resource) -> | |
$resource '/a/profile', {}, | |
update: | |
method: 'PATCH' | |
headers: {'Content-Type': undefined} | |
transformRequest: (resource) -> | |
formData = new FormData() | |
for key,value of resource | |
if resource.hasOwnProperty(key) and key[0] isnt '$' |
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
app.factory 'Resources', ($resource) -> | |
(pluralName, actions = {}) -> | |
actions['create'] ||= {method: 'POST'} | |
actions['update'] ||= {method: 'PATCH'} | |
Resources = $resource "/a/#{pluralName}/:id/:action", {id: '@id'}, actions | |
Resources.save = (object, success, failure) -> | |
failure ||= (object, errors) -> object.errors = errors |
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
# WidgetContainer | |
# top | |
# left | |
# width | |
# height | |
# kind | |
# holdable (polymorphic relation) | |
# attributes (hstore) | |
class Widget < ActiveRecord::Base |
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
module ApiException | |
class InvalidApiKey < StandardError | |
end | |
class InvalidApiVersion < StandardError | |
end | |
class InvalidAuthenticityToken < StandardError | |
end |
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
app.factory 'Resources', ($resource) -> | |
(pluralName, actions = {}) -> | |
actions['create'] ||= {method: 'POST'} | |
actions['update'] ||= {method: 'PATCH'} | |
Resources = $resource "/a/#{pluralName}/:id/:action", {id: '@id'}, actions | |
Resources.save = (object, success, failure) -> | |
failure ||= (object, errors) -> object.errors = errors |
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
# | |
# Render slim templates from asset pipeline with custom helpers | |
# Basically this is inlined slim_assets with minor modifications | |
# | |
# Research links: | |
# | |
# http://stackoverflow.com/questions/14946634/precompile-slim-templates-using-the-rails-asset-pipeline | |
# https://github.com/sstephenson/sprockets/issues/218 | |
# https://github.com/mattvague/slim_assets/blob/add_app_helpers/lib/slim_assets/slim_sprockets_engine.rb | |
# |
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
module TitleValidator | |
module_function | |
def call(object) | |
object.errors.add :title, :blank if object.title.blank | |
object | |
end | |
end |
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
module EventNotifier | |
extend self | |
delegate :register, :register_default, :execute, to: :instance | |
private | |
def instance | |
@instance ||= EventNotifier::Dispatcher.new | |
end |
OlderNewer