Skip to content

Instantly share code, notes, and snippets.

@andrew-aladev
Created August 7, 2014 14:28
Show Gist options
  • Save andrew-aladev/a44adacd773990c4df83 to your computer and use it in GitHub Desktop.
Save andrew-aladev/a44adacd773990c4df83 to your computer and use it in GitHub Desktop.
var infowindow = new google.maps.InfoWindow({
content : "<div></div>"
});
(function (item, item_is_work_order, item_is_task, marker, infowindow) {
google.maps.event.addListener(infowindow, "domready", function () {
var wrapper_el = $(this.k.contentNode).closest(".gm-style-iw").parent()
.empty().css({
width : "",
height : "",
cursor : ""
})
.addClass("work_order_popup_wrapper");
wrapper_el.append("<div class=\"work_order_popup_arrow\"></div>");
var popup_el = $("<div class=\"work_order_popup\"></div>").appendTo(wrapper_el);
item.popup_show = function () {
wrapper_el.show();
};
item.popup_hide = function () {
wrapper_el.hide();
};
item.update_data = function (new_data, success_callback, error_callback) {
var self = this;
var data = $.extend({}, item.popup.details, new_data);
var send_data = {
Id : data.Id,
WorkOrderStatusId : data.WorkOrderStatusId,
Description : data.Description,
FieldWorkerId : data.FieldWorkerId,
CustomId : data.CustomId,
StartDate : data.StartDate,
EndDate : data.EndDate,
StartTime : data.StartTime,
EndTime : data.EndTime
};
if (data.ServiceRequestId != undefined && data.ServiceRequestId != null) {
send_data.ServiceRequestId = data.ServiceRequestId;
} else {
send_data.LocationId = data.LocationId;
}
$.ajax({
url : "/WorkOrder/Update",
type : "post",
data : send_data,
success : function (result) {
if (result.IsSuccess) {
app.broadcast("Success", result.Message);
if ($.isFunction(success_callback)) {
success_callback();
}
} else {
app.broadcast("Error", result.Message);
if ($.isFunction(error_callback)) {
error_callback();
}
}
},
error : function (jqXHR, status, error) {
if (jqXHR.status === 0 || jqXHR.readyState === 0) {
return;
}
if (console && console.error) {
console.error.apply(console, arguments);
}
app.broadcast("Error", "Cant update work order's data");
if ($.isFunction(error_callback)) {
error_callback();
}
}
});
}
if (item_is_work_order) {
item.popup = new app.Schedule.Scheduler.SRPopup(popup_el, wrapper_el, item.Id, item, app.config.users, {
autohide : false,
timeout : 0
});
} else {
item.popup = new app.Schedule.Scheduler.TaskPopup(popup_el, wrapper_el, item.Id, item, app.config.users, {
autohide : false,
timeout : 0
});
}
if (!app.schedule) {
app.schedule = {
calendar : new app.Schedule.Scheduler.Calendar()
};
app.schedule.calendar.load_init_data(function (data) {
app.schedule.calendar.statuses = new app.Schedule.Scheduler.Statuses(data.workOrderStatusTypes);
item.popup.load(function () {
item.popup.show();
});
});
} else {
item.popup.load(function () {
item.popup.show();
});
}
});
google.maps.event.addListener(marker, "click", function () {
if (item.popup) {
if (item.popup.is_loaded) {
item.popup.show();
} else {
item.popup.load(function () {
item.popup.show();
});
}
} else {
infowindow.open(map, this);
opinfb.push(infowindow);
}
});
}) (item, item_is_work_order, item_is_task, marker, infowindow);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment