From facf8d308fe27d30e66a4716180a316425fcac75 Mon Sep 17 00:00:00 2001 From: Peter Date: Sat, 6 Sep 2014 14:36:44 -0700 Subject: [PATCH 1/6] Adding in grunt files for js and less minification. --- Gruntfile.js | 52 ++ css/index.css | 124 --- index.html | 12 +- manifest.json | 4 +- package.json | 10 + public/style.css | 1 + public/tabResize.js | 1122 ++++++++++++++++++++++++++++ public/tabResize.min.js | 1 + public/tabResize_background.js | 181 +++++ public/tabResize_background.min.js | 1 + 10 files changed, 1372 insertions(+), 136 deletions(-) create mode 100644 Gruntfile.js delete mode 100644 css/index.css create mode 100644 package.json create mode 100644 public/style.css create mode 100644 public/tabResize.js create mode 100644 public/tabResize.min.js create mode 100644 public/tabResize_background.js create mode 100644 public/tabResize_background.min.js diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..43a3c38 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,52 @@ +module.exports = function(grunt) { + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + concat: { + options: { + separator: ';', + }, + basic: { + src: [ + 'js/tracking.js', + 'js/resize.js', + 'js/main_view.js', + 'js/custom_view.js', + 'js/options.js', + 'js/layout.js', + 'js/utility.js', + 'js/display.js', + 'js/main.js' + ], + dest: 'public/<%= pkg.name %>.js' + }, + extras: { + src: [ + 'js/background.js' + ], + dest: 'public/<%= pkg.name %>_background.js' + } + }, + uglify: { + my_target: { + files: { + 'public/<%= pkg.name %>.min.js': ['public/<%= pkg.name %>.js'], + 'public/<%= pkg.name %>_background.min.js': ['public/<%= pkg.name %>_background.js'] + } + } + }, + less: { + production: { + options: { + cleancss: true + }, + files: { + "public/style.css": "css/index.less" + } + } + } + }); + + ['grunt-contrib-concat', 'grunt-contrib-uglify', 'grunt-contrib-less'].forEach(grunt.loadNpmTasks); + + grunt.registerTask('default', ['concat','uglify','less']); +}; \ No newline at end of file diff --git a/css/index.css b/css/index.css deleted file mode 100644 index ce72a18..0000000 --- a/css/index.css +++ /dev/null @@ -1,124 +0,0 @@ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;} -article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block;} -body{line-height:1;} -ol,ul{list-style:none;} -blockquote,q{quotes:none;} -blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} -table{border-collapse:collapse;border-spacing:0;} -[type="checkbox"]:not(:checked),[type="checkbox"]:checked{position:absolute;left:-9999px;} -[type="checkbox"]:not(:checked)+span,[type="checkbox"]:checked+span{position:relative;padding-left:25px;cursor:pointer;} -[type="checkbox"]:not(:checked)+span:before,[type="checkbox"]:checked+span:before{content:'';position:absolute;left:0;top:0px;width:17px;height:17px;border:1px solid #aaa;background:#f8f8f8;border-radius:3px;box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.3);} -[type="checkbox"]:not(:checked)+span:after,[type="checkbox"]:checked+span:after{content:'\2713';position:absolute;top:-8px;left:1px;font-size:25px;color:black;} -[type="checkbox"]:not(:checked)+span:after{opacity:0;transform:scale(0);} -[type="checkbox"]:checked+span:after{opacity:1;transform:scale(1);} -[type="checkbox"]:disabled:not(:checked)+span:before,[type="checkbox"]:disabled:checked+span:before{box-shadow:none;border-color:#bbb;background-color:#ddd;} -[type="checkbox"]:disabled:checked+span:after{color:#999;} -[type="checkbox"]:disabled+span{color:#aaa;} -.switch-toggle a,.switch-light span span{display:none;} -.switch-toggle{display:block;height:30px;position:relative;padding:0 !important;} -.switch-toggle *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;} -.switch-toggle a{display:block;-webkit-transition:all 0.3s ease-out;-moz-transition:all 0.3s ease-out;transition:all 0.3s ease-out;} -.switch-toggle label,.switch-toggle>span{line-height:30px;vertical-align:middle;} -.switch-toggle input{position:absolute;opacity:0;} -.switch-toggle input+label{position:relative;top:static;right:static;left:static;display:inherit;width:50%;z-index:2;float:left;height:100%;margin:0;text-align:center;cursor:pointer;}.switch-toggle input+label:hover{background:#b4e2f6;box-shadow:inset 0px 0px 0px 3px #28a2d5;-webkit-box-shadow:inset 0px 0px 0px 3px #28a2d5;} -.switch-toggle a{position:absolute;top:0;right:static;left:0;display:inherit;width:50%;z-index:1;padding:0;height:100%;} -.switch-toggle input:last-of-type:checked~a{left:50%;} -.switch-candy{background-color:#ffffff;border:none;border-radius:6px;color:#ffffff;text-align:center;border:2px solid #808080;}.switch-candy label{color:#000000;} -.switch-candy input:checked+label{color:#000000;cursor:default;}.switch-candy input:checked+label:hover{background:transparent;box-shadow:inset 0px 0px 0px 3px transparent;-webkit-box-shadow:inset 0px 0px 0px 3px transparent;} -.switch-candy a{background-color:#eeeeee;border:1px solid #808080;border-radius:3px;background-image:-webkit-linear-gradient(top, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0));background-image:linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0));} -.switch-candy>span{color:#808080;text-shadow:none;} -.switch-candy span{color:#ffffff;} -html,body{background:white;min-width:630px;} -.hidden{display:none;} -.inactive{opacity:0.2;pointer-events:none;} -.active{display:block;} -strong,.bold{font-weight:bold;} -a{text-decoration:none;}a:hover{text-decoration:underline;} -@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');}.glyphicon{position:relative;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;font-size:18px;box-sizing:border-box;}.glyphicon.glyphicon-refresh:before{content:"\e031";box-sizing:border-box;} -.glyphicon.glyphicon-plus{top:-1px;}.glyphicon.glyphicon-plus:before{content:"\2b";box-sizing:border-box;} -.glyphicon.glyphicon-chevron-down:before{content:"\e114";} -.icon{height:18px;width:18px;position:relative;overflow:hidden;display:inline-block;}.icon.icon-screen{width:32px;height:25px;} -.icon .screen{width:28px;height:16px;border:2px solid #333;background:#eee;}.icon .screen:before{position:absolute;content:'';width:10px;height:3px;background:#333;bottom:2px;left:11px;} -.icon .screen:after{position:absolute;content:'';width:22px;height:2px;background:#333;bottom:0;left:5px;} -input{font-family:Verdana,Geneva,sans-serif;font-size:14px;} -button{outline:none;color:black;padding:5px 10px;font-size:13px;border-radius:3px;font-family:Verdana,Geneva,sans-serif;background:-webkit-linear-gradient(top, #ffffff 0%, #f1f1f1 50%, #f6f6f6 100%);border:1px solid #707070;}button:hover{background:-webkit-linear-gradient(top, #eeeeee 0%, #cccccc 100%);cursor:pointer;box-shadow:0px 0px 3px #707070;-webkit-box-shadow:0px 0px 3px #707070;} -button.primary{border:1px solid #707070;color:white;border:1px solid #333;background:-webkit-linear-gradient(top, #4c4c4c 0%, #595959 12%, #666666 25%, #474747 39%, #2c2c2c 50%, #000000 51%, #111111 60%, #2b2b2b 76%, #1c1c1c 91%, #131313 100%);}button.primary:hover{box-shadow:0px 0px 3px #707070;-webkit-box-shadow:0px 0px 3px #707070;background:-webkit-linear-gradient(top, #4c4c4c 0%, #595959 12%, #666666 25%, #474747 100%, #1c1c1c 100%, #2b2b2b 100%, #111111 100%, #2c2c2c 100%, #000000 100%, #131313 100%);} -button.disabled{opacity:0.5;pointer-events:none;} -.modal-box{font-family:Verdana,Geneva,sans-serif;background:white;border:4px solid #7C7C7C;box-shadow:0px 0px 4px #7c7c7c inset;-webkit-box-shadow:0px 0px 4px #7c7c7c inset;border-radius:8px;position:absolute;top:50%;left:50%;}.modal-box .modal-body{border-radius:4px 4px 0 0;padding:2px 10px 0 10px;width:400px;height:144px;} -.modal-box .modal-footer{border-radius:0 0 4px 4px;padding:0 10px;border-top:1px solid #c0c0c0;overflow:hidden;background:#E7F3FD;}.modal-box .modal-footer .button{float:right;margin:6px 10px 6px 0;} -.display-setting-indicator{display:none;width:0;height:0;position:absolute;z-index:2;bottom:0px;left:80px;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid silver;} -.main-view.display-selected .display-setting-indicator{display:block;} -.main-view.display-selected .resize-footer{border-bottom-width:7px;} -.main-view.display-selected #display-setting-layer{display:block;} -.main-view.display-selected #display-setting{background:#dcf0f6;}.main-view.display-selected #display-setting:hover,.main-view.display-selected #display-setting:focus{background:#b4e2f6;} -.main-view.display-selected .glyphicon-chevron-down:before{content:"\e113";} -.main-view{padding-top:4px;overflow:hidden;}.main-view .resize-container{padding:0 5px;height:156px;overflow-y:auto;}.main-view .resize-container .resize-selector-container{width:127px;height:127px;margin:2px 4px 10px 2px;display:inline-block;position:relative;border:1px solid transparent;border-radius:4px;padding:0 0 15px 15px;float:right;}.main-view .resize-container .resize-selector-container .close-button{width:18px;height:18px;border-radius:10px;cursor:pointer;background:url('../images/sprites/close.png');position:absolute;top:2px;right:2px;display:none;} -.main-view .resize-container .resize-selector-container .layout-title{position:absolute;font-weight:bold;font-size:16px;font-family:Verdana,Geneva,sans-serif;} -.main-view .resize-container .resize-selector-container .resize-selector{width:100px;height:100px;position:absolute;top:21px;border-radius:4px;border:5px solid #7C7C7C;}.main-view .resize-container .resize-selector-container .resize-selector .tab-layer{position:relative;display:inline-block;float:left;top:0px;left:0px;}.main-view .resize-container .resize-selector-container .resize-selector .tab-layer .fav-icon{position:absolute;background-repeat:no-repeat;background-size:27px 27px;width:27px;height:27px;background-image:url('../images/icons/defaultFavIcon.png');} -.main-view .resize-container .resize-selector-container:hover{cursor:pointer;border:1px solid #D3E3F7;background:-webkit-gradient(linear, left top, left bottom, from(#dcf0f6), to(#f4f8fe));-webkit-transition:all 200ms ease-in;}.main-view .resize-container .resize-selector-container:hover .layout-1x1{background:url('../images/sprites/layouts.png') 0px 100px;} -.main-view .resize-container .resize-selector-container:hover .layout-1x2{background:url('../images/sprites/layouts.png') -100px 100px;} -.main-view .resize-container .resize-selector-container:hover .layout-1x3{background:url('../images/sprites/layouts.png') -200px 100px;} -.main-view .resize-container .resize-selector-container:hover .layout-2x1{background:url('../images/sprites/layouts.png') -300px 100px;} -.main-view .resize-container .resize-selector-container:hover .layout-2x2{background:url('../images/sprites/layouts.png') -400px 100px;} -.main-view .resize-container .resize-selector-container:hover .layout-3x1{background:url('../images/sprites/layouts.png') -500px 100px;} -.main-view .resize-container .resize-selector-container:hover .layout-default{background:url('../images/sprites/layouts.png') -600px 100px;} -.main-view .resize-container .resize-selector-container:hover .close-button{display:block;}.main-view .resize-container .resize-selector-container:hover .close-button:hover{background:url('../images/sprites/close_hover.png');} -.main-view .resize-footer{border:3px solid #c0c0c0;overflow:hidden;background:#dcf0f6;clear:right;font-family:Verdana,Geneva,sans-serif;}.main-view .resize-footer .footer-wrap{display:inline-block;overflow:hidden;}.main-view .resize-footer .footer-wrap.button-wrap{padding:3px 0 0 2px;} -.main-view .resize-footer .footer-wrap.monitor-wrap{float:left;padding:6px 12px 5px 8px;border-right:3px solid silver;cursor:pointer;background:white;position:relative;}.main-view .resize-footer .footer-wrap.monitor-wrap:hover,.main-view .resize-footer .footer-wrap.monitor-wrap:focus{background:#b4e2f6;} -.main-view .resize-footer .footer-wrap.monitor-wrap .display-setting-title{vertical-align:top;font-size:15px;position:relative;top:5px;padding:0 13px 0 8px;border-right:1px solid silver;} -.main-view .resize-footer .footer-wrap.monitor-wrap .glyphicon{top:-3px;left:3px;} -.main-view .resize-footer .resize-undo{margin-left:12px;} -.main-view .resize-footer #custom-layout{padding:4px 15px 1px 15px;float:left;} -.main-view .resize-footer #default-configuration{padding:3px 15px 2px 15px;float:left;} -.main-view .resize-footer .checkbox-container{font-family:Verdana,Geneva,sans-serif;overflow:hidden;display:inline-block;border-left:3px solid silver;float:right;background:white;}.main-view .resize-footer .checkbox-container label{font-size:14px;display:block;padding:11px 7px 13px 10px;cursor:pointer;}.main-view .resize-footer .checkbox-container label.selected{background:#dcf0f6;} -.main-view .resize-footer .checkbox-container label:hover{background:#b4e2f6;} -.main-view .resize-footer .checkbox-container label input{border-radius:3px;-webkit-border-radius:3px;vertical-align:top;width:18px;height:18px;} -.main-view .resize-footer .checkbox-container label span{position:relative;top:1px;left:-2px;} -#display-setting-layer{display:none;position:relative;bottom:0px;margin:100px 50px 25px 50px;font-family:Verdana,Geneva,sans-serif;}#display-setting-layer .signature{position:absolute;bottom:-22px;font-size:13px;right:-45px;font-weight:bold;}#display-setting-layer .signature a{color:#005579;padding-right:5px;} -#display-setting-layer .signature .rate-it{border-left:1px solid silver;padding-left:5px;padding-right:0px;} -#display-setting-layer .switch-toggle{top:-80px;left:0px;width:100%;}#display-setting-layer .switch-toggle.right-align a{border-left-width:2px;} -#display-setting-layer .switch-toggle.left-align a{border-right-width:2px;} -#display-setting-layer .display-settings-divider{width:630px;height:1px;position:absolute;top:-22px;left:-50px;background:black;background:-webkit-gradient(linear, 0 0, 100% 0, from(#ffffff), to(#ffffff), color-stop(50%, #000000));} -#display-setting-layer .display-entry{position:absolute;border:1px solid grey;border-radius:3px;-webkit-border-radius:3px;box-shadow:inset 0px 0px 0px 2px #808080;-webkit-box-shadow:inset 0px 0px 0px 2px #808080;background:white;cursor:pointer;z-index:1;}#display-setting-layer .display-entry.selected{z-index:2;background:#eeeeee;border-color:#808080;box-shadow:inset 0px 0px 0px 4px #808080;-webkit-box-shadow:inset 0px 0px 0px 4px #808080;cursor:default;}#display-setting-layer .display-entry.selected:hover{background:#eeeeee;border-color:#808080;box-shadow:inset 0px 0px 0px 4px #808080;-webkit-box-shadow:inset 0px 0px 0px 4px #808080;} -#display-setting-layer .display-entry:hover{z-index:3;background:#b4e2f6;border-color:#28a2d5;box-shadow:inset 0px 0px 0px 4px #28a2d5;-webkit-box-shadow:inset 0px 0px 0px 4px #28a2d5;} -#display-setting-layer .display-entry .display-meta{position:relative;top:10px;left:10px;} -.custom-view .table-container{display:inline-block;position:relative;width:145px;height:145px;left:15px;}.custom-view .table-container .table-label-top{position:absolute;left:48px;top:3px;} -.custom-view .table-container .table-label-left{position:absolute;top:69px;left:-7px;-webkit-transform:rotate(-90deg) translate3d(0, 0, 0);} -.custom-view .table-container .table-cell-container{border:7px solid #7C7C7C;border-radius:4px;width:100px;height:100px;position:absolute;top:25px;left:25px;}.custom-view .table-container .table-cell-container canvas{background:#B4E2F6;} -.custom-view .input-container{display:inline-block;position:relative;top:-25px;left:34px;}.custom-view .input-container .label-container{margin-bottom:10px;overflow:hidden;}.custom-view .input-container .label-container label{height:26px;float:left;margin-right:11px;line-height:26px;} -.custom-view .input-container .label-container .custom-value{float:right;text-align:center;border-radius:2px;border:1px solid #7C7C7C;width:90px;outline:none;padding:4px;}.custom-view .input-container .label-container .custom-value:focus{border:1px solid #599EFF;box-shadow:#599EFF 0px 0px 2px 1px inset;} -.confirmation-modal .modal-body{height:75px;padding-top:35px;}.confirmation-modal .modal-body .warning-sprite{width:40px;height:40px;background:url('../images/sprites/warning.png');display:inline-block;float:left;margin-left:20px;margin-right:10px;} -.confirmation-modal .modal-body .message{width:304px;display:inline-block;float:left;} -.info-modal.modal-box{display:none;z-index:5;}.info-modal.modal-box .modal-body{width:450px;height:400px;}.info-modal.modal-box .modal-body .header-title-wrap{margin:15px auto;text-align:center;}.info-modal.modal-box .modal-body .header-title-wrap .icon-48{background:url('../images/icons/icon48.png');width:48px;height:48px;display:inline-block;} -.info-modal.modal-box .modal-body .header-title-wrap .header-title{display:inline-block;vertical-align:top;font-size:20px;margin:16px 16px 16px 10px;} -.info-modal.modal-box .modal-body .update-list-header{margin:0px 0px 10px 25px;font-style:italic;font-size:15px;} -.info-modal.modal-box .modal-body ul.update-list{margin:0 28px 0 45px;font-size:15px;}.info-modal.modal-box .modal-body ul.update-list li.update-entry{list-style:disc;margin-bottom:10px;line-height:16px;} -.info-modal.modal-box .modal-body .update-list-footer{margin:14px 20px 0px 25px;font-size:15px;line-height:16px;} -.info-modal.modal-box .modal-body .additional-message{font-size:15px;margin:10px 20px 5px 25px;line-height:16px;} -.info-modal.modal-box .modal-body a{color:#0181eb;}.info-modal.modal-box .modal-body a:visited{color:#0181eb;} -.info-modal.modal-box .modal-footer{padding:0px 36px;border:none;background:white;}.info-modal.modal-box .modal-footer button{width:100%;margin:12px auto;float:none;height:40px;font-size:20px;padding-bottom:10px;background:-webkit-linear-gradient(top, #4096ee 0%, #4096ee 100%);} -#promo-modal .modal-body .header-title-wrap .icon-48{background:url('../images/icons/promo/icon48.png');} -body.update #update-modal{display:block;} -body.update .main-view{min-height:500px;} -body.promo #promo-modal{display:block;} -body.promo .main-view{min-height:500px;} -body.warning #warning-modal{display:block;} -body.warning .main-view{min-height:500px;} -body.align-right .tab-layer{float:right !important;} -body.empty-tab-not-selected .tab-layer{background:white;}body.empty-tab-not-selected .tab-layer .fav-icon{visibility:hidden;} -body.empty-tab-not-selected .tab-layer.valid-tab{background:transparent;}body.empty-tab-not-selected .tab-layer.valid-tab .fav-icon{visibility:visible;} -body.single-tab-selected .tab-layer{background:white !important;}body.single-tab-selected .tab-layer .fav-icon{visibility:hidden !important;} -body.single-tab-selected .tab-layer.tab-layer-1{background:transparent !important;}body.single-tab-selected .tab-layer.tab-layer-1 .fav-icon{visibility:visible !important;} -.layout-1x1{background:url('../images/sprites/layouts.png') 0px 0px;}.layout-1x1 .tab-layer{width:100%;height:100%;}.layout-1x1 .tab-layer .fav-icon{left:35px;top:35px;} -.layout-1x2{background:url('../images/sprites/layouts.png') -100px 0px;}.layout-1x2 .tab-layer{width:50%;height:100%;}.layout-1x2 .tab-layer .fav-icon{left:11px;top:35px;} -.layout-1x3{background:url('../images/sprites/layouts.png') -200px 0px;}.layout-1x3 .tab-layer{width:33.3%;height:100%;}.layout-1x3 .tab-layer .fav-icon{left:8px;top:39px;width:18px !important;height:18px !important;background-size:18px 18px !important;} -.layout-2x1{background:url('../images/sprites/layouts.png') -300px 0px;}.layout-2x1 .tab-layer{width:100%;height:50%;}.layout-2x1 .tab-layer .fav-icon{left:35px;top:16px;} -.layout-2x2{background:url('../images/sprites/layouts.png') -400px 0px;}.layout-2x2 .tab-layer{width:50%;height:50%;}.layout-2x2 .tab-layer .fav-icon{top:16px;left:11px;} -.layout-3x1{background:url('../images/sprites/layouts.png') -500px 0px;}.layout-3x1 .tab-layer{width:100%;height:33.3%;}.layout-3x1 .tab-layer .fav-icon{top:12px;left:42px;width:18px !important;height:18px !important;background-size:18px 18px !important;} -.layout-default{background:url('../images/sprites/layouts.png') -600px 0px;}.layout-default .tab-layer{display:none !important;} -.sortable-placeholder{width:113px;height:113px;margin:2px 4px 10px 2px;display:inline-block;position:relative;border:7px dashed darkgrey;border-radius:4px;padding:0 0 15px 15px;float:right;} -#update-modal.partial-update .update-entry{display:none;}#update-modal.partial-update .update-entry.latest{display:block;margin-bottom:50px;} -#update-modal.partial-update .update-list-footer{display:none;} -#update-modal.partial-update .modal-body{height:300px;} -#warning-modal{z-index:10;}#warning-modal .header-title{border-bottom:2px solid grey;padding-bottom:10px;margin-bottom:0px;} -#warning-modal .update-entry{list-style:none;line-height:22px;font-size:16px;margin-bottom:20px;} diff --git a/index.html b/index.html index f12b946..ddbe533 100644 --- a/index.html +++ b/index.html @@ -2,17 +2,9 @@ Resize - - + - - - - - - - - +
diff --git a/manifest.json b/manifest.json index ab6391c..8c5ac00 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Tab Resize - split screen layouts", "short_name": "Tab Resize", - "version": "2.1", + "version": "2.1.1", "manifest_version": 2, "description": "Split Screen made easy. Resize the CURRENT tab and tabs to the RIGHT into layouts on separate windows. w/ Multi Monitor Support.", "browser_action": { @@ -14,7 +14,7 @@ "128": "images/icons/icon128.png" }, "permissions": ["tabs", "system.display"], "background": { - "scripts": ["js/lib/jquery.min.js","js/background.js"] + "scripts": ["js/lib/jquery.min.js","public/tabResize_background.min.js"] }, "offline_enabled": true, "content_security_policy": "script-src 'self' https://www.google-analytics.com; object-src 'self'", diff --git a/package.json b/package.json new file mode 100644 index 0000000..1b964d1 --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "tabResize", + "version": "0.2.1", + "devDependencies": { + "grunt": "~0.4.5", + "grunt-contrib-concat": "~0.5.0", + "grunt-contrib-uglify": "~0.5.1", + "grunt-contrib-less":"~0.11.4" + } +} \ No newline at end of file diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..11703e9 --- /dev/null +++ b/public/style.css @@ -0,0 +1 @@ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}[type=checkbox]:not(:checked),[type=checkbox]:checked{position:absolute;left:-9999px}[type=checkbox]:not(:checked)+span,[type=checkbox]:checked+span{position:relative;padding-left:25px;cursor:pointer}[type=checkbox]:not(:checked)+span:before,[type=checkbox]:checked+span:before{content:'';position:absolute;left:0;top:0;width:17px;height:17px;border:1px solid #aaa;background:#f8f8f8;border-radius:3px;box-shadow:inset 0 1px 3px rgba(0,0,0,.3)}[type=checkbox]:not(:checked)+span:after,[type=checkbox]:checked+span:after{content:'\2713';position:absolute;top:-8px;left:1px;font-size:25px;color:#000}[type=checkbox]:not(:checked)+span:after{opacity:0;transform:scale(0)}[type=checkbox]:checked+span:after{opacity:1;transform:scale(1)}[type=checkbox]:disabled:not(:checked)+span:before,[type=checkbox]:disabled:checked+span:before{box-shadow:none;border-color:#bbb;background-color:#ddd}[type=checkbox]:disabled:checked+span:after{color:#999}[type=checkbox]:disabled+span{color:#aaa}.switch-toggle a,.switch-light span span{display:none}.switch-toggle{display:block;height:30px;position:relative;padding:0!important}.switch-toggle *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.switch-toggle a{display:block;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;transition:all .3s ease-out}.switch-toggle label,.switch-toggle>span{line-height:30px;vertical-align:middle}.switch-toggle input{position:absolute;opacity:0}.switch-toggle input+label{position:relative;top:static;right:static;left:static;display:inherit;width:50%;z-index:2;float:left;height:100%;margin:0;text-align:center;cursor:pointer}.switch-toggle input+label:hover{background:#b4e2f6;box-shadow:inset 0 0 0 3px #28a2d5;-webkit-box-shadow:inset 0 0 0 3px #28a2d5}.switch-toggle a{position:absolute;top:0;right:static;left:0;display:inherit;width:50%;z-index:1;padding:0;height:100%}.switch-toggle input:last-of-type:checked~a{left:50%}.switch-candy{background-color:#fff;border:none;border-radius:6px;color:#fff;text-align:center;border:2px solid gray}.switch-candy label{color:#000}.switch-candy input:checked+label{color:#000;cursor:default}.switch-candy input:checked+label:hover{background:0 0;box-shadow:inset 0 0 0 3px transparent;-webkit-box-shadow:inset 0 0 0 3px transparent}.switch-candy a{background-color:#eee;border:1px solid gray;border-radius:3px;background-image:-webkit-linear-gradient(top,rgba(255,255,255,.2),rgba(0,0,0,0));background-image:linear-gradient(to bottom,rgba(255,255,255,.2),rgba(0,0,0,0))}.switch-candy>span{color:gray;text-shadow:none}.switch-candy span{color:#fff}html,body{background:#fff;min-width:630px}.hidden{display:none}.inactive{opacity:.2;pointer-events:none}.active{display:block}strong,.bold{font-weight:700}a{text-decoration:none}a:hover{text-decoration:underline}@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);src:url(../fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'),url(../fonts/glyphicons-halflings-regular.woff) format('woff'),url(../fonts/glyphicons-halflings-regular.ttf) format('truetype'),url(../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg')}.glyphicon{position:relative;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;font-size:18px;box-sizing:border-box}.glyphicon.glyphicon-refresh:before{content:"\e031";box-sizing:border-box}.glyphicon.glyphicon-plus{top:-1px}.glyphicon.glyphicon-plus:before{content:"\2b";box-sizing:border-box}.glyphicon.glyphicon-chevron-down:before{content:"\e114"}.icon{height:18px;width:18px;position:relative;overflow:hidden;display:inline-block}.icon.icon-screen{width:32px;height:25px}.icon .screen{width:28px;height:16px;border:2px solid #333;background:#eee}.icon .screen:before{position:absolute;content:'';width:10px;height:3px;background:#333;bottom:2px;left:11px}.icon .screen:after{position:absolute;content:'';width:22px;height:2px;background:#333;bottom:0;left:5px}input{font-family:Verdana,Geneva,sans-serif;font-size:14px}button{outline:0;color:#000;padding:5px 10px;font-size:13px;border-radius:3px;font-family:Verdana,Geneva,sans-serif;background:-webkit-linear-gradient(top,#fff 0,#f1f1f1 50%,#f6f6f6 100%);border:1px solid #707070}button:hover{background:-webkit-linear-gradient(top,#eee 0,#ccc 100%);cursor:pointer;box-shadow:0 0 3px #707070;-webkit-box-shadow:0 0 3px #707070}button.primary{border:1px solid #707070;color:#fff;border:1px solid #333;background:-webkit-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%)}button.primary:hover{box-shadow:0 0 3px #707070;-webkit-box-shadow:0 0 3px #707070;background:-webkit-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 100%,#1c1c1c 100%,#2b2b2b 100%,#111 100%,#2c2c2c 100%,#000 100%,#131313 100%)}button.disabled{opacity:.5;pointer-events:none}.modal-box{font-family:Verdana,Geneva,sans-serif;background:#fff;border:4px solid #7C7C7C;box-shadow:0 0 4px #7c7c7c inset;-webkit-box-shadow:0 0 4px #7c7c7c inset;border-radius:8px;position:absolute;top:50%;left:50%}.modal-box .modal-body{border-radius:4px 4px 0 0;padding:2px 10px 0 10px;width:400px;height:144px}.modal-box .modal-footer{border-radius:0 0 4px 4px;padding:0 10px;border-top:1px solid silver;overflow:hidden;background:#E7F3FD}.modal-box .modal-footer .button{float:right;margin:6px 10px 6px 0}.display-setting-indicator{display:none;width:0;height:0;position:absolute;z-index:2;bottom:0;left:80px;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid silver}.main-view.display-selected .display-setting-indicator{display:block}.main-view.display-selected .resize-footer{border-bottom-width:7px}.main-view.display-selected #display-setting-layer{display:block}.main-view.display-selected #display-setting{background:#dcf0f6}.main-view.display-selected #display-setting:hover,.main-view.display-selected #display-setting:focus{background:#b4e2f6}.main-view.display-selected .glyphicon-chevron-down:before{content:"\e113"}.main-view{padding-top:4px;overflow:hidden}.main-view .resize-container{padding:0 5px;height:156px;overflow-y:auto}.main-view .resize-container .resize-selector-container{width:127px;height:127px;margin:2px 4px 10px 2px;display:inline-block;position:relative;border:1px solid transparent;border-radius:4px;padding:0 0 15px 15px;float:right}.main-view .resize-container .resize-selector-container .close-button{width:18px;height:18px;border-radius:10px;cursor:pointer;background:url(../images/sprites/close.png);position:absolute;top:2px;right:2px;display:none}.main-view .resize-container .resize-selector-container .layout-title{position:absolute;font-weight:700;font-size:16px;font-family:Verdana,Geneva,sans-serif}.main-view .resize-container .resize-selector-container .resize-selector{width:100px;height:100px;position:absolute;top:21px;border-radius:4px;border:5px solid #7C7C7C}.main-view .resize-container .resize-selector-container .resize-selector .tab-layer{position:relative;display:inline-block;float:left;top:0;left:0}.main-view .resize-container .resize-selector-container .resize-selector .tab-layer .fav-icon{position:absolute;background-repeat:no-repeat;background-size:27px 27px;width:27px;height:27px;background-image:url(../images/icons/defaultFavIcon.png)}.main-view .resize-container .resize-selector-container:hover{cursor:pointer;border:1px solid #D3E3F7;background:-webkit-gradient(linear,left top,left bottom,from(#dcf0f6),to(#f4f8fe));-webkit-transition:all 200ms ease-in}.main-view .resize-container .resize-selector-container:hover .layout-1x1{background:url(../images/sprites/layouts.png) 0 100px}.main-view .resize-container .resize-selector-container:hover .layout-1x2{background:url(../images/sprites/layouts.png) -100px 100px}.main-view .resize-container .resize-selector-container:hover .layout-1x3{background:url(../images/sprites/layouts.png) -200px 100px}.main-view .resize-container .resize-selector-container:hover .layout-2x1{background:url(../images/sprites/layouts.png) -300px 100px}.main-view .resize-container .resize-selector-container:hover .layout-2x2{background:url(../images/sprites/layouts.png) -400px 100px}.main-view .resize-container .resize-selector-container:hover .layout-3x1{background:url(../images/sprites/layouts.png) -500px 100px}.main-view .resize-container .resize-selector-container:hover .layout-default{background:url(../images/sprites/layouts.png) -600px 100px}.main-view .resize-container .resize-selector-container:hover .close-button{display:block}.main-view .resize-container .resize-selector-container:hover .close-button:hover{background:url(../images/sprites/close_hover.png)}.main-view .resize-footer{border:3px solid silver;overflow:hidden;background:#dcf0f6;clear:right;font-family:Verdana,Geneva,sans-serif}.main-view .resize-footer .footer-wrap{display:inline-block;overflow:hidden}.main-view .resize-footer .footer-wrap.button-wrap{padding:3px 0 0 2px}.main-view .resize-footer .footer-wrap.monitor-wrap{float:left;padding:6px 12px 5px 8px;border-right:3px solid silver;cursor:pointer;background:#fff;position:relative}.main-view .resize-footer .footer-wrap.monitor-wrap:hover,.main-view .resize-footer .footer-wrap.monitor-wrap:focus{background:#b4e2f6}.main-view .resize-footer .footer-wrap.monitor-wrap .display-setting-title{vertical-align:top;font-size:15px;position:relative;top:5px;padding:0 13px 0 8px;border-right:1px solid silver}.main-view .resize-footer .footer-wrap.monitor-wrap .glyphicon{top:-3px;left:3px}.main-view .resize-footer .resize-undo{margin-left:12px}.main-view .resize-footer #custom-layout{padding:4px 15px 1px 15px;float:left}.main-view .resize-footer #default-configuration{padding:3px 15px 2px 15px;float:left}.main-view .resize-footer .checkbox-container{font-family:Verdana,Geneva,sans-serif;overflow:hidden;display:inline-block;border-left:3px solid silver;float:right;background:#fff}.main-view .resize-footer .checkbox-container label{font-size:14px;display:block;padding:11px 7px 13px 10px;cursor:pointer}.main-view .resize-footer .checkbox-container label.selected{background:#dcf0f6}.main-view .resize-footer .checkbox-container label:hover{background:#b4e2f6}.main-view .resize-footer .checkbox-container label input{border-radius:3px;-webkit-border-radius:3px;vertical-align:top;width:18px;height:18px}.main-view .resize-footer .checkbox-container label span{position:relative;top:1px;left:-2px}#display-setting-layer{display:none;position:relative;bottom:0;margin:100px 50px 25px 50px;font-family:Verdana,Geneva,sans-serif}#display-setting-layer .signature{position:absolute;bottom:-22px;font-size:13px;right:-45px;font-weight:700}#display-setting-layer .signature a{color:#005579;padding-right:5px}#display-setting-layer .signature .rate-it{border-left:1px solid silver;padding-left:5px;padding-right:0}#display-setting-layer .switch-toggle{top:-80px;left:0;width:100%}#display-setting-layer .switch-toggle.right-align a{border-left-width:2px}#display-setting-layer .switch-toggle.left-align a{border-right-width:2px}#display-setting-layer .display-settings-divider{width:630px;height:1px;position:absolute;top:-22px;left:-50px;background:#000;background:-webkit-gradient(linear,0 0,100% 0,from(#fff),to(#fff),color-stop(50%,#000))}#display-setting-layer .display-entry{position:absolute;border:1px solid grey;border-radius:3px;-webkit-border-radius:3px;box-shadow:inset 0 0 0 2px gray;-webkit-box-shadow:inset 0 0 0 2px gray;background:#fff;cursor:pointer;z-index:1}#display-setting-layer .display-entry.selected{z-index:2;background:#eee;border-color:gray;box-shadow:inset 0 0 0 4px gray;-webkit-box-shadow:inset 0 0 0 4px gray;cursor:default}#display-setting-layer .display-entry.selected:hover{background:#eee;border-color:gray;box-shadow:inset 0 0 0 4px gray;-webkit-box-shadow:inset 0 0 0 4px gray}#display-setting-layer .display-entry:hover{z-index:3;background:#b4e2f6;border-color:#28a2d5;box-shadow:inset 0 0 0 4px #28a2d5;-webkit-box-shadow:inset 0 0 0 4px #28a2d5}#display-setting-layer .display-entry .display-meta{position:relative;top:10px;left:10px}.custom-view .table-container{display:inline-block;position:relative;width:145px;height:145px;left:15px}.custom-view .table-container .table-label-top{position:absolute;left:48px;top:3px}.custom-view .table-container .table-label-left{position:absolute;top:69px;left:-7px;-webkit-transform:rotate(-90deg) translate3d(0,0,0)}.custom-view .table-container .table-cell-container{border:7px solid #7C7C7C;border-radius:4px;width:100px;height:100px;position:absolute;top:25px;left:25px}.custom-view .table-container .table-cell-container canvas{background:#B4E2F6}.custom-view .input-container{display:inline-block;position:relative;top:-25px;left:34px}.custom-view .input-container .label-container{margin-bottom:10px;overflow:hidden}.custom-view .input-container .label-container label{height:26px;float:left;margin-right:11px;line-height:26px}.custom-view .input-container .label-container .custom-value{float:right;text-align:center;border-radius:2px;border:1px solid #7C7C7C;width:90px;outline:0;padding:4px}.custom-view .input-container .label-container .custom-value:focus{border:1px solid #599EFF;box-shadow:#599EFF 0 0 2px 1px inset}.confirmation-modal .modal-body{height:75px;padding-top:35px}.confirmation-modal .modal-body .warning-sprite{width:40px;height:40px;background:url(../images/sprites/warning.png);display:inline-block;float:left;margin-left:20px;margin-right:10px}.confirmation-modal .modal-body .message{width:304px;display:inline-block;float:left}.info-modal.modal-box{display:none;z-index:5}.info-modal.modal-box .modal-body{width:450px;height:400px}.info-modal.modal-box .modal-body .header-title-wrap{margin:15px auto;text-align:center}.info-modal.modal-box .modal-body .header-title-wrap .icon-48{background:url(../images/icons/icon48.png);width:48px;height:48px;display:inline-block}.info-modal.modal-box .modal-body .header-title-wrap .header-title{display:inline-block;vertical-align:top;font-size:20px;margin:16px 16px 16px 10px}.info-modal.modal-box .modal-body .update-list-header{margin:0 0 10px 25px;font-style:italic;font-size:15px}.info-modal.modal-box .modal-body ul.update-list{margin:0 28px 0 45px;font-size:15px}.info-modal.modal-box .modal-body ul.update-list li.update-entry{list-style:disc;margin-bottom:10px;line-height:16px}.info-modal.modal-box .modal-body .update-list-footer{margin:14px 20px 0 25px;font-size:15px;line-height:16px}.info-modal.modal-box .modal-body .additional-message{font-size:15px;margin:10px 20px 5px 25px;line-height:16px}.info-modal.modal-box .modal-body a{color:#0181eb}.info-modal.modal-box .modal-body a:visited{color:#0181eb}.info-modal.modal-box .modal-footer{padding:0 36px;border:none;background:#fff}.info-modal.modal-box .modal-footer button{width:100%;margin:12px auto;float:none;height:40px;font-size:20px;padding-bottom:10px;background:-webkit-linear-gradient(top,#4096ee 0,#4096ee 100%)}#promo-modal .modal-body .header-title-wrap .icon-48{background:url(../images/icons/promo/icon48.png)}body.update #update-modal{display:block}body.update .main-view{min-height:500px}body.promo #promo-modal{display:block}body.promo .main-view{min-height:500px}body.warning #warning-modal{display:block}body.warning .main-view{min-height:500px}body.align-right .tab-layer{float:right!important}body.empty-tab-not-selected .tab-layer{background:#fff}body.empty-tab-not-selected .tab-layer .fav-icon{visibility:hidden}body.empty-tab-not-selected .tab-layer.valid-tab{background:0 0}body.empty-tab-not-selected .tab-layer.valid-tab .fav-icon{visibility:visible}body.single-tab-selected .tab-layer{background:#fff!important}body.single-tab-selected .tab-layer .fav-icon{visibility:hidden!important}body.single-tab-selected .tab-layer.tab-layer-1{background:transparent!important}body.single-tab-selected .tab-layer.tab-layer-1 .fav-icon{visibility:visible!important}.layout-1x1{background:url(../images/sprites/layouts.png) 0 0}.layout-1x1 .tab-layer{width:100%;height:100%}.layout-1x1 .tab-layer .fav-icon{left:35px;top:35px}.layout-1x2{background:url(../images/sprites/layouts.png) -100px 0}.layout-1x2 .tab-layer{width:50%;height:100%}.layout-1x2 .tab-layer .fav-icon{left:11px;top:35px}.layout-1x3{background:url(../images/sprites/layouts.png) -200px 0}.layout-1x3 .tab-layer{width:33.3%;height:100%}.layout-1x3 .tab-layer .fav-icon{left:8px;top:39px;width:18px!important;height:18px!important;background-size:18px 18px!important}.layout-2x1{background:url(../images/sprites/layouts.png) -300px 0}.layout-2x1 .tab-layer{width:100%;height:50%}.layout-2x1 .tab-layer .fav-icon{left:35px;top:16px}.layout-2x2{background:url(../images/sprites/layouts.png) -400px 0}.layout-2x2 .tab-layer{width:50%;height:50%}.layout-2x2 .tab-layer .fav-icon{top:16px;left:11px}.layout-3x1{background:url(../images/sprites/layouts.png) -500px 0}.layout-3x1 .tab-layer{width:100%;height:33.3%}.layout-3x1 .tab-layer .fav-icon{top:12px;left:42px;width:18px!important;height:18px!important;background-size:18px 18px!important}.layout-default{background:url(../images/sprites/layouts.png) -600px 0}.layout-default .tab-layer{display:none!important}.sortable-placeholder{width:113px;height:113px;margin:2px 4px 10px 2px;display:inline-block;position:relative;border:7px dashed darkgrey;border-radius:4px;padding:0 0 15px 15px;float:right}#update-modal.partial-update .update-entry{display:none}#update-modal.partial-update .update-entry.latest{display:block;margin-bottom:50px}#update-modal.partial-update .update-list-footer{display:none}#update-modal.partial-update .modal-body{height:300px}#warning-modal{z-index:10}#warning-modal .header-title{border-bottom:2px solid grey;padding-bottom:10px;margin-bottom:0}#warning-modal .update-entry{list-style:none;line-height:22px;font-size:16px;margin-bottom:20px} \ No newline at end of file diff --git a/public/tabResize.js b/public/tabResize.js new file mode 100644 index 0000000..85e1ba3 --- /dev/null +++ b/public/tabResize.js @@ -0,0 +1,1122 @@ +var optOut = localStorage.getItem("tracking-opt-out"), + deferTracking = false; + +if(optOut && optOut === 'true'){ + deferTracking = true; +} + +function sendTracking(category, label) { + if(!deferTracking && ga) { + ga('send','event', category, 'clicked', label || "na"); + } +}; + +if(!deferTracking) { + // Standard Google Universal Analytics code + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); // Note: https protocol here + + ga('create', 'UA-34217520-2', 'auto'); + ga('set', 'checkProtocolTask', function(){}); // Removes failing protocol check. @see: http://stackoverflow.com/a/22152353/1958200 + ga('require', 'displayfeatures'); + ga('send', 'pageview', '/index.html'); +};/* +* resize.js +* parent resize object, global variable and object initialization +*/ +(function(){ + /* + * tab resize object + * @constructor + */ + var resize = { + + tabsArray: [], + currentTab: null, + numRows: 0, + numCols: 0, + width: 0, + height: 0, + canvasHeight: 100, + canvasWidth: 100, + currentLayouts: null, + defaultLayouts: {'layoutItems':["1x1","1x2","2x1","2x2"]}, + layoutSprites: {'layoutItems':["1x1","1x2","2x1","2x2","1x3","3x1"]}, + maxSelectorsPerLine: 5, + maxSelectorContainerWidth: 156, + maxSelectorContainerHeight: 156, + singleTab: false, + main_view: {}, + custom_view: {}, + options: {}, + util: {}, + badgeLimit: 7, + isMac: navigator.platform.toUpperCase().indexOf('MAC')!==-1 + }; + + window.resize = resize; + +})();;/** +* main_view.js +* handles main view - bulk of resize functionality +*/ +(function(){ + + var resize = window.resize; + + var main_view = { + + /** + * initializes resize popup + * populates the menu with list of layouts + */ + initialize: function() { + resize.currentLayouts = JSON.parse(localStorage.getItem('layoutItems')); + if(!resize.currentLayouts){ + localStorage.setItem('layoutItems',JSON.stringify(resize.defaultLayouts)); + resize.currentLayouts = $.extend(true,{},resize.defaultLayouts); + } + + this.populateMainView(); + + var singleTabValue = localStorage.getItem('singleTab'); + if(singleTabValue && singleTabValue === 'true'){ + $('#checkbox-single-tab').attr('checked',true); + $('label.single-tab').addClass('selected'); + $('body').addClass('single-tab-selected'); + resize.singleTab = true; + } + + //by default empty tab is checked to avoid any confusion + var emptyTabValue = localStorage.getItem('emptyTab'); + if(!emptyTabValue || emptyTabValue === 'true'){ + $('#checkbox-empty-tab').attr('checked',true); + $('label.empty-tab').addClass('selected'); + resize.emptyTab = true; + } else { + $('body').addClass('empty-tab-not-selected'); + } + + var displayLayerValue = localStorage.getItem('displayLayer'); + if(!displayLayerValue || displayLayerValue === 'true'){ + $('.main-view').addClass('display-selected'); + resize.displayLayer = true; + } + + var alignmentValue = localStorage.getItem('alignment'); + if(!alignmentValue){ + resize.alignment = 'left'; + } else { + resize.alignment = alignmentValue; + if(resize.alignment !== 'left'){ + $('body').addClass('align-right'); + } + } + $('#' + resize.alignment).trigger('click',['defer-tracking']); + + + resize.displayUtil.initialize(); + + if(localStorage.getItem('lastTab')){ + $('#undo-layout').removeClass('disabled'); + } + + window.backJs = chrome.extension.getBackgroundPage(); + + chrome.runtime.onMessage.addListener(function(message){ + if(message === 'enable-undo'){ + resize.options.enableUndoButton(); + } + }); + + var updateCount = Number(localStorage.getItem('updateBadge')); + + if(!updateCount){ + localStorage.setItem('updateBadge',0); + chrome.browserAction.setBadgeText({text:'NEW'}); + chrome.browserAction.setBadgeBackgroundColor({color:[221, 129, 39, 255]}); + } + + if(updateCount < resize.badgeLimit){ + localStorage.setItem('updateBadge',++updateCount); + if(updateCount === resize.badgeLimit){ + chrome.browserAction.setBadgeText({text:''}); + } + } + + var curVersion = localStorage.getItem('version') || '', + isOldVersion = (curVersion === '2.0'); + //user has never seen update + if(!localStorage.getItem('update-seen') || isOldVersion){ + var $body = $('body'); + $body.addClass('update'); + if(isOldVersion){ + localStorage.removeItem('update-seen'); + } else if (!localStorage.getItem('warning-seen')) { + $body.addClass('warning'); + resize.options.showWarningModal(); + } + resize.options.showUpdateModal(isOldVersion ? 'partial-update' : ''); + } + + if(localStorage.getItem('update-seen') && updateCount === resize.badgeLimit && !localStorage.getItem('promo-seen')){ + var $body = $('body'); + $body.addClass('promo'); + resize.options.showPromoModal(); + } + + $(function(){ + resize.util.initSortable(); + }); + }, + + /** + * populate main view with local storage data + */ + populateMainView: function() { + for(var x=0; x=5 && removedRow === 0){ + $('body').height($('body').height() - resize.maxSelectorContainerHeight); + $('html').height($('html').height() - resize.maxSelectorContainerHeight); + } + }, + + /** + * resizes tabs to the right of selected tab + * @param {number} rows number of rows in resize layout + * @param {number} cols number of columns in resize layout + */ + resizeTabs: function(rows,cols) { + + resize.numRows = rows; + resize.numCols = cols; + + /* + * split width of screen equally depending on number of cells + * create new window unable to take non integers for width and height + */ + + var data = $('.display-entry.selected').data(); + + if(!$.isEmptyObject(data)){ + resize.width = Math.round(data.width/resize.numCols); + resize.height = Math.round(data.height/resize.numRows); + resize.offsetX = data.left; + resize.offsetY = data.top; + resize.fullWidth = data.width; + resize.fullHeight = data.height; + } else { + resize.width = Math.round(window.screen.availWidth/resize.numCols); + resize.height = Math.round(window.screen.availHeight/resize.numRows); + resize.offsetX = 0; + resize.offsetY = 0; + resize.fullWidth = window.screen.availWidth; + resize.fullHeight = window.screen.availHeight; + } + + var that = this; + window.chrome.tabs.query({currentWindow: true}, + function (tabs) { + resize.tabsArray = tabs; + window.chrome.tabs.query({currentWindow: true, active: true}, + function (tab) { + resize.currentTab = tab[0]; + var cb = function(){ + return backJs.util.processTabs(resize, resize.tabsArray, resize.currentTab.index, resize.currentTab.windowId, resize.singleTab, resize.currentTab.incognito); + }; + if(resize.singleTab){ + backJs.util.setUndoStorage(resize,resize.currentTab.index,resize.currentTab.windowId, resize.tabsArray.slice(resize.currentTab.index,resize.currentTab.index + 1), cb); + } else { + backJs.util.setUndoStorage(resize, resize.currentTab.index,resize.currentTab.windowId, resize.tabsArray.slice(resize.currentTab.index), cb); + } + + } + ); + } + ); + } + }; + + window.resize.main_view = main_view; + +})();;/* +* custom_view.js +* handles custom view menu +*/ +(function(){ + + var resize = window.resize; + + var custom_view = { + + /** + * hides custom view menu + */ + hideCustomMenu: function() { + $('.custom-view').addClass('hidden'); + $('.main-view').removeClass('inactive'); + resize.util.clearCanvas(); + }, + + /** + * shows custom view menu + */ + showCustomMenu: function() { + this.clearCustomValues(); + $('.main-view').addClass('inactive'); + $('.custom-view').removeClass('hidden').trigger('show'); + $('.custom-view input.row').focus(); + }, + + /** + * clears custom row and col values from input fields + */ + clearCustomValues: function(){ + $('#numRows').val(''); + $('#numCols').val(''); + $('#input-save').addClass('disabled'); + }, + + /** + * performs save of new layout + */ + handleCustomSave: function(){ + var customRows = $('#numRows').val(), + customCols = $('#numCols').val(); + + this.clearCustomValues(); + + if(!Number(customRows) || !Number(customCols) || Number(customRows) < 1 || Number(customCols) < 1){ + //window.alert('Please enter valid input values.'); + } else { + var layoutType = customRows + 'x' + customCols; + resize.layout.addLayout(layoutType); + resize.layout.processTabInfo($('.layout-' + layoutType)); + this.hideCustomMenu(); + } + } + + }; + + window.resize.custom_view = custom_view; + +})();;/* +* options.js +* handles resize options (single tab, undo resize, default config) +*/ +(function(){ + + var resize = window.resize; + var options = { + + /* + * single tab option + */ + + /** + * sets singleTab flag + * @param {boolean} The hex ID. + */ + processSingleTabSelection: function(singleTab) { + var _singleTab = singleTab ? true : false; + localStorage.setItem('singleTab',_singleTab); + resize.singleTab = _singleTab; + $('label.single-tab').toggleClass('selected'); + $('body').toggleClass('single-tab-selected'); + }, + + /* + * empty tab option + */ + + /** + * sets emptyTab flag + * @param {boolean} The hex ID. + */ + processEmptyTabSelection: function(emptyTab) { + var _emptyTab = emptyTab ? true : false; + localStorage.setItem('emptyTab',_emptyTab); + resize.emptyTab = _emptyTab; + $('label.empty-tab').toggleClass('selected'); + $('body').toggleClass('empty-tab-not-selected'); + }, + + /** + * sets displayLayer flag + * @param {boolean} The hex ID. + */ + processDisplayLayerSelection: function(displayLayer) { + var _displayLayer = displayLayer ? true : false; + localStorage.setItem('displayLayer',_displayLayer); + resize.displayLayer = _displayLayer; + }, + + /** + * sets aligmment flag + * @param {String enum} left or right. + */ + processAlignmentSelection: function(alignment) { + localStorage.setItem('alignment',alignment); + resize.alignment = alignment; + if(alignment === 'right'){ + $('body').addClass('align-right'); + } else { + $('body').removeClass('align-right'); + } + }, + + /* + * undo previous resize option + */ + + /** + * undo the previous resize that was selected + */ + undoResize: function() { + var that = this; + resize.lastTab = JSON.parse(localStorage.getItem('lastTab')); + var tabIndex = resize.lastTab.lastTabIndex; + var windowId = resize.lastTab.lastWindowId; + var tabsArray = resize.lastTab.lastTabsArray; + + window.chrome.windows.get(windowId, {}, function(window){ + if(window){ + that.recombineTabs(tabIndex,windowId,tabsArray); + } else { + chrome.tabs.query({status: "complete"}, function(tabs){ + var currentExistingTabs = {}; + var newTabsArray = []; + for(var i=0; i< tabs.length; i++){ + currentExistingTabs[tabs[i].id] = true; + } + for(var j = 0; j< tabsArray.length; j++){ + if(currentExistingTabs[tabsArray[j]]){ + newTabsArray.push(tabsArray[j]); + } + } + if(newTabsArray.length !==0){ + chrome.windows.create({tabId: newTabsArray[0]},function(window){ + that.recombineTabs(1,window.id,newTabsArray.slice(1)); + }); + } else { + if(!resize.isMac){ + alert("Previous tabs were closed."); + } + that.disableUndoButton(); + } + }); + } + }); + }, + + /** + * recombine the tabs into one window + * @param {number} tabIndex Starting tab index in previous window of first tab + * @param {number} windowId Id of final window holding recombined tabs + * @param {array} tabsArray Array of tab objects to be moved back to the previous window + */ + recombineTabs: function(tabIndex, windowId, tabsArray) { + var indexCounter = tabIndex; + // for(var index=0; index
'; + + if(prepend){ + container.prepend(selectorTemplate); + } else { + container.append(selectorTemplate); + } + }, + + /** + * removes the layout from popup + * @param {string} layoutType Type of layout (ROWxCOL). + */ + removeLayout: function(layoutType){ + var layoutList = resize.currentLayouts.layoutItems, + layoutIndex = layoutList.indexOf(layoutType); + + layoutList.splice(layoutIndex,1); + localStorage.setItem('layoutItems',JSON.stringify(resize.currentLayouts)); + this._removeLayoutMarkup(layoutType); + }, + + /** + * removes the layout markup from popup + * @param {string} layoutType Type of layout (ROWxCOL). + */ + _removeLayoutMarkup: function(layoutType){ + var layoutSelector = '[data-selector-type="' + layoutType + '"]'; + $(layoutSelector).parent().remove(); + }, + + /** + * resets to default layouts + */ + resetLayout: function() { + this._removeAllLayouts(); + localStorage.setItem('layoutItems',JSON.stringify(resize.defaultLayouts)); + resize.currentLayouts = $.extend(true,{},resize.defaultLayouts); + resize.main_view.populateMainView(); + this.processTabInfo(); + resize.util.resetSortable(); + }, + + /** + * removes all current layouts + */ + _removeAllLayouts: function() { + $('.resize-container').children().remove(); + }, + + processTabInfo: function($layout){ + var tabs = resize.currentWindowTabs; + var layoutList = $layout || $('.resize-container').find('.resize-selector-container .resize-selector'), + length = 0, + index = 0, + $curLayout, + layoutType, + rows, + cols, + innerHtml, + curTab, + tabNumber; + + layoutList = layoutList.filter(function(){ + return !$(this).hasClass('layout-default'); + }); + + length = layoutList.length; + + if(tabs && tabs.length > 0){ + //iterate through the current list of layout options + for(;index
'; + } + } + $curLayout.html(innerHtml); + } + + //find the selected and add the urls + for(index=0;index currentDisplay.left){ + leastLeft = currentDisplay.left; + } + + if(mostLeft === null || mostLeft < currentDisplay.left + currentDisplay.width){ + mostLeft = currentDisplay.left + currentDisplay.width; + } + + if(leastTop === null || leastTop > currentDisplay.top){ + leastTop = currentDisplay.top; + } + + if(mostTop === null || mostTop < currentDisplay.top + currentDisplay.height){ + mostTop = currentDisplay.top + currentDisplay.height; + } + } + + totalWidth = mostLeft - leastLeft; + totalHeight = mostTop - leastTop; + + availableArea = getAvailableArea(); + + scaleX = availableArea.width/totalWidth; + scaleY = availableArea.height/totalHeight; + + scale = (scaleX < scaleY) ? scaleX : scaleY; + + offsetX = (leastLeft !== 0) ? (leastLeft)*-1*scale : 0; + offsetY = (leastTop !== 0) ? (leastTop)*-1*scale : 0; + + setDisplayHeight(scale,totalHeight); + } + + function getAvailableArea(){ + var $displayLayer = $('#display-setting-layer'); + return { + width: defaultWidth, + height: defaultHeight + } + } + + function setDisplayHeight(scale,height){ + var $displayLayer = $('#display-setting-layer'); + $displayLayer.height(scale*height); + } + + //format the displayInfo + function processInfo(displayInfo,currentWindowInfo){ + var index = 0, + length = displayInfo.length, + info, + displayJSON = { //may need to check for some mirroring property, currently only one monitor is display when mirroring + displays: [], + primaryIndex: 0 + }; + + for(;index info.workArea.left && currentWindowInfo.left < info.workArea.left + info.workArea.width && currentWindowInfo.top > info.workArea.top && currentWindowInfo.top < info.workArea.top + info.workArea.height){ + displayJSON.primaryIndex = index; + } + + } + return displayJSON; + } + + function renderDisplayTemplate(info, id, isPrimary){ + var $template = $('
'); + $template.css({ + top: info.top*scale + offsetY, + left: info.left*scale + offsetX, + width: info.width*scale, + height: info.height*scale + }).data($.extend({id:id},info)); + + $template.find('.display-meta').text(info.width + 'x' + info.height); + + if(isPrimary){ + $template.addClass('selected'); + } + + return $template; + } + +})(window.jQuery);;/** +* main.js +* initialization and event handlers +*/ +(function(){ + + var resize = window.resize, + main_view = resize.main_view, + custom_view = resize.custom_view, + util = resize.util, + layout = resize.layout, + options = resize.options, + displayUtil = resize.displayUtil, + $doc = $(document); + + /* + * events handlers + */ + + $doc.ready(function(){ + main_view.initialize(); + }).on('click','.resize-selector-container',function(){ + var resizeSelector = $(this).children('.resize-selector'), + resizeTypeStr = resizeSelector.attr('data-selector-type'), + resizeType = resizeTypeStr.split('x'); + + main_view.resizeTabs(Number(resizeType[0]),Number(resizeType[1])); + sendTracking('resize',resizeTypeStr); + }).on('show','.modal-box', function(evt){ + evt.stopPropagation(); + util.centerModal($(this)); + }).on('click','.modal-box', function(evt){ + evt.stopPropagation(); + }).on('click','.close-button',function(evt){ + evt.stopPropagation(); + var resizeType = $(this).siblings('.resize-selector').attr('data-selector-type'); + layout.removeLayout(resizeType); + sendTracking('resize-delete',resizeType); + }).on('click','#undo-layout',function(){ + options.undoResize(); + sendTracking('undo','undo'); + }).on('click','#custom-layout',function(evt){ + evt.stopPropagation(); + custom_view.showCustomMenu(); + sendTracking('custom-layout','open'); + }).on('click','#default-configuration',function(evt){ + evt.stopPropagation(); + options.showConfirmationModal(); + sendTracking('default-layout','open'); + }).on('click','#confirmation-cancel',function(){ + options.hideConfirmationModal(); + sendTracking('default-layout','cancel'); + }).on('click','#confirmation-apply',function(){ + layout.resetLayout(); + options.hideConfirmationModal(); + sendTracking('default-layout','apply'); + }).on('click','#input-cancel,.main-view',function(){ + if(!$('.custom-view').hasClass('hidden')){ + custom_view.clearCustomValues(); + custom_view.hideCustomMenu(); + sendTracking('custom-layout','cancel'); + } + }).on('click','#input-save',function(){ + custom_view.handleCustomSave(); + sendTracking('custom-layout','apply'); + }).on('click','body',function(){ + if(!$('.custom-view').hasClass('hidden')){ + util.clearCanvas(); + custom_view.hideCustomMenu(); + sendTracking('custom-layout','cancel-layer'); + } + if(!$('.confirmation-modal').hasClass('hidden')){ + options.hideConfirmationModal(); + sendTracking('default-layout','cancel-layer'); + } + }).on('keyup','#numRows, #numCols',function(evt){ + evt.stopPropagation(); + + var canvas=document.getElementById("myCanvas"); + var context=canvas.getContext("2d"); + + var numRows = Number($('#numRows').attr('value')); + var numCols = Number($('#numCols').attr('value')); + + util.clearCanvas(); + + if(numRows && numRows > 0 && numCols && numCols > 0){ + + if(numRows > resize.canvasHeight/4){ + numRows = resize.canvasHeight/4; + } + + if(numCols > resize.canvasWidth/4){ + numCols = resize.canvasWidth/4; + } + + util.drawTable(resize.canvasWidth, resize.canvasHeight, numRows, numCols, context); + $('#input-save').removeClass('disabled'); + } else { + var $this = $(this), + val = Number($this.attr('value')); + + if(val === 0 || isNaN(val)){ + $this.attr('value',''); + $('#input-save').addClass('disabled'); + } + } + }).on('change','#checkbox-single-tab', function(){ + var checked = $(this).attr('checked'); + options.processSingleTabSelection(checked); + sendTracking('single-tab',checked ? "checked" : "unchecked"); + }).on('change','#checkbox-empty-tab', function(){ + var checked = $(this).attr('checked'); + options.processEmptyTabSelection(checked); + sendTracking('empty-tab',checked ? "checked" : "unchecked"); + }).on('click','#display-setting', function(){ + var $display = $('.main-view'), + isDisplayed; + + $display.toggleClass('display-selected'); + isDisplayed = $display.hasClass('display-selected'); + options.processDisplayLayerSelection(isDisplayed); + sendTracking('display-settings',isDisplayed ? "opened" : "closed"); + }).on('click','#display-setting-layer .switch-toggle input',function(evt,deferTracking){ + var alignment = $(this).attr('id'); + $('.switch-toggle').removeClass('right-align left-align').addClass(alignment + '-align'); + options.processAlignmentSelection(alignment); + if(!deferTracking){ + sendTracking('alignment',alignment); + } + }).on('click','#update-apply',function(){ + options.hideUpdateModal(); + }).on('click','#promo-apply',function(){ + options.hidePromoModal(); + }).on('click','#warning-apply',function(){ + options.hideWarningModal(); + }).on('click','.signature a',function(){ + if($(this).hasClass('rate-it')){ + sendTracking('info-links','rate-it'); + } else { + sendTracking('info-links','author'); + } + }); + +})(); \ No newline at end of file diff --git a/public/tabResize.min.js b/public/tabResize.min.js new file mode 100644 index 0000000..22e5d11 --- /dev/null +++ b/public/tabResize.min.js @@ -0,0 +1 @@ +function sendTracking(a,b){!deferTracking&&ga&&ga("send","event",a,"clicked",b||"na")}var optOut=localStorage.getItem("tracking-opt-out"),deferTracking=!1;optOut&&"true"===optOut&&(deferTracking=!0),deferTracking||(!function(a,b,c,d,e,f,g){a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","https://www.google-analytics.com/analytics.js","ga"),ga("create","UA-34217520-2","auto"),ga("set","checkProtocolTask",function(){}),ga("require","displayfeatures"),ga("send","pageview","/index.html")),function(){var a={tabsArray:[],currentTab:null,numRows:0,numCols:0,width:0,height:0,canvasHeight:100,canvasWidth:100,currentLayouts:null,defaultLayouts:{layoutItems:["1x1","1x2","2x1","2x2"]},layoutSprites:{layoutItems:["1x1","1x2","2x1","2x2","1x3","3x1"]},maxSelectorsPerLine:5,maxSelectorContainerWidth:156,maxSelectorContainerHeight:156,singleTab:!1,main_view:{},custom_view:{},options:{},util:{},badgeLimit:7,isMac:-1!==navigator.platform.toUpperCase().indexOf("MAC")};window.resize=a}(),function(){var a=window.resize,b={initialize:function(){a.currentLayouts=JSON.parse(localStorage.getItem("layoutItems")),a.currentLayouts||(localStorage.setItem("layoutItems",JSON.stringify(a.defaultLayouts)),a.currentLayouts=$.extend(!0,{},a.defaultLayouts)),this.populateMainView();var b=localStorage.getItem("singleTab");b&&"true"===b&&($("#checkbox-single-tab").attr("checked",!0),$("label.single-tab").addClass("selected"),$("body").addClass("single-tab-selected"),a.singleTab=!0);var c=localStorage.getItem("emptyTab");c&&"true"!==c?$("body").addClass("empty-tab-not-selected"):($("#checkbox-empty-tab").attr("checked",!0),$("label.empty-tab").addClass("selected"),a.emptyTab=!0);var d=localStorage.getItem("displayLayer");d&&"true"!==d||($(".main-view").addClass("display-selected"),a.displayLayer=!0);var e=localStorage.getItem("alignment");e?(a.alignment=e,"left"!==a.alignment&&$("body").addClass("align-right")):a.alignment="left",$("#"+a.alignment).trigger("click",["defer-tracking"]),a.displayUtil.initialize(),localStorage.getItem("lastTab")&&$("#undo-layout").removeClass("disabled"),window.backJs=chrome.extension.getBackgroundPage(),chrome.runtime.onMessage.addListener(function(b){"enable-undo"===b&&a.options.enableUndoButton()});var f=Number(localStorage.getItem("updateBadge"));f||(localStorage.setItem("updateBadge",0),chrome.browserAction.setBadgeText({text:"NEW"}),chrome.browserAction.setBadgeBackgroundColor({color:[221,129,39,255]})),f=5&&0===c&&($("body").height($("body").height()-a.maxSelectorContainerHeight),$("html").height($("html").height()-a.maxSelectorContainerHeight))},resizeTabs:function(b,c){a.numRows=b,a.numCols=c;var d=$(".display-entry.selected").data();$.isEmptyObject(d)?(a.width=Math.round(window.screen.availWidth/a.numCols),a.height=Math.round(window.screen.availHeight/a.numRows),a.offsetX=0,a.offsetY=0,a.fullWidth=window.screen.availWidth,a.fullHeight=window.screen.availHeight):(a.width=Math.round(d.width/a.numCols),a.height=Math.round(d.height/a.numRows),a.offsetX=d.left,a.offsetY=d.top,a.fullWidth=d.width,a.fullHeight=d.height);window.chrome.tabs.query({currentWindow:!0},function(b){a.tabsArray=b,window.chrome.tabs.query({currentWindow:!0,active:!0},function(b){a.currentTab=b[0];var c=function(){return backJs.util.processTabs(a,a.tabsArray,a.currentTab.index,a.currentTab.windowId,a.singleTab,a.currentTab.incognito)};a.singleTab?backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(a.currentTab.index,a.currentTab.index+1),c):backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(a.currentTab.index),c)})})}};window.resize.main_view=b}(),function(){var a=window.resize,b={hideCustomMenu:function(){$(".custom-view").addClass("hidden"),$(".main-view").removeClass("inactive"),a.util.clearCanvas()},showCustomMenu:function(){this.clearCustomValues(),$(".main-view").addClass("inactive"),$(".custom-view").removeClass("hidden").trigger("show"),$(".custom-view input.row").focus()},clearCustomValues:function(){$("#numRows").val(""),$("#numCols").val(""),$("#input-save").addClass("disabled")},handleCustomSave:function(){var b=$("#numRows").val(),c=$("#numCols").val();if(this.clearCustomValues(),!Number(b)||!Number(c)||Number(b)<1||Number(c)<1);else{var d=b+"x"+c;a.layout.addLayout(d),a.layout.processTabInfo($(".layout-"+d)),this.hideCustomMenu()}}};window.resize.custom_view=b}(),function(){var a=window.resize,b={processSingleTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("singleTab",c),a.singleTab=c,$("label.single-tab").toggleClass("selected"),$("body").toggleClass("single-tab-selected")},processEmptyTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("emptyTab",c),a.emptyTab=c,$("label.empty-tab").toggleClass("selected"),$("body").toggleClass("empty-tab-not-selected")},processDisplayLayerSelection:function(b){var c=b?!0:!1;localStorage.setItem("displayLayer",c),a.displayLayer=c},processAlignmentSelection:function(b){localStorage.setItem("alignment",b),a.alignment=b,"right"===b?$("body").addClass("align-right"):$("body").removeClass("align-right")},undoResize:function(){var b=this;a.lastTab=JSON.parse(localStorage.getItem("lastTab"));var c=a.lastTab.lastTabIndex,d=a.lastTab.lastWindowId,e=a.lastTab.lastTabsArray;window.chrome.windows.get(d,{},function(f){f?b.recombineTabs(c,d,e):chrome.tabs.query({status:"complete"},function(c){for(var d={},f=[],g=0;gd;b++,d++){a=c[b];var e=$(".resize-container").find(".tab-layer-"+d);e.addClass("valid-tab");for(var f=0;fd;d++)e.push(a.eq(d).attr("data-selector-type"));b.currentLayouts.layoutItems=e,localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts))},addLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);-1!==d&&(c.splice(d,1),this._removeLayoutMarkup(a)),b.currentLayouts.layoutItems.unshift(a),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this.addLayoutMarkup(a,!0),b.util.resetSortable()},addLayoutMarkup:function(a,c){var d="layout-default";(-1!==b.layoutSprites.layoutItems.indexOf(a)||"1x1"===a)&&(d="layout-"+a);var e=$(".resize-container"),f='
  • '+a+'
  • ';c?e.prepend(f):e.append(f)},removeLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);c.splice(d,1),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this._removeLayoutMarkup(a)},_removeLayoutMarkup:function(a){var b='[data-selector-type="'+a+'"]';$(b).parent().remove()},resetLayout:function(){this._removeAllLayouts(),localStorage.setItem("layoutItems",JSON.stringify(b.defaultLayouts)),b.currentLayouts=$.extend(!0,{},b.defaultLayouts),b.main_view.populateMainView(),this.processTabInfo(),b.util.resetSortable()},_removeAllLayouts:function(){$(".resize-container").children().remove()},processTabInfo:function(c){var d,e,f,g,h,i,j,k=b.currentWindowTabs,l=c||$(".resize-container").find(".resize-selector-container .resize-selector"),m=0,n=0;if(l=l.filter(function(){return!$(this).hasClass("layout-default")}),m=l.length,k&&k.length>0){for(;m>n;n++){h="",d=l.eq(n),e=d.attr("data-selector-type").split("x"),f=e[0],g=e[1],j=1;for(var o=0;f>o;o++)for(var p=0;g>p;p++)h+='
    ';d.html(h)}for(n=0;nh;h++)e.moveTo(0,g*h),e.lineTo(b,g*h);for(var i=1;d>i;i++)e.moveTo(f*i,0),e.lineTo(f*i,a);e.closePath(),e.stroke()},clearCanvas:function(){var a=$("canvas")[0],b=a.getContext("2d");b.clearRect(0,0,b.canvas.width,b.canvas.height)},initSortable:function(){$(".sortable").sortable().on("sortupdate",function(){resize.layout.updateLayoutStore(),sendTracking("dnd-event","dnd-label")}),b=!0},resetSortable:function(){if(b){var a=$(".sortable");a.sortable("destroy"),a.sortable()}}},b=!1;window.resize.util=a}(),function(a){function b(a){for(var b,e,f,g,h,l=a.displays,m=null,n=null,o=null,p=null,q=0,r=l.length;r>q;q++)h=l[q].workArea,(null===m||m>h.left)&&(m=h.left),(null===n||nh.top)&&(o=h.top),(null===p||pf?f:g,j=0!==m?-1*m*i:0,k=0!==o?-1*o*i:0,d(i,e)}function c(){a("#display-setting-layer");return{width:l,height:m}}function d(b,c){var d=a("#display-setting-layer");d.height(b*c)}function e(a,b){for(var c,d=0,e=a.length,f={displays:[],primaryIndex:0};e>d;d++)c=a[d],c.id=String(d),f.displays.push({workArea:c.workArea,isEnabled:c.isEnabled,id:c.id}),b.left>c.workArea.left&&b.leftc.workArea.top&&b.top
    ');return e.css({top:b.top*i+k,left:b.left*i+j,width:b.width*i,height:b.height*i}).data(a.extend({id:c},b)),e.find(".display-meta").text(b.width+"x"+b.height),d&&e.addClass("selected"),e}var g,h=window.resize,i=.15,j=0,k=0,l=530,m=250,n={initialize:function(){chrome.system&&chrome.system.display&&(h.display=chrome.system.display,g=a("#display-setting-layer"),g.on("click",".display-entry",function(){var b=a(this),c={},d=b.data("id"),e=b.find(".display-meta").text();c[d]=!0,g.find(".display-entry").removeClass("selected"),b.addClass("selected"),sendTracking("display-select",e)}),h.display.getInfo(function(a){chrome.windows.getCurrent({populate:!0},function(c){var d,i,j={left:c.left+c.width-100,top:c.top+100},k=e(a,j);b(k);for(var l=0;l0&&g&&g>0)f>a.canvasHeight/4&&(f=a.canvasHeight/4),g>a.canvasWidth/4&&(g=a.canvasWidth/4),d.drawTable(a.canvasWidth,a.canvasHeight,f,g,e),$("#input-save").removeClass("disabled");else{var h=$(this),i=Number(h.attr("value"));(0===i||isNaN(i))&&(h.attr("value",""),$("#input-save").addClass("disabled"))}}).on("change","#checkbox-single-tab",function(){var a=$(this).attr("checked");f.processSingleTabSelection(a),sendTracking("single-tab",a?"checked":"unchecked")}).on("change","#checkbox-empty-tab",function(){var a=$(this).attr("checked");f.processEmptyTabSelection(a),sendTracking("empty-tab",a?"checked":"unchecked")}).on("click","#display-setting",function(){var a,b=$(".main-view");b.toggleClass("display-selected"),a=b.hasClass("display-selected"),f.processDisplayLayerSelection(a),sendTracking("display-settings",a?"opened":"closed")}).on("click","#display-setting-layer .switch-toggle input",function(a,b){var c=$(this).attr("id");$(".switch-toggle").removeClass("right-align left-align").addClass(c+"-align"),f.processAlignmentSelection(c),b||sendTracking("alignment",c)}).on("click","#update-apply",function(){f.hideUpdateModal()}).on("click","#promo-apply",function(){f.hidePromoModal()}).on("click","#warning-apply",function(){f.hideWarningModal()}).on("click",".signature a",function(){$(this).hasClass("rate-it")?sendTracking("info-links","rate-it"):sendTracking("info-links","author")})}(); \ No newline at end of file diff --git a/public/tabResize_background.js b/public/tabResize_background.js new file mode 100644 index 0000000..a7518c4 --- /dev/null +++ b/public/tabResize_background.js @@ -0,0 +1,181 @@ +//background.js - background process for tab resize + +if(!localStorage.getItem('updateBadge')){ + localStorage.setItem('updateBadge',0); + chrome.browserAction.setBadgeText({text:'NEW'}); + chrome.browserAction.setBadgeBackgroundColor({color:[221, 129, 39, 255]}); +} + +if(!localStorage.getItem('version')){ + localStorage.setItem('version','2.1'); +} + +var util = { + + /** + * creates a new window at specific location with the tab input + * @param {Number} tabId - id of main tab in new window + * @param {Number} startX - horizontal position of window + * @param {Number} startY - vertical position of window + * @param {Number} width - width of window + * @param {Number} height - height of window + * @param {boolean} incog - if window is of type incognito + * @param {function} callback - callback function after window is created + */ + createNewWindow: function(tabId, startX, startY, width, height, incog, callback) { + var objectInfo = { + left: startX, + top: startY, + width: width, + height: height, + incognito: incog + }; + + if(tabId){ + if($.isArray(tabId)){ + objectInfo.tabId = tabId[0]; + } else { + objectInfo.tabId = tabId; + } + } + + window.chrome.windows.create(objectInfo, + function(_windowCb){ + callback(_windowCb, tabId); + } + ); + }, + + /** + * iterates through tab array to create layout + * @param {array} tabsArray array of tab objects to be moved + * @param {number} startIndex index of selected tab in window + * @param {number} windowId index of window + * @param {boolean} singleTab flag of single tab option + * @param {boolean} incog - if window is of type incognito + */ + processTabs: function(resize, tabsArray, startIndex, windowId, singleTab, incog) { + var tabId, + _tabsArray = tabsArray.slice(startIndex), + index = 0, + numEmptyWindows = 0, + tabsLength = _tabsArray.length, + emptyWindowLimit = (resize.numRows * resize.numCols) - tabsLength, + that = this, + leftValue, + rightValue, + createNewWindowCB = function(_windowCb,_tabId){ + //only if update storage when tab option is used + if(!_tabId && resize.emptyTab){ + _tabsArray.push(_windowCb.tabs[0]); + numEmptyWindows++; + if(emptyWindowLimit === numEmptyWindows){ + that.updateUndoStorage(resize, _tabsArray); + } + } else if(_tabId && $.isArray(_tabId)){ //moving tabs to last window + chrome.tabs.move(_tabId.slice(1),{ + windowId: _windowCb.id, + index: 1 + }); + } + }; + + //loop through all row and col options + for(var y=0; y 1){ + tabId = []; + for(var z = index; z < tabsLength; z++){ + tabId.push(_tabsArray[z].id); + } + } + + //check the number of new windows that will be created + //store the windowId information + that.createNewWindow(tabId, leftValue, rightValue, resize.width, resize.height, incog, createNewWindowCB); + } + index++; + } + } + }, + + /** + * set storage of last window and tabs being moved + * @param {object} resize object from foreground + * @param {number} tabIndex Starting tab index in previous window of first tab + * @param {number} windowId Id of the previous window object which was modified + * @param {array} tabsArray Array of tab objects to be moved back to the previous window + */ + setUndoStorage: function(resize, tabIndex, windowId, tabsArray, cb) { + window.chrome.windows.get(windowId,{},function(_windowCb){ + var updateInfo = { left: _windowCb.left, + top: _windowCb.top, + width: _windowCb.width, + height: _windowCb.height, + focused: true, + state: "normal", + incognito: _windowCb.incognito + }; + var lastTab = {}; + lastTab.lastWindowInfo = updateInfo; + lastTab.lastTabIndex = tabIndex; + lastTab.lastWindowId = windowId; + var tabsStore = []; + for(var x=0; x1){g=[];for(var s=k;m>s;s++)g.push(j[s].id)}o.createNewWindow(g,h,i,a.width,a.height,f,p)}k++}},setUndoStorage:function(a,b,c,d,e){window.chrome.windows.get(c,{},function(a){var f={left:a.left,top:a.top,width:a.width,height:a.height,focused:!0,state:"normal",incognito:a.incognito},g={};g.lastWindowInfo=f,g.lastTabIndex=b,g.lastWindowId=c;for(var h=[],i=0;i Date: Sat, 6 Sep 2014 15:25:59 -0700 Subject: [PATCH 2/6] Adding in jshint automation. --- .gitignore | 1 + Gruntfile.js | 25 ++++++++++++++++++++----- js/display.js | 2 +- js/main_view.js | 5 +++-- js/tracking.js | 5 +++-- package.json | 3 ++- public/tabResize.js | 36 +++++++++++++++++++++++------------- public/tabResize.min.js | 2 +- 8 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 43a3c38..5091df0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,9 +2,6 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { - options: { - separator: ';', - }, basic: { src: [ 'js/tracking.js', @@ -26,6 +23,24 @@ module.exports = function(grunt) { dest: 'public/<%= pkg.name %>_background.js' } }, + jshint: { + beforeconcat: [ + 'js/tracking.js', + 'js/resize.js', + 'js/main_view.js', + 'js/custom_view.js', + 'js/options.js', + 'js/layout.js', + 'js/utility.js', + 'js/display.js', + 'js/main.js', + 'js/background.js' + ], + afterconcat: [ + 'public/<%= pkg.name %>.js', + 'public/<%= pkg.name %>_background.js' + ] + }, uglify: { my_target: { files: { @@ -46,7 +61,7 @@ module.exports = function(grunt) { } }); - ['grunt-contrib-concat', 'grunt-contrib-uglify', 'grunt-contrib-less'].forEach(grunt.loadNpmTasks); + ['grunt-contrib-concat', 'grunt-contrib-jshint', 'grunt-contrib-uglify', 'grunt-contrib-less'].forEach(grunt.loadNpmTasks); - grunt.registerTask('default', ['concat','uglify','less']); + grunt.registerTask('default', ['concat', 'jshint', 'uglify', 'less']); }; \ No newline at end of file diff --git a/js/display.js b/js/display.js index 9982796..40aff13 100644 --- a/js/display.js +++ b/js/display.js @@ -122,7 +122,7 @@ return { width: defaultWidth, height: defaultHeight - } + }; } function setDisplayHeight(scale,height){ diff --git a/js/main_view.js b/js/main_view.js index b5305d4..04e2772 100644 --- a/js/main_view.js +++ b/js/main_view.js @@ -88,9 +88,11 @@ var curVersion = localStorage.getItem('version') || '', isOldVersion = (curVersion === '2.0'); + + var $body = $('body'); + //user has never seen update if(!localStorage.getItem('update-seen') || isOldVersion){ - var $body = $('body'); $body.addClass('update'); if(isOldVersion){ localStorage.removeItem('update-seen'); @@ -102,7 +104,6 @@ } if(localStorage.getItem('update-seen') && updateCount === resize.badgeLimit && !localStorage.getItem('promo-seen')){ - var $body = $('body'); $body.addClass('promo'); resize.options.showPromoModal(); } diff --git a/js/tracking.js b/js/tracking.js index af82ba2..850feeb 100644 --- a/js/tracking.js +++ b/js/tracking.js @@ -9,15 +9,16 @@ function sendTracking(category, label) { if(!deferTracking && ga) { ga('send','event', category, 'clicked', label || "na"); } -}; +} if(!deferTracking) { // Standard Google Universal Analytics code + /* jshint ignore:start */ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); // Note: https protocol here - + /* jshint ignore:end */ ga('create', 'UA-34217520-2', 'auto'); ga('set', 'checkProtocolTask', function(){}); // Removes failing protocol check. @see: http://stackoverflow.com/a/22152353/1958200 ga('require', 'displayfeatures'); diff --git a/package.json b/package.json index 1b964d1..b681ba7 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "grunt": "~0.4.5", "grunt-contrib-concat": "~0.5.0", "grunt-contrib-uglify": "~0.5.1", - "grunt-contrib-less":"~0.11.4" + "grunt-contrib-less":"~0.11.4", + "grunt-contrib-jshint":"~0.10.0" } } \ No newline at end of file diff --git a/public/tabResize.js b/public/tabResize.js index 85e1ba3..299b3df 100644 --- a/public/tabResize.js +++ b/public/tabResize.js @@ -9,20 +9,22 @@ function sendTracking(category, label) { if(!deferTracking && ga) { ga('send','event', category, 'clicked', label || "na"); } -}; +} if(!deferTracking) { // Standard Google Universal Analytics code + /* jshint ignore:start */ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); // Note: https protocol here - + /* jshint ignore:end */ ga('create', 'UA-34217520-2', 'auto'); ga('set', 'checkProtocolTask', function(){}); // Removes failing protocol check. @see: http://stackoverflow.com/a/22152353/1958200 ga('require', 'displayfeatures'); ga('send', 'pageview', '/index.html'); -};/* +} +/* * resize.js * parent resize object, global variable and object initialization */ @@ -58,7 +60,8 @@ if(!deferTracking) { window.resize = resize; -})();;/** +})(); +/** * main_view.js * handles main view - bulk of resize functionality */ @@ -148,9 +151,11 @@ if(!deferTracking) { var curVersion = localStorage.getItem('version') || '', isOldVersion = (curVersion === '2.0'); + + var $body = $('body'); + //user has never seen update if(!localStorage.getItem('update-seen') || isOldVersion){ - var $body = $('body'); $body.addClass('update'); if(isOldVersion){ localStorage.removeItem('update-seen'); @@ -162,7 +167,6 @@ if(!deferTracking) { } if(localStorage.getItem('update-seen') && updateCount === resize.badgeLimit && !localStorage.getItem('promo-seen')){ - var $body = $('body'); $body.addClass('promo'); resize.options.showPromoModal(); } @@ -264,7 +268,8 @@ if(!deferTracking) { window.resize.main_view = main_view; -})();;/* +})(); +/* * custom_view.js * handles custom view menu */ @@ -325,7 +330,8 @@ if(!deferTracking) { window.resize.custom_view = custom_view; -})();;/* +})(); +/* * options.js * handles resize options (single tab, undo resize, default config) */ @@ -546,7 +552,8 @@ if(!deferTracking) { window.resize.options = options; -})();;/* +})(); +/* * layout.js * adds/removes layout from popup */ @@ -718,7 +725,8 @@ if(!deferTracking) { window.resize.layout = layout; -})();;/** +})(); +/** * utility.js * general utility functions used for modal, canvas, etc. */ @@ -798,7 +806,8 @@ if(!deferTracking) { window.resize.util = util; -})();;/* +})(); +/* * display.js * handling display event handling and logic */ @@ -922,7 +931,7 @@ if(!deferTracking) { return { width: defaultWidth, height: defaultHeight - } + }; } function setDisplayHeight(scale,height){ @@ -975,7 +984,8 @@ if(!deferTracking) { return $template; } -})(window.jQuery);;/** +})(window.jQuery); +/** * main.js * initialization and event handlers */ diff --git a/public/tabResize.min.js b/public/tabResize.min.js index 22e5d11..5c49c91 100644 --- a/public/tabResize.min.js +++ b/public/tabResize.min.js @@ -1 +1 @@ -function sendTracking(a,b){!deferTracking&&ga&&ga("send","event",a,"clicked",b||"na")}var optOut=localStorage.getItem("tracking-opt-out"),deferTracking=!1;optOut&&"true"===optOut&&(deferTracking=!0),deferTracking||(!function(a,b,c,d,e,f,g){a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","https://www.google-analytics.com/analytics.js","ga"),ga("create","UA-34217520-2","auto"),ga("set","checkProtocolTask",function(){}),ga("require","displayfeatures"),ga("send","pageview","/index.html")),function(){var a={tabsArray:[],currentTab:null,numRows:0,numCols:0,width:0,height:0,canvasHeight:100,canvasWidth:100,currentLayouts:null,defaultLayouts:{layoutItems:["1x1","1x2","2x1","2x2"]},layoutSprites:{layoutItems:["1x1","1x2","2x1","2x2","1x3","3x1"]},maxSelectorsPerLine:5,maxSelectorContainerWidth:156,maxSelectorContainerHeight:156,singleTab:!1,main_view:{},custom_view:{},options:{},util:{},badgeLimit:7,isMac:-1!==navigator.platform.toUpperCase().indexOf("MAC")};window.resize=a}(),function(){var a=window.resize,b={initialize:function(){a.currentLayouts=JSON.parse(localStorage.getItem("layoutItems")),a.currentLayouts||(localStorage.setItem("layoutItems",JSON.stringify(a.defaultLayouts)),a.currentLayouts=$.extend(!0,{},a.defaultLayouts)),this.populateMainView();var b=localStorage.getItem("singleTab");b&&"true"===b&&($("#checkbox-single-tab").attr("checked",!0),$("label.single-tab").addClass("selected"),$("body").addClass("single-tab-selected"),a.singleTab=!0);var c=localStorage.getItem("emptyTab");c&&"true"!==c?$("body").addClass("empty-tab-not-selected"):($("#checkbox-empty-tab").attr("checked",!0),$("label.empty-tab").addClass("selected"),a.emptyTab=!0);var d=localStorage.getItem("displayLayer");d&&"true"!==d||($(".main-view").addClass("display-selected"),a.displayLayer=!0);var e=localStorage.getItem("alignment");e?(a.alignment=e,"left"!==a.alignment&&$("body").addClass("align-right")):a.alignment="left",$("#"+a.alignment).trigger("click",["defer-tracking"]),a.displayUtil.initialize(),localStorage.getItem("lastTab")&&$("#undo-layout").removeClass("disabled"),window.backJs=chrome.extension.getBackgroundPage(),chrome.runtime.onMessage.addListener(function(b){"enable-undo"===b&&a.options.enableUndoButton()});var f=Number(localStorage.getItem("updateBadge"));f||(localStorage.setItem("updateBadge",0),chrome.browserAction.setBadgeText({text:"NEW"}),chrome.browserAction.setBadgeBackgroundColor({color:[221,129,39,255]})),f=5&&0===c&&($("body").height($("body").height()-a.maxSelectorContainerHeight),$("html").height($("html").height()-a.maxSelectorContainerHeight))},resizeTabs:function(b,c){a.numRows=b,a.numCols=c;var d=$(".display-entry.selected").data();$.isEmptyObject(d)?(a.width=Math.round(window.screen.availWidth/a.numCols),a.height=Math.round(window.screen.availHeight/a.numRows),a.offsetX=0,a.offsetY=0,a.fullWidth=window.screen.availWidth,a.fullHeight=window.screen.availHeight):(a.width=Math.round(d.width/a.numCols),a.height=Math.round(d.height/a.numRows),a.offsetX=d.left,a.offsetY=d.top,a.fullWidth=d.width,a.fullHeight=d.height);window.chrome.tabs.query({currentWindow:!0},function(b){a.tabsArray=b,window.chrome.tabs.query({currentWindow:!0,active:!0},function(b){a.currentTab=b[0];var c=function(){return backJs.util.processTabs(a,a.tabsArray,a.currentTab.index,a.currentTab.windowId,a.singleTab,a.currentTab.incognito)};a.singleTab?backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(a.currentTab.index,a.currentTab.index+1),c):backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(a.currentTab.index),c)})})}};window.resize.main_view=b}(),function(){var a=window.resize,b={hideCustomMenu:function(){$(".custom-view").addClass("hidden"),$(".main-view").removeClass("inactive"),a.util.clearCanvas()},showCustomMenu:function(){this.clearCustomValues(),$(".main-view").addClass("inactive"),$(".custom-view").removeClass("hidden").trigger("show"),$(".custom-view input.row").focus()},clearCustomValues:function(){$("#numRows").val(""),$("#numCols").val(""),$("#input-save").addClass("disabled")},handleCustomSave:function(){var b=$("#numRows").val(),c=$("#numCols").val();if(this.clearCustomValues(),!Number(b)||!Number(c)||Number(b)<1||Number(c)<1);else{var d=b+"x"+c;a.layout.addLayout(d),a.layout.processTabInfo($(".layout-"+d)),this.hideCustomMenu()}}};window.resize.custom_view=b}(),function(){var a=window.resize,b={processSingleTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("singleTab",c),a.singleTab=c,$("label.single-tab").toggleClass("selected"),$("body").toggleClass("single-tab-selected")},processEmptyTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("emptyTab",c),a.emptyTab=c,$("label.empty-tab").toggleClass("selected"),$("body").toggleClass("empty-tab-not-selected")},processDisplayLayerSelection:function(b){var c=b?!0:!1;localStorage.setItem("displayLayer",c),a.displayLayer=c},processAlignmentSelection:function(b){localStorage.setItem("alignment",b),a.alignment=b,"right"===b?$("body").addClass("align-right"):$("body").removeClass("align-right")},undoResize:function(){var b=this;a.lastTab=JSON.parse(localStorage.getItem("lastTab"));var c=a.lastTab.lastTabIndex,d=a.lastTab.lastWindowId,e=a.lastTab.lastTabsArray;window.chrome.windows.get(d,{},function(f){f?b.recombineTabs(c,d,e):chrome.tabs.query({status:"complete"},function(c){for(var d={},f=[],g=0;gd;b++,d++){a=c[b];var e=$(".resize-container").find(".tab-layer-"+d);e.addClass("valid-tab");for(var f=0;fd;d++)e.push(a.eq(d).attr("data-selector-type"));b.currentLayouts.layoutItems=e,localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts))},addLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);-1!==d&&(c.splice(d,1),this._removeLayoutMarkup(a)),b.currentLayouts.layoutItems.unshift(a),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this.addLayoutMarkup(a,!0),b.util.resetSortable()},addLayoutMarkup:function(a,c){var d="layout-default";(-1!==b.layoutSprites.layoutItems.indexOf(a)||"1x1"===a)&&(d="layout-"+a);var e=$(".resize-container"),f='
  • '+a+'
  • ';c?e.prepend(f):e.append(f)},removeLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);c.splice(d,1),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this._removeLayoutMarkup(a)},_removeLayoutMarkup:function(a){var b='[data-selector-type="'+a+'"]';$(b).parent().remove()},resetLayout:function(){this._removeAllLayouts(),localStorage.setItem("layoutItems",JSON.stringify(b.defaultLayouts)),b.currentLayouts=$.extend(!0,{},b.defaultLayouts),b.main_view.populateMainView(),this.processTabInfo(),b.util.resetSortable()},_removeAllLayouts:function(){$(".resize-container").children().remove()},processTabInfo:function(c){var d,e,f,g,h,i,j,k=b.currentWindowTabs,l=c||$(".resize-container").find(".resize-selector-container .resize-selector"),m=0,n=0;if(l=l.filter(function(){return!$(this).hasClass("layout-default")}),m=l.length,k&&k.length>0){for(;m>n;n++){h="",d=l.eq(n),e=d.attr("data-selector-type").split("x"),f=e[0],g=e[1],j=1;for(var o=0;f>o;o++)for(var p=0;g>p;p++)h+='
    ';d.html(h)}for(n=0;nh;h++)e.moveTo(0,g*h),e.lineTo(b,g*h);for(var i=1;d>i;i++)e.moveTo(f*i,0),e.lineTo(f*i,a);e.closePath(),e.stroke()},clearCanvas:function(){var a=$("canvas")[0],b=a.getContext("2d");b.clearRect(0,0,b.canvas.width,b.canvas.height)},initSortable:function(){$(".sortable").sortable().on("sortupdate",function(){resize.layout.updateLayoutStore(),sendTracking("dnd-event","dnd-label")}),b=!0},resetSortable:function(){if(b){var a=$(".sortable");a.sortable("destroy"),a.sortable()}}},b=!1;window.resize.util=a}(),function(a){function b(a){for(var b,e,f,g,h,l=a.displays,m=null,n=null,o=null,p=null,q=0,r=l.length;r>q;q++)h=l[q].workArea,(null===m||m>h.left)&&(m=h.left),(null===n||nh.top)&&(o=h.top),(null===p||pf?f:g,j=0!==m?-1*m*i:0,k=0!==o?-1*o*i:0,d(i,e)}function c(){a("#display-setting-layer");return{width:l,height:m}}function d(b,c){var d=a("#display-setting-layer");d.height(b*c)}function e(a,b){for(var c,d=0,e=a.length,f={displays:[],primaryIndex:0};e>d;d++)c=a[d],c.id=String(d),f.displays.push({workArea:c.workArea,isEnabled:c.isEnabled,id:c.id}),b.left>c.workArea.left&&b.leftc.workArea.top&&b.top
    ');return e.css({top:b.top*i+k,left:b.left*i+j,width:b.width*i,height:b.height*i}).data(a.extend({id:c},b)),e.find(".display-meta").text(b.width+"x"+b.height),d&&e.addClass("selected"),e}var g,h=window.resize,i=.15,j=0,k=0,l=530,m=250,n={initialize:function(){chrome.system&&chrome.system.display&&(h.display=chrome.system.display,g=a("#display-setting-layer"),g.on("click",".display-entry",function(){var b=a(this),c={},d=b.data("id"),e=b.find(".display-meta").text();c[d]=!0,g.find(".display-entry").removeClass("selected"),b.addClass("selected"),sendTracking("display-select",e)}),h.display.getInfo(function(a){chrome.windows.getCurrent({populate:!0},function(c){var d,i,j={left:c.left+c.width-100,top:c.top+100},k=e(a,j);b(k);for(var l=0;l0&&g&&g>0)f>a.canvasHeight/4&&(f=a.canvasHeight/4),g>a.canvasWidth/4&&(g=a.canvasWidth/4),d.drawTable(a.canvasWidth,a.canvasHeight,f,g,e),$("#input-save").removeClass("disabled");else{var h=$(this),i=Number(h.attr("value"));(0===i||isNaN(i))&&(h.attr("value",""),$("#input-save").addClass("disabled"))}}).on("change","#checkbox-single-tab",function(){var a=$(this).attr("checked");f.processSingleTabSelection(a),sendTracking("single-tab",a?"checked":"unchecked")}).on("change","#checkbox-empty-tab",function(){var a=$(this).attr("checked");f.processEmptyTabSelection(a),sendTracking("empty-tab",a?"checked":"unchecked")}).on("click","#display-setting",function(){var a,b=$(".main-view");b.toggleClass("display-selected"),a=b.hasClass("display-selected"),f.processDisplayLayerSelection(a),sendTracking("display-settings",a?"opened":"closed")}).on("click","#display-setting-layer .switch-toggle input",function(a,b){var c=$(this).attr("id");$(".switch-toggle").removeClass("right-align left-align").addClass(c+"-align"),f.processAlignmentSelection(c),b||sendTracking("alignment",c)}).on("click","#update-apply",function(){f.hideUpdateModal()}).on("click","#promo-apply",function(){f.hidePromoModal()}).on("click","#warning-apply",function(){f.hideWarningModal()}).on("click",".signature a",function(){$(this).hasClass("rate-it")?sendTracking("info-links","rate-it"):sendTracking("info-links","author")})}(); \ No newline at end of file +function sendTracking(a,b){!deferTracking&&ga&&ga("send","event",a,"clicked",b||"na")}var optOut=localStorage.getItem("tracking-opt-out"),deferTracking=!1;optOut&&"true"===optOut&&(deferTracking=!0),deferTracking||(!function(a,b,c,d,e,f,g){a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","https://www.google-analytics.com/analytics.js","ga"),ga("create","UA-34217520-2","auto"),ga("set","checkProtocolTask",function(){}),ga("require","displayfeatures"),ga("send","pageview","/index.html")),function(){var a={tabsArray:[],currentTab:null,numRows:0,numCols:0,width:0,height:0,canvasHeight:100,canvasWidth:100,currentLayouts:null,defaultLayouts:{layoutItems:["1x1","1x2","2x1","2x2"]},layoutSprites:{layoutItems:["1x1","1x2","2x1","2x2","1x3","3x1"]},maxSelectorsPerLine:5,maxSelectorContainerWidth:156,maxSelectorContainerHeight:156,singleTab:!1,main_view:{},custom_view:{},options:{},util:{},badgeLimit:7,isMac:-1!==navigator.platform.toUpperCase().indexOf("MAC")};window.resize=a}(),function(){var a=window.resize,b={initialize:function(){a.currentLayouts=JSON.parse(localStorage.getItem("layoutItems")),a.currentLayouts||(localStorage.setItem("layoutItems",JSON.stringify(a.defaultLayouts)),a.currentLayouts=$.extend(!0,{},a.defaultLayouts)),this.populateMainView();var b=localStorage.getItem("singleTab");b&&"true"===b&&($("#checkbox-single-tab").attr("checked",!0),$("label.single-tab").addClass("selected"),$("body").addClass("single-tab-selected"),a.singleTab=!0);var c=localStorage.getItem("emptyTab");c&&"true"!==c?$("body").addClass("empty-tab-not-selected"):($("#checkbox-empty-tab").attr("checked",!0),$("label.empty-tab").addClass("selected"),a.emptyTab=!0);var d=localStorage.getItem("displayLayer");d&&"true"!==d||($(".main-view").addClass("display-selected"),a.displayLayer=!0);var e=localStorage.getItem("alignment");e?(a.alignment=e,"left"!==a.alignment&&$("body").addClass("align-right")):a.alignment="left",$("#"+a.alignment).trigger("click",["defer-tracking"]),a.displayUtil.initialize(),localStorage.getItem("lastTab")&&$("#undo-layout").removeClass("disabled"),window.backJs=chrome.extension.getBackgroundPage(),chrome.runtime.onMessage.addListener(function(b){"enable-undo"===b&&a.options.enableUndoButton()});var f=Number(localStorage.getItem("updateBadge"));f||(localStorage.setItem("updateBadge",0),chrome.browserAction.setBadgeText({text:"NEW"}),chrome.browserAction.setBadgeBackgroundColor({color:[221,129,39,255]})),f=5&&0===c&&($("body").height($("body").height()-a.maxSelectorContainerHeight),$("html").height($("html").height()-a.maxSelectorContainerHeight))},resizeTabs:function(b,c){a.numRows=b,a.numCols=c;var d=$(".display-entry.selected").data();$.isEmptyObject(d)?(a.width=Math.round(window.screen.availWidth/a.numCols),a.height=Math.round(window.screen.availHeight/a.numRows),a.offsetX=0,a.offsetY=0,a.fullWidth=window.screen.availWidth,a.fullHeight=window.screen.availHeight):(a.width=Math.round(d.width/a.numCols),a.height=Math.round(d.height/a.numRows),a.offsetX=d.left,a.offsetY=d.top,a.fullWidth=d.width,a.fullHeight=d.height);window.chrome.tabs.query({currentWindow:!0},function(b){a.tabsArray=b,window.chrome.tabs.query({currentWindow:!0,active:!0},function(b){a.currentTab=b[0];var c=function(){return backJs.util.processTabs(a,a.tabsArray,a.currentTab.index,a.currentTab.windowId,a.singleTab,a.currentTab.incognito)};a.singleTab?backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(a.currentTab.index,a.currentTab.index+1),c):backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(a.currentTab.index),c)})})}};window.resize.main_view=b}(),function(){var a=window.resize,b={hideCustomMenu:function(){$(".custom-view").addClass("hidden"),$(".main-view").removeClass("inactive"),a.util.clearCanvas()},showCustomMenu:function(){this.clearCustomValues(),$(".main-view").addClass("inactive"),$(".custom-view").removeClass("hidden").trigger("show"),$(".custom-view input.row").focus()},clearCustomValues:function(){$("#numRows").val(""),$("#numCols").val(""),$("#input-save").addClass("disabled")},handleCustomSave:function(){var b=$("#numRows").val(),c=$("#numCols").val();if(this.clearCustomValues(),!Number(b)||!Number(c)||Number(b)<1||Number(c)<1);else{var d=b+"x"+c;a.layout.addLayout(d),a.layout.processTabInfo($(".layout-"+d)),this.hideCustomMenu()}}};window.resize.custom_view=b}(),function(){var a=window.resize,b={processSingleTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("singleTab",c),a.singleTab=c,$("label.single-tab").toggleClass("selected"),$("body").toggleClass("single-tab-selected")},processEmptyTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("emptyTab",c),a.emptyTab=c,$("label.empty-tab").toggleClass("selected"),$("body").toggleClass("empty-tab-not-selected")},processDisplayLayerSelection:function(b){var c=b?!0:!1;localStorage.setItem("displayLayer",c),a.displayLayer=c},processAlignmentSelection:function(b){localStorage.setItem("alignment",b),a.alignment=b,"right"===b?$("body").addClass("align-right"):$("body").removeClass("align-right")},undoResize:function(){var b=this;a.lastTab=JSON.parse(localStorage.getItem("lastTab"));var c=a.lastTab.lastTabIndex,d=a.lastTab.lastWindowId,e=a.lastTab.lastTabsArray;window.chrome.windows.get(d,{},function(f){f?b.recombineTabs(c,d,e):chrome.tabs.query({status:"complete"},function(c){for(var d={},f=[],g=0;gd;b++,d++){a=c[b];var e=$(".resize-container").find(".tab-layer-"+d);e.addClass("valid-tab");for(var f=0;fd;d++)e.push(a.eq(d).attr("data-selector-type"));b.currentLayouts.layoutItems=e,localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts))},addLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);-1!==d&&(c.splice(d,1),this._removeLayoutMarkup(a)),b.currentLayouts.layoutItems.unshift(a),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this.addLayoutMarkup(a,!0),b.util.resetSortable()},addLayoutMarkup:function(a,c){var d="layout-default";(-1!==b.layoutSprites.layoutItems.indexOf(a)||"1x1"===a)&&(d="layout-"+a);var e=$(".resize-container"),f='
  • '+a+'
  • ';c?e.prepend(f):e.append(f)},removeLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);c.splice(d,1),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this._removeLayoutMarkup(a)},_removeLayoutMarkup:function(a){var b='[data-selector-type="'+a+'"]';$(b).parent().remove()},resetLayout:function(){this._removeAllLayouts(),localStorage.setItem("layoutItems",JSON.stringify(b.defaultLayouts)),b.currentLayouts=$.extend(!0,{},b.defaultLayouts),b.main_view.populateMainView(),this.processTabInfo(),b.util.resetSortable()},_removeAllLayouts:function(){$(".resize-container").children().remove()},processTabInfo:function(c){var d,e,f,g,h,i,j,k=b.currentWindowTabs,l=c||$(".resize-container").find(".resize-selector-container .resize-selector"),m=0,n=0;if(l=l.filter(function(){return!$(this).hasClass("layout-default")}),m=l.length,k&&k.length>0){for(;m>n;n++){h="",d=l.eq(n),e=d.attr("data-selector-type").split("x"),f=e[0],g=e[1],j=1;for(var o=0;f>o;o++)for(var p=0;g>p;p++)h+='
    ';d.html(h)}for(n=0;nh;h++)e.moveTo(0,g*h),e.lineTo(b,g*h);for(var i=1;d>i;i++)e.moveTo(f*i,0),e.lineTo(f*i,a);e.closePath(),e.stroke()},clearCanvas:function(){var a=$("canvas")[0],b=a.getContext("2d");b.clearRect(0,0,b.canvas.width,b.canvas.height)},initSortable:function(){$(".sortable").sortable().on("sortupdate",function(){resize.layout.updateLayoutStore(),sendTracking("dnd-event","dnd-label")}),b=!0},resetSortable:function(){if(b){var a=$(".sortable");a.sortable("destroy"),a.sortable()}}},b=!1;window.resize.util=a}(),function(a){function b(a){for(var b,e,f,g,h,l=a.displays,m=null,n=null,o=null,p=null,q=0,r=l.length;r>q;q++)h=l[q].workArea,(null===m||m>h.left)&&(m=h.left),(null===n||nh.top)&&(o=h.top),(null===p||pf?f:g,j=0!==m?-1*m*i:0,k=0!==o?-1*o*i:0,d(i,e)}function c(){a("#display-setting-layer");return{width:l,height:m}}function d(b,c){var d=a("#display-setting-layer");d.height(b*c)}function e(a,b){for(var c,d=0,e=a.length,f={displays:[],primaryIndex:0};e>d;d++)c=a[d],c.id=String(d),f.displays.push({workArea:c.workArea,isEnabled:c.isEnabled,id:c.id}),b.left>c.workArea.left&&b.leftc.workArea.top&&b.top
    ');return e.css({top:b.top*i+k,left:b.left*i+j,width:b.width*i,height:b.height*i}).data(a.extend({id:c},b)),e.find(".display-meta").text(b.width+"x"+b.height),d&&e.addClass("selected"),e}var g,h=window.resize,i=.15,j=0,k=0,l=530,m=250,n={initialize:function(){chrome.system&&chrome.system.display&&(h.display=chrome.system.display,g=a("#display-setting-layer"),g.on("click",".display-entry",function(){var b=a(this),c={},d=b.data("id"),e=b.find(".display-meta").text();c[d]=!0,g.find(".display-entry").removeClass("selected"),b.addClass("selected"),sendTracking("display-select",e)}),h.display.getInfo(function(a){chrome.windows.getCurrent({populate:!0},function(c){var d,i,j={left:c.left+c.width-100,top:c.top+100},k=e(a,j);b(k);for(var l=0;l0&&g&&g>0)f>a.canvasHeight/4&&(f=a.canvasHeight/4),g>a.canvasWidth/4&&(g=a.canvasWidth/4),d.drawTable(a.canvasWidth,a.canvasHeight,f,g,e),$("#input-save").removeClass("disabled");else{var h=$(this),i=Number(h.attr("value"));(0===i||isNaN(i))&&(h.attr("value",""),$("#input-save").addClass("disabled"))}}).on("change","#checkbox-single-tab",function(){var a=$(this).attr("checked");f.processSingleTabSelection(a),sendTracking("single-tab",a?"checked":"unchecked")}).on("change","#checkbox-empty-tab",function(){var a=$(this).attr("checked");f.processEmptyTabSelection(a),sendTracking("empty-tab",a?"checked":"unchecked")}).on("click","#display-setting",function(){var a,b=$(".main-view");b.toggleClass("display-selected"),a=b.hasClass("display-selected"),f.processDisplayLayerSelection(a),sendTracking("display-settings",a?"opened":"closed")}).on("click","#display-setting-layer .switch-toggle input",function(a,b){var c=$(this).attr("id");$(".switch-toggle").removeClass("right-align left-align").addClass(c+"-align"),f.processAlignmentSelection(c),b||sendTracking("alignment",c)}).on("click","#update-apply",function(){f.hideUpdateModal()}).on("click","#promo-apply",function(){f.hidePromoModal()}).on("click","#warning-apply",function(){f.hideWarningModal()}).on("click",".signature a",function(){$(this).hasClass("rate-it")?sendTracking("info-links","rate-it"):sendTracking("info-links","author")})}(); \ No newline at end of file From dc9cdd0848518b4a6b8cd9021e1774aeb42d0534 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 12 Sep 2014 07:30:35 -0700 Subject: [PATCH 3/6] Selected tab feature: when 2 or more tabs are selected they are now used for the resize. --- css/style.less | 6 ++-- index.html | 5 +++- js/background.js | 2 +- js/display.js | 14 +++++---- js/main_view.js | 32 ++++++++++++-------- js/options.js | 2 +- public/style.css | 2 +- public/tabResize.js | 48 ++++++++++++++++++------------ public/tabResize.min.js | 2 +- public/tabResize_background.js | 2 +- public/tabResize_background.min.js | 2 +- 11 files changed, 70 insertions(+), 47 deletions(-) diff --git a/css/style.less b/css/style.less index e1bcb1b..e673269 100644 --- a/css/style.less +++ b/css/style.less @@ -634,7 +634,7 @@ button.disabled { display: none; z-index: 5; .modal-body { - width: 450px; + width: 550px; height: 400px; .header-title-wrap { @@ -667,7 +667,7 @@ button.disabled { li.update-entry { list-style: disc; margin-bottom: 10px; - line-height: 16px; + line-height: 18px; } } @@ -915,7 +915,7 @@ body { } .modal-body { - height: 300px; + height: 350px; } } diff --git a/index.html b/index.html index ddbe533..bcb5693 100644 --- a/index.html +++ b/index.html @@ -117,7 +117,7 @@
    - Tab Resize 2.1 Updates + Tab Resize 2.1.1 Updates
    What's New:
    @@ -134,6 +134,9 @@
  • Drag and drop for sorting layouts - Click and hold on any layout and drag to rearange order to your liking
  • +
  • + Highlighted tabs now can be resized - when 2 or more tabs are highlighted, only these tabs will be considered for resize. Credit goes to F.C. for the idea. Highlight info. +
  • ');return e.css({top:b.top*i+k,left:b.left*i+j,width:b.width*i,height:b.height*i}).data(a.extend({id:c},b)),e.find(".display-meta").text(b.width+"x"+b.height),d&&e.addClass("selected"),e}var g,h=window.resize,i=.15,j=0,k=0,l=530,m=250,n={initialize:function(){chrome.system&&chrome.system.display&&(h.display=chrome.system.display,g=a("#display-setting-layer"),g.on("click",".display-entry",function(){var b=a(this),c={},d=b.data("id"),e=b.find(".display-meta").text();c[d]=!0,g.find(".display-entry").removeClass("selected"),b.addClass("selected"),sendTracking("display-select",e)}),h.display.getInfo(function(a){chrome.windows.getCurrent({populate:!0},function(c){var d,i,j={left:c.left+c.width-100,top:c.top+100},k=e(a,j);b(k);for(var l=0;l0&&g&&g>0)f>a.canvasHeight/4&&(f=a.canvasHeight/4),g>a.canvasWidth/4&&(g=a.canvasWidth/4),d.drawTable(a.canvasWidth,a.canvasHeight,f,g,e),$("#input-save").removeClass("disabled");else{var h=$(this),i=Number(h.attr("value"));(0===i||isNaN(i))&&(h.attr("value",""),$("#input-save").addClass("disabled"))}}).on("change","#checkbox-single-tab",function(){var a=$(this).attr("checked");f.processSingleTabSelection(a),sendTracking("single-tab",a?"checked":"unchecked")}).on("change","#checkbox-empty-tab",function(){var a=$(this).attr("checked");f.processEmptyTabSelection(a),sendTracking("empty-tab",a?"checked":"unchecked")}).on("click","#display-setting",function(){var a,b=$(".main-view");b.toggleClass("display-selected"),a=b.hasClass("display-selected"),f.processDisplayLayerSelection(a),sendTracking("display-settings",a?"opened":"closed")}).on("click","#display-setting-layer .switch-toggle input",function(a,b){var c=$(this).attr("id");$(".switch-toggle").removeClass("right-align left-align").addClass(c+"-align"),f.processAlignmentSelection(c),b||sendTracking("alignment",c)}).on("click","#update-apply",function(){f.hideUpdateModal()}).on("click","#promo-apply",function(){f.hidePromoModal()}).on("click","#warning-apply",function(){f.hideWarningModal()}).on("click",".signature a",function(){$(this).hasClass("rate-it")?sendTracking("info-links","rate-it"):sendTracking("info-links","author")})}(); \ No newline at end of file +function sendTracking(a,b){!deferTracking&&ga&&ga("send","event",a,"clicked",b||"na")}var optOut=localStorage.getItem("tracking-opt-out"),deferTracking=!1;optOut&&"true"===optOut&&(deferTracking=!0),deferTracking||(!function(a,b,c,d,e,f,g){a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","https://www.google-analytics.com/analytics.js","ga"),ga("create","UA-34217520-2","auto"),ga("set","checkProtocolTask",function(){}),ga("require","displayfeatures"),ga("send","pageview","/index.html")),function(){var a={tabsArray:[],currentTab:null,numRows:0,numCols:0,width:0,height:0,canvasHeight:100,canvasWidth:100,currentLayouts:null,defaultLayouts:{layoutItems:["1x1","1x2","2x1","2x2"]},layoutSprites:{layoutItems:["1x1","1x2","2x1","2x2","1x3","3x1"]},maxSelectorsPerLine:5,maxSelectorContainerWidth:156,maxSelectorContainerHeight:156,singleTab:!1,main_view:{},custom_view:{},options:{},util:{},badgeLimit:7,isMac:-1!==navigator.platform.toUpperCase().indexOf("MAC")};window.resize=a}(),function(){var a=window.resize,b={initialize:function(){a.currentLayouts=JSON.parse(localStorage.getItem("layoutItems")),a.currentLayouts||(localStorage.setItem("layoutItems",JSON.stringify(a.defaultLayouts)),a.currentLayouts=$.extend(!0,{},a.defaultLayouts)),this.populateMainView();var b=localStorage.getItem("singleTab");b&&"true"===b&&($("#checkbox-single-tab").attr("checked",!0),$("label.single-tab").addClass("selected"),$("body").addClass("single-tab-selected"),a.singleTab=!0);var c=localStorage.getItem("emptyTab");c&&"true"!==c?$("body").addClass("empty-tab-not-selected"):($("#checkbox-empty-tab").attr("checked",!0),$("label.empty-tab").addClass("selected"),a.emptyTab=!0);var d=localStorage.getItem("displayLayer");d&&"true"!==d||($(".main-view").addClass("display-selected"),a.displayLayer=!0);var e=localStorage.getItem("alignment");e?(a.alignment=e,"left"!==a.alignment&&$("body").addClass("align-right")):a.alignment="left",$("#"+a.alignment).trigger("click",["defer-tracking"]),a.displayUtil.initialize(),localStorage.getItem("lastTab")&&$("#undo-layout").removeClass("disabled"),window.backJs=chrome.extension.getBackgroundPage(),chrome.runtime.onMessage.addListener(function(b){"enable-undo"===b&&a.options.enableUndoButton()});var f=Number(localStorage.getItem("updateBadge"));f||(localStorage.setItem("updateBadge",0),chrome.browserAction.setBadgeText({text:"NEW"}),chrome.browserAction.setBadgeBackgroundColor({color:[221,129,39,255]})),fg&&""!==g,i=$("body");(!localStorage.getItem("update-seen")||h)&&(i.addClass("update"),h?localStorage.removeItem("update-seen"):localStorage.getItem("warning-seen")||(i.addClass("warning"),a.options.showWarningModal()),a.options.showUpdateModal(h?"partial-update":"")),localStorage.getItem("update-seen")&&f===a.badgeLimit&&!localStorage.getItem("promo-seen")&&(i.addClass("promo"),a.options.showPromoModal()),$(function(){a.util.initSortable()})},populateMainView:function(){for(var b=0;b=5&&0===c&&($("body").height($("body").height()-a.maxSelectorContainerHeight),$("html").height($("html").height()-a.maxSelectorContainerHeight))},resizeTabs:function(b,c){a.numRows=b,a.numCols=c;var d=$(".display-entry.selected").data();$.isEmptyObject(d)?(a.width=Math.round(window.screen.availWidth/a.numCols),a.height=Math.round(window.screen.availHeight/a.numRows),a.offsetX=0,a.offsetY=0,a.fullWidth=window.screen.availWidth,a.fullHeight=window.screen.availHeight):(a.width=Math.round(d.width/a.numCols),a.height=Math.round(d.height/a.numRows),a.offsetX=d.left,a.offsetY=d.top,a.fullWidth=d.width,a.fullHeight=d.height);window.chrome.tabs.query({currentWindow:!0},function(b){a.tabsArray=b,window.chrome.tabs.query({currentWindow:!0,highlighted:!0},function(b){a.currentTab=b[0];var c=a.currentTab.index;b.length>1&&(a.tabsArray=b,c=0);var d=function(){return backJs.util.processTabs(a,a.tabsArray,c,a.currentTab.windowId,a.singleTab,a.currentTab.incognito)};a.singleTab?backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(c,c+1),d):backJs.util.setUndoStorage(a,a.currentTab.index,a.currentTab.windowId,a.tabsArray.slice(c),d)})})}};window.resize.main_view=b}(),function(){var a=window.resize,b={hideCustomMenu:function(){$(".custom-view").addClass("hidden"),$(".main-view").removeClass("inactive"),a.util.clearCanvas()},showCustomMenu:function(){this.clearCustomValues(),$(".main-view").addClass("inactive"),$(".custom-view").removeClass("hidden").trigger("show"),$(".custom-view input.row").focus()},clearCustomValues:function(){$("#numRows").val(""),$("#numCols").val(""),$("#input-save").addClass("disabled")},handleCustomSave:function(){var b=$("#numRows").val(),c=$("#numCols").val();if(this.clearCustomValues(),!Number(b)||!Number(c)||Number(b)<1||Number(c)<1);else{var d=b+"x"+c;a.layout.addLayout(d),a.layout.processTabInfo($(".layout-"+d)),this.hideCustomMenu()}}};window.resize.custom_view=b}(),function(){var a=window.resize,b={processSingleTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("singleTab",c),a.singleTab=c,$("label.single-tab").toggleClass("selected"),$("body").toggleClass("single-tab-selected")},processEmptyTabSelection:function(b){var c=b?!0:!1;localStorage.setItem("emptyTab",c),a.emptyTab=c,$("label.empty-tab").toggleClass("selected"),$("body").toggleClass("empty-tab-not-selected")},processDisplayLayerSelection:function(b){var c=b?!0:!1;localStorage.setItem("displayLayer",c),a.displayLayer=c},processAlignmentSelection:function(b){localStorage.setItem("alignment",b),a.alignment=b,"right"===b?$("body").addClass("align-right"):$("body").removeClass("align-right")},undoResize:function(){var b=this;a.lastTab=JSON.parse(localStorage.getItem("lastTab"));var c=a.lastTab.lastTabIndex,d=a.lastTab.lastWindowId,e=a.lastTab.lastTabsArray;window.chrome.windows.get(d,{},function(f){f?b.recombineTabs(c,d,e):chrome.tabs.query({status:"complete"},function(c){for(var d={},f=[],g=0;gd;b++,d++){a=c[b];var e=$(".resize-container").find(".tab-layer-"+d);e.addClass("valid-tab");for(var f=0;fd;d++)e.push(a.eq(d).attr("data-selector-type"));b.currentLayouts.layoutItems=e,localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts))},addLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);-1!==d&&(c.splice(d,1),this._removeLayoutMarkup(a)),b.currentLayouts.layoutItems.unshift(a),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this.addLayoutMarkup(a,!0),b.util.resetSortable()},addLayoutMarkup:function(a,c){var d="layout-default";(-1!==b.layoutSprites.layoutItems.indexOf(a)||"1x1"===a)&&(d="layout-"+a);var e=$(".resize-container"),f='
  • '+a+'
  • ';c?e.prepend(f):e.append(f)},removeLayout:function(a){var c=b.currentLayouts.layoutItems,d=c.indexOf(a);c.splice(d,1),localStorage.setItem("layoutItems",JSON.stringify(b.currentLayouts)),this._removeLayoutMarkup(a)},_removeLayoutMarkup:function(a){var b='[data-selector-type="'+a+'"]';$(b).parent().remove()},resetLayout:function(){this._removeAllLayouts(),localStorage.setItem("layoutItems",JSON.stringify(b.defaultLayouts)),b.currentLayouts=$.extend(!0,{},b.defaultLayouts),b.main_view.populateMainView(),this.processTabInfo(),b.util.resetSortable()},_removeAllLayouts:function(){$(".resize-container").children().remove()},processTabInfo:function(c){var d,e,f,g,h,i,j,k=b.currentWindowTabs,l=c||$(".resize-container").find(".resize-selector-container .resize-selector"),m=0,n=0;if(l=l.filter(function(){return!$(this).hasClass("layout-default")}),m=l.length,k&&k.length>0){for(;m>n;n++){h="",d=l.eq(n),e=d.attr("data-selector-type").split("x"),f=e[0],g=e[1],j=1;for(var o=0;f>o;o++)for(var p=0;g>p;p++)h+='
    ';d.html(h)}for(n=0;nh;h++)e.moveTo(0,g*h),e.lineTo(b,g*h);for(var i=1;d>i;i++)e.moveTo(f*i,0),e.lineTo(f*i,a);e.closePath(),e.stroke()},clearCanvas:function(){var a=$("canvas")[0],b=a.getContext("2d");b.clearRect(0,0,b.canvas.width,b.canvas.height)},initSortable:function(){$(".sortable").sortable().on("sortupdate",function(){resize.layout.updateLayoutStore(),sendTracking("dnd-event","dnd-label")}),b=!0},resetSortable:function(){if(b){var a=$(".sortable");a.sortable("destroy"),a.sortable()}}},b=!1;window.resize.util=a}(),function(a){function b(a){for(var b,e,f,g,h,l=a.displays,m=null,n=null,o=null,p=null,q=0,r=l.length;r>q;q++)h=l[q].workArea,(null===m||m>h.left)&&(m=h.left),(null===n||nh.top)&&(o=h.top),(null===p||pf?f:g,j=0!==m?-1*m*i:0,k=0!==o?-1*o*i:0,d(i,e)}function c(){a("#display-setting-layer");return{width:l,height:m}}function d(b,c){var d=a("#display-setting-layer");d.height(b*c)}function e(a,b){for(var c,d=0,e=a.length,f={displays:[],primaryIndex:0};e>d;d++)c=a[d],c.id=String(d),f.displays.push({workArea:c.workArea,isEnabled:c.isEnabled,id:c.id}),b.left>c.workArea.left&&b.leftc.workArea.top&&b.top
    ');return e.css({top:b.top*i+k,left:b.left*i+j,width:b.width*i,height:b.height*i}).data(a.extend({id:c},b)),e.find(".display-meta").text(b.width+"x"+b.height),d&&e.addClass("selected"),e}var g,h=window.resize,i=.15,j=0,k=0,l=530,m=250,n={initialize:function(){chrome.system&&chrome.system.display&&(h.display=chrome.system.display,g=a("#display-setting-layer"),g.on("click",".display-entry",function(){var b=a(this),c={},d=b.data("id"),e=b.find(".display-meta").text();c[d]=!0,g.find(".display-entry").removeClass("selected"),b.addClass("selected"),sendTracking("display-select",e)}),h.display.getInfo(function(a){chrome.windows.getCurrent({populate:!0},function(c){var d,i,j={left:c.left+c.width-100,top:c.top+100},k=e(a,j);b(k);for(var l=0;l1?a:c.tabs,h.layout.processTabInfo()})})}))}};h.displayUtil=n}(window.jQuery),function(){var a=window.resize,b=a.main_view,c=a.custom_view,d=a.util,e=a.layout,f=a.options,g=(a.displayUtil,$(document));g.ready(function(){b.initialize()}).on("click",".resize-selector-container",function(){var a=$(this).children(".resize-selector"),c=a.attr("data-selector-type"),d=c.split("x");b.resizeTabs(Number(d[0]),Number(d[1])),sendTracking("resize",c)}).on("show",".modal-box",function(a){a.stopPropagation(),d.centerModal($(this))}).on("click",".modal-box",function(a){a.stopPropagation()}).on("click",".close-button",function(a){a.stopPropagation();var b=$(this).siblings(".resize-selector").attr("data-selector-type");e.removeLayout(b),sendTracking("resize-delete",b)}).on("click","#undo-layout",function(){f.undoResize(),sendTracking("undo","undo")}).on("click","#custom-layout",function(a){a.stopPropagation(),c.showCustomMenu(),sendTracking("custom-layout","open")}).on("click","#default-configuration",function(a){a.stopPropagation(),f.showConfirmationModal(),sendTracking("default-layout","open")}).on("click","#confirmation-cancel",function(){f.hideConfirmationModal(),sendTracking("default-layout","cancel")}).on("click","#confirmation-apply",function(){e.resetLayout(),f.hideConfirmationModal(),sendTracking("default-layout","apply")}).on("click","#input-cancel,.main-view",function(){$(".custom-view").hasClass("hidden")||(c.clearCustomValues(),c.hideCustomMenu(),sendTracking("custom-layout","cancel"))}).on("click","#input-save",function(){c.handleCustomSave(),sendTracking("custom-layout","apply")}).on("click","body",function(){$(".custom-view").hasClass("hidden")||(d.clearCanvas(),c.hideCustomMenu(),sendTracking("custom-layout","cancel-layer")),$(".confirmation-modal").hasClass("hidden")||(f.hideConfirmationModal(),sendTracking("default-layout","cancel-layer"))}).on("keyup","#numRows, #numCols",function(b){b.stopPropagation();var c=document.getElementById("myCanvas"),e=c.getContext("2d"),f=Number($("#numRows").attr("value")),g=Number($("#numCols").attr("value"));if(d.clearCanvas(),f&&f>0&&g&&g>0)f>a.canvasHeight/4&&(f=a.canvasHeight/4),g>a.canvasWidth/4&&(g=a.canvasWidth/4),d.drawTable(a.canvasWidth,a.canvasHeight,f,g,e),$("#input-save").removeClass("disabled");else{var h=$(this),i=Number(h.attr("value"));(0===i||isNaN(i))&&(h.attr("value",""),$("#input-save").addClass("disabled"))}}).on("change","#checkbox-single-tab",function(){var a=$(this).attr("checked");f.processSingleTabSelection(a),sendTracking("single-tab",a?"checked":"unchecked")}).on("change","#checkbox-empty-tab",function(){var a=$(this).attr("checked");f.processEmptyTabSelection(a),sendTracking("empty-tab",a?"checked":"unchecked")}).on("click","#display-setting",function(){var a,b=$(".main-view");b.toggleClass("display-selected"),a=b.hasClass("display-selected"),f.processDisplayLayerSelection(a),sendTracking("display-settings",a?"opened":"closed")}).on("click","#display-setting-layer .switch-toggle input",function(a,b){var c=$(this).attr("id");$(".switch-toggle").removeClass("right-align left-align").addClass(c+"-align"),f.processAlignmentSelection(c),b||sendTracking("alignment",c)}).on("click","#update-apply",function(){f.hideUpdateModal()}).on("click","#promo-apply",function(){f.hidePromoModal()}).on("click","#warning-apply",function(){f.hideWarningModal()}).on("click",".signature a",function(){$(this).hasClass("rate-it")?sendTracking("info-links","rate-it"):sendTracking("info-links","author")})}(); \ No newline at end of file diff --git a/public/tabResize_background.js b/public/tabResize_background.js index a7518c4..8c7a480 100644 --- a/public/tabResize_background.js +++ b/public/tabResize_background.js @@ -7,7 +7,7 @@ if(!localStorage.getItem('updateBadge')){ } if(!localStorage.getItem('version')){ - localStorage.setItem('version','2.1'); + localStorage.setItem('version','2.1.1'); } var util = { diff --git a/public/tabResize_background.min.js b/public/tabResize_background.min.js index dc3ce56..a7be203 100644 --- a/public/tabResize_background.min.js +++ b/public/tabResize_background.min.js @@ -1 +1 @@ -localStorage.getItem("updateBadge")||(localStorage.setItem("updateBadge",0),chrome.browserAction.setBadgeText({text:"NEW"}),chrome.browserAction.setBadgeBackgroundColor({color:[221,129,39,255]})),localStorage.getItem("version")||localStorage.setItem("version","2.1");var util={createNewWindow:function(a,b,c,d,e,f,g){var h={left:b,top:c,width:d,height:e,incognito:f};a&&(h.tabId=$.isArray(a)?a[0]:a),window.chrome.windows.create(h,function(b){g(b,a)})},processTabs:function(a,b,c,d,e,f){for(var g,h,i,j=b.slice(c),k=0,l=0,m=j.length,n=a.numRows*a.numCols-m,o=this,p=function(b,c){!c&&a.emptyTab?(j.push(b.tabs[0]),l++,n===l&&o.updateUndoStorage(a,j)):c&&$.isArray(c)&&chrome.tabs.move(c.slice(1),{windowId:b.id,index:1})},q=0;q1){g=[];for(var s=k;m>s;s++)g.push(j[s].id)}o.createNewWindow(g,h,i,a.width,a.height,f,p)}k++}},setUndoStorage:function(a,b,c,d,e){window.chrome.windows.get(c,{},function(a){var f={left:a.left,top:a.top,width:a.width,height:a.height,focused:!0,state:"normal",incognito:a.incognito},g={};g.lastWindowInfo=f,g.lastTabIndex=b,g.lastWindowId=c;for(var h=[],i=0;i1){g=[];for(var s=k;m>s;s++)g.push(j[s].id)}o.createNewWindow(g,h,i,a.width,a.height,f,p)}k++}},setUndoStorage:function(a,b,c,d,e){window.chrome.windows.get(c,{},function(a){var f={left:a.left,top:a.top,width:a.width,height:a.height,focused:!0,state:"normal",incognito:a.incognito},g={};g.lastWindowInfo=f,g.lastTabIndex=b,g.lastWindowId=c;for(var h=[],i=0;i Date: Fri, 12 Sep 2014 07:37:39 -0700 Subject: [PATCH 4/6] Fixing broken link. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index bcb5693..363d7e5 100644 --- a/index.html +++ b/index.html @@ -135,7 +135,7 @@ Drag and drop for sorting layouts - Click and hold on any layout and drag to rearange order to your liking
  • - Highlighted tabs now can be resized - when 2 or more tabs are highlighted, only these tabs will be considered for resize. Credit goes to F.C. for the idea. Highlight info. + Highlighted tabs now can be resized - when 2 or more tabs are highlighted, only these tabs will be considered for resize. Credit goes to F.C. for the idea. Highlight info.