diff --git a/lib/classes/eventsmanager/notify/push.php b/lib/classes/eventsmanager/notify/push.php index 488d51431e..367ab499cb 100644 --- a/lib/classes/eventsmanager/notify/push.php +++ b/lib/classes/eventsmanager/notify/push.php @@ -39,8 +39,11 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract $sender = $user->getDisplayName(); $ret = [ - 'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => '', '%after_link%' => '']) + 'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => '', '%after_link%' => '']) , 'class' => ($unread == 1 ? 'reload_baskets' : '') ]; diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php index 16ff582a4f..aab62e4b83 100644 --- a/lib/classes/eventsmanager/notify/validationreminder.php +++ b/lib/classes/eventsmanager/notify/validationreminder.php @@ -53,8 +53,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra $basket_name = $this->app->trans('Une selection'); } - $bask_link = '' + $bask_link = '' . $basket_name . ''; $ret = [ diff --git a/resources/gulp/components/prod.js b/resources/gulp/components/prod.js index 09eb47f04b..9dad5d02c7 100644 --- a/resources/gulp/components/prod.js +++ b/resources/gulp/components/prod.js @@ -73,7 +73,7 @@ gulp.task('build-prod-js', function(){ config.paths.vendors + 'jquery-file-upload/js/jquery.iframe-transport.js', config.paths.vendors + 'jquery-file-upload/js/jquery.fileupload.js', config.paths.vendors + 'geonames-server-jquery-plugin/jquery.geonames.js', - config.paths.src + 'prod/js/core/lists.js', + //config.paths.src + 'prod/js/core/lists.js', config.paths.src + 'prod/js/core/selectable.js', config.paths.src + 'prod/js/core/alert.js', @@ -87,13 +87,13 @@ gulp.task('build-prod-js', function(){ // config.paths.src + 'prod/js/components/cgu.js', // config.paths.src + 'prod/js/components/preferences.js', config.paths.src + 'prod/js/components/record/editable-record.js', - config.paths.src + 'prod/js/components/push/push.js', + //config.paths.src + 'prod/js/components/push/push.js', config.paths.src + 'prod/js/prod.js', config.paths.src + 'prod/js/components/upload/upload.js', // config.paths.src + 'prod/js/components/video-editor.js', config.paths.src + 'vendors/jquery-sprintf/js/jquery.sprintf.1.0.3.js', - config.paths.src + 'prod/js/components/preview/preview.js', - config.paths.src + 'prod/js/components/editor/record-editor.js', + //config.paths.src + 'prod/js/components/preview/preview.js', + //config.paths.src + 'prod/js/components/editor/record-editor.js', config.paths.src + 'prod/js/jquery.color.animation.js', config.paths.src + 'vendors/jquery-image-enhancer/js/jquery.image_enhancer.js', config.paths.vendors + 'jquery-treeview/jquery.treeview.js', diff --git a/resources/www/prod/js/components/editor/record-editor.js b/resources/www/prod/js/components/editor/record-editor.js deleted file mode 100644 index 04e649eff5..0000000000 --- a/resources/www/prod/js/components/editor/record-editor.js +++ /dev/null @@ -1,1938 +0,0 @@ -var p4 = p4 || {}; - -var recordEditorModule = (function (p4) { - var $editorContainer = null; - $(document).ready(function () { - $editorContainer = $('#EDITWINDOW'); - $(window).bind('resize', function () { - _setPreviewEdit(); - _setSizeLimits(); - }); - - $editorContainer.on('mouseup mousedown keyup', '#idEditZTextArea', function(event){ - console.log('textarea event', event) - }) - // idEditZTextArea - }); - function initialize() { - p4.edit = {}; - p4.edit.curField = "?"; - p4.edit.editBox = $('#idFrameE'); - p4.edit.textareaIsDirty = false; - p4.edit.fieldLastValue = ""; - p4.edit.lastClickId = null; - p4.edit.sbas_id = false; - p4.edit.what = false; - p4.edit.regbasprid = false; - p4.edit.newrepresent = false; - p4.edit.ssel = false; - } - - function startThisEditing(sbas_id, what, regbasprid, ssel) { - - p4.edit.sbas_id = sbas_id; - p4.edit.what = what; - p4.edit.regbasprid = regbasprid; - p4.edit.ssel = ssel; - - for (r in p4.edit.T_records) { - var fields = {}; - - for (f in p4.edit.T_records[r].fields) { - var meta_struct_id = p4.edit.T_records[r].fields[f].meta_struct_id; - - var name = p4.edit.T_fields[meta_struct_id].name; - var label = p4.edit.T_fields[meta_struct_id].label; - - var multi = p4.edit.T_fields[meta_struct_id].multi; - var required = p4.edit.T_fields[meta_struct_id].required; - var readonly = p4.edit.T_fields[meta_struct_id].readonly; - var maxLength = p4.edit.T_fields[meta_struct_id].maxLength; - var minLength = p4.edit.T_fields[meta_struct_id].minLength; - var type = p4.edit.T_fields[meta_struct_id].type; - var separator = p4.edit.T_fields[meta_struct_id].separator; - var vocabularyControl = p4.edit.T_fields[meta_struct_id].vocabularyControl; - var vocabularyRestricted = p4.edit.T_fields[meta_struct_id].vocabularyRestricted; - - var fieldOptions = { - multi: multi, - required: required, - readonly: readonly, - maxLength: maxLength, - minLength: minLength, - type: type, - separator: separator, - vocabularyControl: vocabularyControl, - vocabularyRestricted: vocabularyRestricted - }; - - var databoxField = new p4.databoxField(name, label, meta_struct_id, fieldOptions); - - var values = []; - - for (v in p4.edit.T_records[r].fields[f].values) { - var meta_id = p4.edit.T_records[r].fields[f].values[v].meta_id; - var value = p4.edit.T_records[r].fields[f].values[v].value; - var vocabularyId = p4.edit.T_records[r].fields[f].values[v].vocabularyId; - - values.push(new p4.recordFieldValue(meta_id, value, vocabularyId)); - } - - fields[f] = new p4.recordField(databoxField, values); - } - - p4.edit.T_records[r].fields = fields; - p4.edit.fields = fields; - - } - - $('#EditTextMultiValued').bind('keyup', function () { - reveal_mval($(this).val()); - }); - - $('#EDIT_MID_R .tabs').tabs(); - - $('#divS div.edit_field:odd').addClass('odd'); - $('#divS div').bind('mouseover',function () { - $(this).addClass('hover'); - }).bind('mouseout', function () { - $(this).removeClass('hover'); - }); - - $('#editcontextwrap').remove(); - - if ($('#editcontextwrap').length == 0) - $('body').append('
'); - - - // if is a group, only select the group - if (p4.edit.what === 'GRP') { - _toggleGroupSelection(); - } else { - _edit_select_all(); - } - - - $('.previewTips, .DCESTips, .fieldTips', p4.edit.editBox).tooltip({ - fixable: true, - fixableIndex: 1200 - }); - $('.infoTips', p4.edit.editBox).tooltip(); - - if (p4.edit.what == 'GRP') { - $('#EDIT_FILM2 .reg_opts').show(); - - $.each($('#EDIT_FILM2 .contextMenuTrigger'), function () { - - var id = $(this).attr('id').split('_').slice(1, 3).join('_'); - $(this).contextMenu('#editContext_' + id + '', { - appendTo: '#editcontextwrap', - openEvt: 'click', - dropDown: true, - theme: 'vista', - dropDown: true, - showTransition: 'slideDown', - hideTransition: 'hide', - shadow: false - }); - }); - } - - _hsplit1(); - _vsplit2() - _vsplit1(); - - $('#EDIT_TOP', p4.edit.editBox).resizable({ - handles: 's', - minHeight: 100, - resize: function () { - _hsplit1(); - _setPreviewEdit(); - }, - stop: function () { - _hsplit1(); - userModule.setPref('editing_top_box', Math.floor($('#EDIT_TOP').height() * 100 / $('#EDIT_ALL').height())); - _setSizeLimits(); - } - }); - - $('#divS_wrapper', p4.edit.editBox).resizable({ - handles: 'e', - minWidth: 200, - resize: function () { - _vsplit1(); - _setPreviewEdit(); - }, - stop: function () { - userModule.setPref('editing_right_box', Math.floor($('#divS').width() * 100 / $('#EDIT_MID_L').width())); - _vsplit1(); - _setSizeLimits(); - } - }); - - $('#EDIT_MID_R') - .css('left', $('#EDIT_MID_L').position().left + $('#EDIT_MID_L').width() + 15) - .resizable({ - handles: 'w', - minWidth: 200, - resize: function () { - _vsplit2(); - _setPreviewEdit(); - }, - stop: function () { - userModule.setPref('editing_left_box', Math.floor($('#EDIT_MID_R').width() * 100 / $('#EDIT_MID').width())); - _vsplit2(); - _setSizeLimits(); - } - }); - - $('#EDIT_ZOOMSLIDER', p4.edit.editBox).slider({ - min: 60, - max: 300, - value: p4.edit.diapoSize, - slide: function (event, ui) { - var v = $(ui.value)[0]; - $('#EDIT_FILM2 .diapo', p4.edit.editBox).width(v).height(v); - }, - change: function (event, ui) { - p4.edit.diapoSize = $(ui.value)[0]; - userModule.setPref("editing_images_size", p4.edit.diapoSize); - } - }); - - var buttons = {}; - buttons[language.valider] = function (e) { - $(this).dialog("close"); - edit_applyMultiDesc(e); - }; - buttons[language.annuler] = function (e) { - $(this).dialog("close"); - edit_cancelMultiDesc(e); - }; - - $("#EDIT_CLOSEDIALOG", p4.edit.editBox).dialog({ - autoOpen: false, - closeOnEscape: true, - resizable: false, - draggable: false, - modal: true, - buttons: buttons - }); - - var buttons = {}; - - buttons[language.valider] = function () { - var form = $("#Edit_copyPreset_dlg FORM"); - var jtitle = $(".EDIT_presetTitle", form); - if (jtitle.val() == '') { - alert(language.needTitle); - jtitle[0].focus(); - return; - } - - var fields = []; - $(":checkbox", form).each(function (idx, elem) { - var $el = $(elem); - if ($el.is(":checked")) { - var val = $el.val(); - var field = { - name: p4.edit.T_fields[val].name, - value: [] - }; - var tval; - if (p4.edit.T_fields[val].multi) { - field.value = $.map( - p4.edit.T_fields[val]._value.split(";"), - function(obj, idx){ - return obj.trim(); - } - ); - } else { - field.value = [p4.edit.T_fields[val]._value.trim()]; - } - fields.push(field); - } - }); - - $.ajax({ - type: 'POST', - url: "../prod/records/edit/presets", - data: { - sbas_id: p4.edit.sbas_id, - title: jtitle.val(), - fields: fields - }, - dataType: 'json', - success: function (data, textStatus) { - _preset_paint(data); - - if ($("#Edit_copyPreset_dlg").data("ui-dialog")) { - $("#Edit_copyPreset_dlg").dialog("close"); - } - } - }); - }; - - buttons[language.annuler] = function () { - $(this).dialog("close"); - - }; - - $("#Edit_copyPreset_dlg", p4.edit.editBox).dialog({ - stack: true, - closeOnEscape: true, - resizable: false, - draggable: false, - autoOpen: false, - modal: true, - width: 600, - title: language.newPreset, - close: function (event, ui) { - $(this).dialog("widget").css("z-index", "auto"); - }, - open: function (event, ui) { - $(this).dialog("widget").css("z-index", "5000"); - $(".EDIT_presetTitle")[0].focus(); - }, - buttons: buttons - }); - - $('#idEditDateZone', p4.edit.editBox).datepicker({ - changeYear: true, - changeMonth: true, - dateFormat: 'yy/mm/dd', - onSelect: function (dateText, inst) { - var lval = $('#idEditZTextArea', p4.edit.editBox).val(); - if (lval != dateText) { - fieldLastValue = lval; - $('#idEditZTextArea', p4.edit.editBox).val(dateText); - $('#idEditZTextArea').trigger('keyup.maxLength'); - textareaIsDirty = true; - edit_validField(null, 'ok'); - } - } - }); - - ETHSeeker = new _EditThesaurusSeeker(p4.edit.sbas_id); - - _setSizeLimits(); - - $.ajax({ - type: 'GET', - url: "../prod/records/edit/presets", - data: { - sbas_id: p4.edit.sbas_id, - }, - dataType: 'json', - success: function (data, textStatus) { - _preset_paint(data); - } - }); - - _check_required(); - - $('#TH_Opresets button.adder').bind('click', function () { - _preset_copy(); - }); - - try { - $('#divS .edit_field:first').trigger('mousedown'); - } - catch (err) { - - } - } - - function _toggleGroupSelection() { - var groupIndex = 0; - edit_clk_editimg(false, groupIndex); - - } - - function _preset_paint(data) { - $(".EDIT_presets_list", p4.edit.editBox).html(data.html); - $(".EDIT_presets_list A.triangle").click( - function () { - $(this).parent().parent().toggleClass("opened"); - return false; - } - ); - - $(".EDIT_presets_list A.title").dblclick( - function () { - var preset_id = $(this).parent().parent().attr("id"); - if (preset_id.substr(0, 12) == "EDIT_PRESET_") - _preset_load(preset_id.substr(12)); - return false; - } - ); - - $(".EDIT_presets_list A.delete").click( - function () { - var li = $(this).closest("LI"); - var preset_id = li.attr("id"); - var title = $(this).parent().children(".title").html(); - if (preset_id.substr(0, 12) == "EDIT_PRESET_" && confirm("supprimer le preset '" + title + "' ?")) { - _preset_delete(preset_id.substr(12), li); - } - return false; - } - ); - } - - function _preset_copy() { - var html = ""; - for (i in p4.edit.T_fields) { - if (p4.edit.T_fields[i]._status == 1) { - if (p4.edit.T_fields[i].readonly) { - continue; - } - var c = p4.edit.T_fields[i]._value === "" ? "" : "checked=\"1\""; - var v = p4.edit.T_fields[i]._value; - html += "
"; - html += _cleanTags(p4.edit.T_fields[i]._value) + "
"; - } - } - $("#Edit_copyPreset_dlg FORM DIV").html(html); - var $dialog = $("#Edit_copyPreset_dlg"); - if ($dialog.data("ui-dialog")) { - // to show dialog on top of edit window - $dialog.dialog("widget").css("z-index", 1300); - $dialog.dialog("open"); - } - } - - function _preset_delete(preset_id, li) { - $.ajax({ - type: 'DELETE', - url: "../prod/records/edit/presets/" + preset_id, - data: {}, - dataType: 'json', - success: function (data, textStatus) { - li.remove(); - } - }); - } - - function _preset_load(preset_id) { - $.ajax({ - type: 'GET', - url: "../prod/records/edit/presets/" + preset_id, - data: {}, - dataType: 'json', - success: function (data, textStatus) { - if ($("#Edit_copyPreset_dlg").data("ui-dialog")) { - $("#Edit_copyPreset_dlg").dialog("close"); - } - - for (i in p4.edit.T_fields) { - p4.edit.T_fields[i].preset = null; - if (typeof(data.fields[p4.edit.T_fields[i].name]) != "undefined") { - p4.edit.T_fields[i].preset = data.fields[p4.edit.T_fields[i].name]; - } - } - for (var r = 0; r < p4.edit.T_records.length; r++) { - if (!p4.edit.T_records[r]._selected) - continue; - - for (i in p4.edit.T_fields) { - if (p4.edit.T_fields[i].preset != null) { - for (val in p4.edit.T_fields[i].preset) { - // fix : some (old, malformed) presets values may need trim() - p4.edit.T_records[r].fields["" + i].addValue(p4.edit.T_fields[i].preset[val].trim(), false, null); - } - } - } - } - _updateEditSelectedRecords(); - } - }); - } - - function _setPreviewEdit() { - if (!$('#TH_Opreview').is(':visible')) - return false; - - var selected = $('#EDIT_FILM2 .diapo.selected'); - - if (selected.length != 1) { - return; - } - - var id = selected.attr('id').split('_').pop(); - - var container = $('#TH_Opreview'); - var zoomable = $('img.record.zoomable', container); - - if (zoomable.length > 0 && zoomable.hasClass('zoomed')) - return; - - // var datas = p4.edit.T_records[id].preview; - - var h = parseInt($('input[name=height]', container).val()); - var w = parseInt($('input[name=width]', container).val()); - - // if(datas.doctype == 'video') - // { - // var h = parseInt(datas.height); - // var w = parseInt(datas.width); - // } - var t = 0; - var de = 0; - - var margX = 0; - var margY = 0; - - if ($('img.record.record_audio', container).length > 0) { - var margY = 100; - de = 60; - } - - var display_box = $('#TH_Opreview .PNB10'); - var dwidth = display_box.width(); - var dheight = display_box.height(); - - - // if(datas.doctype != 'flash') - // { - var ratioP = w / h; - var ratioD = dwidth / dheight; - - if (ratioD > ratioP) { - //je regle la hauteur d'abord - if ((parseInt(h) + margY) > dheight) { - h = Math.round(dheight - margY); - w = Math.round(h * ratioP); - } - } - else { - if ((parseInt(w) + margX) > dwidth) { - w = Math.round(dwidth - margX); - h = Math.round(w / ratioP); - } - } - // } - // else - // { - // - // h = Math.round(dheight - margY); - // w = Math.round(dwidth - margX); - // } - t = Math.round((dheight - h - de) / 2); - var l = Math.round((dwidth - w) / 2); - $('.record', container).css({ - width: w, - height: h, - top: t, - left: l - }).attr('width', w).attr('height', h); - - } - - function _previewEdit(r) { - - $('#TH_Opreview .PNB10').empty().append(p4.edit.T_records[r].preview); - - if ($('img.PREVIEW_PIC.zoomable').length > 0) { - $('img.PREVIEW_PIC.zoomable').draggable(); - } - _setPreviewEdit(); - } - - function skipImage(evt, step) { - var cache = $('#EDIT_FILM2'); - var first = $('.diapo.selected:first', cache); - var last = $('.diapo.selected:last', cache); - var sel = $('.diapo.selected', cache); - - sel.removeClass('selected'); - - var i = step == 1 ? (parseInt(last.attr('pos')) + 1) : (parseInt(first.attr('pos')) - 1); - - if (i < 0) - i = parseInt($('.diapo:last', cache).attr('pos')); - else if (i >= $('.diapo', cache).length) - i = 0; - - edit_clk_editimg(evt, i); - } - - function setRegDefault(n, record_id) { - p4.edit.newrepresent = record_id; - - var src = $('#idEditDiapo_' + n).find('img.edit_IMGT').attr('src'); - var style = $('#idEditDiapo_' + n).find('img.edit_IMGT').attr('style'); - - $('#EDIT_GRPDIAPO .edit_IMGT').attr('src', src).attr('style', style); - } - - //// --------------------------------------------------------------------------- -//// on change de champ courant -//// --------------------------------------------------------------------------- - - function _editField(evt, meta_struct_id) { - document.getElementById('idEditZTextArea').blur(); - document.getElementById('EditTextMultiValued').blur(); - $(".editDiaButtons", p4.edit.editBox).hide(); - - $('#idEditZTextArea, #EditTextMultiValued').unbind('keyup.maxLength'); - - p4.edit.curField = meta_struct_id; - if (meta_struct_id >= 0) { - var name = p4.edit.T_fields[meta_struct_id].label + (p4.edit.T_fields[meta_struct_id].required ? ' * ' : ''); - $("#idFieldNameEdit", p4.edit.editBox).html(name); - - var vocabType = p4.edit.T_fields[meta_struct_id].vocabularyControl; - - $('#idEditZTextArea, #EditTextMultiValued').autocomplete({ - minLength: 2, - appendTo: "#idEditZone", - source: function (request, response) { - $.ajax({ - url: '../prod/records/edit/vocabulary/' + vocabType + '/', - dataType: "json", - data: { - sbas_id: p4.edit.sbas_id, - query: request.term - }, - success: function (data) { - response(data.results); - } - }); - }, - select: function (event, ui) { - - edit_addmval(ui.item.label, ui.item.id); - - return false; - } - }); - - - if (p4.edit.T_fields[meta_struct_id].maxLength > 0) { - var idexplain = $("#idExplain"); - idexplain.html(''); - - $('#idEditZTextArea, #EditTextMultiValued').bind('keyup.maxLength',function () { - var remaining = Math.max((p4.edit.T_fields[meta_struct_id].maxLength - $(this).val().length), 0); - idexplain.html(" Caracteres restants : " + (remaining) + ""); - $('.metadatas_restrictionsTips', idexplain).tooltip(); - }).trigger('keyup.maxLength'); - } - else { - $("#idExplain").html(""); - } - - if (!p4.edit.T_fields[meta_struct_id].multi) { - // champ monovalue : textarea - $(".editDiaButtons", p4.edit.editBox).hide(); - - if (p4.edit.T_fields[meta_struct_id].type == "date") { - $("#idEditZTextArea", p4.edit.editBox).css("height", "16px"); - $("#idEditDateZone", p4.edit.editBox).show(); - } - else { - $("#idEditDateZone", p4.edit.editBox).hide(); - $("#idEditZTextArea", p4.edit.editBox).css("height", "100%"); - } - - $("#ZTextStatus", p4.edit.editBox).hide(); - $("#ZTextMultiValued", p4.edit.editBox).hide(); - $("#ZTextMonoValued", p4.edit.editBox).show(); - - if (p4.edit.T_fields[meta_struct_id]._status == 2) { - // heterogene - $("#idEditZTextArea", p4.edit.editBox).val(p4.edit.fieldLastValue = ""); - $("#idEditZTextArea", p4.edit.editBox).addClass("hetero"); - $("#idDivButtons", p4.edit.editBox).show(); // valeurs h�t�rog�nes : les 3 boutons remplacer/ajouter/annuler - } - else { - // homogene - $("#idEditZTextArea", p4.edit.editBox).val(p4.edit.fieldLastValue = p4.edit.T_fields[meta_struct_id]._value); - $("#idEditZTextArea", p4.edit.editBox).removeClass("hetero"); - - $("#idDivButtons", p4.edit.editBox).hide(); // valeurs homog�nes - if (p4.edit.T_fields[meta_struct_id].type == "date") { - var v = p4.edit.T_fields[meta_struct_id]._value.split(' '); - d = v[0].split('/'); - var dateObj = new Date(); - if (d.length == 3) { - dateObj.setYear(d[0]); - dateObj.setMonth((d[1] - 1)); - dateObj.setDate(d[2]); - } - - if ($("#idEditDateZone", p4.edit.editBox).data("ui-datepicker")) { - $("#idEditDateZone", p4.edit.editBox).datepicker('setDate', dateObj); - } - } - } - p4.edit.textareaIsDirty = false; - - $("#idEditZone", p4.edit.editBox).show(); - - $('#idEditZTextArea').trigger('keyup.maxLength'); - - self.setTimeout("document.getElementById('idEditZTextArea').focus();", 50); - } - else { - // champ multivalue : liste - $("#ZTextStatus", p4.edit.editBox).hide(); - $("#ZTextMonoValued", p4.edit.editBox).hide(); - $("#ZTextMultiValued", p4.edit.editBox).show(); - - $("#idDivButtons", p4.edit.editBox).hide(); // valeurs homogenes - - _updateCurrentMval(meta_struct_id); - - $('#EditTextMultiValued', p4.edit.editBox).val(""); - $('#idEditZone', p4.edit.editBox).show(); - - $('#EditTextMultiValued').trigger('keyup.maxLength'); - - self.setTimeout("document.getElementById('EditTextMultiValued').focus();", 50); - -// reveal_mval(); - } - } - else { - // pas de champ, masquer la zone du textarea - $("#idEditZone", p4.edit.editBox).hide(); - $(".editDiaButtons", p4.edit.editBox).hide(); - - } - _activeField(); - } - - function _updateEditSelectedRecords(evt) { - $(".editDiaButtons", p4.edit.editBox).hide(); - - for (n in p4.edit.T_statbits) // tous les statusbits de la base - { - p4.edit.T_statbits[n]._value = "-1"; // val unknown - for (i in p4.edit.T_records) { - if (!p4.edit.T_records[i]._selected) - continue; - if (p4.edit.T_records[i].statbits.length === 0) - continue; - - if (p4.edit.T_statbits[n]._value == "-1") - p4.edit.T_statbits[n]._value = p4.edit.T_records[i].statbits[n].value; - else if (p4.edit.T_statbits[n]._value != p4.edit.T_records[i].statbits[n].value) - p4.edit.T_statbits[n]._value = "2"; - } - var ck0 = $("#idCheckboxStatbit0_" + n); - var ck1 = $("#idCheckboxStatbit1_" + n); - - switch (p4.edit.T_statbits[n]._value) { - case "0": - case 0: - ck0.removeClass('gui_ckbox_0 gui_ckbox_2').addClass("gui_ckbox_1"); - ck1.removeClass('gui_ckbox_1 gui_ckbox_2').addClass("gui_ckbox_0"); - break; - case "1": - case 1: - ck0.removeClass('gui_ckbox_1 gui_ckbox_2').addClass("gui_ckbox_0"); - ck1.removeClass('gui_ckbox_0 gui_ckbox_2').addClass("gui_ckbox_1"); - break; - case "2": - ck0.removeClass('gui_ckbox_0 gui_ckbox_1').addClass("gui_ckbox_2"); - ck1.removeClass('gui_ckbox_0 gui_ckbox_1').addClass("gui_ckbox_2"); - break; - } - } - - - var nostatus = $('.diapo.selected.nostatus', p4.edit.editBox).length; - var status_box = $('#ZTextStatus'); - $('.nostatus, .somestatus, .displaystatus', status_box).hide(); - - if (nostatus == 0) { - $('.displaystatus', status_box).show(); - } - else { - var yesstatus = $('.diapo.selected', p4.edit.editBox).length; - if (nostatus == yesstatus) { - $('.nostatus', status_box).show(); - } - else { - $('.somestatus, .displaystatus', status_box).show(); - } - } - - // calcul des valeurs suggerees COMMUNES aux records (collections) selectionnes // - for (f in p4.edit.T_fields) // tous les champs de la base - p4.edit.T_fields[f]._sgval = []; - var t_lsgval = {}; - var t_selcol = {}; // les bases (coll) dont au - une thumb est selectionnee - var ncolsel = 0; - var nrecsel = 0; - for (i in p4.edit.T_records) { - if (!p4.edit.T_records[i]._selected) - continue; - nrecsel++; - - var bid = "b" + p4.edit.T_records[i].bid; - if (t_selcol[bid]) - continue; - - t_selcol[bid] = 1; - ncolsel++; - for (f in p4.edit.T_sgval[bid]) { - if (!t_lsgval[f]) - t_lsgval[f] = {}; - for (ivs in p4.edit.T_sgval[bid][f]) { - vs = p4.edit.T_sgval[bid][f][ivs]; - if (!t_lsgval[f][vs]) - t_lsgval[f][vs] = 0; - t_lsgval[f][vs]++; - } - } - } - var t_sgval = {}; - for (f in t_lsgval) { - for (sv in t_lsgval[f]) { - if (t_lsgval[f][sv] == ncolsel) { - p4.edit.T_fields[f]._sgval.push({ - label: sv, - onclick: function (menuItem, menu, e, label) { - if (p4.edit.T_fields[p4.edit.curField].multi) { - $("#EditTextMultiValued", p4.edit.editBox).val(label); - $('#EditTextMultiValued').trigger('keyup.maxLength'); - edit_addmval($('#EditTextMultiValued', p4.edit.editBox).val(), null); - } - else { - if (utilsModule.is_ctrl_key(e)) { - var t = $("#idEditZTextArea", p4.edit.editBox).val(); - $("#idEditZTextArea", p4.edit.editBox).val(t + (t ? " ; " : "") + label); - } - else { - $("#idEditZTextArea", p4.edit.editBox).val(label); - } - $('#idEditZTextArea').trigger('keyup.maxLength'); - p4.edit.textareaIsDirty = true; - if (p4.edit.T_fields[p4.edit.curField]._status != 2) - edit_validField(evt, "ask_ok"); - } - } - } - ); - } - } - if (p4.edit.T_fields[f]._sgval.length > 0) { - $("#editSGtri_" + f, p4.edit.editBox).css("visibility", "visible"); - $("#editSGtri_" + f, p4.edit.editBox).unbind(); - $("#editSGtri_" + f, p4.edit.editBox).contextMenu( - p4.edit.T_fields[f]._sgval, - { - theme: 'vista', - openEvt: "click", - beforeShow: function (a, b, c, d) { - var fid = this.target.getAttribute('id').substr(10); - if (!p4.edit.textareaIsDirty || edit_validField(null, "ask_ok") == true) { - _editField(null, fid); - return(true); - } - else { - return(false); - } - } - } - ); - } - else { - $("#editSGtri_" + f, p4.edit.editBox).css("visibility", "hidden"); - } - } - - //$('#idFrameE .ww_status', p4.edit.editBox).html(nrecsel + " record(s) selected for editing"); - - _updateFieldDisplay(); - - if (p4.edit.curField == -1) - _editStatus(evt); - else - _editField(evt, p4.edit.curField); - } - - function _updateFieldDisplay() { - for (f in p4.edit.T_fields) // tous les champs de la base - { - p4.edit.T_fields[f]._status = 0; // val unknown - for (i in p4.edit.T_records) { - if (!p4.edit.T_records[i]._selected) - continue; - - - if (p4.edit.T_records[i].fields[f].isEmpty()) { - var v = ""; - } - else { - // le champ existe dans la fiche - if (p4.edit.T_fields[f].multi) { - // champ multi : on compare la concat des valeurs - var v = p4.edit.T_records[i].fields[f].getSerializedValues() - } - else { - var v = p4.edit.T_records[i].fields[f].getValue().getValue(); - } - } - - if (p4.edit.T_fields[f]._status == 0) { - p4.edit.T_fields[f]._value = v; - p4.edit.T_fields[f]._status = 1; - } - else if (p4.edit.T_fields[f]._status == 1 && p4.edit.T_fields[f]._value != v) { - p4.edit.T_fields[f]._value = "*****"; - p4.edit.T_fields[f]._status = 2; - break; // plus la peine de verifier le champ sur les autres records - } - } - if (o = document.getElementById("idEditField_" + f)) { - if (p4.edit.T_fields[f]._status == 2) // mixed - o.innerHTML = "xxxxx"; - else { - var v = p4.edit.T_fields[f]._value; - v = (v instanceof(Array)) ? v.join(";") : v; - o.innerHTML = _cleanTags(v).replace(/\n/gm, "
"); - } - } - } - } - // --------------------------------------------------------------------------- -// on active le pseudo champ 'status' -// --------------------------------------------------------------------------- - function _editStatus(evt) { - $(".editDiaButtons", p4.edit.editBox).hide(); - - document.getElementById('idEditZTextArea').blur(); - document.getElementById('EditTextMultiValued').blur(); - - $("#idFieldNameEdit", p4.edit.editBox).html("[STATUS]"); - $("#idExplain", p4.edit.editBox).html(" "); - - $("#ZTextMultiValued", p4.edit.editBox).hide(); - $("#ZTextMonoValued", p4.edit.editBox).hide(); - $("#ZTextStatus", p4.edit.editBox).show(); - - $("#idEditZone", p4.edit.editBox).show(); - - document.getElementById("editFakefocus").focus(); - p4.edit.curField = -1; - _activeField(); - } - - function _updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) { - - // on compare toutes les valeurs de chaque fiche selectionnee - p4.edit.T_mval = []; // tab des mots, pour trier - var a = []; // key : mot ; val : nbr d'occurences distinctes - var n = 0; // le nbr de records selectionnes - - for (r in p4.edit.T_records) { - if (!p4.edit.T_records[r]._selected) - continue; - - p4.edit.T_records[r].fields[meta_struct_id].sort(_sortCompareMetas); - - var values = p4.edit.T_records[r].fields[meta_struct_id].getValues(); - - for (v in values) { - var word = values[v].getValue(); - var key = values[v].getVocabularyId() + '%' + word; - - if (typeof(a[key]) == 'undefined') { - a[key] = { - 'n': 0, - 'f': new Array() - }; // n:nbr d'occurences DISTINCTES du mot ; f:flag presence mot dans r - p4.edit.T_mval.push(values[v]); - } - - if (!a[key].f[r]) - a[key].n++; // premiere apparition du mot dans le record r - a[key].f[r] = true; // on ne recomptera pas le mot s'il apparait a nouveau dans le meme record - - } - - n++; - } - - p4.edit.T_mval.sort(_sortCompareMetas); - - var t = ""; - for (var i in p4.edit.T_mval) // pour lire le tableau 'a' dans l'ordre trie par 'p4.edit.T_mval' - { - var value = p4.edit.T_mval[i]; - var word = value.getValue(); - var key = value.getVocabularyId() + '%' + word; - - var extra = value.getVocabularyId() ? ' ' : ''; - - if (i > 0) { - if (value.getVocabularyId() !== null && p4.edit.T_mval[i - 1].getVocabularyId() == value.getVocabularyId()) { - continue; - } - if (value.getVocabularyId() === null && p4.edit.T_mval[i - 1].getVocabularyId() === null) { - if (p4.edit.T_mval[i - 1].getValue() == value.getValue()) { - continue; // on n'accepte pas les doublons - } - } - } - - t += "
" - + '
' - + extra - + '' - + $('
').text(word).html() - + "
" - + ' ' - + '' - + "
" - + "
"; - } - $('#ZTextMultiValued_values', p4.edit.editBox).html(t); - - $('#ZTextMultiValued_values .add_all', p4.edit.editBox).unbind('click').bind('click', function () { - var container = $(this).closest('div'); - - var span = $('span.value', container) - - var value = span.text(); - var vocab_id = span.attr('vocabid'); - - edit_addmval(value, vocab_id); - _updateFieldDisplay(); - return false; - }); - $('#ZTextMultiValued_values .remove_all', p4.edit.editBox).unbind('click').bind('click', function () { - var container = $(this).closest('div'); - - var span = $('span.value', container) - - var value = span.text(); - var vocab_id = span.attr('vocabid'); - - _edit_delmval(value, vocab_id); - _updateFieldDisplay(); - return false; - }); - - _updateFieldDisplay(); - } - - // --------------------------------------------------------------------------------------------------------- -// en mode textarea, on clique sur ok, cancel ou fusion -// appele egalement quand on essaye de changer de champ ou d'image : si ret=false on interdit le changement -// --------------------------------------------------------------------------------------------------------- - function edit_validField(evt, action) { - // action : 'ok', 'fusion' ou 'cancel' - if (p4.edit.curField == "?") - return(true); - - if (action == "cancel") { - // on restore le contenu du champ - $("#idEditZTextArea", p4.edit.editBox).val(p4.edit.fieldLastValue); - $('#idEditZTextArea').trigger('keyup.maxLength'); - p4.edit.textareaIsDirty = false; - return(true); - } - - if (action == "ask_ok" && p4.edit.textareaIsDirty && p4.edit.T_fields[p4.edit.curField]._status == 2) { - alert(language.edit_hetero); - return(false); - } - var o, newvalue; - if (o = document.getElementById("idEditField_" + p4.edit.curField)) { - t = $("#idEditZTextArea", p4.edit.editBox).val(); - - status = 0; - firstvalue = ""; - for (i = 0; i < p4.edit.T_records.length; i++) { - if (!p4.edit.T_records[i]._selected) - continue; // on ne modifie pas les fiches non selectionnees - - if (action == "ok" || action == "ask_ok") { - p4.edit.T_records[i].fields[p4.edit.curField].addValue(t, false, null); - } - else if (action == "fusion" || action == "ask_fusion") { - p4.edit.T_records[i].fields[p4.edit.curField].addValue(t, true, null); - } - - _check_required(i, p4.edit.curField); - } - } - - _updateFieldDisplay(); - - p4.edit.textareaIsDirty = false; - - - _editField(evt, p4.edit.curField); - return(true); - } - - // --------------------------------------------------------------------------- -// on a clique sur une checkbox de status -// --------------------------------------------------------------------------- - function edit_clkstatus(evt, bit, val) { - var ck0 = $("#idCheckboxStatbit0_" + bit); - var ck1 = $("#idCheckboxStatbit1_" + bit); - switch (val) { - case 0: - ck0.attr('class', "gui_ckbox_1"); - ck1.attr('class', "gui_ckbox_0"); - break; - case 1: - ck0.attr('class', "gui_ckbox_0"); - ck1.attr('class', "gui_ckbox_1"); - break; - } - var id; - for (id in p4.edit.T_records) { - if (p4.edit.T_records[id]._selected) // toutes les fiches selectionnees - { - if ($('#idEditDiapo_' + id).hasClass('nostatus')) - continue; - - p4.edit.T_records[id].statbits[bit].value = val; - p4.edit.T_records[id].statbits[bit].dirty = true; - } - } - } - - // --------------------------------------------------------------------------- -// on a clique sur une thumbnail -// --------------------------------------------------------------------------- - function edit_clk_editimg(evt, i) { - if (p4.edit.curField >= 0) { - if (p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok") == false) - return; - } - - // guideline : si on mousedown sur une selection, c'est qu'on risque de draguer, donc on ne desectionne pas - if (evt && evt.type == "mousedown" && p4.edit.T_records[i]._selected) - return; - - if (evt && utilsModule.is_shift_key(evt) && p4.edit.lastClickId != null) { - // shift donc on sel du p4.edit.lastClickId a ici - var pos_from = p4.edit.T_pos[p4.edit.lastClickId]; - var pos_to = p4.edit.T_pos[i]; - if (pos_from > pos_to) { - var tmp = pos_from; - pos_from = pos_to; - pos_to = tmp; - } - - var pos; - for (pos = pos_from; pos <= pos_to; pos++) { - var id = p4.edit.T_id[pos]; - if (!p4.edit.T_records[id]._selected) // toutes les fiches selectionnees - { - p4.edit.T_records[id]._selected = true; - $("#idEditDiapo_" + id, p4.edit.editBox).addClass('selected'); - } - } - } - else { - if (!evt || !utilsModule.is_ctrl_key(evt)) { - // on deselectionne tout avant - var id; - for (id in p4.edit.T_records) { - if (p4.edit.T_records[id]._selected) // toutes les fiches selectionnees - { - p4.edit.T_records[id]._selected = false; - $("#idEditDiapo_" + id, p4.edit.editBox).removeClass('selected'); - } - } - } - if (i >= 0) { - p4.edit.T_records[i]._selected = !p4.edit.T_records[i]._selected; - if (p4.edit.T_records[i]._selected) - $("#idEditDiapo_" + i, p4.edit.editBox).addClass('selected'); - else - $("#idEditDiapo_" + i, p4.edit.editBox).removeClass('selected'); - } - } - - $('#TH_Opreview .PNB10').empty(); - - var selected = $('#EDIT_FILM2 .diapo.selected'); - if (selected.length == 1) { - - var r = selected.attr('id').split('_').pop(); - _previewEdit(r); - } - - p4.edit.lastClickId = i; - _updateEditSelectedRecords(evt); - } - - // ---------------------------------------------------------------------------------- -// on a clique sur le 'ok' general : save -// ---------------------------------------------------------------------------------- - function edit_applyMultiDesc(evt) { - var sendorder = ""; - var sendChuOrder = ""; - - var t = []; - - if (p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok") == false) - return(false); - - var required_fields = _check_required(); - - if (required_fields) { - alert(language.some_required_fields); - return; - } - - $("#EDIT_ALL", p4.edit.editBox).hide(); - - $("#EDIT_WORKING", p4.edit.editBox).show(); - - for (r in p4.edit.T_records) { - var record_datas = { - record_id: p4.edit.T_records[r].rid, - metadatas: [], - edit: 0, - status: null - }; - - var editDirty = false; - - for (f in p4.edit.T_records[r].fields) { - if (!p4.edit.T_records[r].fields[f].isDirty()) { - continue; - } - - editDirty = true; - record_datas.edit = 1; - - record_datas.metadatas = record_datas.metadatas.concat( - p4.edit.T_records[r].fields[f].exportDatas() - ); - } - - // les statbits - var tsb = []; - for (var n = 0; n < 64; n++) - tsb[n] = 'x'; - sb_dirty = false; - for (var n in p4.edit.T_records[r].statbits) { - if (p4.edit.T_records[r].statbits[n].dirty) { - tsb[63 - n] = p4.edit.T_records[r].statbits[n].value; - sb_dirty = true; - } - } - - if (sb_dirty || editDirty) { - if (sb_dirty === true) - record_datas.status = tsb.join(""); - - t.push(record_datas); - } - } - - var options = { - mds: t, - sbid: p4.edit.sbas_id, - act: 'WORK', - lst: $('#edit_lst').val(), - act_option: 'SAVE' + p4.edit.what, - regbasprid: p4.edit.regbasprid, - // newrepresent:p4.edit.newrepresent, - ssel: p4.edit.ssel - }; - if (p4.edit.newrepresent != false) - options.newrepresent = p4.edit.newrepresent; - - $.ajax({ - url: "../prod/records/edit/apply/", - data: options - // ,dataType:'json' - , - type: 'POST', - success: function (data) { - if (p4.edit.what == 'GRP' || p4.edit.what == 'SSEL') { - p4.WorkZone.refresh('current'); - } - $("#Edit_copyPreset_dlg").remove(); - $('#EDITWINDOW').hide(); - commonModule.hideOverlay(2); - if (p4.preview.open) - recordPreviewModule.reloadPreview(); - return; - } - }); - - } - - function edit_cancelMultiDesc(evt) { - - - var dirty = false; - - evt.cancelBubble = true; - if (evt.stopPropagation) - evt.stopPropagation(); - - if (p4.edit.curField >= 0) { - if (p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok") == false) - return; - } - - for (r in p4.edit.T_records) { - for (f in p4.edit.T_records[r].fields) { - if ((dirty |= p4.edit.T_records[r].fields[f].isDirty())) - break; - } - for (var n in p4.edit.T_records[r].statbits) { - if ((dirty |= p4.edit.T_records[r].statbits[n].dirty)) - break; - } - } - if (!dirty || confirm(language.confirm_abandon)) { - $("#Edit_copyPreset_dlg").remove(); - $('#idFrameE .ww_content', p4.edit.editBox).empty(); - - // on reaffiche tous les thesaurus - for (i in p4.thesau.thlist) // tous les thesaurus - { - var bid = p4.thesau.thlist[i].sbas_id; - var e = document.getElementById('TH_T.' + bid + '.T'); - if (e) - e.style.display = ""; - } - self.setTimeout("$('#EDITWINDOW').fadeOut();commonModule.hideOverlay(2);", 100); - - } - } - - function _EditThesaurusSeeker(sbas_id) { - this.jq = null; - - this.sbas_id = sbas_id; - - var zid = ("" + sbas_id).replace(new RegExp("\\.", "g"), "\\.") + "\\.T"; - - this.TH_P_node = $("#TH_P\\." + zid, p4.edit.editBox); - this.TH_K_node = $("#TH_K\\." + zid, p4.edit.editBox); - - this._ctimer = null; - - this.search = function (txt) { - if (this._ctimer) - clearTimeout(this._ctimer); - var js = "ETHSeeker.search_delayed('" + txt.replace("'", "\\'") + "');"; - this._ctimer = setTimeout(js, 125); - }; - - this.search_delayed = function (txt) { - if (this.jq && typeof this.jq.abort == "function") { - this.jq.abort(); - this.jq = null; - } - txt = txt.replace("'", "\\'"); - var url = "/xmlhttp/openbranches_prod.h.php"; - var parms = { - bid: this.sbas_id, - lng: p4.lng, - t: txt, - mod: "TREE", - u: Math.random() - }; - - var me = this; - - this.jq = $.ajax({ - url: url, - data: parms, - type: 'POST', - success: function (ret) { - me.TH_P_node.html("..."); - me.TH_K_node.attr("class", "h").html(ret); - me.jq = null; - }, - error: function () { - - }, - timeout: function () { - - } - }); - }; - - this.openBranch = function (id, thid) { - if (this.jq) { - this.jq.abort(); - this.jq = null; - } - var url = "/xmlhttp/getterm_prod.h.php"; - var parms = { - bid: this.sbas_id, - lng: p4.lng, - sortsy: 1, - id: thid, - typ: "TH" - }; - var me = this; - - - this.jq = $.ajax({ - url: url, - data: parms, - success: function (ret) { - var zid = "#TH_K\\." + id.replace(new RegExp("\\.", "g"), "\\."); // escape les '.' pour jquery - $(zid, p4.edit.editBox).html(ret); - me.jq = null; - }, - error: function () { - - }, - timeout: function () { - - } - }); - }; - } - - function edit_clickThesaurus(event) // onclick dans le thesaurus - { - // on cherche ou on a clique - for (e = event.srcElement ? event.srcElement : event.target; e && ((!e.tagName) || (!e.id)); e = e.parentNode) - ; - if (e) { - switch (e.id.substr(0, 4)) { - case "TH_P": // +/- de deploiement de mot - js = "recordEditorModule.edit_thesaurus_ow('" + e.id.substr(5) + "')"; - self.setTimeout(js, 10); - break; - } - } - return(false); - } - - function edit_dblclickThesaurus(event) // ondblclick dans le thesaurus - { - for (e = event.srcElement ? event.srcElement : event.target; e && ((!e.tagName) || (!e.id)); e = e.parentNode) - ; - if (e) { - switch (e.id.substr(0, 4)) { - case "TH_W": - if (p4.edit.curField >= 0) { - var w = $(e).text(); - if (p4.edit.T_fields[p4.edit.curField].multi) { - $("#EditTextMultiValued", p4.edit.editBox).val(w); - $('#EditTextMultiValued').trigger('keyup.maxLength'); - edit_addmval($('#EditTextMultiValued', p4.edit.editBox).val(), null); - } - else { - $("#idEditZTextArea", p4.edit.editBox).val(w); - $('#idEditZTextArea').trigger('keyup.maxLength'); - p4.edit.textareaIsDirty = true; - } - } - break; - } - } - return(false); - } - - function edit_thesaurus_ow(id) // on ouvre ou ferme une branche de thesaurus - { - var o = document.getElementById("TH_K." + id); - if (o.className == "o") { - // on ferme - o.className = "c"; - document.getElementById("TH_P." + id).innerHTML = "+"; - document.getElementById("TH_K." + id).innerHTML = language.loading; - } - else if (o.className == "c" || o.className == "h") { - // on ouvre - o.className = "o"; - document.getElementById("TH_P." + id).innerHTML = "-"; - - var t_id = id.split("."); - var sbas_id = t_id[0]; - t_id.shift(); - var thid = t_id.join("."); - var url = "/xmlhttp/getterm_prod.x.php"; - var parms = "bid=" + sbas_id; - parms += "&lng=" + p4.lng; - parms += "&sortsy=1"; - parms += "&id=" + thid; - parms += "&typ=TH"; - - ETHSeeker.openBranch(id, thid); - } - return(false); - } - - - - - function changeReplaceMode(ckRegExp) { - - - if (ckRegExp.checked) { - $("#EditSR_TX", p4.edit.editBox).hide(); - $("#EditSR_RX", p4.edit.editBox).show(); - } - else { - $("#EditSR_RX", p4.edit.editBox).hide(); - $("#EditSR_TX", p4.edit.editBox).show(); - } - } - - function _setSizeLimits() { - if (!$('#EDITWINDOW').is(':visible')) - return; - - if ($('#EDIT_TOP').data("ui-resizable")) { - $('#EDIT_TOP').resizable('option', 'maxHeight', ($('#EDIT_ALL').height() - $('#buttonEditing').height() - 10 - 160)); - } - if ($('#divS_wrapper').data("ui-resizable")) { - $('#divS_wrapper').resizable('option', 'maxWidth', ($('#EDIT_MID_L').width() - 270)); - } - if ($('#EDIT_MID_R').data("ui-resizable")) { - $('#EDIT_MID_R').resizable('option', 'maxWidth', ($('#EDIT_MID_R').width() + $('#idEditZone').width() - 240)); - } - } - - function _hsplit1() { - var el = $('#EDIT_TOP'); - if (el.length == 0) - return; - var h = $(el).outerHeight(); - $(el).height(h); - var t = $(el).offset().top + h; - - $("#EDIT_MID", p4.edit.editBox).css("top", (t) + "px"); - } - function _vsplit1() { - $('#divS_wrapper').height('auto'); - - var el = $('#divS_wrapper'); - if (el.length == 0) - return; - var a = $(el).width(); - el.width(a); - - $("#idEditZone", p4.edit.editBox).css("left", (a + 20 )); - } - function _vsplit2() { - var el = $('#EDIT_MID_R'); - if (el.length == 0) - return; - var a = $(el).width(); - el.width(a); - var v = $('#EDIT_ALL').width() - a - 20; - - $("#EDIT_MID_L", p4.edit.editBox).width(v); - } - - function _activeField() { - var meta_struct_id = parseInt(p4.edit.curField); - - meta_struct_id = (isNaN(meta_struct_id) || meta_struct_id < 0) ? 'status' : meta_struct_id; - - $('#divS div.active, #divS div.hover').removeClass('active hover'); - $('#EditFieldBox_' + meta_struct_id).addClass('active'); - - var cont = $('#divS'); - var calc = $('#EditFieldBox_' + meta_struct_id).offset().top - cont.offset().top;// hauteur relative par rapport au visible - - if (calc > cont.height() || calc < 0) { - cont.scrollTop(calc + cont.scrollTop()); - } - } - function _sortCompareMetas(a, b) { - if (typeof(a) != 'object') - return(-1); - if (typeof(b) != 'object') - return(1); - var na = a.getValue().toUpperCase(); - var nb = b.getValue().toUpperCase(); - if (na == nb) - return(0); - return(na < nb ? -1 : 1); - } - - //--------------------------------------------------------------------- -//nettoie -//--------------------------------------------------------------------- - function _cleanTags(string) { - var chars2replace = [ - { - f: "&", - t: "&" - }, - { - 'f': "<", - 't': "<" - }, - { - 'f': ">", - 't': ">" - } - ]; - for (c in chars2replace) - string = string.replace(RegExp(chars2replace[c].f, "g"), chars2replace[c].t); - return string; - } - - function _check_required(id_r, id_f) { - var required_fields = false; - - if (typeof id_r == 'undefined') - id_r = false; - if (typeof id_f == 'undefined') - id_f = false; - - for (f in p4.edit.T_fields) { - if (id_f !== false && f != id_f) - continue; - - var name = p4.edit.T_fields[f].name; - - if (!p4.edit.T_fields[f].required) - continue; - - for (r in p4.edit.T_records) { - if (id_r !== false && r != id_r) - continue; - - var elem = $('#idEditDiapo_' + r + ' .require_alert'); - - elem.hide(); - - if (!p4.edit.T_records[r].fields[f]) { - elem.show(); - required_fields = true; - } - else { - - var check_required = ''; - - // le champ existe dans la fiche - if (p4.edit.T_fields[f].multi) { - // champ multi : on compare la concat des valeurs - check_required = $.trim(p4.edit.T_records[r].fields[f].getSerializedValues()) - } - else if (p4.edit.T_records[r].fields[f].getValue()) { - check_required = $.trim(p4.edit.T_records[r].fields[f].getValue().getValue()); - } - - - if (check_required == '') { - elem.show(); - required_fields = true; - } - } - } - - } - return required_fields; - } - - - function _edit_select_all() { - console.log('timeout function called') - $('#EDIT_FILM2 .diapo', p4.edit.editBox).addClass('selected'); - - for (i in p4.edit.T_records) - p4.edit.T_records[i]._selected = true; - - p4.edit.lastClickId = 1; - - _updateEditSelectedRecords(null); // null : no evt available - } - // --------------------------------------------------------------------------- -// highlight la valeur en cours de saisie dans la liste des multi-valeurs -// appele par le onkeyup -// --------------------------------------------------------------------------- - function _reveal_mval(value, vocabularyId) { - if (typeof vocabularyId === 'undefined') - vocabularyId = null; - - var textZone = $('#EditTextMultiValued'); - - if (p4.edit.T_fields[p4.edit.curField].tbranch) { - if (value != "") - ETHSeeker.search(value); - } - - if (value != "") { - // var nsel = 0; - for (rec_i in p4.edit.T_records) { - if (p4.edit.T_records[rec_i].fields[p4.edit.curField].hasValue(value, vocabularyId)) { - $("#idEditDiaButtonsP_" + rec_i).hide(); - var talt = $.sprintf(language.editDelSimple, value); - $("#idEditDiaButtonsM_" + rec_i).show() - .attr('alt', talt) - .attr('Title', talt) - .unbind('click').bind('click', function () { - var indice = $(this).attr('id').split('_').pop(); - _edit_diabutton(indice, 'del', value, vocabularyId); - }); - } - else { - $("#idEditDiaButtonsM_" + rec_i).hide(); - $("#idEditDiaButtonsP_" + rec_i).show(); - var talt = $.sprintf(language.editAddSimple, value); - $("#idEditDiaButtonsP_" + rec_i).show().attr('alt', talt) - .attr('Title', talt) - .unbind('click').bind('click', function () { - var indice = $(this).attr('id').split('_').pop(); - _edit_diabutton(indice, 'add', value, vocabularyId); - }); - } - } - $(".editDiaButtons", p4.edit.editBox).show(); - } - - textZone.trigger('focus'); - return(true); - } - - // --------------------------------------------------------------------------- -// on a clique sur le bouton 'supprimer' un mot dans le multi-val -// --------------------------------------------------------------------------- - function _edit_delmval(value, VocabularyId) { - var meta_struct_id = p4.edit.curField; // le champ en cours d'editing - - for (var r = 0; r < p4.edit.T_records.length; r++) { - if (!p4.edit.T_records[r]._selected) - continue; - - p4.edit.T_records[r].fields[meta_struct_id].removeValue(value, VocabularyId); - } - - _updateEditSelectedRecords(null); - } - - // --------------------------------------------------------------------------- -// on a clique sur le bouton 'ajouter' un mot dans le multi-val -// --------------------------------------------------------------------------- - function edit_addmval(value, VocabularyId) { - var meta_struct_id = p4.edit.curField; // le champ en cours d'editing - - // on ajoute le mot dans tous les records selectionnes - for (var r = 0; r < p4.edit.T_records.length; r++) { - if (!p4.edit.T_records[r]._selected) - continue; - - p4.edit.T_records[r].fields[meta_struct_id].addValue(value, false, VocabularyId); - } - - _updateEditSelectedRecords(null); - } - - // --------------------------------------------------------------------------- - // on a clique sur une des multi-valeurs dans la liste - // --------------------------------------------------------------------------- - function edit_clkmval(mvaldiv, ival) { - $(mvaldiv).parent().find('.hilighted').removeClass('hilighted'); - $(mvaldiv).addClass('hilighted'); - _reveal_mval(p4.edit.T_mval[ival].getValue(), p4.edit.T_mval[ival].getVocabularyId()); - } - - function _edit_diabutton(record_indice, act, value, vocabularyId) { - var meta_struct_id = p4.edit.curField; // le champ en cours d'editing - if (act == 'del') { - p4.edit.T_records[record_indice].fields[meta_struct_id].removeValue(value, vocabularyId); - } - - if (act == 'add') { - p4.edit.T_records[record_indice].fields[meta_struct_id].addValue(value, false, vocabularyId); - } - _updateCurrentMval(meta_struct_id, value, vocabularyId); - _reveal_mval(value, vocabularyId); - - } - - // --------------------------------------------------------------------------- -// change de champ (avec les fleches autour du nom champ) -// --------------------------------------------------------------------------- - function edit_chgFld(evt, dir) { - var current_field = $('#divS .edit_field.active'); - if (current_field.length == 0) { - current_field = $('#divS .edit_field:first'); - current_field.trigger('click'); - } - else { - if (dir >= 0) { - current_field.next().trigger('click'); - } - else { - current_field.prev().trigger('click'); - } - } - } - - // --------------------------------------------------------------------------- -// on a clique sur un champ -// --------------------------------------------------------------------------- - function edit_mdwn_fld(evt, meta_struct_id, fieldname) { - if (!p4.edit.textareaIsDirty || edit_validField(evt, "ask_ok") == true) - _editField(evt, meta_struct_id); - } - - // --------------------------------------------------------------------------- -// on a clique sur le peudo champ 'status' -// --------------------------------------------------------------------------- - function edit_mdwn_status(evt) { - if (!p4.edit.textareaIsDirty || edit_validField(evt, "ask_ok") == true) - _editStatus(evt); - evt.cancelBubble = true; - if (evt.stopPropagation) - evt.stopPropagation(); - return(false); - } - - - - function edit_kdwn(evt, src) { - cancelKey = false; - - switch (evt.keyCode) { - case 13: - case 10: - if (p4.edit.T_fields[p4.edit.curField].type == "date") - cancelKey = true; - } - - if (cancelKey) { - evt.cancelBubble = true; - if (evt.stopPropagation) - evt.stopPropagation(); - return(false); - } - return(true); - } - - // ---------------------------------------------------------------------------------------------- -// des events sur le textarea pour tracker la selection (chercher dans le thesaurus...) -// ---------------------------------------------------------------------------------------------- - function edit_mdwn_ta(evt) { - evt.cancelBubble = true; - return(true); - } - - // mouse up textarea - function edit_mup_ta(evt, obj) { - - if (p4.edit.T_fields[p4.edit.curField].tbranch) { - if (obj.value != "") - ETHSeeker.search(obj.value); - } - return(true); - } - - // key up textarea - function edit_kup_ta(evt, obj) { - - var cancelKey = false; - var o; - switch (evt.keyCode) { - case 27: // esc : on restore la valeur avant editing - // $("#btn_cancel", p4.edit.editBox).parent().css("backgroundColor", "#000000"); - edit_validField(evt, "cancel"); - // self.setTimeout("document.getElementById('btn_cancel').parentNode.style.backgroundColor = '';", 100); - cancelKey = true; - break; - } - - if (cancelKey) { - evt.cancelBubble = true; - if (evt.stopPropagation) - evt.stopPropagation(); - return(false); - } - if (!p4.edit.textareaIsDirty && ($("#idEditZTextArea", p4.edit.editBox).val() != p4.edit.fieldLastValue)) { - p4.edit.textareaIsDirty = true; - } - - var s = obj.value; - if (p4.edit.T_fields[p4.edit.curField].tbranch) { - if (s != "") - ETHSeeker.search(s); - } - return(true); - } - - - return { - initialize: initialize, - startThisEditing: startThisEditing, - setRegDefault: setRegDefault, - skipImage: skipImage, - changeReplaceMode: changeReplaceMode, - edit_clkstatus: edit_clkstatus, - edit_validField: edit_validField, - edit_clk_editimg: edit_clk_editimg, - edit_clkmval: edit_clkmval, - edit_addmval: edit_addmval, - edit_chgFld: edit_chgFld, - edit_mdwn_fld: edit_mdwn_fld, - edit_mdwn_status: edit_mdwn_status, - edit_kdwn: edit_kdwn, - edit_mdwn_ta: edit_mdwn_ta, - edit_mup_ta: edit_mup_ta, - edit_kup_ta: edit_kup_ta, - edit_applyMultiDesc: edit_applyMultiDesc, - edit_cancelMultiDesc: edit_cancelMultiDesc, - edit_clickThesaurus: edit_clickThesaurus, - edit_dblclickThesaurus: edit_dblclickThesaurus, - edit_thesaurus_ow: edit_thesaurus_ow - }; -}(p4)); - -/* NOT USED function replace() { - var field = $("#EditSRField", p4.edit.editBox).val(); - var search = $("#EditSearch", p4.edit.editBox).val(); - var replace = $("#EditReplace", p4.edit.editBox).val(); - - var where = $("[name=EditSR_Where]:checked", p4.edit.editBox).val(); - var commut = ""; - var rgxp = $("#EditSROptionRX", p4.edit.editBox).prop('checked') ? true : false; - - var r_search; - if (rgxp) { - r_search = search; - commut = ($("#EditSR_RXG", p4.edit.editBox).prop('checked') ? "g" : "") - + ($("#EditSR_RXI", p4.edit.editBox).prop('checked') ? "i" : ""); - } - else { - commut = $("#EditSR_case", p4.edit.editBox).prop('checked') ? "g" : "gi"; - r_search = ""; - for (i = 0; i < search.length; i++) { - var c = search.charAt(i); - if (("^$[]()|.*+?\\").indexOf(c) != -1) - r_search += "\\"; - r_search += c; - } - if (where == "exact") - r_search = "^" + r_search + "$"; - } - - search = new RegExp(r_search, commut); - - var r, f, n = 0; - for (r in p4.edit.T_records) { - if (!p4.edit.T_records[r]._selected) - continue; - for (f in p4.edit.T_records[r].fields) { - if (field == '' || field == f) { - n += p4.edit.T_records[r].fields[f].replaceValue(search, replace); - } - } - } - - humane.info($.sprintf(language.nFieldsChanged, n)); - - recordEditorModule.updateEditSelectedRecords(null); -}*/ diff --git a/resources/www/prod/js/components/preview/preview.js b/resources/www/prod/js/components/preview/preview.js deleted file mode 100644 index 806e46a93a..0000000000 --- a/resources/www/prod/js/components/preview/preview.js +++ /dev/null @@ -1,464 +0,0 @@ -// var p4 = p4 || {}; - -var recordPreviewModule = (function (p4) { - var prevAjax, prevAjaxrunning; - prevAjaxrunning = false; - p4.slideShow = false; - - $(document).ready(function () { - $('#PREVIEWIMGDESC').tabs(); - - $('#PREVIEWBOX .gui_vsplitter', p4.edit.editBox).draggable({ - axis: 'x', - containment: 'parent', - drag: function (event, ui) { - var x = $(ui.position.left)[0]; - if (x < 330 || x > (bodySize.x - 400)) { - return false; - } - var v = $(ui.position.left)[0]; - $("#PREVIEWLEFT").width(v); - $("#PREVIEWRIGHT").css("left", $(ui.position.left)[0]); - recordPreviewModule.resizePreview(); - } - }); - }); - - /** - * - * @param env - * @param pos - relative position in current page - * @param contId - * @param reload - */ - function openPreview(env, pos, contId, reload) { - - if (contId == undefined) - contId = ''; - var roll = 0; - var justOpen = false; - - if (!p4.preview.open) { - commonModule.showOverlay(); - - $('#PREVIEWIMGCONT').disableSelection(); - - justOpen = true; - - if (!( navigator.userAgent.match(/msie/i))) { - $('#PREVIEWBOX').css({ - 'display': 'block', - 'opacity': 0 - }).fadeTo(500, 1); - } else { - $('#PREVIEWBOX').css({ - 'display': 'block', - 'opacity': 1 - }); - } - p4.preview.open = true; - p4.preview.nCurrent = 5; - $('#PREVIEWCURRENT, #PREVIEWOTHERSINNER, #SPANTITLE').empty(); - resizePreview(); - if (env == 'BASK') - roll = 1; - - } - - if (reload === true) - roll = 1; - - - $('#tooltip').css({ - 'display': 'none' - }); - - $('#PREVIEWIMGCONT').empty(); - - var options_serial = p4.tot_options; - var query = p4.tot_query; - var navigation = p4.navigation; - - // keep relative position for answer train: - var relativePos = pos; - // update real absolute position with pagination: - var absolutePos = parseInt(navigation.perPage,10) * (parseInt(navigation.page, 10) - 1) + parseInt(pos,10); - - // if comes from story, work with relative positionning - if (env == 'REG') { - // @TODO - if event comes from workzone (basket|story), - // we can use the relative position in order to display the doubleclicked records - // except we can't know the original event in this implementation - absolutePos = 0; - } - - prevAjax = $.ajax({ - type: "POST", - url: "../prod/records/", - dataType: 'json', - data: { - env: env, - pos: absolutePos, - cont: contId, - roll: roll, - options_serial: options_serial, - query: query - }, - beforeSend: function () { - if (prevAjaxrunning) - prevAjax.abort(); - if (env == 'RESULT') - $('#current_result_n').empty().append(parseInt(pos) + 1); - prevAjaxrunning = true; - $('#PREVIEWIMGDESC, #PREVIEWOTHERS').addClass('loading'); - }, - error: function (data) { - prevAjaxrunning = false; - $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); - posAsk = null; - }, - timeout: function () { - prevAjaxrunning = false; - $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); - posAsk = null; - }, - success: function (data) { - _cancelPreview(); - prevAjaxrunning = false; - posAsk = null; - - if (data.error) { - $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); - alert(data.error); - if (justOpen) - closePreview(); - return; - } - posAsk = data.pos - 1; - - $('#PREVIEWIMGCONT').empty().append(data.html_preview); - $('#PREVIEWIMGCONT .thumb_wrapper') - .width('100%').height('100%').image_enhance({zoomable: true}); - - $('#PREVIEWIMGDESCINNER').empty().append(data.desc); - $('#HISTORICOPS').empty().append(data.history); - $('#popularity').empty().append(data.popularity); - - if ($('#popularity .bitly_link').length > 0) { - - BitlyCB.statsResponse = function (data) { - var result = data.results; - if ($('#popularity .bitly_link_' + result.userHash).length > 0) { - $('#popularity .bitly_link_' + result.userHash).append(' (' + result.clicks + ' clicks)'); - } - }; - BitlyClient.stats($('#popularity .bitly_link').html(), 'BitlyCB.statsResponse'); - } - - p4.preview.current = {}; - p4.preview.current.width = parseInt($('#PREVIEWIMGCONT input[name=width]').val()); - p4.preview.current.height = parseInt($('#PREVIEWIMGCONT input[name=height]').val()); - p4.preview.current.tot = data.tot; - p4.preview.current.pos = relativePos; - - if ($('#PREVIEWBOX img.record.zoomable').length > 0) { - $('#PREVIEWBOX img.record.zoomable').draggable(); - } - - $('#SPANTITLE').empty().append(data.title); - $("#PREVIEWTITLE_COLLLOGO").empty().append(data.collection_logo); - $("#PREVIEWTITLE_COLLNAME").empty().append(data.collection_name); - - _setPreview(); - - if (env != 'RESULT') { - if (justOpen || reload) { - _setCurrent(data.current); - } - _viewCurrent($('#PREVIEWCURRENT li.selected')); - } - else { - if (!justOpen) { - $('#PREVIEWCURRENT li.selected').removeClass('selected'); - $('#PREVIEWCURRENTCONT li.current' + absolutePos).addClass('selected'); - } - if (justOpen || ($('#PREVIEWCURRENTCONT li.current' + absolutePos).length === 0) || ($('#PREVIEWCURRENTCONT li:last')[0] == $('#PREVIEWCURRENTCONT li.selected')[0]) || ($('#PREVIEWCURRENTCONT li:first')[0] == $('#PREVIEWCURRENTCONT li.selected')[0])) { - _getAnswerTrain(pos, data.tools, query, options_serial); - } - - _viewCurrent($('#PREVIEWCURRENT li.selected')); - } - if (env == 'REG' && $('#PREVIEWCURRENT').html() === '') { - _getRegTrain(contId, pos, data.tools); - } - _setOthers(data.others); - _setTools(data.tools); - $('#tooltip').css({ - 'display': 'none' - }); - $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); - if (!justOpen || (p4.preview.mode != env)) - resizePreview(); - - p4.preview.mode = env; - $('#EDIT_query').focus(); - - $('#PREVIEWOTHERSINNER .otherBaskToolTip').tooltip(); - - return; - } - - }); - - } - - function closePreview() { - p4.preview.open = false; - commonModule.hideOverlay(); - - $('#PREVIEWBOX').fadeTo(500, 0); - $('#PREVIEWBOX').queue(function () { - $(this).css({ - 'display': 'none' - }); - _cancelPreview(); - $(this).dequeue(); - }); - - } - - function startSlide() { - if (!p4.slideShow) { - p4.slideShow = true; - } - if (p4.slideShowCancel) { - p4.slideShowCancel = false; - p4.slideShow = false; - $('#start_slide').show(); - $('#stop_slide').hide(); - } - if (!p4.preview.open) { - p4.slideShowCancel = false; - p4.slideShow = false; - $('#start_slide').show(); - $('#stop_slide').hide(); - } - if (p4.slideShow) { - $('#start_slide').hide(); - $('#stop_slide').show(); - getNext(); - setTimeout("startSlide()", 3000); - } - } - - function stopSlide() { - p4.slideShowCancel = true; - $('#start_slide').show(); - $('#stop_slide').hide(); - } - - function getNext() { - if (p4.preview.mode == 'REG' && parseInt(p4.preview.current.pos) === 0) - $('#PREVIEWCURRENTCONT li img:first').trigger("click"); - else { - if (p4.preview.mode == 'RESULT') { - posAsk = parseInt(p4.preview.current.pos) + 1; - posAsk = (posAsk >= parseInt(p4.tot) || isNaN(posAsk)) ? 0 : posAsk; - recordPreviewModule.openPreview('RESULT', posAsk, '', false); - } - else { - if (!$('#PREVIEWCURRENT li.selected').is(':last-child')) - $('#PREVIEWCURRENT li.selected').next().children('img').trigger("click"); - else - $('#PREVIEWCURRENT li:first-child').children('img').trigger("click"); - } - - } - } - - function getPrevious() { - if (p4.preview.mode == 'RESULT') { - posAsk = parseInt(p4.preview.current.pos) - 1; - posAsk = (posAsk < 0) ? ((parseInt(p4.tot) - 1)) : posAsk; - recordPreviewModule.openPreview('RESULT', posAsk, '', false); - } - else { - if (!$('#PREVIEWCURRENT li.selected').is(':first-child')) - $('#PREVIEWCURRENT li.selected').prev().children('img').trigger("click"); - else - $('#PREVIEWCURRENT li:last-child').children('img').trigger("click"); - } - } - - function _setPreview() { - if (!p4.preview.current) - return; - - var zoomable = $('img.record.zoomable'); - if (zoomable.length > 0 && zoomable.hasClass('zoomed')) - return; - - var h = parseInt(p4.preview.current.height); - var w = parseInt(p4.preview.current.width); - var t = 20; - var de = 0; - - var margX = 0; - var margY = 0; - - if ($('#PREVIEWIMGCONT .record_audio').length > 0) { - margY = 100; - de = 60; - } - - var ratioP = w / h; - var ratioD = parseInt(p4.preview.width) / parseInt(p4.preview.height); - - if (ratioD > ratioP) { - //je regle la hauteur d'abord - if ((parseInt(h) + margY) > parseInt(p4.preview.height)) { - h = Math.round(parseInt(p4.preview.height) - margY); - w = Math.round(h * ratioP); - } - } - else { - if ((parseInt(w) + margX) > parseInt(p4.preview.width)) { - w = Math.round(parseInt(p4.preview.width) - margX); - h = Math.round(w / ratioP); - } - } - - t = Math.round((parseInt(p4.preview.height) - h - de) / 2); - var l = Math.round((parseInt(p4.preview.width) - w) / 2); - $('#PREVIEWIMGCONT .record').css({ - width: w, - height: h, - top: t, - left: l - }).attr('width', w).attr('height', h); - } - - function _setCurrent(current) { - if (current !== '') { - var el = $('#PREVIEWCURRENT'); - el.removeClass('loading').empty().append(current); - - $('ul', el).width($('li', el).length * 80); - $('img.prevRegToolTip', el).tooltip(); - $.each($('img.openPreview'), function (i, el) { - var jsopt = $(el).attr('jsargs').split('|'); - $(el).removeAttr('jsargs'); - $(el).removeClass('openPreview'); - $(el).bind('click', function () { - _viewCurrent($(this).parent()); - // convert abssolute to relative position - var absolutePos = jsopt[1]; - var relativePos = parseInt(absolutePos, 10) - parseInt(p4.navigation.perPage, 10) * (parseInt(p4.navigation.page, 10) - 1); - // keep relative position for answer train: - recordPreviewModule.openPreview(jsopt[0], relativePos, jsopt[2],false); - }); - }); - } - } - - function _viewCurrent(el) { - if (el.length === 0) { - return; - } - $('#PREVIEWCURRENT li.selected').removeClass('selected'); - el.addClass('selected'); - $('#PREVIEWCURRENTCONT').animate({'scrollLeft': ($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width() / 2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))}); - return; - } - - function reloadPreview() { - $('#PREVIEWCURRENT li.selected img').trigger("click"); - } - - function _getAnswerTrain(pos, tools, query, options_serial) { - // keep relative position for answer train: - var relativePos = pos; - // update real absolute position with pagination: - var absolutePos = parseInt(p4.navigation.perPage,10) * (parseInt(p4.navigation.page, 10) - 1) + parseInt(pos,10); - - $('#PREVIEWCURRENTCONT').fadeOut('fast'); - $.ajax({ - type: "POST", - url: "/prod/query/answer-train/", - dataType: 'json', - data: { - pos: absolutePos, - options_serial: options_serial, - query: query - }, - success: function (data) { - _setCurrent(data.current); - _viewCurrent($('#PREVIEWCURRENT li.selected')); - _setTools(tools); - return; - } - }); - } - - function _getRegTrain(contId, pos, tools) { - $.ajax({ - type: "POST", - url: "/prod/query/reg-train/", - dataType: 'json', - data: { - cont: contId, - pos: pos - }, - success: function (data) { - _setCurrent(data.current); - _viewCurrent($('#PREVIEWCURRENT li.selected')); - if (typeof(tools) != 'undefined') - _setTools(tools); - return; - } - }); - } - - function _cancelPreview() { - $('#PREVIEWIMGDESCINNER').empty(); - $('#PREVIEWIMGCONT').empty(); - p4.preview.current = false; - } - - function _setOthers(others) { - - $('#PREVIEWOTHERSINNER').empty(); - if (others !== '') { - $('#PREVIEWOTHERSINNER').append(others); - - $('#PREVIEWOTHERS table.otherRegToolTip').tooltip(); - } - } - - function _setTools(tools) { - $('#PREVIEWTOOL').empty().append(tools); - if (!p4.slideShowCancel && p4.slideShow) { - $('#start_slide').hide(); - $('#stop_slide').show(); - } else { - $('#start_slide').show(); - $('#stop_slide').hide(); - } - } - - function resizePreview() { - p4.preview.height = $('#PREVIEWIMGCONT').height(); - p4.preview.width = $('#PREVIEWIMGCONT').width(); - _setPreview(); - } - return { - openPreview: openPreview, - closePreview: closePreview, - startSlide: startSlide, - stopSlide: stopSlide, - getNext: getNext, - getPrevious: getPrevious, - reloadPreview: reloadPreview, - resizePreview: resizePreview - } -})(p4); diff --git a/resources/www/prod/js/components/push/push.js b/resources/www/prod/js/components/push/push.js deleted file mode 100644 index 16c586f355..0000000000 --- a/resources/www/prod/js/components/push/push.js +++ /dev/null @@ -1,708 +0,0 @@ - -var pushModule = (function (window, p4) { - - var Feedback = function ($container, context) { - this.container = $($container); - - this.Context = context; - - this.selection = new Selectable( - $('.user_content .badges', this.container), - { - selector: '.badge' - } - ); - - var $this = this; - - this.container.on('click', '.content .options .select-all', function (event) { - $this.selection.selectAll(); - }); - - this.container.on('click', '.content .options .unselect-all', function (event) { - $this.selection.empty(); - }); - - $('.UserTips', this.container).tooltip(); - - this.container.on('click', 'a.user_adder', function (event) { - var $this = $(this); - - $.ajax({ - type: "GET", - url: $this.attr('href'), - dataType: 'html', - beforeSend: function () { - var options = { - size: 'Medium', - title: $this.html() - }; - dialogModule.dialog.create(options, 2).getDomElement().addClass('loading'); - }, - success: function (data) { - dialogModule.dialog.get(2).getDomElement().removeClass('loading').empty().append(data); - return; - }, - error: function () { - dialogModule.dialog.get(2).close(); - return; - }, - timeout: function () { - dialogModule.dialog.get(2).close(); - return; - } - }); - - return false; - }); - - this.container.on('click', '.recommended_users', function (event) { - var usr_id = $('input[name="usr_id"]', $(this)).val(); - - $this.loadUser(usr_id, $this.selectUser); - - return false; - }); - - this.container.on('click', '.recommended_users_list', function (event) { - - var content = $('#push_user_recommendations').html(); - - var options = { - size: 'Small', - title: $(this).attr('title') - }; - - $dialog = dialogModule.dialog.create(options, 2); - $dialog.setContent(content); - - $dialog.getDomElement().find('a.adder').bind('click', function () { - - $(this).addClass('added'); - - var usr_id = $(this).closest('tr').find('input[name="usr_id"]').val(); - - $this.loadUser(usr_id, $this.selectUser); - - return false; - }); - - $dialog.getDomElement().find('a.adder').each(function (i, el) { - - var usr_id = $(this).closest('tr').find('input[name="usr_id"]').val(); - - if ($('.badge_' + usr_id, $this.container).length > 0) { - $(this).addClass('added'); - } - - }); - - - return false; - }); - - //this.container.on('submit', '#PushBox form[name="FeedBackForm"]', function (event) { - $('#PushBox form[name="FeedBackForm"]').bind('submit', function () { - - var $this = $(this); - - $.ajax({ - type: $this.attr('method'), - url: $this.attr('action'), - dataType: 'json', - data: $this.serializeArray(), - beforeSend: function () { - - }, - success: function (data) { - if (data.success) { - humane.info(data.message); - dialogModule.dialog.close(1); - p4.WorkZone.refresh(); - } - else { - humane.error(data.message); - } - return; - }, - error: function () { - - return; - }, - timeout: function () { - - return; - } - }); - - return false; - }); - - $('.FeedbackSend', this.container).bind('click', function () { - if ($('.badges .badge', $container).length === 0) { - alert(language.FeedBackNoUsersSelected); - return; - } - - var buttons = {}; - - buttons[language.send] = function () { - if ($.trim($('input[name="name"]', $dialog.getDomElement()).val()) === '') { - var options = { - size: 'Alert', - closeButton: true, - title: language.warning - } - var $dialogAlert = dialogModule.dialog.create(options, 3); - $dialogAlert.setContent(language.FeedBackNameMandatory); - - return false; - } - - $dialog.close(); - - $('input[name="name"]', $FeedBackForm).val($('input[name="name"]', $dialog.getDomElement()).val()); - $('input[name="duration"]', $FeedBackForm).val($('select[name="duration"]', $dialog.getDomElement()).val()); - $('textarea[name="message"]', $FeedBackForm).val($('textarea[name="message"]', $dialog.getDomElement()).val()); - $('input[name="recept"]', $FeedBackForm).prop('checked', $('input[name="recept"]', $dialog.getDomElement()).prop('checked')); - $('input[name="force_authentication"]', $FeedBackForm).prop('checked', $('input[name="force_authentication"]', $dialog.getDomElement()).prop('checked')); - - $FeedBackForm.trigger('submit'); - }; - - var options = { - size: 'Medium', - buttons: buttons, - loading: true, - title: language.send, - closeOnEscape: true, - cancelButton: true - }; - - var $dialog = dialogModule.dialog.create(options, 2); - - var $FeedBackForm = $('form[name="FeedBackForm"]', $container); - - var html = _.template($("#feedback_sendform_tpl").html()); - - $dialog.setContent(html); - - $('input[name="name"]', $dialog.getDomElement()).val($('input[name="name"]', $FeedBackForm).val()); - $('textarea[name="message"]', $dialog.getDomElement()).val($('textarea[name="message"]', $FeedBackForm).val()); - $('.' + $this.Context, $dialog.getDomElement()).show(); - - $('form', $dialog.getDomElement()).submit(function () { - return false; - }); - }); - - $('.user_content .badges', this.container).disableSelection(); - - - // toggle download feature for users - this.container.on('click', '.user_content .badges .badge .toggle', function (event) { - var $this = $(this); - - $this.toggleClass('status_off status_on'); - - $this.find('input').val($this.hasClass('status_on') ? '1' : '0'); - - return false; - }); - - // toggle feature state of selected users - this.container.on('click', '.general_togglers .general_toggler', function (event) { - var feature = $(this).attr('feature'); - - var $badges = $('.user_content .badge.selected', this.container); - - var toggles = $('.status_off.toggle_' + feature, $badges); - - if (toggles.length === 0) { - var toggles = $('.status_on.toggle_' + feature, $badges); - } - if (toggles.length === 0) { - humane.info('No user selected'); - } - - toggles.trigger('click'); - return false; - }); - - this.container.on('click', '.user_content .badges .badge .deleter', function (event) { - var $elem = $(this).closest('.badge'); - $elem.fadeOut(function () { - $elem.remove(); - }); - return false; - }); - - this.container.on('click', '.list_manager', function (event) { - $('#PushBox').hide(); - $('#ListManager').show(); - return false; - }); - - this.container.on('click', 'a.list_loader', function (event) { - var url = $(this).attr('href'); - - var callbackList = function (list) { - for (var i in list.entries) { - this.selectUser(list.entries[i].User); - } - }; - - $this.loadList(url, callbackList); - - return false; - }); - - $('form.list_saver', this.container).bind('submit', function () { - var $form = $(this); - var $input = $('input[name="name"]', $form); - - var users = p4.Feedback.getUsers(); - - if (users.length === 0) { - humane.error('No users'); - return false; - } - - p4.Lists.create($input.val(), function (list) { - $input.val(''); - list.addUsers(users); - }); - - return false; - }); - - $('input[name="users-search"]', this.container).autocomplete({ - minLength: 2, - source: function (request, response) { - $.ajax({ - url: '/prod/push/search-user/', - dataType: "json", - data: { - query: request.term - }, - success: function (data) { - response(data); - } - }); - }, - focus: function (event, ui) { - $('input[name="users-search"]').val(ui.item.label); - }, - select: function (event, ui) { - if (ui.item.type === 'USER') { - $this.selectUser(ui.item); - } else if (ui.item.type === 'LIST') { - for (var e in ui.item.entries) { - $this.selectUser(ui.item.entries[e].User); - } - } - return false; - } - }) - .data("ui-autocomplete")._renderItem = function (ul, item) { - var html = ""; - - if (item.type === 'USER') { - html = _.template($("#list_user_tpl").html(), { - - item: item - }); - } else if (item.type === 'LIST') { - html = _.template($("#list_list_tpl").html(), { - item: item - }); - } - - return $(html).data("ui-autocomplete-item", item).appendTo(ul); - }; - - return this; - }; - - Feedback.prototype = { - selectUser: function (user) { - if (typeof user !== 'object') { - if (window.console) { - console.log('trying to select a user with wrong datas'); - } - } - if ($('.badge_' + user.usr_id, this.container).length > 0) { - humane.info('User already selected'); - return; - } - - var html = _.template($("#" + this.Context.toLowerCase() + "_badge_tpl").html(), { - user: user - }); - - p4.Feedback.appendBadge(html); - }, - loadUser: function (usr_id, callback) { - var $this = this; - - $.ajax({ - type: 'GET', - url: '/prod/push/user/' + usr_id + '/', - dataType: 'json', - data: { - usr_id: usr_id - }, - success: function (data) { - if (typeof callback === 'function') { - callback.call($this, data); - } - } - }); - }, - loadList: function (url, callback) { - var $this = this; - - $.ajax({ - type: 'GET', - url: url, - dataType: 'json', - success: function (data) { - if (typeof callback === 'function') { - callback.call($this, data); - } - } - }); - }, - appendBadge: function (badge) { - $('.user_content .badges', this.container).append(badge); - }, - addUser: function ($form, callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/push/add-user/', - dataType: 'json', - data: $form.serializeArray(), - success: function (data) { - if (data.success) { - humane.info(data.message); - $this.selectUser(data.user); - callback(); - } - else { - humane.error(data.message); - } - } - }); - }, - getSelection: function () { - return this.selection; - }, - getUsers: function () { - return $('.user_content .badge', this.container).map(function () { - return $('input[name="id"]', $(this)).val(); - }); - } - }; - - - var ListManager = function ($container) { - - this.list = null; - this.container = $container; - - $container.on('click', '.back_link', function() { - $('#PushBox').show(); - $('#ListManager').hide(); - return false; - }); - - $container.on('click', 'a.list_sharer', function() { - - var $this = $(this), - options = { - size: 'Small', - closeButton: true, - title: $this.attr('title') - }, - $dialog = dialogModule.dialog.create(options, 2); - - $dialog.load($this.attr('href'), 'GET'); - - return false; - }); - - $container.on('click', 'a.user_adder', function() { - - var $this = $(this); - - $.ajax({ - type: "GET", - url: $this.attr('href'), - dataType: 'html', - beforeSend: function () { - var options = { - size: 'Medium', - title: $this.html() - }; - dialogModule.dialog.create(options, 2).getDomElement().addClass('loading'); - }, - success: function (data) { - dialogModule.dialog.get(2).getDomElement().removeClass('loading').empty().append(data); - return; - }, - error: function () { - dialogModule.dialog.get(2).close(); - return; - }, - timeout: function () { - dialogModule.dialog.get(2).close(); - return; - } - }); - - return false; - }); - - - var initLeft = function () { - $('a.list_refresh', $container).bind('click', function (event) { - - var callback = function (datas) { - $('.all-lists', $container).removeClass('loading').append(datas); - initLeft(); - }; - - $('.all-lists', $container).empty().addClass('loading'); - - p4.Lists.get(callback, 'html'); - - return false; - }); - - $('a.list_adder', $container).bind('click', function (event) { - - var makeDialog = function (box) { - - var buttons = {}; - - buttons[language.valider] = function () { - - var callbackOK = function () { - $('a.list_refresh', $container).trigger('click'); - dialogModule.dialog.get(2).close(); - }; - - var name = $('input[name="name"]', dialogModule.dialog.get(2).getDomElement()).val(); - - if ($.trim(name) === '') { - alert(language.listNameCannotBeEmpty); - return; - } - - p4.Lists.create(name, callbackOK); - }; - - var options = { - cancelButton: true, - buttons: buttons, - size: '700x170' - }; - - dialogModule.dialog.create(options, 2).setContent(box); - }; - - var html = _.template($("#list_editor_dialog_add_tpl").html()); - - makeDialog(html); - - return false; - }); - - $('li.list a.list_link', $container).bind('click', function (event) { - - var $this = $(this); - - $this.closest('.lists').find('.list.selected').removeClass('selected'); - $this.parent('li.list').addClass('selected'); - - $.ajax({ - type: 'GET', - url: $this.attr('href'), - dataType: 'html', - success: function (data) { - $('.editor', $container).removeClass('loading').append(data); - initRight(); - }, - beforeSend: function () { - $('.editor', $container).empty().addClass('loading'); - } - }); - - return false; - }); - }; - - var initRight = function () { - - var $container = $('#ListManager .editor'); - - $('form[name="list-editor-search"]', $container).bind('submit', function () { - - var $this = $(this); - var dest = $('.list-editor-results', $container); - - $.ajax({ - url: $this.attr('action'), - type: $this.attr('method'), - dataType: "html", - data: $this.serializeArray(), - beforeSend: function () { - dest.empty().addClass('loading'); - }, - success: function (datas) { - - dest.empty().removeClass('loading').append(datas); - } - }); - return false; - }); - - $('form[name="list-editor-search"] select, form[name="list-editor-search"] input[name="ListUser"]', $container).bind('change', function () { - $(this).closest('form').trigger('submit'); - }); - - $('.EditToggle', $container).bind('click', function () { - $('.content.readonly, .content.readwrite', $('#ListManager')).toggle(); - return false; - }); - $('.Refresher', $container).bind('click', function () { - $('#ListManager ul.lists .list.selected a').trigger('click'); - return false; - }); - - $('form[name="SaveName"]', $container).bind('submit', function () { - var $this = $(this); - - $.ajax({ - type: $this.attr('method'), - url: $this.attr('action'), - dataType: 'json', - data: $this.serializeArray(), - beforeSend: function () { - - }, - success: function (data) { - if (data.success) { - humane.info(data.message); - $('#ListManager .lists .list_refresh').trigger('click'); - } - else { - humane.error(data.message); - } - return; - }, - error: function () { - - return; - }, - timeout: function () { - - return; - } - }); - - return false; - }); - - - $('button.deleter', $container).bind('click', function (event) { - - var list_id = $(this).data("list-id"); - - var makeDialog = function (box) { - - var buttons = {}; - - buttons[language.valider] = function () { - - var callbackOK = function () { - $('#ListManager .all-lists a.list_refresh').trigger('click'); - dialogModule.dialog.get(2).close(); - }; - - var List = new document.List(list_id); - List.remove(callbackOK); - }; - - var options = { - cancelButton: true, - buttons: buttons, - size: 'Alert' - }; - - dialogModule.dialog.create(options, 2).setContent(box); - }; - - var html = _.template($("#list_editor_dialog_delete_tpl").html()); - - makeDialog(html); - - return false; - }); - }; - - initLeft(); - - $('.badges a.deleter', this.container).on('click', function () { - var badge = $(this).closest('.badge'); - - var usr_id = badge.find('input[name="id"]').val(); - - - var callback = function (list, datas) { - $('.counter.current, .list.selected .counter', $('#ListManager')).each(function () { - $(this).text(parseInt($(this).text()) - 1); - }); - - badge.remove(); - }; - - p4.ListManager.getList().removeUser(usr_id, callback); - - return false; - }); - - }; - - ListManager.prototype = { - workOn: function (list_id) { - this.list = new document.List(list_id); - }, - getList: function () { - return this.list; - }, - appendBadge: function (datas) { - $('#ListManager .badges').append(datas); - } - }; - - - function reloadBridge(url) { - var options = $('#dialog_publicator form[name="current_datas"]').serializeArray(); - var dialog = dialogModule.dialog.get(1); - dialog.load(url, 'POST', options); - } - - - - // instance wil be stored in p4.Feedback - return { - Feedback: Feedback, - ListManager: ListManager, - reloadBridge: reloadBridge - } - -}(window, p4)); diff --git a/resources/www/prod/js/core/lists.js b/resources/www/prod/js/core/lists.js deleted file mode 100644 index c3c5886990..0000000000 --- a/resources/www/prod/js/core/lists.js +++ /dev/null @@ -1,253 +0,0 @@ -var p4 = p4 || {}; - -(function (window, p4, $) { - - var Lists = function () { - - }; - - var List = function (id) { - - if (parseInt(id) <= 0) { - throw 'Invalid list id'; - } - - this.id = id; - }; - - Lists.prototype = { - create: function (name, callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/', - dataType: 'json', - data: {name: name}, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - var list = new List(data.list_id); - callback(list); - } - } - else { - humane.error(data.message); - } - } - }); - - }, - get: function (callback, type) { - - var $this = this; - type = typeof type === 'undefined' ? 'json' : type; - - $.ajax({ - type: 'GET', - url: '/prod/lists/all/', - dataType: type, - data: {}, - success: function (data) { - if (type == 'json') { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback(data.result); - } - } - else { - humane.error(data.message); - } - } - else { - if (typeof callback === 'function') { - callback(data); - } - } - } - }); - } - - } - - List.prototype = { - addUsers: function (arrayUsers, callback) { - - if (!arrayUsers instanceof Array) { - throw 'addUsers takes array as argument'; - } - - var $this = this; - var data = {usr_ids: $(arrayUsers).toArray()}; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/' + $this.id + '/add/', - dataType: 'json', - data: data, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this, data); - } - } - else { - humane.error(data.message); - } - } - }); - }, - addUser: function (usr_id, callback) { - this.addUsers([usr_id], callback); - }, - remove: function (callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/' + this.id + '/delete/', - dataType: 'json', - data: {}, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this); - } - } - else { - humane.error(data.message); - } - } - }); - }, - update: function (name, callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/' + this.id + '/update/', - dataType: 'json', - data: { name: name }, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this); - } - } - else { - humane.error(data.message); - } - } - }); - }, - removeUser: function (usr_id, callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/' + this.id + '/remove/' + usr_id + '/', - dataType: 'json', - data: {}, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this, data); - } - } - else { - humane.error(data.message); - } - } - }); - }, - shareWith: function (usr_id, role, callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/' + this.id + '/share/' + usr_id + '/', - dataType: 'json', - data: {role: role}, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this); - } - } - else { - humane.error(data.message); - } - } - }); - }, - unshareWith: function (callback) { - - var $this = this; - - $.ajax({ - type: 'POST', - url: '/prod/lists/list/' + this.id + '/unshare/' + usr_id + '/', - dataType: 'json', - data: {}, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this); - } - } - else { - humane.error(data.message); - } - } - }); - }, - get: function (callback) { - - var $this = this; - - $.ajax({ - type: 'GET', - url: '/prod/lists/list/' + this.id + '/', - dataType: 'json', - data: {}, - success: function (data) { - if (data.success) { - humane.info(data.message); - - if (typeof callback === 'function') { - callback($this, data); - } - } - else { - humane.error(data.message); - } - } - }); - } - } - - p4.Lists = new Lists(); - document.List = List; - -})(document, p4, jQuery); diff --git a/resources/www/prod/js/prod.js b/resources/www/prod/js/prod.js index 38c2b214b0..23f1457af9 100644 --- a/resources/www/prod/js/prod.js +++ b/resources/www/prod/js/prod.js @@ -23,72 +23,6 @@ var prodModule = (function (p4, humane) { }; p4.active_zone = false; - /*function _resizeAll() { - var body = $('body'); - bodySize.y = body.height(); - bodySize.x = body.width(); - - var headBlockH = $('#headBlock').outerHeight(); - var bodyY = bodySize.y - headBlockH - 2; - var bodyW = bodySize.x - 2; - //$('#desktop').height(bodyY).width(bodyW); - - if (p4.preview.open) - recordPreviewModule.resizePreview(); - - if ($('#idFrameC').data('ui-resizable')) { - $('#idFrameC').resizable('option', 'maxWidth', (480)); - $('#idFrameC').resizable('option', 'minWidth', 300); - } - - answerSizer(); - linearizeUi(); - - - } - function answerSizer() { - var el = $('#idFrameC').outerWidth(); - if (!$.support.cssFloat) { - // $('#idFrameC .insidebloc').width(el - 56); - } - var widthA = Math.round(bodySize.x - el - 10); - $('#rightFrame').width(widthA); - $('#rightFrame').css('left', $('#idFrameC').width()); - - } - function linearizeUi() { - var list = $('#answers .list'); - if (list.length > 0) { - var fllWidth = $('#answers').innerWidth(); - fllWidth -= 16; - - var stdWidth = 460; - var diff = 28; - var n = Math.round(fllWidth / (stdWidth)); - var w = Math.floor(fllWidth / n) - diff; - if (w < 360 && n > 1) - w = Math.floor(fllWidth / (n - 1)) - diff; - $('#answers .list').width(w); - } - else { - - var minMargin = 5; - var margin = 0; - var el = $('#answers .diapo:first'); - var diapoWidth = el.outerWidth() + (minMargin * 2); - var fllWidth = $('#answers').innerWidth(); - fllWidth -= 26; - - var n = Math.floor(fllWidth / (diapoWidth)); - - margin = Math.floor((fllWidth % diapoWidth) / (2 * n)); - margin = margin + minMargin; - - $('#answers .diapo').css('margin', '5px ' + (margin) + 'px'); - } - - }*/ - function doSpecialSearch(qry, allbase) { if (allbase) { prodApp.appEvents.emit('search.doToggleDatabase', true); @@ -108,7 +42,7 @@ var prodModule = (function (p4, humane) { p4.WorkZone.removeElementFromBasket(el, confirm); } - function openRecordEditor(type, value) { + /*function openRecordEditor(type, value) { $('#idFrameE').empty().addClass('loading'); commonModule.showOverlay(2); @@ -154,171 +88,9 @@ var prodModule = (function (p4, humane) { }); return; - } - - function openShareModal(bas, rec) { - var dialog = dialogModule.dialog.create({ - title: language['share'] - }); - - dialog.load("../prod/share/record/" + bas + "/" + rec + "/", "GET"); - } - function openPrintModal(value) { - _onOpenPrintModal("lst=" + value); - } - - function _onOpenPrintModal(value) { - if ($("#DIALOG").data("ui-dialog")) { - $("#DIALOG").dialog('destroy'); - } - $('#DIALOG').attr('title', language.print) - .empty().addClass('loading') - .dialog({ - resizable: false, - closeOnEscape: true, - modal: true, - width: '800', - height: '500', - open: function (event, ui) { - $(this).dialog("widget").css("z-index", "1999"); - }, - close: function (event, ui) { - $(this).dialog("widget").css("z-index", "auto"); - } - }) - .dialog('open'); - - $.ajax({ - type: "POST", - url: '../prod/printer/?' + value, - dataType: 'html', - beforeSend: function () { - - }, - success: function (data) { - $('#DIALOG').removeClass('loading').empty() - .append(data); - return; - } - }); - } - - function openToolModal(datas, activeTab) { - - var dialog = dialogModule.dialog.create({ - size: 'Medium', - title: language.toolbox, - loading: true - }); - - $.get("../prod/tools/" - , datas - , function (data) { - dialog.setContent(data); - dialog.setOption('contextArgs', datas); - var tabs = $('.tabs', dialog.getDomElement()).tabs(); - - // activate tab if exists: - if( activeTab !== undefined ) { - tabs.tabs('option', 'active', activeTab); - } - return; - } - ); - } - - function openDownloadModal(value, key) { - if( key !== undefined ) { - value = key+'='+value - } - _onOpenDownloadModal(value); - } - // @TODO duplicate with external module - function _onOpenDownloadModal(datas) { - var dialog = dialogModule.dialog.create({title: language['export']}); - - $.post("../prod/export/multi-export/", datas, function (data) { - - dialog.setContent(data); - - $('.tabs', dialog.getDomElement()).tabs(); - - $('.close_button', dialog.getDomElement()).bind('click', function () { - dialog.close(); - }); - - return false; - }); - } + }*/ - function deleteConfirmation(type, el) { - el = $(el); - switch (type) { - - - case "IMGT": - case "CHIM": - - var lst = ''; - - if (type === 'IMGT') - lst = p4.Results.Selection.serialize(); - if (type === 'CHIM') - lst = p4.WorkZone.Selection.serialize(); - - _deleteRecords(lst); - - return; - break; - - - case "SSTT": - - var buttons = {}; - buttons[language.valider] = function (e) { - prodApp.appEvents.emit('baskets.doDeleteBasket', el); - }; - - $('#DIALOG').empty().append(language.confirmDel).attr('title', language.attention).dialog({ - autoOpen: false, - resizable: false, - modal: true, - draggable: false - }).dialog('open').dialog('option', 'buttons', buttons); - $('#tooltip').hide(); - return; - break; - case "STORY": - lst = el.val(); - _deleteRecords(lst); - break; - - } - } - function _deleteRecords(lst) { - if (lst.split(';').length === 0) { - alert(language.nodocselected); - return false; - } - - var $dialog = dialogModule.dialog.create({ - size: 'Small', - title: language.deleteRecords - }); - - $.ajax({ - type: "POST", - url: "../prod/records/delete/what/", - dataType: 'html', - data: {lst: lst}, - success: function (data) { - $dialog.setContent(data); - } - }); - - return false; - } function toggleTopic(id) { var o = $('#TOPIC_UL' + id); @@ -328,119 +100,7 @@ var prodModule = (function (p4, humane) { $('#TOPIC_TRI' + id + ' ,#TOPIC_UL' + id).removeClass('opened').addClass('closed'); } - - - function _triggerShortcuts() { - - $('#keyboard-stop').bind('click', function () { - var display = $(this).get(0).checked ? '0' : '1'; - - userModule.setPref('keyboard_infos', display); - - }); - - var buttons = {}; - - buttons[language.fermer] = function () { - $("#keyboard-dialog").dialog('close'); - }; - - $('#keyboard-dialog').dialog({ - closeOnEscape: false, - resizable: false, - draggable: false, - modal: true, - width: 600, - height: 400, - overlay: { - backgroundColor: '#000', - opacity: 0.7 - }, - open: function (event, ui) { - $(this).dialog("widget").css("z-index", "1400"); - }, - close: function () { - $(this).dialog("widget").css("z-index", "auto"); - if ($('#keyboard-stop').get(0).checked) { - var dialog = $('#keyboard-dialog'); - if (dialog.data("ui-dialog")) { - dialog.dialog('destroy'); - } - dialog.remove(); - } - } - }).dialog('option', 'buttons', buttons).dialog('open'); - - $('#keyboard-dialog').scrollTop(0); - - return false; - } - - - - function _answerSelector(el) { - if (el.hasClass('all_selector')) { - p4.Results.Selection.selectAll(); - } - else { - if (el.hasClass('none_selector')) { - p4.Results.Selection.empty(); - } - else { - if (el.hasClass('starred_selector')) { - - } - else { - if (el.hasClass('video_selector')) { - p4.Results.Selection.empty(); - p4.Results.Selection.select('.type-video'); - } - else { - if (el.hasClass('image_selector')) { - p4.Results.Selection.empty(); - p4.Results.Selection.select('.type-image'); - } - else { - if (el.hasClass('document_selector')) { - p4.Results.Selection.empty(); - p4.Results.Selection.select('.type-document'); - } - else { - if (el.hasClass('audio_selector')) { - p4.Results.Selection.empty(); - p4.Results.Selection.select('.type-audio'); - } - } - } - } - } - } - } - } - - /*function _saveWindows() { - var key = ''; - var value = ''; - - - if ($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible')) { - key = 'edit_window'; - value = $('#idFrameE').outerWidth() / $('#EDITWINDOW').innerWidth(); - } - else { - key = 'search_window'; - value = $('#idFrameC').outerWidth() / bodySize.x; - } - userModule.setPref(key, value); - } -*/ return { - openRecordEditor: openRecordEditor, - openPrintModal: openPrintModal, - openShareModal: openShareModal, - openToolModal: openToolModal, - openDownloadModal: openDownloadModal, - deleteConfirmation: deleteConfirmation, doSpecialSearch: doSpecialSearch, addToBasket: addToBasket, removeFromBasket: removeFromBasket, diff --git a/templates/web/prod/WorkZone/Macros.html.twig b/templates/web/prod/WorkZone/Macros.html.twig index bbe46a7502..4a0ddd487a 100644 --- a/templates/web/prod/WorkZone/Macros.html.twig +++ b/templates/web/prod/WorkZone/Macros.html.twig @@ -44,14 +44,14 @@
-
{{ 'action::exporter' | trans }} +
{{ 'action::exporter' | trans }}
{% if app.getAclForUser(app.getAuthenticatedUser()).has_right('modifyrecord') %}