|
|
|
@ -174,312 +174,315 @@
|
|
|
|
|
<span class='line'>167</span> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
|
|
|
|
|
<span class='line'>168</span>
|
|
|
|
|
<span class='line'>169</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tag_reg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">class_reg</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>171</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>172</span> </span><span class="NAME">tag_reg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^([\w\-]+)$/</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>173</span> </span><span class="WHIT"> </span><span class="NAME">class_reg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\.([\w\-]+)$/</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>170</span>
|
|
|
|
|
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>172</span>
|
|
|
|
|
<span class='line'>173</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tag_reg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">class_reg</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>174</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>175</span>
|
|
|
|
|
<span class='line'>176</span> </span><span class="COMM">//Private function for getting/setting attributes</span><span class="WHIT">
|
|
|
|
|
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>180</span>
|
|
|
|
|
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="COMM">//Get the value of the attribute, if it exists</span><span class="WHIT">
|
|
|
|
|
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.hasAttribute</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.hasAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.getAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>188</span>
|
|
|
|
|
<span class='line'>189</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"class"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.className</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">//className attribute</span><span class="WHIT">
|
|
|
|
|
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"className"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.className</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>202</span>
|
|
|
|
|
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="COMM">//Well, I guess that attribute doesn't exist</span><span class="WHIT">
|
|
|
|
|
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Element does not have the selected attribute"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>211</span>
|
|
|
|
|
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="COMM">//No value to set? Return the current value</span><span class="WHIT">
|
|
|
|
|
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>217</span>
|
|
|
|
|
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="COMM">//Determine what to do with the attribute</span><span class="WHIT">
|
|
|
|
|
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="NAME">sel.setAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
|
|
|
|
<span class='line'>226</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>229</span> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="NAME">sel.removeAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>236</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
|
|
|
|
<span class='line'>237</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>240</span> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>241</span>
|
|
|
|
|
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>243</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>244</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>245</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_toCamel</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/(\-[a-z])/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">$1</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$1.toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>250</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>251</span>
|
|
|
|
|
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>254</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">equi</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>255</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>256</span> </span><span class="COMM">//Camel-case</span><span class="WHIT">
|
|
|
|
|
<span class='line'>257</span> </span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_toCamel</span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>258</span>
|
|
|
|
|
<span class='line'>259</span> </span><span class="WHIT"> </span><span class="COMM">//Equivalent properties for 'special' browsers</span><span class="WHIT">
|
|
|
|
|
<span class='line'>260</span> </span><span class="WHIT"> </span><span class="NAME">equi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>261</span> </span><span class="WHIT"> </span><span class="NAME">outerHeight</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"offsetHeight"</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>262</span> </span><span class="WHIT"> </span><span class="NAME">outerWidth</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"offsetWidth"</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>263</span> </span><span class="WHIT"> </span><span class="NAME">top</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"posTop"</span><span class="WHIT">
|
|
|
|
|
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>265</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>266</span>
|
|
|
|
|
<span class='line'>267</span> </span><span class="COMM">//If you don't define a value, try returning the existing value</span><span class="WHIT">
|
|
|
|
|
<span class='line'>268</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>270</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>271</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>272</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>273</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>274</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>275</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>276</span>
|
|
|
|
|
<span class='line'>277</span> </span><span class="WHIT"> </span><span class="COMM">//Let's try the easy way first</span><span class="WHIT">
|
|
|
|
|
<span class='line'>278</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>279</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>281</span>
|
|
|
|
|
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="COMM">//Short circuit</span><span class="WHIT">
|
|
|
|
|
<span class='line'>283</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>284</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>289</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>290</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>291</span> </span><span class="COMM">//No matches? Well, lets log it for now</span><span class="WHIT">
|
|
|
|
|
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Property "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" nor an equivalent seems to exist"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>293</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>294</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>295</span> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
|
|
|
|
|
<span class='line'>296</span>
|
|
|
|
|
<span class='line'>297</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>298</span> * DOM
|
|
|
|
|
<span class='line'>299</span> *
|
|
|
|
|
<span class='line'>300</span> * Dom manipulation module
|
|
|
|
|
<span class='line'>301</span> * @namespace
|
|
|
|
|
<span class='line'>302</span> * @memberOf $_
|
|
|
|
|
<span class='line'>303</span> * @name dom
|
|
|
|
|
<span class='line'>304</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>305</span> </span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>306</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>307</span> * Adds a class to the element(s) specified by the current
|
|
|
|
|
<span class='line'>308</span> * selector
|
|
|
|
|
<span class='line'>309</span> *
|
|
|
|
|
<span class='line'>310</span> * @name addClass
|
|
|
|
|
<span class='line'>311</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>312</span> * @function
|
|
|
|
|
<span class='line'>313</span> * @param string class
|
|
|
|
|
<span class='line'>314</span> * @return void
|
|
|
|
|
<span class='line'>315</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>316</span> </span><span class="WHIT"> </span><span class="NAME">addClass</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>317</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>318</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>319</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.add</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>320</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>321</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>322</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>323</span> * Removes a class from the element(s) specified by the current
|
|
|
|
|
<span class='line'>324</span> * selector
|
|
|
|
|
<span class='line'>325</span> *
|
|
|
|
|
<span class='line'>326</span> * @name removeClass
|
|
|
|
|
<span class='line'>327</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>328</span> * @function
|
|
|
|
|
<span class='line'>329</span> * @param string class
|
|
|
|
|
<span class='line'>330</span> * @return void
|
|
|
|
|
<span class='line'>331</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>332</span> </span><span class="WHIT"> </span><span class="NAME">removeClass</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>333</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>334</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>335</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.remove</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>336</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>337</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>338</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>339</span> * Hides the element(s) specified by the current selector
|
|
|
|
|
<span class='line'>340</span> *
|
|
|
|
|
<span class='line'>341</span> * @name hide
|
|
|
|
|
<span class='line'>342</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>343</span> * @function
|
|
|
|
|
<span class='line'>344</span> * @return void
|
|
|
|
|
<span class='line'>345</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>346</span> </span><span class="WHIT"> </span><span class="NAME">hide</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>347</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>348</span> </span><span class="WHIT"> </span><span class="NAME">this.css</span><span class="PUNC">(</span><span class="STRN">'display'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'none'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>349</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>350</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>351</span> * Shows the element(s) specified by the current selector.
|
|
|
|
|
<span class='line'>352</span> * if type is specified, the element will have it's style
|
|
|
|
|
<span class='line'>353</span> * property set to "display:[your type]". If type is not
|
|
|
|
|
<span class='line'>354</span> * specified, the element is set to "display:block".
|
|
|
|
|
<span class='line'>355</span> *
|
|
|
|
|
<span class='line'>356</span> * @name show
|
|
|
|
|
<span class='line'>357</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>358</span> * @function
|
|
|
|
|
<span class='line'>359</span> * @param [string] type
|
|
|
|
|
<span class='line'>360</span> * @return void
|
|
|
|
|
<span class='line'>361</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>362</span> </span><span class="WHIT"> </span><span class="NAME">show</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>363</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>364</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>365</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>366</span> </span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"block"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>367</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>368</span>
|
|
|
|
|
<span class='line'>369</span> </span><span class="WHIT"> </span><span class="NAME">this.css</span><span class="PUNC">(</span><span class="STRN">"display"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>370</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>371</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>372</span> * Sets attributes on element(s) specified by the current
|
|
|
|
|
<span class='line'>373</span> * selector, or, if name is not specified, returns the
|
|
|
|
|
<span class='line'>374</span> * value of the attribute of the element specified by the
|
|
|
|
|
<span class='line'>375</span> * current selector.
|
|
|
|
|
<span class='line'>376</span> *
|
|
|
|
|
<span class='line'>377</span> * @name attr
|
|
|
|
|
<span class='line'>378</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>379</span> * @function
|
|
|
|
|
<span class='line'>380</span> * @param string name
|
|
|
|
|
<span class='line'>381</span> * @param string value
|
|
|
|
|
<span class='line'>382</span> * @return string
|
|
|
|
|
<span class='line'>383</span> * @type string
|
|
|
|
|
<span class='line'>384</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>385</span> </span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>386</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>387</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>388</span>
|
|
|
|
|
<span class='line'>389</span> </span><span class="WHIT"> </span><span class="COMM">//Make sure you don't try to get a bunch of elements</span><span class="WHIT">
|
|
|
|
|
<span class='line'>390</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>391</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>392</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>393</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Must be a singular element"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>394</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>395</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>396</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">//You can set a bunch, though</span><span class="WHIT">
|
|
|
|
|
<span class='line'>397</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>398</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>399</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>400</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>401</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>402</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="COMM">//Normal behavior</span><span class="WHIT">
|
|
|
|
|
<span class='line'>403</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>404</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>405</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>406</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>407</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>408</span> * Sets or retrieves the text content of the element
|
|
|
|
|
<span class='line'>409</span> * specified by the current selector. If a value is
|
|
|
|
|
<span class='line'>410</span> * passed, it will set that value on the current element,
|
|
|
|
|
<span class='line'>411</span> * otherwise it will return the value of the current element
|
|
|
|
|
<span class='line'>412</span> *
|
|
|
|
|
<span class='line'>413</span> * @name text
|
|
|
|
|
<span class='line'>414</span> * @memberOf $_.util
|
|
|
|
|
<span class='line'>415</span> * @function
|
|
|
|
|
<span class='line'>416</span> * @param [string] value
|
|
|
|
|
<span class='line'>417</span> * @returns string
|
|
|
|
|
<span class='line'>418</span> * @type string
|
|
|
|
|
<span class='line'>419</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>420</span> </span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>421</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>422</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">set</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>423</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>424</span> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>425</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>426</span> </span><span class="NAME">set</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>427</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>428</span> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.innerText</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>429</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"innerText"</span><span class="WHIT">
|
|
|
|
|
<span class='line'>430</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.textContent</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>431</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"textContent"</span><span class="WHIT">
|
|
|
|
|
<span class='line'>432</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"innerHTML"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>433</span>
|
|
|
|
|
<span class='line'>434</span> </span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>435</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>436</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">set</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>437</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>438</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>439</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>440</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>441</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
|
|
|
|
<span class='line'>442</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>443</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>444</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>445</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>446</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>447</span> * Sets or retrieves a css property of the element
|
|
|
|
|
<span class='line'>448</span> * specified by the current selector. If a value is
|
|
|
|
|
<span class='line'>449</span> * passed, it will set that value on the current element,
|
|
|
|
|
<span class='line'>450</span> * otherwise it will return the value of the css property
|
|
|
|
|
<span class='line'>451</span> * on the current element
|
|
|
|
|
<span class='line'>452</span> *
|
|
|
|
|
<span class='line'>453</span> * @name css
|
|
|
|
|
<span class='line'>454</span> * @memberOf $_.util
|
|
|
|
|
<span class='line'>455</span> * @function
|
|
|
|
|
<span class='line'>456</span> * @param string property
|
|
|
|
|
<span class='line'>457</span> * @param [string] value
|
|
|
|
|
<span class='line'>458</span> * @returns string
|
|
|
|
|
<span class='line'>459</span> * @type string
|
|
|
|
|
<span class='line'>460</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>461</span> </span><span class="WHIT"> </span><span class="NAME">css</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>462</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>463</span> </span><span class="WHIT"> </span><span class="COMM">//Return the current value if a value is not set</span><span class="WHIT">
|
|
|
|
|
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>465</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>466</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">this.el</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>468</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>469</span> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>470</span> </span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>471</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>472</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>473</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>474</span>
|
|
|
|
|
<span class='line'>475</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'dom'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>476</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>477</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>478</span> </span></pre></body></html>
|
|
|
|
|
<span class='line'>175</span> </span><span class="NAME">tag_reg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^([\w\-]+)$/</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="NAME">class_reg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\.([\w\-]+)$/</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>177</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>178</span>
|
|
|
|
|
<span class='line'>179</span> </span><span class="COMM">//Private function for getting/setting attributes</span><span class="WHIT">
|
|
|
|
|
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>183</span>
|
|
|
|
|
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="COMM">//Get the value of the attribute, if it exists</span><span class="WHIT">
|
|
|
|
|
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.hasAttribute</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.hasAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>188</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>189</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.getAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>191</span>
|
|
|
|
|
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"class"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.className</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">//className attribute</span><span class="WHIT">
|
|
|
|
|
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"className"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.className</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>205</span>
|
|
|
|
|
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">//Well, I guess that attribute doesn't exist</span><span class="WHIT">
|
|
|
|
|
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Element does not have the selected attribute"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>214</span>
|
|
|
|
|
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="COMM">//No value to set? Return the current value</span><span class="WHIT">
|
|
|
|
|
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>220</span>
|
|
|
|
|
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="COMM">//Determine what to do with the attribute</span><span class="WHIT">
|
|
|
|
|
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>226</span> </span><span class="WHIT"> </span><span class="NAME">sel.setAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
|
|
|
|
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>232</span> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>236</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>237</span> </span><span class="WHIT"> </span><span class="NAME">sel.removeAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
|
|
|
|
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>241</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>243</span> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>244</span>
|
|
|
|
|
<span class='line'>245</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>247</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>248</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_toCamel</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>250</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/(\-[a-z])/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">$1</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>251</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$1.toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>254</span>
|
|
|
|
|
<span class='line'>255</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>256</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>257</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">equi</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>258</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>259</span> </span><span class="COMM">//Camel-case</span><span class="WHIT">
|
|
|
|
|
<span class='line'>260</span> </span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_toCamel</span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>261</span>
|
|
|
|
|
<span class='line'>262</span> </span><span class="WHIT"> </span><span class="COMM">//Equivalent properties for 'special' browsers</span><span class="WHIT">
|
|
|
|
|
<span class='line'>263</span> </span><span class="WHIT"> </span><span class="NAME">equi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="NAME">outerHeight</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"offsetHeight"</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>265</span> </span><span class="WHIT"> </span><span class="NAME">outerWidth</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"offsetWidth"</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>266</span> </span><span class="WHIT"> </span><span class="NAME">top</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"posTop"</span><span class="WHIT">
|
|
|
|
|
<span class='line'>267</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>268</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>269</span>
|
|
|
|
|
<span class='line'>270</span> </span><span class="COMM">//If you don't define a value, try returning the existing value</span><span class="WHIT">
|
|
|
|
|
<span class='line'>271</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>272</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>273</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>274</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>275</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>276</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>277</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>278</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>279</span>
|
|
|
|
|
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="COMM">//Let's try the easy way first</span><span class="WHIT">
|
|
|
|
|
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>283</span> </span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>284</span>
|
|
|
|
|
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="COMM">//Short circuit</span><span class="WHIT">
|
|
|
|
|
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>289</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>290</span> </span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>291</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>293</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>294</span> </span><span class="COMM">//No matches? Well, lets log it for now</span><span class="WHIT">
|
|
|
|
|
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Property "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" nor an equivalent seems to exist"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>297</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>298</span> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
|
|
|
|
|
<span class='line'>299</span>
|
|
|
|
|
<span class='line'>300</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>301</span> * DOM
|
|
|
|
|
<span class='line'>302</span> *
|
|
|
|
|
<span class='line'>303</span> * Dom manipulation module
|
|
|
|
|
<span class='line'>304</span> * @namespace
|
|
|
|
|
<span class='line'>305</span> * @memberOf $_
|
|
|
|
|
<span class='line'>306</span> * @name dom
|
|
|
|
|
<span class='line'>307</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>308</span> </span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>309</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>310</span> * Adds a class to the element(s) specified by the current
|
|
|
|
|
<span class='line'>311</span> * selector
|
|
|
|
|
<span class='line'>312</span> *
|
|
|
|
|
<span class='line'>313</span> * @name addClass
|
|
|
|
|
<span class='line'>314</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>315</span> * @function
|
|
|
|
|
<span class='line'>316</span> * @param string class
|
|
|
|
|
<span class='line'>317</span> * @return void
|
|
|
|
|
<span class='line'>318</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>319</span> </span><span class="WHIT"> </span><span class="NAME">addClass</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>320</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>321</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>322</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.add</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>323</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>324</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>325</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>326</span> * Removes a class from the element(s) specified by the current
|
|
|
|
|
<span class='line'>327</span> * selector
|
|
|
|
|
<span class='line'>328</span> *
|
|
|
|
|
<span class='line'>329</span> * @name removeClass
|
|
|
|
|
<span class='line'>330</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>331</span> * @function
|
|
|
|
|
<span class='line'>332</span> * @param string class
|
|
|
|
|
<span class='line'>333</span> * @return void
|
|
|
|
|
<span class='line'>334</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>335</span> </span><span class="WHIT"> </span><span class="NAME">removeClass</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>336</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>337</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>338</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.remove</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>339</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>340</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>341</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>342</span> * Hides the element(s) specified by the current selector
|
|
|
|
|
<span class='line'>343</span> *
|
|
|
|
|
<span class='line'>344</span> * @name hide
|
|
|
|
|
<span class='line'>345</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>346</span> * @function
|
|
|
|
|
<span class='line'>347</span> * @return void
|
|
|
|
|
<span class='line'>348</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>349</span> </span><span class="WHIT"> </span><span class="NAME">hide</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>350</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>351</span> </span><span class="WHIT"> </span><span class="NAME">this.css</span><span class="PUNC">(</span><span class="STRN">'display'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'none'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>352</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>353</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>354</span> * Shows the element(s) specified by the current selector.
|
|
|
|
|
<span class='line'>355</span> * if type is specified, the element will have it's style
|
|
|
|
|
<span class='line'>356</span> * property set to "display:[your type]". If type is not
|
|
|
|
|
<span class='line'>357</span> * specified, the element is set to "display:block".
|
|
|
|
|
<span class='line'>358</span> *
|
|
|
|
|
<span class='line'>359</span> * @name show
|
|
|
|
|
<span class='line'>360</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>361</span> * @function
|
|
|
|
|
<span class='line'>362</span> * @param [string] type
|
|
|
|
|
<span class='line'>363</span> * @return void
|
|
|
|
|
<span class='line'>364</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>365</span> </span><span class="WHIT"> </span><span class="NAME">show</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>366</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>367</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>368</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>369</span> </span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"block"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>370</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>371</span>
|
|
|
|
|
<span class='line'>372</span> </span><span class="WHIT"> </span><span class="NAME">this.css</span><span class="PUNC">(</span><span class="STRN">"display"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>373</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>374</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>375</span> * Sets attributes on element(s) specified by the current
|
|
|
|
|
<span class='line'>376</span> * selector, or, if name is not specified, returns the
|
|
|
|
|
<span class='line'>377</span> * value of the attribute of the element specified by the
|
|
|
|
|
<span class='line'>378</span> * current selector.
|
|
|
|
|
<span class='line'>379</span> *
|
|
|
|
|
<span class='line'>380</span> * @name attr
|
|
|
|
|
<span class='line'>381</span> * @memberOf $_.dom
|
|
|
|
|
<span class='line'>382</span> * @function
|
|
|
|
|
<span class='line'>383</span> * @param string name
|
|
|
|
|
<span class='line'>384</span> * @param string value
|
|
|
|
|
<span class='line'>385</span> * @return string
|
|
|
|
|
<span class='line'>386</span> * @type string
|
|
|
|
|
<span class='line'>387</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>388</span> </span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>389</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>390</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>391</span>
|
|
|
|
|
<span class='line'>392</span> </span><span class="WHIT"> </span><span class="COMM">//Make sure you don't try to get a bunch of elements</span><span class="WHIT">
|
|
|
|
|
<span class='line'>393</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>394</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>395</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>396</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Must be a singular element"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>397</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>398</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>399</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">//You can set a bunch, though</span><span class="WHIT">
|
|
|
|
|
<span class='line'>400</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>401</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>402</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>403</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>404</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>405</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="COMM">//Normal behavior</span><span class="WHIT">
|
|
|
|
|
<span class='line'>406</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>407</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>408</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>409</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>410</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>411</span> * Sets or retrieves the text content of the element
|
|
|
|
|
<span class='line'>412</span> * specified by the current selector. If a value is
|
|
|
|
|
<span class='line'>413</span> * passed, it will set that value on the current element,
|
|
|
|
|
<span class='line'>414</span> * otherwise it will return the value of the current element
|
|
|
|
|
<span class='line'>415</span> *
|
|
|
|
|
<span class='line'>416</span> * @name text
|
|
|
|
|
<span class='line'>417</span> * @memberOf $_.util
|
|
|
|
|
<span class='line'>418</span> * @function
|
|
|
|
|
<span class='line'>419</span> * @param [string] value
|
|
|
|
|
<span class='line'>420</span> * @returns string
|
|
|
|
|
<span class='line'>421</span> * @type string
|
|
|
|
|
<span class='line'>422</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>423</span> </span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>424</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>425</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">set</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>426</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>427</span> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>428</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>429</span> </span><span class="NAME">set</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>430</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>431</span> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.innerText</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>432</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"innerText"</span><span class="WHIT">
|
|
|
|
|
<span class='line'>433</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.textContent</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>434</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"textContent"</span><span class="WHIT">
|
|
|
|
|
<span class='line'>435</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"innerHTML"</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>436</span>
|
|
|
|
|
<span class='line'>437</span> </span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>438</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>439</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">set</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>440</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>441</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>442</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>443</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>444</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
|
|
|
|
<span class='line'>445</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>446</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>447</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>448</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
|
|
|
|
<span class='line'>449</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
|
|
|
|
<span class='line'>450</span> * Sets or retrieves a css property of the element
|
|
|
|
|
<span class='line'>451</span> * specified by the current selector. If a value is
|
|
|
|
|
<span class='line'>452</span> * passed, it will set that value on the current element,
|
|
|
|
|
<span class='line'>453</span> * otherwise it will return the value of the css property
|
|
|
|
|
<span class='line'>454</span> * on the current element
|
|
|
|
|
<span class='line'>455</span> *
|
|
|
|
|
<span class='line'>456</span> * @name css
|
|
|
|
|
<span class='line'>457</span> * @memberOf $_.util
|
|
|
|
|
<span class='line'>458</span> * @function
|
|
|
|
|
<span class='line'>459</span> * @param string property
|
|
|
|
|
<span class='line'>460</span> * @param [string] value
|
|
|
|
|
<span class='line'>461</span> * @returns string
|
|
|
|
|
<span class='line'>462</span> * @type string
|
|
|
|
|
<span class='line'>463</span> */</span><span class="WHIT">
|
|
|
|
|
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="NAME">css</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>465</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>466</span> </span><span class="WHIT"> </span><span class="COMM">//Return the current value if a value is not set</span><span class="WHIT">
|
|
|
|
|
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
|
|
|
|
<span class='line'>468</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>469</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">this.el</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>470</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>471</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>472</span> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
|
|
|
|
<span class='line'>473</span> </span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>474</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>475</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
|
|
|
|
<span class='line'>476</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>477</span>
|
|
|
|
|
<span class='line'>478</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'dom'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>479</span> </span><span class="WHIT">
|
|
|
|
|
<span class='line'>480</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
|
|
|
|
<span class='line'>481</span> </span></pre></body></html>
|