Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Yosemite style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhomes committed Oct 16, 2014
1 parent 4cc1685 commit 2ee0561
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 7 deletions.
1 change: 1 addition & 0 deletions radiant-player-mac/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
- (void) ratingChanged:(NSInteger)rating;

- (id) preferenceForKey:(NSString *)key;
- (BOOL) isYosemite;

- (void) evaluateJavaScriptFile:(NSString *)name;
- (void) applyCSSFile:(NSString *)name;
Expand Down
15 changes: 13 additions & 2 deletions radiant-player-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
object:nil
queue:nil
usingBlock:^(NSNotification *note) {
[webView stringByEvaluatingJavaScriptFromString:@"window.Styles.Callbacks.onEnterFullScreen();"];
[self hideToolbar];
}
];
Expand All @@ -87,7 +88,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
addObserverForName:NSWindowWillExitFullScreenNotification
object:nil
queue:nil
usingBlock:^(NSNotification *note) {
usingBlock:^(NSNotification *note) {
[webView stringByEvaluatingJavaScriptFromString:@"window.Styles.Callbacks.onExitFullScreen();"];
[self showToolbar];
}
];
Expand Down Expand Up @@ -766,6 +768,11 @@ - (id)preferenceForKey:(NSString *)key
else
return nil;
}

- (BOOL)isYosemite
{
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9;
}

- (void) evaluateJavaScriptFile:(NSString *)name
{
Expand Down Expand Up @@ -828,6 +835,9 @@ + (NSString *) webScriptNameForSelector:(SEL)sel
if (sel == @selector(preferenceForKey:))
return @"preferenceForKey";

if (sel == @selector(isYosemite))
return @"isYosemite";

return nil;
}

Expand All @@ -841,7 +851,8 @@ + (BOOL) isSelectorExcludedFromWebScript:(SEL)sel
sel == @selector(ratingChanged:) ||
sel == @selector(moveWindowWithDeltaX:andDeltaY:) ||
sel == @selector(showLastFmPopover:) ||
sel == @selector(preferenceForKey:))
sel == @selector(preferenceForKey:) ||
sel == @selector(isYosemite))
return NO;

return YES;
Expand Down
9 changes: 6 additions & 3 deletions radiant-player-mac/Styles/ApplicationStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ + (NSString *)jsNamed:(NSString *)name
}

+ (NSMutableDictionary *)styles
{
CocoaStyle *cocoa = [[CocoaStyle alloc] init];
{
DarkStyle *dark = [[DarkStyle alloc] init];
DarkFlatStyle *darkFlat = [[DarkFlatStyle alloc] init];
SpotifyBlackStyle *spotifyBlack = [[SpotifyBlackStyle alloc] init];

NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
[dictionary setObject:cocoa forKey:[cocoa name]];
[dictionary setObject:dark forKey:[dark name]];
[dictionary setObject:darkFlat forKey:[darkFlat name]];
[dictionary setObject:spotifyBlack forKey:[spotifyBlack name]];
Expand All @@ -83,6 +81,11 @@ + (NSMutableDictionary *)styles
SpotifyBlackVibrantStyle *spotifyBlackVibrant = [[SpotifyBlackVibrantStyle alloc] init];
[dictionary setObject:spotifyBlackVibrant forKey:[spotifyBlackVibrant name]];
}
else
{
CocoaStyle *cocoa = [[CocoaStyle alloc] init];
[dictionary setObject:cocoa forKey:[cocoa name]];
}

return dictionary;
}
Expand Down
5 changes: 5 additions & 0 deletions radiant-player-mac/js/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ if (typeof window.Styles === 'undefined') {
Styles.appliedStyles[key].parentNode.removeChild(Styles.appliedStyles[key]);
delete Styles.appliedStyles[key];
}
},

