#StackBounty: #javascript #jquery #asp.net #clientpeoplepicker PeoplePicker not loading in a ASP.net page – SharePoint

Bounty: 50

I am able to load the peoplepicker control in a page created within SharePoint using the code below but the same when i try to load in a .net application, integrated in SharePoint then i am unable to get the desired result.

After checking multiple blogs I finally ended up using the below references :

http://../includes/js/modernizr-1.6.min.js
http://../includes/js/jquery-1.4.4.min.js
http://../includes/js/jquery.ui.all.js
/_layouts/1033/init.js
http://../includes/js/MicrosoftAjax.js
/_layouts/sp.core.js
/_layouts/15/sp.runtime.js
/_layouts/15/sp.js
/_layouts/15/clientforms.js
/_layouts/15/clientpeoplepicker.js
/_layouts/15/autofill.js
/_layouts/15/1033/initstrings.js
/_layouts/15/clienttemplates.js
/_layouts/15/1033/strings.js

and the code i use is :

function initializePeoplePicker() {

    // Create a schema to store picker properties, and set the properties.
    var schema = {};
    schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
    schema['SearchPrincipalSource'] = 15;
    schema['ResolvePrincipalSource'] = 15;
    schema['AllowMultipleValues'] = true;
    schema['MaximumEntitySuggestions'] = 50;
    schema['Width'] = '220px';

   this.SPClientPeoplePicker_InitStandaloneControlWrapper('peoplePickerDiv', null, schema);
}

I am able to see the desired results in a SharePoint webpart page as shown below :
Working

but the moment i try to do the same in a asp.net project which is deployed as an app in SharePoint server then the code stops working.

NOT Working

I believe the issue is with the references but i tried numerous combinations but nothing worked. Kindly help.


Get this bounty!!!

#StackBounty: #javascript #jquery #jquery-ui #datepicker #jquery-ui-datepicker Jquery Datepicker select multiple date ranges in one cal…

Bounty: 50

My requirement is to allow user to select multiple date ranges in a single calendar, also previous date selections should not be allowed to change. How is this possible? Below is the code and link to fiddle

HTML

<p>from</p>
<input type="text" class="spromotion-input-inbody spromotion-input-datepick" id="sproid-bookingcondition-datefrom">
<p>to</p>
<input type="text" class="spromotion-input-inbody spromotion-input-datepick" id="sproid-bookingcondition-dateto">

SCRIPT

$( function() {
    var dateFormat = "mm/dd/yy",
      from = $( "#sproid-bookingcondition-datefrom" )
        .datepicker({
          defaultDate: "+1w",
          changeMonth: true,
          numberOfMonths: 1
        })
        .on( "change", function() {
          to.datepicker( "option", "minDate", getDate( this ) );
        }),
      to = $( "#sproid-bookingcondition-dateto" ).datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 1
      })
      .on( "change", function() {
        from.datepicker( "option", "maxDate", getDate( this ) );
      });

    function getDate( element ) {
      var date;
      try {
        date = $.datepicker.parseDate( dateFormat, element.value );
      } catch( error ) {
        date = null;
      }

      return date;
    }
  } );


Get this bounty!!!

#StackBounty: #javascript #jquery Regex comma seperating thousands and keeping two decimals

Bounty: 50

I recently came up with this code while answering another StackOverflow question. Basically, on blur, this code will properly comma separate by thousands and leave the decimal at two digits (like how USD is written [7,745.56]).

I was wondering, is there a way to update the regex to accommodate for decimals as well as thousands, without doing the messy .toFixed(2). Especially, because I don’t need to display the decimals if no decimals are specified. Additionally, I would like to knock off any decimals passed 2 (even if that means ’rounding down’).

Input -> Target Output

7456 -> 7,456
45345 -> 45,345
25.23523534 -> 25.23
3333.239 -> 3,333.23
234.99 -> 234.99
2300.99 -> 2,300.99
23123123123.22 -> 23,123,123,123.22

Current Regex

var format = function (num) {
    return parseFloat(num).toFixed(2).replace(/B(?=(d{3})+(?!d))/g, ",")
}
$(function () {
    $("#principalAmtOut").blur(function (e) {
        $(this).val(format($(this).val()));
    });
});
https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
<input id="principalAmtOut" type="text" />


Get this bounty!!!

#StackBounty: #javascript #jquery #html #css #twitter-bootstrap-3 JQUERY.COUNTO.JS: On Scroll Count Numbers NOT OnLoad

Bounty: 50

I’m working with one page website and I want to add a counting numbers with it, so I use javascript.countTo.js. I created every section to group related data and I put the section counter <section id="counters"> below my portfolio section <section class="justaddheight portfolio">. Everytime the page load the number count and when I scroll I always see that numbers stop or ended it’s counting. Now, I want the number counts when I scroll and get into the section counter <section id="counters">. In addition, I used WOW.js and easingJS with my site, it’s the best if you combined the code with it, but it also acceptable if not. The code are the following below:

