{"size": 1848, "ext": "js", "max_stars_repo_path": "src/sap.ui.integration/test/sap/ui/integration/demokit/cardExplorer/webapp/samples/footer/cardWithDialog/DetailsDialogExtension.js", "max_stars_repo_name": "piejanssens/openui5", "max_stars_repo_stars_event_min_datetime": "2015-01-02T22:36:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T10:48:25.000Z", "max_issues_repo_path": "src/sap.ui.integration/test/sap/ui/integration/demokit/cardExplorer/webapp/samples/footer/cardWithDialog/DetailsDialogExtension.js", "max_issues_repo_name": "piejanssens/openui5", "max_issues_repo_issues_event_min_datetime": "2015-01-03T17:00:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:56:23.000Z", "max_forks_repo_path": "src/sap.ui.integration/test/sap/ui/integration/demokit/cardExplorer/webapp/samples/footer/cardWithDialog/DetailsDialogExtension.js", "max_forks_repo_name": "piejanssens/openui5", "max_forks_repo_forks_event_min_datetime": "2015-01-01T00:01:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T23:31:35.000Z"}
{"max_stars_count": 2724, "max_issues_count": 2991, "max_forks_count": 1620, "avg_line_length": 23.6923076923, "max_line_length": 109, "alphanum_fraction": 0.7023809524}
sap.ui.define([
	"sap/base/Log",
	"sap/ui/core/syncStyleClass",
	"sap/ui/integration/Extension",
	"sap/ui/integration/widgets/Card",
	"sap/ui/thirdparty/jquery",
	"sap/m/Dialog"
], function (
	Log,
	syncStyleClass,
	Extension,
	Card,
	jQuery,
	Dialog
) {
	"use strict";

	var DetailsDialogExtension = Extension.extend("card.explorer.footer.cardWithDialog.DetailsDialogExtension");

	DetailsDialogExtension.prototype.init = function () {
		Extension.prototype.init.apply(this, arguments);
		this.attachAction(this._handleAction.bind(this));
	};

	DetailsDialogExtension.prototype.exit = function () {
		if (this._oDetailsDialog) {
			this._oDetailsDialog.destroy();
		}

		Extension.prototype.exit.apply(this, arguments);
	};

	DetailsDialogExtension.prototype._handleAction = function (oEvent) {
		var sActionType = oEvent.getParameter("type"),
			mParams = oEvent.getParameter("parameters");

		if (sActionType !== "Custom") {
			return;
		}

		switch (mParams.method) {
			case "CloseDetailsDialog":
				this._oDetailsDialog.close();
				break;
			case "OpenDetailsDialog":
				this._openDetailsDialog();
				break;
			default:
				Log.error("Method" + mParams.method + " not recognized");
		}
	};

	DetailsDialogExtension.prototype._openDetailsDialog = function () {
		var oCard = this.getCard(),
			sUrl = oCard.getRuntimeUrl("./detailsCard.json"),
			oDetailsCard = new Card({
				manifest: sUrl,
				width: "100%",
				height: "100%"
			});

		// we can reuse the same actions handler if we want
		oDetailsCard.attachAction(this._handleAction.bind(this));

		this._oDetailsDialog = new Dialog({
			content: [
				oDetailsCard
			],
			showHeader: false,
			contentWidth: "40%"
		});

		syncStyleClass("sapUiSizeCompact", jQuery(oCard.getDomRef()), this._oDetailsDialog);
		this._oDetailsDialog.open();
	};

	return DetailsDialogExtension;
});