[js] add a selector string escaping function
will help use id strings in jquery selector expressions, e.g:
"foo.[subject]:42" -> "foo\.\[subject\]\:42"
Related to #3154531.
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr## This file is part of CubicWeb.## CubicWeb is free software: you can redistribute it and/or modify it under the# terms of the GNU Lesser General Public License as published by the Free# Software Foundation, either version 2.1 of the License, or (at your option)# any later version.## CubicWeb 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 Lesser General Public License for more# details.## You should have received a copy of the GNU Lesser General Public License along# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.fromyams.buildobjsimport(EntityType,RelationType,RelationDefinition,SubjectRelation,RichString,String,Int,Float,Boolean,Datetime,TZDatetime,Bytes)fromyams.constraintsimportSizeConstraintfromcubicweb.schemaimport(WorkflowableEntityType,RQLConstraint,RQLUniqueConstraint,ERQLExpression,RRQLExpression)fromyams.buildobjsimportmake_typeBabarTestType=make_type('BabarTestType')classAffaire(WorkflowableEntityType):__permissions__={'read':('managers',ERQLExpression('X owned_by U'),ERQLExpression('X concerne S?, S owned_by U')),'add':('managers',ERQLExpression('X concerne S, S owned_by U')),'update':('managers','owners',ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')),'delete':('managers','owners',ERQLExpression('X concerne S, S owned_by U')),}ref=String(fulltextindexed=True,indexed=True,constraints=[SizeConstraint(16)])sujet=String(fulltextindexed=True,constraints=[SizeConstraint(256)])descr=RichString(fulltextindexed=True,description=_('more detailed description'))duration=Int()invoiced=Float()opt_attr=Bytes()depends_on=SubjectRelation('Affaire')require_permission=SubjectRelation('CWPermission')concerne=SubjectRelation(('Societe','Note'))todo_by=SubjectRelation('Personne',cardinality='?*')documented_by=SubjectRelation('Card')classSociete(EntityType):__unique_together__=[('nom','type','cp')]__permissions__={'read':('managers','users','guests'),'update':('managers','owners',ERQLExpression('U login L, X nom L')),'delete':('managers','owners',ERQLExpression('U login L, X nom L')),'add':('managers','users',)}nom=String(maxsize=64,fulltextindexed=True)web=String(maxsize=128)type=String(maxsize=128)# attribute in common with Notetel=Int()fax=Int()rncs=String(maxsize=128)ad1=String(maxsize=128)ad2=String(maxsize=128)ad3=String(maxsize=128)cp=String(maxsize=12)ville=String(maxsize=32)classDivision(Societe):__specializes_schema__=TrueclassSubDivision(Division):__specializes_schema__=Trueclasstravaille_subdivision(RelationDefinition):subject='Personne'object='SubDivision'fromcubicweb.schemas.baseimportCWUserCWUser.get_relations('login').next().fulltextindexed=TrueclassNote(WorkflowableEntityType):date=String(maxsize=10)type=String(maxsize=6)para=String(maxsize=512,__permissions__={'read':('managers','users','guests'),'update':('managers',ERQLExpression('X in_state S, S name "todo"')),})migrated_from=SubjectRelation('Note')attachment=SubjectRelation('File')inline1=SubjectRelation('Affaire',inlined=True,cardinality='?*',constraints=[RQLUniqueConstraint('S type T, S inline1 A1, A1 todo_by C, ''Y type T, Y inline1 A2, A2 todo_by C','S,Y')])todo_by=SubjectRelation('CWUser')classPersonne(EntityType):__unique_together__=[('nom','prenom','inline2')]nom=String(fulltextindexed=True,required=True,maxsize=64)prenom=String(fulltextindexed=True,maxsize=64)sexe=String(maxsize=1,default='M',fulltextindexed=True)promo=String(vocabulary=('bon','pasbon'))titre=String(fulltextindexed=True,maxsize=128)adel=String(maxsize=128)ass=String(maxsize=128)web=String(maxsize=128)tel=Int()fax=Int()datenaiss=Datetime()tzdatenaiss=TZDatetime()test=Boolean(__permissions__={'read':('managers','users','guests'),'update':('managers',),})description=String()firstname=String(fulltextindexed=True,maxsize=64)concerne=SubjectRelation('Affaire')connait=SubjectRelation('Personne')inline2=SubjectRelation('Affaire',inlined=True,cardinality='?*')custom_field_of_jungle=BabarTestType(jungle_speed=42)classOld(EntityType):name=String()classconnait(RelationType):symmetric=Trueclassconcerne(RelationType):__permissions__={'read':('managers','users','guests'),'add':('managers',RRQLExpression('U has_update_permission S')),'delete':('managers',RRQLExpression('O owned_by U')),}classtravaille(RelationDefinition):__permissions__={'read':('managers','users','guests'),'add':('managers',RRQLExpression('U has_update_permission S')),'delete':('managers',RRQLExpression('O owned_by U')),}subject='Personne'object='Societe'classcomments(RelationDefinition):subject='Comment'object='Personne'classfiche(RelationDefinition):inlined=Truesubject='Personne'object='Card'cardinality='??'classmultisource_inlined_rel(RelationDefinition):inlined=Truecardinality='?*'subject=('Card','Note')object=('Affaire','Note')classmultisource_rel(RelationDefinition):subject=('Card','Note')object='Note'classmultisource_crossed_rel(RelationDefinition):subject=('Card','Note')object='Note'classsee_also_1(RelationDefinition):name='see_also'subject=object='Folder'classsee_also_2(RelationDefinition):name='see_also'subject=('Bookmark','Note')object=('Bookmark','Note')classevaluee(RelationDefinition):subject=('Personne','CWUser','Societe')object=('Note')classecrit_par(RelationType):inlined=Trueclassecrit_par_1(RelationDefinition):name='ecrit_par'subject='Note'object='Personne'constraints=[RQLConstraint('E concerns P, S version_of P')]cardinality='?*'classecrit_par_2(RelationDefinition):name='ecrit_par'subject='Note'object='CWUser'cardinality='?*'classcopain(RelationDefinition):subject=object='CWUser'classtags(RelationDefinition):subject='Tag'object=('CWUser','CWGroup','State','Note','Card','Affaire')classfiled_under(RelationDefinition):subject=('Note','Affaire')object='Folder'classrequire_permission(RelationDefinition):subject=('Card','Note','Personne')object='CWPermission'classrequire_state(RelationDefinition):subject='CWPermission'object='State'classpersonne_composite(RelationDefinition):subject='Personne'object='Personne'composite='subject'classpersonne_inlined(RelationDefinition):subject='Personne'object='Personne'cardinality='?*'inlined=Trueclasslogin_user(RelationDefinition):subject='Personne'object='CWUser'cardinality='??'classambiguous_inlined(RelationDefinition):subject=('Affaire','Note')object='CWUser'inlined=Truecardinality='?*'