Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (2022)

  • Explore
  • Become a Coach
  • Login
  • Sign Up

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (5)

Forsgate Golf Academy

Monroe Township, NJ |

  • Golf,

Send Message

About Forsgate Golf

The academy is geared for all ages and abilities, from beginners to elite competitors. The staff is led by one of the finest golf instructors on the east coast, Director of Instruction Paul Kaster, along with Top 50 U.S. Kids Master Teacher Carolyn McKenzie...

Offerings

Forsgate Country Club

375 Forsgate Dr, Monroe Township, NJ 08831

Paul Kaster
60 Mins, In-Person, 1 Adult

$140.00

Cost

Private lesson with Director of Instruction Paul Kaster

Staff Instructors
60 Mins, In-Person, 1 Adult

$120.00

Cost

Private lesson with Forsgate Golf Academy Staff Instructors

Paul Kaster
60 Mins, In-Person, 1 Junior

$110.00

Cost

Private junior lesson with Director of Instruction Paul Kaster

Staff Instructors
60 Mins, In-Person, 1 Junior

$90.00

Cost

Private junior lesson with Forsgate Golf Academy Staff Instructors

Achievements

  • US Kids Golf Top 50 Master Instructor (Carolyn M. Andrews)
  • US Kids Golf Top 50 Hon. Mention '15 and '16 (Paul Kaster)
  • Nominee, 2016 NJPGA Youth Development Award (Paul Kaster)
  • 2015 Champions Tour Player (Frank Esposito)
  • Division I College Golf All American (Carolyn M. Andrews)
  • New Jersey PGA Public Relations Committee Member (Paul Kaster)

Areas of Focus

  • Putting
  • Short Game
  • Full Swing
  • Fitness
  • Club Fitting
  • Bunker Play
  • Fundamentals
  • Jr. Golf
  • Women's Golf
  • Mental Game
  • Competitive Golf
  • College Prep

Playing Experience

  • Champions Tour
  • Collegiate Golfer
  • LPGA Symetra Tour
  • Mini Tours
  • PGA Section Events
  • PGA Tour

Club Fitting Certifications

  • Callaway
  • Ping
  • Titleist

Certifications

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (7)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (8)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (9)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (10)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (11)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (12)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (13)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (14)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (15)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (16)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (17)

Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (18)

hello

Crop Image

Crop your cover Image

"); $(".ui-dialog-buttonpane").css("visibility", "hidden"); if(param['site_url']!=undefined && param['site_url']!=null) { var url = "https://www.thrivsports.com/cart/add/item_type/package/id/"+param['golfpro_package_id']+"/golfpro/"+param['site_url']+"/qty/1"; } else { var url = "https://www.thrivsports.com/cart/add/item_type/package/id/"+param['golfpro_package_id']+"/golfpro//qty/1"; } $.ajax({ url: url, //dataType: "json", type: "GET", success: function(response) { //alert(response); modal.dialog("close"); if(param['site_url']!=undefined && param['site_url']!=null) { var redurl = "https://www.thrivsports.com/"+param['site_url']+"/buyPackage/?golfpro_package_id="+param['golfpro_package_id']; } else { var redurl = "https://www.thrivsports.com//buyPackage/?golfpro_package_id="+param['golfpro_package_id']; } $.colorbox({ opacity: 0.7, href: redurl, onComplete: function() { if(typeof bindScrollLink == 'function') { bindScrollLink("#selectLesson a", "click"); } } }); }, failure: function() { alert("failed"); } }); } }, { text: "Cancel", click: function() { modal.dialog("close"); } }] }); $(".ui-dialog-buttonpane").css("visibility", "visible"); $('.ui-widget-overlay').height($(document).height()); $('.ui-widget-overlay').css("z-index", "10000"); modal.html("Add this package to cart?"); modal.dialog("open"); $(".ui-dialog").css("z-index", "20000"); */ } function bookAnotherLessonFromPackage(item_id, site_url) { if(site_url!=undefined && site_url!=null) { var redurl = "https://www.thrivsports.com/"+site_url+"/buyPackage/?item_id="+item_id+"&addingAnother=true"; } else { var redurl = "https://www.thrivsports.com//buyPackage/?item_id="+item_id+"&addingAnother=true"; } var params = {}; var modal = new ModalModule(); modal.init(); modal.open(redurl, params, function() { }); //window.location.href = "https://www.thrivsports.com/"+site_url+"/bookNow"; event.stopPropagation(); } function bookNowPackageItem(golfpro_package_item_id, site_url) { if(typeof(event)!="undefined") { event.stopPropagation(); } if(typeof(site_url)=='undefined') { site_url = null; } var paramObj = { 'golfpro_package_item_id': golfpro_package_item_id, 'site_url': site_url }; var callback = function(param) { if(param['site_url']!=undefined && param['site_url']!=null) { window.location.href = "https://www.thrivsports.com/"+param['site_url']+"/bookNow/?golfpro_package_item_id="+param['golfpro_package_item_id']; } else { window.location.href = "https://www.thrivsports.com//bookNow/?golfpro_package_item_id="+param['golfpro_package_item_id']; } }; if(typeof scrollLink == 'function') { return scrollLink(callback, paramObj); } else { return callback(paramObj); } } function bookNowRate(golfpro_rate_id, site_url) { if(typeof(event)!="undefined") { event.preventDefault(); event.stopPropagation(); } window.location.href = "https://www.thrivsports.com/"+site_url+"/bookNow/"+golfpro_rate_id; } function bookNowUserPackageItem(user_package_purchase_item_id, site_url) { if(typeof(event)!="undefined") { event.stopPropagation(); } if(typeof(site_url)=='undefined') { site_url = null; } var paramObj = { 'user_package_purchase_item_id': user_package_purchase_item_id, 'site_url': site_url }; var callback = function(param) { if(param['site_url']!=undefined && param['site_url']!=null) { window.location.href = "https://www.thrivsports.com/"+param['site_url']+"/bookNow/?user_package_purchase_item_id="+param['user_package_purchase_item_id']; } else { window.location.href = "https://www.thrivsports.com//bookNow/?user_package_purchase_item_id="+param['user_package_purchase_item_id']; } }; if(typeof scrollLink == 'function') { return scrollLink(callback, paramObj); } else { return callback(paramObj); } } var ThrivPopover = function() { var init = function(opts) { var self = this; self.opts = opts; $(".popover").remove(); if(typeof(self.opts['trigger']) == 'undefined') { var trigger = 'manual'; } else { var trigger = self.opts['trigger']; } if(typeof(self.opts['viewport']) == 'undefined') { var viewport = null; } else { var viewport = { selector: self.opts['viewport'], padding: 0 }; } if(typeof(self.opts['custom_class']) != 'undefined') { var custom_class = self.opts['custom_class']; } else { var custom_class = ''; } self.opts['e'].popover({ template: '

', html: true, content: function() { return '

Loading...'; }, placement: function (context, source) { if(typeof(self.opts['width']) == 'undefined') { var popover_width = 420; } else { var popover_width = self.opts['width']; } if(typeof(self.opts['placement']) == 'undefined') { var s = $(source).offset(); var s_right = $(source).width() + s.left; var s_left = s.left; var s_top = s.top; var s_bottom = $(source).height() + s.top; var container = self.opts['container']; var b = container.offset(); var b_right = container.width() + b.left; var b_left = b.left; var b_top = b.top; var b_bottom = container.height() + b.top; if(s_right + popover_width > b_right) { if(s_left - popover_width < b_left) { return "bottom"; } return "left"; } return "right"; } else { return "bottom"; } }, viewport: viewport, trigger: trigger, container: "body" }).on("inserted.bs.popover", function() { if(typeof(self.opts['content']) != 'undefined') { var h = $(".popover").height(); $(".popover-loading").removeClass("popover-loading"); $(".popover .popover-content").html(self.opts['content'].html()); self.opts['callback'](); if($(".popover").hasClass("left") || $(".popover").hasClass("right")) { var new_h = $(".popover").height(); var diff = new_h - h; var t = parseInt($(".popover").css("top")); var new_t = t - (diff / 2); $(".popover").css("top", new_t+"px"); } } else { //var popover = e.data('bs.popover'); //var tip = $(popover.tip); $(".popover").addClass("popover-loading"); var params = {}; if(typeof(self.opts['params']) != 'undefined') { for(var i in self.opts['params']) { params[i] = self.opts['params'][i]; } } if(typeof(self.mainReq) != 'undefined') { self.mainReq.abort(); } self.mainReq = $.ajax({ type: "POST", data: params, url: self.opts['url'], success: function(response) { var h = $(".popover").height(); $(".popover-loading").removeClass("popover-loading"); if(response['success']) { $(".popover .popover-content").html(response['html']); self.opts['callback'](); if($(".popover").hasClass("left") || $(".popover").hasClass("right")) { var new_h = $(".popover").height(); var diff = new_h - h; var t = parseInt($(".popover").css("top")); var new_t = t - (diff / 2); $(".popover").css("top", new_t+"px"); } } }, error: function() { }, dataType: "json", cache: false }); } }); } var show = function() { var self = this; self.opts['e'].popover("show"); } var hide = function() { var self = this; if(typeof(self.opts) != 'undefined') { self.opts['e'].popover("hide"); } //$(".popover").remove(); } var adjust = function(e) { var self = this; //to-do: figure out how to adjust position based on new element } return { init: init, show: show, hide: hide, adjust: adjust } } var ThrivFormModule = function() { var init = function() { var self = this; } var validate = function(e, quiet) { var self = this; if(typeof(quiet) == 'undefined') { e.find(".form-control").blur(); if(e.find(".form-group.problem").length) { var ret = true; e.find(".form-group.problem").each(function() { if($(this).closest(".ignore-form").length == 0) { ret = false; return false; } }); return ret; } else { return true; } } else { var ret = true; e.find(".form-control[required]").each(function() { if($(this).closest(".ignore-form").length == 0) { if($.trim($(this).val()) == "") { ret = false; } } }); return ret; } } var initSelectpicker = function(e) { var self = this; e.each(function() { var p = $(this).parent(); if(p.hasClass("bootstrap-select")) { p.replaceWith($(this)); } var spec = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); $(this).attr("name", "select_"+spec); $(this).attr("id", "select_"+spec); $(this).selectpicker("refresh"); $(this).change(); if(p.find(".bootstrap-select").hasClass("form-control-lg")) { p.find(".bootstrap-select").find(".btn").addClass("btn-lg"); } }); } var bind = function(e, opts) { var self = this; if(typeof(opts) != 'undefined') { self.opts = opts; } else { self.opts = {}; } /* e.find(".input-group-toggler .input-group-addon").bind("click", function(ev) { ev.stopPropagation(); ev.preventDefault(); var tog = $(this).find("label"); var tog = $(this).find("input"); if(tog.is(":checked")) { tog.prop("checked", false); } else { tog.prop("checked", true); } tog.change(); }); */ e.find(".input-group-toggler").each(function() { var p = $(this).closest(".form-group"); var i = p.find(".form-control"); var tog = $(this).find("input"); if(i.val() == "") { tog.prop("checked", false); //i.prop("disabled", true); } else { tog.prop("checked", true); //i.prop("disabled", false); } //tog.change(); }); e.find(".input-group-toggler input").unbind("change"); e.find(".input-group-toggler input").bind("change", function(ev) { var t = $(this); var p = t.closest(".form-group"); var i = p.find(".form-control"); var v = $.trim(i.val()); if(p.data("type") == "cost") { if(v == "" || v == "$") { v = ""; } else { v = v.replace(/,|\$/g, ''); } } if(t.prop("checked")) { p.removeClass("inactive"); if(v != "") { p.addClass("done"); } i.focus(); //i.prop("disabled", false); } else { p.addClass("inactive"); p.removeClass("done"); //i.prop("disabled", true); } }); e.find(".form-control").unbind("focus"); e.find(".form-control").bind("focus", function(ev) { var p = $(this).closest(".form-group"); p.removeClass("inactive"); p.removeClass("active"); p.removeClass("problem"); p.removeClass("done"); p.addClass("active"); $(".form-cluster").removeClass("active").addClass("inactive"); var cl = p.closest(".form-cluster"); cl.removeClass("inactive") cl.addClass("active"); if(p.find(".input-group-toggler").length) { p.find(".input-group-toggler").find("input").prop("checked", true); } ev.stopPropagation(); }); e.find(".form-control").unbind("blur"); e.find(".form-control").bind("blur", function(ev) { var p = $(this).closest(".form-group"); p.removeClass("active"); p.removeClass("problem"); p.removeClass("done"); p.find(".problem-notify").remove(); var v = $(this).val(); var error = null; if($(this).attr("required") != null && $.trim($(this).val()) == "") { error = "required"; } else if($.trim(v) != "") { //check for invalid if(p.data("type") != null) { var t = p.data("type"); if(t == "phone") { v = v.replace(/\s/g, ''); var v_test = /^\d{10}$/; if(!v.match(v_test)) { error = "invalid phone number"; } } else if(t == "email") { var v_test = /^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/; if(!v.match(v_test)) { error = "invalid email"; } } else if(t == "integer") { if(p.data("min") != null && parseInt(v.replace(/,/g, '')) < p.data("min")) { error = "must be at least "+p.data("min"); } if(p.data("max") != null && parseInt(v.replace(/,/g, '')) > p.data("max")) { error = "must be less than "+p.data("max"); } } else if(t == "float") { if(p.data("min") != null && parseFloat(v.replace(/,/g, '')) < p.data("min")) { error = "must be at least "+p.data("min"); } if(p.data("max") != null && parseFloat(v.replace(/,/g, '')) > p.data("max")) { error = "must be less than "+p.data("max"); } } else if(t == "cost") { if(v == "" || v == "$") { v = ""; } else { v = v.replace(/,|\$/g, ''); } if($(this).attr("required") != null && v == "") { error = "required"; } else { if(p.data("min") != null && parseFloat(v) < p.data("min")) { error = "must be at least "+p.data("min"); } if(p.data("max") != null && parseFloat(v) > p.data("max")) { error = "must be less than "+p.data("max"); } } } } else { //assume string if(p.data("min") != null && v.length < p.data("min")) { error = "must be at least "+p.data("min")+" characters"; } if(p.data("max") != null && v.length > p.data("max")) { error = "must be less than "+p.data("max")+" characters"; } if(p.data("pattern") != null) { var pattern = RegExp(p.data("pattern"), 'gm'); var matches = pattern.exec(v); if ( (v.length > 0 && matches == null) || (matches != null && matches[0] != v) ) { error = "invalid characters"; } } } } if(error != null) { p.addClass("problem"); var str = ''; str += '

'; str += error; str += '

'; p.append(str); } else if($.trim(v) != "") { p.addClass("done"); } //$(".form-cluster").removeClass("active").removeClass("inactive"); if(p.find(".input-group-toggler").length && $.trim(v) == "") { p.find(".input-group-toggler input").prop("checked", false); //p.find(".input-group-toggler input").change(); } else { p.find(".input-group-toggler input").prop("checked", true); //p.find(".input-group-toggler input").change(); } /* var cl = $(this).closest(".form-cluster"); cl.removeClass("active"); */ }); e.find(".input-group-addon:first-child").unbind("click"); e.find(".input-group-addon:first-child").bind("click", function(ev) { var p = $(this).closest(".input-group"); if(p.hasClass("input-group-toggler")) { //ev.stopPropagation(); //ev.preventDefault(); /* var tog = $(this).find("input"); if(tog.prop("checked")) { tog.prop("checked", false); } else { tog.prop("checked", true); //p.find(".form-control").focus(); } //p.find(".form-control").focus(); ev.preventDefault(); ev.stopPropagation(); */ } else { p.find(".form-control").focus(); } return true; }); e.find(".form-group[data-type='toggler']").each(function() { var elem = $(this).find("input"); elem.attr("data-color", "#009DDD"); if($(this).data("target") != null) { elem.bind("change", function(ev) { var targ = $($(this).closest(".form-group").data("target")); if($(this).is(":checked")) { //targ.show(); targ.slideDown(400, function() { }); } else { //targ.hide(); targ.slideUp(400, function() { }); } }); elem.change(); } var init = new Switchery(elem[0], { color: "#0090FF", jackColor: "#ffffff", secondaryColor: "#969696", jackSecondaryColor: "#cbcbcb" }); elem.data("switch", init); }); e.find(".form-group[data-type='repeats']").each(function() { var inner_div = $(this).find("> div"); var data_source = $($(this).data("source")); var str = ''; str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; str += '

Loading...

'; str += '

'; inner_div.html(str); inner_div.find(".field_repeat_loader").show(); self.bindRepeats(data_source, inner_div, function() { }); }); e.find(".form-group[data-type='repeats-simple']").each(function() { var inner_div = $(this).find("> div"); var data_source = $($(this).data("source")); var data_source_end = $($(this).data("sourceend")); var str = ''; str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; str += '

Loading...

'; str += '

'; inner_div.html(str); inner_div.find(".field_repeat_loader").show(); var init = $(this).data("init"); self.bindRepeats(data_source, inner_div, function() { if(init != null && init != "") { self.injectRrule(inner_div, init, moment(data_source.datepicker("getDate"))); } }, data_source_end); }); e.find(".form-group[data-type='date'], .form-control[data-type='date']").each(function() { var t = $(this); if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } e.datepicker({ autoclose: true, container: t, orientation: "bottom left" }).on("changeDate", function(e) { $(this).blur(); }); }); e.find(".form-group[data-type='integer'], .form-control[data-type='integer']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } if($(this).data("max") != null) { var str = "" + $(this).data("max"); var blocks = str.length; } else { var blocks = 4; } var cleave = new Cleave(e[0], { blocks: [blocks], numericOnly: true }); }); e.find(".form-group[data-type='float'], .form-control[data-type='float']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { numeral: true, numeralThousandsGroupStyle: 'thousand' }); }); e.find(".form-group[data-type='cost'], .form-control[data-type='cost']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { prefix: "$", numeral: true, numeralThousandsGroupStyle: 'thousand' }); }); e.find(".form-group[data-type='phone'], .form-control[data-type='phone']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { phone: true, phoneRegionCode: 'US' }); }); e.find(".form-group[data-type='cc_number'], .form-control[data-type='cc_number']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { creditCard: true, onCreditCardTypeChanged: function (type) { if(type == "diners") { type = "diners-club"; } if(type == "unknown") { var cc = "fa fa-credit-card" } else { var cc = "fab fa-cc-" + type; } $(".thrivcart-cards-addnew-icon i")[0].className = cc; } }); }); e.find(".form-group[data-type='cc_date'], .form-control[data-type='cc_date']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { date: true, datePattern: ['m', 'y'] }); }); e.find(".form-group[data-type='cc_cvv'], .form-control[data-type='cc_cvv']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { blocks: [4], numericOnly: true }); }); e.find(".form-group[data-type='time'], .form-control[data-type='time']").each(function() { if($(this).hasClass("form-control")) { var e = $(this); } else { var e = $(this).find(".form-control"); } var cleave = new Cleave(e[0], { time: true, timePattern: ['h', 'm'] }); e.bind("keyup", function() { var v = $(this).val(); var tmp = v.split(":"); if(typeof(tmp[0]) != 'undefined' && tmp[0] != "") { var hr = parseInt(tmp[0]); if(hr > 12) { hr = hr - 12; if(hr < 10) { hr = "0" + hr; } if(typeof(tmp[1]) != 'undefined' && tmp[1] != "") { var mn = parseInt(tmp[1]); v = hr+":"+mn; } else { v = hr+":00"; } $(this).val(v); var p = $(this).closest(".input-group").find(".input-group-addon-toggler [data-val='pm']").click(); } } }); }); e.find(".form-group[data-type='tags']").each(function() { var o = { placeholder: 'Choose...', width: '100%' }; if($(this).data("tags") != null) { o['tags'] = $(this).data("tags"); } e.find(".select2").select2(o); e.find(".select2").on('select2:open', function (e) { var p = $(this).closest(".form-group").addClass("active"); $(this).closest(".form-group").find("select").focus(); }); e.find(".select2").on('select2:close', function (e) { var p = $(this).closest(".form-group").removeClass("active"); $(this).closest(".form-group").find("select").blur(); }); e.find(".select2").on('select2:select', function (e) { $(this).closest(".form-group").find("select").blur(); }); }); e.find(".input-group-addon-toggler > a").bind("click", function() { var p = $(this).closest(".input-group-addon-toggler"); p.find("a").removeClass("active"); $(this).addClass("active"); }); e.find("input").attr("autocomplete", "off"); e.find(".form-group").each(function() { var p = $(this); var i = $(this).find(".form-control"); var v = $.trim(i.val()); if(p.data("type") == "cost") { if(v == "" || v == "$") { v = ""; } else { v = v.replace(/,|\$/g, ''); } } if(v != "") { $(this).addClass("done"); } }); e.find("[data-momentformat]").each(function() { if($(this).data("momentformat") != null) { if($(this).data("utc") == null) { $(this).text(moment($(this).text()).utc().format($(this).data("momentformat"))); } else { $(this).text(moment($(this).text()).format($(this).data("momentformat"))); } $(this).data("momentformat", null); } }); e.find("[data-toggle='tooltip']").tooltip(); } var setState = function(e) { var self = this; var p = e.closest(".form-group"); p.removeClass("active"); p.removeClass("problem"); p.removeClass("done"); p.find(".problem-notify").remove(); var v = $.trim(e.val()); if(p.data("type") == "cost") { if(v == "" || v == "$") { v = ""; } else { v = v.replace(/,|\$/g, ''); } } if(e.attr("required") != null && v == "") { p.addClass("problem"); var str = ''; str += '

