Skip to content

Commit

Permalink
introduced reasons why shopping online for clothes sucks to demonstra…
Browse files Browse the repository at this point in the history
…te easy refactoring
  • Loading branch information
Arush Sehgal committed Oct 11, 2013
1 parent 38ed4a4 commit b94a6aa
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 44 deletions.
47 changes: 45 additions & 2 deletions client/app/scripts/controllers/master-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,52 @@ angular.module('demo')

$scope.createMonster = function() {
// new up the model
$scope.masterDetailCtrl.collection.addMonster('Joe', 'exploding feces').then(function() {

alert('OMG you created a monster named: ' + $scope.masterDetailCtrl.collection.first().get('name'));
var f1Drivers = [
'Sebastian Vettel',
'Fernando Alonso',
'Kimi Raikkonen',
'Lewis Hamilton',
'Mark Webber',
'Nico Rosberg',
'Felipe Massa',
'Romain Grosjean',
'Jenson Button',
'Paul di Resta',
'Nico Hulkenberg',
'Adrian Sutil',
'Sergio Perez',
'Daniel Ricciardo',
'Jean-Eric Vergne',
'Pastor Maldonado',
'Esteban Gutierrez',
'Valtteri Bottas',
'Jules Bianchi',
'Charles Pic',
];

var reasons = [
'Because what the hell is a: "through button bias cut front and centre back box pleat with hanger loop, finished with mitred button cuffs, bias cut spade chest pocket, contrast lined back yoke and curved hem." - (bensherman.com)',
'On mobile? Forget about it',
'They know I\'m a dude, but they keep emailing me chicks shoes! WTF',
'I don\'t even wanna think about dealing with customer support or the lack thereof',
'I don\'t have to pay to try clothes on in a store, so why do I have to pay to try 2 different sizes online?',
'Because I know I\'m gonna get screwed with the returns',
'Paid $80 for a shirt that doesn\'t fit because I lost the returns form',
'Missed the returns window? Fuck you very much.',
'Because they\'re banking on me to screw up the returns',
'"Oh sorry sir, didn\'t you read the terms?"',
'What happens if it doesn\'t fit?',
'Why pay for shipping when I can go to the mall?'
];

var randomNumber = Math.floor(Math.random()*f1Drivers.length);

var randomNumber2 = Math.floor(Math.random()*reasons.length);

$scope.masterDetailCtrl.collection.addMonster(f1Drivers[randomNumber], reasons[randomNumber2]).then(function() {

alert('You created a new object for: ' + $scope.masterDetailCtrl.collection.first().get('name'));

});

Expand Down
18 changes: 12 additions & 6 deletions client/app/scripts/modules/data/Monsters.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ angular.module('ExternalDataServices')
this.set('name',name);
return this;
},
setScaryMove: function(move) {
this.set('scaryMove',move);
setReason: function(reason) {
this.set('reason', reason);
return this;
},
getName: function(name) {
return this.get('name');
},
getReason: function(reason) {
return this.get('reason');
},
destroyParse:function(){
return ParseQueryAngular(this,{functionToCall:"destroy"});
}
Expand All @@ -24,19 +30,19 @@ angular.module('ExternalDataServices')
comparator: function(model) {
return -model.createdAt.getTime();
},
loadMonstersWithMove: function(move) {
loadMonstersWithName: function(name) {
this.query = (new Parse.Query(Monster));

this.query.equalTo('name', name);
// use the enhanced load() function to fetch the collection
return this.load();
},
addMonster: function(name, move) {
addMonster: function(name, reason) {
// save request_id to Parse
var _this = this;

var monster = new Monster;
monster.setName(name);
monster.setScaryMove(move);
monster.setReason(reason);

// use the extended Parse SDK to perform a save and return the promised object back into the Angular world
return monster.saveParse().then(function(data){
Expand Down
10 changes: 5 additions & 5 deletions client/app/scripts/modules/directives/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ angular.module('forms', [])

scope.editedMonster = {
name: null,
scaryMove: null
reason: null
}

scope.$watch('monsterToSave.attributes.name', function(name) {
scope.editedMonster.name = name;

})

scope.$watch('monsterToSave.attributes.scaryMove', function(scaryMove) {
scope.editedMonster.scaryMove = scaryMove;
scope.$watch('monsterToSave.attributes.reason', function(reason) {
scope.editedMonster.reason = reason;

})

Expand All @@ -37,13 +37,13 @@ angular.module('forms', [])

// put the form in a loading state
var loadingContainer = $('#loadingContainer');
addLoaderTo(loadingContainer, 'savingForm', 'Saving Monster');
addLoaderTo(loadingContainer, 'savingForm', 'Saving');
element.find('button').attr('disabled','disabled');


// set the new attributes
scope.monsterToSave.setName(scope.editedMonster.name);
scope.monsterToSave.setScaryMove(scope.editedMonster.scaryMove);
scope.monsterToSave.setReason(scope.editedMonster.reason);


// perform the save
Expand Down
8 changes: 4 additions & 4 deletions client/app/views/detail/about.list.bootstrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Back
</a>

<h1 class="human title">SASS Twitter Bootstrap</h1>
<h1 class="human title">Sass Bootstrap</h1>

</div>

Expand All @@ -19,18 +19,18 @@ <h1 class="punchy muted light-text-shadow"><i class="icon icon-twitter small-rig
<div class="row-fluid white-back withShadow withRadius width-padding top-padding bottom-padding center-align">


<div class="row-fluid" >
<div class="row-fluid">
<div class="row-fluid bottom-margin">
<div class="row-fluid center-align">
<h4 class="punchy">Because who actually uses LESS?</h4>
<h4 class="punchy">Sass Bootstrap 2.3.2</h4>

</div>

</div>

</div>
<div class="row-fluid left-align muted">
<span class="muted">We use <a href="https://github.com/thomas-mcdonald/bootstrap-sass">sass-bootstrap</a> which is just a version of Bootstrap converted to SASS. </span>
<span class="muted">We use <a href="https://github.com/thomas-mcdonald/bootstrap-sass">sass-bootstrap</a> which is, believe it or not, Bootstrap converted to Sass.</span>
</div>


Expand Down
6 changes: 3 additions & 3 deletions client/app/views/detail/crud.detail.edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Back
</a>

<h1 class="human title">Edit Monster</h1>
<h1 class="human title">Edit</h1>

</div>

Expand All @@ -30,9 +30,9 @@ <h1 class="punchy muted light-text-shadow"><i class="icon icon-user small-right-
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Special Move</label>
<label class="control-label" for="inputPassword">Reason</label>
<div class="controls">
<input style="width:97%" type="text" ng-model="editedMonster.scaryMove" required>
<input style="width:97%" type="text" ng-model="editedMonster.reason" required>
</div>
</div>
<div class="control-group">
Expand Down
10 changes: 5 additions & 5 deletions client/app/views/detail/crud.detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<i class="icon icon-th-list small-right-margin "></i>List
</a>

<h1 class="human title">Monster Detail</h1>
<h1 class="human title">Detail</h1>

<a class="navi-button-main" href="#/crud/{{detailCtrl.current.id}}/edit">
Edit
Expand All @@ -26,8 +26,8 @@ <h1 class="punchy muted light-text-shadow"><i class="icon icon-user small-right-
<div class="row-fluid">
<div class="row-fluid">
<div class="row-fluid center-align">
<h4 class="punchy">Monster's Name</h4>
<span class="machine muted">{{detailCtrl.current.get('name')}}</span>
<h4 class="punchy">Name</h4>
<span class="machine muted">{{detailCtrl.current.getName()}}</span>
</div>

</div>
Expand All @@ -36,8 +36,8 @@ <h4 class="punchy">Monster's Name</h4>


<div class="horizontal-line full-fade top-margin bottom-margin"></div>
<h4 class="punchy">Scary Move</h4>
<span class="machine muted">{{detailCtrl.current.get('scaryMove')}}</span>
<h4 class="punchy">Reason</h4>
<span class="machine muted">{{detailCtrl.current.getReason()}}</span>
</div>

<div class="row-fluid top-margin">
Expand Down
44 changes: 25 additions & 19 deletions client/app/views/detail/crud.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ <h1 class="human title">CRUD</h1>
<div class="row-fluid">
<h1 class="human muted light-text-shadow"><i class="icon icon-cloud small-right-margin"></i></h1>
</div>
<div class="row-fluid bottom-margin">
<div class="row-fluid top-margin big-bottom-margin">
<div class="row-fluid center-align">
<span class="muted machine">Click the <i class="icon icon-plus-sign"></i> up top to create a new model!</span>
<span class="muted machine">Reasons why shopping online for clothes sucks</span>
</div>
</div>

Expand All @@ -27,31 +27,37 @@ <h1 class="human muted light-text-shadow"><i class="icon icon-cloud small-right-


<a href="#/crud/{{item.id}}"
class="block row-fluid top-padding bottom-padding relative light-border-bottom white-border-top line height-med"
class="block row-fluid top-padding bottom-padding relative light-border-bottom white-border-top"
ng-repeat="item in masterDetailCtrl.collection.models"
ng-animate="{ enter: 'waveForward-enter', leave: 'waveForward-leave' }"
>
<div class="span4 muted left-align">
<div class="med-width-padding">
<div class="pull-left small-right-margin">
<span class="machine bold">Monster:</span>
<div class="span90-10 muted">
<div class="row-fluid tiny-bottom-margin">
<div class="span20-80 right-align">
<span class="machine bold">Name:</span>
</div>
<div class="span80-20 left-align">
<div class="small-left-margin machine">{{item.getName()}}</div>
</div>
<div class="pull-left small-left-margin">
<span class="machine">{{item.get('name')}}</span>
</div>
</div>
</div>
<div class="span7 muted left-align">
<div class="med-width-padding clearfix">
<div class="pull-left small-right-margin">
<span class="machine bold">Scary Move:</span>

<div class="row-fluid">
<div class="span20-80 right-align">
<span class="machine bold">Reason:</span>
</div>
<div class="span80-20 left-align">
<span class="small-left-margin machine">{{item.getReason()}}</span>
</div>
<div class="pull-left small-left-margin">
<span class="machine">{{item.get('scaryMove')}}</span>
</div>
</div>

</div>

<div class="span10-90 muted center-align small-top-padding">
<div class="small-top-margin">
<i class="icon icon-chevron-right"></i>
</div>
</div>
<div class="span1 muted pull-right"><i class="icon icon-chevron-right"></i></div>

</a>

</div>
Expand Down

0 comments on commit b94a6aa

Please sign in to comment.