1/** 2 * Public JS functions 3 * 4 * @package GCE 5 * @author Phil Derksen <[email protected]>, Nick Young <[email protected]> 6 * @license GPL-2.0+ 7 * @copyright 2014 Phil Derksen 8 */ 9 10/* global jQuery, gce, gce_grid */ 11 12(function($) { 13 'use strict'; 14 15 $(function() { 16 17 var $body = $( 'body'), 18 grids = $body.find('.gce-page-grid, .gce-widget-grid'), 19 gce_grid = [ grids.each( function( e, i ) { return $( i ).data( 'feed' ); } ) ], 20 tooltip_elements = ''; 21 22 $body.find('.gce-page-grid, .gce-widget-grid').each( function( e, i ) { 23 24 var id = $( this ).attr('id'), 25 gce_grid = $( this ).data( 'feed' ); 26 27 if( gce_grid[id].show_tooltips == 'true' || gce_grid[id].show_tooltips == true ) { 28 tooltip_elements += '#' + gce_grid[id].target_element + ' .gce-has-events,'; 29 } 30 }); 31 32 tooltip_elements = tooltip_elements.substring( 0, tooltip_elements.length - 1 ); 33 34 gce_tooltips(tooltip_elements); 35 36 // Month nav link click for Grid view. 37 // TODO Unbind other attached clicks here? 38 $body.on( 'click.gceNavLink', '.gce-change-month', function( event ) { 39 40 event.preventDefault(); 41 42 var navLink = $(this); 43 44 var grid = navLink.closest('.gce-page-grid'), 45 id = grid.attr('id'); 46 47 if( typeof id == 'undefined' ) { 48 grid = navLink.closest('.gce-widget-grid'), 49 id = grid.attr('id'); 50 } 51 52 var gce_grid = grid.data( 'feed' ); 53 54 //Extract month and year 55 var month_year = navLink.attr('name').split('-', 2); 56 var paging = navLink.attr('data-gce-grid-paging'); 57 58 //Add loading text to table caption 59 $body.find('#' + gce_grid[id].target_element + ' caption').html(gce.loadingText); 60 61 //Send AJAX request 62 $.post(gce.ajaxurl,{ 63 action:'gce_ajax', 64 gce_uid: id, 65 gce_type: gce_grid[id].type, 66 gce_feed_ids: gce_grid[id].feed_ids, 67 gce_title_text: gce_grid[id].title_text, 68 gce_widget_id: gce_grid[id].target_element, 69 gce_month: month_year[0], 70 gce_year: month_year[1], 71 gce_paging: paging 72 73 }, function(data) { 74 75 //Replace existing data with returned AJAX data. 76 var targetEle = $body.find('#' + gce_grid[id].target_element); 77 78 if (gce_grid[id].type == 'widget') { 79 targetEle.html(data); 80 } else { 81 targetEle.replaceWith(data); 82 } 83 84 gce_tooltips(tooltip_elements); 85 86 }).fail(function(data) { 87 console.log( data ); 88 }); 89 }); 90 91 92 // Month nav link click for List view. 93 // TODO Unbind other attached clicks here? 94 $body.on( 'click.gceNavLink', '.gce-change-month-list', function( event ) { 95 96 event.preventDefault(); 97 98 var navLink = $(this); 99 100 var list = navLink.closest('.gce-list'); 101 102 var start = list.data('gce-start'); 103 var grouped = list.data('gce-grouped'); 104 var title_text = list.data('gce-title'); 105 var feed_ids = list.data( 'gce-feeds'); 106 var sort = list.data('gce-sort'); 107 var paging = list.data('gce-paging'); 108 var paging_interval = list.data('gce-paging-interval'); 109 var paging_direction = navLink.data('gce-paging-direction'); 110 var start_offset = list.data('gce-start-offset'); 111 var paging_type = navLink.data('gce-paging-type'); 112 113 //Add loading text to table caption 114 navLink.parents('.gce-navbar').find('.gce-month-title').html(gce.loadingText); 115 116 //Send AJAX request 117 $.post(gce.ajaxurl,{ 118 action:'gce_ajax_list', 119 gce_feed_ids:feed_ids, 120 gce_title_text:title_text, 121 gce_start: start, 122 gce_grouped: grouped, 123 gce_sort: sort, 124 gce_paging: paging, 125 gce_paging_interval: paging_interval, 126 gce_paging_direction: paging_direction, 127 gce_start_offset: start_offset, 128 gce_paging_type: paging_type 129 130 }, function(data){ 131 navLink.parents('.gce-list').replaceWith(data); 132 133 }).fail(function(data) { 134 console.log( data ); 135 }); 136 }); 137 138 // Tooltip config using qTip2 jQuery plugin. 139 function gce_tooltips(target_items) { 140 141 $(target_items).each(function() { 142 143 //Add qtip to all target items 144 $(this).qtip({ 145 content: $(this).find('.gce-event-info'), 146 position: { 147 my: 'bottom left', 148 at: 'center', 149 viewport: true, 150 adjust: { 151 method: 'shift', 152 scroll: false 153 } 154 }, 155 show: { 156 solo: true, 157 effect: function(offset) { 158 $(this).fadeIn(50); 159 } 160 }, 161 hide: { 162 fixed: true 163 }, 164 style: { 165 classes: 'qtip-light qtip-shadow qtip-rounded' 166 } 167 }); 168 }); 169 } 170 }); 171}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.