Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 92E94111BA for ; Mon, 30 Jun 2014 08:23:20 +0000 (UTC) Received: (qmail 75000 invoked by uid 500); 30 Jun 2014 08:23:15 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 74918 invoked by uid 500); 30 Jun 2014 08:23:15 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 73189 invoked by uid 99); 30 Jun 2014 08:23:13 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2014 08:23:13 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C500491B235; Mon, 30 Jun 2014 08:23:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: garren@apache.org To: commits@couchdb.apache.org Date: Mon, 30 Jun 2014 08:23:47 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [36/50] couchdb commit: updated refs/heads/Update-Sidebar-Ui to 01dcb16 Fauxton: Refactor sidebar nav for new design Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/dc83b57f Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/dc83b57f Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/dc83b57f Branch: refs/heads/Update-Sidebar-Ui Commit: dc83b57f02c128dd53e8ae226dc08d2dff14ed81 Parents: cf65167 Author: Garren Smith Authored: Mon May 19 18:12:44 2014 +0200 Committer: Garren Smith Committed: Mon Jun 30 10:17:51 2014 +0200 ---------------------------------------------------------------------- .../addons/documents/assets/less/documents.less | 27 +- .../app/addons/documents/sidebarviews.js | 252 +++++++++++++++++++ .../templates/add_new_ddoc_fn_dropdown.html | 31 --- .../documents/templates/design_doc_menu.html | 4 +- .../documents/templates/index_menu_item.html | 7 +- .../app/addons/documents/templates/sidebar.html | 51 ++-- src/fauxton/app/addons/documents/views.js | 216 +--------------- src/fauxton/app/addons/fauxton/components.js | 26 ++ .../addons/fauxton/templates/menu_dropdown.html | 33 +++ .../assets/less/bootstrap/dropdowns.less | 4 +- src/fauxton/assets/less/fauxton.less | 34 ++- 11 files changed, 376 insertions(+), 309 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc83b57f/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 8b0ba2e..4e87dd6 100644 --- a/src/fauxton/app/addons/documents/assets/less/documents.less +++ b/src/fauxton/app/addons/documents/assets/less/documents.less @@ -171,8 +171,9 @@ button.beautify { padding-left: 55px; font-size: 14px; &:hover { + background-color: #af2d24; + color: #fff; text-decoration: none; - color: #af2d24; } } } @@ -194,30 +195,6 @@ button.beautify { -webkit-transform:rotate(90deg); /* Opera, Chrome, and Safari */ } } - div.new-button { - position: absolute; - top: 2px; - right: 15px; - .dropdown-menu{ - left: -82px; - padding-bottom: 0; - width: auto; - min-width: 0; - li a { - padding: 10px 15px 10px 12px; - } - } - .dropdown-toggle{ - text-decoration: none; - } - > a { - border-bottom: none; - text-decoration: none; - font-size: 16px; - - } - } } } - http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc83b57f/src/fauxton/app/addons/documents/sidebarviews.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/sidebarviews.js b/src/fauxton/app/addons/documents/sidebarviews.js new file mode 100644 index 0000000..88233f6 --- /dev/null +++ b/src/fauxton/app/addons/documents/sidebarviews.js @@ -0,0 +1,252 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +define([ + "app", + + "api", + "addons/fauxton/components", + + "addons/documents/resources", + "addons/databases/resources" +], + +function(app, FauxtonAPI, Components, Documents, Databases) { + var Views = {}; + + Views.Sidebar = FauxtonAPI.View.extend({ + template: "addons/documents/templates/sidebar", + className: "sidenav", + tagName: "nav", + events: { + "click button#delete-database": "showDeleteDatabaseModal" + }, + + initialize: function(options) { + this.database = options.database; + if (options.ddocInfo) { + this.ddocID = options.ddocInfo.id; + this.currView = options.ddocInfo.currView; + } + }, + showDeleteDatabaseModal: function(event){ + this.deleteDBModal.showModal(); + }, + + serialize: function() { + var docLinks = FauxtonAPI.getExtensions('docLinks'), + newLinks = FauxtonAPI.getExtensions('sidebar:newLinks'), + addLinks = FauxtonAPI.getExtensions('sidebar:links'), + extensionList = FauxtonAPI.getExtensions('sidebar:list'); + return { + changes_url: '#' + this.database.url('changes'), + permissions_url: '#' + this.database.url('app') + '/permissions', + db_url: '#' + this.database.url('index'), + database: this.collection.database, + database_url: '#' + this.database.url('app'), + docLinks: docLinks, + addLinks: addLinks, + newLinks: newLinks, + extensionList: extensionList > 0 + }; + }, + + + beforeRender: function(manage) { + this.deleteDBModal = this.setView( + '#delete-db-modal', + new Views.DeleteDBModal({database: this.database}) + ); + + var database = this.collection.database, + newurl = "#" + database.url('app') + '/new'; + + var newLinks = [{ + title: 'Add new', + links: [{ + title: 'New Doc', + url: newurl, + icon: 'fonticon-circle-plus' + },{ + title: 'New Design Doc', + url: newurl, + icon: 'fonticon-circle-plus' + }] + }]; + + this.insertView("#new-all-docs-button", new Components.MenuDropDown({ + links: newLinks, + })); + + this.insertView("#new-design-docs-button", new Components.MenuDropDown({ + links: newLinks, + })); + + this.collection.each(function(design) { + if (design.has('doc')){ + this.insertView(new Views.DdocSidenav({ + model: design, + collection: this.collection + })); + } + },this); + }, + + afterRender: function () { + if (this.selectedTab) { + this.setSelectedTab(this.selectedTab); + } + }, + + setSelectedTab: function (selectedTab) { + this.selectedTab = selectedTab; + var $selectedTab = this.$('#' + selectedTab); + + this.$('li').removeClass('active'); + $selectedTab.parent().addClass('active'); + + if ($selectedTab.parents(".accordion-body").length !== 0){ + $selectedTab + .parents(".accordion-body") + .addClass("in") + .parents(".nav-header") + .find(".js-collapse-toggle").addClass("down"); + } + } + }); + + Views.DdocSidenav = FauxtonAPI.View.extend({ + tagName: "ul", + className: "nav nav-list", + template: "addons/documents/templates/design_doc_menu", + events: { + "click button": "no", + "click .js-collapse-toggle": "toggleArrow" + }, + initialize: function(){ + + }, + toggleArrow: function(e){ + this.$(e.currentTarget).toggleClass("down"); + }, + no: function(event){ + event.preventDefault(); + alert("no"); + }, + buildIndexList: function(collection, selector, ddocType){ + var design = this.model.id.replace(/^_design\//,""); + + _.each(_.keys(collection[selector]), function(key){ + this.insertView(".accordion-body", new Views.IndexItem({ + selector: selector, + ddoc: design, + index: key, + ddocType: ddocType, + database: this.model.collection.database.id + })); + }, this); + }, + + serialize: function(){ + var ddocName = this.model.id.replace(/^_design\//,""); + return{ + database: this.collection.database, + designDoc: ddocName, + ddoc_clean: app.utils.removeSpecialCharacters(ddocName), + ddoc_encoded: app.utils.safeURLName(ddocName), + database_encoded: app.utils.safeURLName(this.model.collection.database.id), + }; + }, + beforeRender: function(manage) { + var ddocDocs = this.model.get("doc"), + ddocName = this.model.id.replace(/^_design\//,""), + sideBarMenuLinks = []; + + var sidebarListTypes = FauxtonAPI.getExtensions('sidebar:list'); + if (ddocDocs){ + //Views + this.buildIndexList(ddocDocs, "views", "view"); + //lists + // this.buildIndexList(ddocDocs, "lists"); + // //show + // this.buildIndexList(ddocDocs, "show"); + // //filters + // this.buildIndexList(ddocDocs, "filters"); + //extensions + _.each(sidebarListTypes, function (type) { + this.buildIndexList(ddocDocs, type); + },this); + } + + var docSafe = app.utils.safeURLName(ddocName), + database = this.collection.database, + links = _.reduce(FauxtonAPI.getExtensions('sidebar:links'), function (menuLinks, link) { + + menuLinks.push({ + title: link.title, + url: "#" + database.url('app') + "/" + link.url + "/" + docSafe, + icon: 'fonticon-circle-plus' + }); + + return menuLinks; + }, [{ + title: 'Secondary View', + url: "#" + database.url('app') + "/new_view/" + docSafe, + icon: 'fonticon-circle-plus' + }]); + + sideBarMenuLinks.push({ + title: 'Add new', + links: links + }); + + this.insertView(".new-button", new Components.MenuDropDown({ + links: sideBarMenuLinks, + })); + } + }); + + Views.IndexItem = FauxtonAPI.View.extend({ + template: "addons/documents/templates/index_menu_item", + tagName: "li", + + initialize: function(options){ + this.index = options.index; + this.ddoc = options.ddoc; + this.database = options.database; + this.selected = !! options.selected; + this.selector = options.selector; + this.ddocType = options.ddocType || this.selector; + }, + + serialize: function() { + return { + icon: this.ddocType, + type: this.ddocType, + index: this.index, + ddoc: this.ddoc, + database: this.database, + selected: this.selected + }; + }, + + afterRender: function() { + if (this.selected) { + $(".sidenav ul.nav-list li").removeClass("active"); + this.$el.addClass("active"); + } + } + }); + + return Views; +}); + http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc83b57f/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html b/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html deleted file mode 100644 index 77323a9..0000000 --- a/src/fauxton/app/addons/documents/templates/add_new_ddoc_fn_dropdown.html +++ /dev/null @@ -1,31 +0,0 @@ - - - http://git-wip-us.apache.org/repos/asf/couchdb/blob/dc83b57f/src/fauxton/app/addons/documents/templates/design_doc_menu.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/templates/design_doc_menu.html b/src/fauxton/app/addons/documents/templates/design_doc_menu.html index c5bd392..63d6016 100644 --- a/src/fauxton/app/addons/documents/templates/design_doc_menu.html +++ b/src/fauxton/app/addons/documents/templates/design_doc_menu.html @@ -12,13 +12,13 @@ License for the specific language governing permissions and limitations under the License. -->