"use strict"; /** * EGroupware eTemplate2 - JS Diff object * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package etemplate * @subpackage api * @link http://www.egroupware.org * @author Nathan Gray * @copyright Nathan Gray 2012 * @version $Id$ */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.et2_diff = void 0; /*egw:uses /vendor/bower-asset/jquery/dist/jquery.js; /vendor/bower-asset/jquery-ui/jquery-ui.js; /vendor/bower-asset/diff2html/dist/diff2html.min.js; et2_core_valueWidget; */ var et2_core_widget_1 = require("./et2_core_widget"); var et2_core_inheritance_1 = require("./et2_core_inheritance"); var et2_core_valueWidget_1 = require("./et2_core_valueWidget"); /** * Class that displays the diff between two [text] values * * @augments et2_valueWidget */ var et2_diff = /** @class */ (function (_super) { __extends(et2_diff, _super); /** * Constructor */ function et2_diff(_parent, _attrs, _child) { var _this = // Call the inherited constructor _super.call(this, _parent, _attrs, et2_core_inheritance_1.ClassWithAttributes.extendAttributes(et2_diff._attributes, _child || {})) || this; _this.mini = true; // included via etemplate2.css //this.egw().includeCSS('../../../vendor/bower-asset/dist/dist2html.css'); _this.div = document.createElement("div"); jQuery(_this.div).addClass('et2_diff'); return _this; } et2_diff.prototype.set_value = function (value) { jQuery(this.div).empty(); if (typeof value == 'string') { // Diff2Html likes to have files, we don't have them if (value.indexOf('---') !== 0) { value = "--- diff\n+++ diff\n" + value; } // @ts-ignore var diff = Diff2Html.getPrettyHtml(value, this.diff_options); // var ui = new Diff2HtmlUI({diff: diff}); // ui.draw(jQuery(this.div), this.diff_options); jQuery(this.div).append(diff); } else if (typeof value != 'object') { jQuery(this.div).append(value); } this.check_mini(); }; et2_diff.prototype.check_mini = function () { if (!this.mini) { return false; } var view = jQuery(this.div).children(); this.minify(view); var self = this; jQuery('
') .appendTo(self.div) .css("cursor", "pointer") .click({ diff: view, div: self.div, label: self.options.label }, function (e) { var diff = e.data.diff; var div = e.data.div; self.un_minify(diff); var dialog_div = jQuery('