public
Last active

  • Download Gist
gistfile1.js
JavaScript
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
$(function(){
$("#flashMessage,#authMessage").hide();
// $("#flashMessage").css('left', ( $(window).width()-$("#flashMessage").outerWidth()) /2 );
$("#flashMessage,#authMessage").css('top', 0).css('left',0);
$("#flashMessage,#authMessage").slideDown('fast');
setTimeout(function(){
$("#flashMessage,#authMessage").slideUp('slow')
},10000);
// $(":submit").click(function(){
// $(this).closest("form").submit();
// $(this).attr('disabled','disabled');
// });
$("form").submit(function(){
$(this).find(":submit").attr('disabled','disabled');
});
$("<div/>",{
"id":"ajaxloading",
"style":"background-color:yellow;padding:7px 15px;border-radius: 5px;-moz-border-radius: 5px;-webkit-border-radius: 5px;box-shadow: 5px 5px 2px black; -moz-box-shadow: 2px 2px 2px #CCC; -webkit-box-shadow: 2px 2px 2px #CCC;z-index:999;"
}).appendTo("body");
$("#ajaxloading").hide();
$("#ajaxloading").css('position','fixed').html("<b>Now Loading ...</b>")
.css('left',($(window).width()-$("#ajaxloading").outerWidth())/2)
.css('top',($(window).height()-$("#ajaxloading").outerWidth())/2);
});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
$(function(){
/**
*POP UP BOX
*/
$.fn.popBox = function(options){
var target= options.target;
var trigger = this;
function _showOverlay(target,trigger){
$(trigger).click(function(){
$('<div>',{
id:'overlay',
css:{
width:"100%",
height:"100%",
left:0,
top:0,
position:"fixed",
"z-index":1000,
"background-color":"#222",
opacity:0.3
}
}).hide().appendTo(document.body).fadeIn(100);
$(target).fadeIn(100);
return false;
});
}
function _hideOverlay(target){
$('body').delegate('#overlay','click',function(){
$('#overlay').fadeOut(100,function(){
$(target).fadeOut(100);
$(this).remove();
});
});
}
_showOverlay(target,trigger);
_hideOverlay(target);
 
};
 
$.fn.checkedAll = function(){
$(this).click(function(){
form = $(this).closest('form');
if (form.find('input:checkbox').attr('checked') == ""){
$(form).find('input:checkbox').attr('checked','checked');
}else{
$(form).find('input:checkbox').attr('checked','');
}
return false;
});
};
 
/**
* PREVIEW IMAGE
*/
$.fn.previewImg = function(options){
 
var options = $.extend({
'removeOld':true,
'event':'click'
},options);
var xOffset =5;
var yOffset = 15;
 
if (options.event == 'hover'){
$(this).hover(function(e){
_showPreview(e);
},
function(){
this.title = this.t;
$("#screenshot").remove();
});
$(this).mousemove(function(e){
$("#screenshot")
.css("top",(e.pageY + yOffset) + "px")
.css("left",(e.pageX + xOffset) + "px");
});
}
if (options.event =='click'){
$(this).bind('click',_showPreview);
}
$(this).click(function(){
return false
});
 
function _showPreview(e){
if (options.event == 'click' && options.removeOld == false){
idscreenshot = Math.floor(Math.random()*30000);
}else{
$("#screenshot").remove();
idscreenshot = 'screenshot'
};
e.currentTarget.t = e.currentTarget.title;
e.currentTarget.title = "";
var c = (e.currentTarget.t != "") ? "<br/><div style='text-align:center'>" + e.currentTarget.t+"</div>" : "";
$("body").append("<div id='"+idscreenshot+"' class='screenshot' class='position:absolute;border:1px solid #ccc;background:#333;padding:5px;display:none;color:#fff;'><img src='"+ e.currentTarget.href +"' alt='url preview' />"+ c +"</div>");
$("#"+idscreenshot).css({
position:"absolute",
border:"1px solid #ccc",
background:"#333",
"box-shadow":"5px 5px 2px #CCC",
"-moz-box-shadow": "2px 2px 2px #CCC",
"-webkit-box-shadow": "4px 4px 4px #CCC",
padding:"5px",
display:'none',
color:"#fff",
cursor:"pointer"
})
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
$("#"+idscreenshot).click(function(){
$(this).remove();
});
}
}
/**
* TOOL TIP
*/
$.fn.tooltip = function(){
xOffset =5;
yOffset = 10;
if ($(this).attr('title').length > 0){
$(this).hover(function(e){
idtooltip = Math.floor(Math.random()*30000);
this.t = this.title;
this.title = '';
$("body").append("<p id='"+idtooltip+"'>"+ this.t +"</p>");
$("#"+idtooltip).css({
position:"absolute",
border:"1px solid #333",
background:"#f7f5d1",
"box-shadow":"5px 5px 2px #CCC",
"-moz-box-shadow": "2px 2px 2px #CCC",
"-webkit-box-shadow": "2px 2px 2px #CCC",
padding:"2px 5px",
color:"#333",
display:"none"
})
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn(100);
},
function(){
this.title = this.t;
$("#"+idtooltip).fadeOut('100',function(){
$(this).remove();
});
});
$(this).mousemove(function(e){
$("#"+idtooltip)
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
}
}
});
 
 
 
/**
* CENTER
*/
$.fn.equalWmargin = function(){
$(this).css('left',($(window).width()-$(this).outerWidth())/2);
}
$.fn.equalHmargin = function(){
$(this).css('top',($(window).height()-$(this).outerHeight())/2);
}
$.fn.equalMargin = function(){
$(this).css('top',($(window).height()-$(this).outerHeight())/2);
$(this).css('left',($(window).width()-$(this).outerWidth())/2);
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.