Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1446

Přidáno uživatelem Ondřej Fibich před více než 12 roky(ů)

Upravy:
- pridani detailu k IP adrese pri pridavani zarizeni (#185)
- upravy vzhledu dialogu pro pridavani zarizeni (#185)
- zmeny v sablonach u internich rozhrani (#185)
- setrideni zakladniho JS pohledu

Zobrazit rozdíly:

freenetis/branches/network/media/css/forms.css
cursor: pointer;
}
.dropdown {
padding:2px;
}
.button_big {
padding: 5px;
font-weight: bold;
freenetis/branches/network/application/i18n/cs_CZ/texts.php
'add comment to financial state of member' => 'Přidat komentář k finančnímu stavu člena',
'add comment to work' => 'Přidat komentář k práci',
'add contact' => 'Přidat kontakt',
'add device template' => 'Přidat šablonu zařízení',
'add device template' => 'Přidat šablonu zařízení',
'add details to ip address' => 'Přidat detaily k IP adrese',
'add items' => 'Přidat položky',
'add member fee payment by cash' => 'Přidat platbu členského příspěvku hotově',
'add new' => 'Přidat nový',
freenetis/branches/network/application/controllers/device_templates.php
->label('Type')
->options($enum_types)
->selected($enum_type_id)
->rules('required');
->rules('required')
->style('width: 200px');
// eth
......
$internal_form = $form->group('Internal interfaces')->visible(FALSE);
$internal_form->input('values[' . Iface_Model::TYPE_INTERNAL . '][min_count]')
->label('Minimal count')
$internal_form->input('values[' . Iface_Model::TYPE_INTERNAL . '][count]')
->label('Count')
->rules('valid_numeric|length[0,2]');
$internal_form->input('values[' . Iface_Model::TYPE_INTERNAL . '][max_count]')
->label('Maximal count')
->rules('valid_numeric|length[0,2]');
$form->submit('Add');
// validate form and save data
......
->label('Type')
->options($enum_types)
->rules('required')
->selected($device_template_model->enum_type_id);
->selected($device_template_model->enum_type_id)
->style('width: 200px');
// eth
......
$internal_form = $form->group('Internal interfaces');
if (!$ivals[Iface_Model::TYPE_INTERNAL]['min_count'] &&
!$ivals[Iface_Model::TYPE_INTERNAL]['max_count'])
if (!$ivals[Iface_Model::TYPE_INTERNAL]['count'])
{
$internal_form->visible(FALSE);
}
$internal_form->input('values[' . Iface_Model::TYPE_INTERNAL . '][min_count]')
->label('Minimal count')
$internal_form->input('values[' . Iface_Model::TYPE_INTERNAL . '][count]')
->label('Count')
->rules('valid_numeric|length[0,2]')
->value($ivals[Iface_Model::TYPE_INTERNAL]['min_count']);
->value($ivals[Iface_Model::TYPE_INTERNAL]['count']);
$internal_form->input('values[' . Iface_Model::TYPE_INTERNAL . '][max_count]')
->label('Maximal count')
->rules('valid_numeric|length[0,2]')
->value($ivals[Iface_Model::TYPE_INTERNAL]['max_count']);
$form->submit('Edit');
//validate form and save data
......
$vals[Iface_Model::TYPE_INTERNAL]['has_ip'] = Iface_Model::type_has_ip_address(Iface_Model::TYPE_INTERNAL);
$vals[Iface_Model::TYPE_INTERNAL]['has_link'] = Iface_Model::type_has_link(Iface_Model::TYPE_INTERNAL);
$vals[Iface_Model::TYPE_INTERNAL]['has_mac'] = Iface_Model::type_has_mac_address(Iface_Model::TYPE_INTERNAL);
$vals[Iface_Model::TYPE_INTERNAL]['min_count'] = intval(@$vals[Iface_Model::TYPE_INTERNAL]['min_count']);
$vals[Iface_Model::TYPE_INTERNAL]['max_count'] = intval(@$vals[Iface_Model::TYPE_INTERNAL]['max_count']);
$vals[Iface_Model::TYPE_INTERNAL]['count'] = intval(@$vals[Iface_Model::TYPE_INTERNAL]['count']);
if (!isset($vals[Iface_Model::TYPE_INTERNAL]['items']))
{
......
{
$vals[Iface_Model::TYPE_WIRELESS]['max_count'] = $vals[Iface_Model::TYPE_WIRELESS]['min_count'];
}
if ($vals[Iface_Model::TYPE_INTERNAL]['min_count'] > $vals[Iface_Model::TYPE_INTERNAL]['max_count'])
{
$vals[Iface_Model::TYPE_INTERNAL]['max_count'] = $vals[Iface_Model::TYPE_INTERNAL]['min_count'];
}
}
}
freenetis/branches/network/application/controllers/devices.php
->label('Device name')
->value(($user_id) ? $user->surname : '')
->rules('required|length[2,200]')
->style('width: 500px');
->style('width: 520px');
$group_device->dropdown('user_id')
->label('User')
->rules('required')
->options($arr_users)
->selected($selected);
->selected($selected)
->style('width: 250px');
$group_device->dropdown('type')
->options($types)
->rules('required');
->rules('required')
->style('width: 250px');
$group_device->dropdown('device_template_id')
->options($device_templates)
->label('Device template')
->rules('required')
->style('width: 250px')
->add_button('device_templates');
$group_device_details = $form->group('Device detail')->visible(FALSE);
$group_device_details->input('trade_name')
->rules('length[2,50]')
->autocomplete('json/device_trade_name');
->autocomplete('json/device_trade_name')
->style('width: 520px');
$group_device_details->dropdown('PPPoE_logging_in')
->label('PPPoE')
......
$group_device_details->input('login')
->label('Username')
->rules('length[0,30]')
->autocomplete('json/device_login');
->autocomplete('json/device_login')
->style('width: 250px');
}
if ($this->acl_check_new(get_class($this), 'password'))
......
$group_device_details->input('login_password')
->label('Password')
->rules('length[0,30]')
->autocomplete('json/device_password');
->autocomplete('json/device_password')
->style('width: 250px');
}
$group_device_details->textarea('comment')
->label('Comment')
->rules('length[0,254]');
$group_device_details->dropdown('first_engineer_id')
->label('Engineer')
->options($arr_engineers)
->rules('required')
->selected($selected_engineer);
->selected($selected_engineer)
->style('width: 250px');
$group_device_details->textarea('comment')
->label('Comment')
->rules('length[0,254]')
->style('width: 520px');
$group_payment = $form->group('Device repayments')->visible(FALSE);
$group_payment->input('price')
->rules('valid_numeric');
->rules('valid_numeric')
->style('width: 250px');
$group_payment->input('payment_rate')
->label('Monthly payment rate')
->rules('valid_numeric');
->rules('valid_numeric')
->style('width: 250px');
$group_payment->date('buy_date')
->label('Buy date')
......
->rules('required')
->options($arr_towns)
->selected($selected_town_id)
->style('width: 250px')
->add_button('towns');
$group_address->dropdown('street_id')
->label('Street')
->options($arr_streets)
->selected($selected_street_id)
->add_button('streets');
->add_button('streets')
->style('width: 250px');
$group_address->input('street_number')
->rules('length[1,50]')
->value($selected_street_number);
->value($selected_street_number)
->style('width: 250px');
$group_address->dropdown('country_id')
->label('Country')
->rules('required')
->options($arr_countries)
->selected(Settings::get('default_country'));
->selected(Settings::get('default_country'))
->style('width: 250px');
$group_address->input('gpsx')
->label(__('GPS').' X: '.help::hint('gps_coordinates'))
->rules('gps')
->value($gpsx);
->value($gpsx)
->style('width: 250px');
$group_address->input('gpsy')
->label(__('GPS').' Y: '.help::hint('gps_coordinates'))
->rules('gps')
->value($gpsy);
->value($gpsy)
->style('width: 250px');
$form->group('Ethernet interfaces');
$form->group('Wireless interfaces');
......
$view = new View('main');
$view->title = __('Add new whole device');
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('form');
$view->content = new View('devices/add');
$view->content->form = $form->html();
$view->content->headline = __('Add new whole device');
$view->content->yes_no_option = $yes_no_option;
$view->render(TRUE);
} // end of function add
freenetis/branches/network/application/libraries/forge/Form_Dropdown.php
* @param string $controller Controller to add
* @param string $method Method of controller [optional]
* @param string $args Other arguments of controller [optional]
* @return Form_Dropdown
*/
public function add_button($controller = NULL, $method = 'add', $args = '')
{
......
$this->data['add_button'] = $url;
$this->data['add_button_title'] = __('Add '.$controller_name);
return $this;
}
protected function load_value()
freenetis/branches/network/application/views/devices/add.php
<h2><?php echo $headline ?></h2>
<br /><?php echo $form ?><br />
<div id="dialog_ip_address_detail" style="display: none">
<form class="form">
<table class="form" cellspacing="0">
<tr>
<th><label><?php echo __('Gateway') ?>:&nbsp;<?php echo help::hint('gateway') ?></label></th>
<td><?php echo form::dropdown('gateway_input', $yes_no_option) ?></td>
</tr>
<tr>
<th><label><?php echo __('Service') ?>:&nbsp;<?php echo help::hint('service') ?></label></th>
<td><?php echo form::dropdown('service_input', $yes_no_option) ?></td>
</tr>
</table>
<button class="submit" type="button"><?php echo __('Save') ?></button>
</form>
</div>
freenetis/branches/network/application/views/js/__pieces/address_point_street.php
prev_val = $street.val();
$street.html('');
$street.css('width', '210px');
if ((options = town_dropdown_change($(this))) !== false)
{
freenetis/branches/network/application/views/js/device_templates_add.php
* Makes internal ifaces inputs - enables to add name
*
* @param parent Parent object after which elements will be added
* @param count Max count of internal ifaces
* @param count Count of internal ifaces
*/
function make_internal_iface_inputs(parent, count)
{
......
}
}
/** Last value of internal internal_iface_min_max_keyup (cache) */
var internal_iface_min_max_keyup_cache = null;
/**
* Processes key events of inputs that allows to fill counts of internal ifaces
*
* @param e Elements who trigger event
*/
function internal_iface_min_max_keyup(e)
{
var emin_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][min_count]"]');
var emax_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][max_count]"]');
var min_count = emin_count.val();
var max_count = emax_count.val();
if (!max_count.length)
{
max_count = 0;
}
else if (isNaN(max_count) || isNaN(min_count))
{
if (isNaN(max_count) && isNaN(min_count))
{
return false;
}
else if (isNaN(max_count))
{
max_count = 0;
}
else if (isNaN(min_count))
{
min_count = 0;
}
}
min_count = parseInt(min_count);
max_count = parseInt(max_count);
if (max_count < min_count)
{
max_count = min_count;
emax_count.val(max_count);
}
if (max_count != internal_iface_min_max_keyup_cache)
{
internal_iface_min_max_keyup_cache = max_count;
make_internal_iface_inputs(emax_count.parent().parent(), max_count);
}
}
/// triggers code //////////////////////////////////////////////////////////
var e_port_count = $('input[name="values[<?php echo Iface_Model::TYPE_PORT ?>][count]"]');
var e_ethernet_count = $('input[name="values[<?php echo Iface_Model::TYPE_ETHERNET ?>][count]"]');
var e_wireless_min_count = $('input[name="values[<?php echo Iface_Model::TYPE_WIRELESS ?>][min_count]"]');
var e_wireless_max_count = $('input[name="values[<?php echo Iface_Model::TYPE_WIRELESS ?>][max_count]"]');
var e_internal_min_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][min_count]"]');
var e_internal_max_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][max_count]"]');
var e_internal_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][count]"]');
// on change of ethernet count
e_ethernet_count.keyup(function ()
......
e_wireless_min_count.keyup(wiface_min_max_keyup);
// on change of max wireless ifaces count
e_wireless_max_count.keyup(wiface_min_max_keyup);
// on change of min wireless ifaces count
e_internal_max_count.keyup(internal_iface_min_max_keyup);
// on change of max wireless ifaces count
e_internal_max_count.keyup(internal_iface_min_max_keyup);
// on change of wireless ifaces count
e_internal_count.keyup(function ()
{
var count = $(this).val();
if (!count.length)
{
count = 0;
}
else if (isNaN(count))
{
return false;
}
make_internal_iface_inputs($(this).parent().parent(), count);
});
// add buttons for increasing, decreasing
input_add_increase_decrease_buttons(e_port_count, 0, 99);
input_add_increase_decrease_buttons(e_ethernet_count, 0, 99);
input_add_increase_decrease_buttons(e_wireless_min_count, 0, 99);
input_add_increase_decrease_buttons(e_wireless_max_count, 0, 99);
input_add_increase_decrease_buttons(e_internal_min_count, 0, 99);
input_add_increase_decrease_buttons(e_internal_max_count, 0, 99);
input_add_increase_decrease_buttons(e_internal_count, 0, 99);
<?php if (isset($device_template_value)): ?>
......
e_port_count.trigger('keyup');
e_wireless_min_count.trigger('keyup');
e_wireless_max_count.trigger('keyup');
e_internal_min_count.trigger('keyup');
e_internal_max_count.trigger('keyup');
e_internal_count.trigger('keyup');
// set values of ethernet ifaces items
<?php $i = 0; foreach ($device_template_value[Iface_Model::TYPE_ETHERNET]['items'] as $item): ?>
freenetis/branches/network/application/views/js/devices_add.php
<?php
/**
* JavaScript funcionality for adding ofdevice especially form building.
*
* @author Michal Kliment, Ondřej Fibich
* @author Ondřej Fibich
*/
// IDE complementation
......
var $internal_group = $('#group-8');
// values for dropdowns
var arr_subnets = '<option value="">---- <?php echo __('Select subnet') ?> ----</option><?php foreach ($arr_subnets as $k => $v): ?><option value="<?php echo $k ?>"><?php echo $v ?></option><?php endforeach; ?>';
var arr_devices = '<option value="">---- <?php echo __('Select device') ?> ----</option><?php foreach ($arr_devices as $k => $v): ?><option value="<?php echo $k ?>"><?php echo $v ?></option><?php endforeach; ?>';
var subnets_options = '<option value="">---- <?php echo __('Select subnet') ?> ----</option><?php foreach ($arr_subnets as $k => $v): ?><option value="<?php echo $k ?>"><?php echo $v ?></option><?php endforeach; ?>';
var devices_options = '<option value="">---- <?php echo __('Select device') ?> ----</option><?php foreach ($arr_devices as $k => $v): ?><option value="<?php echo $k ?>"><?php echo $v ?></option><?php endforeach; ?>';
var port_mode_options = '<?php foreach (Iface_Model::get_port_modes() as $k => $v): ?><option value="<?php echo $k ?>"><?php echo $v ?></option><?php endforeach; ?>';
var wiface_mode_options = '<?php foreach (Iface_Model::get_wireless_modes() as $k => $v): ?><option value="<?php echo $k ?>"<?php echo ($k == Iface_Model::WIRELESS_MODE_CLIENT) ? ' selected="selected"' : '' ?>><?php echo $v ?></option><?php endforeach; ?>';
var wiface_antenna_options = '<?php foreach (Iface_Model::get_wireless_antennas() as $k => $v): ?><option value="<?php echo $k ?>"<?php echo ($k == Iface_Model::WIRELESS_ANTENNA_SECTIONAL) ? ' selected="selected"' : '' ?>><?php echo $v ?></option><?php endforeach; ?>';
// port modes
// port modes asociative array
var port_modes = new Array();
<?php foreach (Iface_Model::get_port_modes() as $k => $v): ?>
port_modes[<?php echo $k ?>] = '<?php echo $v ?>';
......
suggest_connected_to[<?php echo $k ?>] = {device_id : <?php echo $v->device_id ?>, iface_id : <?php echo $v->id ?>};
<?php endif; endforeach; ?>
function add_detail_to_ip() {}
function add_detail_to_link() {}
function add_detail_to_iface() {}
function select_device_using_map() {}
/**
* Opens dialog for specifing of details of IP address of iface. Data
* are stored in hidden fields.
*/
function add_detail_to_ip()
{
var $td = $(this).parent().parent();
// set form with current values
$('#gateway_input').val($td.find('input[name^="gateway"]').val());
$('#service_input').val($td.find('input[name^="service"]').val());
// dialog button action submit
$('#dialog_ip_address_detail form button').unbind('click').click(function ()
{
if ($('#dialog_ip_address_detail form').validate().valid())
{
// fill in hidden fields
$td.find('input[name^="gateway"]').val($('#gateway_input').val())
$td.find('input[name^="service"]').val($('#service_input').val())
// close dialog
$('#dialog_ip_address_detail').dialog('close');
}
});
// open dialog
$('#dialog_ip_address_detail').dialog({
title: '<?php echo __('Add details to IP address') ?>',
modal: true,
position: ['center', 100]
});
return false;
}
/**
* Opens dialog for specifing of details of link of iface. Data are stored
* in hidden fields.
*/
function add_detail_to_link()
{
}
/**
* Opens dialog for specifing of details of iface. Data are stored in hidden
* fields.
*/
function add_detail_to_iface()
{
}
/**
* Allows to select device using dialog with device tree.
*/
function select_device_using_map()
{
}
/**
* On change of connected to device dropdown, select suitable ifaces
*/
function change_connected()
......
name : 'subnet[' + i + ']',
style : 'width: 9em',
change : use_row
}).html(arr_subnets))
}).html(subnets_options))
);
}
......
name : 'connected[' + i + ']',
style : 'width: 13em',
change : use_row
}).bind('change', change_connected).html(arr_devices)).append($('<a>', {
}).bind('change', change_connected).html(devices_options)).append($('<a>', {
href : '#',
click : select_device_using_map,
style : 'margin: 4px',
......
}
// internal
if (internals['max_count'] > 0)
if (internals['count'] > 0)
{
i = create_form_of_group($internal_group, internals, i);
$internal_group.show();
......
// remove add buttons
$this.find('a.popup_link').remove();
// loader
$this.after('<?php echo html::image(array("src" => "media/images/icons/animations/ajax-loader.gif", "id" => "da_loader", "class" => "ajax-loader")); ?>');
$this.after('<?php echo html::image(array('src' => 'media/images/icons/animations/ajax-loader.gif', 'id' => 'da_loader', 'class' => 'ajax-loader')); ?>');
// build form
$.getJSON('<?php echo url_lang::base() ?>json/get_device_template_value', {
device_template_id: $('#device_template_id').val()
freenetis/branches/network/application/views/js/base.php
// After document load
$(document).ready(function()
{
/* Form additional functionality ******************************************/
/**
* Reload given element from given URL
* Due to bug in jQuery element has to be given as selector
......
$('table').tablesorter();
<?php if (!$nobase): ?>
// hide loader animation
$('#loading-overlay').hide();
/* Dialog functionality ***************************************************/
context = $('html');
var r_get = null;
editorInit = function ()
{
tinyMCE.init({
// General options
entity_encoding : "raw",
mode : "textareas",
theme : "advanced",
editor_selector : "wysiwyg",
editor_deselector : "textarea",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
elements : "registration_license",
theme_advanced_toolbar_location : "top",
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
height : "480px",
width : "656px",
extended_valid_elements : "iframe[src|width|height|name|align]"
});
};
// dialog for export
var $export_dialog = $('#export-div').dialog({
autoOpen: false,
title: '<?php echo __('Export') ?>',
modal: true,
position: ['center', 50],
width: 330,
heigth: 30
});
/**
* Main dialogs object, performs all actions with dialogs
*
......
*/
hide: function ()
{
for (i in this._items)
for (var i in this._items)
{
this._items[i].hide();
}
......
dialogs.links.add(($(this)));
});
// asking before delete action
$('.delete_link').live("click", function(e)
{
var confirm = window.confirm('<?php echo __('Do you really want to delete this record') ?>?');
if (!confirm)
e.stopImmediatePropagation();
return confirm;
});
/**
* Opens dialog window
*
......
*
* @author Michal Kliment
*/
$('.dialog form:not(.nopopup)').live("submit", function(){
$('.dialog form:not(.nopopup)').live('submit', function()
{
// get dialog
var dialog = dialogs.get($(this).parent());
......
if (link.hasClass('popup-add'))
{
// load drowdown to which we will add new option
dropdown = link.prev();
var dropdown = link.prev();
var limit = {};
......
values: []
}
dropdown.children().each(function (){
dropdown.children().each(function ()
{
limit.values.push($(this).val())
});
......
// reload it (already with new option)
reload_element('#'+$(dropdown).attr('id'), url, limit);
dropdown.trigger("addOption", data.id);
dropdown.trigger('addOption', data.id);
dropdown.trigger("change");
dropdown.trigger('change');
// set new option as selected
dropdown.val(data.id);
//console.log(dropdown.children());
dropdown.trigger("change");
dropdown.trigger('change');
}
else
{
......
});
// dialog with help
$('.help_hint').live("click", function ()
$('.help_hint').live('click', function ()
{
var title = $(this).attr('title');
......
});
}
});
/* AJAX fulltext search ***************************************************/
// set up for password checker
$.validator.passwordRating.messages = {
'too-short': '<?php echo __('Too short') ?>',
'very-weak': '<?php echo __('Very weak') ?>',
'weak': '<?php echo __('Weak') ?>',
'good': '<?php echo __('Good') ?>',
'strong': '<?php echo __('Strong') ?>'
}
var r_get = null;
// validate all form
$('.form').validate();
// jQuery tabs
$('#tabs, .tabs').tabs();
// activate date picker on class .date after focus
$('.date').live('focus', function ()
{
$(this).datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
onClose: function(dateText, inst)
{
$(this).trigger('keyup');
}
});
});
// show menu in mobile browsers (default state of menu is hide)
$('#a_show_menu').click(function ()
{
$('#menu').toggle();
$(this).hide();
return false;
});
// gave focus to focus classed objects
$('.focus').focus();
/* AJAX fulltext search */
// function for delay during search
var delay = (function()
{
......
$('#keyword').trigger('keypress');
});
/* Input helpers */
// fix MAC values in inputs
$('.mac, .mac_address').live('keyup', function ()
{
$(this).val(str_replace('-', ':', $(this).val()));
});
/* Multiple dropdown functionality ****************************************/
$('.group-button').click(function (){
var items = '.' + $(this).parent().parent().attr('id') + '-items';
if ($(items).is(':visible'))
{
$(items).hide();
var img = 'add';
var title = '<?php echo __('Show form items') ?>';
}
else
{
$(items).show();
var img = 'minus';
var title = '<?php echo __('Hide form items') ?>';
}
$(this).attr('src', '<?php echo url::base() ?>media/images/icons/ico_'+img+'.gif');
$(this).attr('title', title);
$(this).parent().toggleClass('disable');
});
/**
* @var Variable of values of dropdown
* @see dropdown_update_values
* @see update_select_multiple
*/
var select_multiple = new Array();
$('form').submit(function ()
{
$('form').children('.form').children().children(':hidden').children().children('input, select, textarea').remove();
});
values = new Array();
/**
* Switch values
*
* @author Michal Kliment
* @see update_select_multiple
*/
function dropdown_update_values(key, value, from, to)
{
for (var i in values[from])
for (var i in select_multiple[from])
{
if (values[from][i]['key'] == key)
delete values[from][i];
if (select_multiple[from][i]['key'] == key)
delete select_multiple[from][i];
}
values[to].push({'key': key, 'value': value});
select_multiple[to].push({'key': key, 'value': value});
}
/**
* AJAX functionality of dividing of select to two parts with swiching
* capability of their values. Used at device admins and engeneers and etc.
*
* @author Michal Kliment
*/
function update_select_multiple()
{
$('select[multiple="multiple"]').not('.v, .left_dropdown, .right_dropdown').each(function ()
......
$('#'+this.id+" option").removeAttr("selected");
values[id] = new Array();
values[id+'_options'] = new Array();
select_multiple[id] = new Array();
select_multiple[id+'_options'] = new Array();
$('#'+id+" option").each(function ()
{
values[id][values[id].length] = {'key': $(this).attr('value'), 'value': $(this).html()};
select_multiple[id][select_multiple[id].length] = {'key': $(this).attr('value'), 'value': $(this).html()};
});
$('#'+id+"_options option").each(function ()
{
values[id+'_options'][values[id+'_options'].length] = {'key': $(this).attr('value'), 'value': $(this).html()};
select_multiple[id+'_options'][select_multiple[id+'_options'].length] = {'key': $(this).attr('value'), 'value': $(this).html()};
});
});
}
// drigger select multiple
update_select_multiple();
/**
* Add option to multiple select and reload element
*
* @author Michal Kliment
*/
function multiple_select_add_option(select_id, new_option_id)
{
var limit = {
......
reload_element('#'+select_id+'_options', "<?php echo url_lang::base().url_lang::current(0,1) ?>", limit, '#'+select_id);
}
$('select[multiple="multiple"] option').live("dblclick", function ()
$('select[multiple="multiple"] option').live('dblclick', function ()
{
if ($(this).parent().hasClass('right_dropdown'))
{
if ($(this).parent().hasClass('right_dropdown'))
var id = $(this).parent().attr('id');
$('#'+id+'_options').append('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
dropdown_update_values($(this).attr('value'), $(this).text(), id, id+'_options');
}
else
{
var id = str_replace('_options', "", $(this).parent().attr('id'));
$('#'+id).append('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
dropdown_update_values($(this).attr('value'), $(this).text(), id+'_options', id);
}
$(this).remove();
$('.dropdown_button_search').trigger('keyup');
});
$(".dropdown_button").live('click', function ()
{
if ($(this).hasClass('right_dropdown_button'))
{
var id = str_replace('_right_button', '', this.id);
$('#'+id+" option:selected").each(function()
{
var id = $(this).parent().attr('id');
$('#'+id+'_options').append('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
dropdown_update_values($(this).attr('value'), $(this).text(), id, id+'_options');
}
else
$(this).remove();
});
}
else
{
var id = str_replace('_left_button', '', this.id);
$('#'+id+"_options option:selected").each(function()
{
var id = str_replace('_options', "", $(this).parent().attr('id'));
$('#'+id).append('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
dropdown_update_values($(this).attr('value'), $(this).text(), id+'_options', id);
}
$(this).remove();
$('.dropdown_button_search').trigger('keyup');
});
$(".dropdown_button").live('click', function ()
$(this).remove();
});
}
$('.dropdown_button_search').trigger('keyup');
});
$('.dropdown_button_search').live('keyup', function ()
{
var id = str_replace('_button_search', '', this.id);
$('#'+id).html('');
for (var i in select_multiple[id])
{
if ($(this).hasClass('right_dropdown_button'))
if (strtolower(select_multiple[id][i]['value']).search(strtolower($(this).val())) != -1)
{
var id = str_replace('_right_button', '', this.id);
$('#'+id+" option:selected").each(function()
{
$('#'+id+'_options').append('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
dropdown_update_values($(this).attr('value'), $(this).text(), id, id+'_options');
$(this).remove();
});
$('#'+id).append('<option value="'+select_multiple[id][i]['key']+'">'+select_multiple[id][i]['value']+'</option>');
}
else
{
var id = str_replace('_left_button', '', this.id);
$('#'+id+"_options option:selected").each(function()
{
$('#'+id).append('<option value="'+$(this).attr('value')+'">'+$(this).text()+'</option>');
dropdown_update_values($(this).attr('value'), $(this).text(), id+'_options', id);
$(this).remove();
});
}
$('.dropdown_button_search').trigger('keyup');
});
$('.dropdown_button_search').live('keyup', function ()
}
});
$('.dropdown_button_search_clear').live('click', function()
{
var id = str_replace('_clear', '', this.id);
$('#'+id).val('').trigger('keyup');
});
$('form').submit(function()
{
$('form .right_dropdown').each(function ()
{
var id = str_replace("_button_search", "", this.id);
$('#'+id).html("");
for (var i in values[id])
{
if (strtolower(values[id][i]['value']).search(strtolower($(this).val())) != -1)
{
$('#'+id).append('<option value="'+values[id][i]['key']+'">'+values[id][i]['value']+'</option>');
}
}
$('#'+this.id+' option').attr('selected', true);
});
$('.dropdown_button_search_clear').live('click', function()
{
var id = str_replace('_clear', '', this.id);
$('#'+id).val('').trigger('keyup');
});
$('form').submit(function()
{
$('form .right_dropdown').each(function ()
{
$('#'+this.id+" option").attr('selected', true);
});
});
});
/* Form helpers ***********************************************************/
// ip adresses add check due to subnet
$('#ip_address, input.ip_address').live('keyup', function()
{
......
subnet.selectedIndex = 0;
}
}
});
// fix MAC values in inputs
$('.mac, .mac_address').live('keyup', function ()
{
$(this).val(str_replace('-', ':', $(this).val()));
});
// functionality of hiding/showing form group
$('.group-button').live('click', function ()
{
var items = '.' + $(this).parent().parent().attr('id') + '-items';
if ($(items).is(':visible'))
{
$(items).hide();
var img = 'add';
var title = '<?php echo __('Show form items') ?>';
}
else
{
$(items).show();
var img = 'minus';
var title = '<?php echo __('Hide form items') ?>';
}
$(this).attr('src', '<?php echo url::base() ?>media/images/icons/ico_'+img+'.gif');
$(this).attr('title', title);
$(this).parent().toggleClass('disable');
});
// activate date picker on class .date after focus
$('.date').live('focus', function ()
{
$(this).datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
onClose: function(dateText, inst)
{
$(this).trigger('keyup');
}
});
});
/* Validators */
/* Validators *************************************************************/
$.validator.addMethod('ip_address', function(value) {
value = value.replace(new RegExp( "\\n", "g" ),",");
$.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('cidr', function(value) {
$.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]))$/);
if (!result)
return false;
......
return ((ip2long(s[0]) & (0xffffffff<<(32-s[1]) & 0xffffffff)) == ip2long(s[0]));
}, '<?php echo __('Invalid IP address') ?>');
$.validator.addMethod('mac_address', function(value) {
$.validator.addMethod('mac_address', function(value)
{
return (value == '' || value.match(/^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/));
}, '<?php echo __('Invalid MAC address') ?>');
$.validator.addMethod('to_field', function(value) {
$.validator.addMethod('to_field', function(value)
{
return value.match(/^([a-z][a-z0-9]*[_]{0,1}[a-z0-9]+),?[ ]*(([a-z][a-z0-9]*[_]{0,1}[a-z0-9]+),?[ ]*)*$/);
}, '<?php echo __('Invalid value') ?>');
$.validator.addMethod('suffix', function(value) {
$.validator.addMethod('suffix', function(value)
{
return value.match(/^\/([^\/]+\/)*$/);
}, '<?php echo __('suffix has to start with slash character and has to end with slash character') ?>');
$.validator.addMethod('var_sym', function(value) {
$.validator.addMethod('var_sym', function(value)
{
return value.match(/^[0-9]{1,10}$/);
}, '<?php echo __('Bad variable symbol format.') ?>');
$.validator.addMethod('ulogd_active_count', function(value) {
$.validator.addMethod('ulogd_active_count', function(value)
{
return value.match(/^[0-9]+(\.[0-9]+)?%?$/);
}, '<?php echo __('Bad format.') ?>');
$.validator.addMethod('byte_size', function(value) {
$.validator.addMethod('byte_size', function(value)
{
return value.match(/^([0-9]+(\.[0-9]+)?[k|M|G|T]?B)?$/);
}, '<?php echo __('Bad format.') ?>');
$.validator.addMethod('speed_size', function(value) {
$.validator.addMethod('speed_size', function(value)
{
return (value == '' || value.match(/^([0-9]+[k|M|G|T]?)(\/[0-9]+[k|M|G|T]?)?$/i));
}, '<?php echo __('Bad format.') ?>');
$('#grid-label').append(" | <span id='export-grid-button' class='hand'><img src='<?php echo url::base() ?>media/images/icons/grid_action/transfer.png'> <?php echo __('Export')?></span>");
// set up for password checker
$.validator.passwordRating.messages = {
'too-short': '<?php echo __('Too short') ?>',
'very-weak': '<?php echo __('Very weak') ?>',
'weak': '<?php echo __('Weak') ?>',
'good': '<?php echo __('Good') ?>',
'strong': '<?php echo __('Strong') ?>'
}
/* Export dialog **********************************************************
// @TODO missing export/grid controller
// dialog for export
var $export_dialog = $('#export-div').dialog({
autoOpen: false,
title: '<?php echo __('Export') ?>',
modal: true,
position: ['center', 50],
width: 330,
heigth: 30
});
// Export GRID add export button
$('#grid-label').append(' | <span id="export-grid-button" class="hand"><img src="<?php echo url::base() ?>media/images/icons/grid_action/transfer.png" /> <?php echo __('Export')?></span>');
// export GRID button
$('#export-grid-button').click(function()
{
$('#export-form').attr('action', '<?php echo url_lang::base() ?>export/grid');
......
});
});
/* Trigers and other functionality ****************************************/
// asking before delete action
$('.delete_link').live('click', function(e)
{
var confirm = window.confirm('<?php echo __('Do you really want to delete this record') ?>?');
if (!confirm)
e.stopImmediatePropagation();
return confirm;
});
// validate all form
$('.form').validate();
// jQuery tabs
$('#tabs, .tabs').tabs();
// show menu in mobile browsers (default state of menu is hide)
$('#a_show_menu').click(function ()
{
$('#menu').toggle();
$(this).hide();
return false;
});
// gave focus to focus classed objects
$('.focus').focus();
// auto resize for non WYSIWYG textareas
$('textarea').not('.wysiwyg').autoResize();
/* FIX-ME: Commented by Ondřej Fibich at 22.1.2012
......
* <<<< */
<?php if ($this->popup): ?>
/* Pop-up actions */
/* Pop-up actions *********************************************************/
// set size by content
var content_div = $('#content');
......
{
echo $view;
}
?>
freenetis/branches/network/application/views/device_templates/show.php
</tr>
<tr>
<th><?php echo __('Names') ?></th>
<td><?php foreach ($ivals[Iface_Model::TYPE_ETHERNET]['items'] as $item) echo $item['name'] . ', ' ?></td>
<td><?php foreach ($ivals[Iface_Model::TYPE_ETHERNET]['items'] as $item) echo ($item['name']) ? $item['name'] . ', ' : '' ?></td>
</tr>
</table>
......
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('Minimal count') ?></th>
<td><?php echo $ivals[Iface_Model::TYPE_INTERNAL]['min_count'] ?></td>
<th><?php echo __('Count') ?></th>
<td><?php echo $ivals[Iface_Model::TYPE_INTERNAL]['count'] ?></td>
</tr>
<tr>
<th><?php echo __('Maximal count') ?></th>
<td><?php echo $ivals[Iface_Model::TYPE_INTERNAL]['max_count'] ?></td>
</tr>
<tr>
<th><?php echo __('Names') ?></th>
<td><?php foreach ($ivals[Iface_Model::TYPE_INTERNAL]['items'] as $item) echo $item['name'] . ', ' ?></td>
<td><?php foreach ($ivals[Iface_Model::TYPE_INTERNAL]['items'] as $item) echo ($item['name']) ? $item['name'] . ', ' : '' ?></td>
</tr>
</table>

Také k dispozici: Unified diff