Example #1
0
		value: function updateLocale(locale) {
			locale = this.getLocale(locale);
			moment.updateLocale(locale.name, locale);
			moment.locale(locale.name);
		}
Example #2
0
});

// UTC offsets
let n: number;
n = moment().utcOffset();
n = moment().utcOffset(0).utcOffset();
n = moment().utcOffset(-1.5).utcOffset();
n = moment().utcOffset(-90).utcOffset();
n = moment().utcOffset("-01:30").utcOffset();
n = moment().utcOffset("+00:10").utcOffset();

// Optional 2nd and 3rd arguments
n = moment().utcOffset(0, true).utcOffset();
n = moment().utcOffset(0, false).utcOffset();
n = moment().utcOffset(0, true, true).utcOffset();

const getLocale: string = moment.locale();
const setLocale: string = moment.locale("en");
const setArrayLocale: string = moment.locale(["en", "de"]);

// Locales
const localeData = moment().locale('fr').localeData();

// Customize
moment.defineLocale('fakeLocale');
moment.defineLocale('fakeLocale', { parentLocale: 'xyz' });
// $ExpectError
moment.defineLocale('fakeLocale', 'not an object');
// $ExpectError
moment.defineLocale(); // no arguments
Example #3
0
const {formattedTimeFromNow, formattedDateFromTimestamp} = require('../../../../common/lib/ledgerUtil')
const appUrlUtil = require('../../../../../js/lib/appUrlUtil')

// components
const BrowserButton = require('../../common/browserButton')
const ImmutableComponent = require('../../immutableComponent')

// style
const globalStyles = require('../../styles/global')
const {paymentStylesVariables} = require('../../styles/payment')

// other
const aboutUrls = appUrlUtil.aboutUrls
const aboutContributionsUrl = aboutUrls.get('about:contributions')
const moment = require('moment')
moment.locale(navigator.language)

