/**
*qdPM
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@qdPM.net so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade qdPM to newer
* versions in the future. If you wish to customize qdPM for your
* needs please refer to http://www.qdPM.net for more information.
*
* @copyright Copyright (c) 2009 Sergey Kharchishin and Kym Romanets (http://www.qdpm.net)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
var is_mobile = navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i);
function qdpm_app_init()
{
$('.datepicker').datepicker({
rtl: App.isRTL(),
autoclose: true,
format: 'yyyy-mm-dd',
});
$(".datetimepicker").datetimepicker({
autoclose: true,
isRTL: App.isRTL(),
format: "yyyy-mm-dd hh:ii",
pickerPosition: (App.isRTL() ? "bottom-right" : "bottom-left")
});
$.fn.modal.defaults.spinner = $.fn.modalmanager.defaults.spinner =
'
<\/div>/g,'
'), {format:false,allowedTags:["strong","big","b","i","u","strike","hr","div","br","p","ol","ul","li","blockquote","font","img","pre","table","td","th","tr","h1","h2","h3","h4","h5","h6","sub","sup"]});
$('#'+id).html(html);
setCursorEndOfContenteditable(document.getElementById(id))
}
function check_user_form(form_id,url)
{
$('#loading').html(I18NText('Loading...'));
email = $('#users_email').val();
$.ajax({type: "POST",url: url,data: {email:email},success: function(data) {
$('#loading').html('');
if(data==1)
{
$('#email_error').html('
'+I18NText('Email already exists')+'
'+I18NText('You can\'t create user with email:')+' "'+email+'"'+'
');
}
else
{
$('#email_error').html('');
$('#'+form_id).submit();
}
}});
}
function set_tickets_types_by_departmetn_id(department_id)
{
if($('#form_tickets_types_id'))
{
default_tickets_types_id = $('#form_tickets_types_id').val();
}
else
{
default_tickets_types_id = $('#default_tickets_types_id').val();
}
if(department_id>0)
{
if(departments_tickets_types[department_id])
{
if(departments_tickets_types[department_id].length>0)
{
types_id_list = departments_tickets_types[department_id].split(',');
tickets_options = document.getElementById('tickets_tickets_types_id');
tickets_options.options.length = 0;
for(i=0;i
0)
{
$('#'+container).load(url,{projects_id:projects_id},
function(response, status, xhr) {
if (status == "success") {
jQuery(window).resize();
}
}
);
}
else
{
$('#'+container).html('');
}
}
function load_form_by_report_type(container,url,report_type)
{
$('#'+container).html(I18NText('Loading...'));
$('#'+container).load(url,{report_type:report_type},
function(response, status, xhr) {
if (status == "success") {
jQuery(window).resize();
}
}
);
}
function userPattern(id,field_id)
{
name = $('#pattern_name_'+id).val();
desc = $('#pattern_desc_'+id).val();
if(desc.length>0)
{
$('#'+field_id).val($('#'+field_id+'_nicEditor').html()+desc+'
')
$('#'+field_id+'_nicEditor').focus().html($('#'+field_id+'_nicEditor').html()+desc+'
');
}
else
{
$('#'+field_id).val($('#'+field_id+'_nicEditor').html()+name+'
')
$('#'+field_id+'_nicEditor').focus().html($('#'+field_id+'_nicEditor').html()+name+'
');
}
setCursorEndOfContenteditable(document.getElementById(field_id+'_nicEditor'))
}
function setCursorEndOfContenteditable(contentEditableElement)
{
var range,selection;
if(document.createRange)//Firefox, Chrome, Opera, Safari, IE 9+
{
range = document.createRange();//Create a range (a range is a like the selection but invisible)
range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range
range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
selection = window.getSelection();//get the selection object (allows you to change selection)
selection.removeAllRanges();//remove any selections already made
selection.addRange(range);//make the range you have just created the visible selection
}
else if(document.selection)//IE 8 and lower
{
range = document.body.createTextRange();//Create a range (a range is a like the selection but invisible)
range.moveToElementText(contentEditableElement);//Select the entire contents of the element with the range
range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
range.select();//Select the range (make it the visible selection
}
}
function set_off_extra_fields_list()
{
if($('#extra_fields_list').css('display')=='none')
{
$('#extra_fields_list').css('display','block');
}
else
{
$('#extra_fields_list').css('display','none');
}
}
function expand_dashboard_report(report,url)
{
if($('#'+report).css('display')=='block')
{
$.ajax({type: "POST",url: url,data: {report:report,type:'hide'}});
}
else
{
$.ajax({type: "POST",url: url,data: {report:report,type:'show'}});
}
}
function check_event_repeat_type(type)
{
if(type=='weekly')
{
$('#events_repeat_days_tr').css('display','');
}
else
{
$('#events_repeat_days_tr').css('display','none');
}
}
function time_report_export(form_id, type)
{
$('#format','#'+form_id).val(type);
$('#'+form_id).submit();
return false;
}
function removeRelated(hide_id,url)
{
if(confirm(I18NText('Ary you sure?')))
{
$('#'+hide_id).fadeOut();
$.ajax({type: "POST",url: url});
}
}
function copyToRelated(form_name,type,url_copy, url_preview)
{
if(type=='name')
{
$('#'+form_name+'_name').val($('#item_name').val());
}
if(type=='description')
{
field_id =form_name+'_description';
CKEDITOR_holders[field_id].insertHtml($('#item_description').val());
}
if(type=='attachments')
{
$.ajax({type: "POST",
url: url_copy,
data: {attachments:$('#item_attachments').val()},
success: function(data) {
$("#attachmentsList").load(url_preview);
}
});
}
}
function show_original_text(id,v)
{
$(id).val(v);
if($(id+'_nicEditor'))
{
$(id+'_nicEditor').html(v);
}
}
function SelectTextInElement(element)
{
var doc = document;
var text = document.getElementById(element);
if (doc.body.createTextRange) { // ms
var range = doc.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if (window.getSelection) { // moz, opera, webkit
var selection = window.getSelection();
var range = doc.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}
}