Skip to content

Commit

Permalink
half way to working acard directive
Browse files Browse the repository at this point in the history
  • Loading branch information
abarnhard committed Oct 12, 2014
1 parent e6669b5 commit e722e05
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 56 deletions.
1 change: 1 addition & 0 deletions client/components/directives/ab-acard/ab-acard.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{atext}}
56 changes: 56 additions & 0 deletions client/components/directives/ab-acard/ab-acard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function(){
'use strict';

angular.module('abAnswerModule', [])
.directive('abAcard', [function(){
var o = {};
o.restrict = 'A';
o.scope = {atext:'@', playNum:'@'};

o.link = function(scope, element, attrs){
var css = {
position: 'absolute',
display: 'none',
//top: -10000,
//left: -10000,
top: 0,
left: 0,
color: '#111111',
width: '144px',
height: 'auto',
//height: '211px',
// float: 'left',
padding: '10px',
margin: '5px'
};
css['word-wrap'] = 'break-word';
css['background-color'] = '#FFFFFF';
css['font-size'] = '15px';
css['font-weight'] = 800;
css['border-radius'] = '15px';
css['-moz-border-radius'] = '15px';
css['border-width'] = '1px';
css['border-style'] = 'solid';
css['border-color'] = '#777';
// css['-webkit-box-shadow'] = '0 0 8px #D0D0D0';

var $shadow = angular.element('<div></div>').css(css).text(attrs.atext);
angular.element(document.body).append($shadow);

var height = $shadow.css('height'),
fsize = $shadow.css('font-size');
console.log(height, fsize);
// element.css({height:'10px'});
scope.$watch('attrs.playNum', function(newVal, oldVal){
scope.pick = attrs.playNum * 1;
});

scope.$on('$destroy', function(){
$shadow.remove();
});
};

return o;
}]);

})();
36 changes: 36 additions & 0 deletions client/components/directives/ab-acard/ab-acard.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@BLACK: #111111;
@WHITE: #FFFFFF;

div[ab-acard] {
display: inline-block;
//position: relative;

word-wrap: break-word;

background-color: @WHITE;
color: @BLACK;

width: 144px;
height: 211px;
// float: left;

padding: 10px;
margin: 5px;

font-size: 15px;
font-weight: 800;

border-radius: 15px;
-moz-border-radius: 15px;
border-width: 1px;
border-style: solid;
border-color: #777;
-webkit-box-shadow: 0 0 8px #D0D0D0;

}

div[ab-acard]:hover {
position: relative;
top: -5px;
}

2 changes: 2 additions & 0 deletions client/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ html(ng-app='mean-ah', lang='en')
link(href='/views/results/results.css', rel='stylesheet')
link(href='/components/directives/ab-player/ab-player.css', rel='stylesheet')
link(href='/components/directives/ab-qcard/ab-qcard.css', rel='stylesheet')
link(href='/components/directives/ab-acard/ab-acard.css', rel='stylesheet')
//- Load angular in head to support ng-cloak directive on nav bar
script(src='/vendor/jquery/dist/jquery.js')
script(src='/vendor/angular/angular.js')
Expand Down Expand Up @@ -62,4 +63,5 @@ html(ng-app='mean-ah', lang='en')
script(src='/components/factories/game.js')
script(src='/components/directives/ab-player/ab-player.js')
script(src='/components/directives/ab-qcard/ab-qcard.js')
script(src='/components/directives/ab-acard/ab-acard.js')

2 changes: 1 addition & 1 deletion client/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(){
'use strict';

angular.module('mean-ah', ['ngRoute', 'LocalForageModule', 'abPlayerModule', 'abQuestionModule'])
angular.module('mean-ah', ['ngRoute', 'LocalForageModule', 'abPlayerModule', 'abQuestionModule', 'abAnswerModule'])
.config(['$routeProvider', '$httpProvider', '$localForageProvider', function($routeProvider, $httpProvider, $localForageProvider){
$routeProvider
.when('/', {templateUrl:'/views/home/home.html', controller:'HomeCtrl'})
Expand Down
4 changes: 3 additions & 1 deletion client/views/games/games.jade
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
.row
.col-xs-12
button.btn.btn-default.btn-overide(type='button', ng-show='game.isOwner && game.isOpen', ng-click='startGame(game._id)') Start Game
| &nbsp;
button.btn.btn-default.btn-overide(type='button', ng-click='leaveGame(game._id)') Leave Game
| &nbsp;
button.btn.btn-default.btn-overide(type='button', ng-click='voteGameEnd(game._id)') Vote To End Game
h3 Game: {{game.name}}
.row
Expand Down Expand Up @@ -38,7 +40,7 @@
.row
.col-xs-12
.hand
.card(ng-repeat='card in game.hand', ng-click='selectAnswer(card)') {{card.text}}
div(ab-acard, atext='{{card.text}}', playNum='0', ng-repeat='card in game.hand', ng-click='selectAnswer(card)') {{card.text}}
.row
.col-xs-12
.play-hand
Expand Down
54 changes: 0 additions & 54 deletions client/views/games/games.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,3 @@
text-align: center;
}

.card {
display: inline-block;
margin: 5px;
border: 1px solid black;
}

.card {
word-wrap: break-word;

width: 144px;
height: 211px;
float: left;

padding: 10px;
margin: 5px;

font-size: 11pt;
font-weight: 800;

border-radius: 15px;
-moz-border-radius: 15px;
border-width: 1px;
border-style: solid;
border-color: #777;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}

.card:hover {
position: relative;
top: -5px;
}

.black_card {
background-color: black;
background: #282828;
background: -moz-linear-gradient(top, #282828 0%, black 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#282828), color-stop(100%,black));
background: -webkit-linear-gradient(top, #282828 0%,black 100%);
background: -o-linear-gradient(top, #282828 0%,black 100%);
background: -ms-linear-gradient(top, #282828 0%,black 100%);
color: white;
}

.white_card {
background-color:white;
background: white;
background: -moz-linear-gradient(top, white 0%, #A0A0A0 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,white), color-stop(100%,#A0A0A0));
background: -webkit-linear-gradient(top, white 0%,#A0A0A0 100%);
background: -o-linear-gradient(top, white 0%,#A0A0A0 100%);
background: -ms-linear-gradient(top, white 0%,#A0A0A0 100%);
color: black;
}

0 comments on commit e722e05

Please sign in to comment.