Revize 74a7dbca
Přidáno uživatelem Michal Kliment před více než 9 roky(ů)
application/views/js/base.php | ||
---|---|---|
input_add_increase_decrease_buttons($(e));
|
||
}
|
||
});
|
||
|
||
$('.infinitycheckbox').change(function()
|
||
{
|
||
var id = this.id.replace('_infinity', '');
|
||
if (this.checked)
|
||
{
|
||
$("#"+id).attr('disabled', 'disabled');
|
||
$("#"+id).val('9999-12-31');
|
||
}
|
||
else
|
||
{
|
||
$("#"+id).removeAttr('disabled');
|
||
}
|
||
}).trigger('change');
|
||
|
||
// dialog with help
|
||
$('.help_hint').unbind('click').bind('click', function ()
|
||
... | ... | |
if (this._items[id] == undefined)
|
||
this._items[id] = new Dialog(id, parent, isReloadOn);
|
||
|
||
this._items[id]._opened_count++;
|
||
|
||
return this._items[id];
|
||
},
|
||
|
||
... | ... | |
|
||
this._data = '';
|
||
|
||
this._opened_count = 0;
|
||
|
||
// set parent
|
||
this.setParent(parent);
|
||
|
||
... | ... | |
// result is html
|
||
case '<':
|
||
parent._format = 'html';
|
||
|
||
// this is hack because jQuery auto removes scipt tags (credits: http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/)
|
||
data = data.replace(/script/gi, 'myscript');
|
||
|
||
parent._data = $(data).find('#content-padd');
|
||
break;
|
||
|
||
// result is json
|
||
case '{':
|
||
case '[':
|
||
parent._format = 'json';
|
||
parent._data = jQuery.parseJSON(data);
|
||
break;
|
||
... | ... | |
context = this._element;
|
||
$.getScript('<?php echo url_lang::base() ?>js/'+str_replace('<?php echo url_lang::base() ?>', '', this._url)+glue+'nobase=1');
|
||
|
||
this._element.find(".form").validate();
|
||
// this is hack because jQuery auto removes scipt tags (credits: http://blog.devlpr.net/2012/04/29/how-to-get-script-tags-with-jquery-find-from-ajax-result/)
|
||
this._element.find("myscript").each (function (){
|
||
eval($(this).html());
|
||
|
||
$(this).remove();
|
||
});
|
||
|
||
this._element.find('#filter_form').addClass('nopopup');
|
||
|
||
this._element.find(".form, #filter_form").each(function()
|
||
{
|
||
$(this).validate();
|
||
});
|
||
|
||
update_select_multiple();
|
||
}
|
||
... | ... | |
getLink: function ()
|
||
{
|
||
return $('#popup-link-' + this.id);
|
||
},
|
||
|
||
/**
|
||
* Get count of opened dialogs
|
||
*
|
||
* @returns integer
|
||
*/
|
||
getOpenedCount: function ()
|
||
{
|
||
return this._opened_count;
|
||
}
|
||
};
|
||
|
||
... | ... | |
|
||
// create new dialog
|
||
var dialog = dialogs.add($this, parent, !$this.hasClass('isReloadOff'));
|
||
|
||
// load url in it
|
||
dialog.load(url);
|
||
|
||
if (dialog.getOpenedCount() == 1)
|
||
{
|
||
// load url in it
|
||
dialog.load(url);
|
||
}
|
||
|
||
// init TinyMCE Editors in dialog
|
||
if (window['advancedTinyMCE'] !== undefined)
|
||
... | ... | |
if (dialog.isReloadOn())
|
||
{
|
||
reload_element('#'+$(dropdown).attr('id'), url, limit);
|
||
|
||
var text = $('#'+$(dropdown).attr('id')+" option[value="+data.id+"]").text();
|
||
|
||
if (dropdown.attr('multiple') == 'multiple')
|
||
{
|
||
select_multiple[$(dropdown).attr('id')].push({'key': data.id, 'value': text});
|
||
}
|
||
}
|
||
|
||
dropdown.trigger('addOption', data.id);
|
||
... | ... | |
return false;
|
||
});
|
||
|
||
/**
|
||
* Submit of form in filter dialog
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
$(".dialog #filter_form").live('submit', function()
|
||
{
|
||
// get dialog
|
||
var dialog = dialogs.get($(this).parent());
|
||
|
||
var glue = ($(this).attr('action').indexOf('?') == -1) ? '?' : '&';
|
||
|
||
var url = $(this).attr('action')+glue+'noredirect=1';
|
||
|
||
// find link which open this dialog
|
||
var link = dialogs.links.get($(this).parent());
|
||
|
||
// find parent of dialog (another dialog or main page)
|
||
var parent = dialog.getParent();
|
||
|
||
var dropdown = link.prev();
|
||
|
||
$.ajax({
|
||
async: false,
|
||
type: 'GET',
|
||
url: url,
|
||
data: dialog.getFormData(),
|
||
success: function (data)
|
||
{
|
||
var first_option_text = dropdown.children().first().text();
|
||
|
||
dropdown.html('');
|
||
|
||
dropdown.append('<option>'+first_option_text+'</option>');
|
||
|
||
data = jQuery.parseJSON(data);
|
||
|
||
for (key in data)
|
||
{
|
||
dropdown.append('<option value="'+data[key].id+'">'+data[key].name+'</option>');
|
||
}
|
||
}
|
||
});
|
||
|
||
dialog.hide();
|
||
|
||
return false;
|
||
});
|
||
|
||
/* AJAX fulltext search ***************************************************/
|
||
|
||
var r_get = null;
|
||
... | ... | |
|
||
/* Validators *************************************************************/
|
||
|
||
$.validator.addMethod('ttl', function(value)
|
||
{
|
||
value = value.replace(new RegExp("\\n", "g"), ",");
|
||
return value == '' || value.match(/^[0-9]+[mhdw]?$/g);
|
||
}, '<?php echo __('Invalid time to live format') ?>');
|
||
|
||
$.validator.addMethod('domain_name', function(value)
|
||
{
|
||
value = value.replace(new RegExp("\\n", "g"), ",");
|
||
return value == '' || value == '@' || value.match(/^([A-Za-z0-9]+\.)*[A-Za-z0-9]+\.?$/g);
|
||
}, '<?php echo __('Invalid domain name') ?>');
|
||
|
||
$.validator.addMethod('ip_address', function(value)
|
||
{
|
||
value = value.replace(new RegExp("\\n", "g"), ",");
|
||
return value == '' || value.match(/^(((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9]),?)+$/g);
|
||
}, '<?php echo __('Invalid IP address') ?>');
|
||
|
||
$.validator.addMethod('ipv6_address', function(value)
|
||
{
|
||
value = value.replace(new RegExp("\\n", "g"), ",");
|
||
return value == '' || value.match(/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/g);
|
||
}, '<?php echo __('Invalid IP address') ?>');
|
||
|
||
$.validator.addMethod('ip_address_check', function(value, element)
|
||
{
|
||
var ret = false;
|
||
... | ... | |
|
||
return ret;
|
||
}, '<?php echo __('IP address already exists.') ?>');
|
||
|
||
|
||
$.validator.addMethod('zone_name_check', function(value, element)
|
||
{
|
||
var ret = false;
|
||
|
||
$.ajax({
|
||
url: '<?php echo url_lang::base() ?>json/zone_name_check',
|
||
async: false,
|
||
dataType: 'json',
|
||
data: {zone_id: dns_zone_id, zone: value},
|
||
success: function(result)
|
||
{
|
||
if(result.state)
|
||
{
|
||
ret = true;
|
||
}
|
||
else
|
||
{
|
||
$.validator.messages.zone_name_check = result.message;
|
||
}
|
||
}
|
||
});
|
||
|
||
return ret;
|
||
}, '<?php echo __('Zone already exists.') ?>');
|
||
|
||
$.validator.addMethod('cidr', function(value)
|
||
{
|
||
var result = value.match(/^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\/((3[0-2])|(2[0-9])|(1[0-9])|([0-9]))$/);
|
||
... | ... | |
return confirm;
|
||
});
|
||
|
||
// validate all form
|
||
$('.form').validate({
|
||
errorPlacement: function(error, el)
|
||
{
|
||
// if element has multiple inputs in row, insert error message after
|
||
// second input to prevent destroying layout
|
||
if (el.hasClass('join1') || el.hasClass('join2'))
|
||
// validate all form and filters
|
||
$('.form, #filter_form').each(function() {
|
||
$(this).validate({
|
||
errorPlacement: function(error, el)
|
||
{
|
||
error.insertAfter(el.parent().find('.join2'));
|
||
}
|
||
else // insert error after first element
|
||
{
|
||
error.insertAfter(el);
|
||
// if element has multiple inputs in row, insert error message after
|
||
// second input to prevent destroying layout
|
||
if (el.hasClass('join1') || el.hasClass('join2'))
|
||
{
|
||
error.insertAfter(el.parent().find('.join2'));
|
||
}
|
||
else // insert error after first element
|
||
{
|
||
error.insertAfter(el);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
// gave focus to focus classed objects
|
||
... | ... | |
// Set show and hide menu events on mobile device
|
||
if (jQuery.browser.mobile)
|
||
{
|
||
$('body').addClass('cellphone');
|
||
|
||
$('#cellphone_hide_menu').click(function()
|
||
{
|
||
cellphone_hide_menu();
|
||
... | ... | |
});
|
||
|
||
// menu tooltip
|
||
if ($.cookie('cellphone_menu_tooltip') != '1')
|
||
if ($.cookie('cellphone_menu_tooltip') !== '1')
|
||
{
|
||
$('#cellphone_menu_tooltip').fadeIn(function(){
|
||
$.cookie('cellphone_menu_tooltip', '1', { path: '<?php echo Settings::get('suffix') ?>' });
|
Také k dispozici: Unified diff
Merge from SVN branch 1.2.