Skip to content

Commit

Permalink
fix bug: null data support.
Browse files Browse the repository at this point in the history
  • Loading branch information
warfares committed Nov 8, 2014
1 parent 02c46dc commit 6c2c562
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion build/pretty-json-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/tools/jsmin.pyc
Binary file not shown.
Binary file modified build/tools/mergejs.pyc
Binary file not shown.
Binary file modified build/tools/toposort.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions css/pretty-json.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
.number{ color:#ccaa00;}
.boolean{ color:#1979d3;}
.date{ color:#aa6655;}
.null{ color:#ff5050;}
/* eof leaf */
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<script type="text/javascript" src="/libs/underscore-min.js" ></script>
<script type="text/javascript" src="/libs/backbone-min.js" ></script>

<!-- src dev
<!-- src dev
<script type="text/javascript" src="/pretty-json-debug.js" ></script>
-->
<!-- src build -->
<!-- src build -->
<script type="text/javascript" src="/build/pretty-json-min.js" ></script>

<!-- just css for this page example -->
Expand Down
9 changes: 7 additions & 2 deletions src/leaf.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PrettyJSON.view.Leaf = Backbone.View.extend({
if(_.isNumber(d)) m = 'number';
else if(_.isBoolean(d)) m = 'boolean';
else if(_.isDate(d)) m = 'date';
else if(_.isNull(d)) m = 'null'
return m;
},
getState:function(){
Expand All @@ -49,13 +50,17 @@ PrettyJSON.view.Leaf = Backbone.View.extend({
};
return state;
},
render: function(){
render: function() {
var state = this.getState();

if (state.type == "date" && this.dateFormat) {
if (state.type == 'date' && this.dateFormat) {
state.data = PrettyJSON.util.dateFormat(this.data, this.dateFormat);
}

if (state.type == 'null') {
state.data = 'null';
}

this.tpl = _.template(PrettyJSON.tpl.Leaf, state);
$(this.el).html(this.tpl);
return this;
Expand Down

0 comments on commit 6c2c562

Please sign in to comment.