-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.fn.js
127 lines (127 loc) · 4.24 KB
/
application.fn.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
117
118
119
120
121
122
123
124
125
126
127
/**
* Premium URL Shortener jQuery Custom Functions - Don't edit anything below!
* Copyright @KBRmedia - All rights Reserved
*/
(function($){
// Sticky
$.fn.extend({
sticky: function(a) {
var b = {
TopMargin: '0'
}
var e=$(this);
if(!e.length) return false;
var s = $.extend(b, a);
pos=e.position();
$(window).scroll(function(){
if(window.pageYOffset>=pos.top){
e.css({
position: 'fixed',
top: s.TopMargin,
left: pos.left,
margin: 0
});
}else{
e.attr('style','');
}
});
}
});
// Tooltip
$.fn.extend({
tooltip: function(a){
$(this).hover(function(){
var d=$(this).attr("data-content");
var pos=$(this).offset();
console.log(pos);
var x=pos.left + $(this).width() + 20;
var y=pos.top;
$("body").append("<span id='tooltip' style='position:absolute;top:"+y+"px;left:"+x+"px'>"+d+"</span>");
},function(){
$("#tooltip").remove();
});
}
});
// Smooth Scroll
$.fn.extend({
smoothscroll: function(settings) {
var defaults = {
holder: 0
};
var s = $.extend(defaults, settings);
$(this).click(function(e){
e.preventDefault();
if(!s.holder){
var href=$(this).attr("href");
}else{
var href=s.holder;
}
var pos=$(href).position();
var css=$(this).attr('class');
$("."+css).removeClass("active");
$('body,html').animate({ scrollTop: pos.top-30 });
});
}
});
// Modal
$.fn.extend({
modal: function(settings) {
var defaults = {
confimation: 0,
title:$(this).attr("title"),
content:$(this).attr("data-content"),
link:$(this).attr("href")
};
var s = $.extend(defaults, settings);
if(!s.content){
s.content="Note that this action is permanent. Once you click proceed, you <strong>may not undo</strong> this. Click anywhere outside this modal or click <a href='#close' class='close-modal'>close</a> to close this.";
}
if(!s.title){
s.title="Are you sure you want to proceed?";
}
if(s.confimation){
var proceed="";
}else{
var proceed="<a href='" + s.link + "' class='btn btn-success btn-xs'>Proceed</a> <a href='#' class='btn btn-danger btn-xs close-modal'>Cancel</a>";
}
$.fn.modal_destroy=function(){
$("#modal-shadow").fadeOut('normal',function(){
$(this).remove();
});
$("#modal-alert").fadeOut('normal',function(){
$(this).remove();
});
return;
}
if($("#modal-alert").length>0) $(document).modal_destroy();
$("body").prepend('<div id="modal-alert"></div><div id="modal-shadow"></div>');
$("#modal-shadow").css("height",$(document).height()).hide();
$("#modal-shadow").show();
var left=($(document).width() - $("#modal-alert").width())*0.5;
var top=80;
$("#modal-alert").css({"top":top,"left":left}).hide();
$("#modal-alert").fadeIn();
$("#modal-alert").html("<div class='title'>"+s.title+" <a href='#' class='btn btn-danger btn-xs pull-right close-modal'>Close</a></div><p>"+ s.content +"</p>"+proceed);
$(document).on('click',".close-modal,#modal-shadow",function(e) {
e.preventDefault();
$(document).modal_destroy();
});
var pos=$('#modal-alert').position();
$(this).smoothscroll({holder:'#modal-alert'});
$(document).keyup(function(e) {
if (e.keyCode == 27) {
e.preventDefault();
$(document).modal_destroy();
}
});
}
});
})(jQuery);
function is_mobile(){
if($(document).width()<550) return true;
return false;
}
function is_tablet(){
if($(document).width()>=550 && $(document).width()<980) return true;
return false;
}