git-svn-id: https://msi/svn/firstRepo/WebClient/branches/NewRelease@80 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -8,6 +8,9 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewT
|
||||
//initialize template
|
||||
template: _.template(categoryViewTemplate),
|
||||
itemtemplate: _.template(categoryItemTemplate, {variable: 'data'}),
|
||||
events: {
|
||||
"click a[data-ordinal-divider]": "scrollDivider",
|
||||
},
|
||||
initialize: function (options) {
|
||||
this.id = "CategoryView" + options.categoryId;
|
||||
var self = this;
|
||||
@@ -26,7 +29,7 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewT
|
||||
}
|
||||
}
|
||||
},
|
||||
renderItem: function () {
|
||||
renderItem: function () {
|
||||
var $ul = this.$el.find('#allRicette');
|
||||
if ($ul.html().trim() === "") {
|
||||
// var start = new Date().getTime();
|
||||
@@ -45,13 +48,43 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewT
|
||||
$(html).appendTo($ul).enhanceWithin();
|
||||
$ul.listview("refresh");
|
||||
}
|
||||
|
||||
var alphaList = "";
|
||||
this.$el.find(".ui-li-divider").each(function(index, item){
|
||||
alphaList += "<li><a data-ordinal-divider='" + index + "'>" + $(item).text() + "</a></li>";
|
||||
});
|
||||
this.$el.find("#alphabetList").append(alphaList);
|
||||
|
||||
this.$el.find("#alphabetConteiner").on("touchend", function(e){
|
||||
if(self.$el.find("#alphabetConteiner").hasClass("alphabetContainer_hover"))
|
||||
self.$el.find("#alphabetConteiner").removeClass("alphabetContainer_hover");
|
||||
});
|
||||
this.$el.find("#alphabetConteiner").on("touchmove", function(e){
|
||||
if(!self.$el.find("#alphabetConteiner").hasClass("alphabetContainer_hover"))
|
||||
self.$el.find("#alphabetConteiner").addClass("alphabetContainer_hover");
|
||||
e.preventDefault();
|
||||
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
||||
// scroll to divider position
|
||||
var y= touch.pageY;
|
||||
|
||||
self.$el.find("#alphabetList>*").each(function(){
|
||||
if ( ! ( y <= $( this ).offset().top || y >= $( this ).offset().top + $( this ).outerHeight() ) ) {
|
||||
$($( this ).children()[0]).trigger("click");
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.mobile.loading('hide');
|
||||
|
||||
|
||||
},
|
||||
scrollDivider:function(e){
|
||||
var a = $(e.currentTarget);
|
||||
var header = $(this.$el.find("div[data-role='header']"));
|
||||
var divider = $(this.$el.find(".ui-li-divider")[a.attr("data-ordinal-divider")]);
|
||||
$('body').scrollTop(divider.position().top - header.height());
|
||||
},
|
||||
onShowed: function(){
|
||||
$('body').scrollTop(0);
|
||||
|
||||
setTimeout(function(){
|
||||
$('img[data-src!=""]').each(function(index, item){
|
||||
setTimeout(function(){
|
||||
@@ -78,7 +111,7 @@ define(['jquery', 'underscore', 'backbone', 'text!modules/category/categoryViewT
|
||||
this.$el.append(this.template({categoryName: this.categoryName}));
|
||||
this.$el.append(this.footer.$el);
|
||||
//return to enable chained calls
|
||||
}
|
||||
}
|
||||
this.$el.find("#indexBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user