Permalink
Browse files

images loading correctly

  • Loading branch information...
1 parent 381a7ea commit ad461ebd3f89a1579f4a38df756f1f32233576ec @drewlesueur committed Aug 17, 2011
Showing with 39 additions and 50 deletions.
  1. +1 −1 bubble-view.coffee
  2. +1 −1 bubble-view.js
  3. +14 −18 image-rotator.coffee
  4. +18 −23 image-rotator.js
  5. +2 −1 listing.coffee
  6. +3 −2 listing.js
  7. +0 −2 map-page-presenter.coffee
  8. +0 −2 map-page-presenter.js
View
@@ -40,7 +40,7 @@ define "bubble-view", () ->
</div>
<div class="image-area" style="position:relative;">
</div>
- <div style="bottom: -10px; position: absolute;">
+ <div style="bottom: 0px; position: absolute;">
<a href="#" style="font-size: 10px;" class="delete-image">delete image</a>
</div>
</div>
View
@@ -26,7 +26,7 @@
return trigger("addimages", model, urls);
});
bubbleHtml = require("bubble-html");
- el = $("<div>\n <div>\n " + bubbleHtml + "\n </div>\n <a href=\"#\" class=\"delete\">Delete Listing</a>\n <div class=\"file-upload\">\n </div>\n <div class=\"add-image-area\" >\n <textarea class=\"images\"></textarea>\n <input class=\"save-images-button\" type=\"button\" value=\"Save images\">\n </div>\n <div class=\"image-area\" style=\"position:relative;\">\n </div>\n <div style=\"bottom: -10px; position: absolute;\">\n <a href=\"#\" style=\"font-size: 10px;\" class=\"delete-image\">delete image</a>\n </div>\n</div>");
+ el = $("<div>\n <div>\n " + bubbleHtml + "\n </div>\n <a href=\"#\" class=\"delete\">Delete Listing</a>\n <div class=\"file-upload\">\n </div>\n <div class=\"add-image-area\" >\n <textarea class=\"images\"></textarea>\n <input class=\"save-images-button\" type=\"button\" value=\"Save images\">\n </div>\n <div class=\"image-area\" style=\"position:relative;\">\n </div>\n <div style=\"bottom: 0px; position: absolute;\">\n <a href=\"#\" style=\"font-size: 10px;\" class=\"delete-image\">delete image</a>\n </div>\n</div>");
imageRotator = imageRotatorer();
el.find(".image-area").append(imageRotator.el);
el.find(".delete-image").bind("click", function() {
View
@@ -30,60 +30,56 @@ define "image-rotator", () ->
[config.imgMaxWidth, widthedHeight]
deleteImage = self.deleteImage = (url) ->
- for image, index in images
+ console.log images
+ for image, _index in images
+ image = $ image # I tought image was already a jquert object
if image.attr("src") == url
- images.splice(index, 1)
- next()
+ images.splice(_index, 1)
+ render()
image.remove()
addImage = (url) ->
img = $ """
<img src="#{url}" style="width: #{config.imgMaxWidth}px; position: absolute; top: 0; left: 0;"/>
"""
- console.log img
img.bind "load", () ->
+ images.push img
+ el.append img
h = this.height #img.height()
w = this.width #width()
[w,h] = getAdjustedDimensions w,h
img.animate "width": "#{w}px"
img.animate "height": "#{h}px"
+ index = images.length - 1
+ render()
+ self
- images.push img
- index += 1
- el.append img
- next()
- self
handleImageClick = () ->
next()
self.addImage = addImage
next = () ->
- console.log images
- console.log index
index += 1
- if index >= images.length
- index = 0
render()
self.next = next
getCurrentUrl = () ->
- console.log images
- console.log index
- console.log images[index]
images[index].attr "src"
self.getCurrentUrl = getCurrentUrl
prev = () ->
index += 1
- if index <= 0
- index = images.length - 1
render()
self.prev = prev
render = () ->
+ if index >= images.length
+ index = 0
+ else if index < 0
+ index = images.length - 1
for image, i in images
if index == i
images[i].show()
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -34,12 +34,13 @@ define "listing", () ->
self.addImages = addImages
deleteImage = self.deleteImage = (url) ->
attrs.images or= []
+ console.log attrs.images
for image, index in attrs.images
if image == url
attrs.images.splice(index, 1)
- trigger "deleteimage", (url)
save (err) ->
trigger "faileddeleteimage"
+ trigger "deleteimage", (url)
get = (self, prop, value) ->
return self.attrs[prop]
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -59,8 +59,6 @@ define "map-page-presenter", () ->
#addimages presenter
addImages = (listing, urls) ->
- console.log "called the add images function"
- console.log listing
listing.addImages urls
#listingMaker.addImages listing, urls
self.addImages = addImages
View
@@ -73,8 +73,6 @@
return model.set(prop, value);
});
addImages = function(listing, urls) {
- console.log("called the add images function");
- console.log(listing);
return listing.addImages(urls);
};
self.addImages = addImages;

0 comments on commit ad461eb

Please sign in to comment.