%%
%% This is file `grayhints.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% grayhints.dtx  (with options: `copyright,package')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% grayhints.sty package,                                %%
%% Copyright (C) 2017--2018                              %%
%%   dpstory@uakron.edu                                  %%
%%                                                       %%
%% This program can redistributed and/or modified under  %%
%% the terms of the LaTeX Project Public License         %%
%% Distributed from CTAN archives in directory           %%
%% macros/latex/base/lppl.txt; either version 1.2 of the %%
%% License, or (at your option) any later version.       %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}[1997/12/01]
\ProvidesPackage{grayhints}
 [2018/11/01 v1.2 grayhints: Create gray hints in text fields]
\DeclareOption{usehyforms}{%
    \def\FormsRequirement{\RequirePackage{insdljs}[2017/03/02]}}
\def\FormsRequirement{\RequirePackage{eforms}[2017/02/27]}
\DeclareOption{usealtadobe}{\PackageWarningNoLine{grayhints}
  {The `usealtadobe' option is now deprecated.\MessageBreak
   The alternate functions are automatically loaded.\MessageBreak
   Please remove this grayhints package option}}
\DeclareOption{nocalcs}{\let\nocalcs\endinput}
\let\nocalcs\relax
\DeclareOption{nodljs}{\let\FormsRequirement\relax
  \let\nodljsend\endinput}
\let\nodljsend\relax
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{insdljs}}
\ProcessOptions
\FormsRequirement
\@ifundefined{jsColor}{\let\eq@YES=y\let\eq@NO=n%
  \InputIfFileExists{eqcolor.def}
  {\PackageInfo{grayhints}{Inputting eqcolor.def from exerquiz}}
  {\PackageError{grayhints}{cannot find eqcolor.def belonging
  to exerquiz}{Refresh your file name database and try again.}}
}{}
\newcommand{\normalGrayColors}[2]{\def\gh@rgi{#1}\def\gh@rgii{#2}%
  \ifx\gh@rgi\@empty\else
    \jsColor\gh@normalcolor{#1}\gh@chkTr@nsparency\fi
  \ifx\gh@rgii\@empty\else\jsColor\gh@graycolor{#2}\m@tchGray\fi}
\def\gh@normalcolor{}\def\gh@graycolor{}
\AtEndOfPackage{\normalGrayColors{color.black}{color.ltGray}}
\definecolor{ltGray}{gray}{0.75}
\definecolor{gray}{gray}{.5}
\definecolor{dkGray}{gray}{.25}
\def\gh@pd@transparent{ltGray}\def\gh@transparent{transparent}
\def\gh@pd@black{black}\def\gh@pd@white{white}
\def\gh@pd@dkGray{dkGray}\def\gh@pd@gray{gray}\def\gh@pd@ltGray{ltGray}
\def\gh@pd@red{red}\def\gh@pd@green{green}\def\gh@pd@blue{blue}
\def\gh@pd@cyan{cyan}\def\gh@pd@magenta{magenta}
\def\gh@pd@yellow{yellow}
\def\m@tchGray{\eq@checkRawJSColor{\gh@graycolor}%
  \ifx\eqpredefineJSCol\eq@NO
    \let\matchGray\@empty
    \expandafter\gh@extr@ctJSModelInfo\gh@graycolor\@nil
    \ifx\@rgi\@empty\else\edef\matchGray{\@rgi}\fi
    \ifx\@rgii\@empty\else\edef\matchGray{\matchGray\space\@rgii}\fi
    \ifx\@rgiii\@empty\else
      \edef\matchGray{\matchGray\space\@rgiii}\fi
    \ifx\@rgiv\@empty\else\edef\matchGray{\matchGray\space\@rgiv}\fi
  \else
    \expandafter\gh@getColorFromPrefined\gh@graycolor\@nil
    \@ifundefined{gh@pd@\pd@color}{%
      \def\gh@graycolor{color.ltGray}\def\pd@color{ltGray}%
      \PackageWarning{grayhints}
        {The color.\pd@color\space is undefined,\MessageBreak
        substituting color.ltGray}}{\ifx\pd@color\gh@transparent
      \def\gh@graycolor{color.ltGray}\def\pd@color{ltGray}%
      \PackageWarning{grayhints}
        {A transparent color is not supported,\MessageBreak
        using color.ltGray instead}\fi
    }%
    \edef\matchGray{\@nameuse{gh@pd@\pd@color}}%
  \fi}
\def\gh@chkTr@nsparency{\eq@checkRawJSColor{\gh@normalcolor}%
    \ifx\eqpredefineJSCol\eq@YES
        \expandafter\gh@getColorFromPrefined\gh@normalcolor\@nil
        \@ifundefined{gh@pd@\pd@color}{\def\gh@normalcolor{color.black}%
            \PackageWarning{grayhints}
            {The color.\pd@color\space is undefined,\MessageBreak
            substituting color.black}}{}%
        \ifx\pd@color\gh@transparent\def\gh@normalcolor{color.black}%
        \PackageWarning{grayhints}
            {A transparent color is not supported,\MessageBreak
            using color.black instead}\fi
    \fi
}
\def\gh@extr@ctJSModelInfo[#1,#2]\@nil{%
  \gh@getspecv@lues#2,,,,\@nil}%
\def\gh@getspecv@lues#1,#2,#3,#4,#5\@nil{%
  \def\@rgi{#1}\def\@rgii{#2}\def\@rgiii{#3}\def\@rgiv{#4}}
\def\gh@getColorFromPrefined color.#1\@nil{\def\pd@color{#1}}
\def\gh@PriorFormat{event.target.savevalue=event.value;\jsR}
\newcommand\FailStringDef{continue editing}
\newcommand\EnterCommitFailDef{event.value=("\FailStringDef");}
\def\EnterCommitFailEvent#1{\def\@rgi{#1}\ifx\@rgi\@empty
  \def\gh@ECFE{\EnterCommitFailDef}\else\def\gh@ECFE{#1}\fi}
\EnterCommitFailEvent{}
\def\CommitSuccessEvent#1{\def\@rgi{#1}\ifx\@rgi\@empty
\let\gh@CSE\jsR\else\def\gh@CSE{\jsR\jsT #1\jsR}\fi}
\let\gh@CSE\jsR
\newcommand\FmtToGray[1]{%
  if(typeof event.target.savevalue=="undefined"){\jsR\jsT
   event.target.savevalue="";\jsR\jsT
   event.target.success=false;\jsR
  }\jsR
  if(typeof event.target.ghBuiltin=="undefined")%
    event.target.ghBuiltin=false;\jsR
  if(!event.target.ghBuiltin)\gh@PriorFormat
  event.target.ghBuildtin=false;\jsR\gh@FmtToGray{#1}}
\def\gh@FmtToGray#1{%
  if(typeof event.target.saverc=="undefined")%
    event.target.saverc=true;\jsR
  if(!event.target.saverc||event.value==""){\jsR\jsT
    if(event.target.savevalue!=""&&%
      !event.target.success){\jsR\jsT\gh@ECFE\jsR\jsT
      if(typeof app.pxceInfo!="undefined")%
        event.target.savevalue="";\jsR\jsT
    } else {\jsR\jsT\jsT
      event.target.success=false;\jsR\jsT\jsT
      event.value=("#1");\jsT\gh@CSE\jsT}\jsR
  } else {\jsR\jsT
      event.target.success=true;\gh@CSE}
}
\newcommand\KeyToGray{%
  if(event.willCommit&&event.value!=""&&!event.rc)\jsR\jsT
   event.target.success=false;\jsR
  event.target.saverc=event.rc;\jsR
  event.rc=true;\jsR
  if(event.willCommit&&event.value=="")%
    event.target.textColor=\gh@graycolor;\jsR
  if(event.willCommit)%
    event.target.savevalue=event.value;
}
\newcommand\CalcToGray{event.target.textColor=%
  (event.value=="")?\gh@graycolor:\gh@normalcolor;}
\newcommand\FocusToBlack{%
  if (typeof event.target.success=="undefined")%
    event.target.success=false;\jsR
  if(event.target.valueAsString==""%
    ||!event.target.success)\jsR\jsT
    event.target.textColor=\gh@normalcolor;
}
\newcommand\BlurToBlack{%
  if (!event.target.success||event.target.valueAsString=="")\jsR\jsT
   this.resetForm(event.target.name);\jsR
  event.target.savevalue="";\jsR
  event.target.textColor=(!event.target.success||%
  event.target.valueAsString=="")?\gh@graycolor:\gh@normalcolor;
}
\def\NumKey{EFNumber_Keystroke}
\def\NumFmt(#1){try{EFNumber_Format(#1)}catch(e){}}
\def\DateKey{EFDate_Keystroke}
\def\DateFmt(#1){%
  AFDate_Format(#1);\jsR
  event.target.ghBuiltin=true;
}
\def\DateKeyEx{EFDate_KeystrokeEx}
\def\DateFmtEx(#1){%
  AFDate_FormatEx(#1);\jsR
  event.target.ghBuiltin=true;
}
\def\PercentKey{EFPercent_Keystroke}
\def\PercentFmt(#1){%
  if(event.value!=""||%
    (typeof event.target.savevalue!="undefined"&&%
      event.target.savevalue!=""))%
    AFPercent_Format(#1);\jsR
  event.target.ghBuiltin=true;
}
\def\TimeKey{EFTime_Keystroke}\def\TimeFmt{EFTime_Format}
\def\TimeFmtEx(#1){try{EFTime_FormatEx(#1)}catch(e){}}
\def\SpecialKey{EFSpecial_Keystroke}
\def\SpecialKeyEx{EFSpecial_KeystrokeEx}
\def\SpecialFmt(#1){try{EFSpecial_Format(#1)}catch(e){}}
\def\RangeValidate{EFRange_Validate}
\def\SimpleCalc{EFSimple_Calculate}
\def\MergeChange{EFMergeChange}
\nodljsend
\begin{insDLJS}{altadbfncs}{gh: Support for Adobe built-in functions}
var EFNumber_Keystroke=AFNumber_Keystroke;
function EFNumber_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFNumber_Format.apply(null,arguments);
}
var EFDate_Keystroke=AFDate_Keystroke;
function EFDate_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFDate_Format.apply(null,arguments);
}
var EFDate_KeystrokeEx=AFDate_KeystrokeEx;
function EFDate_FormatEx(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFDate_FormatEx.apply(null,arguments);
}
var EFPercent_Keystroke=AFPercent_Keystroke;
function EFPercent_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFPercent_Format.apply(null,arguments);
}
var EFTime_Keystroke=AFTime_Keystroke;
function EFTime_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFTime_Format.apply(null,arguments);
}
function EFTime_FormatEx(){
  event.target.savevalue=event.value;
  ghBuiltin=true;
  AFTime_FormatEx.apply(null,arguments);
}
var EFSpecial_Keystroke=AFSpecial_Keystroke;
var EFSpecial_KeystrokeEx=AFSpecial_KeystrokeEx;
function EFSpecial_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFSpecial_Format.apply(null,arguments);
}
var EFRange_Validate=AFRange_Validate;
var EFSimple_Calculate=AFSimple_Calculate;
var EFMergeChange=AFMergeChange;
\end{insDLJS}
\nocalcs
\begin{insDLJS}{ghsupport}{gh: Support for the Calculate Event}
function AllowCalc(cArray) {
  var f,g;
  for (var i=0; i<cArray.length; i++) {
    f=this.getField(cArray[i]);
    g=f.getArray();
    for (var j=0; j<g.length; j++)
      if (g[j].valueAsString!="") return true;
  }
  return false;
}
\end{insDLJS}
\endinput
%%
%% End of file `grayhints.sty'.
