From: vincent@cubedesigners.com Date: Mon, 4 Feb 2013 11:36:02 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c36dbca0293cbb19cb031c03e1e0e41931582c48;p=cubeextranet.git --- diff --git a/images/extranet/loader.gif b/images/extranet/loader.gif new file mode 100644 index 000000000..70bdc92a0 Binary files /dev/null and b/images/extranet/loader.gif differ diff --git a/images/ws/loader.gif b/images/ws/loader.gif new file mode 100644 index 000000000..70bdc92a0 Binary files /dev/null and b/images/ws/loader.gif differ diff --git a/inc/commons/class.common.ajax.php b/inc/commons/class.common.ajax.php index 8fb73cc99..4db036e23 100644 --- a/inc/commons/class.common.ajax.php +++ b/inc/commons/class.common.ajax.php @@ -21,6 +21,7 @@ class commonAjax { $res .= $extra; $res .= ''; $res .= commonPage::bf(); + if (!$return) { echo $res; exit; diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index cfcc6119d..b6d4eca48 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -385,6 +385,7 @@ class commonCore extends cubeCore { $db->books->dir_external('varchar', 256, false); $db->books->lucene_time('integer', 0, false); $db->books->demo_counter('integer', 0, false); + $db->books->exportdatas('text', 0, false); // Clés $db->books->primary('pk_books', 'book_id'); $db->books->index('index_books_nom', 'BTREE', 'nom'); diff --git a/inc/commons/class.common.page.php b/inc/commons/class.common.page.php index 7f2eb9a8b..5483c3c1c 100644 --- a/inc/commons/class.common.page.php +++ b/inc/commons/class.common.page.php @@ -41,13 +41,13 @@ class commonPage { public static function search($args) { global $core; - if(!isset($args[0])){ + if (!isset($args[0])) { return; } if (!commonDroits::recherche($args[0])) { return; } - + cubePage::emptyfield(); $settings = $core->user->getSettings($args[0]); $action = 'search' . ucfirst($args[0]); @@ -82,24 +82,24 @@ class commonPage { foreach ($onglets as $titre => $url) { // Si cet onglet correspond à la page active, on le place actif - $active =isset($args[0]) && ($args[0] == $url || (isset($supp[$args[0]]) && $supp[$args[0]] == $url)) ? ' active' : ''; + $active = isset($args[0]) && ($args[0] == $url || (isset($supp[$args[0]]) && $supp[$args[0]] == $url)) ? ' active' : ''; $res .= '' . $titre . ''; } $res .= ''; return $res; } - public static function barre($filtres = null, $action = null, $dashboard = null, $shortcuts = null,$big=false) { + public static function barre($filtres = null, $action = null, $dashboard = null, $shortcuts = null, $big = false) { if (is_null($shortcuts) && is_null($filtres)) { return '
'; } - - $class=''; - if($big){ - $class=' class="big"'; + + $class = ''; + if ($big) { + $class = ' class="big"'; } - $res = '
'; + $res = '
'; $res .= '
'; if (!is_null($shortcuts)) { @@ -186,11 +186,16 @@ class commonPage { public static function footer() { $res = ''; $res .= cubePage::googleAnalytics(GA); + $res.='
'; + $res.='
'; + $res.= cubeMedia::image(IMG . '/loader.gif', 32, 32, __('Chargement')); + $res.='

' . __('Chargement en cours. Veuillez patienter ...') . '

'; + $res.='
'; + $res.='
'; $res .= ''; $res .= ''; return $res; } } - ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 9d47c5858..639d14c81 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -209,16 +209,6 @@ class wsAjax extends cubeAjax { $book = $dao->setStatus($book_id, 1); } - if ($version == 'v2') { - $version = 'html'; - } else if ($version == 'online') { - if ($book->parametres->version == '1') { - $version = 'v1'; - } elseif ($book->parametres->version == '2') { - $version = 'html'; - } - } - if (!wsDroits::admin()) { if ($book->status < 1) { $popup = commonAjax::form('downbook/' . $book_id . '/' . $version, __('Téléchargement du Fluidbook'), wsUrl::valideDownload($book_id, $version), __('Télécharger'), 2, '', '', true); @@ -228,8 +218,8 @@ class wsAjax extends cubeAjax { } } - $url = wsPackager::package($book_id, $version); - $x->addRedirection($url); + $exporter = new wsExporter(); + $exporter->export($book_id, $x, 'download', $version); } public static function instbook($args, &$x) { @@ -248,8 +238,6 @@ class wsAjax extends cubeAjax { $x->addOpenPopup($popup); return; } - - fb(time(), 'start making package'); $version = 'html'; if ($book->parametres->version == 1) { $version = 'v1'; @@ -266,7 +254,6 @@ class wsAjax extends cubeAjax { $package = wsPackager::package($book_id, $version, false); } - fb(time(), 'start transfert'); if ($server == 'references') { $root = '/home/fluidbook/www/references'; $url = 'http://www.fluidbook.com/references/'; @@ -325,11 +312,6 @@ class wsAjax extends cubeAjax { $cp->setArg(null, $package . '*'); $cp->setArg(null, $finalDir); $cp->execute(); - - fb($cp->commande); - fb($cp->output); - - fb(time(), 'end transfert'); } elseif ($protocol == 'ftp') { $u = parse_url($root . ltrim($dir, '/')); @@ -352,8 +334,6 @@ class wsAjax extends cubeAjax { $lftp->setArg('e', implode(';', $commandes)); $lftp->setArg(null, $u['host']); $lftp->execute(); - fb($lftp->commande); - fb($lftp->output); } $x->addClosePopup(); @@ -946,6 +926,112 @@ class wsAjax extends cubeAjax { $x->addReload(); } + public static function exportbook($args, &$x) { + if (isset($_POST['action'])) { + $x->addChangePopup(commonAjax::form('exportbookExe', __("Exporter une publication"), self::formExportBook($_POST['book_id']), '', 2, '', '', true)); + return; + } + commonAjax::form('exportbookExe', __("Exporter une publication"), self::formExportBook($args[1]), '', 2); + } + + public static function exportbookExe($args, &$x) { + $exporter = new wsExporter(); + $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $_POST['destination']); + + $x->addClosePopup(); + } + + public static function formExportBook($book_id) { + global $core; + $choices = array(__('Télécharger') => 'download', + __("Installer sur le serveur d'hébergement") => 'install_hosting', + __("Installer sur l'espace de références") => 'install_references', + __('Installer sur un serveur distant') => 'install_ftp', + __('Envoyer vers un projet Phonegap Android') => 'phonegap_android', + __('Envoyer vers un projet Phonegap iOS') => 'phonegap_ios' + ); + + $formatInstall = array('online' => false, + 'v1' => false, + 'html' => false, + 'v2' => false, + 'win-exe' => 'zip', + 'win-ins' => 'exe', + 'mac-exe' => 'zip', + 'win-cd' => 'zip', + 'phonegap' => 'zip'); + + $defaultVersion = isset($_POST['version']) ? $_POST['version'] : 'online'; + $version = '' . __('Version') . '' . form::combo('version', wsUrl::getFluidbookVersions(true), $defaultVersion) . ''; + + $defaultAction = isset($_POST['action']) ? $_POST['action'] : 'download'; + $res = '' . __('Action') . '' . form::combo('action', $choices, $defaultAction) . form::hidden('book_id', $book_id) . ''; + + $ae = explode('_', $defaultAction, 2); + if ($ae[0] == 'phonegap') { + $version = ''; + $defaultVersion = ''; + } + + if ($defaultAction != 'download') { + $daoBook = new wsDAOBook($core->con); + $book = $daoBook->selectById($book_id); + if ($book->exportdatas == '') { + $datas = array(); + } else { + $datas = json_decode($book->exportdatas, true); + } + + $res.=$version; + + if (!isset($datas[$defaultAction][$defaultVersion])) { + $datas[$defaultAction][$defaultVersion] = array('dir' => '', 'file' => ''); + } + $defaultDestination = $datas[$defaultAction][$defaultVersion]; + if ($defaultDestination == '' && isset($_POST['destination']) && $_POST['changed'] != 'version' && $_POST['changed'] != 'action') { + $defaultDestination = $_POST['destination']; + } + + if ($defaultDestination['dir'] == '' && ($defaultAction == 'install_hosting' || $defaultAction == 'install_references')) { + $defaultDestination['dir'] = cubeText::str2URL($book->nom); + } + + + switch ($defaultAction) { + case 'install_hosting': + $s = __("Serveur d'hébergement") . ' /'; + break; + case 'install_references': + $s = __('Espace des références') . ' /'; + break; + case 'install_ftp': + $s = __('Serveur FTP externe') . ' : ftp://'; + break; + case 'phonegap_android': + $s = __("Projet Phonegap Android") . ' /'; + break; + case 'phonegap_ios': + $s = __("Projet Phonegap iOS") . ' /'; + break; + default: + break; + } + + $destinationFile = ''; + if ($displayFile) { + $destinationFile = form::field(array('destination[file]', 'destination'), 30, 128, $defaultDestination['file']); + } + + $res .= '' . $s . '' . form::field(array('destination[dir]', 'destination'), 40, 128, $defaultDestination['dir']) . ' / ' . $destinationFile . ''; + } else { + $res.=$version; + } + + $res .= '' . form::hidden('changed', '') . '' . $core->typo->BoutonOK(__('Exporter')) . ''; + + return $res; + } + } ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index fe2a8b264..25f65d022 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -147,7 +147,11 @@ class wsUrl { } $res .= '' . $btStats . ''; if ($book->version > 1) { - $res .= '' . $btDownload . ''; + if ($core->user->utilisateur_id == 5) { + $res .= '' . $btDownload . ''; + } else { + $res .= '' . $btDownload . ''; + } } else { $res.=''; } @@ -171,13 +175,13 @@ class wsUrl { return $res; } - public static function contextBookDownload($id, $droits) { - global $core; + public static function getFluidbookVersions($select = false) { + $droits = wsDroits::getDroits(); $chooseVersion = wsDroits::admin(); if ($chooseVersion) { - $default = ' (' . __('Default') . ')'; + $default = ' - ' . __('Version par défaut'); } else { $default = ''; } @@ -196,6 +200,33 @@ class wsUrl { $versions['phonegap'] = array('title' => __('Version offline') . ' - ' . __('Application mobile'), 'icon' => cubeMedia::image(IMG . '/phonegap.png')); } + if (!$select) { + return $versions; + } + + $res = array(); + foreach ($versions as $id => $d) { + $t = explode('-', $d['title'], 2); + $meta = trim($t[0]); + if (isset($t[1])) { + $title = trim($t[1]); + } else { + $title = $meta; + } + + if (!isset($res[$meta])) { + $res[$meta] = array(); + } + $res[$meta][$title] = $id; + } + return $res; + } + + public static function contextBookDownload($id, $droits) { + global $core; + + $versions = self::getFluidbookVersions(); + $res = '
'; $res .= '
    '; $res .= '
  • ' . __("Sélectionnez une version") . '
  • '; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 1543068d8..9f1dd5e78 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -48,6 +48,7 @@ class wsDAOBook extends commonDAO { $book->dir_phonegap_android = $r->dir_phonegap_android; $book->dir_external = $r->dir_external; $book->demo_counter = $r->demo_counter; + $book->exportdatas = $r->exportdatas; return $book; } @@ -82,13 +83,19 @@ class wsDAOBook extends commonDAO { return $r->book_id + 1; } + public function saveExportDatas($book_id, $datas) { + $c = $this->con->openCursor('books'); + $c->exportdatas = json_encode($datas); + $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + } + public function addDemoCount($book_id) { $r = $this->con->select('SELECT demo_counter,nom FROM books WHERE book_id=\'' . $book_id . '\''); $m = 20; if ($r->demo_counter > 0 && $r->demo_counter % $m == 0) { $mail = new cubeMail(); - $mail->charset='UTF-8'; + $mail->charset = 'UTF-8'; $mail->from = 'contact@fluidbook.com'; $mail->to = 'tech@fluidbook.com'; $mail->subject = '[Fluidbook Workshop] Fluidbook consulté via l\'url publique'; @@ -1028,7 +1035,7 @@ class wsDAOBook extends commonDAO { $hash .= 'kjgl!az4.'; $hash .= count($pages); $hash .= round($size[0], 4); - + $hash = sha1($hash); $this->makeTextsIndexes($book, $pages, $index, $textes); diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index c052162f5..909d4977c 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -38,6 +38,7 @@ class wsBook extends cubeMetier { protected $dir_phonegap_android; protected $dir_external; protected $demo_counter; + protected $exportdatas; public function __get($varname) { if (!property_exists($this, $varname)) { diff --git a/inc/ws/Util/_common.php b/inc/ws/Util/_common.php index eb6cca453..78d7cbb5e 100644 --- a/inc/ws/Util/_common.php +++ b/inc/ws/Util/_common.php @@ -16,4 +16,5 @@ $__autoload['wsPDFFontExtractor'] = dirname(__FILE__) . '/fontextractor/class.ws $__autoload['wsPDFFont'] = dirname(__FILE__) . '/fontextractor/class.ws.pdf.font.php'; $__autoload['wsSVN'] = dirname(__FILE__) . '/class.ws.svn.php'; $__autoload['wsLinks'] = dirname(__FILE__) . '/class.ws.links.php'; +$__autoload['wsExporter'] = dirname(__FILE__) . '/class.ws.exporter.php'; ?> \ No newline at end of file diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php new file mode 100644 index 000000000..8264af572 --- /dev/null +++ b/inc/ws/Util/class.ws.exporter.php @@ -0,0 +1,228 @@ +origVersion = $version; + $this->origAction = $action; + + $this->book_id = $book_id; + $this->x = $x; + + $this->dao = new wsDAOBook($core->con); + $this->book = $this->dao->selectById($this->book_id); + + $this->action = $action; + $e = explode('_', $this->action, 2); + $this->metaAction = $e[0]; + if (count($e) > 1) { + $this->action = $e[1]; + } + + $this->version = $this->_getVersion($version); + $this->destinationDir = ltrim(trim($destinationDir), '/'); + $this->destinationFile = str_replace('/', '-', trim($destinationFile)); + + $this->_saveDestination(); + + if ($this->metaAction == 'download') { + $this->_download(); + } else if ($this->metaAction == 'phonegap') { + $this->_phonegap(); + } else if ($this->metaAction == 'install') { + $this->_install(); + } + } + + protected function _haveToZip() { + $yes = array('win-exe', 'mac-exe'); + return in_array($this->version, $yes); + } + + protected function _install() { + $package = wsPackager::package($this->book_id, $this->version, $this->_haveToZip()); + + if ($this->action == 'references') { + $root = '/home/fluidbook/www/references/'; + $rootURL = 'http://www.fluidbook.com/references/'; + } else if ($this->action == 'hosting') { + $root = '/home/fluidbook/hosting/'; + $rootURL = 'http://hosting.fluidbook.com/'; + } else if ($this->action == 'ftp') { + $root = 'ftp://'; + $rootURL = null; + } + + if ($this->destinationFile) { + $pathd = $root . $this->destinationDir; + $path = $pathd . '/' . $this->destinationFile; + } else { + $path = $root . $this->destinationDir; + } + + if (stristr($path, 'ftp://')) { + $this->_lftp($package, $path, true); + } else { + $this->_rsync($package, $path); + } + + if (!is_null($rootURL)) { + $url = $rootURL . $this->destinationDir; + $this->x->addTruePopup($url . '/'); + } + } + + protected function _phonegap() { + $os = $this->action; + + if ($this->destinationDir == '') { + return; + } + + $packager = new wsPackagerPhonegap($this->book_id, null, true, false, $os); + $package = $packager->makePackage(false); + + $this->_transfertPhonegap($os, $package, $this->destinationDir); + } + + protected function _transfertPhonegap($os, $package, $destination) { + if ($os == 'android') { + $this->_lftp($package, 'ftp://android:DlSa1LGw@paris.cubedesigners.com:22122/' . $destination, false, true); + } else if ($os == 'ios') { + $this->_rsync($package, '/mnt/macbook/Phonegap/Projects/' . $destination, true); + } + } + + protected function _lftp($src, $dest, $passive = true, $erase = false) { + $u = parse_url($dest); + + $file = is_file($src); + if ($file) { + $e = explode('/', $u['path']); + $u['file'] = array_pop($e); + $u['dir'] = implode('/', $e); + } else { + $u['dir'] = $u['path']; + } + + $passive = $passive ? 'on' : 'off'; + + if (!isset($u['port'])) { + $u['port'] = '21'; + } + + $commandes = array( + 'set ftp:passive-mode ' . $passive, + 'mkdir -p ' . $u['dir'] + ); + + if ($file) { + $commandes[] = 'put -O ' . $u['dir'] . ' ' . $src . ' -o ' . $u['file']; + } else { + $commandes[] = 'lcd ' . $src; + $commandes[] = 'cd ' . $u['dir']; + if ($erase) { + $commandes[] = 'mirror -Rve --parallel=5'; + } else { + $commandes[] = 'mirror -Rv --parallel=5'; + } + } + + $lftp = new cubeCommandLine('lftp'); + $lftp->setArg('u', $u['user'] . ',' . $u['pass']); + $lftp->setArg('p', $u['port']); + $lftp->setArg('e', implode(';', $commandes)); + $lftp->setArg(null, $u['host']); + $lftp->execute(); + } + + protected function _rsync($src, $dest, $erase = false) { + if (!file_exists($dest)) { + mkdir($dest, 0777, true); + } + + if (is_file($src)) { + copy($src, $dest); + return; + } + + if ($erase) { + /** --del -r -z -v * */ + $cp = new cubeCommandLine('rsync'); + $cp->setPath(CONVERTER_PATH); + $cp->setArg('del'); + } + $cp->setArg('t'); + $cp->setArg('r'); + $cp->setArg('z'); + $cp->setArg('v'); + $cp->setArg(null, $src . '*'); + $cp->setArg(null, $dest); + $cp->execute(); + } + + protected function _download() { + $this->x->addRedirection(wsPackager::package($this->book_id, $this->version)); + } + + protected function _getVersion($version) { + if ($version == 'v2') { + return 'html'; + } else if ($version == 'online') { + if ($this->book->parametres->version == '1') { + return 'v1'; + } elseif ($this->book->parametres->version == '2') { + return 'html'; + } + } + return $version; + } + + protected function _saveDestination() { + $datas = $this->book->exportdatas; + if ($datas == '') { + $datas = array(); + } else { + $datas = json_decode($datas, true); + } + if (!isset($datas[$this->origAction])) { + $datas[$this->origAction] = array(); + } + + $d = array(); + if ($this->destinationDir) { + $d['dir'] = $this->destinationDir; + } + if ($this->destinationFile) { + $d['file'] = $this->destinationFile; + } + + $datas[$this->origAction][$this->origVersion] = $d; + + $this->dao->saveExportDatas($this->book_id, $datas); + } + +} + +?> diff --git a/js/common.js b/js/common.js index a7a6107a2..9fafe7fc2 100644 --- a/js/common.js +++ b/js/common.js @@ -1,180 +1,214 @@ -TO_LOAD[TO_LOAD.length]='load_common_extranet();'; -FIRST_LOAD=true; +TO_LOAD[TO_LOAD.length] = 'load_common_extranet();'; +FIRST_LOAD = true; +var DEFAULT_WAIT_MESSAGE = ""; -function load_common_extranet(){ - var viewportWidth=1030; - if($("#main.big").length>0){ +function load_common_extranet() { + DEFAULT_WAIT_MESSAGE = $("#ajaxLoader .c p").text(); + + var viewportWidth = 1030; + if ($("#main.big").length > 0) { $("#header").addClass('big'); - viewportWidth=1250; + viewportWidth = 1250; } - - var is=screen.width/viewportWidth; - $('meta[name="viewport"]').attr('content','width='+viewportWidth+'px,initial-scale='+is+',maximum-scale:2.0'); - - if($(".dashboard").length>=1 && $("#dash").length>=1){ + + var is = screen.width / viewportWidth; + $('meta[name="viewport"]').attr('content', 'width=' + viewportWidth + 'px,initial-scale=' + is + ',maximum-scale:2.0'); + + if ($(".dashboard").length >= 1 && $("#dash").length >= 1) { $("#dash").sortable('destroy'); - if(FIRST_LOAD){ - FIRST_LOAD=false; - }else{ - FIRST_LOAD=true; + if (FIRST_LOAD) { + FIRST_LOAD = false; + } else { + FIRST_LOAD = true; $.ajax({ - url : SITE_PATH+'ajax/reloadDashboards', - success : function(data){ + url: SITE_PATH + 'ajax/reloadDashboards', + success: function(data) { MyAjax(data); } }); } $("#dash").sortable({ - opacity : 0.6, - axis : "y", - handle : ".caption", - stop : function(e,ui){ + opacity: 0.6, + axis: "y", + handle: ".caption", + stop: function(e, ui) { $.ajax({ - url : SITE_PATH+'ajax/orderDashboards?'+$("#dash").sortable('serialize') + url: SITE_PATH + 'ajax/orderDashboards?' + $("#dash").sortable('serialize') }); resize(); } }); } - $(".timereport_field").change(function(){ - var val=parseInt($(this).val()); - if(isNaN(val)){ - val=0; + $(".timereport_field").change(function() { + var val = parseInt($(this).val()); + if (isNaN(val)) { + val = 0; } - var f=this; - var id=$(this).attr('id'); - var a=id.split('_'); + var f = this; + var id = $(this).attr('id'); + var a = id.split('_'); $.ajax({ - url : SITE_PATH+'ajax/saveTimereport/'+a[1]+'/'+a[2]+'/'+val, - success : function(data){ - FIRST_LOAD=true; + url: SITE_PATH + 'ajax/saveTimereport/' + a[1] + '/' + a[2] + '/' + val, + success: function(data) { + FIRST_LOAD = true; MyAjax(data); - var td=$(f).parents('td').get(0); - if(parseFloat($(f).val())>0){ + var td = $(f).parents('td').get(0); + if (parseFloat($(f).val()) > 0) { $(td).addClass('filled'); - }else{ + } else { $(td).removeClass('filled'); } } }); }); - $("#dash .toggle").click(function(){ - var rel=$(this).attr('rel'); - var div=$(this).parents('.dashboard').get(0); - var liste=$(div).find('.liste'); + $("#dash .toggle").click(function() { + var rel = $(this).attr('rel'); + var div = $(this).parents('.dashboard').get(0); + var liste = $(div).find('.liste'); - $(liste).slideToggle('fast',function(){ + $(liste).slideToggle('fast', function() { resize(); }); $(this).toggleClass('close'); $.ajax({ - url : SITE_PATH+'ajax/toggleDashboard/'+rel + url: SITE_PATH + 'ajax/toggleDashboard/' + rel }); return false; }); - $(".filtre .bt").click(function(){ - var ul=$(this).parent().parent().children('ul'); + $(".filtre .bt").click(function() { + var ul = $(this).parent().parent().children('ul'); $(ul).slideToggle('fast'); return false; }); - $(".filtre ul").click(function(e){ - if(e.target.nodeName=='INPUT' || e.target.nodeName=='LABEL'){ + $(".filtre ul").click(function(e) { + if (e.target.nodeName == 'INPUT' || e.target.nodeName == 'LABEL') { return true; } $(this).slideToggle('fast'); }); - $(".filtre span").click(function(){ - var ul=$(this).parent().children('ul'); + $(".filtre span").click(function() { + var ul = $(this).parent().children('ul'); $(ul).slideToggle('fast'); }); - $(".filtre input").change(function(){ - var form=$(this).parents('form').get(0); - var uls=$(form).find("ul"); - var divs=$(form).find(".input"); - var spans=$(form).find("span"); - var i,j,k,ul,lis,li,input,label,checked,div,titre,t,t1,allc,inputs; - for(i=0;i20){ - t1=t.substr(0,16)+'...'; - }else{ - t1=t; + } else { + t = titre.join(', '); + if (t.length > 20) { + t1 = t.substr(0, 16) + '...'; + } else { + t1 = t; } $(div).find('span').text(t1); - $(div).find('a').attr('title',t); + $(div).find('a').attr('title', t); $(div).addClass('active'); } } return true; }); - $(window).resize(function(){ + $(window).resize(function() { resize(); }); resize(); } -function resize(){ - var allh=$("#header").height()+$("#footer").height()+$("#bar").height()+$("#main .content").height()+13+30; - var h=Math.max($(window).height(),allh); +function resize() { + var allh = $("#header").height() + $("#footer").height() + $("#bar").height() + $("#main .content").height() + 13 + 30; + var h = Math.max($(window).height(), allh); - var mh=h-$("#header").height()-$("#footer").height()-$("#bar").height()-30-13; - mh=Math.max(mh,450); - $("#main").css('height',mh); + var mh = h - $("#header").height() - $("#footer").height() - $("#bar").height() - 30 - 13; + mh = Math.max(mh, 450); + $("#main").css('height', mh); } -function refreshFiles(){ +function refreshFiles() { $.ajax({ - url : SITE_PATH+'ajax/refreshFichiers', - success : function(data){ + url: SITE_PATH + 'ajax/refreshFichiers', + success: function(data) { MyAjax(data); } }); } -function findWSAdmin(li){ - var p=li.selectValue.split(' - '); - if(p.length<=1){ +function findWSAdmin(li) { + var p = li.selectValue.split(' - '); + if (p.length <= 1) { return; } - var user_id=parseInt(p[0]); + var user_id = parseInt(p[0]); $("#ws_admin").val(user_id); +} + +function resizeLoader() { + $("#ajaxLoader").css('height', $(window).height()); + $("#ajaxLoader").css('width', $(window).width()); +} + +function displayLoader(message) { + if (message != undefined) { + $("#ajaxLoader .c p").html(message); + } + + resizeLoader(); + $("#ajaxLoader").show(); + var h = $("#ajaxLoader .c").outerHeight(); + $("#ajaxLoader").css('top', -h); + $("#ajaxLoader").animate({ + top: 0 + }, 400); +} + +function hideLoader() { + resizeLoader(); + + var h = $("#ajaxLoader .c").outerHeight(); + $("#ajaxLoader").animate({ + top: -h + }, 400, null, function() { + $(this).hide(); + $("#ajaxLoader .c p").html(DEFAULT_WAIT_MESSAGE); + }); } \ No newline at end of file diff --git a/js/ws.js b/js/ws.js index ebb157af4..e11bb4271 100644 --- a/js/ws.js +++ b/js/ws.js @@ -1,41 +1,50 @@ -TO_LOAD[TO_LOAD.length]='load_ws();'; -FIRST_LOAD=true; +TO_LOAD[TO_LOAD.length] = 'load_ws();'; +TO_LOAD_ONCE[TO_LOAD_ONCE.length] = 'load_ws_once();'; +FIRST_LOAD = true; -function load_ws(){ - if($("#book_nom").length){ - $("#book_nom").autocomplete(SITE_PATH+'autocomplete/book',{ - cacheLength : 0, - maxItemsToShow : 15, - onFindValue : findBook, - onItemSelect : findBook +function load_ws_once() { + $('form[action="exportbook"] select, form[action="exportbookExe"] select').live('change', function() { + var form = $(this).parents('form'); + $(form).find('#changed').val($(this).attr('name')); + $(form).attr('action', 'exportbook').submit().attr('action', 'exportbookExe'); + }); +} + +function load_ws() { + if ($("#book_nom").length) { + $("#book_nom").autocomplete(SITE_PATH + 'autocomplete/book', { + cacheLength: 0, + maxItemsToShow: 15, + onFindValue: findBook, + onItemSelect: findBook }); } - if($("#book_proprietaire").length){ - $("#book_proprietaire").autocomplete(SITE_PATH+'autocomplete/wsuser',{ - cacheLength : 0, - maxItemsToShow : 15, - onFindValue : findProprietaire, - onItemSelect : findProprietaire + if ($("#book_proprietaire").length) { + $("#book_proprietaire").autocomplete(SITE_PATH + 'autocomplete/wsuser', { + cacheLength: 0, + maxItemsToShow: 15, + onFindValue: findProprietaire, + onItemSelect: findProprietaire }); } - if($("#ws_admin_nom").length>0){ - $("#ws_admin_nom").autocomplete(SITE_PATH+'autocomplete/wsadmin',{ - cacheLength:0, - maxItemsToShow:15, - onFindValue:findWSAdmin, - onItemSelect:findWSAdmin + if ($("#ws_admin_nom").length > 0) { + $("#ws_admin_nom").autocomplete(SITE_PATH + 'autocomplete/wsadmin', { + cacheLength: 0, + maxItemsToShow: 15, + onFindValue: findWSAdmin, + onItemSelect: findWSAdmin }); } - - $("#importLinksAsExcel,#offsetLinks").submit(function(){ + + $("#importLinksAsExcel,#offsetLinks").submit(function() { $(this).ajaxSubmit({ - url : SITE_PATH+'ajax/'+$(this).attr('action'), - success : function(data){ + url: SITE_PATH + 'ajax/' + $(this).attr('action'), + success: function(data) { window.opener.document.getElementById("composerSwf").reloadLinks(); - window.close(); + window.close(); } }); return false; @@ -43,21 +52,23 @@ function load_ws(){ + + $(".restoreLink").click(restoreLink); - - $(".hide_new_value").change(function(){ - if($(this).val()==0){ + + $(".hide_new_value").change(function() { + if ($(this).val() == 0) { $(".new").show(); - }else{ + } else { $(".new").hide(); } }); } -function restoreLink(){ +function restoreLink() { $.ajax({ - url : SITE_PATH+'ajax/restoreLinksVersion/'+$(this).attr('rel'), - success : function(data){ + url: SITE_PATH + 'ajax/restoreLinksVersion/' + $(this).attr('rel'), + success: function(data) { window.opener.document.getElementById("composerSwf").reloadLinks(); window.close(); } @@ -65,20 +76,20 @@ function restoreLink(){ return false; } -function findProprietaire(li){ - var p=li.selectValue.split(' - '); - if(p.length<=1){ +function findProprietaire(li) { + var p = li.selectValue.split(' - '); + if (p.length <= 1) { return; } - var user_id=parseInt(p[0]); + var user_id = parseInt(p[0]); $("#proprietaire").val(user_id); } -function findBook(li){ - var book=li.selectValue.split(' - '); - if(book.length<=1){ +function findBook(li) { + var book = li.selectValue.split(' - '); + if (book.length <= 1) { return; } - var book_id=parseInt(book[0]); + var book_id = parseInt(book[0]); $("#book").val(book_id); } \ No newline at end of file diff --git a/style/common.css b/style/common.css index 807bf3458..bc7f4ae42 100644 --- a/style/common.css +++ b/style/common.css @@ -15,9 +15,9 @@ select{ font-family: 'UniversCondensedBold'; src: url('univers-condensedbold-webfont.eot'); src: url('univers-condensedbold-webfont.eot?#iefix') format('embedded-opentype'), - url('univers-condensedbold-webfont.woff') format('woff'), - url('univers-condensedbold-webfont.ttf') format('truetype'), - url('univers-condensedbold-webfont.svg#UniversCondensedBold') format('svg'); + url('univers-condensedbold-webfont.woff') format('woff'), + url('univers-condensedbold-webfont.ttf') format('truetype'), + url('univers-condensedbold-webfont.svg#UniversCondensedBold') format('svg'); font-weight: normal; font-style: normal; } @@ -87,5 +87,43 @@ select{ .onglet.active, .onglet:hover{ background-position:bottom left; - + +} + +#ajaxLoader{ + position:fixed; + display:none; + top:0px; + left:0px; + width:100%; + height:100%; + z-index: 10000000; +} + +#ajaxLoader .c{ + background:#fff; + font-size:16px; + padding:20px; + width:300px; + height:50px; + margin:0 auto; + border-radius: 0 0 10px 10px; + box-shadow: 0px 0px 10px rgba(0,0,0,0.5); + -moz-box-shadow: 0px 0px 10px rgba(0,0,0,0.5); + -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,0.5); + -ms-box-shadow: 0px 0px 10px rgba(0,0,0,0.5); + -o-box-shadow: 0px 0px 10px rgba(0,0,0,0.5); +} + +#ajaxLoader .c img{ + vertical-align: middle; + display: block; + float:left; +} + +#ajaxLoader .c p{ + width:240px; + float:left; + margin-left:20px; + text-align: center; } \ No newline at end of file diff --git a/style/extranet/style.css b/style/extranet/style.css index 413ee08b9..33fbf2d33 100644 --- a/style/extranet/style.css +++ b/style/extranet/style.css @@ -372,7 +372,7 @@ input[type="text"],input[type="password"],input[type="email"],input[type="search } .ac_results iframe{ -display:none; + display:none; } /* Traduction */ @@ -393,4 +393,8 @@ display:none; #urlDecoder textarea{ width:100%; +} + +#ajaxLoader{ + color:#333333; } \ No newline at end of file