PluginProbe
MaxButtons – Create buttons / 6.8
MaxButtons – Create buttons v6.8
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 / responsive.js

responsive.js in MaxButtons – Create buttons 6.8, at js/responsive.js

122 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 var mbResponsive = function ($)
3 {
4 this.jquery = $;
5 }
6
7
8 mbResponsive.prototype = {
9 jquery : null,
10 mbAdmin: null,
11 }
12
13 mbResponsive.prototype.init = function (mbAdmin)
14 {
15 $ = this.jquery;
16
17 this.mbAdmin = mbAdmin;
18
19 this.checkAutoQuery();
20
21 $('input[name="auto_responsive"]').on('click', $.proxy(this.checkAutoQuery,this));
22 $('.add_media_query').on('click', $.proxy(this.addMediaQuery, this));
23 //$('.removebutton').on('click', );
24 $(document).on('click', '.removebutton', $.proxy(this.removeMediaQuery, this));
25 }
26
27 mbResponsive.prototype.checkAutoQuery = function()
28 {
29 $ = this.jquery;
30
31 if ( $('input[name="auto_responsive"]').is(':checked') )
32 {
33
34 $('.media_queries_options').hide();
35 $('.option-design.new-query').hide();
36 }
37 else
38 {
39 $('.media_queries_options').show();
40 $('.option-design.new-query').show();
41 }
42 }
43
44 mbResponsive.prototype.addMediaQuery = function()
45 {
46 $ = this.jquery;
47
48 this.mbAdmin.saveIndicator(true);
49 var new_option = $('.media_option_prot').children().clone();
50
51 var new_query = $("#new_query").val();
52 var new_title = $("#new_query :selected").text();
53 var new_desc = $("#media_desc").children('#' + new_query).text();
54
55 $(new_option).data('query', new_query);
56 $(new_option).children('input[name="media_query[]"]').val(new_query);
57 $(new_option).children('.title').text(new_title);
58 $(new_option).children('.description').text(new_desc);
59
60 if (new_query == 'custom')
61 {
62
63 $(new_option).find('.custom').removeClass('hidden');
64 }
65
66 var new_index = $('input[name="next_media_index"]').val();
67
68 // rename new field to the proper ID
69 $(new_option).find('label, select, input').each(function () {
70
71 var name = $(this).attr('name');
72 var id = $(this).attr('id');
73 var data = $(this).data('field');
74 var tagname = $(this).prop('tagName').toLowerCase();
75
76 if (typeof id !== 'undefined')
77 $(this).attr('id', id.replace('[]','[' + new_index + ']'));
78 if (typeof name !== 'undefined')
79 $(this).attr('name', name.replace('[]','[' + new_index + ']'));
80 if (typeof data !== 'undefined')
81 $(this).data('field', data.replace('[]','[' + new_index + ']'));
82 if (tagname == 'label')
83 {
84 var attrfor = $(this).attr('for');
85 if ( typeof attrfor != 'undefined')
86 $(this).attr('for', attrfor.replace('[]','[' + new_index + ']'));
87 }
88
89 })
90
91 $(document).trigger('reinitConditionals');
92
93 new_index = parseInt(new_index);
94
95 $('input[name="next_media_index"]').val( (new_index+1) );
96
97 if (new_query !== 'custom')
98 {
99 $('#new_query :selected').prop('disabled', true);
100 $('#new_query :selected').prop('selected', false);
101 }
102
103 $('.new_query_space').append(new_option);
104
105 var pos = $('.new_query_space').offset().top;
106 $(window).scrollTop( (pos-100) );
107
108 }
109
110 mbResponsive.prototype.removeMediaQuery = function(e)
111 {
112 $ = this.jquery;
113 var target = e.target;
114
115 var query = $(target).parents('.media_query').data('query');
116 $(target).parents('.media_query').fadeOut(function() { $(this).remove() } );
117
118 $('#new_query option[value="' + query + '"]').prop('disabled', false);
119 }
120
121
122