Add minified build output. Make 'new' optional on Morris.Line.

This commit is contained in:
Olly Smith 2012-02-26 00:28:58 +00:00
parent 40f336e8bc
commit 99aafd3ed8
4 changed files with 18 additions and 11 deletions

View File

@ -45,7 +45,8 @@
{"period": "1995 Q4", "licensed": 1702, "sorned": 0},
{"period": "1994 Q4", "licensed": 1732, "sorned": 0}
];
new Morris.Line("graph", {
Morris.Line({
element: 'graph',
data: tax_data,
xkey: 'period',
ykeys: ['licensed', 'sorned'],

View File

@ -1,14 +1,14 @@
# The original line graph.
#
window.Morris = {}
class window.Morris.Line
Morris = {}
class Morris.Line
# Initialise the graph.
#
# @param {string} id Target element's DOM ID
# @param {Object} options
constructor: (id, options) ->
@el = $ document.getElementById(id)
constructor: (options) ->
if not (this instanceof Morris.Line)
return new Morris.Line(options)
@el = $ document.getElementById(options.element)
@options = $.extend @defaults, options
# bail if there's no data
if @options.data is undefined or @options.data.length is 0
@ -295,4 +295,5 @@ class window.Morris.Line
commas: (num) ->
Math.max(0, num).toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ',')
window.Morris = Morris
# vim: set et ts=2 sw=2 sts=2

View File

@ -1,11 +1,13 @@
(function() {
var Morris;
window.Morris = {};
Morris = {};
window.Morris.Line = (function() {
Morris.Line = (function() {
function Line(id, options) {
this.el = $(document.getElementById(id));
function Line(options) {
if (!(this instanceof Morris.Line)) return new Morris.Line(options);
this.el = $(document.getElementById(options.element));
this.options = $.extend(this.defaults, options);
if (this.options.data === void 0 || this.options.data.length === 0) return;
this.el.addClass('graph-initialised');
@ -315,4 +317,6 @@
})();
window.Morris = Morris;
}).call(this);

1
morris.min.js vendored Normal file

File diff suppressed because one or more lines are too long