Dialog resizing fixes

This commit is contained in:
Jay Wood
2014-12-15 11:09:44 -05:00
parent a709bdc816
commit 39ad867b18
6 changed files with 21 additions and 12 deletions

View File

@ -4,7 +4,7 @@ Plugin Name: Content Warning v2
Plugin URI: http://plugish.com/plugins/content-warning-v3
Description: A plugin based on my v2 code, while drastically deviating from the original. Used mainly for NSFW websites, this plugin provides a dialog popup to warn viewers of it's possible content.
Author: Jerry Wood Jr.
Version: 3.6.0
Version: 3.6.1
Author URI: http://plugish.com
Text Domain: cwv3
*/

View File

@ -38,7 +38,7 @@
.cwv3_dialog .cwv3_content {
height: 80%;
max-height: 700px;
padding: .75em;
padding: 0 .75em;
overflow: auto;
margin-bottom: 0.25em;
}

2
css/cwv3.min.css vendored
View File

@ -1 +1 @@
.cwv3.dialog-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:99998}.cwv3_dialog{border:3px solid #ccc;background:#fff;max-width:60%;max-height:90%;position:fixed;top:25%;left:25%;-webkit-box-shadow:2px 11px 48px #000;-moz-box-shadow:2px 11px 48px #000;box-shadow:2px 11px 48px #000;overflow:hidden;z-index:99999}.cwv3_dialog div{padding:.25em}.cwv3_dialog .cwv3.auth,.cwv3_dialog .cwv3.denied{height:100%}.cwv3_dialog .cwv3_title{color:#fff;font-weight:700;text-align:center;background:red;margin-bottom:.25em}.cwv3_dialog .cwv3_content{height:80%;max-height:700px;padding:.75em;overflow:auto;margin-bottom:.25em}.cwv3_dialog .cwv3_btns{background:rgba(50,50,50,.5);bottom:0;overflow:hidden;padding:.45em .75em}.cwv3_dialog .cwv3_btns a{display:block;width:100%;text-align:center;color:#fff;font-weight:700;text-decoration:none;padding:.35em 0}.cwv3_dialog .cwv3_btns div{width:30%;display:inline-block}.cwv3_dialog .cwv3_btns .cwv3_exit{float:right}.cwv3_dialog .cwv3_btns .cwv3_exit a{background-color:red}.cwv3_dialog .cwv3_btns .cwv3_enter{float:left}.cwv3_dialog .cwv3_btns .cwv3_enter a{background-color:#0c3}
.cwv3.dialog-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:99998}.cwv3_dialog{border:3px solid #ccc;background:#fff;max-width:60%;max-height:90%;position:fixed;top:25%;left:25%;-webkit-box-shadow:2px 11px 48px #000;-moz-box-shadow:2px 11px 48px #000;box-shadow:2px 11px 48px #000;overflow:hidden;z-index:99999}.cwv3_dialog div{padding:.25em}.cwv3_dialog .cwv3.auth,.cwv3_dialog .cwv3.denied{height:100%}.cwv3_dialog .cwv3_title{color:#fff;font-weight:700;text-align:center;background:red;margin-bottom:.25em}.cwv3_dialog .cwv3_content{height:80%;max-height:700px;padding:0 .75em;overflow:auto;margin-bottom:.25em}.cwv3_dialog .cwv3_btns{background:rgba(50,50,50,.5);bottom:0;overflow:hidden;padding:.45em .75em}.cwv3_dialog .cwv3_btns a{display:block;width:100%;text-align:center;color:#fff;font-weight:700;text-decoration:none;padding:.35em 0}.cwv3_dialog .cwv3_btns div{width:30%;display:inline-block}.cwv3_dialog .cwv3_btns .cwv3_exit{float:right}.cwv3_dialog .cwv3_btns .cwv3_exit a{background-color:red}.cwv3_dialog .cwv3_btns .cwv3_enter{float:left}.cwv3_dialog .cwv3_btns .cwv3_enter a{background-color:#0c3}

View File

@ -41,7 +41,7 @@
.cwv3_content{
height: 80%;
max-height: 700px;
padding: .75em;
padding: 0 .75em;
overflow: auto;
margin-bottom: 0.25em;
}
@ -51,8 +51,6 @@
bottom: 0;
overflow: hidden;
padding: .45em .75em;
// position: absolute;
// width: 100%;
a{
display: block;

View File

@ -13,6 +13,8 @@ window.cwv3 = ( function( window, document, $ ){
app.$denial = app.$dialog.find( '.cwv3.denied' );
app.$exit = app.$dialog.find( '.cwv3_exit' );
app.$enter = app.$dialog.find( '.cwv3_enter' );
app.$buttons = app.$dialog.find( '.cwv3_btns' );
app.$title = app.$dialog.find( '.cwv3_title' );
app.$overlay = $( '.cwv3.dialog-overlay' );
app.cookie_name = ( '' !== cwv3_params.cookie_name ) ? 'cwv3_cookie_' + cwv3_params.cookie_name : false;
app.redirect_url = ( '' === cwv3_params.redirect_url || '#' === cwv3_params.redirect_url ) ? 'http://google.com' : cwv3_params.redirect_url;
@ -44,6 +46,8 @@ window.cwv3 = ( function( window, document, $ ){
};
app.center_dialog = function(){
app.$content.css( {'height' : ''} );
var diag ={
x: app.$dialog.width(),
y: app.$dialog.height(),
@ -53,12 +57,19 @@ window.cwv3 = ( function( window, document, $ ){
y: window.innerHeight,
};
// Remove the 'height' property from the content
var diag_pos = {
left: ( vp.x - diag.x ) * 0.5,
top : ( vp.y - diag.y ) * 0.5,
};
},
content_height = ( app.$dialog.height() - 10 ) - app.$buttons.outerHeight( true ) - app.$title.outerHeight( true );
app.$dialog.animate( diag_pos, 250 );
app.$content.animate( { height: content_height }, 250, 'swing', function(){
app.$dialog.animate( diag_pos, 250, 'swing', app.cache );
} );
// app.cache();
};
app.enter_handler = function( evt ){

2
js/cwv3.min.js vendored
View File

@ -1 +1 @@
window.cwv3=function(window,document,$){var app={};return app.cache=function(){app.$dialog=$(".cwv3_dialog"),app.$content=app.$dialog.find(".cwv3_content"),app.$auth=app.$dialog.find(".cwv3.auth"),app.$denial=app.$dialog.find(".cwv3.denied"),app.$exit=app.$dialog.find(".cwv3_exit"),app.$enter=app.$dialog.find(".cwv3_enter"),app.$overlay=$(".cwv3.dialog-overlay"),app.cookie_name=""!==cwv3_params.cookie_name?"cwv3_cookie_"+cwv3_params.cookie_name:!1,app.redirect_url=""===cwv3_params.redirect_url||"#"===cwv3_params.redirect_url?"http://google.com":cwv3_params.redirect_url,app.cookie_data=$.cookie(app.cookie_name),app.diag={max_percent_width:50,max_percent_height:50},app.timeout=""},app.init=function(){app.cache(),$("body").on("click",".cwv3_enter",app.enter_handler),$("body").on("click",".cwv3_exit",app.exit_handler),$(window).resize(function(){clearTimeout(app.timeout),app.timeout=setTimeout(app.center_dialog,500)}),app.cookie_name&&app.dialog_switch()},app.center_dialog=function(){var diag={x:app.$dialog.width(),y:app.$dialog.height()},vp={x:window.innerWidth,y:window.innerHeight},diag_pos={left:.5*(vp.x-diag.x),top:.5*(vp.y-diag.y)};app.$dialog.animate(diag_pos,250)},app.enter_handler=function(evt){evt.preventDefault(),app.set_cookie("enter");var $enter_url=app.$enter.find("a").attr("href");"#"===$enter_url||""===$enter_url?app.close_handler():window.location.replace($enter_url)},app.exit_handler=function(evt){evt.preventDefault(),"denied"!==app.cookie_data&&app.set_cookie("exit");var $exit_url=app.$exit.find("a").attr("href");window.location.replace("#"===$exit_url||""===$exit_url?"http://google.com":$exit_url)},app.set_cookie=function(method){method="exit"===method?"denied":!0,$.cookie(app.cookie_name,method,{expires:parseInt(cwv3_params.cookie_time),path:cwv3_params.cookie_path})},app.close_handler=function(){app.$dialog.fadeOut(100,function(){app.$overlay.fadeOut(100)})},app.dialog_switch=function(){"denied"===app.cookie_data?(app.$auth.remove(),"redirect"===cwv3_params.denial_method?window.location.replace(app.redirect_url):app.show_popup()):void 0===app.cookie_data&&(app.$denial.remove(),app.show_popup())},app.show_popup=function(){app.$overlay.fadeIn(200,function(){app.$dialog.fadeIn(100,function(){app.center_dialog()})})},$(document).ready(app.init),app}(window,document,jQuery);
window.cwv3=function(window,document,$){var app={};return app.cache=function(){app.$dialog=$(".cwv3_dialog"),app.$content=app.$dialog.find(".cwv3_content"),app.$auth=app.$dialog.find(".cwv3.auth"),app.$denial=app.$dialog.find(".cwv3.denied"),app.$exit=app.$dialog.find(".cwv3_exit"),app.$enter=app.$dialog.find(".cwv3_enter"),app.$buttons=app.$dialog.find(".cwv3_btns"),app.$title=app.$dialog.find(".cwv3_title"),app.$overlay=$(".cwv3.dialog-overlay"),app.cookie_name=""!==cwv3_params.cookie_name?"cwv3_cookie_"+cwv3_params.cookie_name:!1,app.redirect_url=""===cwv3_params.redirect_url||"#"===cwv3_params.redirect_url?"http://google.com":cwv3_params.redirect_url,app.cookie_data=$.cookie(app.cookie_name),app.diag={max_percent_width:50,max_percent_height:50},app.timeout=""},app.init=function(){app.cache(),$("body").on("click",".cwv3_enter",app.enter_handler),$("body").on("click",".cwv3_exit",app.exit_handler),$(window).resize(function(){clearTimeout(app.timeout),app.timeout=setTimeout(app.center_dialog,500)}),app.cookie_name&&app.dialog_switch()},app.center_dialog=function(){app.$content.css({height:""});var diag={x:app.$dialog.width(),y:app.$dialog.height()},vp={x:window.innerWidth,y:window.innerHeight},diag_pos={left:.5*(vp.x-diag.x),top:.5*(vp.y-diag.y)},content_height=app.$dialog.height()-10-app.$buttons.outerHeight(!0)-app.$title.outerHeight(!0);app.$content.animate({height:content_height},250,"swing",function(){app.$dialog.animate(diag_pos,250,"swing",app.cache)})},app.enter_handler=function(evt){evt.preventDefault(),app.set_cookie("enter");var $enter_url=app.$enter.find("a").attr("href");"#"===$enter_url||""===$enter_url?app.close_handler():window.location.replace($enter_url)},app.exit_handler=function(evt){evt.preventDefault(),"denied"!==app.cookie_data&&app.set_cookie("exit");var $exit_url=app.$exit.find("a").attr("href");window.location.replace("#"===$exit_url||""===$exit_url?"http://google.com":$exit_url)},app.set_cookie=function(method){method="exit"===method?"denied":!0,$.cookie(app.cookie_name,method,{expires:parseInt(cwv3_params.cookie_time),path:cwv3_params.cookie_path})},app.close_handler=function(){app.$dialog.fadeOut(100,function(){app.$overlay.fadeOut(100)})},app.dialog_switch=function(){"denied"===app.cookie_data?(app.$auth.remove(),"redirect"===cwv3_params.denial_method?window.location.replace(app.redirect_url):app.show_popup()):void 0===app.cookie_data&&(app.$denial.remove(),app.show_popup())},app.show_popup=function(){app.$overlay.fadeIn(200,function(){app.$dialog.fadeIn(100,function(){app.center_dialog()})})},$(document).ready(app.init),app}(window,document,jQuery);