Skip to content

Commit 16cf76f

Browse files
committed
Merge pull request #24 from peterdotjs/dev
Adding in favicons for each tab.
2 parents 6164d03 + 3a39b46 commit 16cf76f

File tree

10 files changed

+225
-126
lines changed

10 files changed

+225
-126
lines changed

css/index.css

Lines changed: 1 addition & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/style.less

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@ button.disabled {
281281
top: 21px;
282282
border-radius: 4px;
283283
border: 5px solid #7C7C7C;
284+
285+
.tab-layer {
286+
position: relative;
287+
display: inline-block;
288+
float: left;
289+
top: 0px;
290+
left: 0px;
291+
.fav-icon {
292+
position: absolute;
293+
background-repeat: no-repeat;
294+
background-size: 27px 27px;
295+
width: 27px;
296+
height: 27px;
297+
background-image: url('https://www.google.com/favicon.ico');
298+
}
299+
}
300+
284301
}
285302

286303

@@ -698,36 +715,150 @@ body.update {
698715
}
699716
}
700717

718+
body {
719+
&.align-right {
720+
.tab-layer {
721+
float: right !important;
722+
}
723+
}
724+
725+
&.empty-tab-not-selected {
726+
.tab-layer {
727+
background: white;
728+
.fav-icon {
729+
visibility: hidden;
730+
}
731+
&.valid-tab {
732+
background: transparent;
733+
.fav-icon {
734+
visibility: visible;
735+
}
736+
}
737+
}
738+
}
739+
740+
&.single-tab-selected {
741+
//all tabs are hidden except for first tab
742+
.tab-layer {
743+
background: white !important;
744+
.fav-icon {
745+
visibility: hidden !important;
746+
}
747+
748+
&.tab-layer-1 {
749+
background: transparent !important;
750+
.fav-icon {
751+
visibility: visible !important;
752+
}
753+
}
754+
}
755+
}
756+
}
757+
701758
//mixin for layout sprites
702759
.selector-url(@x:0, @y:0){
703760
background: url('../images/sprites/layouts.png') @x @y;
704761
}
705762

706-
707763
.layout-1x1 {
708764
.selector-url(0px,0px);
765+
766+
.tab-layer {
767+
width: 100%;
768+
height: 100%;
769+
770+
.fav-icon {
771+
left: 35px;
772+
top: 35px;
773+
}
774+
}
709775
}
710776

711777
.layout-1x2 {
712778
.selector-url(-100px,0px);
779+
780+
.tab-layer {
781+
width: 50%;
782+
height: 100%;
783+
784+
.fav-icon {
785+
left: 11px;
786+
top: 35px;
787+
}
788+
}
789+
713790
}
714791

715792
.layout-1x3 {
716793
.selector-url(-200px,0px);
794+
795+
.tab-layer {
796+
width: 33.3%;
797+
height: 100%;
798+
799+
.fav-icon {
800+
left: 8px;
801+
top: 39px;
802+
width: 18px !important;
803+
height: 18px !important;
804+
background-size: 18px 18px !important;
805+
}
806+
}
807+
717808
}
718809

719810
.layout-2x1 {
720811
.selector-url(-300px,0px);
812+
813+
.tab-layer {
814+
width: 100%;
815+
height: 50%;
816+
817+
.fav-icon {
818+
left: 35px;
819+
top: 16px;
820+
}
821+
}
822+
721823
}
722824

723825
.layout-2x2 {
724826
.selector-url(-400px,0px);
827+
828+
.tab-layer {
829+
width: 50%;
830+
height: 50%;
831+
832+
.fav-icon {
833+
top: 16px;
834+
left: 11px;
835+
}
836+
}
837+
725838
}
726839

727840
.layout-3x1 {
728841
.selector-url(-500px,0px);
842+
843+
.tab-layer {
844+
width: 100%;
845+
height: 33.3%;
846+
847+
.fav-icon {
848+
top: 12px;
849+
left: 42px;
850+
width: 18px !important;
851+
height: 18px !important;
852+
background-size: 18px 18px !important;
853+
}
854+
}
855+
729856
}
730857

