Вход Регистрация
Файл: js/plugin.popups.js
Строк: 97
<?php
/**
 * plugin popups
 * 
 * @package Sngine JSL
 * @author Zamblek
 */

(function($){
    
    $.
popups = {
        
        
popup: function(options) {
            
            
// remove any opened popup
            
$("#popup").remove();
            
            
// default values
            
var defaults = {
                
source"loading",
                
data"",
                
width300,
                };
            var 
options = $.extend(defaultsoptions);
            
            
// append the popup window
            
$("body").append(
              
'<div id="popup" class="popupWrapper">' +
                
'<div class="popupContent">Loading...</div>' +
              
'</div>');
            
            $(
"#popup").css({
                
widthoptions.width
            
});
            
            $.
popups._reposition();
            
            
// handle the request
            
if(options.source !== "loading") {
                $.
ajax({
                    
type"POST",
                    
urloptions.source,
                    
dataoptions.data,
                    
success: function(data) {
                        $(
'#popup').html(data);
                    },
                    
error: function() {
                        $(
'#popup').html('<div class="popupHeader"><div class="button-close popup right" onclick="$.popups._hide();"></div>Error</div><div class="popupContent">There is some thing wrong happened</div>');
                    }
                });
            }
            
        },
        
        
confirm: function(messagewidthcallback) {
            
            $(
"#popup").remove();
            
            $(
"body").append(
              
'<div id="popup" class="popupWrapper">' +
                
'<div class="popupHeader">'message '</div>' +
                
'<div class="popupContent">' +
                  
'<input type="button" value="Yes" class="uiButton light-blue bigButton mr5" id="popup_ok" /><input type="button" value="No" class="uiButton bigButton" id="popup_cancel" />' +
                
'</div>' +
              
'</div>');
            
            $(
"#popup").css({
                
widthwidth
            
});
            
            
// reposition the popup window
            
$.popups._reposition();
            
            $(
"#popup_ok").click( function() {
                $.
popups._hide();
                if( 
callback callback(true);
            });
            
            $(
"#popup_cancel").click( function() {
                $.
popups._hide();
                if( 
callback callbackfalse );
            });
            
            $(
"#popup_ok").focus();
            
            $(
"#popup_ok, #popup_cancel").keypress( function(e) {
                if( 
e.keyCode == 13 ) $("#popup_ok").trigger('click');
                if( 
e.keyCode == 27 ) $("#popup_cancel").trigger('click');
            });
            
            
        },
        
        
alert: function(options) {
            
            
// remove any opened popup
            
$("#popup").remove();
            
            
// default values
            
var defaults = {
                
message"",
                
title"Error",
                
width450,
                };
            var 
options = $.extend(defaultsoptions);
            
            
// append the popup window
            
$("body").append(
              
'<div id="popup" class="popupWrapper">' +
                
'<div class="popupHeader"><div class="button-close popup right" onclick="$.popups._hide();"></div>' options.title '</div>' +
                
'<div class="popupContent">' options.message '</div>' +
              
'</div>');
            
            $(
"#popup").css({
                
widthoptions.width
            
});
            
            
// reposition the popup window
            
$.popups._reposition();
            
        },
        
        
_reposition: function() {
            var 
top  = ($(window).height() - $("#popup").outerHeight()) / window.pageYOffset;
            var 
left = ($(window).width() - $("#popup").outerWidth()) / 2;
            
            if( 
top top 0;
            if( 
left left 0;
            
            $(
"#popup").css({
                
toptop 'px',
                
leftleft 'px'
            
});
        },
        
        
_hide: function() {
            $(
"#popup").fadeOut( function() {
                $(
"#popup").remove();
            });
        }
        
    }
    
})(
jQuery);
?>
Онлайн: 2
Реклама