Initial commit

This commit is contained in:
Almira Krdzic
2018-08-06 15:18:02 +02:00
commit d86f748bc6
363 changed files with 130876 additions and 0 deletions

2
js/chosen.jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

499
js/conditional_logic.js Normal file
View File

@@ -0,0 +1,499 @@
var __gf_timeout_handle;
gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
if( window.gf_form_conditional_logic ) {
var dependentFieldIds = rgars( gf_form_conditional_logic, [ formId, 'fields', gformExtractFieldId( fieldId ) ].join( '/' ) );
if( dependentFieldIds ) {
gf_apply_rules( formId, dependentFieldIds );
}
}
}, 10 );
function gf_apply_rules(formId, fields, isInit){
var rule_applied = 0;
jQuery(document).trigger( 'gform_pre_conditional_logic', [ formId, fields, isInit ] );
for(var i=0; i < fields.length; i++){
gf_apply_field_rule(formId, fields[i], isInit, function(){
rule_applied++;
if(rule_applied == fields.length){
jQuery(document).trigger('gform_post_conditional_logic', [formId, fields, isInit]);
if(window["gformCalculateTotalPrice"])
window["gformCalculateTotalPrice"](formId);
}
});
}
}
function gf_check_field_rule(formId, fieldId, isInit, callback){
//if conditional logic is not specified for that field, it is supposed to be displayed
if(!window["gf_form_conditional_logic"] || !window["gf_form_conditional_logic"][formId] || !window["gf_form_conditional_logic"][formId]["logic"][fieldId])
return "show";
var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
var action = gf_get_field_action(formId, conditionalLogic["section"]);
//If section is hidden, always hide field. If section is displayed, see if field is supposed to be displayed or hidden
if(action != "hide")
action = gf_get_field_action(formId, conditionalLogic["field"]);
return action;
}
function gf_apply_field_rule(formId, fieldId, isInit, callback){
var action = gf_check_field_rule(formId, fieldId, isInit, callback);
gf_do_field_action(formId, action, fieldId, isInit, callback);
var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
//perform conditional logic for the next button
if(conditionalLogic["nextButton"]){
action = gf_get_field_action(formId, conditionalLogic["nextButton"]);
gf_do_next_button_action(formId, action, fieldId, isInit);
}
}
function gf_get_field_action(formId, conditionalLogic){
if(!conditionalLogic)
return "show";
var matches = 0;
for(var i = 0; i < conditionalLogic["rules"].length; i++){
var rule = conditionalLogic["rules"][i];
if(gf_is_match(formId, rule))
matches++;
}
var action;
if( (conditionalLogic["logicType"] == "all" && matches == conditionalLogic["rules"].length) || (conditionalLogic["logicType"] == "any" && matches > 0) )
action = conditionalLogic["actionType"];
else
action = conditionalLogic["actionType"] == "show" ? "hide" : "show";
return action;
}
function gf_is_match( formId, rule ) {
var $ = jQuery,
inputId = rule['fieldId'],
fieldId = gformExtractFieldId( inputId ),
inputIndex = gformExtractInputIndex( inputId ),
isInputSpecific = inputIndex !== false,
$inputs;
if( isInputSpecific ) {
$inputs = $( '#input_{0}_{1}_{2}'.format( formId, fieldId, inputIndex ) );
} else {
$inputs = $( 'input[id="input_{0}_{1}"], input[id^="input_{0}_{1}_"], input[id^="choice_{0}_{1}_"], select#input_{0}_{1}, textarea#input_{0}_{1}'.format( formId, rule.fieldId ) );
}
var isCheckable = $.inArray( $inputs.attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1,
isMatch = isCheckable ? gf_is_match_checkable( $inputs, rule, formId, fieldId ) : gf_is_match_default( $inputs.eq( 0 ), rule, formId, fieldId );
return gform.applyFilters( 'gform_is_value_match', isMatch, formId, rule );
}
function gf_is_match_checkable( $inputs, rule, formId, fieldId ) {
var isMatch = false;
$inputs.each( function() {
var $input = jQuery( this ),
fieldValue = gf_get_value( $input.val() ),
isRangeOperator = jQuery.inArray( rule.operator, [ '<', '>' ] ) !== -1,
isStringOperator = jQuery.inArray( rule.operator, [ 'contains', 'starts_with', 'ends_with' ] ) !== -1;
// if we are looking for a specific value and this is not it, skip
if( fieldValue != rule.value && ! isRangeOperator && ! isStringOperator ) {
return; // continue
}
// force an empty value for unchecked items
if( ! $input.is( ':checked' ) ) {
fieldValue = '';
}
// if the 'other' choice is selected, get the value from the 'other' text input
else if ( fieldValue == 'gf_other_choice' ) {
fieldValue = $( '#input_{0}_{1}_other'.format( formId, fieldId ) ).val();
}
if( gf_matches_operation( fieldValue, rule.value, rule.operator ) ) {
isMatch = true;
return false; // break
}
} );
return isMatch;
}
function gf_is_match_default( $input, rule, formId, fieldId ) {
var val = $input.val(),
values = ( val instanceof Array ) ? val : [ val ], // transform regular value into array to support multi-select (which returns an array of selected items)
matchCount = 0;
for( var i = 0; i < values.length; i++ ) {
// fields with pipes in the value will use the label for conditional logic comparison
var hasLabel = values[i] ? values[i].indexOf( '|' ) >= 0 : true,
fieldValue = gf_get_value( values[i] );
var fieldNumberFormat = gf_get_field_number_format( rule.fieldId, formId, 'value' );
if( fieldNumberFormat && ! hasLabel ) {
fieldValue = gf_format_number( fieldValue, fieldNumberFormat );
}
var ruleValue = rule.value;
//if ( fieldNumberFormat ) {
// ruleValue = gf_format_number( ruleValue, fieldNumberFormat );
//}
if( gf_matches_operation( fieldValue, ruleValue, rule.operator ) ) {
matchCount++;
}
}
// if operator is 'isnot', none of the values can match
var isMatch = rule.operator == 'isnot' ? matchCount == values.length : matchCount > 0;
return isMatch;
}
function gf_format_number( value, fieldNumberFormat ) {
decimalSeparator = '.';
if( fieldNumberFormat == 'currency' ) {
decimalSeparator = gformGetDecimalSeparator( 'currency' );
} else if( fieldNumberFormat == 'decimal_comma' ) {
decimalSeparator = ',';
} else if( fieldNumberFormat == 'decimal_dot' ) {
decimalSeparator = '.';
}
// transform to a decimal dot number
value = gformCleanNumber( value, '', '', decimalSeparator );
/**
* Looking at format specified by wp locale creates issues. When performing conditional logic, all numbers will be formatted to decimal dot and then compared that way. AC
*/
// now transform to number specified by locale
// if( window['gf_number_format'] && window['gf_number_format'] == 'decimal_comma' ) {
// value = gformFormatNumber( value, -1, ',', '.' );
// }
if( ! value ) {
value = 0;
}
number = value.toString();
return number;
}
function gf_try_convert_float(text){
/*
* The only format that should matter is the field format. Attempting to do this by WP locale creates a lot of issues with consistency.
* var format = window["gf_number_format"] == "decimal_comma" ? "decimal_comma" : "decimal_dot";
*/
var format = 'decimal_dot';
if( gformIsNumeric( text, format ) ) {
var decimal_separator = format == "decimal_comma" ? "," : ".";
return gformCleanNumber( text, "", "", decimal_separator );
}
return text;
}
function gf_matches_operation(val1, val2, operation){
val1 = val1 ? val1.toLowerCase() : "";
val2 = val2 ? val2.toLowerCase() : "";
switch(operation){
case "is" :
return val1 == val2;
break;
case "isnot" :
return val1 != val2;
break;
case ">" :
val1 = gf_try_convert_float(val1);
val2 = gf_try_convert_float(val2);
return gformIsNumber(val1) && gformIsNumber(val2) ? val1 > val2 : false;
break;
case "<" :
val1 = gf_try_convert_float(val1);
val2 = gf_try_convert_float(val2);
return gformIsNumber(val1) && gformIsNumber(val2) ? val1 < val2 : false;
break;
case "contains" :
return val1.indexOf(val2) >=0;
break;
case "starts_with" :
return val1.indexOf(val2) ==0;
break;
case "ends_with" :
var start = val1.length - val2.length;
if(start < 0)
return false;
var tail = val1.substring(start);
return val2 == tail;
break;
}
return false;
}
function gf_get_value(val){
if(!val)
return "";
val = val.split("|");
return val[0];
}
function gf_do_field_action(formId, action, fieldId, isInit, callback){
var conditional_logic = window["gf_form_conditional_logic"][formId];
var dependent_fields = conditional_logic["dependents"][fieldId];
for(var i=0; i < dependent_fields.length; i++){
var targetId = fieldId == 0 ? "#gform_submit_button_" + formId : "#field_" + formId + "_" + dependent_fields[i];
var defaultValues = conditional_logic["defaults"][dependent_fields[i]];
//calling callback function on the last dependent field, to make sure it is only called once
do_callback = (i+1) == dependent_fields.length ? callback : null;
gf_do_action(action, targetId, conditional_logic["animation"], defaultValues, isInit, do_callback, formId);
gform.doAction('gform_post_conditional_logic_field_action', formId, action, targetId, defaultValues, isInit);
}
}
function gf_do_next_button_action(formId, action, fieldId, isInit){
var conditional_logic = window["gf_form_conditional_logic"][formId];
var targetId = "#gform_next_button_" + formId + "_" + fieldId;
gf_do_action(action, targetId, conditional_logic["animation"], null, isInit, null, formId);
}
function gf_do_action(action, targetId, useAnimation, defaultValues, isInit, callback, formId){
var $target = jQuery( targetId );
/**
* Do not re-enable inputs that are disabled by default. Check if field's inputs have been assessed. If not, add
* designator class so these inputs are exempted below.
*/
if( ! $target.data( 'gf-disabled-assessed' ) ) {
$target.find( 'input:hidden:disabled' ).addClass( 'gf-default-disabled' );
$target.data( 'gf-disabled-assessed', true );
}
if(action == "show"){
// reset tabindex for selects
$target.find( 'select' ).each( function() {
$select = jQuery( this );
$select.attr( 'tabindex', $select.data( 'tabindex' ) );
} );
if(useAnimation && !isInit){
if($target.length > 0){
$target.find('input:hidden:not(.gf-default-disabled)').prop( 'disabled', false );
$target.slideDown(callback);
} else if(callback){
callback();
}
}
else{
var display = $target.data('gf_display');
//defaults to list-item if previous (saved) display isn't set for any reason
if ( display == '' || display == 'none' ){
display = 'list-item';
}
$target.find('input:hidden:not(.gf-default-disabled)').prop( 'disabled', false );
$target.css('display', display);
if(callback){
callback();
}
}
}
else{
//if field is not already hidden, reset its values to the default
var child = $target.children().first();
if (child.length > 0){
var reset = gform.applyFilters('gform_reset_pre_conditional_logic_field_action', true, formId, targetId, defaultValues, isInit);
if(reset && !gformIsHidden(child)){
gf_reset_to_default(targetId, defaultValues);
}
}
// remove tabindex and stash as a data attr for selects
$target.find( 'select' ).each( function() {
$select = jQuery( this );
$select.data( 'tabindex', $select.attr( 'tabindex' ) ).removeAttr( 'tabindex' );
} );
//Saving existing display so that it can be reset when showing the field
if( ! $target.data('gf_display') ){
$target.data('gf_display', $target.css('display'));
}
if(useAnimation && !isInit){
if($target.length > 0 && $target.is(":visible")) {
$target.slideUp(callback);
} else if(callback) {
callback();
}
} else{
$target.hide();
$target.find('input:hidden:not(.gf-default-disabled)').prop( 'disabled', true );
if(callback){
callback();
}
}
}
}
function gf_reset_to_default(targetId, defaultValue){
var dateFields = jQuery( targetId ).find( '.gfield_date_month input, .gfield_date_day input, .gfield_date_year input, .gfield_date_dropdown_month select, .gfield_date_dropdown_day select, .gfield_date_dropdown_year select' );
if( dateFields.length > 0 ) {
dateFields.each( function(){
var element = jQuery( this );
// defaultValue is associative array (i.e. [ m: 1, d: 13, y: 1987 ] )
if( defaultValue ) {
var key = 'd';
if (element.parents().hasClass('gfield_date_month') || element.parents().hasClass('gfield_date_dropdown_month') ){
key = 'm';
}
else if(element.parents().hasClass('gfield_date_year') || element.parents().hasClass('gfield_date_dropdown_year') ){
key = 'y';
}
val = defaultValue[ key ];
}
else{
val = "";
}
if(element.prop("tagName") == "SELECT" && val != '' )
val = parseInt(val);
if(element.val() != val)
element.val(val).trigger("change");
else
element.val(val);
});
return;
}
//cascading down conditional logic to children to suppport nested conditions
//text fields and drop downs, filter out list field text fields name with "_shim"
var target = jQuery(targetId).find('select, input[type="text"]:not([id*="_shim"]), input[type="number"], textarea');
var target_index = 0;
target.each(function(){
var val = "";
var element = jQuery(this);
//get name of previous input field to see if it is the radio button which goes with the "Other" text box
//otherwise field is populated with input field name
var radio_button_name = element.prev("input").attr("value");
if(radio_button_name == "gf_other_choice"){
val = element.attr("value");
}
else if(jQuery.isArray(defaultValue)){
val = defaultValue[target_index];
}
else if(jQuery.isPlainObject(defaultValue)){
val = defaultValue[element.attr("name")];
if( ! val ) {
// 'input_123_3_1' => '3.1'
var inputId = element.attr( 'id' ).split( '_' ).slice( 2 ).join( '.' );
val = defaultValue[ inputId ];
}
}
else if(defaultValue){
val = defaultValue;
}
if( element.is('select:not([multiple])') && ! val ) {
val = element.find( 'option' ).not( ':disabled' ).eq(0).val();
}
if(element.val() != val) {
element.val(val).trigger('change');
if (element.is('select') && element.next().hasClass('chosen-container')) {
element.trigger('chosen:updated');
}
}
else{
element.val(val);
}
target_index++;
});
//checkboxes and radio buttons
var elements = jQuery(targetId).find('input[type="radio"], input[type="checkbox"]:not(".copy_values_activated")');
elements.each(function(){
//is input currently checked?
var isChecked = jQuery(this).is(':checked') ? true : false;
//does input need to be marked as checked or unchecked?
var doCheck = defaultValue ? jQuery.inArray(jQuery(this).attr('id'), defaultValue) > -1 : false;
//if value changed, trigger click event
if(isChecked != doCheck){
//setting input as checked or unchecked appropriately
if(jQuery(this).attr("type") == "checkbox"){
jQuery(this).trigger('click');
}
else{
jQuery(this).prop("checked", doCheck);
//need to set the prop again after the click is triggered
jQuery(this).trigger('click').prop('checked', doCheck);
}
}
});
}

1
js/conditional_logic.min.js vendored Normal file

File diff suppressed because one or more lines are too long

55
js/datepicker.js Normal file
View File

@@ -0,0 +1,55 @@
jQuery(document).ready(gformInitDatepicker);
function gformInitDatepicker() {
jQuery('.datepicker').each(function () {
var element = jQuery(this),
inputId = this.id,
optionsObj = {
yearRange: '-100:+20',
showOn: 'focus',
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true,
suppressDatePicker: false,
onClose: function () {
element.focus();
var self = this;
this.suppressDatePicker = true;
setTimeout( function() {
self.suppressDatePicker = false;
}, 200 );
},
beforeShow: function( input, inst ) {
return ! this.suppressDatePicker;
}
};
if (element.hasClass('dmy')) {
optionsObj.dateFormat = 'dd/mm/yy';
} else if (element.hasClass('dmy_dash')) {
optionsObj.dateFormat = 'dd-mm-yy';
} else if (element.hasClass('dmy_dot')) {
optionsObj.dateFormat = 'dd.mm.yy';
} else if (element.hasClass('ymd_slash')) {
optionsObj.dateFormat = 'yy/mm/dd';
} else if (element.hasClass('ymd_dash')) {
optionsObj.dateFormat = 'yy-mm-dd';
} else if (element.hasClass('ymd_dot')) {
optionsObj.dateFormat = 'yy.mm.dd';
}
if (element.hasClass('datepicker_with_icon')) {
optionsObj.showOn = 'both';
optionsObj.buttonImage = jQuery('#gforms_calendar_icon_' + inputId).val();
optionsObj.buttonImageOnly = true;
}
inputId = inputId.split('_');
// allow the user to override the datepicker options object
optionsObj = gform.applyFilters('gform_datepicker_options_pre_init', optionsObj, inputId[1], inputId[2]);
element.datepicker(optionsObj);
});
}

1
js/datepicker.min.js vendored Normal file
View File

@@ -0,0 +1 @@
function gformInitDatepicker(){jQuery(".datepicker").each(function(){var a=jQuery(this),b=this.id,c={yearRange:"-100:+20",showOn:"focus",dateFormat:"mm/dd/yy",changeMonth:!0,changeYear:!0,suppressDatePicker:!1,onClose:function(){a.focus();var b=this;this.suppressDatePicker=!0,setTimeout(function(){b.suppressDatePicker=!1},200)},beforeShow:function(a,b){return!this.suppressDatePicker}};a.hasClass("dmy")?c.dateFormat="dd/mm/yy":a.hasClass("dmy_dash")?c.dateFormat="dd-mm-yy":a.hasClass("dmy_dot")?c.dateFormat="dd.mm.yy":a.hasClass("ymd_slash")?c.dateFormat="yy/mm/dd":a.hasClass("ymd_dash")?c.dateFormat="yy-mm-dd":a.hasClass("ymd_dot")&&(c.dateFormat="yy.mm.dd"),a.hasClass("datepicker_with_icon")&&(c.showOn="both",c.buttonImage=jQuery("#gforms_calendar_icon_"+b).val(),c.buttonImageOnly=!0),b=b.split("_"),c=gform.applyFilters("gform_datepicker_options_pre_init",c,b[1],b[2]),a.datepicker(c)})}jQuery(document).ready(gformInitDatepicker);

18
js/floatmenu_init.js Normal file
View File

@@ -0,0 +1,18 @@
// change the menu position based on the scroll position
window.onscroll = function() {
var toolbar = jQuery( '#gf_form_toolbar' );
var floatMenu = jQuery( '#floatMenu' );
if( window.XMLHttpRequest && toolbar.length > 0 ) {
var basePosition = toolbar.offset().top;
if( document.documentElement.scrollTop > basePosition || self.pageYOffset > basePosition ) {
floatMenu.css( { position: 'fixed', top: '40px' } );
} else {
floatMenu.css( { position: 'static', top: '40px' } );
}
}
}

1
js/floatmenu_init.min.js vendored Normal file
View File

@@ -0,0 +1 @@
window.onscroll=function(){var a=jQuery("#gf_form_toolbar"),b=jQuery("#floatMenu");if(window.XMLHttpRequest&&a.length>0){var c=a.offset().top;document.documentElement.scrollTop>c||self.pageYOffset>c?b.css({position:"fixed",top:"40px"}):b.css({position:"static",top:"40px"})}};

1643
js/form_admin.js Normal file

File diff suppressed because it is too large Load Diff

1
js/form_admin.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3722
js/form_editor.js Normal file

File diff suppressed because one or more lines are too long

3
js/form_editor.min.js vendored Normal file

File diff suppressed because one or more lines are too long

63
js/forms.js Normal file
View File

@@ -0,0 +1,63 @@
function Form(){
this.id = 0;
this.title = gf_vars.formTitle;
this.description = gf_vars.formDescription;
this.labelPlacement = "top_label";
this.subLabelPlacement = "below";
this.maxEntriesMessage = "";
this.confirmation = new Confirmation();
this.button = new Button();
this.fields = new Array();
}
function Confirmation(){
this.type = "message";
this.message = gf_vars.formConfirmationMessage;
this.url = "";
this.pageId = "";
this.queryString="";
}
function Button(){
this.type = "text";
this.text = gf_vars.buttonText;
this.imageUrl = "";
}
function Field(id, type){
this.id = id;
this.label = "";
this.adminLabel = "";
this.type = type;
this.isRequired = false;
this.size = "medium";
this.errorMessage = "";
this.visibility = "visible";
//NOTE: other properties will be added dynamically using associative array syntax
}
function Choice(text, value, price){
this.text=text;
this.value = value ? value : text;
this.isSelected = false;
this.price = price ? price : "";
}
function Input(id, label){
this.id = id;
this.label = label;
this.name = "";
}
function ConditionalLogic(){
this.actionType = "show"; //show or hide
this.logicType = "all"; //any or all
this.rules = [new ConditionalRule()];
}
function ConditionalRule(){
this.fieldId = 0;
this.operator = "is"; //is or isnot
this.value = "";
}

1
js/forms.min.js vendored Normal file
View File

@@ -0,0 +1 @@
function Form(){this.id=0,this.title=gf_vars.formTitle,this.description=gf_vars.formDescription,this.labelPlacement="top_label",this.subLabelPlacement="below",this.maxEntriesMessage="",this.confirmation=new Confirmation,this.button=new Button,this.fields=new Array}function Confirmation(){this.type="message",this.message=gf_vars.formConfirmationMessage,this.url="",this.pageId="",this.queryString=""}function Button(){this.type="text",this.text=gf_vars.buttonText,this.imageUrl=""}function Field(a,b){this.id=a,this.label="",this.adminLabel="",this.type=b,this.isRequired=!1,this.size="medium",this.errorMessage="",this.visibility="visible"}function Choice(a,b,c){this.text=a,this.value=b||a,this.isSelected=!1,this.price=c||""}function Input(a,b){this.id=a,this.label=b,this.name=""}function ConditionalLogic(){this.actionType="show",this.logicType="all",this.rules=[new ConditionalRule]}function ConditionalRule(){this.fieldId=0,this.operator="is",this.value=""}

332
js/gf_field_filter.js Normal file
View File

@@ -0,0 +1,332 @@
(function (gfFieldFilterUI, $) {
$.fn.gfFilterUI = function(filterSettings, initVars, allowMultiple, minResizeHeight) {
init(this, filterSettings, initVars, allowMultiple, minResizeHeight );
return this;
};
// private
var $container, operatorStrings, settings, filters, mode, imagesURL, isResizable, allowMultiple, height;
function init (c, s, initVars, m, h){
$container = $(c);
$container
.css('position' , 'relative')
.html('<div id="gform-field-filters"></div>');
height = h;
isResizable = typeof height != 'undefined' && height > 0;
operatorStrings = {"is":"is","isnot":"isNot", ">":"greaterThan", "<":"lessThan", "contains":"contains", "starts_with":"startsWith", "ends_with":"endsWith"};
imagesURL = gf_vars.baseUrl + "/images";
settings = s;
filters = initVars && initVars.filters ? initVars.filters : [];
mode = initVars && initVars.mode ? initVars.mode : "all";
allowMultiple = typeof m == 'undefined' || m ? true : false ;
setUpFilters(filters);
}
function setUpFilters(filters) {
var i;
$container.on('change', '.gform-filter-field', function(){
changeField(this);
});
$container.on('click', '#gform-no-filters', function(e){
if($('.gform-field-filter').length == 0){
addNewFieldFilter(this);
}
$(this).remove();
});
$container.on('click', '.gform-add', function(){
addNewFieldFilter(this);
});
$container.on('click', '.gform-remove', function(){
removeFieldFilter(this);
});
$container.on('change', '.gform-filter-operator', function(){
changeOperator(this, this.value);
});
if (typeof filters == 'undefined' || filters.length == 0){
displayNoFiltersMessage();
return;
}
if(mode != "off"){
$("#gform-field-filters").append(getFilterMode(mode));
}
for (i = 0; i < filters.length; i++) {
$("#gform-field-filters").append(getNewFilterRow());
}
$(".gform-filter-field").each(function (i) {
var fieldId = filters[i].field;
jQuery(this).val(fieldId);
changeField(this);
});
$(".gform-filter-operator").each(function (i) {
var operator = filters[i].operator;
jQuery(this).val(operator);
changeOperator(this, this.value);
});
$(".gform-filter-value").each(function (i) {
var value = filters[i].value;
jQuery(this).val(value);
jQuery(this).change();
});
maybeMakeResizable()
}
function getNewFilterRow() {
var str;
str = "<div class='gform-field-filter'>";
str += getFilterFields() + getFilterOperators() + getFilterValues() + getAddRemoveButtons();
str += "</div>";
return str;
}
function getFilterFields() {
var i, j, key, val, label, question, options, disabled = "", numRows,
select = [];
select.push("<select class='gform-filter-field' name='f[]' >");
for (i = 0; i < settings.length; i++) {
key = settings[i].key;
if (settings[i].group) {
question = settings[i].text;
numRows = settings[i].filters.length;
options = [];
for (j = 0; j < numRows; j++) {
label = settings[i].filters[j].text;
val = settings[i].filters[j].key;
disabled = isFieldSelected(val) ? 'disabled="disabled"' : "";
options.push('<option {0} value="{1}">{2}</option>'.format(disabled, val, label));
}
select.push('<optgroup label="{0}">{1}</optgroup>'.format(question, options.join('')));
} else {
disabled = settings[i].preventMultiple && isFieldSelected(key) ? "disabled='disabled'" : "";
label = settings[i].text;
select.push('<option {0} value="{1}">{2}</option>'.format(disabled, key, label));
}
}
select.push("</select>");
select.push("<input type='hidden' class='gform-filter-type' name='t[]' value='' >");
return select.join('');
}
function changeOperator (operatorSelect) {
var $select = $(operatorSelect);
var $fieldSelect = $select.siblings('.gform-filter-field');
var filter = getFilter($fieldSelect.val());
if (filter) {
$select.siblings(".gform-filter-value").replaceWith(getFilterValues(filter, operatorSelect.value));
}
setDisabledFields();
if(window['gformInitDatepicker']) {gformInitDatepicker();}
}
function changeField (fieldSelect) {
var filter = getFilter(fieldSelect.value);
if (filter) {
var $select = $(fieldSelect);
$select.siblings(".gform-filter-value").replaceWith(getFilterValues(filter));
$select.siblings(".gform-filter-type").val(filter.type);
$select.siblings(".gform-filter-operator").replaceWith(getFilterOperators(filter));
$select.siblings(".gform-filter-operator").change();
}
setDisabledFields();
}
function isFieldSelected (fieldId) {
fieldId = fieldId.toString();
var selectedFields = [];
$('.gform-filter-field :selected').each(function (i, selected) {
selectedFields[i] = $(selected).val();
});
return $.inArray(fieldId, selectedFields) > -1 ? true : false;
}
function getFilterOperators (filter) {
var i, operator,
str = "<select name='o[]' class='gform-filter-operator'>";
if (filter) {
for (i = 0; i < filter.operators.length; i++) {
operator = filter.operators[i];
str += '<option value="{0}">{1}</option>'.format(operator, gf_vars[operatorStrings[operator]] );
}
}
str += "</select>";
return str;
}
function getFilterValues (filter, selectedOperator) {
var i, val, text, str, options = "", placeholder, cssClass, supporterOperators;
cssClass = 'gform-filter-value';
if ( filter && typeof filter.cssClass != 'undefined' ) {
cssClass += ' ' + filter.cssClass;
}
if ( filter && filter.values && selectedOperator != 'contains' ) {
if ( typeof filter.placeholder != 'undefined' ){
options += '<option value="">{0}</option>'.format(filter.placeholder);
}
for (i = 0; i < filter.values.length; i++) {
val = filter.values[i].value;
text = filter.values[i].text;
if ( filter.values[i].operators && $.inArray( selectedOperator, filter.values[i].operators ) === -1 ) {
continue;
}
options += '<option value="{0}">{1}</option>'.format(val, text);
}
str = "<select name='v[]' class='{0}'>{1}</select>".format(cssClass, options);
} else {
placeholder = ( filter && typeof filter.placeholder != 'undefined' ) ? "placeholder='{0}'".format(filter.placeholder) : '';
str = "<input type='text' value='' name='v[]' class='{0}' {1}/>".format(cssClass, placeholder);
}
return str;
}
function getFilter (key) {
if (!key)
return;
for (var i = 0; i < settings.length; i++) {
if (key == settings[i].key)
return settings[i];
if (settings[i].group) {
for (var j = 0; j < settings[i].filters.length; j++) {
if (key == settings[i].filters[j].key)
return settings[i].filters[j];
}
}
}
}
function getAddRemoveButtons () {
var str = "";
if(!allowMultiple)
return str;
str += "<img class='gform-add' src='{0}/add.png' alt='{1}' title='{2}'>".format(imagesURL, gf_vars.addFieldFilter, gf_vars.addFieldFilter);
str += "<img class='gform-remove' src='" + imagesURL + "/remove.png' alt='" + gf_vars.removeFieldFilter + "' title='" + gf_vars.removeFieldFilter + "'>";
return str;
}
function maybeMakeResizable () {
if(!isResizable)
return;
var $filterBox = $("#gform-field-filters");
var $filters = $(".gform-field-filter");
if ($filters.length <= 1) {
if ($($container).hasClass('ui-resizable'))
$container.resizable('destroy');
return;
}
var makeResizable = ($filterBox.get(0).scrollHeight > $container.height()) || $container.height() >= height;
if (makeResizable) {
$container
.css({'min-height': height + 'px' , 'border-bottom': '5px double #DDD'})
.resizable({
handles : 's',
minHeight: height
});
$filterBox.css("min-height", height);
} else {
$container.css({'min-height': '', 'border-bottom': ''});
}
}
function displayNoFiltersMessage () {
var str = "";
str += "<div id='gform-no-filters' >" + gf_vars.addFieldFilter;
str += "<img class='gform-add' src='{0}/add.png' alt='{1}' title='{2}'></div>".format(imagesURL, gf_vars.addFieldFilter, gf_vars.addFieldFilter);
$("#gform-field-filters").html(str);
if(isResizable){
$container.css({'min-height': '', 'border-bottom': ''});
$container.height(80);
$("#gform-field-filters").css("min-height", '');
}
}
function setDisabledFields () {
$("select.gform-filter-field option").removeAttr("disabled");
$("select.gform-filter-field").each(function (i) {
var filter = getFilter(this.value);
if (typeof(filter) != 'undefined' && filter.preventMultiple && isFieldSelected(this.value)) {
$("select.gform-filter-field option[value='" + this.value + "']:not(:selected)").attr('disabled', 'disabled');
}
});
}
function getFilterMode(mode){
var html;
html = '<select name="mode"><option value="all" {0}>{1}</option><option value="any" {2}>{3}</option></select>'.format(selected("all", mode), gf_vars.all, selected("any", mode), gf_vars.any);
html = gf_vars.filterAndAny.format(html);
return html
}
function selected(selected, current){
return selected == current ? 'selected="selected"' : "";
}
function addFilterMode ($filterRow) {
$filterRow.after(getFilterMode());
}
function addNewFieldFilter (el) {
var $el, $filterRow;
$el = $(el);
if($el.is("img"))
$filterRow = $el.parent();
else
$filterRow = $el;
$filterRow.after(getNewFilterRow());
$filterRow.next("div")
.find(".gform-filter-field").change()
.find(".gform-filter-operator").change();
if ($(".gform-field-filter").length == 1){
addFilterMode($filterRow);
}
maybeMakeResizable();
}
function removeFieldFilter (img) {
$(img).parent().remove();
if ($(".gform-field-filter").length == 0)
displayNoFiltersMessage();
setDisabledFields();
maybeMakeResizable();
}
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}(window.gfFilterUI = window.gfFilterUI || {}, jQuery));

1
js/gf_field_filter.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1907
js/gravityforms.js Normal file

File diff suppressed because it is too large Load Diff

1
js/gravityforms.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
js/index.php Normal file
View File

@@ -0,0 +1,2 @@
<?php
//Nothing to see here

160
js/jquery.json-1.3.js Normal file
View File

@@ -0,0 +1,160 @@
/*
* jQuery JSON Plugin
* version: 1.0 (2008-04-17)
*
* This document is licensed as free software under the terms of the
* MIT License: http://www.opensource.org/licenses/mit-license.php
*
* Brantley Harris technically wrote this plugin, but it is based somewhat
* on the JSON.org website's http://www.json.org/json2.js, which proclaims:
* "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
* I uphold. I really just cleaned it up.
*
* It is also based heavily on MochiKit's serializeJSON, which is
* copywrited 2005 by Bob Ippolito.
*/
(function($) {
function toIntegersAtLease(n)
// Format integers to have at least two digits.
{
return n < 10 ? '0' + n : n;
}
Date.prototype.toJSON = function(date)
// Yes, it polutes the Date namespace, but we'll allow it here, as
// it's damned usefull.
{
return this.getUTCFullYear() + '-' +
toIntegersAtLease(this.getUTCMonth()) + '-' +
toIntegersAtLease(this.getUTCDate());
};
var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
var meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
};
$.quoteString = function(string)
// Places quotes around a string, inteligently.
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
{
//if (escapeable.test(string))
//{
return '"' + string.replace(escapeable, function (a)
{
var c = meta[a];
if (typeof c === 'string') {
return c;
}
c = a.charCodeAt();
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
}) + '"';
//}
//else{
// string = string.replace('\n','\\n');
//}
return '"' + string + '"';
};
$.toJSON = function(o, compact)
{
var type = typeof(o);
if (type == "undefined")
return "undefined";
else if (type == "number" || type == "boolean")
return o + "";
else if (o === null)
return "null";
// Is it a string?
if (type == "string")
{
var str = $.quoteString(o);
return str;
}
// Does it have a .toJSON function?
if (type == "object" && typeof o.toJSON == "function")
return o.toJSON(compact);
// Is it an array?
if (type != "function" && typeof(o.length) == "number")
{
var ret = [];
for (var i = 0; i < o.length; i++) {
ret.push( $.toJSON(o[i], compact) );
}
if (compact)
return "[" + ret.join(",") + "]";
else
return "[" + ret.join(", ") + "]";
}
// If it's a function, we have to warn somebody!
if (type == "function") {
throw new TypeError("Unable to convert object of type 'function' to json.");
}
// It's probably an object, then.
var ret = [];
for (var k in o) {
var name;
type = typeof(k);
if (type == "number")
name = '"' + k + '"';
else if (type == "string")
name = $.quoteString(k);
else
continue; //skip non-string or number keys
var val = $.toJSON(o[k], compact);
if (typeof(val) != "string") {
// skip non-serializable values
continue;
}
if (compact)
ret.push(name + ":" + val);
else
ret.push(name + ": " + val);
}
return "{" + ret.join(", ") + "}";
};
$.compactJSON = function(o)
{
return $.toJSON(o, true);
};
$.evalJSON = function(src)
// Evals JSON that we know to be safe.
{
return eval("(" + src + ")");
};
$.secureEvalJSON = function(src)
// Evals JSON in a way that is *more* secure.
{
var filtered = src;
filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@');
filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
if (/^[\],:{}\s]*$/.test(filtered))
return eval("(" + src + ")");
else
throw new SyntaxError("Error parsing JSON, source is not valid.");
};
})(jQuery);

