diff --git a/.gitignore b/.gitignore index d40693b..bc50b5e 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,4 @@ dw_php_codehinting.config #npm stuffs node_modules/ -.sass_cache \ No newline at end of file +.sass-cache/ \ No newline at end of file diff --git a/css/cwv3.css b/css/cwv3.css index 4ec323c..1e0815b 100644 --- a/css/cwv3.css +++ b/css/cwv3.css @@ -1,13 +1,55 @@ /* CSS Document */ -.cwv3_box{background: transparent;} +.cwv3_box { + background: transparent; +} + /* Undocumented cBox colors */ -#cboxLoadingOverlay, #cboxContent, #cboxLoadedContent{background-color: #FFF !important;} -#cwv3_auth{border: 3px solid #ccc; background: #FFF;} -#cwv3_auth div{padding: 0.25em} -#cwv3_title{color: #FFF; font-weight: bold; text-align:center; background: #f00;} -#cwv3_btns{overflow:hidden;} -#cwv3_btns div a{ display: block; width: 100%; text-align:center; color: #FFF; font-weight:bold; text-decoration:none;} -#cwv3_enter{float:left; width: 40%;} -#cwv3_enter a{background-color: #0C3;} -#cwv3_exit{float:right; width: 40%;} -#cwv3_exit a{background-color: #F00;} \ No newline at end of file +#cboxLoadingOverlay, #cboxContent, #cboxLoadedContent { + background-color: #FFF !important; +} + +#cwv3_auth { + border: 3px solid #ccc; + background: #FFF; +} +#cwv3_auth div { + padding: 0.25em; +} + +#cwv3_title { + color: #FFF; + font-weight: bold; + text-align: center; + background: #f00; +} + +#cwv3_btns { + overflow: hidden; +} + +#cwv3_btns div a { + display: block; + width: 100%; + text-align: center; + color: #FFF; + font-weight: bold; + text-decoration: none; +} + +#cwv3_enter { + float: left; + width: 40%; +} + +#cwv3_enter a { + background-color: #0C3; +} + +#cwv3_exit { + float: right; + width: 40%; +} + +#cwv3_exit a { + background-color: #F00; +} diff --git a/css/cwv3.min.css b/css/cwv3.min.css new file mode 100644 index 0000000..e97a397 --- /dev/null +++ b/css/cwv3.min.css @@ -0,0 +1 @@ +.cwv3_box{background:0 0}#cboxContent,#cboxLoadedContent,#cboxLoadingOverlay{background-color:#FFF!important}#cwv3_auth{border:3px solid #ccc;background:#FFF}#cwv3_auth div{padding:.25em}#cwv3_title{color:#FFF;font-weight:700;text-align:center;background:red}#cwv3_btns{overflow:hidden}#cwv3_btns div a{display:block;width:100%;text-align:center;color:#FFF;font-weight:700;text-decoration:none}#cwv3_enter{float:left;width:40%}#cwv3_enter a{background-color:#0C3}#cwv3_exit{float:right;width:40%}#cwv3_exit a{background-color:red} \ No newline at end of file diff --git a/css/sass/cwv3.scss b/css/sass/cwv3.scss new file mode 100644 index 0000000..3fa1d9d --- /dev/null +++ b/css/sass/cwv3.scss @@ -0,0 +1,56 @@ +/* CSS Document */ +.cwv3_box { + background: transparent; +} + +/* Undocumented cBox colors */ +#cboxLoadingOverlay, #cboxContent, #cboxLoadedContent { + background-color: #FFF !important; +} + +#cwv3_auth { + border: 3px solid #ccc; + background: #FFF; + + div{ + padding: 0.25em; + } +} + +#cwv3_title { + color: #FFF; + font-weight: bold; + text-align: center; + background: #f00; +} + +#cwv3_btns { + overflow: hidden; +} + +#cwv3_btns div a { + display: block; + width: 100%; + text-align: center; + color: #FFF; + font-weight: bold; + text-decoration: none; +} + +#cwv3_enter { + float: left; + width: 40%; +} + +#cwv3_enter a { + background-color: #0C3; +} + +#cwv3_exit { + float: right; + width: 40%; +} + +#cwv3_exit a { + background-color: #F00; +} diff --git a/gruntfile.js b/gruntfile.js index e69de29..0a76f23 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -0,0 +1,91 @@ +module.exports = function ( grunt ){ + 'use strict'; + + grunt.initConfig({ + pkg: grunt.file.readJSON( 'package.json' ), + uglify: { + options: { + mangle: false + }, + dist: { + expand: true, + cwd: 'js', + src: ['*.js','!*.min.js'], + dest: 'js', + ext: '.min.js' + } + }, + jshint: { + options: { + node: false, + curly: false, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + unused: true, + boss: true, + eqnull: true, + browser: true, + globals: { + 'jQuery': true, + 'wp': true, + 'module': true + } + }, + gruntfile: { + src: 'gruntfile.js' + }, + lib_test: { + src: ['js/*.js', '!js/*.min.js'] + } + }, + sass: { + options: { + style: 'expanded' + }, + dist: { + files: { + 'css/cwv3.css': 'css/sass/cwv3.scss' + } + } + }, + cssmin: { + minify: { + src: 'css/cwv3.css', + dest: 'css/cwv3.min.css', + } + }, + watch: { + gruntfile: { + files: '<%= jshint.gruntfile.src %>', + tasks: ['jshint:gruntfile'] + }, + lib_test: { + files: '<%= jshint.lib_test.src %>', + tasks: ['jshint:lib_test'] + }, + css: { + files: 'css/**/*.scss', + tasks: ['sass', 'cssmin'] + }, + js: { + files: ['js/*.js', '!js/*.min.js'], + tasks: ['uglify'] + } + } + }); + + // These plugins provide necessary tasks + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-sass'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + + // Default task + grunt.registerTask('default', ['jshint', 'sass', 'uglify', 'cssmin']); +}; \ No newline at end of file diff --git a/js/cwv3.js b/js/cwv3.js index b1bbd67..488ed08 100644 --- a/js/cwv3.js +++ b/js/cwv3.js @@ -1,12 +1,12 @@ -// JavaScript Document +/* global cwv3_params */ jQuery(document).ready(function($) { var wpdata = cwv3_params; //console.log(wpdata); var enter = $('#cw_enter_link'); var exit = $('#cw_exit_link'); - if(wpdata.sd == true){ - var cboxObj = $.colorbox( + if(wpdata.sd === true){ + $.colorbox( { scrolling: false, overlayClose: false, @@ -25,9 +25,12 @@ jQuery(document).ready(function($) { ); enter.click(function(e){ + if( typeof(e) !== "undefined" ){ + e.preventDefault(); + } //console.log(e); - $.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'enter'}, function(e){ - if(cwv3_params.enter == "#"){ + $.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'enter'}, function(){ + if(cwv3_params.enter === "#"){ $.colorbox.close(); }else{ window.location = wpdata.enter; @@ -36,7 +39,10 @@ jQuery(document).ready(function($) { }); exit.click(function(e){ - $.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'exit'}, function(e){ + if( typeof(e) !== "undefined" ){ + e.preventDefault(); + } + $.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'exit'}, function(){ window.location = wpdata.exit; }); }); diff --git a/js/cwv3.min.js b/js/cwv3.min.js new file mode 100644 index 0000000..7a0d5b4 --- /dev/null +++ b/js/cwv3.min.js @@ -0,0 +1 @@ +jQuery(document).ready(function($){var wpdata=cwv3_params,enter=$("#cw_enter_link"),exit=$("#cw_exit_link");wpdata.sd===!0&&($.colorbox({scrolling:!1,overlayClose:!1,escKey:!1,inline:!0,href:"#cwv3_auth",initialWidth:"50%",maxWidth:"600px",loop:!1,onLoad:function(){$("#cboxClose").remove()},className:"cwv3_box",opacity:cwv3_params.opacity}),enter.click(function(e){"undefined"!=typeof e&&e.preventDefault(),$.post(wpdata.admin_url,{action:wpdata.action,nonce:wpdata.nonce,id:wpdata.id,method:"enter"},function(){"#"===cwv3_params.enter?$.colorbox.close():window.location=wpdata.enter})}),exit.click(function(e){"undefined"!=typeof e&&e.preventDefault(),$.post(wpdata.admin_url,{action:wpdata.action,nonce:wpdata.nonce,id:wpdata.id,method:"exit"},function(){window.location=wpdata.exit})}))}); \ No newline at end of file