by Vipul Bhavsar
28. July 2011 05:21
JavaScript / jQuery on the page at either:
- $(document).ready
- _spBodyOnLoadFunctionNames
will not return the required result, since the menu elements we need to interrogate have not been rendered yet.
Solution:
- Set a timer to keep running a particular function to wait until the menu is rendered
- Stop the timer
- Interrogate the DOM as required using jQuery
Code Example:
1 <script type='text/javascript'>
2
3 var timerHandle ="";
4 var currentWindowsAccount ="";
5 _spBodyOnLoadFunctionNames.push("runCustom");
6
7 function runCustom() {
8 timerHandle = setTimeout(getCurrentLoggedInUser, 10);
9 }
10
11 function getCurrentLoggedInUser() {
12 //Function requires jQuery
13
14 /* Retrieve the current logged in user from the My Profile option in **
15 ** the Welcome Menu (id=ID_MySiteLinksMenu) **
16 ** This needs a timeout to wait for the menu to be rendered via AJAX */
17
18 //Timers are expensive on client resources, clear at all opportunities
19 clearTimeout(timerHandle);
20
21 var welcomeMenuItems = $('#ID_MySiteLinksMenu'); //ie:menu with id='ID_MySiteLinksMenu'
22
23 if (welcomeMenuItems.length >0) {
24 var onmenuclickValue = welcomeMenuItems.attr("onmenuclick");
25 var onmenuclicksplit = onmenuclickValue.split("=");
26 var loggedInUserString = onmenuclicksplit[1];
27 var loggedInUserStringSplit = loggedInUserString.split("'");
28
29 currentWindowsAccount = loggedInUserStringSplit[0];
30 alert(currentWindowsAccount);
31 }
32 else {
33 //My Profile link has not been rendered yet, try again.
34 timerHandle = setTimeout(getCurrentLoggedInUser, 10);
35 }
36 }
37
38 </script>
by Altaf Pinjari
19. July 2011 02:05
SharePoint Designer uses caching which can overwrite your changes. I have done this MANY times.
1. Best way to avoid this is to turn off caching for Designer but your site may run slower.
In SPD go to file > options > application options - second to the last checkbox "Cache Site Data across SharePoint Designer sessions"
Or
2. Each time you open your CSS file make sure you hit the refresh button in the top right corner to load the latest not cached version.
If you need I will find the instructions to for turning of site caching so you dont have this issue in the future. I have turned it back on as the site was inreadibly slow and am very aware that changes can be overwritten if I dont hit that refresh button.
by Vipul Bhavsar
14. July 2011 05:03
Add Search To Master Page or enable search box in masterpage
<div class="s4-notdlg">
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4" />
</asp:ContentPlaceHolder>
</div>
To style the Search Button
/*Search Box Styles*/
.s4-search input.ms-sbplain{
margin-top:5px!important;
background:url(../images/search_left.png) no-repeat;
border:0 none !important;
height:16px;
padding:4px 2px 2px 9px;
color:#666;
font-size:.85em;
font-style:normal;}
.s4-search .ms-sbgo{padding-top:5px;}
.s4-search .ms-sbgo a{
margin-top:5px;
background:url(../images/search_btn.png) no-repeat;
width:27px; height:22px; display:block; }
.s4-search .srch-gosearchimg, .s4-search .ms-sbgo span{display:none; }
.adminBar .ms-sbrow a, .ms-sbcell{margin:0; padding:0;}
Download Images Used:


For SharePoint Foundation Search box CSS
/* ::::::::::::::::::Search:::::::::::::::::: */
.s4-search{
padding:0px !important;
margin-right: 5px;
}
.s4-search select,.s4-search input{
/* [ReplaceColor(themeColor:"Light2-Lighter")] */
border:1px solid #e3e3e3 !important;
color:#476382;
float:left;
/* [ReplaceColor(themeColor:"Dark2")] */ color:#476382;
}
.s4-search select{
height:21px;
font-family:Verdana,Arial,sans-serif;
font-size:9pt;
padding:0 3px;
margin:3px 3px 0 0;
}
.s4-search input,.s4-search .ms-searchimage{
float:left;
/* [RecolorImage(themeColor:"Light1-Lighter",method:"Blending",includeRectangle:{x:0,y:511,width:1,height:18})] */
background:none;
/* [ReplaceColor(themeColor:"Light1")] */ background-color:#fff;
}
.s4-search input{
font-size:1.1em ;
height:16px;
padding:1px 3px 2px;
border-right:1px solid #e3e3e3 !important;
width:130px !important;
margin-top:3px;
}
.s4-search .ms-searchimage{
/* [ReplaceColor(themeColor:"Light1")] */ background-color:#fff;
background-image:url('PARTCAT-images/search-btn.png');
background-repeat:no-repeat;
/* [ReplaceColor(themeColor:"Light2-Lighter")] */ border:0px solid #e3e3e3 !important;
height:16px;
width:43px;
padding:2px 3px 1px;
border-left:none !important;
margin-top:3px;
margin-left:5px;
}
#onetIDGoSearch {
width:43px !important;
height:15px !important;
}
#onetIDGoSearch img {
display:none;
width:43px !important;
height:15px !important;
}
.ms-searchimage > .s4-clust {
width:43px !important;
height:15px !important;
}
.s4-help{
display:inline-block;
margin:4px 4px 3px 21px;
}
/* ::::::::::::::::::Search:::::::::::::::::: */