'), this.form_field_jq.hide().after(this.container), this.dropdown = this.container.find("div.chosen-drop").first(), this.search_field = this.container.find("input").first(), this.search_results = this.container.find("ul.chosen-results").first(), this.search_field_scale(), this.search_no_results = this.container.find("li.no-results").first(), this.is_multiple ? (this.search_choices = this.container.find("ul.chosen-choices").first(), this.search_container = this.container.find("li.search-field").first()) : (this.search_container = this.container.find("div.chosen-search").first(), this.selected_item = this.container.find(".chosen-single").first()), this.results_build(), this.set_tab_index(), this.set_label_behavior()
}, Chosen.prototype.on_ready = function () {
return this.form_field_jq.trigger("chosen:ready", {chosen: this})
}, Chosen.prototype.register_observers = function () {
var a = this;
return this.container.bind("touchstart.chosen", function (b) {
return a.container_mousedown(b), b.preventDefault()
}), this.container.bind("touchend.chosen", function (b) {
return a.container_mouseup(b), b.preventDefault()
}), this.container.bind("mousedown.chosen", function (b) {
a.container_mousedown(b)
}), this.container.bind("mouseup.chosen", function (b) {
a.container_mouseup(b)
}), this.container.bind("mouseenter.chosen", function (b) {
a.mouse_enter(b)
}), this.container.bind("mouseleave.chosen", function (b) {
a.mouse_leave(b)
}), this.search_results.bind("mouseup.chosen", function (b) {
a.search_results_mouseup(b)
}), this.search_results.bind("mouseover.chosen", function (b) {
a.search_results_mouseover(b)
}), this.search_results.bind("mouseout.chosen", function (b) {
a.search_results_mouseout(b)
}), this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen", function (b) {
a.search_results_mousewheel(b)
}), this.search_results.bind("touchstart.chosen", function (b) {
a.search_results_touchstart(b)
}), this.search_results.bind("touchmove.chosen", function (b) {
a.search_results_touchmove(b)
}), this.search_results.bind("touchend.chosen", function (b) {
a.search_results_touchend(b)
}), this.form_field_jq.bind("chosen:updated.chosen", function (b) {
a.results_update_field(b)
}), this.form_field_jq.bind("chosen:activate.chosen", function (b) {
a.activate_field(b)
}), this.form_field_jq.bind("chosen:open.chosen", function (b) {
a.container_mousedown(b)
}), this.form_field_jq.bind("chosen:close.chosen", function (b) {
a.input_blur(b)
}), this.search_field.bind("blur.chosen", function (b) {
a.input_blur(b)
}), this.search_field.bind("keyup.chosen", function (b) {
a.keyup_checker(b)
}), this.search_field.bind("keydown.chosen", function (b) {
a.keydown_checker(b)
}), this.search_field.bind("focus.chosen", function (b) {
a.input_focus(b)
}), this.search_field.bind("cut.chosen", function (b) {
a.clipboard_event_checker(b)
}), this.search_field.bind("paste.chosen", function (b) {
a.clipboard_event_checker(b)
}), this.is_multiple ? this.search_choices.bind("click.chosen", function (b) {
a.choices_click(b)
}) : this.container.bind("click.chosen", function (a) {
a.preventDefault()
})
}, Chosen.prototype.destroy = function () {
return a(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action), this.search_field[0].tabIndex && (this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex), this.container.remove(), this.form_field_jq.removeData("chosen"), this.form_field_jq.show()
}, Chosen.prototype.search_field_disabled = function () {
return this.is_disabled = this.form_field_jq[0].disabled, this.is_disabled ? (this.container.addClass("chosen-disabled"), this.search_field[0].disabled = !0, this.is_multiple || this.selected_item.unbind("focus.chosen", this.activate_action), this.close_field()) : (this.container.removeClass("chosen-disabled"), this.search_field[0].disabled = !1, this.is_multiple ? void 0 : this.selected_item.bind("focus.chosen", this.activate_action))
}, Chosen.prototype.container_mousedown = function (b) {
return this.is_disabled || (b && "mousedown" === b.type && !this.results_showing && b.preventDefault(), null != b && a(b.target).hasClass("search-choice-close")) ? void 0 : (this.active_field ? this.is_multiple || !b || a(b.target)[0] !== this.selected_item[0] && !a(b.target).parents("a.chosen-single").length || (b.preventDefault(), this.results_toggle()) : (this.is_multiple && this.search_field.val(""), a(this.container[0].ownerDocument).bind("click.chosen", this.click_test_action), this.results_show()), this.activate_field())
}, Chosen.prototype.container_mouseup = function (a) {
return "ABBR" !== a.target.nodeName || this.is_disabled ? void 0 : this.results_reset(a)
}, Chosen.prototype.search_results_mousewheel = function (a) {
var b;
return a.originalEvent && (b = a.originalEvent.deltaY || -a.originalEvent.wheelDelta || a.originalEvent.detail), null != b ? (a.preventDefault(), "DOMMouseScroll" === a.type && (b = 40 * b), this.search_results.scrollTop(b + this.search_results.scrollTop())) : void 0
}, Chosen.prototype.blur_test = function () {
return !this.active_field && this.container.hasClass("chosen-container-active") ? this.close_field() : void 0
}, Chosen.prototype.close_field = function () {
return a(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action), this.active_field = !1, this.results_hide(), this.container.removeClass("chosen-container-active"), this.clear_backstroke(), this.show_search_field_default(), this.search_field_scale()
}, Chosen.prototype.activate_field = function () {
return this.container.addClass("chosen-container-active"), this.active_field = !0, this.search_field.val(this.search_field.val()), this.search_field.focus()
}, Chosen.prototype.test_active_click = function (b) {
var c;
return c = a(b.target).closest(".chosen-container"), c.length && this.container[0] === c[0] ? this.active_field = !0 : this.close_field()
}, Chosen.prototype.results_build = function () {
return this.parsing = !0, this.selected_option_count = null, this.results_data = SelectParser.select_to_array(this.form_field), this.is_multiple ? this.search_choices.find("li.search-choice").remove() : this.is_multiple || (this.single_set_selected_text(), this.disable_search || this.form_field.options.length <= this.disable_search_threshold ? (this.search_field[0].readOnly = !0, this.container.addClass("chosen-container-single-nosearch")) : (this.search_field[0].readOnly = !1, this.container.removeClass("chosen-container-single-nosearch"))), this.update_results_content(this.results_option_build({first: !0})), this.search_field_disabled(), this.show_search_field_default(), this.search_field_scale(), this.parsing = !1
}, Chosen.prototype.result_do_highlight = function (a) {
var b, c, d, e, f;
if (a.length) {
if (this.result_clear_highlight(), this.result_highlight = a, this.result_highlight.addClass("highlighted"), d = parseInt(this.search_results.css("maxHeight"), 10), f = this.search_results.scrollTop(), e = d + f, c = this.result_highlight.position().top + this.search_results.scrollTop(), b = c + this.result_highlight.outerHeight(), b >= e) return this.search_results.scrollTop(b - d > 0 ? b - d : 0);
if (f > c) return this.search_results.scrollTop(c)
}
}, Chosen.prototype.result_clear_highlight = function () {
return this.result_highlight && this.result_highlight.removeClass("highlighted"), this.result_highlight = null
}, Chosen.prototype.results_show = function () {
return this.is_multiple && this.max_selected_options <= this.choices_count() ? (this.form_field_jq.trigger("chosen:maxselected", {chosen: this}), !1) : (this.container.addClass("chosen-with-drop"), this.results_showing = !0, this.search_field.focus(), this.search_field.val(this.search_field.val()), this.winnow_results(), this.form_field_jq.trigger("chosen:showing_dropdown", {chosen: this}))
}, Chosen.prototype.update_results_content = function (a) {
return this.search_results.html(a)
}, Chosen.prototype.results_hide = function () {
return this.results_showing && (this.result_clear_highlight(), this.container.removeClass("chosen-with-drop"), this.form_field_jq.trigger("chosen:hiding_dropdown", {chosen: this})), this.results_showing = !1
}, Chosen.prototype.set_tab_index = function () {
var a;
return this.form_field.tabIndex ? (a = this.form_field.tabIndex, this.form_field.tabIndex = -1, this.search_field[0].tabIndex = a) : void 0
}, Chosen.prototype.set_label_behavior = function () {
var b = this;
return this.form_field_label = this.form_field_jq.parents("label"), !this.form_field_label.length && this.form_field.id.length && (this.form_field_label = a("label[for='" + this.form_field.id + "']")), this.form_field_label.length > 0 ? this.form_field_label.bind("click.chosen", function (a) {
return b.is_multiple ? b.container_mousedown(a) : b.activate_field()
}) : void 0
}, Chosen.prototype.show_search_field_default = function () {
return this.is_multiple && this.choices_count() < 1 && !this.active_field ? (this.search_field.val(this.default_text), this.search_field.addClass("default")) : (this.search_field.val(""), this.search_field.removeClass("default"))
}, Chosen.prototype.search_results_mouseup = function (b) {
var c;
return c = a(b.target).hasClass("active-result") ? a(b.target) : a(b.target).parents(".active-result").first(), c.length ? (this.result_highlight = c, this.result_select(b), this.search_field.focus()) : void 0
}, Chosen.prototype.search_results_mouseover = function (b) {
var c;
return c = a(b.target).hasClass("active-result") ? a(b.target) : a(b.target).parents(".active-result").first(), c ? this.result_do_highlight(c) : void 0
}, Chosen.prototype.search_results_mouseout = function (b) {
return a(b.target).hasClass("active-result") ? this.result_clear_highlight() : void 0
}, Chosen.prototype.choice_build = function (b) {
var c, d, e = this;
return c = a("", {"class": "search-choice"}).html("" + this.choice_label(b) + ""), b.disabled ? c.addClass("search-choice-disabled") : (d = a("", {
"class": "search-choice-close",
"data-option-array-index": b.array_index
}), d.bind("click.chosen", function (a) {
return e.choice_destroy_link_click(a)
}), c.append(d)), this.search_container.before(c)
}, Chosen.prototype.choice_destroy_link_click = function (b) {
return b.preventDefault(), b.stopPropagation(), this.is_disabled ? void 0 : this.choice_destroy(a(b.target))
}, Chosen.prototype.choice_destroy = function (a) {
return this.result_deselect(a[0].getAttribute("data-option-array-index")) ? (this.show_search_field_default(), this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1 && this.results_hide(), a.parents("li").first().remove(), this.search_field_scale()) : void 0
}, Chosen.prototype.results_reset = function () {
return this.reset_single_select_options(), this.form_field.options[0].selected = !0, this.single_set_selected_text(), this.show_search_field_default(), this.results_reset_cleanup(), this.form_field_jq.trigger("change"), this.active_field ? this.results_hide() : void 0
}, Chosen.prototype.results_reset_cleanup = function () {
return this.current_selectedIndex = this.form_field.selectedIndex, this.selected_item.find("abbr").remove()
}, Chosen.prototype.result_select = function (a) {
var b, c;
return this.result_highlight ? (b = this.result_highlight, this.result_clear_highlight(), this.is_multiple && this.max_selected_options <= this.choices_count() ? (this.form_field_jq.trigger("chosen:maxselected", {chosen: this}), !1) : (this.is_multiple ? b.removeClass("active-result") : this.reset_single_select_options(), b.addClass("result-selected"), c = this.results_data[b[0].getAttribute("data-option-array-index")], c.selected = !0, this.form_field.options[c.options_index].selected = !0, this.selected_option_count = null, this.is_multiple ? this.choice_build(c) : this.single_set_selected_text(this.choice_label(c)), (a.metaKey || a.ctrlKey) && this.is_multiple || this.results_hide(), this.search_field.val(""), (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) && this.form_field_jq.trigger("change", {selected: this.form_field.options[c.options_index].value}), this.current_selectedIndex = this.form_field.selectedIndex, a.preventDefault(), this.search_field_scale())) : void 0
}, Chosen.prototype.single_set_selected_text = function (a) {
return null == a && (a = this.default_text), a === this.default_text ? this.selected_item.addClass("chosen-default") : (this.single_deselect_control_build(), this.selected_item.removeClass("chosen-default")), this.selected_item.find("span").html(a)
}, Chosen.prototype.result_deselect = function (a) {
var b;
return b = this.results_data[a], this.form_field.options[b.options_index].disabled ? !1 : (b.selected = !1, this.form_field.options[b.options_index].selected = !1, this.selected_option_count = null, this.result_clear_highlight(), this.results_showing && this.winnow_results(), this.form_field_jq.trigger("change", {deselected: this.form_field.options[b.options_index].value}), this.search_field_scale(), !0)
}, Chosen.prototype.single_deselect_control_build = function () {
return this.allow_single_deselect ? (this.selected_item.find("abbr").length || this.selected_item.find("span").first().after(''), this.selected_item.addClass("chosen-single-with-deselect")) : void 0
}, Chosen.prototype.get_search_text = function () {
return a("").text(a.trim(this.search_field.val())).html()
}, Chosen.prototype.winnow_results_set_highlight = function () {
var a, b;
return b = this.is_multiple ? [] : this.search_results.find(".result-selected.active-result"), a = b.length ? b.first() : this.search_results.find(".active-result").first(), null != a ? this.result_do_highlight(a) : void 0
}, Chosen.prototype.no_results = function (b) {
var c;
return c = a('
' + this.results_none_found + ' ""
'), c.find("span").first().html(b), this.search_results.append(c), this.form_field_jq.trigger("chosen:no_results", {chosen: this})
}, Chosen.prototype.no_results_clear = function () {
return this.search_results.find(".no-results").remove()
}, Chosen.prototype.keydown_arrow = function () {
var a;
return this.results_showing && this.result_highlight ? (a = this.result_highlight.nextAll("li.active-result").first()) ? this.result_do_highlight(a) : void 0 : this.results_show()
}, Chosen.prototype.keyup_arrow = function () {
var a;
return this.results_showing || this.is_multiple ? this.result_highlight ? (a = this.result_highlight.prevAll("li.active-result"), a.length ? this.result_do_highlight(a.first()) : (this.choices_count() > 0 && this.results_hide(), this.result_clear_highlight())) : void 0 : this.results_show()
}, Chosen.prototype.keydown_backstroke = function () {
var a;
return this.pending_backstroke ? (this.choice_destroy(this.pending_backstroke.find("a").first()), this.clear_backstroke()) : (a = this.search_container.siblings("li.search-choice").last(), a.length && !a.hasClass("search-choice-disabled") ? (this.pending_backstroke = a, this.single_backstroke_delete ? this.keydown_backstroke() : this.pending_backstroke.addClass("search-choice-focus")) : void 0)
}, Chosen.prototype.clear_backstroke = function () {
return this.pending_backstroke && this.pending_backstroke.removeClass("search-choice-focus"), this.pending_backstroke = null
}, Chosen.prototype.keydown_checker = function (a) {
var b, c;
switch (b = null != (c = a.which) ? c : a.keyCode, this.search_field_scale(), 8 !== b && this.pending_backstroke && this.clear_backstroke(), b) {
case 8:
this.backstroke_length = this.search_field.val().length;
break;
case 9:
this.results_showing && !this.is_multiple && this.result_select(a), this.mouse_on_container = !1;
break;
case 13:
this.results_showing && a.preventDefault();
break;
case 32:
this.disable_search && a.preventDefault();
break;
case 38:
a.preventDefault(), this.keyup_arrow();
break;
case 40:
a.preventDefault(), this.keydown_arrow()
}
}, Chosen.prototype.search_field_scale = function () {
var b, c, d, e, f, g, h, i, j;
if (this.is_multiple) {
for (d = 0, h = 0, f = "position:absolute; left: -1000px; top: -1000px; display:none;", g = ["font-size", "font-style", "font-weight", "font-family", "line-height", "text-transform", "letter-spacing"], i = 0, j = g.length; j > i; i++) e = g[i], f += e + ":" + this.search_field.css(e) + ";";
return b = a("", {style: f}), b.text(this.search_field.val()), a("body").append(b), h = b.width() + 25, b.remove(), c = this.container.outerWidth(), h > c - 10 && (h = c - 10), this.search_field.css({width: h + "px"})
}
}, Chosen
}(AbstractChosen)
}).call(this);
/*=========./pages/find-users.js=========*/
RagDoll.register('find-user', function (Sandbox, $) {
var emails_count = 0;
var emails_push_count = 0;
var count_limit = 831;
var email_list = '';
var request_sent = false;
var request_push_sent = false;
function init() {
$('span#email-number').html('');
$('span#push-notification-user-number').html('');
$('.contacts div#push_contacts_found ul').html('');
$('textarea#emails_found').val('');
Sandbox.notify(RagDoll.event('find-user.map_init'));
Sandbox.listen(RagDoll.event('find-user.map_init'), map_init, this);
$('select[name=select-assignment]').change(localize_assignment);
$('div.contacts span.show').click(function () {
$('div.contacts div#push_contacts_found').toggle();
});
// $('button.send_push_notification').click(xhr_send_push_notification);
}
function map_init() {
$('div.search-map').each(function () {
if ($(':visible', this)) {
$(this).attr('id', 'location');
$('.location-choose').attr('id', 'location-choose');
$('.location_text').attr('id', 'location_text');
$('.location_error').attr('id', 'location_error');
$('.location_submit').attr('id', 'location_submit');
$('.location_latitude').attr('id', 'location_latitude');
$('.location_longitude').attr('id', 'location_longitude');
Sandbox.notify(RagDoll.event('inline-map.load'), {
google: {
zoom: 8
},
$map: $('#location-choose'),
$input: $('#location_text'),
$error: $('#location_error'),
$button: $('#location_submit'),
bounding: true,
$zoom: $('input[name=bounding\\[zoom\\]]'),
$center: $('input[name=bounding\\[center\\]]'),
$north_east: $('input[name=bounding\\[north_east\\]]'),
$south_west: $('input[name=bounding\\[south_west\\]]')
});
}
});
}
function localize_assignment() {
var bounding = $(this).val().split("|");
var zoom = bounding[0];
var center = bounding[1].split(",");
var north_east = bounding[2].split(",");
var south_west = bounding[3].split(",");
$('input[name=bounding\\[zoom\\]]').val(zoom);
$('input[name=bounding\\[center\\]]').val(center);
$('input[name=bounding\\[north_east\\]]').val(north_east);
$('input[name=bounding\\[south_west\\]]').val(south_west);
$('div.search-map').each(function () {
Sandbox.notify(RagDoll.event('inline-map.load'), {
google: {},
$map: $('#location-choose'),
$input: $('#location_text'),
$error: $('#location_error'),
$button: $('#location_submit'),
bounding: true,
$zoom: $('input[name=bounding\\[zoom\\]]'),
$center: $('input[name=bounding\\[center\\]]'),
$north_east: $('input[name=bounding\\[north_east\\]]'),
$south_west: $('input[name=bounding\\[south_west\\]]')
});
});
}
function destroy() {
Sandbox.clean();
}
return {
init: init,
destroy: destroy
};
});
/*=========./pages/news_article.js=========*/
RagDoll.register('news_article', function (Sandbox, $) {
var user_to_insert_cache = {};
var boo_debug = true;
var tag_cache = {};
var ass_cache = {};
var filepicker_form = 'form.form-upload:not([id])';
var swf_cntrl = '.upload-container';
var intInitCount = 0;
var filepicker_instances = {};
var id_upload_form = $('#video-upload').attr('data-id');
var fileNameSelector = 'input[name=_fn]';
var s3LocationSelector = 'input[name=_r_fpk]';
var uploadProgressSelector = '.progress-container .filler';
var uploadPercentSelector = '.progress-container .percent';
var uploadIframer = '.upload-iframe';
var uploadLoading = swf_cntrl + ' .upload-loading';
var uploadDataContainer = '.upload-data-container';
// Valid file extensions that we accept - both upper and lower case
var arr_valid_extensions = [
'.mov', '.mp4', '.mts', '.m4v', '.wmv', '.flv', '.3gp', '.avi', '.dv', '.mpg', '.mpe', '.mpeg', '.mp2v', '.m2v', '.m2s',
'swf', '.wav', '.3gp2', '.asf', '.aiff', '.mkv', '.ogg', '.ogm', '.pcm', '.rm', '.rmvb', '.vob', '.webm', '.3ivx', '.divx',
'xvid', '.mjpeg', '.on2', '.qpeg', '.qt', '.MOV', '.MP4', '.MTS', '.M4V', '.WMV', '.FLV', '.3GP', '.AVI', '.DV', '.MPG',
'MPE', '.MPEG', '.MP2V', '.M2V', '.M2S', '.SWF', '.WAV', '.3GP2', '.ASF', '.AIFF', '.MKV', '.OGG', '.OGM', '.PCM', '.RM',
'RMVB', '.VOB', '.WEBM', '.3IVX', '.DIVX', '.XVID', '.MJPEG', '.ON2', '.QPEG', '.QT'
];
var ccEmails = {};
function init() {
Sandbox.notify(RagDoll.event('news_article.users_init'));
Sandbox.notify(RagDoll.event('news_article.users2_init'));
Sandbox.notify(RagDoll.event('news_article.newsorg2_init'));
Sandbox.notify(RagDoll.event('news_article.news_organisation_init'));
Sandbox.notify(RagDoll.event('news_article.datepicker_init'));
Sandbox.notify(RagDoll.event('news_article.datepicker_init_new'));
Sandbox.notify(RagDoll.event('news_article.datepicker_init_regular'));
Sandbox.notify(RagDoll.event('news_article.map_upload_init'));
Sandbox.notify(RagDoll.event('news_article.filepicker_init'));
Sandbox.listen(RagDoll.event('news_article.users_init'), users_init, this);
Sandbox.listen(RagDoll.event('news_article.users2_init'), users2_init, this);
Sandbox.listen(RagDoll.event('news_article.newsorg2_init'), newsorg2_init, this);
Sandbox.listen(RagDoll.event('news_article.news_organisation_init'), news_organisation_init, this);
Sandbox.listen(RagDoll.event('news_article.datepicker_init'), datepicker_init, this);
Sandbox.listen(RagDoll.event('news_article.datepicker_init_new'), datepicker_init_new, this);
Sandbox.listen(RagDoll.event('news_article.datepicker_init_regular'), datepicker_init_regular, this);
Sandbox.listen(RagDoll.event('news_article.map_upload_init'), map_upload_init, this);
Sandbox.listen(RagDoll.event('news_article.filepicker_init'), filepicker_init, this);
$('#currency, #unit').on('change', function () {
let currency_val = $('#currency').val();
let price_for_video_val = $('.unit').val();
if (price_for_video_val === '') {
price_for_video_val = $('.total-price').text().substring(1);
}
$.ajax({
url: ajax_url + 'currency/conversion_of_single_video_price',
type: 'POST',
data: {currency: currency_val, price_for_video: price_for_video_val},
dateType: 'json',
xhrFields: {
withCredentials: true,
allowCrossDomainPages: true
},
success: function (data) {
$('.exchange_rate').val(data.exchange_rate);
$('.calculated_price').val(data.price_of_video_conversion);
if (currency_val === 'usd') {
$('.usd-warning-message').html('
Video price will be overridden with USD currency you have selected above
');
}
},
error: function () {
alert('There was an error getting exchange rate');
}
})
return false;
});
$("input[name*='[slugline]']").on('change', function () {
check_slugline(this);
});
$('#form-buy select').on('change', function () {
if (this.id === 'currency') {
return false;
}
buy_change_select(this);
});
$('#production_name').on('change', function () {
buy_change_select(this);
});
$('#form-buy').on('submit', function (e) {
e.preventDefault();
return false;
});
$('#buy-cancel').on('click', function (e) {
e.preventDefault();
$('#user-to-insert').parent().append(' ');
$('#user-to-insert').siblings('span').remove();
$('#user-to-insert').remove();
users_init();
$('#buy-form-tr').hide();
$('#buy-form-container').empty().html('');
$('#buy-form-user-selected-button').show();
return false;
});
$('#multiple_emails').on('keyup', function (e) {
if (e.keyCode === 13) {
let email = $(this).val();
if (!isValidEmailAddress(email)) {
alert('The email address you have entered is invalid');
return false;
}
$('.cc-emails-container').append('
' + email + '
');
ccEmails[$(this).val()] = $(this).val();
$('#multiple-emails-submission').val(JSON.stringify(ccEmails));
$('#multiple_emails').val('');
}
});
$('#remove-cc-email').on('click', function (e) {
e.preventDefault();
delete ccEmails[$(this).parent().data('value')];
$('.cc-emails-container .cc-email .name[data-value="' + $(this).parent().data('value') + '"]').remove();
$('#multiple-emails-submission').val(JSON.stringify(ccEmails));
});
function isValidEmailAddress(emailAddress) {
var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
return pattern.test(emailAddress);
}
$('#buy-submit').on('click', function (e) {
e.preventDefault();
var form = $('#form-buy');
$('#buy-submit', form).attr('disabled', 'disabled').addClass('disabled');
var price_selected = $('input[name=buy-price-select]:checked', form).val();
var price_video = -1;
if (price_selected == 'manual') {
price_video = $('#buy-set-price', form).val();
}
$.ajax({
type: 'POST',
url: 'https://' + window.location.host + '/ajax/video/add_to_cart',
data: {
data: $(form).serialize(),
user: $('#user-to-insert').attr('value'),
price: price_video
},
success: function (data) {
if (data.error) {
alert(data.error);
$('#buy-submit', form).removeAttr('disabled', 'disabled').removeClass('disabled');
return false;
}
if (data.redirect) {
window.location.href = data.redirect;
} else {
if (data.status == 'Success') {
window.location.href = 'https://' + window.location.host + '/users/all/cart/' + $('#user-to-insert').attr('value');
} else {
}
}
$('#buy-submit', form).removeAttr('disabled').removeClass('disabled');
}
});
return false;
});
$(document).on('click', '.dispute-won', function (e) {
e.preventDefault();
var wonButton = $(this);
var disputeId = $(this).data('dispute-id');
var na_id = $(this).data('na-id');
$.ajax({
type: 'POST',
url: ajax_url + 'video/win_dispute',
data: {
'dispute_id': disputeId
},
xhrFields: {
withCredentials: true,
allowCrossDomainPages: true
},
beforeSend: function () {
wonButton.attr('disabled', 1);
},
dataType: 'json',
success: function (json) {
if (json.status == 1) {
location.reload();
}
}
});
});
$(document).on('click', '.dispute-lost', function (e) {
e.preventDefault();
var lostButton = $(this);
var disputeId = $(this).data('dispute-id');
var na_id = $(this).data('na-id');
$.ajax({
type: 'POST',
url: ajax_url + 'video/lose_dispute',
data: {
'dispute_id': disputeId,
'naid': na_id
},
xhrFields: {
withCredentials: true,
allowCrossDomainPages: true
},
beforeSend: function () {
lostButton.attr('disabled', 1);
},
dataType: 'json',
success: function (json) {
if (json.status == 1) {
location.reload();
}
}
});
});
$('div.label.thumbnail').on('click', function (e) {
e.preventDefault();
_process_thumbnail_click(e);
return false;
});
add_tag();
delete_tag();
delete_all_tags();
add_pc_tag();
delete_pc_tag();
if (false && $('html').hasClass('ie')) {
show_error($(filepicker_form), 'Some members are currently experiencing difficulties uploading video using Internet Explorer \
- the web browser you\'re using right now. We apologise for any inconvenience and assure you we\'re working on a fix.
\
In the meantime, we recommend you use the Google Chrome web browser to upload video. Download now', 'info');
}
$('input:not(textarea), select').on('keypress', function (e) {
var code = e.keyCode || e.which;
if (code == 13) {
e.preventDefault();
return false;
}
});
$('form.form-upload input[type=submit]').on('click', function (e) {
e.preventDefault();
_process_form_submit(this);
return false;
});
$('div.label.assignment-label input[type=checkbox]').on('change', function (e) {
_process_assignment_checkbox_click(e);
});
$('#last-license-terms').on('click', loadLastLicenseTerms);
}
function loadLastLicenseTerms(e) {
var form = $('#form-buy');
$('.buy-price', form).empty().html('');
$('.buy-price', form).addClass('loading');
$.ajax({
type: 'POST',
url: 'https://' + window.location.host + '/ajax/video/get_last_pricing_options',
data: {
data: $(form).serialize(),
user: $('#user-to-insert').attr('value')
},
success: function (data) {
if (data.redirect) {
window.location.href = data.redirect;
} else {
$('#buy-form-container').empty().html('').append(data);
}
}
});
return false;
}
function check_slugline(obj) {
var slugline = $(obj).val();
if (slugline.length > 0) {
$.ajax({
type: 'POST',
url: 'https://' + window.location.host + '/ajax/video/check_duplicate_slugline',
beforeSend: function () {
$('#sluglineCheckStatus').css('color', '#000');
$('#sluglineCheckStatus').html('Checking...');
},
data: {
slugline: slugline
},
success: function (data) {
if (data.status === true) {
$('#sluglineCheckStatus').css('color', 'red');
$('#sluglineCheckStatus').html('⚠ This slugline has been used in the last 3 months. Please check with Head of News before submitting.');
} else {
$('#sluglineCheckStatus').css('color', 'green');
$('#sluglineCheckStatus').html('✓');
}
}
});
} else {
//reset if empty
$('#sluglineCheckStatus').empty();
}
return false;
}
function _process_thumbnail_click(event) {
var cur = $('div.label.thumbnail div.current');
var all = $('div.label.thumbnail div.all');
var p = $('div.label.thumbnail p');
var a = $(event.target);
if ($(all).is(':hidden')) {
$(cur).hide();
$(p).hide();
$(all).show();
// A new thumbnail is selected
} else {
if ($(a).attr('width') != 640) {
$('a', all).removeClass("over");
$(a).parent().addClass("over");
$('#large-thumb img').attr('src', a.attr('src'));
$('a', cur).replaceWith($(a).parent().clone());
$('input.thumbnail').val($(a).attr('data-i'));
$('.current a img').css('width', $('.current a img').width() * 6.4);
$('.current a img').css('height', $('.current a img').height() * 6.4);
$(cur).show();
$(p).show();
$(all).hide();
}
}
}
function filepicker_init() {
if (!window.filepicker) {
// Display message and link to alternative upload page
var r = 'Uh oh, there\'s been a problem loading this page.
';
r += 'Solution
First, refresh this page to try again, most of the time this will work.
';
$(".text", $(uploadLoading)).html(r);
$(uploadLoading).css("margin-left", "50px");
$(".ani", $(uploadLoading)).remove();
// Log this failure
_log_error_reporting($(filepicker_form).val(), 'filepicker_fail');
return;
}
$('.upload-iframe').each(function () {
var _self = this;
var form = $('#admin-form');
$(form).attr('id', 'u' + intInitCount);
$(form).attr('data-c', intInitCount);
filepicker_instances[intInitCount] = _self;
intInitCount++;
uploadProgressUpdatingGetSet(form, 0);
uploadProgressPercentageGetSet(form, 0);
uploadInitGetSet(form, 0);
uploadCompleteGetSet(form, 0);
var fileSelector = $('.btnUpload');
var button = $('.button-container .button');
var _fsz = $("input[name=_fsz]").val(); // Filepicker.io Size
var _fpk = $("input[name=_fpk]").val(); // Filepicker.io Key
var _fpp = $("input[name=_fpp]").val(); // Filepicker.io Policy
var _fps = $("input[name=_fps]").val(); // Filepicker.io Policy Signature
var _fpp_ie = $("input[name=_fpp_ie]").val(); // Filepicker.io Policy specifically for IE
var _fps_ie = $("input[name=_fps_ie]").val(); // Filepicker.io Policy Signature specifically for IE
var _filename = $(fileNameSelector).val(); // S3 filename
// Add an id to the iframe
$(uploadIframer, form).attr('id', 'iframe_' + $(form).attr('data-c'));
// Hide the Loading page, show the upload function
$(uploadIframer, form).on('load', function () {
$(uploadLoading, form).addClass('hidden');
$(this).removeClass('hidden').hide().fadeIn('fast').show();
});
filepicker.setKey(_fpk);
filepicker.pickAndStore(
{
service: 'COMPUTER',
openTo: 'COMPUTER',
extensions: arr_valid_extensions,
container: 'iframe_0',
maxSize: _fsz,
policy: _fpp_ie,
signature: _fps_ie
},
{
location: 'S3',
path: 'filepicker/' + _filename,
policy: _fpp,
signature: _fps
},
// Success
function (FPFile) {
//uploadCompleteGetSet(form, 1);
//_log_error_reporting(_filename, 'success', FPFile);
FPFile = FPFile[0];
// Save and log file attributes
$("input[name=_r_fn]").val(FPFile.filename);// Original filename
$("input[name=_r_sz]").val(FPFile.size);// File size
$("input[name=_r_mi]").val(FPFile.mimetype);// File mimetype
$("input[name=_r_fpk]").val(FPFile.key);// S3 location
$("input[name=_r_fpu]").val(FPFile.url);// Filepicker URL
// _log_error_reporting(_filename, 'success', {
// 'filename': FPFile.filename,
// 'size': FPFile.size,
// 'mime': FPFile.mimetype,
// 's3_location': FPFile.key,
// 'url': FPFile.url
// });
},
// Error
function (FPError) {
handleError(form, FPError);
}
);
_notify_all_listeners();
});
}
function _notify_all_listeners() {
// upload.map_upload_init isn't here to do with the grey box
// bug in Google Maps when changing visibility from hidden to show
Sandbox.notify(RagDoll.event('upload.tag_init'));
Sandbox.notify(RagDoll.event('upload.assignment_init'));
Sandbox.notify(RagDoll.event('upload.datepicker_init'));
}
function _log_error_reporting(filename, key, val) {
//we are not reporting upload errors in CMS, We got same code upload.js
return;
DollHouse.ajax({
url: 'upload/log_error_reporting',
type: 'POST',
data: {
id: id_upload_form,
f: filename,
key: key,
val: (typeof val !== 'undefined' ? val : null)
}
});
}
var uploadInitGetSet = function (form, set) {
if (typeof set === 'undefined') {
return $(form).data('data-upload-init') || 0;
}
return $(form).data('data-upload-init', set);
}
var uploadCompleteGetSet = function (form, set) {
if (typeof set === 'undefined') {
return $(form).data('data-upload-complete') || 0;
}
return $(form).data('data-upload-complete', set);
}
var uploadProgressUpdatingGetSet = function (form, set) {
if (typeof set === 'undefined') {
return $(form).data('data-upload-updating') || 0;
}
return $(form).data('data-upload-updating', set);
}
var uploadProgressPercentageGetSet = function (form, set) {
if (typeof set === 'undefined') {
return $(form).data('data-upload-perc') || 0;
}
return $(form).data('data-upload-perc', set);
}
var _progress_to_data_entry_because_upload_has_started = function (form) {
navigate_away_halter(form);
$('.selector-container', form).addClass('hide');
$('.video-title', form).text($('.btnUpload', form).val().replace(/C:\\fakepath\\/i, '')).fadeIn('fast');
_toggle_upload_data_container(form, 'show');
uploadInitGetSet(form, 1);
}
var handleProgress = function (form, percent, noupdate) {
percent = Math.max(percent, 1);
if (!uploadInitGetSet(form)) {
_progress_to_data_entry_because_upload_has_started(form);
}
if (uploadCompleteGetSet(form))
return;
if (percent > uploadProgressPercentageGetSet(form) || percent == 0) {
// To handle what happens when we browse away, or there's an error. When this happens
// mid-transfer, the percent rushes to 100%, we try to stop that here
if (percent == 100) {
if (uploadProgressPercentageGetSet(form) && uploadProgressPercentageGetSet(form) < 80) {
return;
}
}
if (uploadProgressUpdatingGetSet(form))
return;
uploadProgressUpdatingGetSet(form, 1);
var strP = percent + '%';
$(uploadProgressSelector, form).animate({width: strP}, 400, 'swing', function () {
uploadProgressUpdatingGetSet(form, 0);
handleProgress(form, percent);
});
if (typeof noupdate === 'undefined')
$(uploadPercentSelector, form).text(strP);
uploadProgressPercentageGetSet(form, percent);
}
}
var handleError = function (form, error, str_extra_data) {
_log_error_reporting($(fileNameSelector, form).val(), 'error', error);
var progress_reset = true;
var error_type = 'error';
if (error.code != undefined) {
var er = '';
switch (error.code) {
case 111:
er = 'Sorry, we can\'t upload your file because your web browser is too old.';
er = er + ' We try really hard to make this very important part of Newsflare work for everyone so we are sorry it\'s not working for you.';
er = er + ' Please use a newer browser, we recommend Google Chrome or Firefox';
break;
case 115:
er = 'Sorry, we couldn\'t find that video, please try to reselect the video again.';
break;
case 118:
er = 'Sorry, there was a problem getting that video, please try to reselect the video again.';
break;
case 151:
er = 'Sorry, it appears there\'s a network connection problem, please ensure you\'re connected to the Internet and try again.';
break;
case 403:
er = 'Sorry, it appears there\'s a network problem, please ensure you\'re connected to the Internet and try again.';
break;
case 123:
break;
er = 'Sorry, it appears there\'s a problem. Often reloading the page and trying again will fix the problem.';
break;
case 1001:
er = 'You selected the file "' + str_extra_data + '" but it doesn\'t appear to be a video file.
';
er = er + 'Solution ';
er = er + '
Most of the time this is caused by selecting a shortcut to the video file, not the video itself.
';
er = er + '
The file you select must end in one of the following file extensions: ' + arr_valid_extensions.join(', ') + '
';
er = er + 'If you need assistance, please contact us: contact@newsflare.com';
progress_reset = false;
error_type = 'info';
break;
case 1002:
er = 'Your video has not uploaded yet.';
progress_reset = false;
error_type = 'info';
break;
}
if (er) {
show_error(form, er, error_type);
}
}
}
function _return_form_of_swf(obj) {
if ($(obj).is('form')) return obj;
return $(obj).parentsUntil('form').parent().first();
}
function add_to_cart() {
var user = $('#user-to-insert').attr('value');
if (!(!isNaN(parseFloat(user)) && isFinite(user))) {
return false;
}
$('#cart-insert-loading').show();
$.ajax({
type: 'POST',
url: 'https://' + window.location.host + '/ajax/video/pricing_options',
data: {
data: 'naid=' + $('#naid').attr('value'),
user: user
},
success: function (data) {
if (data.redirect) {
window.location.href = data.redirect;
} else {
$('#buy-form-container').empty().html('').append(data);
$('#cart-insert-loading').hide();
}
}
});
$('#user-to-insert').attr('disabled', 'disabled');
$('#buy-form-tr').show();
$('#buy-form-user-selected-button').hide();
return false;
}
function buy_change_select(obj) {
var form = $('#form-buy');
$('.buy-price', form).empty().html('');
$('.buy-price', form).addClass('loading');
$.ajax({
type: 'POST',
url: 'https://' + window.location.host + '/ajax/video/pricing_options',
data: {
data: $(form).serialize(),
select: $(obj).attr('name'),
user: $('#user-to-insert').attr('value'),
media_types: $('#media-types').val()
},
success: function (data) {
if (data.redirect) {
window.location.href = data.redirect;
} else {
$('#buy-form-container').empty().html('').append(data);
$("#custom_msg").empty().html(data);
if ($('#production_name').val() != "") {
$("[name='custom_msg']").val($("[name='custom_msg']").val() + ", Production: " + $('#production_name').val());
}
for (let email in ccEmails) {
$('.cc-emails-container').append('
' + ccEmails[email] + '
');
}
}
}
});
return false;
}
function buy_submit() {
var lightbox = this;
var form = $('form', lightbox.$content);
$(form).addClass('loading');
DollHouse.ajax({
type: 'POST',
url: 'buy/add',
data: {
data: $(form).serialize()
},
success: function (data) {
if (data.redirect) {
window.location.href = data.redirect;
} else {
lightbox.$content.html(data);
}
}
});
return false;
}
function datepicker_init_new() {
$('#edit_date').datepicker({
dateFormat: 'd M yy',
maxDate: 0
});
$('.datepickerRange#start').datepicker({
dateFormat: 'd M yy',
onSelect: function (date) {
var selectedDate = new Date(date);
var endDate = new Date(selectedDate.getTime());
$(".datepickerRange#end").datepicker("option", "minDate", endDate);
}
});
$('.datepickerRange#end').datepicker({
dateFormat: 'd M yy',
maxDate: 0,
minDate: new Date(new Date($(".datepickerRange#start").val()).getTime())
});
$('.datetimepicker').timepicker({
minDate: 0,
maxDate: 2,
dateFormat: 'd M yy',
timeFormat: 'HH:mm z',
separator: ' ',
showTimezone: false
});
}
function datepicker_init_regular() {
$('#date_datepicker').datepicker({
dateFormat: 'd M yy',
});
}
function datepicker_init() {
$('#date_datepicker_start_of_contract').datepicker({
dateFormat: 'd M yy',
minDate: 0,
onSelect: function (selectedDate) {
if ($('#auto_account_credit_frequency').val() === 'one-off') {
$('#date_datepicker_end_of_contract').datepicker("setDate", new Date(selectedDate));
}
}
});
$('#date_datepicker_end_of_contract').datepicker({
dateFormat: 'd M yy',
minDate: 0
});
$('#timestamp').datepicker({
dateFormat: 'd M yy',
maxDate: 0,
onSelect: function (selectedDate) {
var instance = $(this).data('datepicker'),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
}
});
$('#timestamp_future').datepicker({
dateFormat: 'd M yy',
onSelect: function (selectedDate) {
var instance = $(this).data('datepicker'),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
$('#send_invoice_date').val($('#timestamp_future').val())
$('#send_invoice_date').datepicker('destroy');
$('#send_invoice_date').datepicker({
dateFormat: 'd M yy',
minDate: $('#timestamp_future').val(),
onSelect: function (selectedDate) {
var instance = $(this).data('datepicker'),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
}
});
}
});
$('#recurring_end_date').datepicker({
dateFormat: 'd M yy',
onSelect: function (selectedDate) {
var instance = $(this).data('datepicker'),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
$('#recurring_end_date_value').val($('#recurring_end_date').val())
$('#recurring_end_date_value').datepicker('destroy');
$('#recurring_end_date_value').datepicker({
dateFormat: 'd M yy',
minDate: $('#recurring_end_date').val(),
onSelect: function (selectedDate) {
var instance = $(this).data('datepicker'),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
}
});
}
});
$('#timestamp_generic').datepicker({
dateFormat: 'd M yy',
onSelect: function (selectedDate) {
var instance = $(this).data('datepicker'),
date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat,
selectedDate,
instance.settings
);
}
});
}
function users_init() {
$('#user-to-insert').autocomplete({
//define callback to format results
source: function (request, response) {
if (request.term in user_to_insert_cache) {
response($.map(user_to_insert_cache[request.term], function (item) {
return {
value: item.id + ' ' + item.username + ' ' + item.email,
username: item.username,
id: item.id,
email: item.email
}
}));
return;
}
$.ajax({
url: 'https://' + window.location.host + '/ajax/users/autocomplete',
data: {
term: request.term
},
success: function (data) {
user_to_insert_cache[request.term] = data;
response($.map(data, function (item) {
return {
value: item.id + ' ' + item.username + ' ' + item.email,
username: item.username,
id: item.id,
email: item.email
}
}));
}
});
},
minLength: 2,
select: function (event, ui) {
if (!ui.item || !ui.item.id) return;
if ($('#user-to-insert').attr('type') == 'text') {
if (!$(this).hasClass('overpayment-username-entry')) {
$('#user-to-insert').parent().append('' + ui.item.id + ' ' + ui.item.username + ' ' + ui.item.email + '');
$('#user-to-insert').remove();
add_to_cart();
} else {
$(this).val(ui.item.username);
$('#user-data').val(JSON.stringify(ui.item));
return false;
}
}
},
open: function () {
//$( thisObj ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function () {
//$( thisObj ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
},
destroy: function () {
},
delay: 300
});
}
function users2_init() {
$('#user-to-insert2').autocomplete({
//define callback to format results
source: function (request, response) {
if (request.term in user_to_insert_cache) {
response($.map(user_to_insert_cache[request.term], function (item) {
return {
value: item.id + ' ' + item.username + ' ' + item.email,
username: item.username,
id: item.id,
email: item.email
}
}));
return;
}
$.ajax({
url: 'https://' + window.location.host + '/ajax/users/autocomplete',
data: {
term: request.term
},
success: function (data) {
user_to_insert_cache[request.term] = data;
response($.map(data, function (item) {
return {
value: item.id + ' ' + item.username + ' ' + item.email,
username: item.username,
id: item.id,
email: item.email
}
}));
}
});
},
minLength: 2,
select: function (event, ui) {
if (!ui.item || !ui.item.id) return;
if ($('#user-to-insert2').attr('type') == 'text') {
$('#user-to-insert2').val(ui.item.id);
$('#user-to-insert-hidden').val(ui.item.id);
}
},
open: function () {
//$( thisObj ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function () {
//$( thisObj ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
},
destroy: function () {
},
delay: 300
});
}
function newsorg2_init() {
$('#newsorg_client_2').autocomplete({
//define callback to format results
source: function (request, response) {
if (request.term in user_to_insert_cache) {
response($.map(user_to_insert_cache[request.term], function (item) {
return {
value: item.name + ' id:' + item.id,
name: item.name,
id: item.id,
tracking_category_option: item.tracking_category_option,
news_org_toi: item.news_org_toi,
organisation_type: item.organisation_type
}
}));
return;
}
$.ajax({
url: 'https://' + window.location.host + '/ajax/autocomplete/newsorganisations/true/true',
data: {
term: request.term
},
success: function (data) {
user_to_insert_cache[request.term] = data;
response($.map(data, function (item) {
return {
value: item.name + ' (id:' + item.id + ')',
name: item.name,
id: item.id,
tracking_category_option: item.tracking_category_option,
news_org_toi: item.news_org_toi,
organisation_type: item.organisation_type
}
}));
}
});
},
minLength: 2,
select: function (event, ui) {
if (!ui.item || !ui.item.id) {
return;
}
let userSearchElement = $('#user-to-insert2');
if ($('#newsorg_client_2').attr('type') == 'text') {
$('#newsorg_client_2').val(ui.item.id);
$('#news_org_hidden').val(ui.item.id);
$('#line_of_business').val(ui.item.tracking_category_option);
$('#news_org_toi').val(ui.item.news_org_toi);
if ($('#news_org_type').length) {
$('#news_org_type').val(ui.item.organisation_type).change();
}
userSearchElement.val('');
$('#user-to-insert-hidden').val('');
}
if (userSearchElement.length && userSearchElement.is(':visible')) {
userSearchElement.autocomplete({
//define callback to format results
source: function (request, response) {
$.ajax({
url: 'https://' + window.location.host + '/ajax/users/autocomplete',
data: {
term: request.term,
news_org_id: ui.item.id
},
success: function (data) {
user_to_insert_cache[request.term] = data;
response($.map(data, function (item) {
return {
value: item.id + ' ' + item.username + ' ' + item.email,
username: item.username,
id: item.id,
email: item.email
}
}));
}
});
},
minLength: 0,
select: function (event, ui) {
if (!ui.item || !ui.item.id) return;
if (userSearchElement.attr('type') == 'text') {
userSearchElement.val(ui.item.id);
$('#user-to-insert-hidden').val(ui.item.id);
}
},
open: function () {
//$( thisObj ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function () {
//$( thisObj ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
},
destroy: function () {
},
delay: 300
});
}
userSearchElement.keydown();
if (document.getElementById('invoice_ajax_dropdown')) {
$.ajax({
url: 'https://' + window.location.host + '/ajax/autocomplete/unused_production_companies_inovices',
data: {
news_org_id: ui.item.id
},
type: 'POST',
dataType: 'json',
success: function (json) {
if (Object.keys(json).length > 1) {
$('#invoice_ajax_dropdown').css('height', 'auto')
$('#invoice_ajax_dropdown').html('');
$.each(json, function (index, value) {
$('#invoice_ajax_dropdown').append('');
if (index === '') {
$('#invoice_ajax_dropdown option').prop('disabled', 'disabled');
}
});
}
}
})
}
},
open: function () {
//$( thisObj ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function () {
//$( thisObj ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
},
destroy: function () {
},
delay: 300
});
}
function news_organisation_init() {
$('#news_organisation_autocomplete').autocomplete({
//define callback to format results
source: function (request, response) {
if (request.term in user_to_insert_cache) {
response($.map(user_to_insert_cache[request.term], function (item) {
return { // Not sure what this does
value: item.name + ' id:' + item.id,
name: item.name,
id: item.id
}
}));
return;
}
$.ajax({
url: 'https://' + window.location.host + '/ajax/autocomplete/newsorganisations/true',
data: {
term: request.term
},
success: function (data) {
user_to_insert_cache[request.term] = data;
response($.map(data, function (item) { // Show result data as dropdown list
return {
value: item.name + ' (id:' + item.id + ')',
name: item.name,
id: item.id
}
}));
}
});
},
minLength: 2,
select: function (event, ui) {
if (!ui.item || !ui.item.id) return;
$('#news_organisation_id').val(ui.item.id);
$('div.side-panel-input').not('div.portal').show();
// Turns out we needed staff members, not N_O users...
// Going to leave it here just in case though
// $.ajax({ // Get users of selected news organisation
// url: 'https://' + window.location.host + '/ajax/autocomplete/news_organisation_users',
// data: {
// news_org_id: ui.item.id
// },
// success: function(data) {
// $('#account_manager').find('option').remove(); // Clear current options
// $.map( data, function( item ) { // Push users to select element as options
// $('#account_manager').append(``);
// });
// $('div.side-panel-input').not('div.portal').show();
// }
// });
},
open: function () {
//$( thisObj ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function () {
//$( thisObj ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
},
destroy: function () {
},
delay: 300
});
}
function map_upload_init() {
$('div.location:not([id])').each(function () {
$(this).attr('id', 'location0');
$('.location-choose').attr('id', 'location-choose0');
$('.location_text').attr('id', 'location_text0');
$('.location_error').attr('id', 'location_error0');
$('.location_submit').attr('id', 'location_submit0');
Sandbox.notify(RagDoll.event('inline-map.load'), {
google: {},
$map: $('#location-choose0'),
$input: $('#location_text0'),
$error: $('#location_error0'),
$button: $('#location_submit0'),
$lat: $('#location_lat0'),
$lng: $('#location_lng0')
});
});
}
function add_tag() {
$('#newtag').click(function () {
$(this).hide();
$(this).parent().append('');
$('#newtagzzz').focus();
})
$(document).on('change', '#newtagzzz', function (e) {
let keyCode = e.keyCode || e.which;
var newtag = $(this).val();
if ((keyCode == 13 && node.type == "text") || newtag.length === 0) {
return false;
}
$.ajax({
url: 'https://' + window.location.host + '/ajax/video/newtag',
data: {
id: article_id,
value: newtag
},
type: 'POST',
dataType: 'json',
success: function (json) {
if (json.status == 'Success') {
newtag = json.new_tag;
for (var i = 0; i < newtag.length; i++) {
newtag = newtag.replace('|', " ");
}
$('#newtag').show();
$('#newtagzzz').remove();
$('#add_here').append('' + newtag + ' X');
//to re-bind the delete click event to the newly created span
delete_tag();
$('#tags_string').val($('#tags_string').val() + newtag + ',');
if ($('#clear-tags').parent().is(":hidden")) {
$('#clear-tags').parent().show();
}
}
}
});
});
}
function delete_tag() {
$('.tag_delete').click(function (e) {
if (confirm("Are you sure you want to delete this tag ?")) {
var tag_info = $(this).attr("id");
$.ajax({
url: 'https://' + window.location.host + '/ajax/video/deletetag',
data: {
id: tag_info
},
type: 'POST',
dataType: 'json',
success: function () {
$('#' + tag_info).parent().remove();
}
});
}
e.preventDefault();
return false;
});
}
function delete_all_tags() {
$('#clear-tags').click(function (e) {
if (confirm("Are you sure you want to delete all tags for this video?")) {
$.ajax({
url: 'https://' + window.location.host + '/ajax/video/cleartags',
data: {
na_id: article_id
},
type: 'POST',
dataType: 'json',
success: function () {
// remove all tags
$('.deletable_tag').remove();
// remove clear tags button
$('#clear-tags').parent().hide();
}
});
}
e.preventDefault();
return false;
});
}
function add_pc_tag() {
$('#newtag_pc').click(function () {
$(this).hide();
$(this).parent().append('');
$('#newtagzzz_pc').focus();
});
$('#newtagzzz_pc').on('change', function (evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type == "text")) {
return false;
}
var newtag = $(this).val();
$.ajax({
url: 'https://' + window.location.host + '/ajax/video/newtag_pc_csv',
data: {
id: pc_csv_id,
value: newtag
},
type: 'POST',
dataType: 'json',
success: function (json) {
if (json.status == 'Success') {
newtag = json.new_tag;
for (var i = 0; i < newtag.length; i++) {
newtag = newtag.replace('|', " ");
}
$('#newtag_pc').show();
$('#newtagzzz_pc').remove();
$('#add_here_pc_tag').append('' + newtag + ' X');
//to re-bind the delete click event to the newly created span
delete_pc_tag();
$('#tags_string').val($('#tags_string').val() + newtag + ',');
if ($('#clear-tags').parent().is(":hidden")) {
$('#clear-tags').parent().show();
}
}
}
});
});
$('#newtagzzz_pc').on('keypress', function (evt) {
if (evt.keyCode === 13) {
$('#newtagzzz_pc').blur();
}
});
}
function delete_pc_tag() {
$('.tag_delete_pc').click(function (e) {
if (confirm("Are you sure you want to delete this tag ?")) {
var tag_info = $(this).attr("id");
$.ajax({
url: 'https://' + window.location.host + '/ajax/video/deletetag_pc_csv',
data: {
id: tag_info
},
type: 'POST',
dataType: 'json',
success: function () {
$('#' + tag_info).parent().remove();
}
});
}
e.preventDefault();
return false;
});
}
function destroy() {
Sandbox.clean();
}
return {
init: init,
destroy: destroy
};
});
/*=========./pages/video-check.js=========*/
RagDoll.register('video_check', function (Sandbox, $) {
var initChildCount;
function init() {
if (!$('form[action*="videos/moderate_for_sale/list"]').length) {
return;
}
initChildCount = $("table.admin tbody").children().length;
Sandbox.notify(RagDoll.event('video_check.check_video'));
Sandbox.listen(RagDoll.event('video_check.check_video'), check_video, this);
}
function check_video() {
$('input[type=checkbox]').change(function () {
var that = this;
if ($(this).attr("checked") == "checked") {
$.ajax({
type: 'POST',
url: 'https://' + window.location.host + '/ajax/video/check_video',
data: {
na_id: $(that).attr('id')
},
success: function (data) {
if (data.status == 1) {
var $row = $(that).parent().parent();
var rowCount = $("table.admin tbody").children().length;
if ((initChildCount - rowCount) > 5) {
location.reload();
} else {
$row.fadeOut(300, function () {
$row.remove();
});
}
} else {
alert('You are not permitted for this operation!');
}
}
});
}
});
}
function destroy() {
Sandbox.clean();
}
return {
init: init,
destroy: destroy
};
});
$('#has_download_timeout').click(function () {
if ($(this).is(':checked')) {
$('#download_timeout').attr('disabled', false);
$(this).val(1);
} else {
$('#download_timeout').attr('disabled', true);
$(this).val(0);
}
})
/**
* Limit given input[type='date'] to accept only future dates by setting min attribute to today
*
* @param documentElement element
*/
function limitToFutureDates(element) {
var dtToday = new Date();
var month = dtToday.getMonth() + 1;
var day = dtToday.getDate();
var year = dtToday.getFullYear();
// HTML expects date/month to always be given in double digit format. JS can return them as single digit.
if (month < 10)
month = '0' + month.toString();
if (day < 10)
day = '0' + day.toString();
var minDate = year + '-' + month + '-' + day;
element.attr('min', minDate)
}
$('.button.void').on('click', function () {
if (!confirm('Are you sure you want to void this invoice?')) {
return false;
}
});
// function ott_content_checker(e) {
// e.preventDefault();
// let nas = prompt('News Articles to check (comma separated)');
// if(nas != null){
// jQuery.ajax({
// type: 'POST',
// url: 'https://' + window.location.host + '/ajax/video/check_if_live',
// data: {
// nas: nas
// },
// success: function(data) {
// if(data.destatused !== null && data.destatused.length > 0) {
// alert('News articles (' + data.destatused + ') are not live.');
// } else {
// alert('All news articles are live.');
// }
// }
// });
// }
// return false;
// }