1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

Merge branch '2-0-rc1' into dev

This commit is contained in:
cyril 2016-03-24 23:02:42 +01:00
commit 7f99a045c8
29 changed files with 295 additions and 314 deletions

View File

@ -17,7 +17,7 @@ The [issue tracker](https://github.com/LaCasemate/fab-manager/issues) is the pre
[features requests](#features) and [submitting pull requests](#pull-requests), but please respect the following
restrictions:
* Please **do not** use the issue tracker for personal support requests (use [the forum](http://www.fab-manager.com/forum)).
* Please **do not** use the issue tracker for personal support requests (use [the forum](https://forum.fab-manager.com)).
* Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others.

View File

@ -115,8 +115,6 @@ gem 'stripe', '1.30.2'
gem 'recurrence'
gem 'newrelic_rpm'
# PDF
gem 'prawn'
gem 'prawn-table'

View File

@ -242,7 +242,6 @@ GEM
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
netrc (0.10.3)
newrelic_rpm (3.11.1.284)
nokogiri (1.6.6.4)
mini_portile (~> 0.6.0)
notiffany (0.0.6)
@ -497,7 +496,6 @@ DEPENDENCIES
letter_opener
message_format
mini_magick
newrelic_rpm
notify_with
oj
omniauth

View File

@ -6,23 +6,23 @@ FabManager is the FabLab management solution. It is web-based, open-source and t
##### Table of Contents
1. [Software stack](#software-stack)
2. [Contributing](#contributing)
3. [Setup a development environment](#setup-a-development-environment)
3.1. [General Guidelines](#general-guidelines)
3. [Setup a development environment](#setup-a-development-environment)<br/>
3.1. [General Guidelines](#general-guidelines)<br/>
3.2. [Environment Configuration](#environment-configuration)
4. [PostgreSQL](#postgresql)
4.1. [Install PostgreSQL 9.4 on Ubuntu/Debian](#postgresql-on-debian)
4.2. [Install and launch PostgreSQL on MacOS X](#postgresql-on-macosx)
4. [PostgreSQL](#postgresql)<br/>
4.1. [Install PostgreSQL 9.4 on Ubuntu/Debian](#postgresql-on-debian)<br/>
4.2. [Install and launch PostgreSQL on MacOS X](#postgresql-on-macosx)<br/>
4.3. [Setup the FabManager database in PostgreSQL](#setup-fabmanager-in-postgresql)
5. [ElasticSearch](#elasticsearch)
5.1. [Install ElasticSearch on Ubuntu/Debian](#elasticsearch-on-debian)
5.2. [Install ElasticSearch on MacOS X](#elasticsearch-on-macosx)
5. [ElasticSearch](#elasticsearch)<br/>
5.1. [Install ElasticSearch on Ubuntu/Debian](#elasticsearch-on-debian)<br/>
5.2. [Install ElasticSearch on MacOS X](#elasticsearch-on-macosx)<br/>
5.3. [Setup ElasticSearch for the FabManager](#setup-fabmanager-in-elasticsearch)
6. [Internationalization (i18n)](#i18n)
6.1. [Translation](#i18n-translation)
6.1.1. [Front-end translations](#i18n-translation-front)
6.1.2. [Back-end translations](#i18n-translation-back)
6.2. [Configuration](#i18n-configuration)
6.2.1. [Settings](#i18n-settings)
6. [Internationalization (i18n)](#i18n)<br/>
6.1. [Translation](#i18n-translation)<br/>
6.1.1. [Front-end translations](#i18n-translation-front)<br/>
6.1.2. [Back-end translations](#i18n-translation-back)<br/>
6.2. [Configuration](#i18n-configuration)<br/>
6.2.1. [Settings](#i18n-settings)<br/>
6.2.2. [Applying changes](#i18n-apply)
7. [Known issues](#known-issues)
8. [Related Documentation](#related-documentation)
@ -159,7 +159,7 @@ You can generate such a random key by running `rake secret`.
STRIPE_API_KEY & STRIPE_PUBLISHABLE_KEY
Key an secret used to identify you Stripe account through the API.
Key and secret used to identify you Stripe account through the API.
Retrieve them from https://dashboard.stripe.com/account/apikeys.
STRIPE_CURRENCY
@ -525,6 +525,8 @@ After modifying any values concerning the localisation, restart the application
This may happens when the `application.yml` file is missing.
To solve this issue copy `config/application.yml.default` to `config/application.yml`.
This is required before the first start.
- Due to a stripe limitation, you won't be ble to create plans longer than one year.
<a name="related-documentation"></a>

View File

@ -20,7 +20,7 @@ angular.module('application', ['ngCookies', 'ngResource', 'ngSanitize', 'ngAnima
'ui.select', 'ui.calendar', 'angularMoment', 'Devise', 'DeviseModal', 'angular-growl', 'xeditable',
'checklist-model', 'unsavedChanges', 'angular-loading-bar', 'ngTouch', 'angular-google-analytics',
'angularUtils.directives.dirDisqus', 'summernote', 'elasticsearch', 'angular-medium-editor', 'naif.base64',
'minicolors', 'pascalprecht.translate']).
'minicolors', 'pascalprecht.translate', 'ngFitText']).
config(['$httpProvider', 'AuthProvider', "growlProvider", "unsavedWarningsConfigProvider", "AnalyticsProvider", "uibDatepickerPopupConfig", "$provide", "$translateProvider",
function($httpProvider, AuthProvider, growlProvider, unsavedWarningsConfigProvider, AnalyticsProvider, uibDatepickerPopupConfig, $provide, $translateProvider) {

View File

@ -67,6 +67,7 @@
//= require angular-translate-loader-partial/angular-translate-loader-partial
//= require messageformat/messageformat
//= require angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat
//= require ngFitText/dist/ng-FitText.min
//= require_tree ./controllers
//= require_tree ./services
//= require_tree ./directives

View File

@ -207,6 +207,10 @@ Application.Controllers.controller "EditMemberController", ["$scope", "$state",
## The user to edit
$scope.user = memberPromise
## Should the passord be modified?
$scope.password =
change: false
## the user subscription
if $scope.user.subscribed_plan? and $scope.user.subscription?
$scope.subscription = $scope.user.subscription
@ -371,6 +375,10 @@ Application.Controllers.controller "NewMemberController", ["$scope", "$state", "
## Form action on the above URL
$scope.method = 'post'
## Should the passord be set manually or generated?
$scope.password =
change: false
## Default member's profile parameters
$scope.user =
plan_interval: ''

View File

@ -50,6 +50,10 @@ Application.Controllers.controller "EditProfileController", ["$scope", "$rootSco
## mapping of fields to disable
$scope.preventField = {}
## Should the passord be modified?
$scope.password =
change: false
## Angular-Bootstrap datepicker configuration for birthday
$scope.datePicker =
format: $locale.DATETIME_FORMATS.shortDate

View File

@ -112,25 +112,7 @@ Application.Filters.filter "toTrusted", [ "$sce", ($sce) ->
Application.Filters.filter "planIntervalFilter", [ ->
(interval, intervalCount) ->
if typeof intervalCount != 'number'
switch interval
when 'day' then return 'jour'
when 'week' then return 'semaine'
when 'month' then return 'mois'
when 'year' then return 'année'
else
if intervalCount == 1
switch interval
when 'day' then return 'un jour'
when 'week' then return 'une semaine'
when 'month' then return 'un mois'
when 'year' then return 'un an'
else
switch interval
when 'day' then return intervalCount+ ' jours'
when 'week' then return intervalCount+ ' semaines'
when 'month' then return intervalCount+ ' mois'
when 'year' then return intervalCount+ ' ans'
moment.duration(intervalCount, interval).humanize()
]
Application.Filters.filter "humanReadablePlanName", ['$filter', ($filter)->

View File

@ -31,7 +31,7 @@ h5 {
&:after {
position: absolute;
top: 18px;
left: 0px;
left: 0;
content: '';
width: 35%;
height: 1px;
@ -65,7 +65,7 @@ p {
font-family: $font-proxima-condensed;
font-size: rem-calc(16);
line-height: rem-calc(24);
margin: 1.038em 0px 30px 0px;
margin: 1.038em 0 30px 0;
font-weight: 600;
}
}
@ -79,7 +79,7 @@ dd {
}
//
//
// -------------------------
.col-0{clear:left;}
@ -151,7 +151,7 @@ dd {
[ui-view].ng-leave {
opacity: 1;
/*padding-left: 0px;*/
/*padding-left: 0px;*/
// -webkit-transform:translate3d(0, 0, 0);
// -moz-transform:translate3d(0, 0, 0);
// transform:translate3d(0, 0, 0);

View File

@ -220,12 +220,12 @@
.amount {
padding-top: 16px;
font-weight: bold;
font-size: rem-calc(26);
font-size: rem-calc(20);
color: white;
}
.period {
position: relative;
top: -14px;
top: -6px;
font-size: rem-calc(14);
color: white;
}

View File

@ -9,7 +9,7 @@
}
> .btn,
> .btn-group,
> .btn-toolbar,
> .btn-toolbar
{
margin-top: 14px;
}

View File

@ -169,7 +169,7 @@
&:hover,
&:focus,
&:active,
&.active,
&.active
{
> a{
i{
@ -191,7 +191,7 @@
}
li:hover,
li:focus,
li:active,
li:active
{
> ul{
display: block !important;
@ -349,7 +349,7 @@
display: block !important;
position: absolute;
left: 0;
top: 0px;
top: 0;
bottom: 0;
width: $off-screen-nav-width;
visibility: visible;
@ -384,7 +384,7 @@
overflow: hidden;
position: absolute;
width: 100%;
top: 0px;
top: 0;
bottom: 0;
left: 0;
right: 0;

View File

@ -47,7 +47,7 @@
<tr ng-repeat="plan in plans | orderBy:orderPlans">
<td>{{getPlanType(plan.type)}}</td>
<td>{{plan.base_name}}</td>
<td>{{ plan.interval | planIntervalFilter }}</td>
<td>{{ plan.interval | planIntervalFilter:plan.interval_count }}</td>
<td>{{getGroupFromId(groups, plan.group_id).name}}</td>
<td>{{plan.ui_weight}}</td>
<td>{{plan.amount | currency}}</td>

View File

@ -35,7 +35,7 @@
<div class="content">
<div class="wrap">
<div class="price">
<div class="amount">{{plan.amount | currency}}</div>
<div class="amount" data-fittext>{{plan.amount | currency}}</div>
<span class="period">{{ plan.interval | planIntervalFilter: plan.interval_count }}</span>
</div>
</div>

View File

@ -74,7 +74,7 @@
<input type="checkbox"
name="user[is_allow_contact]"
ng-model="user.is_allow_contact"
value="true"/> {{ 'i_authorize_Fablab_users_registered_on_the_site_to_contact_me' }}
value="true"/> {{ 'i_authorize_Fablab_users_registered_on_the_site_to_contact_me' | translate }}
</div>
<!-- accept cgu -->

View File

@ -5,7 +5,7 @@
<div class="row m-t">
<div class="col-sm-3 col-sm-offset-1">
<div class="form-group m-t-lg">
<div class="form-group m-t-lg">
<div class="fileinput text-center" data-provides="fileinput" ng-class="fileinputClass(user.profile.user_avatar.attachment_url)">
<div class="fileinput-new thumbnail rounded thumb-128-wrapper" style="width: 140px; height: 140px;">
<img src="<%= image_path("no_avatar.png") %>" class="img-circle">
@ -123,11 +123,12 @@
<div class="form-group" ng-hide="preventPassword">
<button class="btn btn-warning btn-block"
ng-click="change_password = !change_password; $event.stopPropagation(); $event.preventDefault()" translate>{{ 'change_password' }}</button>
ng-click="password.change = !password.change; $event.stopPropagation(); $event.preventDefault()"
translate>{{ 'change_password' }}</button>
</div>
<div class="form-group" ng-class="{'has-error': userForm['user[password]'].$dirty && userForm['user[password]'].$invalid}" ng-if="change_password">
<div class="form-group" ng-class="{'has-error': userForm['user[password]'].$dirty && userForm['user[password]'].$invalid}" ng-if="password.change">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key"></i> </span>
<input type="password"
@ -143,7 +144,7 @@
<span class="help-block" ng-show="userForm['user[password]'].$dirty && userForm['user[password]'].$error.minlength" translate>{{ 'password_is_too_short_(minimum_8_characters)' }}</span>
</div>
<div class="form-group" ng-class="{'has-error': userForm['user[password_confirmation]'].$dirty && userForm['user[password_confirmation]'].$invalid}" ng-if="change_password">
<div class="form-group" ng-class="{'has-error': userForm['user[password_confirmation]'].$dirty && userForm['user[password_confirmation]'].$invalid}" ng-if="password.change">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key"></i> </span>
<input type="password"

View File

@ -18,44 +18,48 @@
def create
authorize Plan
if plan_params[:type] and plan_params[:type] == 'PartnerPlan'
begin
if plan_params[:type] and plan_params[:type] == 'PartnerPlan'
partner = User.find(params[:plan][:partner_id])
partner = User.find(params[:plan][:partner_id])
if plan_params[:group_id] == 'all'
plans = PartnerPlan.create_for_all_groups(plan_params)
if plans
plans.each { |plan| partner.add_role :partner, plan }
render json: { plan_ids: plans.map(&:id) }, status: :created
else
render status: :unprocessable_entity
end
if plan_params[:group_id] == 'all'
plans = PartnerPlan.create_for_all_groups(plan_params)
if plans
plans.each { |plan| partner.add_role :partner, plan }
render json: { plan_ids: plans.map(&:id) }, status: :created
else
render status: :unprocessable_entity
end
else
@plan = PartnerPlan.new(plan_params)
if @plan.save
partner.add_role :partner, @plan
render :show, status: :created
else
render json: @plan.errors, status: :unprocessable_entity
end
end
else
if plan_params[:group_id] == 'all'
plans = Plan.create_for_all_groups(plan_params)
if plans
render json: { plan_ids: plans.map(&:id) }, status: :created
else
render status: :unprocessable_entity
@plan = PartnerPlan.new(plan_params)
if @plan.save
partner.add_role :partner, @plan
render :show, status: :created
else
render json: @plan.errors, status: :unprocessable_entity
end
end
else
@plan = Plan.new(plan_params)
if @plan.save
render :show, status: :created, location: @plan
if plan_params[:group_id] == 'all'
plans = Plan.create_for_all_groups(plan_params)
if plans
render json: { plan_ids: plans.map(&:id) }, status: :created
else
render status: :unprocessable_entity
end
else
render json: @plan.errors, status: :unprocessable_entity
@plan = Plan.new(plan_params)
if @plan.save
render :show, status: :created, location: @plan
else
render json: @plan.errors, status: :unprocessable_entity
end
end
end
rescue Stripe::InvalidRequestError => e
render json: {error: e.message}, status: :unprocessable_entity
end
end

View File

@ -52,7 +52,8 @@
"angular-translate-loader-partial": "~2.8.1",
"angular-translate-interpolation-messageformat": "~2.8.1",
"messageformat": "=0.1.8",
"moment-timezone": "~0.5.0"
"moment-timezone": "~0.5.0",
"ngFitText": "~4.1.1"
},
"resolutions": {
"jquery": ">=1.10.2",

View File

@ -0,0 +1,3 @@
Devise::Mailer.class_eval do
helper :application
end

View File

@ -65,7 +65,7 @@ en:
name: "Name"
step_N: "Step {{INDEX}}" # angular interpolation
themes: "Themes"
tags: "Tages"
tags: "Tags"
technical_specifications: "Technical specifications"
online_payment: "Online payment"
type: "Type"

View File

@ -1,224 +0,0 @@
#
# This file configures the New Relic Agent. New Relic monitors Ruby, Java,
# .NET, PHP, Python and Node applications with deep visibility and low
# overhead. For more information, visit www.newrelic.com.
#
# Generated December 11, 2014
#
# This configuration file is custom generated for sleede
# Here are the settings that are common to all environments
common: &default_settings
# ============================== LICENSE KEY ===============================
# You must specify the license key associated with your New Relic
# account. This key binds your Agent's data to your account in the
# New Relic service.
license_key: '3394fafbd05532f2f3c4869fd8125f2da4177f72'
# Agent Enabled (Ruby/Rails Only)
# Use this setting to force the agent to run or not run.
# Default is 'auto' which means the agent will install and run only
# if a valid dispatcher such as Mongrel is running. This prevents
# it from running with Rake or the console. Set to false to
# completely turn the agent off regardless of the other settings.
# Valid values are true, false and auto.
#
# agent_enabled: auto
# Application Name Set this to be the name of your application as
# you'd like it show up in New Relic. The service will then auto-map
# instances of your application into an "application" on your
# dashboard page. If you want to map this instance into multiple
# apps, like "AJAX Requests" and "All UI" then specify a semicolon
# separated list of up to three distinct names, or a yaml list.
# Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
# Production, Staging, etc)
#
# Example:
#
# app_name:
# - Ajax Service
# - All Services
#
# Caution: If you change this name, a new application will appear in the New
# Relic user interface with the new name, and data will stop reporting to the
# app with the old name.
#
# See https://newrelic.com/docs/site/renaming-applications for more details
# on renaming your New Relic applications.
#
app_name: FABLAB
# When "true", the agent collects performance data about your
# application and reports this data to the New Relic service at
# newrelic.com. This global switch is normally overridden for each
# environment below. (formerly called 'enabled')
monitor_mode: true
# Developer mode should be off in every environment but
# development as it has very high overhead in memory.
developer_mode: false
# The newrelic agent generates its own log file to keep its logging
# information separate from that of your application. Specify its
# log level here.
log_level: info
# Optionally set the path to the log file This is expanded from the
# root directory (may be relative or absolute, e.g. 'log/' or
# '/var/log/') The agent will attempt to create this directory if it
# does not exist.
# log_file_path: 'log'
# Optionally set the name of the log file, defaults to 'newrelic_agent.log'
# log_file_name: 'newrelic_agent.log'
# The newrelic agent communicates with the service via https by default. This
# prevents eavesdropping on the performance metrics transmitted by the agent.
# The encryption required by SSL introduces a nominal amount of CPU overhead,
# which is performed asynchronously in a background thread. If you'd prefer
# to send your metrics over http uncomment the following line.
# ssl: false
#============================== Browser Monitoring ===============================
# New Relic Real User Monitoring gives you insight into the performance real users are
# experiencing with your website. This is accomplished by measuring the time it takes for
# your users' browsers to download and render your web pages by injecting a small amount
# of JavaScript code into the header and footer of each page.
browser_monitoring:
# By default the agent automatically injects the monitoring JavaScript
# into web pages. Set this attribute to false to turn off this behavior.
auto_instrument: true
# Proxy settings for connecting to the New Relic server.
#
# If a proxy is used, the host setting is required. Other settings
# are optional. Default port is 8080.
#
# proxy_host: hostname
# proxy_port: 8080
# proxy_user:
# proxy_pass:
# The agent can optionally log all data it sends to New Relic servers to a
# separate log file for human inspection and auditing purposes. To enable this
# feature, change 'enabled' below to true.
# See: https://newrelic.com/docs/ruby/audit-log
audit_log:
enabled: false
# Tells transaction tracer and error collector (when enabled)
# whether or not to capture HTTP params. When true, frameworks can
# exclude HTTP parameters from being captured.
# Rails: the RoR filter_parameter_logging excludes parameters
# Java: create a config setting called "ignored_params" and set it to
# a comma separated list of HTTP parameter names.
# ex: ignored_params: credit_card, ssn, password
capture_params: false
# Transaction tracer captures deep information about slow
# transactions and sends this to the New Relic service once a
# minute. Included in the transaction is the exact call sequence of
# the transactions including any SQL statements issued.
transaction_tracer:
# Transaction tracer is enabled by default. Set this to false to
# turn it off. This feature is only available at the Professional
# and above product levels.
enabled: true
# Threshold in seconds for when to collect a transaction
# trace. When the response time of a controller action exceeds
# this threshold, a transaction trace will be recorded and sent to
# New Relic. Valid values are any float value, or (default) "apdex_f",
# which will use the threshold for an dissatisfying Apdex
# controller action - four times the Apdex T value.
transaction_threshold: apdex_f
# When transaction tracer is on, SQL statements can optionally be
# recorded. The recorder has three modes, "off" which sends no
# SQL, "raw" which sends the SQL statement in its original form,
# and "obfuscated", which strips out numeric and string literals.
record_sql: obfuscated
# Threshold in seconds for when to collect stack trace for a SQL
# call. In other words, when SQL statements exceed this threshold,
# then capture and send to New Relic the current stack trace. This is
# helpful for pinpointing where long SQL calls originate from.
stack_trace_threshold: 0.500
# Determines whether the agent will capture query plans for slow
# SQL queries. Only supported in mysql and postgres. Should be
# set to false when using other adapters.
# explain_enabled: true
# Threshold for query execution time below which query plans will
# not be captured. Relevant only when `explain_enabled` is true.
# explain_threshold: 0.5
# Error collector captures information about uncaught exceptions and
# sends them to New Relic for viewing
error_collector:
# Error collector is enabled by default. Set this to false to turn
# it off. This feature is only available at the Professional and above
# product levels.
enabled: true
# To stop specific errors from reporting to New Relic, set this property
# to comma-separated values. Default is to ignore routing errors,
# which are how 404's get triggered.
ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
# If you're interested in capturing memcache keys as though they
# were SQL uncomment this flag. Note that this does increase
# overhead slightly on every memcached call, and can have security
# implications if your memcached keys are sensitive
# capture_memcache_keys: true
# Application Environments
# ------------------------------------------
# Environment-specific settings are in this section.
# For Rails applications, RAILS_ENV is used to determine the environment.
# For Java applications, pass -Dnewrelic.environment <environment> to set
# the environment.
# NOTE if your application has other named environments, you should
# provide newrelic configuration settings for these environments here.
development:
<<: *default_settings
# Turn on communication to New Relic service in development mode
monitor_mode: true
app_name: FABLAB (Development)
# Rails Only - when running in Developer Mode, the New Relic Agent will
# present performance information on the last 100 transactions you have
# executed since starting the mongrel.
# NOTE: There is substantial overhead when running in developer mode.
# Do not use for production or load testing.
developer_mode: true
test:
<<: *default_settings
# It almost never makes sense to turn on the agent when running
# unit, functional or integration tests or the like.
monitor_mode: false
# Turn on the agent in production for 24x7 monitoring. NewRelic
# testing shows an average performance impact of < 5 ms per
# transaction, you can leave this on all the time without
# incurring any user-visible performance degradation.
production:
<<: *default_settings
monitor_mode: true
# Many applications have a staging environment which behaves
# identically to production. Support for that environment is provided
# here. By default, the staging environment has the agent turned on.
staging:
<<: *default_settings
monitor_mode: true
app_name: FABLAB (Staging)

View File

@ -0,0 +1,37 @@
{
"name": "ngFitText",
"version": "4.1.1",
"main": [
"dist/ng-FitText.min.js"
],
"keywords": [
"angular",
"javascript",
"typography"
],
"ignore": [
"demo",
"lib",
"node_modules",
"src",
"test",
".bowerrc",
"gulpfile.js",
"package.json",
"index.html"
],
"dependencies": {
"angular": "1.x"
},
"homepage": "https://github.com/patrickmarabeas/ng-FitText.js",
"_release": "4.1.1",
"_resolution": {
"type": "version",
"tag": "v4.1.1",
"commit": "0af12af4b129c9b9b9bac119e8dfbf105a8f4ade"
},
"_source": "git://github.com/patrickmarabeas/ng-FitText.js.git",
"_target": "~4.1.1",
"_originalSource": "ngFitText",
"_direct": true
}

View File

@ -0,0 +1,3 @@
.idea
lib/
node_modules/

View File

@ -0,0 +1,8 @@
demo
lib
node_modules
test
.bowerrc
bower.json
gulpfile.js
index.html

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Patrick Marabeas
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,108 @@
# ng-FitText.js
### ng-FitText.js makes font-sizes flexible. Use this AngularJS directive in your fluid or responsive layout to achieve scalable headlines that fill the width of a parent element.
This is a rework of the original jQuery plugin which can be found here: https://github.com/davatron5000/FitText.js.
### Install and Inclusion
Grab it with Bower: `bower install ngFitText`
Include it in your AngularJS application
```javascript
var myApp = angular.module('myApp', ['ngFitText']);
```
### Implementation
```html
<!-- basic implementation -->
<h1 data-fittext>FitText</h1>
<!-- dynamic content -->
<h1 data-fittext ></h1>
<!-- setting a minimum font size -->
<h1 data-fittext data-fittext-min="10">FitText</h1>
<!-- minimum font size inherited from CSS -->
<h1 data-fittext data-fittext-min="inherit">FitText</h1>
<!-- setting a maximum font size -->
<h1 data-fittext data-fittext-max="10">FitText</h1>
<!-- maximum font size inherited from CSS -->
<h1 data-fittext data-fittext-max="inherit">FitText</h1>
<!-- combination of restrictions -->
<h1 data-fittext data-fittext-min="10" data-fittext-max="inherit">FitText</h1>
<h1 data-fittext data-fittext-min="inherit" data-fittext-max="100">FitText</h1>
<h1 data-fittext data-fittext-min="10" data-fittext-max="100">FitText</h1>
<!-- block child elements will share smallest font size -->
<div data-fittext>
<div>Short line</div>
<div>Font size of this element will be used</div>
<div>Short</div>
</div>
<!-- inline child elements will behave as a single line of text -->
<span data-fittext>
<span>Single</span>
<span> line of text</span>
<span> spans 100% width</span>
</span>
<!-- Custom fonts may take to load in. A delay can be specified before size is initially calculated -->
<h1 data-fittext data-fittext-load-delay="500">Custom font</h1>
<!-- Custom fonts may ooze out of element; this is the same as the original compressor attr -->
<h1 data-fittext=".9">Custom font</h1>
```
### FitText Config Provider
Because MODULARIZATION, this module doesn't come with debounce functionality included. Instead you will need to specify the functionality in the `fitTextConfigProvider`:
```javascript
module.config(['fitTextConfigProvider', function(fitTextConfigProvider) {
fitTextConfigProvider.config = {
debounce: _.debounce, // include a vender function like underscore or lodash
debounce: function(a,b,c) { // specify your own function
var d;return function(){var e=this,f=arguments;clearTimeout(d),d=setTimeout(function(){d=null,c||a.apply(e,f)},b),c&&!d&&a.apply(e,f)}
},
delay: 1000, // debounce delay
loadDelay: 10, // global default delay before initial calculation
compressor: 1, // global default calculation multiplier
min: 0, // global default min
max: Number.POSITIVE_INFINITY // global default max
};
}]);
```
### Changelog
#### [v4.1.0](https://github.com/patrickmarabeas/ng-FitText.js/releases/tag/v4.1.0)
+ Replace `'initial'` value with more semantic `'inherit'`
+ Both `data-fittext-min` and `data-fittext-max` can use the inherited CSS value by using `'inherit'`
#### [v4.0.0](https://github.com/patrickmarabeas/ng-FitText.js/releases/tag/v4.0.0)
+ `data-fittext-max` can now take `'initial'` as a value to use inherited CSS value. This allows for PX, EM or REM to be used.
+ Line heights are preserved
+ Display property is now preserved
+ New lines no longer need to be specified with an attribute
+ `ng-model` was mistakenly used for `ng-bind` - No longer need to use both `ng-model` and `{{}}` for dynamic values
+ Minified version now delivered via Bower
+ Config provider namespaced to avoid conflicts
#### [v3.0.0](https://github.com/patrickmarabeas/ng-FitText.js/releases/tag/v3.0.0)
+ Element now defaults to 100% width
+ Compressor now fine tunes from this point
+ Debounce functionality now needs to be passed in via fitTextConfigProvider
#### < v2.4.0
+ Specifying a value for data-fittext allows you to fine tune the text size. Defaults to 1. Increasing this number (ie 1.5) will resize the text more aggressively. Decreasing this number (ie 0.5) will reduce the aggressiveness of resize. data-fittext-min and data-fittext-max allow you to set upper and lower limits.
+ The element needs to either be a block element or an inline-block element with a width specified (% or px).
+ Font sizes can be limited with `data-fittext-max` and `data-fittext-max`
+ Debouncing addded

View File

@ -0,0 +1,26 @@
{
"name": "ngFitText",
"version": "4.1.1",
"main": [
"dist/ng-FitText.min.js"
],
"keywords": [
"angular",
"javascript",
"typography"
],
"ignore": [
"demo",
"lib",
"node_modules",
"src",
"test",
".bowerrc",
"gulpfile.js",
"package.json",
"index.html"
],
"dependencies": {
"angular": "1.x"
}
}

View File

@ -0,0 +1 @@
!function(t,e,i,n){"use strict";i.module("ngFitText",[]).value("fitTextDefaultConfig",{debounce:!1,delay:250,loadDelay:10,compressor:1,min:0,max:Number.POSITIVE_INFINITY}).directive("fittext",["$timeout","fitTextDefaultConfig","fitTextConfig",function(e,n,o){return{restrict:"A",scope:!0,link:function(f,a,l){function r(){var t=T*h/s.offsetWidth/h;return Math.max(Math.min((c[0].offsetWidth-6)*t*p,parseFloat(y)),parseFloat(m))}function u(){s.offsetHeight*s.offsetWidth!==0&&(d.fontSize=T+"px",d.lineHeight="1",d.display="inline-block",d.fontSize=r()+"px",d.lineHeight=b,d.display=v)}i.extend(n,o.config);var c=a.parent(),s=a[0],d=s.style,x=t.getComputedStyle(a[0],null),h=a.children().length||1,g=l.fittextLoadDelay||n.loadDelay,p=l.fittext||n.compressor,m=("inherit"===l.fittextMin?x["font-size"]:l.fittextMin)||n.min,y=("inherit"===l.fittextMax?x["font-size"]:l.fittextMax)||n.max,b=x["line-height"],v=x.display,T=10;e(function(){u()},g),f.$watch(l.ngBind,function(){u()}),n.debounce?i.element(t).bind("resize",n.debounce(function(){f.$apply(u)},n.delay)):i.element(t).bind("resize",function(){f.$apply(u)})}}}]).provider("fitTextConfig",function(){var t=this;return this.config={},this.$get=function(){var e={};return e.config=t.config,e},this})}(window,document,angular);