diff --git a/resources/gulp/components/prod.js b/resources/gulp/components/prod.js
index cd5b7a0cec..2ddf297072 100644
--- a/resources/gulp/components/prod.js
+++ b/resources/gulp/components/prod.js
@@ -77,24 +77,26 @@ gulp.task('build-prod-js', function(){
config.paths.src + 'prod/js/core/selectable.js',
config.paths.src + 'prod/js/core/alert.js',
- config.paths.src + 'prod/js/components/search.js',
+ config.paths.src + 'prod/js/components/search/search.js',
+ config.paths.src + 'prod/js/components/search/search-result.js',
config.paths.src + 'prod/js/components/publication.js',
- config.paths.src + 'prod/js/components/workzone.js',
- config.paths.src + 'prod/js/components/workzone-basket.js',
- config.paths.src + 'prod/js/components/workzone-facets.js',
+ config.paths.src + 'prod/js/components/workzone/workzone.js',
+ config.paths.src + 'prod/js/components/workzone/workzone-basket.js',
+ config.paths.src + 'prod/js/components/workzone/workzone-facets.js',
config.paths.src + 'prod/js/components/utils.js',
+ config.paths.src + 'prod/js/components/cgu.js',
+ config.paths.src + 'prod/js/components/preferences.js',
// config.paths.src + 'prod/js/jquery.form.2.49.js',
- config.paths.src + 'prod/js/jquery.Edit.js',
- config.paths.src + 'prod/js/jquery.Prod.js',
+ config.paths.src + 'prod/js/components/record/editable-record.js',
+ // config.paths.src + 'prod/js/jquery.Prod.js',
config.paths.src + 'prod/js/jquery.Feedback.js',
- config.paths.src + 'prod/js/components/search-result.js',
config.paths.src + 'prod/js/jquery.main-prod.js',
- config.paths.src + 'prod/js/jquery.Upload.js',
- config.paths.src + 'prod/js/ThumbExtractor.js',
+ config.paths.src + 'prod/js/components/upload/upload.js',
+ config.paths.src + 'prod/js/components/video-editor.js',
config.paths.src + 'prod/js/publicator.js',
config.paths.src + 'vendors/jquery-sprintf/js/jquery.sprintf.1.0.3.js',
config.paths.src + 'prod/js/jquery.p4.preview.js',
- config.paths.src + 'prod/js/record.editor.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/cgu.js b/resources/www/prod/js/components/cgu.js
new file mode 100644
index 0000000000..9d762023e9
--- /dev/null
+++ b/resources/www/prod/js/components/cgu.js
@@ -0,0 +1,56 @@
+var p4 = p4 || {};
+
+var cguModule = (function (p4) {
+ function acceptCgus(name, value) {
+ userModule.setPref(name, value);
+ }
+
+ function cancelCgus(id) {
+
+ $.ajax({
+ type: "POST",
+ url: "../prod/TOU/deny/" + id + "/",
+ dataType: 'json',
+ success: function (data) {
+ if (data.success) {
+ alert(language.cgusRelog);
+ self.location.replace(self.location.href);
+ }
+ else {
+ humane.error(data.message);
+ }
+ }
+ });
+
+ }
+
+ function activateCgus() {
+ var $this = $('.cgu-dialog:first');
+ $this.dialog({
+ autoOpen: true,
+ closeOnEscape: false,
+ draggable: false,
+ modal: true,
+ resizable: false,
+ width: 800,
+ height: 500,
+ open: function () {
+ $this.parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").remove();
+ $('.cgus-accept', $(this)).bind('click', function () {
+ acceptCgus($('.cgus-accept', $this).attr('id'), $('.cgus-accept', $this).attr('date'));
+ $this.dialog('close').remove();
+ activateCgus();
+ });
+ $('.cgus-cancel', $(this)).bind('click', function () {
+ if (confirm(language.warningDenyCgus)) {
+ cancelCgus($('.cgus-cancel', $this).attr('id').split('_').pop());
+ }
+ });
+ }
+ });
+ }
+
+ return {
+ activateCgus: activateCgus
+ };
+}(p4));
diff --git a/resources/www/prod/js/components/editor/record-editor.js b/resources/www/prod/js/components/editor/record-editor.js
new file mode 100644
index 0000000000..916545ad5b
--- /dev/null
+++ b/resources/www/prod/js/components/editor/record-editor.js
@@ -0,0 +1,1927 @@
+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('
');
+
+
+ _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 _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() {
+ console.log('set preview edit on resize')
+ 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 (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 && 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 || !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();
+ hideOverlay(2);
+ if (p4.preview.open)
+ 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();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/preferences.js b/resources/www/prod/js/components/preferences.js
new file mode 100644
index 0000000000..ef851fb5a6
--- /dev/null
+++ b/resources/www/prod/js/components/preferences.js
@@ -0,0 +1,84 @@
+var p4 = p4 || {};
+
+var preferencesModule = (function (p4) {
+ function initLook() {
+ $('#nperpage_slider').slider({
+ value: parseInt($('#nperpage_value').val()),
+ min: 10,
+ max: 100,
+ step: 10,
+ slide: function (event, ui) {
+ $('#nperpage_value').val(ui.value);
+ },
+ stop: function (event, ui) {
+ userModule.setPref('images_per_page', $('#nperpage_value').val());
+ }
+ });
+ $('#sizeAns_slider').slider({
+ value: parseInt($('#sizeAns_value').val()),
+ min: 90,
+ max: 270,
+ step: 10,
+ slide: function (event, ui) {
+ $('#sizeAns_value').val(ui.value);
+ },
+ stop: function (event, ui) {
+ userModule.setPref('images_size', $('#sizeAns_value').val());
+ }
+ });
+ }
+
+ // look_box
+ function setInitialStateOptions() {
+ var el = $('#look_box_settings select[name=start_page]');
+
+ switch (el.val()) {
+ case "LAST_QUERY":
+ case "PUBLI":
+ case "HELP":
+ $('#look_box_settings input[name=start_page_value]').hide();
+ break;
+ case "QUERY":
+ $('#look_box_settings input[name=start_page_value]').show();
+ break;
+ }
+ }
+
+ function setInitialState() {
+ var el = $('#look_box_settings select[name=start_page]');
+ var val = el.val();
+
+
+ var start_page_query = $('#look_box_settings input[name=start_page_value]').val();
+
+ if (val === 'QUERY') {
+ userModule.setPref('start_page_query', start_page_query);
+ }
+
+ userModule.setPref('start_page', val);
+
+ }
+
+
+ function lookBox(el, event) {
+ $("#look_box").dialog({
+ closeOnEscape: true,
+ resizable: false,
+ width: 450,
+ height: 500,
+ modal: true,
+ draggable: false,
+ overlay: {
+ backgroundColor: '#000',
+ opacity: 0.7
+ }
+ }).dialog('open');
+ }
+
+ return {
+ initLook: initLook,
+ lookBox: lookBox,
+ setInitialStateOptions: setInitialStateOptions,
+ setInitialState: setInitialState
+ };
+}(p4));
diff --git a/resources/www/prod/js/jquery.Edit.js b/resources/www/prod/js/components/record/editable-record.js
similarity index 100%
rename from resources/www/prod/js/jquery.Edit.js
rename to resources/www/prod/js/components/record/editable-record.js
diff --git a/resources/www/prod/js/components/search-result.js b/resources/www/prod/js/components/search/search-result.js
similarity index 100%
rename from resources/www/prod/js/components/search-result.js
rename to resources/www/prod/js/components/search/search-result.js
diff --git a/resources/www/prod/js/components/search.js b/resources/www/prod/js/components/search/search.js
similarity index 88%
rename from resources/www/prod/js/components/search.js
rename to resources/www/prod/js/components/search/search.js
index 1ecb81d8d5..0833f749f5 100644
--- a/resources/www/prod/js/components/search.js
+++ b/resources/www/prod/js/components/search/search.js
@@ -12,6 +12,41 @@ var searchModule = (function (p4) {
$(todeploy_selector).show();
}
}
+ /**
+ * adv search : check/uncheck all the collections (called by the buttons "all"/"none")
+ *
+ * @param bool
+ */
+ function toggleDatabase(bool) {
+ $('form.phrasea_query .sbas_list').each(function () {
+
+ var sbas_id = $(this).find('input[name=reference]:first').val();
+ if (bool)
+ $(this).find(':checkbox').prop('checked', true);
+ else
+ $(this).find(':checkbox').prop('checked', false);
+ });
+
+ checkFilters(true);
+ }
+
+ function resetSearch() {
+ var container = $("#ADVSRCH_OPTIONS_ZONE");
+ var fieldsSort = $('#ADVSRCH_SORT_ZONE select[name=sort]', container);
+ var fieldsSortOrd = $('#ADVSRCH_SORT_ZONE select[name=ord]', container);
+ var dateFilterSelect = $('#ADVSRCH_DATE_ZONE select', container);
+
+ $("option.default-selection", fieldsSort).prop("selected", true);
+ $("option.default-selection", fieldsSortOrd).prop("selected", true);
+
+ $('#ADVSRCH_FIELDS_ZONE option').prop("selected", false);
+ $('#ADVSRCH_OPTIONS_ZONE input:checkbox.field_switch').prop("checked", false);
+
+ $("option:eq(0)", dateFilterSelect).prop("selected", true);
+ $('#ADVSRCH_OPTIONS_ZONE .datepicker').val('');
+ $('form.adv_search_bind input:text').val('');
+ toggleDatabase(true);
+ }
function selectDatabase(el, sbas_id) {
console.log('ok select')
@@ -309,11 +344,13 @@ var searchModule = (function (p4) {
return {
checkFilters: checkFilters,
+ toggleDatabase: toggleDatabase,
toggleCollection: toggleCollection,
selectDatabase: selectDatabase,
beforeSearch: beforeSearch,
afterSearch: afterSearch,
clearAnswers: clearAnswers,
- newSearch: newSearch
+ newSearch: newSearch,
+ resetSearch: resetSearch
};
}(p4));
diff --git a/resources/www/prod/js/jquery.Upload.js b/resources/www/prod/js/components/upload/upload.js
similarity index 100%
rename from resources/www/prod/js/jquery.Upload.js
rename to resources/www/prod/js/components/upload/upload.js
diff --git a/resources/www/prod/js/ThumbExtractor.js b/resources/www/prod/js/components/video-editor.js
similarity index 97%
rename from resources/www/prod/js/ThumbExtractor.js
rename to resources/www/prod/js/components/video-editor.js
index 0e7c487f6f..4640dbb6fd 100644
--- a/resources/www/prod/js/ThumbExtractor.js
+++ b/resources/www/prod/js/components/video-editor.js
@@ -1,5 +1,4 @@
-;
-(function (document) {
+var videoEditorModule = (function (document) {
/*****************
* Canva Object
@@ -218,7 +217,7 @@
/**
* THUMB EDITOR
*/
- var ThumbEditor = function (videoId, canvaId, outputOptions) {
+ var ThumbnailEditor = function (videoId, canvaId, outputOptions) {
var domElement = document.getElementById(videoId);
@@ -313,7 +312,11 @@
};
};
- document.THUMB_EDITOR = ThumbEditor;
+ // document.THUMB_EDITOR = ThumbEditor;
+
+ return {
+ ThumbnailEditor: ThumbnailEditor
+ }
})(document);
diff --git a/resources/www/prod/js/components/workzone-basket.js b/resources/www/prod/js/components/workzone/workzone-basket.js
similarity index 100%
rename from resources/www/prod/js/components/workzone-basket.js
rename to resources/www/prod/js/components/workzone/workzone-basket.js
diff --git a/resources/www/prod/js/components/workzone-facets.js b/resources/www/prod/js/components/workzone/workzone-facets.js
similarity index 100%
rename from resources/www/prod/js/components/workzone-facets.js
rename to resources/www/prod/js/components/workzone/workzone-facets.js
diff --git a/resources/www/prod/js/components/workzone.js b/resources/www/prod/js/components/workzone/workzone.js
similarity index 100%
rename from resources/www/prod/js/components/workzone.js
rename to resources/www/prod/js/components/workzone/workzone.js
diff --git a/resources/www/prod/js/jquery.Prod.js b/resources/www/prod/js/jquery.Prod.js
deleted file mode 100644
index 9061b9b314..0000000000
--- a/resources/www/prod/js/jquery.Prod.js
+++ /dev/null
@@ -1,37 +0,0 @@
-(function () {
- $(document).ready(function () {
- humane.info = humane.spawn({addnCls: 'humane-libnotify-info', timeout: 1000});
- humane.error = humane.spawn({addnCls: 'humane-libnotify-error', timeout: 1000});
-
- $('body').on('click', 'a.dialog', function (event) {
- var $this = $(this), size = 'Medium';
-
- if ($this.hasClass('small-dialog')) {
- size = 'Small';
- } else if ($this.hasClass('full-dialog')) {
- size = 'Full';
- }
-
- var options = {
- size: size,
- loading: true,
- title: $this.attr('title'),
- closeOnEscape: true
- };
-
- $dialog = p4.Dialog.Create(options);
-
- $.ajax({
- type: "GET",
- url: $this.attr('href'),
- dataType: 'html',
- success: function (data) {
- $dialog.setContent(data);
- return;
- }
- });
-
- return false;
- });
- });
-}());
diff --git a/resources/www/prod/js/jquery.main-prod.js b/resources/www/prod/js/jquery.main-prod.js
index 4671fdb171..cc73744cd6 100644
--- a/resources/www/prod/js/jquery.main-prod.js
+++ b/resources/www/prod/js/jquery.main-prod.js
@@ -9,7 +9,43 @@ answAjaxrunning = false;
var searchAjax, searchAjaxRunning;
searchAjaxRunning = false;
-var language = {};
+$(document).ready(function () {
+ humane.info = humane.spawn({addnCls: 'humane-libnotify-info', timeout: 1000});
+ humane.error = humane.spawn({addnCls: 'humane-libnotify-error', timeout: 1000});
+
+ $('body').on('click', 'a.dialog', function (event) {
+ var $this = $(this), size = 'Medium';
+
+ if ($this.hasClass('small-dialog')) {
+ size = 'Small';
+ } else if ($this.hasClass('full-dialog')) {
+ size = 'Full';
+ }
+
+ var options = {
+ size: size,
+ loading: true,
+ title: $this.attr('title'),
+ closeOnEscape: true
+ };
+
+ $dialog = p4.Dialog.Create(options);
+
+ $.ajax({
+ type: "GET",
+ url: $this.attr('href'),
+ dataType: 'html',
+ success: function (data) {
+ $dialog.setContent(data);
+ return;
+ }
+ });
+
+ return false;
+ });
+});
+
+//var language = {}; // handled with external prodution module
var bodySize = {
x: 0,
y: 0
@@ -21,70 +57,8 @@ function resizePreview() {
setPreview();
}
-function getHome(cas, page) {
-
- if (typeof(page) === 'undefined')
- page = 0;
-
- switch (cas) {
- case 'QUERY':
- workzoneFacetsModule.resetSelectedFacets();
- searchModule.newSearch($("#EDIT_query").val());
- break;
- case 'PUBLI':
- publicationModule.fetchPublications(page, answAjax, answAjaxrunning);
- break;
- case 'HELP':
- $.ajax({
- type: "POST",
- url: "/client/home/",
- dataType: 'html',
- data: {
- type: cas
- },
- beforeSend: function () {
- if (answAjaxrunning && answAjax.abort)
- answAjax.abort();
- searchModule.clearAnswers();
- answAjaxrunning = true;
- $('#answers').addClass('loading');
- },
- error: function () {
- answAjaxrunning = false;
- $('#answers').removeClass('loading');
- },
- timeout: function () {
- answAjaxrunning = false;
- $('#answers').removeClass('loading');
- },
- success: function (data) {
- answAjaxrunning = false;
- $('#answers').append(data);
- searchModule.afterSearch();
- return;
- }
-
- });
- break;
-
-
- default:
- break;
- }
-}
-
-function getLanguage() {
- $.ajax({
- type: "GET",
- url: "../prod/language/",
- dataType: 'json',
- success: function (data) {
- language = data;
- return;
- }
- });
-}
+// @TODO keyboard methods should be moved in an external component
function is_ctrl_key(event) {
if (event.altKey)
return true;
@@ -102,45 +76,13 @@ function is_ctrl_key(event) {
return false;
}
+// @TODO keyboard methods should be moved in an external component
function is_shift_key(event) {
if (event.shiftKey)
return true;
return false;
}
-/**
- * adv search : check/uncheck all the collections (called by the buttons "all"/"none")
- *
- * @param bool
- */
-function checkBases(bool) {
- $('form.phrasea_query .sbas_list').each(function () {
-
- var sbas_id = $(this).find('input[name=reference]:first').val();
- if (bool)
- $(this).find(':checkbox').prop('checked', true);
- else
- $(this).find(':checkbox').prop('checked', false);
- });
-
- searchModule.checkFilters(true);
-}
-
-
-
-/* NOT USED function toggleFilter(filter, ele) {
- var el = $('#' + filter);
- if (el.is(':hidden'))
- $(ele).parent().addClass('open');
- else
- $(ele).parent().removeClass('open');
- el.slideToggle('fast');
-}*/
-
-
-/* NOT USED function setVisible(el) {
- el.style.visibility = 'visible';
-}*/
function resize() {
var body = $('#mainContainer');
@@ -171,38 +113,8 @@ function resize() {
-function reset_adv_search() {
- var container = $("#ADVSRCH_OPTIONS_ZONE");
- var fieldsSort = $('#ADVSRCH_SORT_ZONE select[name=sort]', container);
- var fieldsSortOrd = $('#ADVSRCH_SORT_ZONE select[name=ord]', container);
- var dateFilterSelect = $('#ADVSRCH_DATE_ZONE select', container);
-
- $("option.default-selection", fieldsSort).prop("selected", true);
- $("option.default-selection", fieldsSortOrd).prop("selected", true);
-
- $('#ADVSRCH_FIELDS_ZONE option').prop("selected", false);
- $('#ADVSRCH_OPTIONS_ZONE input:checkbox.field_switch').prop("checked", false);
-
- $("option:eq(0)", dateFilterSelect).prop("selected", true);
- $('#ADVSRCH_OPTIONS_ZONE .datepicker').val('');
- $('form.adv_search_bind input:text').val('');
- checkBases(true);
-}
-
-function search_doubles() {
- workzoneFacetsModule.resetSelectedFacets();
- $('#EDIT_query').val('sha256=sha256');
- searchModule.newSearch('sha256=sha256');
-}
-
-
-
-
-
-
function initAnswerForm() {
-
var searchForm = $('#searchForm');
$('button[type="submit"]', searchForm).bind('click', function () {
workzoneFacetsModule.resetSelectedFacets();
@@ -288,31 +200,9 @@ function initAnswerForm() {
});
return false;
});
- if (searchForm.hasClass('triggerAfterInit')) {
- searchForm.removeClass('triggerAfterInit').trigger('submit');
- }
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-$(document).ready(function() {
-});
-
-
-
function answerSizer() {
var el = $('#idFrameC').outerWidth();
if (!$.support.cssFloat) {
@@ -357,85 +247,12 @@ function linearize() {
}
-function initLook() {
- $('#nperpage_slider').slider({
- value: parseInt($('#nperpage_value').val()),
- min: 10,
- max: 100,
- step: 10,
- slide: function (event, ui) {
- $('#nperpage_value').val(ui.value);
- },
- stop: function (event, ui) {
- userModule.setPref('images_per_page', $('#nperpage_value').val());
- }
- });
- $('#sizeAns_slider').slider({
- value: parseInt($('#sizeAns_value').val()),
- min: 90,
- max: 270,
- step: 10,
- slide: function (event, ui) {
- $('#sizeAns_value').val(ui.value);
- },
- stop: function (event, ui) {
- userModule.setPref('images_size', $('#sizeAns_value').val());
- }
- });
-}
-function acceptCgus(name, value) {
- userModule.setPref(name, value);
-}
-function cancelCgus(id) {
-
- $.ajax({
- type: "POST",
- url: "../prod/TOU/deny/" + id + "/",
- dataType: 'json',
- success: function (data) {
- if (data.success) {
- alert(language.cgusRelog);
- self.location.replace(self.location.href);
- }
- else {
- humane.error(data.message);
- }
- }
- });
-
-}
-
-function activateCgus() {
- var $this = $('.cgu-dialog:first');
- $this.dialog({
- autoOpen: true,
- closeOnEscape: false,
- draggable: false,
- modal: true,
- resizable: false,
- width: 800,
- height: 500,
- open: function () {
- $this.parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").remove();
- $('.cgus-accept', $(this)).bind('click', function () {
- acceptCgus($('.cgus-accept', $this).attr('id'), $('.cgus-accept', $this).attr('date'));
- $this.dialog('close').remove();
- activateCgus();
- });
- $('.cgus-cancel', $(this)).bind('click', function () {
- if (confirm(language.warningDenyCgus)) {
- cancelCgus($('.cgus-cancel', $this).attr('id').split('_').pop());
- }
- });
- }
- });
-}
$(document).ready(function () {
humane.forceNew = true;
- activateCgus();
+ cguModule.activateCgus();
});
@@ -816,7 +633,7 @@ $(document).ready(function () {
initAnswerForm();
- initLook();
+ preferencesModule.initLook();
// setTimeout("pollNotifications();", 10000);
@@ -836,22 +653,22 @@ $(document).ready(function () {
switch (event.keyCode) {
case 9: // tab ou shift-tab
- edit_chgFld(event, is_shift_key(event) ? -1 : 1);
+ recordEditorModule.edit_chgFld(event, is_shift_key(event) ? -1 : 1);
cancelKey = shortCut = true;
break;
case 27:
- edit_cancelMultiDesc(event);
+ recordEditorModule.edit_cancelMultiDesc(event);
shortCut = true;
break;
case 33: // pg up
- if (!p4.edit.textareaIsDirty || edit_validField(event, "ask_ok"))
- skipImage(event, 1);
+ if (!p4.edit.textareaIsDirty || recordEditorModule.edit_validField(event, "ask_ok"))
+ recordEditorModule.skipImage(event, 1);
cancelKey = true;
break;
case 34: // pg dn
- if (!p4.edit.textareaIsDirty || edit_validField(event, "ask_ok"))
- skipImage(event, -1);
+ if (!p4.edit.textareaIsDirty || recordEditorModule.edit_validField(event, "ask_ok"))
+ recordEditorModule.skipImage(event, -1);
cancelKey = true;
break;
}
@@ -1106,7 +923,7 @@ function editThis(type, value) {
dataType: "html",
data: options,
success: function (data) {
- initializeEdit();
+ recordEditorModule.initialize();
$('#idFrameE').removeClass('loading').empty().html(data);
$('#tooltip').hide();
return;
@@ -1142,7 +959,7 @@ function editThis(type, value) {
});
})(jQuery);
-(function ($) {
+/*(function ($) {
$.fn.extend({
flash: function (color) {
if ($(this).hasClass('animating')) {
@@ -1177,7 +994,7 @@ function editThis(type, value) {
});
}
});
-})(jQuery);
+})(jQuery);*/
function toggleRemoveReg(el) {
@@ -1393,7 +1210,7 @@ function remove_from_basket(el, confirm) {
function doSpecialSearch(qry, allbase) {
if (allbase) {
- checkBases(true);
+ searchModule.toggleDatabase(true);
}
workzoneFacetsModule.resetSelectedFacets();
$('#EDIT_query').val(decodeURIComponent(qry).replace(/\+/g, " "));
@@ -1409,140 +1226,10 @@ function clktri(id) {
}
-// ---------------------- fcts du thesaurus
-/* NOT USED function chgProp(path, v, k) {
- var q2;
- if (!k)
- k = "*";
- //if(k!=null)
- v = v + " [" + k + "]";
- $("#thprop_a_" + path).html('"' + v + '"');
- // q = document.getElementById("thprop_q").innerText;
- // if(!q )
- // if(document.getElementById("thprop_q") && document.getElementById("thprop_q").textContent)
- // q = document.getElementById("thprop_q").textContent;
- q = $("#thprop_q").text();
-
- q2 = "";
- for (i = 0; i < q.length; i++)
- q2 += q.charCodeAt(i) == 160 ? " " : q.charAt(i);
-
- workzoneFacetsModule.resetSelectedFacets();
- $('#EDIT_query').val(q);
- newSearch(q);
-
- return(false);
-}*/
-
-/* NOT USED function doDelete(lst) {
- var children = '0';
- if (document.getElementById('del_children') && document.getElementById('del_children').checked)
- children = '1';
- $.ajax({
- type: "POST",
- url: "../prod/delete/",
- dataType: 'json',
- data: {
- lst: lst.join(';'),
- del_children: children
- },
- success: function (data) {
-
- $.each(data, function (i, n) {
- var imgt = $('#IMGT_' + n),
- chim = $('.CHIM_' + n),
- stories = $('.STORY_' + n);
- $('.doc_infos', imgt).remove();
- imgt.unbind("click").removeAttr("ondblclick").removeClass("selected").removeClass("IMGT").find("img").unbind();
-
- if (imgt.data("ui-draggable")) {
- imgt.draggable("destroy");
- }
-
- imgt.find(".thumb img").attr("src", "/assets/common/images/icons/deleted.png").css({
- width: '100%',
- height: 'auto',
- margin: '0 10px',
- top: '0'
- });
- chim.parent().slideUp().remove();
- imgt.find(".status,.title,.bottom").empty();
-
- p4.Results.Selection.remove(n);
- if (stories.length > 0) {
- p4.WorkZone.refresh();
- }
- else {
- p4.WorkZone.Selection.remove(n);
- }
- });
- viewNbSelect();
- }
- });
-}*/
-
-
-
-
-
-/* NOT USED function advSearch(event) {
- event.cancelBubble = true;
- // alternateSearch(false);
- $('#idFrameC .tabs a.adv_search').trigger('click');
-}*/
-
-// look_box
-function start_page_selector() {
- var el = $('#look_box_settings select[name=start_page]');
-
- switch (el.val()) {
- case "LAST_QUERY":
- case "PUBLI":
- case "HELP":
- $('#look_box_settings input[name=start_page_value]').hide();
- break;
- case "QUERY":
- $('#look_box_settings input[name=start_page_value]').show();
- break;
- }
-}
-// look_box
-function set_start_page() {
- var el = $('#look_box_settings select[name=start_page]');
- var val = el.val();
-
-
- var start_page_query = $('#look_box_settings input[name=start_page_value]').val();
-
- if (val === 'QUERY') {
- userModule.setPref('start_page_query', start_page_query);
- }
-
- userModule.setPref('start_page', val);
-
-}
-
-
-// preferences modal
-function lookBox(el, event) {
- $("#look_box").dialog({
- closeOnEscape: true,
- resizable: false,
- width: 450,
- height: 500,
- modal: true,
- draggable: false,
- overlay: {
- backgroundColor: '#000',
- opacity: 0.7
- }
- }).dialog('open');
-}
-
-function showAnswer(p) {
+/* NOT USED function showAnswer(p) {
var o;
if (p === 'Results') {
// on montre les results
@@ -1580,7 +1267,7 @@ function showAnswer(p) {
setTimeout('document.getElementById("AnswerExplain").style.display = "block";', 200);
}
}
-}
+}*/
/** FROM INDEX.php **/
@@ -1589,31 +1276,6 @@ function saveeditPbar(idesc, ndesc) {
document.getElementById("saveeditPbarN").innerHTML = ndesc;
}
-/* NOT USED function getSelText() {
- var txt = '';
- if (window.getSelection) {
- txt = window.getSelection();
- }
- else if (document.getSelection) {
- txt = document.getSelection();
- }
- else if (document.selection) {
- txt = document.selection.createRange().text;
- }
- else
- return;
- return txt;
-}*/
-
-/* NOT USED function getWinPosAsXML() {
- var ret = '';
-
- if ($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible'))
- ret += '';
-
-
- return ret;
-}*/
function saveWindows() {
var key = '';
@@ -1637,78 +1299,6 @@ function gotopage(pag) {
$('#searchForm').submit();
}
-/* NOT USED function addFilterMulti(filter, link, sbasid) {
- var clone = $('#filter_multi_' + sbasid + '_' + filter);
- var orig = clone;
- if (!$('#filter_multi_' + sbasid + '_' + filter).is(':visible')) {
- clone = orig.clone(true);
- var par = orig.parent();
- orig.remove();
- par.append(clone);
- clone.slideDown('fast', function () {
- $(this);
- });
- $(link).addClass('filterActive');
- }
- else {
- clone.slideUp();
- $(link).removeClass('filterActive');
- }
- return false;
-}*/
-
-/* NOT USED function autoorder() {
- var val = $.trim($('#auto_order').val());
-
- if (val === '')
- return;
-
- var sorter = new Array();
-
- $('#reorder_box .diapo form').each(function (i, n) {
-
- var id = $('input[name=id]', n).val();
-
- switch (val) {
- case 'title':
- default:
- var data = $('input[name=title]', n).val();
- break;
- case 'default':
- var data = $('input[name=default]', n).val();
- break;
- }
-
- sorter[id] = data;
- });
-
- var data_type = 'string';
-
- switch (val) {
- case 'default':
- var data_type = 'integer';
- break;
- }
-
- sorter = arraySortByValue(sorter, data_type);
-
- var last_moved = false;
-
- for (i in sorter) {
- var elem = $('#ORDER_' + i);
- if (last_moved) {
- elem.insertAfter(last_moved);
- }
- else {
- $('#reorder_box').prepend(elem);
- }
- last_moved = elem;
- }
-
-}*/
-
-
-
//clear search
$(document).ready(function () {
diff --git a/resources/www/prod/js/record.editor.js b/resources/www/prod/js/record.editor.js
deleted file mode 100644
index a505b33fc3..0000000000
--- a/resources/www/prod/js/record.editor.js
+++ /dev/null
@@ -1,1906 +0,0 @@
-function initializeEdit() {
- 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;
-}
-
-$(document).ready(function () {
- $(window).bind('resize', function () {
- setPreviewEdit();
- setSizeLimits();
- });
-});
-
-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 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);
-}
-
-// ---------------------------------------------------------------------------
-// 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);
-}
-
-// ---------------------------------------------------------------------------
-// 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);
-}
-
-// ---------------------------------------------------------------------------
-// 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 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 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());
- }
-}
-
-//// ---------------------------------------------------------------------------
-//// 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 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();
-}
-
-
-// ---------------------------------------------------------------------------
-// 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());
-}
-
-
-// ---------------------------------------------------------------------------
-// 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);
-}
-
-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);
-
-}
-
-// ---------------------------------------------------------------------------
-// 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 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);
-}
-
-// ---------------------------------------------------------------------------------------------------------
-// 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);
-}
-
-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 edit_select_all() {
- $('#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
-}
-
-// ---------------------------------------------------------------------------
-// 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 && 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 || !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);
-}
-
-function toggleGroupSelection() {
- var groupIndex = 0;
- edit_clk_editimg(false, groupIndex);
-}
-
-// ---------------------------------------------------------------------------
-// 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;
- }
- }
-}
-
-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 (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, "¶
");
- }
- }
- }
-}
-
-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;
-}
-
-// ----------------------------------------------------------------------------------
-// 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();
- hideOverlay(2);
- if (p4.preview.open)
- 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();hideOverlay(2);", 100);
-
- }
-}
-
-// ======================================================
-// ================ gestion du thesaurus ================
-// ======================================================
-
-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 = "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 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 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));
-
- updateEditSelectedRecords(null);
-}
-
-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 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_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_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 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 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 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 {
- self.setTimeout("edit_select_all();", 100);
- }
-
- $('.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 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);
-}
-
-
diff --git a/resources/www/prod/js/tests/jquery.Upload.js.html b/resources/www/prod/js/tests/jquery.Upload.js.html
index 7d83609d01..a0298210c2 100644
--- a/resources/www/prod/js/tests/jquery.Upload.js.html
+++ b/resources/www/prod/js/tests/jquery.Upload.js.html
@@ -7,7 +7,7 @@
-
+
diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig
index e57b165b0d..98668dcab7 100644
--- a/templates/web/prod/index.html.twig
+++ b/templates/web/prod/index.html.twig
@@ -223,9 +223,9 @@
@@ -233,7 +233,7 @@
-
+
@@ -393,21 +393,9 @@
-
+
@@ -623,7 +611,7 @@
{{ 'Affichage au demarrage' | trans }}
@@ -754,6 +742,16 @@
|