$.support.cors = true;
var host = 'https://cashbackcorp.com/';
var sharedSecret = '2980d8c5-5249-423f-89c1-566a255b5183';
var applicationId = '1';
var authPage = '/dev/default';
var redirectAfterAdminLogin = '/dev/dash/home';
var redirectAfterBlogLogin = '/dev/dash/blog';
var redirectAfterStoreLogin = '/dev/dash/cart';
var redirectAfterFulfilmentLogin = '/dev/cart/orders/'
var enableLoadingAnnimation = 1;
var razorStorage = function () {
return {
ClearLocalData: function () {
sessionStorage.clear();
},
SaveLocalData: function (key, value) {
sessionStorage.setItem(key, value);
},
ExtractLocalData: function (key) {
return sessionStorage.getItem(key);
}
};
}();
var razorAlert = function () {
return {
alertError: function (message) {
$.jGrowl(message, { theme: 'razor', position: 'bottom-right', corners: '5px', sticky: true });
}
};
}();
var razorHelpers = function () {
return {
getQueryParam: function (name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
},
formatGoogleDate: function(strDate) {
var strDate1 = strDate.substring(4, 6) + '-' + strDate.substring(6, 8) + '-' + strDate.substring(0, 4);
var d = new Date(strDate1);
try {
if (strDate.indexOf('00:00:00') != -1)
d.setDate(d.getDate() + 1);
} catch (ex) { }
var currDate = d.getDate();
var currMonth = d.getMonth() + 1;
var currYear = d.getFullYear();
return currMonth + "/" + currDate + "/" + currYear;
},
formatDate: function (strDate) {
var d = new Date(strDate);
try {
if (strDate.indexOf('00:00:00') != -1)
d.setDate(d.getDate() + 1);
} catch (ex) { }
var currDate = d.getDate();
var currMonth = d.getMonth() + 1;
var currYear = d.getFullYear();
return currMonth + "/" + currDate + "/" + currYear;
},
formatDateTime: function (strDate) {
var d = new Date(strDate);
try {
if (strDate.indexOf('00:00:00') != -1)
d.setDate(d.getDate() + 1);
} catch (ex) { }
var currDate = d.getDate();
var currMonth = d.getMonth() + 1;
var currYear = d.getFullYear();
var currHour = d.getHours();
var currMin = d.getMinutes();
return currMonth + "/" + currDate + "/" + currYear + " " + pad(currHour, 2, '0') + ":" + pad(currMin, 2, '0') + " GMT";
},
formatNumber: function (strNumber) {
return strNumber.toFixed(0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
},
formatDecimal: function (strNumber, decPlaces) {
return strNumber.toFixed(decPlaces).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
},
formatCurrency: function (strNumber) {
return '$' + strNumber.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
},
formatPercent: function (strNumber) {
return (strNumber * 100).toFixed(2).toString() + "%";
},
formatWholePercent: function (strNumber) {
return (strNumber * 100).toFixed(0).toString() + "%";
},
formatBooleanYesNo: function (value) {
return value != 0 ? 'Yes' : 'No';
},
formatBooleanTrueFalse: function (value) {
return value != 0 ? 'True' : 'False';
},
formatBooleanNumber: function(value) {
return (value) ? 1 : 0;
},
formatBooleanNumberForApi: function (value) {
return (value) ? 1 : -999;
},
formatNumberForApi: function (value) {
if (value == 0)
return -999;
return value;
},
formatDecimalForApi: function (value) {
if (value == 0 || value == 0.00 || value == ''){
value = '-999.00';
return '-999.00';
}
return value;
},
formatPhoneNumber: function(value){
return value;
},
formatDataTable: function (name) {
setTimeout(function () {
var table = $(name).dataTable();
table.fnDraw();
}, 125);
}
};
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
}();
var razorApi = function () {
var failureCallback = function (msg)
{
try {
if (typeof msg.responseText != 'undefined') {
var obj = jQuery.parseJSON(msg.responseText);
razorAlert.alertError(obj.Message);
}
else {
razorAlert.alertError(msg.statusText);
}
} catch (ex) {
razorAlert.alertError(ex);
}
};
var alwaysCallback = function (msg) { setTimeout(endProcess, 1000); };
var openCalls = 0;
var uiBlocked = 0;
return {
ApiUpload: function (path, query, successCallBack, includeToken, data) {
var url = host + path + query;
if (path.indexOf('secured/api') != -1)
startProcess();
else
startProcessAlt();
return {
url: url,
type: 'post',
beforeSend: setHmacOptions(path, query, includeToken),
data: data,
beforeSubmit: function (arr, $form, options) { },
success: successCallBack,
error: failureCallback,
complete: alwaysCallback,
dataType: 'json',
async: false
};
},
ApiUploadSingle: function (path, query, successCallBack, includeToken, data) {
var url = host + path + query;
return {
url: url,
type: 'post',
beforeSend: setHmacOptions(path, query, includeToken),
data: data,
beforeSubmit: function (arr, $form, options) { },
success: successCallBack,
error: failureCallback,
dataType: 'json',
async: false
};
},
ApiGet: function (path, query, includeToken) {
var url = host + path + query;
if (path.indexOf('secured/api') != -1)
startProcess();
else
startProcessAlt();
return $.ajax({
url: url,
beforeSend: setHmacOptions(path, query, includeToken),
contentType: 'json',
dataType: 'json',
async: true
}).fail(failureCallback).always(alwaysCallback);
},
ApiGetSyncronous: function (path, query, includeToken) {
var url = host + path + query;
if (path.indexOf('secured/api') != -1)
startProcess();
else
startProcessAlt();
return $.ajax({
url: url,
beforeSend: setHmacOptions(path, query, includeToken),
contentType: 'json',
dataType: 'json',
async: false
}).fail(failureCallback).always(alwaysCallback);
},
ApiDelete: function (path, query, includeToken) {
var url = host + path + query;
if (path.indexOf('secured/api') != -1)
startProcess();
else
startProcessAlt();
return $.ajax({
url: url,
beforeSend: setHmacOptions(path, query, includeToken),
type: 'DELETE',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: true
}).fail(failureCallback).always(alwaysCallback);
},
ApiPost: function (path, query, data, includeToken) {
var url = host + path + query;
if (path.indexOf('secured/api') != -1)
startProcess();
else
startProcessAlt();
return $.ajax({
url: url,
beforeSend: setHmacOptions(path, query, includeToken),
type: 'POST',
data: JSON.stringify(data),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: true
}).fail(failureCallback).always(alwaysCallback);
},
ApiPut: function (path, query, data, includeToken) {
var url = host + path + query;
if (path.indexOf('secured/api') != -1)
startProcess();
else
startProcessAlt();
return $.ajax({
url: url,
beforeSend: setHmacOptions(path, query, includeToken),
type: 'PUT',
data: JSON.stringify(data),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: true
}).fail(failureCallback).always(alwaysCallback);
}
};
function setHmacOptions(path, query, includeToken) {
if (includeToken) {
var token = razorStorage.ExtractLocalData('token');
return function (xhr) { setHmacHeadersWithToken(xhr, path + query, token); };
}
else {
return function (xhr) { setHmacHeaders(xhr, path + query); };
}
}
function setHmacHeaders(xhr, url) {
var timestamp = getTimestamp();
var msg = url + timestamp + applicationId;
var hash = CryptoJS.HmacSHA256(msg, sharedSecret);
hash = CryptoJS.enc.Base64.stringify(hash);
xhr.setRequestHeader('Request-Signature', hash);
xhr.setRequestHeader('Request-Timestamp', timestamp);
xhr.setRequestHeader('Application-ID', applicationId);
}
function setHmacHeadersWithToken(xhr, url, token) {
var timestamp = getTimestamp();
var msg = url + timestamp + applicationId;
var hash = CryptoJS.HmacSHA256(msg, sharedSecret + token);
hash = CryptoJS.enc.Base64.stringify(hash);
xhr.setRequestHeader('Request-Signature', hash);
xhr.setRequestHeader('Request-Timestamp', timestamp);
xhr.setRequestHeader('Application-ID', applicationId);
xhr.setRequestHeader('Authorization-Token', token);
}
function getTimestamp() {
var now = new Date();
var year = now.getUTCFullYear();
var month = lpad(now.getUTCMonth() + 1);
var day = lpad(now.getUTCDate());
var hour = lpad(now.getUTCHours());
var minute = lpad(now.getUTCMinutes());
var second = lpad(now.getUTCSeconds());
var timestamp = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
return timestamp;
}
function lpad(input) {
var contentToSize = '' + input;
var padLength = 2;
var padChar = '0';
var paddedString = contentToSize.toString();
for (i = contentToSize.length; i < padLength; i++) {
paddedString = padChar + paddedString;
}
return paddedString;
}
function startProcess() {
if (enableLoadingAnnimation == 1) {
openCalls = openCalls + 1;
if (uiBlocked == 0) {
uiBlocked = 1;
$.blockUI({
message: '
',
baseZ: '1099',
css: {
border: 'none',
backgroundColor: 'transparent',
'z-index': '1100',
width: '20%',
left:'40%',
},
overlayCSS: {
backgroundColor: '#000',
opacity: 0.8,
cursor: 'wait'
}
});
}
}
}
function startProcessAlt() {
if (enableLoadingAnnimation == 1) {
openCalls = openCalls + 1;
if (uiBlocked == 0) {
uiBlocked = 1;
$.blockUI({
message: 'loading...
',
baseZ: '1099',
css: {
border: 'none',
backgroundColor: 'transparent',
'z-index': '1100',
width: '20%',
left:'40%',
}
});
}
}
}
function endProcess() {
if (enableLoadingAnnimation == 1) {
openCalls = openCalls - 1;
if (openCalls == 0) {
uiBlocked = 0;
$.unblockUI();
}
}
}
}();
var razorAuth = function () {
return {
logOn: function(userName, password) {
if (userName == '' || password == '') {
razorAlert.alertError('Missing Username/Password');
return;
}
var success = function (msg) {
if (msg != null && msg != '') {
razorStorage.SaveLocalData('token', msg);
var success1 = function (msg1) {
razorStorage.SaveLocalData('userId', msg1);
razorStorage.SaveLocalData('userName', userName);
var success2 = function (msg2) {
razorStorage.SaveLocalData('userType', msg2);
var success3 = function (msg3) {
razorStorage.SaveLocalData('passwordStatus', msg3);
var success4 = function (msg4) {
razorStorage.SaveLocalData('userNameStatus', msg4);
var success5 = function (msg5) {
if (msg2 == 4)
razorStorage.SaveLocalData('roles', JSON.stringify(msg5));
var success6 = function(msg6) {
razorStorage.SaveLocalData('siteUser', JSON.stringify(msg6));
var success7 = function (msg7) {
razorStorage.SaveLocalData('siteSettings', JSON.stringify(msg7));
if(razorAuth.userInRole(1))
document.location.href = redirectAfterAdminLogin;
if(razorAuth.userInRole(2))
document.location.href = redirectAfterBlogLogin;
if(razorAuth.userInRole(3))
document.location.href = redirectAfterStoreLogin;
if(razorAuth.userInRole(4))
document.location.href = redirectAfterFulfilmentLogin;
};
SiteSettingService.List(0, 0).done(success7);
};
SiteUserService.Select(msg1).done(success6);
};
ServiceUserRoleService.ListByUser(0, 0).done(success5);
};
ServiceUserService.UsernameStatus().done(success4);
};
ServiceUserService.PasswordStatus().done(success3);
};
ServiceAuthService.GetUserType().done(success2);
};
ServiceAuthService.GetUserID().done(success1);
}
};
ServiceAuthService.Authenticate(userName, password).done(success);
},
logOff: function() {
var success = function (msg) {
razorStorage.ClearLocalData();
document.location.href = authPage;
};
try {
ServiceAuthService.Logout().done(success).fail(success);
}
catch (ex) {
razorStorage.ClearLocalData();
document.location.href = authPage;
}
},
userInRole: function (role) {
var result = false;
var roleData = razorStorage.ExtractLocalData('roles');
if (roleData != null && roleData != 'undefined') {
roleData = JSON.parse(roleData);
$.each(roleData.Items, function (index, item) {
if (parseInt(item.RoleID) == parseInt(role))
result = true;
});
}
return result;
},
verifyToken: function (callback) {
ServiceAuthService.IsTokenValid().done(callback);
}
};
}();
/***************************************************************************/
/*!
* CryptoJS v3.1.2
* code.google.com/p/crypto-js
* (c) 2009-2013 by Jeff Mott. All rights reserved.
* code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS = CryptoJS || function (h, s) {
var f = {}, g = f.lib = {}, q = function () { }, m = g.Base = { extend: function (a) { q.prototype = this; var c = new q; a && c.mixIn(a); c.hasOwnProperty("init") || (c.init = function () { c.$super.init.apply(this, arguments) }); c.init.prototype = c; c.$super = this; return c }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend(this) } },
r = g.WordArray = m.extend({
init: function (a, c) { a = this.words = a || []; this.sigBytes = c != s ? c : 4 * a.length }, toString: function (a) { return (a || k).stringify(this) }, concat: function (a) { var c = this.words, d = a.words, b = this.sigBytes; a = a.sigBytes; this.clamp(); if (b % 4) for (var e = 0; e < a; e++) c[b + e >>> 2] |= (d[e >>> 2] >>> 24 - 8 * (e % 4) & 255) << 24 - 8 * ((b + e) % 4); else if (65535 < d.length) for (e = 0; e < a; e += 4) c[b + e >>> 2] = d[e >>> 2]; else c.push.apply(c, d); this.sigBytes += a; return this }, clamp: function () {
var a = this.words, c = this.sigBytes; a[c >>> 2] &= 4294967295 <<
32 - 8 * (c % 4); a.length = h.ceil(c / 4)
}, clone: function () { var a = m.clone.call(this); a.words = this.words.slice(0); return a }, random: function (a) { for (var c = [], d = 0; d < a; d += 4) c.push(4294967296 * h.random() | 0); return new r.init(c, a) }
}), l = f.enc = {}, k = l.Hex = {
stringify: function (a) { var c = a.words; a = a.sigBytes; for (var d = [], b = 0; b < a; b++) { var e = c[b >>> 2] >>> 24 - 8 * (b % 4) & 255; d.push((e >>> 4).toString(16)); d.push((e & 15).toString(16)) } return d.join("") }, parse: function (a) {
for (var c = a.length, d = [], b = 0; b < c; b += 2) d[b >>> 3] |= parseInt(a.substr(b,
2), 16) << 24 - 4 * (b % 8); return new r.init(d, c / 2)
}
}, n = l.Latin1 = { stringify: function (a) { var c = a.words; a = a.sigBytes; for (var d = [], b = 0; b < a; b++) d.push(String.fromCharCode(c[b >>> 2] >>> 24 - 8 * (b % 4) & 255)); return d.join("") }, parse: function (a) { for (var c = a.length, d = [], b = 0; b < c; b++) d[b >>> 2] |= (a.charCodeAt(b) & 255) << 24 - 8 * (b % 4); return new r.init(d, c) } }, j = l.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(n.stringify(a))) } catch (c) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return n.parse(unescape(encodeURIComponent(a))) } },
u = g.BufferedBlockAlgorithm = m.extend({
reset: function () { this._data = new r.init; this._nDataBytes = 0 }, _append: function (a) { "string" == typeof a && (a = j.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var c = this._data, d = c.words, b = c.sigBytes, e = this.blockSize, f = b / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0); a = f * e; b = h.min(4 * a, b); if (a) { for (var g = 0; g < a; g += e) this._doProcessBlock(d, g); g = d.splice(0, a); c.sigBytes -= b } return new r.init(g, b) }, clone: function () {
var a = m.clone.call(this);
a._data = this._data.clone(); return a
}, _minBufferSize: 0
}); g.Hasher = u.extend({
cfg: m.extend(), init: function (a) { this.cfg = this.cfg.extend(a); this.reset() }, reset: function () { u.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); return this._doFinalize() }, blockSize: 16, _createHelper: function (a) { return function (c, d) { return (new a.init(d)).finalize(c) } }, _createHmacHelper: function (a) {
return function (c, d) {
return (new t.HMAC.init(a,
d)).finalize(c)
}
}
}); var t = f.algo = {}; return f
}(Math);
(function (h) {
for (var s = CryptoJS, f = s.lib, g = f.WordArray, q = f.Hasher, f = s.algo, m = [], r = [], l = function (a) { return 4294967296 * (a - (a | 0)) | 0 }, k = 2, n = 0; 64 > n;) { var j; a: { j = k; for (var u = h.sqrt(j), t = 2; t <= u; t++) if (!(j % t)) { j = !1; break a } j = !0 } j && (8 > n && (m[n] = l(h.pow(k, 0.5))), r[n] = l(h.pow(k, 1 / 3)), n++); k++ } var a = [], f = f.SHA256 = q.extend({
_doReset: function () { this._hash = new g.init(m.slice(0)) }, _doProcessBlock: function (c, d) {
for (var b = this._hash.words, e = b[0], f = b[1], g = b[2], j = b[3], h = b[4], m = b[5], n = b[6], q = b[7], p = 0; 64 > p; p++) {
if (16 > p) a[p] =
c[d + p] | 0; else { var k = a[p - 15], l = a[p - 2]; a[p] = ((k << 25 | k >>> 7) ^ (k << 14 | k >>> 18) ^ k >>> 3) + a[p - 7] + ((l << 15 | l >>> 17) ^ (l << 13 | l >>> 19) ^ l >>> 10) + a[p - 16] } k = q + ((h << 26 | h >>> 6) ^ (h << 21 | h >>> 11) ^ (h << 7 | h >>> 25)) + (h & m ^ ~h & n) + r[p] + a[p]; l = ((e << 30 | e >>> 2) ^ (e << 19 | e >>> 13) ^ (e << 10 | e >>> 22)) + (e & f ^ e & g ^ f & g); q = n; n = m; m = h; h = j + k | 0; j = g; g = f; f = e; e = k + l | 0
} b[0] = b[0] + e | 0; b[1] = b[1] + f | 0; b[2] = b[2] + g | 0; b[3] = b[3] + j | 0; b[4] = b[4] + h | 0; b[5] = b[5] + m | 0; b[6] = b[6] + n | 0; b[7] = b[7] + q | 0
}, _doFinalize: function () {
var a = this._data, d = a.words, b = 8 * this._nDataBytes, e = 8 * a.sigBytes;
d[e >>> 5] |= 128 << 24 - e % 32; d[(e + 64 >>> 9 << 4) + 14] = h.floor(b / 4294967296); d[(e + 64 >>> 9 << 4) + 15] = b; a.sigBytes = 4 * d.length; this._process(); return this._hash
}, clone: function () { var a = q.clone.call(this); a._hash = this._hash.clone(); return a }
}); s.SHA256 = q._createHelper(f); s.HmacSHA256 = q._createHmacHelper(f)
})(Math);
(function () {
var h = CryptoJS, s = h.enc.Utf8; h.algo.HMAC = h.lib.Base.extend({
init: function (f, g) { f = this._hasher = new f.init; "string" == typeof g && (g = s.parse(g)); var h = f.blockSize, m = 4 * h; g.sigBytes > m && (g = f.finalize(g)); g.clamp(); for (var r = this._oKey = g.clone(), l = this._iKey = g.clone(), k = r.words, n = l.words, j = 0; j < h; j++) k[j] ^= 1549556828, n[j] ^= 909522486; r.sigBytes = l.sigBytes = m; this.reset() }, reset: function () { var f = this._hasher; f.reset(); f.update(this._iKey) }, update: function (f) { this._hasher.update(f); return this }, finalize: function (f) {
var g =
this._hasher; f = g.finalize(f); g.reset(); return g.finalize(this._oKey.clone().concat(f))
}
})
})();
(function () {
var h = CryptoJS, j = h.lib.WordArray; h.enc.Base64 = {
stringify: function (b) { var e = b.words, f = b.sigBytes, c = this._map; b.clamp(); b = []; for (var a = 0; a < f; a += 3) for (var d = (e[a >>> 2] >>> 24 - 8 * (a % 4) & 255) << 16 | (e[a + 1 >>> 2] >>> 24 - 8 * ((a + 1) % 4) & 255) << 8 | e[a + 2 >>> 2] >>> 24 - 8 * ((a + 2) % 4) & 255, g = 0; 4 > g && a + 0.75 * g < f; g++) b.push(c.charAt(d >>> 6 * (3 - g) & 63)); if (e = c.charAt(64)) for (; b.length % 4;) b.push(e); return b.join("") }, parse: function (b) {
var e = b.length, f = this._map, c = f.charAt(64); c && (c = b.indexOf(c), -1 != c && (e = c)); for (var c = [], a = 0, d = 0; d <
e; d++) if (d % 4) { var g = f.indexOf(b.charAt(d - 1)) << 2 * (d % 4), h = f.indexOf(b.charAt(d)) >>> 6 - 2 * (d % 4); c[a >>> 2] |= (g | h) << 24 - 8 * (a % 4); a++ } return j.create(c, a)
}, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
})();
/***************************************************************************/
/*!
* jQuery blockUI plugin
* Version 2.66.0-2013.10.09
* Requires jQuery v1.7 or later
*
* Examples at: http://malsup.com/jquery/block/
* Copyright (c) 2007-2013 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function () {
"use strict";
function setup($) {
$.fn._fadeIn = $.fn.fadeIn;
var noOp = $.noop || function () { };
var msie = /MSIE/.test(navigator.userAgent);
var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
var mode = document.documentMode || 0;
var setExpr = $.isFunction(document.createElement('div').style.setExpression);
$.blockUI = function (opts) { install(window, opts); };
$.unblockUI = function (opts) { remove(window, opts); };
$.growlUI = function (title, message, timeout, onClose) {
var $m = $('');
if (title) $m.append('' + title + '
');
if (message) $m.append('' + message + '
');
if (timeout === undefined) timeout = 3000;
var callBlock = function (opts) {
opts = opts || {};
$.blockUI({
message: $m,
fadeIn: typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700,
fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
centerY: false,
showOverlay: false,
onUnblock: onClose,
css: $.blockUI.defaults.growlCSS
});
};
callBlock();
var nonmousedOpacity = $m.css('opacity');
$m.mouseover(function () {
callBlock({
fadeIn: 0,
timeout: 30000
});
var displayBlock = $('.blockMsg');
displayBlock.stop();
displayBlock.fadeTo(300, 1);
}).mouseout(function () {
$('.blockMsg').fadeOut(1000);
});
};
$.fn.block = function (opts) {
if (this[0] === window) {
$.blockUI(opts);
return this;
}
var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
this.each(function () {
var $el = $(this);
if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
return;
$el.unblock({ fadeOut: 0 });
});
return this.each(function () {
if ($.css(this, 'position') == 'static') {
this.style.position = 'relative';
$(this).data('blockUI.static', true);
}
this.style.zoom = 1;
install(this, opts);
});
};
$.fn.unblock = function (opts) {
if (this[0] === window) {
$.unblockUI(opts);
return this;
}
return this.each(function () {
remove(this, opts);
});
};
$.blockUI.version = 2.66;
$.blockUI.defaults = {
message: 'Please wait...
',
title: null,
draggable: true,
theme: false,
css: {
padding: 0,
margin: 0,
width: '30%',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: '3px solid #aaa',
backgroundColor: '#fff',
cursor: 'wait'
},
themedCSS: {
width: '30%',
top: '40%',
left: '35%'
},
overlayCSS: {
backgroundColor: '#000',
opacity: 0.6,
cursor: 'wait'
},
cursorReset: 'default',
growlCSS: {
width: '350px',
top: '10px',
left: '',
right: '10px',
border: 'none',
padding: '5px',
opacity: 0.6,
cursor: 'default',
color: '#fff',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
'border-radius': '10px'
},
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
forceIframe: false,
baseZ: 1000,
centerX: true,
centerY: true,
allowBodyStretch: true,
bindEvents: true,
constrainTabKey: true,
fadeIn: 200,
fadeOut: 400,
timeout: 0,
showOverlay: true,
focusInput: true,
focusableElements: ':input:enabled:visible',
onBlock: null,
onUnblock: null,
onOverlayClick: null,
quirksmodeOffsetHack: 4,
blockMsgClass: 'blockMsg',
ignoreIfBlocked: false
};
var pageBlock = null;
var pageBlockEls = [];
function install(el, opts) {
var css, themedCSS;
var full = (el == window);
var msg = (opts && opts.message !== undefined ? opts.message : undefined);
opts = $.extend({}, $.blockUI.defaults, opts || {});
if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
return;
opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
if (opts.onOverlayClick)
opts.overlayCSS.cursor = 'pointer';
themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
msg = msg === undefined ? opts.message : msg;
if (full && pageBlock)
remove(window, { fadeOut: 0 });
if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
var node = msg.jquery ? msg[0] : msg;
var data = {};
$(el).data('blockUI.history', data);
data.el = node;
data.parent = node.parentNode;
data.display = node.style.display;
data.position = node.style.position;
if (data.parent)
data.parent.removeChild(node);
}
$(el).data('blockUI.onUnblock', opts.onUnblock);
var z = opts.baseZ;
var lyr1, lyr2, lyr3, s;
if (msie || opts.forceIframe)
lyr1 = $('');
else
lyr1 = $('');
if (opts.theme)
lyr2 = $('');
else
lyr2 = $('');
if (opts.theme && full) {
s = '';
if (opts.title) {
s += '';
}
s += '
';
s += '
';
}
else if (opts.theme) {
s = '';
}
else if (full) {
s = '';
}
else {
s = '';
}
lyr3 = $(s);
if (msg) {
if (opts.theme) {
lyr3.css(themedCSS);
lyr3.addClass('ui-widget-content');
}
else
lyr3.css(css);
}
if (!opts.theme)
lyr2.css(opts.overlayCSS);
lyr2.css('position', full ? 'fixed' : 'absolute');
if (msie || opts.forceIframe)
lyr1.css('opacity', 0.0);
var layers = [lyr1, lyr2, lyr3], $par = full ? $('body') : $(el);
$.each(layers, function () {
this.appendTo($par);
});
if (opts.theme && opts.draggable && $.fn.draggable) {
lyr3.draggable({
handle: '.ui-dialog-titlebar',
cancel: 'li'
});
}
var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
if (ie6 || expr) {
if (full && opts.allowBodyStretch && $.support.boxModel)
$('html,body').css('height', '100%');
if ((ie6 || !$.support.boxModel) && !full) {
var t = sz(el, 'borderTopWidth'), l = sz(el, 'borderLeftWidth');
var fixT = t ? '(0 - ' + t + ')' : 0;
var fixL = l ? '(0 - ' + l + ')' : 0;
}
$.each(layers, function (i, o) {
var s = o[0].style;
s.position = 'absolute';
if (i < 2) {
if (full)
s.setExpression('height', 'Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:' + opts.quirksmodeOffsetHack + ') + "px"');
else
s.setExpression('height', 'this.parentNode.offsetHeight + "px"');
if (full)
s.setExpression('width', 'jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
else
s.setExpression('width', 'this.parentNode.offsetWidth + "px"');
if (fixL) s.setExpression('left', fixL);
if (fixT) s.setExpression('top', fixT);
}
else if (opts.centerY) {
if (full) s.setExpression('top', '(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
s.marginTop = 0;
}
else if (!opts.centerY && full) {
var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + ' + top + ') + "px"';
s.setExpression('top', expression);
}
});
}
if (msg) {
if (opts.theme)
lyr3.find('.ui-widget-content').append(msg);
else
lyr3.append(msg);
if (msg.jquery || msg.nodeType)
$(msg).show();
}
if ((msie || opts.forceIframe) && opts.showOverlay)
lyr1.show();
if (opts.fadeIn) {
var cb = opts.onBlock ? opts.onBlock : noOp;
var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
var cb2 = msg ? cb : noOp;
if (opts.showOverlay)
lyr2._fadeIn(opts.fadeIn, cb1);
if (msg)
lyr3._fadeIn(opts.fadeIn, cb2);
}
else {
if (opts.showOverlay)
lyr2.show();
if (msg)
lyr3.show();
if (opts.onBlock)
opts.onBlock();
}
bind(1, el, opts);
if (full) {
pageBlock = lyr3[0];
pageBlockEls = $(opts.focusableElements, pageBlock);
if (opts.focusInput)
setTimeout(focus, 20);
}
else
center(lyr3[0], opts.centerX, opts.centerY);
if (opts.timeout) {
var to = setTimeout(function () {
if (full)
$.unblockUI(opts);
else
$(el).unblock(opts);
}, opts.timeout);
$(el).data('blockUI.timeout', to);
}
}
function remove(el, opts) {
var count;
var full = (el == window);
var $el = $(el);
var data = $el.data('blockUI.history');
var to = $el.data('blockUI.timeout');
if (to) {
clearTimeout(to);
$el.removeData('blockUI.timeout');
}
opts = $.extend({}, $.blockUI.defaults, opts || {});
bind(0, el, opts);
if (opts.onUnblock === null) {
opts.onUnblock = $el.data('blockUI.onUnblock');
$el.removeData('blockUI.onUnblock');
}
var els;
if (full)
els = $('body').children().filter('.blockUI').add('body > .blockUI');
else
els = $el.find('>.blockUI');
if (opts.cursorReset) {
if (els.length > 1)
els[1].style.cursor = opts.cursorReset;
if (els.length > 2)
els[2].style.cursor = opts.cursorReset;
}
if (full)
pageBlock = pageBlockEls = null;
if (opts.fadeOut) {
count = els.length;
els.stop().fadeOut(opts.fadeOut, function () {
if (--count === 0)
reset(els, data, opts, el);
});
}
else
reset(els, data, opts, el);
}
function reset(els, data, opts, el) {
var $el = $(el);
if ($el.data('blockUI.isBlocked'))
return;
els.each(function (i, o) {
if (this.parentNode)
this.parentNode.removeChild(this);
});
if (data && data.el) {
data.el.style.display = data.display;
data.el.style.position = data.position;
if (data.parent)
data.parent.appendChild(data.el);
$el.removeData('blockUI.history');
}
if ($el.data('blockUI.static')) {
$el.css('position', 'static'); // #22
}
if (typeof opts.onUnblock == 'function')
opts.onUnblock(el, opts);
var body = $(document.body), w = body.width(), cssW = body[0].style.width;
body.width(w - 1).width(w);
body[0].style.width = cssW;
}
function bind(b, el, opts) {
var full = el == window, $el = $(el);
if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
return;
$el.data('blockUI.isBlocked', b);
if (!full || !opts.bindEvents || (b && !opts.showOverlay))
return;
var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
if (b)
$(document).bind(events, opts, handler);
else
$(document).unbind(events, handler);
}
function handler(e) {
if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
if (pageBlock && e.data.constrainTabKey) {
var els = pageBlockEls;
var fwd = !e.shiftKey && e.target === els[els.length - 1];
var back = e.shiftKey && e.target === els[0];
if (fwd || back) {
setTimeout(function () { focus(back); }, 10);
return false;
}
}
}
var opts = e.data;
var target = $(e.target);
if (target.hasClass('blockOverlay') && opts.onOverlayClick)
opts.onOverlayClick(e);
if (target.parents('div.' + opts.blockMsgClass).length > 0)
return true;
return target.parents().children().filter('div.blockUI').length === 0;
}
function focus(back) {
if (!pageBlockEls)
return;
var e = pageBlockEls[back === true ? pageBlockEls.length - 1 : 0];
if (e)
e.focus();
}
function center(el, x, y) {
var p = el.parentNode, s = el.style;
var l = ((p.offsetWidth - el.offsetWidth) / 2) - sz(p, 'borderLeftWidth');
var t = ((p.offsetHeight - el.offsetHeight) / 2) - sz(p, 'borderTopWidth');
if (x) s.left = l > 0 ? (l + 'px') : '0';
if (y) s.top = t > 0 ? (t + 'px') : '0';
}
function sz(el, p) {
return parseInt($.css(el, p), 10) || 0;
}
}
if (typeof define === 'function' && define.amd && define.amd.jQuery) {
define(['jquery'], setup);
} else {
setup(jQuery);
}
})();
/***************************************************************************/
/*!
* jGrowl 1.3.0
*
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Written by Stan Lemon
* Last updated: 2014.04.18
*
* jGrowl is a jQuery plugin implementing unobtrusive userland notifications. These
* notifications function similarly to the Growl Framework available for
* Mac OS X (http://growl.info).
*
*/
(function ($) {
var $ie6 = (function () {
return false === $.support.boxModel && $.support.objectAll && $.support.leadingWhitespace;
})();
$.jGrowl = function (m, o) {
if ($('#jGrowl').size() === 0)
$('').addClass((o && o.position) ? o.position : $.jGrowl.defaults.position).appendTo('body');
$('#jGrowl').jGrowl(m, o);
};
$.fn.jGrowl = function (m, o) {
if ($.isFunction(this.each)) {
var args = arguments;
return this.each(function () {
if ($(this).data('jGrowl.instance') === undefined) {
$(this).data('jGrowl.instance', $.extend(new $.fn.jGrowl(), { notifications: [], element: null, interval: null }));
$(this).data('jGrowl.instance').startup(this);
}
if ($.isFunction($(this).data('jGrowl.instance')[m])) {
$(this).data('jGrowl.instance')[m].apply($(this).data('jGrowl.instance'), $.makeArray(args).slice(1));
} else {
$(this).data('jGrowl.instance').create(m, o);
}
});
}
};
$.extend($.fn.jGrowl.prototype, {
defaults: {
pool: 0,
header: '',
group: '',
sticky: false,
position: 'top-right',
glue: 'after',
theme: 'default',
themeState: 'highlight',
corners: '10px',
check: 250,
life: 3000,
closeDuration: 'normal',
openDuration: 'normal',
easing: 'swing',
closer: true,
closeTemplate: '×',
closerTemplate: '[ close all ]
',
log: function () { },
beforeOpen: function () { },
afterOpen: function () { },
open: function () { },
beforeClose: function () { },
close: function () { },
animateOpen: {
opacity: 'show'
},
animateClose: {
opacity: 'hide'
}
},
notifications: [],
element: null,
interval: null,
create: function (message, options) {
var o = $.extend({}, this.defaults, options);
if (typeof o.speed !== 'undefined') {
o.openDuration = o.speed;
o.closeDuration = o.speed;
}
this.notifications.push({ message: message, options: o });
o.log.apply(this.element, [this.element, message, o]);
},
render: function (n) {
var self = this;
var message = n.message;
var o = n.options;
o.themeState = (o.themeState === '') ? '' : 'ui-state-' + o.themeState;
var notification = $('')
.addClass('jGrowl-notification ' + o.themeState + ' ui-corner-all' + ((o.group !== undefined && o.group !== '') ? ' ' + o.group : ''))
.append($('').addClass('jGrowl-close').html(o.closeTemplate))
.append($('').addClass('jGrowl-header').html(o.header))
.append($('').addClass('jGrowl-message').html(message))
.data("jGrowl", o).addClass(o.theme).children('div.jGrowl-close').bind("click.jGrowl", function () {
$(this).parent().trigger('jGrowl.beforeClose');
})
.parent();
$(notification).bind("mouseover.jGrowl", function () {
$('div.jGrowl-notification', self.element).data("jGrowl.pause", true);
}).bind("mouseout.jGrowl", function () {
$('div.jGrowl-notification', self.element).data("jGrowl.pause", false);
}).bind('jGrowl.beforeOpen', function () {
if (o.beforeOpen.apply(notification, [notification, message, o, self.element]) !== false) {
$(this).trigger('jGrowl.open');
}
}).bind('jGrowl.open', function () {
if (o.open.apply(notification, [notification, message, o, self.element]) !== false) {
if (o.glue == 'after') {
$('div.jGrowl-notification:last', self.element).after(notification);
} else {
$('div.jGrowl-notification:first', self.element).before(notification);
}
$(this).animate(o.animateOpen, o.openDuration, o.easing, function () {
if ($.support.opacity === false)
this.style.removeAttribute('filter');
if ($(this).data("jGrowl") !== null) // Happens when a notification is closing before it's open.
$(this).data("jGrowl").created = new Date();
$(this).trigger('jGrowl.afterOpen');
});
}
}).bind('jGrowl.afterOpen', function () {
o.afterOpen.apply(notification, [notification, message, o, self.element]);
}).bind('jGrowl.beforeClose', function () {
if (o.beforeClose.apply(notification, [notification, message, o, self.element]) !== false)
$(this).trigger('jGrowl.close');
}).bind('jGrowl.close', function () {
$(this).data('jGrowl.pause', true);
$(this).animate(o.animateClose, o.closeDuration, o.easing, function () {
if ($.isFunction(o.close)) {
if (o.close.apply(notification, [notification, message, o, self.element]) !== false)
$(this).remove();
} else {
$(this).remove();
}
});
}).trigger('jGrowl.beforeOpen');
if (o.corners !== '' && $.fn.corner !== undefined) $(notification).corner(o.corners);
if ($('div.jGrowl-notification:parent', self.element).size() > 1 &&
$('div.jGrowl-closer', self.element).size() === 0 && this.defaults.closer !== false) {
$(this.defaults.closerTemplate).addClass('jGrowl-closer ' + this.defaults.themeState + ' ui-corner-all').addClass(this.defaults.theme)
.appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing)
.bind("click.jGrowl", function () {
$(this).siblings().trigger("jGrowl.beforeClose");
if ($.isFunction(self.defaults.closer)) {
self.defaults.closer.apply($(this).parent()[0], [$(this).parent()[0]]);
}
});
}
},
update: function () {
$(this.element).find('div.jGrowl-notification:parent').each(function () {
if ($(this).data("jGrowl") !== undefined && $(this).data("jGrowl").created !== undefined &&
($(this).data("jGrowl").created.getTime() + parseInt($(this).data("jGrowl").life, 10)) < (new Date()).getTime() &&
$(this).data("jGrowl").sticky !== true &&
($(this).data("jGrowl.pause") === undefined || $(this).data("jGrowl.pause") !== true)) {
$(this).trigger('jGrowl.beforeClose');
}
});
if (this.notifications.length > 0 &&
(this.defaults.pool === 0 || $(this.element).find('div.jGrowl-notification:parent').size() < this.defaults.pool))
this.render(this.notifications.shift());
if ($(this.element).find('div.jGrowl-notification:parent').size() < 2) {
$(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function () {
$(this).remove();
});
}
},
startup: function (e) {
this.element = $(e).addClass('jGrowl').append('');
this.interval = setInterval(function () {
$(e).data('jGrowl.instance').update();
}, parseInt(this.defaults.check, 10));
if ($ie6) {
$(this.element).addClass('ie6');
}
},
shutdown: function () {
$(this.element).removeClass('jGrowl')
.find('div.jGrowl-notification').trigger('jGrowl.close')
.parent().empty()
;
clearInterval(this.interval);
},
close: function () {
$(this.element).find('div.jGrowl-notification').each(function () {
$(this).trigger('jGrowl.beforeClose');
});
}
});
$.jGrowl.defaults = $.fn.jGrowl.prototype.defaults;
})(jQuery);