Show More
@@ -6,12 +6,6 if (typeof console == "undefined" || typ | |||
|
6 | 6 | console = { log: function() {} } |
|
7 | 7 | } |
|
8 | 8 | |
|
9 | ||
|
10 | var str_repeat = function(i, m) { | |
|
11 | for (var o = []; m > 0; o[--m] = i); | |
|
12 | return o.join(''); | |
|
13 | }; | |
|
14 | ||
|
15 | 9 | /** |
|
16 | 10 | * INJECT .format function into String |
|
17 | 11 | * Usage: "My name is {0} {1}".format("Johny","Bravo") |
@@ -19,7 +13,6 var str_repeat = function(i, m) { | |||
|
19 | 13 | * Inspired by https://gist.github.com/1049426 |
|
20 | 14 | */ |
|
21 | 15 | String.prototype.format = function() { |
|
22 | ||
|
23 | 16 | function format() { |
|
24 | 17 | var str = this; |
|
25 | 18 | var len = arguments.length+1; |
@@ -50,12 +43,14 String.prototype.strip = function(char) | |||
|
50 | 43 | } |
|
51 | 44 | return this.replace(new RegExp('^'+char+'+|'+char+'+$','g'), ''); |
|
52 | 45 | } |
|
46 | ||
|
53 | 47 | String.prototype.lstrip = function(char) { |
|
54 | 48 | if(char === undefined){ |
|
55 | 49 | char = '\\s'; |
|
56 | 50 | } |
|
57 | 51 | return this.replace(new RegExp('^'+char+'+'),''); |
|
58 | 52 | } |
|
53 | ||
|
59 | 54 | String.prototype.rstrip = function(char) { |
|
60 | 55 | if(char === undefined){ |
|
61 | 56 | char = '\\s'; |
@@ -87,70 +82,6 var prevElementSibling = function( el ) | |||
|
87 | 82 | } |
|
88 | 83 | |
|
89 | 84 | /** |
|
90 | * SmartColorGenerator | |
|
91 | * | |
|
92 | *usage:: | |
|
93 | * var CG = new ColorGenerator(); | |
|
94 | * var col = CG.getColor(key); //returns array of RGB | |
|
95 | * 'rgb({0})'.format(col.join(',') | |
|
96 | * | |
|
97 | * @returns {ColorGenerator} | |
|
98 | */ | |
|
99 | var ColorGenerator = function(){ | |
|
100 | this.GOLDEN_RATIO = 0.618033988749895; | |
|
101 | this.CURRENT_RATIO = 0.22717784590367374 // this can be random | |
|
102 | this.HSV_1 = 0.75;//saturation | |
|
103 | this.HSV_2 = 0.95; | |
|
104 | this.color; | |
|
105 | this.cacheColorMap = {}; | |
|
106 | }; | |
|
107 | ||
|
108 | ColorGenerator.prototype = { | |
|
109 | getColor:function(key){ | |
|
110 | if(this.cacheColorMap[key] !== undefined){ | |
|
111 | return this.cacheColorMap[key]; | |
|
112 | } | |
|
113 | else{ | |
|
114 | this.cacheColorMap[key] = this.generateColor(); | |
|
115 | return this.cacheColorMap[key]; | |
|
116 | } | |
|
117 | }, | |
|
118 | _hsvToRgb:function(h,s,v){ | |
|
119 | if (s == 0.0) | |
|
120 | return [v, v, v]; | |
|
121 | i = parseInt(h * 6.0) | |
|
122 | f = (h * 6.0) - i | |
|
123 | p = v * (1.0 - s) | |
|
124 | q = v * (1.0 - s * f) | |
|
125 | t = v * (1.0 - s * (1.0 - f)) | |
|
126 | i = i % 6 | |
|
127 | if (i == 0) | |
|
128 | return [v, t, p] | |
|
129 | if (i == 1) | |
|
130 | return [q, v, p] | |
|
131 | if (i == 2) | |
|
132 | return [p, v, t] | |
|
133 | if (i == 3) | |
|
134 | return [p, q, v] | |
|
135 | if (i == 4) | |
|
136 | return [t, p, v] | |
|
137 | if (i == 5) | |
|
138 | return [v, p, q] | |
|
139 | }, | |
|
140 | generateColor:function(){ | |
|
141 | this.CURRENT_RATIO = this.CURRENT_RATIO+this.GOLDEN_RATIO; | |
|
142 | this.CURRENT_RATIO = this.CURRENT_RATIO %= 1; | |
|
143 | HSV_tuple = [this.CURRENT_RATIO, this.HSV_1, this.HSV_2] | |
|
144 | RGB_tuple = this._hsvToRgb(HSV_tuple[0],HSV_tuple[1],HSV_tuple[2]); | |
|
145 | function toRgb(v){ | |
|
146 | return ""+parseInt(v*256) | |
|
147 | } | |
|
148 | return [toRgb(RGB_tuple[0]),toRgb(RGB_tuple[1]),toRgb(RGB_tuple[2])]; | |
|
149 | ||
|
150 | } | |
|
151 | } | |
|
152 | ||
|
153 | /** | |
|
154 | 85 | * A customized version of PyRoutes.JS from https://pypi.python.org/pypi/pyroutes.js/ |
|
155 | 86 | * which is copyright Stephane Klein and was made available under the BSD License. |
|
156 | 87 | * |
@@ -292,7 +223,6 var pyroutes = (function() { | |||
|
292 | 223 | var route = matchlist[route_name]; |
|
293 | 224 | // param substitution |
|
294 | 225 | for(var i=0; i < route[1].length; i++) { |
|
295 | ||
|
296 | 226 | if (!params.hasOwnProperty(route[1][i])) |
|
297 | 227 | throw new Error(route[1][i] + ' missing in "' + route_name + '" route generation'); |
|
298 | 228 | } |
@@ -335,7 +265,6 var pyroutes = (function() { | |||
|
335 | 265 | })(); |
|
336 | 266 | |
|
337 | 267 | |
|
338 | ||
|
339 | 268 | /** |
|
340 | 269 | * GLOBAL YUI Shortcuts |
|
341 | 270 | */ |
@@ -344,16 +273,6 var YUD = YAHOO.util.Dom; | |||
|
344 | 273 | var YUE = YAHOO.util.Event; |
|
345 | 274 | var YUQ = YAHOO.util.Selector.query; |
|
346 | 275 | |
|
347 | // defines if push state is enabled for this browser ? | |
|
348 | var push_state_enabled = Boolean( | |
|
349 | window.history && window.history.pushState && window.history.replaceState | |
|
350 | && !( /* disable for versions of iOS before version 4.3 (8F190) */ | |
|
351 | (/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) | |
|
352 | /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ | |
|
353 | || (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) | |
|
354 | ) | |
|
355 | ); | |
|
356 | ||
|
357 | 276 | var _run_callbacks = function(callbacks){ |
|
358 | 277 | if (callbacks !== undefined){ |
|
359 | 278 | var _l = callbacks.length; |
@@ -450,8 +369,6 var ajaxGET = function(url,success) { | |||
|
450 | 369 | return request; |
|
451 | 370 | }; |
|
452 | 371 | |
|
453 | ||
|
454 | ||
|
455 | 372 | var ajaxPOST = function(url,postData,success) { |
|
456 | 373 | // Set special header for ajax == HTTP_X_PARTIAL_XHR |
|
457 | 374 | YUC.initHeader('X-PARTIAL-XHR',true); |
@@ -537,22 +454,7 var onSuccessFollow = function(target){ | |||
|
537 | 454 | } |
|
538 | 455 | } |
|
539 | 456 | |
|
540 | var toggleFollowingUser = function(target,fallows_user_id,token,user_id){ | |
|
541 | args = 'follows_user_id='+fallows_user_id; | |
|
542 | args+= '&auth_token='+token; | |
|
543 | if(user_id != undefined){ | |
|
544 | args+="&user_id="+user_id; | |
|
545 | } | |
|
546 | YUC.asyncRequest('POST',TOGGLE_FOLLOW_URL,{ | |
|
547 | success:function(o){ | |
|
548 | onSuccessFollow(target); | |
|
549 | } | |
|
550 | },args); | |
|
551 | return false; | |
|
552 | } | |
|
553 | ||
|
554 | 457 | var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){ |
|
555 | ||
|
556 | 458 | args = 'follows_repo_id='+fallows_repo_id; |
|
557 | 459 | args+= '&auth_token='+token; |
|
558 | 460 | if(user_id != undefined){ |
@@ -746,7 +648,6 var q_filter = function(target,nodes,dis | |||
|
746 | 648 | if(cnt){ |
|
747 | 649 | YUD.get('repo_count').innerHTML = showing; |
|
748 | 650 | } |
|
749 | ||
|
750 | 651 | } |
|
751 | 652 | }; |
|
752 | 653 | |
@@ -764,11 +665,6 var tableTr = function(cls, body){ | |||
|
764 | 665 | return _el.children[0].children[0].children[0]; |
|
765 | 666 | }; |
|
766 | 667 | |
|
767 | /** comments **/ | |
|
768 | var removeInlineForm = function(form) { | |
|
769 | form.parentNode.removeChild(form); | |
|
770 | }; | |
|
771 | ||
|
772 | 668 | var createInlineForm = function(parent_tr, f_path, line) { |
|
773 | 669 | var tmpl = YUD.get('comment-inline-form-template').innerHTML; |
|
774 | 670 | tmpl = tmpl.format(f_path, line); |
@@ -892,7 +788,6 var injectInlineForm = function(tr){ | |||
|
892 | 788 | YUD.setStyle('preview-container_'+lineno, 'display', 'none'); |
|
893 | 789 | }) |
|
894 | 790 | |
|
895 | ||
|
896 | 791 | setTimeout(function(){ |
|
897 | 792 | // callbacks |
|
898 | 793 | tooltip_activate(); |
@@ -1020,7 +915,6 var renderInlineComment = function(json_ | |||
|
1020 | 915 | var lineno = json_data['line_no']; |
|
1021 | 916 | var target_id = json_data['target_id']; |
|
1022 | 917 | placeInline(target_id, lineno, html); |
|
1023 | ||
|
1024 | 918 | }catch(e){ |
|
1025 | 919 | console.log(e); |
|
1026 | 920 | } |
@@ -1091,7 +985,6 var fileBrowserListeners = function(curr | |||
|
1091 | 985 | } |
|
1092 | 986 | |
|
1093 | 987 | F.updateFilter = function(e) { |
|
1094 | ||
|
1095 | 988 | return function(){ |
|
1096 | 989 | // Reset timeout |
|
1097 | 990 | F.filterTimeout = null; |
@@ -1101,10 +994,8 var fileBrowserListeners = function(curr | |||
|
1101 | 994 | var matches_max = 20; |
|
1102 | 995 | if (query != ""){ |
|
1103 | 996 | for(var i=0;i<nodes.length;i++){ |
|
1104 | ||
|
1105 | 997 | var pos = nodes[i].name.toLowerCase().indexOf(query) |
|
1106 | 998 | if(query && pos != -1){ |
|
1107 | ||
|
1108 | 999 | matches++ |
|
1109 | 1000 | //show only certain amount to not kill browser |
|
1110 | 1001 | if (matches > matches_max){ |
@@ -1138,7 +1029,6 var fileBrowserListeners = function(curr | |||
|
1138 | 1029 | YUD.setStyle('tbody','display',''); |
|
1139 | 1030 | YUD.setStyle('tbody_filtered','display','none'); |
|
1140 | 1031 | } |
|
1141 | ||
|
1142 | 1032 | } |
|
1143 | 1033 | }; |
|
1144 | 1034 | |
@@ -1205,7 +1095,6 var getIdentNode = function(n){ | |||
|
1205 | 1095 | }; |
|
1206 | 1096 | |
|
1207 | 1097 | var getSelectionLink = function(e) { |
|
1208 | ||
|
1209 | 1098 | //get selection from start/to nodes |
|
1210 | 1099 | if (typeof window.getSelection != "undefined") { |
|
1211 | 1100 | s = window.getSelection(); |
@@ -1475,7 +1364,6 var MembersAutoComplete = function (divi | |||
|
1475 | 1364 | }; |
|
1476 | 1365 | } |
|
1477 | 1366 | |
|
1478 | ||
|
1479 | 1367 | var MentionsAutoComplete = function (divid, cont, users_list, groups_list) { |
|
1480 | 1368 | var myUsers = users_list; |
|
1481 | 1369 | var myGroups = groups_list; |
@@ -1622,7 +1510,6 var MentionsAutoComplete = function (div | |||
|
1622 | 1510 | var re = new RegExp('(?:^@|\s@)([a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+)$') |
|
1623 | 1511 | var chunks = []; |
|
1624 | 1512 | |
|
1625 | ||
|
1626 | 1513 | // cut first chunk until curret pos |
|
1627 | 1514 | var to_max = msg.substr(0, max_pos); |
|
1628 | 1515 | var at_pos = Math.max(0,to_max.lastIndexOf('@')-1); |
@@ -1688,7 +1575,6 var addReviewMember = function(id,fname, | |||
|
1688 | 1575 | //only add if it's not there |
|
1689 | 1576 | members.innerHTML += element; |
|
1690 | 1577 | } |
|
1691 | ||
|
1692 | 1578 | } |
|
1693 | 1579 | |
|
1694 | 1580 | var removeReviewMember = function(reviewer_id, repo_name, pull_request_id){ |
@@ -1896,6 +1782,7 var fromHTML = function(html){ | |||
|
1896 | 1782 | _html.innerHTML = html; |
|
1897 | 1783 | return _html; |
|
1898 | 1784 | } |
|
1785 | ||
|
1899 | 1786 | var get_rev = function(node){ |
|
1900 | 1787 | var n = node.firstElementChild.firstElementChild; |
|
1901 | 1788 | |
@@ -1908,29 +1795,12 var get_rev = function(node){ | |||
|
1908 | 1795 | } |
|
1909 | 1796 | } |
|
1910 | 1797 | |
|
1911 | var get_name = function(node){ | |
|
1912 | var name = node.firstElementChild.children[2].innerHTML; | |
|
1913 | return name | |
|
1914 | } | |
|
1915 | var get_group_name = function(node){ | |
|
1916 | var name = node.firstElementChild.children[1].innerHTML; | |
|
1917 | return name | |
|
1918 | } | |
|
1919 | 1798 | var get_date = function(node){ |
|
1920 | 1799 | var date_ = YUD.getAttribute(node.firstElementChild,'date'); |
|
1921 | 1800 | return date_ |
|
1922 | 1801 | } |
|
1923 | 1802 | |
|
1924 | var get_age = function(node){ | |
|
1925 | return node | |
|
1926 | } | |
|
1927 | ||
|
1928 | var get_link = function(node){ | |
|
1929 | return node.firstElementChild.text; | |
|
1930 | } | |
|
1931 | ||
|
1932 | 1803 | var revisionSort = function(a, b, desc, field) { |
|
1933 | ||
|
1934 | 1804 | var a_ = fromHTML(a.getData(field)); |
|
1935 | 1805 | var b_ = fromHTML(b.getData(field)); |
|
1936 | 1806 | |
@@ -1942,6 +1812,7 var revisionSort = function(a, b, desc, | |||
|
1942 | 1812 | var compState = comp(a_, b_, desc); |
|
1943 | 1813 | return compState; |
|
1944 | 1814 | }; |
|
1815 | ||
|
1945 | 1816 | var ageSort = function(a, b, desc, field) { |
|
1946 | 1817 | var a_ = fromHTML(a.getData(field)); |
|
1947 | 1818 | var b_ = fromHTML(b.getData(field)); |
@@ -1973,31 +1844,6 var nameSort = function(a, b, desc, fiel | |||
|
1973 | 1844 | return compState; |
|
1974 | 1845 | }; |
|
1975 | 1846 | |
|
1976 | var permNameSort = function(a, b, desc, field) { | |
|
1977 | var a_ = fromHTML(a.getData(field)); | |
|
1978 | var b_ = fromHTML(b.getData(field)); | |
|
1979 | // extract name from table | |
|
1980 | ||
|
1981 | a_ = a_.children[0].innerHTML; | |
|
1982 | b_ = b_.children[0].innerHTML; | |
|
1983 | ||
|
1984 | var comp = YAHOO.util.Sort.compare; | |
|
1985 | var compState = comp(a_, b_, desc); | |
|
1986 | return compState; | |
|
1987 | }; | |
|
1988 | ||
|
1989 | var groupNameSort = function(a, b, desc, field) { | |
|
1990 | var a_ = fromHTML(a.getData(field)); | |
|
1991 | var b_ = fromHTML(b.getData(field)); | |
|
1992 | ||
|
1993 | // extract name from table | |
|
1994 | a_ = get_group_name(a_) | |
|
1995 | b_ = get_group_name(b_) | |
|
1996 | ||
|
1997 | var comp = YAHOO.util.Sort.compare; | |
|
1998 | var compState = comp(a_, b_, desc); | |
|
1999 | return compState; | |
|
2000 | }; | |
|
2001 | 1847 | var dateSort = function(a, b, desc, field) { |
|
2002 | 1848 | var a_ = fromHTML(a.getData(field)); |
|
2003 | 1849 | var b_ = fromHTML(b.getData(field)); |
@@ -2011,18 +1857,6 var dateSort = function(a, b, desc, fiel | |||
|
2011 | 1857 | return compState; |
|
2012 | 1858 | }; |
|
2013 | 1859 | |
|
2014 | var usernamelinkSort = function(a, b, desc, field) { | |
|
2015 | var a_ = fromHTML(a.getData(field)); | |
|
2016 | var b_ = fromHTML(b.getData(field)); | |
|
2017 | ||
|
2018 | // extract url text from string nodes | |
|
2019 | a_ = get_link(a_) | |
|
2020 | b_ = get_link(b_) | |
|
2021 | var comp = YAHOO.util.Sort.compare; | |
|
2022 | var compState = comp(a_, b_, desc); | |
|
2023 | return compState; | |
|
2024 | } | |
|
2025 | ||
|
2026 | 1860 | var addPermAction = function(_html, users_list, groups_list){ |
|
2027 | 1861 | var elmts = YUD.getElementsByClassName('last_new_member'); |
|
2028 | 1862 | var last_node = elmts[elmts.length-1]; |
@@ -2042,6 +1876,7 var addPermAction = function(_html, user | |||
|
2042 | 1876 | YUD.insertAfter(el, last_node); |
|
2043 | 1877 | } |
|
2044 | 1878 | } |
|
1879 | ||
|
2045 | 1880 | function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) { |
|
2046 | 1881 | var callback = { |
|
2047 | 1882 | success: function (o) { |
@@ -2074,11 +1909,10 function ajaxActionRevokePermission(url, | |||
|
2074 | 1909 | var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, |
|
2075 | 1910 | toQueryString(query_params)); |
|
2076 | 1911 | }; |
|
1912 | ||
|
2077 | 1913 | /* Multi selectors */ |
|
2078 | 1914 | |
|
2079 | 1915 | var MultiSelectWidget = function(selected_id, available_id, form_id){ |
|
2080 | ||
|
2081 | ||
|
2082 | 1916 | //definition of containers ID's |
|
2083 | 1917 | var selected_container = selected_id; |
|
2084 | 1918 | var available_container = available_id; |
@@ -2334,6 +2168,7 var YUI_paginator = function(links_per_p | |||
|
2334 | 2168 | }; |
|
2335 | 2169 | |
|
2336 | 2170 | })(); |
|
2171 | ||
|
2337 | 2172 | (function () { |
|
2338 | 2173 | |
|
2339 | 2174 | var Paginator = YAHOO.widget.Paginator, |
@@ -2494,7 +2329,6 var YUI_paginator = function(links_per_p | |||
|
2494 | 2329 | } |
|
2495 | 2330 | |
|
2496 | 2331 | |
|
2497 | ||
|
2498 | 2332 | // global hooks after DOM is loaded |
|
2499 | 2333 | |
|
2500 | 2334 | YUE.onDOMReady(function(){ |
@@ -2511,7 +2345,4 YUE.onDOMReady(function(){ | |||
|
2511 | 2345 | YUD.get(button).innerHTML = "↓ {0} ↓".format(_TM['Expand diff']); |
|
2512 | 2346 | } |
|
2513 | 2347 | }); |
|
2514 | ||
|
2515 | ||
|
2516 | ||
|
2517 | 2348 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now