PluginProbe
Social Share Buttons / 1.6
Social Share Buttons v1.6
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
share-button / js / network-editor.js

network-editor.js in Social Share Buttons 1.6, at js/network-editor.js

178 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 jQuery(document).ready(function($) {
3
4 mbsEditor = function ()
5 {
6 var maxAdmin;
7 }
8
9 mbsEditor.prototype.init = function ()
10 {
11 this.maxAdmin = window.maxFoundry.maxadmin;
12
13 $(document).on('maxajax_success_network-settings', $.proxy(this.showSettings, this) );
14 $(document).on('maxajax_success_save-network', $.proxy(this.settingsUpdated, this) );
15 $(document).on('maxajax_success_remove-networksettings', $.proxy(this.settingsUpdated, this));
16 $(document).on('maxajax_success_show-customnetworks', $.proxy(this.showCustomNetworks, this));
17
18 $(document).on('maxajax_success_import-customnetworks', $.proxy(this.networksImported, this));
19
20 }
21
22 mbsEditor.prototype.showSettings = function(e, result, status)
23 {
24 result = JSON.parse(result);
25
26 if (result.output)
27 {
28 $('.network_editor .inside').html(result.output);
29 if (result.title)
30 {
31 $('.network_editor .title').html(result.title);
32 }
33 }
34
35 this.doColorPicker();
36 $(document).trigger('mbsocial-editor-settings-loaded');
37 window.maxFoundry.maxadmin.initConditionials();
38 $('#icon_type').trigger('change'); // manual update, to fix
39 window.maxFoundry.maxSocial.form_updated = false; // loading is not changing
40
41 }
42
43 mbsEditor.prototype.doColorPicker = function()
44 {
45 colorPalette = (mbpro_options.colorPalette !== '' ? mbpro_options.colorPalette : true);
46
47 // colors
48 $('.maxbuttons-social .network_editor .color-field').wpColorPicker(
49 {
50 width: 300,
51 palettes: colorPalette,
52 change: $.proxy( _.throttle(function(event, ui) {
53 event.preventDefault();
54 var target = $(event.target);
55 var color = ui.color.toString();
56
57 if (color.indexOf('#') === -1)
58 color = '#' + color;
59
60 var id = target.attr('id');
61 $('#' + id).val(color).trigger('change');
62
63 }, 200), this),
64 }
65 );
66 }
67
68 mbsEditor.prototype.showCustomNetworks = function (e, result, status)
69 {
70 var result = JSON.parse(result);
71 if (result.status == 'error')
72 {
73 $('.network_editor .inside').html('<h4 class="load-error">' + result.message + '</h4>');
74 }
75 else {
76 $('.network_editor .inside').html(result.output);
77
78 if (result.title)
79 {
80 $('.network_editor .title').html(result.title);
81 }
82 $('.network_editor ul li').off();
83 $('.network_editor ul li').on('click', $.proxy(this.toggleCustom, this));
84
85 }
86 }
87
88 mbsEditor.prototype.networksImported = function (e, result)
89 {
90
91 this.notifySaved(e, result);
92 window.location.reload(true);
93 }
94
95 mbsEditor.prototype.toggleCustom = function (e)
96 {
97 var target = $(e.target);
98 if (! $(target).hasClass('the_network'))
99 {
100 target = $(target).parents('.the_network');
101 }
102
103 if ( $(target).hasClass('selected'))
104 {
105 $(target).removeClass('selected');
106 }
107 else {
108 $(target).addClass('selected');
109 }
110
111 var selected = $('.network_editor ul li.selected');
112 var count = $(selected).length;
113
114 $('.cns-toolbar .selected').html(count);
115
116 if (count > 0)
117 {
118 $('.cns-toolbar button').prop('disabled', false);
119 }
120 else {
121 $('.cns-toolbar button').prop('disabled', true);
122 }
123
124 var networks = [];
125 $(selected).each(function()
126 {
127 networks.push($(this).data('network'));
128
129 })
130 $('#selected_custom').val(networks.join(','));
131
132 }
133
134 mbsEditor.prototype.settingsUpdated = function(e, result, status)
135 {
136 if (typeof result !== 'object')
137 var parsed_result = JSON.parse(result);
138
139 if (parsed_result.output)
140 this.showSettings(e, result, status);
141
142 this.notifySaved(e, result, status);
143
144 if (parsed_result.reload)
145 {
146 window.location.reload(true);
147 }
148 }
149
150 mbsEditor.prototype.networkRemoved = function(e, result, status)
151 {
152
153 }
154
155 mbsEditor.prototype.notifySaved = function(e,result,status)
156 {
157
158 if (typeof result !== 'object')
159 var result = JSON.parse(result);
160 var modal = window.maxFoundry.maxmodal;
161
162 modal.newModal('save_done');
163 modal.setTitle(result.title);
164 modal.setContent('');
165 modal.show();
166
167 this.form_updated = false; // set updated to false
168 window.maxFoundry.maxSocial.form_updated = false;
169 window.setTimeout( function () { modal.fadeOut(); }, 1000);
170 }
171
172 if (typeof window.maxFoundry === 'undefined')
173 window.maxFoundry = {};
174
175 window.maxFoundry.maxSocialSettings = new mbsEditor();
176 window.maxFoundry.maxSocialSettings.init();
177 }); // jquery
178