'; str += 'required'; str += '

'; p.append(str); } else if(v != "") { p.addClass("done"); } else { } } var injectRrule = function(e, repeats, start_date) { var self = this; if (typeof (repeats) == 'undefined' || repeats == null || $.trim(repeats) == "") { return; } var tmp = repeats.split(";"); var rr = []; var rr_t = []; for (var i in tmp) { var tt = tmp[i].split("="); rr[tt[0]] = tt[1]; if(tt[0] != "UNTIL") { //rr[tt[0]] = tt[1]; //var tt1 = moment(tt[1]).subtract(24, 'hours').format(); rr_t.push(tt[0]+"="+tt[1]); } } //test if single instance if(rr['FREQ'] == "DAILY") { if(parseInt(rr['INTERVAL']) == 1) { if(typeof(rr['COUNT']) != 'undefined' && parseInt(rr['COUNT']) == 1) { return; } if(typeof(start_date) != 'undefined') { var until = moment(rr['UNTIL']); var start_str = start_date.format('YYYY-MM-DD'); var end_str = until.format('YYYY-MM-DD'); if(start_str == end_str) { return null; } } } } var repeats_mod = rr_t.join(";"); var trypre = e.find(".field_repeat_pattern").find("option[value='" + repeats_mod + "']"); if (trypre.length) { e.find(".field_repeat_pattern").val(repeats_mod); e.find(".field_repeat_custom_outer").hide(); e.find(".field_repeat_custom_outer2").show(); } else { e.find(".field_repeat_pattern").val("custom"); e.find(".field_repeat_custom_outer").show(); e.find(".field_repeat_custom_outer2").show(); } if (typeof (rr['FREQ']) != 'undefined') { if (rr['FREQ'] == "DAILY") { var freq = "day"; } else if (rr['FREQ'] == "WEEKLY") { var freq = "week"; } else if (rr['FREQ'] == "MONTHLY") { var freq = "month"; } else if (rr['FREQ'] == "YEARLY") { var freq = "year"; } if (typeof (freq) != 'undefined') { e.find(".field_repeat_custom_type").val(freq); e.find(".field_repeat_custom_type").selectpicker('refresh'); e.find(".field_repeat_custom_type").change(); } } if (typeof (rr['INTERVAL']) != 'undefined') { e.find(".field_repeat_custom_num").val(rr['INTERVAL']); e.find(".field_repeat_custom_num").selectpicker('refresh'); e.find(".field_repeat_custom_num").change(); } if (typeof (rr['BYDAY']) != 'undefined') { var days = rr['BYDAY'].split(","); var map = {}; map['SU'] = 'sun'; map['MO'] = 'mon'; map['TU'] = 'tue'; map['WE'] = 'wed'; map['TH'] = 'thu'; map['FR'] = 'fri'; map['SA'] = 'sat'; e.find(".field_repeat_custom_week_day").prop("checked", false); for (var i in days) { e.find(".field_repeat_custom_week_" + map[days[i]]).prop("checked", true); } e.find(".field_repeat_custom_month_menu").val("1"); e.find(".field_repeat_custom_month_menu").selectpicker('refresh'); e.find(".field_repeat_custom_month_menu").change(); } if (typeof (rr['BYMONTHDAY']) != 'undefined') { e.find(".field_repeat_custom_month_menu").val("0"); e.find(".field_repeat_custom_month_menu").selectpicker('refresh'); e.find(".field_repeat_custom_month_menu").change(); } if (typeof (rr['COUNT']) != 'undefined') { e.find(".field_repeat_ends_type").val("after"); e.find(".field_repeat_ends_type").selectpicker('refresh'); e.find(".field_repeat_ends_type").change(); e.find(".field_repeat_ends_after").val(rr['COUNT']); e.find(".field_repeat_ends_after").selectpicker('refresh'); e.find(".field_repeat_ends_after").change(); } if (typeof (rr['UNTIL']) != 'undefined') { e.find(".field_repeat_custom_outer2").show(); e.find(".field_repeat_ends_type").val("on"); e.find(".field_repeat_ends_type").selectpicker('refresh'); e.find(".field_repeat_ends_type").change(); var d = moment(rr['UNTIL']).toDate(); e.find(".field_repeat_ends_on").datepicker("setDate", d); } } var bindRepeats = function (date_input, conta, loadFunc, date_input_end) { var self = this; var populateRecurrencePatterns = function (response) { var str = ''; str += ''; if (conta.find(".field_repeat_pattern").length) { var i = 0; var prev_index = 0; conta.find(".field_repeat_pattern option").each(function () { if ($(this).is(":selected")) { prev_index = i; } i++; }); } conta.find(".field_repeat_pattern_outer").html(str); if (typeof (prev_index) != 'undefined') { $(conta.find('.field_repeat_pattern option')[prev_index]).prop("selected", true); } var str = ''; str += ''; conta.find(".field_repeat_custom_month_menu_outer").html(str); var l = response['day'].toLowerCase(); conta.find(".field_repeat_custom_week_outer input").prop("checked", false); conta.find(".field_repeat_custom_week_" + l).prop("checked", true); if (typeof (loadFunc) != 'undefined' && loadFunc != null) { loadFunc(); } conta.find(".field_repeat_pattern").selectpicker({ size: 10 }); conta.find(".field_repeat_pattern").on('changed.bs.select', function (e) { if (conta.find(".field_repeat_pattern").find(":selected").val() == "custom") { conta.find(".field_repeat_custom_outer").show(); } else { conta.find(".field_repeat_custom_outer").hide(); } if(conta.find(".field_repeat_pattern").find(":selected").val() != "") { conta.find(".field_repeat_custom_outer2").show(); } else { conta.find(".field_repeat_custom_outer2").hide(); } }); conta.find(".field_repeat_custom_month_menu").selectpicker({ size: 10 }); conta.find(".field_repeat_loader").hide(); if(typeof(date_input_end) != 'undefined' && date_input_end.val() != "" && date_input_end.val() != null) { conta.find(".field_repeat_ends_on").datepicker("setDate", date_input_end.val()); } else if(response['end'] != null && response['end'] != "") { conta.find(".field_repeat_ends_on").datepicker("setDate", response['end']); } }; /* conta.find('.date').datepicker({ autoclose: true, container: conta.find('.date').parent(), orientation: "bottom left" }).on('changeDate', function (e) { self.fetchRecurrencePatterns(e.format(), function (response) { populateRecurrencePatterns(response); }); }); */ self.fetchRecurrencePatterns(date_input.val(), function (response) { populateRecurrencePatterns(response); }); date_input.bind("change", function() { self.fetchRecurrencePatterns($(this).val(), function (response) { populateRecurrencePatterns(response); }); }); conta.find(".field_repeat_custom_num").selectpicker({ size: 10 }); conta.find(".field_repeat_custom_type").selectpicker({ size: 10 }); conta.find(".field_repeat_custom_num").on('changed.bs.select', function (e) { if (parseInt(conta.find(".field_repeat_custom_num").find(":selected").val()) == 1) { conta.find(".field_repeat_custom_type").find(".filter-option, .text, option").each(function () { var l = $(this).text().substr($(this).text().length - 1); if (l == 's') { $(this).text($(this).text().substr(0, $(this).text().length - 1)); } }); } else { conta.find(".field_repeat_custom_type").find(".filter-option, .text, option").each(function () { var l = $(this).text().substr($(this).text().length - 1); if (l != 's') { $(this).text($(this).text() + 's'); } }); } }); conta.find(".field_repeat_custom_type").on('changed.bs.select', function (e) { conta.find(".field_repeat_custom_week_outer").hide(); conta.find(".field_repeat_custom_month_outer").hide(); if (conta.find(".field_repeat_custom_type").find(":selected").val() == "week") { conta.find(".field_repeat_custom_week_outer").show(); } else if (conta.find(".field_repeat_custom_type").find(":selected").val() == "month") { conta.find(".field_repeat_custom_month_outer").show(); } }); conta.find(".field_repeat_ends_type").selectpicker({ size: 10 }); conta.find(".field_repeat_ends_after").selectpicker({ size: 10 }); conta.find(".field_repeat_ends_after").hide(); conta.find(".field_repeat_ends_type").on('changed.bs.select', function (e) { var v = conta.find(".field_repeat_ends_type").find(":selected").val(); if (v == "never") { conta.find(".field_repeat_ends_on").hide(); conta.find(".field_repeat_ends_after").hide(); } else if (v == "on") { conta.find(".field_repeat_ends_on").css("display", "inline-block"); conta.find(".field_repeat_ends_after").hide(); } else if (v == "after") { conta.find(".field_repeat_ends_on").hide(); conta.find(".field_repeat_ends_after").show(); } }); conta.find(".field_repeat_ends_on").datepicker({ autoclose: true, container: conta.find('.field_repeat_ends_on').parent(), orientation: "bottom left" }); } var formatDateForRrule = function(d, no_time) { var self = this; return d; } var convertDateToISO = function(d) { var self = this; var dd = moment(d).toISOString(); dd = dd.replace(/-/g, ""); dd = dd.replace(/:/g, ""); dd = dd.replace(/\./g, ""); dd = dd.substring(0, dd.length-4) + "Z"; return dd; } var convertRruleToObject = function(start_date, rrule, exdates) { var self = this; var os = {}; //break apart rrule var tmp = rrule.split(";"); var rr_raw = []; for (var i in tmp) { var tt = tmp[i].split("="); if(tt[0] == "UNTIL") { //var tt1 = moment(tt[1]).add(24, 'hours'); var tt1 = moment(tt[1]); var tt1_raw = tt1.format("YYYYMMDDTHHmmss") + 'Z'; } else { var tt1_raw = tt[1]; } rr_raw.push(tt[0]+'='+tt1_raw); } var rrule_raw = rr_raw.join(";"); var dtstart_raw = self.convertDateToISO(start_date); var fullstring_raw = 'DTSTART:'+dtstart_raw+'\nRRULE:'+rrule_raw; var fullstring_object = { 'DTSTART': dtstart_raw, 'RRULE': rrule_raw }; os['string'] = fullstring_raw; os['object'] = fullstring_object; return os; } var generateRrule = function (date_input, conta) { var self = this; var patt = conta.find(".field_repeat_pattern").find(":selected").val(); if (patt != null && patt != "") { if (patt == "custom") { //custom pattern var rr = {}; var ty = conta.find(".field_repeat_custom_type").find(":selected").val(); if (ty == "day") { rr['FREQ'] = "DAILY"; } else if (ty == "week") { rr['FREQ'] = "WEEKLY"; var bydays = []; conta.find(".field_repeat_custom_week_day:checked").each(function () { bydays.push($(this).val()); }); rr['BYDAY'] = bydays.join(","); } else if (ty == "month") { rr['FREQ'] = "MONTHLY"; var rr_item = null; var i = 0; while (rr_item = conta.find(".field_repeat_custom_month_menu").find(":selected").data("opt" + i)) { var v = rr_item.split("="); rr[v[0]] = v[1]; i++; } } else if (ty == "year") { rr['FREQ'] = "YEARLY"; var dd = date_input.datepicker("getDate"); rr['BYMONTH'] = dd.getMonth() + 1; rr['BYMONTHDAY'] = dd.getDate(); } rr['INTERVAL'] = conta.find(".field_repeat_custom_num").find(":selected").val(); var preadd = ''; } else { var rr = {}; var preadd = patt + ';'; } var end_type = conta.find(".field_repeat_ends_type").find(":selected").val(); if (end_type == "after") { rr['COUNT'] = conta.find(".field_repeat_ends_after").find(":selected").val(); } else if (end_type == "on") { //rr['UNTIL'] = conta.find(".field_repeat_ends_on").datepicker("getDate").toISOString(); } var until = moment.utc(self.formatDateForRrule(conta.find(".field_repeat_ends_on").datepicker("getDate").toISOString())); until.hour(23).minute(59).second(59); // default to end of day rr['UNTIL'] = self.formatDateForRrule(until.format("YYYYMMDDTHHmmss"), false); var rr_string = ''; var i = 0; for (var k in rr) { if (i != 0) { rr_string += ';'; } rr_string += k + '=' + rr[k]; i++; } return preadd + rr_string; } var rr_string = 'FREQ=DAILY;INTERVAL=1;COUNT=1'; return rr_string; } var fetchRecurrencePatterns = function (date, func) { var self = this; var params = {}; params['date'] = date; $.ajax({ url: "https://www.thrivsports.com/view/fetchRecurrencePatterns", dataType: 'json', method: 'POST', data: params, success: function (response) { if (response['success'] == true) { func(response['data']); } else { alert(response['error_code']); } }, error: function () { alert("unable to fetch patterns"); } }); } var getTime = function(e, date) { var self = this; var tmp = e.find(".form-control").val(); var a = e.find(".input-group-addon-toggler").find("a.active").data("val"); var pp = tmp.split(":"); var hr = parseInt(pp[0]); var mn = parseInt(pp[1]); if(a == "pm" && hr < 12) { hr += 12; } else if(a == "am" && hr == 12) { hr = 0; } var timeStr = hr+':'+mn; var time = moment(timeStr, 'HH:mm'); if(typeof(date) != 'undefined') { var o = moment(date); o.set({ hour: time.get('hour'), minute: time.get('minute'), second: time.get('second') }); } else { var o = moment(timeStr, 'HH:mm'); } return o; } var setTime = function(e, date) { var self = this; e.find(".form-control").val(date.format("hh:mm")); e.find(".input-group-addon-toggler").find("a[data-val]").removeClass("active"); e.find(".input-group-addon-toggler").find("a[data-val='"+date.format("a")+"']").addClass("active"); } var getOpts = function() { var self = this; return self.opts; } var cleanCost = function(v) { var self = this; var new_v = v.replace(/,/g, ''); new_v = new_v.replace(/\$/g, ''); return new_v; } return { init: init, bind: bind, setState: setState, validate: validate, bindRepeats: bindRepeats, generateRrule: generateRrule, fetchRecurrencePatterns: fetchRecurrencePatterns, injectRrule: injectRrule, formatDateForRrule: formatDateForRrule, convertRruleToObject: convertRruleToObject, convertDateToISO: convertDateToISO, getTime: getTime, setTime: setTime, initSelectpicker: initSelectpicker, cleanCost: cleanCost, getOpts: getOpts } } var ParentChildModule = function() { var init = function(e) { var self = this; self.container = e; self.item_id = e.data("itemid"); self.fetch(); } var fetch = function(editing) { var self = this; var params = {}; params['item'] = self.item_id; self.container.find(".booknow-for-overlay").show(); //alert("test"); $.ajax({ type: "POST", data: params, url: "https://www.thrivsports.com/cart/listItemChildren", success: function(response) { self.container.find(".booknow-for-overlay").hide(); if(response['success']) { self.container.html(response['html']); if(typeof(editing) != 'undefined' && editing) { self.container.find(".booknow-for-select").hide(); self.container.find(".booknow-for-new").show(); } self.container.find(".booknow-for-select-a").bind("click", function() { self.container.find(".booknow-for-select").hide(); self.container.find(".booknow-for-new").show(); }); self.container.find(".booknow-for-new-back").bind("click", function() { self.container.find(".booknow-for-select").show(); self.container.find(".booknow-for-new").hide(); }); self.container.find(".attendee-back-btn").bind("click", function() { self.container.find(".attendee-selection").css("display", "inline-block"); self.container.find(".attendee-creation").css("display", "none"); }); self.container.find(".attendee-selection .dropdown-menu li a").bind("click", function() { if($(this).data("id") != null) { self.container.find(".attendee-selection .dropdown-toggle .selected-item").text($(this).text()); self.container.find(".attendee-selection .dropdown-toggle .selected-item").data("id", $(this).data("id")); } else { self.container.find(".attendee-selection").css("display", "none"); self.container.find(".attendee-creation").css("display", "inline-block"); } }); self.container.find(".attendee-selection .dropdown-menu li a").first().click(); self.container.find(".booknow-for-submit").bind("click", function() { var params = {}; params['item'] = self.item_id; params['child_name'] = self.container.find(".booknow-for-name").val(); self.container.find(".booknow-for-overlay").show(); $.ajax({ type: "POST", dataType: "json", cache: false, data: params, url: "https://www.thrivsports.com/cart/addChild", success: function(response) { if(response['success']) { self.fetch(true); } else { self.container.find(".booknow-for-overlay").hide(); } } }); }); self.container.find(".booknow-for-check").bind("change", function() { if($(this).is(":checked")) { var params = {}; params['item'] = self.item_id; params['child'] = $(this).data("childid"); self.container.find(".booknow-for-overlay").show(); $.ajax({ type: "POST", dataType: "json", cache: false, data: params, url: "https://www.thrivsports.com/cart/addChild", success: function(response) { if(response['success']) { self.fetch(true); } else { self.container.find(".booknow-for-overlay").hide(); } } }); } else { var params = {}; params['item'] = self.item_id; params['child'] = $(this).data("childid"); self.container.find(".booknow-for-overlay").show(); $.ajax({ type: "POST", dataType: "json", cache: false, data: params, url: "https://www.thrivsports.com/cart/removeChild", success: function(response) { if(response['success']) { self.fetch(true); } else { self.container.find(".booknow-for-overlay").hide(); } } }); } }); } else { if ( response['error_code'] == 'RequireAuthentication' ) { window.location.href = "https://www.thrivsports.com/secure/login/"; } self.container.find(".booknow-for-overlay").hide(); } }, error: function() { self.container.find(".booknow-for-overlay").hide(); }, dataType: "json", cache: false }); } var getAttendee = function() { var self = this; if(self.container.find(".attendee-selection").css("display") == "none") { var n = self.container.find(".attendee-creation .booknow-for-name").val(); var i = null; } else { var n = self.container.find(".attendee-selection .dropdown-toggle .selected-item").text(); var i = self.container.find(".attendee-selection .dropdown-toggle .selected-item").data("id"); } var ret = {}; ret['name'] = n; ret['id'] = i; return ret; } return { init: init, fetch: fetch, getAttendee: getAttendee } } var MediaModalModule = function() { var init = function(close_callback) { var self = this; self.modal = $("#media-modal"); self.modal.find(".media-modal-close").bind("click", function() { self.modal.hide(); if(typeof(self.player) != 'undefined') { self.player.dispose(); delete self.player; } self.modal.find(".media-modal-content-inner").html(""); $(window).unbind("resize", self.resize); if(self.reloadOnClose) { close_callback(); } }); self.opts = {}; var closethis = function() { self.resize(); }; $(window).unbind("resize", closethis); $(window).bind("resize", closethis); self.expanded = true; } var close = function() { var self = this; self.modal.hide(); if(typeof(self.player) != 'undefined') { self.player.dispose(); delete self.player; } self.modal.find(".media-modal-content-inner").html(""); } var setOpts = function(opts) { var self = this; self.opts = opts; } var resize = function() { var self = this; $(".mediainfo .edit-but").bind("click", function() { $(".mediainfo-display").hide(); $(".mediainfo-edit").show(); }); $(".mediainfo .save-but").bind("click", function() { var params = {}; params['mediafile_id'] = $(".mediafile-id-input").val(); params['name'] = $(".mediafile-name-input").val(); params['description'] = $(".mediafile-description-input").val(); params['public'] = 0; $("#main-overlay").show(); $.ajax({ type: "POST", url: "https://www.thrivsports.com/api/shared/editFile", data: params, dataType: "json", success: function(response) { $("#main-overlay").hide(); if(response['success']) { $(".mediafile-name-disp").text(params['name']); $(".mediafile-description-disp").text(params['description']); $(".mediainfo-display").show(); $(".mediainfo-edit").hide(); self.reloadOnClose = true; } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }); setTimeout(function() { var based = parseInt($(".modalmediaright").css("margin-left")); $("#modalvidcontain").css({ 'width': 'auto', 'height': 'auto', }); $(".modalmedia").css({ 'width': 'auto', 'height': 'auto', 'margin-left': '0px', 'margin-right': '0px' }); if($("#modalvid").length) { var v = document.getElementById("modalvid"); if($(v).data("origwidth") == null) { $(v).data("origwidth", v.videoWidth); } else { v.videoWidth = $(v).data("origwidth"); } if($(v).data("origheight") == null) { $(v).data("origheight", v.videoHeight); } else { v.videoHeight = $(v).data("origheight"); } var w = parseInt(v.videoWidth); var h = parseInt(v.videoHeight); } else { var v = "#modalvidcontain > img"; var w = parseInt($(v).width()); var h = parseInt($(v).height()); } if(based == 0) { $(".modalmediaright").css("overflow-y", "auto"); $(".modalmediaright").css("-webkit-overflow-scrolling", "touch"); $(".modalmediaright").css("height", $("#media-modal .media-modal-content").height()+"px"); //$(".modalmediabottom").css("height", $("#media-modal .media-modal-content").height()+"px"); } else { $(".modalmediaright").css("overflow-y", "hidden"); $(".modalmediaright").css("height", "auto"); } var containerWidth = $("#media-modal .media-modal-content").width() - based; var containerHeight = $("#media-modal .media-modal-content").height(); w_new = containerWidth; h_new = containerHeight; var marginLeft = -Math.round((w_new + based) / 2); var marginTop = -Math.round((h_new) / 2); $("#modalvidcontain").css({ 'width': w_new+'px', 'height': h_new+'px' }); var remainH = $("#modalvidcontain").height() - $("#modalvidcontain > img").height(); var remainW = $("#modalvidcontain").width() - $("#modalvidcontain > img").width(); var marginLeft2 = -Math.round((w_new -remainW) / 2); var marginTop2 = -Math.round((h_new - remainH) / 2); if($("#modalvid").length) { $(v).attr("width", w_new); $(v).attr("height", h_new); } else { $("#modalvidcontain > img").css({ 'position': 'absolute', 'left': '50%', 'top': '50%', 'margin-left': marginLeft2+"px", 'margin-top': marginTop2+"px" }); } /* $("#media-modal .media-modal-content-inner").find('video, audio').each(function() { var player = $(this).data("mediaelementplayer"); if(player == null) { $(this).mediaelementplayer({ pluginPath: 'https://cdnjs.com/libraries/mediaelement/', shimScriptAccess: 'always' }); } var player = $(this).data("mediaelementplayer"); player.setPlayerSize(w_new, h_new); }); */ if($("#modalvid").length) { self.player = videojs(document.getElementById('modalvid')); } $(".modalmedia").css({ 'margin-left': marginLeft+"px", 'margin-top': marginTop+"px" }); $(".modalmedialeft").css({ 'height': (h_new + 100)+"px" }); if($('.modalmedialeft-blocks').length) { var pos = $('.modalmedialeft-blocks').offset().top - $(window).scrollTop(); var hh = $(window).height() - pos; var remain = hh; $(".modalmedialeft-block-content").css("height", "auto"); $(".modalmedialeft-block-title").each(function() { remain -= $(this).outerHeight(); }); $(".modalmedialeft-block-content").each(function() { $(this).data("height", $(this).height()); }); var c = $(".modalmedialeft-block-content").length; var single_height = Math.round(remain / c); var split_between = 0; var extra = 0; $(".modalmedialeft-block-content").each(function() { if($(this).data("height") > single_height) { split_between++; } else { $(this).css("height", $(this).data("height")+"px"); extra += single_height - $(this).data("height"); } }); var extra_for_each = extra / split_between; var single_height_new = single_height + extra_for_each; $(".modalmedialeft-block-content").each(function() { if($(this).data("height") > single_height) { $(this).css("height", single_height_new+"px"); } }); $(".modalmedialeft-block-content .mediaview-media").unbind("click"); $(".modalmedialeft-block-content .mediaview-media").bind("click", function() { var tParams = {}; tParams['mediafile_id'] = $(this).data("id"); self.reqMedia(tParams, {}, function() { }); }); $(".modalmedialeft-block-content .mediaview-locker").unbind("click"); $(".modalmedialeft-block-content .mediaview-locker").bind("click", function(ev) { self.modal.hide(); self.modal.find(".media-modal-content-inner").html(""); }); } setTimeout(function() { $(".modalmedia").css("opacity", "1"); $("#main-overlay").hide(); }, 10); }, 200); } var reqMedia = function(params, extra, callback) { var self = this; $("#main-overlay").show(); var tParams = {}; if(typeof(params['filemanager']) != 'undefined') { tParams['filemanager'] = true; } else { if(typeof(params['mediafile_id']) != 'undefined') { tParams['mediafile_id'] = params['mediafile_id']; if(typeof(self.opts['chat_id']) != 'undefined' && self.opts['chat_id'] != null) { tParams['chat_id'] = self.opts['chat_id']; } if(typeof(self.opts['transcript_id']) != 'undefined' && self.opts['transcript_id'] != null) { tParams['transcript_id'] = self.opts['transcript_id']; } } else { tParams['extra'] = extra; } } if(typeof(self.player) != 'undefined') { self.player.dispose(); delete self.player; } tParams['return'] = window.location.href; $(".modalmedia").css("opacity", "0"); $.ajax({ type: "POST", data: tParams, url: "https://www.thrivsports.com/api/shared/viewMedia/", success: function(response) { var md = response['mediafile']['path']; if(typeof(tParams['filemanager']) != 'undefined') { self.modal.find(".media-modal-content-inner").html(response['html']); $("#media-modal .media-modal-close").hide(); $("#main-overlay").hide(); self.library = new FileManagerModule(); var urls = { 'file_upload': "https://www.thrivsports.com/student/filemanager/fileUpload/", 'library_files': "https://www.thrivsports.com/student/filemanager/libraryFiles", 'file_rename': "https://www.thrivsports.com/student/filemanager/fileRename", 'folder_create': "https://www.thrivsports.com/student/filemanager/folderCreate", 'file_video_thumbs': "https://www.thrivsports.com/student/filemanager/fileVideoThumbs", 'file_edit': "https://www.thrivsports.com/student/filemanager/fileEdit", 'file_edit_submit': "https://www.thrivsports.com/student/filemanager/fileEditSubmit", 'file_move': "https://www.thrivsports.com/student/filemanager/fileMove", 'file_delete': "https://www.thrivsports.com/student/filemanager/fileDelete", }; self.library.init($(".analyze-upload-area .filemanager-lower"), self, urls); self.library.bindInit(); self.library.filterLibrary("videos"); $(".filemanager-cancel-out-but").bind("click", function() { self.close(); }); setTimeout(function() { var mainheight = $(window).height(); var extraheight = $(".analyze-upload-area .filemanager-lower-content-top").outerHeight() + $(".analyze-upload-area .filemanager-lower-content-bottom").outerHeight(); //alert(mainheight); $(".analyze-upload-area .filemanager-lower").css("height", ""+(mainheight - extraheight - 20)+"px"); }, 100); $(".cancel-analyze-but").bind("click", function() { self.modal.hide(); self.modal.find(".media-modal-content-inner").html(""); }); $("#media-modal").show(); $(".modalmedia").css("opacity", "1"); return; } else { $("#media-modal .media-modal-close").show(); self.modal.find(".media-modal-content-inner").html(response['html']); } $(".original-video-but").bind("click", function() { var parent_mediafile_id = $(this).data("id"); var tParams = {}; tParams['mediafile_id'] = parent_mediafile_id; self.reqMedia(tParams, {}, function() { }); }); if($(".modalvid-processing-placeholder").length) { self.resize(); $("#main-overlay").hide(); } else if($("#modalvid").length) { var v = document.getElementById("modalvid"); v.addEventListener("loadedmetadata", function(e) { self.resize(); $("#main-overlay").hide(); }, false); } else { var img = new Image(); img.onload = function(){ $("#main-overlay").hide(); self.resize(); } img.src = md; self.modal.unbind("click"); self.modal.bind("click", function() { self.modal.hide(); }); } $(".moment").each(function() { if(typeof($(this).data("date")) == 'undefined' || $(this).data("date") == null) { if($.trim($(this).text()) != "") { $(this).data("date", $(this).text()); $(this).text(moment.utc($(this).text()).fromNow()); } } else { $(this).text(moment.utc($(this).data("date")).fromNow()); } }); self.modal.show(); self.modal.unbind("click"); }, error: function(response) { alert(JSON.stringify(response)); }, dataType: "json", cache: false }); } var attachFile = function(id) { var self = this; self.attachCallback(id); } var showFiles = function(callback) { var self = this; var params = {}; params['filemanager'] = true; self.attachCallback = callback; self.reqMedia(params, {}, function() { callback(); }); } var showVideo = function(params, extra) { var self = this; self.reqMedia(params, extra, function() { }); } var showAnalysis = function(params, extra) { var self = this; self.reqMedia(params, extra, function() { }); } var showAudio = function(params, extra) { var self = this; self.reqMedia(params, extra, function() { }); /* var e = params['element']; if(e.find(".fa-play").length) { if(typeof(self.audio) != 'undefined' && self.audio != null) { self.audio.pause(); } self.audio = new Audio(params['path']); self.audio.onended = function() { e.click(); }; self.audio.play(); e.find(".fa-play").removeClass("fa-play").addClass("fa-pause"); } else { if(typeof(self.audio) != 'undefined' && self.audio != null) { self.audio.pause(); } e.find(".fa-pause").removeClass("fa-pause").addClass("fa-play"); } */ } var showImage = function(params, extra) { var self = this; self.reqMedia(params, extra, function() { }); } return { init: init, resize: resize, setOpts: setOpts, reqMedia: reqMedia, showVideo: showVideo, showAnalysis: showAnalysis, showImage: showImage, showAudio: showAudio, showFiles: showFiles, attachFile: attachFile, close: close } } var VideoModule = function() { var init = function(e) { var self = this; if(typeof(e) == 'undefined') { e = $(document.body); } self.e = e; self.e.find('video, audio').each(function() { var w = $(this).attr("width"); var h = $(this).attr("height"); $(this).attr("width", "100%"); var w_new = Math.round($(this).width()); var h_new = Math.round(h * (w_new / w)); $(this).attr("height", h_new); $(this).attr("width", w_new); }); self.e.find('video, audio').mediaelementplayer({ pluginPath: 'https://cdnjs.com/libraries/mediaelement/', shimScriptAccess: 'always' }); self.e.find('.like-but').bind("click", function() { var b = $(this); var v = self.e.find(".like-view > span"); var n = parseInt(v.text()); var url = "https://www.thrivsports.com/" + b.data("pro") + "/video/" + b.data("video"); $("#main-overlay").show(); if(b.data("status") == "1") { var params = {}; $.ajax({ type: "POST", data: params, url: url + '/unlike', success: function(response) { $("#main-overlay").hide(); if(response['success']) { b.removeClass("btn-default").addClass("btn-primary"); var str = ''; str += ' Like'; b.html(str); b.data("status", "0"); v.text(n-1); } else { } }, error: function() { $("#main-overlay").hide(); }, dataType: "json", cache: false }); } else { var params = {}; $.ajax({ type: "POST", data: params, url: url + '/like', success: function(response) { $("#main-overlay").hide(); if(response['success']) { b.removeClass("btn-primary").addClass("btn-default"); var str = ''; str += ' Unlike'; b.html(str); b.data("status", "1"); v.text(n+1); } else { } }, error: function() { $("#main-overlay").hide(); }, dataType: "json", cache: false }); } }); if(self.e.find(".like-but").length) { var b = self.e.find('.like-but'); var url = "https://www.thrivsports.com/" + b.data("pro") + "/video/" + b.data("video"); var params = {}; $.ajax({ type: "POST", data: params, url: url + '/getLike', success: function(response) { if(response['success']) { if(response['like']) { b.removeClass("btn-primary").addClass("btn-default"); var str = ''; str += ' Unlike'; b.html(str); b.data("status", "1"); } else { b.removeClass("btn-default").addClass("btn-primary"); var str = ''; str += ' Like'; b.html(str); b.data("status", "0"); } } else { b.remove(); } }, error: function() { b.remove(); }, dataType: "json", cache: false }); } }; return { init: init }; }; var VideoModalModule = function() { var init = function(video_key) { var self = this; self.modal = new ModalModule(); self.modal.init(true); var params = {}; params['video_key'] = video_key; self.modal.open("https://www.thrivsports.com/view/watchVideo", params, function() { var v = VideoModule(); v.init($("#flush-modal")); }); }; return { init: init }; }; var WebSocketModule = function() { var init = function(opts) { var self = this; self.opts = opts; self.retries = 0; self.openSocket(); }; var openSocket = function() { var self = this; window.WebSocket = window.WebSocket || window.MozWebSocket; if (!window.WebSocket) { return false; } self.connection = new WebSocket(self.opts['url']); self.connection.onopen = function() { try { if(typeof(self.opts['connected']) != 'undefined') { self.opts['connected'](); } } catch(err) { console.log("Failed to open websocket ("+err.name+": "+err.message+")"); } }; self.connection.onerror = function(error) { try { if(typeof(self.opts['error']) != 'undefined') { self.opts['error'](error); } } catch(err) { console.log("Failed to process websocket error ("+err.name+": "+err.message+")"); } }; self.connection.onmessage = function(message) { try { if(typeof(self.opts['message']) != 'undefined') { self.opts['message'](message); } else { console.log("we hit else"); } } catch(err) { console.log("Failed to receive websocket message ("+err.name+": "+err.message+")"); } }; self.connection.onclose = function() { try { //if connection lost, keep retrying if(typeof(self.retry_timer) != 'undefined') { clearTimeout(self.retry_timer); } if(self.retries < 5) { self.retry_timer = setTimeout(function() { self.openSocket(); }, 5000); self.retries++; } else { if(typeof(self.opts['disconnected']) != 'undefined') { self.opts['disconnected'](); } } } catch(err) { console.log("Failed to close websocket ("+err.name+": "+err.message+")"); } }; }; var setOpts = function(opts) { var self = this; if(typeof(opts['message']) != 'undefined') { self.opts['message'] = opts['message']; } }; var send = function(message) { var self = this; try { if(typeof(message['user_id']) == 'undefined') { message['user_id'] = self.opts['user_id']; } var packed = JSON.stringify(message); self.connection.send(packed); } catch(err) { console.log("Failed to send message through websocket ("+err.name+": "+err.message+")"); } }; return { init: init, openSocket: openSocket, send: send, setOpts: setOpts }; }; var ItemSelectorModule = function() { var init = function(e, opts) { var self = this; if(typeof(e) != 'undefined') { self.e = e; self.e.find(".program-item-dropdown-menu-lesson").data("itemselector", self); self.opts = opts; if(self.e.find(".selected-item").length) { self.bindTpl(); } else { self.e.append('

