PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 2.28
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v2.28
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / include / scripts / admin / gallery-settings.js

gallery-settings.js in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 2.28, at include/scripts/admin/gallery-settings.js

81 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 var media = wp.media;
3
4 // Wrap the render() function to append controls.
5 media.view.Settings.Gallery = media.view.Settings.Gallery.extend({
6 render: function() {
7 var $el = this.$el;
8
9 media.view.Settings.prototype.render.apply( this, arguments );
10
11 if (Photonic_Admin_JS.shortcode !== 'gallery') {
12 return;
13 }
14
15 // Append the type template and update the settings.
16 $el.append( media.template( 'photonic-editor-default' ) );
17 $el.find('.photonic-form .hint').remove();
18
19 //media.gallery.defaults.type = 'default'; // lil hack that lets media know there's a type attribute.
20 //this.update.apply( this, ['type'] );
21
22 if (tinymce !== undefined && tinymce.activeEditor !== undefined && tinymce.activeEditor !== null && tinymce.activeEditor.selection !== undefined) {
23 var node = tinymce.activeEditor.selection.getNode();
24 var shortcode = wp.mce.views.getText(node);
25 var shortcodeObj = wp.shortcode.next(Photonic_Admin_JS.shortcode, shortcode);
26 var attrs = shortcodeObj.shortcode.attrs.named;
27 //var attrs = this.model.attributes;
28
29 var gallery = this;
30
31 $.each(attrs, function(name, value) {
32 media.gallery.defaults[name] = '';
33 gallery.update.apply( gallery, [name] );
34
35 var field = $el.find('.photonic-form [name="' + name + '"]');
36 if (field.length > 0) {
37 field = field[0];
38 if (field.nodeName === 'INPUT') {
39 field.value = value;
40 }
41 else if (field.nodeName === 'SELECT') {
42 var defaultValue = field.value;
43 var options = field.children;
44 var oneSelected = false;
45 $.each(options, function(i, v) {
46 options[i].selected = options[i].value === value;
47 if (options[i].value === value) {
48 oneSelected = true;
49 }
50 });
51 if (!oneSelected) {
52 $.each(options, function(i, v) {
53 options[i].selected = options[i].value === defaultValue;
54 if (options[i].value === defaultValue) {
55 return false;
56 }
57 });
58 }
59 }
60 }
61 });
62
63 var inputFields = $el.find('.photonic-form input, .photonic-form select');
64 $(inputFields).on('change', function() {
65 var insertCode = '[' + Photonic_Admin_JS.shortcode + ' type="default"';
66 //var newCode = e.data;
67 $.each(inputFields, function(idx, obj) {
68 if (obj.value !== '') {
69 insertCode += ' ' + obj.name + "='" + $('<div/>').text(decodeURIComponent(obj.value)).html() + "'";
70 }
71 gallery.model.attributes[obj.name] = obj.value;
72 });
73 insertCode += ']';
74 $(node).attr('data-wpview-text', encodeURIComponent(insertCode));
75 });
76 }
77 return this;
78 }
79 });
80 })(jQuery);
81