index.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title></title>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge">
        <meta name="viewport" content="width=device-width, initial-scale=1"><!--The Viewport-->
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!--Character Set-->
        <meta http-equiv="Cache-control" content="no-cache"> <!--The No-Cache-->

        <!--///////////////////////////////////////////////////////
                            CSS 
        ///////////////////////////////////////////////////////-->
        <link rel="stylesheet" href="css/animate.min.css">
        <!-- Bootstrap -->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <!-- Font-Awesome -->
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <!-- Icomoon-->
        <link rel="stylesheet" href="css/icomoon.css">
        <!-- Simple Line Icons -->
        <link rel="stylesheet" href="css/simple-line-icons.css">     
        <!-- Fonts -->
        <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>


        <!--///////////////////////////////////////////////////////
                            JAVASCRIPT 
        ///////////////////////////////////////////////////////-->

        <!-- jQuery -->
        http://js/jquery.js
        <!-- Bootstrap -->
        http://js/bootstrap.min.js
        <!-- Wow -->
        http://js/wow.min.js
        <!-- Counter -->
        http://js/jquery.countTo.js
        <!--Easing-->
        http://js/jquery.easing.1.3.js        
        <!--Custom JS-->
        http://js/custom.js
    </head>
    <body id="top">
        <section class="justaddheight text-center about" >
            <h1>SCROLL DOWN</h1>
            <p>First, Scroll Now</p>
            <p>Second, try Again but wait for few seconds before scroll to identify.</p>
        </section>
         <section class="justaddheight service">

        </section>
         <section class="justaddheight portfolio">

        </section>
        <section id="counters">
            
89 Finished projects
</div>
2343409 Templates
</div>
1302 Cup of coffees
</div>
52 Happy clients
</div> </div> </div> </section> </body> </html> <style type="text/css"> /* USE JUST TO ADJUST HEIGHT*/ .justaddheight{ height: 500px; } .text-center{ text-align: center; } </style> $('.counter-number').countTo();


Get this bounty!!!

#StackBounty: #jquery #twitter-bootstrap How to put a validation for bootstrap time picker so that it never exceeds given minutes?

Bounty: 200

I have got two fields inside a form timervalue and warmupvalue
(timervalue is always in Minutes .)

How to put a validation for timepicker so that it never exceeds given minutes ?

This is my code

<form id="update-form" class="form-horizontal">
   
