forked from MarioRinaldi/rrjs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
103 lines (89 loc) · 2.63 KB
/
main.js
File metadata and controls
103 lines (89 loc) · 2.63 KB
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
var init = init || {};
var main = main || {};
var util = util || {};
var rr = rr || {};
// Specific inits
init.index = function() {
var hide = [
'popupMessage_0_div',
'popupMessage_1_div',
'popupMessage_2_div',
'popupMessage_3_div',
'popupMessage_4_div',
'popupMessage_5_div',
'popupMessage_6_div'
];
for (var i=0, len = hide.length;i < len;i++) {
rr.showHideElement(hide[i]);
}
};
/** * Atalho para document.getElmentById */
var $id = function(elem) {
return document.getElementById(elem);
};
/** * Inicialização automática (Usa jQuery, mas pode usar o main.addEvent no lugar) */
try{
if(typeof($) != "undefined") {
$(function(){
main.autoInit();
});
}else {
rr.addEvent(window, 'load', function(){
main.autoInit();
});
}
} catch(e) { };
/** * Inicializador automático (Não usa jQuery) */
main.autoInit = function() {
try {
var page = document.getElementsByTagName('body')[0];
if (typeof(page) != "undefined" && page.id && typeof(init) != "undefined" && typeof(init[page.id]) != "undefined") {
init[page.id].call();
} else if(typeof(console) != "undefined") {
console.info('Inicialização da página ' + page.id + ' não encontrada');
}
} catch (e) {
if(typeof(console) != "undefined") {
console.warn("Erro na inicialização");
console.info(e.message);
}
}
};
// Show/hide oldnews
util.showHideNews = function(elem, container, url, callback) {
rr.addEvent(elem, 'click', function(event){
if(event.preventDefault) { event.preventDefault(); }
rr.showHideElement(container);
if (rr.getStyle(container, 'display') != 'none') { rr.ajax.replaceContent(container, url, { callback: callback } ); }
return false;
});
};
main.showCode = function(v){
var div = v.id.replace(/_a/i,"_div");
rr.showHideElement(div);
//util.showHideNews('show-index-oldnews', 'index-oldnews', 'ajax/index-oldnews.php', init.index_oldnews );
};
var demo = {
okFunction: function() {
alert('OK clicado!');
},
cancelFunction: function() {
alert('CANCELAR clicado!');
},
noFunction: function() {
alert('NÃO clicado!');
},
yesFunction: function() {
alert('SIM clicado!');
},
displayArray: function (arr) {
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
}
},
displayAssoc: function (arr) {
for (var i in arr) {
alert(i + ' = ' + arr[i]);
}
}
};