Skip to content

Commit 618db7e

Browse files
committed
Several printing fixes
- Closes #35 by renaming all sessionStorage to proper localStorage names - Closes #24 and added a lot of print options and styles - Also added gitignore files for VS
1 parent 14eebee commit 618db7e

File tree

5 files changed

+128
-184
lines changed

5 files changed

+128
-184
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ inc/config.php
77
# Ignore schedule images
88
img/schedules/*.png
99

10-
$ Ignore Eclipse files
10+
# Ignore Eclipse files
1111
.settings
1212
.project
1313
.buildpath
14+
15+
# Ignore VisualStudio files
16+
/*.phpproj*
17+
/*.sln
18+
/*.suo
19+
/WebEssentials-Settings.json

inc/footer.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<? } elseif($LAYOUT_MODE == 'print') { ?>
1414
<div id="print_footer">
1515
Made Using <a href='<?= $HTTPROOTADDRESS ?>'>CSH ScheduleMaker</a>
16-
<a href="http://www.csh.rit.edu/"><img src="/img/csh_print.png"></a>
16+
<a href="http://www.csh.rit.edu/"><img height="25" src="/img/csh_print.png"></a>
1717
</div>
1818

1919
<? } ?>

inc/global.css

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ body.print {
1414
overflow-y: auto;
1515
}
1616

17+
@media print{
18+
@page {
19+
size: auto;
20+
margin: auto;
21+
}
22+
23+
}
24+
1725
@-webkit-viewport { width: device-width; }
1826
@-moz-viewport { width: device-width; }
1927
@-ms-viewport { width: device-width; }
@@ -140,9 +148,10 @@ label {
140148
}
141149

142150
#print_footer {
143-
height:50px;
144-
text-align:center;
145-
line-height:50px;
151+
height: 50px;
152+
text-align: center;
153+
line-height: 50px;
154+
margin-top: -30px;
146155
}
147156

148157
#print_footer img {
@@ -153,6 +162,10 @@ label {
153162
color: #000;
154163
}
155164

165+
#print_header {
166+
margin: 0 0;
167+
}
168+
156169
input[type=text] {
157170
margin-top:0px;
158171
}
@@ -954,9 +967,35 @@ input {
954967
body.print div[schedule] > .panel {
955968
box-shadow: none;
956969
border: none;
957-
width: 720px;
970+
min-width: 720px;
958971
margin: 0 auto;
959972
}
973+
974+
body.print div[schedule].bow svg g[svg-schedule-item] rect,
975+
body.print div[schedule].gow svg g[svg-schedule-item] rect {
976+
fill: #FFFFFF !important;
977+
fill-opacity: 1 !important;
978+
stroke: #000;
979+
stroke-width: 1px;
980+
}
981+
982+
body.print div[schedule].gow svg g[svg-schedule-item] rect {
983+
stroke: #555;
984+
}
985+
986+
body.print div[schedule].bow text,
987+
body.print div[schedule].boc svg g[svg-schedule-item] text {
988+
fill: #000000 !important;
989+
}
990+
991+
body.print div[schedule].bow svg line {
992+
stroke: #000000 !important;
993+
}
994+
995+
body.print div[schedule].gow svg g[svg-schedule-item] text {
996+
fill: #333 !important;
997+
}
998+
960999
@media print {
9611000
body.print a[href]:after {
9621001
content: "";

js/app.js

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,47 +94,47 @@ app.filter("courseNum", function() {
9494
};
9595
});
9696

97-
app.factory("sessionStorage", function($window) {
97+
app.factory("localStorage", function($window) {
9898

99-
var sessionStorage = $window.localStorage;
99+
var localStorage = $window.localStorage;
100100

101101
return {
102102
setItem: function(key, value) {
103-
if(sessionStorage) {
103+
if(localStorage) {
104104
if(value != null) {
105-
sessionStorage.setItem(key, angular.toJson(value));
105+
localStorage.setItem(key, angular.toJson(value));
106106
} else {
107-
sessionStorage.setItem(key, null);
107+
localStorage.setItem(key, null);
108108
}
109109
} else {
110110
return false;
111111
}
112112
},
113113
getItem: function(key) {
114-
if(sessionStorage) {
115-
return angular.fromJson(sessionStorage.getItem(key));
114+
if(localStorage) {
115+
return angular.fromJson(localStorage.getItem(key));
116116
} else {
117117
return false;
118118
}
119119
},
120120
hasKey: function(key) {
121-
if(sessionStorage) {
122-
return sessionStorage.hasOwnProperty(key);
121+
if(localStorage) {
122+
return localStorage.hasOwnProperty(key);
123123
} else {
124124
return false;
125125
}
126126
},
127127
clear: function() {
128-
if(sessionStorage) {
129-
return sessionStorage.clear();
128+
if(localStorage) {
129+
return localStorage.clear();
130130
} else {
131131
return false;
132132
}
133133
},
134134
};
135135
});
136136

137-
app.controller("AppCtrl", function($scope, sessionStorage, $window, $filter) {
137+
app.controller("AppCtrl", function($scope, localStorage, $window, $filter) {
138138

139139
$scope.initState = function() {
140140
$scope.state = {};
@@ -179,7 +179,7 @@ app.controller("AppCtrl", function($scope, sessionStorage, $window, $filter) {
179179
};
180180

181181
$scope.saveState = function() {
182-
sessionStorage.setItem('state', $scope.state);
182+
localStorage.setItem('state', $scope.state);
183183
};
184184

185185
// Force save on close
@@ -188,11 +188,13 @@ app.controller("AppCtrl", function($scope, sessionStorage, $window, $filter) {
188188
};
189189

190190
$scope.noStateSaveOnUnload = function() {
191-
$window.onbeforeunload = null;
191+
$window.onbeforeunload = function() {
192+
//No-op
193+
};
192194
};
193195

194196
// Reload the state if it exists
195-
var storedState = sessionStorage.getItem('state');
197+
var storedState = localStorage.getItem('state');
196198
if(storedState != null) {
197199

198200
// Check if state version exists or is correct
@@ -249,9 +251,9 @@ app.controller("AppCtrl", function($scope, sessionStorage, $window, $filter) {
249251

250252
// The schedule was set as a global variable
251253
$scope.reloadSchedule($window.reloadSchedule);
252-
} else if(sessionStorage.hasKey('reloadSchedule')){
254+
} else if(localStorage.hasKey('reloadSchedule')){
253255
// Get the schedule from sessions storage
254-
var reloadSchedule = sessionStorage.getItem('reloadSchedule');
256+
var reloadSchedule = localStorage.getItem('reloadSchedule');
255257
if(reloadSchedule != null) {
256258
$scope.reloadSchedule(reloadSchedule);
257259
}
@@ -764,18 +766,18 @@ app.controller("AppCtrl", function($scope, sessionStorage, $window, $filter) {
764766
};
765767
});
766768

767-
app.controller("GenerateCtrl", function($scope, globalKbdShortcuts, $http, $filter, sessionStorage, uiDayFactory) {
769+
app.controller("GenerateCtrl", function($scope, globalKbdShortcuts, $http, $filter, localStorage, uiDayFactory) {
768770

769771

770772
//Check if we are forking a schedule
771-
if(sessionStorage.hasKey('forkSchedule')){
773+
if(localStorage.hasKey('forkSchedule')){
772774

773775
// Get the schedule from sessions storage
774-
var forkSchedule = sessionStorage.getItem('forkSchedule');
776+
var forkSchedule = localStorage.getItem('forkSchedule');
775777
if(forkSchedule != null) {
776778

777779
// Clear it so we don't fork again
778-
sessionStorage.setItem('forkSchedule', null);
780+
localStorage.setItem('forkSchedule', null);
779781

780782
var days = uiDayFactory();
781783

@@ -1538,7 +1540,7 @@ app.factory('shareServiceInfo', function() {
15381540
/**
15391541
* Several endpoint abstractions for the schedules
15401542
*/
1541-
app.directive('scheduleActions', function($http, $q, shareServiceInfo, openPopup, sessionStorage) {
1543+
app.directive('scheduleActions', function($http, $q, shareServiceInfo, openPopup, localStorage) {
15421544

15431545
var serializer = new XMLSerializer();
15441546

@@ -1609,7 +1611,7 @@ app.directive('scheduleActions', function($http, $q, shareServiceInfo, openPopup
16091611
});
16101612
} else {
16111613

1612-
sessionStorage.setItem('forkSchedule', scope.schedule);
1614+
localStorage.setItem('forkSchedule', scope.schedule);
16131615

16141616
window.location = "/generate.php";
16151617
}
@@ -1686,7 +1688,7 @@ app.directive('scheduleActions', function($http, $q, shareServiceInfo, openPopup
16861688

16871689
var popup = openPopup(780, 600);
16881690

1689-
popup.sessionStorage.setItem('reloadSchedule', angular.toJson(reloadSchedule));
1691+
popup.localStorage.setItem('reloadSchedule', angular.toJson(reloadSchedule));
16901692
popup.document.title = "My Schedule";
16911693
popup.location = "http://" + window.location.hostname + '/schedule/render/print';
16921694
}
@@ -1978,7 +1980,7 @@ app.controller("scheduleCtrl", function($scope, $location) {
19781980
});
19791981

19801982

1981-
app.controller("printScheduleCtrl", function($scope, $location, sessionStorage) {
1983+
app.controller("printScheduleCtrl", function($scope, $location, localStorage) {
19821984

19831985
if($scope.schedule) {
19841986
var pTerm ='' + $scope.state.requestOptions.term;
@@ -2004,11 +2006,27 @@ app.controller("printScheduleCtrl", function($scope, $location, sessionStorage)
20042006
}
20052007

20062008
$scope.heading = "My " + year + "-" + (year+1) + " " + term + " Schedule";
2009+
2010+
$scope.printTheme = 'woc';
2011+
2012+
$scope.printThemeOptions = [{
2013+
value: 'woc',
2014+
label: "Modern Colors"
2015+
}, {
2016+
value: 'bow',
2017+
label: "Classic B&W"
2018+
}, {
2019+
value: 'gow',
2020+
label: "Classic Greyscale"
2021+
}, {
2022+
value: 'boc',
2023+
label: "Black Text & Colors"
2024+
}];
20072025
}
20082026

20092027
$scope.noStateSaveOnUnload();
20102028

2011-
window.print();
2029+
$scope.print = window.print.bind(window);
20122030
});
20132031

20142032

0 commit comments

Comments
 (0)