btxui 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/favicon.png +0 -0
  2. package/index.js +3289 -0
  3. package/index.js.gz +0 -0
  4. package/index.umd.cjs +1 -0
  5. package/package.json +11 -23
  6. package/README.md +0 -42
  7. package/app.vue +0 -162
  8. package/assets/css/_main.js +0 -73
  9. package/assets/css/btx.min.css +0 -1
  10. package/assets/css/btx.mob.min.css +0 -1
  11. package/assets/css/btx.pad.min.css +0 -1
  12. package/assets/css/btx.webapp.min.css +0 -1
  13. package/assets/css/custom_fonts/iconfont.css +0 -37
  14. package/assets/css/custom_fonts/iconfont.eot +0 -0
  15. package/assets/css/custom_fonts/iconfont.svg +0 -47
  16. package/assets/css/custom_fonts/iconfont.ttf +0 -0
  17. package/assets/css/custom_fonts/iconfont.woff +0 -0
  18. package/assets/css/custom_fonts/iconfont.woff2 +0 -0
  19. package/assets/css/res-l.css +0 -47
  20. package/assets/css/res-m.css +0 -47
  21. package/assets/css/res-s.css +0 -61
  22. package/assets/custom_fonts/iconfont.css +0 -37
  23. package/assets/custom_fonts/iconfont.eot +0 -0
  24. package/assets/custom_fonts/iconfont.svg +0 -47
  25. package/assets/custom_fonts/iconfont.ttf +0 -0
  26. package/assets/custom_fonts/iconfont.woff +0 -0
  27. package/assets/custom_fonts/iconfont.woff2 +0 -0
  28. package/assets/js/Btx.js +0 -196
  29. package/assets/js/Utils.js +0 -421
  30. package/assets/js/fastclick.js +0 -802
  31. package/assets/js/lazy.min.js +0 -2
  32. package/assets/js/touchwipe.js +0 -111
  33. package/assets/server.js +0 -8
  34. package/assets/start_site_code_str.js +0 -119
  35. package/cdn/css/btx.min.css +0 -1
  36. package/cdn/css/btx.min.css.map +0 -1
  37. package/cdn/fonts/iconfont.ttf +0 -0
  38. package/cdn/fonts/iconfont.woff +0 -0
  39. package/cdn/fonts/iconfont.woff2 +0 -0
  40. package/components/BTXUI/app/app-wid.vue +0 -182
  41. package/components/BTXUI/btn/btn-wid.vue +0 -128
  42. package/components/BTXUI/carousel/carousel-wid.vue +0 -138
  43. package/components/BTXUI/checkbox/checkbox-wid.vue +0 -72
  44. package/components/BTXUI/confirm/confirm-wid.vue +0 -279
  45. package/components/BTXUI/content/content-checkbox-wid.vue +0 -44
  46. package/components/BTXUI/content/content-node-wid.vue +0 -114
  47. package/components/BTXUI/content/content-tag-wid.vue +0 -25
  48. package/components/BTXUI/content/content-wid.vue +0 -254
  49. package/components/BTXUI/core/anis/ani-fail.vue +0 -46
  50. package/components/BTXUI/core/anis/ani-loading.vue +0 -32
  51. package/components/BTXUI/core/anis/ani-notic.vue +0 -47
  52. package/components/BTXUI/core/anis/ani-success.vue +0 -48
  53. package/components/BTXUI/core/b-drag.vue +0 -258
  54. package/components/BTXUI/core/b-grid.vue +0 -84
  55. package/components/BTXUI/core/b-hot.vue +0 -171
  56. package/components/BTXUI/core/b-icon.vue +0 -76
  57. package/components/BTXUI/core/b-img.vue +0 -84
  58. package/components/BTXUI/core/b-input.vue +0 -198
  59. package/components/BTXUI/core/b-list.vue +0 -276
  60. package/components/BTXUI/core/b-text/doc.ts +0 -9
  61. package/components/BTXUI/core/b-text/index.vue +0 -16
  62. package/components/BTXUI/core/b-textarea.vue +0 -58
  63. package/components/BTXUI/core/b-video.vue +0 -35
  64. package/components/BTXUI/core/b-view/doc.ts +0 -10
  65. package/components/BTXUI/core/b-view/index.vue +0 -20
  66. package/components/BTXUI/core/b-webview.vue +0 -20
  67. package/components/BTXUI/core/lib/ChapterLink.js +0 -49
  68. package/components/BTXUI/core/lib/Search.vue +0 -60
  69. package/components/BTXUI/core/styles/doc.ts +0 -55
  70. package/components/BTXUI/core/styles/index.vue +0 -98
  71. package/components/BTXUI/core/styles/prestyles.ts +0 -471
  72. package/components/BTXUI/core/styles/theme.ts +0 -29
  73. package/components/BTXUI/drawer/drawer-wid.vue +0 -165
  74. package/components/BTXUI/drawer/title-tag-wid.vue +0 -114
  75. package/components/BTXUI/form/form-select-wid.vue +0 -57
  76. package/components/BTXUI/form/form-wid.vue +0 -324
  77. package/components/BTXUI/formPannel/form-pannel-wid.vue +0 -133
  78. package/components/BTXUI/imgsUpload/imgs-upload-wid.vue +0 -149
  79. package/components/BTXUI/index.js +0 -83
  80. package/components/BTXUI/pageFlip/page-flip-wid.vue +0 -206
  81. package/components/BTXUI/pannel/pannel-wid.vue +0 -167
  82. package/components/BTXUI/range/range-wid.vue +0 -134
  83. package/components/BTXUI/search/search-wid.vue +0 -80
  84. package/components/BTXUI/select/select-wid.vue +0 -186
  85. package/components/BTXUI/slider/slider-wid.vue +0 -444
  86. package/components/BTXUI/tab/tab-wid.vue +0 -109
  87. package/components/BTXUI/table/table-wid.vue +0 -324
  88. package/components/BTXUI/tag/tag-wid.vue +0 -183
  89. package/components/BTXUI/tags/tags-wid.vue +0 -121
  90. package/components/BTXUI/tooltip/tooltip-wid.vue +0 -146
  91. package/components/BTXUI/upload/upload-wid.vue +0 -215
  92. package/components/BTXUI/waterfall/waterfall-wid.vue +0 -166
  93. package/components/header-info.vue +0 -167
  94. package/composables/@types.ts +0 -4
  95. package/composables/api.ts +0 -18
  96. package/env.d.ts +0 -5
  97. package/main.js +0 -16
  98. package/nuxt.config.ts +0 -51
  99. package/pages/article.vue +0 -16
  100. package/pages/download.vue +0 -50
  101. package/pages/example/app_wid/app/data_demo.vue +0 -9
  102. package/pages/example/app_wid/app/download_demo.vue +0 -9
  103. package/pages/example/app_wid/app/list_demo.vue +0 -11
  104. package/pages/example/app_wid/app/system_demo.vue +0 -9
  105. package/pages/example/app_wid/app_wid_demo.vue +0 -198
  106. package/pages/example/app_wid/btn_wid_demo.vue +0 -179
  107. package/pages/example/app_wid/carousel_wid_demo.vue +0 -152
  108. package/pages/example/app_wid/checkbox_wid_demo.vue +0 -65
  109. package/pages/example/app_wid/confirm_wid_demo.vue +0 -197
  110. package/pages/example/app_wid/content_wid_demo.vue +0 -369
  111. package/pages/example/app_wid/drawer_wid_demo.vue +0 -155
  112. package/pages/example/app_wid/form_pannel_wid_demo.vue +0 -338
  113. package/pages/example/app_wid/form_wid_demo.vue +0 -550
  114. package/pages/example/app_wid/imgs_upload_wid_demo.vue +0 -159
  115. package/pages/example/app_wid/index.js +0 -158
  116. package/pages/example/app_wid/page_flip_wid_demo.vue +0 -99
  117. package/pages/example/app_wid/pannel_wid_demo.vue +0 -177
  118. package/pages/example/app_wid/range_wid_demo.vue +0 -101
  119. package/pages/example/app_wid/search_wid_demo.vue +0 -75
  120. package/pages/example/app_wid/select_wid_demo.vue +0 -217
  121. package/pages/example/app_wid/slider_wid_demo.vue +0 -143
  122. package/pages/example/app_wid/tab_wid_demo.vue +0 -170
  123. package/pages/example/app_wid/table_wid_demo.vue +0 -377
  124. package/pages/example/app_wid/tag_wid_demo.vue +0 -133
  125. package/pages/example/app_wid/tags_wid_demo.vue +0 -143
  126. package/pages/example/app_wid/tooltip_wid_demo.vue +0 -117
  127. package/pages/example/app_wid/upload_wid_demo.vue +0 -123
  128. package/pages/example/base_wid/b_drag_demo.vue +0 -159
  129. package/pages/example/base_wid/b_grid_demo.vue +0 -225
  130. package/pages/example/base_wid/b_hot_demo.vue +0 -135
  131. package/pages/example/base_wid/b_icon_demo.vue +0 -80
  132. package/pages/example/base_wid/b_img_demo.vue +0 -95
  133. package/pages/example/base_wid/b_input_demo.vue +0 -171
  134. package/pages/example/base_wid/b_list_demo.vue +0 -241
  135. package/pages/example/base_wid/b_style_demo.vue +0 -928
  136. package/pages/example/base_wid/b_text_demo.vue +0 -36
  137. package/pages/example/base_wid/b_textarea_demo.vue +0 -64
  138. package/pages/example/base_wid/b_video_demo.vue +0 -42
  139. package/pages/example/base_wid/b_view_demo.vue +0 -36
  140. package/pages/example/base_wid/index.js +0 -76
  141. package/pages/example/content.js +0 -49
  142. package/pages/example/global_style/animation.vue +0 -197
  143. package/pages/example/global_style/color.vue +0 -134
  144. package/pages/example/global_style/decoration.vue +0 -546
  145. package/pages/example/global_style/icon.vue +0 -345
  146. package/pages/example/global_style/index.js +0 -52
  147. package/pages/example/global_style/layout.vue +0 -846
  148. package/pages/example/global_style/special.vue +0 -37
  149. package/pages/example/global_style/table.vue +0 -298
  150. package/pages/example/global_style/text.vue +0 -159
  151. package/pages/index.vue +0 -43
  152. package/pages/level_widget.vue +0 -11
  153. package/pages/start.vue +0 -200
  154. package/plugins/index.ts +0 -2
  155. package/public/favicon.gif +0 -0
  156. package/public/fonts/iconfont.ttf +0 -0
  157. package/public/fonts/iconfont.woff +0 -0
  158. package/public/fonts/iconfont.woff2 +0 -0
  159. package/public/img/banner.jpg +0 -0
  160. package/public/img/banner2.jpg +0 -0
  161. package/public/img/bg_pattern.png +0 -0
  162. package/public/img/btx.jpg +0 -0
  163. package/public/img/btx_ui.jpg +0 -0
  164. package/public/img/dir.png +0 -0
  165. package/public/img/f.png +0 -0
  166. package/public/img/head.jpg +0 -0
  167. package/public/img/head2.jpg +0 -0
  168. package/public/img/home_ico.png +0 -0
  169. package/public/img/icons.svg +0 -164
  170. package/public/img/mechanism/b-style.png +0 -0
  171. package/public/img/mechanism/slider-wid.png +0 -0
  172. package/public/img/mechanism/upload-wid.png +0 -0
  173. package/public/img/transform_origin.png +0 -0
  174. package/sass/animation.scss +0 -400
  175. package/sass/btx.mob.scss +0 -10
  176. package/sass/btx.pad.scss +0 -3
  177. package/sass/btx.scss +0 -22
  178. package/sass/btx.webapp.scss +0 -22
  179. package/sass/colors.scss +0 -65
  180. package/sass/decoration.scss +0 -220
  181. package/sass/flex.scss +0 -29
  182. package/sass/icons.scss +0 -100
  183. package/sass/layout.scss +0 -88
  184. package/sass/reset.scss +0 -111
  185. package/sass/response/flex_mixin.scss +0 -91
  186. package/sass/response/layout_mixin.scss +0 -227
  187. package/sass/response/main.scss +0 -59
  188. package/sass/response/text_mixin.scss +0 -65
  189. package/sass/scroll.scss +0 -100
  190. package/sass/special.scss +0 -13
  191. package/sass/table.scss +0 -103
  192. package/sass/text.scss +0 -86
  193. package/sass/webpack.config.js +0 -31
  194. package/tsconfig.json +0 -4
