mix.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>jQuery UI Portlet</title>
  6. <!-- jquery 1.4 and jquery ui 1.8 -->
  7. <link rel="stylesheet" href="../lib/themes/1.8/start/jquery-ui-1.8.5.custom.css" />
  8. <link rel="stylesheet" href="../css/jquery.portlet.css?v=1.1.3" />
  9. <script src="../lib/jquery-1.4.4.min.js" type="text/javascript"></script>
  10. <script src="../lib/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
  11. <!--<link rel="stylesheet" href="../lib/themes/1.9/start/jquery-ui-1.9.1.custom.min.css" />-->
  12. <!--<script src="../lib/jquery-1.8.3.js" type="text/javascript"></script>-->
  13. <!--<script src="../lib/themes/jquery-ui-1.9.1.custom.min.js" type="text/javascript"></script>-->
  14. <script src="../script/jquery.portlet.pack.js?v=1.1.3"></script>
  15. <style>
  16. body {font-size: 13px;}
  17. .highlight-content {color: red;}
  18. </style>
  19. <script>
  20. $(function() {
  21. $('#portlet-demo').portlet({
  22. sortable: true,
  23. create: function() {
  24. //alert('created portlet.');
  25. },
  26. removeItem: function() {
  27. alert('after remove');
  28. },
  29. columns: [{
  30. width: 250,
  31. portlets: [{
  32. attrs: {
  33. id: 'feeds'
  34. },
  35. title: function() {
  36. var d = new Date();
  37. return 'Feeds(' + (d.getMonth() + 1) + '-' + d.getDay() + '日)';
  38. },
  39. icon: 'ui-icon-signal-diag',
  40. content: {
  41. //设置区域内容属性
  42. style: {
  43. height: '200px'
  44. },
  45. type: 'text',
  46. text: '<ul><li>Feed item 1</li><li>Feed item 2</li></ul>',
  47. beforeShow: function(aa) {
  48. //alert('before show, content is: ' + aa);
  49. },
  50. afterShow: function() {
  51. //alert('after show');
  52. }
  53. },
  54. scripts: ['loaded-by-portlet.js']
  55. }, {
  56. attrs: {
  57. id: 'news'
  58. },
  59. title: 'News',
  60. beforeRefresh: function() {
  61. alert("before refresh");
  62. },
  63. afterRefresh: function(data) {
  64. //alert("after refresh: " + data);
  65. },
  66. content: {
  67. style: {
  68. height: '200'
  69. },
  70. type: 'text',
  71. text: function() {
  72. return $('#newsTemplate').html();
  73. //return $('#newsTemplate ul');
  74. }
  75. }
  76. }]
  77. }, {
  78. width: 200,
  79. portlets: [{
  80. title: 'Shopping',
  81. content: {
  82. attrs: {
  83. 'class': 'highlight-content'
  84. },
  85. type: 'text',
  86. text: 'Shopping contens<br/>Shopping contens<br/>Shopping contens<br/>Shopping contens<br/>'
  87. }
  88. }]
  89. }, {
  90. width: 350,
  91. portlets: [{
  92. title: 'Ajax',
  93. content: {
  94. type: 'ajax',
  95. url: 'ajax.html'
  96. }
  97. }, {
  98. title: 'Ajax 错误',
  99. content: {
  100. type: 'ajax',
  101. url: 'noexsit.html',
  102. error: function() {
  103. $(this).append('<br/><br/>捕获到ajax错误');
  104. // alert('出错了');
  105. }
  106. }
  107. }, {
  108. title: 'Ajax Json Datas',
  109. content: {
  110. type: 'ajax',
  111. dataType: 'json',
  112. url: 'ajax.json',
  113. formatter: function(o, pio, data) {
  114. var ct = "<ul>";
  115. $.each(data, function() {
  116. ct += "<li>" + this.text + "</li>";
  117. });
  118. return ct + "</ul>";
  119. }
  120. }
  121. }]
  122. }]
  123. });
  124. });
  125. </script>
  126. </head>
  127. <body>
  128. <div class="ui-state-highlight ui-corner-all" style="padding: 0 .7em;">
  129. <p>
  130. 插件混合演示
  131. </p>
  132. </div>
  133. <hr class='ui-widget-content' />
  134. <div id='portlet-demo'></div>
  135. <!-- 模板 -->
  136. <div id="newsTemplate" style="display:none">
  137. <ul>
  138. <li><a href='http://www.kafeitu.me/'>http://www.kafeitu.me</a></li>
  139. <li><a href='https://github.com/henryyan'>https://github.com/henryyan</a></li>
  140. </ul>
  141. </div>
  142. </body>
  143. </html>