jyr (owner)

Revisions

gist: 182630 Download_button fork
public
Public Clone URL: git://gist.github.com/182630.git
Embed All Files: show embed
jquery.simplagui.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**Dependencias
*
* Gritter
* blockUi - http://malsup.com/jquery/block/
*
*/
(function($){
    $.fn.gui = function(attr)
    {
 
        var settings = {method: '', id: '', url: '', title: '', text: '', image: '', sticky: '', time: '', module: '', action: '', status: '' };
        parameters = jQuery.extend(settings, attr);
        /*var options = new Array();
options['add'] = add();
options['close']= close();
options['remove']= block();
options['growl'] = growl();
alert(options);*/
        
        if (parameters.method == 'add'){
            add();
        }
 
        if(parameters.method == 'close'){
            close();
        }
        
        if(parameters.method == 'remove'){
            remove();
        }
 
        if(parameters.method == 'block'){
            block();
        }
        
        if(parameters.method == 'growl')
        {
            growl();
        }
        
        if(parameters.method == 'pagination')
        {
            pagination();
        }
 
        if(parameters.method == 'run')
        {
            run();
        }
        
        if(parameters.method == 'checkall')
        {
            checkall();
        }
 
        //Agrega tab
        function add()
        {
            url = "/backend/"+parameters.module+"/"+parameters.action+"/"+parameters.id;
     $('ul.content-box-tabs li a.default-tab').removeClass('current'); // Remove "current" class from all tabs
            $('ul.content-box-tabs').append('<li><a class="current current-tab" href="'+url+'">'+parameters.title+'</a></li>');
     $('.content-box-content').load('/backend/'+ parameters.module +'/'+ parameters.action +'/'+ parameters.id);
        }
        
        //Cerrar tab
        function close()
        {
            $('.current').remove();
            $('ul.content-box-tabs li a.default-tab').addClass('current');
            $('.tab-content').load('/backend/'+ parameters.module +'/list/');
        }
        
        //Eliminar un registro
        function remove()
        {
            module = parameters.module;
     action = parameters.action;
     id = parameters.id;
            
            $.getJSON('/backend/'+ module +'/delete/'+id,function(json){
         $().gui({method:'growl', title: json.title, text: json.text, image:json.image, sticky:false});
                $().gui({method: 'run', id: id, module: module, action: action});
            });
        }
        
        function block()
        {
            $.blockUI({message: $('#question'),
     ceterY: 0,
     css: {
                        width: '280px',
                        height: '65px',
                        top: '15px',
                        left: '',
                        right: '20px',
                        //padding: '5px',
                        border: '1px solid color #fff',
                        backgroundColor: '#000',
                        '-webkit-border-radius': '10px',
                        '-moz-border-radius': '10px',
                    }
             });
        }
        
        //Notificaciones
        function growl()
        {
            var unique_id = $.gritter.add({
     title: parameters.title,
     text: parameters.text,
     image: parameters.image,
     sticky: parameters.sticky,
     time: parameters.time
     });
     return false;
        }
        
        //Paginacion
        function pagination()
        {
            $('.tab-content').load(parameters.url);
        }
        
        //Ejecuta una accion desde un select
        function run()
        {
     module = parameters.module;
     action = parameters.action;
     id = parameters.id;
    
     $('.tab-content').load("/backend/"+ module +"/list/");
        }
        
        //Selecciona todos los checbox
        function checkall()
        {
     $("input[name='check[]']").each(function(){
     this.checked = parameters.status;
     });
        }
    };
})(jQuery);