Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Posts Tagged ‘jQuery’

jQuery Ticker for SharePoint Announcement List

Posted by ken zheng on July 23, 2009

By using Scott Price’s code, I add a query to the CAML so it will only display annoucment which not expired.

<script type="text/javascript" src="/Development Library/jquery-1.3.2.min.js"></script>

<script type="text/javascript" src="/Development Library/jquery.newsticker.js"></script>
<script type="text/javascript" src="/Development Library/DateUtilities.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
	var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
		soapEnv += "<listName>Announcements</listName>";
		soapEnv += "<query><Query><Where><Geq><FieldRef Name='Expires' /><Value Type='DateTime'><Today/></Value></Geq></Where></Query></query>";
		soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='Created'/><FieldRef Name='ID'/></ViewFields></viewFields>"; //<RowLimit>1</RowLimit>
		soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

        $.ajax({
            url: "../_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    });

function processResult(xData, status) {
        var newnews = $("<ul>").attr("class", "newsticker");
        var rows;
        if (xData.responseXML.getElementsByTagName("z:row").length==0)
        {
			var url = "/test/Lists/Announcements/";
            var liHtml = "<li class='newscontent'> <b> No Latest News <br><br><a href='" + url + "'>Read All"+"</a></b></li>";
            newnews.append(liHtml);
        }
        else
        {
			rows = xData.responseXML.getElementsByTagName("z:row");
			jQuery(rows).each(function() {
            var createdDate= $(this).attr("ows_Created").split(" ");
            var url = "/test/Lists/Announcements/DispForm.aspx?ID=" + $(this).attr("ows_ID");
            createdDate = parseDate(createdDate[0]);
            var liHtml = "<li class='newscontent'>" +  formatDate(createdDate ,'dd MMM yy')+ " - <b>" +  $(this).attr("ows_Title")+ "<br><br><a href='" + url + "'>Read Details"+"</a></b></li>";
            newnews.append(liHtml);
        });
        }

        newnews.appendTo("#tasksUL").newsTicker();
    }
</script>

<style type="text/css">
.newsticker {
list-style-type: none;
height:50px;
color:#336699;
margin-top: 10;
}

.newscontent{
list-style-type: none;
margin-left: 0;
display: inline;

}

.news{
background: url(/_layouts/1033/IMAGES/SIMCENTRAL/link_m.gif) no-repeat  scroll center top;
width:240px;
}

.marktop {
background:transparent url(/_layouts/1033/IMAGES/SIMCENTRAL/link_t.gif) no-repeat scroll center top;
height:11px;

padding:0;
width:240px;
}

.markbottom {
background:transparent url(/_layouts/1033/IMAGES/SIMCENTRAL/link_b.gif) no-repeat scroll center top;
height:11px;
margin-left:0;
padding:0;
width:240px;
}
.markcenter {
height:auto;
margin-top:10;
padding:0;
width:211px;
}
</style>
<div class="markcenter">
<div class="marktop"/>
<div class="news">
<br>
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Noticeboard</b>
<div id="tasksUL"
</div>
</div>
<div class="markbottom"/>
</div>

Posted in Uncategorized | Tagged: , | 1 Comment »

Hide Search Context DropDown List in SharePoint

Posted by ken zheng on February 5, 2009

User always want to have a search function for current site, so I use the JQuery to hide the drop down list. First allow your Context Drop down and set it default to this site.
Then add this Javascript, just replace the id

  $("#ctl00_m_g_6320b784_9efb_43c3_a98c_e579abb4311b_SBScopesDDL").css({display:'none'});

Posted in Sharepoint | Tagged: | Leave a Comment »

Replace Global Links In SharePoint Using JQuery

Posted by ken zheng on February 4, 2009

Below is the JQuery Script to replace the first link of Global Breadcrumbs and you can replace text as well

<script type="text/javascript">
$(document).ready(function(){

//To replace the Global Breadcrumbs
$("#ctl00_PlaceHolderGlobalNavigation_PlaceHolderGlobalNavigationSiteMap_GlobalNavigationSiteMap").children(":first").children(":first").attr("innerText","SimCentral");

$("#ctl00_PlaceHolderGlobalNavigation_PlaceHolderGlobalNavigationSiteMap_GlobalNavigationSiteMap").children(":first").children(":first").attr("href","http://hotmail.com");

//To hide the Global Breadcrumbs
//$("#ctl00_PlaceHolderGlobalNavigation_PlaceHolderGlobalNavigationSiteMap_GlobalNavigationSiteMap").css({display:'none'});
});

</script>

Posted in Sharepoint | Tagged: | 1 Comment »

JQuery Expand/Collapse All Groups in SharePoint

Posted by ken zheng on January 14, 2009

Just follow the idea of JQuery for Everyone: Expand/Collapse All Groups. I have deployed on a few SharePoint Pages by control id. Just use IE Dev Tool to get control id and replace
$("td.ms-toolbar[width='99%']").append(expandAll).append(collapseAll);
to
$("#ctl00_m_g_2e4a2a42_7e54_4a6e_ba80_923f50d3f0d5_Message").append(expandAll).append(collapseAll);

Posted in Sharepoint, jQuery | Tagged: , | Leave a Comment »

Use JQuery Intellense in VS 2008

Posted by ken zheng on December 7, 2008

Download Hot-fix from Microsoft, In particular, if you are using Windows Vista with UAC enabled, make sure to extract the patch to a directory other than “c:\” (otherwise you’ll see an access denied error).

To verify that this hot-fix patch successfully installed, launch VS 2008 and select the Help->About menu item. Make sure that there is an entry that says ‘Hotfix for Microsoft Visual Studio Team System 2008 Team Suite – ENU (KB946581)’.

If you ever want to remove the patch, go to Control Panel -> Add/Remove Programs and select “Hotfix for Microsoft Visual Studio 2008 – KB946581” under Microsoft Visual Studio 2008 (or Visual Web Developer Express 2008) and click “Remove”.

Now download jquwey-1.2.6-intellisense.js.

Just reference in your web page , you are ready to go.

http://www.mustafaozcan.net/en/post/2008/10/26/ResolveUrl-and-JavaScript-Intellisense-in-Visual-Studio.aspx

Posted in JavaScript | Tagged: | 2 Comments »

ASP.NET, ASP.NET AJAX, jQuery, IIS Tutorial

Posted by ken zheng on October 11, 2008

Scoot Gu has blogged a list of links to these technoloies. Check it now and refresh your knowledge
http://weblogs.asp.net/scottgu/archive/2008/10/10/october-10th-links-asp-net-asp-net-ajax-jquery-iis.aspx

Posted in Uncategorized | Tagged: , , , | Leave a Comment »

jQuery to ship with ASP.NET MVC and Visual Studio

Posted by ken zheng on October 1, 2008

jQuery is a lightweight open source JavaScript library (only 15kb in size) that in a relatively short span of time has become one of the most popular libraries on the web.

Scott Hanselman is also about to post a nice tutorial that shows off integrating jQuery with ASP.NET AJAX (including the new client templating engine) as well as ADO.NET Data Services (which shipped in .NET 3.5 SP1 and was previously code-named “Astoria”).

Posted in Uncategorized | Tagged: | Leave a Comment »