'
});
},
simpleConfirm: function(type, message, callback) {
var btnColorType = 'default';
switch(type) {
case 'alert' :
btnColorType = 'danger';
break;
default :
btnColorType = type;
break;
}
BootstrapDialog.confirm(false, type, false,
lang(message),
false, false, callback, [ {
label: lang('cancel'),
cssClass: 'btn-default',
action: function(dialog) {
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
dialog.close();
}
}, {
label: lang('enter'),
cssClass: 'btn-' + btnColorType,
action: function(dialog) {
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true);
dialog.close();
}
} ]
)
},
simpleAjax: function(ajaxOptions, doneCallBack, failCallBack) {
$.ajax(ajaxOptions).done(function(data, textStatus, jqXHR) {
if(doneCallBack && typeof (doneCallBack) == 'function') {
doneCallBack(data, textStatus, jqXHR);
}
}).fail(function(data, textStatus, jqXHR) {
if(failCallBack && typeof (failCallBack) == 'function') {
failCallBack(data, textStatus, jqXHR);
} else {
console.warn(data, textStatus, jqXHR);
}
});
},
windowFocus: function($windowFocusFunc, $windowBlurFunc, $tabFocusFunc, $tabBlurFunc) {
//Main visibility API function
//Use visibility API to check if current tab is active or not
var vis = (function() {
var stateKey, eventKey,
keys = {
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
};
for(stateKey in keys) {
if(stateKey in document) {
if(keys[ stateKey ]) {
eventKey = keys[ stateKey ];
break;
}
}
}
return function(c) {
if(c) {
document.addEventListener(eventKey, c);
} else {
return !document[ stateKey ];
}
}
})();
//Check if current tab is active or not
vis(function() {
if(vis()) {
// tween resume() code goes here
if($tabFocusFunc && typeof ($tabFocusFunc) !== 'undefined') {
$tabFocusFunc();
}
} else {
// tween pause() code goes here
if($tabBlurFunc && typeof ($tabBlurFunc) !== 'undefined') {
$tabBlurFunc();
}
}
});
//Check if browser window has focus
var notIE = (document.documentMode === undefined),
isChromium = window.chrome;
if(notIE && !isChromium) {
// checks for Firefox and other NON IE Chrome versions
$(window).on("focusin", function() {
// tween resume() code goes here
if($windowFocusFunc && typeof ($windowFocusFunc) !== 'undefined') {
$windowFocusFunc();
}
}).on("focusout", function() {
// tween pause() code goes here
if($windowBlurFunc && typeof ($windowBlurFunc) !== 'undefined') {
$windowBlurFunc();
}
});
} else {
// checks for IE and Chromium versions
if(window.addEventListener) {
// bind focus event
window.addEventListener("focus", function(event) {
// tween resume() code goes here
if($windowFocusFunc && typeof ($windowFocusFunc) !== 'undefined') {
$windowFocusFunc();
}
}, false);
// bind blur event
window.addEventListener("blur", function(event) {
// tween pause() code goes here
if($windowBlurFunc && typeof ($windowBlurFunc) !== 'undefined') {
$windowBlurFunc();
}
}, false);
} else {
// bind focus event
window.attachEvent("focus", function(event) {
// tween resume() code goes here
if($windowFocusFunc && typeof ($windowFocusFunc) !== 'undefined') {
$windowFocusFunc();
}
});
// bind focus event
window.attachEvent("blur", function(event) {
// tween pause() code goes here
if($windowBlurFunc && typeof ($windowBlurFunc) !== 'undefined') {
$windowBlurFunc();
}
});
}
}
},
/*Like PHP Function*/
in_array: function(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[ i ] == needle) return true;
}
return false;
},
urlencode: function(str) {
str = (str + '').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
},
http_build_query: function(formdata, numeric_prefix, arg_separator) {
var value, key, tmp = [];
var _http_build_query_helper = function(key, val, arg_separator) {
var k, tmp = [];
if(val === true) {
val = "1";
} else if(val === false) {
val = "0";
}
if(val !== null && typeof (val) === "object") {
for(k in val) {
if(val[ k ] !== null) {
tmp.push(_http_build_query_helper(key + "[" + k + "]", val[ k ], arg_separator));
}
}
return tmp.join(arg_separator);
} else if(typeof (val) !== "function") {
return cms.urlencode(key) + "=" + cms.urlencode(val);
} else if(typeof (val) == "function") {
return '';
} else {
throw new Error('There was an error processing for http_build_query().');
}
};
if(!arg_separator) {
arg_separator = "&";
}
for(key in formdata) {
value = formdata[ key ];
if(numeric_prefix && !isNaN(key)) {
key = String(numeric_prefix) + key;
}
tmp.push(_http_build_query_helper(key, value, arg_separator));
}
return tmp.join(arg_separator);
}
/*Like PHP Function*/
};
var tempData = {};
tempData[ 'lang' ] = {};
function lang(code, langID, codecheck) {
var span = false;
var start_span, end_span;
if(!code) return '';
code = code;
if((new RegExp("^span:.*")).test(code)) {
span = true;
code = code.replace('span:', '');
}
if(!langID) langID = tempData[ 'currentLangID' ];
if(span) {
//font-size:'+$('body').css('font-size')+';line-height:'+$('body').css('line-height')+';
start_span = '';
end_span = '';
} else {
start_span = '';
end_span = '';
}
var errorCode = start_span + (codecheck ? '400' : code) + end_span;
if(tempData[ 'lang' ]) {
if(langID in tempData[ 'lang' ] && typeof tempData[ 'lang' ][ langID ] !== 'undefined') {
var $breakSpace = false;
if('breakspace' in tempData[ 'lang' ][ langID ]) $breakSpace = tempData[ 'lang' ][ langID ][ 'breakspace' ];
if(code in tempData[ 'lang' ][ langID ]) {
return start_span + tempData[ 'lang' ][ langID ][ code ] + end_span;
} else {
return code;
// var final = code;
// if(code.match(/(_|-|:)/g)){
// var langItems = code.split(":");
// if($.isArray(langItems)){
// $.each(langItems ,function(k,subLangItems){
// var word = '';
// if(subLangItems in tempData['lang'][langID]){
// word = tempData['lang'][langID][subLangItems];
// var reg = new RegExp(word,"g");
// final = subLangItems.replace(reg,final);
// } else {
// subLangItems = subLangItems.split("_");
// var fullString = [];
// if($.isArray(subLangItems)) $.each(subLangItems ,function(ik,$subItems){
// var word;
// if($subItems in tempData['lang'][langID]){
// word = tempData['lang'][langID][$subItems];
// var reg = new RegExp(word,"g");
// fullString.push(word);
// } else {
// fullString.push($subItems);
// }
// });
// final = fullString.join("_");
// }
// });
// }
// if(!$breakSpace) {
// final = final.replace(/(_|-)/g,"");
// }
// if($breakSpace) {
// final = final.replace(/(_|-)/g," ");
// }
// return final;
// } else {
// return errorCode;
// }
}
} else {
return code;
}
} else {
return errorCode;
}
}
function LoadLangPackage(langID, callback, update) {
$(document).trigger('reloadLayout');
var mainHandler = function() {
if(!tempData[ 'lang' ]) tempData[ 'lang' ] = {};
if(!langID && clang > 0) {
langID = clang;
} else {
if(!(langID >= 0) || langID == null) {
langID = 2;
}
}
var obj;
var handler = function() {
if(tempData[ 'oldLangID' ] != tempData[ 'currentLangID' ]) {
obj = $('.langPack');
} else {
obj = $('.langPack:not(.langEcho)');
obj = $('.langPack');
}
$(obj).each(function() {
var $this = $(this);
if($this.hasClass('langSpan')) {
$this.css({
'width': 'auto',
'height': 'auto',
'display': '',
'position': 'relative',
'float': 'none',
'padding': '0px',
'margin': '0px',
'top': '0px',
'left': '0px',
'font-size': $('body').css('font-size'),
'line-height': $('body').css('line-height')
});
}
var rawlangCode = $this.attr('lang');
if(rawlangCode) {
if((new RegExp("^attr:.*")).test(rawlangCode)) {
rawlangCode = rawlangCode.replace('attr:', '');
rawlangCode = rawlangCode.split(":");
if(rawlangCode.length > 1) {
$this.attr(rawlangCode[ 0 ], lang(rawlangCode[ 1 ]));
}
} else {
if(tempData[ 'oldLangID' ] != tempData[ 'currentLangID' ]) {
rawlangCode = rawlangCode.replace('pp:', '').replace('ap:', '').replace('ib:', '').replace('ia:', '');
$this.contents().filter(function() {
return this.nodeType == 3
}).each(function() {
if(this.textContent) {
this.textContent = this.textContent.replace(lang(rawlangCode, tempData[ 'oldLangID' ]), lang(rawlangCode, tempData[ 'currentLangID' ]));
} else {
location.reload();
}
});
} else {
if(!($this.hasClass('langEcho'))) {
if((new RegExp("^pp:.*")).test(rawlangCode)) {
if(!((new RegExp("^" + lang(rawlangCode.replace('pp:', '')) + ".*")).test($this.html()))) {
$this.prepend(lang(rawlangCode.replace('pp:', '')));
}
} else if((new RegExp("^ap:.*")).test(rawlangCode)) {
if(!((new RegExp(".*" + lang(rawlangCode.replace('ap:', '')) + "$")).test($this.html()))) {
$this.append(lang(rawlangCode.replace('ap:', '')));
}
} else if((new RegExp("^ib:.*")).test(rawlangCode)) {
$this.insertBefore(lang(rawlangCode.replace('ib:', '')));
} else if((new RegExp("^ia:.*")).test(rawlangCode)) {
$this.insertAfter(lang(rawlangCode.replace('ia:', '')));
} else {
$this.text(lang(rawlangCode));
}
$this.addClass('langEcho');
}
}
}
}
});
if(tempData[ 'oldLangID' ] != tempData[ 'currentLangID' ]) {
tempData[ 'oldLangID' ] = tempData[ 'currentLangID' ];
}
if(callback && typeof (callback) === "function") {
callback.call();
}
cms.setCookie('lang', tempData[ 'currentLangID' ], 10);
clang = tempData[ 'currentLangID' ];
$(document).trigger('langPackLoaded');
};
if(langID > 0) {
if(langID in tempData[ 'lang' ]) {
tempData[ 'currentLangID' ] = langID;
if(!(tempData[ 'oldLangID' ] >= 0)) tempData[ 'oldLangID' ] = langID;
handler();
} else {
if('isExportMode' in window || 'skipAjaxLang' in window) {
if(callback && typeof (callback) === "function") {
callback.call();
}
$(document).trigger('langPackLoaded');
} else {
$.ajax({
url: root_header_path + 'lib/ajax/lang/get/',
data: {
lang: langID
},
type: 'GET',
dataType: "json",
error: function(data) {
tempData[ 'lang' ][ langID ] = data.lang;
tempData[ 'currentLangID' ] = langID;
if(!(tempData[ 'oldLangID' ] >= 0)) tempData[ 'oldLangID' ] = langID;
handler();
},
success: function(data) {
tempData[ 'lang' ][ langID ] = data.lang;
tempData[ 'currentLangID' ] = langID;
if(!(tempData[ 'oldLangID' ] >= 0)) tempData[ 'oldLangID' ] = langID;
handler();
}
});
}
}
} else {
handler();
}
};
if(update && langID > 0 && (tempData[ 'oldLangID' ] != tempData[ 'currentLangID' ])) {
mainHandler();
} else {
mainHandler();
}
}
$(window).load(function() {
if(!clang) clang = 1;
LoadLangPackage(clang, function() {
$(document).trigger("langLoaded");
$("body").addClass("langLoaded");
});
});
var pad = function(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
};
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
}
var waitForFinalEvent = (function() {
var timers = {};
return function(callback, ms, uniqueId) {
if(!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if(timers[ uniqueId ]) {
clearTimeout(timers[ uniqueId ]);
}
timers[ uniqueId ] = setTimeout(callback, ms);
};
})();
$.fn.extend({
animateCss: function(animationName) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
$(this).addClass('animated ' + animationName).one(animationEnd, function() {
$(this).removeClass('animated ' + animationName);
});
}
});
$(document).ready(function() {
$("[data-animation]").each(function() {
var thisData = ($(this).attr('data-animation')).split(",");
var $this = this;
switch(thisData[ 1 ]) {
case 'hover':
$($this).hover(function() {
$(this).animateCss(thisData[ 0 ]);
});
break;
case 'hover-long':
$($this).hover(function() {
switch(thisData[ 0 ]) {
case 'scale':
if($(this).attr("data-animation-target")) {
$(this).find($(this).attr("data-animation-target")).addClass("hoverScale");
$(this).find($(this).attr("data-animation-target")).addClass("hoverScaled");
} else {
$(this).addClass("hoverScale");
$(this).addClass("hoverScaled");
}
break;
default:
$($this).hover(function() {
$(this).animateCss(thisData[ 0 ]);
});
break;
}
}, function() {
switch(thisData[ 0 ]) {
case 'scale':
if($(this).attr("data-animation-target")) {
var $target = $(this).find($(this).attr("data-animation-target"));
$($target).removeClass("hoverScale");
setTimeout(function() {
if(!$($target).hasClass("hoverScale")) {
$($target).removeClass("hoverScaled");
}
}, 500);
} else {
$(this).removeClass("hoverScale");
setTimeout(function() {
if(!$($this).hasClass("hoverScale")) {
$($this).removeClass("hoverScaled");
}
}, 500);
}
break;
default:
break;
}
});
break;
}
});
});
var getPercentage = function(orgValue, str) {
var s = "%";
if(str.indexOf(s) > -1) {
return orgValue * (parseInt(str.replace("%", "")) / 100);
} else {
return parseInt(str.replace("%", ""));
}
};
var positionObj = function(thisObj) {
var obj = $(thisObj);
if(obj.hasClass("reset-animate-me")) {
console.log('reset-animate-me');
$($this).css({
'-webkit-transform': 'scale(' + ratio + ')',
'-moz-transform': 'scale(' + ratio + ')',
'-ms-transform': 'scale(' + ratio + ')',
'-o-transform': 'scale(' + ratio + ')',
'transform': 'scale(' + ratio + ')'
});
obj.css({
'top': '0px',
'left': '0px',
'margin-left': '0px',
'margin-top': '0px'
});
return;
}
var $this = obj;
var baseWidth = $(obj).attr('data-base-scale-width');
var refObj = $(obj).attr(' data-base-scale-min="0.9" data-base-scale-obj-ref');
var minRatio = $(obj).attr('data-base-scale-min');
var maxRatio = $(obj).attr('data-base-scale-max');
var targetObj = $(obj).parent();
if(refObj) {
targetObj = $(refObj);
}
var ratio = $(targetObj).width() / baseWidth;
if(minRatio) if(ratio < minRatio) ratio = minRatio;
if(maxRatio) if(ratio > maxRatio) ratio = maxRatio;
$($this).css({
'-webkit-transform': 'scale(' + ratio + ')',
'-moz-transform': 'scale(' + ratio + ')',
'-ms-transform': 'scale(' + ratio + ')',
'-o-transform': 'scale(' + ratio + ')',
'transform': 'scale(' + ratio + ')'
});
var targetX = obj.attr('data-center-x');
var targetY = obj.attr('data-center-y');
if($(window).width() < 1200) {
var mdY = obj.attr('data-center-y-md');
if(mdY) targetY = mdY;
var mdX = obj.attr('data-center-x-md');
if(mdX) targetX = mdX;
}
if($(window).width() < 992) {
var smY = obj.attr('data-center-y-sm');
if(smY) targetY = smY;
var smX = obj.attr('data-center-x-sm');
if(smX) targetX = smX;
}
if($(window).width() < 768) {
var xsY = obj.attr('data-center-y-xs');
if(xsY) targetY = xsY;
var xsX = obj.attr('data-center-x-xs');
if(xsX) targetX = xsX;
}
if(targetY == "bottom" || targetY == "top") {
var thisWidth = obj.width();
var thisHeight = obj.height();
var css = {
left: (targetX ? getPercentage(targetObj.width(), targetX) : "0px"),
'margin-left': '-' + (targetX ? thisWidth / 2 : 0) + 'px',
'margin-top': '0px'
};
if(targetY == "bottom") {
css[ 'bottom' ] = "0";
}
if(targetY == "top") {
css[ 'top' ] = "0";
}
} else {
var thisWidth = obj.width();
var thisHeight = obj.height();
var css = {
left: (targetX ? getPercentage(targetObj.width(), targetX) : "0px"),
top: getPercentage(targetObj.height(), targetY),
'margin-left': '-' + (targetX ? thisWidth / 2 : 0) + 'px',
'margin-top': '-' + (targetY ? thisHeight / 2 : 0) + 'px'
};
}
obj.css(css);
};
var animateMe = function() {
$(".animate-me,.reset-animate-me").each(function() {
var $this = this;
positionObj($this);
if(!$($this).attr('id')) $($this).attr('id', cms.makeID());
$(window).resize(function() {
waitForFinalEvent(function() {
positionObj($this);
setTimeout(function() {
positionObj($this);
}, 500);
}, 200, "id-" + $($this).attr('id'))
});
});
$("[data-refHeight]").each(function() {
var $this = this;
var obj = $($this).attr('data-refHeight');
var thisHeight = "auto";
if($(obj).length) {
thisHeight = $(obj).first().outerHeight();
}
$($this).height(thisHeight);
});
$("[data-flex-col]").each(function() {
var totalCol = 0;
$(this).parent().children("[data-flex-col]").each(function() {
var thisCol = parseInt($(this).attr('data-flex-col'));
if(thisCol) totalCol += thisCol
});
var othersHeight = 0;
$(this).parent().children().not("[data-flex-col]").not(".LoadingDiv").filter(function() {
var position = $(this).css('position');
return position !== 'absolute';
}).each(function() {
othersHeight += $(this).outerHeight();
});
var thisHeight = ($(this).parent().height() - othersHeight) / totalCol * parseInt($(this).attr('data-flex-col'));
$(this).height(thisHeight);
});
$("[data-flex-row]").each(function() {
var totalCol = 0;
$(this).parent().children("[data-flex-row]").each(function() {
var thisCol = parseInt($(this).attr('data-flex-row'));
if(thisCol) totalCol += thisCol
});
var othersWidth = 0;
$(this).parent().children().not("[data-flex-row]").not(".LoadingDiv").filter(function() {
var position = $(this).css('position');
return position !== 'absolute';
}).each(function() {
othersWidth += $(this).outerWidth();
});
var thisWidth = ($(this).parent().width() - othersWidth) / totalCol * parseInt($(this).attr('data-flex-row'));
$(this).width(thisWidth);
});
};
var initBackstretchImage = function() {
$("[data-backstretchImage]").each(function() {
var imagePath = $(this).attr('data-backstretchImage');
if(imagePath) $(this).resizeOrInitBackstretch(imagePath);
});
$("[data-xs-class],[data-sm-class],[data-md-class],[data-lg-class]").each(function() {
var dataXS = $(this).attr('data-xs-class');
var dataSM = $(this).attr('data-sm-class');
var dataMD = $(this).attr('data-md-class');
var dataLG = $(this).attr('data-lg-class');
$(this).removeClass(dataXS);
$(this).removeClass(dataSM);
$(this).removeClass(dataMD);
$(this).removeClass(dataLG);
$(this).addClass(dataXS);
if($(window).width() >= 768) {
$(this).removeClass(dataXS);
$(this).addClass(dataSM);
}
if($(window).width() >= 992) {
$(this).removeClass(dataXS);
$(this).removeClass(dataSM);
$(this).addClass(dataMD);
}
if($(window).width() >= 1200) {
$(this).removeClass(dataXS);
$(this).removeClass(dataSM);
$(this).removeClass(dataMD);
$(this).addClass(dataLG);
}
});
};
$(document).bind("refHeightLoaded.positionObj", function() {
$(document).unbind("refHeightLoaded.positionObj");
animateMe();
var callback = function() {
initBackstretchImage();
};
callback();
$(window).resize(function() {
callback();
setTimeout(callback, 500);
});
});
$(window).load(function() {
if(!('noReFontSize' in window)) {
var f = cms.getCookie('font-size');
if(f) {
$('a[rel=' + f + ']')
.addClass('fontSizeActive')
.siblings()
.removeClass('fontSizeActive');
$.switchFontSize(f); // 20131126 added
}
}
$('.fontSizeM, .fontSizeL, .fontSizeEx')
.attr('href', 'javascript:void(0)')
.click(function(e) {
$('.fontSizeM, .fontSizeL, .fontSizeEx').removeClass("fontSizeActive");
$.switchFontSize($(this).attr('rel'));
$(this)
.addClass('fontSizeActive')
.siblings()
.removeClass('fontSizeActive');
});
if($(".scrollToObj").length) {
$('html, body').stop(true).animate({
scrollTop: $(".scrollToObj").offset().top
}, 500);
}
});
var fontChangeCall = false;
$.switchFontSize = function(fz) {
// console.log(fz);
// 20131126: remove all font class
// $(".mainContainer *").each(function () {
// var $this = this;
// if (!$($this).attr('data-org-font-size')) {
// $($this).attr('data-org-font-size', $(this).css('font-size'));
// }
// });
// var runCallback = function () {
// $(".mainContainer *").each(function () {
// var $this = this;
// if (!$($this).attr('data-org-font-size')) {
// $($this).attr('data-org-font-size', $($this).css('font-size'));
// }
// var newFontSize = $($this).attr('data-org-font-size');
// switch (fz) {
// case 'font-size-largest':
// newFontSize = (parseInt(newFontSize.replace('px', '')) + 2) + 'px';
// $($this).get(0).style.setProperty('font-size', newFontSize, 'important');
// break;
// case 'font-size-larger':
// newFontSize = (parseInt(newFontSize.replace('px', '')) + 1) + 'px';
// $($this).get(0).style.setProperty('font-size', newFontSize, 'important');
// break;
// default:
// $($this).get(0).style.setProperty('font-size', newFontSize, 'important');
// break;
// }
// });
//
// };
// runCallback();
if(fontChangeCall) clearInterval(fontChangeCall);
if(fz == "font-size-largest" || fz == "font-size-larger") {
fontChangeCall = setInterval(runCallback, 200);
}
cms.setCookie('font-size', fz);
if('refHeight' in window) refHeight();
};
var isCtrl = false;
var isShift = false;
var adminLoginOpen = false;
function initAdminMode() {
if("FRONTEND_IS_ADMIN" in window && !FRONTEND_IS_ADMIN) {
$(document).keyup(function(e) {
if(e.which == 17) {
isCtrl = false;
}
if(e.which == 16) {
isShift = false;
}
});
$(document).keydown(function(e) {
if(e.which == 17) {
isCtrl = true;
}
if(e.which == 16) {
isShift = true;
}
//ctrl + shift + a
if(e.which == 65 && isCtrl && isShift && adminLoginOpen === false) {
adminLoginOpen = true;
console.log("Admin mode open");
cmsPath = root_header_path;
loadPopupForm('Admin Login', cmsPath + 'cccframework/cccApp/getApp/?app=front-login&client_id=' + CLIENT_ID, cmsPath + '|cccms/ucp/api/ucp-v1/login/front', "", "modal-lg", function(thisApp, dialog) {
thisApp.onSave = function(data) {
if(data[ "status" ] == "1") {
cms.loadingDiv("body");
$.ajax({
url: root_header_path + 'cccframework/admin-mode/',
data: {
token: data[ "data" ][ "token" ],
user_id: data[ "data" ][ "user_id" ],
},
type: 'GET',
dataType: "json",
error: function(data) {
cms.removeLoadingDiv("body");
},
success: function(data) {
cms.removeLoadingDiv("body");
location.reload();
}
});
dialog.close();
}
};
}, function() {
adminLoginOpen = false;
}, false, true);
}
});
}
}
function frontAdminLogout() {
cms.loadingDiv("body");
$.ajax({
url: root_header_path + 'cccframework/admin-mode/logout/',
data: {},
type: 'GET',
dataType: "json",
error: function(data) {
cms.removeLoadingDiv("body");
},
success: function(data) {
location.reload();
cms.removeLoadingDiv("body");
}
});
}
function enableTranslateMode(value) {
cms.loadingDiv("body");
$.ajax({
url: root_header_path + 'cccframework/admin-mode/translate/',
data: {
mode: value
},
type: 'GET',
dataType: "json",
error: function(data) {
cms.removeLoadingDiv("body");
},
success: function(data) {
location.reload();
cms.removeLoadingDiv("body");
}
});
}
function enableSiteSetting(value) {
cms.loadingDiv("body");
$.ajax({
url: root_header_path + 'cccframework/admin-mode/site-setting/',
data: {
mode: value
},
type: 'GET',
dataType: "json",
error: function(data) {
cms.removeLoadingDiv("body");
},
success: function(data) {
location.reload();
cms.removeLoadingDiv("body");
}
});
}
$(document).ready(function() {
if("FRONTEND_LOGIN" in window && FRONTEND_LOGIN) {
initAdminMode();
}
});
!function (n) {
"use strict";
function t(n, t) {
var r = (65535 & n) + (65535 & t);
return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r
}
function r(n, t) {
return n << t | n >>> 32 - t
}
function e(n, e, o, u, c, f) {
return t(r(t(t(e, n), t(u, f)), c), o)
}
function o(n, t, r, o, u, c, f) {
return e(t & r | ~t & o, n, t, u, c, f)
}
function u(n, t, r, o, u, c, f) {
return e(t & o | r & ~o, n, t, u, c, f)
}
function c(n, t, r, o, u, c, f) {
return e(t ^ r ^ o, n, t, u, c, f)
}
function f(n, t, r, o, u, c, f) {
return e(r ^ (t | ~o), n, t, u, c, f)
}
function i(n, r) {
n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r;
var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878;
for (e = 0; e < n.length; e += 16) i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h);
return [l, g, v, m]
}
function a(n) {
var t, r = "", e = 32 * n.length;
for (t = 0; t < e; t += 8) r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
return r
}
function d(n) {
var t, r = [];
for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1) r[t] = 0;
var e = 8 * n.length;
for (t = 0; t < e; t += 8) r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
return r
}
function h(n) {
return a(i(d(n), 8 * n.length))
}
function l(n, t) {
var r, e, o = d(n), u = [], c = [];
for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1) u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r];
return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640))
}
function g(n) {
var t, r, e = "";
for (r = 0; r < n.length; r += 1) t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t);
return e
}
function v(n) {
return unescape(encodeURIComponent(n))
}
function m(n) {
return h(v(n))
}
function p(n) {
return g(m(n))
}
function s(n, t) {
return l(v(n), v(t))
}
function C(n, t) {
return g(s(n, t))
}
function A(n, t, r) {
return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n)
}
"function" == typeof define && define.amd ? define(function () {
return A
}) : "object" == typeof module && module.exports ? module.exports = A : n.md5 = A
}(this);
/*!
* jQuery Mousewheel 3.1.13
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS style for Browserify
module.exports = factory;
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ('onwheel' in document || document.documentMode >= 9) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if ($.event.fixHooks) {
for (var i = toFix.length; i;) {
$.event.fixHooks[toFix[--i]] = $.event.mouseHooks;
}
}
var special = $.event.special.mousewheel = {
version: '3.1.12',
setup: function () {
if (this.addEventListener) {
for (var i = toBind.length; i;) {
this.addEventListener(toBind[--i], handler, false);
}
} else {
this.onmousewheel = handler;
}
// Store the line height and page height for this particular element
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
},
teardown: function () {
if (this.removeEventListener) {
for (var i = toBind.length; i;) {
this.removeEventListener(toBind[--i], handler, false);
}
} else {
this.onmousewheel = null;
}
// Clean up the data we added to the element
$.removeData(this, 'mousewheel-line-height');
$.removeData(this, 'mousewheel-page-height');
},
getLineHeight: function (elem) {
var $elem = $(elem),
$parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
if (!$parent.length) {
$parent = $('body');
}
return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
},
getPageHeight: function (elem) {
return $(elem).height();
},
settings: {
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
normalizeOffset: true // calls getBoundingClientRect for each event
}
};
$.fn.extend({
mousewheel: function (fn) {
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
},
unmousewheel: function (fn) {
return this.unbind('mousewheel', fn);
}
});
function handler(event) {
var orgEvent = event || window.event,
args = slice.call(arguments, 1),
delta = 0,
deltaX = 0,
deltaY = 0,
absDelta = 0,
offsetX = 0,
offsetY = 0;
event = $.event.fix(orgEvent);
event.type = 'mousewheel';
// Old school scrollwheel delta
if ('detail' in orgEvent) {
deltaY = orgEvent.detail * -1;
}
if ('wheelDelta' in orgEvent) {
deltaY = orgEvent.wheelDelta;
}
if ('wheelDeltaY' in orgEvent) {
deltaY = orgEvent.wheelDeltaY;
}
if ('wheelDeltaX' in orgEvent) {
deltaX = orgEvent.wheelDeltaX * -1;
}
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
if ('axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
deltaX = deltaY * -1;
deltaY = 0;
}
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
delta = deltaY === 0 ? deltaX : deltaY;
// New school wheel delta (wheel event)
if ('deltaY' in orgEvent) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ('deltaX' in orgEvent) {
deltaX = orgEvent.deltaX;
if (deltaY === 0) {
delta = deltaX * -1;
}
}
// No change actually happened, no reason to go any further
if (deltaY === 0 && deltaX === 0) {
return;
}
// Need to convert lines and pages to pixels if we aren't already in pixels
// There are three delta modes:
// * deltaMode 0 is by pixels, nothing to do
// * deltaMode 1 is by lines
// * deltaMode 2 is by pages
if (orgEvent.deltaMode === 1) {
var lineHeight = $.data(this, 'mousewheel-line-height');
delta *= lineHeight;
deltaY *= lineHeight;
deltaX *= lineHeight;
} else if (orgEvent.deltaMode === 2) {
var pageHeight = $.data(this, 'mousewheel-page-height');
delta *= pageHeight;
deltaY *= pageHeight;
deltaX *= pageHeight;
}
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max(Math.abs(deltaY), Math.abs(deltaX));
if (!lowestDelta || absDelta < lowestDelta) {
lowestDelta = absDelta;
// Adjust older deltas if necessary
if (shouldAdjustOldDeltas(orgEvent, absDelta)) {
lowestDelta /= 40;
}
}
// Adjust older deltas if necessary
if (shouldAdjustOldDeltas(orgEvent, absDelta)) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
deltaY /= 40;
}
// Get a whole, normalized value for the deltas
delta = Math[delta >= 1 ? 'floor' : 'ceil'](delta / lowestDelta);
deltaX = Math[deltaX >= 1 ? 'floor' : 'ceil'](deltaX / lowestDelta);
deltaY = Math[deltaY >= 1 ? 'floor' : 'ceil'](deltaY / lowestDelta);
// Normalise offsetX and offsetY properties
if (special.settings.normalizeOffset && this.getBoundingClientRect) {
var boundingRect = this.getBoundingClientRect();
offsetX = event.clientX - boundingRect.left;
offsetY = event.clientY - boundingRect.top;
}
// Add information to the event object
event.deltaX = deltaX;
event.deltaY = deltaY;
event.deltaFactor = lowestDelta;
event.offsetX = offsetX;
event.offsetY = offsetY;
// Go ahead and set deltaMode to 0 since we converted to pixels
// Although this is a little odd since we overwrite the deltaX/Y
// properties with normalized deltas.
event.deltaMode = 0;
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
// Clearout lowestDelta after sometime to better
// handle multiple device types that give different
// a different lowestDelta
// Ex: trackpad = 3 and mouse wheel = 120
if (nullLowestDeltaTimeout) {
clearTimeout(nullLowestDeltaTimeout);
}
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
function nullLowestDelta() {
lowestDelta = null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}
}));
;// JavaScript Document
/* Remember to encode */
/* https://javascriptobfuscator.com/Javascript-Obfuscator.aspx */
var isDOM = (getRef ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var local_url = (header_path ? header_path : window.location.protocol + '//' + window.location.host + '/');
var root_local_url = (root_header_path ? root_header_path : window.location.protocol + '//' + window.location.host + '/');
var scripts = document.getElementsByTagName('script');
var myScript = scripts[scripts.length - 1];
var queryString = myScript.src.replace(/^[^\?]+\??/, '');
var global_js_params = parseQuery(queryString);
function parseQuery(query) {
var Params = new Object();
if (!query) return Params; // return empty object
var Pairs = query.split(/[;&]/);
for (var i = 0; i < Pairs.length; i++) {
var KeyVal = Pairs[i].split('=');
if (!KeyVal || KeyVal.length != 2) continue;
var key = unescape(KeyVal[0]);
var val = unescape(KeyVal[1]);
val = val.replace(/\+/g, ' ');
Params[key] = val;
}
return Params;
}
function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
var refHeight = function () {
$(".layoutBlockHeight").each(function () {
if ($(this).closest(".cccApp").length) return;
var obj = $(this).parent().find(".layoutRefHeight").filter(":visible");
var targetHeight = $(obj).height();
if ($(this).hasClass("layoutBlockLineHeight")) {
$(this).css('line-height', targetHeight + 'px');
$(this).css('padding-top', $(obj).css("padding-top"));
$(this).css('padding-bottom', $(obj).css("padding-bottom"));
}
$(this).height(targetHeight);
});
if($(".footer-menu-nav").hasClass("notSticky")){
var contentsHeight = $(".footer-menu-nav").outerHeight() + $(".menu-nav").outerHeight() + $(".mainContainer").outerHeight();
if(contentsHeight > $(window).height()){
$(".footer-padding").height("auto");
} else {
$(".footer-padding").height($(window).height() - contentsHeight);
}
}
$(".mainContainer").not(".notSticky").height($(window).height() - $(".menu-nav").outerHeight() - $(".footer-menu-nav").outerHeight());
$(".mainContainerHeight").not(".notSticky").height($(window).height() - $(".menu-nav").outerHeight() - $(".footer-menu-nav").outerHeight());
$(".changeBg").click(function(){
$(this).closest(".imagesContainer").find(".changeBg").removeClass("active");
$(this).addClass("active");
$(".overLayBg").backstretch($(this).attr("data-image"), {
duration: 3000, fade: 0
});
});
$(".stickToBottom").each(function () {
$(this).css('margin-top',$(this).parent().height() - $(this).outerHeight()+'px');
});
$(document).trigger("refHeightLoaded");
};
var scrollTimer = null;
$(window).resize(function () {
if (scrollTimer) {
clearTimeout(scrollTimer); // clear any previous pending timer
}
scrollTimer = setTimeout(refHeight, 10); // set new timer
});
$(document).bind("langLoaded", refHeight);
$(document).bind("load", refHeight);
$("html").addClass("frontEnd");
;;
function setupDatatable(obj,data,key){
$(obj).data('datatable_settings',data);
if(!key) key = "dataTable";
$(obj).data('datatable_key',key);
}
$(window).load(function(){
$('.auto_datatable').each(function(){
var thisTable = $(this);
var dataTableSetting = $(this).data('datatable_settings');
if(canDebug()) console.log(dataTableSetting);
$(thisTable).dataTable(dataTableSetting);
});
});
if(jQuery.fn.dataTableExt) jQuery.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
// check that we have a column id
if ( typeof iColumn == "undefined" ) {
return [];
}
// by default we only wany unique data
if ( typeof bUnique == "undefined" ) {
bUnique = true;
}
// by default we do want to only look at filtered data
if ( typeof bFiltered == "undefined" ) {
bFiltered = true;
}
// by default we do not wany to include empty values
if ( typeof bIgnoreEmpty == "undefined" ) {
bIgnoreEmpty = true;
}
// list of rows which we're going to loop through
var aiRows;
// use only filtered rows
if (bFiltered === true) {
aiRows = oSettings.aiDisplay;
}
// use all rows
else {
aiRows = oSettings.aiDisplayMaster; // all row numbers
}
// set up data array
var asResultData = [];
for (var i=0,c=aiRows.length; i -1) {
continue;
}
// else push the value onto the result data array
else {
asResultData.push(sValue);
}
}
return asResultData;
};
var initTooltipster = function(){
$(".tooltipster").not(".tooltipstered").each(function() {
var theme = $(this).attr("data-theme");
if(canDebug()) console.log('theme',theme);
$(this).tooltipster({
speed: 200,
animation: 'grow',
position: ($(this).attr("data-position")?$(this).attr("data-position"):'top'),
theme: (theme ? theme :'tooltipster-shadow'),
content: $(this).attr('data-title')
});
$(this).addClass(".tooltipstered");
});
};
$(window).load(function(){
initTooltipster();
});
// JavaScript Document
function ajax_showStatusMessage(status_number){
switch(status_number){
default:
case -1001:
switch(Number(global_js_params.lang)){
default:
return '404 Error or Unstable Internet Connection';
break;
case 2:
return '404 錯誤 或 網絡連接不穩定';
break;
case 3:
return '404 错误 或 网络连接不稳定';
break;
}
break;
// ----- END ----- upate org ----
}
return lang(status_number);
}
$(window).load(function(){
$.noty.defaults = {
layout: 'top',
theme: 'defaultTheme', // or 'relax'
type: 'alert',
text: '', // can be html or string
dismissQueue: true, // If you want to use queue feature set this true
template: '
',
animation: {
open: {height: 'toggle'}, // or Animate.css class names like: 'animated bounceInLeft'
close: {height: 'toggle'}, // or Animate.css class names like: 'animated bounceOutLeft'
easing: 'swing',
speed: 500 // opening & closing animation speed
},
timeout: false, // delay for closing event. Set false for sticky notifications
force: false, // adds notification to the beginning of queue when set to true
modal: false,
maxVisible: 5, // you can set max visible notification for dismissQueue true option,
killer: false, // for close all notifications before show
closeWith: ['click'], // ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications
callback: {
onShow: function() {},
afterShow: function() {},
onClose: function() {},
afterClose: function() {},
onCloseClick: function() {}
},
buttons: false // an array of buttons
};
$.noty.themes.bootstrapTheme = {
name: 'bootstrapTheme',
modal: {
css: {
position: 'fixed',
width: '100%',
height: '100%',
backgroundColor: '#000',
zIndex: 10000,
opacity: 0.6,
display: 'none',
left: 0,
top: 0
}
},
style: function() {
var containerSelector = this.options.layout.container.selector;
//$(containerSelector).addClass('list-group');
this.$closeButton.append('×Close');
this.$closeButton.addClass('close');
this.$bar.css('padding', '10px');
switch (this.options.type) {
case 'alert': case 'notification':
this.$bar.css('background', '#36AEEA');
this.$bar.css('color', '#fff');
this.$bar.find(".noty_text").addClass("f15");
//this.$bar.addClass( "list-group-item-info" );
break;
case 'warning':
this.$bar.css('background', '#ff0000');
this.$bar.css('color', '#fff');
this.$bar.find(".noty_text").addClass("f15");
//this.$bar.addClass( "list-group-item-warning" );
break;
case 'error':
//this.$bar.addClass( "list-group-item-danger" );
break;
case 'information':
//this.$bar.addClass("list-group-item-info");
break;
case 'success':
//this.$bar.addClass( "list-group-item-success" );
break;
}
this.$message.css({
fontSize: '13px',
lineHeight: '16px',
textAlign: 'center',
//padding: '8px 10px 9px',
width: 'auto',
position: 'relative'
});
},
callback: {
onShow: function() { },
onClose: function() { }
}
};
$.noty.layouts.top = {
name : 'top',
options : {},
container: {
object : '
',
selector: 'ul#noty_top_layout_container',
style : function() {
$(this).css({
top : 0,
left : '0%',
position : 'fixed',
width : '100%',
height : 'auto',
margin : 0,
padding : 0,
listStyleType: 'none',
zIndex : 9999999
});
}
},
parent : {
object : '',
selector: 'li',
css : {}
},
css : {
display: 'none'
},
addClass : ''
};
});
function showNotyWithText(str){
noty({
text: str,
animation: {
open: {height: 'toggle'}, // jQuery animate function property object
close: {height: 'toggle'}, // jQuery animate function property object
easing: 'swing', // easing
speed: 100 // opening & closing animation speed
},
theme: 'bootstrapTheme',
timeout : 2000
});
}
function showErrorNotyWithText(str){
noty({
text: str,
type: 'warning',
animation: {
open: {height: 'toggle'}, // jQuery animate function property object
close: {height: 'toggle'}, // jQuery animate function property object
easing: 'swing', // easing
speed: 100 // opening & closing animation speed
},
theme: 'bootstrapTheme',
timeout : 2000
});
}
var cccResize = function(){
if($(".footerMinHeight").length) {
if($(".footerMinHeight").offset().top > $(window).height()){
$(".footerMinHeight").hide();
} else {
$(".footerMinHeight").show();
$(".footerMinHeight").height($(window).outerHeight() - $(".footerMinHeight").offset().top - $(".footerContainer").height() - 50);
}
}
};
$(window).load(cccResize);
$(window).bind("langLoaded",cccResize);
$(window).resize(cccResize);
function checkData(data){
if(data.status == -9999){
if(!$("html").hasClass("sessionError")){
$("html").addClass("sessionError");
BootstrapDialog.confirm(1, 'info', lang('Notice') , lang('Your session has expired. Please log-in again.'), true, {
'callback': function(result){
if ( result ) {
} else {
}
}
}, [
], function(dialog) {
},function(dialog) {
//
},function(dialog) {
},function(dialog) {
location.reload();
});
}
}
}
function init_page_cccms_v4(){
if($('.cccmsv4_datatable').length){
$('.cccmsv4_datatable').not(".datatable_loaded").each(function(){
$('.cccmsv4_datatable').addClass("datatable_loaded");
var thisTable = $(this);
var dataTableSetting = $(this).data('datatable_settings');
var dataTableKey = $(this).data('datatable_key');
if(canDebug()) console.log(dataTableSetting);
var initDelBtnCallback = function(){
//console.log('initDelBtnCallback');
$(thisTable).find('.delBtn').bind('click', function() {
var api = $(this).attr("data-api");
var uid = $(this).attr("data-ref-id");
var row = $(this).parent().closest('tr');
if($('#dialog').length){
var t = '';
var confirmBtnTxt = '';
var cancelBtnTxt = '';
var contentTxt = '';
switch(Number(global_js_params.lang)){
default:
case 1:
t = 'Delete Item';
confirmBtnTxt = 'Confirm';
cancelBtnTxt = 'Cancel';
contentTxt = 'Are you sure to remove for this item ? All removal processes are irreversible.';
break;
case 2:
t = '移除項目';
confirmBtnTxt = '確定';
cancelBtnTxt = '取消';
contentTxt = '您是否確定移除此項目 ? 所有帳戶一經移除,一律不設取消。';
break;
case 3:
t = '移除项目';
confirmBtnTxt = '确定';
cancelBtnTxt = '取消';
contentTxt = '您是否确定移除此项目 ? 所有帐户一经移除,一律不设取消。';
break;
}
$( "#dialog" ).html(contentTxt);
$( "#dialog" ).dialog({
resizable: false,
open: function(){
$('.ui-widget-overlay').hide().fadeIn();
$('.ui-widget-overlay').bind('click', function() {
$('#dialog').dialog('close');
});
},
show: {
effect: "clip",
duration: 200
},
hide: {
effect: "clip",
duration: 200
},
autoOpen: true,
draggable: false,
width: 'auto',
modal: true,
closeOnEscape: false,
title: t,
buttons: [
{
text: confirmBtnTxt,
click: function() {
// -------- AJAX ------
$.ajax({
url: local_url+'lib/ajax/'+api+'/remove/?uid='+uid,
headers: { 'X-Cccms-Key-Secret': $('#h').val() },
data: $('form').serialize(),
type:"POST",
dataType:'json',
beforeSend: function(msg){
ajax_show_loading_mask(true);
},
complete: function(msg){
setTimeout(function() {
ajax_show_loading_mask(false);
//$( this ).dialog( "close" );
}, 500);
},
success: function(json_data){
//alert(json_data.status);
//return;
setTimeout(function() {
$(thisTable).dataTable().fnDeleteRow(row);
}, 500);
},
error:function(xhr, ajaxOptions, thrownError){
//
}
});
// -- END --- AJAX ----
$( this ).dialog( "close" );
}
},
{
text: cancelBtnTxt,
click: function() {
$( this ).dialog( "close" );
}
}
]
});
} // if($('#dialog').length){
}); // $('.delBtn').bind('click', function() {
};
if(dataTableSetting) if(
'drawCallback' in dataTableSetting &&
typeof dataTableSetting['drawCallback'] === "function"
){ // hv callback setup
// console.log('init_page_cccms_v4 1');
var orgCallback = dataTableSetting['drawCallback'];
dataTableSetting['drawCallback'] = function(a){
// console.log('master callback');
orgCallback(a);
initDelBtnCallback(a);
};
} else {
// console.log('init_page_cccms_v4 2');
dataTableSetting['drawCallback'] = initDelBtnCallback; // no callback setup
}
if(!window.dataTableGS) window.dataTableGS = [];
dataTableGS[dataTableKey] = $(thisTable).dataTable(dataTableSetting);
});
}
}
$(window).load(init_page_cccms_v4);
function requestFullScreen(element) {
// Supports most browsers and their versions.
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;
if (requestMethod) { // Native full screen.
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== 'undefined') { // Older IE.
var wscript = new ActiveXObject('WScript.Shell');
if (wscript !== null) {
wscript.SendKeys('{F11}');
}
}
}
function getFormBuilderData(id) {
return $('#textarea_' + id).val();
}
function setFormBuilderData(id, data) {
return $('#textarea_' + id).val(data);
}
function cccFormExportMatrix(obj) {
var data = {};
$(obj).closest('.matrixItem').find('.cccInput').each(function () {
data[$(this).attr('cccdata-ref-name')] = $(this).val();
});
BootstrapDialog.confirm(1, 'info', lang('Exported Field Data'), '
' + lang('Please Copy data.') + '
', true, true, {
'callback': function (result) {
if (result) {
} else {
}
}
}, [
{
label: lang('Close'),
cssClass: 'btn-default',
action: function (dialog) {
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
dialog.close();
}
}
], function (dialog) {
}, function (dialog) {
}, function (dialog) {
if (canDebug()) console.log('onhide');
}, function (dialog) {
if (canDebug()) console.log('onhidden');
});
}
function cccFormExportImportMatrix(obj) {
var person = prompt('Please enter Field data');
var data = JSON.parse(cms.cccApp.Base64.decode(person));
$(obj).closest('.cccApp').trigger('cccApp', [function (thisApp) {
$.each(data, function (k, v) {
var thisObj = $(obj).closest('.matrixItem').find('[cccdata-ref-name=\'' + k + '\']');
if (thisObj.length) {
thisApp.objVal(thisObj, v);
}
});
}]);
$(obj).closest('.matrixItem').find('.cccInput').each(function () {
data[$(this).attr('cccdata-ref-name')] = $(this).val();
});
}
var cccFormRecaptchaLoaded = false;
var cccFormRecaptcha = function () {
cccFormRecaptchaLoaded = true;
$(document).trigger('cccFormRecaptchaLoaded');
};
var loadRecaptcha = function (thisApp) {
$(thisApp.obj).find('.ccc-grecaptcha').not('.ccc-grecaptcha-init').each(function () {
var $this = this;
$($this).addClass('ccc-grecaptcha-init');
var id = $($this).attr('id');
id = id.split('_');
id = id[1];
if (id) {
cms.grecaptcha[id] = function () {
if ($($this).attr('sitekey')) {
var thisCaptcha = grecaptcha.render('grecaptcha_' + id, {
'sitekey': $($this).attr('sitekey'),
'callback': function (response) {
$('#' + id).val(response);
formChecking(thisApp, false, false, $('[cccdata-cccapp-id="' + id + '"]').find('#' + id));
}
});
$(document).unbind('cccApp_' + thisApp.appID + '_reset_grecaptcha.field_' + id).bind('cccApp_' + thisApp.appID + '_reset_grecaptcha.field_' + id, function () {
grecaptcha.reset(thisCaptcha);
$('#' + id).val('');
});
if ($($this).hasClass('ccc-grecaptcha-fullwidth')) {
var callback = function () {
var scale = 1;
if ($(window).width() < 768) {
var width = $('#grecaptcha_' + id).parent().width();
scale = width / 302;
}
$('#grecaptcha_' + id).css('transform', 'scale(' + scale + ')');
$('#grecaptcha_' + id).css('-webkit-transform', 'scale(' + scale + ')');
$('#grecaptcha_' + id).css('transform-origin', '0 0');
$('#grecaptcha_' + id).css('-webkit-transform-origin', '0 0');
};
callback();
$(window).resize(function () {
callback();
});
}
} else {
$($this).html('Please setup sitekey for Google reCAPTCHA');
}
};
if (cccFormRecaptchaLoaded) {
cms.grecaptcha[id]();
} else {
$(document).bind('cccFormRecaptchaLoaded', cms.grecaptcha[id]);
}
}
});
};
function setBase64File(obj, fileURL, fileName) {
$(obj).next('.base64UploadLabel')
.css('background-image', 'url(' + fileURL + ')')
.css('background-size', 'cover')
.css('background-position', 'center')
.addClass('upload-success')
.find('.cccFormIcon').removeClass('hidden')
.filter('.cccappicon-upload').addClass('hidden')
.parent().find('.uploadLabelText').addClass('hidden').last().text((fileName ? fileName : lang('Selected'))).removeClass('hidden');
}
function getBase64(file) {
cms.loadingDiv($(file).closest('.formItem'));
var textarea = $(file).closest('.formItem').find('textarea.cccInput');
var obj = $(file);
file = file.files[0];
var size = file.size;
var base64Label = $(obj).closest('.formItem').find('.base64UploadLabel');
var fileSize = base64Label.attr('cccdata-file-size');
var bytesToSize = function (bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};
var error = '';
var regexData = '';
var regex = '';
if (base64Label.attr('cccdata-regex')) {
regexData = base64Label.attr('cccdata-regex');
if (!regexData) console.error('cccdata-ref-name not found.');
if (regexData) regex = new RegExp('(\\.|\\/)(' + regexData.split(',').join('|') + ')$', 'i');
}
if (regex && !regex.test(file.name)) {
error = lang('File type not allowed') + ' ( Type : ' + regexData + ' )';
} else if (parseInt(size) > parseInt(fileSize)) {
error = lang('File is too large') + ' ( Limit : ' + bytesToSize(fileSize) + ' )';
}
if (error) {
BootstrapDialog.confirm(1, 'info', error, file.name, true, true, {
'callback': function (result) {
$(obj).parent().get(0).reset();
cms.removeLoadingDiv($(textarea).closest('.formItem'));
if (result) {
} else {
}
}
}, [
{
label: lang('Close'),
cssClass: 'btn-default',
action: function (dialog) {
typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false);
dialog.close();
}
}
], function (dialog) {
}, function (dialog) {
}, function (dialog) {
}, function (dialog) {
}, false, true);
return;
}
// console.log('size', size,);
try {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
cms.removeLoadingDiv($(textarea).closest('.formItem'));
setBase64File(obj, reader.result, file.name);
textarea.val(reader.result).triggerHandler('change');
};
reader.onerror = function (error) {
$(obj).parent().get(0).reset();
cms.removeLoadingDiv($(textarea).closest('.formItem'));
cms.cccApp.error($(file).closest('.cccApp'), error);
};
} catch (e) {
cms.removeLoadingDiv($(textarea).closest('.formItem'));
}
}
var onchangeCaseCheck = function (obj, thisApp) {
var onchangecallback = $(obj).closest('.formItem').attr('cccdata-onchange-callback');
if (onchangecallback) {
var fn = new Function('obj', 'thisApp', thisApp.Base64.decode(onchangecallback));
fn(obj, thisApp);
}
};
$(document).on('focusin', function (e) {
if ($(e.target).closest('.mce-window').length) {
e.stopImmediatePropagation();
}
});
// Generated by CoffeeScript 1.8.0
/*
jQuery Credit Card Validator 1.0
Copyright 2012-2015 Pawel Decowski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
(function () {
var $,
__indexOf = [].indexOf || function (item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) return i;
}
return -1;
};
$ = jQuery;
$.fn.validateCreditCard = function (callback, options) {
var bind, card, card_type, card_types, get_card_type, is_valid_length, is_valid_luhn, normalize, validate,
validate_number, _i, _len, _ref;
card_types = [
{
name: 'amex',
pattern: /^3[47]/,
valid_length: [15]
}, {
name: 'diners_club_carte_blanche',
pattern: /^30[0-5]/,
valid_length: [14]
}, {
name: 'diners_club_international',
pattern: /^36/,
valid_length: [14]
}, {
name: 'jcb',
pattern: /^35(2[89]|[3-8][0-9])/,
valid_length: [16]
}, {
name: 'laser',
pattern: /^(6304|670[69]|6771)/,
valid_length: [16, 17, 18, 19]
}, {
name: 'visa_electron',
pattern: /^(4026|417500|4508|4844|491(3|7))/,
valid_length: [16]
}, {
name: 'visa',
pattern: /^4/,
valid_length: [16]
}, {
name: 'mastercard',
pattern: /^5[1-5]/,
valid_length: [16]
}, {
name: 'maestro',
pattern: /^(5018|5020|5038|6304|6759|676[1-3])/,
valid_length: [12, 13, 14, 15, 16, 17, 18, 19]
}, {
name: 'discover',
pattern: /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,
valid_length: [16]
}
];
bind = false;
if (callback) {
if (typeof callback === 'object') {
options = callback;
bind = false;
callback = null;
} else if (typeof callback === 'function') {
bind = true;
}
}
if (options == null) {
options = {};
}
if (options.accept == null) {
options.accept = (function () {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = card_types.length; _i < _len; _i++) {
card = card_types[_i];
_results.push(card.name);
}
return _results;
})();
}
_ref = options.accept;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
card_type = _ref[_i];
if (__indexOf.call((function () {
var _j, _len1, _results;
_results = [];
for (_j = 0, _len1 = card_types.length; _j < _len1; _j++) {
card = card_types[_j];
_results.push(card.name);
}
return _results;
})(), card_type) < 0) {
throw 'Credit card type \'' + card_type + '\' is not supported';
}
}
get_card_type = function (number) {
var _j, _len1, _ref1;
_ref1 = (function () {
var _k, _len1, _ref1, _results;
_results = [];
for (_k = 0, _len1 = card_types.length; _k < _len1; _k++) {
card = card_types[_k];
if (_ref1 = card.name, __indexOf.call(options.accept, _ref1) >= 0) {
_results.push(card);
}
}
return _results;
})();
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
card_type = _ref1[_j];
if (number.match(card_type.pattern)) {
return card_type;
}
}
return null;
};
is_valid_luhn = function (number) {
var digit, n, sum, _j, _len1, _ref1;
sum = 0;
_ref1 = number.split('').reverse();
for (n = _j = 0, _len1 = _ref1.length; _j < _len1; n = ++_j) {
digit = _ref1[n];
digit = +digit;
if (n % 2) {
digit *= 2;
if (digit < 10) {
sum += digit;
} else {
sum += digit - 9;
}
} else {
sum += digit;
}
}
return sum % 10 === 0;
};
is_valid_length = function (number, card_type) {
var _ref1;
return _ref1 = number.length, __indexOf.call(card_type.valid_length, _ref1) >= 0;
};
validate_number = (function (_this) {
return function (number) {
var length_valid, luhn_valid;
card_type = get_card_type(number);
luhn_valid = false;
length_valid = false;
if (card_type != null) {
luhn_valid = is_valid_luhn(number);
length_valid = is_valid_length(number, card_type);
}
return {
card_type: card_type,
valid: luhn_valid && length_valid,
luhn_valid: luhn_valid,
length_valid: length_valid
};
};
})(this);
validate = (function (_this) {
return function () {
var number;
number = normalize($(_this).val());
return validate_number(number);
};
})(this);
normalize = function (number) {
return number.replace(/[ -]/g, '');
};
if (!bind) {
return validate();
}
this.on('input.jccv', (function (_this) {
return function () {
$(_this).off('keyup.jccv');
return callback.call(_this, validate());
};
})(this));
this.on('keyup.jccv', (function (_this) {
return function () {
return callback.call(_this, validate());
};
})(this));
callback.call(this, validate());
return this;
};
}).call(this);
if (!$('html').hasClass('ie8')) {
(function (c) {
try {
document.createEvent('TouchEvent');
return;
} catch (f) {
}
var d = {mousedown: 'touchstart', mouseup: 'touchend', mousemove: 'touchmove'};
var a = function () {
for (var e in d) {
document.body.addEventListener(e, function (i) {
var h = b(d[i.type], i);
// i.target.dispatchEvent(h); racson stop for an error
var g = i.target['on' + d[i.type]];
if (typeof g === 'function') {
g(i);
}
}, false);
}
};
var b = function (g, i) {
var h = document.createEvent('MouseEvents');
h.initMouseEvent(g, i.bubbles, i.cancelable, i.view, i.detail, i.screenX, i.screenY, i.clientX, i.clientY, i.ctrlKey, i.altKey, i.shiftKey, i.metaKey, i.button, i.relatedTarget);
return h;
};
if (document.readyState === 'complete' || document.readyState === 'loaded') {
a();
} else {
c.addEventListener('load', a, false);
}
})(window);
}
;
/*
* Backstretch
* http://srobbin.com/jquery-plugins/backstretch/
*
* Copyright (c) 2013 Scott Robbin
* Licensed under the MIT license.
*/
;(function ($, window, undefined) {
'use strict';
/* PLUGIN DEFINITION
* ========================= */
$.fn.resizeOrInitBackstretch = function (images, options) {
return this.each(function () {
var obj = $(this);
if ($(obj).hasClass('backstretched')) {
$(obj).trigger('backstretchResize');
} else {
if (images) {
// var callback = function () {
// if ($(obj).is(":in-viewport") && $(obj).is(":visible")) {
$(obj).backstretch(images, options);
$(obj).addClass('backstretched');
// } else {
// setTimeout(callback, 1000);
// }
// };
// callback();
}
}
});
};
$.fn.backstretch = function (images, options) {
// We need at least one image or method name
if (images === undefined || images.length === 0) {
// $.error("No images were supplied for Backstretch");
return this;
}
/*
* Scroll the page one pixel to get the right window height on iOS
* Pretty harmless for everyone else
*/
if ($(window).scrollTop() === 0) {
window.scrollTo(0, 0);
}
return this.each(function () {
var $this = $(this)
, obj = $this.data('backstretch');
// Do we already have an instance attached to this element?
if (obj) {
// Is this a method they're trying to execute?
if (typeof images == 'string' && typeof obj[images] == 'function') {
// Call the method
obj[images](options);
// No need to do anything further
return;
}
// Merge the old options with the new
options = $.extend(obj.options, options);
// Remove the old instance
obj.destroy(true);
}
obj = new Backstretch(this, images, options);
$this.data('backstretch', obj);
});
};
// If no element is supplied, we'll attach to body
$.backstretch = function (images, options) {
// Return the instance
return $('body')
.backstretch(images, options)
.data('backstretch');
};
// Custom selector
$.expr[':'].backstretch = function (elem) {
return $(elem).data('backstretch') !== undefined;
};
/* DEFAULTS
* ========================= */
$.fn.backstretch.defaults = {
centeredX: true // Should we center the image on the X axis?
, centeredY: true // Should we center the image on the Y axis?
, duration: 5000 // Amount of time in between slides (if slideshow)
, fade: 0 // Speed of fade transition between slides
};
/* STYLES
*
* Baked-in styles that we'll apply to our elements.
* In an effort to keep the plugin simple, these are not exposed as options.
* That said, anyone can override these in their own stylesheet.
* ========================= */
var styles = {
wrap: {
left: 0
, top: 0
, overflow: 'hidden'
, margin: 0
, padding: 0
, height: '100%'
, width: '100%'
, zIndex: -999999
}
, img: {
position: 'absolute'
, display: 'none'
, margin: 0
, padding: 0
, border: 'none'
, width: 'auto'
, height: 'auto'
, maxHeight: 'none'
, maxWidth: 'none'
, zIndex: -999999
}
};
/* CLASS DEFINITION
* ========================= */
var Backstretch = function (container, images, options) {
this.options = $.extend({}, $.fn.backstretch.defaults, options || {});
/* In its simplest form, we allow Backstretch to be called on an image path.
* e.g. $.backstretch('/path/to/image.jpg')
* So, we need to turn this back into an array.
*/
this.images = $.isArray(images) ? images : [images];
// Preload images
$.each(this.images, function () {
$('')[0].src = this;
});
// Convenience reference to know if the container is body.
this.isBody = container === document.body;
/* We're keeping track of a few different elements
*
* Container: the element that Backstretch was called on.
* Wrap: a DIV that we place the image into, so we can hide the overflow.
* Root: Convenience reference to help calculate the correct height.
*/
this.$container = $(container);
this.$root = this.isBody ? supportsFixedPosition ? $(window) : $(document) : this.$container;
// Don't create a new wrap if one already exists (from a previous instance of Backstretch)
var $existing = this.$container.children('.backstretch').first();
this.$wrap = $existing.length ? $existing : $('').css(styles.wrap).appendTo(this.$container);
// Non-body elements need some style adjustments
if (!this.isBody) {
// If the container is statically positioned, we need to make it relative,
// and if no zIndex is defined, we should set it to zero.
var position = this.$container.css('position')
, zIndex = this.$container.css('zIndex');
this.$container.css({
position: position === 'static' ? 'relative' : position
, zIndex: zIndex === 'auto' ? 0 : zIndex
, background: 'none'
});
// Needs a higher z-index
this.$wrap.css({zIndex: -999998});
}
// Fixed or absolute positioning?
this.$wrap.css({
position: this.isBody && supportsFixedPosition ? 'fixed' : 'absolute'
});
// Set the first image
this.index = 0;
this.show(this.index);
this.id = cms.makeID();
// Listen for resize
var $this = this;
$(container).bind('backstretchResize', function () {
$this.resize();
});
$(window).bind('resize.backstretch-' + this.id, this.resize)
.bind('orientationchange.backstretch-' + this.id, function () {
// Need to do this in order to get the right window height
if ($this.isBody && window.pageYOffset === 0) {
window.scrollTo(0, 1);
$this.resize();
}
});
};
/* PUBLIC METHODS
* ========================= */
Backstretch.prototype = {
resize: function () {
try {
var bgCSS = {left: 0, top: 0}
, rootWidth = this.isBody ? this.$root.width() : this.$root.innerWidth()
, bgWidth = rootWidth
,
rootHeight = this.isBody ? (window.innerHeight ? window.innerHeight : this.$root.height()) : this.$root.innerHeight()
, bgHeight = bgWidth / this.$img.data('ratio')
, bgOffset;
// Make adjustments based on image ratio
if (bgHeight >= rootHeight) {
bgOffset = (bgHeight - rootHeight) / 2;
if (this.options.centeredY) {
bgCSS.top = '-' + bgOffset + 'px';
}
} else {
bgHeight = rootHeight;
bgWidth = bgHeight * this.$img.data('ratio');
bgOffset = (bgWidth - rootWidth) / 2;
if (this.options.centeredX) {
bgCSS.left = '-' + bgOffset + 'px';
}
}
this.$wrap.css({width: rootWidth, height: rootHeight})
.find('img:not(.deleteable)').css({width: bgWidth, height: bgHeight}).css(bgCSS);
} catch (err) {
// IE7 seems to trigger resize before the image is loaded.
// This try/catch block is a hack to let it fail gracefully.
}
return this;
}
// Show the slide at a certain position
, show: function (newIndex) {
// Validate index
if (Math.abs(newIndex) > this.images.length - 1) {
return;
}
// Vars
var self = this
, oldImage = self.$wrap.find('img').addClass('deleteable')
, evtOptions = {relatedTarget: self.$container[0]};
// Trigger the "before" event
self.$container.trigger($.Event('backstretch.before', evtOptions), [self, newIndex]);
// Set the new index
this.index = newIndex;
// Pause the slideshow
clearInterval(self.interval);
// New image
self.$img = $('')
.css(styles.img)
.bind('load', function (e) {
var imgWidth = this.width || $(e.target).width()
, imgHeight = this.height || $(e.target).height();
// Save the ratio
$(this).data('ratio', imgWidth / imgHeight);
// Show the image, then delete the old one
// "speed" option has been deprecated, but we want backwards compatibilty
$(this).fadeIn(self.options.speed || self.options.fade, function () {
oldImage.remove();
// Resume the slideshow
if (!self.paused) {
self.cycle();
}
// Trigger the "after" and "show" events
// "show" is being deprecated
$(['after', 'show']).each(function () {
self.$container.trigger($.Event('backstretch.' + this, evtOptions), [self, newIndex]);
});
});
// Resize
self.resize();
})
.error(function () {
$(['error']).each(function () {
self.$container.trigger($.Event('backstretch.' + this, evtOptions), [self, newIndex]);
});
})
.appendTo(self.$wrap);
// Hack for IE img onload event
self.$img.attr('src', self.images[newIndex]);
return self;
}
, next: function () {
// Next slide
return this.show(this.index < this.images.length - 1 ? this.index + 1 : 0);
}
, prev: function () {
// Previous slide
return this.show(this.index === 0 ? this.images.length - 1 : this.index - 1);
}
, pause: function () {
// Pause the slideshow
this.paused = true;
return this;
}
, resume: function () {
// Resume the slideshow
this.paused = false;
this.next();
return this;
}
, cycle: function () {
// Start/resume the slideshow
if (this.images.length > 1) {
// Clear the interval, just in case
clearInterval(this.interval);
this.interval = setInterval($.proxy(function () {
// Check for paused slideshow
if (!this.paused) {
this.next();
}
}, this), this.options.duration);
}
return this;
}
, destroy: function (preserveBackground) {
// Stop the resize events
$(window).unbind('resize.backstretch-' + this.id);
$(window).unbind('orientationchange.backstretch-' + this.id);
// Clear the interval
clearInterval(this.interval);
// Remove Backstretch
if (!preserveBackground) {
this.$wrap.remove();
}
this.$container.removeData('backstretch');
}
};
/* SUPPORTS FIXED POSITION?
*
* Based on code from jQuery Mobile 1.1.0
* http://jquerymobile.com/
*
* In a nutshell, we need to figure out if fixed positioning is supported.
* Unfortunately, this is very difficult to do on iOS, and usually involves
* injecting content, scrolling the page, etc.. It's ugly.
* jQuery Mobile uses this workaround. It's not ideal, but works.
*
* Modified to detect IE6
* ========================= */
var supportsFixedPosition = (function () {
var ua = navigator.userAgent
, platform = navigator.platform
// Rendering engine is Webkit, and capture major version
, wkmatch = ua.match(/AppleWebKit\/([0-9]+)/)
, wkversion = !!wkmatch && wkmatch[1]
, ffmatch = ua.match(/Fennec\/([0-9]+)/)
, ffversion = !!ffmatch && ffmatch[1]
, operammobilematch = ua.match(/Opera Mobi\/([0-9]+)/)
, omversion = !!operammobilematch && operammobilematch[1]
, iematch = ua.match(/MSIE ([0-9]+)/)
, ieversion = !!iematch && iematch[1];
return !(
// iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5)
((platform.indexOf('iPhone') > -1 || platform.indexOf('iPad') > -1 || platform.indexOf('iPod') > -1) && wkversion && wkversion < 534) ||
// Opera Mini
(window.operamini && ({}).toString.call(window.operamini) === '[object OperaMini]') ||
(operammobilematch && omversion < 7458) ||
//Android lte 2.1: Platform is Android and Webkit version is less than 533 (Android 2.2)
(ua.indexOf('Android') > -1 && wkversion && wkversion < 533) ||
// Firefox Mobile before 6.0 -
(ffversion && ffversion < 6) ||
// WebOS less than 3
('palmGetResource' in window && wkversion && wkversion < 534) ||
// MeeGo
(ua.indexOf('MeeGo') > -1 && ua.indexOf('NokiaBrowser/8.5.0') > -1) ||
// IE6
(ieversion && ieversion <= 6)
);
}());
}(jQuery, window));
// Textarea and select clone() bug workaround | Spencer Tipping
// Licensed under the terms of the MIT source code license
// Motivation.
// jQuery's clone() method works in most cases, but it fails to copy the value of textareas and select elements. This patch replaces jQuery's clone() method with a wrapper that fills in the
// values after the fact.
// An interesting error case submitted by Piotr Przybyl: If two