Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Thursday, 15 May 2014

Branding CSS and Javascript tricks

How To: Hide Left Side Navigation on Home Page
<style type="text/css">
 body #s4-leftpanel {display: none;
.s4-ca {margin-left: 0px;
 </style>

How To: Hide Recently Modified
<style type="text/css">
 .s4-recentchanges {display:none;}
</style>

How To: Change the “No Items” message in a discussion web part with jQuery
<script type="text/javascript">
 $(document).ready(function(){
 $("td .ms-vb:contains('There are no items to show in')").text('There are no active discussions');
  });
</script>

How To: Hiding “Add new item” and “There are no items to show…” in SharePoint
https://www.threewill.com/2013/12/hiding-add-new-item-and-there-are-no-items-to-show-in-sharepoint/

How To: How To Remove Extra Space Around the Web Part In SharePoint 2013
<style type="text/css">
 .ms-webpartPage-root {border-spacing: 0px !important;}
 .ms-webpartzone-cell {margin: 0px !important;}
</style>

How To: Hide a web part with zero rows
<script>
function HideWebPartWithZeroRows()
{
  var a = document.getElementsByTagName("TABLE")
  for (var i=0;i<a.length;i++)
  {
    if (a[i].summary=="Test List")
    {
      if (a[i].rows.length==1)
      {
        //hide all but the title bar
        //var x =  a[i].parentNode.parentNode.parentNode.parentNode.parentNode
        //hide the entire web part
        var x =  a[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode

        x.style.display="none";
      }
    }
  }
}
_spBodyOnLoadFunctionNames.push("HideWebPartWithZeroRows") 
</script>

How To: Remove link border from around image
<style>
   a img {border:none}
</style>
<a href="http://sharepoint.stackexchange.com">
   <img src="http://cdn.sstatic.net/sharepoint/img/logo.png">
</a>

OR via inline styles:


<a href="http://sharepoint.stackexchange.com">
   <img src="http://cdn.sstatic.net/sharepoint/img/logo.png" style="border:none;">

</a>

Thursday, 20 February 2014

How to Get Login Name and Display Name using SharePoint 2013 REST API

jQuery.ajax({
    url: "/SiteName/_api/web/lists/getbytitle('ListName')/items",
    type: "GET",
    headers: { "Accept": "application/json;odata=verbose" },
    success: function(data, textStatus, xhr) {
        var dataResults = data.d.results;
        var resultId = dataResults[0].AuthorId.results[0];        
        getUser(resultId)
    },
    error: function(xhr, textStatus, errorThrown) {
        alert("error:"+JSON.stringify(xhr));
    }
});

function getUser(id){
var returnValue;
  jQuery.ajax({
   url: "http://YourSite/_api/Web/GetUserById(" + id + ")",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" },
   success: function(data) {
           var dataResults = data.d;
      //get login name  
      var loginName  = dataResults.LoginName.split('|')[1];
      alert(loginName);     
      //get display name
      alert(dataResults.Title);
   }
 });
}
How to Get Login Name and Display Name using SharePoint 2013 REST API
http://www.codeproject.com/Articles/692289/How-to-Get-Login-Name-and-Display-Name-using-Share

AngularJS

SharePoint 2013 Apps and AngularJS - The basics
http://blog.meligo.be/2013/08/sharepoint-2013-apps-and-angularjs-the-basics/
SharePoint Hosted App with CSOM & AngularJS for MVC Javascript
http://www.jeremythake.com/2013/10/sharepoint-hosted-app-with-angularjs-for-mvc-javascript/
Marc D Anderson
http://sympmarc.com/
Mark Rackley
http://www.sharepointhillbilly.com/default.aspx
Andrew Connell
http://www.andrewconnell.com/
SharePoint Hosted App with CSOM & AngularJS for MVC Javascript
http://www.jeremythake.com/2013/10/sharepoint-hosted-app-with-angularjs-for-mvc-javascript/