/** * @fileoverview js/main * * @description main network functions
* * @author bKarolyi, Worbyd */ /** * javascript language function * @param {Object} text */ function __( text, replace_pattern ) { if ( typeof dict == "undefined" ) { return text; } for ( i_dict = 0; i_dict < dict.length; i_dict++ ) { var act_dict = dict[i_dict]; if ( act_dict.source == text ) { var target = replaceLanguagePattern( act_dict.target, replace_pattern ); return target; } } text = replaceLanguagePattern( text, replace_pattern ); return text; } function replaceLanguagePattern( target, pattern ) { for ( i in pattern ) { var regexp = new RegExp( i, "g" ); target = target.replace( regexp, pattern[i] ); } return target; } if ( typeof console == "undefined" ) { var console = { log: function() {} }; } /** * YUI helper methods for manipulating Dom elements * @type object */ var Dom = YAHOO.util.Dom, /** * YUI utilities for managing DOM Events and tools for building event systems * @type object */ Event = YAHOO.util.Event, /** * YUI simplified interface to the XMLHttpRequest object * @type object */ Connect = YAHOO.util.Connect, /** * YUI JSON parser * @type object */ JSON = YAHOO.lang.JSON, /** * @description selector */ $ = YAHOO.util.Selector.query, /** * true if browser is Firefox * @type Boolean */ ff = ( YAHOO.env.ua.gecko > 0 ), /** * true if browser is Firefox 3 * @type Boolean */ ff3 = ( YAHOO.env.ua.gecko >= 1.9 ), /** * true if browser is Internet Explorer * @type Boolean */ ie = ( YAHOO.env.ua.ie > 0 ), /** * true if browser is Internet Explorer 6.0 * @type Boolean */ ie6 = ( YAHOO.env.ua.ie == 6 ), /** * true if browser is Internet Explorer 7.0 * @type Boolean */ ie7 = ( YAHOO.env.ua.ie == 7 ), /** * true if operating system is Linux */ linux = ( navigator.userAgent.toLowerCase().indexOf( "linux" ) != -1 ), /** * true if browser is Opera * @type Boolean */ opera = ( YAHOO.env.ua.opera ); YAHOO.log = function( text ) { if ( typeof console != "undefined" ) { //console.log(text); } } /** * @namespace network namespace */ var nw = { /** * Ajax call * Method for initiating an asynchronous request via the XHR object. * @param String url * @param Object callback name of the callback function * example:
* var callback =
* {
* success: function(o)
* {
* //o.responseText;
* },
* failure: function()
* {
*
* }
* }
* * @param String [method] "post" || "get"
* default is get * @param Object [postData] data to post
* example:
* "variable=value&variable2=value2"
*/ ajax: function( url, callback, method, postData ) { method = method || "get"; postData = postData || null Connect.resetFormState(); var transaction = Connect.asyncRequest( method, url, callback, postData ); return transaction; }, /** * * Ajax call with form sending
* Method for initiating an asynchronous request via the XHR object. * @param {String | HTMLelement} id of the form or the form * @param Object callback name of the callback function * example:
* var callback =
* {
* success: function(o)
* {
* //o.responseText;
* },
* failure: function()
* {
*
* }
* }
* @param {Boolean} true if there is file upload * */ ajaxForm: function( form_element, callback, postData, upload ) { form_element = Dom.get( form_element ); var url = form_element.action; var method = form_element.method; upload = upload || false; postData = postData || null; Connect.setForm( form_element, upload ); var transaction = Connect.asyncRequest( method, url, callback, postData ); return transaction; }, /** * ajax call updates tag after getting data * @param {String} url ajax url * @param {String} id Elements id to update * @param {String} method default is get */ ajaxUpdate: function( url, id, method, postData ) { var n_ajax = new n_ajax_class( url, id, function( o ) { Dom.get( id ).innerHTML = o.responseText; }, null, method, postData ); n_ajax.send(); return true; }, /** * shows alert dialog
* an alias for this.showAlertDialog * @param {String} text alert text to show */ alert: function( text ) { alert_lightbox.showAlertDialog( text ); }, /** * * @param {Object} boxnames * @param {Object} current_num * @param {Object} active_classname */ changeTab: function( tab_id, max_num, current_num, active_classname ) { active_classname = active_classname || "n_activetab"; var current_tab = Dom.get( "n_" + tab_id + "tab_" + current_num ); if ( Dom.hasClass( current_tab, active_classname ) ) { return true; } var tabs = []; for( i_tabs = 1; i_tabs <= max_num; i_tabs++ ) { var act_tab_obj = {}; if ( Dom.get( "n_" + tab_id + "tab_" + i_tabs ) ) { act_tab_obj.tab = Dom.get( "n_" + tab_id + "tab_" + i_tabs ); act_tab_obj.content = Dom.get( "n_" + tab_id + "content_" + i_tabs ); if ( Dom.get( "n_" + tab_id + "extracontent_" + i_tabs ) ) { act_tab_obj.extracontent = Dom.get( "n_" + tab_id + "extracontent_" + i_tabs ) } tabs.push( act_tab_obj ); } } for( i_tab_obj = 0; i_tab_obj < tabs.length; i_tab_obj++ ) { var act_tab_obj = tabs[i_tab_obj]; if ( act_tab_obj.tab == current_tab ) { Dom.addClass( act_tab_obj.tab, active_classname ); if ( act_tab_obj.content ) { this.show( act_tab_obj.content ); } if ( act_tab_obj.extracontent ) { this.show( act_tab_obj.extracontent ); } } else { Dom.removeClass( act_tab_obj.tab, active_classname ); if ( act_tab_obj.content ) { this.hide( act_tab_obj.content ); } if ( act_tab_obj.extracontent ) { this.hide( act_tab_obj.extracontent ); } } } return true; }, /** * shows confirm dialog
* an alias for this.showAlertDialog * @param {Object} text confirm question to show * @param {Object} handleYes callback function for Yes button */ confirm: function( text, handleYes ) { confirm_lightbox.showConfirmDialog( text, handleYes ); }, /** * get dom element's real height
* @param {string || HTMLelement} el HTML element or id of the HTML element * @returns {Number} height of the element
* or false if failed to get height ( perhaps not displayed ) */ getRealHeight: function( el, remove_padding ) { el = Dom.get( el ); if ( !el ) { return false; } var hidden = ( Dom.hasClass( el, "n_invisible" ) ) ? true : false; if ( hidden ) { Dom.removeClass( el, "n_invisible" ); } var region = Dom.getRegion( el ); var top = parseInt( region.top ); var bottom = parseInt( region.bottom ); if ( hidden ) { Dom.addClass( el, "n_invisible" ); } var real_height = bottom - top; if ( remove_padding && !ie6 ) { var padding_top = parseInt( Dom.getStyle( el, "padding-top" ) ); var padding_bottom = parseInt( Dom.getStyle( el, "padding-bottom" ) ); real_height -= padding_top; real_height -= padding_bottom; } return real_height; }, /** * makes element hidden * @param {HTMLelement || String} id element or id of the element to hide */ hide: function( id ) { if ( !Dom.get( id ) ) { return false; } Dom.addClass( id, "n_invisible" ); }, /** * hides custom dialog * @id id of the markup code */ hideLight: function( id ) { custom_lightbox.hideCustomDialog( id ); }, /** * hides ajax dialog */ hideLightAjax: function() { ajax_lightbox.onReady = function() {} ajax_lightbox.hideAjaxDialog(); }, /** * an alias for hideWaitingDialog */ hideWaiting: function() { waiting_lightbox.hideWaitingDialog(); }, /** * checks if an element is in the specified array * @param {Object} el an element to check * @param {Array} arr the array we search in * @return {Number} the position of the element in the array -1 if element is not in array */ indexOf: function( el, arr ) { for( i_arr_item = 0; i_arr_item < arr.length; i_arr_item++ ) { var act_arr_item = arr[i_arr_item]; if ( act_arr_item == el ) { return i_arr_item; } } return -1; }, /** * whether an input field is empty * @param {HTMLElement || String} element or id of the element to check * @param {Boolean} trimmed trim the value or not */ isEmptyField: function( el, trimmed ) { el = Dom.get( el ); var value = el.value; if ( trimmed ) { value = YAHOO.lang.trim( el.value ); } return ( value == "" ) ? true : false; }, /** * checks if an element is in the specified array * @param {Object} el an element to check * @param {Object} arr the array we search in * @return true if element is in the array */ isInArray: function( el, arr ) { for( i_arr_item = 0; i_arr_item < arr.length; i_arr_item++ ) { var act_arr_item = arr[i_arr_item]; if ( act_arr_item == el ) { return true; } } return false; }, /** * whether an element is visible * @param {String | HTMLelement} el element or id of the element to check * @return true if visible */ isVisible: function( el ) { el = Dom.get( el ); if ( Dom.hasClass( el, "n_invisible" ) ) { return false; } else { return true; } }, /** * an alias for showCustomDialog * @param {Object} id id of the markup code * @param {Object} config config properties for setting custom dialog */ openLight: function( id, config ) { custom_lightbox.showCustomDialog( id, config ); }, /** * an alias for showAjaxDialog * @param {Object} id id of the markup code * @param {Object} config config properties for setting ajax dialog */ openLightAjax: function( url, config ) { ajax_lightbox.showAjaxDialog( url, config ); }, /** * an alias for showWaitingDialog */ openWaiting: function() { waiting_lightbox.showWaitingDialog(); }, /** * remove accents from string * @param {String} str string to remove accents * @return string with removed accents */ removeAccents: function( str ) { var temp_str = ""; for ( i_letter = 0; i_letter < str.length; i_letter++ ) { var letter = ""; switch ( str.charAt( i_letter ) ) { case "ö": letter = "o"; break; case "ü": letter = "u"; break; case "ó": letter = "o"; break; case "ő": letter = "o"; break; case "ú": letter = "u"; break; case "é": letter = "e"; break; case "á": letter = "a"; break; case "ű": letter = "u"; break; case "í": letter = "i"; break; default: letter = str.charAt( i_letter ); } temp_str = temp_str+letter; } return temp_str; }, /** * scrolls the page to the current element * @param {String||HTMLElement} el element or id of the element to scroll * @param {Number} diff number to decrease the coordinate y with. Default is 10 */ scrollTo: function( el, diff ) { el = Dom.get( el ); if ( !el ) { return false; } diff = diff || 10; var is_hidden = false; if(Dom.getStyle(el, "display") == "none") { is_hidden = true; Dom.setStyle(el, "display", "block"); } var pos_y = Dom.getY(el); if(is_hidden) { Dom.setStyle(el, "display", "none"); } window.scrollTo( 0, pos_y - diff ); }, /** * makes element visible * @param {HTMLelement || String} id element or id of the element to show */ show: function( id ) { if ( !Dom.get( id ) ) { return false; } Dom.removeClass( id, "n_invisible" ) }, /** * show or hide current element * @param {String || HTMLelement} show_el element or id of the element to show * @param {HTMLelement} check_el optional if checked */ toggle: function( show_el, check_el ) { show_el = Dom.get( show_el ); check_el = Dom.get( check_el ); var visible; if ( check_el ) { if ( check_el.nodeName.toLowerCase() == "input" && check_el.type == "checkbox") { visible = ( check_el.checked ) ? false: true; } } else { visible = ( this.isVisible( show_el ) ) ? true : false; } if ( visible ) { this.hide( show_el ); } else { this.show( show_el ); } return true; }, setLightboxOrder: function() { //if authentication ligtbox is on take it to the top for ( i_cl = 0; i_cl < custom_lightbox.custom_dialogs.length; i_cl++ ) { var act_cl = custom_lightbox.custom_dialogs[ i_cl ]; if ( act_cl.id == "authentication_warning" ) { act_cl.bringToTop(); break; } } //if n_banner lightbox take it to the top if ( typeof n_banner != "undefined" ) { n_banner.bringToTop(); } return true; } } /** * @description simplified ajax handler class for instantiation * @param {String} url for sending request to * @param {String || HTMLelement} hide_el html element or id of the element we want to add indicator during the transaction * @param {function} onReady runs this function after the transaction was successed * @param {Object} payload a collection of data we want to transfer * @param {String} method method of the ajax call post || get * @param {String} postData variables we want to post * @class */ var n_ajax_class = function( url, hide_el, onReady, payload, method, postData ) { /** * @description url for sending request to * @type {String} */ this.url = url; /** * @description html element or id of the element we want to add indicator during the transaction * @type {String || HTMLelement} */ this.hide_el = hide_el; /** * @description runs this function after the transaction was successed * @type {function} */ this.onReady = onReady || null; /** * @description a collection of data we want to transfer * @type {Object} */ this.payload = payload || {}; /** * @description method of the ajax call post || get * @type {String} */ this.method = method || null; /** * @description variables we want to post * @type {String} */ this.postData = postData || null; /** * @description an instance of the indicator class * @type {Object} */ this.ind = ( this.hide_el ) ? new indicator.handler( hide_el ) : null; /** * @description stores the original object where the send is called from * @type {Object} */ this.caller_obj = null; /** * @description yui ajax object * @type Object */ this.transaction = null; /** * @description if response is in json format, stores it * @type {Object} */ this.json_response = null; this.indicator_is_disabled = false; this.handleAjaxError = function( o ) { }; this.handleDefaultError = function( message ) { nw.alert( message ); return true; }; /** * @description default function for error handling after the transaction was succeeded * @param {Object} o the transaction object */ this.responseHandler = function( o ) { nw.hideWaiting(); this.json_response = null; if ( this.ind ) { this.ind.hide(); } if ( o.getResponseHeader ) { try { eval( "var response_error = "+ o.getResponseHeader['Errormsg'] ); } catch(e) { } } if ( typeof response_error != "undefined" ) { this.handleDefaultError.call( this.caller_obj, response_error ); return false; } if ( o.getResponseHeader ) { try { eval( "var response_success = " + o.getResponseHeader['Successmsg'] ); } catch(e) { } } if ( typeof response_success != "undefined" ) { this.handleDefaultError.call( this.caller_obj, response_success ); return false; } try { var response = JSON.parse( o.responseText ); this.json_response = response; if ( response.type == 0 ) { this.handleDefaultError.call( this.caller_obj, response.message ); return false; } else if ( response.type == 1 ) { if ( this.onReady ) { this.onReady.call( this.caller_obj, o, this.payload ); return false; } } } catch ( e ) { } return true; }; this.handleFailure = function( o ) {}; /** * @description sends an ajax request * @param {Object} caller_obj stores the original object where the send is called from */ this.send = function( caller_obj ) { this.caller_obj = caller_obj; if ( this.ind ) { delete this.ind; this.ind = new indicator.handler( this.hide_el ); this.ind.show(); } else if ( !this.indicator_is_disabled ) { nw.openWaiting(); } this.transaction = nw.ajax( this.url, this.sendCallback, this.method, this.postData ); } /** * @description sends a form wth ajax * @param {Object} caller_obj stores the original object where the send is called from * @param {HTMLelement || String} form_el the form or id of the form */ this.sendForm = function( caller_obj, form_el ) { this.caller_obj = caller_obj; if ( this.ind ) { delete this.ind; this.ind = new indicator.handler( this.hide_el ); this.ind.show(); } else if ( !this.indicator_is_disabled ) { nw.openWaiting(); } this.transaction = nw.ajaxForm( form_el, this.sendCallback, this.postData ); } /** * @description uploads a form with ajax * @param {Object} caller_obj stores the original object where the send is called from * @param {HTMLelement || String} form_el the form or id of the form */ this.uploadForm = function( caller_obj, form_el ) { this.caller_obj = caller_obj; if ( this.ind ) { this.ind.show(); } else if ( !this.indicator_is_disabled ) { nw.openWaiting(); } this.transaction = nw.ajaxForm( form_el, this.sendCallback, this.postData, true ); } /** * @description callback object for the transaction * @param {Object} o transaction * @namespace */ this.sendCallback = { /** * @description successful ajax call * @param {Object} o the ajax object */ success: function( o ) { this.transaction = null; if ( !this.responseHandler( o ) ) { this.handleAjaxError.call( this.caller_obj, o ); return false; } if ( this.onReady ) { this.onReady.call( this.caller_obj, o, this.payload ); return true; } }, /** * @description ajax call failure */ failure: function( o ) { this.transaction = null; nw.hideWaiting(); if ( this.ind ) { this.ind.hide(); } this.handleFailure.call( this.caller_obj, o ); }, /** * @description ajax call succeed on file upload */ upload: function( o ) { this.sendCallback.success.call( this, o ); return true; }, /** * @description scope of the callback object */ scope: this } } /** * @description class for editiing field * @param {String} editfield_id id of the editable field * @class */ var n_editfield_simple_class = function( editfield_id ) { /** * @description stores ajax result * @type {Object} */ this.ajax_result = null; /** * @description wrap element of the edit field * @type {HTMLelement} */ this.editfieldwrap = null; /** * @description stores edit id * @type {String} */ this.editfield_id = editfield_id; /** * @description error callback element if exist * @type {HTMLelement} */ this.errormsg_el = null; /** * @description field wrap element * @type {HTMLelement} */ this.fieldwrap = null; /** * @description edit form * @type {HTMLelement} */ this.form_el = null; /** * @description field of the original text * @type {HTMLelement} */ this.originaltextfield = null; /** * @description edit input field * @type {HTMLelement} */ this.textinput = null; /** * @description ajax object for save changes * @type {Object} */ this.ajax_save = null; this.construct(); } /** * @description n_editfield_simple_class methods * @namespace */ n_editfield_simple_class.prototype = { /** * @description sets default html elements */ construct: function() { this.editfieldwrap = Dom.get( "n_" + this.editfield_id + "_editfieldwrap" ); this.fieldwrap = Dom.get( "n_" + this.editfield_id + "_fieldwrap" ); this.originaltextfield = Dom.get( "n_" + this.editfield_id + "_originaltextfield" ); this.textinput = Dom.get( "n_" + this.editfield_id + "_textinput" ); this.form_el = Dom.get( "n_" + this.editfield_id + "_form_el" ); this.errormsg_el = Dom.get( "n_" + this.editfield_id + "_errormsg" ) || null; return true; }, /** * @description shows edit area */ edit: function() { if ( this.originaltextfield ) { if ( this.originaltextfield.childNodes[0] ) { this.textinput.value = this.originaltextfield.childNodes[0].nodeValue; } else { this.textinput.value = this.originaltextfield.value; } } else { this.textinput.value = ""; } nw.hide( this.fieldwrap ); nw.show( this.editfieldwrap ); this.textinput.focus(); }, /** * @description saves changes * @param {Object} options options for handling errors */ save: function( options ) { this.ajax_save = this.ajax_save || new n_ajax_class( null, this.editfieldwrap, this.saveCallback ); if ( this.errormsg_el ) { nw.hide( this.errormsg_el ); } var min = 0; var max = 100; if ( options ) { min = options.min || min; max = options.max || max; } if ( YAHOO.lang.trim( this.textinput.value ).length <= min ) { if ( this.errormsg_el ) { nw.show( this.errormsg_el ); } else { nw.alert( __( "Kitöltése kötelező" ) ); } this.textinput.focus(); return false; } else if ( YAHOO.lang.trim( this.textinput.value ).length > max ) { if ( this.errormsg_el ) { nw.show( this.errormsg_el ); } else { nw.alert( __( "A szöveg hossza legfeljebb %num% karakter lehet!", { "%num%": max } ) ); } this.textinput.focus(); return false; } this.ajax_save.sendForm( this, this.form_el ); }, /** * @description callback function for saving changes * @param {Object} o transaction */ saveCallback: function( o ) { this.originaltextfield.innerHTML = this.textinput.value; this.hide(); return true; }, /** * @description hides edit area */ hide: function() { if ( this.errormsg_el ) { nw.hide( this.errormsg_el ); } nw.show( this.fieldwrap ); nw.hide( this.editfieldwrap ); } } var n_editfield_class = function() { this.units = []; } n_editfield_class.prototype = { /** * @description gets current unit * @param {HTMLelement} reload_el wrap element of the box. will be reloaded after saving edit form * @return unit object or false */ getUnitById: function( prefix, id ) { var editfield_id = id ? prefix + "_" + id : prefix; for ( i_unit = 0; i_unit < this.units.length; i_unit++ ) { var act_unit = this.units[ i_unit ]; if ( editfield_id == act_unit.editfield_id ) { return act_unit; } } return false; }, /** * @description makes a new unit if not exist already * @param {HTMLelement} inside_el some element inside the box */ add: function( prefix, id, unit_class, config ) { if ( !this.getUnitById( prefix, id ) ) { var unit = new unit_class; var editfield_id = id ? prefix + "_" + id : prefix; unit.construct( editfield_id, config ); this.units.push( unit ); return unit; } else { return this.getUnitById( prefix, id ); } } } /** * @description class for editiing field * @param {String} editfield_id id of the editable field * @class */ var n_editfield_unit_class = function() { } n_editfield_unit_class.prototype = { /** * @description stores ajax result * @type {Object} */ ajax_result: null, /** * @description wrap element of the edit field * @type {HTMLelement} */ editfieldwrap: null, /** * @description stores edit id * @type {String} */ editfield_id: null, /** * @description error callback element if exist * @type {HTMLelement} */ errormsg_el: null, /** * @description field wrap element * @type {HTMLelement} */ fieldwrap: null, /** * @description edit form * @type {HTMLelement} */ form_el: null, /** * @description field of the original text * @type {HTMLelement} */ originaltextfield: null, /** * @description edit input field * @type {HTMLelement} */ textinput: null, /** * @description ajax object for save changes * @type {Object} */ ajax_save: null, /** * @description sets default html elements */ construct: function( editfield_id ) { this.editfield_id = editfield_id; this.editfieldwrap = Dom.get( "n_" + this.editfield_id + "_editfieldwrap" ); this.fieldwrap = Dom.get( "n_" + this.editfield_id + "_fieldwrap" ); this.originaltextfield = Dom.get( "n_" + this.editfield_id + "_originaltextfield" ); this.textinput = Dom.get( "n_" + this.editfield_id + "_textinput" ); this.form_el = Dom.get( "n_" + this.editfield_id + "_form_el" ); this.errormsg_el = Dom.get( "n_" + this.editfield_id + "_errormsg" ) || null; return true; }, /** * @description shows edit area */ edit: function() { if ( this.originaltextfield ) { if ( this.originaltextfield.childNodes[0] ) { this.textinput.value = this.originaltextfield.childNodes[0].nodeValue; } else { this.textinput.value = this.originaltextfield.value; } } else { this.textinput.value = ""; } nw.hide( this.fieldwrap ); nw.show( this.editfieldwrap ); this.textinput.focus(); }, /** * @description saves changes * @param {Object} options options for handling errors */ save: function( options ) { this.ajax_save = this.ajax_save || new n_ajax_class( null, this.editfieldwrap, this.saveCallback ); if ( this.errormsg_el ) { nw.hide( this.errormsg_el ); } var min = 0; var max = 100; if ( options ) { min = options.min || min; max = options.max || max; } if ( YAHOO.lang.trim( this.textinput.value ).length <= min ) { if ( this.errormsg_el ) { nw.show( this.errormsg_el ); } else { nw.alert( __( "Kitöltése kötelező" ) ); } this.textinput.focus(); return false; } else if ( YAHOO.lang.trim( this.textinput.value ).length > max ) { if ( this.errormsg_el ) { nw.show( this.errormsg_el ); } else { nw.alert( __( "A szöveg hossza legfeljebb %num% karakter lehet!", { "%num%": max } ) ); } this.textinput.focus(); return false; } this.ajax_save.sendForm( this, this.form_el ); }, /** * @description callback function for saving changes * @param {Object} o transaction */ saveCallback: function( o ) { this.originaltextfield.innerHTML = this.textinput.value; this.hide(); return true; }, /** * @description hides edit area */ hide: function() { if ( this.errormsg_el ) { nw.hide( this.errormsg_el ); } nw.show( this.fieldwrap ); nw.hide( this.editfieldwrap ); } } /** * animation effects */ nw.effect = { afterOpen: function() { }, close: function( el ) { el = Dom.get( el ); var height = nw.getRealHeight( el ); var animate = new YAHOO.util.Anim( el, { height: { to: 1 } }, 0.5, YAHOO.util.Easing.backIn ); animate.onComplete.subscribe( function() { Dom.addClass( el, "n_invisible" ); this.edit_box.style.height = ""; }, this, true ); animate.animate(); }, fadeManager: function( config ) { this.fadeout_element = config.fadeout_element || null; this.fadein_element = config.fadein_element || null; this.afterFadeOut = function() { nw.hide( this.fadeout_element ); if ( !this.fadein_element ) { return true; } Dom.setStyle( this.fadein_element, "opacity", 0 ); nw.show( this.fadein_element ); this.fadeIn(); } this.afterFadeIn = function() { png.hackEntire(); return true; } this.fadeOut = function() { var animate = new YAHOO.util.Anim( this.fadeout_element, { opacity: { to: 0 }, zoom: { from: 0, to: 0 } }, 0.5 ); animate.onComplete.subscribe( this.afterFadeOut, this, true ); animate.animate(); } this.fadeIn = function() { var animate = new YAHOO.util.Anim( this.fadein_element, { opacity: { to: 1 }, zoom: { from: 0, to: 0 } }, 0.5 ); animate.onComplete.subscribe( this.afterFadeIn, this, true ); animate.animate(); } }, open: function( el ) { el = Dom.get( el ); var height = nw.getRealHeight( el ); el.style.height = "0px"; Dom.removeClass( el, "n_invisible" ); var animate = new YAHOO.util.Anim( el, { height: { to: height } }, 0.5, YAHOO.util.Easing.backOut ); animate.onComplete.subscribe( function() { el.style.height = "auto"; nw.scrollTo( el ); nw.effect.afterOpen(); }, this, true ) animate.animate(); }, /** * remove HTML element * @param {HTMLelement} el element to remove */ remove: function( el ) { el = Dom.get( el ); el.style.overflow = "hidden"; var animate = new YAHOO.util.Anim( el, { height: { to: 0 }, opacity: { to: 0 } }, 0.3, YAHOO.util.Easing.backOut ); animate.onComplete.subscribe( function() { el.parentNode.removeChild( el ); }, this, true ); animate.animate(); return true; } } /** * validation error handler functions * @namespace */ var errorHandlers = { /** * hides all error messages in a form * * @param {String || HTMLelement} id form or id of the form * @return {Boolean} true if succeed, false else */ hideAllErrorMsg: function( id ) { var form_el = Dom.get( id ); if ( !form_el ) { return false; } var form_elements = form_el.elements; for ( i_elements = 0; i_elements < form_elements.length; i_elements++ ) { this.hideErrorMsg( form_elements[i_elements], "field" ); } var block_msgs = Dom.getElementsByClassName( "n_fieldseterrortext", "span" ); Dom.addClass( block_msgs, "n_invisible" ); var bottom_msgs = Dom.getElementsByClassName( "n_bottomerrortext", "p" ); Dom.addClass( bottom_msgs, "n_invisible" ); var block_n_bottom_msgs = Dom.getElementsByClassName( "n_fieldseterrortext", "p" ); Dom.addClass( block_n_bottom_msgs, "n_invisible" ); var block_n_bottom_bottom_msgs = Dom.getElementsByClassName( "n_errormsg_row", "tr" ); Dom.addClass( block_n_bottom_bottom_msgs, "n_invisible" ); return true; }, /** * hides error message
* * @param {Object} id id of the field
* errormessage block's id is 'id'+errormsg
* errorsign block's id is 'id'+errorsign
* @param {Object} [type] * type of the error display "field" || "block"
* default is "field"
*/ hideErrorMsg: function( id, type ) { type = type || "field"; var el = Dom.get( id ); id = el.id; var is_number_validator = ( id.substring( id.length-2, id.length ) == "_1" ) ? true : false; if ( is_number_validator ) { id = id.substring( 0, id.length-2 ) } var is_date_validator = ( id.substring( id.length-5, id.length ) == "_year" ) ? true : false; if ( is_date_validator ) { id = id.substring( 0, id.length-5 ) } if ( type == "field" ) { var msg_fieldrow, msg_field; var sign_field; if ( Dom.get( id + "_errorsign" ) ) { sign_field = Dom.get( id + "_errorsign" ) Dom.addClass( sign_field, "n_invisible" ); } if ( Dom.get( id + "_errormsg" ) ) { msg_fieldrow = Dom.get( id + "_errormsg" ) msg_field = Dom.getElementsByClassName( "n_forma_errorMessage", "p", msg_fieldrow )[0]; if ( msg_field ) { msg_field.innerHTML = ""; } Dom.addClass( msg_fieldrow, "n_invisible" ); } } else if ( type == "block" ) { var block = Dom.getAncestorByClassName( el, "n_contentboxinlay" ); var right = Dom.getElementsByClassName( "n_fieldseterrortext", "*", block )[0]; right.innerHTML = ""; Dom.addClass( right, "n_invisible" ); return true; } }, highlightManager: function( field_id, type ) { this.field_id = field_id; this.type = type || "field"; this.errorfield_id = field_id + "_errormsg"; this.errorsign_id = field_id + "_errorsign"; this.init = function() { var errormsg_id = ""; var errorsign_id = ""; var element_to_check = ( Dom.get( field_id ) || Dom.get( field_id + "_year" ) ); if ( element_to_check ) { //ie - focus bug try { element_to_check.focus(); } catch( e ) { } } if ( this.type == "field" ) { errormsg_id = this.field_id + "_errormsg"; errormsg_id = Dom.getElementsByClassName( "n_forma_errorMessage", "p", errormsg_id )[0]; errorsign_id = this.field_id + "_errorsign"; } else if ( type == "block" ) { var block = Dom.getAncestorByClassName( this.field_id, "n_contentboxinlay" ); var right = Dom.getElementsByClassName( "n_fieldseterrortext", "*", block )[0]; errormsg_id = ""; errorsign_id = right; } else if ( type == "bottom" ) { errormsg_id = this.field_id + "_errormsg"; errorsign_id = ""; } else if ( type == "block_n_bottom" ) { errormsg_id = this.field_id + "_errormsg"; var block = Dom.getAncestorByClassName( this.field_id, "n_contentboxinlay" ); var right = Dom.getElementsByClassName( "n_fieldseterrortext", "*", block )[0]; errorsign_id = right; } var elements_to_animate = []; if ( errormsg_id != "" ) { if ( Dom.get( errormsg_id ) ) { //zoom hack if ( ie ) { var contentbox = Dom.getAncestorByClassName( Dom.get( errormsg_id ), "n_contentboxinlay" ); if ( contentbox ) { var orig_bgcolor = Dom.getStyle( contentbox, "background-color" ); Dom.setStyle( Dom.get( errormsg_id ), "background-color", orig_bgcolor ); } } elements_to_animate.push( errormsg_id ); } } if ( errorsign_id != "" ) { if ( !Dom.get( errormsg_id ) ) { //zoom hack if ( ie ) { var contentbox = Dom.getAncestorByClassName( Dom.get( errorsign_id ), "n_contentboxinlay" ); if ( contentbox ) { var orig_bgcolor = Dom.getStyle( contentbox, "background-color" ); Dom.setStyle( Dom.get( errorsign_id ), "background-color", orig_bgcolor ); } } elements_to_animate.push( errorsign_id ); } } if ( elements_to_animate.length != 0 ) { this.start( elements_to_animate ); } if ( errorsign_id != "" ) { if ( Dom.get( errorsign_id ) ) { nw.scrollTo( errorsign_id ); return true; } } if ( errormsg_id != "" ) { if ( Dom.get( errormsg_id ) ) { nw.scrollTo( errormsg_id ); return true; } } } this.start = function( anim_el ) { var counter = 1; var fade_out_anim = new YAHOO.util.Anim( anim_el, { opacity: { to: 0 } }, 0.3 ); fade_out_anim.onComplete.subscribe( function() { fade_in_anim.animate() }, this, true ); var fade_in_anim = new YAHOO.util.Anim( anim_el, { opacity: { to: 1 } }, 0.3 ); fade_in_anim.onComplete.subscribe( function() { if ( counter < 3 ) { fade_out_anim.animate(); } counter++; }, this, true ); fade_out_anim.animate(); }; }, /** * shows error message
* * @param {Object} id id of the field
* errormessage block's id is 'id'+errormsg
* errorsign block's id is 'id'+errorsign * @param {Object} msg * text of the error message * @param {Object} [type] * type of the error display "field" || "block"
* default is "field"
*/ showErrorMsg: function( id, msg, type ) { type = type || "field"; var el = Dom.get( id ) || Dom.get( id+"_1" ) || Dom.get( id+"_year" ) || Dom.get( id+"_field" ); if ( !el ) { return false; } if ( type == "field" ) { var msg_fieldrow, msg_field; var sign_field; if ( eval( "Dom.get( '" + id + "_errormsg' ) != undefined " ) ) { msg_fieldrow = eval( "Dom.get( '" + id + "_errormsg' )"); msg_field = Dom.getElementsByClassName( "n_forma_errorMessage", "p", msg_fieldrow )[0]; if ( msg_field && msg ) { msg_field.innerHTML = msg; } Dom.removeClass( msg_fieldrow, "n_invisible" ); } if ( eval( "Dom.get( '" + id + "_errorsign' ) != undefined " ) ) { sign_field = eval ( "Dom.get( '"+id+"_errorsign' )" ); Dom.replaceClass( sign_field, "n_validinputtext", "n_invalidinputtext" ); sign_field.innerHTML = __( "hiba" ); Dom.removeClass( sign_field, "n_invisible" ); } return true; } else if ( type == "block" ) { var block = Dom.getAncestorByClassName( el, "n_contentboxinlay" ); var right = Dom.getElementsByClassName( "n_fieldseterrortext", "*", block )[0]; right.innerHTML = msg; Dom.removeClass( right, "n_invisible" ); return true; } else if ( type == "bottom" ) { var msg_field; if ( eval( "Dom.get( '" + id + "_errormsg' ) != undefined " ) ) { msg_field = Dom.get( id + "_errormsg" ); msg_field.innerHTML = msg; Dom.removeClass( msg_field, "n_invisible" ); } } else if ( type == "block_n_bottom" ) { var msg_field, msg_field_td; if ( eval( "Dom.get( '"+id+"_errormsg' ) != undefined " ) ) { msg_field = Dom.get( id+"_errormsg" ); msg_field_td = Dom.getElementsByClassName( "n_forma_errorMessage", "*", msg_field )[0]; msg_field_td.innerHTML = msg; Dom.removeClass( msg_field, "n_invisible" ); } var block = Dom.getAncestorByClassName( el, "n_contentboxinlay" ); var right = Dom.getElementsByClassName( "n_fieldseterrortext", "*", block )[0]; right.innerHTML = "Hiba"; Dom.removeClass( right, "n_invisible" ); return true; } }, /** * shows true feedback on field elements * * @param {String || HTMLelement} id form element or id of the form element * @return {Boolean} true if succeed false else */ showTrueFeedback: function( id ) { var el = Dom.get( id ); if ( !el ) { return false; } id = el.id; var is_number_validator = ( id.substring( id.length-2, id.length ) == "_1" ) ? true : false; if ( is_number_validator ) { id = id.substring( 0, id.length-2 ) } var is_date_validator = ( id.substring( id.length-5, id.length ) == "_year" ) ? true : false; if ( is_date_validator ) { id = id.substring( 0, id.length-5 ) } if ( el.type == "submit" ) { return false; } var msg_fieldrow, msg_field; var sign_field; if ( eval( "Dom.get( '"+id+"_errorsign' ) != undefined " ) ) { sign_field = eval ( "Dom.get( '"+id+"_errorsign' )" ); Dom.replaceClass( sign_field, "n_invalidinputtext", "n_validinputtext" ); sign_field.innerHTML = __( "rendben" ); Dom.removeClass( sign_field, "n_invisible" ); } if ( eval( "Dom.get( '"+id+"_errormsg' ) != undefined " ) ) { msg_fieldrow = eval( "Dom.get( '"+id+"_errormsg' )"); msg_field = Dom.getElementsByClassName( "n_forma_errorMessage", "p", msg_fieldrow )[0]; if ( msg_field ) { msg_field.innerHTML = ""; } Dom.addClass( msg_fieldrow, "n_invisible" ); } return true; } } /** * indicators * @namespace */ var indicator = { /** * object for block indicator * @type HTMLelement */ indicatorY: null, /** * iframe tag behind the indicator tag * @type HTMLelement */ indicatorYiframe: null, /** * hides indicator */ hideIndicator: function() { Dom.setStyle( this.indicatorY, "top", "0px" ); Dom.setStyle( this.indicatorY, "left", "0px" ); Dom.setStyle( this.indicatorY, "width", "0px" ); Dom.setStyle( this.indicatorY, "height", "0px" ); Dom.setStyle( this.indicatorYiframe, "top", "0px" ); Dom.setStyle( this.indicatorYiframe, "left", "0px" ); Dom.setStyle( this.indicatorYiframe, "width", "0px" ); Dom.setStyle( this.indicatorYiframe, "height", "0px" ); }, /** * sets up indicator */ setIndicator: function() { this.indicatorY = document.createElement( "DIV" ); this.indicatorYiframe = document.createElement( "IFRAME" ); var body = document.getElementsByTagName( "body" )[0]; Dom.setStyle( this.indicatorY, "position", "absolute" ); Dom.setStyle( this.indicatorY, "top", "0px" ); Dom.setStyle( this.indicatorY, "left", "0px" ); Dom.setStyle( this.indicatorY, "width", "0px" ); Dom.setStyle( this.indicatorY, "height", "0px" ); Dom.setStyle( this.indicatorY, "opacity", "0.6" ); Dom.setStyle( this.indicatorY, "z-index", "100000" ); Dom.setStyle( this.indicatorYiframe, "position", "absolute" ); Dom.setStyle( this.indicatorYiframe, "border", "0px" ); Dom.setStyle( this.indicatorYiframe, "top", "0px" ); Dom.setStyle( this.indicatorYiframe, "left", "0px" ); Dom.setStyle( this.indicatorYiframe, "width", "0px" ); Dom.setStyle( this.indicatorYiframe, "height", "0px" ); if ( ie ) { Dom.setStyle( this.indicatorYiframe, "visibility", "hidden" ); } body.appendChild( this.indicatorY ); body.appendChild( this.indicatorYiframe ); }, handler: function( el ) { this.el = Dom.get( el ); this.indicator = null; this.iframe = null; this.show = function() { if ( this.indicator ) { this.hide(); } this.indicator = document.createElement( "div" ); this.iframe = document.createElement( "iframe" ); Dom.setStyle( this.indicator, "position", "absolute" ); Dom.setStyle( this.indicator, "top", "0px" ); Dom.setStyle( this.indicator, "left", "0px" ); Dom.setStyle( this.indicator, "width", "0px" ); Dom.setStyle( this.indicator, "height", "0px" ); Dom.setStyle( this.indicator, "opacity", "0.6" ); Dom.setStyle( this.indicator, "z-index", "100000" ); Dom.setStyle( this.iframe, "position", "absolute" ); Dom.setStyle( this.iframe, "border", "0px" ); Dom.setStyle( this.iframe, "top", "0px" ); Dom.setStyle( this.iframe, "left", "0px" ); Dom.setStyle( this.iframe, "width", "0px" ); Dom.setStyle( this.iframe, "height", "0px" ); if ( ie ) { Dom.setStyle( this.iframe, "visibility", "hidden" ); } document.body.appendChild( this.indicator ); document.body.appendChild( this.iframe ); this.indicator.className="indicatorY"; if ( Dom.hasClass( this.el, "n_invisible" ) ) { return true; } var region = YAHOO.util.Region.getRegion( this.el ); var newHeight = region.bottom-region.top; var newWidth = region.right-region.left; var newXY = Dom.getXY( this.el ) Dom.setXY( this.indicator, newXY ); Dom.setStyle( this.indicator, "width", newWidth+"px" ); Dom.setStyle( this.indicator, "height", newHeight+"px" ); Dom.setXY( this.iframe, newXY ); Dom.setStyle( this.iframe, "width", newWidth+"px" ); Dom.setStyle( this.iframe, "height", newHeight+"px" ); return true; }; this.hide = function() { if ( !this.indicator ) { return false; } this.indicator.parentNode.removeChild( this.indicator ); this.iframe.parentNode.removeChild( this.iframe ); this.indicator = null; this.iframe = null; return true; } }, /** * shows indicator * * @param {Object} id id of hte block the indicator display above */ showIndicator: function( id ) { if ( !this.indicatorY ) { this.setIndicator(); } this.indicatorY.className=""; this.indicatorY.className="indicatorY"; var el = Dom.get( id ); var body = document.getElementsByTagName( "body" )[0]; var region = YAHOO.util.Region.getRegion( el ); var newHeight = region.bottom-region.top; var newWidth = region.right-region.left; var newXY = Dom.getXY( el ) Dom.setXY( this.indicatorY, newXY ); Dom.setStyle( this.indicatorY, "width", newWidth+"px" ); Dom.setStyle( this.indicatorY, "height", newHeight+"px" ); Dom.setXY( this.indicatorYiframe, newXY ); Dom.setStyle( this.indicatorYiframe, "width", newWidth+"px" ); Dom.setStyle( this.indicatorYiframe, "height", newHeight+"px" ); } } var header = { handler_class: null, initClass: function( id ) { if ( this.handler_class ) { return true; } else { this.handler_class = new login_class(); this.handler_class.construct(); } return true;s }, toggleLoginBox: function() { this.initClass(); this.handler_class.toggleLoginBox(); return true; }, hideLoginBox: function() { this.handler_class.hideLoginBox(); return true; }, showPwdReminderForm: function() { this.handler_class.showPwdReminderForm(); return true; }, onLoginKeyDown: function( e, input_el ) { if ( !ie ) { return true; } e = Event.getEvent( e ); var key_code = Event.getCharCode( event ); if ( key_code == 13 ) { Event.stopEvent( e ); input_el.form.onsubmit(); return false; } }, submitLogin: function( form_el ) { this.handler_class.submitLogin( form_el ); return true; }, submitReminder: function( form_el ) { this.handler_class.submitReminder( form_el ); return true; } } /** * singleton for ajax lightbox * @namespace */ var ajax_lightbox = { /** * ajax dialog */ ajax_dialog: null, ajax_wrap: null, dialog_config: null, /** * hides ajax dialog */ hideAjaxDialog: function() { if ( this.ajax_dialog ) { this.ajax_dialog.destroy(); this.ajax_dialog = null; } }, /** * opens ajax dialog * @return {Boolean} true if succeed, false else */ onReady: function() { }, showAjaxDialog: function( url, config ) { this.dialog_config = config; if ( !this.ajax_wrap ) { this.ajax_wrap = Dom.get( "ajax_wrap" ); } this.hideAjaxDialog(); nw.openWaiting(); nw.ajax( url, this.showCallback ); return true; }, showCallback: { success:function( o ) { nw.hideWaiting(); try { var response = JSON.parse( o.responseText ); if ( response.type == 0 ) { nw.alert( response.message ); return false; } } catch ( e ) { } ajax_lightbox.ajax_wrap.innerHTML = o.responseText; var dialog = ajax_lightbox.ajax_wrap.getElementsByTagName( "div" )[0]; if ( !dialog ) { return false; } if ( dialog.length == 0 ) { return false; } dialog.id = "ajax_dialog"; var width; if ( dialog.style.width ) { width = dialog.style.width; } else { width = "auto"; } var default_config = { width: width, fixedcenter: true, close: false, draggable: true, zindex: 4, modal: true, visible: false, iframe: true } for ( i in ajax_lightbox.dialog_config ) { default_config[ i ] = ajax_lightbox.dialog_config[i]; } var config = default_config; Dom.removeClass( dialog, "n_invisible" ); ajax_lightbox.ajax_dialog = new YAHOO.widget.Panel("ajax_dialog", config ); ajax_lightbox.ajax_dialog.showEvent.subscribe( function() { var dialog_iframe = ajax_lightbox.ajax_dialog.iframe; Dom.addClass( dialog_iframe, "n_lightboxiframe" ); if ( linux ) { dialog_iframe.style.visibility = "visible"; } } ); ajax_lightbox.ajax_dialog.render(); nw.show( ajax_lightbox.ajax_dialog.element ); ajax_lightbox.ajax_dialog.show(); nw.setLightboxOrder(); ajax_lightbox.onReady(); return true; }, failure: function() { nw.hideWaiting(); } } } /** * singleton for alert lightbox * @namespace */ var alert_lightbox = { /** * alert dialog */ alert_dialog: null, /** * hides alert dialog */ hideAlertDialog: function() { this.alert_dialog.hide(); if ( this.alert_dialog ) { nw.hide( this.alert_dialog.element ); } }, /** * sets up alert_dialog */ setAlertDialog: function() { if ( this.alert_dialog ) { return false; } this.alert_dialog = new YAHOO.widget.Panel("alert_dialog", { width:"278px", fixedcenter:true, close:false, draggable:false, zindex:4, modal:true, visible:false, iframe: true } ); Dom.removeClass( Dom.get( "alert_dialog" ), "n_invisible" ); alert_lightbox.alert_dialog.showEvent.subscribe( function() { var dialog_iframe = alert_lightbox.alert_dialog.iframe; Dom.addClass( dialog_iframe, "n_lightboxiframe" ); if ( linux ) { dialog_iframe.style.visibility = "visible"; } } ); this.alert_dialog.render(); return true; }, /** * opens alert dialog * @param {String} text alert text to show * * @return {Boolean} true if succeed, false else */ showAlertDialog: function( text ) { if ( Dom.get( "alert_dialog" ) ) { if ( !this.alert_dialog ) { this.setAlertDialog(); } var alert_content = Dom.get( "alert_content" ); alert_content.innerHTML = text; this.alert_dialog.hide(); nw.show( this.alert_dialog.element ); this.alert_dialog.show(); nw.setLightboxOrder(); return true; } return false; } } /** * singleton for confirm lightbox * @namespace */ var confirm_lightbox = { /** * confirm dialog */ confirm_dialog: null, callbackYes: function() { }, callbackYesDefault: function() { this.hideConfirmDialog(); }, callbackNo: function() { this.hideConfirmDialog(); }, handleConfirm: function() { this.callbackYes(); confirm_lightbox.hideConfirmDialog(); }, /** * hides confirm dialog */ hideConfirmDialog: function() { this.confirm_dialog.hide(); if ( this.confirm_dialog ) { nw.hide( this.confirm_dialog.element ); } }, /** * sets up confirm_dialog */ setConfirmDialog: function() { if ( this.confirm_dialog ) { return false; } this.confirm_dialog = new YAHOO.widget.Panel("confirm_dialog", { width:"278px", fixedcenter:true, close:false, draggable:false, zindex:4, modal:true, visible:false, iframe: true } ); confirm_lightbox.confirm_dialog.showEvent.subscribe( function() { var dialog_iframe = confirm_lightbox.confirm_dialog.iframe; Dom.addClass( dialog_iframe, "n_lightboxiframe" ); if ( linux ) { dialog_iframe.style.visibility = "visible"; } } ); Dom.removeClass( Dom.get( "confirm_dialog" ), "n_invisible" ); this.confirm_dialog.render(); this.button_yes = Dom.get("confirm_yes_btn"); return true; }, /** * opens confirm dialog * @param {String} text alert text to show * * @return {Boolean} true if succeed, false else */ showConfirmDialog: function( text, handleYes ) { if ( Dom.get( "confirm_dialog" ) ) { if ( !this.confirm_dialog ) { this.setConfirmDialog(); } var confirm_content = Dom.get( "confirm_content" ); confirm_content.innerHTML = text; if ( handleYes ) { this.callbackYes = handleYes; } else { this.callbackYes = this.callbackYesDefault; } this.confirm_dialog.hide(); nw.show( this.confirm_dialog.element ); this.confirm_dialog.show(); nw.setLightboxOrder(); return true; } return false; } } /** * singleton for custom lightbox * @namespace */ var custom_lightbox = { act_dialog: null, /** * array contains instantiated custom dialogs */ custom_dialogs : [], iframe: null, /** * constructor for setting custom dialog * @param {Object} id id of the markup code * @param {Object} config config properties for setting custom dialog */ customDialog : function( id, config ) { var width; if ( Dom.get( id ).style.width ) { width = Dom.get( id ).style.width; } else { width = "auto"; } var default_config = { width: width, fixedcenter: true, close: false, draggable: true, zindex: 4, modal: true, visible: false, iframe: true } for ( i in config ) { default_config[ i ] = config[i]; } var config = default_config; var custom_dialog = new YAHOO.widget.Panel( id, config ); custom_lightbox.custom_dialogs.push( custom_dialog ); Dom.removeClass( Dom.get( id ), "n_invisible" ); custom_dialog.showEvent.subscribe( function() { var dialog_iframe = custom_dialog.iframe; Dom.addClass( dialog_iframe, "n_lightboxiframe" ); if ( linux ) { dialog_iframe.style.visibility = "visible"; } } ); custom_dialog.render(); return custom_dialog; }, /** * hides custom dialog */ hideCustomDialog: function( id ) { for ( i_custom = 0; i_custom < this.custom_dialogs.length; i_custom++ ) { if ( this.custom_dialogs[i_custom].id == id ) { this.custom_dialogs[i_custom].hide(); } } if ( this.act_dialog ) { nw.hide( this.act_dialog.element ); } }, /** * opens custom dialog * * @param {Object} id id of the markup code * @param {Object} config config properties for setting custom dialog * @return {Boolean} true if succeed, false else * */ showCustomDialog: function( id, config ) { if ( Dom.get( id ) ) { var act_dialog = null; for ( i_custom = 0; i_custom < this.custom_dialogs.length; i_custom++ ) { if ( this.custom_dialogs[i_custom].id == id ) { act_dialog = this.custom_dialogs[i_custom]; } } if ( this.custom_dialogs.length == 0 || !act_dialog ) { if ( Dom.get( id ).parentNode != document.body ) { document.body.appendChild( Dom.get( id ) ); } act_dialog = new this.customDialog( id, config ); } this.act_dialog = act_dialog; act_dialog.hide(); nw.show( this.act_dialog.element ); act_dialog.show(); nw.setLightboxOrder(); return true; } return false; } } /** * singleton for waiting lightbox * @namespace */ var waiting_lightbox = { /** * waiting dialog */ waiting_dialog: null, /** * hides waiting dialog */ hideWaitingDialog: function() { if ( !this.waiting_dialog ) { return false; } this.waiting_dialog.hide(); if ( this.waiting_dialog ) { nw.hide( this.waiting_dialog.element ); } }, /** * sets up waiting_dialog */ setWaitingDialog: function() { if ( this.waiting_dialog ) { return false; } this.waiting_dialog = new YAHOO.widget.Panel("waiting_dialog", { width:"240px", fixedcenter:true, close:false, draggable:true, zindex:4, modal:true, visible:false, iframe: true } ); waiting_lightbox.waiting_dialog.showEvent.subscribe( function() { var dialog_iframe = waiting_lightbox.waiting_dialog.iframe; Dom.addClass( dialog_iframe, "n_lightboxiframe" ); if ( linux ) { dialog_iframe.style.visibility = "visible"; } } ); Dom.removeClass( Dom.get( "waiting_dialog" ), "n_invisible" ); this.waiting_dialog.render(); return true; }, /** * opens waiting dialog * @return {Boolean} true if succeed, false else */ showWaitingDialog: function() { if ( Dom.get( "waiting_dialog" ) ) { if ( !this.waiting_dialog ) { this.setWaitingDialog(); } this.waiting_dialog.hide(); nw.show( this.waiting_dialog.element ); this.waiting_dialog.show(); nw.setLightboxOrder(); return true; } return false; } } /** * rating stars * @namespace */ var rating_widget = { ratings: [], last_is_half: false, /** * initial methods and properties for rating stars * */ _init: function() { var rating_containers = Dom.getElementsByClassName( "n_ratingcontainer_big", "p" ); if ( rating_containers.length == 0 ) { return false; } for ( var i_rating = 0; i_rating < rating_containers.length; i_rating++ ) { var stars = Dom.getElementsByClassName( "n_ratingstar", "a", rating_containers[i_rating] ); if ( Dom.hasClass( stars[0], "n_passivestar" ) ) { continue; } this.ratings.push( new rating( rating_containers[i_rating] ) ); } } } function rating( container ) { this.container = container; this.mouse_in_container = false; this.stars = null; this.current_rating = 0; this.url = ""; this.is_during_waiting = false; this._init(); } rating.prototype = { before_image_url: null, after_image_url: null, half_image_url: null, during_image_url: null, _init: function() { this.before_image_url = static_url + "/images/frontend/n_ratingstarbefore_19.png"; this.after_image_url = static_url + "/images/frontend/n_ratingstarafter_19.png"; this.half_image_url = static_url + "/images/frontend/n_ratingstarhalf_19.png"; this.during_image_url = static_url + "/images/frontend/n_ratingstarduring_19.png"; this.mouse_in_container = false; this.stars = Dom.getElementsByClassName( "n_ratingstar", "a", this.container ); this.current_rating = Dom.getElementsByClassName( "n_afterrating", "a", this.container ).length; var url_container = Dom.getPreviousSibling( this.container ); this.url = url_container.href; this.last_star_is_half = false; for ( i_star = 0; i_star < this.stars.length; i_star++ ) { if ( Dom.hasClass( this.stars[i_star], "n_halfrating" ) ) { this.last_star_is_half = true; } Event.on( this.stars[i_star], "mouseover", this.mouseOver, null, this ); Event.on( this.stars[i_star], "mouseout", this.mouseOut, null, this ); Event.on( this.stars[i_star], "click", this.mouseClick, null, this ); } if ( this.last_star_is_half ) { this.current_rating++; } this.sendVoteCallback.scope = this; }, fillEmptyStars: function() { for ( i_star = 1; i_star <= this.stars.length; i_star++ ) { var act_star = this.stars[i_star - 1]; Dom.removeClass( act_star, "n_afterrating" ); Dom.addClass( act_star, "n_beforerating" ); } }, fillStarsOnHover: function( num ) { for ( i_star = 1; i_star <= this.stars.length; i_star++ ) { var act_star = this.stars[i_star - 1]; if ( i_star <= num ) { Dom.addClass( act_star, "n_duringrating" ); Dom.removeClass( act_star, "n_halfrating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.during_image_url + "', sizingMethod='crop');"; } } else if ( i_star <= this.current_rating ) { if ( i_star == this.current_rating && this.last_star_is_half ) { Dom.removeClass( act_star, "n_afterrating" ); Dom.addClass( act_star, "n_halfrating" ); Dom.removeClass( act_star, "n_duringrating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.half_image_url + "', sizingMethod='crop');"; } } else { Dom.addClass( act_star, "n_afterrating" ); Dom.removeClass( act_star, "n_halfrating" ); Dom.removeClass( act_star, "n_duringrating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.after_image_url + "', sizingMethod='crop');"; } } } else { if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.before_image_url + "', sizingMethod='crop');"; } Dom.removeClass( act_star, "n_duringrating" ); } } }, fillFirstNStars: function( num, set_half ) { for ( i_star = 1; i_star <= this.stars.length; i_star++ ) { var act_star = this.stars[i_star - 1]; Dom.removeClass( act_star, "n_duringrating" ); if ( i_star < num ) { Dom.addClass( act_star, "n_afterrating" ); Dom.removeClass( act_star, "n_beforerating" ); Dom.removeClass( act_star, "n_halfrating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.after_image_url + "', sizingMethod='crop');"; } } else if ( i_star == num ) { if ( this.last_star_is_half ) { if ( set_half ) { Dom.addClass( act_star, "n_halfrating" ); Dom.addClass( act_star, "n_afterrating" ); Dom.removeClass( act_star, "n_beforerating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.half_image_url + "', sizingMethod='crop');"; } } else { Dom.removeClass( act_star, "n_halfrating" ); Dom.addClass( act_star, "n_afterrating" ); Dom.removeClass( act_star, "n_beforerating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.after_image_url + "', sizingMethod='crop');"; } } } else { Dom.removeClass( act_star, "n_halfrating" ); Dom.addClass( act_star, "n_afterrating" ); Dom.removeClass( act_star, "n_beforerating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.after_image_url + "', sizingMethod='crop');"; } } } else { Dom.removeClass( act_star, "n_halfrating" ); Dom.removeClass( act_star, "n_afterrating" ); Dom.addClass( act_star, "n_beforerating" ); if ( ie6 ) { act_star.style.backgroundImage = "none"; act_star.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.before_image_url + "', sizingMethod='crop');"; } } } return true; }, getNumberInPlace: function( star ) { for ( i_star = 1; i_star <= this.stars.length; i_star++ ) { if ( star == this.stars[i_star - 1] ) { return i_star; } } }, mouseClick: function( e ) { if ( this.is_during_waiting ) { return false; } var target = Event.getTarget( e ); var vote_num = this.getNumberInPlace( target ); nw.openWaiting(); this.is_during_waiting = true; nw.ajax( target.href, this.sendVoteCallback, "post", "vote_num=" + vote_num ); }, mouseOver: function( e ) { if ( this.is_during_waiting ) { return false; } var target = Event.getTarget( e ); var n = this.getNumberInPlace( target ); //this.fillFirstNStars( n ); this.fillStarsOnHover( n ); }, mouseOut: function( e ) { if ( this.is_during_waiting ) { return false; } var target = Event.getTarget( e ); var related_target = Event.getRelatedTarget( e ); var out_from_box = true; if ( Dom.hasClass( related_target, "n_ratingstar" ) ) { out_from_box = false; } if ( out_from_box ) { this.fillFirstNStars( this.current_rating, true ); } return false; }, sendVoteCallback: { success: function( o ) { nw.hideWaiting(); this.new_content = o.responseText; var obj = this; var reInit = function() { obj.is_during_waiting = false; obj.container.innerHTML = obj.new_content; png.hackEntire(); obj._init(); } this.setStarsWaiting(); setTimeout( reInit, 3000 ); }, failure: function() { this.is_during_waiting = false; nw.hideWaiting(); } }, setStarsWaiting: function() { for ( i_star = 0; i_star < this.stars.length; i_star++ ) { Dom.removeClass( this.stars[i_star], "n_halfrating" ); Dom.addClass( this.stars[i_star], "n_duringrating" ); if ( ie6 ) { this.stars[i_star].style.backgroundImage = "none"; this.stars[i_star].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.during_image_url + "', sizingMethod='crop');"; } } } } var search_box = { changeTab: function( num, is_club ) { var active_class; if ( is_club ) { active_class = "n_activetab"; } else { active_class = "n_compactsearchtab_active"; } if ( num == 1 ) { Dom.addClass( Dom.get("n_searchtableft"), active_class ); Dom.removeClass( Dom.get("n_searchtabright"), active_class ); Dom.removeClass( Dom.get("n_leftcompactsearchboxwrap"), "n_invisible" ); Dom.addClass( Dom.get("n_rightcompactsearchboxwrap"), "n_invisible" ); } else if ( num == 2 ) { Dom.addClass( Dom.get("n_searchtabright"), active_class ); Dom.removeClass( Dom.get("n_searchtableft"), active_class ); Dom.removeClass( Dom.get("n_rightcompactsearchboxwrap"), "n_invisible" ); Dom.addClass( Dom.get("n_leftcompactsearchboxwrap"), "n_invisible" ); } }, submit: function( form_el ) { var input_el = Dom.getElementsByClassName( "n_compactsearchinput", "input", form_el )[0]; var inputs = form_el.getElementsByTagName( "input" ); var search_input; for( i_input = 0; i_input < inputs.length; i_input++ ) { var act_input = inputs[i_input]; if ( act_input.type == "text" ) { search_input = act_input; break; } } if ( YAHOO.lang.trim( search_input.value ) == "" ) { search_input.focus(); return false; } return true; } } var n_join = { join: function( url ) { nw.openWaiting(); nw.ajax( url, this.joinCallback ); }, joinCallback: { success: function( o ) { nw.hideWaiting(); indicator.hideIndicator(); try { eval( "var error_response = " + o.getResponseHeader['Errormsg'] ); } catch(e) { } if ( error_response ) { nw.alert( error_response ); return false; } try { eval( "var success_response = " + o.getResponseHeader['Successmsg'] ); } catch(e) { } if ( success_response ) { if ( n_permission.wait_with_reload ) { n_permission_lb.succeed( success_response ); return true; } nw.alert( success_response ); alert_lightbox.hideAlertDialog = function() { indicator.showIndicator( "alert_dialog" ); var hash_position = location.href.indexOf( "#" ); if ( hash_position == -1 ) { location.reload(); } else { url = location.href.substring( 0, hash_position ); location.href = url; } return true; } return false; } try { var success_json_response = JSON.parse( o.responseText ); if ( success_json_response.type == 1 ) { if ( n_permission.wait_with_reload ) { n_permission_lb.succeed( success_json_response.message ); return true; } nw.alert( success_json_response.message ); alert_lightbox.hideAlertDialog = function() { indicator.showIndicator( "alert_dialog" ); var hash_position = location.href.indexOf( "#" ); if ( hash_position == -1 ) { location.reload(); } else { url = location.href.substring( 0, hash_position ); location.href = url; } return true; } return false; } } catch ( e ) { } ajax_lightbox.onReady = function() { ajax_lightbox.ajax_dialog.center(); var mask_height = parseInt( Dom.getStyle( Dom.get( "ajax_dialog_mask" ), "height" ) ); var document_height = Dom.getDocumentHeight(); if ( document_height > mask_height ) { Dom.setStyle( Dom.get( "ajax_dialog_mask" ), "height", ( document_height + 30 ) + "px" ) } ajax_lightbox.onReady = function(){} } ajax_lightbox.dialog_config = { fixedcenter: false, constraintoviewport: true } ajax_lightbox.ajax_wrap = Dom.get( "ajax_wrap" ); ajax_lightbox.showCallback.success( o ); }, failure: function() { nw.hideWaiting(); indicator.hideIndicator(); } } } n_join.lightbox = { hide: function() { nw.hideLightAjax(); }, resetErrorMsgs: function() { var errormsgs = Dom.getElementsByClassName( "n_formerrormessage", "p", Dom.get( "jsForm_clubjoin_question" ) ); for( i_errormsg = 0; i_errormsg < errormsgs.length; i_errormsg++ ) { var act_errormsg = errormsgs[i_errormsg]; Dom.addClass( act_errormsg, "n_invisible" ); } return true; }, submit: function( form_el ) { this.resetErrorMsgs(); if ( !this.validate() ) { return false; } indicator.showIndicator( "ajax_dialog" ); nw.ajaxForm( form_el, n_join.joinCallback ); }, validate: function() { var errors = []; var questions = Dom.getElementsByClassName( "n_joinquestionwrap", "div", Dom.get( "jsForm_clubjoin_question" ) ); for( i_question = 0; i_question < questions.length; i_question++ ) { var act_question = questions[i_question]; var error_id = act_question.id + "_errormsg"; var inputs = act_question.getElementsByTagName( "input" ); if ( inputs.length == 0 ) { var area = act_question.getElementsByTagName( "textarea" )[0]; if ( YAHOO.lang.trim( area.value ).length < 2 || YAHOO.lang.trim( area.value ).length > 1000 ) { errors.push( error_id ); } break; } switch( inputs[0].type ) { case "checkbox": case "radio": var is_checked = false; for( i_cb = 0; i_cb < inputs.length; i_cb++ ) { var act_cb = inputs[i_cb]; if ( act_cb.checked ) { is_checked = true; break; } } if ( !is_checked ) { errors.push( error_id ); } break; case "text": if ( YAHOO.lang.trim( inputs[0].value ).length < 2 || YAHOO.lang.trim( inputs[0].value ).length > 1000 ) { errors.push( error_id ); } break; default: break; } } if ( errors.length == 0 ) { return true; } else { for( i_error = 0; i_error < errors.length; i_error++ ) { var act_error = errors[i_error]; Dom.removeClass( Dom.get( act_error ), "n_invisible" ); } return false; } } } var n_flash = { makeAllTransparent: function() { var embeds = document.getElementsByTagName( "embed" ); for( i_embed = 0; i_embed < embeds.length; i_embed++ ) { var act_embed = embeds[i_embed]; new this.setEmbed( act_embed, act_embed.parentNode ); } var objects = document.getElementsByTagName( "object" ); for( i_object = 0; i_object < objects.length; i_object++ ) { var act_object = objects[i_object]; new this.setObject( act_object ); } return true; }, setEmbed: function( embed, embed_parent ) { var embed_str = embed_parent.innerHTML; if ( embed_str.indexOf( "wmode" ) != -1 && embed_str.indexOf( "transparent" ) != -1 ) { return true; } embed_str = embed_str.replace( "