tribulant

hanawey.org

Jul 26th, 2011
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.97 KB | None | 0 0
  1. <?php
  2. wp_deregister_script( 'jquery' ); // unregistered key jQuery
  3. wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', false, '1.4.4'); // register key jQuery with URL of Google CDN
  4. wp_enqueue_script( 'jquery' ); // include jQuery
  5. ?>
  6.  
  7. <?php if ( is_singular() ) wp_enqueue_script('comment-reply'); ?>
  8. <?php wp_head(); ?>
  9.  
  10. <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery-ui-1.8.6.custom.min.js"></script>
  11. <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.tools.min.js"></script>
  12. <script type="text/javascript">
  13. // function that writes the list order to a cookie
  14. function saveOrder() {
  15.     jQuery(".column").each(function(index, value){
  16.         var colid = value.id;
  17.         var cookieName = "cookie-" + colid;
  18.         // Get the order for this column.
  19.         var order = jQuery('#' + colid).sortable("toArray");
  20.         // For each portlet in the column
  21.         for ( var i = 0, n = order.length; i < n; i++ ) {
  22.             // Determine if it is 'opened' or 'closed'
  23.             var v = jQuery('#' + order[i] ).find('.portlet-content').is(':visible');
  24.             // Modify the array we're saving to indicate what's open and
  25.             //  what's not.
  26.             order[i] = order[i] + ":" + v;
  27.         }
  28.         jQuery.cookie(cookieName, order, { path: "/", expiry: new Date(2012, 1, 1)});
  29.     });
  30. }
  31.  
  32. // function that restores the list order from a cookie
  33. function restoreOrder() {
  34.     jQuery(".column").each(function(index, value) {
  35.         var colid = value.id;
  36.         var cookieName = "cookie-" + colid
  37.         var cookie = jQuery.cookie(cookieName);
  38.         if ( cookie == null ) { return; }
  39.         var IDs = cookie.split(",");
  40.         for (var i = 0, n = IDs.length; i < n; i++ ) {
  41.             var toks = IDs[i].split(":");
  42.             if ( toks.length != 2 ) {
  43.                 continue;
  44.             }
  45.             var portletID = toks[0];
  46.             var visible = toks[1]
  47.             var portlet = jQuery(".column")
  48.                 .find('#' + portletID)
  49.                 .appendTo(jQuery('#' + colid));
  50.             if (visible === 'false') {
  51.             }
  52.         }
  53.     });
  54. }
  55.  
  56. // function that writes the list order to a cookie
  57. // set the list selector
  58. var setSelector = "ul.widgets";
  59. // set the cookie name
  60. var setCookieName = "listOrder";
  61. // set the cookie expiry time (days):
  62. var setCookieExpiry = 7;
  63.  
  64. // function that writes the list order to a cookie
  65. function getOrder_s() {
  66.     // save custom order to cookie
  67.     jQuery.cookie(setCookieName, jQuery(setSelector).sortable("toArray"), { expires: setCookieExpiry, path: "/" });
  68. }
  69.  
  70. // function that restores the list order from a cookie
  71. function restoreOrder_s() {
  72.     var list = jQuery(setSelector);
  73.     if (list == null) return
  74.    
  75.     // fetch the cookie value (saved order)
  76.     var cookie = jQuery.cookie(setCookieName);
  77.     if (!cookie) return;
  78.    
  79.     // make array from saved order
  80.     var IDs = cookie.split(",");
  81.    
  82.     // fetch current order
  83.     var items = list.sortable("toArray");
  84.    
  85.     // make array from current order
  86.     var rebuild = new Array();
  87.     for ( var v=0, len=items.length; v<len; v++ ){
  88.         rebuild[items[v]] = items[v];
  89.     }
  90.    
  91.     for (var i = 0, n = IDs.length; i < n; i++) {
  92.        
  93.         // item id from saved order
  94.         var itemID = IDs[i];
  95.        
  96.         if (itemID in rebuild) {
  97.        
  98.             // select item id from current order
  99.             var item = rebuild[itemID];
  100.            
  101.             // select the item according to current order
  102.             var child = jQuery("ul.widgets.ui-sortable").children("#" + item);
  103.            
  104.             // select the item according to the saved order
  105.             var savedOrd = jQuery("ul.widgets.ui-sortable").children("#" + itemID);
  106.            
  107.             // remove all the items
  108.             child.remove();
  109.            
  110.             // add the items in turn according to saved order
  111.             // we need to filter here since the "ui-sortable"
  112.             // class is applied to all ul elements and we
  113.             // only want the very first!  You can modify this
  114.             // to support multiple lists - not tested!
  115.             jQuery("ul.widgets.ui-sortable").filter(":first").append(savedOrd);
  116.         }
  117.     }
  118. }
  119.  
  120. jQuery(function() {
  121.  
  122. // widgets/sortables
  123. jQuery(".column").sortable({
  124.         connectWith: ['.column'],
  125.         cursor: 'move',
  126.         handle: 'h3',
  127.         opacity: 0.80,
  128.         tolerance: 'pointer',
  129.         items: '.cat-widget',
  130.         revert: true,
  131.         stop: function() { saveOrder(); }
  132. });
  133.  
  134. restoreOrder();
  135.    
  136. // sidebar/sortables
  137. jQuery(".widgets").sortable({
  138.         cursor: 'move',
  139.         handle: 'h2',
  140.         items: '.widget',
  141.         opacity: 0.80,
  142.         tolerance: 'pointer',
  143.         revert: true,
  144.         update: function() { getOrder_s(); }
  145. });
  146.    
  147. restoreOrder_s();
  148.  
  149. // Layout options feature
  150. jQuery('a#options').click(function (){
  151.     if ((jQuery('.layout_options')).is(':hidden')) {
  152.     jQuery('.layout_options').fadeIn('normal');
  153.     } else {
  154.     jQuery('.layout_options').fadeOut('normal');
  155.     }
  156. });
  157.  
  158. jQuery('.cancel a').click(function() {
  159.     jQuery('#wrapper').fadeTo('fast', 1.0);
  160.     jQuery('.layout_options').fadeOut('normal');
  161. });
  162.  
  163. jQuery('a#reset').click(function() {
  164. jQuery('.cat-widget').each( function() {jQuery.cookie(jQuery(this).attr('id'), null, { path: '/', expires: 100 }); jQuery(this).show()});
  165. jQuery('.box_a').each( function() {jQuery.cookie(jQuery(this).attr('id'), null, { path: '/', expires: 100 }); jQuery(this).show()});
  166. jQuery('.widgets li').each (function() {jQuery.cookie(jQuery(this).attr('id'), null, { path: '/', expires: 100 }); jQuery(this).show()});
  167. jQuery('.layout_options').fadeOut('normal');
  168. jQuery('#wrapper').fadeTo('fast', 1.0);
  169. });
  170. // done.
  171.  
  172. // Pages Drop Down
  173. jQuery("#topnav ul ul").css({display: "none"}); // Opera Fix
  174. jQuery("#topnav li").hover(function(){
  175. if (jQuery(this).parent().parent().attr("id") == 'topnav') {
  176. jQuery(this).removeClass('active-page');
  177. jQuery(this).addClass('active-page');
  178. }
  179. jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(500);
  180. },function(){
  181. if (jQuery(this).parent().parent().attr("id") == 'topnav') {
  182. jQuery(this).removeClass('active-page');
  183. }
  184. jQuery(this).find('ul:first').css({visibility: "hidden"});
  185. });
  186. // End
  187.  
  188. // Categories Drop Down
  189. jQuery("#menu ul ul").css({display: "none"}); // Opera Fix
  190. jQuery("#menu li").hover(function(){
  191. if (jQuery(this).parent().parent().attr("id") == 'menu') {
  192. jQuery(this).removeClass('active-cat');
  193. jQuery(this).addClass('active-cat');
  194. }
  195. jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(500);
  196. },function(){
  197. if (jQuery(this).parent().parent().attr("id") == 'menu') {
  198. jQuery(this).removeClass('active-cat');
  199. }
  200. jQuery(this).find('ul:first').css({visibility: "hidden"});
  201. });
  202. // End
  203.  
  204. /* various widget actions */
  205. jQuery('.minimize').click(function() {
  206.     jQuery(this).parent('h3').next('.container').toggle();
  207. });
  208.  
  209. jQuery('.Sminimize').click(function() {
  210.     jQuery(this).parent('h2').next().toggle();
  211. });
  212.  
  213. jQuery('.Wminimize').click(function() {
  214.     jQuery(this).parent('h2').next().toggle();
  215. });
  216.  
  217. jQuery('.close').click(function() {
  218.     jQuery(this).parent('h3').parent('.cat-widget').fadeOut('slow');
  219.     jQuery.cookie(jQuery(this).parent('h3').parent('.cat-widget').attr('id'), 'closed', { path: '/', expires: 100 });
  220.     return false;
  221. });
  222.  
  223. jQuery('.Sclose').click(function() {
  224.     jQuery(this).parent('h2').parent().fadeOut('slow');
  225.     jQuery.cookie(jQuery(this).parent('h2').parent('.box_a').attr('id'), 'closed', { path: '/', expires: 100 });
  226.     return false;
  227. });
  228.  
  229. jQuery('.Wclose').click(function() {
  230.     jQuery(this).parent('h2').parent().fadeOut('slow');
  231.     jQuery.cookie(jQuery(this).parent('h2').parent('li').attr('id'), 'closed', { path: '/', expires: 100 });
  232.     return false;
  233. });
  234.  
  235. jQuery('.cat-widget').each( function() {
  236.     var cat_ID = jQuery(this).attr('id');
  237.     if (jQuery.cookie(cat_ID) == 'closed') jQuery(this).hide();
  238. });
  239.  
  240. jQuery('.box_a').each( function() {
  241.     var box_ID = jQuery(this).attr('id');
  242.     if (jQuery.cookie(box_ID) == 'closed') jQuery(this).hide();
  243. });
  244.  
  245. jQuery('.widgets li').each (function() {
  246.     var sidebar_ID = jQuery(this).attr('id');
  247.     if (jQuery.cookie(sidebar_ID) == 'closed') jQuery(this).hide();
  248. });
  249.  
  250. /* clear form */
  251. jQuery('.clearfield').each(function() {
  252.     var default_value = this.value;
  253.     jQuery(this).css('color', '#666'); // this could be in the style sheet instead
  254.     jQuery(this).focus(function() {
  255.         if(this.value == default_value) {
  256.             this.value = '';
  257.         }
  258.     });
  259.     jQuery(this).blur(function() {
  260.         if(this.value == '') {
  261.             this.value = default_value;
  262.         }
  263.     });
  264. });
  265.  
  266. // video thumbs
  267. jQuery('.videothumb').bind('mouseenter', function() {jQuery(this).children('.playit').children('a').show()});
  268. jQuery('.videothumb').bind('mouseleave', function() {jQuery(this).children('.playit').children('a').hide()});
  269.  
  270. // more stories
  271. jQuery('ul.more_stories li').css({'display': 'none'});
  272. jQuery("ul.more_stories").each(function(){
  273. jQuery(this).children('li').slice(0, <?php echo $comfy['moreitems']; ?>).show();
  274. });
  275.  
  276. /* control visible stories */
  277. jQuery('.minus').click(function() {
  278. jQuery(this).parent().next('ul').children('li:visible:last').hide();
  279. });
  280.  
  281. jQuery('.plus').click(function() {
  282. jQuery(this).parent().next('ul').children('li:hidden:first').show();
  283. });
  284.  
  285. // append top menu
  286. jQuery("#topnav ul:first").prepend('<li class="left"></li>');
  287. jQuery("#topnav ul:first").append('<li class="right"></li>');
  288.  
  289. // featured 1
  290. jQuery("span.overlay").fadeTo(1, 0.70);
  291. jQuery("ul.items").tabs(".pane", {
  292.     effect: "fade",
  293.     fadeInSpeed: 500,
  294.     fadeOutSpeed: 500,
  295.     rotate: true
  296. }).slideshow({autoplay: true, interval: 4000, clickable: false});
  297.    
  298. // featured 2
  299. jQuery("ul.featuredposts").tabs(".featuredposts_content", {
  300.     effect: "default",
  301.     rotate: true
  302. }).slideshow({autoplay: true, interval: 4000, clickable: false});
  303.  
  304. });
  305. </script>
  306.  
  307. <?php if (defined('AJAX_COMMENTS_URL')) : ?>
  308. <?php
  309. print '<script type="text/javascript" src="'. AJAX_COMMENTS_URL .'/jquery/jquery.js"></script>'."\n";
  310. print '<script type="text/javascript" src="'. AJAX_COMMENTS_URL .'/ajax-comments.js.php"></script>'."\n";
  311. ?>
  312. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment