examples.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Ext.example = function(){
  2. var msgCt;
  3. function createBox(t, s){
  4. // return ['<div class="msg">',
  5. // '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
  6. // '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
  7. // '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
  8. // '</div>'].join('');
  9. return '<div class="msg"><h3>' + t + '</h3><p>' + s + '</p></div>';
  10. }
  11. return {
  12. msg : function(title, format){
  13. if(!msgCt){
  14. msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
  15. }
  16. var s = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 1));
  17. var m = Ext.DomHelper.append(msgCt, createBox(title, s), true);
  18. m.hide();
  19. m.slideIn('t').ghost("t", { delay: 1000, remove: true});
  20. },
  21. init : function(){
  22. // var t = Ext.get('exttheme');
  23. // if(!t){ // run locally?
  24. // return;
  25. // }
  26. // var theme = Cookies.get('exttheme') || 'aero';
  27. // if(theme){
  28. // t.dom.value = theme;
  29. // Ext.getBody().addClass('x-'+theme);
  30. // }
  31. // t.on('change', function(){
  32. // Cookies.set('exttheme', t.getValue());
  33. // setTimeout(function(){
  34. // window.location.reload();
  35. // }, 250);
  36. // });
  37. //
  38. // var lb = Ext.get('lib-bar');
  39. // if(lb){
  40. // lb.show();
  41. // }
  42. }
  43. };
  44. }();
  45. Ext.example.shortBogusMarkup = '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, '+
  46. 'sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales '+
  47. 'non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet '+
  48. 'tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla.</p>';
  49. Ext.example.bogusMarkup = '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, '+
  50. 'porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, '+
  51. 'lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis '+
  52. 'vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>'+
  53. 'Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing '+
  54. 'eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt '+
  55. 'diam nec urna. Curabitur velit. Lorem ipsum dolor sit amet.</p>';
  56. //Ext.onReady(Ext.example.init, Ext.example);
  57. // old school cookie functions
  58. var Cookies = {};
  59. Cookies.set = function(name, value){
  60. var argv = arguments;
  61. var argc = arguments.length;
  62. var expires = (argc > 2) ? argv[2] : null;
  63. var path = (argc > 3) ? argv[3] : '/';
  64. var domain = (argc > 4) ? argv[4] : null;
  65. var secure = (argc > 5) ? argv[5] : false;
  66. document.cookie = name + "=" + escape (value) +
  67. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  68. ((path == null) ? "" : ("; path=" + path)) +
  69. ((domain == null) ? "" : ("; domain=" + domain)) +
  70. ((secure == true) ? "; secure" : "");
  71. };
  72. Cookies.get = function(name){
  73. var arg = name + "=";
  74. var alen = arg.length;
  75. var clen = document.cookie.length;
  76. var i = 0;
  77. var j = 0;
  78. while(i < clen){
  79. j = i + alen;
  80. if (document.cookie.substring(i, j) == arg)
  81. return Cookies.getCookieVal(j);
  82. i = document.cookie.indexOf(" ", i) + 1;
  83. if(i == 0)
  84. break;
  85. }
  86. return null;
  87. };
  88. Cookies.clear = function(name) {
  89. if(Cookies.get(name)){
  90. document.cookie = name + "=" +
  91. "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  92. }
  93. };
  94. Cookies.getCookieVal = function(offset){
  95. var endstr = document.cookie.indexOf(";", offset);
  96. if(endstr == -1){
  97. endstr = document.cookie.length;
  98. }
  99. return unescape(document.cookie.substring(offset, endstr));
  100. };