cms.RootPath = ''; /* WebFilter 0x1010006400000002 */ local.pagePickerSearch = function(oText) { if (oText._searchTimeout) { clearTimeout(oText._searchTimeout); } oText._searchTimeout = setTimeout(function() { oText._searchTimeout = null; var ot = $(oText); if (oText._lower == null) oText._lower = ot.closest('.cms-page-search').find('.cms-page-search-lower'); var lwr = oText._lower; if (lwr._oldHtml == null) { lwr._oldHtml = $(lwr).html(); } if (oText._searchXhr != null) { // Request already in progress oText._searchQueued = true; } else if (oText.value == '' && lwr._oldHtml != null) { lwr.html(lwr._oldHtml); } else if (oText._lastSearch != oText.value) { // Nothing queued oText._searchQueued = false; ot.closest('div').addClass('active'); oText._lastSearch = oText.value; oText._searchXhr = $.getJSON(cms.RootPath + '/wf.ashx?f=search.json&t=269484034&q=' + encodeURIComponent(oText.value), function(sData) { $(lwr).empty(); var h = $(lwr).closest('.ui-dialog-content').height(); ot.closest('div').removeClass('active'); ot.closest('.cms-page-search').find('.cms-page-search-lower').scrollTop(0); if(sData.length == 0) { var outer = $('
').addClass('cms-info'); var inner = $('
').addClass('cms-info-inner').addClass('cms-info-info').html('

No results found.

').appendTo(outer); outer.appendTo(lwr); } else { for (var idx = 0; idx < sData.length; idx++) { var sObj = sData[idx]; var item = $('
').addClass('cms-page-search-result').addClass(idx % 2 == 0 ? 'list-even':'list-odd'); var hdr = $('
').addClass('cms-page-search-result-title'); var link = $(''); link[0]._type_id = sObj['type_id']; link[0]._object_id = sObj['object_id']; link.click(function(){storeCmsLink('{{'+this._type_id+':'+this._object_id+'}}');return false;}); if(sObj['hl_title']) link.html(sObj['hl_title']); else link.text(sObj['title']); link.attr('href',sObj['link']).appendTo(hdr); hdr.appendTo(item); $('
').addClass('cms-page-search-result-url').text(sObj['link']).appendTo(item); if(sObj['summary']) $('
').addClass('cms-page-search-result-body').html(sObj['summary']).appendTo(item); item.appendTo(lwr); var l = $(lwr); l.height(h - l.position().top + 24); } } oText._searchXhr = null; if (oText._searchQueued == true) { oText._searchQueued = false; local.pagePickerSearch(oText); } }); } }, 300); }; /* WebFilter 0x1010006400000003 */ local.filePickerSearch = function(oText,iFolder) { if (oText._searchTimeout) { clearTimeout(oText._searchTimeout); } oText._searchTimeout = setTimeout(function() { oText._searchTimeout = null; var ot = $(oText); if (oText._lower == null) oText._lower = ot.closest('.cms-page-search').find('.cms-page-search-lower'); var lwr = oText._lower; if (lwr._oldHtml == null) { lwr._oldHtml = $(lwr).html(); } if (oText._searchXhr != null) { // Request already in progress oText._searchQueued = true; } else if (oText.value == '' && lwr._oldHtml != null) { lwr.html(lwr._oldHtml); } else if (oText._lastSearch != oText.value) { // Nothing queued oText._searchQueued = false; ot.closest('div').addClass('active'); oText._lastSearch = oText.value; oText._searchXhr = $.getJSON(cms.RootPath + '/wf.ashx?f=search.json&t=268566529&q=' + encodeURIComponent(oText.value) + '&file.folder=' + parseInt(iFolder,10), function(sData) { $(lwr).empty(); var h = $(lwr).closest('.ui-dialog-content').height(); ot.closest('div').removeClass('active'); ot.closest('.cms-page-search').find('.cms-page-search-lower').scrollTop(0); var result = false; if (sData.length > 0) { for (var idx = 0; idx < sData.length; idx++) { var sObj = sData[idx]; var size = parseInt(sObj['size'],10); if (size > 0) { var item = $('
').addClass('cms-page-search-result').addClass('cms-file-search-result').addClass(idx % 2 == 0 ? 'list-even':'list-odd'); var thm = parseInt(sObj['thumbnail'],10); if (thm != 0) { var imgLink = $('') .click(function(){storeFileChoice(this._object_id);return false;}) .attr('href',sObj['link']) .appendTo($('
') .addClass('cms-file-search-image') .appendTo(item)); imgLink[0]._type_id = sObj['type_id']; imgLink[0]._object_id = sObj['object_id']; $('').attr('src',cms.RootPath + '/f.ashx?v=' + thm).appendTo(imgLink); } var hdr = $('
').addClass('cms-page-search-result-title'); var link = $(''); link[0]._type_id = sObj['type_id']; link[0]._object_id = sObj['object_id']; link.click(function(){storeFileChoice(this._object_id);return false;}); if(sObj['hl_title']) link.html(sObj['hl_title']); else link.text(sObj['title']); link.attr('href',sObj['link']).appendTo(hdr); hdr.appendTo(item); $('
').addClass('cms-page-search-result-right').text(((Math.round(parseFloat(sObj['size']) / 1024) * 100) / 100) + ' kB').appendTo(item); $('
').addClass('cms-page-search-result-url').text(sObj['path']).appendTo(item); $('').attr('href',sObj['download']).attr('target','_blank').text('download') .appendTo($('
').addClass('cms-page-search-result-right').appendTo(item)); $('
').addClass('cms-page-search-result-url').text(sObj['mime']).appendTo(item); $('
').addClass('cms-page-search-result-end').appendTo(item); if(sObj['summary']) $('
').addClass('cms-page-search-result-body').html(sObj['summary']).appendTo(item); item.appendTo(lwr); var l = $(lwr); l.height(h - l.position().top + 24); result = true; } } } if (result == false) { var outer = $('
').addClass('cms-info'); var inner = $('
').addClass('cms-info-inner').addClass('cms-info-info').html('

No results found.

').appendTo(outer); outer.appendTo(lwr); } oText._searchXhr = null; if (oText._searchQueued == true) { oText._searchQueued = false; local.pagePickerSearch(oText); } }); } }, 300); }; /* WebFilter 0x1010006400000004 */ local.fileLinkPickerSearch = function(oText,iFolder) { if (oText._searchTimeout) { clearTimeout(oText._searchTimeout); } oText._searchTimeout = setTimeout(function() { oText._searchTimeout = null; var ot = $(oText); if (oText._lower == null) oText._lower = ot.closest('.cms-page-search').find('.cms-page-search-lower'); var lwr = oText._lower; if (lwr._oldHtml == null) { lwr._oldHtml = $(lwr).html(); } if (oText._searchXhr != null) { // Request already in progress oText._searchQueued = true; } else if (oText.value == '' && lwr._oldHtml != null) { lwr.html(lwr._oldHtml); } else if (oText._lastSearch != oText.value) { // Nothing queued oText._searchQueued = false; ot.closest('div').addClass('active'); oText._lastSearch = oText.value; oText._searchXhr = $.getJSON(cms.RootPath + '/wf.ashx?f=search.json&t=268566529&q=' + encodeURIComponent(oText.value) + '&file.folder=' + parseInt(iFolder,10), function(sData) { $(lwr).empty(); var h = $(lwr).closest('.ui-dialog-content').height(); ot.closest('div').removeClass('active'); ot.closest('.cms-page-search').find('.cms-page-search-lower').scrollTop(0); var result = false; if (sData.length > 0) { for (var idx = 0; idx < sData.length; idx++) { var sObj = sData[idx]; var size = parseInt(sObj['size'],10); if (size > 0) { var item = $('
').addClass('cms-page-search-result').addClass('cms-file-search-result').addClass(idx % 2 == 0 ? 'list-even':'list-odd'); var thm = parseInt(sObj['thumbnail'],10); if (thm != 0) { var imgLink = $('') .click(function(){storeFileChoice(this._object_id);return false;}) .attr('href',sObj['link']) .appendTo($('
') .addClass('cms-file-search-image') .appendTo(item)); imgLink[0]._type_id = sObj['type_id']; imgLink[0]._object_id = sObj['object_id']; $('').attr('src',cms.RootPath + '/f.ashx?v=' + thm).appendTo(imgLink); } var hdr = $('
').addClass('cms-page-search-result-title'); var link = $(''); link[0]._type_id = sObj['type_id']; link[0]._object_id = sObj['object_id']; link.click(function(){storeCmsLink('{{268566529:' + this._object_id + ';File.LinkType=Download}}');return false;}); if(sObj['hl_title']) link.html(sObj['hl_title']); else link.text(sObj['title']); link.attr('href',sObj['link']).appendTo(hdr); hdr.appendTo(item); $('
').addClass('cms-page-search-result-right').text(((Math.round(parseFloat(sObj['size']) / 1024) * 100) / 100) + ' kB').appendTo(item); $('
').addClass('cms-page-search-result-url').text(sObj['path']).appendTo(item); $('').attr('href',sObj['download']).attr('target','_blank').text('download') .appendTo($('
').addClass('cms-page-search-result-right').appendTo(item)); $('
').addClass('cms-page-search-result-url').text(sObj['mime']).appendTo(item); $('
').addClass('cms-page-search-result-end').appendTo(item); if(sObj['summary']) $('
').addClass('cms-page-search-result-body').html(sObj['summary']).appendTo(item); item.appendTo(lwr); var l = $(lwr); l.height(h - l.position().top + 24); result = true; } } } if (result == false) { var outer = $('
').addClass('cms-info'); var inner = $('
').addClass('cms-info-inner').addClass('cms-info-info').html('

No results found.

').appendTo(outer); outer.appendTo(lwr); } oText._searchXhr = null; if (oText._searchQueued == true) { oText._searchQueued = false; local.pagePickerSearch(oText); } }); } }, 300); }; /* WebFilter 0x1010006400000016 */ local.google = {}; local.google.maps = {}; local.google.maps.loadMap = function(selector,itemType,itemTag,bCentreLoc){ //Lookup any new addresses local.google.maps.codeAddress(); //Create Map local.google.maps.itemType = itemType; local.google.maps.itemTag = itemTag; local.google.maps.googlePendingInterval = setInterval(function() { if (local.google.maps.googlePendingCount <= 0) { clearInterval(local.google.maps.googlePendingInterval); local.google.maps.InitializeMap(selector); if (bCentreLoc === true) { if (navigator && navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); local.google.maps.map.setCenter(initialLocation); }); } } } },100); }; local.google.maps.googlePendingInterval = null; local.google.maps.zoomDelayInterval = null; local.google.maps.googlePendingCount = 0; local.google.maps.map = null; local.google.maps.addressArray = []; local.google.maps.encodedAddrArray = []; local.google.maps.overQueryLimit = false; local.google.maps.InitializeMap = function(selector) { mapType = google.maps.MapTypeId.ROADMAP; switch(local.google.maps.mapType) { case 'k': mapType = google.maps.MapTypeId.SATELLITE; break; case 'h': mapType = google.maps.MapTypeId.HYBRID; break; case 'p': mapType = google.maps.MapTypeId.TERRAIN; break; } google.maps.MapTypeId.ROADMAP; var myOptions = { mapTypeId: mapType, zoom: local.google.maps.zoomLevel }; local.google.maps.map = new google.maps.Map(document.getElementById(selector), myOptions); local.google.maps.addMarkers(); local.google.maps.addOverlays(); local.google.maps.zoomDelayInterval = setInterval(function() { clearInterval(local.google.maps.zoomDelayInterval); local.google.maps.map.setZoom(local.google.maps.zoomLevel); },500); }; local.google.maps.codeAddress = function() { $.each( local.google.maps.addressArray, function( intIndex, objValue ){ if(local.google.maps.overQueryLimit != true){ local.google.maps.googlePendingCount++; var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': objValue.address}, function(results, status) { local.google.maps.googlePendingCount--; if (status == google.maps.GeocoderStatus.OK) { local.google.maps.encodedAddrArray.push({'position' : results[0].geometry.location, 'title' : objValue.title, 'content': objValue.content}); var pos = {'lat':results[0].geometry.location.lat(), 'long':results[0].geometry.location.lng()}; local.google.maps.saveLocationData(objValue.marker_id, pos); } else { console.log("Geocode was not successful for the following reason: " + status); if(status == 'OVER_QUERY_LIMIT'){ local.google.maps.overQueryLimit = true; } } }); } } ); }; local.google.maps.addOverlays = function(){ google.maps.event.addListener(local.google.maps.map, "rightclick", function(e) { var lat = e.latLng.lat(); var lng = e.latLng.lng(); // populate yor box/field with lat, lng //alert("Lat=" + lat + "; Lng=" + lng); }); }; local.google.maps.addMarkers = function(){ var infowindow; $.each( local.google.maps.encodedAddrArray, function(intIndex, objValue){ var marker = new google.maps.Marker({ map: local.google.maps.map, position: objValue.position, title: objValue.title }); if (objValue.content) { var iw = new google.maps.InfoWindow({content:objValue.content}); google.maps.event.addListener(marker,'click',function(){ iw.open(local.google.maps.map,marker); }); } /* google.maps.event.addListener(marker, 'click', function() { if (infowindow) infowindow.close(); infowindow = new google.maps.InfoWindow({ content: objValue.content }); infowindow.open(local.google.maps.map, marker); }); */ if (intIndex == local.google.maps.encodedAddrArray.length - 1 && local.google.maps.centerTimeout == null) { local.google.maps.centerTimeout = setTimeout(local.google.maps.centerMap,500); } } ); }; local.google.maps.centerTimeout = null; local.google.maps.centerMap = function(){ local.google.maps.centerTimeout = null; // Create a new viewpoint bound var bounds = new google.maps.LatLngBounds (); // Go through each... for (var i = 0, LtLgLen = local.google.maps.encodedAddrArray.length; i < LtLgLen; i++) { // And increase the bounds to take this point bounds.extend (local.google.maps.encodedAddrArray[i].position); } // Fit these bounds to the map google.maps.event.addListener(local.google.maps.map, 'zoom_changed', function() { zoomChangeBoundsListener = google.maps.event.addListener(local.google.maps.map, 'bounds_changed', function(event) { if (this.getZoom() > 24 && this.initialZoom == true) { // Change max/min zoom here this.setZoom(24); this.f = false; } google.maps.event.removeListener(zoomChangeBoundsListener); }); }); local.google.maps.map.initialZoom = true; local.google.maps.map.fitBounds (bounds); } local.google.maps.addAddress = function(id, address, title, content) { local.google.maps.addressArray.push({'address' : address, 'marker_id' : id, 'title' : title, 'content' : content}); }; local.google.maps.saveLocationData = function(object, data) { var objData = data; var obj = object; //console.log(objData); $.getJSON(cms.RootPath + '/wf.ashx/access.json/getkey/'+local.google.maps.itemTag+'/-1?u=' + Math.random(), function (data) { var ah = data['a.h']; var as = data['a.s']; var at = data['a.t']; if (ah == null || as == null || at == null) { //alert('Failed to authorise.'); } else { var jsonData = []; var thisData = {}; thisData.d = obj; thisData.t = local.google.maps.itemType; thisData.f = {}; thisData.f['latitude'] = objData.lat; thisData.f['longitude'] = objData.long; jsonData.push(thisData); var postData = JSON.stringify(jsonData); var url = cms.RootPath + '/wf.ashx/access.json/put/'+local.google.maps.itemTag+'/-1?a.h=' + encodeURIComponent(ah) + '&a.s=' + encodeURIComponent(as) + '&a.t=' + encodeURIComponent(at) + '&u=' + Math.random(); $.post(url, postData, function (data, textStatus, jqXhr) { }); } }); }; /* TemplateFilter 0x10C80FA000000007 */ local.StartSlideshow = function(g,data,startId,settings) { var s = new slideShow(); s.g = g; g.addClass('i001-gallery-slideshow-parent'); s.ID = Math.floor(Math.random() * 100000); local.slideShowTable[s.ID] = s; s.SlideshowData = data; if (settings) { for (var x in settings) { s.SlideshowSettings[x] = settings[x]; } } // Width fix var tWrap = g.find('.i001-gallery-thumbs'); var tRow = tWrap.find('.i001-gallery-thumb_row'); tRow.width(tWrap.width() - (2 * parseInt(s.SlideshowSettings.navPadding,10))); s.SlideshowStartId = startId; g.data('g',s); s.SlideshowPrepareThumbnails(); s.UnpauseSlideshow(); s.SlideshowTimeout = setTimeout("local.slideShowTable['" + s.ID + "'].SlideshowExecute()",s.SlideshowSettings.interval); } local.slideShowTable = { }; function slideShow() { } slideShow.prototype.ID = 0; slideShow.prototype.g = null; slideShow.prototype.SlideshowIndex = -1; slideShow.prototype.SlideshowCurrent = null; slideShow.prototype.SlideshowData = null; slideShow.prototype.SlideshowTimeout = -1; slideShow.prototype.SlideshowPaused = false; slideShow.prototype.SlideshowSettings = { interval: 5000, transitionInterval: 500, thumbSpacing: 120, navPadding: 66 }; local.PauseSlideshow = function(oLink) { return $(oLink).closest('.i001-gallery-slideshow-parent').data('g').PauseSlideshow(); } slideShow.prototype.PauseSlideshow = function() { var g; if (this.SlideshowData) { g = this; } else if (g == null) { g = $(this).closest('.i001-gallery-slideshow-parent').data('g'); } g.SlideshowPaused = true; g.g.find('.i001-gallery-slideshow-state .play').removeClass('active'); g.g.find('.i001-gallery-slideshow-state .pause').addClass('active'); return false; }; local.UnpauseSlideshow = function(oLink) { return $(oLink).closest('.i001-gallery-slideshow-parent').data('g').UnpauseSlideshow(); } slideShow.prototype.UnpauseSlideshow = function() { var g; if (this.SlideshowData) { g = this; } else if (g == null) { g = $(this).closest('.i001-gallery-slideshow-parent').data('g'); } g.SlideshowPaused = false; g.g.find('.i001-gallery-slideshow-state .pause').removeClass('active'); g.g.find('.i001-gallery-slideshow-state .play').addClass('active'); return false; }; slideShow.prototype.SlideshowExecute = function() { if (this.SlideshowPaused == true) { clearTimeout(this.SlideshowTimeout); this.SetTimeout(2); } else { this.UnpauseSlideshow(); if (this.SlideshowIndex == -1) this.SlideshowPrepare(this.SlideshowData); this.SlideshowChangeTo(this.SlideshowIndex + 1,this.SlideshowData); } }; slideShow.prototype.SlideshowPrepare = function(data) { this.SlideshowData = data; this.g.find('.i001-gallery-slideshow-img-standby').data('g',this).load(this.SlideshowStandbyLoad).parent().css('z-index',90); this.g.find('.i001-gallery-slideshow-img-main').data('g',this).load(this.SlideshowStandbyReset).parent().css('z-index',89); for(var i=0; i < data.length; i++) { if (parseInt(data[i].ss_id) == this.SlideshowStartId) { this.SlideshowIndex = i; } if (data[i].ss_id > 0) { data[i].cacheImg = new Image(); data[i].cacheImg.src = '/f.ashx?v=' + parseInt(data[i].img_tgt,10); } } }; slideShow.prototype.SlideshowChangeTo = function(newIdx,data) { if (this.SlideshowIndex == -1) this.SlideshowPrepare(data); clearTimeout(this.SlideshowTimeout); var oldIdx = this.SlideshowIndex; this.SlideshowIndex = newIdx; if (this.SlideshowIndex >= data.length - 1) this.SlideshowIndex = 0; if (this.SlideshowIndex < 0) this.SlideshowIndex = data.length - 2; var t = data[this.SlideshowIndex]; this.SlideshowCurrent = t; this.g.find('.i001-gallery-slideshow-img-standby').attr('src',t.cacheImg.src); }; slideShow.prototype.SlideshowStandbyReset = function() { $(this).css('opacity',1); $(this).closest('.i001-gallery-slideshow-parent').find('.i001-gallery-slideshow-img-standby').parent().css('top','-20000px'); }; slideShow.prototype.SlideshowStandbyLoad = function() { var g = $(this).data('g'); if (g == null) return; var t = g.SlideshowCurrent; if (t == null) return; var wrap = g.g.find('.i001-gallery-slideshow-wrap'); var standby = g.g.find('.i001-gallery-slideshow-img-standby'); var main = g.g.find('.i001-gallery-slideshow-img-main'); standby.css('opacity',0).parent().css('top','0'); main.stop(true).css('opacity',1); var trans = g.SlideshowSettings.transitionInterval; main.stop(true).animate({opacity:0},trans); standby.stop(true).animate({opacity: 1},trans,function() { main.attr('src',standby.attr('src')); }); wrap.stop(true).animate({height: standby.height()}, trans); g.g.find('.i001-gallery-slideshow-title').text(cms.UnescapeHtml(t.title)); var cap = g.g.find('.i001-gallery-slideshow-caption'); var sbCap = g.g.find('.i001-gallery-slideshow-caption-standby'); sbCap.text(cms.UnescapeHtml(t.caption)); if (t.caption == '' || t.caption == null) { cap.parent().stop(true).animate({height: 0},trans,function() { cap.text(''); cap.parent().css('display','none'); }); } else { cap.parent().css('display','block').stop(true).animate({height: sbCap.parent().height()},trans,function() { cap.text(cms.UnescapeHtml(t.caption)); }); } g.SlideshowActivateThumbnail(g,t.ss_id); g.SetTimeout(); }; slideShow.prototype.SetTimeout = function(divisor) { if (divisor > 1) { } else { divisor = 1; } this.SlideshowTimeout = setTimeout("local.slideShowTable['" + this.ID + "'].SlideshowExecute()", this.SlideshowSettings.interval / divisor); } slideShow.prototype.ThumbOffset = -1; slideShow.prototype.ThumbListWidth = -1; slideShow.prototype.ThumbBoxWidth = -1; slideShow.prototype.ThumbMinPos = 0; slideShow.prototype.SlideshowPrepareThumbnails = function() { var row = this.g.find('.i001-gallery-slideshow-thumbs').data('g',this); var inner = row.find('.i001-gallery-thumb_row_inner'); row.css('overflow','hidden'); this.ThumbBoxWidth = row.width(); inner.css('position','absolute').css('left','0'); var curPos = 0; var curIdx = 0; var parent = this; inner.find('div div').each(function() { var t = $(this); t.css('position','absolute').css('left',curPos).css('float','none'); this._position = curPos; this._idx = curIdx++; curPos += parent.SlideshowSettings.thumbSpacing; }); inner.find('a').click(function() { var parent = $(this).closest('.i001-gallery-slideshow-parent').data('g'); parent.SlideshowChangeTo(parseInt($(this).closest('div')[0]._idx),parent.SlideshowData); return false; }); this.ThumbListWidth = curPos; this.ThumbMinPos = this.ThumbBoxWidth - this.ThumbListWidth; this.g.find('.i001-gallery-nav.i001-gallery-back a').click(function(){ var parent = $(this).closest('.i001-gallery-slideshow-parent').data('g'); parent.SlideshowChangeTo(parent.SlideshowIndex - 1,parent.SlideshowData); return false; }); this.g.find('.i001-gallery-nav.i001-gallery-next a').click(function(){ var parent = $(this).closest('.i001-gallery-slideshow-parent').data('g'); parent.SlideshowChangeTo(parent.SlideshowIndex + 1,parent.SlideshowData); return false; }); }; slideShow.prototype.SlideshowActivateThumbnail = function(g,thmId) { g.g.find('.i001-gallery-slideshow-nav-parent').find('.i001-gallery-slideshow-item-active').removeClass('i001-gallery-slideshow-item-active'); var thm = g.g.find('.i001-gallery-slideshow-item-' + parseInt(thmId)); thm.addClass('i001-gallery-slideshow-item-active'); var ntPos = (g.ThumbBoxWidth / 2) - (thm[0]._position + (thm.width() / 2)); if (ntPos < g.ThumbMinPos) ntPos = g.ThumbMinPos; if (ntPos > 0) ntPos = 0; g.g.find('.i001-gallery-slideshow-thumbs div.i001-gallery-thumb_row_inner').stop(true).animate({left: ntPos},g.SlideshowSettings.transitionInterval); }; /* TemplateFilter 0x10C80FA000000019 */ local.cartRedir_productLinksActive = false; local.cartRedir_activateProductLinks = function() { if (local.cartRedir_productLinksActive == false) { local.cartRedir_productLinksActive = true; if (local.ActivePage) { $('a.i001-prod-tgt-link').click(function(e) { var scrollTop = $(document).scrollTop(); if (isNaN(scrollTop)) { scrollTop = 0; } var pageId = local.ActivePage; var t = $(this); var curTarget = t.attr('originalTarget'); if (curTarget == null) { curTarget = t.attr('href'); t.data('originalTarget',curTarget); } t.attr('href',curTarget + '&lv.nextpage=' + parseInt(pageId,10) + '&lv.nextpagehash=ST' + parseInt(scrollTop,10)); }); $('form').each(function(){ var t = $(this); if (t.find('.i001-detail-info input').length > 0) { t.submit(local.cartRedir_productSubmitForm); } }); } if (window.location.hash) { if (window.location.hash.substring(0,3) == '#ST') { var scrollTop = parseInt(window.location.hash.substring(3),10); if (scrollTop > 0) { $(window).scrollTop(scrollTop); cms.DisplayMessage('Items added to cart successfully.',2000); } } } } }; local.cartRedir_productSubmitForm = function() { if (local.ActivePage) { var scrollTop = $(document).scrollTop(); if (isNaN(scrollTop)) { scrollTop = 0; } var pageId = local.ActivePage; var t = $(this); var curTarget = t.data('originalTarget'); if (curTarget == null) { curTarget = t.attr('action'); t.data('originalTarget',curTarget); } t.attr('action',curTarget + '&lv.nextpage=' + parseInt(pageId,10) + '&lv.nextpagehash=ST' + parseInt(scrollTop,10)); } }; /* TemplateFilter 0x10C80FA00000001A */ local.changeTargetImage = function(smallVerId,largeVerId) { cms.Popup.ImgChangeDynamic('#target_img',smallVerId,largeVerId); return false; }; /* TemplateFilter 0x10C80FA0000000E5 */ cms.InitializeDropdown = function(direction,multi){ if(cms._initializedComplete == true){return}; if(direction == 'vertical'){ var width = $('.w123-std-menu').width(); var shrinkSize = width - (0.3 * width); $('.w123-std-menu li').children('.w123-std-dropdown').css({left: shrinkSize}); cms.VertStdDropdown(); } else if(direction == 'horizontal'){ var height = $('.w123-std-menu').height(); if (height == 0) { height = $('.w123-std-menu li').height(); } var shrinkSize = height - (0.3 * height); $('.w123-std-menu li').children('.w123-std-dropdown').css({top: shrinkSize}); cms.HoriStdDropdown(); } if(multi == true){ $('.w123-std-dropdown').each(function(){ var pWidth = $(this).outerWidth(); var shrinkSize = pWidth - (0.1 * pWidth); if(shrinkSize > 0){ $(this).find('.w123-std-dropdown-inner-child').css({left: shrinkSize}); } }); cms.deepStdDropdown(direction); } cms._initializedComplete = true; }; cms.VertStdDropdown = function(){ if (cms.StdDropdownActive == true) { return; } cms.StdDropdownActive = true; var width = $('.w123-std-menu').width(); var shrinkSize = width - (0.3 * width); $('.w123-std-menu li').mouseover(function(){ $(this).children('.w123-std-dropdown').stop().dequeue().animate({ left: width, opacity: 1},100); $(this).closest('li').addClass('open'); }).mouseleave(function(){ $(this).children('.w123-std-dropdown').animate({ left: shrinkSize, opacity: 0 },200); $('.w123-std-menu li').closest('li').removeClass('open'); }); cms.StdDropdownActive = false; }; cms.HoriStdDropdown = function(){ if (cms.StdDropdownActive == true) { return; } cms.StdDropdownActive = true; var height = $('.w123-std-menu').height(); if (height == 0) { height = $('.w123-std-menu li').height(); } height = height * 0.9; var shrinkSize = height * 0.5; $('.w123-std-menu li').mouseover(function(){ $(this).children('.w123-std-dropdown').stop().dequeue().animate({ top: height, opacity: 1},100); $(this).closest('li').addClass('open'); }).mouseleave(function(){ $(this).children('.w123-std-dropdown').animate({ top: shrinkSize, opacity: 0 },200); $('.w123-std-menu li').closest('li').removeClass('open'); }); cms.StdDropdownActive = false; }; cms.StdDropdown = function(){ if (cms.StdDropdownActive == true) { return; } $('.w123-std-menu li').hover( function() { $(this).closest('li').addClass('open'); }, function() { $(this).closest('li').removeClass('open'); } ); cms.StdDropdownActive = false; }; cms.deepStdDropdown = function(direction){ if (cms.StdDropdownActive == true) { return; } cms.StdDropdownActive = true; if(direction == 'horizontal'){ $('.w123-std-dropdown li').mouseover(function(){ var target = $(this).closest('ul'); cms.getWidth(target); $(this).children('.w123-std-dropdown-inner-child').stop().dequeue().width(cms._targetWidth).animate({ left: cms._targetWidth, opacity: 1},100); $(this).closest('li').addClass('open'); }).mouseleave(function(){ $(this).children('.w123-std-dropdown-inner-child').animate({ left: cms._shrinkSize, opacity: 0 },200); $('.w123-std-menu li').closest('li').removeClass('open'); }); } else if(direction == 'vertical'){ $('.w123-std-dropdown li').mouseover(function(){ var target = $(this).closest('ul'); cms.getWidth(target); $(this).children('.w123-std-dropdown-inner-child').stop().dequeue().animate({ left: cms._targetWidth, opacity: 1},100); $(this).closest('li').addClass('open'); }).mouseleave(function(){ $(this).children('.w123-std-dropdown-inner-child').animate({ left: cms._shrinkSize, opacity: 0 },200); $('.w123-std-menu li').closest('li').removeClass('open'); }); } cms.StdDropdownActive = false; }; cms.StdDropdownActive = false; cms._targetWidth = 0; cms._shrinkSize = 0; cms._initializedComplete = false; cms.getWidth = function(target){ cms._targetWidth = $(target).width(); cms._shrinkSize = cms._targetWidth - (0.1 * cms._targetWidth); }; /* TemplateFilter 0x10C80FA00000042F */ local.toggleFaq = function(obj) { var tgt = $(obj); var parent = tgt.closest('.i001-faq-item0'); var inner = parent.find('.faq-content'); if (parent.hasClass('open')) { inner.hide('fast'); parent.removeClass('open'); } else { inner.show('fast'); parent.addClass('open'); } return false; }; /* TemplateFilter 0x10C80FA00000043E */ local.changeTargetImage = function(selector, smallVerId,largeVerId) { cms.Popup.ImgChangeDynamic(selector, smallVerId,largeVerId); return false; }; local.enableImageZoom = function(selector) { var tgt = $(selector); var zoomData = tgt.data('imgZoom'); if (zoomData == null) { zoomData = { }; tgt.data('imgZoom',zoomData); tgt.addClass('cms-img-zoom'); var nh = tgt.height(); var nw = tgt.width(); var ar = nh / nw; tgt.mouseover(local.imgZoomMouseOver); tgt.mousemove(local.imgZoomMouseMove); //Set event handler as 'mouseleave' if original image is less than 450px high if(ar < 0.4){ tgt.mouseleave(local.imgZoomMouseOut); } else { tgt.mouseout(local.imgZoomMouseOut); } tgt.find('img').load(local.imgZoomLoadImg); local.imgZoomSetSizes(tgt); } }; local.imgZoomSetSizes = function(tgt) { var zoomData = tgt.data('imgZoom'); var lge = tgt.find('.cms-img-zoom-large'); var w = tgt.width(); var h = tgt.height(); var bw = lge.width(); var bh = lge.height(); var xMax = (bw - w); var yMax = (bh - h); zoomData.pad = 20; zoomData.w = w; zoomData.h = h; zoomData.ar = h / w; zoomData.bw = bw; zoomData.bh = bh; zoomData.xMax = xMax; // Set the height of the element to be equal to the height of the large image if less than 450px // so that the mouse move pad is correctly setup for the new, larger height. if(zoomData.ar < 0.4){ zoomData.o = h; h = bh; zoomData.h = bh; zoomData.yMax = bh; } else { zoomData.yMax = yMax; } zoomData.pos = tgt.offset(); zoomData.xt = bw - w; zoomData.yt = bh - h; zoomData.xRatio = (w - zoomData.pad * 2) / zoomData.xt; zoomData.yRatio = (h - zoomData.pad * 2) / zoomData.yt; }; local.imgZoomLoadImg = function(e) { var tgt = $(this).closest('.cms-img-zoom'); if (tgt.length > 0) { local.imgZoomSetSizes(tgt); } }; local.imgZoomMouseOver = function(e) { if($(e.relatedTarget).is('img') == false) { var tgt = $(this); var lge = tgt.find('.cms-img-zoom-large'); var bh = lge.height(); var zoomData = tgt.data('imgZoom'); // Make the image box the size of the large image if less than 450px. if(zoomData.ar < 0.4){ $(this,'#target_img').animate({ height: bh }); } $(this).find('.cms-img-zoom-large').fadeIn(); } }; local.imgZoomMouseMove = function(e) { var tgt = $(this); var lge = tgt.find('.cms-img-zoom-large'); var zoomData = tgt.data('imgZoom'); zoomData.pos = tgt.offset(); var x = e.pageX - zoomData.pos.left; var y = e.pageY - zoomData.pos.top; if (x > zoomData.w - zoomData.pad) { x = zoomData.w - zoomData.pad; } x = Math.max(0,(x - zoomData.pad)); if (y > zoomData.h - zoomData.pad) { y = zoomData.h - zoomData.pad; } y = Math.max(0,(y - zoomData.pad)); x = -(x / zoomData.xRatio); y = -(y / zoomData.yRatio); if (x > 0) { x = 0; } if (y > 0) { y = 0; } if (x < -zoomData.xMax) { x = -zoomData.xMax; } if (y < -zoomData.yMax) { y = -zoomData.yMax; } lge.css('top',y + 'px'); lge.css('left',x + 'px'); }; local.imgZoomMouseOut = function(e) { if($(e.relatedTarget).is('img') == false) { $(this).find('.cms-img-zoom-large').fadeOut(); var tgt = $(this); // Put image box back to original size and remove height styling. var zoomData = tgt.data('imgZoom'); if(zoomData.ar < 0.4){ $(this,'#target_img').css('height', ''); } } }; local.changeTargetZoomImage = function(selector,smallVerId,largeVerId) { var tgt = $(selector); tgt.find('.cms-img-zoom-default img').attr('src','/f.ashx?v=' + smallVerId); tgt.find('.cms-img-zoom-large img').attr('src','/f.ashx?v=' + largeVerId); return false; }; /* TemplateFilter 0x10C80FA000000476 */ local.initBookingForm = function(){ if(local.bookingFormIsInit == false){ $('.i001-booking-date a').click(function(){ local.changeDate($(this)); }); if (window.location.hash) { if (window.location.hash.substring(0,3) == '#ST') { var scrollTop = parseInt(window.location.hash.substring(3),10); if (scrollTop > 0) { $(window).scrollTop(scrollTop); } } } local.bookingFormPostLoad(); cms.Dynamic.CompleteCallback = local.bookingFormPostLoad; local.bookingFormIsInit = true; } }; local.bookingFormIsInit = false; local.bookingFormPostLoad = function() { $('.daywrapper').hover(function(){ var tgt = $(this); tgt.addClass('active'); },function(){ var tgt = $(this); tgt.removeClass('active'); }); $('.i001-booking-main td.day, .i001-booking-extra-sel').not('.sold').click(function(e){ var tgt = $(e.target); if (tgt.is('td') == false) { tgt = tgt.closest('td'); } var chk = tgt.find('input.cms-checkbox'); if (chk.length > 0) { chk.click(); } }); }; local.bookUpdatePicker = function(sDate,inst){ if (sDate != '') { var td = new Date(sDate); if (td.getFullYear() > 1900) { var m = td.getMonth() + 1; var d = td.getDate(); var s = td.getFullYear() + '-' + (m < 10 ? '0' : '') + m + '-' + (d < 10 ? '0' : '') + d; // Get State Dump jsDump = 'ST' + $(window).scrollTop(); document.location.href = local._baseBookUrl.replace('_val_',s) + '#' + jsDump; } } } local.changeDate = function(tgt){ var tgt = tgt; var d = tgt.closest('.i001-booking-date').attr('data-date'); var d = $.datepicker.parseDate('dd-mm-yy',d); console.log(d); }; /* TemplateFilter 0x10C80FA000000489 */ local.gallery = {}; local.gallery.initPopup = function(gId,imgArray){ }; local.gallery.openPopup = function(gId,idx,tgt){ var gallery = $(gId); var imgSrc = tgt.attr('href'); local.gallery.createAndLoad(gallery,idx,imgSrc); return false; }; local.gallery.fixResize = function(){ var p = $('.db-dialog-wrap'); var tgt = $('.db-dialog-backing'); if (tgt.length != 0) { tgt.css({width:local.screenWidth,height:local.screenHeight}); var img = p.find('.slideshow-img'); local.gallery.fitToWindow(img,'.db-dialog-image-wrap',img.width(),img.height()); } }; local.gallery.fitToWindow = function(img,parentSelector,w,h){ var p = $(parentSelector); var ar = w/h; var maxH = local.screenHeight * 0.8; var maxW = local.screenWidth * 0.8; var sAr = maxW/maxH; var finalW; var finalH; if(h > maxH || w > maxW){ if(sAr > ar){ finalW = w * maxH / h; finalH = maxH; } else { finalW = maxW; finalH = h * maxW / w; } } else { finalH = h; finalW = w; } img.css('width',finalW); img.css('height', finalH); $('.db-dialog-caption').css({width:finalW}); p.animate({ width: finalW }, 300).animate({ height: finalH }, 300); }; local.gallery.nav = function(gId,direction,tgt){ var gallery = $(gId); var v = tgt.attr('href'); var newsrc = '/f.ashx?v='+v; var img = $(''); $(img).load(function(){ var newimg = $(this); newimg.appendTo('.db-dialog-image-wrap'); local.gallery.fitToWindow(newimg,'.db-dialog-image-wrap',newimg.width(),newimg.height()); $('.slideshow-img').fadeOut(300, function(){ $(this).remove(); }); newimg.removeClass('slideshow-img-temp').fadeIn('fast').addClass('slideshow-img'); }); img.attr('src', newsrc); var tempArr = gallery.data('arr'); var max = gallery.data('arr').length - 1; var idx = 0; if(v == '#'){ if(direction == -1){ idx = 0; } else { idx = max } } else { idx = local.gallery.findArrIdx(parseInt(v),tempArr); //$.inArray(parseInt(v),tempArr); } var txt = tempArr[idx].t; var caption = $('.db-dialog-image-wrap .db-dialog-caption'); caption.text(txt); if (txt == '') { caption.hide(); } else { caption.show(); } var prev = $('.db-dialog-gallery-nav-prev'); var prevLink = prev.find('a'); var next = $('.db-dialog-gallery-nav-next'); var nextLink = next.find('a'); var prevIdx = prevLink.attr('href'); var nextIdx = nextLink.attr('href'); if(prevIdx == '#'){ prevIdx = -1; } else { prevIdx = local.gallery.findArrIdx(parseInt(prevIdx),tempArr); } if(nextIdx == '#'){ nextIdx = max + 1; } else { nextIdx = local.gallery.findArrIdx(parseInt(nextIdx),tempArr); } if(direction == -1){ if(idx == 0){ prevLink.attr('href','#'); prev.hide(); } else { prevLink.attr('href',gallery.data('arr')[prevIdx-1].i); prev.show(); } nextLink.attr('href',gallery.data('arr')[nextIdx-1].i); next.show(); } else { if(idx == max){ nextLink.attr('href','#'); next.hide(); } else { nextLink.attr('href',gallery.data('arr')[nextIdx+1].i); next.show(); } prevLink.attr('href',gallery.data('arr')[prevIdx+1].i); prev.show(); } }; local.gallery.findArrIdx = function(val,arr) { var idx = 0; for (idx=0; idx < arr.length; idx++) { if (arr[idx].i == val) { break; } } return idx; }; local.gallery.createAndLoad = function(gallery,idx,src){ var tgt = $('#db-dialog-wrap'); if (tgt.length == 0) { tgt = $('
').attr('id','db-dialog-wrap').prependTo('body'); } var boxInitialise = $('
').attr('class','db-dialog-place').prependTo(tgt); $('
').attr('class','loading').prependTo(boxInitialise); var boxInner = $('
').attr('class','db-dialog-image-wrap').prependTo(boxInitialise); $('
').prependTo(boxInner); $('
X
').prependTo(boxInner); var backing = $('
').prependTo(tgt); var img = $(''); $(img).load(function(){ var newimg = $(this); newimg.appendTo('.db-dialog-image-wrap'); local.gallery.fitToWindow(newimg,'.db-dialog-image-wrap',newimg.width(),newimg.height()); newimg.fadeIn('slow'); }); img.attr('src', src); var tempArr = gallery.data('arr'); var gId = $(gallery).attr('id'); var src = parseInt(src.replace('/f.ashx?v=','')); var tgt = idx == 0 ? '' : tempArr[idx-1].i; var prev = $('
').prependTo(boxInner); if(idx == 0){ prev.hide(); } tgt = idx == tempArr.length-1 ? '' : tempArr[idx+1].i; var next = $('').prependTo(boxInner); if(idx == tempArr.length-1){ next.hide(); } var txt = tempArr[idx].t; var caption = $('.db-dialog-image-wrap .db-dialog-caption'); caption.text(txt); if (txt == '') { caption.hide(); } else { caption.show(); } local.gallery.activatePortfolioPopup(gallery); }; local.gallery.activatePortfolioPopup = function(gallery) { b = $(window); var gal = $(gallery); $('.db-dialog-backing').click(local.gallery.hidePortfolioPopup).height(b.height()).width(b.width()).css('opacity',0).show().fadeTo(500,0.65); $('.db-dialog-close-wrap').click(local.gallery.hidePortfolioPopup); $('.db-dialog-place').click(local.gallery.hidePortfolioPopup); $(document).keydown(function(e) { // ESCAPE key pressed if (e.keyCode == 27) { local.gallery.hidePortfolioPopup(); } else if(e.keyCode == 37){ local.gallery.nav(gallery,-1,$('.db-dialog-gallery-nav-prev a')); } else if(e.keyCode == 39){ local.gallery.nav(gallery,1,$('.db-dialog-gallery-nav-next a')); } }); $('.db-dialog-image-wrap').click(function(e){ var t = $(e.target); //console.log(t); if(t.is('a') != false || t.is('input') != false || t.is('b') != false || t.is('img') != false){ return false; } else { } }); }; local.gallery.hidePortfolioPopup = function() { $('.db-dialog-backing').fadeOut(250); $('.db-dialog-place').fadeOut(300,function(){$('#db-dialog-wrap').empty();}); }; local.screenWidth = 0; local.screenHeight = 0; /* TemplateFilter 0x10C80FA0000004A2 */ if (!cms.HtmlEdit) { cms.HtmlEdit = function() {}; } if (!window.CmsHtmlEdit) { CmsHtmlEdit = function() {}; } cms.HtmlEdit.ClickStyleItem = function (e) { var editor = $(this).data('editor'); var item = $(this).data('item'); //cms.HtmlEdit.restoreSelection(editor.LastSelection); // Check collapsed var sel = window.getSelection(); if(sel.focusNode) { var extNodeAttr = sel.focusNode.attributes; } else { var extNodeAttr = sel.extentNode.attributes; } if(extNodeAttr != undefined) { console.log("Bad node!"); console.log(sel); return; } if (sel.isCollapsed == true) { var range = document.createRange(); range.selectNode(sel.focusNode); sel.removeAllRanges(); sel.addRange(range); } if (item.element != null || item.cssClass != null) { var ret = false; if (item.cssClass || $.browser.msie || item.cssClass === '') { var sel = window.getSelection(); // console.log(sel); // var tgt = $(sel.anchorNode); var tgt = $(sel.focusNode); while (tgt.length > 0) { if (item.cssClass != null && tgt.hasClass('tool-htmledit-editor') == false) { tgt.removeClass(); } if (item.element == null && item.cssClass != null && tgt.hasClass(item.cssClass)) { break; } var d; try { d = tgt.css('display');} catch(exx) { d = 'inline'; } if (d == 'list-item' || d == 'table-cell' || tgt.hasClass('tool-htmledit-editor')) { var nTgt = $('<' + (item.element || (tgt.hasClass('tool-htmledit-editor') ? 'p' : 'span')) + '/>'); nTgt.html(tgt.html()); tgt.empty(); nTgt.appendTo(tgt); tgt = nTgt; break; } else if (d == 'block') { break; } tgt = tgt.parent(); } if (tgt.length > 0) { if (item.element && tgt.is(item.element) == false) { var nTgt = $('<' + item.element + '/>').insertBefore(tgt); nTgt.html(tgt.html()); tgt.remove(); tgt = nTgt; } if (item.cssClass && tgt.hasClass(item.cssClass)) { tgt.removeClass(item.cssClass); } else if (item.cssClass) { tgt.removeClass().addClass(item.cssClass); } } } else { cms.HtmlEdit.__EnterDesignMode(this); // CleanupHTML(editor.editor); ret = document.execCommand('formatBlock', false, item.element); cms.HtmlEdit.__ExitDesignMode(this); } e.preventDefault(); e.stopPropagation(); editor.UpdateToolbar(window.getSelection()); //cms.HtmlEdit.restoreSelection(editor.LastSelection); } else { } return ret; }; cms.HtmlEdit.DropHandling = function(e) { e = e || window.event; e.preventDefault(); if(e.originalEvent.dataTransfer) { var files = e.originalEvent.dataTransfer.files; } for (var i = 0, f; f = files[i]; i++) { // We need to represent the image as a file, var thisFile = files[i]; var reader = new FileReader(); var editObj = $(this).closest('.tool-htmledit-wrap').data('editor'); reader.onload = function (event) { editObj.InsertElement($('').attr('src', event.target.result)); }; // data url! reader.readAsDataURL(thisFile); } }; cms.HtmlEdit.Create = function (strId, bHasMerge) { var f = new CmsHtmlEdit(strId); var ta = $('#' + strId); f.Width = ta.width(); //450; f.Height = ta.height(); //550; f.ReplaceTextarea(); ta[0].fck = f; $(".tool-htmledit-wrap").bind({ drop: cms.HtmlEdit.DropHandling }); }; CmsHtmlEdit.prototype.ReplaceTextarea = function () { this.wrap = $('
').addClass('tool-htmledit-wrap').insertBefore(this.targetElement); this.wrap.data('editor', this); this.targetElement.remove().appendTo(this.wrap); this.CreateToolbar(); this.editor = $('
').appendTo(this.wrap); this.editor .attr('contenteditable', 'true') .addClass('tool-htmledit-editor') .bind('paste', this.HandlePaste) //.css('min-height',(this.Height - 24) + 'px'); .height(this.Height - 24); this.UpdateHtml(); var editorWidth = this.editor.width(); this.targetElement.width(editorWidth); this.editor.width(editorWidth); var w = this.wrap; this.wrap.closest('form').bind('submit', function () { cms.HtmlEdit.OnSubmit(w); }); if ($.on) { this.editor.on('click', 'img', cms.HtmlEdit.ClickImage); } else { if (cms.HtmlEdit.FallbackImageClickEnabled == false) { cms.HtmlEdit.FallbackImageClickEnabled = true; $('.tool-htmledit-editor img').live('click', cms.HtmlEdit.ClickImage); } } this.editor.bind('mouseup', cms.HtmlEdit.UpdateSelection); this.editor.bind('keyup', cms.HtmlEdit.__KeyUp); this.editor.bind('keydown', cms.HtmlEdit.__KeyDown); this.editor.bind('focus', cms.HtmlEdit.UpdateSelection); $('body').mouseup(cms.HtmlEdit.UpdateSelectionWin); this.editor.bind('mousedown', cms.HtmlEdit.mouseDownSaveEditorInstance); var wx = this; setTimeout(function () { wx.editor.css('max-width', wx.wrap.parent().width() - 32); }, 125); //.blur(function () { document.designMode = 'off'; }).focus(function () { document.designMode = 'on'; }) }; cms.HtmlEdit.mouseDownSaveEditorInstance = function (e) { var editor = $(this); cms.HtmlEdit.currentlySelectedEditor = editor; }; cms.HtmlEdit.saveSelection = function() { if (window.getSelection) { sel = window.getSelection(); if (sel.getRangeAt && sel.rangeCount) { var ranges = []; for (var i = 0, len = sel.rangeCount; i < len; ++i) { ranges.push(sel.getRangeAt(i)); } return ranges; } } else if (document.selection && document.selection.createRange) { return document.selection.createRange(); } return null; }; cms.HtmlEdit.UpdateSelectionWin = function (e) { var currentEd = cms.HtmlEdit.currentlySelectedEditor; if(currentEd != undefined) { var e = $(currentEd).closest('.tool-htmledit-wrap').data('editor'); }else { var e = $('.tool-htmledit-wrap').data('editor'); } if (e) { var sel = window.getSelection(); var selectionInfo = cms.HtmlEdit.saveSelection(); if (selectionInfo != null) { if (selectionInfo.length > 0) { e.LastSelection = selectionInfo; } } e.UpdateToolbar(sel); } }; cms.HtmlEdit.UpdateSelection = function (e) { var e = $(this).closest('.tool-htmledit-wrap').data('editor'); if (e) { var sel = window.getSelection(); $('.tool-htmledit-img').removeClass('selected'); var isImg = false; if (e.selectedImage) { if (sel.containsNode && sel.containsNode(e.selectedImage[0],false)) { e.selectedImage.addClass('selected'); isImg = true; } else { e.selectedImage = null; } } if (isImg) { e.baseToolbar.removeClass('active'); e.imageToolbar.addClass('active'); } else { e.baseToolbar.addClass('active'); e.imageToolbar.removeClass('active'); } var selectionInfo = cms.HtmlEdit.saveSelection(); if (selectionInfo != null) { if (selectionInfo.length > 0) { e.LastSelection = selectionInfo; } } e.UpdateToolbar(sel); } }; cms.HtmlEdit.__KeyDown = function (e) { var keycode = e.keyCode; var printableChar = (keycode > 47 && keycode < 58) || // number keys keycode == 32 || keycode == 13 || // spacebar & return key(s) (if you want to allow carriage returns) (keycode > 64 && keycode < 91) || // letter keys (keycode > 95 && keycode < 112) || // numpad keys (keycode > 185 && keycode < 193) || // ;=,-./` (in order) (keycode > 218 && keycode < 223); // [\]' (in order) cms.HtmlEdit.UpdateSelection(e); var range = window.getSelection().getRangeAt(0); //console.log(range.startContainer.parentNode); var isButton = $(range.startContainer.parentNode).hasClass("i001-css-button"); if(printableChar && isButton) { // console.log("In button!"); return false; // In button - don't edit! } if (keycode == 8) { var editor = $(this).closest('.tool-htmledit-wrap').data('editor'); if (editor.selectedImage && editor.selectedImage.length > 0) { editor.selectedImage.remove(); editor.selectedImage = null; e.stopPropagation(); e.preventDefault(); } } }; cms.HtmlEdit.__KeyUp = function (e) { var keycode = e.keyCode; var printableChar = (keycode > 47 && keycode < 58) || // number keys keycode == 32 || keycode == 13 || // spacebar & return key(s) (if you want to allow carriage returns) (keycode > 64 && keycode < 91) || // letter keys (keycode > 95 && keycode < 112) || // numpad keys (keycode > 185 && keycode < 193) || // ;=,-./` (in order) (keycode > 218 && keycode < 223); // [\]' (in order) cms.HtmlEdit.UpdateSelection(e); var range = window.getSelection().getRangeAt(0); //console.log(range.startContainer.parentNode); var isButton = $(range.startContainer.parentNode).hasClass("i001-css-button"); if(printableChar && isButton) { // console.log("In button!"); return false; // In button - don't edit! } if (keycode == 46 || keycode == 8) { var editor = $(this).closest('.tool-htmledit-wrap').data('editor'); if (editor.selectedImage && editor.selectedImage.length > 0) { editor.selectedImage.remove(); editor.selectedImage = null; e.stopPropagation(); e.preventDefault(); } } }; CmsHtmlEdit.prototype.CreateButtonLink = function (sUri, noUndo, linkText) { var gsp = this.GetSelectionParent('.tool-htmledit-wrap'); var ret = false; if (gsp != null) { if (gsp.length > 0) { cms.HtmlEdit.__EnterDesignMode(this); ret = document.execCommand('insertHTML',false,"
"+linkText+"
"); cms.HtmlEdit.__ExitDesignMode(this); } } return ret; }; CmsHtmlEdit.prototype.getSelectionText = function() { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange().text; } return text; }; /* CLEAR IMAGE LINK */ cms.HtmlEdit.LinkParserRegex = /^\{\{([0-9]+):(-?[0-9]+)(;.+)?\}\}$/; cms.HtmlEdit.ClearImageLink = function () { var editor = $(this).closest('.tool-htmledit-wrap').data('editor'); if (editor.selectedImage && editor.selectedImage.length > 0) { var blah = $(editor.selectedImage).parent().get(0).tagName; // test that parent is a link FIRST if($(editor.selectedImage).parent().get(0).tagName.toLowerCase()=='a') { editor.selectedImage.unwrap(); } baseUrl = editor.selectedImage.attr('data-link', ''); /* UNFINISHED */ } }; cms.HtmlEdit.OpenLinkPicker = function () { //var oLink = FCK.Selection.MoveToAncestorNode('A'); var editor = $(this).closest('.tool-htmledit-wrap').data('editor'); var oLink, baseUrl; if (editor.selectedImage && editor.selectedImage.length > 0) { oLink = editor.selectedImage[0]; baseUrl = editor.selectedImage.attr('data-link'); } else { oLink = editor.GetSelectionParent('a'); baseUrl = ''; if (oLink && oLink.length > 0) { var sel = window.getSelection(); sel.removeAllRanges(); var range = document.createRange(); range.selectNode(oLink[0]); sel.addRange(range); baseUrl = oLink.attr('href'); } } var oEditor = window; // Open link picker popup and configure 'store' action. var linkDialog = $('
').addClass('cms-picker-loader').attr('title', 'Choose or enter a link destination'); var dConfig = { bgiframe: true, modal: true, width: 700, height: 500, dialogClass: 'cms-picker-loader' }; $('body').unbind('mouseup'); $(this).closest('.tool-htmledit-wrap').unbind('mousedown'); linkDialog.dialog(dConfig); var sUrl = cms.RootPath + '/p.ashx?t=268570528&d=2&p.lr=' + cms.LinkRenderId; window.curDialogBaseUrl = sUrl; if (baseUrl != null && baseUrl != '') { // Interpret supplied URL var isObject = 0; var x = cms.HtmlEdit.LinkParserRegex.exec(baseUrl); if (x != null && x.length > 0) { isObject = 1; sUrl += '&lv.tgt_type=' + parseInt(x[1]); sUrl += '&lv.tgt_id=' + parseInt(x[2]); sUrl += '&lv.link_type=' + (x[3] != null && x[3].match(/attach/i) ? 1 : 0); } else { sUrl += '&lv.raw=' + encodeURIComponent(baseUrl); } sUrl += '&lv.internal=' + isObject; } linkDialog.load(sUrl, null, function () { linkDialog.closest('.ui-dialog').removeClass('cms-picker-loader') }); window.storeCmsLink = function (sUri, sContent) { if (editor.selectedImage && editor.selectedImage.length > 0) { editor.selectedImage.attr('data-link', sUri); /* ********************************** */ /* This is where the editor needs to create a link */ console.log(editor.selectedImage); sInnerHtml = sContent; if($(editor.selectedImage).parent().get(0).tagName.toLowerCase()!='a') { $(editor.selectedImage).wrap(''); } else { $(editor.selectedImage).unwrap(); $(editor.selectedImage).wrap(''); } } else { // If no link is selected, create a new one (it may result in more than one link creation - #220). //if ($.browser.msie) //sRange.select(); //else cms.HtmlEdit.restoreSelection(editor.LastSelection); var selX = window.getSelection(); if (selX == null || selX.isCollapsed == true) { var aLinks = oLink == null ? [] : [$(oLink)]; // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26) var aHasSelection = (aLinks.length > 0); if (!aHasSelection) { // Is internal link? var x = cms.HtmlEdit.LinkParserRegex.exec(sUri); if (x != null && x.length > 0 && sContent == null) { var ajaxUrl = cms.RootPath + '/wf.ashx?f=obj.title&t=' + parseInt(x[1]) + '&d=' + parseInt(x[2]); $.get(ajaxUrl, function (data, textStatus) { window.storeCmsLink(sUri, data); }); return; } else if (sContent == null) { sContent = sUri; } sInnerHtml = sContent; // Create a new (empty) anchor. oLink = $('').attr('href', sUri).html(sInnerHtml); aLinks = [oLink]; editor.InsertElement(oLink); } for (var i = 0; i < aLinks.length; i++) { oLink = aLinks[i]; if (aHasSelection) { sInnerHtml = oLink.html(); // Save the innerHTML (IE changes it if it is like an URL). } oLink.attr('href', sUri); //SetAttribute(oLink, '_fcksavedurl', sUri); try { oLink.html(sInnerHtml); } // Set (or restore) the innerHTML catch (e) { } } } else { editor.CreateLink(sUri, true); } } // Select the (first) link. //oEditor.FCKSelection.SelectNode(aLinks[0]); linkDialog.dialog('close'); linkDialog.remove(); $('body').mouseup(cms.HtmlEdit.UpdateSelectionWin); $(this).closest('.tool-htmledit-wrap').bind('mousedown', cms.HtmlEdit.mouseDownSaveEditorInstance); window.storeCmsLink = null; window.curDialogBaseUrl = null; }; }; cms.HtmlEdit.dragButtonMouseDown = function (e) { cms.HtmlEdit.dragButtonMode = true; cms.HtmlEdit.dragButtonObject = $(this); }; cms.HtmlEdit.dragButtonMouseUp = function (e) { cms.HtmlEdit.dragButtonMode = false; }; cms.HtmlEdit.dragButtonMouseMove = function (e) { if(cms.HtmlEdit.dragButtonMode==true) { $(cms.HtmlEdit.dragButtonObject).offset().x = e.pageX; $(cms.HtmlEdit.dragButtonObject).offset().y = e.pageY; } }; cms.HtmlEdit.CreateButton = function () { var editor = $(this).closest('.tool-htmledit-wrap').data('editor'); var oLink, baseUrl; oLink = editor.GetSelectionParent('a'); baseUrl = ''; if (oLink && oLink.length > 0) { var sel = window.getSelection(); sel.removeAllRanges(); var range = document.createRange(); range.selectNode(oLink[0]); sel.addRange(range); baseUrl = oLink.attr('href'); } var oEditor = window; // Open link picker popup and configure 'store' action. var linkDialog = $('
').addClass('cms-picker-loader').attr('title', 'Choose or enter a link destination'); var dConfig = { bgiframe: true, modal: true, width: 700, height: 500, dialogClass: 'cms-picker-loader' }; $('body').unbind('mouseup'); $(this).closest('.tool-htmledit-wrap').unbind('mousedown'); linkDialog.dialog(dConfig); var sUrl = cms.RootPath + '/p.ashx?t=268570528&d=2&p.lr=' + cms.LinkRenderId; window.curDialogBaseUrl = sUrl; if (baseUrl != null && baseUrl != '') { // Interpret supplied URL var isObject = 0; var x = cms.HtmlEdit.LinkParserRegex.exec(baseUrl); if (x != null && x.length > 0) { isObject = 1; sUrl += '&lv.tgt_type=' + parseInt(x[1]); sUrl += '&lv.tgt_id=' + parseInt(x[2]); sUrl += '&lv.link_type=' + (x[3] != null && x[3].match(/attach/i) ? 1 : 0); } else { sUrl += '&lv.raw=' + encodeURIComponent(baseUrl); } sUrl += '&lv.internal=' + isObject; } linkDialog.load(sUrl, null, function () { linkDialog.closest('.ui-dialog').removeClass('cms-picker-loader') }); window.storeCmsLink = function (sUri, sContent) { if (editor.selectedImage && editor.selectedImage.length > 0) { editor.selectedImage.attr('data-link', sUri); } else { // If no link is selected, create a new one (it may result in more than one link creation - #220). //if ($.browser.msie) //sRange.select(); //else cms.HtmlEdit.restoreSelection(editor.LastSelection); var selX = window.getSelection(); if (selX == null || selX.isCollapsed == true) { // here var aLinks = oLink == null ? [] : [$(oLink)]; // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26) var aHasSelection = (aLinks.length > 0); if (!aHasSelection) { // Is internal link? var x = cms.HtmlEdit.LinkParserRegex.exec(sUri); if (x != null && x.length > 0 && sContent == null) { var ajaxUrl = cms.RootPath + '/wf.ashx?f=obj.title&t=' + parseInt(x[1]) + '&d=' + parseInt(x[2]); $.get(ajaxUrl, function (data, textStatus) { window.storeCmsLink(sUri, data); }); return; } else if (sContent == null) { sContent = sUri; } sInnerHtml = sContent; // Create a new (empty) anchor. oLink = $('').attr('href', sUri).html(sInnerHtml).after('
'); $(oLink).addClass('i001-css-button new_v01 tool-htmledit-img'); $(oLink).before('
'); aLinks = [oLink]; editor.InsertElement(oLink); /* // enable drag and drop for image $(".tool-htmledit-editor").unbind('mousedown'); $(".tool-htmledit-editor").unbind('mouseup'); $(".tool-htmledit-editor").mousedown(cms.HtmlEdit.dragButtonMouseDown); $(".tool-htmledit-editor").mouseup(cms.HtmlEdit.dragButtonMouseUp); $(".tool-htmledit-editor").mousemove(cms.HtmlEdit.dragButtonMouseMove); */ } for (var i = 0; i < aLinks.length; i++) { oLink = aLinks[i]; if (aHasSelection) sInnerHtml = oLink.html(); // Save the innerHTML (IE changes it if it is like an URL). oLink.attr('href', sUri); //SetAttribute(oLink, '_fcksavedurl', sUri); try { oLink.html(sInnerHtml); } // Set (or restore) the innerHTML catch (e) { } } } else { selectionText = editor.getSelectionText(); editor.CreateButtonLink(sUri, true, selectionText); } } // Select the (first) link. //oEditor.FCKSelection.SelectNode(aLinks[0]); linkDialog.dialog('close'); linkDialog.remove(); $('body').mouseup(cms.HtmlEdit.UpdateSelectionWin); $(this).closest('.tool-htmledit-wrap').bind('mousedown', cms.HtmlEdit.mouseDownSaveEditorInstance); window.storeCmsLink = null; window.curDialogBaseUrl = null; }; }; cms.HtmlEdit.ClickToolbarItem = function (e) { var editor = $(this).data('editor'); var item = $(this).data('item'); //cms.HtmlEdit.restoreSelection(editor.LastSelection); // Check collapsed var sel = window.getSelection(); if (sel.isCollapsed == true) { var range = document.createRange(); range.selectNode(sel.focusNode); sel.removeAllRanges(); sel.addRange(range); } var ret = false; var proceed = true; if (item.func == 'insertunorderedlist') { var parentUl = $(sel.focusNode).closest('.tool-htmledit-editor ul'); var parentOl = $(sel.focusNode).closest('.tool-htmledit-editor ol'); if (parentUl.length > 0) { // Remove List var newContainer = $('
'); parentUl.children('li').each(function () { $(this).contents().appendTo($('

').appendTo(newContainer)); }); newContainer.insertBefore(parentUl); parentUl.remove(); proceed = false; } else if (parentOl.length > 0) { // Move list var newList = $('