').before(lassoDragHandle)}else a(this).append(lasso_editor.handle)})}else alert("error")})},jQuery(document).on("submit","#lasso--component-settings-form",function(b){b.preventDefault();var c=window.component,d=c.data(),e=a("#lasso-generator-insert"),f=a("#lasso--component-settings-form"),g=a(this);e.val(lasso_editor.strings.saving),g.find(".lasso-generator-attr").each(function(){var b=a(this).closest(".lasso-option").data("option");c.attr("data-"+b,a(this).val()),c.data(b,a(this).val())});var h=function(a){return delete a.sortableItem,a},i=function(b,c,d){var g=function(a){e.addClass("saved"),1==a?e.val(lasso_editor.strings.galleryCreated):e.val(lasso_editor.strings.saved)};1==b?setTimeout(function(){g()},500):1==d?(f.addClass("hide-all-fields").prepend(''),setTimeout(function(){g(!0)},500)):g(),setTimeout(function(){a("body").removeClass("lasso-sidebar-open")},c),lasso_editor.dirtyByComponent=!0};if("gallery"==d.componentType){var j={action:f.hasClass("creating-gallery")?"process_gallery_create":"process_gallery_update",postid:d.id,unique:d.unique,fields:h(d),gallery_type:a("#ase_gallery_type").val(),gallery_ids:a("#ase_gallery_ids").val(),nonce:a("#lasso-generator-nonce").val()};f.hasClass("creating-gallery")&&(j.edgallerytitle=document.getElementById("lasso--gallery__galleryname").value),a.post(lasso_editor.ajaxurl,j,function(a){"gallery-created"==a.data.message?(i(!1,1e3,!0),d.id=a.data.id):"gallery-updated"==a.data.message?(i(!1,1e3),f.before(lasso_editor.refreshRequired)):alert("error"),window.get_aesop_component_ajax(d)}).fail(function(b,c){var d=a(b.responseText).filter("title").get(0);alert(a(d).text()+"\n"+EditusFormatAJAXErrorMessage(b,c))})}else i(!0,1200);("image"==d.componentType||"quote"==d.componentType||"parallax"==d.componentType||"chapter"==d.componentType||"character"==d.componentType||"collection"==d.componentType)&&window.get_aesop_component_ajax(d)})}(jQuery),function(a){a(document).ready(function(){var b=function(){a("body").removeClass("lasso-modal-open"),a(".lasso--modal, #lasso--modal__overlay").remove(),noWarningReload&&location.reload()};jQuery(document).on("click","#lasso--post-new",function(b){b.preventDefault(),a("body").toggleClass("lasso-modal-open"),a("body").append(lasso_editor.newPostModal),a(".lasso--modal__trigger-footer").on("keyup",function(){a(".lasso--postsettings__footer").slideDown()}),modalResizer()}),jQuery(document).on("click","#lasso--modal__close, #lasso--modal__overlay, .lasso--postsettings-cancel",function(a){a.preventDefault(),b()}),a(document).keyup(function(a){27==a.keyCode&&b()});jQuery(document).on("submit","#lasso--postnew__form",function(b){b.preventDefault();var c=a(this);a(this).find('input[type="submit"]').val(lasso_editor.strings.adding);var d=c.serialize();a.post(lasso_editor.ajaxurl,d,function(b){1==b.success?(a('input[type="submit"]').addClass("saved"),a('input[type="submit"]').val(lasso_editor.strings.added),window.location.replace(b.data.postlink)):alert("error")})})}),jQuery(document).on("change","#lasso--select-type",function(){var b=a(this).val();a('input[name="object"]').val(b),a(this).closest(".story-slug-option").find("label span:not(.lasso-util--help)").text(b)})}(jQuery),function(a){a(document).ready(function(){a(lasso_editor.titleClass).on("blur",function(){var b=a(this),c={action:"process_title-update_post",postid:lasso_editor.postid,title:a.trim(b.text()),nonce:lasso_editor.titleNonce};a.post(lasso_editor.ajaxurl,c,function(a){if(1==a.success){var c="lasso-title-saved";b.addClass(c),setTimeout(function(){b.removeClass(c)},500)}}).fail(function(b,c){var d=a(b.responseText).filter("title").get(0);alert(a(d).text()+"\n"+EditusFormatAJAXErrorMessage(b,c))})})})}(jQuery),function(a){a(document).ready(function(){var b,c;a(document).on("click","#lasso--wpimg-edit",function(d){d.preventDefault();var e=a(this),f=a(this).parent().next("img").attr("class").match(/\d+/);c=d.currentTarget.parentElement.className,b=wp.media.frames.ase_edit_frame=wp.media({title:lasso_editor.strings.selectImage,button:{text:lasso_editor.strings.insertImage},multiple:!1}),b.on("open",function(){var a=b.state().get("selection"),c=wp.media.attachment(f);c.fetch(),a.add(c?[c]:[])}),b.on("select",function(){var c=b.state().get("selection").first().toJSON(),d=void 0===c.sizes.large?c.sizes.full.url:c.sizes.large.url;a(e).parent().next("img").attr({src:d,alt:c.alt,"class":"aligncenter size-large wp-image-"+c.id})}),b.open()})})}(jQuery),function(a){a(document).on("submit","#lasso--post-form",function(b){b.preventDefault();var c=a(this),d=c.find('input[type="submit"]'),e=lasso_editor.strings,f=c.serialize();d.val(e.saving),a.post(lasso_editor.ajaxurl,f,function(a){1==a.success&&(d.val(e.saved).addClass("saved"),console.log(a),setTimeout(function(){d.removeClass("saved"),d.val(e.save)},1e3))}).fail(function(b,c){var d=a(b.responseText).filter("title").get(0);alert(a(d).text()+"\n"+EditusFormatAJAXErrorMessage(b,c))})})}(jQuery),function(a){jQuery(document).ready(function(a){modalResizer=function(){var b=a(".lasso--modal"),c=b.height(),d=a(window).height(),e=a(".lasso--modal").hasClass("lasso--tour__modal")?0:30;b.css({top:(d-c-e)/2})},a(".lasso--modal").imagesLoaded(function(){modalResizer()}),jQuery(window).resize(function(){modalResizer()})})}(jQuery),function(a,b,c,d,e){function f(){a("#lasso--loading").remove()}function g(){a(p).perfectScrollbar({suppressScrollX:!0})}function h(b){"page"==b?(capable=lasso_editor.edit_others_pages,I=capable?i(b,D):i(b,D,lasso_editor.author),F=new wp.api.collections.Pages(I)):(capable=lasso_editor.edit_others_posts,I=capable?i(b,D):i(b,D,lasso_editor.author),F=new wp.api.collections.Posts(I)),F.fetch(I).done(function(){if(a("#lasso--load-more").remove(),F.length>0){var c=F.state.currentPage;c-=1;var e=a('
');F.each(function(a){e.append(n({post:a.attributes,settings:d}))}),a(p).append(e),a(p).append(z),a(".lasso--post-filtering").removeClass("not-visible").addClass("visible"),a("#lasso--load-more").attr("data-post-type",b).removeClass("lasso--btn-loading"),g()}else a(p).append(v),setTimeout(function(){a("#lasso--end-posts").fadeOut("slow")},1e3);f()}).fail(function(){a("#lasso--loading").remove(),a(p).append(w)})}function i(a,b,c){return I={data:{page:b,type:a,filter:{post_status:["publish","draft","pending"],posts_per_page:7,author:c}}}}function j(){a(B).remove()}function k(b){a(p).children().remove(),h(b),a("#lasso--search-field").val("").focusout(),a("#lasso--results-found").parent().css("opacity",0),a(C).remove(),j()}var l,m=a("#lasso-tmpl--post"),n=c.template(m.html()),o=(new wp.api.collections.Posts,new wp.api.collections.Pages,a("#lasso--post-all")),p="#lasso--post-list",q=lasso_editor.strings.loading,r=lasso_editor.strings.loadMore,s=lasso_editor.strings.noPostsFound,t=lasso_editor.strings.fetchFail,u=a("body"),v='
'+s+"",w='
'+t+"",x=lasso_editor.noResultsDiv,y='
',z='
'+r+"",A='
',B="#lasso--clear-search",C="#lasso--helper",D=1,E="post",F=!1,G=null,H=d.root,I={data:{page:D,filter:{post_status:["publish","draft","pending"]}}};a(o).on("click",function(a){a.preventDefault(),u.toggleClass("lasso-modal-open"),u.append(lasso_editor.allPostModal),h("post"),modalResizer()}),a(u).on("click","#lasso--load-more",function(b){b.preventDefault(),type=a(this).attr("data-post-type"),a(this).addClass("lasso--btn-loading").text(q),D++,E=type,h(type)}).on("click",".lasso--show-objects",function(b){b.preventDefault(),a(".lasso--show-objects").removeClass("active"),a(this).addClass("active"),a("#lasso--post-list").empty(),type=a(this).data("post-type"),D=1,G=null,a("#lasso--load-more").attr("data-post-type",type),a(p).prepend(y),h(type)}).on("click","#lasso--post__delete",function(b){b.preventDefault();var c=a(this);swal({title:lasso_editor.strings.deletePost,type:"error",text:!1,showCancelButton:!0,confirmButtonColor:"#d9534f",confirmButtonText:lasso_editor.strings.deleteYes,closeOnConfirm:!0},function(){var b={action:"process_delete_post",postid:c.closest("a").data("postid"),nonce:lasso_editor.deletePost};a.post(lasso_editor.ajaxurl,b,function(a){1==a.success&&c.closest("li").fadeOut().remove()}).fail(function(b,c){var d=a(b.responseText).filter("title").get(0);alert(a(d).text()+"\n"+EditusFormatAJAXErrorMessage(b,c))})})}).on("keyup","#lasso--search-field",function(b){clearTimeout(l);var c=b.which,e=this,f=a.trim(a(this).val()),h=f==a(e).val(),i=""!==f,k=a(".active.lasso--show-objects").data("post-type"),m=H+"/"+k+"s?filter[s]="+f+"&filter[posts_per_page]=50",o="#lasso--search-field",q=a("#lasso--results-found"),r=lasso_editor.strings.helperText,s='
'+r+"";l=setTimeout(function(){return h||i?(2!=f.length||a(C).length||(j(),a(o).after(s)),void((f.length>=3||f.length>=3&&13==c)&&(a(p).prepend(y),a(C).fadeOut().remove(),j(),a.getJSON(m,function(b){a(p).children().remove(),q.parent().css("opacity",1),0==b.length?(q.text("0"),a("#lasso--empty-results").length||a(p).prepend(x),j()):(a(B).length||a(o).after(A),q.text(b.length),a.each(b,function(c){a(p).append(n({post:b[c],settings:d}))}),g())})))):!1},600)}).on("click","#lasso--search__toggle",function(b){b.preventDefault();var c=a("#lasso--search-field");a(".lasso--search").toggleClass("lasso--search__visible"),c.focus(),a(this).parent().hasClass("lasso--search__visible")||""===c.val()||k("post")}).on("click",B,function(a){a.preventDefault(),k("post")})}(jQuery,Backbone,_,WP_API_Settings),function(a){a(document).ready(function(){destroyModal=function(){a("body").removeClass("lasso-modal-open"),a("#lasso--tour__modal,#lasso--tour__modal ~ #lasso--modal__overlay").remove()},jQuery(document).on("click",'#lasso--tour__modal input[type="submit"]',function(b){b.preventDefault();a(this);if(a("#hide_tour").is(":checked")){var c={action:"process_tour_hide",nonce:a(this).data("nonce")};a.post(lasso_editor.ajaxurl,c,function(a){1==a.success&&destroyModal()}).fail(function(b,c){var d=a(b.responseText).filter("title").get(0);alert(a(d).text()+"\n"+EditusFormatAJAXErrorMessage(b,c))})}else destroyModal()})})}(jQuery),function(a){a(document).ready(function(){function b(){a("#lasso--loading").remove()}function c(){a("body").data("revision")&&slider.slider("value",a("body").data("revision"))}function d(){a("#lasso--notice").length||a(g.article_object).before('
'+g.strings.editingBackup+"
")}function e(){a("body").removeClass(function(a,b){return(b.match(/(^|\s)lasso--revision-count-\S+/g)||[]).join(" ")})}var f,g=lasso_editor;revisionList=a("#lasso--revision-list");var h=function(){a("body").removeClass("lasso-modal-open"),a("#lasso--revision__modal").remove(),a("#lasso--post-revisions").show()},i=function(b){b in f&&(revision=f[b],a(g.titleClass).html(revision.post_title),a(g.article_object).html(revision.post_content),a("body").attr("data-revision",b))};a("#lasso--post-revisions").on("click",function(d){d.preventDefault(),a(this).hide(),a("body").append(g.revisionModal),innerModal=a("#lasso--revision__modal .lasso--modal__inner"),innerModal.draggable({cursor:"move",opacity:.8}),data={action:"process_revision_get",postid:g.postid,nonce:g.nonce},a.post(g.ajaxurl,data,function(d){if(1==d.success)if(revisionList=a("#lasso--revision-list"),slider=a("#lasso--slider"),lassoHide=a("#lasso--hide"),e(),b(),lassoHide.show(),"object"==typeof d.data&&d.data.length){f=d.data;var h=1==f.length?1:f.length-1;1!==f.length?(a.each(f,function(a,b){revisionList.append('
'+b.modified_time+"")}),slider.slider({min:0,max:h,animate:"fast",value:0,zindex:999,slide:function(a,b){i(b.value)}}),a(".lasso--jump-revision").on("click",function(b){b.preventDefault();var c=a(this).data("revision");slider.slider("value",c),i(c)}),revisionList.attr("data-count",h+1)):(lassoHide.hide(),innerModal.append(g.noRevisionsDiv)),a("body").addClass("lasso--revision-count-"+f.length),c(),modalResizer()}else a("#lasso--hide").hide(),innerModal.append(g.noRevisionsDiv),modalResizer();else alert("error")}).fail(function(b,c){var d=a(b.responseText).filter("title").get(0);alert(a(d).text()+"\n"+EditusFormatAJAXErrorMessage(b,c))}),modalResizer()}),a(document).on("click","#lasso--select-revision",function(b){b.preventDefault(),h(),a("#lasso--edit").trigger("click"),d()}).on("click","#lasso--close-modal",function(a){a.preventDefault(),h()}),a(document).keyup(function(a){27==a.keyCode&&h()})})}(jQuery);
//# sourceMappingURL=lasso.js.map
\ No newline at end of file
diff --git a/public/assets/js/source/process-gallery.js b/public/assets/js/source/process-gallery.js
index 8325020..64d6bc5 100644
--- a/public/assets/js/source/process-gallery.js
+++ b/public/assets/js/source/process-gallery.js
@@ -137,21 +137,11 @@
});
function editus_gallery_swap(galleryID){
- var data = {
- action: 'process_gallery_swap',
- gallery_id: galleryID,
- nonce: lasso_editor.swapGallNonce
- }
-
- $.post( lasso_editor.ajaxurl, data, function(response) {
- if( true == response.success ) {
- // window.component is the current component being edited
- window.component.replaceWith( response.data.gallery );
- }
- }).fail(function(xhr, err) {
- var responseTitle= $(xhr.responseText).filter('title').get(0);
- alert($(responseTitle).text() + "\n" + EditusFormatAJAXErrorMessage(xhr, err) );
- });
+ var data = {
+ componentType: 'gallery',
+ id: galleryID
+ };
+ window.get_aesop_component_ajax(data);
}
///////////
@@ -175,8 +165,11 @@
}
function ase_encode_gallery_items(){
- var imageArray = gallery.sortable('toArray');
- $('#ase_gallery_ids').val( imageArray );
+ gallery = $('#lasso--gallery__images #ase-gallery-images');
+ if (gallery.length) {
+ var imageArray = gallery.sortable('toArray');
+ $('#ase_gallery_ids').val( imageArray );
+ }
}
// inserting gallery items
diff --git a/public/assets/js/source/process-save-component.js b/public/assets/js/source/process-save-component.js
index b8fb68e..719bded 100644
--- a/public/assets/js/source/process-save-component.js
+++ b/public/assets/js/source/process-save-component.js
@@ -1,6 +1,53 @@
(function( $ ) {
var form;
+ // get updated aesop componets through ajax calls (global function)
+ window.get_aesop_component_ajax = function(cdata)
+ {
+ var data = {
+ action: 'get_aesop_component',
+ code: 'aesop_'+cdata['componentType']
+ };
+ for ( var index in cdata ) {
+ // Don't accept componentType as a param
+ if ( !cdata.hasOwnProperty(index) || index == 'componentType' || index =='sortableItem') {
+ continue;
+ }
+ data[index] = cdata[index];
+ }
+
+ jQuery.post(lasso_editor.ajaxurl2, data, function(response) {
+ if( response ){
+ var $a = $(response);
+ window.component.replaceWith($a);
+ window.component = $a;
+ $('.aesop-component').each(function(){
+
+ // if there's no toolbar present
+ if ( !$('.lasso-component--toolbar').length > 0 ) {
+
+ // if this is a map then we need to first wrap it so that we can drag the map around
+ if ( $(this).hasClass('aesop-map-component') ) {
+
+ var $this = $(this)
+
+ // so wrap it with a aesop-compoentn aesop-map-component div
+ // @todo - note once a map is inserted it can't be edited after saving again. a user has to delete the existin map and add a new map
+ // to
+ //$this.wrap('