source: trunk/web/addons/job_monarch/lib/extjs/examples/shared/examples.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

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