Tagged Questions
CoffeeScript is a little language that compiles into JavaScript. Underneath all of those embarrassing braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.
2
votes
0answers
11 views
Automatically gravitate popover towards page center
I've authored a couple of plugins which show popovers on a given element. One of the objectives for both was no specification of plugin direction. So instead of the implementing dev having to specify ...
3
votes
0answers
45 views
+50
Create component with select+button
I'm new to ReactJs and trying to figure out the preferred style. I also have tried it enough to realize that I'm not a fan of jsx and prefer how React looks when written in coffeescript.
This is a ...
1
vote
1answer
23 views
Implementing a Simple “MoneyAccount” in CoffeeScript
Please critique this CoffeeScript code. Is it idiomatic?
...
3
votes
1answer
33 views
Set up event on class and initialize state [closed]
Very similar to this question, I'm curious about common patterns/best practices for handling events in coffeescript classes, particularly when you also need to call the event handlers immediately to ...
4
votes
2answers
61 views
Initializing events on class
I wrote a simple class that substitutes all file inputs in an HTML for a more complex template and set some actions on it. The code is rather small, but I'm not used to write JavaScript.
I wonder if ...
6
votes
2answers
88 views
Optimize CoffeeScript comparison function
I've wrote this CoffeScript function to compare values in a table, but it turned out to be a HUGE function.
Since the code is really really long, you can find it here as well.
Code explanation:
The ...
1
vote
1answer
63 views
Multiple search filter like the one in freshdesk in rails
I have requirement to apply multiple filters on database. So I am doing this now. I will have multiple conditions in the front end where the user can select the conditions he wants to filter with and ...
3
votes
0answers
72 views
Ruby on Rails text editor
I'm currently building a text editor using contenteditable and RoR back end. As the editor is WYSIWYG and trying to follow DRY, I used only one file to 3 actions: Show, Edit and New.
Edit and new ...
3
votes
1answer
45 views
Resize renderer on browser window size change
For a game, there is some WebGLRenderer object that wraps around canvas element. There is need to update it's size when browser window size changes. Here goes my current code written using BaconJS. ...
2
votes
1answer
33 views
Cleaner Way to Test for Types?
I defined a function that multiplies its argument by 3:
coffee> foo = (x) -> x * 3
[Function]
We can call it with an input of 1:
...
2
votes
0answers
412 views
An Object-Oriented Programming pattern for AngularJS models using CoffeeScript classes
Over the past week, we tried to make our AngularJS model layer more powerful and reduce complexity in our controllers and template by using the object-oriented programming pattern and the CoffeeScript ...
1
vote
2answers
118 views
Writing binding providers in CoffeeScript?
In his KnockoutJs 1.3 beta post, Steve Sanderson has an example of using Binding providers ("5. Binding providers (and hence external bindings)") where he makes a comment in the JSFiddle JavaScript ...
5
votes
1answer
120 views
4
votes
1answer
197 views
Searching an object tree structure
I have this recursive function that searches an object tree structure:
...
0
votes
1answer
56 views
Promises and chained calls
I've realized JS callback hell and I started looking into Promises libraries.
After reading some articles I decided to start with BluebirdJS. I didn't realise how to properly use them yet, because ...
4
votes
2answers
151 views
isRTL.coffee - A JavaScript Library to determine if a text is of Right To Left direction
I just wrote this tiny library called isRTL.coffee to determine the direction of the text. Is there any better way of doing this?
original code:
...
7
votes
5answers
337 views
Avoiding nested conditionals and comparing strings
I have a web page with a set of icons that are grey by default:
If a user clicks one, it toggles green (.toggleClass('green')):
If a user clicks a green one, ...
1
vote
1answer
37 views
Remove nodejs/browser specific code in library
I'm the maintainer of the following library on github: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxgen.coffee
I want to maintain a library that works on node and in the browser, ...
10
votes
1answer
131 views
Tabbed navigation to hide and show pages
I'm new to jQuery and trying to learn how to refactor my bloated code to make it nicer and better maintainable.
I have a tabbed navigation which I'm using jQuery to hide and show pages depending on ...
2
votes
1answer
633 views
A library written in CoffeeScript
So, I wrote this small library for fast DOM building with API tailored for CoffeeScript
I feel like the code overall can be made better/smaller/faster.
I am also not particularly happy about a few ...
8
votes
1answer
140 views
4
votes
1answer
45 views
1
vote
1answer
198 views
0
votes
1answer
116 views
Count non-transparent pixels in a canvas
I need to count non-transparent pixels in a canvas. I am pretty sure there is a nice and elegant syntax for doing this. Note that the data returned by getImageData ...
0
votes
0answers
64 views
Currying options for Bootstrap components for use in Meteor
Bootstrap 3 helper (redacted) for displaying alerts.
...
0
votes
0answers
30 views
Saving on a Backbone Collection
I am currently building a backbone view where there is a mutli select feature. Once the user selects all the records, the user hits the submit and sends all the updated models. How does this mass ...
0
votes
0answers
64 views
Improvements to my binary tree written in CoffeeScript
This is my attempt at a binary tree. I'm using it only for ordering a LDAP user list. My need is for storing multiple objects, so this tree is limited to leaves that are objects (see ...
5
votes
1answer
327 views
Project Euler question 2 in CoffeeScript
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
...
3
votes
2answers
124 views
Fibonacci using cache
This is my simple Fibonacci implementation in CoffeeScript. What do you think? Using cache (fibResults), it's very very fast.
...
2
votes
0answers
88 views
node.js Review Core class of a Javascript framework for SPA's
A few years ago I started building a tiny (~300 SLOC) JavaScript framework for scalable and maintainable Single-Page-Applications written in CoffeeScript:
https://github.com/flosse/scaleApp and ...
2
votes
1answer
75 views
Backbone subviews with non-uniform layout
I have a “featured projects” view that requires its subviews conform to a non-uniform grid: one narrow column with 3 items, then one wide column with 2 items, followed by another narrow column with 3 ...
3
votes
1answer
91 views
How to refactor this series of JavaScript promises?
This is part of a class for paginating a Backbone collection.
The paginateTo method is for paginating to a model id. It returns the model if it's already in the ...
-1
votes
1answer
226 views
How to improve or refactor Backbone CoffeeScript code?
how can I improve the following code mainly regarding the router, when to initialize the and fetch the collection and how I can filter the models?=
Thank you
...
3
votes
2answers
74 views
How can I remove DRY violations from this event handling code?
I've got a bunch of event handlers that follow this pattern:
...
0
votes
1answer
318 views
Express, blade with connect-assets
I have this CoffeeScript code running here (with TZM-Blade) and would like to have your opinion on how to better optimize it.
...
2
votes
1answer
504 views
PageObject implementation (CoffeeScript, CasperJS)
I'm using CasperJS and CoffeeScript for integration testing of a hobby project. Page Objects seem to be a useful abstraction. I had two major requirements:
Support for node.js style callbacks - ...
2
votes
1answer
259 views
Object Wrapper/Parameter Injection Module for CoffeeScript/JavaScript
I made an object wrapper/parameter injector and I hope it will be useful, I made it for a project I am working on but then decided to try polishing it a bit.
The use case is for wrapping objects such ...
1
vote
0answers
274 views
Handling multiple Mongodb connections in Node.js (using Mongolia)
I have a situation where I have multiple objects that each needs to connect to a different mongodb uri.
I am currently testing this using mongolia but the concept should be the same if I were to use ...
1
vote
3answers
217 views
Cleanest way to close over a counter in CoffeeScript
I haven't spent too much time with CoffeeScript and am trying to have a simple counter:
...
3
votes
2answers
573 views
0
votes
1answer
100 views
1
vote
1answer
142 views
CoffeeScript: multiple changes of scope and big if/else
I just wrote this, and cleaned it up as much as I could. A couple things worry me.
I change the scope of $(this) twice (and apparently don't know how to use ...
2
votes
1answer
226 views
Coffeescript Operators: use &&, ||, etc., or keyword operators?
I often use js2coffee.heroku.com to help me convert JS to CoffeeScript. Here was a line of JS I was converting.
...
2
votes
3answers
1k views
Function Is target String found in an Array of Strings in CoffeeScript
I wrote this simple function in CoffeeScript to see if elements are found in an array.
...
-1
votes
1answer
1k views
Coffeescript nested if's
y = (if @projectionStyle is 'flat' then 0 else
if d3.event.y < -90
-90
else if d3.event.y > 90
90
else d3.event.y)
This is working now, but I ...
1
vote
1answer
471 views
coffeescript and angular directive
I feel this is deeply inelegant, but I really want the option of classical inheritance in the future. How could this be written better. FYI animation here is from GSAP if you are curious.
...
1
vote
1answer
338 views
JQuery Dynamic Dropdown Update
This is based (somewhat loosely) on the code written in this railscast. I'm planning to re-use it in different places throughout the site, so I made it a bit more generic rather than based on IDs. ...
3
votes
2answers
247 views
Passing Context in CoffeeScript
I'm trying to migrate from JavaScript to CoffeeScript. However I'm not sure about the best way to optimize the code generated by js2coffee.
Below is the original JavaScript source :
...
2
votes
1answer
112 views
Assign local-variables in constructor
How to make this code in constructor more DRY?
Is there some more concise way to assign variables passed through object?
...
4
votes
3answers
142 views