suffusion.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*************************************************
  2. ** jQuery Masonry version v2.1.04
  3. ** Copyright David DeSandro, licensed MIT
  4. ** http://desandro.com/resources/jquery-masonry
  5. **************************************************/
  6. (function(a,b,c){"use strict";var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()},b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[];var d=this.element[0].style;this.originalStyle={height:d.height||""};var e=this.options.containerStyle;for(var f in e)this.originalStyle[f]=d[f]||"";this.element.css(e),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={x:parseInt(this.element.css("padding-"+this.horizontalDirection),10),y:parseInt(this.element.css("padding-top")+16,10)},this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth=="function";var g=this;setTimeout(function(){g.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){g.resize()}),this.reloadItems()},_init:function(a){this._getColumns(),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,b){for(var c=0,d=a.length;c<d;c++)this._placeBrick(a[c]);var e={};e.height=Math.max.apply(Math,this.colYs);if(this.options.isFitWidth){var f=0;c=this.cols;while(--c){if(this.colYs[c]!==0)break;f++}e.width=(this.cols-f)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:e});var g=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",h=this.options.animationOptions,i;for(c=0,d=this.styleQueue.length;c<d;c++)i=this.styleQueue[c],i.$el[g](i.style,h);this.styleQueue=[],b&&b.call(a),this.isLaidOut=!0},_getColumns:function(){var a=this.options.isFitWidth?this.element.parent():this.element,b=a.width();this.columnWidth=this.isFluid?this.options.columnWidth(b):this.options.columnWidth||this.$bricks.outerWidth(!0)||b,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((b+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(a){var c=b(a),d,e,f,g,h;d=Math.ceil(c.outerWidth(!0)/(this.columnWidth+this.options.gutterWidth)),d=Math.min(d,this.cols);if(d===1)f=this.colYs;else{e=this.cols+1-d,f=[];for(h=0;h<e;h++)g=this.colYs.slice(h,h+d),f[h]=Math.max.apply(Math,g)}var i=Math.min.apply(Math,f),j=0;for(var k=0,l=f.length;k<l;k++)if(f[k]===i){j=k;break}var m={top:i+this.offset.y};m[this.horizontalDirection]=this.columnWidth*j+this.offset.x,this.styleQueue.push({$el:c,style:m});var n=i+c.outerHeight(!0),o=this.cols+1-l;for(k=0;k<o;k++)this.colYs[j+k]=n},resize:function(){var a=this.cols;this._getColumns(),(this.isFluid||this.cols!==a)&&this._reLayout()},_reLayout:function(a){var b=this.cols;this.colYs=[];while(b--)this.colYs.push(0);this.layout(this.$bricks,a)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(a){this.reloadItems(),this._init(a)},appended:function(a,b,c){if(b){this._filterFindBricks(a).css({top:this.element.height()});var d=this;setTimeout(function(){d._appended(a,c)},1)}else this._appended(a,c)},_appended:function(a,b){var c=this._getBricks(a);this.$bricks=this.$bricks.add(c),this.layout(c,b)},remove:function(a){this.$bricks=this.$bricks.not(a),a.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var c=this.element[0].style;for(var d in this.originalStyle)c[d]=this.originalStyle[d];this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),b(a).unbind(".masonry")}},b.fn.imagesLoaded=function(a){function i(a){var c=a.target;c.src!==f&&b.inArray(c,g)===-1&&(g.push(c),--e<=0&&(setTimeout(h),d.unbind(".imagesLoaded",i)))}function h(){a.call(c,d)}var c=this,d=c.find("img").add(c.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",g=[];e||h(),d.bind("load.imagesLoaded error.imagesLoaded",i).each(function(){var a=this.src;this.src=f,this.src=a});return c};var f=function(b){a.console&&a.console.error(b)};b.fn.masonry=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"masonry");if(!d)f("cannot call methods on masonry prior to initialization; attempted to call method '"+a+"'");else{if(!b.isFunction(d[a])||a.charAt(0)==="_"){f("no such method '"+a+"' for masonry instance");return}d[a].apply(d,c)}})}else this.each(function(){var c=b.data(this,"masonry");c?(c.option(a||{}),c._init()):b.data(this,"masonry",new b.Mason(a,this))});return this}})(window,jQuery);
  7. /*!
  8. * jQuery Fancy Letter Plugin v1.1
  9. *
  10. * Date: Sun Feb 06 20:51:59 2011 EST
  11. * Requires: jQuery v1.2.6+
  12. *
  13. * Copyright 2011, Karl Swedberg
  14. * Dual licensed under the MIT and GPL licenses (just like jQuery):
  15. * http://www.opensource.org/licenses/mit-license.php
  16. * http://www.gnu.org/licenses/gpl.html
  17. *
  18. * Contributor: Matt Wiebe (::first-letter spec semi-conformance)
  19. *
  20. *
  21. */
  22. (function(g){g.fn.fancyletter=function(m){function k(a,d,b){return['<span class="',b.punctuationClass," ",b.ltrClassPrefix+b["punctuation"+a][d],'">',d,"</span>"].join("")}function l(a,d){var b=a.firstChild,e="",f={};if(!a)return f;for(;a.childNodes.length;)a=a.firstChild;e=a.nodeValue&&a.nodeValue.replace(/^\s\s*/,"")||"";if(e===""&&b&&b.nextSibling)return l(b.nextSibling,d);else{b=e;for(var i=f="",c=0,h=b.charAt(c),j={};h in d.punctuationLeft;){c++;f+=k("Left",h,d);h=b.charAt(c)}j.pl=f;j.firstChar=
  23. h;c++;for(h=b.charAt(c);h in d.punctuationRight;){c++;i+=k("Right",h,d);h=b.charAt(c)}j.pr=i;j.slicePoint=c;f=j;f.node=a;f.val=e;return f}}this.each(function(){var a,d,b,e,f=this;a=g(this);var i=g.extend({},g.fn.fancyletter.defaults,m||{},g.metadata?a.metadata():g.meta?a.data():{}),c=RegExp(i.characters);e=l(f,i);if(e.firstChar){a=e.val;f=e.node;d=e.firstChar;b=d.toLowerCase();if(c.test(d)){c=g("<span></span>");f.nodeValue=a.slice(e.slicePoint);c.html(e.pl+d+e.pr);c.addClass(i.commonClass+" "+i.ltrClassPrefix+
  24. b);c.prependTo(this)}}});return this};g.fn.fancyletter.defaults={commonClass:"fancy-letter",ltrClassPrefix:"ltr-",characters:"[a-zA-Z0-9]",groupPunctuation:true,punctuationClass:"punct",punctuationLeft:{'"':"dquo","'":"squo","\u201c":"ldquo","\u2018":"lsquo","\u00ab":"laquo","\u2039":"lsaquo","(":"lparen"},punctuationRight:{'"':"dquo","'":"squo","\u201d":"rdquo","\u2019":"rsquo","\u00bb":"raquo","\u203a":"rsaquo",")":"rparen"}}})(jQuery);
  25. /*!
  26. * http://tinynav.viljamis.com v1.03 by @viljamis
  27. * Licensed under the MIT license.
  28. */
  29. (function ($, window, i) {
  30. $.fn.tinyNav = function (options) {
  31. // Default settings
  32. var settings = $.extend({
  33. 'active' : 'selected', // String: Set the "active" class
  34. 'header' : false // Boolean: Show header instead of the active item
  35. }, options);
  36. return this.each(function () {
  37. // Used for namespacing
  38. i++;
  39. var $nav = $(this),
  40. // Namespacing
  41. namespace = 'tinynav',
  42. namespace_i = namespace + i,
  43. l_namespace_i = '.l_' + namespace_i,
  44. $select = $('<select/>').addClass(namespace + ' ' + namespace_i);
  45. if ($nav.is('ul,ol')) {
  46. if (settings.header) {
  47. $select.append(
  48. $('<option/>').text('Navigation')
  49. );
  50. }
  51. // Build options
  52. var options = '';
  53. $nav
  54. .addClass('l_' + namespace_i)
  55. .find('a')
  56. .each(function () {
  57. options += '<option value="' + $(this).attr('href') + '">';
  58. for (j = 0; j < $(this).parents('ul, ol').length - 1; j++) {
  59. options += '&mdash; ';
  60. }
  61. options += $(this).text() + '</option>';
  62. });
  63. // Append options into a select
  64. $select.append(options);
  65. var selectors = settings.active.split(',');
  66. var index_selectors = new Array();
  67. for (var i=0; i<selectors.length; i++) {
  68. index_selectors[i] = l_namespace_i + ' li.' + selectors[i];
  69. }
  70. index_selectors = index_selectors.join(',');
  71. // Select the active item
  72. if (!settings.header) {
  73. $select
  74. .find(':eq(' + $(l_namespace_i + ' li')
  75. .index($(index_selectors)) + ')')
  76. .attr('selected', true);
  77. }
  78. // Change window location
  79. $select.change(function () {
  80. window.location.href = $(this).val();
  81. });
  82. // Inject select
  83. $(l_namespace_i).after($select);
  84. }
  85. });
  86. };
  87. })(jQuery, this, 0);
  88. /*
  89. * Based on the public domain "Responsive Cycle SlideShow" by M. Mikkel Rummelhoff (http://mmikkel.no)
  90. * Modifications by Sayontan Sinha
  91. */
  92. (function(window){
  93. ResponsiveSlideShow.prototype.id = '';
  94. ResponsiveSlideShow.prototype.$container = null;
  95. ResponsiveSlideShow.prototype.$slides = null;
  96. ResponsiveSlideShow.prototype.orgWidth = -1;
  97. ResponsiveSlideShow.prototype.orgHeight = -1;
  98. ResponsiveSlideShow.prototype.activeSlideIndex = 0;
  99. ResponsiveSlideShow.prototype.options = {
  100. fx:'fade',
  101. speed:'fast',
  102. slideResize:0
  103. };
  104. function ResponsiveSlideShow($container, $slides, $options) {
  105. this.$container = $container;
  106. this.$slides = this.$container.children($slides + ':first');
  107. this.options = $options;
  108. this.init();
  109. }
  110. ResponsiveSlideShow.prototype.init = function() {
  111. this.id = this.$container.attr('id');
  112. // Check if there's a nav or pager element present
  113. this.options.startingSlide = this.activeSlideIndex;
  114. this.options.width = this.$container.width();
  115. this.options.before = onSlideChange;
  116. // Init slideshow
  117. this.$slides.show();
  118. this.$slides.cycle(this.options);
  119. // Get original dimensions
  120. if(this.orgWidth <= 0){
  121. this.orgWidth = this.$slides.width();
  122. this.orgHeight = this.$slides.height();
  123. }
  124. }
  125. // Call when width changes
  126. ResponsiveSlideShow.prototype.update = function() {
  127. if(this.$slides.width() !== this.$container.width()){ // Container width changed. Rebuild slideshow
  128. // Get the resize ratio
  129. var ratio = (Math.floor((this.$container.width() / this.orgWidth)*100))*.01;
  130. this.$slides.height(Math.floor(this.orgHeight * ratio));
  131. this.activeSlideIndex = this.$slides.find('.active').index();
  132. this.$slides.hide().cycle('destroy');
  133. this.init();
  134. }
  135. }
  136. function onSlideChange(currSlide,nextSlide) {
  137. jQuery(this).parent().find('.active').removeClass('active');
  138. jQuery(this).addClass('active');
  139. }
  140. window.ResponsiveSlideShow = ResponsiveSlideShow;
  141. }(window)); // End ResponsiveSlideShow
  142. /**
  143. * suffusion.js - Contains all custom JavaScript functions required by Suffusion
  144. */
  145. $j = jQuery.noConflict();
  146. $j.fn.extend({
  147. highlight: function(search, insensitive, hls_class){
  148. var regex = new RegExp("(<[^>]*>)|(\\b"+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +")", insensitive ? "ig" : "g");
  149. return this.html(this.html().replace(regex, function(a, b, c){
  150. return (a.charAt(0) == "<") ? a : "<span class=\""+ hls_class +"\">" + c + "</span>";
  151. }));
  152. }
  153. });
  154. $j.fn.removeHighlight = function() {
  155. return this.find("span.search-highlight").each(function() {
  156. with (this.parentNode) {
  157. replaceChild(this.firstChild, this);
  158. normalize();
  159. }
  160. }).end();
  161. };
  162. function sufHtmlEncode(value){
  163. return $j('<div/>').text(value).html();
  164. }
  165. function sufHtmlDecode(value){
  166. return $j('<div/>').html(value).text();
  167. }
  168. $j(document).ready(function() {
  169. /* Magazine JS, for the headline section */
  170. $j('.suf-mag-headlines div.suf-mag-headline-photo').hide();
  171. $j('div.suf-mag-headline-photo-first').show();
  172. $j('div.suf-mag-headline-block ul.mag-headlines li.suf-mag-headline-first a').addClass('tab-current');
  173. $j('div.suf-mag-headline-block ul.mag-headlines li a').hover(function(){
  174. var thisClass = this.className.substring(17, this.className.indexOf(" "));
  175. $j('.suf-mag-headlines div.suf-mag-headline-photo').hide();
  176. $j('div.suf-mag-headline-block ul.mag-headlines li a').removeClass('tab-current');
  177. $j('div.suf-mag-headline-photo-' + thisClass).show();
  178. $j(this).addClass('tab-current');
  179. } );
  180. /* End Magazine JS */
  181. /* Tabbed Widgets */
  182. $j('.tab-box div.sidebar-tab-content').hide();
  183. $j('div.sbtab-content-first').show();
  184. $j('.tab-box ul.sidebar-tabs li.sbtab-first a').addClass('tab-current');
  185. $j('.tab-box ul.sidebar-tabs li a').click(function(){
  186. var thisClass = this.className.substring(6, this.className.indexOf(" "));
  187. $j('.tab-box div.sidebar-tab-content').hide();
  188. $j('.tab-box div.sbtab-content-' + thisClass).show();
  189. $j('.tab-box ul.sidebar-tabs li a').removeClass('tab-current');
  190. $j(this).addClass('tab-current');
  191. });
  192. /* End Tabbed Widgets */
  193. /* JQuery-based fix for widgets that do not print "after_title" */
  194. $j('.dbx-handle').each(function() {
  195. $j(this).prependTo(this.parentNode.parentNode);
  196. });
  197. /* End JQuery-based fix */
  198. /* JQuery for tabbed sidebars */
  199. $j('.sidebar-tab .sidebar-tab-content').each(function() {
  200. var parentId = this.parentNode.id;
  201. var parentClass = this.parentNode.className;
  202. parentClass = parentClass.substring(12);
  203. $j(this).addClass('sbtab-content-' + parentId);
  204. $j(this).addClass(parentClass);
  205. $j(this).appendTo(this.parentNode.parentNode.parentNode);
  206. });
  207. $j('.tabbed-sidebar ul.sidebar-tabs a').each(function() {
  208. var parentId = this.parentNode.id;
  209. $j(this).addClass(parentId);
  210. });
  211. $j('#wsidebar-top.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
  212. $j('#wsidebar-top.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
  213. $j('#sidebar.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
  214. $j('#sidebar.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
  215. $j('#sidebar-b.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
  216. $j('#sidebar-b.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
  217. $j('#sidebar-2.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
  218. $j('#sidebar-2.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
  219. $j('#sidebar-2-b.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
  220. $j('#sidebar-2-b.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
  221. $j('#wsidebar-bottom.tabbed-sidebar ul.sidebar-tabs li:first').addClass('sbtab-first');
  222. $j('#wsidebar-bottom.tabbed-sidebar div.sidebar-tab-content:first').addClass('sbtab-content-first');
  223. $j('div.tabbed-sidebar div.sidebar-tab-content').hide();
  224. $j('div.sbtab-content-first').show();
  225. $j('div.tabbed-sidebar ul.sidebar-tabs li.sbtab-first a').addClass('tab-current');
  226. $j('div.tabbed-sidebar ul.sidebar-tabs li a').click(function(){
  227. $j(this).removeClass('tab-current');
  228. var thisClass = this.className.substring(12, this.className.length);
  229. var parentId = this.parentNode.parentNode.parentNode.id;
  230. $j('#' + parentId + '.tabbed-sidebar div.sidebar-tab-content').hide();
  231. $j('#' + parentId + '.tabbed-sidebar div.sbtab-content-' + thisClass).show();
  232. $j('#' + parentId + '.tabbed-sidebar ul.sidebar-tabs li a').removeClass('tab-current');
  233. $j(this).addClass('tab-current');
  234. });
  235. /* End tabbed sidebars */
  236. // Kill empty widget areas
  237. $j("#horizontal-outer-widgets-1, #horizontal-outer-widgets-2, #widgets-above-header").each(function () {
  238. if ($j(this).children().length == 0) {
  239. $j(this).remove();
  240. }
  241. });
  242. // Remove empty sub-menus, generated for Mega menus
  243. $j('ul.sf-menu .sub-menu').each(function() {
  244. if ($j(this).children().length == 0) {
  245. $j(this).remove();
  246. }
  247. });
  248. $j('#left-header-widgets ul.menu, #right-header-widgets ul.menu').each(function() {
  249. $j(this).addClass('sf-menu');
  250. });
  251. $j("ul.sf-menu > li").each(function() {
  252. if (this.childNodes.length > 1) {
  253. var drop_down = this.childNodes[1];
  254. if ($j(drop_down).hasClass('mm-warea') && $j(drop_down).find('.mm-widget').length != 0) {
  255. $j(this).removeClass('dd-tab').addClass('mm-tab');
  256. var a_tag_h = this.childNodes[0];
  257. var a_tag = $j(a_tag_h);
  258. a_tag.attr('href', '#');
  259. a_tag.attr('onclick', 'return false;');
  260. a_tag.prepend("<!--[if !IE]>--><span class='down-ptr'>&nbsp;</span><!--<![endif]-->");
  261. a_tag.append("<!--[if lt IE 7]>&nbsp;&nbsp;&darr;<![endif]--> <!--[if (!IE)|(gte IE 7)]><span class='down-ptr'>&nbsp;</span><![endif]-->");
  262. a_tag.addClass('with-arrow');
  263. }
  264. else if ($j(drop_down).find('.mm-widget').length == 0 && $j(this).hasClass('mm-tab')) {
  265. $j(this).remove();
  266. }
  267. else if (!$j(this).hasClass('mm-tab')) {
  268. $j(this).addClass('dd-tab');
  269. }
  270. }
  271. else {
  272. $j(this).removeClass('dd-tab').addClass('regular-tab');
  273. }
  274. });
  275. $j("ul.sf-menu .dd-tab > ul").each(function() {
  276. var a_tag_h = this.parentNode.childNodes[0];
  277. var a_tag = $j(a_tag_h);
  278. a_tag.prepend("<!--[if !IE]>--><span class='down-ptr'>&nbsp;</span><!--<![endif]-->");
  279. a_tag.append("<!--[if lt IE 7]>&nbsp;&nbsp;&darr;<![endif]--> <!--[if (!IE)|(gte IE 7)]><span class='down-ptr'>&nbsp;</span><![endif]-->");
  280. a_tag.addClass('with-arrow');
  281. });
  282. $j("ul.sf-menu .dd-tab ul ul").each(function() {
  283. var a_tag_h = this.parentNode.childNodes[0];
  284. var a_tag = $j(a_tag_h);
  285. a_tag.prepend("<!--[if !IE]>--><span class='float-ptr'>&nbsp;</span><!--<![endif]-->");
  286. a_tag.append("<!--[if lt IE 7]>&nbsp;&nbsp;&rarr;<![endif]--> <!--[if (!IE)|(gte IE 7)]><span class='float-ptr'>&nbsp;</span><![endif]-->");
  287. a_tag.addClass('drop');
  288. });
  289. $j("#nav ul.sf-menu .dd-tab, #nav-top ul.sf-menu .dd-tab").each(function() {
  290. $j(this).children('ul:first').hide();
  291. $j(this).find('ul:first').css({visibility: "hidden"});
  292. });
  293. $j("ul.sf-menu .dd-tab li.current_page_item > a, ul.sf-menu .dd-tab li.current-cat > a, ul.sf-menu .dd-tab li.current-menu-item > a, " +
  294. "ul.sf-menu li.current_page_item.dd-tab > a, ul.sf-menu li.current-cat.dd-tab > a, ul.sf-menu li.current-menu-item.dd-tab > a, " +
  295. "ul.sf-menu li.current_page_item.regular-tab > a, ul.sf-menu li.current-cat.regular-tab > a, ul.sf-menu li.current-menu-item.regular-tab > a").each(function() {
  296. $j(this).addClass('current');
  297. });
  298. $j("ul.sf-menu .mm-tab li.current_page_item > a, ul.sf-menu .mm-tab li.current-cat > a, ul.sf-menu .mm-tab li.current-menu-item > a, " +
  299. "ul.sf-menu li.current_page_item.mm-tab > a, ul.sf-menu li.current-cat.mm-tab > a, ul.sf-menu li.current-menu-item.mm-tab > a").each(function() {
  300. $j(this).addClass('mm-current');
  301. });
  302. $j("#nav ul.sf-menu .dd-tab, #nav ul.sf-menu .dd-tab li").hover(
  303. function() {
  304. if (Suffusion_JS.suf_nav_effect == 'fade') {
  305. $j(this).children('ul:first').fadeIn(Suffusion_JS.suf_nav_delay).css({visibility: "visible"});
  306. }
  307. else {
  308. $j(this).children('ul:first').show(Suffusion_JS.suf_nav_delay).css({visibility: "visible"});
  309. }
  310. },
  311. function() {
  312. $j(this).children('ul:first').hide();
  313. $j(this).find('ul:first').css({visibility: "hidden"});
  314. }
  315. );
  316. $j("#nav-top ul.sf-menu .dd-tab, #nav-top ul.sf-menu .dd-tab li").hover(
  317. function() {
  318. if (Suffusion_JS.suf_navt_effect == 'fade') {
  319. $j(this).find('ul:first').fadeIn(Suffusion_JS.suf_navt_delay).css({visibility: "visible"});
  320. }
  321. else {
  322. $j(this).find('ul:first').show(Suffusion_JS.suf_navt_delay).css({visibility: "visible"});
  323. }
  324. },
  325. function() {
  326. $j(this).children('ul:first').hide();
  327. $j(this).find('ul:first').css({visibility: "hidden"});
  328. }
  329. );
  330. // Expand Panel
  331. $j("#top-bar-right-spanel-tab .open").click(function(){
  332. $j("#top-bar-right-spanel").slideDown("medium");
  333. $j(this).css({ display: 'none' });
  334. $j("#top-bar-right-spanel-tab .close").css({ display: 'block' });
  335. return false;
  336. });
  337. // Collapse Panel
  338. $j("#top-bar-right-spanel-tab .close").click(function(){
  339. $j("#top-bar-right-spanel").slideUp("medium");
  340. $j(this).css({ display: 'none' });
  341. $j("#top-bar-right-spanel-tab .open").css({ display: 'block' });
  342. return false;
  343. });
  344. $j('#search-info input[type="checkbox"].search-hl').change(function(event) {
  345. var search = $j('#search-term').val();
  346. var hls_class = 'search-highlight';
  347. if ($j(this).attr('checked')) {
  348. // Highlight search results
  349. $j('#content .entry').each(function() {
  350. var quotes = search.match(/"([^"]+)"/g);
  351. var len = 0;
  352. var matches = new Array();
  353. if (quotes != null) {
  354. len = quotes.length;
  355. for (i=0; i<len; i++) {
  356. quotes[i] = quotes[i].replace(/"/g, '');
  357. matches[matches.length] = quotes[i];
  358. search = search.replace(quotes[i], ' ');
  359. }
  360. }
  361. var no_quotes = search.match(/\b[\S]+\b/g);
  362. if (no_quotes != null) {
  363. len = no_quotes.length;
  364. for (i=0; i<len; i++) {
  365. matches[matches.length] = no_quotes[i];
  366. }
  367. }
  368. len = matches.length;
  369. for (i=0; i<len; i++) {
  370. var search_string = matches[i];
  371. $j(this).highlight(search_string);
  372. $j(this).highlight(search_string, true, hls_class);
  373. }
  374. });
  375. }
  376. else {
  377. //Un-highlight search results
  378. $j('#content .entry').each(function() {
  379. $j(this).removeHighlight();
  380. });
  381. }
  382. });
  383. if (typeof Suffusion_JS.suf_jq_masonry_enabled != 'undefined' && Suffusion_JS.suf_jq_masonry_enabled == 'enabled') {
  384. //$j("#top-bar-right-spanel").masonry();
  385. //$j("#widgets-above-header").masonry();
  386. $j("#horizontal-outer-widgets-1").masonry();
  387. $j("#horizontal-outer-widgets-2").masonry();
  388. $j("#ad-hoc-1").masonry();
  389. $j("#ad-hoc-2").masonry();
  390. $j("#ad-hoc-3").masonry();
  391. $j("#ad-hoc-4").masonry();
  392. $j("#ad-hoc-5").masonry();
  393. }
  394. if (Suffusion_JS.suf_fix_aspect_ratio == 'preserve') {
  395. // If the HTML height attribute is present for images, the max-width setting really hammers the image proportions.
  396. $j(".entry img").removeAttr('height');
  397. }
  398. // Fixes for NGG on IE8. This should ideally be on NGG's plugin itself, but given their support or lack thereof :-( ...
  399. $j(".ngg-gallery-thumbnail img").removeAttr('height');
  400. $j(".ngg-gallery-thumbnail img").removeAttr('width');
  401. $j(".widget_calendar tbody td a").each(function() {
  402. var parent = this.parentNode;
  403. //var a_tag_h = this.parentNode.childNodes[0];
  404. var td_tag = $j(parent);
  405. td_tag.addClass('with-posts');
  406. });
  407. $j('a.suf-tile-icon').click(function() {
  408. var class_name = this.className;
  409. var thisId = this.id;
  410. var lastSep = thisId.lastIndexOf('-');
  411. var elementType = thisId.substr(0, lastSep);
  412. var elementId = thisId.substr(lastSep);
  413. var textElementId = elementType + '-text' + elementId;
  414. $j('#' + textElementId).toggle();
  415. if (class_name.indexOf('clicked') > -1) {
  416. $j(this).removeClass('clicked');
  417. }
  418. else {
  419. $j(this).addClass('clicked');
  420. }
  421. var parents = $j(this).parents();
  422. for (var i=0; i<parents.length; i++) {
  423. var parent = parents[i];
  424. if ($j(parent).hasClass('suf-tiles') || $j(parent).hasClass('suf-mag-excerpts')) {
  425. $j(parents[i-1]).css({
  426. 'min-height': 0
  427. });
  428. suffusion_make_tiles_equal($j(parent).children('.suf-tile, .suf-mag-excerpt'));
  429. break;
  430. }
  431. }
  432. return false;
  433. });
  434. // JQuery Cycle stops if there is only one image in it. The following snippet fixes the issue.
  435. $j('#sliderContent, .sliderContent').each(function() {
  436. if ($j(this).children().length == 1) {
  437. var single = this.firstChild;
  438. $j(single).show();
  439. }
  440. });
  441. $j('.mosaic-page-nav-right a, .mosaic-page-nav-left a').each(function() {
  442. var parentContainer = $j(this).parent().parent();
  443. var height = 0.45 * parentContainer.height();
  444. $j(this).css({top: height + 'px'});
  445. });
  446. var staticSlideShow;
  447. $j('#sliderContent').each(function() {
  448. staticSlideShow = new ResponsiveSlideShow($j('#slider'), '#sliderContent', {
  449. fx: Suffusion_JS.suf_featured_fx,
  450. timeout: Suffusion_JS.suf_featured_interval,
  451. speed: Suffusion_JS.suf_featured_transition_speed,
  452. pause: 1,
  453. sync: Suffusion_JS.suf_featured_sync,
  454. pager: '#sliderPager',
  455. prev: 'a.sliderPrev',
  456. next: 'a.sliderNext',
  457. slideResize: 0,
  458. pagerAnchorBuilder: suffusion_anchor_builder
  459. });
  460. });
  461. $j('a.sliderPause').click(
  462. function() {
  463. if ($j(this).text() == Suffusion_JS.suf_featured_pause) {
  464. $j('#sliderContent').cycle('pause');
  465. $j('a.sliderPause').addClass('activeSlide');
  466. $j(this).text(Suffusion_JS.suf_featured_resume);
  467. }
  468. else {
  469. $j('#sliderContent').cycle('resume');
  470. $j('a.sliderPause').removeClass('activeSlide');
  471. $j(this).text(Suffusion_JS.suf_featured_pause);
  472. }
  473. return false;
  474. }
  475. );
  476. $j('.controller-icons #sliderControl a, .controller-icons .sliderControl a').hover(
  477. function() {
  478. var parent = $j(this).parent();
  479. parent.children().addClass('slide-hovered');
  480. $j(this).addClass('control-hovered');
  481. },
  482. function() {
  483. var parent = $j(this).parent();
  484. parent.children().addClass('slide-hovered');
  485. $j(this).removeClass('control-hovered');
  486. }
  487. );
  488. $j('#slider, .slider').hover(
  489. function() {
  490. var parent = $j(this).parent();
  491. if (parent.hasClass('controller-icons')) {
  492. parent.find('.sliderPrev, .sliderNext').addClass('slide-hovered');
  493. }
  494. },
  495. function() {
  496. var parent = $j(this).parent();
  497. if (parent.hasClass('controller-icons')) {
  498. parent.find('.sliderPrev, .sliderNext').removeClass('slide-hovered');
  499. }
  500. }
  501. );
  502. $j('.collapse .searchfield').focus(function() {
  503. $j(this).addClass('search-focus');
  504. });
  505. $j('.collapse .searchfield').blur(function() {
  506. $j(this).removeClass('search-focus');
  507. });
  508. $j('a.suf-mosaic-thumb').each(function() {
  509. $j(this).data('title', $j(this).attr('title'));
  510. if ($j.fancybox) {
  511. $j(this).fancybox({
  512. transitionIn : 'elastic',
  513. transitionOut : 'elastic',
  514. speedIn : 600,
  515. speedOut : 200,
  516. overlayShow : true,
  517. overlayColor: '#000',
  518. overlayOpacity: 0.8
  519. });
  520. }
  521. else if ($j.colorbox) {
  522. $j(this).colorbox({
  523. opacity: 0.8,
  524. maxWidth: '95%',
  525. maxHeight: '95%'
  526. });
  527. }
  528. });
  529. $j('.mosaic-overlay').hover(function() {
  530. $j(this).stop().animate({
  531. opacity: 0.65
  532. }, "medium");
  533. }, function() {
  534. $j(this).stop().animate({
  535. opacity: 0
  536. }, "medium");
  537. });
  538. $j('.entry > p:first-child').each(function() {
  539. $j(this).addClass('first-para');
  540. });
  541. if (Suffusion_JS.suf_show_drop_caps != '') {
  542. $j(Suffusion_JS.suf_show_drop_caps).fancyletter();
  543. }
  544. $j(".exif-button .open").on('click', function(){
  545. $j(".exif-panel").slideDown("medium");
  546. $j(this).removeClass('open').addClass('close');
  547. return false;
  548. });
  549. // Collapse Panel
  550. $j(".exif-button .close").on('click', function(){
  551. $j(".exif-panel").slideUp("medium");
  552. $j(this).removeClass('close').addClass('open');
  553. return false;
  554. });
  555. $j('.mm-warea + .sub-menu').each(function() {
  556. $j(this).remove();
  557. });
  558. $j('.mm-warea').each(function() {
  559. if ($j(this).find('.mm-widget').length == 0) {
  560. $j(this).remove();
  561. return;
  562. }
  563. var parents = $j(this).parents();
  564. var parent_li = parents[0];
  565. var col_control = parents[2];
  566. var nav = parents[3];
  567. var nav_left = $j(nav).offset().left;
  568. var nav_right = nav_left + $j(nav).width();
  569. var left_pos, current_offset, right_pos;
  570. var padding = 10;
  571. if (nav.id == 'nav') {
  572. padding = 0;
  573. }
  574. if ($j(col_control).hasClass('center')) { // Centered menu. Mega-menu will be aligned centrally, but left & right positions will be adjusted to not cross the border.
  575. left_pos = -($j(this).width() / 2); // Does the centering by moving it to the left by 50% of its width.
  576. $j(this).css({ left: left_pos });
  577. current_offset = $j(this).offset();
  578. right_pos = current_offset.left + $j(this).width();
  579. if (current_offset.left < nav_left) { // Mega-menu has gone too far left. We will shift it by the difference + padding
  580. left_pos += nav_left - current_offset.left + padding;
  581. $j(this).css({ left: left_pos });
  582. }
  583. else if (right_pos > nav_right) { // Mega-menu has gone too far right. We will shift it by the difference + padding
  584. left_pos -= right_pos - nav_right + padding;
  585. $j(this).css({ left: left_pos });
  586. }
  587. }
  588. else if ($j(col_control).hasClass('left')) {
  589. left_pos = 0;
  590. $j(this).css({ left: left_pos });
  591. current_offset = $j(this).offset();
  592. right_pos = current_offset.left + $j(this).width();
  593. if (right_pos > nav_right) {
  594. left_pos -= right_pos - nav_right + padding;
  595. $j(this).css({ left: left_pos });
  596. }
  597. }
  598. else if ($j(col_control).hasClass('right')) {
  599. right_pos = 0;
  600. $j(this).css({ right: right_pos});
  601. current_offset = $j(this).offset();
  602. left_pos = current_offset.left;
  603. if (left_pos < nav_left) {
  604. right_pos -= nav_left - left_pos + padding;
  605. $j(this).css({ right: right_pos});
  606. }
  607. }
  608. $j(this).children('.mm-mason').masonry();
  609. });
  610. $j(".mm-warea .float-ptr").each(function() {
  611. $j(this).remove();
  612. });
  613. $j(".mm-warea .drop").each(function() {
  614. $j(this).removeClass('drop');
  615. });
  616. $j(".mm-warea select").focus(function() {
  617. $j(this).parents('.mm-warea').addClass('keep-open');
  618. });
  619. $j(".mm-warea select").blur(function() {
  620. $j(this).parents('.mm-warea').removeClass('keep-open');
  621. });
  622. $j(".mm-warea option").hover(
  623. function() {
  624. $j(this).parents('.mm-warea').addClass('keep-open');
  625. },
  626. function() {
  627. $j(this).parents('.mm-warea').removeClass('keep-open');
  628. }
  629. );
  630. $j('.mm-widget img, .cl-widget img').each(function() {
  631. var widget = $j(this).parents('.mm-widget, .cl-widget');
  632. if ($j(this).width() > $j(widget).innerWidth()) {
  633. $j(this).css({width: '100%'});
  634. }
  635. });
  636. $j(window).resize(function() {
  637. if (typeof staticSlideShow != 'undefined') {
  638. staticSlideShow.update();
  639. $j('.controller-icons #sliderControl').css({
  640. top: '-' + ($j('#sliderContent').height() / 2) + 'px'
  641. });
  642. }
  643. suffusion_balance_heights('.suf-tiles, .suf-mag-excerpts, .suf-mag-categories, .cl-warea, .mm-row-equal');
  644. });
  645. $j(function() {
  646. if (typeof staticSlideShow != 'undefined') {
  647. //staticSlideShow.update();
  648. $j('.controller-icons #sliderControl').css({
  649. top: '-' + ($j('#sliderContent').height() / 2) + 'px'
  650. });
  651. }
  652. suffusion_balance_heights('.suf-tiles, .suf-mag-excerpts, .suf-mag-categories, .cl-warea, .mm-row-equal');
  653. });
  654. $j(".sf-menu").tinyNav({
  655. active: 'current_page_item,current-cat,current-menu-item', // Set the "active" class
  656. header: false // Show header instead of the active item
  657. });
  658. function suffusion_anchor_builder(idx, slide) {
  659. var anchor;
  660. if (Suffusion_JS.suf_featured_pager_style == 'numbers') {
  661. anchor = (idx + 1);
  662. }
  663. else {
  664. anchor = '&nbsp;';
  665. }
  666. return '<a href="#">' + anchor + '</a>';
  667. }
  668. function suffusion_make_tiles_equal(tiles) {
  669. var tallest = 0;
  670. // Reset all tiles to 0 min-height
  671. tiles.css({
  672. 'height': 'auto'
  673. });
  674. tiles.each(function() {
  675. var currentHeight = $j(this).height();
  676. if (currentHeight > tallest) {
  677. tallest = currentHeight;
  678. }
  679. });
  680. tiles.css({
  681. 'height': tallest
  682. });
  683. }
  684. function suffusion_balance_heights(selector) {
  685. $j(selector).each(function() {
  686. var children = $j(this).find('.suf-tile, .suf-mag-excerpt, .suf-mag-category, .cl-widget, .mm-widget');
  687. var wareaColumns = 0;
  688. if ($j(this).hasClass('cl-warea') || $j(this).hasClass('mm-row-equal') || $j(this).hasClass('suf-tiles')) {
  689. var baseline = 10 < children.length ? 10 : children.length;
  690. for (var k = 0; k < baseline; k++) {
  691. if (k != 0 && $j(children[k-1]).position().top != $j(children[k]).position().top) {
  692. wareaColumns = k;
  693. break;
  694. }
  695. }
  696. if (wareaColumns == 0) {
  697. for (var k=1; k<=10; k++) {
  698. if ($j(this).hasClass('cl-warea-' + k) || $j(this).hasClass('mm-row-' + k) || $j(this).hasClass('suf-tiles-' + k)) {
  699. wareaColumns = k;
  700. break;
  701. }
  702. }
  703. }
  704. }
  705. if ($j(this).hasClass('cl-warea-all-row') || $j(this).hasClass('cl-warea-all') || $j(this).hasClass('mm-row-equal') || $j(this).hasClass('suf-tiles')) {
  706. for (var m = 0; m * wareaColumns < children.length; m = m + 1) {
  707. var slice = children.slice(m * wareaColumns, (m + 1) * wareaColumns);
  708. if ($j(this).hasClass('cl-warea-all-row') || $j(this).hasClass('mm-row-equal') || $j(this).hasClass('suf-tiles')) {
  709. suffusion_make_tiles_equal(slice);
  710. }
  711. }
  712. if ($j(this).hasClass('cl-warea-all')) {
  713. suffusion_make_tiles_equal(children);
  714. }
  715. }
  716. else if ($j(this).hasClass('cl-warea-masonry')) {
  717. $j(this).masonry({
  718. itemSelector: '.cl-widget',
  719. columnWidth: function(containerWidth) {
  720. if (wareaColumns == 0) {
  721. return containerWidth;
  722. }
  723. return containerWidth/wareaColumns;
  724. }
  725. });
  726. }
  727. suffusion_make_tiles_equal($j(this).children('.suf-mag-excerpt, .suf-mag-category'));
  728. });
  729. }
  730. });