add site
This commit is contained in:
128
Site/Inspection/js/modules/templates/templatepicture.js
Normal file
128
Site/Inspection/js/modules/templates/templatepicture.js
Normal file
@ -0,0 +1,128 @@
|
||||
define(['common'], function (Common) {
|
||||
|
||||
var dialogPicture = null;
|
||||
var ls = function () {
|
||||
};
|
||||
|
||||
ls.prototype.getDialogPicture = function () {
|
||||
if (!dialogPicture)
|
||||
dialogPicture = new $pictureselector();
|
||||
return dialogPicture;
|
||||
}
|
||||
|
||||
var $pictureselector = function () {
|
||||
this.title = GetTextByKey("P_IPT_SELECTPICTURE", 'Select Picture');
|
||||
this.companyId = null;
|
||||
this.exceptSource = null;
|
||||
this.onOK = null;
|
||||
this.onDialogClosed = null;
|
||||
};
|
||||
|
||||
(function () {
|
||||
var __proto = $pictureselector.prototype;
|
||||
|
||||
function initGrid(parent) {
|
||||
var grid = new GridView(parent);
|
||||
var columns = [];
|
||||
columns.push({
|
||||
// checkbox
|
||||
name: 'check',
|
||||
key: 'Selected',
|
||||
width: 30,
|
||||
align: 'center',
|
||||
sortable: false,
|
||||
allcheck: true,
|
||||
type: 3
|
||||
});
|
||||
columns.push({
|
||||
key: 'Name',
|
||||
caption: GetTextByKey("P_IPT_NAME", 'Name'),
|
||||
width: 200
|
||||
});
|
||||
//grid.canMultiSelect = true;
|
||||
grid.columns = columns;
|
||||
grid.init();
|
||||
|
||||
this.gridctrl = grid;
|
||||
}
|
||||
|
||||
function createDialog() {
|
||||
var dialog = $('<div class="dialog" style="display: none; width: 602px; height: 380px;z-index:1;">');
|
||||
|
||||
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
|
||||
title.append($('<span class="title"></span>').text(this.title));
|
||||
title.append('<em class="dialog-close"></em>');
|
||||
|
||||
var content = $('<div class="dialog-content"></div>').appendTo(dialog);
|
||||
|
||||
this.listdiv = $('<div style="width: 580px; height: 290px;margin-bottom:5px;"></div>').appendTo(content);
|
||||
|
||||
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
|
||||
$('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction);
|
||||
//$('<input type="button" value="' + GetTextByKey("P_IPT_COPY", "Copy") + '" />').click(onCopyClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<input type="button" value="' + GetTextByKey("P_IPT_ADDASLINK", "Add as Link") + '" />').click(onLinkClick.bind(this)).appendTo(dialogFunction);
|
||||
$('<div class="clear"></div>').appendTo(dialogFunction);
|
||||
|
||||
$('<div class="maskbg" style="display: none;z-index:1;"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
|
||||
|
||||
// init
|
||||
initGrid.call(this, this.listdiv);
|
||||
$(document.body).append(dialog);
|
||||
var mask = $('<div class="maskbg"></div>');
|
||||
dialog.data('mask', mask);
|
||||
dialog.before(mask);
|
||||
|
||||
var _this = this;
|
||||
dialog.dialog(function () {
|
||||
if (_this.onDialogClosed)
|
||||
_this.onDialogClosed();
|
||||
if (dialog.data('mask'))
|
||||
dialog.data('mask').hide();
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
||||
__proto.showSelector = function () {
|
||||
if (!this.dialog) {
|
||||
this.dialog = createDialog.call(this);
|
||||
}
|
||||
|
||||
if (this.dialog.data('mask'))
|
||||
this.dialog.data('mask').show();
|
||||
this.dialog.showDialog(false);
|
||||
this.gridctrl.setData([]);
|
||||
showTemplatePictures.call(this);
|
||||
};
|
||||
|
||||
function showTemplatePictures() {
|
||||
//currenttemplate is defined in Inspection.aspx, it is a global variable
|
||||
if (currenttemplate && currenttemplate.StaticPictures && currenttemplate.StaticPictures.length > 0) {
|
||||
var items = [];
|
||||
for (var i = 0; i < currenttemplate.StaticPictures.length; i++) {
|
||||
var it = currenttemplate.StaticPictures[i];
|
||||
it.Selected = false;
|
||||
items.push({ Values: it });
|
||||
}
|
||||
this.gridctrl.setData(items);
|
||||
}
|
||||
}
|
||||
|
||||
function onCopyClick() {
|
||||
//var index = this.gridctrl.selectedIndex;
|
||||
this.onOK && this.onOK(this.gridctrl.source, true);
|
||||
if (this.dialog.data('mask'))
|
||||
this.dialog.data('mask').hide();
|
||||
this.dialog.hideDialog();
|
||||
}
|
||||
|
||||
function onLinkClick() {
|
||||
//var index = this.gridctrl.selectedIndex;
|
||||
this.onOK && this.onOK(this.gridctrl.source, false);
|
||||
if (this.dialog.data('mask'))
|
||||
this.dialog.data('mask').hide();
|
||||
this.dialog.hideDialog();
|
||||
}
|
||||
})();
|
||||
|
||||
return ls;
|
||||
});
|
Reference in New Issue
Block a user