function chooseAttr(c, s, s2, r, d, cJson, sJson, s2Json) {
if (!(this instanceof chooseAttr)) {
return new chooseAttr(c, s, s2, r, d, cJson, sJson, s2Json);
}
var instance;
chooseAttr = function () {
return instance;
};
chooseAttr.setterS = function (obj) {
$(document).unbind('click', chooseAttr.setterH);
$('.attr-setter,.add-bar').not($(obj)).removeClass('on');
$(obj).addClass('on');
var _l = $(obj).position().left, _w = $('#g-attrs').width();
if (_l <= 105) {
$(obj).find('.add-bar-con').addClass('bl').removeClass('br');
}
else if ((_w - _l) < 200) {
$(obj).find('.add-bar-con').addClass('br');
}
setTimeout(function () {
$(document).bind('click', chooseAttr.setterH);
});
return false;
};
chooseAttr.setterH = function () {
$('.attr-setter,.add-bar').removeClass('on').find('.add-bar-con').removeClass('bl br');
$(document).unbind('click', chooseAttr.setterH);
};
chooseAttr.hc = function () {//thead 选择
var _val =$(this).parents('th').find('input').val(), _td = $(this).parents('th').attr('class');
if ($(this).attr('ato') == 'toall') {
$('tbody td.' + _td + ' input:text', $('#result-con')).val(_val).blur();
}
else {
$('tbody td.' + _td + ' input:text', $('#result-con')).each(function () {
if ((/^\s*$/g).test($(this).val())) {
$(this).val(_val).blur();
}
});
}
};
chooseAttr.bc = function (attr, obj) {
var _val = $(obj).parent().parent().attr('fval'),
_td = $(obj).parents('td').attr('class');
$('tbody tr[' + attr + '=' + $(obj).parents('tr').attr(attr) + '] td.' + _td + ' input:text', $('#result-con')).val(_val).blur();
};
chooseAttr.validate = function (obj) {
var $this = $(obj),
type = $this.parent().attr('vali'),// 两种验证
regs = {
'float': /^\d+(\.\d+)?$/g,
'string': /^[\u4e00-\u9fa5a-zA-Z0-9]/g,
'int': /^\d+$/g
};
if ((/^\s*$/g).test($this.val())) {//空
if ($this.attr('show') == 'on') {
$this.parent().parent().removeClass('error')
} else {
$this.parent().parent().removeClass('error').end().next().addClass('unshow');
}
} else {//非空
if (regs[type].test($this.val())) {//验证通过
var $curInputParent = $this.parent().parent();
$curInputParent.removeClass('error').end().next().removeClass('unshow').attr('fval', $this.val());
if (!$this.parents('thead').length) {//存储修改的值 验证符合规则的数据后才能进行保存数据,否则会出现错误数据
var _fc = $this.parents('tr').attr('attrc') ? $this.parents('tr').attr('attrc') : 'none',
_fs = $this.parents('tr').attr('attrs') ? $this.parents('tr').attr('attrs') : 'none',
_fdate = instance.data.json[_fc + '|' + _fs] || {};
instance.data.json[_fc + '|' + _fs] = _fdate;
_fdate[$this.parents('td').attr('class')] = $this.val();
}
if ($curInputParent.has('font').length > 0) { //隐藏掉错误提示
$curInputParent.children("font").remove();
}
} else {//验证不通过
if ($this.attr('show') == 'on') {
$this.parent().parent().addClass('error');
} else {
$this.parent().parent().addClass('error').end().next().addClass('unshow');
}
}
}
};
//保存原型属性
chooseAttr.prototype = this;
instance = new chooseAttr();
//重置构造函数指针
instance.constructor = chooseAttr;
//所有功能
this.data = {
"colors": cJson,
"sizes": sJson,
"size2s": s2Json,
"json": d
};
this.c = $('#' + c);
this.s = $('#' + s);
this.s2 = $('#' + s2);
this.r = $('#' + r);
this.addEve('color', c);
this.addEve('size', s);
this.addEve('size2', s2);
this.txtFn();
return instance;
}
chooseAttr.prototype = {
txtFn: function () {
$('thead .a-s-con a', this.r)
.bind('click', chooseAttr.hc);
$('thead input:text', this.r).blur();
},
addEve: function (type, id) { //添加颜色和尺寸CheckBox选项事件
var that = this, con = $('#' + id);
var tempClass = '';
if (id === 'size-con') {
tempClass = '.sizeAliasInput';
} else {
tempClass = '.colorAliasInput';
}
$(document).on('blur', '#' + id + ' ' + tempClass, function () {
var _id = $(this).parent().find('input:checkbox').attr('id'), _val = $(this).val() || $(this).attr("init");
if (type === 'color') {
$("tr[attrc=" + _id + "] td.td-c .s-color").html(_val);
// 更新图片管理前面的文案
$("#picID_" + _id).find(".s-color").html(_val);
} else {
$("tr[attrs=" + _id + "] td.td-s").html(_val);
}
that.userBlur(type, _id);
$(this).val(_val);
if (that.checkAttrAlias($(this))) {
$(this).css({"color": "", "background-color": ""}); //检查通过,恢复正常样式
}
});
$(document).on('change', '#' + id + ' .i-chk', function () {
if ($(this).prop("checked")) {
$(this).parent().find('span').hide().end().next('input').attr("disabled", false).show();
that.add(type, $(this).attr('id'));
} else {
$(this).parent().find('span').show().end().next('input').attr("disabled", true).hide();
that.remove(type, $(this).attr('id'));
}
}).filter(':checked').each(function (index) {
if (type === 'color') { //此处用于过滤用户选中未提交,但刷新页面的问题。
if (that.data.colors.length) {
if ($(this).attr("checked")) {
var delColor_ = $(this).attr("id");
var temp = false;
for (var i = 0, l = that.data.colors.length; i < l; i++) {
var c_ = that.data.colors[i];
if (c_['id'] == delColor_) {
temp = true;
break;
}
}
if (!temp) {
$(this).attr("checked", false);
}
}
} else {
$(this).attr("checked", false);
}
} else {
if (that.data.sizes.length) {
if ($(this).attr("checked")) {
var delSize_ = $(this).attr("id");
var temp = false;
for (var i = 0, l = that.data.sizes.length; i < l; i++) {
var s_ = that.data.sizes[i];
if (s_['id'] == delSize_) {
temp = true;
break;
}
}
if (!temp) {
$(this).attr("checked", false);
}
}
} else {
$(this).attr("checked", false);
}
}
});
},
userBlur: function (type, id) {
var _data = this.data[type + 's'];
for (var i = 0 , l = _data.length; i < l; i++) {
if (_data[i]['id'] == id) {
_data[i]['txt1'] = $('#' + id).parent().next().val();
return;
}
}
},
arrAdd: function (type, id) { //添加SKU属性信息
var _arr = [],
_done = false,
arr = this.data[type + 's'],
_fid = $('#' + id).attr('fid'),
_temp = {},
_flag,
_isfirst = false;
for (var i = 0, l = arr.length; i < l; i++) {
if ((i > 0 ? arr[i - 1]['fid'] : -9999) < _fid && _fid < arr[i]['fid']) {
_temp = {
'fid': _fid,//用户索引
'id': id, //checkbox id
'txt1': $('#' + id).parent().next().val() //用户输入的val
};
_arr.push(_temp);
_flag = arr[i]['id'];
if (i == 0) {
_isfirst = true
}
_done = true;
}
_arr.push(arr[i]);
}
if (!_done) {
_temp = {
'fid': _fid,
'id': id,
'txt1': $('#' + id).parent().next().val()
};
_arr.push(_temp);
_flag = false;
}
this.data[type + "s"] = _arr;
return $.extend({}, _temp, {next: _flag, isfirst: _isfirst})
},
arrRemove: function (type, id) { //移除SKU属性信息
var _arr = [], arr = this.data[type + "s"];
for (var i = 0; i < arr.length; i++) {
if (arr[i]['id'] != id) {
_arr.push(arr[i]);
}
}
this.data[type + "s"] = _arr;
},
add: function (type, id) { //添加SKU销售属性信息
var spuCostPrice = $('#spuCostPrice').val(); //商品成本价
var spuPrice = $('#spuPrice').val(); //商品分销价
var spuMarketPrice = $('#spuMarketPrice').val(); //商品市场价价
if (type === 'color') {//添加颜色
if ($('tr[attrc =' + id + ']').length) {
return;
}
var _temp = this.arrAdd(type, id);
if (this.data.sizes.length) {//已经有了某尺寸
if (this.data.colors.length > 1) {//有尺寸,也有颜色
var _tr = '';
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
var k = this.data.sizes[i];
var skuCostPrice = ((this.data.json[(id + '|' + k['id'])] || {})['td-cost-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[(id + '|' + k['id'])] || {})['td-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[(id + '|' + k['id'])] || {})['td-market-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var colorAttrData = $('#' + id).attr('value');
var sizeAttrData = $('#' + k['id']).attr('value');
var costPriceId = "cost_price_" + colorAttrData + "_" + sizeAttrData;
var priceId = "price_" + colorAttrData + "_" + sizeAttrData;
var marketPriceId = "market_price_" + colorAttrData + "_" + sizeAttrData;
if (i == 0) {
_tr += '
'
+ '' + $('#' + id).next()[0].outerHTML + '' + _temp.txt1 + ' | '
+ '' + k.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
}
else {
_tr += ''
+ '' + k.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
}
}
if (_temp.next) {
$(_tr).insertBefore($('tbody tr[attrc=' + _temp.next + ']:first', this.r));
} else {
$(_tr).appendTo($('tbody', this.r));
}
}
else {//有尺寸,无颜色
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
var j = this.data.sizes[i];
if (i == 0) {
$('tr[attrs=' + j['id'] + ']').attr('attrc', id).find('.td-c').attr('rowspan', l).html($('#' + id).next()[0].outerHTML + '' + _temp.txt1 + '');
}
else {
$('tr[attrs=' + j['id'] + ']').attr('attrc', id);
$('.td-c', 'tr[attrs=' + j['id'] + ']').remove();
}
var colorAttrData = $('#' + id).attr('value');
var sizeAttrData = $('#' + j['id']).attr('value');
var tColorIds = ''; //追加颜色属性值编号
$(tColorIds).appendTo($('tr[attrs=' + j['id'] + ']').find('.td-skuName'));
$('tr[attrs=' + j['id'] + ']').find('.td-skuName').find('input[name="skuIds"]').val((this.data.json[(id + '|' + j['id'])] || {})['td-skuId'] || ''); //重新赋值SKUID
var costPriceId = "cost_price_" + colorAttrData + "_" + sizeAttrData;
$('tr[attrs=' + j['id'] + ']').find('.td-cost-price').find('input[name="skuCostPrices"]').attr('id', costPriceId); //重新赋值价格INPUT ID
var priceId = "price_" + colorAttrData + "_" + sizeAttrData;
$('tr[attrs=' + j['id'] + ']').find('.td-price').find('input[name="skuPrices"]').attr('id', priceId); //重新赋值价格INPUT ID
var marketPriceId = "market_price_" + colorAttrData + "_" + sizeAttrData;
$('tr[attrs=' + j['id'] + ']').find('.td-market-price').find('input[name="skuMarketPrices"]').attr('id', marketPriceId); //重新赋值价格INPUT ID
}
}
}
else {//无尺寸,不需组合
var skuCostPrice = ((this.data.json[(id + '|none')] || {})['td-cost-price'] || '');
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[(id + '|none')] || {})['td-price'] || '');
if (skuPrice == '' || skPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[(id + '|none')] || {})['td-market-price'] || '');
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var colorAttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + colorAttrData;
var priceId = "price_" + colorAttrData;
var marketPriceId = "market_price_" + colorAttrData;
var _tr = ''
+ '' + $('#' + id).next()[0].outerHTML + '' + _temp.txt1 + ' | '
+ ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
if (_temp.next) {
$(_tr).insertBefore($('tbody tr[attrc=' + _temp.next + ']', this.r));
} else {
$(_tr).appendTo($('tbody', this.r));
}
$(".td-s").hide();
}
$(".td-c").show();
}//添加颜色结束
else if (type === 'size') {//添加尺寸
if ($('tr[attrs =' + id + ']').length) return;
var _temp = this.arrAdd(type, id);
if (this.data.colors.length > 0) {//已有颜色
if (this.data.sizes.length > 1) {//已有尺寸
for (var i = 0, l = this.data.colors.length; i < l; i++) {
var _c = this.data.colors[i];
var skuCostPrice = ((this.data.json[(_c['id'] + '|' + id)] || {})['td-cost-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[(_c['id'] + '|' + id)] || {})['td-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[(_c['id'] + '|' + id)] || {})['td-market-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var colorAttrData = $('#' + _c['id']).attr('value');
var sizeAttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + colorAttrData + "_" + sizeAttrData;
var priceId = "price_" + colorAttrData + "_" + sizeAttrData;
var marketPriceId = "market_price_" + colorAttrData + "_" + sizeAttrData;
if (_temp.next) {//
if (_temp.isfirst) {//第一行插入
var _tr = ''
+ '' + $('#' + _c['id']).next()[0].outerHTML + '' + _c.txt1 + ' | '
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
$("td.td-c", 'tr[attrc=' + _c['id'] + ']').remove();
$(_tr).insertBefore($('tr[attrc=' + _c['id'] + ']').first());
if($("#nationallySetWareType3").attr("checked")==true) {
$(".td-stock").hide();
}
}
else {//中间插入
var _tr = ''
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
$(_tr).insertBefore($('tr[attrs=' + _temp.next + '][attrc=' + _c['id'] + ']'));
$('td:first', 'tr[attrs=' + this.data.sizes[0]['id'] + '][attrc=' + _c['id'] + ']').after('' + $('#' + _c['id']).next()[0].outerHTML + '' + _c.txt1 + ' | ').remove();
}
}
else {//
var _tr = ''
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
$('tr[attrc=' + _c['id'] + ']:last').after(_tr)
$('td:first', 'tr[attrs=' + this.data.sizes[0]['id'] + '][attrc=' + _c['id'] + ']').after('' + $('#' + _c['id']).next()[0].outerHTML + '' + _c.txt1 + ' | ').remove();
}
}
}
else {//尚无尺寸
for (var i = 0, l = this.data.colors.length; i < l; i++) {
var skuCostPrice = (this.data.json[(_cc + '|' + id)] || {})['td-cost-price'] || ''; //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = (this.data.json[(_cc + '|' + id)] || {})['td-price'] || ''; //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = (this.data.json[(_cc + '|' + id)] || {})['td-market-price'] || ''; //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var _cc = this.data.colors[i]['id'];
var colorAttrData = $('#' + _cc).attr('value');
var sizeAttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + colorAttrData + "_" + sizeAttrData;
var priceId = "price_" + colorAttrData + "_" + sizeAttrData;
var marketPriceId = "market_price_" + colorAttrData + "_" + sizeAttrData;
$('tr[attrc=' + _cc + ']').attr('attrs', id).find('.td-s').html(_temp.txt1);
$('.td-cost-price input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).val(skuCostPrice);
$('.td-price input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).val(skuPrice);
$('.td-market-price input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).val(skuMarketPrice);
if($("#nationallySetWareType3").attr("checked")==true)
$('.td-stock input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).val((this.data.json[(_cc + '|' + id)] || {})['td-stock'] || '');
$('.td-plu input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).val((this.data.json[(_cc + '|' + id)] || {})['td-plu'] || '');
$('.td-skuName', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).find('input[name="skuIds"]').val((this.data.json[(_cc + '|' + id)] || {})['td-skuId'] || ''); //新添加SKUID
$('.td-cost-price input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).attr('id', costPriceId);
$('.td-price input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).attr('id', priceId);
$('.td-market-price input', $('tr[attrc=' + this.data.colors[i]['id'] + ']')).attr('id', marketPriceId);
var tSizeIds = '';
$(tSizeIds).appendTo($('tr[attrc=' + _cc + ']').find('.td-skuName'));
}
}
}
else if (this.data.size2s.length > 0) {//已有尺寸2
if (this.data.sizes.length > 1) {//有尺寸1
var _tr = '';
for (var i = 0, l = this.data.size2s.length; i < l; i++) {
var k = this.data.size2s[i];
var skuCostPrice = ((this.data.json[(id + '|' + k['id'])] || {})['td-cost-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[(id + '|' + k['id'])] || {})['td-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[(id + '|' + k['id'])] || {})['td-market-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var sizeAttrData = $('#' + id).attr('value');
var size2AttrData = $('#' + k['id']).attr('value');
var costPriceId = "cost_price_" + sizeAttrData + "_" + size2AttrData;
var priceId = "price_" + sizeAttrData + "_" + size2AttrData;
var marketPriceId = "market_price_" + sizeAttrData + "_" + size2AttrData;
if (i == 0) {
_tr += ''
+ '' + _temp.txt1 + ' | '
+ '' + k.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
}
else {
_tr += ''
+ '' + k.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
}
}
if (_temp.next) {
$(_tr).insertBefore($('tbody tr[attrs=' + _temp.next + ']:first', this.r));
} else {
$(_tr).appendTo($('tbody', this.r));
}
} else {
for (var i = 0, l = this.data.size2s.length; i < l; i++) {
var j = this.data.size2s[i];
if (i == 0) {
$('tr[attrs2=' + j['id'] + ']').attr('attrs', id).find('.td-s').attr('rowspan', l).html( _temp.txt1);
}
else {
$('tr[attrs2=' + j['id'] + ']').attr('attrs', id);
$('.td-s', 'tr[attrs2=' + j['id'] + ']').remove();
}
var sizeAttrData = $('#' + id).attr('value');
var size2AttrData = $('#' + j['id']).attr('value');
var tSizeIds = ''; //追加尺寸1属性值编号
$(tSizeIds).appendTo($('tr[attrs2=' + j['id'] + ']').find('.td-skuName'));
$('tr[attrs2=' + j['id'] + ']').find('.td-skuName').find('input[name="skuIds"]').val((this.data.json[(id + '|' + j['id'])] || {})['td-skuId'] || ''); //重新赋值SKUID
var costPriceId = "cost_price_" + sizeAttrData + "_" + size2AttrData;
$('tr[attrs2=' + j['id'] + ']').find('.td-cost-price').find('input[name="skuCostPrices"]').attr('id', costPriceId); //重新赋值价格INPUT ID
var priceId = "price_" + sizeAttrData + "_" + size2AttrData;
$('tr[attrs2=' + j['id'] + ']').find('.td-price').find('input[name="skuPrices"]').attr('id', priceId); //重新赋值价格INPUT ID
var marketPriceId = "market_price_" + sizeAttrData + "_" + size2AttrData;
$('tr[attrs2=' + j['id'] + ']').find('.td-market-price').find('input[name="skuMarketPrices"]').attr('id', marketPriceId); //重新赋值价格INPUT ID
}
}
}
else {//尚无颜色,无尺寸2,不需组合
var skuCostPrice = ((this.data.json[('none|' + id)] || {})['td-cost-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[('none|' + id)] || {})['td-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[('none|' + id)] || {})['td-market-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var sizeAttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + sizeAttrData;
var priceId = "price_" + sizeAttrData;
var marketPriceId = "market_price_" + sizeAttrData;
var _tr = ''
+ ' | '
+ '' + _temp.txt1 + ' | '
+ ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
if (_temp.next) {
$(_tr).insertBefore($('tbody tr[attrs=' + _temp.next + ']', this.r));
} else {
$(_tr).appendTo($('tbody', this.r));
}
$(".td-c").hide();
$(".td-s2").hide();
}
$(".td-s").show();
}//添加尺寸结束
else if (type === 'size2') {//添加尺寸二
if ($('tr[attrs2 =' + id + ']').length) return;
var _temp = this.arrAdd(type, id);
if (this.data.sizes.length > 0) {//已有尺寸1
if (this.data.size2s.length > 1) {//已有尺寸2
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
var _c = this.data.sizes[i];
var skuCostPrice = ((this.data.json[(_c['id'] + '|' + id)] || {})['td-cost-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[(_c['id'] + '|' + id)] || {})['td-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[(_c['id'] + '|' + id)] || {})['td-market-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var sizeAttrData = $('#' + _c['id']).attr('value');
var size2AttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + sizeAttrData + "_" + size2AttrData;
var priceId = "price_" + sizeAttrData + "_" + size2AttrData;
var marketPriceId = "market_price_" + sizeAttrData + "_" + size2AttrData;
if (_temp.next) {//
if (_temp.isfirst) {//第一行插入
var _tr = ''
+ '' + _c.txt1 + ' | '
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
$("td.td-s", 'tr[attrs=' + _c['id'] + ']').remove();
$(_tr).insertBefore($('tr[attrs=' + _c['id'] + ']').first());
}
else {//中间插入
var _tr = ''
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
$(_tr).insertBefore($('tr[attrs2=' + _temp.next + '][attrs=' + _c['id'] + ']'));
$('td.td-s', 'tr[attrs2=' + this.data.size2s[0]['id'] + '][attrs=' + _c['id'] + ']').after('' + _c.txt1 + ' | ').remove();
}
}
else {//
var _tr = ''
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
$('tr[attrs=' + _c['id'] + ']:last').after(_tr)
$('td.td-s', 'tr[attrs2=' + this.data.size2s[0]['id'] + '][attrs=' + _c['id'] + ']').after('' + _c.txt1 + ' | ').remove();
}
}
} else {
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
var skuCostPrice = (this.data.json[(_cc + '|' + id)] || {})['td-cost-price'] || ''; //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = (this.data.json[(_cc + '|' + id)] || {})['td-price'] || ''; //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = (this.data.json[(_cc + '|' + id)] || {})['td-market-price'] || ''; //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var _cc = this.data.sizes[i]['id'];
var sizeAttrData = $('#' + _cc).attr('value');
var size2AttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + sizeAttrData + "_" + size2AttrData;
var priceId = "price_" + sizeAttrData + "_" + size2AttrData;
var marketPriceId = "market_price_" + sizeAttrData + "_" + size2AttrData;
$('tr[attrs=' + _cc + ']').attr('attrs2', id).find('.td-s2').html(_temp.txt1);
$('.td-cost-price input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val(skuCostPrice);
$('.td-price input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val(skuPrice);
$('.td-market-price input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val(skuMarketPrice);
$('.td-stock input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val((this.data.json[(_cc + '|' + id)] || {})['td-stock'] || '');
$('.td-sku-code input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val((this.data.json[(_cc + '|' + id)] || {})['td-sku-code'] || '');
$('.td-internal-code input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val((this.data.json[(_cc + '|' + id)] || {})['td-internal-code'] || '');
$('.td-plu input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).val((this.data.json[(_cc + '|' + id)] || {})['td-plu'] || '');
$('.td-skuName', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).find('input[name="skuIds"]').val((this.data.json[(_cc + '|' + id)] || {})['td-skuId'] || ''); //新添加SKUID
$('.td-cost-price input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).attr('id', costPriceId);
$('.td-price input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).attr('id', priceId);
$('.td-market-price input', $('tr[attrs=' + this.data.sizes[i]['id'] + ']')).attr('id', marketPriceId);
var tSizeIds = '';
$(tSizeIds).appendTo($('tr[attrs=' + _cc + ']').find('.td-skuName'));
}
}
} else { //尚无尺寸1,不需组合
var skuCostPrice = ((this.data.json[('none|' + id)] || {})['td-cost-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuCostPrice == '' || skuCostPrice == null) {
skuCostPrice = spuCostPrice;
}
var skuPrice = ((this.data.json[('none|' + id)] || {})['td-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuPrice == '' || skuPrice == null) {
skuPrice = spuPrice;
}
var skuMarketPrice = ((this.data.json[('none|' + id)] || {})['td-market-price'] || ''); //默认将商品价格赋值给SKU价格
if (skuMarketPrice == '' || skuMarketPrice == null) {
skuMarketPrice = spuMarketPrice;
}
var size2AttrData = $('#' + id).attr('value');
var costPriceId = "cost_price_" + size2AttrData;
var priceId = "price_" + size2AttrData;
var marketPriceId = "market_price_" + size2AttrData;
var _tr = ''
+ ' | '
+ '' + _temp.txt1 + ' | '
+ '元 | '
+ '元 | '
+ '元 | '
+ '件 | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ ' | '
+ '
';
if (_temp.next) {
$(_tr).insertBefore($('tbody tr[attrs=' + _temp.next + ']', this.r));
} else {
$(_tr).appendTo($('tbody', this.r));
}
$(".td-s").hide();
}
$(".td-s2").show();
}
this.r.show();
},
remove: function (type, id) {
if (type === 'color') {//移除颜色
if (this.data.colors.length > 1) {//多个颜色,直接移除
$('tr[attrc=' + id + ']', this.r).remove();
} else {//单一颜色
if (this.data.sizes.length) {//单一颜色有尺寸,清空尺寸单元格
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
//this.data.sizes[i]
var m = this.data.sizes[i]['id'];
if ($('.td-c', 'tr[attrs=' + m + ']').length) {//第一行
$('.td-c', 'tr[attrs=' + m + ']').after(' | ').remove();
} else {//非第一行
$(' | ').prependTo($('tr[attrs=' + m + ']'));
}
$(".td-c").hide();
$('tr[attrs=' + m + ']').removeAttr('attrc');
$('tr[attrs=' + m + ']').find('.td-skuName').find('input[name="skuColorIds"]').remove(); //新增加称除颜色input属性值
$('tr[attrs=' + m + ']').find('.td-skuName').find('input[name="skuIds"]').val((this.data.json[('none|' + m)] || {})['td-skuId'] || '');
var sizeAttrData = $('#' + m).attr('value');
var costPriceId = "cost_price_" + sizeAttrData;
var priceId = "price_" + sizeAttrData;
var marketPriceId = "market_price_" + sizeAttrData;
$('tr[attrs=' + m + ']').find('.td-cost-price').find('input[name="skuCostPrices"]').attr('id', costPriceId);
$('tr[attrs=' + m + ']').find('.td-price').find('input[name="skuPrices"]').attr('id', priceId);
$('tr[attrs=' + m + ']').find('.td-market-price').find('input[name="skuPrices"]').attr('id', marketPriceId);
}
;
} else {//单一颜色无尺寸,直接移除
$('tr[attrc=' + id + ']', this.r).remove();
}
}
}
else if (type == 'size') {//移除尺寸
if (this.data.colors.length) {//有颜色
if (this.data.sizes.length > 1) {//有颜色,且多个尺寸
for (var i = 0, l = this.data.colors.length; i < l; i++) {
var y = this.data.colors[i], ytr = $('tr[attrc=' + y['id'] + ']').first();
if (ytr.attr('attrs') == id) {
$('' + $('#' + y['id']).next()[0].outerHTML + '' + y['txt1'] + ' | ').prependTo(ytr.next());
ytr.remove();
} else {
ytr.find('td:first').attr('rowspan', (this.data.sizes.length - 1));
$('tr[attrs=' + id + '][attrc=' + y['id'] + ']', this.r).remove();
}
}
}
else {//有颜色,一个尺寸
for (var i = 0, l = this.data.colors.length; i < l; i++) {
$('tr[attrc=' + this.data.colors[i]['id'] + ']').removeAttr('attrs').find('.td-s').empty();
$(".td-s").hide();
var tempColorId = this.data.colors[i]['id']; //新增加称除颜色input属性值
$('tr[attrc=' + tempColorId + ']').find('.td-skuName').find('input[name="skuSizeIds"]').remove();
$('tr[attrc=' + tempColorId + ']').find('.td-skuName').find('input[name="skuIds"]').val((this.data.json[(tempColorId + '|none')] || {})['td-skuId'] || '');
var colorAttrData = $('#' + tempColorId).attr('value');
var costPriceId = "cost_price_" + colorAttrData;
$('tr[attrc=' + tempColorId + ']').find('.td-cost-price').find('input[name="skuCostPrices"]').attr('id', costPriceId);
var priceId = "price_" + colorAttrData;
$('tr[attrc=' + tempColorId + ']').find('.td-price').find('input[name="skuPrices"]').attr('id', priceId);
var marketPriceId = "market_price_" + colorAttrData;
$('tr[attrc=' + tempColorId + ']').find('.td-market-price').find('input[name="skuMarketPrices"]').attr('id', marketPriceId);
}
}
}
else if (this.data.size2s.length) {//有尺寸2
if (this.data.sizes.length > 1) {//多个尺寸1,直接移除
$('tr[attrs=' + id + ']', this.r).remove();
} else {//单一尺寸1
if (this.data.sizes.length) {//单一颜色有尺寸,清空尺寸单元格
for (var i = 0, l = this.data.size2s.length; i < l; i++) {
var m = this.data.size2s[i]['id'];
if ($('.td-s', 'tr[attrs2=' + m + ']').length) {//第一行
$('.td-s', 'tr[attrs2=' + m + ']').after(' | ').remove();
} else {//非第一行
$(' | ').prependTo($('tr[attrs2=' + m + ']'));
}
$(".td-s").hide();
$('tr[attrs2=' + m + ']').removeAttr('attrs');
$('tr[attrs2=' + m + ']').find('.td-skuName').find('input[name="skuSizeIds"]').remove(); //新增加称除颜色input属性值
$('tr[attrs2=' + m + ']').find('.td-skuName').find('input[name="skuIds"]').val((this.data.json[('none|' + m)] || {})['td-skuId'] || '');
var size2AttrData = $('#' + m).attr('value');
var costPriceId = "cost_price_" + size2AttrData;
var priceId = "price_" + size2AttrData;
var marketPriceId = "market_price_" + size2AttrData;
$('tr[attrs=' + m + ']').find('.td-cost-price').find('input[name="skuCostPrices"]').attr('id', costPriceId);
$('tr[attrs=' + m + ']').find('.td-price').find('input[name="skuPrices"]').attr('id', priceId);
$('tr[attrs=' + m + ']').find('.td-market-price').find('input[name="skuPrices"]').attr('id', marketPriceId);
}
;
} else {//单一尺寸1无尺寸2,直接移除
$('tr[attrs=' + id + ']', this.r).remove();
}
}
} else {//无颜色、无尺寸2
$('tr[attrs=' + id + ']', this.r).remove();
}
}
else if (type == 'size2') {
if (this.data.sizes.length) {//有尺寸1
if (this.data.size2s.length > 1) {//有尺寸1,尺寸2
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
var y = this.data.sizes[i], ytr = $('tr[attrs=' + y['id'] + ']').first();
if (ytr.attr('attrs2') == id) {
$('' + y['txt1'] + ' | ').prependTo(ytr.next());
ytr.remove();
} else {
ytr.find('td.td-s').attr('rowspan', (this.data.size2s.length - 1));
$('tr[attrs2=' + id + '][attrs=' + y['id'] + ']', this.r).remove();
}
}
}
else {//有尺寸1,无尺寸2
for (var i = 0, l = this.data.sizes.length; i < l; i++) {
$('tr[attrs=' + this.data.sizes[i]['id'] + ']').removeAttr('attrs2').find('.td-s2').empty();
$(".td-s2").hide();
var tempSizeId = this.data.sizes[i]['id'];
$('tr[attrs=' + tempSizeId + ']').find('.td-skuName').find('input[name="skuSize2Ids"]').remove();
$('tr[attrs=' + tempSizeId + ']').find('.td-skuName').find('input[name="skuIds"]').val((this.data.json[(tempSizeId + '|none')] || {})['td-skuId'] || '');
var sizeAttrData = $('#' + tempSizeId).attr('value');
var costPriceId = "cost_price_" + sizeAttrData;
$('tr[attrs=' + tempSizeId + ']').find('.td-cost-price').find('input[name="skuCostPrices"]').attr('id', costPriceId);
var priceId = "price_" + sizeAttrData;
$('tr[attrs=' + tempSizeId + ']').find('.td-price').find('input[name="skuPrices"]').attr('id', priceId);
var marketPriceId = "market_price_" + sizeAttrData;
$('tr[attrs=' + tempSizeId + ']').find('.td-market-price').find('input[name="skuMarketPrices"]').attr('id', marketPriceId);
}
}
}
else {//无尺寸1
$('tr[attrs2=' + id + ']', this.r).remove();
}
}
this.arrRemove(type, id);
if ((this.data.colors.length + this.data.sizes.length + this.data.size2s.length) <= 0) {
this.r.hide();
}
},
checkAttrAlias: function (inputer) { //验证销售属性别名
var v = inputer.val();
var msg = "";
if (v.length > 25) {
msg = "销售属性自定义名称过长,请调整为25字符以内。";
}
if (!checkAttributeValue(v)) {
msg = "暂时只支持! @ # $ % & + - * / \\ _ ( ) = . 16种特殊字符,请重新输入。";
}
var repeated = false;
var inputers = $("");
if (inputer.hasClass("colorAliasInput")) {
inputers = $(".colorAliasInput").not(inputer);
} else if (inputer.hasClass("sizeAliasInput")) {
inputers = $(".sizeAliasInput").not(inputer);
}
inputers.each(function () {
if ($(this).val() == v) {
repeated = true;
}
});
if (repeated) {
msg = "注意:销售属性值名称有重复,请重新进行自定义!";
}
if (msg) {
alert(msg);
inputer.css({"color": "red", "background-color": "#FFF4D7"});
setTimeout('$("#' + inputer.attr("id") + '").focus()', 200);
return false;
}
return true;
}
};
function uploadImgs(o) {
this.o = $(o);
}
uploadImgs.prototype = {
init: function (cookieDomain) {
var _this = this;
$('.ftab-t li', this.o).bind('click', function () {
if ($(this).hasClass("close_btn")) { // 关闭按钮标签被点击, 关闭自己
$(".g-imgs.open").find('.upload-btn').click();
} else if ($(this).hasClass("next_r_btn")) { // 设置下一行图片按钮被点击
var nextRow = $(".g-imgs.open").next();
if (nextRow.length > 0) {
nextRow.find('.upload-btn').click();
}
} else { // 普通标签被点击,切换选项卡
$(this).addClass('curr').siblings().removeClass('curr');
$($(this).attr('fid')).show().siblings('.ftab-con').hide();
// 如果有cookie支持, 将选择结果在cookie中保持30天
if (jQuery.cookie) {
jQuery.cookie.json = true;
jQuery.cookie("_cut_", {
"v": $(this).attr("fid") // cut == Current Upload box Tab
}, {
expires: 30,
path: "/ware/",
domain: cookieDomain
});
}
}
});
// 如果cookie中有上次的标签选择记录, 则使用上次的选择结果
if (jQuery.cookie) {
jQuery.cookie.json = true;
try {
var cut = jQuery.cookie("_cut_");
if (cut) {
$(".ftab-t li[fid=" + cut.v + "]").click();
}
} catch (e) {
}
}
}
};
function ctrlImgs(o) {
this.o = $(o);
}
ctrlImgs.prototype = {
init: function () {
var _this = this;
/**
* 图片框上的hover效果
*/
$('.g-m li', this.o).hover(function () {
if ($(".p-img", this).html()) { // 位置上有图
$(this).addClass('hover');
} else { // 位置上无图
if (!$(this).parents(".g-imgs").hasClass("open")) { // 位置无图且当前行未展开时,提示 点击可展开
$(this).css({
cursor: "pointer"
}).attr("title", "点击,展开图片上传");
}
}
}, function () {
$(this).removeClass('hover');
$(this).css({
cursor: "default"
}).attr("title", "");
});
this.o.bind('click', function (e) {
var _t = $(e.target), _that = this;
/**
* 交换两个图片的位置
* @param sourceImgBox 原图片框
* @param targetImgBox 目标图片框
*/
function swapImg(sourceImgBox, targetImgBox) {
var sourceImgObj = sourceImgBox.html();
sourceImgBox.html(targetImgBox.html());
targetImgBox.html(sourceImgObj);
var sourceLoadError = sourceImgBox.hasClass("imgLoadError");
var targetLoadError = targetImgBox.hasClass("imgLoadError");
if (sourceLoadError) {
targetImgBox.addClass("imgLoadError");
} else {
targetImgBox.removeClass("imgLoadError");
}
if (targetLoadError) {
sourceImgBox.addClass("imgLoadError");
} else {
sourceImgBox.removeClass("imgLoadError");
}
}
/**
* 点击图片框
*/
if (_t.hasClass("p-img")) {
// 在当前行展开上传控件
if (!$(this).hasClass('open')) {
$(this).find('.upload-btn').click();
}
}
/**
* 点击图片上传
*/
if (_t.hasClass('upload-btn') || _t.parent().hasClass('upload-btn')) {
// 显示/隐藏 图片上传控件
toggleUploadBox($(this), true);
}
/**
* 点击左移
*/
if (_t.hasClass('to-l')) {
var _prev = _t.parent().parent().prev(); // 前一张图的li
if (_prev.length) {
if (_prev.hasClass("waiting")) {
return;
}
// 移除错误状态(如果有)
removeErrorState(_prev);
// 交换图片
swapImg(_t.parent().prev(), _prev.find('.p-img'));
}
// 如果移动完了之后,本位置,已经没有图片了,则将图片操作栏隐藏
if (_t.parents("li").find(".p-img img").length <= 0) {
_t.parents("li").removeClass('hover');
}
}
/**
* 点击右移
*/
if (_t.hasClass('to-r')) {
var _next = _t.parent().parent().next();
if (_next.length) {
if (_next.hasClass("waiting")) {
return;
}
// 移除错误状态(如果有)
removeErrorState(_next);
// 交换图片
swapImg(_t.parent().prev(), _next.find('.p-img'));
}
// 如果移动完了之后,本位置,已经没有图片了,则将图片操作栏隐藏
if (_t.parents("li").find(".p-img img").length <= 0) {
_t.parents("li").removeClass('hover');
}
}
/**
* 点击移除
*/
if (_t.hasClass('del')) {
// 移除图片空间中该图片的选中状态
var imgid = _t.parent().prev('.p-img').children("img").attr("imgid");
$("#imgSpaceImgs").find("img[imgid=" + imgid + "]").parent("li").removeClass('sel');
// 移除图片
_t.parent().prev('.p-img').removeClass("imgLoadError").empty();
// 在当前行展开上传控件
if (!$(this).hasClass('open')) {
$(this).find('.upload-btn').click();
}
// 如果移动完了之后,本位置,已经没有图片了,则将图片操作栏隐藏
if (_t.parents("li").find(".p-img img").length <= 0) {
_t.parents("li").removeClass('hover');
}
// ajax删除图片,不包括编辑状态下删除已存在的图片,避免刷洗以后图片丢失, By LCN
$.ajax({
url: "/catalog/item-img/delete?id=" + imgid,
type: "get",
success: function (msg2) {
}
});
}
/**
* 点击使用商品图片
*/
if (_t.hasClass('fbtn')) {
$('#picID_zero').find(".p-img").each(function (i) {
removeErrorState($($('.p-img', _that)[i]).parents("li"));
$($('.p-img', _that)[i]).removeClass("imgLoadError").html($(this).html());
});
}
});
}
};
$.fn.extend({
uploadImgs: function (cookieDomain) {
this.each(function () {
var _o = new uploadImgs(this);
_o.init(cookieDomain);
});
},
ctrlImgs: function () {
this.each(function () {
var _o = new ctrlImgs(this);
_o.init();
});
}
});
/**
* 移除商品图片上的错误状态
* @param imgBox 图片框
*/
function removeErrorState(imgBox) {
imgBox.removeClass("error").find(".error-txt").remove();
}
/**
* 初始化商品图片部分界面
*/
function initImgPartOfPage(img10Url, cookieDomain) {
// 上传控件初始化
$('#uploadbox').uploadImgs(cookieDomain);
$('.g-imgs').ctrlImgs();
// 默认第一行上传控件展开
toggleUploadBox($("#picID_zero"), false);
// (编辑商品时)如果已经有图片,将图片初始化
$(".imgInput").each(function (i, o) {
var wareImg = $(this).val().split(",");
var rowId = (wareImg[2] == "0000000000") ? "picID_zero" : "picID_checkColor_" + wareImg[2];
$("#" + rowId + " .g-m .p-img").eq(wareImg[0] - 1).empty()
.append('
');
});
}
/**
* 图片加载出错时,显示小joy图片
* @param img
*/
function loadImgError(img) {
$(img).hide().parent().addClass("imgLoadError");
}
/**
* 在某一行 显示/隐藏 图片上传控件
* @param gImg 某一行图片
* @param keepInView 是否让展开状态的行保持在视野内
*/
function toggleUploadBox(gImg, keepInView) {
if (!gImg.hasClass('open')) { // 展开
gImg.addClass('open').siblings().removeClass('open');
var _pos = gImg.position();
$('#uploadbox').css({
'top': _pos.top + 100 + $('#pic-con').scrollTop(),
'display': 'block'
});
if (keepInView) {
// 保持打开状态的行在视野内
var rowId = "#" + gImg.attr("id");
window.location.href = window.location.href.substring(0, window.location.href.indexOf("#")) + rowId;
}
} else { // 关闭
gImg.removeClass('open').siblings().removeClass('open');
$('#uploadbox').css({
'top': -9999,
'display': 'none'
});
}
}