vitnet

subscribe.js

Oct 24th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * subscribe.js
  3.  **/
  4. function newsSubs(a, b, c) {
  5.     if( dle_group == 5 && c == 0 ) {
  6.         var d = {};
  7.         d[dle_act_lang[3]] = function() {
  8.             $(this).dialog('close');
  9.         },
  10.         d[dle_p_send] = function() {
  11.             if( $('#email').val().length < 6 ) {
  12.                 DLEalert(dle_req_field, dle_info);
  13.                 return false;
  14.             }
  15.    
  16.             $.post(dle_root + 'engine/ajax/subscribe.news.php', {news_id: a, user_id: b, email: $('#email').val(), action: c}, function(data) {
  17.                 $('#count').text(data.count);
  18.                 $('#news_subscribe').text(data.text);
  19.                 $('#news_subscribe').attr('onclick', data.value);
  20.                 $('#news_subscribe').attr('title', data.text);
  21.                 if( c == 1 ) {
  22.                     $('#news_subscribe').removeClass('link-unsubscribe').addClass('link-subscribe');
  23.                 } else {
  24.                     $('#newsSubs').remove();
  25.                     $('#news_subscribe').removeClass('link-subscribe').addClass('link-unsubscribe');
  26.                 }
  27.                 ShowLoading(data.loading);
  28.                 setTimeout("HideLoading('');", 5000);
  29.             }, 'json');
  30.         }
  31.  
  32.         $('#newsSubs').remove();
  33.         $('body').append('<div id="newsSubs" title="Уведомления о выходе новых серий"><center>Введите ваш E-Mail<br /><br /><input type="text" name="email" id="email" class="ui-widget-content ui-corner-all" style="width:215px; padding: .4em;" /></center></div>');
  34.         $('#newsSubs').dialog({
  35.             dialogClass: 'modalfixed', autoOpen: true, show: 'fade', hide: 'fade', width: 350, buttons: d
  36.         });
  37.         $('.modalfixed.ui-dialog').css({position:'fixed'});
  38.         $('#newsSubs').dialog('option', 'position', ['0','0']);
  39.     } else {
  40.         $.post(dle_root + 'engine/ajax/subscribe.news.php', {news_id: a, user_id: b, action: c}, function(data) {
  41.             $('#count').text(data.count);
  42.             $('#news_subscribe').text(data.text);
  43.             $('#news_subscribe').attr('onclick', data.value);
  44.             $('#news_subscribe').attr('title', data.text);
  45.             if( c == 1 ) {
  46.                 $('#news_subscribe').removeClass('link-unsubscribe').addClass('link-subscribe');
  47.             } else {
  48.                 $('#news_subscribe').removeClass('link-subscribe').addClass('link-unsubscribe');
  49.             }
  50.             ShowLoading(data.loading);
  51.             setTimeout("HideLoading('');", 5000);
  52.         }, 'json');
  53.     }  
  54. }
  55.  
  56. function ShowSubs() {
  57.     ShowLoading('');
  58.     $('#news-sub').remove();
  59.     var id = ($('div[id^=news-id-]').length > 0) ? $('div[id^=news-id-]').attr('id').replace('news-id-', '') : false;
  60.     $.post(dle_root + 'engine/ajax/subscribe.php', {news_id: id}, function(data) {
  61.         HideLoading('');
  62.         $('body').append(data);
  63.         $('#news-sub').dialog({
  64.             dialogClass: 'modalfixed', autoOpen: true, show: 'fade', hide: 'fade', width: 460, height: 350, buttons: {
  65.                 'Закрыть' : function() {
  66.                     $(this).dialog('close');                           
  67.                 }
  68.             }
  69.         });
  70.     });
  71.     return false;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment