Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Remove ComposerFactoryView and complete todo task in code
Browse files Browse the repository at this point in the history
  • Loading branch information
nttuyen committed Oct 28, 2013
1 parent f3f6d0e commit 0d6316c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 33 deletions.
Expand Up @@ -45,18 +45,20 @@
<div id="portlets" class="panel-collapse collapse in">
<div class="panel-body">
<div class="composer-tooltip">Drag and drop to add new portlet!</div>
<ul id="portlet-list" class="portlet-list"></ul>
<ul id="application-list" class="application-list"></ul>
<div style="clear:both"></div>
</div>
</div>
</div>
</div>
<!-- Templat for portlet in composer -->
<script type="text/template" id="portlet-template">
<div class="draggable">
<img alt="${"<%- name %>"}" src="${"<%- logo %>"}"/>
<p>${"<%- title %>"}</p>
</div>
<li data-name="${"<%- name %>"}">
<div class="draggable">
<img alt="${"<%- name %>"}" src="${"<%- logo %>"}"/>
<p>${"<%- title %>"}</p>
</div>
</li>
</script>
<!-- Templat for portlet in page -->
<script type="text/template" id="application-template">
Expand Down
@@ -1,23 +1,4 @@
(function() {

// An item in composer
var ApplicationFactoryView = Backbone.View.extend({
tagName : "li",

// TODO: Can this be removed, an empty method ?
initialize : function() {
},

render : function() {
this.template = _.template($("#portlet-template").html());
this.$el.html(this.template(this.model.toJSONForRenderer()));
this.$el.attr("id", "");
this.$el.attr("data-name", this.model.getName());
return this;
}
});


// Composer
var ComposerView = Backbone.View.extend({
initialize : function(options) {
Expand All @@ -35,15 +16,14 @@
},

onAddChild : function(child) {
var $container = $('#application-list');

// TODO: rename to application-list
var container = $('#portlet-list');

var view = new ApplicationFactoryView({model : child});
container.append(view.render().$el);
var html = _.template($("#portlet-template").html(), child.toJSONForRenderer());
var $html = $(html);
$container.append($html);

//Enable draggable
$(view.$el).draggable({
$($html).draggable({
connectToSortable: ".sortable",
revert: "invalid",
helper: "clone"
Expand All @@ -54,10 +34,9 @@
var ApplicationView = Backbone.View.extend({
tagName: "div",

// TODO: rename to "window"
className: "portlet",
className: "window",
initialize: function() {
this.model.on('change', this.updateContent, this);
this.model.on('change:content', this.updateContent, this);
this.model.fetchContent();
},
render: function() {
Expand Down

0 comments on commit 0d6316c

Please sign in to comment.