PluginProbe
MaxButtons – Create buttons / 7.1.1
MaxButtons – Create buttons v7.1.1
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / js / maxbuttons-admin.js

maxbuttons-admin.js in MaxButtons – Create buttons 7.1.1, at js/maxbuttons-admin.js

858 lines 20.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var $ = jQuery;
2
3 function maxAdmin()
4 {
5
6 //return this;
7 }
8 maxAdmin.prototype = {
9 //initialized: false,
10 colorUpdateTime: true,
11 fields: null,
12 button_id: null,
13 form_updated: false,
14 tabs: null,
15 }; // MaxAdmin
16
17 maxAdmin.prototype.init = function () {
18
19 this.button_id = $('input[name="button_id"]').val();
20 // Prevents the output button from being clickable (also in admin list view )
21 $(document).on('click', ".maxbutton-preview", function(e) { e.preventDefault(); });
22 $(document).on('click', '.output .preview-toggle', $.proxy(this.toggle_preview, this));
23
24 // overview input paging
25 $('#maxbuttons .input-paging').on('change', $.proxy(this.do_paging, this));
26
27 $('.manual-toggle').on('click', $.proxy(this.toggleManual, this));
28 $('.manual-entry').draggable({
29 cancel: 'p, li',
30 });
31
32 $(document).on('submit', 'form.mb_ajax_save', $.proxy(this.formAjaxSave, this));
33
34 // copy / delete / trash action buttons via ajax
35 $(document).on('click', '[data-buttonaction]', $.proxy(this.button_action, this ));
36
37 // conditionals
38 $(document).on('reInitConditionals', $.proxy(this.initConditionials, this));
39 this.initConditionials(); // conditional options
40 // range inputs
41
42 $(document).on('change, input', 'input[type="range"]', $.proxy(this.updateRange, this ));
43 this.updateRange(null);
44
45 /*
46 ****
47 ### After this only init for button main edit screen
48 ****
49
50 */
51 if ($('#new-button-form').length == 0)
52 return;
53
54
55 if (this.button_id > 0) {
56 $("#maxbuttons .mb-message").show();
57 }
58
59 this.initResponsive(); // responsive edit interface
60
61 $("#maxbuttons .output").draggable({
62 cancel: '.nodrag',
63 });
64
65 $('#maxbuttons .color-field').wpColorPicker(
66 {
67 width: 300,
68
69 change: $.proxy( _.throttle(function(event, ui) {
70 event.preventDefault();
71 var color = ui.color.toString();
72 this.update_color(event,ui, color);
73 }, 200), this),
74
75 }
76 );
77
78 /* Copy Color Interface */
79 $('.input.mbcolor .arrows').on('click', $.proxy(this.copyColor, this) );
80
81 $('#radius_toggle').on('click', $.proxy(this.toggleRadiusLock,this));
82
83 if ( typeof buttonFieldMap != 'undefined')
84 this.fields = $.parseJSON(buttonFieldMap);
85
86 // bind to all inputs, except for color-field or items with different handler.
87 $('#maxbuttons input').not('.color-field').on('keyup change', $.proxy(this.update_preview,this));
88 $('#maxbuttons input.color-field').on('focus', $.proxy(this.select_field, this));
89
90 $('#maxbuttons select').on('change', $.proxy(this.update_preview, this));
91
92 $(window).on('beforeunload', $.proxy(function () { if (this.form_updated) return maxajax.leave_page; }, this));
93 $(document).on('keyup', 'input', function (e) {
94
95 if (e.keyCode && e.keyCode == 13)
96 {
97 $(":input")[$(":input").index(document.activeElement) + 1].focus();
98 return false;
99 }
100 });
101
102 $(".button-save").click( $.proxy(function() {
103 this.saveIndicator(false); // prevent alert when saving.
104 $("#new-button-form").submit();
105 return false;
106 }, this) );
107
108 // Expand shortcode tabs for more examples.
109 $('.shortcode-expand').on('click', this.toggleShortcode);
110
111 }; // INIT
112
113
114 maxAdmin.prototype.repaint_preview = function ()
115 {
116 $('.mb_tab input[type="text"]').trigger('change');
117 $('.mb_tab input[type="number"]').trigger('change');
118 $('.mb_tab select').trigger('change');
119 $('.mb_tab input[type="hidden"]').trigger('change');
120 $('.mb_tab input[type="radio"]:checked').trigger('change');
121 $('.mb_tab input[type="checkbox"]:checked').trigger('change');
122
123 //$(document).trigger('colorUpdate', ['#text_color', $('#text_color').val() ]);
124 //$(document).trigger('colorUpdate', ['#text_color_hover', $('#text_color_hover').val() ]);
125
126 }
127
128 maxAdmin.prototype.update_preview = function(e)
129 {
130 e.preventDefault();
131
132 this.saveIndicator(true);
133 var target = $(e.target);
134
135 // migration to data field
136 var field = $(target).data('field');
137 if (typeof field == 'undefined')
138 var id = $(target).attr('id'); // this should change to be ready for the option to have two the same fields on multi locations.
139 else
140 var id = field;
141
142 var data = this.fields[id];
143
144 if (typeof data == 'undefined')
145 return; // field doesn't have updates
146
147 if (typeof data.css != 'undefined')
148 {
149 value = target.val();
150
151 if (typeof data.css_unit != 'undefined' && value.indexOf(data.css_unit) == -1)
152 value += data.css_unit;
153
154 // a target that is checkbox but not checked should unset (empty) value.
155 if (target.is(':checkbox') && ! target.is(':checked') )
156 value = '';
157
158 this.putCSS(data, value);
159 }
160 if (typeof data.attr !== 'undefined')
161 {
162 $('.output .result').find('a').attr(data.attr, target.val());
163 }
164 if (typeof data.func !== 'undefined')
165 {
166 var funcName = data.func;
167 var self = this;
168 if (funcName.indexOf('.') < 0)
169 {
170 funcName = 'self.' + funcName + '(target)';
171 }
172 else {
173 funcName = funcName + '(target)';
174 }
175
176 try
177 {
178 var callFunc = new Function ('target', 'self', funcName);
179 callFunc(target, this);
180 }
181 catch(err)
182 {
183 console.log(err);
184 }
185
186 }
187 };
188
189 maxAdmin.prototype.select_field = function(e)
190 {
191 $(e.target).select();
192 }
193
194 maxAdmin.prototype.button_action = function(e)
195 {
196 e.preventDefault();
197 var action = $(e.target).data('buttonaction');
198
199 this.form_updated = false;
200
201 var button_id = $(e.target).data('buttonid');
202 var nonce = $('input[name="' + action + '_nonce"]').val();
203
204 var url = maxajax.ajax_url;
205 var data =
206 {
207 action: 'mb_button_action',
208 button_action: action,
209 button_id: button_id,
210 nonce: nonce,
211
212 };
213
214 $.post({
215 url: url,
216 data: data,
217 success: function (data) {
218 response = JSON.parse(data);
219
220 if (typeof response.redirection != 'undefined')
221 {
222 window.location = response.redirection;
223 }
224 },
225 error: function () {
226 console.log('error in button action' + action);
227 },
228 });
229 }
230
231 /* Check the copy modal and display a warning if the button has been changes */
232 maxAdmin.prototype.checkCopyModal = function(modal)
233 {
234 if (this.form_updated)
235 {
236 modal.currentModal.find('.mb-message').show();
237
238 }
239 else
240 $(modal.currentModal).find('.mb-message').hide();
241 }
242
243 maxAdmin.prototype.toggle_preview = function (e)
244 {
245 if ( $('.output .inner').is(':hidden') )
246 {
247 $('.output .inner').show();
248 $('.output').css('height', 'auto');
249 $('.preview .preview-toggle').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-up');
250 }
251 else
252 {
253 $('.output .inner').hide();
254 $('.output').css('height', 'auto');
255 $('.preview .preview-toggle').removeClass('dashicons-arrow-up').addClass('dashicons-arrow-down');
256 }
257 };
258
259
260 maxAdmin.prototype.putCSS = function(data,value,state)
261 {
262 state = state || 'both';
263
264 var element = '.maxbutton';
265 if (state == 'hover')
266 element = 'a.hover ';
267 else if(state == 'normal')
268 element = 'a.normal ';
269
270 if (typeof data.csspart != 'undefined')
271 {
272 var parts = data.csspart.split(",");
273 for(i=0; i < parts.length; i++)
274 {
275 var cpart = parts[i];
276 var fullpart = element + " ." + cpart;
277 $('.output .result').find(fullpart).css(data.css, value);
278 }
279 }
280 else
281 $('.output .result').find(element).css(data.css, value);
282 }
283
284 maxAdmin.prototype.update_color = function(event, ui, color)
285 {
286 event.preventDefault();
287 this.saveIndicator(true);
288
289 var target = $(event.target);
290 //var color = target.val();
291
292 if (color.indexOf('#') === -1)
293 color = '#' + color;
294
295 var id = target.attr('id');
296 $('#' + id).val(color); // otherwise field value is running 1 click behind.
297
298
299 if(id.indexOf('box_shadow') !== -1)
300 {
301 this.updateBoxShadow(target);
302 }
303 else if(id.indexOf('text_shadow') !== -1)
304 {
305 this.updateTextShadow(target);
306 }
307 else if (id.indexOf('gradient') !== -1)
308 {
309 if (id.indexOf('hover') == -1)
310 this.updateGradient();
311 else
312 this.updateGradient(true);
313 }
314 else if (id == 'button_preview')
315 {
316 $(".output .result").css('backgroundColor', color);
317 }
318 else // simple update
319 {
320
321 if (id.indexOf('hover') == -1)
322 {
323 state = 'normal';
324 }
325 else
326 {
327 state = 'hover';
328 }
329
330 var data = this.fields[id];
331
332 this.putCSS(data, color, state);
333 return;
334 }
335
336
337 };
338
339 maxAdmin.prototype.copyColor = function (e)
340 {
341 e.preventDefault();
342 e.stopPropagation(); // stop the color picker from closing itself.
343
344 var target = $(e.target);
345 var bindto = $(e.target).parents('[data-bind]');
346 var fieldId = '#' + bindto.data('id'); // Field which is used
347 var bindId = '#' + bindto.data('bind'); // Field is bound to.
348
349 // check which arrow was pressed
350 if (target.hasClass('arrow-right'))
351 var arrow_click = 'right';
352 else
353 var arrow_click = 'left';
354
355 // check on which side the interface is. If arrows are on right side, it's the left side (...)
356 if (bindto.hasClass('right') )
357 var if_side = 'left';
358 else
359 var if_side = 'right';
360
361 /* Decide which color to replace. If interface is left - then right click is copy to other element, but if interface is right, right is overwrite current element.
362 Left : right click - copy, left replace.
363 Right : right click - replace, left copy.
364 */
365 if (if_side == 'left')
366 {
367 if (arrow_click == 'right')
368 copy = true;
369 else
370 copy = false;
371 }
372 else if (if_side == 'right')
373 {
374 if (arrow_click == 'right')
375 copy = false;
376 else
377 copy = true;
378 }
379
380 if ( copy )
381 {
382 $(bindId).val( $(fieldId).val() );
383 $(bindId).trigger('change');
384 $(bindId).wpColorPicker('color', $(fieldId).val());
385 }
386 else
387 {
388 $(fieldId).val( $(bindId).val() );
389 $(fieldId).trigger('change');
390 $(fieldId).wpColorPicker('color', $(bindId).val());
391 }
392
393 }
394
395 maxAdmin.prototype.updateGradient = function(hover)
396 {
397 hover = hover || false;
398
399 var hovtarget = '';
400 if (hover)
401 hovtarget = "_hover";
402
403 var stop = parseInt($('#gradient_stop').val());
404
405 if (isNaN(stop) )
406 stop = 45;
407
408 var gradients_on = $('#use_gradient').prop('checked');
409
410 var start = this.hexToRgb($('#gradient_start_color' + hovtarget).val());
411 var end = this.hexToRgb($('#gradient_end_color' + hovtarget).val());
412 var startop = parseInt($('#gradient_start_opacity' + hovtarget).val());
413 var endop = parseInt($('#gradient_end_opacity' + hovtarget).val());
414
415 if (! gradients_on)
416 {
417 end = start;
418 endop = startop;
419 }
420
421 if(isNaN(startop)) startop = 100;
422 if(isNaN(endop)) endop = 100;
423
424 if (!hover)
425 var button = $('.output .result').find('a.normal');
426 else
427 var button = $('.output .result').find('a.hover');
428
429
430
431
432 button.css("background", "linear-gradient( rgba(" + start + "," + (startop/100) + ") " + stop + "%," + " rgba(" + end + "," + (endop/100) + ") )");
433 button.css("background", "-moz-linear-gradient( rgba(" + start + "," + (startop/100) + ") " + stop + "%," + " rgba(" + end + "," + (endop/100) + ") )");
434 button.css("background", "-o-linear-gradient( rgba(" + start + "," + (startop/100) + ") " + stop + "%," + " rgba(" + end + "," + (endop/100) + ") )");
435 button.css("background", "-webkit-gradient(linear, left top, left bottom, color-stop(" +stop+ "%, rgba(" + start + "," + (startop/100) + ")), color-stop(1, rgba(" + end + "," + (endop/100) + ") ));");
436
437
438 }
439
440 maxAdmin.prototype.hexToRgb = function(hex) {
441
442 hex = hex.replace('#','');
443 var bigint = parseInt(hex, 16);
444 var r = (bigint >> 16) & 255;
445 var g = (bigint >> 8) & 255;
446 var b = bigint & 255;
447
448 return r + "," + g + "," + b;
449 }
450
451 maxAdmin.prototype.updateBoxShadow = function (target)
452 {
453 target = target || null;
454
455 var left = $("#box_shadow_offset_left").val();
456 var top = $("#box_shadow_offset_top").val();
457 var width = $("#box_shadow_width").val();
458 var spread = $('#box_shadow_spread').val();
459
460 var color = $("#box_shadow_color").val();
461 var hovcolor = $("#box_shadow_color_hover").val();
462
463 $('.output .result').find('a.normal').css("boxShadow",left + 'px ' + top + 'px ' + width + 'px ' + spread + 'px ' + color);
464 $('.output .result').find('a.hover').css("boxShadow",left + 'px ' + top + 'px ' + width + 'px ' + spread + 'px ' + hovcolor);
465 }
466
467 maxAdmin.prototype.updateTextShadow = function(target,hover)
468 {
469 hover = hover || false;
470
471 var left = $("#text_shadow_offset_left").val();
472 var top = $("#text_shadow_offset_top").val();
473 var width = $("#text_shadow_width").val();
474
475 var color = $("#text_shadow_color").val();
476 var hovcolor = $("#text_shadow_color_hover").val();
477
478 var id = $(target).attr('id');
479 var data = this.fields[id];
480
481 data.css = 'textShadow';
482
483 var value = left + 'px ' + top + 'px ' + width + 'px ' + color;
484 this.putCSS(data, value, 'normal');
485
486 value = left + 'px ' + top + 'px ' + width + 'px ' + hovcolor;
487 this.putCSS(data, value, 'hover');
488
489 }
490
491 maxAdmin.prototype.updateAnchorText = function (target)
492 {
493 var preview_text = $('.output .result').find('a .mb-text');
494
495 // This can happen when the text is removed, button is saved, so the preview doesn't load the text element.
496 if (preview_text.length === 0)
497 {
498 $('.output .result').find('a').append('<span class="mb-text"></span>');
499 $('.output .result').find('a .mb-text').css({'display':'block','line-height':'1em','box-sizing':'border-box'});
500
501 this.repaint_preview();
502 }
503 $('.output .result').find('a .mb-text').text(target.val());
504 }
505
506 maxAdmin.prototype.updateGradientOpacity = function(target)
507 {
508 this.updateGradient(true);
509 this.updateGradient(false);
510 }
511
512 maxAdmin.prototype.updateDimension = function (target)
513 {
514 var dimension = $(target).val();
515 var id = $(target).attr('id');
516 var data = this.fields[id];
517 if (dimension > 0)
518 this.putCSS(data, dimension);
519 else
520 this.putCSS(data, 'auto');
521 }
522
523 maxAdmin.prototype.updateRadius = function(target)
524 {
525 var value = target.val();
526 var fields = ['radius_bottom_left', 'radius_bottom_right', 'radius_top_left', 'radius_top_right'];
527
528 if ( $('#radius_toggle').data('lock') == 'lock')
529 {
530 for(i=0; i < fields.length; i++)
531 {
532 var id = fields[i];
533 $('#' + id).val(value);
534 var data = this.fields[id];
535 this.putCSS(data,value + 'px');
536
537 }
538
539 }
540 }
541
542 maxAdmin.prototype.toggleRadiusLock = function (event)
543 {
544 var target = $(event.target);
545 var lock = $(target).data('lock');
546 if (lock == 'lock')
547 {
548 $(target).removeClass('dashicons-lock').addClass('dashicons-unlock');
549 $(target).data('lock', 'unlock');
550 }
551 else if (lock == 'unlock')
552 {
553 $(target).removeClass('dashicons-unlock').addClass('dashicons-lock');
554 $(target).data('lock', 'lock');
555 }
556
557 }
558
559
560 maxAdmin.prototype.initResponsive = function()
561 {
562
563 window.maxFoundry.maxadmin.responsive = new mbResponsive();
564 window.maxFoundry.maxadmin.responsive.init(this);
565
566 }
567
568
569 maxAdmin.prototype.do_paging = function(e)
570 {
571 var page = parseInt($(e.target).val());
572
573 if (page <= parseInt($(e.target).attr('max')) )
574 {
575 var url = $(e.target).data("url");
576 window.location = url + "&paged=" + page;
577
578 }
579 }
580
581
582 maxAdmin.prototype.toggleShortcode = function (e)
583 {
584 if ($('.shortcode-expand').hasClass('closed'))
585 {
586 $(' .mb-message.shortcode .expanded').css('display','inline-block');
587 $('.shortcode-expand span').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-up');
588 $('.shortcode-expand').removeClass('closed').addClass('open');
589 }
590 else
591 {
592 $(' .mb-message.shortcode .expanded').css('display','none');
593 $('.shortcode-expand span').addClass('dashicons-arrow-down').removeClass('dashicons-arrow-up');
594 $('.shortcode-expand').addClass('closed').removeClass('open');
595 }
596
597 }
598
599 maxAdmin.prototype.toggleManual = function (e)
600 {
601 e.preventDefault();
602 var $target = $(e.target);
603
604 var subject = $target.data("target");
605 var $newWindow = $('.manual-entry[data-manual="' + subject + '"]');
606
607 if ($newWindow.is(':visible'))
608 {
609 $newWindow.hide();
610 return true;
611 }
612
613 var offset = $('[data-options="' + subject + '"]').position() ;
614 // top + height to position under manual link.
615 var top = offset.top + $target.height();
616
617 $newWindow.css('top', top);
618 $newWindow.css('right',15);
619 $newWindow.css('left', 'auto');
620
621 $newWindow.show();
622 }
623
624 maxAdmin.prototype.initConditionials = function ()
625 {
626 var mAP = this;
627 $('[data-show]').each(function () {
628 var condition = $(this).data('show');
629 var target = condition.target;
630 var values = condition.values;
631 var self = this;
632
633 $(document).on('change','[name="' + target + '"]', {child: this, values: values}, $.proxy(mAP.updateConditional, mAP) );
634
635 if ( $('[name="' + target + '"]').length > 1) // trigger change to test condition
636 {
637 $('[name="' + target + '"]:checked').trigger('change', ['conditional']); // radio / checkbox button
638 }
639 else {
640 $('[name="' + target + '"]').trigger('change', ['conditional']);
641 }
642 });
643
644 // problem here is fields having same target, will add the same event over and over //
645 // the target, input array, have a lot of input fields, which all receive the events. this is the issue.
646
647 var updatelist = [];
648
649 $('[data-has]').each(function () {
650 var condition = $(this).data('has');
651 var target = condition.target;
652 var values = condition.values;
653
654
655 $('[name="' + target + '"]').on('change', {target: target, child: this, values: values}, $.proxy(mAP.updateHasConditional, mAP) );
656
657 var targetdecl = '[name="' + target + '"]';
658 if (! $.inArray(targetdecl, updatelist));
659 updatelist.push(targetdecl);
660 });
661
662 if (updatelist.length > 0)
663 {
664 // the issue will a lot of event checking still exist..
665 $(updatelist.toString()).first().trigger('change', ['conditional']);
666 }
667
668 }
669
670 maxAdmin.prototype.updateConditional = function (event)
671 {
672 var data = event.data;
673 var cond_values = data.values;
674 var cond_child = data.child;
675
676 var target = $(event.currentTarget);
677 var value = $(target).val();
678
679 // if type = checkbox: cond_value checked means it has to be 'checked' to show. Otherwise 'unchecked' go hide.
680 if (target.attr('type') === 'checkbox')
681 {
682
683 var checked = $(target).prop('checked');
684
685 if (cond_values == 'checked' && checked)
686 value = 'checked';
687 else if (cond_values == 'unchecked' && !checked)
688 value = 'unchecked';
689 else
690 value = 0;
691 }
692
693 if (cond_values.indexOf(value) >= 0)
694 {
695
696 $(cond_child).fadeIn('fast');
697 $(cond_child).find('input, select').trigger('change');
698 }
699 else
700 {
701 $(cond_child).fadeOut('fast');
702 $(cond_child).find('input, select').trigger('change');
703 }
704 }
705
706 maxAdmin.prototype.updateHasConditional = function(event)
707 {
708 var mAP = this;
709 var data = event.data;
710
711 var cond_values = data.values;
712 var cond_child = data.child;
713
714 var target = data.target;
715
716 var hascond = false;
717
718 /** The issue here is to change this calls, to searches directly for value form cond_values ( mostly 1-3 options ) and not run the entire DOM each time.
719 */
720 var filter = [];
721 $(cond_values).each(function (el)
722 {
723
724 filter.push( '[value=' + this + ']');
725 } );
726
727 if ($('[name="' + target + '"]').filter( filter.toString() ).length > 0)
728 {
729 hascond = true;
730 }
731 else {
732 hascond = false
733 }
734
735 if (hascond)
736 {
737 $(cond_child).fadeIn('fast');
738 }
739 else
740 {
741 $(cond_child).fadeOut('fast');
742 }
743
744 }
745
746 maxAdmin.prototype.updateRange = function (event)
747 {
748 if (typeof event == 'undefined' || event === null )
749 {
750 var targets = $('input[type="range"]');
751 }
752 else
753 {
754 var targets = [event.target];
755 }
756
757 $(targets).each(function () {
758 var value = $(this).val();
759 $(this).parents('.input').find('.range_value output').val(value + '%');
760
761 });
762
763 }
764
765 maxAdmin.prototype.saveIndicator = function(toggle)
766 {
767
768 if (toggle)
769 this.form_updated = true;
770 else
771 this.form_updated = false;
772 }
773
774 // General AJAX form save
775 maxAdmin.prototype.formAjaxSave = function (e)
776 {
777 e.preventDefault();
778 var url = mb_ajax.ajaxurl;
779 var form = $(e.target);
780
781 var data = form.serialize();
782
783
784 $.ajax({
785 type: "POST",
786 url: url,
787 data: data,
788
789 }).done($.proxy(this.saveDone, this));
790 }
791
792 /*
793 maxAdmin.prototype.buttonSubmit = function (e)
794 {
795
796 e.preventDefault();
797 $('[data-form]').prop('disabled', true);
798 var formName = $(e.target).data('form');
799 $('#' + formName).submit();
800
801 }
802 */
803
804 maxAdmin.prototype.saveDone = function (res)
805 {
806 $('[data-form]').prop('disabled', false);
807
808 var json = $.parseJSON(res);
809
810 var result = json.result;
811 var title = json.title;
812
813
814 var collection_id = json.data.id;
815
816 if (typeof json.data.new_nonce !== 'undefined')
817 {
818 var nonce = json.data.new_nonce;
819 $('input[name="nonce"]').val(json.data.new_nonce);
820 }
821
822 if (result)
823 {
824 // if collection is new - add collection_id to the field
825 $('input[name="collection_id"]').val(collection_id);
826
827 // replace the location to the correct collection
828 var href = window.location.href;
829 if (href.indexOf('collection_id') === -1)
830 window.history.replaceState({}, '', href + '&collection_id=' + collection_id);
831
832 // trigger other updates if needed
833 $(document).trigger('mbFormSaved');
834
835 // update previous selection to current state;
836 var order = $('input[name="sorted"]').val();
837 $('input[name="previous_selection"]').val(order);
838
839 // in case the interface needs to be reloaded.
840 if (json.data.reload)
841 {
842 document.location.reload(true);
843 }
844
845 }
846 if (! result)
847 {
848 $modal = window.maxFoundry.maxModal;
849 $modal.newModal('collection_error');
850 $modal.setTitle(title);
851 $modal.setContent(json.body);
852
853 $modal.setControls('<button class="modal_close button-primary">' + json.close_text + '</button>');
854 $modal.show();
855
856 }
857 }
858