tabs.js 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137
  1. /**************************************************************************
  2. * @name Zozo UI Tabs
  3. * @descripton Create awesome tabbed content area
  4. * @version 6.5
  5. * @Licenses: http://codecanyon.net/licenses/
  6. * @requires jQuery v1.7 or later
  7. * @copyright Copyright (c) 2013 Zozo UI
  8. * @author Zozo UI
  9. * @URL: http://www.zozoui.com
  10. * This files should be not used in production.
  11. ***************************************************************************/
  12. /**
  13. * jQuery.browser.mobile (http://detectmobilebrowser.com/)
  14. **/
  15. ; (function (a) { (jQuery.browser = jQuery.browser || {}).mobile = /(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)) })(navigator.userAgent || navigator.vendor || window.opera);
  16. ; (function ($, window, document, undefined) {
  17. if (!window.console) window.console = {};
  18. if (!window.console.log) window.console.log = function () { };
  19. $.fn.extend({
  20. hasClasses: function (selectors) {
  21. var _base = this;
  22. for (i in selectors) {
  23. if ($(_base).hasClass(selectors[i]))
  24. return true;
  25. }
  26. return false;
  27. }
  28. });
  29. $.zozo = {};
  30. $.zozo.core = {};
  31. $.zozo.core.console = {
  32. debug: false,
  33. log: function (message) {
  34. if ($("#zozo-console").length != 0) {
  35. $("<div/>")
  36. .css({ marginTop: -24 })
  37. .html(message)
  38. .prependTo("#zozo-console")
  39. .animate({ marginTop: 0 }, 300)
  40. .animate({ backgroundColor: "#ffffff" }, 800);
  41. }
  42. else {
  43. if (console && this.debug === true) {
  44. console.log(message);
  45. }
  46. }
  47. }
  48. };
  49. $.zozo.core.content = {
  50. debug: false,
  51. video: function (_content) {
  52. if (_content) {
  53. _content.find("iframe").each(function () {
  54. var _iframeSrc = $(this).attr('src');
  55. var wmode = "wmode=transparent";
  56. if (_iframeSrc && _iframeSrc.indexOf(wmode) === -1) {
  57. if (_iframeSrc.indexOf('?') != -1) $(this).attr('src', _iframeSrc + '&' + wmode);
  58. else $(this).attr('src', _iframeSrc + '?' + wmode);
  59. }
  60. });
  61. }
  62. },
  63. check: function (_content) {
  64. this.video(_content);
  65. }
  66. };
  67. $.zozo.core.keyCodes = {
  68. tab: 9,
  69. enter: 13,
  70. esc: 27,
  71. space: 32,
  72. pageup: 33,
  73. pagedown: 34,
  74. end: 35,
  75. home: 36,
  76. left: 37,
  77. up: 38,
  78. right: 39,
  79. down: 40
  80. };
  81. $.zozo.core.debug = {
  82. startTime: new Date(),
  83. log: function (msg) {
  84. if (console) {
  85. console.log(msg);
  86. }
  87. },
  88. start: function () {
  89. this.startTime = +new Date();
  90. this.log("start: " + this.startTime);
  91. },
  92. stop: function () {
  93. var _end = +new Date();
  94. var _diff = _end - this.startTime;
  95. this.log("end: " + _end);
  96. this.log("diff: " + _diff);
  97. var Seconds_from_T1_to_T2 = _diff / 1000;
  98. var Seconds_Between_Dates = Math.abs(Seconds_from_T1_to_T2);
  99. //this.log("diff s: " + Seconds_Between_Dates);
  100. }
  101. };
  102. $.zozo.core.support = {
  103. is_mouse_present: function () {
  104. return (('onmousedown' in window) && ('onmouseup' in window) && ('onmousemove' in window) && ('onclick' in window) && ('ondblclick' in window) && ('onmousemove' in window) && ('onmouseover' in window) && ('onmouseout' in window) && ('oncontextmenu' in window));
  105. },
  106. is_touch_device: function () {
  107. return (('ontouchstart' in window) || // html5 browsers
  108. (navigator.maxTouchPoints > 0) || // future IE
  109. (navigator.msMaxTouchPoints > 0)) && // current IE10
  110. (jQuery.browser.mobile); // mobile browser
  111. },
  112. html5_storage: function () {
  113. try {//https://github.com/artberri/jquery-html5storage/blob/master/jquery.html5storage.js
  114. return 'localStorage' in window && window['localStorage'] !== null;
  115. } catch (e) {
  116. return false;
  117. }
  118. },
  119. supportsCss: (function () {
  120. var div = document.createElement('div'), vendors = 'khtml ms o moz webkit'.split(' '), cssPre = false;
  121. return function (prop) {
  122. (prop in div.style) && (cssPre = prop)
  123. var propUp = prop.replace(/^[a-z]/, function (val) { return val.toUpperCase(); });
  124. $.each(vendors, function (index, value) {
  125. (value + propUp in div.style) && (cssPre = '-' + value + '-' + prop);
  126. });
  127. return cssPre;
  128. };
  129. })(),
  130. css: {
  131. transition: false
  132. }
  133. };
  134. $.zozo.core.utils = {
  135. toArray: function (_object) {
  136. return $.map(_object, function (value, key) {
  137. return value;
  138. });
  139. },
  140. createHeader: function (_t, _c) {
  141. var _tab = $("<li><a>" + _t + "</a></li>");
  142. var _content = $("<div>" + _c + "</div>");
  143. return { tab: _tab, content: _content };
  144. },
  145. isEmpty: function (_str) {
  146. return (!_str || 0 === _str.length);
  147. },
  148. isNumber: function (_input) {
  149. return typeof _input === 'number' && isFinite(_input);
  150. },
  151. isEven: function (_number) {
  152. return _number % 2 === 0;
  153. },
  154. isOdd: function (_input) {
  155. return !(_number % 2 === 0);
  156. },
  157. animate: function (_base, _elem, _pre, _prop, _post, _hidePre) {
  158. var _duration = (_base.settings.animation.effects === "none") ? 0 : _base.settings.animation.duration;
  159. var _easing = _base.settings.animation.easing;
  160. var _transition = $.zozo.core.support.css.transition;
  161. if (_elem && _prop) {
  162. if (_pre) {
  163. _elem.css(_pre);
  164. }
  165. /* moz transitions css transition fix*/
  166. var _prLeft = _elem.css("left");
  167. var _preTop = _elem.css("top");
  168. if (_base.settings.animation.type === "css") {
  169. //pre animation
  170. _prop[_transition] = "all " + _duration + "ms ease-in-out"
  171. //animation
  172. setTimeout(function () {
  173. _elem.css(_prop);
  174. });
  175. //post animation
  176. setTimeout(function () {
  177. // _base.settings.animating = false;
  178. if (_post) {
  179. _elem.css(_post);
  180. }
  181. _elem.css(_transition, "");
  182. //_container.removeClass(ANIMATINGCLASS);
  183. }, _duration);
  184. }
  185. else {
  186. //lem.show().animate(_prop, {
  187. _elem.animate(_prop, {
  188. duration: _duration,
  189. easing: _easing,
  190. complete: function () {
  191. // _base.settings.animating = false;
  192. if (_post) {
  193. _elem.css(_post);
  194. }
  195. // _container.removeClass(ANIMATINGCLASS);
  196. if (_hidePre) {
  197. _elem.hide();
  198. }
  199. }
  200. });
  201. }
  202. }
  203. return _base;
  204. }
  205. };
  206. $.zozo.core.plugins = {
  207. easing: function (_base) {
  208. var _exist = false;
  209. if (_base) {
  210. if (_base.settings) {
  211. //set up a default value for easing
  212. var _defEasing = 'swing';
  213. // check for the existence of the easing plugin
  214. if ($.easing.def) {
  215. _exist = true;
  216. }
  217. else {
  218. if (_base.settings.animation.easing != 'swing' && _base.settings.animation.easing != 'linear') {
  219. _base.settings.animation.easing = _defEasing;
  220. }
  221. }
  222. }
  223. }
  224. return _exist;
  225. }
  226. };
  227. $.zozo.core.browser = {
  228. init: function () {
  229. this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
  230. this.version = this.searchVersion(navigator.userAgent)
  231. || this.searchVersion(navigator.appVersion)
  232. || "an unknown version";
  233. $.zozo.core.console.log("init: " + this.browser + " : " + this.version);
  234. if (this.browser === "Explorer") {
  235. var _el = $("html");
  236. var version = parseInt(this.version);
  237. if (version === 6) {
  238. _el.addClass("ie ie7");
  239. }
  240. else if (version === 7) {
  241. _el.addClass("ie ie7");
  242. }
  243. else if (version === 8) {
  244. _el.addClass("ie ie8");
  245. }
  246. else if (version === 9) {
  247. _el.addClass("ie ie9");
  248. }
  249. }
  250. },
  251. isIE: function (_version) {
  252. if ($.zozo.core.utils.isNumber(_version)) {
  253. return (this.browser === "Explorer" && this.version <= _version)
  254. }
  255. else {
  256. return (this.browser === "Explorer")
  257. }
  258. },
  259. isChrome: function (_version) {
  260. if ($.zozo.core.utils.isNumber(_version)) {
  261. return (this.browser === "Chrome" && this.version <= _version)
  262. }
  263. else {
  264. return (this.browser === "Chrome")
  265. }
  266. },
  267. searchString: function (data) {
  268. for (var i = 0; i < data.length; i++) {
  269. var dataString = data[i].string;
  270. var dataProp = data[i].prop;
  271. this.versionSearchString = data[i].versionSearch || data[i].identity;
  272. if (dataString) {
  273. if (dataString.indexOf(data[i].subString) != -1)
  274. return data[i].identity;
  275. }
  276. else if (dataProp)
  277. return data[i].identity;
  278. }
  279. },
  280. searchVersion: function (dataString) {
  281. var index = dataString.indexOf(this.versionSearchString);
  282. if (index == -1)
  283. return;
  284. return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
  285. },
  286. dataBrowser: [
  287. {
  288. string: navigator.userAgent,
  289. subString: "Chrome",
  290. identity: "Chrome"
  291. }, {
  292. string: navigator.vendor,
  293. subString: "Apple",
  294. identity: "Safari",
  295. versionSearch: "Version"
  296. }, {
  297. prop: window.opera,
  298. identity: "Opera"
  299. }, {
  300. string: navigator.userAgent,
  301. subString: "Firefox",
  302. identity: "Firefox"
  303. }, {
  304. string: navigator.userAgent,
  305. subString: "MSIE",
  306. identity: "Explorer",
  307. versionSearch: "MSIE"
  308. }
  309. ]
  310. };
  311. $.zozo.core.hashHelper = {
  312. mode: "single",
  313. separator: null,
  314. all: function (_sep) {
  315. var hashArray = [];
  316. var hash = document.location.hash;
  317. if (!this.hasHash()) {
  318. return hashArray;
  319. }
  320. if (this.isSimple(_sep)) {
  321. return hash.substring(1);
  322. } else {
  323. hash = hash.substring(1).split('&');
  324. for (var i = 0; i < hash.length; i++) {
  325. var match = hash[i].split(_sep);
  326. //if (match.length != 2 || match[0] in hashArray) return undefined;
  327. if (match.length != 2 || match[0] in hashArray) {
  328. match[1] = "none";
  329. }
  330. hashArray[match[0]] = match[1];
  331. }
  332. }
  333. return hashArray;
  334. },
  335. get: function (key, _sep) {
  336. var all = this.all(_sep);
  337. if (this.isSimple(_sep)) {
  338. return all;
  339. } else {
  340. if (typeof all === 'undefined' || typeof all.length < 0) {
  341. //self.log("get: undefined or null all");
  342. return null;
  343. }
  344. else {
  345. if (typeof all[key] !== 'undefined' && all[key] !== null) {
  346. //self.log("get: exist key");
  347. return all[key];
  348. }
  349. else {
  350. //self.log("get: undefined or null key" + key);
  351. return null;
  352. }
  353. }
  354. }
  355. },
  356. set: function (key, value, _sep, _mod) {
  357. if (this.isSimple(_sep)) {
  358. document.location.hash = value;
  359. } else {
  360. if (_mod === "multiple") {
  361. var all = this.all(_sep);
  362. var hash = [];
  363. all[key] = value;
  364. for (var key in all) {
  365. hash.push(key + _sep + all[key]);
  366. }
  367. document.location.hash = hash.join('&');
  368. } else {
  369. document.location.hash = key + _sep + value;
  370. }
  371. }
  372. },
  373. isSimple: function (_sep) {
  374. if (!_sep || _sep === "none") {
  375. return true;
  376. }
  377. else {
  378. return false;
  379. }
  380. },
  381. hasHash: function () {
  382. var hash = document.location.hash;
  383. if (hash.length > 0) {
  384. return true;
  385. }
  386. else {
  387. return false;
  388. }
  389. }
  390. };
  391. $.zozo.core.support.css.transition = $.zozo.core.support.supportsCss("transition");
  392. $.zozo.core.browser.init();
  393. })(jQuery, window, document);
  394. ; (function ($) {
  395. $.event.special.ztap = {
  396. // Abort tap if touch moves further than 10 pixels in any direction
  397. distanceThreshold: 10,
  398. // Abort tap if touch lasts longer than half a second
  399. timeThreshold: 500,
  400. //isTouchSupported: 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch,
  401. isTouchSupported: jQuery.zozo.core.support.is_touch_device(),
  402. setup: function (_event) {
  403. var self = this, _base = $(self);
  404. var originalEvent = "click";
  405. if (_event) {
  406. if (_event.data) {
  407. originalEvent = _event.data;
  408. }
  409. }
  410. if ($.event.special.ztap.isTouchSupported) {
  411. // Bind touch start
  412. _base.on('touchstart', function (startEvent) {
  413. // Save the target element of the start event
  414. var target = startEvent.target,
  415. touchStart = startEvent.originalEvent.touches[0],
  416. startX = touchStart.pageX,
  417. startY = touchStart.pageY,
  418. threshold = $.event.special.ztap.distanceThreshold,
  419. timeout;
  420. function clearTapHandler() {
  421. clearTimeout(timeout);
  422. _base.off('touchmove', moveHandler).off('touchend', tapHandler);
  423. };
  424. function tapHandler(endEvent) {
  425. clearTapHandler();
  426. // When the touch end event fires, check if the target of the
  427. // touch end is the same as the target of the start, and if
  428. // so, fire a click.
  429. if (target == endEvent.target) {
  430. $.event.simulate('ztap', self, endEvent);
  431. }
  432. };
  433. // Remove tap and move handlers if the touch moves too far
  434. function moveHandler(moveEvent) {
  435. var touchMove = moveEvent.originalEvent.touches[0],
  436. moveX = touchMove.pageX,
  437. moveY = touchMove.pageY;
  438. if (Math.abs(moveX - startX) > threshold ||
  439. Math.abs(moveY - startY) > threshold) {
  440. clearTapHandler();
  441. }
  442. };
  443. // Remove the tap and move handlers if the timeout expires
  444. timeout = setTimeout(clearTapHandler, $.event.special.ztap.timeThreshold);
  445. // When a touch starts, bind a touch end and touch move handler
  446. _base.on('touchmove', moveHandler).on('touchend', tapHandler);
  447. });
  448. }
  449. else {
  450. // Bind click
  451. _base.on(originalEvent, function (endEvent) {
  452. $.event.simulate('ztap', self, endEvent);
  453. });
  454. }
  455. }
  456. };
  457. })(jQuery);
  458. ;(function ($, window, document, undefined) {
  459. if (window.zozo == null) {
  460. window.zozo = {};
  461. }
  462. var ZozoTabs = function (elem, options) {
  463. this.elem = elem;
  464. this.$elem = $(elem);
  465. this.options = options;
  466. this.metadata = (this.$elem.data("options")) ? this.$elem.data("options") : {};
  467. this.attrdata = (this.$elem.data()) ? this.$elem.data() : {};
  468. this.tabID;
  469. this.$tabGroup;
  470. this.$mobileNav;
  471. this.$mobileDropdownArrow;
  472. this.$tabs;
  473. this.$container;
  474. this.$contents;
  475. this.autoplayIntervalId;
  476. this.resizeWindowIntervalId;
  477. this.currentTab;
  478. this.BrowserDetection = $.zozo.core.browser;
  479. this.Deeplinking = $.zozo.core.hashHelper;
  480. this.lastWindowHeight;
  481. this.lastWindowWidth;
  482. this.responsive;
  483. };
  484. var zozo = {
  485. pluginName: "zozoTabs",
  486. elementSpacer: "<span class='z-tab-spacer' style='clear: both;display: block;'></span>",
  487. commaRegExp: /,/g,
  488. space: " ",
  489. responsive: {
  490. largeDesktop: 1200,
  491. desktop: 960,
  492. tablet: 720,
  493. phone: 480
  494. },
  495. modes: {
  496. tabs: "tabs",
  497. stacked: "stacked",
  498. menu: "menu",
  499. slider: "slider"
  500. },
  501. states:{
  502. closed: "z-state-closed",
  503. open: "z-state-open",
  504. active: "z-state-active"
  505. },
  506. events: {
  507. click: "click",
  508. mousover: "mouseover",
  509. touchend: "touchend",
  510. touchstart: "touchstart",
  511. touchmove: "touchmove"
  512. },
  513. animation: {
  514. effects:{
  515. fade: "fade",
  516. none: "none",
  517. slideH: "slideH",
  518. slideV: "slideV",
  519. slideLeft: "slideLeft",
  520. slideRight: "slideRight",
  521. slideUp: "slideUp",
  522. slideUpDown: "slideUpDown",
  523. slideDown: "slideDown"
  524. },
  525. types: {
  526. css: "css",
  527. jquery: "jquery"
  528. }
  529. },
  530. classes: {
  531. prefix: "z-",
  532. wrapper: "z-tabs",
  533. tabGroup: "z-tabs-nav",
  534. tab: "z-tab",
  535. first: "z-first",
  536. last: "z-last",
  537. left: "z-left",
  538. right: "z-right",
  539. firstCol: "z-first-col",
  540. lastCol: "z-last-col",
  541. firstRow: "z-first-row",
  542. lastRow: "z-last-row",
  543. active: "z-active",
  544. link: "z-link",
  545. container: "z-container",
  546. content: "z-content",
  547. shadows: "z-shadows",
  548. bordered: "z-bordered",
  549. dark: "z-dark",
  550. spaced: "z-spaced",
  551. rounded: "z-rounded",
  552. themes: [
  553. "gray",
  554. "black",
  555. "blue",
  556. "crystal",
  557. "green",
  558. "silver",
  559. "red",
  560. "orange",
  561. "deepblue",
  562. "white"
  563. ],
  564. flatThemes: [
  565. "flat-turquoise",//1
  566. "flat-emerald",
  567. "flat-peter-river",
  568. "flat-amethyst",
  569. "flat-wet-asphalt",
  570. "flat-green-sea",//2
  571. "flat-nephritis",
  572. "flat-belize-hole",
  573. "flat-wisteria",
  574. "flat-midnight-blue",
  575. "flat-sun-flower",//3
  576. "flat-carrot",
  577. "flat-alizarin",
  578. "flat-graphite",
  579. "flat-concrete",
  580. "flat-orange",//4
  581. "flat-pumpkin",
  582. "flat-pomegranate",
  583. "flat-silver",
  584. "flat-asbestos",
  585. "flat-zozo-red"
  586. ],
  587. styles: [
  588. "contained",
  589. "pills",
  590. "underlined",
  591. "clean",
  592. "minimal"
  593. ],
  594. orientations: [
  595. "vertical",
  596. "horizontal"
  597. ],
  598. sizes: [
  599. "mini",
  600. "small",
  601. "medium",
  602. "large",
  603. "xlarge",
  604. "xxlarge"
  605. ],
  606. positions: {
  607. top: "top",
  608. topLeft: "top-left",
  609. topCenter: "top-center",
  610. topRight: "top-right",
  611. topCompact: "top-compact",
  612. bottom: "bottom",
  613. bottomLeft: "bottom-left",
  614. bottomCenter: "bottom-center",
  615. bottomRight: "bottom-right",
  616. bottomCompact: "bottom-compact"
  617. }
  618. }
  619. },
  620. FLATCLASS = "flat",
  621. READY = "ready",
  622. ERROR = "error",
  623. SELECT = "select",
  624. ACTIVATE = "activate",
  625. DEACTIVATE = "deactivate",
  626. HOVERCLASS = "hover",
  627. BEFORESEND = "beforeSend",
  628. CONTENTLOAD = "contentLoad",
  629. CONTENTURL = "contentUrl",
  630. CONTENTTYPE = "contentType",
  631. DISABLED = "disabled",
  632. MENUICONCLASS = "z-icon-menu",
  633. DISABLEDCLASS = "z-disabled",
  634. STACKEDCLASS = "z-stacked",
  635. LIGHTICONCLASS = "z-icons-light",
  636. DARKICONCLASS = "z-icons-dark",
  637. AJAXSPINNERCLASS = "z-spinner",
  638. UNDERLINEDCLASS = "underlined",
  639. CONTAINEDCLASS = "contained",
  640. CLEANCLASS = "clean",
  641. PILLS = "pills",
  642. VERTICALCLASS = "vertical",
  643. HORIZONTALCLASS = "horizontal",
  644. TOPLEFTCLASS = "top-left",
  645. TOPRIGHTCLASS = "top-right",
  646. TOPCLASS = "top",
  647. BOTTOMCLASS = "bottom",
  648. BOTTOMRIGHTCLASS = "bottom-right",
  649. BOTTOMLEFTCLASS = "bottom-left",
  650. MOBILECLASS = "mobile",
  651. MULTILINECLASS = "z-multiline",
  652. TRANSITION = "transition",
  653. ANIMATINGCLASS = "z-animating",
  654. MOBILEDROPDOWNARROWCLASS = "z-dropdown-arrow",
  655. RESPONSIVECLASS = "responsive",
  656. CONTENTINNERCLASS = "z-content-inner";
  657. ZozoTabs.prototype = {
  658. defaults: {
  659. delayAjax:50,
  660. animation: { duration: 600, effects: "slideH", easing: "easeInQuad", type: "css", mobileDuration: 00 },
  661. autoContentHeight:true,
  662. autoplay: { interval: 0, smart: true },
  663. bordered: true,
  664. dark: false,
  665. cacheAjax: true,
  666. contentUrls: null,
  667. deeplinking: false,
  668. deeplinkingAutoScroll:false,
  669. deeplinkingMode: "single",
  670. deeplinkingPrefix: null,
  671. deeplinkingSeparator: "",
  672. defaultTab: "tab1",
  673. event: zozo.events.click,
  674. maxRows: 3,
  675. minWidth: 200,
  676. minWindowWidth: 480,
  677. mobileAutoScrolling: null,//{navTopOffset:-10, contentTopOffset: -10},
  678. mobileNav: true,
  679. mobileMenuIcon: null,
  680. mode: zozo.modes.tabs,
  681. multiline:false,
  682. hashAttribute: "data-link",
  683. position: zozo.classes.positions.topLeft,
  684. orientation: HORIZONTALCLASS,
  685. ready: function () { },
  686. responsive: true,
  687. responsiveDelay: 0,
  688. rounded: false,
  689. shadows: true,
  690. theme: "silver",
  691. scrollToContent: false,
  692. select: function () { },
  693. spaced: false,
  694. deactivate: function () { },
  695. beforeSend: function () { },
  696. contentLoad: function () { },
  697. next: null,
  698. prev:null,
  699. error: function () { },
  700. noTabs: false,
  701. rememberState:false,
  702. size: "medium",
  703. style: CONTAINEDCLASS,
  704. tabRatio: 1.03,
  705. tabRatioCompact: 1.031,
  706. original:{
  707. itemWidth: 0,
  708. itemMinWidth: null,
  709. itemMaxWidth: null,
  710. groupWidth: 0,
  711. initGroupWidth: 0,
  712. itemD: 0,
  713. itemM: 0,
  714. firstRowWidth: 0,
  715. lastRowItems:0,
  716. count:0,
  717. contentMaxHeight: null,
  718. contentMaxWidth: null,
  719. navHeight: null,
  720. position: null,
  721. bottomLeft: null,
  722. tabGroupWidth:0
  723. },
  724. animating: false
  725. },
  726. init: function () {
  727. var _base = this;
  728. //setTimeout( function(){
  729. _base.settings = $.extend(true,{}, _base.defaults, _base.options, _base.metadata, _base.attrdata);
  730. _base.$elem.find(">." + AJAXSPINNERCLASS).remove(); _base.$elem.removeClass("z-tabs-loading");
  731. if (_base.settings.contentUrls != null) {
  732. _base.$elem.find("> div > div").each(function (index, item) {
  733. $(item).data(CONTENTURL, _base.settings.contentUrls[index]);
  734. });
  735. }
  736. methods.initAnimation(_base,true);
  737. methods.updateClasses(_base);
  738. methods.checkWidth(_base, true);
  739. methods.bindEvents(_base);
  740. methods.initAutoPlay(_base);
  741. $.zozo.core.plugins.easing(_base);
  742. /*load tab state from html5 local storage*/
  743. if (_base.settings.rememberState === true && $.zozo.core.support.html5_storage()) {
  744. var tab = localStorage.getItem(_base.tabID + "_defaultTab");
  745. if (methods.tabExist(_base, tab)) {
  746. _base.settings.defaultTab = tab;
  747. }
  748. }
  749. // check if Deeplinking is enabled
  750. if (_base.settings.deeplinking === true) {
  751. var _prefix = (_base.settings.deeplinkingPrefix) ? _base.settings.deeplinkingPrefix : _base.tabID;
  752. if (document.location.hash) {
  753. var tab = _base.Deeplinking.get(_prefix, _base.settings.deeplinkingSeparator);
  754. if (methods.tabExist(_base, tab)) {
  755. methods.showTab(_base, tab);
  756. //scroll to top
  757. if (_base.settings.deeplinkingAutoScroll === true) {
  758. $('html, body').animate({ scrollTop: _base.$elem.offset().top - 150 }, 2000);
  759. }
  760. }
  761. else {
  762. methods.showTab(_base, _base.settings.defaultTab);
  763. }
  764. }
  765. else {
  766. methods.showTab(_base, _base.settings.defaultTab);
  767. }
  768. // bind the event hashchange, using jquery-hashchange-plugin
  769. if (typeof ($(window).hashchange) != "undefined") {
  770. $(window).hashchange(function () {
  771. var _newTab = _base.Deeplinking.get(_prefix, _base.settings.deeplinkingSeparator);
  772. if (!_base.currentTab || _base.currentTab.attr(_base.settings.hashAttribute) !== _newTab) {
  773. methods.showTab(_base, _newTab);
  774. }
  775. });
  776. }
  777. else {
  778. // Bind the event hashchange, using jquery event binding, not supported (IE6, IE7)
  779. $(window).bind('hashchange', function () {
  780. var _newTab = _base.Deeplinking.get(_prefix, _base.settings.deeplinkingSeparator);
  781. if (!_base.currentTab || _base.currentTab.attr(_base.settings.hashAttribute) !== _newTab) {
  782. methods.showTab(_base, _newTab);
  783. }
  784. });
  785. }
  786. }
  787. else {
  788. if (_base.settings.noTabs === true) {
  789. methods.showContent(_base, methods.getActive(_base, 0));
  790. }
  791. else {
  792. methods.showTab(_base, _base.settings.defaultTab);
  793. }
  794. }
  795. methods.checkWidth(_base);
  796. //fire ready event
  797. _base.$elem.trigger(READY, _base.$elem);
  798. return _base;
  799. //}, 2000);
  800. },
  801. setOptions: function (_option) {
  802. var _base = this;
  803. _base.settings = $.extend(true, _base.settings, _option);
  804. methods.initAnimation(_base);
  805. methods.updateClasses(_base, true);
  806. //version 5.0 methods.initTransition(_base, _base.$tabs.index(_base.currentTab));
  807. methods.checkWidth(_base, false, true);
  808. methods.initAutoPlay(_base);
  809. return _base;
  810. },
  811. add: function (item, content, tabID) {
  812. var _base = this;
  813. var tabOjb = {};
  814. if (item != null && typeof item === 'object') {
  815. if (item.tab) {
  816. tabOjb.tab = $(item.tab);
  817. (item.tabID && _base.settings.deeplinking === true) && (tabOjb.tab.attr(_base.settings.hashAttribute, item.tabID));
  818. }
  819. if (item.content) {
  820. tabOjb.content = $(item.content);
  821. }
  822. }
  823. else if (item && content) {
  824. tabOjb.tab = $("<li><a>" + item + "</a></li>");
  825. tabOjb.content = $("<div>" + content + "</div>");
  826. (tabID && _base.settings.deeplinking === true) && (tabOjb.tab.attr(_base.settings.hashAttribute, tabID));
  827. }
  828. if (tabOjb.tab && tabOjb.content) {
  829. tabOjb.tab.appendTo(_base.$tabGroup).hide().fadeIn(300).css("display", "");
  830. tabOjb.content.appendTo(_base.$container);
  831. methods.updateClasses(_base);
  832. methods.bindEvent(_base, tabOjb.tab);
  833. setTimeout(function () {
  834. methods.checkWidth(_base, false, true);
  835. }, 350);
  836. }
  837. return _base;
  838. },
  839. insertAfter: function (_t, _c, _d) {
  840. var _base = this;
  841. return _base;
  842. },
  843. insertBefore: function (_t, _c, _d) {
  844. var _base = this;
  845. return _base;
  846. },
  847. remove: function (_i) {
  848. var _base = this;
  849. var _index = (_i - 1);
  850. var _tabToRemove = _base.$tabs.eq(_index);
  851. var _contentToRmove = _base.$contents.eq(_index);
  852. _contentToRmove.remove();
  853. _tabToRemove.fadeOut(300, function () {
  854. $(this).remove();
  855. methods.updateClasses(_base);
  856. });
  857. setTimeout(function () {
  858. methods.checkWidth(_base, false, true);
  859. }, 350);
  860. return _base;
  861. },
  862. enable: function (_i) {
  863. var _base = this;
  864. var _tabToEnable = _base.$tabs.eq(_i);
  865. //var _contentToEnable= _base.$contents.eq(_i);
  866. if (_tabToEnable.length)
  867. {
  868. _tabToEnable.removeClass(DISABLEDCLASS);
  869. _tabToEnable.data(DISABLED,false);
  870. }
  871. return _base;
  872. },
  873. disable: function (_i) {
  874. var _base = this;
  875. var _tabToDisable = _base.$tabs.eq(_i);
  876. //var _contentToDisable = _base.$contents.eq(_i);
  877. if (_tabToDisable.length) {
  878. _tabToDisable.addClass(DISABLEDCLASS);
  879. _tabToDisable.data(DISABLED, true);
  880. }
  881. return _base;
  882. },
  883. select: function (_i) {
  884. var _base = this;
  885. if (_base.settings.animating !== true) {
  886. if (_base.settings.noTabs === true) {
  887. methods.showContent(_base, methods.getActive(_base, _i));
  888. }
  889. else {
  890. methods.changeHash(_base, _base.$tabs.eq(_i).attr(_base.settings.hashAttribute));
  891. }
  892. }
  893. return _base;
  894. },
  895. first: function () {
  896. var _base = this;
  897. _base.select(methods.getFirst());
  898. return _base;
  899. },
  900. prev: function () {
  901. var _base = this;
  902. var _currentIndex = methods.getActiveIndex(_base)
  903. if (_currentIndex <= methods.getFirst(_base)) {
  904. _base.select(methods.getLast(_base));
  905. }
  906. else {
  907. _base.select(_currentIndex - 1);
  908. $.zozo.core.debug.log("prev tab : " + (_currentIndex - 1));
  909. }
  910. return _base;
  911. },
  912. next: function (_base) {
  913. _base = (_base) ? _base : this;
  914. var _currentIndex = methods.getActiveIndex(_base);
  915. var _count = parseInt(methods.getLast(_base));
  916. if (_currentIndex >= _count) {
  917. _base.select(methods.getFirst());
  918. }
  919. else {
  920. _base.select(_currentIndex + 1);
  921. $.zozo.core.debug.log("next tab : " + (_currentIndex + 1));
  922. }
  923. return _base;
  924. },
  925. last: function () {
  926. var _base = this;
  927. _base.select(methods.getLast(_base));
  928. return _base;
  929. },
  930. play: function (interval) {
  931. var _base = this;
  932. if (interval == null || interval < 0) {
  933. interval = 2000;
  934. }
  935. _base.settings.autoplay.interval = interval;
  936. _base.stop();
  937. _base.autoplayIntervalId = setInterval(function () { _base.next(_base); }, _base.settings.autoplay.interval);
  938. return _base;
  939. },
  940. stop: function (_base) {
  941. _base = (_base) ? _base : this;
  942. clearInterval(_base.autoplayIntervalId);
  943. return _base;
  944. },
  945. refresh: function () {
  946. var _base = this;
  947. _base.$contents.filter(".z-active").css({ "display": "block" }).show();
  948. methods.checkWidth(_base);
  949. return _base;
  950. }
  951. };
  952. var methods = {
  953. initAnimation: function (_base, _init) {
  954. var _effects = $.zozo.core.utils.toArray(zozo.animation.effects);
  955. if ($.inArray(_base.settings.animation.effects, _effects) < 0) {
  956. _base.settings.animation.effects = zozo.animation.effects.slideH;
  957. }
  958. if (jQuery.browser.mobile) {
  959. //_base.settings.event = zozo.events.touchend;
  960. _base.settings.shadows = false;
  961. }
  962. if ($.zozo.core.support.css.transition === false) {
  963. _base.settings.animation.type = zozo.animation.types.jquery;
  964. if (jQuery.browser.mobile) {
  965. _base.settings.animation.duration = 0;
  966. }
  967. }
  968. if (_base.settings.animation.effects === zozo.animation.effects.none && _init ===true) {
  969. _base.settings.animation.duration = 0;
  970. }
  971. },
  972. updateClasses: function (_base, _options) {
  973. _base.$elem.find('*').stop(true, true);
  974. _base.tabID = _base.$elem.attr("id");
  975. _base.$tabGroup = _base.$elem.find("> ul").addClass(zozo.classes.tabGroup).not(".z-tabs-mobile").addClass("z-tabs-desktop");
  976. _base.$tabs = _base.$tabGroup.find("> li");
  977. _base.$container = _base.$elem.find("> div");
  978. _base.$contents = _base.$container.find("> div");
  979. if (_base.$tabGroup.length<=0) {
  980. _base.settings.noTabs = true;
  981. }
  982. var _transition = $.zozo.core.support.css.transition;
  983. var _noTabs = _base.settings.noTabs;
  984. //update container and content classes
  985. _base.$container.addClass(zozo.classes.container).css({_transition:""});
  986. _base.$contents.addClass(zozo.classes.content);
  987. _base.$contents.each(function (index, item) {
  988. var _cont = $(item);
  989. _cont.css({ "left": "", "top": "", "opacity": "", "display": "", _transition: "" });
  990. (_cont.hasClass(zozo.classes.active)) && _cont.show().css({ "display": "block", _transition: "" });
  991. });
  992. if (_noTabs != true) {
  993. _base.$tabs.each(function (index, item) {
  994. var _tab =$(item);
  995. _tab
  996. .removeClass(zozo.classes.first)
  997. .removeClass(zozo.classes.last)
  998. .removeClass(zozo.classes.left)
  999. .removeClass(zozo.classes.right)
  1000. .removeClass(zozo.classes.firstCol)
  1001. .removeClass(zozo.classes.lastCol)
  1002. .removeClass(zozo.classes.firstRow)
  1003. .removeClass(zozo.classes.lastRow)
  1004. .css({ "width": "", "float": "" })
  1005. .addClass(zozo.classes.tab)
  1006. .find("a")
  1007. .addClass(zozo.classes.link);
  1008. (methods.isTabDisabled(_tab)) && (_base.disable(index));
  1009. (_base.settings.deeplinking === false) && $(item).attr(_base.settings.hashAttribute, "tab" + (index + 1))
  1010. });
  1011. _base.$tabs.filter("li:first-child").addClass(zozo.classes.first);
  1012. _base.$tabs.filter("li:last-child").addClass(zozo.classes.last);
  1013. }
  1014. var _positions = $.zozo.core.utils.toArray(zozo.classes.positions);
  1015. _base.$elem
  1016. .removeClass(zozo.classes.wrapper)
  1017. .removeClass(zozo.classes.rounded)
  1018. .removeClass(zozo.classes.shadows)
  1019. .removeClass(zozo.classes.spaced)
  1020. .removeClass(zozo.classes.bordered)
  1021. .removeClass(zozo.classes.dark)
  1022. .removeClass(MULTILINECLASS)
  1023. .removeClass(LIGHTICONCLASS)
  1024. .removeClass(DARKICONCLASS)
  1025. .removeClass(STACKEDCLASS)
  1026. .removeClass(FLATCLASS)
  1027. .removeClass(zozo.classes.styles.join(zozo.space))
  1028. .removeClass(zozo.classes.orientations.join(zozo.space))
  1029. .removeClass(_positions.join().replace(zozo.commaRegExp, zozo.space))
  1030. .removeClass(zozo.classes.sizes.join(zozo.space))
  1031. .removeClass(zozo.classes.themes.join(zozo.space))
  1032. .removeClass(zozo.classes.flatThemes.join(zozo.space))
  1033. .addClass(HOVERCLASS)
  1034. .addClass(_base.settings.style)
  1035. .addClass(_base.settings.size)
  1036. .addClass(_base.settings.theme);
  1037. //console.log(zozo.classes.themes.join(zozo.space));
  1038. // console.log(zozo.classes.flatThemes.join(zozo.space));
  1039. //light or dark icons
  1040. (methods.isFlatTheme(_base)) && _base.$elem.addClass(FLATCLASS);
  1041. (methods.isLightTheme(_base)) ? _base.$elem.addClass(DARKICONCLASS): _base.$elem.addClass(LIGHTICONCLASS);
  1042. (_base.settings.rounded === true) && _base.$elem.addClass(zozo.classes.rounded);
  1043. (_base.settings.shadows === true) && _base.$elem.addClass(zozo.classes.shadows);
  1044. (_base.settings.bordered === true) && _base.$elem.addClass(zozo.classes.bordered);
  1045. (_base.settings.dark === true) && _base.$elem.addClass(zozo.classes.dark);
  1046. (_base.settings.spaced === true) && _base.$elem.addClass(zozo.classes.spaced);
  1047. (_base.settings.multiline === true) && _base.$elem.addClass(MULTILINECLASS);
  1048. methods.checkPosition(_base);
  1049. if (_base.$elem.find("> ul." + "z-tabs-mobile").length) {
  1050. _base.$mobileNav = _base.$elem.find("> ul." + "z-tabs-mobile");
  1051. } else {
  1052. _base.$mobileNav = $("<ul class='z-tabs-nav z-tabs-mobile'><li><a class='z-link' style='text-align: left;'><span class='z-title'>Overview</span><span class='z-arrow'></span></a></li></ul>");
  1053. }
  1054. if (_base.$mobileNav) {
  1055. _base.$tabGroup.before(_base.$mobileNav);
  1056. if (_base.$elem.find("> i." + MOBILEDROPDOWNARROWCLASS).length) {
  1057. _base.$mobileDropdownArrow = _base.$elem.find("> i." + MOBILEDROPDOWNARROWCLASS);
  1058. } else {
  1059. _base.$mobileDropdownArrow = $("<i class='z-dropdown-arrow'></i>");
  1060. }
  1061. _base.$tabGroup.before(_base.$mobileDropdownArrow);
  1062. }
  1063. //remove hover class for touch
  1064. (jQuery.browser.mobile) && (_base.$elem.removeClass(HOVERCLASS));
  1065. },
  1066. checkPosition: function (_base) {
  1067. _base.$container.appendTo(_base.$elem);
  1068. _base.$tabGroup.prependTo(_base.$elem);
  1069. _base.$elem.find("> span.z-tab-spacer").remove();
  1070. _base.$elem.addClass(zozo.classes.wrapper);
  1071. var _isTop = methods.isTop(_base);
  1072. //set calculate and container height
  1073. _base.$contents.each(function (index, item) {
  1074. var _content = $(item);
  1075. var _contentClass = CONTENTINNERCLASS;
  1076. if (!_content.find("> div." + CONTENTINNERCLASS).length) {
  1077. if (_content.hasClass("z-row")) {
  1078. _content.removeClass("z-row");
  1079. _contentClass = "z-row " + CONTENTINNERCLASS;
  1080. }
  1081. _content.wrapInner("<div class='" + _contentClass + "'></div>");
  1082. $.zozo.core.content.check(_content);
  1083. }
  1084. });
  1085. if (_base.settings.orientation === VERTICALCLASS) {
  1086. if (_base.settings.position !== TOPRIGHTCLASS) {
  1087. _base.settings.position = TOPLEFTCLASS;
  1088. }
  1089. }
  1090. else {
  1091. _base.settings.orientation = HORIZONTALCLASS;
  1092. if (_isTop === false) {
  1093. _base.$tabGroup.appendTo(_base.$elem);
  1094. $(zozo.elementSpacer).appendTo(_base.$elem);
  1095. _base.$container.prependTo(_base.$elem);
  1096. }
  1097. }
  1098. _base.$elem.addClass(_base.settings.orientation);
  1099. _base.$elem.addClass(_base.settings.position);
  1100. if (_isTop) {
  1101. _base.$elem.addClass(TOPCLASS);
  1102. } else {
  1103. _base.$elem.addClass(BOTTOMCLASS);
  1104. }
  1105. },
  1106. bindEvents: function (_base) {
  1107. //main tab events
  1108. var _duration = (_base.settings.animation.effects === zozo.animation.effects.none) ? 0 : _base.settings.animation.duration;
  1109. _base.$tabs.each(function () {
  1110. var _tab = $(this);
  1111. var href = _tab.find("a").attr("href");
  1112. var target = _tab.find("a").attr("target");
  1113. if (!$.trim(href).length) {
  1114. methods.bindEvent(_base, _tab);
  1115. } else {
  1116. _tab.on('ztap', { data: _base.settings.event }, function (_event) {
  1117. ($.trim(target).length) ? window.open(href, target) :window.location = href;
  1118. _event.preventDefault();
  1119. });
  1120. }
  1121. });
  1122. /*
  1123. $(window).resize(function () {
  1124. clearInterval(_base.resizeWindowIntervalId);
  1125. _base.resizeWindowIntervalId = setTimeout(function () {
  1126. methods.checkWidth(_base);
  1127. }, 200)
  1128. });
  1129. */
  1130. $(window).resize(function () {
  1131. if (/*_base.lastWindowHeight !== $(window).height() ||*/ _base.lastWindowWidth !== $(window).width()) {
  1132. clearInterval(_base.resizeWindowIntervalId);
  1133. _base.resizeWindowIntervalId = setTimeout(function () {
  1134. _base.lastWindowHeight = $(window).height();
  1135. _base.lastWindowWidth = $(window).width();
  1136. //console.log("resizing " + $(window).width());
  1137. methods.checkWidth(_base);
  1138. }, _base.settings.responsiveDelay);
  1139. }
  1140. });
  1141. //bind next event
  1142. var _nextButton = _base.settings.next;
  1143. if (_nextButton != null)
  1144. {
  1145. $(_nextButton).on(zozo.events.click, function (_event) {
  1146. _event.preventDefault();
  1147. _base.next();
  1148. });
  1149. }
  1150. //bind prve event
  1151. var _prevButton = _base.settings.prev;
  1152. if (_prevButton != null) {
  1153. $(_prevButton).on(zozo.events.click, function (_event) {
  1154. _event.preventDefault();
  1155. _base.prev();
  1156. });
  1157. }
  1158. //mobile dropdown menu event
  1159. if (_base.$mobileNav) {
  1160. _base.$mobileNav.find("li").on('ztap', { data: _base.settings.event }, function (_event) {
  1161. //_base.$mobileNav.find("li").on(_base.settings.event, function (_event) {
  1162. _event.preventDefault();
  1163. if (_base.$mobileNav.hasClass(zozo.states.closed)) {
  1164. _base.$mobileNav.removeClass(zozo.states.closed);
  1165. _base.$tabGroup.removeClass("z-hide-menu");
  1166. methods.mobileNavAutoScroll(_base);
  1167. }
  1168. else {
  1169. _base.$mobileNav.addClass(zozo.states.closed);
  1170. _base.$tabGroup.addClass("z-hide-menu");
  1171. }
  1172. methods.refreshParents(_base, _duration);
  1173. });
  1174. }
  1175. _base.lastWindowHeight = $(window).height();
  1176. _base.lastWindowWidth = $(window).width();
  1177. _base.$elem.bind(READY, _base.settings.ready);
  1178. _base.$elem.bind(SELECT, _base.settings.select);
  1179. _base.$elem.bind(DEACTIVATE, _base.settings.deactivate);
  1180. _base.$elem.bind(ERROR, _base.settings.error);
  1181. _base.$elem.bind(CONTENTLOAD, _base.settings.contentLoad);
  1182. },
  1183. bindEvent: function (_base, _tab) {
  1184. _tab.on('ztap', { data: _base.settings.event }, function (_event) {
  1185. _event.preventDefault();
  1186. //stop autoplay if smart is true
  1187. if (_base.settings.autoplay !== false && _base.settings.autoplay != null) {
  1188. if (_base.settings.autoplay.smart === true) {
  1189. _base.stop();
  1190. }
  1191. }
  1192. methods.changeHash(_base, _tab.attr(_base.settings.hashAttribute));
  1193. if (methods.allowAutoScrolling(_base) === true && methods.isMobile(_base)) {
  1194. $(window.opera ? 'html' : 'html, body').animate({
  1195. scrollTop: _base.$elem.offset().top +_base.settings.mobileAutoScrolling.contentTopOffset
  1196. }, 0);
  1197. }
  1198. });
  1199. },
  1200. mobileNavAutoScroll: function (_base) {
  1201. if (methods.allowAutoScrolling(_base) === true) {
  1202. $(window.opera ? 'html' : 'html, body').animate({
  1203. scrollTop: _base.$mobileNav.offset().top + _base.settings.mobileAutoScrolling.navTopOffset
  1204. }, 0);
  1205. }
  1206. return _base;
  1207. },
  1208. showTab: function (_base, tab) {
  1209. if (methods.tabExist(_base, tab) && tab != null && _base.settings.animating !== true) {
  1210. var nextTab = _base.$tabs.filter("li[" + _base.settings.hashAttribute + "='" + tab + "']");
  1211. var _nextIndex = _base.$tabs.index(nextTab);
  1212. var _tabElement = methods.getActive(_base, _nextIndex);
  1213. if (_tabElement.enabled && _tabElement.preIndex !== _tabElement.index && _base.settings.noTabs !== true) {
  1214. //_base.settings.animating = true
  1215. //set current tab
  1216. _base.currentTab = nextTab;
  1217. //update classes
  1218. _base.$tabs.removeClass(zozo.classes.active);
  1219. _base.currentTab.addClass(zozo.classes.active);
  1220. //save to local html5 storage
  1221. if (_base.settings.rememberState === true && $.zozo.core.support.html5_storage()) {
  1222. localStorage.setItem(_base.tabID + "_defaultTab", nextTab.data("link"));
  1223. }
  1224. methods.mobileNav(_base, false, _tabElement.index);
  1225. if (_tabElement.contentUrl) {
  1226. if (_tabElement.preIndex === -1) {
  1227. //transition.init(_base, _tabElement);
  1228. _tabElement.content.css({ "opacity": "", "left": "", "top": "", "position": "relative" }).show();
  1229. }
  1230. if (_tabElement.contentType === "iframe") {
  1231. methods.iframeContent(_base, _tabElement);
  1232. }
  1233. else {
  1234. methods.ajaxRequest(_base, _tabElement);
  1235. }
  1236. } else {
  1237. methods.showContent(_base, _tabElement);
  1238. }
  1239. }
  1240. }
  1241. },
  1242. getActiveIndex: function (_base) {
  1243. var _index;
  1244. if (_base.settings.noTabs === true) {
  1245. _index = _base.$container.find(">div." + zozo.classes.active).index();
  1246. } else {
  1247. if (_base.currentTab)
  1248. {
  1249. _index = parseInt(_base.currentTab.index());
  1250. } else {
  1251. _index = _base.$tabGroup.find("li." + zozo.classes.active).index();
  1252. }
  1253. }
  1254. return _index;
  1255. },
  1256. getActive: function (_base, _index) {
  1257. var _preIndex = methods.getActiveIndex(_base);
  1258. var _nextContent = _base.$contents.eq(_index);
  1259. var _nextTab = _base.$tabs.eq(_index);
  1260. var _preTab = _base.$tabs.eq(_preIndex);
  1261. var _transition = $.zozo.core.support.css.transition;
  1262. var _duration = (_base.settings.animation.effects === zozo.animation.effects.none) ? 0 : _base.settings.animation.duration;
  1263. var _tabElement = {
  1264. index: _index,
  1265. tab: _nextTab,
  1266. content: _nextContent,
  1267. contentInner: _nextContent.find("> .z-content-inner"),
  1268. enabled: methods.isTabDisabled(_nextTab)===false,
  1269. contentUrl: _nextContent.data(CONTENTURL),
  1270. contentType: _nextContent.data(CONTENTTYPE),
  1271. noAnimation: false,
  1272. transition: _transition,
  1273. duration: _duration,
  1274. preIndex: _preIndex,
  1275. preTab: _preTab,
  1276. preContent: _base.$contents.eq(_preIndex)
  1277. };
  1278. return _tabElement;
  1279. },
  1280. iframeContent: function (_base, _tabElement) {
  1281. var _iframe = _tabElement.contentInner.find("> div >.z-iframe");
  1282. if (!_iframe.length) {
  1283. methods.showLoading(_base);
  1284. _tabElement.contentInner.append('<div class="z-video"><iframe src="' + _tabElement.contentUrl + '" frameborder="0" scrolling="auto" height="1400" class="z-iframe"></iframe></div>');
  1285. console.log("add iframe");
  1286. } else {
  1287. methods.hideLoading(_base);
  1288. }
  1289. methods.showContent(_base, _tabElement);
  1290. _tabElement.contentInner.find(".z-iframe").load(function () { methods.hideLoading(_base); });
  1291. return _base;
  1292. },
  1293. showLoading: function (_base) {
  1294. _base.$container.append('<span class="' + AJAXSPINNERCLASS + '"></span>');
  1295. return _base;
  1296. },
  1297. hideLoading: function (_base) {
  1298. _base.$container.find(">." + AJAXSPINNERCLASS).remove();
  1299. return _base;
  1300. },
  1301. ajaxRequest: function (_base, _tabElement) {
  1302. var data = {};
  1303. var callbackOjb = { tab: _tabElement.tab, content: _tabElement.contentInner, index: _tabElement.index, xhr: null, message: "" };
  1304. $.ajax({
  1305. type: "GET",
  1306. cache: (_base.settings.cacheAjax === true),
  1307. url: _tabElement.contentUrl,
  1308. dataType: "html",
  1309. data: data,
  1310. beforeSend: function (xhr, settings) {
  1311. //return fire(element, 'ajax:beforeSend', [xhr, settings]);
  1312. methods.showLoading(_base);
  1313. _base.settings.animating = true;
  1314. },
  1315. error: function (xhr, status, error) {
  1316. if (xhr.status == 404) {
  1317. callbackOjb.message = "<h4 style='color:red;'>Sorry, error: 404 - the requested content could not be found.</h4>";
  1318. }
  1319. else {
  1320. callbackOjb.message = "<h4 style='color:red;'>An error occurred: " + status + "\nError: " + xhr + " code: " + xhr.status + "</h4>";
  1321. }
  1322. callbackOjb.xhr = xhr;
  1323. (_base.settings.error && typeof (_base.settings.error) == typeof (Function)) && _base.$elem.trigger(ERROR, callbackOjb);
  1324. _tabElement.contentInner.html(callbackOjb.message);
  1325. },
  1326. complete: function (xhr, status) {
  1327. //_base.$elem.trigger('ajax:complete', [xhr, status]);
  1328. setTimeout(function () {
  1329. _base.settings.animating = false;
  1330. //methods.setContentHeight(_base, _tabElement.content);
  1331. methods.showContent(_base, _tabElement);
  1332. methods.hideLoading(_base);
  1333. }, _base.settings.delayAjax);
  1334. },
  1335. success: function (data, status, xhr) {
  1336. setTimeout(function () {
  1337. _tabElement.contentInner.html(data);
  1338. callbackOjb.xhr = xhr;
  1339. _base.$elem.trigger(CONTENTLOAD, callbackOjb);
  1340. }, _base.settings.delayAjax);
  1341. }
  1342. });
  1343. return _base;
  1344. },
  1345. showContent: function (_base, _tabElement) {
  1346. if (_tabElement.preIndex !== _tabElement.index && _base.settings.animating !== true) {
  1347. _base.settings.animating = true;
  1348. _base.$contents.removeClass(zozo.classes.active);
  1349. _tabElement.content.addClass(zozo.classes.active);
  1350. if (_tabElement.preIndex === -1) {
  1351. transition.init(_base, _tabElement);
  1352. }
  1353. else {
  1354. var _effects = _base.settings.animation.effects;
  1355. //var _preSize = methods.getElementSize(_tabElement.preContent).height;
  1356. //var _nextSize = methods.getElementSize(_tabElement.content).height;
  1357. //var _largest = methods.getContentHeight(_base, null, true).height;
  1358. var _preSize = methods.getContentHeight(_base, _tabElement.preContent, true).height;
  1359. var _nextSize = methods.getContentHeight(_base, _tabElement.content,true).height;
  1360. var _largest = methods.isLarger(_preSize, _nextSize);
  1361. if (_base.settings.orientation === HORIZONTALCLASS && _base.settings.autoContentHeight === true) {
  1362. _largest = (_preSize > _nextSize) ? _preSize : _nextSize
  1363. }
  1364. var _width = (_effects === zozo.animation.effects.slideH
  1365. || _effects === zozo.animation.effects.slideLeft
  1366. || _effects === zozo.animation.effects.slideRight) ? _base.$container.width() : _width = _largest;
  1367. if (_tabElement.preIndex < _tabElement.index && _effects === zozo.animation.effects.slideV) {
  1368. var _vHeight = methods.isLarger(_preSize, _nextSize);
  1369. (_vHeight > _width) && (_width = _vHeight);
  1370. }
  1371. var _prevValue = -_width;
  1372. var _nextValue = _width;
  1373. if (_tabElement.preIndex > _tabElement.index) {
  1374. _prevValue = _width;
  1375. _nextValue = -_width;
  1376. }
  1377. transition.before(_base, _tabElement);
  1378. switch(_effects)
  1379. {
  1380. case zozo.animation.effects.slideV:
  1381. methods.animate(_base, _tabElement.preContent,null, { "left": 0, "top": _prevValue + "px" });
  1382. methods.animate(_base, _tabElement.content, {"left": 0, "top": _nextValue + "px"}, { "top": 0});
  1383. break;
  1384. case zozo.animation.effects.slideUp:
  1385. methods.animate(_base, _tabElement.preContent, { "opacity": 1 }, { "left": 0, "top": (-_width) + "px"});
  1386. methods.animate(_base, _tabElement.content, { "left": 0, "top": (_width * 1) + "px" }, { "top": 0 });
  1387. break;
  1388. case zozo.animation.effects.slideDown:
  1389. methods.animate(_base, _tabElement.preContent, { "opacity": 1 }, { "left": 0, "top": (_width) + "px" });
  1390. methods.animate(_base, _tabElement.content, { "left": 0, "top": (-_width) + "px"}, { "top": 0 });
  1391. break;
  1392. case zozo.animation.effects.slideUpDown:
  1393. methods.animate(_base, _tabElement.preContent, { "opacity": 1 }, { "left": 0, "top": (-_width*1) + "px" });
  1394. methods.animate(_base, _tabElement.content, { "left": 0, "top": (-(_width * 2)) + "px" }, { "top": 0 });
  1395. break;
  1396. case zozo.animation.effects.slideH:
  1397. methods.animate(_base, _tabElement.preContent, null, { "left": _prevValue + "px" });
  1398. methods.animate(_base, _tabElement.content, { "left": _nextValue + "px" }, { "left": 0});
  1399. break;
  1400. case zozo.animation.effects.slideRight:
  1401. methods.animate(_base, _tabElement.preContent, { "opacity": 1 }, { "top": 0, "left": (_width) + "px"});
  1402. methods.animate(_base, _tabElement.content, { "top": 0, "left": (-_width) + "px" }, { "top": 0, "left": 0});
  1403. break;
  1404. case zozo.animation.effects.slideLeft:
  1405. methods.animate(_base, _tabElement.preContent, { "opacity": 1 }, { "top": 0, "left": (-_width) + "px" });
  1406. methods.animate(_base, _tabElement.content, { "top": 0, "left": (_width) + "px" }, { "top": 0, "left": 0 });
  1407. break;
  1408. case zozo.animation.effects.fade:
  1409. methods.animate(_base, _tabElement.preContent, { "display": "block" }, { "opacity": 0 });
  1410. methods.animate(_base, _tabElement.content, { "display": "block", "opacity": 0 }, { "opacity": 1 });
  1411. break;
  1412. case zozo.animation.effects.none:
  1413. _base.$contents.css({ "position": "absolute", "left": 0, "top": 0 }).removeClass(zozo.classes.active).hide()
  1414. .eq(_tabElement.index).addClass(zozo.classes.active).css({ "position": "relative" }).show();
  1415. break;
  1416. default:
  1417. }
  1418. transition.after(_base, _tabElement);
  1419. }
  1420. }
  1421. },
  1422. refreshParents: function (_base, _duration) {
  1423. setTimeout(function () {
  1424. _base.$elem.parents(".z-tabs").each(function (index, item) {
  1425. $(item).data('zozoTabs').refresh();
  1426. });
  1427. }, _duration);
  1428. },
  1429. animate: function (_base, _elem, _pre, _prop, _post, _hidePre) {
  1430. $.zozo.core.utils.animate(_base, _elem, _pre, _prop, _post, _hidePre);
  1431. },
  1432. mobileNav: function (_base, _show, _nextIndex) {
  1433. if (_nextIndex !== null && _base.$mobileNav) {
  1434. _base.$mobileNav.find("> li > a > span.z-title").html(_base.$tabs.eq(_nextIndex).find("a").html());
  1435. }
  1436. if (_show === true) {
  1437. setTimeout(function () {
  1438. _base.$mobileNav.removeClass(zozo.states.closed);
  1439. }, _base.settings.animation.mobileDuration);
  1440. _base.$tabGroup.removeClass("z-hide-menu");;
  1441. } else {
  1442. (_base.$mobileNav) && _base.$mobileNav.addClass(zozo.states.closed);
  1443. _base.$tabGroup.addClass("z-hide-menu");
  1444. }
  1445. },
  1446. setResponsiveDimension: function (_base, _groupWidth, _rec) {
  1447. var _container = _base.$container;
  1448. _base.settings.original.count = parseInt(_base.$tabs.size());
  1449. if (!_rec) {
  1450. _base.settings.original.itemD = parseInt(_container.width() / _base.settings.original.itemWidth);
  1451. _base.settings.original.itemM = _base.settings.original.itemWidth + _base.settings.original.itemM;
  1452. }
  1453. _base.settings.original.firstRowWidth = (_base.settings.original.itemWidth / (parseInt(_base.settings.original.itemD) * _base.settings.original.itemWidth) * 100);
  1454. _base.settings.original.itemCount = parseInt(_base.settings.original.itemD) * parseInt(_base.settings.original.count / (parseInt(_base.settings.original.itemD)));
  1455. _base.settings.original.lastItem = 100 / (parseInt(_base.settings.original.count) - parseInt(_base.settings.original.itemCount));
  1456. _base.settings.original.navHeight = _base.settings.original.itemD * (parseInt(_base.$tabs.eq(0).innerHeight())) + ((_base.settings.original.itemM > 0 ? _base.$tabs.eq(0).innerHeight() : 0));
  1457. _base.settings.original.bottomLeft = _base.settings.original.count - (_base.settings.original.count - _base.settings.original.itemCount);
  1458. _base.settings.original.rows = _base.settings.original.count > _base.settings.original.itemCount ? parseInt(_base.settings.original.itemCount / _base.settings.original.itemD) + 1 : parseInt(_base.settings.original.itemCount / _base.settings.original.itemD);
  1459. _base.settings.original.lastRowItems = _base.settings.original.count - (_base.settings.original.itemCount * (_base.settings.original.rows - 1));
  1460. _base.settings.original.itemsPerRow = _base.settings.original.itemCount / _base.settings.original.rows;
  1461. if (_container.width() > _groupWidth && !_rec) {
  1462. _base.settings.original.itemD = _base.settings.original.count;
  1463. _base.settings.original.itemM = 0;
  1464. _base.settings.original.rows = 1;
  1465. _base.settings.original.itemCount = _base.settings.original.count;
  1466. }
  1467. return _base;
  1468. },
  1469. checkWidth: function (_base, _init, _options) {
  1470. var _groupWidth = 0;
  1471. var _container = _base.$container;
  1472. var _isCompact = methods.isCompact(_base);
  1473. var _heightTotal = 0;
  1474. var _tabR = _base.settings.tabRatio;
  1475. var _tabRC = _base.settings.tabRatioCompact;
  1476. _base.$tabs.each(function (index) {
  1477. var _itemTempWidth = $(this).outerWidth(true) * _tabR;
  1478. (_isCompact) && (_itemTempWidth = (_itemTempWidth * _tabRC));
  1479. if (_init === true) {
  1480. if (_itemTempWidth > _base.settings.original.itemWidth) {
  1481. _base.settings.original.itemWidth = _itemTempWidth;
  1482. _base.settings.original.itemMaxWidth = _itemTempWidth;
  1483. }
  1484. if (_itemTempWidth < _base.settings.original.itemMinWidth) {
  1485. _base.settings.original.itemMinWidth = _itemTempWidth;
  1486. }
  1487. }
  1488. _heightTotal = _heightTotal + $(this).innerHeight();
  1489. _groupWidth = _groupWidth + _itemTempWidth;
  1490. });
  1491. if (_init === true)
  1492. {
  1493. _groupWidth = _groupWidth + (_base.settings.original.itemWidth * 0);
  1494. }
  1495. _base.settings.original.count = parseInt(_base.$tabs.size());
  1496. _base.settings.original.groupWidth = _groupWidth;
  1497. methods.setResponsiveDimension(_base, _base.settings.original.groupWidth);
  1498. if (_base.settings.original.count > 3 && _base.settings.original.lastRowItems === 1) {
  1499. _base.settings.original.itemD = _base.settings.original.itemD - 1;
  1500. _base.settings.original.itemM = _container.width() % _base.settings.original.itemWidth;
  1501. methods.setResponsiveDimension(_base, _base.settings.original.groupWidth,true);
  1502. }
  1503. if (_init === true || _options === true) {
  1504. _base.settings.original.initGroupWidth = _base.settings.original.groupWidth;
  1505. if (methods.isCompact(_base)) {
  1506. var _percent = 100 / _base.settings.original.count;
  1507. _base.$tabs.each(function () { $(this).css({ "width": _percent + "%" }) });
  1508. }
  1509. _base.settings.original.position = _base.settings.position;
  1510. }
  1511. if (_base.settings.responsive === true) {
  1512. methods.responsive(_base, _init);
  1513. }
  1514. var _isResORCompact = ( (methods.isCompact(_base) && !methods.isMobile(_base)));
  1515. var _css = (methods.isResponsive(_base) && _base.BrowserDetection.isIE(7)) ? { "float": "none", "width": "auto" } : { "float": "" }; //version 5.1 removed float right
  1516. var _hasResponsiveClass = _base.$elem.hasClass(RESPONSIVECLASS);
  1517. _base.$tabs.each(function (index) {
  1518. if (((_hasResponsiveClass === true && (index + 1) === _base.settings.original.itemD) || (index + 1) === _base.settings.original.count) && _isResORCompact) {
  1519. $(this).css(_css);
  1520. }
  1521. else {
  1522. $(this).css({ "float": "" });
  1523. }
  1524. });
  1525. if (_base.settings.orientation === VERTICALCLASS) {
  1526. methods.setContentHeight(_base, null, true);
  1527. }
  1528. },
  1529. checkModes:function (_base) {
  1530. var _isCompact = methods.isCompact(_base);
  1531. if (_base.settings.mode === zozo.modes.stacked) {
  1532. _base.$elem.addClass(STACKEDCLASS);
  1533. _base.$elem.addClass(RESPONSIVECLASS);
  1534. _base.$tabs.css({ "width": "" });
  1535. (_base.$mobileNav) && _base.$mobileNav.hide();
  1536. } else {
  1537. if (_isCompact) {
  1538. var _percent = 100 / _base.settings.original.count
  1539. _base.$tabs.each(function () { $(this).css({ "float": "", "width": _percent + "%" }) });
  1540. } else {
  1541. _base.$tabs.each(function () { $(this).css({ "float": "", "width": "" }) });
  1542. }
  1543. }
  1544. },
  1545. getContentHeight: function (_base, _contentElement, _noAnimation) {
  1546. var _autoContentHeight = _base.settings.autoContentHeight;
  1547. var _size = { width: 0, height: 0 };
  1548. if (_autoContentHeight != true) {
  1549. _base.$contents.each(function (index, item) {
  1550. var _content = $(item);
  1551. var contentSize = methods.getElementSize(_content);
  1552. (contentSize.height > _size.height) && (_size.height = contentSize.height);
  1553. (contentSize.width > _size.width) && (_size.width = contentSize.width);
  1554. });
  1555. } else {
  1556. var _activeContent = _base.$elem.find("> .z-container > .z-content.z-active");
  1557. if (_contentElement != null) {
  1558. _activeContent = _contentElement;
  1559. }
  1560. _size.height = methods.getElementSize(_activeContent).height;
  1561. }
  1562. if (_base.settings.orientation === VERTICALCLASS && !methods.isMobile(_base)) {
  1563. var _containerSize = 0;
  1564. _base.$tabs.each(function (index) {
  1565. _containerSize = _containerSize + parseInt($(this).height()) + parseInt($(this).css("border-top-width")) + parseInt($(this).css("border-bottom-width"));
  1566. });
  1567. _size.height = methods.isLarger(_size.height, _base.$tabGroup.innerHeight());
  1568. _size.height = methods.isLarger(_size.height, _containerSize);
  1569. }
  1570. return _size;
  1571. },
  1572. setContentHeight: function (_base, _contentElement, _noAnimation) {
  1573. //_heightOption: auto, largest,
  1574. var _size = methods.getContentHeight(_base,_contentElement,_noAnimation);
  1575. _base.settings.original.contentMaxHeight = _size.height;
  1576. _base.settings.original.contentMaxWidth = _size.width;
  1577. var _duration = (_base.settings.animation.effects === zozo.animation.effects.none || _noAnimation === true) ? 0 : _base.settings.animation.duration;
  1578. var _autoContentHeight = _base.settings.autoContentHeight;
  1579. var _transition = $.zozo.core.support.css.transition;
  1580. var _cssProperties = { _transition: "none", 'min-height': _base.settings.original.contentMaxHeight + "px" };
  1581. //var _cssProperties = { _transition: "none", "height": _base.settings.original.contentMaxHeight + "px", 'min-height': _base.settings.original.contentMaxHeight + "px" };
  1582. if (_noAnimation === true) {
  1583. _base.$container.css(_cssProperties);
  1584. }
  1585. else {
  1586. methods.animate(_base, _base.$container, null, _cssProperties, {});
  1587. }
  1588. return _base;
  1589. },
  1590. responsive: function (_base, _init) {
  1591. var _windowSize = $(window).width();
  1592. var _isTop = methods.isTop(_base);
  1593. var _isCompact = methods.isCompact(_base);
  1594. var _isContentLarger = _base.settings.original.initGroupWidth >= _base.$container.width();
  1595. var _maxRowsExecuted = _base.settings.original.rows > _base.settings.maxRows;
  1596. var _minWidthExecuted = _windowSize <= _base.settings.minWindowWidth;
  1597. var _enableMobileNav = (!_base.BrowserDetection.isIE(8) && _base.settings.mobileNav === true && _base.$mobileNav!=null);
  1598. var _count = _base.settings.original.count;
  1599. var _itemCount = _base.settings.original.itemCount;
  1600. var _itemD = _base.settings.original.itemD;
  1601. var _rows = _base.settings.original.rows;
  1602. _base.$elem.removeClass(STACKEDCLASS);
  1603. _base.$tabs.removeClass(zozo.classes.left).removeClass(zozo.classes.right).removeClass(zozo.classes.firstCol).removeClass(zozo.classes.lastCol).removeClass(zozo.classes.firstRow).removeClass(zozo.classes.lastRow)
  1604. if (_base.settings.orientation === HORIZONTALCLASS) {
  1605. var _compactResp = (_isCompact && (parseInt(_base.settings.original.count * _base.settings.original.itemWidth) >= _base.$container.width()))
  1606. var _normalResp = (!_isCompact && _isContentLarger);
  1607. var _isHorizontalResponsive = _compactResp || _normalResp;
  1608. if (_isHorizontalResponsive) {
  1609. (_rows === _count || (_base.settings.mode === zozo.modes.stacked)) && (_base.$elem.addClass(STACKEDCLASS));
  1610. _base.$tabs.each(function (index) {
  1611. var _item = $(this);
  1612. var _currentIndex = (index + 1);
  1613. if (_base.settings.original.itemM > 0) {
  1614. if (_currentIndex <= _itemCount) {
  1615. _item.css({ "float": "", "width": _base.settings.original.firstRowWidth + "%" });
  1616. }
  1617. else {
  1618. _item.css({ "float": "", "width": _base.settings.original.lastItem + "%" });
  1619. }
  1620. if (_isTop ===true) {
  1621. (index === (_itemD - 1)) ? _item.addClass(zozo.classes.right) : _item.removeClass(zozo.classes.right);
  1622. }
  1623. else{
  1624. (_currentIndex === _count) && (_item.addClass(zozo.classes.right));
  1625. (index === _base.settings.original.bottomLeft) && (_item.addClass(zozo.classes.left));
  1626. }
  1627. //console.log("_currentIndex: " + _currentIndex + " _itemD: " + _itemD + " _itemCount: " + _itemCount + " _rows: " + _rows + " _count: " + _count);
  1628. if (_rows > 1 && _itemD!==1) {
  1629. (_currentIndex === 1 || (_currentIndex > _itemD && (_currentIndex % _itemD === 1))) && (_item.addClass(zozo.classes.firstCol));
  1630. (_currentIndex === _count || (_currentIndex >= _itemD && (_currentIndex % _itemD === 0))) && (_item.addClass(zozo.classes.lastCol));
  1631. (_currentIndex <= _itemD) && (_item.addClass(zozo.classes.firstRow));
  1632. (_currentIndex > (_itemD * (_rows - 1))) && (_item.addClass(zozo.classes.lastRow));
  1633. }
  1634. }
  1635. });
  1636. methods.switchResponsiveClasses(_base, true);
  1637. } else {
  1638. if (_isCompact) {
  1639. var _percent = 100 / _base.settings.original.count;
  1640. _base.$tabs.each(function () { $(this).css({ "float": "", "width": _percent + "%" }) });
  1641. } else {
  1642. _base.$tabs.each(function () { $(this).css({ "float": "", "width": "" }) });
  1643. }
  1644. methods.switchResponsiveClasses(_base, false);
  1645. }
  1646. if (_windowSize >= 1200 && _base.responsive != zozo.responsive.largeDesktop) {
  1647. _base.responsive = zozo.responsive.largeDesktop;
  1648. methods.switchMenu(_base, false);
  1649. }
  1650. if (_base.responsive != zozo.responsive.phone && _enableMobileNav && ((_minWidthExecuted) || ((_maxRowsExecuted)))) {
  1651. _base.responsive = 'auto';
  1652. _base.$elem.removeClass(RESPONSIVECLASS)
  1653. _base.$tabs.each(function () { $(this).css({ "width": "" }) });
  1654. _base.$tabs.filter("li:first-child").addClass(zozo.classes.first);
  1655. _base.$tabs.filter("li:last-child").addClass(zozo.classes.last);
  1656. methods.switchMenu(_base, true);
  1657. }
  1658. }
  1659. else {
  1660. // if (_enableMobileNav === true && (_windowSize <= zozo.responsive.phone || parseInt(_base.$elem.width() - _base.settings.original.itemWidth) < _base.settings.minWidth)) {
  1661. if (_enableMobileNav === true && (_minWidthExecuted || parseInt(_base.$elem.width() - _base.settings.original.itemWidth) < _base.settings.minWidth)) {
  1662. methods.switchMenu(_base, true);
  1663. } else {
  1664. methods.switchMenu(_base, false);
  1665. }
  1666. }
  1667. methods.refreshParents(_base, 0);
  1668. },
  1669. switchResponsiveClasses:function (_base, _resp) {
  1670. var _isTop = methods.isTop(_base);
  1671. var _oriPos = _base.settings.original.position;
  1672. var _topLeft = zozo.classes.positions.topLeft;
  1673. var _bLeft = zozo.classes.positions.bottomLeft;
  1674. if (_resp === true)
  1675. {
  1676. _base.$elem.addClass(RESPONSIVECLASS);
  1677. methods.switchMenu(_base, false);
  1678. _base.$elem.removeClass(_oriPos);
  1679. }
  1680. else {
  1681. (_isTop === true) ? _base.$elem.removeClass(_topLeft).addClass(_oriPos) : _base.$elem.removeClass(_bLeft).addClass(_oriPos);
  1682. methods.switchMenu(_base, false);
  1683. _base.$elem.removeClass(RESPONSIVECLASS);
  1684. _base.$tabs.removeClass(zozo.classes.last).filter("li:last-child").addClass(zozo.classes.last);
  1685. }
  1686. },
  1687. switchMenu: function (_base, _isMobile) {
  1688. var _themes = zozo.classes.themes;
  1689. var _sizes = zozo.classes.sizes;
  1690. var _positions = $.zozo.core.utils.toArray(zozo.classes.positions);
  1691. _base.$elem.removeClass(_themes.join(zozo.space));
  1692. if (_isMobile === true) {
  1693. (_base.$mobileNav) && _base.$mobileNav.addClass(zozo.states.closed).show();
  1694. _base.$tabGroup.addClass("z-hide-menu");
  1695. _base.$elem.addClass(MOBILECLASS);
  1696. _base.$elem.removeClass(_base.settings.orientation);
  1697. _base.$elem.removeClass(_base.settings.position);
  1698. (_base.settings.style === UNDERLINEDCLASS) ? _base.$elem.addClass("m-" + _base.settings.theme) : _base.$elem.addClass(_base.settings.theme);
  1699. } else {
  1700. _base.$elem.addClass(_base.settings.orientation);
  1701. _base.$elem.addClass(_base.settings.theme);
  1702. _base.$elem.addClass(_base.settings.position);
  1703. (_base.$mobileNav) && _base.$mobileNav.removeClass(zozo.states.closed);
  1704. _base.$tabGroup.removeClass("z-hide-menu");
  1705. _base.$tabs.filter("li:first-child").addClass(zozo.classes.first);
  1706. _base.$elem.removeClass(MOBILECLASS);
  1707. (_base.$mobileNav) && _base.$mobileNav.hide();
  1708. }
  1709. },
  1710. initAutoPlay: function (_base) {
  1711. if (_base.settings.autoplay !== false && _base.settings.autoplay != null) {
  1712. if (_base.settings.autoplay.interval > 0) {
  1713. _base.stop();
  1714. _base.autoplayIntervalId = setInterval(function () { _base.next(_base); }, _base.settings.autoplay.interval);
  1715. } else {
  1716. _base.stop();
  1717. }
  1718. }
  1719. else {
  1720. _base.stop();
  1721. }
  1722. },
  1723. changeHash: function (_base, tab) {
  1724. var _prefix = (_base.settings.deeplinkingPrefix) ? _base.settings.deeplinkingPrefix : _base.tabID;
  1725. if (_base.settings.animating !== true) {
  1726. if (_base.settings.deeplinking === true) {
  1727. if (typeof ($(window).hashchange) != "undefined") {
  1728. //window.zozo.debug.start();
  1729. _base.Deeplinking.set(_prefix, tab, _base.settings.deeplinkingSeparator, _base.settings.deeplinkingMode);
  1730. //window.zozo.debug.stop();
  1731. }
  1732. else {
  1733. if (_base.BrowserDetection.isIE(7)) {
  1734. //IE and browsers that don't support hashchange
  1735. methods.showTab(_base, tab);
  1736. }
  1737. else {
  1738. //modern browsers
  1739. _base.Deeplinking.set(_prefix, tab, _base.settings.deeplinkingSeparator, _base.settings.deeplinkingMode);
  1740. }
  1741. }
  1742. }
  1743. else {
  1744. methods.showTab(_base, tab);
  1745. }
  1746. }
  1747. },
  1748. getFirst: function (_base) {
  1749. return 0;
  1750. },
  1751. getLast: function (_base) {
  1752. if (_base.settings.noTabs === true) {
  1753. return parseInt(_base.$container.children("div").size()-1);
  1754. }
  1755. return parseInt(_base.$tabGroup.children("li").size()-1);
  1756. },
  1757. isCompact: function (_base) {
  1758. return (_base.settings.position === zozo.classes.positions.topCompact || _base.settings.position === zozo.classes.positions.bottomCompact)
  1759. },
  1760. isTop: function (_base) {
  1761. if (_base.settings.original.position === null)
  1762. {
  1763. _base.settings.original.position = _base.settings.position;
  1764. }
  1765. return (_base.settings.original.position.indexOf("top") >= 0);
  1766. },
  1767. isLightTheme: function (_base) {
  1768. var _lightThemes = ["red", "deepblue", "blue", "green", "orange", "black"];
  1769. var _isLight = true;
  1770. var _isFlat = methods.isFlatTheme(_base);
  1771. if (_base.settings.style !== UNDERLINEDCLASS) {
  1772. ($.inArray(_base.settings.theme, _lightThemes) > -1) && (_isLight = false);
  1773. (_isFlat) && (_isLight = false);
  1774. }
  1775. return _isLight;
  1776. },
  1777. isFlatTheme: function (_base) {
  1778. return (_base.settings.theme.indexOf("flat") >= 0);
  1779. },
  1780. isResponsive: function (_base) {
  1781. return (_base.$elem.hasClass(RESPONSIVECLASS) === true)
  1782. },
  1783. tabExist: function (_base, tab) {
  1784. return (_base.$tabs.filter("li[" + _base.settings.hashAttribute + "='" + tab + "']").length> 0)
  1785. },
  1786. isMobile: function (_base) {
  1787. return (_base.$elem.hasClass(MOBILECLASS) === true)
  1788. },
  1789. isTabDisabled:function (_tab) {
  1790. return (_tab.hasClass(DISABLEDCLASS) || _tab.data(DISABLED) === true);
  1791. },
  1792. allowAutoScrolling: function (_base) {
  1793. return (_base.settings.mobileAutoScrolling != null && _base.settings.mobileAutoScrolling != false)
  1794. },
  1795. getElementSize: function (_content) {
  1796. var _size = { width: 0, height: 0 };
  1797. if (_content == null || _content.length == 0) {
  1798. return _size;
  1799. }
  1800. if (_content.is(":visible") === false) {
  1801. _size.height = _content.show().find(">.z-content-inner").innerHeight();
  1802. _size.width = _content.show().find(">.z-content-inner").outerWidth();
  1803. if (_size.height >= 0) {
  1804. //_size.height = _content.height();
  1805. }
  1806. _content.hide();
  1807. } else {
  1808. _size.height = _content.find(">.z-content-inner").innerHeight();
  1809. _size.width = _content.find(">.z-content-inner").outerWidth();
  1810. if (_size.height >= 0) {
  1811. //_size.height = _content.height();
  1812. }
  1813. }
  1814. (_content.hasClass("z-video") && ( _size.height= _content.innerHeight()));
  1815. return _size;
  1816. },
  1817. getWidth: function (object) {
  1818. if (object == null || object.length == 0) {
  1819. return 0;
  1820. }
  1821. object = object.find("a");
  1822. var value = object.outerWidth();
  1823. //value += parseInt(object.css("padding-left"), 10) + parseInt(object.css("padding-right"), 10); //Total Padding Width
  1824. value += parseInt(object.css("margin-left"), 10) + parseInt(object.css("margin-right"), 10); //Total Margin Width
  1825. value += parseInt(object.css("borderLeftWidth"), 10) + parseInt(object.css("borderRightWidth"), 10); //Total Border Width
  1826. return value;
  1827. },
  1828. isLarger: function (_small, _large) {
  1829. var _r = _small;
  1830. if (_small < _large)
  1831. {
  1832. _r = _large;
  1833. }
  1834. return _r;
  1835. }
  1836. };
  1837. var transition = {
  1838. init: function (_base, _tabElement) {
  1839. _base.$contents.hide()
  1840. _tabElement.content.css({ "opacity": "", "left": "", "top": "", "position": "relative" }).show();
  1841. setTimeout(function () {
  1842. _base.$container.find(".z-tabs").each(function (index, item) {$(item).data('zozoTabs').refresh();});
  1843. _base.$elem.trigger(SELECT, { tab: _tabElement.tab, content: _tabElement.content, index: _tabElement.index });
  1844. _base.settings.animating = false;
  1845. }, _tabElement.duration >= 0 ? 200 : _tabElement.duration);
  1846. if (_base.settings.orientation === VERTICALCLASS) {
  1847. /*set content height for animation*/
  1848. methods.setContentHeight(_base, _tabElement.content,true);
  1849. }
  1850. return _base;
  1851. },
  1852. before: function (_base, _tabElement) {
  1853. setTimeout(function () {
  1854. _tabElement.content.find(".z-tabs").each(function (index, item) { $(item).data('zozoTabs').refresh(); });
  1855. }, 50);
  1856. if (_base.settings.animation.effects !== zozo.animation.effects.none) {
  1857. /*set content height for animation*/
  1858. methods.setContentHeight(_base, _tabElement.preContent, true);
  1859. methods.setContentHeight(_base, _tabElement.content);
  1860. }
  1861. _base.$container.addClass(ANIMATINGCLASS);
  1862. _tabElement.preContent.css({ "position": "absolute", "display": "block", "left": 0, "top": 0 });
  1863. _tabElement.content.css({ "position": "absolute", "display": "block" });
  1864. return _base;
  1865. },
  1866. after: function (_base, _tabElement) {
  1867. setTimeout(function () {
  1868. _tabElement.content.css({ "position": "relative" });
  1869. _tabElement.preContent.css({ "display": "none" });
  1870. }, _tabElement.duration);
  1871. /*hide all other tab contents*/
  1872. _base.$contents.each(function (index, item) {
  1873. if (_tabElement.index != index && _tabElement.preIndex != index) {
  1874. $(item).css({ _transition: "", "position": "", "display": "", "left": "", "top": "" });
  1875. }
  1876. });
  1877. setTimeout(function () {
  1878. _base.$elem.trigger(SELECT, { tab: _tabElement.tab, content: _tabElement.content, index: _tabElement.index });
  1879. _base.$elem.trigger(DEACTIVATE, { tab: _tabElement.preTab, content: _tabElement.preContent, index: _tabElement.preIndex });
  1880. var _cssProperties = (_base.settings.orientation === VERTICALCLASS) ? { "height": "" } : { "height": "", "min-height": "", "overflow": "" };
  1881. /*remove content height and set relative positioning*/
  1882. _base.$container.css(_cssProperties);
  1883. _base.$container.removeClass(ANIMATINGCLASS);
  1884. setTimeout(function () {
  1885. _base.$contents.removeClass(zozo.classes.active).eq(_tabElement.index).addClass(zozo.classes.active);
  1886. _base.settings.animating = false;
  1887. _base.$contents.stop(true, true);
  1888. });
  1889. }, _tabElement.duration+50);
  1890. return _base;
  1891. }
  1892. };
  1893. ZozoTabs.defaults = ZozoTabs.prototype.defaults;
  1894. $.fn.zozoTabs = function (options) {
  1895. return this.each(function () {
  1896. if (undefined == $(this).data(zozo.pluginName)) {
  1897. var zozoTabs = new ZozoTabs(this, options).init();
  1898. $(this).data(zozo.pluginName, zozoTabs);
  1899. }
  1900. });
  1901. };
  1902. window.zozo.tabs = ZozoTabs;
  1903. $(document).ready(function () {
  1904. $("[data-role='z-tabs']").each(function (index, item) {
  1905. if (!$(item).zozoTabs()) {
  1906. $(item).zozoTabs();
  1907. }
  1908. });
  1909. });
  1910. })(jQuery, window, document);