',
ww = wheels[i],
w = ww.values ? ww : convert(ww),
l = 1,
labels = w.labels || [],
values = w.values,
keys = w.keys || values;
$.each(values, function (j, v) {
if (l % 20 == 0) {
html += '
' + (!modal ? '
' : '
') + '
',
isMinw = $.isArray(s.minWidth),
isMaxw = $.isArray(s.maxWidth),
isFixw = $.isArray(s.fixedWidth);
$.each(s.wheels, function (i, wg) { // Wheel groups
html += '
';
});
html += '
';
if (modal && hasButtons) {
html += '
';
$.each(buttons, function (i, b) {
b = (typeof b === 'string') ? that.buttons[b] : b;
html += '
' + b.text + '';
});
html += '
';
}
html += '
';
dw = $(html);
persp = $('.dw-persp', dw);
overlay = $('.dwo', dw);
visible = true;
scrollToPos();
event('onMarkupReady', [dw]);
// Show
if (modal) {
ms.activeInstance = that;
dw.appendTo(s.context);
if (anim && !prevAnim) {
dw.addClass('dw-trans');
// Remove animation class
setTimeout(function () {
dw.removeClass('dw-trans').find('.dw').removeClass(mAnim);
}, 350);
}
} else if (elm.is('div')) {
elm.html(dw);
} else {
dw.insertAfter(elm);
}
event('onMarkupInserted', [dw]);
if (modal) {
// Enter / ESC
$(window).on('keydown.dw', function (e) {
if (e.keyCode == 13) {
that.select();
} else if (e.keyCode == 27) {
that.cancel();
}
});
// Prevent scroll if not specified otherwise
if (s.scrollLock) {
dw.on('touchmove', function (e) {
if (lock) {
e.preventDefault();
}
});
}
// Disable inputs to prevent bleed through (Android bug) and set autocomplete to off (for Firefox)
$('input,select,button', doc).each(function () {
if (!this.disabled) {
if ($(this).attr('autocomplete')) {
$(this).data('autocomplete', $(this).attr('autocomplete'));
}
$(this).addClass('dwtd').prop('disabled', true).attr('autocomplete', 'off');
}
});
attachPosition('scroll.dw', true);
}
// Set position
that.position();
attachPosition('orientationchange.dw resize.dw', false);
// Events
dw.on('DOMMouseScroll mousewheel', '.dwwl', onScroll)
.on('keydown', '.dwwl', onKeyDown)
.on('keyup', '.dwwl', onKeyUp)
.on('selectstart mousedown', prevdef) // Prevents blue highlight on Android and text selection in IE
.on('click', '.dwb-e', prevdef)
.on('keydown', '.dwb-e', function (e) {
if (e.keyCode == 32) { // Space
e.preventDefault();
e.stopPropagation();
$(this).click();
}
});
setTimeout(function () {
// Init buttons
$.each(buttons, function (i, b) {
that.tap($('.dwb' + i, dw), function (e) {
b = (typeof b === 'string') ? that.buttons[b] : b;
b.handler.call(this, e, that);
});
});
if (s.closeOnOverlay) {
that.tap(overlay, function () {
that.cancel();
});
}
dw.on(START_EVENT, '.dwwl', onStart).on(START_EVENT, '.dwb-e', onBtnStart);
}, 300);
event('onShow', [dw, v]);
};
/**
* Hides the scroller instance.
*/
that.hide = function (prevAnim, btn, force) {
// If onClose handler returns false, prevent hide
if (!visible || (!force && event('onClose', [v, btn]) === false)) {
return false;
}
// Re-enable temporary disabled fields
$('.dwtd', doc).each(function () {
$(this).prop('disabled', false).removeClass('dwtd');
if ($(this).data('autocomplete')) {
$(this).attr('autocomplete', $(this).data('autocomplete'));
} else {
$(this).removeAttr('autocomplete');
}
});
// Hide wheels and overlay
if (dw) {
var doAnim = modal && anim && !prevAnim;
if (doAnim) {
dw.addClass('dw-trans').find('.dw').addClass('dw-' + anim + ' dw-out');
}
if (prevAnim) {
dw.remove();
} else {
setTimeout(function () {
dw.remove();
if (activeElm) {
preventShow = true;
activeElm.focus();
}
}, doAnim ? 350 : 1);
}
// Stop positioning on window resize
wndw.off('.dw');
}
delete ms.activeInstance;
pixels = {};
visible = false;
};
/**
* Set button handler.
*/
that.select = function () {
if (that.hide(false, 'set') !== false) {
setVal(true, true, 0, true);
event('onSelect', [that.val]);
}
};
/**
* Show mobiscroll on focus and click event of the parameter.
* @param {jQuery} elm - Events will be attached to this element.
* @param {Function} [beforeShow=undefined] - Optional function to execute before showing mobiscroll.
*/
that.attachShow = function (elm, beforeShow) {
elmList.push(elm);
if (s.display !== 'inline') {
elm.on((s.showOnFocus ? 'focus.dw' : '') + (s.showOnTap ? ' click.dw' : ''), function (ev) {
if ((ev.type !== 'focus' || (ev.type === 'focus' && !preventShow)) && !tap) {
if (beforeShow) {
beforeShow();
}
activeElm = elm;
that.show();
}
setTimeout(function () {
preventShow = false;
}, 300); // With jQuery < 1.9 focus is fired twice in IE
});
}
};
/**
* Cancel and hide the scroller instance.
*/
that.cancel = function () {
if (that.hide(false, 'cancel') !== false) {
event('onCancel', [that.val]);
}
};
/**
* Scroller initialization.
*/
that.init = function (ss) {
// Get theme defaults
theme = ms.themes[ss.theme || s.theme];
// Get language defaults
lang = ms.i18n[ss.lang || s.lang];
extend(settings, ss); // Update original user settings
event('onThemeLoad', [lang, settings]);
extend(s, lang, theme, userdef, settings);
// Add default buttons
s.buttons = s.buttons || ['set', 'cancel'];
// Hide header text in inline mode by default
s.headerText = s.headerText === undefined ? (s.display !== 'inline' ? '{value}' : false) : s.headerText;
that.settings = s;
// Unbind all events (if re-init)
elm.off('.dw');
var preset = ms.presets[s.preset];
if (preset) {
pres = preset.call(e, that);
extend(s, pres, settings); // Load preset settings
}
// Set private members
m = Math.floor(s.rows / 2);
hi = s.height;
anim = s.animate;
modal = s.display !== 'inline';
buttons = s.buttons;
wndw = $(s.context == 'body' ? window : s.context);
doc = $(s.context)[0];
if (!s.setText) {
buttons.splice($.inArray('set', buttons), 1);
}
if (!s.cancelText) {
buttons.splice($.inArray('cancel', buttons), 1);
}
if (s.button3) {
buttons.splice($.inArray('set', buttons) + 1, 0, { text: s.button3Text, handler: s.button3 });
}
that.context = wndw;
that.live = !modal || ($.inArray('set', buttons) == -1);
that.buttons.set = { text: s.setText, css: 'dwb-s', handler: that.select };
that.buttons.cancel = { text: (that.live) ? s.closeText : s.cancelText, css: 'dwb-c', handler: that.cancel };
that.buttons.clear = { text: s.clearText, css: 'dwb-cl', handler: function () {
that.trigger('onClear', [dw]);
elm.val('');
if (!that.live) {
that.hide(false, 'clear');
}
}};
hasButtons = buttons.length > 0;
if (visible) {
that.hide(true, false, true);
}
if (modal) {
read();
if (input) {
// Set element readonly, save original state
if (readOnly === undefined) {
readOnly = e.readOnly;
}
e.readOnly = true;
}
that.attachShow(elm);
} else {
that.show();
}
if (input) {
elm.on('change.dw', function () {
if (!preventChange) {
that.setValue(elm.val(), false, 0.2);
}
preventChange = false;
});
}
};
/**
* Sets one ore more options.
*/
that.option = function (opt, value) {
var obj = {};
if (typeof opt === 'object') {
obj = opt;
} else {
obj[opt] = value;
}
that.init(obj);
};
/**
* Destroys the mobiscroll instance.
*/
that.destroy = function () {
that.hide(true, false, true);
// Remove all events from elements
$.each(elmList, function (i, v) {
v.off('.dw');
});
// Remove events from window
$(window).off('.dwa');
// Reset original readonly state
if (input) {
e.readOnly = readOnly;
}
// Delete scroller instance
delete instances[e.id];
event('onDestroy', []);
};
/**
* Returns the mobiscroll instance.
*/
that.getInst = function () {
return that;
};
/**
* Returns the closest valid cell.
*/
that.getValidCell = getValid;
/**
* Triggers a mobiscroll event.
*/
that.trigger = event;
instances[e.id] = that;
that.values = null;
that.val = null;
that.temp = null;
that.buttons = {};
that._selectedValues = {};
that.init(settings);
}
function setTap() {
tap = true;
setTimeout(function () {
tap = false;
}, 300);
}
function constrain(val, min, max) {
return Math.max(min, Math.min(val, max));
}
function convert(w) {
var ret = {
values: [],
keys: []
};
$.each(w, function (k, v) {
ret.keys.push(k);
ret.values.push(v);
});
return ret;
}
var activeElm,
move,
tap,
preventShow,
ms = $.mobiscroll,
instances = ms.instances,
util = ms.util,
prefix = util.prefix,
pr = util.jsPrefix,
has3d = util.has3d,
getCoord = util.getCoord,
testTouch = util.testTouch,
empty = function () {},
prevdef = function (e) { e.preventDefault(); },
extend = $.extend,
START_EVENT = 'touchstart mousedown',
MOVE_EVENT = 'touchmove mousemove',
END_EVENT = 'touchend mouseup',
userdef = ms.userdef,
defaults = extend(ms.defaults, {
// Options
width: 70,
height: 40,
rows: 3,
delay: 300,
disabled: false,
readonly: false,
closeOnOverlay: true,
showOnFocus: true,
showOnTap: true,
showLabel: true,
wheels: [],
theme: '',
display: 'modal',
mode: 'scroller',
preset: '',
lang: 'en-US',
context: 'body',
scrollLock: true,
tap: true,
btnWidth: true,
speedUnit: 0.0012,
timeUnit: 0.1,
formatResult: function (d) {
return d.join(' ');
},
parseValue: function (value, inst) {
var val = value.split(' '),
ret = [],
i = 0,
keys;
$.each(inst.settings.wheels, function (j, wg) {
$.each(wg, function (k, w) {
w = w.values ? w : convert(w);
keys = w.keys || w.values;
if ($.inArray(val[i], keys) !== -1) {
ret.push(val[i]);
} else {
ret.push(keys[0]);
}
i++;
});
});
return ret;
}
});
// English language module
ms.i18n.en = ms.i18n['en-US'] = {
setText: 'Set',
selectedText: 'Selected',
closeText: 'Close',
cancelText: 'Cancel',
clearText: 'Clear'
};
// Prevent re-show on window focus
$(window).on('focus', function () {
if (activeElm) {
preventShow = true;
}
});
$(document).on('mouseover mouseup mousedown click', function (e) { // Prevent standard behaviour on body click
if (tap) {
e.stopPropagation();
e.preventDefault();
return false;
}
});
})(jQuery);
;
/*jslint eqeq: true, plusplus: true, undef: true, sloppy: true, vars: true, forin: true */
(function ($) {
var ms = $.mobiscroll,
date = new Date(),
defaults = {
startYear: date.getFullYear() - 100,
endYear: date.getFullYear() + 1,
shortYearCutoff: '+10',
showNow: false,
stepHour: 1,
stepMinute: 1,
stepSecond: 1,
separator: ' ',
ampmText: ' '
},
/**
* @class Mobiscroll.datetime
* @extends Mobiscroll
* Mobiscroll Datetime component
*/
preset = function (inst) {
var that = $(this),
html5def = {},
format;
// Force format for html5 date inputs (experimental)
if (that.is('input')) {
switch (that.attr('type')) {
case 'date':
format = 'yy-mm-dd';
break;
case 'datetime':
format = 'yy-mm-ddTHH:ii:ssZ';
break;
case 'datetime-local':
format = 'yy-mm-ddTHH:ii:ss';
break;
case 'month':
format = 'yy-mm';
html5def.dateOrder = 'mmyy';
break;
case 'time':
format = 'HH:ii:ss';
break;
}
// Check for min/max attributes
var min = that.attr('min'),
max = that.attr('max');
if (min) {
html5def.minDate = ms.parseDate(format, min);
}
if (max) {
html5def.maxDate = ms.parseDate(format, max);
}
}
// Set year-month-day order
var i,
k,
keys,
values,
wg,
start,
end,
invalid,
hasTime,
orig = $.extend({}, inst.settings),
s = $.extend(inst.settings, defaults, html5def, orig),
offset = 0,
wheels = [],
ord = [],
o = {},
f = { y: 'getFullYear', m: 'getMonth', d: 'getDate', h: getHour, i: getMinute, s: getSecond, a: getAmPm },
p = s.preset,
dord = s.dateOrder,
tord = s.timeWheels,
regen = dord.match(/D/),
ampm = tord.match(/a/i),
hampm = tord.match(/h/),
hformat = p == 'datetime' ? s.dateFormat + s.separator + s.timeFormat : p == 'time' ? s.timeFormat : s.dateFormat,
defd = new Date(),
stepH = s.stepHour,
stepM = s.stepMinute,
stepS = s.stepSecond,
mind = s.minDate || new Date(s.startYear, 0, 1),
maxd = s.maxDate || new Date(s.endYear, 11, 31, 23, 59, 59);
format = format || hformat;
if (p.match(/date/i)) {
// Determine the order of year, month, day wheels
$.each(['y', 'm', 'd'], function (j, v) {
i = dord.search(new RegExp(v, 'i'));
if (i > -1) {
ord.push({ o: i, v: v });
}
});
ord.sort(function (a, b) { return a.o > b.o ? 1 : -1; });
$.each(ord, function (i, v) {
o[v.v] = i;
});
wg = [];
for (k = 0; k < 3; k++) {
if (k == o.y) {
offset++;
values = [];
keys = [];
start = mind.getFullYear();
end = maxd.getFullYear();
for (i = start; i <= end; i++) {
keys.push(i);
values.push(dord.match(/yy/i) ? i : (i + '').substr(2, 2));
}
addWheel(wg, keys, values, s.yearText);
} else if (k == o.m) {
offset++;
values = [];
keys = [];
for (i = 0; i < 12; i++) {
var str = dord.replace(/[dy]/gi, '').replace(/mm/, i < 9 ? '0' + (i + 1) : i + 1).replace(/m/, (i + 1));
keys.push(i);
values.push(str.match(/MM/) ? str.replace(/MM/, '
' + s.monthNames[i] + '') : str.replace(/M/, '
' + s.monthNamesShort[i] + ''));
}
addWheel(wg, keys, values, s.monthText);
} else if (k == o.d) {
offset++;
values = [];
keys = [];
for (i = 1; i < 32; i++) {
keys.push(i);
values.push(dord.match(/dd/i) && i < 10 ? '0' + i : i);
}
addWheel(wg, keys, values, s.dayText);
}
}
wheels.push(wg);
}
if (p.match(/time/i)) {
hasTime = true;
// Determine the order of hours, minutes, seconds wheels
ord = [];
$.each(['h', 'i', 's', 'a'], function (i, v) {
i = tord.search(new RegExp(v, 'i'));
if (i > -1) {
ord.push({ o: i, v: v });
}
});
ord.sort(function (a, b) {
return a.o > b.o ? 1 : -1;
});
$.each(ord, function (i, v) {
o[v.v] = offset + i;
});
wg = [];
for (k = offset; k < offset + 4; k++) {
if (k == o.h) {
offset++;
values = [];
keys = [];
for (i = 0; i < (hampm ? 12 : 24); i += stepH) {
keys.push(i);
values.push(hampm && i == 0 ? 12 : tord.match(/hh/i) && i < 10 ? '0' + i : i);
}
addWheel(wg, keys, values, s.hourText);
} else if (k == o.i) {
offset++;
values = [];
keys = [];
for (i = 0; i < 60; i += stepM) {
keys.push(i);
values.push(tord.match(/ii/) && i < 10 ? '0' + i : i);
}
addWheel(wg, keys, values, s.minuteText);
} else if (k == o.s) {
offset++;
values = [];
keys = [];
for (i = 0; i < 60; i += stepS) {
keys.push(i);
values.push(tord.match(/ss/) && i < 10 ? '0' + i : i);
}
addWheel(wg, keys, values, s.secText);
} else if (k == o.a) {
offset++;
var upper = tord.match(/A/);
addWheel(wg, [0, 1], upper ? [s.amText.toUpperCase(), s.pmText.toUpperCase()] : [s.amText, s.pmText], s.ampmText);
}
}
wheels.push(wg);
}
function get(d, i, def) {
if (o[i] !== undefined) {
return +d[o[i]];
}
if (def !== undefined) {
return def;
}
return defd[f[i]] ? defd[f[i]]() : f[i](defd);
}
function addWheel(wg, k, v, lbl) {
wg.push({
values: v,
keys: k,
label: lbl
});
}
function step(v, st) {
return Math.floor(v / st) * st;
}
function getHour(d) {
var hour = d.getHours();
hour = hampm && hour >= 12 ? hour - 12 : hour;
return step(hour, stepH);
}
function getMinute(d) {
return step(d.getMinutes(), stepM);
}
function getSecond(d) {
return step(d.getSeconds(), stepS);
}
function getAmPm(d) {
return ampm && d.getHours() > 11 ? 1 : 0;
}
function getDate(d) {
var hour = get(d, 'h', 0);
return new Date(get(d, 'y'), get(d, 'm'), get(d, 'd', 1), get(d, 'a', 0) ? hour + 12 : hour, get(d, 'i', 0), get(d, 's', 0));
}
function getIndex(t, v) {
return $('.dw-li', t).index($('.dw-li[data-val="' + v + '"]', t));
}
function getValidIndex(t, v, max, add) {
if (v < 0) {
return 0;
}
if (v > max) {
return $('.dw-li', t).length;
}
return getIndex(t, v) + add;
}
// Extended methods
// ---
/**
* Sets the selected date
*
* @param {Date} d Date to select.
* @param {Boolean} [fill=false] Also set the value of the associated input element. Default is true.
* @param {Number} [time=0] Animation time to scroll to the selected date.
* @param {Boolean} [temp=false] Set temporary value only.
* @param {Boolean} [change=fill] Trigger change on input element.
*/
inst.setDate = function (d, fill, time, temp, change) {
var i;
// Set wheels
for (i in o) {
inst.temp[o[i]] = d[f[i]] ? d[f[i]]() : f[i](d);
}
inst.setValue(inst.temp, fill, time, temp, change);
};
/**
* Returns the currently selected date.
*
* @param {Boolean} [temp=false] If true, return the currently shown date on the picker, otherwise the last selected one.
* @return {Date}
*/
inst.getDate = function (temp) {
return getDate(temp ? inst.temp : inst.values);
};
inst.convert = function (obj) {
var x = obj;
if (!$.isArray(obj)) { // Convert from old format
x = [];
$.each(obj, function (i, o) {
$.each(o, function (j, o) {
if (i === 'daysOfWeek') {
if (o.d) {
o.d = 'w' + o.d;
} else {
o = 'w' + o;
}
}
x.push(o);
});
});
}
return x;
};
inst.format = hformat;
inst.buttons.now = { text: s.nowText, css: 'dwb-n', handler: function () { inst.setDate(new Date(), false, 0.3, true, true); } };
if (s.showNow) {
s.buttons.splice($.inArray('set', s.buttons) + 1, 0, 'now');
}
invalid = s.invalid ? inst.convert(s.invalid) : false;
// ---
return {
wheels: wheels,
headerText: s.headerText ? function (v) {
return ms.formatDate(hformat, getDate(inst.temp), s);
} : false,
formatResult: function (d) {
return ms.formatDate(format, getDate(d), s);
},
parseValue: function (val) {
var d = ms.parseDate(format, val, s),
i,
result = [];
// Set wheels
for (i in o) {
result[o[i]] = d[f[i]] ? d[f[i]]() : f[i](d);
}
return result;
},
validate: function (dw, i, time, dir) {
var temp = inst.temp, //.slice(0),
mins = { y: mind.getFullYear(), m: 0, d: 1, h: 0, i: 0, s: 0, a: 0 },
maxs = { y: maxd.getFullYear(), m: 11, d: 31, h: step(hampm ? 11 : 23, stepH), i: step(59, stepM), s: step(59, stepS), a: 1 },
steps = { h: stepH, i: stepM, s: stepS, a: 1 },
y = get(temp, 'y'),
m = get(temp, 'm'),
minprop = true,
maxprop = true;
$.each(['y', 'm', 'd', 'a', 'h', 'i', 's'], function (x, i) {
if (o[i] !== undefined) {
var min = mins[i],
max = maxs[i],
maxdays = 31,
val = get(temp, i),
t = $('.dw-ul', dw).eq(o[i]);
if (i == 'd') {
maxdays = 32 - new Date(y, m, 32).getDate();
max = maxdays;
if (regen) {
$('.dw-li', t).each(function () {
var that = $(this),
d = that.data('val'),
w = new Date(y, m, d).getDay(),
str = dord.replace(/[my]/gi, '').replace(/dd/, d < 10 ? '0' + d : d).replace(/d/, d);
$('.dw-i', that).html(str.match(/DD/) ? str.replace(/DD/, '
' + s.dayNames[w] + '') : str.replace(/D/, '
' + s.dayNamesShort[w] + ''));
});
}
}
if (minprop && mind) {
min = mind[f[i]] ? mind[f[i]]() : f[i](mind);
}
if (maxprop && maxd) {
max = maxd[f[i]] ? maxd[f[i]]() : f[i](maxd);
}
if (i != 'y') {
var i1 = getIndex(t, min),
i2 = getIndex(t, max);
$('.dw-li', t).removeClass('dw-v').slice(i1, i2 + 1).addClass('dw-v');
if (i == 'd') { // Hide days not in month
$('.dw-li', t).removeClass('dw-h').slice(maxdays).addClass('dw-h');
}
}
if (val < min) {
val = min;
}
if (val > max) {
val = max;
}
if (minprop) {
minprop = val == min;
}
if (maxprop) {
maxprop = val == max;
}
// Disable some days
if (invalid && i == 'd') {
var d, j, k, v,
first = new Date(y, m, 1).getDay(),
idx = [];
for (j = 0; j < invalid.length; j++) {
d = invalid[j];
v = d + '';
if (!d.start) {
if (d.getTime) { // Exact date
if (d.getFullYear() == y && d.getMonth() == m) {
idx.push(d.getDate() - 1);
}
} else if (!v.match(/w/i)) { // Day of month
v = v.split('/');
if (v[1]) {
if (v[0] - 1 == m) {
idx.push(v[1] - 1);
}
} else {
idx.push(v[0] - 1);
}
} else { // Day of week
v = +v.replace('w', '');
for (k = v - first; k < maxdays; k += 7) {
if (k >= 0) {
idx.push(k);
}
}
}
}
}
$.each(idx, function (i, v) {
$('.dw-li', t).eq(v).removeClass('dw-v');
});
val = inst.getValidCell(val, t, dir).val;
}
// Set modified value
temp[o[i]] = val;
}
});
// Invalid times
if (hasTime && invalid) {
var dd, v, val, str, parts1, parts2, j, v1, v2, i1, i2, prop1, prop2, target, add, remove,
spec = {},
d = get(temp, 'd'),
day = new Date(y, m, d),
w = ['a', 'h', 'i', 's'];
$.each(invalid, function (i, obj) {
if (obj.start) {
obj.apply = false;
dd = obj.d;
v = dd + '';
str = v.split('/');
if (dd && ((dd.getTime && y == dd.getFullYear() && m == dd.getMonth() && d == dd.getDate()) || // Exact date
(!v.match(/w/i) && ((str[1] && d == str[1] && m == str[0] - 1) || (!str[1] && d == str[0]))) || // Day of month
(v.match(/w/i) && day.getDay() == +v.replace('w', '')) // Day of week
)) {
obj.apply = true;
spec[day] = true; // Prevent applying generic rule on day, if specific exists
}
}
});
$.each(invalid, function (i, obj) {
if (obj.start && (obj.apply || (!obj.d && !spec[day]))) {
parts1 = obj.start.split(':');
parts2 = obj.end.split(':');
for (j = 0; j < 3; j++) {
if (parts1[j] === undefined) {
parts1[j] = 0;
}
if (parts2[j] === undefined) {
parts2[j] = 59;
}
parts1[j] = +parts1[j];
parts2[j] = +parts2[j];
}
parts1.unshift(parts1[0] > 11 ? 1 : 0);
parts2.unshift(parts2[0] > 11 ? 1 : 0);
if (hampm) {
if (parts1[1] >= 12) {
parts1[1] = parts1[1] - 12;
}
if (parts2[1] >= 12) {
parts2[1] = parts2[1] - 12;
}
}
prop1 = true;
prop2 = true;
$.each(w, function (i, v) {
if (o[v] !== undefined) {
val = get(temp, v);
add = 0;
remove = 0;
i1 = 0;
i2 = undefined;
target = $('.dw-ul', dw).eq(o[v]);
// Look ahead if next wheels should be disabled completely
for (j = i + 1; j < 4; j++) {
if (parts1[j] > 0) {
add = steps[v];
}
if (parts2[j] < maxs[w[j]]) {
remove = steps[v];
}
}
// Calculate min and max values
v1 = step(parts1[i] + add, steps[v]);
v2 = step(parts2[i] - remove, steps[v]);
if (prop1) {
i1 = getValidIndex(target, v1, maxs[v], 0);
}
if (prop2) {
i2 = getValidIndex(target, v2, maxs[v], 1);
}
// Disable values
if (prop1 || prop2) {
$('.dw-li', target).slice(i1, i2).removeClass('dw-v');
}
// Get valid value
val = inst.getValidCell(val, target, dir).val;
prop1 = prop1 && val == step(parts1[i], steps[v]);
prop2 = prop2 && val == step(parts2[i], steps[v]);
// Set modified value
temp[o[v]] = val;
}
});
}
});
}
}
};
};
ms.i18n.en = $.extend(ms.i18n.en, {
dateFormat: 'mm/dd/yy',
dateOrder: 'mmddy',
timeWheels: 'hhiiA',
timeFormat: 'hh:ii A',
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
monthText: 'Month',
dayText: 'Day',
yearText: 'Year',
hourText: 'Hours',
minuteText: 'Minutes',
secText: 'Seconds',
amText: 'am',
pmText: 'pm',
nowText: 'Now'
});
$.each(['date', 'time', 'datetime'], function (i, v) {
ms.presets[v] = preset;
ms.presetShort(v);
});
/**
* Format a date into a string value with a specified format.
* @param {String} format Output format.
* @param {Date} date Date to format.
* @param {Object} [settings={}] Settings.
* @return {String} Returns the formatted date string.
*/
ms.formatDate = function (format, date, settings) {
if (!date) {
return null;
}
var s = $.extend({}, defaults, settings),
look = function (m) { // Check whether a format character is doubled
var n = 0;
while (i + 1 < format.length && format.charAt(i + 1) == m) {
n++;
i++;
}
return n;
},
f1 = function (m, val, len) { // Format a number, with leading zero if necessary
var n = '' + val;
if (look(m)) {
while (n.length < len) {
n = '0' + n;
}
}
return n;
},
f2 = function (m, val, s, l) { // Format a name, short or long as requested
return (look(m) ? l[val] : s[val]);
},
i,
output = '',
literal = false;
for (i = 0; i < format.length; i++) {
if (literal) {
if (format.charAt(i) == "'" && !look("'")) {
literal = false;
} else {
output += format.charAt(i);
}
} else {
switch (format.charAt(i)) {
case 'd':
output += f1('d', date.getDate(), 2);
break;
case 'D':
output += f2('D', date.getDay(), s.dayNamesShort, s.dayNames);
break;
case 'o':
output += f1('o', (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
break;
case 'm':
output += f1('m', date.getMonth() + 1, 2);
break;
case 'M':
output += f2('M', date.getMonth(), s.monthNamesShort, s.monthNames);
break;
case 'y':
output += (look('y') ? date.getFullYear() : (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
break;
case 'h':
var h = date.getHours();
output += f1('h', (h > 12 ? (h - 12) : (h == 0 ? 12 : h)), 2);
break;
case 'H':
output += f1('H', date.getHours(), 2);
break;
case 'i':
output += f1('i', date.getMinutes(), 2);
break;
case 's':
output += f1('s', date.getSeconds(), 2);
break;
case 'a':
output += date.getHours() > 11 ? s.pmText : s.amText;
break;
case 'A':
output += date.getHours() > 11 ? s.pmText.toUpperCase() : s.amText.toUpperCase();
break;
case "'":
if (look("'")) {
output += "'";
} else {
literal = true;
}
break;
default:
output += format.charAt(i);
}
}
}
return output;
};
/**
* Extract a date from a string value with a specified format.
* @param {String} format Input format.
* @param {String} value String to parse.
* @param {Object} [settings={}] Settings.
* @return {Date} Returns the extracted date.
*/
ms.parseDate = function (format, value, settings) {
var s = $.extend({}, defaults, settings),
def = s.defaultValue || new Date();
if (!format || !value) {
return def;
}
value = (typeof value == 'object' ? value.toString() : value + '');
var shortYearCutoff = s.shortYearCutoff,
year = def.getFullYear(),
month = def.getMonth() + 1,
day = def.getDate(),
doy = -1,
hours = def.getHours(),
minutes = def.getMinutes(),
seconds = 0, //def.getSeconds(),
ampm = -1,
literal = false, // Check whether a format character is doubled
lookAhead = function (match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
if (matches) {
iFormat++;
}
return matches;
},
getNumber = function (match) { // Extract a number from the string value
lookAhead(match);
var size = (match == '@' ? 14 : (match == '!' ? 20 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)))),
digits = new RegExp('^\\d{1,' + size + '}'),
num = value.substr(iValue).match(digits);
if (!num) {
return 0;
}
iValue += num[0].length;
return parseInt(num[0], 10);
},
getName = function (match, s, l) { // Extract a name from the string value and convert to an index
var names = (lookAhead(match) ? l : s),
i;
for (i = 0; i < names.length; i++) {
if (value.substr(iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) {
iValue += names[i].length;
return i + 1;
}
}
return 0;
},
checkLiteral = function () {
iValue++;
},
iValue = 0,
iFormat;
for (iFormat = 0; iFormat < format.length; iFormat++) {
if (literal) {
if (format.charAt(iFormat) == "'" && !lookAhead("'")) {
literal = false;
} else {
checkLiteral();
}
} else {
switch (format.charAt(iFormat)) {
case 'd':
day = getNumber('d');
break;
case 'D':
getName('D', s.dayNamesShort, s.dayNames);
break;
case 'o':
doy = getNumber('o');
break;
case 'm':
month = getNumber('m');
break;
case 'M':
month = getName('M', s.monthNamesShort, s.monthNames);
break;
case 'y':
year = getNumber('y');
break;
case 'H':
hours = getNumber('H');
break;
case 'h':
hours = getNumber('h');
break;
case 'i':
minutes = getNumber('i');
break;
case 's':
seconds = getNumber('s');
break;
case 'a':
ampm = getName('a', [s.amText, s.pmText], [s.amText, s.pmText]) - 1;
break;
case 'A':
ampm = getName('A', [s.amText, s.pmText], [s.amText, s.pmText]) - 1;
break;
case "'":
if (lookAhead("'")) {
checkLiteral();
} else {
literal = true;
}
break;
default:
checkLiteral();
}
}
}
if (year < 100) {
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
(year <= (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)) ? 0 : -100);
}
if (doy > -1) {
month = 1;
day = doy;
do {
var dim = 32 - new Date(year, month - 1, 32).getDate();
if (day <= dim) {
break;
}
month++;
day -= dim;
} while (true);
}
hours = (ampm == -1) ? hours : ((ampm && hours < 12) ? (hours + 12) : (!ampm && hours == 12 ? 0 : hours));
var date = new Date(year, month - 1, day, hours, minutes, seconds);
if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) {
return def; // Invalid date
}
return date;
};
})(jQuery);
;
/*jslint eqeq: true, plusplus: true, undef: true, sloppy: true, vars: true, forin: true */
(function ($) {
var defaults = {
inputClass: '',
invalid: [],
rtl: false,
showInput: true,
group: false,
groupLabel: 'Groups'
};
$.mobiscroll.presetShort('select');
$.mobiscroll.presets.select = function (inst) {
var orig = $.extend({}, inst.settings),
s = $.extend(inst.settings, defaults, orig),
elm = $(this),
multiple = elm.prop('multiple'),
id = this.id + '_dummy',
option = multiple ? (elm.val() ? elm.val()[0] : $('option', elm).attr('value')) : elm.val(),
group = elm.find('option[value="' + option + '"]').parent(),
prev = group.index() + '',
gr = prev,
prevent,
l1 = $('label[for="' + this.id + '"]').attr('for', id),
l2 = $('label[for="' + id + '"]'),
label = s.label !== undefined ? s.label : (l2.length ? l2.text() : elm.attr('name')),
invalid = [],
origValues = [],
main = {},
grIdx,
optIdx,
timer,
input,
roPre = s.readonly,
w;
function genWheels() {
var cont,
wg = 0,
values = [],
keys = [],
w = [[]];
if (s.group) {
if (s.rtl) {
wg = 1;
}
$('optgroup', elm).each(function (i) {
values.push($(this).attr('label'));
keys.push(i);
});
w[wg] = [{
values: values,
keys: keys,
label: s.groupLabel
}];
cont = group;
wg += (s.rtl ? -1 : 1);
} else {
cont = elm;
}
values = [];
keys = [];
$('option', cont).each(function () {
var v = $(this).attr('value');
values.push($(this).text());
keys.push(v);
if ($(this).prop('disabled')) {
invalid.push(v);
}
});
w[wg] = [{
values: values,
keys: keys,
label: label
}];
return w;
}
function setVal(v, fill, change) {
var value = [];
if (multiple) {
var sel = [],
i = 0;
for (i in inst._selectedValues) {
sel.push(main[i]);
value.push(i);
}
input.val(sel.join(', '));
} else {
input.val(v);
value = fill ? inst.values[optIdx] : null;
}
if (fill) {
elm.val(value);
if (change) {
prevent = true;
elm.change();
}
}
}
function onTap(li) {
if (multiple && li.hasClass('dw-v') && li.closest('.dw').find('.dw-ul').index(li.closest('.dw-ul')) == optIdx) {
var val = li.attr('data-val'),
selected = li.hasClass('dw-msel');
if (selected) {
li.removeClass('dw-msel').removeAttr('aria-selected');
delete inst._selectedValues[val];
} else {
li.addClass('dw-msel').attr('aria-selected', 'true');
inst._selectedValues[val] = val;
}
if (inst.live) {
setVal(val, true, true);
}
return false;
}
}
// if groups is true and there are no groups fall back to no grouping
if (s.group && !$('optgroup', elm).length) {
s.group = false;
}
if (!s.invalid.length) {
s.invalid = invalid;
}
if (s.group) {
if (s.rtl) {
grIdx = 1;
optIdx = 0;
} else {
grIdx = 0;
optIdx = 1;
}
} else {
grIdx = -1;
optIdx = 0;
}
$('#' + id).remove();
input = $('
');
if (s.showInput) {
input.insertBefore(elm);
}
$('option', elm).each(function () {
main[$(this).attr('value')] = $(this).text();
});
inst.attachShow(input);
var v = elm.val() || [],
i = 0;
for (i; i < v.length; i++) {
inst._selectedValues[v[i]] = v[i];
}
setVal(main[option]);
elm.off('.dwsel').on('change.dwsel', function () {
if (!prevent) {
inst.setValue(multiple ? elm.val() || [] : [elm.val()], true);
}
prevent = false;
}).addClass('dw-hsel').attr('tabindex', -1).closest('.ui-field-contain').trigger('create');
// Extended methods
// ---
if (!inst._setValue) {
inst._setValue = inst.setValue;
}
inst.setValue = function (d, fill, time, temp, change) {
var value,
v = $.isArray(d) ? d[0] : d;
option = v !== undefined ? v : $('option', elm).attr('value');
if (multiple) {
inst._selectedValues = {};
var i = 0;
for (i; i < d.length; i++) {
inst._selectedValues[d[i]] = d[i];
}
}
if (s.group) {
group = elm.find('option[value="' + option + '"]').parent();
gr = group.index();
value = s.rtl ? [option, group.index()] : [group.index(), option];
if (gr !== prev) { // Need to regenerate wheels, if group changed
s.wheels = genWheels();
inst.changeWheel([optIdx]);
prev = gr + '';
}
} else {
value = [option];
}
inst._setValue(value, fill, time, temp, change);
// Set input/select values
if (fill) {
var changed = multiple ? true : option !== elm.val();
setVal(main[option], changed, change);
}
};
inst.getValue = function (temp) {
var val = temp ? inst.temp : inst.values;
return val[optIdx];
};
// ---
return {
width: 50,
wheels: w,
headerText: false,
multiple: multiple,
anchor: input,
formatResult: function (d) {
return main[d[optIdx]];
},
parseValue: function () {
var v = elm.val() || [],
i = 0;
if (multiple) {
inst._selectedValues = {};
for (i; i < v.length; i++) {
inst._selectedValues[v[i]] = v[i];
}
}
option = multiple ? (elm.val() ? elm.val()[0] : $('option', elm).attr('value')) : elm.val();
group = elm.find('option[value="' + option + '"]').parent();
gr = group.index();
prev = gr + '';
return s.group && s.rtl ? [option, gr] : s.group ? [gr, option] : [option];
},
validate: function (dw, i, time) {
if (i === undefined && multiple) {
var v = inst._selectedValues,
j = 0;
$('.dwwl' + optIdx + ' .dw-li', dw).removeClass('dw-msel').removeAttr('aria-selected');
for (j in v) {
$('.dwwl' + optIdx + ' .dw-li[data-val="' + v[j] + '"]', dw).addClass('dw-msel').attr('aria-selected', 'true');
}
}
if (i === grIdx) {
gr = inst.temp[grIdx];
if (gr !== prev) {
group = elm.find('optgroup').eq(gr);
gr = group.index();
option = group.find('option').eq(0).val();
option = option || elm.val();
s.wheels = genWheels();
if (s.group) {
inst.temp = s.rtl ? [option, gr] : [gr, option];
s.readonly = [s.rtl, !s.rtl];
clearTimeout(timer);
timer = setTimeout(function () {
inst.changeWheel([optIdx], undefined, true);
s.readonly = roPre;
prev = gr + '';
}, time * 1000);
return false;
}
} else {
s.readonly = roPre;
}
} else {
option = inst.temp[optIdx];
}
var t = $('.dw-ul', dw).eq(optIdx);
$.each(s.invalid, function (i, v) {
$('.dw-li[data-val="' + v + '"]', t).removeClass('dw-v');
});
},
onBeforeShow: function (dw) {
if (multiple && s.counter) {
s.headerText = function () {
var length = 0;
$.each(inst._selectedValues, function () {
length++;
});
return length + " " + s.selectedText;
};
}
s.wheels = genWheels();
if (s.group) {
inst.temp = s.rtl ? [option, group.index()] : [group.index(), option];
}
},
onClear: function (dw) {
inst._selectedValues = {};
input.val('');
$('.dwwl' + optIdx + ' .dw-li', dw).removeClass('dw-msel').removeAttr('aria-selected');
},
onMarkupReady: function (dw) {
dw.addClass('dw-select');
$('.dwwl' + grIdx, dw).on('mousedown touchstart', function () {
clearTimeout(timer);
});
if (multiple) {
dw.addClass('dwms');
$('.dwwl', dw).eq(optIdx).addClass('dwwms').attr('aria-multiselectable', 'true');
$('.dwwl', dw).on('keydown', function (e) {
if (e.keyCode == 32) { // Space
e.preventDefault();
e.stopPropagation();
onTap($('.dw-sel', this));
}
});
origValues = $.extend({}, inst._selectedValues);
}
},
onValueTap: onTap,
onSelect: function (v) {
setVal(v, true, true);
if (s.group) {
inst.values = null;
}
},
onCancel: function () {
if (s.group) {
inst.values = null;
}
if (!inst.live && multiple) {
inst._selectedValues = $.extend({}, origValues);
}
},
onChange: function (v) {
if (inst.live && !multiple) {
input.val(v);
prevent = true;
elm.val(inst.temp[optIdx]).change();
}
},
onDestroy: function () {
input.remove();
elm.removeClass('dw-hsel').removeAttr('tabindex');
}
};
};
})(jQuery);
;
(function ($) {
$.mobiscroll.themes.jqm = {
jqmBorder: 'a',
jqmBody: 'c',
jqmHeader: 'b',
jqmWheel: 'd',
jqmClickPick: 'c',
jqmSet: 'b',
jqmCancel: 'c',
disabledClass: 'ui-disabled',
activeClass: 'ui-btn-active',
activeTabInnerClass: 'ui-btn-active',
onThemeLoad: function (lang, s) {
var cal = s.jqmBody || 'c',
txt = s.jqmEventText || 'b',
bubble = s.jqmEventBubble || 'a';
s.dayClass = 'ui-body-a ui-body-' + cal;
s.validDayClass = 'ui-state-default ui-btn ui-btn-up-' + cal;
s.calendarClass = 'ui-body-a ui-body-' + cal;
s.weekNrClass = 'ui-body-a ui-body-' + cal;
s.eventTextClass = 'ui-btn-up-' + txt;
s.eventBubbleClass = 'ui-body-' + bubble;
},
onEventBubbleShow: function (evd, evc) {
$('.dw-cal-event-list', evc).attr('data-role', 'listview');
evc.page().trigger('create');
},
onMarkupInserted: function (elm, inst) {
var s = inst.settings;
$('.dw', elm).removeClass('dwbg').addClass('ui-selectmenu ui-overlay-shadow ui-corner-all ui-body-' + s.jqmBorder);
$('.dwbc .dwb', elm).attr('data-role', 'button').attr('data-mini', 'true').attr('data-theme', s.jqmCancel);
$('.dwb-s .dwb', elm).attr('data-theme', s.jqmSet);
$('.dwwb', elm).attr('data-role', 'button').attr('data-theme', s.jqmClickPick);
$('.dwv', elm).addClass('ui-header ui-bar-' + s.jqmHeader);
$('.dwwr', elm).addClass('ui-body-' + s.jqmBody);
$('.dwpm .dwwl', elm).addClass('ui-body-' + s.jqmWheel);
$('.dwpm .dwl', elm).addClass('ui-body-' + s.jqmBody);
// Calendar base
$('.dw-cal-tabs', elm).attr('data-role', 'navbar');
$('.dw-cal-prev .dw-cal-btn-txt', elm).attr('data-role', 'button').attr('data-icon', 'arrow-l').attr('data-iconpos', 'notext');
$('.dw-cal-next .dw-cal-btn-txt', elm).attr('data-role', 'button').attr('data-icon', 'arrow-r').attr('data-iconpos', 'notext');
// Calendar events
$('.dw-cal-events', elm).attr('data-role', 'page');
// Rangepicker
$('.dw-dr', elm).attr('data-role', 'button').attr('data-mini', 'true');
elm.trigger('create');
}
};
})(jQuery);
;
//get a reference error in safair if we don't create this version global variable
var pageID, version;
//has to be declared or we recieve and error in loadCKEditor()
var CKEDITOR_BASEPATH = '/ckeditor/';
//don't always want/need jquery collections
$s = function(id){return document.getElementById(id);}
$$s = function(cName){if(document.getElementsByClassName) return document.getElementsByClassName(cName);}
$$$s = function(eName){return document.getElementsByName(eName);}
//Return an SHA256 digest of a string object
String.prototype.sha256 = function(){
return sha256_digest(this.salt+this);
}
if( /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
var isMobile = true;
}
else {
var isMobile = false;
}
$.validator.setDefaults({//set defaults on jquery form validation
onkeyup:false, onclick:false, onfocusout:false, //only check when we 'submit' form
focusCleanup: false, //Don't remove classes when we select a field
focusInvalid: true, //Autofocus on first invalid field
errorClass: "invalid", //invalid css class
validClass: "valid", // valid css class
errorPlacement: function(){},
ignoreTitle:true,
highlight: function(element, errorClass, validClass) { // Add error classes for styling
$(element).addClass(errorClass).removeClass(validClass);
var tempLabel = $(element.form).find("label[for='" + $(element).attr('name') + "']");
if(tempLabel && tempLabel.length > 0) {
tempLabel.addClass(errorClass + "Label");
}
},
unhighlight: function(element, errorClass, validClass) { // Remove error classes
var tempLabel = $(element.form).find("label[for='" + $(element).attr('name') + "']");
if(tempLabel && tempLabel.length > 0) {
tempLabel.removeClass(errorClass + "Label");
}
$(element).removeClass(errorClass).addClass(validClass);
},
showErrors: function(errorMap, errorList) { //display error messages in a modal dialog
var formErrMsg = "\n\t\t
There were errors with your form. Please make sure you have filled in all required fields with the proper info.\n\t\t
Click anywhere to hide this message\n\t\t
\n\t\t\t
";
var formErrs = "";
$.each(errorMap,function(index,value) {
//get the ID of the element
var tempID = $$$s(index)[0].id;
//error field description comes from label
if(
typeof tempID !== "undefined" && tempID.length > 0 &&
$("label[for='"+tempID+"']") && $("label[for='"+tempID+"']").length > 0
){
var field = $("label[for='"+tempID+"']").html();
}
//error field description comes from title
else if($("[name='" + index + "']").attr("title")){
var field =$("[name='" + index + "']").attr("title");
}
//error field description comes from input name
else{
var tempName = $("[name='"+index+"']").attr("name");
if(tempName){
var field = $("[name='"+index+"']").attr("name").split(" ")[0];
}
else{
var field = "";
}
}
formErrs += "\n\t\t\t\t- " + field + "" + value + "
";
});
formErrMsg += formErrs + "\n\t\t\t
\n\t\t
";
if(formErrs.length){ //If we have errors!
buildModal("formError-"+this.currentForm.id,formErrMsg,null,true,true,1,null,null,440) //Display a modal dialog
}
this.defaultShowErrors(); //Apply the label classes, etc.
},
messages:{
required: "This field is required.",
remote: "Please fix this field.",
email: "Please enter a valid email address.",
url: "Please enter a valid URL.",
phoneUS: "Please enter a valid phone number.",
date: "Please enter a valid date.",
dateISO: "Please enter a valid date (ISO).",
number: "Please enter a valid number.",
digits: "Please enter only digits.",
creditcard: "Please enter a valid credit card number.",
equalTo: "Please enter the same value again.",
accept: "Please enter a value with a valid extension.",
maxlength: $.validator.format("Please enter no more than {0} characters."),
minlength: $.validator.format("Please enter at least {0} characters."),
rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
range: $.validator.format("Please enter a value between {0} and {1}."),
max: $.validator.format("Please enter a value less than or equal to {0}."),
min: $.validator.format("Please enter a value greater than or equal to {0}.")
},
ignore: []
});
//valid time
$.validator.addMethod(
"time",
function(value, element) {
return this.optional(element) || /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?([\s]?[AaPp][Mm])?$/i.test(value);
},
"Please enter a time in the format HH:MM. AM/PM is optional."
);
//doesn't accept field defaults as valid input
$.validator.addMethod("defaultInvalid", function(value, element) {
return !(element.value == element.defaultValue);
},
"This field is required."
);
/* Function: buildModal
/ Purpose: displays a modal dialog
/ id: id for the dialog (for styling!)
/ inner: the content to be displayed
/ parent: the parent element to display it over
/ fullScreen: whether or not it should take up the full browser window
/ fixed: positioning, false = absolute, useful for when displaying over a smaller element and requires regular flow, true = fixed, useful for overlaying entire page
/ closeType: how it closes, 0 = timed, 1 = click anywhere, 2 = close modal button, string = button ID
/ closeTime: for closeType = 0, defines length of time before it closes
/ boxHeight: height of inner box
/ boxWidth: width of inner box
/ modClass: additional classes
*/
function buildModal(
id,inner,parent,fullScreen,fixed,closeType,closeTime,boxHeight,boxWidth,event,modalClass
){
//default close type
if(closeType !== 0 && closeType !== 1 && closeType.length === 0) closeType = 0;
// default close time
closeTime = closeTime || 3000;
parent = parent || document.body;
modalClass = modalClass || "";
cls = (id.indexOf("formError") != -1) ? "formError " + id : "common";
var modal = $("
").append(
$("
").append($(inner))
);
$(parent).append(modal); //Append our modal dialog to our parent
var wid = (fullScreen) ? $(window).width() : $(parent).outerWidth();
var heig = (fullScreen) ? $(window).height() : $(parent).outerHeight();
var pos = fixed ? "fixed" : "absolute";
$("#"+ id).css({ //Position and size our modal overlay
display: 'none',
height: heig + 'px',
left: '0px',
position: pos,
top: '0px',
width: wid + 'px',
zIndex: '9999'
}).fadeIn();
var inHeight = boxHeight || ((fullScreen) ? $(window).height() * (2 / 3) : $(parent).outerHeight() * (2 / 3)); // Set the max height of the inner container
var inWidth = boxWidth || ((fullScreen) ? $(window).width() * (2 / 3) : $(parent).outerWidth() * (2 / 3));
$("#"+ id + " .modalInner").css({ //Set up the position and size styling for the modal box, the rest can be styled in our standardStyles
height: 'auto',
maxHeight: inHeight + "px",
left: '0px',
overflow: 'hidden',
paddingBottom: '40px', // Take into account our error list size
position: 'fixed',
left: (($("#" + id).width() - inWidth) / 2) + 'px',
top: (($("#" + id).height() - inHeight) / 2) + 'px',
width: inWidth + 'px'
});
inHeight = (boxHeight == null) ? $("#" + id + " .modalInner").outerHeight() : inHeight;
//Animate show the box!
$("#" + id + " .modalInner").css({height:'0px'}).animate({height:inHeight+"px"},500);
if(!isNaN(closeType)){ //Set up our close listeners
if(!closeType){ //Timed
window.setTimeout(
function() {
$("#" + id).fadeOut().remove();
},
closeTime
);
}
//default modal cose button
else if(closeType===2){
//create the button
$(".modalInner").append(
$('
X
')
);
//js to remove the modal
$(".modalClose").on("click",function(){
$(this).parent().parent().fadeOut().remove();
});
}
else{ //Click anywhere
$("#" + id).on("click",function(){
$(this).fadeOut().remove();
});
}
}
else{ //Defined element
$(closeType).on("click",function(){
$("#" + id).fadeOut().remove();
}).children().click(function(e){e.stopPropagation();});
}
if(event){
event.cancelBubble = true; //prevent event bubbling
if(event.stopPropagation) event.stopPropagation();
}
}
//Check if variable is defined and not null
function isset(v){
//they can pass in the name of a global
if("string" === typeof v) {
v = window[v];
}
return ("undefined" !== typeof v && null !== v);
}
function emptystring(s){
return (!isset(s) || s.length == 0);
}
function repSubstr(input, from, to) {// Replace from with to in input
return input.split(from).join(to);
}
//converts a 12 hour time string to a 24 hour time string that is mysql compatible
function timeConvertMysql(timeVal){
var timeAry = timeVal.split(":");
var timeHrs = timeAry[0];
var timeStr = false;
if(timeVal.match(/am/i)) timeStr = timeHrs + ":" + timeAry[1].slice(0,timeAry[1].indexOf(" ",0)) + ":00";
else if(timeVal.match(/pm/i)){
timeHrs = parseInt(timeHrs) + 12;
timeStr = timeHrs + ":" + timeAry[1].slice(0,timeAry[1].indexOf(" ",0)) + ":00";
}
return timeStr;
}
function isNumeric(n){
return !isNaN(parseInt(n,10));
}
//is added for the forms with multiple checkboxes, we require to send all of checkboxe values to client's email
function sendFormValues(formObj){
//close any existing open modal messages
$(".modal-formError").fadeOut().remove();
var formAjax = ajaxObj();//check to see if our form has valid data
var formCompleted = formObj.validate().form();
if(formCompleted){
var paramString = "";
paramString = formObj.serialize();
var paramArray = paramString.split("&");
var params = [];
var tempA = [];
for( var i = 0; i <= paramArray.length - 1; i++){
var paramArr = paramArray[i].split("=");
if ($.inArray(paramArr[0], tempA)!==-1) {
params[$.inArray(paramArr[0], tempA)] = params[$.inArray(paramArr[0], tempA)] + "," + paramArr[1];
}
else {
tempA.push(paramArr[0]);
//if there is a tite on the input field, use that
if($("[name='"+paramArr[0]+"']").attr("title")){
param = encodeURI($("[name='"+paramArr[0]+"']").attr("title"));
}
else{
/*not sure what this was for, but since we serialisze the form anyways i don't know if its needed
param = paramArr[0].replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); });*/
param = paramArr[0];
}
params.push(param + "=" + paramArr[1]);
}
}
//extra parameter so we know we're sending the form value from this script
//should prevent blank forms from being sent
params.push("scriptSend=1");
paramString = params.join("&");
formAjax.formObj = formObj;
formAjax.onreadystatechange=function(){
if(formAjax.readyState===4){
var formSubmittedMsg = "
Your information has been submitted!
Click anywhere to hide this message.";
buildModal("formSuccess",formSubmittedMsg,null,true,true,1,null,null,440) //Display a modal dialog
formObj[0].reset();
return true;
}
};
ajaxPost(formAjax,"/public/sendForm.php",paramString,true,1,null,false);
return false;
}
}
function ajaxObj(){//ajaxObj
var xmlhttp = false;
try {
xmlhttp = new XMLHttpRequest();
}
catch (e) {
alert("Your browser does not support AJAX");
}
return xmlhttp;
}
function ajaxPost(ajaxObject,location,params,async,getPost,contentType,historyTrack,justTrackHist){
async=isset(async)? async: true;
getPost=isset(getPost)? getPost: true;
contentType=isset(contentType)? contentType: "application/x-www-form-urlencoded";
historyTrack=isset(historyTrack)? historyTrack:true;
justTrackHist = justTrackHist || false; //used for single page sites
historyBool=isset(window["historyBool"])? window["historyBool"]:true;
var urlParams = "";
//URL parameters without the function or pageID
var cleanParams;
var argsCaller;
try{
//historyBool is global var that is set in headScripts.php
if(historyTrack && historyBool){
//setup ajax bookmark and browser navigation
var callerFunction = arguments.callee.caller;
while(callerFunction){
if(getParentFunctionCall(callerFunction)) {
argsCaller = callerFunction;
callerFunction = getParentFunctionCall(callerFunction);
}
else {
break;
}
}
var callerFunStr = callerFunction.toString();
var tempFunName = callerFunStr.substr(callerFunStr.indexOf("{",0)+1);
var historyFunName = tempFunName.substr(0,tempFunName.indexOf("(",0));
var historyFunParams = "";
var callerFunctionArgs = argsCaller.arguments;
var argCnt = callerFunctionArgs.length;
for(var i = 0; i < argCnt; i++){
if(historyFunParams.length === 0) historyFunParams = "'" + callerFunctionArgs[i] + "'";
else historyFunParams = historyFunParams + "," + "'" + callerFunctionArgs[i] + "'";
}
//changes URL for bookmarks, and contains page content for foward\back-buttons
//we don't want the function param or pageID in our URL
if(params.length > 0 ){
var regexFunc = new RegExp("[\&]?(function=[a-zA-Z_%]*)");
var regexPageID = new RegExp("[\&]?(pageID=[\-]?[0-9]*)");
cleanParams = params.replace(regexFunc,"");
cleanParams = cleanParams.replace(regexPageID,"");
cleanParams = cleanParams.replace(/^\&/,"");
cleanParams = encodeURIComponent(cleanParams);
urlParams = (cleanParams.length > 0) ? pageArray[pageID].name + "?" + cleanParams : pageArray[pageID].name;
}
historyBool = false;
var historySet = {ajaxRunFunction: historyFunName + "(" + historyFunParams + ")", hisUrlParams: urlParams};
if(historySet.ajaxRunFunction != History.getState().data.ajaxRunFunction) {
History.pushState(historySet,"",urlParams);
}
else {
History.replaceState(historySet,"",urlParams);
historyBool = true;
}
}
}
catch(e){alert("stealth history track error:" + e);}
if(justTrackHist){
//hacky way for now...
ajaxObject.ajaxPost = {responseText:'{"priKeyID":'+pageID+'}'};
ajaxObject.onreadystatechange();
ajaxObject.abort();
return;
}
if(getPost){
ajaxObject.open("POST",location,async);
ajaxObject.setRequestHeader("Content-type", contentType);
ajaxObject.setRequestHeader("Content-length", params.length);
ajaxObject.setRequestHeader("Connection", "close");
try{
ajaxObject.send(params);
}
catch(e){
/*probably no internet connectoin, return
404 so we store form info in local storeage*/
ajaxObject.status = 404;
}
}
else{
//the location could have params itself already
if(location.indexOf("?") === -1) params = "?" + params;
ajaxObject.open("GET",location + params,async);
ajaxObject.send(null);
try{
ajaxObject.send(null);
}
catch(e){
/*probably no internet connectoin, return
404 so we store form info in local storeage*/
ajaxObject.status = 404;
}
}
}
//return the caller of the function object
function getParentFunctionCall(funObj){
if(funObj.caller) return funObj.caller;
else return false;
}
function fieldEscape(fieldVal){
try{ return escape(htmlentities(fieldVal)); } catch(e){ alert(e); }
}
function ckFieldEscape(fieldVal){
return CKEDITOR.instances[fieldVal].getData();
}
function htmlentities(str) {
return str.replace(/&/g,'&').replace(//g,'>');
}
function loadSinglePageSite(){
var currentPage = pageArray[pageID].pageOrder;
var prevPages = [], nextPages = [];
for(var i in pageArray){ //Grab all of the pages in order, split by the current loaded page
if(parseInt(i) != pageID){
if(pageArray[i].pageOrder < currentPage){
prevPages[pageArray[i].pageOrder - 1] = i;
}
else{
nextPages[pageArray[i].pageOrder - currentPage - 1] = i;
}
}
}
if(prevPages.length + nextPages.length <= 1){
return;
}
var first = (prevPages.length > 0) ? prevPages.pop() : -1
if(first === -1) first = (nextPages.length > 0) ? nextPages.shift() : -1; //get the first to load if exists
var current = first, next = -1;
while(prevPages.length > 0 || nextPages.length > 0){ //loop through the rest and build a chain of pages to load
if(pageArray[current].pageOrder < pageArray[pageID].pageOrder){ //The current page to load is to the left/top
next = (nextPages.length > 0) ? nextPages.shift() : (prevPages.length > 0) ? prevPages.pop() : null;
if(next !== null){
if(!emptystring(pageArray[current].postUpdate)){
pageArray[current].tempPost = pageArray[current].postUpdate;
}
pageArray[current].postUpdate = "upc("+next+",null,false);";
}
}
else{
next = (prevPages.length > 0) ? prevPages.pop() : (nextPages.length > 0) ? nextPages.shift() : null;
if(next !== null){
if(!emptystring(pageArray[current].postUpdate)){
pageArray[current].tempPost = pageArray[current].postUpdate;
}
pageArray[current].postUpdate = "upc("+next+",null,false);";
}
}
if(prevPages.length <= 0 && nextPages.length <= 0){
if(!emptystring(pageArray[next].postUpdate)){
pageArray[next].tempPost = pageArray[next].postUpdate;
}
pageArray[next].postUpdate = "if($s('li')){$('#li').fadeOut(400);}pageID = "+pageID+";";
}
else{
current = next;
}
if(prevPages.length === 0 && nextPages.length === 0){
if(!emptystring(pageArray[pageID].postUpdate))
pageArray[next].postUpdate += pageArray[pageID].postUpdate;
}
}
upc(first,null,false);
}
function upt(pID){//update pageText container
var pageAjax = ajaxObj();
var moduleParams = "function=getRecordByID&pID=" + pID;
pageAjax.onreadystatechange=function(){
if(pageAjax.readyState===4){
//JSON parse reponse, update innerHTML of pageText
$(".pageText").html(JSON.parse(pageAjax.responseText).prodIndex0.pageCode);
document.title = $(document.createElement('div')).html( JSON.parse(pageAjax.responseText).prodIndex0.pageTitle).text();
pageID = pID; //update global variable
}
}
ajaxPost(pageAjax,"/cmsAPI/pages/pages.php",moduleParams,true,0,false,true);
}
function upc(pID,moduleParams,hisTrack){//main function for updating pages
//if the first character in our parameters is a ? remove it
if(moduleParams) {
moduleParams = repSubstr(moduleParams,"?","");
}
window.scrollTo(0,0);
if(typeof(pageAjax) !== "undefined") pageAjax.abort();//abort previous page updates
if(moduleParams) var moduleParams = "function=getPage&pageID=" + pID + "&" + moduleParams;
else var moduleParams = "function=getPage&pageID=" + pID;
hisTrack = isset(hisTrack) ? hisTrack : (pID !== pageID);
prevPage = pageID; //we need the previous page if we are appending a page instead of replacing
pageID = pID; //global variable for pageID
pID = prevPage; //need to use this just in case we are doing a single page load and need to reset it!
//clear timers and intervals we had for this page
for(var tempTimer in pageInterTime){
try{ clearTimeout(pageInterTime[tempTimer]); } catch(e){}
try{ clearInterval(pageInterTime[tempTimer]); } catch(e){}
delete(pageInterTime[tempTimer]);
}
pageAjax = ajaxObj();
pageAjax.hideEffectComplete = false;
pageAjax.histTrack = hisTrack;
//show loading gif
if($s("li")){
$("#li").fadeTo(400,1,"swing");
}
if(singlePageSite){
upcDoUpdate();
}
else{
$(".pcpy").stop().fadeTo(400,0,"swing",
function(){
pageAjax.hideEffectComplete = true;
//only proceed if the ajax request is finished
if(typeof(pageAjax.responseText) !== 'unknown' && pageAjax.responseText.length > 0){
upcDoUpdate();
}
}
);
}
//only proceed if the fade is finished
pageAjax.onreadystatechange=function(){
if(pageAjax.readyState===4){
if(pageAjax.hideEffectComplete){
upcDoUpdate();
}
}
}
//make the request for the page content
ajaxPost(
pageAjax, //XMLHTTPRequest Object
"/cmsAPI/pages/pages.php", //API Path
moduleParams, //url params
true, //async
0, //GET
false, //text/html
hisTrack, //track history
(singlePageSite&&pageArray[pageID].pageLoaded)
);
//preUpdate function, default fades in the pagecopy and hides the loading gif
var tempUpdate = new Function(pageArray[prevPage].preUpdate);
tempUpdate();
}
// Function: upcDoUpdate
// Purpose: helper function for the upc function, removes old scripts and styles if not a single page site.
function upcDoUpdate(){
if(!singlePageSite){ //If it's not a single page site, remove the script for the modules loaded for the previous page
while($s("moduleScript")) $("#moduleScript").remove();
}
if(pageAjax.readyState===4){
updatePage();//parse response and finalize page update
}
}
function updatePage(){//finalizes page transition with data retrieved from the server
pageAjax.pageData = JSON.parse(pageAjax.responseText);
//clear out old styles
if(!pageArray[pageAjax.pageData.priKeyID].pageLoaded){
if(navigator.appVersion.indexOf("MSIE") != -1){
var cssCnt = document.styleSheets.length;
for(var c = 0; c < cssCnt; c++)
//ie 7 and 8 handle styleSheets differently in winxp and win7
//need to look for a title and update the correct one
if(document.styleSheets[c].title==="moduleStyles"){
if(singlePageSite){
pageAjax.pageData.moduleStyles = document.styleSheets[c].cssText + pageAjax.pageData.moduleStyles;
}
document.styleSheets[c].cssText = "";
}
}
else{
if(singlePageSite){
pageAjax.pageData.moduleStyles = $("[title='moduleStyles']").text() + pageAjax.pageData.moduleStyles;
}
$("[title='moduleStyles']").empty();
}
}
var tempAfterC = pageArray[pageAjax.pageData.priKeyID].afterComplete;
upcAfterComplete(new Function(tempAfterC));
}
// Function: upcAfterComplete
// Purpose: the replace or append scripts, styles, pageTitle, etc after the ajax call has completed
function upcAfterComplete(transition){
if(
(singlePageSite && !pageArray[pageAjax.pageData.priKeyID].pageLoaded) ||
!singlePageSite
){
//build the pagecopy container
var page = $("
");
if(singlePageSite){
//Build an array of our pages (we can't index an object)
if(pageArray[prevPage].pageOrder < pageArray[pageAjax.pageData.priKeyID].pageOrder){
$("[id^='pcpy']:last").after(page);
}
else{
$("#pc").prepend(page);
}
pageArray[pageAjax.pageData.priKeyID].pageLoaded = 1;
page.html(
pageAjax.pageData.beforeModuleCode +
pageAjax.pageData.pageCode +
pageAjax.pageData.afterModuleCode
);
}
else{
//put in new content & update the id's of our containers
$(".pcpy").eq(0).html(
pageAjax.pageData.beforeModuleCode +
pageAjax.pageData.pageCode +
pageAjax.pageData.afterModuleCode
)
.attr("id","pcpy"+pageAjax.pageData.priKeyID);
$(".pc").attr("id","pc"+pageAjax.pageData.priKeyID);
/*if we are forwarding from one page to another, add a class with
the page ID of the page we would of went to*/
$(".pc").attr("class","pc pcLnk"+ pageID);
}
if(singlePageSite){
var scriptTag = "moduleScriptHead" + pageAjax.pageData.priKeyID;
}
else{
//must remove old script everytime for FF. can only add .change attribute once
if($s("moduleScriptHead")) $("#moduleScriptHead").remove();
var scriptTag = "moduleScriptHead";
}
//insert new moduleScriptHead, should be flexible enough to allow scripts for all pages
var tempScript = document.createElement('script');
tempScript.id = scriptTag;
document.getElementsByTagName("head")[0].appendChild(tempScript);
$s(scriptTag).text = pageAjax.pageData.moduleScripts;
// replace stylesheets
if(navigator.appVersion.indexOf("MSIE") != -1){
var cssCnt = document.styleSheets.length;
for(var c = 0; c < cssCnt; c++){
//ie 7 and 8 handle styleSheets differently in winxp and win7
//need to look for a title and update the correct one
if(document.styleSheets[c].title ==="moduleStyles") {
document.styleSheets[c].cssText = pageAjax.pageData.moduleStyles;
}
}
}
else{
$("[title='moduleStyles']").text(pageAjax.pageData.moduleStyles);
}
//run page transition functions, and functions for the modules
try{
new Function(
pageAjax.pageData.moduleRunScripts +
pageAjax.pageData.modulePageTransition +
pageAjax.pageData.pageTransition
)();
}
catch(e){}
}
try{
if(transition !== null) transition();
}
catch(e){
//Account for a possible error, maybe call default...
}
if(pageAjax.histTrack == true){
_gaq.push(['_trackPageview', (pageAjax.pageData.pageTitle || pageArray[pageAjax.pageData.priKeyID].pageTitle)]);//google tracking code
document.title = (singlePageSite) ? pageArray[pageAjax.pageData.priKeyID].pageTitle :
$(document.createElement('div')).html(pageAjax.pageData.pageTitle).text();
}
//postUpdate function, default fades in the pagecopy and hides the loading gif
var tempPostUp = pageArray[pageAjax.pageData.priKeyID].postUpdate;
if(tempPostUp && tempPostUp.length > 0){
transition(pageAjax);
}
else{
$(".pcpy").stop().fadeTo(500,1,"swing");
}
if($s("li")){
$("#li").stop().fadeOut(400,"swing",function(){
$(this).hide();
});
}
//update page sub nav links that might redirect to this page
$(".lpi" + pageAjax.pageData.priKeyID + ".ni" + pageID).addClass("fakeHover");
if(!emptystring(pageArray[pageAjax.pageData.priKeyID].tempPost)){
pageArray[pageAjax.pageData.priKeyID].postUpdate = pageArray[pageAjax.pageData.priKeyID].tempPost;
delete pageArray[pageAjax.pageData.priKeyID].tempPost;
}
delete pageAjax;
//run standard javascripts that we want on every page
extraScripts();
}
function extraScripts(){
//invoke the plugin for IE9 placeholder text
$('input, textarea').placeholder({customClass:'my-placeholder'});
//invoke fancy box
setGalleryFancyBox();
}
/*as we create accordionObjects we store them in this parent object
so we can reference them when we login in/out to get member pages*/
var accordionTreeObjs = {};
function accordionTree(navClass,navType,toggleSpeed){
this.navID = "#navOuter-"+navClass;
this.navType = navType; //navType, used for generating nav on member sign in
this.className = navClass;
this.toggled = false;
this.toggleSpeed = toggleSpeed;
this.className = navClass;
this.toggleBlind = function(tID,thisRoot,afterEval,clickObjID,thisEvent){
//the element that was clicked, has to be passed as a string for the History to work
var clickObj = $s(clickObjID);
//prevent event bubbling
if(thisEvent){
thisEvent.cancelBubble = true;
if(thisEvent.stopPropagation) thisEvent.stopPropagation();
}
//change the class on whichever one we clicked so that its marked as clicked
this.updateAccordianObjs(tID);
if(afterEval.length> 0) {
var afterRun = new Function(afterEval);
}
else{
var afterRun = new Function("return true");
}
//we clicked on a root element
/*if(pageArray[tID].pageLevel<2){
try{
console.log(accordionTree.prototype.lastExpandedRoot);
//we clicked on a new root
if(accordionTree.prototype.lastExpandedRoot != tID){
this.toggled = true;
$(this.navID).find(".ec").removeClass("expand");
}
//we clicked on the previously expanded root, hide all but the direct descendents
else{
this.toggled = true;
$(this.navID).find(clickObj).next().find(".ec").removeClass("expand");
}
afterRun(tID);
}
catch(e){}
}
//child was clicked. close its siblings
else if(
!isNaN(pageArray[tID].parentPageID) &&
pageArray[tID].parentPageID !== 0 &&
!this.toggled
){
try{
//first page we're going to is a subpage
this.toggled = true;
$(this.navID).find(clickObj).parent().siblings().each(
function(){ //close all sibling children
$(this).find(".ec").removeClass("expand");
}
)
afterRun();
}
catch(e){}
}
else if(!this.toggled && isset(afterEval)){
afterRun(tID);
}*/
$(".ec").removeClass("expand");
$(clickObj).parent('.ec').addClass("expand");
$(clickObj).children('.ec').addClass("expand");
afterRun();
//need properties changes across all instances of the accordionTree object
if(pageArray[tID].pageLevel<2){
accordionTree.prototype.lastExpandedRoot = tID ;
}
else{
accordionTree.prototype.lastExpandedRoot = thisRoot;
}
accordionTree.prototype.lastExpanded = tID;
this.toggled = false;
}
/*this.showChildren = function(tID){
$(this.navID).find('.ni'+tID).mouseleave(function(){//if we leave the nav item
$(this).find('.ec').stop(true).fadeOut(250); //hide all children
}).children('.ec').show(0,function(){ //show the first children container
$(this).mouseenter(function(){$(this).stop().fadeTo(0,1);}) //handles quick mouseout/mousenters
.mouseleave(function(){$(this).stop(true).fadeOut(250);}); //hide on mouseout
});
}*/
}
accordionTree.prototype.determineRoot = function(){
var nc = $(".nc.fakeHover");
if(nc.length <= 0) return null;
else{
return nc.not("[id^='sn']").first().attr('class').split("ni")[1].split(" ")[0];
}
}
//updates the state of an element that we've clicked on
accordionTree.prototype.updateAccordianObjs = function(tID){
//remove fake hover class from any nav objects that may have it
$(".nc").removeClass('fakeHover');
//assign fakeHover to all nav items with the same id. regardless of nav menu
$(".ni" + tID)
.parents(".nc")
.andSelf()
.not('.ntp')
.addClass("fakeHover",this.toggleSpeed);
}
//put an extra class on the nav container when we mouse over a link
accordionTree.prototype.navHover = function(lnk,state,e){
clearTimeout(this.parentHoverTime);
if(state && !$(lnk).parents(".navOuter").hasClass("fakeHover")){
$(lnk).parents(".navOuter").addClass("fakeHover");
}
else if(!state){
var tempNavObj = this;
this.parentHoverTime = setTimeout(
function(){
tempNavObj.removeParentHover(lnk,state,e);
},400
);
}
}
accordionTree.prototype.removeParentHover = function(lnk,state,e){
$(lnk).parents(".navOuter").removeClass("fakeHover");
}
accordionTree.prototype.lastExpandedRoot = 0;
accordionTree.prototype.lastExpanded = 0;
accordionTree.prototype.parentHoverTime = 0;
function enabledEventPropagation(event){
if (event.stopPropagation){
event.stopPropagation();
}
else if(event){
event.cancelBubble=true;
}
}
function disabledEventPropagation(event){
if (event.stopPropagation){
event.stopPropagation();
}
else if(event){
event.cancelBubble=true;
}
}
/* checks window width and sets up mobile styling/functionality if necessary */
responsiveNav = function(){
//loop through all our navigations
for(var prop in accordionTreeObjs){
//instance is set to be responsive.
if(accordionTreeObjs[prop].isResponsive == true){
if(
(window.matchMedia &&
window.matchMedia("(max-width: 1271px)").matches)
|| (!window.matchMedia && $(window).width() < 1255)
) {
//if responsive hasn't been set for this navigation yet
if($('#navOuter-' + accordionTreeObjs[prop].className + '.mobileNav').length == 0){
//create responsive menu button
if($('#navInner-' + accordionTreeObjs[prop].className + ' .expandRespNav').length == 0){
$('#navInner-' + accordionTreeObjs[prop].className).append('
');
}
$('#navOuter-' + accordionTreeObjs[prop].className).addClass("closedMobileNav");
//add class to our nav parent so we know we're in mobile mode
$('#navOuter-' + accordionTreeObjs[prop].className).addClass("mobileNav");
//loop through our links and attach the onclicks as events
$('#navOuter-' + accordionTreeObjs[prop].className + " .nc > a.nc").each(
function(inex, el){
var tempClick = repSubstr(
$(el).attr('onclick'),"return false",""
);
tempClick = repSubstr(
tempClick,"event","null"
);
$(el).attr('data-onclick',tempClick);
$(el).removeAttr('onclick');
$(el).removeAttr('onmouseover');
}
);
//run responsive nav script
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu({
menuHeight: accordionTreeObjs[prop].menuHeight,
menuWidth: accordionTreeObjs[prop].menuWidth,
collapsed: accordionTreeObjs[prop].collapsed,
overlapWidth: accordionTreeObjs[prop].overlapWidth,
originalOverlapWidth: accordionTreeObjs[prop].overlapWidth,
menuInactiveClass: "cMenu",
mode:"overlap",
swipe:"desktop",
/*because of the we always want to show our root level
we need to take some liberties with the way overlapWidth
is used. we keep track of our levels, and then if we return
to the root level, we set overlapWidth manually by dividing
it by whatever level we're currently at.*/
menuLevel:1,
//jquery object to reference in callbacks
navObj: '#navOuter-' + accordionTreeObjs[prop].className,
//by default the nav should only be as tall as the menu button.
//remove the css class that dictates this.
onExpandMenuStart:function(plugOptions){
//sometimes stuff just messes up.... this redraws the menu from scratch
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu( 'redraw' );
$(arguments[0].navObj).removeClass("closedMobileNav");
//once expanded change overlap to 0 otherwise
//menu button vanishes on levels > 1
if(plugOptions.menuLevel > 1){
$(arguments[0].navObj).multilevelpushmenu('option', 'overlapWidth', '0');
}
else{
$(arguments[0].navObj).multilevelpushmenu('option', 'overlapWidth', plugOptions.originalOverlapWidth);
}
},
onBackItemClick:function(thisEvent, menuLevelObject, clickedItem){
if(clickedItem.menuLevel > 0){
clickedItem.menuLevel--;
}
//make previous clicked elements siblings visible again
$(thisEvent.target).parent().parent().parent().siblings().removeClass("closedMobileChildren");
//sometimes stuff just messes up.... this redraws the menu from scratch
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu( 'redraw' );
},
//if we are hiding the nav, and the menu is collpased, make the nav
//the same height as the button again.
onTitleItemClick:function(thisEvent, menuLevelObject, clickedItem){
$(clickedItem.navObj).addClass("closedMobileNav");
$(clickedItem.navObj).multilevelpushmenu('option', 'overlapWidth', clickedItem.originalOverlapWidth/clickedItem.menuLevel);
clickedItem.menuLevel = 1;
$(clickedItem.navObj).multilevelpushmenu(
'collapse'
);
},
//if they click on a link with no children, collapse nav
onItemClick:function(thisEvent, menuLevelObject, clickedItem, plugOptions){
//go to the page the user clicks on
eval($("#" + clickedItem[0].id + " > a").attr('data-onclick'));
$(plugOptions.navObj).addClass("closedMobileNav");
$(plugOptions.navObj).multilevelpushmenu('option', 'overlapWidth', plugOptions.originalOverlapWidth/plugOptions.menuLevel);
plugOptions.menuLevel = 1;
$(plugOptions.navObj).multilevelpushmenu(
'collapse'
);
},
//go to the page the user clicks on
onGroupItemClick:function(thisEvent, menuLevelObject, clickedItem, plugOptions){
eval($("#" + clickedItem[0].id + " > a").attr('data-onclick'));
//don't show its children. we control this manually with the arrow
$(plugOptions.navObj).addClass("closedMobileNav");
$(plugOptions.navObj).multilevelpushmenu('option', 'overlapWidth', plugOptions.originalOverlapWidth/plugOptions.menuLevel);
plugOptions.menuLevel = 1;
$(plugOptions.navObj).multilevelpushmenu(
'collapse'
);
},
onCollapseMenuEnd:function(plugOptions){
//make sure that we set the overlapWidth to the proper one.
if(plugOptions.menuLevel == 1){
$('#navOuter-' + accordionTreeObjs[prop].className).scrollTop(0);
$(plugOptions.navObj).multilevelpushmenu('option', 'overlapWidth', plugOptions.originalOverlapWidth);
$(".nc").removeClass("closedMobileChildren");
}
}
});
//remove href from back button
$(".backItemClass a").each(
function(inex, el){
$(el).removeAttr('href');
}
);
//loop through our links and attach the onclicks as events
$('#navOuter-' + accordionTreeObjs[prop].className + " .hc > .nc").each(
function(inex, el){
//create an icon to expand this page to see its children
$(el).after(
'
>'
);
//javascript to go to children
$("#childShow" + $(el).get(0).id).click(
function(event){
event.stopPropagation();
//get currrent menu level
var tempMenuLevel =
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'option',
'menuLevel'
);
//increase the menu level by 1
tempMenuLevel++;
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'option',
'menuLevel',
tempMenuLevel
);
//expand to desired menu level
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'expand' , $(this).next()
);
//to manage the fakehovers, we run the click
eval($(this).prev().attr('data-onclick'));
//closes siblings of element we just clicked, so everything isn't pushed down
$(this).parent().siblings(".nc").addClass("closedMobileChildren");
}
);
}
);
/*$(".pcpy").click(
function(){
$('#navOuter-' + accordionTreeObjs[prop].className).addClass("closedMobileNav");
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'option',
'overlapWidth',
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'option',
'originalOverlapWidth'
)/$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'option',
'menuLevel'
)
);
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'option',
'menuLevel',
1
);
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu(
'collapse'
);
}
);*/
}
//redraw mobile nav for responsiveness
else{
$('#navOuter-' + accordionTreeObjs[prop].className).multilevelpushmenu( 'redraw' );
}
}
else if ($(window).width() >= 990) {
$s('navOuter-' + accordionTreeObjs[prop].className).outerHTML = accordionTreeObjs[prop].stealthNav;
$(".pcpy").off("click");
}
}
}
}
//once the site loads, run the script for the responsive nav
$(window).load(function(){
responsiveNav();
});
/* check width on resize and execute transition functions if necessary */
$(window).bind('resize', function() {
responsiveNav();
});
function stealthCommon(){};
//defaults for input fields that need to be handled in a special manner
//format date and time for mysql
stealthCommon.prototype.timeFieldArray = [];
stealthCommon.prototype.addEditModule = function(blkEdit,addEditDraftBtn){
//try-catch because asyn errors are difficult to detect
try{
/*function to run before module submits, such as
checking if user and login are available for user
NOTE the preFunction must return true if you want to continue
*/
if(this.preFunction) {
var preFunc = this.preFunction();
if(!preFunc) return;
}
this.blkEdit = blkEdit;
//determine if we are adding or editing the module record
if($(this.modForm).find("input[name='priKeyID']").val() == 0) {
this.addEdit = false;
}
else this.addEdit = true;
/*check to see if there is a form validation script,
and if there is that our form validates*/
if(
typeof($(this.modForm).validate) === "undefined" ||
$(this.modForm).validate().form()
){
//disable so they can't multi-click
$(this.modForm).find("input[name='moduleAddEditBtn']").attr("disabled", false);
$(this.modForm).find("input[name='moduleAddEditDraftBtn']").attr("disabled", false);
//change cursor to loading icon
$('html').css('cursor','wait');
var moduleAjax = ajaxObj(); //prepare our ajax request
//encrypt any sha256 classed fields
if(this.encryptFields){
var encFields = this.encryptFields.split(',');
for (var i = encFields.length - 1; i >= 0; i--){
this.modForm[encFields[i]].value = this.modForm[encFields[i]].value.sha256();
}
}
//put form fields into a JSON object
var requestParams = this.getRequestFields(this,blkEdit,addEditDraftBtn);
//determine if the we are online or offline
//determined by a propertly in the module
if(isset(this.isModOnline)) {
var onlineCheck = this.isModOnline;
}
//not specified by the module, check for connectivity
else{
var onlineCheck = this.isOnline();
}
//silverline - online
if(onlineCheck){
//blk add edit... return our JSON object and send all form JSON objects to the server at once
if(blkEdit){
return requestParams;
}
//individual record add/edit
else{
//if its a public form with an instanceID
requestParams += isset(this.modForm.instanceID) ? "&instanceID=" + this.modForm.instanceID.value : "";
//pass the instanceID along so we know which to use on the server
requestParams += "&pmpmID=" + this.pmpmID;
ajaxPost(
moduleAjax,
this.apiPath,
requestParams,
false,
1,
"application/x-www-form-urlencoded",
false
);
xmlResponse = moduleAjax.responseText;
}
//there was an error, probably wrong security level
if(isNaN(xmlResponse)){
alert(this.apiPath + xmlResponse);
return false;
}
/*quick bug fix. for some reason the server is adding a /n breakline to the front of our
returned returnedID. the php seems fine. could be a server thing? happens on adding and editing
a record. for now I'm doing a parseInt here to 'fix' the problem - jared*/
//add priKeyID, change submit button text
if(!this.addEdit){
$(this.modForm).find("input[name='priKeyID']").val(parseInt(xmlResponse));
this.priKeyID = xmlResponse;
}
//add priKeyIDs for draft and live data, change submit button text when users click on DraftSave and Save Changes Button
if(addEditDraftBtn){
$(this.modForm).find("input[name='draftPriKeyID']").val(parseInt(xmlResponse));
this.draftPriKeyID = xmlResponse;
$(this.modForm).find("input[name='moduleAddEditDraftBtn']").val("Edit Draft");
}
else {
$(this.modForm).find("input[name='livePriKeyID']").val(parseInt(xmlResponse));
this.livePriKeyID = xmlResponse;
$(this.modForm).find("input[name='moduleAddEditBtn']").val("Edit " + this.moduleAlert);
}
}
//silverline - offline
else{
//they key for our offline idata is the date in milliseconds
var d = new Date();
var n = d.getTime();
//it encoded, but we don't want that version
var requestParams = decodeURIComponent(
this.getRequestFields(this,blkEdit,addEditDraftBtn)
);
localStorage.setItem(n,requestParams);
}
/*silverline - no matter if this is online or offline
we want to keep the last ticket available to display*/
/*var requestParams = decodeURIComponent(
this.getRequestFields(this,blkEdit,addEditDraftBtn)
);
localStorage.setItem("prevTicket",requestParams);*/
//quick add/edit, probably through another module
if(this.quickAddEdit) {
$("#" + this.moduleClassName).fadeOut().remove();
}
//enable add/edit buttons, reset cursor
this.addEditComplete();
//callback function for submitting a form
if(this.nextFunction) {
this.nextFunction();
}
if(!this.addEdit && this.disMsg == 1) {
alert(this.moduleAlert + " has been added");
}
else if(this.addEdit && this.disMsg == 1) {
alert(this.moduleAlert + " has been updated");
}
}
}
catch(e){
alert("addEdit Mod Error:" + e);
}
}
stealthCommon.prototype.isOnline = function(){
//test network connectivity with ajax
var netTest = ajaxObj();
netTest.onerror = function(){
return false;
}
ajaxPost(
netTest,
"/public/networkTest.php",
"",
false,
1,
"application/x-www-form-urlencoded",
false
);
if(netTest.status >= 200 && netTest.status < 304){
return true;
}
else{
return false;
}
}
//create Object we turn to JSON full of form values
stealthCommon.prototype.getRequestFields = function(prntObj,blkEdit,addEditDraftBtn){
var modData = {};
/*can't use dot notation here or MSIE breaks, probably should
of used a smarter value other than 'function'
determine the function on the server to call, add be for single records or bulk changes
*/
var modLen = prntObj.modForm.length;
//create and object, that has a property for each checkbox name group as an array
var tempCheckVal = {};
var tempCheckNames = $("#" + prntObj.modForm.id + " input[type='checkbox']").each(
function(){
if(!tempCheckVal[$(this).attr("name")]) {
tempCheckVal[$(this).attr("name")] = [];
}
}
);
for(i=0;i
= 0; i--){
//don't sent it at all
delete modData[ignFields[i]];
//this.modForm[ignFields[i]].value='';
}
}
//determine the function on the server to call, add or update the data
modData.priKeyID = $(this.modForm).find("input[name=priKeyID]").val();
modData.draftPriKeyID=$(this.modForm).find("input[name=draftPriKeyID]").val();
modData.livePriKeyID=$(this.modForm).find("input[name=livePriKeyID]").val();
/*if the draft button exists, we know the draft option is available for this module.
If a user clicks on draft button, add the data first time then set priKeyID as draftPriKeyID
so that it won't change in the next click. Do the same for liveButton */
if($$s("moduleAddEditDraftBtn")[0]){
if(addEditDraftBtn){
if(!modData.draftPriKeyID) {
modData.isDraft = 1;
modData["function"] ="addRecord";
}
else {
modData.priKeyID= modData.draftPriKeyID;
modData["function"] ="updateRecord";
}
}
else {
if(modData.livePriKeyID == "") {
modData.isDraft = 0;
modData["function"] ="addRecord";
}
else {
modData.priKeyID = modData.livePriKeyID;
modData["function"] ="updateRecord";
}
}
}
//Add and update the data for all other pages who do not have draft button.
else {
if(!modData.priKeyID) {
modData["function"] ="addRecord" ;
}
else {
modData["function"] ="updateRecord";
}
}
if(!blkEdit) {
return "modData=" + encodeURIComponent(JSON.stringify(modData));
}
else{
return modData;
}
}
//update all records when we're editing in bulk mode
stealthCommon.prototype.bulkMassAddEdit = function() {
var moduleAjax = ajaxObj();
//all of our module forms
var addEditForms = $$$s("moduleForm");
//number of forms to loop through
var formQty = addEditForms.length;
//object to pass to server contain modified form information
var recordChanges = {};
for(var x = 0; x < formQty; x++){
var tempJSObj = addEditForms[x].jsObjName.value;
//we don't want to display an update message for each record
//for some modules the update message is disabled by default, such as the gallery images
var tempUpdateMessage = window[tempJSObj].disMsg;
window[tempJSObj].disMsg = false;
//put form data into object
recordChanges[x] = window[tempJSObj].addEditModule(
true
);
//activate individual records saves again
window[tempJSObj].disMsg = tempUpdateMessage;
}
var modJSON = encodeURIComponent(JSON.stringify(recordChanges));
ajaxPost(
moduleAjax,
this.apiPath,
"function=bulkAddEdit&modData=" + modJSON,
false,
1,
"application/x-www-form-urlencoded",
false
);
/*loop through the priKeyID's and groupID's and add the returned
number back to the priKeyID field and groupID field needed for bulk add's*/
var returnedIDs = JSON.parse(moduleAjax.responseText);
for(var key in returnedIDs) {
//priKeyID
$s(key).value = returnedIDs[key]["priKeyID"];
//groupID
$s(key).form.groupID.value = returnedIDs[key]["groupID"];
}
//run the callback functions after the new priKeyID's are in place
for(var x = 0; x < formQty; x++){
/*check if this form is valid, doesn't display not-valid
errors at this point they are already displayed*/
/*console.log($(addEditForms[x]).valid());*/
if(
typeof($(addEditForms[x]).validate) === "undefined" ||
$(addEditForms[x]).validate().numberOfInvalids() === 0
){
var tempJSObj = addEditForms[x].jsObjName.value;
//set the new priKeyID on our js object
window[tempJSObj].priKeyID = addEditForms[x].priKeyID.value;
//callback function for submitting a form
if(window[tempJSObj].nextFunction) {
window[tempJSObj].nextFunction();
}
}
}
//enable add/edit buttons, reset cursor
this.addEditComplete();
//some modules display the completed message in the nextFunction, such as the gallery images
if(window[tempJSObj].disMsg == true) {
alert("Changes have been saved.");
}
}
//quickEdit - if true, editing through the module list, else adding through bulk
stealthCommon.prototype.setupRecord = function(quickEdit,thisBtn,writeBackDOM){
var moduleAjax = ajaxObj();
moduleAjax.moduleClassName = this.moduleClassName;
//quick add/edit on public side
if(quickEdit === true) {
var tempPmpmID = this.primaryPmpmAddEditID;
var tmpPriKeyID = this.priKeyID;
moduleAjax.quickEdit = true;
var paramStr = "function=setupRecord&pmpmID=" + tempPmpmID + "&quickEdit=" + quickEdit + "&recordID=" + tmpPriKeyID;
}
//adding a record from within another module - example on the silver line tickets to add new leases
else if(quickEdit == 2) {
var tempPmpmID = this.primaryPmpmAddEditID;
var tmpPriKeyID = "addRec";
//priKeyID of the module opening this one
var parentPriKeyID = $("#" + thisBtn.form.id + " input[name='priKeyID']").val();
moduleAjax.quickEdit = true;
var paramStr = "function=setupRecord&pmpmID=" + tempPmpmID + "&quickEdit=" + quickEdit + "&recordID=" + tmpPriKeyID + "&parentPriKeyID=" + parentPriKeyID;
}
//bulk adding
else{
var tempPmpmID = this.pmpmID;
moduleAjax.quickEdit = false;
//there there is a parent record ID, such as a galleryID for images
if($("#parentPriKeyIDBlk") && !isNaN($("#parentPriKeyIDBlk").val())) {
var parentPriKeyID = $("#parentPriKeyIDBlk").val();
var parentPriStr = "&parentPriKeyID=" + parentPriKeyID;
}
else{
var parentPriStr = "";
}
var paramStr = "function=setupRecord&pmpmID=" + tempPmpmID + "&quickEdit=" + quickEdit + parentPriStr;
}
moduleAjax.onreadystatechange=function(){
if(moduleAjax.readyState===4){
var tempMod = JSON.parse(moduleAjax.responseText);
if(moduleAjax.quickEdit){
//load our form into a modal
//we change the ID of the modal once our module loads
buildModal(
"tempModal",
tempMod.DOM,
"#pc" + pageID,
true,false,
2,null,null,null,null,
"quickAddEdit"
);
//insert styles
//MSIE
if(navigator.appVersion.indexOf("MSIE") != -1){
var cssCnt = document.styleSheets.length;
for(var c = 0; c < cssCnt; c++){
//ie 7 and 8 handle styleSheets differently in winxp and win7
//need to look for a title and update the correct one
if(document.styleSheets[c].title ==="moduleStyles") {
document.styleSheets[c].cssText =
$("[title='moduleStyles']").text() + tempMod.CSS;
}
}
}
//other browsers
else{
$("[title='moduleStyles']").text(
$("[title='moduleStyles']").text() + tempMod.CSS
);
}
}
else{
//insert our DOM at the top of the record list
$("#mfmcc-" + moduleAjax.moduleClassName).append(tempMod.DOM);
}
//run javascript
eval(tempMod.JS);
//if it's a quick add/edit
if($s("tempModal")){
//change our modal ID to be the className of the module we're setting up
$s("tempModal").id = window[mIP.instanceProp.className].moduleClassName;
}
return true;
}
}
ajaxPost(
moduleAjax,
this.apiPath,
paramStr,
false,
1,
"application/x-www-form-urlencoded",
false
);
}
//enable add/edit buttons, reset cursor
stealthCommon.prototype.addEditComplete = function() {
$("input[name='moduleAddEditBtn']").attr("disabled", false);
$("input[name='moduleAddEditDraftBtn']").attr("disabled", false);
$('html').css('cursor','');//remove 'busy' cursor
}
//updates the innerHTML of a parent module with all the records of a child
stealthCommon.prototype.updateParentField = function(pElID){
var childAjax = ajaxObj();
var requestParams = 'function=getConditionalRecord&a={ "0":"priKeyID","1":0,"2":"false","3":"DESC"}';
var winPrtEl = window.opener.document.getElementById(pElID);
winPrtEl.innerHTML = "";//clear parent select
//do ajax call on this object to get the records, sort DESC so the latest one is selected
ajaxPost(childAjax,this.apiPath,requestParams,false,1,null,false);
var domElements = JSON.parse(childAjax.responseText);
//build up parent select
for(var z in domElements){
buildParentHtml.createDOMElement(
"option",
{
innerHTML:domElements[z].galleryName,
value:domElements[z].priKeyID
},
winPrtEl
);
}
}
//load the scripts for CKEditor and CKFinder and create required instances
stealthCommon.prototype.loadCKEditor = function(priKeyArray){
//loose 'this' in jquery callbacks
var tmpObj = this;
if(this.ckEditorFieldName) {
//check if we have loaded CKEDITOR previously, only need to load it once
if(!isset("CKEDITOR")){
//load in ckeditor script with jquery
$.getScript(
"/ckeditor/ckeditor.js",
function(){
//check if we've loaded a CKFinder
if(!isset("CKFinder")) {
//load CKFINDER
$.getScript(
"/ckfinder/ckfinder.js",
function(){
//creates instances
tmpObj.loadCKInstance(priKeyArray);
}
);
}
else {
//creates instances
tmpObj.loadCKInstance(priKeyArray);
}
}
);
}
else{
//creates instances
tmpObj.loadCKInstance(priKeyArray);
}
}
}
//creates instances for our CKEditor and CKFinder
stealthCommon.prototype.loadCKInstance = function(priKeyArray){
//how many priKeyID's have to loop through
var recCnt = priKeyArray.length;
try{
for(var x = 0; x < recCnt; x++){
//priKeyID of our module instance
var recPriKey = priKeyArray[x];
//loose 'this' in jquery callbacks
var tmpObj = this;
//textarea DOM object
var tempCKFields = this.ckEditorFieldName.split(",");
var tempArrayLen = tempCKFields.length;
for(var y = 0; y < tempArrayLen; y++){
var moduleTextArea = $s(tempCKFields[y] + recPriKey);
//delete ckeditor if the module is reloaded
if(
moduleTextArea &&
typeof CKEDITOR.instances[moduleTextArea.id] !== "undefined"
){
CKEDITOR.remove(CKEDITOR.instances[moduleTextArea.id]);
}
var tempCK = CKEDITOR.replace(moduleTextArea.id);
CKEDITOR.config.autoParagraph = false;
//allow custom HTML so ckeditor doesn't try to fix/remove it for us
CKEDITOR.config.allowedContent = true;
//load in our custom template file
CKEDITOR.config.templates_files = [
'/ckeditor/stealthTemplate.js'
];
//load ckfinder
CKFinder.setupCKEditor(tempCK,'/ckfinder/');
//allows div's instead h tags
CKEDITOR.dtd.h1.div = 1;
CKEDITOR.dtd.h2.div = 1;
CKEDITOR.dtd.h3.div = 1;
CKEDITOR.dtd.h4.div = 1;
CKEDITOR.dtd.h5.div = 1;
}
}
}
catch(e){console.log("stealth error loading CKEditor" + e);}
}
stealthCommon.prototype.moduleDelete = function(recordID,thisBtn) {
//if the record is created from the bulk entries we have a random string
if(recordID.length > 0 && !isNaN(recordID)) {
recordID = recordID;
}
else{
recordID = this.priKeyID;
}
var comfDel = confirm("Are you sure you want to delete this record?");
if(comfDel) {
//add\edit form delete
if($$s("moduleDelBtn")){
$(thisBtn).parents(".mi").remove();
}
//module item delete
else if($s("moduleItemDelete" + recordID)){
$("#moduleItemDelete" + recordID).parent().remove();
}
//module draft item delete
else if($s("moduleItemDeleteDraft" + recordID)){
$("#moduleItemDeleteDraft" + recordID).parent().remove();
}
//module draft item delete, if both live and draft items exist.
else if($s("moduleItemDeleteDraftLive" + recordID)){
$("#moduleItemDeleteDraftLive" + recordID).remove();
$("#moduleItemDraftLiveEdit" + recordID).remove();
}
/*callback function for after a record is deleted
must be BEFORE we remove the record from the
database, so we can get the file name etc...*/
try{this.afterModuleDel(recordID);}catch(e){}
var moduleHttp = ajaxObj();
moduleHttp.onreadystatechange=function(){
if(moduleHttp.readyState===4){
alert("The item has been removed");
}
}
ajaxPost(
moduleHttp,
this.apiPath,
"function=removeLiveDraftByID&recordID=" + recordID,
null,
null,
null,
false
);
}
}
//go to add/edit form for this module item in user specified language
stealthCommon.prototype.changeModuleLng = function(){
upc(
this.addEditPageID,
"recLng=" + $('#moduleItemLang').val() + "&recordID=" + $('input[name="priKeyID"]').val()
);
return true;
}
//go to a specific pagination page
//refreshPag if we want to refresh the pagination - doesn't work on level 2 modules
stealthCommon.prototype.paginateModule = function(
requestParams,thisDiv,thisPagPage,refreshPag,historyTrack
){
var refreshPag=isset(refreshPag)?refreshPag:false;
var pagAjax = ajaxObj();
var pagNums = $(".pgc-" + this.moduleClassName);
var historyTrack = isset(historyTrack)?historyTrack:true;
//remove the clicked class from the pagination link
$(".pgc-" + this.moduleClassName).removeClass("pgcClicked");
//scroll to the top of the page
$("html, body").animate({ scrollTop: 0 }, "slow");
//set the recently clicked pag-page link
if(thisDiv) thisDiv.className = thisDiv.className + " pgcClicked";
//went directly to a pagination page
if(thisPagPage) this.pagPage = thisPagPage;
/*make our object properties, properties of the ajax
object so we can access them in the ajax repsonse*/
pagAjax.moduleClassName = this.moduleClassName;
pagAjax.pagAjax = requestParams;
pagAjax.refreshPag = refreshPag;
pagAjax.requestParams = requestParams;
pagAjax.moduleID = this.moduleID;
pagAjax.instanceID = this.instanceID;
pagAjax.afterPaginate = this.afterPaginate;
pagAjax.historyTrack = historyTrack;
pagAjax.afterPaginate = this.afterPaginate;
pagAjax.onreadystatechange=function(){
if(pagAjax.readyState===4){
var tempMod = JSON.parse(pagAjax.responseText);
if(
//regular pagination
$s("mfp-" + pagAjax.moduleClassName) ||
//login module
pagAjax.moduleID == 37
){
$s("mfmcc-" + pagAjax.moduleClassName).innerHTML = tempMod.DOM;
//run javascript
eval(tempMod.JS);
//for now, only for the login module
if(pagAjax.moduleID == 37){
/*append our styles, right now its primary used
for nav styleing differences on silver line
-so it would seem we should NOT be using the title attribute on the style tag
for our jquery selector, we will make sure to keep our pagnation tag as the 3rd tag */
if(navigator.appVersion.indexOf("MSIE") != -1){
//ie 7 and 8 handle styleSheets differently in winxp and win7
//need to look for a title and update the correct one
document.styleSheets[2].cssText = tempMod.STYLES;
}
else{
$("#pagStyles").text(tempMod.STYLES);
}
}
//javascript objects can have an afterPaginate callback, ex
//galleryImageMIObj.prototype.afterPaginate = "doSomething();";
if(typeof pagAjax.afterPaginate !== "undefined"){
try{
//this.afterPaginate can be a string of a function object
if(typeof pagAjax.afterPaginate === "string"){
(new Function(pagAjax.afterPaginate))();
}
else{
pagAjax.afterPaginate();
//call standard extra scripts after ajax call
extraScripts();
}
}
catch(e){
//Account for a possible error, maybe call default...
}
}
}
//using history from a page without the paginate container. do upc instead
else{
var pgID = getParameterByFromString("pageID",thisDiv);//get pageID from requestParams
//update page without history, since its the paginate we want in the history
//upc(pgID,pagAjax.requestParams,false);
upc(prevPage,pagAjax.requestParams,false);
}
/*refresh the pagination - doesn't work on level 2 modules
put in the pagAjax because we set a session variable on that
ajax request that our pagination refresh uses*/
if(pagAjax.refreshPag){
var pagNavAjax = ajaxObj();
//attach the class name to the ajax obj so we can use it in the onreadystatechange function
pagNavAjax.moduleClassName = pagAjax.moduleClassName;
pagNavAjax.onreadystatechange=function(){
//don't need to do if we're doing a upc
if($s("mfp-" + pagAjax.moduleClassName)){
if(pagNavAjax.readyState===4) $s("mfp-" + pagAjax.moduleClassName).innerHTML = pagNavAjax.responseText;
}
}
ajaxPost(
pagNavAjax,
"/public/moduleFrame/modulePaginate.php",
pagAjax.requestParams,
true,
0,
null,
0
);
}
}
}
//regular pagination
if(document.getElementById("mfmcc-" + pagAjax.moduleClassName)){
ajaxPost(
pagAjax,
"/public/moduleFrame/moduleInstanceSet.php",
pagAjax.requestParams,
true,
0,
null,
pagAjax.historyTrack
);
}
//using history from a page without the paginate container. do upc instead
else{
if(!isset("tempParams")) {
tempParams = "";
}
document.location = document.URL + "/" + tempParams;
location.reload();
return true;
}
}
//go up/down a pagination page
stealthCommon.prototype.nextPrevPagPage = function(pagePageDir,requestParams){
//next page
if(pagePageDir && (parseInt(this.pagPage) < parseInt(this.maxPagPage))){
this.pagPage++;
requestParams = repSubstr(
requestParams,'%22pagPage%22%3A%22ppToken%22','"pagPage":"' + this.pagPage + '"'
);
window[this.moduleClassName].paginateModule(
requestParams,
$s("pgc-" + this.moduleClassName + "-" + this.pagPage),
this.pagPage,
false,
true
);
}
//previous page
else if(!pagePageDir && (parseInt(this.pagPage)-1 > 0)){
this.pagPage--;
requestParams = repSubstr(
requestParams,'%22pagPage%22%3A%22ppToken%22','"pagPage":"' + this.pagPage + '"'
);
window[this.moduleClassName].paginateModule(
requestParams,
$s("pgc-" + this.moduleClassName + "-" + this.pagPage),
this.pagPage,
false,
true
);
}
}
//show the desired pagination page links
stealthCommon.prototype.nextPrevPages = function(pagePageDir){
//get the first visible page link
var firstEl = $(".pgc.pgcVisible").first();
//get the last visible page link
var lastEl = $(".pgc.pgcVisible").last();
//hide all the page links
$(".pgc").removeClass("pgcVisible").addClass("pgcHidden");
//show next set of page links
if(pagePageDir) {
//show the paginateLinkQty qty of siblings for lastEl element
for(var x = 1; x <= this.paginateLinkQty; x++){
$(lastEl).next().removeClass("pgcHidden").addClass("pgcVisible");
lastEl = $(lastEl).next();
}
}
else{
//show the paginateLinkQty qty of siblings for lastEl element
for(var x = 1; x <= this.paginateLinkQty; x++){
$(firstEl).prev().removeClass("pgcHidden").addClass("pgcVisible");
firstEl = $(firstEl).prev();
}
}
//get the first visible page link
var firstEl = $(".pgc.pgcVisible").first();
//get the last visible page link
var lastEl = $(".pgc.pgcVisible").last();
//check to see if we should hide or show the next/previous buttons
if($(firstEl).prevAll(".pgc").length < 1){
$s("mfprvi-" + this.moduleClassName).style.display = "none";
}
else{
$s("mfprvi-" + this.moduleClassName).style.display = "inline-block";
}
if($(lastEl).nextAll(".pgc").length < this.paginateLinkQty){
$s("mfni-" + this.moduleClassName).style.display = "none";
}
else{
$s("mfni-" + this.moduleClassName).style.display = "inline-block";
}
}
//modules items be click slid should be float:left position:relative
stealthCommon.prototype.clickSlide = function(slideDir,childSlideClass,thisThumb){
if(this.slideFinished){
this.slideFinished = false;
//main module frame
var mf = $s("mfmcc-" + this.moduleClassName);
//storage container
var ms = $s("clss-" + this.moduleClassName);
//current visible objects
var cObjs = $("#mfmcc-" + this.moduleClassName + " .mi-" + this.moduleClassName);
//objects in storage
var stObjs = $("#clss-" + this.moduleClassName + " .mi-" + this.moduleClassName);
var tempModClass = this.moduleClassName;
var tempModChildClass = childSlideClass;
var tempChangeEffectDuration = this.changeEffectDuration;
var tempEffectEasing = this.effectEasing;
if(this.slideAxis == 0){
//the base of where our new elements are positioned, and how far they slide
var slideDistance = mf.offsetWidth;
//distance left or right
if(slideDir) slideDistance = slideDistance * -1;
//we're always accessing the first item, since we're removing them
for(var i = 0; i < this.holdQty; i++){
//create temp objs if stObjs is empty
if(!stObjs[0]){
//properties of temp dom object
var tID = this.moduleClassName + "tmpObj" + i;
var tClass = cObjs[i].className + " tmpObj";
//create DOM object with jquery
var tmpSObj = $('');
tmpSObj = tmpSObj.get(0);
}
else if(slideDir) {
tmpSObj = stObjs[0];
}
else {
tmpSObj = stObjs[stObjs.length-1];
}
//style of the object we're sliding
var tSt = tmpSObj.style;
if(slideDir){
tSt.position = "absolute";
tSt.top = cObjs[i].offsetTop - parseInt(cObjs.eq(i).css("marginTop")) + "px";
//how far it should be offset
tSt.left = mf.offsetWidth + cObjs[i].offsetLeft - parseInt(cObjs.eq(i).css("margin-left")) + "px";
//place the element in the module frame
mf.appendChild(tmpSObj);
}
else{
tSt.position = "absolute";
tSt.top = cObjs[i*2].offsetTop - parseInt(cObjs.eq(i*2).css("marginTop")) + "px";
//how far it should be offset
var tempoffsetLeft = cObjs[i*2].offsetWidth + cObjs[i*2].offsetLeft + parseInt(cObjs.eq(i*2).css("margin-left"));
tSt.left = (tempoffsetLeft * -1) + "px";
//place the element in the module frame
mf.insertBefore(tmpSObj,cObjs[0]);
}
var cObjs = $("#mfmcc-" + this.moduleClassName + " .mi-" + this.moduleClassName);
var stObjs = $("#clss-" + this.moduleClassName + " .mi-" + this.moduleClassName);
//thumb equivalent obj
var tObjs = $("#mfmcc-" + this.childClassName + " .mi-" + this.childClassName);
//visible element's priKeyID from id attr
var tmpSObjPriKeyID = tmpSObj.id.substring(tmpSObj.id.lastIndexOf("-")+1,tmpSObj.id.length);
//look for current element's equivalent in thumb mfmc and set its selected class
for(var t = 0; t < tObjs.length; t++){
tObjs[t].className = repSubstr(tObjs[t].className,"clicked","");
if(tObjs[t].id.indexOf(tmpSObjPriKeyID) != -1) {
tObjs[t].className = tObjs[t].className + " clicked";
}
}
}
/*when we are doing multiple images at once, the callback of the first ones
finish before the later effects even start. use use this counter to keep track
of where we're at so we can do what we need in the callback on the last effect*/
var tempCount = tempHq = this.holdQty * 2;
for(var b = 0; b < tempHq; b++){
if(cObjs[b]){
cObjs.eq(b).animate(
{left:"+=" + slideDistance},
{
//why doesn't this work without eval? - jared
duration:eval(tempChangeEffectDuration),
easing:eval(tempEffectEasing),
complete:function(){
tempCount--; //counter to keep track of what effect we're on
if(!tempCount){ //reset styling, push elements back into storage
var cObjs = $("#mfmcc-" + tempModClass + " .mi-" + tempModClass);
var stObjs = $("#clss-" + tempModClass + " .mi-" + tempModClass);
for(var s = 0; s < tempHq; s++){
//elements going into storage
if(s < window[tempModClass].holdQty){
if(slideDir){
var tempCoStyle = cObjs[0].style;
tempCoStyle.top = tempCoStyle.right = tempCoStyle.left = "auto";
tempCoStyle.position = "relative";
ms.appendChild(cObjs[0]);
}
else{
var thisObjLoc = cObjs.length-1;
var tempCoStyle = cObjs[thisObjLoc].style;
tempCoStyle.top = tempCoStyle.right = tempCoStyle.left = "auto";
tempCoStyle.position = "relative";
//the storage container might be empty if the holdQty is the
//same as the number of elements in the storage container
if(stObjs[0]) {
ms.insertBefore(cObjs[thisObjLoc],stObjs[0]);
}
else {
ms.appendChild(cObjs[thisObjLoc]);
}
}
var cObjs = $("#mfmcc-" + tempModClass + " .mi-" + tempModClass);
var stObjs = $("#clss-" + tempModClass + " .mi-" + tempModClass);
}
//visible items
else{
var thisObjLoc = s-window[tempModClass].holdQty;
var tempCoStyle = cObjs[thisObjLoc].style;
tempCoStyle.top = tempCoStyle.right = tempCoStyle.left = "auto";
tempCoStyle.position = "relative";
//last item
if(s===tempHq-1){
window[tempModClass].slideFinished = true;
//if a child thumb nail is clicked
if(tempModChildClass) {
window[tempModChildClass].parentSlide(thisThumb);
}
}
}
}//loop through pushing hidden elements
}//counter for what effect we're on
}//jquery call back function
}//jquery animate options
);//jquery animate effect
}//if the element exists
else break;
}//if element in for loop exists
}//for loop
}//if slideFinished
} //clickSlide function closer
stealthCommon.prototype.parentSlide = function(thisDiv){
var tempClass = $(".mfmcc").find('div[id*="mfmcc-' + this.parentClassName + '"]');
/*.parents(".mfmc") //get this elements root .mfmc
.prev(".mfmc") // get the parent of the parentClassName, must be the parents prev sibling
.find('div[id^="mfmcc-' + this.parentClassName + '"]'); //and get the parenClassName container*/
var tempParentElement = tempClass.get(0).id;
var tempParentClassName = repSubstr(tempParentElement,"mfmcc-","");
var parentItem = $s(repSubstr(thisDiv.id,this.moduleClassName,tempParentClassName));
var parentFrame = $s("mfmcc-" + tempParentElement);
//clear thumb click style
var thisThumbs = $(".mi-" + this.moduleClassName);
var thumbQty = thisThumbs.length;
$(parentFrame).find(".clicked").removeClass("clicked");
$(thisDiv).addClass("clicked");
//check if the correct item is in its parent
if(parentItem.parentNode.id !== "mfmcc-" + tempParentClassName) {
window[tempParentClassName].clickSlide(1,this.moduleClassName,thisDiv);
}
}
//fadeDir - order of elements to fade through
stealthCommon.prototype.fadeRotate = function(fadeDir){
//try/catch is primarily incase we're in mid fade when we change pages
try{
if(this.slideFinished){
this.slideFinished = false;
var mf = $s("mfmcc-" + this.moduleClassName); //main module frame
var ms = $s("clss-" + this.moduleClassName); //storage container
var cObjs = $("#mfmcc-" + this.moduleClassName + " .mi-" + this.moduleClassName); //current visible objects
var stObjs = $("#clss-" + this.moduleClassName + " .mi-" + this.moduleClassName); //objects in storage
var tempModClass = this.moduleClassName;
var tempChangeEffectDuration = this.changeEffectDuration;
var tempEffectEasing = this.effectEasing;
if(stObjs.length === 0) return true;
//make the child transparent and give it the same positioning
//properties as the element currently in the module container
for(var x = 0; x').val(optionVal).text(optionAtt).appendTo("#" + galleryAjax.formID + " select[name=galleryImageID]");
}
}
}
var requestParams = 'function=getConditionalRecord&a={ "0":"galleryID","1":"' + galID + '","2":"true"}';
ajaxPost(
galleryAjax,
"/cmsAPI/gallery/galleryImages.php",
requestParams,
true,
0,null,false
);
}
function showTimePicker(timeField){
//destroy any existing instances
$(timeField).scroller('destroy');
//create a new scroller that fits well for the window size
$(timeField).scroller({
preset: 'time',
mode: "scroller",
display: "modal",
width:$(window).width()*0.25,
height:$(window).height()*0.20,
stepMinute:15
});
//display the scroller
$(timeField).mobiscroll('show');
}
//get the url param from a string
function getParameterByFromString(name,urlParamString){
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^]*)";
var regex = new RegExp(regexS);
var results = regex.exec(urlParamString);
if(results == null) return "";
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function clearField(textField){
if(textField.defaultValue == textField.value) textField.value = "";
}
function backToDefault(textField){
if(textField.value == "") textField.value = textField.defaultValue;
}
//adds onfocus and onblur event handlers to all text fields within an element which call the functions: "clearField" and "backToDefaut" respectively
function activateShowHideFields(elID){
var inputs = $s(elID).getElementsByTagName("input");
var textareas = $s(elID).getElementsByTagName("textarea");
for(var i = 0; i < inputs.length; i++){
if(inputs[i].type == "text"){
inputs[i].onfocus = function(){
clearField(this);
}
inputs[i].onblur = function(){
backToDefault(this);
}
}
}
for(var i = 0; i < textareas.length; i++){
textareas[i].onfocus = function(){
clearField(this);
}
textareas[i].onblur = function(){
backToDefault(this);
}
}
}
function getProvStates(provStateFieldID,countryFieldID){
var provAjax = ajaxObj();
var countryCode = $s(countryFieldID).value;
provAjax.provStateFieldID = provStateFieldID;
provAjax.onreadystatechange=function(){
//clear out existing provinces and states
$s(provAjax.provStateFieldID).innerHTML = "";
if(provAjax.readyState===4){
var provObj = JSON.parse(provAjax.responseText);
//update our select with new provinces and states
for(var z in provObj){
//create DOM object with jquery
var tmpSObj = $("#" + provAjax.provStateFieldID).append('');
}
}
}
/*fetch provinces and states for selected country - pass JSON to become php array
the cart uses the countryCode, the users module uses the countryID... determine which param to use*/
if(isNumeric(countryCode)) var queryField = "countryID";
else var queryField = "countryCode";
var requestParams = 'function=getConditionalRecord&a={ "0":"' + queryField + '","1":"' + countryCode + '","2":"true"}';
ajaxPost(provAjax,"/cmsAPI/location/provState.php",requestParams,true,0,null,false);
}
function detectIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// IE 12 => return version number
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
// other browser
return false;
}
function setGalleryFancyBox(){
$('.fancyBoxLink').fancybox({
openEffect : 'none',
closeEffect : 'none',
showNavArrows : true,
showCloseButton : true,
opacity: true,
helpers: {
overlay: {
locked: false
}
}
});
}
;
/* HTML5 Placeholder jQuery Plugin - v2.1.2
* Copyright (c)2015 Mathias Bynens
* 2015-06-09
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof module&&module.exports?require("jquery"):jQuery)}(function(a){function b(b){var c={},d=/^jQuery\d+$/;return a.each(b.attributes,function(a,b){b.specified&&!d.test(b.name)&&(c[b.name]=b.value)}),c}function c(b,c){var d=this,f=a(d);if(d.value==f.attr("placeholder")&&f.hasClass(m.customClass))if(f.data("placeholder-password")){if(f=f.hide().nextAll('input[type="password"]:first').show().attr("id",f.removeAttr("id").data("placeholder-id")),b===!0)return f[0].value=c;f.focus()}else d.value="",f.removeClass(m.customClass),d==e()&&d.select()}function d(){var d,e=this,f=a(e),g=this.id;if(""===e.value){if("password"===e.type){if(!f.data("placeholder-textinput")){try{d=f.clone().prop({type:"text"})}catch(h){d=a("").attr(a.extend(b(this),{type:"text"}))}d.removeAttr("name").data({"placeholder-password":f,"placeholder-id":g}).bind("focus.placeholder",c),f.data({"placeholder-textinput":d,"placeholder-id":g}).before(d)}f=f.removeAttr("id").hide().prevAll('input[type="text"]:first').attr("id",g).show()}f.addClass(m.customClass),f[0].value=f.attr("placeholder")}else f.removeClass(m.customClass)}function e(){try{return document.activeElement}catch(a){}}var f,g,h="[object OperaMini]"==Object.prototype.toString.call(window.operamini),i="placeholder"in document.createElement("input")&&!h,j="placeholder"in document.createElement("textarea")&&!h,k=a.valHooks,l=a.propHooks;if(i&&j)g=a.fn.placeholder=function(){return this},g.input=g.textarea=!0;else{var m={};g=a.fn.placeholder=function(b){var e={customClass:"placeholder"};m=a.extend({},e,b);var f=this;return f.filter((i?"textarea":":input")+"[placeholder]").not("."+m.customClass).bind({"focus.placeholder":c,"blur.placeholder":d}).data("placeholder-enabled",!0).trigger("blur.placeholder"),f},g.input=i,g.textarea=j,f={get:function(b){var c=a(b),d=c.data("placeholder-password");return d?d[0].value:c.data("placeholder-enabled")&&c.hasClass(m.customClass)?"":b.value},set:function(b,f){var g=a(b),h=g.data("placeholder-password");return h?h[0].value=f:g.data("placeholder-enabled")?(""===f?(b.value=f,b!=e()&&d.call(b)):g.hasClass(m.customClass)?c.call(b,!0,f)||(b.value=f):b.value=f,g):b.value=f}},i||(k.input=f,l.value=f),j||(k.textarea=f,l.value=f),a(function(){a(document).delegate("form","submit.placeholder",function(){var b=a("."+m.customClass,this).each(c);setTimeout(function(){b.each(d)},10)})}),a(window).bind("beforeunload.placeholder",function(){a("."+m.customClass).each(function(){this.value=""})})}}); $(window).load(function(){
});;
/*
* jQuery appear plugin
*
* Copyright (c) 2012 Andrey Sidorov
* licensed under MIT license.
*
* https://github.com/morr/jquery.appear/
*
* Version: 0.3.4
*/
(function($) {
var selectors = [];
var check_binded = false;
var check_lock = false;
var defaults = {
interval: 250,
force_process: false
}
var $window = $(window);
var $prior_appeared;
function process() {
check_lock = false;
for (var index = 0, selectorsLength = selectors.length; index < selectorsLength; index++) {
var $appeared = $(selectors[index]).filter(function() {
return $(this).is(':appeared');
});
$appeared.trigger('appear', [$appeared]);
if ($prior_appeared) {
var $disappeared = $prior_appeared.not($appeared);
$disappeared.trigger('disappear', [$disappeared]);
}
$prior_appeared = $appeared;
}
}
// "appeared" custom filter
$.expr[':']['appeared'] = function(element) {
var $element = $(element);
if (!$element.is(':visible')) {
return false;
}
var window_left = $window.scrollLeft();
var window_top = $window.scrollTop();
var offset = $element.offset();
var left = offset.left;
var top = offset.top;
if (top + $element.height() >= window_top &&
top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
left + $element.width() >= window_left &&
left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
return true;
} else {
return false;
}
}
$.fn.extend({
// watching for element's appearance in browser viewport
appear: function(options) {
var opts = $.extend({}, defaults, options || {});
var selector = this.selector || this;
if (!check_binded) {
var on_check = function() {
if (check_lock) {
return;
}
check_lock = true;
setTimeout(process, opts.interval);
};
$(window).scroll(on_check).resize(on_check);
check_binded = true;
}
if (opts.force_process) {
setTimeout(process, opts.interval);
}
selectors.push(selector);
return $(selector);
}
});
$.extend({
// force elements's appearance check
force_appear: function() {
if (check_binded) {
process();
return true;
};
return false;
}
});
})(jQuery);
;
pageArray = {"-616":{"name":"\u7a0e\u91d1 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u7a0e\u91d1 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-618":{"name":"\u30ae\u30e3\u30e9\u30ea\u30fc\u753b\u50cf - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u30ae\u30e3\u30e9\u30ea\u30fc\u753b\u50cf - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1231,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-617":{"name":"\u30a4\u30e1\u30fc\u30b8\u00b7\u30ae\u30e3\u30e9\u30ea\u30fc - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u30a4\u30e1\u30fc\u30b8\u00b7\u30ae\u30e3\u30e9\u30ea\u30fc - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1232,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-615":{"name":"\u7a0e\u91d1 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u7a0e\u91d1 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1233,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-614":{"name":"\u30d9\u30f3\u30c0\u30fc - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u30d9\u30f3\u30c0\u30fc - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1234,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-613":{"name":"\u88fd\u54c1\u30ab\u30c6\u30b4\u30ea - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u88fd\u54c1\u30ab\u30c6\u30b4\u30ea - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1235,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-611":{"name":"\u88fd\u54c1\u306e\u4fa1\u683c\u6c34\u6e96 - \u8ffd\u52a0 - \u7de8\u96c6","pageTitle":"\u88fd\u54c1\u306e\u4fa1\u683c\u6c34\u6e96 - \u8ffd\u52a0 - \u7de8\u96c6","pageOrder":1236,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-610":{"name":"\u88fd\u54c1\u30aa\u30d7\u30b7\u30e7\u30f3 - \u8ffd\u52a0 - \u7de8\u96c6","pageTitle":"\u88fd\u54c1\u30aa\u30d7\u30b7\u30e7\u30f3 - \u8ffd\u52a0 - \u7de8\u96c6","pageOrder":1237,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-609":{"name":"\u88fd\u54c1 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u88fd\u54c1 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1238,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-601":{"name":"\u30da\u30fc\u30b8 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageTitle":"\u30da\u30fc\u30b8 - \u30a2\u30c9\u30aa\u30f3\u306e\u7de8\u96c6","pageOrder":1239,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-568":{"name":"\u30ae\u30e3\u30e9\u30ea\u30fc\u753b\u50cf","pageTitle":"\u30ae\u30e3\u30e9\u30ea\u30fc\u753b\u50cf","pageOrder":1240,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-430":{"name":"\u30d1\u30d6\u30ea\u30c3\u30af\u00b7\u30e6\u30fc\u30b6\u30fc - \u8ffd\u52a0 - \u7de8\u96c6","pageTitle":"\u30d1\u30d6\u30ea\u30c3\u30af\u00b7\u30e6\u30fc\u30b6\u30fc - \u8ffd\u52a0 - \u7de8\u96c6","pageOrder":1241,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"0"},"-263":{"name":"Employees - Add-Edit","pageTitle":"Employees - Add-Edit","pageOrder":1242,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-261":{"name":"FAQ - Add-Edit","pageTitle":"FAQ - Add-Edit","pageOrder":1243,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-260":{"name":"Testimonials - Add-Edit","pageTitle":"Testimonials - Add-Edit","pageOrder":1244,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-251":{"name":"Store Order - Add-Edit","pageTitle":"Store Order - Add-Edit","pageOrder":1245,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-249":{"name":"Blog Categories - Add-Edit","pageTitle":"Blog Categories - Add-Edit","pageOrder":1246,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-40":{"name":"Public User Groups - Add-Edit","pageTitle":"Public User Groups - Add-Edit","pageOrder":1247,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"0"},"-262":{"name":"FAQ Categories - Add-Edit","pageTitle":"FAQ Categories - Add-Edit","pageOrder":1248,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-218":{"name":"Gallery Images - Add-Edit","pageTitle":"Gallery Images - Add-Edit","pageOrder":1249,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-217":{"name":"Image Gallery - Add-Edit","pageTitle":"Image Gallery - Add-Edit","pageOrder":1250,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-215":{"name":"Taxes - Add-Edit","pageTitle":"Taxes - Add-Edit","pageOrder":1251,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-214":{"name":"Vendors - Add-Edit","pageTitle":"Vendors - Add-Edit","pageOrder":1252,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-213":{"name":"Product Categories - Add-Edit","pageTitle":"Product Categories - Add-Edit","pageOrder":1253,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-211":{"name":"Product Price Levels - Add-Edit","pageTitle":"Product Price Levels - Add-Edit","pageOrder":1254,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-210":{"name":"Product Options - Add-Edit","pageTitle":"Product Options - Add-Edit","pageOrder":1255,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-209":{"name":"Products - Add-Edit","pageTitle":"Products - Add-Edit","pageOrder":1256,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"0"},"-201":{"name":"Page - Add-Edit","pageTitle":"Page - Add-Edit","pageOrder":1257,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-168":{"name":"Gallery Images","pageTitle":"Gallery Images","pageOrder":1258,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-30":{"name":"Public Users - Add-Edit","pageTitle":"Public Users - Add\\Edit","pageOrder":1259,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"0"},"-567":{"name":"\u30a4\u30e1\u30fc\u30b8\u00b7\u30ae\u30e3\u30e9\u30ea\u30fc","pageTitle":"\u30a4\u30e1\u30fc\u30b8\u00b7\u30ae\u30e3\u30e9\u30ea\u30fc","pageOrder":31,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-502":{"name":"e\u30b3\u30de\u30fc\u30b9","pageTitle":"e\u30b3\u30de\u30fc\u30b9","pageOrder":61,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-566":{"name":"\u53d7\u6ce8","pageTitle":"\u53d7\u6ce8","pageOrder":62,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-565":{"name":"\u7a0e\u91d1","pageTitle":"\u7a0e\u91d1","pageOrder":92,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-564":{"name":"\u30d9\u30f3\u30c0\u30fc","pageTitle":"\u30d9\u30f3\u30c0\u30fc","pageOrder":122,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-563":{"name":"\u88fd\u54c1\u30ab\u30c6\u30b4\u30ea","pageTitle":"\u88fd\u54c1\u30ab\u30c6\u30b4\u30ea","pageOrder":152,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-562":{"name":"\u88fd\u54c1\u306e\u4fa1\u683c\u6c34\u6e96","pageTitle":"\u88fd\u54c1\u306e\u4fa1\u683c\u6c34\u6e96","pageOrder":182,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-561":{"name":"\u88fd\u54c1\u30aa\u30d7\u30b7\u30e7\u30f3","pageTitle":"\u88fd\u54c1\u30aa\u30d7\u30b7\u30e7\u30f3","pageOrder":212,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-560":{"name":"\u88fd\u54c1","pageTitle":"\u88fd\u54c1","pageOrder":242,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-502","pageLevel":"2"},"-425":{"name":"\u30d1\u30d6\u30ea\u30c3\u30af\u00b7\u30e6\u30fc\u30b6\u30fc","pageTitle":"\u30d1\u30d6\u30ea\u30c3\u30af\u00b7\u30e6\u30fc\u30b6\u30fc","pageOrder":301,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"-250":{"name":"Blog - Add-Edit","pageTitle":"Blog - Add-Edit","pageOrder":331,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-150":{"name":"News and Blog","pageTitle":"News and Blog","pageOrder":361,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-151":{"name":"News and Blog Categories","pageTitle":"News and Blog Categories","pageOrder":362,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-150","pageLevel":"2"},"-10":{"name":"Administration Login","pageTitle":"Administration Login","pageOrder":421,"pageLoaded":0,"preUpdate":null,"afterComplete":null,"postUpdate":null,"members":"0","parentPageID":"0","pageLevel":"1"},"2402":{"name":"gallery","pageTitle":"gallery","pageOrder":451,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"1":{"name":"Home","pageTitle":"Home","pageOrder":481,"pageLoaded":0,"preUpdate":null,"afterComplete":null,"postUpdate":null,"members":"0","parentPageID":"0","pageLevel":"1"},"2396":{"name":"Specials","pageTitle":"Specials","pageOrder":511,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"2227":{"name":"Gallery","pageTitle":"Gallery","pageOrder":541,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"2385":{"name":"Services","pageTitle":"Services","pageOrder":571,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"2214":{"name":"News","pageTitle":"News","pageOrder":601,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"2230":{"name":"Contact","pageTitle":"Contact Us","pageOrder":631,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"0","pageLevel":"1"},"-11":{"name":"Dashboard","pageTitle":"Dashboard","pageOrder":661,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-101":{"name":"Edit Content","pageTitle":"Page List","pageOrder":691,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-501":{"name":"\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u7de8\u96c6","pageTitle":"\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u7de8\u96c6","pageOrder":721,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-216":{"name":"Taxes - Add-Edit","pageTitle":"Taxes - Add-Edit","pageOrder":751,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-173":{"name":"Employees","pageTitle":"Employees","pageOrder":781,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-171":{"name":"FAQ","pageTitle":"FAQ","pageOrder":811,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-172":{"name":"FAQ Categories","pageTitle":"FAQ Categories","pageOrder":812,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-171","pageLevel":"2"},"-170":{"name":"Testimonials","pageTitle":"Testimonials","pageOrder":871,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-167":{"name":"Image Gallery","pageTitle":"Image Gallery","pageOrder":901,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-102":{"name":"Ecommerce","pageTitle":"Ecommerce","pageOrder":931,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-166":{"name":"Orders","pageTitle":"Orders","pageOrder":932,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-165":{"name":"Taxes","pageTitle":"Taxes","pageOrder":962,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-164":{"name":"Vendors","pageTitle":"Vendors","pageOrder":992,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-163":{"name":"Product Categories","pageTitle":"Product Categories","pageOrder":1022,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-162":{"name":"Product Price Level","pageTitle":"Product Price Levels","pageOrder":1052,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-161":{"name":"Product Option","pageTitle":"Product Options","pageOrder":1082,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-160":{"name":"Store Products","pageTitle":"Store Products","pageOrder":1112,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"-102","pageLevel":"2"},"-25":{"name":"Public Users","pageTitle":"Public User List","pageOrder":1171,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"1","parentPageID":"0","pageLevel":"1"},"-35":{"name":"Public User Groups","pageTitle":"Public User Groups","pageOrder":1172,"pageLoaded":0,"preUpdate":"","afterComplete":"","postUpdate":"","members":"0","parentPageID":"-25","pageLevel":"2"}};
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
singlePageSite = false;
;
pageID = ;//global pageID
prevPage = 0;
pageName = "";//global pageName - do we use this?
String.prototype.salt = "";
seoFolderName = "";//do we use this?
speedURL = ""; //2nd url for > 2 http requests
pageInterTime = {}; //objects for timeouts and intervals on a page, properties are the cms classNames
standardInterTime = {}; //objects for timeouts and intervals that are standard, properties are the cms classNames
(function(window,undefined){
var History = window.History; //create History object
historyBool = false; //set historyBool for initial push
historySet =
{
ajaxRunFunction:
"upc('" + pageID + "',window.location.search)"
};
History.pushState(historySet,"","");
historyBool = true; //true is our default
// Note: We are using statechange instead of popstate
History.Adapter.bind(window,'statechange',function(){
// Note: We are using History.getState() instead of event.state
var State = History.getState();
//don't run our function when we do a pushState
if(
historyBool &&
typeof(State.data.ajaxRunFunction) !== "undefined"
){
historyBool = false;
tempFunction = new Function(State.data.ajaxRunFunction);
tempParams = State.data.hisUrlParams;
tempFunction();
}
//set to our default of true
historyBool = true;
return true;
});
})(window);
$(window).load(function(){
historyBool = true; //true is our default
});