PluginProbe
wpForo Forum / 1.4.0
wpForo Forum v1.4.0
3.1.6 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 All 138 releases
wpforo / wpf-assets / js / frontend.js

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

236 lines 8.8 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_show(notice){
16 var cls = '';
17 if( notice === undefined || notice.text === undefined || notice.text == '' ) return;
18 if( notice.type !== undefined ) cls = notice.type;
19 jQuery("#wpf-msg-box").hide();
20 jQuery("#wpf-msg-box p.wpf-msg-box-triangle-right").removeClass("error").removeClass("success").addClass(cls);
21 jQuery("#wpf-msg-box p.wpf-msg-box-triangle-right").html("<span>" + notice.text + "</span>");
22 jQuery("#wpf-msg-box").show(150).delay(1000);
23 if(cls != ''){
24 var dur = 2500;
25 if(cls == 'error'){
26 dur = 6000;
27 }
28 setTimeout(function(){ jQuery("#wpf-msg-box").hide(); }, dur);
29 }
30 }
31
32 function wpforo_phrase(phrase_key){
33 phrase_key = phrase_key.toLowerCase();
34 var wpfaPhrases = wpf_ajax_obj.phrases;
35 if( wpfaPhrases[phrase_key] !== undefined ) phrase_key = wpfaPhrases[phrase_key];
36 return phrase_key;
37 }
38
39 jQuery(document).ready(function($){
40
41 var _m = $("#m_");
42 if( _m !== undefined && _m.length ){
43 $('html, body').scrollTop(_m.offset().top - 25);
44 }
45
46 $(document).on('click', '#add_wpftopic', function(){
47 var stat = $( ".wpf-topic-create" ).is( ":hidden" );
48 $( ".wpf-topic-create" ).slideToggle( "slow" );
49 var add_wpftopic = '<i class="fa fa-times" aria-hidden="true"></i>';
50 if( !stat ) add_wpftopic = wpforo_phrase('add topic');
51 $( "#add_wpftopic" ).html(add_wpftopic);
52 $('html, body').animate({ scrollTop: ($(".wpforo-main").offset().top - 25) }, 415);
53 });
54
55 $(document).on('click','.not_reg_user', function(){
56 $("#wpf-msg-box").hide();
57 $('#wpforo-load').visible();
58 $('#wpf-msg-box').show(150).delay(1000);
59 $('#wpforo-load').invisible();
60 });
61
62 $(document).on('click','#wpf-msg-box', function(){
63 $("#wpf-msg-box").hide();
64 });
65
66 /* Home page loyouts toipcs toglle */
67 $( ".topictoggle" ).click(function(){
68 var wpfload = $('#wpforo-load');
69 wpfload.visible();
70
71 var id = $(this).attr( 'id' );
72
73 id = id.replace( "img-arrow-", "" );
74 $( ".wpforo-last-topics-" + id ).slideToggle( "slow" );
75 if( $(this).hasClass('topictoggle') && $(this).hasClass('fa-chevron-down') ){
76 $( '#img-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up');
77 }else{
78 $( '#img-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
79 }
80
81 id = id.replace( "button-arrow-", "" );
82 $( ".wpforo-last-posts-" + id ).slideToggle( "slow" );
83 if( $(this).hasClass('topictoggle') && $(this).hasClass('wpfcl-a') && $(this).hasClass('fa-chevron-down') ){
84 $( '#button-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up');
85 }else{
86 $( '#button-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
87 }
88
89 wpfload.invisible();
90 });
91
92 /* Home page loyouts toipcs toglle */
93 $( ".wpforo-membertoggle" ).click(function(){
94 var id = $(this).attr( 'id' );
95 id = id.replace( "wpforo-memberinfo-toggle-", "" );
96 $( "#wpforo-memberinfo-" + id ).slideToggle( "slow" );
97 if( $(this).find( "i" ).hasClass('fa-caret-down') ){
98 $(this).find( "i" ).removeClass('fa-caret-down').addClass('fa-caret-up');
99 }else{
100 $(this).find( "i" ).removeClass('fa-caret-up').addClass('fa-caret-down');
101 }
102 });
103
104
105 // Reply
106 $( ".wpforo-reply" ).click(function(){
107
108 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
109 $("#wpf-reply-form-title").html(wpf_ajax_obj.phrases['leave a reply']);
110
111 var parentpostid = $(this).attr('id');
112 parentpostid = parentpostid.replace("parentpostid", "");
113 $("#postparentid").val( parentpostid );
114
115 tinyMCE.activeEditor.setContent('');
116 $( ".wpf-topic-sbs" ).show();
117 $( "#wpf-topic-sbs" ).prop("disabled", false);
118
119 $( "#formaction" ).attr('name', 'post[action]');
120 $( "#formbutton" ).attr('name', 'post[save]');
121 $( "#formtopicid" ).attr('name', 'post[topicid]');
122 $( "#title" ).attr('name', 'post[title]');
123 $( "#formaction" ).val( 'add' );
124 $( "#formpostid" ).val( '' );
125 $( "#formbutton" ).val( wpf_ajax_obj.phrases.save );
126 $( "#title").val( wpf_ajax_obj.phrases['re'] + ": " + $("#title").attr('placeholder').replace( wpf_ajax_obj.phrases['re'] + ": ", ""));
127
128 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
129
130 tinymce.execCommand('mceFocus',false,'postbody');
131 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
132 tinyMCE.activeEditor.selection.collapse(false);
133
134 $('#wpforo-load').invisible();
135
136 });
137
138 //Answer
139 $( ".wpforo-answer" ).click(function(){
140
141 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
142 $("#wpf-reply-form-title").html(wpf_ajax_obj.phrases['your answer']);
143
144 tinyMCE.activeEditor.setContent('');
145 $( "#formaction" ).attr('name', 'post[action]');
146 $( "#formbutton" ).attr('name', 'post[save]');
147 $( "#formtopicid" ).attr('name', 'post[topicid]');
148 $( "#title" ).attr('name', 'post[title]');
149 $( "#formaction" ).val( 'add' );
150 $( "#formpostid" ).val( '' );
151 $( "#formbutton" ).val( wpf_ajax_obj.phrases.save );
152 $( "#title").val( wpf_ajax_obj.phrases['answer to'] + ": " + $("#title").attr('placeholder').replace(wpf_ajax_obj.phrases['re'] + ": ", "").replace(wpf_ajax_obj.phrases['answer to'] + ": ", ""));
153 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
154
155 tinymce.execCommand('mceFocus',false,'postbody');
156 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
157 tinyMCE.activeEditor.selection.collapse(false);
158
159 $('#wpforo-load').invisible();
160
161 });
162
163 //Comment
164 $( ".wpforo-childreply" ).click(function(){
165 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
166 $("#wpf-reply-form-title").html(wpf_ajax_obj.phrases['leave a comment']);
167
168 var parentpostid = $(this).attr('id');
169 var postid = parentpostid.replace("parentpostid", "");
170 $("#postparentid").val( postid );
171
172 tinyMCE.activeEditor.setContent('');
173 $( ".wpf-topic-sbs" ).show();
174 $( "#wpf-topic-sbs" ).prop("disabled", false);
175
176 $( "#formaction" ).attr('name', 'post[action]');
177 $( "#formbutton" ).attr('name', 'post[save]');
178 $( "#formtopicid" ).attr('name', 'post[topicid]');
179 $( "#title" ).attr('name', 'post[title]');
180 $( "#formaction" ).val( 'add' );
181 $( "#formpostid" ).val( '' );
182 $( "#formbutton" ).val( wpf_ajax_obj.phrases.save );
183 $( "#title").val( wpf_ajax_obj.phrases['re'] + ": " + $("#title").attr('placeholder').replace( wpf_ajax_obj.phrases['re'] + ": ", "").replace( wpf_ajax_obj.phrases['answer to'] + ": ", "") );
184 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 800);
185
186 tinymce.execCommand('mceFocus',false,'postbody');
187 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
188 tinyMCE.activeEditor.selection.collapse(false);
189
190 $('#wpforo-load').invisible();
191 });
192
193 // Move
194 jQuery( ".wpforo-move" ).click(function(){
195 jQuery( "#movedialog" ).dialog({dialogClass:'wpforo-dialog wpforo-dialog-move'});
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 #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 #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 });