-
Notifications
You must be signed in to change notification settings - Fork 13
/
alert-form.php
83 lines (77 loc) · 3.54 KB
/
alert-form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/*
* Osclass – software for creating and publishing online classified
* advertising platforms
*
* Copyright (C) 2014 OSCLASS
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<script type="text/javascript">
$(document).ready(function(){
$(".sub_button").click(function(){
$.post('<?php echo osc_base_url(true); ?>', {email:$("#alert_email").val(), userid:$("#alert_userId").val(), alert:$("#alert").val(), page:"ajax", action:"alerts"},
function(data){
if(data==1) { alert('<?php echo osc_esc_js(__('You have sucessfully subscribed to the alert', 'bender')); ?>'); }
else if(data==-1) { alert('<?php echo osc_esc_js(__('Invalid email address', 'bender')); ?>'); }
else { alert('<?php echo osc_esc_js(__('There was a problem with the alert', 'bender')); ?>');
};
});
return false;
});
var sQuery = '<?php echo osc_esc_js(AlertForm::default_email_text()); ?>';
if($('input[name=alert_email]').val() == sQuery) {
$('input[name=alert_email]').css('color', 'gray');
}
$('input[name=alert_email]').click(function(){
if($('input[name=alert_email]').val() == sQuery) {
$('input[name=alert_email]').val('');
$('input[name=alert_email]').css('color', '');
}
});
$('input[name=alert_email]').blur(function(){
if($('input[name=alert_email]').val() == '') {
$('input[name=alert_email]').val(sQuery);
$('input[name=alert_email]').css('color', 'gray');
}
});
$('input[name=alert_email]').keypress(function(){
$('input[name=alert_email]').css('background','');
})
});
</script>
<div class="alert_form">
<?php if(function_exists('osc_search_alert_subscribed') && osc_search_alert_subscribed()) { ?>
<h3>
<strong><?php _e('Already subscribed to this search', 'bender'); ?></strong>
</h3>
<?php } else { ?>
<h3>
<strong><?php _e('Subscribe to this search', 'bender'); ?></strong>
</h3>
<form action="<?php echo osc_base_url(true); ?>" method="post" name="sub_alert" id="sub_alert" class="nocsrf">
<?php AlertForm::page_hidden(); ?>
<?php AlertForm::alert_hidden(); ?>
<?php if(osc_is_web_user_logged_in()) { ?>
<?php AlertForm::user_id_hidden(); ?>
<?php AlertForm::email_hidden(); ?>
<?php } else { ?>
<?php AlertForm::user_id_hidden(); ?>
<?php AlertForm::email_text(); ?>
<?php }; ?>
<button type="submit" class="sub_button" ><?php _e('Subscribe now', 'bender'); ?>!</button>
</form>
<?php } ?>
</div>