Sha256: af07ac0906f4b4ce217ebb0af42cab96915b94a48a05b638ac67886465bd266b

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

class Photo
  constructor: (@attributes) ->

  load: (options, callback) ->
    options ||= {}

    width = options.width if options.width?

    if @attributes.width?
      if width?
        width = Math.min width, @attributes.width
      else
        width = @attributes.width

    if width?
      width = Math.round width
      url = @attributes.url.replace /w\d+-h\d+(-p)?/, "w#{ width }"
    else
      url = @attributes.url

    element = $('<img/>')

    if callback?
      element.on 'load', ->
        element.off 'load'
        callback element

    element.attr src: url

    element

window.GooglePlus ||= {}
window.GooglePlus.Photo = Photo

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
googleplus-reader-0.0.3 lib/assets/javascripts/googleplus.photo.js.coffee
googleplus-reader-0.0.2 lib/assets/javascripts/googleplus.photo.js.coffee