OwnedSymbols view before and after Rivets

Created Diff never expires
34 हटाए गए
लाइनें
कुल
हटाया गया
शब्द
कुल
हटाया गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diffchecker logo
Diffchecker Pro
50 लाइनें
20 जोड़े गए
लाइनें
कुल
जोड़ा गया
शब्द
कुल
जोड़ा गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diffchecker logo
Diffchecker Pro
37 लाइनें
var Radio = require('backbone.radio');
var Radio = require('backbone.radio');


var OwnedSymbolItemView = Marionette.ItemView.extend({
var OwnedSymbolsView = Marionette.ItemView.extend({
template: require('../templates/ownedsymbolitem.hbs'),
template: false,
tagName: 'li',
html: require('../templates/ownedsymbols.html'),
className: 'item item-icon-right row',
modelEvents: {
'change:latestPrice': 'onLatestPriceChange'
},
events: {
'click': 'onClick'
},
onLatestPriceChange: function () {
var price = this.model.get('latestPrice');
var variation = this.model.get('latestVariation');
var variationText = variation ? Math.abs(variation).toFixed(2) + '%' : '--';
var iconClass = 'ion-arrow-' + (variation > 0 ? 'up': 'down') + '-a';
this.$el.find('.stock-variation').toggleClass('negative-value', variation < 0)
.contents().filter(function() {
return this.nodeType == 3 && this.textContent.trim().length > 0
}).replaceWith(' ' + variationText);

this.$el.find('.stock-variation i').removeClass('ion-arrow-up-a ion-arrow-down-a').addClass(iconClass);
this.$el.find('.stock-price').html(price ? 'R$' + price.toFixed(2) : '--');
},
onClick: function (e) {
e.preventDefault();
Radio.channel('navigation').request('goToPage', 'symboldetails', this.model.get('id'));
}
});

var OwnedSymbolsView = Marionette.CompositeView.extend({
template: require('../templates/ownedsymbols.hbs'),
childView: OwnedSymbolItemView,
childViewContainer: '#symbol-list',
pageHeader: {
pageHeader: {
title: 'Carteira de Ações',
title: 'Carteira de Ações',
buttons: [
buttons: [
{
{
icon: 'ion-plus',
icon: 'ion-plus',
method: 'add:buy'
method: 'add:buy'
}
}
]
]
},
},
onBeforeRender: function () {
if (this.view) {
this.view.unbind();
this.view = null;
}
this.attachElContent(this.html);
this.view = rivets.bind(this.el, this);
},
onDestroy: function () {
if (this.view) {
this.view.unbind();
this.view = null;
}
},
onAddBuy: function () {
onAddBuy: function () {
Radio.channel('navigation').request('goToPage', 'newbuy');
Radio.channel('navigation').request('goToPage', 'newbuy');
},
onItemClick: function (e, scope) {
Radio.channel('navigation').request('goToPage', 'symboldetails', scope.model.get('id'));
}
}
});
});


module.exports = OwnedSymbolsView;
module.exports = OwnedSymbolsView;