toolbar_test.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>W2UI Demo: toolbar-3</title>
  5. <link rel="stylesheet" type="text/css" href="http://w2ui.com/src/w2ui-1.4.2.min.css" />
  6. <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
  7. <script type="text/javascript" src="http://w2ui.com/src/w2ui-1.4.2.min.js"></script>
  8. </head>
  9. <body>
  10. <div id="toolbar" style="padding: 4px; border: 1px solid silver; border-radius: 3px"></div>
  11. <script type="text/javascript">
  12. $(function () {
  13. var btnCount = 0;
  14. $('#toolbar').w2toolbar({
  15. name: 'toolbar',
  16. items: [
  17. { type: 'button', id: 'append', caption: 'Append', icon: 'w2ui-icon-plus' },
  18. { type: 'button', id: 'insert', caption: 'Insert', icon: 'w2ui-icon-plus' },
  19. { type: 'button', id: 'delete', caption: 'Delete', icon: 'w2ui-icon-cross' },
  20. { type: 'break', id: 'break0' },
  21. { type: 'break', id: 'break1' }
  22. ],
  23. onClick: function (event) {
  24. console.log(event.target);
  25. switch (event.target) {
  26. case 'append':
  27. this.add({ type: 'button', id: 'button' + btnCount, caption: 'button '+ btnCount, img: 'icon-page' });
  28. btnCount++;
  29. break;
  30. case 'insert':
  31. this.insert('break1', { type: 'button', id: 'button' + btnCount, caption: 'button '+ btnCount, img: 'icon-page' });
  32. btnCount++;
  33. break;
  34. case 'delete':
  35. if (btnCount <= 0) return;
  36. btnCount--;
  37. this.remove('button'+ btnCount);
  38. break;
  39. }
  40. }
  41. });
  42. });
  43. </script>
  44. </body>
  45. </html>