{"action":"created","comment":{"url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/comments/28761077","id":28761077,"diff_hunk":"@@ -18,25 +18,165 @@\n // See doc/COPYRIGHT.md for more details.\n //++\n \n-/*globals jQuery, I18n*/\n+/* globals jQuery, $$, $, Sortable, Effect, Form */\n+/* jshint camelcase: false */\n+/* jshint nonew: false */\n \n-var MyProjectPage = (function ($) {\n-  var init;\n+(function($) {\n+  // $ is prototype\n+  // @see app/views/my_projects_overviews/page_layout.html.erb\n \n-  init = function () {\n-    $('#users_per_role .all').click(function () {\n-      $('#users_per_role').html('');\n-    });\n+  function recreateSortables() {\n+    var lists = $$('.list-position'),\n+        containedPositions = (function() {\n+          var positions = _.map(lists, function(list) {\n+            return list.readAttribute('id');\n+          });\n+          return _.uniq(positions);\n+        }()),\n+        destroy = function destroy(list) {\n+          var id = list.readAttribute('id');\n+          Sortable.destroy(id);\n+        },\n+        create = function create(list) {\n+          var id  = list.readAttribute('id'),\n+              url = list.readAttribute('data-ajax-url');\n+          Sortable.create(id, {\n+            constraint: false,\n+            dropOnEmpty: true,\n+            handle: 'handle',\n+            onUpdate: function updatePosition() {\n+              new Ajax.Request(url, {\n+                asynchronous: true,\n+                evalScripts: true,\n+                parameters: Sortable.serialize(id)\n+              });\n+            },\n+            containment: containedPositions,\n+            only: 'mypage-box',\n+            tag: 'div'\n+          });\n+        };\n \n-    $.ajaxAppend({\n-      trigger: '.all',\n-      indicator_class: 'ajax-indicator',\n-      load_target: '#users_per_role',\n-      loading_text: I18n.t(\"js.ajax.loading\"),\n-      loading_class: 'box loading'\n-    });\n-  };\n+    lists.each(destroy);\n+    lists.each(create);\n+  }\n+\n+  function updateSelect() {\n+    var s = $('block-select');\n+    for (var i = 0; i < s.options.length; i++) {\n+      if ($('block_' + s.options[i].value)) {\n+        s.options[i].disabled = true;\n+      } else {\n+        s.options[i].disabled = false;\n+      }\n+    }\n+    s.options[0].selected = true;\n+  }\n+\n+  function afterAddBlock(response) {\n+    recreateSortables();\n+    updateSelect();\n+    editTextilizable(extractBlockName(response));\n+    new Effect.ScrollTo('list-hidden');\n+  }\n+\n+  function extractBlockName(response) {\n+    return response.responseText.match(/id=\"block_(.*?)\"/)[1];\n+  }\n+\n+  function resetTextilizable(name) {\n+    $('textile_' + name).setValue(window['page_layout-textile' + name] + '');\n+    toggleTextilizableVisibility(name);\n+    return false;\n+  }\n+\n+  function editTextilizable(name) {\n+    var textile_name = $('textile_' + name);\n+    if (textile_name !== null) {\n+      window['page_layout-textile' + name] = textile_name.getValue();\n+      toggleTextilizableVisibility(name);\n+    }\n+    return false;\n+  }\n+\n+  function toggleTextilizableVisibility(name) {\n+    $(name + '-form-div').toggle();\n+    $(name + '-preview-div').toggle();\n+    $(name + '-text').toggle();\n+  }\n+  function addBlock() {\n+    new Ajax.Updater('list-hidden',\n+                     $('block-form').action,\n+                     { insertion: 'top',\n+                       onComplete: afterAddBlock,\n+                       parameters: Form.serialize('block-form'),\n+                       evalScripts:true\n+                     });\n+\n+    return false;\n+  }\n+\n+  // prototype end\n \n-  $('document').ready(init);\n+  (function($) {\n+    // from here on, '$' is jQuery\n \n-}(jQuery));\n+    $(function() {\n+      $('#users_per_role .all').click(function () {\n+        $('#users_per_role').html('');\n+      });\n+\n+      $.ajaxAppend({\n+        trigger: '.all',\n+        indicator_class: 'ajax-indicator',\n+        load_target: '#users_per_role',\n+        loading_text: I18n.t('js.ajax.loading'),","path":"app/assets/javascripts/my_project_page/my_project_page.js","position":143,"original_position":143,"commit_id":"92cc2819015b956d3b33ecf91c5cb702fd9c174e","original_commit_id":"92cc2819015b956d3b33ecf91c5cb702fd9c174e","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"'I18n' is not defined.","created_at":"2015-04-21T09:06:29Z","updated_at":"2015-04-21T09:06:29Z","html_url":"https://github.com/finnlabs/openproject-my_project_page/pull/37#discussion_r28761077","pull_request_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/comments/28761077"},"html":{"href":"https://github.com/finnlabs/openproject-my_project_page/pull/37#discussion_r28761077"},"pull_request":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37","id":33741601,"html_url":"https://github.com/finnlabs/openproject-my_project_page/pull/37","diff_url":"https://github.com/finnlabs/openproject-my_project_page/pull/37.diff","patch_url":"https://github.com/finnlabs/openproject-my_project_page/pull/37.patch","issue_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues/37","number":37,"state":"open","locked":false,"title":"[19325] Personalize Overview does not use two column layout","user":{"login":"floriank","id":498241,"avatar_url":"https://avatars.githubusercontent.com/u/498241?v=3","gravatar_id":"","url":"https://api.github.com/users/floriank","html_url":"https://github.com/floriank","followers_url":"https://api.github.com/users/floriank/followers","following_url":"https://api.github.com/users/floriank/following{/other_user}","gists_url":"https://api.github.com/users/floriank/gists{/gist_id}","starred_url":"https://api.github.com/users/floriank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floriank/subscriptions","organizations_url":"https://api.github.com/users/floriank/orgs","repos_url":"https://api.github.com/users/floriank/repos","events_url":"https://api.github.com/users/floriank/events{/privacy}","received_events_url":"https://api.github.com/users/floriank/received_events","type":"User","site_admin":false},"body":"This introduces the use of the foundation styles to the personalized overview page. It should meet the requirements for https://community.openproject.org/work_packages/19325.\r\n\r\nThis does actually quite a bit of refactoring - I tried to remove the JavaScript calls from the templates and consolidate them in a single file. Instead of doing nothing after executing controller actions, the `MyProjectsOverviewsController` should properly use a `.js.erb` partial to execute the remote callbacks.\r\n\r\nThe page now also uses the `toolbar` component on the page.\r\n\r\nWhile it's not perfect and there is still some pitfalls in there, I can live with this for now. We should probably consolidate the MyProjectPage plugin into core at some point, as there is massive duplication to the core functionality. Maybe _in the future_<sup>TM</sup>\r\n\r\nAlso: Prototype removal.","created_at":"2015-04-21T09:06:24Z","updated_at":"2015-04-21T09:06:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c40ec725259f1bc158c49f9245680f5fba9f7f9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37/commits","review_comments_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37/comments","review_comment_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/comments{/number}","comments_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues/37/comments","statuses_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/statuses/92cc2819015b956d3b33ecf91c5cb702fd9c174e","head":{"label":"floriank:fix/19325-two-columns","ref":"fix/19325-two-columns","sha":"92cc2819015b956d3b33ecf91c5cb702fd9c174e","user":{"login":"floriank","id":498241,"avatar_url":"https://avatars.githubusercontent.com/u/498241?v=3","gravatar_id":"","url":"https://api.github.com/users/floriank","html_url":"https://github.com/floriank","followers_url":"https://api.github.com/users/floriank/followers","following_url":"https://api.github.com/users/floriank/following{/other_user}","gists_url":"https://api.github.com/users/floriank/gists{/gist_id}","starred_url":"https://api.github.com/users/floriank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floriank/subscriptions","organizations_url":"https://api.github.com/users/floriank/orgs","repos_url":"https://api.github.com/users/floriank/repos","events_url":"https://api.github.com/users/floriank/events{/privacy}","received_events_url":"https://api.github.com/users/floriank/received_events","type":"User","site_admin":false},"repo":{"id":30915897,"name":"openproject-my_project_page","full_name":"floriank/openproject-my_project_page","owner":{"login":"floriank","id":498241,"avatar_url":"https://avatars.githubusercontent.com/u/498241?v=3","gravatar_id":"","url":"https://api.github.com/users/floriank","html_url":"https://github.com/floriank","followers_url":"https://api.github.com/users/floriank/followers","following_url":"https://api.github.com/users/floriank/following{/other_user}","gists_url":"https://api.github.com/users/floriank/gists{/gist_id}","starred_url":"https://api.github.com/users/floriank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floriank/subscriptions","organizations_url":"https://api.github.com/users/floriank/orgs","repos_url":"https://api.github.com/users/floriank/repos","events_url":"https://api.github.com/users/floriank/events{/privacy}","received_events_url":"https://api.github.com/users/floriank/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/floriank/openproject-my_project_page","description":"The \"My Page\". For the project overview.","fork":true,"url":"https://api.github.com/repos/floriank/openproject-my_project_page","forks_url":"https://api.github.com/repos/floriank/openproject-my_project_page/forks","keys_url":"https://api.github.com/repos/floriank/openproject-my_project_page/keys{/key_id}","collaborators_url":"https://api.github.com/repos/floriank/openproject-my_project_page/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/floriank/openproject-my_project_page/teams","hooks_url":"https://api.github.com/repos/floriank/openproject-my_project_page/hooks","issue_events_url":"https://api.github.com/repos/floriank/openproject-my_project_page/issues/events{/number}","events_url":"https://api.github.com/repos/floriank/openproject-my_project_page/events","assignees_url":"https://api.github.com/repos/floriank/openproject-my_project_page/assignees{/user}","branches_url":"https://api.github.com/repos/floriank/openproject-my_project_page/branches{/branch}","tags_url":"https://api.github.com/repos/floriank/openproject-my_project_page/tags","blobs_url":"https://api.github.com/repos/floriank/openproject-my_project_page/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/floriank/openproject-my_project_page/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/floriank/openproject-my_project_page/git/refs{/sha}","trees_url":"https://api.github.com/repos/floriank/openproject-my_project_page/git/trees{/sha}","statuses_url":"https://api.github.com/repos/floriank/openproject-my_project_page/statuses/{sha}","languages_url":"https://api.github.com/repos/floriank/openproject-my_project_page/languages","stargazers_url":"https://api.github.com/repos/floriank/openproject-my_project_page/stargazers","contributors_url":"https://api.github.com/repos/floriank/openproject-my_project_page/contributors","subscribers_url":"https://api.github.com/repos/floriank/openproject-my_project_page/subscribers","subscription_url":"https://api.github.com/repos/floriank/openproject-my_project_page/subscription","commits_url":"https://api.github.com/repos/floriank/openproject-my_project_page/commits{/sha}","git_commits_url":"https://api.github.com/repos/floriank/openproject-my_project_page/git/commits{/sha}","comments_url":"https://api.github.com/repos/floriank/openproject-my_project_page/comments{/number}","issue_comment_url":"https://api.github.com/repos/floriank/openproject-my_project_page/issues/comments{/number}","contents_url":"https://api.github.com/repos/floriank/openproject-my_project_page/contents/{+path}","compare_url":"https://api.github.com/repos/floriank/openproject-my_project_page/compare/{base}...{head}","merges_url":"https://api.github.com/repos/floriank/openproject-my_project_page/merges","archive_url":"https://api.github.com/repos/floriank/openproject-my_project_page/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/floriank/openproject-my_project_page/downloads","issues_url":"https://api.github.com/repos/floriank/openproject-my_project_page/issues{/number}","pulls_url":"https://api.github.com/repos/floriank/openproject-my_project_page/pulls{/number}","milestones_url":"https://api.github.com/repos/floriank/openproject-my_project_page/milestones{/number}","notifications_url":"https://api.github.com/repos/floriank/openproject-my_project_page/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/floriank/openproject-my_project_page/labels{/name}","releases_url":"https://api.github.com/repos/floriank/openproject-my_project_page/releases{/id}","created_at":"2015-02-17T12:23:40Z","updated_at":"2015-02-17T12:23:41Z","pushed_at":"2015-04-21T08:58:30Z","git_url":"git://github.com/floriank/openproject-my_project_page.git","ssh_url":"git@github.com:floriank/openproject-my_project_page.git","clone_url":"https://github.com/floriank/openproject-my_project_page.git","svn_url":"https://github.com/floriank/openproject-my_project_page","homepage":"","size":438,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"finnlabs:release/4.1","ref":"release/4.1","sha":"2714211603cf43d29e693f30c9c0091154ef11a8","user":{"login":"finnlabs","id":86719,"avatar_url":"https://avatars.githubusercontent.com/u/86719?v=3","gravatar_id":"","url":"https://api.github.com/users/finnlabs","html_url":"https://github.com/finnlabs","followers_url":"https://api.github.com/users/finnlabs/followers","following_url":"https://api.github.com/users/finnlabs/following{/other_user}","gists_url":"https://api.github.com/users/finnlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/finnlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finnlabs/subscriptions","organizations_url":"https://api.github.com/users/finnlabs/orgs","repos_url":"https://api.github.com/users/finnlabs/repos","events_url":"https://api.github.com/users/finnlabs/events{/privacy}","received_events_url":"https://api.github.com/users/finnlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":2755781,"name":"openproject-my_project_page","full_name":"finnlabs/openproject-my_project_page","owner":{"login":"finnlabs","id":86719,"avatar_url":"https://avatars.githubusercontent.com/u/86719?v=3","gravatar_id":"","url":"https://api.github.com/users/finnlabs","html_url":"https://github.com/finnlabs","followers_url":"https://api.github.com/users/finnlabs/followers","following_url":"https://api.github.com/users/finnlabs/following{/other_user}","gists_url":"https://api.github.com/users/finnlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/finnlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finnlabs/subscriptions","organizations_url":"https://api.github.com/users/finnlabs/orgs","repos_url":"https://api.github.com/users/finnlabs/repos","events_url":"https://api.github.com/users/finnlabs/events{/privacy}","received_events_url":"https://api.github.com/users/finnlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/finnlabs/openproject-my_project_page","description":"The \"My Page\". For the project overview.","fork":false,"url":"https://api.github.com/repos/finnlabs/openproject-my_project_page","forks_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/forks","keys_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/keys{/key_id}","collaborators_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/teams","hooks_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/hooks","issue_events_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues/events{/number}","events_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/events","assignees_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/assignees{/user}","branches_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/branches{/branch}","tags_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/tags","blobs_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/git/refs{/sha}","trees_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/git/trees{/sha}","statuses_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/statuses/{sha}","languages_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/languages","stargazers_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/stargazers","contributors_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/contributors","subscribers_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/subscribers","subscription_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/subscription","commits_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/commits{/sha}","git_commits_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/git/commits{/sha}","comments_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/comments{/number}","issue_comment_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues/comments{/number}","contents_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/contents/{+path}","compare_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/compare/{base}...{head}","merges_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/merges","archive_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/downloads","issues_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues{/number}","pulls_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls{/number}","milestones_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/milestones{/number}","notifications_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/labels{/name}","releases_url":"https://api.github.com/repos/finnlabs/openproject-my_project_page/releases{/id}","created_at":"2011-11-11T12:58:01Z","updated_at":"2015-04-10T14:57:17Z","pushed_at":"2015-04-21T09:06:25Z","git_url":"git://github.com/finnlabs/openproject-my_project_page.git","ssh_url":"git@github.com:finnlabs/openproject-my_project_page.git","clone_url":"https://github.com/finnlabs/openproject-my_project_page.git","svn_url":"https://github.com/finnlabs/openproject-my_project_page","homepage":"","size":1237,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":2,"forks":8,"open_issues":2,"watchers":4,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37"},"html":{"href":"https://github.com/finnlabs/openproject-my_project_page/pull/37"},"issue":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues/37"},"comments":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/finnlabs/openproject-my_project_page/statuses/92cc2819015b956d3b33ecf91c5cb702fd9c174e"}}}}