1function Tab($) 2{ 3 var addHistoryPoint = true, 4 tabStripSelector = ""; 5 6 this.show = function() 7 { 8 var container = this.getContainerControl(), 9 containerId = container.id, 10 currentGxClass, 11 className = this.Class || ""; 12 13 tabStripSelector = '#' + containerId + '_tabs'; 14 15 if (!this.IsPostBack) 16 { 17 if (this.HistoryManagement) { 18 HistoryManager.Initialize(this); 19 } 20 21 var actx = []; 22 for (var i=1; i<=this.PageCount; i++) { 23 var ctx = {}; 24 ctx.index = i; 25 ctx.panel = this.getChildContainer("panel" + i); 26 ctx.title = this.getChildContainer("title" + i); 27 ctx.code = $(ctx.title).contents('div').last().remove().text(); 28 if (ctx.panel && ctx.title) 29 actx.push(ctx); 30 } 31 32 try { 33 var template = '<ul id="{{containerId}}_tabs" class="nav nav-tabs">'+ 34 '{{#ctx}}' + 35 '<li>' + 36 '<a id="Tab_{{panel.id}}" href="#{{code}}" data-target="#{{panel.id}}" data-toggle="tab" data-index="{{index}}" data-code="{{code}}">{{title.textContent}}</a>' + 37 '</li>' + 38 '{{/ctx}}'+ 39 '</ul>' + 40 '<div class="tab-content">'+ 41 '{{#ctx}}' + 42 '<div class="tab-pane" id="{{panel.id}}"></div>' + 43 '{{/ctx}}' + 44 '</div>'; 45 $(container).append(Mustache.render(template, { 46 ctx: actx, 47 containerId: containerId 48 })); 49 50 for (var i=0, len=actx.length; i<len; i++) { 51 var $tabPane = $("#" + actx[i].panel.id); 52 $(actx[i].panel).contents().each(function (i, el) { 53 $tabPane[0].appendChild(el); 54 }); 55 actx[i].panel.id = actx[i].panel.id + '_child'; 56 $tabPane[0].appendChild($(actx[i].panel)[0]) 57 var $tabItem = $("#Tab_" + actx[i].panel.id); 58 $tabItem.data('target', '#' + actx[i].panel.id); 59 } 60 61 if (this.ActivePageControlName) { 62 this.ActivePage = parseInt($(tabStripSelector).find('li a[data-code="' + this.ActivePageControlName + '"]').attr("data-index")); 63 } 64 if (!this.ActivePage) { 65 this.ActivePage = 1; 66 } 67 68 if ($.prototype.tab) { 69 this.showActivePage(); 70 } 71 else { 72 gx.fx.obs.addObserver('gx.onready', this, this.showActivePage, { single: true }); 73 } 74 75 var tabUC = this; 76 $(tabStripSelector).find('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 77 tabUC.ActivePage = parseInt($(this).attr("data-index"), 10); 78 tabUC.ActivePageControlName = $(this).attr("data-code"); 79 if (tabUC.HistoryManagement && addHistoryPoint) { 80 HistoryManager.AddHistoryPoint(tabUC.ActivePageControlName, true); 81 } 82 addHistoryPoint = true; 83 if (tabUC.TabChanged) { 84 tabUC.TabChanged(); 85 } 86 }); 87 } 88 catch(ex) { 89 gx.dbg.write(ex.toString()); 90 } 91 } 92 93 if (gx.lang.gxBoolean(this.Visible)) { 94 $(container).show(); 95 } 96 else { 97 $(container).hide(); 98 } 99 100 currentGxClass = $(container).attr('data-gx-class'); 101 if (currentGxClass) { 102 $(container).removeClass(currentGxClass); 103 } 104 $(container).attr("data-gx-class", className).addClass(className); 105 }; 106 107 this.showActivePage = function () { 108 $(tabStripSelector).find('li:nth-child(' + this.ActivePage + ') a').tab('show'); 109 }; 110 111 // HistoryManager methods /////////////// 112 this.getId = function(){ 113 return (this.ParentObject ? this.ParentObject.CmpContext || "" + "-" + this.ParentObject.ServerClass || "" : "") + "-" + this.ControlName; 114 }; 115 116 this.urlListener = function(){ 117 if (gx.grid.drawAtServer) 118 return; 119 var pageCode = (document.location.hash.length > 0) ? document.location.hash.substr(1) : ""; 120 if (pageCode) { 121 $(tabStripSelector).find('li a[data-code="' + pageCode + '"]').tab('show'); 122 } 123 else { 124 addHistoryPoint = false; 125 this.SelectTab(1); 126 } 127 }; 128 ///////////////////////////////////////// 129 130 // Methods 131 this.SelectTab = function (i) { 132 $(tabStripSelector).find('li:nth-child(' + i +') a').tab('show'); 133 }; 134 135 this.HideTab = function (i) { 136 var selector = tabStripSelector + ' li:nth-child(' + i +')'; 137 $(selector).hide(); 138 if ($(selector).hasClass('active')) { 139 $(tabStripSelector).find('li:visible a').each(function (i, el) { 140 $(el).tab('show'); 141 return false; 142 }); 143 } 144 }; 145 146 this.ShowTab = function (i) { 147 $(tabStripSelector).find('li:nth-child(' + i +')').show(); 148 }; 149}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.