-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathsummit.js
More file actions
139 lines (119 loc) · 3.61 KB
/
Copy pathsummit.js
File metadata and controls
139 lines (119 loc) · 3.61 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Toggle sidebar nav
$(".open-panel").click(function(event){
if($('body').hasClass('openNav')) {
$('body').removeClass('openNav').addClass('closeNav');
} else {
$('body').removeClass('closeNav').addClass('openNav');
}
event.preventDefault();
return false;
});
// Smooth scroll
$("a[href^='#']").click(function(e){
var $this = $(this);
e.preventDefault();
var offset = $($this.attr('href')).offset();
if( typeof offset == 'undefined') return;
$('html, body').animate({
scrollTop: offset.top - 100
}, 500);
});
// on call for presentations, clear localStorage when adding new presentation
$('.add-presentation-button').click(function() {
localStorage.clear();
})
// or editing a presentation
$('.add-presentation-button').click(function() {
localStorage.clear();
})
$('.edit-presentation-button').click(function() {
localStorage.clear();
})
// Photo Credit Tooltip
//$('.photo-credit').tooltip();
$('a[data-confirm]').on('click', function (e) {
e.preventDefault();
var $t = $(this);
swal({
title: $t.data('confirm'),
text: $t.data('confirm-text'),
showCancelButton: true,
confirmButtonText: $t.data('confirm-ok') || "Yes",
cancelButtonText: $t.data('confirm-cancel') || "Nope",
confirmButtonColor: $t.data('confirm-color') || "#DD6B55"
}).then((result) => {
if (result) {
window.location = $t.attr('href');
}
}).catch(swal.noop);
});
var MAX_WORDS = 450;
var WARNING_THRESHOLD = 150;
$(function() {
if($('#PresentationForm_PresentationForm_Abstract').length) {
setTimeout(function() {
tinyMCE.get('PresentationForm_PresentationForm_Abstract')
.on('keyup', debounce(textEvent, 250))
.on('paste', textEvent);
},500);
}
$('.delete-speaker').click(function(event){
if(!confirm('are you sure?')){
event.preventDefault();
event.stopPropagation();
return false;
}
});
if($('#BootstrapForm_AddSpeakerForm_SpeakerType_Me').length == 0){
$('#legal-other').show();
$('#legal-me').hide();
}
else if($('#BootstrapForm_AddSpeakerForm_SpeakerType_Me').is(':checked') ){
$('#legal-other').hide();
$('#legal-me').show();
}
$('#BootstrapForm_AddSpeakerForm_SpeakerType_Else').click(function(evt){
if($(this).is(':checked')){
$('#legal-other').show();
$('#legal-me').hide();
}
});
$('#BootstrapForm_AddSpeakerForm_SpeakerType_Me').click(function(evt){
if($(this).is(':checked')){
$('#legal-other').hide();
$('#legal-me').show();
}
});
});
function textEvent(editor, event) {
var body = this.getBody();
var text = tinyMCE.trim(body.innerText || body.textContent);
var words = text.split(/[\w\u2019\'-]+/).length-1;
var diff = MAX_WORDS - words;
var klass = '';
if(diff > 0) {
$('#word-count').text(diff + ' words remaining');
if(diff < WARNING_THRESHOLD) {
klass = 'warning';
}
}
else {
$('#word-count').text('0 words remaining. Your content will be truncated!');
klass = 'danger';
}
$('#word-count').attr('class', klass);
}
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};