Wednesday, February 15, 2012

Dynamically Change the CSS for MOSS 2007 Master Page.

1.Crate more than two CSS file with different color code.
2. Upload the css files into the any of the document library. In this put in "Shared Documents".
3.Created eight CSS file and upload in the "Shared Documents".
4.Go the sharepoint Designer 2007.
5.Open site collection.
6.Go the master page under the catalogs folder.
7.Copy the default.master and paste rename into "Custom.master".
8.In the Master page <head> section add the following javascript.


<script type="text/javascript" language="javascript">

function loadjscssfile(filename, filetype){
var randomnumber=Math.floor(Math.random()*8);
// alert(randomnumber);
MyNumbers=new Array
("Customtest_green.css","Customtest_red.css","Customtest_orange.css","Customtest_pink.css","Customtest_purple.css","Customtest_turquoise.css","Customtest_yellow.css","Customtest.css");
filename="http://192.168.1.201/sites/test/Shared%20Documents/"+MyNumbers[randomnumber].toString();
  if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}


loadjscssfile("http://192.168.1.201/sites/test/Shared%20Documents/Customtest_green.css", "css") ////dynamically load and add this .css file
</script>

9.Save and publish the master page.
10. Now while loading the page randomly took the css.


Wednesday, February 1, 2012

Expand and Collapse the SharePoint Web parts.

1. Click on the Edit page Under "Site Actions".
2.Add Content Editor Web part any Zone.
3.Click on the Web part. "Click here to add content"
4.Click On "Edit Html Source" on the Ribbon.
5.Add following code.


<script type="text/javascript">
// Add the Web Part Titles here to have them opened by default
var wpsToSkip = ['Search Documents','sandbox'];
 //Add multiple Web parts to skip the Collapse
//var wpsToSkip = ['Search Documents','Pending Documents','sandbox'];


function wpExpander() {
 var theTDs = document.getElementsByTagName("TD");
 for (var t=0;t<theTDs.length;t++) {
  var id = theTDs[t].id;
  if (id.match("WebPartTitleWPQ")) {
   id = id.substr(id.indexOf("WPQ"));
   var title = (theTDs[t].innerText || theTDs[t].textContent).replace(/[\n\r]/,'');
   var strImg = "<img style='margin:6px 5px 0px 2px;cursor:hand;float:left;' ";
   if (wpsToSkip.join().match(title)) {
    strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/minus.gif'>";
   } else {
    strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/plus.gif'>";
    document.getElementById("WebPart"+id).style.display = "none";
   }
   theTDs[t].innerHTML = strImg + theTDs[t].innerHTML;
  }
 }
}


function showHide(i,o) {
 var wp = document.getElementById("WebPart"+i);
 wp.style.display = (wp.style.display=="") ? "none" : "";
 o.src = (o.src.match(/plus.gif/)) ? "/_layouts/images/minus.gif" : "/_layouts/images/plus.gif";
}


_spBodyOnLoadFunctionNames.push("wpExpander()");
</script>


6.Make this Web part as Hidden.
7.Save and Close the web part.



Give Read Permission for SharePoint Add-in for Azure AD Send Mail to Office 365 Domain Group users.

Below are the Steps for Send Mail to Office 365 Domain Group or AD Group users from Provider Hosted ADD-IN. For this we needs to Give Permi...