| 1 |
/** |
| 2 |
* widget.js - Contains all Widget functionality required by Photonic |
| 3 |
*/ |
| 4 |
var photonicWidgetData; |
| 5 |
jQuery(document).ready(function($) { |
| 6 |
(function(win) { |
| 7 |
"use strict"; |
| 8 |
|
| 9 |
$(document).on('click', '.photonic-wizard', function(e) { |
| 10 |
e.preventDefault(); |
| 11 |
|
| 12 |
var clicked = $(this); |
| 13 |
photonicWidgetData = $(clicked.closest('.photonic-widget').find('.photonic-shortcode')[0]); |
| 14 |
tb_show('Click to create gallery', clicked.attr('href')); |
| 15 |
}); |
| 16 |
|
| 17 |
$(document).on('change', '.photonic-shortcode', function() { |
| 18 |
var $sc_field = $(this); |
| 19 |
var $icon = $($(this).closest('.photonic-widget').find('.photonic-wizard')[0]); |
| 20 |
if (top.wp !== undefined && top.wp.shortcode !== undefined) { |
| 21 |
var shortcode = top.wp.shortcode.next(Photonic_Widget_JS.shortcode, $sc_field.attr('value')); |
| 22 |
var attrs = shortcode.shortcode.attrs.named; |
| 23 |
if ($icon.hasClass('photonic')) { |
| 24 |
var $para = $icon.siblings('p'); |
| 25 |
$para.html(Photonic_Widget_JS.edit_message); |
| 26 |
} |
| 27 |
if (attrs.type !== undefined) { |
| 28 |
$icon.attr('class', 'photonic-wizard ' + attrs.type); |
| 29 |
} |
| 30 |
else { |
| 31 |
$icon.attr('class', 'photonic-wizard wp'); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
var $sc_display = $($(this).closest('.photonic-widget').find('.photonic-shortcode-display')[0]); |
| 36 |
$sc_display.html("<h4>" + Photonic_Widget_JS.current_shortcode + "</h4>\n" + |
| 37 |
"<code>" + $sc_field.attr('value') + "</code>\n"); |
| 38 |
}); |
| 39 |
}) (window); |
| 40 |
}); |
| 41 |
|