/* RSence * Copyright 2009 Riassence Inc. * http://riassence.com/ * * You should have received a copy of the GNU General Public License along * with this software package. If not, contact licensing@riassence.com */ /*** = Description ** This application registers url responders to hide/show ** certain views automatically whenever the anchor ** part of the url is changed. ** ** It is bound to the server HValue instance ** +msg.session[:main][:location_href]+ by ** the 'main' plugin. By default it runs with ** a client-side-only HValue instance until then. ** ***/ //var//RSence.COMM COMM.URLResponder = HApplication.extend({ constructor: function(){ this.urlMatchers = []; this.urlCallBacks = []; this.defaultCallBacks = []; this.prevCallBacks = []; this.prevMatchStrs = []; this.base(1, 'URLResponder'); this.value = 0; }, // sets the view to show when there is // no matches (like a virtual 404) setDefaultResponder: function(_callBack){ this.defaultCallBacks = [ _callBack ]; this.refresh(); }, addDefaultResponder: function(_callBack){ this.defaultCallBacks.push( _callBack ); this.refresh(); }, delDefaultResponder: function(_callBack){ this.defaultCallBacks.splice(this.defaultCallbacks.indexOf(_callBack),1); this.refresh(); }, // Removes responder // - matchStr is an url that the callBack will // respond to // - callBack is the component registered delResponder: function(_matchStr,_callBack){ _callBack.hide(); if(this.prevCallBacks.indexOf(_callBack) !== -1){ this.prevCallBacks.splice(this.prevCallBacks.indexOf(_callBack),1); this.prevMatchStrs.splice(this.prevMatchStrs.indexOf(_matchStr),1); } var i=0, _urlMatch, _urlCallBack; for(;i