Loading...

'); self.tpl(); } } } var tpl = function() { var self = this; if(typeof(self.itemReq) != 'undefined') { clearTimeout(self.itemReq); } var params = {}; self.itemReq = $.ajax({ type: "GET", data: params, url: "https://www.thrivsports.com/coach/itemselector/view", success: function(response) { if(response['success']) { self.e.html(response['html']); self.bindTpl(); } }, error: function() { }, dataType: "json", cache: false }); } var bindTpl = function() { var self = this; self.e.find(".item-finder-search input").bind("keyup", function() { self.fetch($(this).val()); }); self.fetch(""); } var fetch = function(v) { var self = this; if(self.opts['type'] == "lessons") { self.fetchLessons(v); } else { self.fetchEvents(v); } } var fetchLessons = function(v) { var self = this; if(typeof(self.itemReq) != 'undefined') { clearTimeout(self.itemReq); } var params = {}; params['term'] = v; self.e.find(".item-finder-results .item-finder-loader").show(); self.itemReq = $.ajax({ type: "GET", data: params, url: "https://www.thrivsports.com/coach/itemselector/lessons", success: function(response) { self.e.find(".item-finder-results .item-finder-loader").hide(); if(response['success']) { self.e.find(".item-finder-results > ul").html(response['html']); self.bindItems(); } }, error: function() { self.e.find(".item-finder-results .item-finder-loader").hide(); }, dataType: "json", cache: false }); } var fetchEvents = function(v) { var self = this; if(typeof(self.itemReq) != 'undefined') { clearTimeout(self.itemReq); } var params = {}; params['term'] = v; self.e.find(".item-finder-results .item-finder-loader").show(); self.itemReq = $.ajax({ type: "GET", data: params, url: "https://www.thrivsports.com/coach/itemselector/events", success: function(response) { self.e.find(".item-finder-results .item-finder-loader").hide(); if(response['success']) { self.e.find(".item-finder-results > ul").html(response['html']); self.bindItems(); } }, error: function() { self.e.find(".item-finder-results .item-finder-loader").hide(); }, dataType: "json", cache: false }); } var bindItems = function() { var self = this; if(typeof(self.opts['id']) != 'undefined' && self.opts['id'] != null) { self.e.find(".selected-item").attr("data-id", self.opts['id']); self.opts['id'] = null; } self.e.find(".item-finder-results li a[data-id]").bind("click", function() { self.e.find(".selected-item").html($(this).html()); self.e.find(".selected-item").attr("data-id", $(this).data("id")); }); if(self.getSelectedItem() == null) { self.e.find(".item-finder-results > ul li").first().find("a").click(); } if(self.e.find(".selected-item").attr("data-id") != null && self.e.find(".selected-item").attr("data-id") != '') { var id = self.e.find(".selected-item").attr("data-id"); self.e.find(".item-finder-results li a[data-id='"+id+"']").click(); } else if (self.e.closest(".program-item-value-choose").attr("data-id") != null && self.e.closest(".program-item-value-choose").attr("data-id") != '') { var id = self.e.closest(".program-item-value-choose").attr("data-id"); self.e.find(".item-finder-results li a[data-id='"+id+"']").click(); } else if (self.e.closest(".program-item-value-choose").attr("data-golfer") != null && self.e.closest(".program-item-value-choose").attr("data-golfer") != '') { var golfer = self.e.closest(".program-item-value-choose").attr("data-golfer"); var studentCount = self.e.closest(".program-item-value-choose").attr("data-studentcount"); var lesson = self.e.closest(".program-item-value-choose").attr("data-lesson"); var duration = self.e.closest(".program-item-value-choose").attr("data-duration"); var title = self.e.closest(".program-item-value-choose").attr("data-title").replace(/'/g, "'").replace(/"/g, '"'); self.e.find(".item-finder-results li").each(function(){ if ( $(this).find('.gmd-lesson-item-golfer-type').attr("data-golfer") == golfer && $(this).find('.gmd-lesson-item-student-count').attr("data-studentcount") == studentCount && ( $(this).find('.gmd-lesson-item-lesson-type').attr("data-lesson") == 'undefined' || $(this).find('.gmd-lesson-item-lesson-type').attr("data-lesson") == null || $(this).find('.gmd-lesson-item-lesson-type').attr("data-lesson") == lesson ) && $(this).find('.gmd-lesson-item-duration').attr("data-duration") == duration && $(this).find('.lesson-title').text().trim().replace(/'/g, "'").replace(/"/g, '"') == title ) { var id = $(this).find("a").attr("data-id"); self.e.find(".item-finder-results li a[data-id='" + id + "']").click(); return false; } }); } } var getSelectedItem = function() { var self = this; return self.e.find(".selected-item").attr("data-id"); } return { init: init, tpl: tpl, bindTpl: bindTpl, fetch: fetch, fetchLessons: fetchLessons, fetchEvents: fetchEvents, bindItems: bindItems, getSelectedItem: getSelectedItem } }; var FileSelectorModule = function() { var init = function(e, params) { var self = this; self.mediaview = new MediaModalModule(); self.mediaview.init(); self.params = params; self.e = e; self.e.html('

Loading...

'); self.o = new FileManagerModule(); self.urls = params['urls']; if(typeof(params['callbacks']) != 'undefined') { self.callbacks = params['callbacks']; } else { self.callbacks = {}; } self.filter = e.data("fileselector"); self.max_count = e.data("max"); self.crop = e.data("aspect"); self.layout = e.data("layout"); self.sizes = e.data("sizes"); self.view = e.data("view"); self.sortable = e.data("sortable"); if(self.view == null) { self.view = ''; } if( (e.data("ids") != null && e.data("ids") != "") || (e.attr("data-ids") != null && e.attr("data-ids") != "") ) { var str = '' + e.data("ids"); if ( str == '' ) { str = '' + e.attr("data-ids"); } var ids = str.split(","); self.fetchItems(ids); } else { self.selected_items = {}; self.bindItems(); } /* $(window).bind("resize", function() { self.e.find(".selected-files .filemanager-attachment").each(function() { if($(this).data("aspect") != null) { var aspe = parseFloat($(this).data("aspectnumeric")); var image = $(this).find("img"); var w = $(this).width(); var h = w * (1 / aspe); //image.css("height", h+"px"); //$(this).data("cropper").destroy(); //console.log(w+", "+h); } }); }); */ } var fetchItems = function(ids) { var self = this; var params = {}; params['ids'] = ids; $.ajax({ type: "POST", url: "https://www.thrivsports.com/api/shared/fetchMediafiles", data: params, dataType: "json", success: function(response) { if(response['success']) { self.selected_items = response['data']['items']; for(var j in self.selected_items) { var other_srcs = generateAllSources(self.selected_items[j]['src']); for(var i in other_srcs) { self.selected_items[j][i] = other_srcs[i]; } } self.e.data("ids", ids.join(",")); self.bindItems(); } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { swal({ title: "Error", text: "error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var bindItems = function() { var self = this; self.e.find(".fileselector-loader").hide(); var str = ''; str += '

'; str += ''; str += '

'; str += '

'; self.e.append(str); self.e.find(".box__input").unbind("click"); self.e.find(".box__input").bind("click", async function() { /* For fucks sake why does this controller need to do multiple things at once! If there is an input with the id of file-upload-input2 we open the selector and sim a click on the input. If there is no input, we ask for files from the user and provide the files. We have to do it like this so that this works on media upload, lockers, event/membership creation. This is so convoluted why do it this way! -Isaac */ var fileUploadTwo = $('#file-upload-input2'); if(fileUploadTwo){ self.openSelector(); fileUploadTwo.trigger('click'); } else { var filesFromUser = await askForFileFromUser(); self.openSelector(filesFromUser); } }); if($(".file-selector-modal").length == 0) { var str = ''; str += '

'; $(document.body).append(str); } $("#file-upload-input2").unbind("change"); $("#file-upload-input2").bind("change", function(ev) { self.openSelector(ev.target.files); }); self.e.find(".box__input") .on( 'drag dragstart dragend dragover dragenter dragleave drop', function( e ) { // preventing the unwanted behaviours e.preventDefault(); e.stopPropagation(); }) .on( 'dragover dragenter', function() // { self.e.find(".box__input").addClass( 'is-dragover' ); }) .on( 'dragleave dragend drop', function() { self.e.find(".box__input").removeClass( 'is-dragover' ); }) .on( 'drop', function( e ) { if(typeof(e.originalEvent.dataTransfer) != 'undefined') { self.openSelector(e.originalEvent.dataTransfer.files); } }); self.selectItems(self.selected_items); } /* @params fs: files */ var openSelector = function(fs) { var self = this; self.e.find(".fileselector-loader").show(); var params = {}; $.ajax({ type: "POST", url: self.urls['container'], data: params, dataType: "json", success: function(response) { if(response['success']) { $(".file-selector-modal").html(response['html']); $("html, body").css("overflow", "hidden"); $(".file-selector-modal").show(); $(".filemanager-selector-close-btn").bind("click", function() { $("html, body").css("overflow", "auto"); $(".file-selector-modal").hide(); }); var callbacks = {}; var spec = function() { var mainheight = $(window).height(); var extraheight = $(".filemanager-lower-content-outer").outerHeight() + $(".filemanager-selector-title").outerHeight(); var newheight = mainheight - extraheight; $(".filemanager-lower").css("max-height", newheight+"px"); $(".filemanager-lower").css("min-height", newheight+"px"); $(".filemanager-lower").css("height", newheight+"px"); }; callbacks['library'] = function() { spec(); } callbacks['select'] = function() { spec(); } callbacks['insert'] = function(items) { $(".file-selector-modal").hide(); $("html, body").css("overflow", "auto"); self.selectItems(items); } $(window).bind("resize", function() { spec(); }); var extra = {}; extra['selector'] = true; extra['selected_items'] = self.selected_items; extra['system_tree'] = response['system_tree']; extra['max_selected'] = self.max_count; extra['sizes'] = self.sizes; $(".filemanager-lower").css("overflow", "auto"); self.o.init($(".filemanager-lower"), null, self.urls, callbacks, extra); self.o.bindInit(); //self.o.viewLibrary("thumbnail"); //console.log(JSON.stringify(self.selected_items)); if(typeof(fs) != 'undefined') { self.o.fetchUploadView(fs); } else { self.o.filterLibrary(self.filter); } self.o.generateSelections(); if(self.filter != "all") { $(".filemanager-filter-toggler").hide(); } } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } self.e.find(".fileselector-loader").hide(); }, error: function() { self.e.find(".fileselector-loader").hide(); } }); } var selectItems = function(items) { var self = this; //console.log(JSON.stringify(items)); self.selected_items = items; var c = 0; var str = ''; if(self.layout != null) { var col_config = self.layout; } else if(self.max_count == 1) { var col_config = 'col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12'; } else if(self.max_count == 2) { var col_config = 'col-xs-6 col-sm-6 col-md-6 col-lg-6 col-xl-6'; } else if(self.max_count == 3) { var col_config = 'col-xs-6 col-sm-6 col-md-6 col-lg-4 col-xl-4'; } else { var col_config = 'col-xs-6 col-sm-6 col-md-6 col-lg-4 col-xl-3'; } self.num_to_crop = 0; self.e.find(".selected-files .filemanager-attachment").each(function() { if(typeof(self.selected_items[$(this).data("index")]) == 'undefined') { if($(this).data("cropper") != null) { $(this).data("cropper").destroy(); } $(this).closest(".filemanager-attachment-col").remove(); } }); for(var i in self.selected_items) { var o = self.selected_items[i]; if(self.e.find(".selected-files .filemanager-attachment[data-id='" + o['id'] + "']").length) { continue; } var typ = o['type']; str += '

'; if(self.crop != null && typ == "image") { var expl = self.crop.split(":"); var w = expl[0]; var h = expl[1]; var aspe = parseInt(w) / parseInt(h); str += '

'; str += 'Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (19)'; str += '

'; str += ''; str += '

'; str += 'Remove'; str += 'Reset'; str += ' Save'; str += '

'; str += '

'; self.num_to_crop++; } else { str += '

'; str += '

'; if(typ == "image") { str += '

'; //str += ''; str += '

'; } else if(typ == "video") { str += '

'; str += ''; str += '

'; } else if(typ == "analysis") { str += '

'; str += ''; str += '

'; } else if(typ == "audio") { str += '

'; str += ''; str += '

'; } else if(typ == "text") { str += '

'; str += ''; str += '

'; } else if(typ == "pdf") { str += '

'; str += ''; str += '

'; } else { str += '

'; str += ''; str += '

'; } str += ''; str += '

'; str += 'Remove'; str += '

'; str += '

'; } str += '

'; str += '

'; c++; } if(c > 0) { self.e.find(".selected-files").append(str); if(typ == "image") { verifyBGImg(self.e.find(".selected-files .filemanager-attachment-inner")); } if(self.num_to_crop > 0) { self.e.find(".fileselector-loader").show(); } self.e.find(".selected-files .filemanager-attachment").each(function() { if($(this).data("aspect") != null && $(this).data("cropper") == null) { var aspe = parseFloat($(this).data("aspectnumeric")); var image = $(this).find("img"); var w = image.width(); var h = w * (1 / aspe); image.css("height", h+"px"); var dt = { viewMode: 3, dragMode: 'move', autoCropArea: 1, aspectRatio: aspe, initialAspectRatio: aspe, restore: true, modal: false, guides: false, highlight: false, cropBoxMovable: false, cropBoxResizable: false, toggleDragModeOnDblclick: false, responsive: true, center: false, rotatable: true, autoCrop: true, ready: function() { self.num_to_crop--; if(self.num_to_crop == 0) { self.e.find(".fileselector-loader").hide(); } var att = $(this).closest(".filemanager-attachment"); att.find("img").css("opacity", "1"); if(att.data("cropdata") != null) { var canvas_data = att.data("cropdata"); if(typeof(canvas_data) != 'undefined') { this.cropper.setCanvasData(canvas_data['canvas_data']); } } if(typeof(self.callbacks['updated']) != 'undefined') { self.callbacks['updated'](self.getSelectionsExpanded()); } return true; }, zoom: function(event) { var att = $(this).closest(".filemanager-attachment"); att.find(".filemanager-attachment-crop-save-btn").show(); att.find(".filemanager-attachment-crop-reset-btn").show(); att.removeClass("filemanager-attachment-crop").addClass("filemanager-attachment-cropped"); }, cropend: function(event) { var att = $(this).closest(".filemanager-attachment"); att.find(".filemanager-attachment-crop-save-btn").show(); att.find(".filemanager-attachment-crop-reset-btn").show(); att.removeClass("filemanager-attachment-crop").addClass("filemanager-attachment-cropped"); } /* zoom: function(event) { var r = ((event.detail.ratio) * 100) + 100; var inpi = $(this).closest(".filemanager-attachment").find("input[type='range']"); if(inpi.data("update") == null) { inpi.val(r); } } */ }; //console.log(JSON.stringify(self.selected_items[$(this).data("id")])); if(typeof(self.selected_items[$(this).data("id")]['crop_data']) != 'undefined' && self.selected_items[$(this).data("id")]['crop_data'] != null && self.selected_items[$(this).data("id")]['crop_data'] != "") { $(this).data("cropdata", self.selected_items[$(this).data("id")]['crop_data']); var crop_data = self.selected_items[$(this).data("id")]['crop_data']['data']; if(typeof(self.selected_items[$(this).data("id")]['crop_data']['crop_data']) != 'undefined') { var box_data = self.selected_items[$(this).data("id")]['crop_data']['crop_data']; for(var i in box_data) { box_data[i] = parseInt(box_data[i]); } } if(typeof(self.selected_items[$(this).data("id")]['crop_data']['canvas_data']) != 'undefined') { var canvas_data = self.selected_items[$(this).data("id")]['crop_data']['canvas_data']; for(var i in canvas_data) { canvas_data[i] = parseFloat(canvas_data[i]); } } delete crop_data['aspect_ratio']; for(var i in crop_data) { crop_data[i] = parseInt(crop_data[i]); } //dt['data'] = crop_data; } var cropper = new Cropper(image[0], dt); $(this).data("cropper", cropper); $(this).find(".filemanager-attachment-crop-save-btn").bind("click", function() { var att = $(this).closest(".filemanager-attachment"); var cropper = att.data("cropper"); var dt = cropper.getData(); var crp = cropper.getCropBoxData(); var cnv = cropper.getCanvasData(); var img = cropper.getImageData(); dt['aspect_ratio'] = att.data("aspect"); var params = {}; params['mediafile_id'] = att.data("id"); var box_data = {}; box_data['data'] = dt; box_data['crop_data'] = crp; box_data['canvas_data'] = cnv; box_data['image_data'] = img; params['crop_data'] = box_data; if(typeof(self.sizes) != 'undefined') { params['sizes'] = self.sizes; } //console.log(JSON.stringify(dt)); //return; self.e.find(".fileselector-loader").show(); $.ajax({ type: "POST", url: "https://www.thrivsports.com/api/shared/cropMediafile", data: params, dataType: "json", success: function(response) { self.e.find(".fileselector-loader").hide(); if(response['success']) { //att.data("croppedid", response['data']['mediafile_id']); var source_id = att.data("id"); var mediafile_id = response['data']['mediafile']['mediafile_id']; var newpath = response['data']['mediafile']['path']; if(source_id != mediafile_id) { self.selected_items[mediafile_id] = {}; for(var i in self.selected_items[source_id]) { self.selected_items[mediafile_id][i] = self.selected_items[source_id][i]; } self.selected_items[mediafile_id]['id'] = mediafile_id; self.selected_items[mediafile_id]['source_id'] = source_id; self.selected_items[mediafile_id]['source_src'] = self.selected_items[mediafile_id]['src'] self.selected_items[mediafile_id]['src'] = newpath; var other_srcs = generateAllSources(newpath); for(var i in other_srcs) { self.selected_items[mediafile_id][i] = other_srcs[i]; } delete self.selected_items[source_id]; } att.data("id", mediafile_id); att.find(".filemanager-attachment-crop-reset-btn").hide(); att.find(".filemanager-attachment-crop-save-btn").hide(); att.removeClass("filemanager-attachment-cropped").addClass("filemanager-attachment-saved"); if(typeof(self.callbacks['updated']) != 'undefined') { self.callbacks['updated'](self.getSelectionsExpanded()); } setTimeout(function() { att.removeClass("filemanager-attachment-saved").addClass("filemanager-attachment-crop"); }, 5000); } else { swal({ title: "Error", text: response['error_msg'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.e.find(".fileselector-loader").hide(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }); $(this).find(".filemanager-attachment-crop-reset-btn").bind("click", function() { var att = $(this).closest(".filemanager-attachment"); att.data("cropper").reset(); att.find(".filemanager-attachment-crop-reset-btn").hide(); att.removeClass("filemanager-attachment-cropped").addClass("filemanager-attachment-crop"); }); /* var zm = $(this).find(".filemanager-attachment-zoom input[type='range']"); zm.bind("mousedown", function() { $(this).data("update", true); }); zm.bind("mouseup", function() { $(this).data("update", null); }); zm.bind("input", function() { if($(this).data("update") != null) { var v = ($(this).val() - 100) / 100; var cropper = $(this).closest(".filemanager-attachment").data("cropper"); const containerData = cropper.getContainerData(); $(this).data("noupdate", true); // Zoom to 50% from the center of the container. cropper.zoomTo(v, { x: containerData.width / 2, y: containerData.height / 2, }); } }); */ } else if(typeof($(this).data("cropper")) != 'undefined') { if(typeof(self.selected_items[$(this).data("id")]['crop_data']) != 'undefined' && self.selected_items[$(this).data("id")]['crop_data'] != null && self.selected_items[$(this).data("id")]['crop_data'] != "") { $(this).data("cropdata", self.selected_items[$(this).data("id")]['crop_data']); var crop_data = self.selected_items[$(this).data("id")]['crop_data']['data']; if(typeof(self.selected_items[$(this).data("id")]['crop_data']['crop_data']) != 'undefined') { var box_data = self.selected_items[$(this).data("id")]['crop_data']['crop_data']; for(var i in box_data) { box_data[i] = parseInt(box_data[i]); } } if(typeof(self.selected_items[$(this).data("id")]['crop_data']['canvas_data']) != 'undefined') { var canvas_data = self.selected_items[$(this).data("id")]['crop_data']['canvas_data']; for(var i in canvas_data) { canvas_data[i] = parseFloat(canvas_data[i]); } } delete crop_data['aspect_ratio']; for(var i in crop_data) { crop_data[i] = parseInt(crop_data[i]); } if(typeof(canvas_data) != 'undefined') { $(this).data("cropper").setCanvasData(canvas_data); } $(this).data("cropper").setData(crop_data); } } }); self.e.find(".filemanager-attachment-crop-remove-btn").unbind("click"); self.e.find(".filemanager-attachment-crop-remove-btn").bind("click", function() { var att = $(this).closest(".filemanager-attachment"); swal({ title: "Confirm Action", text: "Are you sure you want to remove that media item?", type: "warning", showCancelButton: true, confirmButtonClass: 'btn-primary waves-effect waves-light', confirmButtonText: 'Yes' }, function (isConfirm) { if(isConfirm) { delete self.selected_items[att.data("id")]; att.closest(".filemanager-attachment-col").remove(); if(self.e.find(".selected-files").children().length) { self.e.find(".file-choose-btn").hide(); } else { self.e.find(".file-choose-btn").show(); } } }); }); self.e.find(".filemanager-attachment-preview-element").unbind("click"); self.e.find(".filemanager-attachment-preview-element").bind("click", function() { if($(this).hasClass("filemanager-attachment")) { var over = $(this); } else { var over = $(this).closest(".filemanager-attachment"); } var tParams = {}; tParams['mediafile_id'] = over.data("id"); self.mediaview.reqMedia(tParams, {}, function() { }); }); } self.e.find(".selected-files .filemanager-attachment").bind("click", function(ev) { ev.stopPropagation(); }); if(self.e.find(".selected-files").children().length) { self.e.find(".file-choose-btn").hide(); } else { self.e.find(".file-choose-btn").show(); } if(self.sortable != null && self.e.find(".selected-files").children().length > 1) { self.e.find(".selected-files .filemanager-attachment-col").addClass("filemanager-attachment-col-sortable"); self.e.find(".selected-files").sortable({ scroll: false, containment: "parent", helper: "clone", cursor: "move", start: function(ev, ui) { ui.placeholder.html('

'); }, tolerance: "intersect" }); self.e.find(".selected-files").disableSelection(); } /* if(typeof(self.callbacks['updated']) != 'undefined') { self.callbacks['updated'](self.getSelectionsExpanded()); } */ } var getSelections = function() { var self = this; var id_arr = []; self.e.find(".selected-files .filemanager-attachment").each(function() { var id = $(this).data("id"); id_arr.push(id); }); /* for(var i in self.selected_items) { var id = self.selected_items[i]['id']; id_arr.push(id); } */ return id_arr; } var getSelectionsExpanded = function(callback) { var self = this; var id_arr = []; self.e.find(".selected-files .filemanager-attachment").each(function() { var id = $(this).data("id"); var src = $(this).data("src"); var o = {}; o['id'] = id; o['src'] = src; id_arr.push(o); }); if(typeof(callback) != 'undefined') { callback(id_arr); } else { return id_arr; } } var adjustPosition = function() { var self = this; self.init(self.e, self.params); } return { init: init, openSelector: openSelector, selectItems: selectItems, fetchItems: fetchItems, bindItems: bindItems, getSelections: getSelections, getSelectionsExpanded: getSelectionsExpanded, adjustPosition: adjustPosition } } var FileManagerModule = function() { var init = function(container, obj, urls, callbacks, extra) { var self = this; if(typeof(obj) != 'undefined' && obj != null) { self.obj = obj; } else { self.obj = null; } self.page = 1; self.num_per_page = 50; self.fetching = false; if(typeof(callbacks) == 'undefined' || callbacks == null) { self.callbacks = {}; } else { self.callbacks = callbacks; } if(typeof(extra) == 'undefined' || extra == null) { self.extra = {}; } else { self.extra = extra; } if(typeof(self.extra['scroll']) == 'undefined') { self.extra['scroll'] = ".filemanager .filemanager-lower"; } if(typeof(self.extra['selector']) != 'undefined') { self.selector = self.extra['selector']; } else { self.selector = false; } self.urls = urls; self.container = container; self.selected_items = {}; } var selectItem = function(e) { var self = this; e.addClass("filemanager-item-selected"); if(e.data("sourcepath") != null) { var source_path = e.data("sourcepath"); } else { var source_path = e.data("path"); } if(e.data("sourceid") != null) { var source_id = e.data("sourceid"); } else { var source_id = e.data("id"); } self.selected_items[e.data("id")] = { 'id': e.data("id"), 'preview': e.data("previewpath"), 'type': e.data("type"), 'timestamp': Date.now(), 'src': e.data("path"), 'source_id': source_id, 'source_src': source_path }; var other_srcs = generateAllSources(e.data("path")); for(var i in other_srcs) { self.selected_items[e.data("id")][i] = other_srcs[i]; } if(e.data("cropdata") != null && e.data("cropdata") != "") { self.selected_items[e.data("id")]['crop_data'] = e.data("cropdata"); } self.generateSelections(); if(typeof(self.extra['max_selected']) != 'undefined' && $(".filemanager-lower-content-actions-selected-items .filemanager-attachment").length > parseInt(self.extra['max_selected'])) { var current_min = null; var current_item = null; for(var i in self.selected_items) { if(self.selected_items[i]['timestamp'] < current_min || current_item == null) { current_item = i current_min = self.selected_items[i]['timestamp']; } } $(".filemanager-item-selected[data-id='" + self.selected_items[current_item]['id'] + "']").removeClass("filemanager-item-selected"); delete self.selected_items[current_item]; self.generateSelections(); } } var selectItemById = function(id, callback) { var self = this; var params = {}; params['mediafile_id'] = id; $.ajax({ type: "GET", url: "https://www.thrivsports.com/api/shared/fetchMediafile/", data: params, dataType: "json", success: function(response) { if(response['success']) { var md = response['data']['mediafile']; self.selected_items[md['mediafile_id']] = { 'id': md['mediafile_id'], 'preview': md['preview_path'], 'type': md['type'], 'timestamp': Date.now(), 'src': md['path'], 'source_id': md['source_mediafile_id'], 'source_src': md['source_path'], 'crop_data': md['crop_data'] }; var other_srcs = generateAllSources(md['path']); for(var i in other_srcs) { self.selected_items[md['mediafile_id']][i] = other_srcs[i]; } self.generateSelections(); if(typeof(self.extra['max_selected']) != 'undefined' && $(".filemanager-lower-content-actions-selected-items .filemanager-attachment").length > parseInt(self.extra['max_selected'])) { var current_min = null; var current_item = null; for(var i in self.selected_items) { if(self.selected_items[i]['timestamp'] < current_min || current_item == null) { current_item = i current_min = self.selected_items[i]['timestamp']; } } $(".filemanager-item-selected[data-id='" + self.selected_items[current_item]['id'] + "']").removeClass("filemanager-item-selected"); delete self.selected_items[current_item]; self.generateSelections(); } if(typeof(callback) != 'undefined') { callback(); } } else { } }, error: function() { } }); } var deselectItem = function(e) { var self = this; e.removeClass("filemanager-item-selected"); delete self.selected_items[e.data("id")]; self.generateSelections(); } var generateSelections = function() { var self = this; var str = ''; var c = 0; $(".filemanager-lower-content-actions-selected-items .filemanager-attachment").each(function() { if(typeof(self.selected_items[$(this).data("id")]) == 'undefined') { $(this).parent().remove(); } }); if(self.extra['max_selected'] == 1) { var col_config = 'col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12'; var source_index = 'src'; } else if(self.extra['max_selected'] == 2) { var col_config = 'col-xs-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'; var source_index = 'src'; } else if(self.extra['max_selected'] == 3) { var col_config = 'col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-4'; var source_index = 'src'; } else { var col_config = 'col-xs-12 col-sm-6 col-md-6 col-lg-4 col-xl-3'; var source_index = 'preview'; } for(var i in self.selected_items) { var o = self.selected_items[i]; if($(".filemanager-lower-content-actions-selected-items .filemanager-attachment[data-id='" + o['id'] + "']").length == 0) { var typ = o['type']; str += '

'; str += '

'; str += '

'; str += ''; str += '

'; str += '

'; if(typ == "image") { str += '

'; //str += ''; str += '

'; } else if(typ == "video") { str += '

'; str += ''; str += '

'; } else if(typ == "analysis") { str += '

'; str += ''; str += '

'; } else if(typ == "audio") { str += '

'; str += ''; str += '

'; } else if(typ == "text") { str += '

'; str += ''; str += '

'; } else if(typ == "pdf") { str += '

'; str += ''; str += '

'; } else { str += '

'; str += ''; str += '

'; } str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; } c++; } $(".filemanager-lower-content-actions-selected-count").text(c); $(".filemanager-lower-content-actions-selected-items").append(str); $(".filemanager-lower-content-actions-selected-items .filemanager-attachment").unbind("click"); $(".filemanager-lower-content-actions-selected-items .filemanager-attachment").bind("click", function(ev) { ev.stopPropagation(); delete self.selected_items[$(this).data("id")]; $(".filemanager-item-selected[data-id='" + $(this).data("id") + "']").removeClass("filemanager-item-selected"); self.generateSelections(); }); if(typeof(self.callbacks['select']) != 'undefined') { self.callbacks['select'](); } } var bindInit = function() { var self = this; if(typeof(self.extra['selected_items']) != 'undefined') { self.selected_items = self.extra['selected_items']; } $(".filemanager .filemanager-insert-but").bind("click", function() { if(typeof(self.callbacks['insert']) != 'undefined') { self.callbacks['insert'](self.selected_items); } }); self.bindLibrary(); $(".filemanager .filemanager-lower-activate a").bind("click", function() { $(".filemanager .filemanager-lower-activate").hide(); $(".filemanager .filemanager-lower-content").show(); }); $(".filemanager .filemanager-done-but").bind("click", function() { $(".filemanager .filemanager-lower-activate").show(); $(".filemanager .filemanager-lower-content").hide(); }); $(".filemanager .filemanager-folder-new").bind("click", function() { $(".filemanager .filemanager-item-folder-new").show(); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").val(""); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").focus(); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").unbind("blur"); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").bind("blur", function(ev) { ev.stopPropagation(); ev.preventDefault(); if($(this).val() == "") { $(".filemanager .filemanager-item-folder-new").hide(); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").unbind("blur"); } }); }); $(".filemanager .filemanager-search input").bind("keyup", function() { var v = $(this).val(); if($.trim(v) == "") { self.searchLibrary(""); //$(".filemanager .filemanager-search .searchy-but").addClass("btn-inverse").removeClass("btn-default"); $(".filemanager .filemanager-search .searchy-but").html(''); } else { self.searchLibrary($(this).val()); //$(".filemanager .filemanager-search .searchy-but").addClass("btn-default").removeClass("btn-inverse"); $(".filemanager .filemanager-search .searchy-but").html(''); } }); $(".filemanager .filemanager-search button").bind("click", function() { if(!$(this).hasClass("dropdown-toggle")) { $(".filemanager .filemanager-search input").val(""); self.searchLibrary(""); //$(".filemanager .filemanager-search .searchy-but").addClass("btn-inverse").removeClass("btn-default"); $(".filemanager .filemanager-search .searchy-but").html(''); } }); $(".filemanager .filemanager-sort a").bind("click", function() { var s = $(this).data("sort"); var d = $(this).data("direction"); if($(this).find("i").length) { self.sortLibrary(null, null); $(this).find("i").remove(); } else { self.sortLibrary(s, d); $(".filemanager .filemanager-sort a i").remove(); $(this).prepend(' '); } }); $(".filemanager .filemanager-filter a").bind("click", function() { $(this).closest(".btn-group").find(".dropdown-toggle").html($(this).html()); self.filterLibrary($(this).data("filter")); }); $(".filemanager .filemanager-view a").bind("click", function() { $(this).closest(".btn-group").find(".dropdown-toggle").html($(this).html()); self.viewLibrary($(this).data("view")); }); $('#file-upload-input').unbind("change"); $('#file-upload-input').bind("change", function() { if ($('#file-upload-input').get(0).files.length) { //show progress bar $(".filemanager .filemanager-upload-area").show(); $(".filemanager-upload-area-actions").hide(); $(".filemanager-upload-area-progress").show(); var formData = new FormData(); formData.append('file', $('#file-upload-input')[0].files[0]); if(typeof(self.folder_id) != 'undefined') { formData.append('mediafolder_id', self.folder_id); } $.ajax({ xhr: function() { var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener("progress", function(evt) { if (evt.lengthComputable) { var percentComplete = Math.round(evt.loaded / evt.total * 100); //Do something with upload progress here $(".filemanager-upload-progress").find(".progress-bar").css("width", percentComplete+"%"); $(".filemanager-upload-progress-text").html("Uploading - "+percentComplete+"%"); } }, false); xhr.addEventListener("progress", function(evt) { if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; //Do something with download progress } }, false); return xhr; }, url: self.urls['file_upload']+'?mediafolder_id='+self.folder_id, type: 'POST', data: formData, dataType: "json", processData: false, contentType: false, success: function(response) { if(response['success']) { self.upload_mediafile_id = response['mediafile_id']; self.upload_name = response['name']; $(".filemanager .filemanager-upload-edit-field").val(self.upload_name); $(".filemanager-upload-progress-text").html("Done. Please wait..."); setTimeout(function() { $(".filemanager .filemanager-upload-area-progress").hide(); self.editFile(self.upload_mediafile_id); }, 2000); } else { $(".filemanager-upload-progress-text").html(response['error_code']); } } }); } }); $(".filemanager .filemanager-upload-but").unbind("click"); $(".filemanager .filemanager-upload-but").bind("click", function() { //$('#file-upload-input').trigger('click'); self.fetchUploadView(); }); self.noscroll = null; //infinite scroll $(self.extra['scroll']).on("scroll", function() { if(self.noscroll == null && self.fetching == false && self.last_num > 0) { if($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) { self.previousScroll = $(this).scrollTop(); self.startLoad($(".filemanager .filemanager-lower"), true); self.page++; self.fetchLibrary(); } } }); //maybe need to put back in bindLibrary? $(document).on('mousedown', function(){ //$("*").popover('hide'); }); /* $(".filemanager-lower, .filemanager-upper").sortable({ connectWith: ".filemanager-lower, .filemanager-upper", items: ".filemanager-item:not(.filemanager-item-no-action)", placeholder: "filemanager-placeholder", receive: function(event, ui) { if(typeof(ui.item.data("id")) != 'undefined' && ui.item.data("id") != null) { self.startLoad($(".filemanager .filemanager-upper")); self.startLoad($(".filemanager .filemanager-lower")); self.obj.attachFile(ui.item.data("id"), function() { self.obj.fetchFiles(function() { self.fetchLibrary(); }); }); } }, revert: "invalid", start: function() { self.sorting = true; }, stop: function() { setTimeout(function() { self.sorting = false; }, 1000); } }).disableSelection(); */ } /* @params fs: files */ var fetchUploadView = function(fs) { var self = this; self.noscroll = true; var params = {}; params['mediafolder_id'] = self.folder_id; self.startLoad($(".filemanager")); $.ajax({ type: "POST", url: self.urls['upload_view'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.stopLoad(); $(".filemanager-lower").html(response['html']); $(".filemanager-lower-content-outer").hide(); //$(".filemanager-lower-content-bottom").hide(); self.bindUploadView(fs||undefined); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); /* swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); */ } }); } var bindUploadView = function(fs) { var self = this; $(".filemanager-lower").addClass("filemanager-lower-upload-ver"); $(".folder-dropdown-select a").bind("click", function() { var id = $(this).data("id"); var f = $(".folder-dropdown-select [data-id='" + id + "']"); $(".folder-dropdown-select-btn").html(f.html()); $(".folder-dropdown-select .btn-primary").removeClass("btn-primary"); f.addClass("btn-primary"); self.folder_id = id; }); if(typeof(self.folder_id) != 'undefined' && self.folder_id != null) { $(".folder-dropdown-select [data-id='" + self.folder_id + "']").click(); } else { $(".folder-dropdown-select [data-id]").first().click(); } $(".filemanager-upload-submit-btn").bind("click", function() { self.uploadFiles(); }); self.noscroll = true; self.droppedFiles = {}; $(".filemanager-upload-cancel-btn").bind("click", function() { self.startLoad(self.container); //$(".filemanager-lower-content-top").show(); //$(".filemanager-lower-content-bottom").show(); self.page = 1; self.fetchLibrary(); }); $("#file-upload-input2").unbind("change"); $("#file-upload-input2").bind("change", function(ev) { self.addPreviewFile(ev.target.files); }); $(".box__input-modal").unbind("click"); $(".box__input-modal").bind("click", async function() { $('#file-upload-input2').trigger('click'); var filesFromUser = await askForFileFromUser(); self.addPreviewFile(filesFromUser); }); $(".box__input-modal") .on( 'drag dragstart dragend dragover dragenter dragleave drop', function( e ) { // preventing the unwanted behaviours e.preventDefault(); e.stopPropagation(); }) .on( 'dragover dragenter', function() // { $(".box__input-modal").addClass( 'is-dragover' ); }) .on( 'dragleave dragend drop', function() { $(".box__input-modal").removeClass( 'is-dragover' ); }) .on( 'drop', function( e ) { if(typeof(e.originalEvent.dataTransfer) != 'undefined') { self.addPreviewFile(e.originalEvent.dataTransfer.files); } }); if(typeof(fs) != 'undefined') { self.addPreviewFile(fs); } } var uploadFiles = function() { var self = this; self.fs = []; self.startLoad($(".filemanager .filemanager-upload-view"), false, true); for(var i in self.droppedFiles) { var params = {}; params['file'] = self.droppedFiles[i]; params['mediafolder_id'] = self.folder_id; params['index'] = i; var s = $(".filemanager-upload-view-sample .filemanager-attachment[data-id='" + i + "']"); if(s.length) { var inpi = s.find(".filemanager-attachment-name-edit .filemanager-attachment-name-edit-input"); if($.trim(inpi.val()) != "") { params['title'] = inpi.val(); } } //params['title'] = ''; //params['note'] = ''; self.fs.push(params); } self.uploadFile(); } var uploadFile = function() { var self = this; if (self.fs.length > 0) { var params = self.fs.pop(); var formData = new FormData(); for(var i in params) { formData.append(i, params[i]); } if(typeof(params['index']) != 'undefined') { var ele = $(".filemanager-upload-view-sample .filemanager-attachment[data-id='" + params['index'] + "']"); self.fileIndex = params['index']; self.fileLoader = ele.find(".filemanager-attachment-load-progress"); self.fileLoader.show(); self.fileLoader.find(".filemanager-attachment-load-progress-label").text("0%"); self.fileLoader.find(".filemanager-attachment-load-progress-inner").css("width", "0%"); self.fileLoader.removeClass("filemanager-attachment-load-error"); } else { self.fileIndex = null; self.fileLoader = null; } $.ajax({ type: "POST", enctype: 'multipart/form-data', processData: false, contentType: false, cache: false, data: formData, dataType: "json", url: "https://www.thrivsports.com/api/shared/uploadFile", xhr: function() { var jqXHR = $.ajaxSettings.xhr(); jqXHR.upload.addEventListener( "progress", function ( evt ) { if ( evt.lengthComputable ) { var percentComplete = Math.round( (evt.loaded * 100) / evt.total ); var perc = percentComplete + "%"; self.fileLoader.find(".filemanager-attachment-load-progress-label").text(perc); self.fileLoader.find(".filemanager-attachment-load-progress-inner").css("width", perc); } }, false ); return jqXHR; } }) .done(function (result) { if(result['success'] && typeof(result['data']['mediafile_id']) != 'undefined') { self.fileLoader.closest(".filemanager-attachment-col").remove(); self.selectItemById(result['data']['mediafile_id'], function() { self.uploadFile(); }); delete self.droppedFiles[self.fileIndex]; } else { self.fileLoader.find(".filemanager-attachment-load-progress-label").text(result['error_msg']); self.fileLoader.addClass("filemanager-attachment-load-error"); self.uploadFile(); } }); } else { if($(".filemanager-upload-view-sample .filemanager-attachment-col").length == 0) { self.stopLoad(); if(typeof(self.callbacks['insert']) != 'undefined') { self.callbacks['insert'](self.selected_items); } else { self.goFolder(self.folder_id); } } else { self.stopLoad(); swal({ title: "Error", text: "There were some errors during upload", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } } } var addPreviewFile = function(browsed) { var self = this; var str = ''; for(var i=0; i < browsed.length; i++) { var filePath = browsed[i].name; if(typeof(self.droppedFiles[filePath]) == 'undefined') { self.droppedFiles[filePath] = browsed[i]; } } for(var i in self.droppedFiles) { var filePath = self.droppedFiles[i].name; var file_ext = filePath.substr(filePath.lastIndexOf('.')+1,filePath.length).toLowerCase(); str += '

'; str += '

'; str += '

'; if(file_ext == "gif" || file_ext == "png" || file_ext == "jpg" || file_ext == "jpeg" || file_ext == "svg") { var showImage = true; str += '

'; //str += filePath; str += '

'; str += filePath; str += '

'; str += '

'; } else { var showImage = false; str += '

'; //str += filePath; str += '

'; str += filePath; str += '

'; str += '

'; } str += '

'; str += '

'; str += '

'; str += '

0%

'; str += '

'; str += '

'; str += ''; str += '

'; str += ''; str += ''; str += ''; str += '

'; str += '

'; } $(".filemanager-upload-view-sample").html(str); for(var i in self.droppedFiles) { var filePath = self.droppedFiles[i].name; var file_ext = filePath.substr(filePath.lastIndexOf('.')+1,filePath.length).toLowerCase(); if(file_ext == "gif" || file_ext == "png" || file_ext == "jpg" || file_ext == "jpeg" || file_ext == "svg") { var showImage = true; } else { var showImage = false; } if(self.droppedFiles && self.droppedFiles[i] && showImage) { (function(i){ var reader = new FileReader(); reader.onload = function(e) { var img = new Image(); img.src = e.target.result; var url = img.src; $('.filemanager-upload-view-sample .filemanager-attachment[data-id="'+i+'"] .filemanager-attachment-inner').css("background-image", "url('" + url.replace(/(\r\n|\n|\r)/gm, "") + "')"); } reader.readAsDataURL(self.droppedFiles[i]); })(i); } } $(".filemanager-upload-view-sample .filemanager-attachment").bind("click", function(ev) { delete self.droppedFiles[$(this).data("id")]; $(this).closest(".filemanager-attachment-col").remove(); ev.stopPropagation(); }); $(".filemanager-upload-view-sample .filemanager-attachment .filemanager-attachment-name-edit").bind("click", function(ev) { ev.stopPropagation(); }); } var fetchLibrary = function(id) { var self = this; $(".filemanager-lower").removeClass("filemanager-lower-upload-ver"); if(self.fetching) { return; } self.fetching = true; if(typeof(id) != 'undefined' && id != null) { self.folder_id = id; } var params = {}; params['transcript_id'] = self.transcript_id; params['mediafolder_id'] = self.folder_id; if(typeof(self.libSearch) != 'undefined' && self.libSearch != null) { params['search'] = self.libSearch; } if(typeof(self.libSort) != 'undefined' && self.libSort != null) { params['sort'] = self.libSort; } if(typeof(self.libSortDir) != 'undefined' && self.libSortDir != null) { params['sort_dir'] = self.libSortDir; } if(typeof(self.libView) != 'undefined' && self.libView != null) { params['view'] = self.libView; } else { params['view'] = "thumbnail"; } if(typeof(self.libFilter) != 'undefined' && self.libFilter != null) { params['filter'] = self.libFilter; } params['page'] = self.page; params['num_per_page'] = self.num_per_page; if(typeof(self.extra['column_define']) != 'undefined') { params['column_define'] = self.extra['column_define']; } //alert(JSON.stringify(params)); if(typeof(self.lib_fetch_req) != 'undefined') { self.lib_fetch_req.abort(); } self.lib_fetch_req = $.ajax({ type: "POST", url: self.urls['library_files'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.last_num = response['num']; if(typeof(self.container) == 'undefined' || self.container == null || self.container.length == 0) { self.container = $(".filemanager .filemanager-lower"); } self.folder_id = response['mediafolder_id']; self.stopLoad(); if(self.page == 1) { self.current_system_location = response['location']; self.updateSystemLocation(); self.container.html(response['html']); } else { self.container.append(response['html']); } self.bindLibrary(); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } self.fetching = false; $(self.extra['scroll']).trigger("scroll"); }, error: function() { self.stopLoad(); /* swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); */ self.fetching = false; } }); } var bindLibrary = function() { var self = this; self.noscroll = null; $(".filemanager .filemanager-lower-content-outer").show(); //$(".filemanager .filemanager-lower-content-bottom").show(); if(self.obj == null) { $(".filemanager-done-but").hide(); $(".filemanager-item-attach").hide(); } //$(".filemanager-lower").css("min-height", $(".folder-dropdown").outerHeight()+"px"); $('.filemanager .filemanager-item').each(function() { if(typeof($(this).data("bound")) == 'undefined' || $(this).data("bound") == null) { var preview = $(this).data("previewpath"); var typ = $(this).data("type"); if(!$(this).hasClass("filemanager-item-thumb")) { if(typeof(preview) != 'undefined' && preview != null && preview != "") { if(typ == "image" || typ == "video" || typ == "analysis") { $(this).popover({ content: 'Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (20)', html: true, placement: 'right', trigger: 'hover', container: 'body' }); } } } $(this).data("bound", true); } if($(this).hasClass("filemanager-item-file") && typeof(self.selected_items[$(this).data("id")]) != 'undefined') { self.selectItem($(this)); } }); self.sorting = false; /* $(".filemanager-item-folder").droppable({ classes: { "ui-droppable-active": "filemanager-item-active", "ui-droppable-hover": "filemanager-item-hover" }, drop: function(event, ui) { if(typeof(ui.draggable.data("id")) != 'undefined' && ui.draggable.data("id") != null && typeof($(this).data("id")) != 'undefined' && $(this).data("id") != null) { self.startLoad($(".filemanager .filemanager-lower")); var mediafile_id = ui.draggable.data("id"); var folder_id = $(this).data("id"); ui.draggable.remove(); self.moveFile(mediafile_id, folder_id, function() { self.fetchLibrary(); }); } }, activate: function(event, ui) { $(".filemanager-upper .filemanager-item").addClass("filemanager-item-active"); //$(".folder-dropdown").show(); }, deactivate: function(event, ui) { $(".filemanager-item-active").removeClass("filemanager-item-active"); } }); */ var mapping = {}; $(".filemanager .filemanager-upper [data-id]").each(function() { mapping[$(this).data("id")] = true; }); $(".filemanager .filemanager-lower [data-id]").each(function() { if(typeof(mapping[$(this).data("id")]) != 'undefined' && !$(this).hasClass("filemanager-item-folder")) { $(this).addClass("disabled"); $(this).addClass("filemanager-item-no-action"); $(this).find(".filemanager-item-attach").remove(); } }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-view-inner").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-view-inner").bind("click", function(ev) { var e = $(this).closest(".filemanager-item"); if(!e.hasClass("filemanager-item-dummy")) { ev.stopPropagation(); if(self.sorting == false) { var t = e.data("type"); if(t == "back" || t == "folder") { self.goFolder($(this).closest(".filemanager-item").data("id")); } else { if(self.selector) { if(!e.hasClass("filemanager-item-selected")) { self.selectItem(e); } else { self.deselectItem(e); } } else if(self.obj != null) { self.obj.attachFile($(this).closest(".filemanager-item").data("id")); } else { self.previewFile(e); } } } } //ev.preventDefault(); //ev.stopPropagation(); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-delete").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-delete").bind("click", function() { self.deleteFile($(this).data("id"), $(this).data("type")); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-analyze").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-analyze").bind("click", function() { self.analyzeVideo($(this)); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-preview").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-preview").bind("click", function() { self.previewFile($(this)); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-go").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-go").bind("click", function(ev) { self.goFolder($(this).data("id")); }); $(".filemanager .folder-dropdown a").unbind("click"); $(".filemanager .folder-dropdown a").bind("click", function(ev) { self.goFolder($(this).data("id")); }); if(self.obj != null) { $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-attach").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-attach").bind("click", function() { self.obj.attachFile($(this).data("id")); }); } $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit").bind("click", function() { var p = $(this).closest(".filemanager-item"); var mediafile_id = $(this).data("id"); self.editFile(mediafile_id); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-field").unbind("focus"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-field").bind("focus", function(ev) { ev.stopPropagation(); ev.preventDefault(); $(this).select(); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-field").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-field").bind("click", function(ev) { ev.stopPropagation(); ev.preventDefault(); $(this).select(); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-field").unbind("keypress"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-field").keypress(function(ev) { if($(this).closest(".filemanager-item").hasClass("filemanager-item-dummy")) { return true; } if(ev.keyCode == 13) { ev.stopPropagation(); ev.preventDefault(); var p = $(this).closest(".filemanager-item"); var v = p.find(".filemanager-item-edit-field"); var params = {}; if(p.data("type") == "folder") { params['mediafolder_id'] = p.data("id"); } else { params['mediafile_id'] = p.data("id"); } params['name'] = v.val(); self.startLoad($(".filemanager .filemanager-lower")); $.ajax({ type: "POST", url: self.urls['file_rename'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.stopLoad(); p.find(".filemanager-item-view-name").text(response['name']); p.find(".filemanager-item-view-name").show(); p.find(".filemanager-item-view-name-edit").hide(); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-rename").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-rename").bind("click", function() { var p = $(this).closest(".filemanager-item"); p.find(".filemanager-item-view-name-edit").show(); p.find(".filemanager-item-view-name").hide(); p.find(".filemanager-item-view-name-edit .filemanager-item-edit-field").unbind("blur"); p.find(".filemanager-item-view-name-edit .filemanager-item-edit-field").focus(); p.find(".filemanager-item-view-name-edit .filemanager-item-edit-field").bind("blur", function(ev) { var p = $(this).closest(".filemanager-item"); if($(this).val() == "") { p.find(".filemanager-item-view-name-edit").hide(); p.find(".filemanager-item-view-name").show(); } }); }); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-cancel").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item .filemanager-item-edit-cancel").bind("click", function(ev) { ev.stopPropagation(); ev.preventDefault(); var p = $(this).closest(".filemanager-item"); //p.find(".filemanager-item-edit-field").val(""); p.find(".filemanager-item-view-name-edit").hide(); p.find(".filemanager-item-view-name").show(); }); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").unbind("focus"); $(".filemanager .filemanager-item-folder-new .filemanager-item-edit-field").bind("focus", function(ev) { ev.stopPropagation(); ev.preventDefault(); $(".filemanager .filemanager-item-folder-new").show(); }); $('.filemanager .filemanager-item-folder-new .filemanager-item-edit-field').unbind("keypress"); $('.filemanager .filemanager-item-folder-new .filemanager-item-edit-field').keypress(function(ev) { if(ev.keyCode == 13) { ev.stopPropagation(); ev.preventDefault(); var p = $(this).closest(".filemanager-item-folder-new"); var v = p.find(".filemanager-item-edit-field"); var params = {}; params['parent_id'] = self.folder_id; params['name'] = v.val(); self.startLoad($(".filemanager .filemanager-lower")); $.ajax({ type: "POST", url: self.urls['folder_create'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.page = 1; self.fetchLibrary(self.folder_id); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } }); $(".filemanager .filemanager-lower .filemanager-item-folder-new .filemanager-item-edit-cancel").unbind("click"); $(".filemanager .filemanager-lower .filemanager-item-folder-new .filemanager-item-edit-cancel").bind("click", function(ev) { ev.stopPropagation(); ev.preventDefault(); $('.filemanager .filemanager-item-folder-new .filemanager-item-edit-field').val(""); $('.filemanager .filemanager-item-folder-new .filemanager-item-edit-field').blur(); }); /* $(".filemanager .filemanager-item-actions").bind("click", function(ev) { //ev.preventDefault(); //ev.stopPropagation(); }); */ $(".filemanager .filemanager-upload-edit-save").unbind("click"); $(".filemanager .filemanager-upload-edit-save").bind("click", function() { var v = $(".filemanager .filemanager-upload-edit-field"); var params = {}; params['mediafile_id'] = self.upload_mediafile_id; params['name'] = v.val(); self.startLoad($(".filemanager .filemanager-lower")); $.ajax({ type: "POST", url: self.urls['file_rename'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.fetchLibrary(); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }); if(typeof(self.callbacks['library']) != 'undefined') { self.callbacks['library'](); } else { $(".filemanager .filemanager-item-folder").each(function() { //if(typeof($(this).data("bound")) == 'undefined' || $(this).data("bound") == null) { $(this).droppable({ classes: { "ui-droppable-active": "filemanager-item-active", "ui-droppable-hover": "filemanager-item-hover" }, drop: function(event, ui) { if(typeof(ui.draggable.data("id")) != 'undefined' && ui.draggable.data("id") != null && typeof($(this).data("id")) != 'undefined' && $(this).data("id") != null) { self.startLoad($(".filemanager .filemanager-lower")); var mediafile_id = ui.draggable.data("id"); var folder_id = $(this).data("id"); ui.draggable.remove(); self.moveFile(mediafile_id, folder_id, function() { self.fetchLibrary(); }); } }, activate: function(event, ui) { $(".filemanager-upper .filemanager-item").addClass("filemanager-item-active"); //$(".folder-dropdown").show(); }, deactivate: function(event, ui) { $(".filemanager-item-active").removeClass("filemanager-item-active"); } }); $(this).data("bound", true); //} }); $(".filemanager .filemanager-item-file").draggable({ revert: "invalid", scroll: false, helper: "clone", appendTo: 'body', start: function(event, ui) { ui.helper.css("z-index", "4999"); } }); } } var startLoad = function(e, append, abso) { var self = this; var str = ''; if(e.find(".filemanager-load, .filemanager-load-append").length) { e.find(".filemanager-load, .filemanager-load-append").remove(); } if(typeof(append) == 'undefined' || append == false) { if(typeof(abso) == 'undefined' || abso == false) { str += '

'; } else { str += '

'; } str += '

'; str += '

'; str += '

'; str += '

'; e.css("position", "relative"); e.append(str); e.find(".filemanager-load").css("height", e[0].scrollHeight+"px"); var pos = e.offset(); e.find(".filemanager-load-inner").css("margin-top", Math.round((pos.top / 2) - 30)+"px"); e.find(".filemanager-load-inner").css("margin-left", Math.round((pos.left / 2) - 30)+"px"); } else { str += '

'; str += '

'; str += '

'; str += '

'; str += '

'; e.css("position", "relative"); e.append(str); e.find(".filemanager-load-append").css("top", (e[0].scrollHeight - 60)+"px"); } } var stopLoad = function(e) { var self = this; if(typeof(e) != 'undefined' && e != null) { e.find(".filemanager-load, .filemanager-load-append").remove(); } else { $(".filemanager .filemanager-load, .filemanager .filemanager-load-append").remove(); } } var fetchVideoThumbs = function(mediafile_id) { var self = this; var params = {}; params['mediafile_id'] = mediafile_id; self.saved_mediafile_id = mediafile_id; $.ajax({ type: "POST", url: self.urls['file_video_thumbs'], data: params, dataType: "json", success: function(response) { if(response['success']) { $(".filemanager-view-item-large").html(response['html']); $(".filemanager .video_poster_i").bind("click", function() { $(".filemanager .video_poster_sel").removeClass("video_poster_sel").addClass("video_poster"); $(this).removeClass("video_poster").addClass("video_poster_sel"); $(".filemanager .filemanager-view-item-img").css("background-image", "url('"+$(this).data("id")+"')"); }); if($(".filemanager .video_poster_i").length && $(".filemanager .video_poster_sel").length == 0) { $(".filemanager .video_poster_i").first().click(); } $(".filemanager .filemanager-view-item-inner-clickable").bind("click", function() { self.previewFile($(this).closest(".filemanager-view-item")); }); if($(".filemanager .filemanager-view-item-processing").length) { setTimeout(function() { self.fetchVideoThumbs(self.saved_mediafile_id); }, 10000); } } else { } }, error: function() { } }); } var editFile = function(mediafile_id) { var self = this; self.startLoad($(".filemanager .filemanager-lower")); var params = {}; params['mediafile_id'] = mediafile_id; $.ajax({ type: "POST", url: self.urls['file_edit'], data: params, dataType: "json", success: function(response) { if(response['success']) { $(".filemanager .filemanager-lower").html(response['html']); self.bindEditFile(); self.fetchVideoThumbs(mediafile_id); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var bindEditFile = function() { var self = this; $(".filemanager .filemanager-lower-content-outer").hide(); //$(".filemanager .filemanager-lower-content-bottom").hide(); $(".filemanager .filemanager-item-edit-cancel-but").bind("click", function() { self.startLoad($(".filemanager .filemanager-lower")); self.fetchLibrary(); }); $(".filemanager .filemanager-item-edit-save-but").bind("click", function() { self.startLoad($(".filemanager .filemanager-lower")); var params = {}; params['mediafile_id'] = $(".filemanager-item-edit-id").val(); params['name'] = $(".filemanager-item-edit-name").val(); params['description'] = $(".filemanager-item-edit-description").val(); if($(".filemanager-item-edit-public").is(":checked")) { params['public'] = 1; } else { params['public'] = 0; } if($(".video_poster_sel").length) { params['poster_name'] = $(".video_poster_sel").data("id"); } params['tags'] = []; $(".video_tag").each(function() { if($(this).is(":checked")) { params['tags'].push($(this).data("id")); } }); if($(".video_primary").is(":checked")) { params['golfpro_primary'] = 1; } else { params['golfpro_primary'] = 0; } $.ajax({ type: "POST", url: self.urls['file_edit_submit'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.page = 1; self.fetchLibrary(); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }); } var moveFile = function(mediafile_id, folder_id, callback) { var self = this; var params = {}; params['mediafile_id'] = mediafile_id; params['mediafolder_id'] = folder_id; $.ajax({ type: "POST", url: self.urls['file_move'], data: params, dataType: "json", success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var deleteFile = function(id, type) { var self = this; swal({ title: "Confirm Action", text: "Are you sure you want to do this? It is irreversible", type: "warning", showCancelButton: true, confirmButtonClass: 'btn-primary waves-effect waves-light', confirmButtonText: 'Yes' }, function (isConfirm) { if(isConfirm) { var params = {}; if(type == "folder") { params['mediafolder_id'] = id; } else { params['mediafile_id'] = id; } self.startLoad($(".filemanager .filemanager-lower")); $.ajax({ type: "POST", url: self.urls['file_delete'], data: params, dataType: "json", success: function(response) { if(response['success']) { self.page = 1; self.fetchLibrary(); } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } }); } var goFolder = function(id) { var self = this; self.fetching = false; self.startLoad($(".filemanager .filemanager-lower")); self.page = 1; self.fetchLibrary(id); } var previewFile = function(e) { var self = this; var typ = e.data("type"); var pat = e.data("path"); var id = e.data("id"); var preview_pat = e.data("previewpath"); if(typeof(self.mediaModal) == 'undefined') { self.mediaModal = new MediaModalModule(); self.mediaModal.init(); } if(typ == "image") { var params = {}; params['src'] = pat; params['mediafile_id'] = id; self.mediaModal.showImage(params, self.extra); } else if(typ == "video") { var params = {}; params['path'] = pat; params['preview_path'] = preview_pat; params['mediafile_id'] = id; self.mediaModal.showVideo(params, self.extra); } else if(typ == "analysis") { var params = {}; params['path'] = pat; params['preview_path'] = preview_pat; params['mediafile_id'] = id; self.mediaModal.showAnalysis(params, self.extra); } else if(typ == "audio") { var params = {}; params['path'] = pat; params['preview_path'] = preview_pat; params['mediafile_id'] = id; self.mediaModal.showAudio(params, self.extra); } else { window.open(pat, "_blank"); } } var analyzeVideo = function(e) { var self = this; var typ = e.data("type"); var pat = e.data("path"); var id = e.data("id"); var preview_pat = e.data("previewpath"); swal({ title: "Confirm Action", text: "Are you sure you want to analyze this video?", type: "success", showCancelButton: true, confirmButtonClass: 'btn-primary waves-effect waves-light', confirmButtonText: 'Yes' }, function (isConfirm) { if(isConfirm) { var url = "https://www.thrivsports.com/coach/filemanager/analysis/"+id+"/"; window.location.href = url; } }); } var searchLibrary = function(v) { var self = this; v = $.trim(v.toLowerCase()); self.libSearch = v; self.startLoad($(".filemanager .filemanager-lower")); self.page = 1; self.fetchLibrary(); /* $(".filemanager .filemanager-lower .filemanager-item").each(function() { if($(this).data("type") == "back") { if(self.libView == "list") { $(this).show(); } else { $(this).parent().show(); } } else { var n = $(this).find(".filemanager-item-view-name").text(); n = $.trim(n.toLowerCase()); if(n.indexOf(v) == -1) { if(self.libView == "list") { $(this).hide(); } else { $(this).parent().hide(); } } else { if(self.libView == "list") { $(this).show(); } else { $(this).parent().show(); } } } }); */ } var sortLibrary = function(s, d) { var self = this; self.libSort = s; self.libSortDir = d; self.startLoad($(".filemanager .filemanager-lower")); self.page = 1; self.fetchLibrary(); } var filterLibrary = function(f) { var self = this; self.page = 1; if(typeof(f) != 'undefined' && f != null) { self.libFilter = f; } self.fetchLibrary(); /* if(typeof(self.libFilter) != 'undefined' && self.libFilter != null) { $(".filemanager .filemanager-lower .filemanager-item").each(function() { if(self.libView == "list") { var ele = $(this); } else { var ele = $(this).parent(); } var typ = $(this).data("type"); if(self.libFilter == "all") { ele.show(); } else if(self.libFilter == "videos" && typ == "video") { ele.show(); } else if(self.libFilter == "photos" && typ == "image") { ele.show(); } else if(self.libFilter == "sounds" && typ == "audio") { ele.show(); } else if(self.libFilter == "documents" && typ == "text") { ele.show(); } else if(typ == "folder") { ele.show(); } else if(typ == "back") { ele.show(); } else { ele.hide(); } }); } */ } var viewLibrary = function(v) { var self = this; self.page = 1; self.libView = v; self.startLoad($(".filemanager .filemanager-lower")); self.fetchLibrary(); } var updateSystemLocation = function() { var self = this; if(typeof(self.current_system_location) == 'undefined') { return true; } $(".filemanager-lower-content-bread").html(""); var linkee = []; for(var i=0; i < self.current_system_location.length; i++) { var o = self.current_system_location[i]; var str = ''; if(i == self.current_system_location.length-1) { str += '' + o['name'] + ''; } else { str += '' + o['name'] + ''; } linkee.push(str); } var final_str = linkee.join(' '); $(".filemanager-lower-content-bread").html(final_str); $(".filemanager-lower-content-bread a").bind("click", function() { self.goFolder($(this).data("id")); }); } return { init: init, bindInit: bindInit, fetchUploadView: fetchUploadView, bindUploadView: bindUploadView, addPreviewFile: addPreviewFile, fetchLibrary: fetchLibrary, bindLibrary: bindLibrary, startLoad: startLoad, stopLoad: stopLoad, moveFile: moveFile, deleteFile: deleteFile, editFile: editFile, fetchVideoThumbs: fetchVideoThumbs, bindEditFile: bindEditFile, goFolder: goFolder, previewFile: previewFile, analyzeVideo: analyzeVideo, searchLibrary: searchLibrary, sortLibrary: sortLibrary, viewLibrary: viewLibrary, filterLibrary: filterLibrary, selectItem: selectItem, selectItemById: selectItemById, deselectItem: deselectItem, generateSelections: generateSelections, updateSystemLocation: updateSystemLocation, uploadFiles: uploadFiles, uploadFile: uploadFile } }; var TranscriptFileViewerModule = function() { var init = function(container) { var self = this; self.container = container; self.transcript_id = self.container.data("transcriptid"); self.container.html(''); var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/transcriptFilesView", data: params, success: function(response) { if(response['success']) { self.library = new FileManagerModule(); //self.library.init($(".filemanager .filemanager-lower"), self); self.container.html(response['html']); self.bindFiles(); } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }; var bindFiles = function() { var self = this; self.container.find(".filemanager-view-item").bind("click", function() { self.library.previewFile($(this)); }); } return { init: init, bindFiles: bindFiles }; }; var TranscriptFileStudentViewerModule = function() { var init = function(container) { var self = this; self.container = container; self.transcript_id = self.container.data("transcriptid"); self.container.html(''); var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/student/filemanager/transcriptFilesView", data: params, dataType: "json", success: function(response) { if(response['success']) { self.library = new FileManagerModule(); //self.library.init($(".filemanager .filemanager-lower"), self); self.container.html(response['html']); self.bindFiles(); } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }; var bindFiles = function() { var self = this; self.container.find(".filemanager-view-item").bind("click", function() { self.library.previewFile($(this)); }); } return { init: init, bindFiles: bindFiles }; }; var ProgramFileManagerModule = function() { var init = function(container) { var self = this; self.container = container; self.program_id = self.container.data("programid"); self.container.html(''); var params = {}; params['program_id'] = self.program_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/program", data: params, success: function(response) { if(response['success']) { self.container.html(response['html']); self.library = new FileManagerModule(); self.library.init($(".filemanager .filemanager-lower"), self); self.bindFiles(); self.library.bindInit(); } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }; var fetchFiles = function(callback) { var self = this; var params = {}; params['program_id'] = self.program_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/programFiles", data: params, success: function(response) { if(response['success']) { self.stopLoad(); $(".filemanager .filemanager-upper").html(response['html']); self.bindFiles(); self.library.bindLibrary(); if(typeof(callback) != 'undefined' && callback != null) { callback(); //self.library.fetchLibrary(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var bindFiles = function() { var self = this; $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-preview").unbind("click"); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-preview").bind("click", function() { self.library.previewFile($(this)); }); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-remove").unbind("click"); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-remove").bind("click", function() { self.removeFile($(this).data("id"), function() { self.fetchFiles(function() { self.library.fetchLibrary(); }); }); }); } var startLoad = function(e) { var self = this; var str = ''; str += '

'; str += '

'; str += ''; str += '

'; str += '

'; e.css("position", "relative"); e.append(str); } var stopLoad = function(e) { var self = this; if(typeof(e) != 'undefined' && e != null) { e.find(".filemanager-load").remove(); } else { $(".filemanager .filemanager-load").remove(); } } var attachFile = function(id, callback) { var self = this; var params = {}; params['program_id'] = self.program_id; params['mediafile_id'] = id; self.startLoad($(".filemanager .filemanager-upper")); $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/programAttachFile", data: params, success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } else { self.fetchFiles(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var removeFile = function(id, callback) { var self = this; var params = {}; params['program_id'] = self.program_id; params['mediafile_id'] = id; self.startLoad($(".filemanager .filemanager-upper")); $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/programRemoveFile", data: params, success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } else { self.fetchFiles(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } return { init: init, fetchFiles: fetchFiles, bindFiles: bindFiles, startLoad: startLoad, stopLoad: stopLoad, attachFile: attachFile, removeFile: removeFile, } } var TranscriptStudentFileManagerModule = function() { var init = function(container, urls) { var self = this; self.container = container; self.transcript_id = self.container.data("transcriptid"); self.container.html(''); if(typeof(urls) == 'undefined' || urls == null) { self.urls = { }; } else { self.urls = urls; } var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/student/filemanager/transcript", data: params, dataType: "json", success: function(response) { if(response['success']) { self.container.html(response['html']); self.library = new FileManagerModule(); var urls = { 'file_upload': "https://www.thrivsports.com/student/filemanager/fileUpload/", 'library_files': "https://www.thrivsports.com/student/filemanager/libraryFiles", 'file_rename': "https://www.thrivsports.com/student/filemanager/fileRename", 'folder_create': "https://www.thrivsports.com/student/filemanager/folderCreate", 'file_video_thumbs': "https://www.thrivsports.com/student/filemanager/fileVideoThumbs", 'file_edit': "https://www.thrivsports.com/student/filemanager/fileEdit", 'file_edit_submit': "https://www.thrivsports.com/student/filemanager/fileEditSubmit", 'file_move': "https://www.thrivsports.com/student/filemanager/fileMove", 'file_delete': "https://www.thrivsports.com/student/filemanager/fileDelete", }; self.library.init($(".filemanager .filemanager-lower"), self, urls); self.bindFiles(); self.library.bindInit(); } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }; var fetchFiles = function(callback) { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/student/filemanager/transcriptFiles", data: params, dataType: "json", success: function(response) { if(response['success']) { self.stopLoad(); $(".filemanager .filemanager-upper").html(response['html']); self.bindFiles(); self.library.bindLibrary(); if(typeof(callback) != 'undefined' && callback != null) { callback(); //self.library.fetchLibrary(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var bindFiles = function() { var self = this; $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-preview").unbind("click"); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-preview").bind("click", function() { self.library.previewFile($(this)); }); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-remove").unbind("click"); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-remove").bind("click", function() { self.removeFile($(this).data("id"), function() { self.fetchFiles(function() { self.library.fetchLibrary(); }); }); }); } var startLoad = function(e) { var self = this; var str = ''; str += '

'; str += '

'; str += ''; str += '

'; str += '

'; e.css("position", "relative"); e.append(str); } var stopLoad = function(e) { var self = this; if(typeof(e) != 'undefined' && e != null) { e.find(".filemanager-load").remove(); } else { $(".filemanager .filemanager-load").remove(); } } var attachFile = function(id, callback) { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; params['mediafile_id'] = id; self.startLoad($(".filemanager .filemanager-upper")); $.ajax({ type: "POST", url: "https://www.thrivsports.com/student/filemanager/transcriptAttachFile", data: params, dataType: "json", success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } else { self.fetchFiles(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var removeFile = function(id, callback) { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; params['mediafile_id'] = id; self.startLoad($(".filemanager .filemanager-upper")); $.ajax({ type: "POST", url: "https://www.thrivsports.com/student/filemanager/transcriptRemoveFile", data: params, dataType: "json", success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } else { self.fetchFiles(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } return { init: init, fetchFiles: fetchFiles, bindFiles: bindFiles, startLoad: startLoad, stopLoad: stopLoad, attachFile: attachFile, removeFile: removeFile, } } var TranscriptFileManagerModule = function() { var init = function(container, urls) { var self = this; self.container = container; self.transcript_id = self.container.data("transcriptid"); self.container.html(''); if(typeof(urls) == 'undefined' || urls == null) { self.urls = { }; } else { self.urls = urls; } var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/transcript", data: params, dataType: "json", success: function(response) { if(response['success']) { self.container.html(response['html']); self.library = new FileManagerModule(); var urls = { 'file_upload': "https://www.thrivsports.com/coach/filemanager/fileUpload/", 'library_files': "https://www.thrivsports.com/coach/filemanager/libraryFiles", 'file_rename': "https://www.thrivsports.com/coach/filemanager/fileRename", 'folder_create': "https://www.thrivsports.com/coach/filemanager/folderCreate", 'file_video_thumbs': "https://www.thrivsports.com/coach/filemanager/fileVideoThumbs", 'file_edit': "https://www.thrivsports.com/coach/filemanager/fileEdit", 'file_edit_submit': "https://www.thrivsports.com/coach/filemanager/fileEditSubmit", 'file_move': "https://www.thrivsports.com/coach/filemanager/fileMove", 'file_delete': "https://www.thrivsports.com/coach/filemanager/fileDelete", }; self.library.init($(".filemanager .filemanager-lower"), self, urls); self.bindFiles(); self.library.bindInit(); } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); }; var fetchFiles = function(callback) { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/transcriptFiles", data: params, dataType: "json", success: function(response) { if(response['success']) { self.stopLoad(); $(".filemanager .filemanager-upper").html(response['html']); self.bindFiles(); self.library.bindLibrary(); if(typeof(callback) != 'undefined' && callback != null) { callback(); //self.library.fetchLibrary(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var bindFiles = function() { var self = this; $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-preview").unbind("click"); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-preview").bind("click", function() { self.library.previewFile($(this)); }); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-remove").unbind("click"); $(".filemanager .filemanager-upper .filemanager-item .filemanager-item-remove").bind("click", function() { self.removeFile($(this).data("id"), function() { self.fetchFiles(function() { self.library.fetchLibrary(); }); }); }); } var startLoad = function(e) { var self = this; var str = ''; str += '

'; str += '

'; str += ''; str += '

'; str += '

'; e.css("position", "relative"); e.append(str); } var stopLoad = function(e) { var self = this; if(typeof(e) != 'undefined' && e != null) { e.find(".filemanager-load").remove(); } else { $(".filemanager .filemanager-load").remove(); } } var attachFile = function(id, callback) { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; params['mediafile_id'] = id; self.startLoad($(".filemanager .filemanager-upper")); $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/transcriptAttachFile", data: params, dataType: "json", success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } else { self.fetchFiles(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } var removeFile = function(id, callback) { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; params['mediafile_id'] = id; self.startLoad($(".filemanager .filemanager-upper")); $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/filemanager/transcriptRemoveFile", data: params, dataType: "json", success: function(response) { if(response['success']) { if(typeof(callback) != 'undefined' && callback != null) { callback(); } else { self.fetchFiles(); } } else { self.stopLoad(); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.stopLoad(); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }); } return { init: init, fetchFiles: fetchFiles, bindFiles: bindFiles, startLoad: startLoad, stopLoad: stopLoad, attachFile: attachFile, removeFile: removeFile, } } var TranscriptVideoModule = function() { var init = function(container) { var self = this; self.container = container; self.transcript_id = self.container.data("id"); self.container.html(''); self.fetch(); }; var fetch = function() { var self = this; var params = {}; params['transcript_id'] = self.transcript_id; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/transcriptFetchVideoBoot/", data: params, success: function(response) { if(response['success']) { self.container.html(response['html']); if(response['video_state'] == "done") { var v = VideoModule(); v.init(self.container); self.container.find(".remove-transcript-video").bind("click", function() { self.container.html(''); var params = {}; params['transcript_id'] = self.transcript_id; //params['transcript_video_id'] = $(this).data("id"); $.ajax({ type: "POST", data: params, url: "https://www.thrivsports.com/coach/transcriptDeleteVideoSubmit", success: function(response) { if(response['success']) { self.fetch(); } else { self.ele.modal('hide'); swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.ele.modal('hide'); swal({ title: "Error", text: "General error", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); }, dataType: "json", cache: false }); }); } else if(response['video_state'] == "processing") { setTimeout(function() { self.fetch(); }, 2000); } else { $('#file-upload-input').unbind("change"); $('#file-upload-input').bind("change", function() { if ($('#file-upload-input').get(0).files.length) { //show progress bar self.container.find(".transcript-area-actions").hide(); self.container.find(".transcript-area-progress").show(); var formData = new FormData(); formData.append('video', $('#file-upload-input')[0].files[0]); formData.append('transcript_id', self.transcript_id); $.ajax({ xhr: function() { var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener("progress", function(evt) { if (evt.lengthComputable) { var percentComplete = Math.round(evt.loaded / evt.total * 100); //Do something with upload progress here self.container.find(".transcript-upload-progress").find(".progress-bar").css("width", percentComplete+"%"); self.container.find(".transcript-upload-progress-text").html("Uploading - "+percentComplete+"%"); } }, false); xhr.addEventListener("progress", function(evt) { if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; //Do something with download progress } }, false); return xhr; }, url: 'https://www.thrivsports.com/coach/transcriptUploadVideoSubmit/?transcript_id='+self.transcript_id, type: 'POST', data: formData, processData: false, contentType: false, success: function(response) { //alert(JSON.stringify(response)); self.container.find(".transcript-upload-progress-text").html("Done. Please wait..."); setTimeout(function() { self.fetch(); }, 2000); } }); } }); self.container.find(".attach-transcript-video").bind("click", function() { $('#file-upload-input').trigger('click'); }); } } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { setTimeout(function() { self.fetch(); }, 2000); }, dataType: "json", cache: false }); } return { init: init, fetch: fetch }; }; var TranscriptViewModule = function() { var init = function(params, callback) { var self = this; if(typeof(callback) != 'undefined' && callback != null && callback != false) { self.callback = callback; } if(typeof(params['delete']) != 'undefined' && params['delete'] != null && params['delete'] != false) { self.remove = true; } self.modal = new ModalModule(); self.modal.init(); self.modal.open("https://www.thrivsports.com/coach/transcriptViewBoot", params, function() { $(".transcript-filemanager").each(function() { var transcript_filemanager = new TranscriptFileViewerModule(); transcript_filemanager.init($(this)); }); }); }; return { init: init }; }; var TranscriptStudentEditModule = function() { var init = function(params, callback) { var self = this; if(typeof(callback) != 'undefined' && callback != null && callback != false) { self.callback = callback; } if(typeof(params['delete']) != 'undefined' && params['delete'] != null && params['delete'] != false) { self.remove = true; } self.modal = new ModalModule(); self.modal.init(); self.modal.open("https://www.thrivsports.com/student/transcriptEditBoot", params, function() { $(".transcript-filemanager").each(function() { /* var transcript_video = new TranscriptVideoModule(); transcript_video.init($(this)); */ var transcript_filemanager = new TranscriptStudentFileManagerModule(); transcript_filemanager.init($(this)); }); /* $(".mTransEditSave").bind("click", function() { $("#main-overlay").show(); var params = {}; if(typeof(self.remove) != 'undefined') { params['public_notes'] = ""; params['private_notes'] = ""; } else { params['public_notes'] = $(".mTransEditComments").val(); params['private_notes'] = $(".mTransEditPrivate").val(); } params['transcript_id'] = $(".mTransEditLessonId").val(); if($("#lesson_occured").is(":checked")) { params['lesson_occured'] = 0; params['trans_status'] = $("#trans_status").val(); params['trans_reason'] = $("#trans_reason").val(); } else { params['lesson_occured'] = 1; params['trans_status'] = 'occurred'; } params['ajax'] = true; params['jsonEncode'] = true; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/transcriptEditSubmit/", data: params, success: function(response) { $("#main-overlay").hide(); if(response['success']) { self.modal.close(); if(typeof(self.callback) != 'undefined') { self.callback(); } else { self.fetchTranscripts(); } } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { $("#main-overlay").hide(); swal({ title: "Error", text: "An error occurred", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); }, dataType: "json", cache: false }); }); $("#lesson_occured").bind("change", function() { if($(this).is(":checked")) { $("#no_occur").show(); $("#trans_content").hide(); } else { $("#no_occur").hide(); $("#trans_content").show(); } }); $("#trans_status").bind("change", function() { if($(this).val()=="no_show") { $("#trans_reason").hide(); } else { $("#trans_reason").show(); } }); */ //var vid = new TranscriptVideoModule(); //vid.init(); }); } return { init: init } } var TranscriptEditModule = function() { var init = function(params, callback) { var self = this; if(typeof(callback) != 'undefined' && callback != null && callback != false) { self.callback = callback; } if(typeof(params['delete']) != 'undefined' && params['delete'] != null && params['delete'] != false) { self.remove = true; } self.modal = new ModalModule(); self.modal.init(); self.modal.open("https://www.thrivsports.com/coach/transcriptEditBoot", params, function() { $(".transcript-filemanager").each(function() { /* var transcript_video = new TranscriptVideoModule(); transcript_video.init($(this)); */ var transcript_filemanager = new TranscriptFileManagerModule(); transcript_filemanager.init($(this)); }); $(".mTransEditSave").bind("click", function() { $("#main-overlay").show(); var params = {}; if(typeof(self.remove) != 'undefined') { params['public_notes'] = ""; params['private_notes'] = ""; } else { params['public_notes'] = $(".mTransEditComments").val(); params['private_notes'] = $(".mTransEditPrivate").val(); } params['transcript_id'] = $(".mTransEditLessonId").val(); if($("#lesson_occured").is(":checked")) { params['lesson_occured'] = 0; params['trans_status'] = $("#trans_status").val(); params['trans_reason'] = $("#trans_reason").val(); } else { params['lesson_occured'] = 1; params['trans_status'] = 'occurred'; } params['ajax'] = true; params['jsonEncode'] = true; $.ajax({ type: "POST", url: "https://www.thrivsports.com/coach/transcriptEditSubmit/", data: params, success: function(response) { $("#main-overlay").hide(); if(response['success']) { self.modal.close(); if(typeof(self.callback) != 'undefined') { self.callback(); } else { self.fetchTranscripts(); } } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { $("#main-overlay").hide(); swal({ title: "Error", text: "An error occurred", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); }, dataType: "json", cache: false }); }); $("#lesson_occured").bind("change", function() { if($(this).is(":checked")) { $("#no_occur").show(); $("#trans_content").hide(); } else { $("#no_occur").hide(); $("#trans_content").show(); } }); $("#trans_status").bind("change", function() { if($(this).val()=="no_show") { $("#trans_reason").hide(); } else { $("#trans_reason").show(); } }); //var vid = new TranscriptVideoModule(); //vid.init(); }); } return { init: init } } var TranscriptEditBulkModule = function() { var init = function(params, callback) { var self = this; if(typeof(callback) != 'undefined' && callback != null && callback != false) { self.callback = callback; } self.modal = new ModalModule(); self.modal.init(); self.modal.open("https://www.thrivsports.com/coach/transcriptEditBulkBoot", params, function() { $(".transcript-uploader").each(function() { var transcript_video = new TranscriptVideoModule(); transcript_video.init($(this)); }); $(".mTransEditSave").bind("click", function() { $("#main-overlay").show(); var url = "https://www.thrivsports.com/coach/transcriptEditBulkSubmit/"; var params = {}; params['transcript_ids'] = []; $('.transcriptCheck').each(function() { if($(this).is(":checked")) { params['transcript_ids'].push($(this).data("id")); } }); params['public_notes'] = $(".mTransEditComments").val(); params['private_notes'] = $(".mTransEditPrivate").val(); if($("#lesson_occured").is(":checked")) { params['lesson_occured'] = 0; params['trans_status'] = $("#trans_status").val(); params['trans_reason'] = $("#trans_reason").val(); } else { params['lesson_occured'] = 1; params['trans_status'] = 'occurred'; } params['ajax'] = true; params['jsonEncode'] = true; $.ajax({ type: "POST", url: url, data: params, success: function(response) { $("#main-overlay").hide(); if(response['success']) { self.modal.close(); if(typeof(self.callback) != 'undefined') { self.callback(); } else { self.fetchTranscripts(); } } else { swal({ title: "Error", text: response['error_code'], type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { $("#main-overlay").hide(); swal({ title: "Error", text: "An error occurred", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); }, dataType: "json", cache: false }); }); $("#lesson_occured").bind("change", function() { if($(this).is(":checked")) { $("#no_occur").show(); $("#trans_content").hide(); } else { $("#no_occur").hide(); $("#trans_content").show(); } }); $("#trans_status").bind("change", function() { if($(this).val()=="no_show") { $("#trans_reason").hide(); } else { $("#trans_reason").show(); } }); //var vid = new TranscriptVideoModule(); //vid.init(); }); } return { init: init } } var SearchModule = function() { var init = function(e, opts) { var self = this; self.opts = opts; self.e = e; if(typeof(self.opts['min_length']) == 'undefined') { self.opts['min_length'] = 3; } if(typeof(self.opts['delay']) == 'undefined') { self.opts['delay'] = 400; } self.e.typeahead({ items: 10, delay: self.opts['delay'], minLength: self.opts['min_length'], source: function(query, process) { if(typeof(self.vr) != 'undefined') { self.vr.abort(); } var params = {}; params['term'] = $.trim(query); if(typeof(self.opts['params']) != 'undefined') { for(var i in self.opts['params']) { params[i] = self.opts['params'][i]; } } self.vr = $.getJSON(self.opts['url'], params, function(data, status, xhr) { var p = []; for(var i in data) { var t = data[i]; t['name'] = t['label']; p.push(t); //p.push(data[i]['label']); } return process(p); }); }, displayText: self.opts['displayText'], afterSelect: function(item) { var aa = self.e.parent().find(".input-group-addon"); if(aa.length > 0) { var a = aa.first(); } if(aa.length > 1) { var b = aa.last(); } if(typeof(a) != 'undefined') { //a.addClass("input-group-addon-primary"); a.html(''); } if(typeof(b) != 'undefined') { //a.addClass("input-group-addon-primary"); b.html(''); } var locInputId = self.e.parent().find('.facility-add-input-id-selected'); if(locInputId.length > 0) { locInputId.val(item.id); } if(typeof(self.opts['afterSelect']) != 'undefined') { self.opts['afterSelect'](item); } } }); self.e.bind("keydown", function(event) { if(self.e.val() == " ") { self.e.val(""); } }); self.e.bind("keyup", function(event) { if(self.e.val() == " ") { self.e.val(""); } if(typeof(self.opts['nomuck']) == 'undefined' || self.opts['nomuck'] == false) { var keycode = (event.keyCode ? event.keyCode : event.which); var aa = self.e.parent().find(".input-group-addon"); if(aa.length > 0) { var a = aa.first(); } if(aa.length > 1) { var b = aa.last(); } if(keycode == '13'){ } else { self.e.closest(".input-group").addClass("input-group-searching"); if(typeof(a) != 'undefined') { a.html(''); } if(typeof(b) != 'undefined') { b.html(''); } if(typeof(self.opts['keyup_callback']) != 'undefined') { self.opts['keyup_callback'](); } } } }); self.e.bind("focus", function() { var aa = self.e.parent().find(".input-group-addon"); if(aa.length > 0) { var a = aa.first(); } if(aa.length > 1) { var b = aa.last(); } if(typeof(b) != 'undefined') { //b.html(""); } }); self.e.bind("blur", function() { var aa = self.e.parent().find(".input-group-addon"); if(aa.length > 0) { var a = aa.first(); } if(aa.length > 1) { var b = aa.last(); } if(typeof(a) != 'undefined') { if(a.find(".fa").hasClass("fa-spin")) { if(typeof(self.opts['nomuck']) == 'undefined' || self.opts['nomuck'] == false) { a.html(''); } self.e.val(""); self.e.data("id", ""); if(typeof(b) != 'undefined') { b.html(''); } self.e.closest(".input-group").removeClass("input-group-searching"); } } if(self.e.val() == " ") { self.e.val(""); } if(typeof(self.opts['blur_callback']) != 'undefined') { self.opts['blur_callback'](); } }); if(self.opts['min_length'] == 0) { self.e.bind("click", function() { self.e.typeahead('lookup').focus(); }); } var aa = self.e.parent().find(".input-group-addon"); if(aa.length > 0) { var a = aa.first(); } if(aa.length > 1) { var b = aa.last(); } if(typeof(b) != 'undefined') { b.bind("click", function() { var aa = $(this).parent().find(".input-group-addon"); if(aa.length > 0) { var a = aa.first(); } if(aa.length > 1) { var b = aa.last(); } if(typeof(self.opts['nomuck']) == 'undefined' || self.opts['nomuck'] == false) { a.html(''); } self.e.val(" "); self.e.data("id", ""); if(typeof(b) != 'undefined') { b.html(''); } self.e.click(); }); } }; var getVal = function() { var self = this; return self.e.val(); } return { init: init, getVal: getVal }; } var ModalModule = function() { var init = function(flush, lg, callbacks, fullsize) { var self = this; if(typeof(flush) != 'undefined' && flush) { self.ele = $("#flush-modal"); } else { self.ele = $("#main-modal"); } if(typeof(lg) != 'undefined' && lg != null) { self.ele = $("#large-modal"); } if(typeof(flush) != 'undefined' && flush && typeof(lg) != 'undefined' && lg != null) { self.ele = $("#flush-modal-large"); } if(typeof(fullsize) != 'undefined' && fullsize != null) { self.ele = $("#huge-modal"); self.fullsize = true; } if(typeof(callbacks) != 'undefined') { self.callbacks = callbacks; } else { self.callbacks = {}; } }; var init2 = function(e, callbacks) { var self = this; self.ele = e; if(typeof(callbacks) != 'undefined') { self.callbacks = callbacks; } else { self.callbacks = {}; } }; var open = function(url, params, callback) { var self = this; self.ele.modal({ }); self.ele.on('hidden.bs.modal', function (e) { self.ele.find('.modal-content').empty(); if(typeof(self.callbacks['close']) != 'undefined') { self.callbacks['close'](); } //if(typeof(self.fullsize) != 'undefined') { $("html").css("overflow-y", "auto"); //} }); self.ele.modal('show'); self.change(url, params, callback); //if(typeof(self.fullsize) != 'undefined') { $("html").css("overflow-y", "hidden"); //} }; var openStr = function(str) { var self = this; self.ele.find(".modal-content").html(str); self.ele.modal('show'); }; var close = function() { var self = this; self.ele.modal('hide'); if(typeof(self.closeCallback) != 'undefined' && self.closeCallback != null) { self.closeCallback(); } }; var change = function(url, params, callback) { var self = this; var str = '

Loading...

'; self.ele.find(".modal-content").html(str); if(typeof(params) == 'undefined' || params == null || params == false) { params = {}; } $.ajax({ type: "POST", data: params, url: url, success: function(response) { if(response['success']) { self.ele.find(".modal-content").html(response['html']); if(typeof(callback) != 'undefined' && callback != null && callback != false) { callback(response); } } else { self.ele.modal('hide'); if(typeof(response['error_code']) != 'undefined') { if(typeof(response['error_code']) == "string") { var str_str = response['error_code']; } else { var str = []; for(var i = 0; i < response['error_code'].length; i++) { str.push(response['error_code'][i]['message']); } var str_str = str.join(", "); } } else { var str_str = 'Unknown error'; } swal({ title: "Error", text: str_str, type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); } }, error: function() { self.ele.modal('hide'); swal({ title: "Error", text: "Unable to load component", type: "error", showCancelButton: false, confirmButtonClass: 'btn-danger waves-effect waves-light', confirmButtonText: 'Close' }); }, dataType: "json", cache: false }); }; var addCloseCallback = function(func) { var self = this; self.closeCallback = func; } var setCallbacks = function(callbacks) { var self = this; self.callbacks = callbacks; } return { init: init, init2: init2, open: open, openStr: openStr, close: close, change: change, addCloseCallback: addCloseCallback, setCallbacks: setCallbacks }; }; var HelpModule = function() { var init = function(opts) { var self = this; self.timer = null; self.available = true; if(typeof(opts) != 'undefined') { self.opts = opts; } else { self.opts = {}; } if(typeof(self.opts['enabled']) != 'undefined') { self.enabled = self.opts['enabled']; } else { self.enabled = true; } if(typeof(self.opts['show_once']) != 'undefined') { self.show_once = self.opts['show_once']; } else { self.show_once = false; } if(typeof(self.opts['max_items']) != 'undefined') { self.max_items = self.opts['max_items']; } else { self.max_items = 3; } self.items = { "marketing_filemanager": { "content": "In addition to being able to manage your entire file library, you can drag and drop images and videos into your email template." }, "marketing_filestyle": { "content": "Now that you've chosen a place for that file, you must choose a style for it. This is how the file will appear in your email template." }, "marketing_filestyle_done": { "content": "Great job! Your file is now embedded in your email template. Feel free to drag it around, resize it, or even delete it if you've changed your mind." }, "marketing_blocks_generic": { "content": "Generic blocks are commonly used components to an email. Simply drag and drop them into your email template." }, "marketing_blocks_clinics": { "content": "You may insert any of your clinics. Simply drag and drop them into your email template." }, "marketing_blocks_packages": { "content": "You may insert any of your packages. Simply drag and drop them into your email template." }, "marketing_layouts": { "content": "Layouts are a way to divide your email into more than one column. Each column can hold any number of blocks. Simply drag and drop the layouts into your email template. Then go to the 'Blocks' tab and choose from a variety of different blocks to fill up your layouts." }, "marketing_layouts_done": { "content": "Great job! Your layout is now embedded in your email template. Now go to the 'Blocks' tab and choose from a variety of different blocks to fill up your layout. You may also resize the columns in your layout, indicated by the green bars while hovering over it." }, "marketing_design": { "content": "The design tab allows you to change global settings on your email such as fonts and colors." }, "marketing_editor": { "content": "The editor allows you to make your email look exactly the way you want. The green bars indicate handles that can be dragged around for sizing elements. When hovering over a block, blue buttons will appear to its right. When hovering over a layout, green buttons will appear to its left. Blocks and layouts can both be dragged around to different areas in the email as well as duplicated and deleted. Text elements can be clicked on and typed into." }, "marketing_make_link": { "content": "Great job! You have made a block clickable. Clickable blocks are indicated by the link icon being yellow." }, "eventcreate_schedule": { "content": "It's time to create sessions for this event. Click on a day or click and drag across multiple days on the calendar to begin." }, "eventcreate_schedule_create": { "content": "Set the title and time of this session. You may also mark this as a repeating session. Other details can be set after the session has been created." }, "eventcreate_schedule_edit": { "content": "Here you can set more details about this session. You can also choose to override global event settings just for this particular session, such as location and instructors." }, "eventcreate_schedule_repeat": { "content": "You are now editing the settings for this entire repeating session series. All associated sessions will be affected, except those that have been overridden." }, "eventcreate_schedule_repeat_override": { "content": "You are now editing the settings for just one instance of this repeating session series. This is useful in a situation where you want to cancel or change location for just one day." } }; self.shown = {}; self.items_reverse = {}; for(var i in self.items) { self.items_reverse[self.items[i]['content']] = false; } }; var show = function(id) { var self = this; if(self.enabled && self.available) { if(self.show_once == false || (self.show_once == true && (typeof(self.shown[id]) == 'undefined' || self.shown[id] == false))) { var exists = false; $("[data-notify-text]").each(function() { if(self.items[id]['content'] == $(this).text()) { if(typeof(self.items_reverse[$(this).text()]) != 'undefined' && self.items_reverse[$(this).text()] == true) { exists = true; } } }); if(exists == false) { $.notify(self.items[id]['content'], { style: 'bootstrap', className: 'info', clickToHide: true, autoHide: false, elementPosition: 'bottom left', globalPosition: 'bottom left' }); self.items_reverse[self.items[id]['content']] = true; self.shown[id] = true; if($("[data-notify-text]").length > self.max_items) { $("[data-notify-text]").last().closest(".notifyjs-wrapper").click(); } self.available = false; self.timer = setTimeout(function() { self.available = true; }, 2000); } } //console.log(JSON.stringify(self.items_reverse)); } }; var enable = function() { var self = this; self.enabled = true; self.shown = {}; }; var disable = function() { var self = this; self.enabled = false; $(".notifyjs-wrapper").click(); } return { init: init, show: show, enable: enable, disable: disable }; }; var socket = null; var orig_title = document.title; jQuery(document).ready(function() { if($("#search-filters").length) { var filterheight = $(window).height() - $(".topbar").outerHeight(); $("#search-filters").css("height", filterheight+"px"); $("#search-filters").stick_in_parent({ 'parent': $(document.body), 'offset_top': $(".topbar").outerHeight() + 20, 'inner_scrolling': false, 'bottoming': false }); $(".footer").hide(); $(".content-page>.content").css({ 'padding-bottom': '0px', 'margin-bottom': '0px' }); } //search init $(".search-area-remove").bind("click", function() { $(".search-area").css("opacity", "0"); setTimeout(function() { $(".search-area").css("display", "none"); $(".search-area-input").val(""); $( 'body' ).removeClass('tsp-modal-open'); }, 500); }); $(".top-search-but").bind("click", function() { if($(".search-area").css("display") != "none") { $(".search-area-remove").click(); } else { $(".search-area").css("display", "block"); $(".search-area").css("opacity", "1"); $( 'body' ).addClass('tsp-modal-open'); $(".search-area-input").focus(); } }); // $(".search-area-input").keyup(function(e) { // if(e.keyCode == 13) { // alert('searching...'); // } else if(e.keyCode == 27) { // $(".search-area-remove").click(); // } // }); // if (CHAT_STATUS !== 'false') { socket = new WebSocketModule(); var opts = {}; opts['url'] = "wss://www.thrivsports.com/chat_node/"; opts['connected'] = function() { var msg = {}; msg['action'] = "connected"; socket.send(msg); } opts['disconnected'] = function() { var msg = {}; msg['action'] = "disconnected"; socket.send(msg); } opts['error'] = function(error) { } opts['message'] = function(event) { if(typeof(event) != 'undefined') { var o = JSON.parse(event.data); } else { var o = {}; o['action'] = "chat_message"; var nosound = true; } if(o['action'] == "chat_message") { var params = {}; $.ajax({ type: "POST", dataType: "json", cache: false, data: params, url: "https://www.thrivsports.com/api/shared/fetchUnreadChatMessages", success: function(response) { if(response['success']) { var num = parseInt(response['unread_chat_count']); if(num == 0) { $(".chat-notification-badge").hide(); } else { if(parseInt($(".chat-notification-badge").text()) < num && typeof(nosound) == 'undefined') { var audio = new Audio('https://s3.amazonaws.com/golfmds/gmd/sounds/pop2.wav'); audio.play(); } $(".chat-notification-badge").text(num); $(".chat-notification-badge").show(); //document.title = '('+num+') '+orig_title; } } } }); } else if(o['action'] == "locker_message") { var params = {}; $.ajax({ type: "POST", dataType: "json", cache: false, data: params, url: "https://www.thrivsports.com/api/shared/fetchUnreadLockerMessages", success: function(response) { if(response['success']) { var num = parseInt(response['unread_locker_count']); if(num == 0) { $(".locker-notification-badge").hide(); } else { if(parseInt($(".locker-notification-badge").text()) < num && typeof(nosound) == 'undefined') { var audio = new Audio('https://s3.amazonaws.com/golfmds/gmd/sounds/pop2.wav'); audio.play(); } $(".locker-notification-badge").text(num); $(".locker-notification-badge").show(); //document.title = '('+num+') '+orig_title; } } } }); } } socket.init(opts); } $(".select2").each(function() { if($(this).hasClass("select2-multiple")) { var closeOnSelect = false; } else { var closeOnSelect = true; } $(this).select2({ closeOnSelect: closeOnSelect }); }); var userSearchModule = new SearchModule(); userSearchModule.init($(".search-area-input"), { 'url': "https://www.thrivsports.com/api/shared/searchCRM/", 'displayText': function(o) { var str = ''; if(typeof(o) != 'undefined') { var profilePhoto = '//thrivsports.s3.amazonaws.com/assets/images/avatars/male_s.jpg'; if(typeof(o['photo']) != 'undefined') { profilePhoto = o['photo']; } str += '

'; str += '

'; str += '

'; str += '

'; str += 'Forsgate Golf Academy | Forsgate Country Club - Monroe Township, NJ | ThrivSports (21)'; str += '

'; if(typeof(o['student_id']) != 'undefined' && o['student_id'] != null && o['student_id'] != "") { str += '

'; } str += '

'; str += '

'; str += '

'; str += '

' + o['display_name'] + '

'; str += '

' + o['email'] + '

'; str += '

'; str += '

'; str += '

'; } return str; }, 'afterSelect': function(o) { $(".search-area-input").val(o['display_name']); window.location.href = "https://www.thrivsports.com/coach/student/?token=" + o['encrypted_id']; }, 'nomuck': true }); });

" + " PAID UNPAID"; $(this).html(htmlStr); } if($(this).hasClass("paidcheck-pending")) { var t = {}; if(typeof($(this).data("golfproid")) != 'undefined' && $(this).data("golfproid") != null) { t['golfpro_id'] = $(this).data("golfproid"); } if(typeof($(this).data("datets")) != 'undefined' && $(this).data("datets") != null) { t['start_date_ts'] = $(this).data("datets"); } t['object_type'] = $(this).data("objecttype"); t['object_id'] = $(this).data("objectid"); if(typeof($(this).data("objectid2")) != 'undefined' && $(this).data("objectid2") != null) { t['object_id2'] = $(this).data("objectid2"); } t['schedule_recurrence_id'] = $(this).data("schedulerecid"); t['subject_type'] = $(this).data("subjecttype"); t['subject_id'] = $(this).data("subjectid"); var class_name = "checkunique_"+t['object_type']+"_"+t['object_id']+"_"+t['start_date_ts']; if(typeof(t['object_id2']) != 'undefined') { class_name += "_"+t['object_id2']; } class_name += "_"+t['subject_type']+"_"+t['subject_id']; t['class_name'] = "."+class_name; params['toggles'].push(t); $(this).addClass(class_name); $(this).bind("click", function(ev) { ev.preventDefault(); ev.stopPropagation(); var e = $(this); var t = {}; if(typeof(e.data("golfproid")) != 'undefined' && e.data("golfproid") != null) { t['golfpro_id'] = e.data("golfproid"); } t['schedule_recurrence_id'] = e.data("schedulerecid"); t['start_date_ts'] = e.data("datets"); t['object_type'] = e.data("objecttype"); t['object_id'] = e.data("objectid"); if(typeof(e.data("objectid2")) != 'undefined' && e.data("objectid2") != null) { t['object_id2'] = e.data("objectid2"); } t['subject_type'] = e.data("subjecttype"); t['subject_id'] = e.data("subjectid"); t['class_name'] = ".checkunique_"+t['object_type']+"_"+t['object_id']+"_"+t['start_date_ts']; if(typeof(t['object_id2']) != 'undefined') { t['class_name'] += "_"+t['object_id2']; } t['class_name'] += "_"+t['subject_type']+"_"+t['subject_id']; if(e.hasClass("paidcheck-yes")) { t['paid'] = 1; } else { t['paid'] = 0; } var params = t; var paymentOptionsUrl = "https://www.thrivsports.com/coach/paidTogglesPaymentOptions/"; $.ajax({ url: paymentOptionsUrl, dataType: 'json', method: 'POST', data: params, success: function (response) { if (response['success'] == true) { if ( $("#actionModal").length > 0 ) { $("#actionModal").css('z-index', 99999); } $("#confirmModal .modal-body").html(response['html']); $("#confirmModal .modal-title").html('Select a Payment Option'); $("#confirmModal .modal-button-text").html('Apply payment option'); $('.modal').addClass('calendar-default-modal-paymentOptions'); $("#confirmModal").css('z-index', 999999); $("#confirmModal .confirm-modal-but").bind("click", function () { var paymentOptionSelectedUrl = "https://www.thrivsports.com/coach/paidTogglesSubmit/"; var paymentOption = $("input[name='payment_option']:checked").val(); $('.modal').removeClass('calendar-default-modal-paymentOptions'); $('.modal').removeClass('calendar-default-modal-add'); $('.modal').removeClass('calendar-default-modal'); $('.modal').removeClass('calendar-lesson-modal'); params['payment_option'] = paymentOption; switch ( paymentOption ) { case "charge": var chargeAmount = $('.charge_checkbox').parent().find("input[name='charge_amount']").val(); if ( chargeAmount < 1 ) { $("#confirmModal .modal-footer-msg").html("Please enter a value greater than or equal to 1"); return; } params['charge_amount'] = chargeAmount; break; case "lesson_credit": var chargeAmount = $('.lesson_credit_checkbox').find("input[name='charge_amount']").val(); if ( chargeAmount < 1 ) { $("#confirmModal .modal-footer-msg").html("Please enter a value greater than or equal to 1"); return; } params['charge_amount'] = chargeAmount; break; case "membership_credit": var membersihpItemId = $('#membership_payment_option').selectpicker('val'); if ( membersihpItemId == '' || membersihpItemId == null ) { $("#confirmModal .modal-footer-msg").html("Please select a membership credit option"); return; } params['membership_item'] = membersihpItemId; break; case "package_credit": var packageItemId = $('#package_payment_option').selectpicker('val'); if ( packageItemId == '' || packageItemId == null ) { $("#confirmModal .modal-footer-msg").html("Please select a package credit option"); return; } params['package_item'] = packageItemId; break; case "facility": case "send_invoice": /// nothing to do here break; } if ( $(".modal-load").length != 0 ) { $(".modal-load").fadeIn(500); } $.ajax({ url: paymentOptionSelectedUrl, dataType: 'json', method: 'POST', data: params, success: function (response) { if ( response.success ) { swal({ title: 'Success', text: 'Payment option selected completed successfully!', type: 'success', showCancelButton: false, confirmButtonClass: 'btn btn-primary waves-effect waves-light', confirmButtonText: 'Close', }); setTimeout(function () { $("#confirmModal").modal("hide"); $("#confirmModal .modal-footer-msg").html(""); if ( $("#actionModal").length > 0 ) { $("#actionModal").css('z-index', 999999); $("#actionModal").modal("hide"); } if ( $(".modal-load").length != 0 ) { $(".modal-load").fadeOut(200); } }, 750); } else { if ( response.error_msg ) { $("#confirmModal .modal-footer-msg").html(response.error_msg); } else { $("#confirmModal .modal-footer-msg").html("An error occurred"); } if ( $(".modal-load").length != 0 ) { $(".modal-load").fadeOut(200); } } }, failure: function () { $("#confirmModal .modal-footer-msg").html("An error occurred."); if ( $(".modal-load").length != 0 ) { $(".modal-load").fadeOut(500); } } }); }); $('#confirmModal').on('hidden.bs.modal', function (e) { if ( $("#actionModal").length > 0 ) { $("#actionModal").css('z-index', 999999); } $('#confirmModal').unbind('hidden.bs.modal'); $('#confirmModal .confirm-modal-but').unbind('click'); }); $("#confirmModal").modal('show'); } else { $("#confirmModal .modal-footer-msg").html("An error occurred."); } }, failure: function () { $("#actionModal .modal-body").html("An error occurred."); } }); }); } }); fetchPaidToggles(params);}function addTplModals() { // this builds our confirmation modal if ($("#confirmModal").length == 0) { var str = ""; str += '

'; str += '

'; str += '

'; str += '

Confirm Action

'; str += '

Are you sure you want to do that?

'; str += '

'; str += '

'; str += ''; str += ''; str += '

'; str += '

'; str += 'Loading...'; str += '

'; $(document.body).append(str); self.confirmModalFooterMsg = $("#confirmModal .modal-footer-msg"); $('#confirmModal').on('hidden.bs.modal', function (e) { $('.fc-highlight').remove(); $('.fc-highlight2').removeClass("fc-highlight2"); if (typeof (self.pulser) != 'undefined') { clearInterval(self.pulser); } $("#confirmModal .modal-footer").show(); }); }}$(document).ready(function() { bindPaidToggles(); addTplModals();});

Top Articles

You might also like

Latest Posts

Article information

Author: Edwin Metz

Last Updated: 09/28/2022

Views: 6387

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Edwin Metz

Birthday: 1997-04-16

Address: 51593 Leanne Light, Kuphalmouth, DE 50012-5183

Phone: +639107620957

Job: Corporate Banking Technician

Hobby: Reading, scrapbook, role-playing games, Fishing, Fishing, Scuba diving, Beekeeping

Introduction: My name is Edwin Metz, I am a fair, energetic, helpful, brave, outstanding, nice, helpful person who loves writing and wants to share my knowledge and understanding with you.