Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Namespacing the start app

  • Loading branch information...
commit 5405c66235e5e555763498c3bcae587c60677fd2 1 parent 6d41cbb
@juanmaorta authored
View
145 app/app.js
@@ -1,80 +1,73 @@
-var candidate, displayAcademicInfo, displayIdInfo, displayPersonalInfo, displayProfesionalInfo, displayProjects, displayTechnicalSkills, printerView, renderView;
+var myApp;
-candidate = new Candidate();
+myApp = myApp || {};
-candidate.loadJSON(mycv);
-
-displayIdInfo = function(el, cand, append) {
- var template;
- if (append == null) append = false;
- if ((el != null) && (cand != null)) {
- template = $("#id_info").html();
- return renderView(template, el, cand, append);
- }
-};
-
-displayPersonalInfo = function(el, cand, append) {
- var template;
- if (append == null) append = false;
- if ((el != null) && (cand != null)) {
- template = $("#personal_info").html();
- return renderView(template, el, cand, append);
+myApp = {
+ displayIdInfo: function(el, cand, append) {
+ var template;
+ if (append == null) append = false;
+ if ((el != null) && (cand != null)) {
+ template = $("#id_info").html();
+ return this.renderView(template, el, cand, append);
+ }
+ },
+ displayPersonalInfo: function(el, cand, append) {
+ var template;
+ if (append == null) append = false;
+ if ((el != null) && (cand != null)) {
+ template = $("#personal_info").html();
+ return this.renderView(template, el, cand, append);
+ }
+ },
+ displayAcademicInfo: function(el, cand, append) {
+ var template;
+ if (append == null) append = false;
+ if ((el != null) && (cand != null)) {
+ template = $("#academic_info").html();
+ return this.renderView(template, el, cand, append);
+ }
+ },
+ displayProfesionalInfo: function(el, cand, append) {
+ var template;
+ if (append == null) append = false;
+ if ((el != null) && (cand != null)) {
+ template = $("#professional_info").html();
+ return this.renderView(template, el, cand, append);
+ }
+ },
+ displayTechnicalSkills: function(el, cand, append) {
+ var template;
+ if (append == null) append = false;
+ if ((el != null) && (cand != null)) {
+ template = $("#technical_skill_info").html();
+ return this.renderView(template, el, cand, append);
+ }
+ },
+ displayProjects: function(el, cand, append) {
+ var template;
+ if (append == null) append = false;
+ if ((el != null) && (cand != null)) {
+ template = $("#project_info").html();
+ return this.renderView(template, el, cand, append);
+ }
+ },
+ renderView: function(template, el, cand, append) {
+ var html;
+ if (append == null) append = false;
+ html = Mustache.to_html(template, cand);
+ if (append) {
+ return el.append(html);
+ } else {
+ return el.html(html);
+ }
+ },
+ printerView: function(el, cand) {
+ var append;
+ append = true;
+ this.displayPersonalInfo(el, cand);
+ this.displayAcademicInfo(el, cand, append);
+ this.displayProfesionalInfo(el, cand, append);
+ this.displayTechnicalSkills(el, cand, append);
+ return this.displayProjects(el, cand, append);
}
};
-
-displayAcademicInfo = function(el, cand, append) {
- var template;
- if (append == null) append = false;
- if ((el != null) && (cand != null)) {
- template = $("#academic_info").html();
- return renderView(template, el, cand, append);
- }
-};
-
-displayProfesionalInfo = function(el, cand, append) {
- var template;
- if (append == null) append = false;
- if ((el != null) && (cand != null)) {
- template = $("#professional_info").html();
- return renderView(template, el, cand, append);
- }
-};
-
-displayTechnicalSkills = function(el, cand, append) {
- var template;
- if (append == null) append = false;
- if ((el != null) && (cand != null)) {
- template = $("#technical_skill_info").html();
- return renderView(template, el, cand, append);
- }
-};
-
-displayProjects = function(el, cand, append) {
- var template;
- if (append == null) append = false;
- if ((el != null) && (cand != null)) {
- template = $("#project_info").html();
- return renderView(template, el, cand, append);
- }
-};
-
-renderView = function(template, el, cand, append) {
- var html;
- if (append == null) append = false;
- html = Mustache.to_html(template, cand);
- if (append) {
- return el.append(html);
- } else {
- return el.html(html);
- }
-};
-
-printerView = function(el, cand) {
- var append;
- append = true;
- displayPersonalInfo(el, cand);
- displayAcademicInfo(el, cand, append);
- displayProfesionalInfo(el, cand, append);
- displayTechnicalSkills(el, cand, append);
- return displayProjects(el, cand, append);
-};
View
2  app/mycv.json.js
@@ -105,7 +105,7 @@ mycv = {
}, {
name: "Naturapics",
url: "http://gallerie.naturapics.com",
- description: "Naturapics it's an spin-off project of Fotonatura. A friend of us thought it could be a nice idea to adapt our software platform to show the images of the French photographers. And we did. Our tools appears as a subdomain of the main site... but it's where the beauty of French photography can be admired."
+ description: "Naturapics it's an spin-off project of Fotonatura. A friend of us thought it could be a nice idea to adapt our software platform to show the images of the French photographers. And we did it. Our tools appears as a subdomain of the main site... but it's where the beauty of French photography can be admired."
}, {
name: "Personalparatiendas.com",
url: "http://www.personalparatiendas.com",
View
21 index.html
@@ -30,37 +30,42 @@
<script>
$(document).ready(function(){
+ var candidate, $maincont, $idcont;
+
+ candidate = new Candidate();
+ candidate.loadJSON(mycv);
+
$maincont = $("#display_info");
$idcont = $("#id_info_cont");
$("#menu a").click(function () {
switch($(this).attr("title")) {
case "personal":
- displayPersonalInfo($maincont, candidate);
+ myApp.displayPersonalInfo($maincont, candidate);
break;
case "academic":
- displayAcademicInfo($maincont, candidate);
+ myApp.displayAcademicInfo($maincont, candidate);
break;
case "professional":
- displayProfesionalInfo($maincont, candidate);
+ myApp.displayProfesionalInfo($maincont, candidate);
break;
case "tech":
- displayTechnicalSkills($maincont, candidate);
+ myApp.displayTechnicalSkills($maincont, candidate);
break;
case "projects":
- displayProjects($maincont, candidate);
+ myApp.displayProjects($maincont, candidate);
break;
}
});
// shows id info
- displayIdInfo($idcont, candidate);
+ myApp.displayIdInfo($idcont, candidate);
// shows default content
- displayPersonalInfo($maincont, candidate);
+ myApp.displayPersonalInfo($maincont, candidate);
// print
$("#footer").click(function () {
- printerView($maincont, candidate);
+ myApp.printerView($maincont, candidate);
// hides the printer-friendly link
$(".print").hide();
View
102 src/app.coffee
@@ -1,51 +1,51 @@
-candidate = new Candidate()
-
-candidate.loadJSON(mycv)
-
-displayIdInfo = (el, cand, append = false) ->
- if el? and cand?
- template = $("#id_info").html()
- renderView(template, el, cand, append)
-
-displayPersonalInfo = (el, cand, append = false) ->
- if el? and cand?
- template = $("#personal_info").html()
- renderView(template, el, cand, append)
-
-
-displayAcademicInfo = (el, cand, append = false) ->
- if el? and cand?
- template = $("#academic_info").html()
- renderView(template, el, cand, append)
-
-displayProfesionalInfo = (el, cand, append = false) ->
- if el? and cand?
- template = $("#professional_info").html()
- renderView(template, el, cand, append)
-
-displayTechnicalSkills = (el, cand, append = false) ->
- if el? and cand?
- template = $("#technical_skill_info").html()
- renderView(template, el, cand, append)
-
-
-displayProjects = (el, cand, append = false) ->
- if el? and cand?
- template = $("#project_info").html()
- renderView(template, el, cand, append)
-
-renderView = (template, el, cand, append = false) ->
- html = Mustache.to_html(template, cand)
- if append
- el.append html
- else
- el.html html
-
-printerView = (el, cand) ->
- append = true
-
- displayPersonalInfo(el, cand)
- displayAcademicInfo(el, cand, append)
- displayProfesionalInfo(el, cand, append)
- displayTechnicalSkills(el, cand, append)
- displayProjects(el, cand, append)
+# top level namespacing
+myApp = myApp or {}
+
+myApp =
+ displayIdInfo: (el, cand, append = false) ->
+ if el? and cand?
+ template = $("#id_info").html()
+ @.renderView(template, el, cand, append)
+
+ displayPersonalInfo: (el, cand, append = false) ->
+ if el? and cand?
+ template = $("#personal_info").html()
+ @.renderView(template, el, cand, append)
+
+
+ displayAcademicInfo: (el, cand, append = false) ->
+ if el? and cand?
+ template = $("#academic_info").html()
+ @.renderView(template, el, cand, append)
+
+ displayProfesionalInfo: (el, cand, append = false) ->
+ if el? and cand?
+ template = $("#professional_info").html()
+ @.renderView(template, el, cand, append)
+
+ displayTechnicalSkills: (el, cand, append = false) ->
+ if el? and cand?
+ template = $("#technical_skill_info").html()
+ @.renderView(template, el, cand, append)
+
+
+ displayProjects: (el, cand, append = false) ->
+ if el? and cand?
+ template = $("#project_info").html()
+ @.renderView(template, el, cand, append)
+
+ renderView:(template, el, cand, append = false) ->
+ html = Mustache.to_html(template, cand)
+ if append
+ el.append html
+ else
+ el.html html
+
+ printerView: (el, cand) ->
+ append = true
+
+ @.displayPersonalInfo(el, cand)
+ @.displayAcademicInfo(el, cand, append)
+ @.displayProfesionalInfo(el, cand, append)
+ @.displayTechnicalSkills(el, cand, append)
+ @.displayProjects(el, cand, append)
View
2  src/mycv.json.coffee
@@ -127,7 +127,7 @@ mycv =
name: "Naturapics"
url: "http://gallerie.naturapics.com"
description: "Naturapics it's an spin-off project of Fotonatura. A friend of us thought it could be a nice idea to adapt our
- software platform to show the images of the French photographers. And we did. Our tools appears as a subdomain of the main site... but it's where
+ software platform to show the images of the French photographers. And we did it. Our tools appears as a subdomain of the main site... but it's where
the beauty of French photography can be admired."
,
name: "Personalparatiendas.com"
Please sign in to comment.
Something went wrong with that request. Please try again.