1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
|
var grp={jQuery:jQuery.noConflict(!0)},django={jQuery:grp.jQuery},jQuery=grp.jQuery,inputTypes=["[type='search']","[type='email']","[type='url']","[type='tel']","[type='number']","[type='range']","[type='date']","[type='month']","[type='week']","[type='time']","[type='datetime']","[type='datetime-local']","[type='color']"].join(",");!function(e){grappelli.getFormat=function(e){if("date"==e)return DATE_FORMAT.toLowerCase().replace(/%\w/g,function(e){return(e=e.replace(/%/,""))+e})},grappelli.cleanInputTypes=function(){e("form").each(function(){e(this).find(":input").filter(inputTypes).each(function(){e(this).attr("type","text")})})},grappelli.initDateAndTimePicker=function(){e("p.datetime").each(function(){var t=e(this).html();t=(t=t.replace(/\w*: /,"")).replace(/<br>[^<]*: /g,"<br>"),e(this).html(t)});var t={constrainInput:!1,showOn:"button",buttonImageOnly:!1,buttonText:"",dateFormat:grappelli.getFormat("date"),showButtonPanel:!0,showAnim:"",beforeShow:function(e,t,a){grappelli.datepicker_instance=this}},a=e("input[class*='vDateField']:not([id*='__prefix__'])");a.datepicker(t),"undefined"!=typeof IS_POPUP&&IS_POPUP&&a.datepicker("disable"),e(document).on("click",".ui-datepicker-current",function(){e.datepicker._selectDate(grappelli.datepicker_instance),grappelli.datepicker_instance=null}),e("input[class*='vTimeField']:not([id*='__prefix__'])").grp_timepicker()},grappelli.initFilter=function(t){if(e("a.grp-pulldown-handler").on("click",function(){var t=e(this).closest(".grp-pulldown-container");e(t).toggleClass("grp-pulldown-state-open").children(".grp-pulldown-content").toggle()}),e("a.grp-pulldown-handler").on("mouseout",function(){e(this).blur()}),t||e(".grp-filter-choice").change(function(){location.href=e(this).val()}),"confirm"===t){var a=window.location.search.replace("?","").split("&"),r=[];void 0!==a[0]&&""!==a[0]&&a.map(e=>{var t=e.split("=")[0];-1!=t.search("__")&&(t=e.split("__")[0]),-1===r.findIndex(e=>e.fieldName===t)?r.push({fieldName:t,values:[e]}):r.find(e=>e.fieldName===t).values.push(e)}),e(".grp-filter-choice").change(function(){var t=e(this).data("field-name"),a="?"!==e(this).val()&&e(this).val().replace("?",""),n=a&&a.split("&"),l=n&&n.filter(e=>e.includes(t)),i=r.findIndex(e=>e.fieldName===t);!(i<0)?l.length>0?r.find(e=>e.fieldName===t).values=l:r.splice(i,1):l.length>0&&r.push({fieldName:t,values:l});var o=r.flatMap(e=>e.values).join("&");e(this).closest(".grp-filter").find("#grp-filter-apply").attr("href","?"+o)})}},grappelli.initSearchbar=function(){e("input.grp-search-field").trigger("focus")},grappelli.updateSelectFilter=function(e){"undefined"!=typeof SelectFilter&&(e.find(".selectfilter").each(function(e,t){var a=t.name.split("-");SelectFilter.init(t.id,a[a.length-1],!1,"{% admin_media_prefix %}")}),e.find(".selectfilterstacked").each(function(e,t){var a=t.name.split("-");SelectFilter.init(t.id,a[a.length-1],!0,"{% admin_media_prefix %}")}))},grappelli.reinitDateTimeFields=function(e){e.find(".vDateField").datepicker({constrainInput:!1,showOn:"button",buttonImageOnly:!1,buttonText:"",dateFormat:grappelli.getFormat("date")}),e.find(".vTimeField").grp_timepicker()},grappelli.get_app_label=function(e){var t=e.next("a");if(t.length>0){var a=t.attr("href").split("?")[0].split("/");return a[a.length-3]}return!1},grappelli.get_model_name=function(e){var t=e.next("a");if(t.length>0){var a=t.attr("href").split("?")[0].split("/");return a[a.length-2]}return!1},grappelli.get_query_string=function(e){var t=e.next("a");if(t.length>0){var a=t.attr("href").split("/");return pairs=a[a.length-1].replace("?","").split("&"),pairs.join(":")}return!1},grappelli.get_to_field=function(e){var t=e.next("a");if(t.length>0&&-1!==t.attr("href").indexOf("_to_field"))for(var a=t.attr("href").split("/"),r=a[a.length-1].replace("?","").split("&"),n=0;n<r.length;n++)if(v=r[n].split("="),"_to_field"==v[0])return v[1];return!1}}(grp.jQuery),function(e){var t={init:function(t){return t=e.extend({},e.fn.grp_autocomplete_fk.defaults,t),this.each(function(){var i=e(this);i.attr({tabindex:"-1",readonly:"readonly"}).addClass("grp-
|