作者 Karson

!96 修改原有表格中图片新窗口打开预览为layer相册预览

Merge pull request !96 from 壹世朱名/master
@@ -1328,6 +1328,9 @@ EOD; @@ -1328,6 +1328,9 @@ EOD;
1328 if (in_array($datatype, ['set'])) { 1328 if (in_array($datatype, ['set'])) {
1329 $html .= ", operate:'FIND_IN_SET'"; 1329 $html .= ", operate:'FIND_IN_SET'";
1330 } 1330 }
  1331 + if (in_array($formatter, ['image','images'])) {
  1332 + $html .= ", events: Table.api.events.image";
  1333 + }
1331 if ($itemArr && !$formatter) { 1334 if ($itemArr && !$formatter) {
1332 $formatter = 'normal'; 1335 $formatter = 'normal';
1333 } 1336 }
@@ -366,6 +366,23 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table @@ -366,6 +366,23 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
366 } 366 }
367 ); 367 );
368 } 368 }
  369 + },//单元格图片预览
  370 + image: {
  371 + 'click .img-center': function (e, value, row, index) {
  372 + data = [];
  373 + value= value.split(",");
  374 + $.each(value, function (index, value) {
  375 + data.push({
  376 + src: Fast.api.cdnurl(value),
  377 + });
  378 + });
  379 + layer.photos({
  380 + photos: {
  381 + "data": data
  382 + },
  383 + anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  384 + });
  385 + },
369 } 386 }
370 }, 387 },
371 // 单元格数据格式化 388 // 单元格数据格式化
@@ -381,7 +398,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table @@ -381,7 +398,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
381 image: function (value, row, index) { 398 image: function (value, row, index) {
382 value = value ? value : '/assets/img/blank.gif'; 399 value = value ? value : '/assets/img/blank.gif';
383 var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center'; 400 var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
384 - return '<a href="' + Fast.api.cdnurl(value) + '" target="_blank"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>'; 401 + return '<a href="javascript:void(0)" target="_blank"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>';
385 }, 402 },
386 images: function (value, row, index) { 403 images: function (value, row, index) {
387 value = value === null ? '' : value.toString(); 404 value = value === null ? '' : value.toString();
@@ -390,7 +407,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table @@ -390,7 +407,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
390 var html = []; 407 var html = [];
391 $.each(arr, function (i, value) { 408 $.each(arr, function (i, value) {
392 value = value ? value : '/assets/img/blank.gif'; 409 value = value ? value : '/assets/img/blank.gif';
393 - html.push('<a href="' + Fast.api.cdnurl(value) + '" target="_blank"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>'); 410 + html.push('<a href="javascript:void(0)" target="_blank"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>');
394 }); 411 });
395 return html.join(' '); 412 return html.join(' ');
396 }, 413 },