class HistoryContent extends ImmutableComponent {
  render () {
    const transactions = Immutable.fromJS(
      addExportFilenamePrefixToTransactions(this.props.ledgerData.get('transactions').toJS())
    )

    return <table className={css(styles.paymentHistoryTable)}>
      <thead className={css(styles.headerContainer__wrapper)}>
        <tr className={css(styles.flex, styles.headerContainer)}>
          <th className={css(styles.header, styles.column, styles.leftRow, styles.column__narrow)} data-l10n-id='date' />
          <th className={css(styles.header, styles.column, styles.column__narrow)} data-l10n-id='totalAmount' />
          <th className={css(styles.header, styles.column, styles.column__wide)} data-l10n-id='receiptLink' />
        </tr>
      </thead>
Example #4
0
const express = require("express");
const moment = require("moment");
const path = require("path");
//const cons = require('consolidate');
const nunjucks = require('nunjucks');
const database = require("./database");
const morgan = require("morgan");
const loggerLib = require("./logger");
const logger = loggerLib.logger;
const loggerStream = loggerLib.loggerStream;
const config = require("./config");

const router = require("./router");

moment.locale("es");

const app = express();
module.exports.app = app;

/**********************************************************************************************************************
 * Logger
 **********************************************************************************************************************/
loggerLib.configurate(config.log);
logger.debug("Overriding 'Express' logger");
app.use(morgan("combined",{ "stream": loggerStream }));


/**********************************************************************************************************************
 * Se conecta a la base de datos
 **********************************************************************************************************************/
module.exports = function (pox, offset) {

    var _items = pox.items.map(po => {
        return po.items.map(poItem => {
            // var productName = [poItem.product.name, po.refNo].filter(r => r && r.toString().trim() != '').join("\n");
            return {
                product: poItem.product.name,
                prNo: po.refNo,
                quantity: poItem.dealQuantity,
                uom: poItem.dealUom.unit,
                price: poItem.pricePerDealUnit,
                remark: poItem.remark
            };
        });
    });

    _items = [].concat.apply([], _items);

    var items = [];
    var map = new Map();
    for (var _item of _items) {
        var key = _item.product;
        if (!map.has(key))
            map.set(key, [])
        map.get(key).push(_item);
    }
    map.forEach((_items, product) => {
        var poeItem = {};
        poeItem.product = product;
        poeItem.quantity = _items
            .map(_item => _item.quantity)
            .reduce((prev, curr, index) => {
                return prev + curr;
            }, 0);
        var prNos = [];
        _items
            .map(function (_item) {
                if (_item.prNo != "") {
                    prNos.push(_item.prNo);
                }
            })
        poeItem.prNo = prNos.join("\n");
        poeItem.uom = _items[0].uom;
        poeItem.price = _items[0].price;

        var remaks = [];
        _items
            .map(function (_item) {
                if (_item.remark != "") {
                    remaks.push(_item.remark);
                }
            })
        poeItem.remark = remaks.join("\n");
        items.push(poeItem);
    });


    var iso = "FM-PB-00-06-009/R1";
    var number = pox.no;
    var currency = pox.currency.code;
    var supplier = pox.supplier.name;
    var supplierAtt = pox.supplier.PIC;
    var supplierTel = pox.supplier.contact;

    var locale = global.config.locale;

    var moment = require('moment');
    moment.locale(locale.name);

    var header = [{
        text: 'PT. DAN LIRIS',
        style: 'bold'
    }, {
            columns: [{
                width: '50%',
                stack: [
                    'Head Office   : ',
                    'Kelurahan Banaran',
                    'Kecamatan Grogol',
                    'Sukoharjo 57193 - INDONESIA',
                    'PO.BOX 166 Solo 57100',
                    'Telp. (0271) 740888, 714400',
                    'Fax. (0271) 735222, 740777'
                ],
                style: ['size07', 'bold']
            }, {
                    stack: [{
                        text: iso,
                        alignment: "right",
                        style: ['size08']
                    }, {
                            text: `Nomor PO : ${number}`,
                            alignment: "right",
                            style: ['size09', 'bold']
                        }]

                }

            ]
        }, {
            alignment: "center",
            text: 'ORDER PEMBELIAN',
            style: ['size09', 'bold']
        },
        '\n'
    ];

    var attention = [{
        columns: [{
            width: '15%',
            text: 'Kepada Yth:',
            style: ['size08']
        }, {
                width: '*',
                text: `${supplier}\n Attn. ${supplierAtt}\n Telp. ${supplierTel}`,
                style: ['size08']
            }, {
                width: '35%',
                stack: [
                    `Sukoharjo, ${moment(pox.date).add(offset,'h').add(offset,'h').format(locale.date.format)} `, {
                        text: [
                            'Mohon', {
                                text: ' di-fax kembali',
                                style: 'bold'
                            }, ' setelah\n', {
                                text: 'ditandatangani',
                                style: ['bold'],
                                decoration: 'underline'
                            }, ' dan ', {
                                text: 'distempel ',
                                style: ['bold'],
                                decoration: 'underline'
                            }, 'perusahaan.Terima Kasih.'
                        ],
                        style: ['size07']
                    }
                ],
                style: ['size08']
            }]
    }];

    var opening = {
        text: [
            '\n', {
                text: 'Dengan hormat,\n'
            }, {
                text: 'Yang bertanda tangan di bawah ini, '
            }, {
                text: 'PT. DAN LIRIS, SOLO',
                style: ['bold']
            }, {
                text: ' (selanjutnya disebut sebagai pihak Pembeli) dan '
            }, {
                text: supplier,
                style: ['bold']
            }, {
                text: ' (selanjutnya disebut sebagai pihak Penjual) saling menyetujui untuk mengadakan kontrak jual beli dengan ketentuan sebagai berikut: '
            },
            '\n\n'
        ],
        style: ['size09', 'justify']
    };

    var thead = [{
        text: 'NAMA DAN JENIS BARANG',
        style: ['size08', 'bold', 'center']
    }, {
            text: 'JUMLAH',
            style: ['size08', 'bold', 'center']
        }, {
            text: 'HARGA SATUAN',
            style: ['size08', 'bold', 'center']
        }, {
            text: 'SUB TOTAL',
            style: ['size08', 'bold', 'center']
        }];

    var tbody = items.map(function (item) {
        return [{
            stack: [{
                text: item.product,
                style: 'bold'
            }, item.remark, item.prNo],
            style: ['size08']
        }, {
                text: parseFloat(item.quantity).toLocaleString(locale, locale.decimal) + ' ' + item.uom,
                style: ['size08', 'center']
            }, {
                columns: [{
                    width: '30%',
                    text: `${currency}`
                }, {
                        width: '*',
                        text: `${parseFloat(item.price).toLocaleString(locale, locale.currency)}`,
                        style: ['right']
                    }],
                style: ['size08']
            }, {
                columns: [{
                    width: '20%',
                    text: `${currency}`
                }, {
                        width: '*',
                        text: `${parseFloat(item.quantity * item.price).toLocaleString(locale, locale.currency)}`,
                        style: ['right']
                    }],
                style: ['size08']
            }];
    });

    tbody = tbody.length > 0 ? tbody : [
        [{
            text: "tidak ada barang",
            style: ['size08', 'center'],
            colSpan: 4
        }, "", "", ""]
    ];
    var initialValue = {
        price: 0,
        quntity: 0
    };

    var sum = (items.length > 0 ? items : [initialValue])
        .map(item => item.price * item.quantity)
        .reduce(function (prev, curr, index, arr) {
            return prev + curr;
        }, 0);

    var vat = pox.useIncomeTax ? sum * 0.1 : 0;

    var tfoot = [
        [{
            text: 'Jumlah',
            style: ['size08', 'bold', 'right'],
            colSpan: 3
        }, "", "", {
                columns: [{
                    width: '20%',
                    text: currency
                }, {
                        width: '*',
                        text: parseFloat(sum).toLocaleString(locale, locale.currency),
                        style: ['right']
                    }],
                style: ['size08']
            }],
        [{
            text: 'PPN 10%',
            style: ['size08', 'bold', 'right'],
            colSpan: 3
        }, null, null, {
                columns: [{
                    width: '20%',
                    text: currency
                }, {
                        width: '*',
                        text: parseFloat(vat).toLocaleString(locale, locale.currency),
                        style: ['right']
                    }],
                style: ['size08']
            }],
        [{
            text: 'Grand Total',
            style: ['size08', 'bold', 'right'],
            colSpan: 3
        }, null, null, {
                columns: [{
                    width: '20%',
                    text: currency
                }, {
                        width: '*',
                        text: parseFloat(sum + vat).toLocaleString(locale, locale.currency),
                        style: ['bold', 'right']
                    }],
                style: ['size09']
            }]
    ];

    var table = [{
        table: {
            widths: ['*', '15%', '20%', '25%'],
            headerRows: 1,
            body: [].concat([thead], tbody, tfoot)
        }
    }];
    var footer = [
        '\n', {
            stack: [{
                columns: [{
                    width: '40%',
                    columns: [{
                        width: '40%',
                        stack: ['Ongkos Kirim', 'Pembayaran']
                    }, {
                            width: '3%',
                            stack: [':', ':']
                        }, {
                            width: '*',
                            stack: [`Ditanggung ${pox.freightCostBy}`, `${pox.paymentMethod}, ${pox.paymentDueDays} hari setelah terima barang`]
                        }]
                }, {
                        width: '20%',
                        text: ''
                    }, {
                        width: '40%',
                        columns: [{
                            width: '45%',
                            stack: ['Delivery', 'Lain-lain']
                        }, {
                                width: '3%',
                                stack: [':', ':']
                            }, {
                                width: '*',
                                stack: [{
                                    text: `${moment(pox.expectedDeliveryDate).add(offset,'h').format(locale.date.format)}`,
                                    style: ['bold']
                                }, `${pox.remark}`]
                            }]
                    }]
            },
                '\n\n\n', {
                    columns: [{
                        width: '35%',
                        stack: ['Pembeli\n\n\n\n\n', {
                            text: pox._createdBy,
                            style: ['bold']
                        }],
                        style: 'center'
                    }, {
                            width: '30%',
                            text: ''
                        }, {
                            width: '35%',
                            stack: ['Penjual\n\n\n\n\n', {
                                text: supplier,
                                style: ['bold']
                            }],
                            style: 'center'
                        }]
                }
            ],
            style: ['size08']
        }
    ];

    var dd = {
        pageSize: 'A5',
        pageOrientation: 'portrait',
        pageMargins: 20,
        content: [].concat(header, attention, opening, table, footer),
        styles: {
            size06: {
                fontSize: 6
            },
            size07: {
                fontSize: 7
            },
            size08: {
                fontSize: 8
            },
            size09: {
                fontSize: 9
            },
            size10: {
                fontSize: 10
            },
            bold: {
                bold: true
            },
            center: {
                alignment: 'center'
            },
            left: {
                alignment: 'left'
            },
            right: {
                alignment: 'right'
            },
            justify: {
                alignment: 'justify'
            }
        }
    };

    return dd;
};
Example #6
0
import Ember from 'ember';
import moment from 'moment';
import getOwner from 'ember-getowner-polyfill';
import { moduleFor, test } from 'ember-qunit';
import fromNow from 'ember-moment/computeds/from-now';
import momentComputed from 'ember-moment/computeds/moment';

moduleFor('ember-moment@computed:from-now', {
  setup() {
    this.register('object:empty', Ember.Object.extend({}));
    moment.locale('en');
  }
});

function createSubject(attrs) {
  return getOwner(this).resolveRegistration('object:empty').extend(Ember.$.extend(attrs, {
    container: this.container,
    registry: this.registry
  })).create();
}

test('get', function(assert) {
  assert.expect(1);
  const subject = createSubject.call(this, {
    date: moment().subtract(1, 'hour'),
    ago: fromNow('date')
  });
  assert.equal(subject.get('ago'), 'an hour ago');
});

test('get and set', function(assert) {
module.exports = function (unitPaymentCorrection, offset) {

    var items = unitPaymentCorrection.items.map((item) => {
        return {
            quantity: item.quantity,
            uom: item.uom,
            product: item.product,
            pricePerUnit: item.pricePerUnit,
            priceTotal: item.priceTotal
        };
    });

    items = [].concat.apply([], items);

    var currency = unitPaymentCorrection.items.find(r => true).currency.code;

    var locale = global.config.locale;

    var moment = require('moment');
    moment.locale(locale.name);

    var numberLocaleOptions = {
        style: 'decimal',
        maximumFractionDigits: 4

    };
    var header = [
        {
            text: 'NOTA RETUR',
            style: ['size11', 'center']
        }, '\n',
        {
            stack: [
                `Nomor : ${unitPaymentCorrection.returNoteNo}`,
                `(Atas Faktur Pajak Nomor : ${unitPaymentCorrection.unitPaymentOrder.incomeTaxNo} Tanggal : ${moment(unitPaymentCorrection.unitPaymentOrder.incomeTaxDate).add(offset, 'h').format(locale.date.format)})`
            ],
            style: ['size09', 'center']

        }
    ];

    var line = [
        {
            canvas: [{
                type: 'line',
                x1: 0,
                y1: 5,
                x2: 378,
                y2: 5,
                lineWidth: 0.5
            }
            ]
        }, '\n'
    ];

    var subHeaderDanliris = [
        {
            text: 'Pembeli BKP',
            style: ['size09', 'bold']
        },
        {
            columns: [{
                width: '10%',
                text: 'Nama',
                style: ['size09']
            }, {
                width: '3%',
                text: ':',
                style: ['size09']
            }, {
                width: '*',
                text: 'PT EFRATA RETAILINDO',
                style: ['size09']
            }]
        },
        {
            columns: [{
                width: '10%',
                text: 'Alamat',
                style: ['size09']
            }, {
                width: '3%',
                text: ':',
                style: ['size09']
            }, {
                width: '*',
                text: 'Banaran, Grogol, Sukoharjo',
                style: ['size09']
            }]
        },
        {
            columns: [{
                width: '10%',
                text: 'N P W P',
                style: ['size09']
            }, {
                width: '3%',
                text: ':',
                style: ['size09']
            }, {
                width: '*',
                text: '01.139.907.8 - 532.000',
                style: ['size09']
            }]
        }
    ];

    var subHeaderSupplier = [
        {
            text: 'Kepada Penjual',
            style: ['size09', 'bold']
        },
        {
            columns: [{
                width: '10%',
                text: 'Nama',
                style: ['size09']
            }, {
                width: '3%',
                text: ':',
                style: ['size09']
            }, {
                width: '*',
                text: `${unitPaymentCorrection.unitPaymentOrder.supplier.name}`,
                style: ['size09']
            }]
        },
        {
            columns: [{
                width: '10%',
                text: 'Alamat',
                style: ['size09']
            }, {
                width: '3%',
                text: ':',
                style: ['size09']
            }, {
                width: '*',
                text: `${unitPaymentCorrection.unitPaymentOrder.supplier.address}`,
                style: ['size09']
            }]
        },
        {
            columns: [{
                width: '10%',
                text: 'N P W P',
                style: ['size09']
            }, {
                width: '3%',
                text: ':',
                style: ['size09']
            }, {
                width: '*',
                text: `${unitPaymentCorrection.unitPaymentOrder.supplier.NPWP}`,
                style: ['size09']
            }]
        }
    ];

    var thead = [
        {
            text: 'No.',
            style: 'tableHeader'
        }, {
            text: 'Macam dan Jenis BKP',
            style: 'tableHeader'
        }, {
            text: 'Kuantum',
            style: 'tableHeader'
        }, {
            text: 'Harga Satuan Menurut Faktur Pajak',
            style: 'tableHeader'
        }, {
            text: 'Harga Jual BKP',
            style: 'tableHeader'
        }
    ];

    var tbody = items.map(function (item, index) {
        return [{
            text: (index + 1).toString() || '',
            style: ['size08', 'center']
        }, {
            text: item.product.name,
            style: ['size08', 'left']
        }, {
            text: `${item.quantity} ${item.uom.unit}`,
            style: ['size08', 'right']
        }, {
            columns: [{
                width: '20%',
                text: currency,
                style: ['size08']
            }, {
                width: '*',
                text: parseFloat(item.pricePerUnit).toLocaleString(locale, locale.currency),
                style: ['size08', 'right']
            }]
        }, {
            columns: [{
                width: '20%',
                text: currency,
                style: ['size08']
            }, {
                width: '*',
                text: parseFloat(item.priceTotal).toLocaleString(locale, locale.currency),
                style: ['size08', 'right']
            }]
        }];
    });

    tbody = tbody.length > 0 ? tbody : [
        [{
            text: "tidak ada data",
            style: ['size08', 'center'],
            colSpan: 5
        }, "", "", "", ""]
    ];

    var initialValue = {
        priceTotal: 0
    };
    var sum = (items.length > 0 ? items : [initialValue])
        .map(item => item.priceTotal)
        .reduce(function (prev, curr, index, arr) {
            return prev + curr;
        }, 0);

    var vatTax = sum * 0.1;

    var tfoot = [
        [{
            text: 'Jumlah Harga Jual BKP yang dikembalikan',
            style: ['size07', 'left'],
            colSpan: 4
        }, null, null, null, {
            columns: [{
                width: '20%',
                text: currency
            }, {
                width: '*',
                text: parseFloat(sum).toLocaleString(locale, locale.currency),
                style: ['right']
            }],
            style: ['size07']
        }],
        [{
            text: 'PPN yang diminta kembali',
            style: ['size07', 'left'],
            colSpan: 4
        }, null, null, null, {
            columns: [{
                width: '20%',
                text: currency
            }, {
                width: '*',
                text: parseFloat(vatTax).toLocaleString(locale, locale.currency),
                style: ['right']
            }],
            style: ['size07']
        }],
        [{
            stack: [
                '\n',
                `Sukoharjo, ${moment(unitPaymentCorrection.date).format(locale.date.format)}`,
                '\n\n\n\n',
                '_____________________________',
                '\n'
            ],
            colSpan: 5,
            style: ['size08', 'right']
        }, null, null, null, null
        ],
        [{
            stack: [{
                text: 'Lembar ke-1 : untuk PKP Penjual',
                style: ['size07']
            }, {
                text: 'Lembar ke-2 : untuk Pembeli',
                style: ['size07']
            }, {
                text: 'Lembar ke-3 : untuk LPP tempat Pembeli terdaftar (dalam hal Pembeli bukan PKP',
                style: ['size07']
            }
            ],
            colSpan: 5,
            style: ['size07', 'left']
        }, null, null, null, null
        ],
        [{
            text: ' ',
            colSpan: 5
        }, null, null, null, null]
    ];

    var table = [{
        table: {
            widths: ['5%', '30%', '15%', '25%', '25%'],
            headerRows: 1,
            body: [].concat([thead], tbody, tfoot)
        }
    }];

    var dd = {
        pageSize: 'A5',
        pageOrientation: 'portrait',
        pageMargins: 20,
        content: [].concat(header, line, subHeaderDanliris, '\n', subHeaderSupplier, '\n', table),
        styles: {
            size06: {
                fontSize: 6
            },
            size07: {
                fontSize: 7
            },
            size08: {
                fontSize: 8
            },
            size09: {
                fontSize: 9
            },
            size10: {
                fontSize: 10
            },
            size11: {
                fontSize: 11
            },
            size15: {
                fontSize: 15
            },
            bold: {
                bold: true
            },
            center: {
                alignment: 'center'
            },
            left: {
                alignment: 'left'
            },
            right: {
                alignment: 'right'
            },
            justify: {
                alignment: 'justify'
            },
            tableHeader: {
                bold: true,
                fontSize: 8,
                color: 'black',
                alignment: 'center'
            }
        }
    }

    return dd;
}
Example #8
0
import React, { Component, PropTypes } from 'react';
import {StyleSheet, TouchableOpacity, View, Text, Image} from "react-native";

import moment from 'moment';
import localeZh from 'moment/locale/zh-cn';
import { avatar_process } from '../Common/Base';
import { BorderStyles, ImageStyles } from '../Common/Styles';

moment.locale('zh-cn', localeZh);

export default class CommentItem extends Component {
    static defaultProps = {
        relatedTime: false,
    }
    
    static propTypes = {
        rowData: PropTypes.shape({
            id: PropTypes.string,
            content: PropTypes.string,
            area: PropTypes.string,
            score: PropTypes.number,
            avatar: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
            datetime: PropTypes.string,
        }).isRequired,
        relatedTime: PropTypes.bool,
    }
    
    render() {
        let datetime = this.props.relatedTime ? 
                        moment(this.props.rowData.datetime, 'YYYY-MM-DD HH:mm:ss').fromNow()
                        : this.props.rowData.datetime;
Example #9
0
 ConvertStringToInt(str) {
     Moment.locale('en');
     str = Moment(str).format('YYYYMMDD')
     return str;
 }
Example #10
0
File: app.js Project: AlusaChen/oa
require(['jquery', 'bootstrap', 'icheck', 'select2', 'daterangepicker', 'bootstrap-timepicker', 'bootstrap-datepicker'], function(){

    /*! AdminLTE app.js
     * ================
     * Main JS application file for AdminLTE v2. This file
     * should be included in all pages. It controls some layout
     * options and implements exclusive AdminLTE plugins.
     *
     * @Author  Almsaeed Studio
     * @Support <http://www.almsaeedstudio.com>
     * @Email   <*****@*****.**>
     * @version 2.3.3
     * @license MIT <http://opensource.org/licenses/MIT>
     */

    //Make sure jQuery has been loaded before app.js
    if (typeof jQuery === "undefined") {
        throw new Error("AdminLTE requires jQuery");
    }

    /* AdminLTE
     *
     * @type Object
     * @description $.AdminLTE is the main object for the template's app.
     *              It's used for implementing functions and options related
     *              to the template. Keeping everything wrapped in an object
     *              prevents conflict with other plugins and is a better
     *              way to organize our code.
     */
    $.AdminLTE = {};

    /* --------------------
     * - AdminLTE Options -
     * --------------------
     * Modify these options to suit your implementation
     */
    $.AdminLTE.options = {
        //Add slimscroll to navbar menus
        //This requires you to load the slimscroll plugin
        //in every page before app.js
        navbarMenuSlimscroll: true,
        navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
        navbarMenuHeight: "200px", //The height of the inner menu
        //General animation speed for JS animated elements such as box collapse/expand and
        //sidebar treeview slide up/down. This options accepts an integer as milliseconds,
        //'fast', 'normal', or 'slow'
        animationSpeed: 500,
        //Sidebar push menu toggle button selector
        sidebarToggleSelector: "[data-toggle='offcanvas']",
        //Activate sidebar push menu
        sidebarPushMenu: true,
        //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
        sidebarSlimScroll: true,
        //Enable sidebar expand on hover effect for sidebar mini
        //This option is forced to true if both the fixed layout and sidebar mini
        //are used together
        sidebarExpandOnHover: false,
        //BoxRefresh Plugin
        enableBoxRefresh: true,
        //Bootstrap.js tooltip
        enableBSToppltip: true,
        BSTooltipSelector: "[data-toggle='tooltip']",
        //Enable Fast Click. Fastclick.js creates a more
        //native touch experience with touch devices. If you
        //choose to enable the plugin, make sure you load the script
        //before AdminLTE's app.js
        enableFastclick: true,
        //Control Sidebar Options
        enableControlSidebar: true,
        controlSidebarOptions: {
            //Which button should trigger the open/close event
            toggleBtnSelector: "[data-toggle='control-sidebar']",
            //The sidebar selector
            selector: ".control-sidebar",
            //Enable slide over content
            slide: true
        },
        //Box Widget Plugin. Enable this plugin
        //to allow boxes to be collapsed and/or removed
        enableBoxWidget: true,
        //Box Widget plugin options
        boxWidgetOptions: {
            boxWidgetIcons: {
                //Collapse icon
                collapse: 'fa-minus',
                //Open icon
                open: 'fa-plus',
                //Remove icon
                remove: 'fa-times'
            },
            boxWidgetSelectors: {
                //Remove button selector
                remove: '[data-widget="remove"]',
                //Collapse button selector
                collapse: '[data-widget="collapse"]'
            }
        },
        //Direct Chat plugin options
        directChat: {
            //Enable direct chat by default
            enable: true,
            //The button to open and close the chat contacts pane
            contactToggleSelector: '[data-widget="chat-pane-toggle"]'
        },
        //Define the set of colors to use globally around the website
        colors: {
            lightBlue: "#3c8dbc",
            red: "#f56954",
            green: "#00a65a",
            aqua: "#00c0ef",
            yellow: "#f39c12",
            blue: "#0073b7",
            navy: "#001F3F",
            teal: "#39CCCC",
            olive: "#3D9970",
            lime: "#01FF70",
            orange: "#FF851B",
            fuchsia: "#F012BE",
            purple: "#8E24AA",
            maroon: "#D81B60",
            black: "#222222",
            gray: "#d2d6de"
        },
        //The standard screen sizes that bootstrap uses.
        //If you change these in the variables.less file, change
        //them here too.
        screenSizes: {
            xs: 480,
            sm: 768,
            md: 992,
            lg: 1200
        }
    };

    /* ------------------
     * - Implementation -
     * ------------------
     * The next block of code implements AdminLTE's
     * functions and plugins as specified by the
     * options above.
     */
    $(function () {
        "use strict";

        //Fix for IE page transitions
        $("body").removeClass("hold-transition");

        //Extend options if external options exist
        if (typeof AdminLTEOptions !== "undefined") {
            $.extend(true,
                $.AdminLTE.options,
                AdminLTEOptions);
        }

        //Easy access to options
        var o = $.AdminLTE.options;

        //Set up the object
        _init();

        //Activate the layout maker
        $.AdminLTE.layout.activate();

        //Enable sidebar tree view controls
        $.AdminLTE.tree('.sidebar');

        //Enable control sidebar
        if (o.enableControlSidebar) {
            $.AdminLTE.controlSidebar.activate();
        }

        //Add slimscroll to navbar dropdown
        if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
            $(".navbar .menu").slimscroll({
                height: o.navbarMenuHeight,
                alwaysVisible: false,
                size: o.navbarMenuSlimscrollWidth
            }).css("width", "100%");
        }

        //Activate sidebar push menu
        if (o.sidebarPushMenu) {
            $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
        }

        //Activate Bootstrap tooltip
        if (o.enableBSToppltip) {
            $('body').tooltip({
                selector: o.BSTooltipSelector
            });
        }

        //Activate box widget
        if (o.enableBoxWidget) {
            $.AdminLTE.boxWidget.activate();
        }

        //Activate fast click
        if (o.enableFastclick && typeof FastClick != 'undefined') {
            FastClick.attach(document.body);
        }

        //Activate direct chat widget
        if (o.directChat.enable) {
            $(document).on('click', o.directChat.contactToggleSelector, function () {
                var box = $(this).parents('.direct-chat').first();
                box.toggleClass('direct-chat-contacts-open');
            });
        }

        /*
         * INITIALIZE BUTTON TOGGLE
         * ------------------------
         */
        $('.btn-group[data-toggle="btn-toggle"]').each(function () {
            var group = $(this);
            $(this).find(".btn").on('click', function (e) {
                group.find(".btn.active").removeClass("active");
                $(this).addClass("active");
                e.preventDefault();
            });

        });
    });

    /* ----------------------------------
     * - Initialize the AdminLTE Object -
     * ----------------------------------
     * All AdminLTE functions are implemented below.
     */
    function _init() {
        'use strict';
        /* Layout
         * ======
         * Fixes the layout height in case min-height fails.
         *
         * @type Object
         * @usage $.AdminLTE.layout.activate()
         *        $.AdminLTE.layout.fix()
         *        $.AdminLTE.layout.fixSidebar()
         */
        $.AdminLTE.layout = {
            activate: function () {
                var _this = this;
                _this.fix();
                _this.fixSidebar();
                $(window, ".wrapper").resize(function () {
                    _this.fix();
                    _this.fixSidebar();
                });
            },
            fix: function () {
                //Get window height and the wrapper height
                var neg = $('.main-header').outerHeight() + $('.main-footer').outerHeight();
                var window_height = $(window).height();
                var sidebar_height = $(".sidebar").height();
                //Set the min-height of the content and sidebar based on the
                //the height of the document.
                if ($("body").hasClass("fixed")) {
                    $(".content-wrapper, .right-side").css('min-height', window_height - $('.main-footer').outerHeight());
                } else {
                    var postSetWidth;
                    if (window_height >= sidebar_height) {
                        $(".content-wrapper, .right-side").css('min-height', window_height - neg);
                        postSetWidth = window_height - neg;
                    } else {
                        $(".content-wrapper, .right-side").css('min-height', sidebar_height);
                        postSetWidth = sidebar_height;
                    }

                    //Fix for the control sidebar height
                    var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
                    if (typeof controlSidebar !== "undefined") {
                        if (controlSidebar.height() > postSetWidth)
                            $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
                    }

                }
            },
            fixSidebar: function () {
                //Make sure the body tag has the .fixed class
                if (!$("body").hasClass("fixed")) {
                    if (typeof $.fn.slimScroll != 'undefined') {
                        $(".sidebar").slimScroll({destroy: true}).height("auto");
                    }
                    return;
                } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
                    window.console.error("Error: the fixed layout requires the slimscroll plugin!");
                }
                //Enable slimscroll for fixed layout
                if ($.AdminLTE.options.sidebarSlimScroll) {
                    if (typeof $.fn.slimScroll != 'undefined') {
                        //Destroy if it exists
                        $(".sidebar").slimScroll({destroy: true}).height("auto");
                        //Add slimscroll
                        $(".sidebar").slimscroll({
                            height: ($(window).height() - $(".main-header").height()) + "px",
                            color: "rgba(0,0,0,0.2)",
                            size: "3px"
                        });
                    }
                }
            }
        };

        /* PushMenu()
         * ==========
         * Adds the push menu functionality to the sidebar.
         *
         * @type Function
         * @usage: $.AdminLTE.pushMenu("[data-toggle='offcanvas']")
         */
        $.AdminLTE.pushMenu = {
            activate: function (toggleBtn) {
                //Get the screen sizes
                var screenSizes = $.AdminLTE.options.screenSizes;

                //Enable sidebar toggle
                $(document).on('click', toggleBtn, function (e) {
                    e.preventDefault();

                    //Enable sidebar push menu
                    if ($(window).width() > (screenSizes.sm - 1)) {
                        if ($("body").hasClass('sidebar-collapse')) {
                            $("body").removeClass('sidebar-collapse').trigger('expanded.pushMenu');
                        } else {
                            $("body").addClass('sidebar-collapse').trigger('collapsed.pushMenu');
                        }
                    }
                    //Handle sidebar push menu for small screens
                    else {
                        if ($("body").hasClass('sidebar-open')) {
                            $("body").removeClass('sidebar-open').removeClass('sidebar-collapse').trigger('collapsed.pushMenu');
                        } else {
                            $("body").addClass('sidebar-open').trigger('expanded.pushMenu');
                        }
                    }
                });

                $(".content-wrapper").click(function () {
                    //Enable hide menu when clicking on the content-wrapper on small screens
                    if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
                        $("body").removeClass('sidebar-open');
                    }
                });

                //Enable expand on hover for sidebar mini
                if ($.AdminLTE.options.sidebarExpandOnHover
                    || ($('body').hasClass('fixed')
                    && $('body').hasClass('sidebar-mini'))) {
                    this.expandOnHover();
                }
            },
            expandOnHover: function () {
                var _this = this;
                var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
                //Expand sidebar on hover
                $('.main-sidebar').hover(function () {
                    if ($('body').hasClass('sidebar-mini')
                        && $("body").hasClass('sidebar-collapse')
                        && $(window).width() > screenWidth) {
                        _this.expand();
                    }
                }, function () {
                    if ($('body').hasClass('sidebar-mini')
                        && $('body').hasClass('sidebar-expanded-on-hover')
                        && $(window).width() > screenWidth) {
                        _this.collapse();
                    }
                });
            },
            expand: function () {
                $("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
            },
            collapse: function () {
                if ($('body').hasClass('sidebar-expanded-on-hover')) {
                    $('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
                }
            }
        };

        /* Tree()
         * ======
         * Converts the sidebar into a multilevel
         * tree view menu.
         *
         * @type Function
         * @Usage: $.AdminLTE.tree('.sidebar')
         */
        $.AdminLTE.tree = function (menu) {
            var _this = this;
            var animationSpeed = $.AdminLTE.options.animationSpeed;
            $(document).on('click', menu + ' li a', function (e) {
                //Get the clicked link and the next element
                var $this = $(this);
                var checkElement = $this.next();

                //Check if the next element is a menu and is visible
                if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
                    //Close the menu
                    checkElement.slideUp(animationSpeed, function () {
                        checkElement.removeClass('menu-open');
                        //Fix the layout in case the sidebar stretches over the height of the window
                        //_this.layout.fix();
                    });
                    checkElement.parent("li").removeClass("active");
                }
                //If the menu is not visible
                else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
                    //Get the parent menu
                    var parent = $this.parents('ul').first();
                    //Close all open menus within the parent
                    var ul = parent.find('ul:visible').slideUp(animationSpeed);
                    //Remove the menu-open class from the parent
                    ul.removeClass('menu-open');
                    //Get the parent li
                    var parent_li = $this.parent("li");

                    //Open the target menu and add the menu-open class
                    checkElement.slideDown(animationSpeed, function () {
                        //Add the class active to the parent li
                        checkElement.addClass('menu-open');
                        parent.find('li.active').removeClass('active');
                        parent_li.addClass('active');
                        //Fix the layout in case the sidebar stretches over the height of the window
                        _this.layout.fix();
                    });
                }
                //if this isn't a link, prevent the page from being redirected
                if (checkElement.is('.treeview-menu')) {
                    e.preventDefault();
                }
            });
        };

        /* ControlSidebar
         * ==============
         * Adds functionality to the right sidebar
         *
         * @type Object
         * @usage $.AdminLTE.controlSidebar.activate(options)
         */
        $.AdminLTE.controlSidebar = {
            //instantiate the object
            activate: function () {
                //Get the object
                var _this = this;
                //Update options
                var o = $.AdminLTE.options.controlSidebarOptions;
                //Get the sidebar
                var sidebar = $(o.selector);
                //The toggle button
                var btn = $(o.toggleBtnSelector);

                //Listen to the click event
                btn.on('click', function (e) {
                    e.preventDefault();
                    //If the sidebar is not open
                    if (!sidebar.hasClass('control-sidebar-open')
                        && !$('body').hasClass('control-sidebar-open')) {
                        //Open the sidebar
                        _this.open(sidebar, o.slide);
                    } else {
                        _this.close(sidebar, o.slide);
                    }
                });

                //If the body has a boxed layout, fix the sidebar bg position
                var bg = $(".control-sidebar-bg");
                _this._fix(bg);

                //If the body has a fixed layout, make the control sidebar fixed
                if ($('body').hasClass('fixed')) {
                    _this._fixForFixed(sidebar);
                } else {
                    //If the content height is less than the sidebar's height, force max height
                    if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
                        _this._fixForContent(sidebar);
                    }
                }
            },
            //Open the control sidebar
            open: function (sidebar, slide) {
                //Slide over content
                if (slide) {
                    sidebar.addClass('control-sidebar-open');
                } else {
                    //Push the content by adding the open class to the body instead
                    //of the sidebar itself
                    $('body').addClass('control-sidebar-open');
                }
            },
            //Close the control sidebar
            close: function (sidebar, slide) {
                if (slide) {
                    sidebar.removeClass('control-sidebar-open');
                } else {
                    $('body').removeClass('control-sidebar-open');
                }
            },
            _fix: function (sidebar) {
                var _this = this;
                if ($("body").hasClass('layout-boxed')) {
                    sidebar.css('position', 'absolute');
                    sidebar.height($(".wrapper").height());
                    $(window).resize(function () {
                        _this._fix(sidebar);
                    });
                } else {
                    sidebar.css({
                        'position': 'fixed',
                        'height': 'auto'
                    });
                }
            },
            _fixForFixed: function (sidebar) {
                sidebar.css({
                    'position': 'fixed',
                    'max-height': '100%',
                    'overflow': 'auto',
                    'padding-bottom': '50px'
                });
            },
            _fixForContent: function (sidebar) {
                $(".content-wrapper, .right-side").css('min-height', sidebar.height());
            }
        };

        /* BoxWidget
         * =========
         * BoxWidget is a plugin to handle collapsing and
         * removing boxes from the screen.
         *
         * @type Object
         * @usage $.AdminLTE.boxWidget.activate()
         *        Set all your options in the main $.AdminLTE.options object
         */
        $.AdminLTE.boxWidget = {
            selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
            icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
            animationSpeed: $.AdminLTE.options.animationSpeed,
            activate: function (_box) {
                var _this = this;
                if (!_box) {
                    _box = document; // activate all boxes per default
                }
                //Listen for collapse event triggers
                $(_box).on('click', _this.selectors.collapse, function (e) {
                    e.preventDefault();
                    _this.collapse($(this));
                });

                //Listen for remove event triggers
                $(_box).on('click', _this.selectors.remove, function (e) {
                    e.preventDefault();
                    _this.remove($(this));
                });
            },
            collapse: function (element) {
                var _this = this;
                //Find the box parent
                var box = element.parents(".box").first();
                //Find the body and the footer
                var box_content = box.find("> .box-body, > .box-footer, > form  >.box-body, > form > .box-footer");
                if (!box.hasClass("collapsed-box")) {
                    //Convert minus into plus
                    element.children(":first")
                        .removeClass(_this.icons.collapse)
                        .addClass(_this.icons.open);
                    //Hide the content
                    box_content.slideUp(_this.animationSpeed, function () {
                        box.addClass("collapsed-box");
                    });
                } else {
                    //Convert plus into minus
                    element.children(":first")
                        .removeClass(_this.icons.open)
                        .addClass(_this.icons.collapse);
                    //Show the content
                    box_content.slideDown(_this.animationSpeed, function () {
                        box.removeClass("collapsed-box");
                    });
                }
            },
            remove: function (element) {
                //Find the box parent
                var box = element.parents(".box").first();
                box.slideUp(this.animationSpeed);
            }
        };
    }

    /* ------------------
     * - Custom Plugins -
     * ------------------
     * All custom plugins are defined below.
     */

    /*
     * BOX REFRESH BUTTON
     * ------------------
     * This is a custom plugin to use with the component BOX. It allows you to add
     * a refresh button to the box. It converts the box's state to a loading state.
     *
     * @type plugin
     * @usage $("#box-widget").boxRefresh( options );
     */
    (function ($) {

        "use strict";

        $.fn.boxRefresh = function (options) {

            // Render options
            var settings = $.extend({
                //Refresh button selector
                trigger: ".refresh-btn",
                //File source to be loaded (e.g: ajax/src.php)
                source: "",
                //Callbacks
                onLoadStart: function (box) {
                    return box;
                }, //Right after the button has been clicked
                onLoadDone: function (box) {
                    return box;
                } //When the source has been loaded

            }, options);

            //The overlay
            var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');

            return this.each(function () {
                //if a source is specified
                if (settings.source === "") {
                    if (window.console) {
                        window.console.log("Please specify a source first - boxRefresh()");
                    }
                    return;
                }
                //the box
                var box = $(this);
                //the button
                var rBtn = box.find(settings.trigger).first();

                //On trigger click
                rBtn.on('click', function (e) {
                    e.preventDefault();
                    //Add loading overlay
                    start(box);

                    //Perform ajax call
                    box.find(".box-body").load(settings.source, function () {
                        done(box);
                    });
                });
            });

            function start(box) {
                //Add overlay and loading img
                box.append(overlay);

                settings.onLoadStart.call(box);
            }

            function done(box) {
                //Remove overlay and loading img
                box.find(overlay).remove();

                settings.onLoadDone.call(box);
            }

        };

    })(jQuery);

    /*
     * EXPLICIT BOX CONTROLS
     * -----------------------
     * This is a custom plugin to use with the component BOX. It allows you to activate
     * a box inserted in the DOM after the app.js was loaded, toggle and remove box.
     *
     * @type plugin
     * @usage $("#box-widget").activateBox();
     * @usage $("#box-widget").toggleBox();
     * @usage $("#box-widget").removeBox();
     */
    (function ($) {

        'use strict';

        $.fn.activateBox = function () {
            $.AdminLTE.boxWidget.activate(this);
        };

        $.fn.toggleBox = function(){
            var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
            $.AdminLTE.boxWidget.collapse(button);
        };

        $.fn.removeBox = function(){
            var button = $($.AdminLTE.boxWidget.selectors.remove, this);
            $.AdminLTE.boxWidget.remove(button);
        };

    })(jQuery);

    /*
     * TODO LIST CUSTOM PLUGIN
     * -----------------------
     * This plugin depends on iCheck plugin for checkbox and radio inputs
     *
     * @type plugin
     * @usage $("#todo-widget").todolist( options );
     */
    (function ($) {

        'use strict';

        $.fn.todolist = function (options) {
            // Render options
            var settings = $.extend({
                //When the user checks the input
                onCheck: function (ele) {
                    return ele;
                },
                //When the user unchecks the input
                onUncheck: function (ele) {
                    return ele;
                }
            }, options);

            return this.each(function () {

                if (typeof $.fn.iCheck != 'undefined') {
                    $('input', this).on('ifChecked', function () {
                        var ele = $(this).parents("li").first();
                        ele.toggleClass("done");
                        settings.onCheck.call(ele);
                    });

                    $('input', this).on('ifUnchecked', function () {
                        var ele = $(this).parents("li").first();
                        ele.toggleClass("done");
                        settings.onUncheck.call(ele);
                    });
                } else {
                    $('input', this).on('change', function () {
                        var ele = $(this).parents("li").first();
                        ele.toggleClass("done");
                        if ($('input', ele).is(":checked")) {
                            settings.onCheck.call(ele);
                        } else {
                            settings.onUncheck.call(ele);
                        }
                    });
                }
            });
        };
    }(jQuery));



    //
    // 各种初始化
    //


    /**
     * icheck 初始化
     */
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });

    //Red color scheme for iCheck
    $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
        checkboxClass: 'icheckbox_minimal-red',
        radioClass: 'iradio_minimal-red'
    });
    //Flat red color scheme for iCheck
    $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
        checkboxClass: 'icheckbox_flat-green',
        radioClass: 'iradio_flat-green'
    });

    /**
     * select2 初始化
     */
    $(".select2").select2();

    /**
     * timepicker 初始化
     */
    $(".timepicker").timepicker({
        showInputs: false
    });



    //初始化moment
    var moment = require('moment');
    moment.locale('zh-cn');

    /**
     * datepicker 初始化
     */
    $('.datepicker').datepicker({
        autoclose: true
    });

    //Date range picker

    $('.daterange').daterangepicker({
            format: 'YYYY-MM-DD',
            locale:{
                applyLabel: '确认',
                cancelLabel: '取消',
                fromLabel: '从',
                toLabel: '到',
                customRangeLabel: '高级'
            }
        },
        function (start, end) {
            $(this.element).parents('div.datarange-box').find('input.daterange-start-value').val(start.format('YYYY-MM-DD'))
            $(this.element).parents('div.datarange-box').find('input.daterange-end-value').val(end.format('YYYY-MM-DD'))
        }
    );



    //Date range picker with time picker
    $('.daterangetime').daterangepicker({
            timePicker12Hour: false,
            timePicker: true,
            timePickerIncrement: 30,
            timePickerSeconds: true,
            format: 'YYYY-MM-DD HH:mm:ss',
            locale:{
                applyLabel: '确认',
                cancelLabel: '取消',
                fromLabel: '从',
                toLabel: '到',
                customRangeLabel: '高级'
            }
        },
        function (start, end) {
            $(this.element).parents('div.datarange-box').find('input.daterange-start-value').val(start.format('YYYY-MM-DD HH:mm:ss'))
            $(this.element).parents('div.datarange-box').find('input.daterange-end-value').val(end.format('YYYY-MM-DD HH:mm:ss'))
        }
    );

    //Date range as a button
    $('.daterange-btn').daterangepicker({
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                '一周': [moment().subtract(6, 'days'), moment()],
                '30天': [moment().subtract(29, 'days'), moment()],
                '本月': [moment().startOf('month'), moment().endOf('month')],
                '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            },
            startDate: moment().subtract(29, 'days'),
            endDate: moment(),
            format: 'YYYY-MM-DD',
            locale:{
                applyLabel: '确认',
                cancelLabel: '取消',
                fromLabel: '从',
                toLabel: '到',
                customRangeLabel: '高级'
            }
        },
        function (start, end) {
            //$('.daterange-btn span').html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
            $(this.element).html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
            $(this.element).parents('div.datarange-box').find('input.daterange-start-value').val(start.format('YYYY-MM-DD'))
            $(this.element).parents('div.datarange-box').find('input.daterange-end-value').val(end.format('YYYY-MM-DD'))
        }
    );

    //Date picker
    $('#datepicker').datepicker({
        autoclose: true
    });

});
Example #11
0
'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;
var moment = require("moment");
moment.locale("nl");

