1/******************************************************************************/ 2/******************************************************************************/ 3 4;(function($,doc,win) 5{ 6 "use strict"; 7 8 var ThemeComment=function(object,option) 9 { 10 /**********************************************************************/ 11 12 var $this=this; 13 14 var $option=option; 15 16 var $respond=$('#respond'); 17 var $comment=$('#comments'); 18 var $commentForm=$('#comment-form'); 19 20 var $commentFormPostId=$('#comment_post_ID'); 21 var $commentFormParentCommentId=$('#comment_parent'); 22 23 var $commentFormCancelReply=$('#cancel-comment-reply-link'); 24 25 /**********************************************************************/ 26 27 this.build=function() 28 { 29 var self=this; 30 31 $respond.addClass('theme-clear-fix'); 32 33 $commentForm.find('>.form-submit').append($commentFormCancelReply); 34 $commentForm.find('>.form-submit>input[type="submit"]').addClass('theme-button theme-button-1'); 35 36 $commentFormCancelReply.addClass('theme-button theme-button-1'); 37 38 $commentForm.submit(function() 39 { 40 self.addComment(); 41 return(false); 42 }); 43 44 this.bindEvent(); 45 46 $(window).on('hashchange',function() 47 { 48 if(location.hash.substr(1,6)==='cpage-') 49 { 50 var data={}; 51 52 data.cpage=parseInt(location.hash.substr(7),10); 53 data.comment_form_post_id=parseInt($commentFormPostId.val(),10); 54 55 if(data.cpage===$comment.data('cpage')) return; 56 57 data.action='comment_get'; 58 59 $('#comments').css('opacity','0.5'); 60 61 jQuery.ajax( 62 { 63 url : $option.requestURL, 64 data : data, 65 type : 'GET', 66 success : self.getCommentResponse, 67 dataType : 'json', 68 contextObject : self 69 }); 70 } 71 }); 72 73 $(window).trigger('hashchange'); 74 }; 75 76 /**********************************************************************/ 77 78 this.getCommentResponse=function(response) 79 { 80 $comment.html(response.html); 81 82 $comment.data('cpage',response.cpage); 83 84 this.contextObject.bindEvent(); 85 86 $.scrollTo($comment,400,{easing:'easeOutQuint',offset:$this.getScrollOffset()}); 87 88 $('#comments').css('opacity','1.0'); 89 }; 90 91 /**********************************************************************/ 92 93 this.bindEvent=function() 94 { 95 var clickEventType=((document.ontouchstart!==null) ? 'click' : 'touchstart'); 96 97 $('.theme-comment-meta-reply-button').bind(clickEventType,function(e) 98 { 99 e.preventDefault(); 100 101 $commentFormCancelReply.css('display','block'); 102 $commentFormParentCommentId.val(jQuery(this).attr('href').substr(9)); 103 104 $.scrollTo($respond,400,{easing:'easeOutQuint',offset:$this.getScrollOffset()}); 105 }); 106 107 $('.comment-in-reply').bind(clickEventType,function(e) 108 { 109 e.preventDefault(); 110 $.scrollTo($($(this).attr('href')),400,{easing:'easeOutQuint',offset:$this.getScrollOffset()}); 111 }); 112 113 $commentFormCancelReply.bind(clickEventType,function(e) 114 { 115 e.preventDefault(); 116 117 $commentFormParentCommentId.val(0); 118 119 $(this).css('display','none'); 120 $.scrollTo($comment,400,{easing:'easeOutQuint',offset:$this.getScrollOffset()}); 121 }); 122 123 $comment.find('>#comments_list>.theme-pagination>a').each(function() 124 { 125 $(this).attr('href',$(this).attr('href').substr($(this).attr('href').indexOf('#'))); 126 }); 127 }; 128 129 /**********************************************************************/ 130 131 this.addComment=function() 132 { 133 var data=$commentForm.serialize()+'&cpage='+$comment.data('cpage')+'&action=comment_add'; 134 135 this.blockForm('block'); 136 137 $.ajax( 138 { 139 url : $option.requestURL, 140 data : data, 141 type : 'POST', 142 success : this.addCommentResponse, 143 dataType : 'json', 144 contextObject : this 145 }); 146 }; 147 148 /**********************************************************************/ 149 150 this.addCommentResponse=function(response) 151 { 152 this.contextObject.blockForm('unblock'); 153 154 if(parseInt(response.error)===0) 155 { 156 $comment.html(response.html); 157 $comment.data('cpage',response.cpage); 158 } 159 160 $commentForm.find('p').qtip('destroy'); 161 162 if(typeof(response.info)!=='undefined') 163 { 164 if(response.info.length) 165 { 166 for(var key in response.info) 167 { 168 $('#'+response.info[key].fieldId).parent('p').children('label').qtip( 169 { 170 style : 171 { 172 classes : (parseInt(response.error,10)===1 ? 'theme-qtip theme-qtip-error' : 'theme-qtip theme-qtip-success') 173 }, 174 content : 175 { 176 text : response.info[key].message 177 }, 178 position : 179 { 180 my : 'left center', 181 at : 'right center', 182 container : $commentForm 183 } 184 }).qtip('show'); 185 } 186 } 187 } 188 189 if(parseInt(response.error,10)===0) 190 {
191 $commentFormParentCommentId.val(0); 192 $commentFormCancelReply.css('display','none'); 193 194 $.scrollTo('#comment-'+response.commentId,400,{easing:'easeOutQuint',offset:$this.getScrollOffset()}); 195 196 $('#author,#email,#url,#comment').val('').blur(); 197 198 this.contextObject.bindEvent(); 199 200 if(response.changeURL.length!==0) location.href=response.changeURL; 201 } 202 }; 203 204 /**********************************************************************/ 205 206 this.blockForm=function(action) 207 { 208 if(action==='block') 209 { 210 $commentForm.find('>p:not(".comment-notes"):not(".logged-in-as")').block( 211 { 212 message : false, 213 overlayCSS : 214 { 215 opacity : '0.3' 216 } 217 }); 218 } 219 else $commentForm.find('p').unblock(); 220 }; 221 222 /**********************************************************************/ 223 224 this.getScrollOffset=function() 225 { 226 var offset=-20; 227 228 var adminBar=$('#wpadminbar'); 229 if(adminBar.length===1) offset-=adminBar.actual('height') 230 231 var header=$('.theme-page-header'); 232 if(header.length===0) return(offset); 233 234 var headerTop=header.children('.theme-page-header-top'); 235 if(headerTop.length===0) return(offset); 236 237 if(header.hasClass('theme-page-header-sticky')) 238 { 239 return(-1*headerTop.actual('height')+offset); 240 } 241 242 return(offset); 243 }; 244 245 /**********************************************************************/ 246 }; 247 248 /**************************************************************************/ 249 250 $.fn.ThemeComment=function(option) 251 { 252 var comment=new ThemeComment(this,option); 253 comment.build(); 254 }; 255 256 /**************************************************************************/ 257 258})(jQuery,document,window); 259 260/******************************************************************************/
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.