var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var ASC; (function (ASC) { var ui; (function (ui_1) { function getFocusedDialog() { var $ds = $j('div.ui-dialog,div.yui-dialog'); if ($ds.length != 0) return $ds.last().get(0); return null; } ui_1.getFocusedDialog = getFocusedDialog; function autocomplete_data2items(data) { var items = []; for (var i = 0; i < data.length; i++) { var item = ASC.clone(data[i]); var l = '' + item.name; if (item.code) l += ' ' + item.code; if (item.code2) l += ' ' + item.code2; item.label = l; items.push(item); } return items; } ui_1.autocomplete_data2items = autocomplete_data2items; function autocomplete_renderItem(ul, item) { var $li = $j("
  • ") .append("" + item.label + "") .appendTo(ul); } }); var items = []; if (ASC.type(source) == 'object') { for (var i in source) { items.push({ value: source[i], label: i }); } } return $j(input).autocomplete($j.extend({ minLength: 0, autoFocus: true, source: items.length ? items : source, }, options)); } ui_1.addAutoComplete = addAutoComplete; function autocapitalize(tf) { $j(tf).on('DOMAttrModified textInput input keypress paste focus', function (e) { var ov = $j(this).val(); var nv = ov.slice(0, 1).toUpperCase() + ov.slice(1); if (nv != ov) $j(this).val(nv); }); } ui_1.autocapitalize = autocapitalize; function wordwrap(str, int_width, str_break, cut) { var m = ((arguments.length >= 2) ? arguments[1] : 75); var b = ((arguments.length >= 3) ? arguments[2] : '\n'); var c = ((arguments.length >= 4) ? arguments[3] : false); var i, j, l, s, r; str += ''; if (m < 1) { return str; } for (i = -1, l = (r = str.split(/\r\n|\n|\r/)) .length; ++i < l; r[i] += s) { for (s = r[i], r[i] = ''; s.length > m; r[i] += s.slice(0, j) + ((s = s.slice(j)) .length ? b : '')) { j = c == 2 || (j = s.slice(0, m + 1) .match(/\S*(\s)?$/))[1] ? m : j.input.length - j[0].length || c == 1 && m || j.input.length + (j = s.slice(m) .match(/^\S*/))[0].length; } } return r.join('\n'); } function getTextWithIcon(text, config, text_allowHtml) { if (text_allowHtml === void 0) { text_allowHtml = false; } var label = ''; if (config.icon) label = " "; label += text_allowHtml ? text : ASC.escapeHTML(text); if (config.iconRight) label += " "; return label; } ui_1.getTextWithIcon = getTextWithIcon; var Dialog = (function () { function Dialog(options) { var _this = this; var doptions = $j.extend({ modal: true, minHeight: 50, maxWidth: $j(window).innerWidth(), width: 'auto', destroyOnClose: true }, options); doptions.buttons = [{}]; this.$div = $j("
    ").dialog(doptions); this.$div.parent().css('overflow', 'visible'); if (doptions.destroyOnClose) { this.$div.on('dialogclose', function () { if (_this.dlg_jsc) { _this.dlg_jsc.ASC_cn(); } _this.$div.dialog('destroy'); _this.$div.detach(); }); } this.$bd = $j("
    ").appendTo(this.$div); this.$ft = this.$div.siblings(".ui-dialog-buttonpane"); this.body = this.$bd.get(0); this.footer = this.$ft.get(0); this.cfg = { queueProperty: function (p, v) { switch (p) { case 'width': _this.$div.dialog("option", "width", parseInt(v)); break; case 'buttons': _this.setButtons(v); break; default: debugger; } } }; this.cfg.queueProperty('buttons', options.buttons); } Dialog.prototype.setButtons = function (buttons) { var _this = this; if (buttons === void 0) { buttons = []; } var $container = this.$ft.find('.ui-dialog-buttonset').html(''); for (var i = 0; i < buttons.length; i++) { var config = buttons[i]; if (ASC.isString(config)) { config = { text: config, onclick: function () { _this.hide(); }, type: config.toLowerCase() == 'ok' ? 'default' : '' }; } $j.extend(config, { container: $container, label: config.text, }); if (config.onclick) { if (typeof config.onclick == 'function') config.onclick = { fn: config.onclick, scope: this }; else config.onclick.scope = this; } new Button(config); } }; Dialog.prototype.setBody = function (el) { this.$bd.html(''); this.$bd.append(el); }; Dialog.prototype.appendToFooter = function (el) { this.$ft.append(el); }; Dialog.prototype.center = function () { this.$div.dialog("option", "position", { my: "center", at: "center", of: window }); var max = this.$div.dialog("option", "maxWidth"); if (this.$div.dialog("option", "width") > max) { this.$div.dialog("option", "width", max); } this.$div.dialog("widget").draggable("option", "containment", "none"); }; Dialog.prototype.setHeader = function (s) { this.$div.dialog("option", "title", s); }; Dialog.prototype.show = function () { this.$div.dialog('open'); }; Dialog.prototype.hide = function () { if (this.$div.is(":visible")) this.$div.dialog('close'); }; return Dialog; }()); ui_1.Dialog = Dialog; var Button = (function () { function Button(options) { var _this = this; this.onclick = null; this.radio_field = null; this.radio_value = ''; var div = $j('
    ').appendTo(options.container); this.$element = $j("