PluginProbe
wpForo Forum / 1.1.2
wpForo Forum v1.1.2
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.1.2, at wpf-assets/js/frontend.js

209 lines 7.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_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 $( "#add_wpftopic" ).click(function(){
42 $( ".wpf-topic-create" ).slideToggle( "slow" );
43 });
44
45 $(document).on('click','.not_reg_user', function(){
46 $("#wpf-msg-box").hide();
47 $('#wpforo-load').visible();
48 $('#wpf-msg-box').show(150).delay(1000);
49 $('#wpforo-load').invisible();
50 });
51
52 $(document).on('click','#wpf-msg-box', function(){
53 $("#wpf-msg-box").hide();
54 });
55
56 /* Home page loyouts toipcs toglle */
57 $( ".topictoggle" ).click(function(){
58 $('#wpforo-load').visible();
59
60 var id = $(this).attr( 'id' );
61
62 id = id.replace( "img-arrow-", "" );
63 $( ".wpforo-last-topics-" + id ).slideToggle( "slow" );
64 if($(this).attr('class') == 'topictoggle fa fa-chevron-down' ){
65 $( '#img-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up');
66 }else{
67 $( '#img-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
68 }
69
70 id = id.replace( "button-arrow-", "" );
71 $( ".wpforo-last-posts-" + id ).slideToggle( "slow" );
72 if($(this).attr('class') == 'topictoggle wpfcl-a fa fa-chevron-down' ){
73 $( '#button-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up');
74 }else{
75 $( '#button-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
76 }
77
78 $('#wpforo-load').invisible();
79 });
80
81 /* Home page loyouts toipcs toglle */
82 $( ".wpforo-membertoggle" ).click(function(){
83 var id = $(this).attr( 'id' );
84 id = id.replace( "wpforo-memberinfo-toggle-", "" );
85 $( "#wpforo-memberinfo-" + id ).slideToggle( "slow" );
86 if($(this).find( "i" ).attr('class') == 'fa fa-caret-down' ){
87 $(this).find( "i" ).removeClass('fa-caret-down').addClass('fa-caret-up');
88 }else{
89 $(this).find( "i" ).removeClass('fa-caret-up').addClass('fa-caret-down');
90 }
91 });
92
93
94 // Reply
95 $( ".wpforo-reply" ).click(function(){
96
97 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
98 $("#wpf-reply-form-title").html(wpf_ajax_obj.phrases['leave a reply']);
99
100 var parentpostid = $(this).attr('id');
101 parentpostid = parentpostid.replace("parentpostid", "");
102 $("#postparentid").val( parentpostid );
103
104 tinyMCE.activeEditor.setContent('');
105 $( ".wpf-topic-sbs" ).show();
106 $( "#wpf-topic-sbs" ).prop("disabled", false);
107
108 $( "#formaction" ).attr('name', 'post[action]');
109 $( "#formbutton" ).attr('name', 'post[save]');
110 $( "#formtopicid" ).attr('name', 'post[topicid]');
111 $( "#title" ).attr('name', 'post[title]');
112 $( "#formaction" ).val( 'add' );
113 $( "#formpostid" ).val( '' );
114 $( "#formbutton" ).val( wpf_ajax_obj.phrases.save );
115 $( "#title").val( wpf_ajax_obj.phrases['re'] + ": " + $("#title").attr('placeholder').replace( wpf_ajax_obj.phrases['re'] + ": ", ""));
116
117 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
118
119 tinymce.execCommand('mceFocus',false,'postbody');
120 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
121 tinyMCE.activeEditor.selection.collapse(false);
122
123 $('#wpforo-load').invisible();
124
125 });
126
127 //Answer
128 $( ".wpforo-answer" ).click(function(){
129
130 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
131 $("#wpf-reply-form-title").html(wpf_ajax_obj.phrases['your answer']);
132
133 tinyMCE.activeEditor.setContent('');
134 $( "#formaction" ).attr('name', 'post[action]');
135 $( "#formbutton" ).attr('name', 'post[save]');
136 $( "#formtopicid" ).attr('name', 'post[topicid]');
137 $( "#title" ).attr('name', 'post[title]');
138 $( "#formaction" ).val( 'add' );
139 $( "#formpostid" ).val( '' );
140 $( "#formbutton" ).val( wpf_ajax_obj.phrases.save );
141 $( "#title").val( wpf_ajax_obj.phrases['answer to'] + ": " + $("#title").attr('placeholder').replace(wpf_ajax_obj.phrases['re'] + ": ", "").replace(wpf_ajax_obj.phrases['answer to'] + ": ", ""));
142 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
143
144 tinymce.execCommand('mceFocus',false,'postbody');
145 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
146 tinyMCE.activeEditor.selection.collapse(false);
147
148 $('#wpforo-load').invisible();
149
150 });
151
152 //Comment
153 $( ".wpforo-childreply" ).click(function(){
154 $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
155 $("#wpf-reply-form-title").html(wpf_ajax_obj.phrases['leave a comment']);
156
157 var parentpostid = $(this).attr('id');
158 var postid = parentpostid.replace("parentpostid", "");
159 $("#postparentid").val( postid );
160
161 tinyMCE.activeEditor.setContent('');
162 $( ".wpf-topic-sbs" ).show();
163 $( "#wpf-topic-sbs" ).prop("disabled", false);
164
165 $( "#formaction" ).attr('name', 'post[action]');
166 $( "#formbutton" ).attr('name', 'post[save]');
167 $( "#formtopicid" ).attr('name', 'post[topicid]');
168 $( "#title" ).attr('name', 'post[title]');
169 $( "#formaction" ).val( 'add' );
170 $( "#formpostid" ).val( '' );
171 $( "#formbutton" ).val( wpf_ajax_obj.phrases.save );
172 $( "#title").val( wpf_ajax_obj.phrases['re'] + ": " + $("#title").attr('placeholder').replace( wpf_ajax_obj.phrases['re'] + ": ", "").replace( wpf_ajax_obj.phrases['answer to'] + ": ", "") );
173 $('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 800);
174
175 tinymce.execCommand('mceFocus',false,'postbody');
176 tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
177 tinyMCE.activeEditor.selection.collapse(false);
178
179 $('#wpforo-load').invisible();
180 });
181
182 // Move
183 jQuery( ".wpforo-move" ).click(function(){
184 jQuery( "#movedialog" ).dialog({dialogClass:'wpforo-dialog wpforo-dialog-move'});
185 });
186
187 //mobile menu responsive toggle
188 $("#wpforo-menu .wpf-res-menu").click(function(){
189 $("#wpforo-menu .wpf-menu").toggle();
190 });
191 var wpfwin = $(window).width();
192 var wpfwrap = $('#wpforo-wrap').width();
193 if( wpfwin >= 602 && wpfwrap < 700 ){
194 $("#wpforo-menu .wpf-search-field").focus(function(){
195 $("#wpforo-menu .wpf-menu li").hide();
196 $("#wpforo-wrap #wpforo-menu .wpf-res-menu").show();
197 $("#wpforo-menu .wpf-search-field").css('transition-duration', '0s');
198 });
199 $("#wpforo-menu .wpf-search-field").blur(function(){
200 $("#wpforo-wrap #wpforo-menu .wpf-res-menu").hide();
201 $("#wpforo-menu .wpf-menu li").show();
202 $("#wpforo-menu .wpf-search-field").css('transition-duration', '0.4s');
203 });
204 }
205
206 //Turn off on dev mode
207 //$(window).bind('resize', function(){ if (window.RT) { clearTimeout(window.RT); } window.RT = setTimeout(function(){ this.location.reload(false);}, 100); });
208
209 });