Author: sevein
Date: Wed Apr 25 17:57:45 2012
New Revision: 11524

Log:
More work in advanced search for templating

Modified:
   branches/2.0/apps/qubit/modules/search/templates/_searchFields.php
   branches/2.0/js/dominion.js
   branches/2.0/plugins/qtDominionPlugin/css/less/advancedSearch.less

Modified: branches/2.0/apps/qubit/modules/search/templates/_searchFields.php
==============================================================================
--- branches/2.0/apps/qubit/modules/search/templates/_searchFields.php  Wed Apr 
25 17:56:06 2012        (r11523)
+++ branches/2.0/apps/qubit/modules/search/templates/_searchFields.php  Wed Apr 
25 17:57:45 2012        (r11524)
@@ -1,3 +1,17 @@
+<div>
+  <ul>
+    <li><?php echo __('Find') ?></li>
+    <li>[ Archival descriptions ]</li>
+    <li><?php echo __('in') ?></li>
+    <li>
+      <select id="respository" data-placeholder="Any repository" 
class="chzn-select" tabindex="2">
+        <option value="" selected="selected"><?php echo __('Any repository') 
?></option>
+      </select>
+    </li>
+    <li><?php echo __('that match:') ?></li>
+  </ul>
+</div>
+
 <?php $count = 0 ?>
 
 <?php if (isset($sf_request->searchFields)): ?>
@@ -5,13 +19,22 @@
   <?php foreach ($sf_request->searchFields as $key => $item): ?>
 
     <?php if (empty($item['query'])) continue ?>
-    <?php $count++ ?>
 
     <div class="criteria">
 
+      <div class="boolean form-inline">
+
+        <select name="searchFields[<?php echo $count ?>][operator]">
+          <option value="and"<?php echo $item['operator'] == 'and' ? ' 
selected="selected"' : '' ?>><?php echo __('and') ?></option>
+          <option value="or"<?php echo $item['operator'] == 'or' ? ' 
selected="selected"' : '' ?>><?php echo __('or') ?></option>
+          <option value="not"<?php echo $item['operator'] == 'not' ? ' 
selected="selected"' : '' ?>><?php echo __('not') ?></option>
+        </select>
+
+      </div>
+
       <div class="criterion form-inline">
 
-        <input type="text" name="searchFields[<?php echo $key ?>][query]" 
value="<?php echo esc_entities($item['query']) ?>"/>
+        <input type="text" class="span6" placeholder="<?php echo __('Search') 
?>" name="searchFields[<?php echo $key ?>][query]" value="<?php echo 
esc_entities($item['query']) ?>"/>
 
         <span><?php echo __('in') ?></span>
 
@@ -30,27 +53,29 @@
 
       </div>
 
-      <div class="boolean form-inline">
-
-        <select name="searchFields[<?php echo $count ?>][operator]">
-          <option value="and"<?php echo $item['operator'] == 'and' ? ' 
selected="selected"' : '' ?>><?php echo __('and') ?></option>
-          <option value="or"<?php echo $item['operator'] == 'or' ? ' 
selected="selected"' : '' ?>><?php echo __('or') ?></option>
-          <option value="not"<?php echo $item['operator'] == 'not' ? ' 
selected="selected"' : '' ?>><?php echo __('not') ?></option>
-        </select>
-
-      </div>
-
     </div>
 
+    <?php $count++ ?>
+
   <?php endforeach; ?>
 
 <?php endif; ?>
 
 <div class="criteria">
 
+  <div class="boolean form-inline">
+
+    <select name="searchFields[<?php echo $count ?>][operator]">
+      <option value="and"><?php echo __('and') ?></option>
+      <option value="or"><?php echo __('or') ?></option>
+      <option value="not"><?php echo __('not') ?></option>
+    </select>
+
+  </div>
+
   <div class="criterion form-inline">
 
-    <input type="text" class="input-xlarge" name="searchFields[<?php echo 
$count?>][query]"/>
+    <input type="text" class="span6" placeholder="<?php echo __('Search') ?>" 
name="searchFields[<?php echo $count?>][query]"/>
 
     <span><?php echo __('in') ?></span>
 
