From a29d0f3ffbbef5a0703cc76dda12360cdcff4ca3 Mon Sep 17 00:00:00 2001
From: Joel Alphonso
')+"
",level:t,type:e.type,buttons:i},s=this.getDisplay(),l=null;switch(s){case"dialog":case"toast":l=s;break;default:l=e.display}"toast"===l?(a.dismissible=0===i.length,new d(a)):BootstrapDialog.show(a)}this.empty()}return this},o.prototype.empty=function(){t(),this.display=null,this.actions=[],this.storage=[]},function(t,e){if(i.feedback(),this.validLevel(t))return this.setLevel(t),this.validMessage(e)&&this.setMessage(e),this;throw new TypeError("Feedback level required. Must be one of: "+r.join(", "))}),d=(l.createFromObject=function(t){var e=t.level||null,t=t.message||null;return e||t?new l(e,t):null},l.prototype={toString:function(){return this.message()},level:function(){return this._level||null},setLevel:function(t){var e=c.type(t);if("string"!==e)throw new TypeError("Feedback level must be a string, received "+e);return o.prototype.assertValidLevel(t),t in a&&(t=a[t]),this._level=t,this},validLevel:function(t){return o.prototype.isValidLevel(t)},message:function(){return this._message||null},setMessage:function(t){var e=c.type(t);if("string"!==e)throw new TypeError("Feedback message must be a string, received "+e);return this._message=t,this},validMessage:function(t){return o.prototype.validMessage(t)}},function(t){var e=c.type(t);if("object"!==e)throw new TypeError("Notification config must be an associative array, received "+e);return this.validMessage(t.message)&&this.setMessage(t.message),this.config=c.extend({},{id:BootstrapDialog.newGuid(),delay:s.delay},t),this.$elem=c(''),this.$elem.prop("id",this.config.id),this.$elem.addClass("alert-"+this.config.type.replace("type-","")),this.config.dismissible&&(this.$elem.addClass("alert-dismissible"),(e=c('')).append(' '),this.$elem.append(e)),this.config.message&&((t=c('')).html("").append(this.config.message),this.$elem.append(t)),this.$elem.appendTo(".c-notifications").addClass("show"),this.$elem.on("closed.bs.alert",{notification:this},function(t){t=t.data.notification;t.$elem.off(".charcoal.feedback"),t.closeTimer&&window.clearTimeout(t.closeTimer)}),"number"==typeof this.config.delay&&0"+commonL10n.confirmAction+'
'+commonL10n.cantUndo+"
"),btnOKLabel:commonL10n.delete,callback:function(t){var e;t&&(t=Charcoal.Admin.admin_url()+"object/delete",e={obj_type:i.obj_type,obj_id:i.obj_id},t=$.ajax({method:"POST",url:t,data:e,dataType:"json"}),Charcoal.Admin.resolveSimpleJsonXhr(t,function(){window.location.href=o},function(t){t.feedbacks.length?Charcoal.Admin.feedback(t.feedbacks):Charcoal.Admin.feedback([{level:"error",message:formWidgetL10n.deleteFailed}])},function(){i.suppress_feedback()||Charcoal.Admin.feedback().dispatch()}))}})},Charcoal.Admin.Widget_Form.prototype.reload=function(i){return this.destroy(),Charcoal.Admin.Widget.prototype.reload.call(this,function(t,e){"function"==typeof i&&i.call(t,e),Charcoal.Admin.manager().render()},!0),this},Charcoal.Admin.Widget_Form.prototype.switch_language=function(t){var e,i=Charcoal.Admin.lang();i!==t&&(e=$.Event("beforelanguageswitch"+this.EVENT_NAMESPACE,{language:t,originalLanguage:i,relatedTarget:this.$form[0],relatedComponent:this}),$(document).triggerHandler(e),e.isDefaultPrevented()||(Charcoal.Admin.setLang(t),$("[data-lang][data-lang!="+t+"]").addClass("d-none"),$("[data-lang][data-lang="+t+"]").removeClass("d-none"),$("[data-lang-switch][data-lang-switch!="+t+"]").removeClass("btn-primary").addClass("btn-outline-primary"),$("[data-lang-switch][data-lang-switch="+t+"]").removeClass("btn-outline-primary").addClass("btn-primary"),$(document).triggerHandler({type:"switch_language.charcoal"}),e=$.Event("languageswitch"+this.EVENT_NAMESPACE,{language:t,originalLanguage:i,relatedTarget:this.$form[0],relatedComponent:this}),$(document).triggerHandler(e)))},Charcoal.Admin.Widget_Form.prototype.destroy=function(){$(this.form_selector).off(this.EVENT_NAMESPACE),$(".js-sidebar-widget",this.form_selector).off(this.EVENT_NAMESPACE),window.removeEventListener("popstate",this._on_popstate_tab),this.isTab&&$(this.form_selector).off("shown.bs.tab",".js-group-tabs",this._shown_tab_handler)},function(e,t,i){"use strict";function o(t){this.EVENT_NAMESPACE=o.EVENT_NAMESPACE,Charcoal.Admin.Widget.call(this,t),this.graph_options=t.graph_options||t.data.graph_options||{}}o.EVENT_NAMESPACE=".charcoal.widget.graph",((o.prototype=Object.create(Charcoal.Admin.Widget.prototype)).contructor=o).prototype.parent=Charcoal.Admin.Widget.prototype,o.prototype.init=function(){var t;echarts?(t=echarts.init(this.element()[0]),(this.chart=t).setOption(this.graph_options),e(i).on("resize"+this.EVENT_NAMESPACE,function(){t.resize()})):console.error("Could not initialize graph widget:","eCharts is missing")},o.prototype.destroy=function(){this.chart&&this.chart.dispose(),e(i).off("resize"+this.EVENT_NAMESPACE)},t.Widget_Graph=o}(jQuery,Charcoal.Admin,window),Charcoal.Admin.Widget_Map=function(t){return Charcoal.Admin.Widget.call(this,t),this._controller=void 0,this},Charcoal.Admin.Widget_Map.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Map.prototype.constructor=Charcoal.Admin.Widget_Map,Charcoal.Admin.Widget_Map.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Map.prototype.init=function(){var t=this;return"undefined"==typeof google?(window._tmp_google_onload_function=function(){t.activate_map()},$.getScript("https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=fr&callback=_tmp_google_onload_function",function(){})):t.activate_map(),this},Charcoal.Admin.Widget_Map.prototype.activate_map=function(){var t={default_styles:{strokeColor:"#000000",strokeOpacity:.8,strokeWeight:3,fillColor:"#ffffff",fillOpacity:.35,hover:{strokeColor:"#000000",strokeOpacity:1,strokeWeight:2,fillColor:"#ffffff",fillOpacity:.5},focused:{fillOpacity:.8}},use_clusterer:!1,map:{center:{x:this.opts("coords")[0],y:this.opts("coords")[1]},zoom:14,mapType:"roadmap",coordsType:"inpage",map_mode:"default"},places:{first:{type:"marker",coords:this.coords()}}};this._controller=new window.BB.gmap.controller(this.element().find(".js-map-maker-map").get(0),t),this.controller().set_styles([{featureType:"poi",elementType:"all",stylers:[{visibility:"off"}]}]),this.controller().remove_focus(),this.controller().init()},Charcoal.Admin.Widget_Map.prototype.controller=function(){return this._controller},Charcoal.Admin.Widget_Map.prototype.coords=function(){return this.opts("coords")},Charcoal.Admin.Widget_Object_Revisions=function(t){return Charcoal.Admin.Widget.call(this,t),this.extra_form_data=t.extra_form_data||{},this.xhr=null,this.obj_id=Charcoal.Admin.parseNumber(t.obj_id)||0,this.obj_type=t.obj_type,this},Charcoal.Admin.Widget_Object_Revisions.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Object_Revisions.prototype.constructor=Charcoal.Admin.Widget_Object_Revisions,Charcoal.Admin.Widget_Object_Revisions.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Object_Revisions.prototype.init=function(){this.bind_events()},Charcoal.Admin.Widget_Object_Revisions.prototype.bind_events=function(){var e=this;$("#"+this.id()).on("click.object.revisions",".js-obj-revert",this.revert.bind(this)),$("#"+this.id()).on("click.charcoal.bs.dialog",'[data-dismiss="dialog"]',function(t){$.isFunction(e.cancel_callback)&&e.cancel_callback(t)})},Charcoal.Admin.Widget_Object_Revisions.prototype.revert=function(t){t.preventDefault();var e=Charcoal.Admin.admin_url()+"object/revert-revision",i={obj_type:this.obj_type,obj_id:this.obj_id,rev_num:$(t.currentTarget).attr("data-rev-num")};BootstrapDialog.show({title:objectRevisionsWidgetL10n.title,message:objectRevisionsWidgetL10n.message,buttons:[{id:"ok-btn",label:objectRevisionsWidgetL10n.restore,action:function(t){t.close(),$.ajax({url:e,type:"POST",data:i,dataType:"json",success:function(t){t.success?window.location.reload():(Charcoal.Admin.feedback().push([{level:"error",message:objectRevisionsWidgetL10n.restoreError}]),Charcoal.Admin.feedback().dispatch())},error:function(){Charcoal.Admin.feedback().push([{level:"error",message:objectRevisionsWidgetL10n.restoreError}]),Charcoal.Admin.feedback().dispatch()}})}}]})},Charcoal.Admin.Widget_Object_Revisions.prototype.disable_form=Charcoal.Admin.Widget_Form.prototype.disable_form,Charcoal.Admin.Widget_Object_Revisions.prototype.enable_form=Charcoal.Admin.Widget_Form.prototype.enable_form,Charcoal.Admin.Widget_Object_Revisions.prototype.request_url=Charcoal.Admin.Widget_Form.prototype.request_url,Charcoal.Admin.Widget_Object_Revisions.prototype.request_done=Charcoal.Admin.Widget_Form.prototype.request_done,Charcoal.Admin.Widget_Object_Revisions.prototype.request_failed=Charcoal.Admin.Widget_Form.prototype.request_failed,Charcoal.Admin.Widget_Object_Revisions.prototype.request_complete=Charcoal.Admin.Widget_Form.prototype.request_complete,Charcoal.Admin.Widget_Object_Revisions.prototype.request_success=function(t,e,i){i.feedbacks&&!this.suppress_feedback()&&Charcoal.Admin.feedback(i.feedbacks),i.next_url&&Charcoal.Admin.feedback().add_action({label:commonL10n.continue,callback:function(){window.location.href=Charcoal.Admin.admin_url()+i.next_url}})},Charcoal.Admin.Widget_Quick_Form=function(t){this.EVENT_NAMESPACE=Charcoal.Admin.Widget_Quick_Form.EVENT_NAMESPACE,Charcoal.Admin.Widget.call(this,t),this.save_callback=t.save_callback||"",this.cancel_callback=t.cancel_callback||"",this.form_selector=t.data.form_selector,this.save_action=t.save_action||"object/save",this.update_action=t.update_action||"object/update",this.extra_form_data=t.extra_form_data||{},this.group_conditions=t.data.group_conditions,this.group_display_mode=t.data.group_display_mode||"",this.show_language_switch=t.data.show_language_switch||!1,this.form_working=!1,this.is_new_object=!1,this.xhr=null,this.obj_id=Charcoal.Admin.parseNumber(t.obj_id)||0},Charcoal.Admin.Widget_Quick_Form.EVENT_NAMESPACE=".charcoal.quickform",Charcoal.Admin.Widget_Quick_Form.prototype=Object.create(Charcoal.Admin.Widget_Form.prototype),Charcoal.Admin.Widget_Quick_Form.prototype.constructor=Charcoal.Admin.Widget_Quick_Form,Charcoal.Admin.Widget_Quick_Form.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Quick_Form.prototype.init=function(){this.set_properties(this.opts()),this.bind_events(),this.parse_group_conditions(),this.show_language_switch&&$('.nav-link.nav-lang[data-tab-ident="'+Charcoal.Admin.lang()+'"]').trigger("click")},Charcoal.Admin.Widget_Quick_Form.prototype.set_properties=function(){this.$form=$(this.form_selector)},Charcoal.Admin.Widget_Quick_Form.prototype.bind_events=function(){var e=this,t=this.$form;t.on("submit"+this.EVENT_NAMESPACE,function(t){t.preventDefault(),e.request_submit()}).on("click"+this.EVENT_NAMESPACE,'[data-dismiss="dialog"]',function(t){$.isFunction(e.cancel_callback)&&e.cancel_callback(t)}),this.show_language_switch&&t.on("click.nav-link.nav-lang","a.nav-link.nav-lang",function(t){t.preventDefault(),e.trigger_lang_tab($(this).attr("data-tab-ident"))})},Charcoal.Admin.Widget_Quick_Form.prototype.request_success=function(t){var e=$.Event("success"+this.EVENT_NAMESPACE,{subtype:"submission",component:this,response:t});this.$form.trigger(e),e.isDefaultPrevented()||(this.confirmed=!1,t.feedbacks&&!this.suppress_feedback()&&Charcoal.Admin.feedback(t.feedbacks),t.need_confirmation?this.add_actions_for_confirmation(t.confirmation_label):t.next_url?this.add_action_for_next_url(t.next_url,t.next_url_label):(this.enable_form(),this.form_working=!1,"function"==typeof this.save_callback&&this.save_callback(t)))},Charcoal.Admin.Widget_Quick_Form.prototype.trigger_lang_tab=function(e){$(".modal .form-field").each(function(){var t=$(this).attr("data-lang");t&&(e!==t?this.style.setProperty("display","none","important"):this.style.setProperty("display","block","important"))})},Charcoal.Admin.Widget_Relation=function(t){return Charcoal.Admin.Widget.call(this,t),this.dirty=!1,this},Charcoal.Admin.Widget_Relation.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Relation.prototype.constructor=Charcoal.Admin.Widget_Relation,Charcoal.Admin.Widget_Relation.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Relation.prototype.init=function(){var t=this.element().find(".js-relation-sortable .js-grid-container");return this.element().on("hidden.bs.collapse",'[data-toggle="collapse"]',function(){t.sortable("refreshPositions")}),t.sortable({handle:'[draggable="true"]',placeholder:"panel c-attachment_placeholder",start:function(t,e){e.item.children(".panel-heading").find('[data-toggle="collapse"]').hasClass("collapsed")||e.item.children(".panel-collapse").collapse("hide")}}).disableSelection(),this.listeners(),this},Charcoal.Admin.Widget_Relation.prototype.is_dirty=function(){return this.dirty},Charcoal.Admin.Widget_Relation.prototype.set_dirty_state=function(t){return this.dirty=t,this},Charcoal.Admin.Widget_Relation.prototype.listeners=function(){var r=this;this.element().off("click").on("click.charcoal.relation",".js-add-relation",function(t){t.preventDefault();t=$(this).data("type");if(!t)return!1;var e=$(this).data("id");e?(r.add({id:e,type:t}),r.create_relation(function(){r.reload()})):(e=$(this).data("title")||relationWidgetL10n.editObject,r.create_relation_dialog({title:e,widget_options:{form_data:{target_object_type:t,target_object_id:null}}},function(t){t.success&&(t.obj.id=t.obj_id,r.add(t.obj),r.create_relation(function(){r.reload()}))}))}).on("click.charcoal.relation",".js-relation-actions a",function(t){var e=$(this);if(e.data("action"))switch(t.preventDefault(),e.data("action")){case"edit":var i=e.data("type"),o=e.data("id");if(!i||!o)break;o=e.data("title")||relationWidgetL10n.editObject;r.create_relation_dialog({title:o,widget_options:{form_data:{target_object_type:i,target_object_id:null}}},function(t){t.success&&r.reload()});break;case"unlink":if(!e.data("id"))break;r.confirm({title:relationWidgetL10n.confirmRemoval,message:commonL10n.confirmAction,btnOKLabel:commonL10n.removeObject,callback:function(t){t&&r.remove_relation(e.data("id"),function(){r.reload()})}})}})},Charcoal.Admin.Widget_Relation.prototype.create_relation_dialog=function(t,e){t=t||{};var i=this.opts().data,i={size:BootstrapDialog.SIZE_WIDE,cssClass:"-quick-form",widget_type:"charcoal/admin/widget/quick-form",widget_options:{obj_type:"charcoal/relation/pivot",obj_id:0,form_data:{group:i.group,source_object_type:i.obj_type,source_object_id:i.obj_id,target_object_type:"",target_object_id:0}}},o=$.extend(!0,{},i,t,{}),r=this.dialog(o,function(t){if(t.success){if(!t.widget_id)return!1;Charcoal.Admin.manager().add_widget({id:t.widget_id,type:"charcoal/admin/widget/quick-form",data:{obj_type:o.widget_options.type},obj_id:o.widget_options.id,save_callback:function(t){e(t),this instanceof Charcoal.Admin.Component&&this.id()&&Charcoal.Admin.manager().destroy_component("widgets",this.id()),r.close()}}),Charcoal.Admin.manager().render()}})},Charcoal.Admin.Widget_Relation.prototype.add=function(t){if(!t)return!1;this.set_dirty_state(!0);var e=this.element().find(".js-relation-template").clone();return e.find(".js-relation").attr({"data-id":t.target_object_id,"data-type":t.target_object_type}),this.element().find(".js-relation-sortable").find(".js-grid-container").append(e),this},Charcoal.Admin.Widget_Relation.prototype.will_save=function(t){return t&&$.contains(t.element()[0],this.element()[0])},Charcoal.Admin.Widget_Relation.prototype.save=function(){return!this.is_dirty()&&(this.create_relation(),!0)},Charcoal.Admin.Widget_Relation.prototype.create_relation=function(t){var e=this,i=e.opts(),o={obj_type:i.data.obj_type,obj_id:i.data.obj_id,group:i.data.group,pivots:[]};this.element().find(".js-relation-container").find(".js-relation").each(function(t){var e=$(this),i=e.attr("data-id"),e=e.attr("data-type");o.pivots.push({target_object_id:i,target_object_type:e,position:t})}),$.post("relation/link",o,function(){"function"==typeof t&&t(),e.set_dirty_state(!1)},"json")},Charcoal.Admin.Widget_Relation.prototype.remove_relation=function(t,e){if(!t)return!1;var i=this;$.post("relation/unlink",{pivot_id:t},function(){"function"==typeof e&&e(),i.set_dirty_state(!1)},"json")},Charcoal.Admin.Widget_Relation.prototype.widget_options=function(){return this.opts("widget_options")},Charcoal.Admin.Widget_Search=function(t){return this.EVENT_NAMESPACE=Charcoal.Admin.Widget_Search.EVENT_NAMESPACE,Charcoal.Admin.Widget.call(this,t),this._elem=void 0,!!t&&(void 0!==t.id&&(this.set_element($("#"+t.id)),"object"==typeof t.data&&(this.data=t.data,this.$input=null,this._search_filters=!1,this._search_query=!1,this)))},Charcoal.Admin.Widget_Search.EVENT_NAMESPACE=".charcoal.widget.search",Charcoal.Admin.Widget_Search.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Search.prototype.constructor=Charcoal.Admin.Widget_Search,Charcoal.Admin.Widget_Search.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Search.prototype.widget_options=function(){return this.data},Charcoal.Admin.Widget_Search.prototype.set_remote_widget=function(){},Charcoal.Admin.Widget_Search.prototype.init=function(){var e=this,t=this.element();this.$input=t.find('[name="query"]'),t.on("submit"+this.EVENT_NAMESPACE,function(t){t.preventDefault(),e.submit()}),t.on("reset"+this.EVENT_NAMESPACE,function(t){t.preventDefault(),e.clear()})},Charcoal.Admin.Widget_Search.prototype.submit=function(){return this.set_search_query(this.$input.val()),Charcoal.Admin.manager().get_widgets().forEach(this.dispatch.bind(this)),this.set_search_query(null),this},Charcoal.Admin.Widget_Search.prototype.clear=function(){return this._search_search=!1,this._search_filters=!1,this.$input.val(""),this.submit(),this},Charcoal.Admin.Widget_Search.prototype.parse_search_query=function(t){return"string"!=typeof t||0===(t=t.trim()).length?null:t},Charcoal.Admin.Widget_Search.prototype.parse_search_filters=function(t){var e,o,r=[];return(t=this.parse_search_query(t))&&(t=t.split(/\s/),e=this.data.properties||[],$.each(t,function(t,i){o=[],i=i.replace(/'/g,"\\'"),$.each(e,function(t,e){o.push({property:e,operator:"LIKE",value:"%"+i+"%"})}),r.push({conjunction:"OR",filters:o})})),r.length?r:null},Charcoal.Admin.Widget_Search.prototype.set_search_query=function(t){this._search_search=this.parse_search_query(t),this._search_filters=!1},Charcoal.Admin.Widget_Search.prototype.search_query=function(){return!1===this._search_search?null:this._search_search},Charcoal.Admin.Widget_Search.prototype.search_filters=function(){return!1===this._search_filters&&(this._search_filters=this.parse_search_filters(this._search_search)),this._search_filters},Charcoal.Admin.Widget_Search.prototype.dispatch=function(t){if(t&&t!==this){var e="function"==typeof t.set_search_query,i="function"==typeof t.set_filter;if(!e&&!i)return this;e&&(e=this.search_query(),t.set_search_query(e)),i&&(e=this.search_filters(),t.set_filter("search",e)),void 0!==t.pagination&&(t.pagination.page=1),t.reload(null,!0)}},Charcoal.Admin.Widget_Search.prototype.destroy=function(){this.element().off(this.EVENT_NAMESPACE)},Charcoal.Admin.Widget_Table=function(t){Charcoal.Admin.Widget.call(this,t),this.obj_type=null,this.widget_id=null,this.table_selector=null,this.pagination={page:1,num_per_page:50},this.list_actions={},this.object_actions={},this.template=this.properties=this.properties_options=void 0,this.sortable=!1,this.sortable_handler=null},Charcoal.Admin.Widget_Table.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Table.prototype.constructor=Charcoal.Admin.Widget_Table,Charcoal.Admin.Widget_Table.prototype.parent=Charcoal.Admin.Widget.prototype,Object.assign(Charcoal.Admin.Widget_Table.prototype,Charcoal.Admin.Mixin_Model_Search),Object.assign(Charcoal.Admin.Widget_Table.prototype,Charcoal.Admin.Mixin_Model_Filters),Object.assign(Charcoal.Admin.Widget_Table.prototype,Charcoal.Admin.Mixin_Model_Orders),Charcoal.Admin.Widget_Table.prototype.init=function(){this.set_properties().bind_events()},Charcoal.Admin.Widget_Table.prototype.set_properties=function(){var t=this.opts();return this.obj_type=t.data.obj_type||this.obj_type,this.widget_id=t.id||this.widget_id,this.table_selector="#"+this.widget_id,this.sortable=t.data.sortable||this.sortable,this.template=t.data.template||this.template,this.collection_ident=t.data.collection_ident||"default","properties"in t.data&&Array.isArray(t.data.properties)&&(this.properties=t.data.properties),"properties_options"in t.data&&$.isPlainObject(t.data.properties_options)&&(this.properties_options=t.data.properties_options),"filters"in t.data&&this.set_filters(t.data.filters),"orders"in t.data&&this.set_orders(t.data.orders),"pagination"in t.data&&$.isPlainObject(t.data.pagination)&&(this.pagination=t.data.pagination),"list_actions"in t.data&&(Array.isArray(t.data.list_actions)?this.list_actions=Object.assign({},t.data.list_actions):$.isPlainObject(t.data.list_actions)&&(this.list_actions=t.data.list_actions)),"object_actions"in t.data&&(Array.isArray(t.data.object_actions)?this.object_actions=Object.assign({},t.data.object_actions):$.isPlainObject(t.data.object_actions)&&(this.object_actions=t.data.object_actions)),this},Charcoal.Admin.Widget_Table.prototype.bind_events=function(){null!==this.sortable_handler&&this.sortable_handler.destroy();var e=this,t=$("tbody.js-sortable",e.table_selector);0"+authL10n.postLoginRedirect+" "+authL10n.postLoginFallback.replace("[[ url ]]",i)+"
",BootstrapDialog.show({title:authL10n.loginTitle,message:t,type:BootstrapDialog.TYPE_SUCCESS,onhidden:e}),setTimeout(e,300)}).fail(function(t,e,i){var t=Charcoal.Admin.parseJqXhrResponse(t,e,i),e=r.parseFeedbackAsHtml(t)||authL10n.authFailed,o=Charcoal.Admin.recaptcha(),i=null;o.hasApi()&&(i=function(){o.getApi().reset()}),BootstrapDialog.show({title:authL10n.loginTitle,message:e,type:BootstrapDialog.TYPE_DANGER,onhidden:i})})},Charcoal.Admin.Template_Login.prototype.parseFeedbackAsHtml=function(t){if(t.feedbacks&&(t=t.feedbacks),!1===Array.isArray(t)||0===t.length)return null;if(0===t.length)return null;var e,t=Charcoal.Admin.feedback(t),i=t.getMessagesMap(),o="";for(e in i)o+=i[e].join("
");return o+="
",t.empty(),""===o?null:o},Charcoal.Admin.Template_MenuHeader=function(){$(".js-toggle-class").click(function(t){t.preventDefault();var t=$(this),e=t.data("class"),t=t.data("target");$(t).toggleClass(e)}),$(document).on("click",".js-accordion-header",function(t){t.preventDefault(),$(this).toggleClass("is-open").siblings(".js-accordion-content").stop().slideToggle()})},Charcoal.Admin.Template_Account_LostPassword=function(t){this.template_type="charcoal/admin/template/account/lost-password",this.init(t)},Charcoal.Admin.Template_Account_LostPassword.prototype=Object.create(Charcoal.Admin.Template.prototype),Charcoal.Admin.Template_Account_LostPassword.prototype.constructor=Charcoal.Admin.Template_Account_LostPassword,Charcoal.Admin.Template_Account_LostPassword.prototype.parent=Charcoal.Admin.Template.prototype,Charcoal.Admin.Template_Account_LostPassword.prototype.init=function(t){window.console.debug(t),this.bind_events()},Charcoal.Admin.Template_Account_LostPassword.prototype.bind_events=function(){var t=$("#lost-password-form");t.on("submit.charcoal.password",$.proxy(this.onSubmit,this)),window.CharcoalCaptchaResetPassCallback=this.submitForm.bind(this,t)},Charcoal.Admin.Template_Account_LostPassword.prototype.onSubmit=Charcoal.Admin.Template_Login.prototype.onSubmit,Charcoal.Admin.Template_Account_LostPassword.prototype.parseFeedbackAsHtml=Charcoal.Admin.Template_Login.prototype.parseFeedbackAsHtml,Charcoal.Admin.Template_Account_LostPassword.prototype.submitForm=function(t){var r=this,e=t.prop("action")||window.location.href,t=t.serialize();$.post(e,t,Charcoal.Admin.resolveJqXhrFalsePositive.bind(this),"json").done(function(t){var e=r.parseFeedbackAsHtml(t)||authL10n.lostPassSuccess;BootstrapDialog.show({title:authL10n.lostPassword,message:e,type:BootstrapDialog.TYPE_SUCCESS,onhidden:function(){window.location.href=t.next_url||Charcoal.Admin.admin_url("login?notice=resetpass")}})}).fail(function(t,e,i){var t=Charcoal.Admin.parseJqXhrResponse(t,e,i),e=r.parseFeedbackAsHtml(t)||authL10n.lostPassFailed,o=Charcoal.Admin.recaptcha(),i=null;o.hasApi()&&(i=function(){o.getApi().reset()}),BootstrapDialog.show({title:authL10n.lostPassword,message:e,type:BootstrapDialog.TYPE_DANGER,onhidden:i})})},Charcoal.Admin.Template_Account_ResetPassword=function(t){this.template_type="charcoal/admin/template/account/reset-password",this.init(t)},Charcoal.Admin.Template_Account_ResetPassword.prototype=Object.create(Charcoal.Admin.Template.prototype),Charcoal.Admin.Template_Account_ResetPassword.prototype.constructor=Charcoal.Admin.Template_Account_ResetPassword,Charcoal.Admin.Template_Account_ResetPassword.prototype.parent=Charcoal.Admin.Template.prototype,Charcoal.Admin.Template_Account_ResetPassword.prototype.init=function(t){window.console.debug(t),this.bind_events()},Charcoal.Admin.Template_Account_ResetPassword.prototype.bind_events=function(){var t=$("#reset-password-form");t.on("submit.charcoal.password",$.proxy(this.onSubmit,this)),window.CharcoalCaptchaChangePassCallback=this.submitForm.bind(this,t)},Charcoal.Admin.Template_Account_ResetPassword.prototype.onSubmit=Charcoal.Admin.Template_Login.prototype.onSubmit,Charcoal.Admin.Template_Account_ResetPassword.prototype.parseFeedbackAsHtml=Charcoal.Admin.Template_Login.prototype.parseFeedbackAsHtml,Charcoal.Admin.Template_Account_ResetPassword.prototype.submitForm=function(t){var r=this,e=t.prop("action")||window.location.href,t=t.serialize();$.post(e,t,Charcoal.Admin.resolveJqXhrFalsePositive.bind(this),"json").done(function(t){var e=r.parseFeedbackAsHtml(t)||authL10n.resetPassSuccess;BootstrapDialog.show({title:authL10n.passwordReset,message:e,type:BootstrapDialog.TYPE_SUCCESS,onhidden:function(){window.location.href=t.next_url||Charcoal.Admin.admin_url("login?notice=newpass")}})}).fail(function(t,e,i){var t=Charcoal.Admin.parseJqXhrResponse(t,e,i),e=r.parseFeedbackAsHtml(t)||authL10n.resetPassFailed,o=Charcoal.Admin.recaptcha(),i=null;o.hasApi()&&(i=function(){o.getApi().reset()}),BootstrapDialog.show({title:authL10n.passwordReset,message:e,type:BootstrapDialog.TYPE_DANGER,onhidden:i})})}; \ No newline at end of file +$.fn.enable=function(){return this.each(function(){$(this).removeAttr("disabled").prop("disabled",!1)}),this},$.fn.disable=function(){return this.each(function(){$(this).attr("disabled",!0).prop("disabled",!0)}),this},$.fn.exists=function(){return 0')+"
",level:t,type:e.type,buttons:i},s=this.getDisplay(),l=null;switch(s){case"dialog":case"toast":l=s;break;default:l=e.display}"toast"===l?(a.dismissible=0===i.length,new p(a)):BootstrapDialog.show(a)}this.empty()}return this},o.prototype.empty=function(){t(),this.display=null,this.actions=[],this.storage=[]},function(t,e){if(i.feedback(),this.validLevel(t))return this.setLevel(t),this.validMessage(e)&&this.setMessage(e),this;throw new TypeError("Feedback level required. Must be one of: "+r.join(", "))}),p=(l.createFromObject=function(t){var e=t.level||null,t=t.message||null;return e||t?new l(e,t):null},l.prototype={toString:function(){return this.message()},level:function(){return this._level||null},setLevel:function(t){var e=c.type(t);if("string"!==e)throw new TypeError("Feedback level must be a string, received "+e);return o.prototype.assertValidLevel(t),t in a&&(t=a[t]),this._level=t,this},validLevel:function(t){return o.prototype.isValidLevel(t)},message:function(){return this._message||null},setMessage:function(t){var e=c.type(t);if("string"!==e)throw new TypeError("Feedback message must be a string, received "+e);return this._message=t,this},validMessage:function(t){return o.prototype.validMessage(t)}},function(t){var e=c.type(t);if("object"!==e)throw new TypeError("Notification config must be an associative array, received "+e);return this.validMessage(t.message)&&this.setMessage(t.message),this.config=c.extend({},{id:BootstrapDialog.newGuid(),delay:s.delay},t),this.$elem=c(''),this.$elem.prop("id",this.config.id),this.$elem.addClass("alert-"+this.config.type.replace("type-","")),this.config.dismissible&&(this.$elem.addClass("alert-dismissible"),(e=c('')).append(' '),this.$elem.append(e)),this.config.message&&((t=c('')).html("").append(this.config.message),this.$elem.append(t)),this.$elem.appendTo(".c-notifications").addClass("show"),this.$elem.on("closed.bs.alert",{notification:this},function(t){t=t.data.notification;t.$elem.off(".charcoal.feedback"),t.closeTimer&&window.clearTimeout(t.closeTimer)}),"number"==typeof this.config.delay&&0"+commonL10n.confirmAction+'
'+commonL10n.cantUndo+"
"),btnOKLabel:commonL10n.delete,callback:function(t){var e;t&&(t=Charcoal.Admin.admin_url()+"object/delete",e={obj_type:i.obj_type,obj_id:i.obj_id},t=$.ajax({method:"POST",url:t,data:e,dataType:"json"}),Charcoal.Admin.resolveSimpleJsonXhr(t,function(){window.location.href=o},function(t){t.feedbacks.length?Charcoal.Admin.feedback(t.feedbacks):Charcoal.Admin.feedback([{level:"error",message:formWidgetL10n.deleteFailed}])},function(){i.suppress_feedback()||Charcoal.Admin.feedback().dispatch()}))}})},Charcoal.Admin.Widget_Form.prototype.reload=function(i){return this.destroy(),Charcoal.Admin.Widget.prototype.reload.call(this,function(t,e){"function"==typeof i&&i.call(t,e),Charcoal.Admin.manager().render()},!0),this},Charcoal.Admin.Widget_Form.prototype.switch_language=function(t){var e,i=Charcoal.Admin.lang();i!==t&&(e=$.Event("beforelanguageswitch"+this.EVENT_NAMESPACE,{language:t,originalLanguage:i,relatedTarget:this.$form[0],relatedComponent:this}),$(document).triggerHandler(e),e.isDefaultPrevented()||(Charcoal.Admin.setLang(t),$("[data-lang][data-lang!="+t+"]").addClass("d-none"),$("[data-lang][data-lang="+t+"]").removeClass("d-none"),$("[data-lang-switch][data-lang-switch!="+t+"]").removeClass("btn-primary").addClass("btn-outline-primary"),$("[data-lang-switch][data-lang-switch="+t+"]").removeClass("btn-outline-primary").addClass("btn-primary"),$(document).triggerHandler({type:"switch_language.charcoal"}),e=$.Event("languageswitch"+this.EVENT_NAMESPACE,{language:t,originalLanguage:i,relatedTarget:this.$form[0],relatedComponent:this}),$(document).triggerHandler(e)))},Charcoal.Admin.Widget_Form.prototype.destroy=function(){$(this.form_selector).off(this.EVENT_NAMESPACE),$(".js-sidebar-widget",this.form_selector).off(this.EVENT_NAMESPACE),window.removeEventListener("popstate",this._on_popstate_tab),this.isTab&&$(this.form_selector).off("shown.bs.tab",".js-group-tabs",this._shown_tab_handler)},function(e,t,i){"use strict";function o(t){this.EVENT_NAMESPACE=o.EVENT_NAMESPACE,Charcoal.Admin.Widget.call(this,t),this.graph_options=t.graph_options||t.data.graph_options||{}}o.EVENT_NAMESPACE=".charcoal.widget.graph",((o.prototype=Object.create(Charcoal.Admin.Widget.prototype)).contructor=o).prototype.parent=Charcoal.Admin.Widget.prototype,o.prototype.init=function(){var t;echarts?(t=echarts.init(this.element()[0]),(this.chart=t).setOption(this.graph_options),e(i).on("resize"+this.EVENT_NAMESPACE,function(){t.resize()})):console.error("Could not initialize graph widget:","eCharts is missing")},o.prototype.destroy=function(){this.chart&&this.chart.dispose(),e(i).off("resize"+this.EVENT_NAMESPACE)},t.Widget_Graph=o}(jQuery,Charcoal.Admin,window),Charcoal.Admin.Widget_Map=function(t){return Charcoal.Admin.Widget.call(this,t),this._controller=void 0,this},Charcoal.Admin.Widget_Map.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Map.prototype.constructor=Charcoal.Admin.Widget_Map,Charcoal.Admin.Widget_Map.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Map.prototype.init=function(){var t=this;return"undefined"==typeof google?(window._tmp_google_onload_function=function(){t.activate_map()},$.getScript("https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=fr&callback=_tmp_google_onload_function",function(){})):t.activate_map(),this},Charcoal.Admin.Widget_Map.prototype.activate_map=function(){var t={default_styles:{strokeColor:"#000000",strokeOpacity:.8,strokeWeight:3,fillColor:"#ffffff",fillOpacity:.35,hover:{strokeColor:"#000000",strokeOpacity:1,strokeWeight:2,fillColor:"#ffffff",fillOpacity:.5},focused:{fillOpacity:.8}},use_clusterer:!1,map:{center:{x:this.opts("coords")[0],y:this.opts("coords")[1]},zoom:14,mapType:"roadmap",coordsType:"inpage",map_mode:"default"},places:{first:{type:"marker",coords:this.coords()}}};this._controller=new window.BB.gmap.controller(this.element().find(".js-map-maker-map").get(0),t),this.controller().set_styles([{featureType:"poi",elementType:"all",stylers:[{visibility:"off"}]}]),this.controller().remove_focus(),this.controller().init()},Charcoal.Admin.Widget_Map.prototype.controller=function(){return this._controller},Charcoal.Admin.Widget_Map.prototype.coords=function(){return this.opts("coords")},Charcoal.Admin.Widget_Object_Revisions=function(t){return Charcoal.Admin.Widget.call(this,t),this.extra_form_data=t.extra_form_data||{},this.xhr=null,this.obj_id=Charcoal.Admin.parseNumber(t.obj_id)||0,this.obj_type=t.obj_type,this},Charcoal.Admin.Widget_Object_Revisions.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Object_Revisions.prototype.constructor=Charcoal.Admin.Widget_Object_Revisions,Charcoal.Admin.Widget_Object_Revisions.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Object_Revisions.prototype.init=function(){this.bind_events()},Charcoal.Admin.Widget_Object_Revisions.prototype.bind_events=function(){var e=this;$("#"+this.id()).on("click.object.revisions",".js-obj-revert",this.revert.bind(this)),$("#"+this.id()).on("click.charcoal.bs.dialog",'[data-dismiss="dialog"]',function(t){$.isFunction(e.cancel_callback)&&e.cancel_callback(t)})},Charcoal.Admin.Widget_Object_Revisions.prototype.revert=function(t){t.preventDefault();var e=Charcoal.Admin.admin_url()+"object/revert-revision",i={obj_type:this.obj_type,obj_id:this.obj_id,rev_num:$(t.currentTarget).attr("data-rev-num")};BootstrapDialog.show({title:objectRevisionsWidgetL10n.title,message:objectRevisionsWidgetL10n.message,buttons:[{id:"ok-btn",label:objectRevisionsWidgetL10n.restore,action:function(t){t.close(),$.ajax({url:e,type:"POST",data:i,dataType:"json",success:function(t){t.success?window.location.reload():(Charcoal.Admin.feedback().push([{level:"error",message:objectRevisionsWidgetL10n.restoreError}]),Charcoal.Admin.feedback().dispatch())},error:function(){Charcoal.Admin.feedback().push([{level:"error",message:objectRevisionsWidgetL10n.restoreError}]),Charcoal.Admin.feedback().dispatch()}})}}]})},Charcoal.Admin.Widget_Object_Revisions.prototype.disable_form=Charcoal.Admin.Widget_Form.prototype.disable_form,Charcoal.Admin.Widget_Object_Revisions.prototype.enable_form=Charcoal.Admin.Widget_Form.prototype.enable_form,Charcoal.Admin.Widget_Object_Revisions.prototype.request_url=Charcoal.Admin.Widget_Form.prototype.request_url,Charcoal.Admin.Widget_Object_Revisions.prototype.request_done=Charcoal.Admin.Widget_Form.prototype.request_done,Charcoal.Admin.Widget_Object_Revisions.prototype.request_failed=Charcoal.Admin.Widget_Form.prototype.request_failed,Charcoal.Admin.Widget_Object_Revisions.prototype.request_complete=Charcoal.Admin.Widget_Form.prototype.request_complete,Charcoal.Admin.Widget_Object_Revisions.prototype.request_success=function(t,e,i){i.feedbacks&&!this.suppress_feedback()&&Charcoal.Admin.feedback(i.feedbacks),i.next_url&&Charcoal.Admin.feedback().add_action({label:commonL10n.continue,callback:function(){window.location.href=Charcoal.Admin.admin_url()+i.next_url}})},Charcoal.Admin.Widget_Quick_Form=function(t){this.EVENT_NAMESPACE=Charcoal.Admin.Widget_Quick_Form.EVENT_NAMESPACE,Charcoal.Admin.Widget.call(this,t),this.save_callback=t.save_callback||"",this.cancel_callback=t.cancel_callback||"",this.form_selector=t.data.form_selector,this.save_action=t.save_action||"object/save",this.update_action=t.update_action||"object/update",this.extra_form_data=t.extra_form_data||{},this.group_conditions=t.data.group_conditions,this.group_display_mode=t.data.group_display_mode||"",this.show_language_switch=t.data.show_language_switch||!1,this.form_working=!1,this.is_new_object=!1,this.xhr=null,this.obj_id=Charcoal.Admin.parseNumber(t.obj_id)||0},Charcoal.Admin.Widget_Quick_Form.EVENT_NAMESPACE=".charcoal.quickform",Charcoal.Admin.Widget_Quick_Form.prototype=Object.create(Charcoal.Admin.Widget_Form.prototype),Charcoal.Admin.Widget_Quick_Form.prototype.constructor=Charcoal.Admin.Widget_Quick_Form,Charcoal.Admin.Widget_Quick_Form.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Quick_Form.prototype.init=function(){this.set_properties(this.opts()),this.bind_events(),this.parse_group_conditions(),this.show_language_switch&&$('.nav-link.nav-lang[data-tab-ident="'+Charcoal.Admin.lang()+'"]').trigger("click")},Charcoal.Admin.Widget_Quick_Form.prototype.set_properties=function(){this.$form=$(this.form_selector)},Charcoal.Admin.Widget_Quick_Form.prototype.bind_events=function(){var e=this,t=this.$form;t.on("submit"+this.EVENT_NAMESPACE,function(t){t.preventDefault(),e.request_submit()}).on("click"+this.EVENT_NAMESPACE,'[data-dismiss="dialog"]',function(t){$.isFunction(e.cancel_callback)&&e.cancel_callback(t)}),this.show_language_switch&&t.on("click.nav-link.nav-lang","a.nav-link.nav-lang",function(t){t.preventDefault(),e.trigger_lang_tab($(this).attr("data-tab-ident"))})},Charcoal.Admin.Widget_Quick_Form.prototype.request_success=function(t){var e=$.Event("success"+this.EVENT_NAMESPACE,{subtype:"submission",component:this,response:t});this.$form.trigger(e),e.isDefaultPrevented()||(this.confirmed=!1,t.feedbacks&&!this.suppress_feedback()&&Charcoal.Admin.feedback(t.feedbacks),t.need_confirmation?this.add_actions_for_confirmation(t.confirmation_label):t.next_url?this.add_action_for_next_url(t.next_url,t.next_url_label):(this.enable_form(),this.form_working=!1,"function"==typeof this.save_callback&&this.save_callback(t)))},Charcoal.Admin.Widget_Quick_Form.prototype.trigger_lang_tab=function(e){$(".modal .form-field").each(function(){var t=$(this).attr("data-lang");t&&(e!==t?this.style.setProperty("display","none","important"):this.style.setProperty("display","block","important"))})},Charcoal.Admin.Widget_Relation=function(t){return Charcoal.Admin.Widget.call(this,t),this.dirty=!1,this},Charcoal.Admin.Widget_Relation.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Relation.prototype.constructor=Charcoal.Admin.Widget_Relation,Charcoal.Admin.Widget_Relation.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Relation.prototype.init=function(){var t=this.element().find(".js-relation-sortable .js-grid-container");return this.element().on("hidden.bs.collapse",'[data-toggle="collapse"]',function(){t.sortable("refreshPositions")}),t.sortable({handle:'[draggable="true"]',placeholder:"panel c-attachment_placeholder",start:function(t,e){e.item.children(".panel-heading").find('[data-toggle="collapse"]').hasClass("collapsed")||e.item.children(".panel-collapse").collapse("hide")}}).disableSelection(),this.listeners(),this},Charcoal.Admin.Widget_Relation.prototype.is_dirty=function(){return this.dirty},Charcoal.Admin.Widget_Relation.prototype.set_dirty_state=function(t){return this.dirty=t,this},Charcoal.Admin.Widget_Relation.prototype.listeners=function(){var r=this;this.element().off("click").on("click.charcoal.relation",".js-add-relation",function(t){t.preventDefault();t=$(this).data("type");if(!t)return!1;var e=$(this).data("id");e?(r.add({id:e,type:t}),r.create_relation(function(){r.reload()})):(e=$(this).data("title")||relationWidgetL10n.editObject,r.create_relation_dialog({title:e,widget_options:{form_data:{target_object_type:t,target_object_id:null}}},function(t){t.success&&(t.obj.id=t.obj_id,r.add(t.obj),r.create_relation(function(){r.reload()}))}))}).on("click.charcoal.relation",".js-relation-actions a",function(t){var e=$(this);if(e.data("action"))switch(t.preventDefault(),e.data("action")){case"edit":var i=e.data("type"),o=e.data("id");if(!i||!o)break;o=e.data("title")||relationWidgetL10n.editObject;r.create_relation_dialog({title:o,widget_options:{form_data:{target_object_type:i,target_object_id:null}}},function(t){t.success&&r.reload()});break;case"unlink":if(!e.data("id"))break;r.confirm({title:relationWidgetL10n.confirmRemoval,message:commonL10n.confirmAction,btnOKLabel:commonL10n.removeObject,callback:function(t){t&&r.remove_relation(e.data("id"),function(){r.reload()})}})}})},Charcoal.Admin.Widget_Relation.prototype.create_relation_dialog=function(t,e){t=t||{};var i=this.opts().data,i={size:BootstrapDialog.SIZE_WIDE,cssClass:"-quick-form",widget_type:"charcoal/admin/widget/quick-form",widget_options:{obj_type:"charcoal/relation/pivot",obj_id:0,form_data:{group:i.group,source_object_type:i.obj_type,source_object_id:i.obj_id,target_object_type:"",target_object_id:0}}},o=$.extend(!0,{},i,t,{}),r=this.dialog(o,function(t){if(t.success){if(!t.widget_id)return!1;Charcoal.Admin.manager().add_widget({id:t.widget_id,type:"charcoal/admin/widget/quick-form",data:{obj_type:o.widget_options.type},obj_id:o.widget_options.id,save_callback:function(t){e(t),this instanceof Charcoal.Admin.Component&&this.id()&&Charcoal.Admin.manager().destroy_component("widgets",this.id()),r.close()}}),Charcoal.Admin.manager().render()}})},Charcoal.Admin.Widget_Relation.prototype.add=function(t){if(!t)return!1;this.set_dirty_state(!0);var e=this.element().find(".js-relation-template").clone();return e.find(".js-relation").attr({"data-id":t.target_object_id,"data-type":t.target_object_type}),this.element().find(".js-relation-sortable").find(".js-grid-container").append(e),this},Charcoal.Admin.Widget_Relation.prototype.will_save=function(t){return t&&$.contains(t.element()[0],this.element()[0])},Charcoal.Admin.Widget_Relation.prototype.save=function(){return!this.is_dirty()&&(this.create_relation(),!0)},Charcoal.Admin.Widget_Relation.prototype.create_relation=function(t){var e=this,i=e.opts(),o={obj_type:i.data.obj_type,obj_id:i.data.obj_id,group:i.data.group,pivots:[]};this.element().find(".js-relation-container").find(".js-relation").each(function(t){var e=$(this),i=e.attr("data-id"),e=e.attr("data-type");o.pivots.push({target_object_id:i,target_object_type:e,position:t})}),$.post("relation/link",o,function(){"function"==typeof t&&t(),e.set_dirty_state(!1)},"json")},Charcoal.Admin.Widget_Relation.prototype.remove_relation=function(t,e){if(!t)return!1;var i=this;$.post("relation/unlink",{pivot_id:t},function(){"function"==typeof e&&e(),i.set_dirty_state(!1)},"json")},Charcoal.Admin.Widget_Relation.prototype.widget_options=function(){return this.opts("widget_options")},Charcoal.Admin.Widget_Search=function(t){return this.EVENT_NAMESPACE=Charcoal.Admin.Widget_Search.EVENT_NAMESPACE,Charcoal.Admin.Widget.call(this,t),this._elem=void 0,!!t&&(void 0!==t.id&&(this.set_element($("#"+t.id)),"object"==typeof t.data&&(this.data=t.data,this.$input=null,this._search_filters=!1,this._search_query=!1,this)))},Charcoal.Admin.Widget_Search.EVENT_NAMESPACE=".charcoal.widget.search",Charcoal.Admin.Widget_Search.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Search.prototype.constructor=Charcoal.Admin.Widget_Search,Charcoal.Admin.Widget_Search.prototype.parent=Charcoal.Admin.Widget.prototype,Charcoal.Admin.Widget_Search.prototype.widget_options=function(){return this.data},Charcoal.Admin.Widget_Search.prototype.set_remote_widget=function(){},Charcoal.Admin.Widget_Search.prototype.init=function(){var e=this,t=this.element();this.$input=t.find('[name="query"]'),t.on("submit"+this.EVENT_NAMESPACE,function(t){t.preventDefault(),e.submit()}),t.on("reset"+this.EVENT_NAMESPACE,function(t){t.preventDefault(),e.clear()})},Charcoal.Admin.Widget_Search.prototype.submit=function(){return this.set_search_query(this.$input.val()),Charcoal.Admin.manager().get_widgets().forEach(this.dispatch.bind(this)),this.set_search_query(null),this},Charcoal.Admin.Widget_Search.prototype.clear=function(){return this._search_search=!1,this._search_filters=!1,this.$input.val(""),this.submit(),this},Charcoal.Admin.Widget_Search.prototype.parse_search_query=function(t){return"string"!=typeof t||0===(t=t.trim()).length?null:t},Charcoal.Admin.Widget_Search.prototype.parse_search_filters=function(t){var e,o,r=[];return(t=this.parse_search_query(t))&&(t=t.split(/\s/),e=this.data.properties||[],$.each(t,function(t,i){o=[],i=i.replace(/'/g,"\\'"),$.each(e,function(t,e){o.push({property:e,operator:"LIKE",value:"%"+i+"%"})}),r.push({conjunction:"OR",filters:o})})),r.length?r:null},Charcoal.Admin.Widget_Search.prototype.set_search_query=function(t){this._search_search=this.parse_search_query(t),this._search_filters=!1},Charcoal.Admin.Widget_Search.prototype.search_query=function(){return!1===this._search_search?null:this._search_search},Charcoal.Admin.Widget_Search.prototype.search_filters=function(){return!1===this._search_filters&&(this._search_filters=this.parse_search_filters(this._search_search)),this._search_filters},Charcoal.Admin.Widget_Search.prototype.dispatch=function(t){if(t&&t!==this){var e="function"==typeof t.set_search_query,i="function"==typeof t.set_filter;if(!e&&!i)return this;e&&(e=this.search_query(),t.set_search_query(e)),i&&(e=this.search_filters(),t.set_filter("search",e)),void 0!==t.pagination&&(t.pagination.page=1),t.reload(null,!0)}},Charcoal.Admin.Widget_Search.prototype.destroy=function(){this.element().off(this.EVENT_NAMESPACE)},Charcoal.Admin.Widget_Table=function(t){Charcoal.Admin.Widget.call(this,t),this.obj_type=null,this.widget_id=null,this.table_selector=null,this.pagination={page:1,num_per_page:50},this.list_actions={},this.object_actions={},this.template=this.properties=this.properties_options=void 0,this.sortable=!1,this.sortable_handler=null},Charcoal.Admin.Widget_Table.prototype=Object.create(Charcoal.Admin.Widget.prototype),Charcoal.Admin.Widget_Table.prototype.constructor=Charcoal.Admin.Widget_Table,Charcoal.Admin.Widget_Table.prototype.parent=Charcoal.Admin.Widget.prototype,Object.assign(Charcoal.Admin.Widget_Table.prototype,Charcoal.Admin.Mixin_Model_Search),Object.assign(Charcoal.Admin.Widget_Table.prototype,Charcoal.Admin.Mixin_Model_Filters),Object.assign(Charcoal.Admin.Widget_Table.prototype,Charcoal.Admin.Mixin_Model_Orders),Charcoal.Admin.Widget_Table.prototype.init=function(){this.set_properties().bind_events()},Charcoal.Admin.Widget_Table.prototype.set_properties=function(){var t=this.opts();return this.obj_type=t.data.obj_type||this.obj_type,this.widget_id=t.id||this.widget_id,this.table_selector="#"+this.widget_id,this.sortable=t.data.sortable||this.sortable,this.template=t.data.template||this.template,this.collection_ident=t.data.collection_ident||"default","properties"in t.data&&Array.isArray(t.data.properties)&&(this.properties=t.data.properties),"properties_options"in t.data&&$.isPlainObject(t.data.properties_options)&&(this.properties_options=t.data.properties_options),"filters"in t.data&&this.set_filters(t.data.filters),"orders"in t.data&&this.set_orders(t.data.orders),"pagination"in t.data&&$.isPlainObject(t.data.pagination)&&(this.pagination=t.data.pagination),"list_actions"in t.data&&(Array.isArray(t.data.list_actions)?this.list_actions=Object.assign({},t.data.list_actions):$.isPlainObject(t.data.list_actions)&&(this.list_actions=t.data.list_actions)),"object_actions"in t.data&&(Array.isArray(t.data.object_actions)?this.object_actions=Object.assign({},t.data.object_actions):$.isPlainObject(t.data.object_actions)&&(this.object_actions=t.data.object_actions)),this},Charcoal.Admin.Widget_Table.prototype.bind_events=function(){null!==this.sortable_handler&&this.sortable_handler.destroy();var e=this,t=$("tbody.js-sortable",e.table_selector);0"+authL10n.postLoginRedirect+" "+authL10n.postLoginFallback.replace("[[ url ]]",i)+"
",BootstrapDialog.show({title:authL10n.loginTitle,message:t,type:BootstrapDialog.TYPE_SUCCESS,onhidden:e}),setTimeout(e,300)}).fail(function(t,e,i){var t=Charcoal.Admin.parseJqXhrResponse(t,e,i),e=r.parseFeedbackAsHtml(t)||authL10n.authFailed,o=Charcoal.Admin.recaptcha(),i=null;o.hasApi()&&(i=function(){o.getApi().reset()}),BootstrapDialog.show({title:authL10n.loginTitle,message:e,type:BootstrapDialog.TYPE_DANGER,onhidden:i})})},Charcoal.Admin.Template_Login.prototype.parseFeedbackAsHtml=function(t){if(t.feedbacks&&(t=t.feedbacks),!1===Array.isArray(t)||0===t.length)return null;if(0===t.length)return null;var e,t=Charcoal.Admin.feedback(t),i=t.getMessagesMap(),o="";for(e in i)o+=i[e].join("
");return o+="
",t.empty(),""===o?null:o},Charcoal.Admin.Template_MenuHeader=function(){$(".js-toggle-class").click(function(t){t.preventDefault();var t=$(this),e=t.data("class"),t=t.data("target");$(t).toggleClass(e)}),$(document).on("click",".js-accordion-header",function(t){t.preventDefault(),$(this).toggleClass("is-open").siblings(".js-accordion-content").stop().slideToggle()})},Charcoal.Admin.Template_Account_LostPassword=function(t){this.template_type="charcoal/admin/template/account/lost-password",this.init(t)},Charcoal.Admin.Template_Account_LostPassword.prototype=Object.create(Charcoal.Admin.Template.prototype),Charcoal.Admin.Template_Account_LostPassword.prototype.constructor=Charcoal.Admin.Template_Account_LostPassword,Charcoal.Admin.Template_Account_LostPassword.prototype.parent=Charcoal.Admin.Template.prototype,Charcoal.Admin.Template_Account_LostPassword.prototype.init=function(t){window.console.debug(t),this.bind_events()},Charcoal.Admin.Template_Account_LostPassword.prototype.bind_events=function(){var t=$("#lost-password-form");t.on("submit.charcoal.password",$.proxy(this.onSubmit,this)),window.CharcoalCaptchaResetPassCallback=this.submitForm.bind(this,t)},Charcoal.Admin.Template_Account_LostPassword.prototype.onSubmit=Charcoal.Admin.Template_Login.prototype.onSubmit,Charcoal.Admin.Template_Account_LostPassword.prototype.parseFeedbackAsHtml=Charcoal.Admin.Template_Login.prototype.parseFeedbackAsHtml,Charcoal.Admin.Template_Account_LostPassword.prototype.submitForm=function(t){var r=this,e=t.prop("action")||window.location.href,t=t.serialize();$.post(e,t,Charcoal.Admin.resolveJqXhrFalsePositive.bind(this),"json").done(function(t){var e=r.parseFeedbackAsHtml(t)||authL10n.lostPassSuccess;BootstrapDialog.show({title:authL10n.lostPassword,message:e,type:BootstrapDialog.TYPE_SUCCESS,onhidden:function(){window.location.href=t.next_url||Charcoal.Admin.admin_url("login?notice=resetpass")}})}).fail(function(t,e,i){var t=Charcoal.Admin.parseJqXhrResponse(t,e,i),e=r.parseFeedbackAsHtml(t)||authL10n.lostPassFailed,o=Charcoal.Admin.recaptcha(),i=null;o.hasApi()&&(i=function(){o.getApi().reset()}),BootstrapDialog.show({title:authL10n.lostPassword,message:e,type:BootstrapDialog.TYPE_DANGER,onhidden:i})})},Charcoal.Admin.Template_Account_ResetPassword=function(t){this.template_type="charcoal/admin/template/account/reset-password",this.init(t)},Charcoal.Admin.Template_Account_ResetPassword.prototype=Object.create(Charcoal.Admin.Template.prototype),Charcoal.Admin.Template_Account_ResetPassword.prototype.constructor=Charcoal.Admin.Template_Account_ResetPassword,Charcoal.Admin.Template_Account_ResetPassword.prototype.parent=Charcoal.Admin.Template.prototype,Charcoal.Admin.Template_Account_ResetPassword.prototype.init=function(t){window.console.debug(t),this.bind_events()},Charcoal.Admin.Template_Account_ResetPassword.prototype.bind_events=function(){var t=$("#reset-password-form");t.on("submit.charcoal.password",$.proxy(this.onSubmit,this)),window.CharcoalCaptchaChangePassCallback=this.submitForm.bind(this,t)},Charcoal.Admin.Template_Account_ResetPassword.prototype.onSubmit=Charcoal.Admin.Template_Login.prototype.onSubmit,Charcoal.Admin.Template_Account_ResetPassword.prototype.parseFeedbackAsHtml=Charcoal.Admin.Template_Login.prototype.parseFeedbackAsHtml,Charcoal.Admin.Template_Account_ResetPassword.prototype.submitForm=function(t){var r=this,e=t.prop("action")||window.location.href,t=t.serialize();$.post(e,t,Charcoal.Admin.resolveJqXhrFalsePositive.bind(this),"json").done(function(t){var e=r.parseFeedbackAsHtml(t)||authL10n.resetPassSuccess;BootstrapDialog.show({title:authL10n.passwordReset,message:e,type:BootstrapDialog.TYPE_SUCCESS,onhidden:function(){window.location.href=t.next_url||Charcoal.Admin.admin_url("login?notice=newpass")}})}).fail(function(t,e,i){var t=Charcoal.Admin.parseJqXhrResponse(t,e,i),e=r.parseFeedbackAsHtml(t)||authL10n.resetPassFailed,o=Charcoal.Admin.recaptcha(),i=null;o.hasApi()&&(i=function(){o.getApi().reset()}),BootstrapDialog.show({title:authL10n.passwordReset,message:e,type:BootstrapDialog.TYPE_DANGER,onhidden:i})})}; \ No newline at end of file diff --git a/packages/admin/assets/dist/scripts/charcoal.admin.vendors.js b/packages/admin/assets/dist/scripts/charcoal.admin.vendors.js index 44ff04243..b4d64367b 100644 --- a/packages/admin/assets/dist/scripts/charcoal.admin.vendors.js +++ b/packages/admin/assets/dist/scripts/charcoal.admin.vendors.js @@ -49801,6 +49801,28012 @@ return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems} * Licensed MIT © Zeno Rocha */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={686:function(t,e,n){"use strict";n.d(e,{default:function(){return b}});var e=n(279),i=n.n(e),e=n(370),u=n.n(e),e=n(817),r=n.n(e);function c(t){try{return document.execCommand(t)}catch(t){return}}var a=function(t){t=r()(t);return c("cut"),t};function o(t,e){var n,o,t=(n=t,o="rtl"===document.documentElement.getAttribute("dir"),(t=document.createElement("textarea")).style.fontSize="12pt",t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px",o=window.pageYOffset||document.documentElement.scrollTop,t.style.top="".concat(o,"px"),t.setAttribute("readonly",""),t.value=n,t);return e.container.appendChild(t),e=r()(t),c("copy"),t.remove(),e}var f=function(t){var e=1\s*$/g;function Nt(e,t){return b(e,"table")&&b(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Ft(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Bt(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Wt(e,t){var i,n,s,o;if(1===t.nodeType){if(g.hasData(e)&&(o=g.get(e).events))for(s in g.remove(t,"handle events"),o)for(i=0,n=o[s].length;i