PageRenderTime 27ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/tpl/comments/form.tpl

https://github.com/soverc/WriteCrowd-WP-Plugin
Smarty Template | 306 lines | 275 code | 31 blank | 0 comment | 24 complexity | b31f288d3d554f9ec8764d5f74a8ce7f MD5 | raw file
  1. <?php
  2. $oneighty = wp_oneighty_article_info(get_the_ID());
  3. ?>
  4. <style type="text/css">
  5. #oneighty_comment_form .required {
  6. display: block;
  7. color: #ff0000;
  8. }
  9. .oneighty_ajax_success {
  10. display: block;
  11. color: #00ff00;
  12. }
  13. .oneighty_ajax_error {
  14. display: block;
  15. color: #ff0000;
  16. }
  17. #oneighty_comment_syndication_form {
  18. display: none;
  19. }
  20. </style>
  21. <script type="text/javascript" src="<?php _e($mp_defs['plugin_path']) ?>/assets/js/validate.jquery.js"></script>
  22. <script type="text/javascript">
  23. wp_user = 0;
  24. token = '';
  25. user_obj = null;
  26. mpjaxer = 'oneighty_jaxer';
  27. jQuery(document).ready(function(){
  28. setTimeout(function(){
  29. reload_comments();
  30. }, 60000);
  31. checkLogin();
  32. // Validate our Comment
  33. jQuery('#oneighty_comment_form').validate();
  34. jQuery('#oneighty_login_div').dialog({
  35. draggable: false,
  36. resizable: false,
  37. modal: true,
  38. autoOpen: false,
  39. width: 400,
  40. height: 325,
  41. title: 'Please log in ...',
  42. buttons: {
  43. 'Login': function() {
  44. if (doLogin() == true) {
  45. jQuery(this).dialog('close');
  46. }
  47. },
  48. 'Close': function() {
  49. jQuery(this).dialog('close');
  50. }
  51. }
  52. });
  53. // Submit our Comment
  54. jQuery('#oneighty_submit_comment').click(function() {
  55. var oneighty_comment_data = {
  56. action: mpjaxer,
  57. route: 'oneighty_submit_comment',
  58. article_id: jQuery('#oneighty_comment_post_id').val(),
  59. author_id: jQuery('#oneighty_author_id').val(),
  60. author_name: jQuery('#oneighty_author_name').val(),
  61. author_email: jQuery('#oneighty_author_email').val(),
  62. author_url: jQuery('#oneighty_author_url').val(),
  63. author_ip: '<?php _e($_SERVER['REMOTE_ADDR'])?>',
  64. content: jQuery('#oneighty_comment_content').val()
  65. };
  66. jQuery.ajax({
  67. url: '<?php echo(admin_url('admin-ajax.php'))?>',
  68. data: oneighty_comment_data,
  69. dataType: 'json',
  70. type:'post',
  71. async: false,
  72. success: function(response) {
  73. if (response.supplemental.message_type == 'error') {
  74. oneighty_message(response.data, false);
  75. } else {
  76. oneighty_message(response.data, true);
  77. }
  78. },
  79. error: function(){
  80. },
  81. complete: function() {
  82. var comment_count = parseInt(jQuery('#oneighty_comments_count').html()) + 1;
  83. jQuery('#oneighty_comment_syndication_form').slideUp();
  84. reload_comments_once();
  85. jQuery('#oneighty_comments_count').html(comment_count);
  86. }
  87. });
  88. });
  89. jQuery('#oneighty_leave_comment').click(function(){
  90. if (token == '') {
  91. jQuery('#oneighty_login_div').dialog('open');
  92. } else {
  93. }
  94. });
  95. });
  96. function oneighty_message(text, good) {
  97. if (good == true) {
  98. jQuery('#oneighty_ajax_messages').html('<br /><strong>' + text + '</strong><br /><br />');
  99. jQuery('#oneighty_ajax_messages').slideDown();
  100. jQuery('#oneighty_ajax_messages').attr('class', 'oneighty_ajax_success');
  101. } else {
  102. jQuery('#oneighty_ajax_messages').html('<br /><strong>' + text + '</strong><br /><br />');
  103. jQuery('#oneighty_ajax_messages').slideDown();
  104. jQuery('#oneighty_ajax_messages').attr('class', 'oneighty_ajax_error');
  105. }
  106. }
  107. function reload_comments() {
  108. setTimeout(function(){
  109. jQuery.ajax({
  110. url: '<?php echo(admin_url('admin-ajax.php')) ?>',
  111. data: {
  112. action: mpjaxer,
  113. route: 'oneighty_comments_grab',
  114. article_id: '<?php _e($oneighty_post_wp_id) ?>'
  115. },
  116. dataType: 'html',
  117. type: 'post',
  118. async: false,
  119. success: function(comments) {
  120. jQuery('#oneighty_comments_list').focus();
  121. jQuery('#oneighty_comments_list').html(comments);
  122. }
  123. });
  124. }, 60000);
  125. }
  126. function reload_comments_once() {
  127. jQuery.ajax({
  128. url: '<?php echo(admin_url('admin-ajax.php')) ?>',
  129. data: {
  130. action: mpjaxer,
  131. route: 'oneighty_comments_grab',
  132. article_id: '<?php _e($oneighty_post_wp_id) ?>'
  133. },
  134. dataType: 'html',
  135. type: 'post',
  136. async: false,
  137. success: function(comments) {
  138. jQuery('#oneighty_comments_list').focus();
  139. jQuery('#oneighty_comments_list').html(comments);
  140. }
  141. });
  142. }
  143. function doLogin() {
  144. var toReturn = false;
  145. jQuery.ajax({
  146. url: '<?php echo(admin_url('admin-ajax.php')) ?>',
  147. data: {
  148. action: mpjaxer,
  149. route: 'oneighty_user_login',
  150. article_id: '<?php _e($oneighty_post_wp_id) ?>',
  151. uname: jQuery('#mp_user_name').val(),
  152. passwd: jQuery('#mp_user_pass').val(),
  153. method: jQuery("input[name='mp_user_login_method']:checked").val()
  154. },
  155. dataType: 'json',
  156. type: 'post',
  157. async: false,
  158. success: function(robj) {
  159. if (robj.success == true) {
  160. user_obj = robj.user;
  161. token = robj.user.token;
  162. toReturn = true;
  163. } else {
  164. jQuery('#mp_user_error').val(robj.error);
  165. toReturn = false;
  166. }
  167. }
  168. });
  169. return(toReturn);
  170. }
  171. function checkLogin() {
  172. var toReturn = false;
  173. if (token == '') {
  174. jQuery.ajax({
  175. url: '<?php echo(admin_url('admin-ajax.php')) ?>',
  176. data: {
  177. action: mpjaxer,
  178. route: 'oneighty_user_auth',
  179. article_id: '<?php _e($oneighty_post_wp_id) ?>'
  180. },
  181. dataType: 'json',
  182. type: 'post',
  183. async: false,
  184. success: function(robj) {
  185. if (robj.success == true) {
  186. user_obj = robj.user;
  187. token = robj.user.token;
  188. toReturn = true;
  189. } else {
  190. toReturn = false;
  191. }
  192. }
  193. });
  194. }
  195. else if (token != '') {
  196. toReturn = true;
  197. }
  198. if (toReturn == true) {
  199. jQuery('#oneighty_author_name').val(user_obj.name);
  200. jQuery('#oneighty_author_email').val(user_obj.email);
  201. jQuery('#oneighty_author_url').val(user_obj.url);
  202. jQuery('#oneighty_author_id').val(user_obj.id);
  203. jQuery('#oneighty_leave_comment').attr('style', 'display:none;');
  204. jQuery('#oneighty_comment_syndication_form').slideDown();
  205. }
  206. setTimeout(function() {
  207. checkLogin();
  208. }, 1000);
  209. return(toReturn);
  210. }
  211. </script>
  212. <a href="#oneighty_comment_syndication_form" id="oneighty_leave_comment">Leave a Comment ...</a>
  213. <div id="oneighty_login_div">
  214. <div>
  215. <label>Login Method : </label>
  216. <br />
  217. <input type="radio" name="mp_user_login_method" value="wordpress" />
  218. <img src="<?php echo($mp_defs['images_path']) ?>/wordpress-logo.png" width="200" height="50" />
  219. <br />
  220. <input type="radio" name="mp_user_login_method" value="mediaplace" />
  221. <img src="<?php echo($mp_defs['images_path']) ?>/180create-logo.png" width="200" height="50" />
  222. </div>
  223. <div>
  224. <label>Username : </label>
  225. <br />
  226. <input type="text" id="mp_user_name" />
  227. </div>
  228. <div>
  229. <label>Password : </label>
  230. <br />
  231. <input type="password" id="mp_user_pass" />
  232. </div>
  233. </div>
  234. <div id="oneighty_comment_syndication_form" style="display:none;">
  235. <div id="oneighty_ajax_messages" style="display:none;"></div>
  236. <form action="" method="post" id="oneighty_comment_form">
  237. <!-- Author Name -->
  238. <p>
  239. <label for="oneighty_author">
  240. <small>Name (required)</small>
  241. </label>
  242. <br />
  243. <input name="oneighty_author_name" id="oneighty_author_name" value="" size="22" tabindex="1" type="text" class="required">
  244. </p>
  245. <!-- Author Email Address -->
  246. <p>
  247. <label for="oneighty_email">
  248. <small>Mail (will not be published) required)</small>
  249. </label>
  250. <br />
  251. <input name="oneighty_author_email" id="oneighty_author_email" value="" size="22" tabindex="2" type="text" class="required">
  252. </p>
  253. <!-- Author URL -->
  254. <p>
  255. <label for="oneighty_url">
  256. <small>Website</small>
  257. </label>
  258. <br />
  259. <input name="oneighty_author_url" id="oneighty_author_url" value="" size="22" tabindex="3" type="text" class="required">
  260. </p>
  261. <!-- Allowed Tags -->
  262. <p>
  263. <small><strong>XHTML:</strong> You can use these tags:....</small>
  264. </p>
  265. <!-- Comment Body -->
  266. <p>
  267. <textarea name="oneighty_comment_content" id="oneighty_comment_content" cols="100" rows="10" tabindex="4" class="required"></textarea>
  268. </p>
  269. <!-- Form Submisstion -->
  270. <p>
  271. <input name="oneighty_submit_comment" id="oneighty_submit_comment" tabindex="5" value="Submit Comment" type="button">
  272. <input name="oneighty_comment_post_id" id="oneighty_comment_post_id" value="<?php _e($oneighty->mediaplace_id)?>" type="hidden">
  273. </p>
  274. </form>
  275. </div>