diff --git a/resources/gulp/build.js b/resources/gulp/build.js
index 88c691425f..81aa343877 100644
--- a/resources/gulp/build.js
+++ b/resources/gulp/build.js
@@ -27,6 +27,7 @@ gulp.task('build', ['build-vendors'], function(){
// standalone vendors used across application
gulp.task('build-vendors', [
'build-alchemy-embed',
+ 'build-betterjs',
'build-phraseanet-production-client',
'build-bootstrap',
'build-colorpicker',
diff --git a/resources/gulp/components/common.js b/resources/gulp/components/common.js
index 7c204b0208..52adf7f903 100644
--- a/resources/gulp/components/common.js
+++ b/resources/gulp/components/common.js
@@ -26,6 +26,7 @@ gulp.task('build-common-css', ['build-common-font-css'],function(){
gulp.task('build-common-js', function(){
var commonGroup = [
+ config.paths.src + 'common/js/components/user.js',
// config.paths.dist + 'assets/bootstrap/js/bootstrap.js', // should append no conflict
config.paths.src + 'vendors/jquery-mousewheel/js/jquery.mousewheel.js',
// jquery ui date picker langs
diff --git a/resources/gulp/components/prod.js b/resources/gulp/components/prod.js
index e0bbcf7ee0..cd5b7a0cec 100644
--- a/resources/gulp/components/prod.js
+++ b/resources/gulp/components/prod.js
@@ -73,17 +73,22 @@ gulp.task('build-prod-js', function(){
config.paths.vendors + 'jquery-file-upload/js/jquery.iframe-transport.js',
config.paths.vendors + 'jquery-file-upload/js/jquery.fileupload.js',
config.paths.vendors + 'geonames-server-jquery-plugin/jquery.geonames.js',
+ config.paths.src + 'prod/js/core/lists.js',
+ config.paths.src + 'prod/js/core/selectable.js',
+ config.paths.src + 'prod/js/core/alert.js',
+
+ config.paths.src + 'prod/js/components/search.js',
config.paths.src + 'prod/js/components/publication.js',
- config.paths.src + 'prod/js/jquery.form.2.49.js',
- config.paths.src + 'prod/js/jquery.Selection.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/utils.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.lists.js',
config.paths.src + 'prod/js/jquery.Prod.js',
config.paths.src + 'prod/js/jquery.Feedback.js',
- config.paths.src + 'prod/js/jquery.Results.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.WorkZone.js',
- config.paths.src + 'prod/js/jquery.Alerts.js',
config.paths.src + 'prod/js/jquery.Upload.js',
config.paths.src + 'prod/js/ThumbExtractor.js',
config.paths.src + 'prod/js/publicator.js',
diff --git a/resources/gulp/components/vendors/better.js b/resources/gulp/components/vendors/better.js
new file mode 100644
index 0000000000..bdede994ec
--- /dev/null
+++ b/resources/gulp/components/vendors/better.js
@@ -0,0 +1,9 @@
+var gulp = require('gulp');
+var config = require('../../config.js');
+var utils = require('../../utils.js');
+
+gulp.task('build-betterjs', [], function(){
+ return utils.buildJsGroup([
+ config.paths.vendors + 'better.js/build/better.js'
+ ], 'better', 'vendors/better');
+});
\ No newline at end of file
diff --git a/resources/www/common/js/components/user.js b/resources/www/common/js/components/user.js
new file mode 100644
index 0000000000..bf8e7770b6
--- /dev/null
+++ b/resources/www/common/js/components/user.js
@@ -0,0 +1,39 @@
+
+var userModule = (function(){
+ function setPref(name, value) {
+ if (jQuery.data['pref_' + name] && jQuery.data['pref_' + name].abort) {
+ jQuery.data['pref_' + name].abort();
+ jQuery.data['pref_' + name] = false;
+ }
+
+ jQuery.data['pref_' + name] = $.ajax({
+ type: "POST",
+ url: "/user/preferences/",
+ data: {
+ prop: name,
+ value: value
+ },
+ dataType: 'json',
+ timeout: function () {
+ jQuery.data['pref_' + name] = false;
+ },
+ error: function () {
+ jQuery.data['pref_' + name] = false;
+ },
+ success: function (data) {
+ if (data.success) {
+ humane.info(data.message);
+ }
+ else {
+ humane.error(data.message);
+ }
+ jQuery.data['pref_' + name] = false;
+ return;
+ }
+ });
+ }
+
+ return {setPref: setPref}
+})();
+
+
diff --git a/resources/www/common/js/jquery.common.js b/resources/www/common/js/jquery.common.js
index d445728877..19edcba789 100644
--- a/resources/www/common/js/jquery.common.js
+++ b/resources/www/common/js/jquery.common.js
@@ -40,38 +40,6 @@ $(document).ready(function () {
});
-function setPref(name, value) {
- if (jQuery.data['pref_' + name] && jQuery.data['pref_' + name].abort) {
- jQuery.data['pref_' + name].abort();
- jQuery.data['pref_' + name] = false;
- }
-
- jQuery.data['pref_' + name] = $.ajax({
- type: "POST",
- url: "/user/preferences/",
- data: {
- prop: name,
- value: value
- },
- dataType: 'json',
- timeout: function () {
- jQuery.data['pref_' + name] = false;
- },
- error: function () {
- jQuery.data['pref_' + name] = false;
- },
- success: function (data) {
- if (data.success) {
- humane.info(data.message);
- }
- else {
- humane.error(data.message);
- }
- jQuery.data['pref_' + name] = false;
- return;
- }
- });
-}
function infoDialog(el) {
diff --git a/resources/www/prod/js/components/publication.js b/resources/www/prod/js/components/publication.js
index 6b25788277..9ba8b754bd 100644
--- a/resources/www/prod/js/components/publication.js
+++ b/resources/www/prod/js/components/publication.js
@@ -48,7 +48,7 @@ var publicationModule = (function () {
});
}
}
- afterSearch();
+ searchModule.afterSearch();
});
});
@@ -178,7 +178,7 @@ var publicationModule = (function () {
if (ajaxState.isRunning && ajaxState.query.abort)
answAjax.abort();
if (page === 0)
- clearAnswers();
+ searchModule.clearAnswers();
ajaxState.isRunning = true;
$answers.addClass('loading');
},
@@ -307,7 +307,7 @@ var publicationModule = (function () {
container: $answers
});
- afterSearch();
+ searchModule.afterSearch();
if (page > 0) {
$answers.stop().animate({
scrollTop: $answers.scrollTop() + $answers.height()
diff --git a/resources/www/prod/js/jquery.Results.js b/resources/www/prod/js/components/search-result.js
similarity index 100%
rename from resources/www/prod/js/jquery.Results.js
rename to resources/www/prod/js/components/search-result.js
diff --git a/resources/www/prod/js/components/search.js b/resources/www/prod/js/components/search.js
new file mode 100644
index 0000000000..1ecb81d8d5
--- /dev/null
+++ b/resources/www/prod/js/components/search.js
@@ -0,0 +1,319 @@
+var p4 = p4 || {};
+
+var searchModule = (function (p4) {
+ function toggleCollection(deployer, todeploy_selector)
+ {
+ if($(deployer).hasClass("deployer_opened")) {
+ $(deployer).removeClass("deployer_opened").addClass("deployer_closed");
+ $(todeploy_selector).hide();
+ }
+ else {
+ $(deployer).removeClass("deployer_closed").addClass("deployer_opened");
+ $(todeploy_selector).show();
+ }
+ }
+
+ function selectDatabase(el, sbas_id) {
+ console.log('ok select')
+ var bool = $(el).prop('checked');
+ $.each($('.sbascont_' + sbas_id + ' :checkbox'), function () {
+ this.checked = bool;
+ });
+
+ checkFilters(true);
+ }
+
+ function clearAnswers() {
+ $('#formAnswerPage').val('');
+ $('#searchForm input[name="nba"]').val('');
+ $('#answers, #dyn_tool').empty();
+ }
+
+ function newSearch(query) {
+ p4.Results.Selection.empty();
+
+ searchModule.clearAnswers();
+ $('#SENT_query').val(query);
+ var histo = $('#history-queries ul');
+
+ histo.prepend('
' + query + '');
+
+ var lis = $('li', histo);
+ if (lis.length > 25) {
+ $('li:last', histo).remove();
+ }
+
+ $('#idFrameC li.proposals_WZ').removeClass('active');
+
+ $('#searchForm').submit();
+ return false;
+ }
+
+ function beforeSearch() {
+ if (answAjaxrunning)
+ return;
+ answAjaxrunning = true;
+
+ searchModule.clearAnswers();
+ $('#tooltip').css({
+ 'display': 'none'
+ });
+ $('#answers').addClass('loading').empty();
+ $('#answercontextwrap').remove();
+ }
+
+ function afterSearch() {
+ if ($('#answercontextwrap').length === 0)
+ $('body').append('');
+
+ $.each($('#answers .contextMenuTrigger'), function () {
+
+ var id = $(this).closest('.IMGT').attr('id').split('_').slice(1, 3).join('_');
+
+ $(this).contextMenu('#IMGT_' + id + ' .answercontextmenu', {
+ appendTo: '#answercontextwrap',
+ openEvt: 'click',
+ dropDown: true,
+ theme: 'vista',
+ showTransition: 'slideDown',
+ hideTransition: 'hide',
+ shadow: false
+ });
+ });
+
+ answAjaxrunning = false;
+ $('#answers').removeClass('loading');
+ $('.captionTips, .captionRolloverTips').tooltip({
+ delay: 0,
+ isBrowsable: false,
+ extraClass: 'caption-tooltip-container'
+ });
+ $('.infoTips').tooltip({
+ delay: 0
+ });
+ $('.previewTips').tooltip({
+ fixable: true
+ });
+ $('.thumb .rollovable').hover(
+ function () {
+ $('.rollover-gif-hover', this).show();
+ $('.rollover-gif-out', this).hide();
+ },
+ function () {
+ $('.rollover-gif-hover', this).hide();
+ $('.rollover-gif-out', this).show();
+ }
+ );
+ viewNbSelect();
+ $('#answers div.IMGT').draggable({
+ helper: function () {
+ $('body').append('' + p4.Results.Selection.length() + '
');
+ return $('#dragDropCursor');
+ },
+ scope: "objects",
+ distance: 20,
+ scroll: false,
+ cursorAt: {
+ top: -10,
+ left: -20
+ },
+ start: function (event, ui) {
+ if (!$(this).hasClass('selected'))
+ return false;
+ }
+ });
+ linearize();
+ }
+
+ function checkFilters(save) {
+ var danger = false;
+ var search = {
+ bases: {},
+ fields: [],
+ dates: {},
+ status: [],
+ elasticSort: {}
+
+ };
+
+ var adv_box = $('form.phrasea_query .adv_options');
+ var container = $("#ADVSRCH_OPTIONS_ZONE");
+ var fieldsSort = $('#ADVSRCH_SORT_ZONE select[name=sort]', container);
+ var fieldsSortOrd = $('#ADVSRCH_SORT_ZONE select[name=ord]', container);
+ var fieldsSelect = $('#ADVSRCH_FIELDS_ZONE select', container);
+ var dateFilterSelect = $('#ADVSRCH_DATE_ZONE select', container);
+ var scroll = fieldsSelect.scrollTop();
+
+ // hide all the fields in the "sort by" select, so only the relevant ones will be shown again
+ $("option.dbx", fieldsSort).hide().prop("disabled", true); // dbx is for "field of databases"
+
+ // hide all the fields in the "fields" select, so only the relevant ones will be shown again
+ $("option.dbx", fieldsSelect).hide().prop("disabled", true); // option[0] is "all fields"
+
+ // hide all the fields in the "date field" select, so only the relevant ones will be shown again
+ $("option.dbx", dateFilterSelect).hide().prop("disabled", true); // dbx = all "field" entries in the select = all except the firstt
+
+ var nbTotalSelectedColls = 0;
+ $.each($('.sbascont', adv_box), function () {
+ var $this = $(this);
+
+ var sbas_id = $this.parent().find('input[name="reference"]').val();
+ search.bases[sbas_id] = [];
+
+ var nbCols = 0;
+ var nbSelectedColls = 0;
+ $this.find('.checkbas').each(function (idx, el) {
+ nbCols++;
+ if($(this).prop('checked')) {
+ nbSelectedColls++;
+ nbTotalSelectedColls++;
+ search.bases[sbas_id].push($(this).val());
+ }
+ });
+
+ // display the number of selected colls for the databox
+ $('.infos_sbas_' + sbas_id).empty().append(nbSelectedColls + '/' + nbCols);
+
+ // if one coll is not checked, show danger
+ if(nbSelectedColls != nbCols) {
+ $("#ADVSRCH_SBAS_LABEL_" + sbas_id).addClass("danger");
+ danger = true;
+ }
+ else {
+ $("#ADVSRCH_SBAS_LABEL_" + sbas_id).removeClass("danger");
+ }
+
+ if(nbSelectedColls == 0) {
+ // no collections checked for this databox
+ // hide the status bits
+ $("#ADVSRCH_SB_ZONE_"+sbas_id, container).hide();
+ // uncheck
+ $("#ADVSRCH_SB_ZONE_"+sbas_id+" input:checkbox", container).prop("checked", false);
+ }
+ else {
+ // at least one coll checked for this databox
+ // show again the relevant fields in "sort by" select
+ $(".db_"+sbas_id, fieldsSort).show().prop("disabled", false);
+ // show again the relevant fields in "from fields" select
+ $(".db_"+sbas_id, fieldsSelect).show().prop("disabled", false);
+ // show the sb
+ $("#ADVSRCH_SB_ZONE_"+sbas_id, container).show();
+ // show again the relevant fields in "date field" select
+ $(".db_"+sbas_id, dateFilterSelect).show().prop("disabled", false);
+ }
+ });
+
+ if (nbTotalSelectedColls == 0) {
+ // no collections checked at all
+ // hide irrelevant filters
+ $("#ADVSRCH_OPTIONS_ZONE").hide();
+ }
+ else {
+ // at least one collection checked
+ // show relevant filters
+ $("#ADVSRCH_OPTIONS_ZONE").show();
+ }
+
+ // --------- sort --------
+
+ // if no field is selected for sort, select the default option
+ if($("option:selected:enabled", fieldsSort).length == 0) {
+ $("option.default-selection", fieldsSort).prop("selected", true);
+ $("option.default-selection", fieldsSortOrd).prop("selected", true);
+ }
+
+ search.elasticSort.by = $("option:selected:enabled", fieldsSort).val();
+ search.elasticSort.order = $("option:selected:enabled", fieldsSortOrd).val();
+
+ //--------- from fields filter ---------
+
+ // unselect the unavailable fields (or all fields if "all" is selected)
+ var optAllSelected = false;
+ $("option", fieldsSelect).each(
+ function(idx, opt) {
+ if(idx == 0) {
+ // nb: unselect the "all" field, so it acts as a button
+ optAllSelected = $(opt).is(":selected");
+ }
+ if(idx == 0 || optAllSelected || $(opt).is(":disabled") || !$(opt).is(":visible") ) {
+ $(opt).prop("selected", false);
+ }
+ }
+ );
+
+ // here only the relevant fields are selected
+ search.fields = fieldsSelect.val();
+ if(search.fields == null || search.fields.length == 0) {
+ $('#ADVSRCH_FIELDS_ZONE', container).removeClass('danger');
+ search.fields = [];
+ }
+ else {
+ $('#ADVSRCH_FIELDS_ZONE', container).addClass('danger');
+ danger = true;
+ }
+
+ //--------- status bits filter ---------
+
+ // here only the relevant sb are checked
+ for(sbas_id in search.bases) {
+ var nchecked = 0;
+ $("#ADVSRCH_SB_ZONE_"+sbas_id+" :checkbox[checked]", container).each(function () {
+ var n = $(this).attr('n');
+ search.status[n] = $(this).val().split('_');
+ nchecked++;
+ });
+ if(nchecked == 0) {
+ $("#ADVSRCH_SB_ZONE_"+sbas_id, container).removeClass('danger');
+ }
+ else {
+ $("#ADVSRCH_SB_ZONE_"+sbas_id, container).addClass('danger');
+ danger = true;
+ }
+ }
+
+ //--------- dates filter ---------
+
+ // if no date field is selected for filter, select the first option
+ $('#ADVSRCH_DATE_ZONE', adv_box).removeClass('danger');
+ if($("option.dbx:selected:enabled", dateFilterSelect).length == 0) {
+ $("option:eq(0)", dateFilterSelect).prop("selected", true);
+ $("#ADVSRCH_DATE_SELECTORS", container).hide();
+ }
+ else {
+ $("#ADVSRCH_DATE_SELECTORS", container).show();
+ search.dates.minbound = $('#ADVSRCH_DATE_ZONE input[name=date_min]', adv_box).val();
+ search.dates.maxbound = $('#ADVSRCH_DATE_ZONE input[name=date_max]', adv_box).val();
+ search.dates.field = $('#ADVSRCH_DATE_ZONE select[name=date_field]', adv_box).val();
+ console.log(search.dates.minbound, search.dates.maxbound, search.dates.field)
+ if ($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) {
+ danger = true;
+ $('#ADVSRCH_DATE_ZONE', adv_box).addClass('danger');
+ }
+ }
+
+ fieldsSelect.scrollTop(scroll);
+
+ // if one filter shows danger, show it on the query
+ if (danger) {
+ $('#EDIT_query').addClass('danger');
+ }
+ else {
+ $('#EDIT_query').removeClass('danger');
+ }
+
+ if (save === true) {
+ userModule.setPref('search', JSON.stringify(search));
+ }
+ }
+
+
+ return {
+ checkFilters: checkFilters,
+ toggleCollection: toggleCollection,
+ selectDatabase: selectDatabase,
+ beforeSearch: beforeSearch,
+ afterSearch: afterSearch,
+ clearAnswers: clearAnswers,
+ newSearch: newSearch
+ };
+}(p4));
diff --git a/resources/www/prod/js/components/utils.js b/resources/www/prod/js/components/utils.js
new file mode 100644
index 0000000000..63b7fd7a69
--- /dev/null
+++ b/resources/www/prod/js/components/utils.js
@@ -0,0 +1,65 @@
+var p4 = p4 || {};
+
+var utilsModule = (function (p4) {
+
+
+ function RGBtoHex(R, G, B) {
+ return toHex(R) + toHex(G) + toHex(B);
+ }
+ function toHex(N) {
+ if (N === null) return "00";
+ N = parseInt(N);
+ if (N === 0 || isNaN(N)) return "00";
+ N = Math.max(0, N);
+ N = Math.min(N, 255);
+ N = Math.round(N);
+ return "0123456789ABCDEF".charAt((N - N % 16) / 16)
+ + "0123456789ABCDEF".charAt(N % 16);
+ }
+ function hsl2rgb(h, s, l) {
+ var m1, m2, hue;
+ var r, g, b;
+ s /= 100;
+ l /= 100;
+ if (s === 0)
+ r = g = b = (l * 255);
+ else {
+ if (l <= 0.5)
+ m2 = l * (s + 1);
+ else
+ m2 = l + s - l * s;
+ m1 = l * 2 - m2;
+ hue = h / 360;
+ r = HueToRgb(m1, m2, hue + 1 / 3);
+ g = HueToRgb(m1, m2, hue);
+ b = HueToRgb(m1, m2, hue - 1 / 3);
+ }
+ return {
+ r: r,
+ g: g,
+ b: b
+ };
+ }
+
+ function HueToRgb(m1, m2, hue) {
+ var v;
+ if (hue < 0)
+ hue += 1;
+ else if (hue > 1)
+ hue -= 1;
+
+ if (6 * hue < 1)
+ v = m1 + (m2 - m1) * hue * 6;
+ else if (2 * hue < 1)
+ v = m2;
+ else if (3 * hue < 2)
+ v = m1 + (m2 - m1) * (2 / 3 - hue) * 6;
+ else
+ v = m1;
+
+ return 255 * v;
+ }
+ return {
+ RGBtoHex: RGBtoHex, hsl2rgb: hsl2rgb
+ };
+}(p4));
diff --git a/resources/www/prod/js/components/workzone-basket.js b/resources/www/prod/js/components/workzone-basket.js
new file mode 100644
index 0000000000..b92a6686f3
--- /dev/null
+++ b/resources/www/prod/js/components/workzone-basket.js
@@ -0,0 +1,102 @@
+var p4 = p4 || {};
+
+var workzoneBasketModule = (function (p4) {
+
+ function archiveBasket(basket_id) {
+ $.ajax({
+ type: "POST",
+ url: "../prod/baskets/" + basket_id + "/archive/?archive=1",
+ dataType: 'json',
+ beforeSend: function () {
+
+ },
+ success: function (data) {
+ if (data.success) {
+ var basket = $('#SSTT_' + basket_id);
+ var next = basket.next();
+
+ if (next.data("ui-droppable")) {
+ next.droppable('destroy');
+ }
+
+ next.slideUp().remove();
+
+ if (basket.data("ui-droppable")) {
+ basket.droppable('destroy');
+ }
+
+ basket.slideUp().remove();
+
+ if ($('#baskets .SSTT').length === 0) {
+ return p4.WorkZone.refresh(false);
+ }
+ }
+ else {
+ alert(data.message);
+ }
+ return;
+ }
+ });
+ }
+
+ function deleteBasket(item) {
+ if ($("#DIALOG").data("ui-dialog")) {
+ $("#DIALOG").dialog('destroy');
+ }
+
+ var k = $(item).attr('id').split('_').slice(1, 2).pop(); // id de chutier
+ $.ajax({
+ type: "POST",
+ url: "../prod/baskets/" + k + '/delete/',
+ dataType: 'json',
+ beforeSend: function () {
+
+ },
+ success: function (data) {
+ if (data.success) {
+ var basket = $('#SSTT_' + k);
+ var next = basket.next();
+
+ if (next.data("ui-droppable")) {
+ next.droppable('destroy');
+ }
+
+ next.slideUp().remove();
+
+ if (basket.data("ui-droppable")) {
+ basket.droppable('destroy');
+ }
+
+ basket.slideUp().remove();
+
+ if ($('#baskets .SSTT').length === 0) {
+ return p4.WorkZone.refresh(false);
+ }
+ }
+ else {
+ alert(data.message);
+ }
+ return;
+ }
+ });
+ }
+
+ function openBasketPreferences() {
+ $('#basket_preferences').dialog({
+ closeOnEscape: true,
+ resizable: false,
+ width: 450,
+ height: 500,
+ modal: true,
+ draggable: false,
+ overlay: {
+ backgroundColor: '#000',
+ opacity: 0.7
+ }
+ }).dialog('open');
+ }
+
+
+
+ return {archiveBasket: archiveBasket, deleteBasket: deleteBasket, openBasketPreferences: openBasketPreferences}
+})(p4);
\ No newline at end of file
diff --git a/resources/www/prod/js/components/workzone-facets.js b/resources/www/prod/js/components/workzone-facets.js
new file mode 100644
index 0000000000..177092a2e7
--- /dev/null
+++ b/resources/www/prod/js/components/workzone-facets.js
@@ -0,0 +1,162 @@
+var p4 = p4 || {};
+
+var workzoneFacetsModule = (function (p4) {
+ var selectedFacetValues = [];
+ var getSelectedFacets = function() {
+ return selectedFacetValues;
+ }
+ var resetSelectedFacets = function() {
+ selectedFacetValues = [];
+ return selectedFacetValues;
+ };
+ var loadFacets = function(facets) {
+ // Convert facets data to fancytree source format
+ var treeSource = _.map(facets, function(facet) {
+ // Values
+ var values = _.map(facet.values, function(value) {
+ return {
+ title: value.value + ' (' + value.count + ')',
+ query: value.query,
+ label: value.value,
+ tooltip: value.value + ' (' + value.count + ')'
+ }
+ });
+ // Facet
+ return {
+ name: facet.name,
+ title: facet.label,
+ folder: true,
+ children: values,
+ expanded: _.isUndefined(selectedFacetValues[facet.name])
+ };
+ });
+
+ treeSource.sort(_sortFacets('title', true, function(a){return a.toUpperCase()}));
+
+ treeSource = _sortByPredefinedFacets(treeSource, 'name', ['Base_Name', 'Collection_Name', 'Type_Name']);
+
+ return _getFacetsTree().reload(treeSource);
+ };
+
+ // from stackoverflow
+ // http://stackoverflow.com/questions/979256/sorting-an-array-of-javascript-objects/979325#979325
+ function _sortFacets(field, reverse, primer) {
+ var key = function (x) {return primer ? primer(x[field]) : x[field]};
+
+ return function (a,b) {
+ var A = key(a), B = key(b);
+ return ( (A < B) ? -1 : ((A > B) ? 1 : 0) ) * [-1,1][+!!reverse];
+ }
+ }
+
+ function _sortByPredefinedFacets(source, field, predefinedFieldOrder) {
+ var filteredSource = source,
+ ordered = [];
+
+ _.forEach(predefinedFieldOrder, function (fieldValue, index) {
+ _.forEach(source, function (facet, facetIndex) {
+ if (facet[field] !== undefined) {
+ if (facet[field] === fieldValue) {
+ ordered.push(facet);
+ // remove from filtered
+ filteredSource.splice(facetIndex, 1);
+ }
+ }
+ });
+ });
+
+ var olen = filteredSource.length;
+ // fill predefined facets with non predefined facets
+ for (var i = 0; i < olen; i++) {
+ ordered.push(filteredSource[i]);
+ }
+ return ordered;
+ }
+
+ function _getFacetsTree() {
+ var $facetsTree = $('#proposals');
+ if (!$facetsTree.data('ui-fancytree')) {
+ $facetsTree.fancytree({
+ clickFolderMode: 3, // activate and expand
+ icons:false,
+ source: [],
+ activate: function(event, data){
+ var query = data.node.data.query;
+ if (query) {
+ var facet = data.node.parent;
+ selectedFacetValues[facet.title] = data.node.data;
+ _facetCombinedSearch();
+ }
+ },
+ renderNode: function(event, data){
+ var facetFilter = "";
+ if(data.node.folder && !_.isUndefined(selectedFacetValues[data.node.title])) {
+ facetFilter = selectedFacetValues[data.node.title].label;
+
+ var s_label = document.createElement("SPAN");
+ s_label.setAttribute("class", "facetFilter-label");
+ s_label.setAttribute("title", facetFilter);
+
+ var length = 15;
+ var facetFilterString = facetFilter;
+ if( facetFilterString.length > length) {
+ facetFilterString = facetFilterString.substring(0,length) + '…';
+ }
+ s_label.appendChild(document.createTextNode(facetFilterString));
+
+ var s_closer = document.createElement("A");
+ s_closer.setAttribute("class", "facetFilter-closer");
+
+ var s_gradient = document.createElement("SPAN");
+ s_gradient.setAttribute("class", "facetFilter-gradient");
+ s_gradient.appendChild(document.createTextNode("\u00A0"));
+
+ s_label.appendChild(s_gradient);
+
+ var s_facet = document.createElement("SPAN");
+ s_facet.setAttribute("class", "facetFilter");
+ s_facet.appendChild(s_label);
+ s_closer = $(s_facet.appendChild(s_closer));
+ s_closer.data("facetTitle", data.node.title);
+
+ s_closer.click(
+ function(event) {
+ event.stopPropagation();
+ var facetTitle = $(this).data("facetTitle");
+ delete selectedFacetValues[facetTitle];
+ _facetCombinedSearch();
+ return false;
+ }
+ );
+
+ $(".fancytree-folder", data.node.li).append(
+ $(s_facet)
+ );
+ }
+ }
+ });
+
+ }
+ return $facetsTree.fancytree('getTree');
+ }
+
+ function _facetCombinedSearch() {
+ var q = $("#EDIT_query").val();
+ var q_facet = "";
+ _.each(_.values(selectedFacetValues), function(facetValue) {
+ q_facet += (q_facet ? " AND " : "") + '(' + facetValue.query + ')';
+ });
+ if(q_facet) {
+ if(q) {
+ q = '(' + q + ') AND '
+ }
+ q += q_facet;
+ }
+
+ searchModule.checkFilters();
+ searchModule.newSearch(q);
+ }
+
+ return { loadFacets: loadFacets, getSelectedFacets: getSelectedFacets, resetSelectedFacets: resetSelectedFacets}
+
+})(p4);
\ No newline at end of file
diff --git a/resources/www/prod/js/jquery.WorkZone.js b/resources/www/prod/js/components/workzone.js
similarity index 99%
rename from resources/www/prod/js/jquery.WorkZone.js
rename to resources/www/prod/js/components/workzone.js
index 3f90ffe930..f4b353366b 100644
--- a/resources/www/prod/js/jquery.WorkZone.js
+++ b/resources/www/prod/js/components/workzone.js
@@ -1,6 +1,6 @@
var p4 = p4 || {};
-(function (p4) {
+var workzoneModule = (function (p4) {
function refreshBaskets(baskId, sort, scrolltobottom, type) {
type = typeof type === 'undefined' ? 'basket' : type;
diff --git a/resources/www/prod/js/jquery.Alerts.js b/resources/www/prod/js/core/alert.js
similarity index 100%
rename from resources/www/prod/js/jquery.Alerts.js
rename to resources/www/prod/js/core/alert.js
diff --git a/resources/www/prod/js/jquery.lists.js b/resources/www/prod/js/core/lists.js
similarity index 100%
rename from resources/www/prod/js/jquery.lists.js
rename to resources/www/prod/js/core/lists.js
diff --git a/resources/www/prod/js/jquery.Selection.js b/resources/www/prod/js/core/selectable.js
similarity index 100%
rename from resources/www/prod/js/jquery.Selection.js
rename to resources/www/prod/js/core/selectable.js
diff --git a/resources/www/prod/js/jquery.form.2.49.js b/resources/www/prod/js/jquery.form.2.49.js
deleted file mode 100644
index 60e6cf0262..0000000000
--- a/resources/www/prod/js/jquery.form.2.49.js
+++ /dev/null
@@ -1,785 +0,0 @@
-/*!
- * jQuery Form Plugin
- * version: 2.49 (18-OCT-2010)
- * @requires jQuery v1.3.2 or later
- *
- * Examples and documentation at: http://malsup.com/jquery/form/
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- */
-;(function($) {
-
-/*
- Usage Note:
- -----------
- Do not use both ajaxSubmit and ajaxForm on the same form. These
- functions are intended to be exclusive. Use ajaxSubmit if you want
- to bind your own submit handler to the form. For example,
-
- $(document).ready(function() {
- $('#myForm').bind('submit', function(e) {
- e.preventDefault(); // <-- important
- $(this).ajaxSubmit({
- target: '#output'
- });
- });
- });
-
- Use ajaxForm when you want the plugin to manage all the event binding
- for you. For example,
-
- $(document).ready(function() {
- $('#myForm').ajaxForm({
- target: '#output'
- });
- });
-
- When using ajaxForm, the ajaxSubmit function will be invoked for you
- at the appropriate time.
-*/
-
-/**
- * ajaxSubmit() provides a mechanism for immediately submitting
- * an HTML form using AJAX.
- */
-$.fn.ajaxSubmit = function(options) {
- // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
- if (!this.length) {
- log('ajaxSubmit: skipping submit process - no element selected');
- return this;
- }
-
- if (typeof options == 'function') {
- options = { success: options };
- }
-
- var url = $.trim(this.attr('action'));
- if (url) {
- // clean url (don't include hash vaue)
- url = (url.match(/^([^#]+)/)||[])[1];
- }
- url = url || window.location.href || '';
-
- options = $.extend(true, {
- url: url,
- type: this.attr('method') || 'GET',
- iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
- }, options);
-
- // hook for manipulating the form data before it is extracted;
- // convenient for use with rich editors like tinyMCE or FCKEditor
- var veto = {};
- this.trigger('form-pre-serialize', [this, options, veto]);
- if (veto.veto) {
- log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
- return this;
- }
-
- // provide opportunity to alter form data before it is serialized
- if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
- log('ajaxSubmit: submit aborted via beforeSerialize callback');
- return this;
- }
-
- var n,v,a = this.formToArray(options.semantic);
- if (options.data) {
- options.extraData = options.data;
- for (n in options.data) {
- if(options.data[n] instanceof Array) {
- for (var k in options.data[n]) {
- a.push( { name: n, value: options.data[n][k] } );
- }
- }
- else {
- v = options.data[n];
- v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
- a.push( { name: n, value: v } );
- }
- }
- }
-
- // give pre-submit callback an opportunity to abort the submit
- if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
- log('ajaxSubmit: submit aborted via beforeSubmit callback');
- return this;
- }
-
- // fire vetoable 'validate' event
- this.trigger('form-submit-validate', [a, this, options, veto]);
- if (veto.veto) {
- log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
- return this;
- }
-
- var q = $.param(a);
-
- if (options.type.toUpperCase() == 'GET') {
- options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
- options.data = null; // data is null for 'get'
- }
- else {
- options.data = q; // data is the query string for 'post'
- }
-
- var $form = this, callbacks = [];
- if (options.resetForm) {
- callbacks.push(function() { $form.resetForm(); });
- }
- if (options.clearForm) {
- callbacks.push(function() { $form.clearForm(); });
- }
-
- // perform a load on the target only if dataType is not provided
- if (!options.dataType && options.target) {
- var oldSuccess = options.success || function(){};
- callbacks.push(function(data) {
- var fn = options.replaceTarget ? 'replaceWith' : 'html';
- $(options.target)[fn](data).each(oldSuccess, arguments);
- });
- }
- else if (options.success) {
- callbacks.push(options.success);
- }
-
- options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
- var context = options.context || options; // jQuery 1.4+ supports scope context
- for (var i=0, max=callbacks.length; i < max; i++) {
- callbacks[i].apply(context, [data, status, xhr || $form, $form]);
- }
- };
-
- // are there files to upload?
- var fileInputs = $('input:file', this).length > 0;
- var mp = 'multipart/form-data';
- var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
-
- // options.iframe allows user to force iframe mode
- // 06-NOV-09: now defaulting to iframe mode if file input is detected
- if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
- // hack to fix Safari hang (thanks to Tim Molendijk for this)
- // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
- if (options.closeKeepAlive) {
- $.get(options.closeKeepAlive, fileUpload);
- }
- else {
- fileUpload();
- }
- }
- else {
- $.ajax(options);
- }
-
- // fire 'notify' event
- this.trigger('form-submit-notify', [this, options]);
- return this;
-
-
- // private function for handling file uploads (hat tip to YAHOO!)
- function fileUpload() {
- var form = $form[0];
-
- if ($(':input[name=submit],:input[id=submit]', form).length) {
- // if there is an input with a name or id of 'submit' then we won't be
- // able to invoke the submit fn on the form (at least not x-browser)
- alert('Error: Form elements must not have name or id of "submit".');
- return;
- }
-
- var s = $.extend(true, {}, $.ajaxSettings, options);
- s.context = s.context || s;
- var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
- window[fn] = function() {
- var f = $io.data('form-plugin-onload');
- if (f) {
- f();
- window[fn] = undefined;
- try { delete window[fn]; } catch(e){}
- }
- }
- var $io = $('');
- var io = $io[0];
-
- $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
-
- var xhr = { // mock object
- aborted: 0,
- responseText: null,
- responseXML: null,
- status: 0,
- statusText: 'n/a',
- getAllResponseHeaders: function() {},
- getResponseHeader: function() {},
- setRequestHeader: function() {},
- abort: function() {
- this.aborted = 1;
- $io.attr('src', s.iframeSrc); // abort op in progress
- }
- };
-
- var g = s.global;
- // trigger ajax global events so that activity/block indicators work like normal
- if (g && ! $.active++) {
- $.event.trigger("ajaxStart");
- }
- if (g) {
- $.event.trigger("ajaxSend", [xhr, s]);
- }
-
- if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
- if (s.global) {
- $.active--;
- }
- return;
- }
- if (xhr.aborted) {
- return;
- }
-
- var cbInvoked = false;
- var timedOut = 0;
-
- // add submitting element to data if we know it
- var sub = form.clk;
- if (sub) {
- var n = sub.name;
- if (n && !sub.disabled) {
- s.extraData = s.extraData || {};
- s.extraData[n] = sub.value;
- if (sub.type == "image") {
- s.extraData[n+'.x'] = form.clk_x;
- s.extraData[n+'.y'] = form.clk_y;
- }
- }
- }
-
- // take a breath so that pending repaints get some cpu time before the upload starts
- function doSubmit() {
- // make sure form attrs are set
- var t = $form.attr('target'), a = $form.attr('action');
-
- // update form attrs in IE friendly way
- form.setAttribute('target',id);
- if (form.getAttribute('method') != 'POST') {
- form.setAttribute('method', 'POST');
- }
- if (form.getAttribute('action') != s.url) {
- form.setAttribute('action', s.url);
- }
-
- // ie borks in some cases when setting encoding
- if (! s.skipEncodingOverride) {
- $form.attr({
- encoding: 'multipart/form-data',
- enctype: 'multipart/form-data'
- });
- }
-
- // support timout
- if (s.timeout) {
- setTimeout(function() { timedOut = true; cb(); }, s.timeout);
- }
-
- // add "extra" data to form if provided in options
- var extraInputs = [];
- try {
- if (s.extraData) {
- for (var n in s.extraData) {
- extraInputs.push(
- $('')
- .appendTo(form)[0]);
- }
- }
-
- // add iframe to doc and submit the form
- $io.appendTo('body');
- $io.data('form-plugin-onload', cb);
- form.submit();
- }
- finally {
- // reset attrs and remove "extra" input elements
- form.setAttribute('action',a);
- if(t) {
- form.setAttribute('target', t);
- } else {
- $form.removeAttr('target');
- }
- $(extraInputs).remove();
- }
- }
-
- if (s.forceSync) {
- doSubmit();
- }
- else {
- setTimeout(doSubmit, 10); // this lets dom updates render
- }
-
- var data, doc, domCheckCount = 50;
-
- function cb() {
- if (cbInvoked) {
- return;
- }
-
- $io.removeData('form-plugin-onload');
-
- var ok = true;
- try {
- if (timedOut) {
- throw 'timeout';
- }
- // extract the server response from the iframe
- doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
-
- var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
- log('isXml='+isXml);
- if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
- if (--domCheckCount) {
- // in some browsers (Opera) the iframe DOM is not always traversable when
- // the onload callback fires, so we loop a bit to accommodate
- log('requeing onLoad callback, DOM not available');
- setTimeout(cb, 250);
- return;
- }
- // let this fall through because server response could be an empty document
- //log('Could not access iframe DOM after mutiple tries.');
- //throw 'DOMException: not available';
- }
-
- //log('response detected');
- cbInvoked = true;
- xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
- xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
- xhr.getResponseHeader = function(header){
- var headers = {'content-type': s.dataType};
- return headers[header];
- };
-
- var scr = /(json|script)/.test(s.dataType);
- if (scr || s.textarea) {
- // see if user embedded response in textarea
- var ta = doc.getElementsByTagName('textarea')[0];
- if (ta) {
- xhr.responseText = ta.value;
- }
- else if (scr) {
- // account for browsers injecting pre around json response
- var pre = doc.getElementsByTagName('pre')[0];
- var b = doc.getElementsByTagName('body')[0];
- if (pre) {
- xhr.responseText = pre.innerHTML;
- }
- else if (b) {
- xhr.responseText = b.innerHTML;
- }
- }
- }
- else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
- xhr.responseXML = toXml(xhr.responseText);
- }
- data = $.httpData(xhr, s.dataType);
- }
- catch(e){
- log('error caught:',e);
- ok = false;
- xhr.error = e;
- $.handleError(s, xhr, 'error', e);
- }
-
- // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
- if (ok) {
- s.success.call(s.context, data, 'success', xhr);
- if (g) {
- $.event.trigger("ajaxSuccess", [xhr, s]);
- }
- }
- if (g) {
- $.event.trigger("ajaxComplete", [xhr, s]);
- }
- if (g && ! --$.active) {
- $.event.trigger("ajaxStop");
- }
- if (s.complete) {
- s.complete.call(s.context, xhr, ok ? 'success' : 'error');
- }
-
- // clean up
- setTimeout(function() {
- $io.removeData('form-plugin-onload');
- $io.remove();
- xhr.responseXML = null;
- }, 100);
- }
-
- function toXml(s, doc) {
- if (window.ActiveXObject) {
- doc = new ActiveXObject('Microsoft.XMLDOM');
- doc.async = 'false';
- doc.loadXML(s);
- }
- else {
- doc = (new DOMParser()).parseFromString(s, 'text/xml');
- }
- return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
- }
- }
-};
-
-/**
- * ajaxForm() provides a mechanism for fully automating form submission.
- *
- * The advantages of using this method instead of ajaxSubmit() are:
- *
- * 1: This method will include coordinates for elements (if the element
- * is used to submit the form).
- * 2. This method will include the submit element's name/value data (for the element that was
- * used to submit the form).
- * 3. This method binds the submit() method to the form for you.
- *
- * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
- * passes the options argument along after properly binding events for submit elements and
- * the form itself.
- */
-$.fn.ajaxForm = function(options) {
- // in jQuery 1.3+ we can fix mistakes with the ready state
- if (this.length === 0) {
- var o = { s: this.selector, c: this.context };
- if (!$.isReady && o.s) {
- log('DOM not ready, queuing ajaxForm');
- $(function() {
- $(o.s,o.c).ajaxForm(options);
- });
- return this;
- }
- // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
- log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
- return this;
- }
-
- return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
- if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
- e.preventDefault();
- $(this).ajaxSubmit(options);
- }
- }).bind('click.form-plugin', function(e) {
- var target = e.target;
- var $el = $(target);
- if (!($el.is(":submit,input:image"))) {
- // is this a child element of the submit el? (ex: a span within a button)
- var t = $el.closest(':submit');
- if (t.length == 0) {
- return;
- }
- target = t[0];
- }
- var form = this;
- form.clk = target;
- if (target.type == 'image') {
- if (e.offsetX != undefined) {
- form.clk_x = e.offsetX;
- form.clk_y = e.offsetY;
- } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
- var offset = $el.offset();
- form.clk_x = e.pageX - offset.left;
- form.clk_y = e.pageY - offset.top;
- } else {
- form.clk_x = e.pageX - target.offsetLeft;
- form.clk_y = e.pageY - target.offsetTop;
- }
- }
- // clear form vars
- setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
- });
-};
-
-// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
-$.fn.ajaxFormUnbind = function() {
- return this.unbind('submit.form-plugin click.form-plugin');
-};
-
-/**
- * formToArray() gathers form element data into an array of objects that can
- * be passed to any of the following ajax functions: $.get, $.post, or load.
- * Each object in the array has both a 'name' and 'value' property. An example of
- * an array for a simple login form might be:
- *
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
- *
- * It is this array that is passed to pre-submit callback functions provided to the
- * ajaxSubmit() and ajaxForm() methods.
- */
-$.fn.formToArray = function(semantic) {
- var a = [];
- if (this.length === 0) {
- return a;
- }
-
- var form = this[0];
- var els = semantic ? form.getElementsByTagName('*') : form.elements;
- if (!els) {
- return a;
- }
-
- var i,j,n,v,el,max,jmax;
- for(i=0, max=els.length; i < max; i++) {
- el = els[i];
- n = el.name;
- if (!n) {
- continue;
- }
-
- if (semantic && form.clk && el.type == "image") {
- // handle image inputs on the fly when semantic == true
- if(!el.disabled && form.clk == el) {
- a.push({name: n, value: $(el).val()});
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- }
- continue;
- }
-
- v = $.fieldValue(el, true);
- if (v && v.constructor == Array) {
- for(j=0, jmax=v.length; j < jmax; j++) {
- a.push({name: n, value: v[j]});
- }
- }
- else if (v !== null && typeof v != 'undefined') {
- a.push({name: n, value: v});
- }
- }
-
- if (!semantic && form.clk) {
- // input type=='image' are not found in elements array! handle it here
- var $input = $(form.clk), input = $input[0];
- n = input.name;
- if (n && !input.disabled && input.type == 'image') {
- a.push({name: n, value: $input.val()});
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- }
- }
- return a;
-};
-
-/**
- * Serializes form data into a 'submittable' string. This method will return a string
- * in the format: name1=value1&name2=value2
- */
-$.fn.formSerialize = function(semantic) {
- //hand off to jQuery.param for proper encoding
- return $.param(this.formToArray(semantic));
-};
-
-/**
- * Serializes all field elements in the jQuery object into a query string.
- * This method will return a string in the format: name1=value1&name2=value2
- */
-$.fn.fieldSerialize = function(successful) {
- var a = [];
- this.each(function() {
- var n = this.name;
- if (!n) {
- return;
- }
- var v = $.fieldValue(this, successful);
- if (v && v.constructor == Array) {
- for (var i=0,max=v.length; i < max; i++) {
- a.push({name: n, value: v[i]});
- }
- }
- else if (v !== null && typeof v != 'undefined') {
- a.push({name: this.name, value: v});
- }
- });
- //hand off to jQuery.param for proper encoding
- return $.param(a);
-};
-
-/**
- * Returns the value(s) of the element in the matched set. For example, consider the following form:
- *
- *
- *
- * var v = $(':text').fieldValue();
- * // if no values are entered into the text inputs
- * v == ['','']
- * // if values entered into the text inputs are 'foo' and 'bar'
- * v == ['foo','bar']
- *
- * var v = $(':checkbox').fieldValue();
- * // if neither checkbox is checked
- * v === undefined
- * // if both checkboxes are checked
- * v == ['B1', 'B2']
- *
- * var v = $(':radio').fieldValue();
- * // if neither radio is checked
- * v === undefined
- * // if first radio is checked
- * v == ['C1']
- *
- * The successful argument controls whether or not the field element must be 'successful'
- * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
- * The default value of the successful argument is true. If this value is false the value(s)
- * for each element is returned.
- *
- * Note: This method *always* returns an array. If no valid value can be determined the
- * array will be empty, otherwise it will contain one or more values.
- */
-$.fn.fieldValue = function(successful) {
- for (var val=[], i=0, max=this.length; i < max; i++) {
- var el = this[i];
- var v = $.fieldValue(el, successful);
- if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
- continue;
- }
- v.constructor == Array ? $.merge(val, v) : val.push(v);
- }
- return val;
-};
-
-/**
- * Returns the value of the field element.
- */
-$.fieldValue = function(el, successful) {
- var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
- if (successful === undefined) {
- successful = true;
- }
-
- if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
- (t == 'checkbox' || t == 'radio') && !el.checked ||
- (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
- tag == 'select' && el.selectedIndex == -1)) {
- return null;
- }
-
- if (tag == 'select') {
- var index = el.selectedIndex;
- if (index < 0) {
- return null;
- }
- var a = [], ops = el.options;
- var one = (t == 'select-one');
- var max = (one ? index+1 : ops.length);
- for(var i=(one ? index : 0); i < max; i++) {
- var op = ops[i];
- if (op.selected) {
- var v = op.value;
- if (!v) { // extra pain for IE...
- v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
- }
- if (one) {
- return v;
- }
- a.push(v);
- }
- }
- return a;
- }
- return $(el).val();
-};
-
-/**
- * Clears the form data. Takes the following actions on the form's input fields:
- * - input text fields will have their 'value' property set to the empty string
- * - select elements will have their 'selectedIndex' property set to -1
- * - checkbox and radio inputs will have their 'checked' property set to false
- * - inputs of type submit, button, reset, and hidden will *not* be effected
- * - button elements will *not* be effected
- */
-$.fn.clearForm = function() {
- return this.each(function() {
- $('input,select,textarea', this).clearFields();
- });
-};
-
-/**
- * Clears the selected form elements.
- */
-$.fn.clearFields = $.fn.clearInputs = function() {
- return this.each(function() {
- var t = this.type, tag = this.tagName.toLowerCase();
- if (t == 'text' || t == 'password' || tag == 'textarea') {
- this.value = '';
- }
- else if (t == 'checkbox' || t == 'radio') {
- this.checked = false;
- }
- else if (tag == 'select') {
- this.selectedIndex = -1;
- }
- });
-};
-
-/**
- * Resets the form data. Causes all form elements to be reset to their original value.
- */
-$.fn.resetForm = function() {
- return this.each(function() {
- // guard against an input with the name of 'reset'
- // note that IE reports the reset function as an 'object'
- if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
- this.reset();
- }
- });
-};
-
-/**
- * Enables or disables any matching elements.
- */
-$.fn.enable = function(b) {
- if (b === undefined) {
- b = true;
- }
- return this.each(function() {
- this.disabled = !b;
- });
-};
-
-/**
- * Checks/unchecks any matching checkboxes or radio buttons and
- * selects/deselects and matching option elements.
- */
-$.fn.selected = function(select) {
- if (select === undefined) {
- select = true;
- }
- return this.each(function() {
- var t = this.type;
- if (t == 'checkbox' || t == 'radio') {
- this.checked = select;
- }
- else if (this.tagName.toLowerCase() == 'option') {
- var $sel = $(this).parent('select');
- if (select && $sel[0] && $sel[0].type == 'select-one') {
- // deselect all other options
- $sel.find('option').selected(false);
- }
- this.selected = select;
- }
- });
-};
-
-// helper fn for console logging
-// set $.fn.ajaxSubmit.debug to true to enable debug logging
-function log() {
- if ($.fn.ajaxSubmit.debug) {
- var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
- if (window.console && window.console.log) {
- window.console.log(msg);
- }
- else if (window.opera && window.opera.postError) {
- window.opera.postError(msg);
- }
- }
-};
-
-})(jQuery);
diff --git a/resources/www/prod/js/jquery.main-prod.js b/resources/www/prod/js/jquery.main-prod.js
index 6bf25e01e1..4671fdb171 100644
--- a/resources/www/prod/js/jquery.main-prod.js
+++ b/resources/www/prod/js/jquery.main-prod.js
@@ -28,8 +28,8 @@ function getHome(cas, page) {
switch (cas) {
case 'QUERY':
- selectedFacetValues = [];
- newSearch($("#EDIT_query").val());
+ workzoneFacetsModule.resetSelectedFacets();
+ searchModule.newSearch($("#EDIT_query").val());
break;
case 'PUBLI':
publicationModule.fetchPublications(page, answAjax, answAjaxrunning);
@@ -45,7 +45,7 @@ function getHome(cas, page) {
beforeSend: function () {
if (answAjaxrunning && answAjax.abort)
answAjax.abort();
- clearAnswers();
+ searchModule.clearAnswers();
answAjaxrunning = true;
$('#answers').addClass('loading');
},
@@ -60,7 +60,7 @@ function getHome(cas, page) {
success: function (data) {
answAjaxrunning = false;
$('#answers').append(data);
- afterSearch();
+ searchModule.afterSearch();
return;
}
@@ -123,203 +123,24 @@ function checkBases(bool) {
$(this).find(':checkbox').prop('checked', false);
});
- checkFilters(true);
+ searchModule.checkFilters(true);
}
-function checkFilters(save) {
- var danger = false;
- var search = {
- bases: {},
- fields: [],
- dates: {},
- status: [],
- elasticSort: {}
- };
- var adv_box = $('form.phrasea_query .adv_options');
- var container = $("#ADVSRCH_OPTIONS_ZONE");
- var fieldsSort = $('#ADVSRCH_SORT_ZONE select[name=sort]', container);
- var fieldsSortOrd = $('#ADVSRCH_SORT_ZONE select[name=ord]', container);
- var fieldsSelect = $('#ADVSRCH_FIELDS_ZONE select', container);
- var dateFilterSelect = $('#ADVSRCH_DATE_ZONE select', container);
- var scroll = fieldsSelect.scrollTop();
-
- // hide all the fields in the "sort by" select, so only the relevant ones will be shown again
- $("option.dbx", fieldsSort).hide().prop("disabled", true); // dbx is for "field of databases"
-
- // hide all the fields in the "fields" select, so only the relevant ones will be shown again
- $("option.dbx", fieldsSelect).hide().prop("disabled", true); // option[0] is "all fields"
-
- // hide all the fields in the "date field" select, so only the relevant ones will be shown again
- $("option.dbx", dateFilterSelect).hide().prop("disabled", true); // dbx = all "field" entries in the select = all except the firstt
-
- var nbTotalSelectedColls = 0;
- $.each($('.sbascont', adv_box), function () {
- var $this = $(this);
-
- var sbas_id = $this.parent().find('input[name="reference"]').val();
- search.bases[sbas_id] = [];
-
- var nbCols = 0;
- var nbSelectedColls = 0;
- $this.find('.checkbas').each(function (idx, el) {
- nbCols++;
- if($(this).prop('checked')) {
- nbSelectedColls++;
- nbTotalSelectedColls++;
- search.bases[sbas_id].push($(this).val());
- }
- });
-
- // display the number of selected colls for the databox
- $('.infos_sbas_' + sbas_id).empty().append(nbSelectedColls + '/' + nbCols);
-
- // if one coll is not checked, show danger
- if(nbSelectedColls != nbCols) {
- $("#ADVSRCH_SBAS_LABEL_" + sbas_id).addClass("danger");
- danger = true;
- }
- else {
- $("#ADVSRCH_SBAS_LABEL_" + sbas_id).removeClass("danger");
- }
-
- if(nbSelectedColls == 0) {
- // no collections checked for this databox
- // hide the status bits
- $("#ADVSRCH_SB_ZONE_"+sbas_id, container).hide();
- // uncheck
- $("#ADVSRCH_SB_ZONE_"+sbas_id+" input:checkbox", container).prop("checked", false);
- }
- else {
- // at least one coll checked for this databox
- // show again the relevant fields in "sort by" select
- $(".db_"+sbas_id, fieldsSort).show().prop("disabled", false);
- // show again the relevant fields in "from fields" select
- $(".db_"+sbas_id, fieldsSelect).show().prop("disabled", false);
- // show the sb
- $("#ADVSRCH_SB_ZONE_"+sbas_id, container).show();
- // show again the relevant fields in "date field" select
- $(".db_"+sbas_id, dateFilterSelect).show().prop("disabled", false);
- }
- });
-
- if (nbTotalSelectedColls == 0) {
- // no collections checked at all
- // hide irrelevant filters
- $("#ADVSRCH_OPTIONS_ZONE").hide();
- }
- else {
- // at least one collection checked
- // show relevant filters
- $("#ADVSRCH_OPTIONS_ZONE").show();
- }
-
- // --------- sort --------
-
- // if no field is selected for sort, select the default option
- if($("option:selected:enabled", fieldsSort).length == 0) {
- $("option.default-selection", fieldsSort).prop("selected", true);
- $("option.default-selection", fieldsSortOrd).prop("selected", true);
- }
-
- search.elasticSort.by = $("option:selected:enabled", fieldsSort).val();
- search.elasticSort.order = $("option:selected:enabled", fieldsSortOrd).val();
-
- //--------- from fields filter ---------
-
- // unselect the unavailable fields (or all fields if "all" is selected)
- var optAllSelected = false;
- $("option", fieldsSelect).each(
- function(idx, opt) {
- if(idx == 0) {
- // nb: unselect the "all" field, so it acts as a button
- optAllSelected = $(opt).is(":selected");
- }
- if(idx == 0 || optAllSelected || $(opt).is(":disabled") || !$(opt).is(":visible") ) {
- $(opt).prop("selected", false);
- }
- }
- );
-
- // here only the relevant fields are selected
- search.fields = fieldsSelect.val();
- if(search.fields == null || search.fields.length == 0) {
- $('#ADVSRCH_FIELDS_ZONE', container).removeClass('danger');
- search.fields = [];
- }
- else {
- $('#ADVSRCH_FIELDS_ZONE', container).addClass('danger');
- danger = true;
- }
-
- //--------- status bits filter ---------
-
- // here only the relevant sb are checked
- for(sbas_id in search.bases) {
- var nchecked = 0;
- $("#ADVSRCH_SB_ZONE_"+sbas_id+" :checkbox[checked]", container).each(function () {
- var n = $(this).attr('n');
- search.status[n] = $(this).val().split('_');
- nchecked++;
- });
- if(nchecked == 0) {
- $("#ADVSRCH_SB_ZONE_"+sbas_id, container).removeClass('danger');
- }
- else {
- $("#ADVSRCH_SB_ZONE_"+sbas_id, container).addClass('danger');
- danger = true;
- }
- }
-
- //--------- dates filter ---------
-
- // if no date field is selected for filter, select the first option
- $('#ADVSRCH_DATE_ZONE', adv_box).removeClass('danger');
- if($("option.dbx:selected:enabled", dateFilterSelect).length == 0) {
- $("option:eq(0)", dateFilterSelect).prop("selected", true);
- $("#ADVSRCH_DATE_SELECTORS", container).hide();
- }
- else {
- $("#ADVSRCH_DATE_SELECTORS", container).show();
- search.dates.minbound = $('#ADVSRCH_DATE_ZONE input[name=date_min]', adv_box).val();
- search.dates.maxbound = $('#ADVSRCH_DATE_ZONE input[name=date_max]', adv_box).val();
- search.dates.field = $('#ADVSRCH_DATE_ZONE select[name=date_field]', adv_box).val();
- console.log(search.dates.minbound, search.dates.maxbound, search.dates.field)
- if ($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) {
- danger = true;
- $('#ADVSRCH_DATE_ZONE', adv_box).addClass('danger');
- }
- }
-
- fieldsSelect.scrollTop(scroll);
-
- // if one filter shows danger, show it on the query
- if (danger) {
- $('#EDIT_query').addClass('danger');
- }
- else {
- $('#EDIT_query').removeClass('danger');
- }
-
- if (save === true) {
- setPref('search', JSON.stringify(search));
- }
-}
-
-function toggleFilter(filter, ele) {
+/* 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');
-}
+}*/
-function setVisible(el) {
+/* NOT USED function setVisible(el) {
el.style.visibility = 'visible';
-}
+}*/
function resize() {
var body = $('#mainContainer');
@@ -348,11 +169,7 @@ function resize() {
}
-function clearAnswers() {
- $('#formAnswerPage').val('');
- $('#searchForm input[name="nba"]').val('');
- $('#answers, #dyn_tool').empty();
-}
+
function reset_adv_search() {
var container = $("#ADVSRCH_OPTIONS_ZONE");
@@ -373,113 +190,23 @@ function reset_adv_search() {
}
function search_doubles() {
- selectedFacetValues = [];
+ workzoneFacetsModule.resetSelectedFacets();
$('#EDIT_query').val('sha256=sha256');
- newSearch('sha256=sha256');
+ searchModule.newSearch('sha256=sha256');
}
-function newSearch(query) {
- p4.Results.Selection.empty();
- clearAnswers();
- $('#SENT_query').val(query);
- var histo = $('#history-queries ul');
- histo.prepend('' + query + '');
- var lis = $('li', histo);
- if (lis.length > 25) {
- $('li:last', histo).remove();
- }
- $('#idFrameC li.proposals_WZ').removeClass('active');
- $('#searchForm').submit();
- return false;
-}
-
-function beforeSearch() {
- if (answAjaxrunning)
- return;
- answAjaxrunning = true;
-
- clearAnswers();
- $('#tooltip').css({
- 'display': 'none'
- });
- $('#answers').addClass('loading').empty();
- $('#answercontextwrap').remove();
-}
-
-function afterSearch() {
- if ($('#answercontextwrap').length === 0)
- $('body').append('');
-
- $.each($('#answers .contextMenuTrigger'), function () {
-
- var id = $(this).closest('.IMGT').attr('id').split('_').slice(1, 3).join('_');
-
- $(this).contextMenu('#IMGT_' + id + ' .answercontextmenu', {
- appendTo: '#answercontextwrap',
- openEvt: 'click',
- dropDown: true,
- theme: 'vista',
- showTransition: 'slideDown',
- hideTransition: 'hide',
- shadow: false
- });
- });
-
- answAjaxrunning = false;
- $('#answers').removeClass('loading');
- $('.captionTips, .captionRolloverTips').tooltip({
- delay: 0,
- isBrowsable: false,
- extraClass: 'caption-tooltip-container'
- });
- $('.infoTips').tooltip({
- delay: 0
- });
- $('.previewTips').tooltip({
- fixable: true
- });
- $('.thumb .rollovable').hover(
- function () {
- $('.rollover-gif-hover', this).show();
- $('.rollover-gif-out', this).hide();
- },
- function () {
- $('.rollover-gif-hover', this).hide();
- $('.rollover-gif-out', this).show();
- }
- );
- viewNbSelect();
- $('#answers div.IMGT').draggable({
- helper: function () {
- $('body').append('' + p4.Results.Selection.length() + '
');
- return $('#dragDropCursor');
- },
- scope: "objects",
- distance: 20,
- scroll: false,
- cursorAt: {
- top: -10,
- left: -20
- },
- start: function (event, ui) {
- if (!$(this).hasClass('selected'))
- return false;
- }
- });
- linearize();
-}
function initAnswerForm() {
var searchForm = $('#searchForm');
$('button[type="submit"]', searchForm).bind('click', function () {
- selectedFacetValues = [];
- newSearch($("#EDIT_query").val());
+ workzoneFacetsModule.resetSelectedFacets();
+ searchModule.newSearch($("#EDIT_query").val());
return false;
});
@@ -498,7 +225,7 @@ function initAnswerForm() {
beforeSend: function (formData) {
if (answAjaxrunning && answAjax.abort)
answAjax.abort();
- beforeSearch();
+ searchModule.beforeSearch();
},
error: function () {
answAjaxrunning = false;
@@ -522,7 +249,7 @@ function initAnswerForm() {
container: $('#answers')
});
- loadFacets(datas.facets);
+ workzoneFacetsModule.loadFacets(datas.facets);
$('#answers').append('');
@@ -556,7 +283,7 @@ function initAnswerForm() {
$("#PREV_PAGE").unbind('click');
}
- afterSearch();
+ searchModule.afterSearch();
}
});
return false;
@@ -566,155 +293,16 @@ function initAnswerForm() {
}
}
-var selectedFacetValues = [];
-function loadFacets(facets) {
- // Convert facets data to fancytree source format
- var treeSource = _.map(facets, function(facet) {
- // Values
- var values = _.map(facet.values, function(value) {
- return {
- title: value.value + ' (' + value.count + ')',
- query: value.query,
- label: value.value,
- tooltip: value.value + ' (' + value.count + ')'
- }
- });
- // Facet
- return {
- name: facet.name,
- title: facet.label,
- folder: true,
- children: values,
- expanded: _.isUndefined(selectedFacetValues[facet.name])
- };
- });
- treeSource.sort(sortFacets('title', true, function(a){return a.toUpperCase()}));
- treeSource = sortByPredefinedFacets(treeSource, 'name', ['Base_Name', 'Collection_Name', 'Type_Name']);
- return getFacetsTree().reload(treeSource);
-}
-function sortByPredefinedFacets(source, field, predefinedFieldOrder) {
- var filteredSource = source,
- ordered = [];
- _.forEach(predefinedFieldOrder, function (fieldValue, index) {
- _.forEach(source, function (facet, facetIndex) {
- if (facet[field] !== undefined) {
- if (facet[field] === fieldValue) {
- ordered.push(facet);
- // remove from filtered
- filteredSource.splice(facetIndex, 1);
- }
- }
- });
- });
- var olen = filteredSource.length;
- // fill predefined facets with non predefined facets
- for (var i = 0; i < olen; i++) {
- ordered.push(filteredSource[i]);
- }
- return ordered;
-}
-// from stackoverflow
-// http://stackoverflow.com/questions/979256/sorting-an-array-of-javascript-objects/979325#979325
-function sortFacets(field, reverse, primer) {
- var key = function (x) {return primer ? primer(x[field]) : x[field]};
- return function (a,b) {
- var A = key(a), B = key(b);
- return ( (A < B) ? -1 : ((A > B) ? 1 : 0) ) * [-1,1][+!!reverse];
- }
-}
-function getFacetsTree() {
- var $facetsTree = $('#proposals');
- if (!$facetsTree.data('ui-fancytree')) {
- $facetsTree.fancytree({
- clickFolderMode: 3, // activate and expand
- icons:false,
- source: [],
- activate: function(event, data){
- var query = data.node.data.query;
- if (query) {
- var facet = data.node.parent;
- selectedFacetValues[facet.title] = data.node.data;
- facetCombinedSearch();
- }
- },
- renderNode: function(event, data){
- var facetFilter = "";
- if(data.node.folder && !_.isUndefined(selectedFacetValues[data.node.title])) {
- facetFilter = selectedFacetValues[data.node.title].label;
-
- var s_label = document.createElement("SPAN");
- s_label.setAttribute("class", "facetFilter-label");
- s_label.setAttribute("title", facetFilter);
-
- var length = 15;
- var facetFilterString = facetFilter;
- if( facetFilterString.length > length) {
- facetFilterString = facetFilterString.substring(0,length) + '…';
- }
- s_label.appendChild(document.createTextNode(facetFilterString));
-
- var s_closer = document.createElement("A");
- s_closer.setAttribute("class", "facetFilter-closer");
-
- var s_gradient = document.createElement("SPAN");
- s_gradient.setAttribute("class", "facetFilter-gradient");
- s_gradient.appendChild(document.createTextNode("\u00A0"));
-
- s_label.appendChild(s_gradient);
-
- var s_facet = document.createElement("SPAN");
- s_facet.setAttribute("class", "facetFilter");
- s_facet.appendChild(s_label);
- s_closer = $(s_facet.appendChild(s_closer));
- s_closer.data("facetTitle", data.node.title);
-
- s_closer.click(
- function(event) {
- event.stopPropagation();
- var facetTitle = $(this).data("facetTitle");
- delete selectedFacetValues[facetTitle];
- facetCombinedSearch();
- return false;
- }
- );
-
- $(".fancytree-folder", data.node.li).append(
- $(s_facet)
- );
- }
- }
- });
-
- }
- return $facetsTree.fancytree('getTree');
-}
-
-function facetCombinedSearch() {
- var q = $("#EDIT_query").val();
- var q_facet = "";
- _.each(_.values(selectedFacetValues), function(facetValue) {
- q_facet += (q_facet ? " AND " : "") + '(' + facetValue.query + ')';
- });
- if(q_facet) {
- if(q) {
- q = '(' + q + ') AND '
- }
- q += q_facet;
- }
-
- checkFilters();
- newSearch(q);
-}
@@ -779,7 +367,7 @@ function initLook() {
$('#nperpage_value').val(ui.value);
},
stop: function (event, ui) {
- setPref('images_per_page', $('#nperpage_value').val());
+ userModule.setPref('images_per_page', $('#nperpage_value').val());
}
});
$('#sizeAns_slider').slider({
@@ -791,13 +379,13 @@ function initLook() {
$('#sizeAns_value').val(ui.value);
},
stop: function (event, ui) {
- setPref('images_size', $('#sizeAns_value').val());
+ userModule.setPref('images_size', $('#sizeAns_value').val());
}
});
}
function acceptCgus(name, value) {
- setPref(name, value);
+ userModule.setPref(name, value);
}
function cancelCgus(id) {
@@ -856,7 +444,7 @@ function triggerShortcuts() {
$('#keyboard-stop').bind('click', function () {
var display = $(this).get(0).checked ? '0' : '1';
- setPref('keyboard_infos', display);
+ userModule.setPref('keyboard_infos', display);
});
@@ -910,62 +498,8 @@ function activeZoning() {
$('#rightFrame').trigger('mousedown');
}
-function RGBtoHex(R, G, B) {
- return toHex(R) + toHex(G) + toHex(B);
-}
-function toHex(N) {
- if (N === null) return "00";
- N = parseInt(N);
- if (N === 0 || isNaN(N)) return "00";
- N = Math.max(0, N);
- N = Math.min(N, 255);
- N = Math.round(N);
- return "0123456789ABCDEF".charAt((N - N % 16) / 16)
- + "0123456789ABCDEF".charAt(N % 16);
-}
-function hsl2rgb(h, s, l) {
- var m1, m2, hue;
- var r, g, b;
- s /= 100;
- l /= 100;
- if (s === 0)
- r = g = b = (l * 255);
- else {
- if (l <= 0.5)
- m2 = l * (s + 1);
- else
- m2 = l + s - l * s;
- m1 = l * 2 - m2;
- hue = h / 360;
- r = HueToRgb(m1, m2, hue + 1 / 3);
- g = HueToRgb(m1, m2, hue);
- b = HueToRgb(m1, m2, hue - 1 / 3);
- }
- return {
- r: r,
- g: g,
- b: b
- };
-}
-function HueToRgb(m1, m2, hue) {
- var v;
- if (hue < 0)
- hue += 1;
- else if (hue > 1)
- hue -= 1;
- if (6 * hue < 1)
- v = m1 + (m2 - m1) * hue * 6;
- else if (2 * hue < 1)
- v = m2;
- else if (3 * hue < 2)
- v = m1 + (m2 - m1) * (2 / 3 - hue) * 6;
- else
- v = m1;
-
- return 255 * v;
-}
$(document).ready(function () {
@@ -1087,12 +621,12 @@ $(document).ready(function () {
var sim_b = 0.1 * hsb.b;
- var sim_rgb = hsl2rgb(hsb.h, hsb.s, sim_b);
- var sim_hex = RGBtoHex(sim_rgb.r, sim_rgb.g, sim_rgb.b);
+ var sim_rgb = utilsModule.hsl2rgb(hsb.h, hsb.s, sim_b);
+ var sim_hex = utilsModule.RGBtoHex(sim_rgb.r, sim_rgb.g, sim_rgb.b);
- setPref('background-selection', hex);
- setPref('background-selection-disabled', sim_hex);
- setPref('fontcolor-selection', back_hex);
+ userModule.setPref('background-selection', hex);
+ userModule.setPref('background-selection-disabled', sim_hex);
+ userModule.setPref('fontcolor-selection', back_hex);
$('style[title=color_selection]').empty();
@@ -1119,7 +653,7 @@ $(document).ready(function () {
});
startThesaurus();
- checkFilters();
+ searchModule.checkFilters();
activeZoning();
@@ -1648,7 +1182,7 @@ function editThis(type, value) {
function toggleRemoveReg(el) {
var state = !el.checked;
- setPref('reg_delete', (state ? '1' : '0'));
+ userModule.setPref('reg_delete', (state ? '1' : '0'));
p4.reg_delete = state;
}
@@ -1727,7 +1261,7 @@ function checkDeleteThis(type, el) {
var buttons = {};
buttons[language.valider] = function (e) {
- deleteBasket(el);
+ workzoneBasketModule.deleteBasket(el);
};
$('#DIALOG').empty().append(language.confirmDel).attr('title', language.attention).dialog({
@@ -1861,9 +1395,9 @@ function doSpecialSearch(qry, allbase) {
if (allbase) {
checkBases(true);
}
- selectedFacetValues = [];
+ workzoneFacetsModule.resetSelectedFacets();
$('#EDIT_query').val(decodeURIComponent(qry).replace(/\+/g, " "));
- newSearch(qry);
+ searchModule.newSearch(qry);
}
function clktri(id) {
@@ -1876,7 +1410,7 @@ function clktri(id) {
// ---------------------- fcts du thesaurus
-function chgProp(path, v, k) {
+/* NOT USED function chgProp(path, v, k) {
var q2;
if (!k)
k = "*";
@@ -1893,14 +1427,14 @@ function chgProp(path, v, k) {
for (i = 0; i < q.length; i++)
q2 += q.charCodeAt(i) == 160 ? " " : q.charAt(i);
- selectedFacetValues = [];
+ workzoneFacetsModule.resetSelectedFacets();
$('#EDIT_query').val(q);
newSearch(q);
return(false);
-}
+}*/
-function doDelete(lst) {
+/* NOT USED function doDelete(lst) {
var children = '0';
if (document.getElementById('del_children') && document.getElementById('del_children').checked)
children = '1';
@@ -1945,116 +1479,22 @@ function doDelete(lst) {
viewNbSelect();
}
});
-}
-
-function archiveBasket(basket_id) {
- $.ajax({
- type: "POST",
- url: "../prod/baskets/" + basket_id + "/archive/?archive=1",
- dataType: 'json',
- beforeSend: function () {
-
- },
- success: function (data) {
- if (data.success) {
- var basket = $('#SSTT_' + basket_id);
- var next = basket.next();
-
- if (next.data("ui-droppable")) {
- next.droppable('destroy');
- }
-
- next.slideUp().remove();
-
- if (basket.data("ui-droppable")) {
- basket.droppable('destroy');
- }
-
- basket.slideUp().remove();
-
- if ($('#baskets .SSTT').length === 0) {
- return p4.WorkZone.refresh(false);
- }
- }
- else {
- alert(data.message);
- }
- return;
- }
- });
-}
+}*/
-function deleteBasket(item) {
- if ($("#DIALOG").data("ui-dialog")) {
- $("#DIALOG").dialog('destroy');
- }
-
- var k = $(item).attr('id').split('_').slice(1, 2).pop(); // id de chutier
- $.ajax({
- type: "POST",
- url: "../prod/baskets/" + k + '/delete/',
- dataType: 'json',
- beforeSend: function () {
-
- },
- success: function (data) {
- if (data.success) {
- var basket = $('#SSTT_' + k);
- var next = basket.next();
-
- if (next.data("ui-droppable")) {
- next.droppable('destroy');
- }
-
- next.slideUp().remove();
-
- if (basket.data("ui-droppable")) {
- basket.droppable('destroy');
- }
-
- basket.slideUp().remove();
-
- if ($('#baskets .SSTT').length === 0) {
- return p4.WorkZone.refresh(false);
- }
- }
- else {
- alert(data.message);
- }
- return;
- }
- });
-}
-
-function deploy(deployer, todeploy_selector)
-{
- if($(deployer).hasClass("deployer_opened")) {
- $(deployer).removeClass("deployer_opened").addClass("deployer_closed");
- $(todeploy_selector).hide();
- }
- else {
- $(deployer).removeClass("deployer_closed").addClass("deployer_opened");
- $(todeploy_selector).show();
- }
-}
-
-function clksbas(el, sbas_id) {
- var bool = $(el).prop('checked');
- $.each($('.sbascont_' + sbas_id + ' :checkbox'), function () {
- this.checked = bool;
- });
-
- checkFilters(true);
-}
-function advSearch(event) {
+
+
+
+
+/* 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]');
@@ -2069,7 +1509,7 @@ function start_page_selector() {
break;
}
}
-
+// look_box
function set_start_page() {
var el = $('#look_box_settings select[name=start_page]');
var val = el.val();
@@ -2078,28 +1518,15 @@ function set_start_page() {
var start_page_query = $('#look_box_settings input[name=start_page_value]').val();
if (val === 'QUERY') {
- setPref('start_page_query', start_page_query);
+ userModule.setPref('start_page_query', start_page_query);
}
- setPref('start_page', val);
+ userModule.setPref('start_page', val);
}
-function basketPrefs() {
- $('#basket_preferences').dialog({
- closeOnEscape: true,
- resizable: false,
- width: 450,
- height: 500,
- modal: true,
- draggable: false,
- overlay: {
- backgroundColor: '#000',
- opacity: 0.7
- }
- }).dialog('open');
-}
+// preferences modal
function lookBox(el, event) {
$("#look_box").dialog({
closeOnEscape: true,
@@ -2162,7 +1589,7 @@ function saveeditPbar(idesc, ndesc) {
document.getElementById("saveeditPbarN").innerHTML = ndesc;
}
-function getSelText() {
+/* NOT USED function getSelText() {
var txt = '';
if (window.getSelection) {
txt = window.getSelection();
@@ -2176,9 +1603,9 @@ function getSelText() {
else
return;
return txt;
-}
+}*/
-function getWinPosAsXML() {
+/* NOT USED function getWinPosAsXML() {
var ret = '';
if ($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible'))
@@ -2186,7 +1613,7 @@ function getWinPosAsXML() {
return ret;
-}
+}*/
function saveWindows() {
var key = '';
@@ -2201,7 +1628,7 @@ function saveWindows() {
key = 'search_window';
value = $('#idFrameC').outerWidth() / bodySize.x;
}
- setPref(key, value);
+ userModule.setPref(key, value);
}
function gotopage(pag) {
@@ -2210,7 +1637,7 @@ function gotopage(pag) {
$('#searchForm').submit();
}
-function addFilterMulti(filter, link, sbasid) {
+/* NOT USED function addFilterMulti(filter, link, sbasid) {
var clone = $('#filter_multi_' + sbasid + '_' + filter);
var orig = clone;
if (!$('#filter_multi_' + sbasid + '_' + filter).is(':visible')) {
@@ -2228,9 +1655,9 @@ function addFilterMulti(filter, link, sbasid) {
$(link).removeClass('filterActive');
}
return false;
-}
+}*/
-function autoorder() {
+/* NOT USED function autoorder() {
var val = $.trim($('#auto_order').val());
if (val === '')
@@ -2278,7 +1705,7 @@ function autoorder() {
last_moved = elem;
}
-}
+}*/
diff --git a/resources/www/prod/js/record.editor.js b/resources/www/prod/js/record.editor.js
index 97601d1e30..a505b33fc3 100644
--- a/resources/www/prod/js/record.editor.js
+++ b/resources/www/prod/js/record.editor.js
@@ -1701,7 +1701,7 @@ function startThisEditing(sbas_id, what, regbasprid, ssel) {
},
stop: function () {
hsplit1();
- setPref('editing_top_box', Math.floor($('#EDIT_TOP').height() * 100 / $('#EDIT_ALL').height()));
+ userModule.setPref('editing_top_box', Math.floor($('#EDIT_TOP').height() * 100 / $('#EDIT_ALL').height()));
setSizeLimits();
}
});
@@ -1714,7 +1714,7 @@ function startThisEditing(sbas_id, what, regbasprid, ssel) {
setPreviewEdit();
},
stop: function () {
- setPref('editing_right_box', Math.floor($('#divS').width() * 100 / $('#EDIT_MID_L').width()));
+ userModule.setPref('editing_right_box', Math.floor($('#divS').width() * 100 / $('#EDIT_MID_L').width()));
vsplit1();
setSizeLimits();
}
@@ -1730,7 +1730,7 @@ function startThisEditing(sbas_id, what, regbasprid, ssel) {
setPreviewEdit();
},
stop: function () {
- setPref('editing_left_box', Math.floor($('#EDIT_MID_R').width() * 100 / $('#EDIT_MID').width()));
+ userModule.setPref('editing_left_box', Math.floor($('#EDIT_MID_R').width() * 100 / $('#EDIT_MID').width()));
vsplit2();
setSizeLimits();
}
@@ -1746,7 +1746,7 @@ function startThisEditing(sbas_id, what, regbasprid, ssel) {
},
change: function (event, ui) {
p4.edit.diapoSize = $(ui.value)[0];
- setPref("editing_images_size", p4.edit.diapoSize);
+ userModule.setPref("editing_images_size", p4.edit.diapoSize);
}
});
diff --git a/templates/web/common/index_bootstrap.html.twig b/templates/web/common/index_bootstrap.html.twig
index 11127aebbc..45b9d6c40d 100644
--- a/templates/web/common/index_bootstrap.html.twig
+++ b/templates/web/common/index_bootstrap.html.twig
@@ -18,6 +18,15 @@
+ {% if app.debug %}
+
+
+ {% endif %}
{##}
diff --git a/templates/web/prod/WorkZone/Macros.html.twig b/templates/web/prod/WorkZone/Macros.html.twig
index a7079fea50..bef9793c3d 100644
--- a/templates/web/prod/WorkZone/Macros.html.twig
+++ b/templates/web/prod/WorkZone/Macros.html.twig
@@ -167,7 +167,7 @@
diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig
index f315b1c0c7..e57b165b0d 100644
--- a/templates/web/prod/index.html.twig
+++ b/templates/web/prod/index.html.twig
@@ -5,9 +5,9 @@