tabframe.js.html
35.3 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
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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title> Source: tabframe.js</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.dark.css">
<link type="text/css" rel="stylesheet" href="styles/site.slate.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html"><div style='font-size:15px;line-height:15px;margin-top:-5px;'>Web Cabin Docker<br>v3.0.0 (pre-release)</div></a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="module-wcBase.html">wcBase</a></li><li><a href="module-wcCollapser.html">wcCollapser</a></li><li><a href="module-wcDocker.html">wcDocker</a></li><li><a href="module-wcDrawer.html">wcDrawer</a></li><li><a href="module-wcFrame.html">wcFrame</a></li><li><a href="module-wcGhost.html">wcGhost</a></li><li><a href="module-wcIFrame.html">wcIFrame</a></li><li><a href="module-wcLayout.html">wcLayout</a></li><li><a href="module-wcLayoutSimple.html">wcLayoutSimple</a></li><li><a href="module-wcLayoutTable.html">wcLayoutTable</a></li><li><a href="module-wcPanel.html">wcPanel</a></li><li><a href="module-wcSplitter.html">wcSplitter</a></li><li><a href="module-wcTabFrame.html">wcTabFrame</a></li>
</ul>
</li>
<li class="dropdown">
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="module-wcDocker.html#event:onEvent">wcDocker#event:onEvent</a></li>
</ul>
</li>
<li class="dropdown">
<a href="tutorials.list.html" class="dropdown-toggle" data-toggle="dropdown">Tutorials<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="tutorial-1.0-getting-started.html">Getting Started</a></li><li><a href="tutorial-2.0-tips-and-tricks.html">Tips and Tricks</a></li><li><a href="tutorial-3.0-widgets.html">Widgets</a></li>
</ul>
</li>
<li class="dropdown">
<a href="externals.list.html" class="dropdown-toggle" data-toggle="dropdown">Externals<b class="caret"></b></a>
<ul class="dropdown-menu inline">
<li><a href="external-domNode.html">domNode</a></li><li><a href="external-jQuery.html">jQuery</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-12">
<div id="main">
<h1 class="page-title">Source: tabframe.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">/** @module wcTabFrame */
define([
"dcl/dcl",
"./types",
"./base"
], function (dcl, wcDocker, base) {
/**
* @class
* A tab widget container, usable inside a panel to break up multiple elements into separate tabbed pages.
*/
var Module = dcl(base, {
declaredClass: 'wcTabFrame',
LEFT_TAB_BUFFER: 15,
/**
* @memberOf module:wcTabFrame
* @param {external:jQuery~selector|external:jQuery~Object|external:domNode} container - A container element for this layout.
* @param {module:wcPanel} parent - The parent panel object for this widget.
*/
constructor: function(container, parent) {
/**
* The outer container element of the widget.
* @member {external:jQuery~Object}
*/
this.$container = $(container);
this._parent = parent;
this.$frame = null;
this.$tabBar = null;
this.$tabScroll = null;
this.$center = null;
this.$tabLeft = null;
this.$tabRight = null;
this.$close = null;
this._tabOrientation = wcDocker.TAB.TOP;
this._canScrollTabs = false;
this._tabScrollPos = 0;
this._curTab = -1;
this._layoutList = [];
this._moveable = true;
this._boundEvents = [];
this.__init();
},
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Public Functions
///////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Manually update the contents of this tab frame.
* @function module:wcTabFrame#update
*/
update: function () {
var scrollTop = this.$center.scrollTop();
this.__updateTabs();
this.$center.scrollTop(scrollTop);
},
/**
* Destroys the widget.
* @function module:wcTabFrame#destroy
*/
destroy: function () {
this.__destroy();
},
/**
* Gets the total number of tabs in this frame.
* @version 3.0.0
* @function module:wcTabFrame#tabCount
* @returns {Number}
*/
tabCount: function () {
return this._layoutList.length;
},
/**
* Gets, or Sets the tab orientation for the frame. This puts the tabbed widgets visually on any side of the tab frame.
* @version 3.0.0
* @function module:wcTabFrame#tabOrientation
* @param {module:wcDocker.TAB} [orientation] - Assigns the orientation of the tab items displayed.
* @returns {module:wcDocker.TAB} - The current orientation.
*/
tabOrientation: function (orientation) {
if (orientation !== undefined) {
if (this._tabOrientation !== orientation && this.docker()._canOrientTabs) {
this._tabOrientation = orientation;
this.__updateTabs();
this.__updateTabs();
}
}
return this._tabOrientation
},
/**
* Adds a new tabbed page into the widget.
* @function module:wcTabFrame#addTab
* @param {String} name - The name of the new tab page.
* @param {Number} [index] - If supplied and above -1, will insert the new tab page at the given tab index, otherwise the new tab is appended to the end.
* @param {module:wcDocker.LAYOUT} [layout] - If supplied, will set the type of layout to use for this tab.
* @returns {module:wcLayoutSimple|wcLayoutTable} - The layout of the newly created tab page.
*/
addTab: function (name, index, layout) {
var layoutClass = layout || 'wcLayoutTable';
var newLayout = new (this.docker().__getClass(layoutClass))('.wcDockerTransition', this._parent);
newLayout.name = name;
newLayout._scrollable = {
x: true,
y: true
};
newLayout._scroll = {
x: 0,
y: 0
};
newLayout._closeable = false;
newLayout._overflowVisible = false;
if (typeof index === 'undefined' || index <= -1) {
this._layoutList.push(newLayout);
} else {
this._layoutList.splice(index, 0, newLayout);
}
if (this._curTab === -1 && this._layoutList.length) {
this._curTab = 0;
}
this.__updateTabs();
return newLayout;
},
/**
* Removes a tab page from the widget.
* @function module:wcTabFrame#removeTab
* @param {Number} index - The tab page index to remove.
* @returns {Boolean} - Success or failure.
*/
removeTab: function (index) {
if (index > -1 && index < this._layoutList.length) {
var name = this._layoutList[index].name;
this._layoutList[index].__destroy();
this._layoutList.splice(index, 1);
if (this._curTab >= index) {
this._curTab--;
if (this._curTab < 0) {
this._curTab = 0;
}
}
this.__updateTabs();
this._parent.__trigger(wcDocker.EVENT.CUSTOM_TAB_CLOSED, {obj: this, name: name, index: index});
return true;
}
return false;
},
/**
* Gets, or Sets the currently visible tab page.
* @function module:wcTabFrame#tab
* @param {Number} [index] - If supplied, sets the current tab page index.
* @param {Boolean} [scrollTo] - If true, will auto scroll the tab bar until the selected tab is visible.
* @returns {Number} - The index of the currently visible tab page.
*/
tab: function (index, scrollTo) {
if (typeof index !== 'undefined') {
if (index > -1 && index < this._layoutList.length) {
this.$tabBar.find('> .wcTabScroller > .wcPanelTab[id="' + this._curTab + '"]').removeClass('wcPanelTabActive');
this.$center.children('.wcPanelTabContent[id="' + this._curTab + '"]').addClass('wcPanelTabContentHidden');
this._curTab = index;
this.$tabBar.find('> .wcTabScroller > .wcPanelTab[id="' + index + '"]').addClass('wcPanelTabActive');
this.$center.children('.wcPanelTabContent[id="' + index + '"]').removeClass('wcPanelTabContentHidden');
this.__updateTabs(scrollTo);
var name = this._layoutList[this._curTab].name;
this._parent.__trigger(wcDocker.EVENT.CUSTOM_TAB_CHANGED, {obj: this, name: name, index: index});
}
}
return this._curTab;
},
/**
* Retrieves the layout for a given tab page.
* @function module:wcTabFrame#layout
* @param {Number} index - The tab page index to retrieve.
* @returns {module:wcLayoutSimple|wcLayoutTable|Boolean} - The layout of the found tab page, or false.
*/
layout: function (index) {
if (index > -1 && index < this._layoutList.length) {
return this._layoutList[index];
}
return false;
},
/**
* Moves a tab page from a given index to another index.
* @function module:wcTabFrame#moveTab
* @param {Number} fromIndex - The current tab page index to move from.
* @param {Number} toIndex - The new tab page index to move to.
* @returns {external:jQuery~Object} - The new element of the moved tab, or false if an error occurred.
*/
moveTab: function (fromIndex, toIndex) {
if (fromIndex >= 0 && fromIndex < this._layoutList.length &&
toIndex >= 0 && toIndex < this._layoutList.length) {
var panel = this._layoutList.splice(fromIndex, 1);
this._layoutList.splice(toIndex, 0, panel[0]);
// Preserve the currently active tab.
if (this._curTab === fromIndex) {
this._curTab = toIndex;
}
this.__updateTabs();
return this.$tabBar.find('> .wcTabScroller > .wcPanelTab[id="' + toIndex + '"]')[0];
}
return false;
},
/**
* Gets, or Sets whether the tabs can be reordered by the user.
* @function module:wcTabFrame#moveable
* @param {Boolean} [moveable] - If supplied, assigns whether tab pages can be reordered.
* @returns {Boolean} - Whether tab pages are currently moveable.
*/
moveable: function (moveable) {
if (typeof moveable !== 'undefined') {
this._moveable = moveable;
}
return this._moveable;
},
/**
* Gets, or Sets whether a tab can be closed (removed) by the user.
* @function module:wcTabFrame#closeable
* @param {Number} index - The index of the tab page.
* @param {Boolean} [closeable] - If supplied, assigns whether the tab page can be closed.
* @returns {Boolean} - Whether the tab page can be closed.
*/
closeable: function (index, closeable) {
if (index > -1 && index < this._layoutList.length) {
var layout = this._layoutList[index];
if (typeof closeable !== 'undefined') {
layout._closeable = closeable;
}
return layout._closeable;
}
return false;
},
/**
* Gets, or Sets whether a tab page area is scrollable.
* @function module:wcTabFrame#scrollable
* @param {Number} index - The index of the tab page.
* @param {Boolean} [x] - If supplied, assigns whether the tab page is scrollable in the horizontal direction.
* @param {Boolean} [y] - If supplied, assigns whether the tab page is scrollable in the vertical direction.
* @returns {module:wcDocker~Scrollable} - The current scrollable status of the tab page.
*/
scrollable: function (index, x, y) {
if (index > -1 && index < this._layoutList.length) {
var layout = this._layoutList[index];
var changed = false;
if (typeof x !== 'undefined') {
layout._scrollable.x = x;
changed = true;
}
if (typeof y !== 'undefined') {
layout._scrollable.y = y;
changed = true;
}
if (changed) {
this.__onTabChange();
}
return {
x: layout._scrollable.x,
y: layout._scrollable.y
};
}
return false;
},
/**
* Gets, or Sets whether overflow on a tab area is visible.<br>
* Use this if a child element within this panel is intended to 'popup' and be visible outside of its parent area.
* @function module:wcTabFrame#overflowVisible
* @param {Number} index - The index of the tab page.
* @param {Boolean} [visible] - If supplied, assigns whether overflow is visible.
* @returns {Boolean} - The current overflow visiblity status of the tab page.
*/
overflowVisible: function (index, visible) {
if (index > -1 && index < this._layoutList.length) {
var layout = this._layoutList[index];
if (typeof overflow !== 'undefined') {
layout._overflowVisible = overflow;
this.__onTabChange();
}
return layout._overflowVisible;
}
return false;
},
/**
* Gets, or Sets whether the tab frame should fit to its contents.
* @version 3.0.0
* @function module:wcTabFrame#fitContents
* @param {Number} index - The index of the tab page.
* @param {Boolean} [x] - If supplied, assigns whether the tab page is scrollable in the horizontal direction.
* @param {Boolean} [y] - If supplied, assigns whether the tab page is scrollable in the vertical direction.
* @returns {module:wcDocker~FitContents} - The current scrollable status of the tab page.
*/
fitContents: function (index, x, y) {
if (index > -1 && index < this._layoutList.length) {
var layout = this._layoutList[index];
if (!layout.hasOwnProperty('_fitContents')) {
layout._fitContents = {
x: false,
y: false
};
}
var changed = false;
if (typeof x !== 'undefined') {
layout._fitContents.x = x;
changed = true;
}
if (typeof y !== 'undefined') {
layout._fitContents.y = y;
changed = true;
}
if (changed) {
this.__onTabChange();
}
return {
x: layout._fitContents.x,
y: layout._fitContents.y
};
}
return false;
},
/**
* Sets the icon for a tab item.
* @function module:wcTabFrame#icon
* @param {Number} index - The index of the tab item.
* @param {String} icon - A CSS class name that represents the icon.
*/
icon: function (index, icon) {
if (index > -1 && index < this._layoutList.length) {
var layout = this._layoutList[index];
if (!layout.$icon) {
layout.$icon = $('<div>');
}
layout.$icon.removeClass();
layout.$icon.addClass('wcTabIcon ' + icon);
}
},
/**
* Sets the icon for a tab item using the [Font-Awesome]{@link http://fortawesome.github.io/Font-Awesome/} library.
* @function module:wcTabFrame#faicon
* @param {Number} index - The index of the tab item.
* @param {String} icon - A [Font-Awesome]{@link http://fortawesome.github.io/Font-Awesome/} icon name (without the 'fa fa-' prefix).
*/
faicon: function (index, icon) {
if (index > -1 && index < this._layoutList.length) {
var layout = this._layoutList[index];
if (!layout.$icon) {
layout.$icon = $('<div>');
}
layout.$icon.removeClass();
layout.$icon.addClass('fa fa-fw fa-' + icon);
}
},
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Private Functions
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize
__init: function () {
this.$frame = $('<div class="wcCustomTab wcWide wcTall">');
this.$tabBar = $('<div class="wcFrameTitleBar wcCustomTabTitle wcWide">');
this.$tabScroll = $('<div class="wcTabScroller">');
this.$center = $('<div class="wcFrameCenter wcPanelBackground">');
this.$tabLeft = $('<div class="wcFrameButton" title="Scroll tabs to the left."><span class="fa fa-arrow-left"></span>&lt;</div>');
this.$tabRight = $('<div class="wcFrameButton" title="Scroll tabs to the right."><span class="fa fa-arrow-right"></span>&gt;</div>');
this.$close = $('<div class="wcFrameButton" title="Close the currently active panel tab"><span class="fa fa-close"></span>X</div>');
//this.$maximize = $('<div class="wcFrameButton" title="Close the currently active panel tab"><span class="fa fa-expand"></span>X</div>');
this.$buttonBar = $('<div class="wcFrameButtonBar">');
this.$tabBar.append(this.$tabScroll);
this.$tabBar.append(this.$buttonBar);
this.$buttonBar.append(this.$close);
//this.$buttonBar.append(this.$maximize);
this.$frame.append(this.$center);
this.$frame.append(this.$tabBar);
this.__container(this.$container);
this._boundEvents.push({event: wcDocker.EVENT.UPDATED, handler: this.update.bind(this)});
this._boundEvents.push({event: wcDocker.EVENT.CLOSED, handler: this.destroy.bind(this)});
for (var i = 0; i < this._boundEvents.length; ++i) {
this._parent.on(this._boundEvents[i].event, this._boundEvents[i].handler);
}
var docker = this.docker();
if (docker) {
docker._tabList.push(this);
}
},
__updateTabs: function (scrollTo) {
this.$tabScroll.empty();
var getOffset = function ($item) {
switch (this._tabOrientation) {
case wcDocker.TAB.BOTTOM:
return $item.offset().left;
case wcDocker.TAB.TOP:
return $item.offset().left;
case wcDocker.TAB.LEFT:
return $item.offset().top;
case wcDocker.TAB.RIGHT:
return $item.offset().top;
}
}.bind(this);
var tabPositions = [];
var totalWidth = 0;
var parentLeft = getOffset(this.$tabScroll);
var self = this;
this.$center.children('.wcPanelTabContent').each(function () {
$(this).addClass('wcPanelTabContentHidden wcPanelTabUnused');
});
for (var i = 0; i < this._layoutList.length; ++i) {
var $tab = $('<div id="' + i + '" class="wcPanelTab"><div>' + this._layoutList[i].name + '</div></div>');
if (this._moveable) {
$tab.addClass('wcCustomTabMoveable');
}
this.$tabScroll.append($tab);
if (this._layoutList[i].$icon) {
$tab.find('div').prepend(this._layoutList[i].$icon);
}
var $tabContent = this.$center.children('.wcPanelTabContent[id="' + i + '"]');
if (!$tabContent.length) {
$tabContent = $('<div class="wcPanelTabContent wcPanelTabContentHidden" id="' + i + '">');
this.$center.append($tabContent);
}
this._layoutList[i].__container($tabContent);
this._layoutList[i]._parent = this;
var isVisible = this._curTab === i;
$tabContent.removeClass('wcPanelTabUnused');
if (isVisible) {
$tab.addClass('wcPanelTabActive');
$tabContent.removeClass('wcPanelTabContentHidden');
}
totalWidth = getOffset($tab) - parentLeft;
tabPositions.push(totalWidth);
totalWidth += $tab.outerWidth();
}
var tabWidth = 0;
var titleSize = this.$tabBar.height();
switch (this._tabOrientation) {
case wcDocker.TAB.TOP:
this.$tabBar.addClass('wcTabTop').removeClass('wcTabLeft wcTabRight wcTabBottom');
this.$center.css('top', titleSize).css('left', 0).css('right', 0).css('bottom', 0);
tabWidth = this.$center.width();
break;
case wcDocker.TAB.BOTTOM:
this.$tabBar.addClass('wcTabBottom').removeClass('wcTabTop wcTabLeft wcTabRight');
this.$center.css('top', 0).css('left', 0).css('right', 0).css('bottom', titleSize);
tabWidth = this.$center.width();
break;
case wcDocker.TAB.LEFT:
this.$tabBar.addClass('wcTabLeft').removeClass('wcTabTop wcTabRight wcTabBottom');
this.$center.css('top', 0).css('left', titleSize).css('right', 0).css('bottom', 0);
tabWidth = this.$center.height();
break;
case wcDocker.TAB.RIGHT:
this.$tabBar.addClass('wcTabRight').removeClass('wcTabTop wcTabLeft wcTabBottom');
this.$center.css('top', 0).css('left', 0).css('right', titleSize).css('bottom', 0);
tabWidth = this.$center.height();
break;
}
// Now remove all unused panel tabs.
this.$center.children('.wcPanelTabUnused').each(function () {
$(this).remove();
});
var buttonSize = this.__onTabChange();
if (scrollTo) {
for (var i = 0; i < tabPositions.length; ++i) {
if (i === this._curTab) {
var left = tabPositions[i];
var right = totalWidth;
if (i + 1 < tabPositions.length) {
right = tabPositions[i + 1];
}
var scrollPos = -parseInt(this.$tabScroll.css('left'));
var titleWidth = tabWidth - buttonSize;
// If the tab is behind the current scroll position.
if (left < scrollPos) {
this._tabScrollPos = left - this.LEFT_TAB_BUFFER;
if (this._tabScrollPos < 0) {
this._tabScrollPos = 0;
}
}
// If the tab is beyond the current scroll position.
else if (right - scrollPos > titleWidth) {
this._tabScrollPos = right - titleWidth + this.LEFT_TAB_BUFFER;
}
break;
}
}
}
this._canScrollTabs = false;
if (totalWidth > tabWidth - buttonSize) {
this._canScrollTabs = true;
this.$buttonBar.append(this.$tabRight);
this.$buttonBar.append(this.$tabLeft);
buttonSize += this.$tabRight.outerWidth();
buttonSize += this.$tabLeft.outerWidth();
var scrollLimit = totalWidth - (tabWidth - buttonSize) / 2;
// If we are beyond our scroll limit, clamp it.
if (this._tabScrollPos > scrollLimit) {
var children = this.$tabScroll.children();
for (var i = 0; i < children.length; ++i) {
var $tab = $(children[i]);
totalWidth = getOffset($tab) - parentLeft;
if (totalWidth + $tab.outerWidth() > scrollLimit) {
this._tabScrollPos = totalWidth - this.LEFT_TAB_BUFFER;
if (this._tabScrollPos < 0) {
this._tabScrollPos = 0;
}
break;
}
}
}
} else {
this._tabScrollPos = 0;
this.$tabLeft.remove();
this.$tabRight.remove();
}
this.$tabScroll.stop().animate({left: -this._tabScrollPos + 'px'}, 'fast');
},
__onTabChange: function () {
var buttonSize = 0;
var layout = this.layout(this._curTab);
if (layout) {
this.$center.toggleClass('wcScrollableX', layout._scrollable.x);
this.$center.toggleClass('wcScrollableY', layout._scrollable.y);
this.$center.toggleClass('wcOverflowVisible', layout._overflowVisible);
this.$tabLeft.remove();
this.$tabRight.remove();
if (layout._closeable) {
this.$close.show();
buttonSize += this.$close.outerWidth();
} else {
this.$close.hide();
}
if (this._canScrollTabs) {
this.$tabBar.append(this.$tabRight);
this.$tabBar.append(this.$tabLeft);
buttonSize += this.$tabRight.outerWidth() + this.$tabLeft.outerWidth();
}
var fit = this.fitContents(this._curTab);
if (fit.x) {
var w = layout.scene().outerWidth();
if (this._tabOrientation === wcDocker.TAB.LEFT || this._tabOrientation === wcDocker.TAB.RIGHT) {
w += this.$tabScroll.height();
}
this.$container.css('width', w);
} else {
this.$container.css('width', '');
}
if (fit.y) {
var h = layout.scene().outerHeight();
if (this._tabOrientation === wcDocker.TAB.TOP || this._tabOrientation === wcDocker.TAB.BOTTOM) {
h += this.$tabScroll.height();
}
this.$container.css('height', h);
} else {
this.$container.css('height', '');
}
switch (this._tabOrientation) {
case wcDocker.TAB.RIGHT:
case wcDocker.TAB.LEFT:
this.$tabBar.css('width', this.$center.height() || '100%');
break;
case wcDocker.TAB.TOP:
case wcDocker.TAB.BOTTOM:
this.$tabBar.css('width', this.$center.width() || '100%');
default:
break;
}
this.$center.scrollLeft(layout._scroll.x);
this.$center.scrollTop(layout._scroll.y);
}
this.$buttonBar.css('min-width', buttonSize).css('width', buttonSize);
return buttonSize;
},
// Handles scroll notifications.
__scrolled: function () {
var layout = this.layout(this._curTab);
layout._scroll.x = this.$center.scrollLeft();
layout._scroll.y = this.$center.scrollTop();
},
// Gets, or Sets a new container for this layout.
// Params:
// $container If supplied, sets a new container for this layout.
// parent If supplied, sets a new parent for this layout.
// Returns:
// JQuery collection The current container.
__container: function ($container) {
if (typeof $container === 'undefined') {
return this.$container;
}
this.$container = $container;
if (this.$container) {
this.$container.append(this.$frame);
} else {
this.$frame.remove();
}
return this.$container;
},
// Disconnects and prepares this widget for destruction.
__destroy: function () {
var docker = this.docker();
if (docker) {
var index = docker._tabList.indexOf(this);
if (index > -1) {
docker._tabList.splice(index, 1);
}
}
// Remove all registered events.
while (this._boundEvents.length) {
this._parent.off(this._boundEvents[0].event, this._boundEvents[0].handler);
this._boundEvents.shift();
}
this._curTab = -1;
for (var i = 0; i < this._layoutList.length; ++i) {
this._layoutList[i].__destroy();
}
while (this._layoutList.length) this._layoutList.pop();
this.__container(null);
this._parent = null;
}
});
// window['wcTabFrame'] = Module;
return Module;
});
</pre>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="copyright">
2014-2016 Jeff Houde (<a href='mailto:lochemage@webcabin.org'>lochemage@webcabin.org</a>)
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a>
on 2016-08-28
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!-- Piwik Analytics -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.webcabin.org/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 6]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="https://analytics.webcabin.org/piwik.php?idsite=6" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>