Skip to content

Commit acc676f

Browse files
committed
exclude jquery
1 parent 2544fba commit acc676f

7 files changed

Lines changed: 63 additions & 22 deletions

File tree

dist/widgets.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/widgetsGraphiql.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/widgetsJquery.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "widgets",
3-
"version": "1.2.6",
3+
"version": "1.2.7",
44
"description": "",
55
"main": "dist/widgets.js",
66
"directories": {

src/widgets-jquery.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import $ from 'jquery'
2+
export function loading(func){
3+
func($);
4+
}

src/widgets.js

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
import './scss/widgets.scss';
22
import ApolloClient from 'apollo-boost';
3-
import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
4-
import { InMemoryCache } from 'apollo-cache-inmemory';
3+
// import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
4+
// import { InMemoryCache } from 'apollo-cache-inmemory';
55
import gql from 'graphql-tag';
66
import Vue from 'vue';
77
import VueI18n from 'vue-i18n'
88
import _ from 'lodash';
99
import VueGoogleCharts from 'vue-google-charts'
10-
import $ from 'jquery'
10+
// import $ from 'jquery'
1111
import _n from 'numeral'
12+
import utils from './lib/utils'
13+
14+
// search shema
15+
// {
16+
// types: [
17+
// {
18+
// kind: 'UNION',
19+
// name: 'SearchResultItem',
20+
// possibleTypes: [
21+
// { name: 'Address' },
22+
// { name: 'Currency' },
23+
// { name: 'SmartContract' },
24+
// { name: 'TransactionHash' }
25+
// ],
26+
// },
27+
// ],
28+
// }
29+
1230

1331
// Запрос схемы с типами
1432
// __schema{
@@ -143,15 +161,15 @@ export function callbacks(cbs = {}){
143161
export function query(query, schema = undefined){
144162

145163
if (schema){
146-
let fragmentMatcher = new IntrospectionFragmentMatcher({
147-
introspectionQueryResultData: {
148-
__schema: schema,
149-
},
150-
});
151-
152-
let cache = new InMemoryCache({ fragmentMatcher });
153-
apollo.cache = cache;
154-
apollo = new ApolloClient({uri: props['url'], cache});
164+
// let fragmentMatcher = new IntrospectionFragmentMatcher({
165+
// introspectionQueryResultData: {
166+
// __schema: schema,
167+
// },
168+
// });
169+
//
170+
// let cache = new InMemoryCache({ fragmentMatcher });
171+
// apollo.cache = cache;
172+
// apollo = new ApolloClient({uri: props['url'], cache});
155173
} else {
156174
apollo = new ApolloClient({uri: props['url']});
157175
}
@@ -182,14 +200,26 @@ export function query(query, schema = undefined){
182200
it.variables = _.merge(variables, it.variables, p);
183201
it.original.variables == undefined ? it.original.variables = it.variables : '';
184202

203+
let intervals = {};
185204
_.each(it.components,function(component){
186-
let loading = $('<div style="margin: 10px;">' +
205+
let loading = '<div style="margin: 10px;">' +
187206
'<span>Loading...</span>' +
188207
'<div style="background-color: #eeeeee"><div style="width: 0%; height:4px; background-color: #007bff"></div></div>' +
189208
'<span style="font-size: 12px;float: left"">0</span><span style="font-size: 12px;float: right">100</span>' +
190-
'</div>');
191-
$(component.selector).html(loading);
192-
loading.find('div>div').animate({width: (Math.floor(Math.random() * 15) + 84)+"%"}, 4000);
209+
'</div>';
210+
_.each(utils.select(component.selector).elements, function(element){
211+
element.innerHTML = loading;
212+
let line = utils.select(component.selector+'>div>div>div').elements[0];
213+
let i = 1;
214+
intervals[component.selector] = setInterval(function(){
215+
if (i > Math.floor(Math.random() * 15) + 84){
216+
clearInterval(intervals[component.selector]);
217+
}
218+
line.style.width = i+'%';
219+
i = i + 1;
220+
}, 40);
221+
222+
});
193223
});
194224

195225
apollo
@@ -267,9 +297,14 @@ export function component(name, funcName, selector, query, path, options={},init
267297
}
268298

269299
export var lodash = _;
270-
export var jquery = $;
271300
export var numeral = _n;
272301

302+
export function jqueryLoading(func){
303+
utils.widgetsPluginLoader('widgetsJquery', currentScriptPath.join('/')+'/'+'widgetsJquery.js').then(loader => {
304+
widgetsJquery.loading(func);
305+
});
306+
}
307+
273308
export function table_trades(selector, query, path = 'trades', options ={}){
274309
let props = {tableOptions: {}, dataOptions: {}};
275310
props = _.merge(props, options);
@@ -316,4 +351,4 @@ export function template(selector, query, path = '', options ={}){
316351
let props = {excludeButtons: ['csv']};
317352
props = _.merge(props, options);
318353
return component('template_component','template', selector, query, path, props, options);
319-
}
354+
}

webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = function(paths){
88
return {
99
entry: {
1010
'widgets': './src/widgets.js',
11-
'widgetsGraphiql': './src/widgets-graphiql.js'
11+
'widgetsGraphiql': './src/widgets-graphiql.js',
12+
'widgetsJquery': './src/widgets-jquery.js'
1213
},
1314
output: {
1415
filename: '[name].js',

0 commit comments

Comments
 (0)