///
var _MainScrollView = function()
{
this.divScroller = null;
this.divWrapper = null;
this.horizontalScrollview = null;
this.iNumOfPages = 0;
this.pages = [];
this.init = function()
{
this.divWrapper = document.createElement("div");
this.divWrapper.id = "divHorizontalScrollView";
this.divWrapper.style.position="relative";
this.divWrapper.style.width="100%";
this.divWrapper.style.top="0px";//Toolbar.getHeightPercent()+"%";
this.divWrapper.style.height=(100-Toolbar.getHeightPercent())+"%";
this.divScroller = document.createElement("div");
this.divScroller.style.height="100%";
this.divWrapper.appendChild(this.divScroller);
this.horizontalScrollview = new iScroll(this.divWrapper, {
snap: true,
vScroll: false,
momentum: false,
hScrollbar: false,
vScrollbar: false,
lockDirection:true,
onDomChanged:function()
{
MainScrollView.setPagesWidth();
},
onPageChange:function()
{
var bShowBackButton=( (MainScrollView.horizontalScrollview.currPageX!=MainScrollView.horizontalScrollview.getNumOfPages()-1 && T_MenuLanguages.isLangRTL()) ||
(MainScrollView.horizontalScrollview.currPageX!=0 && !T_MenuLanguages.isLangRTL()) );
Toolbar.showBackButton(bShowBackButton);
},
onAnimationStart:function()
{
// Toolbar.showBackButton(MainScrollView.horizontalScrollview.currPageX==0);
},
onAnimationEnd:function()
{
},
onScrollStart:function()
{
},
onScrollEnd: function()
{
}
});
GUI.divMain.appendChild(this.divWrapper);
this.setPagesWidth();
this.horizontalScrollview.refresh();
};
this.pageWidthCSSRule = null;
this.setPagesWidth = function() {
console.log("1");
if (this.pageWidthCSSRule == null) {
for ( var i = 0; i < document.styleSheets.length; i++) {
if (document.styleSheets[i].href.toLowerCase().indexOf("/emenu.css") != -1)
{
document.styleSheets[i].insertRule("div.divVerticalWrapper{}",document.styleSheets[i].cssRules.length);
this.pageWidthCSSRule=document.styleSheets[i].cssRules[document.styleSheets[i].cssRules.length-1];
}
}
}
var s = this.divWrapper.clientWidth+"";
if (s.indexOf("px")==-1)
s+="px";
this.pageWidthCSSRule.style.width=s;
this.setScrollerWidth();
//this.horizontalScrollview.refresh();
//this.pageWidthCSSRule.cssText = "div.divVerticalWrapper{width:"+ this.divScroller.style.width + ";}";
};
this.setScrollerWidth = function()
{
console.log("scroller width before ="+this.divWrapper.scrollWidth);
this.divScroller.style.width = ((this.divWrapper.clientWidth * this.iNumOfPages) + "px");
console.log("scroller width after ="+this.divScroller.style.width);
};
this.addView = function(divToAdd)
{
//create vertical wrapper and add the new div to it
var verticalWrapper = document.createElement("div");
verticalWrapper.setAttribute("class", "divVerticalWrapper");
verticalWrapper.style.height="100%";
verticalWrapper.appendChild(divToAdd);
verticalWrapper.style.float = "left";
//verticalWrapper.style.width = (this.divWrapper.clientWidth + "px");
//verticalWrapper.style.backgroundImage=Common.getUrl("mobile/sites/" + Common.getSiteID() + "/data/innerPageBg.jpg");
//this.setPagesWidth();
var scroll = new iScroll(verticalWrapper, {
snap: false,
hScroll: false,
vScroll: true,
checkDOMChanges:true,
momentum: true,
hScrollbar: false,
vScrollbar: false,
onScrollEnd: function()
{
//document.querySelector('#indicator > li.active').className = '';
//document.querySelector('#indicator > li:nth-child(' + (this.currPageX+1) + ')').className = 'active';
}
});
this.pages[this.iNumOfPages] = scroll;
this.iNumOfPages++;
verticalWrapper.scrollObject=scroll;
//set horizotal scroll width and add new page
this.setScrollerWidth();
//this.divScroller.style.width = ((this.divWrapper.clientWidth * this.iNumOfPages) + "px");
if (T_MenuLanguages.isLangRTL() && this.divScroller.childNodes.length > 0)
{
console.log("adding page at position 0");
//add the new page left to all pages and immidiatly scroll to the right to be on the original page (not on the new oneb)
this.divScroller.insertBefore(verticalWrapper, this.divScroller.childNodes[0]);
this.horizontalScrollview.refresh();
if (this.horizontalScrollview.currPageX