PageSourceSearch

https://artparis.fr/static/js/public_gui/Modal.js

js artparis.fr collected 2026-09-26 06:16:40 UTC 2,606 bytes, 94 lines download raw bytes

1AP.Modal = new JS.Class({
2
3	$element : null,
4	$cancelButton: null,
5	$confirmButton: null,
6
7	options: null,
8
9	extend : {
10		options_default : {
11			$appendTo: null,
12			title: 'Sans titre',
13			cancelButtonText : 'Annuler',
14			confirmButtonText : 'Valider',
15			optional_action_label : null,
16			optional_action_callback : $.noop,
17			when_hidden : $.noop,
18			autoHide : true // false : the caller must hide the modal by itself
19		}
20	},
21
22	initialize : function(options) {
23		if (null == AP.Modal.options_default.$appendTo) {
24			AP.Modal.options_default.$appendTo = $('body'); // can't be set directly because document may not be completely loaded
25		}
26		if ('undefined' == typeof options) options = {};
27		this.options = $.extend({}, AP.Modal.options_default, options);
28
29		var $title =
30			$('<div class="ap_modal_title">')
31			.append(
32				$('<h1>').append($('<span class="title">').text(this.options.title))
33			);
34
35		var me = this;
36		if (this.options.optional_action_label) {
37			$title.append(
38				$('<span style="margin-left:20px">').append(
39					'OU',
40					$('<div class="btn btn-primary" style="margin: 0 0 10px 20px">').text(this.options.optional_action_label).click(function() {
41						me.hide();
42						me.options.when_hidden();
43						me.options.optional_action_callback();
44					})
45				))
46		}
47
48		var $content = $('<div class="ap_modal_content carved">');
49
50		this.$cancelButton = $('<button class="ap_modal_left_button btn btn-inverse">').text(this.options.cancelButtonText);
51		this.$confirmButton = $('<button class="ap_modal_right_button btn btn-primary">').text(this.options.confirmButtonText);
52		var $buttons = $('<div class="ap_modal_buttons">').append(this.$cancelButton, this.$confirmButton);
53
54		this.$element = $('<div class="ap_modal">').append($title, $content, $buttons);
55			
56		this.options.$appendTo.append(this.$element);
57
58		return this;
59	},
60
61	show : function(options) {
62		if ('undefined' == typeof options) options = {};
63		options = $.extend({
64			shown : $.noop,
65			cancelled : $.noop,
66			confirmed : $.noop
67		}, options);
68		var me = this;
69		this.$element.slideDown('fast', options.shown);
70		this.$cancelButton.click(function() {
71			options.cancelled();
72			if (me.options.autoHide) me.hide();
73		});
74		this.$confirmButton.click(function() {
75			options.confirmed();
76			if (me.options.autoHide) me.hide();
77		})
78	},
79
80	hide : function(options) {
81		var me = this;
82		this.$element.slideUp('fast', function() {
83			if ('undefined' != typeof options && 'hidden' in options) {
84				options.hidden();
85			}
86			me.destroy();
87		});
88	},
89
90	destroy : function() {
91		this.$element.remove();
92		this.$element = null;
93	}
94});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.