var debugEl; var hooks = []; var layers = []; var layer_increment = 0; var presets = []; var active = false; presets[1] = '[[],[{"type":"text","shadow_color":"f5f500","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":-1,"shadow_blur":4,"shadow_spread":0,"layer_name":"Yellow"},{"type":"text","shadow_color":"e07b00","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":-4,"shadow_blur":8,"shadow_spread":0,"layer_name":"Orange"},{"type":"text","shadow_color":"ff1100","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":-5,"shadow_blur":16,"shadow_spread":0,"layer_name":"Red"}]]'; presets[2] = '[[],[{"type":"text","shadow_color":"ff1cff","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":3,"shadow_spread":0,"layer_name":"Layer 0"},{"type":"text","shadow_color":"b314b3","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":7,"shadow_spread":0,"layer_name":"Layer 1"},{"type":"text","shadow_color":"850d85","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":10,"shadow_spread":0,"layer_name":"Layer 2"},{"type":"text","shadow_color":"470b47","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":16,"shadow_spread":0,"layer_name":"Layer 3"},{"type":"text","shadow_color":"290029","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":23,"shadow_spread":0,"layer_name":"Layer 4"}]]'; presets[3] = '[[],[{"type":"text","shadow_color":"7700ff","shadow_inset":false,"shadow_offset_x":1,"shadow_offset_y":1,"shadow_blur":0,"shadow_spread":0,"layer_name":"Layer 5"},{"type":"text","shadow_color":"0040ff","shadow_inset":false,"shadow_offset_x":1,"shadow_offset_y":-1,"shadow_blur":0,"shadow_spread":0,"layer_name":"Layer 6"},{"type":"text","shadow_color":"ff0048","shadow_inset":false,"shadow_offset_x":-1,"shadow_offset_y":-1,"shadow_blur":0,"shadow_spread":0,"layer_name":"Layer 7"},{"type":"text","shadow_color":"ffdd00","shadow_inset":false,"shadow_offset_x":-1,"shadow_offset_y":1,"shadow_blur":0,"shadow_spread":0,"layer_name":"Layer 8"}]]'; presets[4] = '[[{"type":"box","shadow_color":"d7e854","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":30,"shadow_spread":7,"layer_name":"Glow"},{"type":"box","shadow_color":"c0d900","shadow_inset":true,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":3,"shadow_spread":0,"layer_name":"Inner glow"}],[]]'; presets[5] = '[[{"type":"box","shadow_color":"0fa37e","shadow_inset":false,"shadow_offset_x":-3,"shadow_offset_y":0,"shadow_blur":6,"shadow_spread":0,"layer_name":"Layer 6"},{"type":"box","shadow_color":"ff0033","shadow_inset":false,"shadow_offset_x":3,"shadow_offset_y":3,"shadow_blur":6,"shadow_spread":0,"layer_name":"Layer 5"},{"type":"box","shadow_color":"ffea00","shadow_inset":false,"shadow_offset_x":3,"shadow_offset_y":-3,"shadow_blur":6,"shadow_spread":0,"layer_name":"Layer 7"}],[]]'; presets[6] = '[[{"type":"box","shadow_color":"000000","shadow_inset":true,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":11,"shadow_spread":1,"layer_name":"Layer 0"}],[{"type":"text","shadow_color":"000000","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":5,"shadow_spread":0,"layer_name":"Layer 1"}]]'; presets[7] = '[[],[{"type":"text","shadow_color":"85f5d9","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":-1,"shadow_blur":4,"shadow_spread":0,"layer_name":"Light"},{"type":"text","shadow_color":"00ff8c","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":-4,"shadow_blur":8,"shadow_spread":0,"layer_name":"Mid"},{"type":"text","shadow_color":"003369","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":-5,"shadow_blur":16,"shadow_spread":0,"layer_name":"Dark"}]]'; presets[8] = '[[],[{"type":"text","shadow_color":"938cc9","shadow_inset":false,"shadow_offset_x":12,"shadow_offset_y":12,"shadow_blur":11,"shadow_spread":0,"layer_name":"Layer 0"},{"type":"text","shadow_color":"80bbd6","shadow_inset":false,"shadow_offset_x":-15,"shadow_offset_y":2,"shadow_blur":16,"shadow_spread":0,"layer_name":"Layer 1"},{"type":"text","shadow_color":"3c48d6","shadow_inset":false,"shadow_offset_x":3,"shadow_offset_y":-4,"shadow_blur":22,"shadow_spread":0,"layer_name":"Layer 2"},{"type":"text","shadow_color":"a3edff","shadow_inset":false,"shadow_offset_x":-6,"shadow_offset_y":10,"shadow_blur":27,"shadow_spread":0,"layer_name":"Layer 3"},{"type":"text","shadow_color":"ffffff","shadow_inset":false,"shadow_offset_x":0,"shadow_offset_y":0,"shadow_blur":11,"shadow_spread":0,"layer_name":"Layer 43"}]]'; hooks['colorbutton_preview_background'] = function(hex, el){ $('#fieldset_preview').css({'background-color' : "#" + hex}); }; hooks['colorbutton_preview_box'] = function(hex, el){ $('#fieldset_preview textarea').css({'background-color' : "#" + hex}); }; hooks['colorbutton_preview_text'] = function(hex, el){ $('#fieldset_preview textarea').css({'color' : "#" + hex}); }; hooks['colorbutton_shadow_color'] = function(hex, el){ current_layer.shadow_color = "#" + hex; }; hooks['slider_blur'] = function(value){ current_layer.shadow_blur = value; }; hooks['slider_offset_x'] = function(value){ current_layer.shadow_offset_x = value; }; hooks['slider_offset_y'] = function(value){ current_layer.shadow_offset_y = value; }; hooks['slider_spread'] = function(value){ current_layer.shadow_spread = value; }; hooks['colorbutton_shadow_color'] = function(hex, el){ current_layer.shadow_color = hex; }; function ShadowLayer(is_text_layer) { if(is_text_layer == true) { this.type = "text"; } else { this.type = "box"; } this.shadow_color = "000000"; this.shadow_inset = false; this.shadow_offset_x = 0; this.shadow_offset_y = 0; this.shadow_blur = 0; this.shadow_spread = 0; this.layer_name = ""; } function initialize() { $('.colorfield .colorbutton').ColorPicker({ onSubmit: function(hsb, hex, rgb, el) { var id_self = $(el).attr('id'); $(el).parent().children('input').val(hex); $(el).css({'background-color': '#' + hex}); if(hooks[id_self]) { hooks[id_self](hex, el); update_preview(); } }, onBeforeShow: function () { $(this).ColorPickerSetColor($(this).parent().children('input').val()); }, onShow: function (colpkr) { $(colpkr).fadeIn(500); return false; }, onHide: function (colpkr) { $(colpkr).fadeOut(500); return false; } }) .bind('keyup', function(){ $(this).ColorPickerSetColor($(this).parent().children('input').val()); }); $('.sortable').sortable({ placeholder: "listbox-item-placeholder", containment: "parent", distance: 8, update: function(){ update_preview(); } }); $('.sortable').disableSelection(); $('#setting_inset').buttonset(); $('.slider').slider({ slide: function(event, ui){ $(ui.handle).parent().parent().children('input').val(ui.value); hooks[$(ui.handle).parent().attr('id')](ui.value); // Run the specified hook update_preview(); }, min: 0, max: 30, }); $('.slider-negative').slider({ slide: function(event, ui){ $(ui.handle).parent().parent().children('input').val(ui.value); hooks[$(ui.handle).parent().attr('id')](ui.value); // Run the specified hook update_preview(); }, min: -30, max: 30, }); $('.slider-field').children('input').change(function(){ var slider_element = $(this).parent().children('.slider, .slider-negative'); slider_element.slider("value", $(this).val()); hooks[slider_element.attr('id')]($(this).val()); // Run the specified hook update_preview(); }); $('#input_inset, #input_outset').change(function(){ //alert(0); if($('#input_inset:checked').val() !== undefined) { current_layer.shadow_inset = true; } else { current_layer.shadow_inset = false; } update_preview(); }); $('#settings').hide(); rebind(); } function rebind() { $('.listbox-item').click(function(){ var layer_id = $(this).children('.layer-id').text(); select_layer(layer_id) }); } function add_layer(is_text_layer) { if(is_text_layer == true) { var target = "#layers_text"; } else { var target = "#layers_box"; } var new_layer = new ShadowLayer(is_text_layer); layers[layer_increment] = new_layer; new_layer.layer_name = "Layer " + layer_increment; $(target).append('