@@ -69,14 +94,11 @@
 
   </div>
 
-  <div class="boolean form-inline">
+</div>
 
-    <select name="searchFields[<?php echo $count ?>][operator]">
-      <option value="and"><?php echo __('and') ?></option>
-      <option value="or"><?php echo __('or') ?></option>
-      <option value="not"><?php echo __('not') ?></option>
-    </select>
+<div id="actions">
 
-  </div>
+  <button id="add-criteria" class="gray btn-large"><?php echo __('Add search 
filter') ?></button>
+  <button type="submit" class="gray btn-large"><?php echo __('Search') 
?></button>
 
 </div>

Modified: branches/2.0/js/dominion.js
==============================================================================
--- branches/2.0/js/dominion.js Wed Apr 25 17:56:06 2012        (r11523)
+++ branches/2.0/js/dominion.js Wed Apr 25 17:57:45 2012        (r11524)
@@ -442,31 +442,74 @@
   var AdvancedSearch = function (element)
     {
       this.$element = $(element);
-      this.$content = this.$element.find('#content');
-      this.$criteria = this.$element.find('.criteria');
 
-      this.init();
+      this.$element.find('.criteria:first .boolean').hide();
+
+      this.listen();
     };
 
   AdvancedSearch.prototype = {
 
     constructor: AdvancedSearch,
 
-    init: function()
+    listen: function()
     {
-      this.$element.find('.add-criteria > a')
-        .on('click', $.proxy(this.addCriteria, this));
+      this.$element.on('click', $.proxy(this.click, this));
     },
 
-    addCriteria: function (event)
+    click: function (event)
     {
-      event.preventDefault();
+      var $target = $(event.target);
 
-      var h = this.$criteria.eq(0).height();
+      switch ($target.attr('id'))
+      {
+        case 'add-criteria':
+          event.preventDefault();
+          this.addCriteria();
+          break;
+      }
+    },
 
-      this.$content.animate({ height: '+=' + h }, 200);
-    }
+    addCriteria: function ()
+    {
+      this
+        .cloneLastCriteria()
+        .insertAfter(this.getLastCriteria())
+        .find('input, select').first().focus();
+    },
+
+    getLastCriteria: function()
+    {
+      return this.$element.find('.criteria:last');
+    },
+
+    cloneLastCriteria: function()
+    {
+      var $clone = this.getLastCriteria().clone();
+
+      var nextNumber = 
parseInt($clone.find('input:first').attr('name').match(/\d+/).shift()) + 1;
+
+      $clone
+        .find('input, select').each(function()
+          {
+            var $this = $(this);
+            $this.attr('name', $this.attr('name').replace(/\[\d+\]/, '[' + 
nextNumber +']'));
+          }).end()
+        .find('.boolean').show();
 
+      return this.resetFormFields($clone);
+    },
+
+    resetFormFields: function($sender)
+    {
+      return $sender
+        .find('input:text, input:password, input:file, select')
+          .val('')
+          .end()
+        .find('input:radio, input:checkbox')
+          .removeAttr('checked').removeAttr('selected')
+          .end();
+    }
   };
 
   $(function ()

Modified: branches/2.0/plugins/qtDominionPlugin/css/less/advancedSearch.less
==============================================================================
--- branches/2.0/plugins/qtDominionPlugin/css/less/advancedSearch.less  Wed Apr 
25 17:56:06 2012        (r11523)
+++ branches/2.0/plugins/qtDominionPlugin/css/less/advancedSearch.less  Wed Apr 
25 17:57:45 2012        (r11524)
@@ -19,26 +19,26 @@
 
   #content {
 
-    position: relative;
+    overflow: auto;
 
   }
 
   #add-criteria {
 
-    position: absolute;
-
   }
 
-  .nav {
+  ul {
 
     font-size: 18px;
     .clearfix();
     margin: 20px;
 
-    li.n {
+    li {
 
+      display: inline-block;
       float: left;
       margin-right: 8px;
+      line-height: 28px;
 
     }
 

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to