Callbacks: {
onEnterFullScreen: function() { },
onExitFullScreen: function() { }
}
};
}
8 changes: 8 additions & 0 deletions radiant-player-mac/js/styles/cocoa.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ if (typeof window.Styles.Applied === 'undefined') {
window.Styles.Applied = true;
window.Styles.Cocoa = true;

window.Styles.Callbacks.onEnterFullScreen = function() {

};

window.Styles.Callbacks.onExitFullScreen = function() {

};s

// Thumbs up and down styles.
(function() {
// Create dummy elements to get the computed styles for these elements.
Expand Down
18 changes: 17 additions & 1 deletion radiant-player-mac/js/styles/dark-flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ if (typeof window.Styles.Applied === 'undefined') {
window.Styles.Applied = true;
window.Styles.DarkFlat = true;

window.Styles.Callbacks.onEnterFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '65px', 'important');
el.style.setProperty('margin-right', '65px', 'important');
}
};

window.Styles.Callbacks.onExitFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '100px', 'important');
el.style.setProperty('margin-right', '30px', 'important');
}
};

// Thumbs up and down styles.
var mediaChange = (function(list) {
(function() {
Expand Down Expand Up @@ -43,7 +59,7 @@ if (typeof window.Styles.Applied === 'undefined') {

// Apply a new stylesheet for the new thumbs up and down positions.
thumbsUpBackY -= 9;
thumbsDownBackY -= 7;
thumbsDownBackY -= 6;

var thumbsUpPosition = thumbsUpBackX + 'px ' + thumbsUpBackY + 'px';
var thumbsDownPosition = thumbsDownBackX + 'px ' + thumbsDownBackY + 'px';
Expand Down
18 changes: 17 additions & 1 deletion radiant-player-mac/js/styles/dark.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ if (typeof window.Styles.Applied === 'undefined') {
window.Styles.Applied = true;
window.Styles.Dark = true;

window.Styles.Callbacks.onEnterFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '65px', 'important');
el.style.setProperty('margin-right', '65px', 'important');
}
};

window.Styles.Callbacks.onExitFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '100px', 'important');
el.style.setProperty('margin-right', '30px', 'important');
}
};

// Thumbs up and down styles.
var mediaChange = (function(list) {
(function() {
Expand Down Expand Up @@ -43,7 +59,7 @@ if (typeof window.Styles.Applied === 'undefined') {

// Apply a new stylesheet for the new thumbs up and down positions.
thumbsUpBackY -= 9;
thumbsDownBackY -= 7;
thumbsDownBackY -= 6;

var thumbsUpPosition = thumbsUpBackX + 'px ' + thumbsUpBackY + 'px';
var thumbsDownPosition = thumbsDownBackX + 'px ' + thumbsDownBackY + 'px';
Expand Down
16 changes: 16 additions & 0 deletions radiant-player-mac/js/styles/spotify-black.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ if (typeof window.Styles.Applied === 'undefined') {
window.Styles.Applied = true;
window.Styles.SpotifyBlack = true;

window.Styles.Callbacks.onEnterFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '65px', 'important');
el.style.setProperty('margin-right', '65px', 'important');
}
};

window.Styles.Callbacks.onExitFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '100px', 'important');
el.style.setProperty('margin-right', '30px', 'important');
}
};

// Thumbs up and down styles.
var mediaChange = (function(list) {
(function() {
Expand Down
16 changes: 16 additions & 0 deletions radiant-player-mac/js/styles/yosemite.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ if (typeof window.Styles.Applied === 'undefined') {
window.Styles.Applied = true;
window.Styles.Yosemite = true;

window.Styles.Callbacks.onEnterFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '30px', 'important');
el.style.setProperty('margin-right', '30px', 'important');
}
};

window.Styles.Callbacks.onExitFullScreen = function() {
if (window.GoogleMusicApp.isYosemite()) {
var el = document.querySelector('#oneGoogleWrapper > div:first-child > div:first-child > div:nth-child(2)');
el.style.setProperty('margin-left', '100px', 'important');
el.style.setProperty('margin-right', '30px', 'important');
}
};

// Thumbs up and down styles.
(function() {
// Create dummy elements to get the computed styles for these elements.
Expand Down

0 comments on commit 2ee0561

Please sign in to comment.