</div> <input type="submit" class="btn btn-primary" value="Update" /> </form> $(document).ready(function() { $('#warmupvalue').timepicker( { showMeridian: false, showSeconds: true, //showMeridian: false, defaultTime: '0:00:00' }); $('#update-form').bootstrapValidator( { fields: { timervalue: { validators: { notEmpty: { message: 'timervalue is required' } } } } }) });

This is my fiddle

http://jsfiddle.net/x7pooh99/46/

Please let me know how to do this


Get this bounty!!!

#StackBounty: #sharepoint-online #jquery #html-form-web-part Submit item on select INSTEAD of button click in HTML Form WP Autocomplete…

Bounty: 50

Below is a script I have loaded into an HTML Form Web Part Filter. It is autopopulated with list items from a list called ‘Companies’. I want the list item to be submitted upon select INSTEAD of the users having to select the item from dropdown, and then hit the ‘submit’ button. New to development, so thanks for being patient if this is an obvious or easy fix. Thanks for your help!

  
// Settings 
var url = "https:///_vti_bin/listdata.svc/Companies()";  
var field = "Title";  

// Onload  
$(document).ready(function () {  
$("#mytags").autocomplete({  
    source: function (req, add) {  
        var suggestions = search(req.term, url, field);  
        add(suggestions);  
    }  
});  
});  



// Search all the listitems by using the REST Service  
// Value is the text that needs to be used in the query  
// listurl is the listdata.svc url withouth the filter params  
// field is the name of the field where the value in exists  
function search(value, listurl, field) {  
    var coll = new Array();  
    var url =  
        listurl + "?$filter=startswith(" + field + ",'" + value + "')";  

$.ajax({  
    cache: true,  
    type: "GET",  
    async: false,  
    dataType: "json",  
    url: url,  
    success: function (data) {  
        var results = data.d.results;  
        for (att in results) {  
            var object = results[att];  
            for (attt in object) {  
                if (attt == field) {  
                    coll.push(object[attt]);  
                    }  
                }  
            }  
        }  
    });  
    return coll  
}  
  


Get this bounty!!!

#StackBounty: #2013 #javascript #jquery #jslink #client-side-rendering Unable to write a jslink which defines a default values for my D…

Bounty: 100

I am working on a list view, where i have a choice column named TrackingStatus. Now for this choice column i defined the default value to be In Progress from the site columns settings.

But i have noticed that inside the Quick edit grid the default value for the TrackingStatus column will not be rendered (unlike inside the built-in create and edit forms).. so i tried to implement the default values using JS Link as follow:

I upload the following script inside my site collection:

(function () {
    alert("1");
    var overrideContext= {};

    overrideContext.Templates = overrideContext.Templates || {};

    overrideContext.Templates.Fields = {
        "TrackingStatus": {
            "View": function (ctx) {if(ctx.CurrentItem.your_column == "")
        return "In Progress";
}
        }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);

})();

Then I edit my list view WebPart and I provide the following to reference the above JSlink under the WebPart Miscellaneous section.:

~sitecollection/Resources/defaultvalues.js

But the JS Link is not having any effect in respect to applying default values for my column, although when I checked the page source I can see that the defaultvalues.js is being loaded and i got the alert(1) which I intentionally added inside the JS Link.

How can I define default values for my choices columns inside the Quick Edit grid?


Get this bounty!!!

#StackBounty: #javascript #jquery #html #image How to check width and height from all images has been called by jquery?

Bounty: 50

i have a problem on jquery image, which i need validate all image has been clicked or show with jquery

here is my code, how i add new images and show the images


true_image = false;
var _URL = window.URL || window.webkitURL;
$(document).ready(function(){

    var abc = 0;
    var wrapper         = $(".images");
    var add_button      = $("#add_more");

    var x = 1;
    $(add_button).click(function(){

        x++;
            $(wrapper).append('
" class="remove_field">
'); }); $(wrapper).on("click",".remove_field", function(e){ e.preventDefault(); $(this).parent('div').remove(); x--; }); $('body').on('change', '#file_input', function() { var image ; if (this.files && this.files[0]) { image = new Image; image.onload =function() { console.log("width : "+this.width+" height: "+this.height); if(this.width
"); var reader = new FileReader(); reader.onload = imageIsLoaded; reader.readAsDataURL(this.files[0]); $(this).hide(); $("#abcd" + abc).append($("", { id: 'img', src: '', alt: 'delete' }).click(function() { $(this).parent().parent().remove(); if(($('#file_input').val()) == undefined){ $(wrapper).append('
'); } })); } } }); function imageIsLoaded(e) { $('#previewimg' + abc).attr('src', e.target.result); $('.remove_field').hide(); }; $('body').on('click', '.images_view', function() { abc += 1; var cover = false; var image_id = this.id; $('.images_view').filter(function( index ) { if($( this ).attr( "id" ) === image_id){ $(this).parent().find('#file_input').attr('name','cover'); $(this).parent().find('#cover').remove(); $(this).parent().append("Cover"); }else{ $(this).parent().find('#file_input').attr('name','file[]'); $(this).parent().find('#cover').remove(); } }) }); });

from the above code, i trying to upload multi images so i add a button, and after it was clicked a new <input id="file_input" class="images_file" type="file" name="file[]"/> will be added, than after an images has been selected it could show the images. i want trying to validate the file is an image file, width and height on the image

my problem are, if i selected the false image (not in criteria) the button will be disabled but if in the next select, i choose the true image the button back to normal. I know this will happen because i don’t check the old images that has been selected before, and that is my problem i don’t know how to check it.

guys can you help me how to solve the problem?


Get this bounty!!!

#StackBounty: Lazy load content of slides inside carousel (content is oEmbeds/iframes)

Bounty: 100

I am loading in ajax a modal/popin with a Bootstrap carousel in which each slide is (not an image as in many question about lazy loading) but an iframe from oEmbed from various social networks (facebook, instagram, twitter, …).

The issue is that when I click the button that laods the modal, ALL the slides content get loaded, that is to say 15 to 20 oembeds(eahc of them loading content tetx, image and and javascript…).

I would like to be clever about it and only “lazy loading” slide by slide or even smarter 3 slides by 3 slides.

I am just also mentioning for the sake of information that I am using scrollMonitor and Hubspot Messenger. But i’d rather use Bootstrap slide events to trigger the apparition/load of each slide or any suggestion you would have.

I’m using ruby on rails as back end language

The url of the oEmbed programmatically change as they are inputed from a Admin Backoffice and change on each Article/page but you’ll find below an example :

Page.html

//button to click to make modal appear
<a class="btn btn-primary" onclick="loadModal()" id="socialStoryModal">
      load modal
</a>

Load Modal with Hubspot Messenger in page.js

function loadModal() {  
      var msg;
      msg = Messenger().post({
        message:  'modal.html.erb',/see below the carousel
        showCloseButton: true,
        hideAfter: false
      }); 
    }

modal.html.erb
= Modal with the carousel and the social embeds (here can be up to 50 of them)

I’ve seen tons of libraries to lazy load images and even sometimes scripts/iframes but they all need to have directly add certain classes I n the block, which is of no help for me as I use oembed above and I have nowhere to put these lazy classes.

I need to make it work with these oEmbeds iframes.


Get this bounty!!!

Fetch GET parameters in JS/jQuery

If you have a URL with some GET parameters as follows:

www.test.com/t.html?a=1&b=3&c=m2-m3-m4-m5 

and need to get the values of each parameters then below is a nifty piece of code solving your requirement.

JavaScript has nothing built in for handling query string parameters.

You could access location.search, which would give you from the ? character on to the end of the URL or the start of the fragment identifier (#foo), whichever comes first.

You can then access QueryString.c