@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 8.76 kB
JavaScript
module.exports=function(e){var n={};function a(o){if(n[o])return n[o].exports;var t=n[o]={exports:{},id:o,loaded:!1};return e[o].call(t.exports,t,t.exports,a),t.loaded=!0,t.exports}return a.m=e,a.c=n,a.p="",a(0)}({0:function(o,t,e){o.exports=e(1680)},3:function(o,t){o.exports=function(){throw Error("define cannot be used indirect")}},6:function(o,t){o.exports=require("../kendo.combobox")},1039:function(o,t){o.exports=require("../kendo.toolbar")},1680:function(o,t,e){var n;e(3),e=[e(1039),e(6),e(1681)],void 0===(t="function"==typeof(n=function(){var l=window.kendo.jQuery,o=void 0,m=window.kendo,i=l.extend,t="action",n="keydown",e=m.support.click,u="change",a="zoomin",p="zoomout",f=m.toolbar.Item,s=m.ui.ToolBar,r={auto:"auto",actual:"actual",fitToWidth:"fitToWidth",fitToPage:"fitToPage"},c={zoomOutIcon:"k-i-zoom-out",zoomInIcon:"k-i-zoom-in",zoomButtons:"k-button-flat k-button-flat-base",zoomOverflowButtons:"k-button-solid k-button-solid-base k-overflow-button",overflowHidden:"k-overflow-hidden"},h=m.template('<a href="\\#" aria-label="#=text#" title="#=text#" data-command="#=command#" class="k-button k-button-md k-rounded-md # if(!showText) { # k-icon-button # } # #=className#">'+'<span class="k-button-icon k-icon #= iconClass #"></span> '+"# if(showText) { #"+'<span class="k-button-text">#= text #</span> '+"# } #"+"</a>"),b=m.template('<select title="#=zoomLevel#" aria-label="#=zoomLevel#">'+"#for(var zoomIndex in zoomLevels){#"+"# var zoomLevel = zoomLevels[zoomIndex]; #"+'<option value="#= zoomLevel.percent || (zoomLevel + "%") #">${zoomLevel.text ? zoomLevel.text : zoomLevel + "%"}</option>'+"#}#"+"</select>"),d={pager:{type:"pager",overflow:"never",command:"PageChangeCommand"},spacer:{type:"spacer"},zoom:{type:"zoom",command:"ZoomCommand",zoomInOut:true,combobox:{zoomLevels:[50,100,150,200,300,400]},enable:false,attributes:{class:"k-button-group"}},toggleSelection:{type:"buttonGroup",attributes:{class:"k-toggle-selection-group"},buttons:[{togglable:true,text:"Enable Selection",command:"EnableSelectionCommand",icon:"cursor",showText:"overflow",name:"toggleSelection",group:"toggle-pan"},{togglable:true,text:"Enable Panning",command:"EnablePanCommand",icon:"hand",showText:"overflow",name:"togglePan",group:"toggle-pan",selected:true}]},spacer2:{type:"spacer"},search:{type:"button",text:"Search",command:"OpenSearchCommand",icon:"search",name:"search",showText:"overflow",enable:false},open:{type:"button",text:"Open",showText:"overflow",name:"open",icon:"folder-open",command:"OpenCommand"},download:{type:"button",text:"Download",showText:"overflow",name:"download",icon:"download",command:"DownloadCommand",enable:false},print:{type:"button",text:"Print",showText:"overflow",name:"print",icon:"print",command:"PrintCommand",enable:false}},g=i({},d,{exportAs:{type:"button",text:"Export",showText:"overflow",name:"exportAs",icon:"image-export",command:"ExportCommand"}}),v=f.extend({init:function(o,t){var e=l("<div />");this.options=i(true,o,t.options.pager);this.toolbar=t;this.toolbar.pager=new m.pdfviewer.Pager(e,i({},o,{change:this._change.bind(this)}));this.element=e;this.element.on(n,this._keydown.bind(this));this.attributes();this.addUidAttr();this.addOverflowAttr()},_change:function(o){if(this.options.change&&this.options.change(o.page))return;this.toolbar.action({command:"PageChangeCommand",options:{value:o.page}})},_keydown:function(o){var t=this,e=l(o.target),n=o.keyCode,a=t.element.find(":kendoFocusable"),i=a.index(e),s=o.shiftKey?-1:1,r=m.keys;if(n===r.TAB&&a[i+s]){a[i+s].focus();o.preventDefault();o.stopPropagation()}else if(n===r.RIGHT&&a[i+1]){a[i+1].focus();o.preventDefault();o.stopPropagation()}else if(n===r.LEFT&&a[i-1]){a[i-1].focus();o.preventDefault();o.stopPropagation()}}});function x(o,t,e){var n=e?c.zoomOverflowButtons:c.zoomButtons;o.append(h({text:t.zoomOut,command:p,iconClass:c.zoomOutIcon,showText:e,className:n}));o.append(h({text:t.zoomIn,command:a,iconClass:c.zoomInIcon,showText:e,className:n}))}m.toolbar.registerComponent("pager",v);var k=f.extend({init:function(o,t){this._init(o,t);this.toolbar.zoom=this;if(t.options.scale)this._initValue=t.options.scale*100+"%";this._appendElements();this._click=m.throttle(this._click.bind(this),200);this._keydown=m.throttle(this._keydown.bind(this),200);this.element.on(e,".k-button[data-command='zoomin'], .k-button[data-command='zoomout']",this._click);this.element.on(n,".k-button[data-command='zoomin'], .k-button[data-command='zoomout']",this._keydown);this.attributes();this.addUidAttr();this.addOverflowAttr();this.enable(o.enable)},_init:function(o,t){var e=l("<div />");this.options=i(true,o,{messages:t.options.messages.zoom});this.toolbar=t;this.element=e},_appendElements:function(){var o=this.options;if(o.zoomInOut)x(this.element,o.messages,false);if(o.combobox)this._buildComboBox()},_buildComboBox:function(){var o=this,t,e=o.options.messages,n=o.options.combobox,a=[{percent:r.auto,text:e.autoWidth},{percent:r.actual,text:e.actualWidth},{percent:r.fitToWidth,text:e.fitToWidth},{percent:r.fitToPage,text:e.fitToPage}];a=a.concat(n.zoomLevels);t=l(b({zoomLevels:a,zoomLevel:e.zoomLevel}));if(!m.support.mobileOS){t=t.kendoComboBox(i({autoWidth:true,clearButton:false,value:o._initValue},n)).getKendoComboBox();o.element.append(t.wrapper);o.combobox=t;o._currentValue=t.value()}else o.element.append(t);t.bind(u,m.throttle(o.change.bind(o),300))},change:function(o){var t=o.sender?o.sender.value():o.target.value,e;if(t.toString().match(/^[0-9]+%?$/))e=parseInt(t.replace("%",""),10)/100;else if(!r[t]){if(this.combobox)this.combobox.value(this._currentValue);o.preventDefault();return}this._currentValue=t;this.toolbar.action({command:"ZoomCommand",options:{scale:e||t}})},_buttonCommand:function(o){var t=l(o).closest(".k-button"),e=t.data("command");this.toolbar.action({command:"ZoomCommand",options:{zoomIn:e===a,zoomOut:e===p,updateComboBox:true}})},_click:function(o){this._buttonCommand(o.target)},_keydown:function(o){var t=o.target,e=o.keyCode,n=m.keys,a=this.element.find(":kendoFocusable"),i=a.index(l(t));if(e===n.ENTER){this._buttonCommand(t);o.preventDefault()}else if(e===n.RIGHT&&a[i+1]){a[i+1].focus();o.preventDefault();o.stopPropagation()}else if(e===n.LEFT&&a[i-1]){a[i-1].focus();o.preventDefault();o.stopPropagation()}},enable:function(o){var t=this.element;t.find(".k-button, select").toggleClass("k-disabled",!o);if(this.combobox)this.combobox.enable(o)},destroy:function(){if(this.combobox)this.combobox.destroy()}}),w=k.extend({_init:function(o,t){var e=l("<li></li>");this.options=i(true,o,{messages:t.options.messages.zoom});this.toolbar=t;this.element=e},_appendElements:function(){var o=this.options;if(o.zoomInOut)x(this.element,o.messages,true)},overflowHidden:function(){this.element.addClass(c.overflowHidden)}}),z=(m.toolbar.registerComponent("zoom",k,w),s.extend({init:function(o,t){var e=this;var n=t.items&&t.items.length?t.items:Object.keys(d);e.options=t;t.items=e._updateItems(n);s.fn.init.call(e,o,t);e.bind({click:e._click,toggle:e._click});t.viewer.bind({update:e._update.bind(e)})},events:[t],_updateItems:function(o){var i=this;var s=this.options.messages;return o.map(function(o){var t=l.isPlainObject(o)&&Object.keys(o).length===1&&o.name;o=t?o.name:o;var e=l.isPlainObject(o)?o:g[o];var n;var a=e.name;if(e.type==="buttonGroup")e.buttons=i._updateItems(e.buttons);else if(e.type!=="pager")n={name:a,attributes:{"aria-label":s[a],title:s[a],"data-command":e.command},overflow:e.overflow,fillMode:"flat"};else n={overflow:"never"};if(e.text)n.text=s[e.name]||e.text;m.deepExtend(e,n);return e})},_click:function(o){var t=l(o.target).data("command");if(!t)return;this.action({command:t,options:o.options})},_update:function(o){var t={page:o.page||1,total:o.total||1};if(this.zoom){this.zoom.enable(!o.isBlank);if(o.action==="zoom")this._updateZoomComboBox(o.zoom)}if((o.action==="pagechange"||o.isBlank)&&this.pager)this.pager.setOptions(t);this.enable(this.wrapper.find(".k-toggle-selection-group"),!o.isBlank);this.enable(this.wrapper.find("[data-command='OpenSearchCommand']"),!o.isBlank);this.enable(this.wrapper.find("[data-command='DownloadCommand']"),!o.isBlank);this.enable(this.wrapper.find("[data-command='PrintCommand']"),!o.isBlank)},_updateZoomComboBox:function(o){var t=o===r.auto||o===r.actual||o===r.fitToPage||o===r.fitToWidth;if(!t)o=Math.round(o*100)+"%";if(this.zoom&&this.zoom.combobox){this.zoom._currentValue=o;this.zoom.combobox.value(o)}},action:function(o){this.trigger(t,o)},destroy:function(){if(this.pager)this.pager.destroy();if(this.zoom)this.zoom.destroy();s.fn.destroy.call(this)}}));return i(m.pdfviewer,{Toolbar:z,DefaultTools:d}),window.kendo})?n.apply(t,e):n)||(o.exports=t)},1681:function(o,t){o.exports=require("./pager")}});