git-svn-id: https://msi/svn/firstRepo/WebClient/branches/NewRelease@52 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2016-01-18 22:18:39 +00:00
parent b4882d0006
commit bcd5752f87
14 changed files with 119 additions and 3294 deletions
+19 -54
View File
@@ -6,10 +6,7 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/item/itemViewTemplate.
collIngredienti: null,
fetchedRicetta: false,
fetchedIngredienti: false,
IMG_WIDTH: 500,
currentImg: 0,
maxImages: 3,
speed: 500,
galleryWall: null,
//initialize template
template: _.template(itemViewTemplate),
initialize: function (options) {
@@ -58,14 +55,24 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/item/itemViewTemplate.
);
},
onShowed: function(){
var self = this;
$('body').scrollTop(0);
this.$el.find("#Gallery").swipe({
triggerOnTouchEnd: true,
swipeStatus: this._swipeStatus,
allowPageScroll: "vertical",
threshold: 75
});
this.galleryWall = new Freewall("#Gallery");
this.galleryWall.reset({
selector: '.brick',
animate: true,
cellW: 150,
cellH: 'auto',
onResize: function() {
self.galleryWall.fitWidth();
}
});
var images = this.galleryWall.container.find('.brick');
images.find('img').load(function() {
self.galleryWall.fitWidth();
});
},
//render the content into div of view
render: function () {
@@ -76,8 +83,6 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/item/itemViewTemplate.
var ric = self.collRicetta.toJSON()[0];
this.maxImages = ric.foto.length;
Profile.existRicettaBloccoNote(ric.ricetta_id,
function (exist) {
self.$el.append(self.template({
@@ -125,48 +130,6 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/item/itemViewTemplate.
return this;
}
},
/**
* Catch each phase of the swipe.
* move : we drag the div
* cancel : we animate back to where we were
* end : we animate to the next image
*/
_swipeStatus: function (event, phase, direction, distance) {
//If we are moving before swipe, and we are going L or R in X mode, or U or D in Y mode then drag.
if (phase == "move" && (direction == "left" || direction == "right")) {
var duration = 0;
if (direction == "left") {
scrollImages((this.IMG_WIDTH * this.currentImg) + distance, duration);
} else if (direction == "right") {
scrollImages((this.IMG_WIDTH * this.currentImg) - distance, duration);
}
} else if (phase == "cancel") {
scrollImages(this.IMG_WIDTH * this.currentImg, this.speed);
} else if (phase == "end") {
if (direction == "right") {
self._previousImage();
} else if (direction == "left") {
self._nextImage();
}
}
},
_previousImage: function () {
this.currentImg = Math.max(this.currentImg - 1, 0);
scrollImages(this.IMG_WIDTH * this.currentImg, this.speed);
},
_nextImage: function() {
this.currentImg = Math.min(this.currentImg + 1, this.maxImages - 1);
this._scrollImages(this.IMG_WIDTH * this.currentImg, this.speed);
},
/**
* Manually update the position of the imgs on drag
*/
_scrollImages: function (distance, duration) {
imgs.css("transition-duration", (duration / 1000).toFixed(1) + "s");
//inverse the number we set in the css
var value = (distance < 0 ? "" : "-") + Math.abs(distance).toString();
imgs.css("transform", "translate(" + value + "px,0)");
},
goToContent: function (newIndex)
{
if (this.$arrayContent.length > newIndex && newIndex >= 0)
@@ -174,6 +137,8 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/item/itemViewTemplate.
this.scrollPositions[this.indexContent] = $('body').scrollTop();
this.indexContent = newIndex;
this.switchContent();
if(this.indexContent == 2)
this.galleryWall.fitWidth();
$('body').scrollTop(this.scrollPositions[this.indexContent]);
}
},
+6 -21
View File
@@ -4,27 +4,12 @@
<a id="backBtn" href="#" class="nav-glyphish-example ui-btn ui-icon-myHome ui-btn-icon-notext ui-btn-right" data-icon="custom"></a>
</div>
<style>
#Gallery {
float: left;
display: inline;
padding: 0;
margin: 0;
/*width: 1510px;*/
transition-property: transform;
transition-duration: 0.5s;
transition-timing-function: ease-out;
/*apply a transform to kick in the hardware acceleration. Without this, the first
time we add the transform you get odd rendering of the divs (half missing) */
transform: translate(0, 0);
.freewallGallery {
margin: 15px;
}
#Gallery img {
padding: 0;
.brick img {
margin: 0;
/*width: 500px;
height: 340px;*/
/*apply a transform to kick in the hardware acceleration. Without this, the first
time we add the transform you get odd rendering of the divs (half missing) */
transform: translate(0, 0);
display: block;
}
</style>
<div id="contentIngredienti" data-role="content">
@@ -50,9 +35,9 @@
</div>
<div id="contentFoto" data-role="content" style="display: none;">
<h1>Foto</h1>
<div id="Gallery">
<div id="Gallery" class="freewallGallery">
<% _.each(ricetta.foto, function(fotoID) {%>
<img src='<%=myManifest.Settings.DefaultURL%>/api/photo/<%=fotoID.ID%>'>
<div class='brick' style='width:250px;'><img src='<%=myManifest.Settings.DefaultURL%>/api/photo/<%=fotoID.ID%>' style="width: 100%;"></div>
<%});%>
</div>
</div>