-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap-fontpicker.min.js
1 lines (1 loc) · 12.6 KB
/
bootstrap-fontpicker.min.js
1
angular.module("schemaForm").run(["$templateCache",function(e){e.put("directives/decorators/bootstrap/fontpicker/fontpicker.html",'<div class="form-group" ng-class="{\'has-error\': hasError()}"><label class="control-label" ng-show="showTitle()">{{form.title}}</label><div font-picker="form" ng-model="$$value$$" style="background-color: white" schema-validate="form"></div><span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span></div>'),e.put("directives/decorators/bootstrap/fontpicker/fontpickerdirective.html",'<div class="fontpicker"><div class="alert alert-danger fontpicker-failedFont" role="alert" ng-if="failedFont.length > 0">{{ loadError({fontName:failedFont}) }}</div><div class="row" ng-if="paneButtons.preset.show && paneButtons.custom.show"><div class="btn-group col-xs-12" role="group"><button type="button" ng-click="switchPane(\'preset\')" ng-class="{\'btn-primary\': activePane === \'preset\', \'btn-default\': activePane !== \'preset\'}" class="btn">{{paneButtons.preset.text}}</button> <button type="button" ng-click="switchPane(\'custom\')" ng-class="{\'btn-primary\': activePane === \'custom\', \'btn-default\': activePane !== \'custom\'}" class="btn">{{paneButtons.custom.text}}</button></div></div><div class="row" ng-if="activePane === \'custom\'"><p class="col-xs-12 col-md-8" ng-bind-html="strings.customFontDesc"></p></div><div class="row quote-row" ng-if="preview.showTextAndSizeInput"><div class="col-xs-1"><svg class="label quoteicon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="0 0 796.455 736.859"><path fill="#231F20" d="M368.938 45.93s.79-34.072-6.21-40-43-5.93-43-5.93h-270s-28.272-2.07-39 5.93-10.73 40-10.73 40v272s-2.27 19 7.73 28 35 7 35 7h219s9 84-27 162-132 125-134 133 47 77.07 56 83 137.79-83 174-162 38.21-151 38.21-173v-350zM796.43 45.93s.788-34.072-6.212-40-43-5.93-43-5.93h-270s-28.272-2.07-39 5.93-10.73 40-10.73 40v272s-2.27 19 7.73 28 35 7 35 7h219s9 84-27 162-132 125-134 133 47 77.07 56 83 137.79-83 174-162 38.21-151 38.21-173v-350z"></path></svg></div><div class="col-xs-11 col-md-7"><input class="form-control quote" ng-model="preview.text"></div><div class="col-md-4 fontsize hidden-sm hidden-xs"><div ng-repeat="(key, size) in preview.sizes" ng-click="preview.defaultSize = size" class="sizebutton pointer" ng-style="{\'width\': Math.floor(100/preview.sizes.length)+\'%\'}" ng-class="{active: preview.defaultSize === size}"><svg class="fonticon" xmlns="http://www.w3.org/2000/svg" ng-width="{{13+(key*5)}}" ng-height="{{13+(key*5)}}" viewbox="83.178 0 645.914 736.859" enable-background="new 83.178 0 645.914 736.859"><path d="M701.562 692.248c-8.223-4.176-15.68-8.213-17.7-10.49-7.02-7.908-7.378-14.375-10.718-23.617-5.377-14.878-12.34-29.087-18.02-44.06-20.12-53.058-40.57-106.165-62.43-158.575-50.47-121.017-97.237-243.76-145.753-365.585-11.266-28.29-22.4-56.65-33.664-84.93 0 0-28.12-6.372-30.346 0-25.59 73.21-83.14 217.562-83.14 217.562L164.07 576.81l-28.037 79.646s-12.376 26.664-22.376 36.188c-3.213 3.06-30.384 17.94-30.48 15.95L84.43 734.7l163.298.002s.178-18.436 0-27.645c.035 1.785-33.015-11.973-36-14.73-10.07-9.297-19.68-25.517-15-38.907 3.49-9.984 70-189.396 70-189.396h209s61.924 174.53 66 182.744c19.782 39.865-15.52 58.564-49 59.75l1 28.182h235.364s-1.14-27.965-1.147-28.182c-.06-1.45-14.077-8.018-26.383-14.27zM278.27 425.982l95.348-247.48 91.11 247.428-186.458.052z"></path></svg><br>{{size}}pt</div></div></div><div class="row type-row" ng-show="activePane === \'preset\'"><div class="col-xs-1"><svg class="label fonticon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="83.178 0 645.914 736.859" enable-background="new 83.178 0 645.914 736.859"><path fill="#231F20" d="M701.562 692.248c-8.223-4.176-15.68-8.213-17.7-10.49-7.02-7.908-7.378-14.375-10.718-23.617-5.377-14.878-12.34-29.087-18.02-44.06-20.12-53.058-40.57-106.165-62.43-158.575-50.47-121.017-97.237-243.76-145.753-365.585-11.266-28.29-22.4-56.65-33.664-84.93 0 0-28.12-6.372-30.346 0-25.59 73.21-83.14 217.562-83.14 217.562L164.07 576.81l-28.037 79.646s-12.376 26.664-22.376 36.188c-3.213 3.06-30.384 17.94-30.48 15.95L84.43 734.7l163.298.002s.178-18.436 0-27.645c.035 1.785-33.015-11.973-36-14.73-10.07-9.297-19.68-25.517-15-38.907 3.49-9.984 70-189.396 70-189.396h209s61.924 174.53 66 182.744c19.782 39.865-15.52 58.564-49 59.75l1 28.182h235.364s-1.14-27.965-1.147-28.182c-.06-1.45-14.077-8.018-26.383-14.27zM278.27 425.982l95.348-247.48 91.11 247.428-186.458.052z"></path></svg></div><div class="col-xs-11"><div class="dropdown" ng-class="{open: dropdown}"><button ng-click="dropdown = !dropdown" class="btn btn-default dropdown-toggle" ng-style="{\'font-family\': modelValues.preset.name == \'Font\' ? \'\' : modelValues.preset.name }" style="min-width: 100%;" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">{{modelValues.preset.name || strings.dropdown}} <span class="caret"></span></button><ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"><li ng-click="chooseFont(font)" role="presentation" style="font-family: \'{{font.name}}\'" ng-repeat="(key, font) in fontlist"><a role="menuitem" tabindex="-1" href="javascript:return false;">{{font.name}}</a></li></ul></div></div></div><div class="row any-type-row" ng-show="activePane === \'custom\'"><div class="col-xs-1"><svg class="label fonticon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewbox="83.178 0 645.914 736.859" enable-background="new 83.178 0 645.914 736.859"><path fill="#231F20" d="M701.562 692.248c-8.223-4.176-15.68-8.213-17.7-10.49-7.02-7.908-7.378-14.375-10.718-23.617-5.377-14.878-12.34-29.087-18.02-44.06-20.12-53.058-40.57-106.165-62.43-158.575-50.47-121.017-97.237-243.76-145.753-365.585-11.266-28.29-22.4-56.65-33.664-84.93 0 0-28.12-6.372-30.346 0-25.59 73.21-83.14 217.562-83.14 217.562L164.07 576.81l-28.037 79.646s-12.376 26.664-22.376 36.188c-3.213 3.06-30.384 17.94-30.48 15.95L84.43 734.7l163.298.002s.178-18.436 0-27.645c.035 1.785-33.015-11.973-36-14.73-10.07-9.297-19.68-25.517-15-38.907 3.49-9.984 70-189.396 70-189.396h209s61.924 174.53 66 182.744c19.782 39.865-15.52 58.564-49 59.75l1 28.182h235.364s-1.14-27.965-1.147-28.182c-.06-1.45-14.077-8.018-26.383-14.27zM278.27 425.982l95.348-247.48 91.11 247.428-186.458.052z"></path></svg></div><div class="col-xs-7 col-md-9"><input class="form-control" ng-model="custom.input"></div><div class="col-xs-4 col-md-2"><button class="anytype-btn btn btn-default col-xs-1" type="button" ng-disabled="custom.loading" ng-click="loadCustomFont()">{{strings.loadButton}}</button></div></div><div class="row" ng-if="modelValues.current.name"><div class="col-xs-11 preview"><p ng-click="((key === 0 && preview.styles.length > 1) && togglePreview())" ng-hide="previewExpanded === false && key > 0" ng-repeat="(key, style) in preview.styles" class="previewRow" ng-style="angular.extend(style, {\'cursor\': (key === 0 && preview.styles.length > 1) ? \'pointer\' : \'default\', \'font-family\': addQuotes(modelValues.current.name), \'font-size\': preview.defaultSize+\'pt\'})">{{preview.text}}</p></div><div ng-click="togglePreview()" class="col-xs-1 caretsign pointer">{{previewExpanded == true ? \'▲\' : \'▼\'}}</div></div></div>')}]),angular.module("schemaFormFontpicker",["schemaForm"]).config(["schemaFormProvider","schemaFormDecoratorsProvider","sfPathProvider",function(e,t,o){var n=function(t,n,s){if("object"===n.type&&"font"===n.format){var a=e.stdFormObj(t,n,s);return a.key=s.path,a.type="fontpicker",s.lookup[o.stringify(s.path)]=a,a}};e.defaults.object.unshift(n),t.addMapping("bootstrapDecorator","fontpicker","directives/decorators/bootstrap/fontpicker/fontpicker.html")}]),angular.module("schemaFormFontpicker").directive("fontPicker",["$q","$interpolate",function(e,t){"use strict";return{restrict:"AE",scope:!0,require:"ngModel",templateUrl:"directives/decorators/bootstrap/fontpicker/fontpickerdirective.html",link:function(o,n,s,a){function i(e){if(/^(?:<link|http)/.test(e)){var t={};if(/^http/.test(e))var n=/^(?:<link href='|@import url\()*([^')]+)+/.exec(e);else if(/^<link/.test(e))var n=/^<link href="([^")]+)".+/.exec(e);t.url=n[1];var s=/.*ily=([^:]+)+/.exec(t.url);return null===s?(o.failedFont=e,!1):(t.name=s[1].replace(/\+/g," "),t)}return o.failedFont=e,!1}function r(t,n){var s=[];return angular.forEach(t,function(e){var t=e.url.match(/.*ily=(.+)$/),o=t[1].replace(/\+/g," ");s.push(o)}),e(function(e,t){o.failedFont="",WebFont.load({google:{families:s},active:e,inactive:t,fontinactive:function(e){if("preset"===n)throw"Failed to load font: "+e;o.failedFont=e,o.$apply()},timeout:3e3})})}var l="//fonts.googleapis.com/css?family=",c={};o.Math=window.Math,o.angular=angular,o.modelValues=c,o.activePane="preset",o.dropdown=!1,o.translations={},o.previewExpanded=!0,o.custom={input:"",loading:!1};var d=o.$watch(s.fontPicker,function(e){void 0!==e&&(o.fontlist=e.fontlist,o.preview=e.preview,o.strings=e.strings,o.paneButtons=e.paneButtons,o.preview||(o.preview={}),o.preview.sizes||(o.preview.sizes=[12,18,24,48]),o.preview.defaultSize||(o.preview.defaultSize=18),void 0===o.preview.showTextAndSizeInput&&(o.preview.showTextAndSizeInput=!0),o.preview.text||(o.preview.text="The quick brown fox jumps over the lazy dog"),o.preview.styles||(o.preview.styles=[{},{"font-weight":"bold"},{"font-style":"italic"}]),o.strings||(o.strings={}),o.strings.loadButton||(o.strings.loadButton="Load"),o.strings.dropdown||(o.strings.dropdown="Choose font"),o.strings.loadError||(o.strings.loadError="{{fontName}} could not be loaded."),o.strings.customFontDesc||(o.strings.customFontDesc='You can load any font from <a href="https://fonts.google.com/">Google Fonts</a>. Press the red (+) icon next to any font. A bar will appear at the bottom of the page.Press that bar, and under Embed font, copy the full text in the gray box that starts with <link.Now paste that below here and press the load button. The font is loaded and can be previewed.On google fonts, below the embed code, under the section "Specify in CSS", it details how to use the font.'),o.paneButtons||(o.paneButtons={}),o.paneButtons.preset||(o.paneButtons.preset={}),o.paneButtons.custom||(o.paneButtons.custom={}),o.paneButtons.preset.text||(o.paneButtons.preset.text="Preset fonts"),o.paneButtons.custom.text||(o.paneButtons.custom.text="Load font"),void 0===o.paneButtons.preset.show&&(o.paneButtons.preset.show=!0),void 0===o.paneButtons.custom.show&&(o.paneButtons.custom.show=!0),o.fontlist||(o.fontlist=[{name:"Old Standard TT",url:l+"Old+Standard+TT:400,400italic,700"},{name:"Josefin Slab",url:l+"Josefin+Slab:300,400,700"},{name:"Arvo",url:l+"Arvo:400,700"},{name:"Vollkorn",url:l+"Vollkorn:400,700"},{name:"Abril Fatface",url:l+"Abril+Fatface"},{name:"Playfair Display SC",url:l+"Playfair+Display+SC"},{name:"Open Sans",url:l+"Open+Sans:400,700,300,800"},{name:"Lato",url:l+"Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic"},{name:"Ubuntu",url:l+"Ubuntu:300,400,500,700"},{name:"PT Sans",url:l+"PT+Sans:400,700"},{name:"Droid Sans",url:l+"Droid+Sans:400,700"},{name:"Roboto",url:l+"Roboto:400,300,700,900"},{name:"Londrina Solid",url:l+"Londrina+Solid"},{name:"Indie Flower",url:l+"Indie+Flower"},{name:"Nothing You Could Do",url:l+"Nothing+You+Could+Do"},{name:"Dancing Script",url:l+"Dancing+Script"},{name:"Satisfy",url:l+"Satisfy"},{name:"Calligraffitti",url:l+"Calligraffitti"}]),o.fontlist=o.fontlist.map(function(e){return{name:e.name,url:e.url.replace(/^http[s]*:\/\//,"//")}}),r(o.fontlist,"preset"),a.$render(),o.loadError=t(o.strings.loadError),d())});a.$render=function(){var e=!1;return void 0===o.fontlist||void 0===a.$viewValue?!1:(angular.forEach(o.fontlist,function(t){a.$viewValue.url===t.url&&(e=!0)}),void(e?(o.activePane="preset",c.preset=a.$viewValue,c.current=c.preset,o.dropdown=!1):(o.activePane="custom",o.loadCustomFont(a.$viewValue),o.custom.input=a.$viewValue.url)))},o.chooseFont=function(e){return a.$setViewValue({name:e.name,url:e.url}),c.preset=e,c.current=c.preset,o.dropdown=!1,!1},o.loadCustomFont=function(e){return void 0===e&&(e=i(o.custom.input)),e&&e.url?(c.current=c.custom,o.custom.loading=!0,void r([e],"custom").then(function(){a.$setViewValue({name:e.name,url:e.url}),c.custom=e,o.custom.loading=!1,c.current=c.custom})["catch"](function(){a.$setViewValue(),o.modelValues.custom={},o.custom.loading=!1})):!1},o.switchPane=function(e){a.$setViewValue(),o.activePane=e,c.current=c[e],"preset"===e?void 0!==c.preset&&o.chooseFont(c.preset):"custom"===e&&void 0!==c.custom&&o.loadCustomFont(c.custom)},o.togglePreview=function(){o.previewExpanded=!o.previewExpanded},o.addQuotes=function(e){return'"'+e+'"'}}}}]),angular.forEach(["x","y","width","height"],function(e){var t="ng"+e[0].toUpperCase()+e.slice(1);angular.module("schemaFormFontpicker").directive(t,function(){return function(o,n,s){s.$observe(t,function(t){s.$set(e,t)})}})});