您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

551 行
11 KiB

  1. <!doctype html>
  2. <html lang="en-au">
  3. <head>
  4. <title>jQuery.Gantt</title>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" >
  7. <link rel="stylesheet" href="css/style.css" />
  8. <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
  9. <link rel="stylesheet" href="http://taitems.github.com/UX-Lab/core/css/prettify.css" />
  10. <style type="text/css">
  11. body {
  12. font-family: Helvetica, Arial, sans-serif;
  13. font-size: 13px;
  14. padding: 0 0 50px 0;
  15. }
  16. .contain {
  17. width: 800px;
  18. margin: 0 auto;
  19. }
  20. h1 {
  21. margin: 40px 0 20px 0;
  22. }
  23. h2 {
  24. font-size: 1.5em;
  25. padding-bottom: 3px;
  26. border-bottom: 1px solid #DDD;
  27. margin-top: 50px;
  28. margin-bottom: 25px;
  29. }
  30. table th:first-child {
  31. width: 150px;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div class="contain">
  37. <h1>
  38. jQuery.Gantt
  39. <small>&mdash; Draw Gantt charts with the famous jQuery ease of development</small>
  40. </h1>
  41. <h2>Contributors</h2>
  42. <ul>
  43. <li>
  44. <strong><a href="http://mbielanczuk.com/" target="_blank">Marek Bielańczuk</a></strong> wrote the original jQuery.Gantt plugin that this version is based off of.
  45. </li>
  46. <li>
  47. <strong><a href="http://taitbrown.com/" target="_blank">Tait Brown</a></strong> enforced stricter code guidelines by validating the code, updating it to support HTML5 and tweaking the design.
  48. </li>
  49. <li>
  50. <strong><a href="mailto:leo.pfeifenberger@googlemail.com" target="_blank">Leo Pfeifenberger</a></strong> made <em>major</em> performance updates as well as adding requested features such as click events, state persisting via cookies and scrollToToday on load functionality.
  51. </li>
  52. </ul>
  53. <h2>
  54. Example
  55. </h2>
  56. <div class="gantt"></div>
  57. <h2>
  58. Gantt Configuration
  59. </h2>
  60. <pre class="prettyprint">
  61. $(".selector").gantt({
  62. source: "ajax/data.json",
  63. scale: "weeks",
  64. minScale: "weeks",
  65. maxScale: "months",
  66. onItemClick: function(data) {
  67. alert("Item clicked - show some details");
  68. },
  69. onAddClick: function(dt, rowId) {
  70. alert("Empty space clicked - add an item!");
  71. },
  72. onRender: function() {
  73. console.log("chart rendered");
  74. }
  75. });
  76. </pre>
  77. <table class="table table-striped">
  78. <thead>
  79. <tr>
  80. <th>
  81. Parameter
  82. </th>
  83. <th>
  84. Default
  85. </th>
  86. <th>
  87. Accepts Type
  88. </th>
  89. </tr>
  90. </thead>
  91. <tbody>
  92. <tr>
  93. <td>
  94. <code>source</code>
  95. </td>
  96. <td>
  97. null
  98. </td>
  99. <td>
  100. Array, String (url)
  101. </td>
  102. </tr>
  103. <tr>
  104. <td>
  105. <code>itemsPerPage</code>
  106. </td>
  107. <td>
  108. 7
  109. </td>
  110. <td>
  111. Number
  112. </td>
  113. </tr>
  114. <tr>
  115. <td>
  116. <code>months</code>
  117. </td>
  118. <td>
  119. ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  120. </td>
  121. <td>
  122. Array
  123. </td>
  124. </tr>
  125. <tr>
  126. <td>
  127. <code>dow</code>
  128. </td>
  129. <td>
  130. ["S", "M", "T", "W", "T", "F", "S"]
  131. </td>
  132. <td>
  133. Array
  134. </td>
  135. </tr>
  136. <tr>
  137. <td>
  138. <code>navigate</code>
  139. </td>
  140. <td>
  141. "buttons"
  142. </td>
  143. <td>
  144. String ("buttons","scroll")
  145. </td>
  146. </tr>
  147. <tr>
  148. <td>
  149. <code>scale</code>
  150. </td>
  151. <td>
  152. "days"
  153. </td>
  154. <td>
  155. String
  156. </td>
  157. </tr>
  158. <tr>
  159. <td>
  160. <code>maxScale</code>
  161. </td>
  162. <td>
  163. "months"
  164. </td>
  165. <td>
  166. String
  167. </td>
  168. </tr>
  169. <tr>
  170. <td>
  171. <code>minScale</code>
  172. </td>
  173. <td>
  174. "hours"
  175. </td>
  176. <td>
  177. String
  178. </td>
  179. </tr>
  180. <tr>
  181. <td>
  182. <code>waitText</code>
  183. </td>
  184. <td>
  185. "Please Wait..."
  186. </td>
  187. <td>
  188. String
  189. </td>
  190. </tr>
  191. <tr>
  192. <td>
  193. <code>onItemClick: </code>
  194. </td>
  195. <td>
  196. <code>function (data) { return; }</code></td>
  197. <td>
  198. a JS Function that gets called when clicking on a Gantt-Item. <br />The parameter passed to the function is the dataObj of the item</td>
  199. </tr>
  200. <tr>
  201. <td>
  202. <code>onAddClick</code></td>
  203. <td>
  204. <code>function (dt, rowId) { return; }</code></td>
  205. <td>
  206. a JS Function that gets called when clicking on a Gantt-Item. <br />The parameter passed to the function is the DateTime in ms for the clicked Cell, and the ID if the source object (row)</td>
  207. </tr>
  208. <tr>
  209. <td>
  210. <code>onRender</code></td>
  211. <td>
  212. <code>function () { return; }</code></td>
  213. <td>
  214. a JS Function called whenever the chart is (re)rendered</td>
  215. </tr>
  216. <tr>
  217. <td>
  218. <code>useCookie</code></td>
  219. <td>
  220. <code>false</code></td>
  221. <td>
  222. indicates if cookies should be used to track the chart's state (scale, scrollposition) between postpacks<br />
  223. <code>jquery.cookie.js</code> needs to be referenced for this to work</td>
  224. </tr>
  225. <tr>
  226. <td>
  227. <code>scrollToToday</code></td>
  228. <td>
  229. <code>true</code></td>
  230. <td>
  231. Boolean</td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. <h2>
  236. Source Configuration
  237. </h2>
  238. <pre class="prettyprint">
  239. source: [{
  240. name: "Example",
  241. desc: "Lorem ipsum dolor sit amet.",
  242. values: [ ... ]
  243. }]
  244. </pre>
  245. <table class="table table-striped">
  246. <thead>
  247. <tr>
  248. <th>
  249. Parameter
  250. </th>
  251. <th>
  252. Default
  253. </th>
  254. <th>
  255. Accepts Type
  256. </th>
  257. <th>
  258. Meaning
  259. </th>
  260. </tr>
  261. </thead>
  262. <tbody>
  263. <tr>
  264. <td>
  265. <code>name</code>
  266. </td>
  267. <td>
  268. null
  269. </td>
  270. <td>
  271. String
  272. </td>
  273. <td>
  274. Bold value in the left-most column of the gantt row.
  275. </td>
  276. </tr>
  277. <tr>
  278. <td>
  279. <code>desc</code>
  280. </td>
  281. <td>
  282. null
  283. </td>
  284. <td>
  285. String
  286. </td>
  287. <td>
  288. Secondary value in the gantt row.
  289. </td>
  290. </tr>
  291. <tr>
  292. <td>
  293. <code>values</code>
  294. </td>
  295. <td>
  296. null
  297. </td>
  298. <td>
  299. Array
  300. </td>
  301. <td>
  302. Collection of date ranges for gantt items. See next table.
  303. </td>
  304. </tr>
  305. </tbody>
  306. </table>
  307. <h2>
  308. Value Configuration
  309. </h2>
  310. <pre class="prettyprint">
  311. values: [{
  312. to: "/Date(1328832000000)/",
  313. from: "/Date(1333411200000)/",
  314. desc: "Something",
  315. label: "Example Value",
  316. customClass: "ganttRed",
  317. dataObj: foo.bar[i]
  318. }]
  319. </pre>
  320. <table class="table table-striped">
  321. <thead>
  322. <tr>
  323. <th>
  324. Parameter
  325. </th>
  326. <th>
  327. Accepts Type
  328. </th>
  329. <th>
  330. Meaning
  331. </th>
  332. </tr>
  333. </thead>
  334. <tbody>
  335. <tr>
  336. <td>
  337. <code>to</code>
  338. </td>
  339. <td>
  340. String (Date)
  341. </td>
  342. <td>
  343. -
  344. </td>
  345. </tr>
  346. <tr>
  347. <td>
  348. <code>from</code>
  349. </td>
  350. <td>
  351. String (Date)
  352. </td>
  353. <td>
  354. -
  355. </td>
  356. </tr>
  357. <tr>
  358. <td>
  359. <code>desc</code>
  360. </td>
  361. <td>
  362. String
  363. </td>
  364. <td>
  365. Text that appears on hover, I think?
  366. </td>
  367. </tr>
  368. <tr>
  369. <td>
  370. <code>label</code>
  371. </td>
  372. <td>
  373. String
  374. </td>
  375. <td>
  376. Appears on the gantt item.
  377. </td>
  378. </tr>
  379. <tr>
  380. <td>
  381. <code>customClass</code>
  382. </td>
  383. <td>
  384. String
  385. </td>
  386. <td>
  387. Custom class to be applied to the gantt item.
  388. </td>
  389. </tr>
  390. <tr>
  391. <td>
  392. <code>dataObj</code>
  393. </td>
  394. <td>
  395. All
  396. </td>
  397. <td>
  398. A data object that is applied directly to the gantt item.
  399. </td>
  400. </tr>
  401. </tbody>
  402. </table>
  403. </div>
  404. </body>
  405. <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
  406. <script src="js/jquery.fn.gantt.js"></script>
  407. <script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-tooltip.js"></script>
  408. <script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-popover.js"></script>
  409. <script src="http://taitems.github.com/UX-Lab/core/js/prettify.js"></script>
  410. <script>
  411. $(function() {
  412. "use strict";
  413. $(".gantt").gantt({
  414. source: [{
  415. name: "Sprint 0",
  416. desc: "Analysis",
  417. values: [{
  418. from: "/Date(1320192000000)/",
  419. to: "/Date(1322401600000)/",
  420. label: "Requirement Gathering",
  421. customClass: "ganttRed"
  422. }]
  423. },{
  424. name: " ",
  425. desc: "Scoping",
  426. values: [{
  427. from: "/Date(1322611200000)/",
  428. to: "/Date(1323302400000)/",
  429. label: "Scoping",
  430. customClass: "ganttRed"
  431. }]
  432. },{
  433. name: "Sprint 1",
  434. desc: "Development",
  435. values: [{
  436. from: "/Date(1323802400000)/",
  437. to: "/Date(1325685200000)/",
  438. label: "Development",
  439. customClass: "ganttGreen"
  440. }]
  441. },{
  442. name: " ",
  443. desc: "Showcasing",
  444. values: [{
  445. from: "/Date(1325685200000)/",
  446. to: "/Date(1325695200000)/",
  447. label: "Showcasing",
  448. customClass: "ganttBlue"
  449. }]
  450. },{
  451. name: "Sprint 2",
  452. desc: "Development",
  453. values: [{
  454. from: "/Date(1326785200000)/",
  455. to: "/Date(1325785200000)/",
  456. label: "Development",
  457. customClass: "ganttGreen"
  458. }]
  459. },{
  460. name: " ",
  461. desc: "Showcasing",
  462. values: [{
  463. from: "/Date(1328785200000)/",
  464. to: "/Date(1328905200000)/",
  465. label: "Showcasing",
  466. customClass: "ganttBlue"
  467. }]
  468. },{
  469. name: "Release Stage",
  470. desc: "Training",
  471. values: [{
  472. from: "/Date(1330011200000)/",
  473. to: "/Date(1336611200000)/",
  474. label: "Training",
  475. customClass: "ganttOrange"
  476. }]
  477. },{
  478. name: " ",
  479. desc: "Deployment",
  480. values: [{
  481. from: "/Date(1336611200000)/",
  482. to: "/Date(1338711200000)/",
  483. label: "Deployment",
  484. customClass: "ganttOrange"
  485. }]
  486. },{
  487. name: " ",
  488. desc: "Warranty Period",
  489. values: [{
  490. from: "/Date(1336611200000)/",
  491. to: "/Date(1349711200000)/",
  492. label: "Warranty Period",
  493. customClass: "ganttOrange"
  494. }]
  495. }],
  496. navigate: "scroll",
  497. scale: "weeks",
  498. maxScale: "months",
  499. minScale: "days",
  500. itemsPerPage: 10,
  501. onItemClick: function(data) {
  502. alert("Item clicked - show some details");
  503. },
  504. onAddClick: function(dt, rowId) {
  505. alert("Empty space clicked - add an item!");
  506. },
  507. onRender: function() {
  508. if (window.console && typeof console.log === "function") {
  509. console.log("chart rendered");
  510. }
  511. }
  512. });
  513. $(".gantt").popover({
  514. selector: ".bar",
  515. title: "I'm a popover",
  516. content: "And I'm the content of said popover."
  517. });
  518. prettyPrint();
  519. });
  520. </script>
  521. </html>