/* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ KCSS.prototype.constructor = KCSS; function KCSS() { } KCSS.styles = new Object(); KCSS.addCSS = function(className) { if (KCSS.getCSS(className)) { return; }; var styles = window.document.createElement('link'); styles.rel = 'stylesheet'; styles.type = 'text/css'; styles.href = Kinky.SITE_CSS_URL + className + '.css'; window.document.getElementsByTagName('head')[0].appendChild(styles); } KCSS.getCSS = function(className) { var classRegex = new RegExp(className + '([.])css'); for ( var k = window.document.styleSheets.length - 1; k != -1; k--) { var rules = window.document.styleSheets.item(k); var isStyle = classRegex.test(rules.href || ''); if (isStyle) { return rules.ownerNode || rules.owningElement; } } } KCSS.removeCSS = function(className) { if (className) { if (typeof className == 'string') { var node = KCSS.getCSS(className); if (!node) { return; } } else { node = className; } node.parentNode.removeChild(node); } } KCSS.disableCSS = function(className) { var classRegex = new RegExp(className + '\.css') for ( var k = window.document.styleSheets.length - 1; k != -1; k--) { var rules = window.document.styleSheets.item(k); var isStyle = classRegex.test(rules.href); if (isStyle) { rules.disabled = true; return; } } } KCSS.enableCSS = function(className) { var classRegex = new RegExp(className + '\.css') for ( var k = window.document.styleSheets.length - 1; k != -1; k--) { var rules = window.document.styleSheets.item(k); var isStyle = classRegex.test(rules.href); if (isStyle) { rules.disabled = false; return; } } KCSS.addCSS(className); } KCSS.toggleDisplay = function(element) { if (element.style.display == 'none') { element.style.display = 'block'; } else { element.style.display = 'none'; } } KCSS.toggleVisibility = function(element) { if (element.style.display == 'hidden') { element.style.visibility = 'visible'; } else { element.style.visibility = 'hidden'; } } KCSS.clearBoth = function(noIE) { var toReturn = window.document.createElement('div'); if (!noIE) { toReturn.className = 'ClearBothIe'; } toReturn.style.clear = 'both'; return toReturn; } KCSS.br = function() { var toReturn = window.document.createElement('br'); return toReturn; } KCSS.img = function(src, alt, title) { var toReturn = window.document.createElement('img'); toReturn.src = src; if (alt) { toReturn.alt = alt; } if (title) { toReturn.title = title; } return toReturn; } KCSS.addCSSClass = function(cssClass, target) { target.className += ' ' + cssClass + ' '; } KCSS.removeCSSClass = function(cssClass, target) { eval('target.className = target.className.replace(/ ' + cssClass + ' /g, \'\');'); } KCSS.setStyle = function(cssStyle, domElements) { for (var index in domElements) { var domElement = domElements[index]; for (var property in cssStyle) { if (!cssStyle[property]) {continue;} switch (property) { case 'clear' : { domElement.appendChild(KCSS.clearBoth()); break; } case 'cssFloat' : { if (KBrowserDetect.browser == 2) { eval('domElement.style.styleFloat = \'' + cssStyle[property] + '\';'); } else { eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); } break; } case 'opacity' : { //dump(KBrowserDetect.browser); switch (KBrowserDetect.browser) { case 1: domElement.style.MozOpacity = cssStyle[property]; break; case 2: if (!KCSS.NO_IE_OPACITY) { domElement.style.MsFilter = '"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + Math.round(cssStyle[property] * 100) + ')"'; domElement.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + Math.round(cssStyle[property] * 100) + ')'; } case 3: domElement.style.opacity = cssStyle[property]; break; case 4: domElement.style.KhtmlOpacity = cssStyle[property]; break; case 5: domElement.style.opacity = cssStyle[property]; break; } break; } default : { try{ eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); } catch(err){ if (Kinky.DEV) { alert(property + "="+ cssStyle[property] + " "+ err.toString()); } } break; } } } } } KCSS.addFrame = function (target, params) { var div = window.document.createElement('div'); div.className = target.className + ' ' + params.cssClass + ' '; div.id = 'border-' + target.id; KCSS.setStyle({ position: 'relative', left : 'auto', top : 'auto', right : 'auto', bottom : 'auto' }, [div]); KCSS.setStyle(target.style, [div]); KCSS.setStyle({ position: 'relative', left : 'auto', top : 'auto', right : 'auto', bottom : 'auto' }, [ target ]); target.parentNode.replaceChild(div, target); var backgroundTopLeft = window.document.createElement('div'); backgroundTopLeft.className = ' ' + params.cssClass + 'TLBackground '; KCSS.setStyle({ height : params.border + 'px', width : params.border + 'px', position : 'absolute', top :'0', left : '0' }, [backgroundTopLeft]); div.appendChild(backgroundTopLeft); var backgroundTopMiddle = window.document.createElement('div'); backgroundTopMiddle.className = ' ' + params.cssClass + 'TMBackground '; KCSS.setStyle({ height : params.border + 'px', margin : '0 ' + params.border + 'px 0 ' + params.border + 'px' }, [backgroundTopMiddle]); div.appendChild(backgroundTopMiddle); var backgroundTopRight = window.document.createElement('div'); backgroundTopRight.className = ' ' + params.cssClass + 'TRBackground '; KCSS.setStyle({ height : params.border + 'px', width : params.border + 'px', position : 'absolute', top :'0', right : '0' }, [backgroundTopRight]); div.appendChild(backgroundTopRight); var backgroundMiddle = window.document.createElement('div'); backgroundMiddle.className = ' ' + params.cssClass + 'MiddleBackground '; div.appendChild(backgroundMiddle); var backgroundMiddleLeft = window.document.createElement('div'); backgroundMiddleLeft.className = ' ' + params.cssClass + 'MLBackground '; KCSS.setStyle({ cssFloat : 'left', height : 'inherit', width : params.border + 'px' }, [backgroundMiddleLeft]); backgroundMiddle.appendChild(backgroundMiddleLeft); var backgroundMiddleMiddle = window.document.createElement('div'); backgroundMiddleMiddle.className = ' ' + params.cssClass + 'MMBackground '; KCSS.setStyle({ cssFloat : 'left' }, [backgroundMiddleMiddle]); backgroundMiddleMiddle.appendChild(target); backgroundMiddle.appendChild(backgroundMiddleMiddle); var backgroundMiddleRight = window.document.createElement('div'); backgroundMiddleRight.className = ' ' + params.cssClass + 'MRBackground '; KCSS.setStyle({ height : 'inherit', cssFloat : 'left', width : params.border + 'px' }, [backgroundMiddleRight]); backgroundMiddle.appendChild(backgroundMiddleRight); var backgroundBottomLeft = window.document.createElement('div'); backgroundBottomLeft.className = ' ' + params.cssClass + 'BLBackground '; KCSS.setStyle({ height : params.border + 'px', width : params.border + 'px', position : 'absolute', bottom :'0', left : '0' }, [backgroundBottomLeft]); div.appendChild(backgroundBottomLeft); var backgroundBottomMiddle = window.document.createElement('div'); backgroundBottomMiddle.className = ' ' + params.cssClass + 'BMBackground '; KCSS.setStyle({ height : params.border + 'px', margin : '0 ' + params.border + 'px 0 ' + params.border + 'px' }, [backgroundBottomMiddle]); div.appendChild(backgroundBottomMiddle); var backgroundBottomRight = window.document.createElement('div'); backgroundBottomRight.className = ' ' + params.cssClass + 'BRBackground '; KCSS.setStyle({ height : params.border + 'px', width : params.border + 'px', position : 'absolute', bottom :'0', right : '0' }, [backgroundBottomRight]); div.appendChild(backgroundBottomRight); return div; } KCSS.normalizBackgroundPosition = function(value) { var splited = value.split(/ /); return { x : KSystem.normalizePixelValue(splited[0]), y : KSystem.normalizePixelValue(splited[1]) }; } KCSS.NO_IE_OPACITY = false; KException.prototype = new Error(); KException.prototype.constructor = KException; function KException(invoker, message) { if (invoker != null) { this.message = (KSystem.getObjectClass(invoker) || '' + invoker) + '[' + invoker.id + ']' + ': ' + message; } } KException.prototype.printStackTrace = function() { var callstack = new Array(); if (this.stack) { // Firefox var lines = this.stack.split("\n"); for ( var i = 0, len = lines.length; i != len; i++) { if (lines[i] != '') { callstack.push(lines[i]); } } } else if (window.opera && this.message) { // Opera var lines = this.message.split("\n"); for ( var i = 0, len = lines.length; i != len; i++) { if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) { var entry = lines[i]; if (lines[i + 1]) { entry += " at " + lines[i + 1]; i++; } callstack.push(entry); } } } else { var currentFunction = arguments.callee.caller; while (currentFunction) { var fn = currentFunction.toString(); var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous"; callstack.push(fname); currentFunction = currentFunction.caller; } } var list = window.document.createElement('ol'); for (var index in callstack) { var error = list.appendChild(window.document.createElement('li')); error.appendChild(window.document.createTextNode(callstack[index])); } return list; } KSystem.prototype = {}; KSystem.prototype.constructor = KSystem; function KSystem() { } KSystem.construct = function(jsonObject, parent, throwException) { try { if (jsonObject.feClass) { var object = null; var newString = 'object = new ' + jsonObject.feClass + "(parent"; var first = true; for ( var arg in jsonObject.args) { newString += ', '; newString += JSON.stringify(jsonObject.args[arg]); } newString += ');'; //dump(newString); eval(newString); if (object.data == null) { object.data = new Object(); } KSystem.constructAttributes(object.data, jsonObject); if (object.data.urlHashText != null) { object.hash = object.data.urlHashText; } if (object.data.totalCount != null) { object.totalCount = object.data.totalCount; } return object; } else { if (throwException || Kinky.SHOW_INSTANTIATIONS_ERRORS) { if (throwException || Kinky.SHOW_INSTANTIATIONS_ERRORS == 'exception') { throw new Error('KSystem: can\'t create KWidget from empty source (parentID=\'' + parent.id + '\', parentClass=\'' + KSystem.getObjectClass(parent) + '\', parentHash=\'' + parent.hash + '\').'); } else { dump('KSystem: can\'t create KWidget from empty source (parentID=\'' + parent.id + '\', parentClass=\'' + KSystem.getObjectClass(parent) + '\', parentHash=\'' + parent.hash + '\'):
' + JSON.stringify(jsonObject) + '
'); } } } } catch (e) { if (throwException || Kinky.SHOW_INSTANTIATIONS_ERRORS) { if (throwException || Kinky.SHOW_INSTANTIATIONS_ERRORS == 'exception') { throw new Error('KSystem: ' + e + ' on object ' + JSON.stringify(jsonObject) + ' width class ' + jsonObject.feClass); } else { dump('KSystem: ' + e + '
' + JSON.stringify(jsonObject) + '
'); } } // throw e; } } KSystem.constructAttributes = function(object, jsonObject) { for ( var attribute in jsonObject) { if (jsonObject[attribute] instanceof Array) { object[attribute] = new Array(); for ( var subObjects in jsonObject[attribute]) { var subObject = new Object(); KSystem.constructAttributes(subObject, jsonObject[attribute][subObjects]); object[attribute].push(subObject); } } else { object[attribute] = jsonObject[attribute]; } } } KSystem.clone = function(object, exceptions, fromRecurrence) { if (object == null) { return fromRecurrence ? null : {}; } var toReturn = null; if (object instanceof Array) { toReturn = new Array(); for ( var i in object) { if (typeof object[i] == 'object') { toReturn[i] = KSystem.clone(object[i], exceptions, true); } else toReturn[i] = object[i]; } } else if (typeof object == 'object') { toReturn = new Object(); for ( var i in object) { if (exceptions && exceptions.test(i)) { continue; } if (typeof object[i] == 'object') { toReturn[i] = KSystem.clone(object[i], exceptions, true); } else toReturn[i] = object[i]; } } else { return object; } return toReturn; } KSystem.merge = function(object1, object2) { for ( var i in object2) { object1[i] = (object2[i] != null ? object2[i] : object1[i]); } return object1; } KSystem.setCookie = function(name, value, expires) { KSystem.removeCookie(name); var exdate = new Date(); if (expires) { exdate.setTime(expires); } else { exdate.setFullYear(exdate.getFullYear() + 10); } window.document.cookie = name + "=" + encodeURIComponent(JSON.stringify(value)) + "; expires=" + exdate.toUTCString(); } KSystem.getCookie = function(name) { if (document.cookie.length > 0) { var start = document.cookie.indexOf(name + "="); if (start != -1) { start = start + name.length + 1; var end = document.cookie.indexOf(";", start); if (end == -1) { end = document.cookie.length; } var toReturn = null; eval('toReturn = ' + unescape(document.cookie.substring(start, end)) + ';'); return toReturn || {}; } } return {}; } KSystem.removeCookie = function(name) { var exdate = new Date(); exdate.setTime(exdate.getTime() - 3600000); window.document.cookie = name + "=delete; expires=" + exdate.toUTCString(); } KSystem.removeEventListener = function(element, eventName, handler) { if (element.detachEvent) { element.detachEvent('on' + eventName, handler); } else { element.removeEventListener(eventName, handler, false); } } KSystem.addEventListener = function(element, eventName, handler) { if (element.attachEvent) { element.attachEvent('on' + eventName, handler); } else { element.addEventListener(eventName, handler, false); } } KSystem.fireEvent = function(element, eventName) { if (element.fireEvent) { if (element.fireEvent) { try { element.fireEvent('on' + eventName); } catch(e) { } } else { debug('No fireevent for ' + element.tagName); } } else { var evt = document.createEvent("HTMLEvents"); evt.initEvent(eventName, true, true); return !element.dispatchEvent(evt); } } KSystem.addTimer = function(code, miliseconds, nonStop) { if (nonStop) { return setInterval(code, miliseconds); } else { return setTimeout(code, miliseconds); } } KSystem.removeTimer = function(timer) { clearInterval(timer); clearTimeout(timer); } KSystem.getEventTarget = function(event){ event = event || window.event; if (event == null) { return null; } return event.target || event.srcElement; } KSystem.isRelatedTarget = function(event, parent, mouseOut) { var mouseEvent = KSystem.getEvent(event); var element = null; if (mouseOut) { element = mouseEvent.toElement || (mouseEvent.relatedTarget && mouseEvent.relatedTarget.nodeName ? mouseEvent.relatedTarget : null); } else { element = mouseEvent.fromElement || (mouseEvent.relatedTarget && mouseEvent.relatedTarget.nodeName ? mouseEvent.relatedTarget : null); } if (!element) { return false; } if (element.id == parent.id) { return true; } if (element != parent && element != null && parent != null) { var nodes = parent.getElementsByTagName(element.tagName); for ( var i = 0; i != nodes.length; i++) { if (nodes[i].id == element.id) { return true; } } } return false; } KSystem.getEventRelatedTarget = function(event, mouseOut) { var mouseEvent = KSystem.getEvent(event); var element = null; if (mouseOut) { element = mouseEvent.toElement || (mouseEvent.relatedTarget && mouseEvent.relatedTarget.nodeName ? mouseEvent.relatedTarget : null); } else { element = mouseEvent.fromElement || (mouseEvent.relatedTarget && mouseEvent.relatedTarget.nodeName ? mouseEvent.relatedTarget : null); } return element; } KSystem.getEvent = function(event){ var toReturn = null; toReturn = event || window.event; return toReturn; } KSystem.getWidget = function(element, className){ var toReturn = element; if (className != null) { while (toReturn != null) { if (/^widget/.test(toReturn.id)) { var object = Kinky.bunnyMan.widgets[toReturn.id]; var isParent = false; eval('isParent = object instanceof ' + className + ';'); if (isParent) { break; } } toReturn = toReturn.parentNode; } } else { try { while (!/^widget/.test(toReturn.id)) { toReturn = toReturn.parentNode; } } catch(e) { return null; } } if (toReturn) { return Kinky.getWidget(toReturn.id); } return null; } KSystem.getEventWidget = function(event, className){ event = event || window.event; if (event == null) { return null; } var element = event.target || event.srcElement; if (className != null) { while (element != null) { if (/^widget/.test(element.id)) { var object = Kinky.bunnyMan.widgets[element.id]; var isParent = false; eval('isParent = object instanceof ' + className + ';'); if (isParent) { break; } } element = element.parentNode; } } else { while (element != null && !/^widget/.test(element.id)) { element = element.parentNode; } } if (!element) { element = event.target || event.srcElement; throw new KWidgetNotFoundException('KSystem', "Widget not for element ID = " + element.id); } return Kinky.bunnyMan.widgets[element.id]; } KSystem.getObjectClass = function(obj){ if (obj && obj.constructor && obj.constructor.toString) { var arr = obj.constructor.toString().match(/function\s*(\w+)/); if (arr && arr.length == 2) { return arr[1]; } } return undefined; } KSystem.getCSSRules = function(){ var rules = window.document.styleSheets.item(0); return rules.cssRules || rules.rules; } KSystem.getCSSRule = function(ruleName){ for (var k = window.document.styleSheets.length - 1; k != -1; k--) { var rules = window.document.styleSheets.item(k); if (!rules) { continue; } rules = rules.cssRules || rules.rules; for (var i = 0; i < rules.length; i++) { if (rules.item(i).selectorText && rules.item(i).selectorText.toLowerCase() == ruleName.toLowerCase()) { return rules.item(i); } } } return null; } KSystem.normalizePixelValue = function(value){ try { return parseInt(value.replace(/px/g, '')); }catch(e){ alert(value); } } KSystem.extractColorInfo = function(value){ try { var info = {}; if (value.substr(0, 1) === '#') { var rgb_from = parseInt(value.replace("#", ""), 16); info.red = (rgb_from & (255 << 16)) >> 16; info.green = (rgb_from & (255 << 8)) >> 8; info.blue = (rgb_from & 255); } else if (value.substr(0, 4) === 'rgb(') { var digits = /(.*?)rgb\((\d+),(\d+),(\d+)\)/.exec(value.replace(/ /g, '')); info.red = parseInt(digits[2]); info.green = parseInt(digits[3]); info.blue = parseInt(digits[4]); } return info; }catch(e){ alert(value + ": " + e.message); } } KSystem.setOpacity = function(widget, alpha){ switch (KBrowserDetect.browser) { case 1: widget.panel.style.MozOpacity = alpha; break; case 2: widget.panel.filters.alpha.opacity = Math.round(alpha * 100); break; case 3: widget.panel.style.opacity = alpha; opacity = parseInt(widget.panel.style.opacity) + tween.threshold; break; case 4: widget.panel.style.MozOpacity = alpha; break; case 5: widget.panel.style.MozOpacity = alpha; break; } } KSystem.getBrowserHeight = function(){ var height = 0; if (window.innerHeight) { height = window.innerHeight; } else { if (window.document.documentElement && window.document.documentElement.clientHeight) { height = window.document.documentElement.clientHeight; } else if (window.document.body) { height = document.body.clientHeight; } } return height; } KSystem.getBrowserWidth = function() { var width = 0; if (window.document.documentElement && window.document.documentElement.clientWidth) { width = window.document.documentElement.clientWidth; } else if (window.document.body) { width = document.body.clientWidth; } else if (window.innerWidth) { width = window.innerWidth; } return width; } KSystem.mouseX = function (event) { if (event.pageX) { return event.pageX; } else if (event.clientX) { return event.clientX + (window.document.documentElement.scrollLeft ? window.document.documentElement.scrollLeft : window.document.body.scrollLeft); } else { return null; } } KSystem.mouseY = function (event) { if (event.pageY) {return event.pageY;} else if (event.clientY) { return event.clientY + (window.document.documentElement.scrollTop ?window.document.documentElement.scrollTop :window.document.body.scrollTop); } else { return null; } } KSystem.widgetToString = function (widget) { var obj = new Object(); for(var field in widget) { if (/parent|children|kinky|constructor|scroll|tooltip/.test(field) || !widget[field] || typeof widget[field] == 'function' || widget[field] instanceof KWidget || widget[field] instanceof KScroll || widget[field].style) { continue; } obj[field] = widget[field]; } var str = JSON.stringify(obj).replace(/{|\[|}|\]|\,/g, function(wholematch, match) { switch (wholematch) { case '{': case '[': { var toReturn = '
'; for ( var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } toReturn += wholematch + '
'; KSystem.ident++; for ( var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } return toReturn; } case '}': case ']': { KSystem.ident--; var toReturn = '
'; for ( var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } toReturn += wholematch + '
'; for ( var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } return toReturn; } case ',': { var toReturn = ''; toReturn += ',
'; for ( var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } return toReturn; } default: { return wholematch; } } }); delete obj; return str; } KSystem.months = ['Janeiro', 'Fevereiro', 'Mar\u00e7o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']; KSystem.monthsAbrev = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']; KSystem.monthsIndex = {'Janeiro' : 0, 'Fevereiro' : 1, 'Mar\u00e7o' : 2, 'Abril' : 3, 'Maio' : 4, 'Junho' : 5, 'Julho' : 6, 'Agosto': 7, 'Setembro' : 8, 'Outubro': 9, 'Novembro': 10, 'Dezembro' : 11}; KSystem.monthsAbrevIndex = {'Jan':0, 'Fev':1, 'Mar':2, 'Abr':3, 'Mai':4, 'Jun':5, 'Jul':6, 'Ago':7, 'Set':8, 'Out' : 9, 'Nov' : 10, 'Dez' : 11}; KSystem.days = ['Domingo', 'Segunda-feira', 'Ter\u00e7a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'S\u00e1bado', 'Domingo']; KSystem.daysAbrev = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sext', 'Sab', 'Dom']; KSystem.daysIndex = {'Domingo' : 0, 'Segunda-feira' : 1, 'Ter\u00e7a-feira' : 2, 'Quarta-feira' : 3, 'Quinta-feira' : 4, 'Sexta-feira' : 5, 'S\u00e1bado' : 6, 'Domingo' : 7}; KSystem.daysAbrevIndex = {'Dom' : 0, 'Seg' : 1, 'Ter' : 2, 'Qua' : 3, 'Qui' : 4, 'Sex' : 5, 'Sab' : 6, 'Dom' : 7}; KSystem.formatDate = function(format, date) { var toReturn = ''; var escape = false; toReturn = format.replace(/(\w+)|%/g, function(wholematch, match){ if (wholematch == '%') { escape = true; return ''; } if (escape) { escape = false; return match; } switch(match) { case 'Y': { return date.getFullYear(); } case 'M': { return (date.getMonth() < 9 ? '0' : '') + (date.getMonth() + 1); } case 'MM': { return KSystem.monthsAbrev[date.getMonth()]; } case 'MMM': { return KSystem.months[date.getMonth()]; } case 'D': { return KSystem.daysAbrev[date.getDay()]; } case 'DD': { return KSystem.days[date.getDay()]; } case 'd': { return (date.getDate() < 10 ? '0' : '') + date.getDate(); } case 'H': { return date.getHours(); } case 'i': { return (date.getMinutes() < 10 ? '0' : '') + date.getMinutes(); } case 's': { return (date.getSeconds() < 10 ? '0' : '') + date.getSeconds(); } default: { return match; } } }); return toReturn.replace(/\|/g, ''); } KSystem.parseDate = function(format, date) { var toReturn = new Date(); format += ' '; var pattIndex = 0; var valIndex = 0; var replaced = format.replace(/(\w+)/g, function(wholematch, match){ var auxIndex = (format.indexOf(match, pattIndex) + match.length); var index = 0; if (auxIndex != 0) { index = date.indexOf(format.charAt(auxIndex), valIndex); } else { index = date.length; } pattIndex += match.length + 1; var value = date.substring(valIndex, index != -1 ? index : date.length); value = value.indexOf('0') == 0 ? value.substr(1) : value; valIndex = index + 1; if (value == '') { return value; } switch(match) { case 'Y': { toReturn.setFullYear(parseInt(value)); break; } case 'M': { toReturn.setMonth(parseInt(value) - 1); break; } case 'MM': { toReturn.setMonth(KSystem.monthsAbrevIndex(value)); break; } case 'MMM': { toReturn.setMonth(KSystem.monthsIndex(value)); break; } case 'd': { toReturn.setDate(parseInt(value)); break; } case 'H': { toReturn.setHours(parseInt(value)); break; } case 'i': { toReturn.setMinutes(parseInt(value)); break; } case 's': { toReturn.setSeconds(parseInt(value)); break; } default: { return match; break; } } return value; }); return toReturn; } function debug(object){ try { if (console && console.log) { console.log(object); return; } } catch (e) { return; } if (!Kinky.DEV_MODE) { return; } alert(JSON.stringify(object)); } function cls(object){ var div = document.getElementById('kdebug'); if (div != null) { div.innerHTML = ''; } } function dump(object, prefix){ if (!Kinky.DEV_MODE) { return; } if (Kinky.DUMP_MODE == 'console') { try { if (console && console.info) { console.info(object); return; } } catch (e) { return; } } else { if (KSystem.dump) { KSystem.dump(JSON.stringify(object)); return; } var div = document.getElementById('kdebug'); if (div == null) { div = window.document.createElement('div'); div.id = 'kdebug'; KCSS.setStyle({ display : 'block', backgroundColor : '#000000', color : '#FFFFFF', opacity : '0.7', position : 'fixed', bottom : '15px', right : '15px', width : '50%', fontSize : '10px', fontFamily : 'sans', overflow : 'auto', height : '400px', padding : '5px', border : '2px groove #ffffff', zIndex : '10000' }, [div]); KSystem.addEventListener(div, 'dblclick', function(event){ div.innerHTML = ''; div.style.display = 'none'; }); window.document.body.appendChild(div); } div.style.display = 'block'; KSystem.ident = 0; div.appendChild(KCSS.br()); div.appendChild(window.document.createTextNode('-----------------------------------------------------------------')); div.appendChild(KCSS.br()); if (Kinky.DUMP_MODE == 'no-json') { div.innerHTML += (prefix ? prefix + '
' : '') + object; } else { if (object instanceof KWidget || object instanceof KScroll) { div.innerHTML += (prefix ? prefix + '
' : '') + object.toString(true); } else { div.innerHTML += (prefix ? prefix + '
' : '') + (object == null ? '' : JSON.stringify(object).replace(/{|\[|}|\]|\,/g, function(wholematch, match){ switch (wholematch) { case '{': case '[': { var toReturn = '
'; for (var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } toReturn += wholematch + '
'; KSystem.ident++; for (var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } return toReturn; } case '}': case ']': { KSystem.ident--; var toReturn = '
'; for (var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } toReturn += wholematch + '
'; for (var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } return toReturn; } case ',' : { var toReturn = ''; toReturn += ',
'; for (var i = 0; i != KSystem.ident; i++) { toReturn += KSystem.identation; } return toReturn; } default : { return wholematch; } } })); } } } } KSystem.ident = 0; KSystem.identation = '      '; Kinky.prototype.constructor = Kinky; function Kinky() { this.resizeListeners = {}; this.widgetResizeListeners = {}; this.lastWidth = 0; this.lastHeight = 0; this.widgets = new Object(); this.widgetCount = 0; this.currentLanguage = 'pt'; this.request = null; this.error = null; this.response = null; this.loggedUser = null; this.loggedFB = null; this.lastError = null; } Kinky.getError = function() { return Kinky.bunnyMan.lastError; } Kinky.setError = function(error) { delete Kinky.bunnyMan.lastError; Kinky.bunnyMan.lastError = error; } Kinky.config = function() { if (Kinky.bunnyMan.started) { return; } Kinky.bunnyMan.started = true; Kinky.bunnyMan.currentLanguage = Kinky.DEFAULT_LANG; if (Kinky.DISABLE_IE6 && KBrowserDetect.browsername == 'Explorer' && KBrowserDetect.version == 6) { window.location = Kinky.SITE_URL + 'browser_not_supported/index.html'; } Kinky.bunnyMan.widgets['proxy'] = Kinky.bunnyMan; Kinky.bunnyMan.widgets['picker'] = KOAuth.lockPicker; if (Kinky.PERSISTENT_SESSION) { var authCookie = KSystem.getCookie('KINKY_AUTH'); if (authCookie.user) { Kinky.DEFAULT_USER = authCookie.user; Kinky.DEFAULT_USER_SECRET = authCookie.password; } } if (Kinky.NEGOTIATE_SESSION_SERVICE) { KOAuth.start(); return; } else { Kinky.init(); } } Kinky.init = function() { KBreadcrumb.sparrow = new KBreadcrumb(); KSystem.addTimer(KBreadcrumb.onLocationChange, 0); KSystem.addTimer(Kinky.onResize, 0); KSystem.addTimer(Kinky.onResizeWidget, 0); if (Kinky.BASE_SERVICE != null) { var service = (typeof Kinky.BASE_SERVICE == 'string' ? Kinky.BASE_SERVICE : Kinky.BASE_SERVICE[Kinky.SERVICE_NAMESPACE]); var request = { type : service.substring(0, service.indexOf(':')), namespace : service.substring(service.indexOf(':') + 1, service.lastIndexOf(':')), service : service.substring(service.lastIndexOf(':') + 1), action : 'get', id : 'proxy', lang : Kinky.bunnyMan.currentLanguage, callback : 'Kinky.bunnyMan.start', contentView : 'Version(versionCode)', contentID : Kinky.BASE_VERSION } Kinky.bunnyMan.request = request; KConnection.getConnection(request.type).send(request, null, Kinky.DEFAULT_USER, Kinky.DEFAULT_USER_SECRET); } else { Kinky.bunnyMan.start({ feClass : Kinky.BASE_CLASS, callback : 'Kinky.bunnyMan.process', contentView : 'Version(versionCode)' }); } } Kinky.prototype.start = function(data) { if (Kinky.ALLOW_EFFECTS) { KEffects.loadTimmingFunctions(); } Kinky.site = KSystem.construct(data, -1); Kinky.site.parent = document.getElementById(Kinky.BASE_TAG); Kinky.site.setPageAutoLoad(Kinky.AUTOLOAD_PAGE); Kinky.site.start(Kinky.HOMEPAGE_URL); } Kinky.getWidget = function(widgetID) { return Kinky.bunnyMan.getWidget(widgetID); } Kinky.getLoggedUser = function() { return Kinky.bunnyMan.loggedUser; } Kinky.getAccessToken = function() { return KOAuth.getAccessToken(); } Kinky.setLoggedFB = function(data) { Kinky.bunnyMan.loggedFB = data; } Kinky.getLoggedFB = function() { return Kinky.bunnyMan.loggedFB; } Kinky.getCurrentLanguage = function() { return Kinky.bunnyMan.currentLanguage; } Kinky.clearSession = function() { delete Kinky.bunnyMan.loggedUser; delete Kinky.bunnyMan.loggedFB; KSystem.removeCookie('KINKY_AUTH'); Kinky.DEFAULT_USER = null; Kinky.DEFAULT_USER_SECRET = null; } Kinky.startSession = function(user, secret, userData) { if (Kinky.PERSISTENT_SESSION && user && secret) { KSystem.setCookie('KINKY_AUTH', { user : user, password : secret }); Kinky.DEFAULT_USER = user; Kinky.DEFAULT_USER_SECRET = secret; } if (userData) { Kinky.bunnyMan.loggedUser = userData; } } Kinky.prototype.dispatchResize = function() { var width = KSystem.getBrowserWidth(); var height = KSystem.getBrowserHeight(); if (width != this.lastWidth || height != this.lastHeight) { this.lastHeight = height; this.lastWidth = width; for ( var widget in this.resizeListeners) { for ( var index in this.resizeListeners[widget]) { this.resizeListeners[widget][index].call(null, this.widgets[widget], { width : width, height : height }); } } } KSystem.addTimer(Kinky.onResize, 200); } Kinky.prototype.dispatchResizeWidget = function() { for ( var widget in this.widgetResizeListeners) { if (!this.widgets[widget].activated() || !this.widgets[widget].display || this.widgets[widget].simpleWidget) { continue; } try { var width = this.widgets[widget].getWidth(); var height = this.widgets[widget].getHeight(); if (width != this.widgets[widget].lastWidth || height != this.widgets[widget].lastHeight) { this.widgets[widget].lastHeight = height; this.widgets[widget].lastWidth = width; for ( var index in this.widgetResizeListeners[widget]) { this.widgetResizeListeners[widget][index].call(null, this.widgets[widget], { width : width, height : height }); } } } catch (e) { dump("dispatchResizeWidget (" + widget + "): " + e.message); } } KSystem.addTimer(Kinky.onResizeWidget, 200); } Kinky.onResize = function() { try { Kinky.bunnyMan.dispatchResize(); } catch (e) { } } Kinky.onResizeWidget = function() { try { Kinky.bunnyMan.dispatchResizeWidget(); } catch (e) { } } Kinky.prototype.addWindowResizeListener = function(widget, callback) { if (this.resizeListeners[widget.id]) { this.resizeListeners[widget.id].push(callback); } else { this.resizeListeners[widget.id] = new Array(); this.resizeListeners[widget.id].push(callback); } } Kinky.prototype.addResizeListener = function(widget, callback) { if (this.widgetResizeListeners[widget.id]) { this.widgetResizeListeners[widget.id].push(callback); } else { this.widgetResizeListeners[widget.id] = new Array(); this.widgetResizeListeners[widget.id].push(callback); } } Kinky.prototype.clearHead = function() { var head = window.document.getElementsByTagName('head')[0]; for ( var i = 0; i != head.childNodes.length; i++) { if (head.childNodes[i].src != null && head.childNodes[i].src.indexOf('id=proxy') != -1) { head.removeChild(head.childNodes[i]); break; } } } Kinky.prototype.addWidget = function(widget, id) { var widgetID = id || 'widget' + (++this.widgetCount); this.widgets[widgetID] = widget; return widgetID; } Kinky.prototype.removeWidget = function(widgetID) { delete KBreadcrumb.sparrow.byWidget.location[widgetID]; delete KBreadcrumb.sparrow.byWidget.query[widgetID]; delete KBreadcrumb.sparrow.byWidget.action[widgetID]; delete this.widgetResizeListeners[widgetID]; delete this.resizeListeners[widgetID]; delete this.widgets[widgetID]; } Kinky.prototype.getWidget = function(widgetID) { return this.widgets[widgetID]; } Kinky.prototype.get = function(widget, service, params, callback, user, password) { var request = { type : service.substring(0, service.indexOf(':')), namespace : service.substring(service.indexOf(':') + 1, service.lastIndexOf(':')), service : service.substring(service.lastIndexOf(':') + 1), action : 'get', id : widget.id, context : (widget.query ? widget.query + widget.nPage : null), lang : params.lang || this.currentLanguage, callback : 'Kinky.getWidget(\'' + widget.id + '\').' + (callback != null ? callback : 'onLoad'), user : user, secret : password } if (widget instanceof KWidget) { widget.wait(); } KConnection.getConnection(request.type).send(request, params, (user == null ? Kinky.DEFAULT_USER : user), (password == null ? Kinky.DEFAULT_USER_SECRET : password)); } Kinky.prototype.save = function(widget, service, params, callback, user, password) { var request = { type : service.substring(0, service.indexOf(':')), namespace : service.substring(service.indexOf(':') + 1, service.lastIndexOf(':')), service : service.substring(service.lastIndexOf(':') + 1), action : 'save', id : widget.id, context : (widget.query ? widget.query + widget.nPage : null), lang : params.lang || this.currentLanguage, callback : 'Kinky.getWidget(\'' + widget.id + '\').' + (callback != null ? callback : 'onSave'), user : user, secret : password } if (widget instanceof KWidget) { widget.wait(); } KConnection.getConnection(request.type).send(request, params, (user == null ? Kinky.DEFAULT_USER : user), (password == null ? Kinky.DEFAULT_USER_SECRET : password)); } Kinky.prototype.remove = function(widget, service, params, callback, user, password) { var request = { type : service.substring(0, service.indexOf(':')), namespace : service.substring(service.indexOf(':') + 1, service.lastIndexOf(':')), service : service.substring(service.lastIndexOf(':') + 1), action : 'remove', id : widget.id, context : (widget.query ? widget.query + widget.nPage : null), lang : params.lang || this.currentLanguage, callback : 'Kinky.getWidget(\'' + widget.id + '\').' + (callback != null ? callback : 'onRemove'), user : user, secret : password } if (widget instanceof KWidget) { widget.wait(); } KConnection.getConnection(request.type).send(request, params, (user == null ? Kinky.DEFAULT_USER : user), (password == null ? Kinky.DEFAULT_USER_SECRET : password)); } Kinky.SERVICES_URL = null; Kinky.SERVICE_NAMESPACE = null; Kinky.DATA_URL = null; Kinky.SITE_URL = null; Kinky.SITE_CSS_URL = null; Kinky.HOMEPAGE_URL = null; Kinky.BASE_CLASS = null; Kinky.BASE_JS_URL = null; Kinky.BASE_TEMP_URL = null; Kinky.BASE_TEMP_DIR = null; Kinky.BASE_SERVICE = null; Kinky.BASE_CONTENT_SERVICE = null; Kinky.BASE_TAG = null; Kinky.BASE_VERSION = '/'; Kinky.AUTOLOAD_PAGE = false; Kinky.DEFAULT_USER = null; Kinky.DEFAULT_USER_SECRET = null; Kinky.ENTITIES = false; Kinky.URL_ENCODED = false; Kinky.SHOW_INSTANTIATIONS_ERRORS = false; Kinky.DISABLE_IE6 = false; Kinky.ALLOW_EFFECTS = false; Kinky.DEFAULT_LANG = 'pt'; Kinky.PERSISTENT_SESSION = false; Kinky.FB_APP_ID = null; Kinky.FB_APP_COOKIE_NAME = null; Kinky.FB_APP_URL = null; Kinky.BROWSER_CLICK = { x : 0, y : 0 } Kinky.TITLE_CLEAR_BOTH = false; Kinky.DEV_MODE = true; Kinky.site = null; Kinky.bunnyMan = new Kinky(); Kinky.HTML_READY = 'html4'; Kinky.CSS_READY = 'css2'; Kinky.DUMP_MODE = 'console'; Kinky.IMAGE_PROXY = null; function KConnection(url, dataURL) { this.urlBase = url; this.dataUrlBase = dataURL; } KConnection.prototype.connect = function(request, callback) { var channel = this.openChannel(); channel.onreadystatechange = function() { KConnection.getConnection(request.type).receive(request, channel); } return channel; } KConnection.prototype.getServiceParams = function(request, params) { if (request) { if (params) { for ( var paramName in params) { request[paramName] = params[paramName]; } } var toSend = 'id=' + request.id + '&request=' + encodeURIComponent(JSON.stringify(request)); } return toSend; } KConnection.prototype.send = function(request, params, user, password) { throw new KNoExtensionException(this, 'send'); } KConnection.prototype.openChannel = function() { var channel = null; if (window.XMLHttpRequest) { // Mozilla, Safari, ... channel = new window.XMLHttpRequest(); } else if (window.ActiveXObject) { // IE try { channel = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { channel = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } return channel; } KConnection.prototype.getBasicHTTPAuthentication = function(user, password) { var tok = user + ':' + password; var hash = Base64.encode(tok); return "Basic " + hash; } KConnection.prototype.receive = function(request, ajaxResponse) { if (ajaxResponse.readyState == 4) { if (ajaxResponse.status == 200) { var response = null; var widget = Kinky.getWidget(request.id); try { eval('response = ' + ajaxResponse.responseText + ';'); } catch (e) { response = { httpStatus : 500, code : 500, description : 'Unrecognizable response format', message : 'Exception', stackTrace : ajaxResponse.responseText, request : request }; } if (response.httpStatus && response.httpStatus != 200) { this.processNonOk(widget, response); } else { Kinky.startSession(request.user, request.secret, response.user || Kinky.bunnyMan.loggedUser); if (widget != null) { widget.authenticated = false; if (widget.resume) { widget.resume(true); } } if (response.content) { eval(request.callback + '(response.content, request.context);'); } else { eval(request.callback + '(response, request.context);'); } } } else { var widget = Kinky.getWidget(request.id); var response = null; try { eval('response = ' + ajaxResponse.responseText + ';'); } catch (e) { response = { code : ajaxResponse.status, description : 'Unrecognizable response format', message : 'Exception', stackTrace : ajaxResponse.responseText, request : request }; } response.httpStatus = response.httpStatus || ajaxResponse.status; this.processNonOk(widget, response); } if (widget && widget.resume) { widget.resume(true); } } } KConnection.prototype.processNonOk = function(widget, nonOk) { Kinky.setError(nonOk.content); switch (nonOk.httpStatus) { case 200: { break; } case 302: { break; } case 307: { var url = encodeURIComponent(window.document.location.href); window.document.location = nonOk.content.description + '&redirect_uri=' + url; break; } case 1223: case 204: { if (widget.onNoContent) { widget.onNoContent(nonOk.content); return; } else { KBreadcrumb.dispatchEvent(widget.id, { action : '/no-content' }); } break; } case 400: { if (widget.onError) { widget.onError(nonOk.content); return; } else { KBreadcrumb.dispatchEvent(null, { action : '/bad-request' }); } break; } case 403: { if (widget.onError) { widget.onError(nonOk.content); return; } else { KBreadcrumb.dispatchEvent(null, { action : '/forbidden' }); } break; } case 404: { if (widget.onError) { widget.onError(nonOk.content); return; } else { KBreadcrumb.dispatchEvent(null, { action : '/not-found' }); } break; } case 401: { if (widget.onError) { widget.onError(nonOk.content); return; } else { KBreadcrumb.dispatchEvent(null, { action : '/authentication' }); } break; } default: { if (widget.onError) { widget.onError(nonOk.content); return; } else { KBreadcrumb.dispatchEvent(null, { action : '/error' }); } break; } } } KConnection.getConnection = function(type) { var connection = null; eval('connection = KConnection.connections[type] || (KConnection.connections[type] = new ' + KConnection.connectors[type] + '(Kinky.SERVICES_URL[type] || Kinky.SERVICES_URL, Kinky.DATA_URL[type] || Kinky.DATA_URL));'); return connection; } KConnection.registerConnector = function(type, connectorClass) { KConnection.connectors[type] = connectorClass; } KConnection.connectors = {}; KConnection.connections = {}; KConnectionPHP.prototype = new KConnection(); KConnectionPHP.prototype.constructor = KConnectionPHP; KConnection.registerConnector('php', 'KConnectionPHP'); function KConnectionPHP(url, dataURL) { if (url && dataURL) { KConnection.call(this, url, dataURL); } } KConnectionPHP.prototype.send = function(request, params, user, password) { var channel = this.connect(request); var method = 'POST'; var url = this.urlBase; var content = this.getServiceParams(request, params); var setHeader = true; channel.open(method, url, true); if (setHeader) { channel.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } if (user != null) { channel.setRequestHeader('Authorization', this.getBasicHTTPAuthentication(user, password)); Kinky.getWidget(request.id).needAuthentication = false; } if (KOAuth.getAccessToken()) { channel.setRequestHeader('OAuth2-Authorization', KOAuth.getAccessToken()); } channel.send(content); } KConnectionJSON.prototype = new KConnection(); KConnectionJSON.prototype.constructor = KConnectionJSON; KConnection.registerConnector('js', 'KConnectionJSON'); function KConnectionJSON(url, dataURL) { if (url && dataURL) { KConnection.call(this, url, dataURL); } } KConnectionJSON.prototype.send = function(request, params, user, password) { var channel = this.connect(request); var content = null; var setHeader = false; var url = null; var method = 'GET'; if (request.type + ':' + request.namespace + ':' + request.service == Kinky.BASE_CONTENT_SERVICE) { var contentDataSet = params.contentView.split('(')[0]; if (params && params.offset != null && params.limit) { url = this.dataUrlBase + request.namespace + '/' + contentDataSet + '/paginated/' + Math.round(params.offset / params.limit) + KConnectionJSON.JSON_FILE_EXTENSION; } else { if (params.groupby) { url = this.dataUrlBase + request.namespace + '/' + contentDataSet + '/grouped/' + params.groupby + KConnectionJSON.JSON_FILE_EXTENSION; } else { url = this.dataUrlBase + request.namespace + '/' + contentDataSet + '/' + params.contentID + KConnectionJSON.JSON_FILE_EXTENSION; } } } else { var queryString = (request.service.indexOf('?') == -1 ? '' : request.service.substr(request.service.indexOf('?'))); url = this.dataUrlBase + request.namespace + '/' + request.service + (params && params.offset != null && params.limit ? '-pages/' + (Math.round(params.offset / params.limit)) : '') + KConnectionJSON.JSON_FILE_EXTENSION + queryString; } channel.open(method, url, true); if (setHeader) { channel.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } if (user != null) { channel.setRequestHeader('Authorization', this.getBasicHTTPAuthentication(user, password)); Kinky.getWidget(request.id).needAuthentication = false; } if (KOAuth.getAccessToken()) { channel.setRequestHeader('OAuth2-Authorization', KOAuth.getAccessToken()); } channel.send(content); } KConnectionJSON.JSON_FILE_EXTENSION = '.json'; KOAuth.prototype = {}; KOAuth.prototype.constructor = KOAuth; function KOAuth() { } KOAuth.start = function() { KOAuth.lockPicker.accessToken = null; KOAuth.lockPicker.request = null; KOAuth.lockPicker.init(); } KOAuth.destroy = function() { KOAuth.lockPicker.accessToken = null; KOAuth.lockPicker.request = null; KSystem.removeCookie('KINKY_OAUTH_ACCESS_TOKEN'); KSystem.removeCookie('KINKY_OAUTH_CODE'); } KOAuth.getAccessToken = function() { if (KOAuth.lockPicker.accessToken) { return KOAuth.lockPicker.accessToken.access_token; } return null; } KOAuth.setAccessToken = function(token) { if (typeof token == 'string') { KOAuth.lockPicker.onAccessToken({ access_token : token }); } else { KOAuth.lockPicker.onAccessToken(token); } } KOAuth.prototype.init = function() { var oauthCookie = KSystem.getCookie('KINKY_OAUTH_ACCESS_TOKEN'); if (oauthCookie.access_token && window.document.location.href.indexOf('access_token=') == -1) { this.accessToken = oauthCookie; this.negotiate(oauthCookie); } else { this.negotiate(); } } KOAuth.prototype.onAccessToken = function(data, expires_in) { var expires = (new Date()).getTime() + ((expires_in - 60) * 1000); KSystem.setCookie('KINKY_OAUTH_ACCESS_TOKEN', data, expires); KSystem.removeCookie('KINKY_OAUTH_CODE'); this.accessToken = data; } KOAuth.prototype.negotiate = function() { var indexOfCode = window.document.location.href.indexOf('code='); var indexOfToken = window.document.location.href.indexOf('access_token='); if (indexOfCode != -1) { var indexOfE = window.document.location.href.indexOf('&', indexOfCode); var code = window.document.location.href.substring(indexOfCode + 'code='.length, indexOfE == -1 ? window.document.location.href.length : indexOfE); var url = window.document.location.href.substring(0, indexOfCode - 1); KSystem.setCookie('KINKY_OAUTH_CODE', { code : code }); window.document.location = url; } else if (indexOfToken != -1) { var indexOfE = window.document.location.href.indexOf('&', indexOfToken); var accessToken = window.document.location.href.substring(indexOfToken + 'access_token='.length, indexOfE == -1 ? window.document.location.href.length : indexOfE); var indexOfExpires = window.document.location.href.indexOf('expires_in='); var expires_in = null; if (indexOfExpires != -1) { indexOfE = window.document.location.href.indexOf('&', indexOfExpires); expires_in = window.document.location.href.substring(indexOfExpires + 'expires_in='.length, indexOfE == -1 ? window.document.location.href.length : indexOfE); } var url = window.document.location.href.substring(0, indexOfToken - 1); if (expires_in != null && expires_in < 65) { KSystem.removeCookie('KINKY_OAUTH_ACCESS_TOKEN'); } else { this.onAccessToken({ access_token : accessToken }, expires_in || 3600); } window.document.location = url; if (url.indexOf('#') != -1) { this.negotiate(); } } else if (KSystem.getCookie('KINKY_OAUTH_CODE').code) { var request = { type : Kinky.NEGOTIATE_SESSION_SERVICE.substring(0, Kinky.NEGOTIATE_SESSION_SERVICE.indexOf(':')), namespace : Kinky.NEGOTIATE_SESSION_SERVICE.substring(Kinky.NEGOTIATE_SESSION_SERVICE.indexOf(':') + 1, Kinky.NEGOTIATE_SESSION_SERVICE.lastIndexOf(':')), service : Kinky.NEGOTIATE_SESSION_SERVICE.substring(Kinky.NEGOTIATE_SESSION_SERVICE.lastIndexOf(':') + 1).replace(/authorize/, 'access_token') + '&code=' + KSystem.getCookie('KINKY_OAUTH_CODE').code + '&grant_type=code', action : 'get', id : 'picker', renegotiate : true, lang : Kinky.bunnyMan.currentLanguage, callback : 'KOAuth.lockPicker.onAccessToken' } KSystem.removeCookie('KINKY_OAUTH_CODE'); this.request = request; KConnection.getConnection(request.type).send(request, null, Kinky.DEFAULT_USER, Kinky.DEFAULT_USER_SECRET); } else { var request = { type : Kinky.NEGOTIATE_SESSION_SERVICE.substring(0, Kinky.NEGOTIATE_SESSION_SERVICE.indexOf(':')), namespace : Kinky.NEGOTIATE_SESSION_SERVICE.substring(Kinky.NEGOTIATE_SESSION_SERVICE.indexOf(':') + 1, Kinky.NEGOTIATE_SESSION_SERVICE.lastIndexOf(':')), service : Kinky.NEGOTIATE_SESSION_SERVICE.substring(Kinky.NEGOTIATE_SESSION_SERVICE.lastIndexOf(':') + 1), action : 'get', id : 'picker', renegotiate : true, lang : Kinky.bunnyMan.currentLanguage, callback : 'KOAuth.lockPicker.onNegotiate' } this.request = request; KConnection.getConnection(request.type).send(request, null, Kinky.DEFAULT_USER, Kinky.DEFAULT_USER_SECRET); } } KOAuth.prototype.onNegotiate = function(data) { if (data.error) { } else { Kinky.init(); } } KOAuth.lockPicker = new KOAuth(); KEffect.prototype.constructor = KEffect; function KEffect(widget, tween, element) { if (widget) { this.widget = widget; this.tween = tween; this.tween.delay = this.tween.delay == null ? 0 : this.tween.delay; this.stop = false; this.element = element; this.id = null; this.timerCode = 'void(0);'; } } KEffect.prototype.config = function() { } KEffect.prototype.go = function() { } KEffect.prototype.cancel = function(noOnComplete) { this.stop = true; this.cancel = function() { return; } var tween = this.tween; var widget = this.widget; KEffects.stopEffect(this); if (!noOnComplete && tween.onComplete != null) { tween.onComplete(widget, tween); } } KEffects.prototype.constructor = KEffects; function KEffects() { } KEffects.effecting = new Object(); KEffects.widgetEffects = new Object(); KEffects.counter = 0; KEffects.installed = new Object(); KEffects.installEffect = function(typeName, className) { KEffects.installed[typeName] = className; } KEffects.stopEffect = function(effect) { delete KEffects.effecting[effect.id]; delete KEffects.widgetEffects[effect.tween.target.id + effect.tween.type]; } KEffects.cancelEffect = function(element, effectType) { if (KEffects.widgetEffects[element.id + effectType]) { KEffects.widgetEffects[element.id + effectType].cancel(); } } KEffects.addEffect = function(element, tweenToAdd) { var widget = (element instanceof KWidget ? element : KSystem.getWidget(element, tweenToAdd.targetClass)); var tweens = null; if (tweenToAdd instanceof Array) { tweens = tweenToAdd; } else { tweens = new Array(); tweens.push(tweenToAdd); } for ( var index in tweens) { var effect = null; var effectCounter = KEffects.counter++; var tween = tweens[index]; if (tween.type != 'drag' && (!tween.duration || !tween.go)) { continue; } if (element instanceof KWidget) { tween.target = widget.panel; } else { element.id = element.id || ('child' + widget.id.replace(/widget/, '') + '.' + effectCounter); tween.target = element; } if (KEffects.widgetEffects[element.id + tween.type]) { KEffects.widgetEffects[element.id + tween.type].cancel(true); } eval('effect = new ' + KEffects.installed[tween.type] + '(widget, tween, element);'); effect.tween.id = effect.id = 'effect' + effectCounter; KEffects.widgetEffects[tween.target.id + tween.type] = KEffects.effecting[effect.id] = effect; effect.start = (new Date()).getTime(); effect.config(); effect.go(); } } KEffects.loadTimmingFunctions = function() { if (Kinky.CSS_READY == 'css3') { KEffects.linear = 'linear'; KEffects.easeOutCubic = 'ease-out'; KEffects.easeOutQuart = 'ease-out'; KEffects.easeOutSine = 'ease-out'; KEffects.easeOutExpo = 'ease-out'; KEffects.easeInExpo = 'ease-in'; KEffects.easeInOutExpo = 'ease-in-out'; } else { KEffects.linear = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var t = now - time; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; // c*t/d + b var t = now - time; var d = duration; for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; toReturn.value[index] = stop ? targetValue[index] : c * t / d + b; } return toReturn; }; KEffects.easeOutCubic = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var t = now - time; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; // c*t/d + b var t = now - time; var d = duration; for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; toReturn.value[index] = stop ? targetValue[index] : c * ((t = t / d - 1) * t * t + 1) + b; } return toReturn; }; KEffects.easeOutQuart = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var t = now - time; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; // -c * ((t=t/d-1)*t*t*t - 1) + b var t = now - time; var d = duration; for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; toReturn.value[index] = stop ? targetValue[index] : -c * ((t = t / d - 1) * t * t * t - 1) + b; } return toReturn; }; KEffects.easeOutSine = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var t = now - time; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; // c * Math.sin(t/d * (Math.PI/2)) + b; var t = now - time; var d = duration; for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; toReturn.value[index] = stop ? targetValue[index] : c * Math.sin(t / d * (Math.PI / 2)) + b; } return toReturn; }; KEffects.easeOutExpo = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; // (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; var t = now - time; var d = duration; for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; toReturn.value[index] = stop ? targetValue[index] : c * (-Math.pow(2, -10 * t / d) + 1) + b; } return toReturn; }; KEffects.easeInExpo = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; var t = now - time; var d = duration; for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; toReturn.value[index] = stop ? targetValue[index] : (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b; } return toReturn; }; KEffects.easeInOutExpo = function(duration, time, targetValue, initialValue, currentValue, fArgs) { var fps = 1000 / (fArgs.fps * 2); var now = (new Date()).getTime(); var stop = now >= time + duration; var toReturn = { stop : stop, step : Math.round(fps), time : time, duration : duration, go : targetValue, from : initialValue, fArgs : fArgs }; toReturn.value = {}; var t = now - time; var d = duration; var n_t = (t / (d / 2)); for ( var index in targetValue) { var c = (targetValue[index] - initialValue[index]); var b = initialValue[index]; if (stop) { toReturn.value[index] = targetValue[index]; } else if (t == 0) { toReturn.value[index] = b; } else if (t == d) { toReturn.value[index] = b + c; } else if (n_t < 1) { toReturn.value[index] = c / 2 * Math.pow(2, 10 * (n_t - 1)) + b; } else { toReturn.value[index] = c / 2 * (-Math.pow(2, -10 * --n_t) + 2) + b; } } return toReturn; }; } } KEffectBackgroundMove.prototype = new KEffect(); KEffectBackgroundMove.prototype.constructor = KEffectBackgroundMove; KEffects.installEffect('background-move', 'KEffectBackgroundMove'); function KEffectBackgroundMove(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); this.widget.effects[this.tween.type] = {}; } } KEffectBackgroundMove.prototype.config = function() { if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } var id = this.id; this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowMove(); } } this.tween.unit = this.tween.unit || 'px'; this.tween.y = parseInt(KSystem.normalizePixelValue(this.tween.target.style.backgroundPosition.split(' ')[1])); if (isNaN(this.tween.y)) { this.tween.y = 0; } this.tween.x = parseInt(KSystem.normalizePixelValue(this.tween.target.style.backgroundPosition.split(' ')[0])); if (isNaN(this.tween.x)) { this.tween.x = 0; } this.tween.target.style.backgroundPosition = this.tween.x + 'px ' + this.tween.y + 'px'; } KEffectBackgroundMove.prototype.go = function() { if (!Kinky.ALLOW_EFFECTS) { this.tween.target.style.backgroundPosition = this.tween.go.x + 'px ' + this.tween.go.y + 'px'; if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { x : this.tween.x, y : this.tween.y }, go : { x : this.tween.go.x || 0, y : this.tween.go.y || 0 }, from : { x : this.tween.x, y : this.tween.y }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); } KEffectBackgroundMove.prototype.slowMove = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var x = this.fValue.value.x = Math.round(this.fValue.value.x); var y = this.fValue.value.y = Math.round(this.fValue.value.y); if (!this.tween.lock || !this.tween.lock.y) { this.tween.y = y; } if (!this.tween.lock || !this.tween.lock.x) { this.tween.x = x; } this.tween.target.style.backgroundPosition = this.tween.x + 'px ' + this.tween.y + 'px'; if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } } KEffectDrag.prototype = new KEffect(); KEffectDrag.prototype.constructor = KEffectDrag; KEffects.installEffect('drag', 'KEffectDrag'); function KEffectDrag(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectDrag.prototype.config = function() { if (this.widget.effects.drag) { delete this.widget.effects.drag; } this.tween.target = this.tween.applyToElement ? this.tween.target : this.widget.panel; this.widget.effects[this.tween.type] = this.tween; if (this.tween.dragndrop) { KSystem.addEventListener(this.element, 'mousedown', function(event) { var mouseEvent = KSystem.getEvent(event); if (mouseEvent.preventDefault) { mouseEvent.preventDefault(); } else { mouseEvent.returnValue = false; } var widget = KEffectDrag.getEventWidget(event); var element = KSystem.getEventTarget(event); widget.effects.drag.stillDown = true; KSystem.addEventListener(element, 'mouseup', KEffectDrag.timeOutDown); KSystem.addTimer(function() { if (widget.effects.drag.stillDown) { KSystem.removeEventListener(element, 'mouseup', KEffectDrag.timeOutDown); KEffectDrag.startDrag(event); } }, 200); }); } else { KSystem.addEventListener(this.element, 'mousedown', KEffectDrag.startDrag); } } KEffectDrag.prototype.go = function() { } KEffectDrag.getEventWidget = function(event) { var widget = KSystem.getEventWidget(event); try { while (!widget.effects.drag) { widget = widget.parent; } return widget; } catch (e) { return null; } } KEffectDrag.timeOutDown = function(event) { var tween = KEffectDrag.getEventWidget(event).effects.drag; tween.stillDown = false; } KEffectDrag.startDrag = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KEffectDrag.getEventWidget(event); KEffectDrag.dragging = widget.id; if (mouseEvent.preventDefault) { mouseEvent.preventDefault(); } else { mouseEvent.returnValue = false; } widget.effects.drag.x = (mouseEvent.pageX ? mouseEvent.pageX : (window.document.documentElement ? mouseEvent.clientX + window.document.documentElement.scrollLeft : mouseEvent.clientX + window.document.body.scrollLeft)); widget.effects.drag.y = (mouseEvent.pageY ? mouseEvent.pageY : (window.document.documentElement ? mouseEvent.clientY + window.document.documentElement.scrollTop : mouseEvent.clientY + window.document.body.scrollTop)); if (widget.effects.drag.onStart != null) { widget.effects.drag.onStart(widget, widget.effects.drag); } widget.effects.drag.animating = true; widget.effects.drag.original = { x : KSystem.normalizePixelValue(widget.effects.drag.target.style.left), y : KSystem.normalizePixelValue(widget.effects.drag.target.style.top), left : KSystem.normalizePixelValue(widget.effects.drag.target.style.left), top : KSystem.normalizePixelValue(widget.effects.drag.target.style.top) }; var left = KSystem.normalizePixelValue(widget.effects.drag.target.style.left); var top = KSystem.normalizePixelValue(widget.effects.drag.target.style.top); if (widget.effects.drag.dragndrop) { widget.effects.drag.original.target = widget.effects.drag.target; widget.effects.drag.target = widget.effects.drag.target.cloneNode(true); widget.effects.drag.target.style.position = 'absolute'; widget.effects.drag.target.id = null; window.document.body.appendChild(widget.effects.drag.target); if (isNaN(left)) { widget.effects.drag.target.style.left = widget.effects.drag.x + 'px'; left = widget.effects.drag.x; } if (isNaN(top)) { widget.effects.drag.target.style.top = widget.effects.drag.y + 'px'; top = widget.effects.drag.x; } } widget.effects.drag.left = left; widget.effects.drag.top = top; KSystem.addEventListener(window.document, 'mouseup', KEffectDrag.stopDrag); KSystem.addEventListener(window.document, 'mousemove', KEffectDrag.drag); } KEffectDrag.getDragWidget = function(widget) { if (widget.effects.drag) { return widget; } if (widget.parent) { return KEffectDrag.getDragWidget(widget.parent); } } KEffectDrag.drag = function(event) { var mouseEvent = KSystem.getEvent(event); if (mouseEvent.preventDefault) { mouseEvent.preventDefault(); } else { mouseEvent.returnValue = false; } var widget = Kinky.getWidget(KEffectDrag.dragging); if (!widget.effects.drag.lock || !widget.effects.drag.lock.y) { var y = (mouseEvent.pageY ? mouseEvent.pageY : (window.document.documentElement ? mouseEvent.clientY + window.document.documentElement.scrollTop : mouseEvent.clientY + window.document.body.scrollTop)); var top = (parseInt(widget.effects.drag.target.style.top.replace(/px/, '')) + (y - widget.effects.drag.y)); if (widget.effects.drag.rectangle && (top < widget.effects.drag.rectangle[0] || top > widget.effects.drag.rectangle[2])) { return; } widget.effects.drag.top = top; widget.effects.drag.target.style.top = widget.effects.drag.top + 'px'; } if (!widget.effects.drag.lock || !widget.effects.drag.lock.x) { var x = (mouseEvent.pageX ? mouseEvent.pageX : (window.document.documentElement ? mouseEvent.clientX + window.document.documentElement.scrollLeft : mouseEvent.clientX + window.document.body.scrollLeft)); var left = (parseInt(widget.effects.drag.target.style.left.replace(/px/, '')) + (x - widget.effects.drag.x)); if (widget.effects.drag.rectangle && (left > widget.effects.drag.rectangle[1] || left < widget.effects.drag.rectangle[3])) { return; } widget.effects.drag.left = left; widget.effects.drag.target.style.left = widget.effects.drag.left + 'px'; } widget.effects.drag.x = x; widget.effects.drag.y = y; if (widget.effects.drag.onAnimate != null) { KSystem.addTimer(function() { widget.effects.drag.onAnimate(widget, widget.effects.drag); }, 1); } } KEffectDrag.stopDrag = function(event, target) { var widget = target || Kinky.getWidget(KEffectDrag.dragging); if (widget.effects.drag == null || !widget.effects.drag.animating) { return; } KSystem.removeEventListener(window.document, 'mouseup', KEffectDrag.stopDrag); KSystem.removeEventListener(window.document, 'mousemove', KEffectDrag.drag); widget.effects.drag.animating = false; KEffectDrag.dragging = null; if (widget.effects.drag.onComplete != null) { widget.effects.drag.onComplete(widget, widget.effects.drag); } if (widget.effects.drag.dragndrop) { window.document.body.removeChild(widget.effects.drag.target); widget.effects.drag.target = widget.effects.drag.original.target; } } KEffectFade.prototype = new KEffect(); KEffectFade.prototype.constructor = KEffectFade; KEffects.installEffect('fade', 'KEffectFade'); function KEffectFade(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectFade.prototype.config = function() { var id = this.id; this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowFade(); } } if (!this.tween.realAlpha) { this.tween.target = this.widget.background.cloneNode(true); this.widget.setStyle({ opacity : 1 - (this.tween.from.alpha) }, this.tween.target); this.widget.panel.appendChild(this.tween.target); } if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } } KEffectFade.prototype.go = function() { var id = this.id; if ((this.tween.cssReady && this.tween.cssReady == 'css3') || ((!this.cssReady || this.cssReady != 'css2') && Kinky.CSS_READY == 'css3')) { var style = { 'MozTransitionDuration' : this.tween.duration + 'ms', 'WebkitTransitionDuration' : this.tween.duration + 'ms', 'OTransitionDuration' : this.tween.duration + 'ms', 'MozTransitionTimingFunction' : this.tween.f, 'WebkitTransitionTimingFunction' : this.tween.f, 'MozTransitionProperty': 'opacity', 'WebkitTransitionProperty': 'opacity', 'OTransitionProperty': 'opacity' }; style.opacity = this.tween.go.alpha; KCSS.setStyle(style, [this.tween.target]); KSystem.addTimer(function() { KCSS.setStyle({ 'MozTransition' : 'none', 'WebkitTransition' : 'none', 'OTransition' : 'none' }, [KEffects.effecting[id].tween.target]); KEffects.effecting[id].cancel(); }, this.tween.duration + 20); return; } if (!Kinky.ALLOW_EFFECTS) { if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { alpha : !this.tween.realAlpha ? 1 - (this.tween.from.alpha) : this.tween.from.alpha }, go : { alpha : !this.tween.realAlpha ? 1 - (this.tween.go.alpha) : this.tween.go.alpha }, from : { alpha : !this.tween.realAlpha ? 1 - (this.tween.from.alpha) : this.tween.from.alpha }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); } KEffectFade.prototype.cancel = function(noOnComplete) { this.stop = true; this.cancel = function() { return; } var tween = this.tween; var widget = this.widget; // if (!this.tween.realAlpha) { // this.widget.panel.removeChild(this.tween.target); // } KEffects.stopEffect(this); if (!noOnComplete && tween.onComplete != null) { tween.onComplete(widget, tween); } } KEffectFade.prototype.slowFade = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var opacity = this.fValue.value.alpha = Math.round(this.fValue.value.alpha * Math.pow(10,2)) / Math.pow(10,2); this.widget.setStyle({ opacity : opacity }, this.tween.target); if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } } KEffectFontResize.prototype = new KEffect(); KEffectFontResize.prototype.constructor = KEffectFontResize; KEffects.installEffect('font-resize', 'KEffectFontResize'); function KEffectFontResize(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectFontResize.prototype.config = function() { var id = this.id; if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowResize(); } } this.tween.unit = this.tween.unit || 'em'; this.tween.original = { overflow : this.tween.target.style.overflow, position : this.tween.target.style.position }; this.tween.fontSize = parseInt(this.tween.target.style.fontSize.replace(/px|pt|em/, '')); if (isNaN(this.tween.fontSize) || this.tween.fontSize == null) { this.tween.fontSize = 8; } } KEffectFontResize.prototype.go = function() { var id = this.id; this.tween.target.style.display = 'block'; if ((this.tween.cssReady && this.tween.cssReady == 'css3') || ((!this.cssReady || this.cssReady != 'css2') && Kinky.CSS_READY == 'css3')) { KCSS.setStyle( { 'MozTransitionDuration' : this.tween.duration + 'ms', 'WebkitTransitionDuration' : this.tween.duration + 'ms', 'OTransitionDuration' : this.tween.duration + 'ms', 'MozTransitionTimingFunction' : this.tween.f, 'WebkitTransitionTimingFunction' : this.tween.f, 'MozTransitionProperty' : 'font-size', 'WebkitTransitionProperty' : 'font-size', 'OTransitionProperty' : 'font-size' }, [ this.tween.target ]); KCSS.setStyle( { 'font-size' : this.tween.go.fontSize + this.tween.unit }, [ this.tween.target ]); KSystem.addTimer(function() { KCSS.setStyle( { 'MozTransitionDuration' : 'none', 'WebkitTransitionDuration' : 'none', 'OTransitionDuration' : 'none', 'MozTransitionProperty' : 'none', 'WebkitTransitionProperty' : 'none', 'OTransitionProperty' : 'none' }, [ KEffects.effecting[id].tween.target ]); KEffects.effecting[id].cancel(); }, this.tween.duration + 20); return; } if (!Kinky.ALLOW_EFFECTS) { this.tween.target.style.fontSize = this.tween.go.fontSize + this.tween.unit; this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { fontSize : this.tween.fontSize }, go : { fontSize : this.tween.go.fontSize }, from : { fontSize : this.tween.fontSize }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); } KEffectFontResize.prototype.slowResize = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var fontSize = this.fValue.value.fontSize;// = Math.ceil(this.fValue.value.fontSize); this.tween.fontSize = fontSize; this.tween.target.style.fontSize = this.tween.fontSize + this.tween.unit;//Math.ceil(this.tween.fontSize) + this.tween.unit; if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } } KEffectMove.prototype = new KEffect(); KEffectMove.prototype.constructor = KEffectMove; KEffects.installEffect('move', 'KEffectMove'); function KEffectMove(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectMove.prototype.config = function() { var id = this.id; if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } this.yAxis = this.tween.gravity && this.tween.gravity.y ? this.tween.gravity.y : 'top'; this.xAxis = this.tween.gravity && this.tween.gravity.x ? this.tween.gravity.x : 'left'; this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowMove(); } } this.tween.unit = this.tween.unit || 'px'; eval('this.tween.y = parseInt(KSystem.normalizePixelValue(this.tween.target.style.' + this.yAxis + '));'); if (isNaN(this.tween.y)) { this.tween.y = 0; if (!this.tween.lock || !this.tween.lock.y) { eval('this.tween.target.style.' + this.yAxis + ' = \'0\';'); } } eval('this.tween.x = parseInt(KSystem.normalizePixelValue(this.tween.target.style.' + this.xAxis + '));'); if (isNaN(this.tween.x)) { this.tween.x = 0; if (!this.tween.lock || !this.tween.lock.x) { eval('this.tween.target.style.' + this.xAxis + ' = \'0\';'); } } } KEffectMove.prototype.go = function() { var id = this.id; if (this.tween.lock && this.tween.lock.y) { this.tween.y = this.tween.go.y = 0; } if (this.tween.lock && this.tween.lock.x) { this.tween.x = this.tween.go.x = 0; } if ((this.tween.cssReady && this.tween.cssReady == 'css3') || ((!this.cssReady || this.cssReady != 'css2') && Kinky.CSS_READY == 'css3')) { var style = { 'MozTransitionDuration' : this.tween.duration + 'ms', 'WebkitTransitionDuration' : this.tween.duration + 'ms', 'OTransitionDuration' : this.tween.duration + 'ms', 'MozTransitionTimingFunction' : this.tween.f, 'WebkitTransitionTimingFunction' : this.tween.f, 'MozTransitionProperty': this.yAxis + ',' + this.xAxis, 'WebkitTransitionProperty': this.yAxis + ',' + this.xAxis, 'OTransitionProperty': this.yAxis + ',' + this.xAxis }; if (!this.tween.lock || !this.tween.lock.x) { style[this.xAxis] = this.tween.go.x + 'px'; } if (!this.tween.lock || !this.tween.lock.y) { style[this.yAxis] = this.tween.go.y + 'px'; } KCSS.setStyle(style, [this.tween.target]); KSystem.addTimer(function() { KCSS.setStyle({ 'MozTransition' : 'none', 'WebkitTransition' : 'none', 'OTransition' : 'none' }, [KEffects.effecting[id].tween.target]); KEffects.effecting[id].cancel(); }, this.tween.duration + 20); return; } if (!Kinky.ALLOW_EFFECTS) { if (!this.tween.lock || !this.tween.lock.y) { eval('this.tween.target.style.' + this.yAxis + ' = this.tween.go.y + \'px\';') } if (!this.tween.lock || !this.tween.lock.x) { eval('this.tween.target.style.' + this.xAxis + ' = this.tween.go.x + \'px\';'); } this.tween.y = this.tween.go.y; this.tween.x = this.tween.go.x; if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration + 10, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { x : this.tween.x, y : this.tween.y }, go : { x : this.tween.go.x || 0, y : this.tween.go.y || 0 }, from : { x : this.tween.x, y : this.tween.y }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); } KEffectMove.prototype.slowMove = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var x = this.fValue.value.x = Math.round(this.fValue.value.x); var y = this.fValue.value.y = Math.round(this.fValue.value.y); if (!this.tween.lock || !this.tween.lock.y) { this.tween.y = y; eval('this.tween.target.style.' + this.yAxis + ' = Math.ceil(this.tween.y) + \'px\';'); } if (!this.tween.lock || !this.tween.lock.x) { this.tween.x = x; eval('this.tween.target.style.' + this.xAxis + ' = Math.ceil(this.tween.x) + \'px\';'); } if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } } KEffectRGB.prototype = new KEffect(); KEffectRGB.prototype.constructor = KEffectRGB; KEffects.installEffect('rgb', 'KEffectRGB'); function KEffectRGB(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectRGB.prototype.config = function() { var id = this.id; this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowRGB(); } }; if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } this.tween.color = this.tween.target.style.color || '#000000'; var color_info_from = KSystem.extractColorInfo(this.tween.color); this.tween.red = color_info_from.red; this.tween.green = color_info_from.green; this.tween.blue = color_info_from.blue; if(this.tween.go.rgb) { var color_info_to = KSystem.extractColorInfo(this.tween.go.rgb); this.tween.go.red = color_info_to.red; this.tween.go.green = color_info_to.green; this.tween.go.blue = color_info_to.blue; this.tween.go.rgb = null; } }; KEffectRGB.prototype.go = function() { var id = this.id; if ((this.tween.cssReady && this.tween.cssReady == 'css3') || ((!this.cssReady || this.cssReady != 'css2') && Kinky.CSS_READY == 'css3')) { var style = { 'MozTransitionDuration' : this.tween.duration + 'ms', 'WebkitTransitionDuration' : this.tween.duration + 'ms', 'OTransitionDuration' : this.tween.duration + 'ms', 'MozTransitionTimingFunction' : this.tween.f, 'WebkitTransitionTimingFunction' : this.tween.f, 'MozTransitionProperty': 'opacity', 'WebkitTransitionProperty': 'opacity', 'OTransitionProperty': 'opacity' }; style.opacity = this.tween.go.alpha; KCSS.setStyle(style, [this.tween.target]); KSystem.addTimer(function() { KCSS.setStyle({ 'MozTransition' : 'none', 'WebkitTransition' : 'none', 'OTransition' : 'none' }, [KEffects.effecting[id].tween.target]); KEffects.effecting[id].cancel(); }, this.tween.duration + 20); return; } if (!Kinky.ALLOW_EFFECTS) { this.widget.setStyle({ color : 'rgb(' + this.tween.go.red + ', ' + this.tween.go.green + ', ' + this.tween.go.blue + ')' }, this.tween.target); if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { red : this.tween.red, green : this.tween.green, blue : this.tween.blue }, go : { red : this.tween.go.red, green : this.tween.go.green, blue : this.tween.go.blue }, from : { red : this.tween.red, green : this.tween.green, blue : this.tween.blue }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); }; KEffectRGB.prototype.slowRGB = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var red = this.fValue.value.red = Math.round(this.fValue.value.red); var green = this.fValue.value.green = Math.round(this.fValue.value.green); var blue = this.fValue.value.blue = Math.round(this.fValue.value.blue); this.widget.setStyle({ color : 'rgb(' + red + ', ' + green + ', ' + blue + ')' }, this.tween.target); if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } }; KEffectResize.prototype = new KEffect(); KEffectResize.prototype.constructor = KEffectResize; KEffects.installEffect('resize', 'KEffectResize'); function KEffectResize(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectResize.prototype.config = function() { var id = this.id; if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowResize(); } } this.tween.unit = this.tween.unit || 'px'; this.tween.original = { overflow : this.tween.target.style.overflow, position : this.tween.target.style.position }; this.tween.gravity = this.tween.gravity || { yAxis : 'height', xAxis : 'width' }; this.tween.width = parseInt(this.tween.target.style.width.replace(/px/, '')); if (isNaN(this.tween.width) || this.tween.width == null) { this.tween.width = 0; if (!this.tween.lock || !this.tween.lock.width) { this.tween.target.style.width = '0px'; } } this.tween.height = parseInt(this.tween.target.style.height.replace(/px/, '')); if (isNaN(this.tween.height) || this.tween.height == null) { this.tween.height = 0; if (!this.tween.lock || !this.tween.lock.height) { this.tween.target.style.height = '0px'; } } } KEffectResize.prototype.go = function() { var id = this.id; this.tween.target.style.display = 'block'; if (this.tween.lock && this.tween.lock.height) { this.tween.height = this.tween.go.height = 0; } if (this.tween.lock && this.tween.lock.width) { this.tween.width = this.tween.go.width = 0; } if ((this.tween.cssReady && this.tween.cssReady == 'css3') || ((!this.cssReady || this.cssReady != 'css2') && Kinky.CSS_READY == 'css3')) { KCSS.setStyle( { 'MozTransitionDuration' : this.tween.duration + 'ms', 'WebkitTransitionDuration' : this.tween.duration + 'ms', 'OTransitionDuration' : this.tween.duration + 'ms', 'MozTransitionTimingFunction' : this.tween.f, 'WebkitTransitionTimingFunction' : this.tween.f, 'MozTransitionProperty' : 'width,height', 'WebkitTransitionProperty' : 'width,height', 'OTransitionProperty' : 'width,height' }, [ this.tween.target ]); if (!this.tween.lock || !this.tween.lock.width) { KCSS.setStyle( { 'width' : this.tween.go.width + 'px' }, [ this.tween.target ]); } if (!this.tween.lock || !this.tween.lock.height) { KCSS.setStyle( { 'height' : this.tween.go.height + 'px' }, [ this.tween.target ]); } KSystem.addTimer(function() { KCSS.setStyle( { 'MozTransitionDuration' : 'none', 'WebkitTransitionDuration' : 'none', 'OTransitionDuration' : 'none', 'MozTransitionProperty' : 'none', 'WebkitTransitionProperty' : 'none', 'OTransitionProperty' : 'none' }, [ KEffects.effecting[id].tween.target ]); KEffects.effecting[id].cancel(); }, this.tween.duration + 20); return; } if (!Kinky.ALLOW_EFFECTS) { if (!this.tween.lock || !this.tween.lock.width) { this.tween.target.style.width = this.tween.go.width + this.tween.unit; } if (!this.tween.lock || !this.tween.lock.height) { this.tween.target.style.height = this.tween.go.height + this.tween.unit; } this.widget.setStyle(this.tween.original, this.tween.target); if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { width : this.tween.width, height : this.tween.height }, go : { width : this.tween.go.width || 0, height : this.tween.go.height || 0 }, from : { width : this.tween.width, height : this.tween.height }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); } KEffectResize.prototype.slowResize = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var width = this.fValue.value.width = Math.round(this.fValue.value.width); var height = this.fValue.value.height = Math.round(this.fValue.value.height); if (!this.tween.lock || !this.tween.lock.width) { this.tween.width = width; this.tween.target.style.width = Math.ceil(this.tween.width) + this.tween.unit; } if (!this.tween.lock || !this.tween.lock.height) { this.tween.height = height; this.tween.target.style.height = Math.ceil(this.tween.height) + this.tween.unit; } if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } } KEffectWindowScrollTo.prototype = new KEffect(); KEffectWindowScrollTo.prototype.constructor = KEffectWindowScrollTo; KEffects.installEffect('window-scroll-to', 'KEffectWindowScrollTo'); function KEffectWindowScrollTo(widget, tween, element) { if (widget) { KEffect.call(this, widget, tween, element); } } KEffectWindowScrollTo.prototype.config = function() { var id = this.id; this.timerCode = function() { if (KEffects.effecting[id]) { KEffects.effecting[id].slowScrollTo(); } }; if (this.tween.onStart != null) { this.tween.onStart(this.widget, this.tween); } this.tween.x = window.pageXOffset || window.scrollLeft || document.body.scrollLeft || 0; this.tween.y = window.pageYOffset || window.scrollTop || document.body.scrollTop || 0; }; KEffectWindowScrollTo.prototype.go = function() { if (!Kinky.ALLOW_EFFECTS) { window.scrollTo(this.tween.go.x || 0, this.tween.go.y || 0); if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } this.cancel(); return; } this.fValue = { stop : false, duration : this.tween.duration, time : (new Date()).getTime() + this.tween.delay, step : 0, value : { x : this.tween.x, y : this.tween.y }, go : { x : this.tween.go.x, y : this.tween.go.y }, from : { x : this.tween.x, y : this.tween.y }, fArgs : { fps : this.tween.fps || 24 } }; KSystem.addTimer(this.timerCode, this.tween.delay); }; KEffectWindowScrollTo.prototype.slowScrollTo = function() { if (this.fValue.stop || this.stop) { this.cancel(); return; } this.fValue = this.tween.f(this.fValue.duration, this.fValue.time, this.fValue.go, this.fValue.from, this.fValue.value, this.fValue.fArgs); var x = this.fValue.value.x = Math.round(this.fValue.value.x); var y = this.fValue.value.y = Math.round(this.fValue.value.y); window.scrollTo(x || 0, y || 0); if (this.tween.onAnimate != null) { this.tween.onAnimate(this.widget, this.tween); } if (!this.fValue.stop && !this.stop) { KSystem.addTimer(this.timerCode, this.fValue.step); } else { this.cancel(); } }; var Base64 = { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } var HTML = { stripTags : function(data, tag) { if (!data) { return ''; } var regex = null; if (tag) { regex = new RegExp("<" + tag + "([^>]*)>|<\/" + tag + "([^>]*)>", 'g'); } else { regex = /<([^>]*)>|<\/([^>]*)>/g; } data = data.replace(regex, function(wholematch, match) { switch (match) { case 'p': return '\n'; case 'br': return String.fromCharCode(161); } return ""; }); return data.replace(/^\s*/, "").replace(/\s*$/, ""); } } var HTMLEntities = { decode: function(data){ data = data.replace(/&(\w+);/g, function(wholematch, match){ switch (match) { case 'nbsp': return String.fromCharCode(32); case 'iexcl': return String.fromCharCode(161); case 'cent': return String.fromCharCode(162); case 'pound': return String.fromCharCode(163); case 'curren': return String.fromCharCode(164); case 'yen': return String.fromCharCode(165); case 'brvbar': return String.fromCharCode(166); case 'sect': return String.fromCharCode(167); case 'uml': return String.fromCharCode(168); case 'copy': return String.fromCharCode(168); case 'ordf': return String.fromCharCode(170); case 'laquo': return String.fromCharCode(171); case 'not': return String.fromCharCode(172); case 'shy': return String.fromCharCode(173); case 'reg': return String.fromCharCode(174); case 'macr': return String.fromCharCode(175); case 'deg': return String.fromCharCode(176); case 'plusmn': return String.fromCharCode(177); case 'sup2': return String.fromCharCode(178); case 'sup3': return String.fromCharCode(179); case 'acute': return String.fromCharCode(180); case 'micro': return String.fromCharCode(181); case 'para': return String.fromCharCode(182); case 'middot': return String.fromCharCode(183); case 'cedil': return String.fromCharCode(184); case 'sup1': return String.fromCharCode(185); case 'ordm': return String.fromCharCode(186); case 'raquo': return String.fromCharCode(187); case 'frac14': return String.fromCharCode(188); case 'frac12': return String.fromCharCode(189); case 'frac34': return String.fromCharCode(190); case 'iquest': return String.fromCharCode(191); case 'Agrave': return String.fromCharCode(192); case 'Aacute': return String.fromCharCode(193); case 'Acirc': return String.fromCharCode(194); case 'Atilde': return String.fromCharCode(195); case 'Auml': return String.fromCharCode(196); case 'Aring': return String.fromCharCode(197); case 'AElig': return String.fromCharCode(198); case 'Ccedil': return String.fromCharCode(199); case 'Egrave': return String.fromCharCode(200); case 'Eacute': return String.fromCharCode(201); case 'Ecirc': return String.fromCharCode(202); case 'Euml': return String.fromCharCode(203); case 'Igrave': return String.fromCharCode(204); case 'Iacute': return String.fromCharCode(205); case 'Icirc': return String.fromCharCode(206); case 'Iuml': return String.fromCharCode(207); case 'ETH': return String.fromCharCode(208); case 'Ntilde': return String.fromCharCode(209); case 'Ograve': return String.fromCharCode(210); case 'Oacute': return String.fromCharCode(211); case 'Ocirc': return String.fromCharCode(212); case 'Otilde': return String.fromCharCode(213); case 'Ouml': return String.fromCharCode(214); case 'times': return String.fromCharCode(215); case 'Oslash': return String.fromCharCode(216); case 'Ugrave': return String.fromCharCode(217); case 'Uacute': return String.fromCharCode(218); case 'Ucirc': return String.fromCharCode(219); case 'Uuml': return String.fromCharCode(220); case 'Yacute': return String.fromCharCode(221); case 'THORN': return String.fromCharCode(222); case 'szlig': return String.fromCharCode(223); case 'agrave': return String.fromCharCode(224); case 'aacute': return String.fromCharCode(225); case 'acirc': return String.fromCharCode(226); case 'atilde': return String.fromCharCode(227); case 'auml': return String.fromCharCode(228); case 'aring': return String.fromCharCode(229); case 'aelig': return String.fromCharCode(230); case 'ccedil': return String.fromCharCode(231); case 'egrave': return String.fromCharCode(232); case 'eacute': return String.fromCharCode(233); case 'ecirc': return String.fromCharCode(234); case 'euml': return String.fromCharCode(235); case 'igrave': return String.fromCharCode(236); case 'iacute': return String.fromCharCode(237); case 'icirc': return String.fromCharCode(238); case 'iuml': return String.fromCharCode(239); case 'eth': return String.fromCharCode(240); case 'ntilde': return String.fromCharCode(241); case 'ograve': return String.fromCharCode(242); case 'oacute': return String.fromCharCode(243); case 'ocirc': return String.fromCharCode(244); case 'otilde': return String.fromCharCode(245); case 'ouml': return String.fromCharCode(246); case 'divide': return String.fromCharCode(247); case 'oslash': return String.fromCharCode(248); case 'ugrave': return String.fromCharCode(249); case 'uacute': return String.fromCharCode(250); case 'ucirc': return String.fromCharCode(251); case 'uuml': return String.fromCharCode(252); case 'yacute': return String.fromCharCode(253); case 'thorn': return String.fromCharCode(254); case 'yuml': return String.fromCharCode(255); case 'quot': return String.fromCharCode(34); case 'apos': return String.fromCharCode(39); case 'lt': return String.fromCharCode(60); case 'gt': return String.fromCharCode(62); case 'amp': return String.fromCharCode(38); } return ""; }); return data; }, encode: function(data, isHTML){ data = data.replace(/(.)/g, function(wholematch, match){ switch (match) { case String.fromCharCode(161): return '¡'; case String.fromCharCode(162): return '¢'; case String.fromCharCode(163): return '£'; case String.fromCharCode(164): return '¤'; case String.fromCharCode(165): return '¥'; case String.fromCharCode(166): return '¦'; case String.fromCharCode(167): return '§'; case String.fromCharCode(168): return '¨'; case String.fromCharCode(168): return '©'; case String.fromCharCode(170): return 'ª'; case String.fromCharCode(171): return '«'; case String.fromCharCode(172): return '¬'; case String.fromCharCode(173): return '­'; case String.fromCharCode(174): return '®'; case String.fromCharCode(175): return '¯'; case String.fromCharCode(176): return '°'; case String.fromCharCode(177): return '±'; case String.fromCharCode(178): return '²'; case String.fromCharCode(179): return '³'; case String.fromCharCode(180): return '´'; case String.fromCharCode(181): return 'µ'; case String.fromCharCode(182): return '¶'; case String.fromCharCode(183): return '·'; case String.fromCharCode(184): return '¸'; case String.fromCharCode(185): return '¹'; case String.fromCharCode(186): return 'º'; case String.fromCharCode(187): return '»'; case String.fromCharCode(188): return '¼'; case String.fromCharCode(189): return '½'; case String.fromCharCode(190): return '¾'; case String.fromCharCode(191): return '¿'; case String.fromCharCode(192): return 'À'; case String.fromCharCode(193): return 'Á'; case String.fromCharCode(194): return 'Â'; case String.fromCharCode(195): return 'Ã'; case String.fromCharCode(196): return 'Ä'; case String.fromCharCode(197): return 'Å'; case String.fromCharCode(198): return 'Æ'; case String.fromCharCode(199): return 'Ç'; case String.fromCharCode(200): return 'È'; case String.fromCharCode(201): return 'É'; case String.fromCharCode(202): return 'Ê'; case String.fromCharCode(203): return 'Ë'; case String.fromCharCode(204): return 'Ì'; case String.fromCharCode(205): return 'Í'; case String.fromCharCode(206): return 'Î'; case String.fromCharCode(207): return 'Ï'; case String.fromCharCode(208): return 'Ð'; case String.fromCharCode(209): return 'Ñ'; case String.fromCharCode(210): return 'Ò'; case String.fromCharCode(211): return 'Ó'; case String.fromCharCode(212): return 'Ô'; case String.fromCharCode(213): return 'Õ'; case String.fromCharCode(214): return 'Ö'; case String.fromCharCode(215): return '×'; case String.fromCharCode(216): return 'Ø'; case String.fromCharCode(217): return 'Ù'; case String.fromCharCode(218): return 'Ú'; case String.fromCharCode(219): return 'Û'; case String.fromCharCode(220): return 'Ü'; case String.fromCharCode(221): return 'Ý'; case String.fromCharCode(222): return 'Þ'; case String.fromCharCode(223): return 'ß'; case String.fromCharCode(224): return 'à'; case String.fromCharCode(225): return 'á'; case String.fromCharCode(226): return 'â'; case String.fromCharCode(227): return 'ã'; case String.fromCharCode(228): return 'ä'; case String.fromCharCode(229): return 'å'; case String.fromCharCode(230): return 'æ'; case String.fromCharCode(231): return 'ç'; case String.fromCharCode(232): return 'è'; case String.fromCharCode(233): return 'é'; case String.fromCharCode(234): return 'ê'; case String.fromCharCode(235): return 'ë'; case String.fromCharCode(236): return 'ì'; case String.fromCharCode(237): return 'í'; case String.fromCharCode(238): return 'î'; case String.fromCharCode(239): return 'ï'; case String.fromCharCode(240): return 'ð'; case String.fromCharCode(241): return 'ñ'; case String.fromCharCode(242): return 'ò'; case String.fromCharCode(243): return 'ó'; case String.fromCharCode(244): return 'ô'; case String.fromCharCode(245): return 'õ'; case String.fromCharCode(246): return 'ö'; case String.fromCharCode(247): return '÷'; case String.fromCharCode(248): return 'ø'; case String.fromCharCode(249): return 'ù'; case String.fromCharCode(250): return 'ú'; case String.fromCharCode(251): return 'û'; case String.fromCharCode(252): return 'ü'; case String.fromCharCode(253): return 'ý'; case String.fromCharCode(254): return 'þ'; case String.fromCharCode(255): return 'ÿ'; case String.fromCharCode(34): if (isHTML) { return '"'; } return '"'; case String.fromCharCode(39): if (isHTML) { return '\''; } return '''; case String.fromCharCode(60): if (isHTML) { return '<'; } return '<'; case String.fromCharCode(62): if (isHTML) { return '>'; } return '>'; case String.fromCharCode(38): if (isHTML) { return '&'; } return '&'; default: return match; } }); return data; } } if (!this.JSON) { JSON = function () { function f(n) { // Format integers to have at least two digits. return n < 10 ? '0' + n : n; } Date.prototype.toJSON = function () { //Eventually, this method will be based on the date.toISOString method. return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z'; }; var m = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }; function stringify(value, whitelist) { var a, // The array holding the partial texts. i, // The loop counter. k, // The member key. l, // Length. r = /["\\\x00-\x1f\x7f-\x9f]/g, v; // The member value. switch (typeof value) { case 'string': //If the string contains no control characters, no quote characters, and no //backslash characters, then we can safely slap some quotes around it. //Otherwise we must also replace the offending characters with safe sequences. return r.test(value) ? '"' + value.replace(r, function (a) { var c = m[a]; if (c) { return c; } c = a.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }) + '"' : '"' + value + '"'; case 'number': //JSON numbers must be finite. Encode non-finite numbers as null. return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': //Due to a specification blunder in ECMAScript, //typeof null is 'object', so watch out for that case. if (!value) { return 'null'; } //If the object has a toJSON method, call it, and stringify the result. if (typeof value.toJSON === 'function') { return stringify(value.toJSON()); } a = []; if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length'))) { //The object is an array. Stringify every element. Use null as a placeholder //for non-JSON values. l = value.length; for (i = 0; i < l; i += 1) { a.push(stringify(value[i], whitelist) || 'null'); } //Join all of the elements together and wrap them in brackets. return '[' + a.join(',') + ']'; } if (whitelist) { //If a whitelist (array of keys) is provided, use it to select the components //of the object. l = whitelist.length; for (i = 0; i < l; i += 1) { k = whitelist[i]; if (typeof k === 'string') { v = stringify(value[k], whitelist); if (v) { a.push(stringify(k) + ':' + v); } } } } else { //Otherwise, iterate through all of the keys in the object. for (k in value) { if (typeof k === 'string') { v = stringify(value[k], whitelist); if (v) { a.push(stringify(k) + ':' + v); } } } } //Join all of the member texts together and wrap them in braces. return '{' + a.join(',') + '}'; } } return { stringify: stringify, parse: function (text, filter) { var j; function walk(k, v) { var i, n; if (v && typeof v === 'object') { for (i in v) { if (Object.prototype.hasOwnProperty.apply(v, [i])) { n = walk(i, v[i]); if (n !== undefined) { v[i] = n; } } } } return filter(k, v); } //Parsing happens in three stages. In the first stage, we run the text against //regular expressions that look for non-JSON patterns. We are especially //concerned with '()' and 'new' because they can cause invocation, and '=' //because it can cause mutation. But just to be safe, we want to reject all //unexpected forms. //We split the first stage into 4 regexp operations in order to work around //crippling inefficiencies in IE's and Safari's regexp engines. First we //replace all backslash pairs with '@' (a non-JSON character). Second, we //replace all simple value tokens with ']' characters. Third, we delete all //open brackets that follow a colon or comma or that begin the text. Finally, //we look to see that the remaining characters are only whitespace or ']' or //',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { //In the second stage we use the eval function to compile the text into a //JavaScript structure. The '{' operator is subject to a syntactic ambiguity //in JavaScript: it can begin a block or an object literal. We wrap the text //in parens to eliminate the ambiguity. j = eval('(' + text + ')'); //In the optional third stage, we recursively walk the new structure, passing //each name/value pair to a filter function for possible transformation. return typeof filter === 'function' ? walk('', j) : j; } //If the text is not JSON parseable, then a SyntaxError is thrown. throw new SyntaxError('parseJSON'); } }; }(); } var KBrowserDetect = { init : function() { this.browsername = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; if ((this.browsername.indexOf("Firefox") != -1 || this.browsername.indexOf("Iceweasel") != -1 || this.browsername.indexOf("Mozilla") != -1) && parseInt(navigator.appVersion) >= 5) { this.browser = 1; } else if (this.browsername.indexOf("Explorer") != -1 && parseInt(navigator.appVersion) >= 4) { this.browser = 2; } else if (this.browsername.indexOf("Opera") != -1) { this.browser = 3; } else if (this.browsername.indexOf("Safari") != -1) { this.browser = 4; } else if (this.browsername.indexOf("Chrome") != -1) { this.browser = 5; } }, searchString : function(data) { for ( var i = 0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion : function(dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return null; return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); }, dataBrowser : [ { string : navigator.userAgent, subString : "Chrome", identity : "Chrome" }, { string : navigator.userAgent, subString : "OmniWeb", versionSearch : "OmniWeb/", identity : "OmniWeb" }, { string : navigator.vendor, subString : "Apple", identity : "Safari", versionSearch : "Version" }, { prop : window.opera, identity : "Opera" }, { string : navigator.vendor, subString : "iCab", identity : "iCab" }, { string : navigator.vendor, subString : "KDE", identity : "Konqueror" }, { string : navigator.userAgent, subString : "Firefox", identity : "Firefox" }, { string : navigator.vendor, subString : "Camino", identity : "Camino" }, { // for newer Netscapes (6+) string : navigator.userAgent, subString : "Netscape", identity : "Netscape" }, { string : navigator.userAgent, subString : "MSIE", identity : "Explorer", versionSearch : "MSIE" }, { string : navigator.userAgent, subString : "Gecko", identity : "Mozilla", versionSearch : "rv" }, { // for older Netscapes (4-) string : navigator.userAgent, subString : "Mozilla", identity : "Netscape", versionSearch : "Mozilla" } ], dataOS : [ { string : navigator.platform, subString : "Win", identity : "Windows" }, { string : navigator.platform, subString : "Mac", identity : "Mac" }, { string : navigator.platform, subString : "Linux", identity : "Linux" } ] }; KBrowserDetect.init(); var MD5 = function (string) { function RotateLeft(lValue, iShiftBits) { return (lValue<>>(32-iShiftBits)); } function AddUnsigned(lX,lY) { var lX4,lY4,lX8,lY8,lResult; lX8 = (lX & 0x80000000); lY8 = (lY & 0x80000000); lX4 = (lX & 0x40000000); lY4 = (lY & 0x40000000); lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); if (lX4 & lY4) { return (lResult ^ 0x80000000 ^ lX8 ^ lY8); } if (lX4 | lY4) { if (lResult & 0x40000000) { return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); } else { return (lResult ^ 0x40000000 ^ lX8 ^ lY8); } } else { return (lResult ^ lX8 ^ lY8); } } function F(x,y,z) { return (x & y) | ((~x) & z); } function G(x,y,z) { return (x & z) | (y & (~z)); } function H(x,y,z) { return (x ^ y ^ z); } function I(x,y,z) { return (y ^ (x | (~z))); } function FF(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function GG(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function HH(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function II(a,b,c,d,x,s,ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; function ConvertToWordArray(string) { var lWordCount; var lMessageLength = string.length; var lNumberOfWords_temp1=lMessageLength + 8; var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; var lNumberOfWords = (lNumberOfWords_temp2+1)*16; var lWordArray=Array(lNumberOfWords-1); var lBytePosition = 0; var lByteCount = 0; while ( lByteCount < lMessageLength ) { lWordCount = (lByteCount-(lByteCount % 4))/4; lBytePosition = (lByteCount % 4)*8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<>>29; return lWordArray; }; function WordToHex(lValue) { var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; for (lCount = 0;lCount<=3;lCount++) { lByte = (lValue>>>(lCount*8)) & 255; WordToHexValue_temp = "0" + lByte.toString(16); WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); } return WordToHexValue; }; function Utf8Encode(string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }; var x=Array(); var k,AA,BB,CC,DD,a,b,c,d; var S11=7, S12=12, S13=17, S14=22; var S21=5, S22=9 , S23=14, S24=20; var S31=4, S32=11, S33=16, S34=23; var S41=6, S42=10, S43=15, S44=21; string = Utf8Encode(string); x = ConvertToWordArray(string); a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; for (k=0;k>> (32 - s)); return t4; } ; function lsb_hex(val) { var str = ""; var i; var vh; var vl; for (i = 0; i <= 6; i += 2) { vh = (val >>> (i * 4 + 4)) & 0x0f; vl = (val >>> (i * 4)) & 0x0f; str += vh.toString(16) + vl.toString(16); } return str; } ; function cvt_hex(val) { var str = ""; var i; var v; for (i = 7; i >= 0; i--) { v = (val >>> (i * 4)) & 0x0f; str += v.toString(16); } return str; } ; function Utf8Encode(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for ( var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; } ; var blockstart; var i, j; var W = new Array(80); var H0 = 0x67452301; var H1 = 0xEFCDAB89; var H2 = 0x98BADCFE; var H3 = 0x10325476; var H4 = 0xC3D2E1F0; var A, B, C, D, E; var temp; msg = Utf8Encode(msg); var msg_len = msg.length; var word_array = new Array(); for (i = 0; i < msg_len - 3; i += 4) { j = msg.charCodeAt(i) << 24 | msg.charCodeAt(i + 1) << 16 | msg.charCodeAt(i + 2) << 8 | msg.charCodeAt(i + 3); word_array.push(j); } switch (msg_len % 4) { case 0: i = 0x080000000; break; case 1: i = msg.charCodeAt(msg_len - 1) << 24 | 0x0800000; break; case 2: i = msg.charCodeAt(msg_len - 2) << 24 | msg.charCodeAt(msg_len - 1) << 16 | 0x08000; break; case 3: i = msg.charCodeAt(msg_len - 3) << 24 | msg.charCodeAt(msg_len - 2) << 16 | msg.charCodeAt(msg_len - 1) << 8 | 0x80; break; } word_array.push(i); while ((word_array.length % 16) != 14) word_array.push(0); word_array.push(msg_len >>> 29); word_array.push((msg_len << 3) & 0x0ffffffff); for (blockstart = 0; blockstart < word_array.length; blockstart += 16) { for (i = 0; i < 16; i++) W[i] = word_array[blockstart + i]; for (i = 16; i <= 79; i++) W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); A = H0; B = H1; C = H2; D = H3; E = H4; for (i = 0; i <= 19; i++) { temp = (rotate_left(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5A827999) & 0x0ffffffff; E = D; D = C; C = rotate_left(B, 30); B = A; A = temp; } for (i = 20; i <= 39; i++) { temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff; E = D; D = C; C = rotate_left(B, 30); B = A; A = temp; } for (i = 40; i <= 59; i++) { temp = (rotate_left(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff; E = D; D = C; C = rotate_left(B, 30); B = A; A = temp; } for (i = 60; i <= 79; i++) { temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff; E = D; D = C; C = rotate_left(B, 30); B = A; A = temp; } H0 = (H0 + A) & 0x0ffffffff; H1 = (H1 + B) & 0x0ffffffff; H2 = (H2 + C) & 0x0ffffffff; H3 = (H3 + D) & 0x0ffffffff; H4 = (H4 + E) & 0x0ffffffff; } var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4); return temp.toLowerCase(); } var UTF8 = { // public method for url encoding encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // public method for url decoding decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } KNoExtensionException.prototype = new KException(); KNoExtensionException.prototype.constructor = KNoExtensionException; function KNoExtensionException(invoker, methodName) { KException.call(invoker, KSystem.getObjectClass(invoker) + '[' + invoker.id + ']' + ': ' + methodName + ': child class must implement this method.') } KScroll.prototype.constructor = KScroll; KScroll.activeScroll = null; function KScroll(parent, type, params) { if (parent) { this.type = type; this.parent = parent; this.className = KSystem.getObjectClass(this); this.effects = {}; this.id = this.parent.kinky.addWidget(this); this.panel = window.document.createElement('div'); this.panel.id = this.id; this.panel.className = ' KWidgetPanel KScroll '; this.panel.style.overflow = 'hidden'; this.panel.style.position = 'absolute'; if (type == KScroll.HSCROLL) { this.panel.style.left = (params.offsetLeft || '0') + 'px'; this.panel.style.bottom = (params.offsetBottom || '0') + 'px'; } else { this.panel.style.right = (params.offsetRight || '0') + 'px'; this.panel.style.top = (params.offsetTop || '0') + 'px'; } this.content = window.document.createElement('div'); this.content.className = ' KWidget' + type + ' ' + this.parent.className + type + ' '; this.content.style.position = 'relative'; this.panel.appendChild(this.content); this.up = window.document.createElement('button'); this.up.className = ' KWidgetUp' + type + ' ' + this.parent.className + 'Up' + type + ' '; this.up.setAttribute('type', 'button'); KSystem.addEventListener(this.up, 'click', KScroll.up); KSystem.addEventListener(this.up, 'mousedown', function(event) { var widget = KSystem.getEventWidget(event); widget.upTimer = KSystem.addTimer(function() { if (widget.upTimer) { KScroll.up(null, widget); } }, 500); }); KSystem.addEventListener(this.up, 'mouseup', function(event) { var widget = KSystem.getEventWidget(event); widget.upTimer = false; }); this.upTimer = null; this.up.style.position = 'absolute'; if (type == KScroll.HSCROLL) { this.up.style.width = (params && params.buttonWidth != null ? params.buttonWidth : 10) + 'px'; if (params && params.buttonWidth == 0) { this.up.style.display = 'none'; } this.up.style.left = '0'; } else { this.up.style.height = (params && params.buttonHeight != null ? params.buttonHeight : 10) + 'px'; if (params && params.buttonHeight == 0) { this.up.style.display = 'none'; } this.up.style.top = '0'; } this.content.appendChild(this.up); this.bar = window.document.createElement('button'); this.bar.className = ' KWidgetBar' + type + ' ' + this.parent.className + 'Bar' + type + ' '; this.bar.setAttribute('type', 'button'); this.bar.style.position = 'absolute'; if (type == KScroll.HSCROLL) { this.bar.style.left = '0'; } else { this.bar.style.top = '0'; } this.content.appendChild(this.bar); this.down = window.document.createElement('button'); this.down.className = ' KWidgetDown' + type + ' ' + this.parent.className + 'Down' + type + ' '; this.down.setAttribute('type', 'button'); KSystem.addEventListener(this.down, 'click', KScroll.down); KSystem.addEventListener(this.down, 'mousedown', function(event) { var widget = KSystem.getEventWidget(event); widget.downTimer = KSystem.addTimer(function() { if (widget.downTimer) { KScroll.down(null, widget); } }, 500); }); KSystem.addEventListener(this.down, 'mouseup', function(event) { var widget = KSystem.getEventWidget(event); widget.downTimer = false; }); this.downTimer = null; this.down.style.position = 'absolute'; if (type == KScroll.HSCROLL) { this.down.style.width = (params && params.buttonWidth != null ? params.buttonWidth : 10) + 'px'; if (params && params.buttonWidth == 0) { this.down.style.display = 'none'; } this.down.style.right = '0'; } else { this.down.style.height = (params && params.buttonHeight != null ? params.buttonHeight : 10) + 'px'; if (params && params.buttonHeight == 0) { this.down.style.display = 'none'; } this.down.style.bottom = '0'; } this.content.appendChild(this.down); this.activateMouseWheel = true; this.scrollTreshold = 1; this.scrollVelocity = 0.05; this.proportion = 0; this.barHeight = 0; this.viewportHeight = 0; this.scrollHeight = 0; this.contentHeight = 0; this.buttonHeight = 0; this.barWidth = 0; this.viewportWidth = 0; this.scrollWidth = 0; this.contentWidth = 0; this.buttonWidth = 0; if (params && params.buttonHeight) { this.setButtonHeight(params.buttonHeight); this.bar.style.top = params.buttonHeight + 'px'; } if (params && params.buttonWidth) { this.setButtonWidth(params.buttonWidth); this.bar.style.left = params.buttonWidth + 'px'; } if (params && params.scrollVelocity) { this.scrollVelocity = params.scrollVelocity; } if (params && params.pagesPerScroll) { this.scrollTreshold = 1 / params.pagesPerScroll; } this.pageScrollDuration = KScroll.pageScrollDuration; if (params && params.scrollEffectDuration) { this.pageScrollDuration = params.scrollEffectDuration; } this.pageScrollEffect = KEffects.easeOutExpo; if (params && params.scrollEffect) { this.pageScrollEffect = params.scrollEffect; } } } KScroll.prototype.go = function() { this.draw(); }; KScroll.prototype.setButtonHeight = function(height) { this.bar.style.top = height + 'px'; this.up.style.height = height + 'px'; this.down.style.height = height + 'px'; this.buttonHeight = height; }; KScroll.prototype.setButtonWidth = function(width) { this.bar.style.left = width + 'px'; this.up.style.width = width + 'px'; this.down.style.width = width + 'px'; this.buttonWidth = width; }; KScroll.prototype.childWidget = function() { return null; }; KScroll.prototype.toString = function(fromDump) { if (fromDump) { KSystem.ident = 0; return KSystem.widgetToString(this); } else { return this.className + '(' + this.id + ')'; } }; KScroll.prototype.addScrollListener = function(callback, widget) { if (!KScroll.listeners[this.id]) { KScroll.listeners[this.id] = new Array(); this.lastPos = 0; } KScroll.listeners[this.id].push({ widget : widget || this.parent, callback : callback }); }; KScroll.prototype.removeScrollListener = function(widget) { if (!KScroll.listeners[this.id]) { return; } for ( var index in KScroll.listeners[this.id]) { if (KScroll.listeners[this.id][index].widget.id == widget.id) { KScroll.listeners[this.id].splice(index, 1); break; } } }; KScroll.prototype.removeScrollListeners = function(callback, widget) { delete KScroll.listeners[this.id]; }; KScroll.prototype.draw = function() { this.up.innerHTML = '↑'; this.down.innerHTML = '↓'; this.target = this.target || this.parent.content; this.target.style.position = 'absolute'; this.target.style.left = '0'; this.target.style.top = '0'; KSystem.addEventListener(this.target, 'mouseover', KScroll.activateScroll); KSystem.addEventListener(this.target, 'mouseout', KScroll.deactivateScroll); this.parent.addResizeListener(KScroll.onWidgetResize); this.parent.addWindowResizeListener(KScroll.onWidgetResize); this.display = true; }; KScroll.prototype.scrollTo = function(pos, callback, noEffect) { this.scrollBarTo(Math.round(pos * this.proportion), callback, noEffect); }; KScroll.prototype.scrollBarTo = function(pos, callback, noEffect) { if (this.type == KScroll.VSCROLL) { var top = KSystem.normalizePixelValue(this.bar.style.top); if (!noEffect) { KEffects.addEffect(this.bar, { f : this.pageScrollEffect, cssReady : 'css2', type : 'move', duration : Math.round(this.pageScrollDuration * (Math.abs(pos - top) / this.offset)), lock : { x : true }, go : { y : pos > this.maxY ? this.maxY : pos }, onAnimate : KScroll.onUpDown, onComplete : function(widget, tween) { var tooltip = window.document.getElementById('ktooltip'); if (tooltip) { tooltip.style.display = 'block'; } if (callback) { callback(widget, tween); } } }); } else { pos = pos > this.maxY ? this.maxY : pos; KCSS.setStyle({ top : pos + 'px' }, [ this.bar ]); KCSS.setStyle({ top : Math.round(-(pos - this.buttonHeight) / this.proportion) + 'px' }, [ this.target ]); } } else { var left = KSystem.normalizePixelValue(this.bar.style.left); if (!noEffect) { KEffects.addEffect(this.bar, { f : this.pageScrollEffect, cssReady : 'css2', type : 'move', duration : Math.round(this.pageScrollDuration * (Math.abs(pos - left) / this.offset)), lock : { y : true }, go : { x : pos > this.maxX ? this.maxX : pos }, onAnimate : KScroll.onUpDown, onComplete : function(widget, tween) { var tooltip = window.document.getElementById('ktooltip'); if (tooltip) { tooltip.style.display = 'block'; } if (callback) { callback(widget, tween); } } }); } else { pos = pos > this.maxX ? this.maxX : pos; KCSS.setStyle({ left : pos + 'px' }, [ this.bar ]); KCSS.setStyle({ left : Math.round(-(pos - this.buttonWidth) / this.proportion) + 'px' }, [ this.target ]); } } }; KScroll.dispatchScroll = function() { for ( var index in KScroll.listeners) { var scroll = Kinky.getWidget(index); var currentPos = 0; if (scroll.type == KScroll.VSCROLL) { currentPos = KSystem.normalizePixelValue(scroll.bar.style.top) || 0; } else { currentPos = KSystem.normalizePixelValue(scroll.bar.style.left) || 0; } if (currentPos != scroll.lastPos) { scroll.lastPos = currentPos; for ( var listener in KScroll.listeners[index]) { if (KScroll.listeners[index][listener]) { KSystem.addTimer(function() { KScroll.listeners[index][listener].callback(KScroll.listeners[index][listener].widget, Kinky.getWidget(index), currentPos); }, 0); } } } } KSystem.addTimer(KScroll.dispatchScroll, 200); }; KScroll.activateScroll = function(event) { var widget = null; try { widget = KSystem.getEventWidget(event); } catch (e) { } if (!widget) { widget = KCombo.getEventWidget(event); } if (widget) { var scroll = KScroll.getScroll(widget); if (scroll) { KScroll.activeScroll = scroll.panel.style.display == 'block' ? scroll : null; } } }; KScroll.deactivateScroll = function(event) { var widget = null; try { widget = KSystem.getEventWidget(event); } catch (e) { } if (!widget) { widget = KCombo.getEventWidget(event); } if (widget) { var scroll = KScroll.getScroll(widget); if (scroll) { KScroll.activeScroll = null; } } }; KScroll.getScroll = function(widget) { while (widget && widget.scroll && !(widget.scroll[KScroll.VSCROLL] || widget.scroll[KScroll.HSCROLL])) { widget = widget.parent; } if (!widget || !widget.scroll) { return; } return widget.scroll[KScroll.VSCROLL] || widget.scroll[KScroll.HSCROLL]; }; KScroll.onUpDown = function(widget, tween) { if (widget.type == KScroll.VSCROLL) { widget.target.style.top = Math.round(-(tween.y - widget.buttonHeight) / widget.proportion) + 'px'; } else { widget.target.style.left = Math.round(-(tween.x - widget.buttonWidth) / widget.proportion) + 'px'; } }; KScroll.up = function(event, widget) { if (!widget) { widget = KSystem.getEventWidget(event); } var tooltip = window.document.getElementById('ktooltip'); if (tooltip) { tooltip.style.display = 'none'; } if (widget.type == KScroll.VSCROLL) { var top = KSystem.normalizePixelValue(widget.bar.style.top); var y = Math.round(top - (widget.offset)); y = y < widget.buttonHeight ? widget.buttonHeight : y; widget.scrollBarTo(y, function(widget, tween) { if (widget.upTimer) { widget.upTimer = KSystem.addTimer(function() { KScroll.up(null, widget); }, 10); } }); } else { var left = KSystem.normalizePixelValue(widget.bar.style.left); var x = Math.round(left - (widget.offset)); x = x < widget.buttonWidth ? widget.buttonWidth : x; widget.scrollBarTo(x, function(widget, tween) { if (widget.upTimer) { widget.upTimer = KSystem.addTimer(function() { KScroll.up(null, widget); }, 10); } }); } }; KScroll.down = function(event, widget) { if (!widget) { widget = KSystem.getEventWidget(event); } var tooltip = window.document.getElementById('ktooltip'); if (tooltip) { tooltip.style.display = 'none'; } if (widget.type == KScroll.VSCROLL) { var top = KSystem.normalizePixelValue(widget.bar.style.top); var y = Math.round(top + (widget.offset)); y = y > widget.maxY ? widget.maxY : y; widget.scrollBarTo(y, function(widget, tween) { if (widget.downTimer) { widget.downTimer = KSystem.addTimer(function() { KScroll.down(null, widget); }, 10); } }); } else { var left = KSystem.normalizePixelValue(widget.bar.style.left); var x = Math.round(left + (widget.offset)); x = x > widget.maxX ? widget.maxX : x; widget.scrollBarTo(x, function(widget, tween) { if (widget.downTimer) { widget.downTimer = KSystem.addTimer(function() { KScroll.down(null, widget); }, 10); } }); } }; KScroll.onWidgetResize = function(scrolledWidget, size) { if (!scrolledWidget || !scrolledWidget.activated() || !scrolledWidget.display) { return; } if (scrolledWidget.type == KScroll.VSCROLL && size.height == 0 || scrolledWidget.type == KScroll.HSCROLL && size.width == 0) { return; } if (scrolledWidget.scroll[KScroll.VSCROLL]) { var widget = scrolledWidget.scroll[KScroll.VSCROLL]; if (widget.rootPanel.style.height) { widget.content.style.height = widget.panel.style.height = widget.rootPanel.style.height; widget.viewportHeight = KSystem.normalizePixelValue(widget.panel.style.height); widget.barHeight = widget.viewportHeight - widget.buttonHeight * 2; widget.contentHeight = widget.parent.getHeight(); var newProportion = (widget.barHeight / widget.contentHeight); if (newProportion == widget.proportion) { return; } if ((widget.viewportHeight / widget.contentHeight) >= 1 || (widget.viewportHeight / widget.contentHeight) <= 0) { widget.panel.style.display = 'none'; widget.proportion = newProportion; widget.scrollBarTo(widget.buttonHeight, null, true); return; } else { if (widget.bar.style.top == '0px' && (widget.up.style.height || widget.up.style.height != '0px')) { widget.bar.style.top = widget.up.style.height; } widget.panel.style.display = 'block'; } widget.proportion = newProportion; widget.scrollHeight = Math.ceil((widget.viewportHeight) * widget.proportion) - 2; widget.offset = widget.scrollHeight / widget.scrollTreshold; widget.bar.style.height = widget.scrollHeight + 'px'; widget.maxY = widget.barHeight - widget.scrollHeight + widget.buttonHeight; var thisTop = KSystem.normalizePixelValue(widget.bar.style.top); if (widget.effects.drag) { widget.effects.drag.rectangle = [ widget.buttonHeight, 0, widget.maxY, 0 ]; widget.effects.drag.onAnimate = function(widget, tween) { widget.target.style.top = Math.round(-(tween.top - widget.buttonHeight) / widget.proportion) + 'px'; }; } else { KEffects.addEffect(widget.bar, [ { f : KEffects.linear, type : 'drag', lock : { x : true }, applyToElement : true, rectangle : [ widget.buttonHeight, 0, widget.maxY, 0 ], onAnimate : function(widget, tween) { widget.target.style.top = Math.round(-(tween.top - widget.buttonHeight) / widget.proportion) + 'px'; } } ]); } if (thisTop + 2 > widget.maxY) { widget.scrollBarTo(widget.maxY, null, true); } } } if (scrolledWidget.scroll[KScroll.HSCROLL]) { var widget = scrolledWidget.scroll[KScroll.HSCROLL]; if (widget.rootPanel.style.width) { widget.content.style.width = widget.panel.style.width = widget.rootPanel.style.width; widget.viewportWidth = KSystem.normalizePixelValue(widget.panel.style.width); widget.barWidth = widget.viewportWidth - widget.buttonWidth * 2; widget.contentWidth = widget.parent.content.offsetWidth; // widget.parent.getWidth(); var newProportion = (widget.barWidth / widget.contentWidth); if (newProportion == widget.proportion) { return; } if (scrolledWidget.id.indexOf('widget240') != -1) { debug([ widget.viewportWidth, widget.contentWidth ]); } if ((widget.viewportWidth / widget.contentWidth) >= 1 || (widget.viewportWidth / widget.contentWidth) <= 0) { widget.panel.style.display = 'none'; widget.proportion = newProportion; widget.scrollBarTo(widget.buttonWidth, null, true); return; } else { if (widget.bar.style.left == '0px' && (widget.up.style.width || widget.up.style.width != '0px')) { widget.bar.style.left = widget.up.style.width; } widget.panel.style.display = 'block'; } widget.proportion = newProportion; widget.scrollWidth = Math.ceil((widget.viewportWidth) * widget.proportion) - 2; widget.offset = widget.scrollWidth / widget.scrollTreshold; widget.bar.style.width = widget.scrollWidth + 'px'; widget.maxX = widget.barWidth - widget.scrollWidth + widget.buttonWidth; var thisLeft = KSystem.normalizePixelValue(widget.bar.style.left); if (widget.effects.drag) { widget.effects.drag.rectangle = [ 0, widget.maxX, 0, widget.buttonWidth ]; widget.effects.drag.onAnimate = function(widget, tween) { widget.target.style.left = Math.round(-(tween.left - widget.buttonWidth) / widget.proportion) + 'px'; }; } else { KEffects.addEffect(widget.bar, [ { f : KEffects.linear, type : 'drag', lock : { y : true }, applyToElement : true, rectangle : [ 0, widget.maxX, 0, widget.buttonWidth ], onAnimate : function(widget, tween) { widget.target.style.left = Math.round(-(tween.left - widget.buttonWidth) / widget.proportion) + 'px'; } } ]); } if (thisLeft + 2 > widget.maxX) { widget.scrollBarTo(widget.maxX, null, true); } } } }; KScroll.prototype.handleMouseWheelScroll = function(scrollDelta) { if (scrollDelta < 0) { KScroll.down(null, this); } else { KScroll.up(null, this); } }; KScroll.prototype.toString = function(fromDump) { if (fromDump) { KSystem.ident = 0; return KSystem.widgetToString(this); } else { return this.className + '(' + this.id + ')'; } }; KScroll.prototype.setStyle = function(cssStyle, target) { var domElement = null; if (target) { if (typeof target == 'string') { eval('domElement = this.' + target + ';'); } else { domElement = target; } } else { domElement = this.panel; } for ( var property in cssStyle) { if (!cssStyle[property]) { continue; } switch (property) { case 'clear': { domElement.appendChild(KCSS.clearBoth()); break; } case 'cssFloat': { if (KBrowserDetect.browser == 2) { eval('domElement.style.styleFloat = \'' + cssStyle[property] + '\';'); } else { eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); } break; } default: { try { eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); } catch (err) { if (Kinky.DEV) { alert(property + "=" + cssStyle[property] + " " + err.toString()); } } break; } } } }; KScroll.prototype.activated = function() { return this.display; }; KScroll.prototype.activate = function() { }; KScroll.prototype.removeAllChildren = function() { }; KScroll.findOffset = function(widget) { if (widget.type == KScroll.VSCROLL) { return Math.round(widget.viewportHeight * widget.proportion); } else { return Math.round(widget.viewportWidth * widget.proportion); } }; KScroll.upKey = function(event) { if (KScroll.activeScroll && !KScroll.deactiveScrollKeys && KScroll.activeScroll.proportion <= 1 && KScroll.activeScroll.proportion > 0) { switch (event.keyCode) { case 34: case 40: { // DOWN if (KScroll.activeScroll.goingDown) { KSystem.removeTimer(KScroll.activeScroll.goingDown); delete (KScroll.activeScroll.goingDown); } break; } case 33: case 38: { // UP if (KScroll.activeScroll.goingUp) { KSystem.removeTimer(KScroll.activeScroll.goingUp); delete (KScroll.activeScroll.goingUp); } break; } } } }; KScroll.downKey = function(event) { if (KScroll.activeScroll && !KScroll.deactiveScrollKeys && KScroll.activeScroll.proportion <= 1 && KScroll.activeScroll.proportion > 0) { switch (event.keyCode) { case 35: { // dump(KScroll.activeScroll.contentHeight); KScroll.activeScroll.scrollTo(KScroll.activeScroll.contentHeight, null, true); break; } case 36: { KScroll.activeScroll.scrollTo(0, null, true); break; } case 34: case 40: { // DOWN if (!KScroll.activeScroll.goingDown) { KScroll.activeScroll.goingDown = KSystem.addTimer(function() { KScroll.activeScroll.handleMouseWheelScroll(-1); }, 20, true) } break; } case 33: case 38: { // UP if (!KScroll.activeScroll.goingUp) { KScroll.activeScroll.goingUp = KSystem.addTimer(function() { KScroll.activeScroll.handleMouseWheelScroll(1); }, 20, true); } break; } } } }; KScroll.disableKeys = function() { KScroll.deactiveScrollKeys = true; }; KScroll.enableKeys = function() { KScroll.deactiveScrollKeys = false; }; KScroll.mouseWheelActive = function(event, mEvent) { var mouseEvent = KSystem.getEvent(event); if (!KScroll.activeScroll || !KScroll.activeScroll.activateMouseWheel || KScroll.activeScroll.proportion > 1 || KScroll.activeScroll.proportion <= 0) { return; } if (mouseEvent.preventDefault) { mouseEvent.preventDefault(); } mouseEvent.returnValue = false; var delta = 0; if (mouseEvent.wheelDelta) { delta = mouseEvent.wheelDelta; } else if (mouseEvent.detail) { delta = -mouseEvent.detail; } if (delta) { KSystem.addTimer(function() { if (KScroll.activeScroll) { KScroll.activeScroll.handleMouseWheelScroll(delta); } }, 0); } }; KScroll.HSCROLL = 'HScroll'; KScroll.VSCROLL = 'VScroll'; KScroll.pageScrollDuration = 300; KScroll.listeners = {}; if (window.addEventListener) { window.addEventListener('DOMMouseScroll', KScroll.mouseWheelActive, false); } window.onmousewheel = document.onmousewheel = KScroll.mouseWheelActive; if (window.attachEvent) { window.attachEvent('onkeydown', KScroll.downKey); window.attachEvent('onkeyup', KScroll.upKey); } else { window.addEventListener('keydown', KScroll.downKey, false); window.addEventListener('keyup', KScroll.upKey, false); }; KSystem.addTimer(KScroll.dispatchScroll, 200); //KWidget.prototype = window.document.createElement('div'); //KWidget.prototype.constructor = KWidget; KWidget.prototype.isPaginated = false; KWidget.prototype.className = null; KWidget.prototype.parent = null; KWidget.prototype.editMode = false; KWidget.prototype.isDrawn = false; KWidget.prototype.query = ''; KWidget.prototype.data = null; KWidget.prototype.children = null; KWidget.prototype.nPage = 0; KWidget.prototype.perPage = 10; KWidget.prototype.totalCount = null; KWidget.prototype.kinky = null; KWidget.prototype.breadcrumb = null; KWidget.prototype.id = null; KWidget.prototype.hash = null; KWidget.prototype.panel = null; KWidget.prototype.topMarker = null; KWidget.prototype.background = null; KWidget.prototype.contentContainer = null; KWidget.prototype.content = null; KWidget.prototype.bottomMarker = null; KWidget.prototype.loader = null; KWidget.prototype.pagination = null; KWidget.prototype.window = false; KWidget.prototype.closeButton = null; KWidget.prototype.minimizeButton = null; KWidget.prototype.maximizeButton = null; KWidget.prototype.movable = false; KWidget.prototype.frame = false; KWidget.prototype.effects = null; KWidget.prototype.error = null; KWidget.prototype.request = null; KWidget.prototype.response = null; KWidget.prototype.overflow = 'hidden'; KWidget.prototype.simpleWidget = false; KWidget.prototype.hasClearOnTitle = false; KWidget.prototype.isAside = false; function KWidget(parent) { if (parent != null || parent == -1) { this.className = KSystem.getObjectClass(this); this.parent = parent; this.editMode = false; this.isDrawn = false; this.data = null; this.children = null; this.requestedPage = this.nPage = 0; this.nChildren = 0; this.loadedChildren = 0; this.perPage = 10; this.totalCount = null; this.display = false; this.parentPanel = null; this.kinky = Kinky.bunnyMan; this.breadcrumb = ''; this.id = this.id || this.kinky.addWidget(this); this.hash = null; this.panel = window.document.createElement(this.isAside ? 'aside' : this.tagNames[Kinky.HTML_READY][KWidget.ROOT_DIV]); this.panel.id = this.id; this.panel.className = ' KWidgetPanel ' + this.className + ' '; this.panel.style.overflow = this.overflow; this.panel.style.position = 'relative'; // this.panel.style.clear = 'both'; if (!this.simpleWidget) { this.topMarker = window.document.createElement('div'); this.topMarker.style.position = 'relative'; this.panel.appendChild(this.topMarker); this.background = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.BACKGROUND_DIV]); this.background.className = ' KWidgetPanelBackground ' + this.className + 'Background '; this.background.style.position = 'absolute'; this.background.style.top = '0px'; this.background.style.left = '0px'; this.panel.appendChild(this.background); this.contentContainer = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.CONTAINER_DIV]); this.contentContainer.className = ' KWidgetPanelContentContainer ' + this.className + 'ContentContainer '; this.contentContainer.style.clear = 'both'; this.contentContainer.style.position = 'relative'; this.panel.appendChild(this.contentContainer); this.widgetTitle = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.TITLE_DIV]); this.widgetTitle.className = ' KWidgetPanelTitle ' + this.className + 'Title '; this.widgetTitle.style.position = 'relative'; this.contentContainer.appendChild(this.widgetTitle); if (Kinky.TITLE_CLEAR_BOTH || this.hasClearOnTitle) { this.contentContainer.appendChild(KCSS.clearBoth(true)); } } this.content = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.CONTENT_DIV]); this.content.className = ' KWidgetPanelContent ' + this.className + 'Content '; if (!this.simpleWidget) { this.contentContainer.appendChild(this.content); } else { this.panel.appendChild(this.content); } if (this.isPaginated) { this.paginationBar = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.PAGINATION_DIV]); this.paginationBar.className = ' KWidgetPanelPaginationBar ' + this.className + 'PaginationBar '; this.prevButton = window.document.createElement('button'); this.prevButton.setAttribute("type","button"); this.prevButton.className = ' KWidgetPanelPaginationPrev '; this.prevButton.innerHTML = ' '; KSystem.addEventListener(this.prevButton, 'click', KWidget.dispatchPrevious); this.paginationBar.appendChild(this.prevButton); this.pagination = window.document.createElement('div'); this.pagination.className = ' KWidgetPanelPages ' + this.className + 'Pages '; this.pagination.innerHTML = ' '; this.paginationBar.appendChild(this.pagination); this.nextButton = window.document.createElement('button'); this.nextButton.setAttribute("type","button"); this.nextButton.className = ' KWidgetPanelPaginationNext '; this.nextButton.innerHTML = ' '; KSystem.addEventListener(this.nextButton, 'click', KWidget.dispatchNext); this.paginationBar.appendChild(this.nextButton); this.panel.appendChild(this.paginationBar); } if (!this.simpleWidget) { this.titleBottomMarker = window.document.createElement('div'); this.titleBottomMarker.style.position = 'absolute'; this.titleBottomMarker.style.bottom = '0'; this.titleBottomMarker.style.clear = 'both'; this.widgetTitle.appendChild(this.titleBottomMarker); this.bottomMarker = window.document.createElement('div'); this.bottomMarker.style.position = 'absolute'; this.bottomMarker.style.bottom = '0'; this.bottomMarker.style.clear = 'both'; this.content.appendChild(this.bottomMarker); } this.waitForLoad = false; this.window = false; this.closeButton = null; this.minimizeButton = null; this.maximizeButton = null; this.buttons = 0; this.movable = false; this.frame = false; this.effects = new Object(); this.waiting = false; this.error = null; this.request = null; this.response = null; this.needAuthentication = false; this.fromListener = false; this.lastWidth = 0; this.lastHeight = 0; this.scroll = {}; } } KWidget.prototype.onLoad = function(data) { this.data = data; } KWidget.prototype.onSave = function(data) { } KWidget.prototype.onRemove = function(data) { } KWidget.prototype.getNChildrenInContext = function() { var toReturn = 0; var context = this.getContext(); if (!this.children || !this.children[context]) { return 0; } for (var child in this.children[context]) { toReturn++; } return toReturn; } KWidget.prototype.onShow = function(justContent) { if (this.waitForLoad && this.getNChildrenInContext() > this.loadedChildren) { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').onShow(' + (justContent ? 'true' : '') + ')', 800); return false; } this.loadedChildren = this.getNChildrenInContext(); if (this.parent) { this.parent.loadedChildren++; } this.setStyle({ display : 'block' }, justContent ? KWidget.CONTENT_DIV : KWidget.ROOT_DIV); if (this.effects[KWidget.ENTER] != null) { KEffects.addEffect(this.effects[KWidget.ENTER].target || this, KSystem.clone(this.effects[KWidget.ENTER], /target/)); } this.display = true; if (this.toActivate) { this.focus(); delete this.toActivate; } return this.display; } KWidget.prototype.onHide = function(justContent) { if (this.effects[KWidget.EXIT] != null) { var tween = KSystem.clone(this.effects[KWidget.EXIT], /target/); tween.onComplete = function(widget) { widget.setStyle({ display : 'none' }, justContent ? KWidget.CONTENT_DIV : KWidget.ROOT_DIV); } KEffects.addEffect(this.effects[KWidget.EXIT].target || this, tween); } else { this.setStyle({ display : 'none' }, justContent ? KWidget.CONTENT_DIV : KWidget.ROOT_DIV); } this.display = false; this.lastHeight = 0; this.lastWidth = 0; return this.display; } KWidget.prototype.insertBefore = function(element, context, before, childDiv) { if (!element) { return; } if (context == null) { if (this.isPaginated && Math.floor(this.nChildren / this.perPage) != this.nPage) { context = this.query + Math.floor(this.nChildren / this.perPage); this.totalCount = this.nChildren + 1; element.onHide(); } else { context = this.query + this.nPage; } } var elementKey = element.hash != null ? element.hash : element.id; if (this.children == null) { this.children = new Object(); } if (this.children[context] == null) { this.children[context] = new Object(); } if (before instanceof KWidget) { before = before.panel; } this.children[context][elementKey] = element; if (childDiv){ this.childDiv(childDiv).insertBefore(element.panel, before); } else { this.content.insertBefore(element.panel, before); } this.nChildren++; return elementKey; } KWidget.prototype.insertAfter = function(element, context, after, childDiv) { if (!element) { return; } if (context == null) { if (this.isPaginated && Math.floor(this.nChildren / this.perPage) != this.nPage) { context = this.query + Math.floor(this.nChildren / this.perPage); this.totalCount = this.nChildren + 1; element.onHide(); } else { context = this.query + this.nPage; } } var elementKey = element.hash != null ? element.hash : element.id; if (this.children == null) { this.children = new Object(); } if (this.children[context] == null) { this.children[context] = new Object(); } if (after instanceof KWidget) { after = after.after; } this.children[context][elementKey] = element; if (childDiv){ this.childDiv(childDiv).insertBefore(element.panel, after.nextSibling); } else { this.content.insertBefore(element.panel, after.nextSibling); } this.nChildren++; return elementKey; } KWidget.prototype.appendChild = function(element, context, childDiv) { if (!element) { return; } if (context == null) { if (this.isPaginated && Math.floor(this.nChildren / this.perPage) != this.nPage) { context = this.query + Math.floor(this.nChildren / this.perPage); this.totalCount = this.totalCount < this.nChildren ? this.nChildren + 1 : this.totalCount; element.onHide(); } else { context = this.query + this.nPage; } } var elementKey = element.key = element.hash != null ? element.hash : element.id; if (this.children == null) { this.children = new Object(); } if (this.children[context] == null) { this.children[context] = new Object(); } this.children[context][elementKey] = element; if (element instanceof KIndex && !childDiv) { this.widgetTitle.appendChild(element.panel); } else if (childDiv){ this.childDiv(childDiv).appendChild(element.panel); } else { this.content.appendChild(element.panel); } this.nChildren++; return element; } KWidget.prototype.appendBackgroundChild = function(element, context) { KWidget.prototype.appendChild.call(this, element, context, KWidget.BACKGROUND_DIV); } KWidget.prototype.appendTitleChild = function(element, context) { KWidget.prototype.appendChild.call(this, element, context, KWidget.TITLE_DIV); } KWidget.prototype.appendContainerChild = function(element, context) { KWidget.prototype.appendChild.call(this, element, context, KWidget.CONTAINER_DIV); } KWidget.prototype.addBorder = function(params) { if (!this.activated()) { this.borderParams = params; return; } if (params.element) { params.element.id = params.element.id || (KSystem.getWidget(params.element).id); KCSS.addFrame(params.element, params); } else if (params.className) { var elements = this.childDiv(KWidget.CONTENT_DIV).childNodes; for (var i = 0; i != elements.length; i++) { if (params.className.test(elements[i].className)) { KCSS.addFrame(elements[i], params); } } } else if (params.tagName) { var elements = this.childDiv(KWidget.CONTENT_DIV).getElementsByTagName(params.tagName); for (var i = 0; i != elements.length; i++) { KCSS.addFrame(elements[i], params); } } else { this.originalPanel = this.panel; this.originalPanel.style.display = 'block'; this.panel = KCSS.addFrame(this.childDiv(KWidget.ROOT_DIV), params); } } KWidget.prototype.addScroll = function(type, params, target, targetPanel, rootPanel) { if (this.scroll[type]) { // dump('scroll of type ' + type + ' already added.'); return this.scroll[type]; } target = target ? this.childDiv(target) : this.content; targetPanel = targetPanel ? this.childDiv(targetPanel) : this.contentContainer; rootPanel = rootPanel ? this.childDiv(rootPanel) : this.panel; var scroll = new KScroll(this, type, params); scroll.target = target; scroll.targetPanel = targetPanel || scroll.target.parentNode; scroll.rootPanel = rootPanel || scroll.targetPanel.parentNode; scroll.targetPanel.appendChild(scroll.panel); scroll.go(); this.scroll[type] = scroll; return scroll; } KWidget.prototype.getScroll = function(type) { if (!type) { return this.scroll[KScroll.VSCROLL] || this.scroll[KScroll.HSCROLL]; } return this.scroll[type]; } KWidget.prototype.getScrollOffset = function() { var toReturn = new Object(); if (this.scroll[KScroll.VSCROLL]) { toReturn.y = Math.abs(KSystem.normalizePixelValue(this.content.style.top)); } if (this.scroll[KScroll.HSCROLL]) { toReturn.x = Math.abs(KSystem.normalizePixelValue(this.content.style.left)); } return toReturn; } KWidget.prototype.childDiv = function(target) { var domElement = null if (target) { if (typeof target == 'string') { eval('domElement = this.' + target + ';'); } else { domElement = target; } } else { domElement = this.panel; } return domElement; } KWidget.prototype.childWidget = function(id, context) { if (context == null) { context = this.query + this.nPage; } if (this.children && this.children[context] && this.children[context][id]) { return this.children[context][id]; } return null; } KWidget.prototype.childAt = function(index) { try { var current = 0; for (var child in this.childWidgets()) { if (current == index) { return this.childWidget(child); } current++; } } catch (e) { } return null; } KWidget.prototype.indexOf = function(widget, context) { try { if (context == null) { context = this.query + this.nPage; } var current = 0; for (var child in this.childWidgets()) { if (this.childWidget(child).id == widget.id) { return current; } current++; } } catch (e) { } return -1; } KWidget.prototype.childWidgets = function(context) { if (context == null) { context = this.query + this.nPage; } if (this.children) { return this.children[context]; } return null; } KWidget.prototype.focus = function() { if (this.display) { this.childDiv(this.FOCUS_DIV).focus(); } else { this.toActivate = true; } } KWidget.prototype.blur = function() { if (this.display) { this.childDiv(this.FOCUS_DIV).blur(); } } KWidget.prototype.hideContext = function(context, element) { for(var child in this.childWidgets(context)) { this.childWidget(child, context).setStyle({ display: 'none' }, element); this.childWidget(child, context).display = false; } KWidget.prototype.onHide.call(this, true); this.loadedChildren = 0; } KWidget.prototype.showContext = function(context, element) { if (context == null) { context = this.query + this.nPage; } for(var child in this.childWidgets(context)) { // dump([context, this.childWidget(child, context)]); if (!this.childWidget(child, context).display) { if (this.childWidget(child, context).activated()) { this.childWidget(child, context).onShow(); this.loadedChildren++; } else { this.childWidget(child, context).go(); } } else { this.loadedChildren++; } } KWidget.prototype.onShow.call(this, true); } KWidget.prototype.getContext = function() { return (this.query || '') + this.nPage; } KWidget.prototype.changeContext = function(query, page) { this.query = query; this.nPage = page || ''; } KWidget.prototype.resetContext = function() { this.query = ''; this.nPage = 0; } KWidget.prototype.afterNext = function() { throw new KNoExtensionException(this, 'afterNext'); } KWidget.prototype.beforePrevious = function() { throw new KNoExtensionException(this, 'beforePrevious'); } KWidget.dispatchNext = function(event, widget) { if (widget == null) { widget = KSystem.getEventWidget(event); } var dispatchPage = widget.nPage + 1; if ((widget.totalCount && widget.totalCount <= widget.perPage * (widget.nPage + 1)) || (widget.getNChildrenInContext() < widget.perPage)) { try { widget.isAfterNext = true; widget.afterNext(widget.nPage); return; } catch(e) { return; } } KBreadcrumb.dispatchEvent(widget.id, { action : '/page/' + dispatchPage }); } KWidget.dispatchPrevious = function(event, widget) { if (widget == null) { widget = KSystem.getEventWidget(event); } var dispatchPage = widget.nPage - 1; if (widget.nPage == 0) { try { widget.isBeforePrevious = true; widget.beforePrevious(widget.nPage); return; } catch(e) { return; } } KBreadcrumb.dispatchEvent(widget.id, { action : '/page/' + dispatchPage }); } KWidget.prototype.gotoPage = function(action) { var nPage = parseInt(action.split('/')[2]); if (this.totalCount && this.totalCount != 0 && Math.floor(this.totalCount / this.perPage) < nPage) { return; } if ((this.nPage < nPage && !this.isBeforePrevious) || this.isAfterNext) { if (this.childWidgets(this.query + nPage) != null) { this.hideContext(); this.nPage = nPage; this.isAfterNext = false; this.onNextPage(); return; } else { this.pageCallback = this.onNextPage; } } else { if (this.childWidgets(this.query + nPage) != null) { this.hideContext(); this.nPage = nPage; this.isBeforePrevious = false; this.onPreviousPage(); return; } else { this.pageCallback = this.onPreviousPage; } } this.hideContext(); this.nPage = this.requestedPage = nPage; // this.showContext(); this.load(); } KWidget.prototype.onNextPage = function() { throw new KNoExtensionException(this, 'onNextPage'); } KWidget.prototype.onPreviousPage = function() { throw new KNoExtensionException(this, 'onPreviousPage'); } KWidget.prototype.removeChild = function(element, context, notDeleteIt) { if (context == null) { context = this.query + this.nPage; } var elementKey = element.hash != null ? element.hash : element.id; if (this.children[context] && this.children[context][elementKey]) { if (element.panel.parentNode) { element.panel.parentNode.removeChild(element.panel); } if (!notDeleteIt) { if (element instanceof KWidget) { element.removeAllChildren(); } this.kinky.removeWidget(this.children[context][elementKey].id); delete this.children[context][elementKey]; this.nChildren--; } } } KWidget.prototype.removeAllChildren = function(context) { if (context == null) { for (var context in this.children) { this.removeAllChildren(context); } } else { for (var elementKey in this.childWidgets(context)) { var id = this.childWidget(elementKey, context).id; this.removeChild(this.childWidget(elementKey, context), context, false); this.kinky.removeWidget(id); } if (this.children && this.children[context]) { delete this.children[context]; } if (this.scroll[KScroll.VSCROLL]) { this.scroll[KScroll.VSCROLL].removeScrollListeners(); } if (this.scroll[KScroll.HSCROLL]) { this.scroll[KScroll.HSCROLL].removeScrollListeners(); } } // this.nChildren = 0; this.loadedChildren = 0; } KWidget.prototype.setEnabled = function(domObject, isEnabled) { if (!domObject) {return;} for (var index = 0; index != domObject.childNodes.length; index++){ if (domObject.childNodes[index].disabled != undefined) { domObject.childNodes[index].disabled = (isEnabled ? false : true); } } } KWidget.prototype.drawWindow = function(params) { if (this.window) { this.panel.style.position = 'absolute'; if (this.frame && this.movable) { this.widgetTitle.style.cursor = 'move'; KEffects.addEffect(this.widgetTitle, { f : KEffects.linear, type : "drag" }); } if (params) { if ((this.buttons & KWidget.CLOSE) == KWidget.CLOSE) { this.closeButton = window.document.createElement('button'); this.closeButton.className = this.className + 'TitleClose'; this.closeButton.setAttribute('type', 'button'); this.closeButton.appendChild(window.document.createTextNode('x')); this.widgetTitle.appendChild(this.closeButton); KSystem.addEventListener(this.closeButton, 'click', params.closeCallback); } if ((this.buttons & KWidget.MINIMIZE) == KWidget.MINIMIZE) { this.minimizeButton = window.document.createElement('button'); this.minimizeButton.className = this.className + 'TitleMinimize'; this.minimizeButton.setAttribute('type', 'button'); this.minimizeButton.appendChild(window.document.createTextNode('_')); this.widgetTitle.appendChild(this.minimizeButton); KSystem.addEventListener(this.minimizeButton, 'click', params.minimizeCallback); } if ((this.buttons & KWidget.MAXIMIZE) == KWidget.MAXIMIZE) { this.maximizeButton = window.document.createElement('button'); this.maximizeButton.className = this.className + 'TitleMaximize'; this.maximizeButton.setAttribute('type', 'button'); this.maximizeButton.appendChild(window.document.createTextNode('\u2207')); this.widgetTitle.appendChild(this.maximizeButton); KSystem.addEventListener(this.maximizeButton, 'click', params.maximizeCallback); } } } } KWidget.prototype.disable = function() { var div = window.document.createElement('div'); div.className = this.className + "Overlay KWidgetDisableOverlay"; var width = this.getWidth(); KCSS.setStyle({ position : 'absolute', top : '0', left : '0', width : (isNaN(width) ? KSystem.getBrowserWidth() : width) + 'px', height : this.getHeight() + 'px' }, [div]); this.panel.appendChild(div); }; KWidget.prototype.enable = function() { var div = this.panel.childNodes[this.panel.childNodes.length - 1]; if (div.className == this.className + "Overlay KWidgetDisableOverlay") { this.panel.removeChild(div); } }; KWidget.prototype.getHeight = function(childDiv) { if (childDiv) { var target = null; target = this.childDiv(childDiv); var computedStyle = null; if (typeof this.panel.currentStyle != 'undefined') { computedStyle = target.currentStyle; } else { computedStyle = document.defaultView.getComputedStyle(target, null); } return KSystem.normalizePixelValue(computedStyle.height); } else { var begin = this.topMarker.offsetTop; var end = this.bottomMarker.offsetTop; var endTitle = this.titleBottomMarker.offsetTop; var dynamicHeight = (end) - begin; return dynamicHeight || 0; } } KWidget.prototype.getWidth = function(childDiv) { var target = null; if (childDiv){ target = this.childDiv(childDiv); } else { target = this.panel; } var computedStyle = null; if (typeof this.panel.currentStyle != 'undefined') { computedStyle = this.panel.currentStyle; } else if (window.document.defaultView) { computedStyle = window.document.defaultView.getComputedStyle(this.panel, null); } if (computedStyle.width) { return KSystem.normalizePixelValue(computedStyle.width); } } KWidget.prototype.getCSSProperty = function(childDiv, prop) { var target = null; if (childDiv){ target = this.childDiv(childDiv); } else { target = this.panel; } var computedStyle = null; if (typeof this.panel.currentStyle != 'undefined') { computedStyle = target.currentStyle; } else { computedStyle = window.document.defaultView.getComputedStyle(target, null); } return computedStyle[prop]; } KWidget.prototype.getTitleHeight = function() { return this.titleBottomMarker.offsetTop; } KWidget.prototype.offsetTop = function() { var parent = this.panel; var toReturn = 0; while (parent != null) { toReturn += parent.offsetTop; parent = parent.offsetParent; } return toReturn; } KWidget.prototype.offsetLeft = function() { var parent = this.panel; var parentWidget = this; var toReturn = 0; while (parent != null) { toReturn += parent.offsetLeft; if (KBrowserDetect.browser == 2 && KBrowserDetect.version == 7) { // parent = parentWidget.panel; // parentWidget = parentWidget.parent; parent = parent.offsetParent; } else { parent = parent.offsetParent; } } return toReturn; } KWidget.prototype.offsetRight = function() { var parent = this.panel; var parentWidget = this; var toReturn = 0; while (parent != null) { toReturn += parent.offsetRight; if (KBrowserDetect.browser == 2 && KBrowserDetect.version == 7) { parent = parentWidget.panel; parentWidget = parentWidget.parent; } else { parent = parent.offsetParent; } } return toReturn; } KWidget.prototype.setTitle = function(title, isHTML) { if (this.widgetTitle.getElementsByTagName('h2').length == 0) { var h2 = window.document.createElement('h2'); if (isHTML) { if (typeof title == 'string') { h2.innerHTML = title; } else { h2.appendChild(title); } } else { h2.appendChild(window.document.createTextNode(title)); } this.widgetTitle.appendChild(h2); this.widgetTitle.appendChild(window.document.createElement('hr')); } else { var h2 = this.widgetTitle.getElementsByTagName('h2')[0]; h2.innerHTML = ''; if (isHTML) { if (typeof title == 'string') { h2.innerHTML = title; } else { h2.appendChild(title); } } else { h2.appendChild(window.document.createTextNode(title)); } } } KWidget.prototype.appendTitleText = function(title, isHTML) { if (this.widgetTitle.getElementsByTagName('h2').length == 0) { var h2 = window.document.createElement('h2'); if (isHTML) { if (typeof title == 'string') { h2.innerHTML = title; } else { h2.appendChild(title); } } else { h2.appendChild(window.document.createTextNode(title)); } this.widgetTitle.appendChild(h2); this.widgetTitle.appendChild(window.document.createElement('hr')); } else { var h2 = this.widgetTitle.getElementsByTagName('h2')[0]; if (isHTML) { if (typeof title == 'string') { h2.innerHTML += title; } else { h2.appendChild(title); } } else { h2.appendChild(window.document.createTextNode(title)); } } } KWidget.prototype.addCSSClass = function(cssClass, target) { var domElement = null; if (target) { if (typeof target == 'string') { eval('domElement = this.' + target + ';'); } else { domElement = target; } } else { domElement = this.panel; } domElement.className += ' ' + cssClass + ' '; } KWidget.prototype.removeCSSClass = function(cssClass, target) { var domElement = null if (target) { if (typeof target == 'string') { eval('domElement = this.' + target + ';'); } else { domElement = target; } } else { domElement = this.panel; } eval('domElement.className = domElement.className.replace(/ ' + cssClass + ' /g, \'\');'); } KWidget.prototype.setStyle = function(cssStyle, target) { var domElements = null; if (target) { if (target instanceof Array) { domElements = new Array(); for (var index in target) { if (typeof target[index] == 'string') { eval('domElements.push( this.' + target[index] + ');'); } else { domElements.push(target); } } } else if (typeof target == 'string') { eval('domElements = [ this.' + target + ' ];'); } else { domElements = [ target ]; } } else { domElements = [ this.panel ]; } KCSS.setStyle(cssStyle, domElements); } KWidget.prototype.clearBoth = function(target) { if (target) { if (typeof target == 'string') { eval('target = this.' + target + ';'); } } else { target = this.content; } target.appendChild(KCSS.clearBoth()); } KWidget.prototype.addWindowResizeListener = function(callback) { this.kinky.addWindowResizeListener(this, callback); } KWidget.prototype.addResizeListener = function(callback) { this.kinky.addResizeListener(this, callback); } KWidget.prototype.addLocationListener = function(callback) { KBreadcrumb.addLocationListener(this, callback); } KWidget.prototype.addQueryListener = function(callback, queries) { KBreadcrumb.addQueryListener(this, callback, queries); } KWidget.prototype.addActionListener = function(callback, actions) { KBreadcrumb.addActionListener(this, callback, actions); } KWidget.prototype.addEventListener = function(eventName, callback, target) { var domElement = null if (target) { eval('domElement = this.' + target + ';'); } else { domElement = this.panel; } KSystem.addEventListener(domElement, eventName, callback); } KWidget.prototype.removeEventListener = function(eventName, callback, target) { var domElement = null if (target) { eval('domElement = this.' + target + ';'); } else { domElement = this.panel; } KSystem.removeEventListener(domElement, eventName, callback); } KWidget.prototype.getLink = function(params) { return KBreadcrumb.getLink(params); } KWidget.prototype.load = function() { if (this.childWidgets() != null) { this.draw(); } else { throw new KNoExtensionException(this, 'load'); } } KWidget.prototype.resume = function(noDisplay) { if (this.waiting) { KWidget.usingLoader--; if (KWidget.usingLoader <= 0 && KWidget.loader) { KWidget.loader.setStyle({ display : 'none' }); } this.waiting = false; } if (!this.display && !noDisplay) { this.onShow(); } } KWidget.prototype.wait = function() { if (KWidget.loader) { KWidget.loader.setStyle({ display : 'block' }); } KWidget.usingLoader++; this.waiting = true; } KWidget.prototype.deactivate = function() { this.isDrawn = false; } KWidget.prototype.activate = function() { if (!this.activated()) { this.isDrawn = true; KBreadcrumb.dispatchEvent(this.id); if (this.borderParams) { this.addBorder(this.borderParams); } } this.isDrawn = true; this.resume(); } KWidget.prototype.activated = function() { return this.isDrawn; } KWidget.prototype.clear = function() { this.content.innerHTML = ''; if (!this.simpleWidget) { this.content.appendChild(this.bottomMarker); this.widgetTitle.innerHTML = ''; this.widgetTitle.appendChild(this.titleBottomMarker); } } KWidget.prototype.draw = function() { throw new KNoExtensionException(this, 'draw'); } KWidget.prototype.redraw = function(context) { if (context == null) { context = this.query + this.nPage; } this.clear(); for (var element in this.childWidgets(context)) { this.content.appendChild(this.childWidget(element, context).panel); } this.draw(); } KWidget.prototype.refresh = function() { this.removeAllChildren(); this.resetContext(); this.onHide(); this.clear(); this.load(); } KWidget.prototype.getParent = function(parentClass) { if (parentClass) { if (this.parent == null) { return null; } else if (this.parent.className) { var isParent = false; eval('isParent = this.parent instanceof ' + parentClass + ';'); if (isParent) { return this.parent; } else { return this.parent.getParent(parentClass); } } else { return null; } } else { return this.parent; } } KWidget.prototype.getURL = function() { return KBreadcrumb.getURL(); } KWidget.prototype.getHash = function() { return KBreadcrumb.getHash(); } KWidget.prototype.getQuery = function() { return KBreadcrumb.getQuery(); } KWidget.prototype.getAction = function() { return KBreadcrumb.getAction(); } KWidget.prototype.go = function() { throw new KNoExtensionException(this, 'go'); } KWidget.prototype.toString = function(fromDump) { if (fromDump) { KSystem.ident = 0; return KSystem.widgetToString(this); } else { return this.className + '(' + this.id + ')'; } } KWidget.usingLoader = 0; KWidget.loader = null; KWidget.EXIT_NEXT = 'exitNext'; KWidget.EXIT_PREVIOUS = 'exitPrevious'; KWidget.ENTER = 'enter'; KWidget.EXIT = 'exit'; KWidget.ROOT_DIV = 'panel'; KWidget.CONTAINER_DIV = 'contentContainer'; KWidget.CONTENT_DIV = 'content'; KWidget.BACKGROUND_DIV = 'background'; KWidget.TITLE_DIV = 'widgetTitle'; KWidget.PAGINATION_DIV = 'paginationBar'; KWidget.PAGINATION_NEXT_BUTTON = 'nextButton'; KWidget.PAGINATION_PREV_BUTTON = 'prevButton'; KWidget.CLOSE_BUTTON = 'closeButton'; KWidget.MINIMIZE_BUTTON = 'minimizeButton'; KWidget.MAXIMIZE_BUTTON = 'maximizeButton'; KWidget.prototype.FOCUS_DIV = 'content'; KWidget.CLOSE = 1; KWidget.MINIMIZE = 2; KWidget.MAXIMIZE = 4; KWidget.NEXT = 8; KWidget.PREVIOUS = 16; KWidget.prototype.tagNames = { html4 : { panel : 'div', contentContainer : 'div', content : 'div', background : 'div', widgetTitle : 'div', paginationBar : 'div' }, html5 : { panel : 'section', contentContainer : 'article', content : 'div', background : 'div', widgetTitle : 'header', paginationBar : 'nav' } } KWidgetNotFoundException.prototype = new KException(); KWidgetNotFoundException.prototype.constructor = KWidgetNotFoundException; function KWidgetNotFoundException(invoker, message) { KException.call(invoker, message); } KButton.prototype = new KWidget(); KButton.prototype.constructor = KButton; KButton.prototype.simpleWidget = true; function KButton(parent, label, id, callback, type) { if (parent != null) { KWidget.call(this, parent); this.data = { buttonID : id, buttonLabel : label, buttonCallback : callback, buttonType : type } this.input = window.document.createElement('button'); this.input.className = ' KButtonInput '; this.input.setAttribute('type', this.data.buttonType || 'button'); this.input.id = this.data.buttonID; var labelDiv = window.document.createElement('div'); labelDiv.className = ' KButtonInputLabel '; labelDiv.appendChild(window.document.createTextNode(this.data.buttonLabel)); this.input.appendChild(labelDiv); this.FOCUS_DIV = 'input'; } } KButton.prototype.go = function() { if (!this.activated()) { this.draw(); } else { this.redraw(); } } KButton.prototype.setCallback = function(callback) { if (this.activated()) { KSystem.removeEventListener(this.input, 'click', this.data.buttonCallback); KSystem.addEventListener(this.input, 'click', callback); } this.data.buttonCallback = callback; } KButton.prototype.setText = function(text) { this.data.buttonLabel = text; var labelDiv = this.input.childNodes[0]; labelDiv.innerHTML = ''; labelDiv.appendChild(window.document.createTextNode(text)); } KButton.prototype.setHelpText = function(text) { this.data.helpText = text; } KButton.prototype.draw = function() { if (this.data.buttonCallback) { if (this.data.buttonCallback instanceof Array) { for (var index in this.data.buttonCallback) { KSystem.addEventListener(this.input, 'click', this.data.buttonCallback[index]); } } else { KSystem.addEventListener(this.input, 'click', this.data.buttonCallback); } } if (this.data.helpText) { KSystem.addEventListener(this.input, 'mouseover', KButton.onMouseOver); KSystem.addEventListener(this.input, 'click', KButton.removeTootip); } this.content.appendChild(this.input); this.activate(); } KButton.removeTootip = function(event) { var widget = KSystem.getEventWidget(event); KTooltip.removeTooltip(widget); } KButton.onMouseOver = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(mouseEvent); KTooltip.showTooltip(widget.input, { text : widget.data.helpText, isHTML : true, offsetX : 0, offsetY : 15, left : KSystem.mouseX(mouseEvent), top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'KButtonTooltip' }); } KButton.BUTTON_ELEMENT = 'input'; KComment.prototype = new KWidget; KComment.prototype.constructor = KComment; function KComment(parent, params) { if (parent != null) { KWidget.call(this, parent); this.data = params || {}; this.exceptions = /urlHashText|actions|user|type|info|reply|cssClass|feClass|feService/; this.fieldInfoExceptions = null; this.infoFields = {}; this.hasAttach = false; this.removeCallback = null; this.dateFormat = 'd de MMM Y, H:i:s'; this.maxAttachs = 1; this.labels = { go : 'go', cancel : 'cancel', remove : 'delete' }; this.infoArea = window.document.createElement('div'); this.infoArea.className = 'KCommentInfoArea'; this.content.appendChild(this.infoArea); this.commentArea = window.document.createElement('div'); this.commentArea.className = 'KCommentArea'; this.content.appendChild(this.commentArea); } } KComment.prototype.go = function() { if (this.data.type != null) { this.draw(); } else { this.load(); } } KComment.prototype.clear = function() { KWidget.prototype.clear.call(this); this.infoArea = window.document.createElement('div'); this.infoArea.className = 'KCommentInfoArea'; this.content.appendChild(this.infoArea); this.commentArea = window.document.createElement('div'); this.commentArea.className = 'KCommentArea'; this.content.appendChild(this.commentArea); } KComment.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } KComment.prototype.onLoad = function(data) { for ( var element in data) { for ( var att in data[element]) { this.data[att] = data[element][att]; } } if (!this.activated()) { this.draw(); } } KComment.prototype.removeComment = function(node) { var parent = node.parentNode; var nodeHTML = '
' + parent.innerHTML.replace('clear: both; "', 'clear: both; "') + '
'; parent.parentNode.removeChild(parent); this.removeCallback(this, nodeHTML); } KComment.prototype.addComment = function(params) { var commentDiv = window.document.createElement('div'); commentDiv.className = ' KCommentEntry '; var header = window.document.createElement('h3'); header.appendChild(window.document.createTextNode(params.name || (Kinky.getLoggedUser() ? Kinky.getLoggedUser().name : 'anonymous'))) commentDiv.appendChild(header); var now = new Date(); var date = window.document.createElement('div'); date.id = 'date' + now.getTime(); date.className = ' KCommentEntryDate '; date.appendChild(window.document.createTextNode(KSystem.formatDate(this.dateFormat, now))); commentDiv.appendChild(date); var img = window.document.createElement('img'); img.className = ' KCommentEntryPhoto '; img.src = (Kinky.getLoggedUser() ? Kinky.getLoggedUser().photo : ''); img.alt = img.title = Kinky.getLoggedUser().name; commentDiv.appendChild(img); var input = window.document.createElement('textarea'); input.id = 'id' + now.getTime() + Kinky.getLoggedUser().id; input.className = ' KCommentEntryInput '; commentDiv.appendChild(input); if (this.hasAttach) { if (Kinky.HTML_READY == 'html5') { this.file = new KFileDropPanel(this); { this.file.hash = '/file-panel'; this.file.setTitle('Anexo(s)
← drag from desktop
', true); } } else { this.file = new KFile(this, 'Anexo(s)', 'attach'); this.file.maxFile = this.maxAttachs; } this.appendChild(this.file, null, commentDiv); this.file.go(); } var button = window.document.createElement('button'); button.setAttribute('type', 'button'); button.innerHTML = this.labels.go; button.className = ' KCommentEntryButton '; KSystem.addEventListener(button, 'click', function(event) { var widget = KSystem.getEventWidget(event); var html = KComment.addHTML(event); if (!html) { return; } if (params && params.commentCallback) { params.commentCallback(widget, html); } }); commentDiv.appendChild(button); var cancel = window.document.createElement('button'); cancel.setAttribute('type', 'button'); cancel.innerHTML = this.labels.cancel; cancel.className = ' KCommentEntryButtonCancel '; KSystem.addEventListener(cancel, 'click', function(event) { var widget = KSystem.getEventWidget(event); if (widget.hasAttach) { widget.removeChild(widget.file); } commentDiv.parentNode.removeChild(commentDiv); if (params && params.cancelCallback) { params.cancelCallback(widget); } }); commentDiv.appendChild(cancel); this.setStyle( { clear : 'both' }, commentDiv); this.commentArea.appendChild(commentDiv); } KComment.addHTML = function(event) { var widget = KSystem.getEventWidget(event); var target = KSystem.getEventTarget(event); var parent = target.parentNode; var textarea = parent.getElementsByTagName('textarea')[0]; var text = textarea.value; if (text == '') { return false; } var div = window.document.createElement('div'); div.className = textarea.className; div.innerHTML = text.replace(/\n/g, '
'); parent.replaceChild(div, textarea); if (widget.hasAttach) { if (Kinky.HTML_READY != 'html5') { var files = widget.file.getValue(); var names = widget.file.getFileName(); if (files.length != 0) { var fileDiv = window.document.createElement('div'); fileDiv.className = ' ' + widget.file.className + ' ' + widget.file.className + 'Readonly '; var label = window.document.createElement('label'); label.appendChild(window.document.createTextNode('Anexo(s): ')); fileDiv.appendChild(label); fileDiv.appendChild(KCSS.br()); var ul = window.document.createElement('ul'); for ( var file in files) { var li = window.document.createElement('li'); var a = window.document.createElement('a'); a.href = files[file].replace(Kinky.BASE_TEMP_DIR, Kinky.BASE_TEMP_URL); a.innerHTML = '· ' + names[file]; a.target = '_blank'; li.appendChild(a); ul.appendChild(li); } fileDiv.appendChild(ul); parent.replaceChild(fileDiv, widget.file.panel); } else { parent.removeChild(widget.file.panel); } } else { var droppedFiles = widget.file.getDropped(); var files = []; for ( var file in droppedFiles) { var li = window.document.createElement('li'); var a = window.document.createElement('a'); a.href = droppedFiles[file].uploadURL; a.innerHTML = '· ' + droppedFiles[file].name; a.target = '_blank'; li.appendChild(a); files.push(li); } if (files.length != 0) { var fileDiv = window.document.createElement('div'); fileDiv.className = ' ' + widget.file.className + ' ' + widget.file.className + 'Readonly '; var label = window.document.createElement('label'); label.appendChild(window.document.createTextNode('Anexo(s): ')); fileDiv.appendChild(label); fileDiv.appendChild(KCSS.br()); var ul = window.document.createElement('ul'); for(var file in files) { ul.appendChild(files[file]); } fileDiv.appendChild(ul); parent.replaceChild(fileDiv, widget.file.panel); } else { parent.removeChild(widget.file.panel); } } widget.removeChild(widget.file); } var buttons = parent.getElementsByTagName('button'); for (; buttons.length != 0;) { parent.removeChild(buttons[0]); } if (widget.removeCallback) { parent.innerHTML += ''; } return '
' + parent.innerHTML + '
'; } KComment.prototype.draw = function() { if (this.data.info) { var info = window.document.createElement('div'); { info.className = 'KCommentInfo ' + (this.data.info.cssClass || '') + ' '; var title = window.document.createElement('h2'); { if (this.data.info.title != null) { title.appendChild(window.document.createTextNode(this.data.info.title)); } else if (this.data.info.titleHTML != null) { title.innerHTML = this.data.info.titleHTML; } if (this.data.info.tooltip) { KSystem.addEventListener(title, 'mouseover', KComment.onTitleMouseOver); } } info.appendChild(title); var description = window.document.createElement('p'); { if (this.data.info.description != null) { description.appendChild(window.document.createTextNode(this.data.info.description)); } else if (this.data.info.descriptionHTML != null) { description.innerHTML = HTML.stripTags(this.data.info.descriptionHTML, 'p'); } } info.appendChild(description); } this.infoArea.appendChild(info); } if (this.data.user) { if (this.data.user.photo) { for ( var photo in this.data.user.photo) { var image = window.document.createElement('img'); image.src = this.data.user.photo[photo]; image.alt = image.title = this.data.user.name || image.src.substr(image.src.lastIndexOf('/') + 1); this.infoArea.appendChild(image); } } } for ( var att in this.data) { if (this.exceptions.test(att) || (this.fieldInfoExceptions && this.fieldInfoExceptions.test(att))) { continue; } var infoField = this.getField(this.data, att); this.infoArea.appendChild(infoField); } this.infoArea.appendChild(KCSS.clearBoth()); if (this.data.actions) { this.actions = window.document.createElement('div'); { this.actions.className = 'KCommentActions'; this.infoArea.appendChild(this.actions); for ( var att in this.data.actions) { var action = window.document.createElement('a'); { action.href = this.getLink( { hash : this.data.actions[att].hash || (this.getParent('KPage') ? this.getParent('KPage').hash : null), action : this.data.actions[att].url }); action.className = 'KCommentInfoAction ' + (this.data.actions[att].cssClass || '') + ' '; if (this.data.actions[att].isHTML) { action.innerHTML = this.data.actions[att].label; } else { action.appendChild(window.document.createTextNode(this.data.actions[att].label)); } if (this.data.actions[att].tooltip) { action.alt = this.data.actions[att].tooltip; KSystem.addEventListener(action, 'mouseover', KComment.onMouseOver); } } this.actions.appendChild(action); } } } if (this.data.reply != null) { this.commentArea.innerHTML = this.data.reply; var scripts = this.commentArea.getElementsByTagName('script'); for ( var script = 0; script != scripts.length; script++) { try { eval(scripts[script].innerHTML.replace(/[\n\r\f\t]/g, '')); } catch(e) { } } } for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); } KComment.prototype.getInfoField = function(field) { return this.infoFields[field]; } KComment.prototype.setInfoFieldText = function(field, value, isHTML) { var infoField = this.infoFields[field]; if (infoField) { if (isHTML) { infoField.childNodes[1].innerHTML = value; } else { infoField.childNodes[1].removeChild(infoField.childNodes[1].childNodes[0]); infoField.childNodes[1].appendChild(window.document.createTextNode(value)); } } } KComment.prototype.getField = function(data, field) { if (!data[field].value) { var infoField = window.document.createElement('div'); infoField.className = 'KCommentInfoFieldPanel ' + (data[field].cssClass || '') + ' '; for ( var subField in data[field]) { if (this.exceptions.test(subField) || (this.fieldInfoExceptions && this.fieldInfoExceptions.test(subField))) { continue; } var subInfoField = this.getField(data[field], subField); infoField.appendChild(subInfoField); } infoField.appendChild(KCSS.clearBoth()); this.infoFields[field] = infoField; return infoField; } else { var infoField = window.document.createElement('div'); infoField.className = 'KCommentInfoField ' + (data[field].cssClass || '') + ' '; if (data[field].label) { var label = window.document.createElement('div'); label.className = 'KCommentInfoFieldLabel'; label.appendChild(window.document.createTextNode(data[field].label + ':')); infoField.appendChild(label); } var value = window.document.createElement('div'); value.className = 'KCommentInfoFieldValue'; if (data[field].isHTML) { value.innerHTML = data[field].value; } else { value.appendChild(window.document.createTextNode(data[field].value)); } if (data[field].tooltip) { value.alt = data[field].tooltip; KSystem.addEventListener(value, 'mouseover', KComment.onMouseOver); } infoField.appendChild(value); this.infoFields[field] = infoField; return infoField; } } KComment.onMouseOver = function(event) { var target = KSystem.getEventTarget(event); if (!target.alt) { target = target.parentNode; } KTooltip.showTooltip(target, { text : target.alt, isHTML : true, offsetX : 0, offsetY : 15, cssClass : 'KCommentActionTooltip' }); } KComment.onTitleMouseOver = function(event) { var target = KSystem.getEventTarget(event); var widget = KSystem.getEventWidget(event); KTooltip.showTooltip(target, { text : widget.data.info.tooltip, isHTML : true, offsetX : 0, offsetY : 15, cssClass : 'KCommentActionTooltip' }, event); } KComment.INFO_DIV = 'infoArea'; KComment.COMMENT_DIV = 'commentArea'; KComment.ACTIONS_DIV = 'actions'; KDialog.prototype = new KWidget(); KDialog.prototype.constructor = KDialog; KDialog.MODAL = 1; KDialog.MOVABLE = 2; KDialog.CENTERED = 4; function KDialog(parent, title, content) { if (parent != null) { KWidget.call(this, parent); this.titleText = title this.dialogContent = content; this.panel.style.display = 'none'; this.buttons = KWidget.CLOSE; this.dialogContentDiv = this.content.appendChild(window.document.createElement('div')); this.closeCallback = null; this.instanceCloseCallback = null; this.type = 0; this.showing = false; this.aside = true; } } KDialog.prototype.go = function() { if (this.activated()) { this.dialogContentDiv.innerHTML = ''; } this.load(); } KDialog.prototype.load = function() { this.draw(); } KDialog.prototype.onShow = function() { if (this.showing) { if (this.activated() && ((this.type & KDialog.MODAL) == KDialog.MODAL)) { Kinky.site.showOverlay(); } return KWidget.prototype.onShow.call(this); } return false; } KDialog.prototype.onHide = function() { if (this.showing) { if (this.activated() && ((this.type & KDialog.MODAL) == KDialog.MODAL)) { Kinky.site.hideOverlay(true); } KWidget.prototype.onHide.call(this); } } KDialog.prototype.draw = function() { if (!this.activated()) { this.window = ((this.type & KDialog.CENTERED) == KDialog.CENTERED) || ((this.type & KDialog.MODAL) == KDialog.MODAL); this.frame = true; this.movable = ((this.type & KDialog.MOVABLE) == KDialog.MOVABLE); this.closeCallback = this.closeCallback || KDialog.close; this.drawWindow( { closeCallback : this.instanceCloseCallback || this.closeCallback }); if (this.childDiv(KWidget.CLOSE_BUTTON)) { this.childDiv(KWidget.CLOSE_BUTTON).className = ' KDialogCloseButton '; } var title = window.document.createElement('h2'); this.widgetTitle.appendChild(title); if ((this.buttons & KWidget.PREVIOUS) == KWidget.PREVIOUS) { var previousButton = window.document.createElement('button'); previousButton.setAttribute('type', 'button'); previousButton.appendChild(window.document.createTextNode(' ')); previousButton.className = ' KDialogPrevButton '; this.content.appendChild(previousButton); KSystem.addEventListener(previousButton, 'click', this.previousCallback || KDialog.close); } if ((this.buttons & KWidget.NEXT) == KWidget.NEXT) { var nextButton = window.document.createElement('button'); nextButton.setAttribute('type', 'button'); nextButton.appendChild(window.document.createTextNode(' ')); nextButton.className = ' KDialogNextButton '; this.content.appendChild(nextButton); KSystem.addEventListener(nextButton, 'click', this.nextCallback || KDialog.close); } } if (this.titleText) { this.widgetTitle.childNodes[0].innerHTML = this.titleText; } if (this.dialogContent) { if (this.dialogContent instanceof KWidget) { this.dialogContentDiv.appendChild(this.dialogContent.panel); this.dialogContent.go(); } else { this.dialogContentDiv.innerHTML = this.dialogContent; } } this.activate(); } KDialog.show = function(dialog, params) { dialog.panel.style.display = 'block'; dialog.dialogContent = params.content; dialog.titleText = params.title; dialog.showing = true; dialog.display = false; dialog.instanceCloseCallback = params.closeCallback; if (params.data) { dialog.data = params.data; } dialog.go(); } KDialog.showConfirm = function(dialog, params) { var group = new KPanel(this); var text = new KText(group); text.setText(params.text); group.addElement(text); var okButton = new KButton(this, 'Ok', 'okButton', [ params.okCallback, KDialog.close ]); group.addElement(okButton); var cancelButton = new KButton(this, 'Cancel', 'cancelButton', params.cancelCallback || KDialog.close); group.addElement(cancelButton); KDialog.show(dialog, { content : group, title : params.title }); } KDialog.showLogin = function(dialog, params) { var group = new KPanel(this); var text = new KText(group); text.setText(params.text || ''); group.addElement(text); var form = new KForm(group); group.addElement(form); form.onValidate = function(data, post, status) { if (!status) { for ( var index in post) { post[index].showErrorMessage(); } } else { params.okCallback.call(); } return false; } var user = new KInput(form, 'text', params.labels[0], 'username$' + group.id); user.addValidator(/.+/, 'Tens que introduzir um username.'); user.addOption(1, 'Um'); user.addOption(2, 'Dois'); user.addOption(3, 'Tr\u00eas'); user.addOption(4, 'Quatro'); form.addInput(user); var password = new KInput(form, 'password', params.labels[1], 'password$' + group.id); password.addValidator(/.+/, 'Tens que introduzir uma password.'); form.addInput(password); var okButton = new KButton(group, 'Ok', 'okButton$' + group.id, [ params.okCallback ]); group.addElement(okButton); var cancelButton = new KButton(group, 'Cancel', 'cancelButton$' + group.id, params.cancelCallback || KDialog.close); group.addElement(cancelButton); if (params.registerLink) { var registerLink = new KLink(group, params.registerLink.url); registerLink.data.titleText = params.registerLink.title; registerLink.data.text = params.registerLink.text; group.addElement(registerLink); } if (params.recoverLink) { var recoverLink = new KLink(group, params.recoverLink.url); recoverLink.data.titleText = params.recoverLink.title; recoverLink.data.text = params.recoverLink.text; group.addElement(recoverLink); } KDialog.show(dialog, { content : group, title : params.title }); return { form : form, username : user, password : password }; } KDialog.close = function(event, dialog) { var widget = dialog || KSystem.getEventWidget(event); widget.onHide(); return; } KDialog.DIALOG_CONTENT_DIV = 'dialogContentDiv'; KFlash.prototype = new KWidget; KFlash.prototype.constructor = KFlash; function KFlash(parent, swfURL, params) { if (parent != null) { this.simpleWidget = true; KWidget.call(this, parent); this.data = params; this.swfURL = swfURL; this.swfID = null; this.staticFlash = false; this.content.id = this.id + 'FlashReplace'; } } KFlash.prototype.go = function() { if (this.staticFlash || this.swfURL != null) { this.draw(); } else { this.load(); } } KFlash.prototype.redraw = function() { if (this.activated()) { this.panel.innerHTML = ''; this.content = window.document.createElement('div'); this.content.className = ' KWidgetPanelContent ' + this.className + 'Content '; this.content.id = this.id + 'FlashReplace'; this.panel.appendChild(this.content); } KWidget.prototype.redraw.call(this); } KFlash.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } KFlash.prototype.onLoad = function(data) { this.swfURL = data.fileURL; this.data = data; this.clear(); this.draw(); } KFlash.prototype.exec = function(callback, params) { var func = null; if (this.getFlashObject()) { eval('func = this.getFlashObject().' + callback); if (func) { try { func(params); } catch (e) { } } } } KFlash.prototype.reset = function() { this.exec('resetFlash'); } KFlash.prototype.stop = function() { this.exec('stopFlash'); } KFlash.prototype.play = function() { this.exec('playFlash'); } KFlash.prototype.onFlashStart = function() { return this.data; } KFlash.prototype.onFlashLoad = function() { this.activate(); } KFlash.prototype.draw = function() { if (this.swfURL) { this.data.attributes = this.data.attributes || { id : this.id, name : this.id }; this.data.flashVars.onStart = 'KFlash.onStart'; this.data.flashVars.onComplete = 'KFlash.onComplete'; this.data.flashVars.className = this.className; this.data.flashVars.widgetID = this.id; this.swfID = this.id + 'FlashReplace'; swfobject.embedSWF(this.swfURL, this.swfID, this.data.width || '100%', this.data.height || '100%', this.data.version || "9.0.124", null, this.data.flashVars, this.data.params, this.data.attributes); if (this.data.noHandlers) { this.activate(); } } else { this.activate(); } } KFlash.prototype.getFlashObject = function() { return window.document.getElementById(this.data.attributes.id); } KFlash.onStart = function(widgetID) { return Kinky.bunnyMan.widgets[widgetID].onFlashStart(); } KFlash.onComplete = function(widgetID) { Kinky.bunnyMan.widgets[widgetID].onFlashLoad(); } KFlash.debug = function(object) { dump(object); } KFlashWidget.prototype = new KWidget(); KFlashWidget.prototype.constructor = KFlashWidget; function KFlashWidget(parent, url, service) { if (parent != null) { KPage.call(this, parent, url, service); } } KFlashWidget.prototype.onShow = function() { if (this.display) { return; } } KFlashWidget.prototype.onHide = function() { if (this.display && !(this instanceof KFlashWidgetDialog) && Kinky.site.childWidget(this.getHash()) instanceof KFlashWidgetDialog) { return; } } KFlashWidget.prototype.draw = function() { this.activate(); } KImage.prototype = new KWidget; KImage.prototype.constructor = KImage; function KImage(parent, imageURL, popupURL) { if (parent != null) { this.simpleWidget = true; KWidget.call(this, parent); if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { this.image = new Image(); } else { this.image = window.document.createElement('img'); this.image.onload = function() { var widget = KSystem.getWidget(this); widget.data.width = this.width; widget.data.height = this.height; widget.image.style.display = 'block'; if (widget.waitForLoad) { widget.activate(); } }; } this.content.appendChild(this.image); this.image.style.display = 'none'; this.staticImage = false; this.data = {}; if (imageURL != null) { this.data.type = 'local'; this.data.url = imageURL; this.data.popupURL = popupURL } } } KImage.prototype.iePreload = function() { if (this.image.complete) { this.data.width = this.image.width; this.data.height = this.image.height; this.activate(); this.image.style.display = 'block'; } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreload()', 100); } } KImage.prototype.iePreloadPopup = function() { if (this.popup.complete) { this.data.popupHeight = this.popup.height; this.data.popupWidth = this.popup.width; this.onLoadPopup(); } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreloadPopup()', 100); } } KImage.prototype.go = function() { if (this.staticImage || this.data.type != null) { this.image.style.display = 'none'; this.draw(); } else { this.load(); } } KImage.prototype.setImage = function(imageURL) { this.data.url = imageURL; if (this.activated()) { this.content.removeChild(this.image); if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { this.image = new Image(); } else { this.image = window.document.createElement('img'); } this.content.appendChild(this.image); this.image.src = Kinky.IMAGE_PROXY ? Kinky.IMAGE_PROXY + encodeURIComponent(this.data.url) : this.data.url; if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreload()', 100); } } } KImage.prototype.setPopupImage = function(popupURL) { this.data.popupURL = popupURL; } KImage.prototype.onShow = function() { if (KWidget.prototype.onShow.call(this)) { if (this.maxWidth && this.maxHeight && this.waitForLoad) { if (this.maxWidth / this.data.width > this.maxHeight / this.data.height) { this.image.style.width = this.maxWidth + 'px'; this.image.style.height = 'auto'; } else { this.image.style.height = this.maxHeight + 'px'; this.image.style.width = 'auto'; } } if (!this.waitForLoad) { this.image.style.display = 'block'; } return true; } return false; } KImage.prototype.loadPopupImage = function() { if (this.data.popupURL) { if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { this.popup = new Image(); KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreloadPopup()', 100); } else { var image = this; this.popup = window.document.createElement('img'); this.popup.onload = function(event) { image.data.popupHeight = this.height; image.data.popupWidth = this.width; image.onLoadPopup(); }; } this.popup.src = this.data.popupURL; } } KImage.prototype.onLoadPopup = function() { } KImage.prototype.addMap = function(params) { if (this.map == null) { this.map = window.document.createElement('map'); this.map.name = this.map.id = 'map' + this.id; } for ( var index in params.map) { var area = window.document.createElement('area'); area.shape = params.map[index].shape || 'poly'; area.coords = params.map[index].coords; area.href = params.map[index].url; area.target = params.map[index].target || '_self'; if (params.map[index].onOver) { KSystem.addEventListener(area, 'mouseover', params.map[index].onOver); } if (params.map[index].onOut) { KSystem.addEventListener(area, 'mouseout', params.map[index].onOut); } if (params.map[index].onClick) { KSystem.addEventListener(area, 'click', params.map[index].onClick); } this.map.appendChild(area); } } KImage.prototype.setTitle = function(text, isHTML) { if (isHTML) { this.image.innerHTML = text; } else { this.image.appendChild(window.document.createTextNode(text)); } } KImage.prototype.setImageName = function(text) { this.data.name = text; } KImage.prototype.setDefaultImage = function(imageURL) { this.defaultImage = imageURL; } KImage.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } KImage.prototype.onLoad = function(data) { for ( var element in data) { for ( var att in data[element]) { this.data[att] = data[element][att]; } } this.image.style.display = 'none'; this.draw(); } KImage.prototype.draw = function() { if (this.data.name) { KSystem.addEventListener(this.image, 'mouseover', KImage.onMouseOver); } if (this.map) { this.image.useMap = '#' + this.map.id; this.content.appendChild(this.map); } if (!this.waitForLoad) { this.activate(); } else { this.isDrawn = true; this.wait(); if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreload()', 100); } } this.image.src = Kinky.IMAGE_PROXY ? Kinky.IMAGE_PROXY + encodeURIComponent(this.data.url) : this.data.url; } KImage.onMouseOver = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(mouseEvent); KTooltip.showTooltip(widget.image, { text : widget.data.name, isHTML : true, offsetX : 0, offsetY : 15, left : KSystem.mouseX(mouseEvent), top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'KLinkImageTooltip' }); } KImage.IMAGE_ELEMENT = 'image'; KImage.prototype.FOCUS_DIV = 'image'; KLink.prototype = new KWidget; KLink.prototype.constructor = KLink; function KLink(parent, url, imageURL, target) { if (parent != null) { this.simpleWidget = true; KWidget.call(this, parent); this.data = new Object(); this.data.linkPath = url; this.link = window.document.createElement('a'); this.link.target = target || '_self'; this.link.href = url || 'javascript:void(0)'; this.text = window.document.createElement('div'); this.data.imageURL = imageURL; if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { this.image = new Image(); KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreload()', 100); } else { this.image = window.document.createElement('img'); this.image.onload = function() { var widget = KSystem.getWidget(this); widget.activate(); this.style.display = 'block'; }; } this.imageOver = window.document.createElement('img'); } } KLink.prototype.iePreload = function() { if (this.image.width && this.image.height) { this.data.width = this.image.width; this.data.height = this.image.height; this.activate(); this.image.style.display = 'block'; } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreload()', 100); } } KLink.prototype.go = function() { if (this.data.linkPath != null) { this.draw(); } else { this.load(); } } KLink.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } KLink.prototype.onLoad = function(data) { for ( var element in data) { for ( var att in data[element]) { this.data[att] = data[element][att]; } } if (!this.activated()) { this.draw(); } } KLink.prototype.getLinkText = function() { return this.data.titleText; } KLink.prototype.setLinkText = function(text, isHTML) { if (text) { this.data.titleText = text; this.data.isHTML = isHTML; if (this.data.isHTML) { this.text.innerHTML = this.data.titleText; } else { this.text.innerHTML = ''; this.text.appendChild(window.document.createTextNode(this.data.titleText)); } } } KLink.prototype.setLinkImage = function(imageURL) { if (imageURL) { this.data.imageURL = imageURL; this.image.src = Kinky.IMAGE_PROXY ? Kinky.IMAGE_PROXY + encodeURIComponent(this.data.imageURL) : this.data.imageURL; } } KLink.prototype.setLinkOverImage = function(imageURL) { if (imageURL) { this.data.imageOverURL = imageURL; this.imageOver.src = Kinky.IMAGE_PROXY ? Kinky.IMAGE_PROXY + encodeURIComponent(this.data.imageOverURL) : this.data.imageOverURL; } } KLink.prototype.setTooltip = function(tooltip) { if (tooltip) { this.data.name = tooltip; } } KLink.prototype.setLinkURL = function(newURL) { if (newURL) { this.data.linkPath = newURL; this.link.href = this.data.linkPath; } } KLink.prototype.initLink = function() { this.setLinkURL(this.data.linkPath); this.setTooltip(this.data.name); this.setLinkOverImage(this.data.imageOverURL); this.setLinkImage(this.data.imageURL); this.setLinkText(this.data.titleText); } KLink.prototype.draw = function() { if (this.data.linkPath && this.data.linkPath != 'javascript:void(0)' && this.link.href == 'javascript:void(0)') { this.initLink(); } this.text.className = ' KLinkText '; this.image.className = ' KLinkImage '; if (this.text.innerHTML.length == 0 && this.data.titleText && this.data.titleText.length > 0) { this.setLinkText(this.data.titleText, true); } if (this.data.imageURL && this.data.imageURL != '' && this.data.imageURL != Kinky.SITE_URL) { this.link.appendChild(this.image); this.image.style.display = 'none'; this.image.src = Kinky.IMAGE_PROXY ? Kinky.IMAGE_PROXY + encodeURIComponent(this.data.imageURL) : this.data.imageURL; this.isImageLink = true; } this.link.appendChild(this.text); if (this.data.name) { this.hasTooltip = true; KSystem.addEventListener(this.link, 'mouseover', KLink.onMouseOver); } if (this.imageOver.src != null && this.imageOver.src != '') { this.setStyle({ display : 'none' }, KLink.IMAGE_OVER_ELEMENT); this.link.appendChild(this.imageOver); if (!this.hashTooltip) { KSystem.addEventListener(this.content, 'mouseover', KLink.onMouseOver); } KSystem.addEventListener(this.content, 'mouseout', KLink.onMouseOut); } this.content.appendChild(this.link); if (!(this.waitForLoad && this.data.imageURL && this.data.imageURL != '' && this.data.imageURL != Kinky.SITE_URL)) { this.activate(); } else { this.isDrawn = true; this.wait(); if (KBrowserDetect.browser == 2 && KBrowserDetect.version < 9) { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').iePreload()', 100); } } } KLink.onMouseOver = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(event); if (widget.data.imageOverURL) { if (widget.isImageLink) { widget.setStyle({ display : 'none' }, KLink.IMAGE_ELEMENT); widget.setStyle({ display : 'block' }, KLink.IMAGE_OVER_ELEMENT); } else { widget.panel.style.backgroundImage = 'url(' + widget.data.thumbOnOverUrlPath + ')'; } } if (widget.hasTooltip) { KTooltip.showTooltip(widget.link, { text : widget.data.name, isHTML : true, offsetX : 15, offsetY : 15, left : KSystem.mouseX(mouseEvent), top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'KLinkImageTooltip' }); } } KLink.onMouseOut = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(mouseEvent); if (widget.isImageLink) { widget.setStyle({ display : 'block' }, KLink.IMAGE_ELEMENT); widget.setStyle({ display : 'none' }, KLink.IMAGE_OVER_ELEMENT); } else { widget.panel.style.backgroundImage = 'url(' + widget.data.thumbLinkPath + ')'; } } KLink.LINK_ELEMENT = 'link'; KLink.IMAGE_ELEMENT = 'image'; KLink.IMAGE_OVER_ELEMENT = 'imageOver'; KLink.TEXT_ELEMENT = 'text'; KLink.prototype.FOCUS_DIV = 'link'; KText.prototype = new KWidget; KText.prototype.constructor = KText; function KText(parent, topTagName) { if (parent != null) { KWidget.call(this, parent); this.tagName = topTagName || 'div'; this.textHeight = 0; this.parts = new Array(); this.isStaticText = true; this.data = {}; } } KText.prototype.getText = function(index) { index = index || 0; if (this.activated()) { return this.parts[index].innerHTML; } else { return this.data.text[index].content; } } KText.prototype.setText = function(text, isNotHTML, index, cssClass) { index = index || 0; if (this.activated()) { if (this.parts.length <= index) { this.appendText(text, isNotHTML, cssClass); return; } if (isNotHTML) { this.parts[index].innerHTML = ''; this.parts[index].appendChild(window.document.createTextNode(text)); } else { if (typeof text == 'string') { this.parts[index].innerHTML = text; } else { this.parts[index].innerHTML = ''; this.parts[index].appendChild(text); } } this.data.text[index] = { content : text, isNotHTML : isNotHTML, cssClass : cssClass }; } else { this.data.text = [ { content : text, isNotHTML : isNotHTML, cssClass : cssClass } ]; } } KText.prototype.appendText = function(text, isNotHTML, cssClass) { if (this.activated()) { var element = window.document.createElement(this.tagName); if (isNotHTML) { element.appendChild(window.document.createTextNode(text)); } else { if (typeof text == 'string') { element.innerHTML = text; } else { element.appendChild(text); } } if (cssClass) { element.className = cssClass; } this.parts.push(element); this.content.appendChild(element); } if (this.data.text) { this.data.text.push( { content : text, isNotHTML : isNotHTML, cssClass : cssClass }); } else { this.data.text = [ { content : text, isNotHTML : isNotHTML, cssClass : cssClass } ]; } } KText.prototype.go = function() { if (this.isStaticText || this.data.text != null) { this.draw(); } else { this.load(); } } KText.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } KText.prototype.onLoad = function(data) { this.data = data; if (!this.activated()) { this.draw(); } } KText.prototype.draw = function() { this.panel.style.overflow = 'visible'; if (this.isPaginated) { this.contentContainer.style.overflow = 'hidden'; this.content.style.position = 'absolute'; } for ( var index in this.data.text) { var element = window.document.createElement(this.data.text[index].type || this.tagName); if (this.data.text[index].isNotHTML) { element.appendChild(window.document.createTextNode(this.data.text[index].content)); } else { if (typeof this.data.text[index].content == 'string') { element.innerHTML = this.data.text[index].content; } else { element.appendChild(this.data.text[index].content); } } if (this.data.text[index].cssClass) { element.className = this.data.text[index].cssClass; } this.parts.push(element); this.content.appendChild(element); } this.textHeight = this.getHeight(); this.activate(); } KText.prototype.resetEffect = function(movement) { var tween = this.effects[movement]; switch (tween.type) { case 'move': { if (!tween.lockX) { this.content.style.left = (tween.targetX * -tween.direction) + 'px'; } if (!tween.lockY) { this.content.style.top = (tween.targetY * -tween.direction) + 'px'; } break; } case 'resize': { break; } } } KTooltip.prototype = new KWidget; KTooltip.prototype.constructor = KTooltip; function KTooltip(parent, params) { if (parent != null) { //this.simpleWidget = true; this.id = Kinky.bunnyMan.addWidget(this, 'ktooltip'); KWidget.call(this, Kinky.site); this.targetWidget = KSystem.getWidget(parent); this.target = parent; this.data = params; this.panel.alt = parent.id; this.textContent = window.document.createElement('div'); this.content.appendChild(this.textContent); this.targetWidget.tooltip = this; } } KTooltip.prototype.go = function() { if (this.data.text != null) { this.draw(); } else { this.load(); } } KTooltip.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } KTooltip.prototype.onLoad = function(data) { for ( var att in data) { this.data[att] = data[att]; } if (!this.activated()) { this.draw(); } } KTooltip.prototype.setText = function(text, isHTML) { this.data.text = text; this.data.isHTML = isHTML; } KTooltip.prototype.draw = function() { if (this.data.text) { if (this.data.isHTML) { this.textContent.innerHTML = this.data.text; } else { this.textContent.appendChild(window.document.createTextNode(this.data.text)); } KSystem.addEventListener(this.target, 'mouseout', KTooltip.hide); KSystem.addEventListener(this.target, 'mousemove', KTooltip.move); this.panel.style.position = 'absolute'; this.panel.style.display = 'none'; this.panel.className = this.data.cssClass || this.panel.className; window.document.body.appendChild(this.panel); this.activate(); } } KTooltip.hide = function(event) { var widget = KSystem.getEventWidget(event); KSystem.removeEventListener(widget.tooltip.target, 'mouseout', KTooltip.hide); KSystem.removeEventListener(widget.tooltip.target, 'mousemove', KTooltip.move); if (widget.tooltip && widget.tooltip.panel && widget.tooltip.panel.parentNode) { widget.tooltip.panel.parentNode.removeChild(widget.tooltip.panel); } delete widget.tooltip; } KTooltip.show = function(event) { KTooltip.removeTooltip(); var parent = KSystem.getEventTarget(event); var tooltip = Kinky.getWidget(parent.alt); tooltip.go(); } KTooltip.move = function(event) { var widget = KSystem.getEventWidget(event); var mouseEvent = KSystem.getEvent(event); widget.tooltip.panel.style.display = 'block'; widget.tooltip.panel.style.left = (KSystem.mouseX(mouseEvent) + widget.tooltip.data.offsetX) + 'px'; if (KSystem.mouseY(mouseEvent) + widget.tooltip.data.offsetY + widget.tooltip.getHeight() + 30 > KSystem.normalizePixelValue(Kinky.site.panel.style.height)) { widget.tooltip.panel.style.top = (KSystem.mouseY(mouseEvent) - widget.tooltip.getHeight() - widget.tooltip.data.offsetY - 15) + 'px'; } else { widget.tooltip.panel.style.top = (KSystem.mouseY(mouseEvent) + widget.tooltip.data.offsetY) + 'px'; } } KTooltip.removeTooltip = function(parent) { if (!parent) { var tooltip = window.document.getElementById('ktooltip'); if (!tooltip) { return; } if (tooltip.parentNode) { tooltip.parentNode.removeChild(tooltip); } return; } if (parent && parent.tooltip && parent.tooltip.panel.parentNode) { KSystem.removeEventListener(parent.tooltip.target, 'mouseout', KTooltip.hide); KSystem.removeEventListener(parent.tooltip.target, 'mousemove', KTooltip.move); parent.tooltip.panel.parentNode.removeChild(parent.tooltip.panel); delete parent.tooltip; } } KTooltip.showTooltip = function(parent, params, event) { if (parent instanceof KWidget) { parent = parent.content; } if (event) { var mouseEvent = KSystem.getEvent(event); params.left = KSystem.mouseX(mouseEvent); params.top = KSystem.mouseY(mouseEvent); } var tooltip = new KTooltip(parent, params); tooltip.go(); } KUpdatableWidget.prototype = new KWidget(); KUpdatableWidget.prototype.constructor = KUpdatableWidget; function KUpdatableWidget(parent, startNow) { if (parent != null) { KWidget.call(this, parent); this.requests = []; this.timeout = 15000; this.rstart = 0; this.data = {}; if (startNow) { this.go(); } } } KUpdatableWidget.prototype.go = function() { this.load(); } KUpdatableWidget.prototype.load = function() { var params = new Object(); params.todo = this.requests; this.kinky.get(this, this.data.feService, params); } KUpdatableWidget.prototype.nextRequest = function() { setTimeout('KUpdatableWidget.timer(Kinky.getWidget(\'' + this.id + '\'))', this.timeout); } KUpdatableWidget.prototype.onLoad = function(data) { if (data) { KSystem.merge(KUpdatableWidget.updates, data); for (var index in this.requests) { KBreadcrumb.dispatchEvent(this.requests[index].id, { hash : this.requests[index].hash, query : this.requests[index].query, action : this.requests[index].action }); } } this.nextRequest(); } KUpdatableWidget.prototype.addRequest = function(params) { this.requests.push(params); } KUpdatableWidget.timer = function(widget) { widget.refresh(); } KUpdatableWidget.updates = {}; /** * @author pfigueiredo */ KForm.prototype = new KWidget(); KForm.prototype.constructor = KForm; function KForm(parent) { if (parent != null) { KWidget.call(this, parent); this.form = window.document.createElement('form'); this.form.method = 'post'; this.content.appendChild(this.form); this.infoArea = window.document.createElement('div'); this.infoArea.className = 'KFormInfoArea'; this.content.appendChild(this.infoArea); this.originalContent = this.content; this.content = this.fieldset = window.document.createElement('fieldset'); this.form.appendChild(this.content); this.entities = false; this.staticForm = false; this.action = null; this.stopOnFirstError = false; this.inputByID = new Object(); this.inputTextCount = 0; this.addActionListener(KForm.actions, ['/error']); } } KForm.prototype.reset = function(){ for ( var element in this.inputByID) { this.inputByID[element].setValue(null); } } KForm.prototype.addInput = function(input) { if (input instanceof KInput) { var id = null; if (input.parent.id == this.id) { id = this.appendChild(input); } else { id = input.id; } this.inputByID[input.inputID] = input; if (input.type == 'text' || input instanceof KMap) { this.inputTextCount++; } input.parentForm = this; } else { throw new KNoExtensionException(this, "addInput"); } } KForm.prototype.getInput = function(inputID) { return this.inputByID[inputID]; } KForm.prototype.removeInput = function(inputID) { var input = this.childWidget(inputID); if (input) { this.removeChild(input); } } KForm.onEnterPressed = function(event) { event = KSystem.getEvent(event); var keyCode = event.keyCode || event.which; if (keyCode == 13) { return false; } return true; } KForm.prototype.showInfo = function(data) { this.infoArea.innerHTML = data; } KForm.prototype.onValidate = function(data, params, status) { throw new KNoExtensionException(this, "onValidate"); } KForm.prototype.onSuccess = function(data) { throw new KNoExtensionException(this, "onSuccess"); } KForm.prototype.onError = function(error) { dump(error); } KForm.prototype.onLoad = function(data) { for ( var block in data) { if (data[block] && typeof data[block] == 'object') { this.appendChild(KSystem.construct(data[block], this)); } } if (!this.activated()) { this.draw(); } else { this.redraw(); } } KForm.prototype.go = function() { if (this.childWidgets() != null || this.staticForm) { this.draw(); } else { this.load(); } } KForm.prototype.load = function() { if (this.data != null && this.data.contentView != null) { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; if (this.isPaginated) { params.offset = this.nPage * this.perPage; params.limit = this.perPage; } this.kinky.get(this, this.data.feService, params); } } KForm.prototype.draw = function() { this.drawWindow(); if (this.data != null && this.data.titleText != null) { var title = window.document.createElement('h2'); title.appendChild(window.document.createTextNode(this.data.titleText)); this.widgetTitle.appendChild(title); this.widgetTitle.appendChild(window.document.createElement('hr')); } if (this.inputTextCount == 1) { var dummy = window.document.createElement('input'); dummy.setAttribute('type', 'text'); dummy.name = dummy.id = '__dummy'; dummy.style.display = 'none'; this.content.appendChild(dummy); } for ( var element in this.childWidgets()) { this.childWidget(element).go(); } KSystem.addEventListener(this.form, 'submit', function(event) { KForm.goSubmit(event); return false; }); this.activate(); } KForm.prototype.submit = function() { var params = this.validate(); if (params) { if ((params = this.onValidate(this.action, params, true)) != false) { this.kinky.save(this, this.action, params, 'onSuccess'); } } return false; } KForm.prototype.validate = function() { var params = new Object(); var wrongParams = new Object(); var validationText = ''; var isValid = true; for ( var element in this.inputByID) { var widget = this.inputByID[element]; if (!(widget instanceof KInput)) { continue; } var validation = widget.validate(); if (validation == true) { params[widget.inputID.replace(/[\[\]]/g, '')] = widget.getValue(); } else { wrongParams[widget.inputID.replace(/[\[\]]/g, '')] = widget; isValid = false; validationText += validation; if (this.stopOnFirstError) break; } } if (!isValid) { this.onValidate(validationText, wrongParams, false); return false; } return params; } KForm.goSubmit = function(event) { var target = KSystem.getEventTarget(event); var form = KSystem.getWidget(target.form || target); while(!(form instanceof KForm)) { form = form.parent; } var params = form.validate(); if (target.form && target.tagName.toUpperCase() == 'BUTTON') { params[target.id] = 'clicked'; } if (params) { if ((params = form.onValidate(form.action, params, true)) != false) { form.kinky.save(form, form.action, params, 'onSuccess'); } } return false; } KForm.actions = function(widget, action) { if (!widget.activated()) { return; } var page = widget.getParent('KPage'); if (page && widget.activated() && widget.getHash() == page.hash) { widget.onError(widget.error); } } KForm.FORM_ELEMENT = 'form'; KInput.prototype = new KWidget(); KInput.prototype.constructor = KInput; KInput.prototype.simpleWidget = true; function KInput(parent, type, label, id, isHTML) { if (parent != null) { KWidget.call(this, parent); this.labelText = label; this.type = type; this.inputID = id; this.editMode = true; this.staticInput = type != null; this.inputs = new Array(); this.options = new Array(); this.validations = new Array(); this.validationIndex = null; this.errorArea = null; this.isMultiple = false; this.noEncryption = false; this.inputListeners = new Array(); this.passValue = ''; this.editable = true; this.onEnterSubmit = true; this.parentForm = null; if (id != null) { this.options.push( { id : id, value : null, label : label, selected : false, position : 'right', labelPosition : 'outside', isHTML : isHTML }); } } } KInput.prototype.validate = function() { if (this.validations.length != 0) { var value = this.getValue(true).toString(); for ( var index in this.validations) { if (this.validations[index].regex instanceof RegExp) { if (!this.validations[index].regex.test(value)) { this.validationIndex = index; this.addCSSClass('KInputError'); return this.validations[index].message; } } else if (this.validations[index].regex.indexOf('equals') == 0) { var field = this.validations[index].regex.split('(')[1]; field = field.substr(0, field.length - 1); if (this.parentForm.getInput(field).getValue() != this.getValue()) { this.validationIndex = index; this.addCSSClass('KInputError'); return this.validations[index].message; } } this.errorArea.innerHTML = ''; this.removeCSSClass('KInputError'); if (this.inputs[0]) { KSystem.removeEventListener(this.inputs[0], 'mouseover', KInput.onMouseOver); } } } return true; } KInput.prototype.addValidator = function(test, message) { this.validations.push( { regex : test, message : message }); } KInput.prototype.removeValidator = function(test) { for (var index in this.validations) { if (this.validations[index].regex.toString() == test.toString()) { delete this.validations[index]; } } } KInput.prototype.addEventListener = function(eventName, callback, target) { if (eventName == 'change' && !target) { target = KInput.INPUT_ELEMENT; } if (target == KInput.INPUT_ELEMENT && !this.activated()) { this.inputListeners.push( { event : eventName, callback : callback }); } else { if (/checkbox|radio/.test(this.type)) { for (var index in this.inputs) { KWidget.prototype.addEventListener.call(this, eventName, callback, 'inputs[' + index + ']'); } } else { KWidget.prototype.addEventListener.call(this, eventName, callback, target); } } } KInput.prototype.addEventListeners = function(eventName, callback) { for ( var index in this.inputs) { KSystem.addEventListener(this.inputs[index], eventName, callback); } } KInput.prototype.focus = function() { if (this.inputs.length > 0) { this.inputs[0].focus(); } } KInput.prototype.getInput = function() { return this.inputs[0]; } KInput.prototype.getErrorMessage = function(index) { return this.validations[index].message; } KInput.prototype.showErrorMessage = function(params) { if (!params || !params.tooltip) { this.errorArea.innerHTML = ''; if (params && params.isHtml) { this.errorArea.innerHTML += '* ' + (this.validationIndex ? this.getErrorMessage(this.validationIndex) : ''); } else { this.errorArea.appendChild(window.document.createTextNode('* ' + (this.validationIndex ? this.getErrorMessage(this.validationIndex) : ''))); } } else if (params && params.tooltip) { KSystem.addEventListener(this.inputs[0], 'mouseover', KInput.onMouseOver); } } KInput.onMouseOver = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(mouseEvent); KTooltip.showTooltip(widget.inputs[0], { text : '* ' + (widget.validationIndex ? widget.getErrorMessage(widget.validationIndex) : ''), isHTML : true, offsetX : 0, offsetY : 15, left : KSystem.mouseX(mouseEvent), top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'KInputTooltip' }); } KInput.prototype.addOption = function(value, caption, selected, isHTML) { if (/select|checkbox|radio/.test(this.type)) { this.options.push( { id : this.inputID + this.options.length, value : value, label : caption || value, selected : selected, isHTML : isHTML }); } else if (/\[\]/.test(this.inputID)) { this.options.push( { id : this.inputID, value : value, label : caption || value, selected : selected, isHTML : isHTML }); } return true; } KInput.prototype.setStyle = function(cssStyle, target) { if (!this.activated() && target && target == KInput.LABEL_CONTAINER) { this.options[0].labelStyle = cssStyle return; } var domElements = null; if (target) { if (target instanceof Array) { domElements = new Array(); for (var index in target) { if (typeof target[index] == 'string') { eval('domElements.push( this.' + target[index] + ');'); } else { domElements.push(target); } } } else if (typeof target == 'string') { eval('domElements = [ this.' + target + ' ];'); } else { domElements = [ target ]; } } else { domElements = [ this.panel ]; } for (var index in domElements) { var domElement = domElements[index]; for (var property in cssStyle) { if (cssStyle[property]) { switch (property) { case 'clear': { if (target == KInput.INPUT_ELEMENT) { eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); } else { domElement.appendChild(KCSS.clearBoth()); } break; } case 'labelPosition': { this.options[0].labelPosition = cssStyle[property]; break; } case 'cssFloat': { if (/checkbox|radio/.test(this.type)) { this.options[0].position = cssStyle[property]; } else { eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); } break; } case 'opacity' : { switch (KBrowserDetect.browser) { case 1: domElement.style.MozOpacity = cssStyle[property]; break; case 2: domElement.style.MsFilter = '"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + Math.round(cssStyle[property] * 100) + ')"'; domElement.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + Math.round(cssStyle[property] * 100) + ')'; case 3: domElement.style.opacity = cssStyle[property]; break; case 4: domElement.style.KhtmlOpacity = cssStyle[property]; break; case 5: domElement.style.opacity = cssStyle[property]; break; } break; } default: { eval('domElement.style.' + property + ' = \'' + cssStyle[property] + '\';'); break; } } } } } } KInput.prototype.onLoad = function(data) { this.data = data; this.type = this.data.type; } KInput.prototype.go = function() { if (this.activated()) { return; } if (this.childWidgets() != null || this.staticInput) { this.draw(); } else { this.load(); } } KInput.prototype.clear = function() { delete this.inputs; this.inputs = new Array(); this.options.splice(1, this.options.length - 1); KWidget.prototype.clear.call(this); } KInput.prototype.clearOptions = function() { if (/select/.test(this.type)) { this.inputs[0].innerHTML = ''; } } KInput.prototype.load = function() { if (this.data != null && this.data.contentView != null) { var params = new Object(); if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } params.contentView = this.data.contentView; params.contentID = this.data.contentID; this.kinky.get(this, this.data.feService, params); } } KInput.prototype.createInput = function(index) { var inputStyle = 'K' + this.type.toUpperCase().charAt(0) + this.type.substring(1); var toReturn = null; var isDiv = false; if (/select|textarea|button/.test(this.type)) { toReturn = window.document.createElement(this.type); if (!this.editable) { toReturn.setAttribute('readonly', 'readonly'); } } else if (/static/.test(this.type)) { toReturn = window.document.createElement('div'); isDiv = true; } else { toReturn = window.document.createElement((this.type == 'submit' ? 'button' : 'input')); toReturn.setAttribute('type', this.type == 'password' ? 'text' : this.type); if (!this.editable) { toReturn.setAttribute('readonly', 'readonly'); } } toReturn.className = 'KInputElement ' + inputStyle; if (/checkbox|radio/.test(this.type)) { toReturn.name = this.inputID; toReturn.id = this.options[index].id; if (this.options[index].selected) { toReturn.setAttribute('checked', 'checked'); } } else if (/\[\]/.test(this.inputID)) { toReturn.name = this.options[index].id; toReturn.id = this.inputID.replace(/\[\]/g, '') + this.inputs.length; } else { toReturn.name = toReturn.id = this.options[index].id; } if (isDiv) { toReturn.innerHTML = this.options[index].value; } else { toReturn.value = this.options[index].value || ''; } if (/checkbox|radio/.test(this.type)) { toReturn.name = this.inputID; toReturn.id = this.options[index].id; } if (/button|submit/.test(this.type)) { toReturn.setAttribute('type', 'button'); if (this.options[index].isHTML) { toReturn.innerHTML = this.options[index].label; } else { toReturn.appendChild(window.document.createTextNode(this.options[index].label)); } if (this.type == 'submit') { KSystem.addEventListener(toReturn, 'click', KForm.goSubmit); } } return toReturn; } KInput.labelFocus = function(event) { var target = KSystem.getEventTarget(event); var widget = KSystem.getEventWidget(event); widget.removeCSSClass('KInputLabelBlur'); if (widget.inputs[target.alt].value == null || widget.inputs[target.alt].value.replace(/[\r\n\f]/g, '') == widget.options[target.alt].label.replace(/[\r\n\f]/g, '')) { target.value = ''; } } KInput.labelBlur = function(event) { var target = KSystem.getEventTarget(event); var widget = KSystem.getEventWidget(event); if (!widget.inputs[target.alt] || widget.inputs[target.alt].value == null || widget.inputs[target.alt].value == '') { target.value = widget.options[target.alt].label; widget.addCSSClass('KInputLabelBlur'); } } KInput.prototype.createLabel = function(index) { if (this.type != 'button' && this.type != 'submit' && this.options[index].label != null && this.options[index].label != '') { if (this.options[index].labelPosition == 'inside') { if (!/select|radio|checkbox/.test(this.type) && (!this.options[index].value || (this.options[index].value && this.options[index].value == ''))) { this.inputs[index].value = this.options[index].label; this.inputs[index].alt = index; this.addCSSClass('KInputLabelBlur'); KSystem.addEventListener(this.inputs[index], 'focus', KInput.labelFocus); KSystem.addEventListener(this.inputs[index], 'blur', KInput.labelBlur); } return false; } else { var inputStyle = 'K' + this.type.toUpperCase().charAt(0) + this.type.substring(1); var labelContainer = window.document.createElement('div'); labelContainer.className = 'KLabelContainer'; var label = window.document.createElement('label'); label.setAttribute('for', this.options[index].id); label.className = 'KLabel ' + inputStyle + 'Label'; if (this.options[index].isHTML) { label.innerHTML = this.options[index].label; } else { label.appendChild(window.document.createTextNode(this.options[index].label)); } labelContainer.appendChild(label); return labelContainer; } } return false; } KInput.prototype.addOptions = function(select) { var first = true; for ( var index in this.options) { if (!first) { var option = window.document.createElement('option'); option.value = this.options[index].value; option.selected = this.options[index].selected; option.appendChild(window.document.createTextNode(this.options[index].label)); select.appendChild(option); } else { first = false; } } } KInput.prototype.draw = function() { var inputStyle = 'K' + this.type.toUpperCase().charAt(0) + this.type.substring(1); var first = true if (/checkbox|radio/.test(this.type)) { var label = this.createLabel(0); if (label) { this.content.appendChild(label); } } for ( var index in this.options) { if (/checkbox|radio/.test(this.type) && first) { first = false; continue; } var input = this.createInput(index); this.inputs.push(input); var label = this.createLabel(index); if (label && this.options[0].position == 'right') { if (/checkbox|radio/.test(this.type)) { label.className += ' ' + inputStyle + 'LabelOption'; } this.content.appendChild(label); } this.inputContainer = window.document.createElement('div'); this.inputContainer.className = 'KInputContainer ' + inputStyle + 'Container'; if (this.onEnterSubmit && !/textarea|button|submit/.test(this.type)) { KSystem.addEventListener(input, 'keypress', KInput.onEnterPressed); } if (/password/.test(this.type)) { KSystem.addEventListener(input, 'keyup', KInput.onValueChanged); } this.inputContainer.appendChild(input); this.content.appendChild(this.inputContainer); if (/checkbox|radio/.test(this.type)) { input.checked = this.options[index].selected; } if (label && this.options[0].position == 'left') { if (/checkbox|radio/.test(this.type)) { label.className += ' ' + inputStyle + 'LabelOption'; } this.content.appendChild(label); } if (label && this.options[0].labelStyle) { this.setStyle(this.options[0].labelStyle, label); } if (/select/.test(this.type)) { if (this.isMultiple) { this.inputs[0].multiple = true; } this.addOptions(input); break; } KSystem.addEventListener(input, 'focus', KInput.onFocus); KSystem.addEventListener(input, 'blur', KInput.onBlur); } for ( var listener = 0; listener != this.inputListeners.length; listener++) { this.addEventListeners(this.inputListeners[listener].event, this.inputListeners[listener].callback); } this.errorArea = window.document.createElement('div'); this.errorArea.className = 'KInputErrorArea ' + inputStyle + 'ErrorArea'; this.content.appendChild(this.errorArea); this.activate(); } KInput.onEnterPressed = function(event) { if (KForm.onEnterPressed(event)) { return true; } else { KForm.goSubmit(event); return false; } } KInput.onFocus = function(event) { if(KScroll && KScroll.activeScroll) { KScroll.disableKeys(); } } KInput.onBlur = function(event) { if(KScroll && KScroll.activeScroll) { KScroll.enableKeys(); } } KInput.onValueChanged = function(event) { var widget = KSystem.getEventWidget(event); var target = KSystem.getEventTarget(event); if (target.value.length > widget.passValue.length) { widget.passValue += target.value.replace(/\*/g, ''); } else { widget.passValue = widget.passValue.substr(0, target.value.length); } target.value = target.value.replace(/./g, '*'); } KInput.prototype.getValue = function(rawValue) { var toReturn = null; if (/checkbox|radio/.test(this.type)) { toReturn = new Array(); for ( var index in this.inputs) { if (this.inputs[index].checked) { toReturn.push(this.inputs[index].value || ''); } } } else if (/select/.test(this.type)) { if (this.isMultiple) { toReturn = new Array(); for ( var index = 0; index != this.inputs[0].options.length; index++) { if (this.inputs[0].options[index].selected) { toReturn.push(this.inputs[0].options[index].value || ''); } } } else { if (this.inputs[0].selectedIndex >= 0) { toReturn = this.inputs[0].options[this.inputs[0].selectedIndex].value || ''; } else { toReturn = this.inputs[0].options[0].value || ''; } } } else if (/password/.test(this.type)) { toReturn = (this.noEncryption || rawValue ? this.passValue : SHA1(this.passValue)); } else if (/\[\]/.test(this.inputID)) { toReturn = new Array(); for ( var index in this.inputs) { if (this.inputs[index].value && this.inputs[index].value != '') { toReturn.push(this.inputs[index].value || ''); } } } else if (/static/.test(this.type)) { toReturn = (rawValue ? this.inputs[0].innerHTML || '' : Kinky.ENTITIES || this.parent.entities ? HTMLEntities.encode(this.inputs[0].innerHTML || '') : (Kinky.URL_ENCODED ? encodeURIComponent(this.inputs[0].innerHTML || '') : this.inputs[0].innerHTML || '')); } else { toReturn = (rawValue ? this.inputs[0].value || '' : Kinky.ENTITIES || this.parent.entities ? HTMLEntities.encode(this.inputs[0].value || '') : (Kinky.URL_ENCODED ? encodeURIComponent(this.inputs[0].value || '') : this.inputs[0].value || '')); if (this.options[0].labelPosition && this.options[0].labelPosition == 'inside' && toReturn == this.options[0].label) { toReturn = ''; } } return toReturn; } KInput.prototype.setValue = function(value, index) { if (this.activated()) { if (/checkbox|radio/.test(this.type)) { for ( var index in this.inputs) { if (this.inputs[index].value == value) { this.inputs[index].checked = true; KSystem.fireEvent(this.inputs[index], 'change'); } } } else if (/select/.test(this.type)) { for ( var index = 0; index != this.inputs[0].options.length; index++) { if (this.inputs[0].options[index].value == value) { this.inputs[0].options[index].selected = true; } } KSystem.fireEvent(this.inputs[0], 'change'); } else if (/\[\]/.test(this.inputID) && index) { this.inputs[index].value = value || ''; KSystem.fireEvent(this.inputs[index], 'change'); } else if (/static/.test(this.type)) { this.inputs[0].innerHTML = value || ''; KSystem.fireEvent(this.inputs[0], 'change'); } else { this.inputs[0].value = value || ''; KSystem.fireEvent(this.inputs[0], 'change'); } } else { this.options[0].value = value || ''; } } KInput.INPUT_ELEMENT = 'inputs[0]'; KInput.INPUT_CONTAINER = 'inputContainer'; KInput.LABEL_CONTAINER = 'label'; KInput.INPUT_ERROR_CONTAINER = 'errorArea'; KCheckBox.prototype = new KInput(); KCheckBox.prototype.constructor = KCheckBox; function KCheckBox(parent, label, id, isSingle) { if (parent != null) { this.simpleWidget = true; KInput.call(this, parent, 'hidden', label, id); this.selectedOptions = {}; this.optionsContent = window.document.createElement('div'); this.optionsContent.className = ' KCheckBoxOptionsContent '; this.optionsContent.style.overflow = 'visible'; this.optionsContent.style.position = 'relative'; var selection = window.document.createElement('input'); selection.type = 'text'; selection.name = id + 'hidden'; selection.style.display = 'none'; this.content.appendChild(selection); this.inputs.push(selection); this.isSingle = isSingle; this.editable = false; this.lastElement = null; } } KCheckBox.prototype.onLoad = function(data) { this.data = data; } KCheckBox.prototype.clear = function() { this.optionsContent.innerHTML = ''; KInput.prototype.clear.call(this); } KCheckBox.prototype.addOption = function(value, caption, selected, isHTML) { this.options.push( { id : this.id + this.options.length, value : value, label : caption, selected : selected, isHTML : isHTML }); if (this.activated()) { var first = true; var selectedOptions = {}; var checkBoxItemContainer = window.document.createElement('div'); checkBoxItemContainer.className = 'KCheckBoxOption'; var check = window.document.createElement('button'); check.src = selected ? this.imageOn : this.image; check.innerHTML = ' '; check.setAttribute('type', 'button'); check.value = value; check.name = this.id; checkBoxItemContainer.appendChild(check); this.inputs.push(check); var label = window.document.createElement('label'); label.alt = value; label.name = this.id; if (isHTML) { label.innerHTML = caption; } else { label.appendChild(window.document.createTextNode(caption)); } KSystem.addEventListener(checkBoxItemContainer, 'click', KCheckBox.selectOption); KSystem.addEventListener(checkBoxItemContainer, 'mouseover', KCheckBox.mouseOver); KSystem.addEventListener(checkBoxItemContainer, 'mouseout', KCheckBox.mouseOut); checkBoxItemContainer.appendChild(label); this.optionsContent.appendChild(checkBoxItemContainer); if (selected) { this.selectedOptions[value] = value; } } return true; } KCheckBox.prototype.draw = function() { var label = this.createLabel(0); if (label) { this.content.appendChild(label); } var inputContainer = window.document.createElement('div'); inputContainer.className = 'KCheckBoxContainer'; inputContainer.appendChild(this.optionsContent); this.content.appendChild(inputContainer); { var first = true; var selectedOptions = {}; for ( var index in this.options) { var value = this.options[index].value; var caption = this.options[index].label; var selected = this.options[index].selected; if (first) { first = false; continue; } var checkBoxItemContainer = window.document.createElement('div'); checkBoxItemContainer.className = selected ? 'KCheckBoxOptionSelected' : 'KCheckBoxOption'; var check = window.document.createElement('button'); check.innerHTML = ' '; check.setAttribute('type', 'button'); check.value = value; check.name = this.id; check.alt = index; checkBoxItemContainer.appendChild(check); this.inputs.push(check); if (caption) { var label = window.document.createElement('label'); label.alt = value; label.name = this.id; if (this.options[index].isHTML) { label.innerHTML = caption; } else { label.appendChild(window.document.createTextNode(caption)); } checkBoxItemContainer.appendChild(label); } KSystem.addEventListener(check, 'click', KCheckBox.selectOption); KSystem.addEventListener(checkBoxItemContainer, 'mouseover', KCheckBox.mouseOver); KSystem.addEventListener(checkBoxItemContainer, 'mouseout', KCheckBox.mouseOut); this.optionsContent.appendChild(checkBoxItemContainer); if (this.options[index].selected) { this.lastElement = checkBoxItemContainer; this.selectedOptions[value] = value; } } } this.errorArea = window.document.createElement('div'); this.errorArea.className = 'KInputErrorArea KCheckBoxErrorArea'; this.content.appendChild(this.errorArea); for ( var listener = 0; listener != this.inputListeners.length; listener++) { this.addEventListeners(this.inputListeners[listener].event, this.inputListeners[listener].callback); } this.activate(); } KCheckBox.prototype.check = function(idx) { if (this.activated() && !this.options[idx + 1].selected) { KSystem.fireEvent(this.inputs[idx + 1], 'click'); } else { this.options[idx + 1].selected = true; } } KCheckBox.prototype.uncheck = function(idx) { if (this.activated() && this.options[idx + 1].selected) { KSystem.fireEvent(this.inputs[idx + 1], 'click'); } else { this.options[idx + 1].selected = false; } } KCheckBox.prototype.setValue = function(value, index) { if (this.activated()) { for ( var idx in this.options) { if (this.options[idx].value == value) { KSystem.fireEvent(this.inputs[idx], 'click'); return; } } } else { for ( var idx in this.options) { if (this.options[idx].value == value) { this.options[idx].selected = true; return; } } } } KCheckBox.prototype.getValue = function(rawValue) { var toReturn = new Array(); for ( var index in this.selectedOptions) { toReturn.push((rawValue ? index : Kinky.ENTITIES ? HTMLEntities.encode(index) : (Kinky.URL_ENCODED ? encodeURIComponent(index) : index))); } if (this.isSingle){ return toReturn.length == 0 ? (rawValue ? '' : null) : toReturn[0]; } return toReturn; } KCheckBox.mouseOver = function(event) { var element = KSystem.getEventTarget(event); if (element.tagName.toLowerCase() == 'label' || element.tagName.toLowerCase() == 'button') { element = element.parentNode; } if (element.className != 'KCheckBoxOptionSelected'){ element.className = 'KCheckBoxOptionOver'; } } KCheckBox.mouseOut = function(event) { var element = KSystem.getEventTarget(event); if (element.tagName.toLowerCase() == 'label' || element.tagName.toLowerCase() == 'button') { element = element.parentNode; } if (element.className != 'KCheckBoxOptionSelected'){ element.className = 'KCheckBoxOption'; } } KCheckBox.selectOption = function(event) { var element = KSystem.getEventTarget(event); var widget = KSystem.getEventWidget(event); widget.options[parseInt(element.alt)].selected = !widget.options[parseInt(element.alt)].selected; if (widget.isSingle) { var isSelected = widget.selectedOptions[element.value]; if (widget.lastElement){ widget.lastElement.className = 'KCheckBoxOption'; } widget.selectedOptions = {}; if (!isSelected) { widget.selectedOptions[element.value] = element.value; if (element.tagName.toLowerCase() == 'label' || element.tagName.toLowerCase() == 'button') { element.parentNode.className = 'KCheckBoxOptionSelected'; widget.lastElement = element.parentNode; } else{ element.className = 'KCheckBoxOptionSelected'; widget.lastElement = element; } } } else { if (widget.selectedOptions[element.value] != null) { delete widget.selectedOptions[element.value]; if (element.tagName.toLowerCase() == 'label' || element.tagName.toLowerCase() == 'button') { element.parentNode.className = 'KCheckBoxOption'; } else{ element.className = 'KCheckBoxOption'; } } else { widget.selectedOptions[element.value] = element.value; if (element.tagName.toLowerCase() == 'label' || element.tagName.toLowerCase() == 'button') { element.parentNode.className = 'KCheckBoxOptionSelected'; } else{ element.className = 'KCheckBoxOptionSelected'; } } } KSystem.fireEvent(widget.inputs[0], 'change'); } KCheckBox.updateValue = function(event) { var widget = KSystem.getEventWidget(event); widget.onKeyPressed(); } KCheckBox.OPTION_CONTAINER_DIV = 'optionsContent'; KCheckBox.SELECT_ELEMENT = 'selectedOptionText'; KCheckBox.OPENED = null; KCombo.prototype = new KInput(); KCombo.prototype.constructor = KCombo; function KCombo(parent, label, id, isHTML) { if (parent != null) { this.simpleWidget = true; KInput.call(this, parent, 'hidden', label, id, isHTML); this.optionsToggled = false; this.selectedOptionText = window.document.createElement('input'); this.selectedOptionText.type = 'text'; this.selectedOption = this.createInput(0); this.optionsPanel = window.document.createElement('div'); this.optionsPanel.className = ' ' + this.panel.className + ' KComboOptionsPanel '; this.optionsPanel.style.overflow = 'visible'; this.optionsPanel.style.position = 'absolute'; this.optionsPanel.style.left = '0'; this.optionsPanel.name = this.id; this.classPanel = window.document.createElement('div'); this.classPanel.className = ' KComboOptions_' + id.toUpperCase() + ' KComboOptions '; this.focusInput = window.document.createElement('input'); this.focusInput.style.height = '0px'; this.focusInput.style.width = '0px'; this.focusInput.style.border = '0px'; this.focusInput.style.position = 'absolute'; this.focusInput.style.top = '0'; this.focusInput.style.left = '0'; this.classPanel.appendChild(this.focusInput); this.optionsPanel.appendChild(this.classPanel); this.optionsTopMarker = window.document.createElement('div'); this.optionsTopMarker.style.position = 'relative'; this.classPanel.appendChild(this.optionsTopMarker); this.optionsContainer = window.document.createElement('div'); this.optionsContainer.className = ' KComboOptionsContainer_' + id.toUpperCase() + ' KComboOptionsContainer '; this.optionsContainer.style.overflow = 'hidden'; this.optionsContainer.style.position = 'relative'; this.classPanel.appendChild(this.optionsContainer); this.optionsContent = window.document.createElement('div'); this.optionsContent.className = ' KComboOptionsContent_' + id.toUpperCase() + ' KComboOptionsContent '; this.optionsContent.style.overflow = 'visible'; this.optionsContent.style.position = 'absolute'; this.optionsContent.style.left = '0'; this.optionsContent.style.right = '0'; this.optionsContainer.appendChild(this.optionsContent); this.optionsBottomMarker = window.document.createElement('div'); this.optionsBottomMarker.style.position = 'absolute'; this.optionsBottomMarker.style.bottom = '0'; this.optionsBottomMarker.style.clear = 'both'; this.optionsContent.appendChild(this.optionsBottomMarker); this.dropButton = window.document.createElement('button'); this.dropButton.innerHTML = ' '; this.dropButton.setAttribute('type', 'button'); KSystem.addEventListener(this.dropButton, 'click', KCombo.toggleOptions); this.editable = false; this.scrollOps = null; this.currentIndex = -1; this.currentIndexDoesntChangeSearch = false; } } KCombo.prototype.onLoad = function(data) { this.data = data; } KCombo.prototype.markNext = function() { var beginIndex = this.currentIndex; var childOptions = this.optionsContent.childNodes; for ( var index = beginIndex + 1; index < childOptions.length; index++) { if (childOptions[index].className && /KComboOption/.test(childOptions[index].className) && childOptions[index].style.display != 'none') { if (this.currentIndex >= 0) { this.removeCSSClass('KComboOptionOver', childOptions[this.currentIndex]); } this.currentIndex = parseInt(childOptions[index].alt) - 1; KCombo.selectOption(null, childOptions[index].childNodes[0], this, true); this.addCSSClass('KComboOptionOver', childOptions[index]); return; } } } KCombo.prototype.markPrevious = function() { var beginIndex = this.currentIndex; var childOptions = this.optionsContent.childNodes; for ( var index = beginIndex - 1; index > -1; index--) { if (childOptions[index].className && /KComboOption/.test(childOptions[index].className) && childOptions[index].style.display != 'none') { if (this.currentIndex >= 0) { this.removeCSSClass('KComboOptionOver', childOptions[this.currentIndex]); } this.currentIndex = parseInt(childOptions[index].alt) - 1; KCombo.selectOption(null, childOptions[index].childNodes[0], this, true); this.addCSSClass('KComboOptionOver', childOptions[index]); return; } } } KCombo.prototype.onKeyPressed = function(keyCode) { if (keyCode == 40) { if (!this.optionsToggled) { KCombo.toggleOptions(null, this); } this.markNext(); } else if (keyCode == 38) { if (!this.optionsToggled) { KCombo.toggleOptions(null, this); } this.markPrevious(); } else { this.selectedOption.value = this.selectedOptionText.value; } } KCombo.prototype.clearOptions = function(justOptions) { this.options.splice(1, this.options.length - 1); this.currentIndex = -1; if (this.activated()) { this.optionsContent.innerHTML = ''; this.selectedOption.value = ''; if (!justOptions) { this.selectedOptionText.value = ''; } } } KCombo.prototype.addOption = function(value, caption, selected, isHTML) { this.options.push({ id : this.id + this.options.length, value : value, label : caption || value, selected : selected, isHTML : isHTML }); if (this.activated()) { this.appendOption(value, caption, selected, isHTML, this.options.length - 1); } return true; } KCombo.prototype.appendOption = function(value, caption, selected, isHTML, index) { var first = true; var selectedOptions = {}; var labelContainer = window.document.createElement('div'); labelContainer.className = 'KComboOption'; labelContainer.alt = index; if (this.isMultiple) { var check = window.document.createElement('input'); check.type = 'checkbox' check.alt = HTML.stripTags(caption); check.value = value; check.name = this.id; this.options[index].check = check; labelContainer.appendChild(check); } var label = window.document.createElement('label'); label.alt = value; label.name = this.id; if (isHTML) { label.innerHTML = caption; } else { label.appendChild(window.document.createTextNode(caption)); } if (!this.isMultiple) { KSystem.addEventListener(labelContainer, 'click', KCombo.toggleOptions); } KSystem.addEventListener(labelContainer, 'click', KCombo.selectOption); KSystem.addEventListener(labelContainer, 'mouseover', KCombo.mouseOver); KSystem.addEventListener(labelContainer, 'mouseout', KCombo.mouseOut); labelContainer.appendChild(label); this.optionsContent.appendChild(labelContainer); this.optionsContent.appendChild(this.optionsBottomMarker); if (selected) { if (this.isMultiple) { var obj = null; eval('obj = ' + (this.selectedOption.value != '' ? this.selectedOption.value : '{}') + ';'); obj[value] = value; this.selectedOption.value = JSON.stringify(obj); check.checked = true; this.selectedOptionText.value += HTML.stripTags(caption) + ', '; } else { this.selectedOption.value = value; this.selectedOptionText.value = HTML.stripTags(caption); } } } KCombo.prototype.draw = function() { var inputContainer = window.document.createElement('div'); inputContainer.className = 'KComboContainer'; if (!this.editable || this.isMultiple) { this.selectedOptionText.setAttribute('readonly', 'readonly'); } else { KSystem.addEventListener(this.selectedOptionText, 'keyup', KCombo.updateValue); } this.selectedOptionText.className = 'KComboSelectedValue'; inputContainer.appendChild(this.selectedOptionText); this.inputs.push(this.selectedOptionText); inputContainer.appendChild(this.selectedOption); if (this.dropButton) { inputContainer.appendChild(this.dropButton); } var label = this.createLabel(0); if (label) { this.content.appendChild(label); } this.content.appendChild(inputContainer); { var first = true; for ( var index in this.options) { var value = this.options[index].value; var caption = this.options[index].label; if (first) { first = false; continue; } this.appendOption(value, caption, this.options[index].selected, this.options[index].isHTML, index); } if (this.isMultiple) { this.selectedOption.value = (this.selectedOption.value != '' ? this.selectedOption.value : '{}'); } } this.errorArea = window.document.createElement('div'); this.errorArea.className = 'KInputErrorArea KComboErrorArea'; this.content.appendChild(this.errorArea); KSystem.addEventListener(this.selectedOptionText, 'focus', function(event) { KScroll.disableKeys(); }); KSystem.addEventListener(this.selectedOptionText, 'blur', function(event) { var widget = KSystem.getEventWidget(event); if (widget.noButton) { KSystem.addTimer(function() { if (widget.optionsToggled) { KCombo.toggleOptions(null, widget); } }, 150); } KScroll.enableKeys(); }); this.activate(); if (this.scrollOps || KCombo.SCROLL_OPS) { this.addScroll(KScroll.VSCROLL, this.scrollOps || KCombo.SCROLL_OPS, KCombo.OPTIONS_CONTENT_DIV, KCombo.OPTIONS_CONTAINER_DIV, KCombo.OPTIONS_DIV); } else { this.optionsPanel.style.overflow = 'auto'; this.optionsContainer.style.overflow = 'visible'; this.optionsContent.style.position = 'relative'; } } KCombo.prototype.setStyle = function(cssStyle, target) { if (target) { if (target instanceof Array) { for ( var index in target) { if (typeof target[index] == 'string' && target[index] == KCombo.OPTIONS_DIV && (cssStyle.height || cssStyle.width)) { KInput.prototype.setStyle.call(this, { width : cssStyle.width, height : cssStyle.height }, [ 'classPanel', 'optionsContainer' ]); break; } } } else if (typeof target == 'string' && target == KCombo.OPTIONS_DIV && (cssStyle.height || cssStyle.width)) { KInput.prototype.setStyle.call(this, { width : cssStyle.width, height : cssStyle.height }, [ 'classPanel', 'optionsContainer' ]); } } KInput.prototype.setStyle.call(this, cssStyle, target); } KCombo.prototype.getHeight = function(options) { if (options) { var begin = this.optionsTopMarker.offsetTop; var end = this.optionsBottomMarker.offsetTop; var dynamicHeight = (end) - begin; return dynamicHeight; } else { return KWidget.prototype.getHeight.call(this); } } KCombo.prototype.getValue = function(rawValue) { if (this.editable && this.selectedOption.value == '' && this.selectedOptionText.value != '') { return (rawValue ? this.selectedOptionText.value : Kinky.ENTITIES ? HTMLEntities.encode(this.selectedOptionText.value) : (Kinky.URL_ENCODED ? encodeURIComponent(this.selectedOptionText.value) : this.selectedOptionText.value)); } if (this.isMultiple) { var obj = null; eval('obj = ' + this.selectedOption.value + ';'); var toReturn = new Array(); for ( var index in obj) { toReturn.push((rawValue ? index : Kinky.ENTITIES ? HTMLEntities.encode(index) : (Kinky.URL_ENCODED ? encodeURIComponent(index) : index))); } return toReturn; } return (rawValue ? this.selectedOption.value : Kinky.ENTITIES ? HTMLEntities.encode(this.selectedOption.value) : (Kinky.URL_ENCODED ? encodeURIComponent(this.selectedOption.value) : this.selectedOption.value)); } KCombo.prototype.setValue = function(value, index) { if (this.activated()) { if (this.isMultiple) { if (!value) { this.selectedOptionText.value = ''; this.selectedOption.value = '{}'; for ( var idx in this.options) { if (this.options[idx].check) { this.options[idx].check.checked = false; } } return; } var obj = null; eval('obj = ' + (this.selectedOption.value != '' ? this.selectedOption.value : '{}') + ';'); for ( var idx in this.options) { if (this.options[idx].value == value) { obj[value] = value; this.selectedOptionText.value += HTML.stripTags(this.options[idx].label) + ', '; this.options[idx].selected = true; this.options[idx].check.checked = true; this.selectedOption.value = JSON.stringify(obj); KSystem.fireEvent(this.selectedOptionText, 'change'); return; } } } else { this.selectedOption.value = value || ''; if (value != null) { for ( var idx in this.options) { if (this.options[idx].value == value) { this.selectedOptionText.value = HTML.stripTags(this.options[idx].label) this.options[idx].selected = true; KSystem.fireEvent(this.selectedOptionText, 'change'); return; } } } this.selectedOptionText.value = value || ''; } KSystem.fireEvent(this.selectedOptionText, 'change'); } else { for ( var idx in this.options) { if (this.options[idx].value == value) { this.options[idx].selected = true; return; } } } } KCombo.mouseOver = function(event) { var element = KSystem.getEventTarget(event); var widget = KCombo.getEventWidget(event); while (element.tagName.toLowerCase() != 'div' || !/KComboOption/.test(element.className)) { element = element.parentNode; } element.className = 'KComboOptionOver'; } KCombo.mouseOut = function(event) { var element = KSystem.getEventTarget(event); while (element.tagName.toLowerCase() != 'div' || !/KComboOption/.test(element.className)) { element = element.parentNode; } element.className = 'KComboOption'; } KCombo.selectOption = function(event, element, widget, noChange) { if (!element) { element = KSystem.getEventTarget(event); widget = KCombo.getEventWidget(event); } element = KCombo.getLabel(element); if (element.alt != null && element.alt != '') { if (widget.isMultiple) { element = element.previousSibling; element.checked = !element.checked; var obj = null; eval('obj = ' + widget.selectedOption.value + ';'); if (element.checked) { obj[element.value] = element.value; if (!widget.currentIndexDoesntChangeSearch) { widget.selectedOptionText.value += HTML.stripTags(HTMLEntities.decode(element.alt)) + ', '; } } else { delete obj[element.value]; if (!widget.currentIndexDoesntChangeSearch) { widget.selectedOptionText.value = widget.selectedOptionText.value.replace(HTML.stripTags(HTMLEntities.decode(element.alt)) + ', ', ''); } } widget.selectedOption.value = JSON.stringify(obj); } else { widget.selectedOption.value = element.alt; if (!widget.currentIndexDoesntChangeSearch) { widget.selectedOptionText.value = HTML.stripTags(HTMLEntities.decode(element.innerHTML)); } } } else { widget.selectedOption.value = ''; widget.selectedOptionText.value = ''; } if (!noChange) { widget.currentIndex = -1; KSystem.fireEvent(widget.selectedOption, 'change'); KSystem.fireEvent(widget.selectedOptionText, 'change'); KSystem.fireEvent(widget.panel, 'change'); } } KCombo.getLabel = function(element) { while (element.tagName.toLowerCase() != 'label') { element = element.parentNode; } return element; } KCombo.updateValue = function(event) { var keyEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(event); widget.onKeyPressed(keyEvent.keyCode); } KCombo.getEventWidget = function(event) { var widget = null; var element = KSystem.getEventTarget(event); if (element.tagName.toLowerCase() == 'button') { widget = KSystem.getEventWidget(event); } else { do { widget = Kinky.getWidget(element.name); element = element.parentNode; } while (element && !widget); } return widget; } KCombo.toggleOptions = function(event, widget) { if (!widget) { widget = KCombo.getEventWidget(event); } widget.setStyle({ top : (widget.offsetTop()) + 'px', left : widget.offsetLeft() + 'px' }, KCombo.OPTIONS_DIV); if (KCombo.OPENED && widget.id != KCombo.OPENED.id) { window.document.body.removeChild(KCombo.OPENED.optionsPanel); KCombo.OPENED.optionsToggled = false; KCombo.OPENED = null; if (widget.scroll) { if (KScroll.activeScroll && KScroll.activeScroll.parent.id == widget.id) { KScroll.activeScroll = null; } } } if (widget.optionsToggled) { window.document.body.removeChild(widget.optionsPanel); widget.optionsToggled = false; KCombo.OPENED = null; if (widget.scroll) { if (KScroll.activeScroll && KScroll.activeScroll.parent.id == widget.id) { KScroll.activeScroll = null; } } } else { window.document.body.appendChild(widget.optionsPanel); widget.optionsToggled = true; KSystem.addEventListener(widget.focusInput, 'keyup', KCombo.activateKeyLogger); widget.focusInput.focus(); KCombo.OPENED = widget; } } KCombo.activateKeyLogger = function(e) { var letra = String.fromCharCode(e.keyCode); if (letra){ var target = KSystem.getEventTarget(e); var labelsToCheck = target.parentNode.getElementsByTagName('label'); for (var index in labelsToCheck){ if (labelsToCheck[index].innerHTML.slice(0,1) == letra){ labelsToCheck[index].scrollIntoView(true); break; } } } } KCombo.OPTIONS_DIV = 'optionsPanel'; KCombo.OPTIONS_CONTENT_DIV = 'optionsContent'; KCombo.OPTIONS_CONTAINER_DIV = 'optionsContainer'; KCombo.SELECT_ELEMENT = 'selectedOptionText'; KCombo.OPENED = null; KCombo.SCROLL_OPS = null; KCombo.clickOut = function() { KSystem.addEventListener(window.document.body, 'click', function(event) { var mouseEvent = KSystem.getEvent(event); Kinky.BROWSER_CLICK = { x : mouseEvent.clientX, y : mouseEvent.clientY }; var widget = null; try { widget = KSystem.getEventWidget(event); if (widget instanceof KScroll && widget.parent instanceof KCombo && widget.parent.id == KCombo.OPENED.id) { return; } } catch (e) { try { var element = KSystem.getEventTarget(event); if (element.tagName.toLowerCase() != 'label' && element.tagName.toLowerCase() != 'input') { if (element.childNodes.length != 0) { element = element.childNodes[0]; } } widget = Kinky.getWidget(element.name); } catch (e) { } } if (KCombo.OPENED && (!widget || (widget && widget.id != KCombo.OPENED.id))) { window.document.body.removeChild(KCombo.OPENED.optionsPanel); KCombo.OPENED.optionsToggled = false; if (KCombo.OPENED) { if (KScroll.activeScroll && KScroll.activeScroll.parent.id == KCombo.OPENED.id) { KScroll.activeScroll = null; } } KCombo.OPENED = null; } }); } if (window.attachEvent) { window.attachEvent('onload', KCombo.clickOut); } else { window.addEventListener('load', KCombo.clickOut, false); } KDate.prototype = new KInput(); KDate.prototype.constructor = KDate; function KDate(parent, label, id) { KInput.call(this, parent, 'hidden', label, id); this.panel.className += ' KDatePanel'; this.htmlValue = null; this.validationIndex = -1; this.hasHour = false; this.defaultErrorMessage = null; } KDate.prototype.getErrorMessage = function(index) { if (index == -1) { return this.defaultErrorMessage || 'data inv\u00e1lida'; } return this.validations[index].message; } KDate.prototype.validate = function(){ var regexValidation = KInput.prototype.validate.call(this); if (regexValidation != true) { return regexValidation; } if (this.day.value == 'dd' && this.month.value == 'mm' && this.year.value == 'aaaa') { return true; } var date = new Date(1900, this.month.value, 1); //var day = parseInt(this.day.value); if (this.day.value.charAt(0) == 0){ var day = parseInt(this.day.value.charAt(1)); }else{ var day = parseInt(this.day.value); } // var month = date.getMonth() || this.month.value; alert(this.month.value.charAt(0)); if (this.month.value.charAt(0) == 0){ var month = parseInt(this.month.value.charAt(1)); }else{ var month = parseInt(this.month.value); } if (!month || month < 1 || month > 12) { this.addCSSClass('KInputError'); return this.defaultErrorMessage || 'data inv\u00e1lida'; } if (!(/\d{4}/.test(this.year.value))) { this.addCSSClass('KInputError'); return this.defaultErrorMessage || 'data inv\u00e1lida'; } var availableDays = KDate.getDaysInMonth(month - 1, parseInt(this.year.value)); if (!day || !(day < (availableDays + 1))) { this.addCSSClass('KInputError'); return this.defaultErrorMessage || 'data inv\u00e1lida'; } if (this.hasHours) { var hour = parseInt(this.hour.value); if (!hour || isNaN(hour) || hour < 0 || hour > 23) { this.addCSSClass('KInputError'); return this.defaultErrorMessage || 'hora inv\u00e1lida'; } var minute = parseInt(this.minute.value); if (!minute || isNaN(minute) || minute < 0 || minute > 59) { this.addCSSClass('KInputError'); return this.defaultErrorMessage || 'minutos inv\u00e1lidos'; } } this.removeCSSClass('KInputError'); this.errorArea.innerHTML = ''; return true; } KDate.prototype.draw = function(){ KInput.prototype.draw.call(this); this.day = window.document.createElement('input'); this.day.className += ' ' + this.className + 'Day '; this.day.name = 'day'; this.day.maxLength = 2; if (this.data && this.data.day) { this.day.value = this.data.day; } else { this.day.value = 'dd'; } KSystem.addEventListener(this.day, 'focus', KDate.labelFocus); KSystem.addEventListener(this.day, 'blur', KDate.labelBlur); this.day.alt = 'dd'; this.inputs.push(this.day); this.content.insertBefore(this.day, this.errorArea); this.content.insertBefore(window.document.createElement('span'), this.errorArea).appendChild(window.document.createTextNode('-')); this.month = window.document.createElement('input'); this.month.className += ' ' + this.className + 'Month '; this.month.name = 'month'; this.month.maxLength = 2; if (this.data && this.data.month) { this.month.value = this.data.month; } else { this.month.value = 'mm'; } KSystem.addEventListener(this.month, 'focus', KDate.labelFocus); KSystem.addEventListener(this.month, 'blur', KDate.labelBlur); this.month.alt = 'mm'; this.inputs.push(this.month); this.content.insertBefore(this.month, this.errorArea); this.content.insertBefore(window.document.createElement('span'), this.errorArea).appendChild(window.document.createTextNode('-')); this.year = window.document.createElement('input'); this.year.className += ' ' + this.className + 'Year '; this.year.name = 'year'; this.year.maxLength = 4; if (this.data && this.data.year) { this.year.value = this.data.year; } else { this.year.value = 'aaaa'; } KSystem.addEventListener(this.year, 'focus', KDate.labelFocus); KSystem.addEventListener(this.year, 'blur', KDate.labelBlur); this.year.alt = 'aaaa'; this.inputs.push(this.year); this.content.insertBefore(this.year, this.errorArea); if (this.hasHour) { this.hour = window.document.createElement('input'); this.hour.className += ' ' + this.className + 'Hour '; this.hour.name = 'hour'; if (this.data && this.data.hour) { this.hour.value = this.data.hour; } else { this.hour.value = 'hh'; } KSystem.addEventListener(this.hour, 'focus', KDate.labelFocus); KSystem.addEventListener(this.hour, 'blur', KDate.labelBlur); this.hour.alt = 'hh'; this.inputs.push(this.hour); this.content.insertBefore(this.hour, this.errorArea); this.content.insertBefore(window.document.createElement('span'), this.errorArea).appendChild(window.document.createTextNode('h')); this.minute = window.document.createElement('input'); this.minute.className += ' ' + this.className + 'Minute '; this.minute.name = 'minute'; if (this.data && this.data.minute) { this.minute.value = this.data.minute; } else { this.minute.value = 'mm'; } KSystem.addEventListener(this.minute, 'focus', KDate.labelFocus); KSystem.addEventListener(this.minute, 'blur', KDate.labelBlur); this.minute.alt = 'mm'; this.inputs.push(this.minute); this.content.insertBefore(this.minute, this.errorArea); } for ( var listener = 0; listener != this.inputListeners.length; listener++) { for ( var index = 1; index != this.inputs.length; index++) { KSystem.addEventListener(this.inputs[index], this.inputListeners[listener].event, this.inputListeners[listener].callback); } } } KDate.prototype.getValue = function(){ if (this.day.value != '' && this.month.value != '' && this.year.value != '' && this.day.value != 'dd' && this.month.value != 'mm' && this.year.value != 'aaaa'){ return this.year.value + '-' + this.month.value + '-' + this.day.value + (this.hasHour ? ' ' + this.hour.value + ':' + this.minute.value + ':00' : ''); } else { return ''; } } KDate.prototype.setValue = function(value){ if (!value || value == '') { if (this.activated()) { this.day.value = 'dd'; this.month.value = 'mm'; this.year.value = 'aaaa'; if (this.hasHour) { this.hour.value = 'hh'; this.minute.value = 'mm'; } } return; } if (typeof value == 'string') { if (!this.hasHour) { value = value.split(' ')[0]; } value = value.replace(/-/g, "/").replace(/h/g, ':') + (this.hasHour ? ':00' : ''); value = new Date(Date.parse(value)); } this.data = this.data || new Object(); if (value != '') { this.data.day = value.getDate(); this.data.month = value.getMonth() + 1; this.data.year = value.getFullYear(); if (this.hasHour) { this.data.hour = value.getHours(); this.data.minute = value.getMinutes(); } if (this.activated()) { this.day.value = this.data.day; this.month.value = this.data.month; this.year.value = this.data.year; if (this.hasHour) { this.hour.value = this.data.hour; this.minute.value = this.data.minute; } } } } KDate.labelFocus = function(event) { var target = KSystem.getEventTarget(event); if (target.value == null || isNaN(parseInt(target.value))) { target.value = ''; } } KDate.labelBlur = function(event) { var target = KSystem.getEventTarget(event); if (target.value == null || target.value == '') { target.value = target.alt; } } KDate.getDaysInMonth = function(month, year){ var m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if (month != 1) { return m[month]; } if (year % 4 != 0) { return m[1]; } if (year % 100 == 0 && year % 400 != 0) { return m[1]; } return m[1] + 1; } KFile.prototype = new KInput(); KFile.prototype.constructor = KFile; function KFile(parent, caption, id) { if (parent != null) { KInput.call(this, parent, 'hidden', null, id); this.fileListContainer = null; this.maxFile = 1; this.noPrompt = true; this.fileListContainer = window.document.createElement('div'); this.fileListContainer.className = 'KFileListContainer'; this.fileListContainer.id = 'container' + this.id; this.inputContainer = window.document.createElement('div'); this.inputContainer.className = 'KFileContainer'; this.iframe = this.createIframe(); this.inputContainer.appendChild(this.iframe); KCSS.setStyle( { overflow : 'hidden', opacity : '0', position : 'absolute', cursor : 'pointer', top : '0', left : '0' }, [ this.inputContainer, this.iframe ]); this.button = window.document.createElement('button'); this.button.setAttribute('type', 'button'); this.button.className = 'KFileButton'; this.button.innerHTML = caption; KCSS.setStyle( { position : 'absolute', top : '0', left : '0' }, [ this.button ]); this.errorArea = window.document.createElement('div'); this.errorArea.className = 'KInputErrorArea KFileErrorArea'; } } KFile.prototype.onLoad = function(data) { this.data = data; this.draw(); } KFile.prototype.addEventListener = function(eventName, callback, target) { if ((!target || target == KWidget.ROOT_DIV) && eventName == 'change') { KSystem.addEventListener(this.button, 'click', callback); } else { KInput.prototype.addEventListener.call(this, eventName, callback, target); } } KFile.prototype.showErrorMessage = function(params) { if (!params || !params.tooltip) { KInput.prototype.showErrorMessage.call(this, params); } else if (params && params.tooltip) { KSystem.addEventListener(this.inputContainer, 'mouseover', KFile.onMouseOver); } } KFile.onMouseOver = function(event) { var mouseEvent = KSystem.getEvent(event); var widget = KSystem.getEventWidget(mouseEvent); KTooltip.showTooltip(widget.inputContainer, { text : '* ' + (widget.validationIndex ? widget.getErrorMessage(widget.validationIndex) : ''), isHTML : true, offsetX : 0, offsetY : 15, left : KSystem.mouseX(mouseEvent), top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'KInputTooltip' }); } KFile.prototype.setLabel = function(label) { this.options[0].label = label; } KFile.prototype.createIframe = function() { var toReturn = window.document.createElement('iframe'); toReturn.className = 'KFileIFrame'; toReturn.frameBorder = 0; toReturn.style.overflow = 'hidden'; toReturn.setAttribute('scrolling', 'no'); return toReturn; } KFile.prototype.createLabel = function() { var inputStyle = 'K' + this.type.toUpperCase().charAt(0) + this.type.substring(1); var labelContainer = window.document.createElement('div'); labelContainer.className = 'KLabelContainer'; var label = window.document.createElement('label'); label.setAttribute('for', this.options[0].id); label.className = 'KLabel ' + inputStyle + 'Label'; label.appendChild(window.document.createTextNode(this.options[0].label)); labelContainer.appendChild(label); return labelContainer; } KFile.prototype.draw = function() { this.iframe.src = Kinky.BASE_JS_URL + "fileManager.php?id=" + this.id + '&maxFile=' + this.maxFile + '&tmp=' + encodeURIComponent(Kinky.BASE_TEMP_DIR) + '&prompt=' + (!this.noPrompt) + '&simpleWidget=' + this.simpleWidget; var label = this.createLabel(); this.content.appendChild(label); this.content.appendChild(this.fileListContainer); this.content.appendChild(this.button); this.content.appendChild(this.inputContainer); this.content.appendChild(this.errorArea); KSystem.addEventListener(this.inputContainer, 'mouseover', function(event) { var widget = KSystem.getEventWidget(event); widget.addCSSClass('KFileButtonOver', widget.button); }); KSystem.addEventListener(this.inputContainer, 'mouseout', function(event) { var widget = KSystem.getEventWidget(event); widget.removeCSSClass('KFileButtonOver', widget.button); }); } KFile.prototype.setSize = function(width, height) { KCSS.setStyle( { width : width + 'px', height : height + 'px' }, [ this.panel, this.content, this.button, this.inputContainer, this.iframe ]); } KFile.prototype.setButtonSize = function(width, height) { KCSS.setStyle( { width : width + 'px', height : height + 'px' }, [ this.button, this.inputContainer, this.iframe ]); } KFile.prototype.getFileName = function() { var toReturn = new Array(); var labels = this.fileListContainer.getElementsByTagName('label'); for ( var label = 0; label != labels.length; label++) { toReturn.push(labels[label].innerHTML); } return toReturn; } KFile.prototype.getValue = function() { var toReturn = new Array(); var inputs = this.fileListContainer.getElementsByTagName('input'); for ( var input = 0; input != inputs.length; input++) { toReturn.push(inputs[input].value); } return toReturn; } KFile.prototype.setValue = function(value) { if (value) { var newFileContainer = window.document.createElement('div'); var newFileLabel = window.document.createElement('label'); newFileLabel.appendChild(window.document.createTextNode(fileName)); newFileContainer.appendChild(newFileLabel); var newFile = window.document.createElement('input'); newFile.type = 'hidden'; newFile.name = parentID + '[]'; newFile.id = parentID + '_' + KFileManager.counter; newFile.value = filePath; newFileContainer.appendChild(newFile); var newFileRemove = window.document.createElement('button'); newFileRemove.setAttribute('type', 'button'); newFileRemove.appendChild(window.document.createTextNode('x')); newFileContainer.appendChild(newFileRemove); if (window.attachEvent) { newFileRemove.attachEvent('onclick', function(event) { var target = null; event = (event == null ? window.event : event); if (event.target) { target = event.target; } else if (event.srcElement) { target = event.srcElement; } target.parentNode.parentNode.removeChild(target.parentNode); var element = parent.parentNode.parentNode; var eventName = 'change'; var evt = window.document.createEventObject(); return element.fireEvent('on' + eventName, evt); }); } else { newFileRemove.addEventListener('click', function(event) { var target = null; event = (event == null ? window.event : event); if (event.target) { target = event.target; } else if (event.srcElement) { target = event.srcElement; } target.parentNode.parentNode.removeChild(target.parentNode); var element = parent.parentNode.parentNode; var eventName = 'change'; var evt = document.createEvent("HTMLEvents"); evt.initEvent(eventName, true, true); element.dispatchEvent(evt); }, false); } this.fileListContainer.appendChild(newFileContainer); } else { this.fileListContainer.innerHTML = ''; } } KFile.prototype.getFileInput = function() { var doc = this.iframe.contentDocument || this.iframe.document; var inputs = doc.getElementsByTagName('input'); for ( var i = 0; i != inputs.length; i++) { if (inputs[i].type == 'file') { return inputs[i]; } } } KFile.BUTTON_ELEMENT = 'button'; /** * @author pfigueiredo */ KSelect.prototype = new KInput; KSelect.prototype.constructor = KSelect; function KSelect(parent, id) { KInput.call(this, parent, id, 'select'); this.isMultiple = false; this.panel.className += ' KSelectPanel'; } KSelect.prototype.onData = function() { for (var i = 0; i != this.data.option.length; i++) { this.addValue(this.data.option[i].value, this.data.option[i].label, false); } } KSelect.prototype.setMultiple = function(isMultiple) { if (isMultiple) { this.input.setAttribute('multiple', 'multiple'); } else { if (this.input.getAttribute('multiple') == 'multiple') { this.input.removeAttribute('multiple'); } } this.isMultiple = isMultiple; } KSelect.prototype.getValue = function() { if (this.isMultiple) { var toReturn = new Array(); for (var i = 0; i != this.input.options.length; i++) { if (this.input.options[i].selected) { toReturn.push(this.input.options[i].value); } } return toReturn; } return this.input.options[this.input.selectedIndex].value; } KSelect.prototype.addValue = function(value, text, selected) { var newOption = window.document.createElement('option'); newOption.value = value; newOption.selected = selected; newOption.text = text; this.input.appendChild(newOption); } /** * @author pfigueiredo */ KTextArea.prototype = new KInput; KTextArea.prototype.constructor = KTextArea; function KTextArea(parent, id) { KInput.call(this, parent, id, 'textarea'); this.panel.className += ' KTextAreaPanel'; } KTextArea.prototype.getValue = function() { return this.input.value; } KTextArea.prototype.setValue = function(value) { this.input.value = value; } KAutoCompletion.prototype = new KCombo(); KAutoCompletion.prototype.constructor = KAutoCompletion; function KAutoCompletion(parent, label, id, callback) { if (parent) { KCombo.call(this, parent, label, id); this.editable = true; this.staticInput = true; this.resultsArrived = true; this.changeCallback = callback || KAutoCompletion.dropResults; this.keypressInterval = 0; this.keypressTimer = null; this.keypressInitialCount = 0; this.onEnterPressed = false; this.noButton = true; this.addActionListener(KAutoCompletion.actions, [ '/no-content' ]); } } KAutoCompletion.prototype.setKeypressInterval = function(interval) { this.keypressInterval = interval; } KAutoCompletion.prototype.setSearchOnEnterPressed = function(onEnterPressed) { this.onEnterPressed = onEnterPressed; } KAutoCompletion.prototype.setSearchParams = function(params) { this.searchParams = params; } KAutoCompletion.prototype.setGoButton = function(button) { this.noButton = !button; } KAutoCompletion.prototype.releaseSearchInput = function() { if (this.searchParams) { this.selectedOptionText.disabled = false; } this.resultsArrived = true; } KAutoCompletion.prototype.blockSearchInput = function() { if (this.searchParams) { this.selectedOptionText.disabled = true; } this.resultsArrived = false; } KAutoCompletion.prototype.onShow = function() { if (KCombo.prototype.onShow.call(this) && this.keypressInterval != 0) { this.keypressTimer = KSystem.addTimer('KAutoCompletion.onTimedKeyPress(Kinky.getWidget(\'' + this.id + '\'))', this.keypressInterval); return true; } return false; } KAutoCompletion.prototype.onHide = function() { if (!KCombo.prototype.onHide.call(this) && this.keypressInterval != 0) { KSystem.removeTimer(this.keypressTimer); this.searchTerm = null; this.selectedOption.value = ''; this.keypressTimer = null; } } KAutoCompletion.prototype.draw = function() { if (this.noButton) { delete this.dropButton; } else { KSystem.removeEventListener(this.dropButton, 'click', KCombo.toggleOptions); KSystem.addEventListener(this.dropButton, 'click', KAutoCompletion.sendSearch); } KSystem.addEventListener(this.selectedOptionText, 'dblclick', function(event) { var widget = KSystem.getEventWidget(event); widget.onKeyPressed(27); }); KCombo.prototype.draw.call(this); } KAutoCompletion.prototype.onKeyPressed = function(keyCode) { if (this.resultsArrived && this.changeCallback) { switch (keyCode) { case 40: { if (!this.optionsToggled) { KCombo.toggleOptions(null, this); } this.markNext(); this.releaseSearchInput(); break; } case 38 : { if (!this.optionsToggled) { KCombo.toggleOptions(null, this); } this.markPrevious(); this.releaseSearchInput(); break; } case 13: { if (this.onEnterPressed && this.searchParams) { this.blockSearchInput(); this.execCallback(this.selectedOptionText.value); } else { if (this.keypressInterval == 0) { this.blockSearchInput(); if (this.selectedOptionText.value.length >= this.keypressInitialCount) { this.searchTerm = this.selectedOptionText.value; this.execCallback(this.selectedOptionText.value); } else { this.releaseSearchInput(); } KCombo.toggleOptions(null, this); } } break; } case 27 : { this.selectedOption.value = ''; this.selectedOptionText.value = ''; this.releaseSearchInput(); this.selectedOptionText.blur(); if (!this.onEnterPressed) { this.execCallback(this.selectedOptionText.value); } break; } default : { if (this.onEnterPressed && this.searchParams) { this.selectedOption.value = ''; } else { if (this.keypressInterval == 0) { this.blockSearchInput(); if (this.selectedOptionText.value.length >= this.keypressInitialCount) { this.searchTerm = this.selectedOptionText.value; this.execCallback(this.selectedOptionText.value); } else { this.releaseSearchInput(); } } } } } } } KAutoCompletion.prototype.execCallback = function(search) { if (search == null || (this.options[0] && this.options[0].labelPosition == 'inside' && search == this.options[0].label)) { if (!this.sendEmptySearch) { this.releaseSearchInput(); return; } else { search = ' '; } } this.changeCallback(this, search); } KAutoCompletion.onTimedKeyPress = function(widget) { if (widget.selectedOptionText.value.length > widget.keypressInitialCount && widget.searchTerm != widget.selectedOptionText.value) { widget.blockSearchInput(); widget.searchTerm = widget.selectedOptionText.value; widget.execCallback(widget.selectedOptionText.value); } widget.keypressTimer = KSystem.addTimer('KAutoCompletion.onTimedKeyPress(Kinky.getWidget(\'' + widget.id + '\'))', widget.keypressInterval); } KAutoCompletion.sendSearch = function(event) { var widget = KSystem.getEventWidget(event); if (widget.selectedOptionText.value != '') { widget.blockSearchInput(); widget.execCallback(widget.selectedOptionText.value); } else if (widget.sendEmptySearch) { widget.blockSearchInput(); widget.execCallback(' '); } } KAutoCompletion.dropResults = function(widget, search) { if (widget.searchParams) { widget.searchServer(search); } else { widget.searchOptions(search); } } KAutoCompletion.prototype.searchServer = function(search) { this.searchParams.contentID = '%' + search.toUpperCase() + '%'; this.searchParams.operator = 'LIKE' this.kinky.get(this, this.searchParams.feService, this.searchParams, 'onChange'); } KAutoCompletion.prototype.searchOptions = function(search) { this.currentIndex = -1; this.selectedOption.value = ''; var regexp = new RegExp((search.length != 0 ? '' + search.replace(/ /g, '(.*)') + '' : '.'), 'im'); var options = this.optionsContent.getElementsByTagName('label'); var hasResult = false; for ( var index = 0; index != options.length; index++) { if (regexp.test(HTMLEntities.decode(options[index].innerHTML))) { options[index].parentNode.style.display = 'block'; hasResult = true; } else { options[index].parentNode.style.display = 'none'; } } this.releaseSearchInput(); if (!this.optionsToggled && search.length != 0 && hasResult) { KCombo.toggleOptions(null, this); } else if (this.optionsToggled && !hasResult) { KCombo.toggleOptions(null, this); } } KAutoCompletion.prototype.onChange = function(data) { this.clearOptions(true); for ( var index in data) { var value = null; var caption = null; var first = true; for ( var att in data[index]) { if (first) { value = data[index][att]; first = false; } else { caption = data[index][att]; break; } } this.addOption(value, caption, false, false); } this.releaseSearchInput(); if (!this.optionsToggled) { KCombo.toggleOptions(null, this); } } KAutoCompletion.actions = function(widget, action) { widget.releaseSearchInput(); widget.optionsContent.innerHTML = ''; widget.options.splice(1, widget.options.length - 1); widget.setValue(''); } /** * @author pfigueiredo */ KMap.prototype = new KInput(); KMap.prototype.constructor = KMap; function KMap(parent, label, id) { if (parent) { KInput.call(this, parent, 'hidden', label, id + '[]'); this.addActionListener(KMap.removeMarker, [ '/remover-marcador/*' ]); this.addLocationListener(KMap.loadUnload); this.panel.className += ' KMapPanel'; this.map = null; this.initialZoom = 13; this.draggableMarkers = false; this.oneMarkerMode = false; this.maxMarkers = 1; this.maxMarkersMessage = 'J\u00e1 seleccionou o m\u00e1ximo de pontos permitidos.'; this.mapMarkers = {}; this.mapMarkersCount = 0; this.mapMarkersIndex = 0; this.showInfoWindow = true; this.defaultIcon = null; this.searchBox = false; this.searchBoxLabel = 'Ir para:'; this.searchBoxSubmitText = 'OK'; this.latlng = new google.maps.LatLng(38.708324327636795, -9.135032854173915); this.geocoder = new google.maps.Geocoder(); this.infowindow = new google.maps.InfoWindow(); this.calculateRoute = false; this.routeOrigin = null; this.routeDestination = null; this.directionsService = null; this.directionsDisplay = null; this.designationBox = false; this.designationBoxURL = null; this.removeOption = true; this.mapContainer = document.createElement('div'); this.onMarkerLoad = function(widget) { }; this.onMarkerRemove = function(widget) { }; } } KMap.prototype.createLabel = function(index) { var inputStyle = 'KHidden'; var labelContainer = window.document.createElement('div'); labelContainer.className = 'KLabelContainer'; this.label = window.document.createElement('label'); this.label.setAttribute('for', this.options[index].id); this.label.className = 'KLabel ' + inputStyle + 'Label'; if (this.options[index].isHTML) { this.label.innerHTML = this.options[index].label; } else { this.label.appendChild(window.document.createTextNode(this.options[index].label)); } labelContainer.appendChild(this.label); return labelContainer; } KMap.prototype.onPageShow = function() { var page = this.getParent('KPage'); if (page) { if (page.display) { this.initializeMap(); } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').onPageShow()', 800); } } else { var dialog = this.getParent('KDialog'); if (dialog) { if (dialog.display) { this.initializeMap(); } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').onPageShow()', 800); } } } } KMap.prototype.refresh = function() { if (this.mapContainer.childNodes.length != 0) { this.mapContainer.removeChild(this.mapContainer.childNodes[0]); } delete this.map; this.display = false; this.clear(); this.draw(); KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').onPageShow()', 800); } KMap.prototype.draw = function() { KInput.prototype.draw.call(this); var thisObject = this; if (this.getValue().length != 0) { eval('this.latlng = new google.maps.LatLng(' + this.getValue()[0].coordinate + ');'); } this.mapContainer.className = 'KMapParent'; this.content.appendChild(this.mapContainer); if (this.searchBox == true) { this.drawSearchControl(); } } KMap.prototype.loadInitialMarkers = function() { for ( var index in this.options) { var latLng = null; if (this.options[index].value != null) { var pointInfo = JSON.parse(this.options[index].value); eval('latLng = new google.maps.LatLng(' + pointInfo.coordinate + ');'); this.placeMarker(latLng, true, this.showInfoWindow, pointInfo); } } } KMap.prototype.calcRoute = function() { var thisObject = this; if (thisObject.routeOrigin == null || thisObject.routeDestination == null) { alert('N\u00e3o existem pontos de origem e destino configurados.'); } else { var request = { origin : thisObject.routeOrigin, destination : thisObject.routeDestination, travelMode : google.maps.DirectionsTravelMode.DRIVING, unitSystem : google.maps.DirectionsUnitSystem.METRIC }; this.directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { thisObject.directionsDisplay.setDirections(response); thisObject.infowindow.close(); } }); } } KMap.prototype.getMarker = function(index) { return this.mapMarkers['marker' + index]; } KMap.prototype.placeMarker = function(latLng, noSet, showInfoWindow, pointObject, customText) { var thisObject = this; this.map.setCenter(latLng); this.infowindow = new google.maps.InfoWindow( { content : '' }); this.getCurrentLocation(latLng, this.mapMarkersIndex); var marker = new google.maps.Marker( { position : latLng, map : this.map, draggable : thisObject.draggableMarkers }); marker.setIcon((pointObject && pointObject.icon ? pointObject.icon : thisObject.defaultIcon)); marker.index = this.mapMarkersIndex++; marker.name = 'marker' + marker.index; this.mapMarkers[marker.name] = marker; this.mapMarkersCount++; if (!noSet) { if (this.mapMarkersIndex != 1) { var input = this.createInput(0); this.inputs.push(input); this.content.appendChild(input); } } if (pointObject == null) { pointObject = new Object(); pointObject.coordinate = this.cleanCoordinate(latLng); } this.setValue(pointObject, marker.index); google.maps.event.addListener(marker, 'click', function() { var baloonInfo = thisObject.getCurrentLocation(marker.position, marker.index, (pointObject && pointObject.title ? pointObject.title : marker.infoTitle || customText)); thisObject.infowindow.setContent(baloonInfo); if(thisObject.showInfoWindow) thisObject.infowindow.open(thisObject.map, marker); }); marker.dragging = false; google.maps.event.addListener(marker, 'dragstart', function() { marker.dragging = true; thisObject.infowindow.close(); }); google.maps.event.addListener(marker, 'dragend', function() { marker.dragging = false; thisObject.map.setCenter(marker.position); thisObject.getCurrentLocation(marker.position, marker.index, (pointObject && pointObject.title ? pointObject.title : marker.infoTitle || customText)); if(thisObject.showInfoWindow) thisObject.infowindow.open(thisObject.map, this); }); if (showInfoWindow == true) { this.infowindow.open(this.map, marker); } return marker.index; } KMap.prototype.clearMarkers = function() { for ( var i = 0; i < this.mapMarkersCount; i++) { this.mapMarkers['marker' + i].setMap(null); delete this.mapMarkers['marker' + i]; this.infowindow.close(); this.inputs[i].value = ''; } this.mapMarkers = {}; this.mapMarkersCount = 0; this.mapMarkersIndex = 0; } KMap.removeMarker = function(widget, action) { if (widget.hash != KBreadcrumb.getQuery() || !widget.activated()) { return; } try { var id = action.split('/')[2]; widget.mapMarkers['marker' + id].setMap(null); widget.inputs[id].value = ''; widget.infowindow.close(); delete widget.mapMarkers['marker' + id]; widget.mapMarkersCount--; widget.onMarkerRemove(widget, 'marker' + id); KBreadcrumb.back( { action : '' }); } catch (error) { } } KMap.prototype.submitDesignation = function(designation, markerIndex) { var obj = this.getValue()[markerIndex]; if (typeof (obj) != 'object') { try { obj = JSON.parse(this.options[markerIndex].value); } catch (error) { obj = JSON.parse(this.inputs[markerIndex].value); } } obj.designation = designation; var inputID = this.inputID.replace('[]', markerIndex); document.getElementById(inputID).value = JSON.stringify(obj); try { this.onMarkerLoad(this, JSON.stringify(obj), 'marker' + markerIndex); } catch (error) { } } KMap.prototype.drawSearchControl = function() { // container da input de pesquisa e do botão: var container = document.createElement('div'); container.className = 'KMapSearchBoxContainer'; this.content.appendChild(container); // Input de pesquisa var searchLabel = document.createElement('span'); searchLabel.className = 'KMapSearchBoxLabel'; var searchLabelText = document.createTextNode(this.searchBoxLabel); searchLabel.appendChild(searchLabelText); container.appendChild(searchLabel); this.searchBoxControl = document.createElement('input'); this.searchBoxControl.setAttribute('type', 'text'); this.searchBoxControl.className = 'KMapSearchBox'; KSystem.addEventListener(this.searchBoxControl, 'keypress', function(ev) { if (ev.keyCode == 13) { var widget = KSystem.getEventWidget(ev); widget.geocodeAddress(widget.searchBoxControl); return false; } }); container.appendChild(this.searchBoxControl); // botão de submissão var searchSubmit = document.createElement('a'); searchSubmit.className = 'KMapSearchBoxSubmit'; var submitText = document.createTextNode(this.searchBoxSubmitText); searchSubmit.appendChild(submitText); KSystem.addEventListener(searchSubmit, 'click', function(event) { var widget = KSystem.getEventWidget(event); widget.geocodeAddress(widget.searchBoxControl); }); container.appendChild(searchSubmit); } KMap.prototype.geocodeAddress = function(address) { var thisObject = this; address = address.value; this.geocoder.geocode( { 'address' : address, 'region' : 'pt', 'partialmatch' : true }, function(results, status) { if (status == 'OK' && results.length > 0) { thisObject.map.setCenter(results[0].geometry.location); } else { alert("Geocode was not successful for the following reason: " + status); } }); } KMap.prototype.getCurrentLocation = function(latLng, inputIndex, customText) { KMap.getAddressFromLatLng(this, latLng, function(thisObject, geoResults, status) { if (status == google.maps.GeocoderStatus.OK) { var location = KMap.getAddressFromGeoCodeResult(geoResults); var inputValue = ''; var toReturn = new Object(); toReturn.coordinate = thisObject.cleanCoordinate(latLng); toReturn.local = HTMLEntities.encode(location.local); toReturn.city = HTMLEntities.encode(location.city); toReturn.address = HTMLEntities.encode(location.address); var testing = thisObject.getValue()[inputIndex]; if (typeof (testing) != 'object') { try { testing = JSON.parse(thisObject.options[inputIndex].value); } catch (error) { try { testing = JSON.parse(thisObject.inputs[inputIndex].value); } catch(e) { testing = {}; } } } KSystem.merge(testing, toReturn); inputValue = JSON.stringify(testing); thisObject.setValue(inputValue, inputIndex); thisObject.label.innerHTML = location.local + ' / ' + location.city; var baloonInfo = ''; if (customText != null) { baloonInfo += '' + customText + '
'; } baloonInfo += '' + location.address + '
Freguesia: ' + location.local + '
Cidade:' + location.city + '


'; if (thisObject.designationBox != false) { baloonInfo += 'editar designação  |  '; } if (thisObject.removeOption == true) { baloonInfo += 'remover   '; } if (thisObject.otherOptions) { for ( var index in thisObject.otherOptions) { baloonInfo += '|  ' + thisObject.otherOptions[index].label + ''; } } thisObject.infowindow.setContent(baloonInfo); thisObject.onMarkerLoad(thisObject, inputValue, 'marker' + inputIndex); } else { thisObject.infowindow.setContent(''); } }); } KMap.prototype.cleanCoordinate = function(coordinate) { coordinate = coordinate.toString(); if (coordinate.length > 0) { coordinate = coordinate.substring(0, coordinate.length - 1); coordinate = coordinate.substring(1, coordinate.length); } return coordinate; } KMap.prototype.getValue = function(rawValue) { var toReturn = new Array(); for ( var index in this.inputs) { if (this.inputs[index].value && this.inputs[index].value != '') { eval('toReturn.push(' + (this.inputs[index].value || '{}') + ' )'); } } return toReturn; } KMap.prototype.initializeMap = function() { var myOptions = { zoom : this.initialZoom, center : this.latlng, disableDoubleClickZoom : true, streetViewControl : true, navigationControlOptions : { style : google.maps.NavigationControlStyle.SMALL }, mapTypeControlOptions : { style : google.maps.MapTypeControlStyle.DROPDOWN_MENU }, mapTypeId : this.mapType || google.maps.MapTypeId.ROADMAP }; this.map = new google.maps.Map(this.mapContainer, myOptions); if (this.calculateRoute == true) { this.directionsDisplay = new google.maps.DirectionsRenderer(); this.directionsDisplay.setMap(this.map); this.directionsService = new google.maps.DirectionsService(); var directionsContainer = document.createElement('div'); directionsContainer.className = 'KMapDirections'; this.content.appendChild(directionsContainer); this.directionsDisplay.setPanel(directionsContainer); this.calcRoute(); } if (this.maxMarkers != 0) { var widget = this; google.maps.event.addListener(this.map, 'dblclick', function(event) { if(!widget.oneMarkerMode || widget.mapMarkersCount < widget.maxMarkers) { if (widget.mapMarkersCount >= widget.maxMarkers) { alert(widget.maxMarkersMessage); } else { if (widget.mapMarkersCount > 0) { widget.infowindow.close(); } widget.placeMarker(event.latLng, false, widget.showInfoWindow, null); } } else if(widget.oneMarkerMode) { var unique_marker = widget.getMarker(0); unique_marker.setPosition(event.latLng); widget.map.setCenter(unique_marker.position); } }); } this.loadInitialMarkers(); } KMap.prototype.setValue = function(value, index) { index = index || 0; var strValue = null; if (typeof (value) == 'object') { var pointInfo = null; if (this.activated()) { try { pointInfo = JSON.parse(this.inputs[index].value); } catch (e) { } } else { try { pointInfo = JSON.parse(this.options[index].value); } catch (e) { } } if (pointInfo) { KSystem.merge(pointInfo, value); } else { pointInfo = value; } strValue = JSON.stringify(pointInfo); } else { pointInfo = value; strValue = value; } if (this.activated()) { if (this.inputs[index]) { this.inputs[index].value = strValue || ''; } else if (!value) { this.clearMarkers(); } } else { if (this.options[index] && this.options[index].value == null) { this.options[index].value = strValue; } else if (!value) { for ( var i = 0; i < this.inputs.length; i++) { this.options[i].value = strValue; } } else { this.addOption(strValue); } } } KMap.loadUnload = function(widget, hash) { //AQUI if (!widget.activated() || !widget.getParent('KPage').activated()) { return; } // dump([widget.mapPane, widget.map, widget.id, hash]); if (hash == widget.getParent('KPage').hash) { widget.refresh(); } } KMap.getAddressFromGeoCodeResult = function(geoResults) { var local = 'N/A'; var city = 'N/A'; var address = 'N/A'; for ( var index in geoResults) { if (address == 'N/A') { address = geoResults[index].formatted_address; } if (geoResults[index].types.length > 0 && geoResults[index].types[0] == 'sublocality') { local = geoResults[index].address_components[0].long_name; city = geoResults[index].address_components[1].long_name; } } if (local == 'N/A' || city == 'N/A') { for ( var index in geoResults) { if (geoResults[index].types.length > 0 && geoResults[index].types[0] == 'locality') { local = geoResults[index].address_components[0].long_name; city = geoResults[index].address_components[1].long_name; address = geoResults[index].formatted_address; } } } return { local : local, address : address, city : city }; } KMap.getAddressFromLatLng = function(widget, latlng, callback) { if (!KMap.GEOCODER) { KMap.GEOCODER = new google.maps.Geocoder(); KSystem.addTimer(KMap.checkGeoCoder, 10); } if (typeof latlng == 'string') { eval('latlng = new google.maps.LatLng(' + latlng + ');'); } KMap.GEOCODER_RUNNING.push( [ widget, latlng, callback ]); } KMap.checkGeoCoder = function() { if (KMap.GEOCODER_RUNNING.length > 0) { var args = KMap.GEOCODER_RUNNING.pop(); var latlng = args[1]; var widget = args[0]; var callback = args[2]; KMap.GEOCODER.geocode( { latLng : latlng }, function(result, status) { callback(widget, result, status); }); KSystem.addTimer(KMap.checkGeoCoder, 1500); } else { KSystem.addTimer(KMap.checkGeoCoder, 200); } } KMap.MAP_CONTAINER = 'mapContainer'; KMap.GEOCODER = null; KMap.GEOCODER_RUNNING = []; KCaptcha.prototype = new KInput; KCaptcha.prototype.constructor = KCaptcha; function KCaptcha(parent, label, id, params) { if (parent != null) { KInput.call(this, parent, 'text', label, id, true); this.image = new Image(); this.image.className = 'KCaptchaImage'; this.button = window.document.createElement('button'); this.button.setAttribute('type', 'button'); this.button.className = 'KCaptchaButton'; this.button.innerHTML = 'Reload'; KSystem.addEventListener(this.button, 'click', KCaptcha.reloadImage); this.data = params; } } KCaptcha.prototype.go = function() { this.load(); } KCaptcha.prototype.load = function() { this.draw(); } KCaptcha.prototype.draw = function() { KInput.prototype.draw.call(this); this.url = ''; for ( var index in this.data) { this.url += '&' + index + '=' + this.data[index]; } this.image.src = KCaptcha.CAPTCHA_SERVICE_URL + "?date=" + new Date().getMilliseconds() + this.url; this.inputContainer.appendChild(this.button); this.inputContainer.appendChild(this.image); } KCaptcha.reloadImage = function(event) { var widget = KSystem.getEventWidget(event); //widget.refresh(); widget.image.src = KCaptcha.CAPTCHA_SERVICE_URL + "?date=" + new Date().getMilliseconds() + widget.url; } KCaptcha.IMAGE_ELEMENT = 'image'; KCaptcha.CAPTCHA_SERVICE_URL = null; KLayeredPanel.prototype = new KWidget(); KLayeredPanel.prototype.constructor = KLayeredPanel; function KLayeredPanel(parent, cssClass) { if (parent != null) { KWidget.call(this, parent); this.loadService = false; this.internalEvent = false; this.addActionListener(KLayeredPanel.actions); this.cssClass = cssClass; this.layout = KLayeredPanel.LINEAR; this.tabBar = new Object(); this.panelCount = 0; this.selectedTab = {}; this.tabEffects = {}; this.defaultTab = null; } } KLayeredPanel.prototype.addPanel = function(element, title, callbacks, isDefault) { if (this.layout == KLayeredPanel.TABS) { this.tabPanel = window.document.createElement(this.tagNames[Kinky.HTML_READY][KLayeredPanel.TABS_DIV]); var a = window.document.createElement('a'); if (this.internalEvent) { KSystem.addEventListener(a, 'click', function(event) { var widget = KSystem.getEventWidget(event); KBreadcrumb.dispatchEvent(widget.id, { action : element.hash }); }); a.style.cursor = 'pointer'; } else { KSystem.addEventListener(a, 'click', function(event) { KBreadcrumb.dispatchURL( { action : element.hash }); }); a.style.cursor = 'pointer'; } a.innerHTML = title || element.widgetTitle.innerHTML; this.tabPanel.alt = element.hash; this.tabPanel.appendChild(a); this.addCSSClass((this.cssClass || 'KLayeredPanelPane') + 'Title', this.tabPanel); this.addCSSClass((this.cssClass || 'KLayeredPanelPane') + 'Title' + (this.widgetTitle.childNodes.length - 1), this.tabPanel); if (((element.buttons & KWidget.CLOSE) == KWidget.CLOSE) || ((this.buttons & KWidget.CLOSE) == KWidget.CLOSE)) { var closeButton = window.document.createElement('button'); closeButton.className = this.cssClass + 'TitleClose'; closeButton.setAttribute('type', 'button'); closeButton.appendChild(window.document.createTextNode('x')); this.tabPanel.appendChild(closeButton); if (callbacks && callbacks.closeCallback) { KSystem.addEventListener(closeButton, 'click', callbacks.closeCallback); } KSystem.addEventListener(closeButton, 'click', KLayeredPanel.closePanel); } this.tabBar[element.hash] = this.tabPanel; this.widgetTitle.appendChild(this.tabPanel); } var panel = null; if (element instanceof KPanel) { panel = element; } else { panel = new KPanel(this); panel.hash = element.hash; element.parent = panel; panel.appendChild(element); } if (isDefault) { this.defaultTab = panel.hash; } panel.layeredPanePosition = this.panelCount++; if (this.layout != KLayeredPanel.TABS) { var a = window.document.createElement('a'); if (this.internalEvent) { KSystem.addEventListener(a, 'click', function(event) { var widget = KSystem.getEventWidget(event); var hash = element.hash; if (widget.parent.selectedTab[widget.parent.getContext()] && widget.parent.selectedTab[widget.parent.getContext()] == element.hash) { hash = ''; } KBreadcrumb.dispatchEvent(widget.parent.id, { action : hash }); }); a.style.cursor = 'pointer'; } else { KSystem.addEventListener(a, 'click', function(event) { var widget = KSystem.getEventWidget(event); var hash = element.hash; if (widget.parent.selectedTab[widget.parent.getContext()] && widget.parent.selectedTab[widget.parent.getContext()] == element.hash) { hash = ''; } KBreadcrumb.dispatchURL( { action : hash }); }); a.style.cursor = 'pointer'; } a.innerHTML = title || element.widgetTitle.innerHTML; panel.widgetTitle.appendChild(a); panel.addCSSClass((this.cssClass || 'KLayeredPanelPane') + 'Title', KWidget.TITLE_DIV); } panel.addCSSClass(this.cssClass || 'KLayeredPanelPane'); panel.addCSSClass(this.cssClass + 'Content' || 'KLayeredPanelPaneContent', KWidget.CONTENT_DIV); this.appendChild(panel); } KLayeredPanel.prototype.load = function() { var params = new Object(); if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } params.contentView = this.data.contentView; params.contentID = this.data.contentID; params.offset = this.nPage * this.perPage; params.limit = this.perPage; this.kinky.get(this, this.data.feService, params); } KLayeredPanel.prototype.go = function() { if (this.activated()) { this.redraw(); } else if (this.loadService) { this.load(); } else { this.draw(); } } KLayeredPanel.prototype.draw = function() { for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.setStyle( { clear : 'both' }, KWidget.CONTENT_DIV); var first = true; for ( var child in this.childWidgets()) { if (!(this.childWidget(child) instanceof KPanel)) { continue; } if (this.defaultTab == child) { this.notRelatedAction = false; if (this.internalEvent) { KBreadcrumb.dispatchEvent(this.id, { action : this.childWidget(child).hash }); } else { KBreadcrumb.dispatchURL( { action : this.childWidget(child).hash }); } first = false; } else { if (this.tabEffects[KWidget.EXIT]) { KEffects.addEffect(this.childWidget(child), KSystem.clone(this.tabEffects[KWidget.EXIT])); } else { this.childWidget(child).setStyle( { display : 'none' }, (this.layout == KLayeredPanel.TABS ? KWidget.CONTAINER_DIV : KWidget.CONTENT_DIV)); } } } this.activate(); } KLayeredPanel.prototype.onChangeTab = function(action) { var context = this.getContext(); if (this.childWidget(action)) { if (this.selectedTab[context] == action) { if (this.layout == KLayeredPanel.TABS) { return; } if (this.tabEffects[KWidget.EXIT]) { KEffects.addEffect(this.childWidget(action), KSystem.clone(this.tabEffects[KWidget.EXIT])); } else { this.childWidget(action).setStyle( { display : 'none' }, KWidget.CONTENT_DIV); } this.childWidget(action).removeCSSClass((this.cssClass || 'KLayeredPanelPane') + 'TitleSelected', KWidget.TITLE_DIV); this.childWidget(action).removeCSSClass((this.cssClass || 'KLayeredPanelPane') + 'TitleSelected' + this.childWidget(this.selectedTab[context]).layeredPanePosition, KWidget.TITLE_DIV); this.selectedTab[context] = null; } else { this.childWidget(action).setStyle( { display : 'block' }, (this.layout == KLayeredPanel.TABS ? KWidget.CONTAINER_DIV : KWidget.CONTENT_DIV)); if (this.tabEffects[KWidget.ENTER]) { KEffects.addEffect(this.childWidget(action), KSystem.clone(this.tabEffects[KWidget.ENTER])); } if (this.selectedTab[context] && this.childWidget(this.selectedTab[context])) { if (this.tabEffects[KWidget.EXIT]) { KEffects.addEffect(this.childWidget(this.selectedTab[context]), KSystem.clone(this.tabEffects[KWidget.EXIT])); } else { this.childWidget(this.selectedTab[context]).setStyle( { display : 'none' }, (this.layout == KLayeredPanel.TABS ? KWidget.CONTAINER_DIV : KWidget.CONTENT_DIV)); } this.childWidget(this.selectedTab[context]).removeCSSClass((this.cssClass || 'KLayeredPanelPane') + 'TitleSelected', (this.layout == KLayeredPanel.TABS ? this.tabBar[this.selectedTab[context]] : KWidget.TITLE_DIV)); this.childWidget(this.selectedTab[context]).removeCSSClass((this.cssClass || 'KLayeredPanelPane') + 'TitleSelected' + this.childWidget(this.selectedTab[context]).layeredPanePosition, (this.layout == KLayeredPanel.TABS ? this.tabBar[this.selectedTab[context]] : KWidget.TITLE_DIV)); } this.childWidget(action).addCSSClass((this.cssClass || 'KLayeredPanelPane') + 'TitleSelected', (this.layout == KLayeredPanel.TABS ? this.tabBar[action] : KWidget.TITLE_DIV)); this.childWidget(action).addCSSClass((this.cssClass || 'KLayeredPanelPane') + 'TitleSelected' + this.childWidget(action).layeredPanePosition, (this.layout == KLayeredPanel.TABS ? this.tabBar[action] : KWidget.TITLE_DIV)); this.selectedTab[context] = action; } } } KLayeredPanel.actions = function(widget, action) { if ((action == 'undefined' || action == '') && !widget.notRelatedAction && widget.selectedTab[widget.getContext()]) { var context = widget.getContext(); if (widget.layout == KLayeredPanel.TABS) { return; } if (widget.tabEffects[KWidget.EXIT]) { KEffects.addEffect(widget.childWidget(widget.selectedTab[context]), KSystem.clone(widget.tabEffects[KWidget.EXIT])); } else { widget.childWidget(widget.selectedTab[context]).setStyle( { display : 'none' }, KWidget.CONTENT_DIV); } widget.childWidget(widget.selectedTab[context]).removeCSSClass((widget.cssClass || 'KLayeredPanelPane') + 'TitleSelected', KWidget.TITLE_DIV); widget.childWidget(widget.selectedTab[context]).removeCSSClass((widget.cssClass || 'KLayeredPanelPane') + 'TitleSelected' + widget.childWidget(widget.selectedTab[context]).layeredPanePosition, KWidget.TITLE_DIV); widget.selectedTab[context] = null; } else if (widget.childWidget(action)) { widget.notRelatedAction = false; widget.onChangeTab(action); } else { widget.notRelatedAction = true; } } KLayeredPanel.closePanel = function(event) { var div = KSystem.getEventTarget(event).parentNode; var id = div.alt; var pane = KSystem.getEventWidget(event); pane.removeChild(pane.childWidget(id)); div.parentNode.removeChild(div); } KLayeredPanel.TABS = 1; KLayeredPanel.LINEAR = 2; KLayeredPanel.TABS_DIV = 'tabPanel'; KLayeredPanel.prototype.tagNames = { html4 : { panel : 'div', contentContainer : 'div', content : 'div', background : 'div', widgetTitle : 'div', paginationBar : 'div', tabPanel : 'div' }, html5 : { panel : 'section', contentContainer : 'article', content : 'div', background : 'div', widgetTitle : 'header', paginationBar : 'nav', tabPanel : 'nav' } } KPanel.prototype = new KWidget(); KPanel.prototype.constructor = KPanel; KPanel.prototype.loadService = false; function KPanel(parent) { if (parent != null) { KWidget.call(this, parent); } } KPanel.prototype.onLoad = function(data) { for ( var block in data) { if (data[block] && typeof data[block] == 'object') { this.appendChild(KSystem.construct(data[block], this)); } } this.draw(); } KPanel.prototype.addElement = function(element) { if (element instanceof KWidget) { this.appendChild(element); } else { throw new KNoExtensionException(this, "addElement"); } } KPanel.prototype.load = function() { var params = new Object(); if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } params.contentView = this.data.contentView; params.contentID = this.data.contentID; params.offset = this.nPage * this.perPage; params.limit = this.perPage; this.kinky.get(this, this.data.feService, params); } KPanel.prototype.go = function() { if (this.activated() && !this.loadService) { this.redraw(); } else if (this.loadService) { this.load(); } else { this.draw(); } } KPanel.prototype.draw = function() { for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); } KList.prototype = new KWidget(); KList.prototype.constructor = KList; KList.prototype.isPaginated = true; function KList(parent, params) { if (parent != null) { this.hasTopPagination = (params && params.topPagination) || false; this.isPaginated = (params && params.isPaginated != undefined ? params.isPaginated : true); KWidget.call(this, parent); this.addActionListener(KList.actions, [ '/no-content', '/page/*', '/bad-request', '/authentication', '/error' ]); if (this.hasTopPagination) { this.topPagination = this.paginationBar.cloneNode(true); KSystem.addEventListener(this.topPagination.childNodes[0], 'click', KWidget.dispatchPrevious); KSystem.addEventListener(this.topPagination.childNodes[2], 'click', KWidget.dispatchNext); this.widgetTitle.appendChild(this.topPagination); } this.totalPages = 1; this.currentPage = 0; this.pageCallback = this.onNextPage; this.paginationDispatchType = KBreadcrumb.DISPATCH_URL; } } KList.prototype.go = function() { if (this.childWidgets() != null) { this.draw(); } else { this.load(); } } KList.prototype.onLoad = function(data, context) { if (this.data == null) { this.data = new Object(); } this.data.feService = data.feService || this.data.feService; this.data.contentView = data.contentView || this.data.contentView; this.data.contentID = data.contentID || this.data.contentID; this.nPage = this.requestedPage; if (this.hasTopPagination) { this.content.appendChild(this.paginationBar.cloneNode(true)); } var i = 0; var page = 0; for ( var block in data) { if (data[block] && typeof data[block] == 'object') { this.appendChild(KSystem.construct(data[block], this), context); i++; if (i == this.perPage) { page++; i = 0; context = this.query + page; if (page != 0) { this.hideContext(this.query + (page - 1)); } } } } if (page != 0) { this.hideContext(this.query + (page - 1)); } this.draw(); } KList.prototype.load = function() { if (this.data != null && this.data.contentView != null) { var params = new Object(); if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } params.contentView = this.data.contentView; params.contentID = this.data.contentID; if (this.isPaginated) { params.offset = this.requestedPage * this.perPage; params.limit = this.perPage; } params.operator = this.data.operator; params.orderby = this.data.orderby; params.nolang = this.data.nolang; this.kinky.get(this, this.data.feService, params); } } KList.prototype.draw = function() { for ( var element in this.childWidgets()) { if (!this.childWidget(element).activated()) { this.childWidget(element).go(); } } this.activate(); } KList.prototype.onShow = function() { if (KWidget.prototype.onShow.call(this)) { if (this.pageCallback) { this.pageCallback(); } return true; } return false; } KList.prototype.onNextPage = function() { // this.hideContext(this.query + (this.nPage - 1)); this.showContext(); } KList.prototype.onPreviousPage = function() { // this.hideContext(this.query + (this.nPage + 1)); this.showContext(); } KList.actions = function(widget, action) { var parentPage = widget.getParent('KPage'); if ((parentPage && parentPage.hash != KBreadcrumb.getHash())) { return; } var baseAction = '/' + action.split('/')[1]; switch (baseAction) { case '/no-content': { widget.totalCount = widget.nChildren; try { widget.afterNext(); } catch (e) { if (widget.nPage != 0) { widget.gotoPage('/page/' + (widget.nPage - 1)); return; } } widget.resume(); break; } case '/page': { widget.gotoPage(action); break; } case '/bad-request': { widget.resume(); break; } case '/authentication': { widget.resume(); break; } case '/error': { widget.resume(); break; } default : { widget.resume(); } } return; } KList.prototype.setTotalPages = function(mpages, clickable) { this.totalPages = (mpages > 0) ? mpages : 0; this.pagination.innerHTML = ''; if (this.hasTopPagination) { this.topPagination.getElementsByTagName('div')[0].innerHTML = ''; } for ( var i = 0; i < this.totalPages; i++) { var pagesHTML = document.createElement('div'); pagesHTML.className = ' ' + this.className + 'PgNumb ' + this.className + 'PgNum' + (i + 1) + ((this.nPage == i) ? " " + this.className + "PgCurrent " : " "); pagesHTML.innerHTML = (i + 1); if (clickable) { KSystem.addEventListener(pagesHTML, 'click', KList.onPaginationClick); } if (this.hasTopPagination) { var clonenode = pagesHTML.cloneNode(true); if (clickable) { KSystem.addEventListener(clonenode, 'click', KList.onPaginationClick); } this.topPagination.getElementsByTagName('div')[0].appendChild(clonenode); } this.pagination.appendChild(pagesHTML); } } KList.onPaginationClick = function(evt) { var widget = KSystem.getEventWidget(evt); var myTarget = KSystem.getEventTarget(evt); var indx = (/[0-9]/.exec(myTarget.className)[0] * 1) - 1; KCSS.addCSSClass(widget.className + 'PgCurrent', myTarget); KCSS.removeCSSClass(widget.className + 'PgCurrent', myTarget.parentNode.childNodes[widget.nPage]); var pageGoTo = '/page/' + indx; if (widget.paginationDispatchType == KBreadcrumb.DISPATCH_URL) { KBreadcrumb.dispatchURL( { action : pageGoTo }); } else { KBreadcrumb.dispatchEvent(widget.id, { action : pageGoTo }); } } KGallery.prototype = new KList(); KGallery.prototype.constructor = KGallery; function KGallery(parent) { if (parent != null) { KList.call(this, parent); this.addActionListener(KGallery.popup, [ '/gallery/view-image/*' ]); this.nImage = [ 0 ]; } } KGallery.prototype.appendChild = function(element, context) { if (element instanceof KLink) { element.isImageLink = true; } else if (element instanceof KImage) { var a = window.document.createElement('a'); if (this.paginationDispatchType == 'url') { a.href = this.getLink( { action : '/gallery/view-image/' + this.getImageCount() }); } else { var imageCount = this.getImageCount(); a.href = 'javascript:void(0)'; KSystem.addEventListener(a, 'click', function(event) { var widget = KSystem.getEventWidget(event); KBreadcrumb.dispatchEvent(widget.parent.id, { action : '/gallery/view-image/' + imageCount }); }); } element.waitForLoad = true; element.maxWidth = this.maxWidth; element.maxHeight = this.maxHeight; element.content.style.overflow = 'hidden'; element.content.style.height = this.maxHeight + 'px'; element.content.style.width = this.maxWidth + 'px'; element.content.appendChild(a); element.content = a; element.content.appendChild(element.image); } this.setImageCount(); KList.prototype.appendChild.call(this, element, context); } KGallery.prototype.getImageCount = function() { var context = this.query + this.nPage; if (this.isPaginated && Math.floor(this.nChildren / this.perPage) != this.nPage) { context = this.query + Math.floor(this.nChildren / this.perPage); } if (this.nImage[context] == null) { this.nImage[context] = 0; } return this.nImage[context]; } KGallery.prototype.setImageCount = function() { var context = this.query + this.nPage; if (this.isPaginated && Math.floor(this.nChildren / this.perPage) != this.nPage) { context = this.query + Math.floor(this.nChildren / this.perPage); } if (this.nImage[context] == null) { this.nImage[context] = 0; } this.nImage[context]++; } KGallery.popup = function(widget, action) { if (widget.activated() && widget.getParent('KPage') && widget.getParent('KPage').hash == widget.getHash()) { var imageID = action.split('/'); var image = widget.childAt(imageID[3]); if (image) { var dialog = null; if (Kinky.site.childWidget('/gallery/popup')) { dialog = Kinky.site.childWidget('/gallery/popup'); } else { Kinky.site.showOverlay(); dialog = new KDialog(Kinky.site); dialog.type = KDialog.MODAL; dialog.addCSSClass('KGalleryDialog'); dialog.hash = '/gallery/popup'; dialog.nextCallback = function(event) { var nImage = parseInt(widget.getAction().split('/')[3]); var nextImage = widget.childAt(++nImage); if (nextImage) { KEffects.addEffect(dialog, { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : 0 }, lock : { width : true }, onComplete : function(wDialog, tween) { Kinky.site.overlayWidgets--; if (widget.paginationDispatchType == 'url') { KBreadcrumb.dispatchURL( { action : '/gallery/view-image/' + nImage }); } else { KBreadcrumb.dispatchEvent( { action : '/gallery/view-image/' + nImage }); } } }); } } dialog.previousCallback = function(event) { var nImage = parseInt(widget.getAction().split('/')[3]); var prevImage = widget.childAt(--nImage); if (prevImage) { KEffects.addEffect(dialog, { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : 0 }, lock : { width : true }, onComplete : function(wDialog, tween) { Kinky.site.overlayWidgets--; if (widget.paginationDispatchType == 'url') { KBreadcrumb.dispatchURL( { action : '/gallery/view-image/' + nImage }); } else { KBreadcrumb.dispatchEvent( { action : '/gallery/view-image/' + nImage }); } } }); } } dialog.closeCallback = function(event) { Kinky.site.removeChild('/gallery/popup'); KDialog.close(event); Kinky.site.hideOverlay(true); } dialog.buttons = KWidget.CLOSE | KWidget.NEXT | KWidget.PREVIOUS; Kinky.site.appendChild(dialog); Kinky.site.panel.appendChild(dialog.panel); } if (image.data.popupURL) { image.onLoadPopup = function() { dialog.setStyle( { width : this.data.popupWidth + 'px', marginTop : Math.round((KSystem.getBrowserHeight() - this.data.popupHeight) / 2) + 'px', height : '0px', left : Math.round(KSystem.getBrowserWidth() / 2 - this.data.popupWidth / 2) + 'px', top : '0px' }); dialog.effects = { enter : { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : this.data.popupHeight }, lock : { width : true } }, exit : { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : 0 }, lock : { width : true }, onComplete : function(wDialog, tween) { Kinky.site.removeChild(wDialog); Kinky.site.hideOverlay(); if (widget.paginationDispatchType == 'url') { KBreadcrumb.back(); } } } }; KDialog.show(dialog, { title : '', content : '' }); }; image.loadPopupImage(); } else { dialog.setStyle( { width : image.data.width + 'px', marginTop : Math.round((KSystem.getBrowserHeight() - image.data.height) / 2) + 'px', height : '0px', left : Math.round(KSystem.getBrowserWidth() / 2 - image.data.width / 2) + 'px', top : '0px' }); dialog.effects = { enter : { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : image.data.height }, lock : { width : true } }, exit : { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : 0 }, lock : { width : true }, onComplete : function(wDialog, tween) { Kinky.site.removeChild(wDialog); Kinky.site.hideOverlay(); if (widget.paginationDispatchType == 'url') { KBreadcrumb.back(); } } } }; KDialog.show(dialog, { title : '', content : '' }); } } } } KSushibar.prototype = new KGallery(); KSushibar.prototype.constructor = KSushibar; function KSushibar(parent) { if (parent != null) { this.isPaginated = true; KGallery.call(this, parent); this.autoScroll = false; this.timeStep = 5000; this.perPage = 4; this.transitionTimer = null; } } KSushibar.prototype.draw = function() { var index = 1; for ( var element in this.childWidgets()) { var child = this.childWidget(element); child.addCSSClass('KSushibarItem' + index++); child.go(); } if (this.autoScroll && this.transitionTimer == null) { this.transitionTimer = KSystem.addTimer('KSushibar.nextSlide(\'' + this.id + '\')', this.timeStep, true); } this.activate(); } KSushibar.prototype.stopSlideshow = function() { KSystem.removeTimer(this.transitionTimer); } KSushibar.nextSlide = function(id) { var widget = null; eval('widget = Kinky.bunnyMan.widgets[\'' + id + '\'];'); var parent = widget.getParent('KPage'); if (parent.hash == KBreadcrumb.getHash()) { KWidget.dispatchNext(null, widget); } } KSushibar.prototype.continueSlideshow = function() { if (this.autoScroll) { this.transitionTimer = KSystem.addTimer('KSushibar.nextSlide(\'' + this.id + '\')', this.timeStep, true); } } KScrolledList.prototype = new KList(); KScrolledList.prototype.constructor = KScrolledList; function KScrolledList(parent) { if (parent) { KList.call(this, parent, { isPaginated : false }); this.autoPages = 3; this.listeningScroll = null; this.nextPageMessage = 'Get more'; this.hasNoMoreItems = false; } } KScrolledList.prototype.setScrollToListen = function(scroll) { scroll.addScrollListener(KScrolledList.pageNavigation, this); this.listeningScroll = scroll; } KScrolledList.prototype.setAutoPages = function(nPages) { this.autoPages = nPages; } KScrolledList.prototype.setNextPageMessage = function(message) { this.nextPageMessage = message; } KScrolledList.prototype.gotoPage = function() { this.requestedPage++; if (this.nextPageLoader) { this.content.appendChild(this.nextPageLoader); } this.load(); } KScrolledList.prototype.load = function() { if (this.data != null && this.data.contentView != null) { var params = { contentView : this.data.contentView, contentID : this.data.contentID, offset : this.requestedPage * this.perPage, limit : this.perPage, operator : this.data.operator, orderby : this.data.orderby, nolang : this.data.nolang } if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } this.kinky.get(this, this.data.feService, params); } } KScrolledList.prototype.onLoad = function(data, context) { if (this.data == null) { this.data = new Object(); } this.data.feService = data.feService || this.data.feService; this.data.contentView = data.contentView || this.data.contentView; this.data.contentID = data.contentID || this.data.contentID; var i = 0; var page = 0; for ( var block in data) { if (data[block] && typeof data[block] == 'object') { this.appendChild(KSystem.construct(data[block], this)); } } this.draw(); } KScrolledList.prototype.draw = function() { if (this.nextPageLoader && this.nextPageLoader.parentNode == this.content) { this.content.removeChild(this.nextPageLoader); } for ( var element in this.childWidgets()) { var child = this.childWidget(element); if (!child.activated()) { child.go(); } } if (!this.nextPageLoader) { this.nextPageLoader = window.document.createElement('div'); var img = window.document.createElement('img'); img.src = 'images/widget-loader.gif'; this.nextPageLoader.appendChild(img); KCSS.addCSSClass('KScrolledListLoader', this.nextPageLoader); } this.activate(); if (this.requestedPage >= this.autoPages) { if (!this.nextPageLink) { if(this.listeningScroll) this.listeningScroll.removeScrollListener(this); this.nextPageLink = window.document.createElement('div'); var link = window.document.createElement('a'); link.href = 'javascript:void(0);'; link.appendChild(window.document.createTextNode(this.nextPageMessage)); this.nextPageLink.appendChild(link); KSystem.addEventListener(link, 'click', function(event) { var widget = KSystem.getEventWidget(event) widget.content.removeChild(widget.nextPageLink); widget.gotoPage(); }); KCSS.addCSSClass('KScrolledListNextPage', this.nextPageLink); } this.content.appendChild(this.nextPageLink); } this.getting = false; } KScrolledList.prototype.afterNext = function() { this.hasNoMoreItems = true; this.getting = true; if(this.listeningScroll) this.listeningScroll.removeScrollListener(this); if (this.nextPageLoader && this.nextPageLoader.parentNode == this.content) { this.content.removeChild(this.nextPageLoader); } } KScrolledList.pageNavigation = function(widget, scroll, pos) { if (widget.getParent('KPage').hash != KBreadcrumb.getHash() || !widget.display) { return; } if (pos + 20 >= scroll.maxY && !widget.getting && !widget.hasNoMoreItems) { widget.getting = true; widget.gotoPage(); } } KCell.prototype = new KWidget(); KCell.prototype.constructor = KCell; function KCell(parent) { if (parent != null || parent == -1) { this.className = KSystem.getObjectClass(this); this.parent = parent; this.editMode = false; this.isDrawn = false; this.data = null; this.children = null; this.requestedPage = this.nPage = 0; this.nChildren = 0; this.perPage = 10; this.totalCount = null; this.display = false; this.kinky = Kinky.bunnyMan; this.breadcrumb = ''; this.id = this.id || this.kinky.addWidget(this); this.hash = null; this.panel = this.content = window.document.createElement('td'); this.panel.id = this.id; this.panel.className = ' KWidgetPanel ' + this.className + ' '; this.panel.style.overflow = this.overflow; this.panel.style.position = 'relative'; // this.panel.style.clear = 'both'; this.waitForLoad = false; this.window = false; this.closeButton = null; this.minimizeButton = null; this.maximizeButton = null; this.buttons = 0; this.movable = false; this.frame = false; this.effects = new Object(); this.waiting = false; this.error = null; this.request = null; this.response = null; this.needAuthentication = false; this.fromListener = false; this.lastWidth = 0; this.lastHeight = 0; this.scroll = {}; } } KCell.prototype.go = function() { this.draw(); } KCell.prototype.draw = function() { this.panel.style.overflow = 'visible'; for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); } KCell.prototype.appendChild = function(element) { if (element instanceof KWidget){ KWidget.prototype.appendChild.call(this, element); } } KRow.prototype = new KWidget(); KRow.prototype.constructor = KRow; function KRow(parent) { if (parent != null || parent == -1) { this.className = KSystem.getObjectClass(this); this.parent = parent; this.editMode = false; this.isDrawn = false; this.data = null; this.children = null; this.requestedPage = this.nPage = 0; this.nChildren = 0; this.perPage = 10; this.totalCount = null; this.display = false; this.kinky = Kinky.bunnyMan; this.breadcrumb = ''; this.id = this.id || this.kinky.addWidget(this); this.hash = null; this.panel = this.content = window.document.createElement('tr'); this.panel.id = this.id; this.panel.className = ' KWidgetPanel ' + this.className + ' '; this.panel.style.overflow = this.overflow; this.panel.style.position = 'relative'; // this.panel.style.clear = 'both'; this.waitForLoad = false; this.window = false; this.closeButton = null; this.minimizeButton = null; this.maximizeButton = null; this.buttons = 0; this.movable = false; this.frame = false; this.effects = new Object(); this.waiting = false; this.error = null; this.request = null; this.response = null; this.needAuthentication = false; this.fromListener = false; this.lastWidth = 0; this.lastHeight = 0; this.scroll = {}; } } KRow.prototype.go = function() { this.draw(); } KRow.prototype.draw = function() { this.panel.style.overflow = 'visible'; for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); } KRow.prototype.appendChild = function(element) { if (element instanceof KCell){ KWidget.prototype.appendChild.call(this, element); } } KTable.prototype = new KWidget(); KTable.prototype.constructor = KTable; function KTable(parent) { if (parent != null || parent == -1) { this.className = KSystem.getObjectClass(this); this.parent = parent; this.editMode = false; this.isDrawn = false; this.data = null; this.children = null; this.requestedPage = this.nPage = 0; this.nChildren = 0; this.perPage = 10; this.totalCount = null; this.display = false; this.kinky = Kinky.bunnyMan; this.breadcrumb = ''; this.id = this.id || this.kinky.addWidget(this); this.hash = null; this.panel = window.document.createElement('div'); this.panel.id = this.id; this.panel.className = ' KWidgetPanel ' + this.className + ' '; this.panel.style.overflow = this.overflow; this.panel.style.position = 'relative'; // this.panel.style.clear = 'both'; if (!this.simpleWidget) { this.topMarker = window.document.createElement('div'); this.topMarker.style.position = 'relative'; this.panel.appendChild(this.topMarker); this.background = window.document.createElement('div'); this.background.className = ' KWidgetPanelBackground ' + this.className + 'Background '; this.background.style.position = 'absolute'; this.background.style.top = '0px'; this.background.style.left = '0px'; this.panel.appendChild(this.background); this.contentContainer = window.document.createElement('table'); this.contentContainer.className = ' KWidgetPanelContentContainer ' + this.className + 'ContentContainer '; this.contentContainer.style.clear = 'both'; this.contentContainer.style.position = 'relative'; this.panel.appendChild(this.contentContainer); this.widgetTitle = window.document.createElement('thead'); this.widgetTitle.className = ' KWidgetPanelTitle ' + this.className + 'Title '; this.widgetTitle.style.position = 'relative'; this.contentContainer.appendChild(this.widgetTitle); if (Kinky.TITLE_CLEAR_BOTH || this.hasClearOnTitle) { this.contentContainer.appendChild(KCSS.clearBoth(true)); } } this.content = window.document.createElement('tbody'); this.content.className = ' KWidgetPanelContent ' + this.className + 'Content '; if (!this.simpleWidget) { this.contentContainer.appendChild(this.content); } else { this.panel.appendChild(this.content); } if (!this.simpleWidget) { this.titleBottomMarker = window.document.createElement('div'); this.titleBottomMarker.style.position = 'absolute'; this.titleBottomMarker.style.bottom = '0'; this.titleBottomMarker.style.clear = 'both'; this.widgetTitle.appendChild(this.titleBottomMarker); this.bottomMarker = window.document.createElement('div'); this.bottomMarker.style.position = 'absolute'; this.bottomMarker.style.bottom = '0'; this.bottomMarker.style.clear = 'both'; this.content.appendChild(this.bottomMarker); } this.waitForLoad = false; this.window = false; this.closeButton = null; this.minimizeButton = null; this.maximizeButton = null; this.buttons = 0; this.movable = false; this.frame = false; this.effects = new Object(); this.waiting = false; this.error = null; this.request = null; this.response = null; this.needAuthentication = false; this.fromListener = false; this.lastWidth = 0; this.lastHeight = 0; this.scroll = {}; } } KTable.prototype.go = function() { this.draw(); } KTable.prototype.draw = function() { this.panel.style.overflow = 'visible'; for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); } KTable.prototype.appendChild = function(element) { if (element instanceof KCell || element instanceof KRow){ KWidget.prototype.appendChild.call(this, element); } } KTable.prototype.load = function() { var params = new Object(); if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } params.contentView = this.data.contentView; params.contentID = this.data.contentID; params.offset = this.nPage * this.perPage; params.limit = this.perPage; this.kinky.get(this, this.data.feService, params); } KBreadcrumb.prototype.constructor = KBreadcrumb; function KBreadcrumb() { this.query = null; this.action = null; this.hash = null; this.url = null; this.last = null; this.history = new Array(); this.redirect = new Object(); this.byWidget = { location : {}, query : {}, action : {} }; this.listeners = { location : {}, query : {}, action : {} }; } KBreadcrumb.addLocationListener = function(widget, callback, hashes) { if (!KBreadcrumb.sparrow.byWidget.location[widget.id]) { KBreadcrumb.sparrow.byWidget.location[widget.id] = {}; } var listener = { widget : widget, callback : callback }; if (!hashes) { hashes = [ '*' ]; } for ( var hash in hashes) { var all = new RegExp('^' + hashes[hash].replace(/\*/g, '(.*)')); if (KBreadcrumb.sparrow.listeners.location[hashes[hash]] == null) { KBreadcrumb.sparrow.listeners.location[hashes[hash]] = { regex : all, listeners : new Array() }; } KBreadcrumb.sparrow.listeners.location[hashes[hash]].listeners.push(listener); if (widget.activated() && all.test(KBreadcrumb.getHash())) { KBreadcrumb.dispatchEvent(widget.id, { hash : KBreadcrumb.getHash() }); } if (!KBreadcrumb.sparrow.byWidget.location[widget.id][hashes[hash]]) { KBreadcrumb.sparrow.byWidget.location[widget.id][hashes[hash]] = { regex : all, listeners : new Array() }; } KBreadcrumb.sparrow.byWidget.location[widget.id][hashes[hash]].listeners.push(listener); } } KBreadcrumb.addQueryListener = function(widget, callback, queries) { if (!KBreadcrumb.sparrow.byWidget.query[widget.id]) { KBreadcrumb.sparrow.byWidget.query[widget.id] = {}; } var listener = { widget : widget, callback : callback }; if (!queries) { queries = [ '*' ]; } for ( var query in queries) { var all = new RegExp('^' + queries[query].replace(/\*/g, '(.*)')); if (KBreadcrumb.sparrow.listeners.query[queries[query]] == null) { KBreadcrumb.sparrow.listeners.query[queries[query]] = { regex : all, listeners : new Array() }; } KBreadcrumb.sparrow.listeners.query[queries[query]].listeners.push(listener); if (widget.activated() && all.test(KBreadcrumb.getQuery())) { KBreadcrumb.dispatchEvent(widget.id, { query : KBreadcrumb.getQuery() }); } if (!KBreadcrumb.sparrow.byWidget.query[widget.id][queries[query]]) { KBreadcrumb.sparrow.byWidget.query[widget.id][queries[query]] = { regex : all, listeners : new Array() }; } KBreadcrumb.sparrow.byWidget.query[widget.id][queries[query]].listeners.push(listener); } } KBreadcrumb.addActionListener = function(widget, callback, actions) { if (!KBreadcrumb.sparrow.byWidget.action[widget.id]) { KBreadcrumb.sparrow.byWidget.action[widget.id] = {}; } var listener = { widget : widget, callback : callback }; if (!actions) { actions = [ '*' ]; } for ( var action in actions) { var all = new RegExp('^' + actions[action].replace(/\*/g, '(.*)')); if (KBreadcrumb.sparrow.listeners.action[actions[action]] == null) { KBreadcrumb.sparrow.listeners.action[actions[action]] = { regex : all, listeners : new Array() }; } KBreadcrumb.sparrow.listeners.action[actions[action]].listeners.push(listener); if (widget.activated() && all.test(KBreadcrumb.getAction())) { KBreadcrumb.dispatchEvent(widget.id, { action : KBreadcrumb.getAction() }); } if (!KBreadcrumb.sparrow.byWidget.action[widget.id][actions[action]]) { KBreadcrumb.sparrow.byWidget.action[widget.id][actions[action]] = { regex : all, listeners : new Array() }; } KBreadcrumb.sparrow.byWidget.action[widget.id][actions[action]].listeners.push(listener); } } KBreadcrumb.back = function(params) { var nTimes = 1; if (params && params.nTimes) { nTimes = params.nTimes; } KBreadcrumb.sparrow.history.pop(); var url = null; for ( var time = 0; time != nTimes; time++) { url = KBreadcrumb.sparrow.history.pop(); if (url == null) return; url = '#' + url; url = KBreadcrumb.processURL(url); params = params || {}; params.query = params.query || url.query || ''; params.action = params.action || url.action || ''; params.hash = url.hash; } KBreadcrumb.sparrow.last = window.document.location.href.split('#')[1]; window.document.location = window.document.location.href.split('#')[0] + KBreadcrumb.getLink(params); } KBreadcrumb.popHistory = function(nTimes) { if (!nTimes) { nTimes = 1; } var toReturn = []; for ( var i = 0; i != nTimes; i++) { toReturn[i] = '#' + KBreadcrumb.sparrow.history.pop(); } return toReturn; } KBreadcrumb.getHistory = function(offset) { var url = KBreadcrumb.sparrow.history[KBreadcrumb.sparrow.history.length - (offset || 0) - 1]; if (url == null) return; return '#' + url; } KBreadcrumb.getLink = function(params) { if (params.url) { return '#' + params.url; } if (params.hash && KBreadcrumb.sparrow.redirect[params.hash]) { params.hash = KBreadcrumb.sparrow.redirect[params.hash]; } var link = '#' + (params.hash != null ? params.hash : (params.hash == '' ? '' : (KBreadcrumb.sparrow && KBreadcrumb.sparrow.hash != null ? KBreadcrumb.sparrow.hash : ''))); link += (params.query != null ? (params.query == '' ? '' : '/?' + params.query) : (KBreadcrumb.sparrow && KBreadcrumb.sparrow.query != null ? '/?' + KBreadcrumb.sparrow.query : '')); link += (params.action != null ? (params.action == '' ? '' : '/@' + params.action) : (KBreadcrumb.sparrow && KBreadcrumb.sparrow.action != null ? '/@' + KBreadcrumb.sparrow.action : '')); return link; } KBreadcrumb.dispatchURL = function(params) { KBreadcrumb.sparrow.last = window.document.location.href.split('#')[1]; window.document.location = window.document.location.href.split('#')[0] + KBreadcrumb.getLink(params); } KBreadcrumb.dispatchEvent = function(widgetID, params) { if (!params) { params = { hash : KBreadcrumb.getHash(), query : KBreadcrumb.getQuery(), action : KBreadcrumb.getAction() }; } if (params.hash && KBreadcrumb.sparrow.redirect[params.hash]) { params.hash = KBreadcrumb.sparrow.redirect[params.hash]; } if (params.hash != null) { try { KBreadcrumb.sendRegex('location', params.hash, widgetID); } catch (e) { throw new KException(KBreadcrumb.sparrow, e.message); } } if (params.query != null) { try { KBreadcrumb.sendRegex('query', params.query, widgetID); } catch (e) { throw new KException(KBreadcrumb.sparrow, e.message); } } if (params.action != null) { try { KBreadcrumb.sendRegex('action', params.action, widgetID); } catch (e) { throw new KException(KBreadcrumb.sparrow, e.message); } } } KBreadcrumb.processURL = function(current) { if (!current) { current = window.document.location.href.split('#'); } else { current = current.split('#'); } var breadcrumb = new Object(); if (current.length > 1) { breadcrumb.url = current[1]; var hash = breadcrumb.url.split('/?'); if (hash.length > 1) { breadcrumb.hash = hash[0]; breadcrumb.query = hash[1]; var actions = hash[1].split('/@'); if (actions.length > 1) { breadcrumb.query = actions[0]; breadcrumb.action = actions[1]; } } else { breadcrumb.hash = breadcrumb.url; var actions = breadcrumb.hash.split('/@'); if (actions.length > 1) { breadcrumb.hash = actions[0]; breadcrumb.action = actions[1]; } } } return breadcrumb; } KBreadcrumb.sendRegex = function(list, hash, widgetID) { if (list == 'location' && Kinky.site && !Kinky.site.childWidget(hash)) { KBreadcrumb.dispatchEvent(null, { action : '/not-found' }); return; } if (widgetID) { var listenersList = KBreadcrumb.sparrow.byWidget[list][widgetID]; for ( var pattern in listenersList) { if (listenersList[pattern].regex.test(hash)) { for ( var listener in listenersList[pattern].listeners) { KSystem.addTimer('KBreadcrumb.sendEvent(KBreadcrumb.sparrow.byWidget.' + list + '[\'' + widgetID + '\'][\'' + pattern + '\'].listeners[' + listener + '], \'' + hash + '\')', 1); } } } } else { var listenersList = KBreadcrumb.sparrow.listeners[list]; for ( var pattern in listenersList) { if (listenersList[pattern].regex.test(hash)) { for ( var listener in listenersList[pattern].listeners) { if (!listenersList[pattern].listeners[listener].widget || !Kinky.getWidget(listenersList[pattern].listeners[listener].widget.id)) { delete listenersList[pattern].listeners[listener]; continue; } KSystem.addTimer('KBreadcrumb.sendEvent(KBreadcrumb.sparrow.listeners.' + list + '[\'' + pattern + '\'].listeners[' + listener + '], \'' + hash + '\')', 1); } } } } } KBreadcrumb.sendEvent = function(listener, event) { try { listener.widget.fromListener = true; listener.callback(listener.widget, event); } catch (e) { if (Kinky.SHOW_INSTANTIATIONS_ERRORS) { if (Kinky.SHOW_INSTANTIATIONS_ERRORS == 'exception') { throw new Error('KSystem: ' + e + ' on object ' + listener.widget.id + ' with class ' + listener.widget.className); } else { dump('KSystem: ' + e + '
' + JSON.stringify(listener.widget.data) + '
', true); } } } } KBreadcrumb.getLast = function() { return KBreadcrumb.sparrow.last; } KBreadcrumb.getHash = function() { return KBreadcrumb.sparrow.hash; } KBreadcrumb.getQuery = function() { return KBreadcrumb.sparrow.query; } KBreadcrumb.getAction = function() { return KBreadcrumb.sparrow.action; } KBreadcrumb.getURL = function() { return KBreadcrumb.sparrow.url; } KBreadcrumb.onLocationChange = function() { KBreadcrumb.sparrow.processing = true; var breadcrumb = KBreadcrumb.processURL(); if (KBreadcrumb.sparrow.url != breadcrumb.url) { KBreadcrumb.sparrow.history.push(breadcrumb.url); KBreadcrumb.sparrow.url = breadcrumb.url; } else { KBreadcrumb.sparrow.last = KBreadcrumb.sparrow.url; } if (breadcrumb.hash != KBreadcrumb.sparrow.hash) { KBreadcrumb.sparrow.hash = breadcrumb.hash; try { KBreadcrumb.sendRegex('location', breadcrumb.hash); } catch (e) { throw new KException(KBreadcrumb.sparrow, e.message); } } if (breadcrumb.query != KBreadcrumb.sparrow.query) { KBreadcrumb.sparrow.query = breadcrumb.query; try { KBreadcrumb.sendRegex('query', breadcrumb.query); } catch (e) { throw new KException(KBreadcrumb.sparrow, e.message); } } if (breadcrumb.action != KBreadcrumb.sparrow.action) { KBreadcrumb.sparrow.action = breadcrumb.action; try { KBreadcrumb.sendRegex('action', breadcrumb.action); } catch (e) { throw new KException(KBreadcrumb.sparrow, e.message); } } KBreadcrumb.sparrow.processing = false; KSystem.addTimer(KBreadcrumb.onLocationChange, 80); } KBreadcrumb.sparrow = null; KBreadcrumb.DISPATCH_URL = 'url'; KBreadcrumb.DISPATCH_EVENT = 'event'; KIndex.prototype = new KWidget(); KIndex.prototype.constructor = KIndex; function KIndex(parent, id, data) { if (parent != null) { KWidget.call(this, parent); this.topUL = null; this.hash = id; this.data = KSystem.clone(data); this.data.urlHashText = id; this.subIndex = new Object(); this.lastMarked = {}; this.addLocationListener(KIndex.markSelected); } } KIndex.prototype.go = function() { this.draw(); } KIndex.prototype.getPageIndex = function(pageHash) { return this.subIndex[pageHash]; } KIndex.prototype.setMarked = function(hash) { if (this.activated() && this.subIndex[hash]) { this.markIndex(hash); } } KIndex.prototype.markIndex = function(hash) { if (!hash) { return; } var paths = hash.split('/'); paths.splice(0, 1); for ( var level in this.lastMarked) { this.removeCSSClass('KIndexMarked', this.lastMarked[level]); } this.lastMarked = {}; var subHash = ''; for ( var path in paths) { subHash += '/' + paths[path]; if (!this.subIndex[subHash]) { continue; } this.lastMarked[this.subIndex[subHash].name] = this.subIndex[subHash]; this.addCSSClass('KIndexMarked', this.subIndex[subHash]); } } KIndex.prototype.loadIndex = function(page, level, topUL, parent) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; this.subIndex[page.urlHashText] = li; li.appendChild(a); ul = window.document.createElement('ul'); ul.className = 'KIndexLevel' + (level + 1); li.appendChild(ul); topUL.appendChild(li); } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } } KIndex.markSelected = function(widget, hash) { if (widget.activated()) { widget.setMarked(hash); } } KIndex.prototype.clear = function(){ KWidget.prototype.clear.call(this); this.topUL = null; } KIndex.prototype.draw = function() { this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); //this.setMarked(this.getHash()); } KIndex.prototype.tagNames = { html4 : { panel : 'div', contentContainer : 'div', content : 'div', background : 'div', widgetTitle : 'div', paginationBar : 'div' }, html5 : { panel : 'aside', contentContainer : 'div', content : 'nav', background : 'div', widgetTitle : 'header', paginationBar : 'nav' } } KPage.prototype = new KWidget(); KPage.prototype.constructor = KPage; function KPage(parent, url, service) { if (parent != null) { KWidget.call(this, parent); this.breadcrumb = ''; this.level = null; this.height = null; this.hash = url; this.data = { urlHashText : url, feService : service }; this.addLocationListener(KPage.display); this.setStyle( { display : 'none' }); this.alwaysReload = false; this.fetchingBlocks = 0; this.aside = false; } } KPage.prototype.onLoadBlock = function(data) { this.data[data.name] = data; this.fetchingBlocks--; if (this.hash == this.getHash() && this.fetchingBlocks == 0) { this.draw(); } } KPage.prototype.onShow = function() { if (this.noShow) { return false; } if (this.display) { return false; } return KWidget.prototype.onShow.call(this); } KPage.prototype.onHide = function() { if (Kinky.site.childWidget(this.getHash()) && Kinky.site.childWidget(this.getHash()).noShow) { return true; } if (this.display && !this.aside && Kinky.site.childWidget(this.getHash()).aside) { return true; } return KWidget.prototype.onHide.call(this); } KPage.prototype.onLoad = function(data) { for ( var block in data) { if (data[block] && typeof data[block] == 'object') { try { var blockWidget = this.appendChild(KSystem.construct(data[block], this, true)); if (data[block].config) { blockWidget.data.feServiceArgs = data[block]; } } catch (e) { if (data[block].feService && data[block].dynamic == 1) { this.fetchingBlocks++; this.kinky.get(this, data[block].feService, data[block], 'onLoadBlock'); } } } } if (this.hash == this.getHash() && this.fetchingBlocks == 0) { this.draw(); } } KPage.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.data.contentID; if (this.isPaginated) { params.offset = this.nPage * this.perPage; params.limit = this.perPage; } this.kinky.get(this, this.data.feService, params); } KPage.prototype.go = function() { if (this.needAuthentication && Kinky.getLoggedUser() == null) { KBreadcrumb.dispatchURL( { action : '/authentication' }); } else if (this.activated()) { } else { this.load(); } } KPage.prototype.setTitle = function(title, isHTML) { if (typeof title == 'string') { this.data.titleText = title; } KWidget.prototype.setTitle.call(this, title, isHTML); } KPage.prototype.draw = function() { if (!this.simpleWidget) { this.drawWindow(); } this.panel.className += ' ' + this.className + 'Panel' + this.hash.replace(/\//g, '_').toUpperCase(); this.panel.className += ' ' + KSystem.getObjectClass(this) + 'Level' + this.level; if (!this.simpleWidget) { if (this.data.graphicStyle && this.data.graphicStyle.textImages && this.data.graphicStyle.textImages.pageTitle) { this.setTitle(KCSS.img(this.data.graphicStyle.textImages.pageTitle.base), true); } else { this.setTitle(window.document.createTextNode(this.data.titleText), true); } } for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); } KPage.prototype.getURL = function() { return this.targetURL; } KPage.display = function(widget, hash) { if (!widget.activated()) { if (widget.hash == hash) { widget.go(); } return; } if (widget.hash == hash) { KSite.setWindowTitle(widget.parent.breadcrumb + ': ' + widget.breadcrumb); if (!widget.display) { if (widget.alwaysReload) { widget.refresh(); } else { widget.onShow(); } } } else if (widget.hash != hash && widget.display) { widget.onHide(); } } KPage.prototype.tagNames = { html4 : { panel : 'div', contentContainer : 'div', content : 'div', background : 'div', widgetTitle : 'div', paginationBar : 'div' }, html5 : { panel : 'section', contentContainer : 'article', content : 'div', background : 'div', widgetTitle : 'header', paginationBar : 'nav' } } KRedirectPage.prototype = new KPage(); KRedirectPage.prototype.constructor = KRedirectPage; function KRedirectPage(parent, url, service) { if (parent != null) { KPage.call(this, parent, url, service); } } KRedirectPage.prototype.getRedirect = function() { return this.data.redirectUrlHashText || (this.data.pages.length > 0 ? this.data.pages[0].urlHashText : '/'); }; KRedirectPage.prototype.onShow = function() { var pass = 0; if (this.data.redirectUrlHashText == KBreadcrumb.getLast()) { for ( var i = KBreadcrumb.sparrow.history.length - 1; i != 0; i--) { if (KBreadcrumb.sparrow.history[i] == this.hash) { if (pass == 1) { KBreadcrumb.sparrow.history.pop(); KBreadcrumb.back(); return; } pass++; } KBreadcrumb.sparrow.history.pop(); } if (pass == 1) { KBreadcrumb.back(); } } else { KBreadcrumb.dispatchURL({ hash : this.data.redirectUrlHashText }); } }; KRedirectPage.prototype.go = function() { if (!this.data.redirectUrlHashText) { this.data.redirectUrlHashText = this.data.pages[0].urlHashText; } this.activate(); }; KSite.prototype = new KWidget(); KSite.prototype.constructor = KSite; function KSite(parent) { if (parent != null) { KWidget.call(this, parent); this.menu = new Object(); this.header = null; this.footer = null; this.menuService = null; this.homepageURL = null; this.autoLoad = false; this.overlay = window.document.createElement('div'); this.overlay.appendChild(window.document.createTextNode(' ')); this.overlay.className = ' ' + this.className + 'Overlay '; this.setStyle( { width : '100%', height : '100%', position : 'absolute', top : '0', left : '0', display : 'none' }, this.overlay); this.panel.appendChild(this.overlay); this.overlayWidgets = 0; this.addResizeListener(KSite.resize); this.addLocationListener(KSite.go); this.center = { loader : { width : true, height : true } }; this.sitemap = null; } } /* * `Native functions. In most cases, no need to implement or override * ---------------------------------------------------------------------------------------------------- */ KSite.prototype.setPageAutoLoad = function(autoLoad) { this.autoLoad = autoLoad; } KSite.prototype.loadSiteMap = function(data, parentPage, level) { level = level || 1; this.sitemap = data; for ( var section in data) { if (section == 'elements') { continue; } var menuData = { feClass : data[section].feClass, args : { section : section } }; var index = KSystem.construct(menuData, this); if (index) { this.menu[this.appendChild(index).key] = index; } for ( var page in data[section].pages) { var child = KSystem.construct(data[section].pages[page], this); if (child == null) { // dump(data[section].pages[page]); continue; } child.level = level; child.data.section = section; child.breadcrumb = child.data.titleText || ''; if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[section].pages[page].urlHashText = redirect; } else { this.appendChild(child); } child.redirectUrlHashText = redirect; } else { this.appendChild(child); } this.loadPages(data[section].pages[page].pages, child, section, level + 1); } if (index) { index.data = { pages : data[section].pages }; } } } KSite.prototype.loadElements = function(data) { for ( var section in data) { if (section == 'elements') { for ( var element in data[section]) { var child = KSystem.construct(data[section][element], this); this.appendChild(child); } break; } } } KSite.prototype.loadPages = function(data, parentPage, section, level) { for ( var page in data) { var child = KSystem.construct(data[page], this); if (child) { child.level = level; child.data.section = section; child.breadcrumb = parentPage.breadcrumb + ' - ' + (child.data.titleText || ''); if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (!/http:/.test(redirect)) { this.appendChild(child); } child.redirectUrlHashText = redirect; } else { this.appendChild(child); } this.loadPages(data[page].pages, child, section, level + 1); } } } KSite.prototype.appendChild = function(element, context, childDiv) { var elementKey = KWidget.prototype.appendChild.call(this, element, context, childDiv); if (element.aside) { this.panel.appendChild(element.panel); } return elementKey; } KSite.prototype.getMenu = function(hash) { return this.menu[hash]; } KSite.go = function(widget, url) { } KSite.prototype.start = function(homeURL) { this.homepageURL = homeURL; KWidget.loader = new KImage(this, KSite.LOADER_IMAGE); KWidget.loader.addCSSClass('KWidgetLoader'); KWidget.loader.waitForLoad = true; KWidget.loader.onShow = function() { var width = KSystem.normalizePixelValue(this.parent.panel.style.width); if (this.parent.center.loader.width) { this.setStyle({ position : 'fixed', left : Math.round((!width || isNaN(width) ? KSystem.getBrowserWidth() : width) / 2 - this.data.width / 2) + 'px' }); } if (this.parent.center.loader.height) { this.setStyle({ position : 'fixed', top : Math.round(KSystem.getBrowserHeight() / 2 - this.data.height / 2) + 'px' }); } KImage.prototype.onShow.call(this); } KWidget.loader.setStyle({ display : 'none' }); if (this.loaderOnTop) { this.appendChild(KWidget.loader, null, KWidget.ROOT_DIV); } else { this.appendBackgroundChild(KWidget.loader); } this.parentPanel = this.parent; if (this.data.feService != null) { this.load(); } else { this.onLoad(); } this.parentPanel.appendChild(this.panel); } /* * `Functions to override, if needed * ---------------------------------------------------------------------------------------------------- */ KSite.prototype.onLoad = function(data) { this.loadSiteMap(data); this.loadElements(data); this.draw(); } KSite.prototype.draw = function() { if (this.data.titleText) { var title = window.document.createElement('h1'); title.appendChild(window.document.createTextNode(this.data.titleText)); this.widgetTitle.appendChild(title); this.content.appendChild(window.document.createElement('hr')); this.breadcrumb = this.data.titleText; } for ( var element in this.childWidgets()) { if (!(this.childWidget(element) instanceof KPage)) { this.childWidget(element).go(); } } KSystem.addTimer(function() { if (window.document.location.href.indexOf('#') == -1) { if (Kinky.site.homepageURL) { KBreadcrumb.dispatchURL( { hash : Kinky.site.homepageURL }); } } else { KBreadcrumb.dispatchEvent(null, { hash : KBreadcrumb.getHash() }); } }, 500); this.activate(); } KSite.prototype.showOverlay = function() { this.overlayWidgets++; this.setStyle( { display : 'block' }, this.overlay); } KSite.prototype.hideOverlay = function(force) { this.overlayWidgets--; if (this.overlayWidgets <= 0 || force) { this.overlayWidgets = 0; this.setStyle( { display : 'none' }, this.overlay); } } KSite.prototype.load = function() { var params = new Object(); params.contentView = this.data.contentView; params.contentID = this.hash; this.kinky.get(this, this.data.feService, params); } KSite.resize = function(site) { if (site.getWidth() && site.center.loader.width) { KWidget.loader.setStyle({ left : Math.round(site.getWidth() / 2 - KWidget.loader.data.width / 2) + 'px' }); } if (site.getHeight() && site.center.loader.height) { KWidget.loader.setStyle({ top : Math.round(KSystem.getBrowserHeight() / 2 - KWidget.loader.height / 2) + 'px' }); } } KSite.setWindowTitle = function(text) { window.document.title = text; } KSite.OVERLAY_DIV = 'overlay'; KSite.LOADER_IMAGE = '/images/loader.gif'; KSite.prototype.tagNames = { html4 : { panel : 'div', contentContainer : 'div', content : 'div', background : 'div', widgetTitle : 'div', paginationBar : 'div' }, html5 : { panel : 'div', contentContainer : 'div', content : 'div', background : 'div', widgetTitle : 'header', paginationBar : 'nav' } } KBlankPage.prototype = new Object(); KBlankPage.prototype.constructor = KBlankPage; function KBlankPage(parent, url, service) { if (parent != null) { this.panel = window.document.createElement('div'); } } KBlankPage.prototype.onShow = function() { } KBlankPage.prototype.onHide = function() { } KBlankPage.prototype.onLoad = function(data) { } KBlankPage.prototype.load = function() { } KBlankPage.prototype.go = function() { } KBlankPage.prototype.draw = function() { } KBlankPage.prototype.getURL = function() { } KBlankPage.prototype.activated = function() { return true; } KHiddenIndex.prototype = new KIndex(); KHiddenIndex.prototype.constructor = KHiddenIndex; function KHiddenIndex(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); } } KHiddenIndex.prototype.onShow = function() { return; } KHiddenIndex.prototype.markIndex = function() { return; } KHiddenIndex.prototype.loadIndex = function() { return; } KHiddenIndex.prototype.draw = function() { this.activate(); return; } KPageDialog.prototype = new KPage(); KPageDialog.prototype.constructor = KPageDialog; function KPageDialog(parent, url, service) { if (parent != null) { KPage.call(this, parent, url, service); this.window = true; this.buttons = KWidget.CLOSE; this.closeCallback = function(event) { KBreadcrumb.back(); Kinky.site.hideOverlay(true); }; this.minimizeCallback = function(event) { }; this.maximizeCallback = function(event) { }; this.aside = true; } } KPageDialog.prototype.onShow = function() { Kinky.site.showOverlay(); return KPage.prototype.onShow.call(this); } KPageDialog.prototype.onHide = function() { Kinky.site.hideOverlay(); KPage.prototype.onHide.call(this); } KPageDialog.prototype.draw = function() { this.drawWindow( { closeCallback : this.closeCallback, minimizeCallback : this.minimizeCallback, maximizeCallback : this.maximizeCallback }); KPage.prototype.draw.call(this); } KFBOpenGraph.prototype.constructor = KFBOpenGraph; function KFBOpenGraph() { } KFBOpenGraph.queryFB = function(widget, params, callback) { if (!KFBOpenGraph.FB_ACCESS_TOKEN) { KFBOpenGraph.FB_ACCESS_TOKEN = KOAuth.getAccessToken(); } params.id = widget.id; params.callback = callback; KFBOpenGraph.send(params); } KFBOpenGraph.postFB = function(widget, params, callback) { if (!KFBOpenGraph.FB_ACCESS_TOKEN) { KFBOpenGraph.FB_ACCESS_TOKEN = KOAuth.getAccessToken(); } params.args = params.args || {}; params.args.access_token = KFBOpenGraph.FB_ACCESS_TOKEN; Kinky.bunnyMan.get(widget, 'php:Facebook:Post', params, callback); } KFBOpenGraph.send = function(params) { // nao está a aceitar () no url // var url = (params.url || 'https://graph.facebook.com') + (params.hash || '') + '?' + (!params.noToken && KFBOpenGraph.FB_ACCESS_TOKEN ? 'access_token=' + KFBOpenGraph.FB_ACCESS_TOKEN : '') + (params.callback ? '&callback=' + encodeURIComponent('Kinky.getWidget(\'' + params.id + '\').' + params.callback) : '&callback=void'); // var url = (params.url || 'https://graph.facebook.com') + (params.hash || '') + '?' + (!params.noToken && KFBOpenGraph.FB_ACCESS_TOKEN ? 'access_token=' + KFBOpenGraph.FB_ACCESS_TOKEN : '') + (params.callback ? '&callback=' + encodeURIComponent('Kinky.bunnyMan.widgets["' + params.id + '"].' + params.callback) : '&callback=void'); var url = (params.url || 'https://graph.facebook.com') + (params.hash || '') + (!params.noToken && KFBOpenGraph.FB_ACCESS_TOKEN ? '?access_token=' + KFBOpenGraph.FB_ACCESS_TOKEN + '&' : '?') + (params.callback ? 'callback=' + encodeURIComponent('Kinky.bunnyMan.widgets.' + params.id + '.' + params.callback) : 'callback=void'); for ( var index in params.args) { url += '&' + index + '=' + params.args[index]; } var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; head.appendChild(script); } KFBOpenGraph.setAccessToken = function(token) { KFBOpenGraph.FB_ACCESS_TOKEN = token; if (KFBOpenGraph.FB_PERSISTENT_SESSION) { } } KFBOpenGraph.FB_APP_ID = null; KFBOpenGraph.FB_APP_URL = null; KFBOpenGraph.FB_APP_AUTH_URL = null; KFBOpenGraph.FB_ACCESS_TOKEN = null; KFBOpenGraph.FB_PERSISTENT_SESSION = true; KFBConnect.prototype = new KButton(); KFBConnect.prototype.constructor = KFBConnect; KFBConnect.prototype.loadService = false; function KFBConnect(parent) { if (parent != null) { KButton.call(this, parent, '', 'fb-connect', KFBConnect.connect, 'button'); this.addActionListener(KFBConnect.actions, ['/fb-connect']); } } KFBConnect.prototype.go = function() { if (!this.activated()) { this.load(); } else { this.redraw(); } } KFBConnect.prototype.load = function() { KFBOpenGraph.queryFB(this, { hash : '/me', args : { fields : 'id,first_name,last_name,name,link,about,birthday,work,education,email,website,hometown,location,bio,quotes,gender,interested_in,meeting_for,relationship_status,religion,political,verified,significant_other,timezone,picture', type : 'small' } }, 'onLoad'); } KFBConnect.prototype.onError = function(data) { this.draw(); } KFBConnect.prototype.onLoad = function(data) { if (data.error) { } else { Kinky.setLoggedFB(data); this.onAuthorize({ code : Kinky.getLoggedUser() ? 200 : 401 }); } this.draw(); } KFBConnect.prototype.onAuthorize = function(data) { } KFBConnect.connect = function(event) { var button = KSystem.getEventWidget(event); KBreadcrumb.dispatchEvent(button.id, { action : '/fb-connect' }); } KFBConnect.actions = function(widget, action) { if (widget.activated()) { switch (action) { case '/fb-connect': { if (Kinky.getLoggedFB()) { window.open(Kinky.getLoggedFB().link); } else { var url = encodeURIComponent(window.document.location.href); window.document.location = KFBOpenGraph.FB_APP_AUTH_URL + '&redirect_uri=' + url; } break; } } } } KFBLikeMe.prototype = new KPanel(); KFBLikeMe.prototype.constructor = KFBLikeMe; function KFBLikeMe(parent, params) { if (parent != null) { KPanel.call(this, parent); this.hash = '/like-me' + params.fbPageHash; this.data = { hash : params.fbPageHash, url : params.siteURL, lookNFeel : params.lookNFeel, size : params.size }; this.addLocationListener(KFBLikeMe.likeMe); } } KFBLikeMe.prototype.draw = function() { this.onChangeURL(this.data.hash); this.setStyle({ width : this.data.size.width + 'px', height : this.data.size.height + 'px', overflow : 'hidden' }); KPanel.prototype.draw.call(this); } KFBLikeMe.prototype.onChangeURL = function(hash) { this.content.innerHTML = ''; } KFBLikeMe.likeMe = function(widget, hash) { if (widget.activated()) { widget.onChangeURL(hash); } } KFBLikeMe.LOOK_N_FEEL = { STANDARD : 'standard', BUTTON_COUNT : 'button_count', BOX_COUNT : 'box_count' } KFBShare.prototype = new KWidget(); KFBShare.prototype.constructor = KFBShare; KFBShare.prototype.loadService = false; function KFBShare(parent, params) { if (parent != null) { this.simpleWidget = true; KWidget.call(this, parent); this.type = params.type; this.url = params.url; } } KFBShare.prototype.go = function() { this.draw(); } KFBShare.prototype.draw = function() { var a = window.document.createElement('a'); a.name = 'fb_share'; a.setAttribute('type', this.type); a.setAttribute('share_url', this.url); this.content.appendChild(a); var include = window.document.createElement('script'); include.src = 'http://static.ak.fbcdn.net/connect.php/js/FB.Share'; this.content.appendChild(include); this.activate(); } KFBWallFeed.prototype = new KPanel(); KFBWallFeed.prototype.constructor = KFBWallFeed; function KFBWallFeed(parent, params) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; this.minimized = false; this.hash = '/wall-feed' + params.fbPageHash; this.data = { hash : params.fbPageHash, url : params.siteURL, postsPerPage : params.postsPerPage, maxPostLength : params.maxPostLength, autoRefresh : params.autoRefresh, hasMinimize : params.hasMinimize, hasLike : params.hasLike, hasShare : params.hasShare }; } } KFBWallFeed.prototype.load = function() { KFBOpenGraph.queryFB(this, { noToken : true, hash : this.data.hash }, 'onLoad'); } KFBWallFeed.prototype.onLoad = function(data) { KSystem.merge(this.data, data); this.draw(); } KFBWallFeed.prototype.draw = function() { this.appendTitleText('
  Likes: ' + this.data.likes + '
', true); if (this.data.hasLike) { this.likeDiv = window.document.createElement('div'); this.likeDiv.innerHTML = ''; KCSS.setStyle({ width : '100px', height : '26px', overflow : 'hidden' }, [ this.likeDiv ]); this.likeDiv.addCSSClass('KFBWallFeedShareButton'); this.widgetTitle.appendChild(this.likeDiv); this.addLocationListener(KFBWallFeed.likeMe); } if (this.data.hasShare) { var share = new KButton(this, '', 'share-button', KFBWallFeed.shareMe); share.addCSSClass('KFBWallFeedShareButton'); this.appendTitleChild(share); } this.clearBoth(KWidget.TITLE_DIV); this.list = new KFBWallFeedList(this, this.data.postsPerPage, this.data.hash, this.data.autoRefresh, this.data.maxPostLength); this.appendChild(this.list); KPanel.prototype.draw.call(this); } KFBWallFeed.likeMe = function(widget, hash) { if (widget.activated()) { widget.likeDiv.innerHTML = ''; } } KFBWallFeed.shareMe = function(event) { var widget = KSystem.getEventWidget(event); window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(widget.data.url.substr(0, widget.data.url.length - 1) + widget.getHash()) + '&src=sp'); } KFBWallFeed.minimizeMe = function(event, bar) { var widget = bar || KSystem.getEventWidget(event).parent; if (widget.minimized) { widget.pos = widget.pos - 100; KSystem.setCookie('wallFeedDisplay', { display : 'true' }); } else { widget.pos = widget.pos + 100; KSystem.setCookie('wallFeedDisplay', { display : 'false' }); } KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'move', duration : 500, lock : { x : true }, go : { y : widget.pos }, onComplete : function(widget, tween) { widget.minimized = !widget.minimized; if (widget.minimized) { widget.minimizeButton.setStyle({ backgroundPosition : '-190px -157px' }, KButton.BUTTON_ELEMENT); widget.minimizeButton.setHelpText('maximizar barra'); } else { widget.minimizeButton.setStyle({ backgroundPosition : '-116px -157px' }, KButton.BUTTON_ELEMENT); widget.minimizeButton.setHelpText('minimizar barra'); } } }); } KFBWallFeedList.prototype = new KList(); KFBWallFeedList.prototype.constructor = KFBWallFeedList; function KFBWallFeedList(parent, perPage, hash, autoRefresh, maxPostLength) { if (parent != null) { KList.call(this, parent); this.perPage = perPage; this.facebookOffset = 0; this.postData = new Array(); this.paginationDispatchType = KBreadcrumb.DISPATCH_URL; this.hash = parent.hash + '/list'; this.pageHash = hash; this.autoRefresh = autoRefresh; this.maxPostLength = maxPostLength; if (this.autoRefresh) { this.setStyle({ display : 'none' }, KWidget.PAGINATION_DIV); } } } KFBWallFeedList.prototype.load = function() { KFBOpenGraph.queryFB(this, { hash : this.pageHash + '/feed', noToken : true, args : { limit : this.perPage, offset : this.facebookOffset } }, 'onLoad'); } KFBWallFeedList.prototype.onLoad = function(data) { if (this.autoRefresh) { for ( var postNr in data.data) { var post = data.data[postNr]; if (!this.childWidget(this.hash + '/item/' + post.id)) { var date = KSystem.parseDate('Y-m-d H:i:s 0000', post.created_time.replace(/T|\+/g, ' ')); var item = new KComment(this, { urlHashText : this.hash + '/item/' + post.id, feClass : 'KComment', type : 'comment', user : { photo : [ post.picture || 'https://graph.facebook.com/' + post.from.id + '/picture' ] }, info : { titleHTML : '' + post.from.name + '', descriptionHTML : '' + KSystem.formatDate('DD, d/MM \u00e0%s H:i', date) + '' + (post.message ? post.message.replace(/<3/g, '♥').substr(0, this.maxPostLength) + (post.message.length > this.maxPostLength ? ' (...)' : '') + '' : '') + (post.description ? '' + post.description.replace(/<3/g, '♥').substr(0, this.maxPostLength) + (post.description.length > this.maxPostLength ? ' (...)' : '') + '' : '') + '' + (post.comments ? post.comments.count : 0) + ' comentário(s) • ' + (post.likes ? post.likes.count : 0) + ' like(s)' } }); item.hash = this.hash + '/item/' + post.id; item.setStyle({ opacity : '0' }); item.onShow = function() { KComment.prototype.onShow.call(this); KEffects.addEffect(this, { f : KEffects.easeOutExpo, type : 'fade', duration : 3000, realAlpha : true, from : { alpha : 0 }, go : { alpha : 1 } }); }; if (this.activated()) { var firstChild = this.childAt(0); var lastChild = this.childAt(this.perPage); this.removeChild(lastChild); this.insertBefore(item, '0', firstChild); item.go(); } else { this.appendChild(item); } } } if (data.data.length == 0) { KBreadcrumb.dispatchEvent(this.id, { action : '/no-content' }); } if (!this.activated()) { KList.prototype.draw.call(this); } var id = this.id; KSystem.addTimer(function() { Kinky.getWidget(id).load(); }, this.autoRefresh); } else { this.facebookOffset += this.perPage; for ( var postNr in data.data) { var post = data.data[postNr]; var date = KSystem.parseDate('Y-m-d H:i:s 0000', post.created_time.replace(/T|\+/g, ' ')); this.postData.push({ urlHashText : this.hash + '/item/' + post.id, feClass : 'KComment', type : 'comment', user : { photo : [ post.picture || 'https://graph.facebook.com/' + post.from.id + '/picture' ] }, info : { titleHTML : '' + post.from.name + '', descriptionHTML : '' + KSystem.formatDate('DD, d/MM \u00e0%s H:i', date) + '' + (post.message ? post.message.replace(/<3/g, '♥').substr(0, this.maxPostLength) + (post.message.length > this.maxPostLength ? ' (...)' : '') + '' : '') + (post.description ? '' + post.description.replace(/<3/g, '♥').substr(0, this.maxPostLength) + (post.description.length > this.maxPostLength ? ' (...)' : '') + '' : '') + '' + (post.comments ? post.comments.count : 0) + ' comentário(s) • ' + (post.likes ? post.likes.count : 0) + ' like(s)' } }); } if (data.data.length == 0) { KBreadcrumb.dispatchEvent(this.id, { action : '/no-content' }); } KList.prototype.onLoad.call(this, this.postData); this.postData = new Array(); this.totalCount = null; } } KFBWallFeedList.prototype.onPreviousPage = function() { KList.prototype.onPreviousPage.call(this); } KFBWallFeedList.prototype.onNextPage = function() { KList.prototype.onNextPage.call(this); } BCMicroSite.prototype = new KSite(); BCMicroSite.prototype.constructor = BCMicroSite; BCMicroSite.activeUser = null; BCMicroSite.dialogWindow = null; function BCMicroSite(parent) { if (parent != null) { KSite.call(this, parent); BCMicroSite.productPageHash = null; this.addCSSClass('BCMicroSite_' + Kinky.BASE_VERSION.replace('/', '')); this.footer = null; this.contentHeight = 0; this.theme = 'none'; this.colors = {}; this.colors.background = '#FFFFFF'; this.colors.menuColor1 = '#000000'; this.colors.menuColor2 = '#000000'; this.colors.subMenuColor1 = '#000000'; this.colors.subMenuColor2 = '#000000'; this.colors.textColor = '#000000'; this.colors.titleColor1 = '#000000'; this.colors.titleColor2 = '#000000'; this.colors.titleColor3 = '#000000'; this.colors.titleColor4 = '#000000'; this.colors.footerMenuColor1 = '#FFFFFF'; this.colors.footerMenuColor2 = '#8B87A4'; this.backgroundSite = new KPanel(this); this.backgroundSite.addCSSClass('BCMicrositeBackground'); this.backgroundSite.hash = '/backgroundSite'; this.backgroundSite.changeContext('/'); this.appendChild(this.backgroundSite, null, KWidget.BACKGROUND_DIV); this.backgroundPage = new KPanel(this); this.backgroundPage.addCSSClass('BCMicrositeBackground'); this.backgroundPage.hash = '/backgroundPage'; this.backgroundPage.changeContext('/'); this.appendChild(this.backgroundPage, null, KWidget.BACKGROUND_DIV); this.loadTranslations(); BCMicroSite.dialogWindow = new KDialog(this); BCMicroSite.dialogWindow.addCSSClass('DialogWindow'); BCMicroSite.dialogWindow.buttons = KWidget.CLOSE; BCMicroSite.dialogWindow.type = KDialog.MODAL | KDialog.CENTERED; BCMicroSite.dialogWindow.buttonLabel = this.translations.buttonLabel; BCMicroSite.dialogWindow.params = {}; BCMicroSite.dialogWindow.effects = { enter : { f : KEffects.linear, type : 'move', duration : 200, go : { y : 110 }, lock : { x : true }, onStart : function(widget, tween) { tween.go.y = 200 + (window.pageYOffset ? window.pageYOffset : document.body.scrollTop); } }, exit : { f : KEffects.linear, type : 'move', duration : 200, go : { y : -this.getHeight() }, lock : { x : true }, onStart : function(widget, tween) { tween.go.y = -widget.getHeight() - 500; } } }; BCMicroSite.dialogWindow.setStyle({ overflow : 'visible', clear : 'both' }); BCMicroSite.dialogWindow.onShow = function() { BCMicroSite.dialogWindow.okBt.setText(BCMicroSite.dialogWindow.buttonLabel); BCMicroSite.dialogWindow.okBt.setStyle({ left : (115 - BCMicroSite.dialogWindow.okBt.panel.offsetWidth / 2) + 'px' }); this.setStyle({ left : (KSystem.getBrowserWidth() / 2) + 'px' }); KDialog.prototype.onShow.call(this); }; BCMicroSite.dialogWindow.draw = function() { if (!this.activated()) { BCMicroSite.dialogWindow.okBt = new BCKButton(this, BCMicroSite.dialogWindow.buttonLabel, 'closeBt', BCMicroSite.dialogCloseHandler); this.appendChild(BCMicroSite.dialogWindow.okBt); BCMicroSite.dialogWindow.okBt.go(); } KDialog.prototype.draw.call(this); }; this.addActionListener(BCMicroSite.serverError); this.addLocationListener(BCMicroSite.analytics); this.widgets = new Object(); this.breadcrumb = 'Biocol'; this.addWindowResizeListener(BCMicroSite.windowResize); } } BCMicroSite.prototype.onLoad = function(data) { this.loadSiteMap(data); this.loadElements(data); var params = { contentView : 'Page(page_path)', contentID : BCMicroSite.homepageContentID }; this.kinky.get(this, this.childWidget('/homepage').data.feService, params, 'onLoadSocialData'); }; BCMicroSite.prototype.onLoadSocialData = function(data) { try { Kinky.GOOGLE_ANALYTICS = data.configuracoesDeMicrosite.config.analytics; BCMicroSite.twitter = data.configuracoesDeMicrosite.config.twitter; } catch (e) { } this.draw(); }; BCMicroSite.dialogCloseHandler = function(widget) { if (BCMicroSite.dialogWindow.params.type == 1) { KBreadcrumb.back(); } KDialog.close(null, BCMicroSite.dialogWindow); }; BCMicroSite.prototype.loadSiteMap = function(data, parentPage, level) { level = level || 1; this.sitemap = data; for ( var section in data) { if (section == 'elements') { continue; } var menuData = { feClass : data[section].feClass, args : { section : section } }; var index = KSystem.construct(menuData, this); if (index) { this.menu[this.appendChild(index).key] = index; } for ( var page in data[section].pages) { var child = KSystem.construct(data[section].pages[page], this); if (child == null) { continue; } child.level = level; child.data.section = section; child.breadcrumb = child.data.titleText || ''; if (data[section].pages[page].urlHashText == this.homepageURL) { BCMicroSite.homepageContentID = data[section].pages[page].contentID; } if (data[section].pages[page].template == 12) { BCMicroSite.productPageHash = data[section].pages[page].urlHashText; } this.addBackgrounds(child); if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[section].pages[page].urlHashText = redirect; } else { this.appendChild(child); } child.redirectUrlHashText = redirect; } else { this.appendChild(child); } this.loadPages(data[section].pages[page].pages, child, section, level + 1); } if (index) { index.data = { pages : data[section].pages }; } } }; BCMicroSite.prototype.loadPages = function(data, parentPage, section, level) { for ( var page in data) { var child = KSystem.construct(data[page], this); if (child) { child.level = level; child.data.section = section; child.breadcrumb = parentPage.breadcrumb + ' - ' + (child.data.titleText || ''); this.addBackgrounds(child); if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[page].urlHashText = redirect; } else { this.appendChild(child); } child.redirectUrlHashText = redirect; } else { this.appendChild(child); } this.loadPages(data[page].pages, child, section, level + 1); } } }; BCMicroSite.prototype.addBackgrounds = function(child) { if (child.data.graphicStyle && child.data.graphicStyle.images && child.data.graphicStyle.images.length != 0) { for ( var image in child.data.graphicStyle.images) { if (child.data.graphicStyle.images[image].stateCode == 'Background Site') { var backSite = new KImage(this.backgroundSite, child.data.graphicStyle.images[image].fileInternalPath); backSite.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 1000, go : { alpha : 1 }, from : { alpha : 0 } } }; backSite.addCSSClass('BCMicrositeBackgroundImage'); backSite.waitForLoad = true; backSite.onShow = function() { this.parent.width = this.data.width; this.setStyle({ width : this.data.width + 'px', opacity : '0' }); this.parent.setStyle({ width : this.data.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.backgroundSite.appendChild(backSite, child.hash); } else if (child.data.graphicStyle.images[image].stateCode == 'Background Pagina') { var backPage = new KImage(this.backgroundPage, child.data.graphicStyle.images[image].fileInternalPath); backPage.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 1000, go : { alpha : 1 }, from : { alpha : 0 } } }; backPage.addCSSClass('BCMicrositeBackgroundImage'); backPage.waitForLoad = true; backPage.onShow = function() { this.parent.width = this.data.width; this.setStyle({ width : this.data.width + 'px', opacity : '0' }); this.parent.setStyle({ width : this.data.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.backgroundPage.appendChild(backPage, child.hash); } } } }; BCMicroSite.prototype.draw = function() { this.colors.background = this.data.graphicStyle.colors.background.background; this.colors.menuColor1 = this.data.graphicStyle.colors.menuColor1.text; this.colors.menuColor2 = this.data.graphicStyle.colors.menuColor2.text; this.colors.subMenuColor1 = this.data.graphicStyle.colors.subMenuColor1.text; this.colors.subMenuColor2 = this.data.graphicStyle.colors.subMenuColor2.text; this.colors.textColor = this.data.graphicStyle.colors.textColor.text; this.colors.titleColor1 = this.data.graphicStyle.colors.titleColor1.text; this.colors.titleColor2 = this.data.graphicStyle.colors.titleColor2.text; this.colors.titleColor3 = this.data.graphicStyle.colors.titleColor3.text; this.colors.titleColor4 = this.data.graphicStyle.colors.titleColor4.text; this.colors.footerMenuColor1 = this.data.graphicStyle.colors.footerMenuColor1.text; this.colors.footerMenuColor2 = this.data.graphicStyle.colors.footerMenuColor2.text; var leftPanel = new BCLeftPanel(this); this.appendChild(leftPanel); var productPagesMenu = new BCProductPagesMenu(this); this.appendChild(productPagesMenu, null, KWidget.CONTENT_DIV); var contestPagesMenu = new BCContestPagesMenu(this); this.appendChild(contestPagesMenu, null, KWidget.CONTENT_DIV); var fbLikeProducts = new KFBLikeMe(this, { fbPageHash : '/produtos', siteURL : Kinky.SITE_URL, lookNFeel : KFBLikeMe.LOOK_N_FEEL.BUTTON_COUNT, size : { width : 72, height : 25 } }); fbLikeProducts.addCSSClass('BCFbLikeSite'); fbLikeProducts.onChangeURL = function(hash) { var reg_exp = new RegExp(BCMicroSite.productPageHash); if (reg_exp.test(hash) && hash.split('/')[2]) { var splited = hash.split('/'); var hashToShare = '/' + Kinky.DEFAULT_LANG + '/' + splited[1] + '/' + splited[2]; if (hashToShare != this.lastHashToShare) { KFBLikeMe.prototype.onChangeURL.call(this, hashToShare); this.onShow(); this.lastHashToShare = hashToShare; } } else { this.onHide(); } }; fbLikeProducts.onShow = function() { var reg_exp = new RegExp(BCMicroSite.productPageHash); if (!reg_exp.test(this.getHash())) { return; } KWidget.prototype.onShow.call(this); }; this.appendChild(fbLikeProducts); var fbLikeHomepage = new KFBLikeMe(this, { fbPageHash : '/' + Kinky.DEFAULT_LANG + '/', siteURL : Kinky.SITE_URL, lookNFeel : KFBLikeMe.LOOK_N_FEEL.STANDARD, size : { width : 300, height : 60 } }); fbLikeHomepage.addCSSClass('BCFbLikeHomepage'); fbLikeHomepage.onChangeURL = function(hash) { if (/homepage/.test(hash)) { var hashToShare = '/' + (Kinky.DEFAULT_LANG != 'pt' ? Kinky.DEFAULT_LANG + '/' : ''); KFBLikeMe.prototype.onChangeURL.call(this, hashToShare); this.onShow(); } else { this.onHide(); } }; fbLikeHomepage.onShow = function() { if (!/homepage/.test(this.getHash())) { return; } KWidget.prototype.onShow.call(this); }; this.appendChild(fbLikeHomepage); var transparency = new KPanel(this); transparency.addCSSClass('Transparency'); this.appendTitleChild(transparency); var titlePanel = new KPanel(this); titlePanel.addCSSClass('HeaderElements'); { titlePanel.hash = '/titlePanel'; titlePanel.setStyle({ overflow : 'visible' }); this.setStyle({ backgroundColor : this.colors.background }); if (this.data.graphicStyle && this.data.graphicStyle.images && this.data.graphicStyle.images.length != 0) { for ( var image in this.data.graphicStyle.images) { if (this.data.graphicStyle.images[image].stateCode == 'Logo') { var logoBC = new KLink(titlePanel, '#' + Kinky.HOMEPAGE_URL, this.data.graphicStyle.images[image].fileInternalPath); logoBC.addCSSClass('BCMicrositeLogo'); titlePanel.appendTitleChild(logoBC); } else if (this.data.graphicStyle.images[image].stateCode == 'Microsite Theme') { this.theme = this.data.graphicStyle.images[image].fileInternalPath; } else if (this.data.graphicStyle.images[image].stateCode == 'Background Site') { var backSite = new KImage(this.backgroundSite, this.data.graphicStyle.images[image].fileInternalPath); backSite.addCSSClass('BCMicrositeBackgroundImage'); backSite.waitForLoad = true; backSite.onShow = function() { this.parent.width = this.data.width; this.setStyle({ width : this.data.width + 'px' }); this.parent.setStyle({ width : this.data.width + 'px', left : Math.round((KSystem.getBrowserWidth() - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.backgroundSite.appendChild(backSite); } else if (this.data.graphicStyle.images[image].stateCode == 'Background Footer') { this.childWidget('menuFooter').setStyle({ backgroundImage : 'url(' + this.data.graphicStyle.images[image].fileInternalPath + ')' }); } } } var languagePanel = new BCLangCombo(titlePanel); languagePanel.addCSSClass('LanguagePanel'); titlePanel.appendChild(languagePanel); } this.appendTitleChild(titlePanel); KSite.prototype.draw.call(this); titlePanel.appendTitleChild(this.childWidget('menuPrincipal')); // MENUS this.footer = this.childWidget('menuFooter').panel; this.contentContainer.appendChild(this.footer); this.footerEsquerda = this.childWidget('menuFooterEsquerda').topUL; this.childWidget('menuFooter').content.appendChild(this.footerEsquerda); this.appendChild(BCMicroSite.dialogWindow); BCMicroSite.dialogWindow.setStyle({ backgroundImage : 'url(' + this.theme + ')' }); this.content.appendChild(KCSS.clearBoth()); this.clearBoth(KWidget.TITLE_DIV); this.resizeHeight(this, null); this.resizeWidth(this, null); }; BCMicroSite.prototype.resizeSite = function(size) { this.contentHeight = size.height; this.resizeHeight(this, size.height); this.resizeWidth(this, size.width); }; BCMicroSite.windowResize = function(site, size) { site.resizeHeight(site, size.height); site.resizeWidth(site, size.width); }; BCMicroSite.prototype.resizeHeight = function(site, height) { if (height != null) { var titleHeight = 250; site.setStyle({ height : Math.max(KSystem.getBrowserHeight(), this.contentHeight + titleHeight) + 'px' }, [ KWidget.CONTAINER_DIV, KWidget.CONTENT_DIV ]); } KCSS.setStyle({ top : (KSystem.getBrowserHeight() - 37) + 'px' }, [ site.footer ]); site.childWidget('/newsletter').setStyle({ top : (KSystem.getBrowserHeight() - 190) + 'px' }); }; BCMicroSite.prototype.resizeWidth = function(site, width) { site.setStyle({ width : KSystem.getBrowserWidth() + 'px' }, KWidget.BACKGROUND_DIV); site.backgroundPage.setStyle({ left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - (site.backgroundPage.width != null ? site.backgroundPage.width : site.backgroundPage.getWidth())) / 2) + 'px' }); site.backgroundSite.setStyle({ left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - (site.backgroundSite.width != null ? site.backgroundSite.width : site.backgroundSite.getWidth())) / 2) + 'px' }); site.childWidget('/newsletter').setStyle({ left : (KSystem.getBrowserWidth() / 2) + 265 + 'px' }); }; BCMicroSite.serverError = function(widget, action) { if (action != '/error') { return; } dump(widget.childWidget(widget.getHash()).error.description, true); }; BCMicroSite.analytics = function(widget, something) { if (something == '') { return; } try { this.pageTracker._trackPageview(widget.getURL().replace(/\/\?|\/@/g, '')); } catch (err) { try { this.pageTracker = _gat._getTracker(Kinky.GOOGLE_ANALYTICS); this.pageTracker._trackPageview(widget.getURL().replace(/\/\?|\/@/g, '')); } catch (err2) { debug(err2); } } }; BCPage.prototype = new KPage(); BCPage.prototype.constructor = BCPage; function BCPage(parent) { if (parent != null) { this.overflow = 'visible'; KPage.call(this, parent); this.addCSSClass('BCPage'); this.addCSSClass('BCPageBackground', KWidget.BACKGROUND_DIV); this.addCSSClass('BCPageTitle', KWidget.TITLE_DIV); this.setStyle({ display : 'none' }); this.subtitle = null; this.addResizeListener(BCPage.resize); this.graphicStyle = null; this.translations = {}; this.waitForLoad = true; this.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : BCPage.FADE_DURATION, go : { alpha : 1 }, from : { alpha : 0 } } }; } } BCPage.prototype.loadTranslations = function() { }; BCPage.prototype.getTranslation = function(widgetClass) { if (this.translations[widgetClass]) { return this.translations[widgetClass]; } }; BCPage.prototype.onLoad = function(data) { var siteGraphicStyle = this.parent.data.graphicStyle; this.graphicStyle = this.data.graphicStyle; this.graphicStyle.colors.background = siteGraphicStyle.colors.background; this.graphicStyle.colors.menuColor1 = siteGraphicStyle.colors.menuColor1; this.graphicStyle.colors.menuColor2 = siteGraphicStyle.colors.menuColor2; this.graphicStyle.colors.subMenuColor1 = siteGraphicStyle.colors.subMenuColor1; this.graphicStyle.colors.subMenuColor2 = siteGraphicStyle.colors.subMenuColor2; this.graphicStyle.colors.textColor = siteGraphicStyle.colors.textColor; this.graphicStyle.colors.titleColor1 = siteGraphicStyle.colors.titleColor1; this.graphicStyle.colors.titleColor2 = siteGraphicStyle.colors.titleColor2; this.graphicStyle.colors.titleColor3 = siteGraphicStyle.colors.titleColor3; this.graphicStyle.colors.titleColor4 = siteGraphicStyle.colors.titleColor4; this.graphicStyle.colors.footerMenuColor1 = siteGraphicStyle.colors.footerMenuColor1.text; this.graphicStyle.colors.footerMenuColor2 = siteGraphicStyle.colors.footerMenuColor2.text; this.setStyle({ color : Kinky.site.colors.titleColor1 }, KWidget.TITLE_DIV); this.loadTranslations(); KSystem.merge(this.data, data); KPage.prototype.onLoad.call(this, data); }; BCPage.prototype.onShow = function() { if (this.display) { return; } this.setStyle({ opacity : 0 }); if (KPage.prototype.onShow.call(this)) { this.changeBackgrounds(this.hash); } }; BCPage.prototype.onHide = function() { if (this.display && Kinky.site.childWidget(this.getHash()) instanceof KPageDialog) { return; } if (!KPage.prototype.onHide.call(this)) { this.setStyle({ opacity : '0' }); this.prepareBackgrounds(this.getHash()); } }; BCPage.prototype.changeBackgrounds = function(hash_to_activate) { var backgroundSite = Kinky.site.childWidget('/backgroundSite'); var backgroundPage = Kinky.site.childWidget('/backgroundPage'); var backSiteOk = false; var backPageOk = false; while (!backSiteOk || !backPageOk) { if (!backSiteOk) { var bg_site_child = backgroundSite.childWidgets(hash_to_activate); if (bg_site_child != null) { for ( var element in bg_site_child) { bg_site_child = bg_site_child[element]; } if (backgroundSite.getContext() != hash_to_activate) { backgroundSite.hideContext(); backgroundSite.changeContext(hash_to_activate); if (bg_site_child instanceof KImage && bg_site_child.data != null) { backgroundSite.width = bg_site_child.data.width; } backgroundSite .setStyle({ width : backgroundSite.width + 'px', left : Math .round((Math.max(960, KSystem .getBrowserWidth()) - backgroundSite.width) / 2) + 'px' }); backgroundSite.showContext(); } backSiteOk = true; } } if (!backPageOk) { var bg_page_child = backgroundPage.childWidgets(hash_to_activate); if (bg_page_child != null) { for ( var element in bg_page_child) { bg_page_child = bg_page_child[element]; } if (backgroundPage.getContext() != hash_to_activate) { backgroundPage.hideContext(); backgroundPage.changeContext(hash_to_activate); if (bg_page_child instanceof KImage && bg_page_child.data != null) { backgroundPage.width = bg_page_child.data.width; } else if (bg_page_child instanceof BCGallery) { backgroundPage.width = bg_page_child.getWidth(); } backgroundPage .setStyle({ width : backgroundPage.width + 'px', left : Math .round((Math.max(960, KSystem .getBrowserWidth()) - backgroundPage.width) / 2) + 'px' }); backgroundPage.showContext(); } backPageOk = true; } } if (hash_to_activate == '/' || hash_to_activate == '') break; if (!backSiteOk || !backPageOk) { hash_to_activate = hash_to_activate.substring(0, hash_to_activate .lastIndexOf('/')); if (hash_to_activate == '') hash_to_activate = '/'; } } if (!backSiteOk) { backgroundSite.hideContext(); backgroundSite.changeContext('/hidden'); } if (!backPageOk) { backgroundPage.hideContext(); backgroundPage.changeContext('/hidden'); } }; BCPage.prototype.prepareBackgrounds = function(hash_to_activate) { var backgroundSite = Kinky.site.childWidget('/backgroundSite'); var backgroundPage = Kinky.site.childWidget('/backgroundPage'); var backSiteOk = false; var backPageOk = false; while (!backSiteOk || !backPageOk) { if (!backSiteOk) { var bg_site_child = backgroundSite.childWidgets(hash_to_activate); if (bg_site_child != null) { for ( var element in bg_site_child) { bg_site_child = bg_site_child[element]; } if (backgroundSite.getContext() != hash_to_activate) { //backgroundSite.hideContext(); } backSiteOk = true; } } if (!backPageOk) { var bg_page_child = backgroundPage.childWidgets(hash_to_activate); if (bg_page_child != null) { for ( var element in bg_page_child) { bg_page_child = bg_page_child[element]; } if (backgroundPage.getContext() != hash_to_activate) { backgroundPage.hideContext(); } backPageOk = true; } } if (hash_to_activate == '/' || hash_to_activate == '') break; if (!backSiteOk || !backPageOk) { hash_to_activate = hash_to_activate.substring(0, hash_to_activate .lastIndexOf('/')); if (hash_to_activate == '') hash_to_activate = '/'; } } // if (!backSiteOk) { // backgroundSite.hideContext(); // backgroundSite.changeContext('/hidden'); // } if (!backPageOk) { backgroundPage.hideContext(); backgroundPage.changeContext('/hidden'); } }; BCPage.prototype.draw = function(data) { this.setStyle({ opacity : '0' }); KPage.prototype.draw.call(this); if (this.data.description) { var subText = window.document.createElement('div'); subText.className = 'PageSubtitle'; subText.innerHTML = this.data.description; this.childDiv(KWidget.TITLE_DIV).appendChild(subText); } this.clearBoth(); }; BCPage.resize = function(page, size) { Kinky.site.resizeSite(size); }; BCPage.FADE_DURATION = 1000; BCProfessionalArea.prototype = new KSite(); BCProfessionalArea.prototype.constructor = BCProfessionalArea; BCProfessionalArea.activeUser = null; function BCProfessionalArea(parent) { if (parent != null) { KSite.call(this, parent); this.footer = null; this.contentHeight = 0; this.addActionListener(BCSite.serverError); this.addLocationListener(BCSite.analytics); this.breadcrumb = 'Biocol'; this.addWindowResizeListener(BCProfessionalArea.windowResize); } } BCProfessionalArea.prototype.loadSiteMap = function(data, parentPage, level) { level = level || 1; this.sitemap = data; for ( var section in data) { if (section == 'elements') { continue; } var menuData = { feClass : data[section].feClass, args : { section : section } }; // var index = KSystem.construct(menuData, this); // if (index) { // this.menu[this.appendChild(index).key] = index; // } for ( var page in data[section].pages) { var child = KSystem.construct(data[section].pages[page], this); if (child == null) { continue; } child.level = level; child.data.section = section; child.breadcrumb = child.data.titleText || ''; if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[section].pages[page].urlHashText = redirect; } else { this.appendChild(child); } } else { this.appendChild(child); } this.loadPages(data[section].pages[page].pages, child, section, level + 1); } // // if (index) { // index.data = { // pages : data[section].pages // }; // } } } BCProfessionalArea.prototype.loadPages = function(data, parentPage, section, level) { for ( var page in data) { var child = KSystem.construct(data[page], this); if (child) { child.level = level; child.data.section = section; child.breadcrumb = parentPage.breadcrumb + ' - ' + (child.data.titleText || ''); if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[page].urlHashText = redirect; } else { this.appendChild(child); } } else { this.appendChild(child); } this.loadPages(data[page].pages, child, section, level + 1); } } } BCProfessionalArea.prototype.draw = function() { KSite.prototype.draw.call(this); var logo = new KImage(this, '/images/professional_area_logo.png'); this.widgetTitle.appendChild(logo.panel); logo.go(); this.footer = new KPanel(this); this.footer.addCSSClass('BCProfessionalAreaFooter'); var footerText = new KText(this.footer); footerText.setText('Lorem Ipsum'); this.footer.appendChild(footerText); footerText.go(); this.panel.appendChild(this.footer.panel); this.content.appendChild(KCSS.clearBoth()); this.clearBoth(KWidget.TITLE_DIV); this.resizeHeight(this, null); } BCProfessionalArea.prototype.resizeSite = function(size) { this.contentHeight = size.height; this.resizeHeight(this, size.height); } BCProfessionalArea.windowResize = function(site, size) { site.resizeHeight(site, size.height); } BCProfessionalArea.prototype.resizeHeight = function(site, height) { if(height != null) { var titleHeight = 80; var footerHeight = 100; site.setStyle( { height : Math.max(KSystem.getBrowserHeight(), height + titleHeight + footerHeight) + 'px' }); } } BCProfessionalArea.serverError = function(widget, action) { if (action != '/error') { return; } dump(widget.childWidget(widget.getHash()).error.description, true); } BCProfessionalArea.analytics = function(widget, something) { if (something == '') { return; } try { this.pageTracker._trackPageview(widget.getURL().replace(/\/\?|\/@/g, '')); } catch (err) { try { this.pageTracker = _gat._getTracker(Kinky.GOOGLE_ANALYTICS); this.pageTracker._trackPageview(widget.getURL().replace(/\/\?|\/@/g, '')); } catch (err) { } } } BCProfessionalAreaPage.prototype = new KPage(); BCProfessionalAreaPage.prototype.constructor = BCProfessionalAreaPage; BCProfessionalAreaPage.prototype.heightFix = 0; function BCProfessionalAreaPage(parent) { if (parent != null) { this.overflow = 'visible'; KPage.call(this, parent); this.addCSSClass('BCProfessionalAreaPage'); this.setStyle( { display : 'none' }); this.subtitle = null; this.addResizeListener(BCProfessionalAreaPage.resize); this.translations = {}; this.waitForLoad = true; this.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : BCProfessionalAreaPage.FADE_DURATION, go : { alpha : 1 }, from : { alpha : 0 } } }; } } BCProfessionalAreaPage.prototype.loadTranslations = function() { }; BCProfessionalAreaPage.prototype.getTranslation = function(widgetClass) { if (this.translations[widgetClass]) { return this.translations[widgetClass]; } }; BCProfessionalAreaPage.prototype.onLoad = function(data) { this.loadTranslations(); KSystem.merge(this.data, data); KPage.prototype.onLoad.call(this, data); }; BCProfessionalAreaPage.prototype.onShow = function() { if (this.display) { return; } this.setStyle({ opacity : 0 }); KPage.prototype.onShow.call(this); }; BCProfessionalAreaPage.prototype.onHide = function() { if (this.display && Kinky.site.childWidget(this.getHash()) instanceof KPageDialog) { return; } if (!KPage.prototype.onHide.call(this)) { this.setStyle({ opacity : '0' }); } }; BCProfessionalAreaPage.prototype.draw = function(data) { this.setStyle({ opacity : '0' }); KPage.prototype.draw.call(this); if (this.data.description) { var subText = window.document.createElement('div'); subText.className = 'PageSubtitle'; subText.innerHTML = this.data.description; this.childDiv(KWidget.TITLE_DIV).appendChild(subText); } this.clearBoth(); }; BCProfessionalAreaPage.resize = function(page, size) { size.height += page.heightFix; Kinky.site.resizeSite(size); }; BCProfessionalAreaPage.FADE_DURATION = 1000; BCSite.prototype = new KSite(); BCSite.prototype.constructor = BCSite; BCSite.activeUser = null; BCSite.dialogWindow = null; function BCSite(parent) { if (parent != null) { KSite.call(this, parent); BCSite.productPageHash = []; this.footer = null; this.contentHeight = 0; this.theme = 'none'; this.colors = {}; this.colors.background = '#FFFFFF'; this.colors.menuColor1 = '#000000'; this.colors.menuColor2 = '#000000'; this.colors.subMenuColor1 = '#000000'; this.colors.subMenuColor2 = '#000000'; this.colors.textColor = '#3F3F3F'; this.colors.titleColor1 = '#000000'; this.colors.titleColor2 = '#000000'; this.colors.titleColor3 = '#000000'; this.colors.titleColor4 = '#000000'; this.colors.footerMenuColor1 = '#FFFFFF'; this.colors.footerMenuColor2 = '#8B87A4'; this.backgroundSite = new KPanel(this); this.backgroundSite.addCSSClass('BCSiteBackground'); this.backgroundSite.hash = '/backgroundSite'; this.backgroundSite.changeContext('/'); this.appendChild(this.backgroundSite, null, KWidget.BACKGROUND_DIV); this.backgroundPage = new KPanel(this); this.backgroundPage.addCSSClass('BCSiteBackground'); this.backgroundPage.hash = '/backgroundPage'; this.backgroundPage.changeContext('/'); this.appendChild(this.backgroundPage, null, KWidget.BACKGROUND_DIV); BCSite.mapWindowDialog = new KDialog(this); BCSite.mapWindowDialog.buttons = KWidget.CLOSE; BCSite.mapWindowDialog.type = KDialog.MODAL | KDialog.CENTERED; BCSite.mapWindowDialog.params = {}; BCSite.mapWindowDialog.addCSSClass('BCWebsiteMap'); BCSite.mapWindowDialog.currentPointInfo = null; BCSite.mapWindowDialog.onShow = function() { KDialog.prototype.onShow.call(this); this.setStyle({ left : (KSystem.getBrowserWidth() / 2) - 407 + 'px', top : '210px' }); }; BCSite.dialogWindow = new KDialog(this); BCSite.dialogWindow.addCSSClass('DialogWindow'); BCSite.dialogWindow.buttons = KWidget.CLOSE; BCSite.dialogWindow.type = KDialog.MODAL | KDialog.CENTERED; BCSite.dialogWindow.params = {}; BCSite.dialogWindow.effects = { enter : { f : KEffects.linear, type : 'move', duration : 200, go : { y : 110 }, lock : { x : true }, onStart : function(widget, tween) { tween.go.y = 200 + (window.pageYOffset ? window.pageYOffset : document.body.scrollTop); } }, exit : { f : KEffects.linear, type : 'move', duration : 200, go : { y : -this.getHeight() }, lock : { x : true }, onStart : function(widget, tween) { tween.go.y = -widget.getHeight() - 500; } } } BCSite.dialogWindow.setStyle({ overflow : 'visible', clear : 'both' }); BCSite.dialogWindow.onShow = function() { this.setStyle({ left : (KSystem.getBrowserWidth() / 2) + 'px' }); KDialog.prototype.onShow.call(this); } BCSite.dialogWindow.draw = function() { if (!this.activated()) { var okBt = new BCKButton(this, 'ok', 'closeBt', BCSite.dialogCloseHandler); this.appendChild(okBt); okBt.go(); } KDialog.prototype.draw.call(this); } this.addActionListener(BCSite.serverError); this.addLocationListener(BCSite.analytics); this.widgets = new Object(); this.breadcrumb = 'Biocol'; this.addWindowResizeListener(BCSite.windowResize); var today = new Date(); var hours = today.getHours(); var bkImg = '/images/site/backgrounds/'; if (hours >= 5 && hours < 10) { bkImg += 'manha.jpg'; } else if (hours >= 10 && hours <= 20) { bkImg += 'tarde.jpg'; } else { bkImg += 'noite.jpg'; } this.setStyle({ backgroundImage : 'url("' + bkImg + '")' }, KWidget.BACKGROUND_DIV); } } BCSite.dialogCloseHandler = function(widget) { if (BCSite.dialogWindow.params.type == 1) { KBreadcrumb.back(); } KDialog.close(null, BCSite.dialogWindow); } BCSite.prototype.loadSiteMap = function(data, parentPage, level) { level = level || 1; this.sitemap = data; for ( var section in data) { if (section == 'elements') { continue; } var menuData = { feClass : data[section].feClass, args : { section : section } }; var index = KSystem.construct(menuData, this); if (index) { this.menu[this.appendChild(index).key] = index; } for ( var page in data[section].pages) { var child = KSystem.construct(data[section].pages[page], this); if (child == null) { continue; } child.level = level; child.data.section = section; child.breadcrumb = child.data.titleText || ''; this.addBackgrounds(child); if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[section].pages[page].urlHashText = redirect; } else { this.appendChild(child); } child.redirectUrlHashText = redirect; } else { this.appendChild(child); } this.loadPages(data[section].pages[page].pages, child, section, level + 1); } if (index) { index.data = { pages : data[section].pages }; } } } BCSite.prototype.loadPages = function(data, parentPage, section, level) { for ( var page in data) { var child = KSystem.construct(data[page], this); if (child) { child.level = level; child.data.section = section; child.breadcrumb = parentPage.breadcrumb + ' - ' + (child.data.titleText || ''); this.addBackgrounds(child); if (data[page].template == 21) { BCSite.productPageHash.push(data[page].urlHashText); } if (child instanceof KRedirectPage) { var redirect = child.getRedirect(); if (/http:/.test(redirect)) { data[page].urlHashText = redirect; } else { this.appendChild(child); } } else { this.appendChild(child); } this.loadPages(data[page].pages, child, section, level + 1); } } } BCSite.prototype.addBackgrounds = function(child) { if (child.data.graphicStyle && child.data.graphicStyle.images && child.data.graphicStyle.images.length != 0) { for ( var image in child.data.graphicStyle.images) { if (child.data.graphicStyle.images[image].stateCode == 'Background Site') { var backSite = new KImage(this.backgroundSite, child.data.graphicStyle.images[image].fileInternalPath); backSite.addCSSClass('BCSiteBackgroundImage'); backSite.waitForLoad = true; backSite.onShow = function() { this.parent.width = this.data.width; this.setStyle({ width : this.data.width + 'px' }); this.parent.setStyle({ width : this.data.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.backgroundSite.appendChild(backSite, child.hash); } else if (child.data.graphicStyle.images[image].stateCode == 'Background Pagina') { var backPage = new KImage(this.backgroundPage, child.data.graphicStyle.images[image].fileInternalPath); backPage.addCSSClass('BCSiteBackgroundImage'); backPage.waitForLoad = true; backPage.onShow = function() { this.parent.width = this.data.width; this.setStyle({ width : this.data.width + 'px' }); this.parent.setStyle({ width : this.data.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.backgroundPage.appendChild(backPage, child.hash); } } } } BCSite.prototype.draw = function() { var leftPanel = new BCLeftPanel(this); this.appendChild(leftPanel); var rightPanel = new BCWebsiteRightPanel(this); this.appendChild(rightPanel); var subPagesMenu = new BCSubPagesMenu(this); this.appendChild(subPagesMenu, null, KWidget.CONTENT_DIV); var productSubPagesMenuLevel1 = new BCWebsiteProductSubPagesLevel1(this); this.appendChild(productSubPagesMenuLevel1, null, KWidget.CONTENT_DIV); var productSubPagesMenuLevel2 = new BCWebsiteProductSubPagesLevel2(this); this.appendChild(productSubPagesMenuLevel2, null, KWidget.CONTENT_DIV); var fbLikeProducts = new KFBLikeMe(this, { fbPageHash : this.getHash(), siteURL : Kinky.SITE_URL, lookNFeel : KFBLikeMe.LOOK_N_FEEL.STANDARD, size : { width : 250, height : 30 } }); fbLikeProducts.addCSSClass('BCFbLikeSite'); fbLikeProducts.onChangeURL = function(hash) { var indice = BCSite.indexOf(hash, BCSite.productPageHash); if (indice) { var splited = hash.split('/'); var hashToShare = '/' + Kinky.DEFAULT_LANG + '/' + splited[1] + '/' + splited[2] + '/' + splited[3]; if (hashToShare != this.lastHashToShare) { KFBLikeMe.prototype.onChangeURL.call(this, hashToShare); this.onShow(); this.lastHashToShare = hashToShare; } } else { this.onHide(); } }; fbLikeProducts.onShow = function() { var indice = BCSite.indexOf(KBreadcrumb.getHash(), BCSite.productPageHash); if (!indice) { return; } KWidget.prototype.onShow.call(this); }; this.appendChild(fbLikeProducts); var titlePanel = new KPanel(this); titlePanel.addCSSClass('HeaderElements'); { titlePanel.hash = '/titlePanel'; titlePanel.setStyle({ overflow : 'visible' }); this.setStyle({ backgroundColor : this.colors.background }); if (this.data.graphicStyle && this.data.graphicStyle.images && this.data.graphicStyle.images.length != 0) { for ( var image in this.data.graphicStyle.images) { if (this.data.graphicStyle.images[image].stateCode == 'Logo') { var logoBC = new KLink(titlePanel, '#' + Kinky.HOMEPAGE_URL, this.data.graphicStyle.images[image].fileInternalPath); logoBC.addCSSClass('BCSiteLogo'); titlePanel.appendTitleChild(logoBC); } else if (this.data.graphicStyle.images[image].stateCode == 'Site Theme') { this.theme = this.data.graphicStyle.images[image].fileInternalPath; } else if (this.data.graphicStyle.images[image].stateCode == 'Background Site') { var backSite = new KImage(this.backgroundSite, this.data.graphicStyle.images[image].fileInternalPath); backSite.addCSSClass('BCSiteBackgroundImage'); backSite.waitForLoad = true; backSite.onShow = function() { this.parent.width = this.data.width; this.setStyle({ width : this.data.width + 'px' }); this.parent.setStyle({ width : this.data.width + 'px', left : Math.round((KSystem.getBrowserWidth() - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.backgroundSite.appendChild(backSite); } else if (this.data.graphicStyle.images[image].stateCode == 'Background Footer') { this.childWidget('menuFooter').setStyle({ backgroundImage : 'url(' + this.data.graphicStyle.images[image].fileInternalPath + ')' }); } } } var searchPanel = new KPanel(titlePanel); searchPanel.addCSSClass('SearchPanel'); { var searchInput = new KInput(searchPanel, 'text', 'Pesquisa aqui', 'PesquisaLojas'); searchInput.setStyle({ labelPosition : 'inside' }); searchInput.onEnterSubmit = false; searchInput.addEventListener('keypress', function(e) { if(e.keyCode==13){ var value = searchInput.getValue(); if (!value || value == '') { return; } KBreadcrumb.dispatchURL({ hash : '/resultados-de-pesquisa', query : '/search/' + value }); } }); searchPanel.appendChild(searchInput); var submitBt = new KButton(searchPanel, '', 'submitBt', function() { var value = searchInput.getValue(); if (!value || value == '') { return; } KBreadcrumb.dispatchURL({ hash : '/resultados-de-pesquisa', query : '/search/' + value }); }); KSystem.addEventListener(window.document.body, 'click', function(e) { var widget = KSystem.getEventWidget(e); if(!(widget instanceof BCWebsiteMainMenu)) { Kinky.site.menu['websiteMenuPrincipal'].hide(); } }); searchPanel.appendChild(submitBt); } titlePanel.appendChild(searchPanel); this.topMenu = this.childWidget('websiteMenuTopo').panel; titlePanel.content.appendChild(this.topMenu); var languagePanel = new BCWebsiteLangPanel(titlePanel); titlePanel.appendChild(languagePanel); } this.appendTitleChild(titlePanel); KSite.prototype.draw.call(this); // MENUS this.appendChild(this.childWidget('websiteMenuPrincipal'), null, KWidget.CONTENT_DIV); this.childWidget('websiteMenuFooter').content.appendChild(this.childWidget('menuLegal').topUL); this.footer = this.childWidget('websiteMenuFooter').panel; this.panel.appendChild(this.footer); this.appendChild(BCSite.mapWindowDialog); this.appendChild(BCSite.dialogWindow); BCSite.dialogWindow.setStyle({ backgroundImage : 'url(' + this.theme + ')' }); this.content.appendChild(KCSS.clearBoth()); this.clearBoth(KWidget.TITLE_DIV); this.resizeHeight(this, null); this.resizeWidth(this, null); } BCSite.prototype.resizeSite = function(size) { this.contentHeight = size.height; this.resizeHeight(this, size.height); this.resizeWidth(this, size.width); } BCSite.windowResize = function(site, size) { site.resizeHeight(site, size.height); site.resizeWidth(site, size.width); } BCSite.prototype.resizeHeight = function(site, height) { if (height != null) { var titleHeight = 190; var footerHeight = 336; site.setStyle({ height : Math.max(KSystem.getBrowserHeight(), height + titleHeight + footerHeight) + 'px' }); } } BCSite.prototype.resizeWidth = function(site, width) { site.setStyle({ width : KSystem.getBrowserWidth() + 'px' }, KWidget.BACKGROUND_DIV); site.backgroundPage.setStyle({ left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - (site.backgroundPage.width != null ? site.backgroundPage.width : site.backgroundPage.getWidth())) / 2) + 'px' }); site.backgroundSite.setStyle({ left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - (site.backgroundSite.width != null ? site.backgroundSite.width : site.backgroundSite.getWidth())) / 2) + 'px' }); } BCSite.serverError = function(widget, action) { if (action != '/error') { return; } dump(widget.childWidget(widget.getHash()).error.description, true); }; BCSite.analytics = function(widget, something) { if (something == '') { return; } try { this.pageTracker._trackPageview(widget.getURL().replace(/\/\?|\/@/g, '')); } catch (err) { try { this.pageTracker = _gat._getTracker(Kinky.GOOGLE_ANALYTICS); this.pageTracker._trackPageview(widget.getURL().replace(/\/\?|\/@/g, '')); } catch (err2) { debug(err2); } } }; BCSite.indexOf = function(string, arrayReceived) { if (!(arrayReceived instanceof Array)) { var arrayToCheck = JSON.parse(arrayReceived); } else { var arrayToCheck = arrayReceived; } for ( var index in arrayToCheck) { if (arrayToCheck[index] == string) { return index; } } return false; }; BCWebsitePage.prototype = new KPage(); BCWebsitePage.prototype.constructor = BCWebsitePage; BCWebsitePage.prototype.heightFix = 0; function BCWebsitePage(parent) { if (parent != null) { this.overflow = 'visible'; KPage.call(this, parent); this.addCSSClass('BCWebsitePage'); this.addCSSClass('BCWebsitePageBackground', KWidget.BACKGROUND_DIV); this.addCSSClass('BCWebsitePageTitle', KWidget.TITLE_DIV); this.setStyle( { display : 'none' }); this.subtitle = null; this.addResizeListener(BCWebsitePage.resize); this.graphicStyle = null; this.translations = {}; this.waitForLoad = true; this.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : BCWebsitePage.FADE_DURATION, go : { alpha : 1 }, from : { alpha : 0 } } }; } } BCWebsitePage.prototype.loadTranslations = function() { }; BCWebsitePage.prototype.getTranslation = function(widgetClass) { if (this.translations[widgetClass]) { return this.translations[widgetClass]; } }; BCWebsitePage.prototype.onLoad = function(data) { var siteGraphicStyle = this.parent.data.graphicStyle; this.graphicStyle = this.data.graphicStyle; this.graphicStyle.colors.background = siteGraphicStyle.colors.background; this.graphicStyle.colors.menuColor1 = siteGraphicStyle.colors.menuColor1; this.graphicStyle.colors.menuColor2 = siteGraphicStyle.colors.menuColor2; this.graphicStyle.colors.subMenuColor1 = siteGraphicStyle.colors.subMenuColor1; this.graphicStyle.colors.subMenuColor2 = siteGraphicStyle.colors.subMenuColor2; this.graphicStyle.colors.textColor = siteGraphicStyle.colors.textColor; this.graphicStyle.colors.titleColor1 = siteGraphicStyle.colors.titleColor1; this.graphicStyle.colors.titleColor2 = siteGraphicStyle.colors.titleColor2; this.graphicStyle.colors.titleColor3 = siteGraphicStyle.colors.titleColor3; this.graphicStyle.colors.titleColor4 = siteGraphicStyle.colors.titleColor4; this.graphicStyle.colors.footerMenuColor1 = siteGraphicStyle.colors.footerMenuColor1.text; this.graphicStyle.colors.footerMenuColor2 = siteGraphicStyle.colors.footerMenuColor2.text; this.setStyle({ color: Kinky.site.colors.titleColor1 }, KWidget.TITLE_DIV); this.loadTranslations(); KSystem.merge(this.data, data); KPage.prototype.onLoad.call(this, data); }; BCWebsitePage.prototype.onShow = function() { if (this.display) { return; } this.setStyle({ opacity : 0 }); if (KPage.prototype.onShow.call(this)) { this.changeBackgrounds(this.hash); } }; BCWebsitePage.prototype.changeBackgrounds = function(hash_to_activate) { var backgroundSite = Kinky.site.childWidget('/backgroundSite'); var backgroundPage = Kinky.site.childWidget('/backgroundPage'); var backSiteOk = false; var backPageOk = false; while(!backSiteOk || !backPageOk) { if(!backSiteOk) { var bg_site_child = backgroundSite.childWidgets(hash_to_activate); if(bg_site_child != null) { for ( var element in bg_site_child) { bg_site_child = bg_site_child[element]; } if(backgroundSite.getContext() != hash_to_activate) { backgroundSite.hideContext(); backgroundSite.changeContext(hash_to_activate); if(bg_site_child instanceof KImage && bg_site_child.data != null) { backgroundSite.width = bg_site_child.data.width; } backgroundSite.setStyle({ width : backgroundSite.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - backgroundSite.width) / 2) + 'px' }); backgroundSite.showContext(); } backSiteOk = true; } } if(!backPageOk) { var bg_page_child = backgroundPage.childWidgets(hash_to_activate); if(bg_page_child != null) { for ( var element in bg_page_child) { bg_page_child = bg_page_child[element]; } if(backgroundPage.getContext() != hash_to_activate) { backgroundPage.hideContext(); backgroundPage.changeContext(hash_to_activate); if(bg_page_child instanceof KImage && bg_page_child.data != null) { backgroundPage.width = bg_page_child.data.width; } else if(bg_page_child instanceof BCGallery) { backgroundPage.width = bg_page_child.getWidth(); } backgroundPage.setStyle({ width : backgroundPage.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - backgroundPage.width) / 2) + 'px' }); backgroundPage.showContext(); } backPageOk = true; } } if(hash_to_activate == '/' || hash_to_activate == '') break; if(!backSiteOk || !backPageOk) { hash_to_activate = hash_to_activate.substring(0, hash_to_activate.lastIndexOf('/')); if(hash_to_activate == '') hash_to_activate = '/'; } } if(!backSiteOk) { backgroundSite.hideContext(); backgroundSite.changeContext('/hidden'); } if(!backPageOk) { backgroundPage.hideContext(); backgroundPage.changeContext('/hidden'); } }; BCWebsitePage.prototype.prepareBackgrounds = function(hash_to_activate) { var backgroundSite = Kinky.site.childWidget('/backgroundSite'); var backgroundPage = Kinky.site.childWidget('/backgroundPage'); var backSiteOk = false; var backPageOk = false; while (!backSiteOk || !backPageOk) { if (!backSiteOk) { var bg_site_child = backgroundSite.childWidgets(hash_to_activate); if (bg_site_child != null) { for ( var element in bg_site_child) { bg_site_child = bg_site_child[element]; } if (backgroundSite.getContext() != hash_to_activate) { //backgroundSite.hideContext(); } backSiteOk = true; } } if (!backPageOk) { var bg_page_child = backgroundPage.childWidgets(hash_to_activate); if (bg_page_child != null) { for ( var element in bg_page_child) { bg_page_child = bg_page_child[element]; } if (backgroundPage.getContext() != hash_to_activate) { backgroundPage.hideContext(); } backPageOk = true; } } if (hash_to_activate == '/' || hash_to_activate == '') break; if (!backSiteOk || !backPageOk) { hash_to_activate = hash_to_activate.substring(0, hash_to_activate .lastIndexOf('/')); if (hash_to_activate == '') hash_to_activate = '/'; } } // if (!backSiteOk) { // backgroundSite.hideContext(); // backgroundSite.changeContext('/hidden'); // } if (!backPageOk) { backgroundPage.hideContext(); backgroundPage.changeContext('/hidden'); } }; BCWebsitePage.prototype.onHide = function() { if (this.display && Kinky.site.childWidget(this.getHash()) instanceof KPageDialog) { return; } if (!KPage.prototype.onHide.call(this)) { this.setStyle({ opacity : '0' }); this.prepareBackgrounds(this.getHash()); } }; BCWebsitePage.prototype.draw = function(data) { this.setStyle({ opacity : '0' }); KPage.prototype.draw.call(this); if(this.getHash().split('/').length <= 2){ this.setStyle({ display : 'none' }, KWidget.TITLE_DIV); } this.clearBoth(); }; BCWebsitePage.resize = function(page, size) { size.height += page.heightFix; Kinky.site.resizeSite(size); }; BCWebsitePage.FADE_DURATION = 1000; BCOneColumnNoTitle.prototype = new BCPage(); BCOneColumnNoTitle.prototype.constructor = BCOneColumnNoTitle; function BCOneColumnNoTitle(parent) { if (parent != null) { BCPage.call(this, parent); this.addCSSClass('BCOneColumnNoTitle'); } } BCOneColumnNoTitle.prototype.draw = function() { BCPage.prototype.draw.call(this); } BCOneColumnTitle.prototype = new BCPage(); BCOneColumnTitle.prototype.constructor = BCOneColumnTitle; function BCOneColumnTitle(parent) { if (parent != null) { BCPage.call(this, parent); } } BCOneColumnTitle.prototype.draw = function() { BCPage.prototype.draw.call(this); } BCTwoColumnTitle.prototype = new BCPage(); BCTwoColumnTitle.prototype.constructor = BCTwoColumnTitle; function BCTwoColumnTitle(parent) { if (parent != null) { BCPage.call(this, parent); this.addCSSClass('BCTwoColumnTitle'); } } BCTwoColumnTitle.prototype.draw = function() { BCPage.prototype.draw.call(this); } BCWebsiteThreeColumnHighlight.prototype = new BCWebsitePage(); BCWebsiteThreeColumnHighlight.prototype.constructor = BCWebsiteThreeColumnHighlight; function BCWebsiteThreeColumnHighlight(parent) { if (parent != null) { BCWebsitePage.call(this, parent); this.addCSSClass('BCWebsiteThreeColumnHighlight'); } } BCWebsiteThreeColumnHighlight.prototype.draw = function() { BCWebsitePage.prototype.draw.call(this); } BCWebsiteTwoColumnHighlight.prototype = new BCWebsitePage(); BCWebsiteTwoColumnHighlight.prototype.constructor = BCWebsiteTwoColumnHighlight; function BCWebsiteTwoColumnHighlight(parent) { if (parent != null) { BCWebsitePage.call(this, parent); this.addCSSClass('BCWebsiteTwoColumnHighlight'); } } BCWebsiteTwoColumnHighlight.prototype.draw = function() { BCWebsitePage.prototype.draw.call(this); } BCWebsiteTwoColumnNoHighlight.prototype = new BCWebsitePage(); BCWebsiteTwoColumnNoHighlight.prototype.constructor = BCWebsiteTwoColumnNoHighlight; BCWebsiteTwoColumnNoHighlight.prototype.heightFix = 120; function BCWebsiteTwoColumnNoHighlight(parent) { if (parent != null) { BCWebsitePage.call(this, parent); this.addCSSClass('BCWebsiteTwoColumnNoHighlight'); } } BCWebsiteTwoColumnNoHighlight.prototype.draw = function() { var topDiv = window.document.createElement('div'); topDiv.className = 'TopDiv'; this.panel.appendChild(topDiv); KCSS.addCSSClass('BCWebsitePageContent', this.content); var bottomDiv = window.document.createElement('div'); bottomDiv.className = 'BottomDiv'; this.contentContainer.appendChild(bottomDiv); BCWebsitePage.prototype.draw.call(this); } BCContestDetail.prototype = new BCOneColumnTitle(); BCContestDetail.prototype.constructor = BCContestDetail; function BCContestDetail(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); BCContestDetail.participatePage = null; } } BCContestDetail.prototype.draw = function() { for (var index in Kinky.site.childWidget('menuPrincipal').data.pages){ //o melhor sera criar um template para a pagina passatempo para o caso de haver outro 7 (internal redirect generico) no menu if (Kinky.site.childWidget('menuPrincipal').data.pages[index].template == 7){ var parentPageChilds = Kinky.site.childWidget('menuPrincipal').data.pages[index].pages; for (var idx in parentPageChilds){ if (parentPageChilds[idx].template == 19){ BCContestDetail.participatePage = parentPageChilds[idx].urlHashText; } } } } this.translations = this.getTranslation(this.className); var participateBt = new BCKButton(this, this.translations.participate, 'participateBt', function(){ KBreadcrumb.dispatchURL({ hash : BCContestDetail.participatePage }); }); this.appendChild(participateBt); BCOneColumnTitle.prototype.draw.call(this); if (this.childWidget('/richtext').content.getElementsByTagName('h2') && this.childWidget('/richtext').content.getElementsByTagName('h2')[0]){ this.childWidget('/richtext').content.getElementsByTagName('h2')[0].style.color = Kinky.site.colors.titleColor1; } }; BCHomepage.prototype = new BCOneColumnNoTitle(); BCHomepage.prototype.constructor = BCHomepage; BCHomepage.rollOverTimer = null; BCHomepage.direction = 1; BCHomepage.Time = 6000; BCHomepage.counter = null; function BCHomepage(parent) { if (parent != null) { BCOneColumnNoTitle.call(this, parent); this.addCSSClass('BCOneColumnNoTitle'); } } BCHomepage.prototype.draw = function() { BCOneColumnNoTitle.prototype.draw.call(this); var backSite = new BCGallery(this); backSite.data = this.data.imagensRotativas; Kinky.site.childWidget('/backgroundPage').appendChild(backSite, this.hash); backSite.draw(); this.panel.appendChild(backSite.pagination); var clickArea = window.document.createElement('div'); clickArea.className = ' BCHomepageClickArea '; clickArea.innerHTML = ' '; KSystem.addEventListener(clickArea, 'click', function(event) { if (backSite.data.highlightItems[backSite.nPage] && backSite.data.highlightItems[backSite.nPage].url) { var url = backSite.data.highlightItems[backSite.nPage].url; if (url.indexOf('http://') == 0) { window.open(url, '_blank'); } else { KBreadcrumb.dispatchURL({ url : url }); } } }); this.panel.appendChild(clickArea); this.prevButton = window.document.createElement('button'); this.prevButton.setAttribute("type", "button"); this.prevButton.className = ' KWidgetPanelPaginationPrev '; this.prevButton.innerHTML = ' '; this.prevButton.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.prevButton.style.backgroundRepeat = 'no-repeat'; KSystem.addEventListener(this.prevButton, 'click', function(event) { clearTimeout(BCHomepage.rollOverTimer); KWidget.dispatchPrevious(null, backSite); if (backSite.totalCount > 1) { BCHomepage.rollOverTimer = setTimeout(BCHomepage.doAutoNext, BCHomepage.Time * 2); } }); KSystem.addEventListener(this.prevButton, 'mouseover', function(event) { var widget = KSystem.getEventTarget(event); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'move', duration : 400, gravity : { x : 'left' }, go : { x : 0 }, lock : { y : true } }); }); KSystem.addEventListener(this.prevButton, 'mouseout', function(event) { var widget = KSystem.getEventTarget(event); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'move', duration : 400, gravity : { x : 'left' }, go : { x : 5 }, lock : { y : true } }); }); this.panel.appendChild(this.prevButton); this.nextButton = window.document.createElement('button'); this.nextButton.setAttribute("type", "button"); this.nextButton.className = ' KWidgetPanelPaginationNext '; this.nextButton.innerHTML = ' '; this.nextButton.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.nextButton.style.backgroundRepeat = 'no-repeat'; KSystem.addEventListener(this.nextButton, 'click', function(event) { clearTimeout(BCHomepage.rollOverTimer); KWidget.dispatchNext(null, backSite); if (backSite.totalCount > 1) { BCHomepage.rollOverTimer = setTimeout(BCHomepage.doAutoNext, BCHomepage.Time * 2); } }); KSystem.addEventListener(this.nextButton, 'mouseover', function(event) { var widget = KSystem.getEventTarget(event); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'move', duration : 400, gravity : { x : 'right' }, go : { x : -5 }, lock : { y : true } }); }); KSystem.addEventListener(this.nextButton, 'mouseout', function(event) { var widget = KSystem.getEventTarget(event); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'move', duration : 400, gravity : { x : 'right' }, go : { x : 0 }, lock : { y : true } }); }); this.panel.appendChild(this.nextButton); backSite.pagination.style.width = (backSite.totalCount * 20) + 'px'; clearTimeout(BCHomepage.rollOverTimer); if (backSite.totalCount > 1) { this.prevButton.style.display = 'block'; this.nextButton.style.display = 'block'; BCHomepage.rollOverTimer = setTimeout(BCHomepage.doAutoNext, BCHomepage.Time); } else { this.prevButton.style.display = 'none'; this.nextButton.style.display = 'none'; } }; BCHomepage.prototype.onShow = function() { BCPage.prototype.onShow.call(this); clearTimeout(BCHomepage.rollOverTimer); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); if (backSite != null) { if (backSite.totalCount > 1) { this.prevButton.style.display = 'block'; this.nextButton.style.display = 'block'; BCHomepage.rollOverTimer = setTimeout(BCHomepage.doAutoNext, BCHomepage.Time); } else { this.prevButton.style.display = 'none'; this.nextButton.style.display = 'none'; } } }; BCHomepage.prototype.onHide = function() { clearTimeout(BCHomepage.rollOverTimer); BCPage.prototype.onHide.call(this); }; BCHomepage.doAutoNext = function() { clearTimeout(BCHomepage.rollOverTimer); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); KWidget.dispatchNext(null, backSite); if (backSite.totalCount > 1) { BCHomepage.rollOverTimer = setTimeout(BCHomepage.doAutoNext, BCHomepage.Time); } }; BCHomepage.prototype.changeBackgrounds = function(hash_to_activate) { var backgroundSite = Kinky.site.childWidget('/backgroundSite'); var backgroundPage = Kinky.site.childWidget('/backgroundPage'); var backSiteOk = false; while (!backSiteOk) { var bg_site_child = backgroundSite.childWidgets(hash_to_activate); if (bg_site_child != null) { for ( var element in bg_site_child) { bg_site_child = bg_site_child[element]; } if (backgroundSite.getContext() != hash_to_activate) { backgroundSite.hideContext(); backgroundSite.changeContext(hash_to_activate); if (bg_site_child instanceof KImage && (bg_site_child.data != null)) { backgroundSite.width = bg_site_child.data.width; } backgroundSite.setStyle({ width : backgroundSite.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - backgroundSite.width) / 2) + 'px' }); backgroundSite.showContext(); } backSiteOk = true; } if ((hash_to_activate == '/') || (hash_to_activate == '')) { break; } if (!backSiteOk) { hash_to_activate = hash_to_activate.substring(0, hash_to_activate.lastIndexOf('/')); if (hash_to_activate == '') { hash_to_activate = '/'; } } } if (!backSiteOk) { backgroundSite.hideContext(); backgroundSite.changeContext('/hidden'); } backgroundPage.hideContext(); backgroundPage.changeContext(this.hash); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); if (backSite != null) { backgroundPage.width = backSite.width; } backgroundPage.setStyle({ width : backgroundPage.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - backgroundPage.width) / 2) + 'px' }); backgroundPage.showContext(); }; BCLocationMap.prototype = new BCOneColumnTitle(); BCLocationMap.prototype.constructor = BCLocationMap; function BCLocationMap(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); this.waitForLoad = false; } } BCLocationMap.prototype.draw = function() { var topDiv = window.document.createElement('div'); topDiv.className = 'BorderTop'; this.content.appendChild(topDiv); var botDiv = window.document.createElement('div'); botDiv.className = 'BorderBot'; this.contentContainer.appendChild(botDiv); BCOneColumnTitle.prototype.draw.call(this); }; BCNewsletter.prototype = new KPageDialog(); BCNewsletter.prototype.constructor = BCNewsletter; function BCNewsletter(parent) { if (parent) { KPageDialog.call(this, parent); this.addCSSClass('BCNewsletter'); this.newsletterForm = new KForm(this); this.newsletterForm.staticForm = true; this.newsletterForm.action = 'php:Entity:SubscribeNewsletter'; this.setStyle({ position : 'fixed' }); BCNewsletter.newsletterCategory = null; this.translations = null; } } BCNewsletter.prototype.onLoad = function(data) { KSystem.merge(this.data, data); KPage.prototype.onLoad.call(this, this.data); }; BCNewsletter.prototype.onShow = function() { KPageDialog.prototype.onShow.call(this); this.setStyle({ left : (KSystem.getBrowserWidth() / 2) + 265 + 'px', top : (KSystem.getBrowserHeight() - 190) + 'px' }); this.newsletterForm.reset(); }; BCNewsletter.prototype.draw = function() { this.loadTranslations(); this.setStyle({ backgroundImage : 'url("' + Kinky.site.theme + '")', backgroudRepeat : 'no-repeat' }); BCNewsletter.newsletterCategory = this.data.categoriaDeNewsletter.config.contentID; var subscriberName = new KInput(this.newsletterForm, 'text', this.translations.name, 'entityName'); subscriberName.addCSSClass('NewsletterInput'); subscriberName.addValidator(/.+/, 'campo de preenchimento obrigat\u00f3rio'); subscriberName.setStyle({ labelPosition : 'inside' }); this.newsletterForm.addInput(subscriberName); var subscriberEmail = new KInput(this.newsletterForm, 'text', this.translations.email, 'entityEmail'); subscriberEmail.addCSSClass('NewsletterInput'); subscriberEmail.addValidator(/(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/, 'campo de preenchimento obrigat\u00f3rio'); subscriberEmail.setStyle({ labelPosition : 'inside' }); this.newsletterForm.addInput(subscriberEmail); this.newsletterForm.clearBoth(); var checkBiocol = new KCheckBox(this.newsletterForm, '', 'biocolNewsletter', true); checkBiocol.addOption(1, this.translations.biocol, true); this.newsletterForm.addInput(checkBiocol); var submitButton = new BCButton(this.newsletterForm, this.translations.submit, 'submit'); this.newsletterForm.appendChild(submitButton); this.newsletterForm.onValidate = function(data, params, status) { if (status) { params.newsletterCategory = [ BCNewsletter.newsletterCategory ]; return params; } else { var first = true; for ( var index in params) { var input = params[index].getInput(); if (first) { first = false; input.focus(); } input.style.color = 'red'; } } }; this.newsletterForm.onSuccess = function(data) { BCMicroSite.dialogWindow.params.type = 1; BCMicroSite.dialogWindow.buttonLabel = (data.errorCode == 1 ? this.parent.translations.successButton : this.parent.translations.errorButton); KDialog.show(BCMicroSite.dialogWindow, { content : (data.errorCode == 1 ? this.parent.translations.successText : this.parent.translations.errorText), title : (data.errorCode == 1 ? this.parent.translations.successTitle : this.parent.translations.errorTitle) }); if (data.errorCode != 1) { BCMicroSite.dialogWindow.widgetTitle.childNodes[0].style.color = 'red'; } }; this.newsletterForm.reset = function() { for ( var element in this.inputByID) { if (this.inputByID[element].getValue() != '') { this.inputByID[element].setValue(null); } } }; this.appendChild(this.newsletterForm); KPageDialog.prototype.draw.call(this); }; BCWebsiteHomepage.prototype = new BCWebsiteTwoColumnHighlight(); BCWebsiteHomepage.prototype.constructor = BCWebsiteHomepage; BCWebsiteHomepage.prototype.heightFix = 270 + 26; BCWebsiteHomepage.rollOverTimer = null; BCWebsiteHomepage.direction = 1; BCWebsiteHomepage.Time = 6000; BCWebsiteHomepage.counter = null; function BCWebsiteHomepage(parent) { if (parent != null) { BCWebsiteTwoColumnHighlight.call(this, parent); } } BCWebsiteHomepage.prototype.draw = function() { var backSite = new BCGallery(this); backSite.data = this.data.imagensRotativas; Kinky.site.childWidget('/backgroundPage').appendChild(backSite, this.hash); backSite.draw(); var clickArea = window.document.createElement('img'); clickArea.src = 'images/site/click-area.png'; clickArea.className = ' BCWebsiteHomepageClickArea '; KSystem.addEventListener(clickArea, 'click', function(event) { if (backSite.data.highlightItems[backSite.nPage] && backSite.data.highlightItems[backSite.nPage].url) { var url = backSite.data.highlightItems[backSite.nPage].url; if (url.indexOf('http://') == 0) { window.open(url, '_blank'); } else { KBreadcrumb.dispatchURL({ url : url }); } } }); this.panel.appendChild(clickArea); backSite.pagination.style.width = (backSite.totalCount * 24) + 'px'; this.panel.appendChild(backSite.pagination); var translations = this.getTranslation('BCFacebookShare'); var facebookSharePanel = new KPanel(this); facebookSharePanel.addCSSClass('FacebookSharePanel'); facebookSharePanel.setTitle(translations.shareTitle); var shareBt = new KLink(facebookSharePanel, 'javascript:void(0);'); shareBt.setLinkText(translations.share); shareBt.addEventListener('click', function() { window.open('http://www.facebook.com/sharer.php?u=http://' + encodeURIComponent(window.location.host)); }); facebookSharePanel.appendChild(shareBt); this.appendChild(facebookSharePanel); BCWebsiteTwoColumnHighlight.prototype.draw.call(this); clearTimeout(BCWebsiteHomepage.rollOverTimer); if (backSite.totalCount > 1) { BCWebsiteHomepage.rollOverTimer = setTimeout(BCWebsiteHomepage.doAutoNext, BCWebsiteHomepage.Time); } }; BCWebsiteHomepage.prototype.onShow = function() { BCWebsiteTwoColumnHighlight.prototype.onShow.call(this); clearTimeout(BCWebsiteHomepage.rollOverTimer); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); if (backSite != null) { if (backSite.totalCount > 1) { BCWebsiteHomepage.rollOverTimer = setTimeout(BCWebsiteHomepage.doAutoNext, BCWebsiteHomepage.Time); } } }; BCWebsiteHomepage.prototype.onHide = function() { clearTimeout(BCWebsiteHomepage.rollOverTimer); BCWebsiteTwoColumnHighlight.prototype.onHide.call(this); }; BCWebsiteHomepage.doAutoNext = function() { clearTimeout(BCWebsiteHomepage.rollOverTimer); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); KWidget.dispatchNext(null, backSite); if (backSite.totalCount > 1) { BCWebsiteHomepage.rollOverTimer = setTimeout(BCWebsiteHomepage.doAutoNext, BCWebsiteHomepage.Time); } }; BCWebsiteHomepage.prototype.changeBackgrounds = function(hash_to_activate) { var backgroundSite = Kinky.site.childWidget('/backgroundSite'); var backgroundPage = Kinky.site.childWidget('/backgroundPage'); var backSiteOk = false; while (!backSiteOk) { var bg_site_child = backgroundSite.childWidgets(hash_to_activate); if (bg_site_child != null) { for ( var element in bg_site_child) { bg_site_child = bg_site_child[element]; } if (backgroundSite.getContext() != hash_to_activate) { backgroundSite.hideContext(); backgroundSite.changeContext(hash_to_activate); if (bg_site_child instanceof KImage && (bg_site_child.data != null)) { backgroundSite.width = bg_site_child.data.width; } backgroundSite.setStyle({ width : backgroundSite.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - backgroundSite.width) / 2) + 'px' }); backgroundSite.showContext(); } backSiteOk = true; } if ((hash_to_activate == '/') || (hash_to_activate == '')) { break; } if (!backSiteOk) { hash_to_activate = hash_to_activate.substring(0, hash_to_activate.lastIndexOf('/')); if (hash_to_activate == '') { hash_to_activate = '/'; } } } if (!backSiteOk) { backgroundSite.hideContext(); backgroundSite.changeContext('/hidden'); } backgroundPage.hideContext(); backgroundPage.changeContext(this.hash); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); if (backSite != null) { backgroundPage.width = backSite.width; } backgroundPage.setStyle({ width : backgroundPage.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - backgroundPage.width) / 2) + 'px' }); backgroundPage.showContext(); }; BCContact.prototype = new BCOneColumnTitle(); BCContact.prototype.constructor = BCContact; function BCContact(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCContact.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); if (this.childWidget('/richtext').content.getElementsByTagName('h2') && this.childWidget('/richtext').content.getElementsByTagName('h2')[0]){ this.childWidget('/richtext').content.getElementsByTagName('h2')[0].style.color = Kinky.site.colors.titleColor1; } } BCContestParticipate.prototype = new BCOneColumnTitle(); BCContestParticipate.prototype.constructor = BCContestParticipate; function BCContestParticipate(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCContestParticipate.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCContestPrizes.prototype = new BCOneColumnTitle(); BCContestPrizes.prototype.constructor = BCContestPrizes; function BCContestPrizes(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCContestPrizes.prototype.draw = function() { for (var index in Kinky.site.childWidget('menuPrincipal').data.pages){ //o melhor sera criar um template para a pagina passatempo para o caso de haver outro 7 (internal redirect generico) no menu if (Kinky.site.childWidget('menuPrincipal').data.pages[index].template == 7){ var parentPageChilds = Kinky.site.childWidget('menuPrincipal').data.pages[index].pages; for (var idx in parentPageChilds){ if (parentPageChilds[idx].template == 19){ BCContestDetail.participatePage = parentPageChilds[idx].urlHashText; } } } } var participateBt = new BCKButton(this, 'Participar', 'participateBt', function(){ KBreadcrumb.dispatchURL({ hash : BCContestDetail.participatePage }); }); this.appendChild(participateBt); BCOneColumnTitle.prototype.draw.call(this); } BCContestTerms.prototype = new BCOneColumnTitle(); BCContestTerms.prototype.constructor = BCContestTerms; function BCContestTerms(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCContestTerms.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCContestWinners.prototype = new BCOneColumnTitle(); BCContestWinners.prototype.constructor = BCContestWinners; function BCContestWinners(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCContestWinners.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCDownloads.prototype = new BCOneColumnTitle(); BCDownloads.prototype.constructor = BCDownloads; function BCDownloads(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCDownloads.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCFaq.prototype = new BCOneColumnTitle(); BCFaq.prototype.constructor = BCFaq; function BCFaq(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCFaq.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCNews.prototype = new BCOneColumnTitle(); BCNews.prototype.constructor = BCNews; function BCNews(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCNews.prototype.draw = function() { var lista = this.childWidget('/item-list'); lista.showReadMore = true; BCOneColumnTitle.prototype.draw.call(this); } BCProductDetail.prototype = new BCOneColumnTitle(); BCProductDetail.prototype.constructor = BCOneColumnTitle; function BCProductDetail(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); this.addCSSClass('BCProductDetail'); } } BCProductDetail.prototype.draw = function() { var richtextWidget = this.childWidget('/richtext'); richtextWidget.setTitle(this.data.titleText); richtextWidget.setStyle({ color: Kinky.site.colors.titleColor1 }, KWidget.TITLE_DIV); var div = window.document.createElement('div'); div.className = 'RootDiv'; if (Kinky.BASE_VERSION == '/biocolkids'){ richtextWidget.setStyle({ background : 'url("images/microsite/kids_product_detail_mid.png") repeat-y' }, KWidget.CONTAINER_DIV); richtextWidget.setStyle({ marginTop : '315px' }); div.style.background = 'url("images/microsite/kids_product_detail_bot.png") no-repeat'; div.style.height = '19px'; div.style.width = '698px'; }; richtextWidget.childDiv(KWidget.ROOT_DIV).appendChild(div); this.data.titleText = Kinky.site.childWidget(BCMicroSite.productPageHash).data.titleText; BCOneColumnTitle.prototype.draw.call(this); } BCTestimony.prototype = new BCOneColumnTitle(); BCTestimony.prototype.constructor = BCTestimony; function BCTestimony(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCTestimony.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCTextPage.prototype = new BCOneColumnTitle(); BCTextPage.prototype.constructor = BCTextPage; function BCTextPage(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCTextPage.prototype.draw = function() { BCOneColumnTitle.prototype.draw.call(this); } BCTips.prototype = new BCOneColumnTitle(); BCTips.prototype.constructor = BCTips; function BCTips(parent) { if (parent != null) { BCOneColumnTitle.call(this, parent); } } BCTips.prototype.draw = function() { var lista = this.childWidget('/item-list'); lista.showReadMore = false; BCOneColumnTitle.prototype.draw.call(this); } BCWebsiteContact.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteContact.prototype.constructor = BCWebsiteContact; function BCWebsiteContact(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsiteContact.prototype.draw = function() { BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); var widgetChilds = this.childWidgets(); if (widgetChilds) { for ( var index in widgetChilds) { if (widgetChilds[index] instanceof BCContactRichtext) { if (widgetChilds[index].hash == '/richtext/block1') { widgetChilds[index].addCSSClass('FirstBox'); } } } } if (this.childWidget('/BCWebsiteFormContact')) { var clearBoth = new KPanel(this); clearBoth.addCSSClass('ClearBothIe'); clearBoth.go(); this.insertBefore(clearBoth, null, this.childWidget('/BCWebsiteFormContact')); } } BCWebsiteExport.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteExport.prototype.constructor = BCWebsiteExport; function BCWebsiteExport(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsiteExport.prototype.draw = function() { var children = this.childWidgets(); for (var index in children){ if (children[index].className == 'BCContactRichtext'){ if (children[index].data.blockTitle == 'Intro Formul\u00e1rio'){ children[index].addCSSClass('FormIntroText'); } } } BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); } BCWebsiteMap.prototype = new KPanel(); BCWebsiteMap.prototype.constructor = BCWebsiteMap; function BCWebsiteMap(parent) { if (parent) { KPanel.call(this, parent); } } BCWebsiteMap.prototype.draw = function() { this.googleMap = new KMap(this, 'Seleccione a sua localiza\u00e7\u00e3o', 'locations'); { this.googleMap.hash = '/page/map'; this.googleMap.searchBox = false; this.googleMap.draggableMarkers = false; this.googleMap.showInfoWindow = true; this.googleMap.maxMarkers = 0; this.googleMap.initialZoom = 11; this.googleMap.removeOption = false; this.googleMap.defaultIcon = '/images/site/map_pointer.png'; this.googleMap.designationBox = false; } this.googleMap.refresh(); this.appendChild(this.googleMap); KPanel.prototype.draw.call(this); this.googleMap.addBorder({ cssClass : 'BCWebsiteMapBox', border : 10 }); this.placePoints(); }; BCWebsiteMap.prototype.placePoints = function() { var googleMap = this.googleMap; if (googleMap && googleMap.activated() && googleMap.map) { for ( var index = BCSite.mapWindowDialog.data.items.length - 1; index != -1; --index) { var coordinate = null; eval('coordinate = new google.maps.LatLng(' + BCSite.mapWindowDialog.data.items[index].coordinate + ');'); var mapPoint = new Object(); mapPoint.coordinate = BCSite.mapWindowDialog.data.items[index].coordinate; mapPoint.local = ''; mapPoint.city = ''; mapPoint.address = ''; if (BCSite.mapWindowDialog.data.items[index].designation) mapPoint.designation = BCSite.mapWindowDialog.data.items[index].designation; else mapPoint.designation = ''; googleMap.placeMarker(coordinate, false, false, mapPoint); } var coordinate = null; eval('coordinate = new google.maps.LatLng(' + BCSite.mapWindowDialog.currentPointInfo.coordinate + ');'); googleMap.map.setCenter(coordinate); } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').placePoints()', 800); } }; BCWebsiteNews.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteNews.prototype.constructor = BCWebsiteNews; function BCWebsiteNews(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsiteNews.prototype.draw = function() { BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); } BCWebsiteNewsletter.prototype = new KPageDialog(); BCWebsiteNewsletter.prototype.constructor = BCWebsiteNewsletter; function BCWebsiteNewsletter(parent) { if (parent) { KPageDialog.call(this, parent); this.addCSSClass('BCWebsiteNewsletter'); this.newsletterForm = new KForm(this); this.newsletterForm.staticForm = true; this.newsletterForm.action = 'php:Entity:SubscribeNewsletter'; this.setStyle({ position : 'fixed' }); BCWebsiteNewsletter.newsletterCategory = null; this.translations = null; } } BCWebsiteNewsletter.prototype.onLoad = function(data) { KSystem.merge(this.data, data); KPage.prototype.onLoad.call(this, this.data); } BCWebsiteNewsletter.prototype.onShow = function() { KPageDialog.prototype.onShow.call(this); this.setStyle({ left : (Math.floor(KSystem.getBrowserWidth() / 2)) + 'px', top : '42px' }); this.hideContext('result'); this.showContext('form'); this.newsletterForm.reset(); } BCWebsiteNewsletter.prototype.draw = function() { this.loadTranslations(); var dataTitle = new KText(this); dataTitle.setText(this.translations.dataTitle); this.appendChild(dataTitle, 'form'); var subscriberName = new KInput(this.newsletterForm, 'text', this.translations.name, 'entityName'); subscriberName.addCSSClass('NewsletterInput'); subscriberName.addValidator(/.+/, 'campo de preenchimento obrigat\u00f3rio'); subscriberName.setStyle({ labelPosition : 'inside' }); this.newsletterForm.addInput(subscriberName); var subscriberEmail = new KInput(this.newsletterForm, 'text', this.translations.email, 'entityEmail'); subscriberEmail.addCSSClass('NewsletterInput'); subscriberEmail.addValidator(/(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/, 'campo de preenchimento obrigat\u00f3rio'); subscriberEmail.setStyle({ labelPosition : 'inside' }); this.newsletterForm.addInput(subscriberEmail); this.newsletterForm.clearBoth(); var categoryTitle = new KText(this.newsletterForm); categoryTitle.setText(this.translations.categoriesTitle); categoryTitle.setStyle({ marginTop : '6px' }); this.newsletterForm.appendChild(categoryTitle); var categoriesChecks = new KCheckBox(this.newsletterForm, '', 'newsletterCategory', false); for ( var index in this.data.categoriaDeNewsletter.itemList) { categoriesChecks.addOption(this.data.categoriaDeNewsletter.itemList[index].id, this.data.categoriaDeNewsletter.itemList[index].title, true); } this.newsletterForm.addInput(categoriesChecks); var submitButton = new BCWebsiteKInput(this.newsletterForm, this.translations.submit, 'submit'); this.newsletterForm.addInput(submitButton); this.newsletterForm.onValidate = function(data, params, status) { if (status) { params.biocolNewsletter = 1; this.disable(); return params; } else { var first = true; for ( var index in params) { var input = params[index].getInput(); if (first) { first = false; input.focus(); } input.style.color = 'red'; } } }; this.newsletterForm.onSuccess = function(data) { this.enable(); this.reset(); /* * BCSite.dialogWindow.params.type = 1; * * KDialog.show(BCSite.dialogWindow, { content : (data.errorCode == 1 ? this.parent.translations.successText : this.parent.translations.errorText ), title : (data.errorCode == 1 ? this.parent.translations.successTitle : this.parent.translations.errorTitle ) }); if (data.errorCode != 1){ BCSite.dialogWindow.widgetTitle.childNodes[0].style.color = 'red'; } */ var widget = this.getParent(); widget.resultText.setText(data.errorCode == 1 ? this.parent.translations.successText : this.parent.translations.errorText); widget.hideContext('form'); widget.showContext('result'); }; this.newsletterForm.reset = function() { for ( var element in this.inputByID) { if (this.inputByID[element].getValue() != '') { this.inputByID[element].setValue(null); } } } this.appendChild(this.newsletterForm, 'form'); this.resultText = new KText(this); this.appendChild(this.resultText, 'result'); KPageDialog.prototype.draw.call(this); } BCWebsiteOpportunity.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteOpportunity.prototype.constructor = BCWebsiteOpportunity; function BCWebsiteOpportunity(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsiteOpportunity.prototype.draw = function() { if (this.childWidget('/job-form')){ var clearBoth = new KPanel(this); clearBoth.addCSSClass('ClearBothIe'); clearBoth.go(); this.insertBefore(clearBoth, null, this.childWidget('/job-form')); } BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); } BCWebsitePressRelease.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsitePressRelease.prototype.constructor = BCWebsitePressRelease; function BCWebsitePressRelease(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsitePressRelease.prototype.draw = function() { BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); } BCWebsiteProductDetail.prototype = new BCWebsiteThreeColumnHighlight(); BCWebsiteProductDetail.prototype.constructor = BCWebsiteProductDetail; BCWebsiteProductDetail.prototype.heightFix = 450; function BCWebsiteProductDetail(parent) { if (parent != null) { BCWebsiteThreeColumnHighlight.call(this, parent); } } BCWebsiteProductDetail.prototype.draw = function() { BCWebsiteThreeColumnHighlight.prototype.draw.call(this); var parentPage = Kinky.site.childWidget('/' + this.getHash().split('/')[1] + '/' + this.getHash().split('/')[2]); var parentColor = parentPage.data.graphicStyle.colors.blockGraphicalDefinition.text; var h2collection = this.childWidget('/richtext').content.getElementsByTagName('h2'); if (h2collection && h2collection.length > 0) { for ( var index in h2collection) { if (h2collection[index].tagName == 'H2') { h2collection[index].style.color = parentColor; } } } } BCWebsiteSearch.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteSearch.prototype.constructor = BCWebsiteSearch; function BCWebsiteSearch(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsiteSearch.prototype.draw = function() { BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); } BCWebsiteStoreFinder.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteStoreFinder.prototype.constructor = BCWebsiteStoreFinder; function BCWebsiteStoreFinder(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); // this.addLocationListener(BCWebsiteStoreFinder.addScrollListener); this.timer = null; } } BCWebsiteStoreFinder.prototype.draw = function() { // this.mapContainer = new KPanel(this); // this.mapContainer.addCSSClass('MapContainer'); // // var maximizeBt = new KLink(this.mapContainer, 'javascript:void(0);', '/images/site/map_maximize.png'); // this.mapContainer.appendTitleChild(maximizeBt); // maximizeBt.addEventListener('click', function() { // KDialog.show(BCSite.mapWindowDialog, { // content : new BCWebsiteMap(BCSite.mapWindowDialog), // title : '' // }); // }); // // this.googleMap = new KMap(this.mapContainer, '', 'locations'); // { // this.googleMap.hash = '/right-panel/map'; // this.googleMap.searchBox = false; // this.googleMap.draggableMarkers = false; // this.googleMap.showInfoWindow = true; // this.googleMap.initialZoom = 11; // this.googleMap.maxMarkers = 0; // this.googleMap.removeOption = false; // this.googleMap.defaultIcon = '/images/site/map_pointer.png'; // // this.googleMap.designationBox = false; // } // // this.mapContainer.appendChild(this.googleMap); // this.mapContainer.setStyle( { // top : '292px' // }); // var bottomDiv = window.document.createElement('div'); // bottomDiv.className = 'BottomDiv'; // this.mapContainer.content.appendChild(bottomDiv); // this.appendChild(this.mapContainer); BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); }; BCWebsiteStoreFinder.addScrollListener = function(widget, location){ if (location == '/localizador-de-lojas'){ if (widget.mapContainer){ var top = widget.mapContainer.panel.style.top; var newTop = null; this.timer = KSystem.addTimer(function(){ newTop = window.document.documentElement.scrollTop + parseInt(top.replace('px', '') - 200); if ((parseInt(Kinky.site.panel.style.height.replace('px', '')) - newTop) < 960){ newTop = parseInt(Kinky.site.panel.style.height.replace('px', '')) - 960 ; }else if( newTop < 292){ newTop = 292; } KEffects.addEffect(widget.mapContainer, { f : KEffects.easeOutExpo, type : 'move', duration : 1000, gravity : { y : 'top' }, go : { y : newTop }, lock : { x : true } }); }, 500, true); } }else{ if (this.timer){ KSystem.removeTimer(this.timer); this.timer = null; } } }; BCWebsiteTextPage.prototype = new BCWebsiteTwoColumnNoHighlight(); BCWebsiteTextPage.prototype.constructor = BCWebsiteTextPage; function BCWebsiteTextPage(parent) { if (parent != null) { BCWebsiteTwoColumnNoHighlight.call(this, parent); } } BCWebsiteTextPage.prototype.draw = function() { BCWebsiteTwoColumnNoHighlight.prototype.draw.call(this); } BCKList.prototype = new KList(); BCKList.prototype.constructor = BCKList; function BCKList(parent) { if (parent != null) { KList.call(this, parent); } } BCKList.prototype.setTotalPages = function(mpages, clickable) { this.totalPages = (mpages > 0) ? mpages : 0; this.pagination.innerHTML = ''; if (this.hasTopPagination) { this.topPagination.getElementsByTagName('div')[0].innerHTML = ''; } for ( var i = 0; i < this.totalPages; i++) { var pagesHTML = document.createElement('div'); pagesHTML.className = ' PgNumb ' + this.className + 'PgNum' + (i + 1) + ((this.nPage == i) ? " PgCurrent " : " "); pagesHTML.innerHTML = (i + 1); if (this.nPage == i){ pagesHTML.style.color = Kinky.site.colors.menuColor1; } if (clickable) { KSystem.addEventListener(pagesHTML, 'click', BCKList.onPaginationClick); } if (this.hasTopPagination) { var clonenode = pagesHTML.cloneNode(true); if (clickable) { KSystem.addEventListener(clonenode, 'click', BCKList.onPaginationClick); } this.topPagination.getElementsByTagName('div')[0].appendChild(clonenode); } this.pagination.appendChild(pagesHTML); } }; BCKList.prototype.draw = function(){ KList.prototype.draw.call(this); var botoes = this.paginationBar.getElementsByTagName('BUTTON'); for (var i = 0; i != botoes.length; i++){ botoes[i].style.color = Kinky.site.colors.titleColor1; if (/Prev/.test(botoes[i].className)){ botoes[i].innerHTML = '<'; }else{ botoes[i].innerHTML = '>'; } } }; BCKList.prototype.hideContext = function(context, element) { KCSS.removeCSSClass('PgCurrent', this.pagination.childNodes[this.nPage]); this.pagination.childNodes[this.nPage].style.color = Kinky.site.colors.textColor; KList.prototype.hideContext.call(this, context, element); }; BCKList.prototype.showContext = function(context, element) { if (this.totalPages > 1) { KCSS.addCSSClass('PgCurrent', this.pagination.childNodes[this.nPage]); this.pagination.childNodes[this.nPage].style.color = Kinky.site.colors.menuColor1; } KList.prototype.showContext.call(this, context, element); }; BCKList.onPaginationClick = function(evt) { var widget = KSystem.getEventWidget(evt); var myTarget = KSystem.getEventTarget(evt); var indx = (/[0-9]/.exec(myTarget.className)[0] * 1) - 1; KCSS.addCSSClass('PgCurrent', myTarget); myTarget.style.color = Kinky.site.colors.menuColor1; KCSS.removeCSSClass('PgCurrent', myTarget.parentNode.childNodes[widget.nPage]); myTarget.parentNode.childNodes[widget.nPage].style.color = Kinky.site.colors.textColor; var pageGoTo = '/page/' + indx; if (widget.paginationDispatchType == KBreadcrumb.DISPATCH_URL) { KBreadcrumb.dispatchURL( { action : pageGoTo }); } else { KBreadcrumb.dispatchEvent(widget.id, { action : pageGoTo }); } }; BCWebsiteKList.prototype = new KList(); BCWebsiteKList.prototype.constructor = BCWebsiteKList; function BCWebsiteKList(parent) { if (parent != null) { KList.call(this, parent); this.paginationBar.removeChild(this.prevButton); this.paginationBar.removeChild(this.nextButton); this.perPage = 10; this.nPage = 0; this.isPaginated = true; this.showReadMore = true; this.widget_translations = {}; this.loadTranslations(); var translations = this.getTranslation('BCWebsiteKList'); var prevBt = new BCWebsiteKButton(this, '< ' + translations.previousPage, 'less', null); prevBt.go(); var nextBt = new BCWebsiteKButton(this, translations.nextPage + ' >', 'more', null); nextBt.go(); this.prevButton = prevBt; this.paginationBar.appendChild(this.prevButton.panel); this.prevButton.addEventListener('click', function(e){ var widget = KSystem.getEventWidget(e, 'BCWebsiteKList'); KWidget.dispatchPrevious(e, widget); }); this.nextButton = nextBt; this.paginationBar.appendChild(this.nextButton.panel); this.nextButton.addEventListener('click', function(e){ var widget = KSystem.getEventWidget(e, 'BCWebsiteKList'); KWidget.dispatchNext(e, widget); }); } } BCWebsiteKList.prototype.loadTranslations = function() { }; BCWebsiteKList.prototype.getTranslation = function(widgetClass) { if (this.widget_translations[widgetClass]) { return this.widget_translations[widgetClass]; } }; BCWebsiteKList.prototype.setTotalPages = function(mpages, clickable) { this.totalPages = (mpages > 0) ? mpages : 0; this.pagination.innerHTML = ''; if (this.hasTopPagination) { this.topPagination.getElementsByTagName('div')[0].innerHTML = ''; } var pagesHTML = document.createElement('div'); pagesHTML.innerHTML = this.nPage + 1 + '/' + this.totalPages; this.pagination.appendChild(pagesHTML); }; BCWebsiteKList.prototype.showContext = function(context, element) { if(this.pagination.childNodes[0].tagName == 'DIV'){ this.pagination.childNodes[0].innerHTML = this.nPage + 1 + '/' + this.totalPages; } if (this.totalPages <= 1) { this.setStyle( { display : 'none' }, KWidget.PAGINATION_DIV); }else{ this.setStyle( { display : 'block' }, KWidget.PAGINATION_DIV); } KList.prototype.showContext.call(this, context, element); }; BCProfessionalAreaGallery.prototype = new KPanel(); BCProfessionalAreaGallery.prototype.constructor = BCProfessionalAreaGallery; function BCProfessionalAreaGallery(parent) { if (parent != null) { KPanel.call(this, parent); this.addQueryListener(BCProfessionalAreaGallery.changeGallery, [ '/category/*' ]); this.loadService = true; } } BCProfessionalAreaGallery.prototype.onLoad = function(data) { this.data.galleryItems = data.galleryItems; this.draw(); } BCProfessionalAreaGallery.prototype.draw = function() { if (this.parent.childWidget('/menu').data && this.parent.childWidget('/menu').data.itemList && this.getQuery()) { var brotherData = this.parent.childWidget('/menu').data.itemList; var categoryID = this.getQuery().split('/')[2]; for ( var menuIdx in brotherData) { if (brotherData[menuIdx].id == categoryID) { this.setTitle(brotherData[menuIdx].title); break; } } } if (this.data.galleryItems && this.data.galleryItems.length > 0) { for ( var index in this.data.galleryItems) { var item = new KText(this); item.setTitle(this.data.galleryItems[index].fileTitle); item.setText('Download'); item.file = this.data.galleryItems[index].fileInternalPath; item.addEventListener('click', function(e) { var widget = KSystem.getEventWidget(e); window.open(widget.file); }, KWidget.CONTENT_DIV); this.appendChild(item); } } else { var noContent = new KText(this); noContent.addCSSClass('NoContent'); noContent.setText('N\u00e3o existem resultados a apresentar.'); this.appendChild(noContent); } KPanel.prototype.draw.call(this); }; BCProfessionalAreaGallery.changeGallery = function(widget, query) { widget.data.config.categoryID = query.split('/')[2]; widget.refresh(); }; BCProfessionalAreaMenu.prototype = new KPanel(); BCProfessionalAreaMenu.prototype.constructor = BCProfessionalAreaMenu; function BCProfessionalAreaMenu(parent) { if (parent != null) { KPanel.call(this, parent); this.addQueryListener(BCProfessionalAreaMenu.changeGallery, [ '/category/*' ]); this.loadService = true; this.lastMarked = null; this.hash = '/menu'; } } BCProfessionalAreaMenu.prototype.onShow = function() { if (!this.getQuery()){ KBreadcrumb.dispatchURL({ query : '/category/' + this.data.itemList[0].id }); } } BCProfessionalAreaMenu.prototype.onLoad = function(data) { this.removeAllChildren(); this.data.itemList = {}; KSystem.merge(this.data.itemList, data.itemList); this.draw(); }; BCProfessionalAreaMenu.prototype.draw = function() { for (var index in this.data.itemList){ var menuItem = new KLink(this, 'javascript:void(0);'); menuItem.setLinkText(this.data.itemList[index].title.replace('\u00c1rea Profissional ', '')); menuItem.hash = '/category/' + this.data.itemList[index].id; menuItem.addEventListener('click', function(e){ var widget = KSystem.getEventWidget(e); KBreadcrumb.dispatchURL({ query : widget.hash }); }); this.appendChild(menuItem); } KPanel.prototype.draw.call(this); }; BCProfessionalAreaMenu.changeGallery = function(widget, query) { if (widget.lastMarked){ widget.lastMarked.removeCSSClass('Selected'); } var element = widget.childWidget(query); element.addCSSClass('Selected'); widget.lastMarked = element; }; BCFormContact.prototype = new KForm(); BCFormContact.prototype.constructor = BCFormContact; function BCFormContact(parent) { if (parent != null) { KForm.call(this, parent); this.staticForm = true; this.action = 'php:Contact:Submit'; this.translations = null; } } BCFormContact.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); var contactName = new KInput(this, 'text', this.translations.name, 'contactName'); contactName.addCSSClass('NameInput'); contactName.setStyle({ labelPosition : 'inside' }); contactName.addValidator(/.+/, ''); this.addInput(contactName); var contactEmail = new KInput(this, 'text', this.translations.email, 'contactEmail'); contactEmail.addCSSClass('EmailInput'); contactEmail.setStyle({ labelPosition : 'inside' }); contactEmail.addValidator(/(\w+@[a-zA-Z_-]+?\.[a-zA-Z]{2,6})/, ''); this.addInput(contactEmail); var contactPhone = new KInput(this, 'text', this.translations.phone, 'contactPhone'); contactPhone.addCSSClass('PhoneInput'); contactPhone.setStyle({ labelPosition : 'inside' }); this.addInput(contactPhone); var contactMessage = new KInput(this, 'textarea', this.translations.message, 'contactMessage'); contactMessage.addCSSClass('MessageInput'); contactMessage.setStyle({ labelPosition : 'inside' }); contactMessage.addValidator(/.+/, ''); this.addInput(contactMessage); var mandatoryText = new KText(this); mandatoryText.addCSSClass('MandatoryText'); mandatoryText.setText(this.translations.mandatoryFields); this.appendChild(mandatoryText); var submitButton = new BCButton(this, this.translations.submit, 'submit'); this.addInput(submitButton); KForm.prototype.draw.call(this); }; BCFormContact.prototype.onValidate = function(text, params, status) { if (status) { params.categoryID = this.data.config.contentID; return params; } else { var first = true; for ( var element in params) { var input = params[element].getInput(); if (first) { first = false; input.focus(); } input.style.color = 'red'; // params[element].showErrorMessage(); } return false; } }; BCFormContact.prototype.onSuccess = function(data) { BCMicroSite.dialogWindow.params.type = 0; KDialog.show(BCMicroSite.dialogWindow, { content : (data.errorCode == 1 ? this.translations.successText : this.translations.errorText ), title : (data.errorCode == 1 ? this.translations.successTitle : this.translations.errorTitle ) }); if (data.errorCode != 1){ BCMicroSite.dialogWindow.widgetTitle.childNodes[0].style.color = '#EF4048'; } }; BCFormContact.prototype.onError = function(data) { KDialog.show(BCMicroSite.dialogWindow, { content : this.translations.errorText, title : this.translations.errorTitle, closeCallback : function(widget) { KDialog.close(null, BCMicroSite.dialogWindow); } }); }; BCMappedList.prototype = new KPanel(); BCMappedList.prototype.constructor = BCMappedList; function BCMappedList(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; } } BCMappedList.prototype.onLoad = function(data) { if (!this.data){ this.data = {}; } KSystem.merge(this.data, data); this.draw(); } BCMappedList.prototype.draw = function() { var translations = this.getParent('KPage').getTranslation(this.className); if (this.data.itemList.length > 0) { // lista do topo, com mapeamento: var topList = new KPanel(this); topList.addCSSClass('TopList'); this.appendChild(topList); var bottomBorder = window.document.createElement('div'); bottomBorder.className = 'BottomBorder'; topList.childDiv(KWidget.CONTAINER_DIV).appendChild(bottomBorder); // lista do fundo: var mainList = new KPanel(this); mainList.addCSSClass('MainList'); var count = 0; for ( var index in this.data.itemList) { var itemInfo = this.data.itemList[index]; var link = this.getLink({ query : '/scroll/' + itemInfo.id }); var topLink = new KLink(this, link); topLink.setLinkText(itemInfo.title); topLink.addCSSClass('TopLink'); topList.appendChild(topLink); var backLink = this.getLink({ query : '' }); var topAnswer = new KPanel(this); topAnswer.addCSSClass('TopAnswer'); var backToTop = new KLink(topAnswer, backLink); backToTop.setLinkText(translations.btBack); backToTop.addCSSClass('TopLink'); backToTop.setStyle({ backgroundPosition : '0px 0px' }); backToTop.addEventListener('click', function(event) { KEffects.addEffect(backToTop, { f : KEffects.easeOutExpo, type : 'window-scroll-to', duration : 1000, go : { x : 0, y : 0 } }); }); backToTop.addEventListener('mouseover', function(event) { var widget = KSystem.getEventWidget(event); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'background-move', duration : 400, go : { x : 0, y : -5 } }); }); backToTop.addEventListener('mouseout', function(event) { var widget = KSystem.getEventWidget(event); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'background-move', duration : 400, go : { x : 0, y : 0 } }); }); topAnswer.appendChild(backToTop); mainList.appendChild(topAnswer); var mainText = new KText(this); mainText.addCSSClass('MainText'); mainText.setTitle(itemInfo.title); mainText.setText(itemInfo.text); mainText.addQueryListener(function(widget, query) { KEffects.addEffect(backToTop, { f : KEffects.easeOutExpo, type : 'window-scroll-to', duration : 1000, go : { x : 0, y : widget.offsetTop() - 36 } }); }, [ '/scroll/' + itemInfo.id ]); mainList.appendChild(mainText); if (Kinky.site.colors && Kinky.site.colors.textColor) { topLink.setStyle({ color : Kinky.site.colors.textColor }, KLink.LINK_ELEMENT); backToTop.setStyle({ color : Kinky.site.colors.textColor }, KLink.LINK_ELEMENT); mainText.setStyle({ color : Kinky.site.colors.textColor }); } if (Kinky.site.colors && Kinky.site.colors.titleColor2) { mainText.setStyle({ color : Kinky.site.colors.titleColor2 }, KWidget.TITLE_DIV); } count++; if (count % 3 == 0) { topList.clearBoth(); } } this.appendChild(mainList); } else { var noContent = new KText(this); noContent.addCSSClass('NoContent'); noContent.setText(translations.noContent); if (Kinky.site.colors && Kinky.site.colors.textColor) { noContent.setStyle({ color : Kinky.site.colors.textColor }); } this.appendChild(noContent); } KPanel.prototype.draw.call(this); }; BCGallery.prototype = new KList(); BCGallery.prototype.constructor = BCGallery; function BCGallery(parent) { if (parent != null) { KList.call(this, parent); this.hash = '/rotation-gallery'; this.perPage = 1; this.waitForLoad = true; } this.afterNext = function() { KBreadcrumb.dispatchEvent(this.id, { action : '/page/0' }); }; this.beforePrevious = function() { KBreadcrumb.dispatchEvent(this.id, { action : '/page/' + (this.totalCount - 1) }); }; } BCGallery.prototype.onLoad = function(data) { if (this.data == null) { this.data = {}; } KSystem.merge(this.data, data); this.draw(); }; BCGallery.prototype.draw = function() { if (this.data.highlightItems.length > 0) { for ( var index in this.data.highlightItems) { var fileInfo = this.data.highlightItems[index]; var image = new KImage(this, fileInfo.image); image.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 1000, go : { alpha : 1 }, from : { alpha : 0 } } }; image.waitForLoad = true; image.onShow = function() { this.setStyle({ width : this.data.width + 'px', opacity : '0' }); this.parent.width = this.data.width; this.parent.setStyle({ width : this.data.width + 'px' }); Kinky.site.backgroundPage.width = this.data.width; Kinky.site.backgroundPage.setStyle({ width : this.data.width + 'px', left : Math.round((Math.max(960, KSystem.getBrowserWidth()) - this.data.width) / 2) + 'px' }); KImage.prototype.onShow.call(this); }; this.appendChild(image); } this.totalCount = this.nChildren; } this.setTotalPages(this.totalCount, false); KList.prototype.draw.call(this); }; BCGallery.prototype.setTotalPages = function(mpages, clickable) { this.totalPages = (mpages > 0) ? mpages : 0; this.pagination.innerHTML = ''; for ( var i = 0; i < this.totalPages; i++) { var pagesHTML = document.createElement('div'); pagesHTML.className = ' ' + this.className + 'PgNumb ' + this.className + 'PgNum' + (i + 1) + ((this.nPage == i) ? " " + this.className + "PgCurrent " : " "); pagesHTML.innerHTML = ' '; KSystem.addEventListener(pagesHTML, 'click', BCGallery.onPaginationClick); if(Kinky.site.theme != null && Kinky.site.theme != '' && Kinky.site.theme != 'none') { pagesHTML.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; } pagesHTML.style.backgroundRepeat = 'no-repeat'; this.pagination.appendChild(pagesHTML); } }; BCGallery.onPaginationClick = function(evt) { clearTimeout(BCHomepage.rollOverTimer); var backSite = Kinky.site.childWidget('/backgroundPage').childWidget('/rotation-gallery'); var myTarget = KSystem.getEventTarget(evt); var indx = (/[0-9]/.exec(myTarget.className)[0] * 1) - 1; KBreadcrumb.dispatchEvent(backSite.id, { action : '/page/' + indx }); if (backSite.totalCount > 1) BCHomepage.rollOverTimer = setTimeout(BCHomepage.doAutoNext, BCHomepage.Time); }; BCGallery.prototype.hideContext = function(context, element) { KWidget.prototype.hideContext.call(this, context, element); if(this.totalPages > 0) KCSS.removeCSSClass(this.className + 'PgCurrent', this.pagination.childNodes[this.nPage]); }; BCGallery.prototype.showContext = function(context, element) { this.setStyle({ opacity : 0 }); KWidget.prototype.showContext.call(this, context, element); if(this.totalPages > 0) KCSS.addCSSClass(this.className + 'PgCurrent', this.pagination.childNodes[this.nPage]); }; BCFooterLeftMenu.prototype = new KIndex(); BCFooterLeftMenu.prototype.constructor = BCFooterLeftMenu; function BCFooterLeftMenu(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); BCFooterLeftMenu.activeTool = null; } } BCFooterLeftMenu.prototype.draw = function() { this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); this.markIndex(this.getHash()); }; BCFooterLeftMenu.prototype.loadIndex = function(page, level, topUL, parent, pageIndex) { if (!pageIndex) { pageIndex = 1; } var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page, pageIndex++); } } else { if (level == 1) { var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); a.appendChild(window.document.createTextNode(page.menuText)); a.style.color = Kinky.site.colors.footerMenuColor2; a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; li.appendChild(a); topUL.appendChild(li); } } }; BCFooterMenu.prototype = new KIndex(); BCFooterMenu.prototype.constructor = BCFooterMenu; function BCFooterMenu(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); BCFooterMenu.activeTool = null; } } BCFooterMenu.prototype.draw = function() { var biocolLink = new KLink(this, 'http://www.biocol.pt', '', '_blank'); biocolLink.addCSSClass('BCFooterLogo'); biocolLink.setStyle({ backgroundImage: 'url("' + Kinky.site.theme + '")', backgroudRepeat: 'no-repeat' }, KLink.TEXT_ELEMENT); this.appendChild(biocolLink); this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); this.markIndex(this.getHash()); var sharePanel = new KPanel(this); sharePanel.hash = '/share-panel'; sharePanel.addCSSClass('BCSharePanel'); var facebookShare = new KButton(this, ' ', 'shareBook', BCFooterMenu.shareMe); facebookShare.addCSSClass('BCShareBook'); sharePanel.appendChild(facebookShare); var twitterShare = new KButton(this, ' ', 'shareTwitter', BCFooterMenu.shareMeTwitter); twitterShare.addCSSClass('BCShareTwitter'); sharePanel.appendChild(twitterShare); this.appendChild(sharePanel); sharePanel.go(); }; BCFooterMenu.shareMe = function(event) { var widget = KSystem.getEventWidget(event); window.open('http://www.facebook.com/sharer.php?u=http://' + encodeURIComponent(window.location.host) + '/' + Kinky.DEFAULT_LANG + '/'); }; BCFooterMenu.shareMeTwitter = function(event) { var widget = KSystem.getEventWidget(event); window.open('http://twitter.com/home?status=' + encodeURIComponent(BCMicroSite.twitter)); }; BCFooterMenu.prototype.loadIndex = function(page, level, topUL, parent, pageIndex) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page, pageIndex++); } } else { if (level == 1) { var buttonType = ((/newsletter/.test(page.urlHashText) || /professional/.test(page.urlHashText)) ? 'Special' : ''); var li = window.document.createElement('li'); li.name = level; var leftDiv = window.document.createElement('div'); leftDiv.className = 'ButtonLeft' + buttonType; leftDiv.link = page.urlHashText; if (buttonType == 'Special'){ KSystem.addEventListener(leftDiv, 'click', function(e){ var el = KSystem.getEventTarget(e); KBreadcrumb.dispatchURL({ hash: el.link }); }); } var middleDiv = window.document.createElement('div'); middleDiv.className = 'ButtonMiddle' + buttonType; var rightDiv = window.document.createElement('div'); rightDiv.className = 'ButtonRight' + buttonType; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); a.style.color = Kinky.site.colors.footerMenuColor1; a.appendChild(window.document.createTextNode(page.menuText)); a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; middleDiv.appendChild(a); leftDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; leftDiv.style.backgroundRepeat = 'no-repeat'; middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; middleDiv.style.backgroundRepeat = 'no-repeat'; rightDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; rightDiv.style.backgroundRepeat = 'no-repeat'; li.appendChild(leftDiv); li.appendChild(middleDiv); li.appendChild(rightDiv); topUL.appendChild(li); } } }; BCMainMenu.prototype = new KIndex(); BCMainMenu.prototype.constructor = BCMainMenu; function BCMainMenu(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); this.changeMenuIndex = 0; } } BCMainMenu.prototype.setMarked = function(hash) { this.markIndex(hash); }; BCMainMenu.prototype.draw = function() { this.changeMenuIndex = Math.round(this.data.pages.length / 2); this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); this.markIndex(this.getHash()); }; BCMainMenu.prototype.loadIndex = function(page, level, topUL, parent, pageIndex) { if (!pageIndex) { pageIndex = 1; } var menuColor1 = Kinky.site.colors.menuColor1; var menuColor2 = Kinky.site.colors.menuColor2; var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page, pageIndex++); } } else { if (level == 1) { var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var background = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.BACKGROUND_DIV]); background.id = li.id + '_background'; background.className = ' KWidgetPanelBackground MainLinkBackground '; background.style.position = 'absolute'; background.style.top = '-22px'; background.style.left = '0px'; li.appendChild(background); var leftDiv = window.document.createElement('div'); leftDiv.className = 'MainLinkLeft'; leftDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; leftDiv.style.backgroundRepeat = 'no-repeat'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'MainLinkMiddle'; middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; middleDiv.style.backgroundRepeat = 'no-repeat'; var rightDiv = window.document.createElement('div'); rightDiv.className = 'MainLinkRight'; rightDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; rightDiv.style.backgroundRepeat = 'no-repeat'; background.appendChild(leftDiv); background.appendChild(middleDiv); background.appendChild(rightDiv); var contentContainer = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.CONTAINER_DIV]); contentContainer.className = ' KWidgetPanelContentContainer MainLinkContentContainer '; contentContainer.style.clear = 'both'; contentContainer.style.position = 'relative'; li.appendChild(contentContainer); var a = window.document.createElement('a'); contentContainer.appendChild(a); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); if (pageIndex <= this.changeMenuIndex) { a.style.color = menuColor1; } else { a.style.color = menuColor2; } } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); KSystem.addEventListener(a, 'mouseover', function(event) { var liParent = a.parentNode.parentNode; if (liParent.alt != 1) { var target = document.getElementById(li.id + '_background'); KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'move', duration : 450, go : { y : 0 }, lock : { x : true } }); } }); KSystem.addEventListener(a, 'mouseout', function(event) { var liParent = a.parentNode.parentNode; if (liParent.alt != 1) { var target = document.getElementById(li.id + '_background'); KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'move', duration : 450, go : { y : -22 }, lock : { x : true } }); } }); topUL.appendChild(li); this.subIndex[page.urlHashText] = li; } } }; BCMainMenu.prototype.markIndex = function(hash) { if (this.lastMarked[1] != null && this.lastMarked[1] != this.subIndex[hash]) { this.lastMarked[1].alt = 0; var target = document.getElementById(this.lastMarked[1].id + '_background'); KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'move', duration : 450, go : { y : -22 }, lock : { x : true } }); } KIndex.prototype.markIndex.call(this, hash); if (this.lastMarked[1] != null) { this.lastMarked[1].alt = 1; var target = document.getElementById(this.lastMarked[1].id + '_background'); KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'move', duration : 450, go : { y : 0 }, lock : { x : true } }); } }; BCSubPagesMenu.prototype = new KIndex(); BCSubPagesMenu.prototype.constructor = BCSubPagesMenu; function BCSubPagesMenu(parent) { if (parent != null) { KIndex.call(this, parent, 'pageMenu'); this.addLocationListener(BCSubPagesMenu.changeContext); this.setStyle({ display : 'none' }); } } BCSubPagesMenu.prototype.load = function() { if (this.activated()) { this.draw(); } else { this.activate(); } }; BCSubPagesMenu.prototype.draw = function() { var h = this.getHash(); var parentPage = h != null ? Kinky.site.childWidget('/' + h.split('/')[1]) : null; if (parentPage && parentPage.data && parentPage.data.pages) { var parentTitle = new KText(this); parentTitle.addCSSClass('ParentTitle'); parentTitle.setText(parentPage.data.titleText); this.appendChild(parentTitle); this.setStyle( { display : 'block' }); var pageData = new Object(); pageData.pages = parentPage.data.pages; this.loadIndex(pageData); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.markIndex(this.getHash()); } this.activate(); }; BCSubPagesMenu.prototype.loadIndex = function(page, level, topUL, parent) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (level == 1) { var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } if (level == 1) { var leftDiv = window.document.createElement('div'); leftDiv.className = 'LeftBt'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'MiddleBt'; var rightDiv = window.document.createElement('div'); rightDiv.className = 'RightBt'; } var a = window.document.createElement('a'); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; middleDiv.appendChild(a); li.appendChild(leftDiv); li.appendChild(middleDiv); li.appendChild(rightDiv); topUL.appendChild(li); } } if(page.pages.length) { for ( var index = page.pages.length - 1; index != -1; --index) { this.loadIndex(page.pages[index], level + 1, ul, page); } } }; BCSubPagesMenu.changeContext = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof KPageDialog)) { if (!(Kinky.site.childWidget(hash) instanceof BCWebsiteTwoColumnNoHighlight)){ widget.setStyle({ display : 'none' }); return; }else{ widget.setStyle({ display : 'block' }); widget.refresh(); } } }; BCMap.prototype = new KPanel(); BCMap.prototype.constructor = BCMap; function BCMap(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; BCMap.districtSelected = null; this.addQueryListener(BCMap.changeRegion, [ '/region/*' ]); this.hash = '/widget-map'; this.points = {}; this.pointsAddedToMap = {}; } } BCMap.prototype.onLoad = function(data) { this.data.districts = {}; KSystem.merge(this.data.districts, data.districts); this.draw(); }; BCMap.prototype.draw = function() { this.googleMap = new KMap(this, 'Seleccione a sua localiza\u00e7\u00e3o', 'locations'); { this.googleMap.hash = '/onde-comprar/mapa'; this.googleMap.searchBox = false; this.googleMap.draggableMarkers = false; this.googleMap.showInfoWindow = true; this.googleMap.initialZoom = 11; this.googleMap.removeOption = false; this.googleMap.designationBox = false; } this.appendChild(this.googleMap); this.districsPanel = new KPanel(this); this.districsPanel.addCSSClass('RegionPanel'); for ( var index in this.data.districts) { var regionItem = new KLink(this.districsPanel, 'javascript:void(0);'); regionItem.setLinkText(this.data.districts[index].name); regionItem.hash = '/district-item/' + this.data.districts[index].regionID; regionItem.data.districtName = this.data.districts[index].name; regionItem.data.districtID = this.data.districts[index].regionID; if (this.data.districts[index].totalStores > 0) { regionItem.addEventListener('click', function(e) { var widget = KSystem.getEventWidget(e); KBreadcrumb.dispatchURL({ query : '/region/' + widget.data.districtID }); }); regionItem.setStyle({ backgroundImage : 'url("' + Kinky.site.theme + '")', backgroudRepeat : 'no-repeat', backgroundPosition : '-280px -230px' }); } else { regionItem.addCSSClass('WithoutItems'); } this.districsPanel.appendChild(regionItem); } this.appendChild(this.districsPanel); KPanel.prototype.draw.call(this); }; BCMap.changeRegion = function(widget, query) { if (!widget.activated()) { return; } var districtID = query.split('/')[2]; if (widget.districsPanel.childWidget('/district-item/' + districtID)) { if (BCMap.districtSelected) { KEffects.addEffect(BCMap.districtSelected.link, { f : KEffects.easeOutExpo, type : 'rgb', duration : 500, go : { rgb : '#383838' } }); KEffects.addEffect(BCMap.districtSelected.link, { f : KEffects.easeOutExpo, type : 'font-resize', unit : 'px', duration : 500, go : { fontSize : 12 }, from : { fontSize : 18 } }); KEffects.addEffect(BCMap.districtSelected, { f : KEffects.easeOutExpo, type : 'resize', unit : 'px', duration : 500, go : { height : 12 }, from : { height : 20 }, lock : { width : true } }); KEffects.addEffect(BCMap.districtSelected, { f : KEffects.easeOutExpo, type : 'background-move', duration : 500, go : { x : -280, y : -230 } }); BCMap.districtSelected.removeCSSClass('Selected'); } var districtItem = widget.districsPanel.childWidget('/district-item/' + districtID); KEffects.addEffect(districtItem.link, { f : KEffects.easeOutExpo, type : 'rgb', duration : 1000, go : { rgb : '#ffffff' } }); KEffects.addEffect(districtItem.link, { f : KEffects.easeOutExpo, type : 'font-resize', unit : 'px', duration : 500, go : { fontSize : 18 }, from : { fontSize : 12 } }); KEffects.addEffect(districtItem, { f : KEffects.easeOutExpo, type : 'resize', unit : 'px', duration : 500, go : { height : 20 }, from : { height : 12 }, lock : { width : true } }); KEffects.addEffect(districtItem, { f : KEffects.easeOutExpo, type : 'background-move', duration : 1000, go : { x : -420, y : -230 } }); districtItem.addCSSClass('Selected'); var districtName = districtItem.data.districtName; BCMap.districtSelected = districtItem; } if (districtName) { if(widget.points[districtID] == null || widget.points[districtID].length != 1) { var address = { value : districtName == 'V. do Castelo' ? 'Viana do Castelo' : districtName }; widget.googleMap.geocodeAddress(address); widget.googleMap.map.setZoom(11); } else { widget.googleMap.map.setCenter(widget.points[districtID][0]); widget.googleMap.map.setZoom(14); } } }; BCMapGridList.prototype = new BCKList(); BCMapGridList.prototype.constructor = BCMapGridList; function BCMapGridList(parent) { if (parent != null) { BCKList.call(this, parent); this.perPage = 8; this.addQueryListener(BCMapGridList.changeRegion, [ '/region/*' ]); this.isPaginated = true; } } BCMapGridList.prototype.load = function() { if (this.getQuery()) { var regionID = this.getQuery().split('/')[2]; this.data.feServiceArgs = { config : { 'regionID' : regionID, 'stateID' : this.data.config.stateID, 'categoryID' : this.data.config.categoryID } }; } KList.prototype.load.call(this); }; BCMapGridList.changeRegion = function(widget, query) { if (widget.activated()) { widget.refresh(); } }; BCMapGridList.prototype.onShow = function() { if (!this.getQuery() || !this.getQuery().split('/')[2]) { KBreadcrumb.dispatchURL({ query : '/region/23' }); } else { BCKList.prototype.onShow.call(this); } }; BCMapGridList.prototype.onLoad = function(data) { this.data.items = data.items; this.setTotalPages(this.totalPages, true); var bcMapWidget = this.parent.childWidget('/widget-map'); var googleMap = bcMapWidget.googleMap; if (this.getQuery() != null && googleMap) { var coordinate = null; var regionID = this.getQuery().split('/')[2]; if (!bcMapWidget.points[regionID]) { bcMapWidget.points[regionID] = []; } for ( var index in this.data.items) { if (bcMapWidget.pointsAddedToMap[this.data.items[index].coordinate] == null) { eval('coordinate = new google.maps.LatLng(' + this.data.items[index].coordinate + ');'); var mapPoint = new Object(); mapPoint.coordinate = this.data.items[index].coordinate; mapPoint.local = ''; mapPoint.city = ''; mapPoint.address = ''; if (this.data.items[index].designation) mapPoint.designation = this.data.items[index].designation; else mapPoint.designation = ''; googleMap.placeMarker(coordinate, false, false, mapPoint); bcMapWidget.points[regionID].push(coordinate); bcMapWidget.pointsAddedToMap[this.data.items[index].coordinate] = true; } } if (bcMapWidget.points[regionID] != null && bcMapWidget.points[regionID].length == 1) { bcMapWidget.googleMap.map.setCenter(bcMapWidget.points[regionID][0]); bcMapWidget.googleMap.map.setZoom(14); } } this.draw(); }; BCMapGridList.prototype.draw = function() { var translations = this.getParent('KPage').getTranslation(this.className); // se nao houver mais do que uma página, esconder a paginação if (this.data.pageCount <= 1) { this.setStyle({ display : 'none' }, KWidget.PAGINATION_DIV); } if (this.data.items && this.data.items.length > 0) { var count = 0; for ( var index in this.data.items) { if (count % 3 == 0) { var gridPanel = new KPanel(this); gridPanel.hash = '/panel-' + count; this.appendChild(gridPanel); } var item = new KText(gridPanel); item.setTitle(this.data.items[index].name); item.appendTitleText('
' + this.data.items[index].address + '', true); if (this.data.items[index].telephone) { item.appendText('' + translations.telephone + ' ' + this.data.items[index].telephone); } if (this.data.items[index].fax) { item.appendText('' + translations.fax + ' ' + this.data.items[index].fax); } if (this.data.items[index].schedule) { item.appendText('' + translations.schedule + ' ' + this.data.items[index].schedule); } item.data.id = this.data.items[index].locationID; item.data.coordinate = this.data.items[index].coordinate; item.addEventListener('click', function(e) { var widget = KSystem.getEventWidget(e); eval('coordinate = new google.maps.LatLng(' + widget.data.coordinate + ');'); var mapWidget = widget.parent.parent.parent.childWidget('/widget-map'); mapWidget.googleMap.map.setCenter(coordinate); mapWidget.googleMap.map.setZoom(14); }); if (count % 3 == 0) { item.setStyle({ border : 'none' }); } item.setStyle({ color : Kinky.site.colors.menuColor1 }, KWidget.TITLE_DIV); count++; gridPanel.appendChild(item); } } BCKList.prototype.draw.call(this); }; BCContestForm.prototype = new KForm(); BCContestForm.prototype.constructor = BCContestForm; function BCContestForm(parent) { if (parent != null) { KForm.call(this, parent); this.staticForm = true; this.action = 'php:Game:SubmitParticipation'; this.translations = null; } } BCContestForm.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); if (this.data.game && this.data.game.teaser){ var contestPanel = new KPanel(this); contestPanel.setTitle(this.translations.answerTitle); contestPanel.setStyle({ color : Kinky.site.colors.titleColor1 }, KWidget.TITLE_DIV); var contestQuestion = new KText(contestPanel); contestQuestion.addCSSClass('ContestQuestion'); contestQuestion.setText(this.data.game.teaser); contestPanel.appendChild(contestQuestion); var contestMessage = new KInput(contestPanel, 'textarea', this.translations.answer, 'participationAnswer'); contestMessage.addCSSClass('MessageInput'); contestMessage.setStyle({ labelPosition : 'inside' }); contestMessage.addValidator(/.+/, ''); contestPanel.appendChild(contestMessage); this.addInput(contestMessage); this.appendChild(contestPanel); var dataPanel = new KPanel(this); dataPanel.setTitle(this.translations.dataTitle); dataPanel.setStyle({ color : Kinky.site.colors.titleColor1 }, KWidget.TITLE_DIV); { var contestName = new KInput(dataPanel, 'text', this.translations.name, 'participationName'); contestName.addCSSClass('TextInput'); contestName.setStyle({ labelPosition : 'inside' }); contestName.addValidator(/.+/, ''); dataPanel.appendChild(contestName); this.addInput(contestName); var contestEmail = new KInput(dataPanel, 'text', this.translations.email, 'participationEmail'); contestEmail.addCSSClass('TextInput'); contestEmail.setStyle({ labelPosition : 'inside' }); contestEmail.addValidator(/.+/, ''); dataPanel.appendChild(contestEmail); this.addInput(contestEmail); var contestPhone = new KInput(dataPanel, 'text', this.translations.phone, 'participationPhone'); contestPhone.addCSSClass('TextInput'); contestPhone.setStyle({ labelPosition : 'inside' }); contestPhone.addValidator(/.+/, ''); dataPanel.appendChild(contestPhone); this.addInput(contestPhone); var biocolCheck = new KCheckBox(dataPanel, '', 'biocolCheck', true); biocolCheck.addOption(true, this.translations.biocolNewsletter, false, false); dataPanel.appendChild(biocolCheck); this.addInput(biocolCheck); var termsCheck = new KCheckBox(dataPanel, '', 'termsCheck', true); termsCheck.addOption(true, this.translations.termsText, false, false); termsCheck.addValidator(/.+/, ''); dataPanel.appendChild(termsCheck); this.addInput(termsCheck); var submitButton = new BCButton(dataPanel, this.translations.submit, 'submit'); dataPanel.appendChild(submitButton); this.addInput(submitButton); } this.appendChild(dataPanel); }else{ var noActiveContest = new KText(this); noActiveContest.setText('N\u00e3o existem passatempos activos'); this.appendChild(noActiveContest); } KForm.prototype.draw.call(this); }; BCContestForm.prototype.onValidate = function(text, params, status) { if (status) { params.gameID = this.data.game.gameID; return params; } else { var first = true; for ( var element in params) { var input = params[element].getInput(); if (first) { first = false; input.focus(); } input.style.color = 'red'; } return false; } }; BCContestForm.prototype.onSuccess = function(data) { BCMicroSite.dialogWindow.params.type = 0; KDialog.show(BCMicroSite.dialogWindow, { content : (data.errorCode == 1 ? this.translations.successText : this.translations.errorText ), title : (data.errorCode == 1 ? this.translations.successTitle : this.translations.errorTitle ) }); if (data.errorCode != 1){ BCMicroSite.dialogWindow.widgetTitle.childNodes[0].style.color = '#EF4048'; } }; BCContestPagesMenu.prototype = new KIndex(); BCContestPagesMenu.prototype.constructor = BCContestPagesMenu; function BCContestPagesMenu(parent) { if (parent != null) { KIndex.call(this, parent, 'pageMenu'); this.addLocationListener(BCContestPagesMenu.changeContext, ['/passatempo/*']); this.setStyle({ display : 'none' }); BCContestPagesMenu.firstPage = true; } } BCContestPagesMenu.prototype.load = function() { if (this.activated()) { this.draw(); } else { this.activate(); } }; BCContestPagesMenu.prototype.draw = function() { var parentPage = Kinky.site.childWidget('/passatempo'); if (parentPage && parentPage.data && parentPage.data.pages) { var pageData = new Object(); pageData.pages = parentPage.data.pages; this.loadIndex(pageData); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.markIndex(this.getHash()); } this.activate(); }; BCContestPagesMenu.prototype.loadIndex = function(page, level, topUL, parent) { var subMenuColor1 = Kinky.site.colors.subMenuColor1; var subMenuColor2 = Kinky.site.colors.subMenuColor2; var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (level == 1) { if (!BCContestPagesMenu.firstPage){ var div = window.document.createElement('div'); div.className = 'MenuDivision'; topUL.appendChild(div); }else{ BCContestPagesMenu.firstPage = false; } var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); a.style.color = subMenuColor2; if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; li.appendChild(a); topUL.appendChild(li); } } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } }; BCContestPagesMenu.prototype.markIndex = function(hash) { if (!hash) { return; } var paths = hash.split('/'); paths.splice(0, 1); for ( var level in this.lastMarked) { this.removeCSSClass('KIndexMarked', this.lastMarked[level]); this.lastMarked[level].childNodes[0].style.color = Kinky.site.colors.subMenuColor2; } this.lastMarked = {}; var subHash = ''; for ( var path in paths) { subHash += '/' + paths[path]; if (!this.subIndex[subHash]) { continue; } this.lastMarked[this.subIndex[subHash].name] = this.subIndex[subHash]; this.addCSSClass('KIndexMarked', this.subIndex[subHash]); this.subIndex[subHash].childNodes[0].style.color = Kinky.site.colors.subMenuColor1; } }; BCContestPagesMenu.changeContext = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof KPageDialog)){ if (!/passatempo/.test(hash)){ widget.setStyle({ display : 'none' }); return; } widget.setStyle({ display : 'block' }); widget.refresh(); } }; BCContestWinnersList.prototype = new KPanel(); BCContestWinnersList.prototype.constructor = BCContestWinnersList; function BCContestWinnersList(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; this.translations = null; } } BCContestWinnersList.prototype.onLoad = function(data){ if (data.winners){ this.data.winners = {}; KSystem.merge(this.data.winners, data.winners); } this.draw(); }; BCContestWinnersList.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); if (this.data.winners){ var titles = new KText(this, false, null, 'result'); titles.addCSSClass('Title'); titles.setTitle(this.translations.winnerName); titles.setText(this.translations.winnerText); this.appendChild(titles); titles.setStyle({ color : Kinky.site.colors.titleColor1 }); for(var index in this.data.winners){ var result = new KText(this); result.setStyle({ color : Kinky.site.colors.subMenuColor2 }); result.addCSSClass('Winner'); var i = 0; var countHeight = 0; while (this.data.winners[index].answer.length > i){ i = i + 95; countHeight++; } result.setText('
' + this.data.winners[index].name + '
' + this.data.winners[index].answer + '
'); var bottomBorder = window.document.createElement('div'); bottomBorder.className = 'BottomBorder'; result.childDiv(KWidget.CONTAINER_DIV).appendChild(bottomBorder); this.appendChild(result); } } KPanel.prototype.draw.call(this); }; BCLeftPanel.prototype = new KPanel(); BCLeftPanel.prototype.constructor = BCLeftPanel; function BCLeftPanel(parent) { if (parent != null) { KPanel.call(this, parent); this.hash = '/left-panel'; this.addLocationListener(BCLeftPanel.toggleLeftPanel, [ BCMicroSite.productPageHash + '/*', '/area-profissional' ]); this.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : BCPage.FADE_DURATION, go : { alpha : 1 }, from : { alpha : 0 } } }; } } BCLeftPanel.prototype.draw = function() { var products = Kinky.site.childWidget(BCMicroSite.productPageHash); if (products && products.data && products.data.pages) { var pageData = new Object(); pageData.pages = products.data.pages; productMenu = new BCLeftPanelProductsMenu(this, pageData); this.appendChild(productMenu, null, KWidget.CONTENT_DIV); } var productHighlights = new BCProductHighlight(this); this.appendChild(productHighlights); KPanel.prototype.draw.call(this); }; BCLeftPanel.toggleLeftPanel = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof KPageDialog)) { var reg_exp = new RegExp(BCMicroSite.productPageHash); if (reg_exp.test(hash) || /area\-profissional/.test(hash)) { if(widget.loadedChildren == 0) { widget.setStyle({ display : 'block', opacity : '0' }); widget.showContext(); } } else { if(widget.loadedChildren != 0) { widget.setStyle({ display : 'none', opacity : '0' }); widget.hideContext(); } } } }; BCLeftPanelProductsMenu.prototype = new KIndex(); BCLeftPanelProductsMenu.prototype.constructor = BCLeftPanelProductsMenu; function BCLeftPanelProductsMenu(parent, pageData) { if (parent != null) { KIndex.call(this, parent, 'productMenu', pageData); } } BCLeftPanelProductsMenu.prototype.draw = function() { KIndex.prototype.draw.call(this); this.markIndex(this.getHash()); }; BCLeftPanelProductsMenu.prototype.loadIndex = function(page, level, topUL, parent) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (level == 1) { var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } li.appendChild(new BCLeftPanelProductsMenuItem(li, page.menuText, page.urlHashText).childDiv(KWidget.ROOT_DIV)); this.subIndex[page.urlHashText] = li; topUL.appendChild(li); } } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } }; BCLeftPanelProductsMenu.prototype.setMarked = function(hash) { if (this.activated()) { this.markIndex(hash); } }; BCLeftPanelProductsMenu.prototype.markIndex = function(hash) { var level = 1; if (this.lastMarked[level] != null && this.lastMarked[level] != this.subIndex[hash]) { var target = KSystem.getWidget(this.lastMarked[level].childNodes[0]); target.setActive(false); } KIndex.prototype.markIndex.call(this, hash); if (this.lastMarked[level] != null) { var target = KSystem.getWidget(this.lastMarked[level].childNodes[0]); target.setActive(true); } }; BCLeftPanelProductsMenuItem.prototype = new KWidget(); BCLeftPanelProductsMenuItem.prototype.constructor = BCLeftPanelProductsMenuItem; function BCLeftPanelProductsMenuItem(parent, label, urlHashText) { if (parent != null) { KWidget.call(this, parent); this.backgroundContainer = window.document.createElement('div'); this.backgroundContainer.className = 'BCLeftPanelProductsMenuItemBackgroundContainer'; this.backgroundHoverContainer = window.document.createElement('div'); this.backgroundHoverContainer.className = 'BCLeftPanelProductsMenuItemBackgroundHoverContainer'; this.backgroundActiveContainer = window.document.createElement('div'); this.backgroundActiveContainer.className = 'BCLeftPanelProductsMenuItemBackgroundActiveContainer'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.backgroundContainer); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.backgroundHoverContainer); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.backgroundActiveContainer); var topDiv = window.document.createElement('div'); topDiv.className = 'BCLeftPanelProductsMenuItemBackgroundTop'; topDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; topDiv.style.backgroundRepeat = 'no-repeat'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'BCLeftPanelProductsMenuItemBackgroundMiddle'; middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; middleDiv.style.backgroundRepeat = 'no-repeat'; var bottomDiv = window.document.createElement('div'); bottomDiv.className = 'BCLeftPanelProductsMenuItemBackgroundBottom'; bottomDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; bottomDiv.style.backgroundRepeat = 'no-repeat'; this.backgroundContainer.appendChild(topDiv); this.backgroundContainer.appendChild(middleDiv); this.backgroundContainer.appendChild(bottomDiv); var topDiv = window.document.createElement('div'); topDiv.className = 'BCLeftPanelProductsMenuItemBackgroundTop'; topDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; topDiv.style.backgroundRepeat = 'no-repeat'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'BCLeftPanelProductsMenuItemBackgroundMiddle'; middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; middleDiv.style.backgroundRepeat = 'no-repeat'; var bottomDiv = window.document.createElement('div'); bottomDiv.className = 'BCLeftPanelProductsMenuItemBackgroundBottom'; bottomDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; bottomDiv.style.backgroundRepeat = 'no-repeat'; this.backgroundHoverContainer.appendChild(topDiv); this.backgroundHoverContainer.appendChild(middleDiv); this.backgroundHoverContainer.appendChild(bottomDiv); var topDiv = window.document.createElement('div'); topDiv.className = 'BCLeftPanelProductsMenuItemBackgroundTop'; topDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; topDiv.style.backgroundRepeat = 'no-repeat'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'BCLeftPanelProductsMenuItemBackgroundMiddle'; middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; middleDiv.style.backgroundRepeat = 'no-repeat'; var bottomDiv = window.document.createElement('div'); bottomDiv.className = 'BCLeftPanelProductsMenuItemBackgroundBottom'; bottomDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; bottomDiv.style.backgroundRepeat = 'no-repeat'; this.backgroundActiveContainer.appendChild(topDiv); this.backgroundActiveContainer.appendChild(middleDiv); this.backgroundActiveContainer.appendChild(bottomDiv); this.a = window.document.createElement('a'); this.a.appendChild(window.document.createTextNode(label)); this.a.href = (/http:/.test(urlHashText) ? '' : '#') + urlHashText; this.link = urlHashText; this.childDiv(KWidget.CONTENT_DIV).appendChild(this.a); this.setStyle({ fontSize : '16px' }, this.a); if (KBrowserDetect.browser != 2) { this.setStyle({ opacity : (Kinky.BASE_VERSION == '/biocolkids' ? '0.6' : '0') }, this.backgroundHoverContainer); this.setStyle({ opacity : '0' }, this.backgroundActiveContainer); } else { this.setStyle({ display : 'none' }, this.backgroundHoverContainer); this.setStyle({ display : 'none' }, this.backgroundActiveContainer); } KSystem.addEventListener(this.panel, 'click', BCLeftPanelProductsMenuItem.onClick); KSystem.addEventListener(this.panel, 'mouseover', BCLeftPanelProductsMenuItem.onMouseOver); KSystem.addEventListener(this.panel, 'mouseout', BCLeftPanelProductsMenuItem.onMouseOut); this.currentState = false; } } BCLeftPanelProductsMenuItem.prototype.setActive = function(state) { if (state && !this.currentState) { if (KBrowserDetect.browser != 2) { KEffects.addEffect(this.backgroundActiveContainer, { f : KEffects.easeOutExpo, type : 'fade', realAlpha : true, duration : 750, go : { alpha : 1 }, from : { alpha : 0 } }); KEffects.addEffect(this.a, { f : KEffects.easeOutExpo, type : 'font-resize', unit : 'px', duration : 750, go : { fontSize : 20 }, from : { fontSize : 16 } }); } else { this.setStyle({ fontSize : '20px' }, this.a); this.setStyle({ display : 'block' }, this.backgroundActiveContainer); } this.currentState = true; } else if (!state && this.currentState) { if (KBrowserDetect.browser != 2) { KEffects.addEffect(this.backgroundActiveContainer, { f : KEffects.easeOutExpo, type : 'fade', realAlpha : true, duration : 750, go : { alpha : 0 }, from : { alpha : 1 } }); KEffects.addEffect(this.a, { f : KEffects.easeOutExpo, type : 'font-resize', unit : 'px', duration : 750, go : { fontSize : 16 }, from : { fontSize : 20 } }); } else { this.setStyle({ fontSize : '16px' }, this.a); this.setStyle({ display : 'none' }, this.backgroundActiveContainer); } this.currentState = false; } }; BCLeftPanelProductsMenuItem.onClick = function(e) { var el = KSystem.getEventTarget(e); var widget = (el instanceof KWidget ? el : KSystem.getWidget(el)); KBreadcrumb.dispatchURL({ hash : widget.link }); }; BCLeftPanelProductsMenuItem.onMouseOver = function(e) { var el = KSystem.getEventTarget(e); var widget = (el instanceof KWidget ? el : KSystem.getWidget(el)); if (!this.currentState) { if (KBrowserDetect.browser != 2) { KEffects.addEffect(widget.backgroundHoverContainer, { f : KEffects.easeOutExpo, type : 'fade', realAlpha : true, duration : 750, go : { alpha : 1 }, from : { alpha : (Kinky.BASE_VERSION == '/biocolkids' ? 0.6 : 0) } }); } else { widget.setStyle({ display : 'block' }, widget.backgroundHoverContainer); } } }; BCLeftPanelProductsMenuItem.onMouseOut = function(e) { var el = KSystem.getEventTarget(e); var widget = (el instanceof KWidget ? el : KSystem.getWidget(el)); if (!this.currentState) { if (KBrowserDetect.browser != 2) { KEffects.addEffect(widget.backgroundHoverContainer, { f : KEffects.easeOutExpo, type : 'fade', realAlpha : true, duration : 750, go : { alpha : (Kinky.BASE_VERSION == '/biocolkids' ? 0.6 : 0) }, from : { alpha : 1 } }); } else { widget.setStyle({ display : 'none' }, widget.backgroundHoverContainer); } } }; BCProductPagesMenu.prototype = new KIndex(); BCProductPagesMenu.prototype.constructor = BCProductPagesMenu; function BCProductPagesMenu(parent) { if (parent != null) { KIndex.call(this, parent, 'pageMenu'); this.addLocationListener(BCProductPagesMenu.changeContext, [ BCMicroSite.productPageHash + '/*' ]); var styles = { display : 'none', opacity : '0' }; if (Kinky.BASE_VERSION == '/biocolkids'){ styles.background = 'url("images/microsite/kids_product_menu_bk.png")'; styles.height = '80px'; }; this.setStyle(styles); this.effects = { enter : { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : BCPage.FADE_DURATION, go : { alpha : 1 }, from : { alpha : 0 } } }; BCProductPagesMenu.firstPage = true; } } BCProductPagesMenu.prototype.load = function() { this.draw(); }; BCProductPagesMenu.prototype.draw = function() { this.currentProduct = this.getHash().split('/'); var parentPage = Kinky.site.childWidget(BCMicroSite.productPageHash + '/' + this.getHash().split('/')[2]); if (parentPage && parentPage.data && parentPage.data.pages) { var pageData = new Object(); pageData.pages = parentPage.data.pages; this.loadIndex(pageData); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.lastMarked = {}; this.activate(); this.markIndex(this.getHash()); } }; BCProductPagesMenu.prototype.loadIndex = function(page, level, topUL, parent) { var subMenuColor1 = Kinky.site.colors.subMenuColor1; var subMenuColor2 = Kinky.site.colors.subMenuColor2; var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (level == 1) { if (!BCProductPagesMenu.firstPage) { var div = window.document.createElement('div'); div.className = 'MenuDivision'; topUL.appendChild(div); } else { BCProductPagesMenu.firstPage = false; } var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); a.style.color = subMenuColor2; if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; li.appendChild(a); KSystem.addEventListener(a, 'mouseover', function(event) { var target = a; if (target.parentNode.alt != 1) { KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'rgb', duration : 450, go : { rgb : subMenuColor1 } }); } }); KSystem.addEventListener(a, 'mouseout', function(event) { var target = a; if (target.parentNode.alt != 1) { KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'rgb', duration : 450, go : { rgb : subMenuColor2 } }); } }); topUL.appendChild(li); } } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } }; BCProductPagesMenu.prototype.markIndex = function(hash) { var changedProduct = this.checkContext(hash); if (!changedProduct) { var level = 1; var subMenuColor1 = Kinky.site.colors.subMenuColor1; var subMenuColor2 = Kinky.site.colors.subMenuColor2; if (this.lastMarked[level] != null && this.lastMarked[level] != this.subIndex[hash]) { this.lastMarked[level].alt = 0; var target = this.lastMarked[level].childNodes[0]; KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'rgb', duration : 450, go : { rgb : subMenuColor2 } }); } KIndex.prototype.markIndex.call(this, hash); if (this.lastMarked[level] != null) { this.lastMarked[level].alt = 1; var target = this.lastMarked[level].childNodes[0]; KEffects.addEffect(target, { f : KEffects.easeOutExpo, type : 'rgb', duration : 450, go : { rgb : subMenuColor1 } }); } } }; BCProductPagesMenu.prototype.checkContext = function(hash) { var changedProduct = false; if (this.currentProduct) { var parts = this.getHash().split('/'); for ( var index = 0; index != 3; index++) { if (index < this.currentProduct.length && parts[index] == this.currentProduct[index]) { continue; } changedProduct = true; break; } } else { changedProduct = true; } return changedProduct; }; BCProductPagesMenu.changeContext = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof KPageDialog)) { var reg_exp = new RegExp(BCMicroSite.productPageHash); if (!reg_exp.test(hash)) { widget.setStyle({ display : 'none', opacity : '0' }); widget.hideContext(); return; } var changedProduct = widget.checkContext(hash); if (changedProduct) { widget.setStyle({ display : 'block', opacity : '0' }); widget.showContext(); widget.refresh(); } } }; BCLangCombo.prototype = new KCombo(); BCLangCombo.prototype.constructor = BCLangCombo; function BCLangCombo(parent) { if (parent != null) { KCombo.call(this, parent, '', 'langSelect', true); this.staticInput = false; } } BCLangCombo.prototype.load = function() { if (!this.data) this.data = {}; this.data.contentView = 'TemplateBlock(templateHandler)'; this.data.contentID = 'Page:language.list.block.php'; this.data.feService = 'php:Frontend:GetBlock'; this.data.feServiceArgs = { args : { versionCode : Kinky.BASE_VERSION } }; KInput.prototype.load.call(this); }; BCLangCombo.prototype.onLoad = function(data) { KSystem.merge(this.data, data); this.draw(); }; BCLangCombo.prototype.draw = function() { if (this.data.languageList && this.data.languageList.length > 0) { this.onShow = function() { this.setStyle( { display : this.data.languageList.length > 1 ? 'block' : 'none' }); }; var currentLanguage = Kinky.getCurrentLanguage(); var selectedLanguage = window.document.createElement('div'); selectedLanguage.className = 'SelectedLanguage'; selectedLanguage.innerHTML = '
' + currentLanguage.toUpperCase() + '
'; selectedLanguage.id = 'selected-language'; this.childDiv().appendChild(selectedLanguage); this.addEventListener('click', function(event) { var widget = KSystem.getEventWidget(event); KCombo.toggleOptions(event, widget); if (widget.optionsToggled == true) { widget.setStyle( { backgroundPosition : '-64px 0px' }); } else { widget.setStyle( { backgroundPosition : '0px 0px' }); } }); for ( var index in this.data.languageList) { var language = this.data.languageList[index]; if(language != currentLanguage) this.addOption(language, '
' + language.toUpperCase() + '
', false, true); } KCombo.prototype.draw.call(this); var opcoes = this.optionsContent.getElementsByTagName('div'); for ( var i = 0; i != opcoes.length; i++) { if (/KComboOption/.test(opcoes[i].className)) { KSystem.removeEventListener(opcoes[i], 'click', KCombo.selectOption); KSystem.addEventListener(opcoes[i], 'click', this.selectOption); } } } }; BCLangCombo.prototype.selectOption = function(event, element, widget, noChange) { if (!element) { element = KSystem.getEventTarget(event); widget = KCombo.getEventWidget(event); } element = KCombo.getLabel(element); if (element.alt != null && element.alt != '') { widget.selectedOption.value = element.alt; // widget.selectedOptionText.value = // HTML.stripTags(HTMLEntities.decode(element.innerHTML)); document.getElementById('selected-language').innerHTML = '
' + element.alt.toUpperCase() + '
'; window.location = Kinky.SITE_URL + element.alt + '/'; } /* * else { widget.selectedOption.value = ''; widget.selectedOptionText.value = * ''; } */ if (!noChange) { KSystem.fireEvent(widget.selectedOption, 'change'); KSystem.fireEvent(widget.selectedOptionText, 'change'); KSystem.fireEvent(widget.panel, 'change'); } }; BCButton.prototype = new KInput(); BCButton.prototype.constructor = BCButton; function BCButton(parent, label, id) { if (parent != null) { this.simpleWidget = false; KInput.call(this, parent, 'submit', label, id, false); this.addCSSClass('KInput'); this.leftDiv = window.document.createElement('div'); this.leftDiv.className = 'BCButtonLeft'; this.middleDiv = window.document.createElement('div'); this.middleDiv.className = 'BCButtonMiddle'; this.rightDiv = window.document.createElement('div'); this.rightDiv.className = 'BCButtonRight'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.leftDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.middleDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.rightDiv); this.leftDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.leftDiv.style.backgroundRepeat = 'no-repeat'; this.middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.middleDiv.style.backgroundRepeat = 'no-repeat'; this.rightDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.rightDiv.style.backgroundRepeat = 'no-repeat'; } } BCButton.prototype.draw = function() { KInput.prototype.draw.call(this); //this.middleDiv.appendChild(this.inputContainer); } BCContactRichtext.prototype = new KText(); BCContactRichtext.prototype.constructor = BCContactRichtext; function BCContactRichtext(parent) { if (parent != null) { KText.call(this, parent); } } BCContactRichtext.prototype.draw = function() { this.hash = '/richtext/' + this.data.name; if (this.data.config && this.data.config.html){ this.setText(this.data.config.html); } KText.prototype.draw.call(this); if (!(this.data.config && this.data.config.html)){ this.setStyle({ display : 'none' }); } }; BCContinent.prototype = new KImage(); BCContinent.prototype.constructor = BCContinent; function BCContinent(parent, image) { if (parent != null) { KImage.call(this, parent, image); } } BCContinent.prototype.draw = function() { KImage.prototype.draw.call(this); } BCDownloadList.prototype = new KPanel(); BCDownloadList.prototype.constructor = BCDownloadList; function BCDownloadList(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; } } BCDownloadList.prototype.draw = function() { if (this.data.galleryItems.length > 0) { for ( var index in this.data.galleryItems) { var itemInfo = this.data.galleryItems[index]; if (itemInfo.internalFilename && itemInfo.internalFilename != '') { var itemPanel = new KPanel(this); itemPanel.addCSSClass('ItemPanel'); var itemText = new KText(itemPanel); itemText.addCSSClass('ItemText'); itemText.setText(itemInfo.fileTitle); if (itemInfo.iconFilename && itemInfo.iconFilename != '') { var itemImage = new KImage(itemPanel, itemInfo.fileIconPath); itemImage.addCSSClass('ItemImage'); itemPanel.appendChild(itemImage); itemText.setStyle({ width: '155px', paddingTop: '10px' }); } else { itemText.setStyle({ width: '223px' }); } itemPanel.appendChild(itemText); var itemFile = new KLink(itemPanel, itemInfo.fileInternalPath, null, '_blank'); itemFile.setLinkText(itemInfo.internalFilename); itemFile.addCSSClass('ItemFile'); if (Kinky.site.colors && Kinky.site.colors.textColor) { itemText.setStyle({ color: Kinky.site.colors.textColor }); itemFile.setStyle({ color: Kinky.site.colors.textColor }, KLink.LINK_ELEMENT); } itemPanel.appendChild(itemFile); if (itemInfo.downloadIcon && itemInfo.downloadIcon != '') { itemFile.setStyle({ width: '157px' }); var itemIcon = new KImage(this, itemInfo.downloadIcon); itemIcon.addCSSClass('ItemIcon'); itemPanel.appendChild(itemIcon); if (itemInfo.iconFilename && itemInfo.iconFilename != '') { itemFile.setStyle({ paddingTop: '10px' }); itemIcon.setStyle({ paddingTop: '10px' }); } } else { itemFile.setStyle({ width: '177px' }); } var bottomBorder = window.document.createElement('div'); bottomBorder.className = 'BottomBorder'; itemPanel.childDiv(KWidget.CONTAINER_DIV).appendChild(bottomBorder); this.appendChild(itemPanel); } } } KPanel.prototype.draw.call(this); } BCFile.prototype = new KFile(); BCFile.prototype.constructor = BCFile; function BCFile(parent, label, id) { if (parent != null) { this.simpleWidget = false; KFile.call(this, parent, label, id); this.addCSSClass('BCButtonContent', KWidget.CONTENT_DIV); this.addCSSClass('BCDivBackground', KWidget.BACKGROUND_DIV); this.leftDiv = window.document.createElement('div'); this.leftDiv.className = 'BCFileLeft BCBackgroundLeft'; this.middleDiv = window.document.createElement('div'); this.middleDiv.className = 'BCFileMiddle BCBackgroundMiddle'; this.rightDiv = window.document.createElement('div'); this.rightDiv.className = 'BCFileRight BCBackgroundRight'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.leftDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.middleDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.rightDiv); } } BCFile.prototype.draw = function() { KFile.prototype.draw.call(this); }; BCGalleryList.prototype = new KPanel(); BCGalleryList.prototype.constructor = BCGalleryList; function BCGalleryList(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; } } BCGalleryList.prototype.draw = function() { if (this.data.galleryItems.length > 0) { for ( var index in this.data.galleryItems) { var itemInfo = this.data.galleryItems[index]; var itemPanel = new KPanel(this); itemPanel.addCSSClass('ItemPanel'); { if (itemInfo.fileInternalPath && itemInfo.fileInternalPath != '') { var itemImage = new KImage(itemPanel, itemInfo.fileInternalPath); itemImage.addCSSClass('ItemImage'); itemPanel.appendChild(itemImage); } var itemText = new KText(itemPanel); itemText.addCSSClass('ItemText'); itemText.setText(itemInfo.fileDescription); itemPanel.appendChild(itemText); } this.appendChild(itemPanel); } } KPanel.prototype.draw.call(this); } BCGridList.prototype = new KList(); BCGridList.prototype.constructor = BCGridList; function BCGridList(parent) { if (parent != null) { KList.call(this, parent); this.perPage = 30; this.isPaginated = false; } } BCGridList.prototype.onLoad = function(data) { if (!this.data){ this.data = {}; } KSystem.merge(this.data, data); this.draw(); } BCGridList.prototype.draw = function() { if (this.data.itemList && this.data.itemList.length > 0) { var count = 0; var total = this.data.itemList.length; for ( var index in this.data.itemList) { if (count % 2 == 0){ var gridPanel = new KPanel(this); gridPanel.hash = '/panel-' + count; if (total % 2 != 0 && (count + 1) == total){ gridPanel.setStyle({ backgroundImage : 'url(images/microsite/dicas_half_box.png)' }); } this.appendChild(gridPanel); } var gridItem = new KText(gridPanel); gridItem.setTitle(this.data.itemList[index].title); gridItem.setText(this.data.itemList[index].text); gridItem.setStyle({ background : 'url(' + this.data.itemList[index].image + ') no-repeat' }); if (count % 2 == 0){ gridItem.setStyle({ marginRight : '60px' }); } count++; gridPanel.appendChild(gridItem); } } KList.prototype.draw.call(this); } BCHomepageHighlights.prototype = new KPanel(); BCHomepageHighlights.prototype.constructor = BCHomepageHighlights; function BCHomepageHighlights(parent) { if (parent != null) { KPanel.call(this, parent); this.selectedHighlight = null; this.translations = null; } } BCHomepageHighlights.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.setTitle(this.translations.highlightTitle); // var productWizard = new BCWebsiteKButton(this, this.translations.wizardBt, 'wizardBt', null); // productWizard.addEventListener('click', function() { // KBreadcrumb.dispatchURL({ // hash : '/wizard' // }); // }); // this.appendTitleChild(productWizard); var first = true; for ( var index in this.data.highlightItems) { var highlightItem = new KPanel(this); highlightItem.hash = '/highlight-item/' + index; var leftBk = window.document.createElement('div'); leftBk.className = 'LeftBk'; highlightItem.widgetTitle.appendChild(leftBk); var middleBk = window.document.createElement('div'); middleBk.className = 'MiddleBk'; highlightItem.widgetTitle.appendChild(middleBk); var rightBk = window.document.createElement('div'); rightBk.className = 'RightBk'; highlightItem.widgetTitle.appendChild(rightBk); var title = window.document.createElement('h1'); title.style.fontSize = '14px'; title.innerHTML = this.data.highlightItems[index].name; highlightItem.content.appendChild(title); var highlightLink = new KLink(this, this.data.highlightItems[index].url.indexOf('http://') != -1 ? this.data.highlightItems[index].url : '#' + this.data.highlightItems[index].url, this.data.highlightItems[index].image); highlightLink.isImageLink = true; highlightLink.childDiv(KLink.LINK_ELEMENT).setAttribute('target', this.data.highlightItems[index].url.indexOf('http://') != -1 ? '_blank' : '_self'); var lead = this.data.highlightItems[index].lead; if (this.data.highlightItems[index].lead.length > 155) { lead = this.data.highlightItems[index].lead.substr(0, 155) + ' (...)'; } lead += '

' + this.translations.more + ' \u00bb'; highlightLink.setLinkText(lead, true); highlightItem.appendChild(highlightLink); var sectionTitle = window.document.createElement('h2'); sectionTitle.innerHTML = this.data.highlightItems[index].subtitle || ''; highlightItem.content.appendChild(sectionTitle); highlightItem.setStyle({ width : '151px' }); if (KBrowserDetect.browser != 2) { highlightItem.setStyle({ opacity : '0' }, KWidget.BACKGROUND_DIV); } else { highlightItem.setStyle({ display : 'none' }, KWidget.BACKGROUND_DIV); } if (first) { highlightItem.setStyle({ width : '342px', marginLeft : '0', zIndex : '2' }); if (KBrowserDetect.browser != 2) { highlightItem.setStyle({ opacity : '1' }, KWidget.BACKGROUND_DIV); } else { highlightItem.setStyle({ display : 'block' }, KWidget.BACKGROUND_DIV); } this.selectedHighlight = highlightItem.hash; title.style.fontSize = '22px'; first = false; } highlightItem.addEventListener('mouseover', function(e) { var widget = KSystem.getEventWidget(e, 'KPanel'); if (widget.hash != widget.parent.selectedHighlight) { var lastWidget = widget.parent.childWidget(widget.parent.selectedHighlight); if (KBrowserDetect.browser != 2) { lastWidget.setStyle({ opacity : '0' }, KWidget.BACKGROUND_DIV); } else { lastWidget.setStyle({ display : 'none' }, KWidget.BACKGROUND_DIV); } lastWidget.setStyle({ zIndex : '1' }); var widgetTitle = widget.content.getElementsByTagName('h1')[0]; var lastWidgetTitle = lastWidget.content.getElementsByTagName('h1')[0]; KEffects.addEffect(widgetTitle, { f : KEffects.easeOutExpo, type : 'font-resize', unit : 'px', duration : 300, go : { fontSize : 22 } }); KEffects.addEffect(lastWidgetTitle, { f : KEffects.easeOutExpo, type : 'font-resize', unit : 'px', duration : 300, go : { fontSize : 14 } }); widget.setStyle({ zIndex : '2' }); KEffects.addEffect(widget, { f : KEffects.easeOutExpo, type : 'resize', unit : 'px', duration : 1000, go : { width : 342 }, lock : { height : true }, onComplete : function(widget, tween) { if (KBrowserDetect.browser != 2) { lastWidget.setStyle({ opacity : '0' }, KWidget.BACKGROUND_DIV); } else { lastWidget.setStyle({ display : 'none' }, KWidget.BACKGROUND_DIV); } if (KBrowserDetect.browser != 2) { KEffects.addEffect(widget.background, { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 200, go : { alpha : 1 }, from : { alpha : 0 } }); } else { widget.setStyle({ display : 'block' }, KWidget.BACKGROUND_DIV); } } }); KEffects.addEffect(lastWidget, { f : KEffects.easeOutExpo, type : 'resize', unit : 'px', duration : 1000, go : { width : 151 }, lock : { height : true } }); widget.parent.selectedHighlight = widget.hash; } }); this.appendChild(highlightItem); } KPanel.prototype.draw.call(this); } BCKButton.prototype = new KButton(); BCKButton.prototype.constructor = BCKButton; function BCKButton(parent, label, id, callback) { if (parent != null) { this.simpleWidget = false; KButton.call(this, parent, label, id, callback); this.leftDiv = window.document.createElement('div'); this.leftDiv.className = 'BCKButtonLeft'; this.middleDiv = window.document.createElement('div'); this.middleDiv.className = 'BCKButtonMiddle'; this.rightDiv = window.document.createElement('div'); this.rightDiv.className = 'BCKButtonRight'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.leftDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.middleDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.rightDiv); this.leftDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.leftDiv.style.backgroundRepeat = 'no-repeat'; this.middleDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.middleDiv.style.backgroundRepeat = 'no-repeat'; this.rightDiv.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; this.rightDiv.style.backgroundRepeat = 'no-repeat'; } } BCKButton.prototype.draw = function() { KButton.prototype.draw.call(this); }; BCList.prototype = new BCKList(); BCList.prototype.constructor = BCList; function BCList(parent) { if (parent != null) { KList.call(this, parent); this.hash = '/item-list'; /*this.perPage = 2;*/ this.nPage = 0; this.isPaginated = true; this.showReadMore = true; } } BCList.prototype.onLoad = function(data) { if (this.data == null) { this.data = {}; } KSystem.merge(this.data, data); this.draw(); } BCList.prototype.draw = function() { var translations = this.getParent('KPage').getTranslation(this.className); this.totalCount = this.data.pageCount * this.perPage; // se nao houver mais do que uma página, esconder a paginação if (this.data.pageCount <= 1) { this.setStyle({ display: 'none' }, KWidget.PAGINATION_DIV); } if (this.data.itemList.length > 0) { this.setTotalPages(this.data.pageCount, true); for ( var index in this.data.itemList) { var itemInfo = this.data.itemList[index]; var image = (itemInfo.image && itemInfo.image.length) > 0 && itemInfo.image.charAt(itemInfo.image.length-1) != '/' ? itemInfo.image : null; var itemPanel = new KPanel(this); itemPanel.addCSSClass('ItemPanel'); { if (image) { var itemImage = new KImage(itemPanel, image); itemImage.addCSSClass('ItemImage'); itemPanel.appendChild(itemImage); } var itemText = new KText(itemPanel); itemText.hash = '/item-text'; itemText.addCSSClass('ItemText'); itemText.setTitle(itemInfo.title); if (this.showReadMore == true) { // noticias - mostrar a breve descricao itemText.setText(itemInfo.introText); } else { // dicas - mostrar ja a descricao completa itemText.setText(itemInfo.text); } if (image) { itemText.addCSSClass('ShortText'); } if (Kinky.site.colors && Kinky.site.colors.titleColor1) { itemText.setStyle( { color : Kinky.site.colors.titleColor1 }, KWidget.TITLE_DIV); } if (Kinky.site.colors && Kinky.site.colors.textColor) { itemText.setStyle( { color : Kinky.site.colors.textColor }); } itemPanel.appendChild(itemText); if (this.showReadMore == true) { var readMore = new KText(itemPanel); readMore.addCSSClass('BtReadMore'); readMore.setText(translations.readMore); readMore.indice = index; itemPanel.appendChild(readMore); // estado inicial { readMore.NewsToggled = false; readMore.setStyle( { backgroundImage : 'url("' + Kinky.site.theme + '")' }, [ KWidget.CONTENT_DIV, KWidget.TITLE_DIV ]); } var rightBorder = window.document.createElement('div'); rightBorder.className = 'RightBorder'; rightBorder.style.backgroundImage = 'url("' + Kinky.site.theme + '")'; readMore.childDiv(KWidget.CONTAINER_DIV).appendChild(rightBorder); readMore.addEventListener('mouseover', function(event) { var widget = KSystem.getEventWidget(event); if (!widget.NewsToggled) { widget.addCSSClass('BtReadMoreOver'); } }); readMore.addEventListener('mouseout', function(event) { var widget = KSystem.getEventWidget(event); widget.removeCSSClass('BtReadMoreOver'); }); readMore.addEventListener('click', function(event) { var widget = KSystem.getEventWidget(event); var page = widget.getParent('KList'); var textWidget = widget.parent.childWidget('/item-text'); if (!widget.NewsToggled) { // vamos mostrar o detalhe e mudar o botao textWidget.setText(page.data.itemList[widget.indice].text); widget.NewsToggled = true; widget.setText(translations.close); widget.addCSSClass('BtReadMoreSelected'); widget.removeCSSClass('BtReadMoreOver'); } else { textWidget.setText(page.data.itemList[widget.indice].introText); widget.NewsToggled = false; widget.setText(translations.readMore); widget.removeCSSClass('BtReadMoreSelected'); } }); } } this.appendChild(itemPanel); var bottomBorder = window.document.createElement('div'); bottomBorder.className = 'BottomBorder'; itemPanel.childDiv(KWidget.CONTAINER_DIV).appendChild(bottomBorder); } } else { var noContent = new KText(this); noContent.addCSSClass('NoContent'); noContent.setText(translations.noContent); if (Kinky.site.colors && Kinky.site.colors.textColor) { noContent.setStyle( { color : Kinky.site.colors.textColor }); } this.appendChild(noContent); } BCKList.prototype.draw.call(this); } BCNewsHighlights.prototype = new KPanel(); BCNewsHighlights.prototype.constructor = BCNewsHighlights; function BCNewsHighlights(parent) { if (parent != null) { KPanel.call(this, parent); } } BCNewsHighlights.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.setTitle(this.translations.newsTitle); var allNewsBt = new BCWebsiteKButton(this, this.translations.seeAll, 'allNewsBt', null); allNewsBt.addEventListener('click', function() { KBreadcrumb.dispatchURL({ hash : '/actualidade/noticias' }); }); this.appendTitleChild(allNewsBt); if (this.data.itemList.length > 0) { var first = true; for ( var index in this.data.itemList) { var newsItem = new KPanel(this); { var newsItemContent = new KLink(newsItem, 'javascript:void(0);', this.data.itemList[index].image); newsItemContent.setLinkText(this.data.itemList[index].title); newsItemContent.setStyle({ cursor : 'default' }, KLink.LINK_ELEMENT); newsItem.appendChild(newsItemContent); var text = this.data.itemList[index].introText.length > 60 ? this.data.itemList[index].introText.substr(0, 60) + ' (...)' : this.data.itemList[index].introText; var textDiv = window.document.createElement('div'); textDiv.className = 'NewsShortDesc'; textDiv.innerHTML = text; newsItem.content.appendChild(textDiv); newsItem.clearBoth(); var newsItemBt = new BCWebsiteKButton(newsItem, this.translations.more, 'more', null); newsItemBt.url = this.data.itemList[index].url; newsItemBt.indice = this.data.itemList[index].id; newsItemBt.addEventListener('click', function(e) { var wid = KSystem.getEventWidget(e); KBreadcrumb.dispatchURL({ hash : '/actualidade/noticias', action : '/news/' + wid.indice }); }); newsItem.appendChild(newsItemBt); } if (first) { newsItem.setStyle({ border : 'none' }); } this.appendChild(newsItem); first = false; } } KPanel.prototype.draw.call(this); } BCNewsMarquee.prototype = new KPanel(); BCNewsMarquee.prototype.constructor = BCNewsMarquee; BCNewsMarquee.rollOverTimer = null; BCNewsMarquee.Time = 33; BCNewsMarquee.instance = null; function BCNewsMarquee(parent) { if (parent != null) { KPanel.call(this, parent); BCNewsMarquee.instance = this; } } BCNewsMarquee.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.setTitle(this.translations.newsTitle); var image = window.document.createElement('img'); image.src = '/images/site/marquee_title_arrow.png'; this.widgetTitle.appendChild(image); this.div1 = window.document.createElement('div'); this.div1.className = 'MarqueeDiv'; this.div1.style.left = '0px'; this.content.appendChild(this.div1); if (this.data.highlightItems.length > 0) { var tamText = 6.5; var tamDiv = 0; this.l1 = 0; this.l2 = 0; this.div2 = window.document.createElement('div'); this.div2.className = 'MarqueeDiv'; this.div2.style.left = '0px'; this.content.appendChild(this.div2); for ( var index in this.data.highlightItems) { var newsItem = new KLink(this, this.data.highlightItems[index].url); newsItem.setLinkText(this.data.highlightItems[index].name); this.div1.appendChild(newsItem.panel); newsItem.go(); newsItem = new KLink(this, this.data.highlightItems[index].url); newsItem.setLinkText(this.data.highlightItems[index].name); this.div2.appendChild(newsItem.panel); newsItem.go(); tamDiv += this.data.highlightItems[index].name.length + 2; } tamDiv = (tamDiv * tamText) + 'px'; this.div1.style.width = tamDiv; this.div2.style.width = tamDiv; KSystem.addEventListener(this, 'mouseover', function(event) { clearTimeout(BCNewsMarquee.rollOverTimer); }); KSystem.addEventListener(this, 'mouseout', function(event) { if (BCNewsMarquee.instance.data.highlightItems.length > 0) { BCNewsMarquee.rollOverTimer = setTimeout(BCNewsMarquee.doAutoNext, BCNewsMarquee.Time); } }); BCNewsMarquee.rollOverTimer = setTimeout(BCNewsMarquee.doAutoNext, BCNewsMarquee.Time); } else if (this.data.highlightItems.length == 1) { var newsItem = new KLink(this, this.data.highlightItems[0].url); newsItem.setLinkText(this.data.highlightItems[0].name); this.div1.appendChild(newsItem.panel); newsItem.go(); } KPanel.prototype.draw.call(this); }; BCNewsMarquee.prototype.onShow = function() { KPanel.prototype.onShow.call(this); clearTimeout(BCNewsMarquee.rollOverTimer); if (this.data.highlightItems.length > 0) { BCNewsMarquee.rollOverTimer = setTimeout(BCNewsMarquee.doAutoNext, BCNewsMarquee.Time); } }; BCNewsMarquee.prototype.onHide = function() { clearTimeout(BCNewsMarquee.rollOverTimer); KPanel.prototype.onHide.call(this); }; BCNewsMarquee.doAutoNext = function() { clearTimeout(BCNewsMarquee.rollOverTimer); if(BCNewsMarquee.instance.l1 == BCNewsMarquee.instance.l2) { BCNewsMarquee.instance.l1 = 0; BCNewsMarquee.instance.l2 = BCNewsMarquee.instance.div1.offsetWidth; } else { BCNewsMarquee.instance.l1 -= 2; if(BCNewsMarquee.instance.l1 < BCNewsMarquee.instance.div1.offsetWidth * -1) { BCNewsMarquee.instance.l1 = BCNewsMarquee.instance.div2.offsetWidth; } BCNewsMarquee.instance.l2 -= 2; if(BCNewsMarquee.instance.l2 < BCNewsMarquee.instance.div2.offsetWidth * -1) { BCNewsMarquee.instance.l2 = BCNewsMarquee.instance.div1.offsetWidth; } } BCNewsMarquee.instance.div1.style.left = BCNewsMarquee.instance.l1 + 'px'; BCNewsMarquee.instance.div2.style.left = BCNewsMarquee.instance.l2 + 'px'; if (BCNewsMarquee.instance.data.highlightItems.length > 0) BCNewsMarquee.rollOverTimer = setTimeout(BCNewsMarquee.doAutoNext, BCNewsMarquee.Time); }; BCPressList.prototype = new BCWebsiteKList(); BCPressList.prototype.constructor = BCPressList; function BCPressList(parent) { if (parent != null) { BCWebsiteKList.call(this, parent); this.hash = '/item-list'; } } BCPressList.prototype.onLoad = function(data) { if (this.data == null) { this.data = {}; } KSystem.merge(this.data, data); this.draw(); } BCPressList.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.totalCount = this.data.pageCount * this.perPage; if (this.data.pageCount <= 1) { this.setStyle({ display: 'none' }, KWidget.PAGINATION_DIV); } if (this.data.galleryItems.length > 0) { this.setTotalPages(this.data.pageCount, true); for ( var index in this.data.galleryItems) { var itemInfo = this.data.galleryItems[index]; var itemPanel = new KPanel(this); itemPanel.addCSSClass('ItemPanel'); { var itemText = new KText(itemPanel); itemText.hash = '/item-text'; itemText.addCSSClass('ItemText'); itemText.setTitle(itemInfo.fileTitle); itemText.setText(itemInfo.fileDescription); itemPanel.appendChild(itemText); itemPanel.clearBoth(); var downloadBt = new BCWebsiteKButton(itemPanel, this.translations.download, 'more', null); downloadBt.file = itemInfo.fileInternalPath; downloadBt.addEventListener('click', function(e){ var widget = KSystem.getEventWidget(e); window.open(widget.file); }); downloadBt.addCSSClass('DownloadBt'); itemPanel.appendChild(downloadBt); } this.appendChild(itemPanel); var bottomBorder = window.document.createElement('div'); bottomBorder.className = 'BottomBorder'; itemPanel.childDiv(KWidget.CONTAINER_DIV).appendChild(bottomBorder); } } else { var noContent = new KText(this); noContent.addCSSClass('NoContent'); noContent.setText(this.translations.noContent); this.appendChild(noContent); } BCWebsiteKList.prototype.draw.call(this); } BCProductHighlight.prototype = new KPanel(); BCProductHighlight.prototype.constructor = BCProductHighlight; function BCProductHighlight(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; this.addLocationListener(BCProductHighlight.toggleHighlights, [BCMicroSite.productPageHash + '/*']); this.loadTranslations(); this.highlightsPageHashLast = null; this.highlightsPageHash = null; this.setStyle( { display : 'none' }); } } BCProductHighlight.prototype.load = function() { if (this.highlightsPageHash){ var params = { contentView : 'TemplateBlock(templateHandler)', contentID : 'Highlight:highlight.list.block.php', args : { 'urlHash' : this.highlightsPageHash, 'categoryID' : 326 } }; this.kinky.get(this, 'php:Frontend:GetBlock', params); } } BCProductHighlight.prototype.onLoad = function(data) { if (!this.data) { this.data = {}; } this.data.highlights = data.highlightItems; this.draw(); } BCProductHighlight.prototype.draw = function() { if (this.data.highlights.length > 0){ this.setTitle(this.translations.title); for(var index in this.data.highlights){ var highlight = new KLink(this, 'javascript:void(0);', this.data.highlights[index].image); highlight.url = this.data.highlights[index].url; highlight.addEventListener('click', function(e) { var wid = KSystem.getEventWidget(e); var url = wid.url; if (url.indexOf('http://') == 0) { window.open(url, '_blank'); } else { KBreadcrumb.dispatchURL({ url : url }); } }); this.appendChild(highlight, this.highlightsPageHash); } this.hideContext(); this.changeContext(this.highlightsPageHash); this.showContext(); } else { this.hideContext(); this.setStyle( { display : 'none' }); } KPanel.prototype.draw.call(this); } BCProductHighlight.toggleHighlights = function(widget, hash){ if(!Kinky.site.childWidget(hash) instanceof KPageDialog) { var reg_exp = new RegExp(BCMicroSite.productPageHash); if (reg_exp.test(hash)) { widget.highlightsPageHash = Kinky.site.childWidget('/' + hash.split('/')[1] + '/' + hash.split('/')[2]).data.contentID; if(widget.highlightsPageHash != widget.highlightsPageHashLast) { widget.highlightsPageHashLast = widget.highlightsPageHash; if(widget.childWidgets(widget.highlightsPageHash) != null) { widget.hideContext(); widget.changeContext(widget.highlightsPageHash); widget.showContext(); } else { widget.load(); } } widget.setStyle( { display : 'block' }); } else { widget.setStyle( { display : 'none' }); } } } BCRichtext.prototype = new KText(); BCRichtext.prototype.constructor = BCRichtext; function BCRichtext(parent) { if (parent != null) { KText.call(this, parent); this.hash = '/richtext'; } } BCRichtext.prototype.draw = function() { if (Kinky.site.colors && Kinky.site.colors.textColor) { this.setStyle({ color: Kinky.site.colors.textColor }); } if (this.data.config && this.data.config.html){ this.setText(this.data.config.html); } KText.prototype.draw.call(this); }; BCTooltip.prototype = new KTooltip(); BCTooltip.prototype.constructor = BCTooltip; function BCTooltip(parent, params) { if (parent != null) { this.simpleWidget = false; KTooltip.call(this, parent, params); this.addCSSClass('BCDivBackground', KWidget.BACKGROUND_DIV); this.addCSSClass('BCTooltipContent', KWidget.CONTENT_DIV); this.leftDiv = window.document.createElement('div'); this.leftDiv.className = 'BCTooltipLeft BCBackgroundLeft'; this.middleDiv = window.document.createElement('div'); this.middleDiv.className = 'BCTooltipMiddle BCBackgroundMiddle'; this.rightDiv = window.document.createElement('div'); this.rightDiv.className = 'BCTooltipRight BCBackgroundRight'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.leftDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.middleDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.rightDiv); } } BCTooltip.prototype.draw = function() { if (this.data.text) { if (this.data.isHTML) { this.textContent.innerHTML = this.data.text; } else { this.textContent.appendChild(window.document.createTextNode(this.data.text)); } KSystem.addEventListener(this.target, 'mouseout', KTooltip.hide); KSystem.addEventListener(this.target, 'mousemove', BCTooltip.move); this.panel.style.position = 'absolute'; this.panel.style.display = 'none'; this.panel.className = this.data.cssClass || this.panel.className; window.document.body.appendChild(this.panel); this.activate(); } }; BCTooltip.move = function(event) { var widget = KSystem.getEventWidget(event); var mouseEvent = KSystem.getEvent(event); widget.tooltip.panel.style.display = 'block'; var align = widget.tooltip.data.align || 'original'; if(align == 'top') { widget.tooltip.panel.style.left = (KSystem.mouseX(mouseEvent) - (widget.tooltip.panel.offsetWidth / 2) + widget.tooltip.data.offsetX) + 'px'; widget.tooltip.panel.style.top = (KSystem.mouseY(mouseEvent) - widget.tooltip.panel.offsetHeight - widget.tooltip.data.offsetY) + 'px'; } else if(align == 'bottom') { widget.tooltip.panel.style.left = (KSystem.mouseX(mouseEvent) - (widget.tooltip.panel.offsetWidth / 2) + widget.tooltip.data.offsetX) + 'px'; widget.tooltip.panel.style.top = (KSystem.mouseY(mouseEvent) + widget.tooltip.data.offsetY) + 'px'; } else if(align == 'left') { widget.tooltip.panel.style.top = (KSystem.mouseY(mouseEvent) - (widget.tooltip.panel.offsetHeight / 2) + widget.tooltip.data.offsetY) + 'px'; widget.tooltip.panel.style.left = (KSystem.mouseX(mouseEvent) - widget.tooltip.panel.offsetWidth - widget.tooltip.data.offsetX) + 'px'; } else if(align == 'right') { widget.tooltip.panel.style.top = (KSystem.mouseY(mouseEvent) - (widget.tooltip.panel.offsetHeight / 2) + widget.tooltip.data.offsetY) + 'px'; widget.tooltip.panel.style.left = (KSystem.mouseX(mouseEvent) + widget.tooltip.data.offsetX) + 'px'; } else if(align == 'original') { KTooltip.move(event); } }; BCTooltip.showTooltip = function(parent, params, event) { if (parent instanceof KWidget) { parent = parent.content; } if (event) { var mouseEvent = KSystem.getEvent(event); params.left = KSystem.mouseX(mouseEvent); params.top = KSystem.mouseY(mouseEvent); } var tooltip = new BCTooltip(parent, params); tooltip.go(); }; BCWebsiteAccordionList.prototype = new KLayeredPanel(); BCWebsiteAccordionList.prototype.constructor = BCWebsiteAccordionList; function BCWebsiteAccordionList(parent) { if (parent) { KLayeredPanel.call(this, parent, 'BCWebsiteAccordionList'); this.hash = '/accordion-list'; /* this.tabEffects = { enter : { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : 50 }, lock : { width : true }, onStart : function(widget, tween) { tween.go.height = widget.getHeight(); } }, exit : { f : KEffects.easeOutExpo, type : 'resize', duration : 200, go : { height : 50 }, lock : { width : true } } }; */ } } BCWebsiteAccordionList.prototype.draw = function() { var translations = this.getParent('KPage').getTranslation(this.className); if (this.data.itemList.length > 0) { { var titlePanel = new KPanel(this); titlePanel.addCSSClass('TitlePanel'); var titleText = new KText(titlePanel); titleText.addCSSClass('TitleText'); titleText.setText(translations.opportunityList); titlePanel.appendChild(titleText); var applyButton = new BCWebsiteKButton(titlePanel, translations.applyHere, 'applyJob', function(){ scrollTo(0,600); }); applyButton.addCSSClass('ApplyButton'); titlePanel.appendChild(applyButton); this.appendChild(titlePanel); this.clearBoth(); } for ( var index in this.data.itemList) { var itemInfo = this.data.itemList[index]; var newItem = new KPanel(this); newItem.addCSSClass('Item'); newItem.hash = '/opportunity/' + (parseInt(index) + 1); var itemContent = new KText(newItem); itemContent.setText(itemInfo.text); newItem.appendChild(itemContent); var itemButton = new BCWebsiteKButton(newItem, translations.applyOpportunity, 'applyOpportunity', function(e){ var widget = KSystem.getEventWidget(e); widget.getParent('BCWebsiteAccordionList').parent.childWidget('/job-form').setOpportunity(widget.itemInfo); }); itemButton.itemInfo = itemInfo; itemButton.addCSSClass('ApplyOpportunity'); newItem.appendChild(itemButton); this.addPanel(newItem, '
' + itemInfo.date + '
- ' + itemInfo.title + '
'); } } KLayeredPanel.prototype.draw.call(this); } BCWebsiteExportMap.prototype = new KPanel(); BCWebsiteExportMap.prototype.constructor = BCWebsiteExportMap; function BCWebsiteExportMap(parent) { if (parent != null) { KPanel.call(this, parent); this.translations = null; this.addQueryListener(BCWebsiteExportMap.changeRegion, [ '/region/*' ]); this.actualContinent = null; } } BCWebsiteExportMap.prototype.draw = function() { var parentPage = this.getParent('KPage'); this.translations = parentPage.getTranslation(this.className); if (parentPage.data.graphicStyle.images[0] && parentPage.data.graphicStyle.images[0].fileInternalPath){ var worldMap = new KImage(this, parentPage.data.graphicStyle.images[0].fileInternalPath, null); this.appendChild(worldMap); this.setStyle({ height : 'auto' }); }else{ this.continentes = this.data.items; this.worldMap = new KImage(this, '/images/site/mapa/mundo.png', null); this.worldMap.addCSSClass('WorldMap Absolute'); this.appendChild(this.worldMap); this.continentContainer = new KPanel(this); this.continentContainer.addCSSClass('ContinentContainer'); this.overMapContainer = new KPanel(this); this.overMapContainer.addCSSClass('OverContainer'); var map = new Array(); for ( var index in this.continentes) { var continent = new BCContinent(this, this.continentes[index].closeUp); continent.hash = '/continent/' + this.continentes[index].id; if (this.continentes[index].points.length > 0) { var pointContainer = window.document.createElement('div'); pointContainer.id = 'pointContainer_' + this.continentes[index].id; pointContainer.className = 'PointContainer'; pointContainer.style.display = 'none'; for ( var idxPoints in this.continentes[index].points) { var point = window.document.createElement('img'); point.src = '/images/site/map_pointer.png'; point.title = this.continentes[index].points[idxPoints].title; point.alt = this.continentes[index].points[idxPoints].text; point.style.left = ((this.continentes[index].points[idxPoints].x) * 100) + '%'; point.style.top = (this.continentes[index].points[idxPoints].y * 100) + '%'; pointContainer.appendChild(point); KSystem.addEventListener(point, 'mouseover', function(event) { var mouseEvent = KSystem.getEvent(event); var target = KSystem.getEventTarget(event); BCTooltip.showTooltip(target, { text : "

" + target.title + "

" + target.alt, isHTML : true, offsetX : 0, offsetY : 15, align : 'top', left : KSystem.mouseX(mouseEvent) + 15, top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'BCWebsiteExportMapPoint' }); }); } continent.content.appendChild(pointContainer); } this.continentContainer.appendChild(continent); var overPlace = window.document.createElement('img'); overPlace.id = this.continentes[index].id; overPlace.src = this.continentes[index].over; this.overMapContainer.content.appendChild(overPlace); if (this.continentes[index].map != null) { map.push({ coords : this.continentes[index].map, shape : 'poly', onOver : BCWebsiteExportMap.showRegion, onOut : BCWebsiteExportMap.hideRegion, url : this.getLink({ query : '/region/' + this.continentes[index].id }) }); } } this.appendChild(this.continentContainer); this.appendChild(this.overMapContainer); this.frame = new KImage(this, '/images/site/mapa/frame.png', null); this.frame.addCSSClass('Absolute'); this.appendChild(this.frame); this.frame.addMap({ map : map }); this.backBt = new KLink(this, 'javascript:void(0);', '/images/site/mapa/back.png'); this.backBt.isImageLink = true; this.appendChild(this.backBt); this.backBt.addEventListener('click', function(e){ var parentWidget = KSystem.getEventWidget(e, 'BCWebsiteExportMap'); parentWidget.backToWorldMap(); }); } KPanel.prototype.draw.call(this); if (!(parentPage.data.graphicStyle.images[0] && parentPage.data.graphicStyle.images[0].fileInternalPath)){ var continentContainerChilds = this.continentContainer.childWidgets(); for ( var contIndex in continentContainerChilds) { continentContainerChilds[contIndex].setStyle({ display : 'none' }); } this.backBt.setStyle({ display : 'none' }); } }; BCWebsiteExportMap.changeRegion = function(widget, query) { if (widget.activated()) { var continent = query.split('/')[2]; widget.backBt.setStyle({ display : 'block' }); widget.overMapContainer.setStyle({ display : 'none' }); widget.frame.setStyle({ display : 'none' }); var pointContainer = window.document.getElementById('pointContainer_' + continent); pointContainer.style.opacity = '0'; pointContainer.style.display = 'block'; widget.actualContinent = widget.continentContainer.childWidget('/continent/' + continent); // fx widget.actualContinent.setStyle({ opacity : '0', width : '855px', height : '316px' }, widget.actualContinent.image); widget.actualContinent.setStyle({ display : 'block' }); KEffects.addEffect(widget.actualContinent.image, [ { f : KEffects.easeOutExpo, type : 'resize', unit : 'px', duration : 1000, go : { width : 633, height : 234 } }, { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 1000, go : { alpha : 1 }, from : { alpha : 0 }, onComplete : function(widget, tween) { if (pointContainer) { pointContainer.style.opacity = '0'; pointContainer.style.display = 'block'; pointContainer.style.left = '18px'; pointContainer.style.top = '-25px'; KEffects.addEffect(pointContainer, [ { f : KEffects.easeOutExpo, type : 'fade', realAlpha : true, duration : 1500, go : { alpha : 1 }, from : { alpha : 0 } }, { f : KEffects.easeOutExpo, type : 'move', duration : 1500, go : { x : 0, y : 0 }, from : { x : 18, y : -25 } } ]); } } } ]); } }; BCWebsiteExportMap.prototype.backToWorldMap = function(){ KBreadcrumb.dispatchURL({ query : '' }); this.overMapContainer.setStyle({ display : 'block' }); this.frame.setStyle({ display : 'block' }); this.actualContinent.setStyle({ display : 'none' }); this.backBt.setStyle({ display : 'none' }); } BCWebsiteExportMap.showRegion = function(event) { var mouseEvent = KSystem.getEvent(event); var target = KSystem.getEventTarget(event); var href = target.href.split('/'); var region = href[href.length - 1]; var parentTarget = KSystem.getEventWidget(event, 'BCWebsiteExportMap'); BCTooltip.showTooltip(target, { text : parentTarget.translations[region], isHTML : true, offsetX : 15, offsetY : 0, align : 'right', left : KSystem.mouseX(mouseEvent) + 15, top : (KSystem.mouseY(mouseEvent) + 15), cssClass : 'BCWebsiteExportMapContinent' }); document.getElementById(region).style.display = 'block'; }; BCWebsiteExportMap.hideRegion = function(event) { var mouseEvent = KSystem.getEvent(event); var target = KSystem.getEventTarget(event); var href = target.href.split('/'); var region = href[href.length - 1]; document.getElementById(region).style.display = 'none'; }; BCWebsiteFooterMenu.prototype = new KIndex(); BCWebsiteFooterMenu.prototype.constructor = BCWebsiteFooterMenu; function BCWebsiteFooterMenu(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); BCWebsiteFooterMenu.activeTool = null; this.widget_translations = {}; this.loadTranslations(); BCWebsiteFooterMenu.translations = this.getTranslation('BCWebsiteFooterMenu'); } } BCWebsiteFooterMenu.prototype.loadTranslations = function() { }; BCWebsiteFooterMenu.prototype.getTranslation = function(widgetClass) { if (this.widget_translations[widgetClass]) { return this.widget_translations[widgetClass]; } }; BCWebsiteFooterMenu.prototype.draw = function() { var rightsText = new KText(this); rightsText.setText(BCWebsiteFooterMenu.translations.rightsText); this.appendChild(rightsText); this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); this.markIndex(this.getHash()); } BCWebsiteFooterMenu.shareMe = function(event) { var widget = KSystem.getEventWidget(event); window.open('http://www.facebook.com/sharer.php?u=http://' + encodeURIComponent(window.location.host)); } BCWebsiteFooterMenu.shareMeTwitter = function(event) { var widget = KSystem.getEventWidget(event); window.open('http://twitter.com/home?status=' + encodeURIComponent('Nelson')); } BCWebsiteFooterMenu.prototype.loadIndex = function(page, level, topUL, parent, pageIndex) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page, pageIndex++); } } else { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (page.graphicStyle && page.graphicStyle.images[0] && page.graphicStyle.images[0].fileInternalPath && page.graphicStyle.images[0].stateCode == 'destaque submenu'){ var exportLink = new KLink(this, this.getLink({ hash : page.redirectUrlHashText }), page.graphicStyle.images[0].fileInternalPath); exportLink.addCSSClass('BCFooterHighlightPage'); this.appendChild(exportLink); }else{ var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); if (page.graphicStyle.images.length > 0){ for (var image in page.graphicStyle.images){ if (page.graphicStyle.images[image].presentationGalleryFile == 1){ li.style.background = 'url(' + page.graphicStyle.images[image].fileInternalPath + ') no-repeat'; KCSS.addCSSClass('Special', li); } } } a.appendChild(window.document.createTextNode(page.menuText)); a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; li.appendChild(a); ul = window.document.createElement('ul'); ul.className = 'KIndexLevel' + (level + 1); li.appendChild(ul); topUL.appendChild(li); } } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } } } BCWebsiteFormContact.prototype = new KForm(); BCWebsiteFormContact.prototype.constructor = BCWebsiteFormContact; function BCWebsiteFormContact(parent) { if (parent != null) { KForm.call(this, parent); this.staticForm = true; this.action = 'php:Contact:Submit'; this.translations = null; this.hash = '/BCWebsiteFormContact'; } } BCWebsiteFormContact.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); var firstName = new KInput(this, 'text', this.translations.firstName, 'firstName', true); firstName.addCSSClass('NameInput'); firstName.addValidator(/.+/, this.translations.firstNameError); this.addInput(firstName); var lastName = new KInput(this, 'text', this.translations.lastName, 'lastName', true); lastName.addCSSClass('NameInput'); lastName.addValidator(/.+/, this.translations.lastNameError); this.addInput(lastName); this.clearBoth(); var contactEmail = new KInput(this, 'text', this.translations.email, 'contactEmail', true); contactEmail.addCSSClass('NameInput'); contactEmail.addValidator(/(\w+@[a-zA-Z_-]+?\.[a-zA-Z]{2,6})/, this.translations.emailError); this.addInput(contactEmail); var contactPhone = new KInput(this, 'text', this.translations.phone, 'contactPhone', true); contactPhone.addCSSClass('NameInput'); contactPhone.addValidator(/[0-9]{9,9}/, this.translations.phoneError); this.addInput(contactPhone); this.clearBoth(); var contactMessage = new KInput(this, 'textarea', this.translations.message, 'contactMessage', true); contactMessage.addCSSClass('MessageInput'); contactMessage.addValidator(/.+/, this.translations.messageError); this.addInput(contactMessage); var mandatoryText = new KText(this); mandatoryText.addCSSClass('MandatoryText'); mandatoryText.setText(this.translations.mandatoryFields); this.appendChild(mandatoryText); this.clearBoth(); this.errorPanel = new KText(this); this.errorPanel.addCSSClass('ErrorPanel'); this.appendChild(this.errorPanel); var submitButton = new BCWebsiteKInput(this, this.translations.submit, 'submit'); this.addInput(submitButton); KForm.prototype.draw.call(this); this.errorPanel.setStyle({ display : 'none' }); } BCWebsiteFormContact.prototype.onValidate = function(text, params, status) { if (status) { params.contactName = params.firstName + ' ' + params.lastName; params.categoryID = this.data.config.contentID; this.disable(); return params; } else { var first = true; for ( var element in params) { var input = params[element].getInput(); if (first) { first = false; input.focus(); } input.style.color = 'red'; this.errorPanel.setStyle({ color : '#b11f7d' }); this.errorPanel.setTitle('', true); this.errorPanel.setText(params[element].getErrorMessage(params[element].validationIndex)); this.errorPanel.setStyle({ display : 'block' }); break; } return false; } } BCWebsiteFormContact.prototype.onSuccess = function(data) { this.enable(); this.reset(); this.errorPanel.setStyle({ color : '#519719' }); // this.errorPanel.setTitle('', true); this.errorPanel.setText(this.translations.successText); this.errorPanel.setStyle({ display : 'block' }); } BCWebsiteFormContact.prototype.onError = function(data) { this.enable(); this.errorPanel.setStyle({ color : '#b11f7d' }); this.errorPanel.setTitle('', true); this.errorPanel.setText(this.translations.errorText); this.errorPanel.setStyle({ display : 'block' }); } BCWebsiteHighlightsWidget.prototype = new KPanel(); BCWebsiteHighlightsWidget.prototype.constructor = BCWebsiteHighlightsWidget; function BCWebsiteHighlightsWidget(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; this.addLocationListener(BCWebsiteHighlightsWidget.toggleHighlights); // this.loadTranslations(); this.highlightsPageHashLast = null; this.highlightsPageHash = null; this.setStyle( { display : 'none' }); } } BCWebsiteHighlightsWidget.prototype.load = function() { if (this.highlightsPageHash){ var params = { contentView : 'TemplateBlock(templateHandler)', contentID : 'Highlight:highlight.list.block.php', args : { 'urlHash' : this.highlightsPageHash } }; this.kinky.get(this, 'php:Frontend:GetBlock', params); } } BCWebsiteHighlightsWidget.prototype.onLoad = function(data) { if (!this.data) { this.data = {}; } this.data.highlights = data.highlightItems; this.draw(); } BCWebsiteHighlightsWidget.prototype.draw = function() { if (this.data.highlights.length > 0){ for(var index in this.data.highlights){ var highlight = new KLink(this, 'javascript:void(0);', this.data.highlights[index].image); highlight.url = this.data.highlights[index].url; highlight.addEventListener('click', function(e) { var wid = KSystem.getEventWidget(e); var url = wid.url; if (url.indexOf('http://') == 0) { window.open(url, '_blank'); } else { KBreadcrumb.dispatchURL({ url : url }); } }); this.appendChild(highlight, this.highlightsPageHash); } this.hideContext(); this.changeContext(this.highlightsPageHash); this.showContext(); } else { this.hideContext(); this.setStyle( { display : 'none' }); } KPanel.prototype.draw.call(this); } BCWebsiteHighlightsWidget.toggleHighlights = function(widget, hash){ if(!(Kinky.site.childWidget(hash) instanceof KPageDialog)) { if(Kinky.site.childWidget(hash) instanceof BCWebsiteTwoColumnNoHighlight){ widget.highlightsPageHash = Kinky.site.childWidget('/' + hash.split('/')[1]).data.contentID; }else{ widget.setStyle( { display : 'none' }); return; } if (widget.highlightsPageHash){ if(widget.highlightsPageHash != widget.highlightsPageHashLast) { widget.highlightsPageHashLast = widget.highlightsPageHash; if(widget.childWidgets(widget.highlightsPageHash) != null) { widget.hideContext(); widget.changeContext(widget.highlightsPageHash); widget.showContext(); } else { widget.load(); } } widget.setStyle( { display : 'block' }); } } } BCWebsiteJobForm.prototype = new KForm(); BCWebsiteJobForm.prototype.constructor = BCWebsiteJobForm; function BCWebsiteJobForm(parent) { if (parent != null) { KForm.call(this, parent); this.staticForm = true; this.action = 'php:JobOpportunity:SubmitAnswer'; this.hash = '/job-form'; this.translations = null; } } BCWebsiteJobForm.prototype.setOpportunity = function(data) { if (data == null) { this.opportunityHidden.setValue(0); this.setTitle(this.translations.formTitle); } else { this.opportunityHidden.setValue(data.id); this.setTitle(data.title); } } BCWebsiteJobForm.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.setTitle(this.translations.formTitle); var topBt = new BCWebsiteKButton(this, this.translations.backToTop, 'topBt', function() { scrollTo(0, 0); }); topBt.addCSSClass('BackToTopButton'); this.appendTitleChild(topBt); var contactName = new KInput(this, 'text', this.translations.name, 'name', true); contactName.addCSSClass('NameInput'); contactName.addValidator(/.+/, this.translations.nameError); this.addInput(contactName); var contactEmail = new KInput(this, 'text', this.translations.email, 'email', true); contactEmail.addCSSClass('NameInput'); contactEmail.addValidator(/(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/, this.translations.emailError); this.addInput(contactEmail); this.clearBoth(); var contactPhone = new KInput(this, 'text', this.translations.phone, 'phone', true); contactPhone.addCSSClass('NameInput'); contactPhone.addValidator(/[0-9]{9,9}/, this.translations.phoneError); this.addInput(contactPhone); var contactMessage = new KInput(this, 'textarea', this.translations.message, 'apresentation', true); contactMessage.addCSSClass('MessageInput'); contactMessage.addValidator(/.+/, this.translations.messageError); this.addInput(contactMessage); this.clearBoth(); var contactCV = new KFile(this, 'Upload', 'curriculumFile'); contactCV.addValidator(/.+/, this.translations.cvError); contactCV.addCSSClass('UploadedCV'); contactCV.maxFile = 1; contactCV.setLabel(this.translations.cv); contactCV.noPrompt = true; contactCV.setButtonSize(72, 37); this.addInput(contactCV); var mandatoryText = new KText(this); mandatoryText.addCSSClass('MandatoryText'); mandatoryText.setText(this.translations.mandatoryFields); this.appendChild(mandatoryText); this.clearBoth(); this.errorPanel = new KText(this); this.errorPanel.addCSSClass('ErrorPanel'); this.appendChild(this.errorPanel); var submitButton = new BCWebsiteKInput(this, this.translations.submit, 'submit'); this.addInput(submitButton); this.opportunityHidden = new KInput(this, 'hidden', '', 'opportunityID'); this.opportunityHidden.setValue(this.data.config.contentID); this.addInput(this.opportunityHidden); KForm.prototype.draw.call(this); this.errorPanel.setStyle({ display : 'none' }); }; BCWebsiteJobForm.prototype.onValidate = function(text, params, status) { if (status) { this.disable(); return params; } else { var first = true; for ( var element in params) { var input = params[element].getInput(); if (first) { first = false; if (input) { input.focus(); } } if (input) { input.style.color = 'red'; } this.errorPanel.setStyle({ color : '#b11f7d' }); this.errorPanel.setTitle('', true); this.errorPanel.setText(params[element].getErrorMessage(params[element].validationIndex)); this.errorPanel.setStyle({ display : 'block' }); break; } return false; } } BCWebsiteJobForm.prototype.onSuccess = function(data) { this.enable(); this.reset(); this.errorPanel.setStyle({ color : '#519719' }); // this.errorPanel.setTitle('', true); this.errorPanel.setText(this.translations.successText); this.errorPanel.setStyle({ display : 'block' }); } BCWebsiteJobForm.prototype.onError = function(data) { this.enable(); this.errorPanel.setStyle({ color : '#b11f7d' }); this.errorPanel.setTitle('', true); this.errorPanel.setText(this.translations.errorText); this.errorPanel.setStyle({ display : 'block' }); } BCWebsiteKButton.prototype = new KButton(); BCWebsiteKButton.prototype.constructor = BCWebsiteKButton; function BCWebsiteKButton(parent, label, id, callback) { if (parent != null) { this.simpleWidget = false; KButton.call(this, parent, label, id, callback); this.leftDiv = window.document.createElement('div'); this.leftDiv.className = 'BCWebsiteKButtonLeft'; this.middleDiv = window.document.createElement('div'); this.middleDiv.className = 'BCWebsiteKButtonMiddle'; this.rightDiv = window.document.createElement('div'); this.rightDiv.className = 'BCWebsiteKButtonRight'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.leftDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.middleDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.rightDiv); } } BCWebsiteKButton.prototype.draw = function() { KButton.prototype.draw.call(this); //this.middleDiv.appendChild(this.inputContainer); } BCWebsiteKInput.prototype = new KInput(); BCWebsiteKInput.prototype.constructor = BCWebsiteKInput; function BCWebsiteKInput(parent, label, id) { if (parent != null) { this.simpleWidget = false; KInput.call(this, parent, 'submit', label, id, false); this.leftDiv = window.document.createElement('div'); this.leftDiv.className = 'BCWebsiteKInputLeft'; this.middleDiv = window.document.createElement('div'); this.middleDiv.className = 'BCWebsiteKInputMiddle'; this.rightDiv = window.document.createElement('div'); this.rightDiv.className = 'BCWebsiteKInputRight'; this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.leftDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.middleDiv); this.childDiv(KWidget.BACKGROUND_DIV).appendChild(this.rightDiv); } } BCWebsiteKInput.prototype.draw = function() { KInput.prototype.draw.call(this); //this.middleDiv.appendChild(this.inputContainer); } BCWebsiteLangPanel.prototype = new KPanel(); BCWebsiteLangPanel.prototype.constructor = BCWebsiteLangPanel; function BCWebsiteLangPanel(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; } } BCWebsiteLangPanel.prototype.load = function() { if (!this.data) this.data = {}; this.data.contentView = 'TemplateBlock(templateHandler)'; this.data.contentID = 'Page:language.list.block.php'; this.data.feService = 'php:Frontend:GetBlock'; this.data.feServiceArgs = { args : { versionCode : Kinky.BASE_VERSION } }; KPanel.prototype.load.call(this); } BCWebsiteLangPanel.prototype.onLoad = function(data) { KSystem.merge(this.data, data); this.draw(); } BCWebsiteLangPanel.prototype.draw = function() { var currentLanguage = Kinky.getCurrentLanguage(); if (this.data.languageList && this.data.languageList.length > 0) { for ( var index in this.data.languageList) { var lang = new KLink(this, 'javascript:void(0);'); if (this.data.languageList[index] == currentLanguage){ lang.addCSSClass('Selected'); } lang.langID = this.data.languageList[index]; lang.setLinkText(this.data.languageList[index].toUpperCase()); lang.addEventListener('click', function(e) { var element = KSystem.getEventWidget(e); window.location = Kinky.SITE_URL + element.langID + '/'; }); this.appendChild(lang); break; } } var rightBorder = window.document.createElement('div'); rightBorder.className = 'RightBorder'; this.childDiv(KWidget.CONTAINER_DIV).appendChild(rightBorder); KPanel.prototype.draw.call(this); }; BCWebsiteList.prototype = new BCWebsiteKList(); BCWebsiteList.prototype.constructor = BCWebsiteList; function BCWebsiteList(parent) { if (parent != null) { BCWebsiteKList.call(this, parent); this.hash = '/item-list'; this.addActionListener(BCWebsiteList.toggleNewsByUrl, [ '/news/*' ]); this.translation = null; } } BCWebsiteList.prototype.onLoad = function(data) { if (this.data == null) { this.data = {}; } KSystem.merge(this.data, data); this.draw(); } BCWebsiteList.prototype.draw = function() { this.translation = this.getParent('KPage').getTranslation(this.className); this.totalCount = this.data.pageCount * this.perPage; if (this.data.pageCount <= 1) { this.setStyle( { display : 'none' }, KWidget.PAGINATION_DIV); } if (this.data.itemList.length > 0) { this.setTotalPages(this.data.pageCount, true); for ( var index in this.data.itemList) { var itemInfo = this.data.itemList[index]; var image = (itemInfo.image && itemInfo.image.length) > 0 && itemInfo.image.charAt(itemInfo.image.length - 1) != '/' ? itemInfo.image : null; var itemPanel = new KPanel(this); itemPanel.addCSSClass('ItemPanel'); itemPanel.hash = '/item-panel/' + itemInfo.id; itemPanel.NewsToggled = false; { if (image) { var itemImage = new KImage(itemPanel, image); itemImage.addCSSClass('ItemImage'); itemPanel.appendChild(itemImage); } var itemText = new KText(itemPanel); itemText.hash = '/item-text'; itemText.addCSSClass('ItemText'); itemText.setTitle(itemInfo.title); itemText.data.desc = itemInfo.text; itemText.data.shortDesc = itemInfo.introText; if (this.showReadMore == true) { // noticias - mostrar a breve descricao itemText.setText(itemInfo.introText); } else { // dicas - mostrar ja a descricao completa itemText.setText(itemInfo.text); } if (image) { itemText.addCSSClass('ShortText'); } itemPanel.appendChild(itemText); if (this.showReadMore == true) { var readMore = new BCWebsiteKButton(itemPanel, this.translation.readMore, 'more', null); readMore.hash = '/button'; if (!image) { readMore.setStyle( { cssFloat : 'left' }); } readMore.addCSSClass('BtReadMore'); itemPanel.appendChild(readMore); readMore.addEventListener('mouseover', function(event) { var widget = KSystem.getEventWidget(event); if (!widget.parent.NewsToggled) { widget.addCSSClass('BtReadMoreOver'); } }); readMore.addEventListener('mouseout', function(event) { var widget = KSystem.getEventWidget(event); widget.removeCSSClass('BtReadMoreOver'); }); readMore.addEventListener('click', function(event) { var widget = KSystem.getEventWidget(event); var parentWidget = widget.parent; if (!parentWidget.NewsToggled){ KBreadcrumb.dispatchURL({ action : '/news/' + parentWidget.hash.split('/')[2] }); }else{ parentWidget.parent.toggleNews(parentWidget); KBreadcrumb.dispatchURL({ action : '' }); } }); } } this.appendChild(itemPanel); var bottomBorder = window.document.createElement('div'); bottomBorder.className = 'BottomBorder'; itemPanel.childDiv(KWidget.CONTAINER_DIV).appendChild(bottomBorder); } } else { var noContent = new KText(this); noContent.addCSSClass('NoContent'); noContent.setText(this.translation.noContent); this.appendChild(noContent); } BCWebsiteKList.prototype.draw.call(this); } BCWebsiteList.prototype.toggleNews = function(widget) { var textWidget = widget.childWidget('/item-text'); var btWidget = widget.childWidget('/button'); if (!widget.NewsToggled) { // vamos mostrar o detalhe e mudar o botao textWidget.setText(textWidget.data.desc); widget.NewsToggled = true; btWidget.setText(this.translation.close); btWidget.addCSSClass('BtReadMoreSelected'); btWidget.removeCSSClass('BtReadMoreOver'); } else { textWidget.setText(textWidget.data.shortDesc); widget.NewsToggled = false; btWidget.setText(this.translation.readMore); btWidget.removeCSSClass('BtReadMoreSelected'); } } BCWebsiteList.toggleNewsByUrl = function(widget, action) { var newsID = action.split('/')[2]; var panel = widget.childWidget('/item-panel/' + newsID); if (panel) { widget.toggleNews(panel); } } BCWebsiteMainMenu.prototype = new KIndex(); BCWebsiteMainMenu.prototype.constructor = BCWebsiteMainMenu; function BCWebsiteMainMenu(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); this.changeMenuIndex = 0; this.lastSelected = null; } } BCWebsiteMainMenu.prototype.setMarked = function(hash) { this.markIndex(hash); } BCWebsiteMainMenu.prototype.draw = function() { this.changeMenuIndex = Math.round(this.data.pages.length / 2); this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); this.markIndex(this.getHash()); } BCWebsiteMainMenu.prototype.hide = function() { if(this.lastSelected != null){ KCSS.removeCSSClass('KIndexLevel1ItemSelected', this.lastSelected); KCSS.removeCSSClass('KIndexLevel1Over', this.lastSelected.parentNode); this.lastSelected = null; } } BCWebsiteMainMenu.prototype.loadIndex = function(page, level, topUL, parent, pageIndex) { if (!pageIndex) { pageIndex = 1; } var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page, pageIndex++); } } else { if (level > 2) { return; } if (level > 0) { if (page.urlHashText == '/homepage') { return; } var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } if (level == 1) { var leftDiv = window.document.createElement('div'); leftDiv.className = 'LeftBt'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'MiddleBt'; var rightDiv = window.document.createElement('div'); rightDiv.className = 'RightBt'; } var a = window.document.createElement('a'); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } this.subIndex[page.urlHashText] = li; if (level == 1) { a.style.opacity = 1; KSystem.addEventListener(a, 'mouseover', function(e) { KEffects.addEffect(a, { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 800, go : { alpha : 0.4 }, from : { alpha : 1 } }); }); KSystem.addEventListener(a, 'mouseout', function(e) { KEffects.addEffect(a, { f : KEffects.easeInOutExpo, type : 'fade', realAlpha : true, duration : 800, go : { alpha : 1 }, from : { alpha : 0.4 } }); }); KSystem.addEventListener(li, 'click', function(e) { var target = KSystem.getEventTarget(e); if(target.tagName.toLowerCase() == 'a'){ var mainWidget = KSystem.getEventWidget(e, 'BCWebsiteMainMenu'); if (mainWidget.lastSelected == li ) { KCSS.removeCSSClass('KIndexLevel1ItemSelected', li); mainWidget.lastSelected = null; KCSS.removeCSSClass('KIndexLevel1Over', li.parentNode); } else { if (mainWidget.lastSelected) { KCSS.removeCSSClass('KIndexLevel1ItemSelected', mainWidget.lastSelected); } KCSS.addCSSClass('KIndexLevel1Over', li.parentNode); KCSS.addCSSClass('KIndexLevel1ItemSelected', li); mainWidget.lastSelected = li; var liChilds = li.getElementsByTagName('LI'); var els = li.getElementsByTagName('*'); for ( var i = 0; i < els.length; i++) { if (els[i].tagName == 'IMG') { els[i].src = liChilds[0].image; continue; } if (els[i].className == 'TextContainer') { els[i].innerHTML = '

' + liChilds[0].pageTitle + '

' + liChilds[0].imageText + '

'; continue; } } } } }); var secundaryMenu = window.document.createElement('div'); { var title = window.document.createElement('h2'); title.innerHTML = page.description; secundaryMenu.appendChild(title); var leftContainer = window.document.createElement('div'); leftContainer.className = 'LeftContainer'; { var imgContainer = window.document.createElement('div'); imgContainer.className = 'ImgContainer'; { var image = window.document.createElement('img'); imgContainer.appendChild(image); } leftContainer.appendChild(imgContainer); var textContainer = window.document.createElement('div'); textContainer.className = 'TextContainer'; leftContainer.appendChild(textContainer); } secundaryMenu.appendChild(leftContainer); var secundaryUL = window.document.createElement('ul'); secundaryMenu.className = 'SecundaryMenu'; secundaryMenu.appendChild(secundaryUL); } li.appendChild(secundaryMenu); middleDiv.appendChild(a); li.appendChild(leftDiv); li.appendChild(middleDiv); li.appendChild(rightDiv); } else { a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); li.appendChild(a); a.innerHTML = '•  ' + a.innerHTML; KSystem.addEventListener(li, 'mouseover', function(e) { var element = KSystem.getEventTarget(e); if (!(element.tagName == 'LI')) { element = element.parentNode; } var secundaryMenuElement = element.parentNode.parentNode; var leftContainerElement = secundaryMenuElement.getElementsByTagName('div')[0]; for ( var elements in leftContainerElement.childNodes) { if (leftContainerElement.childNodes[elements].className == 'ImgContainer') { leftContainerElement.childNodes[elements].childNodes[0].src = element.image; } else if (leftContainerElement.childNodes[elements].className == 'TextContainer') { leftContainerElement.childNodes[elements].innerHTML = '

' + element.pageTitle + '

' + element.imageText + '

'; } } }); for ( var image in page.graphicStyle.images) { if (page.graphicStyle.images[image].stateCode == 'destaque submenu') { li.image = page.graphicStyle.images[image].fileInternalPath; li.imageText = page.graphicStyle.images[image].fileDescription; } } li.pageTitle = page.menuText; } topUL.appendChild(li); } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, secundaryUL, page); } } } BCWebsiteProductHighlights.prototype = new KPanel(); BCWebsiteProductHighlights.prototype.constructor = BCWebsiteProductHighlights; function BCWebsiteProductHighlights(parent) { if (parent != null) { KPanel.call(this, parent); this.loadService = true; this.addLocationListener(BCWebsiteProductHighlights.toggleHighlights); // this.loadTranslations(); this.highlightsPageHashLast = null; this.highlightsPageHash = null; this.setStyle({ display : 'none' }); } } BCWebsiteProductHighlights.prototype.load = function() { if (this.highlightsPageHash) { var params = { contentView : 'TemplateBlock(templateHandler)', contentID : 'Highlight:highlight.list.block.php', args : { 'urlHash' : this.highlightsPageHash } }; this.kinky.get(this, 'php:Frontend:GetBlock', params); } } BCWebsiteProductHighlights.prototype.onLoad = function(data) { if (!this.data) { this.data = {}; } this.data.highlights = data.highlightItems; this.draw(); } BCWebsiteProductHighlights.prototype.draw = function() { if (this.data.highlights.length > 0) { var first = true; for ( var index in this.data.highlights) { var highlight = new KPanel(this); { var highlightItem = new KLink(highlight, 'javascript:void(0);', this.data.highlights[index].image); highlightItem.setLinkText(this.data.highlights[index].name); highlightItem.setStyle({ cursor : 'default' }, KLink.LINK_ELEMENT); highlight.appendChild(highlightItem); var highlightBt = new BCWebsiteKButton(highlight, 'Saber mais', 'more', null); highlightBt.url = this.data.highlights[index].url; highlightBt.addEventListener('click', function(e) { var wid = KSystem.getEventWidget(e); var url = wid.url; if (url.indexOf('http://') == 0) { window.open(url, '_blank'); } else { KBreadcrumb.dispatchURL({ url : url }); } }); highlight.appendChild(highlightBt); } if (first) { highlightBt.setStyle({ border : 'none' }); } this.appendChild(highlight, this.highlightsPageHash); first = false; } this.hideContext(); this.changeContext(this.highlightsPageHash); this.showContext(); } else { this.hideContext(); this.setStyle({ display : 'none' }); } KPanel.prototype.draw.call(this); } BCWebsiteProductHighlights.toggleHighlights = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof KPageDialog)) { if (Kinky.site.childWidget(hash) instanceof BCWebsiteThreeColumnHighlight) { // produtos widget.highlightsPageHash = Kinky.site.childWidget('/' + hash.split('/')[1] + '/' + hash.split('/')[2]).data.contentID; } else { widget.setStyle({ display : 'none' }); return; } if (widget.highlightsPageHash) { if (widget.highlightsPageHash != widget.highlightsPageHashLast) { widget.highlightsPageHashLast = widget.highlightsPageHash; if (widget.childWidgets(widget.highlightsPageHash) != null) { widget.hideContext(); widget.changeContext(widget.highlightsPageHash); widget.showContext(); } else { widget.load(); } } widget.setStyle({ display : 'block' }); } } } BCWebsiteProductSubPagesLevel1.prototype = new KIndex(); BCWebsiteProductSubPagesLevel1.prototype.constructor = BCWebsiteProductSubPagesLevel1; function BCWebsiteProductSubPagesLevel1(parent) { if (parent != null) { KIndex.call(this, parent, 'ProductPageMenu'); this.addLocationListener(BCWebsiteProductSubPagesLevel1.changeContext); BCWebsiteProductSubPagesLevel1.parentColor = null; this.setStyle({ display : 'none' }); } } BCWebsiteProductSubPagesLevel1.prototype.load = function() { if (this.activated()) { this.draw(); } else { this.activate(); } } BCWebsiteProductSubPagesLevel1.prototype.draw = function() { var parentPage = Kinky.site.childWidget('/' + this.getHash().split('/')[1] + '/' + this.getHash().split('/')[2]); BCWebsiteProductSubPagesLevel1.parentColor = parentPage.data.graphicStyle.colors.blockGraphicalDefinition.text; if (parentPage && parentPage.data && parentPage.data.pages) { var parentImage = ''; for(var index in parentPage.data.graphicStyle.images){ if(parentPage.data.graphicStyle.images[index].stateCode == 'Menu Lateral'){ parentImage = parentPage.data.graphicStyle.images[index].fileInternalPath; } } var parentImageWidget = new KImage(this, parentImage); this.appendChild(parentImageWidget); this.setStyle( { display : 'block' }); var pageData = new Object(); pageData.pages = parentPage.data.pages; this.loadIndex(pageData); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.markIndex(this.getHash()); } this.activate(); } BCWebsiteProductSubPagesLevel1.prototype.loadIndex = function(page, level, topUL, parent) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (level == 1) { var li = window.document.createElement('li'); li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var a = window.document.createElement('a'); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; li.appendChild(a); KSystem.addEventListener(li, 'mouseover', function(){ if (!(/KIndexMarked/.test(li.className))){ a.style.color = BCWebsiteProductSubPagesLevel1.parentColor; } }); KSystem.addEventListener(li, 'mouseout', function(){ if (!(/KIndexMarked/.test(li.className))){ a.style.color = '#919191'; } }); topUL.appendChild(li); } } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } } BCWebsiteProductSubPagesLevel1.prototype.markIndex = function(hash) { if (!hash) { return; } var paths = hash.split('/'); paths.splice(0, 1); for ( var level in this.lastMarked) { this.removeCSSClass('KIndexMarked', this.lastMarked[level]); this.lastMarked[level].childNodes[0].style.background = ''; } this.lastMarked = {}; var subHash = ''; for ( var path in paths) { subHash += '/' + paths[path]; if (!this.subIndex[subHash]) { continue; } this.lastMarked[this.subIndex[subHash].name] = this.subIndex[subHash]; this.addCSSClass('KIndexMarked', this.subIndex[subHash]); this.subIndex[subHash].style.background = BCWebsiteProductSubPagesLevel1.parentColor; } } BCWebsiteProductSubPagesLevel1.changeContext = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof BCWebsiteThreeColumnHighlight)){ widget.setStyle({ display : 'none' }); return; }else{ widget.setStyle({ display : 'block' }); widget.refresh(); } } BCWebsiteProductSubPagesLevel2.prototype = new KIndex(); BCWebsiteProductSubPagesLevel2.prototype.constructor = BCWebsiteProductSubPagesLevel2; function BCWebsiteProductSubPagesLevel2(parent) { if (parent != null) { KIndex.call(this, parent, 'ProductPageMenu'); this.addLocationListener(BCWebsiteProductSubPagesLevel2.changeContext); this.liWidth = null; this.setStyle({ display : 'none' }); BCWebsiteProductSubPagesLevel2.parentColor = null; } } BCWebsiteProductSubPagesLevel2.prototype.load = function() { if (this.activated()) { this.draw(); } else { this.activate(); } } BCWebsiteProductSubPagesLevel2.prototype.draw = function() { var parentPage = null; var parentParentPage = null; var h = this.getHash(); if(h) { var parts = h.split('/'); parentPage = Kinky.site.childWidget('/' + parts[1] + '/' + parts[2] + '/' + parts[3]); parentParentPage = Kinky.site.childWidget('/' + parts[1] + '/' + parts[2]); } if (parentParentPage) { BCWebsiteProductSubPagesLevel2.parentColor = parentParentPage.data.graphicStyle.colors.blockGraphicalDefinition ? parentParentPage.data.graphicStyle.colors.blockGraphicalDefinition.text : ''; } if (parentPage && parentPage.data && parentPage.data.pages) { this.liWidth = 490 / parentPage.data.pages.length; this.setStyle({ display : 'block' }); var pageData = new Object(); pageData.pages = parentPage.data.pages; this.loadIndex(pageData); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.markIndex(this.getHash()); } this.activate(); } BCWebsiteProductSubPagesLevel2.prototype.loadIndex = function(page, level, topUL, parent) { var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; } else { if (level == 1) { var li = window.document.createElement('li'); li.style.width = this.liWidth + 'px'; li.name = level; try { li.className = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } if (level == 1) { var leftDiv = window.document.createElement('div'); leftDiv.className = 'LeftBt'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'MiddleBt'; var rightDiv = window.document.createElement('div'); rightDiv.className = 'RightBt'; } var a = window.document.createElement('a'); KSystem.addEventListener(a, 'mouseover', function() { var target = a; if (target.parentNode.parentNode.alt != 1) { target.style.color = BCWebsiteProductSubPagesLevel2.parentColor; } }); KSystem.addEventListener(a, 'mouseout', function() { var target = a; if (target.parentNode.parentNode.alt != 1) { target.style.color = ''; } }); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); this.subIndex[page.urlHashText] = li; middleDiv.appendChild(a); li.appendChild(leftDiv); li.appendChild(middleDiv); li.appendChild(rightDiv); topUL.appendChild(li); } } for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page); } } BCWebsiteProductSubPagesLevel2.prototype.setMarked = function(hash) { this.markIndex(hash); }; BCWebsiteProductSubPagesLevel2.prototype.markIndex = function(hash) { if (!hash) { return; } var level = 1; var subMenuColor1 = BCWebsiteProductSubPagesLevel2.parentColor; var subMenuColor2 = ''; if (this.lastMarked[level] != null && this.lastMarked[level] != this.subIndex[hash]) { this.lastMarked[level].alt = 0; /*var target = this.lastMarked[level].childNodes[1].childNodes[0]; target.style.color = subMenuColor2;*/ } KIndex.prototype.markIndex.call(this, hash); if (this.lastMarked[level] != null) { this.lastMarked[level].alt = 1; var target = this.lastMarked[level].childNodes[1].childNodes[0]; target.style.color = subMenuColor1; } /* var paths = hash.split('/'); paths.splice(0, 1); for ( var level in this.lastMarked) { this.removeCSSClass('KIndexMarked', this.lastMarked[level]); this.lastMarked[level].childNodes[1].childNodes[0].style.color = ''; this.lastMarked[level].alt = 0; } this.lastMarked = {}; var subHash = ''; for ( var path in paths) { subHash += '/' + paths[path]; if (!this.subIndex[subHash]) { continue; } this.lastMarked[this.subIndex[subHash].name] = this.subIndex[subHash]; this.addCSSClass('KIndexMarked', this.subIndex[subHash]); this.lastMarked[this.subIndex[subHash].name].alt = 1; }*/ } BCWebsiteProductSubPagesLevel2.changeContext = function(widget, hash) { if (!(Kinky.site.childWidget(hash) instanceof BCWebsiteThreeColumnHighlight)) { widget.setStyle({ display : 'none' }); return; } else { widget.setStyle({ display : 'block' }); widget.refresh(); } } BCWebsiteRightPanel.prototype = new KPanel(); BCWebsiteRightPanel.prototype.constructor = BCWebsiteRightPanel; function BCWebsiteRightPanel(parent) { if (parent != null) { KPanel.call(this, parent); this.hash = '/right-panel'; } } BCWebsiteRightPanel.prototype.draw = function() { var highlightsContainer = new BCWebsiteHighlightsWidget(this); this.appendChild(highlightsContainer); var productContainer = new BCWebsiteProductHighlights(this); productContainer.setTitle("Produtos Relacionados"); this.appendChild(productContainer); KPanel.prototype.draw.call(this); } BCWebsiteSearchBox.prototype = new KForm(); BCWebsiteSearchBox.prototype.constructor = BCWebsiteSearchBox; function BCWebsiteSearchBox(parent) { if (parent != null) { KForm.call(this, parent); this.staticForm = true; this.addQueryListener(BCWebsiteSearchBox.changeSearch, [ '/search/*' ]); this.translations = null; } } BCWebsiteSearchBox.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.setTitle(this.translations.searchTitle); this.searchInput = new KInput(this, 'text', '', 'text'); this.searchInput.addValidator(/.+/, ''); this.searchInput.addCSSClass('SearchInput'); this.addInput(this.searchInput); this.clearBoth(); var submitBt = new BCWebsiteKInput(this, this.translations.search, 'searchBt'); this.addInput(submitBt); KForm.prototype.draw.call(this); } BCWebsiteSearchBox.prototype.onValidate = function(text, params, status) { if (status) { var query = '/search/' + encodeURIComponent(params.text); KBreadcrumb.dispatchURL({ query : query }); } else { for (var index in params) { var input = params[index].getInput(); input.focus(); input.style.color = 'red'; } } return false; } BCWebsiteSearchBox.changeSearch = function(widget, query) { var value = query.split('/')[2]; if (value && value != '') widget.searchInput.setValue(value); } BCWebsiteSearchResults.prototype = new BCWebsiteKList(); BCWebsiteSearchResults.prototype.constructor = BCWebsiteSearchResults; function BCWebsiteSearchResults(parent) { if (parent != null) { BCWebsiteKList.call(this, parent); this.perPage = 10; this.addQueryListener(BCWebsiteSearchResults.changeSearch, [ '/search/*' ]); this.isPaginated = true; this.totalResults = 0; this.data = {}; this.translations = this.getParent('KPage').getTranslation(this.className); } } BCWebsiteSearchResults.changeSearch = function(widget, query){ if (widget.activated() && (query.split('/')[2] != '')) { widget.totalResults = 0; widget.totalPages = 1; widget.refresh(); } } BCWebsiteSearchResults.prototype.load = function() { if (this.getQuery()) { var queryArgs = this.getQuery().split('/'); this.data.feServiceArgs = { args : { text : queryArgs[2] } }; }else{ this.draw(); return; } KList.prototype.load.call(this); } BCWebsiteSearchResults.prototype.onLoad = function(data) { this.data.items = data.searchResults; this.data.searchQuery = data.searchQuery; this.totalResults = data.totalResults; this.setTotalPages(Math.ceil(this.totalResults / this.perPage), true); this.draw(); } BCWebsiteSearchResults.prototype.afterNext = function() { if(this.totalResults == 0){ var noContent = new KText(this); noContent.setText(this.translations.noContent); this.appendChild(noContent); } if (this.totalPages <= 1){ this.setStyle( { display : 'none' }, KWidget.PAGINATION_DIV); } this.activate(); } BCWebsiteSearchResults.prototype.draw = function() { if (this.data.items && this.data.items.length > 0) { var titleElements = new KText(this); titleElements.setTitle(this.translations.searchResults + '

' + this.totalResults + ' ' + this.translations.resultsfound + '

', true); titleElements.setText(this.data.searchQuery); this.appendTitleChild(titleElements); for ( var index in this.data.items) { var item = new KPanel(this); item.setTitle(this.data.items[index].resultTitle); var itemLink = new BCWebsiteKButton(item, this.translations.more, 'link', function(e){ var widget = KSystem.getEventWidget(e); KBreadcrumb.dispatchURL({ hash : widget.link.split('public/biocol')[1], query : '' }); }); itemLink.link = this.data.items[index].resultLink; item.appendChild(itemLink); this.appendChild(item); } } BCWebsiteKList.prototype.draw.call(this); if (!this.data.items || !(this.data.items.length > 0)){ this.setStyle({ display : 'none' }); } if (this.totalPages <= 1) { this.setStyle( { display : 'none' }, KWidget.PAGINATION_DIV); }else{ this.setStyle( { display : 'block' }, KWidget.PAGINATION_DIV); } } BCWebsiteStoreFilter.prototype = new KForm(); BCWebsiteStoreFilter.prototype.constructor = BCWebsiteStoreFilter; function BCWebsiteStoreFilter(parent) { if (parent != null) { KForm.call(this, parent); this.translations = null; } } BCWebsiteStoreFilter.prototype.load = function() { var params = new Object(); if (this.data.feServiceArgs) { KSystem.merge(params, this.data.feServiceArgs); } params.contentView = this.data.contentView; params.contentID = this.data.contentID; params.offset = this.nPage * this.perPage; params.limit = this.perPage; this.kinky.get(this, this.data.feService, params); } BCWebsiteStoreFilter.prototype.onLoad = function(data) { if (!this.data){ this.data = {}; } this.data.categories = data.categories; this.data.districts = data.districts; this.draw(); } BCWebsiteStoreFilter.prototype.draw = function() { this.translations = this.getParent('KPage').getTranslation(this.className); this.setTitle(this.translations.title); var districtCombo = new KCombo(this, this.translations.district, 'districtID'); for (var distIndex in this.data.districts){ districtCombo.addOption(this.data.districts[distIndex].regionID, this.data.districts[distIndex].name); } districtCombo.setStyle({ labelPosition : 'inside', marginLeft: '168px' }); this.addInput(districtCombo); var productCombo = new KCombo(this, this.translations.product, 'categoryID'); for (var prodIndex in this.data.categories){ productCombo.addOption(this.data.categories[prodIndex].categoryID, this.data.categories[prodIndex].name); } productCombo.setStyle({ labelPosition : 'inside' }); this.addInput(productCombo); var allStores = new KCheckBox(this, '', 'allStores', true); allStores.addOption(true, this.translations.allStores); this.addInput(allStores); this.clearBoth(); var submitBt = new BCWebsiteKInput(this, this.translations.search, 'searchBt'); this.addInput(submitBt); KForm.prototype.draw.call(this); } BCWebsiteStoreFilter.prototype.onValidate = function(text, params, status) { var query = '/store-filter'; if(params.allStores == 'true'){ query += '/all'; }else{ if (params.districtID && params.districtID != ''){ query += '/district/' + params.districtID; }else if (params.categoryID && params.categoryID != ''){ query += '/category/' + params.categoryID; }else{ query += '/all'; } } KBreadcrumb.dispatchURL({ query : query }); return false; } BCWebsiteStoreList.prototype = new BCWebsiteKList(); BCWebsiteStoreList.prototype.constructor = BCWebsiteStoreList; function BCWebsiteStoreList(parent) { if (parent != null) { BCWebsiteKList.call(this, parent); this.perPage = 6; this.addQueryListener(BCWebsiteStoreList.changeRegion, [ '/store-filter/*' ]); this.isPaginated = true; this.actualRegion = null; this.waitForLoad = true; this.translations = this.getParent('KPage').getTranslation(this.className); } } BCWebsiteStoreList.changeRegion = function(widget, query) { this.actualRegion = null; if (widget.activated()) { // widget.parent.mapContainer.setStyle({ // visibility : 'visible' // }); widget.refresh(); } }; BCWebsiteStoreList.prototype.load = function() { if (this.getQuery()) { var queryArgs = this.getQuery().split('/'); for ( var index in queryArgs) { var indexInt = parseInt(index); if (queryArgs[indexInt] == 'category' && queryArgs[indexInt + 1] != '') { this.data.feServiceArgs.config.categoryID = queryArgs[indexInt + 1]; } if (queryArgs[indexInt] == 'district' && queryArgs[indexInt + 1] != '') { this.data.feServiceArgs.config.regionID = queryArgs[indexInt + 1]; } if (queryArgs[indexInt] == 'all') { this.data.feServiceArgs.config.categoryID = null; this.data.feServiceArgs.config.regionID = null; break; } } } else { this.draw(); return; } this.data.feServiceArgs.config.stateID = this.data.config.stateID; BCWebsiteKList.prototype.load.call(this); }; BCWebsiteStoreList.prototype.onLoad = function(data) { BCSite.mapWindowDialog.data = this.data; this.data.items = data.items; this.setTotalPages((Math.ceil(data.items.length / this.perPage)), true); this.draw(); }; BCWebsiteStoreList.prototype.afterNext = function() { if ((this.data.items.length / this.perPage) <= 1){ this.setStyle({ display : 'none' }, KWidget.PAGINATION_DIV); } if (!(this.data.items.length > 0)){ var noContent = new KText(this); noContent.setText(this.translations.noContent); this.appendChild(noContent); // this.parent.mapContainer.setStyle({ // visibility : 'hidden' // }); } }; BCWebsiteStoreList.prototype.draw = function() { // var googleMap = this.parent.googleMap; if (this.data.items && this.data.items.length > 0) { this.titleElements = new KText(this); this.titleElements.setTitle(this.translations.searchResults + '

' + this.data.items.length + ' ' + this.translations.resultsfound + '

', true); this.appendTitleChild(this.titleElements); var first = true; for ( var index in this.data.items) { var item = new KText(this); { if (this.data.items[index].regionName != this.actualRegion && !(/district/.test(this.getQuery()))) { item.setTitle('\u2022 ' + this.data.items[index].regionName); this.actualRegion = this.data.items[index].regionName; this.titleElements.setText(this.translations.all); } else { item.setStyle({ display : 'none' }, KWidget.TITLE_DIV); this.titleElements.setText(this.data.items[index].regionName); } if (this.data.items[index].name) { item.appendText('

' + this.translations.name + '

' + this.data.items[index].name + ''); } if (this.data.items[index].address) { item.appendText('

' + this.translations.address + '

' + this.data.items[index].address + ''); } if (this.data.items[index].telephone) { item.appendText('

' + this.translations.telephone + '

' + this.data.items[index].telephone + ''); } if (this.data.items[index].fax) { item.appendText('

' + this.translations.fax + '

' + this.data.items[index].fax + ''); } if (this.data.items[index].schedule) { item.appendText('

' + this.translations.schedule + '

' + this.data.items[index].schedule + ''); } //nao descomentar ja estava item.data.id = this.data.items[index].locationID; item.data.pointInfo = this.data.items[index]; // item.addEventListener('mouseover', function(e) { // if (googleMap && googleMap.activated() && googleMap.map) { // var widget = KSystem.getEventWidget(e); // BCSite.mapWindowDialog.currentPointInfo = widget.data.pointInfo; // eval('coordinate = new google.maps.LatLng(' + widget.data.pointInfo.coordinate + ');'); // // googleMap.map.setCenter(coordinate); // } // }); if (this.data.items[index].image) { var itemPhoto = new KImage(item, this.data.items[index].image); item.appendChild(itemPhoto); itemPhoto.go(); } } this.appendChild(item); } } BCWebsiteKList.prototype.draw.call(this); if (!this.data.items || !(this.data.items.length > 0)) { this.setStyle({ display : 'none' }); // this.parent.mapContainer.setStyle({ // visibility : 'hidden' // }); } else { // this.placePoints(); } }; BCWebsiteStoreList.prototype.placePoints = function() { var googleMap = this.parent.googleMap; if (googleMap && googleMap.activated() && googleMap.map) { for ( var index = this.data.items.length - 1; index != -1; --index) { var coordinate = null; eval('coordinate = new google.maps.LatLng(' + this.data.items[index].coordinate + ');'); var mapPoint = new Object(); mapPoint.coordinate = this.data.items[index].coordinate; mapPoint.local = ''; mapPoint.city = ''; mapPoint.address = ''; if (this.data.items[index].designation) mapPoint.designation = this.data.items[index].designation; else mapPoint.designation = ''; googleMap.placeMarker(coordinate, false, false, mapPoint); } } else { KSystem.addTimer('Kinky.getWidget(\'' + this.id + '\').placePoints()', 800); } }; BCWebsiteTopMenu.prototype = new KIndex(); BCWebsiteTopMenu.prototype.constructor = BCWebsiteTopMenu; function BCWebsiteTopMenu(parent, id, data) { if (parent) { KIndex.call(this, parent, id, data); this.changeMenuIndex = 0; } } BCWebsiteTopMenu.prototype.setMarked = function(hash) { this.markIndex(hash); } BCWebsiteTopMenu.prototype.draw = function() { this.changeMenuIndex = Math.round(this.data.pages.length / 2); this.loadIndex(this.data); for ( var element in this.childWidgets()) { this.childWidget(element).go(); } this.activate(); this.markIndex(this.getHash()); } BCWebsiteTopMenu.prototype.loadIndex = function(page, level, topUL, parent, pageIndex) { if (!pageIndex) { pageIndex = 1; } var ul = null; if (level == null) { if (this.topUL == null) { this.topUL = window.document.createElement('ul'); this.topUL.className = 'KIndexLevel1'; this.topUL.id = this.hash; this.content.appendChild(this.topUL); } ul = topUL = this.topUL; level = 0; for ( var index in page.pages) { this.loadIndex(page.pages[index], level + 1, ul, page, pageIndex++); } } else { if (level == 1) { if (page.urlHashText == '/map'){ return; } if(page.template == 12) { BCMicroSite.productPageHash = page.urlHashText; } var li = window.document.createElement('li'); var liClassName = 'KIndexLevelItem' + level + ' KIndex' + page.urlHashText.replace(/\//g, '_').toUpperCase(); if (page.urlHashText != '/newsletter'){ liClassName += ' Special'; } li.name = level; try { li.className = liClassName; li.id = page.urlHashText.replace(/\//g, '_').toUpperCase(); } catch (e) { dump(parent, false, true); } var background = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.BACKGROUND_DIV]); background.id = li.id + '_background'; background.className = ' KWidgetPanelBackground MainLinkBackground '; background.style.position = 'absolute'; li.appendChild(background); var leftDiv = window.document.createElement('div'); leftDiv.className = 'MainLinkLeft'; var middleDiv = window.document.createElement('div'); middleDiv.className = 'MainLinkMiddle'; var rightDiv = window.document.createElement('div'); rightDiv.className = 'MainLinkRight'; background.appendChild(leftDiv); background.appendChild(middleDiv); background.appendChild(rightDiv); var contentContainer = window.document.createElement(this.tagNames[Kinky.HTML_READY][KWidget.CONTAINER_DIV]); contentContainer.className = ' KWidgetPanelContentContainer MainLinkContentContainer '; contentContainer.style.clear = 'both'; contentContainer.style.position = 'relative'; li.appendChild(contentContainer); var a = window.document.createElement('a'); contentContainer.appendChild(a); if (page.graphicStyle && page.graphicStyle.textImages && page.graphicStyle.textImages.pageMenuTitle) { a.appendChild(KCSS.img(page.graphicStyle.textImages.pageMenuTitle.base, page.menuText, page.titleText)); } else { a.appendChild(window.document.createTextNode(page.menuText)); } a.href = (/http:/.test(page.urlHashText) ? '' : '#') + page.urlHashText; a.target = (/http:/.test(page.urlHashText) ? '_blank' : '_self'); topUL.appendChild(li); this.subIndex[page.urlHashText] = li; } } }; BCWebsiteFooterMenu.prototype.loadTranslations = function() { this.widget_translations = { 'BCWebsiteFooterMenu' : { rightsText : 'Todos os direitos reservados \u00e0 Biocol S.A. 2011' } }; }; BCWebsiteKList.prototype.loadTranslations = function() { this.widget_translations = { 'BCWebsiteKList' : { previousPage : 'P\u00e1g. Anterior', nextPage : 'P\u00e1g. Seguinte' } }; }; BCWebsitePressRelease.prototype.loadTranslations = function() { this.translations = { 'BCPressList' : { download : 'Download', noContent : 'N\u00e3o existem conte\u00fados a apresentar.' } }; } BCContact.prototype.loadTranslations = function() { this.translations = { 'BCFormContact' : { name : 'Nome *', email : 'E-Mail *', phone : 'Telefone', message : 'Mensagem *', submit : 'SUBMETER', mandatoryFields : '* Campos obrigat\u00f3rios', successTitle : 'SUCESSO', successText : 'Mensagem enviada com sucesso. Obrigada pelo contacto.', successButton : 'FECHAR', errorTitle : 'ERRO', errorText : 'Ocorreu um erro no envio do pedido de contacto. Pedimos desculpa.', errorButton : 'TENTAR NOVAMENTE' } }; } BCContestDetail.prototype.loadTranslations = function() { this.translations = { 'BCContestDetail' : { participate : 'PARTICIPAR' } }; }; BCContestParticipate.prototype.loadTranslations = function() { this.translations = { 'BCContestForm' : { name : 'Nome', email : 'E-Mail', phone : 'Telefone', answer : 'Resposta', submit : 'SUBMETER', biocolNewsletter : 'Quero receber a Newsletter da BIOCOL', termsText : 'Concordo com os Termos & Condi\u00e7\u00f5es', answerTitle : 'Pergunta', dataTitle : 'Formul\u00e1rio', successTitle : 'SUCESSO', successText : 'A tua participa\u00e7\u00e3o no passatempo foi enviada com sucesso.', successButton : 'FECHAR', errorTitle : 'ERRO', errorText : 'Ocorreu um erro e n\u00e3o nos foi poss\u00edvel receber a tua participa\u00e7\u00e3o no passatempo.', errorButton : 'TENTAR NOVAMENTE' } }; }; BCContestWinners.prototype.loadTranslations = function() { this.translations = { 'BCContestWinnersList' : { winnerName : 'Vencedores', winnerText : 'Frase' } }; }; BCFaq.prototype.loadTranslations = function() { this.translations = { 'BCMappedList' : { btBack : 'topo', noContent : 'N\u00e3o existem conte\u00fados a apresentar.' } }; }; BCLocationMap.prototype.loadTranslations = function() { this.translations = { 'BCMapGridList' : { fax : 'Fax.', telephone : 'Tel.', schedule : 'Hor\u00e1rio.' } }; }; BCMicroSite.prototype.loadTranslations = function() { this.translations = { buttonLabel : 'FECHAR' }; } BCNews.prototype.loadTranslations = function() { this.translations = { 'BCList' : { readMore : 'LER MAIS', close : 'FECHAR', noContent : 'N\u00e3o existem conte\u00fados a apresentar.' } }; }; BCNewsletter.prototype.loadTranslations = function() { this.translations = { name : 'Nome', email : 'E-mail', biocol : 'Quero receber a Newsletter da BIOCOL', submit : 'SUBSCREVER', successTitle : 'SUCESSO', successText: 'Subscri\u00e7\u00e3o efectuada com sucesso.', successButton : 'FECHAR', errorTitle: 'ERRO', errorText: 'Ocorreu um erro na subscri\u00e7\u00e3o.', errorButton : 'TENTAR NOVAMENTE' }; }; BCProductHighlight.prototype.loadTranslations = function() { this.translations = { title : 'Produtos Relacionados' }; }; BCTips.prototype.loadTranslations = function() { this.translations = { 'BCList' : { noContent : 'N\u00e3o existem conte\u00fados a apresentar.' } }; }; BCWebsiteContact.prototype.loadTranslations = function() { this.translations = { 'BCWebsiteFormContact' : { firstName : '* Primeiro Nome', firstNameError : 'Insira o seu Primeiro Nome', lastName : '* \u00daltimo Nome', lastNameError : 'Insira o seu \u00daltimo Nome', email : '* E-mail de contacto', emailError : 'o email foi introduzido incorrectamente', phone : '* Nr de contacto', phoneError : 'Insira o seu N\u00famero de Telefone', mandatoryFields : '* Campos obrigat\u00f3rios', message : '* Mensagem', messageError : 'Insira a sua Mensagem', submit : 'Enviar', successTitle : 'Sucesso', successText : 'O seu formul\u00e1rio de contacto foi enviado com sucesso.', errorTitle : 'Erro', errorText : 'Ocorreu um erro e n\u00e3o nos foi poss\u00edvel receber o seu formul\u00e1rio de contacto.' } }; } BCWebsiteExport.prototype.loadTranslations = function() { this.translations = { 'BCWebsiteFormContact' : { firstName : '* Primeiro Nome', firstNameError : 'Insira o seu Primeiro Nome', lastName : '* \u00daltimo Nome', lastNameError : 'Insira o seu \u00daltimo Nome', email : '* E-mail de contacto', emailError : 'o email foi introduzido incorrectamente', phone : '* Nr de contacto', phoneError : 'Insira o seu N\u00famero de Telefone', mandatoryFields : '* Campos obrigat\u00f3rios', message : '* Mensagem', messageError : 'Insira a sua Mensagem', submit : 'Enviar', successTitle : 'Sucesso', successText : 'O seu formul\u00e1rio de contacto foi enviado com sucesso.', errorTitle : 'Erro', errorText : 'Ocorreu um erro e n\u00e3o nos foi poss\u00edvel receber o seu formul\u00e1rio de contacto.' }, 'BCWebsiteExportMap' : { 'south-america' : 'America do Sul', 'north-america' : 'America do Norte', 'asia' : 'Asia', 'europe' : 'Europa', 'oceania' : 'Oceania', 'africa' : 'Africa' } }; } BCWebsiteHomepage.prototype.loadTranslations = function() { this.translations = { 'BCHomepageHighlights' : { wizardBt : 'Descubra aqui o produto ideal para si', highlightTitle : 'Produtos em Destaque', more : 'Saber mais' }, 'BCNewsMarquee' : { newsTitle : 'Novidades' }, 'BCNewsHighlights' : { newsTitle : 'Not\u00edcias', seeAll : 'Ver todas', more : 'Ver mais' }, 'BCFacebookShare' : { shareTitle : 'Partilhe no Facebook', share : 'Partilhar' } }; } BCWebsiteNews.prototype.loadTranslations = function() { this.translations = { 'BCWebsiteList' : { readMore : 'Ler mais', close : 'Fechar', noContent : 'N\u00e3o existem conte\u00fados a apresentar.', previous : 'Pag. Anterior', next : 'Pag. Seguinte' } }; } BCWebsiteNewsletter.prototype.loadTranslations = function() { this.translations = { name : 'Nome', email : 'Email', dataTitle : 'Insira o seu nome e e-mail:', categoriesTitle : 'Eu quero receber novidades de:', submit : 'Subscrever', successTitle : 'Sucesso', errorTitle: 'Erro', successText: 'Subscreveste a nossa newsletter com sucesso.', errorText: 'Ocorreu um erro e n\u00e3o foi poss\u00edvel subscreveres a newsletter.' }; } BCWebsiteOpportunity.prototype.loadTranslations = function() { this.translations = { 'BCWebsiteAccordionList' : { opportunityList : 'Lista de Oportunidades', applyHere : 'Fa\u00e7a aqui a sua candidatura', applyOpportunity : 'Candidatar' }, 'BCWebsiteJobForm' : { formTitle : 'Candidatura espont\u00e2nea', backToTop: 'Voltar ao topo', name : '* Nome', nameError : 'Insira o seu Nome', email : '* E-mail de contacto', emailError : 'o email foi introduzido incorrectamente', phone : '* Telefone', phoneError : 'Insira o seu N\u00famero de Telefone', cv : '* Carregar CV', cvError : 'Insira o seu CV', mandatoryFields : '* Campos obrigat\u00f3rios', message : '* Mensagem', messageError : 'Insira a sua Mensagem', submit : 'Enviar', successTitle : 'Sucesso', successText : 'A sua candidatura foi enviada com sucesso.', errorTitle : 'Erro', errorText : 'Ocorreu um erro e n\u00e3o nos foi poss\u00edvel receber a sua candidatura.' } }; } BCWebsitePressRelease.prototype.loadTranslations = function() { this.translations = { 'BCPressList' : { download : 'Download', noContent : 'N\u00e3o existem conte\u00fados a apresentar.' } }; } BCWebsiteSearch.prototype.loadTranslations = function() { this.translations = { 'BCWebsiteSearchBox' : { searchTitle : 'Pesquisa', search : 'Pesquisar' }, 'BCWebsiteSearchResults' : { searchResults : 'Resultados da Pesquisa', resultsfound : 'resultados encontrados', more : 'Ver mais', noContent : 'N\u00e3o foram encontrados resultados.' } }; } BCWebsiteStoreFinder.prototype.loadTranslations = function() { this.translations = { 'BCWebsiteStoreFilter' : { title : 'Filtre a sua pesquisa por:', district : 'Localidade', product : 'Produto', allStores : 'Todas as lojas', search : 'Pesquisar' }, 'BCWebsiteStoreList' : { name : 'Nome', address : 'Morada:', telephone : 'Telefone:', fax : 'Fax:', schedule : 'Hor\u00e1rio de abertura:', all : '> Todas as Localidades', searchResults : 'Resultados da Pesquisa', resultsfound : 'resultados encontrados', noContent : 'N\u00e3o foram encontrados resultados.' } }; } function load() { Kinky.SERVICES_URL = 'http://www.dieteffect.pt/ui/proxy.php'; Kinky.GOOGLE_ANALYTICS = 'UA-1573854-68'; Kinky.SITE_URL = 'http://www.dieteffect.pt/'; Kinky.SITE_CSS_URL = Kinky.SITE_URL + 'ui/styles/'; Kinky.DATA_URL = Kinky.SITE_URL + 'cache/'; Kinky.HOMEPAGE_URL = '/homepage'; Kinky.BASE_VERSION = '/dieteffect'; var prefix = window.document.location.href.split('#')[0].replace(Kinky.SITE_URL, '').split('/'); if (prefix != '') { Kinky.DEFAULT_LANG = prefix[0]; } else { Kinky.DEFAULT_LANG = 'pt'; } Kinky.BASE_JS_URL = 'http://www.dieteffect.pt/ui/'; Kinky.BASE_TEMP_DIR = '/dados/sites/biocol/www/temp/'; Kinky.BASE_TEMP_URL = '/dados/sites/biocol/www/temp/'; Kinky.BASE_SERVICE = 'php:Frontend:Website'; Kinky.BASE_SERVICE = 'js:structure/' + Kinky.DEFAULT_LANG + '/public' + Kinky.BASE_VERSION + ':info'; Kinky.SERVICE_NAMESPACE = Kinky.BASE_SERVICE.split(':')[0]; Kinky.BASE_CONTENT_SERVICE = 'php:Frontend:GetContent'; Kinky.BASE_CONTENT_SERVICE = 'js:data/' + Kinky.DEFAULT_LANG + '/public/:info.json'; Kinky.BASE_CLASS = 'BCMicroSite'; Kinky.BASE_TAG = 'contentDiv'; Kinky.AUTOLOAD_PAGE = true; //Kinky.DEFAULT_USER = 'admin'; //Kinky.DEFAULT_USER_SECRET = SHA1('zeroeum'); Kinky.SHOW_INSTANTIATIONS_ERRORS = 'dump'; KCaptcha.CAPTCHA_SERVICE_URL = Kinky.BASE_JS_URL + 'captchaCreate.php'; Kinky.DEV_MODE = true; Kinky.ALLOW_EFFECTS = true; KCSS.NO_IE_OPACITY = true; Kinky.config(); } if (window.attachEvent) { window.attachEvent('onload', load); } else { window.addEventListener('load', load, false); }