{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/50998658","id":50998658,"diff_hunk":"@@ -0,0 +1,78 @@\n+var cdb = require('cartodb-deep-insights.js');\n+var Backbone = require('backbone');\n+var TabPaneView = require('./tab-pane-view.js');\n+var TabPaneCollection = require('./tab-pane-collection');\n+var LabelView = require('./tab-pane-label-view');\n+var IconView = require('./tab-pane-icon-view');\n+\n+/**\n+ *  TabPane Factory component\n+ */\n+\n+module.exports = {\n+\n+  /*\n+   * {\n+   *   label: 'My label',\n+   *   createContentView: cdb.core.View(),\n+   *   selected: false\n+   * }\n+   */\n+  createWithTextLabels: function(paneItems) {\n+    var items = _.map(paneItems, function(paneItem) {\n+      _.each(['label', 'createContentView'], function(check) {\n+        if (!paneItem[check]) {\n+          throw new Error(check + ' should be provided');\n+        }\n+      });\n+\n+      return {\n+        selected: paneItem.selected,\n+        label: paneItem.label,\n+        createButtonView: function() {\n+          return new LabelView({ model: this });\n+        },\n+        createContentView: function() {\n+          return paneItem.createContentView && paneItem.createContentView() || new cdb.core.View();","path":"lib/assets/javascripts/cartodb3/components/tab-pane/tab-pane-factory.js","position":36,"original_position":36,"commit_id":"4bdf088a5eb230e319f7e2393060680eccd5f3ca","original_commit_id":"4bdf088a5eb230e319f7e2393060680eccd5f3ca","user":{"login":"viddo","id":978461,"avatar_url":"https://avatars.githubusercontent.com/u/978461?v=3","gravatar_id":"","url":"https://api.github.com/users/viddo","html_url":"https://github.com/viddo","followers_url":"https://api.github.com/users/viddo/followers","following_url":"https://api.github.com/users/viddo/following{/other_user}","gists_url":"https://api.github.com/users/viddo/gists{/gist_id}","starred_url":"https://api.github.com/users/viddo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viddo/subscriptions","organizations_url":"https://api.github.com/users/viddo/orgs","repos_url":"https://api.github.com/users/viddo/repos","events_url":"https://api.github.com/users/viddo/events{/privacy}","received_events_url":"https://api.github.com/users/viddo/received_events","type":"User","site_admin":false},"body":"I'd change this to `createContentView: paneItem.createContentView` because:\r\n1. can't control what context the fn will have\r\n1. The fallback code could/should be handled by the TabPaneView, to not have to repeat it in multiple places","created_at":"2016-01-27T15:27:28Z","updated_at":"2016-01-27T15:27:28Z","html_url":"https://github.com/CartoDB/cartodb/pull/6473#discussion_r50998658","pull_request_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/50998658"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/6473#discussion_r50998658"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473","id":57367311,"html_url":"https://github.com/CartoDB/cartodb/pull/6473","diff_url":"https://github.com/CartoDB/cartodb/pull/6473.diff","patch_url":"https://github.com/CartoDB/cartodb/pull/6473.patch","issue_url":"https://api.github.com/repos/CartoDB/cartodb/issues/6473","number":6473,"state":"open","locked":false,"title":"Adds new TabPane","user":{"login":"javierarce","id":4933,"avatar_url":"https://avatars.githubusercontent.com/u/4933?v=3","gravatar_id":"","url":"https://api.github.com/users/javierarce","html_url":"https://github.com/javierarce","followers_url":"https://api.github.com/users/javierarce/followers","following_url":"https://api.github.com/users/javierarce/following{/other_user}","gists_url":"https://api.github.com/users/javierarce/gists{/gist_id}","starred_url":"https://api.github.com/users/javierarce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierarce/subscriptions","organizations_url":"https://api.github.com/users/javierarce/orgs","repos_url":"https://api.github.com/users/javierarce/repos","events_url":"https://api.github.com/users/javierarce/events{/privacy}","received_events_url":"https://api.github.com/users/javierarce/received_events","type":"User","site_admin":false},"body":"This PR:\r\n\r\n- Adds the new `TabPane` component.\r\n- Adds a factory to create two kinds of TabPanes (`createWithTextLabels` & `createWithIcons`)\r\n- Adds a label and icon components (just to be added in the TabPane)\r\n* Changes the paths (and name) of the components folder (lib  > assets > javascripts > cartodb3 > components)\r\n* Updates the names of the tab pane files with the `tab-pane-` prefix\r\n* Flattens the structure of the `tab-pane` components directory\r\n* Lazy loading of the tab-pane content views.\r\n* Removes the default model of the tab-pane component.\r\n* Views within the factory now receive a model instead of a hash of options.\r\n* Fixes specs and increased its coverage.\r\n* Fixes spec system for the cartodb3 specs.\r\n\r\n### Creating a TabPane directly\r\n\r\n```js\r\nvar collection = new TabPaneCollection([\r\n  {\r\n    createButtonView: function() { return new cdb.core.View(); },\r\n    createContentView: function () { return new createWadusView(arguments); }\r\n  }, {\r\n    createButtonView: createItemView,\r\n    createContentView: createEmptyContentView\r\n  }, {\r\n    createButtonView: createItemView,\r\n    createContentView: createEmptyContentView\r\n  }, {\r\n    createContentView: createEmptyContentView\r\n  }\r\n]);\r\n\r\nvar tabPaneView = new TabPaneView({\r\n  collection: collection,\r\n  template: require('./tab-pane-template')\r\n});\r\n```\r\n\r\n### Creating a TabPane with a factory\r\n\r\nIn this case we use the factory `createWithTextLabels`:\r\n\r\n```js\r\nvar tabPaneView = TabPaneFactory.createWithTextLabels([\r\n  {\r\n    label: 'Layers',\r\n    createContentView: createEmptyContentView //= function() { return cdb.core.View() }\r\n  }, {\r\n    label: 'Elements',\r\n    createContentView: createEmptyContentView\r\n  }, {\r\n    // Widget will be implemented from the start\r\n    label: 'Widgets',\r\n    selected: true,\r\n    createContentView: function() {\r\n      return new EditorWidgetsView(editorWidgetsCollection);\r\n    }\r\n  }\r\n]);\r\n```","created_at":"2016-01-27T14:32:16Z","updated_at":"2016-01-27T15:27:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d11bc3aa7742bb94283c7d526adf1011dac3d033","assignee":{"login":"javierarce","id":4933,"avatar_url":"https://avatars.githubusercontent.com/u/4933?v=3","gravatar_id":"","url":"https://api.github.com/users/javierarce","html_url":"https://github.com/javierarce","followers_url":"https://api.github.com/users/javierarce/followers","following_url":"https://api.github.com/users/javierarce/following{/other_user}","gists_url":"https://api.github.com/users/javierarce/gists{/gist_id}","starred_url":"https://api.github.com/users/javierarce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javierarce/subscriptions","organizations_url":"https://api.github.com/users/javierarce/orgs","repos_url":"https://api.github.com/users/javierarce/repos","events_url":"https://api.github.com/users/javierarce/events{/privacy}","received_events_url":"https://api.github.com/users/javierarce/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473/commits","review_comments_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473/comments","review_comment_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/issues/6473/comments","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/4bdf088a5eb230e319f7e2393060680eccd5f3ca","head":{"label":"CartoDB:6441-new-tabpane-2","ref":"6441-new-tabpane-2","sha":"4bdf088a5eb230e319f7e2393060680eccd5f3ca","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Location Intelligence & Data Visualization tool","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/cartodb/deployments","created_at":"2012-07-05T15:23:45Z","updated_at":"2016-01-26T18:16:08Z","pushed_at":"2016-01-27T15:19:08Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"http://cartodb.com","size":382721,"stargazers_count":1039,"watchers_count":1039,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":250,"mirror_url":null,"open_issues_count":815,"forks":250,"open_issues":815,"watchers":1039,"default_branch":"master"}},"base":{"label":"CartoDB:6444-editor3-frontend","ref":"6444-editor3-frontend","sha":"e0040fa8558324f54ef972590a9cc3d6c615d958","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Location Intelligence & Data Visualization tool","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/cartodb/deployments","created_at":"2012-07-05T15:23:45Z","updated_at":"2016-01-26T18:16:08Z","pushed_at":"2016-01-27T15:19:08Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"http://cartodb.com","size":382721,"stargazers_count":1039,"watchers_count":1039,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":250,"mirror_url":null,"open_issues_count":815,"forks":250,"open_issues":815,"watchers":1039,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/6473"},"issue":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/6473"},"comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/6473/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/6473/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/cartodb/statuses/4bdf088a5eb230e319f7e2393060680eccd5f3ca"}}}}