Files
dss/static/js/app/views/user/userProfileView.js
2014-02-10 20:21:54 +00:00

81 lines
3.2 KiB
JavaScript

// Generated by CoffeeScript 1.4.0
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['app', 'utils', 'moment', 'marionette', 'vent', 'app.lib/editableView', 'models/user/userItem', 'text!/tpl/UserProfileView', 'ace-editable', 'wysiwyg'], function(App, utils, moment, Marionette, vent, EditableView, UserItem, Template) {
var UserProfileView;
UserProfileView = (function(_super) {
__extends(UserProfileView, _super);
function UserProfileView() {
this.initialize = __bind(this.initialize, this);
return UserProfileView.__super__.constructor.apply(this, arguments);
}
UserProfileView.prototype.template = _.template(Template);
UserProfileView.prototype.events = {
"click #follow-button": function() {
return vent.trigger("user:follow", this.model);
},
"click #follow-button-login": function() {
return vent.trigger("app:login", this.model);
}
};
UserProfileView.prototype.initialize = function() {
return this.listenTo(this.model, 'change:is_following', this.render);
};
UserProfileView.prototype.templateHelpers = {
humanise: function(date) {
return moment(date).fromNow();
}
};
UserProfileView.prototype.onDomRefresh = function() {
var _this = this;
console.log("UserProfileView: initialize");
$.fn.editable.defaults.mode = "inline";
$.fn.editableform.loading = "<div class='editableform-loading'><i class='light-blue icon-2x icon-spinner icon-spin'></i></div>";
$.fn.editableform.buttons = "<button type=\"submit\" class=\"btn btn-info editable-submit\"><i class=\"fa fa-check fa-white\"></i></button>" + "<button type=\"button\" class=\"btn editable-cancel\"><i class=\"fa fa-times fa-white\"></i></button>";
if (utils.isMe(this.model.get("id"))) {
this.setupImageEditable({
el: $("#avatar", this.el),
url: "/ajax/upload_avatar_image/",
chooseMessage: "Choose profile image"
});
$("#about", this.el).editable({
mode: "inline",
type: "wysiwyg",
name: "about",
wysiwyg: {},
css: {
'max-width': '300px'
},
success: function(response, newValue) {
console.log("Update model with new value");
return _this.model.save('description', newValue, {
patch: true
});
}
});
}
return $(".usereditable").attr('class', utils.isMe(this.model.get("id")) ? "editable editable-click" : "user-info");
};
UserProfileView.prototype.onRender = function() {
return window.scrollTo(0, 0);
};
return UserProfileView;
})(EditableView);
return UserProfileView;
});
}).call(this);