', { 'class': 'jq-file__browse', html: browse });
$input
.wrap($wrapInputFile)
.before($name, $file)
.on('change', function() {
var value = $input.val();
if ($input.is('[multiple]') && $input[0].files) {
value = '';
var files = $input[0].files.length;
if (files > 0) {
value = fileNumber + ' ' + files;
}
}
value = value.replace(/.+[\\\/]/, '') || placeholder;
$name.text(value);
});
});
}
function videoCanPlay(el) {
if ($('html').hasClass('ua-desktop')) {
if (el != null && $(el).length > 0 && $(el).context != null) {
var w = $(el).context.videoWidth;
var h = $(el).context.videoHeight;
if (w > 0) {
var ww = $("html").width();
var w1 = w;
var h1 = h;
if (ww <= w1) {
w1 = ww - 300;
h1 = h / (w / w1);
w = w1;
h = h1 - 50;
}
$(el).css("width", w + "px").css("height", h + "px");
$.fancybox.update();
}
}
}
};
// Content of this file was generated on application start
var Constants = {PageSize:10,MediaLibraryPageSize:12,PaginationSize:3,OilCatalogPageSize:9,WinnersPageSize:20};
Constants.queryParamNames = {
"LanguageCode": "lng",
"LanguageGuid": "l",
"WidgetId": "wid",
"PressReleaseId": "rid",
"InformationMaterialId": "mid",
"MediaFileId": "mfid",
"Region": "reg",
"SearchQuery": "query",
"Industry": "ind",
"Country": "ctry",
"StartDate": "sdate",
"EndDate": "edate",
"FileType": "ftype",
"Theme": "theme",
"Person": "pers",
"Project": "proj",
"Organization": "org",
"Audience": "aud",
"Importance": "imp",
"Tags": "tags",
"Id": "id",
"IsFullScreenMode": "isFullScreenMode",
"Expand": "expand",
"AdvertisementId": "aid",
"TypeId": "typeid",
"TreeId": "treeid",
"OwnerId": "ownerid",
"Query": "query",
"OrganizationId": "organizationId",
"ProjectId": "projectId",
"FieldOfActivityId": "fieldOfActivityId",
"DownloadFile": "dl",
"ConfirmationToken": "token",
"SubscriptionAction": "action",
"SubscriptionGuid": "subscription",
"RegistrationGuid": "registration",
"EventId": "eventId",
"PreviewMassMediaId": "preview_corpmediaid",
"PreviewEventId": "preview_eventid",
"OfficeWebAppsFileSource": "src",
"OilProductId": "product",
"ApplicationId": "application",
"ViscosityId": "viscosity",
"BrandId": "brand",
"GasStationId": "gasStationId",
"Take": "take",
"Skip": "skip"
};
Constants.AjaxResultCodes = {
"Success": "Success",
"Error": "Error"
};
Constants.InformationMaterialTypes = {
"Default": 0,
"MediaAlbum": 1,
"PressRelease": 2,
"News": 3,
"MassMediaIssue": 4,
"Event": 5,
"Publication": 6
};
Constants.fileTypes = {
"Default": 0,
"Document": 1,
"Image": 2,
"Video": 3,
"Audio": 4,
"Template": 5,
"Zip": 6
};
Constants.previewTypes = {
"Default": 0,
"NewsFeeds": 1,
"Album": 2,
"AlbumFeed": 3,
"Interestingly": 4,
"MediaLibrary": 5,
"ItMayInterestHigher": 6,
"ItMayInterestLower": 7,
"Photowire": 8,
"Videos": 9,
"PhotoRibbon": 10
};
Constants.Languages = ['kz','ru','nl','cn','sk','ka','sr','de','fi','el','pl','dk','en','se','bg','no','az','hr','pt','it','tr','fr','hu','cz','lt','lv','uk','me','ar','mk','ro','es','uz','be'];
;
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));
;
(function ($) {
$.lukoilGetCookie = function (key) {
return Cookies.get(key);
}
$.lukoilSaveCookie = function (key, value, config) {
var redList = [
"LukCookiePolicy",
"LukCookiePolicy_functional",
"LukCookiePolicy_analystic",
"LukCartMapPositionYandex",
"LukCartMapPositionGoogle",
"LukCountryCode",
"LukGeoObjectId",
"LukGeolocation",
"LukLocationSelect",
"LukLanguage",
"LukDisplayedBanners",
"LukDisplayedBannersAllowAdditional",
"LukOnlineSuveyUserId",
"LukOnlineSurveySkipIds",
"LukRedirected",
"OldSiteRedirection",
"OldSiteRedirectionSession",
"azs_prices_station_id",
"FULL_SITE_MODE",
"TEXT_SIZE",
"WIDGETS_SAVED",
"LukSlider"
];
var functionalCookieEnabled = $.lukoilGetCookie('LukCookiePolicy_functional');
if (window.CookiePolicyEnable == null || window.CookiePolicyEnable == false || functionalCookieEnabled == 'true' || ((functionalCookieEnabled == null || functionalCookieEnabled == "" || functionalCookieEnabled == 'false') && $.inArray(key, redList) >= 0))
{
if (config != null) {
Cookies.set(key, value, config);
} else {
Cookies.set(key, value);
}
}
}
})(jQuery);;
// @hash v3-B9289FC5A3EA2EB516FF11485225A6B93A5B9059
// Automatically generated by ReactJS.NET. Do not edit, your changes will be overridden.
// Version: 2.1.1-dev-20151124-1300 (build 563ed55)
// Generated at:
///////////////////////////////////////////////////////////////////////////////
/*! globaldata v0.0.1 | MIT */
;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
var current = global.GlobalData;
var exports = global.GlobalData = factory();
exports.noConflict = function () {
global.GlobalData = current;return exports;
};
})());
})(this, function () {
'use strict';
///* eslint-disable no-var */
//function assign(target) {
// for (var i = 1; i < arguments.length; i++) {
// var source = arguments[i];
// for (var key in source) {
// target[key] = source[key];
// }
// }
// return target
//}
///* eslint-enable no-var */
/* eslint-disable no-var */
function main(url, name) {
var _handshake = undefined;
var _key = undefined;
var _url = undefined;
var _name = "globaldata-api";
//window.addEventListener ?
// window.addEventListener("load", constr, false) :
// window.attachEvent && window.attachEvent("onload", constr);
function handshake() {
Postmate.debug = true;
_handshake = new Postmate({
container: document.body,
url: _url,
name: _name
});
}
function initsync(url, key) {
_url = url + "?" + key;
handshake();
}
function init(url, key) {
_url = url + "?" + key;
if (document.readyState === "loading") {
window.addEventListener ? window.addEventListener("DOMContentLoaded", handshake, false) : window.attachEvent && window.attachEvent("onDOMContentLoaded ", handshake);
} else {
handshake();
}
}
function set(name, value) {
return regeneratorRuntime.async(function set$(context$3$0) {
var _this = this;
while (1) switch (context$3$0.prev = context$3$0.next) {
case 0:
if (!(typeof _handshake === 'undefined')) {
context$3$0.next = 3;
break;
}
console.log("run init before use");
return context$3$0.abrupt('return');
case 3:
context$3$0.next = 5;
return regeneratorRuntime.awrap(_handshake.then(function callee$3$0(child) {
return regeneratorRuntime.async(function callee$3$0$(context$4$0) {
while (1) switch (context$4$0.prev = context$4$0.next) {
case 0:
context$4$0.next = 2;
return regeneratorRuntime.awrap(child.call('set_' + name, value));
case 2:
case 'end':
return context$4$0.stop();
}
}, null, _this);
}));
case 5:
case 'end':
return context$3$0.stop();
}
}, null, this);
}
function get(name) {
var args$3$0 = arguments;
return regeneratorRuntime.async(function get$(context$3$0) {
var _this2 = this;
while (1) switch (context$3$0.prev = context$3$0.next) {
case 0:
if (!(typeof _handshake === 'undefined' || args$3$0.length && !name)) {
context$3$0.next = 3;
break;
}
console.log("run init before use");
return context$3$0.abrupt('return');
case 3:
context$3$0.next = 5;
return regeneratorRuntime.awrap(_handshake.then(function callee$3$0(child) {
return regeneratorRuntime.async(function callee$3$0$(context$4$0) {
while (1) switch (context$4$0.prev = context$4$0.next) {
case 0:
context$4$0.next = 2;
return regeneratorRuntime.awrap(child.get(name).then(function (data) {
/*console.log(name + " - " + data);*/return data;
}));
case 2:
return context$4$0.abrupt('return', context$4$0.sent);
case 3:
case 'end':
return context$4$0.stop();
}
}, null, _this2);
}));
case 5:
return context$3$0.abrupt('return', context$3$0.sent);
case 6:
case 'end':
return context$3$0.stop();
}
}, null, this);
}
function remove(name) {
var args$3$0 = arguments;
return regeneratorRuntime.async(function remove$(context$3$0) {
var _this3 = this;
while (1) switch (context$3$0.prev = context$3$0.next) {
case 0:
if (!(typeof _handshake === 'undefined' || args$3$0.length && !name)) {
context$3$0.next = 3;
break;
}
console.log("run init before use");
return context$3$0.abrupt('return');
case 3:
context$3$0.next = 5;
return regeneratorRuntime.awrap(_handshake.then(function callee$3$0(child) {
return regeneratorRuntime.async(function callee$3$0$(context$4$0) {
while (1) switch (context$4$0.prev = context$4$0.next) {
case 0:
context$4$0.next = 2;
return regeneratorRuntime.awrap(child.call('remove_' + name, value));
case 2:
case 'end':
return context$4$0.stop();
}
}, null, _this3);
}));
case 5:
case 'end':
return context$3$0.stop();
}
}, null, this);
}
return Object.create({
init: init,
initsync: initsync,
set: set,
get: get,
remove: remove
});
}
var api = main();
/* eslint-enable no-var */
return api;
});;
var LukoilApp = new Marionette.Application();
$(document).ready(function () {
if (!Date.prototype.toISOString) {
(function () {
function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
Date.prototype.toISOString = function () {
return this.getUTCFullYear() +
'-' + pad(this.getUTCMonth() + 1) +
'-' + pad(this.getUTCDate()) +
'T' + pad(this.getUTCHours()) +
':' + pad(this.getUTCMinutes()) +
':' + pad(this.getUTCSeconds()) +
'.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
'Z';
};
}());
}
(function() {
var D = new Date('2011-06-02T09:34:29+02:00');
if (isNaN(D) || D.getUTCMonth() !== 5 || D.getUTCDate() !== 2 ||
D.getUTCHours() !== 7 || D.getUTCMinutes() !== 34) {
Date.fromISO = function(s) {
var day,
tz,
rx = /^(\d{4}\-\d\d\-\d\d([tT][\d:\.]*)?)([zZ]|([+\-])(\d\d):(\d\d))?$/,
p = rx.exec(s) || [];
if (p[1]) {
day = p[1].split(/\D/);
for (var i = 0, L = day.length; i < L; i++) {
day[i] = parseInt(day[i], 10) || 0;
}
day[1] -= 1;
day = new Date(Date.UTC.apply(Date, day));
if (!day.getDate()) return NaN;
if (p[5]) {
tz = (parseInt(p[5], 10) * 60);
if (p[6]) tz += parseInt(p[6], 10);
if (p[4] == '+') tz *= -1;
if (tz) day.setUTCMinutes(day.getUTCMinutes() + tz);
}
return day;
}
return NaN;
};
} else {
Date.fromISO = function(s) {
return new Date(s);
};
}
})();
var options = {};
if (lukAppSettings) {
$.extend(options, lukAppSettings);
}
setTimeout(function() {
$(document).on("shown.bs.collapse", ".ua-safari .content .panel-collapse", function () {
$(this).find("img").each(function() {
var $clone = $(this).clone(true);
$(this).replaceWith($clone);
});
});
},100);
LukoilApp.start(options);
});
/*
Number.prototype.formatNumber(n, x, s, c)
@param integer n: length of decimal
@param integer x: length of whole part
@param mixed s: sections delimiter
@param mixed c: decimal delimiter
*/
Number.prototype.formatNumber = function (n, x, s, c) {
var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')',
num = this.toFixed(Math.max(0, ~~n));
return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
};
String.prototype.encodeURIComponent = function () {
return isNullOrWhiteSpace(this) ? null : encodeURIComponent(this);
};
String.prototype.decodeURIComponent = function () {
return isNullOrWhiteSpace(this) ? null : decodeURIComponent(this);
};
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str) {
return this.substring(0, str.length) === str;
}
};
Date.prototype.localAsUtcDate = function() {
return new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
};
Date.prototype.utcAslocalDate = function () {
return new Date(this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate());
};
function isNullOrWhiteSpace(value) {
return value == null || value.trim() == "";
}
function submitSearchForm(form) {
var input = $(form).find(":input.inputSearchQuery");
var val = input.val().trim();
if (val != "") {
$(form).find(":input.searchQuery").val(val.encodeURIComponent());
} else {
return false;
}
return true;
}
/*
Jquery Plugins
*/
(function ($) {
$.validator.messages.required = GlobalSettings.Validator.Required;
$.validator.messages.email = GlobalSettings.Validator.Email;
$.validator.messages.maxlength = $.validator.format(GlobalSettings.Validator.MaxLength);
$.validator.addMethod("regex", function (value, element, regstring) {
if (this.optional(element)) {
return true;
}
var regParts = regstring.match(/^\/(.*?)\/([gim]*)$/);
var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(regstring);
var regexMessage = $(element).attr("regexMessage");
if (regexMessage == null || regexMessage == "") {
regexMessage = GlobalSettings.Validator.Regex;
}
$.validator.messages["regex"] = regexMessage;
return regexp.test(value);
}, GlobalSettings.Validator.Regex);
// Date now max validator
$.validator.addMethod("lukoildatenowmax", function (value, element, params) {
try {
return (!value.trim()) || ($.datepicker.parseDate(GlobalSettings.ViewForm.DateFormat, value) <= $.datepicker.parseDate(GlobalSettings.ViewForm.DateFormat, params.nowdate));
} catch (e) {
return false;
}
});
$.validator.unobtrusive.adapters.add("lukoildatenowmax", ['nowdate'], function (options) {
var params = { nowdate: options.params.nowdate };
options.rules["lukoildatenowmax"] = params;
options.messages["lukoildatenowmax"] = options.message;
});
jQuery.validator.setDefaults({
highlight: function (element) {
if ($(element).is("select")) {
$(element).closest("div.form-control").addClass("error");
}
$(element).addClass("input-validation-error");
},
unhighlight: function (element) {
if ($(element).is("select")) {
$(element).closest("div.form-control").removeClass("error");
}
$(element).removeClass("input-validation-error");
}
});
//File size validator
jQuery.validator.unobtrusive.adapters.add("filesize", ["maxfilesizemb"], function (options) {
var params = { maxfilesizemb: options.params.maxfilesizemb };
options.rules["filesize"] = params;
if (options.message) {
options.messages["filesize"] = options.message;
}
});
jQuery.validator.addMethod("filesize", function (value, element, param) {
if (value === "") {
return true;
}
var maxFileSizeMb = parseInt(param.maxfilesizemb);
// use HTML5 File API to check selected file size
// https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications
// http://caniuse.com/#feat=fileapi
if (element.files != undefined && element.files[0] != undefined && element.files[0].size != undefined) {
var filesize = parseInt(element.files[0].size);
return filesize <= maxFileSizeMb * 1024 * 1024;
}
// if the browser doesn't support the HTML5 file API, just return true
// since returning false would prevent submitting the form
return true;
});
$.fn.getNullValue = function () {
var val = $(this).val();
return val == "null" ? null : val;
};
$.fn.formStyler = function (isDestroy) {
$(this).find("select.select-custom").initSelect2(isDestroy);
return this;
};
$.fn.destroySelect2 = function () {
$(this).select2("destroy");
};
$.fn.initSelect2 = function (isDestroy) {
$(this).each(function () {
var minimumResultsForSearch = Infinity;
var dataSearch = $(this).attr("data-search");
if (dataSearch != null && dataSearch.toLowerCase() == 'true') {
minimumResultsForSearch = 1;
}
if (isDestroy != null && isDestroy) {
$(this).destroySelect2();
}
var theme = $(this).attr("data-theme");
var select2Options = {
minimumResultsForSearch: minimumResultsForSearch,
width: 'auto',
language: window.GlobalSettings.CurrentLanguage,
theme: theme || ''
};
var dataChangeSelectAll = $(this).attr("data-change-select-all");
if (dataChangeSelectAll != null && dataChangeSelectAll.toLowerCase() == 'true') {
select2Options.templateResult = function(data) {
if (data.id === '' || data.id === 'null' || data.id === '0') {
return GlobalSettings.SelectAllOptionText;
}
return data.text;
};
}
$(this).select2(select2Options).on('select2:close', function() {
var frm = $(this).closest("form");
if (frm != null) {
var validator = $(frm).validate();
if (validator != null) {
$(this).valid();
$(frm).fixValidationStyle();
}
}
});
});
return this;
};
$.fn.setCurrentValuesAsDefault = function () {
$(this).find(":input").each(function () {
var type = $(this).prop("type");
if (type === "checkbox" || type === "radio") {
$(this).prop("defaultChecked", $(this).prop("checked"));
} else if (type === "hidden" || type === "password" || type === "text" || type === "textarea") {
$(this).prop("defaultValue", $(this).prop("value"));
} else if (type === "select-one" || type === "select-multiple") {
$(this).find("option").each(function () {
$(this).prop("defaultSelected", $(this).prop("selected"));
});
}
});
return this;
};
$.fn.formReset = function (clearForm, resetValidation) {
var $form = $(this);
if ($form != null) {
$.each($form, function () {
if (clearForm != null && clearForm) {
$(this).find("input[type='text']").val("");
$(this).find("input[type='checkbox']").removeAttr("checked");
$(this).find("input[type='radio']").removeAttr("checked");
$(this).find("select option").removeAttr("selected");
$(this).setCurrentValuesAsDefault();
}
this.reset();
$(this).formStyler(true).formStyler();
if (resetValidation == undefined || resetValidation) {
$(this).resetValidation();
}
});
}
return this;
};
$.fn.resetValidation = function () {
var $form = $(this);
//reset jQuery Validate's internals
var validator = $form.validate();
validator.resetForm();
$form.hideValidationMessages();
return this;
};
$.fn.hideValidationMessages = function () {
var $form = $(this);
$form.find(".field-validation-error[data-valmsg-for]").hide();
$form.find(".field-validation-error, .input-validation-error").removeClass("field-validation-error").removeClass("input-validation-error");
return this;
};
$.fn.hideValidationMessage = function () {
var $field = $(this);
var $form = $field.closest("form");
var $message = $form.find(".field-validation-error[data-valmsg-for='" + $field.prop("name") + "']");
$message.removeClass("field-validation-error").empty();
return this;
};
/* Get all form parameters */
$.fn.serializeJSON = function (includeDisabled) {
var json = {};
var disabled = null;
if (includeDisabled != null && includeDisabled) {
disabled = $(this).find(":input:disabled").removeAttr("disabled");
}
jQuery.map($(this).serializeArray(), function (n, i) {
if (!json.hasOwnProperty(n["name"]) || json[n["name"]] == "false") {//for checkbox which was built MVC
json[n["name"]] = n["value"];
}
});
if (includeDisabled != null && includeDisabled && disabled != null) {
disabled.attr("disabled", "disabled");
}
return json;
};
$.fn.getFormValidationSummary = function () {
var $el = $(this).find(".validation-summary-errors ul");
if ($el.length == 0) {
$(this).prepend('
');
return $(this).getFormValidationSummary();
}
return $el;
};
$.fn.fixValidationStyle = function () {
$(this).each(function () {
$(this).find("div.form-group").removeClass("error");
$(this).find(".input-validation-error").each(function () {
$(this).fixValidationElementStyle();
});
});
return this;
};
$.fn.fixValidationElementStyle = function () {
if ($(this).attr("type") == "file") {
$(this).closest("div.form-group").addClass("error");
}
return this;
};
$.fn.showValidationMessage = function (form) {
$(this).each(function (i, e) {
var name = $(e).attr("name");
$(e).addClass("input-validation-error").removeClass("valid");
$(e).fixValidationElementStyle();
if (form == null)
form = $(e).closest("form");
var $dataValmsgFor = $(form).find("[data-valmsg-for='" + name + "']");
if ($dataValmsgFor == null || $dataValmsgFor.length == 0) {
$dataValmsgFor = $("
");
$dataValmsgFor.insertAfter($(e));
}
$dataValmsgFor.addClass("field-validation-error").show();
});
return this;
};
$.fn.isValiationSummaryErrors = function (data) {
var form = this;
if (data == null || data.Tag == null || data.Tag != "ValidationErrors")
return false;
var $list = $(form).getFormValidationSummary();
//clear last validation messages
$list.html("");
$(form).find(".field-validation-error[data-valmsg-for]").hide();
$(form).find(".field-validation-error, .input-validation-error").removeClass("field-validation-error").removeClass("input-validation-error");
$(form).find("div.form-group").removeClass("error");
$.each(data.State, function (i, item) {
var valmsg, lblTxt, errorList = "";
if (item.Name) {
var el = $(form).find("[name='" + item.Name + "']");
$(el).showValidationMessage(form);
valmsg = $(form).find("[data-valmsg-for='" + item.Name + "']");
lblTxt = $(form).find("label[for='" + item.Name + "']").text();
if (lblTxt) {
lblTxt += ": ";
}
}
if (valmsg != null && valmsg.length) {
$(valmsg).text(item.Errors.shift());
if (!item.Errors.length) {
return;
}
}
$.each(item.Errors, function (c, val) {
errorList += "
";
if (lblTxt != null && lblTxt != "")
errorList += lblTxt;
errorList += val + "";
});
$list.append(errorList);
});
if ($list.find("li:first").length) {
$list.closest("div").show();
}
return true;
};
$.fn.initDatepickers = function () {
$(this).find(".form-datePicker").each(function () {
$(this).datepicker({
dateFormat: GlobalSettings.ViewForm.DateFormat,
changeYear: true,
changeMonth: true,
yearRange: "1990:+3",
firstDay: GlobalSettings.ViewForm.FirstDay,
maxDate: $(this).data('val-lukoildatenowmax-nowdate'),
onSelect: function (dateText, inst) {
$(inst.input).val(dateText).datepicker("hide");
var frm = $(inst.input).closest("form");
if (frm != null && frm.length > 0) {
$(frm).validate().element("#" + inst.id);
}
$(inst.input).trigger("change");
},
onClose: function (selectedDate) {
var dateTo = $(this).attr("date-to");
if (dateTo != null && dateTo != '') {
$("#" + dateTo).datepicker("option", "minDate", selectedDate);
}
var dateFrom = $(this).attr("date-from");
if (dateFrom != null && dateFrom != '') {
$("#" + dateFrom).datepicker("option", "maxDate", selectedDate);
}
}
});
});
return this;
};
$.fn.reloadLukoilCaptcha = function () {
$(this).find(".captcha").find("[id$='_ReloadLink']").trigger("click");
};
$.reloadLukoilCaptcha = function (captchaId) {
$("form .captcha #" + captchaId + "_ReloadLink").trigger("click");
};
$.fn.getCaptcha = function () {
var $frm = $(this);
var captchaID = $frm.find("input[name='Captcha_Client_CaptchaID']").val();
var userInputID = $frm.find("input[name='Captcha_Client_UserInputID']").val();
var instanceID = $frm.find("input[name='Captcha_Client_InstanceID']").val();
var value = $frm.find("#" + userInputID).val();
return {
value: value,
captchaID: captchaID,
userInputID: userInputID,
instanceID: instanceID
}
};
$.fn.lukoilAjaxSubmitForm = function (beforeSubmitCallback, completeCallback, successCallback, hideFormAfterSubmit, onCloseCallBack ) {
var $frm = $(this);
if ($frm.attr("hideForm") == null) {
$frm.attr("hideForm", hideFormAfterSubmit == null ? true : hideFormAfterSubmit);
}
$frm.on("submit",function () {
if ($frm.valid()) {
$frm.hideValidationMessages();
$frm.find(".overlay").show();
$frm.ajaxSubmit({
beforeSubmit: function(arr, $form, options) {
if (beforeSubmitCallback) {
beforeSubmitCallback();
}
},
success: function(responseText, statusText, xhr, form) {
var responseJson = $.isPlainObject(responseText) ? responseText : $.parseJSON(responseText);
if (!$frm.isValiationSummaryErrors(responseJson)) {
if (responseJson != null) {
var actionResult = responseJson.Result;
if (window.location.pathname.indexOf('/consumers/support') != -1) {
ym(42633489, 'reachGoal', 'mn_expert_forms_sent')
}
switch (actionResult) {
case Constants.AjaxResultCodes.Success:
$.fancyboxMessage(responseJson.Value, function() { if (responseJson.OnCloseEvent != null) onCloseCallBack(responseJson.OnCloseEvent) });
var hideForm = $frm.attr("hideForm");
if (hideForm == null || hideForm == "true") {
$frm.hide();
} else {
$frm.reloadLukoilCaptcha();
}
if (successCallback) {
successCallback();
}
break;
default:
$.fancyboxMessage(responseJson.Value);
$frm.reloadLukoilCaptcha();
break;
}
}
} else {
$frm.reloadLukoilCaptcha();
$.fancybox.reposition();
}
},
error: function(jqXHR, textStatus, errorThrown) {
$frm.reloadLukoilCaptcha();
if (jqXHR != null && jqXHR.responseJSON != null && jqXHR.responseJSON.Result != null && jqXHR.responseJSON.Value != null) {
if (jqXHR.responseJSON.WebEventCode != null && jqXHR.responseJSON.WebEventCode == GlobalSettings.WebEventCodes.RuntimeErrorPostTooLarge) {
$.fancyboxMessage(GlobalSettings.ErrorMessages.RuntimeErrorPostTooLargeMessage);
}
else {
$.fancyboxMessage(jqXHR.responseJSON.Value);
}
}
else {
$.fancyboxMessage(GlobalSettings.ErrorMessages.FormSubmitErrorMessage);
}
},
complete: function() {
if (completeCallback) {
completeCallback();
}
$frm.find(".overlay").hide();
}
});
} else {
$frm.fixValidationStyle();
}
return false;
});
};
$.fn.lukMediaAlbum = function (options) {
var gallery = function () {
var $container = $(this);
var $thumbs = $container.find('.photo-album-thumbs');
var $thumb = $container.find('.photo-album-thumb');
var $box = $container.find('.photo-album-box');
var $boxElem = $('
');
var content = [];
var data;
var isDisable = false;
var mediaContent = {
image: {
img: function (src, icon) {
icon = icon || '';
return '

' + icon;
}
},
video: {
local: function (src) {
return '
';
},
youtube: function (src) {
return '