Fix for beautify to work with require.js
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6d171cbe Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6d171cbe Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6d171cbe Branch: refs/heads/fauxton-file-reorder Commit: 6d171cbecc3338f11d72c5aa3218d791d6e2363a Parents: bcb6e04 Author: suelockwood <[email protected]> Authored: Tue Jan 28 10:39:05 2014 -0500 Committer: suelockwood <[email protected]> Committed: Tue Jan 28 11:31:37 2014 -0500 ---------------------------------------------------------------------- .../addons/documents/templates/view_editor.html | 4 ++-- src/fauxton/app/addons/documents/views.js | 4 ++-- src/fauxton/assets/js/plugins/beautify.js | 17 ++++------------- 3 files changed, 8 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d171cbe/src/fauxton/app/addons/documents/templates/view_editor.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/view_editor.html b/src/fauxton/app/addons/documents/templates/view_editor.html index bf31ba2..d02971e 100644 --- a/src/fauxton/app/addons/documents/templates/view_editor.html +++ b/src/fauxton/app/addons/documents/templates/view_editor.html @@ -41,7 +41,7 @@ the License. <div class="js-editor" id="map-function"><%= langTemplates.map %></div> <% } else { %> <div class="js-editor" id="map-function"><%- ddoc.get('views')[viewName].map %></div> - <button class="beautify beautify_map button hidden beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button> + <button class="beautify beautify_map button hide beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button> <% } %> </div> @@ -64,7 +64,7 @@ the License. <div class="js-editor" id="reduce-function"><%= langTemplates.reduce %></div> <% } else { %> <div class="js-editor" id="reduce-function"><%- ddoc.get('views')[viewName].reduce %></div> - <button class="beautify beautify_reduce button hidden beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button> + <button class="beautify beautify_reduce button hide beautify-tooltip" type="button" data-toggle="tooltip" title="Reformat your minified code to make edits to it.">beautify this code</button> <% } %> </div> http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d171cbe/src/fauxton/app/addons/documents/views.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index e2f5578..9516355 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -1630,7 +1630,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.reduceEditor.render(); if (this.reduceEditor.getLines() === 1){ - this.$('.beautify_reduce').removeClass("hidden"); + this.$('.beautify_reduce').removeClass("hide"); $('.beautify-tooltip').tooltip(); } }, @@ -1709,7 +1709,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.reduceEditor && this.reduceEditor.editSaved(); if (this.mapEditor.getLines() === 1){ - this.$('.beautify_map').removeClass("hidden"); + this.$('.beautify_map').removeClass("hide"); $('.beautify-tooltip').tooltip(); } }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/6d171cbe/src/fauxton/assets/js/plugins/beautify.js ---------------------------------------------------------------------- diff --git a/src/fauxton/assets/js/plugins/beautify.js b/src/fauxton/assets/js/plugins/beautify.js index e934fe3..07b6617 100644 --- a/src/fauxton/assets/js/plugins/beautify.js +++ b/src/fauxton/assets/js/plugins/beautify.js @@ -1611,19 +1611,10 @@ } - if (typeof define === "function") { - // Add support for require.js - if (typeof define.amd === "undefined") { - define(function(require, exports, module) { - exports.js_beautify = js_beautify; - }); - } else { - // if is AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- ) - define([], function() { - return js_beautify; - }); - } - + if (typeof define === "function" && define.amd) { + define([], function() { + return js_beautify; + }); } else if (typeof exports !== "undefined") { // Add support for CommonJS. Just put this file somewhere on your require.paths // and you will be able to `var js_beautify = require("beautify").js_beautify`.
