PageSourceSearch

https://otzyvy.best/plugins/feedback/templates/skin/default/js/feedback.js

js otzyvy.best collected 2026-10-08 00:01:30 UTC 6,485 bytes, 179 lines download raw bytes

1/*---------------------------------------------------------------------------
2* @Module Name: Feedback
3* @Description: Feedback for LiveStreet
4* @Version: 2.0
5* @Author: Chiffa
6* @LiveStreet Version: 1.X
7* @File Name: feedback.js
8* @License: CC BY-NC, http://creativecommons.org/licenses/by-nc/3.0/
9*----------------------------------------------------------------------------
10*/
11
12var ls=ls || {}
13
14ls.feedback = (function ($) {
15	/**
16	 * Èíèöèàëèçàöèÿ ôîðìû îáðàòíîé ñâÿçè
17	 * @param	isPopup
18	 */
19	this.initForm = function(isPopup) {
20		isPopup = isPopup ? true : false;
21		var form = isPopup ? 'popup-feedback-form' : 'feedback-form';
22		var submit = isPopup ? 'popup-feedback-form-submit' : 'feedback-form-submit';
23		if (typeof(form)=='string') {
24			form=$('#'+form);
25		}
26		if (typeof(submit)=='string') {
27			submit=$('#'+submit);
28		}
29		$(form).find('.js-ajax-validate').blur(function(e){
30			ls.feedback.validateField($(e.target).attr('name'),$(e.target).val(),$(form));
31		});
32		$(form).bind('submit',function(){
33			ls.feedback.send(form,isPopup);
34			return false;
35		});
36		$(submit).attr('disabled',false);
37	};
38
39	/**
40	 * Íàñòðîéêè äëÿ ðåäàêòîðà
41	 * @return	hash
42	 */
43	this.getMarkitup = function() {
44		return {
45			onShiftEnter:	{keepDefault:false, replaceWith:'<br />\n'},
46			onCtrlEnter:	{keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
47			onTab:			{keepDefault:false, replaceWith:'    '},
48			markupSet: [
49				{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
50				{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)'  },
51				{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
52				{separator:'---------------' },
53				{name: ls.lang.get('panel_list'), className:'editor-ul', openWith:'    <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>' },
54				{name: ls.lang.get('panel_list'), className:'editor-ol', openWith:'    <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>' },
55				{name: ls.lang.get('panel_list_li'), className:'editor-li', openWith:'<li>', closeWith:'</li>' },
56				{separator:'---------------' },
57				{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
58				{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
59				{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#window_upload_img').jqmShow(); } },
60				{separator:'---------------' },
61				{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
62			]
63		}
64	};
65
66	/**
67	 * Î÷èñêà ïîëåé ôîðìû îáðàòíîé ñâÿçè
68	 * @param	form
69	 */
70	this.clearFields = function(form) {
71		if (typeof(form)=='string') {
72			form=$('#'+form);
73		}
74		form.find('.validate-error-show').removeClass('validate-error-show').addClass('validate-error-hide');
75		form.find('.icon-ok-green').hide();
76		form.find('input.js-ajax-validate').val('');
77		form.find('textarea.js-ajax-validate').val('');
78		form.find('select.js-ajax-validate').val('');
79		form.find('.captcha-image').click();
80	};
81
82	/**
83	 * Âàëèäàöèÿ ïîëåé ôîðìû îáðàòíîé ñâÿçè
84	 * @param aFields
85	 * @param sForm
86	 */
87	this.validateFields = function(aFields,sForm) {
88		var url = aRouter['feedback']+'ajax/validate/';
89		var params = {fields: aFields};
90		if (typeof(sForm)=='string') {
91			sForm=$('#'+sForm);
92		}
93
94		ls.hook.marker('validateFeedbackFieldsBefore');
95		ls.ajax(url, params, function(result) {
96			if (!sForm) {
97				sForm=$('body');
98			}
99			$.each(aFields,function(i,aField){
100				if (result.aErrors && result.aErrors[aField.field][0]) {
101					sForm.find('.validate-error-field-'+aField.field).removeClass('validate-error-hide').addClass('validate-error-show').text(result.aErrors[aField.field][0]);
102					sForm.find('.validate-ok-field-'+aField.field).hide();
103				} else {
104					sForm.find('.validate-error-field-'+aField.field).removeClass('validate-error-show').addClass('validate-error-hide');
105					sForm.find('.validate-ok-field-'+aField.field).show();
106				}
107			});
108			ls.hook.run('validate_feedback_fields_after', [aFields, sForm, result]);
109		});
110	};
111
112	/**
113	 * Âàëèäàöèÿ êîíêðåòíîãî ïîëÿ ôîðìû
114	 * @param	sField
115	 * @param	sValue
116	 * @param	sForm
117	 * @param	aParams
118	 */
119	this.validateField = function(sField,sValue,sForm,aParams) {
120		var aFields=[];
121		aFields.push({field: sField, value: sValue, params: aParams || {}});
122		this.validateFields(aFields,sForm);
123	};
124
125	/**
126	 * Ajax îòïðàâêà ïèñüìà ñ ïðîâåðêîé ïîëåé ôîðìû
127	 * @param	form
128	 * @param	isPopup
129	 */
130	this.send = function(form,isPopup) {
131		var url = aRouter['feedback']+'ajax/send/';
132
133		ls.user.formLoader(form);
134		ls.hook.marker('feedbackSendBefore');
135		ls.ajaxSubmit(url, form, function(result) {
136			ls.user.formLoader(form,true);
137			if (result.bStateError) {
138				ls.msg.error(null,result.sMsg);
139			} else {
140				if (typeof(form)=='string') {
141					form=$('#'+form);
142				}
143				form.find('.validate-error-show').removeClass('validate-error-show').addClass('validate-error-hide');
144				if (result.aErrors) {
145					$.each(result.aErrors,function(sField,aErrors){
146						if (aErrors[0]) {
147							form.find('.validate-error-field-'+sField).removeClass('validate-error-hide').addClass('validate-error-show').text(aErrors[0]);
148						}
149					});
150				} else {
151					if (result.sMsg) {
152						//if (isPopup) {
153							//this.noticePopup(result.sMsg);
154						//} else {
155							ls.msg.notice(null,result.sMsg);
156						//}
157					}
158					this.clearFields(form);
159				}
160				ls.hook.run('feedback_send_after', [form, result]);
161			}
162		}.bind(this));
163	};
164
165	return this;
166}).call(ls.feedback || {},jQuery);
167
168
169jQuery(document).ready(function($){
170	ls.hook.run('feedback_template_init_start',[],window);
171
172	// Èíèöèàëèçàöèÿ ôîðìû
173	ls.feedback.initForm();
174
175	// Ìîäàëüíîå îêíî
176	$('#modal_feedback').jqm({trigger: '.js-feedback-window-show'});
177
178	ls.hook.run('feedback_template_init_end',[],window);
179});

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.