Updated JQuery; Added resize sensor library; Updated the admin code (prior to changing gears to use Meteor).
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,7 +2,7 @@
|
||||
node_modules
|
||||
config.js
|
||||
public/main.css
|
||||
public/admin/main.css
|
||||
public/admin/index.css
|
||||
public/admin/*.css
|
||||
public/emailFailures.txt
|
||||
sessions/
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
var Promise = require('bluebird');
|
||||
|
||||
module.exports = function(sequelize) {
|
||||
var models = sequelize.models;
|
||||
|
||||
//Pre-populate a new database with some data.
|
||||
models.Category.count().then(function(count) {
|
||||
if(count == 0) {
|
||||
var basicJarIds = [];
|
||||
|
||||
models.User.create({login: 'wcrisman', password: 'landFJ40', admin: true});
|
||||
|
||||
models.Venue.create({name: 'Boonville'});
|
||||
models.Venue.create({name: 'Clement St Farmers Market in SF'});
|
||||
models.Venue.create({name: 'Ukiah Farmers Market'});
|
||||
models.Venue.create({name: 'Mendocino Farmers Market'});
|
||||
models.Venue.create({name: 'Ft Bragg Farmers Market'});
|
||||
|
||||
Promise.each([
|
||||
models.Measure.create({name: 'Jar 4oz', postfix: '4oz'}),
|
||||
models.Measure.create({name: 'Jar 8oz', postfix: '8oz'}),
|
||||
models.Measure.create({name: 'Jar 12oz', postfix: '12oz'}),
|
||||
models.Measure.create({name: 'Jar 16oz', postfix: '16oz'}),
|
||||
models.Measure.create({name: 'Jar 32oz', postfix: '32oz'}),
|
||||
models.Measure.create({name: 'Jar 64oz', postfix: '64oz'}),
|
||||
models.Measure.create({name: 'Pounds', postfix: 'lbs'}),
|
||||
models.Measure.create({name: 'Each', postfix: ''}),
|
||||
models.Measure.create({name: 'Bags', postfix: 'bags'})
|
||||
], function(value, index, length) {
|
||||
//Collect the first 5 jar ids.
|
||||
if(index < 5) basicJarIds.push(value.id);
|
||||
}).then(function() {
|
||||
models.Category.create({name: 'VAP'}).then(function(category) {
|
||||
models.Subcategory.create({name: 'Soups'}).then(function(subcategory) {
|
||||
category.addSubcategory(subcategory);
|
||||
models.Item.create({name: 'Fava Bean Bisque', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Tomato Basil Soup', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Winter Squash Soup', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
});
|
||||
models.Subcategory.create({name: 'Drink Mixes & Syrups'}).then(function(subcategory) {
|
||||
category.addSubcategory(subcategory);
|
||||
models.Item.create({name: 'Bloody Mary Mix', defaultPrice: 12, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Grape Syrup', defaultPrice: 8, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Prickly Pear Syrup', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Quince Syrup', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Strawberry Syrup', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Wild Plum Syrup', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
});
|
||||
models.Subcategory.create({name: 'Fermented'}).then(function(subcategory) {
|
||||
category.addSubcategory(subcategory);
|
||||
models.Item.create({name: 'Napa Cabbage Sauerkraut', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Napa Cabbage Sauerkraut w/ Watercress & Espelette Pepper', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Red Sauerkraut', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
});
|
||||
models.Subcategory.create({name: 'Dried Goods'}).then(function(subcategory) {
|
||||
category.addSubcategory(subcategory);
|
||||
models.Item.create({name: 'Dried Strawberries', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Membrillo', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Sugared Jalape<70>os', defaultPrice: 10, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
});
|
||||
models.Subcategory.create({name: 'Spices'}).then(function(subcategory) {
|
||||
category.addSubcategory(subcategory);
|
||||
models.Item.create({name: 'Basque Pepper Powder', defaultPrice: 8, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Korean Pepper Powder', defaultPrice: 8, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Smoked Basque Pepper Powder', defaultPrice: 8, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
models.Item.create({name: 'Smoked Korean Pepper Powder', defaultPrice: 8, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
});
|
||||
models.Subcategory.create({name: 'Specialty'}).then(function(subcategory) {
|
||||
category.addSubcategory(subcategory);
|
||||
models.Item.create({name: 'Pure Lard', defaultPrice: 4, measures: basicJarIds}).then(function(item) {
|
||||
subcategory.addItem(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
15
csv.js
Normal file
15
csv.js
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
var fs = require("fs");
|
||||
var csv = require('csv-parse');
|
||||
|
||||
module.exports = {
|
||||
read: function(csvFilePath, callback) {
|
||||
var parser = csv({delimiter: '\t'}, function(error, data) {
|
||||
if(error) callback(error);
|
||||
else callback(null, data);
|
||||
});
|
||||
|
||||
|
||||
fs.createReadStream(csvFilePath).pipe(parser);
|
||||
}
|
||||
};
|
||||
BIN
downloaded tools/jsgrid-1.5.2.zip
Normal file
BIN
downloaded tools/jsgrid-1.5.2.zip
Normal file
Binary file not shown.
88
importAll.js
Normal file
88
importAll.js
Normal file
@@ -0,0 +1,88 @@
|
||||
var Promise = require('bluebird');
|
||||
var models = require("./models");
|
||||
|
||||
var fm = 0;
|
||||
var res = 0;
|
||||
var rt = 0;
|
||||
var mail = 0;
|
||||
|
||||
//First get the basics, then load the items. Finally load sales and production data.
|
||||
//Create the venue types.
|
||||
Promise.each([
|
||||
models.VenueType.findOrCreate({where: {name: 'Farmers Market'}, defaults: {name: 'Farmers Market'}}),
|
||||
models.VenueType.findOrCreate({where: {name: 'Restaurant'}, defaults: {name: 'Restaurant'}}),
|
||||
models.VenueType.findOrCreate({where: {name: 'Retail'}, defaults: {name: 'Retail'}}),
|
||||
models.VenueType.findOrCreate({where: {name: 'Mail'}, defaults: {name: 'Mail'}})
|
||||
], function(value, index, length) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
fm = value[0].id;
|
||||
break;
|
||||
case 1:
|
||||
res = value[0].id;
|
||||
break;
|
||||
case 2:
|
||||
rt = value[0].id;
|
||||
break;
|
||||
case 3:
|
||||
mail = value[0].id;
|
||||
break;
|
||||
}
|
||||
}).then(function() {
|
||||
//Create the measures and venues.
|
||||
Promise.each([
|
||||
//Initialize the users.
|
||||
models.User.findOrCreate({where: {login: 'wcrisman'}, defaults: {login: 'wcrisman', password: 'landFJ40', admin: true}}),
|
||||
//Initialize the measures.
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 4oz'}, defaults: {name: 'Jar 4oz', postfix: '4oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 8oz'}, defaults: {name: 'Jar 8oz', postfix: '8oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 12oz'}, defaults: {name: 'Jar 12oz', postfix: '12oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 16oz'}, defaults: {name: 'Jar 16oz', postfix: '16oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 32oz'}, defaults: {name: 'Jar 32oz', postfix: '32oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 64oz'}, defaults: {name: 'Jar 64oz', postfix: '64oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Pounds'}, defaults: {name: 'Pounds', postfix: 'lbs'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Each'}, defaults: {name: 'Each', postfix: ''}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Bags'}, defaults: {name: 'Bags', postfix: 'bags'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Dozen Large'}, defaults: {name: 'Dozen Large', postfix: '12/lg'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Dozen Small'}, defaults: {name: 'Dozen Small', postfix: '12/sm'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Half Dozen Large'}, defaults: {name: 'Half Dozen Large', postfix: '6/lg'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Half Dozen Small'}, defaults: {name: 'Half Dozen Small', postfix: '6/sm'}}),
|
||||
//Initialize the venues.
|
||||
models.Venue.findOrCreate({where: {name: 'Boonville'}, defaults: {name: 'Boonville', typeId: fm}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Clement St'}, defaults: {name: 'Clement St', typeId: fm}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Ukiah'}, defaults: {name: 'Ukiah', typeId: fm}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Mendocino'}, defaults: {name: 'Mendocino', typeId: fm}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Ft Bragg'}, defaults: {name: 'Ft Bragg', typeId: fm}}),
|
||||
models.Venue.findOrCreate({where: {name: 'On Farm'}, defaults: {name: 'On Farm', typeId: rt}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Unknown Restaurant'}, defaults: {name: 'Unknown Restaurant', typeId: res}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Yorkville Market'}, defaults: {name: 'Yorkville Market', typeId: rt}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Yorkville Cellars'}, defaults: {name: 'Yorkville Cellars', typeId: rt}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Mail Order'}, defaults: {name: 'Mail Order', typeId: mail}}),
|
||||
models.Venue.findOrCreate({where: {name: 'Website Order'}, defaults: {name: 'Website Order', typeId: mail}})
|
||||
], function(value, index, length) {
|
||||
//Ignore results for now.
|
||||
}).then(function() {
|
||||
// var softErrors = [];
|
||||
//
|
||||
// //Read all the Categories, Subcategories, and Items.
|
||||
// require('./importItems.js')(models, softErrors).then(function() {
|
||||
// //Read all the sales data.
|
||||
// require('./importSales.js')(models, softErrors).then(function() {
|
||||
// //Log all errors at the end so they are easily visible.
|
||||
// if(softErrors.length) {
|
||||
// for(var i = 0; i < softErrors.length; i++) {
|
||||
// console.log(softErrors[i]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// process.exit(0);
|
||||
// }).catch(function(e) {
|
||||
// console.log(e);
|
||||
// process.exit(1);
|
||||
// });
|
||||
// }).catch(function(e) {
|
||||
// console.log(e);
|
||||
// process.exit(1);
|
||||
// });
|
||||
});
|
||||
});
|
||||
206
importItems.csv
Normal file
206
importItems.csv
Normal file
@@ -0,0 +1,206 @@
|
||||
Item Subcategory Category 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total 32 oz 16 oz 12 oz 8 oz 4 oz Total
|
||||
3packs Specialty VAP 75
|
||||
Adobo Sauce Condiment VAP 14 9 23 70 70 39 1 40 57% 59 59 59 59 100% 26
|
||||
Apple Butter Jams & Spreads VAP 42 42 36 36 15 16 31 45 45 145% 60 13 73 30 16 46 63%
|
||||
Apple Jam Jams & Spreads VAP 48 32 80 4 3 7 9%
|
||||
Apple Jam, French Jams & Spreads VAP 15 15 15 15 100%
|
||||
Apple Jam, Rum Jams & Spreads VAP 47 14
|
||||
Apple Pie Jam Jams & Spreads VAP 38 20 58 16 8 24 41% 74 34 108 34 11 45 42%
|
||||
Apple Raisin Chutney Chutney VAP 36 36 0 21 21 NEG 0 17 17 NEG
|
||||
Apple Rhubarb Chutney Chutney VAP 27 27 2 2 7%
|
||||
Apple Walnut Conserve Jams & Spreads VAP 21
|
||||
Applesauce Honey Side VAP 20 1 21 9 9 43% 13 13 12 12 92%
|
||||
Applesauce, Blackberry Side VAP 20 20 9 9 45%
|
||||
Applesauce, Cinnamon Side VAP 8 8 0 2 2 NEG 29 29 10 10 34%
|
||||
Applesauce, Quince Side VAP 29 29 0 0%
|
||||
Applesauce, Rhubarb Side VAP 18 18 5 5 28%
|
||||
Applesauce, Unsweetened Side VAP 7 7 11 11 35 35 8 1 9 26% 47 1 48 33 33 69%
|
||||
Applesauce. Strawberry Side VAP 36 36 10 10 28%
|
||||
Artichoke Antipasto Side VAP 15 15 17 17 113% 0
|
||||
Baba Ganoush Condiment VAP 14 1
|
||||
Bangkok Peppers Side VAP 53 53 5 5 9%
|
||||
Bartlett Pear jam Jams & Spreads VAP 69 69 24 10 34 58 6 64 188% 28 21 49 24 12 36 73%
|
||||
Bartlett Vanilla Jam Jams & Spreads VAP 15 9 24 1 4 5 21% 35 5 40 16 2 18 45%
|
||||
BBQ Sauce Condiment VAP 18 18 15 7 22 0 1 3 4 NEG 28 28 24 24 86%
|
||||
Beet Marmalade Jams & Spreads VAP 23 38 61 5 16 21 34% 12 15 27 27 19 46 170% 10 18
|
||||
Blackberry Chutney Chutney VAP 26
|
||||
Blackberry Hazelnut Conserve Jams & Spreads VAP 22
|
||||
Blackberry Jalapeno Jam Jams & Spreads VAP 15 18
|
||||
Blackberry Jam Jams & Spreads VAP 32 32 24 24 67 25 92 41 23 64 70% 102 51 153 92 25 117 76% 50
|
||||
Blackberry Jelly Jams & Spreads VAP 20 20 10 10 50% 0 11 1 12 NEG
|
||||
Blackberry Mint Jam Jams & Spreads VAP 21
|
||||
Blackberry Peach Jam Jams & Spreads VAP 16 2 18 10 2 12 67% 0 5 5 NEG
|
||||
Blackberry Syrup Drink Mixes & Syrups VAP 1 17 18 22 22 122%
|
||||
Blackberry Vanilla Jam Jams & Spreads VAP 65 20 85 38 8 46 54% 28 3
|
||||
Bloody Mary Mix Drink Mixes & Syrups VAP 9 9 72 72 53 53 74% 167 167 112 112 67%
|
||||
Bosc Pear Chutney Chutney VAP 15 15 2 2 13% 0 15 15 NEG
|
||||
Bosc Pear Jam Jams & Spreads VAP 18 18 2 21 23 128% 0 10 10 NEG
|
||||
Brinjal Eggplant Relish Pickles & Relishes VAP 0 11 11 NEG
|
||||
Candied Quince Side VAP 0 4 4 NEG
|
||||
Catsup Condiment VAP 37 28 65 38 13 7 58 55 7 62 38 14 52 84% 49 49 2 40 42 86%
|
||||
Chili Sauce Condiment VAP 18 18 11 11 61% 0 3 3 NEG
|
||||
Chow Chow Mild Pickles & Relishes VAP 25 25 5 5 20% 0 12 12 NEG
|
||||
Chow Chow Spicy Pickles & Relishes VAP 27 27 6 6 22% 0 19 19 NEG
|
||||
Comice Pear Jam Jams & Spreads VAP 17 7 24 12 5 17 71%
|
||||
Comice Pear Jam w/ Sherry Jams & Spreads VAP 36 36 27 27 75%
|
||||
Confetti Relish Pickles & Relishes VAP 0 2 2 NEG
|
||||
Cowboy Candy Side VAP 38 38 76 13 2 15 20%
|
||||
Curried Onions Side VAP 11 11 0 0%
|
||||
D'Anjou Pear Conserve Jams & Spreads VAP 0 2 2 NEG
|
||||
D'Anjou Pear Jam Jams & Spreads VAP 38 16 54 3 3 6% 14 36 50 42 20 62 124%
|
||||
Dilly Beans Pickles & Relishes VAP 17 17 34 20 20 11 134 145 15 36 51 35% 11 73 84 6 98 104 124%
|
||||
Dried, Pear Dried VAP 1
|
||||
Dried, Strawberry Dried VAP 22
|
||||
Dried, Tomatillo Dried VAP 2
|
||||
Dried Tomato Dried VAP 56 18 32%
|
||||
Eggplant Conserve Jams & Spreads VAP 21 21 10 14 24 22 3 25 104% 18 36 54 9 3 12 22%
|
||||
Pesto, Eggplant Condiment VAP 12 2 17%
|
||||
Pesto, Garlic Scape Condiment VAP 13 12 92%
|
||||
Elderberry Butter Jams & Spreads VAP 23 23 23 23 100% 36 36 36 36 100%
|
||||
Enchilada Sauce Condiment VAP 3 9 12 9 9 75%
|
||||
Espelette Peppers Side VAP 36 36 3 3 8% 86 86 60 60 70%
|
||||
Fava Bean Bisque Soup VAP 9 9 0 0%
|
||||
Fava Bean Soup Soup VAP 23 7 30 20 7 27 90% 19 1 20 21 21 105%
|
||||
Fennel Relish Pickles & Relishes VAP 4 4 0 4 4 NEG 22 22 10 10 45%
|
||||
Fig Jam Jams & Spreads VAP 23 8 31 61 21 82 69 44 113 40 5 45 40% 97 41 138 82 33 115 83%
|
||||
Ginger Peaches Side VAP 17 17 11 11 65% 0 6 6 NEG
|
||||
Grape Jam Jams & Spreads VAP 20 12 32 7 3 10 26 12 38 6 5 11 29% 22 13 35 12 10 22 63%
|
||||
Grape Jam, White Jams & Spreads VAP 36 36 0 0%
|
||||
Grape Syrup Drink Mixes & Syrups VAP 9 4 13 2 2 15%
|
||||
Green Gage Jam Jams & Spreads VAP 24 24 48 0 14 8 22 NEG 28 17 45 21 21 47%
|
||||
Green Gage Jam w/ Ginger Jams & Spreads VAP 40 4 44 10 1 11 25%
|
||||
Green Gage Jelly Jams & Spreads VAP 0 6 6 NEG
|
||||
Green Tomato Catsup Condiment VAP 19 19 0 0%
|
||||
Green Tomato Chutney Chutney VAP 24 24 19 19 42 42 17 17 40% 0 16 16 NEG
|
||||
Green Tomato Jam Jams & Spreads VAP 12 6 18 58 10 68 38 3 41 60% 15 12 27 17 13 30 111%
|
||||
Green Tomato Relish Pickles & Relishes VAP 72 72 1 1 1%
|
||||
Green Tomato Salsa Condiment VAP 42 42 4 4 10%
|
||||
Jalapeno Salsa Condiment VAP 35 35 19 19 54% 58 12 70 37 37 53%
|
||||
Jalapeno Carrot Hot Sauce Condiment VAP 12 12 11 11 92%
|
||||
Jalapenos Side VAP 30 30 8 8 27% 38 38 20 20 53%
|
||||
Jalapeno Candy Specialty VAP 101 115 114%
|
||||
Jujube & Ginger Butter Jams & Spreads VAP 4 4 4 4 100% 16 11 27 5 4 9 33%
|
||||
Jujube Butter Jams & Spreads VAP 13 11 24 13 13 30 19 49 9 10 19 39% 0 22 2 24 NEG
|
||||
Kadota Figs Side VAP 0 2 2 NEG
|
||||
Kimchi Fermented VAP 12 23 136 136 52 52 38% 40 40 113 113 283%
|
||||
Korean Peppers Side VAP 58 58 8 8 14% 0 29 29 NEG
|
||||
Lard Specialty VAP 38 38 15 15 39% 20 1 21 21 21 100%
|
||||
Leather, Unspecified Dried VAP 52
|
||||
Leather, Apple Dried VAP 18 4 22%
|
||||
Leather, Grape Dried VAP 46 10 22%
|
||||
Leather, Peach Dried VAP 18 6 33%
|
||||
Leather, Persimmon Dried VAP 6 0%
|
||||
Leather, Pumpkin Dried VAP 102 69 68%
|
||||
Leather, Strawberry Dried VAP 60 56 93%
|
||||
Leek & Potato Soup Soup VAP 21 4 25 2 2 4 16% 0 2 2 NEG
|
||||
Marionberry Jam Jams & Spreads VAP 17 6 23 8 4 12 86 42 128 51 32 83 65% 110 41 151 89 28 117 77%
|
||||
Membrillo Dried VAP 48 66 138%
|
||||
Membrillo Truffles Specialty VAP 8 NEG
|
||||
Mint Jelly Jams & Spreads VAP 23 23 3 3 13% 0 13 13 NEG
|
||||
Mixed Berry Jam Jams & Spreads VAP 5 5 26 12 38 21 11 32 84% 18 33 51 18 25 43 84%
|
||||
Napa Kraut watercress pepper Fermented VAP 28 28 15 15 54%
|
||||
Napa Kraut, Onion Fermented VAP 26 26 19 19 73%
|
||||
Onion Marmalade Jams & Spreads VAP 60 60 27 27 45% 0 27 27 NEG
|
||||
Pasta sauce Condiment VAP 14 14 14 14 100%
|
||||
Peach BBQ Condiment VAP 18 18 5 5 28%
|
||||
Peach Butter Jams & Spreads VAP 30 30 26 26 87% 0 1 1 NEG
|
||||
Peach Chutney Chutney VAP 13 7 20 58 58 9 32 41 71% 0 23 23 NEG
|
||||
Peach Jam Jams & Spreads VAP 18 5 23 19 3 22 96%
|
||||
Peach Jam, Babcobk w/ Ginger Jams & Spreads VAP 36 17 53 9 4 13 25%
|
||||
Peach Jam, Babcock Jams & Spreads VAP 20 10 30 18 8 26 87% 89 41 130 25 12 37 28%
|
||||
Peach Jam, Babcock w/ Lavender Jams & Spreads VAP 54 34 88 21 12 33 38%
|
||||
Peach Jam, Indian Free Jams & Spreads VAP 55 24 79 17 4 21 27%
|
||||
Peach Jam, Saturn Jams & Spreads VAP 19 19 10 10 53%
|
||||
Pear Apple Jam Jams & Spreads VAP 30 20 50 0 0% 0 16 13 29 NEG
|
||||
Pear Chutney Chutney VAP 18 18 6 6 33% 42 42 9 9 21%
|
||||
Pear Dessert Topping Condiment VAP 14 14 2 2 14% 0 5 5 NEG
|
||||
Pear Ginger Butter Jams & Spreads VAP 36 17 53 21 21 48 30 78 45 16 61 78% 29 8 37 35 20 55 149%
|
||||
Pear Jam, Seckel Jams & Spreads VAP 55 55 31 21 52 36 4 40 77% 0 18 4 22 NEG
|
||||
Pear Syrup Drink Mixes & Syrups VAP 9 2 11 8 2 10 91% 0 11 11 NEG
|
||||
Pearsauce Side VAP 36 36 1 1 3% 0 15 15 NEG
|
||||
Pepper Jelly Jams & Spreads VAP 35 32 67 16 1 17 30 12 42 247% 66 44 110 47 27 74 67%
|
||||
Pesto, Mint Condiment VAP 57 47 82%
|
||||
Pickle Relish Pickles & Relishes VAP 0 0 0% 0 3 3 NEG
|
||||
Pickled Asparagus Pickles & Relishes VAP 50 50 47 47 94% 105 105 73 73 70%
|
||||
Pickled Beets Pickles & Relishes VAP 8 8 44 44 31 31 70% 39 39 47 47 121%
|
||||
Pickled Eggs Pickles & Relishes VAP 10 10 26 26 50 50 49 49 98% 53 53 37 37 70%
|
||||
Pickled Eggplant Pickles & Relishes VAP 0 4 4 NEG
|
||||
Pickled Fennel Pickles & Relishes VAP 22 4 26 4 27 31 3 7 10 32% 17 17 6 6 35%
|
||||
Pickled Okra Pickles & Relishes VAP 7 7 9 1 7 5 22 59 4 63 6 28 3 37 59% 4 65 1 70 52 52 74%
|
||||
Pickled Onions (sweet) Pickles & Relishes VAP 1 11 12 1 5 6 50% 0 2 2 NEG
|
||||
Pickled Onion Dill w/Espelette Pickles & Relishes VAP 13 13 4 4 31%
|
||||
Pickled Onion Dill w/Sweet Pep. Pickles & Relishes VAP 15 15 8 8 53%
|
||||
Pickled Onions Fennel Pickles & Relishes VAP 42 42 23 23 55%
|
||||
Pickled Onions, Dill Pickles & Relishes VAP 2 2 0 0%
|
||||
Pickled Peas Pickles & Relishes VAP 0 3 3 NEG
|
||||
Pickled Scapes Pickles & Relishes VAP 24 24 18 18 75% 0 5 5 NEG
|
||||
Pickled Summer Squash Pickles & Relishes VAP 9 9 76 76 10 10 13% 0 59 59 NEG
|
||||
Pickles, Bread Butter Pickles & Relishes VAP 22 22 20 20 18 18 23 3 26 144% 96 96 67 67 70%
|
||||
Pickles, Dill Pickles & Relishes VAP 40 7 47 66 21 87 87 26 113 75 22 97 86% 165 165 75 75 45%
|
||||
Pickles, Fennel Pickles & Relishes VAP 21 21 17 17 81% 109 109 47 47 43%
|
||||
Pickles, Ginger Garlic Pickles & Relishes VAP 13 13 2 33 35 27 27 77% 49 49 48 48 98%
|
||||
Pickles, Green Tomato Pickles & Relishes VAP 0 4 4 NEG 24 24 2 2 8%
|
||||
Pippin Apple Chutney Chutney VAP 41 41 15 15 37%
|
||||
Plum BBQ Condiment VAP 0 1 1 NEG
|
||||
Plum Jam Jams & Spreads VAP 21 21 49 12 61 21 8 29 48% 16 7 23 38 10 48 209%
|
||||
Plum Jam, Spiced Jams & Spreads VAP 25 6 31 3 4 7 23% 0 2 1 3 NEG
|
||||
Plum Jam, Santa Rosa Jams & Spreads VAP 13 11 24 66 9 75 31 9 40 53%
|
||||
Plum Sauce Condiment VAP 0 14 14 NEG
|
||||
Plum Syrup Drink Mixes & Syrups VAP 3 3 4 4 133%
|
||||
Popsicles Specialty VAP 249 205 82%
|
||||
Prickly Pear Jelly Jams & Spreads VAP 46 24 70 4 4 6% 0 22 3 25 NEG
|
||||
Prickly Pear Syrup Drink Mixes & Syrups VAP 20 21 8 49 11 11 22%
|
||||
Pumpkin Chutney Chutney VAP 11 11 11 11 100% 0
|
||||
Quince Chutney Chutney VAP 65 65 0 35 35 NEG 0
|
||||
Quince Butter Jams & Spreads VAP 29 12 41 19 8 27 66% 0 7 7 NEG
|
||||
Quince Fennel Butter Jams & Spreads VAP 69 51 120 33 21 54 45% 49 7 56 30 12 42 75%
|
||||
Quince Jam Jams & Spreads VAP 51 11 62 44 25 69 50 17 67 97% 68 33 101 52 25 77 76%
|
||||
Quince Jam w/ Cinnamon Jams & Spreads VAP 14 14 1 1 7%
|
||||
Quince Plum Jam Jams & Spreads VAP 55 55 23 23 42% 0 17 17 NEG
|
||||
Quince Syrup Drink Mixes & Syrups VAP 23 23 7 7 30% 0 21 21 NEG
|
||||
Raspberry Jam Jams & Spreads VAP 25 12 37 15 6 21 57% 7 31 38 19 24 43 113%
|
||||
Ratatouille Relish Pickles & Relishes VAP 43 43 5 5 12%
|
||||
Rhubarb Jam Jams & Spreads VAP 38 14 52 31 14 45 87% 0 1 1 NEG
|
||||
Salsa Verde Condiment VAP 6 39 11 56 94 94 38 38 40% 53 53 74 74 140%
|
||||
Sauerkraut Fermented VAP 108 108 34 34 31% 99 99
|
||||
Sauerkraut, Red Fermented VAP 15 15 71 71 47 47 66% 67 67 35 35 52%
|
||||
Shrubs Specialty VAP 1 2 46 49 1 25 26 53%
|
||||
Sorrel Soup Soup VAP 7 3 10 4 3 7 70% 0 1 1 2 NEG
|
||||
Spices, Unspecified Dried VAP 14
|
||||
Spices, Basil/Corriander Dried VAP 4
|
||||
Spices, Fennel Dried VAP 1
|
||||
Spices, Pepper Dried VAP 8
|
||||
Spices, Smoked Pepper Dried VAP 20
|
||||
Spicy Pepper Relish Pickles & Relishes VAP 73 1 74 31 1 32 43% 20 20 33 33 165%
|
||||
Spicy Pepper Syrup Drink Mixes & Syrups VAP 12 12 1 1 8% 14 9 23 6 6 26%
|
||||
Spicy Walla Walla w/ Bangkok Side VAP 7 7 0 0%
|
||||
Spring Onion Relish Pickles & Relishes VAP 12 12 8 8 67% 0 3 3 NEG
|
||||
Spring Onion Soup Soup VAP 19 5 24 5 5 21% 0 4 7 11 NEG
|
||||
Strawberry Espelette Jam Jams & Spreads VAP 21 21 100 100 52 52 52% 0 25 25 NEG
|
||||
Strawberry Jam Jams & Spreads VAP 20 10 30 179 51 230 105 34 139 60% 100 28 128 125 34 159 124%
|
||||
Strawberry Balsamic Jam Jams & Spreads VAP 12 12 10 10 83% 8 8 0%
|
||||
Strawberry Lavender Jam Jams & Spreads VAP 59 38 97 52 27 79 81% 100 49 149 92 40 132 89%
|
||||
Strawberry Peach Jam Jams & Spreads VAP 55 19 74 35 8 43 58% 104 40 144 56 12 68 47%
|
||||
Strawberry Pear Jam Jams & Spreads VAP 72 25 97 19 6 25 26% 0 46 16 62 NEG
|
||||
Strawberry Quince Jam Jams & Spreads VAP 8 8 6 6 75%
|
||||
Strawberry Rhubarb Jam Jams & Spreads VAP 48 23 71 34 7 41 58% 96 38 134 104 20 124 93%
|
||||
Strawberry Syrup Drink Mixes & Syrups VAP 0 4 4 NEG 1 23 24 14 14 58%
|
||||
Strawberry Vanilla Jam Jams & Spreads VAP 20 6 26 52 9 61 63 42 105 66 37 103 98% 86 27 113 80 23 103 91%
|
||||
Strawberry Vanilla Syrup Drink Mixes & Syrups VAP 5 5 0 0%
|
||||
Sweet Pepper Relish Pickles & Relishes VAP 26 26 12 12 46%
|
||||
Sweet Peppers Condiment VAP 18 18 27 14 41 12 12 29% 0 16 4 20 NEG
|
||||
Sweet Sour Red Cabbage Side VAP 43 43 16 16 37% 0 20 20 NEG
|
||||
Szechuan Broccoli Pickles & Relishes VAP 0 1 2 3 NEG
|
||||
Tayberry Jam Jams & Spreads VAP 12 12 11 10 21 175% 38 12 50 36 8 44 88%
|
||||
Tomatillo Chutney Chutney VAP 19 19 5 5 72 72 10 3 13 18% 0 19 19 NEG
|
||||
Tomatillo Jam Jams & Spreads VAP 6 27 33 4 4 12% 37 6 43 41 12 53 123%
|
||||
Tomato Basil Soup Soup VAP 42 6 48 36 4 40 83% 31 1 32 26 5 31 97%
|
||||
Tomato Juice Cocktail Drink Mixes & Syrups VAP 9 9 0 0% 0 9 9 NEG
|
||||
Tomato Sauce, Basil Condiment VAP 29 29 24 24 4 16 20 83% 35 35 30 30 86%
|
||||
Tomato Sauce, Fennel Condiment VAP 8 8 2 2 25% 0 9 9 NEG
|
||||
Tomato Sauce, Oregano Condiment VAP 28 28 2 2 7% 23 23 19 19 83%
|
||||
Tokyo Turnips Pickles & Relishes VAP 17 17 18 18 0 6 6 NEG
|
||||
White Peach Chutney Chutney VAP 0 18 8 26 NEG 15 15 6 6 40%
|
||||
Wild Plum Jam Jams & Spreads VAP 35 35 15 15 43%
|
||||
Wild Plum Syrup Drink Mixes & Syrups VAP 13 1 14 8 8 57%
|
||||
Winter Squash Soup Soup VAP 21 21 7 7 12 1 13 186% 22 22 8 1 9 41%
|
||||
|
221
importItems.js
Normal file
221
importItems.js
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
var fs = require("fs");
|
||||
var csv = require('./csv.js');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
var fileName = "./importItems.csv";
|
||||
|
||||
// module.exports = function(models, softErrors) {
|
||||
// return new Promise(function(resolve, reject) {
|
||||
var models = require("./models");
|
||||
var softErrors = [];
|
||||
var p = new Promise(function(resolve, reject) {
|
||||
//var sequelize = models.sequelize;
|
||||
//The CSV data as an array of rows (each row is an array).
|
||||
var data;
|
||||
//The mapping of model attributes to CSV columns. The oz sizes are arrays of columns since there are multiple.
|
||||
var map = {};
|
||||
//The id's in the db for the various jar sizes.
|
||||
var measureIdMap = {};
|
||||
//The id of the 'each' measure.
|
||||
var eachId = -1;
|
||||
//A default price for all items.
|
||||
var DEFAULT_PRICE = 11.0;
|
||||
|
||||
//Collect the metadata from the first row of the CSV data - make a mapping.
|
||||
function collectMetadata() {
|
||||
var CATEGORY = 'category';
|
||||
var SUBCATEGORY = 'subcategory';
|
||||
var ITEM = 'item';
|
||||
var OZ32 = '32 oz';
|
||||
var OZ16 = '16 oz';
|
||||
var OZ12 = '12 oz';
|
||||
var OZ8 = '8 oz';
|
||||
var OZ4 = '4 oz';
|
||||
|
||||
//Data is an array of arrays. data[0] = array of headers. data[1] = first row of data.
|
||||
//Iterate over the columns to create a mapping.
|
||||
for(var i = 0; i < data[0].length; i++) {
|
||||
var next = data[0][i];
|
||||
|
||||
if(next && next != '') {
|
||||
switch(next.toLowerCase()) {
|
||||
case CATEGORY:
|
||||
map.category = i;
|
||||
break;
|
||||
case SUBCATEGORY:
|
||||
map.subcategory = i;
|
||||
break;
|
||||
case ITEM:
|
||||
map.item = i;
|
||||
break;
|
||||
case OZ32:
|
||||
if(!map.oz32) map.oz32 = [];
|
||||
map.oz32.push(i);
|
||||
break;
|
||||
case OZ16:
|
||||
if(!map.oz16) map.oz16 = [];
|
||||
map.oz16.push(i);
|
||||
break;
|
||||
case OZ12:
|
||||
if(!map.oz12) map.oz12 = [];
|
||||
map.oz12.push(i);
|
||||
break;
|
||||
case OZ8:
|
||||
if(!map.oz8) map.oz8 = [];
|
||||
map.oz8.push(i);
|
||||
break;
|
||||
case OZ4:
|
||||
if(!map.oz4) map.oz4 = [];
|
||||
map.oz4.push(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Reads a single row of CSV data and adds it to the database.
|
||||
function readRow(rowIndex) {
|
||||
if(!data) {
|
||||
console.log("WTF?");
|
||||
//process.exit(1);
|
||||
reject(new Error("Data is null?!?"));
|
||||
return;
|
||||
}
|
||||
else if(!data[rowIndex]) {
|
||||
softErrors.push("Empty line? - Found while reading items.");
|
||||
readRow(rowIndex + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
var category = data[rowIndex][map.category];
|
||||
var subcategory = data[rowIndex][map.subcategory];
|
||||
var item = data[rowIndex][map.item];
|
||||
var oz32 = 0;
|
||||
var oz16 = 0;
|
||||
var oz12 = 0;
|
||||
var oz8 = 0;
|
||||
var oz4 = 0;
|
||||
|
||||
for(var o = 0; o < map.oz32.length; o++) {
|
||||
oz32 += Math.max(data[rowIndex][map.oz32[o]], 0);
|
||||
}
|
||||
|
||||
for(var o = 0; o < map.oz16.length; o++) {
|
||||
oz16 += Math.max(data[rowIndex][map.oz16[o]], 0);
|
||||
}
|
||||
|
||||
for(var o = 0; o < map.oz12.length; o++) {
|
||||
oz12 += Math.max(data[rowIndex][map.oz12[o]], 0);
|
||||
}
|
||||
|
||||
for(var o = 0; o < map.oz8.length; o++) {
|
||||
oz8 += Math.max(data[rowIndex][map.oz8[o]], 0);
|
||||
}
|
||||
|
||||
for(var o = 0; o < map.oz4.length; o++) {
|
||||
oz4 += Math.max(data[rowIndex][map.oz4[o]], 0);
|
||||
}
|
||||
|
||||
//If the category doesn't yet exist then add it, otherwise get the ID.
|
||||
models.Category.findOrCreate({where: {name: category}, defaults: {name: category}}).then(function(result) {
|
||||
var categoryId = result[0].id; //Note: result[1] is a boolean indicating whether the object had to be created.
|
||||
|
||||
//If the subcategory doesn't yet exist then add it, otherwise get the ID.
|
||||
models.Subcategory.findOrCreate({
|
||||
where: {name: subcategory},
|
||||
defaults: {name: subcategory, categoryId: categoryId}
|
||||
}).then(function(result) {
|
||||
var subcategoryId = result[0].id;
|
||||
var weightedMeasures = [];
|
||||
var measures = [];
|
||||
|
||||
if(oz32 > 0) weightedMeasures.push({name: '32 oz', count: oz32});
|
||||
if(oz16 > 0) weightedMeasures.push({name: '16 oz', count: oz16});
|
||||
if(oz12 > 0) weightedMeasures.push({name: '12 oz', count: oz12});
|
||||
if(oz8 > 0) weightedMeasures.push({name: '8 oz', count: oz8});
|
||||
if(oz4 > 0) weightedMeasures.push({name: '4 oz', count: oz4});
|
||||
|
||||
if(weightedMeasures.length == 0) {
|
||||
measures.push(eachId);
|
||||
}
|
||||
else {
|
||||
//Place the measure that had the most jars at the front of the list.
|
||||
weightedMeasures.sort(function(a, b) {
|
||||
return a.count >= b.count ? 1 : -1;
|
||||
});
|
||||
|
||||
//Build the array of measure id's.
|
||||
for(var i = 0; i < weightedMeasures.length; i++) {
|
||||
measures.push(measureIdMap[weightedMeasures[i].name]);
|
||||
}
|
||||
}
|
||||
|
||||
//Ensure the item doesn't yet exist - display an error if it does, otherwise add it.
|
||||
models.Item.findOrCreate({
|
||||
where: {name: item},
|
||||
defaults: {name: item, subcategoryId: subcategoryId, measures: measures}
|
||||
}).then(function(result) {
|
||||
if(!result[1]) {
|
||||
console.log("The item named '" + item + "' already exists in the database.");
|
||||
}
|
||||
|
||||
//Recursively read rows until there are no more rows to read.
|
||||
if(rowIndex + 1 < data.length) readRow(rowIndex + 1);
|
||||
else resolve();
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(fs.existsSync(fileName)) {
|
||||
csv.read(fileName, function(error, csvData) {
|
||||
if(error) console.log(error);
|
||||
else {
|
||||
data = csvData;
|
||||
//Collect the mapping data.
|
||||
collectMetadata();
|
||||
|
||||
//Read or create the required models to make this all work:
|
||||
Promise.each([
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 32oz'}, defaults: {name: 'Jar 32oz', postfix: '32oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 16oz'}, defaults: {name: 'Jar 16oz', postfix: '16oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 12oz'}, defaults: {name: 'Jar 12oz', postfix: '12oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 8oz'}, defaults: {name: 'Jar 8oz', postfix: '8oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Jar 4oz'}, defaults: {name: 'Jar 4oz', postfix: '4oz'}}),
|
||||
models.Measure.findOrCreate({where: {name: 'Each'}, defaults: {name: 'Each', postfix: ''}})
|
||||
], function(value, index, length) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
measureIdMap['32 oz'] = value[0].id;
|
||||
break;
|
||||
case 1:
|
||||
measureIdMap['16 oz'] = value[0].id;
|
||||
break;
|
||||
case 2:
|
||||
measureIdMap['12 oz'] = value[0].id;
|
||||
break;
|
||||
case 3:
|
||||
measureIdMap['8 oz'] = value[0].id;
|
||||
break;
|
||||
case 4:
|
||||
measureIdMap['4 oz'] = value[0].id;
|
||||
break;
|
||||
case 5:
|
||||
eachId = value[0].id;
|
||||
break;
|
||||
}
|
||||
}).then(function() {
|
||||
//Read the first row.
|
||||
readRow(1);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("Cannot find " + fileName);
|
||||
}
|
||||
});
|
||||
|
||||
p.then(function() {console.log("Import Complete!")}).error(function(error) {console.log("Ran into an error: \n" + error)});
|
||||
// };
|
||||
416
importSales.js
Normal file
416
importSales.js
Normal file
@@ -0,0 +1,416 @@
|
||||
|
||||
var fs = require("fs");
|
||||
var csv = require('./csv.js');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
var fileName = "./importSales.csv";
|
||||
|
||||
// module.exports = function(models, softErrors, handler) {
|
||||
// return new Promise(function(resolve, reject) {
|
||||
var models = require("./models");
|
||||
var softErrors = [];
|
||||
var p = new Promise(function(resolve, reject) {
|
||||
//The CSV data as an array of rows (each row is an array).
|
||||
var data;
|
||||
//The mapping of model attributes to CSV columns. The oz sizes are arrays of columns since there are multiple.
|
||||
var map = {};
|
||||
|
||||
//Database maps so we don't have to constantly query for the same data repeatedly.
|
||||
var vendorIdMap = {};
|
||||
var measureIdMap = {};
|
||||
var itemIdMap = {};
|
||||
|
||||
//Collect the metadata from the first row of the CSV data - make a mapping.
|
||||
function collectMetadata() {
|
||||
var DATE = 'date';
|
||||
var VENDOR = 'vendor';
|
||||
var ITEM = 'item';
|
||||
var OZ32 = '32 oz';
|
||||
var OZ16 = '16 oz';
|
||||
var OZ12 = '12 oz';
|
||||
var OZ8 = '8 oz';
|
||||
var OZ4 = '4 oz';
|
||||
var BAGS = 'bags';
|
||||
var EACH = 'each';
|
||||
|
||||
//Data is an array of arrays. data[0] = array of headers. data[1] = first row of data.
|
||||
//Iterate over the columns to create a mapping.
|
||||
for(var i = 0; i < data[0].length; i++) {
|
||||
var next = data[0][i];
|
||||
|
||||
if(next && next != '') {
|
||||
switch(next.toLowerCase()) {
|
||||
case DATE:
|
||||
map.date = i;
|
||||
break;
|
||||
case VENDOR:
|
||||
map.vendor = i;
|
||||
break;
|
||||
case ITEM:
|
||||
map.item = i;
|
||||
break;
|
||||
case OZ32:
|
||||
map.oz32 = i;
|
||||
break;
|
||||
case OZ16:
|
||||
map.oz16 = i;
|
||||
break;
|
||||
case OZ12:
|
||||
map.oz12 = i;
|
||||
break;
|
||||
case OZ8:
|
||||
map.oz8 = i;
|
||||
break;
|
||||
case OZ4:
|
||||
map.oz4 = i;
|
||||
break;
|
||||
case BAGS:
|
||||
map.bags = i;
|
||||
break;
|
||||
case EACH:
|
||||
map.each = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Reads a single row of CSV data and adds it to the database.
|
||||
function readRow(rowIndex) {
|
||||
if(!data) {
|
||||
console.log("WTF?");
|
||||
//process.exit(1);
|
||||
reject(new Error("Data is null?!?"));
|
||||
return;
|
||||
}
|
||||
else if(!data[rowIndex]) {
|
||||
console.log("Empty line?");
|
||||
readRow(rowIndex + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
var date = data[rowIndex][map.date];
|
||||
var vendor = data[rowIndex][map.vendor];
|
||||
var item = data[rowIndex][map.item];
|
||||
var oz32 = data[rowIndex][map.oz32];
|
||||
var oz16 = data[rowIndex][map.oz16];
|
||||
var oz12 = data[rowIndex][map.oz12];
|
||||
var oz8 = data[rowIndex][map.oz8];
|
||||
var oz4 = data[rowIndex][map.oz4];
|
||||
var bags = data[rowIndex][map.bags];
|
||||
var each = data[rowIndex][map.each];
|
||||
|
||||
var vendorId = vendorIdMap[vendor];
|
||||
var itemId = itemIdMap[item];
|
||||
var priceMap = {};
|
||||
|
||||
var saleQueries = [];
|
||||
|
||||
//TODO: Trim and lowercase any names.
|
||||
priceMap[2016] = {
|
||||
oz4: 7,
|
||||
oz8: 11,
|
||||
oz12: 13,
|
||||
oz16: 11,
|
||||
oz32: 15,
|
||||
"pickled onion, spicy": {oz16: 12},
|
||||
"pickled onion, sweet": {oz16: 12},
|
||||
"pickled onion, fennel": {oz16: 12},
|
||||
"pickled beets": {oz16: 15},
|
||||
"prickly pear margarita mix": {oz16: 15},
|
||||
"prickly pear syrup": {oz16: 15},
|
||||
"tomato sauce": {oz16: 15}, //TODO: Replace all 'tomato sauce, xxxx' with 'tomato sauce' for price lookup only.
|
||||
"bone broth": {oz16: 20}, //TODO: Replace all 'bone broth, xxxx' with 'bone broth' for price lookup only.
|
||||
"fava bean soup": {oz32: 20},
|
||||
"pickles, bread butter": {oz16: 11},
|
||||
"kimchi": {oz16: 11},
|
||||
"kraut - red & white": {oz16: 11},
|
||||
|
||||
"3 pack": {each: 21},
|
||||
"espelette, smoked": {each: 1},
|
||||
"leather": {each: 6},
|
||||
"leather, apple": {each: 6},
|
||||
"leather, grape": {each: 6},
|
||||
"leather, peach": {each: 6},
|
||||
"leather, persimmon": {each: 6},
|
||||
"leather, pumpkin": {each: 6},
|
||||
"leather, strawberry": {each: 6},
|
||||
"leather, quince": {each: 6},
|
||||
"membrillo": {each: 7},
|
||||
"membrillo candy": {each: 2.5},
|
||||
"spices": {each: 4},
|
||||
"spices, basil/coriander": {each: 4},
|
||||
"spices, fennel": {each: 4},
|
||||
"spices, other": {each: 4},
|
||||
"spices, pepper": {each: 4},
|
||||
"spices, smoked": {each: 4},
|
||||
|
||||
"baba ganoush": {bag: 8, oz4: 8},
|
||||
"dried, pear": {bag: 6}, //Price??
|
||||
"dried, tomatillo": {bag: 6}, //Price??
|
||||
"dried, strawberry": {bag: 7.5},
|
||||
"dried, tomato": {bag: 7},
|
||||
"pesto": {bags: 8},
|
||||
"pesto, cilantro jalapeno": {bags: 8},
|
||||
"pesto, eggplant": {bags: 8},
|
||||
"pesto, mint": {bags: 8},
|
||||
"pesto, jalapeno": {bags: 8},
|
||||
"jalapeno candy": {bags: 5},
|
||||
"tomato, dried": {bag: 7}, //Spelling??? Should be Dried, Tomato
|
||||
|
||||
|
||||
//Fresh
|
||||
"persimmons": {lbs: 5},
|
||||
"persimmon, frozen": {lbs: 5},
|
||||
"dried, persimmon": {lbs: 5},
|
||||
|
||||
"eggs": {each: 11}
|
||||
};
|
||||
|
||||
priceMap[2015] = {
|
||||
oz4: 6,
|
||||
oz8: 10,
|
||||
oz12: 13,
|
||||
oz16: 10,
|
||||
oz32: 15,
|
||||
"blackberry jam": {oz4: 7, oz8: 12},
|
||||
"raspberry jam": {oz4: 7, oz8: 12},
|
||||
"blackberry vanilla": {oz4: 7, oz8: 12},
|
||||
"bloody mary mix": {oz16: 13},
|
||||
"pickled beets": {oz16: 15},
|
||||
"tomato juice cocktail": {oz16: 8},
|
||||
"fava bean soup": {oz32: 20},
|
||||
"kimchi": {oz16: 10},
|
||||
"kraut - red & white": {oz16: 10},
|
||||
"bread & butter pickles": {oz16: 10},
|
||||
"pickled eggs": {oz16: 15},
|
||||
|
||||
"3 pack": {each: 18},
|
||||
"leather": {each: 6},
|
||||
"leather, apple": {each: 6},
|
||||
"leather, grape": {each: 6},
|
||||
"leather, peach": {each: 6},
|
||||
"leather, persimmon": {each: 6},
|
||||
"leather, pumpkin": {each: 6},
|
||||
"leather, strawberry": {each: 6},
|
||||
"leather, quince": {each: 6},
|
||||
"membrillo": {each: 6},
|
||||
"membrillo candy": {each: 2.5},
|
||||
"popsicles": {each: 5},
|
||||
"spices": {each: 4},
|
||||
"spices, basil/coriander": {each: 4},
|
||||
"spices, fennel": {each: 4},
|
||||
"spices, other": {each: 4},
|
||||
"spices, pepper": {each: 4},
|
||||
"spices, smoked": {each: 4},
|
||||
|
||||
"baba ganoush": {bag: 8, oz4: 8},
|
||||
"dried, pear": {bag: 6}, //Price??
|
||||
"dried, tomatillo": {bag: 6}, //Price??
|
||||
"dried, strawberry": {bag: 7.5},
|
||||
"dried, tomato": {bag: 7},
|
||||
"jalapeno candy": {bag: 5},
|
||||
|
||||
"eggs": {each: 10},
|
||||
};
|
||||
|
||||
//Log errors, but keep on chugging.
|
||||
if(vendorId == undefined) {
|
||||
softErrors.push("ERROR: Unexpected vendor: " + vendor);
|
||||
}
|
||||
else if(itemId == undefined) {
|
||||
softErrors.push("ERROR: Unexpected item: " + item);
|
||||
}
|
||||
else {
|
||||
//Split it into multiple sales entries, one for each measure that has a positive value.
|
||||
if(oz32 > 0) {
|
||||
var measureId = measureIdMap['32 oz'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['oz32'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
if(oz16 > 0) {
|
||||
var measureId = measureIdMap['16 oz'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['oz16'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
if(oz12 > 0) {
|
||||
var measureId = measureIdMap['12 oz'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['oz12'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
if(oz8 > 0) {
|
||||
var measureId = measureIdMap['8 oz'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['oz8'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
if(oz4 > 0) {
|
||||
var measureId = measureIdMap['4 oz'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['oz4'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
if(bags > 0) {
|
||||
var measureId = measureIdMap['bags'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['bags'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
if(each > 0) {
|
||||
var measureId = measureIdMap['each'];
|
||||
var price = priceMap[year][item];
|
||||
|
||||
if(price == undefined) {
|
||||
price = priceMap[year]['each'];
|
||||
}
|
||||
|
||||
saleQueries.push(models.Sale.create({date: date, vendorId: vendorId, itemId: itemId, measureId: measureId, amount: oz32, price: price}));
|
||||
}
|
||||
|
||||
Promise.each(saleQueries, function(value, index, length) {
|
||||
//Ignored.
|
||||
}).then(function(result) {
|
||||
//Recursively read rows until there are no more rows to read.
|
||||
if(rowIndex + 1 < data.length) readRow(rowIndex + 1);
|
||||
else resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(fs.existsSync(fileName)) {
|
||||
csv.read(fileName, function(error, csvData) {
|
||||
if(error) console.log(error);
|
||||
else {
|
||||
data = csvData;
|
||||
//Collect the mapping data.
|
||||
collectMetadata();
|
||||
|
||||
//Read or create the required models to make this all work:
|
||||
Promise.each([
|
||||
//Measures 1-6
|
||||
models.Measure.find({where: {name: 'Jar 32oz'}}),
|
||||
models.Measure.find({where: {name: 'Jar 16oz'}}),
|
||||
models.Measure.find({where: {name: 'Jar 12oz'}}),
|
||||
models.Measure.find({where: {name: 'Jar 8oz'}}),
|
||||
models.Measure.find({where: {name: 'Jar 4oz'}}),
|
||||
models.Measure.find({where: {name: 'Each'}}),
|
||||
models.Measure.find({where: {name: 'Bags'}}),
|
||||
//Vendors 7-16
|
||||
models.Venue.find({where: {name: 'Boonville'}}),
|
||||
models.Venue.find({where: {name: 'Clement St'}}),
|
||||
models.Venue.find({where: {name: 'Ukiah'}}),
|
||||
models.Venue.find({where: {name: 'Mendocino'}}),
|
||||
models.Venue.find({where: {name: 'Ft Bragg'}}),
|
||||
models.Venue.find({where: {name: 'On Farm'}}),
|
||||
models.Venue.find({where: {name: 'Unknown Restaurant'}}),
|
||||
models.Venue.find({where: {name: 'Yorkville Market'}}),
|
||||
models.Venue.find({where: {name: 'Yorkville Cellars'}}),
|
||||
models.Venue.find({where: {name: 'Mail Order'}}),
|
||||
//Items
|
||||
models.Item.findAll()
|
||||
], function(value, index, length) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
measureIdMap['32 oz'] = value.id;
|
||||
break;
|
||||
case 1:
|
||||
measureIdMap['16 oz'] = value.id;
|
||||
break;
|
||||
case 2:
|
||||
measureIdMap['12 oz'] = value.id;
|
||||
break;
|
||||
case 3:
|
||||
measureIdMap['8 oz'] = value.id;
|
||||
break;
|
||||
case 4:
|
||||
measureIdMap['4 oz'] = value.id;
|
||||
break;
|
||||
case 5:
|
||||
measureIdMap['each'] = value.id;
|
||||
break;
|
||||
case 6:
|
||||
measureIdMap['bags'] = value.id;
|
||||
break;
|
||||
case 7:
|
||||
vendorIdMap['bv'] = value.id;
|
||||
break;
|
||||
case 8:
|
||||
vendorIdMap['sf'] = value.id;
|
||||
break;
|
||||
case 9:
|
||||
vendorIdMap['uk'] = value.id;
|
||||
break;
|
||||
case 10:
|
||||
vendorIdMap['men'] = value.id;
|
||||
break;
|
||||
case 11:
|
||||
vendorIdMap['fb'] = value.id;
|
||||
break;
|
||||
case 12:
|
||||
vendorIdMap['of'] = value.id;
|
||||
break;
|
||||
case 13:
|
||||
vendorIdMap['res'] = value.id;
|
||||
break;
|
||||
case 14:
|
||||
vendorIdMap['ym'] = value.id;
|
||||
break;
|
||||
case 15:
|
||||
vendorIdMap['yc'] = value.id;
|
||||
break;
|
||||
case 16:
|
||||
vendorIdMap['mo'] = value.id;
|
||||
break;
|
||||
case 17:
|
||||
//Iterate over all the items and setup the itemIdMap to reference the item id given the item name. Item names are unique.
|
||||
for(var i = 0; i < value.length; i++) {
|
||||
itemIdMap[value[i].name] = value[i].id;
|
||||
}
|
||||
}
|
||||
}).then(function() {
|
||||
//Read the first row.
|
||||
readRow(1);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("Cannot find " + fileName);
|
||||
}
|
||||
});
|
||||
|
||||
p.then(function() {console.log("Import Complete!")}).error(function(error) {console.log("Ran into an error: \n" + error)});
|
||||
// };
|
||||
@@ -12,7 +12,8 @@ module.exports = {
|
||||
autoIncrement: true
|
||||
},
|
||||
login: {
|
||||
type: DataTypes.STRING
|
||||
type: DataTypes.STRING,
|
||||
unique: true
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING
|
||||
|
||||
@@ -13,7 +13,8 @@ module.exports = {
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
image: {
|
||||
type: DataTypes.STRING,
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = {
|
||||
up: function (query, Sequelize) {
|
||||
var DataTypes = Sequelize; //Allow for more cut and paste :)
|
||||
|
||||
return query.createTable('Venue', {
|
||||
return query.createTable('VenueType', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
@@ -13,7 +13,8 @@ module.exports = {
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
@@ -35,6 +36,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
down: function (query, Sequelize) {
|
||||
return query.dropTable('Venue');
|
||||
return query.dropTable('VenueType');
|
||||
}
|
||||
};
|
||||
49
migrations/20160602030147-Venue.js
Normal file
49
migrations/20160602030147-Venue.js
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: function (query, Sequelize) {
|
||||
var DataTypes = Sequelize; //Allow for more cut and paste :)
|
||||
|
||||
return query.createTable('Venue', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
autoIncrement: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
typeId: {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'VenueType',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'cascade',
|
||||
onDelete: 'cascade'
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false
|
||||
},
|
||||
deletedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
charset: 'utf8',
|
||||
timestamps: true,
|
||||
paranoid: true
|
||||
});
|
||||
},
|
||||
|
||||
down: function (query, Sequelize) {
|
||||
return query.dropTable('Venue');
|
||||
}
|
||||
};
|
||||
@@ -13,7 +13,8 @@ module.exports = {
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
@@ -15,7 +15,8 @@ module.exports = {
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
field: 'name',
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
categoryId: {
|
||||
type: Sequelize.INTEGER,
|
||||
@@ -13,7 +13,8 @@ module.exports = {
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
measures: {
|
||||
type: DataTypes.JSON,
|
||||
@@ -23,9 +24,10 @@ module.exports = {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true
|
||||
},
|
||||
defaultPrice: {
|
||||
type: DataTypes.DECIMAL(9,2),
|
||||
allowNull: false
|
||||
prices: {
|
||||
type: DataTypes.JSON,
|
||||
//type: DataTypes.DECIMAL(9,2),
|
||||
allowNull: true
|
||||
},
|
||||
subcategoryId: {
|
||||
type: Sequelize.INTEGER,
|
||||
@@ -22,9 +22,10 @@ module.exports = function(sequelize, DataTypes) {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true
|
||||
},
|
||||
defaultPrice: {
|
||||
type: DataTypes.DECIMAL(9,2),
|
||||
allowNull: false
|
||||
prices: {
|
||||
type: DataTypes.JSON,
|
||||
//type: DataTypes.DECIMAL(9,2),
|
||||
allowNull: true
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
|
||||
@@ -27,6 +27,11 @@ module.exports = function(sequelize, DataTypes) {
|
||||
}
|
||||
}, {
|
||||
freezeTableName: true, // Model tableName will be the same as the model name,
|
||||
paranoid: true
|
||||
paranoid: true,
|
||||
classMethods: {
|
||||
associate: function(models) {
|
||||
models.Venue.belongsTo(models.VenueType, {as: 'type', foreignKey: {name: 'typeId', field: 'typeId'}});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
32
models/venueType.js
Normal file
32
models/venueType.js
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
//The id field is auto added and made primary key.
|
||||
return sequelize.define('VenueType', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
autoIncrement: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false
|
||||
},
|
||||
deletedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
freezeTableName: true, // Model tableName will be the same as the model name,
|
||||
paranoid: true
|
||||
});
|
||||
};
|
||||
@@ -11,7 +11,10 @@
|
||||
"start": "node server.js",
|
||||
"migrateDB": "sequelize db:migrate",
|
||||
"dropDB": "sudo -u postgres dropdb PetitTeton",
|
||||
"createDB": "sudo -u postgres createdb PetitTeton"
|
||||
"createDB": "sudo -u postgres createdb PetitTeton",
|
||||
"import1": "node importAll.js",
|
||||
"import2": "node importItems.js",
|
||||
"import3": "node %NODE_DEBUG_OPTION% importSales.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"bcrypt-nodejs": "^0.0.3",
|
||||
@@ -38,6 +41,7 @@
|
||||
"serve-favicon": "~2.2.0",
|
||||
"session-file-store": "~0.0.24",
|
||||
"stylus": "~0.42.3",
|
||||
"swig": "~1.4.2"
|
||||
"swig": "~1.4.2",
|
||||
"csv-parse": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<table id="dataTable" class="table table-striped table-hover">
|
||||
<table id="dataTable" class="table table-striped table-hover" tabindex="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-key-name="name">Name</th>
|
||||
@@ -99,7 +99,8 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.buildTable({
|
||||
url: "data/Venue/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
@@ -122,16 +123,19 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
$page.find('#dataTable').on('dblclick', 'tr', function(event) {
|
||||
if(dataTable.getSelectedRow()) {
|
||||
location.hash = "#!/venues-edit";
|
||||
}
|
||||
});
|
||||
$page.find('#dataTable').on('keyup', 'table', function(event) {
|
||||
|
||||
$page.find('#page').on('keyup', '.page', function(event) {
|
||||
switch(event.keyCode || event.which) {
|
||||
case 0x0D: //Enter
|
||||
if(dataTable.getSelectedRow()) {
|
||||
$btnEdit.click();
|
||||
location.hash = '#!/venues-edit';
|
||||
}
|
||||
break;
|
||||
case 0x08: //Backspace
|
||||
@@ -144,9 +148,6 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
dataTable.build();
|
||||
|
||||
//Refresh the data table if the user toggles the button to show/hide deleted elements.
|
||||
$page.find('#includeDeletedToggle').on('click', function(event) {
|
||||
dataTable.refresh();
|
||||
@@ -247,6 +248,16 @@ $(function() {
|
||||
});
|
||||
});
|
||||
|
||||
//Close the view if the user uses the escape key and it isn't handled at the widget level.
|
||||
$editorView.on('keyup', function(event) {
|
||||
switch(event.keyCode) {
|
||||
case 27:
|
||||
if(!event.isDefaultPrevented())
|
||||
history.back();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++ Delete View +++++++++++
|
||||
|
||||
|
||||
3
public/admin/bootstrap.styl
vendored
3
public/admin/bootstrap.styl
vendored
@@ -13,7 +13,8 @@ input[type="url"]:focus,
|
||||
input[type="search"]:focus,
|
||||
input[type="tel"]:focus,
|
||||
input[type="color"]:focus,
|
||||
.uneditable-input:focus {
|
||||
.uneditable-input:focus,
|
||||
.list-group:focus {
|
||||
border-color: rgba(82, 168, 236, 0.8);
|
||||
outline: 0;
|
||||
outline: thin dotted \9;
|
||||
|
||||
@@ -99,7 +99,8 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.buildTable({
|
||||
url: "data/Category/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
@@ -122,15 +123,14 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
$page.find('#dataTable').on('dblclick', 'tr', function(event) {
|
||||
if(dataTable.getSelectedRow()) {
|
||||
location.hash = "#!/categories-edit";
|
||||
}
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
dataTable.build();
|
||||
|
||||
//Refresh the data table if the user toggles the button to show/hide deleted elements.
|
||||
$page.find('#includeDeletedToggle').on('click', function(event) {
|
||||
dataTable.refresh();
|
||||
@@ -231,6 +231,16 @@ $(function() {
|
||||
});
|
||||
});
|
||||
|
||||
//Close the view if the user uses the escape key and it isn't handled at the widget level.
|
||||
$editorView.on('keyup', function(event) {
|
||||
switch(event.keyCode) {
|
||||
case 27:
|
||||
if(!event.isDefaultPrevented())
|
||||
history.back();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++ Delete View +++++++++++
|
||||
|
||||
|
||||
258
public/admin/css/jsgrid-theme.css
Normal file
258
public/admin/css/jsgrid-theme.css
Normal file
File diff suppressed because one or more lines are too long
7
public/admin/css/jsgrid-theme.min.css
vendored
Normal file
7
public/admin/css/jsgrid-theme.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
126
public/admin/css/jsgrid.css
Normal file
126
public/admin/css/jsgrid.css
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* jsGrid v1.5.2 (http://js-grid.com)
|
||||
* (c) 2016 Artem Tabalin
|
||||
* Licensed under MIT (https://github.com/tabalinas/jsgrid/blob/master/LICENSE)
|
||||
*/
|
||||
|
||||
.jsgrid {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.jsgrid, .jsgrid *, .jsgrid *:before, .jsgrid *:after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.jsgrid input,
|
||||
.jsgrid textarea,
|
||||
.jsgrid select {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.jsgrid-grid-header {
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.jsgrid-grid-body {
|
||||
overflow-x: auto;
|
||||
overflow-y: scroll;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.jsgrid-table {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.jsgrid-cell {
|
||||
padding: 0.5em 0.5em;
|
||||
}
|
||||
|
||||
.jsgrid-сell,
|
||||
.jsgrid-header-cell {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.jsgrid-align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.jsgrid-align-center,
|
||||
.jsgrid-align-center input,
|
||||
.jsgrid-align-center textarea,
|
||||
.jsgrid-align-center select {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.jsgrid-align-right,
|
||||
.jsgrid-align-right input,
|
||||
.jsgrid-align-right textarea,
|
||||
.jsgrid-align-right select {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.jsgrid-header-cell {
|
||||
padding: .5em .5em;
|
||||
}
|
||||
|
||||
.jsgrid-filter-row input,
|
||||
.jsgrid-filter-row textarea,
|
||||
.jsgrid-filter-row select,
|
||||
.jsgrid-edit-row input,
|
||||
.jsgrid-edit-row textarea,
|
||||
.jsgrid-edit-row select,
|
||||
.jsgrid-insert-row input,
|
||||
.jsgrid-insert-row textarea,
|
||||
.jsgrid-insert-row select {
|
||||
width: 100%;
|
||||
padding: .3em .5em;
|
||||
}
|
||||
|
||||
.jsgrid-filter-row input[type='checkbox'],
|
||||
.jsgrid-edit-row input[type='checkbox'],
|
||||
.jsgrid-insert-row input[type='checkbox'] {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
|
||||
.jsgrid-selected-row .jsgrid-cell {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jsgrid-nodata-row .jsgrid-cell {
|
||||
padding: .5em 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.jsgrid-header-sort {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jsgrid-pager {
|
||||
padding: .5em 0;
|
||||
}
|
||||
|
||||
.jsgrid-pager-nav-button {
|
||||
padding: .2em .6em;
|
||||
}
|
||||
|
||||
.jsgrid-pager-nav-inactive-button {
|
||||
display: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jsgrid-pager-page {
|
||||
padding: .2em .6em;
|
||||
}
|
||||
7
public/admin/css/jsgrid.min.css
vendored
Normal file
7
public/admin/css/jsgrid.min.css
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* jsGrid v1.5.2 (http://js-grid.com)
|
||||
* (c) 2016 Artem Tabalin
|
||||
* Licensed under MIT (https://github.com/tabalinas/jsgrid/blob/master/LICENSE)
|
||||
*/
|
||||
|
||||
.jsgrid{position:relative;overflow:hidden;font-size:1em}.jsgrid,.jsgrid *,.jsgrid :after,.jsgrid :before{box-sizing:border-box}.jsgrid input,.jsgrid select,.jsgrid textarea{font-size:1em}.jsgrid-grid-header{overflow-x:hidden;overflow-y:scroll;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.jsgrid-grid-body{overflow-x:auto;overflow-y:scroll;-webkit-overflow-scrolling:touch}.jsgrid-table{width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0}.jsgrid-cell{padding:.5em}.jsgrid-header-cell,.jsgrid-сell{box-sizing:border-box}.jsgrid-align-left{text-align:left}.jsgrid-align-center,.jsgrid-align-center input,.jsgrid-align-center select,.jsgrid-align-center textarea{text-align:center}.jsgrid-align-right,.jsgrid-align-right input,.jsgrid-align-right select,.jsgrid-align-right textarea{text-align:right}.jsgrid-header-cell{padding:.5em}.jsgrid-edit-row input,.jsgrid-edit-row select,.jsgrid-edit-row textarea,.jsgrid-filter-row input,.jsgrid-filter-row select,.jsgrid-filter-row textarea,.jsgrid-insert-row input,.jsgrid-insert-row select,.jsgrid-insert-row textarea{width:100%;padding:.3em .5em}.jsgrid-edit-row input[type=checkbox],.jsgrid-filter-row input[type=checkbox],.jsgrid-insert-row input[type=checkbox]{width:auto}.jsgrid-selected-row .jsgrid-cell{cursor:pointer}.jsgrid-nodata-row .jsgrid-cell{padding:.5em 0;text-align:center}.jsgrid-header-sort{cursor:pointer}.jsgrid-pager{padding:.5em 0}.jsgrid-pager-nav-button{padding:.2em .6em}.jsgrid-pager-nav-inactive-button{display:none;pointer-events:none}.jsgrid-pager-page{padding:.2em .6em}
|
||||
@@ -26,10 +26,12 @@
|
||||
<link rel="stylesheet" href="css/select2.css"/>
|
||||
<link rel="stylesheet" href="css/bootstrap-datetimepicker.css"/>
|
||||
<link rel="stylesheet" href="css/jquery.editable.select.css"/>
|
||||
<link rel="stylesheet" href="main.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="css/jsgrid.css"/>
|
||||
<link rel="stylesheet" href="css/jsgrid-theme.css"/>
|
||||
<link rel="stylesheet" href="index.css" type="text/css"/>
|
||||
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-1.11.3.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-migrate-1.2.1.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-1.12.4.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-migrate-1.3.0.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.history.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.cycle.min.js"></script>
|
||||
@@ -38,15 +40,16 @@
|
||||
<script type="text/javascript" language="JavaScript" src="js/scroller.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/polyfills.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/main.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/LinkedTable.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/moment.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/select2.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/validator.js"></script> <!-- https://github.com/1000hz/bootstrap-validator http://1000hz.github.io/bootstrap-validator/ -->
|
||||
<script type="text/javascript" language="JavaScript" src="js/bootstrap-datetimepicker.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.tabbable.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.editable.select.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/EditableSelect.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/de.table.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/de.combo.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.disableSelection.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jsgrid.js"></script>
|
||||
|
||||
<script type="text/javascript" language="JavaScript">
|
||||
//Add functionality to jquery to display a class listing.
|
||||
|
||||
@@ -204,3 +204,4 @@ sup, sub {
|
||||
@require "subcategories"
|
||||
@require "items"
|
||||
@require "sales"
|
||||
@require "prices"
|
||||
@@ -21,8 +21,7 @@
|
||||
<th data-key-name="name">Name</th>
|
||||
<th data-key-name="category">Category</th>
|
||||
<th data-key-name="subcategory">Subcategory</th>
|
||||
<th data-key-name="defaultPrice">Default Price</th>
|
||||
<th data-key-name="measures">Measures</th>
|
||||
<th data-key-name="prices">Prices</th>
|
||||
<th data-key-name="aliases">Aliases</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -38,7 +37,8 @@
|
||||
<h4 class="modal-title"></h4>
|
||||
</div>
|
||||
<form role="form" autocomplete="off">
|
||||
<div class="modal-body">
|
||||
<div class="modal-body row">
|
||||
<div class="col-sm-6">
|
||||
<label for="DFName">Name</label>
|
||||
<div class="form-group">
|
||||
<input name="name" id="DFName" type="text" class="form-control" tabindex="0" placeholder="Strawberry Jam" required>
|
||||
@@ -48,19 +48,24 @@
|
||||
<input name="subcategoryId" id="DFSubcategoryId" type="hidden"/>
|
||||
<input name="subcategory" id="DFSubcategory" class="form-control" type="text" tabindex="0" required/>
|
||||
</div>
|
||||
<label for="DFPrice">Default Price</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">$</span><input name="defaultPrice" id="DFPrice" type="number" min="0.00" step="0.50" value="10.00" data-number-to-fixed="2" class="form-control currency" tabindex="0" required>
|
||||
</div>
|
||||
<label for="DFMeasures">Measures</label>
|
||||
<div class="form-group">
|
||||
<select class="js-states form-control" name="measures" id="DFMeasures" multiple="multiple" tabindex="0" style="width: 100%;" required></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<label for="DFNewAlias">Aliases</label>
|
||||
<div class="input-group">
|
||||
<input name="newAlias" id="DFNewAlias" type="text" class="form-control text" tabindex="0"><span class="input-group-btn"><button id="DFNewAliasAdd" class="btn" type="button">Add</button></span>
|
||||
</div>
|
||||
<div id="DFAliases" class="list-group" tabindex="0">
|
||||
<div id="DFAliases" class="form-control list-group" tabindex="0">
|
||||
</div>
|
||||
<!--<label>Prices</label>-->
|
||||
<!--<div class="input-group">-->
|
||||
<!--<span class="metric">8oz Jars</span> <span class="input-group-addon">$</span><input type="number" min="0.00" step="0.50" value="11.00" data-number-to-fixed="2" class="form-control currency" tabindex="0" required>-->
|
||||
<!--<span class="metric">16oz Jars</span> <span class="input-group-addon">$</span><input type="number" min="0.00" step="0.50" value="11.00" data-number-to-fixed="2" class="form-control currency" tabindex="0" required>-->
|
||||
<!--<span class="metric">32oz Jars</span> <span class="input-group-addon">$</span><input type="number" min="0.00" step="0.50" value="11.00" data-number-to-fixed="2" class="form-control currency" tabindex="0" required>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -125,7 +130,7 @@ $(function() {
|
||||
};
|
||||
|
||||
var $table = $page.find('#dataTable');
|
||||
var dataTable = new LinkedTable($table, {
|
||||
$table.buildTable({
|
||||
url: "data/Item/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
@@ -192,6 +197,8 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
$page.find('#dataTable').on('dblclick', 'tr', function(event) {
|
||||
if(dataTable.getSelectedRow()) {
|
||||
location.hash = "#!/items-edit";
|
||||
@@ -264,7 +271,7 @@ $(function() {
|
||||
//Initialize the measures selector.
|
||||
$editorForm.find('#DFMeasures').select2({data: measureData}).focus(function() {$(this).select2('focus')});
|
||||
//Initialize the drop down menu.
|
||||
$editorForm.find("#DFSubcategory").buildEditableSelect(query1[0], {textAttr: 'name', listClass: 'comboList', groupFunctions: {
|
||||
$editorForm.find("#DFSubcategory").buildCombo(query1[0], {textAttr: 'name', listClass: 'comboList', groupFunctions: {
|
||||
groupParents: function(category) {
|
||||
return category;
|
||||
},
|
||||
@@ -315,9 +322,9 @@ $(function() {
|
||||
$editorView.find(".modal-title").text("Edit Item");
|
||||
//Reset fields to selected values.
|
||||
$editorView.find('#DFName').val(model.name);
|
||||
$editorView.find('#DFSubcategory').val(model.subcategoryId);
|
||||
$editorView.find('#DFSubcategoryId').val(model.subcategoryId).trigger("change");
|
||||
$editorView.find('#DFPrice').val(model.defaultPrice);
|
||||
$editorView.find('#DFMeasures').val(model.measures);
|
||||
$editorView.find('#DFMeasures').val(model.measures).trigger("change");
|
||||
$editorView.find('#DFAliases').empty();
|
||||
|
||||
if(model.aliases && model.aliases.length) {
|
||||
@@ -484,7 +491,7 @@ $(function() {
|
||||
switch(event.keyCode) {
|
||||
case 27:
|
||||
if(!event.isDefaultPrevented())
|
||||
location.href='#!/items';
|
||||
history.back();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,19 +4,22 @@
|
||||
// Takes a input form element and a hidden form element (to store the selected id in) along with an array of objects, to build a dropdown select control that allows the user to type part of the selection to filter the list.
|
||||
//
|
||||
(function($) {
|
||||
var EditableSelect = function($input, $hidden, data, options) {
|
||||
var Combo = function($input, $hidden, data, options) {
|
||||
var _this = this;
|
||||
|
||||
this.$input = $input;
|
||||
this.$hidden = $hidden;
|
||||
this.options = $.extend({}, EditableSelect.DEFAULTS, options);
|
||||
this.options = $.extend({}, Combo.DEFAULTS, options);
|
||||
this.$selected = null;
|
||||
this.$listContainer = $('<div/>', {style: 'position: relative; height: 0;'});
|
||||
this.$list = $('<ul/>', {role: 'menu', class: this.options.listClass});
|
||||
|
||||
//Ensure that if the hidden field exists and changes, that the hidden field's id matches the text in the input field. If not then the hidden id field was changed manually and externally and the text field should be updated.
|
||||
if(this.$hidden) {
|
||||
this.$hidden.on('change', function(event) {
|
||||
this.$hidden.on('change', hiddenInputChanged);
|
||||
}
|
||||
|
||||
function hiddenInputChanged() {
|
||||
var id = _this.$hidden.val();
|
||||
var $li = _this.$list.children("[role!='node']");
|
||||
|
||||
@@ -28,7 +31,6 @@
|
||||
_this.$input.val($next.text());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//this.$list.appendTo($input.parent());
|
||||
@@ -176,9 +178,14 @@
|
||||
|
||||
//Add the initial set of data.
|
||||
add(data);
|
||||
|
||||
//Check the hidden input field for an ID, and setup the selection based in it if there is one.
|
||||
if(this.$hidden && _this.$hidden.val()) {
|
||||
hiddenInputChanged();
|
||||
}
|
||||
};
|
||||
|
||||
EditableSelect.DEFAULTS = {
|
||||
Combo.DEFAULTS = {
|
||||
textAttr: 'text', //The attribute of the data elements to use for the name. This can also be a function that takes the data object and returns the text.
|
||||
idAttr: 'id', //The attribute of the data elements to use for the ID. This can also be a function that takes the data obejct and returns the ID.
|
||||
// groupFunctions: The object containing three functions: 'groupParent', 'parentText', 'children'.
|
||||
@@ -189,15 +196,15 @@
|
||||
filter: true, //Whether to filter the list as the user types.
|
||||
effects: 'fade',
|
||||
duration: '200',
|
||||
listClass: 'editable-select-list',
|
||||
listClass: 'de.combo-list',
|
||||
selectionClass: 'selected' //The class to use for the selected element in the dropdown list.
|
||||
};
|
||||
|
||||
EditableSelect.prototype.select = function($li) {
|
||||
Combo.prototype.select = function($li) {
|
||||
if($li.length == 0) {
|
||||
if(this.$input.val() != '') {
|
||||
this.$input.val("")
|
||||
if(this.$hidden) this.$hidden.val(undefined);
|
||||
if(this.$hidden) this.$hidden.val(undefined).change();
|
||||
this.filter();
|
||||
//Note: Don't trigger the select event - for some reason it causes the dropdown to reopen and the control to retain focus when clicking out of the widget.
|
||||
}
|
||||
@@ -208,7 +215,10 @@
|
||||
//No need to change selection if the selection has not changed.
|
||||
if(this.$input.val() != $li.text()) {
|
||||
this.$input.val($li.text()); //Save the selected text into the text input.
|
||||
if(this.$hidden) this.$hidden.val($li.data('model')[this.options.idAttr]); //Save the ID into the hidden form input if it exists.
|
||||
if(this.$hidden) {
|
||||
this.$hidden.val($li.data('model')[this.options.idAttr]);
|
||||
this.$hidden.change();
|
||||
} //Save the ID into the hidden form input if it exists.
|
||||
this.hide();
|
||||
this.filter();
|
||||
//this.trigger('select', $li);
|
||||
@@ -217,7 +227,7 @@
|
||||
};
|
||||
|
||||
//Filters the list items by marking those that match the text in the text field as having the class 'visible'.
|
||||
EditableSelect.prototype.filter = function() {
|
||||
Combo.prototype.filter = function() {
|
||||
try {
|
||||
var search = this.$input.val();
|
||||
var _this = this;
|
||||
@@ -261,17 +271,17 @@
|
||||
}
|
||||
};
|
||||
|
||||
EditableSelect.prototype.focus = function() {
|
||||
Combo.prototype.focus = function() {
|
||||
this.show();
|
||||
this.$input.select();
|
||||
};
|
||||
|
||||
EditableSelect.prototype.blur = function() {
|
||||
Combo.prototype.blur = function() {
|
||||
this.hide();
|
||||
this.select(this.$list.find('li.selected'));
|
||||
};
|
||||
|
||||
EditableSelect.prototype.show = function() {
|
||||
Combo.prototype.show = function() {
|
||||
//Position the list relative to the edit field.
|
||||
this.$list.css({position: 'absolute', top: 0, left: 0, width: this.$input.outerWidth()});
|
||||
|
||||
@@ -285,7 +295,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
EditableSelect.prototype.hide = function() {
|
||||
Combo.prototype.hide = function() {
|
||||
var fns = {default: 'hide', fade: 'fadeOut', slide: 'slideUp'};
|
||||
var fn = fns[this.options.effects];
|
||||
|
||||
@@ -295,7 +305,7 @@
|
||||
};
|
||||
|
||||
// goDown: true/false - defaults to true - indicating whether the highlighting should go up or down if the requested item is a node. Nodes cannot be highlighted or selected.
|
||||
EditableSelect.prototype.highlight = function(index) {
|
||||
Combo.prototype.highlight = function(index) {
|
||||
var _this = this;
|
||||
|
||||
this.show();
|
||||
@@ -320,9 +330,9 @@
|
||||
});
|
||||
};
|
||||
|
||||
EditableSelect.prototype.trigger = function(event) {
|
||||
Combo.prototype.trigger = function(event) {
|
||||
var params = Array.prototype.slice.call(arguments, 1);
|
||||
var args = [event + '.editable-select'];
|
||||
var args = [event + '.de.combo'];
|
||||
|
||||
args.push(params);
|
||||
|
||||
@@ -330,17 +340,17 @@
|
||||
this.$input.trigger.apply(this.$input, args);
|
||||
};
|
||||
|
||||
$.fn.buildEditableSelect = function(data, options) {
|
||||
$.fn.buildCombo = function(data, options) {
|
||||
for(var index = 0; index < this.length; index++) {
|
||||
var $next = $(this[index]);
|
||||
var nextEditableSelect = new EditableSelect($next, $next.siblings('input[type=hidden]').first(), data, options);
|
||||
var nextCombo = new Combo($next, $next.siblings('input[type=hidden]').first(), data, options);
|
||||
|
||||
$next.data("editable-select", nextEditableSelect);
|
||||
$next.data("de.combo", nextCombo);
|
||||
}
|
||||
};
|
||||
$.fn.editableSelect = function() {
|
||||
$.fn.getCombo = function() {
|
||||
if(this.length > 0) {
|
||||
return $(this[0]).data('editable-select');
|
||||
return $(this[0]).data('de.combo');
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
@@ -74,12 +74,12 @@
|
||||
var $next = $(this[index]);
|
||||
var nextDropdown = new Dropdown($next, data, options);
|
||||
|
||||
$next.data("dropdown", nextDropdown);
|
||||
$next.data("de.dropdown", nextDropdown);
|
||||
}
|
||||
}
|
||||
$.fn.dropdown = function() {
|
||||
$.fn.getDropdown = function() {
|
||||
if(this.length > 0) {
|
||||
return $(this[0]).data('dropdown');
|
||||
return $(this[0]).data('de.dropdown');
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -1,12 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var LinkedTable;
|
||||
|
||||
+function($) {
|
||||
LinkedTable = function(element, options) {
|
||||
var Table = function(element, options) {
|
||||
var _this = this;
|
||||
this.$element = $(element);
|
||||
this.options = $.extend({}, LinkedTable.DEFAULTS, options);
|
||||
this.options = $.extend({}, Table.DEFAULTS, options);
|
||||
this.$selectedRow = null;
|
||||
this.selectionHandler = function(event) {
|
||||
if(this) {
|
||||
@@ -29,7 +27,9 @@ var LinkedTable;
|
||||
_this.options.selectionChanged(_this.$selectedRow, _this.$selectedRow ? _this.$selectedRow.data(_this.options.modelPropName) : null);
|
||||
}
|
||||
|
||||
return false;
|
||||
_this.$element.focus();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
//Takes a callback function with three parameters:
|
||||
@@ -188,7 +188,7 @@ var LinkedTable;
|
||||
};
|
||||
};
|
||||
|
||||
LinkedTable.DEFAULTS = {
|
||||
Table.DEFAULTS = {
|
||||
url: '', //The absolute or relative path to use to query the data. Server is expected to respond with a JSON array of objects.
|
||||
attr: 'data-key-name', //The attribute name used by the HTML <th></th> tags to specify either the model attribute used to fill the cells for the row, or the function that will update the cell data. The function should take three parameters: $cell, model, supportingData. $cell is the jquery wrapped <td></td> element. Model is the json model sent by the server for this row. SupportingData is a map of query results for supporting queries as setup when defining the table.
|
||||
modelPropName: 'model', //The property name to use when attaching the model to the table row. Not normally changed.
|
||||
@@ -206,12 +206,12 @@ var LinkedTable;
|
||||
parameters: null //Optional function that returns an object, or an object whose attributes are passed to the URL as parameters.
|
||||
};
|
||||
|
||||
LinkedTable.prototype.getSelectedRow = function() {
|
||||
Table.prototype.getSelectedRow = function() {
|
||||
return this.$selectedRow;
|
||||
};
|
||||
|
||||
//Refreshes the table data with updated server data. Does not clear the table or rebuild it.
|
||||
LinkedTable.prototype.refresh = function() {
|
||||
Table.prototype.refresh = function() {
|
||||
//Load the results from the server, then build the table.
|
||||
this.load.call(this, function(data, attributes, supportingData) {
|
||||
var $table = this.$element;
|
||||
@@ -263,7 +263,7 @@ var LinkedTable;
|
||||
|
||||
//A function that will clean and rebuild the table displaying all the users.
|
||||
//Note that each row of the table will have a data element attached to the table row. The key will be "model" and the value will be the object sent by the server.
|
||||
LinkedTable.prototype.build = function() {
|
||||
Table.prototype.build = function() {
|
||||
var table = this.$element;
|
||||
var thead = table.find("thead tr");
|
||||
var tbody = table.find("tbody");
|
||||
@@ -299,5 +299,42 @@ var LinkedTable;
|
||||
//Setup the row selection handler.
|
||||
if(selection == 'row') table.on('click', 'tbody tr', selectionHandler);
|
||||
});
|
||||
|
||||
//This does not work: Cannot unregister the handler because we never get the notification that the table has been removed from the DOM. We could listen for all removals and find any that are any of the parents of this table, but that would be rediculously expensive.
|
||||
// //Handle any key event that bubbles back to the document while the page is being shown. This allows the table elements to be navigated without focusing the table.
|
||||
// var keyHandler = function(event) {
|
||||
// console.log(event.keyCode);
|
||||
// };
|
||||
// var parent = this.$element.parent()[0];
|
||||
// $(document).on('keyup', keyHandler);
|
||||
// var observer = new MutationObserver(function(mutations) {
|
||||
// for(var i = 0; i < mutations.length; i++) {
|
||||
// if(mutations[i].removedNodes && mutations[i].removedNodes.length) {
|
||||
// for(var n = 0; n < mutations[i].removedNodes.length; n++) {
|
||||
// if(mutations[i].removedNodes[n] == parent) {
|
||||
// $(document).off('keyup', keyHandler);
|
||||
// observer.disconnect();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// //Remove the key handler when the table is removed from the DOM.
|
||||
// observer.observe(parent, {childList: true, subtree: true});
|
||||
};
|
||||
|
||||
$.fn.buildTable = function(options) {
|
||||
for(var index = 0; index < this.length; index++) {
|
||||
var $next = $(this[index]);
|
||||
var nextTable = new Table($next, options);
|
||||
|
||||
$next.data("de.table", nextTable);
|
||||
nextTable.build();
|
||||
}
|
||||
};
|
||||
$.fn.getTable = function() {
|
||||
if(this.length > 0) {
|
||||
return $(this[0]).data('de.table');
|
||||
}
|
||||
};
|
||||
}(jQuery);
|
||||
11008
public/admin/js/jquery-1.12.4.js
vendored
Normal file
11008
public/admin/js/jquery-1.12.4.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
public/admin/js/jquery-1.12.4.min.js
vendored
Normal file
5
public/admin/js/jquery-1.12.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
702
public/admin/js/jquery-migrate-1.3.0.js
Normal file
702
public/admin/js/jquery-migrate-1.3.0.js
Normal file
@@ -0,0 +1,702 @@
|
||||
/*!
|
||||
* jQuery Migrate - v1.3.0 - 2016-01-13
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
*/
|
||||
(function( jQuery, window, undefined ) {
|
||||
// See http://bugs.jquery.com/ticket/13335
|
||||
// "use strict";
|
||||
|
||||
|
||||
jQuery.migrateVersion = "1.3.0";
|
||||
|
||||
|
||||
var warnedAbout = {};
|
||||
|
||||
// List of warnings already given; public read only
|
||||
jQuery.migrateWarnings = [];
|
||||
|
||||
// Set to true to prevent console output; migrateWarnings still maintained
|
||||
// jQuery.migrateMute = false;
|
||||
|
||||
// Show a message on the console so devs know we're active
|
||||
if ( !jQuery.migrateMute && window.console && window.console.log ) {
|
||||
window.console.log("JQMIGRATE: Logging is active");
|
||||
}
|
||||
|
||||
// Set to false to disable traces that appear with warnings
|
||||
if ( jQuery.migrateTrace === undefined ) {
|
||||
jQuery.migrateTrace = true;
|
||||
}
|
||||
|
||||
// Forget any warnings we've already given; public
|
||||
jQuery.migrateReset = function() {
|
||||
warnedAbout = {};
|
||||
jQuery.migrateWarnings.length = 0;
|
||||
};
|
||||
|
||||
function migrateWarn( msg) {
|
||||
var console = window.console;
|
||||
if ( !warnedAbout[ msg ] ) {
|
||||
warnedAbout[ msg ] = true;
|
||||
jQuery.migrateWarnings.push( msg );
|
||||
if ( console && console.warn && !jQuery.migrateMute ) {
|
||||
console.warn( "JQMIGRATE: " + msg );
|
||||
if ( jQuery.migrateTrace && console.trace ) {
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function migrateWarnProp( obj, prop, value, msg ) {
|
||||
if ( Object.defineProperty ) {
|
||||
// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
|
||||
// allow property to be overwritten in case some other plugin wants it
|
||||
try {
|
||||
Object.defineProperty( obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
migrateWarn( msg );
|
||||
return value;
|
||||
},
|
||||
set: function( newValue ) {
|
||||
migrateWarn( msg );
|
||||
value = newValue;
|
||||
}
|
||||
});
|
||||
return;
|
||||
} catch( err ) {
|
||||
// IE8 is a dope about Object.defineProperty, can't warn there
|
||||
}
|
||||
}
|
||||
|
||||
// Non-ES5 (or broken) browser; just set the property
|
||||
jQuery._definePropertyBroken = true;
|
||||
obj[ prop ] = value;
|
||||
}
|
||||
|
||||
if ( document.compatMode === "BackCompat" ) {
|
||||
// jQuery has never supported or tested Quirks Mode
|
||||
migrateWarn( "jQuery is not compatible with Quirks Mode" );
|
||||
}
|
||||
|
||||
|
||||
var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
|
||||
oldAttr = jQuery.attr,
|
||||
valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
|
||||
function() { return null; },
|
||||
valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
|
||||
function() { return undefined; },
|
||||
rnoType = /^(?:input|button)$/i,
|
||||
rnoAttrNodeType = /^[238]$/,
|
||||
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
|
||||
ruseDefault = /^(?:checked|selected)$/i;
|
||||
|
||||
// jQuery.attrFn
|
||||
migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
|
||||
|
||||
jQuery.attr = function( elem, name, value, pass ) {
|
||||
var lowerName = name.toLowerCase(),
|
||||
nType = elem && elem.nodeType;
|
||||
|
||||
if ( pass ) {
|
||||
// Since pass is used internally, we only warn for new jQuery
|
||||
// versions where there isn't a pass arg in the formal params
|
||||
if ( oldAttr.length < 4 ) {
|
||||
migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
|
||||
}
|
||||
if ( elem && !rnoAttrNodeType.test( nType ) &&
|
||||
(attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
|
||||
return jQuery( elem )[ name ]( value );
|
||||
}
|
||||
}
|
||||
|
||||
// Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
|
||||
// for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
|
||||
if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
|
||||
migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
|
||||
}
|
||||
|
||||
// Restore boolHook for boolean property/attribute synchronization
|
||||
if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
|
||||
jQuery.attrHooks[ lowerName ] = {
|
||||
get: function( elem, name ) {
|
||||
// Align boolean attributes with corresponding properties
|
||||
// Fall back to attribute presence where some booleans are not supported
|
||||
var attrNode,
|
||||
property = jQuery.prop( elem, name );
|
||||
return property === true || typeof property !== "boolean" &&
|
||||
( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
|
||||
|
||||
name.toLowerCase() :
|
||||
undefined;
|
||||
},
|
||||
set: function( elem, value, name ) {
|
||||
var propName;
|
||||
if ( value === false ) {
|
||||
// Remove boolean attributes when set to false
|
||||
jQuery.removeAttr( elem, name );
|
||||
} else {
|
||||
// value is true since we know at this point it's type boolean and not false
|
||||
// Set boolean attributes to the same name and set the DOM property
|
||||
propName = jQuery.propFix[ name ] || name;
|
||||
if ( propName in elem ) {
|
||||
// Only set the IDL specifically if it already exists on the element
|
||||
elem[ propName ] = true;
|
||||
}
|
||||
|
||||
elem.setAttribute( name, name.toLowerCase() );
|
||||
}
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
// Warn only for attributes that can remain distinct from their properties post-1.9
|
||||
if ( ruseDefault.test( lowerName ) ) {
|
||||
migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
|
||||
}
|
||||
}
|
||||
|
||||
return oldAttr.call( jQuery, elem, name, value );
|
||||
};
|
||||
|
||||
// attrHooks: value
|
||||
jQuery.attrHooks.value = {
|
||||
get: function( elem, name ) {
|
||||
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
||||
if ( nodeName === "button" ) {
|
||||
return valueAttrGet.apply( this, arguments );
|
||||
}
|
||||
if ( nodeName !== "input" && nodeName !== "option" ) {
|
||||
migrateWarn("jQuery.fn.attr('value') no longer gets properties");
|
||||
}
|
||||
return name in elem ?
|
||||
elem.value :
|
||||
null;
|
||||
},
|
||||
set: function( elem, value ) {
|
||||
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
||||
if ( nodeName === "button" ) {
|
||||
return valueAttrSet.apply( this, arguments );
|
||||
}
|
||||
if ( nodeName !== "input" && nodeName !== "option" ) {
|
||||
migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
|
||||
}
|
||||
// Does not return so that setAttribute is also used
|
||||
elem.value = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var matched, browser,
|
||||
oldInit = jQuery.fn.init,
|
||||
oldParseJSON = jQuery.parseJSON,
|
||||
rspaceAngle = /^\s*</,
|
||||
// Note: XSS check is done below after string is trimmed
|
||||
rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
|
||||
|
||||
// $(html) "looks like html" rule change
|
||||
jQuery.fn.init = function( selector, context, rootjQuery ) {
|
||||
var match, ret;
|
||||
|
||||
if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
|
||||
(match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
|
||||
// This is an HTML string according to the "old" rules; is it still?
|
||||
if ( !rspaceAngle.test( selector ) ) {
|
||||
migrateWarn("$(html) HTML strings must start with '<' character");
|
||||
}
|
||||
if ( match[ 3 ] ) {
|
||||
migrateWarn("$(html) HTML text after last tag is ignored");
|
||||
}
|
||||
|
||||
// Consistently reject any HTML-like string starting with a hash (#9521)
|
||||
// Note that this may break jQuery 1.6.x code that otherwise would work.
|
||||
if ( match[ 0 ].charAt( 0 ) === "#" ) {
|
||||
migrateWarn("HTML string cannot start with a '#' character");
|
||||
jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
|
||||
}
|
||||
// Now process using loose rules; let pre-1.8 play too
|
||||
if ( context && context.context ) {
|
||||
// jQuery object as context; parseHTML expects a DOM object
|
||||
context = context.context;
|
||||
}
|
||||
if ( jQuery.parseHTML ) {
|
||||
return oldInit.call( this,
|
||||
jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
|
||||
context || document, true ), context, rootjQuery );
|
||||
}
|
||||
}
|
||||
|
||||
// jQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
|
||||
if ( selector === "#" ) {
|
||||
migrateWarn( "jQuery( '#' ) is not a valid selector" );
|
||||
selector = [];
|
||||
}
|
||||
|
||||
ret = oldInit.apply( this, arguments );
|
||||
|
||||
// Fill in selector and context properties so .live() works
|
||||
if ( selector && selector.selector !== undefined ) {
|
||||
// A jQuery object, copy its properties
|
||||
ret.selector = selector.selector;
|
||||
ret.context = selector.context;
|
||||
|
||||
} else {
|
||||
ret.selector = typeof selector === "string" ? selector : "";
|
||||
if ( selector ) {
|
||||
ret.context = selector.nodeType? selector : context || document;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
jQuery.fn.init.prototype = jQuery.fn;
|
||||
|
||||
// Let $.parseJSON(falsy_value) return null
|
||||
jQuery.parseJSON = function( json ) {
|
||||
if ( !json ) {
|
||||
migrateWarn("jQuery.parseJSON requires a valid JSON string");
|
||||
return null;
|
||||
}
|
||||
return oldParseJSON.apply( this, arguments );
|
||||
};
|
||||
|
||||
jQuery.uaMatch = function( ua ) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(msie) ([\w.]+)/.exec( ua ) ||
|
||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
||||
[];
|
||||
|
||||
return {
|
||||
browser: match[ 1 ] || "",
|
||||
version: match[ 2 ] || "0"
|
||||
};
|
||||
};
|
||||
|
||||
// Don't clobber any existing jQuery.browser in case it's different
|
||||
if ( !jQuery.browser ) {
|
||||
matched = jQuery.uaMatch( navigator.userAgent );
|
||||
browser = {};
|
||||
|
||||
if ( matched.browser ) {
|
||||
browser[ matched.browser ] = true;
|
||||
browser.version = matched.version;
|
||||
}
|
||||
|
||||
// Chrome is Webkit, but Webkit is also Safari.
|
||||
if ( browser.chrome ) {
|
||||
browser.webkit = true;
|
||||
} else if ( browser.webkit ) {
|
||||
browser.safari = true;
|
||||
}
|
||||
|
||||
jQuery.browser = browser;
|
||||
}
|
||||
|
||||
// Warn if the code tries to get jQuery.browser
|
||||
migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
|
||||
|
||||
// jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
|
||||
jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
|
||||
migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
|
||||
migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
|
||||
|
||||
jQuery.sub = function() {
|
||||
function jQuerySub( selector, context ) {
|
||||
return new jQuerySub.fn.init( selector, context );
|
||||
}
|
||||
jQuery.extend( true, jQuerySub, this );
|
||||
jQuerySub.superclass = this;
|
||||
jQuerySub.fn = jQuerySub.prototype = this();
|
||||
jQuerySub.fn.constructor = jQuerySub;
|
||||
jQuerySub.sub = this.sub;
|
||||
jQuerySub.fn.init = function init( selector, context ) {
|
||||
var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
||||
return instance instanceof jQuerySub ?
|
||||
instance :
|
||||
jQuerySub( instance );
|
||||
};
|
||||
jQuerySub.fn.init.prototype = jQuerySub.fn;
|
||||
var rootjQuerySub = jQuerySub(document);
|
||||
migrateWarn( "jQuery.sub() is deprecated" );
|
||||
return jQuerySub;
|
||||
};
|
||||
|
||||
// The number of elements contained in the matched element set
|
||||
jQuery.fn.size = function() {
|
||||
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
|
||||
return this.length;
|
||||
};
|
||||
|
||||
|
||||
var internalSwapCall = false;
|
||||
|
||||
// If this version of jQuery has .swap(), don't false-alarm on internal uses
|
||||
if ( jQuery.swap ) {
|
||||
jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
|
||||
var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
|
||||
|
||||
if ( oldHook ) {
|
||||
jQuery.cssHooks[ name ].get = function() {
|
||||
var ret;
|
||||
|
||||
internalSwapCall = true;
|
||||
ret = oldHook.apply( this, arguments );
|
||||
internalSwapCall = false;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
jQuery.swap = function( elem, options, callback, args ) {
|
||||
var ret, name,
|
||||
old = {};
|
||||
|
||||
if ( !internalSwapCall ) {
|
||||
migrateWarn( "jQuery.swap() is undocumented and deprecated" );
|
||||
}
|
||||
|
||||
// Remember the old values, and insert the new ones
|
||||
for ( name in options ) {
|
||||
old[ name ] = elem.style[ name ];
|
||||
elem.style[ name ] = options[ name ];
|
||||
}
|
||||
|
||||
ret = callback.apply( elem, args || [] );
|
||||
|
||||
// Revert the old values
|
||||
for ( name in options ) {
|
||||
elem.style[ name ] = old[ name ];
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// Ensure that $.ajax gets the new parseJSON defined in core.js
|
||||
jQuery.ajaxSetup({
|
||||
converters: {
|
||||
"text json": jQuery.parseJSON
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var oldFnData = jQuery.fn.data;
|
||||
|
||||
jQuery.fn.data = function( name ) {
|
||||
var ret, evt,
|
||||
elem = this[0];
|
||||
|
||||
// Handles 1.7 which has this behavior and 1.8 which doesn't
|
||||
if ( elem && name === "events" && arguments.length === 1 ) {
|
||||
ret = jQuery.data( elem, name );
|
||||
evt = jQuery._data( elem, name );
|
||||
if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
|
||||
migrateWarn("Use of jQuery.fn.data('events') is deprecated");
|
||||
return evt;
|
||||
}
|
||||
}
|
||||
return oldFnData.apply( this, arguments );
|
||||
};
|
||||
|
||||
|
||||
var rscriptType = /\/(java|ecma)script/i;
|
||||
|
||||
// Since jQuery.clean is used internally on older versions, we only shim if it's missing
|
||||
if ( !jQuery.clean ) {
|
||||
jQuery.clean = function( elems, context, fragment, scripts ) {
|
||||
// Set context per 1.8 logic
|
||||
context = context || document;
|
||||
context = !context.nodeType && context[0] || context;
|
||||
context = context.ownerDocument || context;
|
||||
|
||||
migrateWarn("jQuery.clean() is deprecated");
|
||||
|
||||
var i, elem, handleScript, jsTags,
|
||||
ret = [];
|
||||
|
||||
jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
|
||||
|
||||
// Complex logic lifted directly from jQuery 1.8
|
||||
if ( fragment ) {
|
||||
// Special handling of each script element
|
||||
handleScript = function( elem ) {
|
||||
// Check if we consider it executable
|
||||
if ( !elem.type || rscriptType.test( elem.type ) ) {
|
||||
// Detach the script and store it in the scripts array (if provided) or the fragment
|
||||
// Return truthy to indicate that it has been handled
|
||||
return scripts ?
|
||||
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
|
||||
fragment.appendChild( elem );
|
||||
}
|
||||
};
|
||||
|
||||
for ( i = 0; (elem = ret[i]) != null; i++ ) {
|
||||
// Check if we're done after handling an executable script
|
||||
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
|
||||
// Append to fragment and handle embedded scripts
|
||||
fragment.appendChild( elem );
|
||||
if ( typeof elem.getElementsByTagName !== "undefined" ) {
|
||||
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
|
||||
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
|
||||
|
||||
// Splice the scripts into ret after their former ancestor and advance our index beyond them
|
||||
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
||||
i += jsTags.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
var eventAdd = jQuery.event.add,
|
||||
eventRemove = jQuery.event.remove,
|
||||
eventTrigger = jQuery.event.trigger,
|
||||
oldToggle = jQuery.fn.toggle,
|
||||
oldLive = jQuery.fn.live,
|
||||
oldDie = jQuery.fn.die,
|
||||
oldLoad = jQuery.fn.load,
|
||||
ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
|
||||
rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
|
||||
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
|
||||
hoverHack = function( events ) {
|
||||
if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
|
||||
return events;
|
||||
}
|
||||
if ( rhoverHack.test( events ) ) {
|
||||
migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
|
||||
}
|
||||
return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
|
||||
};
|
||||
|
||||
// Event props removed in 1.9, put them back if needed; no practical way to warn them
|
||||
if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
|
||||
jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
|
||||
}
|
||||
|
||||
// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
|
||||
if ( jQuery.event.dispatch ) {
|
||||
migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
|
||||
}
|
||||
|
||||
// Support for 'hover' pseudo-event and ajax event warnings
|
||||
jQuery.event.add = function( elem, types, handler, data, selector ){
|
||||
if ( elem !== document && rajaxEvent.test( types ) ) {
|
||||
migrateWarn( "AJAX events should be attached to document: " + types );
|
||||
}
|
||||
eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
|
||||
};
|
||||
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
|
||||
eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
|
||||
};
|
||||
|
||||
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
|
||||
|
||||
jQuery.fn[ name ] = function() {
|
||||
var args = Array.prototype.slice.call( arguments, 0 );
|
||||
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
|
||||
|
||||
// If this is an ajax load() the first arg should be the string URL;
|
||||
// technically this could also be the "Anything" arg of the event .load()
|
||||
// which just goes to show why this dumb signature has been deprecated!
|
||||
// jQuery custom builds that exclude the Ajax module justifiably die here.
|
||||
if ( name === "load" && typeof arguments[ 0 ] === "string" ) {
|
||||
return oldLoad.apply( this, arguments );
|
||||
}
|
||||
|
||||
args.splice( 0, 0, name );
|
||||
if ( arguments.length ) {
|
||||
return this.bind.apply( this, args );
|
||||
}
|
||||
|
||||
// Use .triggerHandler here because:
|
||||
// - load and unload events don't need to bubble, only applied to window or image
|
||||
// - error event should not bubble to window, although it does pre-1.7
|
||||
// See http://bugs.jquery.com/ticket/11820
|
||||
this.triggerHandler.apply( this, args );
|
||||
return this;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
jQuery.fn.toggle = function( fn, fn2 ) {
|
||||
|
||||
// Don't mess with animation or css toggles
|
||||
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
|
||||
return oldToggle.apply( this, arguments );
|
||||
}
|
||||
migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
|
||||
|
||||
// Save reference to arguments for access in closure
|
||||
var args = arguments,
|
||||
guid = fn.guid || jQuery.guid++,
|
||||
i = 0,
|
||||
toggler = function( event ) {
|
||||
// Figure out which function to execute
|
||||
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
||||
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
||||
|
||||
// Make sure that clicks stop
|
||||
event.preventDefault();
|
||||
|
||||
// and execute the function
|
||||
return args[ lastToggle ].apply( this, arguments ) || false;
|
||||
};
|
||||
|
||||
// link all the functions, so any of them can unbind this click handler
|
||||
toggler.guid = guid;
|
||||
while ( i < args.length ) {
|
||||
args[ i++ ].guid = guid;
|
||||
}
|
||||
|
||||
return this.click( toggler );
|
||||
};
|
||||
|
||||
jQuery.fn.live = function( types, data, fn ) {
|
||||
migrateWarn("jQuery.fn.live() is deprecated");
|
||||
if ( oldLive ) {
|
||||
return oldLive.apply( this, arguments );
|
||||
}
|
||||
jQuery( this.context ).on( types, this.selector, data, fn );
|
||||
return this;
|
||||
};
|
||||
|
||||
jQuery.fn.die = function( types, fn ) {
|
||||
migrateWarn("jQuery.fn.die() is deprecated");
|
||||
if ( oldDie ) {
|
||||
return oldDie.apply( this, arguments );
|
||||
}
|
||||
jQuery( this.context ).off( types, this.selector || "**", fn );
|
||||
return this;
|
||||
};
|
||||
|
||||
// Turn global events into document-triggered events
|
||||
jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
|
||||
if ( !elem && !rajaxEvent.test( event ) ) {
|
||||
migrateWarn( "Global events are undocumented and deprecated" );
|
||||
}
|
||||
return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
|
||||
};
|
||||
jQuery.each( ajaxEvents.split("|"),
|
||||
function( _, name ) {
|
||||
jQuery.event.special[ name ] = {
|
||||
setup: function() {
|
||||
var elem = this;
|
||||
|
||||
// The document needs no shimming; must be !== for oldIE
|
||||
if ( elem !== document ) {
|
||||
jQuery.event.add( document, name + "." + jQuery.guid, function() {
|
||||
jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
|
||||
});
|
||||
jQuery._data( this, name, jQuery.guid++ );
|
||||
}
|
||||
return false;
|
||||
},
|
||||
teardown: function() {
|
||||
if ( this !== document ) {
|
||||
jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
jQuery.event.special.ready = {
|
||||
setup: function() { migrateWarn( "'ready' event is deprecated" ); }
|
||||
};
|
||||
|
||||
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
|
||||
oldFind = jQuery.fn.find;
|
||||
|
||||
jQuery.fn.andSelf = function() {
|
||||
migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
|
||||
return oldSelf.apply( this, arguments );
|
||||
};
|
||||
|
||||
jQuery.fn.find = function( selector ) {
|
||||
var ret = oldFind.apply( this, arguments );
|
||||
ret.context = this.context;
|
||||
ret.selector = this.selector ? this.selector + " " + selector : selector;
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// jQuery 1.6 did not support Callbacks, do not warn there
|
||||
if ( jQuery.Callbacks ) {
|
||||
|
||||
var oldDeferred = jQuery.Deferred,
|
||||
tuples = [
|
||||
// action, add listener, callbacks, .then handlers, final state
|
||||
[ "resolve", "done", jQuery.Callbacks("once memory"),
|
||||
jQuery.Callbacks("once memory"), "resolved" ],
|
||||
[ "reject", "fail", jQuery.Callbacks("once memory"),
|
||||
jQuery.Callbacks("once memory"), "rejected" ],
|
||||
[ "notify", "progress", jQuery.Callbacks("memory"),
|
||||
jQuery.Callbacks("memory") ]
|
||||
];
|
||||
|
||||
jQuery.Deferred = function( func ) {
|
||||
var deferred = oldDeferred(),
|
||||
promise = deferred.promise();
|
||||
|
||||
deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
|
||||
var fns = arguments;
|
||||
|
||||
migrateWarn( "deferred.pipe() is deprecated" );
|
||||
|
||||
return jQuery.Deferred(function( newDefer ) {
|
||||
jQuery.each( tuples, function( i, tuple ) {
|
||||
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
||||
// deferred.done(function() { bind to newDefer or newDefer.resolve })
|
||||
// deferred.fail(function() { bind to newDefer or newDefer.reject })
|
||||
// deferred.progress(function() { bind to newDefer or newDefer.notify })
|
||||
deferred[ tuple[1] ](function() {
|
||||
var returned = fn && fn.apply( this, arguments );
|
||||
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
||||
returned.promise()
|
||||
.done( newDefer.resolve )
|
||||
.fail( newDefer.reject )
|
||||
.progress( newDefer.notify );
|
||||
} else {
|
||||
newDefer[ tuple[ 0 ] + "With" ](
|
||||
this === promise ? newDefer.promise() : this,
|
||||
fn ? [ returned ] : arguments
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
fns = null;
|
||||
}).promise();
|
||||
|
||||
};
|
||||
|
||||
deferred.isResolved = function() {
|
||||
migrateWarn( "deferred.isResolved is deprecated" );
|
||||
return deferred.state() === "resolved";
|
||||
};
|
||||
|
||||
deferred.isRejected = function() {
|
||||
migrateWarn( "deferred.isRejected is deprecated" );
|
||||
return deferred.state() === "rejected";
|
||||
};
|
||||
|
||||
if ( func ) {
|
||||
func.call( deferred, deferred );
|
||||
}
|
||||
|
||||
return deferred;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
})( jQuery, window );
|
||||
2
public/admin/js/jquery-migrate-1.3.0.min.js
vendored
Normal file
2
public/admin/js/jquery-migrate-1.3.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
540
public/admin/js/jquery-migrate-3.0.0.js
Normal file
540
public/admin/js/jquery-migrate-3.0.0.js
Normal file
@@ -0,0 +1,540 @@
|
||||
/*!
|
||||
* jQuery Migrate - v3.0.0 - 2016-06-09
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
*/
|
||||
(function( jQuery, window ) {
|
||||
"use strict";
|
||||
|
||||
|
||||
jQuery.migrateVersion = "3.0.0";
|
||||
|
||||
|
||||
( function() {
|
||||
|
||||
// Support: IE9 only
|
||||
// IE9 only creates console object when dev tools are first opened
|
||||
// Also, avoid Function#bind here to simplify PhantomJS usage
|
||||
var log = window.console && window.console.log &&
|
||||
function() { window.console.log.apply( window.console, arguments ); },
|
||||
rbadVersions = /^[12]\./;
|
||||
|
||||
if ( !log ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Need jQuery 3.0.0+ and no older Migrate loaded
|
||||
if ( !jQuery || rbadVersions.test( jQuery.fn.jquery ) ) {
|
||||
log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
|
||||
}
|
||||
if ( jQuery.migrateWarnings ) {
|
||||
log( "JQMIGRATE: Migrate plugin loaded multiple times" );
|
||||
}
|
||||
|
||||
// Show a message on the console so devs know we're active
|
||||
log( "JQMIGRATE: Migrate is installed" +
|
||||
( jQuery.migrateMute ? "" : " with logging active" ) +
|
||||
", version " + jQuery.migrateVersion );
|
||||
|
||||
} )();
|
||||
|
||||
var warnedAbout = {};
|
||||
|
||||
// List of warnings already given; public read only
|
||||
jQuery.migrateWarnings = [];
|
||||
|
||||
// Set to false to disable traces that appear with warnings
|
||||
if ( jQuery.migrateTrace === undefined ) {
|
||||
jQuery.migrateTrace = true;
|
||||
}
|
||||
|
||||
// Forget any warnings we've already given; public
|
||||
jQuery.migrateReset = function() {
|
||||
warnedAbout = {};
|
||||
jQuery.migrateWarnings.length = 0;
|
||||
};
|
||||
|
||||
function migrateWarn( msg ) {
|
||||
var console = window.console;
|
||||
if ( !warnedAbout[ msg ] ) {
|
||||
warnedAbout[ msg ] = true;
|
||||
jQuery.migrateWarnings.push( msg );
|
||||
if ( console && console.warn && !jQuery.migrateMute ) {
|
||||
console.warn( "JQMIGRATE: " + msg );
|
||||
if ( jQuery.migrateTrace && console.trace ) {
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function migrateWarnProp( obj, prop, value, msg ) {
|
||||
Object.defineProperty( obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
migrateWarn( msg );
|
||||
return value;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( document.compatMode === "BackCompat" ) {
|
||||
|
||||
// JQuery has never supported or tested Quirks Mode
|
||||
migrateWarn( "jQuery is not compatible with Quirks Mode" );
|
||||
}
|
||||
|
||||
|
||||
var oldInit = jQuery.fn.init,
|
||||
oldIsNumeric = jQuery.isNumeric,
|
||||
oldFind = jQuery.find,
|
||||
rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
|
||||
rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g;
|
||||
|
||||
jQuery.fn.init = function( arg1 ) {
|
||||
var args = Array.prototype.slice.call( arguments );
|
||||
|
||||
if ( typeof arg1 === "string" && arg1 === "#" ) {
|
||||
|
||||
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
|
||||
migrateWarn( "jQuery( '#' ) is not a valid selector" );
|
||||
args[ 0 ] = [];
|
||||
}
|
||||
|
||||
return oldInit.apply( this, args );
|
||||
};
|
||||
jQuery.fn.init.prototype = jQuery.fn;
|
||||
|
||||
jQuery.find = function( selector ) {
|
||||
var args = Array.prototype.slice.call( arguments );
|
||||
|
||||
// Support: PhantomJS 1.x
|
||||
// String#match fails to match when used with a //g RegExp, only on some strings
|
||||
if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
|
||||
|
||||
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
|
||||
// First see if qS thinks it's a valid selector, if so avoid a false positive
|
||||
try {
|
||||
document.querySelector( selector );
|
||||
} catch ( err1 ) {
|
||||
|
||||
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
|
||||
selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
|
||||
return "[" + attr + op + "\"" + value + "\"]";
|
||||
} );
|
||||
|
||||
// If the regexp *may* have created an invalid selector, don't update it
|
||||
// Note that there may be false alarms if selector uses jQuery extensions
|
||||
try {
|
||||
document.querySelector( selector );
|
||||
migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
|
||||
args[ 0 ] = selector;
|
||||
} catch ( err2 ) {
|
||||
migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return oldFind.apply( this, args );
|
||||
};
|
||||
|
||||
// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
|
||||
var findProp;
|
||||
for ( findProp in oldFind ) {
|
||||
if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
|
||||
jQuery.find[ findProp ] = oldFind[ findProp ];
|
||||
}
|
||||
}
|
||||
|
||||
// The number of elements contained in the matched element set
|
||||
jQuery.fn.size = function() {
|
||||
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
|
||||
return this.length;
|
||||
};
|
||||
|
||||
jQuery.parseJSON = function() {
|
||||
migrateWarn( "jQuery.parseJSON is deprecated; use JSON.parse" );
|
||||
return JSON.parse.apply( null, arguments );
|
||||
};
|
||||
|
||||
jQuery.isNumeric = function( val ) {
|
||||
|
||||
// The jQuery 2.2.3 implementation of isNumeric
|
||||
function isNumeric2( obj ) {
|
||||
var realStringObj = obj && obj.toString();
|
||||
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
|
||||
}
|
||||
|
||||
var newValue = oldIsNumeric( val ),
|
||||
oldValue = isNumeric2( val );
|
||||
|
||||
if ( newValue !== oldValue ) {
|
||||
migrateWarn( "jQuery.isNumeric() should not be called on constructed objects" );
|
||||
}
|
||||
|
||||
return oldValue;
|
||||
};
|
||||
|
||||
migrateWarnProp( jQuery, "unique", jQuery.uniqueSort,
|
||||
"jQuery.unique is deprecated, use jQuery.uniqueSort" );
|
||||
|
||||
// Now jQuery.expr.pseudos is the standard incantation
|
||||
migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
|
||||
"jQuery.expr.filters is now jQuery.expr.pseudos" );
|
||||
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
|
||||
"jQuery.expr[\":\"] is now jQuery.expr.pseudos" );
|
||||
|
||||
|
||||
var oldAjax = jQuery.ajax;
|
||||
|
||||
jQuery.ajax = function( ) {
|
||||
var jQXHR = oldAjax.apply( this, arguments );
|
||||
|
||||
// Be sure we got a jQXHR (e.g., not sync)
|
||||
if ( jQXHR.promise ) {
|
||||
migrateWarnProp( jQXHR, "success", jQXHR.done,
|
||||
"jQXHR.success is deprecated and removed" );
|
||||
migrateWarnProp( jQXHR, "error", jQXHR.fail,
|
||||
"jQXHR.error is deprecated and removed" );
|
||||
migrateWarnProp( jQXHR, "complete", jQXHR.always,
|
||||
"jQXHR.complete is deprecated and removed" );
|
||||
}
|
||||
|
||||
return jQXHR;
|
||||
};
|
||||
|
||||
|
||||
var oldRemoveAttr = jQuery.fn.removeAttr,
|
||||
oldToggleClass = jQuery.fn.toggleClass,
|
||||
rmatchNonSpace = /\S+/g;
|
||||
|
||||
jQuery.fn.removeAttr = function( name ) {
|
||||
var self = this;
|
||||
|
||||
jQuery.each( name.match( rmatchNonSpace ), function( i, attr ) {
|
||||
if ( jQuery.expr.match.bool.test( attr ) ) {
|
||||
migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
|
||||
self.prop( attr, false );
|
||||
}
|
||||
} );
|
||||
|
||||
return oldRemoveAttr.apply( this, arguments );
|
||||
};
|
||||
|
||||
jQuery.fn.toggleClass = function( state ) {
|
||||
|
||||
// Only deprecating no-args or single boolean arg
|
||||
if ( state !== undefined && typeof state !== "boolean" ) {
|
||||
return oldToggleClass.apply( this, arguments );
|
||||
}
|
||||
|
||||
migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" );
|
||||
|
||||
// Toggle entire class name of each element
|
||||
return this.each( function() {
|
||||
var className = this.getAttribute && this.getAttribute( "class" ) || "";
|
||||
|
||||
if ( className ) {
|
||||
jQuery.data( this, "__className__", className );
|
||||
}
|
||||
|
||||
// If the element has a class name or if we're passed `false`,
|
||||
// then remove the whole classname (if there was one, the above saved it).
|
||||
// Otherwise bring back whatever was previously saved (if anything),
|
||||
// falling back to the empty string if nothing was stored.
|
||||
if ( this.setAttribute ) {
|
||||
this.setAttribute( "class",
|
||||
className || state === false ?
|
||||
"" :
|
||||
jQuery.data( this, "__className__" ) || ""
|
||||
);
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
|
||||
var internalSwapCall = false;
|
||||
|
||||
// If this version of jQuery has .swap(), don't false-alarm on internal uses
|
||||
if ( jQuery.swap ) {
|
||||
jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
|
||||
var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
|
||||
|
||||
if ( oldHook ) {
|
||||
jQuery.cssHooks[ name ].get = function() {
|
||||
var ret;
|
||||
|
||||
internalSwapCall = true;
|
||||
ret = oldHook.apply( this, arguments );
|
||||
internalSwapCall = false;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
jQuery.swap = function( elem, options, callback, args ) {
|
||||
var ret, name,
|
||||
old = {};
|
||||
|
||||
if ( !internalSwapCall ) {
|
||||
migrateWarn( "jQuery.swap() is undocumented and deprecated" );
|
||||
}
|
||||
|
||||
// Remember the old values, and insert the new ones
|
||||
for ( name in options ) {
|
||||
old[ name ] = elem.style[ name ];
|
||||
elem.style[ name ] = options[ name ];
|
||||
}
|
||||
|
||||
ret = callback.apply( elem, args || [] );
|
||||
|
||||
// Revert the old values
|
||||
for ( name in options ) {
|
||||
elem.style[ name ] = old[ name ];
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
var oldData = jQuery.data;
|
||||
|
||||
jQuery.data = function( elem, name, value ) {
|
||||
var curData;
|
||||
|
||||
// If the name is transformed, look for the un-transformed name in the data object
|
||||
if ( name && name !== jQuery.camelCase( name ) ) {
|
||||
curData = jQuery.hasData( elem ) && oldData.call( this, elem );
|
||||
if ( curData && name in curData ) {
|
||||
migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name );
|
||||
if ( arguments.length > 2 ) {
|
||||
curData[ name ] = value;
|
||||
}
|
||||
return curData[ name ];
|
||||
}
|
||||
}
|
||||
|
||||
return oldData.apply( this, arguments );
|
||||
};
|
||||
|
||||
var oldTweenRun = jQuery.Tween.prototype.run;
|
||||
|
||||
jQuery.Tween.prototype.run = function( percent ) {
|
||||
if ( jQuery.easing[ this.easing ].length > 1 ) {
|
||||
migrateWarn(
|
||||
"easing function " +
|
||||
"\"jQuery.easing." + this.easing.toString() +
|
||||
"\" should use only first argument"
|
||||
);
|
||||
|
||||
jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind(
|
||||
jQuery.easing,
|
||||
percent, this.options.duration * percent, 0, 1, this.options.duration
|
||||
);
|
||||
}
|
||||
|
||||
oldTweenRun.apply( this, arguments );
|
||||
};
|
||||
|
||||
var oldLoad = jQuery.fn.load,
|
||||
originalFix = jQuery.event.fix;
|
||||
|
||||
jQuery.event.props = [];
|
||||
jQuery.event.fixHooks = {};
|
||||
|
||||
jQuery.event.fix = function( originalEvent ) {
|
||||
var event,
|
||||
type = originalEvent.type,
|
||||
fixHook = this.fixHooks[ type ],
|
||||
props = jQuery.event.props;
|
||||
|
||||
if ( props.length ) {
|
||||
migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() );
|
||||
while ( props.length ) {
|
||||
jQuery.event.addProp( props.pop() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( fixHook && !fixHook._migrated_ ) {
|
||||
fixHook._migrated_ = true;
|
||||
migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
|
||||
if ( ( props = fixHook.props ) && props.length ) {
|
||||
while ( props.length ) {
|
||||
jQuery.event.addProp( props.pop() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event = originalFix.call( this, originalEvent );
|
||||
|
||||
return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
||||
};
|
||||
|
||||
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
|
||||
|
||||
jQuery.fn[ name ] = function() {
|
||||
var args = Array.prototype.slice.call( arguments, 0 );
|
||||
|
||||
// If this is an ajax load() the first arg should be the string URL;
|
||||
// technically this could also be the "Anything" arg of the event .load()
|
||||
// which just goes to show why this dumb signature has been deprecated!
|
||||
// jQuery custom builds that exclude the Ajax module justifiably die here.
|
||||
if ( name === "load" && typeof args[ 0 ] === "string" ) {
|
||||
return oldLoad.apply( this, args );
|
||||
}
|
||||
|
||||
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
|
||||
|
||||
args.splice( 0, 0, name );
|
||||
if ( arguments.length ) {
|
||||
return this.on.apply( this, args );
|
||||
}
|
||||
|
||||
// Use .triggerHandler here because:
|
||||
// - load and unload events don't need to bubble, only applied to window or image
|
||||
// - error event should not bubble to window, although it does pre-1.7
|
||||
// See http://bugs.jquery.com/ticket/11820
|
||||
this.triggerHandler.apply( this, args );
|
||||
return this;
|
||||
};
|
||||
|
||||
} );
|
||||
|
||||
// Trigger "ready" event only once, on document ready
|
||||
jQuery( function() {
|
||||
jQuery( document ).triggerHandler( "ready" );
|
||||
} );
|
||||
|
||||
jQuery.event.special.ready = {
|
||||
setup: function() {
|
||||
if ( this === document ) {
|
||||
migrateWarn( "'ready' event is deprecated" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.fn.extend( {
|
||||
|
||||
bind: function( types, data, fn ) {
|
||||
migrateWarn( "jQuery.fn.bind() is deprecated" );
|
||||
return this.on( types, null, data, fn );
|
||||
},
|
||||
unbind: function( types, fn ) {
|
||||
migrateWarn( "jQuery.fn.unbind() is deprecated" );
|
||||
return this.off( types, null, fn );
|
||||
},
|
||||
delegate: function( selector, types, data, fn ) {
|
||||
migrateWarn( "jQuery.fn.delegate() is deprecated" );
|
||||
return this.on( types, selector, data, fn );
|
||||
},
|
||||
undelegate: function( selector, types, fn ) {
|
||||
migrateWarn( "jQuery.fn.undelegate() is deprecated" );
|
||||
return arguments.length === 1 ?
|
||||
this.off( selector, "**" ) :
|
||||
this.off( types, selector || "**", fn );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
var oldOffset = jQuery.fn.offset;
|
||||
|
||||
jQuery.fn.offset = function() {
|
||||
var docElem,
|
||||
elem = this[ 0 ],
|
||||
origin = { top: 0, left: 0 };
|
||||
|
||||
if ( !elem || !elem.nodeType ) {
|
||||
migrateWarn( "jQuery.fn.offset() requires a valid DOM element" );
|
||||
return origin;
|
||||
}
|
||||
|
||||
docElem = ( elem.ownerDocument || document ).documentElement;
|
||||
if ( !jQuery.contains( docElem, elem ) ) {
|
||||
migrateWarn( "jQuery.fn.offset() requires an element connected to a document" );
|
||||
return origin;
|
||||
}
|
||||
|
||||
return oldOffset.apply( this, arguments );
|
||||
};
|
||||
|
||||
|
||||
var oldParam = jQuery.param;
|
||||
|
||||
jQuery.param = function( data, traditional ) {
|
||||
var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
|
||||
|
||||
if ( traditional === undefined && ajaxTraditional ) {
|
||||
|
||||
migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" );
|
||||
traditional = ajaxTraditional;
|
||||
}
|
||||
|
||||
return oldParam.call( this, data, traditional );
|
||||
};
|
||||
|
||||
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
|
||||
|
||||
jQuery.fn.andSelf = function() {
|
||||
migrateWarn( "jQuery.fn.andSelf() replaced by jQuery.fn.addBack()" );
|
||||
return oldSelf.apply( this, arguments );
|
||||
};
|
||||
|
||||
|
||||
var oldDeferred = jQuery.Deferred,
|
||||
tuples = [
|
||||
|
||||
// Action, add listener, callbacks, .then handlers, final state
|
||||
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
|
||||
jQuery.Callbacks( "once memory" ), "resolved" ],
|
||||
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
|
||||
jQuery.Callbacks( "once memory" ), "rejected" ],
|
||||
[ "notify", "progress", jQuery.Callbacks( "memory" ),
|
||||
jQuery.Callbacks( "memory" ) ]
|
||||
];
|
||||
|
||||
jQuery.Deferred = function( func ) {
|
||||
var deferred = oldDeferred(),
|
||||
promise = deferred.promise();
|
||||
|
||||
deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
|
||||
var fns = arguments;
|
||||
|
||||
migrateWarn( "deferred.pipe() is deprecated" );
|
||||
|
||||
return jQuery.Deferred( function( newDefer ) {
|
||||
jQuery.each( tuples, function( i, tuple ) {
|
||||
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
||||
|
||||
// Deferred.done(function() { bind to newDefer or newDefer.resolve })
|
||||
// deferred.fail(function() { bind to newDefer or newDefer.reject })
|
||||
// deferred.progress(function() { bind to newDefer or newDefer.notify })
|
||||
deferred[ tuple[ 1 ] ]( function() {
|
||||
var returned = fn && fn.apply( this, arguments );
|
||||
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
||||
returned.promise()
|
||||
.done( newDefer.resolve )
|
||||
.fail( newDefer.reject )
|
||||
.progress( newDefer.notify );
|
||||
} else {
|
||||
newDefer[ tuple[ 0 ] + "With" ](
|
||||
this === promise ? newDefer.promise() : this,
|
||||
fn ? [ returned ] : arguments
|
||||
);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
fns = null;
|
||||
} ).promise();
|
||||
|
||||
};
|
||||
|
||||
if ( func ) {
|
||||
func.call( deferred, deferred );
|
||||
}
|
||||
|
||||
return deferred;
|
||||
};
|
||||
|
||||
|
||||
|
||||
})( jQuery, window );
|
||||
2
public/admin/js/jquery-migrate-3.0.0.min.js
vendored
Normal file
2
public/admin/js/jquery-migrate-3.0.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2508
public/admin/js/jsgrid.js
Normal file
2508
public/admin/js/jsgrid.js
Normal file
File diff suppressed because it is too large
Load Diff
8
public/admin/js/jsgrid.min.js
vendored
Normal file
8
public/admin/js/jsgrid.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -104,7 +104,8 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.buildTable({
|
||||
url: "data/Measure/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
@@ -127,15 +128,14 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
$page.find('#dataTable').on('dblclick', 'tr', function(event) {
|
||||
if(dataTable.getSelectedRow()) {
|
||||
location.hash = "#!/measures-edit";
|
||||
}
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
dataTable.build();
|
||||
|
||||
//Refresh the data table if the user toggles the button to show/hide deleted elements.
|
||||
$page.find('#includeDeletedToggle').on('click', function(event) {
|
||||
dataTable.refresh();
|
||||
@@ -240,6 +240,16 @@ $(function() {
|
||||
$editorView.find('#DFName').focus();
|
||||
});
|
||||
|
||||
//Close the view if the user uses the escape key and it isn't handled at the widget level.
|
||||
$editorView.on('keyup', function(event) {
|
||||
switch(event.keyCode) {
|
||||
case 27:
|
||||
if(!event.isDefaultPrevented())
|
||||
history.back();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++ Delete View +++++++++++
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
<i class="fa fa-usd"></i>
|
||||
<p>Sales</p>
|
||||
</a>
|
||||
<a class="option" href="#!/prices">
|
||||
<i class="fa fa-usd"></i>
|
||||
<p>Prices</p>
|
||||
</a>
|
||||
<a class="option" href="#!/items">
|
||||
<i class="fa fa-sitemap"></i>
|
||||
<p>Items</p>
|
||||
|
||||
81
public/admin/prices.html
Normal file
81
public/admin/prices.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<div id="prices" class="page">
|
||||
<div id="gridView" class="view">
|
||||
<div class="measureSelectionContainer">
|
||||
<h1><span class="fa fa-sitemap"></span> Prices</h1>
|
||||
<label for="DFMeasure">Measure</label>
|
||||
<div class="form-group">
|
||||
<select id="DFMeasure" class="form-control" tabindex="0">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dataTable">
|
||||
</div>
|
||||
<div class="priceEditorContainer">
|
||||
<div class="col-md-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">$</span><input id="DFPrice" type="number" min="0.00" step="0.50" value="11.00" data-number-to-fixed="2" class="form-control currency" tabindex="0" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6"><button id="changePriceBtn" type="button" class="btn btn-default btn-primary btn-md" tabindex="0">Apply</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">//# sourceURL=prices.html
|
||||
$(function() {
|
||||
var numPattern = /^\d+/;
|
||||
var $page = $('#prices');
|
||||
var $measure = $page.find("#DFMeasure");
|
||||
var $changePriceBtn = $page.find("#changePriceBtn");
|
||||
|
||||
//Update the dialog drop downs when the queries finish.
|
||||
$.when.apply($, [$.get("data/Measure/readAll", {request: JSON.stringify({order: ['id', ['id']]})})]).then(function(query1) {
|
||||
//Initialize the drop down menu.
|
||||
//$page.find("#DFMeasure").buildCombo(query1, {textAttr: 'name', listClass: 'comboList'});
|
||||
// query1.sort(function(a, b) {
|
||||
// a.id > b.id ? 1 : -1;
|
||||
// });
|
||||
|
||||
for(var i = 0; i < query1.length; i++) {
|
||||
var next = query1[i];
|
||||
var $opt = $('<option/>', {id: next.id, text: next.name});
|
||||
|
||||
$opt.appendTo($measure);
|
||||
}
|
||||
});
|
||||
|
||||
$changePriceBtn.disable(true);
|
||||
$measure.change(function() {
|
||||
var id = $measure.val();
|
||||
|
||||
//TODO: Update the data table with items that use the given measure.
|
||||
$table.jsGrid('loadData', id);
|
||||
});
|
||||
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.jsGrid({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
heading: true,
|
||||
selecting: true,
|
||||
inserting: false,
|
||||
editing: false,
|
||||
sorting: true,
|
||||
paging: false,
|
||||
fields: [
|
||||
{name: "Item", type: "text", width: '50%'},
|
||||
{name: 'Price', type: 'number'}
|
||||
],
|
||||
controller: {
|
||||
loadData: function(filter) {
|
||||
return $.ajax({
|
||||
type: 'POST',
|
||||
url: "data/Item/readAll",
|
||||
data: {request: JSON.stringify({showDeleted: true, filter: filter})},
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
3
public/admin/prices.styl
Normal file
3
public/admin/prices.styl
Normal file
@@ -0,0 +1,3 @@
|
||||
#prices {
|
||||
|
||||
}
|
||||
@@ -111,7 +111,8 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.buildTable({
|
||||
url: "data/Sale/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
@@ -156,15 +157,14 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
$page.find('#dataTable').on('dblclick', 'tr', function(event) {
|
||||
if(dataTable.getSelectedRow()) {
|
||||
location.hash = "#!/sales-edit";
|
||||
}
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
dataTable.build();
|
||||
|
||||
//Refresh the data table if the user toggles the button to show/hide deleted elements.
|
||||
$page.find('#includeDeletedToggle').on('click', function(event) {
|
||||
dataTable.refresh();
|
||||
@@ -187,9 +187,9 @@ $(function() {
|
||||
//Update the dialog drop downs when the queries finish.
|
||||
$.when.apply($, queries).then(function(query1, query2, query3) {
|
||||
//Initialize the drop down menus.
|
||||
$editorForm.find("#DFItem").buildEditableSelect(query1[0], {textAttr: 'name', listClass: 'comboList'});
|
||||
$editorForm.find("#DFMeasure").buildEditableSelect(query2[0], {textAttr: 'name', listClass: 'comboList'});
|
||||
$editorForm.find("#DFVenue").buildEditableSelect(query3[0], {textAttr: 'name', listClass: 'comboList'});
|
||||
$editorForm.find("#DFItem").buildCombo(query1[0], {textAttr: 'name', listClass: 'comboList'});
|
||||
$editorForm.find("#DFMeasure").buildCombo(query2[0], {textAttr: 'name', listClass: 'comboList'});
|
||||
$editorForm.find("#DFVenue").buildCombo(query3[0], {textAttr: 'name', listClass: 'comboList'});
|
||||
//Initialize the validator
|
||||
$editorForm.validator();
|
||||
});
|
||||
@@ -287,6 +287,21 @@ $(function() {
|
||||
});
|
||||
});
|
||||
|
||||
//Close the view if the user uses the escape key and it isn't handled at the widget level.
|
||||
$editorView.on('keyup', function(event) {
|
||||
switch(event.keyCode) {
|
||||
case 27:
|
||||
if(!event.isDefaultPrevented())
|
||||
history.back();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$page.find('div.date').datetimepicker({
|
||||
viewMode: 'years',
|
||||
format: 'MM/DD/YY'
|
||||
});
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++ Delete View +++++++++++
|
||||
|
||||
|
||||
@@ -104,7 +104,8 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.buildTable({
|
||||
url: "data/Subcategory/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
@@ -148,15 +149,14 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
$page.find('#dataTable').on('dblclick', 'tr', function(event) {
|
||||
if(dataTable.getSelectedRow()) {
|
||||
location.hash = "#!/subcategories-edit";
|
||||
}
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
dataTable.build();
|
||||
|
||||
//Refresh the data table if the user toggles the button to show/hide deleted elements.
|
||||
$page.find('#includeDeletedToggle').on('click', function(event) {
|
||||
dataTable.refresh();
|
||||
@@ -188,7 +188,7 @@ $(function() {
|
||||
//Update the dialog drop downs when the queries finish.
|
||||
$.when.apply($, queries).then(function(query1) {
|
||||
//Initialize the drop down menu.
|
||||
$editorForm.find("#DFCategory").buildEditableSelect(query1, {textAttr: 'name', listClass: 'comboList'});
|
||||
$editorForm.find("#DFCategory").buildCombo(query1, {textAttr: 'name', listClass: 'comboList'});
|
||||
//Initialize the validator
|
||||
$editorForm.validator();
|
||||
});
|
||||
@@ -266,6 +266,16 @@ $(function() {
|
||||
});
|
||||
});
|
||||
|
||||
//Close the view if the user uses the escape key and it isn't handled at the widget level.
|
||||
$editorView.on('keyup', function(event) {
|
||||
switch(event.keyCode) {
|
||||
case 27:
|
||||
if(!event.isDefaultPrevented())
|
||||
history.back();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++ Delete View +++++++++++
|
||||
|
||||
|
||||
@@ -143,15 +143,14 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
var dataTable = new LinkedTable($page.find('#dataTable'), {
|
||||
var $table = $page.find('#dataTable');
|
||||
$table.buildTable({
|
||||
url: "data/User/readAll",
|
||||
attr: "data-key-name",
|
||||
selection: "row",
|
||||
selectionChanged: selectionChanged
|
||||
});
|
||||
|
||||
//Call the refresh user table function once initially.
|
||||
dataTable.build();
|
||||
var dataTable = $table.getTable();
|
||||
|
||||
//----------------------------
|
||||
//---- Create User Dialog ----
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
<link rel="shortcut icon" href="images/Chicken.ico"/>
|
||||
<link rel="stylesheet" href="main.css" type="text/css"/>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-1.11.1.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-migrate-1.2.1.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-1.12.4.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery-migrate-1.3.0.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.history.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/layout.js"></script>
|
||||
<script type="text/javascript" language="JavaScript" src="js/jquery.cycle.min.js"></script>
|
||||
|
||||
11008
public/js/jquery-1.12.4.js
vendored
Normal file
11008
public/js/jquery-1.12.4.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
public/js/jquery-1.12.4.min.js
vendored
Normal file
5
public/js/jquery-1.12.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
702
public/js/jquery-migrate-1.3.0.js
Normal file
702
public/js/jquery-migrate-1.3.0.js
Normal file
@@ -0,0 +1,702 @@
|
||||
/*!
|
||||
* jQuery Migrate - v1.3.0 - 2016-01-13
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
*/
|
||||
(function( jQuery, window, undefined ) {
|
||||
// See http://bugs.jquery.com/ticket/13335
|
||||
// "use strict";
|
||||
|
||||
|
||||
jQuery.migrateVersion = "1.3.0";
|
||||
|
||||
|
||||
var warnedAbout = {};
|
||||
|
||||
// List of warnings already given; public read only
|
||||
jQuery.migrateWarnings = [];
|
||||
|
||||
// Set to true to prevent console output; migrateWarnings still maintained
|
||||
// jQuery.migrateMute = false;
|
||||
|
||||
// Show a message on the console so devs know we're active
|
||||
if ( !jQuery.migrateMute && window.console && window.console.log ) {
|
||||
window.console.log("JQMIGRATE: Logging is active");
|
||||
}
|
||||
|
||||
// Set to false to disable traces that appear with warnings
|
||||
if ( jQuery.migrateTrace === undefined ) {
|
||||
jQuery.migrateTrace = true;
|
||||
}
|
||||
|
||||
// Forget any warnings we've already given; public
|
||||
jQuery.migrateReset = function() {
|
||||
warnedAbout = {};
|
||||
jQuery.migrateWarnings.length = 0;
|
||||
};
|
||||
|
||||
function migrateWarn( msg) {
|
||||
var console = window.console;
|
||||
if ( !warnedAbout[ msg ] ) {
|
||||
warnedAbout[ msg ] = true;
|
||||
jQuery.migrateWarnings.push( msg );
|
||||
if ( console && console.warn && !jQuery.migrateMute ) {
|
||||
console.warn( "JQMIGRATE: " + msg );
|
||||
if ( jQuery.migrateTrace && console.trace ) {
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function migrateWarnProp( obj, prop, value, msg ) {
|
||||
if ( Object.defineProperty ) {
|
||||
// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
|
||||
// allow property to be overwritten in case some other plugin wants it
|
||||
try {
|
||||
Object.defineProperty( obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
migrateWarn( msg );
|
||||
return value;
|
||||
},
|
||||
set: function( newValue ) {
|
||||
migrateWarn( msg );
|
||||
value = newValue;
|
||||
}
|
||||
});
|
||||
return;
|
||||
} catch( err ) {
|
||||
// IE8 is a dope about Object.defineProperty, can't warn there
|
||||
}
|
||||
}
|
||||
|
||||
// Non-ES5 (or broken) browser; just set the property
|
||||
jQuery._definePropertyBroken = true;
|
||||
obj[ prop ] = value;
|
||||
}
|
||||
|
||||
if ( document.compatMode === "BackCompat" ) {
|
||||
// jQuery has never supported or tested Quirks Mode
|
||||
migrateWarn( "jQuery is not compatible with Quirks Mode" );
|
||||
}
|
||||
|
||||
|
||||
var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
|
||||
oldAttr = jQuery.attr,
|
||||
valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
|
||||
function() { return null; },
|
||||
valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
|
||||
function() { return undefined; },
|
||||
rnoType = /^(?:input|button)$/i,
|
||||
rnoAttrNodeType = /^[238]$/,
|
||||
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
|
||||
ruseDefault = /^(?:checked|selected)$/i;
|
||||
|
||||
// jQuery.attrFn
|
||||
migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
|
||||
|
||||
jQuery.attr = function( elem, name, value, pass ) {
|
||||
var lowerName = name.toLowerCase(),
|
||||
nType = elem && elem.nodeType;
|
||||
|
||||
if ( pass ) {
|
||||
// Since pass is used internally, we only warn for new jQuery
|
||||
// versions where there isn't a pass arg in the formal params
|
||||
if ( oldAttr.length < 4 ) {
|
||||
migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
|
||||
}
|
||||
if ( elem && !rnoAttrNodeType.test( nType ) &&
|
||||
(attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
|
||||
return jQuery( elem )[ name ]( value );
|
||||
}
|
||||
}
|
||||
|
||||
// Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
|
||||
// for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
|
||||
if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
|
||||
migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
|
||||
}
|
||||
|
||||
// Restore boolHook for boolean property/attribute synchronization
|
||||
if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
|
||||
jQuery.attrHooks[ lowerName ] = {
|
||||
get: function( elem, name ) {
|
||||
// Align boolean attributes with corresponding properties
|
||||
// Fall back to attribute presence where some booleans are not supported
|
||||
var attrNode,
|
||||
property = jQuery.prop( elem, name );
|
||||
return property === true || typeof property !== "boolean" &&
|
||||
( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
|
||||
|
||||
name.toLowerCase() :
|
||||
undefined;
|
||||
},
|
||||
set: function( elem, value, name ) {
|
||||
var propName;
|
||||
if ( value === false ) {
|
||||
// Remove boolean attributes when set to false
|
||||
jQuery.removeAttr( elem, name );
|
||||
} else {
|
||||
// value is true since we know at this point it's type boolean and not false
|
||||
// Set boolean attributes to the same name and set the DOM property
|
||||
propName = jQuery.propFix[ name ] || name;
|
||||
if ( propName in elem ) {
|
||||
// Only set the IDL specifically if it already exists on the element
|
||||
elem[ propName ] = true;
|
||||
}
|
||||
|
||||
elem.setAttribute( name, name.toLowerCase() );
|
||||
}
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
// Warn only for attributes that can remain distinct from their properties post-1.9
|
||||
if ( ruseDefault.test( lowerName ) ) {
|
||||
migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
|
||||
}
|
||||
}
|
||||
|
||||
return oldAttr.call( jQuery, elem, name, value );
|
||||
};
|
||||
|
||||
// attrHooks: value
|
||||
jQuery.attrHooks.value = {
|
||||
get: function( elem, name ) {
|
||||
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
||||
if ( nodeName === "button" ) {
|
||||
return valueAttrGet.apply( this, arguments );
|
||||
}
|
||||
if ( nodeName !== "input" && nodeName !== "option" ) {
|
||||
migrateWarn("jQuery.fn.attr('value') no longer gets properties");
|
||||
}
|
||||
return name in elem ?
|
||||
elem.value :
|
||||
null;
|
||||
},
|
||||
set: function( elem, value ) {
|
||||
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
||||
if ( nodeName === "button" ) {
|
||||
return valueAttrSet.apply( this, arguments );
|
||||
}
|
||||
if ( nodeName !== "input" && nodeName !== "option" ) {
|
||||
migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
|
||||
}
|
||||
// Does not return so that setAttribute is also used
|
||||
elem.value = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var matched, browser,
|
||||
oldInit = jQuery.fn.init,
|
||||
oldParseJSON = jQuery.parseJSON,
|
||||
rspaceAngle = /^\s*</,
|
||||
// Note: XSS check is done below after string is trimmed
|
||||
rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
|
||||
|
||||
// $(html) "looks like html" rule change
|
||||
jQuery.fn.init = function( selector, context, rootjQuery ) {
|
||||
var match, ret;
|
||||
|
||||
if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
|
||||
(match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
|
||||
// This is an HTML string according to the "old" rules; is it still?
|
||||
if ( !rspaceAngle.test( selector ) ) {
|
||||
migrateWarn("$(html) HTML strings must start with '<' character");
|
||||
}
|
||||
if ( match[ 3 ] ) {
|
||||
migrateWarn("$(html) HTML text after last tag is ignored");
|
||||
}
|
||||
|
||||
// Consistently reject any HTML-like string starting with a hash (#9521)
|
||||
// Note that this may break jQuery 1.6.x code that otherwise would work.
|
||||
if ( match[ 0 ].charAt( 0 ) === "#" ) {
|
||||
migrateWarn("HTML string cannot start with a '#' character");
|
||||
jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
|
||||
}
|
||||
// Now process using loose rules; let pre-1.8 play too
|
||||
if ( context && context.context ) {
|
||||
// jQuery object as context; parseHTML expects a DOM object
|
||||
context = context.context;
|
||||
}
|
||||
if ( jQuery.parseHTML ) {
|
||||
return oldInit.call( this,
|
||||
jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
|
||||
context || document, true ), context, rootjQuery );
|
||||
}
|
||||
}
|
||||
|
||||
// jQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
|
||||
if ( selector === "#" ) {
|
||||
migrateWarn( "jQuery( '#' ) is not a valid selector" );
|
||||
selector = [];
|
||||
}
|
||||
|
||||
ret = oldInit.apply( this, arguments );
|
||||
|
||||
// Fill in selector and context properties so .live() works
|
||||
if ( selector && selector.selector !== undefined ) {
|
||||
// A jQuery object, copy its properties
|
||||
ret.selector = selector.selector;
|
||||
ret.context = selector.context;
|
||||
|
||||
} else {
|
||||
ret.selector = typeof selector === "string" ? selector : "";
|
||||
if ( selector ) {
|
||||
ret.context = selector.nodeType? selector : context || document;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
jQuery.fn.init.prototype = jQuery.fn;
|
||||
|
||||
// Let $.parseJSON(falsy_value) return null
|
||||
jQuery.parseJSON = function( json ) {
|
||||
if ( !json ) {
|
||||
migrateWarn("jQuery.parseJSON requires a valid JSON string");
|
||||
return null;
|
||||
}
|
||||
return oldParseJSON.apply( this, arguments );
|
||||
};
|
||||
|
||||
jQuery.uaMatch = function( ua ) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
||||
/(msie) ([\w.]+)/.exec( ua ) ||
|
||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
||||
[];
|
||||
|
||||
return {
|
||||
browser: match[ 1 ] || "",
|
||||
version: match[ 2 ] || "0"
|
||||
};
|
||||
};
|
||||
|
||||
// Don't clobber any existing jQuery.browser in case it's different
|
||||
if ( !jQuery.browser ) {
|
||||
matched = jQuery.uaMatch( navigator.userAgent );
|
||||
browser = {};
|
||||
|
||||
if ( matched.browser ) {
|
||||
browser[ matched.browser ] = true;
|
||||
browser.version = matched.version;
|
||||
}
|
||||
|
||||
// Chrome is Webkit, but Webkit is also Safari.
|
||||
if ( browser.chrome ) {
|
||||
browser.webkit = true;
|
||||
} else if ( browser.webkit ) {
|
||||
browser.safari = true;
|
||||
}
|
||||
|
||||
jQuery.browser = browser;
|
||||
}
|
||||
|
||||
// Warn if the code tries to get jQuery.browser
|
||||
migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
|
||||
|
||||
// jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
|
||||
jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
|
||||
migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
|
||||
migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
|
||||
|
||||
jQuery.sub = function() {
|
||||
function jQuerySub( selector, context ) {
|
||||
return new jQuerySub.fn.init( selector, context );
|
||||
}
|
||||
jQuery.extend( true, jQuerySub, this );
|
||||
jQuerySub.superclass = this;
|
||||
jQuerySub.fn = jQuerySub.prototype = this();
|
||||
jQuerySub.fn.constructor = jQuerySub;
|
||||
jQuerySub.sub = this.sub;
|
||||
jQuerySub.fn.init = function init( selector, context ) {
|
||||
var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
||||
return instance instanceof jQuerySub ?
|
||||
instance :
|
||||
jQuerySub( instance );
|
||||
};
|
||||
jQuerySub.fn.init.prototype = jQuerySub.fn;
|
||||
var rootjQuerySub = jQuerySub(document);
|
||||
migrateWarn( "jQuery.sub() is deprecated" );
|
||||
return jQuerySub;
|
||||
};
|
||||
|
||||
// The number of elements contained in the matched element set
|
||||
jQuery.fn.size = function() {
|
||||
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
|
||||
return this.length;
|
||||
};
|
||||
|
||||
|
||||
var internalSwapCall = false;
|
||||
|
||||
// If this version of jQuery has .swap(), don't false-alarm on internal uses
|
||||
if ( jQuery.swap ) {
|
||||
jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
|
||||
var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
|
||||
|
||||
if ( oldHook ) {
|
||||
jQuery.cssHooks[ name ].get = function() {
|
||||
var ret;
|
||||
|
||||
internalSwapCall = true;
|
||||
ret = oldHook.apply( this, arguments );
|
||||
internalSwapCall = false;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
jQuery.swap = function( elem, options, callback, args ) {
|
||||
var ret, name,
|
||||
old = {};
|
||||
|
||||
if ( !internalSwapCall ) {
|
||||
migrateWarn( "jQuery.swap() is undocumented and deprecated" );
|
||||
}
|
||||
|
||||
// Remember the old values, and insert the new ones
|
||||
for ( name in options ) {
|
||||
old[ name ] = elem.style[ name ];
|
||||
elem.style[ name ] = options[ name ];
|
||||
}
|
||||
|
||||
ret = callback.apply( elem, args || [] );
|
||||
|
||||
// Revert the old values
|
||||
for ( name in options ) {
|
||||
elem.style[ name ] = old[ name ];
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// Ensure that $.ajax gets the new parseJSON defined in core.js
|
||||
jQuery.ajaxSetup({
|
||||
converters: {
|
||||
"text json": jQuery.parseJSON
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var oldFnData = jQuery.fn.data;
|
||||
|
||||
jQuery.fn.data = function( name ) {
|
||||
var ret, evt,
|
||||
elem = this[0];
|
||||
|
||||
// Handles 1.7 which has this behavior and 1.8 which doesn't
|
||||
if ( elem && name === "events" && arguments.length === 1 ) {
|
||||
ret = jQuery.data( elem, name );
|
||||
evt = jQuery._data( elem, name );
|
||||
if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
|
||||
migrateWarn("Use of jQuery.fn.data('events') is deprecated");
|
||||
return evt;
|
||||
}
|
||||
}
|
||||
return oldFnData.apply( this, arguments );
|
||||
};
|
||||
|
||||
|
||||
var rscriptType = /\/(java|ecma)script/i;
|
||||
|
||||
// Since jQuery.clean is used internally on older versions, we only shim if it's missing
|
||||
if ( !jQuery.clean ) {
|
||||
jQuery.clean = function( elems, context, fragment, scripts ) {
|
||||
// Set context per 1.8 logic
|
||||
context = context || document;
|
||||
context = !context.nodeType && context[0] || context;
|
||||
context = context.ownerDocument || context;
|
||||
|
||||
migrateWarn("jQuery.clean() is deprecated");
|
||||
|
||||
var i, elem, handleScript, jsTags,
|
||||
ret = [];
|
||||
|
||||
jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
|
||||
|
||||
// Complex logic lifted directly from jQuery 1.8
|
||||
if ( fragment ) {
|
||||
// Special handling of each script element
|
||||
handleScript = function( elem ) {
|
||||
// Check if we consider it executable
|
||||
if ( !elem.type || rscriptType.test( elem.type ) ) {
|
||||
// Detach the script and store it in the scripts array (if provided) or the fragment
|
||||
// Return truthy to indicate that it has been handled
|
||||
return scripts ?
|
||||
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
|
||||
fragment.appendChild( elem );
|
||||
}
|
||||
};
|
||||
|
||||
for ( i = 0; (elem = ret[i]) != null; i++ ) {
|
||||
// Check if we're done after handling an executable script
|
||||
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
|
||||
// Append to fragment and handle embedded scripts
|
||||
fragment.appendChild( elem );
|
||||
if ( typeof elem.getElementsByTagName !== "undefined" ) {
|
||||
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
|
||||
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
|
||||
|
||||
// Splice the scripts into ret after their former ancestor and advance our index beyond them
|
||||
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
||||
i += jsTags.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
var eventAdd = jQuery.event.add,
|
||||
eventRemove = jQuery.event.remove,
|
||||
eventTrigger = jQuery.event.trigger,
|
||||
oldToggle = jQuery.fn.toggle,
|
||||
oldLive = jQuery.fn.live,
|
||||
oldDie = jQuery.fn.die,
|
||||
oldLoad = jQuery.fn.load,
|
||||
ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
|
||||
rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
|
||||
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
|
||||
hoverHack = function( events ) {
|
||||
if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
|
||||
return events;
|
||||
}
|
||||
if ( rhoverHack.test( events ) ) {
|
||||
migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
|
||||
}
|
||||
return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
|
||||
};
|
||||
|
||||
// Event props removed in 1.9, put them back if needed; no practical way to warn them
|
||||
if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
|
||||
jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
|
||||
}
|
||||
|
||||
// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
|
||||
if ( jQuery.event.dispatch ) {
|
||||
migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
|
||||
}
|
||||
|
||||
// Support for 'hover' pseudo-event and ajax event warnings
|
||||
jQuery.event.add = function( elem, types, handler, data, selector ){
|
||||
if ( elem !== document && rajaxEvent.test( types ) ) {
|
||||
migrateWarn( "AJAX events should be attached to document: " + types );
|
||||
}
|
||||
eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
|
||||
};
|
||||
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
|
||||
eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
|
||||
};
|
||||
|
||||
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
|
||||
|
||||
jQuery.fn[ name ] = function() {
|
||||
var args = Array.prototype.slice.call( arguments, 0 );
|
||||
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
|
||||
|
||||
// If this is an ajax load() the first arg should be the string URL;
|
||||
// technically this could also be the "Anything" arg of the event .load()
|
||||
// which just goes to show why this dumb signature has been deprecated!
|
||||
// jQuery custom builds that exclude the Ajax module justifiably die here.
|
||||
if ( name === "load" && typeof arguments[ 0 ] === "string" ) {
|
||||
return oldLoad.apply( this, arguments );
|
||||
}
|
||||
|
||||
args.splice( 0, 0, name );
|
||||
if ( arguments.length ) {
|
||||
return this.bind.apply( this, args );
|
||||
}
|
||||
|
||||
// Use .triggerHandler here because:
|
||||
// - load and unload events don't need to bubble, only applied to window or image
|
||||
// - error event should not bubble to window, although it does pre-1.7
|
||||
// See http://bugs.jquery.com/ticket/11820
|
||||
this.triggerHandler.apply( this, args );
|
||||
return this;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
jQuery.fn.toggle = function( fn, fn2 ) {
|
||||
|
||||
// Don't mess with animation or css toggles
|
||||
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
|
||||
return oldToggle.apply( this, arguments );
|
||||
}
|
||||
migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
|
||||
|
||||
// Save reference to arguments for access in closure
|
||||
var args = arguments,
|
||||
guid = fn.guid || jQuery.guid++,
|
||||
i = 0,
|
||||
toggler = function( event ) {
|
||||
// Figure out which function to execute
|
||||
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
||||
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
||||
|
||||
// Make sure that clicks stop
|
||||
event.preventDefault();
|
||||
|
||||
// and execute the function
|
||||
return args[ lastToggle ].apply( this, arguments ) || false;
|
||||
};
|
||||
|
||||
// link all the functions, so any of them can unbind this click handler
|
||||
toggler.guid = guid;
|
||||
while ( i < args.length ) {
|
||||
args[ i++ ].guid = guid;
|
||||
}
|
||||
|
||||
return this.click( toggler );
|
||||
};
|
||||
|
||||
jQuery.fn.live = function( types, data, fn ) {
|
||||
migrateWarn("jQuery.fn.live() is deprecated");
|
||||
if ( oldLive ) {
|
||||
return oldLive.apply( this, arguments );
|
||||
}
|
||||
jQuery( this.context ).on( types, this.selector, data, fn );
|
||||
return this;
|
||||
};
|
||||
|
||||
jQuery.fn.die = function( types, fn ) {
|
||||
migrateWarn("jQuery.fn.die() is deprecated");
|
||||
if ( oldDie ) {
|
||||
return oldDie.apply( this, arguments );
|
||||
}
|
||||
jQuery( this.context ).off( types, this.selector || "**", fn );
|
||||
return this;
|
||||
};
|
||||
|
||||
// Turn global events into document-triggered events
|
||||
jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
|
||||
if ( !elem && !rajaxEvent.test( event ) ) {
|
||||
migrateWarn( "Global events are undocumented and deprecated" );
|
||||
}
|
||||
return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
|
||||
};
|
||||
jQuery.each( ajaxEvents.split("|"),
|
||||
function( _, name ) {
|
||||
jQuery.event.special[ name ] = {
|
||||
setup: function() {
|
||||
var elem = this;
|
||||
|
||||
// The document needs no shimming; must be !== for oldIE
|
||||
if ( elem !== document ) {
|
||||
jQuery.event.add( document, name + "." + jQuery.guid, function() {
|
||||
jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
|
||||
});
|
||||
jQuery._data( this, name, jQuery.guid++ );
|
||||
}
|
||||
return false;
|
||||
},
|
||||
teardown: function() {
|
||||
if ( this !== document ) {
|
||||
jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
jQuery.event.special.ready = {
|
||||
setup: function() { migrateWarn( "'ready' event is deprecated" ); }
|
||||
};
|
||||
|
||||
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
|
||||
oldFind = jQuery.fn.find;
|
||||
|
||||
jQuery.fn.andSelf = function() {
|
||||
migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
|
||||
return oldSelf.apply( this, arguments );
|
||||
};
|
||||
|
||||
jQuery.fn.find = function( selector ) {
|
||||
var ret = oldFind.apply( this, arguments );
|
||||
ret.context = this.context;
|
||||
ret.selector = this.selector ? this.selector + " " + selector : selector;
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// jQuery 1.6 did not support Callbacks, do not warn there
|
||||
if ( jQuery.Callbacks ) {
|
||||
|
||||
var oldDeferred = jQuery.Deferred,
|
||||
tuples = [
|
||||
// action, add listener, callbacks, .then handlers, final state
|
||||
[ "resolve", "done", jQuery.Callbacks("once memory"),
|
||||
jQuery.Callbacks("once memory"), "resolved" ],
|
||||
[ "reject", "fail", jQuery.Callbacks("once memory"),
|
||||
jQuery.Callbacks("once memory"), "rejected" ],
|
||||
[ "notify", "progress", jQuery.Callbacks("memory"),
|
||||
jQuery.Callbacks("memory") ]
|
||||
];
|
||||
|
||||
jQuery.Deferred = function( func ) {
|
||||
var deferred = oldDeferred(),
|
||||
promise = deferred.promise();
|
||||
|
||||
deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
|
||||
var fns = arguments;
|
||||
|
||||
migrateWarn( "deferred.pipe() is deprecated" );
|
||||
|
||||
return jQuery.Deferred(function( newDefer ) {
|
||||
jQuery.each( tuples, function( i, tuple ) {
|
||||
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
||||
// deferred.done(function() { bind to newDefer or newDefer.resolve })
|
||||
// deferred.fail(function() { bind to newDefer or newDefer.reject })
|
||||
// deferred.progress(function() { bind to newDefer or newDefer.notify })
|
||||
deferred[ tuple[1] ](function() {
|
||||
var returned = fn && fn.apply( this, arguments );
|
||||
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
||||
returned.promise()
|
||||
.done( newDefer.resolve )
|
||||
.fail( newDefer.reject )
|
||||
.progress( newDefer.notify );
|
||||
} else {
|
||||
newDefer[ tuple[ 0 ] + "With" ](
|
||||
this === promise ? newDefer.promise() : this,
|
||||
fn ? [ returned ] : arguments
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
fns = null;
|
||||
}).promise();
|
||||
|
||||
};
|
||||
|
||||
deferred.isResolved = function() {
|
||||
migrateWarn( "deferred.isResolved is deprecated" );
|
||||
return deferred.state() === "resolved";
|
||||
};
|
||||
|
||||
deferred.isRejected = function() {
|
||||
migrateWarn( "deferred.isRejected is deprecated" );
|
||||
return deferred.state() === "rejected";
|
||||
};
|
||||
|
||||
if ( func ) {
|
||||
func.call( deferred, deferred );
|
||||
}
|
||||
|
||||
return deferred;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
})( jQuery, window );
|
||||
2
public/js/jquery-migrate-1.3.0.min.js
vendored
Normal file
2
public/js/jquery-migrate-1.3.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
540
public/js/jquery-migrate-3.0.0.js
Normal file
540
public/js/jquery-migrate-3.0.0.js
Normal file
@@ -0,0 +1,540 @@
|
||||
/*!
|
||||
* jQuery Migrate - v3.0.0 - 2016-06-09
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
*/
|
||||
(function( jQuery, window ) {
|
||||
"use strict";
|
||||
|
||||
|
||||
jQuery.migrateVersion = "3.0.0";
|
||||
|
||||
|
||||
( function() {
|
||||
|
||||
// Support: IE9 only
|
||||
// IE9 only creates console object when dev tools are first opened
|
||||
// Also, avoid Function#bind here to simplify PhantomJS usage
|
||||
var log = window.console && window.console.log &&
|
||||
function() { window.console.log.apply( window.console, arguments ); },
|
||||
rbadVersions = /^[12]\./;
|
||||
|
||||
if ( !log ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Need jQuery 3.0.0+ and no older Migrate loaded
|
||||
if ( !jQuery || rbadVersions.test( jQuery.fn.jquery ) ) {
|
||||
log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
|
||||
}
|
||||
if ( jQuery.migrateWarnings ) {
|
||||
log( "JQMIGRATE: Migrate plugin loaded multiple times" );
|
||||
}
|
||||
|
||||
// Show a message on the console so devs know we're active
|
||||
log( "JQMIGRATE: Migrate is installed" +
|
||||
( jQuery.migrateMute ? "" : " with logging active" ) +
|
||||
", version " + jQuery.migrateVersion );
|
||||
|
||||
} )();
|
||||
|
||||
var warnedAbout = {};
|
||||
|
||||
// List of warnings already given; public read only
|
||||
jQuery.migrateWarnings = [];
|
||||
|
||||
// Set to false to disable traces that appear with warnings
|
||||
if ( jQuery.migrateTrace === undefined ) {
|
||||
jQuery.migrateTrace = true;
|
||||
}
|
||||
|
||||
// Forget any warnings we've already given; public
|
||||
jQuery.migrateReset = function() {
|
||||
warnedAbout = {};
|
||||
jQuery.migrateWarnings.length = 0;
|
||||
};
|
||||
|
||||
function migrateWarn( msg ) {
|
||||
var console = window.console;
|
||||
if ( !warnedAbout[ msg ] ) {
|
||||
warnedAbout[ msg ] = true;
|
||||
jQuery.migrateWarnings.push( msg );
|
||||
if ( console && console.warn && !jQuery.migrateMute ) {
|
||||
console.warn( "JQMIGRATE: " + msg );
|
||||
if ( jQuery.migrateTrace && console.trace ) {
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function migrateWarnProp( obj, prop, value, msg ) {
|
||||
Object.defineProperty( obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
migrateWarn( msg );
|
||||
return value;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( document.compatMode === "BackCompat" ) {
|
||||
|
||||
// JQuery has never supported or tested Quirks Mode
|
||||
migrateWarn( "jQuery is not compatible with Quirks Mode" );
|
||||
}
|
||||
|
||||
|
||||
var oldInit = jQuery.fn.init,
|
||||
oldIsNumeric = jQuery.isNumeric,
|
||||
oldFind = jQuery.find,
|
||||
rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
|
||||
rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g;
|
||||
|
||||
jQuery.fn.init = function( arg1 ) {
|
||||
var args = Array.prototype.slice.call( arguments );
|
||||
|
||||
if ( typeof arg1 === "string" && arg1 === "#" ) {
|
||||
|
||||
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
|
||||
migrateWarn( "jQuery( '#' ) is not a valid selector" );
|
||||
args[ 0 ] = [];
|
||||
}
|
||||
|
||||
return oldInit.apply( this, args );
|
||||
};
|
||||
jQuery.fn.init.prototype = jQuery.fn;
|
||||
|
||||
jQuery.find = function( selector ) {
|
||||
var args = Array.prototype.slice.call( arguments );
|
||||
|
||||
// Support: PhantomJS 1.x
|
||||
// String#match fails to match when used with a //g RegExp, only on some strings
|
||||
if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
|
||||
|
||||
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
|
||||
// First see if qS thinks it's a valid selector, if so avoid a false positive
|
||||
try {
|
||||
document.querySelector( selector );
|
||||
} catch ( err1 ) {
|
||||
|
||||
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
|
||||
selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
|
||||
return "[" + attr + op + "\"" + value + "\"]";
|
||||
} );
|
||||
|
||||
// If the regexp *may* have created an invalid selector, don't update it
|
||||
// Note that there may be false alarms if selector uses jQuery extensions
|
||||
try {
|
||||
document.querySelector( selector );
|
||||
migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
|
||||
args[ 0 ] = selector;
|
||||
} catch ( err2 ) {
|
||||
migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return oldFind.apply( this, args );
|
||||
};
|
||||
|
||||
// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
|
||||
var findProp;
|
||||
for ( findProp in oldFind ) {
|
||||
if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
|
||||
jQuery.find[ findProp ] = oldFind[ findProp ];
|
||||
}
|
||||
}
|
||||
|
||||
// The number of elements contained in the matched element set
|
||||
jQuery.fn.size = function() {
|
||||
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
|
||||
return this.length;
|
||||
};
|
||||
|
||||
jQuery.parseJSON = function() {
|
||||
migrateWarn( "jQuery.parseJSON is deprecated; use JSON.parse" );
|
||||
return JSON.parse.apply( null, arguments );
|
||||
};
|
||||
|
||||
jQuery.isNumeric = function( val ) {
|
||||
|
||||
// The jQuery 2.2.3 implementation of isNumeric
|
||||
function isNumeric2( obj ) {
|
||||
var realStringObj = obj && obj.toString();
|
||||
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
|
||||
}
|
||||
|
||||
var newValue = oldIsNumeric( val ),
|
||||
oldValue = isNumeric2( val );
|
||||
|
||||
if ( newValue !== oldValue ) {
|
||||
migrateWarn( "jQuery.isNumeric() should not be called on constructed objects" );
|
||||
}
|
||||
|
||||
return oldValue;
|
||||
};
|
||||
|
||||
migrateWarnProp( jQuery, "unique", jQuery.uniqueSort,
|
||||
"jQuery.unique is deprecated, use jQuery.uniqueSort" );
|
||||
|
||||
// Now jQuery.expr.pseudos is the standard incantation
|
||||
migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
|
||||
"jQuery.expr.filters is now jQuery.expr.pseudos" );
|
||||
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
|
||||
"jQuery.expr[\":\"] is now jQuery.expr.pseudos" );
|
||||
|
||||
|
||||
var oldAjax = jQuery.ajax;
|
||||
|
||||
jQuery.ajax = function( ) {
|
||||
var jQXHR = oldAjax.apply( this, arguments );
|
||||
|
||||
// Be sure we got a jQXHR (e.g., not sync)
|
||||
if ( jQXHR.promise ) {
|
||||
migrateWarnProp( jQXHR, "success", jQXHR.done,
|
||||
"jQXHR.success is deprecated and removed" );
|
||||
migrateWarnProp( jQXHR, "error", jQXHR.fail,
|
||||
"jQXHR.error is deprecated and removed" );
|
||||
migrateWarnProp( jQXHR, "complete", jQXHR.always,
|
||||
"jQXHR.complete is deprecated and removed" );
|
||||
}
|
||||
|
||||
return jQXHR;
|
||||
};
|
||||
|
||||
|
||||
var oldRemoveAttr = jQuery.fn.removeAttr,
|
||||
oldToggleClass = jQuery.fn.toggleClass,
|
||||
rmatchNonSpace = /\S+/g;
|
||||
|
||||
jQuery.fn.removeAttr = function( name ) {
|
||||
var self = this;
|
||||
|
||||
jQuery.each( name.match( rmatchNonSpace ), function( i, attr ) {
|
||||
if ( jQuery.expr.match.bool.test( attr ) ) {
|
||||
migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
|
||||
self.prop( attr, false );
|
||||
}
|
||||
} );
|
||||
|
||||
return oldRemoveAttr.apply( this, arguments );
|
||||
};
|
||||
|
||||
jQuery.fn.toggleClass = function( state ) {
|
||||
|
||||
// Only deprecating no-args or single boolean arg
|
||||
if ( state !== undefined && typeof state !== "boolean" ) {
|
||||
return oldToggleClass.apply( this, arguments );
|
||||
}
|
||||
|
||||
migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" );
|
||||
|
||||
// Toggle entire class name of each element
|
||||
return this.each( function() {
|
||||
var className = this.getAttribute && this.getAttribute( "class" ) || "";
|
||||
|
||||
if ( className ) {
|
||||
jQuery.data( this, "__className__", className );
|
||||
}
|
||||
|
||||
// If the element has a class name or if we're passed `false`,
|
||||
// then remove the whole classname (if there was one, the above saved it).
|
||||
// Otherwise bring back whatever was previously saved (if anything),
|
||||
// falling back to the empty string if nothing was stored.
|
||||
if ( this.setAttribute ) {
|
||||
this.setAttribute( "class",
|
||||
className || state === false ?
|
||||
"" :
|
||||
jQuery.data( this, "__className__" ) || ""
|
||||
);
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
|
||||
var internalSwapCall = false;
|
||||
|
||||
// If this version of jQuery has .swap(), don't false-alarm on internal uses
|
||||
if ( jQuery.swap ) {
|
||||
jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
|
||||
var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
|
||||
|
||||
if ( oldHook ) {
|
||||
jQuery.cssHooks[ name ].get = function() {
|
||||
var ret;
|
||||
|
||||
internalSwapCall = true;
|
||||
ret = oldHook.apply( this, arguments );
|
||||
internalSwapCall = false;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
jQuery.swap = function( elem, options, callback, args ) {
|
||||
var ret, name,
|
||||
old = {};
|
||||
|
||||
if ( !internalSwapCall ) {
|
||||
migrateWarn( "jQuery.swap() is undocumented and deprecated" );
|
||||
}
|
||||
|
||||
// Remember the old values, and insert the new ones
|
||||
for ( name in options ) {
|
||||
old[ name ] = elem.style[ name ];
|
||||
elem.style[ name ] = options[ name ];
|
||||
}
|
||||
|
||||
ret = callback.apply( elem, args || [] );
|
||||
|
||||
// Revert the old values
|
||||
for ( name in options ) {
|
||||
elem.style[ name ] = old[ name ];
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
var oldData = jQuery.data;
|
||||
|
||||
jQuery.data = function( elem, name, value ) {
|
||||
var curData;
|
||||
|
||||
// If the name is transformed, look for the un-transformed name in the data object
|
||||
if ( name && name !== jQuery.camelCase( name ) ) {
|
||||
curData = jQuery.hasData( elem ) && oldData.call( this, elem );
|
||||
if ( curData && name in curData ) {
|
||||
migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name );
|
||||
if ( arguments.length > 2 ) {
|
||||
curData[ name ] = value;
|
||||
}
|
||||
return curData[ name ];
|
||||
}
|
||||
}
|
||||
|
||||
return oldData.apply( this, arguments );
|
||||
};
|
||||
|
||||
var oldTweenRun = jQuery.Tween.prototype.run;
|
||||
|
||||
jQuery.Tween.prototype.run = function( percent ) {
|
||||
if ( jQuery.easing[ this.easing ].length > 1 ) {
|
||||
migrateWarn(
|
||||
"easing function " +
|
||||
"\"jQuery.easing." + this.easing.toString() +
|
||||
"\" should use only first argument"
|
||||
);
|
||||
|
||||
jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind(
|
||||
jQuery.easing,
|
||||
percent, this.options.duration * percent, 0, 1, this.options.duration
|
||||
);
|
||||
}
|
||||
|
||||
oldTweenRun.apply( this, arguments );
|
||||
};
|
||||
|
||||
var oldLoad = jQuery.fn.load,
|
||||
originalFix = jQuery.event.fix;
|
||||
|
||||
jQuery.event.props = [];
|
||||
jQuery.event.fixHooks = {};
|
||||
|
||||
jQuery.event.fix = function( originalEvent ) {
|
||||
var event,
|
||||
type = originalEvent.type,
|
||||
fixHook = this.fixHooks[ type ],
|
||||
props = jQuery.event.props;
|
||||
|
||||
if ( props.length ) {
|
||||
migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() );
|
||||
while ( props.length ) {
|
||||
jQuery.event.addProp( props.pop() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( fixHook && !fixHook._migrated_ ) {
|
||||
fixHook._migrated_ = true;
|
||||
migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
|
||||
if ( ( props = fixHook.props ) && props.length ) {
|
||||
while ( props.length ) {
|
||||
jQuery.event.addProp( props.pop() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event = originalFix.call( this, originalEvent );
|
||||
|
||||
return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
||||
};
|
||||
|
||||
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
|
||||
|
||||
jQuery.fn[ name ] = function() {
|
||||
var args = Array.prototype.slice.call( arguments, 0 );
|
||||
|
||||
// If this is an ajax load() the first arg should be the string URL;
|
||||
// technically this could also be the "Anything" arg of the event .load()
|
||||
// which just goes to show why this dumb signature has been deprecated!
|
||||
// jQuery custom builds that exclude the Ajax module justifiably die here.
|
||||
if ( name === "load" && typeof args[ 0 ] === "string" ) {
|
||||
return oldLoad.apply( this, args );
|
||||
}
|
||||
|
||||
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
|
||||
|
||||
args.splice( 0, 0, name );
|
||||
if ( arguments.length ) {
|
||||
return this.on.apply( this, args );
|
||||
}
|
||||
|
||||
// Use .triggerHandler here because:
|
||||
// - load and unload events don't need to bubble, only applied to window or image
|
||||
// - error event should not bubble to window, although it does pre-1.7
|
||||
// See http://bugs.jquery.com/ticket/11820
|
||||
this.triggerHandler.apply( this, args );
|
||||
return this;
|
||||
};
|
||||
|
||||
} );
|
||||
|
||||
// Trigger "ready" event only once, on document ready
|
||||
jQuery( function() {
|
||||
jQuery( document ).triggerHandler( "ready" );
|
||||
} );
|
||||
|
||||
jQuery.event.special.ready = {
|
||||
setup: function() {
|
||||
if ( this === document ) {
|
||||
migrateWarn( "'ready' event is deprecated" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.fn.extend( {
|
||||
|
||||
bind: function( types, data, fn ) {
|
||||
migrateWarn( "jQuery.fn.bind() is deprecated" );
|
||||
return this.on( types, null, data, fn );
|
||||
},
|
||||
unbind: function( types, fn ) {
|
||||
migrateWarn( "jQuery.fn.unbind() is deprecated" );
|
||||
return this.off( types, null, fn );
|
||||
},
|
||||
delegate: function( selector, types, data, fn ) {
|
||||
migrateWarn( "jQuery.fn.delegate() is deprecated" );
|
||||
return this.on( types, selector, data, fn );
|
||||
},
|
||||
undelegate: function( selector, types, fn ) {
|
||||
migrateWarn( "jQuery.fn.undelegate() is deprecated" );
|
||||
return arguments.length === 1 ?
|
||||
this.off( selector, "**" ) :
|
||||
this.off( types, selector || "**", fn );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
var oldOffset = jQuery.fn.offset;
|
||||
|
||||
jQuery.fn.offset = function() {
|
||||
var docElem,
|
||||
elem = this[ 0 ],
|
||||
origin = { top: 0, left: 0 };
|
||||
|
||||
if ( !elem || !elem.nodeType ) {
|
||||
migrateWarn( "jQuery.fn.offset() requires a valid DOM element" );
|
||||
return origin;
|
||||
}
|
||||
|
||||
docElem = ( elem.ownerDocument || document ).documentElement;
|
||||
if ( !jQuery.contains( docElem, elem ) ) {
|
||||
migrateWarn( "jQuery.fn.offset() requires an element connected to a document" );
|
||||
return origin;
|
||||
}
|
||||
|
||||
return oldOffset.apply( this, arguments );
|
||||
};
|
||||
|
||||
|
||||
var oldParam = jQuery.param;
|
||||
|
||||
jQuery.param = function( data, traditional ) {
|
||||
var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
|
||||
|
||||
if ( traditional === undefined && ajaxTraditional ) {
|
||||
|
||||
migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" );
|
||||
traditional = ajaxTraditional;
|
||||
}
|
||||
|
||||
return oldParam.call( this, data, traditional );
|
||||
};
|
||||
|
||||
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
|
||||
|
||||
jQuery.fn.andSelf = function() {
|
||||
migrateWarn( "jQuery.fn.andSelf() replaced by jQuery.fn.addBack()" );
|
||||
return oldSelf.apply( this, arguments );
|
||||
};
|
||||
|
||||
|
||||
var oldDeferred = jQuery.Deferred,
|
||||
tuples = [
|
||||
|
||||
// Action, add listener, callbacks, .then handlers, final state
|
||||
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
|
||||
jQuery.Callbacks( "once memory" ), "resolved" ],
|
||||
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
|
||||
jQuery.Callbacks( "once memory" ), "rejected" ],
|
||||
[ "notify", "progress", jQuery.Callbacks( "memory" ),
|
||||
jQuery.Callbacks( "memory" ) ]
|
||||
];
|
||||
|
||||
jQuery.Deferred = function( func ) {
|
||||
var deferred = oldDeferred(),
|
||||
promise = deferred.promise();
|
||||
|
||||
deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
|
||||
var fns = arguments;
|
||||
|
||||
migrateWarn( "deferred.pipe() is deprecated" );
|
||||
|
||||
return jQuery.Deferred( function( newDefer ) {
|
||||
jQuery.each( tuples, function( i, tuple ) {
|
||||
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
||||
|
||||
// Deferred.done(function() { bind to newDefer or newDefer.resolve })
|
||||
// deferred.fail(function() { bind to newDefer or newDefer.reject })
|
||||
// deferred.progress(function() { bind to newDefer or newDefer.notify })
|
||||
deferred[ tuple[ 1 ] ]( function() {
|
||||
var returned = fn && fn.apply( this, arguments );
|
||||
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
||||
returned.promise()
|
||||
.done( newDefer.resolve )
|
||||
.fail( newDefer.reject )
|
||||
.progress( newDefer.notify );
|
||||
} else {
|
||||
newDefer[ tuple[ 0 ] + "With" ](
|
||||
this === promise ? newDefer.promise() : this,
|
||||
fn ? [ returned ] : arguments
|
||||
);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
fns = null;
|
||||
} ).promise();
|
||||
|
||||
};
|
||||
|
||||
if ( func ) {
|
||||
func.call( deferred, deferred );
|
||||
}
|
||||
|
||||
return deferred;
|
||||
};
|
||||
|
||||
|
||||
|
||||
})( jQuery, window );
|
||||
2
public/js/jquery-migrate-3.0.0.min.js
vendored
Normal file
2
public/js/jquery-migrate-3.0.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
515
public/js/resize/ElementQueries.js
Normal file
515
public/js/resize/ElementQueries.js
Normal file
@@ -0,0 +1,515 @@
|
||||
/**
|
||||
* Copyright Marc J. Schmidt. See the LICENSE file at the top-level
|
||||
* directory of this distribution and at
|
||||
* https://github.com/marcj/css-element-queries/blob/master/LICENSE.
|
||||
*/
|
||||
;
|
||||
(function (root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(['./ResizeSensor.js'], factory);
|
||||
} else if (typeof exports === "object") {
|
||||
module.exports = factory(require('./ResizeSensor.js'));
|
||||
} else {
|
||||
root.ElementQueries = factory(root.ResizeSensor);
|
||||
}
|
||||
}(this, function (ResizeSensor) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {Function}
|
||||
* @constructor
|
||||
*/
|
||||
var ElementQueries = function() {
|
||||
|
||||
var trackingActive = false;
|
||||
var elements = [];
|
||||
|
||||
/**
|
||||
*
|
||||
* @param element
|
||||
* @returns {Number}
|
||||
*/
|
||||
function getEmSize(element) {
|
||||
if (!element) {
|
||||
element = document.documentElement;
|
||||
}
|
||||
var fontSize = window.getComputedStyle(element, null).fontSize;
|
||||
return parseFloat(fontSize) || 16;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright https://github.com/Mr0grog/element-query/blob/master/LICENSE
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @param {*} value
|
||||
* @returns {*}
|
||||
*/
|
||||
function convertToPx(element, value) {
|
||||
var numbers = value.split(/\d/);
|
||||
var units = numbers[numbers.length-1];
|
||||
value = parseFloat(value);
|
||||
switch (units) {
|
||||
case "px":
|
||||
return value;
|
||||
case "em":
|
||||
return value * getEmSize(element);
|
||||
case "rem":
|
||||
return value * getEmSize();
|
||||
// Viewport units!
|
||||
// According to http://quirksmode.org/mobile/tableViewport.html
|
||||
// documentElement.clientWidth/Height gets us the most reliable info
|
||||
case "vw":
|
||||
return value * document.documentElement.clientWidth / 100;
|
||||
case "vh":
|
||||
return value * document.documentElement.clientHeight / 100;
|
||||
case "vmin":
|
||||
case "vmax":
|
||||
var vw = document.documentElement.clientWidth / 100;
|
||||
var vh = document.documentElement.clientHeight / 100;
|
||||
var chooser = Math[units === "vmin" ? "min" : "max"];
|
||||
return value * chooser(vw, vh);
|
||||
default:
|
||||
return value;
|
||||
// for now, not supporting physical units (since they are just a set number of px)
|
||||
// or ex/ch (getting accurate measurements is hard)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @constructor
|
||||
*/
|
||||
function SetupInformation(element) {
|
||||
this.element = element;
|
||||
this.options = {};
|
||||
var key, option, width = 0, height = 0, value, actualValue, attrValues, attrValue, attrName;
|
||||
|
||||
/**
|
||||
* @param {Object} option {mode: 'min|max', property: 'width|height', value: '123px'}
|
||||
*/
|
||||
this.addOption = function(option) {
|
||||
var idx = [option.mode, option.property, option.value].join(',');
|
||||
this.options[idx] = option;
|
||||
};
|
||||
|
||||
var attributes = ['min-width', 'min-height', 'max-width', 'max-height'];
|
||||
|
||||
/**
|
||||
* Extracts the computed width/height and sets to min/max- attribute.
|
||||
*/
|
||||
this.call = function() {
|
||||
// extract current dimensions
|
||||
width = this.element.offsetWidth;
|
||||
height = this.element.offsetHeight;
|
||||
|
||||
attrValues = {};
|
||||
|
||||
for (key in this.options) {
|
||||
if (!this.options.hasOwnProperty(key)){
|
||||
continue;
|
||||
}
|
||||
option = this.options[key];
|
||||
|
||||
value = convertToPx(this.element, option.value);
|
||||
|
||||
actualValue = option.property == 'width' ? width : height;
|
||||
attrName = option.mode + '-' + option.property;
|
||||
attrValue = '';
|
||||
|
||||
if (option.mode == 'min' && actualValue >= value) {
|
||||
attrValue += option.value;
|
||||
}
|
||||
|
||||
if (option.mode == 'max' && actualValue <= value) {
|
||||
attrValue += option.value;
|
||||
}
|
||||
|
||||
if (!attrValues[attrName]) attrValues[attrName] = '';
|
||||
if (attrValue && -1 === (' '+attrValues[attrName]+' ').indexOf(' ' + attrValue + ' ')) {
|
||||
attrValues[attrName] += ' ' + attrValue;
|
||||
}
|
||||
}
|
||||
|
||||
for (var k in attributes) {
|
||||
if(!attributes.hasOwnProperty(k)) continue;
|
||||
|
||||
if (attrValues[attributes[k]]) {
|
||||
this.element.setAttribute(attributes[k], attrValues[attributes[k]].substr(1));
|
||||
} else {
|
||||
this.element.removeAttribute(attributes[k]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} element
|
||||
* @param {Object} options
|
||||
*/
|
||||
function setupElement(element, options) {
|
||||
if (element.elementQueriesSetupInformation) {
|
||||
element.elementQueriesSetupInformation.addOption(options);
|
||||
} else {
|
||||
element.elementQueriesSetupInformation = new SetupInformation(element);
|
||||
element.elementQueriesSetupInformation.addOption(options);
|
||||
element.elementQueriesSensor = new ResizeSensor(element, function() {
|
||||
element.elementQueriesSetupInformation.call();
|
||||
});
|
||||
}
|
||||
element.elementQueriesSetupInformation.call();
|
||||
|
||||
if (trackingActive && elements.indexOf(element) < 0) {
|
||||
elements.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} selector
|
||||
* @param {String} mode min|max
|
||||
* @param {String} property width|height
|
||||
* @param {String} value
|
||||
*/
|
||||
var allQueries = {};
|
||||
function queueQuery(selector, mode, property, value) {
|
||||
if (typeof(allQueries[mode]) == 'undefined') allQueries[mode] = {};
|
||||
if (typeof(allQueries[mode][property]) == 'undefined') allQueries[mode][property] = {};
|
||||
if (typeof(allQueries[mode][property][value]) == 'undefined') allQueries[mode][property][value] = selector;
|
||||
else allQueries[mode][property][value] += ','+selector;
|
||||
}
|
||||
|
||||
function getQuery() {
|
||||
var query;
|
||||
if (document.querySelectorAll) query = document.querySelectorAll.bind(document);
|
||||
if (!query && 'undefined' !== typeof $$) query = $$;
|
||||
if (!query && 'undefined' !== typeof jQuery) query = jQuery;
|
||||
|
||||
if (!query) {
|
||||
throw 'No document.querySelectorAll, jQuery or Mootools\'s $$ found.';
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the magic. Go through all collected rules (readRules()) and attach the resize-listener.
|
||||
*/
|
||||
function findElementQueriesElements() {
|
||||
var query = getQuery();
|
||||
|
||||
for (var mode in allQueries) if (allQueries.hasOwnProperty(mode)) {
|
||||
|
||||
for (var property in allQueries[mode]) if (allQueries[mode].hasOwnProperty(property)) {
|
||||
for (var value in allQueries[mode][property]) if (allQueries[mode][property].hasOwnProperty(value)) {
|
||||
var elements = query(allQueries[mode][property][value]);
|
||||
for (var i = 0, j = elements.length; i < j; i++) {
|
||||
setupElement(elements[i], {
|
||||
mode: mode,
|
||||
property: property,
|
||||
value: value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
*/
|
||||
function attachResponsiveImage(element) {
|
||||
var children = [];
|
||||
var rules = [];
|
||||
var sources = [];
|
||||
var defaultImageId = 0;
|
||||
var lastActiveImage = -1;
|
||||
var loadedImages = [];
|
||||
|
||||
for (var i in element.children) {
|
||||
if(!element.children.hasOwnProperty(i)) continue;
|
||||
|
||||
if (element.children[i].tagName && element.children[i].tagName.toLowerCase() === 'img') {
|
||||
children.push(element.children[i]);
|
||||
|
||||
var minWidth = element.children[i].getAttribute('min-width') || element.children[i].getAttribute('data-min-width');
|
||||
//var minHeight = element.children[i].getAttribute('min-height') || element.children[i].getAttribute('data-min-height');
|
||||
var src = element.children[i].getAttribute('data-src') || element.children[i].getAttribute('url');
|
||||
|
||||
sources.push(src);
|
||||
|
||||
var rule = {
|
||||
minWidth: minWidth
|
||||
};
|
||||
|
||||
rules.push(rule);
|
||||
|
||||
if (!minWidth) {
|
||||
defaultImageId = children.length - 1;
|
||||
element.children[i].style.display = 'block';
|
||||
} else {
|
||||
element.children[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastActiveImage = defaultImageId;
|
||||
|
||||
function check() {
|
||||
var imageToDisplay = false, i;
|
||||
|
||||
for (i in children){
|
||||
if(!children.hasOwnProperty(i)) continue;
|
||||
|
||||
if (rules[i].minWidth) {
|
||||
if (element.offsetWidth > rules[i].minWidth) {
|
||||
imageToDisplay = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!imageToDisplay) {
|
||||
//no rule matched, show default
|
||||
imageToDisplay = defaultImageId;
|
||||
}
|
||||
|
||||
if (lastActiveImage != imageToDisplay) {
|
||||
//image change
|
||||
|
||||
if (!loadedImages[imageToDisplay]){
|
||||
//image has not been loaded yet, we need to load the image first in memory to prevent flash of
|
||||
//no content
|
||||
|
||||
var image = new Image();
|
||||
image.onload = function() {
|
||||
children[imageToDisplay].src = sources[imageToDisplay];
|
||||
|
||||
children[lastActiveImage].style.display = 'none';
|
||||
children[imageToDisplay].style.display = 'block';
|
||||
|
||||
loadedImages[imageToDisplay] = true;
|
||||
|
||||
lastActiveImage = imageToDisplay;
|
||||
};
|
||||
|
||||
image.src = sources[imageToDisplay];
|
||||
} else {
|
||||
children[lastActiveImage].style.display = 'none';
|
||||
children[imageToDisplay].style.display = 'block';
|
||||
lastActiveImage = imageToDisplay;
|
||||
}
|
||||
} else {
|
||||
//make sure for initial check call the .src is set correctly
|
||||
children[imageToDisplay].src = sources[imageToDisplay];
|
||||
}
|
||||
}
|
||||
|
||||
element.resizeSensor = new ResizeSensor(element, check);
|
||||
check();
|
||||
|
||||
if (trackingActive) {
|
||||
elements.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
function findResponsiveImages(){
|
||||
var query = getQuery();
|
||||
|
||||
var elements = query('[data-responsive-image],[responsive-image]');
|
||||
for (var i = 0, j = elements.length; i < j; i++) {
|
||||
attachResponsiveImage(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var regex = /,?[\s\t]*([^,\n]*?)((?:\[[\s\t]*?(?:min|max)-(?:width|height)[\s\t]*?[~$\^]?=[\s\t]*?"[^"]*?"[\s\t]*?])+)([^,\n\s\{]*)/mgi;
|
||||
var attrRegex = /\[[\s\t]*?(min|max)-(width|height)[\s\t]*?[~$\^]?=[\s\t]*?"([^"]*?)"[\s\t]*?]/mgi;
|
||||
/**
|
||||
* @param {String} css
|
||||
*/
|
||||
function extractQuery(css) {
|
||||
var match;
|
||||
var smatch;
|
||||
css = css.replace(/'/g, '"');
|
||||
while (null !== (match = regex.exec(css))) {
|
||||
smatch = match[1] + match[3];
|
||||
attrs = match[2];
|
||||
|
||||
while (null !== (attrMatch = attrRegex.exec(attrs))) {
|
||||
queueQuery(smatch, attrMatch[1], attrMatch[2], attrMatch[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CssRule[]|String} rules
|
||||
*/
|
||||
function readRules(rules) {
|
||||
var selector = '';
|
||||
if (!rules) {
|
||||
return;
|
||||
}
|
||||
if ('string' === typeof rules) {
|
||||
rules = rules.toLowerCase();
|
||||
if (-1 !== rules.indexOf('min-width') || -1 !== rules.indexOf('max-width')) {
|
||||
extractQuery(rules);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0, j = rules.length; i < j; i++) {
|
||||
if (1 === rules[i].type) {
|
||||
selector = rules[i].selectorText || rules[i].cssText;
|
||||
if (-1 !== selector.indexOf('min-height') || -1 !== selector.indexOf('max-height')) {
|
||||
extractQuery(selector);
|
||||
}else if(-1 !== selector.indexOf('min-width') || -1 !== selector.indexOf('max-width')) {
|
||||
extractQuery(selector);
|
||||
}
|
||||
} else if (4 === rules[i].type) {
|
||||
readRules(rules[i].cssRules || rules[i].rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var defaultCssInjected = false;
|
||||
|
||||
/**
|
||||
* Searches all css rules and setups the event listener to all elements with element query rules..
|
||||
*
|
||||
* @param {Boolean} withTracking allows and requires you to use detach, since we store internally all used elements
|
||||
* (no garbage collection possible if you don not call .detach() first)
|
||||
*/
|
||||
this.init = function(withTracking) {
|
||||
trackingActive = typeof withTracking === 'undefined' ? false : withTracking;
|
||||
|
||||
for (var i = 0, j = document.styleSheets.length; i < j; i++) {
|
||||
try {
|
||||
readRules(document.styleSheets[i].cssRules || document.styleSheets[i].rules || document.styleSheets[i].cssText);
|
||||
} catch(e) {
|
||||
if (e.name !== 'SecurityError') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!defaultCssInjected) {
|
||||
var style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
style.innerHTML = '[responsive-image] > img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img { width: 100%;}';
|
||||
document.getElementsByTagName('head')[0].appendChild(style);
|
||||
defaultCssInjected = true;
|
||||
}
|
||||
|
||||
findElementQueriesElements();
|
||||
findResponsiveImages();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Boolean} withTracking allows and requires you to use detach, since we store internally all used elements
|
||||
* (no garbage collection possible if you don not call .detach() first)
|
||||
*/
|
||||
this.update = function(withTracking) {
|
||||
this.init(withTracking);
|
||||
};
|
||||
|
||||
this.detach = function() {
|
||||
if (!this.withTracking) {
|
||||
throw 'withTracking is not enabled. We can not detach elements since we don not store it.' +
|
||||
'Use ElementQueries.withTracking = true; before domready or call ElementQueryes.update(true).';
|
||||
}
|
||||
|
||||
var element;
|
||||
while (element = elements.pop()) {
|
||||
ElementQueries.detach(element);
|
||||
}
|
||||
|
||||
elements = [];
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Boolean} withTracking allows and requires you to use detach, since we store internally all used elements
|
||||
* (no garbage collection possible if you don not call .detach() first)
|
||||
*/
|
||||
ElementQueries.update = function(withTracking) {
|
||||
ElementQueries.instance.update(withTracking);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all sensor and elementquery information from the element.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
*/
|
||||
ElementQueries.detach = function(element) {
|
||||
if (element.elementQueriesSetupInformation) {
|
||||
//element queries
|
||||
element.elementQueriesSensor.detach();
|
||||
delete element.elementQueriesSetupInformation;
|
||||
delete element.elementQueriesSensor;
|
||||
|
||||
} else if (element.resizeSensor) {
|
||||
//responsive image
|
||||
|
||||
element.resizeSensor.detach();
|
||||
delete element.resizeSensor;
|
||||
} else {
|
||||
//console.log('detached already', element);
|
||||
}
|
||||
};
|
||||
|
||||
ElementQueries.withTracking = false;
|
||||
|
||||
ElementQueries.init = function() {
|
||||
if (!ElementQueries.instance) {
|
||||
ElementQueries.instance = new ElementQueries();
|
||||
}
|
||||
|
||||
ElementQueries.instance.init(ElementQueries.withTracking);
|
||||
};
|
||||
|
||||
var domLoaded = function (callback) {
|
||||
/* Internet Explorer */
|
||||
/*@cc_on
|
||||
@if (@_win32 || @_win64)
|
||||
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
|
||||
document.getElementById('ieScriptLoad').onreadystatechange = function() {
|
||||
if (this.readyState == 'complete') {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
@end @*/
|
||||
/* Mozilla, Chrome, Opera */
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener('DOMContentLoaded', callback, false);
|
||||
}
|
||||
/* Safari, iCab, Konqueror */
|
||||
else if (/KHTML|WebKit|iCab/i.test(navigator.userAgent)) {
|
||||
var DOMLoadTimer = setInterval(function () {
|
||||
if (/loaded|complete/i.test(document.readyState)) {
|
||||
callback();
|
||||
clearInterval(DOMLoadTimer);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
/* Other web browsers */
|
||||
else window.onload = callback;
|
||||
};
|
||||
|
||||
ElementQueries.listen = function() {
|
||||
domLoaded(ElementQueries.init);
|
||||
};
|
||||
|
||||
// make available to common module loader
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
module.exports = ElementQueries;
|
||||
}
|
||||
else {
|
||||
window.ElementQueries = ElementQueries;
|
||||
ElementQueries.listen();
|
||||
}
|
||||
|
||||
return ElementQueries;
|
||||
|
||||
}));
|
||||
227
public/js/resize/ResizeSensor.js
Normal file
227
public/js/resize/ResizeSensor.js
Normal file
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* Copyright Marc J. Schmidt. See the LICENSE file at the top-level
|
||||
* directory of this distribution and at
|
||||
* https://github.com/marcj/css-element-queries/blob/master/LICENSE.
|
||||
*/
|
||||
;
|
||||
(function (root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(factory);
|
||||
} else if (typeof exports === "object") {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
root.ResizeSensor = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
|
||||
//Make sure it does not throw in a SSR (Server Side Rendering) situation
|
||||
if (typeof window === "undefined") {
|
||||
return null;
|
||||
}
|
||||
// Only used for the dirty checking, so the event callback count is limted to max 1 call per fps per sensor.
|
||||
// In combination with the event based resize sensor this saves cpu time, because the sensor is too fast and
|
||||
// would generate too many unnecessary events.
|
||||
var requestAnimationFrame = window.requestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
function (fn) {
|
||||
return window.setTimeout(fn, 20);
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterate over each of the provided element(s).
|
||||
*
|
||||
* @param {HTMLElement|HTMLElement[]} elements
|
||||
* @param {Function} callback
|
||||
*/
|
||||
function forEachElement(elements, callback){
|
||||
var elementsType = Object.prototype.toString.call(elements);
|
||||
var isCollectionTyped = ('[object Array]' === elementsType
|
||||
|| ('[object NodeList]' === elementsType)
|
||||
|| ('[object HTMLCollection]' === elementsType)
|
||||
|| ('[object Object]' === elementsType)
|
||||
|| ('undefined' !== typeof jQuery && elements instanceof jQuery) //jquery
|
||||
|| ('undefined' !== typeof Elements && elements instanceof Elements) //mootools
|
||||
);
|
||||
var i = 0, j = elements.length;
|
||||
if (isCollectionTyped) {
|
||||
for (; i < j; i++) {
|
||||
callback(elements[i]);
|
||||
}
|
||||
} else {
|
||||
callback(elements);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for dimension change detection.
|
||||
*
|
||||
* @param {Element|Element[]|Elements|jQuery} element
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var ResizeSensor = function(element, callback) {
|
||||
/**
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function EventQueue() {
|
||||
var q = [];
|
||||
this.add = function(ev) {
|
||||
q.push(ev);
|
||||
};
|
||||
|
||||
var i, j;
|
||||
this.call = function() {
|
||||
for (i = 0, j = q.length; i < j; i++) {
|
||||
q[i].call();
|
||||
}
|
||||
};
|
||||
|
||||
this.remove = function(ev) {
|
||||
var newQueue = [];
|
||||
for(i = 0, j = q.length; i < j; i++) {
|
||||
if(q[i] !== ev) newQueue.push(q[i]);
|
||||
}
|
||||
q = newQueue;
|
||||
}
|
||||
|
||||
this.length = function() {
|
||||
return q.length;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} element
|
||||
* @param {String} prop
|
||||
* @returns {String|Number}
|
||||
*/
|
||||
function getComputedStyle(element, prop) {
|
||||
if (element.currentStyle) {
|
||||
return element.currentStyle[prop];
|
||||
} else if (window.getComputedStyle) {
|
||||
return window.getComputedStyle(element, null).getPropertyValue(prop);
|
||||
} else {
|
||||
return element.style[prop];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @param {Function} resized
|
||||
*/
|
||||
function attachResizeEvent(element, resized) {
|
||||
if (!element.resizedAttached) {
|
||||
element.resizedAttached = new EventQueue();
|
||||
element.resizedAttached.add(resized);
|
||||
} else if (element.resizedAttached) {
|
||||
element.resizedAttached.add(resized);
|
||||
return;
|
||||
}
|
||||
|
||||
element.resizeSensor = document.createElement('div');
|
||||
element.resizeSensor.className = 'resize-sensor';
|
||||
var style = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';
|
||||
var styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
|
||||
|
||||
element.resizeSensor.style.cssText = style;
|
||||
element.resizeSensor.innerHTML =
|
||||
'<div class="resize-sensor-expand" style="' + style + '">' +
|
||||
'<div style="' + styleChild + '"></div>' +
|
||||
'</div>' +
|
||||
'<div class="resize-sensor-shrink" style="' + style + '">' +
|
||||
'<div style="' + styleChild + ' width: 200%; height: 200%"></div>' +
|
||||
'</div>';
|
||||
element.appendChild(element.resizeSensor);
|
||||
|
||||
if (getComputedStyle(element, 'position') == 'static') {
|
||||
element.style.position = 'relative';
|
||||
}
|
||||
|
||||
var expand = element.resizeSensor.childNodes[0];
|
||||
var expandChild = expand.childNodes[0];
|
||||
var shrink = element.resizeSensor.childNodes[1];
|
||||
var dirty, rafId, newWidth, newHeight;
|
||||
var lastWidth = element.offsetWidth;
|
||||
var lastHeight = element.offsetHeight;
|
||||
|
||||
var reset = function() {
|
||||
expandChild.style.width = '100000px';
|
||||
expandChild.style.height = '100000px';
|
||||
|
||||
expand.scrollLeft = 100000;
|
||||
expand.scrollTop = 100000;
|
||||
|
||||
shrink.scrollLeft = 100000;
|
||||
shrink.scrollTop = 100000;
|
||||
};
|
||||
|
||||
reset();
|
||||
|
||||
var onResized = function() {
|
||||
rafId = 0;
|
||||
|
||||
if (!dirty) return;
|
||||
|
||||
lastWidth = newWidth;
|
||||
lastHeight = newHeight;
|
||||
|
||||
if (element.resizedAttached) {
|
||||
element.resizedAttached.call();
|
||||
}
|
||||
};
|
||||
|
||||
var onScroll = function() {
|
||||
newWidth = element.offsetWidth;
|
||||
newHeight = element.offsetHeight;
|
||||
dirty = newWidth != lastWidth || newHeight != lastHeight;
|
||||
|
||||
if (dirty && !rafId) {
|
||||
rafId = requestAnimationFrame(onResized);
|
||||
}
|
||||
|
||||
reset();
|
||||
};
|
||||
|
||||
var addEvent = function(el, name, cb) {
|
||||
if (el.attachEvent) {
|
||||
el.attachEvent('on' + name, cb);
|
||||
} else {
|
||||
el.addEventListener(name, cb);
|
||||
}
|
||||
};
|
||||
|
||||
addEvent(expand, 'scroll', onScroll);
|
||||
addEvent(shrink, 'scroll', onScroll);
|
||||
}
|
||||
|
||||
forEachElement(element, function(elem){
|
||||
attachResizeEvent(elem, callback);
|
||||
});
|
||||
|
||||
this.detach = function(ev) {
|
||||
ResizeSensor.detach(element, ev);
|
||||
};
|
||||
};
|
||||
|
||||
ResizeSensor.detach = function(element, ev) {
|
||||
forEachElement(element, function(elem){
|
||||
if(elem.resizedAttached && typeof ev == "function"){
|
||||
elem.resizedAttached.remove(ev);
|
||||
if(elem.resizedAttached.length()) return;
|
||||
}
|
||||
if (elem.resizeSensor) {
|
||||
if (elem.contains(elem.resizeSensor)) {
|
||||
elem.removeChild(elem.resizeSensor);
|
||||
}
|
||||
delete elem.resizeSensor;
|
||||
delete elem.resizedAttached;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return ResizeSensor;
|
||||
|
||||
}));
|
||||
@@ -71,9 +71,6 @@ var models = require("./models");
|
||||
//Routes
|
||||
require('./app/routes.js')(app, rootPath, passport, smtpTransport, models.sequelize); // load our routes and pass in our app and fully configured passport
|
||||
|
||||
//Setup initial database data.
|
||||
require('./app/initialData.js')(models.sequelize);
|
||||
|
||||
//Setup the brainstorm communications system.
|
||||
//require('./brainstorm.js')(server, models.sequelize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user