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 = $('