id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
buttercoin/buttercoin:test/test_journal.coffee:1:raw_corpus | raw_corpus | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
logger = require('../lib/logger')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach... | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 60128172e99e262c89bca29af515ad6d1080332f | 663 | https://github.com/buttercoin/buttercoin/blob/60128172e99e262c89bca29af515ad6d1080332f/test/test_journal.coffee | 1 | 50 | ||
buttercoin/buttercoin:test/test_journal.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
logger = require('../lib/logger')
kTestF... | var Journal, Ops, Q, TestHelper, assert, chai, expect, fs, kTestFilename, logger;
chai = require('chai');
chai.should();
expect = chai.expect;
assert = chai.assert;
Q = require('q');
fs = require('fs');
Journal = require('../lib/journal');
Ops = require('../lib/operations');
TestHelper = require('./test_helper... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 60128172e99e262c89bca29af515ad6d1080332f | 663 | https://github.com/buttercoin/buttercoin/blob/60128172e99e262c89bca29af515ad6d1080332f/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Journal, Ops, Q, TestHelper, assert, chai, expect, fs, kTestFilename, logger;
chai = require('chai');
chai.should();
expect = chai.expect;
assert = chai.assert;
Q = require('q');
fs = require('fs');
Journal = require('../lib/journal');
Ops = require('..... | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
logger = require('../lib/logger')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 60128172e99e262c89bca29af515ad6d1080332f | 663 | https://github.com/buttercoin/buttercoin/blob/60128172e99e262c89bca29af515ad6d1080332f/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:completion | completion | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
logger = require('../lib/logger')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach... | console.log 'EXECUTE OP', op
).then =>
console.log 'FINISHED'
assert journal.filename is kTestFilename
journal.shutdown().then =>
finish()
.done()
it 'should initialize if the log file already exists', (finish) ->
logger.info('test journal')
journal = new Journal( kTestFilen... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 60128172e99e262c89bca29af515ad6d1080332f | 663 | https://github.com/buttercoin/buttercoin/blob/60128172e99e262c89bca29af515ad6d1080332f/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:raw_corpus | raw_corpus | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach =>
TestHelper.clean_state_sync
... | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | fff4935d554f9e1afeab404570654c3102cb790a | 663 | https://github.com/buttercoin/buttercoin/blob/fff4935d554f9e1afeab404570654c3102cb790a/test/test_journal.coffee | 1 | 50 | ||
buttercoin/buttercoin:test/test_journal.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Jou... | var Journal, Ops, Q, TestHelper, assert, chai, expect, fs, kTestFilename;
chai = require('chai');
chai.should();
expect = chai.expect;
assert = chai.assert;
Q = require('q');
fs = require('fs');
Journal = require('../lib/journal');
Ops = require('../lib/operations');
TestHelper = require('./test_helper');
kTe... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | fff4935d554f9e1afeab404570654c3102cb790a | 663 | https://github.com/buttercoin/buttercoin/blob/fff4935d554f9e1afeab404570654c3102cb790a/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Journal, Ops, Q, TestHelper, assert, chai, expect, fs, kTestFilename;
chai = require('chai');
chai.should();
expect = chai.expect;
assert = chai.assert;
Q = require('q');
fs = require('fs');
Journal = require('../lib/journal');
Ops = require('../lib/ope... | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach =>
TestHelper.clean_state_sync
... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | fff4935d554f9e1afeab404570654c3102cb790a | 663 | https://github.com/buttercoin/buttercoin/blob/fff4935d554f9e1afeab404570654c3102cb790a/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:completion | completion | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach =>
TestHelper.clean_state_sync
... | assert journal.filename is kTestFilename
# journal.shutdown()
finish()
.done()
it 'should initialize if the log file already exists', (finish) ->
journal = new Journal( kTestFilename )
journal.start((op) =>
console.log 'EXECUTE OP', op
).then =>
assert journal.filename is kTes... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | fff4935d554f9e1afeab404570654c3102cb790a | 663 | https://github.com/buttercoin/buttercoin/blob/fff4935d554f9e1afeab404570654c3102cb790a/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:2:raw_corpus | raw_corpus | raw_msg = [ Ops.ADD_DEPOSIT, "fake" ]
msg = JSON.stringify(raw_msg)
journal.record msg
.then =>
journal.flush
journal.shutdown
assert fs.existsSync kTestFilename
finish()
.done() | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | fff4935d554f9e1afeab404570654c3102cb790a | 663 | https://github.com/buttercoin/buttercoin/blob/fff4935d554f9e1afeab404570654c3102cb790a/test/test_journal.coffee | 51 | 59 | ||
buttercoin/buttercoin:test/test_journal.coffee:2:completion | completion | raw_msg = [ Ops.ADD_DEPOSIT, "fake" ]
msg = JSON.stringify(raw_msg)
journal.record msg
.then => | journal.flush
journal.shutdown
assert fs.existsSync kTestFilename
finish()
.done() | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | fff4935d554f9e1afeab404570654c3102cb790a | 663 | https://github.com/buttercoin/buttercoin/blob/fff4935d554f9e1afeab404570654c3102cb790a/test/test_journal.coffee | 51 | 59 |
buttercoin/buttercoin:test/test_journal.coffee:1:raw_corpus | raw_corpus | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach =>
TestHelper.clean_state_sync
... | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 1f186911398a725c15be4770d1a60bffb6454c4e | 663 | https://github.com/buttercoin/buttercoin/blob/1f186911398a725c15be4770d1a60bffb6454c4e/test/test_journal.coffee | 1 | 50 | ||
buttercoin/buttercoin:test/test_journal.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Jou... | var Journal, Ops, Q, TestHelper, assert, chai, expect, fs, kTestFilename;
chai = require('chai');
chai.should();
expect = chai.expect;
assert = chai.assert;
Q = require('q');
fs = require('fs');
Journal = require('../lib/journal');
Ops = require('../lib/operations');
TestHelper = require('./test_helper');
kTe... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 1f186911398a725c15be4770d1a60bffb6454c4e | 663 | https://github.com/buttercoin/buttercoin/blob/1f186911398a725c15be4770d1a60bffb6454c4e/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Journal, Ops, Q, TestHelper, assert, chai, expect, fs, kTestFilename;
chai = require('chai');
chai.should();
expect = chai.expect;
assert = chai.assert;
Q = require('q');
fs = require('fs');
Journal = require('../lib/journal');
Ops = require('../lib/ope... | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach =>
TestHelper.clean_state_sync
... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 1f186911398a725c15be4770d1a60bffb6454c4e | 663 | https://github.com/buttercoin/buttercoin/blob/1f186911398a725c15be4770d1a60bffb6454c4e/test/test_journal.coffee | 1 | 50 |
buttercoin/buttercoin:test/test_journal.coffee:1:completion | completion | chai = require 'chai'
chai.should()
expect = chai.expect
assert = chai.assert
Q = require('q')
fs = require 'fs'
Journal = require '../lib/journal'
Ops = require '../lib/operations'
TestHelper = require('./test_helper')
kTestFilename = 'test.log'
describe 'Journal', ->
beforeEach =>
TestHelper.clean_state_sync
... | assert journal.filename is kTestFilename
# journal.shutdown()
finish()
.done()
it 'should initialize if the log file already exists', (finish) ->
journal = new Journal( kTestFilename )
journal.start((op) =>
console.log 'EXECUTE OP', op
).then =>
assert journal.filename is kTes... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/test_journal.coffee | MIT | 1f186911398a725c15be4770d1a60bffb6454c4e | 663 | https://github.com/buttercoin/buttercoin/blob/1f186911398a725c15be4770d1a60bffb6454c4e/test/test_journal.coffee | 1 | 50 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:1:raw_corpus | raw_corpus | module.exports = favoriteController = app.controller 'favorite', ->
@mixin require './mixins/permission'
@ratelimit '60 300', only: 'search'
@ensure '_messageId', only: 'create'
@ensure '_teamId', only: 'read search'
@ensure '_favoriteIds', only: 'batchRemove reposts'
@before 'creatableFavorite', only: ... | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 17 | 66 | ||
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = favoriteController = app.controller 'favorite', ->
@mixin require './mixins/permission'
@ratelimit '60 300', only: 'search'
@ensure '_messageId', only: 'create'
@ensure '_teamId', only: 'read search'
@ensure '_favoriteIds', only: 'ba... | var favoriteController;
module.exports = favoriteController = app.controller('favorite', function() {
this.mixin(require('./mixins/permission'));
this.ratelimit('60 300', {
only: 'search'
});
this.ensure('_messageId', {
only: 'create'
});
this.ensure('_teamId', {
only: 'read search'
});
thi... | CoffeeScript | JavaScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 17 | 66 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var favoriteController;
module.exports = favoriteController = app.controller('favorite', function() {
this.mixin(require('./mixins/permission'));
this.ratelimit('60 300', {
only: 'search'
});
this.ensure('_messageId', {
only: 'create'
});
this.... | module.exports = favoriteController = app.controller 'favorite', ->
@mixin require './mixins/permission'
@ratelimit '60 300', only: 'search'
@ensure '_messageId', only: 'create'
@ensure '_teamId', only: 'read search'
@ensure '_favoriteIds', only: 'batchRemove reposts'
@before 'creatableFavorite', only: ... | JavaScript | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 17 | 66 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:1:completion | completion | module.exports = favoriteController = app.controller 'favorite', ->
@mixin require './mixins/permission'
@ratelimit '60 300', only: 'search'
@ensure '_messageId', only: 'create'
@ensure '_teamId', only: 'read search'
@ensure '_favoriteIds', only: 'batchRemove reposts'
@before 'creatableFavorite', only: ... | _messageId = message._id
_favorite = _.omit message.toJSON(), '_id'
if favorite
favorite.favoritedAt = new Date
else
favorite = new FavoriteModel
favoritedBy: _sessionUserId
favoritedAt: new Date
message: _messageId
Object.keys(_favorite).forEach (k... | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 17 | 66 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:2:raw_corpus | raw_corpus | @action 'remove', (req, res, callback) ->
{_id, favorite, _sessionUserId} = req.get()
favorite.remove (err, favorite) ->
return callback(err) if err
callback err, favorite
res.broadcast "user:#{_sessionUserId}", "favorite:remove", favorite
@action 'batchRemove', (req, res, callback) ->
... | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 67 | 116 | ||
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@action 'remove', (req, res, callback) ->
{_id, favorite, _sessionUserId} = req.get()
favorite.remove (err, favorite) ->
return callback(err) if err
callback err, favorite
res.broadcast "user:#{_sessionUserId}", "favorite:remove", favori... | this.action('remove', function(req, res, callback) {
var _id, _sessionUserId, favorite;
({_id, favorite, _sessionUserId} = req.get());
return favorite.remove(function(err, favorite) {
if (err) {
return callback(err);
}
callback(err, favorite);
return res.broadcast(`user:${_sessionUserId}`, "... | CoffeeScript | JavaScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 67 | 116 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.action('remove', function(req, res, callback) {
var _id, _sessionUserId, favorite;
({_id, favorite, _sessionUserId} = req.get());
return favorite.remove(function(err, favorite) {
if (err) {
return callback(err);
}
callback(err, favorite... | @action 'remove', (req, res, callback) ->
{_id, favorite, _sessionUserId} = req.get()
favorite.remove (err, favorite) ->
return callback(err) if err
callback err, favorite
res.broadcast "user:#{_sessionUserId}", "favorite:remove", favorite
@action 'batchRemove', (req, res, callback) ->
... | JavaScript | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 67 | 116 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:2:completion | completion | @action 'remove', (req, res, callback) ->
{_id, favorite, _sessionUserId} = req.get()
favorite.remove (err, favorite) ->
return callback(err) if err
callback err, favorite
res.broadcast "user:#{_sessionUserId}", "favorite:remove", favorite
@action 'batchRemove', (req, res, callback) ->
... | @action 'repost', (req, res, callback) ->
{_id, favorite, _sessionUserId, _roomId, _teamId, _toId, _storyId} = req.get()
_message = favorite.toObject virtuals: false, getters: false
_message = _.pick _message, [
'body'
'authorName'
'authorAvatarUrl'
'attachments'
'isSystem'
... | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 67 | 116 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:3:raw_corpus | raw_corpus | @action 'reposts', (req, res, callback) ->
{_id, favorites, _roomId, _teamId, _toId, _sessionUserId, _storyId} = req.get()
async.map favorites, (favorite, next) ->
_message = favorite.toObject virtuals: false, getters: false
_message = _.pick _message, [
'body'
'authorName'
'... | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 117 | 144 | ||
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@action 'reposts', (req, res, callback) ->
{_id, favorites, _roomId, _teamId, _toId, _sessionUserId, _storyId} = req.get()
async.map favorites, (favorite, next) ->
_message = favorite.toObject virtuals: false, getters: false
_message = _.pick ... | this.action('reposts', function(req, res, callback) {
var _id, _roomId, _sessionUserId, _storyId, _teamId, _toId, favorites;
({_id, favorites, _roomId, _teamId, _toId, _sessionUserId, _storyId} = req.get());
return async.map(favorites, function(favorite, next) {
var _message, repost;
_message = favorite.t... | CoffeeScript | JavaScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 117 | 144 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.action('reposts', function(req, res, callback) {
var _id, _roomId, _sessionUserId, _storyId, _teamId, _toId, favorites;
({_id, favorites, _roomId, _teamId, _toId, _sessionUserId, _storyId} = req.get());
return async.map(favorites, function(favorite, next... | @action 'reposts', (req, res, callback) ->
{_id, favorites, _roomId, _teamId, _toId, _sessionUserId, _storyId} = req.get()
async.map favorites, (favorite, next) ->
_message = favorite.toObject virtuals: false, getters: false
_message = _.pick _message, [
'body'
'authorName'
'... | JavaScript | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 117 | 144 |
jianliaoim/talk-os:talk-api2x/server/controllers/favorite.coffee:3:completion | completion | @action 'reposts', (req, res, callback) ->
{_id, favorites, _roomId, _teamId, _toId, _sessionUserId, _storyId} = req.get()
async.map favorites, (favorite, next) ->
_message = favorite.toObject virtuals: false, getters: false
_message = _.pick _message, [
'body'
'authorName'
'... | repost = new MessageModel _message
repost.creator = _sessionUserId
repost.team = _teamId
if _roomId
repost.room = _roomId
else if _toId
repost.to = _toId
else if _storyId
repost.story = _storyId
else return callback(new Err('PARAMS_MISSING', '_roomId', '_toId'... | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-api2x/server/controllers/favorite.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/controllers/favorite.coffee | 117 | 144 |
jianliaoim/talk-os:talk-web/test/spec/actions/search.spec.coffee:1:raw_corpus | raw_corpus | xdescribe 'Actions: search', ->
beforeEach ->
@action = require 'actions/search'
@api = require 'network/api'
describe 'Method: query', ->
it 'should call api', ->
spyOn(@api.messages.search, 'get').and.callThrough()
teamId = 1
q = 'query string'
page = 2
config =
... | CoffeeScript | jianliaoim/talk-os | talk-web/test/spec/actions/search.spec.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/test/spec/actions/search.spec.coffee | 1 | 50 | ||
jianliaoim/talk-os:talk-web/test/spec/actions/search.spec.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
xdescribe 'Actions: search', ->
beforeEach ->
@action = require 'actions/search'
@api = require 'network/api'
describe 'Method: query', ->
it 'should call api', ->
spyOn(@api.messages.search, 'get').and.callThrough()
teamId = 1
... | xdescribe('Actions: search', function() {
beforeEach(function() {
this.action = require('actions/search');
return this.api = require('network/api');
});
describe('Method: query', function() {
return it('should call api', function() {
var config, page, q, teamId;
spyOn(this.api.messages.sea... | CoffeeScript | JavaScript | jianliaoim/talk-os | talk-web/test/spec/actions/search.spec.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/test/spec/actions/search.spec.coffee | 1 | 50 |
jianliaoim/talk-os:talk-web/test/spec/actions/search.spec.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
xdescribe('Actions: search', function() {
beforeEach(function() {
this.action = require('actions/search');
return this.api = require('network/api');
});
describe('Method: query', function() {
return it('should call api', function() {
var con... | xdescribe 'Actions: search', ->
beforeEach ->
@action = require 'actions/search'
@api = require 'network/api'
describe 'Method: query', ->
it 'should call api', ->
spyOn(@api.messages.search, 'get').and.callThrough()
teamId = 1
q = 'query string'
page = 2
config =
... | JavaScript | CoffeeScript | jianliaoim/talk-os | talk-web/test/spec/actions/search.spec.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/test/spec/actions/search.spec.coffee | 1 | 50 |
jianliaoim/talk-os:talk-web/test/spec/actions/search.spec.coffee:1:completion | completion | xdescribe 'Actions: search', ->
beforeEach ->
@action = require 'actions/search'
@api = require 'network/api'
describe 'Method: query', ->
it 'should call api', ->
spyOn(@api.messages.search, 'get').and.callThrough()
teamId = 1
q = 'query string'
page = 2
config =
... | spyOn(@api.messages.search, 'post').and.callThrough()
data = {}
config = data: data
@action.collection(data)
expect(@api.messages.search.post).toHaveBeenCalledWith config
describe 'Method: collectionFile', ->
it 'should call api', ->
spyOn(@api.messages.search, 'post').and.callThr... | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-web/test/spec/actions/search.spec.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/test/spec/actions/search.spec.coffee | 1 | 50 |
jianliaoim/talk-os:talk-web/test/spec/actions/search.spec.coffee:2:raw_corpus | raw_corpus | @action.collectionPost(data)
expect(data.type).toBe 'rtf'
expect(@api.messages.search.post).toHaveBeenCalledWith config
describe 'Method: collectionLink', ->
it 'should call api', ->
spyOn(@api.messages.search, 'post').and.callThrough()
data = {}
config = data: data
@action.... | CoffeeScript | jianliaoim/talk-os | talk-web/test/spec/actions/search.spec.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/test/spec/actions/search.spec.coffee | 51 | 64 | ||
jianliaoim/talk-os:talk-web/test/spec/actions/search.spec.coffee:2:completion | completion | @action.collectionPost(data)
expect(data.type).toBe 'rtf'
expect(@api.messages.search.post).toHaveBeenCalledWith config
describe 'Method: collectionLink', ->
it 'should call api', ->
spyOn(@api.messages.search, 'post').and.callThrough() | data = {}
config = data: data
@action.collectionLink(data)
expect(data.type).toBe 'url'
expect(@api.messages.search.post).toHaveBeenCalledWith config | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-web/test/spec/actions/search.spec.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/test/spec/actions/search.spec.coffee | 51 | 64 |
jashkenas/coffeescript:test/importing/error.coffee:1:raw_corpus | raw_corpus | # This file throws an error on line 3. It is used for testing error stack traces with sourcemaps.
module.exports =
throw new Error 'I am error' | CoffeeScript | jashkenas/coffeescript | test/importing/error.coffee | MIT | 817c39a13065a900725943c33a79252a69d779e2 | 16,577 | https://github.com/jashkenas/coffeescript/blob/817c39a13065a900725943c33a79252a69d779e2/test/importing/error.coffee | 1 | 3 | ||
jashkenas/coffeescript:test/importing/error.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# This file throws an error on line 3. It is used for testing error stack traces with sourcemaps.
module.exports =
throw new Error 'I am error'
``` | // This file throws an error on line 3. It is used for testing error stack traces with sourcemaps.
module.exports = (function() {
throw new Error('I am error');
})(); | CoffeeScript | JavaScript | jashkenas/coffeescript | test/importing/error.coffee | MIT | 817c39a13065a900725943c33a79252a69d779e2 | 16,577 | https://github.com/jashkenas/coffeescript/blob/817c39a13065a900725943c33a79252a69d779e2/test/importing/error.coffee | 1 | 3 |
jashkenas/coffeescript:test/importing/error.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// This file throws an error on line 3. It is used for testing error stack traces with sourcemaps.
module.exports = (function() {
throw new Error('I am error');
})();
``` | # This file throws an error on line 3. It is used for testing error stack traces with sourcemaps.
module.exports =
throw new Error 'I am error' | JavaScript | CoffeeScript | jashkenas/coffeescript | test/importing/error.coffee | MIT | 817c39a13065a900725943c33a79252a69d779e2 | 16,577 | https://github.com/jashkenas/coffeescript/blob/817c39a13065a900725943c33a79252a69d779e2/test/importing/error.coffee | 1 | 3 |
nicolaskruchten/pivottable:src/export_renderers.coffee:1:raw_corpus | raw_corpus | callWithJQuery = (pivotModule) ->
if typeof exports is "object" and typeof module is "object" # CommonJS
pivotModule require("jquery")
else if typeof define is "function" and define.amd # AMD
define ["jquery"], pivotModule
# Plain browser env
else
pivotModule jQuery
callWithJQue... | CoffeeScript | nicolaskruchten/pivottable | src/export_renderers.coffee | MIT | 838ec2fc38747749c28d2fd1cb6c4ace9e9cc520 | 4,440 | https://github.com/nicolaskruchten/pivottable/blob/838ec2fc38747749c28d2fd1cb6c4ace9e9cc520/src/export_renderers.coffee | 1 | 50 | ||
nicolaskruchten/pivottable:src/export_renderers.coffee:1:completion | completion | callWithJQuery = (pivotModule) ->
if typeof exports is "object" and typeof module is "object" # CommonJS
pivotModule require("jquery")
else if typeof define is "function" and define.amd # AMD
define ["jquery"], pivotModule
# Plain browser env
else
pivotModule jQuery
callWithJQue... | row = []
for rowAttr in rowAttrs
row.push rowAttr
if colKeys.length == 1 and colKeys[0].length == 0
row.push pivotData.aggregatorName
else
for colKey in colKeys
row.push colKey.join("-")
result.push row
for rowKey in rowKeys
... | CoffeeScript | CoffeeScript | nicolaskruchten/pivottable | src/export_renderers.coffee | MIT | 838ec2fc38747749c28d2fd1cb6c4ace9e9cc520 | 4,440 | https://github.com/nicolaskruchten/pivottable/blob/838ec2fc38747749c28d2fd1cb6c4ace9e9cc520/src/export_renderers.coffee | 1 | 50 |
nicolaskruchten/pivottable:src/export_renderers.coffee:2:raw_corpus | raw_corpus | text += r.join("\t")+"\n"
return $("<textarea>").text(text).css(
width: ($(window).width() / 2) + "px",
height: ($(window).height() / 2) + "px") | CoffeeScript | nicolaskruchten/pivottable | src/export_renderers.coffee | MIT | 838ec2fc38747749c28d2fd1cb6c4ace9e9cc520 | 4,440 | https://github.com/nicolaskruchten/pivottable/blob/838ec2fc38747749c28d2fd1cb6c4ace9e9cc520/src/export_renderers.coffee | 51 | 55 | ||
nicolaskruchten/pivottable:src/export_renderers.coffee:2:completion | completion | text += r.join("\t")+"\n" | return $("<textarea>").text(text).css(
width: ($(window).width() / 2) + "px",
height: ($(window).height() / 2) + "px") | CoffeeScript | CoffeeScript | nicolaskruchten/pivottable | src/export_renderers.coffee | MIT | 838ec2fc38747749c28d2fd1cb6c4ace9e9cc520 | 4,440 | https://github.com/nicolaskruchten/pivottable/blob/838ec2fc38747749c28d2fd1cb6c4ace9e9cc520/src/export_renderers.coffee | 51 | 55 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:1:raw_corpus | raw_corpus | class Animation
@transitions:
"webkitTransition": "webkitTransitionEnd"
"mozTransition": "mozTransitionEnd"
"msTransition": "msTransitionEnd"
"oTransition": "oTransitionEnd"
"transition": "transitionend"
@transition: ($el) ->
el = $el[0]
return result for type, result of @transitions wh... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 10 | 24 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Animation
@transitions:
"webkitTransition": "webkitTransitionEnd"
"mozTransition": "mozTransitionEnd"
"msTransition": "msTransitionEnd"
"oTransition": "oTransitionEnd"
"transition": "transitionend"
@transition: ($el) ->
el = $el... | var Animation;
Animation = (function() {
class Animation {
static transition($el) {
var el, ref, result, type;
el = $el[0];
ref = this.transitions;
for (type in ref) {
result = ref[type];
if (el.style[type] != null) {
return result;
}
}
}
s... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 10 | 24 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Animation;
Animation = (function() {
class Animation {
static transition($el) {
var el, ref, result, type;
el = $el[0];
ref = this.transitions;
for (type in ref) {
result = ref[type];
if (el.style[type] != null) {
... | class Animation
@transitions:
"webkitTransition": "webkitTransitionEnd"
"mozTransition": "mozTransitionEnd"
"msTransition": "msTransitionEnd"
"oTransition": "oTransitionEnd"
"transition": "transitionend"
@transition: ($el) ->
el = $el[0]
return result for type, result of @transitions wh... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 10 | 24 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:1:completion | completion | class Animation
@transitions:
"webkitTransition": "webkitTransitionEnd"
"mozTransition": "mozTransitionEnd"
"msTransition": "msTransitionEnd"
"oTransition": "oTransitionEnd"
"transition": "transitionend" | @transition: ($el) ->
el = $el[0]
return result for type, result of @transitions when el.style[type]?
@execute: ($el, callback) ->
transition = @transition($el)
if transition? then $el.one(transition, callback) else callback() | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 10 | 24 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:raw_corpus | raw_corpus | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 26 | 75 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) -... | var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = new Gridly($el, options);
}
return this.exi... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = ... | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:completion | completion | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | $: (selector) =>
@$el.find(selector)
compare: (d, s) =>
return +1 if d.y > s.y + s.h
return -1 if s.y > d.y + d.h
return +1 if (d.x + (d.w / 2)) > (s.x + (s.w / 2))
return -1 if (s.x + (s.w / 2)) > (d.x + (d.w / 2))
return 0
draggable: =>
@$('> *').draggable
zIndex: 800
dra... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:raw_corpus | raw_corpus | @settings?.callbacks?.reordering?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.reordered?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 76 | 125 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@settings?.callbacks?.reordering?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.reordered?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b)... | var ref, ref1;
if ((ref = this.settings) != null) {
if ((ref1 = ref.callbacks) != null) {
if (typeof ref1.reordering === "function") {
ref1.reordering($elements)({
stop: (event, ui) => {
var $elements, ref2, ref3;
$elements = this.$sorted();
this.ordinalize($elements);... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var ref, ref1;
if ((ref = this.settings) != null) {
if ((ref1 = ref.callbacks) != null) {
if (typeof ref1.reordering === "function") {
ref1.reordering($elements)({
stop: (event, ui) => {
var $elements, ref2, ref3;
$elements ... | @settings?.callbacks?.reordering?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.reordered?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:completion | completion | @settings?.callbacks?.reordering?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.reordered?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.... | $dragging = $(event.target)
$elements = @$sorted()
positions = @structure($elements).positions
original = index = $dragging.data('position')
for element in positions.filter((position) -> position.$element.is($dragging))
element.x = $dragging.position().left
element.y = $dragging.position().... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:raw_corpus | raw_corpus | size = @size($element)
height = Infinity
column = 0
for i in [0 ... (columns.length - size)]
max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $ele... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 126 | 175 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:completion | completion | size = @size($element)
height = Infinity
column = 0
for i in [0 ... (columns.length - size)]
max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $ele... | positions.push
x: position.x
y: position.y
w: $element.data('width') || $element.width()
h: $element.data('height') || $element.height()
$element: $element
height: Math.max columns...
positions: positions
layout: =>
$elements = (@settings.callbacks?.optimize || @o... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 126 | 175 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:raw_corpus | raw_corpus | height: structure.height
optimize: (originals) =>
results = []
columns = 0
while originals.length > 0
columns = 0 if columns is @settings.columns
index = 0
for index in [0...originals.length]
break if columns + @size($(originals[index])) <= @settings.columns
if index is... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 176 | 209 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
height: structure.height
optimize: (originals) =>
results = []
columns = 0
while originals.length > 0
columns = 0 if columns is @settings.columns
index = 0
for index in [0...originals.length]
break if columns + @size($(o... | ({
height: structure.height({
optimize: (originals) => {
var columns, i, index, ref, results;
results = [];
columns = 0;
while (originals.length > 0) {
if (columns === this.settings.columns) {
columns = 0;
}
index = 0;
for (index = i = 0, ref = ori... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 176 | 209 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
height: structure.height({
optimize: (originals) => {
var columns, i, index, ref, results;
results = [];
columns = 0;
while (originals.length > 0) {
if (columns === this.settings.columns) {
columns = 0;
}
... | height: structure.height
optimize: (originals) =>
results = []
columns = 0
while originals.length > 0
columns = 0 if columns is @settings.columns
index = 0
for index in [0...originals.length]
break if columns + @size($(originals[index])) <= @settings.columns
if index is... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 176 | 209 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:completion | completion | height: structure.height
optimize: (originals) =>
results = []
columns = 0
while originals.length > 0
columns = 0 if columns is @settings.columns
index = 0
for index in [0...originals.length]
break if columns + @size($(originals[index])) <= @settings.columns
if index is... | columns += @size($(originals[index]))
# Move from originals into results
results.push(originals.splice(index,1)[0])
return results
$.fn.extend
gridly: (option = {}) ->
@each ->
$this = $(@)
options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option
acti... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 7c330b31f82e7802ccf90818011024362f277247 | 852 | https://github.com/ksylvest/jquery-gridly/blob/7c330b31f82e7802ccf90818011024362f277247/javascripts/jquery.gridly.coffee | 176 | 209 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:raw_corpus | raw_corpus | @settings?.callbacks?.dragging?.started?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.dragging?.stopped?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 76 | 125 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@settings?.callbacks?.dragging?.started?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.dragging?.stopped?($elements)
$sorted: ($elements) =>
($elements || @$('> ... | var ref, ref1, ref2;
if ((ref = this.settings) != null) {
if ((ref1 = ref.callbacks) != null) {
if ((ref2 = ref1.dragging) != null) {
if (typeof ref2.started === "function") {
ref2.started($elements)({
stop: (event, ui) => {
var $elements, ref3, ref4, ref5;
$elemen... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var ref, ref1, ref2;
if ((ref = this.settings) != null) {
if ((ref1 = ref.callbacks) != null) {
if ((ref2 = ref1.dragging) != null) {
if (typeof ref2.started === "function") {
ref2.started($elements)({
stop: (event, ui) => {
... | @settings?.callbacks?.dragging?.started?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.dragging?.stopped?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:completion | completion | @settings?.callbacks?.dragging?.started?($elements)
stop: (event, ui) =>
$elements = @$sorted()
@ordinalize($elements)
setTimeout @layout, 0
@settings?.callbacks?.dragging?.stopped?($elements)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
... | drag: (event, ui) =>
$dragging = $(event.target)
$elements = @$sorted()
positions = @structure($elements).positions
original = index = $dragging.data('position')
for element in positions.filter((position) -> position.$element.is($dragging))
element.x = $dragging.position().left
element.... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:raw_corpus | raw_corpus | height = Infinity
column = 0
for i in [0 ... (columns.length - size)]
max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $element.height()) + @settings.g... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 126 | 175 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:completion | completion | height = Infinity
column = 0
for i in [0 ... (columns.length - size)]
max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $element.height()) + @settings.g... | y: position.y
w: $element.data('width') || $element.width()
h: $element.data('height') || $element.height()
$element: $element
height: Math.max columns...
positions: positions
layout: () =>
$elements = @$sorted()
$reordered = @settings.callbacks?.reorder?($elements)
$elem... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 126 | 175 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:raw_corpus | raw_corpus | height: structure.height
$.fn.extend
gridly: (option = {}) ->
@each ->
$this = $(@)
options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option
action = if typeof option is "string" then option else option.action
action ?= "layout"
Gridly.gridly($this, option... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 176 | 187 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
height: structure.height
$.fn.extend
gridly: (option = {}) ->
@each ->
$this = $(@)
options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option
action = if typeof option is "string" then option else option.action
... | ({
height: structure.height
});
$.fn.extend({
gridly: function(option = {}) {
return this.each(function() {
var $this, action, options;
$this = $(this);
options = $.extend({}, $.fn.gridly.defaults, typeof option === "object" && option);
action = typeof option === "string" ? option : opt... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 176 | 187 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
height: structure.height
});
$.fn.extend({
gridly: function(option = {}) {
return this.each(function() {
var $this, action, options;
$this = $(this);
options = $.extend({}, $.fn.gridly.defaults, typeof option === "object" && option);
... | height: structure.height
$.fn.extend
gridly: (option = {}) ->
@each ->
$this = $(@)
options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option
action = if typeof option is "string" then option else option.action
action ?= "layout"
Gridly.gridly($this, option... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 176 | 187 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:completion | completion | height: structure.height
$.fn.extend
gridly: (option = {}) ->
@each ->
$this = $(@) | options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option
action = if typeof option is "string" then option else option.action
action ?= "layout"
Gridly.gridly($this, options)[action]() | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | a570a585a64d13ae479ce84bfbdba7cda4dac299 | 852 | https://github.com/ksylvest/jquery-gridly/blob/a570a585a64d13ae479ce84bfbdba7cda4dac299/javascripts/jquery.gridly.coffee | 176 | 187 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:raw_corpus | raw_corpus | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 26 | 75 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) -... | var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = new Gridly($el, options);
}
return this.exi... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = ... | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:completion | completion | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | $: (selector) =>
@$el.find(selector)
compare: (d, s) =>
return +1 if d.y > s.y + s.h
return -1 if s.y > d.y + d.h
return +1 if (d.x + (d.w / 2)) > (s.x + (s.w / 2))
return -1 if (s.x + (s.w / 2)) > (d.x + (d.w / 2))
return 0
draggable: =>
@$('> *').draggable
zIndex: 800
dra... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:raw_corpus | raw_corpus | stop: (event, ui) =>
$dragging = $(event.target)
@ordinalize(@$sorted())
setTimeout @layout, 0
@settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.data('position')
bPosition = $b.data('positio... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 76 | 125 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:completion | completion | stop: (event, ui) =>
$dragging = $(event.target)
@ordinalize(@$sorted())
setTimeout @layout, 0
@settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.data('position')
bPosition = $b.data('positio... | $elements = @$sorted()
positions = @structure($elements).positions
original = index = $dragging.data('position')
for element in positions.filter((position) -> position.$element.is($dragging))
element.x = $dragging.position().left
element.y = $dragging.position().top
element.w = $dragging.... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:raw_corpus | raw_corpus | max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structu... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 126 | 175 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:completion | completion | max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structu... | height: Math.max columns...
positions: positions
layout: ($elements = @$sorted()) =>
structure = @structure($elements)
$elements.each (index, element) =>
$element = $(element)
position = structure.positions[index]
$element.css
position: 'absolute'
left: position.x
... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 126 | 175 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:raw_corpus | raw_corpus | action = if typeof option is "string" then option else option.action
action ?= "layout"
Gridly.gridly($this, options)[action]() | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 176 | 179 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:completion | completion | action = if typeof option is "string" then option else option.action
action ?= "layout" | Gridly.gridly($this, options)[action]() | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 3a906c95f09f8e42b27d2fc20fe4bc00373c8230 | 852 | https://github.com/ksylvest/jquery-gridly/blob/3a906c95f09f8e42b27d2fc20fe4bc00373c8230/javascripts/jquery.gridly.coffee | 176 | 179 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:raw_corpus | raw_corpus | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 26 | 75 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) -... | var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = new Gridly($el, options);
}
return this.exi... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = ... | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:completion | completion | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | compare: (d, s) =>
return +1 if d.y > s.y + s.h
return -1 if s.y > d.y + d.h
return +1 if (d.x + (d.w / 2)) > (s.x + (s.w / 2))
return -1 if (s.x + (s.w / 2)) > (d.x + (d.w / 2))
return 0
draggable: =>
@$('> *').draggable
zIndex: 800
drag: @drag
start: @start
stop: @st... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:raw_corpus | raw_corpus | @ordinalize(@$sorted())
setTimeout @layout, 0
@settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.data('position')
bPosition = $b.data('position')
aPositionInt = parseInt(aPosition)
bPosit... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 76 | 125 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:completion | completion | @ordinalize(@$sorted())
setTimeout @layout, 0
@settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
$a = $(a)
$b = $(b)
aPosition = $a.data('position')
bPosition = $b.data('position')
aPositionInt = parseInt(aPosition)
bPosit... | positions = @structure($elements).positions
index = $dragging.data('position')
original = index
coordinate =
x: $dragging.position().left
y: $dragging.position().top
w: $dragging.data('width') || $dragging.width()
h: $dragging.data('height') || $dragging.height()
for i in [0 .... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:raw_corpus | raw_corpus | height = Infinity
column = 0
for i in [0 ... (columns.length - size)]
max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $element.height()) + @settings.g... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 126 | 175 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:completion | completion | height = Infinity
column = 0
for i in [0 ... (columns.length - size)]
max = Math.max columns[i ... (i + size)]...
if max < height
height = max
column = i
for i in [column ... column + size]
columns[i] = height + ($element.data('height') || $element.height()) + @settings.g... | y: position.y
w: $element.data('width') || $element.width()
h: $element.data('height') || $element.height()
height: Math.max columns...
positions: positions
layout: ($elements = @$sorted()) =>
structure = @structure($elements)
$elements.each (index, element) =>
$element = $(el... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 126 | 175 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:raw_corpus | raw_corpus | $this = $(@)
options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option
action = if typeof option is "string" then option else option.action
action ?= "layout"
Gridly.gridly($this, options)[action]() | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 176 | 182 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:5:completion | completion | $this = $(@)
options = $.extend {}, $.fn.gridly.defaults, typeof option is "object" and option | action = if typeof option is "string" then option else option.action
action ?= "layout"
Gridly.gridly($this, options)[action]() | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | f84fbee39d0d1a4614162c5c03efd9a62fb77990 | 852 | https://github.com/ksylvest/jquery-gridly/blob/f84fbee39d0d1a4614162c5c03efd9a62fb77990/javascripts/jquery.gridly.coffee | 176 | 182 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:raw_corpus | raw_corpus | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 26 | 75 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) -... | var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = new Gridly($el, options);
}
return this.exi... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Gridly;
Gridly = (function() {
class Gridly {
static gridly($el, options = {}) {
var base, name;
if (this.existing == null) {
this.existing = {};
}
if ((base = this.existing)[name = $el[0]] == null) {
base[name] = ... | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:2:completion | completion | class Gridly
@settings:
base: 60
gutter: 20
columns: 12
draggable: true
@gridly: ($el, options = {}) ->
@existing ?= {}
@existing[$el[0]] ?= new Gridly($el, options)
return @existing[$el[0]]
constructor: ($el, settings = {}) ->
@$el = $el
@settings = $.extend {}, Gridly.sett... | @$el.find(selector)
compare: (d, s) =>
return +1 if d.y > s.y + s.h
return -1 if s.y > d.y + d.h
return +1 if (d.x + (d.w / 2)) > (s.x + (s.w / 2))
return -1 if (s.x + (s.w / 2)) > (d.x + (d.w / 2))
return 0
draggable: =>
@$('> *').draggable
zIndex: 800
drag: @drag
start:... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 26 | 75 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:raw_corpus | raw_corpus | @settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
aVal = parseInt($(a).data('position'))
bVal = parseInt($(b).data('position'))
return -1 if aVal < bVal
return +1 if aVal > bVal
return 0
drag: (event, ui) =>
delta = 0.5
$dra... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 76 | 125 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:completion | completion | @settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
aVal = parseInt($(a).data('position'))
bVal = parseInt($(b).data('position'))
return -1 if aVal < bVal
return +1 if aVal > bVal
return 0
drag: (event, ui) =>
delta = 0.5
$dra... | $element = $($elements[i])
continue if $element.is($dragging)
position = positions[i]
if @compare(coordinate, position) < 0
index = i
break
unless index is original
$dragging.data('position', index + delta)
@layout(@$sorted())
position: ($element, columns) =>
s... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:raw_corpus | raw_corpus | columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structure: ($elements = @$sorted()) =>
positions = []
columns = (0 for i in [0 .. @settings.columns])
$elements.each (index, element) =>
$ele... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 126 | 172 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structure: ($elements = @$sorted()) =>
positions = []
columns = (0 for i in [0 .. @settings.col... | columns[i] = height + ($element.data('height') || $element.height()) + this.settings.gutter({
x: column * (this.settings.base + this.settings.gutter),
y: height
});
({
structure: ($elements = this.$sorted()) => {
var columns, i, positions;
positions = [];
columns = (function() {
var j, ref, res... | CoffeeScript | JavaScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 126 | 172 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
columns[i] = height + ($element.data('height') || $element.height()) + this.settings.gutter({
x: column * (this.settings.base + this.settings.gutter),
y: height
});
({
structure: ($elements = this.$sorted()) => {
var columns, i, positions;
positions ... | columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structure: ($elements = @$sorted()) =>
positions = []
columns = (0 for i in [0 .. @settings.columns])
$elements.each (index, element) =>
$ele... | JavaScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 126 | 172 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:completion | completion | columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structure: ($elements = @$sorted()) =>
positions = []
columns = (0 for i in [0 .. @settings.columns])
$elements.each (index, element) =>
$ele... | structure = @structure($elements)
$elements.each (index, element) =>
$element = $(element)
position = structure.positions[index]
$element.css
position: 'absolute'
left: position.x
top: position.y
@$el.css
height: structure.height
$.fn.extend
gridly: (option... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 26f7721c58ae617c756e7f0033f9077f12d21bb7 | 852 | https://github.com/ksylvest/jquery-gridly/blob/26f7721c58ae617c756e7f0033f9077f12d21bb7/javascripts/jquery.gridly.coffee | 126 | 172 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:raw_corpus | raw_corpus | @settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
aVal = parseInt($(a).data('position'))
bVal = parseInt($(b).data('position'))
return -1 if aVal < bVal
return +1 if aVal > bVal
return 0
drag: (event, ui) =>
delta = 0.5
$dra... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 137ac7708acab19d739081593a3588a19ac5f70b | 852 | https://github.com/ksylvest/jquery-gridly/blob/137ac7708acab19d739081593a3588a19ac5f70b/javascripts/jquery.gridly.coffee | 76 | 125 | ||
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:3:completion | completion | @settings?.callbacks?.reordered(@)
$sorted: ($elements) =>
($elements || @$('> *')).sort (a,b) ->
aVal = parseInt($(a).data('position'))
bVal = parseInt($(b).data('position'))
return -1 if aVal < bVal
return +1 if aVal > bVal
return 0
drag: (event, ui) =>
delta = 0.5
$dra... | $element = $($elements[i])
continue if $element.is($dragging)
position = positions[i]
if @compare(coordinate, position) < 0
index = i
break
unless index is original
$dragging.data('position', index + delta)
@layout(@$sorted())
position: ($element, columns) =>
s... | CoffeeScript | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 137ac7708acab19d739081593a3588a19ac5f70b | 852 | https://github.com/ksylvest/jquery-gridly/blob/137ac7708acab19d739081593a3588a19ac5f70b/javascripts/jquery.gridly.coffee | 76 | 125 |
ksylvest/jquery-gridly:javascripts/jquery.gridly.coffee:4:raw_corpus | raw_corpus | columns[i] = height + ($element.data('height') || $element.height()) + @settings.gutter
x: (column * (@settings.base + @settings.gutter))
y: height
structure: ($elements = @$sorted()) =>
positions = []
columns = (0 for i in [0 .. @settings.columns])
$elements.each (index, element) =>
$ele... | CoffeeScript | ksylvest/jquery-gridly | javascripts/jquery.gridly.coffee | MIT | 137ac7708acab19d739081593a3588a19ac5f70b | 852 | https://github.com/ksylvest/jquery-gridly/blob/137ac7708acab19d739081593a3588a19ac5f70b/javascripts/jquery.gridly.coffee | 126 | 172 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.