From 6adc597d0e1597cdf71005c9cedbc402717ee6e1 Mon Sep 17 00:00:00 2001 From: Florian BLOUET Date: Tue, 22 Mar 2016 12:21:25 +0100 Subject: [PATCH] frontent refactoring - move lighbox into phraseanet-production-client --- package.json | 2 +- resources/gulp/components/lightbox.js | 32 +- resources/gulp/utils.js | 4 +- resources/gulp/watch.js | 1 - resources/www/lightbox/js/jquery.lightbox.js | 963 ------------------ .../lightbox/js/jquery.validator.mobile.js | 122 --- .../mobile/lightbox/basket_element.html.twig | 3 +- templates/mobile/lightbox/feed.html.twig | 3 +- .../mobile/lightbox/feed_element.html.twig | 3 +- templates/mobile/lightbox/index.html.twig | 14 +- templates/mobile/lightbox/note_form.html.twig | 3 +- templates/mobile/lightbox/validate.html.twig | 13 +- templates/web/lightbox/feed.html.twig | 4 +- templates/web/lightbox/index.html.twig | 4 +- templates/web/lightbox/index_layout.html.twig | 9 + templates/web/lightbox/validate.html.twig | 11 +- templates/web/prod/index.html.twig | 7 +- 17 files changed, 62 insertions(+), 1136 deletions(-) delete mode 100644 resources/www/lightbox/js/jquery.lightbox.js delete mode 100644 resources/www/lightbox/js/jquery.validator.mobile.js diff --git a/package.json b/package.json index 40bac5b1ca..de1efe2b24 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,6 @@ "postinstall": "./node_modules/.bin/gulp install;" }, "dependencies": { - "phraseanet-production-client": "~0.4.0" + "phraseanet-production-client": "~0.5.0" } } diff --git a/resources/gulp/components/lightbox.js b/resources/gulp/components/lightbox.js index d68f8e67d4..9db80dc911 100644 --- a/resources/gulp/components/lightbox.js +++ b/resources/gulp/components/lightbox.js @@ -14,44 +14,18 @@ gulp.task('build-lightbox-mobile-css', function(){ ], 'lightbox-mobile', 'lightbox/css/', debugMode); }); -gulp.task('build-lightbox-mobile-js', function(){ - - return utils.buildJsGroup([ - config.paths.src + 'lightbox/js/jquery.validator.mobile.js' - ], 'lightbox-mobile', 'lightbox/js', debugMode); -}); - -gulp.task('build-lightbox-ie6-css', function(){ - return utils.buildCssGroup([ - config.paths.src + 'lightbox/styles/main-ie6.scss' - ], 'lightbox-ie6', 'lightbox/css/', debugMode) -}); - -gulp.task('build-lightbox-css', ['build-lightbox-mobile-css', 'build-lightbox-ie6-css'], function(){ +gulp.task('build-lightbox-css', ['build-lightbox-mobile-css'], function(){ return utils.buildCssGroup([ config.paths.src + 'lightbox/styles/main.scss' ], 'lightbox', 'lightbox/css/', debugMode) }); -gulp.task('build-lightbox-js', ['build-lightbox-mobile-js'], function(){ - var lightboxGroup = [ - config.paths.src + 'lightbox/js/jquery.lightbox.js' - ]; - - return utils.buildJsGroup(lightboxGroup, 'lightbox', 'lightbox/js', debugMode); -}); - -gulp.task('watch-lightbox-js', function() { - debugMode = true; - return gulp.watch(config.paths.src + 'lightbox/**/*.js', ['build-lightbox-js']); -}); - gulp.task('watch-lightbox-css', function() { debugMode = true; gulp.watch(config.paths.src + 'lightbox/**/*.scss', ['build-lightbox-css']); }); -gulp.task('build-lightbox', ['copy-lightbox-images', 'build-lightbox-css'], function(){ +gulp.task('build-lightbox', ['copy-lightbox-images'], function(){ debugMode = false; - return gulp.start('build-lightbox-js'); + return gulp.start('build-lightbox-css'); }); diff --git a/resources/gulp/utils.js b/resources/gulp/utils.js index b77eb2b9a3..ce17148fe4 100644 --- a/resources/gulp/utils.js +++ b/resources/gulp/utils.js @@ -35,7 +35,7 @@ exports.buildJsGroup = function(srcGroup, name, dest, debugMode){ compress: { drop_console: true } - }).on('error', config.errorHandler('UGLIFY ERROR'))) //util.log)) + }).on('error', config.errorHandler('UGLIFY ERROR'))) .pipe(rename({ extname: '.min.js' })) .pipe(gulp.dest( config.paths.build + dest)) }; @@ -66,4 +66,4 @@ exports.buildCssGroup = function(srcGroup, name, dest, debugMode){ .pipe(cssmin()) .pipe(rename({suffix: '.min'})) .pipe(gulp.dest(config.paths.build + dest)); -}; \ No newline at end of file +}; diff --git a/resources/gulp/watch.js b/resources/gulp/watch.js index dc030b2456..6bb8cbfc61 100644 --- a/resources/gulp/watch.js +++ b/resources/gulp/watch.js @@ -25,7 +25,6 @@ gulp.task('watch-js', function(){ // gulp.start('watch-oauth-js'); gulp.start('watch-thesaurus-js'); //gulp.start('watch-uploadFlash'); - gulp.start('watch-lightbox-js'); gulp.start('watch-admin-js'); gulp.start('watch-report-js'); gulp.start('watch-account-js'); diff --git a/resources/www/lightbox/js/jquery.lightbox.js b/resources/www/lightbox/js/jquery.lightbox.js deleted file mode 100644 index 7ae5c766df..0000000000 --- a/resources/www/lightbox/js/jquery.lightbox.js +++ /dev/null @@ -1,963 +0,0 @@ -var lightboxModule = (function($){ - var _releasable = false; - var _bodySize = { - x: 0, - y: 0 - }; - $(document).ready(function () { - - _bodySize.y = $('#mainContainer').height(); - _bodySize.x = $('#mainContainer').width(); - - $(this).data('slideshow', false); - $(this).data('slideshow_ctime', false); - - $(window).bind('beforeunload', function () { - if (_releasable !== false) { - if (confirm(_releasable)) { - $('#basket_options .confirm_report').trigger('click'); - } - } - }); - - - $('#mainMenu, .unselectable').disableSelection(); - - _display_basket(); - - $(window).bind('mousedown',function () { - $(this).focus(); - }).trigger('mousedown'); - - $('.basket_wrapper').hover( - function () { - $(this).addClass('hover'); - }, - function () { - $(this).removeClass('hover'); - } - ).bind('click', function () { - var id = $('input[name=ssel_id]', this).val(); - document.location = '/lightbox/validate/' + id + '/'; - return; - }); - $('.basket_downloader').bind('click', function () { - _downloadBasket(); - }); - if ($('.right_column_wrapper_user').length > 0) { - $('.right_column_title, #right_column_validation_toggle').bind('click',function () { - if (!$('.right_column_wrapper_caption').is(':visible')) { - $('.right_column_wrapper_user').height($('.right_column_wrapper_user').height()).css('top', 'auto').animate({ - 'height': 0 - }); - $('.right_column_wrapper_caption').slideDown(); - $('#right_column_validation_toggle').show(); - } - else { - $('.right_column_wrapper_user').height('auto').animate({ - 'top': $('.right_column_title').height() - }); - $('.right_column_wrapper_caption').slideUp(); - $('#right_column_validation_toggle').hide(); - } - var title = $('.right_column_title'); - title.hasClass('expanded') ? title.removeClass('expanded') : title.addClass('expanded'); - }).addClass('clickable'); - } - var sselcont = $('#sc_container .basket_element:first'); - if (sselcont.length > 0) { - _display_basket_element(false, sselcont.attr('id').split('_').pop()); - } - - - _setSizeable($('#record_main .lightbox_container, #record_compare .lightbox_container')); - - $('#navigation') - .bind('change', - function () { - window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/'); - } - ); - - $('#left_scroller') - .bind('click', - function () { - _scrollElements(false); - } - ); - - $('#right_scroller') - .bind('click', function () { - _scrollElements(true); - } - ); - - $(window) - .bind('resize', function () { - _resizeLightbox(); - } - ); - _bind_keyboard(); - }); - - function _resizeLightbox() { - _bodySize.y = $('#mainContainer').height(); - _bodySize.x = $('#mainContainer').width(); - _displayRecord($('#record_compare').css('visibility') != 'hidden'); - } - - function _display_basket() { - var sc_wrapper = $('#sc_wrapper'); - var basket_options = $('#basket_options'); - - $('.report').on('click',function () { - _loadReport(); - return false; - }).addClass('clickable'); - // $('#basket_infos .report').button({ - // icons: { - // primary: 'ui-icon-document' - // } - // }).bind('click',function(){ - // $(this).blur(); - // }); - $('.confirm_report', basket_options).button() - .bind('click', function () { - _setRelease($(this)); - }); - - $('.basket_element', sc_wrapper).parent() - .bind('click', function (event) { - _scid_click(event, this); - return false; - }); - - $('.agree_button, .disagree_button', sc_wrapper).bind('click',function (event) { - - var sselcont_id = $(this).closest('.basket_element').attr('id').split('_').pop(); - - var agreement = $(this).hasClass('agree_button') ? '1' : '-1'; - - _setAgreement(event, $(this), sselcont_id, agreement); - return false; - }).addClass('clickable'); - - n = $('.basket_element', sc_wrapper).length; - $('#sc_container').width(n * $('.basket_element_wrapper:first', sc_wrapper).outerWidth() + 1); - - $('.previewTips').tooltip(); - } - - - function setReleasable(val) { - _releasable = val; - } - - function _bind_keyboard() { - $(document).bind('keydown', function (event) { - - var stop = false; - $('.notes_wrapper').each(function (i, n) { - if (parseInt($(n).css('top')) >= 0) - stop = true; - }); - - if (stop) - return true; - - var cancelKey = false; - var el, id; - switch (event.keyCode) { - case 39: - _getNext(); - cancelKey = true; - break; - case 37: - _getPrev(); - cancelKey = true; - break; - case 32: - var bool = !$(document).data('slideshow'); - _slideshow(bool); - break; - case 38: - el = $('#sc_container .basket_element.selected'); - if (el.length === 1) { - id = el.attr('id').split('_').pop(); - _setAgreement(event, el, id, 1); - } - break; - case 40: - el = $('#sc_container .basket_element.selected'); - if (el.length === 1) { - id = el.attr('id').split('_').pop(); - _setAgreement(event, el, id, -1); - } - break; - default: - break; - } - - if (cancelKey) { - event.cancelBubble = true; - if (event.stopPropagation) - event.stopPropagation(); - return(false); - } - return true; - }); - } - - function _loadReport() { - $.ajax({ - type: "GET", - url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/", - dataType: 'html', - success: function (data) { - $('#report').empty().append(data); - $('#report .reportTips').tooltip({ - delay: false - }); - $('#report').dialog({ - width: 600, - modal: true, - resizable: false, - height: Math.round($(window).height() * 0.8) - }); - - return; - } - }); - } - - - function _scid_click(event, el) { - var compare = utilsModule.is_ctrl_key(event); - - if (compare) { - if ($('.basket_element', el).hasClass('selected')) - return; - } - else { - $('#sc_container .basket_element.selected').removeClass('selected'); - $('.basket_element', el).addClass('selected'); - } - - var sselcont_id = $('.basket_element', el).attr('id').split('_').pop(); - var ssel_id = $('#navigation').val(); - - var container = $('#sc_container'); - - var request = container.data('request'); - if (request && typeof(request.abort) == 'function') { - request.abort(); - } - - request = $.ajax({ - type: "GET", - url: $(el).attr('href'),//"/lightbox/ajax/LOAD_BASKET_ELEMENT/"+sselcont_id+'/', - dataType: 'json', - success: function (datas) { - var container = false; - var data = datas; - - if (compare) { - container = $('#record_compare'); - } - else { - container = $('#record_main'); - - $('#record_infos .lightbox_container') - .empty() - .append(data.caption); - - $('#basket_infos') - .empty() - .append(data.agreement_html); - } - - $('.display_id', container) - .empty() - .append(data.number); - - $('.title', container) - .empty() - .append(data.title) - .attr('title', data.title); - - var options_container = $('.options', container); - options_container - .empty() - .append(data.options_html); - - $('.lightbox_container', container).empty() - .append(data.preview + data.selector_html + data.note_html); - - - _display_basket_element(compare, sselcont_id); - - - return; - } - }); - container.data('request', request); - } - - function _display_basket_element(compare, sselcont_id) { - var container; - if (compare) { - container = $('#record_compare'); - } - else { - container = $('#record_main'); - } - $('.record_image', container).removeAttr('ondragstart'); - $('.record_image', container).draggable(); - - var options_container = $('.options', container); - - $('.download_button', options_container).bind('click', function () { - // $(this).blur(); - _download($(this).next('form[name=download_form]').find('input').val()); - }); - - $('.comment_button', options_container).bind('click', function () { - // $(this).blur(); - if ($('.lightbox_container', container).hasClass('note_editing')) { - _hideNotes(container); - } - else { - _showNotes(container); - } - } - ); - - _activateNotes(container); - - $('.previous_button', options_container).bind('click', function () { - // $(this).blur(); - _getPrev(); - }); - - $('.play_button', options_container).bind('click', function () { - // $(this).blur(); - _slideshow(true); - }); - - $('.pause_button', options_container).bind('click', function () { - // $(this).blur(); - _slideshow(false); - }); - - if ($(document).data('slideshow')) { - $('.play_button, .next_button.play, .previous_button.play', options_container).hide(); - } - else { - $('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide(); - } - - $('.next_button', options_container).bind('click', function () { - // $(this).blur(); - _slideshow(false); - _getNext(); - }); - - - $('.lightbox_container', container).bind('dblclick', function (event) { - _displayRecord(); - }); - - - $('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree') - .bind('click', - function (event) { - _setAgreement(event, $(this), sselcont_id, '1'); - } - ) - .addClass('clickable'); - - $('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree') - .bind('click', - function (event) { - _setAgreement(event, $(this), sselcont_id, '-1'); - } - ) - .addClass('clickable'); - - if (compare == $('#record_wrapper').hasClass('single')) { - if (compare) { - // $('.agreement_selector').show(); - // $('#record_wrapper').stop().animate({right:0},100,function(){display_record(compare);}); - $('#record_wrapper').css({ - right: 0 - }); - _displayRecord(compare); - $('#right_column').hide(); - } - else { - // $('.agreement_selector').hide(); - $('#record_wrapper').css({ - right: 250 - }); - _displayRecord(compare); - $('#right_column').show(); - $('#record_compare .lightbox_container').empty(); - } - - } - else { - _displayRecord(compare); - } - - } - - function _getPrev() { - var current_wrapper = $('#sc_container .basket_element.selected').parent().parent(); - - if (current_wrapper.length === 0) - return; - - _slideshow(false); - - current_wrapper = current_wrapper.prev(); - if (current_wrapper.length === 0) - current_wrapper = $('#sc_container .basket_element_wrapper:last'); - - $('.basket_element', current_wrapper).parent().trigger('click'); - - _adjust_visibility($('.basket_element', current_wrapper)); - } - - function _getNext() { - var current_wrapper = $('#sc_container .basket_element.selected').parent().parent(); - - if (current_wrapper.length === 0) - return; - - current_wrapper = current_wrapper.next(); - if (current_wrapper.length === 0) - current_wrapper = $('#sc_container .basket_element_wrapper:first'); - - $('.basket_element', current_wrapper).parent().trigger('click'); - - _adjust_visibility($('.basket_element', current_wrapper)); - - if ($(document).data('slideshow')) { - var timer = setTimeout('get_next();', 3500); - $(document).data('slideshow_ctime', timer); - } - } - - function _slideshow(boolean_value) { - if (boolean_value == $(document).data('slideshow')) - return; - - if (!boolean_value && $(document).data('slideshow_ctime')) { - clearTimeout($(document).data('slideshow_ctime')); - $(document).data('slideshow_ctime', false); - } - - $(document).data('slideshow', boolean_value); - - var headers = $('#record_wrapper .header'); - - if (boolean_value) { - $('.play_button, .next_button.play, .previous_button.play', headers).hide(); - $('.pause_button, .next_button.pause, .previous_button.pause', headers).show(); - _getNext(); - } - else { - $('.pause_button, .next_button.pause, .previous_button.pause', headers).hide(); - $('.play_button, .next_button.play, .previous_button.play', headers).show(); - } - } - - function _adjust_visibility(el) { - if (_isViewable(el)) - return; - - var sc_wrapper = $('#sc_wrapper'); - var el_parent = $(el).parent(); - - var sc_left = el_parent.position().left + el_parent.outerWidth() / 2 - sc_wrapper.width() / 2; - - sc_wrapper.stop().animate({ - 'scrollLeft': sc_left - }); - } - - - function _setAgreement(event, el, sselcont_id, boolean_value) { - if (event.stopPropagation) - event.stopPropagation(); - event.cancelBubble = true; - - var id = - - $.ajax({ - type: "POST", - url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/" + sselcont_id + "/", - dataType: 'json', - data: { - agreement: boolean_value - }, - success: function (datas) { - if (!datas.error) { - if (boolean_value == '1') { - $('.agree_' + sselcont_id + '').removeClass('not_decided'); - $('.disagree_' + sselcont_id + '').addClass('not_decided'); - $('.userchoice.me').addClass('agree').removeClass('disagree'); - } - else { - $('.agree_' + sselcont_id + '').addClass('not_decided'); - $('.disagree_' + sselcont_id + '').removeClass('not_decided'); - $('.userchoice.me').addClass('disagree').removeClass('agree'); - } - _releasable = datas.releasable; - if (datas.releasable !== false) { - if (confirm(datas.releasable)) - $('#basket_options .confirm_report').trigger('click'); - } - } - else { - alert(datas.datas); - } - return; - } - }); - } - - function _displayRecord(compare) { - var main_container = $('#record_wrapper'); - - if (typeof compare == 'undefined') - compare = !main_container.hasClass('single'); - - var main_box = $('#record_main'); - var compare_box = $('#record_compare'); - - var main_record = $('.lightbox_container .record', main_box); - var compare_record = $('.lightbox_container .record', compare_box); - - var main_record_width = parseInt($('input[name=width]', main_box).val()); - var main_record_height = parseInt($('input[name=height]', main_box).val()); - var compare_record_width = parseInt($('input[name=width]', compare_box).val()); - var compare_record_height = parseInt($('input[name=height]', compare_box).val()); - - var main_container_width = main_container.width(); - var main_container_innerwidth = main_container.innerWidth(); - var main_container_height = main_container.height(); - var main_container_innerheight = main_container.innerHeight(); - - if (compare) { - $('.agreement_selector').show(); - main_container.addClass('comparison'); - - var double_portrait_width = main_container_innerwidth / 2; - var double_portrait_height = main_container_innerheight - $('.header', main_box).outerHeight(); - - var double_paysage_width = main_container_innerwidth; - var double_paysage_height = main_container_innerheight / 2 - $('.header', main_box).outerHeight(); - - var main_display_portrait = _calculateDisplay( - double_portrait_width, double_portrait_height, - main_record_width, main_record_height - ); - var main_display_paysage = _calculateDisplay( - double_paysage_width, double_paysage_height, - main_record_width, main_record_height - ); - - var compare_display_portrait = _calculateDisplay( - double_portrait_width, double_portrait_height, - compare_record_width, compare_record_height - ); - var compare_display_paysage = _calculateDisplay( - double_paysage_width, double_paysage_height, - compare_record_width, compare_record_height - ); - - var surface_main_portrait = main_display_portrait.width * main_display_portrait.height; - var surface_main_paysage = main_display_paysage.width * main_display_paysage.height; - var surface_compare_portrait = compare_display_portrait.width * compare_display_portrait.height; - var surface_compare_paysage = compare_display_paysage.width * compare_display_paysage.height; - - var double_portrait_surface = (surface_main_portrait + surface_compare_portrait) / 2; - var double_paysage_surface = (surface_main_paysage + surface_compare_paysage) / 2; - - var smooth_image = false; - - var m_width_image, m_height_image, c_width_image, c_height_image, dim_container; - - if (double_portrait_surface > double_paysage_surface) { - if (!main_container.hasClass('portrait')) { - smooth_image = true; - - _smoothTransform( - main_box, - '50%', - '100%', - function () { - _setContainerStatus('portrait'); - } - ); - - compare_box.css('visibility', 'hidden'); - - _smoothTransform( - compare_box, - '50%', - '100%', - function () { - compare_box.css('display', 'none') - .css('visibility', 'visible') - .fadeIn(); - } - ); - } - m_width_image = main_display_portrait.width; - m_height_image = main_display_portrait.height; - c_width_image = compare_display_portrait.width; - c_height_image = compare_display_portrait.height; - dim_container = { - width: double_portrait_width, - height: double_portrait_height - }; - } - else { - if (!main_container.hasClass('paysage')) { - smooth_image = true; - - _smoothTransform( - main_box, - '100%', - '50%', - function () { - _setContainerStatus('paysage'); - } - ); - - compare_box.css('visibility', 'hidden'); - - _smoothTransform( - compare_box, - '100%', - '50%', - function () { - compare_box.css('display', 'none') - .css('visibility', 'visible') - .fadeIn(); - } - ); - } - m_width_image = main_display_paysage.width; - m_height_image = main_display_paysage.height; - c_width_image = compare_display_paysage.width; - c_height_image = compare_display_paysage.height; - dim_container = { - width: double_paysage_width, - height: double_paysage_height - }; - } - - var image_callback = _setImagePosition(false, compare_record, c_width_image, c_height_image, dim_container, function () { - }); - _setImagePosition(smooth_image, main_record, m_width_image, m_height_image, dim_container, image_callback); - } - else { - $('.agreement_selector').hide(); - main_container.removeClass('comparison'); - - if (compare_box.is(':visible')) { - compare_box.hide().css('visibility', 'hidden').css('display', 'block'); - } - - var main_display = _calculateDisplay( - main_container_innerwidth, (main_container_innerheight - $('.header', main_box).outerHeight()), - main_record_width, main_record_height - ); - - if (!main_container.hasClass('single')) { - main_box.width('100%') - .height('100%'); - - _setContainerStatus('single'); - } - _setImagePosition(smooth_image, main_record, main_display.width, main_display.height, { - width: main_container_width, - height: (main_container_height - $('.header', main_box).outerHeight()) - }); - } - } - - function _calculateDisplay(display_width, display_height, width, height, margin) { - if (typeof margin == 'undefined') - margin = 10; - - var display_ratio = display_width / display_height; - var ratio = width / height; - var w, h; - - if (ratio > display_ratio)//landscape - { - w = display_width - 2 * margin; - if (w > width) - w = width; - h = w / ratio; - } - else { - h = display_height - 2 * margin; - if (h > height) - h = height; - w = ratio * h; - } - - return { - width: w, - height: h - }; - } - - function _downloadBasket() { - var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) { - return $('input[name="basrec"]', $(el)).val(); - }); - _download(ids.join(';')); - } - - function _download(value) { - var dialog = dialogModule.dialog.create({title: typeof(language) !== 'undefined' ? language['export'] : ''}); - - $.post("/prod/export/multi-export/", "lst=" + value, function (data) { - - dialog.setContent(data); - - $('.tabs', dialog.getDomElement()).tabs(); - - $('.close_button', dialog.getDomElement()).bind('click', function () { - dialog.close(); - }); - - return false; - }); - } - - function _setSizeable(container) { - - $(container).bind('mousewheel', function (event, delta) { - - if ($(this).hasClass('note_editing')) - return; - - var record = $('.record_image', this); - - if (record.length === 0) - return; - - var o_top = parseInt(record.css('top')); - var o_left = parseInt(record.css('left')); - - var o_width, o_height, width, height; - - if (delta > 0) { - if (record.width() > 29788 || record.height() >= 29788) - return; - o_width = record.width(); - o_height = record.height(); - width = Math.round(o_width * 1.1); - height = Math.round(o_height * 1.1); - } - else { - if (record.width() < 30 || record.height() < 30) - return; - o_width = record.width(); - o_height = record.height(); - width = Math.round(o_width / 1.05); - height = Math.round(o_height / 1.05); - } - - var top = Math.round((height / o_height) * (o_top - $(this).height() / 2) + $(this).height() / 2); - var left = Math.round((width / o_width) * (o_left - $(this).width() / 2) + $(this).width() / 2); - - record.width(width).height(height).css({ - top: top, - left: left - }); - }); - - } - - function _setImagePosition(smooth, image, width, height, container, callback) { - var dimensions = {}; - - if (typeof container !== 'undefined') { - var c_width = container.width; - var c_height = container.height; - - dimensions.top = parseInt((c_height - height) / 2); - dimensions.left = parseInt((c_width - width) / 2); - } - if (typeof callback == 'undefined') { - callback = function () { - }; - } - - dimensions.width = width; - dimensions.height = height; - - if (smooth) { - $(image).stop().animate(dimensions, 500, callback); - } - else { - $(image).css(dimensions); - callback(); - } - } - - function _scrollElements(boolean_value) { - var sc_wrapper = $('#sc_wrapper'); - var value; - if (boolean_value) - value = sc_wrapper.scrollLeft() + 400; - else - value = sc_wrapper.scrollLeft() - 400; - - sc_wrapper.stop().animate({ - 'scrollLeft': value - }); - return; - } - - function _smoothTransform(box, width, height, callback) { - if (typeof callback == 'undefined') - callback = function () { - }; - - $(box).stop() - .animate( - { - width: width, - height: height - }, - 500, - callback - ); - } - - function _setContainerStatus(status) { - $('#record_wrapper').removeClass('paysage portrait single').addClass(status); - } - - function _isViewable(el) { - var sc_wrapper = $('#sc_wrapper'); - var sc_container = $('#sc_container'); - - var el_width = $(el).parent().outerWidth(); - var el_position = $(el).parent().position(); - var sc_scroll_left = sc_wrapper.scrollLeft(); - - var boundup = sc_wrapper.width(), - bounddown = 0, - placeup = el_position.left + el_width - sc_scroll_left, - placedown = el_position.left - sc_scroll_left; - - if (placeup <= boundup && placedown >= bounddown) - return true; - return false; - } - - function _saveNote(container, button) { - var sselcont_id = $(button).attr('id').split('_').pop(); - var note = $('.notes_wrapper textarea', container).val(); - - $.ajax({ - type: "POST", - url: "/lightbox/ajax/SET_NOTE/" + sselcont_id + "/", - dataType: 'json', - data: { - note: note - }, - success: function (datas) { - _hideNotes(container); - $('.notes_wrapper', container).remove(); - $('.lightbox_container', container).append(datas.datas); - _activateNotes(container); - return; - } - }); - - } - - function _activateNotes(container) { - $('.note_closer', container).button({ - text: true - }).bind('click', function () { - $(this).blur(); - _hideNotes(container); - return false; - } - ); - - $('.note_saver', container).button({ - text: true - }).bind('click', function () { - $(this).blur(); - _saveNote(container, this); - return false; - } - ); - } - - - function _showNotes(container) { - $('.notes_wrapper', container).animate({ - top: 0 - }); - $('.lightbox_container', container).addClass('note_editing'); - } - - function _hideNotes(container) { - $('.notes_wrapper', container).animate({ - top: '-100%' - }); - $('.lightbox_container', container).removeClass('note_editing'); - } - - function _setRelease(el) { - $('.loader', el).css({ - visibility: 'visible' - }); - $.ajax({ - type: "POST", - url: "/lightbox/ajax/SET_RELEASE/" + $('#navigation').val() + "/", - dataType: 'json', - error: function (data) { - $('.loader', el).css({ - visibility: 'hidden' - }); - }, - timeout: function (data) { - $('.loader', el).css({ - visibility: 'hidden' - }); - }, - success: function (data) { - $('.loader', el).css({ - visibility: 'hidden' - }); - if (data.datas) { - alert(data.datas); - } - if (!data.error) { - _releasable = false; - } - - return; - } - }); - } - - return { - setReleasable: setReleasable - } -})(jQuery); diff --git a/resources/www/lightbox/js/jquery.validator.mobile.js b/resources/www/lightbox/js/jquery.validator.mobile.js deleted file mode 100644 index e9a5feaa6b..0000000000 --- a/resources/www/lightbox/js/jquery.validator.mobile.js +++ /dev/null @@ -1,122 +0,0 @@ -$(document).ready(function () { - if (typeof validator_loaded === 'boolean') - return; - - - $('.confirm_report').on('click', function () { - var $this = $(this); - - $('.loader', $this).css({ - visibility: 'visible' - }); - - $.ajax({ - type: "POST", - url: "/lightbox/ajax/SET_RELEASE/" + $('#basket_validation_id').val() + "/", - dataType: 'json', - error: function (data) { - $('.loader', $this).css({ - visibility: 'hidden' - }); - }, - timeout: function (data) { - $('.loader', $this).css({ - visibility: 'hidden' - }); - }, - success: function (data) { - $('.loader', $this).css({ - visibility: 'hidden' - }); - if (data.datas) { - alert(data.datas); - } - if (!data.error) { - releasable = false; - } - - return; - } - }); - }); - - $('.agreement_radio').on('vmousedown', function () { - var sselcont_id = $(this).attr('for').split('_').pop(); - var agreement = $('#' + $(this).attr('for')).val() == 'yes' ? '1' : '-1'; - - $.mobile.loading(); - - $.ajax({ - type: "POST", - url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/" + sselcont_id + "/", - dataType: 'json', - data: { - agreement: agreement - }, - error: function (datas) { - alert('error'); - $.mobile.loading(); - }, - timeout: function (datas) { - alert('error'); - $.mobile.loading(); - }, - success: function (datas) { - if (!datas.error) { - if (agreement == '1') - $('.valid_choice_' + sselcont_id).removeClass('disagree').addClass('agree'); - else - $('.valid_choice_' + sselcont_id).removeClass('agree').addClass('disagree'); - $.mobile.loading(); - if (datas.error) { - alert(datas.datas); - return; - } - - releasable = datas.release; - } - else { - alert(datas.datas); - } - return; - } - }); - return false; - - }); - $('.note_area_validate').on('click', function () { - var sselcont_id = $(this).closest('form').find('input[name="sselcont_id"]').val(); - - $.mobile.loading(); - $.ajax({ - type: "POST", - url: "/lightbox/ajax/SET_NOTE/" + sselcont_id + "/", - dataType: 'json', - data: { - note: $('#note_form_' + sselcont_id).find('textarea').val() - }, - error: function (datas) { - alert('error'); - $.mobile.loading(); - }, - timeout: function (datas) { - alert('error'); - $.mobile.loading(); - }, - success: function (datas) { - $.mobile.loading(); - if (datas.error) { - alert(datas.datas); - return; - } - - $('#notes_' + sselcont_id).empty().append(datas.datas); - window.history.back(); - return; - } - }); - return false; - }); - - validator_loaded = true; -}); diff --git a/templates/mobile/lightbox/basket_element.html.twig b/templates/mobile/lightbox/basket_element.html.twig index 697d732c7f..ef2881ad2c 100644 --- a/templates/mobile/lightbox/basket_element.html.twig +++ b/templates/mobile/lightbox/basket_element.html.twig @@ -3,7 +3,8 @@ {% extends "common/index.html.twig" %} {% block javascript %} - + + {% endblock %} {% block stylesheet %} diff --git a/templates/mobile/lightbox/feed.html.twig b/templates/mobile/lightbox/feed.html.twig index dc2cd826b6..de2d4287e6 100644 --- a/templates/mobile/lightbox/feed.html.twig +++ b/templates/mobile/lightbox/feed.html.twig @@ -2,7 +2,8 @@ {% extends "common/index.html.twig" %} {% block javascript %} - + + {% endblock %} {% block stylesheet %} diff --git a/templates/mobile/lightbox/feed_element.html.twig b/templates/mobile/lightbox/feed_element.html.twig index 6408f4baba..f21f153930 100644 --- a/templates/mobile/lightbox/feed_element.html.twig +++ b/templates/mobile/lightbox/feed_element.html.twig @@ -3,7 +3,8 @@ {% extends "common/index.html.twig" %} {% block javascript %} - + + {% endblock %} {% block stylesheet %} diff --git a/templates/mobile/lightbox/index.html.twig b/templates/mobile/lightbox/index.html.twig index 87a6fb0301..c15a34d9a5 100644 --- a/templates/mobile/lightbox/index.html.twig +++ b/templates/mobile/lightbox/index.html.twig @@ -1,7 +1,9 @@ {% extends "common/index.html.twig" %} {% block javascript %} - + + + {# #} {% endblock %} {% block stylesheet %} @@ -135,4 +137,14 @@ + + + + {% endblock %} diff --git a/templates/mobile/lightbox/note_form.html.twig b/templates/mobile/lightbox/note_form.html.twig index 771a75c2a6..daa36631ab 100644 --- a/templates/mobile/lightbox/note_form.html.twig +++ b/templates/mobile/lightbox/note_form.html.twig @@ -3,7 +3,8 @@ {% extends "common/index.html.twig" %} {% block javascript %} - + + {% endblock %} {% block stylesheet %} diff --git a/templates/mobile/lightbox/validate.html.twig b/templates/mobile/lightbox/validate.html.twig index 7cf62e4af8..9988639e2a 100644 --- a/templates/mobile/lightbox/validate.html.twig +++ b/templates/mobile/lightbox/validate.html.twig @@ -2,12 +2,21 @@ {% extends "common/index.html.twig" %} {% block javascript %} + + - {% endblock %} {% block stylesheet %} diff --git a/templates/web/lightbox/feed.html.twig b/templates/web/lightbox/feed.html.twig index 965083321d..0844091f2e 100644 --- a/templates/web/lightbox/feed.html.twig +++ b/templates/web/lightbox/feed.html.twig @@ -4,8 +4,8 @@ {% import 'common/macros.html.twig' as macro %} {% block javascript %} - - + + {% endblock %} {% block stylesheet %} diff --git a/templates/web/lightbox/index.html.twig b/templates/web/lightbox/index.html.twig index 89b9db2b4a..9ff76249e1 100644 --- a/templates/web/lightbox/index.html.twig +++ b/templates/web/lightbox/index.html.twig @@ -3,8 +3,8 @@ {% import 'common/thumbnail.html.twig' as thumbnail %} {% block javascript %} - - + + {% endblock %} {% block stylesheet %} diff --git a/templates/web/lightbox/index_layout.html.twig b/templates/web/lightbox/index_layout.html.twig index a1c31df559..e04cfe9b77 100644 --- a/templates/web/lightbox/index_layout.html.twig +++ b/templates/web/lightbox/index_layout.html.twig @@ -3,3 +3,12 @@ {% block extra_content %}
{% endblock %} +{% block bodyJavascript %} + +{% endblock %} diff --git a/templates/web/lightbox/validate.html.twig b/templates/web/lightbox/validate.html.twig index 7106031259..aeeac975c7 100644 --- a/templates/web/lightbox/validate.html.twig +++ b/templates/web/lightbox/validate.html.twig @@ -4,8 +4,8 @@ {% import 'common/macros.html.twig' as macro %} {% block javascript %} - - + + {% endblock %} {% block stylesheet %} @@ -178,7 +178,12 @@ {% endblock %} diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index 31e8c51d0b..16252d49f9 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -702,9 +702,8 @@ - - {##} - {##} + +