731858
.layout-default{
732859
.selector-url(-600px,0px);
860+
861+
.tab-layer {
862+
display: none !important;
863+
}
733864
}

js/background.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,12 @@ var util = {
9494

9595
// base case we update the current window
9696
if(x === 0 && y === 0){
97-
if(resize.numRows === 1 && resize.numCols === 1){
98-
window.chrome.windows.update(_tabsArray[index].windowId,{ state: "maximized" });
99-
} else {
100-
window.chrome.windows.update(_tabsArray[index].windowId,{ left: leftValue,
101-
top: rightValue,
102-
width: resize.width,
103-
height: resize.height,
104-
state: "normal"
105-
});
106-
}
97+
window.chrome.windows.update(_tabsArray[index].windowId,{ left: leftValue,
98+
top: rightValue,
99+
width: resize.width,
100+
height: resize.height,
101+
state: "normal"
102+
});
107103

108104
if(singleTab){
109105
return;
@@ -142,9 +138,7 @@ var util = {
142138
*/
143139
setUndoStorage: function(resize, tabIndex, windowId, tabsArray, cb) {
144140
window.chrome.windows.get(windowId,{},function(_windowCb){
145-
var updateInfo = (_windowCb.state === 'maximized') ? {focused: true,
146-
state: "maximized",
147-
incognito: _windowCb.incognito} : {left: _windowCb.left,
141+
var updateInfo = {left: _windowCb.left,
148142
top: _windowCb.top,
149143
width: _windowCb.width,
150144
height: _windowCb.height,

js/custom_view.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
} else {
5050
var layoutType = customRows + 'x' + customCols;
5151
resize.layout.addLayout(layoutType);
52+
resize.layout.processTabInfo($('.layout-' + layoutType));
5253
this.hideCustomMenu();
5354
}
5455
}

js/display.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
var currentWindowInfo = {
4242
left: windowInfo.left + windowInfo.width - 100,
4343
top: windowInfo.top + 100
44-
}
44+
};
4545

4646
var displayJSON = processInfo(displayInfo,currentWindowInfo),
4747
template,
@@ -55,6 +55,9 @@
5555
$el.append(template);
5656
}
5757
//need to start building the dom display
58+
resize.currentWindowTabs = windowInfo.tabs;
59+
resize.layout.processTabInfo();
60+
5861
});
5962
});
6063

@@ -149,7 +152,7 @@
149152
if(currentWindowInfo.left > info.workArea.left && currentWindowInfo.left < info.workArea.left + info.workArea.width && currentWindowInfo.top > info.workArea.top && currentWindowInfo.top < info.workArea.top + info.workArea.height){
150153
displayJSON.primaryIndex = index;
151154
}
152-
155+
153156
}
154157
return displayJSON;
155158
}

js/layout.js

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,79 @@
7979
localStorage.setItem('layoutItems',JSON.stringify(resize.defaultLayouts));
8080
resize.currentLayouts = $.extend(true,{},resize.defaultLayouts);
8181
resize.main_view.populateMainView();
82+
this.processTabInfo();
8283
},
8384

8485
/**
8586
* removes all current layouts
8687
*/
8788
_removeAllLayouts: function() {
8889
$('.resize-container').children().remove();
89-
}
90+
},
9091

