This repository was archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyAgendaPlanner.js
More file actions
97 lines (86 loc) · 2.83 KB
/
myAgendaPlanner.js
File metadata and controls
97 lines (86 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* My Agenda Planner
* This is the "general controller" of the application. It controlls
* which views are displayed, some generic statuses and so forth.
*
* @Parameter 1 ( model | object Model | ... )
* -------------------------------------------------
*/
function MyAgendaPlanner (model) {
"use strict";
// Defining variables.
var mainView;
this.activityPrevPos; // This variable is needed to know prevPos when moving between containers.
/*
* Views & view-object.
* the views-array contains view-objects to be sent through the displayView-method.
*
* view-object:
* {
* type : "view-type",
* view : reference to view class,
* controller : reference to controller class
* }
*/
this.views = [];
/*
* init ().
* This method is used to 'start' the application.
* --------------------------------------------------
*/
this.init = function () {
//console.log("myAgendaPlanner - init()");
// Initalizing views by pushing view-objects to the views-array.
this.views["main-view"] = {
type : "main-view",
view : MainView,
controller : MainViewController
};
this.views["activity-view"] = {
type : "activity-view",
view : ActivityView,
controller : ActivityViewController
};
this.views["day-view"] = {
type : "day-view",
view : DayView,
controller : DayViewController
};
this.views["add-activity-view"] = {
type : "add-activity-view",
view : AddActivityView,
controller : AddActivityViewController
};
// Displaying default view(s).
mainView = this.displayView({}, this.views["main-view"], "my-agenda-planner");
mainView.addActivityView();
mainView.addDayViews();
};
/*
* displayView (viewParameters, viewObject, targetDOM).
* This method is used to display a view somewhere in the HTML document.
* Each view passed through the method must have a method called init which returns a DOM-element.
*
* @Parameter 1 (viewParameters | object {} | This object should contain view-specific attributes.)
* @Parameter 2 (viewObject | object {} | view-object, read documentation above.)
* @Parameter 3 (targetDOM | string | "DOM-id", without the #.)
*
* @Return (view | object | "instance of main-view".)
* --------------------------------------------------------------------------
*/
this.displayView = function (viewParameters, viewObject, targetDOM) {
//console.log("myAgendaPlanner - displayView()");
// Defining variables.
var controller,
view;
// Creating new view & controller.
controller = new viewObject.controller(model, this);
view = new viewObject.view(viewParameters, controller, model, this);
// Displaying view by pushing returned DOM-element to targetDOM.
$("#" + targetDOM).append(view.init());
// Returning only if type is main-view.
if (viewObject.type == "main-view") {
return view;
};
};
};