o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1355857733.3126929: @value"r{I" class:EFI"BundledAsset;FI"logical_path;FI",woople-theme/reports/activity_report.js;TI" pathname;FI"w/Users/adamdoeler/Sites/bigbang/woople-theme/app/assets/javascripts/woople-theme/reports/activity_report.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2012-12-05T14:56:05-05:00;FI" length;FicI" digest;F"%f59684481a12f038539e8f4e173d6f7dI" source;FI"c(function() { var ActivityReport; ActivityReport = (function() { function ActivityReport() {} ActivityReport.RED = '255, 0, 0'; ActivityReport.YELLOW = '255, 215, 0'; ActivityReport.GREEN = '70, 136, 71'; ActivityReport.YELLOW_GOAL = 4; ActivityReport.GREEN_GOAL = 7; ActivityReport.prototype.init = function(selector, debugMode) { this.debugMode = debugMode != null ? debugMode : false; this.selector = $(selector); this.log('initialize'); return this.setupListeners(); }; ActivityReport.prototype.setupListeners = function() { this.log('setup listeners'); return this.selector.on('shown', $.proxy(this, 'shownListener')); }; ActivityReport.prototype.shownListener = function(event) { this.log('tab shown: ' + $(event.target).attr('href')); return this.loadReport($(event.target).attr('data-type'), $(event.target).attr('data-container'), $(event.target).attr('data-path')); }; ActivityReport.prototype.loadReport = function(reportType, container, path) { this.reportType = reportType; this.container = container; this.log('report: loading...'); return $.ajax(path, { type: 'GET', success: $.proxy(this, 'successCallback'), error: $.proxy(this, 'errorCallback') }); }; ActivityReport.prototype.successCallback = function(data, textStatus, jqXHR) { this.log('report: loaded'); this.reportData = data; return this.buildReport(); }; ActivityReport.prototype.errorCallback = function(jqXHR, textStatus, errorThrown) { return this.log('report: error'); }; ActivityReport.prototype.highchartOptions = function() { var options; options = { chart: { borderRadius: 0, renderTo: this.container, height: 400, type: 'column' }, title: { text: this.reportTitle() }, tooltip: { borderColor: 'darkGrey', useHMTL: true, headerFormat: '{series.name}', pointFormat: '\ Total:{point.y}\ ', footerFormat: '' }, xAxis: { categories: this.categories(), labels: { formatter: function() { var index, numberOfAxisLabels, offset; numberOfAxisLabels = this.axis.categories.length; offset = numberOfAxisLabels % 2; index = this.axis.categories.indexOf(this.value); if ((index + offset) % 2 === 0 && $(window).width() <= 500) { return ''; } else { return this.value; } } } }, yAxis: { title: { text: "Views/Relearns" }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: 'grey' } } }, plotOptions: { series: { stacking: 'normal', borderColor: 'white' } }, series: [ { type: 'column', name: 'Relearns', data: this.relearns(), borderColor: 'white', shadow: false }, { type: 'column', name: 'Unique Views', data: this.uniqueViews(), borderColor: 'white', shadow: false } ], credits: { enabled: false }, legend: { enabled: false } }; return options; }; ActivityReport.prototype.buildReport = function() { this.log('report: building'); return this.chart = new Highcharts.Chart(this.highchartOptions()); }; ActivityReport.prototype.reportTitle = function() { this.log('report title for: ' + this.reportType); return $('#' + this.reportType).data('title'); }; ActivityReport.prototype.categories = function() { var categories, category, _i, _len, _ref; categories = []; _ref = this.reportData; for (_i = 0, _len = _ref.length; _i < _len; _i++) { category = _ref[_i]; categories.push(this.formatCategoryName(category)); } return categories; }; ActivityReport.prototype.formatCategoryName = function(data) { return "" + data.primary_name + "
" + data.secondary_name; }; ActivityReport.prototype.uniqueViews = function() { var data, uniqueViews, _i, _len, _ref; uniqueViews = []; _ref = this.reportData; for (_i = 0, _len = _ref.length; _i < _len; _i++) { data = _ref[_i]; uniqueViews.push({ y: data.views, color: this.gradeColour(data, 1) }); } return uniqueViews; }; ActivityReport.prototype.relearns = function() { var data, relearns, _i, _len, _ref; relearns = []; _ref = this.reportData; for (_i = 0, _len = _ref.length; _i < _len; _i++) { data = _ref[_i]; relearns.push({ y: data.relearns, color: this.gradeColour(data, 0.5) }); } return relearns; }; ActivityReport.prototype.gradeColour = function(data, opacity) { var total; total = parseInt(data.views, 10) + parseInt(data.relearns, 10); if (total < (ActivityReport.YELLOW_GOAL * this.multiplier())) { return "rgba(" + ActivityReport.RED + ", " + opacity + ")"; } if (total < (ActivityReport.GREEN_GOAL * this.multiplier())) { return "rgba(" + ActivityReport.YELLOW + ", " + opacity + ")"; } if (total >= (ActivityReport.GREEN_GOAL * this.multiplier())) { return "rgba(" + ActivityReport.GREEN + ", " + opacity + ")"; } }; ActivityReport.prototype.multiplier = function() { if (this.isWeekly()) { return 1; } if (this.isMonthly()) { return 7; } if (this.isAnnually()) { return 31; } }; ActivityReport.prototype.isWeekly = function() { return this.reportType === 'week'; }; ActivityReport.prototype.isMonthly = function() { return this.reportType === 'month'; }; ActivityReport.prototype.isAnnually = function() { return this.reportType === 'annual'; }; ActivityReport.prototype.log = function(message) { if (this.debugMode) { return console.log("[ActivityReport] " + message); } }; return ActivityReport; })(); this.ActivityReport = ActivityReport; }).call(this); ;FI"required_assets_digest;F"%7b5a76dd2ec3b7e2b61c2305bb649844I" _version;F"%6776f581a4329e299531e1d52aa59832