var productListHandler = function() {
this._next_page = null;
this._max_count = null;
this._base_url = null;
this._order = null;
this._loading_btn = null;
this._tax_rule = 1;
this._tax = 8;
this._objTimesaleses = new Array();
this._timesales_idx = 0;
this._default_timesales_layout = 'タイムセール終了まで
{dn}{dl}と{hnn}時間{mnn}分{snn}秒 {desc}';
this._default_msg_before_start = '{start_date}からタイムセール';
this._default_msg_after_stoped = 'タイムセールは終了しました。';
this._default_max_count = 10;
this._class1 = 'listphoto';
this._class2 = 'listrightblock';
this._name = null;
if (window.location.host.match(/.*(tyi|ss).*/)) this._tyijp_flg = true;
};
productListHandler.prototype = {
initialize:function() {
this._setBtnText();
var objTemplateLoader = new templateLoader(1);
var ref = this;
objTemplateLoader.setCallback(function(res) { ref._setTimesalesTemplate('layout' , res); });
objTemplateLoader.load('timesales/countdown_layout');
objTemplateLoader.setCallback(function(res) { ref._setTimesalesTemplate('before' , res); });
objTemplateLoader.load('timesales/msg_before_start')
objTemplateLoader.setCallback(function(res) { ref._setTimesalesTemplate('after' , res); });
objTemplateLoader.load('timesales/msg_after_stoped');
objTemplateLoader.setCallback(function(res) { ref._setPriceFormat(res); });
objTemplateLoader.load('price_format');
this._checkLineMax();
},
setName:function(name){
this._name = name;
},
setPage:function(page) {
this._next_page = page + 1;
},
setMaxCountPerPage:function(max) {
this._max_count = max ? max : this._default_max_count;
},
setBaseUrl:function(base_url) {
this._base_url = base_url;
},
setOrder:function(order) {
this._order = order;
},
setMode:function(mode) {
this._mode = mode;
},
setPhotoAreaClass:function(className) {
this._class1 = className ? className : this._class1;
},
setListRightBlockClass:function(className) {
this._class2 = className ? className : this._class2;
},
setLoadingBtn:function(btn) {
this._loading_btn = btn;
var ref = this;
this._loading_btn.unbind('click');
if ($('.product_list_div').size() < this._max_count) {
this._loading_btn.remove();
}
else {
this._loading_btn.bind('click' , function(e) {
ref.load();
});
}
},
load:function() {
this._insertLoading();
var params = {
mode:this._mode,
pageno:this._next_page,
name:this._name,
orderby:this._order,
disp_number:this._max_count,
ajax:1
};
var ref = this;
$.ajax({
url:this._base_url,
data:params,
dataType:'json',
type:'POST',
cache:false,
success:function(res) { ref._callback(res); },
error:function(res) {
alert(res.responseText);
}
});
},
_insertLoading:function() {
this._loading_btn.html($(''));
},
_callback:function(res) {
var productList = res.result;
var linemax = res.linemax;
this._response_count = productList.length;
var i = 0;
var div_type = 0;
var last_elm_class = '';
for (idx in productList) {
var product = productList[idx];
var div = $('.product_list_div:last').clone();
if (this._tyijp_flg == true)
{
div_type = (idx + 1) % 3;
div.removeClass('listarea01').removeClass('listarea02');
if (div_type == 0) {
div.addClass('listarea02');
}
else {
div.addClass('listarea01');
}
div.children('ul').children('li').children('.' + this._class1).children('a').attr('href' , '/smp/product/detail/' + product['product_id']);
div.children('ul').children('li').children('.' + this._class1).children('a').children('img').attr('src' , '/upload/save_image//' + product['main_list_image']);
div.children('ul').children('li').children('.' + this._class2).children('a').attr('href' , '/smp/product/detail/' + product['product_id']);
if ((product['name'].length * 2) > 41) {
product['name'] = product['name'].substring(0 , 20) + '...';
}
div.children('ul').children('li').children('.' + this._class2).children('a').children('h3').text(product['name']);
if (div.children('ul').children('li').children('.' + this._class2).children('a').children('.count_down_box').is('.count_down_box')) {
div.children('ul').children('li').children('.' + this._class2).children('a').children('.count_down_box').attr('id' , 'count_down_' + product['product_id']);
}
else {
div.children('ul').children('li').children('.' + this._class2).children('a').children('h3').after($('