Changeset 42572c in indico
- Timestamp:
- 03/26/10 09:04:56 (3 years ago)
- 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)
- Location:
- indico/MaKaC
- Files:
-
- 6 edited
-
PDFinterface/conference.py (modified) (1 diff)
-
badge.py (modified) (2 diffs)
-
poster.py (modified) (29 diffs)
-
posterDesignConf.py (modified) (7 diffs)
-
webinterface/pages/conferences.py (modified) (7 diffs)
-
webinterface/tpls/ConfModifPosterDesign.tpl (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/PDFinterface/conference.py
r550acf r42572c 2964 2964 2965 2965 # First we determine the actual text that has to be drawed. 2966 action = PosterDesignConfiguration().items_actions[item.get Name()]2966 action = PosterDesignConfiguration().items_actions[item.getKey()][1] 2967 2967 2968 2968 if isinstance(action, str): -
indico/MaKaC/badge.py
r550acf r42572c 203 203 # using the name as key). 204 204 for item in self.__templateData[4]: 205 itemName = item['name']206 205 if not "key" in item: 207 item['key'] = item Name206 item['key'] = item['name'] 208 207 ############################## 209 208 … … 379 378 -itemData must be a dictionary with the attributes of the item 380 379 Example: 381 {'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, ' name': 'Country', 'fontFamily': 'Arial',380 {'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, 'key': 'Country', 'fontFamily': 'Arial', 382 381 'color': 'blue', 'selected': false, 'fontSizeIndex': 5, 'id': 0, 'width': 250, 'italic': False, 383 382 'fontSize': 'x-large', 'textAlignIndex': 1, 'y': 40, 'x': 210, 'textAlign': 'Right', -
indico/MaKaC/poster.py
r696f10 r42572c 35 35 of a conference. This conference is called the owner of the manager. 36 36 """ 37 37 38 38 def __init__(self, conf): 39 39 """ Class constructor … … 45 45 self.__tempBackgrounds = {} 46 46 self.__tempBackgroundCounters = {} 47 47 48 48 def notifyModification(self): 49 49 self._p_changed = 1 50 50 51 51 def getTemplateById(self, templateId): 52 52 """ … … 54 54 """ 55 55 return self.__templates[templateId] 56 56 57 57 def getTemplateData(self, templateId): 58 58 """ … … 61 61 """ 62 62 return self.__templates[templateId].getData() 63 63 64 64 def getTemplates(self): 65 65 """ Returns a dictionary of (templateId, PosterTemplate) keys and values 66 66 """ 67 67 return self.__templates 68 68 69 69 def hasTemplate(self, templateId): 70 70 """ Tests if there is a template stored with the given templateId 71 71 """ 72 72 return self.__templates.has_key(templateId) 73 73 74 74 def getNewTemplateId(self): 75 75 76 76 """ Returns a new an unused templateId 77 77 Increments the templateId counter 78 78 """ 79 79 return self.__counter.newCount() 80 80 81 81 def storeTemplate(self, templateId, templateData): 82 82 """ … … 99 99 self.__templates[templateId] = PosterTemplate(templateId, simplejson.loads(templateData)) 100 100 self.notifyModification() 101 101 102 102 def addTemplate(self, templ, templateId): 103 103 if self.__templates.has_key(templateId): … … 106 106 self.__templates[templateId] = templ 107 107 return templ 108 108 109 109 def deleteTemplate(self, templateId): 110 110 """ Deletes a template, if it exists (otherwise it does nothing) … … 145 145 will be used to print posters. 146 146 """ 147 147 148 148 def __init__(self, id, templateData): 149 149 """ Class Constructor … … 160 160 -The index of the background used in the template, among the several backgrounds of the template. -1 if none 161 161 -A list of dictionaries. Each dictionary has the attributes of one of the items of the template. 162 162 163 163 """ 164 164 self.__id = id … … 170 170 self.__bgPositions = {} #dictionary with the background positioning, for each of them (key: id, value: String ('Center','Stretch')) 171 171 self.notifyModification() 172 172 173 173 def clone(self, templMan, templId=None): 174 174 if templId == None: … … 188 188 templMan.notifyModification() 189 189 return newTempl 190 190 191 191 def notifyModification(self): 192 192 self._p_changed = 1 193 193 194 194 def getData(self): 195 195 """ Returns the list with all the information of the template. 196 196 Useful so that javascript can analyze it on its own. 197 197 """ 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 ############################## 198 205 return self.__templateData 199 206 200 207 def setData(self, templateData): 201 208 """ Sets the data of the template … … 204 211 self.__cleanData() 205 212 self.notifyModification() 206 213 207 214 def getName(self): 208 215 """ Returns the name of the template 209 216 """ 210 217 return self.__templateData[0].encode('utf-8') 211 218 212 219 213 220 def getWidth(self): … … 215 222 """ 216 223 return self.__templateData[1]["width"] 217 224 218 225 219 226 def getHeight(self): … … 221 228 """ 222 229 return self.__templateData[1]["height"] 223 230 224 231 225 232 def getPixelsPerCm(self): … … 228 235 """ 229 236 return self.__templateData[2] 230 237 231 238 def getItems(self): 232 239 """ Returns a list of object of the class PosterTemplateItem with … … 234 241 """ 235 242 return [PosterTemplateItem(itemData, self) for itemData in self.__templateData[4]] 236 243 237 244 def getItem(self, name): 238 245 """ Returns an object of the class PosterTemplateItem … … 240 247 """ 241 248 return PosterTemplateItem(filter(lambda item: item['name'] == name, self.__templateData[4])[0]) 242 249 243 250 def pixelsToCm(self, length): 244 251 """ Transforms a length in pixels to a length in cm. … … 256 263 """ 257 264 return self.pixelsToCm(self.__templateData[1]["height"]) 258 265 259 266 def getAllBackgrounds(self): 260 267 """ Returns the list of stored background … … 262 269 """ 263 270 return self.__backgrounds 264 271 265 272 def getUsedBackgroundId(self): 266 273 """ Returns the id of the currently used background … … 268 275 """ 269 276 return int(self.__templateData[3]) 270 277 271 278 def getBackground(self, backgroundId): 272 279 """ Returns a tuple made of: 273 280 -a boolean 274 281 -a background based on an id 275 There are 3 possibilities: 282 There are 3 possibilities: 276 283 -the background has already been archived. Then the boolean value is True, 277 284 and the background is a LocalFile object, … … 281 288 -there is no background with such id. Then the method returns (None, None) 282 289 """ 283 290 284 291 if self.__backgrounds.has_key(backgroundId): 285 292 return True, self.__backgrounds[backgroundId] … … 295 302 else: 296 303 return None 297 304 298 305 def addTempBackgroundFilePath(self, filePath, position): 299 306 """ Adds a filePath of a temporary background to the dictionary of temporary backgrounds … … 304 311 self.notifyModification() 305 312 return backgroundId 306 313 307 314 def archiveTempBackgrounds(self, conf): 308 315 """ Archives all the temporary backgrounds of this template. … … 313 320 After the archiving, the __tempBackgroundsFilePaths dictionary is reset to {} 314 321 """ 315 322 316 323 for backgroundId, (filePath, bgPosition) in self.__tempBackgroundsFilePaths.iteritems(): 317 324 fileName = "background" + str(backgroundId) + "_t" + self.__id + "_c" + conf.id 318 325 319 326 file = conference.LocalFile() 320 327 file.setName( fileName ) … … 322 329 file.setFileName( fileName ) 323 330 file.setFilePath( filePath ) 324 331 325 332 file.setOwner( conf ) 326 333 file.setId( fileName ) 327 334 file.archive( conf._getRepository() ) 328 335 329 336 self.__backgrounds[backgroundId] = file 330 337 self.__bgPositions[backgroundId] = bgPosition 331 338 332 339 self.notifyModification() 333 340 self.__tempBackgroundsFilePaths = {} 334 341 335 342 def deleteTempBackgrounds(self): 336 343 """ Deletes all the temporary backgrounds of this template 337 344 """ 338 345 self.__tempBackgroundsFilePaths = {} 339 346 340 347 def deleteBackgrounds(self): 341 348 """ Deletes all of the template archived backgrounds. … … 344 351 for localFile in self.__backgrounds.values(): 345 352 localFile.delete() 346 353 347 354 def __cleanData(self): 348 355 """ Private method which cleans the list passed by the javascript in WConfModifPosterDesign.tpl, … … 362 369 if isinstance(item['y'],basestring) and item['y'][-2:] == 'px': 363 370 item['y'] = item['y'][0:-2] 364 365 371 372 366 373 class PosterTemplateItem: 367 374 """ This class represents one of the items of a poster template 368 375 It is not stored in the database, just used for convenience access methods. 369 376 """ 370 377 371 378 def __init__(self, itemData, posterTemplate): 372 379 """ Constructor 373 380 -itemData must be a dictionary with the attributes of the item 374 381 Example: 375 'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, ' name': 'Country', 'fontFamily': 'Arial',382 'fontFamilyIndex': 0, 'styleIndex': 1, 'bold': True, 'key': 'Country', 'fontFamily': 'Arial', 376 383 'color': 'blue', 'selected': false, 'fontSizeIndex': 5, 'id': 0, 'width': 250, 'italic': False, 377 384 'fontSize': 'x-large', 'textAlignIndex': 1, 'y': 40, 'x': 210, 'textAlign': 'Right', … … 387 394 self.__itemData = itemData 388 395 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 396 406 def getFixedText(self): 397 407 """ Returns the text content of a Fixed Text item. … … 399 409 """ 400 410 return self.__itemData['text'] 401 411 402 412 def getX(self): 403 413 """ Returns the x coordinate of the item, in pixels. 404 414 """ 405 415 return self.__itemData['x'] 406 416 407 417 def getXInCm(self): 408 418 """ Returns the x coordinate of the item, in cm. 409 419 """ 410 420 return self.__posterTemplate.pixelsToCm(self.getX()) 411 421 412 422 def getY(self): 413 423 """ Returns the y coordinate of the item, in pixels. 414 424 """ 415 425 return self.__itemData['y'] 416 426 417 427 def getYInCm(self): 418 428 """ Returns the y coordinate of the item, in cm. 419 429 """ 420 430 return self.__posterTemplate.pixelsToCm(self.getY()) 421 431 422 432 def getFont(self): 423 433 """ Returns the name of the font used by this item. 424 434 """ 425 435 return self.__itemData['fontFamily'] 426 436 427 437 def getFontSize(self): 428 438 """ Returns the font size used by this item. … … 431 441 """ 432 442 return self.__itemData['fontSize'] 433 443 434 444 def getColor(self): 435 445 """ Returns the color used by the item, as a string. 436 446 """ 437 447 return self.__itemData['color'] 438 448 439 449 def getWidth(self): 440 450 """ Returns the width of the item, in pixels. 441 451 """ 442 452 return self.__itemData['width'] 443 453 444 454 def getWidthInCm(self): 445 455 """ Returns the width of the item, in cm. 446 456 """ 447 457 return self.__posterTemplate.pixelsToCm(self.getWidth()) 448 458 449 459 def isBold(self): 450 460 """ Checks of the item is bold (returns a boolean) 451 461 """ 452 462 return self.__itemData['bold'] 453 463 454 464 def isItalic(self): 455 465 """ Checks of the item is italic (returns a boolean) 456 466 """ 457 467 return self.__itemData['italic'] 458 468 459 469 def getTextAlign(self): 460 470 """ Returns the text alignment of the item, as a string. -
indico/MaKaC/posterDesignConf.py
r9033fd r42572c 27 27 28 28 class ConferenceDates: 29 29 30 30 def getArgumentType(cls): 31 31 return Conference 32 32 getArgumentType = classmethod (getArgumentType) 33 33 34 34 def getValue(cls, conf): 35 35 if conf.getStartDate().date() == conf.getEndDate().date(): … … 38 38 return str(conf.getAdjustedStartDate().date()) + ' - ' + str(conf.getAdjustedEndDate().date()) 39 39 getValue = classmethod (getValue) 40 40 41 41 class ConferenceLocation: 42 42 43 43 def getArgumentType(cls): 44 44 return Conference 45 45 getArgumentType = classmethod (getArgumentType) 46 46 47 47 def getValue(cls, conf): 48 return conf.getLocation().getName() 48 return conf.getLocation().getName() 49 49 getValue = classmethod (getValue) 50 50 51 51 52 52 class ConferenceAddress: 53 53 54 54 def getArgumentType(cls): 55 55 return Conference 56 56 getArgumentType = classmethod (getArgumentType) 57 57 58 58 def getValue(cls, conf): 59 59 return conf.getLocation().getAddress() 60 60 getValue = classmethod (getValue) 61 61 62 62 class LectureCategory: 63 63 def getArgumentType(cls): 64 64 return Conference 65 65 getArgumentType = classmethod (getArgumentType) 66 66 67 67 def getValue(cls, conf): 68 68 return conf.getOwner().getTitle() … … 73 73 return Conference 74 74 getArgumentType = classmethod (getArgumentType) 75 75 76 76 def getValue(cls, conf): 77 77 return conf.getOrgText() … … 82 82 return Conference 83 83 getArgumentType = classmethod (getArgumentType) 84 84 85 85 def getValue(cls, conf): 86 86 if conf.getRoom(): … … 89 89 return "" 90 90 getValue = classmethod (getValue) 91 91 92 92 class ConferenceChairperson: 93 93 def getArgumentType(cls): 94 94 return Conference 95 95 getArgumentType = classmethod (getArgumentType) 96 96 97 97 def getValue(cls, conf): 98 98 list = conf.getChairList() 99 99 return list 100 100 101 101 getValue = classmethod (getValue) 102 102 … … 109 109 <select> box in the WConfModifPosterDesign.tpl file. 110 110 """ 111 111 112 112 """ Dictionary that maps the name of an item to the action that should be taken 113 113 at the time it is drawed. … … 126 126 *it must have a getValue(object) method, to which a Conference instance, a Registrant instance or a 127 127 PosterTemplateItem instance must be passed, depending on the result of the getArgumentType() method. 128 128 129 129 """ 130 130 def __init__(self): 131 131 132 132 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.getFixedText133 "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) 143 143 } 144 144 145 145 """ Dictionary that maps group names to the item names that fall into that group. 146 146 The groups are only used for the <select> box in the WConfModifPosterDesign.tpl file. 147 147 """ 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 12128 12128 vars["loadingIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("loading"))) 12129 12129 vars["templateId"]=self.__templateId 12130 12131 badgeDesignConfiguration = BadgeDesignConfiguration() 12130 12132 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()])) 12132 12134 12133 12135 cases = [] 12134 badgeDesignConfiguration = BadgeDesignConfiguration()12135 12136 for itemKey in badgeDesignConfiguration.items_actions.keys(): 12136 12137 case = [] … … 12191 12192 vars["editingTemplate"]="true" 12192 12193 12193 from MaKaC.services.interface.rpc.json import encode as jsonEncode12194 12194 templateDataString = jsonEncode(self.__conf.getBadgeTemplateManager().getTemplateData(self.__templateId)) 12195 12195 vars["templateData"]= templateDataString … … 12428 12428 vars["templateId"]=self.__templateId 12429 12429 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 12430 12435 cases = [] 12431 for item Name in PosterDesignConfiguration().items_actions.keys():12436 for itemKey in posterDesignConfiguration.items_actions.keys(): 12432 12437 case = [] 12433 12438 case.append('case "') 12434 case.append(item Name)12439 case.append(itemKey) 12435 12440 case.append('":') 12436 12441 case.append('\n') 12437 12442 case.append('items[itemId] = new Item(itemId, "') 12438 case.append(item Name)12443 case.append(itemKey) 12439 12444 case.append('");') 12440 12445 case.append('\n') … … 12447 12452 12448 12453 optgroups = [] 12449 for optgroupName, options in PosterDesignConfiguration().groups:12454 for optgroupName, options in posterDesignConfiguration.groups: 12450 12455 optgroup = [] 12451 12456 optgroup.append('<optgroup label="') … … 12454 12459 optgroup.append('\n') 12455 12460 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]) 12458 12463 optgroup.append('</option>') 12459 12464 optgroup.append('\n') … … 12481 12486 vars["backgroundId"]=-1 12482 12487 vars["backgroundPos"]="Stretch" 12483 vars["templateData"] = ="''"12488 vars["templateData"] = "''" 12484 12489 vars["editingTemplate"]="false" 12485 12490 … … 12489 12494 vars["titleMessage"]= _("Editing poster template") 12490 12495 vars["editingTemplate"]="true" 12491 from MaKaC.services.interface.rpc.json import encode as jsonEncode12492 12496 templateDataString = jsonEncode(self.__conf.getPosterTemplateManager().getTemplateData(self.__templateId)) 12493 12497 vars["templateData"]=quoteattr(templateDataString) -
indico/MaKaC/webinterface/tpls/ConfModifPosterDesign.tpl
r385d02 r42572c 1 1 <script type="text/javascript"> 2 2 3 // "Zoom factor" - the size of the document, related to reality4 5 var zoom_factor = 0.53 // "Zoom factor" - the size of the document, related to reality 4 5 var zoom_factor = 0.5 6 6 7 7 // These variables are initialised by a script at the end of the document … … 18 18 // Number of pixels per cm 19 19 var pixelsPerCm = 50 * zoom_factor; 20 20 21 21 // Id of the background used 22 22 var backgroundId = -1 … … 36 36 var lastSelectedDiv; 37 37 38 // Translation dictionary from key to name in current language. 39 var translate = <%=translateName%>; 40 38 41 // List of poster template items 39 42 var items = []; 40 43 41 44 // Item class 42 function Item(itemId, name) {45 function Item(itemId, key) { 43 46 this.id = itemId; 44 this. name = name;47 this.key = key; 45 48 this.x = initialOffset; 46 49 this.y = initialOffset; … … 68 71 '" style="cursor:move; font-weight:' + (this.bold ? 'bold' : 'normal') + '; font-style:' + (this.italic ? 'italic' : 'normal') + 69 72 '; 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]) + 72 75 '</span></td></tr></tbody></table>'; 73 76 } 74 77 75 78 // Dimensions class 76 79 function Dimensions(width, height) { … … 102 105 } 103 106 104 // This function creates a new draggable div105 function createDiv() {106 // Each div has:107 // This function creates a new draggable div 108 function createDiv() { 109 // Each div has: 107 110 // -an unique id, which is a natural number (0, 1, 2, ...) 108 111 // -a type (stored in the name attribute) … … 110 113 // -an inner HTML with its content 111 114 itemId++; 112 115 113 116 var newDiv = document.createElement('div'); 114 117 … … 156 159 157 160 snap: ($F('snap checkbox') == "on") ? mySnap : false 158 }); 161 }); 159 162 160 163 // We store the initial position as a good position which to return to 161 164 newDiv.lastGoodPositionLeft = 0; 162 165 newDiv.lastGoodPositionTop = 0; 163 166 164 167 return newDiv; 165 }168 } 166 169 167 170 // This function inserts the selected element in the blank space where poster template designing takes place … … 178 181 markSelected(newDiv); 179 182 } 180 183 181 184 initialOffset += 10 182 185 … … 215 218 216 219 // 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]; 218 221 219 222 // TODO: add check to see if there's a table inside and not an image … … 237 240 $('color selector').selectedIndex = newSelectedItem.colorIndex; 238 241 $('width field').value = newSelectedItem.width / pixelsPerCm; 239 if (newSelectedItem. name== "Fixed Text") {242 if (newSelectedItem.key == "Fixed Text") { 240 243 $('fixed text field').value = newSelectedItem.text 241 244 } else { 242 $('fixed text field').value = "--"245 $('fixed text field').value = "--" 243 246 } 244 247 } … … 253 256 254 257 if (templateDimensions.width > previousTemplateDimensions.width) { 255 var hRuler = $('horizontal ruler');256 258 var hRuler = $('horizontal ruler'); 259 257 260 for (i = Math.ceil(previousTemplateDimensions.width / pixelsPerCm); i < Math.ceil(templateDimensions.width / pixelsPerCm); i++) { 258 261 var newImg = document.createElement('div'); … … 278 281 279 282 if (templateDimensions.height > previousTemplateDimensions.height) { 280 var vRuler = $('vertical ruler');281 283 var vRuler = $('vertical ruler'); 284 282 285 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'); 284 287 newImg.id = "rulerv" + i; 285 288 newImg.style.height = pixelsPerCm-1 + 'px'; … … 303 306 304 307 } 305 308 306 309 // This function displays all the items in the 'items' array on the screen 307 310 // If there are already some items being displayed, it does not erase them … … 404 407 } 405 408 } 406 409 407 410 function zoom_font(zfact,fontSize) 408 411 { 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"; 414 417 } 415 418 … … 468 471 } 469 472 } 470 473 471 474 function changeText() { 472 475 if(lastSelectedDiv) { … … 486 489 template.push(templateDimensions, pixelsPerCm); 487 490 template.push(backgroundId); 488 491 489 492 for (var i=0;i<items.length;++i) 490 493 { 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 495 498 template.push(items); 496 499 $('templateData').value = template.toJSON(); 497 500 document.hiddenform.submit() 498 501 } 499 502 500 503 function sending() { 501 504 Element.show('loadingIcon') 502 505 } 503 506 504 507 firstLoad = true 505 508 506 509 function sent() { 507 510 if (firstLoad) { … … 518 521 } 519 522 backgroundId = iframeDocument.getElementById('background id').innerHTML 520 var backgroundURL = iframeDocument.getElementById('background url').innerHTML521 522 backgroundPos = iframeDocument.getElementById('background pos').innerHTML523 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 528 531 } catch (err) { 529 532 Element.hide('loadingIcon') … … 532 535 } 533 536 534 537 535 538 function setBackgroundPos(mode) 536 539 { 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 else586 {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 600 603 function backgroundReceived() { 601 604 Element.hide('loadingIcon') 602 605 603 606 setBackgroundPos(backgroundPos); 604 607 } 605 608 606 609 function displayBackground(backgroundURL) { 607 610 var newBackground = document.createElement('img'); … … 616 619 newBackground.onload = backgroundReceived 617 620 var template = $("templateDiv"); 618 template.appendChild(newBackground); 619 } 620 621 template.appendChild(newBackground); 622 } 623 621 624 function removeBackground() { 622 625 if (backgroundId != -1) { … … 627 630 628 631 </script> 629 630 631 632 632 633 634 635 633 636 <iframe id="uploadTarget" name="uploadTarget" src="" style="width:0px;height:0px;border:0" onload="sent()"></iframe> 634 637 … … 655 658 <form action="%(saveBackgroundURL)s" method="POST" ENCTYPE="multipart/form-data" onsubmit="sending()" target="uploadTarget"> 656 659 <td height="20px" NOWRAP align="left" colspan="3"> 657 <input name="file" size="58" type="file">660 <input name="file" size="58" type="file"> 658 661 <input class="btn" value="Send File" type="submit"> 659 662 <input class="btn" type="button" value="Remove background" onclick="removeBackground()"> 660 663 </td> 661 <td width="100%%" align="left" colspan="4">664 <td width="100%%" align="left" colspan="4"> 662 665 <img id="loadingIcon" src=%(loadingIconURL)s width="20px" height="20px" style="display:none;"> 663 </td>666 </td> 664 667 </tr> 665 668 <tr> 666 669 <td></td> 667 670 <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> 681 684 </td> 682 685 <td></td> … … 816 819 <option>Times New Roman</option> 817 820 <option>Courier</option> 818 </optgroup> 821 </optgroup> 819 822 <optgroup label="Special Character Fonts"> 820 823 <option>LinuxLibertine</option> … … 939 942 </tbody> 940 943 </table> 941 944 942 945 <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"> 945 948 </form> 946 949 947 950 <!-- 948 951 <table id='test' width="200" height="200" border="1" onclick="alert(Element.getDimensions(this).width);this.width = parseInt(this.width) + 10; return false"> … … 952 955 953 956 <script type="text/javascript"> 954 957 955 958 // We load the template if we are editing a template 956 959 if (%(editingTemplate)s) { … … 968 971 templateDimensions = new Dimensions(525,742); //put here the initial dimensions of templateDiv 969 972 } 970 973 971 974 previousTemplateDimensions = new Dimensions(0,0) 972 975 973 976 $('poster width').value = templateDimensions.width / pixelsPerCm; 974 977 $('poster height').value = templateDimensions.height / pixelsPerCm; 975 978 976 979 // This function initialises the rulers 977 980 updateRulers(); 978 981 979 982 // This function displays the items, if any have been loaded, on the screen 980 983 displayItems() 981 984 982 985 if (%(editingTemplate)s && %(hasBackground)s) { 983 986 backgroundId = %(backgroundId)s
Note: See TracChangeset
for help on using the changeset viewer.
