Commit b38ae6a1 authored by O'Reilly Media, Inc's avatar O'Reilly Media, Inc
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

CH06/1.txt

0 → 100755
+75 −0
Changes for CH06/1.txt: 75 added lines, 0 removed lines.
Original line number Diff line number Diff line
<style type="text/css">
	.message { text-align: center; }
	.message img { vertical-align: middle; }
	blockquote p { font: italic bold 1.6em/1.2 "Times New Roman" , serif; }
	blockquote p.author {
	  font: normal 1em/1.2 sans-serif;
	  color: #666;
	  text-align: right;
	}
	</style>
	<div id="quoteOfTheDay"></div>
	<script type="text/javascript">
	Date.prototype.getFullDate = function () {
	    var dateAsString = '';
	    dateAsString += this.getFullYear();
	    var month = this.getMonth() + 1;
	    if (month < 10) {
	        dateAsString += 0;
	    }
	 
	    dateAsString += month;
	 
	    var day = this.getDate();
	    if (day < 10) {
	        dateAsString += 0;
	    }
	 
	    dateAsString += day;
	 
	    return parseInt(dateAsString);
	}
	 
	SP.SOD.executeOrDelayUntilScriptLoaded(function() {
	    Type.registerNamespace('Mavention.QuoteOfTheDay');
	    Mavention.QuoteOfTheDay.displayQuote =
            function (webUrl, listName, container) {
	        container.innerHTML = '<div class="message">\
<img src="/_layouts/images/loading.gif" alt=""/> \
Loading Quote of the Day...</div>';
	 
	        context = SP.ClientContext.get_current();
	        web = context.get_site().openWeb(webUrl);
	        list = web.get_lists().getByTitle(listName);
	        query = new SP.CamlQuery();
	        query.set_viewXml('<View><ViewFields><FieldRef Name="Title"/>\
<FieldRef Name="Quote"/></ViewFields></View>');
	        items = list.getItems(query);
	        context.load(items);
	        context.executeQueryAsync(Function.createDelegate(this, function () {
	            numberOfQuotes = items.get_count();
	            if (numberOfQuotes > 0) {
	                now = new Date();
	                quoteNumber = now.getFullDate() % numberOfQuotes;
	                quoteItem = items.get_item(quoteNumber);
	                quote = quoteItem.get_item('Quote');
	                author = quoteItem.get_item('Title');
	 
	                container.innerHTML = '<blockquote><p>' + quote +
                        '</p><p class="author">' + author + '</p></blockquote>';
	            }
	            else {
	                container.innerHTML = '<div class="message">\
There are no quotes in the list yet</div>';
	            }
	        }), Function.createDelegate(this, function () {
	            container.innerHTML = '<div class="message">\
<img src="/_layouts/images/error16by16.gif" alt=""/> \
An error has occured while loading Quote of the Day</div>';
	        }));
	    }
	 
	    Mavention.QuoteOfTheDay.displayQuote('/', 'Quotes',
            document.getElementById('quoteOfTheDay'));
	}, 'sp.js');
	</script>

CH06/2.txt

0 → 100755
+68 −0
Changes for CH06/2.txt: 68 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Quotes List"
FolderCreation="FALSE" DisableAttachments="TRUE"
Direction="$Resources:Direction;" Url="Lists/Quotes" BaseType="0"
xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <Fields>
      <Field DisplayName="Author" Name="Title" Type="Text"/>
      <Field DisplayName="Author" Name="LinkTitle" Type="Text"/>
      <Field DisplayName="Quote" Name="Quote" Type="Note" />
    </Fields>
    <Views>
      <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="LinkTitleNoMenu"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="AddNewAnnouncement"
                Location="Resource(wss,addnewitem)" />
          <ParameterBinding Name="NoAnnouncements"
                Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo"
                Location="Resource(wss,noXinviewofY_ONET_HOME)" />
        </ParameterBindings>
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main"
        DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;"
        DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE"
        SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png"
        Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="LinkTitle" DisplayName="Author"/>
          <FieldRef Name="Quote"/>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="ID"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements"
            Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo"
            Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx"
        WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx"
        WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx"
        WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>

CH06/3.txt

0 → 100755
+17 −0
Changes for CH06/3.txt: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type
name="Mavention.SharePoint.QuoteOfTheDay.QuoteOfTheDayWebPart.QuoteOfTheDayWebPart, $SharePoint.Project.AssemblyFullName$" />
      <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">Quote of the Day Web Part</property>
        <property name="Description"
type="string">Displays quote of the day</property>
      </properties>
    </data>
  </webPart>
</webParts>

CH06/4.txt

0 → 100755
+9 −0
Changes for CH06/4.txt: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="QuoteOfTheDayWebPartAssets" Url="style library/quoteoftheday">
    <File Path="QuoteOfTheDayWebPartAssets\mavention.quoteoftheday.js"
        Url="mavention.quoteoftheday.js" />
    <File Path="QuoteOfTheDayWebPartAssets\mavention.quoteoftheday.css"
        Url="mavention.quoteoftheday.css" />
  </Module>
</Elements>

CH06/5.txt

0 → 100755
+35 −0
Changes for CH06/5.txt: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;

namespace Mavention.SharePoint.QuoteOfTheDay.QuoteOfTheDayWebPart {
    [ToolboxItem(false)]
    public partial class QuoteOfTheDayWebPart :
        System.Web.UI.WebControls.WebParts.WebPart {
        [WebDisplayName("Site URL"),
        WebDescription(@"Server-relative URL of the site where the Quotes List
is located"), Category("Quote of the Day Configuration"),
        Personalizable(PersonalizationScope.Shared), WebBrowsable(true)]
        public string WebUrl { get; set; }
        [WebDisplayName("List Name"),
        WebDescription("Name of the Quotes List that you want to use"),
        Category("Quote of the Day Configuration"),
        Personalizable(PersonalizationScope.Shared), WebBrowsable(true)]
        public string ListName { get; set; }

        public bool Configured {
            get {
                return !String.IsNullOrEmpty(WebUrl) &&
                    !String.IsNullOrEmpty(ListName);
            }
        }

        protected override void OnInit(EventArgs e) {
            base.OnInit(e);
            InitializeControl();
        }

        protected void Page_Load(object sender, EventArgs e) {
        }
    }
}
Loading