From 97936e9f12293eb9db389a88216031ef14d833d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 31 Mar 2014 15:22:41 +0200 Subject: [PATCH 01/16] =?utf8?q?Mise=20=C3=A0=20jour=20de=20la=20barre=20d?= =?utf8?q?'adresse=20sur=20changement=20de=20photo=20(history.pushState).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/photo_film_viewer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index ff6d619..70f8b99 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -94,7 +94,7 @@ FilmSlider.prototype.resizeSlider = function(evt) { var sliderWidth = filmBarWidth * sliderRatio; this.rail.style.width = filmBarWidth + 'px'; this.rail.style.display = 'block'; - this.rail.style.visibility = 'visible'; + this.rail.style.visibility = 'visible'; if (sliderRatio < 1) { this.slider.style.width = Math.round(sliderWidth) + 'px'; this.slider.style.visibility = 'visible'; @@ -103,7 +103,7 @@ FilmSlider.prototype.resizeSlider = function(evt) { this.slider.style.visibility = 'hidden'; } - this.winSize = {'width' : getWindowWidth(), + this.winSize = {'width' : getWindowWidth(), 'height' : getWindowHeight()}; this.maxRightPosition = filmBarWidth - sliderWidth this.sliderSpeedRatio = - (filmBarWidth - sliderWidth) / (filmWidth - filmBarWidth); @@ -305,12 +305,13 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { disableDefault(evt); disablePropagation(evt); target.blur(); + history.pushState(target.href, '', target.href); var imgBaseUrl = target.href; var canonicalImgUrl; if (this.ctxUrlTranslation[0]) canonicalImgUrl = imgBaseUrl.replace(this.ctxUrlTranslation[0], - this.ctxUrlTranslation[1]); + this.ctxUrlTranslation[1]); else canonicalImgUrl = imgBaseUrl; -- 2.20.1 From 92be47053b7b97d7fa74cbf4dbe2accd89fe27c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Tue, 1 Apr 2014 16:17:15 +0200 Subject: [PATCH 02/16] Maniaquerie. --- skins/photo_info.pt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skins/photo_info.pt b/skins/photo_info.pt index 69c56be..4219c2d 100644 --- a/skins/photo_info.pt +++ b/skins/photo_info.pt @@ -32,7 +32,7 @@ Dimensions - width x height + width × height \ No newline at end of file -- 2.20.1 From 55fd3ac8a0827cd48596d41112dfe92d3a8c6dff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Tue, 1 Apr 2014 17:38:20 +0200 Subject: [PATCH 03/16] =?utf8?q?Ajout=20script=20de=20reg=C3=A9n=C3=A9rati?= =?utf8?q?on=20des=20photos=20(vigettes,=20retailles,=20zoom).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- _zctl/regenPhotos.py | 134 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 _zctl/regenPhotos.py diff --git a/_zctl/regenPhotos.py b/_zctl/regenPhotos.py new file mode 100644 index 0000000..a6f5596 --- /dev/null +++ b/_zctl/regenPhotos.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +from argparse import ArgumentParser +from AccessControl import getSecurityManager +from Testing.makerequest import makerequest +from zope.globalrequest import setRequest +from zope.site.hooks import setSite +from ZODB.POSException import ConflictError +from Products.Photo.cache import aggregateIndex +import transaction + +GET_RI_SIGNATURE = (('size', 1), ('keepAspectRatio', 2)) + + +def main(app, portal_path, userid) : + portal = app.unrestrictedTraverse(portal_path) + portal = makerequest(portal) + setRequest(portal.REQUEST) + setSite(portal) + user = portal.acl_users.getUser(userid) + sm = getSecurityManager() + sm._context.user = user + + thumb_size = portal.thumb_size + + ctool = portal.portal_catalog + brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) + + while brains : + try : + for i, b in enumerate(brains) : + path = b.getPath() + p = b._unrestrictedGetObject() + + print '%d/%d: %s' % (i+1, len(brains), p.absolute_url()) + + try : + if hasattr(p, 'thumbnail'): + print 'make thumbnail' + delattr(p, 'thumbnail') + p.thumb_width = thumb_size + p.thumb_height = thumb_size + p.makeThumbnail() + transaction.commit() + + for size in ((500, 500), (600, 600), (800, 800)) : + index = aggregateIndex(GET_RI_SIGNATURE, (size, True)) + if p._methodResultsCache['_getResizedImage'].has_key(index) : + del p._methodResultsCache['_getResizedImage'][index] + print 'resize at', size + p._getResizedImage(size, True) + transaction.commit() + + zMin = p.tiles_min_zoom + zMax = p.tiles_max_zoom + zStep = p.tiles_step_zoom + levels = range(zMin, zMax + zStep, zStep) + zooms = [l/100. for l in levels] + + if p.tileGenerationLock.locked() : + print 'skip %s: already tiling.' % p.absolute_url() + continue + + p.tileGenerationLock.acquire() + try : + ppm = p._getPPM() + for zoom in zooms : + + print 'tiling at', zoom + if zoom < 1 : + rppm = ppm.resize(ratio=zoom) + else : + rppm = ppm + p._makeTilesAt(zoom, rppm) + del rppm + transaction.commit() + finally : + try : del ppm + except UnboundLocalError : pass + p.tileGenerationLock.release() + + try : + delattr(p, '_v__methodResultsCache') + except AttributeError: + pass + + # _skipDict[path] = True + # skipFile.write('%s\n' % path) + + except ConflictError : + print 'Resync after ZODB ConflicError' + transaction.abort() + portal._p_jar.sync() + brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) + # brains = [b for b in brains if not toSkip(b.getPath())] + break + + except KeyboardInterrupt: + raise + else : + p.tiles_available = 1 + + p.reindexObject(idxs=['tiles_available']) + transaction.commit() + else : + print 'queue finished.' + break + + except KeyError : + print 'Objects deleted during processing' + portal._p_jar.sync() + brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) + # brains = [b for b in brains if not toSkip(b.getPath())] + + except ConflictError : + print 'Resync after ZODB ConflicError' + transaction.abort() + portal._p_jar.sync() + brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) + # brains = [b for b in brains if not toSkip(b.getPath())] + + except KeyboardInterrupt: + # skipFile.close() + break + + + + +if __name__ == '__main__': + parser = ArgumentParser(description="Thumbnails regeneration") + parser.add_argument('portal_path', help='portal object path') + parser.add_argument('userid', help='zope user id') + args = parser.parse_args() + portal_path, userid = args.portal_path, args.userid + main(app, portal_path, userid) \ No newline at end of file -- 2.20.1 From 8a525218303715fcf1b977a459947b5b899d9640 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 2 Apr 2014 10:22:14 +0200 Subject: [PATCH 04/16] =?utf8?q?Ajout=20de=20l'argument=20=C2=AB=C2=A0skip?= =?utf8?q?file=C2=A0=C2=BB=20qui=20permet=20de=20marquer=20de=20mani=C3=A8?= =?utf8?q?re=20externe=20les=20=C3=A9l=C3=A9ments=20d=C3=A9j=C3=A0=20trait?= =?utf8?q?=C3=A9s=20(pour=20ne=20pas=20avoir=20=C3=A0=20les=20reg=C3=A9n?= =?utf8?q?=C3=A9rer=20si=20plantage=20intempestif).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- _zctl/regenPhotos.py | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/_zctl/regenPhotos.py b/_zctl/regenPhotos.py index a6f5596..2dcf8f5 100644 --- a/_zctl/regenPhotos.py +++ b/_zctl/regenPhotos.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from argparse import ArgumentParser +import os from AccessControl import getSecurityManager from Testing.makerequest import makerequest from zope.globalrequest import setRequest @@ -11,7 +12,7 @@ import transaction GET_RI_SIGNATURE = (('size', 1), ('keepAspectRatio', 2)) -def main(app, portal_path, userid) : +def main(app, portal_path, userid, skipfile) : portal = app.unrestrictedTraverse(portal_path) portal = makerequest(portal) setRequest(portal.REQUEST) @@ -20,10 +21,23 @@ def main(app, portal_path, userid) : sm = getSecurityManager() sm._context.user = user - thumb_size = portal.thumb_size + absSkipFilePath = os.path.abspath(os.path.expanduser(skipfile)) + if os.path.exists(absSkipFilePath) : + skipFile = open(absSkipFilePath, 'r+') + skip = filter(None, skipFile.readlines()) + _skipDict = dict([(path.strip(), True) for path in skip]) + del skip + else : + skipFile = open(absSkipFilePath, 'w') + _skipDict = {} + + toSkip = _skipDict.has_key + + thumb_size = portal.thumb_size ctool = portal.portal_catalog brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) + brains = [b for b in brains if not toSkip(b.getPath())] while brains : try : @@ -83,15 +97,15 @@ def main(app, portal_path, userid) : except AttributeError: pass - # _skipDict[path] = True - # skipFile.write('%s\n' % path) + _skipDict[path] = True + skipFile.write('%s\n' % path) except ConflictError : print 'Resync after ZODB ConflicError' transaction.abort() portal._p_jar.sync() brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) - # brains = [b for b in brains if not toSkip(b.getPath())] + brains = [b for b in brains if not toSkip(b.getPath())] break except KeyboardInterrupt: @@ -109,19 +123,19 @@ def main(app, portal_path, userid) : print 'Objects deleted during processing' portal._p_jar.sync() brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) - # brains = [b for b in brains if not toSkip(b.getPath())] + brains = [b for b in brains if not toSkip(b.getPath())] except ConflictError : print 'Resync after ZODB ConflicError' transaction.abort() portal._p_jar.sync() brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) - # brains = [b for b in brains if not toSkip(b.getPath())] + brains = [b for b in brains if not toSkip(b.getPath())] except KeyboardInterrupt: - # skipFile.close() break - + + skipFile.close() @@ -129,6 +143,13 @@ if __name__ == '__main__': parser = ArgumentParser(description="Thumbnails regeneration") parser.add_argument('portal_path', help='portal object path') parser.add_argument('userid', help='zope user id') + parser.add_argument('--skipfile', + type=str, + required=False, + default='skipfile.txt', + help="File that log work's progress.") args = parser.parse_args() - portal_path, userid = args.portal_path, args.userid - main(app, portal_path, userid) \ No newline at end of file + main(app, + args.portal_path, + args.userid, + args.skipfile) \ No newline at end of file -- 2.20.1 From 2ef5bb98238c65fc8927d95cc97bd2fa0de3142c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 2 Apr 2014 10:33:59 +0200 Subject: [PATCH 05/16] Tabs -> spaces Bugfix localisation / getattr. --- skins/lightboxcontext.py | 110 ++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/skins/lightboxcontext.py b/skins/lightboxcontext.py index d1d7529..d031b1a 100644 --- a/skins/lightboxcontext.py +++ b/skins/lightboxcontext.py @@ -19,90 +19,91 @@ resp = req.RESPONSE selDict = req.SESSION.get('objects_selection_dict', {}) if traverse_subpath[-1] == 'photo_view_ajax' : - photoSubPath = traverse_subpath[:-1] - ajax = True + photoSubPath = traverse_subpath[:-1] + ajax = True else : - photoSubPath = traverse_subpath - ajax = False - + photoSubPath = traverse_subpath + ajax = False + photo = portal.restrictedTraverse(photoSubPath) photouid = uidh.register(photo) lightboxUids = context.getUidList() if pptool : - buyable = bool(pptool.getPrintingOptionsFor(photo)) - sd = context.session_data_manager.getSessionData(create=1) - cart = sd.get('cart', None) - if cart and cart.locked : - buyable = False + buyable = bool(pptool.getPrintingOptionsFor(photo)) + sd = context.session_data_manager.getSessionData(create=1) + cart = sd.get('cart', None) + if cart and cart.locked : + buyable = False else : - buyable = False + buyable = False options['buyable'] = buyable infos = [] posOfPhoto = 0 if ajax == True : - try : posOfPhoto = lightboxUids.index(photouid) - except ValueError : pass - options['backToContextUrl'] = '%s?b_start:int=%s' % (lightboxUrl, posOfPhoto/bsize*bsize) - relPhotoPath = '/'.join(photo.getPhysicalPath()[portalDepth:]) - lastBcUrl = '%s/lightboxcontext/%s' % (lightboxUrl, relPhotoPath) - options['lastBcUrl'] = lastBcUrl - meth = getattr(photo, 'photo_view_ajax_template') - return meth(**options) + try : posOfPhoto = lightboxUids.index(photouid) + except ValueError : pass + options['backToContextUrl'] = '%s?b_start:int=%s' % (lightboxUrl, posOfPhoto/bsize*bsize) + relPhotoPath = '/'.join(photo.getPhysicalPath()[portalDepth:]) + lastBcUrl = '%s/lightboxcontext/%s' % (lightboxUrl, relPhotoPath) + options['lastBcUrl'] = lastBcUrl + app = context.restrictedTraverse('/') + meth = app.restrictedTraverse(photo.getPhysicalPath() + ('photo_view_ajax_template',)) + return meth(**options) for i, uid in enumerate(lightboxUids) : - b = uidh.getBrain(uid) - size = b.getThumbnailSize - size = {'width':int(size['width']/2.0), 'height':int(size['height']/2.0)} - - className = selDict.has_key(uid) and 'selected' or '' - if uid == photouid : - className = ('%s displayed' % className).lstrip() - posOfPhoto = i - - relPhotoPath = '/'.join(b.getPath().split('/')[portalDepth:]) - href = '%s/lightboxcontext/%s' % (lightboxUrl, relPhotoPath) - - d = {'src': '%s/getThumbnail' % b.getURL() - ,'href': href - ,'thumbSize': size - ,'title' : b.Title - ,'className': className - , 'index': i - } - infos.append(d) + b = uidh.getBrain(uid) + size = b.getThumbnailSize + size = {'width':int(size['width']/2.0), 'height':int(size['height']/2.0)} + + className = selDict.has_key(uid) and 'selected' or '' + if uid == photouid : + className = ('%s displayed' % className).lstrip() + posOfPhoto = i + + relPhotoPath = '/'.join(b.getPath().split('/')[portalDepth:]) + href = '%s/lightboxcontext/%s' % (lightboxUrl, relPhotoPath) + + d = {'src': '%s/getThumbnail' % b.getURL() + ,'href': href + ,'thumbSize': size + ,'title' : b.Title + ,'className': className + , 'index': i + } + infos.append(d) if posOfPhoto > 0 : - previous = infos[posOfPhoto - 1]['href'] + previous = infos[posOfPhoto - 1]['href'] else : - previous = infos[0]['href'] + previous = infos[0]['href'] if posOfPhoto < len(infos) -1 : - next = infos[posOfPhoto + 1]['href'] + next = infos[posOfPhoto + 1]['href'] else : - next = infos[-1]['href'] + next = infos[-1]['href'] contextInfos = {'infos':infos, - 'isSelected': selDict.has_key(photouid), - 'backUrl' : '%s?b_start:int=%s' % (lightboxUrl, posOfPhoto/bsize*bsize), - 'index' : posOfPhoto, - 'previous' : previous, - 'next' : next, - 'reBaseCtxUrl':'/^%s/' % ('%s/lightboxcontext/' % lightboxUrl).replace('/', '\/'), - 'canonicalUrl': "'%s/'" % portal_url} + 'isSelected': selDict.has_key(photouid), + 'backUrl' : '%s?b_start:int=%s' % (lightboxUrl, posOfPhoto/bsize*bsize), + 'index' : posOfPhoto, + 'previous' : previous, + 'next' : next, + 'reBaseCtxUrl':'/^%s/' % ('%s/lightboxcontext/' % lightboxUrl).replace('/', '\/'), + 'canonicalUrl': "'%s/'" % portal_url} options['contextInfos'] = contextInfos # breadcrumbs customization breadcrumbs = context.breadcrumbs() breadcrumbs.append( - {'id' : photo.getId() - ,'title' : photo.title_or_id() - , 'url' : req.ACTUAL_URL} + {'id' : photo.getId() + ,'title' : photo.title_or_id() + , 'url' : req.ACTUAL_URL} ) options['breadcrumbs'] = breadcrumbs @@ -110,5 +111,6 @@ options['breadcrumbs'] = breadcrumbs ti = photo.getTypeInfo() method_id = ti.queryMethodID('view', context=photo) -meth = getattr(photo, method_id) +app = context.restrictedTraverse('/') +meth = app.restrictedTraverse(photo.getPhysicalPath() + (method_id,)) return meth(req, resp, **options) -- 2.20.1 From 0971623cf1c52edd330de6dd62a455be497f4ac6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 2 Apr 2014 10:56:23 +0200 Subject: [PATCH 06/16] tabs -> spaces --- skins/selectioncontext.py | 146 +++++++++++++++++++------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/skins/selectioncontext.py b/skins/selectioncontext.py index f042b6d..36727f6 100644 --- a/skins/selectioncontext.py +++ b/skins/selectioncontext.py @@ -18,116 +18,116 @@ toUrl = req.physicalPathToURL resp = req.RESPONSE if traverse_subpath[-1] == 'photo_view_ajax' : - photoSubPath = traverse_subpath[:-1] - ajax = True + photoSubPath = traverse_subpath[:-1] + ajax = True else : - photoSubPath = traverse_subpath - ajax = False - + photoSubPath = traverse_subpath + ajax = False + photo = portal.restrictedTraverse(photoSubPath) photouid = uidh.register(photo) lightboxpath = req.SESSION.get('lightboxpath', None) selectionIsLightbox = False if lightboxpath is None : - selection = req.SESSION.get('objects_selection', []) + selection = req.SESSION.get('objects_selection', []) else : - try : - lightbox = portal.restrictedTraverse(lightboxpath) - selection = lightbox.getUidList() - selectionIsLightbox = True - except: - req.SESSION.set('lightboxpath', None) - selection = req.SESSION.get('objects_selection', []) + try : + lightbox = portal.restrictedTraverse(lightboxpath) + selection = lightbox.getUidList() + selectionIsLightbox = True + except: + req.SESSION.set('lightboxpath', None) + selection = req.SESSION.get('objects_selection', []) if pptool : - buyable = bool(pptool.getPrintingOptionsFor(photo)) - sd = context.session_data_manager.getSessionData(create=1) - cart = sd.get('cart', None) - if cart and cart.locked : - buyable = False + buyable = bool(pptool.getPrintingOptionsFor(photo)) + sd = context.session_data_manager.getSessionData(create=1) + cart = sd.get('cart', None) + if cart and cart.locked : + buyable = False else : - buyable = False + buyable = False options['buyable'] = buyable infos = [] posOfPhoto = 0 if ajax == True : - try : posOfPhoto = selection.index(photouid) - except ValueError : pass - options['backToContextUrl'] = '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize) - photoPath = list(photo.getPhysicalPath()) - photoPath.insert(portalDepth, 'selectioncontext') - options['lastBcUrl'] = toUrl(photoPath) - meth = getattr(photo, 'photo_view_ajax_template') - return meth(req, resp, **options) + try : posOfPhoto = selection.index(photouid) + except ValueError : pass + options['backToContextUrl'] = '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize) + photoPath = list(photo.getPhysicalPath()) + photoPath.insert(portalDepth, 'selectioncontext') + options['lastBcUrl'] = toUrl(photoPath) + meth = getattr(photo, 'photo_view_ajax_template') + return meth(req, resp, **options) for i, uid in enumerate(selection) : - b = uidh.getBrain(uid) - size = b.getThumbnailSize - size = {'width':int(size['width']/2.0), 'height':int(size['height']/2.0)} - - if uid == photouid : - className = 'selected displayed' - posOfPhoto = i - else : - className = 'selected' - - path = b.getPath().split('/') - path.insert(portalDepth, 'selectioncontext') - - d = {'src': '%s/getThumbnail' % b.getURL() - ,'href': toUrl(path) - ,'thumbSize': size - ,'title' : b.Title - ,'className': className - , 'index': i - } - infos.append(d) + b = uidh.getBrain(uid) + size = b.getThumbnailSize + size = {'width':int(size['width']/2.0), 'height':int(size['height']/2.0)} + + if uid == photouid : + className = 'selected displayed' + posOfPhoto = i + else : + className = 'selected' + + path = b.getPath().split('/') + path.insert(portalDepth, 'selectioncontext') + + d = {'src': '%s/getThumbnail' % b.getURL() + ,'href': toUrl(path) + ,'thumbSize': size + ,'title' : b.Title + ,'className': className + , 'index': i + } + infos.append(d) if posOfPhoto > 0 : - previous = infos[posOfPhoto - 1]['href'] + previous = infos[posOfPhoto - 1]['href'] else : - previous = infos[0]['href'] + previous = infos[0]['href'] if posOfPhoto < len(infos) -1 : - next = infos[posOfPhoto + 1]['href'] + next = infos[posOfPhoto + 1]['href'] else : - next = infos[-1]['href'] + next = infos[-1]['href'] contextInfos = {'infos':infos, - 'isSelected':True, - 'backUrl' : '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize), - 'index' : posOfPhoto, - 'previous' : previous, - 'next' : next, - 'reBaseCtxUrl':'/^%s/' % (portal_url+'/selectioncontext/').replace('/', '\/'), - 'canonicalUrl': "'%s/'" % portal_url} + 'isSelected':True, + 'backUrl' : '%s?b_start:int=%s' % (selectionUrl, posOfPhoto/bsize*bsize), + 'index' : posOfPhoto, + 'previous' : previous, + 'next' : next, + 'reBaseCtxUrl':'/^%s/' % (portal_url+'/selectioncontext/').replace('/', '\/'), + 'canonicalUrl': "'%s/'" % portal_url} options['contextInfos'] = contextInfos # breadcrumbs customization if selectionIsLightbox : - lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) + lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) else : - lastBcTitle = _('My selection') + lastBcTitle = _('My selection') breadcrumbs = [ - { 'id' : 'root' - , 'title' : portal.title - , 'url' : portal_url}, - - {'id' : 'selection_view' - ,'title' : lastBcTitle - , 'url' : selectionUrl}, - - {'id' : photo.getId() - ,'title' : photo.title_or_id() - , 'url' : req.ACTUAL_URL} - ] + { 'id' : 'root' + , 'title' : portal.title + , 'url' : portal_url}, + + {'id' : 'selection_view' + ,'title' : lastBcTitle + , 'url' : selectionUrl}, + + {'id' : photo.getId() + ,'title' : photo.title_or_id() + , 'url' : req.ACTUAL_URL} + ] options['breadcrumbs'] = breadcrumbs -- 2.20.1 From b7206bf3b2e6b8d380e30e646c366beed91b88b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 2 Apr 2014 11:04:14 +0200 Subject: [PATCH 07/16] =?utf8?q?getattr=20->=20restrictedTraverse=C2=A0:?= =?utf8?q?=20si=20on=20utilise=20geattr=20au=20lieu=20de=20restrictedTrave?= =?utf8?q?rse,=20alors=20la=20variable=20globale=20=C2=AB=C2=A0request?= =?utf8?q?=C2=A0=C2=BB=20dans=20une=20zpt=20est=20la=20cha=C3=AEne=20de=20?= =?utf8?q?caract=C3=A8re=20"Special=20Object=20Used=20to=20Force=20Acquisi?= =?utf8?q?tion"=20au=20lieu=20d'=C3=AAtre=20une=20instance=20de=20HTTPRequ?= =?utf8?q?est=20:-/.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/selectioncontext.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skins/selectioncontext.py b/skins/selectioncontext.py index 36727f6..8539a4e 100644 --- a/skins/selectioncontext.py +++ b/skins/selectioncontext.py @@ -60,7 +60,8 @@ if ajax == True : photoPath = list(photo.getPhysicalPath()) photoPath.insert(portalDepth, 'selectioncontext') options['lastBcUrl'] = toUrl(photoPath) - meth = getattr(photo, 'photo_view_ajax_template') + app = context.restrictedTraverse('/') + meth = app.restrictedTraverse(photo.getPhysicalPath() + ('photo_view_ajax_template',)) return meth(req, resp, **options) @@ -134,5 +135,6 @@ options['breadcrumbs'] = breadcrumbs ti = photo.getTypeInfo() method_id = ti.queryMethodID('view', context=photo) -meth = getattr(photo, method_id) +app = context.restrictedTraverse('/') +meth = app.restrictedTraverse(photo.getPhysicalPath() + (method_id,)) return meth(req, resp, **options) -- 2.20.1 From a92dc673fbc741d25d91fdc6cc481012fc4b33f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 09:54:55 +0200 Subject: [PATCH 08/16] =?utf8?q?Bugfix=C2=A0:=20quand=20on=20a=20une=20pr?= =?utf8?q?=C3=A9sentation=20sans=20breadcrumbs,=20il=20ne=20faut=20pas=20q?= =?utf8?q?ue=20=C3=A7a=20plante.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/photo_film_viewer.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index 70f8b99..bda6428 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -1,5 +1,5 @@ /* -* © 2008 Benoît Pin – Centre de recherche en informatique – École des mines de Paris +* © 2008-2014 Benoît Pin – Centre de recherche en informatique – MINES ParisTech * http://plinn.org * Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/ * @@ -36,10 +36,16 @@ FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { this.buttons = new Array(); this.toolbar = toolbar; - var bcElements = breadcrumbs.getElementsByTagName('a'); - this.lastBCElement = bcElements[bcElements.length-1]; - var imgSrcParts = image.src.split('/'); - this.lastBCElement.innerHTML = imgSrcParts[imgSrcParts.length-2]; + if (breadcrumbs) { + var bcElements = breadcrumbs.getElementsByTagName('a'); + this.lastBCElement = bcElements[bcElements.length-1]; + var imgSrcParts = image.src.split('/'); + this.lastBCElement.innerHTML = imgSrcParts[imgSrcParts.length-2]; + this.hasBreadcrumbs = true; + } + else { + this.hasBreadcrumbs = false; + } var buttons = toolbar.getElementsByTagName('img'); var b, name; @@ -589,7 +595,7 @@ FilmSlider.prototype.populateViewer = function(req) { switch (element.nodeName) { case 'fragment' : var dest = document.getElementById(element.getAttribute('id')); - dest.innerHTML = element.firstChild.nodeValue; + if (dest) { dest.innerHTML = element.firstChild.nodeValue; } break; case 'imageattributes' : var link = this.buttons['back_to_portfolio'].parentNode; @@ -601,8 +607,8 @@ FilmSlider.prototype.populateViewer = function(req) { else if(buyable == 'False') link.className = 'hidden'; this.image.alt = element.getAttribute('alt'); - this.lastBCElement.href = element.getAttribute('lastBcUrl'); - this.lastBCElement.innerHTML = element.getAttribute('img_id'); + this.updateBreadcrumbs(element.getAttribute('lastBcUrl'), + element.getAttribute('img_id')); break; } } @@ -620,6 +626,13 @@ FilmSlider.prototype.refreshImage = function() { this.image.parentNode.className = ''; }; +FilmSlider.prototype.updateBreadcrumbs = function(url, title) { + if (this.hasBreadcrumbs) { + this.lastBCElement.href = element.getAttribute('lastBcUrl'); + this.lastBCElement.innerHTML = element.getAttribute('img_id'); + } +}; + FilmSlider.prototype.startSlideShow = function() { this.slideShowSlide = this.pendingSlideShowSlide = this.selectedSlide; return this.slideShowSlide.href; -- 2.20.1 From de796b93caf39451cab93560b5978620a21db2f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 10:13:00 +0200 Subject: [PATCH 09/16] jslint --- skins/photo_film_viewer.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index bda6428..cfd7df5 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -20,7 +20,7 @@ FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { var thisSlider = this; this.filmBar = filmBar; var film = filmBar.firstChild; - if (film.nodeType == 3) + if (film.nodeType === 3) film = film.nextSibling; this.film = film; this.slider = slider; @@ -209,12 +209,12 @@ FilmSlider.prototype.loadSibling = function(previous) { var slide = null; if (previous) { slide = this.selectedSlide.parentNode.previousSibling; - if (slide && slide.nodeType==3) + if (slide && slide.nodeType===3) slide = slide.previousSibling; } else { slide = this.selectedSlide.parentNode.nextSibling; - if (slide && slide.nodeType==3) + if (slide && slide.nodeType===3) slide = slide.nextSibling; } @@ -303,7 +303,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { if (target.tagName != 'A') return; else { - if (this.viewMode == 'full') { + if (this.viewMode === 'full') { this.mosaique.unload(); this.mosaique = null; this.viewMode = 'medium'; @@ -335,7 +335,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { var toggleSelectionBtn = this.buttons['toggle_selection']; var toggleSelectionLink = toggleSelectionBtn.parentNode; - this.selectedSlideInSelection = (target.className=='selected'); + this.selectedSlideInSelection = (target.className==='selected'); if (this.selectedSlideInSelection) { toggleSelectionBtn.src = portal_url() + '/unselect_flag_btn.gif'; toggleSelectionBtn.alt = toggleSelectionLink.title = 'Retirer de la sélection'; @@ -379,7 +379,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { break; case 4 : hideProgressImage(); - if (req.status == '200') + if (req.status === '200') thisFS.populateViewer(req); else //window.location.href = target.href; @@ -399,7 +399,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { for (i in classes) { name = classes[i]; - if (name == 'displayed') + if (name === 'displayed') continue; else newClasses.push(name); @@ -418,7 +418,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { FilmSlider.prototype.toolbarClickHandler = function(evt) { var target = getTargetedObject(evt); - if(target.tagName == 'IMG' && target.getAttribute('name')){ + if(target.tagName === 'IMG' && target.getAttribute('name')){ switch(target.getAttribute('name')) { case 'previous' : disableDefault(evt); @@ -440,7 +440,7 @@ FilmSlider.prototype.toolbarClickHandler = function(evt) { disableDefault(evt); disablePropagation(evt); target.parentNode.blur(); - if (this.viewMode == 'full') { + if (this.viewMode === 'full') { this.mosaique.unload(); this.mosaique = null; this.viewMode = 'medium'; @@ -516,7 +516,7 @@ FilmSlider.prototype.toolbarClickHandler = function(evt) { disableDefault(evt); disablePropagation(evt); target.blur(); - if (this.viewMode == 'full') { + if (this.viewMode === 'full') { this.mosaique.unload(); this.mosaique = null; this.viewMode = 'medium'; @@ -576,7 +576,7 @@ FilmSlider.prototype.keyDownHandler = function(evt) { FilmSlider.prototype.keyPressHandler = function(evt) { var target = getTargetedObject(evt); - if (target.tagName == 'INPUT' || target.tagName== 'TEXTAREA') + if (target.tagName === 'INPUT' || target.tagName=== 'TEXTAREA') return; var evt = getEventObject(evt); var charPress = String.fromCharCode((evt.keyCode) ? evt.keyCode : evt.which); @@ -602,9 +602,9 @@ FilmSlider.prototype.populateViewer = function(req) { link.href = element.getAttribute('backToContextUrl'); link = this.buttons['show_buyable'].parentNode; var buyable = element.getAttribute('buyable'); - if(buyable == 'True') + if(buyable === 'True') link.className = null; - else if(buyable == 'False') + else if(buyable === 'False') link.className = 'hidden'; this.image.alt = element.getAttribute('alt'); this.updateBreadcrumbs(element.getAttribute('lastBcUrl'), @@ -640,7 +640,7 @@ FilmSlider.prototype.startSlideShow = function() { FilmSlider.prototype.slideShowNext = function() { var nextSlide = this.slideShowSlide.parentNode.nextSibling; - if (nextSlide && nextSlide.nodeType==3) + if (nextSlide && nextSlide.nodeType===3) nextSlide = nextSlide.nextSibling; if (nextSlide) { @@ -651,7 +651,7 @@ FilmSlider.prototype.slideShowNext = function() { else { var row = this.slideShowSlide.parentNode.parentNode; var first = row.firstChild; - if (first.nodeType==3) + if (first.nodeType===3) first = first.nextSibling; this.pendingSlideShowSlide = first.getElementsByTagName('a')[0]; return this.pendingSlideShowSlide.href; @@ -660,7 +660,7 @@ FilmSlider.prototype.slideShowNext = function() { FilmSlider.prototype.slideShowPrevious = function() { var previousSlide = this.slideShowSlide.parentNode.previousSibling; - if (previousSlide && previousSlide.nodeType==3) + if (previousSlide && previousSlide.nodeType===3) previousSlide = previousSlide.previousSibling; if (previousSlide) { @@ -671,7 +671,7 @@ FilmSlider.prototype.slideShowPrevious = function() { else { var row = this.slideShowSlide.parentNode.parentNode; var last = row.lastChild; - if (last.nodeType==3) + if (last.nodeType===3) last = last.previousSibling; this.pendingSlideShowSlide = last.getElementsByTagName('a')[0]; return this.pendingSlideShowSlide.href; -- 2.20.1 From 7ac0ca74ce1435919f21b6a0e5b28ba40cf00780 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 10:27:30 +0200 Subject: [PATCH 10/16] jslint --- skins/photo_film_viewer.js | 121 ++++++++++++++----------------------- 1 file changed, 47 insertions(+), 74 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index cfd7df5..edf2069 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -20,8 +20,7 @@ FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { var thisSlider = this; this.filmBar = filmBar; var film = filmBar.firstChild; - if (film.nodeType === 3) - film = film.nextSibling; + if (film.nodeType === 3) { film = film.nextSibling; } this.film = film; this.slider = slider; this.rail = slider.parentNode; @@ -34,7 +33,7 @@ FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { this.stretchable = image.parentNode; this.viewMode = 'medium'; - this.buttons = new Array(); + this.buttons = []; this.toolbar = toolbar; if (breadcrumbs) { var bcElements = breadcrumbs.getElementsByTagName('a'); @@ -48,12 +47,11 @@ FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { } var buttons = toolbar.getElementsByTagName('img'); - var b, name; - for (var i=0 ; i this.winSize['width'] || y < 0 || y > this.winSize['height'] - ){ + ) { this.mouseUpHandler(evt); } }; FilmSlider.prototype.thumbnailClickHandler = function(evt) { var target = getTargetedObject(evt); - while (target.tagName != 'A' && target != this.filmBar) + while (target.tagName !== 'A' && target !== this.filmBar) target = target.parentNode; - if (target.tagName != 'A') - return; + if (target.tagName !== 'A') { return; } else { if (this.viewMode === 'full') { this.mosaique.unload(); @@ -311,15 +295,15 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { disableDefault(evt); disablePropagation(evt); target.blur(); - history.pushState(target.href, '', target.href); + history.pushState(target.href, '', target.href); var imgBaseUrl = target.href; var canonicalImgUrl; - if (this.ctxUrlTranslation[0]) + if (this.ctxUrlTranslation[0]) { canonicalImgUrl = imgBaseUrl.replace(this.ctxUrlTranslation[0], this.ctxUrlTranslation[1]); - else - canonicalImgUrl = imgBaseUrl; + } + else { canonicalImgUrl = imgBaseUrl; } var ajaxUrl = imgBaseUrl + '/photo_view_ajax'; var thisFS = this; @@ -379,11 +363,10 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { break; case 4 : hideProgressImage(); - if (req.status === '200') - thisFS.populateViewer(req); - else - //window.location.href = target.href; - console.error(ajaxUrl); + if (req.status === '200') { thisFS.populateViewer(req); } + // else + // //window.location.href = target.href; + // console.error(ajaxUrl); }; }; @@ -394,15 +377,13 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { // update old displayed slide className var className = this.selectedSlide.className; var classes = className.split(' '); - var newClasses = new Array(); - var name; + var newClasses = []; + var name, i; for (i in classes) { name = classes[i]; - if (name === 'displayed') - continue; - else - newClasses.push(name); + if (name === 'displayed') { continue; } + else { newClasses.push(name); } } this.selectedSlide.className = newClasses.join(' ') @@ -418,7 +399,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { FilmSlider.prototype.toolbarClickHandler = function(evt) { var target = getTargetedObject(evt); - if(target.tagName === 'IMG' && target.getAttribute('name')){ + if(target.tagName === 'IMG' && target.getAttribute('name')) { switch(target.getAttribute('name')) { case 'previous' : disableDefault(evt); @@ -531,7 +512,7 @@ FilmSlider.prototype.toolbarClickHandler = function(evt) { }; -if(browser.isDOM2Event){ +if(browser.isDOM2Event) { if (browser.isAppleWebKit) { FilmSlider.prototype.mouseWheelHandler = function(evt) { disableDefault(evt); @@ -576,8 +557,7 @@ FilmSlider.prototype.keyDownHandler = function(evt) { FilmSlider.prototype.keyPressHandler = function(evt) { var target = getTargetedObject(evt); - if (target.tagName === 'INPUT' || target.tagName=== 'TEXTAREA') - return; + if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') { return; } var evt = getEventObject(evt); var charPress = String.fromCharCode((evt.keyCode) ? evt.keyCode : evt.which); switch(charPress) { @@ -602,10 +582,8 @@ FilmSlider.prototype.populateViewer = function(req) { link.href = element.getAttribute('backToContextUrl'); link = this.buttons['show_buyable'].parentNode; var buyable = element.getAttribute('buyable'); - if(buyable === 'True') - link.className = null; - else if(buyable === 'False') - link.className = 'hidden'; + if(buyable === 'True') { link.className = null; } + else if(buyable === 'False') { link.className = 'hidden'; } this.image.alt = element.getAttribute('alt'); this.updateBreadcrumbs(element.getAttribute('lastBcUrl'), element.getAttribute('img_id')); @@ -620,10 +598,8 @@ FilmSlider.prototype.refreshImage = function() { this.image.width = this.pendingImage.width; this.image.height = this.pendingImage.height; this.image.style.visibility = 'visible'; - if (this.selectedSlideInSelection) - this.image.parentNode.className = 'selected'; - else - this.image.parentNode.className = ''; + if (this.selectedSlideInSelection) { this.image.parentNode.className = 'selected'; } + else { this.image.parentNode.className = ''; } }; FilmSlider.prototype.updateBreadcrumbs = function(url, title) { @@ -640,8 +616,7 @@ FilmSlider.prototype.startSlideShow = function() { FilmSlider.prototype.slideShowNext = function() { var nextSlide = this.slideShowSlide.parentNode.nextSibling; - if (nextSlide && nextSlide.nodeType===3) - nextSlide = nextSlide.nextSibling; + if (nextSlide && nextSlide.nodeType===3) { nextSlide = nextSlide.nextSibling; } if (nextSlide) { nextSlide = nextSlide.getElementsByTagName('a')[0]; @@ -660,8 +635,7 @@ FilmSlider.prototype.slideShowNext = function() { FilmSlider.prototype.slideShowPrevious = function() { var previousSlide = this.slideShowSlide.parentNode.previousSibling; - if (previousSlide && previousSlide.nodeType===3) - previousSlide = previousSlide.previousSibling; + if (previousSlide && previousSlide.nodeType===3) { previousSlide = previousSlide.previousSibling; } if (previousSlide) { previousSlide = previousSlide.getElementsByTagName('a')[0]; @@ -671,8 +645,7 @@ FilmSlider.prototype.slideShowPrevious = function() { else { var row = this.slideShowSlide.parentNode.parentNode; var last = row.lastChild; - if (last.nodeType===3) - last = last.previousSibling; + if (last.nodeType===3) { last = last.previousSibling; } this.pendingSlideShowSlide = last.getElementsByTagName('a')[0]; return this.pendingSlideShowSlide.href; } -- 2.20.1 From 4f04a5762f82ec39ed45338648daab0533784926 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 10:35:02 +0200 Subject: [PATCH 11/16] jslint --- skins/photo_film_viewer.js | 42 +++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index edf2069..efda660 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -144,16 +144,14 @@ FilmSlider.prototype.getBestFitSize = function(ratio) { for (i=DEFAULT_IMAGE_SIZES.length -1 ; i>0 ; i--) { irw = DEFAULT_IMAGE_SIZES[i]; irh = irw * ratio; - if (irw <= fw && irh <= fh) - break; + if (irw <= fw && irh <= fh) { break; } } } else { for (i=DEFAULT_IMAGE_SIZES.length -1 ; i>0 ; i--) { irh = DEFAULT_IMAGE_SIZES[i]; irw = irh / ratio; - if (irw <= fw && irh <= fh) - break; + if (irw <= fw && irh <= fh) { break; } } } return DEFAULT_IMAGE_SIZES[i]; @@ -162,10 +160,10 @@ FilmSlider.prototype.getBestFitSize = function(ratio) { FilmSlider.prototype.centerSlide = function(slideIndex) { if (this.sliderRatio > 1) { return; } var filmBarWidth = getObjectWidth(this.filmBar); - var x = slideIndex * this.slideSize + var x = slideIndex * this.slideSize; x = x - (filmBarWidth - this.slideSize) / 2.0; x = x * this.sliderSpeedRatio; - var p = new Point( -x, 0 ) + var p = new Point( -x, 0 ); this.setSliderPosition(p); }; @@ -181,15 +179,15 @@ FilmSlider.prototype.setFilmPosition = function(point) { }; FilmSlider.prototype.getSliderPosition = function() { - var x = parseInt(this.slider.style.left); - var y = parseInt(this.slider.style.top); + var x = parseInt(this.slider.style.left, 10); + var y = parseInt(this.slider.style.top, 10); var p = new Point(x, y); return p; }; FilmSlider.prototype.getFilmPosition = function() { - var x = parseInt(this.film.style.left); - var y = parseInt(this.film.style.top); + var x = parseInt(this.film.style.left, 10); + var y = parseInt(this.film.style.top, 10); var p = new Point(x, y); return p; }; @@ -209,7 +207,7 @@ FilmSlider.prototype.loadSibling = function(previous) { else { var target = slide.getElementsByTagName('a')[0]; raiseMouseEvent(target, 'click'); - var index = parseInt(target.getAttribute('portfolio:position')); + var index = parseInt(target.getAttribute('portfolio:position'), 10); this.centerSlide(index); } }; @@ -222,7 +220,7 @@ FilmSlider.prototype.addEventListeners = function() { addListener(window, 'load', function(evt){thisSlider.fitToScreen(evt);}); // dd listeners - addListener(this.slider, 'mousedown', this.ddHandlers['down']); + addListener(this.slider, 'mousedown', this.ddHandlers.down); if(browser.isDOM2Event){ if (browser.isAppleWebKit) { this.filmBar.addEventListener('mousewheel', function(evt){thisSlider.mouseWheelHandler(evt);}, false); @@ -244,10 +242,9 @@ FilmSlider.prototype.mouseDownHandler = function(evt) { this.initialClickPoint = new Point(evt.clientX, evt.clientY); this.initialPosition = this.getSliderPosition(); this.dragInProgress = true; - addListener(document, 'mousemove', this.ddHandlers['move']); - addListener(document, 'mouseup', this.ddHandlers['up']); - addListener(document.body, 'mouseout', this.ddHandlers['out']) - + addListener(document, 'mousemove', this.ddHandlers.move); + addListener(document, 'mouseup', this.ddHandlers.up); + addListener(document.body, 'mouseout', this.ddHandlers.out); }; @@ -273,9 +270,9 @@ FilmSlider.prototype.mouseOutHandler = function(evt) { var x = evt.clientX; var y = evt.clientY; if (x < 0 || - x > this.winSize['width'] || + x > this.winSize.width || y < 0 || - y > this.winSize['height'] + y > this.winSize.height ) { this.mouseUpHandler(evt); } @@ -283,8 +280,7 @@ FilmSlider.prototype.mouseOutHandler = function(evt) { FilmSlider.prototype.thumbnailClickHandler = function(evt) { var target = getTargetedObject(evt); - while (target.tagName !== 'A' && target !== this.filmBar) - target = target.parentNode; + while (target.tagName !== 'A' && target !== this.filmBar) { target = target.parentNode; } if (target.tagName !== 'A') { return; } else { if (this.viewMode === 'full') { @@ -314,10 +310,10 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=' + bestFitSize; // update buttons - var fullScreenLink = this.buttons['full_screen'].parentNode; + var fullScreenLink = this.buttons.full_screen.parentNode; fullScreenLink.href = canonicalImgUrl + '/zoom_view'; - var toggleSelectionBtn = this.buttons['toggle_selection']; + var toggleSelectionBtn = this.buttons.toggle_selection; var toggleSelectionLink = toggleSelectionBtn.parentNode; this.selectedSlideInSelection = (target.className==='selected'); if (this.selectedSlideInSelection) { @@ -331,7 +327,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { toggleSelectionLink.href = canonicalImgUrl + '/add_to_selection'; } - var showBuyableButtonLink = this.buttons['show_buyable'].parentNode; + var showBuyableButtonLink = this.buttons.show_buyable.parentNode; showBuyableButtonLink.href = canonicalImgUrl + '/get_slide_buyable_items'; this.cartSlide.innerHTML = ''; this.cartSlide.style.visibility='hidden'; -- 2.20.1 From ee0633b788ca7650b0cab7f57ef6b846333c26f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 10:37:12 +0200 Subject: [PATCH 12/16] jslint --- skins/photo_film_viewer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index efda660..a1ec07d 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -333,7 +333,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { this.cartSlide.style.visibility='hidden'; - var metadataButton = this.buttons['edit_metadata'] + var metadataButton = this.buttons.edit_metadata if (metadataButton) { var metadataEditLink = metadataButton.parentNode; metadataEditLink.href = canonicalImgUrl + '/photo_edit_form' @@ -559,7 +559,7 @@ FilmSlider.prototype.keyPressHandler = function(evt) { switch(charPress) { case 'f': case 'F': - raiseMouseEvent(this.buttons['full_screen'], 'click'); + raiseMouseEvent(this.buttons.full_screen, 'click'); break; } }; @@ -574,9 +574,9 @@ FilmSlider.prototype.populateViewer = function(req) { if (dest) { dest.innerHTML = element.firstChild.nodeValue; } break; case 'imageattributes' : - var link = this.buttons['back_to_portfolio'].parentNode; + var link = this.buttons.back_to_portfolio.parentNode; link.href = element.getAttribute('backToContextUrl'); - link = this.buttons['show_buyable'].parentNode; + link = this.buttons.show_buyable.parentNode; var buyable = element.getAttribute('buyable'); if(buyable === 'True') { link.className = null; } else if(buyable === 'False') { link.className = 'hidden'; } -- 2.20.1 From c41e535e2e805f096dfe6554c0ab760350bb3729 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 10:51:20 +0200 Subject: [PATCH 13/16] =?utf8?q?jslint=20termin=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/photo_film_viewer.js | 65 ++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index a1ec07d..c9615fb 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -1,9 +1,7 @@ /* -* © 2008-2014 Benoît Pin – Centre de recherche en informatique – MINES ParisTech -* http://plinn.org -* Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/ -* -* +copyright 2008-2014 Benoit Pin - Centre de recherche en informatique - MINES ParisTech +http://plinn.org +Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/ */ var FilmSlider; @@ -333,10 +331,10 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { this.cartSlide.style.visibility='hidden'; - var metadataButton = this.buttons.edit_metadata + var metadataButton = this.buttons.edit_metadata; if (metadataButton) { var metadataEditLink = metadataButton.parentNode; - metadataEditLink.href = canonicalImgUrl + '/photo_edit_form' + metadataEditLink.href = canonicalImgUrl + '/photo_edit_form'; } @@ -360,11 +358,8 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { case 4 : hideProgressImage(); if (req.status === '200') { thisFS.populateViewer(req); } - // else - // //window.location.href = target.href; - // console.error(ajaxUrl); - - }; + break; + } }; req.open("GET", ajaxUrl, true); @@ -376,13 +371,14 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { var newClasses = []; var name, i; - for (i in classes) { + for (i=0 ; i Date: Mon, 7 Apr 2014 13:17:39 +0200 Subject: [PATCH 14/16] =?utf8?q?bugfix=C2=A0:=20XMLHttpRequest.status=20es?= =?utf8?q?t=20un=20entier.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/photo_film_viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index c9615fb..2ebe6ca 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -357,7 +357,7 @@ FilmSlider.prototype.thumbnailClickHandler = function(evt) { break; case 4 : hideProgressImage(); - if (req.status === '200') { thisFS.populateViewer(req); } + if (req.status === 200) { thisFS.populateViewer(req); } break; } }; -- 2.20.1 From 9c9b2f54e463753e5516303323c96eb9d8317f3e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 7 Apr 2014 15:39:53 +0200 Subject: [PATCH 15/16] =?utf8?q?Bugfix=C2=A0:=20chargement=20du=20script?= =?utf8?q?=20d'upload=20seulement=20si=20autoris=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/photo_layout_macros.pt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skins/photo_layout_macros.pt b/skins/photo_layout_macros.pt index b9f63c5..c895466 100644 --- a/skins/photo_layout_macros.pt +++ b/skins/photo_layout_macros.pt @@ -86,7 +86,9 @@
batch navigation
-