Skip to content

Instantly share code, notes, and snippets.

@qickstarter
Created September 27, 2012 08:10
Show Gist options
  • Select an option

  • Save qickstarter/3792819 to your computer and use it in GitHub Desktop.

Select an option

Save qickstarter/3792819 to your computer and use it in GitHub Desktop.
# ready function
$(document).ready ->
newpage = (obj, event, key) ->
obj.insertHtml('<-- newpage -->')
# ???
$("#body").redactor
imageUpload: '/admin/interview/articles/image_post'
buttonsAdd: ['|','newpage']
buttonsCustom:
newpage:
title: 'newpage'
callback: newpage
# ???よー分からん
$ ->
# 座標取得してなんかやってる
updatePreview = (coords) ->
if parseInt(coords.w) > 0
rx = 100 / coords.w
ry = 100 / coords.h
$("#preview").css
width: Math.round(rx * boundx) + 'px'
height: Math.round(ry * boundy) + 'px'
marginLeft: '-' + Math.round(rx * coords.x) + 'px'
marginTop: '-' + Math.round(ry * coords.y) + 'px'
# Jcrop plugin
# lean more [ http://deepliquid.com/projects/Jcrop/demos.php ]
$("#target").Jcrop
onChange: updatePreview
onSelect: updatePreview
aspectRatio: 1
->
bounds = @getBounds()
boundx = bounds[0]
boundy = bounds[1]
jcrop_api = @
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment