Changeset 324 for branches

Show
Ignore:
Timestamp:
02/24/06 16:34:11 (3 years ago)
Author:
anti
Message:

experimental collection adding using ajax

Location:
branches/ajax_editing/trunk
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/ajax_editing/trunk/admin/js/plogger.js

    r318 r324  
    5656        new Ajax.Request('plog-thumb.php', {method: 'get', onComplete: onImportThumbComplete, parameters: 'img=' + importThumbs[importThumbCounter]}); 
    5757}; 
     58 
     59function addItemForm() { 
     60        Element.hide('add_item_link'); 
     61        Element.show('add_item_form'); 
     62        Form.focusFirstElement('add_form'); 
     63} 
     64 
     65function addItemLink() { 
     66        Element.show('add_item_link'); 
     67        Element.hide('add_item_form'); 
     68        Element.hide('rpc_message'); 
     69 
     70} 
     71 
     72function submitAddForm() { 
     73        // I need to clear the form. 
     74        new Ajax.Request('plog-rpc.php', { 
     75                        method: 'post', 
     76                        onComplete: onAddComplete, 
     77                        postBody: Form.serialize('add_form')}); 
     78} 
     79 
     80function onAddComplete(request) { 
     81        Element.update('rsv',request.responseText); 
     82        reloadManager(); 
     83        // I need to know whether I got an error or not. 
     84        // if there was an error, then I need to keep the form. 
     85        // otherwise I have to hide it. 
     86        // here I should trigger the reload of collection list. 
     87} 
     88 
     89function reloadManager() { 
     90        new Ajax.Updater('mgrtable','plog-rpc.php', { 
     91                        method: 'post', 
     92                        postBody: 'action=list-collections&page=' + $F('plog_page')}); 
     93        //alert('reloading page ' + $F('plog_page')); 
     94 
     95} 
  • branches/ajax_editing/trunk/admin/plog-admin-functions.php

    r316 r324  
    44require_once($config['basedir'] . "/plog-functions.php"); 
    55require_once($config['basedir'] . "/lib/exifer1_5/exif.php"); 
    6  
    76function get_files($directory) { 
    87        // Try to open the directory 
     
    895894// so plugis could add new fields to all those forms. 
    896895function plog_add_collection_form() { 
    897         $output = '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; 
    898         $output .= '<div class="box-3"><h2 class="add">Create a Collection: </h2><label for="name">Name </label><br/><input name="name" id="name"> 
    899          <br/><label for="description">Description </label><br/><input name="description" id="description" size="50"> 
    900          <input name="action" type="hidden" value="add-collection"> 
    901          <input class="submit" type="submit" value="Add Collection"> 
    902          </div></form>'; 
     896        global $plog_page; 
     897        $output = ""; 
     898        $output .= '<div id="rsv"></div><div id="add_container"><div id="add_item_link" class="add_item"><h2 class="add"><a href="javascript:addItemForm();">Create a Collection &raquo;</a></h2></div>'; 
     899        $output .= '<div id="add_item_form" class="box-3" style="display: none;"><form action="'.$_SERVER["PHP_SELF"].'" id="add_form" method="post" onsubmit="submitAddForm();return false;">'; 
     900        $output .= '<h2 class="add">Create a Collection: </h2><label for="name">Name </label><br/><input name="name" id="name"> 
     901         <br/><label for="description">Description </label><br/><input name="description" id="description" size="50"/><br/> 
     902         <input name="action" type="hidden" value="add-collection"/> 
     903         <!--<input class="submit" type="submit" value="Add Collection"/>--> 
     904        <input type="hidden" id="plog_page" value="' . $plog_page  .'"/> 
     905        <input type="button" class="submit" value="Add Collection" onclick="submitAddForm();"/> 
     906     <input class="submit" type="button" value="Cancel" onClick="addItemLink();"/> 
     907         </form></div></div>'; 
    903908         return $output; 
    904909} 
     
    11141119} 
    11151120 
    1116 function plog_collection_manager($from,$limit) { 
     1121function plog_collection_manager($page,$limit) { 
     1122        $from = ($page - 1) * $_SESSION['entries_per_page']; 
     1123        if ($from < 0) { 
     1124                $from = 0; 
     1125        }; 
     1126 
    11171127        $output = '<table style="width: 100%" cellpadding="4"> 
    11181128                <col style="width: 15px;"/><tr class="header"><td></td>'; 
  • branches/ajax_editing/trunk/admin/plog-manage.php

    r317 r324  
    275275} 
    276276 
     277 
     278$plog_page = isset($_REQUEST['plog_page']) ? $_REQUEST['plog_page'] : 1; 
     279$first_item = ($plog_page - 1) * $_SESSION['entries_per_page']; 
     280if ($first_item < 0) { 
     281        $first_item = 0; 
     282}; 
     283 
    277284// here we will generate a "add collection/album" header 
    278285if ($level == "collections") { 
     
    307314$url = "?entries_per_page=$_SESSION[entries_per_page]&amp;level=$_REQUEST[level]&amp;id=$id"; 
    308315 
    309 $plog_page = isset($_REQUEST['plog_page']) ? $_REQUEST['plog_page'] : 0; 
    310 $first_item = ($plog_page - 1) * $_SESSION['entries_per_page']; 
    311 if ($first_item < 0) { 
    312         $first_item = 0; 
    313 }; 
     316 
    314317$limit = "LIMIT $first_item, $_SESSION[entries_per_page]"; 
    315318 
     
    328331if (empty($level)) { 
    329332        $output .= generate_breadcrumb_admin(""); 
    330         $output .= plog_collection_manager($first_item,$_SESSION['entries_per_page']); 
    331 }; 
     333        $output .= "<div id='mgrtable'>"; 
     334        $output .= plog_collection_manager($plog_page,$_SESSION['entries_per_page']); 
     335        $output .= "</div>"; 
     336};       
     337 
     338 
    332339 
    333340if ($level == "albums") { 
  • branches/ajax_editing/trunk/css/admin.css

    r312 r324  
    318318} 
    319319 
     320.add_item { 
     321    margin: 15px; 
     322    border: 1px solid #488F62; 
     323    padding: 10px; 
     324    padding-left: 20px; 
     325    padding-bottom: 2px; 
     326    margin-bottom: 0px; 
     327    background-color: #BEDEBE; 
     328    padding-top: 0; 
     329    width: 300px; 
     330    margin-left: 0; 
     331} 
     332 
    320333.box-3 
    321334{