forked from cocoo/easyui-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel.html
574 lines (530 loc) · 17.9 KB
/
panel.html
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>panel</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/SyntaxHighlighter.css" />
<script type="text/javascript" src="js/shCore.js"></script>
<script type="text/javascript" src="js/shBrushJScript.js"></script>
<script type="text/javascript" src="js/shBrushXml.js"></script>
</head>
<body style="text-align:left">
<div style="padding:10px">
<h3>Panel</h3>
<p>Override defaults with $.fn.panel.defaults.</p>
<p>
The panel is used as a container for other contents.
It is the base component for building other components such as layout, tabs, accordion, etc.
It also provides built-in collapsible, closable, maximizable and minimizable behavior and other customized behavior.
Panels can be easily embedded into any position of web page.
</p>
<img src="images/panel.png">
<h4>Usage Example</h4>
<h5>Create Panel</h5>
<p>1. Create Panel via markup</p>
<p>Creation from markup is even easier. Add 'easyui-panel' class to <div/> markup.</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">div</span><span> </span><span class="attribute">id</span><span>=</span><span class="attribute-value">"p"</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"easyui-panel"</span><span> </span><span class="attribute">title</span><span>=</span><span class="attribute-value">"My Panel"</span><span> </span></span></li><li class=""><span> <span class="attribute">style</span><span>=</span><span class="attribute-value">"width:500px;height:150px;padding:10px;background:#fafafa;"</span><span> </span></span></li><li class="alt"><span> <span class="attribute">data-options</span><span>="iconCls:'icon-save',closable:true, </span></span></li><li class=""><span> collapsible:true,minimizable:true,maximizable:true"<span class="tag">></span><span> </span></span></li><li class="alt"><span> <span class="tag"><</span><span class="tag-name">p</span><span class="tag">></span><span>panel content.</span><span class="tag"></</span><span class="tag-name">p</span><span class="tag">></span><span> </span></span></li><li class=""><span> <span class="tag"><</span><span class="tag-name">p</span><span class="tag">></span><span>panel content.</span><span class="tag"></</span><span class="tag-name">p</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"></</span><span class="tag-name">div</span><span class="tag">></span><span> </span></span></li></ol></div><textarea class="html" name="code-panel" style="display: none;"> <div id="p" class="easyui-panel" title="My Panel"
style="width:500px;height:150px;padding:10px;background:#fafafa;"
data-options="iconCls:'icon-save',closable:true,
collapsible:true,minimizable:true,maximizable:true">
<p>panel content.</p>
<p>panel content.</p>
</div>
</textarea>
<p>2. Create Panel programatically</p>
<p>Let's create panel with tools on top right.</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span><div id=</span><span class="string">"p"</span><span> style=</span><span class="string">"padding:10px;"</span><span>> </span></span></li><li class=""><span> <p>panel content.</p> </span></li><li class="alt"><span> <p>panel content.</p> </span></li><li class=""><span></div> </span></li><li class="alt"><span> </span></li><li class=""><span>$(<span class="string">'#p'</span><span>).panel({ </span></span></li><li class="alt"><span> width:500, </span></li><li class=""><span> height:150, </span></li><li class="alt"><span> title: <span class="string">'My Panel'</span><span>, </span></span></li><li class=""><span> tools: [{ </span></li><li class="alt"><span> iconCls:<span class="string">'icon-add'</span><span>, </span></span></li><li class=""><span> handler:<span class="keyword">function</span><span>(){alert(</span><span class="string">'new'</span><span>)} </span></span></li><li class="alt"><span> },{ </span></li><li class=""><span> iconCls:<span class="string">'icon-save'</span><span>, </span></span></li><li class="alt"><span> handler:<span class="keyword">function</span><span>(){alert(</span><span class="string">'save'</span><span>)} </span></span></li><li class=""><span> }] </span></li><li class="alt"><span>}); </span></li></ol></div><textarea class="js" name="code-panel" style="display: none;"> <div id="p" style="padding:10px;">
<p>panel content.</p>
<p>panel content.</p>
</div>
$('#p').panel({
width:500,
height:150,
title: 'My Panel',
tools: [{
iconCls:'icon-add',
handler:function(){alert('new')}
},{
iconCls:'icon-save',
handler:function(){alert('save')}
}]
});
</textarea>
<br>
<h5>Move Panel</h5>
<p>Call 'move' method to move panel to a new position</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span>$(</span><span class="string">'#p'</span><span>).panel(</span><span class="string">'move'</span><span>,{ </span></span></li><li class=""><span> left:100, </span></li><li class="alt"><span> top:100 </span></li><li class=""><span>}); </span></li></ol></div><textarea class="js" name="code-panel" style="display: none;"> $('#p').panel('move',{
left:100,
top:100
});
</textarea>
<br>
<h5>Load Content</h5>
<p>Let's load the panel content via ajax and show some message when loaded successfully.</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span>$(</span><span class="string">'#p'</span><span>).panel({ </span></span></li><li class=""><span> href:<span class="string">'content_url.php'</span><span>, </span></span></li><li class="alt"><span> onLoad:<span class="keyword">function</span><span>(){ </span></span></li><li class=""><span> alert(<span class="string">'loaded successfully'</span><span>); </span></span></li><li class="alt"><span> } </span></li><li class=""><span>}); </span></li></ol></div><textarea class="js" name="code-panel" style="display: none;"> $('#p').panel({
href:'content_url.php',
onLoad:function(){
alert('loaded successfully');
}
});
</textarea>
<p> </p>
<h4>Properties</h4>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Type</strong></th>
<th><strong>Description</strong></th>
<th><strong>Default</strong></th>
</tr>
<tr>
<td>id</td>
<td>string</td>
<td>The id attribute of this panel.</td>
<td>null</td>
</tr>
<tr>
<td>title</td>
<td>string</td>
<td>The title text to display in panel header.</td>
<td>null</td>
</tr>
<tr>
<td>iconCls</td>
<td>string</td>
<td>A CSS class to display a 16x16 icon in panel.</td>
<td>null</td>
</tr>
<tr>
<td>width</td>
<td>number</td>
<td>Set the panel width.</td>
<td>auto</td>
</tr>
<tr>
<td>height</td>
<td>number</td>
<td>Set the panel height.</td>
<td>auto</td>
</tr>
<tr>
<td>left</td>
<td>number</td>
<td>Set the panel left position.</td>
<td>null</td>
</tr>
<tr>
<td>top</td>
<td>number</td>
<td>Set the panel top position.</td>
<td>null</td>
</tr>
<tr>
<td>cls</td>
<td>string</td>
<td>Add a CSS class to the panel.</td>
<td>null</td>
</tr>
<tr>
<td>headerCls</td>
<td>string</td>
<td>Add a CSS class to the panel header.</td>
<td>null</td>
</tr>
<tr>
<td>bodyCls</td>
<td>string</td>
<td>Add a CSS class to the panel body.</td>
<td>null</td>
</tr>
<tr>
<td>style</td>
<td>object</td>
<td>
Add a custom specification style to the panel.
<p>Code example to change the panel border width:</p>
<pre style="color:#006600"><div class="easyui-panel" style="width:200px;height:100px"
data-options="style:{borderWidth:2}">
</div>
</pre>
</td>
<td>{}</td>
</tr>
<tr>
<td>fit</td>
<td>boolean</td>
<td>
When true to set the panel size fit it's parent container.
The example below shows a panel which can be auto resized to max inner dimensions of its parent container
<pre style="color:#006600"><div style="width:200px;height:100px;padding:5px">
<div class="easyui-panel" style="width:200px;height:100px"
data-options="fit:true,border:false">
Embedded Panel
</div>
</div>
</pre>
</td>
<td>false</td>
</tr>
<tr>
<td>border</td>
<td>boolean</td>
<td>Defines if to show panel border.</td>
<td>true</td>
</tr>
<tr>
<td>doSize</td>
<td>boolean</td>
<td>If set to true,the panel will be resize and do layout when created.</td>
<td>true</td>
</tr>
<tr>
<td>noheader</td>
<td>boolean</td>
<td>If set to true, the panel header will not be created.</td>
<td>false</td>
</tr>
<tr>
<td>content</td>
<td>string</td>
<td>The panel body content.</td>
<td>null</td>
</tr>
<tr>
<td>collapsible</td>
<td>boolean</td>
<td>Defines if to show collapsible button.</td>
<td>false</td>
</tr>
<tr>
<td>minimizable</td>
<td>boolean</td>
<td>Defines if to show minimizable button.</td>
<td>false</td>
</tr>
<tr>
<td>maximizable</td>
<td>boolean</td>
<td>Defines if to show maximizable button.</td>
<td>false</td>
</tr>
<tr>
<td>closable</td>
<td>boolean</td>
<td>Defines if to show closable button.</td>
<td>false</td>
</tr>
<tr>
<td>tools</td>
<td>array,selector</td>
<td>
Custom tools, possible values:<br>
1) an array, each element contains iconCls and handler properties. <br>
2) a selector that indicating the tools<br>
<p>The panel tools can be declared with exists <div> tag:</p>
<pre><div class="easyui-panel" style="width:300px;height:200px"
title="My Panel" data-options="iconCls:'icon-ok',tools:'#tt'">
</div>
<div id="tt">
<a href="#" class="icon-add" onclick="javascript:alert('add')"></a>
<a href="#" class="icon-edit" onclick="javascript:alert('edit')"></a>
</div>
</pre>
<p>The panel tools can also be defined via array:</p>
<pre><div class="easyui-panel" style="width:300px;height:200px"
title="My Panel" data-options="iconCls:'icon-ok',tools:[
{
iconCls:'icon-add',
handler:function(){alert('add')}
},{
iconCls:'icon-edit',
handler:function(){alert('edit')}
}]">
</div>
</pre>
</td>
<td>[]</td>
</tr>
<tr>
<td>collapsed</td>
<td>boolean</td>
<td>Defines if the panel is collapsed at initialization.</td>
<td>false</td>
</tr>
<tr>
<td>minimized</td>
<td>boolean</td>
<td>Defines if the panel is minimized at initialization.</td>
<td>false</td>
</tr>
<tr>
<td>maximized</td>
<td>boolean</td>
<td>Defines if the panel is maximized at initialization.</td>
<td>false</td>
</tr>
<tr>
<td>closed</td>
<td>boolean</td>
<td>Defines if the panel is closed at initialization.</td>
<td>false</td>
</tr>
<tr>
<td>href</td>
<td>string</td>
<td>
A URL to load remote data and then display in the panel.
Notice that the content will not be loaded until the panel is open and expand.
This is useful to create a lazy loading panel:
<pre><div id="pp" class="easyui-panel" style="width:300px;height:200px"
data-options="href='get_content.php',closed:true">
</div>
<a href="#" onclick="javascript:$('#pp').panel('open')">Open</a>
</pre>
</td>
<td>null</td>
</tr>
<tr>
<td>cache</td>
<td>boolean</td>
<td>True to cache the panel content that loaded from href.</td>
<td>true</td>
</tr>
<tr>
<td>loadingMessage</td>
<td>string</td>
<td>When loading remote data show a message in the panel.</td>
<td>Loading¡</td>
</tr>
<tr>
<td>extractor</td>
<td>function</td>
<td>
Defines how to extract the content from ajax response, return extracted data.
<pre>extractor: function(data){
var pattern = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
var matches = pattern.exec(data);
if (matches){
return matches[1]; // only extract body content
} else {
return data;
}
}
</pre>
</td>
<td></td>
</tr>
</tbody></table>
<h4>Events</h4>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameters</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>onLoad</td>
<td>none</td>
<td>Fires when remote data is loaded.</td>
</tr>
<tr>
<td>onBeforeOpen</td>
<td>none</td>
<td>Fires before panel is opened, return false to stop the open.</td>
</tr>
<tr>
<td>onOpen</td>
<td>none</td>
<td>Fires after panel is opened.</td>
</tr>
<tr>
<td>onBeforeClose</td>
<td>none</td>
<td>
Fires before panel is closed, return false to cancel the close.
The panel declared below cannot be closed.
<pre><div class="easyui-panel" style="width:300px;height:200px;"
title="My Panel" data-options="onBeforeClose:function(){return false}">
The panel cannot be closed.
</div>
</pre>
</td>
</tr>
<tr>
<td>onClose</td>
<td>none</td>
<td>Fires after panel is closed.</td>
</tr>
<tr>
<td>onBeforeDestroy</td>
<td>none</td>
<td>Fires before panel is destroyed, return false to cancel the destroy.</td>
</tr>
<tr>
<td>onDestroy</td>
<td>none</td>
<td>Fires after panel is destroyed.</td>
</tr>
<tr>
<td>onBeforeCollapse</td>
<td>none</td>
<td>Fires before panel is collapsed, return false to stop the collapse.</td>
</tr>
<tr>
<td>onCollapse</td>
<td>none</td>
<td>Fires after panel is collpased.</td>
</tr>
<tr>
<td>onBeforeExpand</td>
<td>none</td>
<td>Fires before panel is expanded, return false to stop the expand.</td>
</tr>
<tr>
<td>onExpand</td>
<td>none</td>
<td>Fires after panel is expanded.</td>
</tr>
<tr>
<td>onResize</td>
<td>width, height</td>
<td>Fires after panel is resized.<br>
width: the new outer width<br>
height: the new outer height</td>
</tr>
<tr>
<td>onMove</td>
<td>left,top</td>
<td>Fires after panel is moved.<br>
left: the new left postion<br>
top: the new top position</td>
</tr>
<tr>
<td>onMaximize</td>
<td>none</td>
<td>Fires after the window has been maximized.</td>
</tr>
<tr>
<td>onRestore</td>
<td>none</td>
<td>Fires after the window has been restored to its original size.</td>
</tr>
<tr>
<td>onMinimize</td>
<td>none</td>
<td>Fires after the window has been minimized.</td>
</tr>
</tbody></table>
<h4>Methods</h4>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameter</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>options</td>
<td>none</td>
<td>Return options property.</td>
</tr>
<tr>
<td>panel</td>
<td>none</td>
<td>Return the outer panel object.</td>
</tr>
<tr>
<td>header</td>
<td>none</td>
<td>Return the panel header object.</td>
</tr>
<tr>
<td>body</td>
<td>none</td>
<td>Return the panel body object.</td>
</tr>
<tr>
<td>setTitle</td>
<td>title</td>
<td>Set the title text of header.</td>
</tr>
<tr>
<td>open</td>
<td>forceOpen</td>
<td>When forceOpen parameter set to true, the panel is opened bypass the onBeforeOpen callback.</td>
</tr>
<tr>
<td>close</td>
<td>forceClose</td>
<td>When forceClose parameter set to true, the panel is closed bypass the onBeforeClose callback.</td>
</tr>
<tr>
<td>destroy</td>
<td>forceDestroy</td>
<td>When forceDestroy parameter set to true, the panel is destroyed bypass the onBeforeDestroy callback.</td>
</tr>
<tr>
<td>refresh</td>
<td>href</td>
<td>
Refresh the panel to load remote data.
If the 'href' parameter is assigned, it will override the old 'href' property.
<p>Code example:</p>
<pre>// open a panel and then refresh its contents.
$('#pp').panel('open').panel('refresh');
// refresh contents with a new URL.
$('#pp').panel('open').panel('refresh','new_content.php');
</pre>
</td>
</tr>
<tr>
<td>resize</td>
<td>options</td>
<td>Set panel size and do layout. The options object contains following properties:<br>
width: the new panel width<br>
height: the new panel height<br>
left: the new panel left position<br>
top: the new panel top position
<p>Code example:</p>
<pre>$('#pp').panel('resize',{
width: 600,
height: 400
});
</pre>
</td>
</tr>
<tr>
<td>move</td>
<td>options</td>
<td>Move the panel to a new position. The options object contains following properties:<br>
left: the new panel left position<br>
top: the new panel top position</td>
</tr>
<tr>
<td>maximize</td>
<td>none</td>
<td>Fits the panel winthin its container.</td>
</tr>
<tr>
<td>minimize</td>
<td>none</td>
<td>Minimizing the panel.</td>
</tr>
<tr>
<td>restore</td>
<td>none</td>
<td>Restores the maximized panel back to its original size and position.</td>
</tr>
<tr>
<td>collapse</td>
<td>animate</td>
<td>Collapses the panel body.</td>
</tr>
<tr>
<td>expand</td>
<td>animate</td>
<td>Expand the panel body.</td>
</tr>
</tbody></table>
</div>
</body>
</html>