/*** ajax-client.js ***/ function checkPositiveInt(val){ var result = val.match(/^\d+$/); return (result != null && result != 0); } function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } function handleResponse(myhttp) { if(myhttp.readyState == 4){ var response = myhttp.responseText; var update = new Array(); if(response.indexOf("?xml") == 1 ) { // not use the less-than bracket to avoid PHP problem // parse the XML var xmlresponse = myhttp.responseXML.documentElement; if ( xmlresponse.getElementsByTagName('searchresult') ) { var param = xmlresponse.getElementsByTagName('param'); var request=param[0].getAttribute("request"); var imgid=param[0].getAttribute("imgid"); var dispimg=param[0].getAttribute("dispimg"); var zoom=param[0].getAttribute("zoom"); var resultname=param[0].getAttribute("resultname"); var resultname_en=param[0].getAttribute("resultname_en"); var bookmark=parseInt(param[0].getAttribute("bookmark")); var hasmore=param[0].getAttribute("hasmore"); var forcezoom=param[0].getAttribute("forcezoom"); var search_key=param[0].getAttribute("search"); var pois = xmlresponse.getElementsByTagName('searchobject'); var servicesearch = param[0].getAttribute('service'); var servicelongdosearch = (typeof servicesearch == 'undefined' || servicesearch == '' || servicesearch == null || servicesearch == 'longdo'); var next_token = param[0].getAttribute('nexttoken'); var gg_html_attribute = servicesearch=='google' ? param[0].getAttribute('gghtmlattribute') : ''; var searchdiv = param[0].getAttribute('searchdiv'); if(servicelongdosearch) servicesearch = 'longdo'; var search_by = mylang == 'en' ? ' by ' : 'จาก '; switch(servicesearch) { case 'osm': search_by += 'Open Street Map'; break; case 'google': search_by += 'Google'; break; case 'foursquare': search_by += 'Foursquare'; break; case 'longdo': search_by += 'Longdo Map'; break; default: search_by += servicesearch; break; } var points = xmlresponse.getElementsByTagName('pointobject'); // for showobject n_points = points ? points.length : 0; var n_pois=0; if (pois) n_pois = pois.length; if (request == "getpois") { poi_saved[zoom][imgid] = new Array(); poi_num[zoom][imgid] = n_pois; for (var i = 0 ; i < n_pois; i++) { var item = pois[i]; var id=item.getAttribute("id"); var name=item.getAttribute("name"); var lat=item.getAttribute("lat"); var mylong=item.getAttribute("long"); var type=item.getAttribute("type"); var status=item.getAttribute("status"); var showlevel=item.getAttribute("showlevel"); var name_en=item.getAttribute("name_en"); var contributor=item.getAttribute("contributor"); var imagefile=item.getAttribute("imagefile"); var iconlabel=item.getAttribute("iconlabel"); var iconlabel_en=item.getAttribute("iconlabel_en"); var iconlabel_en=item.getAttribute("iconlabel_en"); // save to poi array poi_saved[zoom][imgid][i] = new Array(); var usename = name; if (mylang == "en") { usename = name_en; if (name_en == "") { usename = "(Thai) " + name; } } var useiconlabel = iconlabel; if (mylang == "en") { useiconlabel = iconlabel_en; } poi_saved[zoom][imgid][i][0] = id; poi_saved[zoom][imgid][i][1] = usename; poi_saved[zoom][imgid][i][2] = lat; poi_saved[zoom][imgid][i][3] = mylong; poi_saved[zoom][imgid][i][4] = status; poi_saved[zoom][imgid][i][5] = contributor; poi_saved[zoom][imgid][i][6] = imagefile; poi_saved[zoom][imgid][i][7] = useiconlabel; //drawPOI(id,name,lat,mylong,status,zoom,dispimg,i); } drawPOIFromArray(zoom,imgid,dispimg); // hide the unused image var oldnum = poi_images_num[dispimg]; if (n_pois < oldnum ) { for (var i = n_pois ; i < oldnum ; i++) { //poi_images[dispimg][i].style.visibility = "hidden"; mymap.removeChild(poi_images[dispimg][i]); // remove and recreate seems to be faster! //poi_images_label[dispimg][i].style.visibility = "hidden"; //poi_images_label[dispimg][i].style.width = "0px"; //poi_images_label[dispimg][i].innerHTML = ""; mymap.removeChild(poi_images_label[dispimg][i]); } } poi_images_num[dispimg] = n_pois; } else if ( request == "searchresultsxml") { search_results_poi = new Array(); var shortdesc_limit = mylang == 'th' ? 60 : 70; var searchresultshtml = ''; if(bookmark == 0) { if(servicesearch != 'longdo') { searchresultshtml += '
'+(mylang=='en' ? 'Search results' : 'ผลลัพธ์')+search_by+'
'; } searchresultshtml += ''; } var flipflop = 'odd'; if (n_pois > 0) { // google mode // if (currentmode == "gmap") { // gmap.clearMarkers(); // } for (var i = 0 ; i < n_pois; i++) { var item = pois[i]; var id=item.getAttribute("id"); var name=item.getAttribute("name"); var lat=item.getAttribute("lat"); var mylong=item.getAttribute("long"); var type=item.getAttribute("objecttype"); var showlevel=item.getAttribute("showlevel"); var name_en=item.getAttribute("name_en"); var shortdesc=item.getAttribute("shortdesc"); var shortdesc_en=item.getAttribute("shortdesc_en"); var markicon = item.getAttribute('markicon'); var geocode = item.getAttribute('geocode'); markicon = markicon.split("^", 2); var markicon_title = typeof markicon[1] == "string" ? markicon[1] : ''; if(markicon_title != '') { markicon_title = markicon_title.replace(/'/g, "'"); markicon_title = markicon_title.replace(/"/g, """); markicon_title = ' title="'+markicon_title+'"'; } markicon = markicon[0]; var num_location_image=item.getAttribute("num_location_image"); var num_location_event=item.getAttribute("num_location_event"); var countlabel = bookmark + 1 + i; var search_result_icon = ""; //alert(id+","+name+","+lat+","+mylong+","+ showlevel + ", " +i); // save to poi array search_results_poi[i] = new Array(); var usename = mylang == "en" ? ( name_en ? name_en : name) : (name ? name : name_en); usename_org = usename; usename = usename.replace(/'/g, "\\'"); usename = usename.replace(/"/g, """); var usedesc = mylang=='th' ? (shortdesc ? shortdesc : shortdesc_en) : (shortdesc_en ? shortdesc_en : shortdesc); usedesc = mmmap.stripHtml(usedesc); search_results_poi[i][0] = id; search_results_poi[i][1] = usename; search_results_poi[i][2] = lat; search_results_poi[i][3] = mylong; search_results_poi[i][4] = type; search_results_poi[i][5] = showlevel; // google mode // if (currentmode == "gmap") { // gmap.addMarker(lat,mylong,usename); // } var type_text = ''; switch(type) { case 'road': type_text = (mylang == "en" ? 'Alley/Road' : 'ถนน/ซอย'); break; case 'tag': type_text = 'Tag'; break; case 'khet': type_text = (mylang == "en" ? 'Boundary of Administrator' : 'ขอบเขตการปกครอง'); break; default: type_text = (mylang == "en" ? 'Place' : 'สถานที่'); break; } searchresultshtml += ''; flipflop = (flipflop == 'even' ? 'odd' : 'even'); searchresultshtml += ""; // countlabel searchresultshtml += '"; } // pager //searchresultshtml += ""; //if (n_pois > 20) { if (hasmore == "true") { searchresultshtml += ""; searchresultshtml += ""; } if(gg_html_attribute) { gg_html_attribute = gg_html_attribute.replace(/"; } } else { // no result if(bookmark == 0) { var at_least_characters = 2; if(search_key.length >= at_least_characters) { searchresultshtml += ""; } else { searchresultshtml += ""; } } } if(bookmark == 0) { searchresultshtml += "
'; var zoom = Math.log(resolution)/Math.log(2); var zoomimg = (browser=='IE' && version<=6) ? "" : ""; var viewimg = ""; if(num_location_image>0) { viewimg += (browser=='IE' && version<=6) ? "" : " "; } var eventimg = ""; if(num_location_event>0) { eventimg += (browser=='IE' && version<=6) ? "" : " "; } var routeimg = ""; if(searchdiv == 'routing-result') { routeimg += (browser=='IE' && version<=6) ? "" : " "; } if (type == "poi" || type == "foursquare-poi" || type == "google-poi" || type == "osm-poi") { var name_padded = id; var markpoijs = 'selectMapTab();'; var markpoiandzoomjs = 'selectMapTab();'; if(type == "poi") { while (name_padded.length < 8) name_padded = "0" + name_padded; markpoijs += 'markPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + ", " + zoom + " , '');"; markpoiandzoomjs += 'mmmap.setZoom(' + showlevel + ');markPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + "," + showlevel + ", '');"; } else { //if(type == "foursquare-poi") { markpoijs += 'markOtherServiceSearchPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + ", " + zoom + ");"; markpoiandzoomjs += 'mmmap.setZoom(' + showlevel + ');markOtherServiceSearchPOI(' + '\''+id+'\'' + ",'" + usename + "'," + lat +',' + mylong + "," + showlevel + ");"; } searchresultshtml += '' + usename_org + ""; search_result_icon += ' ' + zoomimg + ""; if(viewimg!="") { search_result_icon += ' ' + viewimg + ''; } if(eventimg!="") { search_result_icon += ' ' + eventimg + ''; } if(routeimg!="") { search_result_icon += ' ' + routeimg + ''; } } else if (type == "road") { searchresultshtml += '' + usename_org + ""; if(routeimg!="") { search_result_icon += ' ' + routeimg + ''; } } else if (type == "khet") { var js_func = ''; //if(geocode) { // js_func = 'mmmap.showObject(\''+geocode+'\', \'IG\');'; //} else { js_func = 'markPOI(-1 ,\'' + usename + '\',' + lat +',' + mylong + ', ' + zoom + ', \'
'+usedesc+'\');'; //} if (lat && mylong) { searchresultshtml += '' + usename_org + ""; } else { // probably only KWANG here searchresultshtml += '' + usename_org + ""; } if(routeimg!="") { search_result_icon += ' ' + routeimg + ''; } } else if (type == "tag") { var tagname = name.replace(/^tag: /, ""); searchresultshtml += '' + name + ""; } else if (type == "geom") { var name_padded = id; while (name_padded.length < 8) name_padded = "0" + name_padded; searchresultshtml += '' + name + ""; if(viewimg!="") { search_result_icon += ' ' + viewimg + ''; } if(eventimg!="") { search_result_icon += ' ' + eventimg + ''; } if(routeimg!="") { search_result_icon += ' ' + routeimg + ''; } } else if (type == "map") { var name_padded = id; while (name_padded.length < 8) name_padded = "0" + name_padded; searchresultshtml += '' + name + ""; if(viewimg!="") { search_result_icon += ' ' + viewimg + ''; } if(eventimg!="") { search_result_icon += ' ' + eventimg + ''; } } if(search_result_icon != '') { search_result_icon = '
'+search_result_icon+'
'; searchresultshtml += search_result_icon; } if(typeof(usedesc) != "undefined" && usedesc != "") { searchresultshtml += "
"+ usedesc.substr(0,shortdesc_limit) + (usedesc.length > shortdesc_limit ? "..." : "") + ""; } searchresultshtml += "
"; var nextbookmark = bookmark + n_pois; var more_result_func = 'setBookmark('+ nextbookmark + '); doPreviousSearch(\'\');'; if(typeof(servicesearch) == 'string' && servicesearch == 'google') more_result_func = 'setBookmark('+ nextbookmark + ', \''+servicesearch+'\'); searchOtherService(\''+search_key+'\', \'google\', \''+next_token+'\');'; else if(typeof(servicesearch) == 'string' && servicesearch == 'foursquare') more_result_func = 'setBookmark('+ nextbookmark + ', \''+servicesearch+'\'); searchOtherService(\''+search_key+'\', \'foursquare\', \''+next_token+'\');'; else if(typeof(servicesearch) == 'string' && servicesearch == 'osm') more_result_func = 'setBookmark('+ nextbookmark + ', \''+servicesearch+'\'); searchOtherService(\''+search_key+'\', \'osm\', \''+next_token+'\');'; searchresultshtml += '
 '+(mylang == "en" ? 'more' : 'เพิ่มเติม')+'
'; searchresultshtml += "
"+(servicelongdosearch ? (mylang == "en" ? 'Sorry, no result found.' : 'ไม่พบผลลัพธ์การค้นหา') : '-')+"
"+(servicelongdosearch ? (mylang == "en" ? 'Please enter at least '+at_least_characters+' characters' : 'โปรดระบุอย่างน้อย '+at_least_characters+' ตัวอักษร') : '-')+"
"; if(servicelongdosearch) { searchresultshtml += "
"+(mylang == "en" ? 'Other search services' : 'ค้นหาจากบริการอื่น')+": "; if(typeof(servicesearch) == 'string' && servicesearch != 'longdo') searchresultshtml += ""; if(typeof(servicesearch) != 'string' || servicesearch != 'foursquare') searchresultshtml += ""; if(typeof(servicesearch) != 'string' || servicesearch != 'google') searchresultshtml += ""; if(typeof(servicesearch) != 'string' || servicesearch != 'osm') searchresultshtml += ""; searchresultshtml += "
"; showDiv(searchdiv, searchresultshtml); } else { $('#search-with-other-services').before(searchresultshtml); } } else if(document.getElementById('search-result-list'+(servicesearch ? '-'+servicesearch : ''))) { if(document.getElementById("more-search-result-loading"+(servicesearch ? '-'+servicesearch : ''))) { document.getElementById("more-search-result-loading"+(servicesearch ? '-'+servicesearch : '')).style.display = 'none'; } $(searchresultshtml).appendTo('#search-result-list'+(servicesearch ? '-'+servicesearch : '')); } var isMMSnippet = false; if (document.getElementById('isMMMapSnippet') != null) { isMMSnippet = true; } if (showingmark != -1 && showingmark && (isMMSnippet || forcezoom == 1)) { _setAllSearchResultsPOIVisible(false); }else if (showingmark != -1 && showingmark){ _setAllSearchResultsPOIVisible(true); } // if (showingmark != -1 && showingmark){ // setAllSearchResultsPOIVisible(true); // } if(servicelongdosearch) { if (n_pois == 1) { if(document.getElementById('search_result_zoom_0')) document.getElementById('search_result_zoom_0').onclick(); else document.getElementById('search_result_0').onclick(); } if(n_pois <= 3) { searchOtherService(search_key, 'all'); } } } else if ( request == "showpoi") { if (n_pois > 0) { var item = pois[0]; var id=item.getAttribute("id"); var name=item.getAttribute("name"); var lat=item.getAttribute("lat"); var mylong=item.getAttribute("long"); var type=item.getAttribute("type"); var status=item.getAttribute("status"); var showlevel=item.getAttribute("showlevel"); var name_en=item.getAttribute("name_en"); var dozoom=item.getAttribute("dozoom"); var hidepopup=item.getAttribute("hidepopup"); var forcezoomlevel=item.getAttribute("forcezoomlevel"); if(forcezoomlevel > 0) showlevel = forcezoomlevel; var usename = name; if (mylang == "en") { if (name_en != "") usename = name_en; else usename = "(Thai) " + name; } if(hidepopup == "1") { markPoint(id,usename,lat,mylong); if(dozoom && dozoom != '0') { if ( showlevel > mmmap.getZoom() || forcezoomlevel > 0) { mmmap.setZoom(showlevel); } } mmmap.moveTo(lat,mylong); } else { markPOIandZoom(id,usename,lat,mylong,showlevel,"",dozoom); } /* markPOI(id,usename,lat,mylong,showlevel,""); if (dozoom == "1") { mmmap.setZoom(showlevel); } */ } } else if ( request == "showobject") { if (n_pois > 0) { var item = pois[0]; var id=item.getAttribute("id"); var ds='LONGDO'; if(/^L/.test(id)) { ds = 'RID'; } mmmap.showObject({"id":id, "dozoom":1, "ds":ds}); } } } } else if(response.indexOf('|') != -1) { update = response.split('|'); var elementname = removeNL(update[0]); showDiv(elementname, removeNL(update[1])); // SUPER HACK if (elementname == "locationdetails_contents") { showLocationdetailsDiv(elementname, removeNL(update[1])); } } myhttp = null; // garbage collection } } function removeNL(s) { /* ** Remove NewLine, CarriageReturn and Tab characters from a String ** s string to be processed ** returns new string */ r = ""; for (i=0; i < s.length; i++) { if (s.charAt(i) != '\n' && s.charAt(i) != '\r' && s.charAt(i) != '\t') { r += s.charAt(i); } } return r; } function showDiv(divname, contents) { if (window.document.getElementById(divname) != null) { window.document.getElementById(divname).innerHTML = contents; } } function showLocationdetailsDiv(divname, contents) { if (window.document.getElementById(divname) != null) { window.document.getElementById(divname).innerHTML = contents; setTimeout(function(){ if($('#'+divname+' a[rel^="prettyText"]') && $('#'+divname+' a[rel^="prettyText"]').length > 0) { if($('#'+divname+' a[rel^="prettyText"]').prettyPhoto) { $('#'+divname+' a[rel^="prettyText"]').removeAttr("target"); $('#'+divname+' a[rel^="prettyText"]').prettyPhoto({default_width: 400,default_height: 60}); } } //if($("#location_popup_title") && $("#location_popup_title").length > 0 && $("#detail_0") && $("#detail_0").length > 0) { // $("#location_popup_title").removeAttr('onclick'); // $("#location_popup_title").unbind('click').click(function(){ // eval($("#detail_0").attr('href').replace('javascript:', '')); // }); //} if($("#snippet_0") && $("#snippet_0").length > 0) { $("#snippet_0").click(function(event){ event.stopPropagation(); var ooiid = $("#snippet_0").attr('rel'); createSnippetCodeByOOIID(ooiid); return false; }); } if($("#link_0") && $("#link_0").length > 0 && typeof $.prettyPhoto == 'object') { var permalink_href = $("#link_0").attr('href') + '#?permalink=true'; $("#link_0").attr('href', permalink_href); } }, 500); } } function _setAllSearchResultsPOIVisible(zoomout_even_if_onscreen) { if ( ! search_results_poi || search_results_poi.length <= 0 ) return; clearMarks(); var sumlat = 0; var sumlong = 0; var poicount = 0; var some_points_on_screen = false; var points = new Array(); search_results_poi.sort(function(a,b) {return a[2]==b[2] ? 0 : (a[2] < b[2] ? -1 : 1)}) for (var i = search_results_poi.length - 1 ; i >= 0 ; i-- ) { var id = search_results_poi[i][0]; var name = search_results_poi[i][1]; var lat = search_results_poi[i][2]; var mylong = search_results_poi[i][3]; var type = search_results_poi[i][4]; var showlevel = search_results_poi[i][5]; lat = parseFloat(lat); mylong = parseFloat(mylong); if (type == "poi" || type == "foursquare-poi" || type == "google-poi" || type == "osm-poi") { if(type == "poi") { markPoint(id,name,lat,mylong); } else { //if(type == "foursquare-poi") { markPointOtherServiceSearch(id,name,lat,mylong); } sumlat += lat; sumlong += mylong; poicount++; points[points.length] = [ mylong, lat]; } if (!some_points_on_screen) { if (lat >visible_min_latitude && lat < visible_max_latitude && mylong > visible_min_longitude && mylong < visible_max_longitude ) { some_points_on_screen = true; } } } if ( sumlat != 0 && sumlong != 0) { if (zoomout_even_if_onscreen && !some_points_on_screen) { if (document.getElementById('isMMMapSnippet') == null) { mmmap.setZoom(mmmap.findAppropriateZoom(points)); } } } } function markPointOtherServiceSearch(id,name,lat,mylong) { var imageObject = document.createElement('div'); imageObject.mark_lat = lat; imageObject.mark_long = mylong; var bg_pos = ''; if(/^foursquare/.test(id)) { bg_pos = '0px -44px'; } else if(/^osm/.test(id)) { bg_pos = '0px -88px'; } else { // google bg_pos = '0px 0px'; } imageObject.style.width = '25px'; imageObject.style.height = '44px'; imageObject.style.background = 'url(/mmmap/images/pin_mark_other_services.png) '+bg_pos+' no-repeat'; imageObject.poi_id = id; imageObject.title = name; imageObject.onmousedown = poiClicked; imageObject.border=0; imageObject.style.zIndex = 1000; imageObject.style.cursor = 'pointer'; imageObject.innerHTML = ' '; var attr = {"centerOffsetX" : "12px", "centerOffsetY" : "44px"}; mmmap.drawCustomDivWithPopup(imageObject, lat, mylong, name, '', attr); return; } function markOtherServiceSearchPOI(id,name,lat,mylong,showlevel) { if (id != -1) markPointOtherServiceSearch(id,name,lat,mylong); showlevel = Math.pow(2,showlevel); // check within the visible area if ( (lat < visible_min_latitude || lat > visible_max_latitude) || (mylong < visible_min_longitude || mylong > visible_max_longitude) ) { mmmap.moveTo(lat,mylong); } // FIXME now supports only popup_idx = 0 var popup_idx = 0; var popup_idx = 0; // mmmap.popupinfo.length; // FIXME right now supports only one popup if (!mmmap.popupinfo[popup_idx]) { mmmap.popupinfo[popup_idx] = new Object(); } // save _lat, _long, ..... to this.popupinfo[this.popupinfo.length] mmmap.popupinfo[popup_idx].lat = lat; mmmap.popupinfo[popup_idx].lon = mylong; showLocationDetailPopup(id,name,mylong,lat,'',popup_idx); showLocationDetail(id, popup_idx); }/* ------------------------------------------------------------------------ Class: prettyPhoto Use: Lightbox clone for jQuery Author: Stephane Caron (http://www.no-margin-for-errors.com) Version: 3.1.4 ------------------------------------------------------------------------- */ (function($) { $.prettyPhoto = {version: '3.1.4'}; $.fn.prettyPhoto = function(pp_settings) { pp_settings = jQuery.extend({ hook: 'rel', /* the attribute tag to use for prettyPhoto hooks. default: 'rel'. For HTML5, use "data-rel" or similar. */ animation_speed: 'fast', /* fast/slow/normal */ ajaxcallback: function() {}, slideshow: false, /* false OR interval time in ms [default: 5000] */ autoplay_slideshow: false, /* true/false */ opacity: 0.60, /* Value between 0 and 1 */ show_title: true, /* true/false */ show_description: true, /* true/false */ allow_resize: true, /* Resize the photos bigger than viewport. true/false */ allow_expand: true, /* Allow the user to expand a resized image. true/false */ default_width: 500, default_height: 344, counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */ theme: 'facebook pp-longdo', /* light_rounded / dark_rounded / light_square / dark_square / facebook / pp_default [default: pp_default] */ horizontal_padding: 20, /* The padding on each side of the picture */ hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */ wmode: 'opaque', /* Set the flash wmode attribute */ autoplay: true, /* Automatically start videos: True/False */ modal: false, /* If set to true, only the close button will close the window */ deeplinking: false, /* Allow prettyPhoto to update the url to enable deeplinking. [default: true] */ overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */ overlay_gallery_max: 30, /* Maximum number of pictures in the overlay gallery */ keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */ changepicturecallback: function(){}, /* Called everytime an item is shown/changed */ callback: function(){}, /* Called when prettyPhoto is closed */ ie6_fallback: true, markup: '
\
 
\
\
\
\
\
\
\
\
\
\ Close \
\
\ Expand \
\ next \ previous \
\
\
\
\ Previous \

0/0

\ Next \
\

\
{pp_social}
\
\
\
\
\
\
\
\
\
\
\
\
\
', gallery_markup: '', image_markup: '', flash_markup: '', quicktime_markup: '', iframe_markup: '', inline_markup: '
{content}
', custom_markup: '', permalink_markup: ' ', textarea_markup: ' ', login_markup: '
\
\
\ \ \
Enter your longdo.com username.
\
\
\ \ \
Enter the password that accompanies your username.
\
\ \ \
\
\
\
', social_tools: false /* html or false to disable [default: '
Tweet
'] */ }, pp_settings); // Global variables accessible only by prettyPhoto var matchedObjects = this, percentBased = false, pp_dimensions, pp_open, // prettyPhoto container specific pp_contentHeight, pp_contentWidth, pp_containerHeight, pp_containerWidth, // Window size windowHeight = $(window).height(), windowWidth = $(window).width(), // Global elements pp_slideshow; doresize = true, scroll_pos = _get_scroll(); // Window/Keyboard events $(window).unbind('resize.prettyphoto').bind('resize.prettyphoto',function(){ _center_overlay(); _resize_overlay(); }); if(pp_settings.keyboard_shortcuts) { $(document).unbind('keydown.prettyphoto').bind('keydown.prettyphoto',function(e){ if(typeof $pp_pic_holder != 'undefined'){ if($pp_pic_holder.is(':visible')){ switch(e.keyCode){ case 37: if(_getFileType(pp_images[set_position])=="image") { $.prettyPhoto.changePage('previous'); e.preventDefault(); } break; case 39: if(_getFileType(pp_images[set_position])=="image") { $.prettyPhoto.changePage('next'); e.preventDefault(); } break; case 27: if(!settings.modal) { $.prettyPhoto.close(); } e.preventDefault(); break; }; // return false; }; }; }); }; /** * Initialize prettyPhoto. */ $.prettyPhoto.initialize = function() { settings = pp_settings; if(settings.theme == 'pp_default') settings.horizontal_padding = 16; if(settings.ie6_fallback && $.browser.msie && parseInt($.browser.version) == 6) settings.theme = "light_square"; // Fallback to a supported theme for IE6 // Find out if the picture is part of a set theRel = $(this).attr(settings.hook); galleryRegExp = /\[(?:.*)\]/; isSet = (galleryRegExp.exec(theRel)) ? true : false; // Put the SRCs, TITLEs, ALTs into an array. pp_images = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return $(n).attr('href'); }) : $.makeArray($(this).attr('href')); pp_titles = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return ($(n).find('img').attr('alt')) ? $(n).find('img').attr('alt') : ""; }) : $.makeArray($(this).find('img').attr('alt')); if(settings.show_description) { pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return ($(n).attr('title')) ? $(n).attr('title') : ""; }) : $.makeArray($(this).attr('title')); } else { pp_descriptions = $.makeArray(""); } if(pp_images.length > settings.overlay_gallery_max) settings.overlay_gallery = false; set_position = jQuery.inArray($(this).attr('href'), pp_images); // Define where in the array the clicked item is positionned rel_index = (isSet) ? set_position : $("a["+settings.hook+"^='"+theRel+"']").index($(this)); _build_overlay(this); // Build the overlay {this} being the caller if(settings.allow_resize) $(window).bind('scroll.prettyphoto',function(){ _center_overlay(); }); $.prettyPhoto.open(); return false; } /** * Opens the prettyPhoto modal box. * @param image {String,Array} Full path to the image to be open, can also be an array containing full images paths. * @param title {String,Array} The title to be displayed with the picture, can also be an array containing all the titles. * @param description {String,Array} The description to be displayed with the picture, can also be an array containing all the descriptions. */ $.prettyPhoto.open = function(event) { if(typeof settings == "undefined"){ // Means it's an API call, need to manually get the settings and set the variables settings = pp_settings; if($.browser.msie && $.browser.version == 6) settings.theme = "light_square"; // Fallback to a supported theme for IE6 pp_images = $.makeArray(arguments[0]); pp_titles = (arguments[1]) ? $.makeArray(arguments[1]) : $.makeArray(""); pp_descriptions = (arguments[2]) ? $.makeArray(arguments[2]) : $.makeArray(""); isSet = (pp_images.length > 1) ? true : false; set_position = (arguments[3])? arguments[3]: 0; _build_overlay(event.target); // Build the overlay {this} being the caller } if($.browser.msie && $.browser.version == 6) $('select').css('visibility','hidden'); // To fix the bug with IE select boxes if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','hidden'); // Hide the flash _checkPosition($(pp_images).size()); // Hide the next/previous links if on first or last images. $('.pp_loaderIcon').show(); if(settings.deeplinking) setHashtag(); // Rebuild Facebook Like Button with updated href if(settings.social_tools){ facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); $pp_pic_holder.find('.pp_social').html(facebook_like_link); } // Fade the content in if($ppt.is(':hidden')) $ppt.css('opacity',0).show(); $pp_overlay.show().fadeTo(settings.animation_speed,settings.opacity); // Display the current position $pp_pic_holder.find('.currentTextHolder').text((set_position+1) + settings.counter_separator_label + $(pp_images).size()); // Set the description if(typeof pp_descriptions[set_position] != 'undefined' && pp_descriptions[set_position] != ""){ $pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position])); }else{ $pp_pic_holder.find('.pp_description').hide(); } // Get the dimensions movie_width = ( parseFloat(getParam('width',pp_images[set_position])) ) ? getParam('width',pp_images[set_position]) : settings.default_width.toString(); movie_height = ( parseFloat(getParam('height',pp_images[set_position])) ) ? getParam('height',pp_images[set_position]) : settings.default_height.toString(); // If the size is % based, calculate according to window dimensions percentBased=false; if(movie_height.indexOf('%') != -1) { movie_height = parseFloat(($(window).height() * parseFloat(movie_height) / 100) - 150); percentBased = true; } if(movie_width.indexOf('%') != -1) { movie_width = parseFloat(($(window).width() * parseFloat(movie_width) / 100) - 150); percentBased = true; } // Fade the holder $pp_pic_holder.fadeIn(function(){ // Set the title (settings.show_title && pp_titles[set_position] != "" && typeof pp_titles[set_position] != "undefined") ? $ppt.html(unescape(pp_titles[set_position])) : $ppt.html(' '); imgPreloader = ""; skipInjection = false; // Inject the proper content switch(_getFileType(pp_images[set_position])){ case 'image': imgPreloader = new Image(); // Preload the neighbour images nextImage = new Image(); if(isSet && set_position < $(pp_images).size() -1) nextImage.src = pp_images[set_position + 1]; prevImage = new Image(); if(isSet && pp_images[set_position - 1]) prevImage.src = pp_images[set_position - 1]; $pp_pic_holder.find('#pp_full_res')[0].innerHTML = settings.image_markup.replace(/{path}/g,pp_images[set_position]); imgPreloader.onload = function(){ // Fit item to viewport pp_dimensions = _fitToViewport(imgPreloader.width,imgPreloader.height); _showContent(); }; imgPreloader.onerror = function(){ alert('Image cannot be loaded. Make sure the path is correct and image exist.'); $.prettyPhoto.close(); }; imgPreloader.src = pp_images[set_position]; break; case 'youtube': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport // Regular youtube link movie_id = getParam('v',pp_images[set_position]); // youtu.be link if(movie_id == ""){ movie_id = pp_images[set_position].split('youtu.be/'); movie_id = movie_id[1]; if(movie_id.indexOf('?') > 0) movie_id = movie_id.substr(0,movie_id.indexOf('?')); // Strip anything after the ? if(movie_id.indexOf('&') > 0) movie_id = movie_id.substr(0,movie_id.indexOf('&')); // Strip anything after the & } movie = 'http://www.youtube.com/embed/'+movie_id; (getParam('rel',pp_images[set_position])) ? movie+="?rel="+getParam('rel',pp_images[set_position]) : movie+="?rel=1"; if(settings.autoplay) movie += "&autoplay=1"; toInject = settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie); break; case 'vimeo': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport movie_id = pp_images[set_position]; var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)/; var match = movie_id.match(regExp); movie = 'http://player.vimeo.com/video/'+ match[2] +'?title=0&byline=0&portrait=0'; if(settings.autoplay) movie += "&autoplay=1;"; vimeo_width = pp_dimensions['width'] + '/embed/?moog_width='+ pp_dimensions['width']; toInject = settings.iframe_markup.replace(/{width}/g,vimeo_width).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,movie); break; case 'quicktime': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport pp_dimensions['height']+=15; pp_dimensions['contentHeight']+=15; pp_dimensions['containerHeight']+=15; // Add space for the control bar toInject = settings.quicktime_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,pp_images[set_position]).replace(/{autoplay}/g,settings.autoplay); break; case 'flash': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport flash_vars = pp_images[set_position]; flash_vars = flash_vars.substring(pp_images[set_position].indexOf('flashvars') + 10,pp_images[set_position].length); filename = pp_images[set_position]; filename = filename.substring(0,filename.indexOf('?')); toInject = settings.flash_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars); break; case 'iframe': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport frame_url = pp_images[set_position]; frame_url = frame_url.substr(0,frame_url.indexOf('iframe')-1); toInject = settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,frame_url); settings.allow_expand = false; break; /*case 'ajax': // koB hack 20120830 doresize = false; // Make sure the dimensions are not resized. pp_dimensions = _fitToViewport(movie_width,movie_height); doresize = true; // Reset the dimensions skipInjection = true; $.get(pp_images[set_position],function(responseHTML){ toInject = settings.inline_markup.replace(/{content}/g,responseHTML); $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; _showContent(); }); break;*/ case 'ajax': skipInjection = true; $.get(pp_images[set_position], function (responseHTML) { toInject = settings.inline_markup.replace(/{content}/g, responseHTML); $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; myClone = $($pp_pic_holder.find('#pp_full_res')[0]).clone().append('
').css({ 'width': settings.default_width }).wrapInner('
').appendTo($('body')).show(); doresize = false; // Make sure the dimensions are not resized. pp_dimensions = _fitToViewport($(myClone).width(), $(myClone).height()); doresize = true; // Reset the dimensions $(myClone).remove(); _showContent(); }); break; case 'custom': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport toInject = settings.custom_markup; break; case 'inline': // to get the item height clone it, apply default width, wrap it in the prettyPhoto containers , then delete myClone = $(pp_images[set_position]).clone().append('
').css({'width':settings.default_width}).wrapInner('
').appendTo($('body')).show(); doresize = false; // Make sure the dimensions are not resized. pp_dimensions = _fitToViewport($(myClone).width(),$(myClone).height()); doresize = true; // Reset the dimensions $(myClone).remove(); toInject = settings.inline_markup.replace(/{content}/g,$(pp_images[set_position]).html()); break; case 'permalink': pp_dimensions = _fitToViewport(movie_width,movie_height); var link = pp_images[set_position].split('#',2)[0]; toInject = settings.permalink_markup.replace(/{link}/g,link); break; case 'textarea': pp_dimensions = _fitToViewport(movie_width,movie_height); var link = getPermalinkURL(); toInject = settings.textarea_markup.replace(/{link}/g,link); break; case 'login': pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport var destination = ''; var pattern = /destination=(.*)/ var href = pp_images[set_position]; if(href) { var dest = href.match(pattern) ? href.match(pattern)[1] : ''; if(dest != '') destination = dest; } toInject = settings.login_markup.replace(/{destination}/g,destination); break; }; if(!imgPreloader && !skipInjection){ $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; // Show content _showContent(); }; }); return false; }; /** * Change page in the prettyPhoto modal box * @param direction {String} Direction of the paging, previous or next. */ $.prettyPhoto.changePage = function(direction){ currentGalleryPage = 0; if(direction == 'previous') { set_position--; if (set_position < 0) set_position = $(pp_images).size()-1; }else if(direction == 'next'){ set_position++; if(set_position > $(pp_images).size()-1) set_position = 0; }else{ set_position=direction; }; rel_index = set_position; //if(!doresize) doresize = true; // Allow the resizing of the images if(settings.allow_expand) { if (doresize) { $('.pp_contract').removeClass('pp_expand').addClass('pp_contract'); } else { $('.pp_expand').removeClass('pp_contract').addClass('pp_expand'); } } _hideContent(function(){ $.prettyPhoto.open(); }); }; /** * Change gallery page in the prettyPhoto modal box * @param direction {String} Direction of the paging, previous or next. */ $.prettyPhoto.changeGalleryPage = function(direction){ if(direction=='next'){ currentGalleryPage ++; if(currentGalleryPage > totalPage) currentGalleryPage = 0; }else if(direction=='previous'){ currentGalleryPage --; if(currentGalleryPage < 0) currentGalleryPage = totalPage; }else{ currentGalleryPage = direction; }; slide_speed = (direction == 'next' || direction == 'previous') ? settings.animation_speed : 0; slide_to = currentGalleryPage * (itemsPerPage * itemWidth); $pp_gallery.find('ul').animate({left:-slide_to},slide_speed); }; /** * Start the slideshow... */ $.prettyPhoto.startSlideshow = function(){ if(typeof pp_slideshow == 'undefined'){ $pp_pic_holder.find('.pp_play').unbind('click').removeClass('pp_play').addClass('pp_pause').click(function(){ $.prettyPhoto.stopSlideshow(); return false; }); pp_slideshow = setInterval($.prettyPhoto.startSlideshow,settings.slideshow); }else{ $.prettyPhoto.changePage('next'); }; } /** * Stop the slideshow... */ $.prettyPhoto.stopSlideshow = function(){ $pp_pic_holder.find('.pp_pause').unbind('click').removeClass('pp_pause').addClass('pp_play').click(function(){ $.prettyPhoto.startSlideshow(); return false; }); clearInterval(pp_slideshow); pp_slideshow=undefined; } /** * Closes prettyPhoto. */ $.prettyPhoto.close = function(){ if($pp_overlay.is(":animated")) return; $.prettyPhoto.stopSlideshow(); $pp_pic_holder.stop().find('object,embed').css('visibility','hidden'); $('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animation_speed,function(){ $(this).remove(); }); $pp_overlay.fadeOut(settings.animation_speed, function(){ if($.browser.msie && $.browser.version == 6) $('select').css('visibility','visible'); // To fix the bug with IE select boxes if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','visible'); // Show the flash $(this).remove(); // No more need for the prettyPhoto markup $(window).unbind('scroll.prettyphoto'); clearHashtag(); settings.callback(); doresize = true; pp_open = false; delete settings; }); }; /** * Set the proper sizes on the containers and animate the content in. */ function _showContent(){ $('.pp_loaderIcon').hide(); // Calculate the opened top position of the pic holder projectedTop = scroll_pos['scrollTop'] + ((windowHeight/2) - (pp_dimensions['containerHeight']/2)); if(projectedTop < 0) projectedTop = 0; $ppt.fadeTo(settings.animation_speed,1); // Resize the content holder $pp_pic_holder.find('.pp_content') .animate({ height:pp_dimensions['contentHeight'], width:pp_dimensions['contentWidth'] },settings.animation_speed); // Resize picture the holder $pp_pic_holder.animate({ 'top': projectedTop, 'left': ((windowWidth/2) - (pp_dimensions['containerWidth']/2) < 0) ? 0 : (windowWidth/2) - (pp_dimensions['containerWidth']/2), width:pp_dimensions['containerWidth'] },settings.animation_speed,function(){ $pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(pp_dimensions['height']).width(pp_dimensions['width']); $pp_pic_holder.find('.pp_fade').fadeIn(settings.animation_speed); // Fade the new content // Show the nav if(isSet && _getFileType(pp_images[set_position])=="image") { $pp_pic_holder.find('.pp_hoverContainer').show(); }else{ $pp_pic_holder.find('.pp_hoverContainer').hide(); } if(settings.allow_expand) { if(pp_dimensions['resized']){ // Fade the resizing link if the image is resized $('a.pp_expand,a.pp_contract').show(); }else{ if (doresize) $('a.pp_expand,a.pp_expand').hide(); } } if(settings.autoplay_slideshow && !pp_slideshow && !pp_open) $.prettyPhoto.startSlideshow(); if(_getFileType(pp_images[set_position])=="permalink" || _getFileType(pp_images[set_position])=="textarea" || _getFileType(pp_images[set_position])=="login") { $pp_pic_holder.find('[rel="thickbox-focus"]').focus(); if(_getFileType(pp_images[set_position])=="permalink" || _getFileType(pp_images[set_position])=="textarea") { $pp_pic_holder.find('[rel="thickbox-focus"]').select(); } } settings.changepicturecallback(); // Callback! pp_open = true; }); _insert_gallery(); pp_settings.ajaxcallback(); }; /** * Hide the content...DUH! */ function _hideContent(callback){ // Fade out the current picture $pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden'); $pp_pic_holder.find('.pp_fade').fadeOut(settings.animation_speed,function(){ $('.pp_loaderIcon').show(); callback(); }); }; /** * Check the item position in the gallery array, hide or show the navigation links * @param setCount {integer} The total number of items in the set */ function _checkPosition(setCount){ (setCount > 1) ? $('.pp_nav').show() : $('.pp_nav').hide(); // Hide the bottom nav if it's not a set. }; /** * Resize the item dimensions if it's bigger than the viewport * @param width {integer} Width of the item to be opened * @param height {integer} Height of the item to be opened * @return An array containin the "fitted" dimensions */ function _fitToViewport(width,height){ resized = false; _getDimensions(width,height); // Define them in case there's no resize needed imageWidth = width, imageHeight = height; if( ((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)) && doresize && settings.allow_resize && !percentBased) { resized = true, fitting = false; while (!fitting){ if((pp_containerWidth > windowWidth)){ imageWidth = (windowWidth - 110); imageHeight = (height/width) * imageWidth; }else if((pp_containerHeight > windowHeight)){ imageHeight = (windowHeight - 110); imageWidth = (width/height) * imageHeight; }else{ fitting = true; }; pp_containerHeight = imageHeight, pp_containerWidth = imageWidth; }; _getDimensions(imageWidth,imageHeight); if((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)){ _fitToViewport(pp_containerWidth,pp_containerHeight) }; }; return { width:Math.floor(imageWidth), height:Math.floor(imageHeight), containerHeight:Math.floor(pp_containerHeight), containerWidth:Math.floor(pp_containerWidth) + (settings.horizontal_padding * 2), contentHeight:Math.floor(pp_contentHeight), contentWidth:Math.floor(pp_contentWidth), resized:resized }; }; /** * Get the containers dimensions according to the item size * @param width {integer} Width of the item to be opened * @param height {integer} Height of the item to be opened */ function _getDimensions(width,height){ width = parseFloat(width); height = parseFloat(height); // Get the details height, to do so, I need to clone it since it's invisible $pp_details = $pp_pic_holder.find('.pp_details'); $pp_details.width(width); detailsHeight = parseFloat($pp_details.css('marginTop')) + parseFloat($pp_details.css('marginBottom')); $pp_details = $pp_details.clone().addClass(settings.theme).width(width).appendTo($('body')).css({ 'position':'absolute', 'top':-10000 }); detailsHeight += $pp_details.height(); detailsHeight = (detailsHeight <= 34) ? 36 : detailsHeight; // Min-height for the details if($.browser.msie && $.browser.version==7) detailsHeight+=8; $pp_details.remove(); // Get the titles height, to do so, I need to clone it since it's invisible $pp_title = $pp_pic_holder.find('.ppt'); $pp_title.width(width); titleHeight = parseFloat($pp_title.css('marginTop')) + parseFloat($pp_title.css('marginBottom')); $pp_title = $pp_title.clone().appendTo($('body')).css({ 'position':'absolute', 'top':-10000 }); titleHeight += $pp_title.height(); $pp_title.remove(); // Get the container size, to resize the holder to the right dimensions pp_contentHeight = height + detailsHeight; pp_contentWidth = width; pp_containerHeight = pp_contentHeight + titleHeight + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height(); pp_containerWidth = width; } function _getFileType(itemSrc){ if (itemSrc.match(/youtube\.com\/watch/i) || itemSrc.match(/youtu\.be/i)) { return 'youtube'; }else if (itemSrc.match(/vimeo\.com/i)) { return 'vimeo'; }else if(itemSrc.match(/\b.mov\b/i)){ return 'quicktime'; }else if(itemSrc.match(/\b.swf\b/i)){ return 'flash'; }else if(itemSrc.match(/\biframe=true\b/i)){ return 'iframe'; }else if(itemSrc.match(/\bajax=true\b/i)){ return 'ajax'; }else if(itemSrc.match(/\bcustom=true\b/i)){ return 'custom'; }else if(itemSrc.match(/\bpermalink=true\b/i)){ return 'permalink'; }else if(itemSrc.match(/\btextarea=true\b/i)){ return 'textarea'; }else if(itemSrc.match(/\/login/i)){ return 'login'; }else if(itemSrc.substr(0,1) == '#'){ return 'inline'; }else{ return 'image'; }; }; function _center_overlay(){ if(doresize && typeof $pp_pic_holder != 'undefined') { scroll_pos = _get_scroll(); contentHeight = $pp_pic_holder.height(), contentwidth = $pp_pic_holder.width(); projectedTop = (windowHeight/2) + scroll_pos['scrollTop'] - (contentHeight/2); if(projectedTop < 0) projectedTop = 0; if(contentHeight > windowHeight) return; $pp_pic_holder.css({ 'top': projectedTop, 'left': (windowWidth/2) + scroll_pos['scrollLeft'] - (contentwidth/2) }); }; }; function _get_scroll(){ if (self.pageYOffset) { return {scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset}; } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict return {scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft}; } else if (document.body) {// all other Explorers return {scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}; }; }; function _resize_overlay() { windowHeight = $(window).height(), windowWidth = $(window).width(); if(typeof $pp_overlay != "undefined") $pp_overlay.height($(document).height()).width(windowWidth); }; function _insert_gallery(){ if(isSet && settings.overlay_gallery && _getFileType(pp_images[set_position])=="image" && (settings.ie6_fallback && !($.browser.msie && parseInt($.browser.version) == 6))) { itemWidth = 52+5; // 52 beign the thumb width, 5 being the right margin. navWidth = (settings.theme == "facebook" || settings.theme == "pp_default") ? 50 : 30; // Define the arrow width depending on the theme itemsPerPage = Math.floor((pp_dimensions['containerWidth'] - 100 - navWidth) / itemWidth); itemsPerPage = (itemsPerPage < pp_images.length) ? itemsPerPage : pp_images.length; totalPage = Math.ceil(pp_images.length / itemsPerPage) - 1; // Hide the nav in the case there's no need for links if(totalPage == 0){ navWidth = 0; // No nav means no width! $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').hide(); }else{ $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').show(); }; galleryWidth = itemsPerPage * itemWidth; fullGalleryWidth = pp_images.length * itemWidth; // Set the proper width to the gallery items $pp_gallery .css('margin-left',-((galleryWidth/2) + (navWidth/2))) .find('div:first').width(galleryWidth+5) .find('ul').width(fullGalleryWidth) .find('li.selected').removeClass('selected'); goToPage = (Math.floor(set_position/itemsPerPage) < totalPage) ? Math.floor(set_position/itemsPerPage) : totalPage; $.prettyPhoto.changeGalleryPage(goToPage); $pp_gallery_li.filter(':eq('+set_position+')').addClass('selected'); }else{ $pp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave'); // $pp_gallery.hide(); } } function _build_overlay(caller){ // Inject Social Tool markup into General markup if(settings.social_tools) facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); settings.markup = settings.markup.replace('{pp_social}',''); $('body').append(settings.markup); // Inject the markup $pp_pic_holder = $('.pp_pic_holder'), $ppt = $('.ppt'), $pp_overlay = $('div.pp_overlay'); // Set my global selectors // Inject the inline gallery! if(isSet && settings.overlay_gallery) { currentGalleryPage = 0; toInject = ""; for (var i=0; i < pp_images.length; i++) { if(!pp_images[i].match(/\b(jpg|jpeg|png|gif|files\/images)\b/gi)){ classname = 'default'; img_src = ''; }else{ classname = ''; img_src = pp_images[i]; } toInject += "
  • "; }; toInject = settings.gallery_markup.replace(/{gallery}/g,toInject); $pp_pic_holder.find('#pp_full_res').after(toInject); $pp_gallery = $('.pp_pic_holder .pp_gallery'), $pp_gallery_li = $pp_gallery.find('li'); // Set the gallery selectors $pp_gallery.find('.pp_arrow_next').click(function(){ $.prettyPhoto.changeGalleryPage('next'); $.prettyPhoto.stopSlideshow(); return false; }); $pp_gallery.find('.pp_arrow_previous').click(function(){ $.prettyPhoto.changeGalleryPage('previous'); $.prettyPhoto.stopSlideshow(); return false; }); $pp_pic_holder.find('.pp_content').hover( function(){ $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeIn(); }, function(){ $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeOut(); }); itemWidth = 52+5; // 52 beign the thumb width, 5 being the right margin. $pp_gallery_li.each(function(i){ $(this) .find('a') .click(function(){ $.prettyPhoto.changePage(i); $.prettyPhoto.stopSlideshow(); return false; }); }); }; // Inject the play/pause if it's a slideshow if(settings.slideshow){ $pp_pic_holder.find('.pp_nav').prepend('Play') $pp_pic_holder.find('.pp_nav .pp_play').click(function(){ $.prettyPhoto.startSlideshow(); return false; }); } $pp_pic_holder.attr('class','pp_pic_holder ' + settings.theme); // Set the proper theme $pp_overlay .css({ 'opacity':0, 'height':$(document).height(), 'width':$(window).width() }) .bind('click',function(){ if(!settings.modal) $.prettyPhoto.close(); }); $('a.pp_close').bind('click',function(){ $.prettyPhoto.close(); return false; }); if(settings.allow_expand) { $('a.pp_expand').bind('click',function(e){ // Expand the image if($(this).hasClass('pp_expand')){ $(this).removeClass('pp_expand').addClass('pp_contract'); doresize = false; }else{ $(this).removeClass('pp_contract').addClass('pp_expand'); doresize = true; }; _hideContent(function(){ $.prettyPhoto.open(); }); return false; }); } $pp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click',function(){ $.prettyPhoto.changePage('previous'); $.prettyPhoto.stopSlideshow(); return false; }); $pp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click',function(){ $.prettyPhoto.changePage('next'); $.prettyPhoto.stopSlideshow(); return false; }); _center_overlay(); // Center it }; if(!pp_alreadyInitialized && getHashtag()){ pp_alreadyInitialized = true; // Grab the rel index to trigger the click on the correct element hashIndex = getHashtag(); hashRel = hashIndex; hashIndex = hashIndex.substring(hashIndex.indexOf('/')+1,hashIndex.length-1); hashRel = hashRel.substring(0,hashRel.indexOf('/')); // Little timeout to make sure all the prettyPhoto initialize scripts has been run. // Useful in the event the page contain several init scripts. setTimeout(function(){ $("a["+pp_settings.hook+"^='"+hashRel+"']:eq("+hashIndex+")").trigger('click'); },50); } return this.unbind('click.prettyphoto').bind('click.prettyphoto',$.prettyPhoto.initialize); // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once }; function getHashtag(){ url = location.href; hashtag = (url.indexOf('#prettyPhoto') !== -1) ? decodeURI(url.substring(url.indexOf('#prettyPhoto')+1,url.length)) : false; return hashtag; }; function setHashtag(){ if(typeof theRel == 'undefined') return; // theRel is set on normal calls, it's impossible to deeplink using the API location.hash = theRel + '/'+rel_index+'/'; }; function clearHashtag(){ if ( location.href.indexOf('#prettyPhoto') !== -1 ) location.hash = "prettyPhoto"; } function getParam(name,url){ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( url ); return ( results == null ) ? "" : results[1]; } })(jQuery); var pp_alreadyInitialized = false; // Used for the deep linking to make sure not to call the same function several times. /*** longdo-jquery ***/ $(document).ready(function(){ if($('.customselector').length > 0) $('.customselector').customSelect(); $("a[rel^='prettyPhoto']").prettyPhoto(); $("a[rel^='prettyText']").prettyPhoto({ default_width: 400, default_height: 60 }); $("a[rel^='prettyAreatext']").prettyPhoto({ default_width: 400, default_height: 120 }); //$("a[href$='/login'], a[href*='/login?destination']").prettyPhoto({ // default_width: 400, // default_height: 200 //}); $(".menu-top").hover( function () { $(this).addClass("menu-top-hover"); }, function () { $(this).removeClass("menu-top-hover"); } ); $("#longdo-menu-link, #longdo-link-other-menu dt").hover( function () { $(this).addClass("hover"); }, function () { $(this).removeClass("hover"); } ) $("#longdo-link-other-menu dt").click(function() { window.open( $(this).children("a").attr('href') ); return false; }) .mouseover(function(){ $(this).children("a").addClass("hover"); }) .mouseout(function(){ $(this).children("a").removeClass("hover"); }); $("#tomtom-map-button").click(function(){ initTomtomMap(); initRoutingForm(); //window.open('/tomtom'); }); $("#numap-map-button").click(function(){ initNuMap(); initRoutingForm(); }); }); var searchtomtom; // move to front-page-jquery ? function isShowMap() { return (Drupal.settings && Drupal.settings.showmap); } function initNuMap() { Drupal.settings.mapdata = 'numap'; clearSerchFormValue(); clearSuggestDiv(); map_init(false, 'icons'); var search_txtbox = document.getElementById("searchfor"); var search_button = document.getElementById("bluesearch-button"); var clear_search_button = document.getElementById("searchclear"); var searchform = search_txtbox.form; if (search_txtbox) { search_txtbox.onkeyup = function() {}; search_txtbox.onkeydown = function() {}; search_txtbox.onfocus = function(e) { document.onkeydown='return true'; document.onkeypress='return true'; setSuggestDivPosition(search_txtbox, '_suggest_disp'); onkeyup=_suggest_load; onkeydown=function(e){suggest_navigation_keys_check(e, search_txtbox, '_suggest_disp');}; setTimeout(function(){document.getElementById('searchfor').select();},10);}; search_txtbox.onblur = function() {setKeyFocusAtMaparea();setTimeout('clearSuggestDiv()',500);}; } if (search_button) { search_button.onclick = function() {setBookmark(0, 'all');longdomapSearch('');setKeyFocusAtMaparea();}; } if (clear_search_button) { clear_search_button.onclick = function() {clearSerchFormValue();adjust_searchresult('true');}; } if (searchform) { searchform.onsubmit = function() { setBookmark(0, 'all');_suggest_entersearch=true;longdomapSearch('');return false; }; } $('#numap-map-button').addClass('map-data-button-active'); $('#tomtom-map-button').removeClass('map-data-button-active'); showAddLocationMode(); hideTomtomLogo(); $('body').removeClass('map-data-tomtom'); } function htmlEscape(str) { return String(str) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(//g, '>'); } function longdomapSearch(keyword) { if(keyword == "" && document.getElementById("searchfor")) { keyword = document.getElementById("searchfor").value; } if (typeof keyword.trim == 'function') { keyword = keyword.trim(); } if (getSelectedMapdata() == 'tomtom') { searchtomtom.searchPlace(keyword); } else { doSearch(keyword); } } function initTomtomMap() { if (!isShowMap()) { window.open('/tomtom'); return false; } Drupal.settings.mapdata = 'tomtom'; clearSerchFormValue(); clearSuggestDiv(); map_init(false, 'tomicons'); var searchform = document.getElementById("searchfor").form; if (searchform) { searchform.onsubmit = function() { return false; }; onkeydown = false; onkeyup = false; } searchtomtom = new longdo.SearchPOI(mmmap2, { search_id: 'search-tools', search_txtbox_id: 'searchfor', search_button_id: 'bluesearch-button', clear_button_id: 'searchclear', search_result_id: 'search-result', routing_result_id: 'routing-result', search_ds: 'toma,tomp,tomr,tomw,tomb', suggest_ds: 'toma_s,tomp_s,tomr_s,tomw_s,tomb_s'}); searchtomtom.setBasePath('/mmmap/tomtom/'); searchtomtom.searchPlaceByAjax = function(keyword, bookmark) { var center_location = searchtomtom.map.location(); var params = "?action=searchpoi"; params += "&keyword="+encodeURIComponent(keyword); params += "&lat="+center_location.lat; params += "&lon="+center_location.lon; params += "&ds="+searchtomtom.search_ds; if (typeof bookmark != "undefined") { params += "&bookmark="+bookmark; } if(typeof bookmark == 'undefined' || bookmark == 0) { searchtomtom.clearSearchMarker(); searchtomtom.setSearchResults('
    '); } searchtomtom.hideSuggestion(); searchtomtom.clearSuggestionTimeout(); params += "&callback=searchtomtom.showSearchResult"; searchtomtom.Ajax.externalLoad('/mmmap/tomtom/search/rpc.php'+params); adjust_searchresult(false, 0); } $('#numap-map-button').removeClass('map-data-button-active'); $('#tomtom-map-button').addClass('map-data-button-active'); hideAddLocationMode(); showTomtomLogo(); $('body').addClass('map-data-tomtom'); } function showLoginForm() { if($("#loginbar-login-button").length > 0) { $("#loginbar-login-button").click(); } else if($("#loginbar-login-button", top.parent.document).length > 0) { $("#loginbar-login-button", top.parent.document).click(); } } function loadjscssfile(filename, filetype){ if (filetype=="js"){ //if filename is a external JavaScript file var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) } else if (filetype=="css"){ //if filename is an external CSS file var fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", filename) } if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref); } var filesadded="" //list of files already added function checkloadjscssfile(filename, filetype){ if (filesadded.indexOf("["+filename+"]")==-1){ loadjscssfile(filename, filetype) filesadded+="["+filename+"]" //List of files added in the form "[filename1],[filename2],etc" } } $.fn.customSelect = function() { // define defaults and override with options, if available // by extending the default settings, we don't modify the argument return this.each(function() { var selected_obj = false; obj = $(this); obj.after("
    "); obj.find('option').each(function(i) { $("#selectoptions").append("
    " + $(this).html() + "
    "); if($(this).attr("value")==$('.customselector').val()) { selected_obj = "
    " + $(this).html() + "
    "; } }); if(selected_obj) { obj.before("
    " + selected_obj + "
    ").remove(); } else { obj.before("
    " + this.title + "
    ").remove(); } $("#iconselect .select-text").css( {width: $('#iconselect').width()-($('#iconselect img').width()+28)+"px"} ); $("#iconselectholder").append( $("#selectoptions")[0] ); $("#iconselect").click(function(){ $("#iconselectholder").css( { width: ($('#pre-customselect').width()+$('#iconselect').width()-2)+"px", left: "-"+($('#pre-customselect').width()+$('#iconselect').width())+"px", top: $('#iconselect').height()+15+"px" } ); $("#iconselectholder").toggle("fast"); }); $(".selectitems").mouseover(function(){ $(this).addClass("hoverclass"); }); $(".selectitems").mouseout(function(){ $(this).removeClass("hoverclass"); }); $(".selectitems").click(function(){ $(".selectedclass").removeClass("selectedclass"); $(this).addClass("selectedclass"); var thisselection = $(this).html(); thisselection.replace("", ""); $(".customselect").val(this.id); $("#iconselect").html(thisselection); $("#iconselectholder").toggle("fast"); if(obj.hasClass('onchange-changeCategoryOOI')) { window.location = '//'+location.hostname+"/poilist/"+$(".customselect").val()+"/recently"; } }); }); } function checkLoadedAdsIFrameOnFrontPage(iframe) { var iframeDocument = iframe.contentDocument || iframe.contentWindow.document; if(iframeDocument && iframeDocument.body && iframeDocument.body.innerHTML != "") { iframe.className = 'ads-iframe-loaded'; } } function checkAreaForAdsIframe() { if(($(window).width() - $('#logo').width() - 20) < $('#longdo_advertisement').width()) { // 20: margin-left of logo if($('#longdo_advertisement_iframe').attr('src') != '') { $('#longdo_advertisement_iframe').removeAttr('src'); $('#longdo_advertisement_iframe').removeClass('ads-iframe-loaded'); } } else { if(! $('#longdo_advertisement_iframe').attr('src')) { $('#longdo_advertisement_iframe').attr('src', '/ads/rand_ads.php'); } } } function getPermalinkURL() { if(isShowMap()) { var selected_tab_index = getCurrentTabIndex(); var url = false; if (selected_tab_index > 0) { var tab_panel = $(".ui-tabs-panel").get(selected_tab_index); if (typeof(tab_panel) != 'undefiend' && tab_panel.id) { url = $("#"+tab_panel.id).attr('originalpath'); } if (url) { url = window.location.protocol+'//'+window.location.hostname+url; } } if (!url) { url = window.location.protocol+'//'+window.location.hostname+'/?'; var location = getCenterLocation(); var latitude = location.lat; var longitude = location.lon; var zoom = mapZoom(); var search, tag, ooi; /*, searchlat, searchlon*/ if (typeof(window._longdomap_permalink_act) != 'undefined') { search = _longdomap_permalink_act.search ? _longdomap_permalink_act.search : false; //searchlat = _longdomap_permalink_act.searchlat ? _longdomap_permalink_act.searchlat : false; //searchlon = _longdomap_permalink_act.searchlon ? _longdomap_permalink_act.searchlon : false; tag = _longdomap_permalink_act.tag ? _longdomap_permalink_act.tag : false; ooi = _longdomap_permalink_act.ooi ? _longdomap_permalink_act.ooi : false; // if (search && searchlat && searchlon) { // latitude = searchlat; // longitude = searchlon; // } } var advance_param = ''; if (search) { advance_param += '&search='+search; } if (tag) { advance_param += '&tag='+tag; } if (ooi) { advance_param += '&ooi='+ooi; } var ggmode = getGoogleMapModeV1(); if(ggmode == 'gmap') { url += "gmap=1&"; } else if(ggmode == 'hybrid') { url += "hybrid=1&"; } else { url += "mode=" + encodeURIComponent(getMapModeV1()) + "&"; } url = url + 'lat='+latitude+'&long='+longitude+'&zoom='+zoom+'&map='+getMapProjection()+advance_param; if (mylang) { url += '&locale='+mylang; } } } else { url = window.location.href; } return url; }