diff --git a/ajax.php b/ajax.php new file mode 100644 index 0000000000000000000000000000000000000000..71f9494de657afa8446d2143e4e4d3d5090ca18b --- /dev/null +++ b/ajax.php @@ -0,0 +1,34 @@ +<?php +/********************************************************************* + ajax.php + + Ajax utils for client interface. + + Peter Rotich <peter@osticket.com> + Copyright (c) 2006-2012 osTicket + http://www.osticket.com + + Released under the GNU General Public License WITHOUT ANY WARRANTY. + See LICENSE.TXT for details. + + vim: expandtab sw=4 ts=4 sts=4: +**********************************************************************/ + +function clientLoginPage($msg='Unauthorized') { + Http::response(403,'Must login: '.Format::htmlchars($msg)); + exit; +} + +require('client.inc.php'); + +if(!defined('INCLUDE_DIR')) Http::response(500,'config error'); +require_once INCLUDE_DIR.'/class.dispatcher.php'; +require_once INCLUDE_DIR.'/class.ajax.php'; + +$dispatcher = patterns('', + url('^/config/', patterns('ajax.config.php:ConfigAjaxAPI', + url_get('^client', 'client') + )) +); +print $dispatcher->resolve($_SERVER['PATH_INFO']); +?> diff --git a/include/ajax.config.php b/include/ajax.config.php index 5a60bc45993d3bec56d8ab0283cf4121e800bd9f..feb1eb4b0646f75762c554e73e55b7d7701b9680 100644 --- a/include/ajax.config.php +++ b/include/ajax.config.php @@ -20,14 +20,27 @@ class ConfigAjaxAPI extends AjaxController { //config info UI might need. function scp() { - global $thisstaff, $cfg; + global $cfg; - $config=array('lock_time' => ($cfg->getLockTime()*3600), + $config=array( + 'lock_time' => ($cfg->getLockTime()*3600), 'file_types' => $cfg->getAllowedFileTypes(), 'max_file_size' => (int) $cfg->getMaxFileSize(), 'max_file_uploads'=> (int) $cfg->getStaffMaxFileUploads() ); return $this->json_encode($config); } + + function client() { + global $cfg; + + $config=array( + 'file_types' => $cfg->getAllowedFileTypes(), + 'max_file_size' => (int) $cfg->getMaxFileSize(), + 'max_file_uploads'=> (int) $cfg->getClientMaxFileUploads() + ); + + return $this->json_encode($config); + } } ?> diff --git a/js/osticket.js b/js/osticket.js index a809e6f2f794a0534096c69b2a210428424d703d..4057b04b84a25e0cc7d2e249e17cac5efaa5c9e5 100644 --- a/js/osticket.js +++ b/js/osticket.js @@ -1 +1,55 @@ -//Nothing for now... +/* + osticket.js + Copyright (c) osTicket.com + */ + +$(document).ready(function(){ + + $("input:not(.dp):visible:enabled:first").focus(); + $('table.list tbody tr:odd').addClass('odd'); + + $("form#save :input").change(function() { + var fObj = $(this).closest('form'); + if(!fObj.data('changed')){ + fObj.data('changed', true); + $('input[type=submit]', fObj).css('color', 'red'); + $(window).bind('beforeunload', function(e) { + return 'Are you sure you want to leave? Any changes or info you\'ve entered will be discarded!'; + }); + } + }); + + $("form#save :input[type=reset]").click(function() { + var fObj = $(this).closest('form'); + if(fObj.data('changed')){ + $('input[type=submit]', fObj).removeAttr('style'); + $('label', fObj).removeAttr('style'); + $('label', fObj).removeClass('strike'); + fObj.data('changed', false); + $(window).unbind('beforeunload'); + } + }); + + $('form#save').submit(function() { + $(window).unbind('beforeunload'); + return true; + }); + + /* Get config settings from the backend */ + var $config = null; + $.ajax({ + url: "ajax.php/config/client", + dataType: 'json', + async: false, + success: function (config) { + $config = config; + } + }); + + /* Multifile uploads */ + $('.multifile').multifile({ + container: '.uploads', + max_uploads: ($config && $config.max_file_uploads)?$config.max_file_uploads:1, + file_types: ($config && $config.file_types)?$config.file_types:".*" + }); +});