-
Notifications
You must be signed in to change notification settings - Fork 9
complete #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pahaz
wants to merge
9
commits into
cripi-javascript:master
Choose a base branch
from
pahaz:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
complete #12
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2d5601f
init git
pahaz 9cb38f9
init submodules
pahaz a372867
init work html and styles
pahaz f9373bf
fix submodules
pahaz 1ddf52f
Find strange error.
pahaz 94a8964
Add create event button
pahaz b3a20d3
complete
pahaz 487dabd
add new function logic for ajax
pahaz d1dbb0e
comment init app
pahaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "oop"] | ||
path = oop | ||
url = https://github.com/pahaz/dz-4-oop.git | ||
[submodule "todo"] | ||
path = todo | ||
url = https://github.com/addyosmani/todomvc.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="todo/assets/base.css"> | ||
<style> | ||
#add-button { | ||
width: 100%; | ||
border-bottom: 1px solid #6C615C; | ||
background: #8D7D77; | ||
background: -webkit-gradient(linear, left top, left bottom, from(rgba(132, 110, 100, 0.8)),to(rgba(101, 84, 76, 0.8))); | ||
background: -webkit-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); | ||
background: -moz-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); | ||
background: -o-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); | ||
background: -ms-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); | ||
background: linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); | ||
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670'); | ||
border-top-left-radius: 1px; | ||
border-top-right-radius: 1px; | ||
border: double; | ||
border-color: aliceBlue; | ||
padding: 10px; | ||
} | ||
.events__item { | ||
word-break: break-word; | ||
padding: 15px; | ||
margin-left: 45px; | ||
display: block; | ||
line-height: 1.2; | ||
-webkit-transition: color 0.4s; | ||
-moz-transition: color 0.4s; | ||
-ms-transition: color 0.4s; | ||
-o-transition: color 0.4s; | ||
transition: color 0.4s; | ||
} | ||
</style> | ||
|
||
<!-- script src="jquery-1.7.2.min.js"></script --> | ||
<script src="oop/underscore/underscore.js"></script> | ||
<!-- script src="backbone.js"></script --> | ||
<script src="oop/MyAbstractLayer.js"></script> | ||
<script src="oop/Model.js"></script> | ||
<script src="oop/Collection.js"></script> | ||
|
||
<title>Yo!</title> | ||
</head> | ||
<body> | ||
|
||
<form> | ||
<section id="todoapp"> | ||
<header id="header"> | ||
<h1>Events</h1> | ||
<input id="new-todo" placeholder="What event?" autofocus=""/> | ||
|
||
<div style="padding: 16px 16px 16px 60px; background: rgba(0, 0, 0, 0.02);"> | ||
<label>Start | ||
<input type="date" name="start" id="js-start_time" /> | ||
</label> | ||
|
||
<label style="float: right;"> | ||
<input type="date" name="end" id="js-end_time" /> | ||
End | ||
</label> | ||
<br/> | ||
<br/> | ||
|
||
<input type="submit" value="Add event" id="add-button" /> | ||
|
||
<br/> | ||
<br/> | ||
|
||
<hr/> | ||
|
||
<div class="filter"> | ||
<label><input type="checkbox" id="filter_future" class="js-filters" />Select future events</label> | ||
<label><input type="checkbox" id="filter_my" class="js-filters" />Select my events</label> | ||
|
||
<div>Order by</div> | ||
<label><input type="radio" name="sort" class="js-filters" value="title" />Name</label> | ||
<label><input type="radio" name="sort" class="js-filters" value="go" />My</label> | ||
<label><input type="radio" name="sort" class="js-filters" value="start_time" />Start</label> | ||
<label><input type="radio" name="sort" class="js-filters" value="end_time" />End</label> | ||
</div> | ||
|
||
|
||
</div> | ||
</header> | ||
<section id="main"> | ||
<ul id="todo-list"> | ||
<li class=""> | ||
<input class="toggle" type="checkbox"> | ||
<div class="events__item"> | ||
<div>Name: pewpew</div> | ||
<div>Start: 18.8.2005 12:00</div> | ||
<div>End: 18.8.2005 12:30</div> | ||
</div> | ||
</li> | ||
</ul> | ||
</section> | ||
</section> | ||
<br/> | ||
|
||
</form> | ||
|
||
<script src="index.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/** | ||
* Created with PyCharm. | ||
* User: pahaz | ||
* Date: 11.11.12 | ||
* Time: 22:08 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
|
||
/** | ||
* Application Event. | ||
* | ||
* @constructor | ||
* @this {app} | ||
*/ | ||
var app = function () {}; | ||
|
||
/** | ||
* Application initialization. | ||
* | ||
* @this {app} | ||
*/ | ||
app.prototype.init = function () { | ||
var self = this; | ||
this.render = document.getElementById('todo-list'); | ||
this.inputs = { | ||
'title': document.getElementById('new-todo'), | ||
'start_time': document.getElementById('js-start_time'), | ||
'end_time': document.getElementById('js-end_time') | ||
}; | ||
|
||
this.full_collection = new EventsCollection(this.load()); | ||
this.current_collection = this.full_collection; | ||
|
||
this.template = _.template("\ | ||
<% collection.each(function(event) { %> \ | ||
<li> \ | ||
<% if (event.get('go')) { %> \ | ||
<input class='toggle' type='checkbox'> \ | ||
<% } %> \ | ||
<div class='events__item'> \ | ||
<div><b><%- event.get('title') %></b></div> \ | ||
<div><small>Start: <%- event.get('start_time').toLocaleDateString() %></small></div> \ | ||
<div><small>End: <%- event.get('end_time').toLocaleDateString() %></small></div> \ | ||
</div> \ | ||
</li> \ | ||
<% }); %>"); | ||
|
||
this.action = document.getElementById('add-button'); | ||
this.action.addEventListener('click', function (event) { | ||
self.action_click(event); | ||
event.preventDefault(); | ||
}); | ||
|
||
var listeners = document.querySelectorAll('.js-filters'); | ||
var self = this; | ||
_.each(listeners, function(listener) { | ||
listener.addEventListener('change', self.change_current_collection.bind(self)); | ||
}); | ||
}; | ||
|
||
/** | ||
* Load initial collection data. | ||
* | ||
* @this {app} | ||
*/ | ||
app.prototype.load = function () { | ||
return [ | ||
createNewEvent(new Date(2000, 10, 1), new Date(2000, 11, 1), "First", true), | ||
createNewEvent(new Date(2005, 5, 1), new Date(2006, 1, 1), "Second"), | ||
createNewEvent(new Date(2001, 10, 1), new Date(2006, 10, 1), "Looooong event", true), | ||
createNewEvent(new Date(1991, 5, 1), new Date(2000, 1, 20), "OoOOOoold event"), | ||
createNewEvent(new Date(2007, 3, 11), new Date(2008, 1, 5), "from 2007 to 2008", true), | ||
createNewEvent(new Date(2000, 5, 12), new Date(2020, 8, 17), "from 2000 To futureeeee"), | ||
createNewEvent(new Date(2013, 5, 12), new Date(2017, 1, 27), "Futureeeee", true), | ||
createNewEvent(new Date(2006, 10, 1), new Date(2008, 11, 1), "Firth") | ||
]; | ||
}; | ||
|
||
/** | ||
* Application click action listener. | ||
* | ||
* @this {app} | ||
*/ | ||
app.prototype.action_click = function (event) { // WTF: this is WINDOW !!! | ||
var info = {}; | ||
_.each(this.inputs, function(num, key) { | ||
info[key] = num.value; | ||
}); | ||
|
||
try { | ||
var model_class = this.full_collection.model; | ||
var new_event = new model_class(info); | ||
this.full_collection.add(new_event); | ||
this.change_current_collection(event); | ||
this.save(); | ||
} catch (e) { | ||
alert(e.message); | ||
} | ||
}; | ||
|
||
/** | ||
* Save collection data. | ||
* | ||
* @this {app} | ||
*/ | ||
app.prototype.save = function() { | ||
|
||
}; | ||
|
||
/** | ||
* Application change collection listener. | ||
* | ||
* @this {app} | ||
*/ | ||
app.prototype.change_current_collection = function (event) { | ||
this.current_collection = this.full_collection; | ||
|
||
// TODO: optimization; | ||
var my = document.getElementById('filter_my').checked; | ||
var future = document.getElementById('filter_future').checked; | ||
var sort = false; | ||
|
||
if (document.querySelector('input[name="sort"]:checked') !== null) { | ||
sort = document.querySelector('input[name="sort"]:checked').value; | ||
} | ||
|
||
var tmp_collection = this.current_collection; | ||
if (my) { | ||
tmp_collection = tmp_collection.my_events(); | ||
} | ||
if (future) { | ||
tmp_collection = tmp_collection.start_after(new Date()); | ||
} | ||
if (sort) { | ||
tmp_collection = tmp_collection.sortBy(function (model) { return model.get(sort); }); | ||
} | ||
|
||
this.current_collection = tmp_collection; | ||
this.paint(); | ||
}; | ||
|
||
/** | ||
* Render current collection. | ||
* | ||
* @this {app} | ||
*/ | ||
app.prototype.paint = function () { | ||
this.render.innerHTML = this.template({'collection': this.current_collection}); | ||
}; | ||
|
||
/* | ||
var application = new app(); | ||
application.init(); | ||
application.paint(); | ||
*/ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше не использовать
\
я бы даже сказал предельно крайне не желательно использовать. Проще всего вынести этот шаблон в HTML (в скрытый элемент) и не мучаться так