PageSourceSearch

https://www.moviequotes.com/static/js/fc/ui/comment.min.js?2e03167f

js moviequotes.com collected 2026-10-02 07:03:42 UTC 5,676 bytes, 186 lines download raw bytes

1define(['jquery', 'fc/login', 'fc/utils', 'i18n', 'setup'], function ($, fc_login, fc_utils, i18n) {
2	function message(comment_form, title, message) {
3		require(['fc/ui/dialog'], function (fc_ui_dialog) {
4			fc_ui_dialog.createAndShow(title, message, {width: 500, buttons: false});
5		});
6	}
7
8	function post(form, form_data, panel) {
9		// Faccio il post da anonimo
10		var url = form.attr('action');
11		$.post(url, form_data, function(data, textStatus) {
12			if ($('input[name=success]', data).val() == '1') {
13				var comment_id = $('input[name=comment_id]', data).val();
14				_gaq.push(['_trackEvent', 'Comments', 'Add', '']);
15				// Tutto ok, grazie!
16				// Se l'utente effettua anche il login, allora lo imposto come
17				// autore
18				fc_login.logged_action(function() {
19					var url = form.find('.assign_comment_ownership').val();
20					$.post(url, {'c': comment_id}, function(owner_data, textStatus) {
21						if ($('input[name=success]', owner_data).val() == '1') {
22							var comment_id = $('input[name=comment_id]', owner_data).val();
23							var url = form.find('.comment_success').val();
24							$.post(url, {c: comment_id}, function(success_data, textStatus) {
25								panel.html(success_data);
26								panel.trigger('comment-ready');
27								panel.trigger('comment-new');
28								panel.trigger('opened');
29							});
30							_gaq.push(['_trackEvent', 'Comments', 'Assigned', '']);
31						}
32						else {
33							panel.html(owner_data);
34							panel.trigger('comment-ready');
35						}
36					});
37				}, i18n.gettext('Per rendere subito visibile il tuo commento e farlo comparire con il tuo nome è necessario registrarsi'), function() {
38					panel.html(data);
39					panel.trigger('comment-ready');
40				});
41			} else {
42				// C'è un errore
43				panel.html(data);
44				panel.trigger('comment-ready');
45				_gaq.push(['_trackEvent', 'Comments', 'Error', '']);
46			}
47		});
48	}
49
50	function edit_comment(link, panel) {
51		panel.trigger('comment-waiting');
52		fc_login.logged_action(function() {
53			_gaq.push(['_trackEvent', 'Comments', 'Edit', '']);
54			$.get(link.href, function (data) {
55				panel.html(data);
56				panel.trigger('comment-ready');
57			})
58			.error(function (jqXHR) {
59				panel.one('opened', function() {
60					set_alert(panel, i18n.gettext('Non puoi modificare questo commento'));
61			});
62				panel.trigger('comment-reload');
63			});
64		}, undefined, undefined, undefined, true);
65	}
66
67	function save_comment(form, panel) {
68		// Se il testo è vuoto, non faccio niente
69		if (form.find('.comment-text').val().length == 0) return;
70
71		// non so cosa ne faranno al waiting, meglio clonarla
72		// per non perderne il riferimento su ie,
73		// anche se perde tutti i dati, megli estrarli subito
74		var form_data = form.serialize();
75		var $form = form.clone();
76
77		panel.trigger('comment-waiting');
78
79		if (! $form.hasClass('comment-edit')) {
80			post($form, form_data, panel);
81		}
82		else {
83			fc_login.logged_action(function() {
84				$.post($form.attr('action'), form_data, function (data) {
85					if (data == 'ok') {
86						panel.trigger('comment-reload');
87					} else {
88						panel.html(data);
89						panel.trigger('comment-ready');
90					}
91				});
92			}, undefined, undefined, undefined, true);
93		}
94	}
95
96	function delete_comment(link, panel) {
97		panel.trigger('comment-waiting');
98		_gaq.push(['_trackEvent', 'Comments', 'Delete', '']);
99		fc_login.logged_action(function() {
100			$.get(link.href, function (data) {
101				if (data == 'ok') {
102					panel.trigger('comment-reload');
103					panel.trigger('comment-deleted');
104				} else {
105					panel.trigger('comment-ready');
106					panel.html(data);
107				}
108			})
109			.error(function (jqXHR) {
110				panel.one('opened', function() {
111					set_alert(panel, i18n.gettext('Non puoi cancellare questo commento'));
112			});
113				panel.trigger('comment-reload');
114			});
115		}, undefined, undefined, undefined, true);
116	}
117
118	function set_alert(panel, text) {
119		var alert = '<div class="alert">' +
120			'<a class="close" data-dismiss="alert" href="#">×</a>' +
121			text +
122			'</div>';
123
124		panel.prepend(alert);
125	}
126
127	function click_send(e) {
128		e.preventDefault();
129		var $panel = $(e.target).closest('.comment_form');
130		var $form = $panel.find('form');
131
132		// Attenzione, il bottone ha una doppia valenza: per il form di
133		// inserimento commento e quello di modifica
134
135		save_comment($form, $panel);
136	}
137
138	function click_back(e) {
139		e.preventDefault();
140		var $panel = $(e.target).closest('.comment_form');
141		$panel.trigger('comment-waiting');
142		$panel.trigger('comment-reload');
143	}
144
145	function click_edit(e) {
146		e.preventDefault();
147		var $panel = $(e.target).closest('.comment_form');
148		edit_comment(e.target, $panel);
149	}
150
151	function click_delete(e) {
152		e.preventDefault();
153		var $panel = $(e.target).closest('.comment_form');
154		delete_comment(e.target, $panel);
155	}
156
157	function init($target) {
158		if (typeof $target != 'undefined') {
159			var selector = $target.selector + ' ';
160		} else {
161			return;
162		}
163
164		var click_send_selector = selector + '.comment_form button';
165		var click_back_selector = selector + '.comment_form .back';
166		var click_edit_selector = selector + '.comment_form .comment .content .edit';
167		var click_delete_selector = selector + '.comment_form .comment .content .delete';
168
169		// Click sul commenta
170		$(document).off('click', click_send_selector, click_send)
171			.on('click', click_send_selector, click_send);
172
173		$(document).off('click', click_back_selector, click_back)
174			.on('click', click_back_selector, click_back);
175
176		$(document).off('click', click_edit_selector, click_edit)
177			.on('click', click_edit_selector, click_edit);
178
179		$(document).off('click', click_delete_selector, click_delete)
180			.on('click', click_delete_selector, click_delete);
181	}
182
183	return {
184		'init': init
185	};
186});

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.