1
js/jquery.json-1.3.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function($){function toIntegersAtLease(a){return a<10?"0"+a:a}Date.prototype.toJSON=function(a){return this.getUTCFullYear()+"-"+toIntegersAtLease(this.getUTCMonth())+"-"+toIntegersAtLease(this.getUTCDate())};var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};$.quoteString=function(a){return'"'+a.replace(escapeable,function(a){var b=meta[a];return"string"==typeof b?b:(b=a.charCodeAt(),"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16))})+'"'},$.toJSON=function(a,b){var c=typeof a;if("undefined"==c)return"undefined";if("number"==c||"boolean"==c)return a+"";if(null===a)return"null";if("string"==c){return $.quoteString(a)}if("object"==c&&"function"==typeof a.toJSON)return a.toJSON(b);if("function"!=c&&"number"==typeof a.length){for(var d=[],e=0;e<a.length;e++)d.push($.toJSON(a[e],b));return b?"["+d.join(",")+"]":"["+d.join(", ")+"]"}if("function"==c)throw new TypeError("Unable to convert object of type 'function' to json.");var d=[];for(var f in a){var g;if("number"==(c=typeof f))g='"'+f+'"';else{if("string"!=c)continue;g=$.quoteString(f)}var h=$.toJSON(a[f],b);"string"==typeof h&&(b?d.push(g+":"+h):d.push(g+": "+h))}return"{"+d.join(", ")+"}"},$.compactJSON=function(a){return $.toJSON(a,!0)},$.evalJSON=function(src){return eval("("+src+")")},$.secureEvalJSON=function(src){var filtered=src;if(filtered=filtered.replace(/\\["\\\/bfnrtu]/g,"@"),filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]"),filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(filtered))return eval("("+src+")");throw new SyntaxError("Error parsing JSON, source is not valid.")}}(jQuery);

200
js/jquery.json.js Normal file
View File

@@ -0,0 +1,200 @@
/**
* jQuery JSON plugin v2.5.1
* https://github.com/Krinkle/jquery-json
*
* @author Brantley Harris, 2009-2011
* @author Timo Tijhof, 2011-2014
* @source This plugin is heavily influenced by MochiKit's serializeJSON, which is
* copyrighted 2005 by Bob Ippolito.
* @source Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
* website's http://www.json.org/json2.js, which proclaims:
* "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
* I uphold.
* @license MIT License <http://opensource.org/licenses/MIT>
*/
(function ($) {
'use strict';
var escape = /["\\\x00-\x1f\x7f-\x9f]/g,
meta = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"': '\\"',
'\\': '\\\\'
},
hasOwn = Object.prototype.hasOwnProperty;
/**
* jQuery.toJSON
* Converts the given argument into a JSON representation.
*
* @param o {Mixed} The json-serializable *thing* to be converted
*
* If an object has a toJSON prototype, that will be used to get the representation.
* Non-integer/string keys are skipped in the object, as are keys that point to a
* function.
*
*/
$.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) {
if (o === null) {
return 'null';
}
var pairs, k, name, val,
type = $.type(o);
if (type === 'undefined') {
return undefined;
}
// Also covers instantiated Number and Boolean objects,
// which are typeof 'object' but thanks to $.type, we
// catch them here. I don't know whether it is right
// or wrong that instantiated primitives are not
// exported to JSON as an {"object":..}.
// We choose this path because that's what the browsers did.
if (type === 'number' || type === 'boolean') {
return String(o);
}
if (type === 'string') {
return $.quoteString(o);
}
if (typeof o.toJSON === 'function') {
return $.toJSON(o.toJSON());
}
if (type === 'date') {
var month = o.getUTCMonth() + 1,
day = o.getUTCDate(),
year = o.getUTCFullYear(),
hours = o.getUTCHours(),
minutes = o.getUTCMinutes(),
seconds = o.getUTCSeconds(),
milli = o.getUTCMilliseconds();
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
if (hours < 10) {
hours = '0' + hours;
}
if (minutes < 10) {
minutes = '0' + minutes;
}
if (seconds < 10) {
seconds = '0' + seconds;
}
if (milli < 100) {
milli = '0' + milli;
}
if (milli < 10) {
milli = '0' + milli;
}
return '"' + year + '-' + month + '-' + day + 'T' +
hours + ':' + minutes + ':' + seconds +
'.' + milli + 'Z"';
}
pairs = [];
if ($.isArray(o)) {
for (k = 0; k < o.length; k++) {
pairs.push($.toJSON(o[k]) || 'null');
}
return '[' + pairs.join(',') + ']';
}
// Any other object (plain object, RegExp, ..)
// Need to do typeof instead of $.type, because we also
// want to catch non-plain objects.
if (typeof o === 'object') {
for (k in o) {
// Only include own properties,
// Filter out inherited prototypes
if (hasOwn.call(o, k)) {
// Keys must be numerical or string. Skip others
type = typeof k;
if (type === 'number') {
name = '"' + k + '"';
} else if (type === 'string') {
name = $.quoteString(k);
} else {
continue;
}
type = typeof o[k];
// Invalid values like these return undefined
// from toJSON, however those object members
// shouldn't be included in the JSON string at all.
if (type !== 'function' && type !== 'undefined') {
val = $.toJSON(o[k]);
pairs.push(name + ':' + val);
}
}
}
return '{' + pairs.join(',') + '}';
}
};
/**
* jQuery.evalJSON
* Evaluates a given json string.
*
* @param str {String}
*/
$.evalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
/*jshint evil: true */
return eval('(' + str + ')');
};
/**
* jQuery.secureEvalJSON
* Evals JSON in a way that is *more* secure.
*
* @param str {String}
*/
$.secureEvalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
var filtered =
str
.replace(/\\["\\\/bfnrtu]/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
if (/^[\],:{}\s]*$/.test(filtered)) {
/*jshint evil: true */
return eval('(' + str + ')');
}
throw new SyntaxError('Error parsing JSON, source is not valid.');
};
/**
* jQuery.quoteString
* Returns a string-repr of a string, escaping quotes intelligently.
* Mostly a support function for toJSON.
* Examples:
* >>> jQuery.quoteString('apple')
* "apple"
*
* >>> jQuery.quoteString('"Where are we going?", she asked.')
* "\"Where are we going?\", she asked."
*/
$.quoteString = function (str) {
if (str.match(escape)) {
return '"' + str.replace(escape, function (a) {
var c = meta[a];
if (typeof c === 'string') {
return c;
}
c = a.charCodeAt();
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
}) + '"';
}
return '"' + str + '"';
};
}(jQuery));

1
js/jquery.json.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function($){"use strict";var escape=/["\\\x00-\x1f\x7f-\x9f]/g,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},hasOwn=Object.prototype.hasOwnProperty;$.toJSON="object"==typeof JSON&&JSON.stringify?JSON.stringify:function(a){if(null===a)return"null";var b,c,d,e,f=$.type(a);if("undefined"!==f){if("number"===f||"boolean"===f)return String(a);if("string"===f)return $.quoteString(a);if("function"==typeof a.toJSON)return $.toJSON(a.toJSON());if("date"===f){var g=a.getUTCMonth()+1,h=a.getUTCDate(),i=a.getUTCFullYear(),j=a.getUTCHours(),k=a.getUTCMinutes(),l=a.getUTCSeconds(),m=a.getUTCMilliseconds();return g<10&&(g="0"+g),h<10&&(h="0"+h),j<10&&(j="0"+j),k<10&&(k="0"+k),l<10&&(l="0"+l),m<100&&(m="0"+m),m<10&&(m="0"+m),'"'+i+"-"+g+"-"+h+"T"+j+":"+k+":"+l+"."+m+'Z"'}if(b=[],$.isArray(a)){for(c=0;c<a.length;c++)b.push($.toJSON(a[c])||"null");return"["+b.join(",")+"]"}if("object"==typeof a){for(c in a)if(hasOwn.call(a,c)){if("number"===(f=typeof c))d='"'+c+'"';else{if("string"!==f)continue;d=$.quoteString(c)}f=typeof a[c],"function"!==f&&"undefined"!==f&&(e=$.toJSON(a[c]),b.push(d+":"+e))}return"{"+b.join(",")+"}"}}},$.evalJSON="object"==typeof JSON&&JSON.parse?JSON.parse:function(str){return eval("("+str+")")},$.secureEvalJSON="object"==typeof JSON&&JSON.parse?JSON.parse:function(str){var filtered=str.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"");if(/^[\],:{}\s]*$/.test(filtered))return eval("("+str+")");throw new SyntaxError("Error parsing JSON, source is not valid.")},$.quoteString=function(a){return a.match(escape)?'"'+a.replace(escape,function(a){var b=meta[a];return"string"==typeof b?b:(b=a.charCodeAt(),"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16))})+'"':'"'+a+'"'}}(jQuery);

9
js/jquery.maskedinput-1.3.1.min.js vendored Normal file
View File

@@ -0,0 +1,9 @@
/*
*** NOTE: File Kept for backwards compatibility. Link to jquery.maskedinput.min.js instead ***
Masked Input plugin for jQuery
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
Version: 1.4.1
*/
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){var t,n=navigator.userAgent,a=/iphone/i.test(n),i=/chrome/i.test(n),r=/android/i.test(n);e.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},e.fn.extend({caret:function(e,t){var n;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof e?(t="number"==typeof t?t:e,this.each(function(){this.setSelectionRange?this.setSelectionRange(e,t):this.createTextRange&&(n=this.createTextRange(),n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",e),n.select())})):(this[0].setSelectionRange?(e=this[0].selectionStart,t=this[0].selectionEnd):document.selection&&document.selection.createRange&&(n=document.selection.createRange(),e=0-n.duplicate().moveStart("character",-1e5),t=e+n.text.length),{begin:e,end:t})},unmask:function(){return this.trigger("unmask")},mask:function(n,o){var c,l,u,f,s,h,g,m;if(!n&&this.length>0){c=e(this[0]);var d=c.data(e.mask.dataName);return d?d():void 0}return o=e.extend({autoclear:e.mask.autoclear,placeholder:e.mask.placeholder,completed:null},o),l=e.mask.definitions,u=[],f=g=n.length,s=null,e.each(n.split(""),function(e,t){"?"==t?(g--,f=e):l[t]?(u.push(new RegExp(l[t])),null===s&&(s=u.length-1),f>e&&(h=u.length-1)):u.push(null)}),this.trigger("unmask").each(function(){function c(){if(o.completed){for(var e=s;h>=e;e++)if(u[e]&&C[e]===d(e))return;o.completed.call(w)}}function d(e){return o.placeholder.charAt(e<o.placeholder.length?e:0)}function p(e){for(;++e<g&&!u[e];);return e}function v(e){for(;--e>=0&&!u[e];);return e}function b(e,t){var n,a;if(!(0>e)){for(n=e,a=p(t);g>n;n++)if(u[n]){if(!(g>a&&u[n].test(C[a])))break;C[n]=C[a],C[a]=d(a),a=p(a)}A(),w.caret(Math.max(s,e))}}function k(e){var t,n,a,i;for(t=e,n=d(e);g>t;t++)if(u[t]){if(a=p(t),i=C[t],C[t]=n,!(g>a&&u[a].test(i)))break;n=i}}function y(){var e=w.val(),t=w.caret();if(m&&m.length&&m.length>e.length){for(T(!0);t.begin>0&&!u[t.begin-1];)t.begin--;if(0===t.begin)for(;t.begin<s&&!u[t.begin];)t.begin++;w.caret(t.begin,t.begin)}else{for(T(!0);t.begin<g&&!u[t.begin];)t.begin++;w.caret(t.begin,t.begin)}c()}function x(){T(),w.val()!=E&&w.change()}function j(e){if(!w.prop("readonly")){var t,n,i,r=e.which||e.keyCode;m=w.val(),8===r||46===r||a&&127===r?(t=w.caret(),n=t.begin,i=t.end,i-n===0&&(n=46!==r?v(n):i=p(n-1),i=46===r?p(i):i),S(n,i),b(n,i-1),e.preventDefault()):13===r?x.call(this,e):27===r&&(w.val(E),w.caret(0,T()),e.preventDefault())}}function R(t){if(!w.prop("readonly")){var n,a,i,o=t.which||t.keyCode,l=w.caret();if(!(t.ctrlKey||t.altKey||t.metaKey||32>o)&&o&&13!==o){if(l.end-l.begin!==0&&(S(l.begin,l.end),b(l.begin,l.end-1)),n=p(l.begin-1),g>n&&(a=String.fromCharCode(o),u[n].test(a))){if(k(n),C[n]=a,A(),i=p(n),r){var f=function(){e.proxy(e.fn.caret,w,i)()};setTimeout(f,0)}else w.caret(i);l.begin<=h&&c()}t.preventDefault()}}}function S(e,t){var n;for(n=e;t>n&&g>n;n++)u[n]&&(C[n]=d(n))}function A(){w.val(C.join(""))}function T(e){var t,n,a,i=w.val(),r=-1;for(t=0,a=0;g>t;t++)if(u[t]){for(C[t]=d(t);a++<i.length;)if(n=i.charAt(a-1),u[t].test(n)){C[t]=n,r=t;break}if(a>i.length){S(t+1,g);break}}else C[t]===i.charAt(a)&&a++,f>t&&(r=t);return e?A():f>r+1?o.autoclear||C.join("")===D?(w.val()&&w.val(""),S(0,g)):A():(A(),w.val(w.val().substring(0,r+1))),f?t:s}var w=e(this),C=e.map(n.split(""),function(e,t){return"?"!=e?l[e]?d(t):e:void 0}),D=C.join(""),E=w.val();w.data(e.mask.dataName,function(){return e.map(C,function(e,t){return u[t]&&e!=d(t)?e:null}).join("")}),w.one("unmask",function(){w.off(".mask").removeData(e.mask.dataName)}).on("focus.mask",function(){if(!w.prop("readonly")){clearTimeout(t);var e;E=w.val(),e=T(),t=setTimeout(function(){w.get(0)===document.activeElement&&(A(),e==n.replace("?","").length?w.caret(0,e):w.caret(e))},10)}}).on("blur.mask",x).on("keydown.mask",j).on("keypress.mask",R).on("input.mask paste.mask",function(){w.prop("readonly")||setTimeout(function(){var e=T(!0);w.caret(e),c()},0)}),i&&r&&w.off("input.mask").on("input.mask",y),T()})}})});

459
js/jquery.maskedinput.js Normal file
View File

@@ -0,0 +1,459 @@
/*
Masked Input plugin for jQuery
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
Version: 1.4.1
Source: https://github.com/RubtsovAV/jquery.maskedinput/blob/master/src/jquery.maskedinput.js
Updated 26 June 2017
- Fixed bug with caret position on Android
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var ua = navigator.userAgent,
iPhone = /iphone/i.test(ua),
chrome = /chrome/i.test(ua),
android = /android/i.test(ua),
caretTimeoutId;
$.mask = {
//Predefined character definitions
definitions: {
'9': "[0-9]",
'a': "[A-Za-z]",
'*': "[A-Za-z0-9]"
},
autoclear: true,
dataName: "rawMaskFn",
placeholder: '_'
};
$.fn.extend({
//Helper Function for Caret positioning
caret: function(begin, end) {
var range;
if (this.length === 0 || this.is(":hidden") || this.get(0) !== document.activeElement) {
return;
}
if (typeof begin == 'number') {
end = (typeof end === 'number') ? end : begin;
return this.each(function() {
if (this.setSelectionRange) {
this.setSelectionRange(begin, end);
} else if (this.createTextRange) {
range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', begin);
range.select();
}
});
} else {
if (this[0].setSelectionRange) {
begin = this[0].selectionStart;
end = this[0].selectionEnd;
} else if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
begin = 0 - range.duplicate().moveStart('character', -100000);
end = begin + range.text.length;
}
return { begin: begin, end: end };
}
},
unmask: function() {
return this.trigger("unmask");
},
mask: function(mask, settings) {
var input,
defs,
tests,
partialPosition,
firstNonMaskPos,
lastRequiredNonMaskPos,
len,
oldVal;
if (!mask && this.length > 0) {
input = $(this[0]);
var fn = input.data($.mask.dataName)
return fn?fn():undefined;
}
settings = $.extend({
autoclear: $.mask.autoclear,
placeholder: $.mask.placeholder, // Load default placeholder
completed: null
}, settings);
defs = $.mask.definitions;
tests = [];
partialPosition = len = mask.length;
firstNonMaskPos = null;
mask = String(mask);
$.each(mask.split(""), function(i, c) {
if (c == '?') {
len--;
partialPosition = i;
} else if (defs[c]) {
tests.push(new RegExp(defs[c]));
if (firstNonMaskPos === null) {
firstNonMaskPos = tests.length - 1;
}
if(i < partialPosition){
lastRequiredNonMaskPos = tests.length - 1;
}
} else {
tests.push(null);
}
});
return this.trigger("unmask").each(function() {
var input = $(this),
buffer = $.map(
mask.split(""),
function(c, i) {
if (c != '?') {
return defs[c] ? getPlaceholder(i) : c;
}
}),
defaultBuffer = buffer.join(''),
focusText = input.val();
function tryFireCompleted(){
if (!settings.completed) {
return;
}
for (var i = firstNonMaskPos; i <= lastRequiredNonMaskPos; i++) {
if (tests[i] && buffer[i] === getPlaceholder(i)) {
return;
}
}
settings.completed.call(input);
}
function getPlaceholder(i){
if(i < settings.placeholder.length)
return settings.placeholder.charAt(i);
return settings.placeholder.charAt(0);
}
function seekNext(pos) {
while (++pos < len && !tests[pos]);
return pos;
}
function seekPrev(pos) {
while (--pos >= 0 && !tests[pos]);
return pos;
}
function shiftL(begin,end) {
var i,
j;
if (begin<0) {
return;
}
for (i = begin, j = seekNext(end); i < len; i++) {
if (tests[i]) {
if (j < len && tests[i].test(buffer[j])) {
buffer[i] = buffer[j];
buffer[j] = getPlaceholder(j);
} else {
break;
}
j = seekNext(j);
}
}
writeBuffer();
input.caret(Math.max(firstNonMaskPos, begin));
}
function shiftR(pos) {
var i,
c,
j,
t;
for (i = pos, c = getPlaceholder(pos); i < len; i++) {
if (tests[i]) {
j = seekNext(i);
t = buffer[i];
buffer[i] = c;
if (j < len && tests[j].test(t)) {
c = t;
} else {
break;
}
}
}
}
function androidInputEvent(e) {
var curVal = input.val();
var pos = input.caret();
var proxy = function () {
$.proxy($.fn.caret, input, pos.begin, pos.begin)();
};
if (oldVal && oldVal.length && oldVal.length > curVal.length ) {
// a deletion or backspace happened
checkVal(true);
while (pos.begin > 0 && !tests[pos.begin-1])
pos.begin--;
if (pos.begin === 0)
{
while (pos.begin < firstNonMaskPos && !tests[pos.begin])
pos.begin++;
}
setTimeout(proxy, 0);
} else {
var pos2 = checkVal(true);
var lastEnteredValue = curVal.charAt(pos.begin);
if (pos.begin < len){
if (!tests[pos.begin]) {
pos.begin = pos2;
} else {
if(tests[pos.begin].test(lastEnteredValue)){
pos.begin++;
}
}
}
setTimeout(proxy, 0);
}
tryFireCompleted();
}
function blurEvent(e) {
checkVal();
if (input.val() != focusText)
input.change();
}
function keydownEvent(e) {
if (input.prop("readonly")){
return;
}
var k = e.which || e.keyCode,
pos,
begin,
end;
oldVal = input.val();
//backspace, delete, and escape get special treatment
if (k === 8 || k === 46 || (iPhone && k === 127)) {
pos = input.caret();
begin = pos.begin;
end = pos.end;
if (end - begin === 0) {
begin=k!==46?seekPrev(begin):(end=seekNext(begin-1));
end=k===46?seekNext(end):end;
}
clearBuffer(begin, end);
shiftL(begin, end - 1);
e.preventDefault();
} else if( k === 13 ) { // enter
blurEvent.call(this, e);
} else if (k === 27) { // escape
input.val(focusText);
input.caret(0, checkVal());
e.preventDefault();
}
}
function keypressEvent(e) {
if (input.prop("readonly")){
return;
}
var k = e.which || e.keyCode,
pos = input.caret(),
p,
c,
next;
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
return;
} else if ( k && k !== 13 ) {
if (pos.end - pos.begin !== 0){
clearBuffer(pos.begin, pos.end);
shiftL(pos.begin, pos.end-1);
}
p = seekNext(pos.begin - 1);
if (p < len) {
c = String.fromCharCode(k);
if (tests[p].test(c)) {
shiftR(p);
buffer[p] = c;
writeBuffer();
next = seekNext(p);
if(android){
//Path for CSP Violation on FireFox OS 1.1
var proxy = function() {
$.proxy($.fn.caret,input,next)();
};
setTimeout(proxy,0);
}else{
input.caret(next);
}
if(pos.begin <= lastRequiredNonMaskPos){
tryFireCompleted();
}
}
}
e.preventDefault();
}
}
function clearBuffer(start, end) {
var i;
for (i = start; i < end && i < len; i++) {
if (tests[i]) {
buffer[i] = getPlaceholder(i);
}
}
}
function writeBuffer() { input.val(buffer.join('')); }
function checkVal(allow) {
//try to place characters where they belong
var test = input.val(),
lastMatch = -1,
i,
c,
pos;
for (i = 0, pos = 0; i < len; i++) {
if (tests[i]) {
buffer[i] = getPlaceholder(i);
while (pos++ < test.length) {
c = test.charAt(pos - 1);
if (tests[i].test(c)) {
buffer[i] = c;
lastMatch = i;
break;
}
}
if (pos > test.length) {
clearBuffer(i + 1, len);
break;
}
} else {
if (buffer[i] === test.charAt(pos)) {
pos++;
}
if( i < partialPosition){
lastMatch = i;
}
}
}
if (allow) {
writeBuffer();
} else if (lastMatch + 1 < partialPosition) {
if (settings.autoclear || buffer.join('') === defaultBuffer) {
// Invalid value. Remove it and replace it with the
// mask, which is the default behavior.
if(input.val()) input.val("");
clearBuffer(0, len);
} else {
// Invalid value, but we opt to show the value to the
// user and allow them to correct their mistake.
writeBuffer();
}
} else {
writeBuffer();
input.val(input.val().substring(0, lastMatch + 1));
}
return (partialPosition ? i : firstNonMaskPos);
}
input.data($.mask.dataName,function(){
return $.map(buffer, function(c, i) {
return tests[i]&&c!=getPlaceholder(i) ? c : null;
}).join('');
});
input
.one("unmask", function() {
input
.off(".mask")
.removeData($.mask.dataName);
})
.on("focus.mask", function() {
if (input.prop("readonly")){
return;
}
clearTimeout(caretTimeoutId);
var pos;
focusText = input.val();
pos = checkVal();
caretTimeoutId = setTimeout(function(){
if(input.get(0) !== document.activeElement){
return;
}
writeBuffer();
if (pos == mask.replace("?","").length) {
input.caret(0, pos);
} else {
input.caret(pos);
}
}, 10);
})
.on("blur.mask", blurEvent)
.on("keydown.mask", keydownEvent)
.on("keypress.mask", keypressEvent)
.on("input.mask paste.mask", function() {
if (input.prop("readonly")){
return;
}
setTimeout(function() {
var pos=checkVal(true);
input.caret(pos);
tryFireCompleted();
}, 0);
});
if (chrome && android)
{
input
.off('input.mask')
.on('input.mask', androidInputEvent);
}
checkVal(); //Perform initial check for existing values
});
}
});
}));

1
js/jquery.maskedinput.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;if(0!==this.length&&!this.is(":hidden")&&this.get(0)===document.activeElement)return"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,c=String(c),a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),a<k&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;a<=m;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return a<g.placeholder.length?g.placeholder.charAt(a):g.placeholder.charAt(0)}function q(a){for(;++a<n&&!j[a];);return a}function r(a){for(;--a>=0&&!j[a];);return a}function s(a,b){var c,d;if(!(a<0)){for(c=a,d=q(b);c<n;c++)if(j[c]){if(!(d<n&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);b<n;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(d<n&&j[d].test(e)))break;c=e}}function u(b){var c=B.val(),d=B.caret(),e=function(){a.proxy(a.fn.caret,B,d.begin,d.begin)()};if(o&&o.length&&o.length>c.length){for(A(!0);d.begin>0&&!j[d.begin-1];)d.begin--;if(0===d.begin)for(;d.begin<l&&!j[d.begin];)d.begin++;setTimeout(e,0)}else{var f=A(!0),g=c.charAt(d.begin);d.begin<n&&(j[d.begin]?j[d.begin].test(g)&&d.begin++:d.begin=f),setTimeout(e,0)}h()}function v(a){A(),B.val()!=E&&B.change()}function w(a){if(!B.prop("readonly")){var b,c,e,f=a.which||a.keyCode;o=B.val(),8===f||46===f||d&&127===f?(b=B.caret(),c=b.begin,e=b.end,e-c==0&&(c=46!==f?r(c):e=q(c-1),e=46===f?q(e):e),y(c,e),s(c,e-1),a.preventDefault()):13===f?v.call(this,a):27===f&&(B.val(E),B.caret(0,A()),a.preventDefault())}}function x(b){if(!B.prop("readonly")){var c,d,e,g=b.which||b.keyCode,i=B.caret();if(!(b.ctrlKey||b.altKey||b.metaKey||g<32)&&g&&13!==g){if(i.end-i.begin!=0&&(y(i.begin,i.end),s(i.begin,i.end-1)),(c=q(i.begin-1))<n&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;c<b&&c<n;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;b<n;b++)if(j[b]){for(C[b]=p(b);d++<e.length;)if(c=e.charAt(d-1),j[b].test(c)){C[b]=c,f=b;break}if(d>e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,b<k&&(f=b);return a?z():f+1<k?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){if("?"!=a)return i[a]?p(b):a}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})});

1
js/jquery.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;if(0!==this.length&&!this.is(":hidden")&&this.get(0)===document.activeElement)return"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,c=String(c),a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),a<k&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;a<=m;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return a<g.placeholder.length?g.placeholder.charAt(a):g.placeholder.charAt(0)}function q(a){for(;++a<n&&!j[a];);return a}function r(a){for(;--a>=0&&!j[a];);return a}function s(a,b){var c,d;if(!(a<0)){for(c=a,d=q(b);c<n;c++)if(j[c]){if(!(d<n&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);b<n;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(d<n&&j[d].test(e)))break;c=e}}function u(b){var c=B.val(),d=B.caret(),e=function(){a.proxy(a.fn.caret,B,d.begin,d.begin)()};if(o&&o.length&&o.length>c.length){for(A(!0);d.begin>0&&!j[d.begin-1];)d.begin--;if(0===d.begin)for(;d.begin<l&&!j[d.begin];)d.begin++;setTimeout(e,0)}else{var f=A(!0),g=c.charAt(d.begin);d.begin<n&&(j[d.begin]?j[d.begin].test(g)&&d.begin++:d.begin=f),setTimeout(e,0)}h()}function v(a){A(),B.val()!=E&&B.change()}function w(a){if(!B.prop("readonly")){var b,c,e,f=a.which||a.keyCode;o=B.val(),8===f||46===f||d&&127===f?(b=B.caret(),c=b.begin,e=b.end,e-c==0&&(c=46!==f?r(c):e=q(c-1),e=46===f?q(e):e),y(c,e),s(c,e-1),a.preventDefault()):13===f?v.call(this,a):27===f&&(B.val(E),B.caret(0,A()),a.preventDefault())}}function x(b){if(!B.prop("readonly")){var c,d,e,g=b.which||b.keyCode,i=B.caret();if(!(b.ctrlKey||b.altKey||b.metaKey||g<32)&&g&&13!==g){if(i.end-i.begin!=0&&(y(i.begin,i.end),s(i.begin,i.end-1)),(c=q(i.begin-1))<n&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;c<b&&c<n;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;b<n;b++)if(j[b]){for(C[b]=p(b);d++<e.length;)if(c=e.charAt(d-1),j[b].test(c)){C[b]=c,f=b;break}if(d>e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,b<k&&(f=b);return a?z():f+1<k?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){if("?"!=a)return i[a]?p(b):a}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})});

View File

@@ -0,0 +1,195 @@
/*
* jQuery Textarea Counter Plugin
* Copyright (c) 2010 Roy Jin
* Copyright (c) 2013 LeadSift
* Version: 3.0 (11-APR-2013)
* http://www.opensource.org/licenses/mit-license.php
* Requires: jQuery v1.4.2 or later
*/
(function($) {
$.fn.textareaCount = function(options, fn) {
var defaults = {
maxCharacterSize: -1
, truncate: true
, charCounter: 'standard'
, originalStyle: 'originalTextareaInfo'
, warningStyle: 'warningTextareaInfo'
, errorStyle: 'errorTextareaInfo'
, warningNumber: 20
, displayFormat: '#input characters | #words words'
}
, container = $(this)
, charLeftInfo
, numInput = 0
, maxCharacters = options.maxCharacterSize
, numLeft = 0
, numWords = 0
, charCounters = {}
;
charCounters.standard = function(content){
return content.length;
};
charCounters.twitter = function(content){
// function that counts urls as 22 chars
// regex to match various urls ... from http://stackoverflow.com/a/6427654
var url_length = 22
, replacement = Array(url_length+1).join("*")
, regex_str = "(https?:\/\/)?" + // SCHEME
"([a-z0-9+!*(),;?&=$_.-]+(:[a-z0-9+!*(),;?&=$_.-]+)?@)?" + // User and Pass
"([a-z0-9-.]*)\\.(travel|museum|[a-z]{2,4})" + // Host or IP
"(:[0-9]{2,5})?" + // Port
"(\/([a-z0-9+$_-]\\.?)+)*\/?" + // Path
"(\\?[a-z+&$_.-][a-z0-9;:@&%=+\/$_.-]*)?" + // GET Query
"(#[a-z_.-][a-z0-9+$_.-]*)?" // Anchor
, regex = new RegExp(regex_str, 'gi')
;
return content.replace(regex, replacement).length;
};
function getNewlineCount(content){
var newlineCount = 0
, i;
for(i=0; i<content.length; i++){
if(content.charAt(i) === '\n'){
newlineCount++;
}
}
return newlineCount;
}
function formatDisplayInfo(){
var format = options.displayFormat;
format = format.replace('#input', numInput);
format = format.replace('#words', numWords);
//When maxCharacters <= 0, #max, #left cannot be substituted.
if(maxCharacters > 0){
format = format.replace('#max', maxCharacters);
format = format.replace('#left', numLeft);
}
return format;
}
function getInfo(){
var info = {
input: numInput,
max: maxCharacters,
left: numLeft,
words: numWords
};
return info;
}
function getNextCharLeftInformation(container){
return container.next('.charleft');
}
function isWin(){
var strOS = navigator.appVersion;
if (strOS.toLowerCase().indexOf('win') !== -1){
return true;
}
return false;
}
function getCleanedWordString(content){
var fullStr = content + " "
, initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi
, left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "")
, non_alphanumerics_rExp = /[^A-Za-z0-9]+/gi
, cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ")
, splitString = cleanedStr.split(" ")
;
return splitString;
}
function countWord(cleanedWordString){
var word_count = cleanedWordString.length-1;
return word_count;
}
function countByCharacters(){
var content = container.val()
, lengthFunc = typeof(options.charCounter) === 'function'? options.charCounter : charCounters[options.charCounter]
, contentLength = lengthFunc(content)
, newlineCount
, systemmaxCharacterSize
, originalScrollTopPosition
;
// Start Cut
if(options.maxCharacterSize > 0){
// If copied content is already more than maxCharacterSize,
// chop it to maxCharacterSize only if truncate is true
if(options.truncate && contentLength >= options.maxCharacterSize) {
content = content.substring(0, options.maxCharacterSize);
}
newlineCount = getNewlineCount(content);
systemmaxCharacterSize = options.maxCharacterSize;
if (isWin()){
// newlineCount new line character. For windows, it occupies 2 characters
systemmaxCharacterSize = options.maxCharacterSize - newlineCount;
}
if(options.truncate && contentLength > systemmaxCharacterSize){
//avoid scroll bar moving
originalScrollTopPosition = this.scrollTop;
container.val(content.substring(0, systemmaxCharacterSize));
this.scrollTop = originalScrollTopPosition;
}
charLeftInfo.removeClass(options.warningStyle + ' ' + options.errorStyle);
if(systemmaxCharacterSize - contentLength <= options.warningNumber){
charLeftInfo.addClass(options.warningStyle);
}
if(systemmaxCharacterSize - contentLength < 0){
charLeftInfo.addClass(options.errorStyle);
}
numInput = contentLength;
if(isWin()){
numInput = contentLength + newlineCount;
}
numWords = countWord(getCleanedWordString(container.val()));
numLeft = maxCharacters - numInput;
} else {
//normal count, no cut
newlineCount = getNewlineCount(content);
numInput = contentLength;
if(isWin()){
numInput = contentLength + newlineCount;
}
numWords = countWord(getCleanedWordString(container.val()));
}
return formatDisplayInfo();
}
function limitTextAreaByCharacterCount(){
charLeftInfo.html(countByCharacters());
//function call back
if(typeof fn !== 'undefined'){
fn.call(this, getInfo());
}
return true;
}
options = $.extend(defaults, options);
$("<div class='charleft'>&nbsp;</div>").insertAfter(container);
charLeftInfo = getNextCharLeftInformation(container);
charLeftInfo.addClass(options.originalStyle);
limitTextAreaByCharacterCount();
container.bind('keyup', function(){
limitTextAreaByCharacterCount();}
).bind('mouseover paste', function(){
setTimeout(function(){
limitTextAreaByCharacterCount();
}, 10);
});
};
})(jQuery);

View File

@@ -0,0 +1 @@
!function(a){a.fn.textareaCount=function(b,c){function d(a){var b,c=0;for(b=0;b<a.length;b++)"\n"===a.charAt(b)&&c++;return c}function e(){var a=b.displayFormat;return a=a.replace("#input",p),a=a.replace("#words",s),q>0&&(a=a.replace("#max",q),a=a.replace("#left",r)),a}function f(){return{input:p,max:q,left:r,words:s}}function g(a){return a.next(".charleft")}function h(){return-1!==navigator.appVersion.toLowerCase().indexOf("win")}function i(a){var b=a+" ",c=/^[^A-Za-z0-9]+/gi,d=b.replace(c,""),e=/[^A-Za-z0-9]+/gi;return d.replace(e," ").split(" ")}function j(a){return a.length-1}function k(){var a,c,f,g=o.val(),k="function"==typeof b.charCounter?b.charCounter:t[b.charCounter],l=k(g);return b.maxCharacterSize>0?(b.truncate&&l>=b.maxCharacterSize&&(g=g.substring(0,b.maxCharacterSize)),a=d(g),c=b.maxCharacterSize,h()&&(c=b.maxCharacterSize-a),b.truncate&&l>c&&(f=this.scrollTop,o.val(g.substring(0,c)),this.scrollTop=f),m.removeClass(b.warningStyle+" "+b.errorStyle),c-l<=b.warningNumber&&m.addClass(b.warningStyle),c-l<0&&m.addClass(b.errorStyle),p=l,h()&&(p=l+a),s=j(i(o.val())),r=q-p):(a=d(g),p=l,h()&&(p=l+a),s=j(i(o.val()))),e()}function l(){return m.html(k()),void 0!==c&&c.call(this,f()),!0}var m,n={maxCharacterSize:-1,truncate:!0,charCounter:"standard",originalStyle:"originalTextareaInfo",warningStyle:"warningTextareaInfo",errorStyle:"errorTextareaInfo",warningNumber:20,displayFormat:"#input characters | #words words"},o=a(this),p=0,q=b.maxCharacterSize,r=0,s=0,t={};t.standard=function(a){return a.length},t.twitter=function(a){var b=22,c=Array(b+1).join("*"),d="(https?://)?([a-z0-9+!*(),;?&=$_.-]+(:[a-z0-9+!*(),;?&=$_.-]+)?@)?([a-z0-9-.]*)\\.(travel|museum|[a-z]{2,4})(:[0-9]{2,5})?(/([a-z0-9+$_-]\\.?)+)*/?(\\?[a-z+&$_.-][a-z0-9;:@&%=+/$_.-]*)?(#[a-z_.-][a-z0-9+$_.-]*)?",e=new RegExp(d,"gi");return a.replace(e,c).length},b=a.extend(n,b),a("<div class='charleft'>&nbsp;</div>").insertAfter(o),m=g(o),m.addClass(b.originalStyle),l(),o.bind("keyup",function(){l()}).bind("mouseover paste",function(){setTimeout(function(){l()},10)})}}(jQuery);

39
js/menu.js Normal file
View File

@@ -0,0 +1,39 @@
/*
Copyright 2008 by Marco van Hylckama Vlieg
web: http://www.i-marco.nl/weblog/
email: marco@i-marco.nl
Free for use
*/
function initMenus() {
jQuery('ul.menu ul').hide();
jQuery.each(jQuery('ul.menu'), function(){
jQuery('#' + this.id + '.expandfirst ul:first').show();
});
jQuery('ul.menu li .button-title-link').click(
function() {
var checkElement = jQuery(this).next();
var parent = this.parentNode.parentNode.id;
if(jQuery('#' + parent).hasClass('noaccordion')) {
jQuery(this).next().slideToggle('normal');
return false;
}
if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
if(jQuery('#' + parent).hasClass('collapsible')) {
jQuery('#' + parent + ' ul:visible').slideUp('normal', function(){jQuery(this).prev().removeClass('gf_button_title_active')});
}
return false;
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
jQuery('#' + parent + ' ul:visible').slideUp('normal', function(){jQuery(this).prev().removeClass('gf_button_title_active')});
checkElement.slideDown('normal', function(){jQuery(this).prev().addClass('gf_button_title_active')});
return false;
}
}
);
}
jQuery(document).ready(function() {initMenus();});
jQuery(document).ready(function() {
jQuery('div.add-buttons-title').append('<span class="add-buttons-caret-down"><i class="fa fa-caret-down"></i></span>');
});

1
js/menu.min.js vendored Normal file
View File

@@ -0,0 +1 @@
function initMenus(){jQuery("ul.menu ul").hide(),jQuery.each(jQuery("ul.menu"),function(){jQuery("#"+this.id+".expandfirst ul:first").show()}),jQuery("ul.menu li .button-title-link").click(function(){var a=jQuery(this).next(),b=this.parentNode.parentNode.id;return jQuery("#"+b).hasClass("noaccordion")?(jQuery(this).next().slideToggle("normal"),!1):a.is("ul")&&a.is(":visible")?(jQuery("#"+b).hasClass("collapsible")&&jQuery("#"+b+" ul:visible").slideUp("normal",function(){jQuery(this).prev().removeClass("gf_button_title_active")}),!1):a.is("ul")&&!a.is(":visible")?(jQuery("#"+b+" ul:visible").slideUp("normal",function(){jQuery(this).prev().removeClass("gf_button_title_active")}),a.slideDown("normal",function(){jQuery(this).prev().addClass("gf_button_title_active")}),!1):void 0})}jQuery(document).ready(function(){initMenus()}),jQuery(document).ready(function(){jQuery("div.add-buttons-title").append('<span class="add-buttons-caret-down"><i class="fa fa-caret-down"></i></span>')});

2
js/placeholders.jquery.min.js vendored Normal file
View File

@@ -0,0 +1,2 @@
/* Placeholders.js v3.0.2 */
(function(t){"use strict";function e(t,e,r){return t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent?t.attachEvent("on"+e,r):void 0}function r(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(t[r]===e)return!0;return!1}function n(t,e){var r;t.createTextRange?(r=t.createTextRange(),r.move("character",e),r.select()):t.selectionStart&&(t.focus(),t.setSelectionRange(e,e))}function a(t,e){try{return t.type=e,!0}catch(r){return!1}}t.Placeholders={Utils:{addEventListener:e,inArray:r,moveCaret:n,changeType:a}}})(this),function(t){"use strict";function e(){}function r(){try{return document.activeElement}catch(t){}}function n(t,e){var r,n,a=!!e&&t.value!==e,u=t.value===t.getAttribute(V);return(a||u)&&"true"===t.getAttribute(P)?(t.removeAttribute(P),t.value=t.value.replace(t.getAttribute(V),""),t.className=t.className.replace(R,""),n=t.getAttribute(z),parseInt(n,10)>=0&&(t.setAttribute("maxLength",n),t.removeAttribute(z)),r=t.getAttribute(D),r&&(t.type=r),!0):!1}function a(t){var e,r,n=t.getAttribute(V);return""===t.value&&n?(t.setAttribute(P,"true"),t.value=n,t.className+=" "+I,r=t.getAttribute(z),r||(t.setAttribute(z,t.maxLength),t.removeAttribute("maxLength")),e=t.getAttribute(D),e?t.type="text":"password"===t.type&&K.changeType(t,"text")&&t.setAttribute(D,"password"),!0):!1}function u(t,e){var r,n,a,u,i,l,o;if(t&&t.getAttribute(V))e(t);else for(a=t?t.getElementsByTagName("input"):f,u=t?t.getElementsByTagName("textarea"):h,r=a?a.length:0,n=u?u.length:0,o=0,l=r+n;l>o;o++)i=r>o?a[o]:u[o-r],e(i)}function i(t){u(t,n)}function l(t){u(t,a)}function o(t){return function(){b&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(P)?K.moveCaret(t,0):n(t)}}function c(t){return function(){a(t)}}function s(t){return function(e){return A=t.value,"true"===t.getAttribute(P)&&A===t.getAttribute(V)&&K.inArray(C,e.keyCode)?(e.preventDefault&&e.preventDefault(),!1):void 0}}function d(t){return function(){n(t,A),""===t.value&&(t.blur(),K.moveCaret(t,0))}}function v(t){return function(){t===r()&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(P)&&K.moveCaret(t,0)}}function g(t){return function(){i(t)}}function p(t){t.form&&(T=t.form,"string"==typeof T&&(T=document.getElementById(T)),T.getAttribute(U)||(K.addEventListener(T,"submit",g(T)),T.setAttribute(U,"true"))),K.addEventListener(t,"focus",o(t)),K.addEventListener(t,"blur",c(t)),b&&(K.addEventListener(t,"keydown",s(t)),K.addEventListener(t,"keyup",d(t)),K.addEventListener(t,"click",v(t))),t.setAttribute(j,"true"),t.setAttribute(V,x),(b||t!==r())&&a(t)}var f,h,b,m,A,y,E,x,L,T,S,N,w,B=["text","search","url","tel","email","password","number","textarea"],C=[27,33,34,35,36,37,38,39,40,8,46],k="#ccc",I="placeholdersjs",R=RegExp("(?:^|\\s)"+I+"(?!\\S)"),V="data-placeholder-value",P="data-placeholder-active",D="data-placeholder-type",U="data-placeholder-submit",j="data-placeholder-bound",q="data-placeholder-focus",Q="data-placeholder-live",z="data-placeholder-maxlength",F=document.createElement("input"),G=document.getElementsByTagName("head")[0],H=document.documentElement,J=t.Placeholders,K=J.Utils;if(J.nativeSupport=void 0!==F.placeholder,!J.nativeSupport){for(f=document.getElementsByTagName("input"),h=document.getElementsByTagName("textarea"),b="false"===H.getAttribute(q),m="false"!==H.getAttribute(Q),y=document.createElement("style"),y.type="text/css",E=document.createTextNode("."+I+" { color:"+k+"; }"),y.styleSheet?y.styleSheet.cssText=E.nodeValue:y.appendChild(E),G.insertBefore(y,G.firstChild),w=0,N=f.length+h.length;N>w;w++)S=f.length>w?f[w]:h[w-f.length],x=S.attributes.placeholder,x&&(x=x.nodeValue,x&&K.inArray(B,S.type)&&p(S));L=setInterval(function(){for(w=0,N=f.length+h.length;N>w;w++)S=f.length>w?f[w]:h[w-f.length],x=S.attributes.placeholder,x?(x=x.nodeValue,x&&K.inArray(B,S.type)&&(S.getAttribute(j)||p(S),(x!==S.getAttribute(V)||"password"===S.type&&!S.getAttribute(D))&&("password"===S.type&&!S.getAttribute(D)&&K.changeType(S,"text")&&S.setAttribute(D,"password"),S.value===S.getAttribute(V)&&(S.value=x),S.setAttribute(V,x)))):S.getAttribute(P)&&(n(S),S.removeAttribute(V));m||clearInterval(L)},100)}K.addEventListener(t,"beforeunload",function(){J.disable()}),J.disable=J.nativeSupport?e:i,J.enable=J.nativeSupport?e:l}(this),function(t){"use strict";var e=t.fn.val,r=t.fn.prop;Placeholders.nativeSupport||(t.fn.val=function(t){var r=e.apply(this,arguments),n=this.eq(0).data("placeholder-value");return void 0===t&&this.eq(0).data("placeholder-active")&&r===n?"":r},t.fn.prop=function(t,e){return void 0===e&&this.eq(0).data("placeholder-active")&&"value"===t?"":r.apply(this,arguments)})}(jQuery);

762
js/shortcode-ui.js Normal file
View File

@@ -0,0 +1,762 @@
//Props: https://github.com/fusioneng/Shortcake/
var GformShortcodeUI;
( function (gfShortCodeUI, $) {
var sui = window.GformShortcodeUI = {
models: {},
collections: {},
views: {},
utils: {},
strings: {}
};
/**
* Shortcode Attribute Model.
*/
sui.models.ShortcodeAttribute = Backbone.Model.extend({
defaults: {
attr: '',
label: '',
type: '',
section: '',
description: '',
default: '',
value: ''
}
});
/**
* Shortcode Attributes collection.
*/
sui.models.ShortcodeAttributes = Backbone.Collection.extend({
model: sui.models.ShortcodeAttribute,
// Deep Clone.
clone: function () {
return new this.constructor(_.map(this.models, function (m) {
return m.clone();
}));
}
});
/**
* Shortcode Model
*/
sui.models.Shortcode = Backbone.Model.extend({
defaults: {
label: '',
shortcode_tag: '',
action_tag: '',
attrs: sui.models.ShortcodeAttributes,
},
/**
* Custom set method.
* Handles setting the attribute collection.
*/
set: function (attributes, options) {
if (attributes.attrs !== undefined && !( attributes.attrs instanceof sui.models.ShortcodeAttributes )) {
_.each(attributes.attrs, function (attr) {
if (attr.default != undefined) {
attr.value = attr.default
}
});
attributes.attrs = new sui.models.ShortcodeAttributes(attributes.attrs);
}
return Backbone.Model.prototype.set.call(this, attributes, options);
},
/**
* Custom toJSON.
* Handles converting the attribute collection to JSON.
*/
toJSON: function (options) {
options = Backbone.Model.prototype.toJSON.call(this, options);
if (options.attrs !== undefined && ( options.attrs instanceof sui.models.ShortcodeAttributes )) {
options.attrs = options.attrs.toJSON();
}
return options;
},
/**
* Custom clone
* Make sure we don't clone a reference to attributes.
*/
clone: function () {
var clone = Backbone.Model.prototype.clone.call(this);
clone.set('attrs', clone.get('attrs').clone());
return clone;
},
/**
* Get the shortcode as... a shortcode!
*
* @return string eg [shortcode attr1=value]
*/
formatShortcode: function () {
var template, shortcodeAttributes, attrs = [], content, action = '', actions = [];
this.get('attrs').each(function (attr) {
var val = attr.get('value');
var type = attr.get('type');
var def = attr.get('default');
// Skip empty attributes.
// Skip unchecked checkboxes that have don't have default='true'.
if (( ( !val || val.length < 1 ) && type != 'checkbox') || ( type == 'checkbox' && def != 'true' && !val )) {
return;
}
// Handle content attribute as a special case.
if (attr.get('attr') === 'content') {
content = attr.get('value');
} else {
attrs.push(attr.get('attr') + '="' + val + '"');
}
});
template = "[{{ shortcode }} {{ attributes }}]"
if (content && content.length > 0) {
template += "{{ content }}[/{{ shortcode }}]"
}
template = template.replace(/{{ shortcode }}/g, this.get('shortcode_tag'));
template = template.replace(/{{ attributes }}/g, attrs.join(' '));
template = template.replace(/{{ content }}/g, content);
return template;
},
validate: function (shortcode) {
var errors = [];
var id = shortcode.attrs.findWhere({attr: 'id'});
if (!id.get('value')) {
errors.push({'id': sui.strings.pleaseSelectAForm});
}
return errors.length ? errors : null;
}
});
// Shortcode Collection
sui.collections.Shortcodes = Backbone.Collection.extend({
model: sui.models.Shortcode
});
/**
* Single edit shortcode content view.
*/
sui.views.editShortcodeForm = wp.Backbone.View.extend({
el: '#gform-shortcode-ui-container',
template: wp.template('gf-shortcode-default-edit-form'),
hasAdvancedValue: false,
events: {
'click #gform-update-shortcode': 'insertShortcode',
'click #gform-insert-shortcode': 'insertShortcode',
'click #gform-cancel-shortcode': 'cancelShortcode'
},
initialize: function () {
_.bindAll(this, 'beforeRender', 'render', 'afterRender');
var t = this;
this.render = _.wrap(this.render, function (render) {
t.beforeRender();
render();
t.afterRender();
return t;
});
this.model.get('attrs').each(function (attr) {
switch (attr.get('section')) {
case 'required':
t.views.add(
'.gf-edit-shortcode-form-required-attrs',
new sui.views.editAttributeField({model: attr, parent: t})
);
break;
case 'standard':
t.views.add(
'.gf-edit-shortcode-form-standard-attrs',
new sui.views.editAttributeField({model: attr, parent: t})
);
break;
default:
t.views.add(
'.gf-edit-shortcode-form-advanced-attrs',
new sui.views.editAttributeField({model: attr, parent: t})
);
if (!t.hasAdvancedVal) {
t.hasAdvancedVal = attr.get('value') !== '';
}
}
});
this.listenTo(this.model, 'change', this.render);
},
beforeRender: function () {
//
},
afterRender: function () {
gform_initialize_tooltips();
$('#gform-insert-shortcode').toggle(this.options.viewMode == 'insert');
$('#gform-update-shortcode').toggle(this.options.viewMode != 'insert');
$('#gf-edit-shortcode-form-advanced-attrs').toggle(this.hasAdvancedVal);
},
insertShortcode: function (e) {
var isValid = this.model.isValid({validate: true});
if (isValid) {
send_to_editor(this.model.formatShortcode());
tb_remove();
this.dispose();
} else {
_.each(this.model.validationError, function (error) {
_.each(error, function (message, attr) {
alert(message);
});
});
}
},
cancelShortcode: function (e) {
tb_remove();
this.dispose();
},
dispose: function () {
this.remove();
$('#gform-shortcode-ui-wrap').append('<div id="gform-shortcode-ui-container"></div>');
}
});
sui.views.editAttributeField = Backbone.View.extend({
tagName: "div",
initialize: function (options) {
this.parent = options.parent;
},
events: {
'keyup input[type="text"]': 'updateValue',
'keyup textarea': 'updateValue',
'change select': 'updateValue',
'change #gf-shortcode-attr-action': 'updateAction',
'change input[type=checkbox]': 'updateCheckbox',
'change input[type=radio]': 'updateValue',
'change input[type=email]': 'updateValue',
'change input[type=number]': 'updateValue',
'change input[type=date]': 'updateValue',
'change input[type=url]': 'updateValue',
},
render: function () {
this.template = wp.media.template('gf-shortcode-ui-field-' + this.model.get('type'));
return this.$el.html(this.template(this.model.toJSON()));
},
/**
* Input Changed Update Callback.
*
* If the input field that has changed is for content or a valid attribute,
* then it should update the model.
*/
updateValue: function (e) {
var $el = $(e.target);
this.model.set('value', $el.val());
},
updateCheckbox: function (e) {
var $el = $(e.target);
var val = $el.prop('checked');
this.model.set('value', val);
},
updateAction: function (e) {
var $el = $(e.target),
val = $el.val();
this.model.set('value', val);
var m = this.parent.model;
var newShortcodeModel = sui.shortcodes.findWhere({shortcode_tag: 'gravityform', action_tag: val});
// copy over values to new shortcode model
var currentAttrs = m.get('attrs');
newShortcodeModel.get('attrs').each(function (attr) {
var newAt = attr.get('attr');
var currentAtModel = currentAttrs.findWhere({attr: newAt});
if (typeof currentAtModel != 'undefined') {
var currentAt = currentAtModel.get('attr');
if (newAt == currentAt) {
var currentVal = currentAtModel.get('value');
attr.set('value', String(currentVal));
}
}
});
$(this.parent.el).empty();
var viewMode = this.parent.options.viewMode;
this.parent.dispose();
this.parent.model.set(newShortcodeModel);
GformShortcodeUI = new sui.views.editShortcodeForm({model: newShortcodeModel, viewMode: viewMode});
GformShortcodeUI.render();
}
});
sui.utils.shortcodeViewConstructor = {
initialize: function( options ) {
this.shortcodeModel = this.getShortcodeModel( this.shortcode );
},
/**
* Get the shortcode model given the view shortcode options.
* Must be a registered shortcode (see sui.shortcodes)
*/
getShortcodeModel: function( options ) {
var actionTag = typeof options.attrs.named.action != 'undefined' ? options.attrs.named.action : '';
var shortcodeModel = sui.shortcodes.findWhere({action_tag: actionTag});
if ( ! shortcodeModel ) {
return;
}
var shortcode = shortcodeModel.clone();
shortcode.get('attrs').each(function (attr) {
if (attr.get('attr') in options.attrs.named) {
attr.set('value', options.attrs.named[attr.get('attr')]);
}
if (attr.get('attr') === 'content' && ( 'content' in options )) {
attr.set('value', options.content);
}
});
return shortcode;
},
/**
* Return the preview HTML.
* If empty, fetches data.
*
* @return string
*/
getContent : function() {
if ( ! this.content ) {
this.fetch();
}
return this.content;
},
/**
* Fetch preview.
* Async. Sets this.content and calls this.render.
*
* @return undefined
*/
fetch : function() {
var self = this;
if ( ! this.fetching ) {
this.fetching = true;
var attr = this.shortcodeModel.get('attrs').findWhere({attr: 'id'});
var formId = attr.get('value');
var data;
data = {
action: 'gf_do_shortcode',
post_id: $('#post_ID').val(),
form_id: formId,
shortcode: this.shortcodeModel.formatShortcode(),
nonce: gfShortcodeUIData.previewNonce
};
$.post(ajaxurl, data).done(function(response) {
self.content = response;
}).fail(function () {
self.content = '<span class="gf_shortcode_ui_error">' + gfShortcodeUIData.strings.errorLoadingPreview + '</span>';
}).always(function () {
delete self.fetching;
self.render();
});
}
},
setLoader: function() {
this.setContent(
'<div class="loading-placeholder">' +
'<div class="dashicons dashicons-feedback"></div>' +
'<div class="wpview-loading"><ins></ins></div>' +
'</div>'
);
},
// Backwards compatability for WP pre-4.2
View: {
overlay: true,
shortcodeHTML: false,
setContent: function (html, option) {
this.getNodes(function (editor, node, content) {
var el = ( option === 'wrap' || option === 'replace' ) ? node : content,
insert = html;
if (_.isString(insert)) {
insert = editor.dom.createFragment(insert);
}
if (option === 'replace') {
editor.dom.replace(insert, el);
} else if (option === 'remove') {
node.parentNode.insertBefore(insert, node.nextSibling);
$(node).remove();
} else {
el.innerHTML = '';
el.appendChild(insert);
}
});
},
initialize: function (options) {
var actionTag = typeof options.shortcode.attrs.named.action != 'undefined' ? options.shortcode.attrs.named.action : '';
var shortcodeModel = sui.shortcodes.findWhere({action_tag: actionTag});
if (!shortcodeModel) {
this.shortcodeHTML = decodeURIComponent(options.encodedText);
this.shortcode = false;
return;
}
var shortcode = shortcodeModel.clone();
shortcode.get('attrs').each(function (attr) {
if (attr.get('attr') in options.shortcode.attrs.named) {
attr.set(
'value',
options.shortcode.attrs.named[attr.get('attr')]
);
}
if (attr.get('attr') === 'content' && ( 'content' in options.shortcode )) {
attr.set('value', options.shortcode.content);
}
});
this.shortcode = shortcode;
},
loadingPlaceholder: function () {
return '' +
'<div class="loading-placeholder">' +
'<div class="dashicons dashicons-feedback"></div>' +
'<div class="wpview-loading"><ins></ins></div>' +
'</div>';
},
/**
* @see wp.mce.View.getEditors
*/
getEditors: function (callback) {
var editors = [];
_.each(tinymce.editors, function (editor) {
if (editor.plugins.wpview) {
if (callback) {
callback(editor);
}
editors.push(editor);
}
}, this);
return editors;
},
/**
* @see wp.mce.View.getNodes
*/
getNodes: function (callback) {
var nodes = [],
self = this;
this.getEditors(function (editor) {
$(editor.getBody())
.find('[data-wpview-text="' + self.encodedText + '"]')
.each(function (i, node) {
if (callback) {
callback(editor, node, $(node).find('.wpview-content').get(0));
}
nodes.push(node);
});
});
return nodes;
},
/**
* Set the HTML. Modeled after wp.mce.View.setIframes
*
*/
setIframes: function (body) {
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
if (body.indexOf('<script') === -1) {
this.shortcodeHTML = body;
this.render();
return;
}
this.getNodes(function (editor, node, content) {
var dom = editor.dom,
styles = '',
bodyClasses = editor.getBody().className || '',
iframe, iframeDoc, i, resize;
content.innerHTML = '';
var head = '';
if (!wp.mce.views.sandboxStyles) {
tinymce.each(dom.$('link[rel="stylesheet"]', editor.getDoc().head), function (link) {
if (link.href && link.href.indexOf('skins/lightgray/content.min.css') === -1 &&
link.href.indexOf('skins/wordpress/wp-content.css') === -1) {
styles += dom.getOuterHTML(link) + '\n';
}
});
wp.mce.views.sandboxStyles = styles;
} else {
styles = wp.mce.views.sandboxStyles;
}
// Seems Firefox needs a bit of time to insert/set the view nodes, or the iframe will fail
// especially when switching Text => Visual.
setTimeout(function () {
iframe = dom.add(content, 'iframe', {
src: tinymce.Env.ie ? 'javascript:""' : '',
frameBorder: '0',
id: 'gf-shortcode-preview-' + new Date().getTime(),
allowTransparency: 'true',
scrolling: 'no',
'class': 'wpview-sandbox',
style: {
width: '100%',
display: 'block'
}
});
iframeDoc = iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(
'<!DOCTYPE html>' +
'<html>' +
'<head>' +
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' +
head +
styles +
'<style>' +
'html {' +
'background: transparent;' +
'padding: 0;' +
'margin: 0;' +
'}' +
'body#wpview-iframe-sandbox {' +
'background: transparent;' +
'padding: 1px 0 !important;' +
'margin: -1px 0 0 !important;' +
'}' +
'body#wpview-iframe-sandbox:before,' +
'body#wpview-iframe-sandbox:after {' +
'display: none;' +
'content: "";' +
'}' +
'</style>' +
'</head>' +
'<body id="wpview-iframe-sandbox" class="' + bodyClasses + '">' +
body +
'</body>' +
'</html>'
);
iframeDoc.close();
resize = function () {
// Make sure the iframe still exists.
iframe.contentWindow && $(iframe).height($(iframeDoc.body).height());
};
if (MutationObserver) {
new MutationObserver(_.debounce(function () {
resize();
}, 100))
.observe(iframeDoc.body, {
attributes: true,
childList: true,
subtree: true
});
} else {
for (i = 1; i < 6; i++) {
setTimeout(resize, i * 700);
}
}
resize();
editor.on('wp-body-class-change', function () {
iframeDoc.body.className = editor.getBody().className;
});
}, 50);
});
},
/**
* Render the shortcode
*
* To ensure consistent rendering - this makes an ajax request to the admin and displays.
* @return string html
*/
getHtml: function () {
if (!this.shortcode) {
this.setContent(this.shortcodeHTML, 'remove');
return;
}
var data;
if (false === this.shortcodeHTML) {
var attr = this.shortcode.get('attrs').findWhere({attr: 'id'});
var formId = attr.get('value');
data = {
action: 'gf_do_shortcode',
post_id: $('#post_ID').val(),
form_id: formId,
shortcode: this.shortcode.formatShortcode(),
nonce: gfShortcodeUIData.previewNonce
};
$.post(ajaxurl, data, $.proxy(this.setIframes, this));
}
return this.shortcodeHTML;
},
},
edit : function( shortcodeString ) {
var currentShortcode;
// Backwards compatability for WP pre-4.2
if ( 'object' === typeof( shortcodeString ) ) {
shortcodeString = decodeURIComponent( jQuery(shortcodeString).attr('data-wpview-text') );
}
currentShortcode = wp.shortcode.next('gravityform', shortcodeString);
if ( currentShortcode ) {
var action = currentShortcode.shortcode.attrs.named.action ? currentShortcode.shortcode.attrs.named.action : '';
var defaultShortcode = sui.shortcodes.findWhere({
shortcode_tag: currentShortcode.shortcode.tag,
action_tag: action
});
if (!defaultShortcode) {
return;
}
var currentShortcodeModel = defaultShortcode.clone();
// convert attribute strings to object.
_.each(currentShortcode.shortcode.attrs.named, function (val, key) {
attr = currentShortcodeModel.get('attrs').findWhere({attr: key});
if (attr) {
attr.set('value', val);
}
});
var idAttr = currentShortcodeModel.get('attrs').findWhere({attr: 'id'});
var formId = idAttr.get('value');
$('#add_form_id').val(formId);
GformShortcodeUI = new sui.views.editShortcodeForm({model: currentShortcodeModel, viewMode: 'update'});
GformShortcodeUI.render();
$('#gform-insert-shortcode').hide();
$('#gform-update-shortcode').show();
tb_show("Edit Gravity Form", "#TB_inline?inlineId=select_gravity_form&width=753&height=686", "");
}
},
};
$(document).ready(function () {
sui.strings = gfShortcodeUIData.strings;
sui.shortcodes = new sui.collections.Shortcodes( gfShortcodeUIData.shortcodes );
if( ! gfShortcodeUIData.previewDisabled && typeof wp.mce != 'undefined'){
wp.mce.views.register( 'gravityform', $.extend(true, {}, sui.utils.shortcodeViewConstructor) );
}
$(document).on('click', '.gform_media_link', function () {
sui.shortcodes = new sui.collections.Shortcodes(gfShortcodeUIData.shortcodes);
var shortcode = sui.shortcodes.findWhere({shortcode_tag: 'gravityform', action_tag: ''});
GformShortcodeUI = new sui.views.editShortcodeForm({model: shortcode, viewMode: 'insert'});
GformShortcodeUI.render();
tb_show("Insert Gravity Form", "#TB_inline?inlineId=select_gravity_form&width=753&height=686", "");
});
});
}(window.gfShortcodeUI = window.gfShortcodeUI || {}, jQuery));

1
js/shortcode-ui.min.js vendored Normal file

File diff suppressed because one or more lines are too long

30
js/tooltip_init.js Normal file
View File

@@ -0,0 +1,30 @@
jQuery(document).ready(function() {
gform_initialize_tooltips();
});
function gform_initialize_tooltips() {
jQuery('.gf_tooltip').tooltip({
show: 500,
content: function () {
return jQuery(this).prop('title');
},
open: function (event, ui) {
if (typeof(event.originalEvent) === 'undefined') {
return false;
}
var $id = jQuery(ui.tooltip).attr('id');
jQuery('div.ui-tooltip').not('#' + $id).remove();
},
close: function (event, ui) {
ui.tooltip.hover(function () {
jQuery(this).stop(true).fadeTo(400, 1);
},
function () {
jQuery(this).fadeOut('500', function () {
jQuery(this).remove();
});
});
}
});
}

1
js/tooltip_init.min.js vendored Normal file
View File

@@ -0,0 +1 @@
function gform_initialize_tooltips(){jQuery(".gf_tooltip").tooltip({show:500,content:function(){return jQuery(this).prop("title")},open:function(a,b){if(void 0===a.originalEvent)return!1;var c=jQuery(b.tooltip).attr("id");jQuery("div.ui-tooltip").not("#"+c).remove()},close:function(a,b){b.tooltip.hover(function(){jQuery(this).stop(!0).fadeTo(400,1)},function(){jQuery(this).fadeOut("500",function(){jQuery(this).remove()})})}})}jQuery(document).ready(function(){gform_initialize_tooltips()});