package/assets/js/Btx.js DELETED
@@ -1,196 +0,0 @@
1
- <!--19-09-26-->
2
- class Btx{
3
- constructor(){
4
- document.body.addEventListener('touchstart', function(){});//保证ios下:active效果
5
-
6
- /*数组去重追加*/
7
- Array.prototype.unique_push = (ele)=>{
8
- if(this.indexOf(ele) === -1) this.push(ele);
9
- }
10
-
11
- }
12
-
13
- /*-------------------------------dom 操作-------------------------------*/
14
-
15
- //获取 dom 元素
16
- $(selector, all){
17
- return document["querySelector" + (all? "all": "")](selector);
18
- }
19
-
20
- //移除 dom 元素
21
- remove($dom){
22
- $dom.parentNode.removeChild($dom);
23
- }
24
-
25
- /*数据转换(通常用于前后端分离数据获取及转换)*/
26
- data_convert(data, convert){
27
- let return_arr = [];
28
- data.forEach( (el, index) => {
29
- let _convert = {};
30
- for(let k in convert){
31
- let v = convert[k];
32
- if(typeof v == "function"){//函数处理
33
- _convert[k] = v(el);
34
- }else if(v == ""){//空值
35
- _convert[k] = "";
36
- }else{//直接量
37
- _convert[k] = el[v == "1"?k:v];
38
- }
39
- }
40
- return_arr[index] = _convert;
41
- })
42
- return return_arr;
43
- }
44
-
45
- /*按钮选中*/
46
- select(select, $btn, cb){
47
- if(this.has_class($btn, select)){
48
- let $before_act = $btn.parentNode.querySelector(".act");
49
-
50
- if($before_act) $before_act.className = $before_act.className.replace("act", "");
51
- $btn.className = ($btn.className += " act");//依赖.act样式
52
- cb && cb();//执行回调
53
- }
54
- }
55
-
56
- /*集成插件*/
57
- plugin(plugin_name, dom){
58
- let plugin;
59
- //import "./plugin/Slider.js";
60
- eval("plugin = new " + plugin_name + "()")
61
- console.log(plugin);
62
- return plugin;
63
- }
64
-
65
- /*-------------------------------工具方法-------------------------------*/
66
-
67
- //json 数据转换
68
- /*
69
- 支持:
70
- * 属性替换;
71
- * 属性值重置;
72
- * 属性值清空;
73
- * 属性值回调函数操作;
74
- (注:对象层级无法被修改,但可移除)
75
- * 递归修改;
76
- * 属性移除;
77
- * 属性追加(在指定属性内或根节点,追加一个或多个属性);
78
- (注:属性追加执行于属性修改之后)
79
- */
80
- json_convert(inp, mod_rule, append_rule, scope){
81
- let new_data = {},
82
- new_pro,
83
- cur_val,
84
- _pro,
85
- _val,
86
- skip;
87
- for(let pro in inp){
88
- new_pro = mod_rule[pro];
89
- cur_val = inp[pro];
90
-
91
- //修改属性名及属性值
92
- if(new_pro){//有修改
93
- if(
94
- !new_pro._scope_ || //全层级修改
95
- new_pro._scope_._ROOT_ && !scope || //根节点层级修改
96
- new_pro._scope_[scope] //指定节点层级修改
97
- ){
98
- if(new_pro._scope_) new_pro = new_pro._scope_[scope] || new_pro._scope_._ROOT_;
99
- skip = new_pro.skip || false;
100
- if(skip === false){
101
-
102
- //设置新属性名
103
- if(new_pro.pro_name instanceof Function){
104
- _pro = new_pro.pro_name(inp) || pro;
105
- }else{
106
- _pro = new_pro.pro_name || pro;
107
- }
108
-
109
- //设置新属性值
110
- if(new_pro.pro_val == "" || new_pro.pro_val == 0){
111
- _val = new_pro.pro_val;
112
- }else if(new_pro.pro_val instanceof Function){
113
- _val = new_pro.pro_val(cur_val, inp) || "";
114
- }else{
115
- _val = new_pro.pro_val || cur_val;
116
- }
117
-
118
- }
119
- }else{//无修改
120
- skip = false;
121
- _pro = pro;
122
- _val = cur_val;
123
- }
124
- }else{ //无修改
125
- skip = false;
126
- _pro = pro;
127
- _val = cur_val;
128
- }
129
-
130
- if(skip === false){
131
- if(Array.isArray(_val)){//数组元素递归操作
132
- _val.forEach(function(val, i){
133
- if(typeof(val) === "object"){
134
- cur_val[i] = mod_json_data_format(val, mod_rule, append_rule, _pro);
135
- }
136
- })
137
- new_data[_pro] = _val;
138
- }else if(typeof(cur_val) === "object"){//对象层级递归操作
139
- new_data[_pro] = mod_json_data_format(cur_val, mod_rule, append_rule, _pro);
140
- }else{
141
- new_data[_pro] = _val;
142
- }
143
- }
144
- }
145
-
146
- //属性追加
147
- if(append_rule){
148
- if(append_rule instanceof Function){//基于节点自定义追加
149
- let append_data = append_rule(inp) || {};
150
- new_data = {...new_data, ...append_data}
151
- }else if(!scope){//根节点属性追加
152
- new_data = {...new_data, ...append_rule};
153
- }
154
- }
155
-
156
- return new_data;
157
- }
158
-
159
- /*按顺序遍历对象*/
160
- for_in(obj, callback, order){
161
- let ordered = [];
162
- order = order || ["0","1","2","3","4","5","6","7","8","9",
163
- "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
164
- "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
165
- for(let word of order){
166
- if(obj[word]) ordered.push(obj[word]);
167
- }
168
- for(let data of ordered){
169
- callback(data);
170
- }
171
- }
172
-
173
- /*中文转码unicode*/
174
- zh_convert_to_unicode(str){
175
- let res = [];
176
- for ( var i=0; i<str.length; i++ ) {
177
- res[i] = ( "00" + str.charCodeAt(i).toString(16) ).slice(-4);
178
- }
179
- return "\\u" + res.join("\\u");
180
- }
181
-
182
- /*判断dom对象是否具有class类*/
183
- has_class($dom, class_name){
184
- return $dom.className.split(" ").indexOf(class_name) === -1?false:true;
185
- }
186
-
187
- /*转换html为普通text*/
188
- convert_html_to_text(html){
189
- let $doc = document.createElement("div");
190
- $doc.innerHTML = html;
191
- return $doc.innerText || $doc.textContent;
192
- }
193
-
194
- }
195
-
196
- window.Btx = Btx;
@@ -1,421 +0,0 @@
1
- //基本常用函数库
2
-
3
- var BTXUtils = {
4
- "str":{}
5
- }
6
-
7
- /*
8
- * 默认支持追加前导0,也可以追加其它字符,追加数目依据:limit长度 - 原字符长度;
9
- * 若追加数目计算为0或负数,则直接返回原字符串str;
10
- * padchar限制为单个字符,否则同样以0代替;
11
- */
12
- BTXUtils.pad_zero = function(str, limit, padchar){//追加前导零或其它字符
13
- str = String(str);
14
- padchar = padchar || 0;
15
- padchar = String(padchar);
16
- padchar = padchar.length == 1?padchar:"0";
17
- var pad_len = limit - str.length, _padchar="";
18
- if(pad_len <= 0) return str;
19
- for(var i=0; i<pad_len; i++)
20
- {
21
- _padchar += padchar;
22
- }
23
- return _padchar + str;
24
- }
25
-
26
- BTXUtils.hex2rgb = function(colour){//将16进制颜色值转换为rgb颜色值
27
- var r, g, b;
28
- if(colour[0] == '#') {
29
- colour = colour.substr(1);
30
- }
31
- if(colour.length == 6) {
32
- r = colour[0] + colour[1];
33
- g = colour[2] + colour[3];
34
- b = colour[4] + colour[5];
35
- }
36
- else if (colour.length == 3) {
37
- r = colour[0] + colour[0];
38
- g = colour[1] + colour[1];
39
- b = colour[2] + colour[2];
40
- }
41
- else {
42
- return false;
43
- }
44
- r = parseInt(r, 16);
45
- g = parseInt(g, 16);
46
- b = parseInt(b, 16);
47
- return {'red':r, 'green':g, 'blue':b};
48
- }
49
-
50
- /*----------------------------常用工具函数-----------------------------*/
51
-
52
- //将两个数组合并为对象,其中一个数组元素作为对象键值,另一个数组元素作为对象键名
53
- function array_combine(arr1,arr2){
54
- var obj = {};
55
- var len;
56
- if(arr1 instanceof Array && arr2 instanceof Array){//两个数组参数都必须为数组
57
- len = Math.min(arr1.length,arr2.length);
58
- for(var i =0;i<len;i++){
59
- obj[arr1[i]] = arr2[i];
60
- }
61
- return obj;
62
- }
63
- return null;
64
- }
65
-
66
- //判断数组中是否有重复元素
67
- function array_repeat(arr){
68
- for(var i=0; i<arr.length; i++){
69
- for(var j=i+1; j<arr.length; j++){
70
- if(arr[i] && arr[j] && arr[i] == arr[j]) return true;//元素值需有效
71
- }
72
- }
73
- return false;
74
- }
75
-
76
- //字符串替换
77
- /*
78
- * 支持多字符替换,基于替换映射表
79
- */
80
- function str_replace(str, replace_base_table){
81
- var _return_str = "";
82
- for(var i= 0, tmp_str_arr = str.split(""); i<tmp_str_arr.length; i++){
83
- if(tmp_str_arr[i] in replace_base_table){
84
- _return_str += replace_base_table[tmp_str_arr[i]];
85
- }else{
86
- _return_str += tmp_str_arr[i];
87
- }
88
- }
89
- return _return_str;
90
- }
91
-
92
- /*----------------------------------------------------------------------------------------------------------------*/
93
-
94
- /*
95
- * 数字系列拓展函数
96
- */
97
-
98
- //函数有效化执行
99
- /*
100
- * [number number]:数值
101
- * [number len]:小数点保留位数
102
- * [boolean round]:整数数值是否启用小数部分隐藏
103
- */
104
- function number_fixed(number, len, round){
105
- if(typeof(number) == "number"){
106
- number = number.toFixed(len);
107
- }
108
- if(round && parseInt(number.split(".")[1])==0){//整数值不显示小数部分
109
- number = Math.round(number);
110
- }
111
- return number;
112
- }
113
-
114
- //随机生成指定位数数字
115
- /*
116
- * [number n]: 位数
117
- */
118
- function rand_number(n){
119
- var Num="";
120
- for(var i=0;i<n;i++){
121
- Num+=Math.floor(Math.random()*10);
122
- }
123
- return Num;
124
- }
125
-
126
- //----------------------------字符串扩展函数-----------------------------
127
-
128
- //字符串首字母小写
129
- String.prototype.lower_c = function(){
130
- return this.replace(this[0], this[0].toLowerCase());
131
- }
132
-
133
-
134
- //字符串首字母大写
135
- String.prototype.upper_c = function(){
136
- return this.replace(this[0], this[0].toUpperCase());
137
- }
138
-
139
-
140
- //反转字符串
141
- String.prototype.reverse = function(){
142
- return this.split("").reverse().join("");
143
- }
144
-
145
-
146
- /*
147
- * 字符串左侧空白截除
148
- * [string slice]: 截取移除字符串
149
- */
150
- String.prototype.ltrim = function(slice){
151
- var str = this.replace(/^\s+/, "");
152
-
153
- if(slice && str.search(slice.replace("[", "\\[").replace("$", "\\$").replace("(", "\\(")) == 0){
154
- var strlen = slice.length;
155
- str = str.substr(strlen);
156
- }
157
- return str;
158
- }
159
-
160
-
161
- //字符串右侧空白截除
162
- String.prototype.rtrim = function(slice){
163
- var str = this.replace(/\s+$/, ""),
164
- rstr = str.reverse();
165
-
166
- if(slice && rstr.search(slice.reverse().replace("[", "\\[").replace(")", "\\)")) == 0){
167
- var strlen = slice.length;
168
-
169
- str = rstr.substr(strlen).reverse();
170
- }
171
- return str;
172
- }
173
-
174
-
175
- //字符串两侧空白截除
176
- String.prototype.trim = function(slice){
177
- return (this.ltrim(slice)).rtrim(slice);
178
- }
179
-
180
-
181
- //字符串首字母大写
182
- String.prototype.capitalize = function(){
183
- return this[0].toUpperCase() + this.substr(1);
184
- }
185
-
186
- //----------------------------数组扩展函数-----------------------------
187
-
188
- //获取数组元素中的最大值
189
- Array.prototype.max = function(){
190
- this.sort(function(a, b){
191
- return b - a
192
- });
193
- return this[0];
194
- }
195
-
196
-
197
- //获取数组元素中的最小值
198
- Array.prototype.min = function(){
199
- this.sort(function(a, b){
200
- return a - b
201
- });
202
- return this[0];
203
- }
204
-
205
-
206
- //获取最后一个数组元素值
207
- Array.prototype.end = function(){
208
- return this[this.length-1];
209
- }
210
-
211
-
212
- //判断数组是否包含指定数据
213
- /*
214
- * 【使用】:
215
- * 1. 支持严格比较(数据类型匹配)
216
- * */
217
- Array.prototype.in_array = function(d, strict){
218
- var i;
219
-
220
- if(i = this.indexOf(d) != -1){
221
- return strict?( this[i] === d?true:false ):true;
222
- }else{
223
- return false;
224
- }
225
- }
226
-
227
- //----------------------------主执行-----------------------------
228
-
229
- var e_lib = {//兼容性事件库
230
- "animation": window.Modernizr.prefixed("animation").lower_c(),
231
- "transition": window.Modernizr.prefixed("transition").lower_c(),
232
- "down": ("touchstart" in document? "touchstart": "mousedown"),
233
- "up": ("ontouchend" in document? "touchend": "mouseup"),
234
- "click":"click"
235
- };
236
-
237
- /*----------------------------工具函数-----------------------------*/
238
-
239
- //获取视口高度
240
- function view_height(){
241
- return document.documentElement.clientHeight || document.body.clientHeight || window.innerHeight;
242
- }
243
-
244
-
245
- //居中视口
246
- function center($dom){
247
- var view_h = this.view_height(),
248
- view_w = document.documentElement.clientWidth || document.body.clientWidth || window.innerWidth,
249
- dom = $dom[0];
250
-
251
- $dom.css({"top": (view_h - dom.clientHeight)*.5, "left": (view_w - dom.clientWidth)*.5});
252
- return $dom;
253
- }
254
-
255
-
256
- //报错抛出
257
- function error(msg){
258
- throw new Error(msg);
259
- }
260
-
261
-
262
- //快速console.log
263
- function c(str){ console.log(str) }
264
-
265
-
266
- //快速console.dir
267
- function dir(str){ console.dir(str) }
268
-
269
-
270
- //适配h5兼容性事件
271
- /*
272
- * String ev:事件名前缀
273
- * String name:事件名后缀
274
- */
275
- function e(ev, name){
276
- if(arguments.length == 2){//含前缀判断
277
- if(!(ev+name in e_lib)) e_lib[ev+name] = e_lib[ev] + (e_lib[ev].search(ev) != 0?name.upper_c:name);
278
- return e_lib[ev+name];
279
- }else{//响应式事件判断(基于鼠标交互/触屏交互)
280
- return e_lib[ev];
281
- }
282
- }
283
-
284
-
285
- //字节转换
286
- function to_bit(v){
287
- var d = v.match(/[\d\.]+/)[0],
288
- unit = v.split(d)[1],
289
- b = 1;
290
-
291
- switch(unit.toLowerCase()){
292
- case "kb": b = 1000;
293
- break;
294
- case "m": b = 1000000;
295
- break;
296
- case "g": b = 1000000000;
297
- break;
298
- }
299
- return d * b;
300
- }
301
-
302
-
303
- //函数有效化执行
304
- /*
305
- * function fn: 自定义函数
306
- * mixed arg: 自定义函数传参,可为任意类型
307
- * object call: this指针绑定对象
308
- * int delay: 延迟时间,单位毫秒
309
- */
310
- function exefn(fn, arg, call, delay){
311
- var exe = function(){ call?fn.call(call, arg || null):fn(arg || null) }
312
- if(fn instanceof Function){
313
- if(delay){
314
- var t = setTimeout(function(){
315
- clearTimeout(t);
316
- exe();
317
- }, delay);
318
- }else{
319
- exe();
320
- }
321
- }else{
322
- console.error("fn si not a function!");
323
- }
324
- }
325
-
326
- //判断对象是否为dom对象或jquery封装的dom对象
327
- function is_dom(ele){
328
- return ele && ((ele.jquery && ele[0]) || ele.nodeType == 1)?true:false;
329
- }
330
-
331
- //获取手机屏方向
332
- function viewport_orientation(){
333
- return viewport_height() > document.body.clientWidth?"v":"h";
334
- }
335
-
336
- //判断手机屏方向
337
- function viewport_orientation_judge(dir){
338
- return dir == viewport_orientation()?true:false;
339
- }
340
-
341
- //获取路径目录
342
- function basename(url){
343
- var tmp_arr = url.split("/");
344
- tmp_arr.pop();
345
- return tmp_arr.join("/")+"/";
346
- }
347
-
348
- /*css类处理*/
349
-
350
- //模糊提取对象指定css类
351
- /*
352
- * [mixed ele]: 操作对象或选择器
353
- * [class_str]: 见:regexp_class()
354
- * [pos]: 见:regexp_class()
355
- * [string return]
356
- */
357
- function match_class(ele, class_str, pos){
358
- ele = _jquery(ele);
359
- if(ele){
360
- return (ele.tem_reg = regexp_class(class_str, pos).exec(ele.attr("class")))?ele.tem_reg[0]:"";
361
- }
362
- }
363
-
364
- //获取对象css类匹配正则
365
- /*
366
- * [string class_str]: css类名片段
367
- * [string<"after", "before", null> pos]: 匹配位置
368
- * [Regexp return]
369
- */
370
- function regexp_class(class_str, pos){
371
- if(pos == "after"){//尾匹配
372
- return RegExp("\\b"+class_str+"\\w+\\b");
373
- }else if(pos == "before"){//头匹配
374
- return RegExp("\\b\\w+"+class_str+"\\b");
375
- }else{//身匹配
376
- return RegExp("\\b\\w+"+class_str+"\\w+\\b");
377
- }
378
- }
379
-
380
- //取消图片缓存
381
- /*
382
- * string img: 图片元素
383
- * string src: 图片src
384
- */
385
- function cancel_img_cache(img, src){
386
- img = _jquery(img);
387
- img.attr("src", src+"?random="+Math.random()*1000);
388
- img.next().before(img);
389
- }
390
-
391
- //格式化时间
392
- /*
393
- * [string format_str]: 时间格式
394
- * [number timestamp]: 时间戳
395
- * [string return]
396
- * 支持: php生成10位时间戳自动转换
397
- */
398
- function date(format_str, timestamp){
399
- var fTime, fStr = 'ymdhis';
400
- if(!format_str) format_str = "y-m-d h:i:s";
401
- fTime = timestamp?new Date(timestamp.length == 10?timestamp*1000:timestamp):new Date();
402
- var format = function(v){//时间格式统一为2位,以保证格式整洁
403
- return v.length == 1?"0"+v:v;
404
- }
405
- var formatArr = [
406
- fTime.getFullYear().toString().substr(2),//年份显示后2位
407
- format((fTime.getMonth()+1).toString()),
408
- format(fTime.getDate().toString()),
409
- format(fTime.getHours().toString()),
410
- format(fTime.getMinutes().toString()),
411
- format(fTime.getSeconds().toString())
412
- ]
413
- for(var i=0; i<formatArr.length; i++){
414
- format_str = format_str.replace(fStr.charAt(i), formatArr[i]);
415
- }
416
- return format_str;
417
- }
418
-
419
-
420
-
421
-