Sha256: 073dbb68c0e37f36c5c44fdb1205d17f7443f801469d2434614047a6c2e10938

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 KB

Contents

$(document).ready ->
  background = $("body").data("background-image")
  background_tile = $("body").data("background-tile")
  background_blur = $("body").data("background-blur")
  logo = $("body").data("logo-image")

  $("a.logo div").css("background-image", "url(" + (if logo? then logo else "<%= asset_path('almanac/logo.jpg') %>") + ")")

  if background_tile
    $("body.almanac").css("background-image", "url(" + (if background? then background else "<%= asset_path('almanac/background.jpg') %>") + ")")
  else
    image = new Image()
    options = { amount: background_blur }

    image.onload = ->
      Pixastic.process (Pixastic.process image, "blurfast", options), "blur", options
      $.backstretch options.resultCanvas.toDataURL('image/png')

    image.src = if background? then background else "<%= asset_path('almanac/background.jpg') %>"

  $(".custom-upload input[type=file]").change ->
    $("#new_image input[type=submit]").show()
    $(this).next().find("input").val $(this).val()

  $("a.popup").click (e) ->
    e.preventDefault()
    window.open(this.href, "mywindow","width=600,height=300")

  $("a.add-photo").click (e) ->
    e.preventDefault()
    $("#post_body").val($("#post_body").val() + "\n\n![](" + $(this).data("image") + ")\n\n")

  $(".delete-post").bind ("ajax:success"), ->
    post = $(this).parent().parent()
    if post.prev().attr('class') is "head" and post.next().attr('class') is "head"
      post.prev().fadeOut()
    post.fadeOut()

  $(".delete-comment").bind ("ajax:success"), ->
    comment = $(this).parent().parent()
    if comment.prev().prop("tagName") is "H4" and comment.next().prop("tagName") is "HR"
      comment.prev().fadeOut()
      comment.next().fadeOut()
    comment.fadeOut()

  $('.datepicker').datepicker({ format: 'yyyy-mm-dd' })

  $("#post_title").change (e) ->
    $("#post_slug").val($(this).val().convertToSlug())

unless String::convertToSlug?
  String::convertToSlug = ->
    @toLowerCase().replace(/[^\w ]+/g, "").replace RegExp(" +", "g"), "-"

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
almanac-0.6.1 app/assets/javascripts/almanac/5-main.coffee.erb
almanac-0.6.0 app/assets/javascripts/almanac/5-main.coffee.erb
almanac-0.5.3 app/assets/javascripts/almanac/5-main.coffee.erb
almanac-0.5.2 app/assets/javascripts/almanac/5-main.coffee.erb
almanac-0.5.1 app/assets/javascripts/almanac/5-main.coffee.erb
almanac-0.5.0 app/assets/javascripts/almanac/5-main.coffee.erb