Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit 54f1d43

Browse files
committed
#8: Use real device width
1 parent 6116a79 commit 54f1d43

File tree

5 files changed

+111
-97
lines changed

5 files changed

+111
-97
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
v1.2.0 (2013/09/27)
44

55
* Upgrade jQuery to 1.10.2 and 2.0.3
6-
* Add new device (LG Nexus 4)
6+
* Add new devices (LG Nexus 4, Samsung Y, Samsung S)
77
* Extend the width of preview 15px (scroll bar width)
88
* Remove screenshot feature
9+
* [#8] Use real device width
910

1011
v1.1.1 (2013/08/22)
1112

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ If you want it to support more devices and screen resolutions, please fork the p
1515

1616
**Nguyen Huu Phuoc** ([Email](mailto: [email protected]) / [Twitter](http://twitter.com/nghuuphuoc) / [Github](http://github.com/nghuuphuoc))
1717

18+
Big thanks to the contributors:
19+
20+
* [michaseel](https://github.com/michaseel)
21+
1822
## License
1923

2024
Copyright (c) 2013 Nguyen Huu Phuoc

app/js/responsivetest.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ angular
4141
}
4242
template += '<li class="dropdown-header" ng-mouseover="toggleBrand(' + i + ')">' + brands[i].name + '</li>';
4343
for (var j in brands[i].devices) {
44-
template += '<li ng-show="openStatus[' + i + ']"><a href="javascript: void(0);" ng-click="$parent.resizeTo(' + brands[i].devices[j].w + ', ' + brands[i].devices[j].h + ')">' + brands[i].devices[j].name;
44+
var pixelDestiny = brands[i].devices[j].pxd ? brands[i].devices[j].pxd : 1;
45+
template += '<li ng-show="openStatus[' + i + ']"><a href="javascript: void(0);" ng-click="$parent.resizeTo(' + brands[i].devices[j].w + ', ' + brands[i].devices[j].h + ', ' + pixelDestiny + ')">' + brands[i].devices[j].name;
4546

4647
if (brands[i].devices[j].inch) {
4748
template += ' <small></small><span>' + brands[i].devices[j].inch + '"</span>';
@@ -64,8 +65,8 @@ angular
6465
var parent = $scope.$parent;
6566
$element.resizable({
6667
resize: function(event, ui) {
67-
$scope.w = ui.size.width;
68-
$scope.h = ui.size.height;
68+
$scope.w = ui.size.width * $scope.pxd;
69+
$scope.h = ui.size.height * $scope.pxd;
6970
parent.$apply();
7071
}
7172
});
@@ -105,6 +106,10 @@ angular
105106
$scope.loading = true;
106107
$scope.w = 1024;
107108
$scope.h = 768;
109+
110+
// Pixel destiny
111+
// See http://screensiz.es
112+
$scope.pxd = 1;
108113
$scope.url = null;
109114
$scope.frameSrc = null;
110115

@@ -125,6 +130,7 @@ angular
125130
$scope.url = array[0];
126131
$scope.w = array[1];
127132
$scope.h = array[2];
133+
$scope.pxd = array.length > 3 ? array[3] : 1;
128134
}
129135
} else {
130136
// Get the random URL
@@ -157,10 +163,12 @@ angular
157163
* Switch to given size
158164
* @param {int} width
159165
* @param {int} height
166+
* @param {int} pixelDestiny
160167
*/
161-
$scope.resizeTo = function(width, height) {
162-
$scope.w = width;
163-
$scope.h = height;
168+
$scope.resizeTo = function(width, height, pixelDestiny) {
169+
$scope.w = width;
170+
$scope.h = height;
171+
$scope.pxd = pixelDestiny;
164172
};
165173

166174
/**
@@ -194,7 +202,7 @@ angular
194202
$scope.updateHash = function() {
195203
if ($scope.w && $scope.h && $scope.url) {
196204
// Update the location hash
197-
window.location.hash = '#u=' + [$scope.url, $scope.w, $scope.h].join('|');
205+
window.location.hash = '#u=' + [$scope.url, $scope.w, $scope.h, $scope.pxd].join('|');
198206
}
199207
};
200208
});

0 commit comments

Comments
 (0)