Import legacy nurinda.co.id website
This commit is contained in:
1 parent
3f59bb9038
commit
6e21646ac4
13389 files changed
+3246690
No files matched your search
@@ -0,0 +1,175 @@
|
||||
(function($)
|
||||
{
|
||||
"use strict";
|
||||
$.SmileTrigger = $.SmileTrigger || {};
|
||||
$.SmileTrigger.wp_media = $.SmileTrigger.wp_media || [];
|
||||
$.SmileTrigger.media_new = function()
|
||||
{
|
||||
var $body = $("body");
|
||||
$body.on('click', '.smile_upload_icon', $.SmileTrigger.media_new_activate );
|
||||
};
|
||||
//intended for zip files only. if needed should be easy to expand in the future
|
||||
$.SmileTrigger.media_new_activate = function( event )
|
||||
{
|
||||
event.preventDefault();
|
||||
var clicked = $(this), options = clicked.data();
|
||||
options.input_target = $('#'+options.target);
|
||||
// Create the media frame.
|
||||
var file_frame = wp.media(
|
||||
{
|
||||
frame: options.frame,
|
||||
library: { type: options.type },
|
||||
button: { text: options.button },
|
||||
className: options['class']
|
||||
});
|
||||
file_frame.on( 'select update insert', function(){ $.SmileTrigger.media_new_insert( file_frame , options); });
|
||||
//open the media frame
|
||||
file_frame.open();
|
||||
};
|
||||
//insert the url of the zip file
|
||||
$.SmileTrigger.media_new_insert = function( file_frame , options )
|
||||
{
|
||||
var state = file_frame.state(), selection = state.get('selection').first().toJSON();
|
||||
options.input_target.val(selection.id).trigger('change')
|
||||
$("body").trigger(options.trigger, [selection, options]);
|
||||
}
|
||||
$(document).ready(function ()
|
||||
{
|
||||
$.SmileTrigger.media_new();
|
||||
//Fonts Zip file upload
|
||||
$("body").on('smile_insert_zip', $.SmileTrigger.icon_insert);
|
||||
//font manager
|
||||
$("body").on('click', '.smile_del_icon', $.SmileTrigger.icon_remove);
|
||||
});
|
||||
/************************************************************************
|
||||
EXTRA FUNCTIONS, NOT NECESSARY FOR THE DEFAULT UPLOAD
|
||||
*************************************************************************/
|
||||
$.SmileTrigger.icon_insert = function(event, selection, options)
|
||||
{
|
||||
// clean the options field, we dont need to save a value
|
||||
options.input_target.val("");
|
||||
var manager = $('.smile_iconfont_manager');
|
||||
var msg = $('#msg');
|
||||
var proceed = (selection.subtype == 'zip' || selection.subtype == 'x-zip') ? true : false;
|
||||
if(proceed == false)
|
||||
{
|
||||
$('.spinner').hide();
|
||||
msg.html("<div class='error'><p>Please upload a valid ZIP file.<br/>You can create the file on icomoon.io</p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
}, 5000);
|
||||
return;
|
||||
}
|
||||
// send request to server to extract the zip file, re arrange the content and save a config file
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
data:
|
||||
{
|
||||
action: 'smile_ajax_add_zipped_font',
|
||||
security: uavc.add_zipped_font,
|
||||
values: selection,
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$('.spinner').css({opacity:0, display:"block", visibility:'visible',position:'absolute', top:'21px', left:'345px'}).animate({opacity:1});
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
$('.spinner').hide();
|
||||
msg.html("<div class='error'><p>Couldn\'t add the font because the server didn’t respond. Please reload the page, then try again.</p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
}, 5000);
|
||||
},
|
||||
success: function(response)
|
||||
{
|
||||
$('.spinner').hide();
|
||||
if(response.match(/smile_font_added/))
|
||||
{
|
||||
msg.html("<div class='updated'><p>Font icon added successfully! Reloading the page... </p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
location.reload();
|
||||
}, 5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.html("<div class='error'><p>Couldn't add the font.<br/>The script returned the following error: "+response+"</p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
}, 5000);
|
||||
}
|
||||
if(typeof console != 'undefined') console.log(response);
|
||||
//msg.fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
$.SmileTrigger.icon_remove = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var button = $(this),
|
||||
parent = button.parents('.smile-available-font:eq(0)'),
|
||||
manager = button.parents('.smile_iconfont_manager:eq(0)'),
|
||||
all_fonts = manager.find('.smile-available-font'),
|
||||
del_font = button.data('delete');
|
||||
//alert(del_font);
|
||||
var msg = $('#msg');
|
||||
// send request to server to remove the folder and the database entry
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
data:
|
||||
{
|
||||
action: 'smile_ajax_remove_zipped_font',
|
||||
del_font: del_font,
|
||||
security: uavc.remove_zipped_font
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$('.spinner').css({opacity:0, display:"block", visibility:'visible',position:'absolute', top:'21px', left:'345px'}).animate({opacity:1});
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
$('.spinner').hide();
|
||||
msg.html("<div class='error'><p>Couldn't remove the font because the server didn’t respond.<br/>Please reload the page, then try again</p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
}, 5000);
|
||||
},
|
||||
success: function(response)
|
||||
{
|
||||
$('.spinner').hide();
|
||||
if(response.match(/smile_font_removed/))
|
||||
{
|
||||
msg.html("<div class='updated'><p>Icon set deleted successfully! Reloading the page...</p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
location.reload();
|
||||
}, 5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.html("<p><div class='error'><p>Couldn't remove the font.<br/>Reloading the page...</p></div>");
|
||||
msg.show();
|
||||
setTimeout(function() {
|
||||
msg.slideUp();
|
||||
location.reload();
|
||||
}, 5000);
|
||||
}
|
||||
if(typeof console != 'undefined') console.log(response);
|
||||
//msg.fadeOut('slow');
|
||||
},
|
||||
complete: function(response)
|
||||
{
|
||||
//alert(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,22 @@
|
||||
jQuery(window).load(function(e) {
|
||||
var update = jQuery(".update-plugins");
|
||||
|
||||
var plugin_counter = update.find(".plugin-count").html();
|
||||
plugin_counter = parseInt(plugin_counter)+1;
|
||||
jQuery(".plugin-count").html(plugin_counter);
|
||||
|
||||
update.removeClass("count-0").addClass("count-"+plugin_counter);
|
||||
update.find(".update-count").html(plugin_counter);
|
||||
jQuery("#wp-admin-bar-updates").find(".ab-label").html(plugin_counter);
|
||||
|
||||
jQuery("#ultimate-addons-for-visual-composer").addClass("update");
|
||||
var html = '<tr class="plugin-update-tr">\
|
||||
<td colspan="3" class="plugin-update colspanchange">\
|
||||
<div class="update-message">There is a new version of Ultimate Addons for WPBakery Page Builder available. \
|
||||
<a href="update-core.php#brainstormforce-plugins">Check update details.</a>\
|
||||
</div>\
|
||||
</td>\
|
||||
</tr>';
|
||||
jQuery(html).insertAfter("#ultimate-addons-for-visual-composer");
|
||||
|
||||
});
|
||||
+1094
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(){jQuery("body").on("change",".btn_hover_style",function(){var o=jQuery(this).data("option");"_"==o?(jQuery(".icon_hover_color").closest("div.wpb_el_type_colorpicker").css({display:"none"}),jQuery(".icon_color_hoverbg").closest("div.wpb_el_type_colorpicker").css({display:"none"}),jQuery(".icon_color_hoverborder").closest("div.wpb_el_type_colorpicker").css({display:"none"}),jQuery(".btn_iconhover_color").closest("div.wpb_el_type_colorpicker").css({display:"none"}),jQuery(".btn_icon_color_hoverbg").closest("div.wpb_el_type_colorpicker").css({display:"none"}),jQuery(".btn_icon_color_hoverborder").closest("div.wpb_el_type_colorpicker").css({display:"none"})):(jQuery(".icon_hover_color").closest("div.wpb_el_type_colorpicker").css({display:"block"}),jQuery(".icon_color_hoverbg").closest("div.wpb_el_type_colorpicker").css({display:"block"}),jQuery(".icon_color_hoverborder").closest("div.wpb_el_type_colorpicker").css({display:"block"}),jQuery(".btn_iconhover_color").closest("div.wpb_el_type_colorpicker").css({display:"block"}),jQuery(".btn_icon_color_hoverbg").closest("div.wpb_el_type_colorpicker").css({display:"block"}),jQuery(".btn_icon_color_hoverborder").closest("div.wpb_el_type_colorpicker").css({display:"block"}))})});
|
||||
@@ -0,0 +1,28 @@
|
||||
jQuery(document).ready(function() {
|
||||
//alert('hi');
|
||||
|
||||
//console.log(this.model.get("params"));
|
||||
/*jQuery("body").on("click",".vc_control-btn-edit",function(){
|
||||
|
||||
//var element = jQuery(this).parents('.vc_element:first');
|
||||
//var model_id = jQuery(element).data('model-id');
|
||||
//console(model_id);
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
jQuery("body").on("click",".vc_panel-btn-save",function(){
|
||||
|
||||
var data = jQuery(this).parent().parent();
|
||||
|
||||
var dp=data.find(".wpb_edit_form_elements").data('title');//console.log(dp);
|
||||
if(dp=='Edit Dual Button'){
|
||||
jQuery(".ult_main_dualbtn").each(function() {
|
||||
console.log('1');
|
||||
var t=jQuery(".ult_dual1").css({"height","100px"});
|
||||
//console.log(t);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,409 @@
|
||||
$gf = jQuery.noConflict();
|
||||
$gf(document).ready(function () {
|
||||
$gf('body').on('click', '#refresh-google-fonts', function () {
|
||||
$gf(this).next('.spinner').css({'display':'inline-block','float':'none','vertical-align': 'middle','visibility':'visible'});
|
||||
var data = {
|
||||
action: 'ultimate_google_fonts_refresh',
|
||||
security: uavc.google_font_nonce,
|
||||
};
|
||||
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
||||
$gf.post(ajaxurl, data, function(response) {
|
||||
var object = jQuery.parseJSON(response);
|
||||
var count = object.count;
|
||||
var msg = object.message;
|
||||
if(count == 0)
|
||||
{
|
||||
var dmsg = msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dmsg = msg+' Please wait, Page is reloading.';
|
||||
window.location.reload(true);
|
||||
}
|
||||
$gf('#vc-gf-msg').html('<div class="updated">'+dmsg+'</div>').hide();
|
||||
$gf('#vc-gf-msg').slideDown(300);
|
||||
$gf('#refresh-google-fonts').next('.spinner').css({'display':'none'});
|
||||
setTimeout(function(){
|
||||
$gf('#vc-gf-msg').slideUp(300);
|
||||
},4000);
|
||||
});
|
||||
});
|
||||
$gf('body').on('click', '.add-google-font', function () {
|
||||
var button = $gf(this);
|
||||
var font_family = $gf(this).attr('data-font_family');
|
||||
var font_name = $gf(this).attr('data-font_name');
|
||||
if(!button.hasClass('font-added'))
|
||||
{
|
||||
button.next('.spinner').show();
|
||||
button.next('.spinner').css({'float':'right','visibility':'visible'});
|
||||
|
||||
var variants_array = new Array();
|
||||
var subsets_array = new Array();
|
||||
button.parent().find('.variants').find('.font-variant').each(function (iv, variant) {
|
||||
$v = $gf(variant);
|
||||
var temp_arr = {};
|
||||
var variant_value = $v.find('.font-variant-inputs').val();
|
||||
temp_arr['variant_value'] = variant_value;
|
||||
if ($v.find('.font-variant-inputs').is(':checked')) {
|
||||
temp_arr['variant_selected'] = true;
|
||||
}
|
||||
else {
|
||||
temp_arr['variant_selected'] = false;
|
||||
}
|
||||
variants_array.push(temp_arr);
|
||||
});
|
||||
button.parent().find('.subsets').find('.font-subset').each(function (iv, subset) {
|
||||
$s = $gf(subset);
|
||||
var temp_arr = {};
|
||||
var subset_value = $s.find('.font-subset-inputs').val();
|
||||
temp_arr['subset_value'] = subset_value;
|
||||
if ($s.find('.font-subset-inputs').is(':checked')) {
|
||||
temp_arr['subset_selected'] = true;
|
||||
}
|
||||
else {
|
||||
temp_arr['subset_selected'] = false;
|
||||
}
|
||||
subsets_array.push(temp_arr);
|
||||
});
|
||||
var data = {
|
||||
action: 'add_google_font',
|
||||
font_family: font_family,
|
||||
font_name: font_name,
|
||||
variants: variants_array,
|
||||
subsets: subsets_array,
|
||||
security: uavc.add_google_fonts
|
||||
};
|
||||
$gf.post(ajaxurl, data, function(response) {
|
||||
// console.log(response);
|
||||
button.next('.spinner').hide();
|
||||
button.val('Added in collection');
|
||||
button.addClass('font-added');
|
||||
//if(variants_array.length > 0)
|
||||
if(variants_array.length > 0 || subsets_array.length > 0)
|
||||
var xclass = 'have-variants';
|
||||
else
|
||||
var xclass = '';
|
||||
|
||||
var gshtml = '<div class="selected-font"><div class="selected-font-top fopened '+xclass+'"><div class="font-header" style="font-family:\''+font_name+'\'">'+font_name+'</div>';
|
||||
if(variants_array.length > 0)
|
||||
gshtml += '<i class="dashicons dashicons-arrow-down"></i>';
|
||||
gshtml += '<div class="clear"></div></div><span class="font-delete" data-font_name="'+font_name+'"><i class="dashicons dashicons-no-alt"></i></span>';
|
||||
|
||||
if(variants_array.length > 0 || subsets_array.length > 0)
|
||||
{
|
||||
gshtml += '<div class="selected-font-content" style="display:block">';
|
||||
|
||||
if(temp = font_name.split(' '))
|
||||
{
|
||||
var ctemp = temp.length;
|
||||
var temp_id = '';
|
||||
$gf.each(temp,function (i, val) {
|
||||
temp_id += val;
|
||||
if ((ctemp-1) != i)
|
||||
temp_id += '-';
|
||||
})
|
||||
}
|
||||
else
|
||||
var temp_id = font_name;
|
||||
|
||||
var temp_subset_class = '';
|
||||
|
||||
if(variants_array.length > 0)
|
||||
{
|
||||
gshtml += '<div class="selected-font-varient-wrapper">';
|
||||
$gf.each(variants_array, function(index, variant){
|
||||
var lid = temp_id+'-dynamic-'+variant.variant_value+'-'+index;
|
||||
var font_style = 'font-family:\''+font_name+'\';';
|
||||
if(/italic/i.test(variant.variant_value)) {
|
||||
font_style += 'font-style:italic;';
|
||||
}
|
||||
var weight = 'normal';
|
||||
if (weight = variant.variant_value.match(/\d+/)) {
|
||||
font_style += 'font-weight:'+weight+';';
|
||||
}
|
||||
gshtml += '<span class="font-variant"><input type="checkbox" id="'+lid+'" value="'+variant.variant_value+'" class="selected-variant-checkbox" /><label style="'+font_style+'" for="'+lid+'">'+variant.variant_value+'</label></span>';
|
||||
});
|
||||
gshtml += '</div>';
|
||||
temp_subset_class = 'selected-font-subset-wrapper';
|
||||
}
|
||||
|
||||
if(subsets_array.length > 0)
|
||||
{
|
||||
gshtml += '<div class="'+temp_subset_class+'">';
|
||||
$gf.each(subsets_array, function(index, subset){
|
||||
var lid = temp_id+'-dynamic-subset-'+subset.subset_value+'-'+index;
|
||||
gshtml += '<span class="font-subset"><input type="checkbox" id="'+lid+'" value="'+subset.subset_value+'" class="selected-subset-checkbox" /><label for="'+lid+'">'+subset.subset_value+'</label></span>';
|
||||
});
|
||||
gshtml += '</div>';
|
||||
}
|
||||
|
||||
gshtml += '<input type="button" class="button alignleft update-google-font-button" value="Update font" data-font_name="'+font_name+'" /><span class="spinner fspinner"></span><div class="clear"></div></div>';
|
||||
}
|
||||
|
||||
gshtml += '</div>';
|
||||
$gf('#fonts-selected-wrapper').prepend(gshtml);
|
||||
});
|
||||
}
|
||||
});
|
||||
$gf('body').on('click', '.font-delete', function () {
|
||||
$gf('.google-font-overlay').remove();
|
||||
$gf('.google-font-confirmation').remove();
|
||||
var button = $gf(this);
|
||||
var font_name = $gf(this).attr('data-font_name');
|
||||
$gf('body').append('<div class="google-font-overlay"></div>');
|
||||
$gf('body').append('<div class="google-font-confirmation"><div class="google-font-confirmation-header"><h3>Are you sure you want to remove this font?</h3></div><div class="google-font-message"><input type="button" id="" data-gfont_name="'+font_name+'" class="google-font-message-buttons google-font-message-delete gfont-buttons" value="Yes"/><input type="button" id="" class="google-font-message-buttons google-font-message-no-delete gfont-buttons" value="No"/></div><a href="javacript:void(0)" class="gfont-anchor-buttons gfont-buttons google-font-message-no-delete"><i class="dashicons dashicons-no-alt"></i></a></div>');
|
||||
$gf('.google-font-overlay').fadeIn(100);
|
||||
$gf('.google-font-confirmation').fadeIn(100);
|
||||
});
|
||||
$gf('body').on('click', '.gfont-buttons', function(){
|
||||
if($gf(this).hasClass('google-font-message-delete'))
|
||||
{
|
||||
var font_name = $gf(this).attr('data-gfont_name');
|
||||
var data = {
|
||||
action: 'delete_google_font',
|
||||
font_name: font_name,
|
||||
security: uavc.delete_google_fonts
|
||||
};
|
||||
$gf.post(ajaxurl, data, function(response) {
|
||||
$gf('.font-delete').each(function(i,e){
|
||||
var button = $gf(this);
|
||||
var bfont_name = $gf(this).attr('data-font_name');
|
||||
if(bfont_name == font_name)
|
||||
button.parent().remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
$gf('.google-font-confirmation').fadeOut(200);
|
||||
$gf('.google-font-overlay').fadeOut(200);
|
||||
});
|
||||
$gf('body').on('click', '.update-google-font-button', function () {
|
||||
var font_name = $gf(this).attr('data-font_name');
|
||||
var parent = $gf(this).parent();
|
||||
var variant_array = new Array();
|
||||
var subset_array = new Array();
|
||||
$gf(parent).find('.font-variant').each(function (index, variant_wrap) {
|
||||
var temp_array = {};
|
||||
var variant_checkbox = $gf(variant_wrap).find('.selected-variant-checkbox');
|
||||
temp_array['variant_value'] = $gf(variant_checkbox).val();
|
||||
if ($gf(variant_checkbox).is(':checked'))
|
||||
temp_array['variant_selected'] = true;
|
||||
else
|
||||
temp_array['variant_selected'] = false;
|
||||
variant_array.push(temp_array);
|
||||
});
|
||||
$gf(parent).find('.font-subset').each(function (index, subset_wrap) {
|
||||
var temp_array = {};
|
||||
var subset_checkbox = $gf(subset_wrap).find('.selected-subset-checkbox');
|
||||
temp_array['subset_value'] = $gf(subset_checkbox).val();
|
||||
if ($gf(subset_checkbox).is(':checked'))
|
||||
temp_array['subset_selected'] = true;
|
||||
else
|
||||
temp_array['subset_selected'] = false;
|
||||
subset_array.push(temp_array);
|
||||
});
|
||||
var data = {
|
||||
action: 'update_google_font',
|
||||
font_name: font_name,
|
||||
variants: variant_array,
|
||||
subsets: subset_array,
|
||||
security: uavc.update_google_fonts
|
||||
};
|
||||
$gf(this).next('.fspinner').addClass('fspinner-show');
|
||||
$gf.post(ajaxurl, data, function(response) {
|
||||
$gf('.fspinner').removeClass('fspinner-show');
|
||||
});
|
||||
});
|
||||
$gf('body').on('click', '.selected-font-top', function () {
|
||||
if ($gf(this).hasClass('fopened')) {
|
||||
$gf(this).parent().find('.selected-font-content').slideUp(200);
|
||||
$gf(this).removeClass('fopened');
|
||||
return;
|
||||
}
|
||||
$gf('.selected-font .selected-font-content').slideUp(200);
|
||||
$gf('.selected-font-top').removeClass('fopened');
|
||||
$gf(this).addClass('fopened');
|
||||
$gf(this).parent().find('.selected-font-content').slideToggle(200);
|
||||
});
|
||||
//get google fonts
|
||||
get_google_fonts();
|
||||
});
|
||||
function get_google_fonts()
|
||||
{
|
||||
$gf('#load-more').show();
|
||||
$list_wrapper = $gf('#fonts-list-wrapper');
|
||||
var gstart = $list_wrapper.attr('data-gstart');
|
||||
var gfetch = $list_wrapper.attr('data-gfetch');
|
||||
var gsearch = $gf('#search_gfont').val();
|
||||
var data = {
|
||||
action : 'get_google_fonts',
|
||||
start : gstart,
|
||||
fetch : gfetch,
|
||||
search : gsearch,
|
||||
security : uavc.get_google_fonts
|
||||
};
|
||||
$gf.post(ajaxurl, data, function(response) {
|
||||
var object = jQuery.parseJSON(response);
|
||||
var font_count = object.fonts_count;
|
||||
var fonts = object.fonts;
|
||||
var is_search = object.is_search;
|
||||
if(font_count == 0 && is_search == 'false')
|
||||
{
|
||||
var ghtml = '<div class="gfont">It seems you don\'t have any Google Fonts yet. But you can download them now with <a href="javascript:void(0)" id="refresh-google-fonts">just a click.</a> <span class="spinner"></span></div>';
|
||||
$list_wrapper.html(ghtml);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fonts.length == 0)
|
||||
{
|
||||
var ghtml = '<div class="gfont">';
|
||||
ghtml += 'Bummer, there are no font families that match. Try with other search keyword';
|
||||
ghtml += '</div>';
|
||||
$list_wrapper.html(ghtml);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ghtml = convert_json_to_html(fonts);
|
||||
$list_wrapper.append(ghtml);
|
||||
}
|
||||
}
|
||||
$gf('#load-more').hide();
|
||||
$list_wrapper.attr('data-gstart',parseInt(gstart)+parseInt(gfetch));
|
||||
});
|
||||
}
|
||||
function convert_json_to_html(object)
|
||||
{
|
||||
var html = '';
|
||||
$gf.each(object,function (index, gfont) {
|
||||
var font_call = gfont.font_call;
|
||||
var font_name = gfont.font_name;
|
||||
var font_variants = gfont.variants;
|
||||
var font_subsets = gfont.subsets;
|
||||
var selected = gfont.selected;
|
||||
if(temp = font_name.split(' '))
|
||||
{
|
||||
var ctemp = temp.length;
|
||||
var temp_id = '';
|
||||
$gf.each(temp,function (i, val) {
|
||||
temp_id += val;
|
||||
if ((ctemp-1) != i)
|
||||
temp_id += '-';
|
||||
})
|
||||
}
|
||||
else
|
||||
var temp_id = font_name;
|
||||
|
||||
var variants_length = font_variants.length;
|
||||
var subsets_length = font_subsets.length;
|
||||
|
||||
if (selected == 'true') {
|
||||
var button_text = 'Added in collection';
|
||||
var button_class = 'font-added';
|
||||
}
|
||||
else {
|
||||
var button_text = 'Add to Collection';
|
||||
var button_class = '';
|
||||
}
|
||||
html += '<div class="gfont">';
|
||||
html += '<div class="font-header" style="font-family:\''+font_name+'\'">'+font_name+'</div>';
|
||||
html += '<input type="button" class="add-google-font alignright '+button_class+'" data-font_family="'+font_call+'" data-font_name="'+font_name+'" value="'+button_text+'"/><span class="spinner"></span><div class="clear"></div>';
|
||||
if (variants_length > 1) {
|
||||
font_call += ':';
|
||||
html += '<span class="variants">';
|
||||
$gf.each(font_variants, function (vindex, variant) {
|
||||
if (variant != 'regular') {
|
||||
var font_style = 'font-family:\''+font_name+'\';';
|
||||
if(/italic/i.test(variant)) {
|
||||
font_style += 'font-style:italic;';
|
||||
}
|
||||
var weight = 'normal';
|
||||
if (weight = variant.match(/\d+/)) {
|
||||
font_style += 'font-weight:'+weight+';';
|
||||
}
|
||||
html += '<span class="font-variant">';
|
||||
html += '<input type="checkbox" class="font-variant-inputs" value="'+variant+'" id="'+temp_id+'-'+variant+'-'+vindex+'"/>';
|
||||
html += '<label for="'+temp_id+'-'+variant+'-'+vindex+'" style="'+font_style+'">'+variant+'</label>';
|
||||
html += '</span>';
|
||||
font_call += variant;
|
||||
if (variants_length > 0 && (variants_length-1) != vindex) {
|
||||
font_call += ',';
|
||||
}
|
||||
}
|
||||
});
|
||||
html += '</span>';
|
||||
} //end of varients
|
||||
if(subsets_length > 1)
|
||||
{
|
||||
html += '<span class="subsets">';
|
||||
$gf.each(font_subsets, function(sindex, subset){
|
||||
html += '<span class="font-subset">';
|
||||
html += '<input type="checkbox" class="font-subset-inputs" value="'+subset+'" id="'+temp_id+'-'+subset+'-'+sindex+'"/>';
|
||||
html += '</span>';
|
||||
});
|
||||
html += '</span>';
|
||||
} //end of subsets
|
||||
html += '<div class="clear"></div>';
|
||||
html += '</div>';
|
||||
$gf('head').append('<link href="//fonts.googleapis.com/css?family='+font_call+'" type="text/css" media="all" rel="stylesheet"/>');
|
||||
});
|
||||
return html;
|
||||
}
|
||||
$gf(window).scroll(function () {
|
||||
if ($gf(window).height() + $gf(window).scrollTop() == $gf(document).height()) {
|
||||
var gsearch = $gf('#search_gfont').val();
|
||||
if (gsearch == '')
|
||||
get_google_fonts();
|
||||
}
|
||||
});
|
||||
$gf(document).ready(function(){
|
||||
var typingTimer; //timer identifier
|
||||
var doneTypingInterval = 500; //time in ms, 2 second for example
|
||||
//on keyup, start the countdown
|
||||
$gf('#search_gfont').keyup(function(){
|
||||
clearTimeout(typingTimer);
|
||||
typingTimer = setTimeout(search_gfont, doneTypingInterval);
|
||||
});
|
||||
//on keydown, clear the countdown
|
||||
$gf('#search_gfont').keydown(function(){
|
||||
clearTimeout(typingTimer);
|
||||
});
|
||||
});
|
||||
function search_gfont()
|
||||
{
|
||||
var gsearch = $gf('#search_gfont').val();
|
||||
$list_wrapper = $gf('#fonts-list-wrapper');
|
||||
$list_wrapper.html('');
|
||||
if (gsearch == '') {
|
||||
$list_wrapper.attr('data-gstart',parseInt(0));
|
||||
}
|
||||
get_google_fonts();
|
||||
}
|
||||
$gf(document).ready(function() {
|
||||
//set_wrap_height('notfixed');
|
||||
var $menu = jQuery(".fonts-selected-list"),
|
||||
$window = jQuery(window),
|
||||
offset = $menu.offset(),
|
||||
topPadding = 15;
|
||||
$window.scroll(function() {
|
||||
if ($window.scrollTop()+35+15 > offset.top) {
|
||||
$menu.addClass('uagffixed');
|
||||
//set_wrap_height('fixed');
|
||||
} else {
|
||||
$menu.removeClass('uagffixed');
|
||||
//set_wrap_height('notfixed');
|
||||
}
|
||||
});
|
||||
});
|
||||
function set_wrap_height(fx)
|
||||
{
|
||||
var win_height = $gf(window).height();
|
||||
if(fx == 'notfixed')
|
||||
{
|
||||
var swrap_top = $gf('#fonts-selected-wrapper').offset().top;
|
||||
var cheight = win_height - swrap_top - 40;
|
||||
}
|
||||
else
|
||||
{
|
||||
var cheight = win_height - 140;
|
||||
}
|
||||
$gf('#fonts-selected-wrapper').height(cheight);
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
/*!
|
||||
* jQuery ClassyGradient
|
||||
* www.class.pm
|
||||
*
|
||||
* Written by Marius Stanciu - Sergiu <marius@class.pm>
|
||||
* Licensed under the MIT license www.class.pm/LICENSE-MIT
|
||||
* Version 1.1.0
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
$.ClassyGradient = function(element, options) {
|
||||
var defaults = {
|
||||
gradient: '0% #02CDE8, 100% #000000',
|
||||
width: 300,
|
||||
height: 18,
|
||||
point: 8,
|
||||
orientation: 'vertical',
|
||||
target: null,
|
||||
onChange: function() {
|
||||
|
||||
},
|
||||
onInit: function() {
|
||||
|
||||
}
|
||||
};
|
||||
var $element = $(element), _container, _canvas, $pointsContainer, $pointsInfos, $pointsInfosContent, $pointColor, $pointPosition, $btnPointDelete, _context, _selPoint;
|
||||
var points = new Array();
|
||||
this.settings = {};
|
||||
this.__constructor = function() {
|
||||
this.settings = $.extend({}, defaults, options);
|
||||
this.update();
|
||||
this.settings.onInit();
|
||||
return this;
|
||||
};
|
||||
this.update = function() {
|
||||
this._setupPoints();
|
||||
this._setup();
|
||||
this._render();
|
||||
};
|
||||
this.getCSS = function() {
|
||||
var out = '', svgX = '0%', svgY = '100%', webkitDir = 'left bottom', defDir = 'top';
|
||||
if (this.settings.orientation === 'horizontal') {
|
||||
svgX = '100%';
|
||||
svgY = '0%';
|
||||
webkitDir = 'right top';
|
||||
defDir = 'left';
|
||||
}
|
||||
|
||||
defDir = this.settings.orientation; // hack by amit
|
||||
|
||||
var svg = '<svg xmlns="http://www.w3.org/2000/svg">' + '<defs>' + '<linearGradient id="gradient" x1="0%" y1="0%" x2="' + svgX + '" y2="' + svgY + '">';
|
||||
var webkitCss = '-webkit-gradient(linear, left top, ' + webkitDir;
|
||||
var defCss = '';
|
||||
$.each(points, function(i, el) {
|
||||
webkitCss += ', color-stop(' + el[0] + ', ' + el[1] + ')';
|
||||
defCss += ',' + el[1] + ' ' + el[0] + '';
|
||||
svg += '<stop offset="' + el[0] + '" style="stop-color:' + el[1] + ';" />';
|
||||
});
|
||||
webkitCss += ')';
|
||||
defCss = defCss.substr(1);
|
||||
svg += '</linearGradient>' + '</defs>' + '<rect fill="url(#gradient)" height="100%" width="100%" />' + '</svg>';
|
||||
svg = this._base64(svg);
|
||||
out += 'background: url(data:image/svg+xml;base64,' + svg + ');' + '\n';
|
||||
out += 'background: ' + webkitCss + ';\n';
|
||||
out += 'background: ' + '-moz-linear-gradient(' + defDir + ',' + defCss + ');' + '\n';
|
||||
out += 'background: ' + '-webkit-linear-gradient(' + defDir + ',' + defCss + ');' + '\n';
|
||||
out += 'background: ' + '-o-linear-gradient(' + defDir + ',' + defCss + ');' + '\n';
|
||||
out += 'background: ' + '-ms-linear-gradient(' + defDir + ',' + defCss + ');' + '\n';
|
||||
out += 'background: ' + 'linear-gradient(' + defDir + ',' + defCss + ');';
|
||||
return out;
|
||||
};
|
||||
this.getArray = function() {
|
||||
return points;
|
||||
};
|
||||
this.getString = function() {
|
||||
var out = '';
|
||||
$.each(points, function(i, el) {
|
||||
out += el[0] + ' ' + el[1] + ',';
|
||||
});
|
||||
out = out.substr(0, out.length - 1);
|
||||
return out;
|
||||
};
|
||||
this.setOrientation = function(orientation) {
|
||||
this.settings.orientation = orientation;
|
||||
this._renderToTarget();
|
||||
};
|
||||
this._setupPoints = function() {
|
||||
points = new Array();
|
||||
if ($.isArray(this.settings.gradient)) {
|
||||
points = this.settings.gradient;
|
||||
}
|
||||
else {
|
||||
points = this._getGradientFromString(this.settings.gradient);
|
||||
}
|
||||
};
|
||||
this._setup = function() {
|
||||
var self = this;
|
||||
$element.empty();
|
||||
_container = $('<div class="ClassyGradient"></div>');
|
||||
_canvas = $('<canvas class="canvas" width="' + this.settings.width + '" height="' + this.settings.height + '"></canvas>');
|
||||
_container.append(_canvas);
|
||||
_context = _canvas.get(0).getContext('2d');
|
||||
$pointsContainer = $('<div class="points"></div>');
|
||||
$pointsContainer.css('width', (this.settings.width) + Math.round(this.settings.point / 2 + 1) + 'px');
|
||||
_container.append($pointsContainer);
|
||||
$pointsInfos = $('<div class="info"></div>');
|
||||
$pointsInfos.append('<div class="arrow"></div>');
|
||||
_container.append($pointsInfos);
|
||||
$pointsInfosContent = $('<div class="content"></div>');
|
||||
$pointsInfos.append($pointsInfosContent);
|
||||
$element.hover(function() {
|
||||
$element.addClass('hover');
|
||||
}, function() {
|
||||
$element.removeClass('hover');
|
||||
});
|
||||
$pointColor = $('<div class="point-color"><div style="background-color: #00ff00"></div></div>');
|
||||
$pointPosition = $('<span class="point-position">%</span>');
|
||||
$btnPointDelete = $('<a href="#" class="delete"></a>');
|
||||
$pointsInfosContent.append($pointColor, $pointPosition, $btnPointDelete);
|
||||
$element.append(_container);
|
||||
$pointColor.ColorPicker({
|
||||
color: '#00ff00',
|
||||
onSubmit: function(hsb, hex, rgb) {
|
||||
$element.find('.point-color div').css('backgroundColor', '#' + hex);
|
||||
_selPoint.css('backgroundColor', '#' + hex);
|
||||
self._renderCanvas();
|
||||
self._renderToTarget();
|
||||
},
|
||||
onChange: function(hsb, hex, rgb) {
|
||||
$element.find('.point-color div').css('backgroundColor', '#' + hex);
|
||||
_selPoint.css('backgroundColor', '#' + hex);
|
||||
self._renderCanvas();
|
||||
self._renderToTarget();
|
||||
}
|
||||
});
|
||||
$(document).bind('click', function() {
|
||||
if (!$element.is('.hover')) {
|
||||
$pointsInfos.hide('fast');
|
||||
}
|
||||
});
|
||||
_canvas.unbind('click');
|
||||
_canvas.bind('click', function(e) {
|
||||
var offset = _canvas.offset(), clickPosition = e.pageX - offset.left;
|
||||
clickPosition = Math.round((clickPosition * 100) / self.settings.width);
|
||||
var defaultColor = '#000000', minDist = 999999999999;
|
||||
$.each(points, function(i, el) {
|
||||
if ((parseInt(el[0]) < clickPosition) && (clickPosition - parseInt(el[0]) < minDist)) {
|
||||
minDist = clickPosition - parseInt(el[0]);
|
||||
defaultColor = el[1];
|
||||
}
|
||||
else if ((parseInt(el[0]) > clickPosition) && (parseInt(el[0]) - clickPosition < minDist)) {
|
||||
minDist = parseInt(el[0]) - clickPosition;
|
||||
defaultColor = el[1];
|
||||
}
|
||||
});
|
||||
points.push([clickPosition + '%', defaultColor]);
|
||||
points.sort(self._sortByPosition);
|
||||
self._render();
|
||||
$.each(points, function(i, el) {
|
||||
if (el[0] == clickPosition + '%') {
|
||||
self._selectPoint($pointsContainer.find('.point:eq(' + i + ')'));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
this._render = function() {
|
||||
this._initGradientPoints();
|
||||
this._renderCanvas();
|
||||
this._renderToTarget();
|
||||
};
|
||||
this._initGradientPoints = function() {
|
||||
var self = this;
|
||||
$pointsContainer.empty();
|
||||
$.each(points, function(i, el) {
|
||||
$pointsContainer.append('<div class="point" style="background-color: ' + el[1] + '; left:' + (parseInt(el[0]) * self.settings.width) / 100 + 'px;"></div>');
|
||||
});
|
||||
$pointsContainer.find('.point').css('width', this.settings.point + 'px').css('height', this.settings.point + 'px').mouseup(function() {
|
||||
self._selectPoint(this);
|
||||
}).draggable({
|
||||
axis: 'x',
|
||||
containment: 'parent',
|
||||
drag: function() {
|
||||
self._selectPoint(this);
|
||||
self._renderCanvas();
|
||||
self._renderToTarget();
|
||||
}
|
||||
});
|
||||
};
|
||||
this._selectPoint = function(el) {
|
||||
var self = this;
|
||||
_selPoint = $(el);
|
||||
var color = $(el).css('backgroundColor'), position = parseInt($(el).css('left'));
|
||||
position = Math.round((position / this.settings.width) * 100);
|
||||
color = color.substr(4, color.length);
|
||||
color = color.substr(0, color.length - 1);
|
||||
$pointColor.ColorPickerSetColor(this._rgbToHex(color.split(',')));
|
||||
$pointColor.find('div').css('backgroundColor', this._rgbToHex(color.split(',')));
|
||||
$pointPosition.html('Position: ' + position + '%');
|
||||
$btnPointDelete.unbind('click').bind('click', function() {
|
||||
if (points.length > 1) {
|
||||
points.splice(_selPoint.index(), 1);
|
||||
self._render();
|
||||
$element.find('.info').hide('fast');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$element.find('.info').css('marginLeft', parseInt($(el).css('left')) - 30 + 'px').show('fast');
|
||||
};
|
||||
this._renderCanvas = function() {
|
||||
var self = this;
|
||||
points = new Array();
|
||||
$element.find('.point').each(function(i, el) {
|
||||
var position = Math.round((parseInt($(el).css('left')) / self.settings.width) * 100);
|
||||
var color = $(el).css('backgroundColor').substr(4, $(el).css('backgroundColor').length - 5);
|
||||
color = self._rgbToHex(color.split(','));
|
||||
points.push([position + '%', color]);
|
||||
});
|
||||
points.sort(self._sortByPosition);
|
||||
this._renderToCanvas();
|
||||
this.settings.onChange(this.getString(), this.getCSS(), this.getArray());
|
||||
};
|
||||
this._renderToElement = function(target, gradient) {
|
||||
var svgX = '0%', svgY = '100%', webkitDir = 'left bottom', defDir = 'top';
|
||||
if ((target === _canvas) || (this.settings.orientation === 'horizontal')) {
|
||||
svgX = '100%';
|
||||
svgY = '0%';
|
||||
webkitDir = 'right top';
|
||||
defDir = 'left';
|
||||
}
|
||||
|
||||
defDir = this.settings.orientation; // hack by amit
|
||||
|
||||
var svg = '<svg xmlns="http://www.w3.org/2000/svg">' + '<defs>' + '<linearGradient id="gradient" x1="0%" y1="0%" x2="' + svgX + '" y2="' + svgY + '">';
|
||||
var webkitCss = '-webkit-gradient(linear, left top, ' + webkitDir;
|
||||
var defCss = '';
|
||||
$.each(gradient, function(i, el) {
|
||||
webkitCss += ', color-stop(' + el[0] + ', ' + el[1] + ')';
|
||||
defCss += ',' + el[1] + ' ' + el[0] + '';
|
||||
svg += '<stop offset="' + el[0] + '" style="stop-color:' + el[1] + ';" />';
|
||||
});
|
||||
webkitCss += ')';
|
||||
defCss = defCss.substr(1);
|
||||
svg += '</linearGradient>' + '</defs>';
|
||||
if (target === $pointsInfosContent) {
|
||||
var tooltipRadius = parseInt($pointsInfosContent.css('borderRadius'));
|
||||
svg += '<rect fill="url(#gradient)" height="100%" width="100%" rx="' + tooltipRadius + '" ry="' + tooltipRadius + '" />';
|
||||
}
|
||||
else {
|
||||
svg += '<rect fill="url(#gradient)" height="100%" width="100%" />';
|
||||
}
|
||||
svg += '</svg>';
|
||||
svg = this._base64(svg);
|
||||
target.css('background', 'url(data:image/svg+xml;base64,' + svg + ')');
|
||||
target.css('background', webkitCss);
|
||||
target.css('background', '-moz-linear-gradient(' + defDir + ',' + defCss + ')');
|
||||
target.css('background', '-webkit-linear-gradient(' + defDir + ',' + defCss + ')');
|
||||
target.css('background', '-o-linear-gradient(' + defDir + ',' + defCss + ')');
|
||||
target.css('background', '-ms-linear-gradient(' + defDir + ',' + defCss + ')');
|
||||
target.css('background', 'linear-gradient(' + defDir + ',' + defCss + ')');
|
||||
};
|
||||
this._renderToTarget = function() {
|
||||
if (this.settings.target !== null) {
|
||||
this._renderToElement($(this.settings.target), points);
|
||||
}
|
||||
};
|
||||
this._renderToCanvas = function() {
|
||||
var gradient = _context.createLinearGradient(0, 0, this.settings.width, 0);
|
||||
$.each(points, function(i, el) {
|
||||
gradient.addColorStop(parseInt(el[0]) / 100, el[1]);
|
||||
});
|
||||
_context.clearRect(0, 0, this.settings.width, this.settings.height);
|
||||
_context.fillStyle = gradient;
|
||||
_context.fillRect(0, 0, this.settings.width, this.settings.height);
|
||||
this.settings.onChange(this.getString(), this.getCSS(), this.getArray());
|
||||
};
|
||||
this._getGradientFromString = function(gradient) {
|
||||
var arr = new Array(), _t = gradient.split(',');
|
||||
$.each(_t, function(i, el) {
|
||||
var position;
|
||||
if ((el.substr(el.indexOf('%') - 3, el.indexOf('%')) == '100') || (el.substr(el.indexOf('%') - 3, el.indexOf('%')) == '100%')) {
|
||||
position = '100%';
|
||||
}
|
||||
else if (el.indexOf('%') > 1) {
|
||||
position = parseInt(el.substr(el.indexOf('%') - 2, el.indexOf('%')));
|
||||
position += '%';
|
||||
}
|
||||
else {
|
||||
position = parseInt(el.substr(el.indexOf('%') - 1, el.indexOf('%')));
|
||||
position += '%';
|
||||
}
|
||||
var color = el.substr(el.indexOf('#'), 7);
|
||||
arr.push([position, color]);
|
||||
});
|
||||
return arr;
|
||||
};
|
||||
this._rgbToHex = function(rgb) {
|
||||
var R = rgb[0], G = rgb[1], B = rgb[2];
|
||||
function toHex(n) {
|
||||
n = parseInt(n, 10);
|
||||
if (isNaN(n))
|
||||
return "00";
|
||||
n = Math.max(0, Math.min(n, 255));
|
||||
return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
|
||||
}
|
||||
return '#' + toHex(R) + toHex(G) + toHex(B);
|
||||
};
|
||||
this._sortByPosition = function(data_A, data_B) {
|
||||
if (parseInt(data_A[0]) < parseInt(data_B[0])) {
|
||||
return -1;
|
||||
}
|
||||
if (parseInt(data_A[0]) > parseInt(data_B[0])) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
this._base64 = function(input) {
|
||||
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", output = "", chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0;
|
||||
while (i < input.length) {
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
}
|
||||
else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
|
||||
}
|
||||
return output;
|
||||
};
|
||||
return this.__constructor();
|
||||
};
|
||||
$.fn.ClassyGradient = function(options) {
|
||||
return this.each(function() {
|
||||
if ($(this).data('ClassyGradient') === undefined) {
|
||||
var plugin = new $.ClassyGradient(this, options);
|
||||
$(this).data('ClassyGradient', plugin);
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,517 @@
|
||||
/**
|
||||
*
|
||||
* Color picker
|
||||
* Author: Stefan Petre www.eyecon.ro
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
var ColorPicker = function() {
|
||||
var
|
||||
ids = {},
|
||||
inAction,
|
||||
charMin = 65,
|
||||
visible,
|
||||
tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
|
||||
defaults = {
|
||||
eventName: 'click',
|
||||
onShow: function() {
|
||||
},
|
||||
onBeforeShow: function() {
|
||||
},
|
||||
onHide: function() {
|
||||
},
|
||||
onChange: function() {
|
||||
},
|
||||
onSubmit: function() {
|
||||
},
|
||||
color: 'ff0000',
|
||||
livePreview: true,
|
||||
flat: false
|
||||
},
|
||||
fillRGBFields = function(hsb, cal) {
|
||||
var rgb = HSBToRGB(hsb);
|
||||
$(cal).data('colorpicker').fields
|
||||
.eq(1).val(rgb.r).end()
|
||||
.eq(2).val(rgb.g).end()
|
||||
.eq(3).val(rgb.b).end();
|
||||
},
|
||||
fillHSBFields = function(hsb, cal) {
|
||||
$(cal).data('colorpicker').fields
|
||||
.eq(4).val(hsb.h).end()
|
||||
.eq(5).val(hsb.s).end()
|
||||
.eq(6).val(hsb.b).end();
|
||||
},
|
||||
fillHexFields = function(hsb, cal) {
|
||||
$(cal).data('colorpicker').fields
|
||||
.eq(0).val(HSBToHex(hsb)).end();
|
||||
},
|
||||
setSelector = function(hsb, cal) {
|
||||
$(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
|
||||
$(cal).data('colorpicker').selectorIndic.css({
|
||||
left: parseInt(150 * hsb.s / 100, 10),
|
||||
top: parseInt(150 * (100 - hsb.b) / 100, 10),
|
||||
});
|
||||
},
|
||||
setHue = function(hsb, cal) {
|
||||
$(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h / 360, 10));
|
||||
},
|
||||
setCurrentColor = function(hsb, cal) {
|
||||
$(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
|
||||
},
|
||||
setNewColor = function(hsb, cal) {
|
||||
$(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
|
||||
},
|
||||
keyDown = function(ev) {
|
||||
var pressedKey = ev.charCode || ev.keyCode || -1;
|
||||
if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
|
||||
return false;
|
||||
}
|
||||
var cal = $(this).parent().parent();
|
||||
if (cal.data('colorpicker').livePreview === true) {
|
||||
change.apply(this);
|
||||
}
|
||||
},
|
||||
change = function(ev) {
|
||||
var cal = $(this).parent().parent(), col;
|
||||
if (this.parentNode.className.indexOf('_hex') > 0) {
|
||||
cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
|
||||
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
||||
cal.data('colorpicker').color = col = fixHSB({
|
||||
h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
|
||||
s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
|
||||
b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
|
||||
});
|
||||
} else {
|
||||
cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
|
||||
r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
|
||||
g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
|
||||
b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
|
||||
}));
|
||||
}
|
||||
if (ev) {
|
||||
fillRGBFields(col, cal.get(0));
|
||||
fillHexFields(col, cal.get(0));
|
||||
fillHSBFields(col, cal.get(0));
|
||||
}
|
||||
setSelector(col, cal.get(0));
|
||||
setHue(col, cal.get(0));
|
||||
setNewColor(col, cal.get(0));
|
||||
cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
|
||||
},
|
||||
blur = function(ev) {
|
||||
var cal = $(this).parent().parent();
|
||||
cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
|
||||
},
|
||||
focus = function() {
|
||||
charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
|
||||
$(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
|
||||
$(this).parent().addClass('colorpicker_focus');
|
||||
},
|
||||
downIncrement = function(ev) {
|
||||
var field = $(this).parent().find('input').focus();
|
||||
var current = {
|
||||
el: $(this).parent().addClass('colorpicker_slider'),
|
||||
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
||||
y: ev.pageY,
|
||||
field: field,
|
||||
val: parseInt(field.val(), 10),
|
||||
preview: $(this).parent().parent().data('colorpicker').livePreview
|
||||
};
|
||||
$(document).bind('mouseup', current, upIncrement);
|
||||
$(document).bind('mousemove', current, moveIncrement);
|
||||
},
|
||||
moveIncrement = function(ev) {
|
||||
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
|
||||
if (ev.data.preview) {
|
||||
change.apply(ev.data.field.get(0), [true]);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
upIncrement = function(ev) {
|
||||
change.apply(ev.data.field.get(0), [true]);
|
||||
ev.data.el.removeClass('colorpicker_slider').find('input').focus();
|
||||
$(document).unbind('mouseup', upIncrement);
|
||||
$(document).unbind('mousemove', moveIncrement);
|
||||
return false;
|
||||
},
|
||||
downHue = function(ev) {
|
||||
var current = {
|
||||
cal: $(this).parent(),
|
||||
y: $(this).offset().top
|
||||
};
|
||||
current.preview = current.cal.data('colorpicker').livePreview;
|
||||
$(document).bind('mouseup', current, upHue);
|
||||
$(document).bind('mousemove', current, moveHue);
|
||||
},
|
||||
moveHue = function(ev) {
|
||||
change.apply(
|
||||
ev.data.cal.data('colorpicker')
|
||||
.fields
|
||||
.eq(4)
|
||||
.val(parseInt(360 * (150 - Math.max(0, Math.min(150, (ev.pageY - ev.data.y)))) / 150, 10))
|
||||
.get(0),
|
||||
[ev.data.preview]
|
||||
);
|
||||
return false;
|
||||
},
|
||||
upHue = function(ev) {
|
||||
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||
$(document).unbind('mouseup', upHue);
|
||||
$(document).unbind('mousemove', moveHue);
|
||||
return false;
|
||||
},
|
||||
downSelector = function(ev) {
|
||||
var current = {
|
||||
cal: $(this).parent(),
|
||||
pos: $(this).offset()
|
||||
};
|
||||
current.preview = current.cal.data('colorpicker').livePreview;
|
||||
$(document).bind('mouseup', current, upSelector);
|
||||
$(document).bind('mousemove', current, moveSelector);
|
||||
},
|
||||
moveSelector = function(ev) {
|
||||
change.apply(
|
||||
ev.data.cal.data('colorpicker')
|
||||
.fields
|
||||
.eq(6)
|
||||
.val(parseInt(100 * (150 - Math.max(0, Math.min(150, (ev.pageY - ev.data.pos.top)))) / 150, 10))
|
||||
.end()
|
||||
.eq(5)
|
||||
.val(parseInt(100 * (Math.max(0, Math.min(150, (ev.pageX - ev.data.pos.left)))) / 150, 10))
|
||||
.get(0),
|
||||
[ev.data.preview]
|
||||
);
|
||||
return false;
|
||||
},
|
||||
upSelector = function(ev) {
|
||||
fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||
fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
|
||||
$(document).unbind('mouseup', upSelector);
|
||||
$(document).unbind('mousemove', moveSelector);
|
||||
return false;
|
||||
},
|
||||
enterSubmit = function(ev) {
|
||||
$(this).addClass('colorpicker_focus');
|
||||
},
|
||||
leaveSubmit = function(ev) {
|
||||
$(this).removeClass('colorpicker_focus');
|
||||
},
|
||||
clickSubmit = function(ev) {
|
||||
var cal = $(this).parent();
|
||||
var col = cal.data('colorpicker').color;
|
||||
cal.data('colorpicker').origColor = col;
|
||||
setCurrentColor(col, cal.get(0));
|
||||
cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
|
||||
},
|
||||
show = function(ev) {
|
||||
var cal = $('#' + $(this).data('colorpickerId'));
|
||||
cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
|
||||
var pos = $(this).offset();
|
||||
var viewPort = getViewport();
|
||||
var top = pos.top + this.offsetHeight;
|
||||
var left = pos.left;
|
||||
if (top + 176 > viewPort.t + viewPort.h) {
|
||||
top -= this.offsetHeight + 176;
|
||||
}
|
||||
if (left + 356 > viewPort.l + viewPort.w) {
|
||||
left -= 356;
|
||||
}
|
||||
cal.css({left: left + 'px', top: top + 'px'});
|
||||
if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
|
||||
cal.show();
|
||||
}
|
||||
$(document).bind('mousedown', {cal: cal}, hide);
|
||||
return false;
|
||||
},
|
||||
hide = function(ev) {
|
||||
if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
|
||||
if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
||||
ev.data.cal.hide();
|
||||
}
|
||||
$(document).unbind('mousedown', hide);
|
||||
}
|
||||
},
|
||||
isChildOf = function(parentEl, el, container) {
|
||||
if (parentEl == el) {
|
||||
return true;
|
||||
}
|
||||
if (parentEl.contains) {
|
||||
return parentEl.contains(el);
|
||||
}
|
||||
if (parentEl.compareDocumentPosition) {
|
||||
return !!(parentEl.compareDocumentPosition(el) & 16);
|
||||
}
|
||||
var prEl = el.parentNode;
|
||||
while (prEl && prEl != container) {
|
||||
if (prEl == parentEl)
|
||||
return true;
|
||||
prEl = prEl.parentNode;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getViewport = function() {
|
||||
var m = document.compatMode == 'CSS1Compat';
|
||||
return {
|
||||
l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
||||
t: window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
|
||||
w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
|
||||
h: window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
|
||||
};
|
||||
},
|
||||
fixHSB = function(hsb) {
|
||||
return {
|
||||
h: Math.min(360, Math.max(0, hsb.h)),
|
||||
s: Math.min(100, Math.max(0, hsb.s)),
|
||||
b: Math.min(100, Math.max(0, hsb.b))
|
||||
};
|
||||
},
|
||||
fixRGB = function(rgb) {
|
||||
return {
|
||||
r: Math.min(255, Math.max(0, rgb.r)),
|
||||
g: Math.min(255, Math.max(0, rgb.g)),
|
||||
b: Math.min(255, Math.max(0, rgb.b))
|
||||
};
|
||||
},
|
||||
fixHex = function(hex) {
|
||||
var len = 6 - hex.length;
|
||||
if (len > 0) {
|
||||
var o = [];
|
||||
for (var i = 0; i < len; i++) {
|
||||
o.push('0');
|
||||
}
|
||||
o.push(hex);
|
||||
hex = o.join('');
|
||||
}
|
||||
return hex;
|
||||
},
|
||||
HexToRGB = function(hex) {
|
||||
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
||||
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
||||
},
|
||||
HexToHSB = function(hex) {
|
||||
return RGBToHSB(HexToRGB(hex));
|
||||
},
|
||||
RGBToHSB = function(rgb) {
|
||||
var hsb = {
|
||||
h: 0,
|
||||
s: 0,
|
||||
b: 0
|
||||
};
|
||||
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
||||
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
||||
var delta = max - min;
|
||||
hsb.b = max;
|
||||
if (max != 0) {
|
||||
}
|
||||
hsb.s = max != 0 ? 255 * delta / max : 0;
|
||||
if (hsb.s != 0) {
|
||||
if (rgb.r == max) {
|
||||
hsb.h = (rgb.g - rgb.b) / delta;
|
||||
} else if (rgb.g == max) {
|
||||
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
||||
} else {
|
||||
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
||||
}
|
||||
} else {
|
||||
hsb.h = -1;
|
||||
}
|
||||
hsb.h *= 60;
|
||||
if (hsb.h < 0) {
|
||||
hsb.h += 360;
|
||||
}
|
||||
hsb.s *= 100 / 255;
|
||||
hsb.b *= 100 / 255;
|
||||
return hsb;
|
||||
},
|
||||
HSBToRGB = function(hsb) {
|
||||
var rgb = {};
|
||||
var h = Math.round(hsb.h);
|
||||
var s = Math.round(hsb.s * 255 / 100);
|
||||
var v = Math.round(hsb.b * 255 / 100);
|
||||
if (s == 0) {
|
||||
rgb.r = rgb.g = rgb.b = v;
|
||||
} else {
|
||||
var t1 = v;
|
||||
var t2 = (255 - s) * v / 255;
|
||||
var t3 = (t1 - t2) * (h % 60) / 60;
|
||||
if (h == 360)
|
||||
h = 0;
|
||||
if (h < 60) {
|
||||
rgb.r = t1;
|
||||
rgb.b = t2;
|
||||
rgb.g = t2 + t3
|
||||
}
|
||||
else if (h < 120) {
|
||||
rgb.g = t1;
|
||||
rgb.b = t2;
|
||||
rgb.r = t1 - t3
|
||||
}
|
||||
else if (h < 180) {
|
||||
rgb.g = t1;
|
||||
rgb.r = t2;
|
||||
rgb.b = t2 + t3
|
||||
}
|
||||
else if (h < 240) {
|
||||
rgb.b = t1;
|
||||
rgb.r = t2;
|
||||
rgb.g = t1 - t3
|
||||
}
|
||||
else if (h < 300) {
|
||||
rgb.b = t1;
|
||||
rgb.g = t2;
|
||||
rgb.r = t2 + t3
|
||||
}
|
||||
else if (h < 360) {
|
||||
rgb.r = t1;
|
||||
rgb.g = t2;
|
||||
rgb.b = t1 - t3
|
||||
}
|
||||
else {
|
||||
rgb.r = 0;
|
||||
rgb.g = 0;
|
||||
rgb.b = 0
|
||||
}
|
||||
}
|
||||
return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
|
||||
},
|
||||
RGBToHex = function(rgb) {
|
||||
var hex = [
|
||||
rgb.r.toString(16),
|
||||
rgb.g.toString(16),
|
||||
rgb.b.toString(16)
|
||||
];
|
||||
$.each(hex, function(nr, val) {
|
||||
if (val.length == 1) {
|
||||
hex[nr] = '0' + val;
|
||||
}
|
||||
});
|
||||
return hex.join('');
|
||||
},
|
||||
HSBToHex = function(hsb) {
|
||||
return RGBToHex(HSBToRGB(hsb));
|
||||
},
|
||||
restoreOriginal = function() {
|
||||
var cal = $(this).parent();
|
||||
var col = cal.data('colorpicker').origColor;
|
||||
cal.data('colorpicker').color = col;
|
||||
fillRGBFields(col, cal.get(0));
|
||||
fillHexFields(col, cal.get(0));
|
||||
fillHSBFields(col, cal.get(0));
|
||||
setSelector(col, cal.get(0));
|
||||
setHue(col, cal.get(0));
|
||||
setNewColor(col, cal.get(0));
|
||||
};
|
||||
return {
|
||||
init: function(opt) {
|
||||
opt = $.extend({}, defaults, opt || {});
|
||||
if (typeof opt.color == 'string') {
|
||||
opt.color = HexToHSB(opt.color);
|
||||
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
||||
opt.color = RGBToHSB(opt.color);
|
||||
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
||||
opt.color = fixHSB(opt.color);
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
return this.each(function() {
|
||||
if (!$(this).data('colorpickerId')) {
|
||||
var options = $.extend({}, opt);
|
||||
options.origColor = opt.color;
|
||||
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
||||
$(this).data('colorpickerId', id);
|
||||
var cal = $(tpl).attr('id', id);
|
||||
if (options.flat) {
|
||||
cal.appendTo(this).show();
|
||||
} else {
|
||||
cal.appendTo(document.body);
|
||||
}
|
||||
options.fields = cal
|
||||
.find('input')
|
||||
.bind('keyup', keyDown)
|
||||
.bind('change', change)
|
||||
.bind('blur', blur)
|
||||
.bind('focus', focus);
|
||||
cal
|
||||
.find('span').bind('mousedown', downIncrement).end()
|
||||
.find('>div.colorpicker_current_color').bind('click', restoreOriginal);
|
||||
options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
|
||||
options.selectorIndic = options.selector.find('div div');
|
||||
options.el = this;
|
||||
options.hue = cal.find('div.colorpicker_hue div');
|
||||
cal.find('div.colorpicker_hue').bind('mousedown', downHue);
|
||||
options.newColor = cal.find('div.colorpicker_new_color');
|
||||
options.currentColor = cal.find('div.colorpicker_current_color');
|
||||
cal.data('colorpicker', options);
|
||||
cal.find('div.colorpicker_submit')
|
||||
.bind('mouseenter', enterSubmit)
|
||||
.bind('mouseleave', leaveSubmit)
|
||||
.bind('click', clickSubmit);
|
||||
fillRGBFields(options.color, cal.get(0));
|
||||
fillHSBFields(options.color, cal.get(0));
|
||||
fillHexFields(options.color, cal.get(0));
|
||||
setHue(options.color, cal.get(0));
|
||||
setSelector(options.color, cal.get(0));
|
||||
setCurrentColor(options.color, cal.get(0));
|
||||
setNewColor(options.color, cal.get(0));
|
||||
if (options.flat) {
|
||||
cal.css({
|
||||
position: 'relative',
|
||||
display: 'block'
|
||||
});
|
||||
} else {
|
||||
$(this).bind(options.eventName, show);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
showPicker: function() {
|
||||
return this.each(function() {
|
||||
if ($(this).data('colorpickerId')) {
|
||||
show.apply(this);
|
||||
}
|
||||
});
|
||||
},
|
||||
hidePicker: function() {
|
||||
return this.each(function() {
|
||||
if ($(this).data('colorpickerId')) {
|
||||
$('#' + $(this).data('colorpickerId')).hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
setColor: function(col) {
|
||||
if (typeof col == 'string') {
|
||||
col = HexToHSB(col);
|
||||
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
||||
col = RGBToHSB(col);
|
||||
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
||||
col = fixHSB(col);
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
return this.each(function() {
|
||||
if ($(this).data('colorpickerId')) {
|
||||
var cal = $('#' + $(this).data('colorpickerId'));
|
||||
cal.data('colorpicker').color = col;
|
||||
cal.data('colorpicker').origColor = col;
|
||||
fillRGBFields(col, cal.get(0));
|
||||
fillHSBFields(col, cal.get(0));
|
||||
fillHexFields(col, cal.get(0));
|
||||
setHue(col, cal.get(0));
|
||||
setSelector(col, cal.get(0));
|
||||
setCurrentColor(col, cal.get(0));
|
||||
setNewColor(col, cal.get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
$.fn.extend({
|
||||
ColorPicker: ColorPicker.init,
|
||||
ColorPickerHide: ColorPicker.hidePicker,
|
||||
ColorPickerShow: ColorPicker.showPicker,
|
||||
ColorPickerSetColor: ColorPicker.setColor
|
||||
});
|
||||
})(jQuery)
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* jQuery MiniColors: A tiny color picker built on jQuery
|
||||
*
|
||||
* Copyright Cory LaViska for A Beautiful Site, LLC. (http://www.abeautifulsite.net/)
|
||||
*
|
||||
* Licensed under the MIT license: http://opensource.org/licenses/MIT
|
||||
*
|
||||
*/jQuery&&function(e){function t(t,n){var r=e('<div class="minicolors" />'),i=e.minicolors.defaults;if(t.data("minicolors-initialized"))return;n=e.extend(!0,{},i,n);r.addClass("minicolors-theme-"+n.theme).toggleClass("minicolors-with-opacity",n.opacity);n.position!==undefined&&e.each(n.position.split(" "),function(){r.addClass("minicolors-position-"+this)});t.addClass("minicolors-input").data("minicolors-initialized",!1).data("minicolors-settings",n).prop("size",7).wrap(r).after('<div class="minicolors-panel minicolors-slider-'+n.control+'">'+'<div class="minicolors-slider">'+'<div class="minicolors-picker"></div>'+"</div>"+'<div class="minicolors-opacity-slider">'+'<div class="minicolors-picker"></div>'+"</div>"+'<div class="minicolors-grid">'+'<div class="minicolors-grid-inner"></div>'+'<div class="minicolors-picker"><div></div></div>'+"</div>"+"</div>");if(!n.inline){t.after('<span class="minicolors-swatch"><span class="minicolors-swatch-color"></span></span>');t.next(".minicolors-swatch").on("click",function(e){e.preventDefault();t.focus()})}t.parent().find(".minicolors-panel").on("selectstart",function(){return!1}).end();n.inline&&t.parent().addClass("minicolors-inline");u(t,!1);t.data("minicolors-initialized",!0)}function n(e){var t=e.parent();e.removeData("minicolors-initialized").removeData("minicolors-settings").removeProp("size").removeClass("minicolors-input");t.before(e).remove()}function r(e){var t=e.parent(),n=t.find(".minicolors-panel"),r=e.data("minicolors-settings");if(!e.data("minicolors-initialized")||e.prop("disabled")||t.hasClass("minicolors-inline")||t.hasClass("minicolors-focus"))return;i();t.addClass("minicolors-focus");n.stop(!0,!0).fadeIn(r.showSpeed,function(){r.show&&r.show.call(e.get(0))})}function i(){e(".minicolors-focus").each(function(){var t=e(this),n=t.find(".minicolors-input"),r=t.find(".minicolors-panel"),i=n.data("minicolors-settings");r.fadeOut(i.hideSpeed,function(){i.hide&&i.hide.call(n.get(0));t.removeClass("minicolors-focus")})})}function s(e,t,n){var r=e.parents(".minicolors").find(".minicolors-input"),i=r.data("minicolors-settings"),s=e.find("[class$=-picker]"),u=e.offset().left,a=e.offset().top,f=Math.round(t.pageX-u),l=Math.round(t.pageY-a),c=n?i.animationSpeed:0,h,p,d,v;if(t.originalEvent.changedTouches){f=t.originalEvent.changedTouches[0].pageX-u;l=t.originalEvent.changedTouches[0].pageY-a}f<0&&(f=0);l<0&&(l=0);f>e.width()&&(f=e.width());l>e.height()&&(l=e.height());if(e.parent().is(".minicolors-slider-wheel")&&s.parent().is(".minicolors-grid")){h=75-f;p=75-l;d=Math.sqrt(h*h+p*p);v=Math.atan2(p,h);v<0&&(v+=Math.PI*2);if(d>75){d=75;f=75-75*Math.cos(v);l=75-75*Math.sin(v)}f=Math.round(f);l=Math.round(l)}e.is(".minicolors-grid")?s.stop(!0).animate({top:l+"px",left:f+"px"},c,i.animationEasing,function(){o(r,e)}):s.stop(!0).animate({top:l+"px"},c,i.animationEasing,function(){o(r,e)})}function o(e,t){function n(e,t){var n,r;if(!e.length||!t)return null;n=e.offset().left;r=e.offset().top;return{x:n-t.offset().left+e.outerWidth()/2,y:r-t.offset().top+e.outerHeight()/2}}var r,i,s,o,u,f,l,h=e.val(),d=e.attr("data-opacity"),v=e.parent(),g=e.data("minicolors-settings"),y=v.find(".minicolors-swatch"),b=v.find(".minicolors-grid"),w=v.find(".minicolors-slider"),E=v.find(".minicolors-opacity-slider"),S=b.find("[class$=-picker]"),x=w.find("[class$=-picker]"),T=E.find("[class$=-picker]"),N=n(S,b),C=n(x,w),k=n(T,E);if(t.is(".minicolors-grid, .minicolors-slider")){switch(g.control){case"wheel":o=b.width()/2-N.x;u=b.height()/2-N.y;f=Math.sqrt(o*o+u*u);l=Math.atan2(u,o);l<0&&(l+=Math.PI*2);if(f>75){f=75;N.x=69-75*Math.cos(l);N.y=69-75*Math.sin(l)}i=p(f/.75,0,100);r=p(l*180/Math.PI,0,360);s=p(100-Math.floor(C.y*(100/w.height())),0,100);h=m({h:r,s:i,b:s});w.css("backgroundColor",m({h:r,s:i,b:100}));break;case"saturation":r=p(parseInt(N.x*(360/b.width()),10),0,360);i=p(100-Math.floor(C.y*(100/w.height())),0,100);s=p(100-Math.floor(N.y*(100/b.height())),0,100);h=m({h:r,s:i,b:s});w.css("backgroundColor",m({h:r,s:100,b:s}));v.find(".minicolors-grid-inner").css("opacity",i/100);break;case"brightness":r=p(parseInt(N.x*(360/b.width()),10),0,360);i=p(100-Math.floor(N.y*(100/b.height())),0,100);s=p(100-Math.floor(C.y*(100/w.height())),0,100);h=m({h:r,s:i,b:s});w.css("backgroundColor",m({h:r,s:i,b:100}));v.find(".minicolors-grid-inner").css("opacity",1-s/100);break;default:r=p(360-parseInt(C.y*(360/w.height()),10),0,360);i=p(Math.floor(N.x*(100/b.width())),0,100);s=p(100-Math.floor(N.y*(100/b.height())),0,100);h=m({h:r,s:i,b:s});b.css("backgroundColor",m({h:r,s:100,b:100}))}e.val(c(h,g.letterCase))}if(t.is(".minicolors-opacity-slider")){g.opacity?d=parseFloat(1-k.y/E.height()).toFixed(2):d=1;g.opacity&&e.attr("data-opacity",d)}y.find("SPAN").css({backgroundColor:h,opacity:d});a(e,h,d)}function u(e,t){var n,r,i,s,o,u,f,l=e.parent(),d=e.data("minicolors-settings"),v=l.find(".minicolors-swatch"),y=l.find(".minicolors-grid"),b=l.find(".minicolors-slider"),w=l.find(".minicolors-opacity-slider"),Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(){jQuery("body").on("click",".ui-tabs-anchor",function(){var c=jQuery(this).closest("div.vc_row ").data("title");"Edit Creative Link"==c&&(jQuery(".vc_col-xs-5").children().not(".vc_checkbox").css("display","none"),jQuery(".vc_border").children().not(".vc_padding").css("display","none"),jQuery(".vc_padding").css("margin","0px"))})});
|
||||
@@ -0,0 +1,55 @@
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
function autoChange() {
|
||||
jQuery('.wpb_el_type_icon_manager').each(function(i,val){
|
||||
var sel = jQuery(this).find('.wpb_txt_icons_block'),
|
||||
current_i = (i+1),
|
||||
Icon_value = sel.data('old-icon-value'),
|
||||
Icon_values = '';
|
||||
|
||||
sel.data('old-icon-value', current_i );
|
||||
Icon_values = sel.html();
|
||||
Icon_values = Icon_values.replace(Icon_value, current_i);
|
||||
|
||||
sel.html(Icon_values);
|
||||
sel.find('li').each(function(){
|
||||
jQuery(this).attr('id', current_i);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
vc.events.on('vc-param-group-add-new',function(){
|
||||
|
||||
autoChange();
|
||||
|
||||
jQuery('.wpb_txt_icon_value').each(function(i,val){
|
||||
jQuery(this).attr('id', i+1);
|
||||
|
||||
var pcmd = jQuery(this).attr('id');
|
||||
var pmid = pcmd;
|
||||
|
||||
var val=jQuery("#"+pcmd).val();
|
||||
if(val==""){
|
||||
val="none";
|
||||
}
|
||||
if(val=="icon_color="){
|
||||
val="none";
|
||||
}
|
||||
|
||||
jQuery(".preview-icon-"+ pcmd ).html("<i class="+val+"></i>");
|
||||
|
||||
jQuery(".icon-list-"+ pcmd +" li[data-icons="+ val+"]").addClass("selected");
|
||||
|
||||
jQuery(".icons-list li").click(function() {
|
||||
|
||||
var id=jQuery(this).attr("id");
|
||||
jQuery(this).attr("class","selected").siblings().removeAttr("class");
|
||||
var icon = jQuery(this).attr("data-icons");
|
||||
|
||||
jQuery("#"+id).val(icon);
|
||||
jQuery(".preview-icon-"+id).html("<i class="+icon+"></i>");
|
||||
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
(function(){var l,i,r,n,o={}.hasOwnProperty;(n=function(){function t(){this.options_index=0,this.parsed=[]}return t.prototype.add_node=function(t){return"OPTGROUP"===t.nodeName.toUpperCase()?this.add_group(t):this.add_option(t)},t.prototype.add_group=function(t){var e,i,s,r,o,n;for(e=this.parsed.length,this.parsed.push({array_index:e,group:!0,label:this.escapeExpression(t.label),children:0,disabled:t.disabled}),n=[],s=0,r=(o=t.childNodes).length;s<r;s++)i=o[s],n.push(this.add_option(i,e,t.disabled));return n},t.prototype.add_option=function(t,e,i){if("OPTION"===t.nodeName.toUpperCase())return""!==t.text?(null!=e&&(this.parsed[e].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:t.value,text:t.text,html:t.innerHTML,selected:t.selected,disabled:!0===i?i:t.disabled,group_array_index:e,classes:t.className,style:t.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},t.prototype.escapeExpression=function(t){var e,i;return null==t||!1===t?"":/[\&\<\>\"\'\`]/.test(t)?(e={"<":"<",">":">",'"':""","'":"'","`":"`"},i=/&(?!\w+;)|[\<\>\"\'\`]/g,t.replace(i,function(t){return e[t]||"&"})):t},t}()).select_to_array=function(t){var e,i,s,r,o;for(i=new n,s=0,r=(o=t.childNodes).length;s<r;s++)e=o[s],i.add_node(e);return i.parsed},i=function(){function i(t,e){this.form_field=t,this.options=null!=e?e:{},i.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return i.prototype.set_default_values=function(){var e=this;return this.click_test_action=function(t){return e.test_active_click(t)},this.activate_action=function(t){return e.activate_field(t)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text&&this.options.allow_single_deselect,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null==this.options.enable_split_word_search||this.options.enable_split_word_search,this.group_search=null==this.options.group_search||this.options.group_search,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null==this.options.single_backstroke_delete||this.options.single_backstroke_delete,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null==this.options.display_selected_options||this.options.display_selected_options,this.display_disabled_options=null==this.options.display_disabled_options||this.options.display_disabled_options},i.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||i.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||i.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||i.default_no_result_text},i.prototype.mouse_enter=function(){return this.mouse_on_container=!0},i.prototype.mouse_leave=function(){return this.mouse_on_container=!1},i.prototype.input_focus=function(t){var e=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return e.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},i.prototype.input_blur=function(t){var e=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return e.blur_test()},100)},i.prototype.results_option_build=function(t){var e,i,s,r,o;for(e="",s=0,r=(o=this.results_data).length;s<r;s++)(i=o[s]).group?e+=this.result_add_group(i):e+=this.result_add_option(i),(null!=t?t.first:void 0)&&(i.selected&&this.is_multiple?this.choice_build(i):i.selected&&!this.is_multiple&&this.single_set_selected_text(i.text));return e},i.prototype.result_add_option=function(t){var e,i;return t.search_match&&this.include_option_in_results(t)?(e=[],t.disabled||t.selected&&this.is_multiple||e.push("active-result"),!t.disabled||t.selected&&this.is_multiple||e.push("disabled-result"),t.selected&&e.push("result-selected"),null!=t.group_array_index&&e.push("group-option"),""!==t.classes&&e.push(t.classes),(i=document.createElement("li")).className=e.join(" "),i.style.cssText=t.style,i.setAttribute("data-option-array-index",t.array_index),i.innerHTML=t.search_text,this.outerHTML(i)):""},i.prototype.result_add_group=function(t){var e;return(t.search_match||t.group_match)&&0<t.active_options?((e=documentLine truncated
|
||||
Reference in new issue
Block a user