ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

material-icons-icon-control.js (1421B)


      1 (function (root, $) {
      2 
      3 	function openMIManager(title, callback, single) {
      4 
      5 		var frame = root.wp.media.cp.extendFrameWithMDI(root.wp.media.view.MediaFrame.Select);
      6 		custom_uploader = new frame({
      7 			title: title,
      8 			button: {
      9 				text: ficTexts.media_button_label
     10 			},
     11 			multiple: !single
     12 		});
     13 		root.wp.media.cp.MIFrame = custom_uploader;
     14 
     15 
     16 		root.wp.media.cp.MIFrame.on('select', function () {
     17 			attachment = custom_uploader.state().get('selection').toJSON();
     18 			root.wp.media.cp.MIFrame.content.mode('browse');
     19 			callback(attachment);
     20 		});
     21 		root.wp.media.cp.MIFrame.on('close', function () {
     22 			root.wp.media.cp.MIFrame.content.mode('browse');
     23 			callback(false);
     24 		});
     25 
     26 
     27 		root.wp.media.cp.MIFrame.open();
     28 		root.wp.media.cp.MIFrame.content.mode('cp_material_icons');
     29 
     30 		root.jQuery(custom_uploader.views.selector).parent().css({
     31 			'z-index': '16000000'
     32 		});
     33 
     34 	}
     35 
     36 	wp.customize.controlConstructor['material-icons-icon-control'] = wp.customize.Control.extend({
     37 
     38 		ready: function () {
     39 
     40 			'use strict';
     41 
     42 			var control = this;
     43 
     44 			// Change the value
     45 			this.container.on('click', 'i.mdi , button', function () {
     46 				openMIManager(ficTexts.media_title, function (response) {
     47 
     48 					if (!response) {
     49 						return;
     50 					}
     51 					var value = response[0].mdi;
     52 
     53 					control.container.find('i.mdi').attr('class','mdi ' + value);
     54 					control.setting.set(value);
     55 
     56 				}, false);
     57 			});
     58 
     59 		}
     60 
     61 	});
     62 
     63 })(window, jQuery);