1 2/* Settings 3------------------------------------------------------------------------*/ 4 5// jQueryObjects 6var $doc = $(document), 7 $w = $(window), 8 $html = $('html'), 9 $body, 10 $page, 11 $changeImg; 12 13// commonSettings 14var abi = { 15 bp_tab : 991, 16 bp_sp : 767, 17 pc : '', 18 tab : '', 19 sp : '', 20 pcView : '', 21 tabView : '', 22 spView : '', 23 finish : '', 24 deviceWidth : '', 25 deviceHeight : '', 26 sT : '', 27 ie9 : ($html.hasClass('ie9')) ? true : false, 28 ie8 : ($html.hasClass('ie8')) ? true : false, 29 ua_mouse : ($html.hasClass('mouse')) ? true : false, 30 ua_touch : ($html.hasClass('touch')) ? true : false, 31 ua_phone : ($html.hasClass('phone')) ? true : false 32} 33 34 35/* Functions & Plugins 36------------------------------------------------------------------------*/ 37 38// rwdFunctions 39var rwdFunctions = { 40 // checkValue 41 checkValue : function(){ 42 abi.deviceWidth = (abi.ie8) ? $w.width() : window.innerWidth, 43 abi.deviceHeight= $w.height(), 44 abi.pc = (abi.ie8 || abi.deviceWidth > abi.bp_tab) ? true : false, 45 abi.tab = (!abi.ie8 && abi.deviceWidth <= abi.bp_tab && abi.deviceWidth > abi.bp_sp) ? true : false, 46 abi.sp = (!abi.ie8 && abi.deviceWidth <= abi.bp_sp) ? true : false; 47 }, 48 // fooLoad 49 fooLoad : function($o){ 50 $o.each(function(){ $(this).attr('src', $(this).data('img')); }); 51 }, 52 // loadImg 53 loadImg : function(){ 54 abi.finish = (abi.pcView && abi.tabView && abi.spView) ? true : false; 55 if(!abi.ie8 && !abi.finish){ 56 if(abi.pc || abi.tab){ 57 if(!abi.pcView || !abi.tabView){ 58 rwdFunctions.fooLoad($('img.load_pc-tab')); 59 } 60 if(abi.pc && !abi.pcView){ 61 rwdFunctions.fooLoad($('img.load_pc')); 62 abi.pcView = true; 63 } 64 if(abi.tab && !abi.tabView){ 65 rwdFunctions.fooLoad($('img.load_tab-sp')); 66 abi.tabView = true; 67 } 68 }else if(!abi.spView){ 69 rwdFunctions.fooLoad($('img.load_sp,img.load_tab-sp')); 70 abi.spView = true; 71 } 72 }else if(!abi.pcView){ 73 abi.pcView = true; 74 } 75 }, 76 // changeImg 77 changeImg : function(){ 78 if(!abi.ie8){ 79 for(var i = 0; i <= $changeImg.length - 1; i++){ 80 if($changeImg.eq(i).is('.custom')){ 81 82 if(abi.deviceWidth > $changeImg.eq(i).data('custom')) $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img')); 83 else $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img').replace('-before', '-after')); 84 85 }else if(!$changeImg.eq(i).is('.tab,.all')) { 86 87 if(!abi.sp) $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img')); 88 else $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img').replace('-pc', '-sp')); 89 90 }else if($changeImg.eq(i).is('.tab')) { 91 92 if(abi.pc) $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img')); 93 else $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img').replace('-pc', '-tab')); 94 95 }else if($changeImg.eq(i).is('.all')) { 96 97 if(abi.pc) $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img')); 98 else if(abi.tab) $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img').replace('-pc', '-tab')); 99 else if(abi.sp) $changeImg.eq(i).attr('src', $changeImg.eq(i).data('img').replace('-pc', '-sp')); 100 101 } 102 } 103 } 104 }, 105 // adjustFsz 106// adjustFsz : function(){ 107// if(abi.sp){ 108// if(abi.deviceHeight > abi.deviceWidth){ 109// p = abi.deviceWidth / 3.2; 110// $page.css('fontSize',p+'%'); 111// }else { 112// $page.css('fontSize',''); 113// } 114// } 115// }, 116 // settingRwd 117 settingRwd : function(){ 118 rwdFunctions.checkValue(); 119 rwdFunctions.changeImg(); 120 rwdFunctions.loadImg(); 121 //rwdFunctions.adjustFsz(); 122 } 123} 124 125// superResize 126$.fn.superResize = function(options){ 127 var defaults = { 128 loadAction : true, 129 resizeAfter : function(){} 130 }; 131 var setting = $.extend(defaults, options); 132 133 if(setting.loadAction) 134 this.load(function(){ 135 setting.resizeAfter(); 136 }); 137 138 var timer = false, 139 w = abi.deviceWidth; 140 141 this.resize(function(){ 142 if (timer !== false) clearTimeout(timer); 143 timer = setTimeout(function(){ 144 if(w != abi.deviceWidth){ 145 setting.resizeAfter(); 146 w = abi.deviceWidth; 147 } 148 }, 300); 149 }); 150 return(this); 151}; 152 153// firstLoad 154$.fn.firstLoad = function(options){ 155 var defaults = { 156 pc : function(){}, 157 pc_tab : function(){}, 158 tab : function(){}, 159 tab_sp : function(){}, 160 sp : function(){} 161 }; 162 var setting = $.extend(defaults, options); 163 164 var first = []; 165 166 this.superResize({ 167 resizeAfter : function(){ 168 setTimeout(function(){ 169 if(first[0] != true && abi.pcView){ 170 setting.pc(); 171 first[0] = true; 172 } 173 if(first[1] != true && abi.pcView || first[1] != true && abi.tabView){ 174 setting.pc_tab(); 175 first[1] = true; 176 } 177 if(first[2] != true && abi.tabView){ 178 setting.tab(); 179 first[2] = true; 180 } 181 if(first[3] != true && abi.tabView || first[3] != true && abi.spView){ 182 setting.tab_sp(); 183 first[3] = true; 184 } 185 if(first[4] != true && abi.spView){ 186 setting.sp(); 187 first[4] = true; 188 } 189 },200); 190 } 191 }); 192 193 return(this); 194}; 195 196//hasAttr
197$.fn.hasAttr = function(name) { 198 var attr = this.attr(name); 199 if(typeof attr !== 'undefined' && attr !== false) 200 return true; 201 else 202 return false; 203} 204 205 206/* readyEvent 207------------------------------------------------------------------------*/ 208 209$(function(){ 210 211 // Settings ------------------------------// 212 $body = $('body'), 213 $page = $('#page'), 214 $changeImg = $('img.change_img'); 215 216 rwdFunctions.settingRwd(); 217 218 // ie8Img ---------------------------------// 219 if(abi.ie8) rwdFunctions.fooLoad($('img.change_img,img.load_pc,img.load_pc-tab')); 220 221 // telCancel ------------------------------// 222 //if(!abi.ua_phone) $('a[href^="tel:"]').wrapInner('<span class="tel"></span>').children('span').unwrap(); 223 224 // touching -------------------------------// 225 if(abi.ua_touch){ 226 $page.find('*').on({ 227 'touchstart' : function(){ 228 $(this).addClass('touchstart').removeClass('touchend'); 229 }, 230 'touchend' : function(){ 231 $(this).addClass('touchend').removeClass('touchstart'); 232 } 233 }); 234 } 235 236 // load & resize & scroll -----------------// 237 $w.on({ 238 'load' : function(){ 239 $w.trigger('resize').trigger('scroll'); 240 }, 241 'resize' : function(){ 242 rwdFunctions.checkValue(); 243 }, 244 'scroll' : function(){ 245 abi.sT = $w.scrollTop(); 246 } 247 }).superResize({ 248 loadAction : false, 249 resizeAfter : function(){ 250 rwdFunctions.settingRwd(); 251 } 252 }) 253 254});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.