Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions app/components/subscribe-to.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Ember from 'ember';

export default Ember.Component.extend({
actions: {
subscribe: function() {
var that = this;

var email = this.get("subscribeEmail");
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

if (re.test(email)) {
$('.error').removeClass('show').addClass('hide');
$('.success').removeClass('hide').addClass('show');

if(localStorage.subscribeEmail === undefined) {
var subscribeEmail = [];
var lastEmail = {'id': 1,'email': email};
} else {
var subscribeEmail = JSON.parse(localStorage.subscribeEmail);
var arrayLength = subscribeEmail.length;
var lastEmail = {'id': ++arrayLength,'email': email};
}

subscribeEmail.push(lastEmail);
localStorage.subscribeEmail = JSON.stringify(subscribeEmail)

setTimeout(function() {
that.set('subscribeEmail', '');
$('.success').removeClass('show').addClass('hide');
}, 1000);

} else {
$('.error').removeClass('hide').addClass('show');
}
}
}
});
52 changes: 51 additions & 1 deletion app/controllers/job.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
import Ember from 'ember';

export default Ember.ObjectController.extend();
export default Ember.ObjectController.extend({
needs: ['jobs'],

getJobs: function() {
var that = this;

var jobs = this.store.find('jobs')
.then(function(data) {
that.set("jobs", data);

var jobsLength = that.get("jobs.length"),
currentJob = parseInt(that.get("id")),
nextJob = currentJob+1,
prevJob = currentJob-1;

that.get('jobs')
.forEach(function (job, index) {

if(++index === currentJob){

if(index < jobsLength){
that.set("nextPage", nextJob);
} else {
that.set("nextPage", false);
}

if(index > 0){
that.set("prevPage", prevJob);
} else {
that.set("prevPage", false);
}

}

});

});
}.observes("model").on("init"),

prevJob : function() {
if (this.get("prevPage") !== undefined) {
return this.store.find("jobs", this.get("prevPage"));
}
}.property("prevPage"),

nextJob : function() {
if (this.get("nextPage") !== undefined) {
return this.store.find("jobs", this.get("nextPage"));
}
}.property("nextPage")
});
1 change: 0 additions & 1 deletion app/controllers/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default Ember.ArrayController.extend({

filteredContent: function(){
var filterPrice = this.get('filterPrice');

var selectedCity = this.get('selectedCity.city');
var city = this.get('arrangedContent');
var rx = new RegExp(selectedCity);
Expand Down
7 changes: 7 additions & 0 deletions app/styles/items.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ button:hover {
}
}

.hide { display: none; }
.show { display: block; }

.messages { padding: 10px; margin-bottom: 20px; font-size: 18px; }
.error { background: #ffb4ad; color: #fff;}
.success { background: #E9F5DE; }

@media (max-width: 768px) {
.on-email--blog,
.add-job a {
Expand Down
7 changes: 7 additions & 0 deletions app/templates/components/subscribe-to.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<form>
<div class="messages error hide">Error!</div>
<div class="messages success hide">Success!</div>

{{input type="text" classNames='my-email' value=subscribeEmail placeholder="ваш email"}}
<button {{action 'subscribe'}}>Підписатись</button>
</form>
5 changes: 1 addition & 4 deletions app/templates/job.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
<div class="col-xs-12 col-sm-4">
<div class="on-email">
<div class="on-email_label">Нові вакансії на email</div>
<form>
<input type="text" placeholder="ваш email">
<button>Підписатись</button>
</form>
{{subscribe-to}}
</div>

<div class="add-job">
Expand Down
6 changes: 2 additions & 4 deletions app/templates/jobs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<div class="items">
<h2>{{#link-to 'job' this classNames="items-title" }}{{title}}{{/link-to}}</h2>

<div class="items-title-bottom">
<a>{{city}}</a>
<span>{{price}} $</span>
Expand All @@ -49,10 +50,7 @@
<div class="col-xs-12 col-sm-4">
<div class="on-email">
<div class="on-email_label">Нові вакансії на email</div>
<form>
<input type="text" placeholder="ваш email">
<button>Підписатись</button>
</form>
{{subscribe-to}}
</div>

<div class="add-job">
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"ember-data": "1.0.0-beta.12",
"ember-export-application-global": "^1.0.0",
"ember-flex-grid": "0.0.2",
"ember-localstorage-adapter": "^0.5.2",
"express": "^4.8.5",
"glob": "^4.0.5",
"rimraf": "2.2.8"
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/components/subscribe-to-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
moduleForComponent,
test
} from 'ember-qunit';

moduleForComponent('subscribe-to', 'SubscribeToComponent', {
// specify the other units that are required for this test
// needs: ['component:foo', 'helper:bar']
});

test('it renders', function() {
expect(2);

// creates the component instance
var component = this.subject();
equal(component._state, 'preRender');

// appends the component to the page
this.append();
equal(component._state, 'inDOM');
});