Changeset 42572c in indico


Ignore:
Timestamp:
03/26/10 09:04:56 (3 years ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 4c7d4152dff271ba5df5a8606605969cab454080
Children:
afe4553
Parents:
550acf
git-author:
Jose Benito <jose.benito.gonzalez@…> (03/26/10 09:03:16)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (03/26/10 09:04:56)
Message:

[FIX] i18n problems with poster creation

All the items (elements inside a poster) were storing
their name (translated or not) in the DB. Now, we use
a key and a dictionary JS in order to translate the
names.

Location:
indico/MaKaC
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/PDFinterface/conference.py

    r550acf r42572c  
    29642964 
    29652965            # First we determine the actual text that has to be drawed. 
    2966             action = PosterDesignConfiguration().items_actions[item.getName()] 
     2966            action = PosterDesignConfiguration().items_actions[item.getKey()][1] 
    29672967 
    29682968            if isinstance(action, str): 
  • indico/MaKaC/badge.py

    r550acf r42572c  
    203203        # using the name as key). 
    204204        for item in self.__templateData[4]: 
    205             itemName = item['name'] 
    206205            if not "key" in item: 
    207                 item['key'] = itemName 
     206                item['key'] = item['name'] 
    208207        ############################## 
    209208 
     
    379378            -itemData must be a dictionary with the attributes of the item 
    380379            Example: 
    381             {'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, 'name': 'Country', 'fontFamily': 'Arial', 
     380            {'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, 'key': 'Country', 'fontFamily': 'Arial', 
    382381            'color': 'blue', 'selected': false, 'fontSizeIndex': 5, 'id': 0, 'width': 250, 'italic': False, 
    383382            'fontSize': 'x-large', 'textAlignIndex': 1, 'y': 40, 'x': 210, 'textAlign': 'Right', 
  • indico/MaKaC/poster.py

    r696f10 r42572c  
    3535        of a conference. This conference is called the owner of the manager. 
    3636    """ 
    37      
     37 
    3838    def __init__(self, conf): 
    3939        """ Class constructor 
     
    4545        self.__tempBackgrounds = {} 
    4646        self.__tempBackgroundCounters = {} 
    47          
     47 
    4848    def notifyModification(self): 
    4949        self._p_changed = 1 
    50      
     50 
    5151    def getTemplateById(self, templateId): 
    5252        """ 
     
    5454        """ 
    5555        return self.__templates[templateId] 
    56      
     56 
    5757    def getTemplateData(self, templateId): 
    5858        """ 
     
    6161        """ 
    6262        return self.__templates[templateId].getData() 
    63      
     63 
    6464    def getTemplates(self): 
    6565        """ Returns a dictionary of (templateId, PosterTemplate) keys and values 
    6666        """ 
    6767        return self.__templates 
    68      
     68 
    6969    def hasTemplate(self, templateId): 
    7070        """ Tests if there is a template stored with the given templateId 
    7171        """ 
    7272        return self.__templates.has_key(templateId) 
    73      
     73 
    7474    def getNewTemplateId(self): 
    75          
     75 
    7676        """ Returns a new an unused templateId 
    7777        Increments the templateId counter 
    7878        """ 
    7979        return self.__counter.newCount() 
    80      
     80 
    8181    def storeTemplate(self, templateId, templateData): 
    8282        """ 
     
    9999            self.__templates[templateId] = PosterTemplate(templateId, simplejson.loads(templateData)) 
    100100        self.notifyModification() 
    101          
     101 
    102102    def addTemplate(self, templ, templateId): 
    103103        if self.__templates.has_key(templateId): 
     
    106106            self.__templates[templateId] = templ 
    107107            return templ 
    108          
     108 
    109109    def deleteTemplate(self, templateId): 
    110110        """ Deletes a template, if it exists (otherwise it does nothing) 
     
    145145        will be used to print posters. 
    146146    """ 
    147      
     147 
    148148    def __init__(self, id, templateData): 
    149149        """ Class Constructor 
     
    160160                -The index of the background used in the template, among the several backgrounds of the template. -1 if none 
    161161                -A list of dictionaries. Each dictionary has the attributes of one of the items of the template. 
    162              
     162 
    163163        """ 
    164164        self.__id = id 
     
    170170        self.__bgPositions = {} #dictionary with the background positioning, for each of them (key: id, value: String ('Center','Stretch')) 
    171171        self.notifyModification() 
    172          
     172 
    173173    def clone(self, templMan, templId=None): 
    174174        if templId == None: 
     
    188188        templMan.notifyModification() 
    189189        return newTempl 
    190          
     190 
    191191    def notifyModification(self): 
    192192        self._p_changed = 1 
    193      
     193 
    194194    def getData(self): 
    195195        """ Returns the list with all the information of the template. 
    196196        Useful so that javascript can analyze it on its own. 
    197197        """ 
     198 
     199        # ensure that each item's got a key (in order to avoid 
     200        # using the name as key). 
     201        for item in self.__templateData[4]: 
     202            if not "key" in item: 
     203                item['key'] = item['name'] 
     204        ############################## 
    198205        return self.__templateData 
    199      
     206 
    200207    def setData(self, templateData): 
    201208        """ Sets the data of the template 
     
    204211        self.__cleanData() 
    205212        self.notifyModification() 
    206      
     213 
    207214    def getName(self): 
    208215        """ Returns the name of the template 
    209216        """ 
    210217        return self.__templateData[0].encode('utf-8') 
    211      
     218 
    212219 
    213220    def getWidth(self): 
     
    215222        """ 
    216223        return self.__templateData[1]["width"] 
    217      
     224 
    218225 
    219226    def getHeight(self): 
     
    221228        """ 
    222229        return self.__templateData[1]["height"] 
    223      
     230 
    224231 
    225232    def getPixelsPerCm(self): 
     
    228235        """ 
    229236        return self.__templateData[2] 
    230      
     237 
    231238    def getItems(self): 
    232239        """ Returns a list of object of the class PosterTemplateItem with 
     
    234241        """ 
    235242        return [PosterTemplateItem(itemData, self) for itemData in self.__templateData[4]] 
    236      
     243 
    237244    def getItem(self, name): 
    238245        """ Returns an object of the class PosterTemplateItem 
     
    240247        """ 
    241248        return PosterTemplateItem(filter(lambda item: item['name'] == name, self.__templateData[4])[0]) 
    242      
     249 
    243250    def pixelsToCm(self, length): 
    244251        """ Transforms a length in pixels to a length in cm. 
     
    256263        """ 
    257264        return self.pixelsToCm(self.__templateData[1]["height"]) 
    258      
     265 
    259266    def getAllBackgrounds(self): 
    260267        """ Returns the list of stored background 
     
    262269        """ 
    263270        return self.__backgrounds 
    264      
     271 
    265272    def getUsedBackgroundId(self): 
    266273        """ Returns the id of the currently used background 
     
    268275        """ 
    269276        return int(self.__templateData[3]) 
    270      
     277 
    271278    def getBackground(self, backgroundId): 
    272279        """ Returns a tuple made of: 
    273280        -a boolean 
    274281        -a background based on an id 
    275         There are 3 possibilities:  
     282        There are 3 possibilities: 
    276283         -the background has already been archived. Then the boolean value is True, 
    277284         and the background is a LocalFile object, 
     
    281288         -there is no background with such id. Then the method returns (None, None) 
    282289        """ 
    283          
     290 
    284291        if self.__backgrounds.has_key(backgroundId): 
    285292            return True, self.__backgrounds[backgroundId] 
     
    295302        else: 
    296303            return None 
    297      
     304 
    298305    def addTempBackgroundFilePath(self, filePath, position): 
    299306        """ Adds a filePath of a temporary background to the dictionary of temporary backgrounds 
     
    304311        self.notifyModification() 
    305312        return backgroundId 
    306      
     313 
    307314    def archiveTempBackgrounds(self, conf): 
    308315        """ Archives all the temporary backgrounds of this template. 
     
    313320        After the archiving, the __tempBackgroundsFilePaths dictionary is reset to {} 
    314321        """ 
    315          
     322 
    316323        for backgroundId, (filePath, bgPosition) in self.__tempBackgroundsFilePaths.iteritems(): 
    317324            fileName = "background" + str(backgroundId) + "_t" + self.__id + "_c" + conf.id 
    318                  
     325 
    319326            file = conference.LocalFile() 
    320327            file.setName( fileName ) 
     
    322329            file.setFileName( fileName ) 
    323330            file.setFilePath( filePath ) 
    324              
     331 
    325332            file.setOwner( conf ) 
    326333            file.setId( fileName ) 
    327334            file.archive( conf._getRepository() ) 
    328              
     335 
    329336            self.__backgrounds[backgroundId] = file 
    330337            self.__bgPositions[backgroundId] = bgPosition 
    331                          
     338 
    332339        self.notifyModification() 
    333340        self.__tempBackgroundsFilePaths = {} 
    334          
     341 
    335342    def deleteTempBackgrounds(self): 
    336343        """ Deletes all the temporary backgrounds of this template 
    337344        """ 
    338345        self.__tempBackgroundsFilePaths = {} 
    339          
     346 
    340347    def deleteBackgrounds(self): 
    341348        """ Deletes all of the template archived backgrounds. 
     
    344351        for localFile in self.__backgrounds.values(): 
    345352            localFile.delete() 
    346              
     353 
    347354    def __cleanData(self): 
    348355        """ Private method which cleans the list passed by the javascript in WConfModifPosterDesign.tpl, 
     
    362369            if isinstance(item['y'],basestring) and item['y'][-2:] == 'px': 
    363370                item['y'] = item['y'][0:-2] 
    364          
    365      
     371 
     372 
    366373class PosterTemplateItem: 
    367374    """ This class represents one of the items of a poster template 
    368375        It is not stored in the database, just used for convenience access methods. 
    369376    """ 
    370      
     377 
    371378    def __init__(self, itemData, posterTemplate): 
    372379        """ Constructor 
    373380            -itemData must be a dictionary with the attributes of the item 
    374381            Example: 
    375             'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, 'name': 'Country', 'fontFamily': 'Arial', 
     382            'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, 'key': 'Country', 'fontFamily': 'Arial', 
    376383            'color': 'blue', 'selected': false, 'fontSizeIndex': 5, 'id': 0, 'width': 250, 'italic': False, 
    377384            'fontSize': 'x-large', 'textAlignIndex': 1, 'y': 40, 'x': 210, 'textAlign': 'Right', 
     
    387394        self.__itemData = itemData 
    388395        self.__posterTemplate = posterTemplate 
    389          
    390     def getName(self): 
    391         """ Returns the name of the item. 
    392         The name of an item idientifies the kind of item it is: "Name", "Country", "Fixed Text"... 
    393         """ 
    394         return self.__itemData['name'] 
    395      
     396 
     397    def getKey(self): 
     398        """ Returns the key of the item. 
     399        The key of an item idientifies the kind of item it is: "Name", "Country", "Fixed Text"... 
     400        """ 
     401        if "key" in self.__itemData: 
     402            return self.__itemData['key'] 
     403        else: 
     404            return self.__itemData['name'] 
     405 
    396406    def getFixedText(self): 
    397407        """ Returns the text content of a Fixed Text item. 
     
    399409        """ 
    400410        return self.__itemData['text'] 
    401          
     411 
    402412    def getX(self): 
    403413        """ Returns the x coordinate of the item, in pixels. 
    404414        """ 
    405415        return self.__itemData['x'] 
    406      
     416 
    407417    def getXInCm(self): 
    408418        """ Returns the x coordinate of the item, in cm. 
    409419        """ 
    410420        return self.__posterTemplate.pixelsToCm(self.getX()) 
    411      
     421 
    412422    def getY(self): 
    413423        """ Returns the y coordinate of the item, in pixels. 
    414424        """ 
    415425        return self.__itemData['y'] 
    416      
     426 
    417427    def getYInCm(self): 
    418428        """ Returns the y coordinate of the item, in cm. 
    419429        """ 
    420430        return self.__posterTemplate.pixelsToCm(self.getY()) 
    421      
     431 
    422432    def getFont(self): 
    423433        """ Returns the name of the font used by this item. 
    424434        """ 
    425435        return self.__itemData['fontFamily'] 
    426      
     436 
    427437    def getFontSize(self): 
    428438        """ Returns the font size used by this item. 
     
    431441        """ 
    432442        return self.__itemData['fontSize'] 
    433      
     443 
    434444    def getColor(self): 
    435445        """ Returns the color used by the item, as a string. 
    436446        """ 
    437447        return self.__itemData['color'] 
    438      
     448 
    439449    def getWidth(self): 
    440450        """ Returns the width of the item, in pixels. 
    441451        """ 
    442452        return self.__itemData['width'] 
    443      
     453 
    444454    def getWidthInCm(self): 
    445455        """ Returns the width of the item, in cm. 
    446456        """ 
    447457        return self.__posterTemplate.pixelsToCm(self.getWidth()) 
    448      
     458 
    449459    def isBold(self): 
    450460        """ Checks of the item is bold (returns a boolean) 
    451461        """ 
    452462        return self.__itemData['bold'] 
    453      
     463 
    454464    def isItalic(self): 
    455465        """ Checks of the item is italic (returns a boolean) 
    456466        """ 
    457467        return self.__itemData['italic'] 
    458      
     468 
    459469    def getTextAlign(self): 
    460470        """ Returns the text alignment of the item, as a string. 
  • indico/MaKaC/posterDesignConf.py

    r9033fd r42572c  
    2727 
    2828class ConferenceDates: 
    29      
     29 
    3030    def getArgumentType(cls): 
    3131        return Conference 
    3232    getArgumentType = classmethod (getArgumentType) 
    33      
     33 
    3434    def getValue(cls, conf): 
    3535        if conf.getStartDate().date() == conf.getEndDate().date(): 
     
    3838            return str(conf.getAdjustedStartDate().date()) + ' - ' + str(conf.getAdjustedEndDate().date()) 
    3939    getValue = classmethod (getValue) 
    40      
     40 
    4141class ConferenceLocation: 
    42      
     42 
    4343    def getArgumentType(cls): 
    4444        return Conference 
    4545    getArgumentType = classmethod (getArgumentType) 
    46      
     46 
    4747    def getValue(cls, conf): 
    48         return conf.getLocation().getName()            
     48        return conf.getLocation().getName() 
    4949    getValue = classmethod (getValue) 
    5050 
    5151 
    5252class ConferenceAddress: 
    53      
     53 
    5454    def getArgumentType(cls): 
    5555        return Conference 
    5656    getArgumentType = classmethod (getArgumentType) 
    57      
     57 
    5858    def getValue(cls, conf): 
    5959        return conf.getLocation().getAddress() 
    6060    getValue = classmethod (getValue) 
    61      
     61 
    6262class LectureCategory: 
    6363    def getArgumentType(cls): 
    6464        return Conference 
    6565    getArgumentType = classmethod (getArgumentType) 
    66      
     66 
    6767    def getValue(cls, conf): 
    6868        return conf.getOwner().getTitle() 
     
    7373        return Conference 
    7474    getArgumentType = classmethod (getArgumentType) 
    75      
     75 
    7676    def getValue(cls, conf): 
    7777        return conf.getOrgText() 
     
    8282        return Conference 
    8383    getArgumentType = classmethod (getArgumentType) 
    84      
     84 
    8585    def getValue(cls, conf): 
    8686        if conf.getRoom(): 
     
    8989            return "" 
    9090    getValue = classmethod (getValue) 
    91      
     91 
    9292class ConferenceChairperson: 
    9393    def getArgumentType(cls): 
    9494        return Conference 
    9595    getArgumentType = classmethod (getArgumentType) 
    96      
     96 
    9797    def getValue(cls, conf): 
    9898        list = conf.getChairList() 
    9999        return list 
    100         
     100 
    101101    getValue = classmethod (getValue) 
    102102 
     
    109109    <select> box in the WConfModifPosterDesign.tpl file. 
    110110    """ 
    111      
     111 
    112112    """ Dictionary that maps the name of an item to the action that should be taken 
    113113    at the time it is drawed. 
     
    126126       *it must have a getValue(object) method, to which a Conference instance, a Registrant instance or a 
    127127       PosterTemplateItem instance must be passed, depending on the result of the getArgumentType() method. 
    128        
     128 
    129129      """ 
    130130    def __init__(self): 
    131            
     131 
    132132        self.items_actions = { 
    133                          _("Lecture Category") : LectureCategory, 
    134                          _("Lecture Name") : Conference.getTitle,                      
    135                          _("Lecture Date(s)") : ConferenceDates,                      
    136                          _("Speaker(s)") : ConferenceChairperson, 
    137                          _("Description") : Conference.getDescription,                    
    138                          _("Location (name)") : ConferenceLocation, 
    139                          _("Location (address)") : ConferenceAddress, 
    140                          _("Location (room)") : ConferenceRoom, 
    141                          _("Organisers") : Organisers, 
    142                          _("Fixed Text") : PosterTemplateItem.getFixedText 
     133                         "Lecture Category": (_("Lecture Category"), LectureCategory), 
     134                         "Lecture Name": (_("Lecture Name"), Conference.getTitle), 
     135                         "Lecture Date(s)": (_("Lecture Date(s)"), ConferenceDates), 
     136                         "Speaker(s)": (_("Speaker(s)"), ConferenceChairperson), 
     137                         "Description": (_("Description"), Conference.getDescription), 
     138                         "Location (name)": (_("Location (name)"), ConferenceLocation), 
     139                         "Location (address)": (_("Location (address)"), ConferenceAddress), 
     140                         "Location (room)": (_("Location (room)"), ConferenceRoom), 
     141                         "Organisers": (_("Organisers"), Organisers), 
     142                         "Fixed Text": (_("Fixed Text"), PosterTemplateItem.getFixedText) 
    143143                        } 
    144          
     144 
    145145        """ Dictionary that maps group names to the item names that fall into that group. 
    146146        The groups are only used for the <select> box in the WConfModifPosterDesign.tpl file. 
    147147        """ 
    148         self.groups = [( _("Lecture Data"), [ _("Lecture Category"),  _("Lecture Name"),  _("Lecture Date(s)"), _("Speaker(s)"),  _("Description"),  _("Location (name)"),  _("Location (address)"),  _("Location (room)"), _("Organisers")]), 
    149                   ( _("Fixed Elements"), [ _("Fixed Text")])] 
     148        self.groups = [( _("Lecture Data"), ["Lecture Category", "Lecture Name", "Lecture Date(s)","Speaker(s)", 
     149                                             "Description", "Location (name)", "Location (address)", "Location (room)","Organisers"]), 
     150                        ( _("Fixed Elements"), ["Fixed Text"])] 
  • indico/MaKaC/webinterface/pages/conferences.py

    r550acf r42572c  
    1212812128        vars["loadingIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("loading"))) 
    1212912129        vars["templateId"]=self.__templateId 
     12130 
     12131        badgeDesignConfiguration = BadgeDesignConfiguration() 
    1213012132        from MaKaC.services.interface.rpc.json import encode as jsonEncode 
    12131         vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in BadgeDesignConfiguration().items_actions.iteritems()])) 
     12133        vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in badgeDesignConfiguration.items_actions.iteritems()])) 
    1213212134 
    1213312135        cases = [] 
    12134         badgeDesignConfiguration = BadgeDesignConfiguration() 
    1213512136        for itemKey in badgeDesignConfiguration.items_actions.keys(): 
    1213612137            case = [] 
     
    1219112192            vars["editingTemplate"]="true" 
    1219212193 
    12193             from MaKaC.services.interface.rpc.json import encode as jsonEncode 
    1219412194            templateDataString = jsonEncode(self.__conf.getBadgeTemplateManager().getTemplateData(self.__templateId)) 
    1219512195            vars["templateData"]= templateDataString 
     
    1242812428        vars["templateId"]=self.__templateId 
    1242912429 
     12430        posterDesignConfiguration = PosterDesignConfiguration() 
     12431        from MaKaC.services.interface.rpc.json import encode as jsonEncode 
     12432        vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in posterDesignConfiguration.items_actions.iteritems()])) 
     12433 
     12434 
    1243012435        cases = [] 
    12431         for itemName in PosterDesignConfiguration().items_actions.keys(): 
     12436        for itemKey in posterDesignConfiguration.items_actions.keys(): 
    1243212437            case = [] 
    1243312438            case.append('case "') 
    12434             case.append(itemName) 
     12439            case.append(itemKey) 
    1243512440            case.append('":') 
    1243612441            case.append('\n') 
    1243712442            case.append('items[itemId] = new Item(itemId, "') 
    12438             case.append(itemName) 
     12443            case.append(itemKey) 
    1243912444            case.append('");') 
    1244012445            case.append('\n') 
     
    1244712452 
    1244812453        optgroups = [] 
    12449         for optgroupName, options in PosterDesignConfiguration().groups: 
     12454        for optgroupName, options in posterDesignConfiguration.groups: 
    1245012455            optgroup = [] 
    1245112456            optgroup.append('<optgroup label="') 
     
    1245412459            optgroup.append('\n') 
    1245512460            for optionName in options: 
    12456                 optgroup.append('<option>') 
    12457                 optgroup.append(optionName) 
     12461                optgroup.append('<option value="%s">'%optionName) 
     12462                optgroup.append(posterDesignConfiguration.items_actions[optionName][0]) 
    1245812463                optgroup.append('</option>') 
    1245912464                optgroup.append('\n') 
     
    1248112486            vars["backgroundId"]=-1 
    1248212487            vars["backgroundPos"]="Stretch" 
    12483             vars["templateData"] == "''" 
     12488            vars["templateData"] = "''" 
    1248412489            vars["editingTemplate"]="false" 
    1248512490 
     
    1248912494            vars["titleMessage"]= _("Editing poster template") 
    1249012495            vars["editingTemplate"]="true" 
    12491             from MaKaC.services.interface.rpc.json import encode as jsonEncode 
    1249212496            templateDataString = jsonEncode(self.__conf.getPosterTemplateManager().getTemplateData(self.__templateId)) 
    1249312497            vars["templateData"]=quoteattr(templateDataString) 
  • indico/MaKaC/webinterface/tpls/ConfModifPosterDesign.tpl

    r385d02 r42572c  
    11  <script type="text/javascript"> 
    22 
    3         // "Zoom factor" - the size of the document, related to reality 
    4          
    5         var zoom_factor = 0.5 
     3    // "Zoom factor" - the size of the document, related to reality 
     4 
     5    var zoom_factor = 0.5 
    66 
    77    // These variables are initialised by a script at the end of the document 
     
    1818    // Number of pixels per cm 
    1919    var pixelsPerCm = 50 * zoom_factor; 
    20      
     20 
    2121    // Id of the background used 
    2222    var backgroundId = -1 
     
    3636    var lastSelectedDiv; 
    3737 
     38    // Translation dictionary from key to name in current language. 
     39    var translate = <%=translateName%>; 
     40 
    3841    // List of poster template items 
    3942    var items = []; 
    4043 
    4144    // Item class 
    42     function Item(itemId, name) { 
     45    function Item(itemId, key) { 
    4346      this.id = itemId; 
    44       this.name = name; 
     47      this.key = key; 
    4548      this.x = initialOffset; 
    4649      this.y = initialOffset; 
     
    6871              '" style="cursor:move; font-weight:' + (this.bold ? 'bold' : 'normal') + '; font-style:' + (this.italic ? 'italic' : 'normal') + 
    6972              '; text-align: ' + this.textAlign + ';"' + 
    70               '><tbody><tr><td><span style="color:' + this.color + '; font-family: ' + this.fontFamily + '; font-size:' + this.fontSize + ';">' +  
    71               (this.name == "Fixed Text" ? this.text : this.name) +  
     73              '><tbody><tr><td><span style="color:' + this.color + '; font-family: ' + this.fontFamily + '; font-size:' + this.fontSize + ';">' + 
     74              (this.key == "Fixed Text" ? this.text : translate[this.key]) + 
    7275              '</span></td></tr></tbody></table>'; 
    7376      } 
    74        
     77 
    7578    // Dimensions class 
    7679    function Dimensions(width, height) { 
     
    102105    } 
    103106 
    104         // This function creates a new draggable div 
    105         function createDiv() { 
    106         //       Each div has: 
     107    // This function creates a new draggable div 
     108    function createDiv() { 
     109    //       Each div has: 
    107110    //       -an unique id, which is a natural number (0, 1, 2, ...) 
    108111    //       -a type (stored in the name attribute) 
     
    110113    //       -an inner HTML with its content 
    111114      itemId++; 
    112      
     115 
    113116      var newDiv = document.createElement('div'); 
    114117 
     
    156159 
    157160        snap: ($F('snap checkbox') == "on") ? mySnap : false 
    158       });  
     161      }); 
    159162 
    160163      // We store the initial position as a good position which to return to 
    161164      newDiv.lastGoodPositionLeft = 0; 
    162165      newDiv.lastGoodPositionTop = 0; 
    163        
     166 
    164167      return newDiv; 
    165         } 
     168    } 
    166169 
    167170    // This function inserts the selected element in the blank space where poster template designing takes place 
     
    178181        markSelected(newDiv); 
    179182      } 
    180        
     183 
    181184      initialOffset += 10 
    182185 
     
    215218 
    216219      // Change the text that says which item is selected 
    217       $('selection text').innerHTML = items[newSelectedDiv.id].name; 
     220      $('selection text').innerHTML = translate[items[newSelectedDiv.id].key]; 
    218221 
    219222      // TODO: add check to see if there's a table inside and not an image 
     
    237240      $('color selector').selectedIndex = newSelectedItem.colorIndex; 
    238241      $('width field').value = newSelectedItem.width / pixelsPerCm; 
    239       if (newSelectedItem.name == "Fixed Text") { 
     242      if (newSelectedItem.key == "Fixed Text") { 
    240243        $('fixed text field').value = newSelectedItem.text 
    241244      } else { 
    242         $('fixed text field').value = "--" 
     245          $('fixed text field').value = "--" 
    243246      } 
    244247    } 
     
    253256 
    254257      if (templateDimensions.width > previousTemplateDimensions.width) { 
    255         var hRuler = $('horizontal ruler'); 
    256          
     258           var hRuler = $('horizontal ruler'); 
     259 
    257260        for (i = Math.ceil(previousTemplateDimensions.width / pixelsPerCm); i < Math.ceil(templateDimensions.width / pixelsPerCm); i++) { 
    258261          var newImg = document.createElement('div'); 
     
    278281 
    279282      if (templateDimensions.height > previousTemplateDimensions.height) { 
    280                 var vRuler = $('vertical ruler'); 
    281                  
     283           var vRuler = $('vertical ruler'); 
     284 
    282285        for (i = Math.ceil(previousTemplateDimensions.height / pixelsPerCm); i < Math.ceil(templateDimensions.height / pixelsPerCm); i++) { 
    283                   var newImg = document.createElement('div'); 
     286          var newImg = document.createElement('div'); 
    284287          newImg.id = "rulerv" + i; 
    285288          newImg.style.height = pixelsPerCm-1 + 'px'; 
     
    303306 
    304307    } 
    305      
     308 
    306309    // This function displays all the items in the 'items' array on the screen 
    307310    // If there are already some items being displayed, it does not erase them 
     
    404407      } 
    405408    } 
    406      
     409 
    407410    function zoom_font(zfact,fontSize) 
    408411    { 
    409                 var pattern = new RegExp ("([0-9.]+)pt", "g"); 
    410                  
    411                 var ftsize = pattern.exec(fontSize)[1]; 
    412                  
    413                 return (ftsize*zfact)+"pt"; 
     412        var pattern = new RegExp ("([0-9.]+)pt", "g"); 
     413 
     414        var ftsize = pattern.exec(fontSize)[1]; 
     415 
     416        return (ftsize*zfact)+"pt"; 
    414417    } 
    415418 
     
    468471      } 
    469472    } 
    470      
     473 
    471474    function changeText() { 
    472475      if(lastSelectedDiv) { 
     
    486489      template.push(templateDimensions, pixelsPerCm); 
    487490      template.push(backgroundId); 
    488        
     491 
    489492      for (var i=0;i<items.length;++i) 
    490493      { 
    491         if (items[i] != false) 
    492                 items[i].fontSize = zoom_font(1/zoom_factor,items[i].fontSize); 
    493       } 
    494        
     494          if (items[i] != false) 
     495              items[i].fontSize = zoom_font(1/zoom_factor,items[i].fontSize); 
     496      } 
     497 
    495498      template.push(items); 
    496499      $('templateData').value = template.toJSON(); 
    497500      document.hiddenform.submit() 
    498501    } 
    499      
     502 
    500503    function sending() { 
    501504      Element.show('loadingIcon') 
    502505    } 
    503      
     506 
    504507    firstLoad = true 
    505      
     508 
    506509    function sent() { 
    507510      if (firstLoad) { 
     
    518521          } 
    519522          backgroundId = iframeDocument.getElementById('background id').innerHTML 
    520           var backgroundURL = iframeDocument.getElementById('background url').innerHTML 
    521            
    522           backgroundPos = iframeDocument.getElementById('background pos').innerHTML 
    523            
    524               displayBackground(backgroundURL); 
    525                
    526           
    527                
     523          var backgroundURL = iframeDocument.getElementById('background url').innerHTML 
     524 
     525          backgroundPos = iframeDocument.getElementById('background pos').innerHTML 
     526 
     527          displayBackground(backgroundURL); 
     528 
     529 
     530 
    528531        } catch (err) { 
    529532          Element.hide('loadingIcon') 
     
    532535    } 
    533536 
    534      
     537 
    535538    function setBackgroundPos(mode) 
    536539    { 
    537         var background = document.getElementById('background'); 
    538                 var hiddenField = document.getElementById('bgPosition'); 
    539  
    540         var bgPosStretch = document.getElementById('bgPosStretch'); 
    541                 var bgPosCenter = document.getElementById('bgPosCenter'); 
    542  
    543  
    544         if (mode == 'Stretch') 
    545         { 
    546                 background.style.left = 0; 
    547                 background.style.top = 0; 
    548                 background.height = templateDimensions.height; 
    549                 background.width = templateDimensions.width; 
    550                  
    551                  
    552                 bgPosStretch.checked = true; 
    553                 bgPosCenter.checked = false; 
    554         } 
    555         else if (mode == 'Center') 
    556         { 
    557                 background.height = background.naturalHeight; 
    558                         background.width = background.naturalWidth; 
    559                  
    560                 if (background.width > templateDimensions.width || 
    561                         background.height > templateDimensions.height) 
    562                 {                        
    563                         if (background.width > templateDimensions.width) 
    564                         { 
    565                                         var ratio = templateDimensions.width/background.width; 
    566                                          
    567                                 background.width = templateDimensions.width; 
    568                                 background.height = background.height * ratio; 
    569                                 background.style.top = templateDimensions.height/2.0 - background.height/2.0; 
    570                                 background.style.left = 0; 
    571                                  
    572                         } 
    573                          
    574                         if (background.height > templateDimensions.height) 
    575                         { 
    576                                 var ratio = templateDimensions.height/background.height; 
    577                                  
    578                                 background.height = templateDimensions.height; 
    579                                 background.height = background.height * ratio; 
    580                                  
    581                                 background.style.left = templateDimensions.width/2.0 - background.width/2.0; 
    582                                 baclground.style.top = 0; 
    583                         }                    
    584                 } 
    585                 else 
    586                 {                
    587                         background.style.left = templateDimensions.width/2 - background.naturalWidth/2; 
    588                         background.style.top = templateDimensions.height/2 - background.naturalHeight/2; 
    589                 } 
    590                  
    591                                                  
    592                 bgPosStretch.checked = false; 
    593                 bgPosCenter.checked = true; 
    594                  
    595         }        
    596          
    597          
    598     } 
    599   
     540        var background = document.getElementById('background'); 
     541        var hiddenField = document.getElementById('bgPosition'); 
     542 
     543        var bgPosStretch = document.getElementById('bgPosStretch'); 
     544        var bgPosCenter = document.getElementById('bgPosCenter'); 
     545 
     546 
     547        if (mode == 'Stretch') 
     548        { 
     549            background.style.left = 0; 
     550            background.style.top = 0; 
     551            background.height = templateDimensions.height; 
     552            background.width = templateDimensions.width; 
     553 
     554 
     555            bgPosStretch.checked = true; 
     556            bgPosCenter.checked = false; 
     557        } 
     558        else if (mode == 'Center') 
     559        { 
     560            background.height = background.naturalHeight; 
     561            background.width = background.naturalWidth; 
     562 
     563            if (background.width > templateDimensions.width || 
     564                background.height > templateDimensions.height) 
     565            { 
     566                if (background.width > templateDimensions.width) 
     567                { 
     568                    var ratio = templateDimensions.width/background.width; 
     569 
     570                    background.width = templateDimensions.width; 
     571                    background.height = background.height * ratio; 
     572                    background.style.top = templateDimensions.height/2.0 - background.height/2.0; 
     573                    background.style.left = 0; 
     574 
     575                } 
     576 
     577                if (background.height > templateDimensions.height) 
     578                { 
     579                    var ratio = templateDimensions.height/background.height; 
     580 
     581                    background.height = templateDimensions.height; 
     582                    background.height = background.height * ratio; 
     583 
     584                    background.style.left = templateDimensions.width/2.0 - background.width/2.0; 
     585                    baclground.style.top = 0; 
     586                } 
     587            } 
     588            else 
     589            { 
     590                background.style.left = templateDimensions.width/2 - background.naturalWidth/2; 
     591                background.style.top = templateDimensions.height/2 - background.naturalHeight/2; 
     592            } 
     593 
     594 
     595            bgPosStretch.checked = false; 
     596            bgPosCenter.checked = true; 
     597 
     598        } 
     599 
     600 
     601    } 
     602 
    600603    function backgroundReceived() { 
    601604      Element.hide('loadingIcon') 
    602        
     605 
    603606      setBackgroundPos(backgroundPos); 
    604607    } 
    605      
     608 
    606609    function displayBackground(backgroundURL) { 
    607610        var newBackground = document.createElement('img'); 
     
    616619        newBackground.onload = backgroundReceived 
    617620        var template = $("templateDiv"); 
    618         template.appendChild(newBackground);       
    619     }    
    620      
     621        template.appendChild(newBackground); 
     622    } 
     623 
    621624    function removeBackground() { 
    622625      if (backgroundId != -1) { 
     
    627630 
    628631  </script> 
    629    
    630    
    631    
    632    
     632 
     633 
     634 
     635 
    633636<iframe id="uploadTarget" name="uploadTarget" src="" style="width:0px;height:0px;border:0" onload="sent()"></iframe> 
    634637 
     
    655658        <form action="%(saveBackgroundURL)s" method="POST" ENCTYPE="multipart/form-data" onsubmit="sending()" target="uploadTarget"> 
    656659        <td height="20px" NOWRAP align="left" colspan="3"> 
    657               <input name="file" size="58" type="file"> 
     660          <input name="file" size="58" type="file"> 
    658661          <input class="btn" value="Send File" type="submit"> 
    659662          <input class="btn" type="button" value="Remove background" onclick="removeBackground()"> 
    660663        </td> 
    661             <td width="100%%" align="left" colspan="4"> 
     664        <td width="100%%" align="left" colspan="4"> 
    662665          <img id="loadingIcon" src=%(loadingIconURL)s width="20px" height="20px" style="display:none;"> 
    663             </td> 
     666        </td> 
    664667      </tr> 
    665668      <tr> 
    666669        <td></td> 
    667670        <td> 
    668                         <table> 
    669                           <tbody> 
    670                             <tr><td> 
    671                                                 <input checked type="radio" id="bgPosStretch" name ='bgPosition' value="Stretch"> 
    672                                                 <label>Stretch</label>  
    673                                         </td> 
    674                                 <td> 
    675                                                 <input type='radio' id="bgPosCenter" name ='bgPosition' value="Center"> 
    676                                                 <label>Center</label> 
    677                             </td></tr> 
    678                           </tbody> 
    679                         </table> 
    680             </form> 
     671            <table> 
     672              <tbody> 
     673                <tr><td> 
     674                          <input checked type="radio" id="bgPosStretch" name ='bgPosition' value="Stretch"> 
     675                          <label>Stretch</label> 
     676                    </td> 
     677                    <td> 
     678                        <input type='radio' id="bgPosCenter" name ='bgPosition' value="Center"> 
     679                        <label>Center</label> 
     680                </td></tr> 
     681              </tbody> 
     682            </table> 
     683        </form> 
    681684        </td> 
    682685        <td></td> 
     
    816819              <option>Times New Roman</option> 
    817820              <option>Courier</option> 
    818             </optgroup>   
     821            </optgroup> 
    819822            <optgroup label="Special Character Fonts"> 
    820823              <option>LinuxLibertine</option> 
     
    939942    </tbody> 
    940943  </table> 
    941    
     944 
    942945  <form name="hiddenform" action="%(saveTemplateURL)s" method="POST"> 
    943         <input name="templateId" value="%(templateId)s" type="hidden"> 
    944         <input id="templateData" name="templateData" type="hidden"> 
     946      <input name="templateId" value="%(templateId)s" type="hidden"> 
     947      <input id="templateData" name="templateData" type="hidden"> 
    945948  </form> 
    946    
     949 
    947950<!-- 
    948951  <table id='test' width="200" height="200" border="1" onclick="alert(Element.getDimensions(this).width);this.width = parseInt(this.width) + 10; return false"> 
     
    952955 
    953956  <script type="text/javascript"> 
    954    
     957 
    955958    // We load the template if we are editing a template 
    956959    if (%(editingTemplate)s) { 
     
    968971       templateDimensions = new Dimensions(525,742); //put here the initial dimensions of templateDiv 
    969972    } 
    970          
     973 
    971974    previousTemplateDimensions = new Dimensions(0,0) 
    972      
     975 
    973976    $('poster width').value = templateDimensions.width / pixelsPerCm; 
    974977    $('poster height').value = templateDimensions.height / pixelsPerCm; 
    975      
     978 
    976979    // This function initialises the rulers 
    977980    updateRulers(); 
    978      
     981 
    979982    // This function displays the items, if any have been loaded, on the screen 
    980983    displayItems() 
    981      
     984 
    982985    if (%(editingTemplate)s && %(hasBackground)s) { 
    983986       backgroundId = %(backgroundId)s 
Note: See TracChangeset for help on using the changeset viewer.