Download:
child 149:344b03642d02
parent 147:af2c69b87882
148:7a236aa969f8
Anton Shestakov <av6@dwimlabs.net>, Sun, 30 Jul 2017 23:00:46 +0800
js: remove trailing spaces

7 файлов изменено, 77 вставок(+), 77 удалений(-) [+]
static/js/framework/models.js file | annotate | diff | comparison | revisions
static/js/framework/router.js file | annotate | diff | comparison | revisions
static/js/framework/views/base.js file | annotate | diff | comparison | revisions
static/js/framework/views/inline.js file | annotate | diff | comparison | revisions
static/js/framework/views/projects.js file | annotate | diff | comparison | revisions
static/js/framework/views/tasks.js file | annotate | diff | comparison | revisions
static/js/ui.js file | annotate | diff | comparison | revisions
--- a/static/js/framework/models.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/framework/models.js Sun Jul 30 23:00:46 2017 +0800
@@ -3,14 +3,14 @@
var url = Backbone.Model.prototype.url.call(this);
return url[url.length - 1] === '/' ? url : url + '/';
},
-
+
adhoc: function(data) {
var model = this;
var options = {
contentType: 'application/json',
data: JSON.stringify(data)
};
-
+
return (this.sync || Backbone.sync).call(this, 'update', model, options).then(function(serverAttrs) {
model.set(serverAttrs);
});
@@ -23,12 +23,12 @@
var Project = Model.extend({
idAttribute: '_id',
-
+
switchColor: function() {
var colorChain = [null, 'info', 'success', 'warning', 'danger'];
var currentColorIndex = colorChain.indexOf(this.get('color') || null);
var nextColor = colorChain[(currentColorIndex + 1) % colorChain.length];
-
+
return this.adhoc({color: nextColor});
}
});
--- a/static/js/framework/router.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/framework/router.js Sun Jul 30 23:00:46 2017 +0800
@@ -3,18 +3,18 @@
'': 'randomize',
':workspace': 'setWorkspace'
},
-
+
makeRandomString: function(length) {
return _.map(_.range(length), function() {
return (Math.random()*16|0).toString(16);
}).join('');
},
-
+
randomize: function() {
var randomString = this.makeRandomString(8);
this.navigate(randomString, {trigger: true, replace: true});
},
-
+
setWorkspace: function(workspace) {
fruitbar.trigger('workspace', workspace);
}
--- a/static/js/framework/views/base.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/framework/views/base.js Sun Jul 30 23:00:46 2017 +0800
@@ -9,7 +9,7 @@
},
bindCollection: function() {
this.repopulate();
-
+
this.collection
.on('add', this.appendItem, this)
.on('change', this.updateItem, this)
@@ -21,7 +21,7 @@
},
compileTemplates: function(templates) {
this.templates = {};
-
+
_.each(templates, function(template, name) {
this.templates[name] = _.template(template);
}, this);
--- a/static/js/framework/views/inline.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/framework/views/inline.js Sun Jul 30 23:00:46 2017 +0800
@@ -2,12 +2,12 @@
initialize: function(options) {
this.render(options);
},
-
+
renderInput: function(options) {
var view = this;
-
+
this.$input = $('<input type="text" class="form-control input-sm">').val(options.target.text());
-
+
this.$input.keyup(function(e) {
switch (e.keyCode) {
case 13:
@@ -18,20 +18,20 @@
break;
}
});
-
+
this.$group.append(this.$saveButton, this.$cancelButton);
this.$el.append(this.$input, this.$group);
options.target.after(this.$el);
this.$input.focus();
-
+
return this;
},
-
+
renderTextarea: function(options) {
var view = this;
-
+
this.$input = $('<textarea class="form-control input-sm" rows="3">').text(options.target.text());
-
+
this.$input.keyup(function(e) {
switch (e.keyCode) {
case 13:
@@ -44,32 +44,32 @@
break;
}
});
-
+
this.$group.append(this.$saveButton, this.$cancelButton);
this.$el.append(this.$input, this.$group);
options.target.after(this.$el);
this.$input.focus();
-
+
return this;
},
-
+
render: function(options) {
var view = this;
-
+
this.$saveButton = $('<button class="btn btn-sm btn-success">').html('<i class="glyphicon glyphicon-ok"></i>');
this.$cancelButton = $('<button class="btn btn-sm btn-default">').html('<i class="glyphicon glyphicon-remove"></i>');
this.$el = $('<div class="inline-editor input-group">');
this.$group = $('<span class="input-group-btn">');
-
+
this.$cancelButton.click(function() {
view.$el.remove();
options.target.show();
});
-
+
this.$saveButton.click(function() {
view.trigger('save', view.$input.val());
});
-
+
switch (options.type) {
case 'input':
return this.renderInput(options);
@@ -84,20 +84,20 @@
bindInlineEditable: function(model, selector) {
model.$item.delegate(selector, 'click', function(e) {
e.preventDefault();
-
+
var $this = $(this);
var attribute = $this.attr('data-model-attribute');
var inlineEditor = new InlineEditorView({
target: $this,
type: $this.attr('data-input-type') || 'input'
});
-
+
$this.hide();
-
+
inlineEditor.on('save', function(value) {
var data = {};
data[attribute] = value;
-
+
model.adhoc(data).then(function() {
inlineEditor.remove();
$this.show();
--- a/static/js/framework/views/projects.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/framework/views/projects.js Sun Jul 30 23:00:46 2017 +0800
@@ -2,24 +2,24 @@
initialize: function(options) {
this.tasks = options.tasks;
this.rawTemplates = options.templates;
-
+
this.compileTemplates(options.templates);
this.bindCollection();
-
+
options.controls.create.click(function() {
options.collection.create({
name: 'new project'
}, {wait: true});
});
},
-
+
clear: function() {
this.$el.empty();
},
-
+
renderItem: function(project) {
var $item = $(this.templates.project(project.toJSON()));
-
+
$item.tasksView = new TasksView({
el: $item.find('.tasks'),
collection: project.tasks,
@@ -28,7 +28,7 @@
create: $item.find('.btn-new-task')
}
});
-
+
$item
.find('.progress')
.click(function() {
@@ -38,16 +38,16 @@
$progress.removeClass('active');
});
});
-
+
$item
.find('.btn-delete-project')
.click(function() {
project.destroy({wait: true});
});
-
+
return $item;
},
-
+
updateProgress: function(project) {
project.$item
.find('.progress-bar')
@@ -56,45 +56,45 @@
.attr('aria-valuenow', (100 * project.tasks.progress()))
.css('width', (100 * project.tasks.progress()) + '%');
},
-
+
appendItem: function(project) {
var tasks = this.tasks;
-
+
project.tasks = new Backbone.Shard({
collection: this.tasks,
filter: function(task) { return task.get('project_id') === project.id; }
});
-
+
project.tasks.progress = function() {
return this.filter(function(task) { return task.get('done') === true; }).length / this.size();
};
-
+
project.tasks.create = function(attributes, options) {
attributes = attributes || {};
attributes.project_id = project.id;
return tasks.create(attributes, options);
};
-
+
project.$item = this.renderItem(project);
-
+
this.bindInlineEditable(project, '.inline-editable[data-model="project"]');
this.updateProgress(project);
-
+
project.on('change:name', function() {
project.$item.find('[data-model="project"][data-model-attribute="name"]').text(project.get('name'));
});
-
+
project.on('change:color', function() {
this.updateProgress(project);
}, this);
-
+
project.tasks.on('add remove change:done reset', function() {
this.updateProgress(project);
}, this);
-
+
this.$el.append(project.$item);
},
-
+
removeItem: function(project) {
project.$item.remove();
}
--- a/static/js/framework/views/tasks.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/framework/views/tasks.js Sun Jul 30 23:00:46 2017 +0800
@@ -2,39 +2,39 @@
initialize: function(options) {
this.compileTemplates(options.templates);
this.bindCollection();
-
+
options.controls.create.click(function() {
options.collection.create({
name: 'new task'
}, {wait: true});
});
},
-
+
clear: function() {
this.$el.empty();
},
-
+
renderItem: function(task) {
var $item = $(this.templates.task(task.toJSON()));
-
+
$item
.find('input:checkbox')
.change(function() {
task.adhoc({'done': this.checked});
});
-
+
$item
.find('.btn-delete-task')
.click(function() {
task.destroy({wait: true});
});
-
+
return $item;
},
-
+
updateNote: function(task) {
var $note = task.$item.find('[data-model="task"][data-model-attribute="note"]');
-
+
if (task.get('note')) {
$note.text(task.get('note'));
task.$item.find('.task-note').removeClass('muted').addClass('present');
@@ -43,28 +43,28 @@
task.$item.find('.task-note').addClass('muted').removeClass('present');
}
},
-
+
appendItem: function(task) {
task.$item = this.renderItem(task);
-
+
this.bindInlineEditable(task, '.inline-editable[data-model="task"]');
this.updateNote(task);
-
+
task.on('change:done', function() {
task.$item.find('input:checkbox').prop('checked', task.get('done'));
});
-
+
task.on('change:name', function() {
task.$item.find('[data-model="task"][data-model-attribute="name"]').text(task.get('name'));
});
-
+
task.on('change:note', function() {
this.updateNote(task);
}, this);
-
+
this.$el.append(task.$item);
},
-
+
removeItem: function(task) {
task.$item.remove();
}
--- a/static/js/ui.js Sun Jul 30 22:54:22 2017 +0800
+++ b/static/js/ui.js Sun Jul 30 23:00:46 2017 +0800
@@ -4,7 +4,7 @@
fruitbar.tasks = new Tasks();
fruitbar.projects = new Projects();
fruitbar.router = new Router();
-
+
fruitbar.xhrs = [];
fruitbar.xhrs.done = function() {
return _(this).all(function(xhr) {
@@ -15,10 +15,10 @@
_(this).each(function(xhr) {
xhr.abort();
});
-
+
this.length = 0;
};
-
+
fruitbar.fetchAll = function(url) {
return Backbone.ajax({
url: url,
@@ -29,11 +29,11 @@
fruitbar.tasks.set(data.tasks);
});
};
-
+
fruitbar.workspaceTitleDisplayer = new Displayer({
el: $('.workspace-title')
});
-
+
fruitbar.workspaceTabs = new WorkspaceTabsView({
el: $('.workspace-tabs'),
collection: fruitbar.workspaces,
@@ -41,13 +41,13 @@
tab: $.trim($('#workspace-tab-template').html())
}
});
-
+
fruitbar.projectCounter = new CollectionCounterView({
el: $('.project-counter'),
collection: fruitbar.projects,
plurals: ['project', 'projects']
});
-
+
fruitbar.projectsView = new ProjectsView({
el: $('.projects'),
collection: fruitbar.projects,
@@ -60,31 +60,31 @@
create: $('.btn-new-project')
}
});
-
+
fruitbar.on('workspace', function(workspace) {
$('body').stop().animate({opacity: 0});
-
+
this.xhrs.abort();
-
+
this.workspace = workspace;
this.workspaces.create({name: workspace});
this.tasks.url = '/' + encodeURIComponent(workspace) + '/tasks/';
this.projects.url = '/' + encodeURIComponent(workspace) + '/projects/';
-
+
this.xhrs.push(this.fetchAll('/' + encodeURIComponent(workspace) + '/all/'));
-
+
_(this.xhrs).each(function(fetch, index, xhrs) {
fetch.then(function() {
if (xhrs.done()) {
fruitbar.workspaceTitleDisplayer.render(workspace);
fruitbar.workspaceTabs.activate(workspace);
-
+
$('body').stop().animate({opacity: 1});
}
});
});
});
-
+
fruitbar.once('workspace', function() {
window.setInterval(function() {
fruitbar.xhrs.push(fruitbar.fetchAll('/' + encodeURIComponent(fruitbar.workspace) + '/all/'));