var AgendaSchema = new Schema({
  venueName: String,
  venueAddress: String,
  details: String,
  fbEvent: String,
  ticketLink: String,
  date: {
    raw: {type: Date}
  },
  time: String,
  played: Boolean,
  cancelled: Boolean
}, {
  toObject: {
    virtuals: true
  },
  toJSON: {
    virtuals: true
  }
});

// *** Virtuals
// Format date
AgendaSchema
Example #12
0
addDecorator((story) => {
  moment.locale('en');
  return (story());
});
Example #13
0
// External
import React, { Component } from 'react'
import moment from 'moment';
import {
  Text,
  View,
  StyleSheet,
  TouchableOpacity,
  ScrollView
} from 'react-native';

// Internal
import colors from 'constants/colors';
import HTMLView from 'react-native-htmlview';

moment.locale('fi');

export default class BlogPostFull extends Component {
  static route = {
    navigationBar: {
      title(params) {
        return params.title
      },
    }
  }

  render() {
    const { title, date, content } = this.props;
    const formattedDate = moment(date).format('LL');

    const formattedText = content
Example #14
0
import createStore from './store'
import api from './api_client'
import reporter from './reporter'
import {hydrateNotYetOpen} from './actions/not_yet_open'

import './default.css'
import './effects.css'
import './dhm_profile_camera.css'

import { browserHistory } from 'react-router'
import withScroll from 'scroll-behavior'
import { syncHistoryWithStore } from 'react-router-redux'

import moment from 'moment'

moment.locale('de') // TODO: find a better place to init
addLocaleData(localeDe) // TODO: find a better place to init Intl
const messages = {...messagesEn, ...messagesDe}
//const messages = messagesEn


class App extends React.Component {

  static childContextTypes = {
    muiTheme: React.PropTypes.object
  }

  static propTypes = {
    history: React.PropTypes.object.isRequired,
    store: React.PropTypes.object.isRequired
  }
Example #15
0
    function(err, response, body) {
      res.set({
        "Cache-Control": "no-cache"
      });

      if (err) {
        res.status(500);
        next(
          HttpError.format(
            {
              message: "Failed to send request to " + readURL,
              context: err
            },
            req
          )
        );
        return;
      }

      if (response.statusCode === 404) {
        // If there aren't any projects for this user, create one with a redirect
        res.redirect(307, "/" + locale + "/projects/new" + qs);
        return;
      }

      if (response.statusCode !== 200) {
        res.status(response.statusCode);
        next(
          HttpError.format(
            {
              message:
                "Request to " +
                readURL +
                " returned a status of " +
                response.statusCode,
              context: response.body
            },
            req
          )
        );
        return;
      }

      var projects;
      try {
        projects = JSON.parse(body);
      } catch (e) {
        res.status(500);
        next(
          HttpError.format(
            {
              message:
                "Project sent by calling function was in an invalid format. Failed to run `JSON.parse`",
              context: e.message,
              stack: e.stack
            },
            req
          )
        );
        return;
      }

      //Sort projects in ascending order by last updated
      projects.sort(function(project1, project2) {
        var g1 = project1.glitch_migrated,
          g2 = project2.glitch_migrated;

        // put "migrated already" at the end of the list
        if (g1 && !g2) {
          return 1;
        }
        if (g2 && !g1) {
          return -1;
        }

        // If both are already migrated, or they're both not
        // migrated, simply sort on when they were last updated.
        var t1 = new Date(project1.date_updated).getTime(),
          t2 = new Date(project2.date_updated).getTime();
        return t1 - t2;
      });

      // make sure the glitch move date is localized:
      moment.locale("en");
      var migrationDate = moment(config.glitch.migrationDate);
      migrationDate = migrationDate.locale(locale).format("LL");

      var options = {
        languages: req.app.locals.languages,
        URL_PATHNAME: "/projects" + qs,
        csrf: req.csrfToken ? req.csrfToken() : null,
        username: user.username,
        avatar: user.avatar,
        projects: projects,
        glitchExportEnabled: req.user && config.glitch.exportEnabled,
        glitch: req.user && config.glitch,
        migrationDate,
        queryString: qs,
        logoutURL: config.logoutURL
      };

      res.render("projects-list/index.html", options);
    }
Example #16
0
import React, { Component, PropTypes } from 'react';
import { bindFunctions } from '../utils';
import ControlButtons from './ControlButtons';
import { formTypes } from '../constants';
import Moment from 'moment';
Moment.locale('ru');
import momentLocalizer from 'react-widgets/lib/localizers/moment';
momentLocalizer(Moment);

const dateFormat = 'DD.MM.YYYY';
const timeFormat = 'HH:mm';

export default class FormsTable extends Component {
  constructor(props) {
    super(props);

    bindFunctions.call(this, ['renderRows', 'renderRow', 'rowClickHandler']);
  }

  rowClickHandler(formId) {
    const previewForm = this.props.previewForm.bind(null, formId);

    function clickHandler(e) {
      let target = e.target;
      const currentTarget = e.currentTarget;

      while (target != currentTarget) {
        if ( target.classList.contains('btn-group') ) {
          return;
        }
Example #17
0
import { appConfig }  from '../../../../config';
import moment         from 'moment';
moment.locale('fr');

const formatDate = appConfig.formatDate.defaut;

export const ENTER_MAILBOX_INBOX  = 'ENTER_MAILBOX_INBOX';
export const LEAVE_MAILBOX_INBOX  = 'LEAVE_MAILBOX_INBOX';

export const ENTER_MAILBOX_SENTBOX  = 'ENTER_MAILBOX_SENTBOX';
export const LEAVE_MAILBOX_SENTBOX  = 'LEAVE_MAILBOX_SENTBOX';

export const ENTER_MAILBOX_CONSULT  = 'ENTER_MAILBOX_CONSULT';
export const LEAVE_MAILBOX_CONSULT  = 'LEAVE_MAILBOX_CONSULT';

export const ENTER_MAILBOX_WRITE_NEW  = 'ENTER_MAILBOX_WRITE_NEW';
export const LEAVE_MAILBOX_WRITE_NEW  = 'LEAVE_MAILBOX_WRITE_NEW';

export const ENTER_MAILBOX_REPLY_MAIL  = 'ENTER_MAILBOX_REPLY_MAIL';
export const LEAVE_MAILBOX_REPLY_MAIL  = 'LEAVE_MAILBOX_REPLY_MAIL';


// inbox
export const enterMailboxInbox = (mailboxId = 0, time = moment().format(formatDate)) => {
  if (!parseInt(mailboxId, 10) > 0) {
    return {};
  }
  return {
    type:         ENTER_MAILBOX_INBOX,
    currentView:  `${appConfig.views.mailbox.reception.viewName}#${mailboxId}`,
    viewDetails:  `${appConfig.views.mailbox.reception.viewName}: mailbox#${mailboxId}` || 'non defini',
Example #18
0
  getTime() {
    moment.locale('ru');

    return moment().format('LTS');
  }
Example #19
0
'use strict';
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import { message } from 'antd';
import { Provider } from 'react-redux';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import { ReduxAsyncConnect } from 'redux-connect'
import { syncHistoryWithStore } from 'react-router-redux';

import moment from 'moment';
moment.locale('zh-CN');

import store from './redux/store';

import App from './components/App';
import MainPage from './components/MainPage';
import AccountPage from './components/AccountPage';
import AccountRecordPage from './components/AccountRecordPage';
import AccountSecurityPage from './components/AccountSecurityPage';
import AccountWelcomePage from './components/AccountWelcomePage';
import AccountInfoPage from './components/AccountInfoPage';
import AdminIndexPage from './components/AdminIndexPage';
import AdminApp from './components/AdminApp';
import AdminWelcomePage from './components/AdminWelcomePage';
import AdminInfoPage from './components/AdminInfoPage';
import AdminManager from './components/AdminManager';
import AdminAddAdminPage from './components/AdminAddAdminPage';
import AdminAddAuditorPage from './components/AdminAddAuditorPage';
import AdminAddBookerPage from './components/AdminAddBookerPage';
import AdminRegisterPage from './components/AdminRegisterPage';
Example #20
0
/**
 *
 * ProjectName:blogme
 * Description:
 * Created by qimuyunduan on 16/5/4 .
 * Revise person:qimuyunduan
 * Revise Time:16/5/4 下午6:29
 * @version
 *
 */
var _      = require('lodash'),
	moment = require('moment');


//set moment env
moment.locale('zh-cn');



function getWeekday(){

	return moment().format('dddd');  //星期三
}

function getLocalDate(){

	return moment().format("LL");

}
function getDate(){
	return moment().format('L'); //2016-5-4
Example #21
0
/* jshint expr:true */
var chai = require('chai'),
    when = require('when'),
    expect = chai.expect,
    streams = require('memory-streams'),
    Printer = require('../lib/streamfire/printer'),
    moment = require('moment');

moment.locale('en-GB');

describe("printer", function () {

    var dummyCreatedAt = "2014-09-21T21:28:00Z";

    function dummyUserRegistry(users) {
        return {
            getUser: function (userId) {
                return {
                    then: function (f) {
                        return when.resolve(
                            f(users[userId])
                        );
                    }
                };
            }
        };
    }

    it("prints a single line message with user's name", function () {

        var dummyStream = new streams.WritableStream(),
Example #22
0
 /*@ngInject*/
 constructor(Models) {
   this.Models = Models;
   Moment.locale('zh_cn');
 }