<CustomActionGroup
      Id="SPMRBGroup"
      Description="$Resources:SPMeetingRoomBooking,spmrb_el_websitemanage"
      ImageUrl="/_layouts/images/SPMRB/SiteSettings_SiteActions_48x48.png"
      Title="$Resources:SPMeetingRoomBooking,spmrb_el_websitemanage"
      Location="Microsoft.SharePoint.SiteSettings"
      Sequence="30" />
  
  <CustomAction
      Id="SPMRBCustomAction"
      Description="$Resources:SPMeetingRoomBooking,spmrb_el_linkresourcelist"
      Title="$Resources:SPMeetingRoomBooking,spmrb_el_maintaintitle"
      GroupId="SPMRBGroup"
      Location="Microsoft.SharePoint.SiteSettings"
      Rights="ManageWeb"
      RequireSiteAdministrator="FALSE"
      Sequence="20">
    <UrlAction Url="./Lists/Facilities and Shared Assets/AllItems.aspx" />
  </CustomAction>
     <CustomAction Id="ReturnCustomization" Location="CommandUI.Ribbon.ListView" RegistrationId="106" RegistrationType="List" Title="返回预约画面">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Calendar.Calendar.Scope.Controls._children">
          <Button Id="ReturnButton"
                  Command="ReturnButtonCommand"
                  Description="$Resources:SPMeetingRoomBooking,spmrb_el_returnfrompage"
                  Image32by32="/_layouts/images/SPMRB/backicon.png"
                  LabelText="$Resources:SPMeetingRoomBooking,spmrb_el_return" 
                  TemplateAlias="o2" 
                  Sequence="91"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="ReturnButtonCommand" CommandAction="javascript: window.location.href = window.ribbonPollResponse.fromPageUrl;" EnabledScript="javascript:
                          if ('undefined' === typeof window.ribbonPollResponse)
                              window.ribbonPollResponse = {};
                          if ('undefined' === typeof window.ribbonPollResponse.fromPageUrl)
                              window.ribbonPollResponse.fromPageUrl = null;
                          var fromPageUrl = '';
                          var listItems;
                          function getDeviceInfo(){
                              this.clientContext = SP.ClientContext.get_current();
                              this.oWebsite = this.clientContext.get_web();

                              this.collList = this.oWebsite.get_lists();

                              this.targetList = this.collList.getByTitle('DeviceMaintain');
                              var query = new SP.CamlQuery();
                              //query.set_viewXml('&lt;View &gt;&lt;Query&gt;&lt;Where&gt;&lt;Neq&gt;&lt;FieldRef Name='Title'/&gt;&lt;Value Type='Text'&gt;&lt;/Value&gt;&lt;/Neq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;');
                                this.listItems = this.targetList.getItems(query);

                              this.clientContext.load(this.listItems);
                              this.clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));
                              repollRibbon();
                          }
                           function onQuerySucceeded() {
                             var queryString = new String();            
                               queryString = window.location.href;
                             this.listEnumerator = this.listItems.getEnumerator();
                             while (this.listEnumerator.moveNext()) {
                                var calendarListUrlitem = this.listEnumerator.get_current().get_item('CalendarListUrl');
                                if(decodeURIComponent(queryString).indexOf(calendarListUrlitem + '/') > -1)
                                {
                                    window.ribbonPollResponse.fromPageUrl = listEnumerator.get_current().get_item('FromPageUrl');
                                    break;
                                }
                              }
                          }

                          function onQueryFailed(sender, args) {
                          
                          }
                          function invokeReturnButton()
                          {
                            if (null === window.ribbonPollResponse.fromPageUrl)
                                getDeviceInfo();
                            else {
                                return true;
                            }
                          }
                          
                          function repollRibbon() {
                              if (null === window.ribbonPollResponse.fromPageUrl)
                                  this.timeoutId = window.setTimeout(repollRibbon, 1000);
                              else {
                                  window.clearTimeout(this.timeoutId);
                                  RefreshCommandUI();
                              }
                          }
                          invokeReturnButton();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

CustomAction 元素

定义用户界面扩展,如工具栏上的按钮或网站设置页上的链接。 

属性

Location:指定此自定义操作的位置,例如,"Microsoft.SharePoint.SiteSettings"

Sequence:指定操作的排序优先级

 

CustomAction 元素包含 CommandUIExtension 子元素,则 Location 必须以“CommandUI.Ribbon”开头。

 

posted on 2013-10-24 18:06  金海浪  阅读(843)  评论(0编辑  收藏  举报