PluginProbe
wpForo Forum / 1.4.11
wpForo Forum v1.4.11
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / wpf-assets / js / frontend.js

frontend.js in wpForo Forum 1.4.11, at wpf-assets/js/frontend.js

338 lines 12.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery.fn.visible = function() {
2 return this.css('visibility', 'visible');
3 };
4
5 jQuery.fn.invisible = function() {
6 return this.css('visibility', 'hidden');
7 };
8
9 jQuery.fn.visibilityToggle = function() {
10 return this.css('visibility', function(i, visibility) {
11 return (visibility === 'visible') ? 'hidden' : 'visible';
12 });
13 };
14
15 function wpforo_notice_clear() {
16 var msg_box = jQuery("#wpf-msg-box");
17 msg_box.hide();
18 msg_box.empty();
19 }
20
21 function wpforo_notice_show(notice){
22 if( notice === undefined || notice === '' ) return;
23
24 var n = notice.search(/<p(?:\s[^<>]*?)?>/i);
25 if( n < 0 ) notice = '<p>' + wpforo_phrase(notice) + '</p>';
26
27 var msg_box = jQuery("#wpf-msg-box");
28 msg_box.hide();
29 msg_box.html(notice);
30 msg_box.show(150).delay(1000);
31 setTimeout(function(){ jQuery("#wpf-msg-box > p.error").remove(); }, 6500);
32 setTimeout(function(){ jQuery("#wpf-msg-box > p.success").remove(); }, 2500);
33 }
34
35 function wpforo_phrase(phrase_key){
36 if( typeof wpforo_phrases !== 'undefined' ){
37 phrase_key = phrase_key.toLowerCase();
38 if( wpforo_phrases[phrase_key] !== undefined ) phrase_key = wpforo_phrases[phrase_key];
39 }
40 return phrase_key;
41 }
42
43 jQuery(document).ready(function($){
44 var wpforo_wrap = $('#wpforo-wrap');
45
46 var _m = $("#m_");
47 if( _m !== undefined && _m.length ){
48 $('html, body').scrollTop(_m.offset().top - 25);
49 }
50
51 $(document).on('click', '#add_wpftopic:not(.not_reg_user)', function(){
52 var stat = $( ".wpf-topic-create" ).is( ":hidden" );
53 $( ".wpf-topic-create" ).slideToggle( "slow" );
54 var add_wpftopic = '<i class="fas fa-times" aria-hidden="true"></i>';
55 if( !stat ) add_wpftopic = wpforo_phrase('add topic');
56 $( "#add_wpftopic" ).html(add_wpftopic);
57 $('html, body').animate({ scrollTop: ($(".wpforo-main").offset().top - 25) }, 415);
58 });
59
60 $(document).on('click','.not_reg_user', function(){
61 $("#wpf-msg-box").hide();
62 $('#wpforo-load').visible();
63 $('#wpf-msg-box').show(150).delay(1000);
64 $('#wpforo-load').invisible();
65 });
66
67 $(document).on('click','#wpf-msg-box', function(){
68 $(this).hide();
69 });
70
71 /* Home page loyouts toipcs toglle */
72 $( ".topictoggle" ).click(function(){
73 var wpfload = $('#wpforo-load');
74 wpfload.visible();
75
76 var id = $(this).attr( 'id' );
77
78 id = id.replace( "img-arrow-", "" );
79 $( ".wpforo-last-topics-" + id ).slideToggle( "slow" );
80 if( $(this).hasClass('topictoggle') && $(this).hasClass('fa-chevron-down') ){
81 $( '#img-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up');
82 }else{
83 $( '#img-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
84 }
85
86 id = id.replace( "button-arrow-", "" );
87 $( ".wpforo-last-posts-" + id ).slideToggle( "slow" );
88 if( $(this).hasClass('topictoggle') && $(this).hasClass('wpfcl-a') && $(this).hasClass('fa-chevron-down') ){
89 $( '#button-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up');
90 }else{
91 $( '#button-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
92 }
93
94 wpfload.invisible();
95 });
96
97 /* Home page loyouts toipcs toglle */
98 $( ".wpforo-membertoggle" ).click(function(){
99 var id = $(this).attr( 'id' );
100 id = id.replace( "wpforo-memberinfo-toggle-", "" );
101 $( "#wpforo-memberinfo-" + id ).slideToggle( "slow" );
102 if( $(this).find( "i" ).hasClass('fa-caret-down') ){
103 $(this).find( "i" ).removeClass('fa-caret-down').addClass('fa-caret-up');
104 }else{
105 $(this).find( "i" ).removeClass('fa-caret-up').addClass('fa-caret-down');
106 }
107 });
108
109
110 // Reply
111 $( ".wpforo-reply" ).click(function(){
112
113 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
114 $("#wpf-reply-form-title").html( wpforo_phrase('Leave a reply') );
115
116 var parentpostid = $(this).attr('id');
117 parentpostid = parentpostid.replace("parentpostid", "");
118 $("#wpf_postparentid").val( parentpostid );
119
120 tinyMCE.activeEditor.setContent('');
121 $( ".wpf-topic-sbs" ).show();
122 $( "#wpf-topic-sbs" ).prop("disabled", false);
123
124 $( "#wpf_formaction" ).attr('name', 'post[action]');
125 $( "#wpf_formbutton" ).attr('name', 'post[save]');
126 $( "#wpf_formtopicid" ).attr('name', 'post[topicid]');
127 $( "#wpf_title" ).attr('name', 'post[title]');
128 $( "#wpf_formaction" ).val( 'add' );
129 $( "#wpf_formpostid" ).val( '' );
130 $( "#wpf_formbutton" ).val( wpforo_phrase('Save') );
131 $( "#wpf_title").val( wpforo_phrase('re') + ": " + $("#wpf_title").attr('placeholder').replace( wpforo_phrase('re') + ": ", ""));
132
133 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
134
135 tinymce.execCommand('mceFocus',false,'postbody');
136 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
137 tinyMCE.activeEditor.selection.collapse(false);
138
139 $('#wpforo-load').invisible();
140
141 });
142
143 //Answer
144 $( ".wpforo-answer" ).click(function(){
145
146 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
147 $("#wpf-reply-form-title").html( wpforo_phrase('Your answer') );
148
149 tinyMCE.activeEditor.setContent('');
150 $( "#wpf_formaction" ).attr('name', 'post[action]');
151 $( "#wpf_formbutton" ).attr('name', 'post[save]');
152 $( "#wpf_formtopicid" ).attr('name', 'post[topicid]');
153 $( "#wpf_title" ).attr('name', 'post[title]');
154 $( "#wpf_formaction" ).val( 'add' );
155 $( "#wpf_formpostid" ).val( '' );
156 $( "#wpf_formbutton" ).val( wpforo_phrase('Save') );
157 $( "#wpf_title").val( wpforo_phrase('Answer to') + ": " + $("#wpf_title").attr('placeholder').replace( wpforo_phrase('re') + ": ", "").replace( wpforo_phrase('Answer to') + ": ", ""));
158 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
159
160 tinymce.execCommand('mceFocus',false,'postbody');
161 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
162 tinyMCE.activeEditor.selection.collapse(false);
163
164 $('#wpforo-load').invisible();
165
166 });
167
168 //Comment
169 $( ".wpforo-childreply" ).click(function(){
170 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
171 $("#wpf-reply-form-title").html( wpforo_phrase('Leave a comment') );
172
173 var parentpostid = $(this).attr('id');
174 var postid = parentpostid.replace("parentpostid", "");
175 $("#wpf_postparentid").val( postid );
176
177 tinyMCE.activeEditor.setContent('');
178 $( ".wpf-topic-sbs" ).show();
179 $( "#wpf-topic-sbs" ).prop("disabled", false);
180
181 $( "#wpf_formaction" ).attr('name', 'post[action]');
182 $( "#wpf_formbutton" ).attr('name', 'post[save]');
183 $( "#wpf_formtopicid" ).attr('name', 'post[topicid]');
184 $( "#wpf_title" ).attr('name', 'post[title]');
185 $( "#wpf_formaction" ).val( 'add' );
186 $( "#wpf_formpostid" ).val( '' );
187 $( "#wpf_formbutton" ).val( wpforo_phrase('Save') );
188 $( "#wpf_title").val( wpforo_phrase('re') + ": " + $("#wpf_title").attr('placeholder').replace( wpforo_phrase('re') + ": ", "").replace( wpforo_phrase('Answer to') + ": ", "") );
189 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 800);
190
191 tinymce.execCommand('mceFocus',false,'postbody');
192 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
193 tinyMCE.activeEditor.selection.collapse(false);
194
195 $('#wpforo-load').invisible();
196 });
197
198 //mobile menu responsive toggle
199 $("#wpforo-menu .wpf-res-menu").click(function(){
200 $("#wpforo-menu .wpf-menu").toggle();
201 });
202 var wpfwin = $(window).width();
203 var wpfwrap = wpforo_wrap.width();
204 if( wpfwin >= 602 && wpfwrap < 700 ){
205 $("#wpforo-menu .wpf-search-field").focus(function(){
206 $("#wpforo-menu .wpf-menu li").hide();
207 wpforo_wrap.find("#wpforo-menu .wpf-res-menu").show();
208 $("#wpforo-menu .wpf-search-field").css('transition-duration', '0s');
209 });
210 $("#wpforo-menu .wpf-search-field").blur(function(){
211 wpforo_wrap.find("#wpforo-menu .wpf-res-menu").hide();
212 $("#wpforo-menu .wpf-menu li").show();
213 $("#wpforo-menu .wpf-search-field").css('transition-duration', '0.4s');
214 });
215 }
216
217 // password show/hide switcher */
218 $(document).delegate('.wpf-show-password', 'click', function () {
219 var btn = $(this);
220 var parent = btn.parents('.wpf-field-wrap');
221 var input = $(':input', parent);
222 if (input.attr('type') == 'password') {
223 input.attr('type', 'text');
224 btn.removeClass('fa-eye-slash');
225 btn.addClass('fa-eye');
226 } else {
227 input.attr('type', 'password');
228 btn.removeClass('fa-eye');
229 btn.addClass('fa-eye-slash');
230 }
231 });
232
233 //Turn off on dev mode
234 //$(window).bind('resize', function(){ if (window.RT) { clearTimeout(window.RT); } window.RT = setTimeout(function(){ this.location.reload(false);}, 100); });
235
236 wpforo_wrap.on("change", "#wpforo_split_form #wpf_split_create_new", function () {
237 var checked = $("#wpf_split_create_new").is(":checked"),
238 target_url = $("#wpf_split_target_url"),
239 append = $("#wpf_split_append"),
240 new_title = $("#wpf_split_new_title"),
241 forumid = $("#wpf_split_forumid");
242 if( checked ){
243 target_url.children("input").prop("disabled", true);
244 target_url.hide();
245 append.children("input").prop("disabled", true);
246 append.hide();
247 new_title.children("input").prop("disabled", false);
248 new_title.show();
249 forumid.children("select").prop("disabled", false);
250 forumid.show();
251 }else{
252 target_url.children("input").prop("disabled", false);
253 target_url.show();
254 append.children("input").prop("disabled", false);
255 append.show();
256 new_title.children("input").prop("disabled", true);
257 new_title.hide();
258 forumid.children("select").prop("disabled", true);
259 forumid.hide();
260 }
261 });
262
263 });
264
265
266 jQuery(document).ready(function($){
267
268 //Facebook Share Buttons
269 $(document).on('click','.wpf-fb', function(){
270 var item_url = $(this).data('wpfurl');
271 var item_quote = $(this).parents('.post-wrap').find('.wpforo-post-content').text();
272 FB.ui({
273 method: 'share',
274 href: item_url,
275 quote: item_quote,
276 hashtag: null,
277 }, function (response) {});
278 });
279
280 //Share Buttons Toggle
281 $('.wpf-sb').mouseover(function(){
282 $(this).find(".wpf-sb-toggle").find("i").addClass("wpfsa");
283 $(this).find(".wpf-sb-buttons").show();
284 }).mouseout(function() {
285 $(this).find(".wpf-sb-toggle").find("i").removeClass("wpfsa");
286 $(this).find(".wpf-sb-buttons").hide();
287 });
288 $('.wpf-sb-toggle').mouseover(function(){
289 $(this).next().filter('.wpf-sb-buttons').parent().find("i").addClass("wpfsa");
290 }).mouseout(function() {
291 $(this).next().filter('.wpf-sb-buttons').parent().find("i").removeClass("wpfsa");
292 });
293
294 //Forum Rules
295 $("#wpf-open-rules").click(function(){
296 $(".wpforo-legal-rules").toggle();
297 return false;
298 });
299 $(document).on('click','#wpflegal-rules-yes', function(){
300 $('#wpflegal_rules').prop('checked', true);
301 $('#wpflegal-rules-not').removeClass('wpflb-active-not');
302 $(this).addClass('wpflb-active-yes');
303 setTimeout(function(){ $(".wpforo-legal-rules").slideToggle( "slow" ); }, 500);
304 });
305 $(document).on('click','#wpflegal-rules-not', function(){
306 $('#wpflegal_rules').prop('checked', false);
307 $('#wpflegal-rules-yes').removeClass('wpflb-active-yes');
308 $(this).addClass('wpflb-active-not');
309 });
310
311 //Forum Privacy Buttons
312 $("#wpf-open-privacy").click(function(){
313 $(".wpforo-legal-privacy").toggle();
314 return false;
315 });
316 $(document).on('click','#wpflegal-privacy-yes', function(){
317 $('#wpflegal_privacy').prop('checked', true);
318 $('#wpflegal-privacy-not').removeClass('wpflb-active-not');
319 $(this).addClass('wpflb-active-yes');
320 setTimeout(function(){ $(".wpforo-legal-privacy").slideToggle( "slow" ); }, 500);
321 });
322 $(document).on('click','#wpflegal-privacy-not', function(){
323 $('#wpflegal_privacy').prop('checked', false);
324 $('#wpflegal-privacy-yes').removeClass('wpflb-active-yes');
325 $(this).addClass('wpflb-active-not');
326 });
327
328 //Facebook Login Button
329 $('#wpflegal_fblogin').on('click', function() {
330 if( $(this).is(':checked') ){
331 $('.wpforo_fb-button').attr('style','pointer-events:auto; opacity:1;');
332 } else{
333 $('.wpforo_fb-button').attr('style','pointer-events: none; opacity:0.6;');
334 }
335 });
336
337 });
338