/pollapli/ui/static/pollapli/views/updates_view.js

https://bitbucket.org/kaosat_dev/pollapli · JavaScript · 134 lines · 99 code · 11 blank · 24 comment · 5 complexity · d7681eff70917a8eb22a921e67687e59 MD5 · raw file

  1. function get_type(thing)
  2. {
  3. if(thing===null)return "[object Null]"; // special case
  4. return Object.prototype.toString.call(thing);
  5. }
  6. function displayProperties(obj)
  7. {
  8. var list="";
  9. for(var p in obj)
  10. list += p + " : " + obj[p] + "<br>";
  11. console.log(list);
  12. }
  13. var UpdatesView= Backbone.View.extend
  14. (
  15. {
  16. initialize: function()
  17. {
  18. //this.updateListView=new UpdatesListView({collection: this.collection, el: $("#machin") });
  19. _.bindAll(this, "render");
  20. this.collection.bind("all", this.render,this);
  21. },
  22. renderList : function(updates)
  23. {
  24. $("#innerContent").html("");
  25. updates.each(function(update)
  26. {
  27. var view = new UpdateView({model: update});
  28. $("#innerContent").append(view.render().el);
  29. });
  30. return this;
  31. },
  32. render : function()
  33. {
  34. $(this.el).html("");
  35. this.el.append($("<div id='innerHeader' class='widgetHeader'></div>", {id: "#innerHeader"}));
  36. this.el.append($("<div id='innerContent'>dfgdfg</div", {id: "#innerContent"}));
  37. this.filterView=new FilterView({el: $("#innerHeader"),orderables:["name","version","type"],filterables:["downloaded","installed",] });//,{orderables:["name","version","type"],filterables:["downloaded","installed",]});
  38. this.filterView.parent=this;
  39. this.filterView.render();
  40. this.renderList(this.collection);
  41. },
  42. tutu : function()
  43. {
  44. $(this.el).trigger('totoEvent');
  45. alert("child event tutu raised inside update view");
  46. },
  47. events:
  48. {
  49. 'tutuEvent': 'tutu'
  50. },
  51. }
  52. );
  53. var UpdateView= Backbone.View.extend
  54. (
  55. {
  56. initialize: function()
  57. {
  58. this.template=pollapli.ui.templates["updates_tmpl"];
  59. $('.progressbar').progressbar({value:0});
  60. // _.bindAll(this, "render");
  61. // this.model.bind("all", this.render,this);
  62. },
  63. render: function()
  64. {
  65. $(this.el).jqotesub(this.template, this.model.toJSON());
  66. //needs to reference only the progressbars inside of this el
  67. //this.$(".title")
  68. /*$(' .progressbar').progressbar(
  69. {
  70. value: 0,
  71. change: function(event, ui)
  72. {
  73. var newVal = $(this).progressbar('option', 'value');
  74. $('.pblabel', this).text(newVal + '%');
  75. }
  76. });
  77. pollapli.ui.set_progressbar=function(divName,percent)
  78. {
  79. $(divName).progressbar( "option", "value", percent);
  80. }
  81. */
  82. return this;
  83. }
  84. }
  85. );
  86. var UpdatesListView= Backbone.View.extend
  87. (
  88. {
  89. events: {
  90. "click #new-zone-button": "add"
  91. },
  92. initialize: function()
  93. {
  94. this.template=this.options.template;
  95. if (this.template==null)
  96. {
  97. this.template=pollapli.ui.templates["updates_tmpl"];
  98. }
  99. _.bindAll(this, "render","add");
  100. if (this.collection!=null)
  101. {
  102. this.collection.bind("all", this.render,this);
  103. }
  104. },
  105. render: function()
  106. {
  107. if (this.collection!=null)
  108. {
  109. // $(this.el).jqotesub(this.template, this.collection.toJSON());
  110. //this.el.append($("<div id='truc'></div>", {id: "#truc"}));
  111. //this.el.append($("<div id='machin'>dfgdfg</div", {id: "#machin"}));
  112. $("#machin").jqotesub(this.template, this.collection.toJSON());
  113. //$(this.el).jqotesub(this.template, this.collection.toJSON());
  114. //$(this.el+"> div[id=machin]").jqotesub(this.template, this.collection.toJSON());
  115. }
  116. return this;
  117. },
  118. add: function ()
  119. {
  120. $("#new-zone-form-dialog").dialog("open");
  121. }
  122. }
  123. );