PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.6.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.6.0
4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 3.8.0 All 110 releases
wp-optimize / js / modal.js

modal.js in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.6.0, at js/modal.js

69 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 How to use the modal
3
4 wp_optimize.modal.open({
5 className: 'a-class', // A class name, added to the main modal container
6 events: {}, // An object containing the events added to the modal. See Backbonejs View events syntax.
7 content: function() {
8 return ''; // the Content method returns html or jQuery objects which will be added to the content area of the modal
9 },
10 ... // Other methods used by the custom events
11 })
12 */
13
14 var wp_optimize = window.wp_optimize || {};
15
16 (function($, wp) {
17 'use strict';
18 var modal = {};
19 modal.views = {};
20
21 /**
22 * Main modal View
23 */
24 modal.views.modal = Backbone.View.extend({
25 tagName: 'div',
26 template: wp.template('wpo-modal'),
27 /**
28 * Extend default values
29 */
30 preinitialize: function() {
31 this.events = _.extend(this.events || {}, {
32 'click .wpo-modal--close': 'close'
33 });
34 this.className = this.className ? 'wpo-modal--container ' + this.className : 'wpo-modal--container ';
35 },
36 render: function() {
37 this.$el.append(this.template());
38 this.trigger('rendered');
39 },
40 initialize: function() {
41 this.trigger('initialize');
42 this.render();
43 this.$content = this.$el.find('.wpo-modal--content');
44 // Append the content area with the content provided by the child object
45 if ('function' === typeof this.content) {
46 this.$content.append(this.content());
47 }
48 },
49 close: function() {
50 $('body').removeClass('wpo-modal-is-opened');
51 this.remove();
52 }
53 });
54
55 /**
56 * Public method to create and open the modal
57 */
58 modal.open = function(options) {
59 var view_options = _.extend(options || {}, {});
60 var modalView = modal.views.modal.extend(view_options);
61 var m = new modalView();
62 m.$el.appendTo('body');
63 m.$('.wpo-modal').focus();
64 $('body').addClass('wpo-modal-is-opened');
65 return m;
66 }
67
68 wp_optimize.modal = modal;
69 })(jQuery, window.wp);