92+
processTabInfo: function($layout){
93+
var tabs = resize.currentWindowTabs;
94+
var layoutList = $layout || $('.resize-container').find('.resize-selector-container .resize-selector'),
95+
length = 0,
96+
index = 0,
97+
$curLayout,
98+
layoutType,
99+
rows,
100+
cols,
101+
innerHtml,
102+
curTab,
103+
tabNumber;
104+
105+
layoutList = layoutList.filter(function(){
106+
return !$(this).hasClass('layout-default');
107+
});
108+
109+
length = layoutList.length;
110+
111+
if(tabs && tabs.length > 0){
112+
//iterate through the current list of layout options
113+
for(;index<length;index++){
114+
innerHtml = '';
115+
$curLayout = layoutList.eq(index);
116+
layoutType = $curLayout.attr('data-selector-type').split('x');
117+
rows = layoutType[0];
118+
cols = layoutType[1];
119+
tabNumber = 1;
120+
for(var y=0; y<rows; y++){
121+
for(var x=0; x<cols; x++){
122+
//add in markup - styles will be added in less
123+
innerHtml += '<div title="New Tab" class="tab-layer tab-layer-'+ (tabNumber++) + '"><div class="fav-icon"></div></div>';
124+
}
125+
}
126+
$curLayout.html(innerHtml);
127+
}
128+
129+
//find the selected and add the urls
130+
for(index=0;index<tabs.length;index++){
131+
curTab = tabs[index];
132+
if(curTab.highlighted){
133+
processSelectedTab(curTab,index,tabs);
134+
break;
135+
}
136+
}
137+
}
138+
}
91139
};
92140

141+
function processSelectedTab(curTab,index,tabs){
142+
for(var i=1;index<tabs.length && i<5;index++,i++){
143+
curTab = tabs[index];
144+
if(curTab.favIconUrl){
145+
var tabLayers = $('.resize-container').find('.tab-layer-' + i);
146+
tabLayers.addClass('valid-tab');
147+
for(var j=0;j<tabLayers.length; j++){
148+
tabLayers.eq(j).find('.fav-icon').css('background-image','url("' + curTab.favIconUrl + '")');
149+
tabLayers.eq(j).attr('title',curTab.title);
150+
}
151+
}
152+
}
153+
}
154+
93155
window.resize.layout = layout;
94156

95157
})();

js/main_view.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
if(singleTabValue && singleTabValue === 'true'){
2626
$('#checkbox-single-tab').attr('checked',true);
2727
$('label.single-tab').addClass('selected');
28+
$('body').addClass('single-tab-selected');
2829
resize.singleTab = true;
2930
}
3031

@@ -34,6 +35,8 @@
3435
$('#checkbox-empty-tab').attr('checked',true);
3536
$('label.empty-tab').addClass('selected');
3637
resize.emptyTab = true;
38+
} else {
39+
$('body').addClass('empty-tab-not-selected');
3740
}
3841

3942
var displayLayerValue = localStorage.getItem('displayLayer');
@@ -47,9 +50,13 @@
4750
resize.alignment = 'left';
4851
} else {
4952
resize.alignment = alignmentValue;
53+
if(resize.alignment !== 'left'){
54+
$('body').addClass('align-right');
55+
}
5056
}
5157
$('#' + resize.alignment).trigger('click',['defer-tracking']);
5258

59+
5360
resize.displayUtil.initialize();
5461

5562
if(localStorage.getItem('lastTab')){

js/options.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
localStorage.setItem('singleTab',_singleTab);
2121
resize.singleTab = _singleTab;
2222
$('label.single-tab').toggleClass('selected');
23+
$('body').toggleClass('single-tab-selected');
2324
},
2425

2526
/*
@@ -35,6 +36,7 @@
3536
localStorage.setItem('emptyTab',_emptyTab);
3637
resize.emptyTab = _emptyTab;
3738
$('label.empty-tab').toggleClass('selected');
39+
$('body').toggleClass('empty-tab-not-selected');
3840
},
3941

4042
/**
@@ -54,6 +56,11 @@
5456
processAlignmentSelection: function(alignment) {
5557
localStorage.setItem('alignment',alignment);
5658
resize.alignment = alignment;
59+
if(alignment === 'right'){
60+
$('body').addClass('align-right');
61+
} else {
62+
$('body').removeClass('align-right');
63+
}
5764
},
5865

5966
/*

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Tab Resize - split screen layouts",
33
"short_name": "Tab Resize",
4-
"version": "2.0.7.10",
4+
"version": "2.0.8",
55
"manifest_version": 2,
66
"description": "Split Screen made easy. Resize the CURRENT tab and tabs to the RIGHT into layouts on separate windows. w/ Multi Monitor Support.",
77
"browser_action": {

0 commit comments

Comments
 (0)