Skip to content

Instantly share code, notes, and snippets.

@ChrisMBarr
Last active May 29, 2018 20:12
Show Gist options
  • Select an option

  • Save ChrisMBarr/22fec2cdf0199976a12c to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMBarr/22fec2cdf0199976a12c to your computer and use it in GitHub Desktop.

Revisions

  1. ChrisMBarr revised this gist Feb 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Add Css.css
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #js-other-comments{
    padding: 5px;
    border-top: 1px solid #C0C0C0
    border-top: 1px solid #C0C0C0;
    }
    #js-other-comments a{
    padding: 5px 7px;
  2. ChrisMBarr created this gist Feb 17, 2015.
    7 changes: 7 additions & 0 deletions Add Css.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #js-other-comments{
    padding: 5px;
    border-top: 1px solid #C0C0C0
    }
    #js-other-comments a{
    padding: 5px 7px;
    }
    94 changes: 94 additions & 0 deletions Add Html.htm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    <script>
    function changeButtons(){

    //Select buttons
    var $btn_copy = $("#btnAutoFill");
    var $btn_add = $("#btnAddEntry");
    var $btn_delete = $("a[id$=btnDeleteAllEntries]");
    var $btn_submit = $("a[id$=btnSubmit]");
    var $btn_back = $(".page1").children(".btn");

    //Change buttons colors
    $btn_copy.removeClass("btn-primary").addClass("btn-default");
    $btn_add.removeClass("btn-primary").addClass("btn-success");
    $btn_delete.removeClass("btn-primary").addClass("btn-default");
    $btn_back.removeClass("btn-primary").addClass("btn-default");

    //Change button sizes
    $btn_copy.add($btn_delete).add($btn_back).addClass("btn-sm");

    //Change button icons
    $btn_copy.children(".glyphicon").attr("class","glyphicon glyphicon-repeat");
    $btn_submit.children(".glyphicon").attr("class","glyphicon glyphicon-ok");

    //Select the buttons inside of modal windows
    $(".section-modal .btn").each(function(){
    var $thisModalBtn = $(this);
    var btnTxt = $thisModalBtn.text().toLowerCase();

    //Change button colors inside the modals depending on the text
    if(btnTxt.indexOf("save")>=0 || btnTxt.indexOf("submit")>=0){
    $thisModalBtn.removeClass("btn-primary").addClass("btn-success");
    }else if(btnTxt.indexOf("delete")>=0){
    $thisModalBtn.removeClass("btn-primary").addClass("btn-danger");
    }
    });
    }

    function setModalText(){
    //These are all the possible options that will show up below the textbox to select
    var comments = ["ATL Office","Remote - Cartersville, GA", "Remote - Rome, GA"]

    var otherId = "js-other-comments";

    var $visibleModals = $(".section-modal:visible");
    if($visibleModals.length>0){
    //find the comments field only for fields marked as null
    var $textbox = $visibleModals.find("#Comments textarea");

    //Show the other possible values as selectable links below the textbox
    if(!$("#"+otherId).length){
    var otherHtml = "<ul id='"+otherId +"' class='nav nav-pills'>";
    for(var i=0;i<comments.length;i++){
    otherHtml+="<li><a href='javascript:{};' data-txt='"+comments[i]+"'>"+comments[i]+"</a></li>";
    }
    otherHtml += "</ul>";
    $textbox.after(otherHtml);
    $("#"+otherId+" a").on("click",function(){
    setTextboxVal($textbox, $(this).data("txt"), true);
    });
    }

    //set the initial textbox value, but only if it's flagged as being null
    if($textbox.parents(".dxeNullText_Greenshades").length>0){
    var today = new Date;
    //Tuesdays(2) I am normally in the ATL office, most other days I work from home in Cartersville
    var textToUse = comments[(today.getDay()===2 ? 0 : 1)];
    setTextboxVal($textbox, textToUse, true);
    }else{
    //Otherwise, don't set the value, just highlight the button that matches the current value
    setTextboxVal($textbox, $textbox.val(), false);
    }
    }

    function setTextboxVal($tb, val, setValue){
    if(setValue){
    $tb.val(val).trigger("keyup").blur().focus();
    }
    $("#"+otherId+" li").removeClass("active").find("a[data-txt='"+val+"']").parent().addClass("active");
    }
    }

    $(function(){
    //Run initially
    changeButtons();
    setModalText();

    //Run on updatePanel posts
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){
    setTimeout(function(){
    changeButtons();
    setModalText();
    },250);
    });
    });</script>
    1 change: 1 addition & 0 deletions Match URL
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    ^https*://(.*?)greenemployee.com/ATE/Default.aspx