diff --git a/app/components/subscribe-to.js b/app/components/subscribe-to.js new file mode 100644 index 0000000..962025b --- /dev/null +++ b/app/components/subscribe-to.js @@ -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'); + } + } + } +}); diff --git a/app/controllers/job.js b/app/controllers/job.js index eb6a61a..c49c1b8 100644 --- a/app/controllers/job.js +++ b/app/controllers/job.js @@ -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") +}); diff --git a/app/controllers/jobs.js b/app/controllers/jobs.js index dcee46a..571f926 100644 --- a/app/controllers/jobs.js +++ b/app/controllers/jobs.js @@ -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); diff --git a/app/styles/items.scss b/app/styles/items.scss index 64ea735..1b83f96 100644 --- a/app/styles/items.scss +++ b/app/styles/items.scss @@ -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 { diff --git a/app/templates/components/subscribe-to.hbs b/app/templates/components/subscribe-to.hbs new file mode 100644 index 0000000..4f417b8 --- /dev/null +++ b/app/templates/components/subscribe-to.hbs @@ -0,0 +1,7 @@ +
diff --git a/app/templates/job.hbs b/app/templates/job.hbs index b3628cd..e190971 100644 --- a/app/templates/job.hbs +++ b/app/templates/job.hbs @@ -33,10 +33,7 @@