1function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 3(function (_, $) { 4 (function ($) { 5 function _getTabTools(id) { 6 return $('.cm-tab-tools[id^="tools_' + id + '"]'); 7 } 8 9 function _getTabIds(id) { 10 var result_ids = ['content_' + id]; 11 var additional_ids = $('#content_' + id).data('caTabTargetId'); 12 13 if (additional_ids) { 14 result_ids.push(additional_ids); 15 } 16 17 _getTabTools(id).each(function () { 18 result_ids.push($(this).prop('id')); 19 }); 20 21 return result_ids.join(','); 22 } 23 24 function _switchTab(tab_id, tabs_elm, show) { 25 var id_obj = $('#content_' + tab_id); 26 27 var tab_tools = _getTabTools(tab_id); 28 29 if (show) { 30 id_obj.removeClass('hidden'); 31 tab_tools.removeClass('hidden'); 32 33 if (id_obj.hasClass('cm-hide-save-button')) { 34 $('.cm-save-buttons').addClass('hidden'); 35 } else { 36 $('.cm-save-buttons').removeClass('hidden'); 37 } 38 39 var editors = $(id_obj).find('textarea.cm-wysiwyg'); 40 41 if (editors.length) { 42 editors.each(function () { 43 $(this).ceEditor('destroy'); 44 $(this).ceEditor('recover'); 45 }); 46 } 47 48 $.ceEvent('trigger', 'ce.tab.show', [tab_id, tabs_elm]); 49 } else { 50 id_obj.addClass('hidden'); 51 tab_tools.addClass('hidden'); 52 } 53 54 return true; 55 } 56 57 function _cloneTools(tab_id, prev_id) { 58 if (!tab_id || !prev_id) { 59 return; 60 } 61 62 var _prev_tools = _getTabTools(prev_id); 63 64 _prev_tools.each(function () { 65 var self = $(this); 66 67 var _new_id = self.prop('id').replace(prev_id, tab_id); 68 69 if (!$('#' + _new_id).length) { 70 var _new_tool = self.clone(); 71 72 _new_tool.children().remove(); 73 74 _new_tool.prop('id', _new_id).addClass('hidden').appendTo(self.parent()); 75 } 76 }); 77 } 78 79 var methods = { 80 switch: function _switch(tab_id) { 81 if (!tab_id) { 82 return false; 83 } 84 85 var tabs_elm = $(this); 86 var ul = tabs_elm.data('ceTabs').ul; 87 var elm = tabs_elm.data('ceTabs').tabs[tab_id]; 88 89 if (!ul || !elm) { 90 return false; 91 } // we set selected_section to keep active tab opened after form submit 92 // we do it for all forms to fix settings_dev situation: forms under tabs 93 94 95 var $tabs = $(tabs_elm); 96 97 if ($tabs.hasClass('cm-track')) { 98 var input_name = 'selected_section'; 99 100 if (typeof $tabs.data('caTabsInputName') !== 'undefined') { 101 input_name = $tabs.data('caTabsInputName') === '' ? 'selected_sub_section' : $tabs.data('caTabsInputName'); 102 } 103 104 $("input[name=".concat(input_name, "]")).val(tab_id); 105 } 106 107 if (elm.hasClass('cm-js') == false) { 108 return false; 109 } 110 111 var active_id = $('li.active:first', ul).prop('id'); 112 var content_id = 'content_' + tab_id; 113 $('li', ul).each(function () { 114 var self = $(this); 115 self.removeClass('active'); 116 117 _switchTab(self.prop('id'), tabs_elm, false); 118 }); //Select clicked tab and show content 119 120 elm.addClass('active'); 121 var sub_tab = elm.parents('.cm-subtabs', ul); 122 123 if (sub_tab.length && elm.hasClass('cm-no-highlight')) { 124 sub_tab.addClass('active'); 125 } 126 127 if (elm.hasClass('cm-ajax-onclick') && !elm.hasClass('cm-ajax-onclick-active')) { 128 $.ceAjax('request', $('a', elm).prop('href'), { 129 result_ids: _getTabIds(tab_id), 130 callback: function callback(data) { 131 _switchTab(tab_id, tabs_elm, true); 132 } 133 }); 134 elm.addClass('cm-ajax-onclick-active'); 135 return true; 136 } 137 138 if (elm.hasClass('cm-ajax-onclick-active')) { 139 _switchTab(tab_id, tabs_elm, true); 140 141 return true; 142 } 143 144 if (elm.hasClass('cm-ajax') && $('#' + content_id).length == 0) { 145 // Create tab content if it is not exist 146 tabs_elm.after('<div id="' + content_id + '"></div>'); 147 148 _cloneTools(tab_id, active_id); 149 150 $.ceAjax('request', $('a', elm).prop('href'), { 151 result_ids: _getTabIds(tab_id), 152 callback: function callback(data) { 153 _switchTab(tab_id, tabs_elm, true); 154 } 155 }); 156 } else { 157 _switchTab(tab_id, tabs_elm, true); 158 } 159 160 return true; 161 },
162 init: function init() { 163 $(this).each(function () { 164 var tabs_elm = $(this); 165 $.ceEvent('trigger', 'ce.tab.pre_init', [tabs_elm]); //Setup Tabs 166 167 var ul = $('ul:first', tabs_elm); 168 var list = $('li', ul); 169 var data = { 170 ul: ul, 171 tabs: {} 172 }; 173 list.each(function () { 174 var elm = $(this); 175 var tab_id = elm.prop('id'); 176 data.tabs[tab_id] = elm; 177 }); 178 tabs_elm.data('ceTabs', data); 179 list.on('click', function (e) { 180 var $clickedElm = $(e.target); 181 182 if ($clickedElm.data('caStopEventPropagation')) { 183 e.stopPropagation(); 184 return; 185 } 186 187 var elm = $(this); 188 var tab_id = elm.prop('id'); 189 190 if (tabs_elm.ceTabs('switch', tab_id)) { 191 e.preventDefault(); 192 } 193 194 return true; 195 }); //Select default tab 196 197 var test; 198 199 if ((test = list.filter('.active')).length) { 200 test.trigger('click'); //Select tab with class 'active' 201 } else { 202 test = list.filter(':first').trigger('click'); //Select first tab 203 } // create similar active tab tools 204 205 206 var active_id = test.prop('id'); 207 $('li.cm-ajax.cm-js').each(function () { 208 var self = $(this); 209 var tab_id = self.prop('id'); // Check if the active content needs to be loaded 210 211 if (self.hasClass('active')) { 212 content = $('#content_' + tab_id).html().replace(/<!--.*?-->/, '').replace(/(^\s+|\s+$)/, ''); 213 214 if (content.length) { 215 return true; 216 } 217 } 218 219 if (!self.data('passed') && $('a', self).prop('href')) { 220 self.data('passed', true); 221 var id = 'content_' + tab_id; // Check if block already exists 222 223 var block = $('#' + id); 224 225 if (!block.length) { 226 self.parents('.cm-j-tabs').eq(0).next().prepend('<div id="' + id + '"></div>'); 227 block = $('#' + id); 228 } 229 230 if (!self.hasClass('active')) { 231 block.addClass('hidden'); 232 } 233 234 _cloneTools(tab_id, active_id); 235 236 if (!self.hasClass('cm-ajax-onclick')) { 237 $.ceAjax('request', $('a', self).prop('href'), { 238 result_ids: _getTabIds(tab_id), 239 hidden: true, 240 repeat_on_error: true 241 }); 242 } 243 } 244 }); 245 return true; 246 }); 247 $.ceEvent('trigger', 'ce.tab.init'); 248 } 249 }; 250 251 $.fn.ceTabs = function (method) { 252 if (methods[method]) { 253 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 254 } else if (_typeof(method) === 'object' || !method) { 255 return methods.init.apply(this, arguments); 256 } else { 257 $.error('ty.tabs: method ' + method + ' does not exist'); 258 } 259 }; 260 })($); 261})(Tygh, Tygh.$);
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.