forked from OHNLP/NLP_WG_Pre-symposium-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.js
116 lines (105 loc) · 4.63 KB
/
home.js
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function initGallery(){
// init gallery
if(!isIE() || isIE() > 8) {
var mediaboxLinks = jQuery('.mediabox a.post');
mediaboxLinks.click(function (event) {
event.preventDefault();
blueimp.Gallery(mediaboxLinks, {
index: this,
event: event,
titleElement: 'strong',
youTubeClickToPlay: false
});
});
}
else {
jQuery('.mediabox a.post').attr('target','_blank');
}
}
jQuery(function(){
jQuery('#tile_media .btn-group-header .btn').click(function(){
jQuery('#tile_media .btn-group-header .btn').removeClass('active');
jQuery(this).addClass('active');
jQuery('#tile_media .carousel-indicators').empty();
jQuery('#tile_media .carousel-inner').empty();
});
jQuery('#tile_media .btn-group-header .btn').click(function(e){
var data_id = jQuery(this).attr('data-id');
jQuery.ajax({
type: "POST",
dataType: "json",
url: ajaxurl,
data: {
'action': 'get_media',
'data-id': data_id
},
success: function(data) {
var medias = '';
if(data.media)
jQuery.each(data.media, function(index, media_chunk) {
var class_active = index == 0 ? ' class="active"' : '';
var active = index == 0 ? 'active' : '';
jQuery('#tile_media .carousel-indicators').append('<li data-target="#mediabox-carousel" data-slide-to="' + index + '"' + class_active + '></li>');
medias += '<div class="item ' + active + '">';
for(var key in media_chunk){
var media = media_chunk[key];
if(media.post_video_code != '')
medias += '<a class="post video" ' + media.post_video_attributes + '">';
else
medias += '<a class="post" href="' + media.post_image_big_url + '">';
medias += '<span class="wrapper">' + media.post_image + '</span>';
medias += '<span class="desc">';
medias += '<strong>' + media.post_title + '</strong>';
medias += media.post_content;
medias += '</span>';
medias += '</a>';
}
medias += '</div>';
});
jQuery('#tile_media .carousel-inner').append(medias);
initGallery();
}
});
e.preventDefault();
});
jQuery('#tile_media .btn-group-header .btn:first').trigger('click');
jQuery('#tile_contact form').submit(function() {
var hasError = false;
jQuery('.error', this).remove();
jQuery('.requiredField', this).each(function() {
if(jQuery.trim(jQuery(this).val()) == '') {
jQuery(this).parent().append('<span class="error">' + contact_missingfield_error + '</span>');
jQuery(this).addClass('inputError');
hasError = true;
} else if(jQuery(this).hasClass('email')) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?jQuery/;
if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {
jQuery(this).parent().append('<span class="error">' + contact_wrongemail_error+ '</span>');
jQuery(this).addClass('inputError');
hasError = true;
}
}
});
if(!hasError) {
jQuery('#tile_contact .alert, #tile_contact .info').remove();
jQuery.ajax({
url: ajaxurl,
data: jQuery(this).serialize(),
dataType: 'json',
type: 'POST',
success: function(data) {
if(data.sent == true)
jQuery('#tile_contact form').slideUp("fast", function() {
jQuery('#tile_contact form').before('<p class="info">' + data.message + '</p>');
});
else
jQuery('#tile_contact form').before('<p class="alert">' + data.message + '</p>');
},
error: function(data) {
jQuery('#tile_contact form').before('<p class="alert">' + data.message + '</p>');
}
});
}
return false;
});
});