Updated Branches:
  refs/heads/BEAUTIFY 17d99b757 -> 5ab7fd005

Beautify Code button fixed for views and reduces


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5ab7fd00
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5ab7fd00
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5ab7fd00

Branch: refs/heads/BEAUTIFY
Commit: 5ab7fd0059d786d52588890bda6e3c50d636ddf4
Parents: 17d99b7
Author: suelockwood <[email protected]>
Authored: Mon Jan 27 15:01:04 2014 -0500
Committer: suelockwood <[email protected]>
Committed: Mon Jan 27 15:01:04 2014 -0500

----------------------------------------------------------------------
 .../addons/documents/assets/less/documents.less |  4 +++-
 .../addons/documents/templates/view_editor.html |  3 ++-
 src/fauxton/app/addons/documents/views.js       | 21 +++++++++++++++-----
 3 files changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/5ab7fd00/src/fauxton/app/addons/documents/assets/less/documents.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/assets/less/documents.less 
b/src/fauxton/app/addons/documents/assets/less/documents.less
index 38fd792..68fc58d 100644
--- a/src/fauxton/app/addons/documents/assets/less/documents.less
+++ b/src/fauxton/app/addons/documents/assets/less/documents.less
@@ -19,4 +19,6 @@ tr.all-docs-item{
         top: 6px;
     }
 }
-
+button.beautify {
+       margin-top: 20px;
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/5ab7fd00/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 036aff9..bf31ba2 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 button hidden" type="button">beautify this 
code</button>
+            <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>
             <% } %>
           </div>
 
@@ -64,6 +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>
             <% } %>
           </div>
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/5ab7fd00/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 392cfc4..dd1468d 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1249,7 +1249,8 @@ function(app, FauxtonAPI, Components, Documents, 
Databases, pouchdb, resizeColum
       "change select#reduce-function-selector": "updateReduce",
       "click button.preview": "previewView",
       "click #db-views-tabs-nav": 'toggleIndexNav',
-      "click .beautify":  "beautifyCode"
+      "click .beautify_map":  "beautifyCode",
+      "click .beautify_reduce":  "beautifyCode"
     },
 
     langTemplates: {
@@ -1591,6 +1592,11 @@ function(app, FauxtonAPI, Components, Documents, 
Databases, pouchdb, resizeColum
         couchJSHINT: true
       });
       this.reduceEditor.render();
+
+      if (this.reduceEditor.getLines() === 1){
+        this.$('.beautify_reduce').removeClass("hidden");
+        $('.beautify-tooltip').tooltip();
+      }
     },
 
     beforeRender: function () {
@@ -1639,6 +1645,8 @@ function(app, FauxtonAPI, Components, Documents, 
Databases, pouchdb, resizeColum
         this.$('#index').hide();
         this.$('#index-nav').parent().removeClass('active');
       }
+
+
     },
 
     showEditors: function () {
@@ -1665,12 +1673,15 @@ function(app, FauxtonAPI, Components, Documents, 
Databases, pouchdb, resizeColum
       this.reduceEditor && this.reduceEditor.editSaved();
 
       if (this.mapEditor.getLines() === 1){
-        this.$('.beautify').removeClass("hidden");
+        this.$('.beautify_map').removeClass("hidden");
+        $('.beautify-tooltip').tooltip();
       }
     },
-    beautifyCode: function(){
-      var beautifiedCode = beautify(this.mapEditor.getValue());
-      this.mapEditor.setValue(beautifiedCode);
+    beautifyCode: function(e){
+      e.preventDefault();
+      var targetEditor = 
$(e.currentTarget).hasClass('beautify_reduce')?this.reduceEditor:this.mapEditor;
+      var beautifiedCode = beautify(targetEditor.getValue());
+      targetEditor.setValue(beautifiedCode);
     },
     cleanup: function () {
       this.mapEditor && this.mapEditor.remove();

Reply via email to