11import './scss/widgets.scss' ;
22import 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';
55import gql from 'graphql-tag' ;
66import Vue from 'vue' ;
77import VueI18n from 'vue-i18n'
88import _ from 'lodash' ;
99import VueGoogleCharts from 'vue-google-charts'
10- import $ from 'jquery'
10+ // import $ from 'jquery'
1111import _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 = {}){
143161export 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
269299export var lodash = _ ;
270- export var jquery = $ ;
271300export 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+
273308export 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+ }
0 commit comments