-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path51-sekme-cubugu.htm
More file actions
242 lines (171 loc) · 7.49 KB
/
51-sekme-cubugu.htm
File metadata and controls
242 lines (171 loc) · 7.49 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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html>
<head>
<title>Sekme Çubuğu</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- DIŞARIDAN YÜKLENEN KÜTÜPHANE DOSYALARI -->
<link rel="stylesheet" type="text/css" href="kutuphane/basic.css">
<script src="kutuphane/basic.js" type="text/javascript" charset="utf-8"></script>
<script>
/*
- tabs, tüm nesneyi taşıyan kutu.
- Bu nesne, iki parçaya bölünmüştür;
1. tabs.b1, butonları gruplayan, taşıyıcı kutu.
2. tabs.b2, içerik kutularını gruplayan taşıyıcı kutu
Böylece, butonları grup olarak ortalayabiliyor ve içerikleri yine grup
olarak kaydırabiliyorum.
- Buton isimleri ve genişlikleri tabBarButtons isimli diziden alınıyor.
Buton genişlikleri otomatik olarak HESAPLANMIYOR.
- Bir butona basıldığında, önceki basılı butonun arkaplan renginin,
hareketli olarak, basılan butonun arkasına getirmek için;
kayan parçayı farklı bir nesne yaptım. Ve butonların arka planlarını şeffaf yaptım.
- Her bir içeriği oluşturmak için, bir fonksiyon oluşturdum.
Böylece; her bir içerik, birbirinden bağımsız ve özel olarak oluşturulabilir.
*/
// Sekme çubuğu içerik boyutları
var TAB_CONTENT_WIDTH = 450
var TAB_CONTENT_HEIGHT = 300
// Sekme çubuğu
var tabs
// Sekme çubuğu, butonlar
var tabBarButtons = [
{id: 1, name: "Bilim", width: 90},
{id: 2, name: "Teknoloji", width: 120},
{id: 3, name: "Sanat", width: 100},
{id: 3, name: "?", width: 40}
]
// ÖZEL FONKSİYONLAR
// İlk çalışan fonksiyon.
var start = function() {
page.color = "whitesmoke"
// NESNE: Sekme çubuğu taşıyıcı
tabs = createBox(10, 10, TAB_CONTENT_WIDTH, TAB_CONTENT_HEIGHT + 60)
that.border = 0
that.color = "transparent"
// Butonların toplam genişliği hesaplanacak.
var buttonsTotalWidth = 0
// NESNE: Butonların taşıyıcısı
tabs.b1 = createBox(0, 0, 50, 50)
that.color = "white"
that.border = 0
that.round = 8
// NESNE: Seçili butonun arkasına hareket eden renkli kutu
tabs.b1.btnSelected = createBox(0, 0)
that.border = 2
that.borderColor = "white"
that.round = 8
that.height = 50
// İlk yüklenirken içerik hareketli olsun.
that.width = 10
that.color = "whitesmoke"
that.setMotion("left 0.5s, width 0.5s, background-color 0.5s")
// Butonları oluştur
for (var i = 0; i < tabBarButtons.length; i++) {
// NESNE: Buton
tabs.b1["btn" + i] = createButton(0, 0, tabBarButtons[i].width, 50)
that.left = buttonsTotalWidth
that.text = tabBarButtons[i].name
that.minimal = 1
that.round = 8
that.color = "transparent"
that.indexNumber = i
that.onClick(tabBarBtnClicked)
buttonsTotalWidth += that.width
}
// Taşıyıcıyı, butonların toplam genişliğine ayarla.
tabs.b1.width = buttonsTotalWidth
tabs.b1.center("left")
// İçeriklerin toplam genişliği hesaplanacak.
var contentsTotalWidth = 0
// NESNE: İçeriklerin taşıyıcısı
tabs.b2 = createBox(0, 60, 50, 50)
that.height = TAB_CONTENT_HEIGHT
that.round = 0
that.border = 0
// İlk yüklenirken içerik hareketli olsun.
that.left -= TAB_CONTENT_WIDTH / 2
that.setMotion("left 0.5s")
// İçerikleri oluştur
for (var i = 0; i < tabBarButtons.length; i++) {
// Her bir içerik için bir taşıyıcı
tabs.b2["box" + i] = createBox(0, 0, TAB_CONTENT_WIDTH, TAB_CONTENT_HEIGHT)
that.left = contentsTotalWidth
that.border = 0
that.round = 4
contentsTotalWidth += TAB_CONTENT_WIDTH
}
// Taşıyıcıyı, içeriklerin toplam genişline ayala.
tabs.b2.width = contentsTotalWidth
// İçerik taşıyıcıların , içlerini dolduran fonksiyonlar.
createBox0Content()
createBox1Content()
createBox2Content()
createBox3Content()
tabs.center()
page.onResize(centerAll)
// Başlangıçta, ilk butona basılmış gibi ayarla.
tabs.withMotion(function(self) {
tabBarBtnClicked(tabs.b1.btn0)
})
}
// DİĞER FONKSİYONLAR
var centerAll = function() {
tabs.center()
}
// Butona basıldığında, gereken işlemleri yap.
var tabBarBtnClicked = function(self) {
// Renkli kutuyu, butonun konum ve boyutuna getir.
tabs.b1.btnSelected.left = self.left
tabs.b1.btnSelected.width = self.width
// Renkli kutunun rengini, içerik kutusunun rengi ile aynı yap.
tabs.b1.btnSelected.color = tabs.b2["box" + self.indexNumber].color
// Basılan butona göre, içeriği hareket ettir.
tabs.b2.left = (self.indexNumber * TAB_CONTENT_WIDTH) * -1
}
var createBox0Content = function() {
var box = tabs.b2.box0
box.color = "Lavender"
box.lblTitle = createLabel()
that.text = "İçerik 1"
that.textAlign = "center"
that.height = 30
that.center()
// Bu kutunun içini burada doldur.
}
var createBox1Content = function() {
var box = tabs.b2.box1
box.color = "PaleTurquoise"
box.lblTitle = createLabel()
that.text = "İçerik 2"
that.textAlign = "center"
that.height = 30
that.center()
// Bu kutunun içini burada doldur.
}
var createBox2Content = function() {
var box = tabs.b2.box2
box.color = "Bisque"
box.lblTitle = createLabel()
that.text = "İçerik 3"
that.textAlign = "center"
that.height = 30
that.center()
// Bu kutunun içini burada doldur.
}
var createBox3Content = function() {
var box = tabs.b2.box3
box.color = "whitesmoke"
box.lblTitle = createLabel()
that.text = "İçerik 4"
that.textAlign = "center"
that.height = 30
that.center()
// Bu kutunun içini burada doldur.
}
</script>
</head>
<body>
<!-- HTML içeriği -->
</body>
</html>