芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/tvc.mgaplay.com.br/web/dist/core/xibo-calendar.js
var calendar,mymap,mymapmarker,events=[];$(document).ready((function(){var e=null;if($("body").on("click",(function(e){$('[data-toggle="popover"]').each((function(){$(this).is(e.target)||0!==$(this).has(e.target).length||0!==$(".popover").has(e.target).length||$(this).popover("hide")}))})),$(".btn-group button[data-calendar-nav]").each((function(){var e=$(this);e.click((function(){calendar.navigate(e.data("calendar-nav"))}))})),$(".btn-group button[data-calendar-view]").each((function(){var e=$(this);e.click((function(){calendar.view(e.data("calendar-view"))}))})),$("#Calendar").length>0){var a=$("#CalendarContainer").data(),t={};"Jalali"==calendarType?t={autoClose:!0,altField:"#dateInputLink",altFieldFormatter:function(e){var a=moment.unix(e/1e3);return a.set("hour",0),a.set("minute",0),a.set("second",0),a.format(jsDateFormat)},onSelect:function(){},onHide:function(){$("#dateInput").trigger("change"),$("#dateInputLink").trigger("change")}}:"Gregorian"==calendarType&&(t={wrap:!0,altFormat:jsDateOnlyFormat}),initDatePicker($("#dateInput"),systemDateFormat,jsDateOnlyFormat,t,(function(){null!=calendar&&calendar.navigate("date",moment($("#dateInput input[data-input]").val()))}),!1);var n=$(".cal-event-location-map #geoFilterAgendaMap");$("#getLocation").off().click((function(){var e=$(this);e.prop("disabled",!0),navigator.geolocation.getCurrentPosition((function(a){$("#geoLatitude").val(a.coords.latitude).change(),$("#geoLongitude").val(a.coords.longitude).change(),e.prop("disabled",!1),generateFilterGeoMap()}),(function(a){console.warn("ERROR("+a.code+"): "+a.message),e.prop("disabled",!1)}),{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})})),$("#toggleMap").off().click((function(){n.toggleClass("d-none"),n.hasClass("d-none")||generateFilterGeoMap()})),$("#clearLocation").off().click((function(){$("#geoLatitude").val("").change(),$("#geoLongitude").val("").change(),n.hasClass("d-none")||generateFilterGeoMap()})),$("#geoLatitude, #geoLongitude").off().change(_.debounce((function(){calendar.view()}),400));var o={time_start:"00:00",time_end:"00:00",events_source:function(){return events},view:"month",tmpl_path:function(e){return"calendar-template-"+e},tmpl_cache:!0,onBeforeEventsLoad:function(a){var t=$("#CalendarContainer").data(),n=$("#showAll").is(":checked");if($("#DisplayList").prop("disabled",n),"agenda"!==this.options.view){$(".cal-event-agenda-filter").hide();var o=$("#DisplayList").serialize(),r=$("#campaignId").serialize(),s=t.eventSource;s+="?"+r,n?s+="&displayGroupIds[]=-1":""!==o&&(s+="&"+o),events=[];var l={from:moment(this.options.position.start.getTime()).format(systemDateFormat),to:moment(this.options.position.end.getTime()).format(systemDateFormat)};e&&e.abort(),$("#calendar-progress").addClass("show"),e=$.getJSON(s,l).done((function(e){events=e.result,null!=a&&a(),calendar._render(),$('[data-toggle="popover"]').popover({trigger:"manual",html:!0,placement:"bottom",content:function(){return $(this).html()}}).on("mouseenter",(function(){var e=this;$('[data-toggle="popover"]').not(this).popover("hide"),$(this).popover("show"),$(".popover").off("mouseleave").on("mouseleave",(function(){$(e).popover("hide")}))})).on("shown.bs.popover",(function(){var e=$(this),a=e.attr("aria-describedby");$("#"+a+" a").click((function(a){a.preventDefault(),XiboFormRender($(this)),e.popover("hide")}))})),$("#calendar-progress").removeClass("show")})).fail((function(e){$("#calendar-progress").removeClass("show"),null!=a&&a(),calendar._render(),"abort"!=e.statusText&&(toastr.error(translations.failure),console.error(e))}))}else{$(".cal-event-agenda-filter").show();for(var i=$("#timePicker"),d=moment().tz?moment().tz(timezone):moment(),c=[],p=[],u=[],m=0;m<=1440;m+=120){var v=1440===m?1439:m;c.push(v),p.push(d.clone().startOf("day").add(v,"minutes").format(jsTimeFormat)),u.push(m/1440*100)}i.slider({value:60*d.hour()+d.minute(),tooltip:"always",ticks:c,ticks_labels:p,ticks_positions:u,formatter:function(e){return moment().startOf("day").minute(e).format(jsTimeFormat)}}).off("slideStop").on("slideStop",(function(e){calendar.view()})),$(".time-picker-step-btn").off().on("click",(function(){i.slider("setValue",i.slider("getValue")+$(this).data("step")),calendar.view()}));var g=$(".cal-context").data().selectedTab,h=[],f=!1;n||($("#DisplayList").prop("disabled",!1),$("#DisplayList option").each((function(){var e=$(this);if(-1==e.val()&&e.is(":selected"))return f=!0,!0;(e.is(":selected")||f)&&(h.push({id:e.val(),name:e.html(),isDisplaySpecific:e.attr("type")}),void 0===g&&(g=e.val()))}))),h.sort((function(e,a){var t=e.name.toLowerCase(),n=a.name.toLowerCase();return t
n?1:0})),s=t.agendaLink.replace(":id",g);var y=moment(this.options.position.start.getTime()/1e3,"X"),b=$("#timePickerSlider").length?$("#timePicker").slider("getValue"):0,L=moment(60*b,"X");l={date:moment(y+L).format(systemDateFormat)},jQuery.isEmptyObject(events.results)&&((events=[]).results={}),events.displayGroupList=h,events.selectedDisplayGroup=g,events.errorMessage="",1==calendar.options.clearCache&&(events.results={}),e&&e.abort(),n?(events.errorMessage="all_displays_selected",null!=a&&a(),calendar._render()):null==$("#DisplayList").val()||Array.isArray($("#DisplayList").val())&&0==$("#DisplayList").val().length?(events.errorMessage="display_not_selected",null!=a&&a(),calendar._render()):jQuery.isEmptyObject(events.results[g])||events.results[g].request_date!=l.date||events.results[g].geoLatitude!=$("#geoLatitude").val()||events.results[g].geoLongitude!=$("#geoLongitude").val()?($("#calendar-progress").addClass("show"),e=$.getJSON(s,l).done((function(e){var t=!0;!jQuery.isEmptyObject(e.data)&&null!=e.data.events&&e.data.events.length>0&&(events.results[String(g)]=e.data,events.results[String(g)].request_date=l.date,t=!1,null!=$("#geoLatitude").val()&&""!=$("#geoLatitude").val()&&null!=$("#geoLongitude").val()&&""!=$("#geoLongitude").val()&&(events.results[String(g)].geoLatitude=$("#geoLatitude").val(),events.results[String(g)].geoLongitude=$("#geoLongitude").val(),events.results[String(g)].events=filterEventsByLocation(events.results[String(g)].events),t=e.data.events.length<=0)),t&&(events.results[String(g)]={},events.errorMessage="no_events"),null!=a&&a(),calendar._render(),$("#calendar-progress").removeClass("show")})).fail((function(e){null!=a&&a(),"abort"!=e.statusText&&(events.errorMessage="request_failed"),calendar._render(),$("#calendar-progress").removeClass("show")}))):(null!=a&&a(),calendar._render())}},onAfterEventsLoad:function(e){"agenda"==this.options.view&&$(".agenda-panel").ready((function(){$(".agenda-table-layouts").dataTable({searching:!1})}))},onAfterViewLoad:function(e){null!=this.options.position.start&&""!=this.options.position.start&&updateDatePicker($("#dateInput"),moment.unix(this.options.position.start.getTime()/1e3).format(jsDateOnlyFormat),jsDateOnlyFormat),"function"==typeof this.getTitle&&$("h1.page-header").text(this.getTitle()),$(".btn-group button").removeClass("active"),$('button[data-calendar-view="'+e+'"]').addClass("active")},language:calendarLanguage};o.type=a.calendarType,calendar=$("#Calendar").calendar(o),$(".cal-context").on("click",'a[data-toggle="tab"]',(function(e){$(".cal-context").data().selectedTab=$(this).data("id"),calendar.view()})),$(".cal-context").on("click","tbody tr",(function(e){var a=$(this),t=a.hasClass("selected");$(".cal-event-breadcrumb-trail").hide(),$(".cal-context tbody tr").removeClass("selected"),$(".cal-context tbody tr").removeClass("selected-linked"),t||("layouts"==a.closest("table").data("type")&&($(".cal-event-breadcrumb-trail").show(),$(".cal-event-breadcrumb-trail #content").html(""),$(".cal-event-breadcrumb-trail #content").append(calendar._breadcrumbTrail(a.data("elemId"),events,a.data("eventId"))),createMiniLayoutPreview(layoutPreviewUrl.replace(":id",a.data("elemId"))),XiboInitialise("")),agendaSelectLinkedElements(a.closest("table").data("type"),a.data("elemId"),events,a.data("eventId")))}))}}));var setupScheduleForm=function(e){console.log("Setup schedule form");var a=$("#isGeoAware"),t=a.is(":checked");t&&$(".nav-tabs a").on("shown.bs.tab",(function(e){"Geo Location"===$(e.target).text()&&($("#geoScheduleMap").removeClass("d-none"),generateGeoMap())})),a.change((function(){(t=$("#isGeoAware").is(":checked"))?($("#geoScheduleMap").removeClass("d-none"),generateGeoMap()):$("#geoScheduleMap").addClass("d-none")}));var n=$("#shareOfVoice"),o=$("#shareOfVoicePercentage");n.on("change paste keyup",(function(){r(n.val())})),o.on("change paste keyup",(function(){var e,a=o.val();e=Math.round(3600*a/100),n.val(e)}));var r=function(e){var a;a=100*e/3600,o.val(a.toFixed(2))};r(n.val()),setupSelectForSchedule(e),$('select[name="recurrenceRepeatsOn[]"]',e).select2({width:"100%"}),processScheduleFormElements($("#recurrenceType",e)),processScheduleFormElements($("#eventTypeId",e)),processScheduleFormElements($("#campaignId",e)),processScheduleFormElements($("#actionType",e)),$("#recurrenceType, #eventTypeId, #dayPartId, #campaignId, #actionType",e).on("change",(function(){processScheduleFormElements($(this))})),$('a[data-toggle="tab"]',e).on("shown.bs.tab",(function(a){var t,n=$(e).find("input[name=fromDt]"),o=null===n.val()||""===n.val()?moment():moment(n.val()),r=$(e).find("select[name=recurrenceMonthlyRepeatsOn]"),s=$('
'+r.data("transDay").replace("[DAY]",o.format("Do"))+"
"),l=$('
'+r.data("transWeekday").replace("[POSITION]",(t=Math.ceil(o.date()/7),t+(["st","nd","rd"][((t+90)%100-10)%10-1]||"th"))).replace("[WEEKDAY]",o.format("dddd"))+"
");r.find("option").remove().end().append(s).append(l).val(r.data("value"))})),$("#scheduleAddForm, #scheduleEditForm, #scheduleDeleteForm, #scheduleRecurrenceDeleteForm").submit((function(e){e.preventDefault();var a=$(this);$.ajax({type:$(this).attr("method"),url:$(this).attr("action"),data:$(this).serialize(),cache:!1,dataType:"json",success:function(e,t,n){XiboSubmitResponse(e,a),e.success&&(calendar.options.clearCache=!0,calendar.view())}})})),$(e).find('[data-toggle="popover"]').popover();var s=$(e).find("#scheduleEditForm");if(s.length>0){var l=$("
").addClass("btn btn-info").attr("id","scheduleDuplateButton").html(translations.duplicate).on("click",(function(){duplicateScheduledEvent()}));$(e).find(".modal-footer").prepend(l),s.find("#instanceStartDate").html(moment(s.data().eventStart,"X").format(jsDateFormat)),s.find("#instanceEndDate").html(moment(s.data().eventEnd,"X").format(jsDateFormat)),l=$("
").addClass("btn btn-primary").attr("id","scheduleRecurringDeleteButton").html(translations.deleteRecurring).on("click",(function(){deleteRecurringScheduledEvent(s.data("eventId"),s.data("eventStart"),s.data("eventEnd"))})),$(e).find("#recurringInfo").prepend(l)}configReminderFields($(e))},deleteRecurringScheduledEvent=function(e,a,t){var n=scheduleRecurrenceDeleteUrl.replace(":id",e);XiboSwapDialog(n,{eventStart:a,eventEnd:t})},beforeSubmitScheduleForm=function(e){e.find('[name="reminder_isEmail[]"]').each((function(e){$(this).parent().find('[type="hidden"]').val($(this).is(":checked")?"1":"0")})),$('[data-toggle="popover"]').popover(),e.submit()},configReminderFields=function(e){var a=e.find("#reminderFields");if(0!=a.length){var t=Handlebars.compile($("#reminderEventTemplate").html());if(0==a.data().reminders.length)a.append(t({title:0,buttonGlyph:"fa-plus"}));else{var n=0;$.each(a.data().reminders,(function(e,o){n++;var r={scheduleReminderId:o.scheduleReminderId,value:o.value,type:o.type,option:o.option,isEmail:o.isEmail,title:n,buttonGlyph:1==n?"fa-plus":"fa-minus"};a.append(t(r))}))}a.on("click","button",(function(e){if(e.preventDefault(),$(this).find("i").hasClass("fa-plus")){var n={title:a.find(".form-group").length+1,buttonGlyph:"fa-minus"};a.append(t(n))}else $(this).closest(".form-group").remove()}))}},processScheduleFormElements=function(e){var a=e.val();switch(e.attr("id")){case"recurrenceType":var t=""==a?"none":"",n="Week"!=a?"none":"",o="Month"!==a?"none":"";$(".repeat-control-group").css("display",t),$(".repeat-weekly-control-group").css("display",n),$(".repeat-monthly-control-group").css("display",o),$("#recurrenceDetail").parent().find(".input-group-addon").html(e.val());break;case"eventTypeId":console.log("Process: eventTypeId, val = "+a);var r=2==a||6==a?"none":"",s=2==a?"none":"",l="",i=2==a?"none":"",d=2==a?"":"none",c=1==a?"":"none",p=4==a?"":"none",u=6==a?"":"none",m=2==a||6==a?"none":"";if($(".layout-control").css("display",r),$(".endtime-control").css("display",s),$(".starttime-control").css("display",l),$(".day-part-control").css("display",i),$(".command-control").css("display",d),$(".sync-schedule-control").css("display",c),$(".interrupt-control").css("display",p),$(".action-control").css("display",u),$(".max-plays-control").css("display",m),6===a&&$(".displayOrder-control").css("display","none"),2==a){var v=$("#dayPartId"),g=0;v.find("option").each((function(e,a){1===$(a).data("isCustom")&&(g=$(a).val())})),console.log("Setting dayPartId to custom: "+g),v.val(g),(k=$(".starttime-control")).find("input[name=fromDt_Link2]").show(),k.find(".help-block").html(k.closest("form").data().daypartMessage),$("li.repeats").css("display","block"),$("li.reminders").css("display","block")}processScheduleFormElements($("#dayPartId"));var h=e.closest("form").find("#campaignId"),f=$(".layout-control"),y=-1;"1"===a||"3"===a||"4"===a?(y=1,f.children("label").text(h.data("transLayout")),f.children("div").children("small.form-text.text-muted").text(h.data("transLayoutHelpText"))):(y=0,f.children("label").text(h.data("transCampaign")),f.children("div").children("small.form-text.text-muted").text(h.data("transCampaignHelpText"))),h.data("searchIsLayoutSpecific",y);break;case"dayPartId":if(console.log("Process: dayPartId, val = "+a+", visibility = "+e.is(":visible")),!e.is(":visible"))return;var b=e.find("option[value="+a+"]").data(),L=(s=0===b.isCustom?"none":"",l=1===b.isAlways?"none":"",1===b.isAlways?"none":""),w=1===b.isAlways?"none":"",k=$(".starttime-control"),S=$(".endtime-control"),D=$("li.repeats"),F=$("li.reminders");k.css("display",l),S.css("display",s),D.css("display",L),F.css("display",w),0===b.isAlways&&0===b.isCustom?(k.find("input[name=fromDt_Link2]").hide(),k.find(".help-block").html(k.closest("form").data().notDaypartMessage)):(k.find("input[name=fromDt_Link2]").show(),k.find(".help-block").html(k.closest("form").data().daypartMessage));break;case"campaignId":console.log("Process: campaignId, val = "+a+", visibility = "+e.is(":visible"));var C=$("#previewButton");null===a||""===a||0===a?C.closest(".preview-button-container").hide():(C.closest(".preview-button-container").show(),C.attr("href",C.data().url.replace(":id",a)));break;case"actionType":console.log("Action type changed");var I="navLayout"==a&&e.is(":visible")?"":"none";d="command"==a?"":"none",$(".layout-code-control").css("display",I),$(".command-control").css("display",d)}},duplicateScheduledEvent=function(){var e=$("#scheduleEditForm");e.attr("action",e.data().addUrl).attr("method","post"),$("#scheduleDuplateButton").remove(),toastr.info(e.data().duplicatedMessage)},setupScheduleNowForm=function(e){setupSelectForSchedule(e),processScheduleFormElements($("#eventTypeId",e)),dateFormat.indexOf("s")<=-1&&$(e).find(".schedule-now-seconds-field").hide(),$(e).find("#always").on("change",(function(){var a=$(e).find("#always").is(":checked")?$(e).find("#alwaysDayPartId").val():$(e).find("#customDayPartId").val();$(e).find("#dayPartId").val(a),$(e).find(".duration-part").toggle(),dateFormat.indexOf("s")<=-1&&$(e).find(".schedule-now-seconds-field").hide()}));var a=_.debounce((function(){scheduleNowFormEvaluateDates(e)}),500);$(e).find("#hours").on("keyup",a),$(e).find("#minutes").on("keyup",a),$(e).find("#seconds").on("keyup",a)},scheduleNowFormEvaluateDates=function(e){if(!$(e).find("#always").is(":checked")){var a=$(e).find("#hours").val(),t=$(e).find("#minutes").val(),n=$(e).find("#seconds").val(),o=moment(),r=moment(),s=$(".scheduleNowMessage");""!=a&&r.add(a,"hours"),""!=t&&r.add(t,"minutes"),""!=n&&r.add(n,"seconds"),s.html(s.data().template.replace("[fromDt]",o.format(jsDateFormat)).replace("[toDt]",r.format(jsDateFormat))).removeClass("d-none"),$("#fromDt").val(o.format(systemDateFormat)),$("#toDt").val(r.format(systemDateFormat))}},scheduleNowFormSubmit=function(e){scheduleNowFormEvaluateDates(e),e.submit()},agendaSelectLinkedElements=function(e,a,t,n){var o=[],r={layouts:"selected-linked",overlays:"selected-linked",displaygroups:"selected-linked",campaigns:"selected-linked"};results=t.results[t.selectedDisplayGroup];for(var s=results.events,l=0;l
OpenStreetMap',subdomains:["a","b","c"]}).addTo(mymap);var t=new L.FeatureGroup;mymap.addLayer(t);var n=new L.Control.Draw({position:"topright",draw:{polyline:!1,circle:!1,marker:!1,circlemarker:!1},edit:{featureGroup:t}}),o=new L.Control.Draw({position:"topright",draw:!1,edit:{featureGroup:t}});mymap.addControl(n);var r=new L.Control.Search({url:"https://nominatim.openstreetmap.org/search?format=json&q={s}",jsonpParam:"json_callback",propertyName:"display_name",propertyLoc:["lat","lon"],marker:L.circleMarker([0,0],{radius:30}),autoCollapse:!0,autoType:!1,minLength:2,hideMarkerOnCollapse:!0,firstTipSubmit:!0});mymap.addControl(r);var s="",l=null;if(mymap.on("draw:created",(function(e){l=e.layer,t.addLayer(l),s=l.toGeoJSON(),$("#geoLocation").val(JSON.stringify(s)),mymap.removeControl(n),mymap.addControl(o)})),mymap.on("draw:edited",(function(e){e.layers.eachLayer((function(e){s=e.toGeoJSON(),$("#geoLocation").val(JSON.stringify(s))}))})),mymap.on("draw:deleted",(function(e){e.layers.eachLayer((function(e){$("#geoLocation").val(""),t.removeLayer(e)})),0===t.getLayers().length&&(mymap.removeControl(o),mymap.addControl(n))})),null!=$("#geoLocation").val()&&""!==$("#geoLocation").val()){var i=JSON.parse($("#geoLocation").val());L.geoJSON(i,{onEachFeature:function(e,a){t.addLayer(a),mymap.fitBounds(a.getBounds())}}),mymap.removeControl(n),mymap.addControl(o)}},generateFilterGeoMap=function(){null!=mymap&&mymap.remove();var e=$("#geoLatitude").val(),a=$("#geoLongitude").val();null!=e&&""!=e&&null!=a&&""!=a||(e=$(".cal-event-location-map").data("defaultLat"),a=$(".cal-event-location-map").data("defaultLong")),mymap=L.map("geoFilterAgendaMap").setView([e,a],13),L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'©
OpenStreetMap
',subdomains:["a","b","c"]}).addTo(mymap);var t=new L.Control.Search({url:"https://nominatim.openstreetmap.org/search?format=json&q={s}",jsonpParam:"json_callback",propertyName:"display_name",propertyLoc:["lat","lon"],marker:L.circleMarker([0,0],{radius:30}),autoCollapse:!0,autoType:!1,minLength:2,hideMarkerOnCollapse:!0});mymap.addControl(t);var n=function(e,a){null!=mymapmarker&&mymap.removeLayer(mymapmarker),mymapmarker=L.marker([e,a],mymap).addTo(mymap)};mymap.on("click",(function(e){$("#geoLatitude").val(e.latlng.lat).change(),$("#geoLongitude").val(e.latlng.lng).change(),n(e.latlng.lat,e.latlng.lng)})),null!=$("#geoLatitude").val()&&""!=$("#geoLatitude").val()&&null!=$("#geoLongitude").val()&&""!=$("#geoLongitude").val()&&n($("#geoLatitude").val(),$("#geoLongitude").val())},filterEventsByLocation=function(e){for(var a=[],t=0;t
0&&a.push(n)}else a.push(n)}return a},setupSelectForSchedule=function(e){var a=$("#campaignId",e);a.select2({ajax:{url:a.data("searchUrl"),dataType:"json",data:function(e){var t={isLayoutSpecific:a.data("searchIsLayoutSpecific"),retired:0,totalDuration:0,name:e.term,start:0,length:10,columns:[{data:"isLayoutSpecific"},{data:"campaign"}],order:[{column:0,dir:"asc"},{column:1,dir:"asc"}]};return null!=e.page&&(t.start=10*(e.page-1)),t},processResults:function(e,a){var t=[];$.each(e.data,(function(e,a){t.push({id:a.campaignId,text:a.campaign})}));var n=a.page||1;return{results:t,pagination:{more:10*(n=n>1?n-1:n)
1?r-1:r,{results:[{text:t.data("transGroups"),children:n},{text:t.data("transDisplay"),children:o}],pagination:{more:10*r