diff options
Diffstat (limited to 'modules/organize')
| -rw-r--r-- | modules/organize/css/organize.css | 6 | ||||
| -rw-r--r-- | modules/organize/js/organize.js | 141 | ||||
| -rw-r--r-- | modules/organize/views/organize.html.php | 25 | ||||
| -rw-r--r-- | modules/organize/views/organize_button_pane.html.php | 75 | ||||
| -rw-r--r-- | modules/organize/views/organize_edit.html.php | 10 | 
5 files changed, 166 insertions, 91 deletions
| diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index cef25f1c..0fdf5aef 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -170,12 +170,18 @@    width: 15px;  } +#gOrganizeEditHandleButtonsMiddle,  #gOrganizeEditHandleButtonsLeft {    float: left;    height: 20px;    padding: 2px 10px;  } +#gOrganizeEditHandleButtonsMiddle { +  margin-left: 20px; +} + +#gOrganizeEditHandleButtonsMiddle a,  #gOrganizeEditHandleButtonsLeft a {    float: left;    margin: 0 2.5px; diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 538e366d..30b3f8b6 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -150,9 +150,7 @@ var selectable = {      setDrawerButtonState();    },    stop: function(event, ui) { -    if ($("#gMicroThumbGrid li.ui-selected").length > 0) { -      getEditForm(); -    } +    getEditForm();    }  }; @@ -197,11 +195,21 @@ function drawerHandleButtonsClick(event) {      var operation = $(this).attr("ref");      switch (operation) {      case "edit": +    case "close":        $("#gOrganizeEditDrawerPanel").animate(          {"height": "toggle", "display": "block"},          {duration: "fast",           complete: function() {             setSelectedThumbs(); +           if (operation == "close") { +             $("#gOrganizeEditHandleButtonsLeft a[ref='edit']").css("display", "inline-block"); +             $("#gOrganizeEditHandleButtonsLeft a[ref='close']").css("display", "none"); +             $("#gOrganizeEditHandleButtonsMiddle a").css("display", "none"); +           } else { +             $("#gOrganizeEditHandleButtonsLeft a[ref='edit']").css("display", "none"); +             $("#gOrganizeEditHandleButtonsLeft a[ref='close']").css("display", "inline-block"); +             $("#gOrganizeEditHandleButtonsMiddle a").css("display", "inline-block"); +           }           },           step: function() {             $("#gMicroThumbPanel").height(heightMicroThumbPanel - $(this).height()); @@ -209,22 +217,59 @@ function drawerHandleButtonsClick(event) {        });        break;      case "select-all": -      $(".gMicroThumbContainer").addClass("ui-selected"); +      $("#gMicroThumbGrid li").addClass("ui-selected");        $("#gMicroThumbSelectAll").hide();        $("#gMicroThumbUnselectAll").show(); +      setDrawerButtonState(); +      getEditForm();        break;      case "unselect-all": -      $(".gMicroThumbContainer").removeClass("ui-selected"); +      $("#gMicroThumbGrid li").removeClass("ui-selected");        $("#gMicroThumbSelectAll").show();        $("#gMicroThumbUnselectAll").hide(); +      setDrawerButtonState();        break; -    case "close": +    case "done":        $("#gDialog").dialog("close");        break; +    case "submit": +      var currentTab = $("#gOrganizeEditForm").tabs("option", "selected"); +      var form = $("#pane-"+currentTab+" form"); +      var url = $(form).attr("action") +        .replace("__FUNCTION__", $(form).attr("ref")); +      $.ajax({ +        data: $(form).serialize(), +        dataType: "json", +        success: function (data, textStatus) { +          if (data.task) { +            // @todo if task is sent then create a progress bar and run the task +          } else { +            $("#pane-"+currentTab).children("form").replaceWith(data.form); +            if (data.message) { +              $("#pane-"+currentTab + " form").before("<div class=\"gSuccess\">" + data.message +"</div>"); +            } +         } +        }, +        type: "POST", +        url: url +      }); +      break; +    case "reset": +      currentTab = $("#gOrganizeEditForm").tabs("option", "selected"); +      form = $("#pane-"+currentTab+" form"); +      $.ajax({ +        data: serializeItemIds("#gMicroThumbPanel li.ui-selected"), +        dataType: "html", +        success: function (data, textStatus) { +          $("#pane-"+currentTab + " form").replaceWith(data); +        }, +        type: "GET", +        url: $(form).attr("action").replace("__FUNCTION__", "reset_" + $(form).attr("ref")) +      }); +      break;      default: -      var postData = serializeItemIds("#gMicroThumbPanel li.ui-selected");        $.ajax({ -        data: postData, +        data: serializeItemIds("#gMicroThumbPanel li.ui-selected"),          dataType: "json",          success: operationCallback,          type: "POST", @@ -408,25 +453,22 @@ function get_url(uri, parms) {  function setDrawerButtonState() {    $("#gOrganizeFormThumbStack").empty();    $("#gOrganizeEditForm").empty(); -  switch ($("#gMicroThumbGrid li.ui-selected").length) { -  case 0: +  var selectedCount = $("#gMicroThumbGrid li.ui-selected").length; +  if (selectedCount) { +    $("#gOrganizeEditHandleButtonsLeft a").removeAttr("disabled"); +    $("#gOrganizeEditHandleButtonsLeft a").removeClass("ui-state-disabled"); + +    if (selectedCount > 1) { +      $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").attr("disabled", true); +      $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").addClass("ui-state-disabled"); +    } +    setSelectedThumbs(); +  } else {      if ($("#gOrganizeEditDrawerPanel::visible").length) { -      $("#gOrganizeEditHandleButtonsLeft a[ref='edit']").trigger("click"); +      $("#gOrganizeEditHandleButtonsLeft a[ref='close']").trigger("click");      }      $("#gOrganizeEditHandleButtonsLeft a").attr("disabled", true);      $("#gOrganizeEditHandleButtonsLeft a").addClass("ui-state-disabled"); -    break; -  case 1: -    $("#gOrganizeEditHandleButtonsLeft a").removeAttr("disabled"); -    $("#gOrganizeEditHandleButtonsLeft a").removeClass("ui-state-disabled"); -    setSelectedThumbs(); -//    getEditForm(); -   break; -  default: -    $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").attr("disabled", true); -    $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").addClass("ui-state-disabled"); -    setSelectedThumbs(); -//    getEditForm();    }  } @@ -456,17 +498,25 @@ function setSelectedThumbs() {  }  function getEditForm() { -  var postData = ""; -  $("li.ui-selected").each(function(i) { -    postData += "&item[]=" + $(this).attr("ref"); -  }); -  var url_data = get_url("organize/editForm", {}) + postData; -  $.get(url_data, function(data, textStatus) { +  if ($("#gMicroThumbGrid li.ui-selected").length > 0) { +    var postData = serializeItemIds("li.ui-selected"); +    var url_data = get_url("organize/editForm", {}) + postData; +    $.get(url_data, function(data, textStatus) { +      $("#gOrganizeEditForm").tabs("destroy"); +      $("#gOrganizeEditForm").html(data); +      if ($("#gOrganizeEditForm ul li").length) { +        $("#gOrganizeEditForm").tabs(); +        $("#gOrganizeEditHandleButtonsMiddle a").removeAttr("disabled"); +        $("#gOrganizeEditHandleButtonsMiddle a").removeClass("ui-state-disabled"); +      } else { +        $("#gOrganizeEditHandleButtonsMiddle a").attr("disabled", true); +        $("#gOrganizeEditHandleButtonsMiddle a").addClass("ui-state-disabled"); +      } +    }); +  } else {      $("#gOrganizeEditForm").tabs("destroy"); -    //$("#gOrganizeEditForm").empty(); -    $("#gOrganizeEditForm").html(data); -    $("#gOrganizeEditForm").tabs(); -  }); +    $("#gOrganizeEditForm").empty(); +  }  }  function serializeItemIds(selector) { @@ -478,6 +528,16 @@ function serializeItemIds(selector) {    return postData;  } +function submitCurrentForm(event) { +  console.log("submitCurrentForm"); +  return false; +} + +function resetCurrentForm(event) { +  console.log("resetCurrentForm"); +  return false; +} +  function createProgressDialog(title) {    $("body").append("<div id='gOrganizeProgressDialog'>" +        "<div class='gProgressBar'></div>" + @@ -548,12 +608,13 @@ function getViewportSize() {  function displayAjaxError(error) {    $("body").append("<div id=\"gAjaxError\" title=\"" + FATAL_ERROR + "\">" + error + "</div>"); +    $("#gAjaxError").dialog({ -      autoOpen: true, -      autoResize: false, -      modal: true, -      resizable: true, -      width: 610, -      height: $("#gDialog").height() -    }); +    autoOpen: true, +    autoResize: false, +    modal: true, +    resizable: true, +    width: 610, +    height: $("#gDialog").height() +  });  } diff --git a/modules/organize/views/organize.html.php b/modules/organize/views/organize.html.php index 60c4a524..b1f062a1 100644 --- a/modules/organize/views/organize.html.php +++ b/modules/organize/views/organize.html.php @@ -36,25 +36,18 @@             ref="<?= url::site("organize/content/__ITEM_ID__?width=__WIDTH__&height=__HEIGHT__&offset=__OFFSET__") ?>">          <ul id="gMicroThumbGrid"></ul>        </div> -        <div id="gOrganizeEditDrawer" class="yui-u"> -          <div id="gOrganizeEditDrawerPanel" class="yui-gf"> -            <div id="gOrganizeFormThumbs" class="yui-u first"> -              <ul id="gOrganizeFormThumbStack" /> -            </div> -            <div id="gOrganizeEditForm"> -            </div> +      <div id="gOrganizeEditDrawer" class="yui-u"> +        <div id="gOrganizeEditDrawerPanel" class="yui-gf"> +          <div id="gOrganizeFormThumbs" class="yui-u first"> +            <ul id="gOrganizeFormThumbStack" />            </div> -          <div id="gOrganizeEditDrawerHandle"> -            <div id="gOrganizeEditHandleButtonsLeft"> -              <?= $button_pane ?> -            </div> -            <div id="gOrganizeEditHandleButtonsRight"> -              <a id="gMicroThumbSelectAll" href="#" ref="select-all" class="gButtonLink ui-corner-all ui-state-default"><?= t("Select all") ?></a> -              <a id="gMicroThumbUnselectAll" href="#" ref="unselect-all" style="display: none" class="gButtonLink ui-corner-all ui-state-default"><?= t("Deselect all") ?></a> -              <a id="gMicroThumbDone" href="#" ref="close" class="gButtonLink ui-corner-all ui-state-default"><?= t("Done") ?></a> -            </div> +          <div id="gOrganizeEditForm">            </div>          </div> +        <div id="gOrganizeEditDrawerHandle"> +          <?= $button_pane ?> +        </div> +      </div>      </div>    </div>  </div> diff --git a/modules/organize/views/organize_button_pane.html.php b/modules/organize/views/organize_button_pane.html.php index 9902eafb..cd780d5e 100644 --- a/modules/organize/views/organize_button_pane.html.php +++ b/modules/organize/views/organize_button_pane.html.php @@ -1,39 +1,50 @@  <?php defined("SYSPATH") or die("No direct script access.") ?> +<div id="gOrganizeEditHandleButtonsLeft"> +  <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="edit" +     disabled="1" title="<?= t("Open Drawer") ?>"> +    <span class="ui-icon ui-icon-arrowthickstop-1-n"><?= t("Open Drawer") ?></span> +  </a> -<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="edit" -  disabled="1" title="<?= t("Edit Selection") ?>"> -  <span class="ui-icon ui-icon-pencil"> -    <?= t("Edit Selection") ?> -  </span> -</a> +  <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="close" +     disabled="1" title="<?= t("Close Drawer") ?>" style="display: none"> +    <span class="ui-icon ui-icon-arrowthickstop-1-s"><?= t("Close Drawer") ?></span> +  </a> -<? if (graphics::can("rotate")): ?> -<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCcw" -  disabled="1" title="<?= t("Rotate 90 degrees counter clockwise") ?>"> -  <span class="ui-icon ui-icon-rotate-ccw"> -    <?= t("Rotate 90 degrees counter clockwise") ?> -  </span> -</a> +  <? if (graphics::can("rotate")): ?> +  <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCcw" +     disabled="1" title="<?= t("Rotate 90 degrees counter clockwise") ?>"> +    <span class="ui-icon ui-icon-rotate-ccw"><?= t("Rotate 90 degrees counter clockwise") ?></span> +  </a> -<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCw" -  disabled="1" title="<?= t("Rotate 90 degrees clockwise") ?>"> -  <span class="ui-icon ui-icon-rotate-cw"> -    <?= t("Rotate 90 degrees clockwise") ?> -  </span> -</a> -<? endif ?> +  <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCw" +     disabled="1" title="<?= t("Rotate 90 degrees clockwise") ?>"> +    <span class="ui-icon ui-icon-rotate-cw"> <?= t("Rotate 90 degrees clockwise") ?></span> +  </a> +  <? endif ?> -<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="albumCover" -   disabled="1" title="<?= t("Choose this photo as the album cover") ?>"> -  <span class="ui-icon ui-icon-star"> -    <?= t("Choose this photo as the album cover") ?> -  </span> -</a> +  <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="albumCover" +     disabled="1" title="<?= t("Choose this photo as the album cover") ?>"> +    <span class="ui-icon ui-icon-star"><?= t("Choose this photo as the album cover") ?></span> +  </a> -<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="delete" -   disabled="1" title="<?= t("Delete selection") ?>"> -  <span class="ui-icon ui-icon-trash"> -    <?= t("Delete selection") ?> -  </span> -</a> +  <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="delete" +     disabled="1" title="<?= t("Delete selection") ?>"> +    <span class="ui-icon ui-icon-trash"><?= t("Delete selection") ?></span> +  </a> +</div> +<div id="gOrganizeEditHandleButtonsMiddle"> +  <a class="gButtonLink ui-corner-all ui-state-default" href="#" ref="submit" +     title="<?= t("Apply Changes") ?>" style="display: none" > +    <span class="ui-icon ui-icon-check"><?= t("Apply Changes") ?></span> +  </a> +  <a class="gButtonLink ui-corner-all ui-state-default" href="#" ref="reset" +     title="<?= t("Reset Form") ?>" style="display: none" > +    <span class="ui-icon ui-icon-closethick"><?= t("Reset Form") ?></span> +  </a> +</div> +<div id="gOrganizeEditHandleButtonsRight"> +  <a id="gMicroThumbSelectAll" href="#" ref="select-all" class="gButtonLink ui-corner-all ui-state-default"><?= t("Select all") ?></a> +  <a id="gMicroThumbUnselectAll" href="#" ref="unselect-all" style="display: none" class="gButtonLink ui-corner-all ui-state-default"><?= t("Deselect all") ?></a> +  <a id="gMicroThumbDone" href="#" ref="done" class="gButtonLink ui-corner-all ui-state-default"><?= t("Done") ?></a> +</div> diff --git a/modules/organize/views/organize_edit.html.php b/modules/organize/views/organize_edit.html.php index c0fc43e5..1adf290f 100644 --- a/modules/organize/views/organize_edit.html.php +++ b/modules/organize/views/organize_edit.html.php @@ -5,6 +5,10 @@  <? endforeach?>  </ul> -<? foreach ($panes as $idx => $pane): ?> -  <div id="pane-<?= $idx ?>" class="gOrganizeEditPane"><?= $pane["content"] ?></div> -<? endforeach?> +<? if (count($panes) > 0): ?> +  <? foreach ($panes as $idx => $pane): ?> +    <div id="pane-<?= $idx ?>" class="gOrganizeEditPane ui-tabs-hide"><?= $pane["content"] ?></div> +  <? endforeach?> +<? else: ?> +<div class="gWarning"><?= t("No Edit pages apply to the selected items") ?></div> +<? endif ?>
\ No newline at end of file | 
