You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
/*
|
|
|
* Metadata - jQuery plugin for parsing metadata from elements
|
|
|
*
|
|
|
* Copyright (c) 2006 John Resig, Yehuda Katz, J<>örn Zaefferer, Paul McLanahan
|
|
|
*
|
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
|
*
|
|
|
* Revision: $Id: jquery.metadata.js 3620 2007-10-10 20:55:38Z pmclanahan $
|
|
|
*
|
|
|
*/
|
|
|
(function($){$.extend({metadata:{defaults:{type:'class',name:'metadata',cre:/({.*})/,single:'metadata'},setType:function(type,name){this.defaults.type=type;this.defaults.name=name;},get:function(elem,opts){var settings=$.extend({},this.defaults,opts);if(!settings.single.length)settings.single='metadata';var data=$.data(elem,settings.single);if(data)return data;data="{}";if(settings.type=="class"){var m=settings.cre.exec(elem.className);if(m)data=m[1];}else if(settings.type=="elem"){if(!elem.getElementsByTagName)return;var e=elem.getElementsByTagName(settings.name);if(e.length)data=$.trim(e[0].innerHTML);}else if(elem.getAttribute!=undefined){var attr=elem.getAttribute(settings.name);if(attr)data=attr;}if(data.indexOf('{')<0)data="{"+data+"}";data=eval("("+data+")");$.data(elem,settings.single,data);return data;}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts);};})(jQuery); |