| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- $.fn.initCheckImg = function (imgdata, oldimg, width, height) {
- var imgInfo = null;
- if(imgdata && imgdata.length > 0) {
- $.extend(imgdata[0]);
- var imgstr = '';
- if (oldimg) {
- imgdata.map(function (item, index) {
- if (item.Id == oldimg.Id) {
- imgInfo = {
- Id: item.Id,
- Class: item.IconClass
- };
- $.ImgInfo = imgInfo;
- imgstr += '<div class="imgbox true" id="' + item.Id + '" style="width:' + width + ';height:' + height + '"><i class="' + item.IconClass + '"></i><span class="ifcheck"></span></div>';
- } else {
- imgstr += '<div class="imgbox" id="' + item.Id + '" style="width:' + width + ';height:' + height + '"><i class="' + item.IconClass + '"></i><span class="ifcheck"></span></div>';
- }
- });
- } else {
- imgdata.map(function (item, index) {
- if (index === 0) {
- imgInfo = {
- Id: item.Id,
- Class: item.IconClass
- };
- $.ImgInfo = imgInfo;
- imgstr += '<div class="imgbox true" id="' + item.Id + '" style="width:' + width + ';height:' + height + '"><i class="' + item.IconClass + '"></i><span class="ifcheck"></span></div>';
- } else {
- imgstr += '<div class="imgbox" id="' + item.Id + '" style="width:' + width + ';height:' + height + '"><i class="' + item.IconClass + '"></i><span class="ifcheck"></span></div>';
- }
- });
- }
-
- imgstr = '<div class="checkImgBox clearfix" style="height:100%;">' + imgstr + '</div>';
- $(this).html(imgstr);
- $(this).find('.imgbox').click(function() {
- $(this).addClass('true').siblings().removeClass('true');
- imgInfo = {
- Id: $(this).attr("id"),
- Class: $(this).find('i').attr('class')
- };
- $.extend({
- ImgInfo: imgInfo
- });
- });
- } else {
- console.log('数组参数错误');
- }
- }
|