examples.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. if(!msgCt){
  23. // It's better to create the msg-div here in order to avoid re-layouts
  24. // later that could interfere with the HtmlEditor and reset its iFrame.
  25. msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
  26. }
  27. // var t = Ext.get('exttheme');
  28. // if(!t){ // run locally?
  29. // return;
  30. // }
  31. // var theme = Cookies.get('exttheme') || 'aero';
  32. // if(theme){
  33. // t.dom.value = theme;
  34. // Ext.getBody().addClass('x-'+theme);
  35. // }
  36. // t.on('change', function(){
  37. // Cookies.set('exttheme', t.getValue());
  38. // setTimeout(function(){
  39. // window.location.reload();
  40. // }, 250);
  41. // });
  42. //
  43. // var lb = Ext.get('lib-bar');
  44. // if(lb){
  45. // lb.show();
  46. // }
  47. }
  48. };
  49. }();
  50. Ext.onReady(Ext.example.init, Ext.example);
  51. Ext.example.shortBogusMarkup = '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, '+
  52. 'sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales '+
  53. 'non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet '+
  54. 'tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla.</p>';
  55. Ext.example.bogusMarkup = '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, '+
  56. 'porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, '+
  57. 'lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis '+
  58. 'vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>'+
  59. 'Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing '+
  60. 'eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt '+
  61. 'diam nec urna. Curabitur velit. Lorem ipsum dolor sit amet.</p>';
  62. // old school cookie functions
  63. var Cookies = {};
  64. Cookies.set = function(name, value){
  65. var argv = arguments;
  66. var argc = arguments.length;
  67. var expires = (argc > 2) ? argv[2] : null;
  68. var path = (argc > 3) ? argv[3] : '/';
  69. var domain = (argc > 4) ? argv[4] : null;
  70. var secure = (argc > 5) ? argv[5] : false;
  71. document.cookie = name + "=" + escape (value) +
  72. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  73. ((path == null) ? "" : ("; path=" + path)) +
  74. ((domain == null) ? "" : ("; domain=" + domain)) +
  75. ((secure == true) ? "; secure" : "");
  76. };
  77. Cookies.get = function(name){
  78. var arg = name + "=";
  79. var alen = arg.length;
  80. var clen = document.cookie.length;
  81. var i = 0;
  82. var j = 0;
  83. while(i < clen){
  84. j = i + alen;
  85. if (document.cookie.substring(i, j) == arg)
  86. return Cookies.getCookieVal(j);
  87. i = document.cookie.indexOf(" ", i) + 1;
  88. if(i == 0)
  89. break;
  90. }
  91. return null;
  92. };
  93. Cookies.clear = function(name) {
  94. if(Cookies.get(name)){
  95. document.cookie = name + "=" +
  96. "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  97. }
  98. };
  99. Cookies.getCookieVal = function(offset){
  100. var endstr = document.cookie.indexOf(";", offset);
  101. if(endstr == -1){
  102. endstr = document.cookie.length;
  103. }
  104. return unescape(document.cookie.substring(offset, endstr));
  105. };