1 line
No EOL
4 KiB
JavaScript
1 line
No EOL
4 KiB
JavaScript
(()=>{var e={135:(e,t,a)=>{wp.media.view.AstraSearch=a(75);var i=wp.media.View.extend({tagName:"div",className:"ast-attachments-search-wrap",initialize:function(){this.value=this.options.value},render:function(){var e=new wp.media.view.AstraSearch({controller:this.controller,model:this.model});return this.views.add(e),this}});e.exports=i},280:(e,t,a)=>{var i,s=wp.media.view.Frame;wp.media.view.AstraContent=a(135),i=s.extend({tagName:"div",className:"attachments-browser ast-attachments-browser",images:[],object:[],initialize:function(){_.defaults(this.options,{filters:!1,search:!0,date:!0,display:!1,sidebar:!0,AttachmentView:wp.media.view.Attachment.Library}),this.createContent()},createContent:function(){this.attachmentsHeading=new wp.media.view.Heading({text:astraImages.title,level:"h3",className:"ast-media-views-heading"}),this.views.add(new wp.media.view.AstraContent),this.$el.find(".ast-image__search").wrapAll('<div class="ast-image__search-wrap">').parent().html(),this.$el.find(".ast-image__search-wrap").append('<span class="ast-icon-search search-icon"></span>')},photoUploadComplete:function(e){e&&e.attachmentData&&(this.model.frame.content.mode("browse"),this.model.get("selection").add(e.attachmentData),this.model.frame.trigger("library:selection:add"),this.model.get("selection"),jQuery(".media-frame .media-button-select").click())}}),e.exports=i},75:e=>{$=jQuery;var t=wp.Backbone.View.extend({tagName:"input",className:"ast-image__search",id:"ast-image-search-input",searching:!1,images:[],attributes:{placeholder:astraImages.search_placeholder,type:"search","aria-describedby":"live-search-desc"},events:{search:"search",keyup:"search",blur:"pushState",infinite:"infinite"},initialize:function(e){this.parent=e.parent},infinite:function(e){this.doSearch(e)},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),""==e.target.value?this.$el.removeClass("has-input"):this.$el.addClass("has-input"),$scope.find(".ast-image__skeleton").animate({scrollTop:0},0),$("body").data("page",1),AstraImageCommon.infiniteLoad=!1;let t=this;setTimeout((function(){t.doSearch(e)}),1500)},doSearch:function(e){if(this.searching)return;let t=this;t.searching=!0,AstraImageCommon.config.q=e.target.value,$.ajax({url:astraImages.ajaxurl,type:"POST",data:{action:"astra-sites-search-images",params:AstraImageCommon.config,_ajax_nonce:astraImages._ajax_nonce},beforeSend:function(){console.groupCollapsed("Requesting Pixabay API")}}).fail((function(e){console.log(e),console.groupEnd()})).done((function(e){console.log("Response:"),console.log(e),console.groupEnd(),e.success&&(t.searching=!1,this.images=e.data.hits,wp.media.view.AstraAttachmentsBrowser.images=this.images),$(document).trigger("ast-image__refresh")}))},pushState:function(e){$(document).trigger("ast-image__refresh")}});e.exports=t}},t={};function a(i){var s=t[i];if(void 0!==s)return s.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,a),r.exports}!function(e){var t=function(){if(null!=wp&&wp.media){var e=jQuery,t=wp.media.view.MediaFrame.Post,i=wp.media.view.MediaFrame.Select;wp.media.view.AstraAttachmentsBrowser=a(280);const s={browseRouter(e){i.prototype.browseRouter.apply(this,arguments),e.set({astraimages:{text:astraImages.title,priority:70}})},bindHandlers(){astraImages.is_elementor_editor?t.prototype.bindHandlers.apply(this,arguments):i.prototype.bindHandlers.apply(this,arguments),this.on("content:create:astraimages",this.astraimages,this)},astraimages(t){const a=this.state();let i=new wp.media.view.AstraAttachmentsBrowser({controller:this,model:a,AttachmentView:a.get("AttachmentView")});t.view=i,wp.media.view.AstraAttachmentsBrowser.object=i,setTimeout((function(){e(document).trigger("ast-image__set-scope")}),100)}};astraImages.is_elementor_editor?wp.media.view.MediaFrame.Post=t.extend(s):wp.media.view.MediaFrame.Select=i.extend(s)}};e((function(){t(),astraImages.is_bb_active&&astraImages.is_bb_editor&&void 0!==FLBuilder&&null!==FLBuilder._singlePhotoSelector&&FLBuilder._singlePhotoSelector.on("open",(function(e){t()}))}))}(jQuery)})(); |